]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blame - test/grsecurity-3.1-4.2.4-201510222059.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.1-4.2.4-201510222059.patch
CommitLineData
31a7c07c
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 13f888a..250729b 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 1d6f045..2714987 100644
317--- a/Documentation/kernel-parameters.txt
318+++ b/Documentation/kernel-parameters.txt
319@@ -1244,6 +1244,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@@ -2364,6 +2371,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@@ -2662,6 +2673,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 6fccb69..60c7c7a 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 a952801..9da1dcb 100644
410--- a/Makefile
411+++ b/Makefile
412@@ -298,7 +298,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@@ -434,8 +436,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@@ -615,6 +617,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@@ -714,7 +784,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@@ -886,7 +956,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@@ -936,6 +1006,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@@ -945,7 +1017,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@@ -988,10 +1060,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@@ -1099,6 +1174,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@@ -1114,7 +1191,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@@ -1180,7 +1257,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@@ -1219,7 +1299,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@@ -1385,6 +1465,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@@ -1525,17 +1607,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@@ -1547,11 +1633,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 4a905bd..0a4da53 100644
823--- a/arch/alpha/mm/fault.c
824+++ b/arch/alpha/mm/fault.c
825@@ -52,6 +52,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@@ -132,8 +250,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/arc/Kconfig b/arch/arc/Kconfig
982index bd4670d..920c97a 100644
983--- a/arch/arc/Kconfig
984+++ b/arch/arc/Kconfig
985@@ -485,6 +485,7 @@ config ARC_DBG_TLB_MISS_COUNT
986 bool "Profile TLB Misses"
987 default n
988 select DEBUG_FS
989+ depends on !GRKERNSEC_KMEM
990 help
991 Counts number of I and D TLB Misses and exports them via Debugfs
992 The counters can be cleared via Debugfs as well
993diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
994index ede2526..9e12300 100644
995--- a/arch/arm/Kconfig
996+++ b/arch/arm/Kconfig
997@@ -1770,7 +1770,7 @@ config ALIGNMENT_TRAP
998
999 config UACCESS_WITH_MEMCPY
1000 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
1001- depends on MMU
1002+ depends on MMU && !PAX_MEMORY_UDEREF
1003 default y if CPU_FEROCEON
1004 help
1005 Implement faster copy_to_user and clear_user methods for CPU
1006@@ -2006,6 +2006,7 @@ config KEXEC
1007 bool "Kexec system call (EXPERIMENTAL)"
1008 depends on (!SMP || PM_SLEEP_SMP)
1009 depends on !CPU_V7M
1010+ depends on !GRKERNSEC_KMEM
1011 help
1012 kexec is a system call that implements the ability to shutdown your
1013 current kernel, and to start another kernel. It is like a reboot
1014diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
1015index a2e16f9..b26e911 100644
1016--- a/arch/arm/Kconfig.debug
1017+++ b/arch/arm/Kconfig.debug
1018@@ -7,6 +7,7 @@ config ARM_PTDUMP
1019 depends on DEBUG_KERNEL
1020 depends on MMU
1021 select DEBUG_FS
1022+ depends on !GRKERNSEC_KMEM
1023 ---help---
1024 Say Y here if you want to show the kernel pagetable layout in a
1025 debugfs file. This information is only useful for kernel developers
1026diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
1027index e22c119..abe7041 100644
1028--- a/arch/arm/include/asm/atomic.h
1029+++ b/arch/arm/include/asm/atomic.h
1030@@ -18,17 +18,41 @@
1031 #include <asm/barrier.h>
1032 #include <asm/cmpxchg.h>
1033
1034+#ifdef CONFIG_GENERIC_ATOMIC64
1035+#include <asm-generic/atomic64.h>
1036+#endif
1037+
1038 #define ATOMIC_INIT(i) { (i) }
1039
1040 #ifdef __KERNEL__
1041
1042+#ifdef CONFIG_THUMB2_KERNEL
1043+#define REFCOUNT_TRAP_INSN "bkpt 0xf1"
1044+#else
1045+#define REFCOUNT_TRAP_INSN "bkpt 0xf103"
1046+#endif
1047+
1048+#define _ASM_EXTABLE(from, to) \
1049+" .pushsection __ex_table,\"a\"\n"\
1050+" .align 3\n" \
1051+" .long " #from ", " #to"\n" \
1052+" .popsection"
1053+
1054 /*
1055 * On ARM, ordinary assignment (str instruction) doesn't clear the local
1056 * strex/ldrex monitor on some implementations. The reason we can use it for
1057 * atomic_set() is the clrex or dummy strex done on every exception return.
1058 */
1059 #define atomic_read(v) ACCESS_ONCE((v)->counter)
1060+static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
1061+{
1062+ return ACCESS_ONCE(v->counter);
1063+}
1064 #define atomic_set(v,i) (((v)->counter) = (i))
1065+static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
1066+{
1067+ v->counter = i;
1068+}
1069
1070 #if __LINUX_ARM_ARCH__ >= 6
1071
1072@@ -38,26 +62,50 @@
1073 * to ensure that the update happens.
1074 */
1075
1076-#define ATOMIC_OP(op, c_op, asm_op) \
1077-static inline void atomic_##op(int i, atomic_t *v) \
1078+#ifdef CONFIG_PAX_REFCOUNT
1079+#define __OVERFLOW_POST \
1080+ " bvc 3f\n" \
1081+ "2: " REFCOUNT_TRAP_INSN "\n"\
1082+ "3:\n"
1083+#define __OVERFLOW_POST_RETURN \
1084+ " bvc 3f\n" \
1085+" mov %0, %1\n" \
1086+ "2: " REFCOUNT_TRAP_INSN "\n"\
1087+ "3:\n"
1088+#define __OVERFLOW_EXTABLE \
1089+ "4:\n" \
1090+ _ASM_EXTABLE(2b, 4b)
1091+#else
1092+#define __OVERFLOW_POST
1093+#define __OVERFLOW_POST_RETURN
1094+#define __OVERFLOW_EXTABLE
1095+#endif
1096+
1097+#define __ATOMIC_OP(op, suffix, c_op, asm_op, post_op, extable) \
1098+static inline void atomic_##op##suffix(int i, atomic##suffix##_t *v) \
1099 { \
1100 unsigned long tmp; \
1101 int result; \
1102 \
1103 prefetchw(&v->counter); \
1104- __asm__ __volatile__("@ atomic_" #op "\n" \
1105+ __asm__ __volatile__("@ atomic_" #op #suffix "\n" \
1106 "1: ldrex %0, [%3]\n" \
1107 " " #asm_op " %0, %0, %4\n" \
1108+ post_op \
1109 " strex %1, %0, [%3]\n" \
1110 " teq %1, #0\n" \
1111-" bne 1b" \
1112+" bne 1b\n" \
1113+ extable \
1114 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) \
1115 : "r" (&v->counter), "Ir" (i) \
1116 : "cc"); \
1117 } \
1118
1119-#define ATOMIC_OP_RETURN(op, c_op, asm_op) \
1120-static inline int atomic_##op##_return(int i, atomic_t *v) \
1121+#define ATOMIC_OP(op, c_op, asm_op) __ATOMIC_OP(op, _unchecked, c_op, asm_op, , )\
1122+ __ATOMIC_OP(op, , c_op, asm_op##s, __OVERFLOW_POST, __OVERFLOW_EXTABLE)
1123+
1124+#define __ATOMIC_OP_RETURN(op, suffix, c_op, asm_op, post_op, extable) \
1125+static inline int atomic_##op##_return##suffix(int i, atomic##suffix##_t *v)\
1126 { \
1127 unsigned long tmp; \
1128 int result; \
1129@@ -65,12 +113,14 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \
1130 smp_mb(); \
1131 prefetchw(&v->counter); \
1132 \
1133- __asm__ __volatile__("@ atomic_" #op "_return\n" \
1134+ __asm__ __volatile__("@ atomic_" #op "_return" #suffix "\n" \
1135 "1: ldrex %0, [%3]\n" \
1136 " " #asm_op " %0, %0, %4\n" \
1137+ post_op \
1138 " strex %1, %0, [%3]\n" \
1139 " teq %1, #0\n" \
1140-" bne 1b" \
1141+" bne 1b\n" \
1142+ extable \
1143 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) \
1144 : "r" (&v->counter), "Ir" (i) \
1145 : "cc"); \
1146@@ -80,6 +130,9 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \
1147 return result; \
1148 }
1149
1150+#define ATOMIC_OP_RETURN(op, c_op, asm_op) __ATOMIC_OP_RETURN(op, _unchecked, c_op, asm_op, , )\
1151+ __ATOMIC_OP_RETURN(op, , c_op, asm_op##s, __OVERFLOW_POST_RETURN, __OVERFLOW_EXTABLE)
1152+
1153 static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1154 {
1155 int oldval;
1156@@ -115,12 +168,24 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1157 __asm__ __volatile__ ("@ atomic_add_unless\n"
1158 "1: ldrex %0, [%4]\n"
1159 " teq %0, %5\n"
1160-" beq 2f\n"
1161-" add %1, %0, %6\n"
1162+" beq 4f\n"
1163+" adds %1, %0, %6\n"
1164+
1165+#ifdef CONFIG_PAX_REFCOUNT
1166+" bvc 3f\n"
1167+"2: " REFCOUNT_TRAP_INSN "\n"
1168+"3:\n"
1169+#endif
1170+
1171 " strex %2, %1, [%4]\n"
1172 " teq %2, #0\n"
1173 " bne 1b\n"
1174-"2:"
1175+"4:"
1176+
1177+#ifdef CONFIG_PAX_REFCOUNT
1178+ _ASM_EXTABLE(2b, 4b)
1179+#endif
1180+
1181 : "=&r" (oldval), "=&r" (newval), "=&r" (tmp), "+Qo" (v->counter)
1182 : "r" (&v->counter), "r" (u), "r" (a)
1183 : "cc");
1184@@ -131,14 +196,36 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1185 return oldval;
1186 }
1187
1188+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1189+{
1190+ unsigned long oldval, res;
1191+
1192+ smp_mb();
1193+
1194+ do {
1195+ __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1196+ "ldrex %1, [%3]\n"
1197+ "mov %0, #0\n"
1198+ "teq %1, %4\n"
1199+ "strexeq %0, %5, [%3]\n"
1200+ : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1201+ : "r" (&ptr->counter), "Ir" (old), "r" (new)
1202+ : "cc");
1203+ } while (res);
1204+
1205+ smp_mb();
1206+
1207+ return oldval;
1208+}
1209+
1210 #else /* ARM_ARCH_6 */
1211
1212 #ifdef CONFIG_SMP
1213 #error SMP not supported on pre-ARMv6 CPUs
1214 #endif
1215
1216-#define ATOMIC_OP(op, c_op, asm_op) \
1217-static inline void atomic_##op(int i, atomic_t *v) \
1218+#define __ATOMIC_OP(op, suffix, c_op, asm_op) \
1219+static inline void atomic_##op##suffix(int i, atomic##suffix##_t *v) \
1220 { \
1221 unsigned long flags; \
1222 \
1223@@ -147,8 +234,11 @@ static inline void atomic_##op(int i, atomic_t *v) \
1224 raw_local_irq_restore(flags); \
1225 } \
1226
1227-#define ATOMIC_OP_RETURN(op, c_op, asm_op) \
1228-static inline int atomic_##op##_return(int i, atomic_t *v) \
1229+#define ATOMIC_OP(op, c_op, asm_op) __ATOMIC_OP(op, , c_op, asm_op) \
1230+ __ATOMIC_OP(op, _unchecked, c_op, asm_op)
1231+
1232+#define __ATOMIC_OP_RETURN(op, suffix, c_op, asm_op) \
1233+static inline int atomic_##op##_return##suffix(int i, atomic##suffix##_t *v)\
1234 { \
1235 unsigned long flags; \
1236 int val; \
1237@@ -161,6 +251,9 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \
1238 return val; \
1239 }
1240
1241+#define ATOMIC_OP_RETURN(op, c_op, asm_op) __ATOMIC_OP_RETURN(op, , c_op, asm_op)\
1242+ __ATOMIC_OP_RETURN(op, _unchecked, c_op, asm_op)
1243+
1244 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1245 {
1246 int ret;
1247@@ -175,6 +268,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1248 return ret;
1249 }
1250
1251+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1252+{
1253+ return atomic_cmpxchg((atomic_t *)v, old, new);
1254+}
1255+
1256 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1257 {
1258 int c, old;
1259@@ -196,16 +294,38 @@ ATOMIC_OPS(sub, -=, sub)
1260
1261 #undef ATOMIC_OPS
1262 #undef ATOMIC_OP_RETURN
1263+#undef __ATOMIC_OP_RETURN
1264 #undef ATOMIC_OP
1265+#undef __ATOMIC_OP
1266
1267 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1268+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1269+{
1270+ return xchg(&v->counter, new);
1271+}
1272
1273 #define atomic_inc(v) atomic_add(1, v)
1274+static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1275+{
1276+ atomic_add_unchecked(1, v);
1277+}
1278 #define atomic_dec(v) atomic_sub(1, v)
1279+static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1280+{
1281+ atomic_sub_unchecked(1, v);
1282+}
1283
1284 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1285+static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1286+{
1287+ return atomic_add_return_unchecked(1, v) == 0;
1288+}
1289 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1290 #define atomic_inc_return(v) (atomic_add_return(1, v))
1291+static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1292+{
1293+ return atomic_add_return_unchecked(1, v);
1294+}
1295 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1296 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1297
1298@@ -216,6 +336,14 @@ typedef struct {
1299 long long counter;
1300 } atomic64_t;
1301
1302+#ifdef CONFIG_PAX_REFCOUNT
1303+typedef struct {
1304+ long long counter;
1305+} atomic64_unchecked_t;
1306+#else
1307+typedef atomic64_t atomic64_unchecked_t;
1308+#endif
1309+
1310 #define ATOMIC64_INIT(i) { (i) }
1311
1312 #ifdef CONFIG_ARM_LPAE
1313@@ -232,6 +360,19 @@ static inline long long atomic64_read(const atomic64_t *v)
1314 return result;
1315 }
1316
1317+static inline long long atomic64_read_unchecked(const atomic64_unchecked_t *v)
1318+{
1319+ long long result;
1320+
1321+ __asm__ __volatile__("@ atomic64_read_unchecked\n"
1322+" ldrd %0, %H0, [%1]"
1323+ : "=&r" (result)
1324+ : "r" (&v->counter), "Qo" (v->counter)
1325+ );
1326+
1327+ return result;
1328+}
1329+
1330 static inline void atomic64_set(atomic64_t *v, long long i)
1331 {
1332 __asm__ __volatile__("@ atomic64_set\n"
1333@@ -240,6 +381,15 @@ static inline void atomic64_set(atomic64_t *v, long long i)
1334 : "r" (&v->counter), "r" (i)
1335 );
1336 }
1337+
1338+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
1339+{
1340+ __asm__ __volatile__("@ atomic64_set_unchecked\n"
1341+" strd %2, %H2, [%1]"
1342+ : "=Qo" (v->counter)
1343+ : "r" (&v->counter), "r" (i)
1344+ );
1345+}
1346 #else
1347 static inline long long atomic64_read(const atomic64_t *v)
1348 {
1349@@ -254,6 +404,19 @@ static inline long long atomic64_read(const atomic64_t *v)
1350 return result;
1351 }
1352
1353+static inline long long atomic64_read_unchecked(const atomic64_unchecked_t *v)
1354+{
1355+ long long result;
1356+
1357+ __asm__ __volatile__("@ atomic64_read_unchecked\n"
1358+" ldrexd %0, %H0, [%1]"
1359+ : "=&r" (result)
1360+ : "r" (&v->counter), "Qo" (v->counter)
1361+ );
1362+
1363+ return result;
1364+}
1365+
1366 static inline void atomic64_set(atomic64_t *v, long long i)
1367 {
1368 long long tmp;
1369@@ -268,29 +431,57 @@ static inline void atomic64_set(atomic64_t *v, long long i)
1370 : "r" (&v->counter), "r" (i)
1371 : "cc");
1372 }
1373+
1374+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
1375+{
1376+ long long tmp;
1377+
1378+ prefetchw(&v->counter);
1379+ __asm__ __volatile__("@ atomic64_set_unchecked\n"
1380+"1: ldrexd %0, %H0, [%2]\n"
1381+" strexd %0, %3, %H3, [%2]\n"
1382+" teq %0, #0\n"
1383+" bne 1b"
1384+ : "=&r" (tmp), "=Qo" (v->counter)
1385+ : "r" (&v->counter), "r" (i)
1386+ : "cc");
1387+}
1388 #endif
1389
1390-#define ATOMIC64_OP(op, op1, op2) \
1391-static inline void atomic64_##op(long long i, atomic64_t *v) \
1392+#undef __OVERFLOW_POST_RETURN
1393+#define __OVERFLOW_POST_RETURN \
1394+ " bvc 3f\n" \
1395+" mov %0, %1\n" \
1396+" mov %H0, %H1\n" \
1397+ "2: " REFCOUNT_TRAP_INSN "\n"\
1398+ "3:\n"
1399+
1400+#define __ATOMIC64_OP(op, suffix, op1, op2, post_op, extable) \
1401+static inline void atomic64_##op##suffix(long long i, atomic64##suffix##_t *v)\
1402 { \
1403 long long result; \
1404 unsigned long tmp; \
1405 \
1406 prefetchw(&v->counter); \
1407- __asm__ __volatile__("@ atomic64_" #op "\n" \
1408+ __asm__ __volatile__("@ atomic64_" #op #suffix "\n" \
1409 "1: ldrexd %0, %H0, [%3]\n" \
1410 " " #op1 " %Q0, %Q0, %Q4\n" \
1411 " " #op2 " %R0, %R0, %R4\n" \
1412+ post_op \
1413 " strexd %1, %0, %H0, [%3]\n" \
1414 " teq %1, #0\n" \
1415-" bne 1b" \
1416+" bne 1b\n" \
1417+ extable \
1418 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) \
1419 : "r" (&v->counter), "r" (i) \
1420 : "cc"); \
1421 } \
1422
1423-#define ATOMIC64_OP_RETURN(op, op1, op2) \
1424-static inline long long atomic64_##op##_return(long long i, atomic64_t *v) \
1425+#define ATOMIC64_OP(op, op1, op2) __ATOMIC64_OP(op, _unchecked, op1, op2, , ) \
1426+ __ATOMIC64_OP(op, , op1, op2##s, __OVERFLOW_POST, __OVERFLOW_EXTABLE)
1427+
1428+#define __ATOMIC64_OP_RETURN(op, suffix, op1, op2, post_op, extable) \
1429+static inline long long atomic64_##op##_return##suffix(long long i, atomic64##suffix##_t *v) \
1430 { \
1431 long long result; \
1432 unsigned long tmp; \
1433@@ -298,13 +489,15 @@ static inline long long atomic64_##op##_return(long long i, atomic64_t *v) \
1434 smp_mb(); \
1435 prefetchw(&v->counter); \
1436 \
1437- __asm__ __volatile__("@ atomic64_" #op "_return\n" \
1438+ __asm__ __volatile__("@ atomic64_" #op "_return" #suffix "\n" \
1439 "1: ldrexd %0, %H0, [%3]\n" \
1440 " " #op1 " %Q0, %Q0, %Q4\n" \
1441 " " #op2 " %R0, %R0, %R4\n" \
1442+ post_op \
1443 " strexd %1, %0, %H0, [%3]\n" \
1444 " teq %1, #0\n" \
1445-" bne 1b" \
1446+" bne 1b\n" \
1447+ extable \
1448 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) \
1449 : "r" (&v->counter), "r" (i) \
1450 : "cc"); \
1451@@ -314,6 +507,9 @@ static inline long long atomic64_##op##_return(long long i, atomic64_t *v) \
1452 return result; \
1453 }
1454
1455+#define ATOMIC64_OP_RETURN(op, op1, op2) __ATOMIC64_OP_RETURN(op, _unchecked, op1, op2, , ) \
1456+ __ATOMIC64_OP_RETURN(op, , op1, op2##s, __OVERFLOW_POST_RETURN, __OVERFLOW_EXTABLE)
1457+
1458 #define ATOMIC64_OPS(op, op1, op2) \
1459 ATOMIC64_OP(op, op1, op2) \
1460 ATOMIC64_OP_RETURN(op, op1, op2)
1461@@ -323,7 +519,12 @@ ATOMIC64_OPS(sub, subs, sbc)
1462
1463 #undef ATOMIC64_OPS
1464 #undef ATOMIC64_OP_RETURN
1465+#undef __ATOMIC64_OP_RETURN
1466 #undef ATOMIC64_OP
1467+#undef __ATOMIC64_OP
1468+#undef __OVERFLOW_EXTABLE
1469+#undef __OVERFLOW_POST_RETURN
1470+#undef __OVERFLOW_POST
1471
1472 static inline long long atomic64_cmpxchg(atomic64_t *ptr, long long old,
1473 long long new)
1474@@ -351,6 +552,31 @@ static inline long long atomic64_cmpxchg(atomic64_t *ptr, long long old,
1475 return oldval;
1476 }
1477
1478+static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, long long old,
1479+ long long new)
1480+{
1481+ long long oldval;
1482+ unsigned long res;
1483+
1484+ smp_mb();
1485+
1486+ do {
1487+ __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1488+ "ldrexd %1, %H1, [%3]\n"
1489+ "mov %0, #0\n"
1490+ "teq %1, %4\n"
1491+ "teqeq %H1, %H4\n"
1492+ "strexdeq %0, %5, %H5, [%3]"
1493+ : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1494+ : "r" (&ptr->counter), "r" (old), "r" (new)
1495+ : "cc");
1496+ } while (res);
1497+
1498+ smp_mb();
1499+
1500+ return oldval;
1501+}
1502+
1503 static inline long long atomic64_xchg(atomic64_t *ptr, long long new)
1504 {
1505 long long result;
1506@@ -376,21 +602,35 @@ static inline long long atomic64_xchg(atomic64_t *ptr, long long new)
1507 static inline long long atomic64_dec_if_positive(atomic64_t *v)
1508 {
1509 long long result;
1510- unsigned long tmp;
1511+ u64 tmp;
1512
1513 smp_mb();
1514 prefetchw(&v->counter);
1515
1516 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1517-"1: ldrexd %0, %H0, [%3]\n"
1518-" subs %Q0, %Q0, #1\n"
1519-" sbc %R0, %R0, #0\n"
1520+"1: ldrexd %1, %H1, [%3]\n"
1521+" subs %Q0, %Q1, #1\n"
1522+" sbcs %R0, %R1, #0\n"
1523+
1524+#ifdef CONFIG_PAX_REFCOUNT
1525+" bvc 3f\n"
1526+" mov %Q0, %Q1\n"
1527+" mov %R0, %R1\n"
1528+"2: " REFCOUNT_TRAP_INSN "\n"
1529+"3:\n"
1530+#endif
1531+
1532 " teq %R0, #0\n"
1533-" bmi 2f\n"
1534+" bmi 4f\n"
1535 " strexd %1, %0, %H0, [%3]\n"
1536 " teq %1, #0\n"
1537 " bne 1b\n"
1538-"2:"
1539+"4:\n"
1540+
1541+#ifdef CONFIG_PAX_REFCOUNT
1542+ _ASM_EXTABLE(2b, 4b)
1543+#endif
1544+
1545 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1546 : "r" (&v->counter)
1547 : "cc");
1548@@ -414,13 +654,25 @@ static inline int atomic64_add_unless(atomic64_t *v, long long a, long long u)
1549 " teq %0, %5\n"
1550 " teqeq %H0, %H5\n"
1551 " moveq %1, #0\n"
1552-" beq 2f\n"
1553+" beq 4f\n"
1554 " adds %Q0, %Q0, %Q6\n"
1555-" adc %R0, %R0, %R6\n"
1556+" adcs %R0, %R0, %R6\n"
1557+
1558+#ifdef CONFIG_PAX_REFCOUNT
1559+" bvc 3f\n"
1560+"2: " REFCOUNT_TRAP_INSN "\n"
1561+"3:\n"
1562+#endif
1563+
1564 " strexd %2, %0, %H0, [%4]\n"
1565 " teq %2, #0\n"
1566 " bne 1b\n"
1567-"2:"
1568+"4:\n"
1569+
1570+#ifdef CONFIG_PAX_REFCOUNT
1571+ _ASM_EXTABLE(2b, 4b)
1572+#endif
1573+
1574 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1575 : "r" (&v->counter), "r" (u), "r" (a)
1576 : "cc");
1577@@ -433,10 +685,13 @@ static inline int atomic64_add_unless(atomic64_t *v, long long a, long long u)
1578
1579 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1580 #define atomic64_inc(v) atomic64_add(1LL, (v))
1581+#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1582 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1583+#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1584 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1585 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1586 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1587+#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1588 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1589 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1590 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1591diff --git a/arch/arm/include/asm/barrier.h b/arch/arm/include/asm/barrier.h
1592index 6c2327e..85beac4 100644
1593--- a/arch/arm/include/asm/barrier.h
1594+++ b/arch/arm/include/asm/barrier.h
1595@@ -67,7 +67,7 @@
1596 do { \
1597 compiletime_assert_atomic_type(*p); \
1598 smp_mb(); \
1599- ACCESS_ONCE(*p) = (v); \
1600+ ACCESS_ONCE_RW(*p) = (v); \
1601 } while (0)
1602
1603 #define smp_load_acquire(p) \
1604diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1605index 75fe66b..ba3dee4 100644
1606--- a/arch/arm/include/asm/cache.h
1607+++ b/arch/arm/include/asm/cache.h
1608@@ -4,8 +4,10 @@
1609 #ifndef __ASMARM_CACHE_H
1610 #define __ASMARM_CACHE_H
1611
1612+#include <linux/const.h>
1613+
1614 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1615-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1616+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1617
1618 /*
1619 * Memory returned by kmalloc() may be used for DMA, so we must make
1620@@ -24,5 +26,6 @@
1621 #endif
1622
1623 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1624+#define __read_only __attribute__ ((__section__(".data..read_only")))
1625
1626 #endif
1627diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1628index 4812cda..9da8116 100644
1629--- a/arch/arm/include/asm/cacheflush.h
1630+++ b/arch/arm/include/asm/cacheflush.h
1631@@ -116,7 +116,7 @@ struct cpu_cache_fns {
1632 void (*dma_unmap_area)(const void *, size_t, int);
1633
1634 void (*dma_flush_range)(const void *, const void *);
1635-};
1636+} __no_const;
1637
1638 /*
1639 * Select the calling method
1640diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1641index 5233151..87a71fa 100644
1642--- a/arch/arm/include/asm/checksum.h
1643+++ b/arch/arm/include/asm/checksum.h
1644@@ -37,7 +37,19 @@ __wsum
1645 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1646
1647 __wsum
1648-csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1649+__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1650+
1651+static inline __wsum
1652+csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1653+{
1654+ __wsum ret;
1655+ pax_open_userland();
1656+ ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1657+ pax_close_userland();
1658+ return ret;
1659+}
1660+
1661+
1662
1663 /*
1664 * Fold a partial checksum without adding pseudo headers
1665diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1666index 1692a05..1835802 100644
1667--- a/arch/arm/include/asm/cmpxchg.h
1668+++ b/arch/arm/include/asm/cmpxchg.h
1669@@ -107,6 +107,10 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1670 (__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), \
1671 sizeof(*(ptr))); \
1672 })
1673+#define xchg_unchecked(ptr, x) ({ \
1674+ (__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), \
1675+ sizeof(*(ptr))); \
1676+})
1677
1678 #include <asm-generic/cmpxchg-local.h>
1679
1680diff --git a/arch/arm/include/asm/cpuidle.h b/arch/arm/include/asm/cpuidle.h
1681index 0f84249..8e83c55 100644
1682--- a/arch/arm/include/asm/cpuidle.h
1683+++ b/arch/arm/include/asm/cpuidle.h
1684@@ -32,7 +32,7 @@ struct device_node;
1685 struct cpuidle_ops {
1686 int (*suspend)(int cpu, unsigned long arg);
1687 int (*init)(struct device_node *, int cpu);
1688-};
1689+} __no_const;
1690
1691 struct of_cpuidle_method {
1692 const char *method;
1693diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1694index 6ddbe44..b5e38b1a 100644
1695--- a/arch/arm/include/asm/domain.h
1696+++ b/arch/arm/include/asm/domain.h
1697@@ -48,18 +48,37 @@
1698 * Domain types
1699 */
1700 #define DOMAIN_NOACCESS 0
1701-#define DOMAIN_CLIENT 1
1702 #ifdef CONFIG_CPU_USE_DOMAINS
1703+#define DOMAIN_USERCLIENT 1
1704+#define DOMAIN_KERNELCLIENT 1
1705 #define DOMAIN_MANAGER 3
1706+#define DOMAIN_VECTORS DOMAIN_USER
1707 #else
1708+
1709+#ifdef CONFIG_PAX_KERNEXEC
1710 #define DOMAIN_MANAGER 1
1711+#define DOMAIN_KERNEXEC 3
1712+#else
1713+#define DOMAIN_MANAGER 1
1714+#endif
1715+
1716+#ifdef CONFIG_PAX_MEMORY_UDEREF
1717+#define DOMAIN_USERCLIENT 0
1718+#define DOMAIN_UDEREF 1
1719+#define DOMAIN_VECTORS DOMAIN_KERNEL
1720+#else
1721+#define DOMAIN_USERCLIENT 1
1722+#define DOMAIN_VECTORS DOMAIN_USER
1723+#endif
1724+#define DOMAIN_KERNELCLIENT 1
1725+
1726 #endif
1727
1728 #define domain_val(dom,type) ((type) << (2*(dom)))
1729
1730 #ifndef __ASSEMBLY__
1731
1732-#ifdef CONFIG_CPU_USE_DOMAINS
1733+#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1734 static inline void set_domain(unsigned val)
1735 {
1736 asm volatile(
1737@@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1738 isb();
1739 }
1740
1741-#define modify_domain(dom,type) \
1742- do { \
1743- struct thread_info *thread = current_thread_info(); \
1744- unsigned int domain = thread->cpu_domain; \
1745- domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1746- thread->cpu_domain = domain | domain_val(dom, type); \
1747- set_domain(thread->cpu_domain); \
1748- } while (0)
1749-
1750+extern void modify_domain(unsigned int dom, unsigned int type);
1751 #else
1752 static inline void set_domain(unsigned val) { }
1753 static inline void modify_domain(unsigned dom, unsigned type) { }
1754diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1755index d2315ff..f60b47b 100644
1756--- a/arch/arm/include/asm/elf.h
1757+++ b/arch/arm/include/asm/elf.h
1758@@ -117,7 +117,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1759 the loader. We need to make sure that it is out of the way of the program
1760 that it will "exec", and that there is sufficient room for the brk. */
1761
1762-#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1763+#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1764+
1765+#ifdef CONFIG_PAX_ASLR
1766+#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1767+
1768+#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1769+#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1770+#endif
1771
1772 /* When the program starts, a1 contains a pointer to a function to be
1773 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1774diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1775index de53547..52b9a28 100644
1776--- a/arch/arm/include/asm/fncpy.h
1777+++ b/arch/arm/include/asm/fncpy.h
1778@@ -81,7 +81,9 @@
1779 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1780 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1781 \
1782+ pax_open_kernel(); \
1783 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1784+ pax_close_kernel(); \
1785 flush_icache_range((unsigned long)(dest_buf), \
1786 (unsigned long)(dest_buf) + (size)); \
1787 \
1788diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1789index 5eed828..365e018 100644
1790--- a/arch/arm/include/asm/futex.h
1791+++ b/arch/arm/include/asm/futex.h
1792@@ -46,6 +46,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1793 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1794 return -EFAULT;
1795
1796+ pax_open_userland();
1797+
1798 smp_mb();
1799 /* Prefetching cannot fault */
1800 prefetchw(uaddr);
1801@@ -63,6 +65,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1802 : "cc", "memory");
1803 smp_mb();
1804
1805+ pax_close_userland();
1806+
1807 *uval = val;
1808 return ret;
1809 }
1810@@ -94,6 +98,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1811 return -EFAULT;
1812
1813 preempt_disable();
1814+ pax_open_userland();
1815+
1816 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1817 "1: " TUSER(ldr) " %1, [%4]\n"
1818 " teq %1, %2\n"
1819@@ -104,6 +110,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1820 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1821 : "cc", "memory");
1822
1823+ pax_close_userland();
1824+
1825 *uval = val;
1826 preempt_enable();
1827
1828@@ -131,6 +139,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1829 preempt_disable();
1830 #endif
1831 pagefault_disable();
1832+ pax_open_userland();
1833
1834 switch (op) {
1835 case FUTEX_OP_SET:
1836@@ -152,6 +161,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1837 ret = -ENOSYS;
1838 }
1839
1840+ pax_close_userland();
1841 pagefault_enable();
1842 #ifndef CONFIG_SMP
1843 preempt_enable();
1844diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1845index 83eb2f7..ed77159 100644
1846--- a/arch/arm/include/asm/kmap_types.h
1847+++ b/arch/arm/include/asm/kmap_types.h
1848@@ -4,6 +4,6 @@
1849 /*
1850 * This is the "bare minimum". AIO seems to require this.
1851 */
1852-#define KM_TYPE_NR 16
1853+#define KM_TYPE_NR 17
1854
1855 #endif
1856diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1857index 9e614a1..3302cca 100644
1858--- a/arch/arm/include/asm/mach/dma.h
1859+++ b/arch/arm/include/asm/mach/dma.h
1860@@ -22,7 +22,7 @@ struct dma_ops {
1861 int (*residue)(unsigned int, dma_t *); /* optional */
1862 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1863 const char *type;
1864-};
1865+} __do_const;
1866
1867 struct dma_struct {
1868 void *addr; /* single DMA address */
1869diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1870index f98c7f3..e5c626d 100644
1871--- a/arch/arm/include/asm/mach/map.h
1872+++ b/arch/arm/include/asm/mach/map.h
1873@@ -23,17 +23,19 @@ struct map_desc {
1874
1875 /* types 0-3 are defined in asm/io.h */
1876 enum {
1877- MT_UNCACHED = 4,
1878- MT_CACHECLEAN,
1879- MT_MINICLEAN,
1880+ MT_UNCACHED_RW = 4,
1881+ MT_CACHECLEAN_RO,
1882+ MT_MINICLEAN_RO,
1883 MT_LOW_VECTORS,
1884 MT_HIGH_VECTORS,
1885- MT_MEMORY_RWX,
1886+ __MT_MEMORY_RWX,
1887 MT_MEMORY_RW,
1888- MT_ROM,
1889- MT_MEMORY_RWX_NONCACHED,
1890+ MT_MEMORY_RX,
1891+ MT_ROM_RX,
1892+ MT_MEMORY_RW_NONCACHED,
1893+ MT_MEMORY_RX_NONCACHED,
1894 MT_MEMORY_RW_DTCM,
1895- MT_MEMORY_RWX_ITCM,
1896+ MT_MEMORY_RX_ITCM,
1897 MT_MEMORY_RW_SO,
1898 MT_MEMORY_DMA_READY,
1899 };
1900diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1901index 563b92f..689d58e 100644
1902--- a/arch/arm/include/asm/outercache.h
1903+++ b/arch/arm/include/asm/outercache.h
1904@@ -39,7 +39,7 @@ struct outer_cache_fns {
1905 /* This is an ARM L2C thing */
1906 void (*write_sec)(unsigned long, unsigned);
1907 void (*configure)(const struct l2x0_regs *);
1908-};
1909+} __no_const;
1910
1911 extern struct outer_cache_fns outer_cache;
1912
1913diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1914index 4355f0e..cd9168e 100644
1915--- a/arch/arm/include/asm/page.h
1916+++ b/arch/arm/include/asm/page.h
1917@@ -23,6 +23,7 @@
1918
1919 #else
1920
1921+#include <linux/compiler.h>
1922 #include <asm/glue.h>
1923
1924 /*
1925@@ -114,7 +115,7 @@ struct cpu_user_fns {
1926 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1927 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1928 unsigned long vaddr, struct vm_area_struct *vma);
1929-};
1930+} __no_const;
1931
1932 #ifdef MULTI_USER
1933 extern struct cpu_user_fns cpu_user;
1934diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1935index 19cfab5..3f5c7e9 100644
1936--- a/arch/arm/include/asm/pgalloc.h
1937+++ b/arch/arm/include/asm/pgalloc.h
1938@@ -17,6 +17,7 @@
1939 #include <asm/processor.h>
1940 #include <asm/cacheflush.h>
1941 #include <asm/tlbflush.h>
1942+#include <asm/system_info.h>
1943
1944 #define check_pgt_cache() do { } while (0)
1945
1946@@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1947 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1948 }
1949
1950+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1951+{
1952+ pud_populate(mm, pud, pmd);
1953+}
1954+
1955 #else /* !CONFIG_ARM_LPAE */
1956
1957 /*
1958@@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1959 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1960 #define pmd_free(mm, pmd) do { } while (0)
1961 #define pud_populate(mm,pmd,pte) BUG()
1962+#define pud_populate_kernel(mm,pmd,pte) BUG()
1963
1964 #endif /* CONFIG_ARM_LPAE */
1965
1966@@ -128,6 +135,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1967 __free_page(pte);
1968 }
1969
1970+static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1971+{
1972+#ifdef CONFIG_ARM_LPAE
1973+ pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1974+#else
1975+ if (addr & SECTION_SIZE)
1976+ pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1977+ else
1978+ pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1979+#endif
1980+ flush_pmd_entry(pmdp);
1981+}
1982+
1983 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1984 pmdval_t prot)
1985 {
1986diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1987index 5e68278..1869bae 100644
1988--- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1989+++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1990@@ -27,7 +27,7 @@
1991 /*
1992 * - section
1993 */
1994-#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1995+#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1996 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1997 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1998 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1999@@ -39,6 +39,7 @@
2000 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
2001 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
2002 #define PMD_SECT_AF (_AT(pmdval_t, 0))
2003+#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
2004
2005 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
2006 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
2007@@ -68,6 +69,7 @@
2008 * - extended small page/tiny page
2009 */
2010 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
2011+#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
2012 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
2013 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
2014 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
2015diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
2016index aeddd28..207745c 100644
2017--- a/arch/arm/include/asm/pgtable-2level.h
2018+++ b/arch/arm/include/asm/pgtable-2level.h
2019@@ -127,6 +127,9 @@
2020 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
2021 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
2022
2023+/* Two-level page tables only have PXN in the PGD, not in the PTE. */
2024+#define L_PTE_PXN (_AT(pteval_t, 0))
2025+
2026 /*
2027 * These are the memory types, defined to be compatible with
2028 * pre-ARMv6 CPUs cacheable and bufferable bits: n/a,n/a,C,B
2029diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
2030index a745a2a..481350a 100644
2031--- a/arch/arm/include/asm/pgtable-3level.h
2032+++ b/arch/arm/include/asm/pgtable-3level.h
2033@@ -80,6 +80,7 @@
2034 #define L_PTE_USER (_AT(pteval_t, 1) << 6) /* AP[1] */
2035 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2036 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
2037+#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2038 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
2039 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55)
2040 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56)
2041@@ -91,10 +92,12 @@
2042 #define L_PMD_SECT_SPLITTING (_AT(pmdval_t, 1) << 56)
2043 #define L_PMD_SECT_NONE (_AT(pmdval_t, 1) << 57)
2044 #define L_PMD_SECT_RDONLY (_AT(pteval_t, 1) << 58)
2045+#define PMD_SECT_RDONLY PMD_SECT_AP2
2046
2047 /*
2048 * To be used in assembly code with the upper page attributes.
2049 */
2050+#define L_PTE_PXN_HIGH (1 << (53 - 32))
2051 #define L_PTE_XN_HIGH (1 << (54 - 32))
2052 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
2053
2054diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
2055index f403541..b10df68 100644
2056--- a/arch/arm/include/asm/pgtable.h
2057+++ b/arch/arm/include/asm/pgtable.h
2058@@ -33,6 +33,9 @@
2059 #include <asm/pgtable-2level.h>
2060 #endif
2061
2062+#define ktla_ktva(addr) (addr)
2063+#define ktva_ktla(addr) (addr)
2064+
2065 /*
2066 * Just any arbitrary offset to the start of the vmalloc VM area: the
2067 * current 8MB value just means that there will be a 8MB "hole" after the
2068@@ -48,6 +51,9 @@
2069 #define LIBRARY_TEXT_START 0x0c000000
2070
2071 #ifndef __ASSEMBLY__
2072+extern pteval_t __supported_pte_mask;
2073+extern pmdval_t __supported_pmd_mask;
2074+
2075 extern void __pte_error(const char *file, int line, pte_t);
2076 extern void __pmd_error(const char *file, int line, pmd_t);
2077 extern void __pgd_error(const char *file, int line, pgd_t);
2078@@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2079 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2080 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2081
2082+#define __HAVE_ARCH_PAX_OPEN_KERNEL
2083+#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2084+
2085+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2086+#include <asm/domain.h>
2087+#include <linux/thread_info.h>
2088+#include <linux/preempt.h>
2089+
2090+static inline int test_domain(int domain, int domaintype)
2091+{
2092+ return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2093+}
2094+#endif
2095+
2096+#ifdef CONFIG_PAX_KERNEXEC
2097+static inline unsigned long pax_open_kernel(void) {
2098+#ifdef CONFIG_ARM_LPAE
2099+ /* TODO */
2100+#else
2101+ preempt_disable();
2102+ BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2103+ modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2104+#endif
2105+ return 0;
2106+}
2107+
2108+static inline unsigned long pax_close_kernel(void) {
2109+#ifdef CONFIG_ARM_LPAE
2110+ /* TODO */
2111+#else
2112+ BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2113+ /* DOMAIN_MANAGER = "client" under KERNEXEC */
2114+ modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2115+ preempt_enable_no_resched();
2116+#endif
2117+ return 0;
2118+}
2119+#else
2120+static inline unsigned long pax_open_kernel(void) { return 0; }
2121+static inline unsigned long pax_close_kernel(void) { return 0; }
2122+#endif
2123+
2124 /*
2125 * This is the lowest virtual address we can permit any user space
2126 * mapping to be mapped at. This is particularly important for
2127@@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2128 /*
2129 * The pgprot_* and protection_map entries will be fixed up in runtime
2130 * to include the cachable and bufferable bits based on memory policy,
2131- * as well as any architecture dependent bits like global/ASID and SMP
2132- * shared mapping bits.
2133+ * as well as any architecture dependent bits like global/ASID, PXN,
2134+ * and SMP shared mapping bits.
2135 */
2136 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2137
2138@@ -307,7 +355,7 @@ static inline pte_t pte_mknexec(pte_t pte)
2139 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2140 {
2141 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2142- L_PTE_NONE | L_PTE_VALID;
2143+ L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2144 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2145 return pte;
2146 }
2147diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2148index c25ef3e..735f14b 100644
2149--- a/arch/arm/include/asm/psci.h
2150+++ b/arch/arm/include/asm/psci.h
2151@@ -32,7 +32,7 @@ struct psci_operations {
2152 int (*affinity_info)(unsigned long target_affinity,
2153 unsigned long lowest_affinity_level);
2154 int (*migrate_info_type)(void);
2155-};
2156+} __no_const;
2157
2158 extern struct psci_operations psci_ops;
2159 extern struct smp_operations psci_smp_ops;
2160diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2161index 2f3ac1b..67182ae0 100644
2162--- a/arch/arm/include/asm/smp.h
2163+++ b/arch/arm/include/asm/smp.h
2164@@ -108,7 +108,7 @@ struct smp_operations {
2165 int (*cpu_disable)(unsigned int cpu);
2166 #endif
2167 #endif
2168-};
2169+} __no_const;
2170
2171 struct of_cpu_method {
2172 const char *method;
2173diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2174index bd32ede..bd90a0b 100644
2175--- a/arch/arm/include/asm/thread_info.h
2176+++ b/arch/arm/include/asm/thread_info.h
2177@@ -74,9 +74,9 @@ struct thread_info {
2178 .flags = 0, \
2179 .preempt_count = INIT_PREEMPT_COUNT, \
2180 .addr_limit = KERNEL_DS, \
2181- .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2182- domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2183- domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2184+ .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2185+ domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2186+ domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2187 }
2188
2189 #define init_thread_info (init_thread_union.thread_info)
2190@@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2191 #define TIF_SYSCALL_AUDIT 9
2192 #define TIF_SYSCALL_TRACEPOINT 10
2193 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2194-#define TIF_NOHZ 12 /* in adaptive nohz mode */
2195+/* within 8 bits of TIF_SYSCALL_TRACE
2196+ * to meet flexible second operand requirements
2197+ */
2198+#define TIF_GRSEC_SETXID 12
2199+#define TIF_NOHZ 13 /* in adaptive nohz mode */
2200 #define TIF_USING_IWMMXT 17
2201 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2202 #define TIF_RESTORE_SIGMASK 20
2203@@ -166,10 +170,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2204 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2205 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2206 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2207+#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2208
2209 /* Checks for any syscall work in entry-common.S */
2210 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2211- _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2212+ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2213
2214 /*
2215 * Change these and you break ASM code in entry-common.S
2216diff --git a/arch/arm/include/asm/tls.h b/arch/arm/include/asm/tls.h
2217index 5f833f7..76e6644 100644
2218--- a/arch/arm/include/asm/tls.h
2219+++ b/arch/arm/include/asm/tls.h
2220@@ -3,6 +3,7 @@
2221
2222 #include <linux/compiler.h>
2223 #include <asm/thread_info.h>
2224+#include <asm/pgtable.h>
2225
2226 #ifdef __ASSEMBLY__
2227 #include <asm/asm-offsets.h>
2228@@ -89,7 +90,9 @@ static inline void set_tls(unsigned long val)
2229 * at 0xffff0fe0 must be used instead. (see
2230 * entry-armv.S for details)
2231 */
2232+ pax_open_kernel();
2233 *((unsigned int *)0xffff0ff0) = val;
2234+ pax_close_kernel();
2235 #endif
2236 }
2237
2238diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2239index 74b17d0..7e6da4b 100644
2240--- a/arch/arm/include/asm/uaccess.h
2241+++ b/arch/arm/include/asm/uaccess.h
2242@@ -18,6 +18,7 @@
2243 #include <asm/domain.h>
2244 #include <asm/unified.h>
2245 #include <asm/compiler.h>
2246+#include <asm/pgtable.h>
2247
2248 #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2249 #include <asm-generic/uaccess-unaligned.h>
2250@@ -70,11 +71,38 @@ extern int __put_user_bad(void);
2251 static inline void set_fs(mm_segment_t fs)
2252 {
2253 current_thread_info()->addr_limit = fs;
2254- modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2255+ modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2256 }
2257
2258 #define segment_eq(a, b) ((a) == (b))
2259
2260+#define __HAVE_ARCH_PAX_OPEN_USERLAND
2261+#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2262+
2263+static inline void pax_open_userland(void)
2264+{
2265+
2266+#ifdef CONFIG_PAX_MEMORY_UDEREF
2267+ if (segment_eq(get_fs(), USER_DS)) {
2268+ BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2269+ modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2270+ }
2271+#endif
2272+
2273+}
2274+
2275+static inline void pax_close_userland(void)
2276+{
2277+
2278+#ifdef CONFIG_PAX_MEMORY_UDEREF
2279+ if (segment_eq(get_fs(), USER_DS)) {
2280+ BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2281+ modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2282+ }
2283+#endif
2284+
2285+}
2286+
2287 #define __addr_ok(addr) ({ \
2288 unsigned long flag; \
2289 __asm__("cmp %2, %0; movlo %0, #0" \
2290@@ -198,8 +226,12 @@ extern int __get_user_64t_4(void *);
2291
2292 #define get_user(x, p) \
2293 ({ \
2294+ int __e; \
2295 might_fault(); \
2296- __get_user_check(x, p); \
2297+ pax_open_userland(); \
2298+ __e = __get_user_check((x), (p)); \
2299+ pax_close_userland(); \
2300+ __e; \
2301 })
2302
2303 extern int __put_user_1(void *, unsigned int);
2304@@ -244,8 +276,12 @@ extern int __put_user_8(void *, unsigned long long);
2305
2306 #define put_user(x, p) \
2307 ({ \
2308+ int __e; \
2309 might_fault(); \
2310- __put_user_check(x, p); \
2311+ pax_open_userland(); \
2312+ __e = __put_user_check((x), (p)); \
2313+ pax_close_userland(); \
2314+ __e; \
2315 })
2316
2317 #else /* CONFIG_MMU */
2318@@ -269,6 +305,7 @@ static inline void set_fs(mm_segment_t fs)
2319
2320 #endif /* CONFIG_MMU */
2321
2322+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
2323 #define access_ok(type, addr, size) (__range_ok(addr, size) == 0)
2324
2325 #define user_addr_max() \
2326@@ -286,13 +323,17 @@ static inline void set_fs(mm_segment_t fs)
2327 #define __get_user(x, ptr) \
2328 ({ \
2329 long __gu_err = 0; \
2330+ pax_open_userland(); \
2331 __get_user_err((x), (ptr), __gu_err); \
2332+ pax_close_userland(); \
2333 __gu_err; \
2334 })
2335
2336 #define __get_user_error(x, ptr, err) \
2337 ({ \
2338+ pax_open_userland(); \
2339 __get_user_err((x), (ptr), err); \
2340+ pax_close_userland(); \
2341 (void) 0; \
2342 })
2343
2344@@ -368,13 +409,17 @@ do { \
2345 #define __put_user(x, ptr) \
2346 ({ \
2347 long __pu_err = 0; \
2348+ pax_open_userland(); \
2349 __put_user_err((x), (ptr), __pu_err); \
2350+ pax_close_userland(); \
2351 __pu_err; \
2352 })
2353
2354 #define __put_user_error(x, ptr, err) \
2355 ({ \
2356+ pax_open_userland(); \
2357 __put_user_err((x), (ptr), err); \
2358+ pax_close_userland(); \
2359 (void) 0; \
2360 })
2361
2362@@ -474,11 +519,44 @@ do { \
2363
2364
2365 #ifdef CONFIG_MMU
2366-extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2367-extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2368-extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, 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+extern unsigned long __must_check __size_overflow(3) ___copy_from_user(void *to, const void __user *from, unsigned long n);
2372+extern unsigned long __must_check __size_overflow(3) ___copy_to_user(void __user *to, const void *from, unsigned long n);
2373+
2374+static inline unsigned long __must_check __size_overflow(3) __copy_from_user(void *to, const void __user *from, unsigned long n)
2375+{
2376+ unsigned long ret;
2377+
2378+ check_object_size(to, n, false);
2379+ pax_open_userland();
2380+ ret = ___copy_from_user(to, from, n);
2381+ pax_close_userland();
2382+ return ret;
2383+}
2384+
2385+static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2386+{
2387+ unsigned long ret;
2388+
2389+ check_object_size(from, n, true);
2390+ pax_open_userland();
2391+ ret = ___copy_to_user(to, from, n);
2392+ pax_close_userland();
2393+ return ret;
2394+}
2395+
2396+extern unsigned long __must_check __size_overflow(3) __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2397+extern unsigned long __must_check __size_overflow(2) ___clear_user(void __user *addr, unsigned long n);
2398+extern unsigned long __must_check __size_overflow(2) __clear_user_std(void __user *addr, unsigned long n);
2399+
2400+static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2401+{
2402+ unsigned long ret;
2403+ pax_open_userland();
2404+ ret = ___clear_user(addr, n);
2405+ pax_close_userland();
2406+ return ret;
2407+}
2408+
2409 #else
2410 #define __copy_from_user(to, from, n) (memcpy(to, (void __force *)from, n), 0)
2411 #define __copy_to_user(to, from, n) (memcpy((void __force *)to, from, n), 0)
2412@@ -487,6 +565,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2413
2414 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2415 {
2416+ if ((long)n < 0)
2417+ return n;
2418+
2419 if (access_ok(VERIFY_READ, from, n))
2420 n = __copy_from_user(to, from, n);
2421 else /* security hole - plug it */
2422@@ -496,6 +577,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2423
2424 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2425 {
2426+ if ((long)n < 0)
2427+ return n;
2428+
2429 if (access_ok(VERIFY_WRITE, to, n))
2430 n = __copy_to_user(to, from, n);
2431 return n;
2432diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2433index 5af0ed1..cea83883 100644
2434--- a/arch/arm/include/uapi/asm/ptrace.h
2435+++ b/arch/arm/include/uapi/asm/ptrace.h
2436@@ -92,7 +92,7 @@
2437 * ARMv7 groups of PSR bits
2438 */
2439 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2440-#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2441+#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2442 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2443 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2444
2445diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2446index 5e5a51a..b21eeef 100644
2447--- a/arch/arm/kernel/armksyms.c
2448+++ b/arch/arm/kernel/armksyms.c
2449@@ -58,7 +58,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2450
2451 /* networking */
2452 EXPORT_SYMBOL(csum_partial);
2453-EXPORT_SYMBOL(csum_partial_copy_from_user);
2454+EXPORT_SYMBOL(__csum_partial_copy_from_user);
2455 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2456 EXPORT_SYMBOL(__csum_ipv6_magic);
2457
2458@@ -97,9 +97,9 @@ EXPORT_SYMBOL(mmiocpy);
2459 #ifdef CONFIG_MMU
2460 EXPORT_SYMBOL(copy_page);
2461
2462-EXPORT_SYMBOL(__copy_from_user);
2463-EXPORT_SYMBOL(__copy_to_user);
2464-EXPORT_SYMBOL(__clear_user);
2465+EXPORT_SYMBOL(___copy_from_user);
2466+EXPORT_SYMBOL(___copy_to_user);
2467+EXPORT_SYMBOL(___clear_user);
2468
2469 EXPORT_SYMBOL(__get_user_1);
2470 EXPORT_SYMBOL(__get_user_2);
2471diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c
2472index 318da33..373689f 100644
2473--- a/arch/arm/kernel/cpuidle.c
2474+++ b/arch/arm/kernel/cpuidle.c
2475@@ -19,7 +19,7 @@ extern struct of_cpuidle_method __cpuidle_method_of_table[];
2476 static const struct of_cpuidle_method __cpuidle_method_of_table_sentinel
2477 __used __section(__cpuidle_method_of_table_end);
2478
2479-static struct cpuidle_ops cpuidle_ops[NR_CPUS];
2480+static struct cpuidle_ops cpuidle_ops[NR_CPUS] __read_only;
2481
2482 /**
2483 * arm_cpuidle_simple_enter() - a wrapper to cpu_do_idle()
2484diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2485index cb4fb1e..dc7fcaf 100644
2486--- a/arch/arm/kernel/entry-armv.S
2487+++ b/arch/arm/kernel/entry-armv.S
2488@@ -50,6 +50,87 @@
2489 9997:
2490 .endm
2491
2492+ .macro pax_enter_kernel
2493+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2494+ @ make aligned space for saved DACR
2495+ sub sp, sp, #8
2496+ @ save regs
2497+ stmdb sp!, {r1, r2}
2498+ @ read DACR from cpu_domain into r1
2499+ mov r2, sp
2500+ @ assume 8K pages, since we have to split the immediate in two
2501+ bic r2, r2, #(0x1fc0)
2502+ bic r2, r2, #(0x3f)
2503+ ldr r1, [r2, #TI_CPU_DOMAIN]
2504+ @ store old DACR on stack
2505+ str r1, [sp, #8]
2506+#ifdef CONFIG_PAX_KERNEXEC
2507+ @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2508+ bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2509+ orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2510+#endif
2511+#ifdef CONFIG_PAX_MEMORY_UDEREF
2512+ @ set current DOMAIN_USER to DOMAIN_NOACCESS
2513+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2514+#endif
2515+ @ write r1 to current_thread_info()->cpu_domain
2516+ str r1, [r2, #TI_CPU_DOMAIN]
2517+ @ write r1 to DACR
2518+ mcr p15, 0, r1, c3, c0, 0
2519+ @ instruction sync
2520+ instr_sync
2521+ @ restore regs
2522+ ldmia sp!, {r1, r2}
2523+#endif
2524+ .endm
2525+
2526+ .macro pax_open_userland
2527+#ifdef CONFIG_PAX_MEMORY_UDEREF
2528+ @ save regs
2529+ stmdb sp!, {r0, r1}
2530+ @ read DACR from cpu_domain into r1
2531+ mov r0, sp
2532+ @ assume 8K pages, since we have to split the immediate in two
2533+ bic r0, r0, #(0x1fc0)
2534+ bic r0, r0, #(0x3f)
2535+ ldr r1, [r0, #TI_CPU_DOMAIN]
2536+ @ set current DOMAIN_USER to DOMAIN_CLIENT
2537+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2538+ orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2539+ @ write r1 to current_thread_info()->cpu_domain
2540+ str r1, [r0, #TI_CPU_DOMAIN]
2541+ @ write r1 to DACR
2542+ mcr p15, 0, r1, c3, c0, 0
2543+ @ instruction sync
2544+ instr_sync
2545+ @ restore regs
2546+ ldmia sp!, {r0, r1}
2547+#endif
2548+ .endm
2549+
2550+ .macro pax_close_userland
2551+#ifdef CONFIG_PAX_MEMORY_UDEREF
2552+ @ save regs
2553+ stmdb sp!, {r0, r1}
2554+ @ read DACR from cpu_domain into r1
2555+ mov r0, sp
2556+ @ assume 8K pages, since we have to split the immediate in two
2557+ bic r0, r0, #(0x1fc0)
2558+ bic r0, r0, #(0x3f)
2559+ ldr r1, [r0, #TI_CPU_DOMAIN]
2560+ @ set current DOMAIN_USER to DOMAIN_NOACCESS
2561+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2562+ @ write r1 to current_thread_info()->cpu_domain
2563+ str r1, [r0, #TI_CPU_DOMAIN]
2564+ @ write r1 to DACR
2565+ mcr p15, 0, r1, c3, c0, 0
2566+ @ instruction sync
2567+ instr_sync
2568+ @ restore regs
2569+ ldmia sp!, {r0, r1}
2570+#endif
2571+ .endm
2572+
2573 .macro pabt_helper
2574 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2575 #ifdef MULTI_PABORT
2576@@ -92,11 +173,15 @@
2577 * Invalid mode handlers
2578 */
2579 .macro inv_entry, reason
2580+
2581+ pax_enter_kernel
2582+
2583 sub sp, sp, #S_FRAME_SIZE
2584 ARM( stmib sp, {r1 - lr} )
2585 THUMB( stmia sp, {r0 - r12} )
2586 THUMB( str sp, [sp, #S_SP] )
2587 THUMB( str lr, [sp, #S_LR] )
2588+
2589 mov r1, #\reason
2590 .endm
2591
2592@@ -152,7 +237,11 @@ ENDPROC(__und_invalid)
2593 .macro svc_entry, stack_hole=0, trace=1
2594 UNWIND(.fnstart )
2595 UNWIND(.save {r0 - pc} )
2596+
2597+ pax_enter_kernel
2598+
2599 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2600+
2601 #ifdef CONFIG_THUMB2_KERNEL
2602 SPFIX( str r0, [sp] ) @ temporarily saved
2603 SPFIX( mov r0, sp )
2604@@ -167,7 +256,12 @@ ENDPROC(__und_invalid)
2605 ldmia r0, {r3 - r5}
2606 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2607 mov r6, #-1 @ "" "" "" ""
2608+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2609+ @ offset sp by 8 as done in pax_enter_kernel
2610+ add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2611+#else
2612 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2613+#endif
2614 SPFIX( addeq r2, r2, #4 )
2615 str r3, [sp, #-4]! @ save the "real" r0 copied
2616 @ from the exception stack
2617@@ -371,6 +465,9 @@ ENDPROC(__fiq_abt)
2618 .macro usr_entry, trace=1
2619 UNWIND(.fnstart )
2620 UNWIND(.cantunwind ) @ don't unwind the user space
2621+
2622+ pax_enter_kernel_user
2623+
2624 sub sp, sp, #S_FRAME_SIZE
2625 ARM( stmib sp, {r1 - r12} )
2626 THUMB( stmia sp, {r0 - r12} )
2627@@ -481,7 +578,9 @@ __und_usr:
2628 tst r3, #PSR_T_BIT @ Thumb mode?
2629 bne __und_usr_thumb
2630 sub r4, r2, #4 @ ARM instr at LR - 4
2631+ pax_open_userland
2632 1: ldrt r0, [r4]
2633+ pax_close_userland
2634 ARM_BE8(rev r0, r0) @ little endian instruction
2635
2636 @ r0 = 32-bit ARM instruction which caused the exception
2637@@ -515,11 +614,15 @@ __und_usr_thumb:
2638 */
2639 .arch armv6t2
2640 #endif
2641+ pax_open_userland
2642 2: ldrht r5, [r4]
2643+ pax_close_userland
2644 ARM_BE8(rev16 r5, r5) @ little endian instruction
2645 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2646 blo __und_usr_fault_16 @ 16bit undefined instruction
2647+ pax_open_userland
2648 3: ldrht r0, [r2]
2649+ pax_close_userland
2650 ARM_BE8(rev16 r0, r0) @ little endian instruction
2651 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2652 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2653@@ -549,7 +652,8 @@ ENDPROC(__und_usr)
2654 */
2655 .pushsection .text.fixup, "ax"
2656 .align 2
2657-4: str r4, [sp, #S_PC] @ retry current instruction
2658+4: pax_close_userland
2659+ str r4, [sp, #S_PC] @ retry current instruction
2660 ret r9
2661 .popsection
2662 .pushsection __ex_table,"a"
2663@@ -769,7 +873,7 @@ ENTRY(__switch_to)
2664 THUMB( str lr, [ip], #4 )
2665 ldr r4, [r2, #TI_TP_VALUE]
2666 ldr r5, [r2, #TI_TP_VALUE + 4]
2667-#ifdef CONFIG_CPU_USE_DOMAINS
2668+#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2669 ldr r6, [r2, #TI_CPU_DOMAIN]
2670 #endif
2671 switch_tls r1, r4, r5, r3, r7
2672@@ -778,7 +882,7 @@ ENTRY(__switch_to)
2673 ldr r8, =__stack_chk_guard
2674 ldr r7, [r7, #TSK_STACK_CANARY]
2675 #endif
2676-#ifdef CONFIG_CPU_USE_DOMAINS
2677+#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2678 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2679 #endif
2680 mov r5, r0
2681diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2682index b48dd4f..9f9a72f 100644
2683--- a/arch/arm/kernel/entry-common.S
2684+++ b/arch/arm/kernel/entry-common.S
2685@@ -11,18 +11,46 @@
2686 #include <asm/assembler.h>
2687 #include <asm/unistd.h>
2688 #include <asm/ftrace.h>
2689+#include <asm/domain.h>
2690 #include <asm/unwind.h>
2691
2692+#include "entry-header.S"
2693+
2694 #ifdef CONFIG_NEED_RET_TO_USER
2695 #include <mach/entry-macro.S>
2696 #else
2697 .macro arch_ret_to_user, tmp1, tmp2
2698+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2699+ @ save regs
2700+ stmdb sp!, {r1, r2}
2701+ @ read DACR from cpu_domain into r1
2702+ mov r2, sp
2703+ @ assume 8K pages, since we have to split the immediate in two
2704+ bic r2, r2, #(0x1fc0)
2705+ bic r2, r2, #(0x3f)
2706+ ldr r1, [r2, #TI_CPU_DOMAIN]
2707+#ifdef CONFIG_PAX_KERNEXEC
2708+ @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2709+ bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2710+ orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2711+#endif
2712+#ifdef CONFIG_PAX_MEMORY_UDEREF
2713+ @ set current DOMAIN_USER to DOMAIN_UDEREF
2714+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2715+ orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2716+#endif
2717+ @ write r1 to current_thread_info()->cpu_domain
2718+ str r1, [r2, #TI_CPU_DOMAIN]
2719+ @ write r1 to DACR
2720+ mcr p15, 0, r1, c3, c0, 0
2721+ @ instruction sync
2722+ instr_sync
2723+ @ restore regs
2724+ ldmia sp!, {r1, r2}
2725+#endif
2726 .endm
2727 #endif
2728
2729-#include "entry-header.S"
2730-
2731-
2732 .align 5
2733 /*
2734 * This is the fast syscall return path. We do as little as
2735@@ -174,6 +202,12 @@ ENTRY(vector_swi)
2736 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2737 #endif
2738
2739+ /*
2740+ * do this here to avoid a performance hit of wrapping the code above
2741+ * that directly dereferences userland to parse the SWI instruction
2742+ */
2743+ pax_enter_kernel_user
2744+
2745 adr tbl, sys_call_table @ load syscall table pointer
2746
2747 #if defined(CONFIG_OABI_COMPAT)
2748diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2749index 1a0045a..9b4f34d 100644
2750--- a/arch/arm/kernel/entry-header.S
2751+++ b/arch/arm/kernel/entry-header.S
2752@@ -196,6 +196,60 @@
2753 msr cpsr_c, \rtemp @ switch back to the SVC mode
2754 .endm
2755
2756+ .macro pax_enter_kernel_user
2757+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2758+ @ save regs
2759+ stmdb sp!, {r0, r1}
2760+ @ read DACR from cpu_domain into r1
2761+ mov r0, sp
2762+ @ assume 8K pages, since we have to split the immediate in two
2763+ bic r0, r0, #(0x1fc0)
2764+ bic r0, r0, #(0x3f)
2765+ ldr r1, [r0, #TI_CPU_DOMAIN]
2766+#ifdef CONFIG_PAX_MEMORY_UDEREF
2767+ @ set current DOMAIN_USER to DOMAIN_NOACCESS
2768+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2769+#endif
2770+#ifdef CONFIG_PAX_KERNEXEC
2771+ @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2772+ bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2773+ orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2774+#endif
2775+ @ write r1 to current_thread_info()->cpu_domain
2776+ str r1, [r0, #TI_CPU_DOMAIN]
2777+ @ write r1 to DACR
2778+ mcr p15, 0, r1, c3, c0, 0
2779+ @ instruction sync
2780+ instr_sync
2781+ @ restore regs
2782+ ldmia sp!, {r0, r1}
2783+#endif
2784+ .endm
2785+
2786+ .macro pax_exit_kernel
2787+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2788+ @ save regs
2789+ stmdb sp!, {r0, r1}
2790+ @ read old DACR from stack into r1
2791+ ldr r1, [sp, #(8 + S_SP)]
2792+ sub r1, r1, #8
2793+ ldr r1, [r1]
2794+
2795+ @ write r1 to current_thread_info()->cpu_domain
2796+ mov r0, sp
2797+ @ assume 8K pages, since we have to split the immediate in two
2798+ bic r0, r0, #(0x1fc0)
2799+ bic r0, r0, #(0x3f)
2800+ str r1, [r0, #TI_CPU_DOMAIN]
2801+ @ write r1 to DACR
2802+ mcr p15, 0, r1, c3, c0, 0
2803+ @ instruction sync
2804+ instr_sync
2805+ @ restore regs
2806+ ldmia sp!, {r0, r1}
2807+#endif
2808+ .endm
2809+
2810 #ifndef CONFIG_THUMB2_KERNEL
2811 .macro svc_exit, rpsr, irq = 0
2812 .if \irq != 0
2813@@ -215,6 +269,9 @@
2814 blne trace_hardirqs_off
2815 #endif
2816 .endif
2817+
2818+ pax_exit_kernel
2819+
2820 msr spsr_cxsf, \rpsr
2821 #if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_32v6K)
2822 @ We must avoid clrex due to Cortex-A15 erratum #830321
2823@@ -291,6 +348,9 @@
2824 blne trace_hardirqs_off
2825 #endif
2826 .endif
2827+
2828+ pax_exit_kernel
2829+
2830 ldr lr, [sp, #S_SP] @ top of the stack
2831 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2832
2833diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2834index 059c3da..8e45cfc 100644
2835--- a/arch/arm/kernel/fiq.c
2836+++ b/arch/arm/kernel/fiq.c
2837@@ -95,7 +95,10 @@ void set_fiq_handler(void *start, unsigned int length)
2838 void *base = vectors_page;
2839 unsigned offset = FIQ_OFFSET;
2840
2841+ pax_open_kernel();
2842 memcpy(base + offset, start, length);
2843+ pax_close_kernel();
2844+
2845 if (!cache_is_vipt_nonaliasing())
2846 flush_icache_range((unsigned long)base + offset, offset +
2847 length);
2848diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2849index 29e2991..7bc5757 100644
2850--- a/arch/arm/kernel/head.S
2851+++ b/arch/arm/kernel/head.S
2852@@ -467,7 +467,7 @@ __enable_mmu:
2853 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2854 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2855 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2856- domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2857+ domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2858 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2859 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2860 #endif
2861diff --git a/arch/arm/kernel/module-plts.c b/arch/arm/kernel/module-plts.c
2862index 097e2e2..3927085 100644
2863--- a/arch/arm/kernel/module-plts.c
2864+++ b/arch/arm/kernel/module-plts.c
2865@@ -30,17 +30,12 @@ struct plt_entries {
2866 u32 lit[PLT_ENT_COUNT];
2867 };
2868
2869-static bool in_init(const struct module *mod, u32 addr)
2870-{
2871- return addr - (u32)mod->module_init < mod->init_size;
2872-}
2873-
2874 u32 get_module_plt(struct module *mod, unsigned long loc, Elf32_Addr val)
2875 {
2876 struct plt_entries *plt, *plt_end;
2877 int c, *count;
2878
2879- if (in_init(mod, loc)) {
2880+ if (within_module_init(loc, mod)) {
2881 plt = (void *)mod->arch.init_plt->sh_addr;
2882 plt_end = (void *)plt + mod->arch.init_plt->sh_size;
2883 count = &mod->arch.init_plt_count;
2884diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2885index efdddcb..35e58f6 100644
2886--- a/arch/arm/kernel/module.c
2887+++ b/arch/arm/kernel/module.c
2888@@ -38,17 +38,47 @@
2889 #endif
2890
2891 #ifdef CONFIG_MMU
2892-void *module_alloc(unsigned long size)
2893+static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2894 {
2895- void *p = __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2896- GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
2897+ void *p;
2898+
2899+ if (!size || (!IS_ENABLED(CONFIG_ARM_MODULE_PLTS) && PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR))
2900+ return NULL;
2901+
2902+ p = __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2903+ GFP_KERNEL, prot, 0, NUMA_NO_NODE,
2904 __builtin_return_address(0));
2905 if (!IS_ENABLED(CONFIG_ARM_MODULE_PLTS) || p)
2906 return p;
2907 return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
2908- GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
2909+ GFP_KERNEL, prot, 0, NUMA_NO_NODE,
2910 __builtin_return_address(0));
2911 }
2912+
2913+void *module_alloc(unsigned long size)
2914+{
2915+
2916+#ifdef CONFIG_PAX_KERNEXEC
2917+ return __module_alloc(size, PAGE_KERNEL);
2918+#else
2919+ return __module_alloc(size, PAGE_KERNEL_EXEC);
2920+#endif
2921+
2922+}
2923+
2924+#ifdef CONFIG_PAX_KERNEXEC
2925+void module_memfree_exec(void *module_region)
2926+{
2927+ module_memfree(module_region);
2928+}
2929+EXPORT_SYMBOL(module_memfree_exec);
2930+
2931+void *module_alloc_exec(unsigned long size)
2932+{
2933+ return __module_alloc(size, PAGE_KERNEL_EXEC);
2934+}
2935+EXPORT_SYMBOL(module_alloc_exec);
2936+#endif
2937 #endif
2938
2939 int
2940diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2941index 69bda1a..755113a 100644
2942--- a/arch/arm/kernel/patch.c
2943+++ b/arch/arm/kernel/patch.c
2944@@ -66,6 +66,7 @@ void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
2945 else
2946 __acquire(&patch_lock);
2947
2948+ pax_open_kernel();
2949 if (thumb2 && __opcode_is_thumb16(insn)) {
2950 *(u16 *)waddr = __opcode_to_mem_thumb16(insn);
2951 size = sizeof(u16);
2952@@ -97,6 +98,7 @@ void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
2953 *(u32 *)waddr = insn;
2954 size = sizeof(u32);
2955 }
2956+ pax_close_kernel();
2957
2958 if (waddr != addr) {
2959 flush_kernel_vmap_range(waddr, twopage ? size / 2 : size);
2960diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2961index f192a2a..1a40523 100644
2962--- a/arch/arm/kernel/process.c
2963+++ b/arch/arm/kernel/process.c
2964@@ -105,8 +105,8 @@ void __show_regs(struct pt_regs *regs)
2965
2966 show_regs_print_info(KERN_DEFAULT);
2967
2968- print_symbol("PC is at %s\n", instruction_pointer(regs));
2969- print_symbol("LR is at %s\n", regs->ARM_lr);
2970+ printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2971+ printk("LR is at %pA\n", (void *)regs->ARM_lr);
2972 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2973 "sp : %08lx ip : %08lx fp : %08lx\n",
2974 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2975@@ -283,12 +283,6 @@ unsigned long get_wchan(struct task_struct *p)
2976 return 0;
2977 }
2978
2979-unsigned long arch_randomize_brk(struct mm_struct *mm)
2980-{
2981- unsigned long range_end = mm->brk + 0x02000000;
2982- return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2983-}
2984-
2985 #ifdef CONFIG_MMU
2986 #ifdef CONFIG_KUSER_HELPERS
2987 /*
2988@@ -304,7 +298,7 @@ static struct vm_area_struct gate_vma = {
2989
2990 static int __init gate_vma_init(void)
2991 {
2992- gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2993+ gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2994 return 0;
2995 }
2996 arch_initcall(gate_vma_init);
2997@@ -333,91 +327,13 @@ const char *arch_vma_name(struct vm_area_struct *vma)
2998 return is_gate_vma(vma) ? "[vectors]" : NULL;
2999 }
3000
3001-/* If possible, provide a placement hint at a random offset from the
3002- * stack for the sigpage and vdso pages.
3003- */
3004-static unsigned long sigpage_addr(const struct mm_struct *mm,
3005- unsigned int npages)
3006-{
3007- unsigned long offset;
3008- unsigned long first;
3009- unsigned long last;
3010- unsigned long addr;
3011- unsigned int slots;
3012-
3013- first = PAGE_ALIGN(mm->start_stack);
3014-
3015- last = TASK_SIZE - (npages << PAGE_SHIFT);
3016-
3017- /* No room after stack? */
3018- if (first > last)
3019- return 0;
3020-
3021- /* Just enough room? */
3022- if (first == last)
3023- return first;
3024-
3025- slots = ((last - first) >> PAGE_SHIFT) + 1;
3026-
3027- offset = get_random_int() % slots;
3028-
3029- addr = first + (offset << PAGE_SHIFT);
3030-
3031- return addr;
3032-}
3033-
3034-static struct page *signal_page;
3035-extern struct page *get_signal_page(void);
3036-
3037-static const struct vm_special_mapping sigpage_mapping = {
3038- .name = "[sigpage]",
3039- .pages = &signal_page,
3040-};
3041-
3042 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
3043 {
3044 struct mm_struct *mm = current->mm;
3045- struct vm_area_struct *vma;
3046- unsigned long npages;
3047- unsigned long addr;
3048- unsigned long hint;
3049- int ret = 0;
3050-
3051- if (!signal_page)
3052- signal_page = get_signal_page();
3053- if (!signal_page)
3054- return -ENOMEM;
3055-
3056- npages = 1; /* for sigpage */
3057- npages += vdso_total_pages;
3058
3059 down_write(&mm->mmap_sem);
3060- hint = sigpage_addr(mm, npages);
3061- addr = get_unmapped_area(NULL, hint, npages << PAGE_SHIFT, 0, 0);
3062- if (IS_ERR_VALUE(addr)) {
3063- ret = addr;
3064- goto up_fail;
3065- }
3066-
3067- vma = _install_special_mapping(mm, addr, PAGE_SIZE,
3068- VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
3069- &sigpage_mapping);
3070-
3071- if (IS_ERR(vma)) {
3072- ret = PTR_ERR(vma);
3073- goto up_fail;
3074- }
3075-
3076- mm->context.sigpage = addr;
3077-
3078- /* Unlike the sigpage, failure to install the vdso is unlikely
3079- * to be fatal to the process, so no error check needed
3080- * here.
3081- */
3082- arm_install_vdso(mm, addr + PAGE_SIZE);
3083-
3084- up_fail:
3085+ mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
3086 up_write(&mm->mmap_sem);
3087- return ret;
3088+ return 0;
3089 }
3090 #endif
3091diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
3092index f90fdf4..24e8c84 100644
3093--- a/arch/arm/kernel/psci.c
3094+++ b/arch/arm/kernel/psci.c
3095@@ -26,7 +26,7 @@
3096 #include <asm/psci.h>
3097 #include <asm/system_misc.h>
3098
3099-struct psci_operations psci_ops;
3100+struct psci_operations psci_ops __read_only;
3101
3102 static int (*invoke_psci_fn)(u32, u32, u32, u32);
3103 typedef int (*psci_initcall_t)(const struct device_node *);
3104diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
3105index ef9119f..31995a3 100644
3106--- a/arch/arm/kernel/ptrace.c
3107+++ b/arch/arm/kernel/ptrace.c
3108@@ -928,10 +928,19 @@ static void tracehook_report_syscall(struct pt_regs *regs,
3109 regs->ARM_ip = ip;
3110 }
3111
3112+#ifdef CONFIG_GRKERNSEC_SETXID
3113+extern void gr_delayed_cred_worker(void);
3114+#endif
3115+
3116 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
3117 {
3118 current_thread_info()->syscall = scno;
3119
3120+#ifdef CONFIG_GRKERNSEC_SETXID
3121+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3122+ gr_delayed_cred_worker();
3123+#endif
3124+
3125 /* Do the secure computing check first; failures should be fast. */
3126 #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
3127 if (secure_computing() == -1)
3128diff --git a/arch/arm/kernel/reboot.c b/arch/arm/kernel/reboot.c
3129index 3826935..8ed63ed 100644
3130--- a/arch/arm/kernel/reboot.c
3131+++ b/arch/arm/kernel/reboot.c
3132@@ -122,6 +122,7 @@ void machine_power_off(void)
3133
3134 if (pm_power_off)
3135 pm_power_off();
3136+ while (1);
3137 }
3138
3139 /*
3140diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
3141index 36c18b7..0d78292 100644
3142--- a/arch/arm/kernel/setup.c
3143+++ b/arch/arm/kernel/setup.c
3144@@ -108,21 +108,23 @@ EXPORT_SYMBOL(elf_hwcap);
3145 unsigned int elf_hwcap2 __read_mostly;
3146 EXPORT_SYMBOL(elf_hwcap2);
3147
3148+pteval_t __supported_pte_mask __read_only;
3149+pmdval_t __supported_pmd_mask __read_only;
3150
3151 #ifdef MULTI_CPU
3152-struct processor processor __read_mostly;
3153+struct processor processor __read_only;
3154 #endif
3155 #ifdef MULTI_TLB
3156-struct cpu_tlb_fns cpu_tlb __read_mostly;
3157+struct cpu_tlb_fns cpu_tlb __read_only;
3158 #endif
3159 #ifdef MULTI_USER
3160-struct cpu_user_fns cpu_user __read_mostly;
3161+struct cpu_user_fns cpu_user __read_only;
3162 #endif
3163 #ifdef MULTI_CACHE
3164-struct cpu_cache_fns cpu_cache __read_mostly;
3165+struct cpu_cache_fns cpu_cache __read_only;
3166 #endif
3167 #ifdef CONFIG_OUTER_CACHE
3168-struct outer_cache_fns outer_cache __read_mostly;
3169+struct outer_cache_fns outer_cache __read_only;
3170 EXPORT_SYMBOL(outer_cache);
3171 #endif
3172
3173@@ -253,9 +255,13 @@ static int __get_cpu_architecture(void)
3174 * Register 0 and check for VMSAv7 or PMSAv7 */
3175 unsigned int mmfr0 = read_cpuid_ext(CPUID_EXT_MMFR0);
3176 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3177- (mmfr0 & 0x000000f0) >= 0x00000030)
3178+ (mmfr0 & 0x000000f0) >= 0x00000030) {
3179 cpu_arch = CPU_ARCH_ARMv7;
3180- else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3181+ if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3182+ __supported_pte_mask |= L_PTE_PXN;
3183+ __supported_pmd_mask |= PMD_PXNTABLE;
3184+ }
3185+ } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3186 (mmfr0 & 0x000000f0) == 0x00000020)
3187 cpu_arch = CPU_ARCH_ARMv6;
3188 else
3189diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3190index 586eef2..61aabd4 100644
3191--- a/arch/arm/kernel/signal.c
3192+++ b/arch/arm/kernel/signal.c
3193@@ -24,8 +24,6 @@
3194
3195 extern const unsigned long sigreturn_codes[7];
3196
3197-static unsigned long signal_return_offset;
3198-
3199 #ifdef CONFIG_CRUNCH
3200 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3201 {
3202@@ -390,8 +388,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3203 * except when the MPU has protected the vectors
3204 * page from PL0
3205 */
3206- retcode = mm->context.sigpage + signal_return_offset +
3207- (idx << 2) + thumb;
3208+ retcode = mm->context.sigpage + (idx << 2) + thumb;
3209 } else
3210 #endif
3211 {
3212@@ -597,33 +594,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3213 } while (thread_flags & _TIF_WORK_MASK);
3214 return 0;
3215 }
3216-
3217-struct page *get_signal_page(void)
3218-{
3219- unsigned long ptr;
3220- unsigned offset;
3221- struct page *page;
3222- void *addr;
3223-
3224- page = alloc_pages(GFP_KERNEL, 0);
3225-
3226- if (!page)
3227- return NULL;
3228-
3229- addr = page_address(page);
3230-
3231- /* Give the signal return code some randomness */
3232- offset = 0x200 + (get_random_int() & 0x7fc);
3233- signal_return_offset = offset;
3234-
3235- /*
3236- * Copy signal return handlers into the vector page, and
3237- * set sigreturn to be a pointer to these.
3238- */
3239- memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3240-
3241- ptr = (unsigned long)addr + offset;
3242- flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3243-
3244- return page;
3245-}
3246diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3247index 3d6b782..8b3baeb 100644
3248--- a/arch/arm/kernel/smp.c
3249+++ b/arch/arm/kernel/smp.c
3250@@ -76,7 +76,7 @@ enum ipi_msg_type {
3251
3252 static DECLARE_COMPLETION(cpu_running);
3253
3254-static struct smp_operations smp_ops;
3255+static struct smp_operations smp_ops __read_only;
3256
3257 void __init smp_set_ops(struct smp_operations *ops)
3258 {
3259diff --git a/arch/arm/kernel/tcm.c b/arch/arm/kernel/tcm.c
3260index b10e136..cb5edf9 100644
3261--- a/arch/arm/kernel/tcm.c
3262+++ b/arch/arm/kernel/tcm.c
3263@@ -64,7 +64,7 @@ static struct map_desc itcm_iomap[] __initdata = {
3264 .virtual = ITCM_OFFSET,
3265 .pfn = __phys_to_pfn(ITCM_OFFSET),
3266 .length = 0,
3267- .type = MT_MEMORY_RWX_ITCM,
3268+ .type = MT_MEMORY_RX_ITCM,
3269 }
3270 };
3271
3272@@ -362,7 +362,9 @@ no_dtcm:
3273 start = &__sitcm_text;
3274 end = &__eitcm_text;
3275 ram = &__itcm_start;
3276+ pax_open_kernel();
3277 memcpy(start, ram, itcm_code_sz);
3278+ pax_close_kernel();
3279 pr_debug("CPU ITCM: copied code from %p - %p\n",
3280 start, end);
3281 itcm_present = true;
3282diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3283index d358226..bfd4019 100644
3284--- a/arch/arm/kernel/traps.c
3285+++ b/arch/arm/kernel/traps.c
3286@@ -65,7 +65,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3287 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3288 {
3289 #ifdef CONFIG_KALLSYMS
3290- printk("[<%08lx>] (%ps) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3291+ printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3292 #else
3293 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3294 #endif
3295@@ -267,6 +267,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3296 static int die_owner = -1;
3297 static unsigned int die_nest_count;
3298
3299+extern void gr_handle_kernel_exploit(void);
3300+
3301 static unsigned long oops_begin(void)
3302 {
3303 int cpu;
3304@@ -309,6 +311,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3305 panic("Fatal exception in interrupt");
3306 if (panic_on_oops)
3307 panic("Fatal exception");
3308+
3309+ gr_handle_kernel_exploit();
3310+
3311 if (signr)
3312 do_exit(signr);
3313 }
3314@@ -870,7 +875,11 @@ void __init early_trap_init(void *vectors_base)
3315 kuser_init(vectors_base);
3316
3317 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3318- modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3319+
3320+#ifndef CONFIG_PAX_MEMORY_UDEREF
3321+ modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3322+#endif
3323+
3324 #else /* ifndef CONFIG_CPU_V7M */
3325 /*
3326 * on V7-M there is no need to copy the vector table to a dedicated
3327diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3328index 8b60fde..8d986dd 100644
3329--- a/arch/arm/kernel/vmlinux.lds.S
3330+++ b/arch/arm/kernel/vmlinux.lds.S
3331@@ -37,7 +37,7 @@
3332 #endif
3333
3334 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3335- defined(CONFIG_GENERIC_BUG)
3336+ defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3337 #define ARM_EXIT_KEEP(x) x
3338 #define ARM_EXIT_DISCARD(x)
3339 #else
3340@@ -120,6 +120,8 @@ SECTIONS
3341 #ifdef CONFIG_DEBUG_RODATA
3342 . = ALIGN(1<<SECTION_SHIFT);
3343 #endif
3344+ _etext = .; /* End of text section */
3345+
3346 RO_DATA(PAGE_SIZE)
3347
3348 . = ALIGN(4);
3349@@ -150,8 +152,6 @@ SECTIONS
3350
3351 NOTES
3352
3353- _etext = .; /* End of text and rodata section */
3354-
3355 #ifndef CONFIG_XIP_KERNEL
3356 # ifdef CONFIG_ARM_KERNMEM_PERMS
3357 . = ALIGN(1<<SECTION_SHIFT);
3358diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3359index f9c341c..7430436 100644
3360--- a/arch/arm/kvm/arm.c
3361+++ b/arch/arm/kvm/arm.c
3362@@ -57,7 +57,7 @@ static unsigned long hyp_default_vectors;
3363 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3364
3365 /* The VMID used in the VTTBR */
3366-static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3367+static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3368 static u8 kvm_next_vmid;
3369 static DEFINE_SPINLOCK(kvm_vmid_lock);
3370
3371@@ -372,7 +372,7 @@ void force_vm_exit(const cpumask_t *mask)
3372 */
3373 static bool need_new_vmid_gen(struct kvm *kvm)
3374 {
3375- return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3376+ return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3377 }
3378
3379 /**
3380@@ -405,7 +405,7 @@ static void update_vttbr(struct kvm *kvm)
3381
3382 /* First user of a new VMID generation? */
3383 if (unlikely(kvm_next_vmid == 0)) {
3384- atomic64_inc(&kvm_vmid_gen);
3385+ atomic64_inc_unchecked(&kvm_vmid_gen);
3386 kvm_next_vmid = 1;
3387
3388 /*
3389@@ -422,7 +422,7 @@ static void update_vttbr(struct kvm *kvm)
3390 kvm_call_hyp(__kvm_flush_vm_context);
3391 }
3392
3393- kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3394+ kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3395 kvm->arch.vmid = kvm_next_vmid;
3396 kvm_next_vmid++;
3397
3398@@ -1110,7 +1110,7 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr)
3399 /**
3400 * Initialize Hyp-mode and memory mappings on all CPUs.
3401 */
3402-int kvm_arch_init(void *opaque)
3403+int kvm_arch_init(const void *opaque)
3404 {
3405 int err;
3406 int ret, cpu;
3407diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3408index 1710fd7..ec3e014 100644
3409--- a/arch/arm/lib/clear_user.S
3410+++ b/arch/arm/lib/clear_user.S
3411@@ -12,14 +12,14 @@
3412
3413 .text
3414
3415-/* Prototype: int __clear_user(void *addr, size_t sz)
3416+/* Prototype: int ___clear_user(void *addr, size_t sz)
3417 * Purpose : clear some user memory
3418 * Params : addr - user memory address to clear
3419 * : sz - number of bytes to clear
3420 * Returns : number of bytes NOT cleared
3421 */
3422 ENTRY(__clear_user_std)
3423-WEAK(__clear_user)
3424+WEAK(___clear_user)
3425 stmfd sp!, {r1, lr}
3426 mov r2, #0
3427 cmp r1, #4
3428@@ -44,7 +44,7 @@ WEAK(__clear_user)
3429 USER( strnebt r2, [r0])
3430 mov r0, #0
3431 ldmfd sp!, {r1, pc}
3432-ENDPROC(__clear_user)
3433+ENDPROC(___clear_user)
3434 ENDPROC(__clear_user_std)
3435
3436 .pushsection .text.fixup,"ax"
3437diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3438index 7a235b9..73a0556 100644
3439--- a/arch/arm/lib/copy_from_user.S
3440+++ b/arch/arm/lib/copy_from_user.S
3441@@ -17,7 +17,7 @@
3442 /*
3443 * Prototype:
3444 *
3445- * size_t __copy_from_user(void *to, const void *from, size_t n)
3446+ * size_t ___copy_from_user(void *to, const void *from, size_t n)
3447 *
3448 * Purpose:
3449 *
3450@@ -89,11 +89,11 @@
3451
3452 .text
3453
3454-ENTRY(__copy_from_user)
3455+ENTRY(___copy_from_user)
3456
3457 #include "copy_template.S"
3458
3459-ENDPROC(__copy_from_user)
3460+ENDPROC(___copy_from_user)
3461
3462 .pushsection .fixup,"ax"
3463 .align 0
3464diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3465index 6ee2f67..d1cce76 100644
3466--- a/arch/arm/lib/copy_page.S
3467+++ b/arch/arm/lib/copy_page.S
3468@@ -10,6 +10,7 @@
3469 * ASM optimised string functions
3470 */
3471 #include <linux/linkage.h>
3472+#include <linux/const.h>
3473 #include <asm/assembler.h>
3474 #include <asm/asm-offsets.h>
3475 #include <asm/cache.h>
3476diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3477index 9648b06..19c333c 100644
3478--- a/arch/arm/lib/copy_to_user.S
3479+++ b/arch/arm/lib/copy_to_user.S
3480@@ -17,7 +17,7 @@
3481 /*
3482 * Prototype:
3483 *
3484- * size_t __copy_to_user(void *to, const void *from, size_t n)
3485+ * size_t ___copy_to_user(void *to, const void *from, size_t n)
3486 *
3487 * Purpose:
3488 *
3489@@ -93,11 +93,11 @@
3490 .text
3491
3492 ENTRY(__copy_to_user_std)
3493-WEAK(__copy_to_user)
3494+WEAK(___copy_to_user)
3495
3496 #include "copy_template.S"
3497
3498-ENDPROC(__copy_to_user)
3499+ENDPROC(___copy_to_user)
3500 ENDPROC(__copy_to_user_std)
3501
3502 .pushsection .text.fixup,"ax"
3503diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3504index 1d0957e..f708846 100644
3505--- a/arch/arm/lib/csumpartialcopyuser.S
3506+++ b/arch/arm/lib/csumpartialcopyuser.S
3507@@ -57,8 +57,8 @@
3508 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3509 */
3510
3511-#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3512-#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3513+#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3514+#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3515
3516 #include "csumpartialcopygeneric.S"
3517
3518diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3519index 8044591..c9b2609 100644
3520--- a/arch/arm/lib/delay.c
3521+++ b/arch/arm/lib/delay.c
3522@@ -29,7 +29,7 @@
3523 /*
3524 * Default to the loop-based delay implementation.
3525 */
3526-struct arm_delay_ops arm_delay_ops = {
3527+struct arm_delay_ops arm_delay_ops __read_only = {
3528 .delay = __loop_delay,
3529 .const_udelay = __loop_const_udelay,
3530 .udelay = __loop_udelay,
3531diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3532index 4b39af2..9ae747d 100644
3533--- a/arch/arm/lib/uaccess_with_memcpy.c
3534+++ b/arch/arm/lib/uaccess_with_memcpy.c
3535@@ -85,7 +85,7 @@ pin_page_for_write(const void __user *_addr, pte_t **ptep, spinlock_t **ptlp)
3536 return 1;
3537 }
3538
3539-static unsigned long noinline
3540+static unsigned long noinline __size_overflow(3)
3541 __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n)
3542 {
3543 int atomic;
3544@@ -136,7 +136,7 @@ out:
3545 }
3546
3547 unsigned long
3548-__copy_to_user(void __user *to, const void *from, unsigned long n)
3549+___copy_to_user(void __user *to, const void *from, unsigned long n)
3550 {
3551 /*
3552 * This test is stubbed out of the main function above to keep
3553@@ -150,7 +150,7 @@ __copy_to_user(void __user *to, const void *from, unsigned long n)
3554 return __copy_to_user_memcpy(to, from, n);
3555 }
3556
3557-static unsigned long noinline
3558+static unsigned long noinline __size_overflow(2)
3559 __clear_user_memset(void __user *addr, unsigned long n)
3560 {
3561 if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
3562@@ -190,7 +190,7 @@ out:
3563 return n;
3564 }
3565
3566-unsigned long __clear_user(void __user *addr, unsigned long n)
3567+unsigned long ___clear_user(void __user *addr, unsigned long n)
3568 {
3569 /* See rational for this in __copy_to_user() above. */
3570 if (n < 64)
3571diff --git a/arch/arm/mach-exynos/suspend.c b/arch/arm/mach-exynos/suspend.c
3572index f572219..2cf36d5 100644
3573--- a/arch/arm/mach-exynos/suspend.c
3574+++ b/arch/arm/mach-exynos/suspend.c
3575@@ -732,8 +732,10 @@ void __init exynos_pm_init(void)
3576 tmp |= pm_data->wake_disable_mask;
3577 pmu_raw_writel(tmp, S5P_WAKEUP_MASK);
3578
3579- exynos_pm_syscore_ops.suspend = pm_data->pm_suspend;
3580- exynos_pm_syscore_ops.resume = pm_data->pm_resume;
3581+ pax_open_kernel();
3582+ *(void **)&exynos_pm_syscore_ops.suspend = pm_data->pm_suspend;
3583+ *(void **)&exynos_pm_syscore_ops.resume = pm_data->pm_resume;
3584+ pax_close_kernel();
3585
3586 register_syscore_ops(&exynos_pm_syscore_ops);
3587 suspend_set_ops(&exynos_suspend_ops);
3588diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
3589index e46e9ea..9141c83 100644
3590--- a/arch/arm/mach-mvebu/coherency.c
3591+++ b/arch/arm/mach-mvebu/coherency.c
3592@@ -117,7 +117,7 @@ static void __init armada_370_coherency_init(struct device_node *np)
3593
3594 /*
3595 * This ioremap hook is used on Armada 375/38x to ensure that PCIe
3596- * memory areas are mapped as MT_UNCACHED instead of MT_DEVICE. This
3597+ * memory areas are mapped as MT_UNCACHED_RW instead of MT_DEVICE. This
3598 * is needed as a workaround for a deadlock issue between the PCIe
3599 * interface and the cache controller.
3600 */
3601@@ -130,7 +130,7 @@ armada_pcie_wa_ioremap_caller(phys_addr_t phys_addr, size_t size,
3602 mvebu_mbus_get_pcie_mem_aperture(&pcie_mem);
3603
3604 if (pcie_mem.start <= phys_addr && (phys_addr + size) <= pcie_mem.end)
3605- mtype = MT_UNCACHED;
3606+ mtype = MT_UNCACHED_RW;
3607
3608 return __arm_ioremap_caller(phys_addr, size, mtype, caller);
3609 }
3610diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3611index b6443a4..20a0b74 100644
3612--- a/arch/arm/mach-omap2/board-n8x0.c
3613+++ b/arch/arm/mach-omap2/board-n8x0.c
3614@@ -569,7 +569,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3615 }
3616 #endif
3617
3618-struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3619+struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3620 .late_init = n8x0_menelaus_late_init,
3621 };
3622
3623diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3624index 79f49d9..70bf184 100644
3625--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3626+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3627@@ -86,7 +86,7 @@ struct cpu_pm_ops {
3628 void (*resume)(void);
3629 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3630 void (*hotplug_restart)(void);
3631-};
3632+} __no_const;
3633
3634 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3635 static struct powerdomain *mpuss_pd;
3636@@ -105,7 +105,7 @@ static void dummy_cpu_resume(void)
3637 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3638 {}
3639
3640-struct cpu_pm_ops omap_pm_ops = {
3641+static struct cpu_pm_ops omap_pm_ops __read_only = {
3642 .finish_suspend = default_finish_suspend,
3643 .resume = dummy_cpu_resume,
3644 .scu_prepare = dummy_scu_prepare,
3645diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
3646index 5305ec7..6d74045 100644
3647--- a/arch/arm/mach-omap2/omap-smp.c
3648+++ b/arch/arm/mach-omap2/omap-smp.c
3649@@ -19,6 +19,7 @@
3650 #include <linux/device.h>
3651 #include <linux/smp.h>
3652 #include <linux/io.h>
3653+#include <linux/irq.h>
3654 #include <linux/irqchip/arm-gic.h>
3655
3656 #include <asm/smp_scu.h>
3657diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3658index e1d2e99..d9b3177 100644
3659--- a/arch/arm/mach-omap2/omap-wakeupgen.c
3660+++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3661@@ -330,7 +330,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3662 return NOTIFY_OK;
3663 }
3664
3665-static struct notifier_block __refdata irq_hotplug_notifier = {
3666+static struct notifier_block irq_hotplug_notifier = {
3667 .notifier_call = irq_cpu_hotplug_notify,
3668 };
3669
3670diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3671index 4cb8fd9..5ce65bc 100644
3672--- a/arch/arm/mach-omap2/omap_device.c
3673+++ b/arch/arm/mach-omap2/omap_device.c
3674@@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3675 struct platform_device __init *omap_device_build(const char *pdev_name,
3676 int pdev_id,
3677 struct omap_hwmod *oh,
3678- void *pdata, int pdata_len)
3679+ const void *pdata, int pdata_len)
3680 {
3681 struct omap_hwmod *ohs[] = { oh };
3682
3683@@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3684 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3685 int pdev_id,
3686 struct omap_hwmod **ohs,
3687- int oh_cnt, void *pdata,
3688+ int oh_cnt, const void *pdata,
3689 int pdata_len)
3690 {
3691 int ret = -ENOMEM;
3692diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3693index 78c02b3..c94109a 100644
3694--- a/arch/arm/mach-omap2/omap_device.h
3695+++ b/arch/arm/mach-omap2/omap_device.h
3696@@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3697 /* Core code interface */
3698
3699 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3700- struct omap_hwmod *oh, void *pdata,
3701+ struct omap_hwmod *oh, const void *pdata,
3702 int pdata_len);
3703
3704 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3705 struct omap_hwmod **oh, int oh_cnt,
3706- void *pdata, int pdata_len);
3707+ const void *pdata, int pdata_len);
3708
3709 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3710 struct omap_hwmod **ohs, int oh_cnt);
3711diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3712index 486cc4d..8d1a0b7 100644
3713--- a/arch/arm/mach-omap2/omap_hwmod.c
3714+++ b/arch/arm/mach-omap2/omap_hwmod.c
3715@@ -199,10 +199,10 @@ struct omap_hwmod_soc_ops {
3716 int (*init_clkdm)(struct omap_hwmod *oh);
3717 void (*update_context_lost)(struct omap_hwmod *oh);
3718 int (*get_context_lost)(struct omap_hwmod *oh);
3719-};
3720+} __no_const;
3721
3722 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3723-static struct omap_hwmod_soc_ops soc_ops;
3724+static struct omap_hwmod_soc_ops soc_ops __read_only;
3725
3726 /* omap_hwmod_list contains all registered struct omap_hwmods */
3727 static LIST_HEAD(omap_hwmod_list);
3728diff --git a/arch/arm/mach-omap2/powerdomains43xx_data.c b/arch/arm/mach-omap2/powerdomains43xx_data.c
3729index 95fee54..cfa9cf1 100644
3730--- a/arch/arm/mach-omap2/powerdomains43xx_data.c
3731+++ b/arch/arm/mach-omap2/powerdomains43xx_data.c
3732@@ -10,6 +10,7 @@
3733
3734 #include <linux/kernel.h>
3735 #include <linux/init.h>
3736+#include <asm/pgtable.h>
3737
3738 #include "powerdomain.h"
3739
3740@@ -129,7 +130,9 @@ static int am43xx_check_vcvp(void)
3741
3742 void __init am43xx_powerdomains_init(void)
3743 {
3744- omap4_pwrdm_operations.pwrdm_has_voltdm = am43xx_check_vcvp;
3745+ pax_open_kernel();
3746+ *(void **)&omap4_pwrdm_operations.pwrdm_has_voltdm = am43xx_check_vcvp;
3747+ pax_close_kernel();
3748 pwrdm_register_platform_funcs(&omap4_pwrdm_operations);
3749 pwrdm_register_pwrdms(powerdomains_am43xx);
3750 pwrdm_complete_init();
3751diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3752index ff0a68c..b312aa0 100644
3753--- a/arch/arm/mach-omap2/wd_timer.c
3754+++ b/arch/arm/mach-omap2/wd_timer.c
3755@@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3756 struct omap_hwmod *oh;
3757 char *oh_name = "wd_timer2";
3758 char *dev_name = "omap_wdt";
3759- struct omap_wd_timer_platform_data pdata;
3760+ static struct omap_wd_timer_platform_data pdata = {
3761+ .read_reset_sources = prm_read_reset_sources
3762+ };
3763
3764 if (!cpu_class_is_omap2() || of_have_populated_dt())
3765 return 0;
3766@@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3767 return -EINVAL;
3768 }
3769
3770- pdata.read_reset_sources = prm_read_reset_sources;
3771-
3772 pdev = omap_device_build(dev_name, id, oh, &pdata,
3773 sizeof(struct omap_wd_timer_platform_data));
3774 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3775diff --git a/arch/arm/mach-shmobile/platsmp-apmu.c b/arch/arm/mach-shmobile/platsmp-apmu.c
3776index b0790fc..71eb21f 100644
3777--- a/arch/arm/mach-shmobile/platsmp-apmu.c
3778+++ b/arch/arm/mach-shmobile/platsmp-apmu.c
3779@@ -22,6 +22,7 @@
3780 #include <asm/proc-fns.h>
3781 #include <asm/smp_plat.h>
3782 #include <asm/suspend.h>
3783+#include <asm/pgtable.h>
3784 #include "common.h"
3785 #include "platsmp-apmu.h"
3786
3787@@ -233,6 +234,8 @@ static int shmobile_smp_apmu_enter_suspend(suspend_state_t state)
3788
3789 void __init shmobile_smp_apmu_suspend_init(void)
3790 {
3791- shmobile_suspend_ops.enter = shmobile_smp_apmu_enter_suspend;
3792+ pax_open_kernel();
3793+ *(void **)&shmobile_suspend_ops.enter = shmobile_smp_apmu_enter_suspend;
3794+ pax_close_kernel();
3795 }
3796 #endif
3797diff --git a/arch/arm/mach-shmobile/pm-r8a7740.c b/arch/arm/mach-shmobile/pm-r8a7740.c
3798index 34608fc..344d7c0 100644
3799--- a/arch/arm/mach-shmobile/pm-r8a7740.c
3800+++ b/arch/arm/mach-shmobile/pm-r8a7740.c
3801@@ -11,6 +11,7 @@
3802 #include <linux/console.h>
3803 #include <linux/io.h>
3804 #include <linux/suspend.h>
3805+#include <asm/pgtable.h>
3806
3807 #include "common.h"
3808 #include "pm-rmobile.h"
3809@@ -117,7 +118,9 @@ static int r8a7740_enter_suspend(suspend_state_t suspend_state)
3810
3811 static void r8a7740_suspend_init(void)
3812 {
3813- shmobile_suspend_ops.enter = r8a7740_enter_suspend;
3814+ pax_open_kernel();
3815+ *(void **)&shmobile_suspend_ops.enter = r8a7740_enter_suspend;
3816+ pax_close_kernel();
3817 }
3818 #else
3819 static void r8a7740_suspend_init(void) {}
3820diff --git a/arch/arm/mach-shmobile/pm-sh73a0.c b/arch/arm/mach-shmobile/pm-sh73a0.c
3821index a7e4668..83334f33 100644
3822--- a/arch/arm/mach-shmobile/pm-sh73a0.c
3823+++ b/arch/arm/mach-shmobile/pm-sh73a0.c
3824@@ -9,6 +9,7 @@
3825 */
3826
3827 #include <linux/suspend.h>
3828+#include <asm/pgtable.h>
3829 #include "common.h"
3830
3831 #ifdef CONFIG_SUSPEND
3832@@ -20,7 +21,9 @@ static int sh73a0_enter_suspend(suspend_state_t suspend_state)
3833
3834 static void sh73a0_suspend_init(void)
3835 {
3836- shmobile_suspend_ops.enter = sh73a0_enter_suspend;
3837+ pax_open_kernel();
3838+ *(void **)&shmobile_suspend_ops.enter = sh73a0_enter_suspend;
3839+ pax_close_kernel();
3840 }
3841 #else
3842 static void sh73a0_suspend_init(void) {}
3843diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3844index 7469347..1ecc350 100644
3845--- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3846+++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3847@@ -177,7 +177,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3848 bool entered_lp2 = false;
3849
3850 if (tegra_pending_sgi())
3851- ACCESS_ONCE(abort_flag) = true;
3852+ ACCESS_ONCE_RW(abort_flag) = true;
3853
3854 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3855
3856diff --git a/arch/arm/mach-tegra/irq.c b/arch/arm/mach-tegra/irq.c
3857index 3b9098d..15b390f 100644
3858--- a/arch/arm/mach-tegra/irq.c
3859+++ b/arch/arm/mach-tegra/irq.c
3860@@ -20,6 +20,7 @@
3861 #include <linux/cpu_pm.h>
3862 #include <linux/interrupt.h>
3863 #include <linux/io.h>
3864+#include <linux/irq.h>
3865 #include <linux/irqchip/arm-gic.h>
3866 #include <linux/irq.h>
3867 #include <linux/kernel.h>
3868diff --git a/arch/arm/mach-ux500/pm.c b/arch/arm/mach-ux500/pm.c
3869index 8538910..2f39bc4 100644
3870--- a/arch/arm/mach-ux500/pm.c
3871+++ b/arch/arm/mach-ux500/pm.c
3872@@ -10,6 +10,7 @@
3873 */
3874
3875 #include <linux/kernel.h>
3876+#include <linux/irq.h>
3877 #include <linux/irqchip/arm-gic.h>
3878 #include <linux/delay.h>
3879 #include <linux/io.h>
3880diff --git a/arch/arm/mach-zynq/platsmp.c b/arch/arm/mach-zynq/platsmp.c
3881index f66816c..228b951 100644
3882--- a/arch/arm/mach-zynq/platsmp.c
3883+++ b/arch/arm/mach-zynq/platsmp.c
3884@@ -24,6 +24,7 @@
3885 #include <linux/io.h>
3886 #include <asm/cacheflush.h>
3887 #include <asm/smp_scu.h>
3888+#include <linux/irq.h>
3889 #include <linux/irqchip/arm-gic.h>
3890 #include "common.h"
3891
3892diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3893index 7c6b976..055db09 100644
3894--- a/arch/arm/mm/Kconfig
3895+++ b/arch/arm/mm/Kconfig
3896@@ -446,6 +446,7 @@ config CPU_32v5
3897
3898 config CPU_32v6
3899 bool
3900+ select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3901 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3902
3903 config CPU_32v6K
3904@@ -600,6 +601,7 @@ config CPU_CP15_MPU
3905
3906 config CPU_USE_DOMAINS
3907 bool
3908+ depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3909 help
3910 This option enables or disables the use of domain switching
3911 via the set_fs() function.
3912@@ -818,7 +820,7 @@ config NEED_KUSER_HELPERS
3913
3914 config KUSER_HELPERS
3915 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3916- depends on MMU
3917+ depends on MMU && (!(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND)
3918 default y
3919 help
3920 Warning: disabling this option may break user programs.
3921@@ -832,7 +834,7 @@ config KUSER_HELPERS
3922 See Documentation/arm/kernel_user_helpers.txt for details.
3923
3924 However, the fixed address nature of these helpers can be used
3925- by ROP (return orientated programming) authors when creating
3926+ by ROP (Return Oriented Programming) authors when creating
3927 exploits.
3928
3929 If all of the binaries and libraries which run on your platform
3930diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3931index 9769f1e..16aaa55 100644
3932--- a/arch/arm/mm/alignment.c
3933+++ b/arch/arm/mm/alignment.c
3934@@ -216,10 +216,12 @@ union offset_union {
3935 #define __get16_unaligned_check(ins,val,addr) \
3936 do { \
3937 unsigned int err = 0, v, a = addr; \
3938+ pax_open_userland(); \
3939 __get8_unaligned_check(ins,v,a,err); \
3940 val = v << ((BE) ? 8 : 0); \
3941 __get8_unaligned_check(ins,v,a,err); \
3942 val |= v << ((BE) ? 0 : 8); \
3943+ pax_close_userland(); \
3944 if (err) \
3945 goto fault; \
3946 } while (0)
3947@@ -233,6 +235,7 @@ union offset_union {
3948 #define __get32_unaligned_check(ins,val,addr) \
3949 do { \
3950 unsigned int err = 0, v, a = addr; \
3951+ pax_open_userland(); \
3952 __get8_unaligned_check(ins,v,a,err); \
3953 val = v << ((BE) ? 24 : 0); \
3954 __get8_unaligned_check(ins,v,a,err); \
3955@@ -241,6 +244,7 @@ union offset_union {
3956 val |= v << ((BE) ? 8 : 16); \
3957 __get8_unaligned_check(ins,v,a,err); \
3958 val |= v << ((BE) ? 0 : 24); \
3959+ pax_close_userland(); \
3960 if (err) \
3961 goto fault; \
3962 } while (0)
3963@@ -254,6 +258,7 @@ union offset_union {
3964 #define __put16_unaligned_check(ins,val,addr) \
3965 do { \
3966 unsigned int err = 0, v = val, a = addr; \
3967+ pax_open_userland(); \
3968 __asm__( FIRST_BYTE_16 \
3969 ARM( "1: "ins" %1, [%2], #1\n" ) \
3970 THUMB( "1: "ins" %1, [%2]\n" ) \
3971@@ -273,6 +278,7 @@ union offset_union {
3972 " .popsection\n" \
3973 : "=r" (err), "=&r" (v), "=&r" (a) \
3974 : "0" (err), "1" (v), "2" (a)); \
3975+ pax_close_userland(); \
3976 if (err) \
3977 goto fault; \
3978 } while (0)
3979@@ -286,6 +292,7 @@ union offset_union {
3980 #define __put32_unaligned_check(ins,val,addr) \
3981 do { \
3982 unsigned int err = 0, v = val, a = addr; \
3983+ pax_open_userland(); \
3984 __asm__( FIRST_BYTE_32 \
3985 ARM( "1: "ins" %1, [%2], #1\n" ) \
3986 THUMB( "1: "ins" %1, [%2]\n" ) \
3987@@ -315,6 +322,7 @@ union offset_union {
3988 " .popsection\n" \
3989 : "=r" (err), "=&r" (v), "=&r" (a) \
3990 : "0" (err), "1" (v), "2" (a)); \
3991+ pax_close_userland(); \
3992 if (err) \
3993 goto fault; \
3994 } while (0)
3995diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
3996index 71b3d33..8af9ade 100644
3997--- a/arch/arm/mm/cache-l2x0.c
3998+++ b/arch/arm/mm/cache-l2x0.c
3999@@ -44,7 +44,7 @@ struct l2c_init_data {
4000 void (*configure)(void __iomem *);
4001 void (*unlock)(void __iomem *, unsigned);
4002 struct outer_cache_fns outer_cache;
4003-};
4004+} __do_const;
4005
4006 #define CACHE_LINE_SIZE 32
4007
4008diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
4009index 845769e..4278fd7 100644
4010--- a/arch/arm/mm/context.c
4011+++ b/arch/arm/mm/context.c
4012@@ -43,7 +43,7 @@
4013 #define NUM_USER_ASIDS ASID_FIRST_VERSION
4014
4015 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
4016-static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
4017+static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
4018 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
4019
4020 static DEFINE_PER_CPU(atomic64_t, active_asids);
4021@@ -178,7 +178,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
4022 {
4023 static u32 cur_idx = 1;
4024 u64 asid = atomic64_read(&mm->context.id);
4025- u64 generation = atomic64_read(&asid_generation);
4026+ u64 generation = atomic64_read_unchecked(&asid_generation);
4027
4028 if (asid != 0) {
4029 /*
4030@@ -208,7 +208,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
4031 */
4032 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, cur_idx);
4033 if (asid == NUM_USER_ASIDS) {
4034- generation = atomic64_add_return(ASID_FIRST_VERSION,
4035+ generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
4036 &asid_generation);
4037 flush_context(cpu);
4038 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
4039@@ -240,14 +240,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
4040 cpu_set_reserved_ttbr0();
4041
4042 asid = atomic64_read(&mm->context.id);
4043- if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
4044+ if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
4045 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
4046 goto switch_mm_fastpath;
4047
4048 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
4049 /* Check that our ASID belongs to the current generation. */
4050 asid = atomic64_read(&mm->context.id);
4051- if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
4052+ if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
4053 asid = new_context(mm, cpu);
4054 atomic64_set(&mm->context.id, asid);
4055 }
4056diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
4057index 0d629b8..01867c8 100644
4058--- a/arch/arm/mm/fault.c
4059+++ b/arch/arm/mm/fault.c
4060@@ -25,6 +25,7 @@
4061 #include <asm/system_misc.h>
4062 #include <asm/system_info.h>
4063 #include <asm/tlbflush.h>
4064+#include <asm/sections.h>
4065
4066 #include "fault.h"
4067
4068@@ -138,6 +139,31 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
4069 if (fixup_exception(regs))
4070 return;
4071
4072+#ifdef CONFIG_PAX_MEMORY_UDEREF
4073+ if (addr < TASK_SIZE) {
4074+ if (current->signal->curr_ip)
4075+ 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),
4076+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
4077+ else
4078+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
4079+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
4080+ }
4081+#endif
4082+
4083+#ifdef CONFIG_PAX_KERNEXEC
4084+ if ((fsr & FSR_WRITE) &&
4085+ (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
4086+ (MODULES_VADDR <= addr && addr < MODULES_END)))
4087+ {
4088+ if (current->signal->curr_ip)
4089+ 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),
4090+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
4091+ else
4092+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
4093+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
4094+ }
4095+#endif
4096+
4097 /*
4098 * No handler, we'll have to terminate things with extreme prejudice.
4099 */
4100@@ -173,6 +199,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
4101 }
4102 #endif
4103
4104+#ifdef CONFIG_PAX_PAGEEXEC
4105+ if (fsr & FSR_LNX_PF) {
4106+ pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
4107+ do_group_exit(SIGKILL);
4108+ }
4109+#endif
4110+
4111 tsk->thread.address = addr;
4112 tsk->thread.error_code = fsr;
4113 tsk->thread.trap_no = 14;
4114@@ -400,6 +433,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
4115 }
4116 #endif /* CONFIG_MMU */
4117
4118+#ifdef CONFIG_PAX_PAGEEXEC
4119+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4120+{
4121+ long i;
4122+
4123+ printk(KERN_ERR "PAX: bytes at PC: ");
4124+ for (i = 0; i < 20; i++) {
4125+ unsigned char c;
4126+ if (get_user(c, (__force unsigned char __user *)pc+i))
4127+ printk(KERN_CONT "?? ");
4128+ else
4129+ printk(KERN_CONT "%02x ", c);
4130+ }
4131+ printk("\n");
4132+
4133+ printk(KERN_ERR "PAX: bytes at SP-4: ");
4134+ for (i = -1; i < 20; i++) {
4135+ unsigned long c;
4136+ if (get_user(c, (__force unsigned long __user *)sp+i))
4137+ printk(KERN_CONT "???????? ");
4138+ else
4139+ printk(KERN_CONT "%08lx ", c);
4140+ }
4141+ printk("\n");
4142+}
4143+#endif
4144+
4145 /*
4146 * First Level Translation Fault Handler
4147 *
4148@@ -547,9 +607,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
4149 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
4150 struct siginfo info;
4151
4152+#ifdef CONFIG_PAX_MEMORY_UDEREF
4153+ if (addr < TASK_SIZE && is_domain_fault(fsr)) {
4154+ if (current->signal->curr_ip)
4155+ 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),
4156+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
4157+ else
4158+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
4159+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
4160+ goto die;
4161+ }
4162+#endif
4163+
4164 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
4165 return;
4166
4167+die:
4168 pr_alert("Unhandled fault: %s (0x%03x) at 0x%08lx\n",
4169 inf->name, fsr, addr);
4170 show_pte(current->mm, addr);
4171@@ -574,15 +647,104 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
4172 ifsr_info[nr].name = name;
4173 }
4174
4175+asmlinkage int sys_sigreturn(struct pt_regs *regs);
4176+asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
4177+
4178 asmlinkage void __exception
4179 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
4180 {
4181 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
4182 struct siginfo info;
4183+ unsigned long pc = instruction_pointer(regs);
4184+
4185+ if (user_mode(regs)) {
4186+ unsigned long sigpage = current->mm->context.sigpage;
4187+
4188+ if (sigpage <= pc && pc < sigpage + 7*4) {
4189+ if (pc < sigpage + 3*4)
4190+ sys_sigreturn(regs);
4191+ else
4192+ sys_rt_sigreturn(regs);
4193+ return;
4194+ }
4195+ if (pc == 0xffff0f60UL) {
4196+ /*
4197+ * PaX: __kuser_cmpxchg64 emulation
4198+ */
4199+ // TODO
4200+ //regs->ARM_pc = regs->ARM_lr;
4201+ //return;
4202+ }
4203+ if (pc == 0xffff0fa0UL) {
4204+ /*
4205+ * PaX: __kuser_memory_barrier emulation
4206+ */
4207+ // dmb(); implied by the exception
4208+ regs->ARM_pc = regs->ARM_lr;
4209+ return;
4210+ }
4211+ if (pc == 0xffff0fc0UL) {
4212+ /*
4213+ * PaX: __kuser_cmpxchg emulation
4214+ */
4215+ // TODO
4216+ //long new;
4217+ //int op;
4218+
4219+ //op = FUTEX_OP_SET << 28;
4220+ //new = futex_atomic_op_inuser(op, regs->ARM_r2);
4221+ //regs->ARM_r0 = old != new;
4222+ //regs->ARM_pc = regs->ARM_lr;
4223+ //return;
4224+ }
4225+ if (pc == 0xffff0fe0UL) {
4226+ /*
4227+ * PaX: __kuser_get_tls emulation
4228+ */
4229+ regs->ARM_r0 = current_thread_info()->tp_value[0];
4230+ regs->ARM_pc = regs->ARM_lr;
4231+ return;
4232+ }
4233+ }
4234+
4235+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4236+ else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
4237+ if (current->signal->curr_ip)
4238+ 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),
4239+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
4240+ pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
4241+ else
4242+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
4243+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
4244+ pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
4245+ goto die;
4246+ }
4247+#endif
4248+
4249+#ifdef CONFIG_PAX_REFCOUNT
4250+ if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
4251+#ifdef CONFIG_THUMB2_KERNEL
4252+ unsigned short bkpt;
4253+
4254+ if (!probe_kernel_address(pc, bkpt) && cpu_to_le16(bkpt) == 0xbef1) {
4255+#else
4256+ unsigned int bkpt;
4257+
4258+ if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
4259+#endif
4260+ current->thread.error_code = ifsr;
4261+ current->thread.trap_no = 0;
4262+ pax_report_refcount_overflow(regs);
4263+ fixup_exception(regs);
4264+ return;
4265+ }
4266+ }
4267+#endif
4268
4269 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4270 return;
4271
4272+die:
4273 pr_alert("Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4274 inf->name, ifsr, addr);
4275
4276diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4277index cf08bdf..772656c 100644
4278--- a/arch/arm/mm/fault.h
4279+++ b/arch/arm/mm/fault.h
4280@@ -3,6 +3,7 @@
4281
4282 /*
4283 * Fault status register encodings. We steal bit 31 for our own purposes.
4284+ * Set when the FSR value is from an instruction fault.
4285 */
4286 #define FSR_LNX_PF (1 << 31)
4287 #define FSR_WRITE (1 << 11)
4288@@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4289 }
4290 #endif
4291
4292+/* valid for LPAE and !LPAE */
4293+static inline int is_xn_fault(unsigned int fsr)
4294+{
4295+ return ((fsr_fs(fsr) & 0x3c) == 0xc);
4296+}
4297+
4298+static inline int is_domain_fault(unsigned int fsr)
4299+{
4300+ return ((fsr_fs(fsr) & 0xD) == 0x9);
4301+}
4302+
4303 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4304 unsigned long search_exception_table(unsigned long addr);
4305
4306diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4307index 8a63b4c..6b04370 100644
4308--- a/arch/arm/mm/init.c
4309+++ b/arch/arm/mm/init.c
4310@@ -710,7 +710,46 @@ void free_tcmmem(void)
4311 {
4312 #ifdef CONFIG_HAVE_TCM
4313 extern char __tcm_start, __tcm_end;
4314+#endif
4315
4316+#ifdef CONFIG_PAX_KERNEXEC
4317+ unsigned long addr;
4318+ pgd_t *pgd;
4319+ pud_t *pud;
4320+ pmd_t *pmd;
4321+ int cpu_arch = cpu_architecture();
4322+ unsigned int cr = get_cr();
4323+
4324+ if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4325+ /* make pages tables, etc before .text NX */
4326+ for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4327+ pgd = pgd_offset_k(addr);
4328+ pud = pud_offset(pgd, addr);
4329+ pmd = pmd_offset(pud, addr);
4330+ __section_update(pmd, addr, PMD_SECT_XN);
4331+ }
4332+ /* make init NX */
4333+ for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4334+ pgd = pgd_offset_k(addr);
4335+ pud = pud_offset(pgd, addr);
4336+ pmd = pmd_offset(pud, addr);
4337+ __section_update(pmd, addr, PMD_SECT_XN);
4338+ }
4339+ /* make kernel code/rodata RX */
4340+ for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4341+ pgd = pgd_offset_k(addr);
4342+ pud = pud_offset(pgd, addr);
4343+ pmd = pmd_offset(pud, addr);
4344+#ifdef CONFIG_ARM_LPAE
4345+ __section_update(pmd, addr, PMD_SECT_RDONLY);
4346+#else
4347+ __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4348+#endif
4349+ }
4350+ }
4351+#endif
4352+
4353+#ifdef CONFIG_HAVE_TCM
4354 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4355 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4356 #endif
4357diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4358index 0c81056..97279f7 100644
4359--- a/arch/arm/mm/ioremap.c
4360+++ b/arch/arm/mm/ioremap.c
4361@@ -405,9 +405,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4362 unsigned int mtype;
4363
4364 if (cached)
4365- mtype = MT_MEMORY_RWX;
4366+ mtype = MT_MEMORY_RX;
4367 else
4368- mtype = MT_MEMORY_RWX_NONCACHED;
4369+ mtype = MT_MEMORY_RX_NONCACHED;
4370
4371 return __arm_ioremap_caller(phys_addr, size, mtype,
4372 __builtin_return_address(0));
4373diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4374index 407dc78..047ce9d 100644
4375--- a/arch/arm/mm/mmap.c
4376+++ b/arch/arm/mm/mmap.c
4377@@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4378 struct vm_area_struct *vma;
4379 int do_align = 0;
4380 int aliasing = cache_is_vipt_aliasing();
4381+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4382 struct vm_unmapped_area_info info;
4383
4384 /*
4385@@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4386 if (len > TASK_SIZE)
4387 return -ENOMEM;
4388
4389+#ifdef CONFIG_PAX_RANDMMAP
4390+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4391+#endif
4392+
4393 if (addr) {
4394 if (do_align)
4395 addr = COLOUR_ALIGN(addr, pgoff);
4396@@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4397 addr = PAGE_ALIGN(addr);
4398
4399 vma = find_vma(mm, addr);
4400- if (TASK_SIZE - len >= addr &&
4401- (!vma || addr + len <= vma->vm_start))
4402+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4403 return addr;
4404 }
4405
4406@@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4407 info.high_limit = TASK_SIZE;
4408 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4409 info.align_offset = pgoff << PAGE_SHIFT;
4410+ info.threadstack_offset = offset;
4411 return vm_unmapped_area(&info);
4412 }
4413
4414@@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4415 unsigned long addr = addr0;
4416 int do_align = 0;
4417 int aliasing = cache_is_vipt_aliasing();
4418+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4419 struct vm_unmapped_area_info info;
4420
4421 /*
4422@@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4423 return addr;
4424 }
4425
4426+#ifdef CONFIG_PAX_RANDMMAP
4427+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4428+#endif
4429+
4430 /* requesting a specific address */
4431 if (addr) {
4432 if (do_align)
4433@@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4434 else
4435 addr = PAGE_ALIGN(addr);
4436 vma = find_vma(mm, addr);
4437- if (TASK_SIZE - len >= addr &&
4438- (!vma || addr + len <= vma->vm_start))
4439+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4440 return addr;
4441 }
4442
4443@@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4444 info.high_limit = mm->mmap_base;
4445 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4446 info.align_offset = pgoff << PAGE_SHIFT;
4447+ info.threadstack_offset = offset;
4448 addr = vm_unmapped_area(&info);
4449
4450 /*
4451@@ -183,14 +193,30 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4452 {
4453 unsigned long random_factor = 0UL;
4454
4455+#ifdef CONFIG_PAX_RANDMMAP
4456+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4457+#endif
4458+
4459 if (current->flags & PF_RANDOMIZE)
4460 random_factor = arch_mmap_rnd();
4461
4462 if (mmap_is_legacy()) {
4463 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4464+
4465+#ifdef CONFIG_PAX_RANDMMAP
4466+ if (mm->pax_flags & MF_PAX_RANDMMAP)
4467+ mm->mmap_base += mm->delta_mmap;
4468+#endif
4469+
4470 mm->get_unmapped_area = arch_get_unmapped_area;
4471 } else {
4472 mm->mmap_base = mmap_base(random_factor);
4473+
4474+#ifdef CONFIG_PAX_RANDMMAP
4475+ if (mm->pax_flags & MF_PAX_RANDMMAP)
4476+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4477+#endif
4478+
4479 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4480 }
4481 }
4482diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4483index 870838a..070df1d 100644
4484--- a/arch/arm/mm/mmu.c
4485+++ b/arch/arm/mm/mmu.c
4486@@ -41,6 +41,22 @@
4487 #include "mm.h"
4488 #include "tcm.h"
4489
4490+#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4491+void modify_domain(unsigned int dom, unsigned int type)
4492+{
4493+ struct thread_info *thread = current_thread_info();
4494+ unsigned int domain = thread->cpu_domain;
4495+ /*
4496+ * DOMAIN_MANAGER might be defined to some other value,
4497+ * use the arch-defined constant
4498+ */
4499+ domain &= ~domain_val(dom, 3);
4500+ thread->cpu_domain = domain | domain_val(dom, type);
4501+ set_domain(thread->cpu_domain);
4502+}
4503+EXPORT_SYMBOL(modify_domain);
4504+#endif
4505+
4506 /*
4507 * empty_zero_page is a special page that is used for
4508 * zero-initialized data and COW.
4509@@ -242,7 +258,15 @@ __setup("noalign", noalign_setup);
4510 #define PROT_PTE_S2_DEVICE PROT_PTE_DEVICE
4511 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4512
4513-static struct mem_type mem_types[] = {
4514+#ifdef CONFIG_PAX_KERNEXEC
4515+#define L_PTE_KERNEXEC L_PTE_RDONLY
4516+#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4517+#else
4518+#define L_PTE_KERNEXEC L_PTE_DIRTY
4519+#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4520+#endif
4521+
4522+static struct mem_type mem_types[] __read_only = {
4523 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4524 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4525 L_PTE_SHARED,
4526@@ -271,19 +295,19 @@ static struct mem_type mem_types[] = {
4527 .prot_sect = PROT_SECT_DEVICE,
4528 .domain = DOMAIN_IO,
4529 },
4530- [MT_UNCACHED] = {
4531+ [MT_UNCACHED_RW] = {
4532 .prot_pte = PROT_PTE_DEVICE,
4533 .prot_l1 = PMD_TYPE_TABLE,
4534 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4535 .domain = DOMAIN_IO,
4536 },
4537- [MT_CACHECLEAN] = {
4538- .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4539+ [MT_CACHECLEAN_RO] = {
4540+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_RDONLY,
4541 .domain = DOMAIN_KERNEL,
4542 },
4543 #ifndef CONFIG_ARM_LPAE
4544- [MT_MINICLEAN] = {
4545- .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4546+ [MT_MINICLEAN_RO] = {
4547+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_XN | PMD_SECT_RDONLY,
4548 .domain = DOMAIN_KERNEL,
4549 },
4550 #endif
4551@@ -291,15 +315,15 @@ static struct mem_type mem_types[] = {
4552 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4553 L_PTE_RDONLY,
4554 .prot_l1 = PMD_TYPE_TABLE,
4555- .domain = DOMAIN_USER,
4556+ .domain = DOMAIN_VECTORS,
4557 },
4558 [MT_HIGH_VECTORS] = {
4559 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4560 L_PTE_USER | L_PTE_RDONLY,
4561 .prot_l1 = PMD_TYPE_TABLE,
4562- .domain = DOMAIN_USER,
4563+ .domain = DOMAIN_VECTORS,
4564 },
4565- [MT_MEMORY_RWX] = {
4566+ [__MT_MEMORY_RWX] = {
4567 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4568 .prot_l1 = PMD_TYPE_TABLE,
4569 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4570@@ -312,17 +336,30 @@ static struct mem_type mem_types[] = {
4571 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4572 .domain = DOMAIN_KERNEL,
4573 },
4574- [MT_ROM] = {
4575- .prot_sect = PMD_TYPE_SECT,
4576+ [MT_MEMORY_RX] = {
4577+ .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4578+ .prot_l1 = PMD_TYPE_TABLE,
4579+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4580+ .domain = DOMAIN_KERNEL,
4581+ },
4582+ [MT_ROM_RX] = {
4583+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4584 .domain = DOMAIN_KERNEL,
4585 },
4586- [MT_MEMORY_RWX_NONCACHED] = {
4587+ [MT_MEMORY_RW_NONCACHED] = {
4588 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4589 L_PTE_MT_BUFFERABLE,
4590 .prot_l1 = PMD_TYPE_TABLE,
4591 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4592 .domain = DOMAIN_KERNEL,
4593 },
4594+ [MT_MEMORY_RX_NONCACHED] = {
4595+ .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4596+ L_PTE_MT_BUFFERABLE,
4597+ .prot_l1 = PMD_TYPE_TABLE,
4598+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4599+ .domain = DOMAIN_KERNEL,
4600+ },
4601 [MT_MEMORY_RW_DTCM] = {
4602 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4603 L_PTE_XN,
4604@@ -330,9 +367,10 @@ static struct mem_type mem_types[] = {
4605 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4606 .domain = DOMAIN_KERNEL,
4607 },
4608- [MT_MEMORY_RWX_ITCM] = {
4609- .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4610+ [MT_MEMORY_RX_ITCM] = {
4611+ .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4612 .prot_l1 = PMD_TYPE_TABLE,
4613+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4614 .domain = DOMAIN_KERNEL,
4615 },
4616 [MT_MEMORY_RW_SO] = {
4617@@ -544,9 +582,14 @@ static void __init build_mem_type_table(void)
4618 * Mark cache clean areas and XIP ROM read only
4619 * from SVC mode and no access from userspace.
4620 */
4621- mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4622- mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4623- mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4624+ mem_types[MT_ROM_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4625+#ifdef CONFIG_PAX_KERNEXEC
4626+ mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4627+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4628+ mem_types[MT_MEMORY_RX_ITCM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4629+#endif
4630+ mem_types[MT_MINICLEAN_RO].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4631+ mem_types[MT_CACHECLEAN_RO].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4632 #endif
4633
4634 /*
4635@@ -563,13 +606,17 @@ static void __init build_mem_type_table(void)
4636 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4637 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4638 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4639- mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4640- mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4641+ mem_types[__MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4642+ mem_types[__MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4643 mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4644 mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4645+ mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4646+ mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4647 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4648- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= PMD_SECT_S;
4649- mem_types[MT_MEMORY_RWX_NONCACHED].prot_pte |= L_PTE_SHARED;
4650+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |= PMD_SECT_S;
4651+ mem_types[MT_MEMORY_RW_NONCACHED].prot_pte |= L_PTE_SHARED;
4652+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= PMD_SECT_S;
4653+ mem_types[MT_MEMORY_RX_NONCACHED].prot_pte |= L_PTE_SHARED;
4654 }
4655 }
4656
4657@@ -580,15 +627,20 @@ static void __init build_mem_type_table(void)
4658 if (cpu_arch >= CPU_ARCH_ARMv6) {
4659 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4660 /* Non-cacheable Normal is XCB = 001 */
4661- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |=
4662+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |=
4663+ PMD_SECT_BUFFERED;
4664+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |=
4665 PMD_SECT_BUFFERED;
4666 } else {
4667 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4668- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |=
4669+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |=
4670+ PMD_SECT_TEX(1);
4671+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |=
4672 PMD_SECT_TEX(1);
4673 }
4674 } else {
4675- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4676+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4677+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4678 }
4679
4680 #ifdef CONFIG_ARM_LPAE
4681@@ -609,6 +661,8 @@ static void __init build_mem_type_table(void)
4682 user_pgprot |= PTE_EXT_PXN;
4683 #endif
4684
4685+ user_pgprot |= __supported_pte_mask;
4686+
4687 for (i = 0; i < 16; i++) {
4688 pteval_t v = pgprot_val(protection_map[i]);
4689 protection_map[i] = __pgprot(v | user_pgprot);
4690@@ -626,21 +680,24 @@ static void __init build_mem_type_table(void)
4691
4692 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4693 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4694- mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4695- mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4696+ mem_types[__MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4697+ mem_types[__MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4698 mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4699 mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4700+ mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4701+ mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4702 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4703- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= ecc_mask;
4704- mem_types[MT_ROM].prot_sect |= cp->pmd;
4705+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |= ecc_mask;
4706+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= ecc_mask;
4707+ mem_types[MT_ROM_RX].prot_sect |= cp->pmd;
4708
4709 switch (cp->pmd) {
4710 case PMD_SECT_WT:
4711- mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WT;
4712+ mem_types[MT_CACHECLEAN_RO].prot_sect |= PMD_SECT_WT;
4713 break;
4714 case PMD_SECT_WB:
4715 case PMD_SECT_WBWA:
4716- mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WB;
4717+ mem_types[MT_CACHECLEAN_RO].prot_sect |= PMD_SECT_WB;
4718 break;
4719 }
4720 pr_info("Memory policy: %sData cache %s\n",
4721@@ -854,7 +911,7 @@ static void __init create_mapping(struct map_desc *md)
4722 return;
4723 }
4724
4725- if ((md->type == MT_DEVICE || md->type == MT_ROM) &&
4726+ if ((md->type == MT_DEVICE || md->type == MT_ROM_RX) &&
4727 md->virtual >= PAGE_OFFSET &&
4728 (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) {
4729 pr_warn("BUG: mapping for 0x%08llx at 0x%08lx out of vmalloc space\n",
4730@@ -1224,18 +1281,15 @@ void __init arm_mm_memblock_reserve(void)
4731 * called function. This means you can't use any function or debugging
4732 * method which may touch any device, otherwise the kernel _will_ crash.
4733 */
4734+
4735+static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4736+
4737 static void __init devicemaps_init(const struct machine_desc *mdesc)
4738 {
4739 struct map_desc map;
4740 unsigned long addr;
4741- void *vectors;
4742
4743- /*
4744- * Allocate the vector page early.
4745- */
4746- vectors = early_alloc(PAGE_SIZE * 2);
4747-
4748- early_trap_init(vectors);
4749+ early_trap_init(&vectors);
4750
4751 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4752 pmd_clear(pmd_off_k(addr));
4753@@ -1248,7 +1302,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4754 map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
4755 map.virtual = MODULES_VADDR;
4756 map.length = ((unsigned long)_etext - map.virtual + ~SECTION_MASK) & SECTION_MASK;
4757- map.type = MT_ROM;
4758+ map.type = MT_ROM_RX;
4759 create_mapping(&map);
4760 #endif
4761
4762@@ -1259,14 +1313,14 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4763 map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS);
4764 map.virtual = FLUSH_BASE;
4765 map.length = SZ_1M;
4766- map.type = MT_CACHECLEAN;
4767+ map.type = MT_CACHECLEAN_RO;
4768 create_mapping(&map);
4769 #endif
4770 #ifdef FLUSH_BASE_MINICACHE
4771 map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + SZ_1M);
4772 map.virtual = FLUSH_BASE_MINICACHE;
4773 map.length = SZ_1M;
4774- map.type = MT_MINICLEAN;
4775+ map.type = MT_MINICLEAN_RO;
4776 create_mapping(&map);
4777 #endif
4778
4779@@ -1275,7 +1329,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4780 * location (0xffff0000). If we aren't using high-vectors, also
4781 * create a mapping at the low-vectors virtual address.
4782 */
4783- map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4784+ map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4785 map.virtual = 0xffff0000;
4786 map.length = PAGE_SIZE;
4787 #ifdef CONFIG_KUSER_HELPERS
4788@@ -1335,8 +1389,10 @@ static void __init kmap_init(void)
4789 static void __init map_lowmem(void)
4790 {
4791 struct memblock_region *reg;
4792+#ifndef CONFIG_PAX_KERNEXEC
4793 phys_addr_t kernel_x_start = round_down(__pa(_stext), SECTION_SIZE);
4794 phys_addr_t kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE);
4795+#endif
4796
4797 /* Map all the lowmem memory banks. */
4798 for_each_memblock(memory, reg) {
4799@@ -1349,11 +1405,48 @@ static void __init map_lowmem(void)
4800 if (start >= end)
4801 break;
4802
4803+#ifdef CONFIG_PAX_KERNEXEC
4804+ map.pfn = __phys_to_pfn(start);
4805+ map.virtual = __phys_to_virt(start);
4806+ map.length = end - start;
4807+
4808+ if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4809+ struct map_desc kernel;
4810+ struct map_desc initmap;
4811+
4812+ /* when freeing initmem we will make this RW */
4813+ initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4814+ initmap.virtual = (unsigned long)__init_begin;
4815+ initmap.length = _sdata - __init_begin;
4816+ initmap.type = __MT_MEMORY_RWX;
4817+ create_mapping(&initmap);
4818+
4819+ /* when freeing initmem we will make this RX */
4820+ kernel.pfn = __phys_to_pfn(__pa(_stext));
4821+ kernel.virtual = (unsigned long)_stext;
4822+ kernel.length = __init_begin - _stext;
4823+ kernel.type = __MT_MEMORY_RWX;
4824+ create_mapping(&kernel);
4825+
4826+ if (map.virtual < (unsigned long)_stext) {
4827+ map.length = (unsigned long)_stext - map.virtual;
4828+ map.type = __MT_MEMORY_RWX;
4829+ create_mapping(&map);
4830+ }
4831+
4832+ map.pfn = __phys_to_pfn(__pa(_sdata));
4833+ map.virtual = (unsigned long)_sdata;
4834+ map.length = end - __pa(_sdata);
4835+ }
4836+
4837+ map.type = MT_MEMORY_RW;
4838+ create_mapping(&map);
4839+#else
4840 if (end < kernel_x_start) {
4841 map.pfn = __phys_to_pfn(start);
4842 map.virtual = __phys_to_virt(start);
4843 map.length = end - start;
4844- map.type = MT_MEMORY_RWX;
4845+ map.type = __MT_MEMORY_RWX;
4846
4847 create_mapping(&map);
4848 } else if (start >= kernel_x_end) {
4849@@ -1377,7 +1470,7 @@ static void __init map_lowmem(void)
4850 map.pfn = __phys_to_pfn(kernel_x_start);
4851 map.virtual = __phys_to_virt(kernel_x_start);
4852 map.length = kernel_x_end - kernel_x_start;
4853- map.type = MT_MEMORY_RWX;
4854+ map.type = __MT_MEMORY_RWX;
4855
4856 create_mapping(&map);
4857
4858@@ -1390,6 +1483,7 @@ static void __init map_lowmem(void)
4859 create_mapping(&map);
4860 }
4861 }
4862+#endif
4863 }
4864 }
4865
4866diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
4867index c011e22..92a0260 100644
4868--- a/arch/arm/net/bpf_jit_32.c
4869+++ b/arch/arm/net/bpf_jit_32.c
4870@@ -20,6 +20,7 @@
4871 #include <asm/cacheflush.h>
4872 #include <asm/hwcap.h>
4873 #include <asm/opcodes.h>
4874+#include <asm/pgtable.h>
4875
4876 #include "bpf_jit_32.h"
4877
4878@@ -72,54 +73,38 @@ struct jit_ctx {
4879 #endif
4880 };
4881
4882+#ifdef CONFIG_GRKERNSEC_BPF_HARDEN
4883+int bpf_jit_enable __read_only;
4884+#else
4885 int bpf_jit_enable __read_mostly;
4886+#endif
4887
4888-static inline int call_neg_helper(struct sk_buff *skb, int offset, void *ret,
4889- unsigned int size)
4890-{
4891- void *ptr = bpf_internal_load_pointer_neg_helper(skb, offset, size);
4892-
4893- if (!ptr)
4894- return -EFAULT;
4895- memcpy(ret, ptr, size);
4896- return 0;
4897-}
4898-
4899-static u64 jit_get_skb_b(struct sk_buff *skb, int offset)
4900+static u64 jit_get_skb_b(struct sk_buff *skb, unsigned offset)
4901 {
4902 u8 ret;
4903 int err;
4904
4905- if (offset < 0)
4906- err = call_neg_helper(skb, offset, &ret, 1);
4907- else
4908- err = skb_copy_bits(skb, offset, &ret, 1);
4909+ err = skb_copy_bits(skb, offset, &ret, 1);
4910
4911 return (u64)err << 32 | ret;
4912 }
4913
4914-static u64 jit_get_skb_h(struct sk_buff *skb, int offset)
4915+static u64 jit_get_skb_h(struct sk_buff *skb, unsigned offset)
4916 {
4917 u16 ret;
4918 int err;
4919
4920- if (offset < 0)
4921- err = call_neg_helper(skb, offset, &ret, 2);
4922- else
4923- err = skb_copy_bits(skb, offset, &ret, 2);
4924+ err = skb_copy_bits(skb, offset, &ret, 2);
4925
4926 return (u64)err << 32 | ntohs(ret);
4927 }
4928
4929-static u64 jit_get_skb_w(struct sk_buff *skb, int offset)
4930+static u64 jit_get_skb_w(struct sk_buff *skb, unsigned offset)
4931 {
4932 u32 ret;
4933 int err;
4934
4935- if (offset < 0)
4936- err = call_neg_helper(skb, offset, &ret, 4);
4937- else
4938- err = skb_copy_bits(skb, offset, &ret, 4);
4939+ err = skb_copy_bits(skb, offset, &ret, 4);
4940
4941 return (u64)err << 32 | ntohl(ret);
4942 }
4943@@ -199,8 +184,10 @@ static void jit_fill_hole(void *area, unsigned int size)
4944 {
4945 u32 *ptr;
4946 /* We are guaranteed to have aligned memory. */
4947+ pax_open_kernel();
4948 for (ptr = area; size >= sizeof(u32); size -= sizeof(u32))
4949 *ptr++ = __opcode_to_mem_arm(ARM_INST_UDF);
4950+ pax_close_kernel();
4951 }
4952
4953 static void build_prologue(struct jit_ctx *ctx)
4954@@ -556,6 +543,9 @@ static int build_body(struct jit_ctx *ctx)
4955 case BPF_LD | BPF_B | BPF_ABS:
4956 load_order = 0;
4957 load:
4958+ /* the interpreter will deal with the negative K */
4959+ if ((int)k < 0)
4960+ return -ENOTSUPP;
4961 emit_mov_i(r_off, k, ctx);
4962 load_common:
4963 ctx->seen |= SEEN_DATA | SEEN_CALL;
4964@@ -570,18 +560,6 @@ load_common:
4965 condt = ARM_COND_HI;
4966 }
4967
4968- /*
4969- * test for negative offset, only if we are
4970- * currently scheduled to take the fast
4971- * path. this will update the flags so that
4972- * the slowpath instruction are ignored if the
4973- * offset is negative.
4974- *
4975- * for loard_order == 0 the HI condition will
4976- * make loads at offset 0 take the slow path too.
4977- */
4978- _emit(condt, ARM_CMP_I(r_off, 0), ctx);
4979-
4980 _emit(condt, ARM_ADD_R(r_scratch, r_off, r_skb_data),
4981 ctx);
4982
4983diff --git a/arch/arm/plat-iop/setup.c b/arch/arm/plat-iop/setup.c
4984index 5b217f4..c23f40e 100644
4985--- a/arch/arm/plat-iop/setup.c
4986+++ b/arch/arm/plat-iop/setup.c
4987@@ -24,7 +24,7 @@ static struct map_desc iop3xx_std_desc[] __initdata = {
4988 .virtual = IOP3XX_PERIPHERAL_VIRT_BASE,
4989 .pfn = __phys_to_pfn(IOP3XX_PERIPHERAL_PHYS_BASE),
4990 .length = IOP3XX_PERIPHERAL_SIZE,
4991- .type = MT_UNCACHED,
4992+ .type = MT_UNCACHED_RW,
4993 },
4994 };
4995
4996diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4997index a5bc92d..0bb4730 100644
4998--- a/arch/arm/plat-omap/sram.c
4999+++ b/arch/arm/plat-omap/sram.c
5000@@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
5001 * Looks like we need to preserve some bootloader code at the
5002 * beginning of SRAM for jumping to flash for reboot to work...
5003 */
5004+ pax_open_kernel();
5005 memset_io(omap_sram_base + omap_sram_skip, 0,
5006 omap_sram_size - omap_sram_skip);
5007+ pax_close_kernel();
5008 }
5009diff --git a/arch/arm64/Kconfig.debug b/arch/arm64/Kconfig.debug
5010index d6285ef..b684dac 100644
5011--- a/arch/arm64/Kconfig.debug
5012+++ b/arch/arm64/Kconfig.debug
5013@@ -10,6 +10,7 @@ config ARM64_PTDUMP
5014 bool "Export kernel pagetable layout to userspace via debugfs"
5015 depends on DEBUG_KERNEL
5016 select DEBUG_FS
5017+ depends on !GRKERNSEC_KMEM
5018 help
5019 Say Y here if you want to show the kernel pagetable layout in a
5020 debugfs file. This information is only useful for kernel developers
5021diff --git a/arch/arm64/include/asm/atomic.h b/arch/arm64/include/asm/atomic.h
5022index 7047051..44e8675 100644
5023--- a/arch/arm64/include/asm/atomic.h
5024+++ b/arch/arm64/include/asm/atomic.h
5025@@ -252,5 +252,15 @@ static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
5026 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
5027 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
5028
5029+#define atomic64_read_unchecked(v) atomic64_read(v)
5030+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5031+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5032+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5033+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5034+#define atomic64_inc_unchecked(v) atomic64_inc(v)
5035+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5036+#define atomic64_dec_unchecked(v) atomic64_dec(v)
5037+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5038+
5039 #endif
5040 #endif
5041diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
5042index 0fa47c4..b167938 100644
5043--- a/arch/arm64/include/asm/barrier.h
5044+++ b/arch/arm64/include/asm/barrier.h
5045@@ -44,7 +44,7 @@
5046 do { \
5047 compiletime_assert_atomic_type(*p); \
5048 barrier(); \
5049- ACCESS_ONCE(*p) = (v); \
5050+ ACCESS_ONCE_RW(*p) = (v); \
5051 } while (0)
5052
5053 #define smp_load_acquire(p) \
5054diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h
5055index 4fde8c1..441f84f 100644
5056--- a/arch/arm64/include/asm/percpu.h
5057+++ b/arch/arm64/include/asm/percpu.h
5058@@ -135,16 +135,16 @@ static inline void __percpu_write(void *ptr, unsigned long val, int size)
5059 {
5060 switch (size) {
5061 case 1:
5062- ACCESS_ONCE(*(u8 *)ptr) = (u8)val;
5063+ ACCESS_ONCE_RW(*(u8 *)ptr) = (u8)val;
5064 break;
5065 case 2:
5066- ACCESS_ONCE(*(u16 *)ptr) = (u16)val;
5067+ ACCESS_ONCE_RW(*(u16 *)ptr) = (u16)val;
5068 break;
5069 case 4:
5070- ACCESS_ONCE(*(u32 *)ptr) = (u32)val;
5071+ ACCESS_ONCE_RW(*(u32 *)ptr) = (u32)val;
5072 break;
5073 case 8:
5074- ACCESS_ONCE(*(u64 *)ptr) = (u64)val;
5075+ ACCESS_ONCE_RW(*(u64 *)ptr) = (u64)val;
5076 break;
5077 default:
5078 BUILD_BUG();
5079diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h
5080index 7642056..bffc904 100644
5081--- a/arch/arm64/include/asm/pgalloc.h
5082+++ b/arch/arm64/include/asm/pgalloc.h
5083@@ -46,6 +46,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5084 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
5085 }
5086
5087+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5088+{
5089+ pud_populate(mm, pud, pmd);
5090+}
5091+
5092 #endif /* CONFIG_PGTABLE_LEVELS > 2 */
5093
5094 #if CONFIG_PGTABLE_LEVELS > 3
5095diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
5096index 07e1ba44..ec8cbbb 100644
5097--- a/arch/arm64/include/asm/uaccess.h
5098+++ b/arch/arm64/include/asm/uaccess.h
5099@@ -99,6 +99,7 @@ static inline void set_fs(mm_segment_t fs)
5100 flag; \
5101 })
5102
5103+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
5104 #define access_ok(type, addr, size) __range_ok(addr, size)
5105 #define user_addr_max get_fs
5106
5107diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
5108index d16a1ce..a5acc60 100644
5109--- a/arch/arm64/mm/dma-mapping.c
5110+++ b/arch/arm64/mm/dma-mapping.c
5111@@ -134,7 +134,7 @@ static void __dma_free_coherent(struct device *dev, size_t size,
5112 phys_to_page(paddr),
5113 size >> PAGE_SHIFT);
5114 if (!freed)
5115- swiotlb_free_coherent(dev, size, vaddr, dma_handle);
5116+ swiotlb_free_coherent(dev, size, vaddr, dma_handle, attrs);
5117 }
5118
5119 static void *__dma_alloc(struct device *dev, size_t size,
5120diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
5121index c3a58a1..78fbf54 100644
5122--- a/arch/avr32/include/asm/cache.h
5123+++ b/arch/avr32/include/asm/cache.h
5124@@ -1,8 +1,10 @@
5125 #ifndef __ASM_AVR32_CACHE_H
5126 #define __ASM_AVR32_CACHE_H
5127
5128+#include <linux/const.h>
5129+
5130 #define L1_CACHE_SHIFT 5
5131-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5132+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5133
5134 /*
5135 * Memory returned by kmalloc() may be used for DMA, so we must make
5136diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
5137index 0388ece..87c8df1 100644
5138--- a/arch/avr32/include/asm/elf.h
5139+++ b/arch/avr32/include/asm/elf.h
5140@@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
5141 the loader. We need to make sure that it is out of the way of the program
5142 that it will "exec", and that there is sufficient room for the brk. */
5143
5144-#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5145+#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5146
5147+#ifdef CONFIG_PAX_ASLR
5148+#define PAX_ELF_ET_DYN_BASE 0x00001000UL
5149+
5150+#define PAX_DELTA_MMAP_LEN 15
5151+#define PAX_DELTA_STACK_LEN 15
5152+#endif
5153
5154 /* This yields a mask that user programs can use to figure out what
5155 instruction set this CPU supports. This could be done in user space,
5156diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
5157index 479330b..53717a8 100644
5158--- a/arch/avr32/include/asm/kmap_types.h
5159+++ b/arch/avr32/include/asm/kmap_types.h
5160@@ -2,9 +2,9 @@
5161 #define __ASM_AVR32_KMAP_TYPES_H
5162
5163 #ifdef CONFIG_DEBUG_HIGHMEM
5164-# define KM_TYPE_NR 29
5165+# define KM_TYPE_NR 30
5166 #else
5167-# define KM_TYPE_NR 14
5168+# define KM_TYPE_NR 15
5169 #endif
5170
5171 #endif /* __ASM_AVR32_KMAP_TYPES_H */
5172diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
5173index c035339..e1fa594 100644
5174--- a/arch/avr32/mm/fault.c
5175+++ b/arch/avr32/mm/fault.c
5176@@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
5177
5178 int exception_trace = 1;
5179
5180+#ifdef CONFIG_PAX_PAGEEXEC
5181+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5182+{
5183+ unsigned long i;
5184+
5185+ printk(KERN_ERR "PAX: bytes at PC: ");
5186+ for (i = 0; i < 20; i++) {
5187+ unsigned char c;
5188+ if (get_user(c, (unsigned char *)pc+i))
5189+ printk(KERN_CONT "???????? ");
5190+ else
5191+ printk(KERN_CONT "%02x ", c);
5192+ }
5193+ printk("\n");
5194+}
5195+#endif
5196+
5197 /*
5198 * This routine handles page faults. It determines the address and the
5199 * problem, and then passes it off to one of the appropriate routines.
5200@@ -178,6 +195,16 @@ bad_area:
5201 up_read(&mm->mmap_sem);
5202
5203 if (user_mode(regs)) {
5204+
5205+#ifdef CONFIG_PAX_PAGEEXEC
5206+ if (mm->pax_flags & MF_PAX_PAGEEXEC) {
5207+ if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
5208+ pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
5209+ do_group_exit(SIGKILL);
5210+ }
5211+ }
5212+#endif
5213+
5214 if (exception_trace && printk_ratelimit())
5215 printk("%s%s[%d]: segfault at %08lx pc %08lx "
5216 "sp %08lx ecr %lu\n",
5217diff --git a/arch/blackfin/Kconfig.debug b/arch/blackfin/Kconfig.debug
5218index f3337ee..15b6f8d 100644
5219--- a/arch/blackfin/Kconfig.debug
5220+++ b/arch/blackfin/Kconfig.debug
5221@@ -18,6 +18,7 @@ config DEBUG_VERBOSE
5222 config DEBUG_MMRS
5223 tristate "Generate Blackfin MMR tree"
5224 select DEBUG_FS
5225+ depends on !GRKERNSEC_KMEM
5226 help
5227 Create a tree of Blackfin MMRs via the debugfs tree. If
5228 you enable this, you will find all MMRs laid out in the
5229diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
5230index 568885a..f8008df 100644
5231--- a/arch/blackfin/include/asm/cache.h
5232+++ b/arch/blackfin/include/asm/cache.h
5233@@ -7,6 +7,7 @@
5234 #ifndef __ARCH_BLACKFIN_CACHE_H
5235 #define __ARCH_BLACKFIN_CACHE_H
5236
5237+#include <linux/const.h>
5238 #include <linux/linkage.h> /* for asmlinkage */
5239
5240 /*
5241@@ -14,7 +15,7 @@
5242 * Blackfin loads 32 bytes for cache
5243 */
5244 #define L1_CACHE_SHIFT 5
5245-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5246+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5247 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5248
5249 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5250diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
5251index aea2718..3639a60 100644
5252--- a/arch/cris/include/arch-v10/arch/cache.h
5253+++ b/arch/cris/include/arch-v10/arch/cache.h
5254@@ -1,8 +1,9 @@
5255 #ifndef _ASM_ARCH_CACHE_H
5256 #define _ASM_ARCH_CACHE_H
5257
5258+#include <linux/const.h>
5259 /* Etrax 100LX have 32-byte cache-lines. */
5260-#define L1_CACHE_BYTES 32
5261 #define L1_CACHE_SHIFT 5
5262+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5263
5264 #endif /* _ASM_ARCH_CACHE_H */
5265diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
5266index 7caf25d..ee65ac5 100644
5267--- a/arch/cris/include/arch-v32/arch/cache.h
5268+++ b/arch/cris/include/arch-v32/arch/cache.h
5269@@ -1,11 +1,12 @@
5270 #ifndef _ASM_CRIS_ARCH_CACHE_H
5271 #define _ASM_CRIS_ARCH_CACHE_H
5272
5273+#include <linux/const.h>
5274 #include <arch/hwregs/dma.h>
5275
5276 /* A cache-line is 32 bytes. */
5277-#define L1_CACHE_BYTES 32
5278 #define L1_CACHE_SHIFT 5
5279+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5280
5281 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
5282
5283diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
5284index 102190a..5334cea 100644
5285--- a/arch/frv/include/asm/atomic.h
5286+++ b/arch/frv/include/asm/atomic.h
5287@@ -181,6 +181,16 @@ static inline void atomic64_dec(atomic64_t *v)
5288 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
5289 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
5290
5291+#define atomic64_read_unchecked(v) atomic64_read(v)
5292+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5293+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5294+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5295+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5296+#define atomic64_inc_unchecked(v) atomic64_inc(v)
5297+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5298+#define atomic64_dec_unchecked(v) atomic64_dec(v)
5299+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5300+
5301 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5302 {
5303 int c, old;
5304diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
5305index 2797163..c2a401df9 100644
5306--- a/arch/frv/include/asm/cache.h
5307+++ b/arch/frv/include/asm/cache.h
5308@@ -12,10 +12,11 @@
5309 #ifndef __ASM_CACHE_H
5310 #define __ASM_CACHE_H
5311
5312+#include <linux/const.h>
5313
5314 /* bytes per L1 cache line */
5315 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
5316-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5317+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5318
5319 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
5320 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
5321diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
5322index 43901f2..0d8b865 100644
5323--- a/arch/frv/include/asm/kmap_types.h
5324+++ b/arch/frv/include/asm/kmap_types.h
5325@@ -2,6 +2,6 @@
5326 #ifndef _ASM_KMAP_TYPES_H
5327 #define _ASM_KMAP_TYPES_H
5328
5329-#define KM_TYPE_NR 17
5330+#define KM_TYPE_NR 18
5331
5332 #endif
5333diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
5334index 836f147..4cf23f5 100644
5335--- a/arch/frv/mm/elf-fdpic.c
5336+++ b/arch/frv/mm/elf-fdpic.c
5337@@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5338 {
5339 struct vm_area_struct *vma;
5340 struct vm_unmapped_area_info info;
5341+ unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5342
5343 if (len > TASK_SIZE)
5344 return -ENOMEM;
5345@@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5346 if (addr) {
5347 addr = PAGE_ALIGN(addr);
5348 vma = find_vma(current->mm, addr);
5349- if (TASK_SIZE - len >= addr &&
5350- (!vma || addr + len <= vma->vm_start))
5351+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
5352 goto success;
5353 }
5354
5355@@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5356 info.high_limit = (current->mm->start_stack - 0x00200000);
5357 info.align_mask = 0;
5358 info.align_offset = 0;
5359+ info.threadstack_offset = offset;
5360 addr = vm_unmapped_area(&info);
5361 if (!(addr & ~PAGE_MASK))
5362 goto success;
5363diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
5364index 69952c18..4fa2908 100644
5365--- a/arch/hexagon/include/asm/cache.h
5366+++ b/arch/hexagon/include/asm/cache.h
5367@@ -21,9 +21,11 @@
5368 #ifndef __ASM_CACHE_H
5369 #define __ASM_CACHE_H
5370
5371+#include <linux/const.h>
5372+
5373 /* Bytes per L1 cache line */
5374-#define L1_CACHE_SHIFT (5)
5375-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5376+#define L1_CACHE_SHIFT 5
5377+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5378
5379 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5380
5381diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
5382index 42a91a7..29d446e 100644
5383--- a/arch/ia64/Kconfig
5384+++ b/arch/ia64/Kconfig
5385@@ -518,6 +518,7 @@ source "drivers/sn/Kconfig"
5386 config KEXEC
5387 bool "kexec system call"
5388 depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
5389+ depends on !GRKERNSEC_KMEM
5390 help
5391 kexec is a system call that implements the ability to shutdown your
5392 current kernel, and to start another kernel. It is like a reboot
5393diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
5394index 970d0bd..e750b9b 100644
5395--- a/arch/ia64/Makefile
5396+++ b/arch/ia64/Makefile
5397@@ -98,5 +98,6 @@ endef
5398 archprepare: make_nr_irqs_h FORCE
5399 PHONY += make_nr_irqs_h FORCE
5400
5401+make_nr_irqs_h: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
5402 make_nr_irqs_h: FORCE
5403 $(Q)$(MAKE) $(build)=arch/ia64/kernel include/generated/nr-irqs.h
5404diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
5405index 0bf0350..2ad1957 100644
5406--- a/arch/ia64/include/asm/atomic.h
5407+++ b/arch/ia64/include/asm/atomic.h
5408@@ -193,4 +193,14 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
5409 #define atomic64_inc(v) atomic64_add(1, (v))
5410 #define atomic64_dec(v) atomic64_sub(1, (v))
5411
5412+#define atomic64_read_unchecked(v) atomic64_read(v)
5413+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5414+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5415+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5416+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5417+#define atomic64_inc_unchecked(v) atomic64_inc(v)
5418+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5419+#define atomic64_dec_unchecked(v) atomic64_dec(v)
5420+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5421+
5422 #endif /* _ASM_IA64_ATOMIC_H */
5423diff --git a/arch/ia64/include/asm/barrier.h b/arch/ia64/include/asm/barrier.h
5424index 843ba43..fa118fb 100644
5425--- a/arch/ia64/include/asm/barrier.h
5426+++ b/arch/ia64/include/asm/barrier.h
5427@@ -66,7 +66,7 @@
5428 do { \
5429 compiletime_assert_atomic_type(*p); \
5430 barrier(); \
5431- ACCESS_ONCE(*p) = (v); \
5432+ ACCESS_ONCE_RW(*p) = (v); \
5433 } while (0)
5434
5435 #define smp_load_acquire(p) \
5436diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
5437index 988254a..e1ee885 100644
5438--- a/arch/ia64/include/asm/cache.h
5439+++ b/arch/ia64/include/asm/cache.h
5440@@ -1,6 +1,7 @@
5441 #ifndef _ASM_IA64_CACHE_H
5442 #define _ASM_IA64_CACHE_H
5443
5444+#include <linux/const.h>
5445
5446 /*
5447 * Copyright (C) 1998-2000 Hewlett-Packard Co
5448@@ -9,7 +10,7 @@
5449
5450 /* Bytes per L1 (data) cache line. */
5451 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
5452-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5453+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5454
5455 #ifdef CONFIG_SMP
5456 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5457diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
5458index 5a83c5c..4d7f553 100644
5459--- a/arch/ia64/include/asm/elf.h
5460+++ b/arch/ia64/include/asm/elf.h
5461@@ -42,6 +42,13 @@
5462 */
5463 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
5464
5465+#ifdef CONFIG_PAX_ASLR
5466+#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
5467+
5468+#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
5469+#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
5470+#endif
5471+
5472 #define PT_IA_64_UNWIND 0x70000001
5473
5474 /* IA-64 relocations: */
5475diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
5476index f5e70e9..624fad5 100644
5477--- a/arch/ia64/include/asm/pgalloc.h
5478+++ b/arch/ia64/include/asm/pgalloc.h
5479@@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
5480 pgd_val(*pgd_entry) = __pa(pud);
5481 }
5482
5483+static inline void
5484+pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
5485+{
5486+ pgd_populate(mm, pgd_entry, pud);
5487+}
5488+
5489 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
5490 {
5491 return quicklist_alloc(0, GFP_KERNEL, NULL);
5492@@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
5493 pud_val(*pud_entry) = __pa(pmd);
5494 }
5495
5496+static inline void
5497+pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
5498+{
5499+ pud_populate(mm, pud_entry, pmd);
5500+}
5501+
5502 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
5503 {
5504 return quicklist_alloc(0, GFP_KERNEL, NULL);
5505diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
5506index 9f3ed9e..c99b418 100644
5507--- a/arch/ia64/include/asm/pgtable.h
5508+++ b/arch/ia64/include/asm/pgtable.h
5509@@ -12,7 +12,7 @@
5510 * David Mosberger-Tang <davidm@hpl.hp.com>
5511 */
5512
5513-
5514+#include <linux/const.h>
5515 #include <asm/mman.h>
5516 #include <asm/page.h>
5517 #include <asm/processor.h>
5518@@ -139,6 +139,17 @@
5519 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5520 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5521 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
5522+
5523+#ifdef CONFIG_PAX_PAGEEXEC
5524+# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
5525+# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5526+# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5527+#else
5528+# define PAGE_SHARED_NOEXEC PAGE_SHARED
5529+# define PAGE_READONLY_NOEXEC PAGE_READONLY
5530+# define PAGE_COPY_NOEXEC PAGE_COPY
5531+#endif
5532+
5533 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
5534 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
5535 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
5536diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
5537index 45698cd..e8e2dbc 100644
5538--- a/arch/ia64/include/asm/spinlock.h
5539+++ b/arch/ia64/include/asm/spinlock.h
5540@@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
5541 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
5542
5543 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
5544- ACCESS_ONCE(*p) = (tmp + 2) & ~1;
5545+ ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
5546 }
5547
5548 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
5549diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
5550index 4f3fb6cc..254055e 100644
5551--- a/arch/ia64/include/asm/uaccess.h
5552+++ b/arch/ia64/include/asm/uaccess.h
5553@@ -70,6 +70,7 @@
5554 && ((segment).seg == KERNEL_DS.seg \
5555 || likely(REGION_OFFSET((unsigned long) (addr)) < RGN_MAP_LIMIT))); \
5556 })
5557+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
5558 #define access_ok(type, addr, size) __access_ok((addr), (size), get_fs())
5559
5560 /*
5561@@ -241,12 +242,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
5562 static inline unsigned long
5563 __copy_to_user (void __user *to, const void *from, unsigned long count)
5564 {
5565+ if (count > INT_MAX)
5566+ return count;
5567+
5568+ if (!__builtin_constant_p(count))
5569+ check_object_size(from, count, true);
5570+
5571 return __copy_user(to, (__force void __user *) from, count);
5572 }
5573
5574 static inline unsigned long
5575 __copy_from_user (void *to, const void __user *from, unsigned long count)
5576 {
5577+ if (count > INT_MAX)
5578+ return count;
5579+
5580+ if (!__builtin_constant_p(count))
5581+ check_object_size(to, count, false);
5582+
5583 return __copy_user((__force void __user *) to, from, count);
5584 }
5585
5586@@ -256,10 +269,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5587 ({ \
5588 void __user *__cu_to = (to); \
5589 const void *__cu_from = (from); \
5590- long __cu_len = (n); \
5591+ unsigned long __cu_len = (n); \
5592 \
5593- if (__access_ok(__cu_to, __cu_len, get_fs())) \
5594+ if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5595+ if (!__builtin_constant_p(n)) \
5596+ check_object_size(__cu_from, __cu_len, true); \
5597 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5598+ } \
5599 __cu_len; \
5600 })
5601
5602@@ -267,11 +283,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5603 ({ \
5604 void *__cu_to = (to); \
5605 const void __user *__cu_from = (from); \
5606- long __cu_len = (n); \
5607+ unsigned long __cu_len = (n); \
5608 \
5609 __chk_user_ptr(__cu_from); \
5610- if (__access_ok(__cu_from, __cu_len, get_fs())) \
5611+ if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5612+ if (!__builtin_constant_p(n)) \
5613+ check_object_size(__cu_to, __cu_len, false); \
5614 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5615+ } \
5616 __cu_len; \
5617 })
5618
5619diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5620index b15933c..098b1c8 100644
5621--- a/arch/ia64/kernel/module.c
5622+++ b/arch/ia64/kernel/module.c
5623@@ -484,15 +484,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5624 }
5625
5626 static inline int
5627+in_init_rx (const struct module *mod, uint64_t addr)
5628+{
5629+ return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5630+}
5631+
5632+static inline int
5633+in_init_rw (const struct module *mod, uint64_t addr)
5634+{
5635+ return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5636+}
5637+
5638+static inline int
5639 in_init (const struct module *mod, uint64_t addr)
5640 {
5641- return addr - (uint64_t) mod->module_init < mod->init_size;
5642+ return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5643+}
5644+
5645+static inline int
5646+in_core_rx (const struct module *mod, uint64_t addr)
5647+{
5648+ return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5649+}
5650+
5651+static inline int
5652+in_core_rw (const struct module *mod, uint64_t addr)
5653+{
5654+ return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5655 }
5656
5657 static inline int
5658 in_core (const struct module *mod, uint64_t addr)
5659 {
5660- return addr - (uint64_t) mod->module_core < mod->core_size;
5661+ return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5662 }
5663
5664 static inline int
5665@@ -675,7 +699,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5666 break;
5667
5668 case RV_BDREL:
5669- val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5670+ if (in_init_rx(mod, val))
5671+ val -= (uint64_t) mod->module_init_rx;
5672+ else if (in_init_rw(mod, val))
5673+ val -= (uint64_t) mod->module_init_rw;
5674+ else if (in_core_rx(mod, val))
5675+ val -= (uint64_t) mod->module_core_rx;
5676+ else if (in_core_rw(mod, val))
5677+ val -= (uint64_t) mod->module_core_rw;
5678 break;
5679
5680 case RV_LTV:
5681@@ -810,15 +841,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5682 * addresses have been selected...
5683 */
5684 uint64_t gp;
5685- if (mod->core_size > MAX_LTOFF)
5686+ if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5687 /*
5688 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5689 * at the end of the module.
5690 */
5691- gp = mod->core_size - MAX_LTOFF / 2;
5692+ gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5693 else
5694- gp = mod->core_size / 2;
5695- gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5696+ gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5697+ gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5698 mod->arch.gp = gp;
5699 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5700 }
5701diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5702index c39c3cd..3c77738 100644
5703--- a/arch/ia64/kernel/palinfo.c
5704+++ b/arch/ia64/kernel/palinfo.c
5705@@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5706 return NOTIFY_OK;
5707 }
5708
5709-static struct notifier_block __refdata palinfo_cpu_notifier =
5710+static struct notifier_block palinfo_cpu_notifier =
5711 {
5712 .notifier_call = palinfo_cpu_callback,
5713 .priority = 0,
5714diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5715index 41e33f8..65180b2a 100644
5716--- a/arch/ia64/kernel/sys_ia64.c
5717+++ b/arch/ia64/kernel/sys_ia64.c
5718@@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5719 unsigned long align_mask = 0;
5720 struct mm_struct *mm = current->mm;
5721 struct vm_unmapped_area_info info;
5722+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5723
5724 if (len > RGN_MAP_LIMIT)
5725 return -ENOMEM;
5726@@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5727 if (REGION_NUMBER(addr) == RGN_HPAGE)
5728 addr = 0;
5729 #endif
5730+
5731+#ifdef CONFIG_PAX_RANDMMAP
5732+ if (mm->pax_flags & MF_PAX_RANDMMAP)
5733+ addr = mm->free_area_cache;
5734+ else
5735+#endif
5736+
5737 if (!addr)
5738 addr = TASK_UNMAPPED_BASE;
5739
5740@@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5741 info.high_limit = TASK_SIZE;
5742 info.align_mask = align_mask;
5743 info.align_offset = 0;
5744+ info.threadstack_offset = offset;
5745 return vm_unmapped_area(&info);
5746 }
5747
5748diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5749index dc506b0..39baade 100644
5750--- a/arch/ia64/kernel/vmlinux.lds.S
5751+++ b/arch/ia64/kernel/vmlinux.lds.S
5752@@ -171,7 +171,7 @@ SECTIONS {
5753 /* Per-cpu data: */
5754 . = ALIGN(PERCPU_PAGE_SIZE);
5755 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5756- __phys_per_cpu_start = __per_cpu_load;
5757+ __phys_per_cpu_start = per_cpu_load;
5758 /*
5759 * ensure percpu data fits
5760 * into percpu page size
5761diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5762index 70b40d1..01a9a28 100644
5763--- a/arch/ia64/mm/fault.c
5764+++ b/arch/ia64/mm/fault.c
5765@@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5766 return pte_present(pte);
5767 }
5768
5769+#ifdef CONFIG_PAX_PAGEEXEC
5770+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5771+{
5772+ unsigned long i;
5773+
5774+ printk(KERN_ERR "PAX: bytes at PC: ");
5775+ for (i = 0; i < 8; i++) {
5776+ unsigned int c;
5777+ if (get_user(c, (unsigned int *)pc+i))
5778+ printk(KERN_CONT "???????? ");
5779+ else
5780+ printk(KERN_CONT "%08x ", c);
5781+ }
5782+ printk("\n");
5783+}
5784+#endif
5785+
5786 # define VM_READ_BIT 0
5787 # define VM_WRITE_BIT 1
5788 # define VM_EXEC_BIT 2
5789@@ -151,8 +168,21 @@ retry:
5790 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5791 goto bad_area;
5792
5793- if ((vma->vm_flags & mask) != mask)
5794+ if ((vma->vm_flags & mask) != mask) {
5795+
5796+#ifdef CONFIG_PAX_PAGEEXEC
5797+ if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5798+ if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5799+ goto bad_area;
5800+
5801+ up_read(&mm->mmap_sem);
5802+ pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5803+ do_group_exit(SIGKILL);
5804+ }
5805+#endif
5806+
5807 goto bad_area;
5808+ }
5809
5810 /*
5811 * If for any reason at all we couldn't handle the fault, make
5812diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5813index f50d4b3..c7975ee 100644
5814--- a/arch/ia64/mm/hugetlbpage.c
5815+++ b/arch/ia64/mm/hugetlbpage.c
5816@@ -138,6 +138,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5817 unsigned long pgoff, unsigned long flags)
5818 {
5819 struct vm_unmapped_area_info info;
5820+ unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5821
5822 if (len > RGN_MAP_LIMIT)
5823 return -ENOMEM;
5824@@ -161,6 +162,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5825 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5826 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5827 info.align_offset = 0;
5828+ info.threadstack_offset = offset;
5829 return vm_unmapped_area(&info);
5830 }
5831
5832diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5833index 97e48b0..fc59c36 100644
5834--- a/arch/ia64/mm/init.c
5835+++ b/arch/ia64/mm/init.c
5836@@ -119,6 +119,19 @@ ia64_init_addr_space (void)
5837 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5838 vma->vm_end = vma->vm_start + PAGE_SIZE;
5839 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5840+
5841+#ifdef CONFIG_PAX_PAGEEXEC
5842+ if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5843+ vma->vm_flags &= ~VM_EXEC;
5844+
5845+#ifdef CONFIG_PAX_MPROTECT
5846+ if (current->mm->pax_flags & MF_PAX_MPROTECT)
5847+ vma->vm_flags &= ~VM_MAYEXEC;
5848+#endif
5849+
5850+ }
5851+#endif
5852+
5853 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5854 down_write(&current->mm->mmap_sem);
5855 if (insert_vm_struct(current->mm, vma)) {
5856@@ -279,7 +292,7 @@ static int __init gate_vma_init(void)
5857 gate_vma.vm_start = FIXADDR_USER_START;
5858 gate_vma.vm_end = FIXADDR_USER_END;
5859 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
5860- gate_vma.vm_page_prot = __P101;
5861+ gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
5862
5863 return 0;
5864 }
5865diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5866index 40b3ee98..8c2c112 100644
5867--- a/arch/m32r/include/asm/cache.h
5868+++ b/arch/m32r/include/asm/cache.h
5869@@ -1,8 +1,10 @@
5870 #ifndef _ASM_M32R_CACHE_H
5871 #define _ASM_M32R_CACHE_H
5872
5873+#include <linux/const.h>
5874+
5875 /* L1 cache line size */
5876 #define L1_CACHE_SHIFT 4
5877-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5878+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5879
5880 #endif /* _ASM_M32R_CACHE_H */
5881diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5882index 82abd15..d95ae5d 100644
5883--- a/arch/m32r/lib/usercopy.c
5884+++ b/arch/m32r/lib/usercopy.c
5885@@ -14,6 +14,9 @@
5886 unsigned long
5887 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5888 {
5889+ if ((long)n < 0)
5890+ return n;
5891+
5892 prefetch(from);
5893 if (access_ok(VERIFY_WRITE, to, n))
5894 __copy_user(to,from,n);
5895@@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5896 unsigned long
5897 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5898 {
5899+ if ((long)n < 0)
5900+ return n;
5901+
5902 prefetchw(to);
5903 if (access_ok(VERIFY_READ, from, n))
5904 __copy_user_zeroing(to,from,n);
5905diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5906index 0395c51..5f26031 100644
5907--- a/arch/m68k/include/asm/cache.h
5908+++ b/arch/m68k/include/asm/cache.h
5909@@ -4,9 +4,11 @@
5910 #ifndef __ARCH_M68K_CACHE_H
5911 #define __ARCH_M68K_CACHE_H
5912
5913+#include <linux/const.h>
5914+
5915 /* bytes per L1 cache line */
5916 #define L1_CACHE_SHIFT 4
5917-#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5918+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5919
5920 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5921
5922diff --git a/arch/metag/include/asm/barrier.h b/arch/metag/include/asm/barrier.h
5923index 5a696e5..070490d 100644
5924--- a/arch/metag/include/asm/barrier.h
5925+++ b/arch/metag/include/asm/barrier.h
5926@@ -90,7 +90,7 @@ static inline void fence(void)
5927 do { \
5928 compiletime_assert_atomic_type(*p); \
5929 smp_mb(); \
5930- ACCESS_ONCE(*p) = (v); \
5931+ ACCESS_ONCE_RW(*p) = (v); \
5932 } while (0)
5933
5934 #define smp_load_acquire(p) \
5935diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5936index 53f0f6c..2dc07fd 100644
5937--- a/arch/metag/mm/hugetlbpage.c
5938+++ b/arch/metag/mm/hugetlbpage.c
5939@@ -189,6 +189,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5940 info.high_limit = TASK_SIZE;
5941 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5942 info.align_offset = 0;
5943+ info.threadstack_offset = 0;
5944 return vm_unmapped_area(&info);
5945 }
5946
5947diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5948index 4efe96a..60e8699 100644
5949--- a/arch/microblaze/include/asm/cache.h
5950+++ b/arch/microblaze/include/asm/cache.h
5951@@ -13,11 +13,12 @@
5952 #ifndef _ASM_MICROBLAZE_CACHE_H
5953 #define _ASM_MICROBLAZE_CACHE_H
5954
5955+#include <linux/const.h>
5956 #include <asm/registers.h>
5957
5958 #define L1_CACHE_SHIFT 5
5959 /* word-granular cache in microblaze */
5960-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5961+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5962
5963 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5964
5965diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
5966index 199a835..822b487 100644
5967--- a/arch/mips/Kconfig
5968+++ b/arch/mips/Kconfig
5969@@ -2591,6 +2591,7 @@ source "kernel/Kconfig.preempt"
5970
5971 config KEXEC
5972 bool "Kexec system call"
5973+ depends on !GRKERNSEC_KMEM
5974 help
5975 kexec is a system call that implements the ability to shutdown your
5976 current kernel, and to start another kernel. It is like a reboot
5977diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c
5978index d8960d4..77dbd31 100644
5979--- a/arch/mips/cavium-octeon/dma-octeon.c
5980+++ b/arch/mips/cavium-octeon/dma-octeon.c
5981@@ -199,7 +199,7 @@ static void octeon_dma_free_coherent(struct device *dev, size_t size,
5982 if (dma_release_from_coherent(dev, order, vaddr))
5983 return;
5984
5985- swiotlb_free_coherent(dev, size, vaddr, dma_handle);
5986+ swiotlb_free_coherent(dev, size, vaddr, dma_handle, attrs);
5987 }
5988
5989 static dma_addr_t octeon_unity_phys_to_dma(struct device *dev, phys_addr_t paddr)
5990diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5991index 26d4363..3c9a82e 100644
5992--- a/arch/mips/include/asm/atomic.h
5993+++ b/arch/mips/include/asm/atomic.h
5994@@ -22,15 +22,39 @@
5995 #include <asm/cmpxchg.h>
5996 #include <asm/war.h>
5997
5998+#ifdef CONFIG_GENERIC_ATOMIC64
5999+#include <asm-generic/atomic64.h>
6000+#endif
6001+
6002 #define ATOMIC_INIT(i) { (i) }
6003
6004+#ifdef CONFIG_64BIT
6005+#define _ASM_EXTABLE(from, to) \
6006+" .section __ex_table,\"a\"\n" \
6007+" .dword " #from ", " #to"\n" \
6008+" .previous\n"
6009+#else
6010+#define _ASM_EXTABLE(from, to) \
6011+" .section __ex_table,\"a\"\n" \
6012+" .word " #from ", " #to"\n" \
6013+" .previous\n"
6014+#endif
6015+
6016 /*
6017 * atomic_read - read atomic variable
6018 * @v: pointer of type atomic_t
6019 *
6020 * Atomically reads the value of @v.
6021 */
6022-#define atomic_read(v) ACCESS_ONCE((v)->counter)
6023+static inline int atomic_read(const atomic_t *v)
6024+{
6025+ return ACCESS_ONCE(v->counter);
6026+}
6027+
6028+static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
6029+{
6030+ return ACCESS_ONCE(v->counter);
6031+}
6032
6033 /*
6034 * atomic_set - set atomic variable
6035@@ -39,47 +63,77 @@
6036 *
6037 * Atomically sets the value of @v to @i.
6038 */
6039-#define atomic_set(v, i) ((v)->counter = (i))
6040+static inline void atomic_set(atomic_t *v, int i)
6041+{
6042+ v->counter = i;
6043+}
6044
6045-#define ATOMIC_OP(op, c_op, asm_op) \
6046-static __inline__ void atomic_##op(int i, atomic_t * v) \
6047+static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
6048+{
6049+ v->counter = i;
6050+}
6051+
6052+#ifdef CONFIG_PAX_REFCOUNT
6053+#define __OVERFLOW_POST \
6054+ " b 4f \n" \
6055+ " .set noreorder \n" \
6056+ "3: b 5f \n" \
6057+ " move %0, %1 \n" \
6058+ " .set reorder \n"
6059+#define __OVERFLOW_EXTABLE \
6060+ "3:\n" \
6061+ _ASM_EXTABLE(2b, 3b)
6062+#else
6063+#define __OVERFLOW_POST
6064+#define __OVERFLOW_EXTABLE
6065+#endif
6066+
6067+#define __ATOMIC_OP(op, suffix, asm_op, extable) \
6068+static inline void atomic_##op##suffix(int i, atomic##suffix##_t * v) \
6069 { \
6070 if (kernel_uses_llsc && R10000_LLSC_WAR) { \
6071 int temp; \
6072 \
6073 __asm__ __volatile__( \
6074- " .set arch=r4000 \n" \
6075- "1: ll %0, %1 # atomic_" #op " \n" \
6076- " " #asm_op " %0, %2 \n" \
6077+ " .set mips3 \n" \
6078+ "1: ll %0, %1 # atomic_" #op #suffix "\n" \
6079+ "2: " #asm_op " %0, %2 \n" \
6080 " sc %0, %1 \n" \
6081 " beqzl %0, 1b \n" \
6082+ extable \
6083 " .set mips0 \n" \
6084 : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6085 : "Ir" (i)); \
6086 } else if (kernel_uses_llsc) { \
6087 int temp; \
6088 \
6089- do { \
6090- __asm__ __volatile__( \
6091- " .set "MIPS_ISA_LEVEL" \n" \
6092- " ll %0, %1 # atomic_" #op "\n" \
6093- " " #asm_op " %0, %2 \n" \
6094- " sc %0, %1 \n" \
6095- " .set mips0 \n" \
6096- : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6097- : "Ir" (i)); \
6098- } while (unlikely(!temp)); \
6099+ __asm__ __volatile__( \
6100+ " .set "MIPS_ISA_LEVEL" \n" \
6101+ "1: ll %0, %1 # atomic_" #op #suffix "\n" \
6102+ "2: " #asm_op " %0, %2 \n" \
6103+ " sc %0, %1 \n" \
6104+ " beqz %0, 1b \n" \
6105+ extable \
6106+ " .set mips0 \n" \
6107+ : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6108+ : "Ir" (i)); \
6109 } else { \
6110 unsigned long flags; \
6111 \
6112 raw_local_irq_save(flags); \
6113- v->counter c_op i; \
6114+ __asm__ __volatile__( \
6115+ "2: " #asm_op " %0, %1 \n" \
6116+ extable \
6117+ : "+r" (v->counter) : "Ir" (i)); \
6118 raw_local_irq_restore(flags); \
6119 } \
6120 }
6121
6122-#define ATOMIC_OP_RETURN(op, c_op, asm_op) \
6123-static __inline__ int atomic_##op##_return(int i, atomic_t * v) \
6124+#define ATOMIC_OP(op, asm_op) __ATOMIC_OP(op, _unchecked, asm_op##u, ) \
6125+ __ATOMIC_OP(op, , asm_op, __OVERFLOW_EXTABLE)
6126+
6127+#define __ATOMIC_OP_RETURN(op, suffix, asm_op, post_op, extable) \
6128+static inline int atomic_##op##_return##suffix(int i, atomic##suffix##_t * v) \
6129 { \
6130 int result; \
6131 \
6132@@ -89,12 +143,15 @@ static __inline__ int atomic_##op##_return(int i, atomic_t * v) \
6133 int temp; \
6134 \
6135 __asm__ __volatile__( \
6136- " .set arch=r4000 \n" \
6137- "1: ll %1, %2 # atomic_" #op "_return \n" \
6138- " " #asm_op " %0, %1, %3 \n" \
6139+ " .set mips3 \n" \
6140+ "1: ll %1, %2 # atomic_" #op "_return" #suffix"\n" \
6141+ "2: " #asm_op " %0, %1, %3 \n" \
6142 " sc %0, %2 \n" \
6143 " beqzl %0, 1b \n" \
6144- " " #asm_op " %0, %1, %3 \n" \
6145+ post_op \
6146+ extable \
6147+ "4: " #asm_op " %0, %1, %3 \n" \
6148+ "5: \n" \
6149 " .set mips0 \n" \
6150 : "=&r" (result), "=&r" (temp), \
6151 "+" GCC_OFF_SMALL_ASM() (v->counter) \
6152@@ -102,26 +159,33 @@ static __inline__ int atomic_##op##_return(int i, atomic_t * v) \
6153 } else if (kernel_uses_llsc) { \
6154 int temp; \
6155 \
6156- do { \
6157- __asm__ __volatile__( \
6158- " .set "MIPS_ISA_LEVEL" \n" \
6159- " ll %1, %2 # atomic_" #op "_return \n" \
6160- " " #asm_op " %0, %1, %3 \n" \
6161- " sc %0, %2 \n" \
6162- " .set mips0 \n" \
6163- : "=&r" (result), "=&r" (temp), \
6164- "+" GCC_OFF_SMALL_ASM() (v->counter) \
6165- : "Ir" (i)); \
6166- } while (unlikely(!result)); \
6167+ __asm__ __volatile__( \
6168+ " .set "MIPS_ISA_LEVEL" \n" \
6169+ "1: ll %1, %2 # atomic_" #op "_return" #suffix "\n" \
6170+ "2: " #asm_op " %0, %1, %3 \n" \
6171+ " sc %0, %2 \n" \
6172+ post_op \
6173+ extable \
6174+ "4: " #asm_op " %0, %1, %3 \n" \
6175+ "5: \n" \
6176+ " .set mips0 \n" \
6177+ : "=&r" (result), "=&r" (temp), \
6178+ "+" GCC_OFF_SMALL_ASM() (v->counter) \
6179+ : "Ir" (i)); \
6180 \
6181 result = temp; result c_op i; \
6182 } else { \
6183 unsigned long flags; \
6184 \
6185 raw_local_irq_save(flags); \
6186- result = v->counter; \
6187- result c_op i; \
6188- v->counter = result; \
6189+ __asm__ __volatile__( \
6190+ " lw %0, %1 \n" \
6191+ "2: " #asm_op " %0, %1, %2 \n" \
6192+ " sw %0, %1 \n" \
6193+ "3: \n" \
6194+ extable \
6195+ : "=&r" (result), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6196+ : "Ir" (i)); \
6197 raw_local_irq_restore(flags); \
6198 } \
6199 \
6200@@ -130,16 +194,21 @@ static __inline__ int atomic_##op##_return(int i, atomic_t * v) \
6201 return result; \
6202 }
6203
6204-#define ATOMIC_OPS(op, c_op, asm_op) \
6205- ATOMIC_OP(op, c_op, asm_op) \
6206- ATOMIC_OP_RETURN(op, c_op, asm_op)
6207+#define ATOMIC_OP_RETURN(op, asm_op) __ATOMIC_OP_RETURN(op, _unchecked, asm_op##u, , ) \
6208+ __ATOMIC_OP_RETURN(op, , asm_op, __OVERFLOW_POST, __OVERFLOW_EXTABLE)
6209
6210-ATOMIC_OPS(add, +=, addu)
6211-ATOMIC_OPS(sub, -=, subu)
6212+#define ATOMIC_OPS(op, asm_op) \
6213+ ATOMIC_OP(op, asm_op) \
6214+ ATOMIC_OP_RETURN(op, asm_op)
6215+
6216+ATOMIC_OPS(add, add)
6217+ATOMIC_OPS(sub, sub)
6218
6219 #undef ATOMIC_OPS
6220 #undef ATOMIC_OP_RETURN
6221+#undef __ATOMIC_OP_RETURN
6222 #undef ATOMIC_OP
6223+#undef __ATOMIC_OP
6224
6225 /*
6226 * atomic_sub_if_positive - conditionally subtract integer from atomic variable
6227@@ -149,7 +218,7 @@ ATOMIC_OPS(sub, -=, subu)
6228 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6229 * The function returns the old value of @v minus @i.
6230 */
6231-static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
6232+static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
6233 {
6234 int result;
6235
6236@@ -159,7 +228,7 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
6237 int temp;
6238
6239 __asm__ __volatile__(
6240- " .set arch=r4000 \n"
6241+ " .set "MIPS_ISA_LEVEL" \n"
6242 "1: ll %1, %2 # atomic_sub_if_positive\n"
6243 " subu %0, %1, %3 \n"
6244 " bltz %0, 1f \n"
6245@@ -208,8 +277,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
6246 return result;
6247 }
6248
6249-#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
6250-#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
6251+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
6252+{
6253+ return cmpxchg(&v->counter, old, new);
6254+}
6255+
6256+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
6257+ int new)
6258+{
6259+ return cmpxchg(&(v->counter), old, new);
6260+}
6261+
6262+static inline int atomic_xchg(atomic_t *v, int new)
6263+{
6264+ return xchg(&v->counter, new);
6265+}
6266+
6267+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
6268+{
6269+ return xchg(&(v->counter), new);
6270+}
6271
6272 /**
6273 * __atomic_add_unless - add unless the number is a given value
6274@@ -237,6 +324,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6275
6276 #define atomic_dec_return(v) atomic_sub_return(1, (v))
6277 #define atomic_inc_return(v) atomic_add_return(1, (v))
6278+static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
6279+{
6280+ return atomic_add_return_unchecked(1, v);
6281+}
6282
6283 /*
6284 * atomic_sub_and_test - subtract value from variable and test result
6285@@ -258,6 +349,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6286 * other cases.
6287 */
6288 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
6289+static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
6290+{
6291+ return atomic_add_return_unchecked(1, v) == 0;
6292+}
6293
6294 /*
6295 * atomic_dec_and_test - decrement by 1 and test
6296@@ -282,6 +377,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6297 * Atomically increments @v by 1.
6298 */
6299 #define atomic_inc(v) atomic_add(1, (v))
6300+static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
6301+{
6302+ atomic_add_unchecked(1, v);
6303+}
6304
6305 /*
6306 * atomic_dec - decrement and test
6307@@ -290,6 +389,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6308 * Atomically decrements @v by 1.
6309 */
6310 #define atomic_dec(v) atomic_sub(1, (v))
6311+static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
6312+{
6313+ atomic_sub_unchecked(1, v);
6314+}
6315
6316 /*
6317 * atomic_add_negative - add and test if negative
6318@@ -311,54 +414,77 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6319 * @v: pointer of type atomic64_t
6320 *
6321 */
6322-#define atomic64_read(v) ACCESS_ONCE((v)->counter)
6323+static inline long atomic64_read(const atomic64_t *v)
6324+{
6325+ return ACCESS_ONCE(v->counter);
6326+}
6327+
6328+static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
6329+{
6330+ return ACCESS_ONCE(v->counter);
6331+}
6332
6333 /*
6334 * atomic64_set - set atomic variable
6335 * @v: pointer of type atomic64_t
6336 * @i: required value
6337 */
6338-#define atomic64_set(v, i) ((v)->counter = (i))
6339+static inline void atomic64_set(atomic64_t *v, long i)
6340+{
6341+ v->counter = i;
6342+}
6343
6344-#define ATOMIC64_OP(op, c_op, asm_op) \
6345-static __inline__ void atomic64_##op(long i, atomic64_t * v) \
6346+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
6347+{
6348+ v->counter = i;
6349+}
6350+
6351+#define __ATOMIC64_OP(op, suffix, asm_op, extable) \
6352+static inline void atomic64_##op##suffix(long i, atomic64##suffix##_t * v) \
6353 { \
6354 if (kernel_uses_llsc && R10000_LLSC_WAR) { \
6355 long temp; \
6356 \
6357 __asm__ __volatile__( \
6358- " .set arch=r4000 \n" \
6359- "1: lld %0, %1 # atomic64_" #op " \n" \
6360- " " #asm_op " %0, %2 \n" \
6361+ " .set "MIPS_ISA_LEVEL" \n" \
6362+ "1: lld %0, %1 # atomic64_" #op #suffix "\n" \
6363+ "2: " #asm_op " %0, %2 \n" \
6364 " scd %0, %1 \n" \
6365 " beqzl %0, 1b \n" \
6366+ extable \
6367 " .set mips0 \n" \
6368 : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6369 : "Ir" (i)); \
6370 } else if (kernel_uses_llsc) { \
6371 long temp; \
6372 \
6373- do { \
6374- __asm__ __volatile__( \
6375- " .set "MIPS_ISA_LEVEL" \n" \
6376- " lld %0, %1 # atomic64_" #op "\n" \
6377- " " #asm_op " %0, %2 \n" \
6378- " scd %0, %1 \n" \
6379- " .set mips0 \n" \
6380- : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6381- : "Ir" (i)); \
6382- } while (unlikely(!temp)); \
6383+ __asm__ __volatile__( \
6384+ " .set "MIPS_ISA_LEVEL" \n" \
6385+ "1: lld %0, %1 # atomic64_" #op #suffix "\n" \
6386+ "2: " #asm_op " %0, %2 \n" \
6387+ " scd %0, %1 \n" \
6388+ " beqz %0, 1b \n" \
6389+ extable \
6390+ " .set mips0 \n" \
6391+ : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6392+ : "Ir" (i)); \
6393 } else { \
6394 unsigned long flags; \
6395 \
6396 raw_local_irq_save(flags); \
6397- v->counter c_op i; \
6398+ __asm__ __volatile__( \
6399+ "2: " #asm_op " %0, %1 \n" \
6400+ extable \
6401+ : "+" GCC_OFF_SMALL_ASM() (v->counter) : "Ir" (i)); \
6402 raw_local_irq_restore(flags); \
6403 } \
6404 }
6405
6406-#define ATOMIC64_OP_RETURN(op, c_op, asm_op) \
6407-static __inline__ long atomic64_##op##_return(long i, atomic64_t * v) \
6408+#define ATOMIC64_OP(op, asm_op) __ATOMIC64_OP(op, _unchecked, asm_op##u, ) \
6409+ __ATOMIC64_OP(op, , asm_op, __OVERFLOW_EXTABLE)
6410+
6411+#define __ATOMIC64_OP_RETURN(op, suffix, asm_op, post_op, extable) \
6412+static inline long atomic64_##op##_return##suffix(long i, atomic64##suffix##_t * v)\
6413 { \
6414 long result; \
6415 \
6416@@ -368,12 +494,15 @@ static __inline__ long atomic64_##op##_return(long i, atomic64_t * v) \
6417 long temp; \
6418 \
6419 __asm__ __volatile__( \
6420- " .set arch=r4000 \n" \
6421+ " .set mips3 \n" \
6422 "1: lld %1, %2 # atomic64_" #op "_return\n" \
6423- " " #asm_op " %0, %1, %3 \n" \
6424+ "2: " #asm_op " %0, %1, %3 \n" \
6425 " scd %0, %2 \n" \
6426 " beqzl %0, 1b \n" \
6427- " " #asm_op " %0, %1, %3 \n" \
6428+ post_op \
6429+ extable \
6430+ "4: " #asm_op " %0, %1, %3 \n" \
6431+ "5: \n" \
6432 " .set mips0 \n" \
6433 : "=&r" (result), "=&r" (temp), \
6434 "+" GCC_OFF_SMALL_ASM() (v->counter) \
6435@@ -381,27 +510,35 @@ static __inline__ long atomic64_##op##_return(long i, atomic64_t * v) \
6436 } else if (kernel_uses_llsc) { \
6437 long temp; \
6438 \
6439- do { \
6440- __asm__ __volatile__( \
6441- " .set "MIPS_ISA_LEVEL" \n" \
6442- " lld %1, %2 # atomic64_" #op "_return\n" \
6443- " " #asm_op " %0, %1, %3 \n" \
6444- " scd %0, %2 \n" \
6445- " .set mips0 \n" \
6446- : "=&r" (result), "=&r" (temp), \
6447- "=" GCC_OFF_SMALL_ASM() (v->counter) \
6448- : "Ir" (i), GCC_OFF_SMALL_ASM() (v->counter) \
6449- : "memory"); \
6450- } while (unlikely(!result)); \
6451+ __asm__ __volatile__( \
6452+ " .set "MIPS_ISA_LEVEL" \n" \
6453+ "1: lld %1, %2 # atomic64_" #op "_return" #suffix "\n"\
6454+ "2: " #asm_op " %0, %1, %3 \n" \
6455+ " scd %0, %2 \n" \
6456+ " beqz %0, 1b \n" \
6457+ post_op \
6458+ extable \
6459+ "4: " #asm_op " %0, %1, %3 \n" \
6460+ "5: \n" \
6461+ " .set mips0 \n" \
6462+ : "=&r" (result), "=&r" (temp), \
6463+ "=" GCC_OFF_SMALL_ASM() (v->counter) \
6464+ : "Ir" (i), GCC_OFF_SMALL_ASM() (v->counter) \
6465+ : "memory"); \
6466 \
6467 result = temp; result c_op i; \
6468 } else { \
6469 unsigned long flags; \
6470 \
6471 raw_local_irq_save(flags); \
6472- result = v->counter; \
6473- result c_op i; \
6474- v->counter = result; \
6475+ __asm__ __volatile__( \
6476+ " ld %0, %1 \n" \
6477+ "2: " #asm_op " %0, %1, %2 \n" \
6478+ " sd %0, %1 \n" \
6479+ "3: \n" \
6480+ extable \
6481+ : "=&r" (result), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6482+ : "Ir" (i)); \
6483 raw_local_irq_restore(flags); \
6484 } \
6485 \
6486@@ -410,16 +547,23 @@ static __inline__ long atomic64_##op##_return(long i, atomic64_t * v) \
6487 return result; \
6488 }
6489
6490-#define ATOMIC64_OPS(op, c_op, asm_op) \
6491- ATOMIC64_OP(op, c_op, asm_op) \
6492- ATOMIC64_OP_RETURN(op, c_op, asm_op)
6493+#define ATOMIC64_OP_RETURN(op, asm_op) __ATOMIC64_OP_RETURN(op, _unchecked, asm_op##u, , ) \
6494+ __ATOMIC64_OP_RETURN(op, , asm_op, __OVERFLOW_POST, __OVERFLOW_EXTABLE)
6495
6496-ATOMIC64_OPS(add, +=, daddu)
6497-ATOMIC64_OPS(sub, -=, dsubu)
6498+#define ATOMIC64_OPS(op, asm_op) \
6499+ ATOMIC64_OP(op, asm_op) \
6500+ ATOMIC64_OP_RETURN(op, asm_op)
6501+
6502+ATOMIC64_OPS(add, dadd)
6503+ATOMIC64_OPS(sub, dsub)
6504
6505 #undef ATOMIC64_OPS
6506 #undef ATOMIC64_OP_RETURN
6507+#undef __ATOMIC64_OP_RETURN
6508 #undef ATOMIC64_OP
6509+#undef __ATOMIC64_OP
6510+#undef __OVERFLOW_EXTABLE
6511+#undef __OVERFLOW_POST
6512
6513 /*
6514 * atomic64_sub_if_positive - conditionally subtract integer from atomic
6515@@ -430,7 +574,7 @@ ATOMIC64_OPS(sub, -=, dsubu)
6516 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6517 * The function returns the old value of @v minus @i.
6518 */
6519-static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6520+static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6521 {
6522 long result;
6523
6524@@ -440,7 +584,7 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6525 long temp;
6526
6527 __asm__ __volatile__(
6528- " .set arch=r4000 \n"
6529+ " .set "MIPS_ISA_LEVEL" \n"
6530 "1: lld %1, %2 # atomic64_sub_if_positive\n"
6531 " dsubu %0, %1, %3 \n"
6532 " bltz %0, 1f \n"
6533@@ -489,9 +633,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6534 return result;
6535 }
6536
6537-#define atomic64_cmpxchg(v, o, n) \
6538- ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6539-#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6540+static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6541+{
6542+ return cmpxchg(&v->counter, old, new);
6543+}
6544+
6545+static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6546+ long new)
6547+{
6548+ return cmpxchg(&(v->counter), old, new);
6549+}
6550+
6551+static inline long atomic64_xchg(atomic64_t *v, long new)
6552+{
6553+ return xchg(&v->counter, new);
6554+}
6555+
6556+static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6557+{
6558+ return xchg(&(v->counter), new);
6559+}
6560
6561 /**
6562 * atomic64_add_unless - add unless the number is a given value
6563@@ -521,6 +682,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6564
6565 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6566 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6567+#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6568
6569 /*
6570 * atomic64_sub_and_test - subtract value from variable and test result
6571@@ -542,6 +704,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6572 * other cases.
6573 */
6574 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6575+#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6576
6577 /*
6578 * atomic64_dec_and_test - decrement by 1 and test
6579@@ -566,6 +729,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6580 * Atomically increments @v by 1.
6581 */
6582 #define atomic64_inc(v) atomic64_add(1, (v))
6583+#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6584
6585 /*
6586 * atomic64_dec - decrement and test
6587@@ -574,6 +738,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6588 * Atomically decrements @v by 1.
6589 */
6590 #define atomic64_dec(v) atomic64_sub(1, (v))
6591+#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6592
6593 /*
6594 * atomic64_add_negative - add and test if negative
6595diff --git a/arch/mips/include/asm/barrier.h b/arch/mips/include/asm/barrier.h
6596index 7ecba84..21774af 100644
6597--- a/arch/mips/include/asm/barrier.h
6598+++ b/arch/mips/include/asm/barrier.h
6599@@ -133,7 +133,7 @@
6600 do { \
6601 compiletime_assert_atomic_type(*p); \
6602 smp_mb(); \
6603- ACCESS_ONCE(*p) = (v); \
6604+ ACCESS_ONCE_RW(*p) = (v); \
6605 } while (0)
6606
6607 #define smp_load_acquire(p) \
6608diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6609index b4db69f..8f3b093 100644
6610--- a/arch/mips/include/asm/cache.h
6611+++ b/arch/mips/include/asm/cache.h
6612@@ -9,10 +9,11 @@
6613 #ifndef _ASM_CACHE_H
6614 #define _ASM_CACHE_H
6615
6616+#include <linux/const.h>
6617 #include <kmalloc.h>
6618
6619 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6620-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6621+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6622
6623 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6624 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6625diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6626index f19e890..a4f8177 100644
6627--- a/arch/mips/include/asm/elf.h
6628+++ b/arch/mips/include/asm/elf.h
6629@@ -417,6 +417,13 @@ extern const char *__elf_platform;
6630 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6631 #endif
6632
6633+#ifdef CONFIG_PAX_ASLR
6634+#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6635+
6636+#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6637+#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6638+#endif
6639+
6640 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6641 struct linux_binprm;
6642 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6643diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6644index c1f6afa..38cc6e9 100644
6645--- a/arch/mips/include/asm/exec.h
6646+++ b/arch/mips/include/asm/exec.h
6647@@ -12,6 +12,6 @@
6648 #ifndef _ASM_EXEC_H
6649 #define _ASM_EXEC_H
6650
6651-extern unsigned long arch_align_stack(unsigned long sp);
6652+#define arch_align_stack(x) ((x) & ~0xfUL)
6653
6654 #endif /* _ASM_EXEC_H */
6655diff --git a/arch/mips/include/asm/hw_irq.h b/arch/mips/include/asm/hw_irq.h
6656index 9e8ef59..1139d6b 100644
6657--- a/arch/mips/include/asm/hw_irq.h
6658+++ b/arch/mips/include/asm/hw_irq.h
6659@@ -10,7 +10,7 @@
6660
6661 #include <linux/atomic.h>
6662
6663-extern atomic_t irq_err_count;
6664+extern atomic_unchecked_t irq_err_count;
6665
6666 /*
6667 * interrupt-retrigger: NOP for now. This may not be appropriate for all
6668diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6669index 8feaed6..1bd8a64 100644
6670--- a/arch/mips/include/asm/local.h
6671+++ b/arch/mips/include/asm/local.h
6672@@ -13,15 +13,25 @@ typedef struct
6673 atomic_long_t a;
6674 } local_t;
6675
6676+typedef struct {
6677+ atomic_long_unchecked_t a;
6678+} local_unchecked_t;
6679+
6680 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6681
6682 #define local_read(l) atomic_long_read(&(l)->a)
6683+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6684 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6685+#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6686
6687 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6688+#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6689 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6690+#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6691 #define local_inc(l) atomic_long_inc(&(l)->a)
6692+#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6693 #define local_dec(l) atomic_long_dec(&(l)->a)
6694+#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6695
6696 /*
6697 * Same as above, but return the result value
6698@@ -71,6 +81,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6699 return result;
6700 }
6701
6702+static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6703+{
6704+ unsigned long result;
6705+
6706+ if (kernel_uses_llsc && R10000_LLSC_WAR) {
6707+ unsigned long temp;
6708+
6709+ __asm__ __volatile__(
6710+ " .set mips3 \n"
6711+ "1:" __LL "%1, %2 # local_add_return \n"
6712+ " addu %0, %1, %3 \n"
6713+ __SC "%0, %2 \n"
6714+ " beqzl %0, 1b \n"
6715+ " addu %0, %1, %3 \n"
6716+ " .set mips0 \n"
6717+ : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6718+ : "Ir" (i), "m" (l->a.counter)
6719+ : "memory");
6720+ } else if (kernel_uses_llsc) {
6721+ unsigned long temp;
6722+
6723+ __asm__ __volatile__(
6724+ " .set mips3 \n"
6725+ "1:" __LL "%1, %2 # local_add_return \n"
6726+ " addu %0, %1, %3 \n"
6727+ __SC "%0, %2 \n"
6728+ " beqz %0, 1b \n"
6729+ " addu %0, %1, %3 \n"
6730+ " .set mips0 \n"
6731+ : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6732+ : "Ir" (i), "m" (l->a.counter)
6733+ : "memory");
6734+ } else {
6735+ unsigned long flags;
6736+
6737+ local_irq_save(flags);
6738+ result = l->a.counter;
6739+ result += i;
6740+ l->a.counter = result;
6741+ local_irq_restore(flags);
6742+ }
6743+
6744+ return result;
6745+}
6746+
6747 static __inline__ long local_sub_return(long i, local_t * l)
6748 {
6749 unsigned long result;
6750@@ -118,6 +173,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6751
6752 #define local_cmpxchg(l, o, n) \
6753 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6754+#define local_cmpxchg_unchecked(l, o, n) \
6755+ ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6756 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6757
6758 /**
6759diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6760index 89dd7fe..a123c97 100644
6761--- a/arch/mips/include/asm/page.h
6762+++ b/arch/mips/include/asm/page.h
6763@@ -118,7 +118,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6764 #ifdef CONFIG_CPU_MIPS32
6765 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6766 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6767- #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6768+ #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6769 #else
6770 typedef struct { unsigned long long pte; } pte_t;
6771 #define pte_val(x) ((x).pte)
6772diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6773index b336037..5b874cc 100644
6774--- a/arch/mips/include/asm/pgalloc.h
6775+++ b/arch/mips/include/asm/pgalloc.h
6776@@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6777 {
6778 set_pud(pud, __pud((unsigned long)pmd));
6779 }
6780+
6781+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6782+{
6783+ pud_populate(mm, pud, pmd);
6784+}
6785 #endif
6786
6787 /*
6788diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
6789index ae85694..4cdbba8 100644
6790--- a/arch/mips/include/asm/pgtable.h
6791+++ b/arch/mips/include/asm/pgtable.h
6792@@ -20,6 +20,9 @@
6793 #include <asm/io.h>
6794 #include <asm/pgtable-bits.h>
6795
6796+#define ktla_ktva(addr) (addr)
6797+#define ktva_ktla(addr) (addr)
6798+
6799 struct mm_struct;
6800 struct vm_area_struct;
6801
6802diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6803index 9c0014e..5101ef5 100644
6804--- a/arch/mips/include/asm/thread_info.h
6805+++ b/arch/mips/include/asm/thread_info.h
6806@@ -100,6 +100,9 @@ static inline struct thread_info *current_thread_info(void)
6807 #define TIF_SECCOMP 4 /* secure computing */
6808 #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */
6809 #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */
6810+/* li takes a 32bit immediate */
6811+#define TIF_GRSEC_SETXID 10 /* update credentials on syscall entry/exit */
6812+
6813 #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
6814 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
6815 #define TIF_NOHZ 19 /* in adaptive nohz mode */
6816@@ -135,14 +138,16 @@ static inline struct thread_info *current_thread_info(void)
6817 #define _TIF_USEDMSA (1<<TIF_USEDMSA)
6818 #define _TIF_MSA_CTX_LIVE (1<<TIF_MSA_CTX_LIVE)
6819 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6820+#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6821
6822 #define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6823 _TIF_SYSCALL_AUDIT | \
6824- _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
6825+ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
6826+ _TIF_GRSEC_SETXID)
6827
6828 /* work to do in syscall_trace_leave() */
6829 #define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6830- _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT)
6831+ _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
6832
6833 /* work to do on interrupt/exception return */
6834 #define _TIF_WORK_MASK \
6835@@ -150,7 +155,7 @@ static inline struct thread_info *current_thread_info(void)
6836 /* work to do on any return to u-space */
6837 #define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6838 _TIF_WORK_SYSCALL_EXIT | \
6839- _TIF_SYSCALL_TRACEPOINT)
6840+ _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
6841
6842 /*
6843 * We stash processor id into a COP0 register to retrieve it fast
6844diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h
6845index 5305d69..1da2bf5 100644
6846--- a/arch/mips/include/asm/uaccess.h
6847+++ b/arch/mips/include/asm/uaccess.h
6848@@ -146,6 +146,7 @@ static inline bool eva_kernel_access(void)
6849 __ok == 0; \
6850 })
6851
6852+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
6853 #define access_ok(type, addr, size) \
6854 likely(__access_ok((addr), (size), __access_mask))
6855
6856diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6857index 1188e00..41cf144 100644
6858--- a/arch/mips/kernel/binfmt_elfn32.c
6859+++ b/arch/mips/kernel/binfmt_elfn32.c
6860@@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6861 #undef ELF_ET_DYN_BASE
6862 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6863
6864+#ifdef CONFIG_PAX_ASLR
6865+#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6866+
6867+#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6868+#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6869+#endif
6870+
6871 #include <asm/processor.h>
6872 #include <linux/module.h>
6873 #include <linux/elfcore.h>
6874diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6875index 9287678..f870e47 100644
6876--- a/arch/mips/kernel/binfmt_elfo32.c
6877+++ b/arch/mips/kernel/binfmt_elfo32.c
6878@@ -70,6 +70,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6879 #undef ELF_ET_DYN_BASE
6880 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6881
6882+#ifdef CONFIG_PAX_ASLR
6883+#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6884+
6885+#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6886+#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6887+#endif
6888+
6889 #include <asm/processor.h>
6890
6891 #include <linux/module.h>
6892diff --git a/arch/mips/kernel/i8259.c b/arch/mips/kernel/i8259.c
6893index 74f6752..f3d7a47 100644
6894--- a/arch/mips/kernel/i8259.c
6895+++ b/arch/mips/kernel/i8259.c
6896@@ -205,7 +205,7 @@ spurious_8259A_irq:
6897 printk(KERN_DEBUG "spurious 8259A interrupt: IRQ%d.\n", irq);
6898 spurious_irq_mask |= irqmask;
6899 }
6900- atomic_inc(&irq_err_count);
6901+ atomic_inc_unchecked(&irq_err_count);
6902 /*
6903 * Theoretically we do not have to handle this IRQ,
6904 * but in Linux this does not cause problems and is
6905diff --git a/arch/mips/kernel/irq-gt641xx.c b/arch/mips/kernel/irq-gt641xx.c
6906index 44a1f79..2bd6aa3 100644
6907--- a/arch/mips/kernel/irq-gt641xx.c
6908+++ b/arch/mips/kernel/irq-gt641xx.c
6909@@ -110,7 +110,7 @@ void gt641xx_irq_dispatch(void)
6910 }
6911 }
6912
6913- atomic_inc(&irq_err_count);
6914+ atomic_inc_unchecked(&irq_err_count);
6915 }
6916
6917 void __init gt641xx_irq_init(void)
6918diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6919index 8eb5af8..2baf465 100644
6920--- a/arch/mips/kernel/irq.c
6921+++ b/arch/mips/kernel/irq.c
6922@@ -34,17 +34,17 @@ void ack_bad_irq(unsigned int irq)
6923 printk("unexpected IRQ # %d\n", irq);
6924 }
6925
6926-atomic_t irq_err_count;
6927+atomic_unchecked_t irq_err_count;
6928
6929 int arch_show_interrupts(struct seq_file *p, int prec)
6930 {
6931- seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6932+ seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6933 return 0;
6934 }
6935
6936 asmlinkage void spurious_interrupt(void)
6937 {
6938- atomic_inc(&irq_err_count);
6939+ atomic_inc_unchecked(&irq_err_count);
6940 }
6941
6942 void __init init_IRQ(void)
6943@@ -58,6 +58,8 @@ void __init init_IRQ(void)
6944 }
6945
6946 #ifdef CONFIG_DEBUG_STACKOVERFLOW
6947+
6948+extern void gr_handle_kernel_exploit(void);
6949 static inline void check_stack_overflow(void)
6950 {
6951 unsigned long sp;
6952@@ -73,6 +75,7 @@ static inline void check_stack_overflow(void)
6953 printk("do_IRQ: stack overflow: %ld\n",
6954 sp - sizeof(struct thread_info));
6955 dump_stack();
6956+ gr_handle_kernel_exploit();
6957 }
6958 }
6959 #else
6960diff --git a/arch/mips/kernel/pm-cps.c b/arch/mips/kernel/pm-cps.c
6961index 0614717..002fa43 100644
6962--- a/arch/mips/kernel/pm-cps.c
6963+++ b/arch/mips/kernel/pm-cps.c
6964@@ -172,7 +172,7 @@ int cps_pm_enter_state(enum cps_pm_state state)
6965 nc_core_ready_count = nc_addr;
6966
6967 /* Ensure ready_count is zero-initialised before the assembly runs */
6968- ACCESS_ONCE(*nc_core_ready_count) = 0;
6969+ ACCESS_ONCE_RW(*nc_core_ready_count) = 0;
6970 coupled_barrier(&per_cpu(pm_barrier, core), online);
6971
6972 /* Run the generated entry code */
6973diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6974index f2975d4..f61d355 100644
6975--- a/arch/mips/kernel/process.c
6976+++ b/arch/mips/kernel/process.c
6977@@ -541,18 +541,6 @@ out:
6978 return pc;
6979 }
6980
6981-/*
6982- * Don't forget that the stack pointer must be aligned on a 8 bytes
6983- * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6984- */
6985-unsigned long arch_align_stack(unsigned long sp)
6986-{
6987- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6988- sp -= get_random_int() & ~PAGE_MASK;
6989-
6990- return sp & ALMASK;
6991-}
6992-
6993 static void arch_dump_stack(void *info)
6994 {
6995 struct pt_regs *regs;
6996diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6997index e933a30..0d02625 100644
6998--- a/arch/mips/kernel/ptrace.c
6999+++ b/arch/mips/kernel/ptrace.c
7000@@ -785,6 +785,10 @@ long arch_ptrace(struct task_struct *child, long request,
7001 return ret;
7002 }
7003
7004+#ifdef CONFIG_GRKERNSEC_SETXID
7005+extern void gr_delayed_cred_worker(void);
7006+#endif
7007+
7008 /*
7009 * Notification of system call entry/exit
7010 * - triggered by current->work.syscall_trace
7011@@ -803,6 +807,11 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
7012 tracehook_report_syscall_entry(regs))
7013 ret = -1;
7014
7015+#ifdef CONFIG_GRKERNSEC_SETXID
7016+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7017+ gr_delayed_cred_worker();
7018+#endif
7019+
7020 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
7021 trace_sys_enter(regs, regs->regs[2]);
7022
7023diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
7024index 2242bdd..b284048 100644
7025--- a/arch/mips/kernel/sync-r4k.c
7026+++ b/arch/mips/kernel/sync-r4k.c
7027@@ -18,8 +18,8 @@
7028 #include <asm/mipsregs.h>
7029
7030 static atomic_t count_start_flag = ATOMIC_INIT(0);
7031-static atomic_t count_count_start = ATOMIC_INIT(0);
7032-static atomic_t count_count_stop = ATOMIC_INIT(0);
7033+static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
7034+static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
7035 static atomic_t count_reference = ATOMIC_INIT(0);
7036
7037 #define COUNTON 100
7038@@ -58,13 +58,13 @@ void synchronise_count_master(int cpu)
7039
7040 for (i = 0; i < NR_LOOPS; i++) {
7041 /* slaves loop on '!= 2' */
7042- while (atomic_read(&count_count_start) != 1)
7043+ while (atomic_read_unchecked(&count_count_start) != 1)
7044 mb();
7045- atomic_set(&count_count_stop, 0);
7046+ atomic_set_unchecked(&count_count_stop, 0);
7047 smp_wmb();
7048
7049 /* this lets the slaves write their count register */
7050- atomic_inc(&count_count_start);
7051+ atomic_inc_unchecked(&count_count_start);
7052
7053 /*
7054 * Everyone initialises count in the last loop:
7055@@ -75,11 +75,11 @@ void synchronise_count_master(int cpu)
7056 /*
7057 * Wait for all slaves to leave the synchronization point:
7058 */
7059- while (atomic_read(&count_count_stop) != 1)
7060+ while (atomic_read_unchecked(&count_count_stop) != 1)
7061 mb();
7062- atomic_set(&count_count_start, 0);
7063+ atomic_set_unchecked(&count_count_start, 0);
7064 smp_wmb();
7065- atomic_inc(&count_count_stop);
7066+ atomic_inc_unchecked(&count_count_stop);
7067 }
7068 /* Arrange for an interrupt in a short while */
7069 write_c0_compare(read_c0_count() + COUNTON);
7070@@ -112,8 +112,8 @@ void synchronise_count_slave(int cpu)
7071 initcount = atomic_read(&count_reference);
7072
7073 for (i = 0; i < NR_LOOPS; i++) {
7074- atomic_inc(&count_count_start);
7075- while (atomic_read(&count_count_start) != 2)
7076+ atomic_inc_unchecked(&count_count_start);
7077+ while (atomic_read_unchecked(&count_count_start) != 2)
7078 mb();
7079
7080 /*
7081@@ -122,8 +122,8 @@ void synchronise_count_slave(int cpu)
7082 if (i == NR_LOOPS-1)
7083 write_c0_count(initcount);
7084
7085- atomic_inc(&count_count_stop);
7086- while (atomic_read(&count_count_stop) != 2)
7087+ atomic_inc_unchecked(&count_count_stop);
7088+ while (atomic_read_unchecked(&count_count_stop) != 2)
7089 mb();
7090 }
7091 /* Arrange for an interrupt in a short while */
7092diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
7093index 8ea28e6..c8873d5 100644
7094--- a/arch/mips/kernel/traps.c
7095+++ b/arch/mips/kernel/traps.c
7096@@ -697,7 +697,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
7097 siginfo_t info;
7098
7099 prev_state = exception_enter();
7100- die_if_kernel("Integer overflow", regs);
7101+ if (unlikely(!user_mode(regs))) {
7102+
7103+#ifdef CONFIG_PAX_REFCOUNT
7104+ if (fixup_exception(regs)) {
7105+ pax_report_refcount_overflow(regs);
7106+ exception_exit(prev_state);
7107+ return;
7108+ }
7109+#endif
7110+
7111+ die("Integer overflow", regs);
7112+ }
7113
7114 info.si_code = FPE_INTOVF;
7115 info.si_signo = SIGFPE;
7116diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
7117index cd4c129..290c518 100644
7118--- a/arch/mips/kvm/mips.c
7119+++ b/arch/mips/kvm/mips.c
7120@@ -1016,7 +1016,7 @@ long kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
7121 return r;
7122 }
7123
7124-int kvm_arch_init(void *opaque)
7125+int kvm_arch_init(const void *opaque)
7126 {
7127 if (kvm_mips_callbacks) {
7128 kvm_err("kvm: module already exists\n");
7129diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
7130index 852a41c..75b9d38 100644
7131--- a/arch/mips/mm/fault.c
7132+++ b/arch/mips/mm/fault.c
7133@@ -31,6 +31,23 @@
7134
7135 int show_unhandled_signals = 1;
7136
7137+#ifdef CONFIG_PAX_PAGEEXEC
7138+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7139+{
7140+ unsigned long i;
7141+
7142+ printk(KERN_ERR "PAX: bytes at PC: ");
7143+ for (i = 0; i < 5; i++) {
7144+ unsigned int c;
7145+ if (get_user(c, (unsigned int *)pc+i))
7146+ printk(KERN_CONT "???????? ");
7147+ else
7148+ printk(KERN_CONT "%08x ", c);
7149+ }
7150+ printk("\n");
7151+}
7152+#endif
7153+
7154 /*
7155 * This routine handles page faults. It determines the address,
7156 * and the problem, and then passes it off to one of the appropriate
7157@@ -207,6 +224,14 @@ bad_area:
7158 bad_area_nosemaphore:
7159 /* User mode accesses just cause a SIGSEGV */
7160 if (user_mode(regs)) {
7161+
7162+#ifdef CONFIG_PAX_PAGEEXEC
7163+ if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
7164+ pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
7165+ do_group_exit(SIGKILL);
7166+ }
7167+#endif
7168+
7169 tsk->thread.cp0_badvaddr = address;
7170 tsk->thread.error_code = write;
7171 if (show_unhandled_signals &&
7172diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
7173index 5c81fdd..db158d3 100644
7174--- a/arch/mips/mm/mmap.c
7175+++ b/arch/mips/mm/mmap.c
7176@@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
7177 struct vm_area_struct *vma;
7178 unsigned long addr = addr0;
7179 int do_color_align;
7180+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7181 struct vm_unmapped_area_info info;
7182
7183 if (unlikely(len > TASK_SIZE))
7184@@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
7185 do_color_align = 1;
7186
7187 /* requesting a specific address */
7188+
7189+#ifdef CONFIG_PAX_RANDMMAP
7190+ if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
7191+#endif
7192+
7193 if (addr) {
7194 if (do_color_align)
7195 addr = COLOUR_ALIGN(addr, pgoff);
7196@@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
7197 addr = PAGE_ALIGN(addr);
7198
7199 vma = find_vma(mm, addr);
7200- if (TASK_SIZE - len >= addr &&
7201- (!vma || addr + len <= vma->vm_start))
7202+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7203 return addr;
7204 }
7205
7206 info.length = len;
7207 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
7208 info.align_offset = pgoff << PAGE_SHIFT;
7209+ info.threadstack_offset = offset;
7210
7211 if (dir == DOWN) {
7212 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
7213@@ -160,45 +166,34 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7214 {
7215 unsigned long random_factor = 0UL;
7216
7217+#ifdef CONFIG_PAX_RANDMMAP
7218+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7219+#endif
7220+
7221 if (current->flags & PF_RANDOMIZE)
7222 random_factor = arch_mmap_rnd();
7223
7224 if (mmap_is_legacy()) {
7225 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
7226+
7227+#ifdef CONFIG_PAX_RANDMMAP
7228+ if (mm->pax_flags & MF_PAX_RANDMMAP)
7229+ mm->mmap_base += mm->delta_mmap;
7230+#endif
7231+
7232 mm->get_unmapped_area = arch_get_unmapped_area;
7233 } else {
7234 mm->mmap_base = mmap_base(random_factor);
7235+
7236+#ifdef CONFIG_PAX_RANDMMAP
7237+ if (mm->pax_flags & MF_PAX_RANDMMAP)
7238+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7239+#endif
7240+
7241 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7242 }
7243 }
7244
7245-static inline unsigned long brk_rnd(void)
7246-{
7247- unsigned long rnd = get_random_int();
7248-
7249- rnd = rnd << PAGE_SHIFT;
7250- /* 8MB for 32bit, 256MB for 64bit */
7251- if (TASK_IS_32BIT_ADDR)
7252- rnd = rnd & 0x7ffffful;
7253- else
7254- rnd = rnd & 0xffffffful;
7255-
7256- return rnd;
7257-}
7258-
7259-unsigned long arch_randomize_brk(struct mm_struct *mm)
7260-{
7261- unsigned long base = mm->brk;
7262- unsigned long ret;
7263-
7264- ret = PAGE_ALIGN(base + brk_rnd());
7265-
7266- if (ret < mm->brk)
7267- return mm->brk;
7268-
7269- return ret;
7270-}
7271-
7272 int __virt_addr_valid(const volatile void *kaddr)
7273 {
7274 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
7275diff --git a/arch/mips/net/bpf_jit_asm.S b/arch/mips/net/bpf_jit_asm.S
7276index dabf417..0be1d6d 100644
7277--- a/arch/mips/net/bpf_jit_asm.S
7278+++ b/arch/mips/net/bpf_jit_asm.S
7279@@ -62,7 +62,9 @@ sk_load_word_positive:
7280 is_offset_in_header(4, word)
7281 /* Offset within header boundaries */
7282 PTR_ADDU t1, $r_skb_data, offset
7283+ .set reorder
7284 lw $r_A, 0(t1)
7285+ .set noreorder
7286 #ifdef CONFIG_CPU_LITTLE_ENDIAN
7287 # if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
7288 wsbh t0, $r_A
7289@@ -90,7 +92,9 @@ sk_load_half_positive:
7290 is_offset_in_header(2, half)
7291 /* Offset within header boundaries */
7292 PTR_ADDU t1, $r_skb_data, offset
7293+ .set reorder
7294 lh $r_A, 0(t1)
7295+ .set noreorder
7296 #ifdef CONFIG_CPU_LITTLE_ENDIAN
7297 # if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
7298 wsbh t0, $r_A
7299diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
7300index a2358b4..7cead4f 100644
7301--- a/arch/mips/sgi-ip27/ip27-nmi.c
7302+++ b/arch/mips/sgi-ip27/ip27-nmi.c
7303@@ -187,9 +187,9 @@ void
7304 cont_nmi_dump(void)
7305 {
7306 #ifndef REAL_NMI_SIGNAL
7307- static atomic_t nmied_cpus = ATOMIC_INIT(0);
7308+ static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
7309
7310- atomic_inc(&nmied_cpus);
7311+ atomic_inc_unchecked(&nmied_cpus);
7312 #endif
7313 /*
7314 * Only allow 1 cpu to proceed
7315@@ -233,7 +233,7 @@ cont_nmi_dump(void)
7316 udelay(10000);
7317 }
7318 #else
7319- while (atomic_read(&nmied_cpus) != num_online_cpus());
7320+ while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
7321 #endif
7322
7323 /*
7324diff --git a/arch/mips/sni/rm200.c b/arch/mips/sni/rm200.c
7325index a046b30..6799527 100644
7326--- a/arch/mips/sni/rm200.c
7327+++ b/arch/mips/sni/rm200.c
7328@@ -270,7 +270,7 @@ spurious_8259A_irq:
7329 "spurious RM200 8259A interrupt: IRQ%d.\n", irq);
7330 spurious_irq_mask |= irqmask;
7331 }
7332- atomic_inc(&irq_err_count);
7333+ atomic_inc_unchecked(&irq_err_count);
7334 /*
7335 * Theoretically we do not have to handle this IRQ,
7336 * but in Linux this does not cause problems and is
7337diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
7338index 41e873b..34d33a7 100644
7339--- a/arch/mips/vr41xx/common/icu.c
7340+++ b/arch/mips/vr41xx/common/icu.c
7341@@ -653,7 +653,7 @@ static int icu_get_irq(unsigned int irq)
7342
7343 printk(KERN_ERR "spurious ICU interrupt: %04x,%04x\n", pend1, pend2);
7344
7345- atomic_inc(&irq_err_count);
7346+ atomic_inc_unchecked(&irq_err_count);
7347
7348 return -1;
7349 }
7350diff --git a/arch/mips/vr41xx/common/irq.c b/arch/mips/vr41xx/common/irq.c
7351index ae0e4ee..e8f0692 100644
7352--- a/arch/mips/vr41xx/common/irq.c
7353+++ b/arch/mips/vr41xx/common/irq.c
7354@@ -64,7 +64,7 @@ static void irq_dispatch(unsigned int irq)
7355 irq_cascade_t *cascade;
7356
7357 if (irq >= NR_IRQS) {
7358- atomic_inc(&irq_err_count);
7359+ atomic_inc_unchecked(&irq_err_count);
7360 return;
7361 }
7362
7363@@ -84,7 +84,7 @@ static void irq_dispatch(unsigned int irq)
7364 ret = cascade->get_irq(irq);
7365 irq = ret;
7366 if (ret < 0)
7367- atomic_inc(&irq_err_count);
7368+ atomic_inc_unchecked(&irq_err_count);
7369 else
7370 irq_dispatch(irq);
7371 if (!irqd_irq_disabled(idata) && chip->irq_unmask)
7372diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
7373index 967d144..db12197 100644
7374--- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
7375+++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
7376@@ -11,12 +11,14 @@
7377 #ifndef _ASM_PROC_CACHE_H
7378 #define _ASM_PROC_CACHE_H
7379
7380+#include <linux/const.h>
7381+
7382 /* L1 cache */
7383
7384 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
7385 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
7386-#define L1_CACHE_BYTES 16 /* bytes per entry */
7387 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
7388+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
7389 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
7390
7391 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
7392diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7393index bcb5df2..84fabd2 100644
7394--- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7395+++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7396@@ -16,13 +16,15 @@
7397 #ifndef _ASM_PROC_CACHE_H
7398 #define _ASM_PROC_CACHE_H
7399
7400+#include <linux/const.h>
7401+
7402 /*
7403 * L1 cache
7404 */
7405 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
7406 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
7407-#define L1_CACHE_BYTES 32 /* bytes per entry */
7408 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
7409+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
7410 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
7411
7412 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
7413diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
7414index 4ce7a01..449202a 100644
7415--- a/arch/openrisc/include/asm/cache.h
7416+++ b/arch/openrisc/include/asm/cache.h
7417@@ -19,11 +19,13 @@
7418 #ifndef __ASM_OPENRISC_CACHE_H
7419 #define __ASM_OPENRISC_CACHE_H
7420
7421+#include <linux/const.h>
7422+
7423 /* FIXME: How can we replace these with values from the CPU...
7424 * they shouldn't be hard-coded!
7425 */
7426
7427-#define L1_CACHE_BYTES 16
7428 #define L1_CACHE_SHIFT 4
7429+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7430
7431 #endif /* __ASM_OPENRISC_CACHE_H */
7432diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
7433index 226f8ca9..9d9b87d 100644
7434--- a/arch/parisc/include/asm/atomic.h
7435+++ b/arch/parisc/include/asm/atomic.h
7436@@ -273,6 +273,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
7437 return dec;
7438 }
7439
7440+#define atomic64_read_unchecked(v) atomic64_read(v)
7441+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7442+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7443+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7444+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7445+#define atomic64_inc_unchecked(v) atomic64_inc(v)
7446+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7447+#define atomic64_dec_unchecked(v) atomic64_dec(v)
7448+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7449+
7450 #endif /* !CONFIG_64BIT */
7451
7452
7453diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
7454index 47f11c7..3420df2 100644
7455--- a/arch/parisc/include/asm/cache.h
7456+++ b/arch/parisc/include/asm/cache.h
7457@@ -5,6 +5,7 @@
7458 #ifndef __ARCH_PARISC_CACHE_H
7459 #define __ARCH_PARISC_CACHE_H
7460
7461+#include <linux/const.h>
7462
7463 /*
7464 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
7465@@ -15,13 +16,13 @@
7466 * just ruin performance.
7467 */
7468 #ifdef CONFIG_PA20
7469-#define L1_CACHE_BYTES 64
7470 #define L1_CACHE_SHIFT 6
7471 #else
7472-#define L1_CACHE_BYTES 32
7473 #define L1_CACHE_SHIFT 5
7474 #endif
7475
7476+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7477+
7478 #ifndef __ASSEMBLY__
7479
7480 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7481diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7482index 78c9fd3..42fa66a 100644
7483--- a/arch/parisc/include/asm/elf.h
7484+++ b/arch/parisc/include/asm/elf.h
7485@@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7486
7487 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7488
7489+#ifdef CONFIG_PAX_ASLR
7490+#define PAX_ELF_ET_DYN_BASE 0x10000UL
7491+
7492+#define PAX_DELTA_MMAP_LEN 16
7493+#define PAX_DELTA_STACK_LEN 16
7494+#endif
7495+
7496 /* This yields a mask that user programs can use to figure out what
7497 instruction set this CPU supports. This could be done in user space,
7498 but it's not easy, and we've already done it here. */
7499diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7500index 3edbb9f..08fef28 100644
7501--- a/arch/parisc/include/asm/pgalloc.h
7502+++ b/arch/parisc/include/asm/pgalloc.h
7503@@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7504 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7505 }
7506
7507+static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7508+{
7509+ pgd_populate(mm, pgd, pmd);
7510+}
7511+
7512 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7513 {
7514 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7515@@ -97,6 +102,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7516 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7517 #define pmd_free(mm, x) do { } while (0)
7518 #define pgd_populate(mm, pmd, pte) BUG()
7519+#define pgd_populate_kernel(mm, pmd, pte) BUG()
7520
7521 #endif
7522
7523diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7524index f93c4a4..cfd5663 100644
7525--- a/arch/parisc/include/asm/pgtable.h
7526+++ b/arch/parisc/include/asm/pgtable.h
7527@@ -231,6 +231,17 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
7528 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7529 #define PAGE_COPY PAGE_EXECREAD
7530 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7531+
7532+#ifdef CONFIG_PAX_PAGEEXEC
7533+# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7534+# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7535+# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7536+#else
7537+# define PAGE_SHARED_NOEXEC PAGE_SHARED
7538+# define PAGE_COPY_NOEXEC PAGE_COPY
7539+# define PAGE_READONLY_NOEXEC PAGE_READONLY
7540+#endif
7541+
7542 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7543 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7544 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7545diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7546index 0abdd4c..1af92f0 100644
7547--- a/arch/parisc/include/asm/uaccess.h
7548+++ b/arch/parisc/include/asm/uaccess.h
7549@@ -243,10 +243,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7550 const void __user *from,
7551 unsigned long n)
7552 {
7553- int sz = __compiletime_object_size(to);
7554+ size_t sz = __compiletime_object_size(to);
7555 int ret = -EFAULT;
7556
7557- if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7558+ if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7559 ret = __copy_from_user(to, from, n);
7560 else
7561 copy_from_user_overflow();
7562diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7563index 3c63a82..b1d6ee9 100644
7564--- a/arch/parisc/kernel/module.c
7565+++ b/arch/parisc/kernel/module.c
7566@@ -98,16 +98,38 @@
7567
7568 /* three functions to determine where in the module core
7569 * or init pieces the location is */
7570+static inline int in_init_rx(struct module *me, void *loc)
7571+{
7572+ return (loc >= me->module_init_rx &&
7573+ loc < (me->module_init_rx + me->init_size_rx));
7574+}
7575+
7576+static inline int in_init_rw(struct module *me, void *loc)
7577+{
7578+ return (loc >= me->module_init_rw &&
7579+ loc < (me->module_init_rw + me->init_size_rw));
7580+}
7581+
7582 static inline int in_init(struct module *me, void *loc)
7583 {
7584- return (loc >= me->module_init &&
7585- loc <= (me->module_init + me->init_size));
7586+ return in_init_rx(me, loc) || in_init_rw(me, loc);
7587+}
7588+
7589+static inline int in_core_rx(struct module *me, void *loc)
7590+{
7591+ return (loc >= me->module_core_rx &&
7592+ loc < (me->module_core_rx + me->core_size_rx));
7593+}
7594+
7595+static inline int in_core_rw(struct module *me, void *loc)
7596+{
7597+ return (loc >= me->module_core_rw &&
7598+ loc < (me->module_core_rw + me->core_size_rw));
7599 }
7600
7601 static inline int in_core(struct module *me, void *loc)
7602 {
7603- return (loc >= me->module_core &&
7604- loc <= (me->module_core + me->core_size));
7605+ return in_core_rx(me, loc) || in_core_rw(me, loc);
7606 }
7607
7608 static inline int in_local(struct module *me, void *loc)
7609@@ -367,13 +389,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7610 }
7611
7612 /* align things a bit */
7613- me->core_size = ALIGN(me->core_size, 16);
7614- me->arch.got_offset = me->core_size;
7615- me->core_size += gots * sizeof(struct got_entry);
7616+ me->core_size_rw = ALIGN(me->core_size_rw, 16);
7617+ me->arch.got_offset = me->core_size_rw;
7618+ me->core_size_rw += gots * sizeof(struct got_entry);
7619
7620- me->core_size = ALIGN(me->core_size, 16);
7621- me->arch.fdesc_offset = me->core_size;
7622- me->core_size += fdescs * sizeof(Elf_Fdesc);
7623+ me->core_size_rw = ALIGN(me->core_size_rw, 16);
7624+ me->arch.fdesc_offset = me->core_size_rw;
7625+ me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7626
7627 me->arch.got_max = gots;
7628 me->arch.fdesc_max = fdescs;
7629@@ -391,7 +413,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7630
7631 BUG_ON(value == 0);
7632
7633- got = me->module_core + me->arch.got_offset;
7634+ got = me->module_core_rw + me->arch.got_offset;
7635 for (i = 0; got[i].addr; i++)
7636 if (got[i].addr == value)
7637 goto out;
7638@@ -409,7 +431,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7639 #ifdef CONFIG_64BIT
7640 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7641 {
7642- Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7643+ Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7644
7645 if (!value) {
7646 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7647@@ -427,7 +449,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7648
7649 /* Create new one */
7650 fdesc->addr = value;
7651- fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7652+ fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7653 return (Elf_Addr)fdesc;
7654 }
7655 #endif /* CONFIG_64BIT */
7656@@ -839,7 +861,7 @@ register_unwind_table(struct module *me,
7657
7658 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7659 end = table + sechdrs[me->arch.unwind_section].sh_size;
7660- gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7661+ gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7662
7663 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7664 me->arch.unwind_section, table, end, gp);
7665diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7666index 5aba01a..47cdd5a 100644
7667--- a/arch/parisc/kernel/sys_parisc.c
7668+++ b/arch/parisc/kernel/sys_parisc.c
7669@@ -92,6 +92,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7670 unsigned long task_size = TASK_SIZE;
7671 int do_color_align, last_mmap;
7672 struct vm_unmapped_area_info info;
7673+ unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7674
7675 if (len > task_size)
7676 return -ENOMEM;
7677@@ -109,6 +110,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7678 goto found_addr;
7679 }
7680
7681+#ifdef CONFIG_PAX_RANDMMAP
7682+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7683+#endif
7684+
7685 if (addr) {
7686 if (do_color_align && last_mmap)
7687 addr = COLOR_ALIGN(addr, last_mmap, pgoff);
7688@@ -127,6 +132,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7689 info.high_limit = mmap_upper_limit();
7690 info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
7691 info.align_offset = shared_align_offset(last_mmap, pgoff);
7692+ info.threadstack_offset = offset;
7693 addr = vm_unmapped_area(&info);
7694
7695 found_addr:
7696@@ -146,6 +152,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7697 unsigned long addr = addr0;
7698 int do_color_align, last_mmap;
7699 struct vm_unmapped_area_info info;
7700+ unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7701
7702 #ifdef CONFIG_64BIT
7703 /* This should only ever run for 32-bit processes. */
7704@@ -170,6 +177,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7705 }
7706
7707 /* requesting a specific address */
7708+#ifdef CONFIG_PAX_RANDMMAP
7709+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7710+#endif
7711+
7712 if (addr) {
7713 if (do_color_align && last_mmap)
7714 addr = COLOR_ALIGN(addr, last_mmap, pgoff);
7715@@ -187,6 +198,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7716 info.high_limit = mm->mmap_base;
7717 info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
7718 info.align_offset = shared_align_offset(last_mmap, pgoff);
7719+ info.threadstack_offset = offset;
7720 addr = vm_unmapped_area(&info);
7721 if (!(addr & ~PAGE_MASK))
7722 goto found_addr;
7723@@ -252,6 +264,13 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7724 mm->mmap_legacy_base = mmap_legacy_base();
7725 mm->mmap_base = mmap_upper_limit();
7726
7727+#ifdef CONFIG_PAX_RANDMMAP
7728+ if (mm->pax_flags & MF_PAX_RANDMMAP) {
7729+ mm->mmap_legacy_base += mm->delta_mmap;
7730+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7731+ }
7732+#endif
7733+
7734 if (mmap_is_legacy()) {
7735 mm->mmap_base = mm->mmap_legacy_base;
7736 mm->get_unmapped_area = arch_get_unmapped_area;
7737diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7738index b99b39f..e3915ae 100644
7739--- a/arch/parisc/kernel/traps.c
7740+++ b/arch/parisc/kernel/traps.c
7741@@ -722,9 +722,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7742
7743 down_read(&current->mm->mmap_sem);
7744 vma = find_vma(current->mm,regs->iaoq[0]);
7745- if (vma && (regs->iaoq[0] >= vma->vm_start)
7746- && (vma->vm_flags & VM_EXEC)) {
7747-
7748+ if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7749 fault_address = regs->iaoq[0];
7750 fault_space = regs->iasq[0];
7751
7752diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7753index 15503ad..4b1b8b6 100644
7754--- a/arch/parisc/mm/fault.c
7755+++ b/arch/parisc/mm/fault.c
7756@@ -16,6 +16,7 @@
7757 #include <linux/interrupt.h>
7758 #include <linux/module.h>
7759 #include <linux/uaccess.h>
7760+#include <linux/unistd.h>
7761
7762 #include <asm/traps.h>
7763
7764@@ -50,7 +51,7 @@ int show_unhandled_signals = 1;
7765 static unsigned long
7766 parisc_acctyp(unsigned long code, unsigned int inst)
7767 {
7768- if (code == 6 || code == 16)
7769+ if (code == 6 || code == 7 || code == 16)
7770 return VM_EXEC;
7771
7772 switch (inst & 0xf0000000) {
7773@@ -136,6 +137,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7774 }
7775 #endif
7776
7777+#ifdef CONFIG_PAX_PAGEEXEC
7778+/*
7779+ * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7780+ *
7781+ * returns 1 when task should be killed
7782+ * 2 when rt_sigreturn trampoline was detected
7783+ * 3 when unpatched PLT trampoline was detected
7784+ */
7785+static int pax_handle_fetch_fault(struct pt_regs *regs)
7786+{
7787+
7788+#ifdef CONFIG_PAX_EMUPLT
7789+ int err;
7790+
7791+ do { /* PaX: unpatched PLT emulation */
7792+ unsigned int bl, depwi;
7793+
7794+ err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7795+ err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7796+
7797+ if (err)
7798+ break;
7799+
7800+ if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7801+ unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7802+
7803+ err = get_user(ldw, (unsigned int *)addr);
7804+ err |= get_user(bv, (unsigned int *)(addr+4));
7805+ err |= get_user(ldw2, (unsigned int *)(addr+8));
7806+
7807+ if (err)
7808+ break;
7809+
7810+ if (ldw == 0x0E801096U &&
7811+ bv == 0xEAC0C000U &&
7812+ ldw2 == 0x0E881095U)
7813+ {
7814+ unsigned int resolver, map;
7815+
7816+ err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7817+ err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7818+ if (err)
7819+ break;
7820+
7821+ regs->gr[20] = instruction_pointer(regs)+8;
7822+ regs->gr[21] = map;
7823+ regs->gr[22] = resolver;
7824+ regs->iaoq[0] = resolver | 3UL;
7825+ regs->iaoq[1] = regs->iaoq[0] + 4;
7826+ return 3;
7827+ }
7828+ }
7829+ } while (0);
7830+#endif
7831+
7832+#ifdef CONFIG_PAX_EMUTRAMP
7833+
7834+#ifndef CONFIG_PAX_EMUSIGRT
7835+ if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7836+ return 1;
7837+#endif
7838+
7839+ do { /* PaX: rt_sigreturn emulation */
7840+ unsigned int ldi1, ldi2, bel, nop;
7841+
7842+ err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7843+ err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7844+ err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7845+ err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7846+
7847+ if (err)
7848+ break;
7849+
7850+ if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7851+ ldi2 == 0x3414015AU &&
7852+ bel == 0xE4008200U &&
7853+ nop == 0x08000240U)
7854+ {
7855+ regs->gr[25] = (ldi1 & 2) >> 1;
7856+ regs->gr[20] = __NR_rt_sigreturn;
7857+ regs->gr[31] = regs->iaoq[1] + 16;
7858+ regs->sr[0] = regs->iasq[1];
7859+ regs->iaoq[0] = 0x100UL;
7860+ regs->iaoq[1] = regs->iaoq[0] + 4;
7861+ regs->iasq[0] = regs->sr[2];
7862+ regs->iasq[1] = regs->sr[2];
7863+ return 2;
7864+ }
7865+ } while (0);
7866+#endif
7867+
7868+ return 1;
7869+}
7870+
7871+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7872+{
7873+ unsigned long i;
7874+
7875+ printk(KERN_ERR "PAX: bytes at PC: ");
7876+ for (i = 0; i < 5; i++) {
7877+ unsigned int c;
7878+ if (get_user(c, (unsigned int *)pc+i))
7879+ printk(KERN_CONT "???????? ");
7880+ else
7881+ printk(KERN_CONT "%08x ", c);
7882+ }
7883+ printk("\n");
7884+}
7885+#endif
7886+
7887 int fixup_exception(struct pt_regs *regs)
7888 {
7889 const struct exception_table_entry *fix;
7890@@ -234,8 +345,33 @@ retry:
7891
7892 good_area:
7893
7894- if ((vma->vm_flags & acc_type) != acc_type)
7895+ if ((vma->vm_flags & acc_type) != acc_type) {
7896+
7897+#ifdef CONFIG_PAX_PAGEEXEC
7898+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7899+ (address & ~3UL) == instruction_pointer(regs))
7900+ {
7901+ up_read(&mm->mmap_sem);
7902+ switch (pax_handle_fetch_fault(regs)) {
7903+
7904+#ifdef CONFIG_PAX_EMUPLT
7905+ case 3:
7906+ return;
7907+#endif
7908+
7909+#ifdef CONFIG_PAX_EMUTRAMP
7910+ case 2:
7911+ return;
7912+#endif
7913+
7914+ }
7915+ pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7916+ do_group_exit(SIGKILL);
7917+ }
7918+#endif
7919+
7920 goto bad_area;
7921+ }
7922
7923 /*
7924 * If for any reason at all we couldn't handle the fault, make
7925diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
7926index 5ef2711..21be2c3 100644
7927--- a/arch/powerpc/Kconfig
7928+++ b/arch/powerpc/Kconfig
7929@@ -415,6 +415,7 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
7930 config KEXEC
7931 bool "kexec system call"
7932 depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
7933+ depends on !GRKERNSEC_KMEM
7934 help
7935 kexec is a system call that implements the ability to shutdown your
7936 current kernel, and to start another kernel. It is like a reboot
7937diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7938index 512d278..d31fadd 100644
7939--- a/arch/powerpc/include/asm/atomic.h
7940+++ b/arch/powerpc/include/asm/atomic.h
7941@@ -12,6 +12,11 @@
7942
7943 #define ATOMIC_INIT(i) { (i) }
7944
7945+#define _ASM_EXTABLE(from, to) \
7946+" .section __ex_table,\"a\"\n" \
7947+ PPC_LONG" " #from ", " #to"\n" \
7948+" .previous\n"
7949+
7950 static __inline__ int atomic_read(const atomic_t *v)
7951 {
7952 int t;
7953@@ -21,39 +26,80 @@ static __inline__ int atomic_read(const atomic_t *v)
7954 return t;
7955 }
7956
7957+static __inline__ int atomic_read_unchecked(const atomic_unchecked_t *v)
7958+{
7959+ int t;
7960+
7961+ __asm__ __volatile__("lwz%U1%X1 %0,%1" : "=r"(t) : "m"(v->counter));
7962+
7963+ return t;
7964+}
7965+
7966 static __inline__ void atomic_set(atomic_t *v, int i)
7967 {
7968 __asm__ __volatile__("stw%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
7969 }
7970
7971-#define ATOMIC_OP(op, asm_op) \
7972-static __inline__ void atomic_##op(int a, atomic_t *v) \
7973+static __inline__ void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7974+{
7975+ __asm__ __volatile__("stw%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
7976+}
7977+
7978+#ifdef CONFIG_PAX_REFCOUNT
7979+#define __REFCOUNT_OP(op) op##o.
7980+#define __OVERFLOW_PRE \
7981+ " mcrxr cr0\n"
7982+#define __OVERFLOW_POST \
7983+ " bf 4*cr0+so, 3f\n" \
7984+ "2: .long 0x00c00b00\n" \
7985+ "3:\n"
7986+#define __OVERFLOW_EXTABLE \
7987+ "\n4:\n"
7988+ _ASM_EXTABLE(2b, 4b)
7989+#else
7990+#define __REFCOUNT_OP(op) op
7991+#define __OVERFLOW_PRE
7992+#define __OVERFLOW_POST
7993+#define __OVERFLOW_EXTABLE
7994+#endif
7995+
7996+#define __ATOMIC_OP(op, suffix, pre_op, asm_op, post_op, extable) \
7997+static inline void atomic_##op##suffix(int a, atomic##suffix##_t *v) \
7998 { \
7999 int t; \
8000 \
8001 __asm__ __volatile__( \
8002-"1: lwarx %0,0,%3 # atomic_" #op "\n" \
8003+"1: lwarx %0,0,%3 # atomic_" #op #suffix "\n" \
8004+ pre_op \
8005 #asm_op " %0,%2,%0\n" \
8006+ post_op \
8007 PPC405_ERR77(0,%3) \
8008 " stwcx. %0,0,%3 \n" \
8009 " bne- 1b\n" \
8010+ extable \
8011 : "=&r" (t), "+m" (v->counter) \
8012 : "r" (a), "r" (&v->counter) \
8013 : "cc"); \
8014 } \
8015
8016-#define ATOMIC_OP_RETURN(op, asm_op) \
8017-static __inline__ int atomic_##op##_return(int a, atomic_t *v) \
8018+#define ATOMIC_OP(op, asm_op) __ATOMIC_OP(op, , , asm_op, , ) \
8019+ __ATOMIC_OP(op, _unchecked, __OVERFLOW_PRE, __REFCOUNT_OP(asm_op), __OVERFLOW_POST, __OVERFLOW_EXTABLE)
8020+
8021+#define __ATOMIC_OP_RETURN(op, suffix, pre_op, asm_op, post_op, extable)\
8022+static inline int atomic_##op##_return##suffix(int a, atomic##suffix##_t *v)\
8023 { \
8024 int t; \
8025 \
8026 __asm__ __volatile__( \
8027 PPC_ATOMIC_ENTRY_BARRIER \
8028-"1: lwarx %0,0,%2 # atomic_" #op "_return\n" \
8029+"1: lwarx %0,0,%2 # atomic_" #op "_return" #suffix "\n" \
8030+ pre_op \
8031 #asm_op " %0,%1,%0\n" \
8032+ post_op \
8033 PPC405_ERR77(0,%2) \
8034 " stwcx. %0,0,%2 \n" \
8035 " bne- 1b\n" \
8036+ extable \
8037 PPC_ATOMIC_EXIT_BARRIER \
8038 : "=&r" (t) \
8039 : "r" (a), "r" (&v->counter) \
8040@@ -62,6 +108,9 @@ static __inline__ int atomic_##op##_return(int a, atomic_t *v) \
8041 return t; \
8042 }
8043
8044+#define ATOMIC_OP_RETURN(op, asm_op) __ATOMIC_OP_RETURN(op, , , asm_op, , )\
8045+ __ATOMIC_OP_RETURN(op, _unchecked, __OVERFLOW_PRE, __REFCOUNT_OP(asm_op), __OVERFLOW_POST, __OVERFLOW_EXTABLE)
8046+
8047 #define ATOMIC_OPS(op, asm_op) ATOMIC_OP(op, asm_op) ATOMIC_OP_RETURN(op, asm_op)
8048
8049 ATOMIC_OPS(add, add)
8050@@ -69,42 +118,29 @@ ATOMIC_OPS(sub, subf)
8051
8052 #undef ATOMIC_OPS
8053 #undef ATOMIC_OP_RETURN
8054+#undef __ATOMIC_OP_RETURN
8055 #undef ATOMIC_OP
8056+#undef __ATOMIC_OP
8057
8058 #define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
8059
8060-static __inline__ void atomic_inc(atomic_t *v)
8061-{
8062- int t;
8063+/*
8064+ * atomic_inc - increment atomic variable
8065+ * @v: pointer of type atomic_t
8066+ *
8067+ * Automatically increments @v by 1
8068+ */
8069+#define atomic_inc(v) atomic_add(1, (v))
8070+#define atomic_inc_return(v) atomic_add_return(1, (v))
8071
8072- __asm__ __volatile__(
8073-"1: lwarx %0,0,%2 # atomic_inc\n\
8074- addic %0,%0,1\n"
8075- PPC405_ERR77(0,%2)
8076-" stwcx. %0,0,%2 \n\
8077- bne- 1b"
8078- : "=&r" (t), "+m" (v->counter)
8079- : "r" (&v->counter)
8080- : "cc", "xer");
8081+static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8082+{
8083+ atomic_add_unchecked(1, v);
8084 }
8085
8086-static __inline__ int atomic_inc_return(atomic_t *v)
8087+static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8088 {
8089- int t;
8090-
8091- __asm__ __volatile__(
8092- PPC_ATOMIC_ENTRY_BARRIER
8093-"1: lwarx %0,0,%1 # atomic_inc_return\n\
8094- addic %0,%0,1\n"
8095- PPC405_ERR77(0,%1)
8096-" stwcx. %0,0,%1 \n\
8097- bne- 1b"
8098- PPC_ATOMIC_EXIT_BARRIER
8099- : "=&r" (t)
8100- : "r" (&v->counter)
8101- : "cc", "xer", "memory");
8102-
8103- return t;
8104+ return atomic_add_return_unchecked(1, v);
8105 }
8106
8107 /*
8108@@ -117,43 +153,38 @@ static __inline__ int atomic_inc_return(atomic_t *v)
8109 */
8110 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8111
8112-static __inline__ void atomic_dec(atomic_t *v)
8113+static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8114 {
8115- int t;
8116-
8117- __asm__ __volatile__(
8118-"1: lwarx %0,0,%2 # atomic_dec\n\
8119- addic %0,%0,-1\n"
8120- PPC405_ERR77(0,%2)\
8121-" stwcx. %0,0,%2\n\
8122- bne- 1b"
8123- : "=&r" (t), "+m" (v->counter)
8124- : "r" (&v->counter)
8125- : "cc", "xer");
8126+ return atomic_add_return_unchecked(1, v) == 0;
8127 }
8128
8129-static __inline__ int atomic_dec_return(atomic_t *v)
8130+/*
8131+ * atomic_dec - decrement atomic variable
8132+ * @v: pointer of type atomic_t
8133+ *
8134+ * Atomically decrements @v by 1
8135+ */
8136+#define atomic_dec(v) atomic_sub(1, (v))
8137+#define atomic_dec_return(v) atomic_sub_return(1, (v))
8138+
8139+static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
8140 {
8141- int t;
8142-
8143- __asm__ __volatile__(
8144- PPC_ATOMIC_ENTRY_BARRIER
8145-"1: lwarx %0,0,%1 # atomic_dec_return\n\
8146- addic %0,%0,-1\n"
8147- PPC405_ERR77(0,%1)
8148-" stwcx. %0,0,%1\n\
8149- bne- 1b"
8150- PPC_ATOMIC_EXIT_BARRIER
8151- : "=&r" (t)
8152- : "r" (&v->counter)
8153- : "cc", "xer", "memory");
8154-
8155- return t;
8156+ atomic_sub_unchecked(1, v);
8157 }
8158
8159 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8160 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8161
8162+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8163+{
8164+ return cmpxchg(&(v->counter), old, new);
8165+}
8166+
8167+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8168+{
8169+ return xchg(&(v->counter), new);
8170+}
8171+
8172 /**
8173 * __atomic_add_unless - add unless the number is a given value
8174 * @v: pointer of type atomic_t
8175@@ -171,11 +202,27 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
8176 PPC_ATOMIC_ENTRY_BARRIER
8177 "1: lwarx %0,0,%1 # __atomic_add_unless\n\
8178 cmpw 0,%0,%3 \n\
8179- beq- 2f \n\
8180- add %0,%2,%0 \n"
8181+ beq- 2f \n"
8182+
8183+#ifdef CONFIG_PAX_REFCOUNT
8184+" mcrxr cr0\n"
8185+" addo. %0,%2,%0\n"
8186+" bf 4*cr0+so, 4f\n"
8187+"3:.long " "0x00c00b00""\n"
8188+"4:\n"
8189+#else
8190+ "add %0,%2,%0 \n"
8191+#endif
8192+
8193 PPC405_ERR77(0,%2)
8194 " stwcx. %0,0,%1 \n\
8195 bne- 1b \n"
8196+"5:"
8197+
8198+#ifdef CONFIG_PAX_REFCOUNT
8199+ _ASM_EXTABLE(3b, 5b)
8200+#endif
8201+
8202 PPC_ATOMIC_EXIT_BARRIER
8203 " subf %0,%2,%0 \n\
8204 2:"
8205@@ -248,6 +295,11 @@ static __inline__ int atomic_dec_if_positive(atomic_t *v)
8206 }
8207 #define atomic_dec_if_positive atomic_dec_if_positive
8208
8209+#define smp_mb__before_atomic_dec() smp_mb()
8210+#define smp_mb__after_atomic_dec() smp_mb()
8211+#define smp_mb__before_atomic_inc() smp_mb()
8212+#define smp_mb__after_atomic_inc() smp_mb()
8213+
8214 #ifdef __powerpc64__
8215
8216 #define ATOMIC64_INIT(i) { (i) }
8217@@ -261,37 +313,60 @@ static __inline__ long atomic64_read(const atomic64_t *v)
8218 return t;
8219 }
8220
8221+static __inline__ long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8222+{
8223+ long t;
8224+
8225+ __asm__ __volatile__("ld%U1%X1 %0,%1" : "=r"(t) : "m"(v->counter));
8226+
8227+ return t;
8228+}
8229+
8230 static __inline__ void atomic64_set(atomic64_t *v, long i)
8231 {
8232 __asm__ __volatile__("std%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
8233 }
8234
8235-#define ATOMIC64_OP(op, asm_op) \
8236-static __inline__ void atomic64_##op(long a, atomic64_t *v) \
8237+static __inline__ void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8238+{
8239+ __asm__ __volatile__("std%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
8240+}
8241+
8242+#define __ATOMIC64_OP(op, suffix, pre_op, asm_op, post_op, extable) \
8243+static inline void atomic64_##op##suffix(long a, atomic64##suffix##_t *v)\
8244 { \
8245 long t; \
8246 \
8247 __asm__ __volatile__( \
8248 "1: ldarx %0,0,%3 # atomic64_" #op "\n" \
8249+ pre_op \
8250 #asm_op " %0,%2,%0\n" \
8251+ post_op \
8252 " stdcx. %0,0,%3 \n" \
8253 " bne- 1b\n" \
8254+ extable \
8255 : "=&r" (t), "+m" (v->counter) \
8256 : "r" (a), "r" (&v->counter) \
8257 : "cc"); \
8258 }
8259
8260-#define ATOMIC64_OP_RETURN(op, asm_op) \
8261-static __inline__ long atomic64_##op##_return(long a, atomic64_t *v) \
8262+#define ATOMIC64_OP(op, asm_op) __ATOMIC64_OP(op, , , asm_op, , ) \
8263+ __ATOMIC64_OP(op, _unchecked, __OVERFLOW_PRE, __REFCOUNT_OP(asm_op), __OVERFLOW_POST, __OVERFLOW_EXTABLE)
8264+
8265+#define __ATOMIC64_OP_RETURN(op, suffix, pre_op, asm_op, post_op, extable)\
8266+static inline long atomic64_##op##_return##suffix(long a, atomic64##suffix##_t *v)\
8267 { \
8268 long t; \
8269 \
8270 __asm__ __volatile__( \
8271 PPC_ATOMIC_ENTRY_BARRIER \
8272 "1: ldarx %0,0,%2 # atomic64_" #op "_return\n" \
8273+ pre_op \
8274 #asm_op " %0,%1,%0\n" \
8275+ post_op \
8276 " stdcx. %0,0,%2 \n" \
8277 " bne- 1b\n" \
8278+ extable \
8279 PPC_ATOMIC_EXIT_BARRIER \
8280 : "=&r" (t) \
8281 : "r" (a), "r" (&v->counter) \
8282@@ -300,6 +375,9 @@ static __inline__ long atomic64_##op##_return(long a, atomic64_t *v) \
8283 return t; \
8284 }
8285
8286+#define ATOMIC64_OP_RETURN(op, asm_op) __ATOMIC64_OP_RETURN(op, , , asm_op, , )\
8287+ __ATOMIC64_OP_RETURN(op, _unchecked, __OVERFLOW_PRE, __REFCOUNT_OP(asm_op), __OVERFLOW_POST, __OVERFLOW_EXTABLE)
8288+
8289 #define ATOMIC64_OPS(op, asm_op) ATOMIC64_OP(op, asm_op) ATOMIC64_OP_RETURN(op, asm_op)
8290
8291 ATOMIC64_OPS(add, add)
8292@@ -307,40 +385,33 @@ ATOMIC64_OPS(sub, subf)
8293
8294 #undef ATOMIC64_OPS
8295 #undef ATOMIC64_OP_RETURN
8296+#undef __ATOMIC64_OP_RETURN
8297 #undef ATOMIC64_OP
8298+#undef __ATOMIC64_OP
8299+#undef __OVERFLOW_EXTABLE
8300+#undef __OVERFLOW_POST
8301+#undef __OVERFLOW_PRE
8302+#undef __REFCOUNT_OP
8303
8304 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
8305
8306-static __inline__ void atomic64_inc(atomic64_t *v)
8307-{
8308- long t;
8309+/*
8310+ * atomic64_inc - increment atomic variable
8311+ * @v: pointer of type atomic64_t
8312+ *
8313+ * Automatically increments @v by 1
8314+ */
8315+#define atomic64_inc(v) atomic64_add(1, (v))
8316+#define atomic64_inc_return(v) atomic64_add_return(1, (v))
8317
8318- __asm__ __volatile__(
8319-"1: ldarx %0,0,%2 # atomic64_inc\n\
8320- addic %0,%0,1\n\
8321- stdcx. %0,0,%2 \n\
8322- bne- 1b"
8323- : "=&r" (t), "+m" (v->counter)
8324- : "r" (&v->counter)
8325- : "cc", "xer");
8326+static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8327+{
8328+ atomic64_add_unchecked(1, v);
8329 }
8330
8331-static __inline__ long atomic64_inc_return(atomic64_t *v)
8332+static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8333 {
8334- long t;
8335-
8336- __asm__ __volatile__(
8337- PPC_ATOMIC_ENTRY_BARRIER
8338-"1: ldarx %0,0,%1 # atomic64_inc_return\n\
8339- addic %0,%0,1\n\
8340- stdcx. %0,0,%1 \n\
8341- bne- 1b"
8342- PPC_ATOMIC_EXIT_BARRIER
8343- : "=&r" (t)
8344- : "r" (&v->counter)
8345- : "cc", "xer", "memory");
8346-
8347- return t;
8348+ return atomic64_add_return_unchecked(1, v);
8349 }
8350
8351 /*
8352@@ -353,36 +424,18 @@ static __inline__ long atomic64_inc_return(atomic64_t *v)
8353 */
8354 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8355
8356-static __inline__ void atomic64_dec(atomic64_t *v)
8357+/*
8358+ * atomic64_dec - decrement atomic variable
8359+ * @v: pointer of type atomic64_t
8360+ *
8361+ * Atomically decrements @v by 1
8362+ */
8363+#define atomic64_dec(v) atomic64_sub(1, (v))
8364+#define atomic64_dec_return(v) atomic64_sub_return(1, (v))
8365+
8366+static __inline__ void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8367 {
8368- long t;
8369-
8370- __asm__ __volatile__(
8371-"1: ldarx %0,0,%2 # atomic64_dec\n\
8372- addic %0,%0,-1\n\
8373- stdcx. %0,0,%2\n\
8374- bne- 1b"
8375- : "=&r" (t), "+m" (v->counter)
8376- : "r" (&v->counter)
8377- : "cc", "xer");
8378-}
8379-
8380-static __inline__ long atomic64_dec_return(atomic64_t *v)
8381-{
8382- long t;
8383-
8384- __asm__ __volatile__(
8385- PPC_ATOMIC_ENTRY_BARRIER
8386-"1: ldarx %0,0,%1 # atomic64_dec_return\n\
8387- addic %0,%0,-1\n\
8388- stdcx. %0,0,%1\n\
8389- bne- 1b"
8390- PPC_ATOMIC_EXIT_BARRIER
8391- : "=&r" (t)
8392- : "r" (&v->counter)
8393- : "cc", "xer", "memory");
8394-
8395- return t;
8396+ atomic64_sub_unchecked(1, v);
8397 }
8398
8399 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
8400@@ -415,6 +468,16 @@ static __inline__ long atomic64_dec_if_positive(atomic64_t *v)
8401 #define atomic64_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8402 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8403
8404+static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
8405+{
8406+ return cmpxchg(&(v->counter), old, new);
8407+}
8408+
8409+static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8410+{
8411+ return xchg(&(v->counter), new);
8412+}
8413+
8414 /**
8415 * atomic64_add_unless - add unless the number is a given value
8416 * @v: pointer of type atomic64_t
8417@@ -430,13 +493,29 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
8418
8419 __asm__ __volatile__ (
8420 PPC_ATOMIC_ENTRY_BARRIER
8421-"1: ldarx %0,0,%1 # __atomic_add_unless\n\
8422+"1: ldarx %0,0,%1 # atomic64_add_unless\n\
8423 cmpd 0,%0,%3 \n\
8424- beq- 2f \n\
8425- add %0,%2,%0 \n"
8426+ beq- 2f \n"
8427+
8428+#ifdef CONFIG_PAX_REFCOUNT
8429+" mcrxr cr0\n"
8430+" addo. %0,%2,%0\n"
8431+" bf 4*cr0+so, 4f\n"
8432+"3:.long " "0x00c00b00""\n"
8433+"4:\n"
8434+#else
8435+ "add %0,%2,%0 \n"
8436+#endif
8437+
8438 " stdcx. %0,0,%1 \n\
8439 bne- 1b \n"
8440 PPC_ATOMIC_EXIT_BARRIER
8441+"5:"
8442+
8443+#ifdef CONFIG_PAX_REFCOUNT
8444+ _ASM_EXTABLE(3b, 5b)
8445+#endif
8446+
8447 " subf %0,%2,%0 \n\
8448 2:"
8449 : "=&r" (t)
8450diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/asm/barrier.h
8451index 51ccc72..35de789 100644
8452--- a/arch/powerpc/include/asm/barrier.h
8453+++ b/arch/powerpc/include/asm/barrier.h
8454@@ -76,7 +76,7 @@
8455 do { \
8456 compiletime_assert_atomic_type(*p); \
8457 smp_lwsync(); \
8458- ACCESS_ONCE(*p) = (v); \
8459+ ACCESS_ONCE_RW(*p) = (v); \
8460 } while (0)
8461
8462 #define smp_load_acquire(p) \
8463diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
8464index 0dc42c5..b80a3a1 100644
8465--- a/arch/powerpc/include/asm/cache.h
8466+++ b/arch/powerpc/include/asm/cache.h
8467@@ -4,6 +4,7 @@
8468 #ifdef __KERNEL__
8469
8470 #include <asm/reg.h>
8471+#include <linux/const.h>
8472
8473 /* bytes per L1 cache line */
8474 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
8475@@ -23,7 +24,7 @@
8476 #define L1_CACHE_SHIFT 7
8477 #endif
8478
8479-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8480+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8481
8482 #define SMP_CACHE_BYTES L1_CACHE_BYTES
8483
8484diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
8485index ee46ffe..b36c98c 100644
8486--- a/arch/powerpc/include/asm/elf.h
8487+++ b/arch/powerpc/include/asm/elf.h
8488@@ -30,6 +30,18 @@
8489
8490 #define ELF_ET_DYN_BASE 0x20000000
8491
8492+#ifdef CONFIG_PAX_ASLR
8493+#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
8494+
8495+#ifdef __powerpc64__
8496+#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
8497+#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
8498+#else
8499+#define PAX_DELTA_MMAP_LEN 15
8500+#define PAX_DELTA_STACK_LEN 15
8501+#endif
8502+#endif
8503+
8504 #define ELF_CORE_EFLAGS (is_elf2_task() ? 2 : 0)
8505
8506 /*
8507diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
8508index 8196e9c..d83a9f3 100644
8509--- a/arch/powerpc/include/asm/exec.h
8510+++ b/arch/powerpc/include/asm/exec.h
8511@@ -4,6 +4,6 @@
8512 #ifndef _ASM_POWERPC_EXEC_H
8513 #define _ASM_POWERPC_EXEC_H
8514
8515-extern unsigned long arch_align_stack(unsigned long sp);
8516+#define arch_align_stack(x) ((x) & ~0xfUL)
8517
8518 #endif /* _ASM_POWERPC_EXEC_H */
8519diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
8520index 5acabbd..7ea14fa 100644
8521--- a/arch/powerpc/include/asm/kmap_types.h
8522+++ b/arch/powerpc/include/asm/kmap_types.h
8523@@ -10,7 +10,7 @@
8524 * 2 of the License, or (at your option) any later version.
8525 */
8526
8527-#define KM_TYPE_NR 16
8528+#define KM_TYPE_NR 17
8529
8530 #endif /* __KERNEL__ */
8531 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
8532diff --git a/arch/powerpc/include/asm/local.h b/arch/powerpc/include/asm/local.h
8533index b8da913..c02b593 100644
8534--- a/arch/powerpc/include/asm/local.h
8535+++ b/arch/powerpc/include/asm/local.h
8536@@ -9,21 +9,65 @@ typedef struct
8537 atomic_long_t a;
8538 } local_t;
8539
8540+typedef struct
8541+{
8542+ atomic_long_unchecked_t a;
8543+} local_unchecked_t;
8544+
8545 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
8546
8547 #define local_read(l) atomic_long_read(&(l)->a)
8548+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
8549 #define local_set(l,i) atomic_long_set(&(l)->a, (i))
8550+#define local_set_unchecked(l,i) atomic_long_set_unchecked(&(l)->a, (i))
8551
8552 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
8553+#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
8554 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
8555+#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
8556 #define local_inc(l) atomic_long_inc(&(l)->a)
8557+#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
8558 #define local_dec(l) atomic_long_dec(&(l)->a)
8559+#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
8560
8561 static __inline__ long local_add_return(long a, local_t *l)
8562 {
8563 long t;
8564
8565 __asm__ __volatile__(
8566+"1:" PPC_LLARX(%0,0,%2,0) " # local_add_return\n"
8567+
8568+#ifdef CONFIG_PAX_REFCOUNT
8569+" mcrxr cr0\n"
8570+" addo. %0,%1,%0\n"
8571+" bf 4*cr0+so, 3f\n"
8572+"2:.long " "0x00c00b00""\n"
8573+#else
8574+" add %0,%1,%0\n"
8575+#endif
8576+
8577+"3:\n"
8578+ PPC405_ERR77(0,%2)
8579+ PPC_STLCX "%0,0,%2 \n\
8580+ bne- 1b"
8581+
8582+#ifdef CONFIG_PAX_REFCOUNT
8583+"\n4:\n"
8584+ _ASM_EXTABLE(2b, 4b)
8585+#endif
8586+
8587+ : "=&r" (t)
8588+ : "r" (a), "r" (&(l->a.counter))
8589+ : "cc", "memory");
8590+
8591+ return t;
8592+}
8593+
8594+static __inline__ long local_add_return_unchecked(long a, local_unchecked_t *l)
8595+{
8596+ long t;
8597+
8598+ __asm__ __volatile__(
8599 "1:" PPC_LLARX(%0,0,%2,0) " # local_add_return\n\
8600 add %0,%1,%0\n"
8601 PPC405_ERR77(0,%2)
8602@@ -101,6 +145,8 @@ static __inline__ long local_dec_return(local_t *l)
8603
8604 #define local_cmpxchg(l, o, n) \
8605 (cmpxchg_local(&((l)->a.counter), (o), (n)))
8606+#define local_cmpxchg_unchecked(l, o, n) \
8607+ (cmpxchg_local(&((l)->a.counter), (o), (n)))
8608 #define local_xchg(l, n) (xchg_local(&((l)->a.counter), (n)))
8609
8610 /**
8611diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
8612index 8565c25..2865190 100644
8613--- a/arch/powerpc/include/asm/mman.h
8614+++ b/arch/powerpc/include/asm/mman.h
8615@@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
8616 }
8617 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
8618
8619-static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
8620+static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
8621 {
8622 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
8623 }
8624diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
8625index 71294a6..9e40aca 100644
8626--- a/arch/powerpc/include/asm/page.h
8627+++ b/arch/powerpc/include/asm/page.h
8628@@ -227,8 +227,9 @@ extern long long virt_phys_offset;
8629 * and needs to be executable. This means the whole heap ends
8630 * up being executable.
8631 */
8632-#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
8633- VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8634+#define VM_DATA_DEFAULT_FLAGS32 \
8635+ (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
8636+ VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8637
8638 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
8639 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8640@@ -256,6 +257,9 @@ extern long long virt_phys_offset;
8641 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
8642 #endif
8643
8644+#define ktla_ktva(addr) (addr)
8645+#define ktva_ktla(addr) (addr)
8646+
8647 #ifndef CONFIG_PPC_BOOK3S_64
8648 /*
8649 * Use the top bit of the higher-level page table entries to indicate whether
8650diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
8651index d908a46..3753f71 100644
8652--- a/arch/powerpc/include/asm/page_64.h
8653+++ b/arch/powerpc/include/asm/page_64.h
8654@@ -172,15 +172,18 @@ do { \
8655 * stack by default, so in the absence of a PT_GNU_STACK program header
8656 * we turn execute permission off.
8657 */
8658-#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
8659- VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8660+#define VM_STACK_DEFAULT_FLAGS32 \
8661+ (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
8662+ VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8663
8664 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
8665 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8666
8667+#ifndef CONFIG_PAX_PAGEEXEC
8668 #define VM_STACK_DEFAULT_FLAGS \
8669 (is_32bit_task() ? \
8670 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
8671+#endif
8672
8673 #include <asm-generic/getorder.h>
8674
8675diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
8676index 4b0be20..c15a27d 100644
8677--- a/arch/powerpc/include/asm/pgalloc-64.h
8678+++ b/arch/powerpc/include/asm/pgalloc-64.h
8679@@ -54,6 +54,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8680 #ifndef CONFIG_PPC_64K_PAGES
8681
8682 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
8683+#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
8684
8685 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
8686 {
8687@@ -71,6 +72,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
8688 pud_set(pud, (unsigned long)pmd);
8689 }
8690
8691+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
8692+{
8693+ pud_populate(mm, pud, pmd);
8694+}
8695+
8696 #define pmd_populate(mm, pmd, pte_page) \
8697 pmd_populate_kernel(mm, pmd, page_address(pte_page))
8698 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
8699@@ -173,6 +179,7 @@ extern void __tlb_remove_table(void *_table);
8700 #endif
8701
8702 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
8703+#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
8704
8705 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
8706 pte_t *pte)
8707diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
8708index 11a3863..108f194 100644
8709--- a/arch/powerpc/include/asm/pgtable.h
8710+++ b/arch/powerpc/include/asm/pgtable.h
8711@@ -2,6 +2,7 @@
8712 #define _ASM_POWERPC_PGTABLE_H
8713 #ifdef __KERNEL__
8714
8715+#include <linux/const.h>
8716 #ifndef __ASSEMBLY__
8717 #include <linux/mmdebug.h>
8718 #include <linux/mmzone.h>
8719diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
8720index 62cfb0c..50c6402 100644
8721--- a/arch/powerpc/include/asm/pte-hash32.h
8722+++ b/arch/powerpc/include/asm/pte-hash32.h
8723@@ -20,6 +20,7 @@
8724 #define _PAGE_HASHPTE 0x002 /* hash_page has made an HPTE for this pte */
8725 #define _PAGE_USER 0x004 /* usermode access allowed */
8726 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
8727+#define _PAGE_EXEC _PAGE_GUARDED
8728 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
8729 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
8730 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
8731diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
8732index af56b5c..f86f3f6 100644
8733--- a/arch/powerpc/include/asm/reg.h
8734+++ b/arch/powerpc/include/asm/reg.h
8735@@ -253,6 +253,7 @@
8736 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
8737 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
8738 #define DSISR_NOHPTE 0x40000000 /* no translation found */
8739+#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
8740 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
8741 #define DSISR_ISSTORE 0x02000000 /* access was a store */
8742 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
8743diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
8744index 825663c..f9e9134 100644
8745--- a/arch/powerpc/include/asm/smp.h
8746+++ b/arch/powerpc/include/asm/smp.h
8747@@ -51,7 +51,7 @@ struct smp_ops_t {
8748 int (*cpu_disable)(void);
8749 void (*cpu_die)(unsigned int nr);
8750 int (*cpu_bootable)(unsigned int nr);
8751-};
8752+} __no_const;
8753
8754 extern void smp_send_debugger_break(void);
8755 extern void start_secondary_resume(void);
8756diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
8757index 4dbe072..b803275 100644
8758--- a/arch/powerpc/include/asm/spinlock.h
8759+++ b/arch/powerpc/include/asm/spinlock.h
8760@@ -204,13 +204,29 @@ static inline long __arch_read_trylock(arch_rwlock_t *rw)
8761 __asm__ __volatile__(
8762 "1: " PPC_LWARX(%0,0,%1,1) "\n"
8763 __DO_SIGN_EXTEND
8764-" addic. %0,%0,1\n\
8765- ble- 2f\n"
8766+
8767+#ifdef CONFIG_PAX_REFCOUNT
8768+" mcrxr cr0\n"
8769+" addico. %0,%0,1\n"
8770+" bf 4*cr0+so, 3f\n"
8771+"2:.long " "0x00c00b00""\n"
8772+#else
8773+" addic. %0,%0,1\n"
8774+#endif
8775+
8776+"3:\n"
8777+ "ble- 4f\n"
8778 PPC405_ERR77(0,%1)
8779 " stwcx. %0,0,%1\n\
8780 bne- 1b\n"
8781 PPC_ACQUIRE_BARRIER
8782-"2:" : "=&r" (tmp)
8783+"4:"
8784+
8785+#ifdef CONFIG_PAX_REFCOUNT
8786+ _ASM_EXTABLE(2b,4b)
8787+#endif
8788+
8789+ : "=&r" (tmp)
8790 : "r" (&rw->lock)
8791 : "cr0", "xer", "memory");
8792
8793@@ -286,11 +302,27 @@ static inline void arch_read_unlock(arch_rwlock_t *rw)
8794 __asm__ __volatile__(
8795 "# read_unlock\n\t"
8796 PPC_RELEASE_BARRIER
8797-"1: lwarx %0,0,%1\n\
8798- addic %0,%0,-1\n"
8799+"1: lwarx %0,0,%1\n"
8800+
8801+#ifdef CONFIG_PAX_REFCOUNT
8802+" mcrxr cr0\n"
8803+" addico. %0,%0,-1\n"
8804+" bf 4*cr0+so, 3f\n"
8805+"2:.long " "0x00c00b00""\n"
8806+#else
8807+" addic. %0,%0,-1\n"
8808+#endif
8809+
8810+"3:\n"
8811 PPC405_ERR77(0,%1)
8812 " stwcx. %0,0,%1\n\
8813 bne- 1b"
8814+
8815+#ifdef CONFIG_PAX_REFCOUNT
8816+"\n4:\n"
8817+ _ASM_EXTABLE(2b, 4b)
8818+#endif
8819+
8820 : "=&r"(tmp)
8821 : "r"(&rw->lock)
8822 : "cr0", "xer", "memory");
8823diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
8824index 7efee4a..48d47cc 100644
8825--- a/arch/powerpc/include/asm/thread_info.h
8826+++ b/arch/powerpc/include/asm/thread_info.h
8827@@ -101,6 +101,8 @@ static inline struct thread_info *current_thread_info(void)
8828 #if defined(CONFIG_PPC64)
8829 #define TIF_ELF2ABI 18 /* function descriptors must die! */
8830 #endif
8831+/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
8832+#define TIF_GRSEC_SETXID 6 /* update credentials on syscall entry/exit */
8833
8834 /* as above, but as bit values */
8835 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
8836@@ -119,9 +121,10 @@ static inline struct thread_info *current_thread_info(void)
8837 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8838 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
8839 #define _TIF_NOHZ (1<<TIF_NOHZ)
8840+#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8841 #define _TIF_SYSCALL_DOTRACE (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
8842 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
8843- _TIF_NOHZ)
8844+ _TIF_NOHZ | _TIF_GRSEC_SETXID)
8845
8846 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
8847 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
8848diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
8849index 2a8ebae..5643c6f 100644
8850--- a/arch/powerpc/include/asm/uaccess.h
8851+++ b/arch/powerpc/include/asm/uaccess.h
8852@@ -58,6 +58,7 @@
8853
8854 #endif
8855
8856+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
8857 #define access_ok(type, addr, size) \
8858 (__chk_user_ptr(addr), \
8859 __access_ok((__force unsigned long)(addr), (size), get_fs()))
8860@@ -318,52 +319,6 @@ do { \
8861 extern unsigned long __copy_tofrom_user(void __user *to,
8862 const void __user *from, unsigned long size);
8863
8864-#ifndef __powerpc64__
8865-
8866-static inline unsigned long copy_from_user(void *to,
8867- const void __user *from, unsigned long n)
8868-{
8869- unsigned long over;
8870-
8871- if (access_ok(VERIFY_READ, from, n))
8872- return __copy_tofrom_user((__force void __user *)to, from, n);
8873- if ((unsigned long)from < TASK_SIZE) {
8874- over = (unsigned long)from + n - TASK_SIZE;
8875- return __copy_tofrom_user((__force void __user *)to, from,
8876- n - over) + over;
8877- }
8878- return n;
8879-}
8880-
8881-static inline unsigned long copy_to_user(void __user *to,
8882- const void *from, unsigned long n)
8883-{
8884- unsigned long over;
8885-
8886- if (access_ok(VERIFY_WRITE, to, n))
8887- return __copy_tofrom_user(to, (__force void __user *)from, n);
8888- if ((unsigned long)to < TASK_SIZE) {
8889- over = (unsigned long)to + n - TASK_SIZE;
8890- return __copy_tofrom_user(to, (__force void __user *)from,
8891- n - over) + over;
8892- }
8893- return n;
8894-}
8895-
8896-#else /* __powerpc64__ */
8897-
8898-#define __copy_in_user(to, from, size) \
8899- __copy_tofrom_user((to), (from), (size))
8900-
8901-extern unsigned long copy_from_user(void *to, const void __user *from,
8902- unsigned long n);
8903-extern unsigned long copy_to_user(void __user *to, const void *from,
8904- unsigned long n);
8905-extern unsigned long copy_in_user(void __user *to, const void __user *from,
8906- unsigned long n);
8907-
8908-#endif /* __powerpc64__ */
8909-
8910 static inline unsigned long __copy_from_user_inatomic(void *to,
8911 const void __user *from, unsigned long n)
8912 {
8913@@ -387,6 +342,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
8914 if (ret == 0)
8915 return 0;
8916 }
8917+
8918+ if (!__builtin_constant_p(n))
8919+ check_object_size(to, n, false);
8920+
8921 return __copy_tofrom_user((__force void __user *)to, from, n);
8922 }
8923
8924@@ -413,6 +372,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
8925 if (ret == 0)
8926 return 0;
8927 }
8928+
8929+ if (!__builtin_constant_p(n))
8930+ check_object_size(from, n, true);
8931+
8932 return __copy_tofrom_user(to, (__force const void __user *)from, n);
8933 }
8934
8935@@ -430,6 +393,92 @@ static inline unsigned long __copy_to_user(void __user *to,
8936 return __copy_to_user_inatomic(to, from, size);
8937 }
8938
8939+#ifndef __powerpc64__
8940+
8941+static inline unsigned long __must_check copy_from_user(void *to,
8942+ const void __user *from, unsigned long n)
8943+{
8944+ unsigned long over;
8945+
8946+ if ((long)n < 0)
8947+ return n;
8948+
8949+ if (access_ok(VERIFY_READ, from, n)) {
8950+ if (!__builtin_constant_p(n))
8951+ check_object_size(to, n, false);
8952+ return __copy_tofrom_user((__force void __user *)to, from, n);
8953+ }
8954+ if ((unsigned long)from < TASK_SIZE) {
8955+ over = (unsigned long)from + n - TASK_SIZE;
8956+ if (!__builtin_constant_p(n - over))
8957+ check_object_size(to, n - over, false);
8958+ return __copy_tofrom_user((__force void __user *)to, from,
8959+ n - over) + over;
8960+ }
8961+ return n;
8962+}
8963+
8964+static inline unsigned long __must_check copy_to_user(void __user *to,
8965+ const void *from, unsigned long n)
8966+{
8967+ unsigned long over;
8968+
8969+ if ((long)n < 0)
8970+ return n;
8971+
8972+ if (access_ok(VERIFY_WRITE, to, n)) {
8973+ if (!__builtin_constant_p(n))
8974+ check_object_size(from, n, true);
8975+ return __copy_tofrom_user(to, (__force void __user *)from, n);
8976+ }
8977+ if ((unsigned long)to < TASK_SIZE) {
8978+ over = (unsigned long)to + n - TASK_SIZE;
8979+ if (!__builtin_constant_p(n))
8980+ check_object_size(from, n - over, true);
8981+ return __copy_tofrom_user(to, (__force void __user *)from,
8982+ n - over) + over;
8983+ }
8984+ return n;
8985+}
8986+
8987+#else /* __powerpc64__ */
8988+
8989+#define __copy_in_user(to, from, size) \
8990+ __copy_tofrom_user((to), (from), (size))
8991+
8992+static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
8993+{
8994+ if ((long)n < 0 || n > INT_MAX)
8995+ return n;
8996+
8997+ if (!__builtin_constant_p(n))
8998+ check_object_size(to, n, false);
8999+
9000+ if (likely(access_ok(VERIFY_READ, from, n)))
9001+ n = __copy_from_user(to, from, n);
9002+ else
9003+ memset(to, 0, n);
9004+ return n;
9005+}
9006+
9007+static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
9008+{
9009+ if ((long)n < 0 || n > INT_MAX)
9010+ return n;
9011+
9012+ if (likely(access_ok(VERIFY_WRITE, to, n))) {
9013+ if (!__builtin_constant_p(n))
9014+ check_object_size(from, n, true);
9015+ n = __copy_to_user(to, from, n);
9016+ }
9017+ return n;
9018+}
9019+
9020+extern unsigned long copy_in_user(void __user *to, const void __user *from,
9021+ unsigned long n);
9022+
9023+#endif /* __powerpc64__ */
9024+
9025 extern unsigned long __clear_user(void __user *addr, unsigned long size);
9026
9027 static inline unsigned long clear_user(void __user *addr, unsigned long size)
9028diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
9029index 12868b1..5155667 100644
9030--- a/arch/powerpc/kernel/Makefile
9031+++ b/arch/powerpc/kernel/Makefile
9032@@ -14,6 +14,11 @@ CFLAGS_prom_init.o += -fPIC
9033 CFLAGS_btext.o += -fPIC
9034 endif
9035
9036+CFLAGS_REMOVE_cputable.o = $(LATENT_ENTROPY_PLUGIN_CFLAGS)
9037+CFLAGS_REMOVE_prom_init.o = $(LATENT_ENTROPY_PLUGIN_CFLAGS)
9038+CFLAGS_REMOVE_btext.o = $(LATENT_ENTROPY_PLUGIN_CFLAGS)
9039+CFLAGS_REMOVE_prom.o = $(LATENT_ENTROPY_PLUGIN_CFLAGS)
9040+
9041 ifdef CONFIG_FUNCTION_TRACER
9042 # Do not trace early boot code
9043 CFLAGS_REMOVE_cputable.o = -pg -mno-sched-epilog
9044@@ -26,6 +31,8 @@ CFLAGS_REMOVE_ftrace.o = -pg -mno-sched-epilog
9045 CFLAGS_REMOVE_time.o = -pg -mno-sched-epilog
9046 endif
9047
9048+CFLAGS_REMOVE_prom_init.o += $(LATENT_ENTROPY_PLUGIN_CFLAGS)
9049+
9050 obj-y := cputable.o ptrace.o syscalls.o \
9051 irq.o align.o signal_32.o pmc.o vdso.o \
9052 process.o systbl.o idle.o \
9053diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
9054index 3e68d1c..72a5ee6 100644
9055--- a/arch/powerpc/kernel/exceptions-64e.S
9056+++ b/arch/powerpc/kernel/exceptions-64e.S
9057@@ -1010,6 +1010,7 @@ storage_fault_common:
9058 std r14,_DAR(r1)
9059 std r15,_DSISR(r1)
9060 addi r3,r1,STACK_FRAME_OVERHEAD
9061+ bl save_nvgprs
9062 mr r4,r14
9063 mr r5,r15
9064 ld r14,PACA_EXGEN+EX_R14(r13)
9065@@ -1018,8 +1019,7 @@ storage_fault_common:
9066 cmpdi r3,0
9067 bne- 1f
9068 b ret_from_except_lite
9069-1: bl save_nvgprs
9070- mr r5,r3
9071+1: mr r5,r3
9072 addi r3,r1,STACK_FRAME_OVERHEAD
9073 ld r4,_DAR(r1)
9074 bl bad_page_fault
9075diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
9076index 0a0399c2..262a2e6 100644
9077--- a/arch/powerpc/kernel/exceptions-64s.S
9078+++ b/arch/powerpc/kernel/exceptions-64s.S
9079@@ -1591,10 +1591,10 @@ handle_page_fault:
9080 11: ld r4,_DAR(r1)
9081 ld r5,_DSISR(r1)
9082 addi r3,r1,STACK_FRAME_OVERHEAD
9083+ bl save_nvgprs
9084 bl do_page_fault
9085 cmpdi r3,0
9086 beq+ 12f
9087- bl save_nvgprs
9088 mr r5,r3
9089 addi r3,r1,STACK_FRAME_OVERHEAD
9090 lwz r4,_DAR(r1)
9091diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
9092index 4509603..cdb491f 100644
9093--- a/arch/powerpc/kernel/irq.c
9094+++ b/arch/powerpc/kernel/irq.c
9095@@ -460,6 +460,8 @@ void migrate_irqs(void)
9096 }
9097 #endif
9098
9099+extern void gr_handle_kernel_exploit(void);
9100+
9101 static inline void check_stack_overflow(void)
9102 {
9103 #ifdef CONFIG_DEBUG_STACKOVERFLOW
9104@@ -472,6 +474,7 @@ static inline void check_stack_overflow(void)
9105 pr_err("do_IRQ: stack overflow: %ld\n",
9106 sp - sizeof(struct thread_info));
9107 dump_stack();
9108+ gr_handle_kernel_exploit();
9109 }
9110 #endif
9111 }
9112diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
9113index c94d2e0..992a9ce 100644
9114--- a/arch/powerpc/kernel/module_32.c
9115+++ b/arch/powerpc/kernel/module_32.c
9116@@ -158,7 +158,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
9117 me->arch.core_plt_section = i;
9118 }
9119 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
9120- pr_err("Module doesn't contain .plt or .init.plt sections.\n");
9121+ pr_err("Module $s doesn't contain .plt or .init.plt sections.\n", me->name);
9122 return -ENOEXEC;
9123 }
9124
9125@@ -188,11 +188,16 @@ static uint32_t do_plt_call(void *location,
9126
9127 pr_debug("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
9128 /* Init, or core PLT? */
9129- if (location >= mod->module_core
9130- && location < mod->module_core + mod->core_size)
9131+ if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
9132+ (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
9133 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
9134- else
9135+ else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
9136+ (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
9137 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
9138+ else {
9139+ printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
9140+ return ~0UL;
9141+ }
9142
9143 /* Find this entry, or if that fails, the next avail. entry */
9144 while (entry->jump[0]) {
9145@@ -296,7 +301,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
9146 }
9147 #ifdef CONFIG_DYNAMIC_FTRACE
9148 module->arch.tramp =
9149- do_plt_call(module->module_core,
9150+ do_plt_call(module->module_core_rx,
9151 (unsigned long)ftrace_caller,
9152 sechdrs, module);
9153 #endif
9154diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
9155index 64e6e9d..cf90ed5 100644
9156--- a/arch/powerpc/kernel/process.c
9157+++ b/arch/powerpc/kernel/process.c
9158@@ -1033,8 +1033,8 @@ void show_regs(struct pt_regs * regs)
9159 * Lookup NIP late so we have the best change of getting the
9160 * above info out without failing
9161 */
9162- printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
9163- printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
9164+ printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
9165+ printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
9166 #endif
9167 show_stack(current, (unsigned long *) regs->gpr[1]);
9168 if (!user_mode(regs))
9169@@ -1550,10 +1550,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
9170 newsp = stack[0];
9171 ip = stack[STACK_FRAME_LR_SAVE];
9172 if (!firstframe || ip != lr) {
9173- printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
9174+ printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
9175 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
9176 if ((ip == rth) && curr_frame >= 0) {
9177- printk(" (%pS)",
9178+ printk(" (%pA)",
9179 (void *)current->ret_stack[curr_frame].ret);
9180 curr_frame--;
9181 }
9182@@ -1573,7 +1573,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
9183 struct pt_regs *regs = (struct pt_regs *)
9184 (sp + STACK_FRAME_OVERHEAD);
9185 lr = regs->link;
9186- printk("--- interrupt: %lx at %pS\n LR = %pS\n",
9187+ printk("--- interrupt: %lx at %pA\n LR = %pA\n",
9188 regs->trap, (void *)regs->nip, (void *)lr);
9189 firstframe = 1;
9190 }
9191@@ -1609,49 +1609,3 @@ void notrace __ppc64_runlatch_off(void)
9192 mtspr(SPRN_CTRLT, ctrl);
9193 }
9194 #endif /* CONFIG_PPC64 */
9195-
9196-unsigned long arch_align_stack(unsigned long sp)
9197-{
9198- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
9199- sp -= get_random_int() & ~PAGE_MASK;
9200- return sp & ~0xf;
9201-}
9202-
9203-static inline unsigned long brk_rnd(void)
9204-{
9205- unsigned long rnd = 0;
9206-
9207- /* 8MB for 32bit, 1GB for 64bit */
9208- if (is_32bit_task())
9209- rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
9210- else
9211- rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
9212-
9213- return rnd << PAGE_SHIFT;
9214-}
9215-
9216-unsigned long arch_randomize_brk(struct mm_struct *mm)
9217-{
9218- unsigned long base = mm->brk;
9219- unsigned long ret;
9220-
9221-#ifdef CONFIG_PPC_STD_MMU_64
9222- /*
9223- * If we are using 1TB segments and we are allowed to randomise
9224- * the heap, we can put it above 1TB so it is backed by a 1TB
9225- * segment. Otherwise the heap will be in the bottom 1TB
9226- * which always uses 256MB segments and this may result in a
9227- * performance penalty.
9228- */
9229- if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
9230- base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
9231-#endif
9232-
9233- ret = PAGE_ALIGN(base + brk_rnd());
9234-
9235- if (ret < mm->brk)
9236- return mm->brk;
9237-
9238- return ret;
9239-}
9240-
9241diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
9242index f21897b..28c0428 100644
9243--- a/arch/powerpc/kernel/ptrace.c
9244+++ b/arch/powerpc/kernel/ptrace.c
9245@@ -1762,6 +1762,10 @@ long arch_ptrace(struct task_struct *child, long request,
9246 return ret;
9247 }
9248
9249+#ifdef CONFIG_GRKERNSEC_SETXID
9250+extern void gr_delayed_cred_worker(void);
9251+#endif
9252+
9253 /*
9254 * We must return the syscall number to actually look up in the table.
9255 * This can be -1L to skip running any syscall at all.
9256@@ -1774,6 +1778,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
9257
9258 secure_computing_strict(regs->gpr[0]);
9259
9260+#ifdef CONFIG_GRKERNSEC_SETXID
9261+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9262+ gr_delayed_cred_worker();
9263+#endif
9264+
9265 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
9266 tracehook_report_syscall_entry(regs))
9267 /*
9268@@ -1805,6 +1814,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
9269 {
9270 int step;
9271
9272+#ifdef CONFIG_GRKERNSEC_SETXID
9273+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9274+ gr_delayed_cred_worker();
9275+#endif
9276+
9277 audit_syscall_exit(regs);
9278
9279 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9280diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
9281index da50e0c..5ff6307 100644
9282--- a/arch/powerpc/kernel/signal_32.c
9283+++ b/arch/powerpc/kernel/signal_32.c
9284@@ -1009,7 +1009,7 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset,
9285 /* Save user registers on the stack */
9286 frame = &rt_sf->uc.uc_mcontext;
9287 addr = frame;
9288- if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
9289+ if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
9290 sigret = 0;
9291 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
9292 } else {
9293diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
9294index c7c24d2..1bf7039 100644
9295--- a/arch/powerpc/kernel/signal_64.c
9296+++ b/arch/powerpc/kernel/signal_64.c
9297@@ -754,7 +754,7 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs
9298 current->thread.fp_state.fpscr = 0;
9299
9300 /* Set up to return from userspace. */
9301- if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
9302+ if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
9303 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
9304 } else {
9305 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
9306diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
9307index 37de90f..12472ac 100644
9308--- a/arch/powerpc/kernel/traps.c
9309+++ b/arch/powerpc/kernel/traps.c
9310@@ -36,6 +36,7 @@
9311 #include <linux/debugfs.h>
9312 #include <linux/ratelimit.h>
9313 #include <linux/context_tracking.h>
9314+#include <linux/uaccess.h>
9315
9316 #include <asm/emulated_ops.h>
9317 #include <asm/pgtable.h>
9318@@ -142,6 +143,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
9319 return flags;
9320 }
9321
9322+extern void gr_handle_kernel_exploit(void);
9323+
9324 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
9325 int signr)
9326 {
9327@@ -191,6 +194,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
9328 panic("Fatal exception in interrupt");
9329 if (panic_on_oops)
9330 panic("Fatal exception");
9331+
9332+ gr_handle_kernel_exploit();
9333+
9334 do_exit(signr);
9335 }
9336
9337@@ -1139,6 +1145,26 @@ void __kprobes program_check_exception(struct pt_regs *regs)
9338 enum ctx_state prev_state = exception_enter();
9339 unsigned int reason = get_reason(regs);
9340
9341+#ifdef CONFIG_PAX_REFCOUNT
9342+ unsigned int bkpt;
9343+ const struct exception_table_entry *entry;
9344+
9345+ if (reason & REASON_ILLEGAL) {
9346+ /* Check if PaX bad instruction */
9347+ if (!probe_kernel_address(regs->nip, bkpt) && bkpt == 0xc00b00) {
9348+ current->thread.trap_nr = 0;
9349+ pax_report_refcount_overflow(regs);
9350+ /* fixup_exception() for PowerPC does not exist, simulate its job */
9351+ if ((entry = search_exception_tables(regs->nip)) != NULL) {
9352+ regs->nip = entry->fixup;
9353+ return;
9354+ }
9355+ /* fixup_exception() could not handle */
9356+ goto bail;
9357+ }
9358+ }
9359+#endif
9360+
9361 /* We can now get here via a FP Unavailable exception if the core
9362 * has no FPU, in that case the reason flags will be 0 */
9363
9364diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
9365index b457bfa..9018cde 100644
9366--- a/arch/powerpc/kernel/vdso.c
9367+++ b/arch/powerpc/kernel/vdso.c
9368@@ -34,6 +34,7 @@
9369 #include <asm/vdso.h>
9370 #include <asm/vdso_datapage.h>
9371 #include <asm/setup.h>
9372+#include <asm/mman.h>
9373
9374 #undef DEBUG
9375
9376@@ -179,7 +180,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
9377 vdso_base = VDSO32_MBASE;
9378 #endif
9379
9380- current->mm->context.vdso_base = 0;
9381+ current->mm->context.vdso_base = ~0UL;
9382
9383 /* vDSO has a problem and was disabled, just don't "enable" it for the
9384 * process
9385@@ -199,7 +200,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
9386 vdso_base = get_unmapped_area(NULL, vdso_base,
9387 (vdso_pages << PAGE_SHIFT) +
9388 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
9389- 0, 0);
9390+ 0, MAP_PRIVATE | MAP_EXECUTABLE);
9391 if (IS_ERR_VALUE(vdso_base)) {
9392 rc = vdso_base;
9393 goto fail_mmapsem;
9394diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
9395index e5dde32..557af3d 100644
9396--- a/arch/powerpc/kvm/powerpc.c
9397+++ b/arch/powerpc/kvm/powerpc.c
9398@@ -1404,7 +1404,7 @@ void kvmppc_init_lpid(unsigned long nr_lpids_param)
9399 }
9400 EXPORT_SYMBOL_GPL(kvmppc_init_lpid);
9401
9402-int kvm_arch_init(void *opaque)
9403+int kvm_arch_init(const void *opaque)
9404 {
9405 return 0;
9406 }
9407diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
9408index 5eea6f3..5d10396 100644
9409--- a/arch/powerpc/lib/usercopy_64.c
9410+++ b/arch/powerpc/lib/usercopy_64.c
9411@@ -9,22 +9,6 @@
9412 #include <linux/module.h>
9413 #include <asm/uaccess.h>
9414
9415-unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9416-{
9417- if (likely(access_ok(VERIFY_READ, from, n)))
9418- n = __copy_from_user(to, from, n);
9419- else
9420- memset(to, 0, n);
9421- return n;
9422-}
9423-
9424-unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9425-{
9426- if (likely(access_ok(VERIFY_WRITE, to, n)))
9427- n = __copy_to_user(to, from, n);
9428- return n;
9429-}
9430-
9431 unsigned long copy_in_user(void __user *to, const void __user *from,
9432 unsigned long n)
9433 {
9434@@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
9435 return n;
9436 }
9437
9438-EXPORT_SYMBOL(copy_from_user);
9439-EXPORT_SYMBOL(copy_to_user);
9440 EXPORT_SYMBOL(copy_in_user);
9441
9442diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
9443index a67c6d7..a662e6d 100644
9444--- a/arch/powerpc/mm/fault.c
9445+++ b/arch/powerpc/mm/fault.c
9446@@ -34,6 +34,10 @@
9447 #include <linux/context_tracking.h>
9448 #include <linux/hugetlb.h>
9449 #include <linux/uaccess.h>
9450+#include <linux/slab.h>
9451+#include <linux/pagemap.h>
9452+#include <linux/compiler.h>
9453+#include <linux/unistd.h>
9454
9455 #include <asm/firmware.h>
9456 #include <asm/page.h>
9457@@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
9458 }
9459 #endif
9460
9461+#ifdef CONFIG_PAX_PAGEEXEC
9462+/*
9463+ * PaX: decide what to do with offenders (regs->nip = fault address)
9464+ *
9465+ * returns 1 when task should be killed
9466+ */
9467+static int pax_handle_fetch_fault(struct pt_regs *regs)
9468+{
9469+ return 1;
9470+}
9471+
9472+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9473+{
9474+ unsigned long i;
9475+
9476+ printk(KERN_ERR "PAX: bytes at PC: ");
9477+ for (i = 0; i < 5; i++) {
9478+ unsigned int c;
9479+ if (get_user(c, (unsigned int __user *)pc+i))
9480+ printk(KERN_CONT "???????? ");
9481+ else
9482+ printk(KERN_CONT "%08x ", c);
9483+ }
9484+ printk("\n");
9485+}
9486+#endif
9487+
9488 /*
9489 * Check whether the instruction at regs->nip is a store using
9490 * an update addressing form which will update r1.
9491@@ -227,7 +258,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
9492 * indicate errors in DSISR but can validly be set in SRR1.
9493 */
9494 if (trap == 0x400)
9495- error_code &= 0x48200000;
9496+ error_code &= 0x58200000;
9497 else
9498 is_write = error_code & DSISR_ISSTORE;
9499 #else
9500@@ -384,12 +415,16 @@ good_area:
9501 * "undefined". Of those that can be set, this is the only
9502 * one which seems bad.
9503 */
9504- if (error_code & 0x10000000)
9505+ if (error_code & DSISR_GUARDED)
9506 /* Guarded storage error. */
9507 goto bad_area;
9508 #endif /* CONFIG_8xx */
9509
9510 if (is_exec) {
9511+#ifdef CONFIG_PPC_STD_MMU
9512+ if (error_code & DSISR_GUARDED)
9513+ goto bad_area;
9514+#endif
9515 /*
9516 * Allow execution from readable areas if the MMU does not
9517 * provide separate controls over reading and executing.
9518@@ -484,6 +519,23 @@ bad_area:
9519 bad_area_nosemaphore:
9520 /* User mode accesses cause a SIGSEGV */
9521 if (user_mode(regs)) {
9522+
9523+#ifdef CONFIG_PAX_PAGEEXEC
9524+ if (mm->pax_flags & MF_PAX_PAGEEXEC) {
9525+#ifdef CONFIG_PPC_STD_MMU
9526+ if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
9527+#else
9528+ if (is_exec && regs->nip == address) {
9529+#endif
9530+ switch (pax_handle_fetch_fault(regs)) {
9531+ }
9532+
9533+ pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
9534+ do_group_exit(SIGKILL);
9535+ }
9536+ }
9537+#endif
9538+
9539 _exception(SIGSEGV, regs, code, address);
9540 goto bail;
9541 }
9542diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
9543index 0f0502e..bc3e7a3 100644
9544--- a/arch/powerpc/mm/mmap.c
9545+++ b/arch/powerpc/mm/mmap.c
9546@@ -86,6 +86,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9547 {
9548 unsigned long random_factor = 0UL;
9549
9550+#ifdef CONFIG_PAX_RANDMMAP
9551+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9552+#endif
9553+
9554 if (current->flags & PF_RANDOMIZE)
9555 random_factor = arch_mmap_rnd();
9556
9557@@ -95,9 +99,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9558 */
9559 if (mmap_is_legacy()) {
9560 mm->mmap_base = TASK_UNMAPPED_BASE;
9561+
9562+#ifdef CONFIG_PAX_RANDMMAP
9563+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9564+ mm->mmap_base += mm->delta_mmap;
9565+#endif
9566+
9567 mm->get_unmapped_area = arch_get_unmapped_area;
9568 } else {
9569 mm->mmap_base = mmap_base(random_factor);
9570+
9571+#ifdef CONFIG_PAX_RANDMMAP
9572+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9573+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9574+#endif
9575+
9576 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9577 }
9578 }
9579diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
9580index 0f432a7..abfe841 100644
9581--- a/arch/powerpc/mm/slice.c
9582+++ b/arch/powerpc/mm/slice.c
9583@@ -105,7 +105,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
9584 if ((mm->task_size - len) < addr)
9585 return 0;
9586 vma = find_vma(mm, addr);
9587- return (!vma || (addr + len) <= vma->vm_start);
9588+ return check_heap_stack_gap(vma, addr, len, 0);
9589 }
9590
9591 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
9592@@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
9593 info.align_offset = 0;
9594
9595 addr = TASK_UNMAPPED_BASE;
9596+
9597+#ifdef CONFIG_PAX_RANDMMAP
9598+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9599+ addr += mm->delta_mmap;
9600+#endif
9601+
9602 while (addr < TASK_SIZE) {
9603 info.low_limit = addr;
9604 if (!slice_scan_available(addr, available, 1, &addr))
9605@@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
9606 if (fixed && addr > (mm->task_size - len))
9607 return -ENOMEM;
9608
9609+#ifdef CONFIG_PAX_RANDMMAP
9610+ if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
9611+ addr = 0;
9612+#endif
9613+
9614 /* If hint, make sure it matches our alignment restrictions */
9615 if (!fixed && addr) {
9616 addr = _ALIGN_UP(addr, 1ul << pshift);
9617diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
9618index d966bbe..372124a 100644
9619--- a/arch/powerpc/platforms/cell/spufs/file.c
9620+++ b/arch/powerpc/platforms/cell/spufs/file.c
9621@@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9622 return VM_FAULT_NOPAGE;
9623 }
9624
9625-static int spufs_mem_mmap_access(struct vm_area_struct *vma,
9626+static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
9627 unsigned long address,
9628- void *buf, int len, int write)
9629+ void *buf, size_t len, int write)
9630 {
9631 struct spu_context *ctx = vma->vm_file->private_data;
9632 unsigned long offset = address - vma->vm_start;
9633diff --git a/arch/s390/Kconfig.debug b/arch/s390/Kconfig.debug
9634index c56878e..073d04e 100644
9635--- a/arch/s390/Kconfig.debug
9636+++ b/arch/s390/Kconfig.debug
9637@@ -21,6 +21,7 @@ config S390_PTDUMP
9638 bool "Export kernel pagetable layout to userspace via debugfs"
9639 depends on DEBUG_KERNEL
9640 select DEBUG_FS
9641+ depends on !GRKERNSEC_KMEM
9642 ---help---
9643 Say Y here if you want to show the kernel pagetable layout in a
9644 debugfs file. This information is only useful for kernel developers
9645diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
9646index adbe380..adb7516 100644
9647--- a/arch/s390/include/asm/atomic.h
9648+++ b/arch/s390/include/asm/atomic.h
9649@@ -317,4 +317,14 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
9650 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
9651 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9652
9653+#define atomic64_read_unchecked(v) atomic64_read(v)
9654+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
9655+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
9656+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
9657+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
9658+#define atomic64_inc_unchecked(v) atomic64_inc(v)
9659+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
9660+#define atomic64_dec_unchecked(v) atomic64_dec(v)
9661+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
9662+
9663 #endif /* __ARCH_S390_ATOMIC__ */
9664diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h
9665index e6f8615..4a66339 100644
9666--- a/arch/s390/include/asm/barrier.h
9667+++ b/arch/s390/include/asm/barrier.h
9668@@ -42,7 +42,7 @@
9669 do { \
9670 compiletime_assert_atomic_type(*p); \
9671 barrier(); \
9672- ACCESS_ONCE(*p) = (v); \
9673+ ACCESS_ONCE_RW(*p) = (v); \
9674 } while (0)
9675
9676 #define smp_load_acquire(p) \
9677diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
9678index 4d7ccac..d03d0ad 100644
9679--- a/arch/s390/include/asm/cache.h
9680+++ b/arch/s390/include/asm/cache.h
9681@@ -9,8 +9,10 @@
9682 #ifndef __ARCH_S390_CACHE_H
9683 #define __ARCH_S390_CACHE_H
9684
9685-#define L1_CACHE_BYTES 256
9686+#include <linux/const.h>
9687+
9688 #define L1_CACHE_SHIFT 8
9689+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9690 #define NET_SKB_PAD 32
9691
9692 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
9693diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
9694index 3ad48f2..64cc6f3 100644
9695--- a/arch/s390/include/asm/elf.h
9696+++ b/arch/s390/include/asm/elf.h
9697@@ -163,6 +163,13 @@ extern unsigned int vdso_enabled;
9698 (STACK_TOP / 3 * 2) : \
9699 (STACK_TOP / 3 * 2) & ~((1UL << 32) - 1))
9700
9701+#ifdef CONFIG_PAX_ASLR
9702+#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
9703+
9704+#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
9705+#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
9706+#endif
9707+
9708 /* This yields a mask that user programs can use to figure out what
9709 instruction set this CPU supports. */
9710
9711diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
9712index c4a93d6..4d2a9b4 100644
9713--- a/arch/s390/include/asm/exec.h
9714+++ b/arch/s390/include/asm/exec.h
9715@@ -7,6 +7,6 @@
9716 #ifndef __ASM_EXEC_H
9717 #define __ASM_EXEC_H
9718
9719-extern unsigned long arch_align_stack(unsigned long sp);
9720+#define arch_align_stack(x) ((x) & ~0xfUL)
9721
9722 #endif /* __ASM_EXEC_H */
9723diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
9724index 9dd4cc4..36f4b84 100644
9725--- a/arch/s390/include/asm/uaccess.h
9726+++ b/arch/s390/include/asm/uaccess.h
9727@@ -59,6 +59,7 @@ static inline int __range_ok(unsigned long addr, unsigned long size)
9728 __range_ok((unsigned long)(addr), (size)); \
9729 })
9730
9731+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
9732 #define access_ok(type, addr, size) __access_ok(addr, size)
9733
9734 /*
9735@@ -278,6 +279,10 @@ static inline unsigned long __must_check
9736 copy_to_user(void __user *to, const void *from, unsigned long n)
9737 {
9738 might_fault();
9739+
9740+ if ((long)n < 0)
9741+ return n;
9742+
9743 return __copy_to_user(to, from, n);
9744 }
9745
9746@@ -307,10 +312,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
9747 static inline unsigned long __must_check
9748 copy_from_user(void *to, const void __user *from, unsigned long n)
9749 {
9750- unsigned int sz = __compiletime_object_size(to);
9751+ size_t sz = __compiletime_object_size(to);
9752
9753 might_fault();
9754- if (unlikely(sz != -1 && sz < n)) {
9755+
9756+ if ((long)n < 0)
9757+ return n;
9758+
9759+ if (unlikely(sz != (size_t)-1 && sz < n)) {
9760 copy_from_user_overflow();
9761 return n;
9762 }
9763diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
9764index 0c1a679..e1df357 100644
9765--- a/arch/s390/kernel/module.c
9766+++ b/arch/s390/kernel/module.c
9767@@ -159,11 +159,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
9768
9769 /* Increase core size by size of got & plt and set start
9770 offsets for got and plt. */
9771- me->core_size = ALIGN(me->core_size, 4);
9772- me->arch.got_offset = me->core_size;
9773- me->core_size += me->arch.got_size;
9774- me->arch.plt_offset = me->core_size;
9775- me->core_size += me->arch.plt_size;
9776+ me->core_size_rw = ALIGN(me->core_size_rw, 4);
9777+ me->arch.got_offset = me->core_size_rw;
9778+ me->core_size_rw += me->arch.got_size;
9779+ me->arch.plt_offset = me->core_size_rx;
9780+ me->core_size_rx += me->arch.plt_size;
9781 return 0;
9782 }
9783
9784@@ -279,7 +279,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9785 if (info->got_initialized == 0) {
9786 Elf_Addr *gotent;
9787
9788- gotent = me->module_core + me->arch.got_offset +
9789+ gotent = me->module_core_rw + me->arch.got_offset +
9790 info->got_offset;
9791 *gotent = val;
9792 info->got_initialized = 1;
9793@@ -302,7 +302,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9794 rc = apply_rela_bits(loc, val, 0, 64, 0);
9795 else if (r_type == R_390_GOTENT ||
9796 r_type == R_390_GOTPLTENT) {
9797- val += (Elf_Addr) me->module_core - loc;
9798+ val += (Elf_Addr) me->module_core_rw - loc;
9799 rc = apply_rela_bits(loc, val, 1, 32, 1);
9800 }
9801 break;
9802@@ -315,7 +315,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9803 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
9804 if (info->plt_initialized == 0) {
9805 unsigned int *ip;
9806- ip = me->module_core + me->arch.plt_offset +
9807+ ip = me->module_core_rx + me->arch.plt_offset +
9808 info->plt_offset;
9809 ip[0] = 0x0d10e310; /* basr 1,0; lg 1,10(1); br 1 */
9810 ip[1] = 0x100a0004;
9811@@ -334,7 +334,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9812 val - loc + 0xffffUL < 0x1ffffeUL) ||
9813 (r_type == R_390_PLT32DBL &&
9814 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
9815- val = (Elf_Addr) me->module_core +
9816+ val = (Elf_Addr) me->module_core_rx +
9817 me->arch.plt_offset +
9818 info->plt_offset;
9819 val += rela->r_addend - loc;
9820@@ -356,7 +356,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9821 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
9822 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
9823 val = val + rela->r_addend -
9824- ((Elf_Addr) me->module_core + me->arch.got_offset);
9825+ ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
9826 if (r_type == R_390_GOTOFF16)
9827 rc = apply_rela_bits(loc, val, 0, 16, 0);
9828 else if (r_type == R_390_GOTOFF32)
9829@@ -366,7 +366,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9830 break;
9831 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
9832 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
9833- val = (Elf_Addr) me->module_core + me->arch.got_offset +
9834+ val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
9835 rela->r_addend - loc;
9836 if (r_type == R_390_GOTPC)
9837 rc = apply_rela_bits(loc, val, 1, 32, 0);
9838diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
9839index 8f587d8..0642516b 100644
9840--- a/arch/s390/kernel/process.c
9841+++ b/arch/s390/kernel/process.c
9842@@ -200,27 +200,3 @@ unsigned long get_wchan(struct task_struct *p)
9843 }
9844 return 0;
9845 }
9846-
9847-unsigned long arch_align_stack(unsigned long sp)
9848-{
9849- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
9850- sp -= get_random_int() & ~PAGE_MASK;
9851- return sp & ~0xf;
9852-}
9853-
9854-static inline unsigned long brk_rnd(void)
9855-{
9856- /* 8MB for 32bit, 1GB for 64bit */
9857- if (is_32bit_task())
9858- return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
9859- else
9860- return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
9861-}
9862-
9863-unsigned long arch_randomize_brk(struct mm_struct *mm)
9864-{
9865- unsigned long ret;
9866-
9867- ret = PAGE_ALIGN(mm->brk + brk_rnd());
9868- return (ret > mm->brk) ? ret : mm->brk;
9869-}
9870diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
9871index 6e552af..3e608a1 100644
9872--- a/arch/s390/mm/mmap.c
9873+++ b/arch/s390/mm/mmap.c
9874@@ -239,6 +239,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9875 {
9876 unsigned long random_factor = 0UL;
9877
9878+#ifdef CONFIG_PAX_RANDMMAP
9879+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9880+#endif
9881+
9882 if (current->flags & PF_RANDOMIZE)
9883 random_factor = arch_mmap_rnd();
9884
9885@@ -248,9 +252,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9886 */
9887 if (mmap_is_legacy()) {
9888 mm->mmap_base = mmap_base_legacy(random_factor);
9889+
9890+#ifdef CONFIG_PAX_RANDMMAP
9891+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9892+ mm->mmap_base += mm->delta_mmap;
9893+#endif
9894+
9895 mm->get_unmapped_area = s390_get_unmapped_area;
9896 } else {
9897 mm->mmap_base = mmap_base(random_factor);
9898+
9899+#ifdef CONFIG_PAX_RANDMMAP
9900+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9901+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9902+#endif
9903+
9904 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
9905 }
9906 }
9907diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
9908index ae3d59f..f65f075 100644
9909--- a/arch/score/include/asm/cache.h
9910+++ b/arch/score/include/asm/cache.h
9911@@ -1,7 +1,9 @@
9912 #ifndef _ASM_SCORE_CACHE_H
9913 #define _ASM_SCORE_CACHE_H
9914
9915+#include <linux/const.h>
9916+
9917 #define L1_CACHE_SHIFT 4
9918-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9919+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9920
9921 #endif /* _ASM_SCORE_CACHE_H */
9922diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
9923index f9f3cd5..58ff438 100644
9924--- a/arch/score/include/asm/exec.h
9925+++ b/arch/score/include/asm/exec.h
9926@@ -1,6 +1,6 @@
9927 #ifndef _ASM_SCORE_EXEC_H
9928 #define _ASM_SCORE_EXEC_H
9929
9930-extern unsigned long arch_align_stack(unsigned long sp);
9931+#define arch_align_stack(x) (x)
9932
9933 #endif /* _ASM_SCORE_EXEC_H */
9934diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
9935index a1519ad3..e8ac1ff 100644
9936--- a/arch/score/kernel/process.c
9937+++ b/arch/score/kernel/process.c
9938@@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
9939
9940 return task_pt_regs(task)->cp0_epc;
9941 }
9942-
9943-unsigned long arch_align_stack(unsigned long sp)
9944-{
9945- return sp;
9946-}
9947diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
9948index ef9e555..331bd29 100644
9949--- a/arch/sh/include/asm/cache.h
9950+++ b/arch/sh/include/asm/cache.h
9951@@ -9,10 +9,11 @@
9952 #define __ASM_SH_CACHE_H
9953 #ifdef __KERNEL__
9954
9955+#include <linux/const.h>
9956 #include <linux/init.h>
9957 #include <cpu/cache.h>
9958
9959-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9960+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9961
9962 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
9963
9964diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
9965index 6777177..cb5e44f 100644
9966--- a/arch/sh/mm/mmap.c
9967+++ b/arch/sh/mm/mmap.c
9968@@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
9969 struct mm_struct *mm = current->mm;
9970 struct vm_area_struct *vma;
9971 int do_colour_align;
9972+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9973 struct vm_unmapped_area_info info;
9974
9975 if (flags & MAP_FIXED) {
9976@@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
9977 if (filp || (flags & MAP_SHARED))
9978 do_colour_align = 1;
9979
9980+#ifdef CONFIG_PAX_RANDMMAP
9981+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9982+#endif
9983+
9984 if (addr) {
9985 if (do_colour_align)
9986 addr = COLOUR_ALIGN(addr, pgoff);
9987@@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
9988 addr = PAGE_ALIGN(addr);
9989
9990 vma = find_vma(mm, addr);
9991- if (TASK_SIZE - len >= addr &&
9992- (!vma || addr + len <= vma->vm_start))
9993+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9994 return addr;
9995 }
9996
9997 info.flags = 0;
9998 info.length = len;
9999- info.low_limit = TASK_UNMAPPED_BASE;
10000+ info.low_limit = mm->mmap_base;
10001 info.high_limit = TASK_SIZE;
10002 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
10003 info.align_offset = pgoff << PAGE_SHIFT;
10004@@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10005 struct mm_struct *mm = current->mm;
10006 unsigned long addr = addr0;
10007 int do_colour_align;
10008+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
10009 struct vm_unmapped_area_info info;
10010
10011 if (flags & MAP_FIXED) {
10012@@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10013 if (filp || (flags & MAP_SHARED))
10014 do_colour_align = 1;
10015
10016+#ifdef CONFIG_PAX_RANDMMAP
10017+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10018+#endif
10019+
10020 /* requesting a specific address */
10021 if (addr) {
10022 if (do_colour_align)
10023@@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10024 addr = PAGE_ALIGN(addr);
10025
10026 vma = find_vma(mm, addr);
10027- if (TASK_SIZE - len >= addr &&
10028- (!vma || addr + len <= vma->vm_start))
10029+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10030 return addr;
10031 }
10032
10033@@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10034 VM_BUG_ON(addr != -ENOMEM);
10035 info.flags = 0;
10036 info.low_limit = TASK_UNMAPPED_BASE;
10037+
10038+#ifdef CONFIG_PAX_RANDMMAP
10039+ if (mm->pax_flags & MF_PAX_RANDMMAP)
10040+ info.low_limit += mm->delta_mmap;
10041+#endif
10042+
10043 info.high_limit = TASK_SIZE;
10044 addr = vm_unmapped_area(&info);
10045 }
10046diff --git a/arch/sparc/crypto/aes_glue.c b/arch/sparc/crypto/aes_glue.c
10047index 2e48eb8..c90930d 100644
10048--- a/arch/sparc/crypto/aes_glue.c
10049+++ b/arch/sparc/crypto/aes_glue.c
10050@@ -433,6 +433,7 @@ static struct crypto_alg algs[] = { {
10051 .blkcipher = {
10052 .min_keysize = AES_MIN_KEY_SIZE,
10053 .max_keysize = AES_MAX_KEY_SIZE,
10054+ .ivsize = AES_BLOCK_SIZE,
10055 .setkey = aes_set_key,
10056 .encrypt = cbc_encrypt,
10057 .decrypt = cbc_decrypt,
10058@@ -452,6 +453,7 @@ static struct crypto_alg algs[] = { {
10059 .blkcipher = {
10060 .min_keysize = AES_MIN_KEY_SIZE,
10061 .max_keysize = AES_MAX_KEY_SIZE,
10062+ .ivsize = AES_BLOCK_SIZE,
10063 .setkey = aes_set_key,
10064 .encrypt = ctr_crypt,
10065 .decrypt = ctr_crypt,
10066diff --git a/arch/sparc/crypto/camellia_glue.c b/arch/sparc/crypto/camellia_glue.c
10067index 6bf2479..561a84d 100644
10068--- a/arch/sparc/crypto/camellia_glue.c
10069+++ b/arch/sparc/crypto/camellia_glue.c
10070@@ -274,6 +274,7 @@ static struct crypto_alg algs[] = { {
10071 .blkcipher = {
10072 .min_keysize = CAMELLIA_MIN_KEY_SIZE,
10073 .max_keysize = CAMELLIA_MAX_KEY_SIZE,
10074+ .ivsize = CAMELLIA_BLOCK_SIZE,
10075 .setkey = camellia_set_key,
10076 .encrypt = cbc_encrypt,
10077 .decrypt = cbc_decrypt,
10078diff --git a/arch/sparc/crypto/des_glue.c b/arch/sparc/crypto/des_glue.c
10079index dd6a34f..61af794 100644
10080--- a/arch/sparc/crypto/des_glue.c
10081+++ b/arch/sparc/crypto/des_glue.c
10082@@ -429,6 +429,7 @@ static struct crypto_alg algs[] = { {
10083 .blkcipher = {
10084 .min_keysize = DES_KEY_SIZE,
10085 .max_keysize = DES_KEY_SIZE,
10086+ .ivsize = DES_BLOCK_SIZE,
10087 .setkey = des_set_key,
10088 .encrypt = cbc_encrypt,
10089 .decrypt = cbc_decrypt,
10090@@ -485,6 +486,7 @@ static struct crypto_alg algs[] = { {
10091 .blkcipher = {
10092 .min_keysize = DES3_EDE_KEY_SIZE,
10093 .max_keysize = DES3_EDE_KEY_SIZE,
10094+ .ivsize = DES3_EDE_BLOCK_SIZE,
10095 .setkey = des3_ede_set_key,
10096 .encrypt = cbc3_encrypt,
10097 .decrypt = cbc3_decrypt,
10098diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
10099index 4082749..fd97781 100644
10100--- a/arch/sparc/include/asm/atomic_64.h
10101+++ b/arch/sparc/include/asm/atomic_64.h
10102@@ -15,18 +15,38 @@
10103 #define ATOMIC64_INIT(i) { (i) }
10104
10105 #define atomic_read(v) ACCESS_ONCE((v)->counter)
10106+static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
10107+{
10108+ return ACCESS_ONCE(v->counter);
10109+}
10110 #define atomic64_read(v) ACCESS_ONCE((v)->counter)
10111+static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
10112+{
10113+ return ACCESS_ONCE(v->counter);
10114+}
10115
10116 #define atomic_set(v, i) (((v)->counter) = i)
10117+static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
10118+{
10119+ v->counter = i;
10120+}
10121 #define atomic64_set(v, i) (((v)->counter) = i)
10122+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
10123+{
10124+ v->counter = i;
10125+}
10126
10127-#define ATOMIC_OP(op) \
10128-void atomic_##op(int, atomic_t *); \
10129-void atomic64_##op(long, atomic64_t *);
10130+#define __ATOMIC_OP(op, suffix) \
10131+void atomic_##op##suffix(int, atomic##suffix##_t *); \
10132+void atomic64_##op##suffix(long, atomic64##suffix##_t *);
10133
10134-#define ATOMIC_OP_RETURN(op) \
10135-int atomic_##op##_return(int, atomic_t *); \
10136-long atomic64_##op##_return(long, atomic64_t *);
10137+#define ATOMIC_OP(op) __ATOMIC_OP(op, ) __ATOMIC_OP(op, _unchecked)
10138+
10139+#define __ATOMIC_OP_RETURN(op, suffix) \
10140+int atomic_##op##_return##suffix(int, atomic##suffix##_t *); \
10141+long atomic64_##op##_return##suffix(long, atomic64##suffix##_t *);
10142+
10143+#define ATOMIC_OP_RETURN(op) __ATOMIC_OP_RETURN(op, ) __ATOMIC_OP_RETURN(op, _unchecked)
10144
10145 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
10146
10147@@ -35,13 +55,23 @@ ATOMIC_OPS(sub)
10148
10149 #undef ATOMIC_OPS
10150 #undef ATOMIC_OP_RETURN
10151+#undef __ATOMIC_OP_RETURN
10152 #undef ATOMIC_OP
10153+#undef __ATOMIC_OP
10154
10155 #define atomic_dec_return(v) atomic_sub_return(1, v)
10156 #define atomic64_dec_return(v) atomic64_sub_return(1, v)
10157
10158 #define atomic_inc_return(v) atomic_add_return(1, v)
10159+static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
10160+{
10161+ return atomic_add_return_unchecked(1, v);
10162+}
10163 #define atomic64_inc_return(v) atomic64_add_return(1, v)
10164+static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
10165+{
10166+ return atomic64_add_return_unchecked(1, v);
10167+}
10168
10169 /*
10170 * atomic_inc_and_test - increment and test
10171@@ -52,6 +82,10 @@ ATOMIC_OPS(sub)
10172 * other cases.
10173 */
10174 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
10175+static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
10176+{
10177+ return atomic_inc_return_unchecked(v) == 0;
10178+}
10179 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
10180
10181 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
10182@@ -61,25 +95,60 @@ ATOMIC_OPS(sub)
10183 #define atomic64_dec_and_test(v) (atomic64_sub_return(1, v) == 0)
10184
10185 #define atomic_inc(v) atomic_add(1, v)
10186+static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
10187+{
10188+ atomic_add_unchecked(1, v);
10189+}
10190 #define atomic64_inc(v) atomic64_add(1, v)
10191+static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
10192+{
10193+ atomic64_add_unchecked(1, v);
10194+}
10195
10196 #define atomic_dec(v) atomic_sub(1, v)
10197+static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
10198+{
10199+ atomic_sub_unchecked(1, v);
10200+}
10201 #define atomic64_dec(v) atomic64_sub(1, v)
10202+static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
10203+{
10204+ atomic64_sub_unchecked(1, v);
10205+}
10206
10207 #define atomic_add_negative(i, v) (atomic_add_return(i, v) < 0)
10208 #define atomic64_add_negative(i, v) (atomic64_add_return(i, v) < 0)
10209
10210 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
10211+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
10212+{
10213+ return cmpxchg(&v->counter, old, new);
10214+}
10215 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
10216+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
10217+{
10218+ return xchg(&v->counter, new);
10219+}
10220
10221 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
10222 {
10223- int c, old;
10224+ int c, old, new;
10225 c = atomic_read(v);
10226 for (;;) {
10227- if (unlikely(c == (u)))
10228+ if (unlikely(c == u))
10229 break;
10230- old = atomic_cmpxchg((v), c, c + (a));
10231+
10232+ asm volatile("addcc %2, %0, %0\n"
10233+
10234+#ifdef CONFIG_PAX_REFCOUNT
10235+ "tvs %%icc, 6\n"
10236+#endif
10237+
10238+ : "=r" (new)
10239+ : "0" (c), "ir" (a)
10240+ : "cc");
10241+
10242+ old = atomic_cmpxchg(v, c, new);
10243 if (likely(old == c))
10244 break;
10245 c = old;
10246@@ -90,20 +159,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
10247 #define atomic64_cmpxchg(v, o, n) \
10248 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
10249 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
10250+static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
10251+{
10252+ return xchg(&v->counter, new);
10253+}
10254
10255 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10256 {
10257- long c, old;
10258+ long c, old, new;
10259 c = atomic64_read(v);
10260 for (;;) {
10261- if (unlikely(c == (u)))
10262+ if (unlikely(c == u))
10263 break;
10264- old = atomic64_cmpxchg((v), c, c + (a));
10265+
10266+ asm volatile("addcc %2, %0, %0\n"
10267+
10268+#ifdef CONFIG_PAX_REFCOUNT
10269+ "tvs %%xcc, 6\n"
10270+#endif
10271+
10272+ : "=r" (new)
10273+ : "0" (c), "ir" (a)
10274+ : "cc");
10275+
10276+ old = atomic64_cmpxchg(v, c, new);
10277 if (likely(old == c))
10278 break;
10279 c = old;
10280 }
10281- return c != (u);
10282+ return c != u;
10283 }
10284
10285 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10286diff --git a/arch/sparc/include/asm/barrier_64.h b/arch/sparc/include/asm/barrier_64.h
10287index 809941e..b443309 100644
10288--- a/arch/sparc/include/asm/barrier_64.h
10289+++ b/arch/sparc/include/asm/barrier_64.h
10290@@ -60,7 +60,7 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
10291 do { \
10292 compiletime_assert_atomic_type(*p); \
10293 barrier(); \
10294- ACCESS_ONCE(*p) = (v); \
10295+ ACCESS_ONCE_RW(*p) = (v); \
10296 } while (0)
10297
10298 #define smp_load_acquire(p) \
10299diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
10300index 5bb6991..5c2132e 100644
10301--- a/arch/sparc/include/asm/cache.h
10302+++ b/arch/sparc/include/asm/cache.h
10303@@ -7,10 +7,12 @@
10304 #ifndef _SPARC_CACHE_H
10305 #define _SPARC_CACHE_H
10306
10307+#include <linux/const.h>
10308+
10309 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
10310
10311 #define L1_CACHE_SHIFT 5
10312-#define L1_CACHE_BYTES 32
10313+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10314
10315 #ifdef CONFIG_SPARC32
10316 #define SMP_CACHE_BYTES_SHIFT 5
10317diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
10318index a24e41f..47677ff 100644
10319--- a/arch/sparc/include/asm/elf_32.h
10320+++ b/arch/sparc/include/asm/elf_32.h
10321@@ -114,6 +114,13 @@ typedef struct {
10322
10323 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
10324
10325+#ifdef CONFIG_PAX_ASLR
10326+#define PAX_ELF_ET_DYN_BASE 0x10000UL
10327+
10328+#define PAX_DELTA_MMAP_LEN 16
10329+#define PAX_DELTA_STACK_LEN 16
10330+#endif
10331+
10332 /* This yields a mask that user programs can use to figure out what
10333 instruction set this cpu supports. This can NOT be done in userspace
10334 on Sparc. */
10335diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
10336index 370ca1e..d4f4a98 100644
10337--- a/arch/sparc/include/asm/elf_64.h
10338+++ b/arch/sparc/include/asm/elf_64.h
10339@@ -189,6 +189,13 @@ typedef struct {
10340 #define ELF_ET_DYN_BASE 0x0000010000000000UL
10341 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
10342
10343+#ifdef CONFIG_PAX_ASLR
10344+#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
10345+
10346+#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
10347+#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
10348+#endif
10349+
10350 extern unsigned long sparc64_elf_hwcap;
10351 #define ELF_HWCAP sparc64_elf_hwcap
10352
10353diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
10354index a3890da..f6a408e 100644
10355--- a/arch/sparc/include/asm/pgalloc_32.h
10356+++ b/arch/sparc/include/asm/pgalloc_32.h
10357@@ -35,6 +35,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
10358 }
10359
10360 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
10361+#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
10362
10363 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
10364 unsigned long address)
10365diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
10366index 5e31871..13469c6 100644
10367--- a/arch/sparc/include/asm/pgalloc_64.h
10368+++ b/arch/sparc/include/asm/pgalloc_64.h
10369@@ -21,6 +21,7 @@ static inline void __pgd_populate(pgd_t *pgd, pud_t *pud)
10370 }
10371
10372 #define pgd_populate(MM, PGD, PUD) __pgd_populate(PGD, PUD)
10373+#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
10374
10375 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
10376 {
10377@@ -38,6 +39,7 @@ static inline void __pud_populate(pud_t *pud, pmd_t *pmd)
10378 }
10379
10380 #define pud_populate(MM, PUD, PMD) __pud_populate(PUD, PMD)
10381+#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
10382
10383 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
10384 {
10385diff --git a/arch/sparc/include/asm/pgtable.h b/arch/sparc/include/asm/pgtable.h
10386index 59ba6f6..4518128 100644
10387--- a/arch/sparc/include/asm/pgtable.h
10388+++ b/arch/sparc/include/asm/pgtable.h
10389@@ -5,4 +5,8 @@
10390 #else
10391 #include <asm/pgtable_32.h>
10392 #endif
10393+
10394+#define ktla_ktva(addr) (addr)
10395+#define ktva_ktla(addr) (addr)
10396+
10397 #endif
10398diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
10399index f06b36a..bca3189 100644
10400--- a/arch/sparc/include/asm/pgtable_32.h
10401+++ b/arch/sparc/include/asm/pgtable_32.h
10402@@ -51,6 +51,9 @@ unsigned long __init bootmem_init(unsigned long *pages_avail);
10403 #define PAGE_SHARED SRMMU_PAGE_SHARED
10404 #define PAGE_COPY SRMMU_PAGE_COPY
10405 #define PAGE_READONLY SRMMU_PAGE_RDONLY
10406+#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
10407+#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
10408+#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
10409 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
10410
10411 /* Top-level page directory - dummy used by init-mm.
10412@@ -63,18 +66,18 @@ extern unsigned long ptr_in_current_pgd;
10413
10414 /* xwr */
10415 #define __P000 PAGE_NONE
10416-#define __P001 PAGE_READONLY
10417-#define __P010 PAGE_COPY
10418-#define __P011 PAGE_COPY
10419+#define __P001 PAGE_READONLY_NOEXEC
10420+#define __P010 PAGE_COPY_NOEXEC
10421+#define __P011 PAGE_COPY_NOEXEC
10422 #define __P100 PAGE_READONLY
10423 #define __P101 PAGE_READONLY
10424 #define __P110 PAGE_COPY
10425 #define __P111 PAGE_COPY
10426
10427 #define __S000 PAGE_NONE
10428-#define __S001 PAGE_READONLY
10429-#define __S010 PAGE_SHARED
10430-#define __S011 PAGE_SHARED
10431+#define __S001 PAGE_READONLY_NOEXEC
10432+#define __S010 PAGE_SHARED_NOEXEC
10433+#define __S011 PAGE_SHARED_NOEXEC
10434 #define __S100 PAGE_READONLY
10435 #define __S101 PAGE_READONLY
10436 #define __S110 PAGE_SHARED
10437diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
10438index ae51a11..eadfd03 100644
10439--- a/arch/sparc/include/asm/pgtsrmmu.h
10440+++ b/arch/sparc/include/asm/pgtsrmmu.h
10441@@ -111,6 +111,11 @@
10442 SRMMU_EXEC | SRMMU_REF)
10443 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
10444 SRMMU_EXEC | SRMMU_REF)
10445+
10446+#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
10447+#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
10448+#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
10449+
10450 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
10451 SRMMU_DIRTY | SRMMU_REF)
10452
10453diff --git a/arch/sparc/include/asm/setup.h b/arch/sparc/include/asm/setup.h
10454index 29d64b1..4272fe8 100644
10455--- a/arch/sparc/include/asm/setup.h
10456+++ b/arch/sparc/include/asm/setup.h
10457@@ -55,8 +55,8 @@ int handle_ldf_stq(u32 insn, struct pt_regs *regs);
10458 void handle_ld_nf(u32 insn, struct pt_regs *regs);
10459
10460 /* init_64.c */
10461-extern atomic_t dcpage_flushes;
10462-extern atomic_t dcpage_flushes_xcall;
10463+extern atomic_unchecked_t dcpage_flushes;
10464+extern atomic_unchecked_t dcpage_flushes_xcall;
10465
10466 extern int sysctl_tsb_ratio;
10467 #endif
10468diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
10469index 9689176..63c18ea 100644
10470--- a/arch/sparc/include/asm/spinlock_64.h
10471+++ b/arch/sparc/include/asm/spinlock_64.h
10472@@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
10473
10474 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
10475
10476-static void inline arch_read_lock(arch_rwlock_t *lock)
10477+static inline void arch_read_lock(arch_rwlock_t *lock)
10478 {
10479 unsigned long tmp1, tmp2;
10480
10481 __asm__ __volatile__ (
10482 "1: ldsw [%2], %0\n"
10483 " brlz,pn %0, 2f\n"
10484-"4: add %0, 1, %1\n"
10485+"4: addcc %0, 1, %1\n"
10486+
10487+#ifdef CONFIG_PAX_REFCOUNT
10488+" tvs %%icc, 6\n"
10489+#endif
10490+
10491 " cas [%2], %0, %1\n"
10492 " cmp %0, %1\n"
10493 " bne,pn %%icc, 1b\n"
10494@@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
10495 " .previous"
10496 : "=&r" (tmp1), "=&r" (tmp2)
10497 : "r" (lock)
10498- : "memory");
10499+ : "memory", "cc");
10500 }
10501
10502-static int inline arch_read_trylock(arch_rwlock_t *lock)
10503+static inline int arch_read_trylock(arch_rwlock_t *lock)
10504 {
10505 int tmp1, tmp2;
10506
10507@@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
10508 "1: ldsw [%2], %0\n"
10509 " brlz,a,pn %0, 2f\n"
10510 " mov 0, %0\n"
10511-" add %0, 1, %1\n"
10512+" addcc %0, 1, %1\n"
10513+
10514+#ifdef CONFIG_PAX_REFCOUNT
10515+" tvs %%icc, 6\n"
10516+#endif
10517+
10518 " cas [%2], %0, %1\n"
10519 " cmp %0, %1\n"
10520 " bne,pn %%icc, 1b\n"
10521@@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
10522 return tmp1;
10523 }
10524
10525-static void inline arch_read_unlock(arch_rwlock_t *lock)
10526+static inline void arch_read_unlock(arch_rwlock_t *lock)
10527 {
10528 unsigned long tmp1, tmp2;
10529
10530 __asm__ __volatile__(
10531 "1: lduw [%2], %0\n"
10532-" sub %0, 1, %1\n"
10533+" subcc %0, 1, %1\n"
10534+
10535+#ifdef CONFIG_PAX_REFCOUNT
10536+" tvs %%icc, 6\n"
10537+#endif
10538+
10539 " cas [%2], %0, %1\n"
10540 " cmp %0, %1\n"
10541 " bne,pn %%xcc, 1b\n"
10542@@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
10543 : "memory");
10544 }
10545
10546-static void inline arch_write_lock(arch_rwlock_t *lock)
10547+static inline void arch_write_lock(arch_rwlock_t *lock)
10548 {
10549 unsigned long mask, tmp1, tmp2;
10550
10551@@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
10552 : "memory");
10553 }
10554
10555-static void inline arch_write_unlock(arch_rwlock_t *lock)
10556+static inline void arch_write_unlock(arch_rwlock_t *lock)
10557 {
10558 __asm__ __volatile__(
10559 " stw %%g0, [%0]"
10560@@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
10561 : "memory");
10562 }
10563
10564-static int inline arch_write_trylock(arch_rwlock_t *lock)
10565+static inline int arch_write_trylock(arch_rwlock_t *lock)
10566 {
10567 unsigned long mask, tmp1, tmp2, result;
10568
10569diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
10570index 229475f..2fca9163 100644
10571--- a/arch/sparc/include/asm/thread_info_32.h
10572+++ b/arch/sparc/include/asm/thread_info_32.h
10573@@ -48,6 +48,7 @@ struct thread_info {
10574 struct reg_window32 reg_window[NSWINS]; /* align for ldd! */
10575 unsigned long rwbuf_stkptrs[NSWINS];
10576 unsigned long w_saved;
10577+ unsigned long lowest_stack;
10578 };
10579
10580 /*
10581diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
10582index bde5982..9cbb56d 100644
10583--- a/arch/sparc/include/asm/thread_info_64.h
10584+++ b/arch/sparc/include/asm/thread_info_64.h
10585@@ -59,6 +59,8 @@ struct thread_info {
10586 struct pt_regs *kern_una_regs;
10587 unsigned int kern_una_insn;
10588
10589+ unsigned long lowest_stack;
10590+
10591 unsigned long fpregs[(7 * 256) / sizeof(unsigned long)]
10592 __attribute__ ((aligned(64)));
10593 };
10594@@ -180,12 +182,13 @@ register struct thread_info *current_thread_info_reg asm("g6");
10595 #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
10596 /* flag bit 4 is available */
10597 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
10598-/* flag bit 6 is available */
10599+#define TIF_GRSEC_SETXID 6 /* update credentials on syscall entry/exit */
10600 #define TIF_32BIT 7 /* 32-bit binary */
10601 #define TIF_NOHZ 8 /* in adaptive nohz mode */
10602 #define TIF_SECCOMP 9 /* secure computing */
10603 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
10604 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
10605+
10606 /* NOTE: Thread flags >= 12 should be ones we have no interest
10607 * in using in assembly, else we can't use the mask as
10608 * an immediate value in instructions such as andcc.
10609@@ -205,12 +208,17 @@ register struct thread_info *current_thread_info_reg asm("g6");
10610 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
10611 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
10612 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
10613+#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
10614
10615 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
10616 _TIF_DO_NOTIFY_RESUME_MASK | \
10617 _TIF_NEED_RESCHED)
10618 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
10619
10620+#define _TIF_WORK_SYSCALL \
10621+ (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
10622+ _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
10623+
10624 #define is_32bit_task() (test_thread_flag(TIF_32BIT))
10625
10626 /*
10627diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
10628index bd56c28..4b63d83 100644
10629--- a/arch/sparc/include/asm/uaccess.h
10630+++ b/arch/sparc/include/asm/uaccess.h
10631@@ -1,5 +1,6 @@
10632 #ifndef ___ASM_SPARC_UACCESS_H
10633 #define ___ASM_SPARC_UACCESS_H
10634+
10635 #if defined(__sparc__) && defined(__arch64__)
10636 #include <asm/uaccess_64.h>
10637 #else
10638diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
10639index 64ee103..388aef0 100644
10640--- a/arch/sparc/include/asm/uaccess_32.h
10641+++ b/arch/sparc/include/asm/uaccess_32.h
10642@@ -47,6 +47,7 @@
10643 #define __user_ok(addr, size) ({ (void)(size); (addr) < STACK_TOP; })
10644 #define __kernel_ok (segment_eq(get_fs(), KERNEL_DS))
10645 #define __access_ok(addr, size) (__user_ok((addr) & get_fs().seg, (size)))
10646+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
10647 #define access_ok(type, addr, size) \
10648 ({ (void)(type); __access_ok((unsigned long)(addr), size); })
10649
10650@@ -313,27 +314,46 @@ unsigned long __copy_user(void __user *to, const void __user *from, unsigned lon
10651
10652 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
10653 {
10654- if (n && __access_ok((unsigned long) to, n))
10655+ if ((long)n < 0)
10656+ return n;
10657+
10658+ if (n && __access_ok((unsigned long) to, n)) {
10659+ if (!__builtin_constant_p(n))
10660+ check_object_size(from, n, true);
10661 return __copy_user(to, (__force void __user *) from, n);
10662- else
10663+ } else
10664 return n;
10665 }
10666
10667 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
10668 {
10669+ if ((long)n < 0)
10670+ return n;
10671+
10672+ if (!__builtin_constant_p(n))
10673+ check_object_size(from, n, true);
10674+
10675 return __copy_user(to, (__force void __user *) from, n);
10676 }
10677
10678 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
10679 {
10680- if (n && __access_ok((unsigned long) from, n))
10681+ if ((long)n < 0)
10682+ return n;
10683+
10684+ if (n && __access_ok((unsigned long) from, n)) {
10685+ if (!__builtin_constant_p(n))
10686+ check_object_size(to, n, false);
10687 return __copy_user((__force void __user *) to, from, n);
10688- else
10689+ } else
10690 return n;
10691 }
10692
10693 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
10694 {
10695+ if ((long)n < 0)
10696+ return n;
10697+
10698 return __copy_user((__force void __user *) to, from, n);
10699 }
10700
10701diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
10702index ea6e9a2..5703598 100644
10703--- a/arch/sparc/include/asm/uaccess_64.h
10704+++ b/arch/sparc/include/asm/uaccess_64.h
10705@@ -10,6 +10,7 @@
10706 #include <linux/compiler.h>
10707 #include <linux/string.h>
10708 #include <linux/thread_info.h>
10709+#include <linux/kernel.h>
10710 #include <asm/asi.h>
10711 #include <asm/spitfire.h>
10712 #include <asm-generic/uaccess-unaligned.h>
10713@@ -76,6 +77,11 @@ static inline int __access_ok(const void __user * addr, unsigned long size)
10714 return 1;
10715 }
10716
10717+static inline int access_ok_noprefault(int type, const void __user * addr, unsigned long size)
10718+{
10719+ return 1;
10720+}
10721+
10722 static inline int access_ok(int type, const void __user * addr, unsigned long size)
10723 {
10724 return 1;
10725@@ -250,8 +256,15 @@ unsigned long copy_from_user_fixup(void *to, const void __user *from,
10726 static inline unsigned long __must_check
10727 copy_from_user(void *to, const void __user *from, unsigned long size)
10728 {
10729- unsigned long ret = ___copy_from_user(to, from, size);
10730+ unsigned long ret;
10731
10732+ if ((long)size < 0 || size > INT_MAX)
10733+ return size;
10734+
10735+ if (!__builtin_constant_p(size))
10736+ check_object_size(to, size, false);
10737+
10738+ ret = ___copy_from_user(to, from, size);
10739 if (unlikely(ret))
10740 ret = copy_from_user_fixup(to, from, size);
10741
10742@@ -267,8 +280,15 @@ unsigned long copy_to_user_fixup(void __user *to, const void *from,
10743 static inline unsigned long __must_check
10744 copy_to_user(void __user *to, const void *from, unsigned long size)
10745 {
10746- unsigned long ret = ___copy_to_user(to, from, size);
10747+ unsigned long ret;
10748
10749+ if ((long)size < 0 || size > INT_MAX)
10750+ return size;
10751+
10752+ if (!__builtin_constant_p(size))
10753+ check_object_size(from, size, true);
10754+
10755+ ret = ___copy_to_user(to, from, size);
10756 if (unlikely(ret))
10757 ret = copy_to_user_fixup(to, from, size);
10758 return ret;
10759diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
10760index 7cf9c6e..6206648 100644
10761--- a/arch/sparc/kernel/Makefile
10762+++ b/arch/sparc/kernel/Makefile
10763@@ -4,7 +4,7 @@
10764 #
10765
10766 asflags-y := -ansi
10767-ccflags-y := -Werror
10768+#ccflags-y := -Werror
10769
10770 extra-y := head_$(BITS).o
10771
10772diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
10773index 50e7b62..79fae35 100644
10774--- a/arch/sparc/kernel/process_32.c
10775+++ b/arch/sparc/kernel/process_32.c
10776@@ -123,14 +123,14 @@ void show_regs(struct pt_regs *r)
10777
10778 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
10779 r->psr, r->pc, r->npc, r->y, print_tainted());
10780- printk("PC: <%pS>\n", (void *) r->pc);
10781+ printk("PC: <%pA>\n", (void *) r->pc);
10782 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10783 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
10784 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
10785 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10786 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
10787 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
10788- printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
10789+ printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
10790
10791 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10792 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
10793@@ -167,7 +167,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10794 rw = (struct reg_window32 *) fp;
10795 pc = rw->ins[7];
10796 printk("[%08lx : ", pc);
10797- printk("%pS ] ", (void *) pc);
10798+ printk("%pA ] ", (void *) pc);
10799 fp = rw->ins[6];
10800 } while (++count < 16);
10801 printk("\n");
10802diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
10803index 46a5964..a35c62c 100644
10804--- a/arch/sparc/kernel/process_64.c
10805+++ b/arch/sparc/kernel/process_64.c
10806@@ -161,7 +161,7 @@ static void show_regwindow(struct pt_regs *regs)
10807 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
10808 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
10809 if (regs->tstate & TSTATE_PRIV)
10810- printk("I7: <%pS>\n", (void *) rwk->ins[7]);
10811+ printk("I7: <%pA>\n", (void *) rwk->ins[7]);
10812 }
10813
10814 void show_regs(struct pt_regs *regs)
10815@@ -170,7 +170,7 @@ void show_regs(struct pt_regs *regs)
10816
10817 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
10818 regs->tpc, regs->tnpc, regs->y, print_tainted());
10819- printk("TPC: <%pS>\n", (void *) regs->tpc);
10820+ printk("TPC: <%pA>\n", (void *) regs->tpc);
10821 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
10822 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
10823 regs->u_regs[3]);
10824@@ -183,7 +183,7 @@ void show_regs(struct pt_regs *regs)
10825 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
10826 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
10827 regs->u_regs[15]);
10828- printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
10829+ printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
10830 show_regwindow(regs);
10831 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
10832 }
10833@@ -278,7 +278,7 @@ void arch_trigger_all_cpu_backtrace(bool include_self)
10834 ((tp && tp->task) ? tp->task->pid : -1));
10835
10836 if (gp->tstate & TSTATE_PRIV) {
10837- printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
10838+ printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
10839 (void *) gp->tpc,
10840 (void *) gp->o7,
10841 (void *) gp->i7,
10842diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
10843index 79cc0d1..ec62734 100644
10844--- a/arch/sparc/kernel/prom_common.c
10845+++ b/arch/sparc/kernel/prom_common.c
10846@@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
10847
10848 unsigned int prom_early_allocated __initdata;
10849
10850-static struct of_pdt_ops prom_sparc_ops __initdata = {
10851+static struct of_pdt_ops prom_sparc_ops __initconst = {
10852 .nextprop = prom_common_nextprop,
10853 .getproplen = prom_getproplen,
10854 .getproperty = prom_getproperty,
10855diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
10856index 9ddc492..27a5619 100644
10857--- a/arch/sparc/kernel/ptrace_64.c
10858+++ b/arch/sparc/kernel/ptrace_64.c
10859@@ -1060,6 +1060,10 @@ long arch_ptrace(struct task_struct *child, long request,
10860 return ret;
10861 }
10862
10863+#ifdef CONFIG_GRKERNSEC_SETXID
10864+extern void gr_delayed_cred_worker(void);
10865+#endif
10866+
10867 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
10868 {
10869 int ret = 0;
10870@@ -1070,6 +1074,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
10871 if (test_thread_flag(TIF_NOHZ))
10872 user_exit();
10873
10874+#ifdef CONFIG_GRKERNSEC_SETXID
10875+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
10876+ gr_delayed_cred_worker();
10877+#endif
10878+
10879 if (test_thread_flag(TIF_SYSCALL_TRACE))
10880 ret = tracehook_report_syscall_entry(regs);
10881
10882@@ -1088,6 +1097,11 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs)
10883 if (test_thread_flag(TIF_NOHZ))
10884 user_exit();
10885
10886+#ifdef CONFIG_GRKERNSEC_SETXID
10887+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
10888+ gr_delayed_cred_worker();
10889+#endif
10890+
10891 audit_syscall_exit(regs);
10892
10893 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
10894diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
10895index 19cd08d..ff21e99 100644
10896--- a/arch/sparc/kernel/smp_64.c
10897+++ b/arch/sparc/kernel/smp_64.c
10898@@ -891,7 +891,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
10899 return;
10900
10901 #ifdef CONFIG_DEBUG_DCFLUSH
10902- atomic_inc(&dcpage_flushes);
10903+ atomic_inc_unchecked(&dcpage_flushes);
10904 #endif
10905
10906 this_cpu = get_cpu();
10907@@ -915,7 +915,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
10908 xcall_deliver(data0, __pa(pg_addr),
10909 (u64) pg_addr, cpumask_of(cpu));
10910 #ifdef CONFIG_DEBUG_DCFLUSH
10911- atomic_inc(&dcpage_flushes_xcall);
10912+ atomic_inc_unchecked(&dcpage_flushes_xcall);
10913 #endif
10914 }
10915 }
10916@@ -934,7 +934,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
10917 preempt_disable();
10918
10919 #ifdef CONFIG_DEBUG_DCFLUSH
10920- atomic_inc(&dcpage_flushes);
10921+ atomic_inc_unchecked(&dcpage_flushes);
10922 #endif
10923 data0 = 0;
10924 pg_addr = page_address(page);
10925@@ -951,7 +951,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
10926 xcall_deliver(data0, __pa(pg_addr),
10927 (u64) pg_addr, cpu_online_mask);
10928 #ifdef CONFIG_DEBUG_DCFLUSH
10929- atomic_inc(&dcpage_flushes_xcall);
10930+ atomic_inc_unchecked(&dcpage_flushes_xcall);
10931 #endif
10932 }
10933 __local_flush_dcache_page(page);
10934diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
10935index 646988d..b88905f 100644
10936--- a/arch/sparc/kernel/sys_sparc_32.c
10937+++ b/arch/sparc/kernel/sys_sparc_32.c
10938@@ -54,7 +54,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10939 if (len > TASK_SIZE - PAGE_SIZE)
10940 return -ENOMEM;
10941 if (!addr)
10942- addr = TASK_UNMAPPED_BASE;
10943+ addr = current->mm->mmap_base;
10944
10945 info.flags = 0;
10946 info.length = len;
10947diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
10948index 30e7ddb..266a3b0 100644
10949--- a/arch/sparc/kernel/sys_sparc_64.c
10950+++ b/arch/sparc/kernel/sys_sparc_64.c
10951@@ -89,13 +89,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10952 struct vm_area_struct * vma;
10953 unsigned long task_size = TASK_SIZE;
10954 int do_color_align;
10955+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
10956 struct vm_unmapped_area_info info;
10957
10958 if (flags & MAP_FIXED) {
10959 /* We do not accept a shared mapping if it would violate
10960 * cache aliasing constraints.
10961 */
10962- if ((flags & MAP_SHARED) &&
10963+ if ((filp || (flags & MAP_SHARED)) &&
10964 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
10965 return -EINVAL;
10966 return addr;
10967@@ -110,6 +111,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10968 if (filp || (flags & MAP_SHARED))
10969 do_color_align = 1;
10970
10971+#ifdef CONFIG_PAX_RANDMMAP
10972+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10973+#endif
10974+
10975 if (addr) {
10976 if (do_color_align)
10977 addr = COLOR_ALIGN(addr, pgoff);
10978@@ -117,22 +122,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10979 addr = PAGE_ALIGN(addr);
10980
10981 vma = find_vma(mm, addr);
10982- if (task_size - len >= addr &&
10983- (!vma || addr + len <= vma->vm_start))
10984+ if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10985 return addr;
10986 }
10987
10988 info.flags = 0;
10989 info.length = len;
10990- info.low_limit = TASK_UNMAPPED_BASE;
10991+ info.low_limit = mm->mmap_base;
10992 info.high_limit = min(task_size, VA_EXCLUDE_START);
10993 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
10994 info.align_offset = pgoff << PAGE_SHIFT;
10995+ info.threadstack_offset = offset;
10996 addr = vm_unmapped_area(&info);
10997
10998 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10999 VM_BUG_ON(addr != -ENOMEM);
11000 info.low_limit = VA_EXCLUDE_END;
11001+
11002+#ifdef CONFIG_PAX_RANDMMAP
11003+ if (mm->pax_flags & MF_PAX_RANDMMAP)
11004+ info.low_limit += mm->delta_mmap;
11005+#endif
11006+
11007 info.high_limit = task_size;
11008 addr = vm_unmapped_area(&info);
11009 }
11010@@ -150,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11011 unsigned long task_size = STACK_TOP32;
11012 unsigned long addr = addr0;
11013 int do_color_align;
11014+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
11015 struct vm_unmapped_area_info info;
11016
11017 /* This should only ever run for 32-bit processes. */
11018@@ -159,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11019 /* We do not accept a shared mapping if it would violate
11020 * cache aliasing constraints.
11021 */
11022- if ((flags & MAP_SHARED) &&
11023+ if ((filp || (flags & MAP_SHARED)) &&
11024 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
11025 return -EINVAL;
11026 return addr;
11027@@ -172,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11028 if (filp || (flags & MAP_SHARED))
11029 do_color_align = 1;
11030
11031+#ifdef CONFIG_PAX_RANDMMAP
11032+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11033+#endif
11034+
11035 /* requesting a specific address */
11036 if (addr) {
11037 if (do_color_align)
11038@@ -180,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11039 addr = PAGE_ALIGN(addr);
11040
11041 vma = find_vma(mm, addr);
11042- if (task_size - len >= addr &&
11043- (!vma || addr + len <= vma->vm_start))
11044+ if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11045 return addr;
11046 }
11047
11048@@ -191,6 +206,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11049 info.high_limit = mm->mmap_base;
11050 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
11051 info.align_offset = pgoff << PAGE_SHIFT;
11052+ info.threadstack_offset = offset;
11053 addr = vm_unmapped_area(&info);
11054
11055 /*
11056@@ -203,6 +219,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11057 VM_BUG_ON(addr != -ENOMEM);
11058 info.flags = 0;
11059 info.low_limit = TASK_UNMAPPED_BASE;
11060+
11061+#ifdef CONFIG_PAX_RANDMMAP
11062+ if (mm->pax_flags & MF_PAX_RANDMMAP)
11063+ info.low_limit += mm->delta_mmap;
11064+#endif
11065+
11066 info.high_limit = STACK_TOP32;
11067 addr = vm_unmapped_area(&info);
11068 }
11069@@ -259,10 +281,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
11070 EXPORT_SYMBOL(get_fb_unmapped_area);
11071
11072 /* Essentially the same as PowerPC. */
11073-static unsigned long mmap_rnd(void)
11074+static unsigned long mmap_rnd(struct mm_struct *mm)
11075 {
11076 unsigned long rnd = 0UL;
11077
11078+#ifdef CONFIG_PAX_RANDMMAP
11079+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11080+#endif
11081+
11082 if (current->flags & PF_RANDOMIZE) {
11083 unsigned long val = get_random_int();
11084 if (test_thread_flag(TIF_32BIT))
11085@@ -275,7 +301,7 @@ static unsigned long mmap_rnd(void)
11086
11087 void arch_pick_mmap_layout(struct mm_struct *mm)
11088 {
11089- unsigned long random_factor = mmap_rnd();
11090+ unsigned long random_factor = mmap_rnd(mm);
11091 unsigned long gap;
11092
11093 /*
11094@@ -288,6 +314,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
11095 gap == RLIM_INFINITY ||
11096 sysctl_legacy_va_layout) {
11097 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
11098+
11099+#ifdef CONFIG_PAX_RANDMMAP
11100+ if (mm->pax_flags & MF_PAX_RANDMMAP)
11101+ mm->mmap_base += mm->delta_mmap;
11102+#endif
11103+
11104 mm->get_unmapped_area = arch_get_unmapped_area;
11105 } else {
11106 /* We know it's 32-bit */
11107@@ -299,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
11108 gap = (task_size / 6 * 5);
11109
11110 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
11111+
11112+#ifdef CONFIG_PAX_RANDMMAP
11113+ if (mm->pax_flags & MF_PAX_RANDMMAP)
11114+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
11115+#endif
11116+
11117 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
11118 }
11119 }
11120diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
11121index bb00089..e0ea580 100644
11122--- a/arch/sparc/kernel/syscalls.S
11123+++ b/arch/sparc/kernel/syscalls.S
11124@@ -62,7 +62,7 @@ sys32_rt_sigreturn:
11125 #endif
11126 .align 32
11127 1: ldx [%g6 + TI_FLAGS], %l5
11128- andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
11129+ andcc %l5, _TIF_WORK_SYSCALL, %g0
11130 be,pt %icc, rtrap
11131 nop
11132 call syscall_trace_leave
11133@@ -194,7 +194,7 @@ linux_sparc_syscall32:
11134
11135 srl %i3, 0, %o3 ! IEU0
11136 srl %i2, 0, %o2 ! IEU0 Group
11137- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
11138+ andcc %l0, _TIF_WORK_SYSCALL, %g0
11139 bne,pn %icc, linux_syscall_trace32 ! CTI
11140 mov %i0, %l5 ! IEU1
11141 5: call %l7 ! CTI Group brk forced
11142@@ -218,7 +218,7 @@ linux_sparc_syscall:
11143
11144 mov %i3, %o3 ! IEU1
11145 mov %i4, %o4 ! IEU0 Group
11146- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
11147+ andcc %l0, _TIF_WORK_SYSCALL, %g0
11148 bne,pn %icc, linux_syscall_trace ! CTI Group
11149 mov %i0, %l5 ! IEU0
11150 2: call %l7 ! CTI Group brk forced
11151@@ -233,7 +233,7 @@ ret_sys_call:
11152
11153 cmp %o0, -ERESTART_RESTARTBLOCK
11154 bgeu,pn %xcc, 1f
11155- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
11156+ andcc %l0, _TIF_WORK_SYSCALL, %g0
11157 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
11158
11159 2:
11160diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
11161index 4f21df7..0a374da 100644
11162--- a/arch/sparc/kernel/traps_32.c
11163+++ b/arch/sparc/kernel/traps_32.c
11164@@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
11165 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
11166 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
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@@ -76,15 +78,17 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11174 count++ < 30 &&
11175 (((unsigned long) rw) >= PAGE_OFFSET) &&
11176 !(((unsigned long) rw) & 0x7)) {
11177- printk("Caller[%08lx]: %pS\n", rw->ins[7],
11178+ printk("Caller[%08lx]: %pA\n", rw->ins[7],
11179 (void *) rw->ins[7]);
11180 rw = (struct reg_window32 *)rw->ins[6];
11181 }
11182 }
11183 printk("Instruction DUMP:");
11184 instruction_dump ((unsigned long *) regs->pc);
11185- if(regs->psr & PSR_PS)
11186+ if(regs->psr & PSR_PS) {
11187+ gr_handle_kernel_exploit();
11188 do_exit(SIGKILL);
11189+ }
11190 do_exit(SIGSEGV);
11191 }
11192
11193diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
11194index d21cd62..00a4a17 100644
11195--- a/arch/sparc/kernel/traps_64.c
11196+++ b/arch/sparc/kernel/traps_64.c
11197@@ -79,7 +79,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
11198 i + 1,
11199 p->trapstack[i].tstate, p->trapstack[i].tpc,
11200 p->trapstack[i].tnpc, p->trapstack[i].tt);
11201- printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
11202+ printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
11203 }
11204 }
11205
11206@@ -99,6 +99,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
11207
11208 lvl -= 0x100;
11209 if (regs->tstate & TSTATE_PRIV) {
11210+
11211+#ifdef CONFIG_PAX_REFCOUNT
11212+ if (lvl == 6)
11213+ pax_report_refcount_overflow(regs);
11214+#endif
11215+
11216 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
11217 die_if_kernel(buffer, regs);
11218 }
11219@@ -117,11 +123,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
11220 void bad_trap_tl1(struct pt_regs *regs, long lvl)
11221 {
11222 char buffer[32];
11223-
11224+
11225 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
11226 0, lvl, SIGTRAP) == NOTIFY_STOP)
11227 return;
11228
11229+#ifdef CONFIG_PAX_REFCOUNT
11230+ if (lvl == 6)
11231+ pax_report_refcount_overflow(regs);
11232+#endif
11233+
11234 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
11235
11236 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
11237@@ -1151,7 +1162,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
11238 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
11239 printk("%s" "ERROR(%d): ",
11240 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
11241- printk("TPC<%pS>\n", (void *) regs->tpc);
11242+ printk("TPC<%pA>\n", (void *) regs->tpc);
11243 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
11244 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
11245 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
11246@@ -1758,7 +1769,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
11247 smp_processor_id(),
11248 (type & 0x1) ? 'I' : 'D',
11249 regs->tpc);
11250- printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
11251+ printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
11252 panic("Irrecoverable Cheetah+ parity error.");
11253 }
11254
11255@@ -1766,7 +1777,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
11256 smp_processor_id(),
11257 (type & 0x1) ? 'I' : 'D',
11258 regs->tpc);
11259- printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
11260+ printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
11261 }
11262
11263 struct sun4v_error_entry {
11264@@ -1839,8 +1850,8 @@ struct sun4v_error_entry {
11265 /*0x38*/u64 reserved_5;
11266 };
11267
11268-static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
11269-static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
11270+static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
11271+static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
11272
11273 static const char *sun4v_err_type_to_str(u8 type)
11274 {
11275@@ -1932,7 +1943,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
11276 }
11277
11278 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
11279- int cpu, const char *pfx, atomic_t *ocnt)
11280+ int cpu, const char *pfx, atomic_unchecked_t *ocnt)
11281 {
11282 u64 *raw_ptr = (u64 *) ent;
11283 u32 attrs;
11284@@ -1990,8 +2001,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
11285
11286 show_regs(regs);
11287
11288- if ((cnt = atomic_read(ocnt)) != 0) {
11289- atomic_set(ocnt, 0);
11290+ if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
11291+ atomic_set_unchecked(ocnt, 0);
11292 wmb();
11293 printk("%s: Queue overflowed %d times.\n",
11294 pfx, cnt);
11295@@ -2048,7 +2059,7 @@ out:
11296 */
11297 void sun4v_resum_overflow(struct pt_regs *regs)
11298 {
11299- atomic_inc(&sun4v_resum_oflow_cnt);
11300+ atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
11301 }
11302
11303 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
11304@@ -2101,7 +2112,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
11305 /* XXX Actually even this can make not that much sense. Perhaps
11306 * XXX we should just pull the plug and panic directly from here?
11307 */
11308- atomic_inc(&sun4v_nonresum_oflow_cnt);
11309+ atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
11310 }
11311
11312 static void sun4v_tlb_error(struct pt_regs *regs)
11313@@ -2120,9 +2131,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
11314
11315 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
11316 regs->tpc, tl);
11317- printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
11318+ printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
11319 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
11320- printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
11321+ printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
11322 (void *) regs->u_regs[UREG_I7]);
11323 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
11324 "pte[%lx] error[%lx]\n",
11325@@ -2143,9 +2154,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
11326
11327 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
11328 regs->tpc, tl);
11329- printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
11330+ printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
11331 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
11332- printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
11333+ printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
11334 (void *) regs->u_regs[UREG_I7]);
11335 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
11336 "pte[%lx] error[%lx]\n",
11337@@ -2362,13 +2373,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
11338 fp = (unsigned long)sf->fp + STACK_BIAS;
11339 }
11340
11341- printk(" [%016lx] %pS\n", pc, (void *) pc);
11342+ printk(" [%016lx] %pA\n", pc, (void *) pc);
11343 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
11344 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
11345 int index = tsk->curr_ret_stack;
11346 if (tsk->ret_stack && index >= graph) {
11347 pc = tsk->ret_stack[index - graph].ret;
11348- printk(" [%016lx] %pS\n", pc, (void *) pc);
11349+ printk(" [%016lx] %pA\n", pc, (void *) pc);
11350 graph++;
11351 }
11352 }
11353@@ -2386,6 +2397,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
11354 return (struct reg_window *) (fp + STACK_BIAS);
11355 }
11356
11357+extern void gr_handle_kernel_exploit(void);
11358+
11359 void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11360 {
11361 static int die_counter;
11362@@ -2414,7 +2427,7 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11363 while (rw &&
11364 count++ < 30 &&
11365 kstack_valid(tp, (unsigned long) rw)) {
11366- printk("Caller[%016lx]: %pS\n", rw->ins[7],
11367+ printk("Caller[%016lx]: %pA\n", rw->ins[7],
11368 (void *) rw->ins[7]);
11369
11370 rw = kernel_stack_up(rw);
11371@@ -2429,8 +2442,10 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11372 }
11373 if (panic_on_oops)
11374 panic("Fatal exception");
11375- if (regs->tstate & TSTATE_PRIV)
11376+ if (regs->tstate & TSTATE_PRIV) {
11377+ gr_handle_kernel_exploit();
11378 do_exit(SIGKILL);
11379+ }
11380 do_exit(SIGSEGV);
11381 }
11382 EXPORT_SYMBOL(die_if_kernel);
11383diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
11384index 62098a8..547ab2c 100644
11385--- a/arch/sparc/kernel/unaligned_64.c
11386+++ b/arch/sparc/kernel/unaligned_64.c
11387@@ -297,7 +297,7 @@ static void log_unaligned(struct pt_regs *regs)
11388 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
11389
11390 if (__ratelimit(&ratelimit)) {
11391- printk("Kernel unaligned access at TPC[%lx] %pS\n",
11392+ printk("Kernel unaligned access at TPC[%lx] %pA\n",
11393 regs->tpc, (void *) regs->tpc);
11394 }
11395 }
11396diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
11397index 3269b02..64f5231 100644
11398--- a/arch/sparc/lib/Makefile
11399+++ b/arch/sparc/lib/Makefile
11400@@ -2,7 +2,7 @@
11401 #
11402
11403 asflags-y := -ansi -DST_DIV0=0x02
11404-ccflags-y := -Werror
11405+#ccflags-y := -Werror
11406
11407 lib-$(CONFIG_SPARC32) += ashrdi3.o
11408 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
11409diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
11410index 05dac43..76f8ed4 100644
11411--- a/arch/sparc/lib/atomic_64.S
11412+++ b/arch/sparc/lib/atomic_64.S
11413@@ -15,11 +15,22 @@
11414 * a value and does the barriers.
11415 */
11416
11417-#define ATOMIC_OP(op) \
11418-ENTRY(atomic_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11419+#ifdef CONFIG_PAX_REFCOUNT
11420+#define __REFCOUNT_OP(op) op##cc
11421+#define __OVERFLOW_IOP tvs %icc, 6;
11422+#define __OVERFLOW_XOP tvs %xcc, 6;
11423+#else
11424+#define __REFCOUNT_OP(op) op
11425+#define __OVERFLOW_IOP
11426+#define __OVERFLOW_XOP
11427+#endif
11428+
11429+#define __ATOMIC_OP(op, suffix, asm_op, post_op) \
11430+ENTRY(atomic_##op##suffix) /* %o0 = increment, %o1 = atomic_ptr */ \
11431 BACKOFF_SETUP(%o2); \
11432 1: lduw [%o1], %g1; \
11433- op %g1, %o0, %g7; \
11434+ asm_op %g1, %o0, %g7; \
11435+ post_op \
11436 cas [%o1], %g1, %g7; \
11437 cmp %g1, %g7; \
11438 bne,pn %icc, BACKOFF_LABEL(2f, 1b); \
11439@@ -29,11 +40,15 @@ ENTRY(atomic_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11440 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11441 ENDPROC(atomic_##op); \
11442
11443-#define ATOMIC_OP_RETURN(op) \
11444-ENTRY(atomic_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11445+#define ATOMIC_OP(op) __ATOMIC_OP(op, , op, ) \
11446+ __ATOMIC_OP(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_IOP)
11447+
11448+#define __ATOMIC_OP_RETURN(op, suffix, asm_op, post_op) \
11449+ENTRY(atomic_##op##_return##suffix) /* %o0 = increment, %o1 = atomic_ptr */\
11450 BACKOFF_SETUP(%o2); \
11451 1: lduw [%o1], %g1; \
11452- op %g1, %o0, %g7; \
11453+ asm_op %g1, %o0, %g7; \
11454+ post_op \
11455 cas [%o1], %g1, %g7; \
11456 cmp %g1, %g7; \
11457 bne,pn %icc, BACKOFF_LABEL(2f, 1b); \
11458@@ -43,6 +58,9 @@ ENTRY(atomic_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11459 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11460 ENDPROC(atomic_##op##_return);
11461
11462+#define ATOMIC_OP_RETURN(op) __ATOMIC_OP_RETURN(op, , op, ) \
11463+ __ATOMIC_OP_RETURN(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_IOP)
11464+
11465 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
11466
11467 ATOMIC_OPS(add)
11468@@ -50,13 +68,16 @@ ATOMIC_OPS(sub)
11469
11470 #undef ATOMIC_OPS
11471 #undef ATOMIC_OP_RETURN
11472+#undef __ATOMIC_OP_RETURN
11473 #undef ATOMIC_OP
11474+#undef __ATOMIC_OP
11475
11476-#define ATOMIC64_OP(op) \
11477-ENTRY(atomic64_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11478+#define __ATOMIC64_OP(op, suffix, asm_op, post_op) \
11479+ENTRY(atomic64_##op##suffix) /* %o0 = increment, %o1 = atomic_ptr */ \
11480 BACKOFF_SETUP(%o2); \
11481 1: ldx [%o1], %g1; \
11482- op %g1, %o0, %g7; \
11483+ asm_op %g1, %o0, %g7; \
11484+ post_op \
11485 casx [%o1], %g1, %g7; \
11486 cmp %g1, %g7; \
11487 bne,pn %xcc, BACKOFF_LABEL(2f, 1b); \
11488@@ -66,11 +87,15 @@ ENTRY(atomic64_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11489 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11490 ENDPROC(atomic64_##op); \
11491
11492-#define ATOMIC64_OP_RETURN(op) \
11493-ENTRY(atomic64_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11494+#define ATOMIC64_OP(op) __ATOMIC64_OP(op, , op, ) \
11495+ __ATOMIC64_OP(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_XOP)
11496+
11497+#define __ATOMIC64_OP_RETURN(op, suffix, asm_op, post_op) \
11498+ENTRY(atomic64_##op##_return##suffix) /* %o0 = increment, %o1 = atomic_ptr */\
11499 BACKOFF_SETUP(%o2); \
11500 1: ldx [%o1], %g1; \
11501- op %g1, %o0, %g7; \
11502+ asm_op %g1, %o0, %g7; \
11503+ post_op \
11504 casx [%o1], %g1, %g7; \
11505 cmp %g1, %g7; \
11506 bne,pn %xcc, BACKOFF_LABEL(2f, 1b); \
11507@@ -80,6 +105,9 @@ ENTRY(atomic64_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11508 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11509 ENDPROC(atomic64_##op##_return);
11510
11511+#define ATOMIC64_OP_RETURN(op) __ATOMIC64_OP_RETURN(op, , op, ) \
11512+i __ATOMIC64_OP_RETURN(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_XOP)
11513+
11514 #define ATOMIC64_OPS(op) ATOMIC64_OP(op) ATOMIC64_OP_RETURN(op)
11515
11516 ATOMIC64_OPS(add)
11517@@ -87,7 +115,12 @@ ATOMIC64_OPS(sub)
11518
11519 #undef ATOMIC64_OPS
11520 #undef ATOMIC64_OP_RETURN
11521+#undef __ATOMIC64_OP_RETURN
11522 #undef ATOMIC64_OP
11523+#undef __ATOMIC64_OP
11524+#undef __OVERFLOW_XOP
11525+#undef __OVERFLOW_IOP
11526+#undef __REFCOUNT_OP
11527
11528 ENTRY(atomic64_dec_if_positive) /* %o0 = atomic_ptr */
11529 BACKOFF_SETUP(%o2)
11530diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
11531index 8069ce1..c2e23c4 100644
11532--- a/arch/sparc/lib/ksyms.c
11533+++ b/arch/sparc/lib/ksyms.c
11534@@ -101,7 +101,9 @@ EXPORT_SYMBOL(__clear_user);
11535 /* Atomic counter implementation. */
11536 #define ATOMIC_OP(op) \
11537 EXPORT_SYMBOL(atomic_##op); \
11538-EXPORT_SYMBOL(atomic64_##op);
11539+EXPORT_SYMBOL(atomic_##op##_unchecked); \
11540+EXPORT_SYMBOL(atomic64_##op); \
11541+EXPORT_SYMBOL(atomic64_##op##_unchecked);
11542
11543 #define ATOMIC_OP_RETURN(op) \
11544 EXPORT_SYMBOL(atomic_##op##_return); \
11545@@ -110,6 +112,8 @@ EXPORT_SYMBOL(atomic64_##op##_return);
11546 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
11547
11548 ATOMIC_OPS(add)
11549+EXPORT_SYMBOL(atomic_add_ret_unchecked);
11550+EXPORT_SYMBOL(atomic64_add_ret_unchecked);
11551 ATOMIC_OPS(sub)
11552
11553 #undef ATOMIC_OPS
11554diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
11555index 30c3ecc..736f015 100644
11556--- a/arch/sparc/mm/Makefile
11557+++ b/arch/sparc/mm/Makefile
11558@@ -2,7 +2,7 @@
11559 #
11560
11561 asflags-y := -ansi
11562-ccflags-y := -Werror
11563+#ccflags-y := -Werror
11564
11565 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
11566 obj-y += fault_$(BITS).o
11567diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
11568index c399e7b..2387414 100644
11569--- a/arch/sparc/mm/fault_32.c
11570+++ b/arch/sparc/mm/fault_32.c
11571@@ -22,6 +22,9 @@
11572 #include <linux/interrupt.h>
11573 #include <linux/kdebug.h>
11574 #include <linux/uaccess.h>
11575+#include <linux/slab.h>
11576+#include <linux/pagemap.h>
11577+#include <linux/compiler.h>
11578
11579 #include <asm/page.h>
11580 #include <asm/pgtable.h>
11581@@ -156,6 +159,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
11582 return safe_compute_effective_address(regs, insn);
11583 }
11584
11585+#ifdef CONFIG_PAX_PAGEEXEC
11586+#ifdef CONFIG_PAX_DLRESOLVE
11587+static void pax_emuplt_close(struct vm_area_struct *vma)
11588+{
11589+ vma->vm_mm->call_dl_resolve = 0UL;
11590+}
11591+
11592+static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
11593+{
11594+ unsigned int *kaddr;
11595+
11596+ vmf->page = alloc_page(GFP_HIGHUSER);
11597+ if (!vmf->page)
11598+ return VM_FAULT_OOM;
11599+
11600+ kaddr = kmap(vmf->page);
11601+ memset(kaddr, 0, PAGE_SIZE);
11602+ kaddr[0] = 0x9DE3BFA8U; /* save */
11603+ flush_dcache_page(vmf->page);
11604+ kunmap(vmf->page);
11605+ return VM_FAULT_MAJOR;
11606+}
11607+
11608+static const struct vm_operations_struct pax_vm_ops = {
11609+ .close = pax_emuplt_close,
11610+ .fault = pax_emuplt_fault
11611+};
11612+
11613+static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
11614+{
11615+ int ret;
11616+
11617+ INIT_LIST_HEAD(&vma->anon_vma_chain);
11618+ vma->vm_mm = current->mm;
11619+ vma->vm_start = addr;
11620+ vma->vm_end = addr + PAGE_SIZE;
11621+ vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
11622+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
11623+ vma->vm_ops = &pax_vm_ops;
11624+
11625+ ret = insert_vm_struct(current->mm, vma);
11626+ if (ret)
11627+ return ret;
11628+
11629+ ++current->mm->total_vm;
11630+ return 0;
11631+}
11632+#endif
11633+
11634+/*
11635+ * PaX: decide what to do with offenders (regs->pc = fault address)
11636+ *
11637+ * returns 1 when task should be killed
11638+ * 2 when patched PLT trampoline was detected
11639+ * 3 when unpatched PLT trampoline was detected
11640+ */
11641+static int pax_handle_fetch_fault(struct pt_regs *regs)
11642+{
11643+
11644+#ifdef CONFIG_PAX_EMUPLT
11645+ int err;
11646+
11647+ do { /* PaX: patched PLT emulation #1 */
11648+ unsigned int sethi1, sethi2, jmpl;
11649+
11650+ err = get_user(sethi1, (unsigned int *)regs->pc);
11651+ err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
11652+ err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
11653+
11654+ if (err)
11655+ break;
11656+
11657+ if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
11658+ (sethi2 & 0xFFC00000U) == 0x03000000U &&
11659+ (jmpl & 0xFFFFE000U) == 0x81C06000U)
11660+ {
11661+ unsigned int addr;
11662+
11663+ regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
11664+ addr = regs->u_regs[UREG_G1];
11665+ addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11666+ regs->pc = addr;
11667+ regs->npc = addr+4;
11668+ return 2;
11669+ }
11670+ } while (0);
11671+
11672+ do { /* PaX: patched PLT emulation #2 */
11673+ unsigned int ba;
11674+
11675+ err = get_user(ba, (unsigned int *)regs->pc);
11676+
11677+ if (err)
11678+ break;
11679+
11680+ if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
11681+ unsigned int addr;
11682+
11683+ if ((ba & 0xFFC00000U) == 0x30800000U)
11684+ addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
11685+ else
11686+ addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11687+ regs->pc = addr;
11688+ regs->npc = addr+4;
11689+ return 2;
11690+ }
11691+ } while (0);
11692+
11693+ do { /* PaX: patched PLT emulation #3 */
11694+ unsigned int sethi, bajmpl, nop;
11695+
11696+ err = get_user(sethi, (unsigned int *)regs->pc);
11697+ err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
11698+ err |= get_user(nop, (unsigned int *)(regs->pc+8));
11699+
11700+ if (err)
11701+ break;
11702+
11703+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11704+ ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
11705+ nop == 0x01000000U)
11706+ {
11707+ unsigned int addr;
11708+
11709+ addr = (sethi & 0x003FFFFFU) << 10;
11710+ regs->u_regs[UREG_G1] = addr;
11711+ if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
11712+ addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11713+ else
11714+ addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11715+ regs->pc = addr;
11716+ regs->npc = addr+4;
11717+ return 2;
11718+ }
11719+ } while (0);
11720+
11721+ do { /* PaX: unpatched PLT emulation step 1 */
11722+ unsigned int sethi, ba, nop;
11723+
11724+ err = get_user(sethi, (unsigned int *)regs->pc);
11725+ err |= get_user(ba, (unsigned int *)(regs->pc+4));
11726+ err |= get_user(nop, (unsigned int *)(regs->pc+8));
11727+
11728+ if (err)
11729+ break;
11730+
11731+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11732+ ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11733+ nop == 0x01000000U)
11734+ {
11735+ unsigned int addr, save, call;
11736+
11737+ if ((ba & 0xFFC00000U) == 0x30800000U)
11738+ addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
11739+ else
11740+ addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11741+
11742+ err = get_user(save, (unsigned int *)addr);
11743+ err |= get_user(call, (unsigned int *)(addr+4));
11744+ err |= get_user(nop, (unsigned int *)(addr+8));
11745+ if (err)
11746+ break;
11747+
11748+#ifdef CONFIG_PAX_DLRESOLVE
11749+ if (save == 0x9DE3BFA8U &&
11750+ (call & 0xC0000000U) == 0x40000000U &&
11751+ nop == 0x01000000U)
11752+ {
11753+ struct vm_area_struct *vma;
11754+ unsigned long call_dl_resolve;
11755+
11756+ down_read(&current->mm->mmap_sem);
11757+ call_dl_resolve = current->mm->call_dl_resolve;
11758+ up_read(&current->mm->mmap_sem);
11759+ if (likely(call_dl_resolve))
11760+ goto emulate;
11761+
11762+ vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11763+
11764+ down_write(&current->mm->mmap_sem);
11765+ if (current->mm->call_dl_resolve) {
11766+ call_dl_resolve = current->mm->call_dl_resolve;
11767+ up_write(&current->mm->mmap_sem);
11768+ if (vma)
11769+ kmem_cache_free(vm_area_cachep, vma);
11770+ goto emulate;
11771+ }
11772+
11773+ call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11774+ if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11775+ up_write(&current->mm->mmap_sem);
11776+ if (vma)
11777+ kmem_cache_free(vm_area_cachep, vma);
11778+ return 1;
11779+ }
11780+
11781+ if (pax_insert_vma(vma, call_dl_resolve)) {
11782+ up_write(&current->mm->mmap_sem);
11783+ kmem_cache_free(vm_area_cachep, vma);
11784+ return 1;
11785+ }
11786+
11787+ current->mm->call_dl_resolve = call_dl_resolve;
11788+ up_write(&current->mm->mmap_sem);
11789+
11790+emulate:
11791+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11792+ regs->pc = call_dl_resolve;
11793+ regs->npc = addr+4;
11794+ return 3;
11795+ }
11796+#endif
11797+
11798+ /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11799+ if ((save & 0xFFC00000U) == 0x05000000U &&
11800+ (call & 0xFFFFE000U) == 0x85C0A000U &&
11801+ nop == 0x01000000U)
11802+ {
11803+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11804+ regs->u_regs[UREG_G2] = addr + 4;
11805+ addr = (save & 0x003FFFFFU) << 10;
11806+ addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11807+ regs->pc = addr;
11808+ regs->npc = addr+4;
11809+ return 3;
11810+ }
11811+ }
11812+ } while (0);
11813+
11814+ do { /* PaX: unpatched PLT emulation step 2 */
11815+ unsigned int save, call, nop;
11816+
11817+ err = get_user(save, (unsigned int *)(regs->pc-4));
11818+ err |= get_user(call, (unsigned int *)regs->pc);
11819+ err |= get_user(nop, (unsigned int *)(regs->pc+4));
11820+ if (err)
11821+ break;
11822+
11823+ if (save == 0x9DE3BFA8U &&
11824+ (call & 0xC0000000U) == 0x40000000U &&
11825+ nop == 0x01000000U)
11826+ {
11827+ unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
11828+
11829+ regs->u_regs[UREG_RETPC] = regs->pc;
11830+ regs->pc = dl_resolve;
11831+ regs->npc = dl_resolve+4;
11832+ return 3;
11833+ }
11834+ } while (0);
11835+#endif
11836+
11837+ return 1;
11838+}
11839+
11840+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11841+{
11842+ unsigned long i;
11843+
11844+ printk(KERN_ERR "PAX: bytes at PC: ");
11845+ for (i = 0; i < 8; i++) {
11846+ unsigned int c;
11847+ if (get_user(c, (unsigned int *)pc+i))
11848+ printk(KERN_CONT "???????? ");
11849+ else
11850+ printk(KERN_CONT "%08x ", c);
11851+ }
11852+ printk("\n");
11853+}
11854+#endif
11855+
11856 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
11857 int text_fault)
11858 {
11859@@ -226,6 +500,24 @@ good_area:
11860 if (!(vma->vm_flags & VM_WRITE))
11861 goto bad_area;
11862 } else {
11863+
11864+#ifdef CONFIG_PAX_PAGEEXEC
11865+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
11866+ up_read(&mm->mmap_sem);
11867+ switch (pax_handle_fetch_fault(regs)) {
11868+
11869+#ifdef CONFIG_PAX_EMUPLT
11870+ case 2:
11871+ case 3:
11872+ return;
11873+#endif
11874+
11875+ }
11876+ pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
11877+ do_group_exit(SIGKILL);
11878+ }
11879+#endif
11880+
11881 /* Allow reads even for write-only mappings */
11882 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
11883 goto bad_area;
11884diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
11885index dbabe57..d34d315 100644
11886--- a/arch/sparc/mm/fault_64.c
11887+++ b/arch/sparc/mm/fault_64.c
11888@@ -23,6 +23,9 @@
11889 #include <linux/percpu.h>
11890 #include <linux/context_tracking.h>
11891 #include <linux/uaccess.h>
11892+#include <linux/slab.h>
11893+#include <linux/pagemap.h>
11894+#include <linux/compiler.h>
11895
11896 #include <asm/page.h>
11897 #include <asm/pgtable.h>
11898@@ -76,7 +79,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
11899 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
11900 regs->tpc);
11901 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
11902- printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
11903+ printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
11904 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
11905 dump_stack();
11906 unhandled_fault(regs->tpc, current, regs);
11907@@ -279,6 +282,466 @@ static void noinline __kprobes bogus_32bit_fault_tpc(struct pt_regs *regs)
11908 show_regs(regs);
11909 }
11910
11911+#ifdef CONFIG_PAX_PAGEEXEC
11912+#ifdef CONFIG_PAX_DLRESOLVE
11913+static void pax_emuplt_close(struct vm_area_struct *vma)
11914+{
11915+ vma->vm_mm->call_dl_resolve = 0UL;
11916+}
11917+
11918+static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
11919+{
11920+ unsigned int *kaddr;
11921+
11922+ vmf->page = alloc_page(GFP_HIGHUSER);
11923+ if (!vmf->page)
11924+ return VM_FAULT_OOM;
11925+
11926+ kaddr = kmap(vmf->page);
11927+ memset(kaddr, 0, PAGE_SIZE);
11928+ kaddr[0] = 0x9DE3BFA8U; /* save */
11929+ flush_dcache_page(vmf->page);
11930+ kunmap(vmf->page);
11931+ return VM_FAULT_MAJOR;
11932+}
11933+
11934+static const struct vm_operations_struct pax_vm_ops = {
11935+ .close = pax_emuplt_close,
11936+ .fault = pax_emuplt_fault
11937+};
11938+
11939+static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
11940+{
11941+ int ret;
11942+
11943+ INIT_LIST_HEAD(&vma->anon_vma_chain);
11944+ vma->vm_mm = current->mm;
11945+ vma->vm_start = addr;
11946+ vma->vm_end = addr + PAGE_SIZE;
11947+ vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
11948+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
11949+ vma->vm_ops = &pax_vm_ops;
11950+
11951+ ret = insert_vm_struct(current->mm, vma);
11952+ if (ret)
11953+ return ret;
11954+
11955+ ++current->mm->total_vm;
11956+ return 0;
11957+}
11958+#endif
11959+
11960+/*
11961+ * PaX: decide what to do with offenders (regs->tpc = fault address)
11962+ *
11963+ * returns 1 when task should be killed
11964+ * 2 when patched PLT trampoline was detected
11965+ * 3 when unpatched PLT trampoline was detected
11966+ */
11967+static int pax_handle_fetch_fault(struct pt_regs *regs)
11968+{
11969+
11970+#ifdef CONFIG_PAX_EMUPLT
11971+ int err;
11972+
11973+ do { /* PaX: patched PLT emulation #1 */
11974+ unsigned int sethi1, sethi2, jmpl;
11975+
11976+ err = get_user(sethi1, (unsigned int *)regs->tpc);
11977+ err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
11978+ err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
11979+
11980+ if (err)
11981+ break;
11982+
11983+ if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
11984+ (sethi2 & 0xFFC00000U) == 0x03000000U &&
11985+ (jmpl & 0xFFFFE000U) == 0x81C06000U)
11986+ {
11987+ unsigned long addr;
11988+
11989+ regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
11990+ addr = regs->u_regs[UREG_G1];
11991+ addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11992+
11993+ if (test_thread_flag(TIF_32BIT))
11994+ addr &= 0xFFFFFFFFUL;
11995+
11996+ regs->tpc = addr;
11997+ regs->tnpc = addr+4;
11998+ return 2;
11999+ }
12000+ } while (0);
12001+
12002+ do { /* PaX: patched PLT emulation #2 */
12003+ unsigned int ba;
12004+
12005+ err = get_user(ba, (unsigned int *)regs->tpc);
12006+
12007+ if (err)
12008+ break;
12009+
12010+ if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
12011+ unsigned long addr;
12012+
12013+ if ((ba & 0xFFC00000U) == 0x30800000U)
12014+ addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
12015+ else
12016+ addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
12017+
12018+ if (test_thread_flag(TIF_32BIT))
12019+ addr &= 0xFFFFFFFFUL;
12020+
12021+ regs->tpc = addr;
12022+ regs->tnpc = addr+4;
12023+ return 2;
12024+ }
12025+ } while (0);
12026+
12027+ do { /* PaX: patched PLT emulation #3 */
12028+ unsigned int sethi, bajmpl, nop;
12029+
12030+ err = get_user(sethi, (unsigned int *)regs->tpc);
12031+ err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
12032+ err |= get_user(nop, (unsigned int *)(regs->tpc+8));
12033+
12034+ if (err)
12035+ break;
12036+
12037+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12038+ ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
12039+ nop == 0x01000000U)
12040+ {
12041+ unsigned long addr;
12042+
12043+ addr = (sethi & 0x003FFFFFU) << 10;
12044+ regs->u_regs[UREG_G1] = addr;
12045+ if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
12046+ addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
12047+ else
12048+ addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
12049+
12050+ if (test_thread_flag(TIF_32BIT))
12051+ addr &= 0xFFFFFFFFUL;
12052+
12053+ regs->tpc = addr;
12054+ regs->tnpc = addr+4;
12055+ return 2;
12056+ }
12057+ } while (0);
12058+
12059+ do { /* PaX: patched PLT emulation #4 */
12060+ unsigned int sethi, mov1, call, mov2;
12061+
12062+ err = get_user(sethi, (unsigned int *)regs->tpc);
12063+ err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
12064+ err |= get_user(call, (unsigned int *)(regs->tpc+8));
12065+ err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
12066+
12067+ if (err)
12068+ break;
12069+
12070+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12071+ mov1 == 0x8210000FU &&
12072+ (call & 0xC0000000U) == 0x40000000U &&
12073+ mov2 == 0x9E100001U)
12074+ {
12075+ unsigned long addr;
12076+
12077+ regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
12078+ addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
12079+
12080+ if (test_thread_flag(TIF_32BIT))
12081+ addr &= 0xFFFFFFFFUL;
12082+
12083+ regs->tpc = addr;
12084+ regs->tnpc = addr+4;
12085+ return 2;
12086+ }
12087+ } while (0);
12088+
12089+ do { /* PaX: patched PLT emulation #5 */
12090+ unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
12091+
12092+ err = get_user(sethi, (unsigned int *)regs->tpc);
12093+ err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
12094+ err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
12095+ err |= get_user(or1, (unsigned int *)(regs->tpc+12));
12096+ err |= get_user(or2, (unsigned int *)(regs->tpc+16));
12097+ err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
12098+ err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
12099+ err |= get_user(nop, (unsigned int *)(regs->tpc+28));
12100+
12101+ if (err)
12102+ break;
12103+
12104+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12105+ (sethi1 & 0xFFC00000U) == 0x03000000U &&
12106+ (sethi2 & 0xFFC00000U) == 0x0B000000U &&
12107+ (or1 & 0xFFFFE000U) == 0x82106000U &&
12108+ (or2 & 0xFFFFE000U) == 0x8A116000U &&
12109+ sllx == 0x83287020U &&
12110+ jmpl == 0x81C04005U &&
12111+ nop == 0x01000000U)
12112+ {
12113+ unsigned long addr;
12114+
12115+ regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
12116+ regs->u_regs[UREG_G1] <<= 32;
12117+ regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
12118+ addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
12119+ regs->tpc = addr;
12120+ regs->tnpc = addr+4;
12121+ return 2;
12122+ }
12123+ } while (0);
12124+
12125+ do { /* PaX: patched PLT emulation #6 */
12126+ unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
12127+
12128+ err = get_user(sethi, (unsigned int *)regs->tpc);
12129+ err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
12130+ err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
12131+ err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
12132+ err |= get_user(or, (unsigned int *)(regs->tpc+16));
12133+ err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
12134+ err |= get_user(nop, (unsigned int *)(regs->tpc+24));
12135+
12136+ if (err)
12137+ break;
12138+
12139+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12140+ (sethi1 & 0xFFC00000U) == 0x03000000U &&
12141+ (sethi2 & 0xFFC00000U) == 0x0B000000U &&
12142+ sllx == 0x83287020U &&
12143+ (or & 0xFFFFE000U) == 0x8A116000U &&
12144+ jmpl == 0x81C04005U &&
12145+ nop == 0x01000000U)
12146+ {
12147+ unsigned long addr;
12148+
12149+ regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
12150+ regs->u_regs[UREG_G1] <<= 32;
12151+ regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
12152+ addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
12153+ regs->tpc = addr;
12154+ regs->tnpc = addr+4;
12155+ return 2;
12156+ }
12157+ } while (0);
12158+
12159+ do { /* PaX: unpatched PLT emulation step 1 */
12160+ unsigned int sethi, ba, nop;
12161+
12162+ err = get_user(sethi, (unsigned int *)regs->tpc);
12163+ err |= get_user(ba, (unsigned int *)(regs->tpc+4));
12164+ err |= get_user(nop, (unsigned int *)(regs->tpc+8));
12165+
12166+ if (err)
12167+ break;
12168+
12169+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12170+ ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
12171+ nop == 0x01000000U)
12172+ {
12173+ unsigned long addr;
12174+ unsigned int save, call;
12175+ unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
12176+
12177+ if ((ba & 0xFFC00000U) == 0x30800000U)
12178+ addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
12179+ else
12180+ addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
12181+
12182+ if (test_thread_flag(TIF_32BIT))
12183+ addr &= 0xFFFFFFFFUL;
12184+
12185+ err = get_user(save, (unsigned int *)addr);
12186+ err |= get_user(call, (unsigned int *)(addr+4));
12187+ err |= get_user(nop, (unsigned int *)(addr+8));
12188+ if (err)
12189+ break;
12190+
12191+#ifdef CONFIG_PAX_DLRESOLVE
12192+ if (save == 0x9DE3BFA8U &&
12193+ (call & 0xC0000000U) == 0x40000000U &&
12194+ nop == 0x01000000U)
12195+ {
12196+ struct vm_area_struct *vma;
12197+ unsigned long call_dl_resolve;
12198+
12199+ down_read(&current->mm->mmap_sem);
12200+ call_dl_resolve = current->mm->call_dl_resolve;
12201+ up_read(&current->mm->mmap_sem);
12202+ if (likely(call_dl_resolve))
12203+ goto emulate;
12204+
12205+ vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
12206+
12207+ down_write(&current->mm->mmap_sem);
12208+ if (current->mm->call_dl_resolve) {
12209+ call_dl_resolve = current->mm->call_dl_resolve;
12210+ up_write(&current->mm->mmap_sem);
12211+ if (vma)
12212+ kmem_cache_free(vm_area_cachep, vma);
12213+ goto emulate;
12214+ }
12215+
12216+ call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
12217+ if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
12218+ up_write(&current->mm->mmap_sem);
12219+ if (vma)
12220+ kmem_cache_free(vm_area_cachep, vma);
12221+ return 1;
12222+ }
12223+
12224+ if (pax_insert_vma(vma, call_dl_resolve)) {
12225+ up_write(&current->mm->mmap_sem);
12226+ kmem_cache_free(vm_area_cachep, vma);
12227+ return 1;
12228+ }
12229+
12230+ current->mm->call_dl_resolve = call_dl_resolve;
12231+ up_write(&current->mm->mmap_sem);
12232+
12233+emulate:
12234+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
12235+ regs->tpc = call_dl_resolve;
12236+ regs->tnpc = addr+4;
12237+ return 3;
12238+ }
12239+#endif
12240+
12241+ /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
12242+ if ((save & 0xFFC00000U) == 0x05000000U &&
12243+ (call & 0xFFFFE000U) == 0x85C0A000U &&
12244+ nop == 0x01000000U)
12245+ {
12246+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
12247+ regs->u_regs[UREG_G2] = addr + 4;
12248+ addr = (save & 0x003FFFFFU) << 10;
12249+ addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
12250+
12251+ if (test_thread_flag(TIF_32BIT))
12252+ addr &= 0xFFFFFFFFUL;
12253+
12254+ regs->tpc = addr;
12255+ regs->tnpc = addr+4;
12256+ return 3;
12257+ }
12258+
12259+ /* PaX: 64-bit PLT stub */
12260+ err = get_user(sethi1, (unsigned int *)addr);
12261+ err |= get_user(sethi2, (unsigned int *)(addr+4));
12262+ err |= get_user(or1, (unsigned int *)(addr+8));
12263+ err |= get_user(or2, (unsigned int *)(addr+12));
12264+ err |= get_user(sllx, (unsigned int *)(addr+16));
12265+ err |= get_user(add, (unsigned int *)(addr+20));
12266+ err |= get_user(jmpl, (unsigned int *)(addr+24));
12267+ err |= get_user(nop, (unsigned int *)(addr+28));
12268+ if (err)
12269+ break;
12270+
12271+ if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
12272+ (sethi2 & 0xFFC00000U) == 0x0B000000U &&
12273+ (or1 & 0xFFFFE000U) == 0x88112000U &&
12274+ (or2 & 0xFFFFE000U) == 0x8A116000U &&
12275+ sllx == 0x89293020U &&
12276+ add == 0x8A010005U &&
12277+ jmpl == 0x89C14000U &&
12278+ nop == 0x01000000U)
12279+ {
12280+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
12281+ regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
12282+ regs->u_regs[UREG_G4] <<= 32;
12283+ regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
12284+ regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
12285+ regs->u_regs[UREG_G4] = addr + 24;
12286+ addr = regs->u_regs[UREG_G5];
12287+ regs->tpc = addr;
12288+ regs->tnpc = addr+4;
12289+ return 3;
12290+ }
12291+ }
12292+ } while (0);
12293+
12294+#ifdef CONFIG_PAX_DLRESOLVE
12295+ do { /* PaX: unpatched PLT emulation step 2 */
12296+ unsigned int save, call, nop;
12297+
12298+ err = get_user(save, (unsigned int *)(regs->tpc-4));
12299+ err |= get_user(call, (unsigned int *)regs->tpc);
12300+ err |= get_user(nop, (unsigned int *)(regs->tpc+4));
12301+ if (err)
12302+ break;
12303+
12304+ if (save == 0x9DE3BFA8U &&
12305+ (call & 0xC0000000U) == 0x40000000U &&
12306+ nop == 0x01000000U)
12307+ {
12308+ unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
12309+
12310+ if (test_thread_flag(TIF_32BIT))
12311+ dl_resolve &= 0xFFFFFFFFUL;
12312+
12313+ regs->u_regs[UREG_RETPC] = regs->tpc;
12314+ regs->tpc = dl_resolve;
12315+ regs->tnpc = dl_resolve+4;
12316+ return 3;
12317+ }
12318+ } while (0);
12319+#endif
12320+
12321+ do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
12322+ unsigned int sethi, ba, nop;
12323+
12324+ err = get_user(sethi, (unsigned int *)regs->tpc);
12325+ err |= get_user(ba, (unsigned int *)(regs->tpc+4));
12326+ err |= get_user(nop, (unsigned int *)(regs->tpc+8));
12327+
12328+ if (err)
12329+ break;
12330+
12331+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12332+ (ba & 0xFFF00000U) == 0x30600000U &&
12333+ nop == 0x01000000U)
12334+ {
12335+ unsigned long addr;
12336+
12337+ addr = (sethi & 0x003FFFFFU) << 10;
12338+ regs->u_regs[UREG_G1] = addr;
12339+ addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
12340+
12341+ if (test_thread_flag(TIF_32BIT))
12342+ addr &= 0xFFFFFFFFUL;
12343+
12344+ regs->tpc = addr;
12345+ regs->tnpc = addr+4;
12346+ return 2;
12347+ }
12348+ } while (0);
12349+
12350+#endif
12351+
12352+ return 1;
12353+}
12354+
12355+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
12356+{
12357+ unsigned long i;
12358+
12359+ printk(KERN_ERR "PAX: bytes at PC: ");
12360+ for (i = 0; i < 8; i++) {
12361+ unsigned int c;
12362+ if (get_user(c, (unsigned int *)pc+i))
12363+ printk(KERN_CONT "???????? ");
12364+ else
12365+ printk(KERN_CONT "%08x ", c);
12366+ }
12367+ printk("\n");
12368+}
12369+#endif
12370+
12371 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
12372 {
12373 enum ctx_state prev_state = exception_enter();
12374@@ -353,6 +816,29 @@ retry:
12375 if (!vma)
12376 goto bad_area;
12377
12378+#ifdef CONFIG_PAX_PAGEEXEC
12379+ /* PaX: detect ITLB misses on non-exec pages */
12380+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
12381+ !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
12382+ {
12383+ if (address != regs->tpc)
12384+ goto good_area;
12385+
12386+ up_read(&mm->mmap_sem);
12387+ switch (pax_handle_fetch_fault(regs)) {
12388+
12389+#ifdef CONFIG_PAX_EMUPLT
12390+ case 2:
12391+ case 3:
12392+ return;
12393+#endif
12394+
12395+ }
12396+ pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
12397+ do_group_exit(SIGKILL);
12398+ }
12399+#endif
12400+
12401 /* Pure DTLB misses do not tell us whether the fault causing
12402 * load/store/atomic was a write or not, it only says that there
12403 * was no match. So in such a case we (carefully) read the
12404diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
12405index 131eaf4..285ea31 100644
12406--- a/arch/sparc/mm/hugetlbpage.c
12407+++ b/arch/sparc/mm/hugetlbpage.c
12408@@ -25,8 +25,10 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
12409 unsigned long addr,
12410 unsigned long len,
12411 unsigned long pgoff,
12412- unsigned long flags)
12413+ unsigned long flags,
12414+ unsigned long offset)
12415 {
12416+ struct mm_struct *mm = current->mm;
12417 unsigned long task_size = TASK_SIZE;
12418 struct vm_unmapped_area_info info;
12419
12420@@ -35,15 +37,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
12421
12422 info.flags = 0;
12423 info.length = len;
12424- info.low_limit = TASK_UNMAPPED_BASE;
12425+ info.low_limit = mm->mmap_base;
12426 info.high_limit = min(task_size, VA_EXCLUDE_START);
12427 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
12428 info.align_offset = 0;
12429+ info.threadstack_offset = offset;
12430 addr = vm_unmapped_area(&info);
12431
12432 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
12433 VM_BUG_ON(addr != -ENOMEM);
12434 info.low_limit = VA_EXCLUDE_END;
12435+
12436+#ifdef CONFIG_PAX_RANDMMAP
12437+ if (mm->pax_flags & MF_PAX_RANDMMAP)
12438+ info.low_limit += mm->delta_mmap;
12439+#endif
12440+
12441 info.high_limit = task_size;
12442 addr = vm_unmapped_area(&info);
12443 }
12444@@ -55,7 +64,8 @@ static unsigned long
12445 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
12446 const unsigned long len,
12447 const unsigned long pgoff,
12448- const unsigned long flags)
12449+ const unsigned long flags,
12450+ const unsigned long offset)
12451 {
12452 struct mm_struct *mm = current->mm;
12453 unsigned long addr = addr0;
12454@@ -70,6 +80,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
12455 info.high_limit = mm->mmap_base;
12456 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
12457 info.align_offset = 0;
12458+ info.threadstack_offset = offset;
12459 addr = vm_unmapped_area(&info);
12460
12461 /*
12462@@ -82,6 +93,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
12463 VM_BUG_ON(addr != -ENOMEM);
12464 info.flags = 0;
12465 info.low_limit = TASK_UNMAPPED_BASE;
12466+
12467+#ifdef CONFIG_PAX_RANDMMAP
12468+ if (mm->pax_flags & MF_PAX_RANDMMAP)
12469+ info.low_limit += mm->delta_mmap;
12470+#endif
12471+
12472 info.high_limit = STACK_TOP32;
12473 addr = vm_unmapped_area(&info);
12474 }
12475@@ -96,6 +113,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
12476 struct mm_struct *mm = current->mm;
12477 struct vm_area_struct *vma;
12478 unsigned long task_size = TASK_SIZE;
12479+ unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
12480
12481 if (test_thread_flag(TIF_32BIT))
12482 task_size = STACK_TOP32;
12483@@ -111,19 +129,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
12484 return addr;
12485 }
12486
12487+#ifdef CONFIG_PAX_RANDMMAP
12488+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
12489+#endif
12490+
12491 if (addr) {
12492 addr = ALIGN(addr, HPAGE_SIZE);
12493 vma = find_vma(mm, addr);
12494- if (task_size - len >= addr &&
12495- (!vma || addr + len <= vma->vm_start))
12496+ if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
12497 return addr;
12498 }
12499 if (mm->get_unmapped_area == arch_get_unmapped_area)
12500 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
12501- pgoff, flags);
12502+ pgoff, flags, offset);
12503 else
12504 return hugetlb_get_unmapped_area_topdown(file, addr, len,
12505- pgoff, flags);
12506+ pgoff, flags, offset);
12507 }
12508
12509 pte_t *huge_pte_alloc(struct mm_struct *mm,
12510diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
12511index 4ac88b7..bac6cb2 100644
12512--- a/arch/sparc/mm/init_64.c
12513+++ b/arch/sparc/mm/init_64.c
12514@@ -187,9 +187,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
12515 int num_kernel_image_mappings;
12516
12517 #ifdef CONFIG_DEBUG_DCFLUSH
12518-atomic_t dcpage_flushes = ATOMIC_INIT(0);
12519+atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
12520 #ifdef CONFIG_SMP
12521-atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
12522+atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
12523 #endif
12524 #endif
12525
12526@@ -197,7 +197,7 @@ inline void flush_dcache_page_impl(struct page *page)
12527 {
12528 BUG_ON(tlb_type == hypervisor);
12529 #ifdef CONFIG_DEBUG_DCFLUSH
12530- atomic_inc(&dcpage_flushes);
12531+ atomic_inc_unchecked(&dcpage_flushes);
12532 #endif
12533
12534 #ifdef DCACHE_ALIASING_POSSIBLE
12535@@ -469,10 +469,10 @@ void mmu_info(struct seq_file *m)
12536
12537 #ifdef CONFIG_DEBUG_DCFLUSH
12538 seq_printf(m, "DCPageFlushes\t: %d\n",
12539- atomic_read(&dcpage_flushes));
12540+ atomic_read_unchecked(&dcpage_flushes));
12541 #ifdef CONFIG_SMP
12542 seq_printf(m, "DCPageFlushesXC\t: %d\n",
12543- atomic_read(&dcpage_flushes_xcall));
12544+ atomic_read_unchecked(&dcpage_flushes_xcall));
12545 #endif /* CONFIG_SMP */
12546 #endif /* CONFIG_DEBUG_DCFLUSH */
12547 }
12548diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
12549index 9def1f5..cf0cabc 100644
12550--- a/arch/tile/Kconfig
12551+++ b/arch/tile/Kconfig
12552@@ -204,6 +204,7 @@ source "kernel/Kconfig.hz"
12553
12554 config KEXEC
12555 bool "kexec system call"
12556+ depends on !GRKERNSEC_KMEM
12557 ---help---
12558 kexec is a system call that implements the ability to shutdown your
12559 current kernel, and to start another kernel. It is like a reboot
12560diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
12561index 0496970..1a57e5f 100644
12562--- a/arch/tile/include/asm/atomic_64.h
12563+++ b/arch/tile/include/asm/atomic_64.h
12564@@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
12565
12566 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12567
12568+#define atomic64_read_unchecked(v) atomic64_read(v)
12569+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
12570+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
12571+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
12572+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
12573+#define atomic64_inc_unchecked(v) atomic64_inc(v)
12574+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
12575+#define atomic64_dec_unchecked(v) atomic64_dec(v)
12576+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
12577+
12578 #endif /* !__ASSEMBLY__ */
12579
12580 #endif /* _ASM_TILE_ATOMIC_64_H */
12581diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
12582index 6160761..00cac88 100644
12583--- a/arch/tile/include/asm/cache.h
12584+++ b/arch/tile/include/asm/cache.h
12585@@ -15,11 +15,12 @@
12586 #ifndef _ASM_TILE_CACHE_H
12587 #define _ASM_TILE_CACHE_H
12588
12589+#include <linux/const.h>
12590 #include <arch/chip.h>
12591
12592 /* bytes per L1 data cache line */
12593 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
12594-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12595+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12596
12597 /* bytes per L2 cache line */
12598 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
12599diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
12600index 0a9c4265..bfb62d1 100644
12601--- a/arch/tile/include/asm/uaccess.h
12602+++ b/arch/tile/include/asm/uaccess.h
12603@@ -429,9 +429,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
12604 const void __user *from,
12605 unsigned long n)
12606 {
12607- int sz = __compiletime_object_size(to);
12608+ size_t sz = __compiletime_object_size(to);
12609
12610- if (likely(sz == -1 || sz >= n))
12611+ if (likely(sz == (size_t)-1 || sz >= n))
12612 n = _copy_from_user(to, from, n);
12613 else
12614 copy_from_user_overflow();
12615diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
12616index c034dc3..cf1cc96 100644
12617--- a/arch/tile/mm/hugetlbpage.c
12618+++ b/arch/tile/mm/hugetlbpage.c
12619@@ -174,6 +174,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
12620 info.high_limit = TASK_SIZE;
12621 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
12622 info.align_offset = 0;
12623+ info.threadstack_offset = 0;
12624 return vm_unmapped_area(&info);
12625 }
12626
12627@@ -191,6 +192,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
12628 info.high_limit = current->mm->mmap_base;
12629 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
12630 info.align_offset = 0;
12631+ info.threadstack_offset = 0;
12632 addr = vm_unmapped_area(&info);
12633
12634 /*
12635diff --git a/arch/um/Makefile b/arch/um/Makefile
12636index 098ab33..fc54a33 100644
12637--- a/arch/um/Makefile
12638+++ b/arch/um/Makefile
12639@@ -73,6 +73,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
12640 -D_FILE_OFFSET_BITS=64 -idirafter include \
12641 -D__KERNEL__ -D__UM_HOST__
12642
12643+ifdef CONSTIFY_PLUGIN
12644+USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
12645+endif
12646+
12647 #This will adjust *FLAGS accordingly to the platform.
12648 include $(ARCH_DIR)/Makefile-os-$(OS)
12649
12650diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
12651index 19e1bdd..3665b77 100644
12652--- a/arch/um/include/asm/cache.h
12653+++ b/arch/um/include/asm/cache.h
12654@@ -1,6 +1,7 @@
12655 #ifndef __UM_CACHE_H
12656 #define __UM_CACHE_H
12657
12658+#include <linux/const.h>
12659
12660 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
12661 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12662@@ -12,6 +13,6 @@
12663 # define L1_CACHE_SHIFT 5
12664 #endif
12665
12666-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12667+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12668
12669 #endif
12670diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
12671index 2e0a6b1..a64d0f5 100644
12672--- a/arch/um/include/asm/kmap_types.h
12673+++ b/arch/um/include/asm/kmap_types.h
12674@@ -8,6 +8,6 @@
12675
12676 /* No more #include "asm/arch/kmap_types.h" ! */
12677
12678-#define KM_TYPE_NR 14
12679+#define KM_TYPE_NR 15
12680
12681 #endif
12682diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
12683index 71c5d13..4c7b9f1 100644
12684--- a/arch/um/include/asm/page.h
12685+++ b/arch/um/include/asm/page.h
12686@@ -14,6 +14,9 @@
12687 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
12688 #define PAGE_MASK (~(PAGE_SIZE-1))
12689
12690+#define ktla_ktva(addr) (addr)
12691+#define ktva_ktla(addr) (addr)
12692+
12693 #ifndef __ASSEMBLY__
12694
12695 struct page;
12696diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
12697index 2b4274e..754fe06 100644
12698--- a/arch/um/include/asm/pgtable-3level.h
12699+++ b/arch/um/include/asm/pgtable-3level.h
12700@@ -58,6 +58,7 @@
12701 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
12702 #define pud_populate(mm, pud, pmd) \
12703 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
12704+#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
12705
12706 #ifdef CONFIG_64BIT
12707 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
12708diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
12709index 68b9119..f72353c 100644
12710--- a/arch/um/kernel/process.c
12711+++ b/arch/um/kernel/process.c
12712@@ -345,22 +345,6 @@ int singlestepping(void * t)
12713 return 2;
12714 }
12715
12716-/*
12717- * Only x86 and x86_64 have an arch_align_stack().
12718- * All other arches have "#define arch_align_stack(x) (x)"
12719- * in their asm/exec.h
12720- * As this is included in UML from asm-um/system-generic.h,
12721- * we can use it to behave as the subarch does.
12722- */
12723-#ifndef arch_align_stack
12724-unsigned long arch_align_stack(unsigned long sp)
12725-{
12726- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
12727- sp -= get_random_int() % 8192;
12728- return sp & ~0xf;
12729-}
12730-#endif
12731-
12732 unsigned long get_wchan(struct task_struct *p)
12733 {
12734 unsigned long stack_page, sp, ip;
12735diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
12736index ad8f795..2c7eec6 100644
12737--- a/arch/unicore32/include/asm/cache.h
12738+++ b/arch/unicore32/include/asm/cache.h
12739@@ -12,8 +12,10 @@
12740 #ifndef __UNICORE_CACHE_H__
12741 #define __UNICORE_CACHE_H__
12742
12743-#define L1_CACHE_SHIFT (5)
12744-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12745+#include <linux/const.h>
12746+
12747+#define L1_CACHE_SHIFT 5
12748+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12749
12750 /*
12751 * Memory returned by kmalloc() may be used for DMA, so we must make
12752diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
12753index b3a1a5d..8dbc2d6 100644
12754--- a/arch/x86/Kconfig
12755+++ b/arch/x86/Kconfig
12756@@ -35,13 +35,12 @@ config X86
12757 select ARCH_MIGHT_HAVE_PC_SERIO
12758 select ARCH_SUPPORTS_ATOMIC_RMW
12759 select ARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INIT
12760- select ARCH_SUPPORTS_INT128 if X86_64
12761+ select ARCH_SUPPORTS_INT128 if X86_64 && !PAX_SIZE_OVERFLOW
12762 select ARCH_SUPPORTS_NUMA_BALANCING if X86_64
12763 select ARCH_USE_BUILTIN_BSWAP
12764 select ARCH_USE_CMPXCHG_LOCKREF if X86_64
12765 select ARCH_USE_QUEUED_RWLOCKS
12766 select ARCH_USE_QUEUED_SPINLOCKS
12767- select ARCH_WANTS_DYNAMIC_TASK_STRUCT
12768 select ARCH_WANT_FRAME_POINTERS
12769 select ARCH_WANT_IPC_PARSE_VERSION if X86_32
12770 select ARCH_WANT_OPTIONAL_GPIOLIB
12771@@ -85,7 +84,7 @@ config X86
12772 select HAVE_ARCH_TRACEHOOK
12773 select HAVE_ARCH_TRANSPARENT_HUGEPAGE
12774 select HAVE_BPF_JIT if X86_64
12775- select HAVE_CC_STACKPROTECTOR
12776+ select HAVE_CC_STACKPROTECTOR if X86_64 || !PAX_MEMORY_UDEREF
12777 select HAVE_CMPXCHG_DOUBLE
12778 select HAVE_CMPXCHG_LOCAL
12779 select HAVE_CONTEXT_TRACKING if X86_64
12780@@ -274,7 +273,7 @@ config X86_64_SMP
12781
12782 config X86_32_LAZY_GS
12783 def_bool y
12784- depends on X86_32 && !CC_STACKPROTECTOR
12785+ depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
12786
12787 config ARCH_HWEIGHT_CFLAGS
12788 string
12789@@ -646,6 +645,7 @@ config SCHED_OMIT_FRAME_POINTER
12790
12791 menuconfig HYPERVISOR_GUEST
12792 bool "Linux guest support"
12793+ depends on !GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_VIRT_GUEST || (GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_XEN)
12794 ---help---
12795 Say Y here to enable options for running Linux under various hyper-
12796 visors. This option enables basic hypervisor detection and platform
12797@@ -1014,6 +1014,7 @@ config VM86
12798
12799 config X86_16BIT
12800 bool "Enable support for 16-bit segments" if EXPERT
12801+ depends on !GRKERNSEC
12802 default y
12803 ---help---
12804 This option is required by programs like Wine to run 16-bit
12805@@ -1182,6 +1183,7 @@ choice
12806
12807 config NOHIGHMEM
12808 bool "off"
12809+ depends on !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
12810 ---help---
12811 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
12812 However, the address space of 32-bit x86 processors is only 4
12813@@ -1218,6 +1220,7 @@ config NOHIGHMEM
12814
12815 config HIGHMEM4G
12816 bool "4GB"
12817+ depends on !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
12818 ---help---
12819 Select this if you have a 32-bit processor and between 1 and 4
12820 gigabytes of physical RAM.
12821@@ -1270,7 +1273,7 @@ config PAGE_OFFSET
12822 hex
12823 default 0xB0000000 if VMSPLIT_3G_OPT
12824 default 0x80000000 if VMSPLIT_2G
12825- default 0x78000000 if VMSPLIT_2G_OPT
12826+ default 0x70000000 if VMSPLIT_2G_OPT
12827 default 0x40000000 if VMSPLIT_1G
12828 default 0xC0000000
12829 depends on X86_32
12830@@ -1290,7 +1293,6 @@ config X86_PAE
12831
12832 config ARCH_PHYS_ADDR_T_64BIT
12833 def_bool y
12834- depends on X86_64 || X86_PAE
12835
12836 config ARCH_DMA_ADDR_T_64BIT
12837 def_bool y
12838@@ -1724,6 +1726,7 @@ source kernel/Kconfig.hz
12839
12840 config KEXEC
12841 bool "kexec system call"
12842+ depends on !GRKERNSEC_KMEM
12843 ---help---
12844 kexec is a system call that implements the ability to shutdown your
12845 current kernel, and to start another kernel. It is like a reboot
12846@@ -1906,7 +1909,9 @@ config X86_NEED_RELOCS
12847
12848 config PHYSICAL_ALIGN
12849 hex "Alignment value to which kernel should be aligned"
12850- default "0x200000"
12851+ default "0x1000000"
12852+ range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
12853+ range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
12854 range 0x2000 0x1000000 if X86_32
12855 range 0x200000 0x1000000 if X86_64
12856 ---help---
12857@@ -1989,6 +1994,7 @@ config COMPAT_VDSO
12858 def_bool n
12859 prompt "Disable the 32-bit vDSO (needed for glibc 2.3.3)"
12860 depends on X86_32 || IA32_EMULATION
12861+ depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
12862 ---help---
12863 Certain buggy versions of glibc will crash if they are
12864 presented with a 32-bit vDSO that is not mapped at the address
12865@@ -2053,6 +2059,22 @@ config CMDLINE_OVERRIDE
12866 This is used to work around broken boot loaders. This should
12867 be set to 'N' under normal conditions.
12868
12869+config DEFAULT_MODIFY_LDT_SYSCALL
12870+ bool "Allow userspace to modify the LDT by default"
12871+ default y
12872+
12873+ ---help---
12874+ Modifying the LDT (Local Descriptor Table) may be needed to run a
12875+ 16-bit or segmented code such as Dosemu or Wine. This is done via
12876+ a system call which is not needed to run portable applications,
12877+ and which can sometimes be abused to exploit some weaknesses of
12878+ the architecture, opening new vulnerabilities.
12879+
12880+ For this reason this option allows one to enable or disable the
12881+ feature at runtime. It is recommended to say 'N' here to leave
12882+ the system protected, and to enable it at runtime only if needed
12883+ by setting the sys.kernel.modify_ldt sysctl.
12884+
12885 source "kernel/livepatch/Kconfig"
12886
12887 endmenu
12888diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
12889index 6983314..54ad7e8 100644
12890--- a/arch/x86/Kconfig.cpu
12891+++ b/arch/x86/Kconfig.cpu
12892@@ -319,7 +319,7 @@ config X86_PPRO_FENCE
12893
12894 config X86_F00F_BUG
12895 def_bool y
12896- depends on M586MMX || M586TSC || M586 || M486
12897+ depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
12898
12899 config X86_INVD_BUG
12900 def_bool y
12901@@ -327,7 +327,7 @@ config X86_INVD_BUG
12902
12903 config X86_ALIGNMENT_16
12904 def_bool y
12905- depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
12906+ depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
12907
12908 config X86_INTEL_USERCOPY
12909 def_bool y
12910@@ -369,7 +369,7 @@ config X86_CMPXCHG64
12911 # generates cmov.
12912 config X86_CMOV
12913 def_bool y
12914- depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
12915+ depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
12916
12917 config X86_MINIMUM_CPU_FAMILY
12918 int
12919diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
12920index d8c0d32..28e3117 100644
12921--- a/arch/x86/Kconfig.debug
12922+++ b/arch/x86/Kconfig.debug
12923@@ -69,6 +69,7 @@ config X86_PTDUMP
12924 bool "Export kernel pagetable layout to userspace via debugfs"
12925 depends on DEBUG_KERNEL
12926 select DEBUG_FS
12927+ depends on !GRKERNSEC_KMEM
12928 ---help---
12929 Say Y here if you want to show the kernel pagetable layout in a
12930 debugfs file. This information is only useful for kernel developers
12931@@ -89,7 +90,7 @@ config EFI_PGT_DUMP
12932 config DEBUG_RODATA
12933 bool "Write protect kernel read-only data structures"
12934 default y
12935- depends on DEBUG_KERNEL
12936+ depends on DEBUG_KERNEL && BROKEN
12937 ---help---
12938 Mark the kernel read-only data as write-protected in the pagetables,
12939 in order to catch accidental (and incorrect) writes to such const
12940@@ -107,7 +108,7 @@ config DEBUG_RODATA_TEST
12941
12942 config DEBUG_SET_MODULE_RONX
12943 bool "Set loadable kernel module data as NX and text as RO"
12944- depends on MODULES
12945+ depends on MODULES && BROKEN
12946 ---help---
12947 This option helps catch unintended modifications to loadable
12948 kernel module's text and read-only data. It also prevents execution
12949@@ -359,6 +360,7 @@ config X86_DEBUG_FPU
12950 config PUNIT_ATOM_DEBUG
12951 tristate "ATOM Punit debug driver"
12952 select DEBUG_FS
12953+ depends on !GRKERNSEC_KMEM
12954 select IOSF_MBI
12955 ---help---
12956 This is a debug driver, which gets the power states
12957diff --git a/arch/x86/Makefile b/arch/x86/Makefile
12958index 118e6de..e02efff 100644
12959--- a/arch/x86/Makefile
12960+++ b/arch/x86/Makefile
12961@@ -65,9 +65,6 @@ ifeq ($(CONFIG_X86_32),y)
12962 # CPU-specific tuning. Anything which can be shared with UML should go here.
12963 include arch/x86/Makefile_32.cpu
12964 KBUILD_CFLAGS += $(cflags-y)
12965-
12966- # temporary until string.h is fixed
12967- KBUILD_CFLAGS += -ffreestanding
12968 else
12969 BITS := 64
12970 UTS_MACHINE := x86_64
12971@@ -116,6 +113,9 @@ else
12972 KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args)
12973 endif
12974
12975+# temporary until string.h is fixed
12976+KBUILD_CFLAGS += -ffreestanding
12977+
12978 # Make sure compiler does not have buggy stack-protector support.
12979 ifdef CONFIG_CC_STACKPROTECTOR
12980 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
12981@@ -184,6 +184,7 @@ archheaders:
12982 $(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all
12983
12984 archprepare:
12985+ $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
12986 ifeq ($(CONFIG_KEXEC_FILE),y)
12987 $(Q)$(MAKE) $(build)=arch/x86/purgatory arch/x86/purgatory/kexec-purgatory.c
12988 endif
12989@@ -267,3 +268,9 @@ define archhelp
12990 echo ' FDARGS="..." arguments for the booted kernel'
12991 echo ' FDINITRD=file initrd for the booted kernel'
12992 endef
12993+
12994+define OLD_LD
12995+
12996+*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
12997+*** Please upgrade your binutils to 2.18 or newer
12998+endef
12999diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
13000index 57bbf2f..b100fce 100644
13001--- a/arch/x86/boot/Makefile
13002+++ b/arch/x86/boot/Makefile
13003@@ -58,6 +58,9 @@ clean-files += cpustr.h
13004 # ---------------------------------------------------------------------------
13005
13006 KBUILD_CFLAGS := $(USERINCLUDE) $(REALMODE_CFLAGS) -D_SETUP
13007+ifdef CONSTIFY_PLUGIN
13008+KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
13009+endif
13010 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
13011 GCOV_PROFILE := n
13012
13013diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
13014index 878e4b9..20537ab 100644
13015--- a/arch/x86/boot/bitops.h
13016+++ b/arch/x86/boot/bitops.h
13017@@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
13018 u8 v;
13019 const u32 *p = (const u32 *)addr;
13020
13021- asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
13022+ asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
13023 return v;
13024 }
13025
13026@@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
13027
13028 static inline void set_bit(int nr, void *addr)
13029 {
13030- asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
13031+ asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
13032 }
13033
13034 #endif /* BOOT_BITOPS_H */
13035diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
13036index bd49ec6..94c7f58 100644
13037--- a/arch/x86/boot/boot.h
13038+++ b/arch/x86/boot/boot.h
13039@@ -84,7 +84,7 @@ static inline void io_delay(void)
13040 static inline u16 ds(void)
13041 {
13042 u16 seg;
13043- asm("movw %%ds,%0" : "=rm" (seg));
13044+ asm volatile("movw %%ds,%0" : "=rm" (seg));
13045 return seg;
13046 }
13047
13048diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
13049index 0a291cd..9686efc 100644
13050--- a/arch/x86/boot/compressed/Makefile
13051+++ b/arch/x86/boot/compressed/Makefile
13052@@ -30,6 +30,9 @@ KBUILD_CFLAGS += $(cflags-y)
13053 KBUILD_CFLAGS += -mno-mmx -mno-sse
13054 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
13055 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
13056+ifdef CONSTIFY_PLUGIN
13057+KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
13058+endif
13059
13060 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
13061 GCOV_PROFILE := n
13062diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
13063index a53440e..c3dbf1e 100644
13064--- a/arch/x86/boot/compressed/efi_stub_32.S
13065+++ b/arch/x86/boot/compressed/efi_stub_32.S
13066@@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
13067 * parameter 2, ..., param n. To make things easy, we save the return
13068 * address of efi_call_phys in a global variable.
13069 */
13070- popl %ecx
13071- movl %ecx, saved_return_addr(%edx)
13072- /* get the function pointer into ECX*/
13073- popl %ecx
13074- movl %ecx, efi_rt_function_ptr(%edx)
13075+ popl saved_return_addr(%edx)
13076+ popl efi_rt_function_ptr(%edx)
13077
13078 /*
13079 * 3. Call the physical function.
13080 */
13081- call *%ecx
13082+ call *efi_rt_function_ptr(%edx)
13083
13084 /*
13085 * 4. Balance the stack. And because EAX contain the return value,
13086@@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
13087 1: popl %edx
13088 subl $1b, %edx
13089
13090- movl efi_rt_function_ptr(%edx), %ecx
13091- pushl %ecx
13092+ pushl efi_rt_function_ptr(%edx)
13093
13094 /*
13095 * 10. Push the saved return address onto the stack and return.
13096 */
13097- movl saved_return_addr(%edx), %ecx
13098- pushl %ecx
13099- ret
13100+ jmpl *saved_return_addr(%edx)
13101 ENDPROC(efi_call_phys)
13102 .previous
13103
13104diff --git a/arch/x86/boot/compressed/efi_thunk_64.S b/arch/x86/boot/compressed/efi_thunk_64.S
13105index 630384a..278e788 100644
13106--- a/arch/x86/boot/compressed/efi_thunk_64.S
13107+++ b/arch/x86/boot/compressed/efi_thunk_64.S
13108@@ -189,8 +189,8 @@ efi_gdt64:
13109 .long 0 /* Filled out by user */
13110 .word 0
13111 .quad 0x0000000000000000 /* NULL descriptor */
13112- .quad 0x00af9a000000ffff /* __KERNEL_CS */
13113- .quad 0x00cf92000000ffff /* __KERNEL_DS */
13114+ .quad 0x00af9b000000ffff /* __KERNEL_CS */
13115+ .quad 0x00cf93000000ffff /* __KERNEL_DS */
13116 .quad 0x0080890000000000 /* TS descriptor */
13117 .quad 0x0000000000000000 /* TS continued */
13118 efi_gdt64_end:
13119diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
13120index 8ef964d..fcfb8aa 100644
13121--- a/arch/x86/boot/compressed/head_32.S
13122+++ b/arch/x86/boot/compressed/head_32.S
13123@@ -141,10 +141,10 @@ preferred_addr:
13124 addl %eax, %ebx
13125 notl %eax
13126 andl %eax, %ebx
13127- cmpl $LOAD_PHYSICAL_ADDR, %ebx
13128+ cmpl $____LOAD_PHYSICAL_ADDR, %ebx
13129 jge 1f
13130 #endif
13131- movl $LOAD_PHYSICAL_ADDR, %ebx
13132+ movl $____LOAD_PHYSICAL_ADDR, %ebx
13133 1:
13134
13135 /* Target address to relocate to for decompression */
13136diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
13137index b0c0d16..3b44ff8 100644
13138--- a/arch/x86/boot/compressed/head_64.S
13139+++ b/arch/x86/boot/compressed/head_64.S
13140@@ -95,10 +95,10 @@ ENTRY(startup_32)
13141 addl %eax, %ebx
13142 notl %eax
13143 andl %eax, %ebx
13144- cmpl $LOAD_PHYSICAL_ADDR, %ebx
13145+ cmpl $____LOAD_PHYSICAL_ADDR, %ebx
13146 jge 1f
13147 #endif
13148- movl $LOAD_PHYSICAL_ADDR, %ebx
13149+ movl $____LOAD_PHYSICAL_ADDR, %ebx
13150 1:
13151
13152 /* Target address to relocate to for decompression */
13153@@ -323,10 +323,10 @@ preferred_addr:
13154 addq %rax, %rbp
13155 notq %rax
13156 andq %rax, %rbp
13157- cmpq $LOAD_PHYSICAL_ADDR, %rbp
13158+ cmpq $____LOAD_PHYSICAL_ADDR, %rbp
13159 jge 1f
13160 #endif
13161- movq $LOAD_PHYSICAL_ADDR, %rbp
13162+ movq $____LOAD_PHYSICAL_ADDR, %rbp
13163 1:
13164
13165 /* Target address to relocate to for decompression */
13166@@ -435,8 +435,8 @@ gdt:
13167 .long gdt
13168 .word 0
13169 .quad 0x0000000000000000 /* NULL descriptor */
13170- .quad 0x00af9a000000ffff /* __KERNEL_CS */
13171- .quad 0x00cf92000000ffff /* __KERNEL_DS */
13172+ .quad 0x00af9b000000ffff /* __KERNEL_CS */
13173+ .quad 0x00cf93000000ffff /* __KERNEL_DS */
13174 .quad 0x0080890000000000 /* TS descriptor */
13175 .quad 0x0000000000000000 /* TS continued */
13176 gdt_end:
13177diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
13178index e28437e..6a17460 100644
13179--- a/arch/x86/boot/compressed/misc.c
13180+++ b/arch/x86/boot/compressed/misc.c
13181@@ -242,7 +242,7 @@ static void handle_relocations(void *output, unsigned long output_len)
13182 * Calculate the delta between where vmlinux was linked to load
13183 * and where it was actually loaded.
13184 */
13185- delta = min_addr - LOAD_PHYSICAL_ADDR;
13186+ delta = min_addr - ____LOAD_PHYSICAL_ADDR;
13187 if (!delta) {
13188 debug_putstr("No relocation needed... ");
13189 return;
13190@@ -324,7 +324,7 @@ static void parse_elf(void *output)
13191 Elf32_Ehdr ehdr;
13192 Elf32_Phdr *phdrs, *phdr;
13193 #endif
13194- void *dest;
13195+ void *dest, *prev;
13196 int i;
13197
13198 memcpy(&ehdr, output, sizeof(ehdr));
13199@@ -351,13 +351,16 @@ static void parse_elf(void *output)
13200 case PT_LOAD:
13201 #ifdef CONFIG_RELOCATABLE
13202 dest = output;
13203- dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
13204+ dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
13205 #else
13206 dest = (void *)(phdr->p_paddr);
13207 #endif
13208 memcpy(dest,
13209 output + phdr->p_offset,
13210 phdr->p_filesz);
13211+ if (i)
13212+ memset(prev, 0xff, dest - prev);
13213+ prev = dest + phdr->p_filesz;
13214 break;
13215 default: /* Ignore other PT_* */ break;
13216 }
13217@@ -419,7 +422,7 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
13218 error("Destination address too large");
13219 #endif
13220 #ifndef CONFIG_RELOCATABLE
13221- if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
13222+ if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
13223 error("Wrong destination address");
13224 #endif
13225
13226diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
13227index 1fd7d57..0f7d096 100644
13228--- a/arch/x86/boot/cpucheck.c
13229+++ b/arch/x86/boot/cpucheck.c
13230@@ -125,9 +125,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
13231 u32 ecx = MSR_K7_HWCR;
13232 u32 eax, edx;
13233
13234- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13235+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13236 eax &= ~(1 << 15);
13237- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13238+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13239
13240 get_cpuflags(); /* Make sure it really did something */
13241 err = check_cpuflags();
13242@@ -140,9 +140,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
13243 u32 ecx = MSR_VIA_FCR;
13244 u32 eax, edx;
13245
13246- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13247+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13248 eax |= (1<<1)|(1<<7);
13249- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13250+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13251
13252 set_bit(X86_FEATURE_CX8, cpu.flags);
13253 err = check_cpuflags();
13254@@ -153,12 +153,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
13255 u32 eax, edx;
13256 u32 level = 1;
13257
13258- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13259- asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
13260- asm("cpuid"
13261+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13262+ asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
13263+ asm volatile("cpuid"
13264 : "+a" (level), "=d" (cpu.flags[0])
13265 : : "ecx", "ebx");
13266- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13267+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13268
13269 err = check_cpuflags();
13270 } else if (err == 0x01 &&
13271diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
13272index 16ef025..91e033b 100644
13273--- a/arch/x86/boot/header.S
13274+++ b/arch/x86/boot/header.S
13275@@ -438,10 +438,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
13276 # single linked list of
13277 # struct setup_data
13278
13279-pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
13280+pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
13281
13282 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
13283+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
13284+#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
13285+#else
13286 #define VO_INIT_SIZE (VO__end - VO__text)
13287+#endif
13288 #if ZO_INIT_SIZE > VO_INIT_SIZE
13289 #define INIT_SIZE ZO_INIT_SIZE
13290 #else
13291diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
13292index db75d07..8e6d0af 100644
13293--- a/arch/x86/boot/memory.c
13294+++ b/arch/x86/boot/memory.c
13295@@ -19,7 +19,7 @@
13296
13297 static int detect_memory_e820(void)
13298 {
13299- int count = 0;
13300+ unsigned int count = 0;
13301 struct biosregs ireg, oreg;
13302 struct e820entry *desc = boot_params.e820_map;
13303 static struct e820entry buf; /* static so it is zeroed */
13304diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
13305index ba3e100..6501b8f 100644
13306--- a/arch/x86/boot/video-vesa.c
13307+++ b/arch/x86/boot/video-vesa.c
13308@@ -201,6 +201,7 @@ static void vesa_store_pm_info(void)
13309
13310 boot_params.screen_info.vesapm_seg = oreg.es;
13311 boot_params.screen_info.vesapm_off = oreg.di;
13312+ boot_params.screen_info.vesapm_size = oreg.cx;
13313 }
13314
13315 /*
13316diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
13317index 05111bb..a1ae1f0 100644
13318--- a/arch/x86/boot/video.c
13319+++ b/arch/x86/boot/video.c
13320@@ -98,7 +98,7 @@ static void store_mode_params(void)
13321 static unsigned int get_entry(void)
13322 {
13323 char entry_buf[4];
13324- int i, len = 0;
13325+ unsigned int i, len = 0;
13326 int key;
13327 unsigned int v;
13328
13329diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
13330index 9105655..41779c1 100644
13331--- a/arch/x86/crypto/aes-x86_64-asm_64.S
13332+++ b/arch/x86/crypto/aes-x86_64-asm_64.S
13333@@ -8,6 +8,8 @@
13334 * including this sentence is retained in full.
13335 */
13336
13337+#include <asm/alternative-asm.h>
13338+
13339 .extern crypto_ft_tab
13340 .extern crypto_it_tab
13341 .extern crypto_fl_tab
13342@@ -70,6 +72,8 @@
13343 je B192; \
13344 leaq 32(r9),r9;
13345
13346+#define ret pax_force_retaddr; ret
13347+
13348 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
13349 movq r1,r2; \
13350 movq r3,r4; \
13351diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
13352index 6bd2c6c..368c93e 100644
13353--- a/arch/x86/crypto/aesni-intel_asm.S
13354+++ b/arch/x86/crypto/aesni-intel_asm.S
13355@@ -31,6 +31,7 @@
13356
13357 #include <linux/linkage.h>
13358 #include <asm/inst.h>
13359+#include <asm/alternative-asm.h>
13360
13361 /*
13362 * The following macros are used to move an (un)aligned 16 byte value to/from
13363@@ -217,7 +218,7 @@ enc: .octa 0x2
13364 * num_initial_blocks = b mod 4
13365 * encrypt the initial num_initial_blocks blocks and apply ghash on
13366 * the ciphertext
13367-* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13368+* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13369 * are clobbered
13370 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
13371 */
13372@@ -227,8 +228,8 @@ enc: .octa 0x2
13373 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
13374 MOVADQ SHUF_MASK(%rip), %xmm14
13375 mov arg7, %r10 # %r10 = AAD
13376- mov arg8, %r12 # %r12 = aadLen
13377- mov %r12, %r11
13378+ mov arg8, %r15 # %r15 = aadLen
13379+ mov %r15, %r11
13380 pxor %xmm\i, %xmm\i
13381
13382 _get_AAD_loop\num_initial_blocks\operation:
13383@@ -237,17 +238,17 @@ _get_AAD_loop\num_initial_blocks\operation:
13384 psrldq $4, %xmm\i
13385 pxor \TMP1, %xmm\i
13386 add $4, %r10
13387- sub $4, %r12
13388+ sub $4, %r15
13389 jne _get_AAD_loop\num_initial_blocks\operation
13390
13391 cmp $16, %r11
13392 je _get_AAD_loop2_done\num_initial_blocks\operation
13393
13394- mov $16, %r12
13395+ mov $16, %r15
13396 _get_AAD_loop2\num_initial_blocks\operation:
13397 psrldq $4, %xmm\i
13398- sub $4, %r12
13399- cmp %r11, %r12
13400+ sub $4, %r15
13401+ cmp %r11, %r15
13402 jne _get_AAD_loop2\num_initial_blocks\operation
13403
13404 _get_AAD_loop2_done\num_initial_blocks\operation:
13405@@ -442,7 +443,7 @@ _initial_blocks_done\num_initial_blocks\operation:
13406 * num_initial_blocks = b mod 4
13407 * encrypt the initial num_initial_blocks blocks and apply ghash on
13408 * the ciphertext
13409-* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13410+* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13411 * are clobbered
13412 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
13413 */
13414@@ -452,8 +453,8 @@ _initial_blocks_done\num_initial_blocks\operation:
13415 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
13416 MOVADQ SHUF_MASK(%rip), %xmm14
13417 mov arg7, %r10 # %r10 = AAD
13418- mov arg8, %r12 # %r12 = aadLen
13419- mov %r12, %r11
13420+ mov arg8, %r15 # %r15 = aadLen
13421+ mov %r15, %r11
13422 pxor %xmm\i, %xmm\i
13423 _get_AAD_loop\num_initial_blocks\operation:
13424 movd (%r10), \TMP1
13425@@ -461,15 +462,15 @@ _get_AAD_loop\num_initial_blocks\operation:
13426 psrldq $4, %xmm\i
13427 pxor \TMP1, %xmm\i
13428 add $4, %r10
13429- sub $4, %r12
13430+ sub $4, %r15
13431 jne _get_AAD_loop\num_initial_blocks\operation
13432 cmp $16, %r11
13433 je _get_AAD_loop2_done\num_initial_blocks\operation
13434- mov $16, %r12
13435+ mov $16, %r15
13436 _get_AAD_loop2\num_initial_blocks\operation:
13437 psrldq $4, %xmm\i
13438- sub $4, %r12
13439- cmp %r11, %r12
13440+ sub $4, %r15
13441+ cmp %r11, %r15
13442 jne _get_AAD_loop2\num_initial_blocks\operation
13443 _get_AAD_loop2_done\num_initial_blocks\operation:
13444 PSHUFB_XMM %xmm14, %xmm\i # byte-reflect the AAD data
13445@@ -1280,7 +1281,7 @@ _esb_loop_\@:
13446 *
13447 *****************************************************************************/
13448 ENTRY(aesni_gcm_dec)
13449- push %r12
13450+ push %r15
13451 push %r13
13452 push %r14
13453 mov %rsp, %r14
13454@@ -1290,8 +1291,8 @@ ENTRY(aesni_gcm_dec)
13455 */
13456 sub $VARIABLE_OFFSET, %rsp
13457 and $~63, %rsp # align rsp to 64 bytes
13458- mov %arg6, %r12
13459- movdqu (%r12), %xmm13 # %xmm13 = HashKey
13460+ mov %arg6, %r15
13461+ movdqu (%r15), %xmm13 # %xmm13 = HashKey
13462 movdqa SHUF_MASK(%rip), %xmm2
13463 PSHUFB_XMM %xmm2, %xmm13
13464
13465@@ -1319,10 +1320,10 @@ ENTRY(aesni_gcm_dec)
13466 movdqa %xmm13, HashKey(%rsp) # store HashKey<<1 (mod poly)
13467 mov %arg4, %r13 # save the number of bytes of plaintext/ciphertext
13468 and $-16, %r13 # %r13 = %r13 - (%r13 mod 16)
13469- mov %r13, %r12
13470- and $(3<<4), %r12
13471+ mov %r13, %r15
13472+ and $(3<<4), %r15
13473 jz _initial_num_blocks_is_0_decrypt
13474- cmp $(2<<4), %r12
13475+ cmp $(2<<4), %r15
13476 jb _initial_num_blocks_is_1_decrypt
13477 je _initial_num_blocks_is_2_decrypt
13478 _initial_num_blocks_is_3_decrypt:
13479@@ -1372,16 +1373,16 @@ _zero_cipher_left_decrypt:
13480 sub $16, %r11
13481 add %r13, %r11
13482 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte block
13483- lea SHIFT_MASK+16(%rip), %r12
13484- sub %r13, %r12
13485+ lea SHIFT_MASK+16(%rip), %r15
13486+ sub %r13, %r15
13487 # adjust the shuffle mask pointer to be able to shift 16-%r13 bytes
13488 # (%r13 is the number of bytes in plaintext mod 16)
13489- movdqu (%r12), %xmm2 # get the appropriate shuffle mask
13490+ movdqu (%r15), %xmm2 # get the appropriate shuffle mask
13491 PSHUFB_XMM %xmm2, %xmm1 # right shift 16-%r13 butes
13492
13493 movdqa %xmm1, %xmm2
13494 pxor %xmm1, %xmm0 # Ciphertext XOR E(K, Yn)
13495- movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
13496+ movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
13497 # get the appropriate mask to mask out top 16-%r13 bytes of %xmm0
13498 pand %xmm1, %xmm0 # mask out top 16-%r13 bytes of %xmm0
13499 pand %xmm1, %xmm2
13500@@ -1410,9 +1411,9 @@ _less_than_8_bytes_left_decrypt:
13501 sub $1, %r13
13502 jne _less_than_8_bytes_left_decrypt
13503 _multiple_of_16_bytes_decrypt:
13504- mov arg8, %r12 # %r13 = aadLen (number of bytes)
13505- shl $3, %r12 # convert into number of bits
13506- movd %r12d, %xmm15 # len(A) in %xmm15
13507+ mov arg8, %r15 # %r13 = aadLen (number of bytes)
13508+ shl $3, %r15 # convert into number of bits
13509+ movd %r15d, %xmm15 # len(A) in %xmm15
13510 shl $3, %arg4 # len(C) in bits (*128)
13511 MOVQ_R64_XMM %arg4, %xmm1
13512 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
13513@@ -1451,7 +1452,8 @@ _return_T_done_decrypt:
13514 mov %r14, %rsp
13515 pop %r14
13516 pop %r13
13517- pop %r12
13518+ pop %r15
13519+ pax_force_retaddr
13520 ret
13521 ENDPROC(aesni_gcm_dec)
13522
13523@@ -1540,7 +1542,7 @@ ENDPROC(aesni_gcm_dec)
13524 * poly = x^128 + x^127 + x^126 + x^121 + 1
13525 ***************************************************************************/
13526 ENTRY(aesni_gcm_enc)
13527- push %r12
13528+ push %r15
13529 push %r13
13530 push %r14
13531 mov %rsp, %r14
13532@@ -1550,8 +1552,8 @@ ENTRY(aesni_gcm_enc)
13533 #
13534 sub $VARIABLE_OFFSET, %rsp
13535 and $~63, %rsp
13536- mov %arg6, %r12
13537- movdqu (%r12), %xmm13
13538+ mov %arg6, %r15
13539+ movdqu (%r15), %xmm13
13540 movdqa SHUF_MASK(%rip), %xmm2
13541 PSHUFB_XMM %xmm2, %xmm13
13542
13543@@ -1575,13 +1577,13 @@ ENTRY(aesni_gcm_enc)
13544 movdqa %xmm13, HashKey(%rsp)
13545 mov %arg4, %r13 # %xmm13 holds HashKey<<1 (mod poly)
13546 and $-16, %r13
13547- mov %r13, %r12
13548+ mov %r13, %r15
13549
13550 # Encrypt first few blocks
13551
13552- and $(3<<4), %r12
13553+ and $(3<<4), %r15
13554 jz _initial_num_blocks_is_0_encrypt
13555- cmp $(2<<4), %r12
13556+ cmp $(2<<4), %r15
13557 jb _initial_num_blocks_is_1_encrypt
13558 je _initial_num_blocks_is_2_encrypt
13559 _initial_num_blocks_is_3_encrypt:
13560@@ -1634,14 +1636,14 @@ _zero_cipher_left_encrypt:
13561 sub $16, %r11
13562 add %r13, %r11
13563 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte blocks
13564- lea SHIFT_MASK+16(%rip), %r12
13565- sub %r13, %r12
13566+ lea SHIFT_MASK+16(%rip), %r15
13567+ sub %r13, %r15
13568 # adjust the shuffle mask pointer to be able to shift 16-r13 bytes
13569 # (%r13 is the number of bytes in plaintext mod 16)
13570- movdqu (%r12), %xmm2 # get the appropriate shuffle mask
13571+ movdqu (%r15), %xmm2 # get the appropriate shuffle mask
13572 PSHUFB_XMM %xmm2, %xmm1 # shift right 16-r13 byte
13573 pxor %xmm1, %xmm0 # Plaintext XOR Encrypt(K, Yn)
13574- movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
13575+ movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
13576 # get the appropriate mask to mask out top 16-r13 bytes of xmm0
13577 pand %xmm1, %xmm0 # mask out top 16-r13 bytes of xmm0
13578 movdqa SHUF_MASK(%rip), %xmm10
13579@@ -1674,9 +1676,9 @@ _less_than_8_bytes_left_encrypt:
13580 sub $1, %r13
13581 jne _less_than_8_bytes_left_encrypt
13582 _multiple_of_16_bytes_encrypt:
13583- mov arg8, %r12 # %r12 = addLen (number of bytes)
13584- shl $3, %r12
13585- movd %r12d, %xmm15 # len(A) in %xmm15
13586+ mov arg8, %r15 # %r15 = addLen (number of bytes)
13587+ shl $3, %r15
13588+ movd %r15d, %xmm15 # len(A) in %xmm15
13589 shl $3, %arg4 # len(C) in bits (*128)
13590 MOVQ_R64_XMM %arg4, %xmm1
13591 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
13592@@ -1715,7 +1717,8 @@ _return_T_done_encrypt:
13593 mov %r14, %rsp
13594 pop %r14
13595 pop %r13
13596- pop %r12
13597+ pop %r15
13598+ pax_force_retaddr
13599 ret
13600 ENDPROC(aesni_gcm_enc)
13601
13602@@ -1733,6 +1736,7 @@ _key_expansion_256a:
13603 pxor %xmm1, %xmm0
13604 movaps %xmm0, (TKEYP)
13605 add $0x10, TKEYP
13606+ pax_force_retaddr
13607 ret
13608 ENDPROC(_key_expansion_128)
13609 ENDPROC(_key_expansion_256a)
13610@@ -1759,6 +1763,7 @@ _key_expansion_192a:
13611 shufps $0b01001110, %xmm2, %xmm1
13612 movaps %xmm1, 0x10(TKEYP)
13613 add $0x20, TKEYP
13614+ pax_force_retaddr
13615 ret
13616 ENDPROC(_key_expansion_192a)
13617
13618@@ -1779,6 +1784,7 @@ _key_expansion_192b:
13619
13620 movaps %xmm0, (TKEYP)
13621 add $0x10, TKEYP
13622+ pax_force_retaddr
13623 ret
13624 ENDPROC(_key_expansion_192b)
13625
13626@@ -1792,6 +1798,7 @@ _key_expansion_256b:
13627 pxor %xmm1, %xmm2
13628 movaps %xmm2, (TKEYP)
13629 add $0x10, TKEYP
13630+ pax_force_retaddr
13631 ret
13632 ENDPROC(_key_expansion_256b)
13633
13634@@ -1905,6 +1912,7 @@ ENTRY(aesni_set_key)
13635 #ifndef __x86_64__
13636 popl KEYP
13637 #endif
13638+ pax_force_retaddr
13639 ret
13640 ENDPROC(aesni_set_key)
13641
13642@@ -1927,6 +1935,7 @@ ENTRY(aesni_enc)
13643 popl KLEN
13644 popl KEYP
13645 #endif
13646+ pax_force_retaddr
13647 ret
13648 ENDPROC(aesni_enc)
13649
13650@@ -1985,6 +1994,7 @@ _aesni_enc1:
13651 AESENC KEY STATE
13652 movaps 0x70(TKEYP), KEY
13653 AESENCLAST KEY STATE
13654+ pax_force_retaddr
13655 ret
13656 ENDPROC(_aesni_enc1)
13657
13658@@ -2094,6 +2104,7 @@ _aesni_enc4:
13659 AESENCLAST KEY STATE2
13660 AESENCLAST KEY STATE3
13661 AESENCLAST KEY STATE4
13662+ pax_force_retaddr
13663 ret
13664 ENDPROC(_aesni_enc4)
13665
13666@@ -2117,6 +2128,7 @@ ENTRY(aesni_dec)
13667 popl KLEN
13668 popl KEYP
13669 #endif
13670+ pax_force_retaddr
13671 ret
13672 ENDPROC(aesni_dec)
13673
13674@@ -2175,6 +2187,7 @@ _aesni_dec1:
13675 AESDEC KEY STATE
13676 movaps 0x70(TKEYP), KEY
13677 AESDECLAST KEY STATE
13678+ pax_force_retaddr
13679 ret
13680 ENDPROC(_aesni_dec1)
13681
13682@@ -2284,6 +2297,7 @@ _aesni_dec4:
13683 AESDECLAST KEY STATE2
13684 AESDECLAST KEY STATE3
13685 AESDECLAST KEY STATE4
13686+ pax_force_retaddr
13687 ret
13688 ENDPROC(_aesni_dec4)
13689
13690@@ -2342,6 +2356,7 @@ ENTRY(aesni_ecb_enc)
13691 popl KEYP
13692 popl LEN
13693 #endif
13694+ pax_force_retaddr
13695 ret
13696 ENDPROC(aesni_ecb_enc)
13697
13698@@ -2401,6 +2416,7 @@ ENTRY(aesni_ecb_dec)
13699 popl KEYP
13700 popl LEN
13701 #endif
13702+ pax_force_retaddr
13703 ret
13704 ENDPROC(aesni_ecb_dec)
13705
13706@@ -2443,6 +2459,7 @@ ENTRY(aesni_cbc_enc)
13707 popl LEN
13708 popl IVP
13709 #endif
13710+ pax_force_retaddr
13711 ret
13712 ENDPROC(aesni_cbc_enc)
13713
13714@@ -2534,6 +2551,7 @@ ENTRY(aesni_cbc_dec)
13715 popl LEN
13716 popl IVP
13717 #endif
13718+ pax_force_retaddr
13719 ret
13720 ENDPROC(aesni_cbc_dec)
13721
13722@@ -2561,6 +2579,7 @@ _aesni_inc_init:
13723 mov $1, TCTR_LOW
13724 MOVQ_R64_XMM TCTR_LOW INC
13725 MOVQ_R64_XMM CTR TCTR_LOW
13726+ pax_force_retaddr
13727 ret
13728 ENDPROC(_aesni_inc_init)
13729
13730@@ -2590,6 +2609,7 @@ _aesni_inc:
13731 .Linc_low:
13732 movaps CTR, IV
13733 PSHUFB_XMM BSWAP_MASK IV
13734+ pax_force_retaddr
13735 ret
13736 ENDPROC(_aesni_inc)
13737
13738@@ -2651,6 +2671,7 @@ ENTRY(aesni_ctr_enc)
13739 .Lctr_enc_ret:
13740 movups IV, (IVP)
13741 .Lctr_enc_just_ret:
13742+ pax_force_retaddr
13743 ret
13744 ENDPROC(aesni_ctr_enc)
13745
13746@@ -2777,6 +2798,7 @@ ENTRY(aesni_xts_crypt8)
13747 pxor INC, STATE4
13748 movdqu STATE4, 0x70(OUTP)
13749
13750+ pax_force_retaddr
13751 ret
13752 ENDPROC(aesni_xts_crypt8)
13753
13754diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
13755index 246c670..466e2d6 100644
13756--- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
13757+++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
13758@@ -21,6 +21,7 @@
13759 */
13760
13761 #include <linux/linkage.h>
13762+#include <asm/alternative-asm.h>
13763
13764 .file "blowfish-x86_64-asm.S"
13765 .text
13766@@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
13767 jnz .L__enc_xor;
13768
13769 write_block();
13770+ pax_force_retaddr
13771 ret;
13772 .L__enc_xor:
13773 xor_block();
13774+ pax_force_retaddr
13775 ret;
13776 ENDPROC(__blowfish_enc_blk)
13777
13778@@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
13779
13780 movq %r11, %rbp;
13781
13782+ pax_force_retaddr
13783 ret;
13784 ENDPROC(blowfish_dec_blk)
13785
13786@@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
13787
13788 popq %rbx;
13789 popq %rbp;
13790+ pax_force_retaddr
13791 ret;
13792
13793 .L__enc_xor4:
13794@@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
13795
13796 popq %rbx;
13797 popq %rbp;
13798+ pax_force_retaddr
13799 ret;
13800 ENDPROC(__blowfish_enc_blk_4way)
13801
13802@@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
13803 popq %rbx;
13804 popq %rbp;
13805
13806+ pax_force_retaddr
13807 ret;
13808 ENDPROC(blowfish_dec_blk_4way)
13809diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13810index ce71f92..1dce7ec 100644
13811--- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13812+++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13813@@ -16,6 +16,7 @@
13814 */
13815
13816 #include <linux/linkage.h>
13817+#include <asm/alternative-asm.h>
13818
13819 #define CAMELLIA_TABLE_BYTE_LEN 272
13820
13821@@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
13822 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
13823 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
13824 %rcx, (%r9));
13825+ pax_force_retaddr
13826 ret;
13827 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
13828
13829@@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
13830 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
13831 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
13832 %rax, (%r9));
13833+ pax_force_retaddr
13834 ret;
13835 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
13836
13837@@ -780,6 +783,7 @@ __camellia_enc_blk16:
13838 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
13839 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
13840
13841+ pax_force_retaddr
13842 ret;
13843
13844 .align 8
13845@@ -865,6 +869,7 @@ __camellia_dec_blk16:
13846 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
13847 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
13848
13849+ pax_force_retaddr
13850 ret;
13851
13852 .align 8
13853@@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
13854 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13855 %xmm8, %rsi);
13856
13857+ pax_force_retaddr
13858 ret;
13859 ENDPROC(camellia_ecb_enc_16way)
13860
13861@@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
13862 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13863 %xmm8, %rsi);
13864
13865+ pax_force_retaddr
13866 ret;
13867 ENDPROC(camellia_ecb_dec_16way)
13868
13869@@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
13870 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13871 %xmm8, %rsi);
13872
13873+ pax_force_retaddr
13874 ret;
13875 ENDPROC(camellia_cbc_dec_16way)
13876
13877@@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
13878 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13879 %xmm8, %rsi);
13880
13881+ pax_force_retaddr
13882 ret;
13883 ENDPROC(camellia_ctr_16way)
13884
13885@@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
13886 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13887 %xmm8, %rsi);
13888
13889+ pax_force_retaddr
13890 ret;
13891 ENDPROC(camellia_xts_crypt_16way)
13892
13893diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13894index 0e0b886..5a3123c 100644
13895--- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13896+++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13897@@ -11,6 +11,7 @@
13898 */
13899
13900 #include <linux/linkage.h>
13901+#include <asm/alternative-asm.h>
13902
13903 #define CAMELLIA_TABLE_BYTE_LEN 272
13904
13905@@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
13906 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
13907 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
13908 %rcx, (%r9));
13909+ pax_force_retaddr
13910 ret;
13911 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
13912
13913@@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
13914 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
13915 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
13916 %rax, (%r9));
13917+ pax_force_retaddr
13918 ret;
13919 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
13920
13921@@ -820,6 +823,7 @@ __camellia_enc_blk32:
13922 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
13923 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
13924
13925+ pax_force_retaddr
13926 ret;
13927
13928 .align 8
13929@@ -905,6 +909,7 @@ __camellia_dec_blk32:
13930 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
13931 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
13932
13933+ pax_force_retaddr
13934 ret;
13935
13936 .align 8
13937@@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
13938
13939 vzeroupper;
13940
13941+ pax_force_retaddr
13942 ret;
13943 ENDPROC(camellia_ecb_enc_32way)
13944
13945@@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
13946
13947 vzeroupper;
13948
13949+ pax_force_retaddr
13950 ret;
13951 ENDPROC(camellia_ecb_dec_32way)
13952
13953@@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
13954
13955 vzeroupper;
13956
13957+ pax_force_retaddr
13958 ret;
13959 ENDPROC(camellia_cbc_dec_32way)
13960
13961@@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
13962
13963 vzeroupper;
13964
13965+ pax_force_retaddr
13966 ret;
13967 ENDPROC(camellia_ctr_32way)
13968
13969@@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
13970
13971 vzeroupper;
13972
13973+ pax_force_retaddr
13974 ret;
13975 ENDPROC(camellia_xts_crypt_32way)
13976
13977diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
13978index 310319c..db3d7b5 100644
13979--- a/arch/x86/crypto/camellia-x86_64-asm_64.S
13980+++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
13981@@ -21,6 +21,7 @@
13982 */
13983
13984 #include <linux/linkage.h>
13985+#include <asm/alternative-asm.h>
13986
13987 .file "camellia-x86_64-asm_64.S"
13988 .text
13989@@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
13990 enc_outunpack(mov, RT1);
13991
13992 movq RRBP, %rbp;
13993+ pax_force_retaddr
13994 ret;
13995
13996 .L__enc_xor:
13997 enc_outunpack(xor, RT1);
13998
13999 movq RRBP, %rbp;
14000+ pax_force_retaddr
14001 ret;
14002 ENDPROC(__camellia_enc_blk)
14003
14004@@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
14005 dec_outunpack();
14006
14007 movq RRBP, %rbp;
14008+ pax_force_retaddr
14009 ret;
14010 ENDPROC(camellia_dec_blk)
14011
14012@@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
14013
14014 movq RRBP, %rbp;
14015 popq %rbx;
14016+ pax_force_retaddr
14017 ret;
14018
14019 .L__enc2_xor:
14020@@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
14021
14022 movq RRBP, %rbp;
14023 popq %rbx;
14024+ pax_force_retaddr
14025 ret;
14026 ENDPROC(__camellia_enc_blk_2way)
14027
14028@@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
14029
14030 movq RRBP, %rbp;
14031 movq RXOR, %rbx;
14032+ pax_force_retaddr
14033 ret;
14034 ENDPROC(camellia_dec_blk_2way)
14035diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
14036index c35fd5d..2d8c7db 100644
14037--- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
14038+++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
14039@@ -24,6 +24,7 @@
14040 */
14041
14042 #include <linux/linkage.h>
14043+#include <asm/alternative-asm.h>
14044
14045 .file "cast5-avx-x86_64-asm_64.S"
14046
14047@@ -281,6 +282,7 @@ __cast5_enc_blk16:
14048 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
14049 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
14050
14051+ pax_force_retaddr
14052 ret;
14053 ENDPROC(__cast5_enc_blk16)
14054
14055@@ -352,6 +354,7 @@ __cast5_dec_blk16:
14056 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
14057 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
14058
14059+ pax_force_retaddr
14060 ret;
14061
14062 .L__skip_dec:
14063@@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
14064 vmovdqu RR4, (6*4*4)(%r11);
14065 vmovdqu RL4, (7*4*4)(%r11);
14066
14067+ pax_force_retaddr
14068 ret;
14069 ENDPROC(cast5_ecb_enc_16way)
14070
14071@@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
14072 vmovdqu RR4, (6*4*4)(%r11);
14073 vmovdqu RL4, (7*4*4)(%r11);
14074
14075+ pax_force_retaddr
14076 ret;
14077 ENDPROC(cast5_ecb_dec_16way)
14078
14079@@ -430,10 +435,10 @@ ENTRY(cast5_cbc_dec_16way)
14080 * %rdx: src
14081 */
14082
14083- pushq %r12;
14084+ pushq %r14;
14085
14086 movq %rsi, %r11;
14087- movq %rdx, %r12;
14088+ movq %rdx, %r14;
14089
14090 vmovdqu (0*16)(%rdx), RL1;
14091 vmovdqu (1*16)(%rdx), RR1;
14092@@ -447,16 +452,16 @@ ENTRY(cast5_cbc_dec_16way)
14093 call __cast5_dec_blk16;
14094
14095 /* xor with src */
14096- vmovq (%r12), RX;
14097+ vmovq (%r14), RX;
14098 vpshufd $0x4f, RX, RX;
14099 vpxor RX, RR1, RR1;
14100- vpxor 0*16+8(%r12), RL1, RL1;
14101- vpxor 1*16+8(%r12), RR2, RR2;
14102- vpxor 2*16+8(%r12), RL2, RL2;
14103- vpxor 3*16+8(%r12), RR3, RR3;
14104- vpxor 4*16+8(%r12), RL3, RL3;
14105- vpxor 5*16+8(%r12), RR4, RR4;
14106- vpxor 6*16+8(%r12), RL4, RL4;
14107+ vpxor 0*16+8(%r14), RL1, RL1;
14108+ vpxor 1*16+8(%r14), RR2, RR2;
14109+ vpxor 2*16+8(%r14), RL2, RL2;
14110+ vpxor 3*16+8(%r14), RR3, RR3;
14111+ vpxor 4*16+8(%r14), RL3, RL3;
14112+ vpxor 5*16+8(%r14), RR4, RR4;
14113+ vpxor 6*16+8(%r14), RL4, RL4;
14114
14115 vmovdqu RR1, (0*16)(%r11);
14116 vmovdqu RL1, (1*16)(%r11);
14117@@ -467,8 +472,9 @@ ENTRY(cast5_cbc_dec_16way)
14118 vmovdqu RR4, (6*16)(%r11);
14119 vmovdqu RL4, (7*16)(%r11);
14120
14121- popq %r12;
14122+ popq %r14;
14123
14124+ pax_force_retaddr
14125 ret;
14126 ENDPROC(cast5_cbc_dec_16way)
14127
14128@@ -480,10 +486,10 @@ ENTRY(cast5_ctr_16way)
14129 * %rcx: iv (big endian, 64bit)
14130 */
14131
14132- pushq %r12;
14133+ pushq %r14;
14134
14135 movq %rsi, %r11;
14136- movq %rdx, %r12;
14137+ movq %rdx, %r14;
14138
14139 vpcmpeqd RTMP, RTMP, RTMP;
14140 vpsrldq $8, RTMP, RTMP; /* low: -1, high: 0 */
14141@@ -523,14 +529,14 @@ ENTRY(cast5_ctr_16way)
14142 call __cast5_enc_blk16;
14143
14144 /* dst = src ^ iv */
14145- vpxor (0*16)(%r12), RR1, RR1;
14146- vpxor (1*16)(%r12), RL1, RL1;
14147- vpxor (2*16)(%r12), RR2, RR2;
14148- vpxor (3*16)(%r12), RL2, RL2;
14149- vpxor (4*16)(%r12), RR3, RR3;
14150- vpxor (5*16)(%r12), RL3, RL3;
14151- vpxor (6*16)(%r12), RR4, RR4;
14152- vpxor (7*16)(%r12), RL4, RL4;
14153+ vpxor (0*16)(%r14), RR1, RR1;
14154+ vpxor (1*16)(%r14), RL1, RL1;
14155+ vpxor (2*16)(%r14), RR2, RR2;
14156+ vpxor (3*16)(%r14), RL2, RL2;
14157+ vpxor (4*16)(%r14), RR3, RR3;
14158+ vpxor (5*16)(%r14), RL3, RL3;
14159+ vpxor (6*16)(%r14), RR4, RR4;
14160+ vpxor (7*16)(%r14), RL4, RL4;
14161 vmovdqu RR1, (0*16)(%r11);
14162 vmovdqu RL1, (1*16)(%r11);
14163 vmovdqu RR2, (2*16)(%r11);
14164@@ -540,7 +546,8 @@ ENTRY(cast5_ctr_16way)
14165 vmovdqu RR4, (6*16)(%r11);
14166 vmovdqu RL4, (7*16)(%r11);
14167
14168- popq %r12;
14169+ popq %r14;
14170
14171+ pax_force_retaddr
14172 ret;
14173 ENDPROC(cast5_ctr_16way)
14174diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
14175index e3531f8..e123f35 100644
14176--- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
14177+++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
14178@@ -24,6 +24,7 @@
14179 */
14180
14181 #include <linux/linkage.h>
14182+#include <asm/alternative-asm.h>
14183 #include "glue_helper-asm-avx.S"
14184
14185 .file "cast6-avx-x86_64-asm_64.S"
14186@@ -295,6 +296,7 @@ __cast6_enc_blk8:
14187 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
14188 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
14189
14190+ pax_force_retaddr
14191 ret;
14192 ENDPROC(__cast6_enc_blk8)
14193
14194@@ -340,6 +342,7 @@ __cast6_dec_blk8:
14195 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
14196 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
14197
14198+ pax_force_retaddr
14199 ret;
14200 ENDPROC(__cast6_dec_blk8)
14201
14202@@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
14203
14204 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14205
14206+ pax_force_retaddr
14207 ret;
14208 ENDPROC(cast6_ecb_enc_8way)
14209
14210@@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
14211
14212 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14213
14214+ pax_force_retaddr
14215 ret;
14216 ENDPROC(cast6_ecb_dec_8way)
14217
14218@@ -386,19 +391,20 @@ ENTRY(cast6_cbc_dec_8way)
14219 * %rdx: src
14220 */
14221
14222- pushq %r12;
14223+ pushq %r14;
14224
14225 movq %rsi, %r11;
14226- movq %rdx, %r12;
14227+ movq %rdx, %r14;
14228
14229 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14230
14231 call __cast6_dec_blk8;
14232
14233- store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14234+ store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14235
14236- popq %r12;
14237+ popq %r14;
14238
14239+ pax_force_retaddr
14240 ret;
14241 ENDPROC(cast6_cbc_dec_8way)
14242
14243@@ -410,20 +416,21 @@ ENTRY(cast6_ctr_8way)
14244 * %rcx: iv (little endian, 128bit)
14245 */
14246
14247- pushq %r12;
14248+ pushq %r14;
14249
14250 movq %rsi, %r11;
14251- movq %rdx, %r12;
14252+ movq %rdx, %r14;
14253
14254 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
14255 RD2, RX, RKR, RKM);
14256
14257 call __cast6_enc_blk8;
14258
14259- store_ctr_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14260+ store_ctr_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14261
14262- popq %r12;
14263+ popq %r14;
14264
14265+ pax_force_retaddr
14266 ret;
14267 ENDPROC(cast6_ctr_8way)
14268
14269@@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
14270 /* dst <= regs xor IVs(in dst) */
14271 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14272
14273+ pax_force_retaddr
14274 ret;
14275 ENDPROC(cast6_xts_enc_8way)
14276
14277@@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
14278 /* dst <= regs xor IVs(in dst) */
14279 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14280
14281+ pax_force_retaddr
14282 ret;
14283 ENDPROC(cast6_xts_dec_8way)
14284diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
14285index 225be06..2885e731 100644
14286--- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
14287+++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
14288@@ -45,6 +45,7 @@
14289
14290 #include <asm/inst.h>
14291 #include <linux/linkage.h>
14292+#include <asm/alternative-asm.h>
14293
14294 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
14295
14296@@ -309,6 +310,7 @@ do_return:
14297 popq %rsi
14298 popq %rdi
14299 popq %rbx
14300+ pax_force_retaddr
14301 ret
14302
14303 ################################################################
14304@@ -330,7 +332,7 @@ ENDPROC(crc_pcl)
14305 ## PCLMULQDQ tables
14306 ## Table is 128 entries x 2 words (8 bytes) each
14307 ################################################################
14308-.section .rotata, "a", %progbits
14309+.section .rodata, "a", %progbits
14310 .align 8
14311 K_table:
14312 .long 0x493c7d27, 0x00000001
14313diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
14314index 5d1e007..098cb4f 100644
14315--- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
14316+++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
14317@@ -18,6 +18,7 @@
14318
14319 #include <linux/linkage.h>
14320 #include <asm/inst.h>
14321+#include <asm/alternative-asm.h>
14322
14323 .data
14324
14325@@ -89,6 +90,7 @@ __clmul_gf128mul_ble:
14326 psrlq $1, T2
14327 pxor T2, T1
14328 pxor T1, DATA
14329+ pax_force_retaddr
14330 ret
14331 ENDPROC(__clmul_gf128mul_ble)
14332
14333@@ -101,6 +103,7 @@ ENTRY(clmul_ghash_mul)
14334 call __clmul_gf128mul_ble
14335 PSHUFB_XMM BSWAP DATA
14336 movups DATA, (%rdi)
14337+ pax_force_retaddr
14338 ret
14339 ENDPROC(clmul_ghash_mul)
14340
14341@@ -128,5 +131,6 @@ ENTRY(clmul_ghash_update)
14342 PSHUFB_XMM BSWAP DATA
14343 movups DATA, (%rdi)
14344 .Lupdate_just_ret:
14345+ pax_force_retaddr
14346 ret
14347 ENDPROC(clmul_ghash_update)
14348diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
14349index 9279e0b..c4b3d2c 100644
14350--- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
14351+++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
14352@@ -1,4 +1,5 @@
14353 #include <linux/linkage.h>
14354+#include <asm/alternative-asm.h>
14355
14356 # enter salsa20_encrypt_bytes
14357 ENTRY(salsa20_encrypt_bytes)
14358@@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
14359 add %r11,%rsp
14360 mov %rdi,%rax
14361 mov %rsi,%rdx
14362+ pax_force_retaddr
14363 ret
14364 # bytesatleast65:
14365 ._bytesatleast65:
14366@@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
14367 add %r11,%rsp
14368 mov %rdi,%rax
14369 mov %rsi,%rdx
14370+ pax_force_retaddr
14371 ret
14372 ENDPROC(salsa20_keysetup)
14373
14374@@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
14375 add %r11,%rsp
14376 mov %rdi,%rax
14377 mov %rsi,%rdx
14378+ pax_force_retaddr
14379 ret
14380 ENDPROC(salsa20_ivsetup)
14381diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
14382index 2f202f4..d9164d6 100644
14383--- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
14384+++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
14385@@ -24,6 +24,7 @@
14386 */
14387
14388 #include <linux/linkage.h>
14389+#include <asm/alternative-asm.h>
14390 #include "glue_helper-asm-avx.S"
14391
14392 .file "serpent-avx-x86_64-asm_64.S"
14393@@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
14394 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14395 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14396
14397+ pax_force_retaddr
14398 ret;
14399 ENDPROC(__serpent_enc_blk8_avx)
14400
14401@@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
14402 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
14403 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
14404
14405+ pax_force_retaddr
14406 ret;
14407 ENDPROC(__serpent_dec_blk8_avx)
14408
14409@@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
14410
14411 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14412
14413+ pax_force_retaddr
14414 ret;
14415 ENDPROC(serpent_ecb_enc_8way_avx)
14416
14417@@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
14418
14419 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
14420
14421+ pax_force_retaddr
14422 ret;
14423 ENDPROC(serpent_ecb_dec_8way_avx)
14424
14425@@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
14426
14427 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
14428
14429+ pax_force_retaddr
14430 ret;
14431 ENDPROC(serpent_cbc_dec_8way_avx)
14432
14433@@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
14434
14435 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14436
14437+ pax_force_retaddr
14438 ret;
14439 ENDPROC(serpent_ctr_8way_avx)
14440
14441@@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
14442 /* dst <= regs xor IVs(in dst) */
14443 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14444
14445+ pax_force_retaddr
14446 ret;
14447 ENDPROC(serpent_xts_enc_8way_avx)
14448
14449@@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
14450 /* dst <= regs xor IVs(in dst) */
14451 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
14452
14453+ pax_force_retaddr
14454 ret;
14455 ENDPROC(serpent_xts_dec_8way_avx)
14456diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
14457index b222085..abd483c 100644
14458--- a/arch/x86/crypto/serpent-avx2-asm_64.S
14459+++ b/arch/x86/crypto/serpent-avx2-asm_64.S
14460@@ -15,6 +15,7 @@
14461 */
14462
14463 #include <linux/linkage.h>
14464+#include <asm/alternative-asm.h>
14465 #include "glue_helper-asm-avx2.S"
14466
14467 .file "serpent-avx2-asm_64.S"
14468@@ -610,6 +611,7 @@ __serpent_enc_blk16:
14469 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14470 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14471
14472+ pax_force_retaddr
14473 ret;
14474 ENDPROC(__serpent_enc_blk16)
14475
14476@@ -664,6 +666,7 @@ __serpent_dec_blk16:
14477 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
14478 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
14479
14480+ pax_force_retaddr
14481 ret;
14482 ENDPROC(__serpent_dec_blk16)
14483
14484@@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
14485
14486 vzeroupper;
14487
14488+ pax_force_retaddr
14489 ret;
14490 ENDPROC(serpent_ecb_enc_16way)
14491
14492@@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
14493
14494 vzeroupper;
14495
14496+ pax_force_retaddr
14497 ret;
14498 ENDPROC(serpent_ecb_dec_16way)
14499
14500@@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
14501
14502 vzeroupper;
14503
14504+ pax_force_retaddr
14505 ret;
14506 ENDPROC(serpent_cbc_dec_16way)
14507
14508@@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
14509
14510 vzeroupper;
14511
14512+ pax_force_retaddr
14513 ret;
14514 ENDPROC(serpent_ctr_16way)
14515
14516@@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
14517
14518 vzeroupper;
14519
14520+ pax_force_retaddr
14521 ret;
14522 ENDPROC(serpent_xts_enc_16way)
14523
14524@@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
14525
14526 vzeroupper;
14527
14528+ pax_force_retaddr
14529 ret;
14530 ENDPROC(serpent_xts_dec_16way)
14531diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
14532index acc066c..1559cc4 100644
14533--- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
14534+++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
14535@@ -25,6 +25,7 @@
14536 */
14537
14538 #include <linux/linkage.h>
14539+#include <asm/alternative-asm.h>
14540
14541 .file "serpent-sse2-x86_64-asm_64.S"
14542 .text
14543@@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
14544 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14545 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14546
14547+ pax_force_retaddr
14548 ret;
14549
14550 .L__enc_xor8:
14551 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14552 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14553
14554+ pax_force_retaddr
14555 ret;
14556 ENDPROC(__serpent_enc_blk_8way)
14557
14558@@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
14559 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
14560 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
14561
14562+ pax_force_retaddr
14563 ret;
14564 ENDPROC(serpent_dec_blk_8way)
14565diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
14566index a410950..9dfe7ad 100644
14567--- a/arch/x86/crypto/sha1_ssse3_asm.S
14568+++ b/arch/x86/crypto/sha1_ssse3_asm.S
14569@@ -29,6 +29,7 @@
14570 */
14571
14572 #include <linux/linkage.h>
14573+#include <asm/alternative-asm.h>
14574
14575 #define CTX %rdi // arg1
14576 #define BUF %rsi // arg2
14577@@ -75,9 +76,9 @@
14578
14579 push %rbx
14580 push %rbp
14581- push %r12
14582+ push %r14
14583
14584- mov %rsp, %r12
14585+ mov %rsp, %r14
14586 sub $64, %rsp # allocate workspace
14587 and $~15, %rsp # align stack
14588
14589@@ -99,11 +100,12 @@
14590 xor %rax, %rax
14591 rep stosq
14592
14593- mov %r12, %rsp # deallocate workspace
14594+ mov %r14, %rsp # deallocate workspace
14595
14596- pop %r12
14597+ pop %r14
14598 pop %rbp
14599 pop %rbx
14600+ pax_force_retaddr
14601 ret
14602
14603 ENDPROC(\name)
14604diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
14605index 92b3b5d..0dc1dcb 100644
14606--- a/arch/x86/crypto/sha256-avx-asm.S
14607+++ b/arch/x86/crypto/sha256-avx-asm.S
14608@@ -49,6 +49,7 @@
14609
14610 #ifdef CONFIG_AS_AVX
14611 #include <linux/linkage.h>
14612+#include <asm/alternative-asm.h>
14613
14614 ## assume buffers not aligned
14615 #define VMOVDQ vmovdqu
14616@@ -460,6 +461,7 @@ done_hash:
14617 popq %r13
14618 popq %rbp
14619 popq %rbx
14620+ pax_force_retaddr
14621 ret
14622 ENDPROC(sha256_transform_avx)
14623
14624diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
14625index 570ec5e..cf2b625 100644
14626--- a/arch/x86/crypto/sha256-avx2-asm.S
14627+++ b/arch/x86/crypto/sha256-avx2-asm.S
14628@@ -50,6 +50,7 @@
14629
14630 #ifdef CONFIG_AS_AVX2
14631 #include <linux/linkage.h>
14632+#include <asm/alternative-asm.h>
14633
14634 ## assume buffers not aligned
14635 #define VMOVDQ vmovdqu
14636@@ -720,6 +721,7 @@ done_hash:
14637 popq %r12
14638 popq %rbp
14639 popq %rbx
14640+ pax_force_retaddr
14641 ret
14642 ENDPROC(sha256_transform_rorx)
14643
14644diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
14645index 2cedc44..5144899 100644
14646--- a/arch/x86/crypto/sha256-ssse3-asm.S
14647+++ b/arch/x86/crypto/sha256-ssse3-asm.S
14648@@ -47,6 +47,7 @@
14649 ########################################################################
14650
14651 #include <linux/linkage.h>
14652+#include <asm/alternative-asm.h>
14653
14654 ## assume buffers not aligned
14655 #define MOVDQ movdqu
14656@@ -471,6 +472,7 @@ done_hash:
14657 popq %rbp
14658 popq %rbx
14659
14660+ pax_force_retaddr
14661 ret
14662 ENDPROC(sha256_transform_ssse3)
14663
14664diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
14665index 565274d..af6bc08 100644
14666--- a/arch/x86/crypto/sha512-avx-asm.S
14667+++ b/arch/x86/crypto/sha512-avx-asm.S
14668@@ -49,6 +49,7 @@
14669
14670 #ifdef CONFIG_AS_AVX
14671 #include <linux/linkage.h>
14672+#include <asm/alternative-asm.h>
14673
14674 .text
14675
14676@@ -364,6 +365,7 @@ updateblock:
14677 mov frame_RSPSAVE(%rsp), %rsp
14678
14679 nowork:
14680+ pax_force_retaddr
14681 ret
14682 ENDPROC(sha512_transform_avx)
14683
14684diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
14685index 1f20b35..f25c8c1 100644
14686--- a/arch/x86/crypto/sha512-avx2-asm.S
14687+++ b/arch/x86/crypto/sha512-avx2-asm.S
14688@@ -51,6 +51,7 @@
14689
14690 #ifdef CONFIG_AS_AVX2
14691 #include <linux/linkage.h>
14692+#include <asm/alternative-asm.h>
14693
14694 .text
14695
14696@@ -678,6 +679,7 @@ done_hash:
14697
14698 # Restore Stack Pointer
14699 mov frame_RSPSAVE(%rsp), %rsp
14700+ pax_force_retaddr
14701 ret
14702 ENDPROC(sha512_transform_rorx)
14703
14704diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
14705index e610e29..ffcb5ed 100644
14706--- a/arch/x86/crypto/sha512-ssse3-asm.S
14707+++ b/arch/x86/crypto/sha512-ssse3-asm.S
14708@@ -48,6 +48,7 @@
14709 ########################################################################
14710
14711 #include <linux/linkage.h>
14712+#include <asm/alternative-asm.h>
14713
14714 .text
14715
14716@@ -363,6 +364,7 @@ updateblock:
14717 mov frame_RSPSAVE(%rsp), %rsp
14718
14719 nowork:
14720+ pax_force_retaddr
14721 ret
14722 ENDPROC(sha512_transform_ssse3)
14723
14724diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14725index 0505813..b067311 100644
14726--- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14727+++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14728@@ -24,6 +24,7 @@
14729 */
14730
14731 #include <linux/linkage.h>
14732+#include <asm/alternative-asm.h>
14733 #include "glue_helper-asm-avx.S"
14734
14735 .file "twofish-avx-x86_64-asm_64.S"
14736@@ -284,6 +285,7 @@ __twofish_enc_blk8:
14737 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
14738 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
14739
14740+ pax_force_retaddr
14741 ret;
14742 ENDPROC(__twofish_enc_blk8)
14743
14744@@ -324,6 +326,7 @@ __twofish_dec_blk8:
14745 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
14746 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
14747
14748+ pax_force_retaddr
14749 ret;
14750 ENDPROC(__twofish_dec_blk8)
14751
14752@@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
14753
14754 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14755
14756+ pax_force_retaddr
14757 ret;
14758 ENDPROC(twofish_ecb_enc_8way)
14759
14760@@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
14761
14762 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14763
14764+ pax_force_retaddr
14765 ret;
14766 ENDPROC(twofish_ecb_dec_8way)
14767
14768@@ -370,19 +375,20 @@ ENTRY(twofish_cbc_dec_8way)
14769 * %rdx: src
14770 */
14771
14772- pushq %r12;
14773+ pushq %r14;
14774
14775 movq %rsi, %r11;
14776- movq %rdx, %r12;
14777+ movq %rdx, %r14;
14778
14779 load_8way(%rdx, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14780
14781 call __twofish_dec_blk8;
14782
14783- store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14784+ store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14785
14786- popq %r12;
14787+ popq %r14;
14788
14789+ pax_force_retaddr
14790 ret;
14791 ENDPROC(twofish_cbc_dec_8way)
14792
14793@@ -394,20 +400,21 @@ ENTRY(twofish_ctr_8way)
14794 * %rcx: iv (little endian, 128bit)
14795 */
14796
14797- pushq %r12;
14798+ pushq %r14;
14799
14800 movq %rsi, %r11;
14801- movq %rdx, %r12;
14802+ movq %rdx, %r14;
14803
14804 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
14805 RD2, RX0, RX1, RY0);
14806
14807 call __twofish_enc_blk8;
14808
14809- store_ctr_8way(%r12, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14810+ store_ctr_8way(%r14, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14811
14812- popq %r12;
14813+ popq %r14;
14814
14815+ pax_force_retaddr
14816 ret;
14817 ENDPROC(twofish_ctr_8way)
14818
14819@@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
14820 /* dst <= regs xor IVs(in dst) */
14821 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14822
14823+ pax_force_retaddr
14824 ret;
14825 ENDPROC(twofish_xts_enc_8way)
14826
14827@@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
14828 /* dst <= regs xor IVs(in dst) */
14829 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14830
14831+ pax_force_retaddr
14832 ret;
14833 ENDPROC(twofish_xts_dec_8way)
14834diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14835index 1c3b7ce..02f578d 100644
14836--- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14837+++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14838@@ -21,6 +21,7 @@
14839 */
14840
14841 #include <linux/linkage.h>
14842+#include <asm/alternative-asm.h>
14843
14844 .file "twofish-x86_64-asm-3way.S"
14845 .text
14846@@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
14847 popq %r13;
14848 popq %r14;
14849 popq %r15;
14850+ pax_force_retaddr
14851 ret;
14852
14853 .L__enc_xor3:
14854@@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
14855 popq %r13;
14856 popq %r14;
14857 popq %r15;
14858+ pax_force_retaddr
14859 ret;
14860 ENDPROC(__twofish_enc_blk_3way)
14861
14862@@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
14863 popq %r13;
14864 popq %r14;
14865 popq %r15;
14866+ pax_force_retaddr
14867 ret;
14868 ENDPROC(twofish_dec_blk_3way)
14869diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
14870index a350c99..c1bac24 100644
14871--- a/arch/x86/crypto/twofish-x86_64-asm_64.S
14872+++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
14873@@ -22,6 +22,7 @@
14874
14875 #include <linux/linkage.h>
14876 #include <asm/asm-offsets.h>
14877+#include <asm/alternative-asm.h>
14878
14879 #define a_offset 0
14880 #define b_offset 4
14881@@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
14882
14883 popq R1
14884 movl $1,%eax
14885+ pax_force_retaddr
14886 ret
14887 ENDPROC(twofish_enc_blk)
14888
14889@@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
14890
14891 popq R1
14892 movl $1,%eax
14893+ pax_force_retaddr
14894 ret
14895 ENDPROC(twofish_dec_blk)
14896diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h
14897index f4e6308..7ba29a1 100644
14898--- a/arch/x86/entry/calling.h
14899+++ b/arch/x86/entry/calling.h
14900@@ -93,23 +93,26 @@ For 32-bit we have the following conventions - kernel is built with
14901 .endm
14902
14903 .macro SAVE_C_REGS_HELPER offset=0 rax=1 rcx=1 r8910=1 r11=1
14904+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14905+ movq %r12, R12+\offset(%rsp)
14906+#endif
14907 .if \r11
14908- movq %r11, 6*8+\offset(%rsp)
14909+ movq %r11, R11+\offset(%rsp)
14910 .endif
14911 .if \r8910
14912- movq %r10, 7*8+\offset(%rsp)
14913- movq %r9, 8*8+\offset(%rsp)
14914- movq %r8, 9*8+\offset(%rsp)
14915+ movq %r10, R10+\offset(%rsp)
14916+ movq %r9, R9+\offset(%rsp)
14917+ movq %r8, R8+\offset(%rsp)
14918 .endif
14919 .if \rax
14920- movq %rax, 10*8+\offset(%rsp)
14921+ movq %rax, RAX+\offset(%rsp)
14922 .endif
14923 .if \rcx
14924- movq %rcx, 11*8+\offset(%rsp)
14925+ movq %rcx, RCX+\offset(%rsp)
14926 .endif
14927- movq %rdx, 12*8+\offset(%rsp)
14928- movq %rsi, 13*8+\offset(%rsp)
14929- movq %rdi, 14*8+\offset(%rsp)
14930+ movq %rdx, RDX+\offset(%rsp)
14931+ movq %rsi, RSI+\offset(%rsp)
14932+ movq %rdi, RDI+\offset(%rsp)
14933 .endm
14934 .macro SAVE_C_REGS offset=0
14935 SAVE_C_REGS_HELPER \offset, 1, 1, 1, 1
14936@@ -128,76 +131,87 @@ For 32-bit we have the following conventions - kernel is built with
14937 .endm
14938
14939 .macro SAVE_EXTRA_REGS offset=0
14940- movq %r15, 0*8+\offset(%rsp)
14941- movq %r14, 1*8+\offset(%rsp)
14942- movq %r13, 2*8+\offset(%rsp)
14943- movq %r12, 3*8+\offset(%rsp)
14944- movq %rbp, 4*8+\offset(%rsp)
14945- movq %rbx, 5*8+\offset(%rsp)
14946+ movq %r15, R15+\offset(%rsp)
14947+ movq %r14, R14+\offset(%rsp)
14948+ movq %r13, R13+\offset(%rsp)
14949+#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14950+ movq %r12, R12+\offset(%rsp)
14951+#endif
14952+ movq %rbp, RBP+\offset(%rsp)
14953+ movq %rbx, RBX+\offset(%rsp)
14954 .endm
14955 .macro SAVE_EXTRA_REGS_RBP offset=0
14956- movq %rbp, 4*8+\offset(%rsp)
14957+ movq %rbp, RBP+\offset(%rsp)
14958 .endm
14959
14960 .macro RESTORE_EXTRA_REGS offset=0
14961- movq 0*8+\offset(%rsp), %r15
14962- movq 1*8+\offset(%rsp), %r14
14963- movq 2*8+\offset(%rsp), %r13
14964- movq 3*8+\offset(%rsp), %r12
14965- movq 4*8+\offset(%rsp), %rbp
14966- movq 5*8+\offset(%rsp), %rbx
14967+ movq R15+\offset(%rsp), %r15
14968+ movq R14+\offset(%rsp), %r14
14969+ movq R13+\offset(%rsp), %r13
14970+#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14971+ movq R12+\offset(%rsp), %r12
14972+#endif
14973+ movq RBP+\offset(%rsp), %rbp
14974+ movq RBX+\offset(%rsp), %rbx
14975 .endm
14976
14977 .macro ZERO_EXTRA_REGS
14978 xorl %r15d, %r15d
14979 xorl %r14d, %r14d
14980 xorl %r13d, %r13d
14981+#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14982 xorl %r12d, %r12d
14983+#endif
14984 xorl %ebp, %ebp
14985 xorl %ebx, %ebx
14986 .endm
14987
14988- .macro RESTORE_C_REGS_HELPER rstor_rax=1, rstor_rcx=1, rstor_r11=1, rstor_r8910=1, rstor_rdx=1
14989+ .macro RESTORE_C_REGS_HELPER rstor_rax=1, rstor_rcx=1, rstor_r11=1, rstor_r8910=1, rstor_rdx=1, rstor_r12=1
14990+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14991+ .if \rstor_r12
14992+ movq R12(%rsp), %r12
14993+ .endif
14994+#endif
14995 .if \rstor_r11
14996- movq 6*8(%rsp), %r11
14997+ movq R11(%rsp), %r11
14998 .endif
14999 .if \rstor_r8910
15000- movq 7*8(%rsp), %r10
15001- movq 8*8(%rsp), %r9
15002- movq 9*8(%rsp), %r8
15003+ movq R10(%rsp), %r10
15004+ movq R9(%rsp), %r9
15005+ movq R8(%rsp), %r8
15006 .endif
15007 .if \rstor_rax
15008- movq 10*8(%rsp), %rax
15009+ movq RAX(%rsp), %rax
15010 .endif
15011 .if \rstor_rcx
15012- movq 11*8(%rsp), %rcx
15013+ movq RCX(%rsp), %rcx
15014 .endif
15015 .if \rstor_rdx
15016- movq 12*8(%rsp), %rdx
15017+ movq RDX(%rsp), %rdx
15018 .endif
15019- movq 13*8(%rsp), %rsi
15020- movq 14*8(%rsp), %rdi
15021+ movq RSI(%rsp), %rsi
15022+ movq RDI(%rsp), %rdi
15023 .endm
15024 .macro RESTORE_C_REGS
15025- RESTORE_C_REGS_HELPER 1,1,1,1,1
15026+ RESTORE_C_REGS_HELPER 1,1,1,1,1,1
15027 .endm
15028 .macro RESTORE_C_REGS_EXCEPT_RAX
15029- RESTORE_C_REGS_HELPER 0,1,1,1,1
15030+ RESTORE_C_REGS_HELPER 0,1,1,1,1,0
15031 .endm
15032 .macro RESTORE_C_REGS_EXCEPT_RCX
15033- RESTORE_C_REGS_HELPER 1,0,1,1,1
15034+ RESTORE_C_REGS_HELPER 1,0,1,1,1,0
15035 .endm
15036 .macro RESTORE_C_REGS_EXCEPT_R11
15037- RESTORE_C_REGS_HELPER 1,1,0,1,1
15038+ RESTORE_C_REGS_HELPER 1,1,0,1,1,1
15039 .endm
15040 .macro RESTORE_C_REGS_EXCEPT_RCX_R11
15041- RESTORE_C_REGS_HELPER 1,0,0,1,1
15042+ RESTORE_C_REGS_HELPER 1,0,0,1,1,1
15043 .endm
15044 .macro RESTORE_RSI_RDI
15045- RESTORE_C_REGS_HELPER 0,0,0,0,0
15046+ RESTORE_C_REGS_HELPER 0,0,0,0,0,1
15047 .endm
15048 .macro RESTORE_RSI_RDI_RDX
15049- RESTORE_C_REGS_HELPER 0,0,0,0,1
15050+ RESTORE_C_REGS_HELPER 0,0,0,0,1,1
15051 .endm
15052
15053 .macro REMOVE_PT_GPREGS_FROM_STACK addskip=0
15054diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
15055index 21dc60a..844def1 100644
15056--- a/arch/x86/entry/entry_32.S
15057+++ b/arch/x86/entry/entry_32.S
15058@@ -157,13 +157,154 @@
15059 movl \reg, PT_GS(%esp)
15060 .endm
15061 .macro SET_KERNEL_GS reg
15062+
15063+#ifdef CONFIG_CC_STACKPROTECTOR
15064 movl $(__KERNEL_STACK_CANARY), \reg
15065+#elif defined(CONFIG_PAX_MEMORY_UDEREF)
15066+ movl $(__USER_DS), \reg
15067+#else
15068+ xorl \reg, \reg
15069+#endif
15070+
15071 movl \reg, %gs
15072 .endm
15073
15074 #endif /* CONFIG_X86_32_LAZY_GS */
15075
15076-.macro SAVE_ALL
15077+.macro pax_enter_kernel
15078+#ifdef CONFIG_PAX_KERNEXEC
15079+ call pax_enter_kernel
15080+#endif
15081+.endm
15082+
15083+.macro pax_exit_kernel
15084+#ifdef CONFIG_PAX_KERNEXEC
15085+ call pax_exit_kernel
15086+#endif
15087+.endm
15088+
15089+#ifdef CONFIG_PAX_KERNEXEC
15090+ENTRY(pax_enter_kernel)
15091+#ifdef CONFIG_PARAVIRT
15092+ pushl %eax
15093+ pushl %ecx
15094+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
15095+ mov %eax, %esi
15096+#else
15097+ mov %cr0, %esi
15098+#endif
15099+ bts $X86_CR0_WP_BIT, %esi
15100+ jnc 1f
15101+ mov %cs, %esi
15102+ cmp $__KERNEL_CS, %esi
15103+ jz 3f
15104+ ljmp $__KERNEL_CS, $3f
15105+1: ljmp $__KERNEXEC_KERNEL_CS, $2f
15106+2:
15107+#ifdef CONFIG_PARAVIRT
15108+ mov %esi, %eax
15109+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
15110+#else
15111+ mov %esi, %cr0
15112+#endif
15113+3:
15114+#ifdef CONFIG_PARAVIRT
15115+ popl %ecx
15116+ popl %eax
15117+#endif
15118+ ret
15119+ENDPROC(pax_enter_kernel)
15120+
15121+ENTRY(pax_exit_kernel)
15122+#ifdef CONFIG_PARAVIRT
15123+ pushl %eax
15124+ pushl %ecx
15125+#endif
15126+ mov %cs, %esi
15127+ cmp $__KERNEXEC_KERNEL_CS, %esi
15128+ jnz 2f
15129+#ifdef CONFIG_PARAVIRT
15130+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
15131+ mov %eax, %esi
15132+#else
15133+ mov %cr0, %esi
15134+#endif
15135+ btr $X86_CR0_WP_BIT, %esi
15136+ ljmp $__KERNEL_CS, $1f
15137+1:
15138+#ifdef CONFIG_PARAVIRT
15139+ mov %esi, %eax
15140+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
15141+#else
15142+ mov %esi, %cr0
15143+#endif
15144+2:
15145+#ifdef CONFIG_PARAVIRT
15146+ popl %ecx
15147+ popl %eax
15148+#endif
15149+ ret
15150+ENDPROC(pax_exit_kernel)
15151+#endif
15152+
15153+ .macro pax_erase_kstack
15154+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
15155+ call pax_erase_kstack
15156+#endif
15157+ .endm
15158+
15159+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
15160+/*
15161+ * ebp: thread_info
15162+ */
15163+ENTRY(pax_erase_kstack)
15164+ pushl %edi
15165+ pushl %ecx
15166+ pushl %eax
15167+
15168+ mov TI_lowest_stack(%ebp), %edi
15169+ mov $-0xBEEF, %eax
15170+ std
15171+
15172+1: mov %edi, %ecx
15173+ and $THREAD_SIZE_asm - 1, %ecx
15174+ shr $2, %ecx
15175+ repne scasl
15176+ jecxz 2f
15177+
15178+ cmp $2*16, %ecx
15179+ jc 2f
15180+
15181+ mov $2*16, %ecx
15182+ repe scasl
15183+ jecxz 2f
15184+ jne 1b
15185+
15186+2: cld
15187+ or $2*4, %edi
15188+ mov %esp, %ecx
15189+ sub %edi, %ecx
15190+
15191+ cmp $THREAD_SIZE_asm, %ecx
15192+ jb 3f
15193+ ud2
15194+3:
15195+
15196+ shr $2, %ecx
15197+ rep stosl
15198+
15199+ mov TI_task_thread_sp0(%ebp), %edi
15200+ sub $128, %edi
15201+ mov %edi, TI_lowest_stack(%ebp)
15202+
15203+ popl %eax
15204+ popl %ecx
15205+ popl %edi
15206+ ret
15207+ENDPROC(pax_erase_kstack)
15208+#endif
15209+
15210+.macro __SAVE_ALL _DS
15211 cld
15212 PUSH_GS
15213 pushl %fs
15214@@ -176,7 +317,7 @@
15215 pushl %edx
15216 pushl %ecx
15217 pushl %ebx
15218- movl $(__USER_DS), %edx
15219+ movl $\_DS, %edx
15220 movl %edx, %ds
15221 movl %edx, %es
15222 movl $(__KERNEL_PERCPU), %edx
15223@@ -184,6 +325,15 @@
15224 SET_KERNEL_GS %edx
15225 .endm
15226
15227+.macro SAVE_ALL
15228+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15229+ __SAVE_ALL __KERNEL_DS
15230+ pax_enter_kernel
15231+#else
15232+ __SAVE_ALL __USER_DS
15233+#endif
15234+.endm
15235+
15236 .macro RESTORE_INT_REGS
15237 popl %ebx
15238 popl %ecx
15239@@ -222,7 +372,7 @@ ENTRY(ret_from_fork)
15240 pushl $0x0202 # Reset kernel eflags
15241 popfl
15242 jmp syscall_exit
15243-END(ret_from_fork)
15244+ENDPROC(ret_from_fork)
15245
15246 ENTRY(ret_from_kernel_thread)
15247 pushl %eax
15248@@ -262,7 +412,15 @@ ret_from_intr:
15249 andl $SEGMENT_RPL_MASK, %eax
15250 #endif
15251 cmpl $USER_RPL, %eax
15252+
15253+#ifdef CONFIG_PAX_KERNEXEC
15254+ jae resume_userspace
15255+
15256+ pax_exit_kernel
15257+ jmp resume_kernel
15258+#else
15259 jb resume_kernel # not returning to v8086 or userspace
15260+#endif
15261
15262 ENTRY(resume_userspace)
15263 LOCKDEP_SYS_EXIT
15264@@ -274,8 +432,8 @@ ENTRY(resume_userspace)
15265 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
15266 # int/exception return?
15267 jne work_pending
15268- jmp restore_all
15269-END(ret_from_exception)
15270+ jmp restore_all_pax
15271+ENDPROC(ret_from_exception)
15272
15273 #ifdef CONFIG_PREEMPT
15274 ENTRY(resume_kernel)
15275@@ -287,7 +445,7 @@ need_resched:
15276 jz restore_all
15277 call preempt_schedule_irq
15278 jmp need_resched
15279-END(resume_kernel)
15280+ENDPROC(resume_kernel)
15281 #endif
15282
15283 /*
15284@@ -312,32 +470,44 @@ sysenter_past_esp:
15285 pushl $__USER_CS
15286 /*
15287 * Push current_thread_info()->sysenter_return to the stack.
15288- * A tiny bit of offset fixup is necessary: TI_sysenter_return
15289- * is relative to thread_info, which is at the bottom of the
15290- * kernel stack page. 4*4 means the 4 words pushed above;
15291- * TOP_OF_KERNEL_STACK_PADDING takes us to the top of the stack;
15292- * and THREAD_SIZE takes us to the bottom.
15293 */
15294- pushl ((TI_sysenter_return) - THREAD_SIZE + TOP_OF_KERNEL_STACK_PADDING + 4*4)(%esp)
15295+ pushl $0
15296
15297 pushl %eax
15298 SAVE_ALL
15299+ GET_THREAD_INFO(%ebp)
15300+ movl TI_sysenter_return(%ebp), %ebp
15301+ movl %ebp, PT_EIP(%esp)
15302 ENABLE_INTERRUPTS(CLBR_NONE)
15303
15304 /*
15305 * Load the potential sixth argument from user stack.
15306 * Careful about security.
15307 */
15308+ movl PT_OLDESP(%esp),%ebp
15309+
15310+#ifdef CONFIG_PAX_MEMORY_UDEREF
15311+ mov PT_OLDSS(%esp), %ds
15312+1: movl %ds:(%ebp), %ebp
15313+ push %ss
15314+ pop %ds
15315+#else
15316 cmpl $__PAGE_OFFSET-3, %ebp
15317 jae syscall_fault
15318 ASM_STAC
15319 1: movl (%ebp), %ebp
15320 ASM_CLAC
15321+#endif
15322+
15323 movl %ebp, PT_EBP(%esp)
15324 _ASM_EXTABLE(1b, syscall_fault)
15325
15326 GET_THREAD_INFO(%ebp)
15327
15328+#ifdef CONFIG_PAX_RANDKSTACK
15329+ pax_erase_kstack
15330+#endif
15331+
15332 testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%ebp)
15333 jnz sysenter_audit
15334 sysenter_do_call:
15335@@ -353,12 +523,24 @@ sysenter_after_call:
15336 testl $_TIF_ALLWORK_MASK, %ecx
15337 jnz sysexit_audit
15338 sysenter_exit:
15339+
15340+#ifdef CONFIG_PAX_RANDKSTACK
15341+ pushl %eax
15342+ movl %esp, %eax
15343+ call pax_randomize_kstack
15344+ popl %eax
15345+#endif
15346+
15347+ pax_erase_kstack
15348+
15349 /* if something modifies registers it must also disable sysexit */
15350 movl PT_EIP(%esp), %edx
15351 movl PT_OLDESP(%esp), %ecx
15352 xorl %ebp, %ebp
15353 TRACE_IRQS_ON
15354 1: mov PT_FS(%esp), %fs
15355+2: mov PT_DS(%esp), %ds
15356+3: mov PT_ES(%esp), %es
15357 PTGS_TO_GS
15358 ENABLE_INTERRUPTS_SYSEXIT
15359
15360@@ -372,6 +554,9 @@ sysenter_audit:
15361 pushl PT_ESI(%esp) /* a3: 5th arg */
15362 pushl PT_EDX+4(%esp) /* a2: 4th arg */
15363 call __audit_syscall_entry
15364+
15365+ pax_erase_kstack
15366+
15367 popl %ecx /* get that remapped edx off the stack */
15368 popl %ecx /* get that remapped esi off the stack */
15369 movl PT_EAX(%esp), %eax /* reload syscall number */
15370@@ -397,10 +582,16 @@ sysexit_audit:
15371 #endif
15372
15373 .pushsection .fixup, "ax"
15374-2: movl $0, PT_FS(%esp)
15375+4: movl $0, PT_FS(%esp)
15376+ jmp 1b
15377+5: movl $0, PT_DS(%esp)
15378+ jmp 1b
15379+6: movl $0, PT_ES(%esp)
15380 jmp 1b
15381 .popsection
15382- _ASM_EXTABLE(1b, 2b)
15383+ _ASM_EXTABLE(1b, 4b)
15384+ _ASM_EXTABLE(2b, 5b)
15385+ _ASM_EXTABLE(3b, 6b)
15386 PTGS_TO_GS_EX
15387 ENDPROC(entry_SYSENTER_32)
15388
15389@@ -410,6 +601,11 @@ ENTRY(entry_INT80_32)
15390 pushl %eax # save orig_eax
15391 SAVE_ALL
15392 GET_THREAD_INFO(%ebp)
15393+
15394+#ifdef CONFIG_PAX_RANDKSTACK
15395+ pax_erase_kstack
15396+#endif
15397+
15398 # system call tracing in operation / emulation
15399 testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%ebp)
15400 jnz syscall_trace_entry
15401@@ -429,6 +625,15 @@ syscall_exit:
15402 testl $_TIF_ALLWORK_MASK, %ecx # current->work
15403 jnz syscall_exit_work
15404
15405+restore_all_pax:
15406+
15407+#ifdef CONFIG_PAX_RANDKSTACK
15408+ movl %esp, %eax
15409+ call pax_randomize_kstack
15410+#endif
15411+
15412+ pax_erase_kstack
15413+
15414 restore_all:
15415 TRACE_IRQS_IRET
15416 restore_all_notrace:
15417@@ -483,14 +688,34 @@ ldt_ss:
15418 * compensating for the offset by changing to the ESPFIX segment with
15419 * a base address that matches for the difference.
15420 */
15421-#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
15422+#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
15423 mov %esp, %edx /* load kernel esp */
15424 mov PT_OLDESP(%esp), %eax /* load userspace esp */
15425 mov %dx, %ax /* eax: new kernel esp */
15426 sub %eax, %edx /* offset (low word is 0) */
15427+#ifdef CONFIG_SMP
15428+ movl PER_CPU_VAR(cpu_number), %ebx
15429+ shll $PAGE_SHIFT_asm, %ebx
15430+ addl $cpu_gdt_table, %ebx
15431+#else
15432+ movl $cpu_gdt_table, %ebx
15433+#endif
15434 shr $16, %edx
15435- mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
15436- mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
15437+
15438+#ifdef CONFIG_PAX_KERNEXEC
15439+ mov %cr0, %esi
15440+ btr $X86_CR0_WP_BIT, %esi
15441+ mov %esi, %cr0
15442+#endif
15443+
15444+ mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
15445+ mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
15446+
15447+#ifdef CONFIG_PAX_KERNEXEC
15448+ bts $X86_CR0_WP_BIT, %esi
15449+ mov %esi, %cr0
15450+#endif
15451+
15452 pushl $__ESPFIX_SS
15453 pushl %eax /* new kernel esp */
15454 /*
15455@@ -519,20 +744,18 @@ work_resched:
15456 movl TI_flags(%ebp), %ecx
15457 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
15458 # than syscall tracing?
15459- jz restore_all
15460+ jz restore_all_pax
15461 testb $_TIF_NEED_RESCHED, %cl
15462 jnz work_resched
15463
15464 work_notifysig: # deal with pending signals and
15465 # notify-resume requests
15466+ movl %esp, %eax
15467 #ifdef CONFIG_VM86
15468 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
15469- movl %esp, %eax
15470 jnz work_notifysig_v86 # returning to kernel-space or
15471 # vm86-space
15472 1:
15473-#else
15474- movl %esp, %eax
15475 #endif
15476 TRACE_IRQS_ON
15477 ENABLE_INTERRUPTS(CLBR_NONE)
15478@@ -553,7 +776,7 @@ work_notifysig_v86:
15479 movl %eax, %esp
15480 jmp 1b
15481 #endif
15482-END(work_pending)
15483+ENDPROC(work_pending)
15484
15485 # perform syscall exit tracing
15486 ALIGN
15487@@ -561,11 +784,14 @@ syscall_trace_entry:
15488 movl $-ENOSYS, PT_EAX(%esp)
15489 movl %esp, %eax
15490 call syscall_trace_enter
15491+
15492+ pax_erase_kstack
15493+
15494 /* What it returned is what we'll actually use. */
15495 cmpl $(NR_syscalls), %eax
15496 jnae syscall_call
15497 jmp syscall_exit
15498-END(syscall_trace_entry)
15499+ENDPROC(syscall_trace_entry)
15500
15501 # perform syscall exit tracing
15502 ALIGN
15503@@ -578,24 +804,28 @@ syscall_exit_work:
15504 movl %esp, %eax
15505 call syscall_trace_leave
15506 jmp resume_userspace
15507-END(syscall_exit_work)
15508+ENDPROC(syscall_exit_work)
15509
15510 syscall_fault:
15511+#ifdef CONFIG_PAX_MEMORY_UDEREF
15512+ push %ss
15513+ pop %ds
15514+#endif
15515 ASM_CLAC
15516 GET_THREAD_INFO(%ebp)
15517 movl $-EFAULT, PT_EAX(%esp)
15518 jmp resume_userspace
15519-END(syscall_fault)
15520+ENDPROC(syscall_fault)
15521
15522 syscall_badsys:
15523 movl $-ENOSYS, %eax
15524 jmp syscall_after_call
15525-END(syscall_badsys)
15526+ENDPROC(syscall_badsys)
15527
15528 sysenter_badsys:
15529 movl $-ENOSYS, %eax
15530 jmp sysenter_after_call
15531-END(sysenter_badsys)
15532+ENDPROC(sysenter_badsys)
15533
15534 .macro FIXUP_ESPFIX_STACK
15535 /*
15536@@ -607,8 +837,15 @@ END(sysenter_badsys)
15537 */
15538 #ifdef CONFIG_X86_ESPFIX32
15539 /* fixup the stack */
15540- mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
15541- mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
15542+#ifdef CONFIG_SMP
15543+ movl PER_CPU_VAR(cpu_number), %ebx
15544+ shll $PAGE_SHIFT_asm, %ebx
15545+ addl $cpu_gdt_table, %ebx
15546+#else
15547+ movl $cpu_gdt_table, %ebx
15548+#endif
15549+ mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
15550+ mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
15551 shl $16, %eax
15552 addl %esp, %eax /* the adjusted stack pointer */
15553 pushl $__KERNEL_DS
15554@@ -644,7 +881,7 @@ ENTRY(irq_entries_start)
15555 jmp common_interrupt
15556 .align 8
15557 .endr
15558-END(irq_entries_start)
15559+ENDPROC(irq_entries_start)
15560
15561 /*
15562 * the CPU automatically disables interrupts when executing an IRQ vector,
15563@@ -691,7 +928,7 @@ ENTRY(coprocessor_error)
15564 pushl $0
15565 pushl $do_coprocessor_error
15566 jmp error_code
15567-END(coprocessor_error)
15568+ENDPROC(coprocessor_error)
15569
15570 ENTRY(simd_coprocessor_error)
15571 ASM_CLAC
15572@@ -705,25 +942,25 @@ ENTRY(simd_coprocessor_error)
15573 pushl $do_simd_coprocessor_error
15574 #endif
15575 jmp error_code
15576-END(simd_coprocessor_error)
15577+ENDPROC(simd_coprocessor_error)
15578
15579 ENTRY(device_not_available)
15580 ASM_CLAC
15581 pushl $-1 # mark this as an int
15582 pushl $do_device_not_available
15583 jmp error_code
15584-END(device_not_available)
15585+ENDPROC(device_not_available)
15586
15587 #ifdef CONFIG_PARAVIRT
15588 ENTRY(native_iret)
15589 iret
15590 _ASM_EXTABLE(native_iret, iret_exc)
15591-END(native_iret)
15592+ENDPROC(native_iret)
15593
15594 ENTRY(native_irq_enable_sysexit)
15595 sti
15596 sysexit
15597-END(native_irq_enable_sysexit)
15598+ENDPROC(native_irq_enable_sysexit)
15599 #endif
15600
15601 ENTRY(overflow)
15602@@ -731,59 +968,59 @@ ENTRY(overflow)
15603 pushl $0
15604 pushl $do_overflow
15605 jmp error_code
15606-END(overflow)
15607+ENDPROC(overflow)
15608
15609 ENTRY(bounds)
15610 ASM_CLAC
15611 pushl $0
15612 pushl $do_bounds
15613 jmp error_code
15614-END(bounds)
15615+ENDPROC(bounds)
15616
15617 ENTRY(invalid_op)
15618 ASM_CLAC
15619 pushl $0
15620 pushl $do_invalid_op
15621 jmp error_code
15622-END(invalid_op)
15623+ENDPROC(invalid_op)
15624
15625 ENTRY(coprocessor_segment_overrun)
15626 ASM_CLAC
15627 pushl $0
15628 pushl $do_coprocessor_segment_overrun
15629 jmp error_code
15630-END(coprocessor_segment_overrun)
15631+ENDPROC(coprocessor_segment_overrun)
15632
15633 ENTRY(invalid_TSS)
15634 ASM_CLAC
15635 pushl $do_invalid_TSS
15636 jmp error_code
15637-END(invalid_TSS)
15638+ENDPROC(invalid_TSS)
15639
15640 ENTRY(segment_not_present)
15641 ASM_CLAC
15642 pushl $do_segment_not_present
15643 jmp error_code
15644-END(segment_not_present)
15645+ENDPROC(segment_not_present)
15646
15647 ENTRY(stack_segment)
15648 ASM_CLAC
15649 pushl $do_stack_segment
15650 jmp error_code
15651-END(stack_segment)
15652+ENDPROC(stack_segment)
15653
15654 ENTRY(alignment_check)
15655 ASM_CLAC
15656 pushl $do_alignment_check
15657 jmp error_code
15658-END(alignment_check)
15659+ENDPROC(alignment_check)
15660
15661 ENTRY(divide_error)
15662 ASM_CLAC
15663 pushl $0 # no error code
15664 pushl $do_divide_error
15665 jmp error_code
15666-END(divide_error)
15667+ENDPROC(divide_error)
15668
15669 #ifdef CONFIG_X86_MCE
15670 ENTRY(machine_check)
15671@@ -791,7 +1028,7 @@ ENTRY(machine_check)
15672 pushl $0
15673 pushl machine_check_vector
15674 jmp error_code
15675-END(machine_check)
15676+ENDPROC(machine_check)
15677 #endif
15678
15679 ENTRY(spurious_interrupt_bug)
15680@@ -799,7 +1036,7 @@ ENTRY(spurious_interrupt_bug)
15681 pushl $0
15682 pushl $do_spurious_interrupt_bug
15683 jmp error_code
15684-END(spurious_interrupt_bug)
15685+ENDPROC(spurious_interrupt_bug)
15686
15687 #ifdef CONFIG_XEN
15688 /*
15689@@ -906,7 +1143,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
15690
15691 ENTRY(mcount)
15692 ret
15693-END(mcount)
15694+ENDPROC(mcount)
15695
15696 ENTRY(ftrace_caller)
15697 pushl %eax
15698@@ -936,7 +1173,7 @@ ftrace_graph_call:
15699 .globl ftrace_stub
15700 ftrace_stub:
15701 ret
15702-END(ftrace_caller)
15703+ENDPROC(ftrace_caller)
15704
15705 ENTRY(ftrace_regs_caller)
15706 pushf /* push flags before compare (in cs location) */
15707@@ -1034,7 +1271,7 @@ trace:
15708 popl %ecx
15709 popl %eax
15710 jmp ftrace_stub
15711-END(mcount)
15712+ENDPROC(mcount)
15713 #endif /* CONFIG_DYNAMIC_FTRACE */
15714 #endif /* CONFIG_FUNCTION_TRACER */
15715
15716@@ -1052,7 +1289,7 @@ ENTRY(ftrace_graph_caller)
15717 popl %ecx
15718 popl %eax
15719 ret
15720-END(ftrace_graph_caller)
15721+ENDPROC(ftrace_graph_caller)
15722
15723 .globl return_to_handler
15724 return_to_handler:
15725@@ -1100,14 +1337,17 @@ error_code:
15726 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
15727 REG_TO_PTGS %ecx
15728 SET_KERNEL_GS %ecx
15729- movl $(__USER_DS), %ecx
15730+ movl $(__KERNEL_DS), %ecx
15731 movl %ecx, %ds
15732 movl %ecx, %es
15733+
15734+ pax_enter_kernel
15735+
15736 TRACE_IRQS_OFF
15737 movl %esp, %eax # pt_regs pointer
15738 call *%edi
15739 jmp ret_from_exception
15740-END(page_fault)
15741+ENDPROC(page_fault)
15742
15743 /*
15744 * Debug traps and NMI can happen at the one SYSENTER instruction
15745@@ -1145,7 +1385,7 @@ debug_stack_correct:
15746 movl %esp, %eax # pt_regs pointer
15747 call do_debug
15748 jmp ret_from_exception
15749-END(debug)
15750+ENDPROC(debug)
15751
15752 /*
15753 * NMI is doubly nasty. It can happen _while_ we're handling
15754@@ -1184,6 +1424,9 @@ nmi_stack_correct:
15755 xorl %edx, %edx # zero error code
15756 movl %esp, %eax # pt_regs pointer
15757 call do_nmi
15758+
15759+ pax_exit_kernel
15760+
15761 jmp restore_all_notrace
15762
15763 nmi_stack_fixup:
15764@@ -1217,11 +1460,14 @@ nmi_espfix_stack:
15765 FIXUP_ESPFIX_STACK # %eax == %esp
15766 xorl %edx, %edx # zero error code
15767 call do_nmi
15768+
15769+ pax_exit_kernel
15770+
15771 RESTORE_REGS
15772 lss 12+4(%esp), %esp # back to espfix stack
15773 jmp irq_return
15774 #endif
15775-END(nmi)
15776+ENDPROC(nmi)
15777
15778 ENTRY(int3)
15779 ASM_CLAC
15780@@ -1232,17 +1478,17 @@ ENTRY(int3)
15781 movl %esp, %eax # pt_regs pointer
15782 call do_int3
15783 jmp ret_from_exception
15784-END(int3)
15785+ENDPROC(int3)
15786
15787 ENTRY(general_protection)
15788 pushl $do_general_protection
15789 jmp error_code
15790-END(general_protection)
15791+ENDPROC(general_protection)
15792
15793 #ifdef CONFIG_KVM_GUEST
15794 ENTRY(async_page_fault)
15795 ASM_CLAC
15796 pushl $do_async_page_fault
15797 jmp error_code
15798-END(async_page_fault)
15799+ENDPROC(async_page_fault)
15800 #endif
15801diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
15802index d330840..4f1925e 100644
15803--- a/arch/x86/entry/entry_64.S
15804+++ b/arch/x86/entry/entry_64.S
15805@@ -37,6 +37,8 @@
15806 #include <asm/smap.h>
15807 #include <asm/pgtable_types.h>
15808 #include <linux/err.h>
15809+#include <asm/pgtable.h>
15810+#include <asm/alternative-asm.h>
15811
15812 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
15813 #include <linux/elf-em.h>
15814@@ -54,6 +56,402 @@ ENTRY(native_usergs_sysret64)
15815 ENDPROC(native_usergs_sysret64)
15816 #endif /* CONFIG_PARAVIRT */
15817
15818+ .macro ljmpq sel, off
15819+#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
15820+ .byte 0x48; ljmp *1234f(%rip)
15821+ .pushsection .rodata
15822+ .align 16
15823+ 1234: .quad \off; .word \sel
15824+ .popsection
15825+#else
15826+ pushq $\sel
15827+ pushq $\off
15828+ lretq
15829+#endif
15830+ .endm
15831+
15832+ .macro pax_enter_kernel
15833+ pax_set_fptr_mask
15834+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15835+ call pax_enter_kernel
15836+#endif
15837+ .endm
15838+
15839+ .macro pax_exit_kernel
15840+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15841+ call pax_exit_kernel
15842+#endif
15843+ .endm
15844+
15845+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15846+ENTRY(pax_enter_kernel)
15847+ pushq %rdi
15848+
15849+#ifdef CONFIG_PARAVIRT
15850+ PV_SAVE_REGS(CLBR_RDI)
15851+#endif
15852+
15853+#ifdef CONFIG_PAX_KERNEXEC
15854+ GET_CR0_INTO_RDI
15855+ bts $X86_CR0_WP_BIT,%rdi
15856+ jnc 3f
15857+ mov %cs,%edi
15858+ cmp $__KERNEL_CS,%edi
15859+ jnz 2f
15860+1:
15861+#endif
15862+
15863+#ifdef CONFIG_PAX_MEMORY_UDEREF
15864+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
15865+ GET_CR3_INTO_RDI
15866+ cmp $0,%dil
15867+ jnz 112f
15868+ mov $__KERNEL_DS,%edi
15869+ mov %edi,%ss
15870+ jmp 111f
15871+112: cmp $1,%dil
15872+ jz 113f
15873+ ud2
15874+113: sub $4097,%rdi
15875+ bts $63,%rdi
15876+ SET_RDI_INTO_CR3
15877+ mov $__UDEREF_KERNEL_DS,%edi
15878+ mov %edi,%ss
15879+111:
15880+#endif
15881+
15882+#ifdef CONFIG_PARAVIRT
15883+ PV_RESTORE_REGS(CLBR_RDI)
15884+#endif
15885+
15886+ popq %rdi
15887+ pax_force_retaddr
15888+ retq
15889+
15890+#ifdef CONFIG_PAX_KERNEXEC
15891+2: ljmpq __KERNEL_CS,1b
15892+3: ljmpq __KERNEXEC_KERNEL_CS,4f
15893+4: SET_RDI_INTO_CR0
15894+ jmp 1b
15895+#endif
15896+ENDPROC(pax_enter_kernel)
15897+
15898+ENTRY(pax_exit_kernel)
15899+ pushq %rdi
15900+
15901+#ifdef CONFIG_PARAVIRT
15902+ PV_SAVE_REGS(CLBR_RDI)
15903+#endif
15904+
15905+#ifdef CONFIG_PAX_KERNEXEC
15906+ mov %cs,%rdi
15907+ cmp $__KERNEXEC_KERNEL_CS,%edi
15908+ jz 2f
15909+ GET_CR0_INTO_RDI
15910+ bts $X86_CR0_WP_BIT,%rdi
15911+ jnc 4f
15912+1:
15913+#endif
15914+
15915+#ifdef CONFIG_PAX_MEMORY_UDEREF
15916+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
15917+ mov %ss,%edi
15918+ cmp $__UDEREF_KERNEL_DS,%edi
15919+ jnz 111f
15920+ GET_CR3_INTO_RDI
15921+ cmp $0,%dil
15922+ jz 112f
15923+ ud2
15924+112: add $4097,%rdi
15925+ bts $63,%rdi
15926+ SET_RDI_INTO_CR3
15927+ mov $__KERNEL_DS,%edi
15928+ mov %edi,%ss
15929+111:
15930+#endif
15931+
15932+#ifdef CONFIG_PARAVIRT
15933+ PV_RESTORE_REGS(CLBR_RDI);
15934+#endif
15935+
15936+ popq %rdi
15937+ pax_force_retaddr
15938+ retq
15939+
15940+#ifdef CONFIG_PAX_KERNEXEC
15941+2: GET_CR0_INTO_RDI
15942+ btr $X86_CR0_WP_BIT,%rdi
15943+ jnc 4f
15944+ ljmpq __KERNEL_CS,3f
15945+3: SET_RDI_INTO_CR0
15946+ jmp 1b
15947+4: ud2
15948+ jmp 4b
15949+#endif
15950+ENDPROC(pax_exit_kernel)
15951+#endif
15952+
15953+ .macro pax_enter_kernel_user
15954+ pax_set_fptr_mask
15955+#ifdef CONFIG_PAX_MEMORY_UDEREF
15956+ call pax_enter_kernel_user
15957+#endif
15958+ .endm
15959+
15960+ .macro pax_exit_kernel_user
15961+#ifdef CONFIG_PAX_MEMORY_UDEREF
15962+ call pax_exit_kernel_user
15963+#endif
15964+#ifdef CONFIG_PAX_RANDKSTACK
15965+ pushq %rax
15966+ pushq %r11
15967+ call pax_randomize_kstack
15968+ popq %r11
15969+ popq %rax
15970+#endif
15971+ .endm
15972+
15973+#ifdef CONFIG_PAX_MEMORY_UDEREF
15974+ENTRY(pax_enter_kernel_user)
15975+ pushq %rdi
15976+ pushq %rbx
15977+
15978+#ifdef CONFIG_PARAVIRT
15979+ PV_SAVE_REGS(CLBR_RDI)
15980+#endif
15981+
15982+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
15983+ GET_CR3_INTO_RDI
15984+ cmp $1,%dil
15985+ jnz 4f
15986+ sub $4097,%rdi
15987+ bts $63,%rdi
15988+ SET_RDI_INTO_CR3
15989+ jmp 3f
15990+111:
15991+
15992+ GET_CR3_INTO_RDI
15993+ mov %rdi,%rbx
15994+ add $__START_KERNEL_map,%rbx
15995+ sub phys_base(%rip),%rbx
15996+
15997+#ifdef CONFIG_PARAVIRT
15998+ cmpl $0, pv_info+PARAVIRT_enabled
15999+ jz 1f
16000+ pushq %rdi
16001+ i = 0
16002+ .rept USER_PGD_PTRS
16003+ mov i*8(%rbx),%rsi
16004+ mov $0,%sil
16005+ lea i*8(%rbx),%rdi
16006+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
16007+ i = i + 1
16008+ .endr
16009+ popq %rdi
16010+ jmp 2f
16011+1:
16012+#endif
16013+
16014+ i = 0
16015+ .rept USER_PGD_PTRS
16016+ movb $0,i*8(%rbx)
16017+ i = i + 1
16018+ .endr
16019+
16020+2: SET_RDI_INTO_CR3
16021+
16022+#ifdef CONFIG_PAX_KERNEXEC
16023+ GET_CR0_INTO_RDI
16024+ bts $X86_CR0_WP_BIT,%rdi
16025+ SET_RDI_INTO_CR0
16026+#endif
16027+
16028+3:
16029+
16030+#ifdef CONFIG_PARAVIRT
16031+ PV_RESTORE_REGS(CLBR_RDI)
16032+#endif
16033+
16034+ popq %rbx
16035+ popq %rdi
16036+ pax_force_retaddr
16037+ retq
16038+4: ud2
16039+ENDPROC(pax_enter_kernel_user)
16040+
16041+ENTRY(pax_exit_kernel_user)
16042+ pushq %rdi
16043+ pushq %rbx
16044+
16045+#ifdef CONFIG_PARAVIRT
16046+ PV_SAVE_REGS(CLBR_RDI)
16047+#endif
16048+
16049+ GET_CR3_INTO_RDI
16050+ ALTERNATIVE "jmp 1f", "", X86_FEATURE_PCID
16051+ cmp $0,%dil
16052+ jnz 3f
16053+ add $4097,%rdi
16054+ bts $63,%rdi
16055+ SET_RDI_INTO_CR3
16056+ jmp 2f
16057+1:
16058+
16059+ mov %rdi,%rbx
16060+
16061+#ifdef CONFIG_PAX_KERNEXEC
16062+ GET_CR0_INTO_RDI
16063+ btr $X86_CR0_WP_BIT,%rdi
16064+ jnc 3f
16065+ SET_RDI_INTO_CR0
16066+#endif
16067+
16068+ add $__START_KERNEL_map,%rbx
16069+ sub phys_base(%rip),%rbx
16070+
16071+#ifdef CONFIG_PARAVIRT
16072+ cmpl $0, pv_info+PARAVIRT_enabled
16073+ jz 1f
16074+ i = 0
16075+ .rept USER_PGD_PTRS
16076+ mov i*8(%rbx),%rsi
16077+ mov $0x67,%sil
16078+ lea i*8(%rbx),%rdi
16079+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
16080+ i = i + 1
16081+ .endr
16082+ jmp 2f
16083+1:
16084+#endif
16085+
16086+ i = 0
16087+ .rept USER_PGD_PTRS
16088+ movb $0x67,i*8(%rbx)
16089+ i = i + 1
16090+ .endr
16091+2:
16092+
16093+#ifdef CONFIG_PARAVIRT
16094+ PV_RESTORE_REGS(CLBR_RDI)
16095+#endif
16096+
16097+ popq %rbx
16098+ popq %rdi
16099+ pax_force_retaddr
16100+ retq
16101+3: ud2
16102+ENDPROC(pax_exit_kernel_user)
16103+#endif
16104+
16105+ .macro pax_enter_kernel_nmi
16106+ pax_set_fptr_mask
16107+
16108+#ifdef CONFIG_PAX_KERNEXEC
16109+ GET_CR0_INTO_RDI
16110+ bts $X86_CR0_WP_BIT,%rdi
16111+ jc 110f
16112+ SET_RDI_INTO_CR0
16113+ or $2,%ebx
16114+110:
16115+#endif
16116+
16117+#ifdef CONFIG_PAX_MEMORY_UDEREF
16118+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
16119+ GET_CR3_INTO_RDI
16120+ cmp $0,%dil
16121+ jz 111f
16122+ sub $4097,%rdi
16123+ or $4,%ebx
16124+ bts $63,%rdi
16125+ SET_RDI_INTO_CR3
16126+ mov $__UDEREF_KERNEL_DS,%edi
16127+ mov %edi,%ss
16128+111:
16129+#endif
16130+ .endm
16131+
16132+ .macro pax_exit_kernel_nmi
16133+#ifdef CONFIG_PAX_KERNEXEC
16134+ btr $1,%ebx
16135+ jnc 110f
16136+ GET_CR0_INTO_RDI
16137+ btr $X86_CR0_WP_BIT,%rdi
16138+ SET_RDI_INTO_CR0
16139+110:
16140+#endif
16141+
16142+#ifdef CONFIG_PAX_MEMORY_UDEREF
16143+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
16144+ btr $2,%ebx
16145+ jnc 111f
16146+ GET_CR3_INTO_RDI
16147+ add $4097,%rdi
16148+ bts $63,%rdi
16149+ SET_RDI_INTO_CR3
16150+ mov $__KERNEL_DS,%edi
16151+ mov %edi,%ss
16152+111:
16153+#endif
16154+ .endm
16155+
16156+ .macro pax_erase_kstack
16157+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16158+ call pax_erase_kstack
16159+#endif
16160+ .endm
16161+
16162+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16163+ENTRY(pax_erase_kstack)
16164+ pushq %rdi
16165+ pushq %rcx
16166+ pushq %rax
16167+ pushq %r11
16168+
16169+ GET_THREAD_INFO(%r11)
16170+ mov TI_lowest_stack(%r11), %rdi
16171+ mov $-0xBEEF, %rax
16172+ std
16173+
16174+1: mov %edi, %ecx
16175+ and $THREAD_SIZE_asm - 1, %ecx
16176+ shr $3, %ecx
16177+ repne scasq
16178+ jecxz 2f
16179+
16180+ cmp $2*8, %ecx
16181+ jc 2f
16182+
16183+ mov $2*8, %ecx
16184+ repe scasq
16185+ jecxz 2f
16186+ jne 1b
16187+
16188+2: cld
16189+ or $2*8, %rdi
16190+ mov %esp, %ecx
16191+ sub %edi, %ecx
16192+
16193+ cmp $THREAD_SIZE_asm, %rcx
16194+ jb 3f
16195+ ud2
16196+3:
16197+
16198+ shr $3, %ecx
16199+ rep stosq
16200+
16201+ mov TI_task_thread_sp0(%r11), %rdi
16202+ sub $256, %rdi
16203+ mov %rdi, TI_lowest_stack(%r11)
16204+
16205+ popq %r11
16206+ popq %rax
16207+ popq %rcx
16208+ popq %rdi
16209+ pax_force_retaddr
16210+ ret
16211+ENDPROC(pax_erase_kstack)
16212+#endif
16213+
16214 .macro TRACE_IRQS_IRETQ
16215 #ifdef CONFIG_TRACE_IRQFLAGS
16216 bt $9, EFLAGS(%rsp) /* interrupts off? */
16217@@ -89,7 +487,7 @@ ENDPROC(native_usergs_sysret64)
16218 .endm
16219
16220 .macro TRACE_IRQS_IRETQ_DEBUG
16221- bt $9, EFLAGS(%rsp) /* interrupts off? */
16222+ bt $X86_EFLAGS_IF_BIT, EFLAGS(%rsp) /* interrupts off? */
16223 jnc 1f
16224 TRACE_IRQS_ON_DEBUG
16225 1:
16226@@ -149,14 +547,6 @@ GLOBAL(entry_SYSCALL_64_after_swapgs)
16227 /* Construct struct pt_regs on stack */
16228 pushq $__USER_DS /* pt_regs->ss */
16229 pushq PER_CPU_VAR(rsp_scratch) /* pt_regs->sp */
16230- /*
16231- * Re-enable interrupts.
16232- * We use 'rsp_scratch' as a scratch space, hence irq-off block above
16233- * must execute atomically in the face of possible interrupt-driven
16234- * task preemption. We must enable interrupts only after we're done
16235- * with using rsp_scratch:
16236- */
16237- ENABLE_INTERRUPTS(CLBR_NONE)
16238 pushq %r11 /* pt_regs->flags */
16239 pushq $__USER_CS /* pt_regs->cs */
16240 pushq %rcx /* pt_regs->ip */
16241@@ -172,7 +562,27 @@ GLOBAL(entry_SYSCALL_64_after_swapgs)
16242 pushq %r11 /* pt_regs->r11 */
16243 sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */
16244
16245- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16246+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16247+ movq %r12, R12(%rsp)
16248+#endif
16249+
16250+ pax_enter_kernel_user
16251+
16252+#ifdef CONFIG_PAX_RANDKSTACK
16253+ pax_erase_kstack
16254+#endif
16255+
16256+ /*
16257+ * Re-enable interrupts.
16258+ * We use 'rsp_scratch' as a scratch space, hence irq-off block above
16259+ * must execute atomically in the face of possible interrupt-driven
16260+ * task preemption. We must enable interrupts only after we're done
16261+ * with using rsp_scratch:
16262+ */
16263+ ENABLE_INTERRUPTS(CLBR_NONE)
16264+
16265+ GET_THREAD_INFO(%rcx)
16266+ testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%rcx)
16267 jnz tracesys
16268 entry_SYSCALL_64_fastpath:
16269 #if __SYSCALL_MASK == ~0
16270@@ -205,9 +615,13 @@ entry_SYSCALL_64_fastpath:
16271 * flags (TIF_NOTIFY_RESUME, TIF_USER_RETURN_NOTIFY, etc) set is
16272 * very bad.
16273 */
16274- testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16275+ GET_THREAD_INFO(%rcx)
16276+ testl $_TIF_ALLWORK_MASK, TI_flags(%rcx)
16277 jnz int_ret_from_sys_call_irqs_off /* Go to the slow path */
16278
16279+ pax_exit_kernel_user
16280+ pax_erase_kstack
16281+
16282 RESTORE_C_REGS_EXCEPT_RCX_R11
16283 movq RIP(%rsp), %rcx
16284 movq EFLAGS(%rsp), %r11
16285@@ -236,6 +650,9 @@ tracesys:
16286 call syscall_trace_enter_phase1
16287 test %rax, %rax
16288 jnz tracesys_phase2 /* if needed, run the slow path */
16289+
16290+ pax_erase_kstack
16291+
16292 RESTORE_C_REGS_EXCEPT_RAX /* else restore clobbered regs */
16293 movq ORIG_RAX(%rsp), %rax
16294 jmp entry_SYSCALL_64_fastpath /* and return to the fast path */
16295@@ -247,6 +664,8 @@ tracesys_phase2:
16296 movq %rax, %rdx
16297 call syscall_trace_enter_phase2
16298
16299+ pax_erase_kstack
16300+
16301 /*
16302 * Reload registers from stack in case ptrace changed them.
16303 * We don't reload %rax because syscall_trace_entry_phase2() returned
16304@@ -284,6 +703,8 @@ GLOBAL(int_with_check)
16305 andl %edi, %edx
16306 jnz int_careful
16307 andl $~TS_COMPAT, TI_status(%rcx)
16308+ pax_exit_kernel_user
16309+ pax_erase_kstack
16310 jmp syscall_return
16311
16312 /*
16313@@ -407,14 +828,14 @@ syscall_return_via_sysret:
16314 opportunistic_sysret_failed:
16315 SWAPGS
16316 jmp restore_c_regs_and_iret
16317-END(entry_SYSCALL_64)
16318+ENDPROC(entry_SYSCALL_64)
16319
16320
16321 .macro FORK_LIKE func
16322 ENTRY(stub_\func)
16323 SAVE_EXTRA_REGS 8
16324 jmp sys_\func
16325-END(stub_\func)
16326+ENDPROC(stub_\func)
16327 .endm
16328
16329 FORK_LIKE clone
16330@@ -434,7 +855,7 @@ return_from_execve:
16331 ZERO_EXTRA_REGS
16332 movq %rax, RAX(%rsp)
16333 jmp int_ret_from_sys_call
16334-END(stub_execve)
16335+ENDPROC(stub_execve)
16336 /*
16337 * Remaining execve stubs are only 7 bytes long.
16338 * ENTRY() often aligns to 16 bytes, which in this case has no benefits.
16339@@ -443,7 +864,7 @@ END(stub_execve)
16340 GLOBAL(stub_execveat)
16341 call sys_execveat
16342 jmp return_from_execve
16343-END(stub_execveat)
16344+ENDPROC(stub_execveat)
16345
16346 #if defined(CONFIG_X86_X32_ABI) || defined(CONFIG_IA32_EMULATION)
16347 .align 8
16348@@ -451,15 +872,15 @@ GLOBAL(stub_x32_execve)
16349 GLOBAL(stub32_execve)
16350 call compat_sys_execve
16351 jmp return_from_execve
16352-END(stub32_execve)
16353-END(stub_x32_execve)
16354+ENDPROC(stub32_execve)
16355+ENDPROC(stub_x32_execve)
16356 .align 8
16357 GLOBAL(stub_x32_execveat)
16358 GLOBAL(stub32_execveat)
16359 call compat_sys_execveat
16360 jmp return_from_execve
16361-END(stub32_execveat)
16362-END(stub_x32_execveat)
16363+ENDPROC(stub32_execveat)
16364+ENDPROC(stub_x32_execveat)
16365 #endif
16366
16367 /*
16368@@ -488,7 +909,7 @@ ENTRY(stub_x32_rt_sigreturn)
16369 SAVE_EXTRA_REGS 8
16370 call sys32_x32_rt_sigreturn
16371 jmp return_from_stub
16372-END(stub_x32_rt_sigreturn)
16373+ENDPROC(stub_x32_rt_sigreturn)
16374 #endif
16375
16376 /*
16377@@ -527,7 +948,7 @@ ENTRY(ret_from_fork)
16378 movl $0, RAX(%rsp)
16379 RESTORE_EXTRA_REGS
16380 jmp int_ret_from_sys_call
16381-END(ret_from_fork)
16382+ENDPROC(ret_from_fork)
16383
16384 /*
16385 * Build the entry stubs with some assembler magic.
16386@@ -542,7 +963,7 @@ ENTRY(irq_entries_start)
16387 jmp common_interrupt
16388 .align 8
16389 .endr
16390-END(irq_entries_start)
16391+ENDPROC(irq_entries_start)
16392
16393 /*
16394 * Interrupt entry/exit.
16395@@ -555,21 +976,13 @@ END(irq_entries_start)
16396 /* 0(%rsp): ~(interrupt number) */
16397 .macro interrupt func
16398 cld
16399- /*
16400- * Since nothing in interrupt handling code touches r12...r15 members
16401- * of "struct pt_regs", and since interrupts can nest, we can save
16402- * four stack slots and simultaneously provide
16403- * an unwind-friendly stack layout by saving "truncated" pt_regs
16404- * exactly up to rbp slot, without these members.
16405- */
16406- ALLOC_PT_GPREGS_ON_STACK -RBP
16407- SAVE_C_REGS -RBP
16408- /* this goes to 0(%rsp) for unwinder, not for saving the value: */
16409- SAVE_EXTRA_REGS_RBP -RBP
16410+ ALLOC_PT_GPREGS_ON_STACK
16411+ SAVE_C_REGS
16412+ SAVE_EXTRA_REGS
16413
16414- leaq -RBP(%rsp), %rdi /* arg1 for \func (pointer to pt_regs) */
16415+ movq %rsp, %rdi /* arg1 for \func (pointer to pt_regs) */
16416
16417- testb $3, CS-RBP(%rsp)
16418+ testb $3, CS(%rsp)
16419 jz 1f
16420 SWAPGS
16421 1:
16422@@ -584,6 +997,18 @@ END(irq_entries_start)
16423 incl PER_CPU_VAR(irq_count)
16424 cmovzq PER_CPU_VAR(irq_stack_ptr), %rsp
16425 pushq %rsi
16426+
16427+#ifdef CONFIG_PAX_MEMORY_UDEREF
16428+ testb $3, CS(%rdi)
16429+ jnz 1f
16430+ pax_enter_kernel
16431+ jmp 2f
16432+1: pax_enter_kernel_user
16433+2:
16434+#else
16435+ pax_enter_kernel
16436+#endif
16437+
16438 /* We entered an interrupt context - irqs are off: */
16439 TRACE_IRQS_OFF
16440
16441@@ -608,7 +1033,7 @@ ret_from_intr:
16442 /* Restore saved previous stack */
16443 popq %rsi
16444 /* return code expects complete pt_regs - adjust rsp accordingly: */
16445- leaq -RBP(%rsi), %rsp
16446+ movq %rsi, %rsp
16447
16448 testb $3, CS(%rsp)
16449 jz retint_kernel
16450@@ -630,6 +1055,8 @@ retint_swapgs: /* return to user-space */
16451 * The iretq could re-enable interrupts:
16452 */
16453 DISABLE_INTERRUPTS(CLBR_ANY)
16454+ pax_exit_kernel_user
16455+# pax_erase_kstack
16456 TRACE_IRQS_IRETQ
16457
16458 SWAPGS
16459@@ -648,6 +1075,21 @@ retint_kernel:
16460 jmp 0b
16461 1:
16462 #endif
16463+
16464+ pax_exit_kernel
16465+
16466+#if defined(CONFIG_EFI) && defined(CONFIG_PAX_KERNEXEC)
16467+ /* This is a quirk to allow IRQs/NMIs/MCEs during early EFI setup,
16468+ * namely calling EFI runtime services with a phys mapping. We're
16469+ * starting off with NOPs and patch in the real instrumentation
16470+ * (BTS/OR) before starting any userland process; even before starting
16471+ * up the APs.
16472+ */
16473+ ALTERNATIVE "", "pax_force_retaddr 16*8", X86_FEATURE_ALWAYS
16474+#else
16475+ pax_force_retaddr RIP
16476+#endif
16477+
16478 /*
16479 * The iretq could re-enable interrupts:
16480 */
16481@@ -689,15 +1131,15 @@ native_irq_return_ldt:
16482 SWAPGS
16483 movq PER_CPU_VAR(espfix_waddr), %rdi
16484 movq %rax, (0*8)(%rdi) /* RAX */
16485- movq (2*8)(%rsp), %rax /* RIP */
16486+ movq (2*8 + RIP-RIP)(%rsp), %rax /* RIP */
16487 movq %rax, (1*8)(%rdi)
16488- movq (3*8)(%rsp), %rax /* CS */
16489+ movq (2*8 + CS-RIP)(%rsp), %rax /* CS */
16490 movq %rax, (2*8)(%rdi)
16491- movq (4*8)(%rsp), %rax /* RFLAGS */
16492+ movq (2*8 + EFLAGS-RIP)(%rsp), %rax /* RFLAGS */
16493 movq %rax, (3*8)(%rdi)
16494- movq (6*8)(%rsp), %rax /* SS */
16495+ movq (2*8 + SS-RIP)(%rsp), %rax /* SS */
16496 movq %rax, (5*8)(%rdi)
16497- movq (5*8)(%rsp), %rax /* RSP */
16498+ movq (2*8 + RSP-RIP)(%rsp), %rax /* RSP */
16499 movq %rax, (4*8)(%rdi)
16500 andl $0xffff0000, %eax
16501 popq %rdi
16502@@ -738,7 +1180,7 @@ retint_signal:
16503 GET_THREAD_INFO(%rcx)
16504 jmp retint_with_reschedule
16505
16506-END(common_interrupt)
16507+ENDPROC(common_interrupt)
16508
16509 /*
16510 * APIC interrupts.
16511@@ -750,7 +1192,7 @@ ENTRY(\sym)
16512 .Lcommon_\sym:
16513 interrupt \do_sym
16514 jmp ret_from_intr
16515-END(\sym)
16516+ENDPROC(\sym)
16517 .endm
16518
16519 #ifdef CONFIG_TRACING
16520@@ -815,7 +1257,7 @@ apicinterrupt IRQ_WORK_VECTOR irq_work_interrupt smp_irq_work_interrupt
16521 /*
16522 * Exception entry points.
16523 */
16524-#define CPU_TSS_IST(x) PER_CPU_VAR(cpu_tss) + (TSS_ist + ((x) - 1) * 8)
16525+#define CPU_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r13)
16526
16527 .macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1
16528 ENTRY(\sym)
16529@@ -862,6 +1304,12 @@ ENTRY(\sym)
16530 .endif
16531
16532 .if \shift_ist != -1
16533+#ifdef CONFIG_SMP
16534+ imul $TSS_size, PER_CPU_VAR(cpu_number), %r13d
16535+ lea cpu_tss(%r13), %r13
16536+#else
16537+ lea cpu_tss(%rip), %r13
16538+#endif
16539 subq $EXCEPTION_STKSZ, CPU_TSS_IST(\shift_ist)
16540 .endif
16541
16542@@ -905,7 +1353,7 @@ ENTRY(\sym)
16543
16544 jmp error_exit /* %ebx: no swapgs flag */
16545 .endif
16546-END(\sym)
16547+ENDPROC(\sym)
16548 .endm
16549
16550 #ifdef CONFIG_TRACING
16551@@ -947,8 +1395,9 @@ gs_change:
16552 2: mfence /* workaround */
16553 SWAPGS
16554 popfq
16555+ pax_force_retaddr
16556 ret
16557-END(native_load_gs_index)
16558+ENDPROC(native_load_gs_index)
16559
16560 _ASM_EXTABLE(gs_change, bad_gs)
16561 .section .fixup, "ax"
16562@@ -970,8 +1419,9 @@ ENTRY(do_softirq_own_stack)
16563 call __do_softirq
16564 leaveq
16565 decl PER_CPU_VAR(irq_count)
16566+ pax_force_retaddr
16567 ret
16568-END(do_softirq_own_stack)
16569+ENDPROC(do_softirq_own_stack)
16570
16571 #ifdef CONFIG_XEN
16572 idtentry xen_hypervisor_callback xen_do_hypervisor_callback has_error_code=0
16573@@ -1007,7 +1457,7 @@ ENTRY(xen_do_hypervisor_callback) /* do_hypervisor_callback(struct *pt_regs) */
16574 call xen_maybe_preempt_hcall
16575 #endif
16576 jmp error_exit
16577-END(xen_do_hypervisor_callback)
16578+ENDPROC(xen_do_hypervisor_callback)
16579
16580 /*
16581 * Hypervisor uses this for application faults while it executes.
16582@@ -1052,7 +1502,7 @@ ENTRY(xen_failsafe_callback)
16583 SAVE_C_REGS
16584 SAVE_EXTRA_REGS
16585 jmp error_exit
16586-END(xen_failsafe_callback)
16587+ENDPROC(xen_failsafe_callback)
16588
16589 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
16590 xen_hvm_callback_vector xen_evtchn_do_upcall
16591@@ -1101,8 +1551,36 @@ ENTRY(paranoid_entry)
16592 js 1f /* negative -> in kernel */
16593 SWAPGS
16594 xorl %ebx, %ebx
16595-1: ret
16596-END(paranoid_entry)
16597+1:
16598+#ifdef CONFIG_PAX_MEMORY_UDEREF
16599+ testb $3, CS+8(%rsp)
16600+ jnz 1f
16601+ pax_enter_kernel
16602+ jmp 2f
16603+1: pax_enter_kernel_user
16604+2:
16605+#else
16606+ pax_enter_kernel
16607+#endif
16608+ pax_force_retaddr
16609+ ret
16610+ENDPROC(paranoid_entry)
16611+
16612+ENTRY(paranoid_entry_nmi)
16613+ cld
16614+ SAVE_C_REGS 8
16615+ SAVE_EXTRA_REGS 8
16616+ movl $1, %ebx
16617+ movl $MSR_GS_BASE, %ecx
16618+ rdmsr
16619+ testl %edx, %edx
16620+ js 1f /* negative -> in kernel */
16621+ SWAPGS
16622+ xorl %ebx, %ebx
16623+1: pax_enter_kernel_nmi
16624+ pax_force_retaddr
16625+ ret
16626+ENDPROC(paranoid_entry_nmi)
16627
16628 /*
16629 * "Paranoid" exit path from exception stack. This is invoked
16630@@ -1119,19 +1597,26 @@ END(paranoid_entry)
16631 ENTRY(paranoid_exit)
16632 DISABLE_INTERRUPTS(CLBR_NONE)
16633 TRACE_IRQS_OFF_DEBUG
16634- testl %ebx, %ebx /* swapgs needed? */
16635+ testl $1, %ebx /* swapgs needed? */
16636 jnz paranoid_exit_no_swapgs
16637+#ifdef CONFIG_PAX_MEMORY_UDEREF
16638+ pax_exit_kernel_user
16639+#else
16640+ pax_exit_kernel
16641+#endif
16642 TRACE_IRQS_IRETQ
16643 SWAPGS_UNSAFE_STACK
16644 jmp paranoid_exit_restore
16645 paranoid_exit_no_swapgs:
16646+ pax_exit_kernel
16647 TRACE_IRQS_IRETQ_DEBUG
16648 paranoid_exit_restore:
16649 RESTORE_EXTRA_REGS
16650 RESTORE_C_REGS
16651 REMOVE_PT_GPREGS_FROM_STACK 8
16652+ pax_force_retaddr_bts
16653 INTERRUPT_RETURN
16654-END(paranoid_exit)
16655+ENDPROC(paranoid_exit)
16656
16657 /*
16658 * Save all registers in pt_regs, and switch gs if needed.
16659@@ -1149,7 +1634,18 @@ ENTRY(error_entry)
16660 SWAPGS
16661
16662 error_entry_done:
16663+#ifdef CONFIG_PAX_MEMORY_UDEREF
16664+ testb $3, CS+8(%rsp)
16665+ jnz 1f
16666+ pax_enter_kernel
16667+ jmp 2f
16668+1: pax_enter_kernel_user
16669+2:
16670+#else
16671+ pax_enter_kernel
16672+#endif
16673 TRACE_IRQS_OFF
16674+ pax_force_retaddr
16675 ret
16676
16677 /*
16678@@ -1199,7 +1695,7 @@ error_bad_iret:
16679 mov %rax, %rsp
16680 decl %ebx
16681 jmp error_entry_done
16682-END(error_entry)
16683+ENDPROC(error_entry)
16684
16685
16686 /*
16687@@ -1212,10 +1708,10 @@ ENTRY(error_exit)
16688 RESTORE_EXTRA_REGS
16689 DISABLE_INTERRUPTS(CLBR_NONE)
16690 TRACE_IRQS_OFF
16691- testl %eax, %eax
16692+ testl $1, %eax
16693 jnz retint_kernel
16694 jmp retint_user
16695-END(error_exit)
16696+ENDPROC(error_exit)
16697
16698 /* Runs on exception stack */
16699 ENTRY(nmi)
16700@@ -1269,6 +1765,8 @@ ENTRY(nmi)
16701 * other IST entries.
16702 */
16703
16704+ ASM_CLAC
16705+
16706 /* Use %rdx as our temp variable throughout */
16707 pushq %rdx
16708
16709@@ -1312,6 +1810,12 @@ ENTRY(nmi)
16710 pushq %r14 /* pt_regs->r14 */
16711 pushq %r15 /* pt_regs->r15 */
16712
16713+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
16714+ xorl %ebx, %ebx
16715+#endif
16716+
16717+ pax_enter_kernel_nmi
16718+
16719 /*
16720 * At this point we no longer need to worry about stack damage
16721 * due to nesting -- we're on the normal thread stack and we're
16722@@ -1322,12 +1826,19 @@ ENTRY(nmi)
16723 movq $-1, %rsi
16724 call do_nmi
16725
16726+ pax_exit_kernel_nmi
16727+
16728 /*
16729 * Return back to user mode. We must *not* do the normal exit
16730 * work, because we don't want to enable interrupts. Fortunately,
16731 * do_nmi doesn't modify pt_regs.
16732 */
16733 SWAPGS
16734+
16735+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
16736+ movq RBX(%rsp), %rbx
16737+#endif
16738+
16739 jmp restore_c_regs_and_iret
16740
16741 .Lnmi_from_kernel:
16742@@ -1449,6 +1960,7 @@ nested_nmi_out:
16743 popq %rdx
16744
16745 /* We are returning to kernel mode, so this cannot result in a fault. */
16746+# pax_force_retaddr_bts
16747 INTERRUPT_RETURN
16748
16749 first_nmi:
16750@@ -1522,20 +2034,22 @@ end_repeat_nmi:
16751 ALLOC_PT_GPREGS_ON_STACK
16752
16753 /*
16754- * Use paranoid_entry to handle SWAPGS, but no need to use paranoid_exit
16755+ * Use paranoid_entry_nmi to handle SWAPGS, but no need to use paranoid_exit
16756 * as we should not be calling schedule in NMI context.
16757 * Even with normal interrupts enabled. An NMI should not be
16758 * setting NEED_RESCHED or anything that normal interrupts and
16759 * exceptions might do.
16760 */
16761- call paranoid_entry
16762+ call paranoid_entry_nmi
16763
16764 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
16765 movq %rsp, %rdi
16766 movq $-1, %rsi
16767 call do_nmi
16768
16769- testl %ebx, %ebx /* swapgs needed? */
16770+ pax_exit_kernel_nmi
16771+
16772+ testl $1, %ebx /* swapgs needed? */
16773 jnz nmi_restore
16774 nmi_swapgs:
16775 SWAPGS_UNSAFE_STACK
16776@@ -1546,6 +2060,8 @@ nmi_restore:
16777 /* Point RSP at the "iret" frame. */
16778 REMOVE_PT_GPREGS_FROM_STACK 6*8
16779
16780+ pax_force_retaddr_bts
16781+
16782 /*
16783 * Clear "NMI executing". Set DF first so that we can easily
16784 * distinguish the remaining code between here and IRET from
16785@@ -1563,9 +2079,9 @@ nmi_restore:
16786 * mode, so this cannot result in a fault.
16787 */
16788 INTERRUPT_RETURN
16789-END(nmi)
16790+ENDPROC(nmi)
16791
16792 ENTRY(ignore_sysret)
16793 mov $-ENOSYS, %eax
16794 sysret
16795-END(ignore_sysret)
16796+ENDPROC(ignore_sysret)
16797diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
16798index a7e257d..3a6ad23 100644
16799--- a/arch/x86/entry/entry_64_compat.S
16800+++ b/arch/x86/entry/entry_64_compat.S
16801@@ -13,8 +13,10 @@
16802 #include <asm/irqflags.h>
16803 #include <asm/asm.h>
16804 #include <asm/smap.h>
16805+#include <asm/pgtable.h>
16806 #include <linux/linkage.h>
16807 #include <linux/err.h>
16808+#include <asm/alternative-asm.h>
16809
16810 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
16811 #include <linux/elf-em.h>
16812@@ -35,6 +37,32 @@ ENTRY(native_usergs_sysret32)
16813 ENDPROC(native_usergs_sysret32)
16814 #endif
16815
16816+ .macro pax_enter_kernel_user
16817+ pax_set_fptr_mask
16818+#ifdef CONFIG_PAX_MEMORY_UDEREF
16819+ call pax_enter_kernel_user
16820+#endif
16821+ .endm
16822+
16823+ .macro pax_exit_kernel_user
16824+#ifdef CONFIG_PAX_MEMORY_UDEREF
16825+ call pax_exit_kernel_user
16826+#endif
16827+#ifdef CONFIG_PAX_RANDKSTACK
16828+ pushq %rax
16829+ pushq %r11
16830+ call pax_randomize_kstack
16831+ popq %r11
16832+ popq %rax
16833+#endif
16834+ .endm
16835+
16836+ .macro pax_erase_kstack
16837+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16838+ call pax_erase_kstack
16839+#endif
16840+ .endm
16841+
16842 /*
16843 * 32-bit SYSENTER instruction entry.
16844 *
16845@@ -65,20 +93,21 @@ ENTRY(entry_SYSENTER_compat)
16846 */
16847 SWAPGS_UNSAFE_STACK
16848 movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
16849- ENABLE_INTERRUPTS(CLBR_NONE)
16850
16851 /* Zero-extending 32-bit regs, do not remove */
16852 movl %ebp, %ebp
16853 movl %eax, %eax
16854
16855- movl ASM_THREAD_INFO(TI_sysenter_return, %rsp, 0), %r10d
16856+ GET_THREAD_INFO(%r11)
16857+ movl TI_sysenter_return(%r11), %r11d
16858
16859 /* Construct struct pt_regs on stack */
16860 pushq $__USER32_DS /* pt_regs->ss */
16861 pushq %rbp /* pt_regs->sp */
16862 pushfq /* pt_regs->flags */
16863+ orl $X86_EFLAGS_IF,(%rsp)
16864 pushq $__USER32_CS /* pt_regs->cs */
16865- pushq %r10 /* pt_regs->ip = thread_info->sysenter_return */
16866+ pushq %r11 /* pt_regs->ip = thread_info->sysenter_return */
16867 pushq %rax /* pt_regs->orig_ax */
16868 pushq %rdi /* pt_regs->di */
16869 pushq %rsi /* pt_regs->si */
16870@@ -88,15 +117,37 @@ ENTRY(entry_SYSENTER_compat)
16871 cld
16872 sub $(10*8), %rsp /* pt_regs->r8-11, bp, bx, r12-15 not saved */
16873
16874+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16875+ movq %r12, R12(%rsp)
16876+#endif
16877+
16878+ pax_enter_kernel_user
16879+
16880+#ifdef CONFIG_PAX_RANDKSTACK
16881+ pax_erase_kstack
16882+#endif
16883+
16884+ ENABLE_INTERRUPTS(CLBR_NONE)
16885+
16886 /*
16887 * no need to do an access_ok check here because rbp has been
16888 * 32-bit zero extended
16889 */
16890+
16891+#ifdef CONFIG_PAX_MEMORY_UDEREF
16892+ addq pax_user_shadow_base, %rbp
16893+ ASM_PAX_OPEN_USERLAND
16894+#endif
16895+
16896 ASM_STAC
16897 1: movl (%rbp), %ebp
16898 _ASM_EXTABLE(1b, ia32_badarg)
16899 ASM_CLAC
16900
16901+#ifdef CONFIG_PAX_MEMORY_UDEREF
16902+ ASM_PAX_CLOSE_USERLAND
16903+#endif
16904+
16905 /*
16906 * Sysenter doesn't filter flags, so we need to clear NT
16907 * ourselves. To save a few cycles, we can check whether
16908@@ -106,8 +157,9 @@ ENTRY(entry_SYSENTER_compat)
16909 jnz sysenter_fix_flags
16910 sysenter_flags_fixed:
16911
16912- orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
16913- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16914+ GET_THREAD_INFO(%r11)
16915+ orl $TS_COMPAT, TI_status(%r11)
16916+ testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%r11)
16917 jnz sysenter_tracesys
16918
16919 sysenter_do_call:
16920@@ -123,9 +175,10 @@ sysenter_dispatch:
16921 call *ia32_sys_call_table(, %rax, 8)
16922 movq %rax, RAX(%rsp)
16923 1:
16924+ GET_THREAD_INFO(%r11)
16925 DISABLE_INTERRUPTS(CLBR_NONE)
16926 TRACE_IRQS_OFF
16927- testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16928+ testl $_TIF_ALLWORK_MASK, TI_flags(%r11)
16929 jnz sysexit_audit
16930 sysexit_from_sys_call:
16931 /*
16932@@ -138,7 +191,9 @@ sysexit_from_sys_call:
16933 * This code path is still called 'sysexit' because it pairs
16934 * with 'sysenter' and it uses the SYSENTER calling convention.
16935 */
16936- andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
16937+ pax_exit_kernel_user
16938+ pax_erase_kstack
16939+ andl $~TS_COMPAT, TI_status(%r11)
16940 movl RIP(%rsp), %ecx /* User %eip */
16941 movq RAX(%rsp), %rax
16942 RESTORE_RSI_RDI
16943@@ -194,6 +249,8 @@ sysexit_from_sys_call:
16944 movl %eax, %edi /* arg1 (RDI) <= syscall number (EAX) */
16945 call __audit_syscall_entry
16946
16947+ pax_erase_kstack
16948+
16949 /*
16950 * We are going to jump back to the syscall dispatch code.
16951 * Prepare syscall args as required by the 64-bit C ABI.
16952@@ -209,7 +266,7 @@ sysexit_from_sys_call:
16953 .endm
16954
16955 .macro auditsys_exit exit
16956- testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16957+ testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), TI_flags(%r11)
16958 jnz ia32_ret_from_sys_call
16959 TRACE_IRQS_ON
16960 ENABLE_INTERRUPTS(CLBR_NONE)
16961@@ -220,10 +277,11 @@ sysexit_from_sys_call:
16962 1: setbe %al /* 1 if error, 0 if not */
16963 movzbl %al, %edi /* zero-extend that into %edi */
16964 call __audit_syscall_exit
16965+ GET_THREAD_INFO(%r11)
16966 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %edi
16967 DISABLE_INTERRUPTS(CLBR_NONE)
16968 TRACE_IRQS_OFF
16969- testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16970+ testl %edi, TI_flags(%r11)
16971 jz \exit
16972 xorl %eax, %eax /* Do not leak kernel information */
16973 movq %rax, R11(%rsp)
16974@@ -249,7 +307,7 @@ sysenter_fix_flags:
16975
16976 sysenter_tracesys:
16977 #ifdef CONFIG_AUDITSYSCALL
16978- testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16979+ testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), TI_flags(%r11)
16980 jz sysenter_auditsys
16981 #endif
16982 SAVE_EXTRA_REGS
16983@@ -269,6 +327,9 @@ sysenter_tracesys:
16984 movl %eax, %eax /* zero extension */
16985
16986 RESTORE_EXTRA_REGS
16987+
16988+ pax_erase_kstack
16989+
16990 jmp sysenter_do_call
16991 ENDPROC(entry_SYSENTER_compat)
16992
16993@@ -311,7 +372,6 @@ ENTRY(entry_SYSCALL_compat)
16994 SWAPGS_UNSAFE_STACK
16995 movl %esp, %r8d
16996 movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
16997- ENABLE_INTERRUPTS(CLBR_NONE)
16998
16999 /* Zero-extending 32-bit regs, do not remove */
17000 movl %eax, %eax
17001@@ -331,16 +391,41 @@ ENTRY(entry_SYSCALL_compat)
17002 pushq $-ENOSYS /* pt_regs->ax */
17003 sub $(10*8), %rsp /* pt_regs->r8-11, bp, bx, r12-15 not saved */
17004
17005+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
17006+ movq %r12, R12(%rsp)
17007+#endif
17008+
17009+ pax_enter_kernel_user
17010+
17011+#ifdef CONFIG_PAX_RANDKSTACK
17012+ pax_erase_kstack
17013+#endif
17014+
17015+ ENABLE_INTERRUPTS(CLBR_NONE)
17016+
17017 /*
17018 * No need to do an access_ok check here because r8 has been
17019 * 32-bit zero extended:
17020 */
17021+
17022+#ifdef CONFIG_PAX_MEMORY_UDEREF
17023+ ASM_PAX_OPEN_USERLAND
17024+ movq pax_user_shadow_base, %r8
17025+ addq RSP(%rsp), %r8
17026+#endif
17027+
17028 ASM_STAC
17029 1: movl (%r8), %r9d
17030 _ASM_EXTABLE(1b, ia32_badarg)
17031 ASM_CLAC
17032- orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
17033- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
17034+
17035+#ifdef CONFIG_PAX_MEMORY_UDEREF
17036+ ASM_PAX_CLOSE_USERLAND
17037+#endif
17038+
17039+ GET_THREAD_INFO(%r11)
17040+ orl $TS_COMPAT,TI_status(%r11)
17041+ testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
17042 jnz cstar_tracesys
17043
17044 cstar_do_call:
17045@@ -358,13 +443,16 @@ cstar_dispatch:
17046 call *ia32_sys_call_table(, %rax, 8)
17047 movq %rax, RAX(%rsp)
17048 1:
17049+ GET_THREAD_INFO(%r11)
17050 DISABLE_INTERRUPTS(CLBR_NONE)
17051 TRACE_IRQS_OFF
17052- testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
17053+ testl $_TIF_ALLWORK_MASK, TI_flags(%r11)
17054 jnz sysretl_audit
17055
17056 sysretl_from_sys_call:
17057- andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
17058+ pax_exit_kernel_user
17059+ pax_erase_kstack
17060+ andl $~TS_COMPAT, TI_status(%r11)
17061 RESTORE_RSI_RDI_RDX
17062 movl RIP(%rsp), %ecx
17063 movl EFLAGS(%rsp), %r11d
17064@@ -403,7 +491,7 @@ sysretl_audit:
17065
17066 cstar_tracesys:
17067 #ifdef CONFIG_AUDITSYSCALL
17068- testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
17069+ testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), TI_flags(%r11)
17070 jz cstar_auditsys
17071 #endif
17072 xchgl %r9d, %ebp
17073@@ -426,11 +514,19 @@ cstar_tracesys:
17074
17075 RESTORE_EXTRA_REGS
17076 xchgl %ebp, %r9d
17077+
17078+ pax_erase_kstack
17079+
17080 jmp cstar_do_call
17081 END(entry_SYSCALL_compat)
17082
17083 ia32_badarg:
17084 ASM_CLAC
17085+
17086+#ifdef CONFIG_PAX_MEMORY_UDEREF
17087+ ASM_PAX_CLOSE_USERLAND
17088+#endif
17089+
17090 movq $-EFAULT, RAX(%rsp)
17091 ia32_ret_from_sys_call:
17092 xorl %eax, %eax /* Do not leak kernel information */
17093@@ -462,14 +558,8 @@ ia32_ret_from_sys_call:
17094 */
17095
17096 ENTRY(entry_INT80_compat)
17097- /*
17098- * Interrupts are off on entry.
17099- * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
17100- * it is too small to ever cause noticeable irq latency.
17101- */
17102 PARAVIRT_ADJUST_EXCEPTION_FRAME
17103 SWAPGS
17104- ENABLE_INTERRUPTS(CLBR_NONE)
17105
17106 /* Zero-extending 32-bit regs, do not remove */
17107 movl %eax, %eax
17108@@ -488,8 +578,26 @@ ENTRY(entry_INT80_compat)
17109 cld
17110 sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */
17111
17112- orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
17113- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
17114+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
17115+ movq %r12, R12(%rsp)
17116+#endif
17117+
17118+ pax_enter_kernel_user
17119+
17120+#ifdef CONFIG_PAX_RANDKSTACK
17121+ pax_erase_kstack
17122+#endif
17123+
17124+ /*
17125+ * Interrupts are off on entry.
17126+ * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
17127+ * it is too small to ever cause noticeable irq latency.
17128+ */
17129+ ENABLE_INTERRUPTS(CLBR_NONE)
17130+
17131+ GET_THREAD_INFO(%r11)
17132+ orl $TS_COMPAT, TI_status(%r11)
17133+ testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%r11)
17134 jnz ia32_tracesys
17135
17136 ia32_do_call:
17137@@ -524,6 +632,9 @@ ia32_tracesys:
17138 movl RDI(%rsp), %edi
17139 movl %eax, %eax /* zero extension */
17140 RESTORE_EXTRA_REGS
17141+
17142+ pax_erase_kstack
17143+
17144 jmp ia32_do_call
17145 END(entry_INT80_compat)
17146
17147diff --git a/arch/x86/entry/thunk_64.S b/arch/x86/entry/thunk_64.S
17148index efb2b93..8a9cb8e 100644
17149--- a/arch/x86/entry/thunk_64.S
17150+++ b/arch/x86/entry/thunk_64.S
17151@@ -8,6 +8,7 @@
17152 #include <linux/linkage.h>
17153 #include "calling.h"
17154 #include <asm/asm.h>
17155+#include <asm/alternative-asm.h>
17156
17157 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
17158 .macro THUNK name, func, put_ret_addr_in_rdi=0
17159@@ -62,6 +63,7 @@ restore:
17160 popq %rdx
17161 popq %rsi
17162 popq %rdi
17163+ pax_force_retaddr
17164 ret
17165 _ASM_NOKPROBE(restore)
17166 #endif
17167diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
17168index e970320..c006fea 100644
17169--- a/arch/x86/entry/vdso/Makefile
17170+++ b/arch/x86/entry/vdso/Makefile
17171@@ -175,7 +175,7 @@ quiet_cmd_vdso = VDSO $@
17172 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
17173 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
17174
17175-VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
17176+VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
17177 $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS)
17178 GCOV_PROFILE := n
17179
17180diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h
17181index 0224987..8deb742 100644
17182--- a/arch/x86/entry/vdso/vdso2c.h
17183+++ b/arch/x86/entry/vdso/vdso2c.h
17184@@ -12,7 +12,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
17185 unsigned long load_size = -1; /* Work around bogus warning */
17186 unsigned long mapping_size;
17187 ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr;
17188- int i;
17189+ unsigned int i;
17190 unsigned long j;
17191 ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
17192 *alt_sec = NULL;
17193@@ -83,7 +83,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
17194 for (i = 0;
17195 i < GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
17196 i++) {
17197- int k;
17198+ unsigned int k;
17199 ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) +
17200 GET_LE(&symtab_hdr->sh_entsize) * i;
17201 const char *name = raw_addr + GET_LE(&strtab_hdr->sh_offset) +
17202diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
17203index 1c9f750..cfddb1a 100644
17204--- a/arch/x86/entry/vdso/vma.c
17205+++ b/arch/x86/entry/vdso/vma.c
17206@@ -19,10 +19,7 @@
17207 #include <asm/page.h>
17208 #include <asm/hpet.h>
17209 #include <asm/desc.h>
17210-
17211-#if defined(CONFIG_X86_64)
17212-unsigned int __read_mostly vdso64_enabled = 1;
17213-#endif
17214+#include <asm/mman.h>
17215
17216 void __init init_vdso_image(const struct vdso_image *image)
17217 {
17218@@ -101,6 +98,11 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
17219 .pages = no_pages,
17220 };
17221
17222+#ifdef CONFIG_PAX_RANDMMAP
17223+ if (mm->pax_flags & MF_PAX_RANDMMAP)
17224+ calculate_addr = false;
17225+#endif
17226+
17227 if (calculate_addr) {
17228 addr = vdso_addr(current->mm->start_stack,
17229 image->size - image->sym_vvar_start);
17230@@ -111,14 +113,14 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
17231 down_write(&mm->mmap_sem);
17232
17233 addr = get_unmapped_area(NULL, addr,
17234- image->size - image->sym_vvar_start, 0, 0);
17235+ image->size - image->sym_vvar_start, 0, MAP_EXECUTABLE);
17236 if (IS_ERR_VALUE(addr)) {
17237 ret = addr;
17238 goto up_fail;
17239 }
17240
17241 text_start = addr - image->sym_vvar_start;
17242- current->mm->context.vdso = (void __user *)text_start;
17243+ mm->context.vdso = text_start;
17244
17245 /*
17246 * MAYWRITE to allow gdb to COW and set breakpoints
17247@@ -163,15 +165,12 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
17248 hpet_address >> PAGE_SHIFT,
17249 PAGE_SIZE,
17250 pgprot_noncached(PAGE_READONLY));
17251-
17252- if (ret)
17253- goto up_fail;
17254 }
17255 #endif
17256
17257 up_fail:
17258 if (ret)
17259- current->mm->context.vdso = NULL;
17260+ current->mm->context.vdso = 0;
17261
17262 up_write(&mm->mmap_sem);
17263 return ret;
17264@@ -191,8 +190,8 @@ static int load_vdso32(void)
17265
17266 if (selected_vdso32->sym_VDSO32_SYSENTER_RETURN)
17267 current_thread_info()->sysenter_return =
17268- current->mm->context.vdso +
17269- selected_vdso32->sym_VDSO32_SYSENTER_RETURN;
17270+ (void __force_user *)(current->mm->context.vdso +
17271+ selected_vdso32->sym_VDSO32_SYSENTER_RETURN);
17272
17273 return 0;
17274 }
17275@@ -201,9 +200,6 @@ static int load_vdso32(void)
17276 #ifdef CONFIG_X86_64
17277 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
17278 {
17279- if (!vdso64_enabled)
17280- return 0;
17281-
17282 return map_vdso(&vdso_image_64, true);
17283 }
17284
17285@@ -212,12 +208,8 @@ int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
17286 int uses_interp)
17287 {
17288 #ifdef CONFIG_X86_X32_ABI
17289- if (test_thread_flag(TIF_X32)) {
17290- if (!vdso64_enabled)
17291- return 0;
17292-
17293+ if (test_thread_flag(TIF_X32))
17294 return map_vdso(&vdso_image_x32, true);
17295- }
17296 #endif
17297
17298 return load_vdso32();
17299@@ -231,15 +223,6 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
17300 #endif
17301
17302 #ifdef CONFIG_X86_64
17303-static __init int vdso_setup(char *s)
17304-{
17305- vdso64_enabled = simple_strtoul(s, NULL, 0);
17306- return 0;
17307-}
17308-__setup("vdso=", vdso_setup);
17309-#endif
17310-
17311-#ifdef CONFIG_X86_64
17312 static void vgetcpu_cpu_init(void *arg)
17313 {
17314 int cpu = smp_processor_id();
17315diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c
17316index 2dcc6ff..082dc7a 100644
17317--- a/arch/x86/entry/vsyscall/vsyscall_64.c
17318+++ b/arch/x86/entry/vsyscall/vsyscall_64.c
17319@@ -38,15 +38,13 @@
17320 #define CREATE_TRACE_POINTS
17321 #include "vsyscall_trace.h"
17322
17323-static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
17324+static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
17325
17326 static int __init vsyscall_setup(char *str)
17327 {
17328 if (str) {
17329 if (!strcmp("emulate", str))
17330 vsyscall_mode = EMULATE;
17331- else if (!strcmp("native", str))
17332- vsyscall_mode = NATIVE;
17333 else if (!strcmp("none", str))
17334 vsyscall_mode = NONE;
17335 else
17336@@ -264,8 +262,7 @@ do_ret:
17337 return true;
17338
17339 sigsegv:
17340- force_sig(SIGSEGV, current);
17341- return true;
17342+ do_group_exit(SIGKILL);
17343 }
17344
17345 /*
17346@@ -283,8 +280,8 @@ static struct vm_operations_struct gate_vma_ops = {
17347 static struct vm_area_struct gate_vma = {
17348 .vm_start = VSYSCALL_ADDR,
17349 .vm_end = VSYSCALL_ADDR + PAGE_SIZE,
17350- .vm_page_prot = PAGE_READONLY_EXEC,
17351- .vm_flags = VM_READ | VM_EXEC,
17352+ .vm_page_prot = PAGE_READONLY,
17353+ .vm_flags = VM_READ,
17354 .vm_ops = &gate_vma_ops,
17355 };
17356
17357@@ -325,10 +322,7 @@ void __init map_vsyscall(void)
17358 unsigned long physaddr_vsyscall = __pa_symbol(&__vsyscall_page);
17359
17360 if (vsyscall_mode != NONE)
17361- __set_fixmap(VSYSCALL_PAGE, physaddr_vsyscall,
17362- vsyscall_mode == NATIVE
17363- ? PAGE_KERNEL_VSYSCALL
17364- : PAGE_KERNEL_VVAR);
17365+ __set_fixmap(VSYSCALL_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
17366
17367 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_PAGE) !=
17368 (unsigned long)VSYSCALL_ADDR);
17369diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
17370index ae6aad1..719d6d9 100644
17371--- a/arch/x86/ia32/ia32_aout.c
17372+++ b/arch/x86/ia32/ia32_aout.c
17373@@ -153,6 +153,8 @@ static int aout_core_dump(struct coredump_params *cprm)
17374 unsigned long dump_start, dump_size;
17375 struct user32 dump;
17376
17377+ memset(&dump, 0, sizeof(dump));
17378+
17379 fs = get_fs();
17380 set_fs(KERNEL_DS);
17381 has_dumped = 1;
17382diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
17383index ae3a29a..cea65e9 100644
17384--- a/arch/x86/ia32/ia32_signal.c
17385+++ b/arch/x86/ia32/ia32_signal.c
17386@@ -216,7 +216,7 @@ asmlinkage long sys32_sigreturn(void)
17387 if (__get_user(set.sig[0], &frame->sc.oldmask)
17388 || (_COMPAT_NSIG_WORDS > 1
17389 && __copy_from_user((((char *) &set.sig) + 4),
17390- &frame->extramask,
17391+ frame->extramask,
17392 sizeof(frame->extramask))))
17393 goto badframe;
17394
17395@@ -336,7 +336,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
17396 sp -= frame_size;
17397 /* Align the stack pointer according to the i386 ABI,
17398 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
17399- sp = ((sp + 4) & -16ul) - 4;
17400+ sp = ((sp - 12) & -16ul) - 4;
17401 return (void __user *) sp;
17402 }
17403
17404@@ -381,10 +381,10 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
17405 } else {
17406 /* Return stub is in 32bit vsyscall page */
17407 if (current->mm->context.vdso)
17408- restorer = current->mm->context.vdso +
17409- selected_vdso32->sym___kernel_sigreturn;
17410+ restorer = (void __force_user *)(current->mm->context.vdso +
17411+ selected_vdso32->sym___kernel_sigreturn);
17412 else
17413- restorer = &frame->retcode;
17414+ restorer = frame->retcode;
17415 }
17416
17417 put_user_try {
17418@@ -394,7 +394,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
17419 * These are actually not used anymore, but left because some
17420 * gdb versions depend on them as a marker.
17421 */
17422- put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
17423+ put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
17424 } put_user_catch(err);
17425
17426 if (err)
17427@@ -436,7 +436,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
17428 0xb8,
17429 __NR_ia32_rt_sigreturn,
17430 0x80cd,
17431- 0,
17432+ 0
17433 };
17434
17435 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
17436@@ -459,16 +459,19 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
17437
17438 if (ksig->ka.sa.sa_flags & SA_RESTORER)
17439 restorer = ksig->ka.sa.sa_restorer;
17440+ else if (current->mm->context.vdso)
17441+ /* Return stub is in 32bit vsyscall page */
17442+ restorer = (void __force_user *)(current->mm->context.vdso +
17443+ selected_vdso32->sym___kernel_rt_sigreturn);
17444 else
17445- restorer = current->mm->context.vdso +
17446- selected_vdso32->sym___kernel_rt_sigreturn;
17447+ restorer = frame->retcode;
17448 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
17449
17450 /*
17451 * Not actually used anymore, but left because some gdb
17452 * versions need it.
17453 */
17454- put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
17455+ put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
17456 } put_user_catch(err);
17457
17458 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
17459diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
17460index 719cd70..72af944 100644
17461--- a/arch/x86/ia32/sys_ia32.c
17462+++ b/arch/x86/ia32/sys_ia32.c
17463@@ -49,18 +49,26 @@
17464
17465 #define AA(__x) ((unsigned long)(__x))
17466
17467+static inline loff_t compose_loff(unsigned int high, unsigned int low)
17468+{
17469+ loff_t retval = low;
17470+
17471+ BUILD_BUG_ON(sizeof retval != sizeof low + sizeof high);
17472+ __builtin_memcpy((unsigned char *)&retval + sizeof low, &high, sizeof high);
17473+ return retval;
17474+}
17475
17476 asmlinkage long sys32_truncate64(const char __user *filename,
17477- unsigned long offset_low,
17478- unsigned long offset_high)
17479+ unsigned int offset_low,
17480+ unsigned int offset_high)
17481 {
17482- return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low);
17483+ return sys_truncate(filename, compose_loff(offset_high, offset_low));
17484 }
17485
17486-asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
17487- unsigned long offset_high)
17488+asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned int offset_low,
17489+ unsigned int offset_high)
17490 {
17491- return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low);
17492+ return sys_ftruncate(fd, ((unsigned long) offset_high << 32) | offset_low);
17493 }
17494
17495 /*
17496@@ -69,8 +77,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
17497 */
17498 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
17499 {
17500- typeof(ubuf->st_uid) uid = 0;
17501- typeof(ubuf->st_gid) gid = 0;
17502+ typeof(((struct stat64 *)0)->st_uid) uid = 0;
17503+ typeof(((struct stat64 *)0)->st_gid) gid = 0;
17504 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
17505 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
17506 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
17507@@ -196,29 +204,29 @@ long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
17508 __u32 len_low, __u32 len_high, int advice)
17509 {
17510 return sys_fadvise64_64(fd,
17511- (((u64)offset_high)<<32) | offset_low,
17512- (((u64)len_high)<<32) | len_low,
17513+ compose_loff(offset_high, offset_low),
17514+ compose_loff(len_high, len_low),
17515 advice);
17516 }
17517
17518 asmlinkage ssize_t sys32_readahead(int fd, unsigned off_lo, unsigned off_hi,
17519 size_t count)
17520 {
17521- return sys_readahead(fd, ((u64)off_hi << 32) | off_lo, count);
17522+ return sys_readahead(fd, compose_loff(off_hi, off_lo), count);
17523 }
17524
17525 asmlinkage long sys32_sync_file_range(int fd, unsigned off_low, unsigned off_hi,
17526 unsigned n_low, unsigned n_hi, int flags)
17527 {
17528 return sys_sync_file_range(fd,
17529- ((u64)off_hi << 32) | off_low,
17530- ((u64)n_hi << 32) | n_low, flags);
17531+ compose_loff(off_hi, off_low),
17532+ compose_loff(n_hi, n_low), flags);
17533 }
17534
17535 asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi,
17536- size_t len, int advice)
17537+ int len, int advice)
17538 {
17539- return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
17540+ return sys_fadvise64_64(fd, compose_loff(offset_hi, offset_lo),
17541 len, advice);
17542 }
17543
17544@@ -226,6 +234,6 @@ asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_lo,
17545 unsigned offset_hi, unsigned len_lo,
17546 unsigned len_hi)
17547 {
17548- return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
17549- ((u64)len_hi << 32) | len_lo);
17550+ return sys_fallocate(fd, mode, compose_loff(offset_hi, offset_lo),
17551+ compose_loff(len_hi, len_lo));
17552 }
17553diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
17554index e7636ba..e1fb78a 100644
17555--- a/arch/x86/include/asm/alternative-asm.h
17556+++ b/arch/x86/include/asm/alternative-asm.h
17557@@ -18,6 +18,45 @@
17558 .endm
17559 #endif
17560
17561+#ifdef KERNEXEC_PLUGIN
17562+ .macro pax_force_retaddr_bts rip=0
17563+ btsq $63,\rip(%rsp)
17564+ .endm
17565+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
17566+ .macro pax_force_retaddr rip=0, reload=0
17567+ btsq $63,\rip(%rsp)
17568+ .endm
17569+ .macro pax_force_fptr ptr
17570+ btsq $63,\ptr
17571+ .endm
17572+ .macro pax_set_fptr_mask
17573+ .endm
17574+#endif
17575+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
17576+ .macro pax_force_retaddr rip=0, reload=0
17577+ .if \reload
17578+ pax_set_fptr_mask
17579+ .endif
17580+ orq %r12,\rip(%rsp)
17581+ .endm
17582+ .macro pax_force_fptr ptr
17583+ orq %r12,\ptr
17584+ .endm
17585+ .macro pax_set_fptr_mask
17586+ movabs $0x8000000000000000,%r12
17587+ .endm
17588+#endif
17589+#else
17590+ .macro pax_force_retaddr rip=0, reload=0
17591+ .endm
17592+ .macro pax_force_fptr ptr
17593+ .endm
17594+ .macro pax_force_retaddr_bts rip=0
17595+ .endm
17596+ .macro pax_set_fptr_mask
17597+ .endm
17598+#endif
17599+
17600 /*
17601 * Issue one struct alt_instr descriptor entry (need to put it into
17602 * the section .altinstructions, see below). This entry contains
17603@@ -50,7 +89,7 @@
17604 altinstruction_entry 140b,143f,\feature,142b-140b,144f-143f,142b-141b
17605 .popsection
17606
17607- .pushsection .altinstr_replacement,"ax"
17608+ .pushsection .altinstr_replacement,"a"
17609 143:
17610 \newinstr
17611 144:
17612@@ -86,7 +125,7 @@
17613 altinstruction_entry 140b,144f,\feature2,142b-140b,145f-144f,142b-141b
17614 .popsection
17615
17616- .pushsection .altinstr_replacement,"ax"
17617+ .pushsection .altinstr_replacement,"a"
17618 143:
17619 \newinstr1
17620 144:
17621diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
17622index 7bfc85b..65d1ec4 100644
17623--- a/arch/x86/include/asm/alternative.h
17624+++ b/arch/x86/include/asm/alternative.h
17625@@ -136,7 +136,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
17626 ".pushsection .altinstructions,\"a\"\n" \
17627 ALTINSTR_ENTRY(feature, 1) \
17628 ".popsection\n" \
17629- ".pushsection .altinstr_replacement, \"ax\"\n" \
17630+ ".pushsection .altinstr_replacement, \"a\"\n" \
17631 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
17632 ".popsection"
17633
17634@@ -146,7 +146,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
17635 ALTINSTR_ENTRY(feature1, 1) \
17636 ALTINSTR_ENTRY(feature2, 2) \
17637 ".popsection\n" \
17638- ".pushsection .altinstr_replacement, \"ax\"\n" \
17639+ ".pushsection .altinstr_replacement, \"a\"\n" \
17640 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
17641 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
17642 ".popsection"
17643diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
17644index c839363..b9a8c43 100644
17645--- a/arch/x86/include/asm/apic.h
17646+++ b/arch/x86/include/asm/apic.h
17647@@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
17648
17649 #ifdef CONFIG_X86_LOCAL_APIC
17650
17651-extern unsigned int apic_verbosity;
17652+extern int apic_verbosity;
17653 extern int local_apic_timer_c2_ok;
17654
17655 extern int disable_apic;
17656diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
17657index 20370c6..a2eb9b0 100644
17658--- a/arch/x86/include/asm/apm.h
17659+++ b/arch/x86/include/asm/apm.h
17660@@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
17661 __asm__ __volatile__(APM_DO_ZERO_SEGS
17662 "pushl %%edi\n\t"
17663 "pushl %%ebp\n\t"
17664- "lcall *%%cs:apm_bios_entry\n\t"
17665+ "lcall *%%ss:apm_bios_entry\n\t"
17666 "setc %%al\n\t"
17667 "popl %%ebp\n\t"
17668 "popl %%edi\n\t"
17669@@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
17670 __asm__ __volatile__(APM_DO_ZERO_SEGS
17671 "pushl %%edi\n\t"
17672 "pushl %%ebp\n\t"
17673- "lcall *%%cs:apm_bios_entry\n\t"
17674+ "lcall *%%ss:apm_bios_entry\n\t"
17675 "setc %%bl\n\t"
17676 "popl %%ebp\n\t"
17677 "popl %%edi\n\t"
17678diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
17679index e916895..42d729d 100644
17680--- a/arch/x86/include/asm/atomic.h
17681+++ b/arch/x86/include/asm/atomic.h
17682@@ -28,6 +28,17 @@ static __always_inline int atomic_read(const atomic_t *v)
17683 }
17684
17685 /**
17686+ * atomic_read_unchecked - read atomic variable
17687+ * @v: pointer of type atomic_unchecked_t
17688+ *
17689+ * Atomically reads the value of @v.
17690+ */
17691+static __always_inline int __intentional_overflow(-1) atomic_read_unchecked(const atomic_unchecked_t *v)
17692+{
17693+ return ACCESS_ONCE((v)->counter);
17694+}
17695+
17696+/**
17697 * atomic_set - set atomic variable
17698 * @v: pointer of type atomic_t
17699 * @i: required value
17700@@ -40,6 +51,18 @@ static __always_inline void atomic_set(atomic_t *v, int i)
17701 }
17702
17703 /**
17704+ * atomic_set_unchecked - set atomic variable
17705+ * @v: pointer of type atomic_unchecked_t
17706+ * @i: required value
17707+ *
17708+ * Atomically sets the value of @v to @i.
17709+ */
17710+static __always_inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
17711+{
17712+ v->counter = i;
17713+}
17714+
17715+/**
17716 * atomic_add - add integer to atomic variable
17717 * @i: integer value to add
17718 * @v: pointer of type atomic_t
17719@@ -48,7 +71,29 @@ static __always_inline void atomic_set(atomic_t *v, int i)
17720 */
17721 static __always_inline void atomic_add(int i, atomic_t *v)
17722 {
17723- asm volatile(LOCK_PREFIX "addl %1,%0"
17724+ asm volatile(LOCK_PREFIX "addl %1,%0\n"
17725+
17726+#ifdef CONFIG_PAX_REFCOUNT
17727+ "jno 0f\n"
17728+ LOCK_PREFIX "subl %1,%0\n"
17729+ "int $4\n0:\n"
17730+ _ASM_EXTABLE(0b, 0b)
17731+#endif
17732+
17733+ : "+m" (v->counter)
17734+ : "ir" (i));
17735+}
17736+
17737+/**
17738+ * atomic_add_unchecked - add integer to atomic variable
17739+ * @i: integer value to add
17740+ * @v: pointer of type atomic_unchecked_t
17741+ *
17742+ * Atomically adds @i to @v.
17743+ */
17744+static __always_inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
17745+{
17746+ asm volatile(LOCK_PREFIX "addl %1,%0\n"
17747 : "+m" (v->counter)
17748 : "ir" (i));
17749 }
17750@@ -62,7 +107,29 @@ static __always_inline void atomic_add(int i, atomic_t *v)
17751 */
17752 static __always_inline void atomic_sub(int i, atomic_t *v)
17753 {
17754- asm volatile(LOCK_PREFIX "subl %1,%0"
17755+ asm volatile(LOCK_PREFIX "subl %1,%0\n"
17756+
17757+#ifdef CONFIG_PAX_REFCOUNT
17758+ "jno 0f\n"
17759+ LOCK_PREFIX "addl %1,%0\n"
17760+ "int $4\n0:\n"
17761+ _ASM_EXTABLE(0b, 0b)
17762+#endif
17763+
17764+ : "+m" (v->counter)
17765+ : "ir" (i));
17766+}
17767+
17768+/**
17769+ * atomic_sub_unchecked - subtract integer from atomic variable
17770+ * @i: integer value to subtract
17771+ * @v: pointer of type atomic_unchecked_t
17772+ *
17773+ * Atomically subtracts @i from @v.
17774+ */
17775+static __always_inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
17776+{
17777+ asm volatile(LOCK_PREFIX "subl %1,%0\n"
17778 : "+m" (v->counter)
17779 : "ir" (i));
17780 }
17781@@ -78,7 +145,7 @@ static __always_inline void atomic_sub(int i, atomic_t *v)
17782 */
17783 static __always_inline int atomic_sub_and_test(int i, atomic_t *v)
17784 {
17785- GEN_BINARY_RMWcc(LOCK_PREFIX "subl", v->counter, "er", i, "%0", "e");
17786+ GEN_BINARY_RMWcc(LOCK_PREFIX "subl", LOCK_PREFIX "addl", v->counter, "er", i, "%0", "e");
17787 }
17788
17789 /**
17790@@ -89,7 +156,27 @@ static __always_inline int atomic_sub_and_test(int i, atomic_t *v)
17791 */
17792 static __always_inline void atomic_inc(atomic_t *v)
17793 {
17794- asm volatile(LOCK_PREFIX "incl %0"
17795+ asm volatile(LOCK_PREFIX "incl %0\n"
17796+
17797+#ifdef CONFIG_PAX_REFCOUNT
17798+ "jno 0f\n"
17799+ LOCK_PREFIX "decl %0\n"
17800+ "int $4\n0:\n"
17801+ _ASM_EXTABLE(0b, 0b)
17802+#endif
17803+
17804+ : "+m" (v->counter));
17805+}
17806+
17807+/**
17808+ * atomic_inc_unchecked - increment atomic variable
17809+ * @v: pointer of type atomic_unchecked_t
17810+ *
17811+ * Atomically increments @v by 1.
17812+ */
17813+static __always_inline void atomic_inc_unchecked(atomic_unchecked_t *v)
17814+{
17815+ asm volatile(LOCK_PREFIX "incl %0\n"
17816 : "+m" (v->counter));
17817 }
17818
17819@@ -101,7 +188,27 @@ static __always_inline void atomic_inc(atomic_t *v)
17820 */
17821 static __always_inline void atomic_dec(atomic_t *v)
17822 {
17823- asm volatile(LOCK_PREFIX "decl %0"
17824+ asm volatile(LOCK_PREFIX "decl %0\n"
17825+
17826+#ifdef CONFIG_PAX_REFCOUNT
17827+ "jno 0f\n"
17828+ LOCK_PREFIX "incl %0\n"
17829+ "int $4\n0:\n"
17830+ _ASM_EXTABLE(0b, 0b)
17831+#endif
17832+
17833+ : "+m" (v->counter));
17834+}
17835+
17836+/**
17837+ * atomic_dec_unchecked - decrement atomic variable
17838+ * @v: pointer of type atomic_unchecked_t
17839+ *
17840+ * Atomically decrements @v by 1.
17841+ */
17842+static __always_inline void atomic_dec_unchecked(atomic_unchecked_t *v)
17843+{
17844+ asm volatile(LOCK_PREFIX "decl %0\n"
17845 : "+m" (v->counter));
17846 }
17847
17848@@ -115,7 +222,7 @@ static __always_inline void atomic_dec(atomic_t *v)
17849 */
17850 static __always_inline int atomic_dec_and_test(atomic_t *v)
17851 {
17852- GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", "e");
17853+ GEN_UNARY_RMWcc(LOCK_PREFIX "decl", LOCK_PREFIX "incl", v->counter, "%0", "e");
17854 }
17855
17856 /**
17857@@ -128,7 +235,20 @@ static __always_inline int atomic_dec_and_test(atomic_t *v)
17858 */
17859 static __always_inline int atomic_inc_and_test(atomic_t *v)
17860 {
17861- GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, "%0", "e");
17862+ GEN_UNARY_RMWcc(LOCK_PREFIX "incl", LOCK_PREFIX "decl", v->counter, "%0", "e");
17863+}
17864+
17865+/**
17866+ * atomic_inc_and_test_unchecked - increment and test
17867+ * @v: pointer of type atomic_unchecked_t
17868+ *
17869+ * Atomically increments @v by 1
17870+ * and returns true if the result is zero, or false for all
17871+ * other cases.
17872+ */
17873+static __always_inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
17874+{
17875+ GEN_UNARY_RMWcc_unchecked(LOCK_PREFIX "incl", v->counter, "%0", "e");
17876 }
17877
17878 /**
17879@@ -142,7 +262,7 @@ static __always_inline int atomic_inc_and_test(atomic_t *v)
17880 */
17881 static __always_inline int atomic_add_negative(int i, atomic_t *v)
17882 {
17883- GEN_BINARY_RMWcc(LOCK_PREFIX "addl", v->counter, "er", i, "%0", "s");
17884+ GEN_BINARY_RMWcc(LOCK_PREFIX "addl", LOCK_PREFIX "subl", v->counter, "er", i, "%0", "s");
17885 }
17886
17887 /**
17888@@ -152,7 +272,19 @@ static __always_inline int atomic_add_negative(int i, atomic_t *v)
17889 *
17890 * Atomically adds @i to @v and returns @i + @v
17891 */
17892-static __always_inline int atomic_add_return(int i, atomic_t *v)
17893+static __always_inline int __intentional_overflow(-1) atomic_add_return(int i, atomic_t *v)
17894+{
17895+ return i + xadd_check_overflow(&v->counter, i);
17896+}
17897+
17898+/**
17899+ * atomic_add_return_unchecked - add integer and return
17900+ * @i: integer value to add
17901+ * @v: pointer of type atomi_uncheckedc_t
17902+ *
17903+ * Atomically adds @i to @v and returns @i + @v
17904+ */
17905+static __always_inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
17906 {
17907 return i + xadd(&v->counter, i);
17908 }
17909@@ -164,15 +296,24 @@ static __always_inline int atomic_add_return(int i, atomic_t *v)
17910 *
17911 * Atomically subtracts @i from @v and returns @v - @i
17912 */
17913-static __always_inline int atomic_sub_return(int i, atomic_t *v)
17914+static __always_inline int __intentional_overflow(-1) atomic_sub_return(int i, atomic_t *v)
17915 {
17916 return atomic_add_return(-i, v);
17917 }
17918
17919 #define atomic_inc_return(v) (atomic_add_return(1, v))
17920+static __always_inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
17921+{
17922+ return atomic_add_return_unchecked(1, v);
17923+}
17924 #define atomic_dec_return(v) (atomic_sub_return(1, v))
17925
17926-static __always_inline int atomic_cmpxchg(atomic_t *v, int old, int new)
17927+static __always_inline int __intentional_overflow(-1) atomic_cmpxchg(atomic_t *v, int old, int new)
17928+{
17929+ return cmpxchg(&v->counter, old, new);
17930+}
17931+
17932+static __always_inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
17933 {
17934 return cmpxchg(&v->counter, old, new);
17935 }
17936@@ -182,6 +323,11 @@ static inline int atomic_xchg(atomic_t *v, int new)
17937 return xchg(&v->counter, new);
17938 }
17939
17940+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
17941+{
17942+ return xchg(&v->counter, new);
17943+}
17944+
17945 /**
17946 * __atomic_add_unless - add unless the number is already a given value
17947 * @v: pointer of type atomic_t
17948@@ -193,12 +339,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
17949 */
17950 static __always_inline int __atomic_add_unless(atomic_t *v, int a, int u)
17951 {
17952- int c, old;
17953+ int c, old, new;
17954 c = atomic_read(v);
17955 for (;;) {
17956- if (unlikely(c == (u)))
17957+ if (unlikely(c == u))
17958 break;
17959- old = atomic_cmpxchg((v), c, c + (a));
17960+
17961+ asm volatile("addl %2,%0\n"
17962+
17963+#ifdef CONFIG_PAX_REFCOUNT
17964+ "jno 0f\n"
17965+ "subl %2,%0\n"
17966+ "int $4\n0:\n"
17967+ _ASM_EXTABLE(0b, 0b)
17968+#endif
17969+
17970+ : "=r" (new)
17971+ : "0" (c), "ir" (a));
17972+
17973+ old = atomic_cmpxchg(v, c, new);
17974 if (likely(old == c))
17975 break;
17976 c = old;
17977@@ -207,6 +366,49 @@ static __always_inline int __atomic_add_unless(atomic_t *v, int a, int u)
17978 }
17979
17980 /**
17981+ * atomic_inc_not_zero_hint - increment if not null
17982+ * @v: pointer of type atomic_t
17983+ * @hint: probable value of the atomic before the increment
17984+ *
17985+ * This version of atomic_inc_not_zero() gives a hint of probable
17986+ * value of the atomic. This helps processor to not read the memory
17987+ * before doing the atomic read/modify/write cycle, lowering
17988+ * number of bus transactions on some arches.
17989+ *
17990+ * Returns: 0 if increment was not done, 1 otherwise.
17991+ */
17992+#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
17993+static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
17994+{
17995+ int val, c = hint, new;
17996+
17997+ /* sanity test, should be removed by compiler if hint is a constant */
17998+ if (!hint)
17999+ return __atomic_add_unless(v, 1, 0);
18000+
18001+ do {
18002+ asm volatile("incl %0\n"
18003+
18004+#ifdef CONFIG_PAX_REFCOUNT
18005+ "jno 0f\n"
18006+ "decl %0\n"
18007+ "int $4\n0:\n"
18008+ _ASM_EXTABLE(0b, 0b)
18009+#endif
18010+
18011+ : "=r" (new)
18012+ : "0" (c));
18013+
18014+ val = atomic_cmpxchg(v, c, new);
18015+ if (val == c)
18016+ return 1;
18017+ c = val;
18018+ } while (c);
18019+
18020+ return 0;
18021+}
18022+
18023+/**
18024 * atomic_inc_short - increment of a short integer
18025 * @v: pointer to type int
18026 *
18027@@ -220,14 +422,37 @@ static __always_inline short int atomic_inc_short(short int *v)
18028 }
18029
18030 /* These are x86-specific, used by some header files */
18031-#define atomic_clear_mask(mask, addr) \
18032- asm volatile(LOCK_PREFIX "andl %0,%1" \
18033- : : "r" (~(mask)), "m" (*(addr)) : "memory")
18034+static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
18035+{
18036+ asm volatile(LOCK_PREFIX "andl %1,%0"
18037+ : "+m" (v->counter)
18038+ : "r" (~(mask))
18039+ : "memory");
18040+}
18041
18042-#define atomic_set_mask(mask, addr) \
18043- asm volatile(LOCK_PREFIX "orl %0,%1" \
18044- : : "r" ((unsigned)(mask)), "m" (*(addr)) \
18045- : "memory")
18046+static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
18047+{
18048+ asm volatile(LOCK_PREFIX "andl %1,%0"
18049+ : "+m" (v->counter)
18050+ : "r" (~(mask))
18051+ : "memory");
18052+}
18053+
18054+static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
18055+{
18056+ asm volatile(LOCK_PREFIX "orl %1,%0"
18057+ : "+m" (v->counter)
18058+ : "r" (mask)
18059+ : "memory");
18060+}
18061+
18062+static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
18063+{
18064+ asm volatile(LOCK_PREFIX "orl %1,%0"
18065+ : "+m" (v->counter)
18066+ : "r" (mask)
18067+ : "memory");
18068+}
18069
18070 #ifdef CONFIG_X86_32
18071 # include <asm/atomic64_32.h>
18072diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
18073index b154de7..3dc335d 100644
18074--- a/arch/x86/include/asm/atomic64_32.h
18075+++ b/arch/x86/include/asm/atomic64_32.h
18076@@ -12,6 +12,14 @@ typedef struct {
18077 u64 __aligned(8) counter;
18078 } atomic64_t;
18079
18080+#ifdef CONFIG_PAX_REFCOUNT
18081+typedef struct {
18082+ u64 __aligned(8) counter;
18083+} atomic64_unchecked_t;
18084+#else
18085+typedef atomic64_t atomic64_unchecked_t;
18086+#endif
18087+
18088 #define ATOMIC64_INIT(val) { (val) }
18089
18090 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
18091@@ -37,21 +45,31 @@ typedef struct {
18092 ATOMIC64_DECL_ONE(sym##_386)
18093
18094 ATOMIC64_DECL_ONE(add_386);
18095+ATOMIC64_DECL_ONE(add_unchecked_386);
18096 ATOMIC64_DECL_ONE(sub_386);
18097+ATOMIC64_DECL_ONE(sub_unchecked_386);
18098 ATOMIC64_DECL_ONE(inc_386);
18099+ATOMIC64_DECL_ONE(inc_unchecked_386);
18100 ATOMIC64_DECL_ONE(dec_386);
18101+ATOMIC64_DECL_ONE(dec_unchecked_386);
18102 #endif
18103
18104 #define alternative_atomic64(f, out, in...) \
18105 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
18106
18107 ATOMIC64_DECL(read);
18108+ATOMIC64_DECL(read_unchecked);
18109 ATOMIC64_DECL(set);
18110+ATOMIC64_DECL(set_unchecked);
18111 ATOMIC64_DECL(xchg);
18112 ATOMIC64_DECL(add_return);
18113+ATOMIC64_DECL(add_return_unchecked);
18114 ATOMIC64_DECL(sub_return);
18115+ATOMIC64_DECL(sub_return_unchecked);
18116 ATOMIC64_DECL(inc_return);
18117+ATOMIC64_DECL(inc_return_unchecked);
18118 ATOMIC64_DECL(dec_return);
18119+ATOMIC64_DECL(dec_return_unchecked);
18120 ATOMIC64_DECL(dec_if_positive);
18121 ATOMIC64_DECL(inc_not_zero);
18122 ATOMIC64_DECL(add_unless);
18123@@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
18124 }
18125
18126 /**
18127+ * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
18128+ * @p: pointer to type atomic64_unchecked_t
18129+ * @o: expected value
18130+ * @n: new value
18131+ *
18132+ * Atomically sets @v to @n if it was equal to @o and returns
18133+ * the old value.
18134+ */
18135+
18136+static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
18137+{
18138+ return cmpxchg64(&v->counter, o, n);
18139+}
18140+
18141+/**
18142 * atomic64_xchg - xchg atomic64 variable
18143 * @v: pointer to type atomic64_t
18144 * @n: value to assign
18145@@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
18146 }
18147
18148 /**
18149+ * atomic64_set_unchecked - set atomic64 variable
18150+ * @v: pointer to type atomic64_unchecked_t
18151+ * @n: value to assign
18152+ *
18153+ * Atomically sets the value of @v to @n.
18154+ */
18155+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
18156+{
18157+ unsigned high = (unsigned)(i >> 32);
18158+ unsigned low = (unsigned)i;
18159+ alternative_atomic64(set, /* no output */,
18160+ "S" (v), "b" (low), "c" (high)
18161+ : "eax", "edx", "memory");
18162+}
18163+
18164+/**
18165 * atomic64_read - read atomic64 variable
18166 * @v: pointer to type atomic64_t
18167 *
18168@@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
18169 }
18170
18171 /**
18172+ * atomic64_read_unchecked - read atomic64 variable
18173+ * @v: pointer to type atomic64_unchecked_t
18174+ *
18175+ * Atomically reads the value of @v and returns it.
18176+ */
18177+static inline long long __intentional_overflow(-1) atomic64_read_unchecked(const atomic64_unchecked_t *v)
18178+{
18179+ long long r;
18180+ alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
18181+ return r;
18182+ }
18183+
18184+/**
18185 * atomic64_add_return - add and return
18186 * @i: integer value to add
18187 * @v: pointer to type atomic64_t
18188@@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
18189 return i;
18190 }
18191
18192+/**
18193+ * atomic64_add_return_unchecked - add and return
18194+ * @i: integer value to add
18195+ * @v: pointer to type atomic64_unchecked_t
18196+ *
18197+ * Atomically adds @i to @v and returns @i + *@v
18198+ */
18199+static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
18200+{
18201+ alternative_atomic64(add_return_unchecked,
18202+ ASM_OUTPUT2("+A" (i), "+c" (v)),
18203+ ASM_NO_INPUT_CLOBBER("memory"));
18204+ return i;
18205+}
18206+
18207 /*
18208 * Other variants with different arithmetic operators:
18209 */
18210@@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
18211 return a;
18212 }
18213
18214+static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
18215+{
18216+ long long a;
18217+ alternative_atomic64(inc_return_unchecked, "=&A" (a),
18218+ "S" (v) : "memory", "ecx");
18219+ return a;
18220+}
18221+
18222 static inline long long atomic64_dec_return(atomic64_t *v)
18223 {
18224 long long a;
18225@@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
18226 }
18227
18228 /**
18229+ * atomic64_add_unchecked - add integer to atomic64 variable
18230+ * @i: integer value to add
18231+ * @v: pointer to type atomic64_unchecked_t
18232+ *
18233+ * Atomically adds @i to @v.
18234+ */
18235+static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
18236+{
18237+ __alternative_atomic64(add_unchecked, add_return_unchecked,
18238+ ASM_OUTPUT2("+A" (i), "+c" (v)),
18239+ ASM_NO_INPUT_CLOBBER("memory"));
18240+ return i;
18241+}
18242+
18243+/**
18244 * atomic64_sub - subtract the atomic64 variable
18245 * @i: integer value to subtract
18246 * @v: pointer to type atomic64_t
18247diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
18248index b965f9e..8e22dd3 100644
18249--- a/arch/x86/include/asm/atomic64_64.h
18250+++ b/arch/x86/include/asm/atomic64_64.h
18251@@ -22,6 +22,18 @@ static inline long atomic64_read(const atomic64_t *v)
18252 }
18253
18254 /**
18255+ * atomic64_read_unchecked - read atomic64 variable
18256+ * @v: pointer of type atomic64_unchecked_t
18257+ *
18258+ * Atomically reads the value of @v.
18259+ * Doesn't imply a read memory barrier.
18260+ */
18261+static inline long __intentional_overflow(-1) atomic64_read_unchecked(const atomic64_unchecked_t *v)
18262+{
18263+ return ACCESS_ONCE((v)->counter);
18264+}
18265+
18266+/**
18267 * atomic64_set - set atomic64 variable
18268 * @v: pointer to type atomic64_t
18269 * @i: required value
18270@@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
18271 }
18272
18273 /**
18274+ * atomic64_set_unchecked - set atomic64 variable
18275+ * @v: pointer to type atomic64_unchecked_t
18276+ * @i: required value
18277+ *
18278+ * Atomically sets the value of @v to @i.
18279+ */
18280+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
18281+{
18282+ v->counter = i;
18283+}
18284+
18285+/**
18286 * atomic64_add - add integer to atomic64 variable
18287 * @i: integer value to add
18288 * @v: pointer to type atomic64_t
18289@@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
18290 */
18291 static __always_inline void atomic64_add(long i, atomic64_t *v)
18292 {
18293+ asm volatile(LOCK_PREFIX "addq %1,%0\n"
18294+
18295+#ifdef CONFIG_PAX_REFCOUNT
18296+ "jno 0f\n"
18297+ LOCK_PREFIX "subq %1,%0\n"
18298+ "int $4\n0:\n"
18299+ _ASM_EXTABLE(0b, 0b)
18300+#endif
18301+
18302+ : "=m" (v->counter)
18303+ : "er" (i), "m" (v->counter));
18304+}
18305+
18306+/**
18307+ * atomic64_add_unchecked - add integer to atomic64 variable
18308+ * @i: integer value to add
18309+ * @v: pointer to type atomic64_unchecked_t
18310+ *
18311+ * Atomically adds @i to @v.
18312+ */
18313+static __always_inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
18314+{
18315 asm volatile(LOCK_PREFIX "addq %1,%0"
18316 : "=m" (v->counter)
18317 : "er" (i), "m" (v->counter));
18318@@ -56,7 +102,29 @@ static __always_inline void atomic64_add(long i, atomic64_t *v)
18319 */
18320 static inline void atomic64_sub(long i, atomic64_t *v)
18321 {
18322- asm volatile(LOCK_PREFIX "subq %1,%0"
18323+ asm volatile(LOCK_PREFIX "subq %1,%0\n"
18324+
18325+#ifdef CONFIG_PAX_REFCOUNT
18326+ "jno 0f\n"
18327+ LOCK_PREFIX "addq %1,%0\n"
18328+ "int $4\n0:\n"
18329+ _ASM_EXTABLE(0b, 0b)
18330+#endif
18331+
18332+ : "=m" (v->counter)
18333+ : "er" (i), "m" (v->counter));
18334+}
18335+
18336+/**
18337+ * atomic64_sub_unchecked - subtract the atomic64 variable
18338+ * @i: integer value to subtract
18339+ * @v: pointer to type atomic64_unchecked_t
18340+ *
18341+ * Atomically subtracts @i from @v.
18342+ */
18343+static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
18344+{
18345+ asm volatile(LOCK_PREFIX "subq %1,%0\n"
18346 : "=m" (v->counter)
18347 : "er" (i), "m" (v->counter));
18348 }
18349@@ -72,7 +140,7 @@ static inline void atomic64_sub(long i, atomic64_t *v)
18350 */
18351 static inline int atomic64_sub_and_test(long i, atomic64_t *v)
18352 {
18353- GEN_BINARY_RMWcc(LOCK_PREFIX "subq", v->counter, "er", i, "%0", "e");
18354+ GEN_BINARY_RMWcc(LOCK_PREFIX "subq", LOCK_PREFIX "addq", v->counter, "er", i, "%0", "e");
18355 }
18356
18357 /**
18358@@ -83,6 +151,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
18359 */
18360 static __always_inline void atomic64_inc(atomic64_t *v)
18361 {
18362+ asm volatile(LOCK_PREFIX "incq %0\n"
18363+
18364+#ifdef CONFIG_PAX_REFCOUNT
18365+ "jno 0f\n"
18366+ LOCK_PREFIX "decq %0\n"
18367+ "int $4\n0:\n"
18368+ _ASM_EXTABLE(0b, 0b)
18369+#endif
18370+
18371+ : "=m" (v->counter)
18372+ : "m" (v->counter));
18373+}
18374+
18375+/**
18376+ * atomic64_inc_unchecked - increment atomic64 variable
18377+ * @v: pointer to type atomic64_unchecked_t
18378+ *
18379+ * Atomically increments @v by 1.
18380+ */
18381+static __always_inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
18382+{
18383 asm volatile(LOCK_PREFIX "incq %0"
18384 : "=m" (v->counter)
18385 : "m" (v->counter));
18386@@ -96,7 +185,28 @@ static __always_inline void atomic64_inc(atomic64_t *v)
18387 */
18388 static __always_inline void atomic64_dec(atomic64_t *v)
18389 {
18390- asm volatile(LOCK_PREFIX "decq %0"
18391+ asm volatile(LOCK_PREFIX "decq %0\n"
18392+
18393+#ifdef CONFIG_PAX_REFCOUNT
18394+ "jno 0f\n"
18395+ LOCK_PREFIX "incq %0\n"
18396+ "int $4\n0:\n"
18397+ _ASM_EXTABLE(0b, 0b)
18398+#endif
18399+
18400+ : "=m" (v->counter)
18401+ : "m" (v->counter));
18402+}
18403+
18404+/**
18405+ * atomic64_dec_unchecked - decrement atomic64 variable
18406+ * @v: pointer to type atomic64_t
18407+ *
18408+ * Atomically decrements @v by 1.
18409+ */
18410+static __always_inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
18411+{
18412+ asm volatile(LOCK_PREFIX "decq %0\n"
18413 : "=m" (v->counter)
18414 : "m" (v->counter));
18415 }
18416@@ -111,7 +221,7 @@ static __always_inline void atomic64_dec(atomic64_t *v)
18417 */
18418 static inline int atomic64_dec_and_test(atomic64_t *v)
18419 {
18420- GEN_UNARY_RMWcc(LOCK_PREFIX "decq", v->counter, "%0", "e");
18421+ GEN_UNARY_RMWcc(LOCK_PREFIX "decq", LOCK_PREFIX "incq", v->counter, "%0", "e");
18422 }
18423
18424 /**
18425@@ -124,7 +234,7 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
18426 */
18427 static inline int atomic64_inc_and_test(atomic64_t *v)
18428 {
18429- GEN_UNARY_RMWcc(LOCK_PREFIX "incq", v->counter, "%0", "e");
18430+ GEN_UNARY_RMWcc(LOCK_PREFIX "incq", LOCK_PREFIX "decq", v->counter, "%0", "e");
18431 }
18432
18433 /**
18434@@ -138,7 +248,7 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
18435 */
18436 static inline int atomic64_add_negative(long i, atomic64_t *v)
18437 {
18438- GEN_BINARY_RMWcc(LOCK_PREFIX "addq", v->counter, "er", i, "%0", "s");
18439+ GEN_BINARY_RMWcc(LOCK_PREFIX "addq", LOCK_PREFIX "subq", v->counter, "er", i, "%0", "s");
18440 }
18441
18442 /**
18443@@ -150,6 +260,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
18444 */
18445 static __always_inline long atomic64_add_return(long i, atomic64_t *v)
18446 {
18447+ return i + xadd_check_overflow(&v->counter, i);
18448+}
18449+
18450+/**
18451+ * atomic64_add_return_unchecked - add and return
18452+ * @i: integer value to add
18453+ * @v: pointer to type atomic64_unchecked_t
18454+ *
18455+ * Atomically adds @i to @v and returns @i + @v
18456+ */
18457+static __always_inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
18458+{
18459 return i + xadd(&v->counter, i);
18460 }
18461
18462@@ -159,6 +281,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
18463 }
18464
18465 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
18466+static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
18467+{
18468+ return atomic64_add_return_unchecked(1, v);
18469+}
18470 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
18471
18472 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
18473@@ -166,6 +292,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
18474 return cmpxchg(&v->counter, old, new);
18475 }
18476
18477+static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
18478+{
18479+ return cmpxchg(&v->counter, old, new);
18480+}
18481+
18482 static inline long atomic64_xchg(atomic64_t *v, long new)
18483 {
18484 return xchg(&v->counter, new);
18485@@ -182,17 +313,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
18486 */
18487 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
18488 {
18489- long c, old;
18490+ long c, old, new;
18491 c = atomic64_read(v);
18492 for (;;) {
18493- if (unlikely(c == (u)))
18494+ if (unlikely(c == u))
18495 break;
18496- old = atomic64_cmpxchg((v), c, c + (a));
18497+
18498+ asm volatile("add %2,%0\n"
18499+
18500+#ifdef CONFIG_PAX_REFCOUNT
18501+ "jno 0f\n"
18502+ "sub %2,%0\n"
18503+ "int $4\n0:\n"
18504+ _ASM_EXTABLE(0b, 0b)
18505+#endif
18506+
18507+ : "=r" (new)
18508+ : "0" (c), "ir" (a));
18509+
18510+ old = atomic64_cmpxchg(v, c, new);
18511 if (likely(old == c))
18512 break;
18513 c = old;
18514 }
18515- return c != (u);
18516+ return c != u;
18517 }
18518
18519 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
18520diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
18521index e51a8f8..ee075df 100644
18522--- a/arch/x86/include/asm/barrier.h
18523+++ b/arch/x86/include/asm/barrier.h
18524@@ -57,7 +57,7 @@
18525 do { \
18526 compiletime_assert_atomic_type(*p); \
18527 smp_mb(); \
18528- ACCESS_ONCE(*p) = (v); \
18529+ ACCESS_ONCE_RW(*p) = (v); \
18530 } while (0)
18531
18532 #define smp_load_acquire(p) \
18533@@ -74,7 +74,7 @@ do { \
18534 do { \
18535 compiletime_assert_atomic_type(*p); \
18536 barrier(); \
18537- ACCESS_ONCE(*p) = (v); \
18538+ ACCESS_ONCE_RW(*p) = (v); \
18539 } while (0)
18540
18541 #define smp_load_acquire(p) \
18542diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
18543index cfe3b95..d01b118 100644
18544--- a/arch/x86/include/asm/bitops.h
18545+++ b/arch/x86/include/asm/bitops.h
18546@@ -50,7 +50,7 @@
18547 * a mask operation on a byte.
18548 */
18549 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
18550-#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
18551+#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
18552 #define CONST_MASK(nr) (1 << ((nr) & 7))
18553
18554 /**
18555@@ -203,7 +203,7 @@ static inline void change_bit(long nr, volatile unsigned long *addr)
18556 */
18557 static inline int test_and_set_bit(long nr, volatile unsigned long *addr)
18558 {
18559- GEN_BINARY_RMWcc(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", "c");
18560+ GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", "c");
18561 }
18562
18563 /**
18564@@ -249,7 +249,7 @@ static inline int __test_and_set_bit(long nr, volatile unsigned long *addr)
18565 */
18566 static inline int test_and_clear_bit(long nr, volatile unsigned long *addr)
18567 {
18568- GEN_BINARY_RMWcc(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", "c");
18569+ GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", "c");
18570 }
18571
18572 /**
18573@@ -302,7 +302,7 @@ static inline int __test_and_change_bit(long nr, volatile unsigned long *addr)
18574 */
18575 static inline int test_and_change_bit(long nr, volatile unsigned long *addr)
18576 {
18577- GEN_BINARY_RMWcc(LOCK_PREFIX "btc", *addr, "Ir", nr, "%0", "c");
18578+ GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "btc", *addr, "Ir", nr, "%0", "c");
18579 }
18580
18581 static __always_inline int constant_test_bit(long nr, const volatile unsigned long *addr)
18582@@ -343,7 +343,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
18583 *
18584 * Undefined if no bit exists, so code should check against 0 first.
18585 */
18586-static inline unsigned long __ffs(unsigned long word)
18587+static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
18588 {
18589 asm("rep; bsf %1,%0"
18590 : "=r" (word)
18591@@ -357,7 +357,7 @@ static inline unsigned long __ffs(unsigned long word)
18592 *
18593 * Undefined if no zero exists, so code should check against ~0UL first.
18594 */
18595-static inline unsigned long ffz(unsigned long word)
18596+static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
18597 {
18598 asm("rep; bsf %1,%0"
18599 : "=r" (word)
18600@@ -371,7 +371,7 @@ static inline unsigned long ffz(unsigned long word)
18601 *
18602 * Undefined if no set bit exists, so code should check against 0 first.
18603 */
18604-static inline unsigned long __fls(unsigned long word)
18605+static inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
18606 {
18607 asm("bsr %1,%0"
18608 : "=r" (word)
18609@@ -434,7 +434,7 @@ static inline int ffs(int x)
18610 * set bit if value is nonzero. The last (most significant) bit is
18611 * at position 32.
18612 */
18613-static inline int fls(int x)
18614+static inline int __intentional_overflow(-1) fls(int x)
18615 {
18616 int r;
18617
18618@@ -476,7 +476,7 @@ static inline int fls(int x)
18619 * at position 64.
18620 */
18621 #ifdef CONFIG_X86_64
18622-static __always_inline int fls64(__u64 x)
18623+static __always_inline __intentional_overflow(-1) int fls64(__u64 x)
18624 {
18625 int bitpos = -1;
18626 /*
18627diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
18628index 4fa687a..4ca636f 100644
18629--- a/arch/x86/include/asm/boot.h
18630+++ b/arch/x86/include/asm/boot.h
18631@@ -6,7 +6,7 @@
18632 #include <uapi/asm/boot.h>
18633
18634 /* Physical address where kernel should be loaded. */
18635-#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
18636+#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
18637 + (CONFIG_PHYSICAL_ALIGN - 1)) \
18638 & ~(CONFIG_PHYSICAL_ALIGN - 1))
18639
18640diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
18641index 48f99f1..d78ebf9 100644
18642--- a/arch/x86/include/asm/cache.h
18643+++ b/arch/x86/include/asm/cache.h
18644@@ -5,12 +5,13 @@
18645
18646 /* L1 cache line size */
18647 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
18648-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
18649+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
18650
18651 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
18652+#define __read_only __attribute__((__section__(".data..read_only")))
18653
18654 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
18655-#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
18656+#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
18657
18658 #ifdef CONFIG_X86_VSMP
18659 #ifdef CONFIG_SMP
18660diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
18661index f50de69..2b0a458 100644
18662--- a/arch/x86/include/asm/checksum_32.h
18663+++ b/arch/x86/include/asm/checksum_32.h
18664@@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
18665 int len, __wsum sum,
18666 int *src_err_ptr, int *dst_err_ptr);
18667
18668+asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
18669+ int len, __wsum sum,
18670+ int *src_err_ptr, int *dst_err_ptr);
18671+
18672+asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
18673+ int len, __wsum sum,
18674+ int *src_err_ptr, int *dst_err_ptr);
18675+
18676 /*
18677 * Note: when you get a NULL pointer exception here this means someone
18678 * passed in an incorrect kernel address to one of these functions.
18679@@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
18680
18681 might_sleep();
18682 stac();
18683- ret = csum_partial_copy_generic((__force void *)src, dst,
18684+ ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
18685 len, sum, err_ptr, NULL);
18686 clac();
18687
18688@@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
18689 might_sleep();
18690 if (access_ok(VERIFY_WRITE, dst, len)) {
18691 stac();
18692- ret = csum_partial_copy_generic(src, (__force void *)dst,
18693+ ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
18694 len, sum, NULL, err_ptr);
18695 clac();
18696 return ret;
18697diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
18698index ad19841..0784041 100644
18699--- a/arch/x86/include/asm/cmpxchg.h
18700+++ b/arch/x86/include/asm/cmpxchg.h
18701@@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
18702 __compiletime_error("Bad argument size for cmpxchg");
18703 extern void __xadd_wrong_size(void)
18704 __compiletime_error("Bad argument size for xadd");
18705+extern void __xadd_check_overflow_wrong_size(void)
18706+ __compiletime_error("Bad argument size for xadd_check_overflow");
18707 extern void __add_wrong_size(void)
18708 __compiletime_error("Bad argument size for add");
18709+extern void __add_check_overflow_wrong_size(void)
18710+ __compiletime_error("Bad argument size for add_check_overflow");
18711
18712 /*
18713 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
18714@@ -67,6 +71,38 @@ extern void __add_wrong_size(void)
18715 __ret; \
18716 })
18717
18718+#ifdef CONFIG_PAX_REFCOUNT
18719+#define __xchg_op_check_overflow(ptr, arg, op, lock) \
18720+ ({ \
18721+ __typeof__ (*(ptr)) __ret = (arg); \
18722+ switch (sizeof(*(ptr))) { \
18723+ case __X86_CASE_L: \
18724+ asm volatile (lock #op "l %0, %1\n" \
18725+ "jno 0f\n" \
18726+ "mov %0,%1\n" \
18727+ "int $4\n0:\n" \
18728+ _ASM_EXTABLE(0b, 0b) \
18729+ : "+r" (__ret), "+m" (*(ptr)) \
18730+ : : "memory", "cc"); \
18731+ break; \
18732+ case __X86_CASE_Q: \
18733+ asm volatile (lock #op "q %q0, %1\n" \
18734+ "jno 0f\n" \
18735+ "mov %0,%1\n" \
18736+ "int $4\n0:\n" \
18737+ _ASM_EXTABLE(0b, 0b) \
18738+ : "+r" (__ret), "+m" (*(ptr)) \
18739+ : : "memory", "cc"); \
18740+ break; \
18741+ default: \
18742+ __ ## op ## _check_overflow_wrong_size(); \
18743+ } \
18744+ __ret; \
18745+ })
18746+#else
18747+#define __xchg_op_check_overflow(ptr, arg, op, lock) __xchg_op(ptr, arg, op, lock)
18748+#endif
18749+
18750 /*
18751 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
18752 * Since this is generally used to protect other memory information, we
18753@@ -165,6 +201,9 @@ extern void __add_wrong_size(void)
18754 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
18755 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
18756
18757+#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
18758+#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
18759+
18760 #define __add(ptr, inc, lock) \
18761 ({ \
18762 __typeof__ (*(ptr)) __ret = (inc); \
18763diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
18764index acdee09..a553db3 100644
18765--- a/arch/x86/include/asm/compat.h
18766+++ b/arch/x86/include/asm/compat.h
18767@@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
18768 typedef u32 compat_uint_t;
18769 typedef u32 compat_ulong_t;
18770 typedef u64 __attribute__((aligned(4))) compat_u64;
18771-typedef u32 compat_uptr_t;
18772+typedef u32 __user compat_uptr_t;
18773
18774 struct compat_timespec {
18775 compat_time_t tv_sec;
18776diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
18777index 3d6606f..300641d 100644
18778--- a/arch/x86/include/asm/cpufeature.h
18779+++ b/arch/x86/include/asm/cpufeature.h
18780@@ -214,7 +214,8 @@
18781 #define X86_FEATURE_PAUSEFILTER ( 8*32+13) /* AMD filtered pause intercept */
18782 #define X86_FEATURE_PFTHRESHOLD ( 8*32+14) /* AMD pause filter threshold */
18783 #define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer vmmcall to vmcall */
18784-
18785+#define X86_FEATURE_PCIDUDEREF ( 8*32+30) /* PaX PCID based UDEREF */
18786+#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
18787
18788 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
18789 #define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
18790@@ -222,7 +223,7 @@
18791 #define X86_FEATURE_BMI1 ( 9*32+ 3) /* 1st group bit manipulation extensions */
18792 #define X86_FEATURE_HLE ( 9*32+ 4) /* Hardware Lock Elision */
18793 #define X86_FEATURE_AVX2 ( 9*32+ 5) /* AVX2 instructions */
18794-#define X86_FEATURE_SMEP ( 9*32+ 7) /* Supervisor Mode Execution Protection */
18795+#define X86_FEATURE_SMEP ( 9*32+ 7) /* Supervisor Mode Execution Prevention */
18796 #define X86_FEATURE_BMI2 ( 9*32+ 8) /* 2nd group bit manipulation extensions */
18797 #define X86_FEATURE_ERMS ( 9*32+ 9) /* Enhanced REP MOVSB/STOSB */
18798 #define X86_FEATURE_INVPCID ( 9*32+10) /* Invalidate Processor Context ID */
18799@@ -401,6 +402,7 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
18800 #define cpu_has_eager_fpu boot_cpu_has(X86_FEATURE_EAGER_FPU)
18801 #define cpu_has_topoext boot_cpu_has(X86_FEATURE_TOPOEXT)
18802 #define cpu_has_bpext boot_cpu_has(X86_FEATURE_BPEXT)
18803+#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
18804
18805 #if __GNUC__ >= 4
18806 extern void warn_pre_alternatives(void);
18807@@ -454,7 +456,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
18808
18809 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
18810 t_warn:
18811- warn_pre_alternatives();
18812+ if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID && bit != X86_FEATURE_PCIDUDEREF)
18813+ warn_pre_alternatives();
18814 return false;
18815 #endif
18816
18817@@ -475,7 +478,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
18818 ".section .discard,\"aw\",@progbits\n"
18819 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
18820 ".previous\n"
18821- ".section .altinstr_replacement,\"ax\"\n"
18822+ ".section .altinstr_replacement,\"a\"\n"
18823 "3: movb $1,%0\n"
18824 "4:\n"
18825 ".previous\n"
18826@@ -510,7 +513,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
18827 " .byte 5f - 4f\n" /* repl len */
18828 " .byte 3b - 2b\n" /* pad len */
18829 ".previous\n"
18830- ".section .altinstr_replacement,\"ax\"\n"
18831+ ".section .altinstr_replacement,\"a\"\n"
18832 "4: jmp %l[t_no]\n"
18833 "5:\n"
18834 ".previous\n"
18835@@ -545,7 +548,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
18836 ".section .discard,\"aw\",@progbits\n"
18837 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
18838 ".previous\n"
18839- ".section .altinstr_replacement,\"ax\"\n"
18840+ ".section .altinstr_replacement,\"a\"\n"
18841 "3: movb $0,%0\n"
18842 "4:\n"
18843 ".previous\n"
18844@@ -560,7 +563,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
18845 ".section .discard,\"aw\",@progbits\n"
18846 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
18847 ".previous\n"
18848- ".section .altinstr_replacement,\"ax\"\n"
18849+ ".section .altinstr_replacement,\"a\"\n"
18850 "5: movb $1,%0\n"
18851 "6:\n"
18852 ".previous\n"
18853diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
18854index 4e10d73..7319a47 100644
18855--- a/arch/x86/include/asm/desc.h
18856+++ b/arch/x86/include/asm/desc.h
18857@@ -4,6 +4,7 @@
18858 #include <asm/desc_defs.h>
18859 #include <asm/ldt.h>
18860 #include <asm/mmu.h>
18861+#include <asm/pgtable.h>
18862
18863 #include <linux/smp.h>
18864 #include <linux/percpu.h>
18865@@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
18866
18867 desc->type = (info->read_exec_only ^ 1) << 1;
18868 desc->type |= info->contents << 2;
18869+ desc->type |= info->seg_not_present ^ 1;
18870
18871 desc->s = 1;
18872 desc->dpl = 0x3;
18873@@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
18874 }
18875
18876 extern struct desc_ptr idt_descr;
18877-extern gate_desc idt_table[];
18878-extern struct desc_ptr debug_idt_descr;
18879-extern gate_desc debug_idt_table[];
18880-
18881-struct gdt_page {
18882- struct desc_struct gdt[GDT_ENTRIES];
18883-} __attribute__((aligned(PAGE_SIZE)));
18884-
18885-DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
18886+extern gate_desc idt_table[IDT_ENTRIES];
18887+extern const struct desc_ptr debug_idt_descr;
18888+extern gate_desc debug_idt_table[IDT_ENTRIES];
18889
18890+extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
18891 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
18892 {
18893- return per_cpu(gdt_page, cpu).gdt;
18894+ return cpu_gdt_table[cpu];
18895 }
18896
18897 #ifdef CONFIG_X86_64
18898@@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
18899 unsigned long base, unsigned dpl, unsigned flags,
18900 unsigned short seg)
18901 {
18902- gate->a = (seg << 16) | (base & 0xffff);
18903- gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
18904+ gate->gate.offset_low = base;
18905+ gate->gate.seg = seg;
18906+ gate->gate.reserved = 0;
18907+ gate->gate.type = type;
18908+ gate->gate.s = 0;
18909+ gate->gate.dpl = dpl;
18910+ gate->gate.p = 1;
18911+ gate->gate.offset_high = base >> 16;
18912 }
18913
18914 #endif
18915@@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
18916
18917 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
18918 {
18919+ pax_open_kernel();
18920 memcpy(&idt[entry], gate, sizeof(*gate));
18921+ pax_close_kernel();
18922 }
18923
18924 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
18925 {
18926+ pax_open_kernel();
18927 memcpy(&ldt[entry], desc, 8);
18928+ pax_close_kernel();
18929 }
18930
18931 static inline void
18932@@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
18933 default: size = sizeof(*gdt); break;
18934 }
18935
18936+ pax_open_kernel();
18937 memcpy(&gdt[entry], desc, size);
18938+ pax_close_kernel();
18939 }
18940
18941 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
18942@@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
18943
18944 static inline void native_load_tr_desc(void)
18945 {
18946+ pax_open_kernel();
18947 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
18948+ pax_close_kernel();
18949 }
18950
18951 static inline void native_load_gdt(const struct desc_ptr *dtr)
18952@@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
18953 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
18954 unsigned int i;
18955
18956+ pax_open_kernel();
18957 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
18958 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
18959+ pax_close_kernel();
18960 }
18961
18962 /* This intentionally ignores lm, since 32-bit apps don't have that field. */
18963@@ -280,7 +293,7 @@ static inline void clear_LDT(void)
18964 set_ldt(NULL, 0);
18965 }
18966
18967-static inline unsigned long get_desc_base(const struct desc_struct *desc)
18968+static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
18969 {
18970 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
18971 }
18972@@ -304,7 +317,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
18973 }
18974
18975 #ifdef CONFIG_X86_64
18976-static inline void set_nmi_gate(int gate, void *addr)
18977+static inline void set_nmi_gate(int gate, const void *addr)
18978 {
18979 gate_desc s;
18980
18981@@ -314,14 +327,14 @@ static inline void set_nmi_gate(int gate, void *addr)
18982 #endif
18983
18984 #ifdef CONFIG_TRACING
18985-extern struct desc_ptr trace_idt_descr;
18986-extern gate_desc trace_idt_table[];
18987+extern const struct desc_ptr trace_idt_descr;
18988+extern gate_desc trace_idt_table[IDT_ENTRIES];
18989 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
18990 {
18991 write_idt_entry(trace_idt_table, entry, gate);
18992 }
18993
18994-static inline void _trace_set_gate(int gate, unsigned type, void *addr,
18995+static inline void _trace_set_gate(int gate, unsigned type, const void *addr,
18996 unsigned dpl, unsigned ist, unsigned seg)
18997 {
18998 gate_desc s;
18999@@ -341,7 +354,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
19000 #define _trace_set_gate(gate, type, addr, dpl, ist, seg)
19001 #endif
19002
19003-static inline void _set_gate(int gate, unsigned type, void *addr,
19004+static inline void _set_gate(int gate, unsigned type, const void *addr,
19005 unsigned dpl, unsigned ist, unsigned seg)
19006 {
19007 gate_desc s;
19008@@ -364,14 +377,14 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
19009 #define set_intr_gate_notrace(n, addr) \
19010 do { \
19011 BUG_ON((unsigned)n > 0xFF); \
19012- _set_gate(n, GATE_INTERRUPT, (void *)addr, 0, 0, \
19013+ _set_gate(n, GATE_INTERRUPT, (const void *)addr, 0, 0, \
19014 __KERNEL_CS); \
19015 } while (0)
19016
19017 #define set_intr_gate(n, addr) \
19018 do { \
19019 set_intr_gate_notrace(n, addr); \
19020- _trace_set_gate(n, GATE_INTERRUPT, (void *)trace_##addr,\
19021+ _trace_set_gate(n, GATE_INTERRUPT, (const void *)trace_##addr,\
19022 0, 0, __KERNEL_CS); \
19023 } while (0)
19024
19025@@ -399,19 +412,19 @@ static inline void alloc_system_vector(int vector)
19026 /*
19027 * This routine sets up an interrupt gate at directory privilege level 3.
19028 */
19029-static inline void set_system_intr_gate(unsigned int n, void *addr)
19030+static inline void set_system_intr_gate(unsigned int n, const void *addr)
19031 {
19032 BUG_ON((unsigned)n > 0xFF);
19033 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
19034 }
19035
19036-static inline void set_system_trap_gate(unsigned int n, void *addr)
19037+static inline void set_system_trap_gate(unsigned int n, const void *addr)
19038 {
19039 BUG_ON((unsigned)n > 0xFF);
19040 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
19041 }
19042
19043-static inline void set_trap_gate(unsigned int n, void *addr)
19044+static inline void set_trap_gate(unsigned int n, const void *addr)
19045 {
19046 BUG_ON((unsigned)n > 0xFF);
19047 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
19048@@ -420,16 +433,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
19049 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
19050 {
19051 BUG_ON((unsigned)n > 0xFF);
19052- _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
19053+ _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
19054 }
19055
19056-static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
19057+static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
19058 {
19059 BUG_ON((unsigned)n > 0xFF);
19060 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
19061 }
19062
19063-static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
19064+static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
19065 {
19066 BUG_ON((unsigned)n > 0xFF);
19067 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
19068@@ -501,4 +514,17 @@ static inline void load_current_idt(void)
19069 else
19070 load_idt((const struct desc_ptr *)&idt_descr);
19071 }
19072+
19073+#ifdef CONFIG_X86_32
19074+static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
19075+{
19076+ struct desc_struct d;
19077+
19078+ if (likely(limit))
19079+ limit = (limit - 1UL) >> PAGE_SHIFT;
19080+ pack_descriptor(&d, base, limit, 0xFB, 0xC);
19081+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
19082+}
19083+#endif
19084+
19085 #endif /* _ASM_X86_DESC_H */
19086diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
19087index 278441f..b95a174 100644
19088--- a/arch/x86/include/asm/desc_defs.h
19089+++ b/arch/x86/include/asm/desc_defs.h
19090@@ -31,6 +31,12 @@ struct desc_struct {
19091 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
19092 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
19093 };
19094+ struct {
19095+ u16 offset_low;
19096+ u16 seg;
19097+ unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
19098+ unsigned offset_high: 16;
19099+ } gate;
19100 };
19101 } __attribute__((packed));
19102
19103diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
19104index ced283a..ffe04cc 100644
19105--- a/arch/x86/include/asm/div64.h
19106+++ b/arch/x86/include/asm/div64.h
19107@@ -39,7 +39,7 @@
19108 __mod; \
19109 })
19110
19111-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
19112+static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
19113 {
19114 union {
19115 u64 v64;
19116diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
19117index f161c18..97d43e8 100644
19118--- a/arch/x86/include/asm/elf.h
19119+++ b/arch/x86/include/asm/elf.h
19120@@ -75,9 +75,6 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
19121
19122 #include <asm/vdso.h>
19123
19124-#ifdef CONFIG_X86_64
19125-extern unsigned int vdso64_enabled;
19126-#endif
19127 #if defined(CONFIG_X86_32) || defined(CONFIG_COMPAT)
19128 extern unsigned int vdso32_enabled;
19129 #endif
19130@@ -250,7 +247,25 @@ extern int force_personality32;
19131 the loader. We need to make sure that it is out of the way of the program
19132 that it will "exec", and that there is sufficient room for the brk. */
19133
19134+#ifdef CONFIG_PAX_SEGMEXEC
19135+#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
19136+#else
19137 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
19138+#endif
19139+
19140+#ifdef CONFIG_PAX_ASLR
19141+#ifdef CONFIG_X86_32
19142+#define PAX_ELF_ET_DYN_BASE 0x10000000UL
19143+
19144+#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
19145+#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
19146+#else
19147+#define PAX_ELF_ET_DYN_BASE 0x400000UL
19148+
19149+#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
19150+#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
19151+#endif
19152+#endif
19153
19154 /* This yields a mask that user programs can use to figure out what
19155 instruction set this CPU supports. This could be done in user space,
19156@@ -299,17 +314,13 @@ do { \
19157
19158 #define ARCH_DLINFO \
19159 do { \
19160- if (vdso64_enabled) \
19161- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
19162- (unsigned long __force)current->mm->context.vdso); \
19163+ NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
19164 } while (0)
19165
19166 /* As a historical oddity, the x32 and x86_64 vDSOs are controlled together. */
19167 #define ARCH_DLINFO_X32 \
19168 do { \
19169- if (vdso64_enabled) \
19170- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
19171- (unsigned long __force)current->mm->context.vdso); \
19172+ NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
19173 } while (0)
19174
19175 #define AT_SYSINFO 32
19176@@ -324,10 +335,10 @@ else \
19177
19178 #endif /* !CONFIG_X86_32 */
19179
19180-#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
19181+#define VDSO_CURRENT_BASE (current->mm->context.vdso)
19182
19183 #define VDSO_ENTRY \
19184- ((unsigned long)current->mm->context.vdso + \
19185+ (current->mm->context.vdso + \
19186 selected_vdso32->sym___kernel_vsyscall)
19187
19188 struct linux_binprm;
19189diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
19190index 77a99ac..39ff7f5 100644
19191--- a/arch/x86/include/asm/emergency-restart.h
19192+++ b/arch/x86/include/asm/emergency-restart.h
19193@@ -1,6 +1,6 @@
19194 #ifndef _ASM_X86_EMERGENCY_RESTART_H
19195 #define _ASM_X86_EMERGENCY_RESTART_H
19196
19197-extern void machine_emergency_restart(void);
19198+extern void machine_emergency_restart(void) __noreturn;
19199
19200 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
19201diff --git a/arch/x86/include/asm/floppy.h b/arch/x86/include/asm/floppy.h
19202index 1c7eefe..d0e4702 100644
19203--- a/arch/x86/include/asm/floppy.h
19204+++ b/arch/x86/include/asm/floppy.h
19205@@ -229,18 +229,18 @@ static struct fd_routine_l {
19206 int (*_dma_setup)(char *addr, unsigned long size, int mode, int io);
19207 } fd_routine[] = {
19208 {
19209- request_dma,
19210- free_dma,
19211- get_dma_residue,
19212- dma_mem_alloc,
19213- hard_dma_setup
19214+ ._request_dma = request_dma,
19215+ ._free_dma = free_dma,
19216+ ._get_dma_residue = get_dma_residue,
19217+ ._dma_mem_alloc = dma_mem_alloc,
19218+ ._dma_setup = hard_dma_setup
19219 },
19220 {
19221- vdma_request_dma,
19222- vdma_nop,
19223- vdma_get_dma_residue,
19224- vdma_mem_alloc,
19225- vdma_dma_setup
19226+ ._request_dma = vdma_request_dma,
19227+ ._free_dma = vdma_nop,
19228+ ._get_dma_residue = vdma_get_dma_residue,
19229+ ._dma_mem_alloc = vdma_mem_alloc,
19230+ ._dma_setup = vdma_dma_setup
19231 }
19232 };
19233
19234diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
19235index 3c3550c..995858d 100644
19236--- a/arch/x86/include/asm/fpu/internal.h
19237+++ b/arch/x86/include/asm/fpu/internal.h
19238@@ -97,8 +97,11 @@ extern void fpstate_sanitize_xstate(struct fpu *fpu);
19239 #define user_insn(insn, output, input...) \
19240 ({ \
19241 int err; \
19242+ pax_open_userland(); \
19243 asm volatile(ASM_STAC "\n" \
19244- "1:" #insn "\n\t" \
19245+ "1:" \
19246+ __copyuser_seg \
19247+ #insn "\n\t" \
19248 "2: " ASM_CLAC "\n" \
19249 ".section .fixup,\"ax\"\n" \
19250 "3: movl $-1,%[err]\n" \
19251@@ -107,6 +110,7 @@ extern void fpstate_sanitize_xstate(struct fpu *fpu);
19252 _ASM_EXTABLE(1b, 3b) \
19253 : [err] "=r" (err), output \
19254 : "0"(0), input); \
19255+ pax_close_userland(); \
19256 err; \
19257 })
19258
19259@@ -186,9 +190,9 @@ static inline int copy_user_to_fregs(struct fregs_state __user *fx)
19260 static inline void copy_fxregs_to_kernel(struct fpu *fpu)
19261 {
19262 if (config_enabled(CONFIG_X86_32))
19263- asm volatile( "fxsave %[fx]" : [fx] "=m" (fpu->state.fxsave));
19264+ asm volatile( "fxsave %[fx]" : [fx] "=m" (fpu->state->fxsave));
19265 else if (config_enabled(CONFIG_AS_FXSAVEQ))
19266- asm volatile("fxsaveq %[fx]" : [fx] "=m" (fpu->state.fxsave));
19267+ asm volatile("fxsaveq %[fx]" : [fx] "=m" (fpu->state->fxsave));
19268 else {
19269 /* Using "rex64; fxsave %0" is broken because, if the memory
19270 * operand uses any extended registers for addressing, a second
19271@@ -212,8 +216,8 @@ static inline void copy_fxregs_to_kernel(struct fpu *fpu)
19272 * registers.
19273 */
19274 asm volatile( "rex64/fxsave (%[fx])"
19275- : "=m" (fpu->state.fxsave)
19276- : [fx] "R" (&fpu->state.fxsave));
19277+ : "=m" (fpu->state->fxsave)
19278+ : [fx] "R" (&fpu->state->fxsave));
19279 }
19280 }
19281
19282@@ -388,12 +392,16 @@ static inline int copy_xregs_to_user(struct xregs_state __user *buf)
19283 if (unlikely(err))
19284 return -EFAULT;
19285
19286+ pax_open_userland();
19287 __asm__ __volatile__(ASM_STAC "\n"
19288- "1:"XSAVE"\n"
19289+ "1:"
19290+ __copyuser_seg
19291+ XSAVE"\n"
19292 "2: " ASM_CLAC "\n"
19293 xstate_fault(err)
19294 : "D" (buf), "a" (-1), "d" (-1), "0" (err)
19295 : "memory");
19296+ pax_close_userland();
19297 return err;
19298 }
19299
19300@@ -402,17 +410,21 @@ static inline int copy_xregs_to_user(struct xregs_state __user *buf)
19301 */
19302 static inline int copy_user_to_xregs(struct xregs_state __user *buf, u64 mask)
19303 {
19304- struct xregs_state *xstate = ((__force struct xregs_state *)buf);
19305+ struct xregs_state *xstate = ((__force_kernel struct xregs_state *)buf);
19306 u32 lmask = mask;
19307 u32 hmask = mask >> 32;
19308 int err = 0;
19309
19310+ pax_open_userland();
19311 __asm__ __volatile__(ASM_STAC "\n"
19312- "1:"XRSTOR"\n"
19313+ "1:"
19314+ __copyuser_seg
19315+ XRSTOR"\n"
19316 "2: " ASM_CLAC "\n"
19317 xstate_fault(err)
19318 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (err)
19319 : "memory"); /* memory required? */
19320+ pax_close_userland();
19321 return err;
19322 }
19323
19324@@ -429,7 +441,7 @@ static inline int copy_user_to_xregs(struct xregs_state __user *buf, u64 mask)
19325 static inline int copy_fpregs_to_fpstate(struct fpu *fpu)
19326 {
19327 if (likely(use_xsave())) {
19328- copy_xregs_to_kernel(&fpu->state.xsave);
19329+ copy_xregs_to_kernel(&fpu->state->xsave);
19330 return 1;
19331 }
19332
19333@@ -442,7 +454,7 @@ static inline int copy_fpregs_to_fpstate(struct fpu *fpu)
19334 * Legacy FPU register saving, FNSAVE always clears FPU registers,
19335 * so we have to mark them inactive:
19336 */
19337- asm volatile("fnsave %[fp]; fwait" : [fp] "=m" (fpu->state.fsave));
19338+ asm volatile("fnsave %[fp]; fwait" : [fp] "=m" (fpu->state->fsave));
19339
19340 return 0;
19341 }
19342@@ -471,7 +483,7 @@ static inline void copy_kernel_to_fpregs(union fpregs_state *fpstate)
19343 "fnclex\n\t"
19344 "emms\n\t"
19345 "fildl %P[addr]" /* set F?P to defined value */
19346- : : [addr] "m" (fpstate));
19347+ : : [addr] "m" (cpu_tss[raw_smp_processor_id()].x86_tss.sp0));
19348 }
19349
19350 __copy_kernel_to_fpregs(fpstate);
19351@@ -643,7 +655,7 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu)
19352 static inline void switch_fpu_finish(struct fpu *new_fpu, fpu_switch_t fpu_switch)
19353 {
19354 if (fpu_switch.preload)
19355- copy_kernel_to_fpregs(&new_fpu->state);
19356+ copy_kernel_to_fpregs(new_fpu->state);
19357 }
19358
19359 /*
19360diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h
19361index c49c517..55ff1d0 100644
19362--- a/arch/x86/include/asm/fpu/types.h
19363+++ b/arch/x86/include/asm/fpu/types.h
19364@@ -287,10 +287,9 @@ struct fpu {
19365 * logic, which unconditionally saves/restores all FPU state
19366 * across context switches. (if FPU state exists.)
19367 */
19368- union fpregs_state state;
19369+ union fpregs_state *state;
19370 /*
19371- * WARNING: 'state' is dynamically-sized. Do not put
19372- * anything after it here.
19373+ * WARNING: 'state' is dynamically-sized.
19374 */
19375 };
19376
19377diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
19378index b4c1f54..e290c08 100644
19379--- a/arch/x86/include/asm/futex.h
19380+++ b/arch/x86/include/asm/futex.h
19381@@ -12,6 +12,7 @@
19382 #include <asm/smap.h>
19383
19384 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
19385+ typecheck(u32 __user *, uaddr); \
19386 asm volatile("\t" ASM_STAC "\n" \
19387 "1:\t" insn "\n" \
19388 "2:\t" ASM_CLAC "\n" \
19389@@ -20,15 +21,16 @@
19390 "\tjmp\t2b\n" \
19391 "\t.previous\n" \
19392 _ASM_EXTABLE(1b, 3b) \
19393- : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
19394+ : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
19395 : "i" (-EFAULT), "0" (oparg), "1" (0))
19396
19397 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
19398+ typecheck(u32 __user *, uaddr); \
19399 asm volatile("\t" ASM_STAC "\n" \
19400 "1:\tmovl %2, %0\n" \
19401 "\tmovl\t%0, %3\n" \
19402 "\t" insn "\n" \
19403- "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
19404+ "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
19405 "\tjnz\t1b\n" \
19406 "3:\t" ASM_CLAC "\n" \
19407 "\t.section .fixup,\"ax\"\n" \
19408@@ -38,7 +40,7 @@
19409 _ASM_EXTABLE(1b, 4b) \
19410 _ASM_EXTABLE(2b, 4b) \
19411 : "=&a" (oldval), "=&r" (ret), \
19412- "+m" (*uaddr), "=&r" (tem) \
19413+ "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
19414 : "r" (oparg), "i" (-EFAULT), "1" (0))
19415
19416 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
19417@@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
19418
19419 pagefault_disable();
19420
19421+ pax_open_userland();
19422 switch (op) {
19423 case FUTEX_OP_SET:
19424- __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
19425+ __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
19426 break;
19427 case FUTEX_OP_ADD:
19428- __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
19429+ __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
19430 uaddr, oparg);
19431 break;
19432 case FUTEX_OP_OR:
19433@@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
19434 default:
19435 ret = -ENOSYS;
19436 }
19437+ pax_close_userland();
19438
19439 pagefault_enable();
19440
19441diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
19442index 6615032..9c233be 100644
19443--- a/arch/x86/include/asm/hw_irq.h
19444+++ b/arch/x86/include/asm/hw_irq.h
19445@@ -158,8 +158,8 @@ static inline void unlock_vector_lock(void) {}
19446 #endif /* CONFIG_X86_LOCAL_APIC */
19447
19448 /* Statistics */
19449-extern atomic_t irq_err_count;
19450-extern atomic_t irq_mis_count;
19451+extern atomic_unchecked_t irq_err_count;
19452+extern atomic_unchecked_t irq_mis_count;
19453
19454 extern void elcr_set_level_irq(unsigned int irq);
19455
19456diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
19457index ccffa53..3c90c87 100644
19458--- a/arch/x86/include/asm/i8259.h
19459+++ b/arch/x86/include/asm/i8259.h
19460@@ -62,7 +62,7 @@ struct legacy_pic {
19461 void (*init)(int auto_eoi);
19462 int (*irq_pending)(unsigned int irq);
19463 void (*make_irq)(unsigned int irq);
19464-};
19465+} __do_const;
19466
19467 extern struct legacy_pic *legacy_pic;
19468 extern struct legacy_pic null_legacy_pic;
19469diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
19470index cc9c61b..7b17f40 100644
19471--- a/arch/x86/include/asm/io.h
19472+++ b/arch/x86/include/asm/io.h
19473@@ -42,6 +42,7 @@
19474 #include <asm/page.h>
19475 #include <asm/early_ioremap.h>
19476 #include <asm/pgtable_types.h>
19477+#include <asm/processor.h>
19478
19479 #define build_mmio_read(name, size, type, reg, barrier) \
19480 static inline type name(const volatile void __iomem *addr) \
19481@@ -54,12 +55,12 @@ static inline void name(type val, volatile void __iomem *addr) \
19482 "m" (*(volatile type __force *)addr) barrier); }
19483
19484 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
19485-build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
19486-build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
19487+build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
19488+build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
19489
19490 build_mmio_read(__readb, "b", unsigned char, "=q", )
19491-build_mmio_read(__readw, "w", unsigned short, "=r", )
19492-build_mmio_read(__readl, "l", unsigned int, "=r", )
19493+build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
19494+build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
19495
19496 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
19497 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
19498@@ -115,7 +116,7 @@ build_mmio_write(writeq, "q", unsigned long, "r", :"memory")
19499 * this function
19500 */
19501
19502-static inline phys_addr_t virt_to_phys(volatile void *address)
19503+static inline phys_addr_t __intentional_overflow(-1) virt_to_phys(volatile void *address)
19504 {
19505 return __pa(address);
19506 }
19507@@ -192,7 +193,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
19508 return ioremap_nocache(offset, size);
19509 }
19510
19511-extern void iounmap(volatile void __iomem *addr);
19512+extern void iounmap(const volatile void __iomem *addr);
19513
19514 extern void set_iounmap_nonlazy(void);
19515
19516@@ -200,6 +201,17 @@ extern void set_iounmap_nonlazy(void);
19517
19518 #include <asm-generic/iomap.h>
19519
19520+#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
19521+static inline int valid_phys_addr_range(unsigned long addr, size_t count)
19522+{
19523+ return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
19524+}
19525+
19526+static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
19527+{
19528+ return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
19529+}
19530+
19531 /*
19532 * Convert a virtual cached pointer to an uncached pointer
19533 */
19534diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
19535index b77f5ed..a2f791e 100644
19536--- a/arch/x86/include/asm/irqflags.h
19537+++ b/arch/x86/include/asm/irqflags.h
19538@@ -137,6 +137,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
19539 swapgs; \
19540 sysretl
19541
19542+#define GET_CR0_INTO_RDI mov %cr0, %rdi
19543+#define SET_RDI_INTO_CR0 mov %rdi, %cr0
19544+#define GET_CR3_INTO_RDI mov %cr3, %rdi
19545+#define SET_RDI_INTO_CR3 mov %rdi, %cr3
19546+
19547 #else
19548 #define INTERRUPT_RETURN iret
19549 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
19550diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
19551index 4421b5d..8543006 100644
19552--- a/arch/x86/include/asm/kprobes.h
19553+++ b/arch/x86/include/asm/kprobes.h
19554@@ -37,13 +37,8 @@ typedef u8 kprobe_opcode_t;
19555 #define RELATIVEJUMP_SIZE 5
19556 #define RELATIVECALL_OPCODE 0xe8
19557 #define RELATIVE_ADDR_SIZE 4
19558-#define MAX_STACK_SIZE 64
19559-#define MIN_STACK_SIZE(ADDR) \
19560- (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
19561- THREAD_SIZE - (unsigned long)(ADDR))) \
19562- ? (MAX_STACK_SIZE) \
19563- : (((unsigned long)current_thread_info()) + \
19564- THREAD_SIZE - (unsigned long)(ADDR)))
19565+#define MAX_STACK_SIZE 64UL
19566+#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
19567
19568 #define flush_insn_slot(p) do { } while (0)
19569
19570diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
19571index 4ad6560..75c7bdd 100644
19572--- a/arch/x86/include/asm/local.h
19573+++ b/arch/x86/include/asm/local.h
19574@@ -10,33 +10,97 @@ typedef struct {
19575 atomic_long_t a;
19576 } local_t;
19577
19578+typedef struct {
19579+ atomic_long_unchecked_t a;
19580+} local_unchecked_t;
19581+
19582 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
19583
19584 #define local_read(l) atomic_long_read(&(l)->a)
19585+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
19586 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
19587+#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
19588
19589 static inline void local_inc(local_t *l)
19590 {
19591- asm volatile(_ASM_INC "%0"
19592+ asm volatile(_ASM_INC "%0\n"
19593+
19594+#ifdef CONFIG_PAX_REFCOUNT
19595+ "jno 0f\n"
19596+ _ASM_DEC "%0\n"
19597+ "int $4\n0:\n"
19598+ _ASM_EXTABLE(0b, 0b)
19599+#endif
19600+
19601+ : "+m" (l->a.counter));
19602+}
19603+
19604+static inline void local_inc_unchecked(local_unchecked_t *l)
19605+{
19606+ asm volatile(_ASM_INC "%0\n"
19607 : "+m" (l->a.counter));
19608 }
19609
19610 static inline void local_dec(local_t *l)
19611 {
19612- asm volatile(_ASM_DEC "%0"
19613+ asm volatile(_ASM_DEC "%0\n"
19614+
19615+#ifdef CONFIG_PAX_REFCOUNT
19616+ "jno 0f\n"
19617+ _ASM_INC "%0\n"
19618+ "int $4\n0:\n"
19619+ _ASM_EXTABLE(0b, 0b)
19620+#endif
19621+
19622+ : "+m" (l->a.counter));
19623+}
19624+
19625+static inline void local_dec_unchecked(local_unchecked_t *l)
19626+{
19627+ asm volatile(_ASM_DEC "%0\n"
19628 : "+m" (l->a.counter));
19629 }
19630
19631 static inline void local_add(long i, local_t *l)
19632 {
19633- asm volatile(_ASM_ADD "%1,%0"
19634+ asm volatile(_ASM_ADD "%1,%0\n"
19635+
19636+#ifdef CONFIG_PAX_REFCOUNT
19637+ "jno 0f\n"
19638+ _ASM_SUB "%1,%0\n"
19639+ "int $4\n0:\n"
19640+ _ASM_EXTABLE(0b, 0b)
19641+#endif
19642+
19643+ : "+m" (l->a.counter)
19644+ : "ir" (i));
19645+}
19646+
19647+static inline void local_add_unchecked(long i, local_unchecked_t *l)
19648+{
19649+ asm volatile(_ASM_ADD "%1,%0\n"
19650 : "+m" (l->a.counter)
19651 : "ir" (i));
19652 }
19653
19654 static inline void local_sub(long i, local_t *l)
19655 {
19656- asm volatile(_ASM_SUB "%1,%0"
19657+ asm volatile(_ASM_SUB "%1,%0\n"
19658+
19659+#ifdef CONFIG_PAX_REFCOUNT
19660+ "jno 0f\n"
19661+ _ASM_ADD "%1,%0\n"
19662+ "int $4\n0:\n"
19663+ _ASM_EXTABLE(0b, 0b)
19664+#endif
19665+
19666+ : "+m" (l->a.counter)
19667+ : "ir" (i));
19668+}
19669+
19670+static inline void local_sub_unchecked(long i, local_unchecked_t *l)
19671+{
19672+ asm volatile(_ASM_SUB "%1,%0\n"
19673 : "+m" (l->a.counter)
19674 : "ir" (i));
19675 }
19676@@ -52,7 +116,7 @@ static inline void local_sub(long i, local_t *l)
19677 */
19678 static inline int local_sub_and_test(long i, local_t *l)
19679 {
19680- GEN_BINARY_RMWcc(_ASM_SUB, l->a.counter, "er", i, "%0", "e");
19681+ GEN_BINARY_RMWcc(_ASM_SUB, _ASM_ADD, l->a.counter, "er", i, "%0", "e");
19682 }
19683
19684 /**
19685@@ -65,7 +129,7 @@ static inline int local_sub_and_test(long i, local_t *l)
19686 */
19687 static inline int local_dec_and_test(local_t *l)
19688 {
19689- GEN_UNARY_RMWcc(_ASM_DEC, l->a.counter, "%0", "e");
19690+ GEN_UNARY_RMWcc(_ASM_DEC, _ASM_INC, l->a.counter, "%0", "e");
19691 }
19692
19693 /**
19694@@ -78,7 +142,7 @@ static inline int local_dec_and_test(local_t *l)
19695 */
19696 static inline int local_inc_and_test(local_t *l)
19697 {
19698- GEN_UNARY_RMWcc(_ASM_INC, l->a.counter, "%0", "e");
19699+ GEN_UNARY_RMWcc(_ASM_INC, _ASM_DEC, l->a.counter, "%0", "e");
19700 }
19701
19702 /**
19703@@ -92,7 +156,7 @@ static inline int local_inc_and_test(local_t *l)
19704 */
19705 static inline int local_add_negative(long i, local_t *l)
19706 {
19707- GEN_BINARY_RMWcc(_ASM_ADD, l->a.counter, "er", i, "%0", "s");
19708+ GEN_BINARY_RMWcc(_ASM_ADD, _ASM_SUB, l->a.counter, "er", i, "%0", "s");
19709 }
19710
19711 /**
19712@@ -105,6 +169,30 @@ static inline int local_add_negative(long i, local_t *l)
19713 static inline long local_add_return(long i, local_t *l)
19714 {
19715 long __i = i;
19716+ asm volatile(_ASM_XADD "%0, %1\n"
19717+
19718+#ifdef CONFIG_PAX_REFCOUNT
19719+ "jno 0f\n"
19720+ _ASM_MOV "%0,%1\n"
19721+ "int $4\n0:\n"
19722+ _ASM_EXTABLE(0b, 0b)
19723+#endif
19724+
19725+ : "+r" (i), "+m" (l->a.counter)
19726+ : : "memory");
19727+ return i + __i;
19728+}
19729+
19730+/**
19731+ * local_add_return_unchecked - add and return
19732+ * @i: integer value to add
19733+ * @l: pointer to type local_unchecked_t
19734+ *
19735+ * Atomically adds @i to @l and returns @i + @l
19736+ */
19737+static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
19738+{
19739+ long __i = i;
19740 asm volatile(_ASM_XADD "%0, %1;"
19741 : "+r" (i), "+m" (l->a.counter)
19742 : : "memory");
19743@@ -121,6 +209,8 @@ static inline long local_sub_return(long i, local_t *l)
19744
19745 #define local_cmpxchg(l, o, n) \
19746 (cmpxchg_local(&((l)->a.counter), (o), (n)))
19747+#define local_cmpxchg_unchecked(l, o, n) \
19748+ (cmpxchg_local(&((l)->a.counter), (o), (n)))
19749 /* Always has a lock prefix */
19750 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
19751
19752diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
19753new file mode 100644
19754index 0000000..2bfd3ba
19755--- /dev/null
19756+++ b/arch/x86/include/asm/mman.h
19757@@ -0,0 +1,15 @@
19758+#ifndef _X86_MMAN_H
19759+#define _X86_MMAN_H
19760+
19761+#include <uapi/asm/mman.h>
19762+
19763+#ifdef __KERNEL__
19764+#ifndef __ASSEMBLY__
19765+#ifdef CONFIG_X86_32
19766+#define arch_mmap_check i386_mmap_check
19767+int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
19768+#endif
19769+#endif
19770+#endif
19771+
19772+#endif /* X86_MMAN_H */
19773diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
19774index 364d274..e51b4bc 100644
19775--- a/arch/x86/include/asm/mmu.h
19776+++ b/arch/x86/include/asm/mmu.h
19777@@ -17,7 +17,19 @@ typedef struct {
19778 #endif
19779
19780 struct mutex lock;
19781- void __user *vdso;
19782+ unsigned long vdso;
19783+
19784+#ifdef CONFIG_X86_32
19785+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
19786+ unsigned long user_cs_base;
19787+ unsigned long user_cs_limit;
19788+
19789+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
19790+ cpumask_t cpu_user_cs_mask;
19791+#endif
19792+
19793+#endif
19794+#endif
19795
19796 atomic_t perf_rdpmc_allowed; /* nonzero if rdpmc is allowed */
19797 } mm_context_t;
19798diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
19799index 984abfe..9996c62 100644
19800--- a/arch/x86/include/asm/mmu_context.h
19801+++ b/arch/x86/include/asm/mmu_context.h
19802@@ -45,7 +45,7 @@ struct ldt_struct {
19803 * allocations, but it's not worth trying to optimize.
19804 */
19805 struct desc_struct *entries;
19806- int size;
19807+ unsigned int size;
19808 };
19809
19810 static inline void load_mm_ldt(struct mm_struct *mm)
19811@@ -86,26 +86,95 @@ void destroy_context(struct mm_struct *mm);
19812
19813 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
19814 {
19815+
19816+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19817+ if (!(static_cpu_has(X86_FEATURE_PCIDUDEREF))) {
19818+ unsigned int i;
19819+ pgd_t *pgd;
19820+
19821+ pax_open_kernel();
19822+ pgd = get_cpu_pgd(smp_processor_id(), kernel);
19823+ for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
19824+ set_pgd_batched(pgd+i, native_make_pgd(0));
19825+ pax_close_kernel();
19826+ }
19827+#endif
19828+
19829 #ifdef CONFIG_SMP
19830 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
19831 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
19832 #endif
19833 }
19834
19835+static inline void pax_switch_mm(struct mm_struct *next, unsigned int cpu)
19836+{
19837+
19838+#ifdef CONFIG_PAX_PER_CPU_PGD
19839+ pax_open_kernel();
19840+
19841+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19842+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF))
19843+ __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
19844+ else
19845+#endif
19846+
19847+ __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
19848+
19849+ __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
19850+
19851+ pax_close_kernel();
19852+
19853+ 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));
19854+
19855+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19856+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF)) {
19857+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
19858+ u64 descriptor[2];
19859+ descriptor[0] = PCID_USER;
19860+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
19861+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
19862+ descriptor[0] = PCID_KERNEL;
19863+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
19864+ }
19865+ } else {
19866+ write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
19867+ if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
19868+ write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
19869+ else
19870+ write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
19871+ }
19872+ } else
19873+#endif
19874+
19875+ load_cr3(get_cpu_pgd(cpu, kernel));
19876+#endif
19877+
19878+}
19879+
19880 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
19881 struct task_struct *tsk)
19882 {
19883 unsigned cpu = smp_processor_id();
19884+#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
19885+ int tlbstate = TLBSTATE_OK;
19886+#endif
19887
19888 if (likely(prev != next)) {
19889 #ifdef CONFIG_SMP
19890+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
19891+ tlbstate = this_cpu_read(cpu_tlbstate.state);
19892+#endif
19893 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
19894 this_cpu_write(cpu_tlbstate.active_mm, next);
19895 #endif
19896 cpumask_set_cpu(cpu, mm_cpumask(next));
19897
19898 /* Re-load page tables */
19899+#ifdef CONFIG_PAX_PER_CPU_PGD
19900+ pax_switch_mm(next, cpu);
19901+#else
19902 load_cr3(next->pgd);
19903+#endif
19904 trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL);
19905
19906 /* Stop flush ipis for the previous mm */
19907@@ -128,9 +197,31 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
19908 */
19909 if (unlikely(prev->context.ldt != next->context.ldt))
19910 load_mm_ldt(next);
19911+
19912+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
19913+ if (!(__supported_pte_mask & _PAGE_NX)) {
19914+ smp_mb__before_atomic();
19915+ cpumask_clear_cpu(cpu, &prev->context.cpu_user_cs_mask);
19916+ smp_mb__after_atomic();
19917+ cpumask_set_cpu(cpu, &next->context.cpu_user_cs_mask);
19918+ }
19919+#endif
19920+
19921+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
19922+ if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
19923+ prev->context.user_cs_limit != next->context.user_cs_limit))
19924+ set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
19925+#ifdef CONFIG_SMP
19926+ else if (unlikely(tlbstate != TLBSTATE_OK))
19927+ set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
19928+#endif
19929+#endif
19930+
19931 }
19932+ else {
19933+ pax_switch_mm(next, cpu);
19934+
19935 #ifdef CONFIG_SMP
19936- else {
19937 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
19938 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
19939
19940@@ -147,13 +238,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
19941 * tlb flush IPI delivery. We must reload CR3
19942 * to make sure to use no freed page tables.
19943 */
19944+
19945+#ifndef CONFIG_PAX_PER_CPU_PGD
19946 load_cr3(next->pgd);
19947 trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL);
19948+#endif
19949+
19950 load_mm_cr4(next);
19951 load_mm_ldt(next);
19952+
19953+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
19954+ if (!(__supported_pte_mask & _PAGE_NX))
19955+ cpumask_set_cpu(cpu, &next->context.cpu_user_cs_mask);
19956+#endif
19957+
19958+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
19959+#ifdef CONFIG_PAX_PAGEEXEC
19960+ if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
19961+#endif
19962+ set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
19963+#endif
19964+
19965 }
19966+#endif
19967 }
19968-#endif
19969 }
19970
19971 #define activate_mm(prev, next) \
19972diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
19973index e3b7819..b257c64 100644
19974--- a/arch/x86/include/asm/module.h
19975+++ b/arch/x86/include/asm/module.h
19976@@ -5,6 +5,7 @@
19977
19978 #ifdef CONFIG_X86_64
19979 /* X86_64 does not define MODULE_PROC_FAMILY */
19980+#define MODULE_PROC_FAMILY ""
19981 #elif defined CONFIG_M486
19982 #define MODULE_PROC_FAMILY "486 "
19983 #elif defined CONFIG_M586
19984@@ -57,8 +58,20 @@
19985 #error unknown processor family
19986 #endif
19987
19988-#ifdef CONFIG_X86_32
19989-# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
19990+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
19991+#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
19992+#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
19993+#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
19994+#else
19995+#define MODULE_PAX_KERNEXEC ""
19996 #endif
19997
19998+#ifdef CONFIG_PAX_MEMORY_UDEREF
19999+#define MODULE_PAX_UDEREF "UDEREF "
20000+#else
20001+#define MODULE_PAX_UDEREF ""
20002+#endif
20003+
20004+#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
20005+
20006 #endif /* _ASM_X86_MODULE_H */
20007diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
20008index 5f2fc44..106caa6 100644
20009--- a/arch/x86/include/asm/nmi.h
20010+++ b/arch/x86/include/asm/nmi.h
20011@@ -36,26 +36,35 @@ enum {
20012
20013 typedef int (*nmi_handler_t)(unsigned int, struct pt_regs *);
20014
20015+struct nmiaction;
20016+
20017+struct nmiwork {
20018+ const struct nmiaction *action;
20019+ u64 max_duration;
20020+ struct irq_work irq_work;
20021+};
20022+
20023 struct nmiaction {
20024 struct list_head list;
20025 nmi_handler_t handler;
20026- u64 max_duration;
20027- struct irq_work irq_work;
20028 unsigned long flags;
20029 const char *name;
20030-};
20031+ struct nmiwork *work;
20032+} __do_const;
20033
20034 #define register_nmi_handler(t, fn, fg, n, init...) \
20035 ({ \
20036- static struct nmiaction init fn##_na = { \
20037+ static struct nmiwork fn##_nw; \
20038+ static const struct nmiaction init fn##_na = { \
20039 .handler = (fn), \
20040 .name = (n), \
20041 .flags = (fg), \
20042+ .work = &fn##_nw, \
20043 }; \
20044 __register_nmi_handler((t), &fn##_na); \
20045 })
20046
20047-int __register_nmi_handler(unsigned int, struct nmiaction *);
20048+int __register_nmi_handler(unsigned int, const struct nmiaction *);
20049
20050 void unregister_nmi_handler(unsigned int, const char *);
20051
20052diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
20053index 802dde3..9183e68 100644
20054--- a/arch/x86/include/asm/page.h
20055+++ b/arch/x86/include/asm/page.h
20056@@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
20057 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
20058
20059 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
20060+#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
20061
20062 #define __boot_va(x) __va(x)
20063 #define __boot_pa(x) __pa(x)
20064@@ -60,11 +61,21 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
20065 * virt_to_page(kaddr) returns a valid pointer if and only if
20066 * virt_addr_valid(kaddr) returns true.
20067 */
20068-#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
20069 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
20070 extern bool __virt_addr_valid(unsigned long kaddr);
20071 #define virt_addr_valid(kaddr) __virt_addr_valid((unsigned long) (kaddr))
20072
20073+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
20074+#define virt_to_page(kaddr) \
20075+ ({ \
20076+ const void *__kaddr = (const void *)(kaddr); \
20077+ BUG_ON(!virt_addr_valid(__kaddr)); \
20078+ pfn_to_page(__pa(__kaddr) >> PAGE_SHIFT); \
20079+ })
20080+#else
20081+#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
20082+#endif
20083+
20084 #endif /* __ASSEMBLY__ */
20085
20086 #include <asm-generic/memory_model.h>
20087diff --git a/arch/x86/include/asm/page_32.h b/arch/x86/include/asm/page_32.h
20088index 904f528..b4d0d24 100644
20089--- a/arch/x86/include/asm/page_32.h
20090+++ b/arch/x86/include/asm/page_32.h
20091@@ -7,11 +7,17 @@
20092
20093 #define __phys_addr_nodebug(x) ((x) - PAGE_OFFSET)
20094 #ifdef CONFIG_DEBUG_VIRTUAL
20095-extern unsigned long __phys_addr(unsigned long);
20096+extern unsigned long __intentional_overflow(-1) __phys_addr(unsigned long);
20097 #else
20098-#define __phys_addr(x) __phys_addr_nodebug(x)
20099+static inline unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
20100+{
20101+ return __phys_addr_nodebug(x);
20102+}
20103 #endif
20104-#define __phys_addr_symbol(x) __phys_addr(x)
20105+static inline unsigned long __intentional_overflow(-1) __phys_addr_symbol(unsigned long x)
20106+{
20107+ return __phys_addr(x);
20108+}
20109 #define __phys_reloc_hide(x) RELOC_HIDE((x), 0)
20110
20111 #ifdef CONFIG_FLATMEM
20112diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
20113index b3bebf9..cb419e7 100644
20114--- a/arch/x86/include/asm/page_64.h
20115+++ b/arch/x86/include/asm/page_64.h
20116@@ -7,9 +7,9 @@
20117
20118 /* duplicated to the one in bootmem.h */
20119 extern unsigned long max_pfn;
20120-extern unsigned long phys_base;
20121+extern const unsigned long phys_base;
20122
20123-static inline unsigned long __phys_addr_nodebug(unsigned long x)
20124+static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
20125 {
20126 unsigned long y = x - __START_KERNEL_map;
20127
20128@@ -20,12 +20,14 @@ static inline unsigned long __phys_addr_nodebug(unsigned long x)
20129 }
20130
20131 #ifdef CONFIG_DEBUG_VIRTUAL
20132-extern unsigned long __phys_addr(unsigned long);
20133-extern unsigned long __phys_addr_symbol(unsigned long);
20134+extern unsigned long __intentional_overflow(-1) __phys_addr(unsigned long);
20135+extern unsigned long __intentional_overflow(-1) __phys_addr_symbol(unsigned long);
20136 #else
20137 #define __phys_addr(x) __phys_addr_nodebug(x)
20138-#define __phys_addr_symbol(x) \
20139- ((unsigned long)(x) - __START_KERNEL_map + phys_base)
20140+static inline unsigned long __intentional_overflow(-1) __phys_addr_symbol(unsigned long x)
20141+{
20142+ return x - __START_KERNEL_map + phys_base;
20143+}
20144 #endif
20145
20146 #define __phys_reloc_hide(x) (x)
20147diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
20148index d143bfa..30d1f41 100644
20149--- a/arch/x86/include/asm/paravirt.h
20150+++ b/arch/x86/include/asm/paravirt.h
20151@@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
20152 return (pmd_t) { ret };
20153 }
20154
20155-static inline pmdval_t pmd_val(pmd_t pmd)
20156+static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
20157 {
20158 pmdval_t ret;
20159
20160@@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
20161 val);
20162 }
20163
20164+static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
20165+{
20166+ pgdval_t val = native_pgd_val(pgd);
20167+
20168+ if (sizeof(pgdval_t) > sizeof(long))
20169+ PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
20170+ val, (u64)val >> 32);
20171+ else
20172+ PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
20173+ val);
20174+}
20175+
20176 static inline void pgd_clear(pgd_t *pgdp)
20177 {
20178 set_pgd(pgdp, __pgd(0));
20179@@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
20180 pv_mmu_ops.set_fixmap(idx, phys, flags);
20181 }
20182
20183+#ifdef CONFIG_PAX_KERNEXEC
20184+static inline unsigned long pax_open_kernel(void)
20185+{
20186+ return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
20187+}
20188+
20189+static inline unsigned long pax_close_kernel(void)
20190+{
20191+ return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
20192+}
20193+#else
20194+static inline unsigned long pax_open_kernel(void) { return 0; }
20195+static inline unsigned long pax_close_kernel(void) { return 0; }
20196+#endif
20197+
20198 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
20199
20200 #ifdef CONFIG_QUEUED_SPINLOCKS
20201@@ -933,7 +960,7 @@ extern void default_banner(void);
20202
20203 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
20204 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
20205-#define PARA_INDIRECT(addr) *%cs:addr
20206+#define PARA_INDIRECT(addr) *%ss:addr
20207 #endif
20208
20209 #define INTERRUPT_RETURN \
20210@@ -1003,6 +1030,21 @@ extern void default_banner(void);
20211 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_usergs_sysret64), \
20212 CLBR_NONE, \
20213 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_usergs_sysret64))
20214+
20215+#define GET_CR0_INTO_RDI \
20216+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
20217+ mov %rax,%rdi
20218+
20219+#define SET_RDI_INTO_CR0 \
20220+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20221+
20222+#define GET_CR3_INTO_RDI \
20223+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
20224+ mov %rax,%rdi
20225+
20226+#define SET_RDI_INTO_CR3 \
20227+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
20228+
20229 #endif /* CONFIG_X86_32 */
20230
20231 #endif /* __ASSEMBLY__ */
20232diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
20233index a6b8f9f..fd61ef7 100644
20234--- a/arch/x86/include/asm/paravirt_types.h
20235+++ b/arch/x86/include/asm/paravirt_types.h
20236@@ -84,7 +84,7 @@ struct pv_init_ops {
20237 */
20238 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
20239 unsigned long addr, unsigned len);
20240-};
20241+} __no_const __no_randomize_layout;
20242
20243
20244 struct pv_lazy_ops {
20245@@ -92,13 +92,13 @@ struct pv_lazy_ops {
20246 void (*enter)(void);
20247 void (*leave)(void);
20248 void (*flush)(void);
20249-};
20250+} __no_randomize_layout;
20251
20252 struct pv_time_ops {
20253 unsigned long long (*sched_clock)(void);
20254 unsigned long long (*steal_clock)(int cpu);
20255 unsigned long (*get_tsc_khz)(void);
20256-};
20257+} __no_const __no_randomize_layout;
20258
20259 struct pv_cpu_ops {
20260 /* hooks for various privileged instructions */
20261@@ -193,7 +193,7 @@ struct pv_cpu_ops {
20262
20263 void (*start_context_switch)(struct task_struct *prev);
20264 void (*end_context_switch)(struct task_struct *next);
20265-};
20266+} __no_const __no_randomize_layout;
20267
20268 struct pv_irq_ops {
20269 /*
20270@@ -216,7 +216,7 @@ struct pv_irq_ops {
20271 #ifdef CONFIG_X86_64
20272 void (*adjust_exception_frame)(void);
20273 #endif
20274-};
20275+} __no_randomize_layout;
20276
20277 struct pv_apic_ops {
20278 #ifdef CONFIG_X86_LOCAL_APIC
20279@@ -224,7 +224,7 @@ struct pv_apic_ops {
20280 unsigned long start_eip,
20281 unsigned long start_esp);
20282 #endif
20283-};
20284+} __no_const __no_randomize_layout;
20285
20286 struct pv_mmu_ops {
20287 unsigned long (*read_cr2)(void);
20288@@ -314,6 +314,7 @@ struct pv_mmu_ops {
20289 struct paravirt_callee_save make_pud;
20290
20291 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
20292+ void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
20293 #endif /* CONFIG_PGTABLE_LEVELS == 4 */
20294 #endif /* CONFIG_PGTABLE_LEVELS >= 3 */
20295
20296@@ -325,7 +326,13 @@ struct pv_mmu_ops {
20297 an mfn. We can tell which is which from the index. */
20298 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
20299 phys_addr_t phys, pgprot_t flags);
20300-};
20301+
20302+#ifdef CONFIG_PAX_KERNEXEC
20303+ unsigned long (*pax_open_kernel)(void);
20304+ unsigned long (*pax_close_kernel)(void);
20305+#endif
20306+
20307+} __no_randomize_layout;
20308
20309 struct arch_spinlock;
20310 #ifdef CONFIG_SMP
20311@@ -347,11 +354,14 @@ struct pv_lock_ops {
20312 struct paravirt_callee_save lock_spinning;
20313 void (*unlock_kick)(struct arch_spinlock *lock, __ticket_t ticket);
20314 #endif /* !CONFIG_QUEUED_SPINLOCKS */
20315-};
20316+} __no_randomize_layout;
20317
20318 /* This contains all the paravirt structures: we get a convenient
20319 * number for each function using the offset which we use to indicate
20320- * what to patch. */
20321+ * what to patch.
20322+ * shouldn't be randomized due to the "NEAT TRICK" in paravirt.c
20323+ */
20324+
20325 struct paravirt_patch_template {
20326 struct pv_init_ops pv_init_ops;
20327 struct pv_time_ops pv_time_ops;
20328@@ -360,7 +370,7 @@ struct paravirt_patch_template {
20329 struct pv_apic_ops pv_apic_ops;
20330 struct pv_mmu_ops pv_mmu_ops;
20331 struct pv_lock_ops pv_lock_ops;
20332-};
20333+} __no_randomize_layout;
20334
20335 extern struct pv_info pv_info;
20336 extern struct pv_init_ops pv_init_ops;
20337diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
20338index bf7f8b5..ca5799d 100644
20339--- a/arch/x86/include/asm/pgalloc.h
20340+++ b/arch/x86/include/asm/pgalloc.h
20341@@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
20342 pmd_t *pmd, pte_t *pte)
20343 {
20344 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
20345+ set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
20346+}
20347+
20348+static inline void pmd_populate_user(struct mm_struct *mm,
20349+ pmd_t *pmd, pte_t *pte)
20350+{
20351+ paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
20352 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
20353 }
20354
20355@@ -108,12 +115,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
20356
20357 #ifdef CONFIG_X86_PAE
20358 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
20359+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
20360+{
20361+ pud_populate(mm, pudp, pmd);
20362+}
20363 #else /* !CONFIG_X86_PAE */
20364 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
20365 {
20366 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
20367 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
20368 }
20369+
20370+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
20371+{
20372+ paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
20373+ set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
20374+}
20375 #endif /* CONFIG_X86_PAE */
20376
20377 #if CONFIG_PGTABLE_LEVELS > 3
20378@@ -123,6 +140,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
20379 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
20380 }
20381
20382+static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
20383+{
20384+ paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
20385+ set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
20386+}
20387+
20388 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
20389 {
20390 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
20391diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
20392index fd74a11..35fd5af 100644
20393--- a/arch/x86/include/asm/pgtable-2level.h
20394+++ b/arch/x86/include/asm/pgtable-2level.h
20395@@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
20396
20397 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
20398 {
20399+ pax_open_kernel();
20400 *pmdp = pmd;
20401+ pax_close_kernel();
20402 }
20403
20404 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
20405diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
20406index cdaa58c..ae30f0d 100644
20407--- a/arch/x86/include/asm/pgtable-3level.h
20408+++ b/arch/x86/include/asm/pgtable-3level.h
20409@@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
20410
20411 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
20412 {
20413+ pax_open_kernel();
20414 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
20415+ pax_close_kernel();
20416 }
20417
20418 static inline void native_set_pud(pud_t *pudp, pud_t pud)
20419 {
20420+ pax_open_kernel();
20421 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
20422+ pax_close_kernel();
20423 }
20424
20425 /*
20426@@ -116,9 +120,12 @@ static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr,
20427 static inline void native_pmd_clear(pmd_t *pmd)
20428 {
20429 u32 *tmp = (u32 *)pmd;
20430+
20431+ pax_open_kernel();
20432 *tmp = 0;
20433 smp_wmb();
20434 *(tmp + 1) = 0;
20435+ pax_close_kernel();
20436 }
20437
20438 static inline void pud_clear(pud_t *pudp)
20439diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
20440index 867da5b..7ec083d 100644
20441--- a/arch/x86/include/asm/pgtable.h
20442+++ b/arch/x86/include/asm/pgtable.h
20443@@ -47,6 +47,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
20444
20445 #ifndef __PAGETABLE_PUD_FOLDED
20446 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
20447+#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
20448 #define pgd_clear(pgd) native_pgd_clear(pgd)
20449 #endif
20450
20451@@ -84,12 +85,53 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
20452
20453 #define arch_end_context_switch(prev) do {} while(0)
20454
20455+#define pax_open_kernel() native_pax_open_kernel()
20456+#define pax_close_kernel() native_pax_close_kernel()
20457 #endif /* CONFIG_PARAVIRT */
20458
20459+#define __HAVE_ARCH_PAX_OPEN_KERNEL
20460+#define __HAVE_ARCH_PAX_CLOSE_KERNEL
20461+
20462+#ifdef CONFIG_PAX_KERNEXEC
20463+static inline unsigned long native_pax_open_kernel(void)
20464+{
20465+ unsigned long cr0;
20466+
20467+ preempt_disable();
20468+ barrier();
20469+ cr0 = read_cr0() ^ X86_CR0_WP;
20470+ BUG_ON(cr0 & X86_CR0_WP);
20471+ write_cr0(cr0);
20472+ barrier();
20473+ return cr0 ^ X86_CR0_WP;
20474+}
20475+
20476+static inline unsigned long native_pax_close_kernel(void)
20477+{
20478+ unsigned long cr0;
20479+
20480+ barrier();
20481+ cr0 = read_cr0() ^ X86_CR0_WP;
20482+ BUG_ON(!(cr0 & X86_CR0_WP));
20483+ write_cr0(cr0);
20484+ barrier();
20485+ preempt_enable_no_resched();
20486+ return cr0 ^ X86_CR0_WP;
20487+}
20488+#else
20489+static inline unsigned long native_pax_open_kernel(void) { return 0; }
20490+static inline unsigned long native_pax_close_kernel(void) { return 0; }
20491+#endif
20492+
20493 /*
20494 * The following only work if pte_present() is true.
20495 * Undefined behaviour if not..
20496 */
20497+static inline int pte_user(pte_t pte)
20498+{
20499+ return pte_val(pte) & _PAGE_USER;
20500+}
20501+
20502 static inline int pte_dirty(pte_t pte)
20503 {
20504 return pte_flags(pte) & _PAGE_DIRTY;
20505@@ -150,6 +192,11 @@ static inline unsigned long pud_pfn(pud_t pud)
20506 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
20507 }
20508
20509+static inline unsigned long pgd_pfn(pgd_t pgd)
20510+{
20511+ return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
20512+}
20513+
20514 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
20515
20516 static inline int pmd_large(pmd_t pte)
20517@@ -203,9 +250,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
20518 return pte_clear_flags(pte, _PAGE_RW);
20519 }
20520
20521+static inline pte_t pte_mkread(pte_t pte)
20522+{
20523+ return __pte(pte_val(pte) | _PAGE_USER);
20524+}
20525+
20526 static inline pte_t pte_mkexec(pte_t pte)
20527 {
20528- return pte_clear_flags(pte, _PAGE_NX);
20529+#ifdef CONFIG_X86_PAE
20530+ if (__supported_pte_mask & _PAGE_NX)
20531+ return pte_clear_flags(pte, _PAGE_NX);
20532+ else
20533+#endif
20534+ return pte_set_flags(pte, _PAGE_USER);
20535+}
20536+
20537+static inline pte_t pte_exprotect(pte_t pte)
20538+{
20539+#ifdef CONFIG_X86_PAE
20540+ if (__supported_pte_mask & _PAGE_NX)
20541+ return pte_set_flags(pte, _PAGE_NX);
20542+ else
20543+#endif
20544+ return pte_clear_flags(pte, _PAGE_USER);
20545 }
20546
20547 static inline pte_t pte_mkdirty(pte_t pte)
20548@@ -426,6 +493,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
20549 #endif
20550
20551 #ifndef __ASSEMBLY__
20552+
20553+#ifdef CONFIG_PAX_PER_CPU_PGD
20554+extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
20555+enum cpu_pgd_type {kernel = 0, user = 1};
20556+static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
20557+{
20558+ return cpu_pgd[cpu][type];
20559+}
20560+#endif
20561+
20562 #include <linux/mm_types.h>
20563 #include <linux/mmdebug.h>
20564 #include <linux/log2.h>
20565@@ -577,7 +654,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
20566 * Currently stuck as a macro due to indirect forward reference to
20567 * linux/mmzone.h's __section_mem_map_addr() definition:
20568 */
20569-#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
20570+#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
20571
20572 /* Find an entry in the second-level page table.. */
20573 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
20574@@ -617,7 +694,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
20575 * Currently stuck as a macro due to indirect forward reference to
20576 * linux/mmzone.h's __section_mem_map_addr() definition:
20577 */
20578-#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
20579+#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
20580
20581 /* to find an entry in a page-table-directory. */
20582 static inline unsigned long pud_index(unsigned long address)
20583@@ -632,7 +709,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
20584
20585 static inline int pgd_bad(pgd_t pgd)
20586 {
20587- return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
20588+ return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
20589 }
20590
20591 static inline int pgd_none(pgd_t pgd)
20592@@ -655,7 +732,12 @@ static inline int pgd_none(pgd_t pgd)
20593 * pgd_offset() returns a (pgd_t *)
20594 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
20595 */
20596-#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
20597+#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
20598+
20599+#ifdef CONFIG_PAX_PER_CPU_PGD
20600+#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
20601+#endif
20602+
20603 /*
20604 * a shortcut which implies the use of the kernel's pgd, instead
20605 * of a process's
20606@@ -666,6 +748,25 @@ static inline int pgd_none(pgd_t pgd)
20607 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
20608 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
20609
20610+#ifdef CONFIG_X86_32
20611+#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
20612+#else
20613+#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
20614+#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
20615+
20616+#ifdef CONFIG_PAX_MEMORY_UDEREF
20617+#ifdef __ASSEMBLY__
20618+#define pax_user_shadow_base pax_user_shadow_base(%rip)
20619+#else
20620+extern unsigned long pax_user_shadow_base;
20621+extern pgdval_t clone_pgd_mask;
20622+#endif
20623+#else
20624+#define pax_user_shadow_base (0UL)
20625+#endif
20626+
20627+#endif
20628+
20629 #ifndef __ASSEMBLY__
20630
20631 extern int direct_gbpages;
20632@@ -832,11 +933,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
20633 * dst and src can be on the same page, but the range must not overlap,
20634 * and must not cross a page boundary.
20635 */
20636-static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
20637+static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
20638 {
20639- memcpy(dst, src, count * sizeof(pgd_t));
20640+ pax_open_kernel();
20641+ while (count--)
20642+ *dst++ = *src++;
20643+ pax_close_kernel();
20644 }
20645
20646+#ifdef CONFIG_PAX_PER_CPU_PGD
20647+extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
20648+#endif
20649+
20650+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
20651+extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
20652+#else
20653+static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
20654+#endif
20655+
20656 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
20657 static inline int page_level_shift(enum pg_level level)
20658 {
20659diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
20660index b6c0b40..3535d47 100644
20661--- a/arch/x86/include/asm/pgtable_32.h
20662+++ b/arch/x86/include/asm/pgtable_32.h
20663@@ -25,9 +25,6 @@
20664 struct mm_struct;
20665 struct vm_area_struct;
20666
20667-extern pgd_t swapper_pg_dir[1024];
20668-extern pgd_t initial_page_table[1024];
20669-
20670 static inline void pgtable_cache_init(void) { }
20671 static inline void check_pgt_cache(void) { }
20672 void paging_init(void);
20673@@ -45,6 +42,12 @@ void paging_init(void);
20674 # include <asm/pgtable-2level.h>
20675 #endif
20676
20677+extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
20678+extern pgd_t initial_page_table[PTRS_PER_PGD];
20679+#ifdef CONFIG_X86_PAE
20680+extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
20681+#endif
20682+
20683 #if defined(CONFIG_HIGHPTE)
20684 #define pte_offset_map(dir, address) \
20685 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
20686@@ -59,12 +62,17 @@ void paging_init(void);
20687 /* Clear a kernel PTE and flush it from the TLB */
20688 #define kpte_clear_flush(ptep, vaddr) \
20689 do { \
20690+ pax_open_kernel(); \
20691 pte_clear(&init_mm, (vaddr), (ptep)); \
20692+ pax_close_kernel(); \
20693 __flush_tlb_one((vaddr)); \
20694 } while (0)
20695
20696 #endif /* !__ASSEMBLY__ */
20697
20698+#define HAVE_ARCH_UNMAPPED_AREA
20699+#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
20700+
20701 /*
20702 * kern_addr_valid() is (1) for FLATMEM and (0) for
20703 * SPARSEMEM and DISCONTIGMEM
20704diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
20705index 9fb2f2b..8e18c70 100644
20706--- a/arch/x86/include/asm/pgtable_32_types.h
20707+++ b/arch/x86/include/asm/pgtable_32_types.h
20708@@ -8,7 +8,7 @@
20709 */
20710 #ifdef CONFIG_X86_PAE
20711 # include <asm/pgtable-3level_types.h>
20712-# define PMD_SIZE (1UL << PMD_SHIFT)
20713+# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
20714 # define PMD_MASK (~(PMD_SIZE - 1))
20715 #else
20716 # include <asm/pgtable-2level_types.h>
20717@@ -46,6 +46,28 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
20718 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
20719 #endif
20720
20721+#ifdef CONFIG_PAX_KERNEXEC
20722+#ifndef __ASSEMBLY__
20723+extern unsigned char MODULES_EXEC_VADDR[];
20724+extern unsigned char MODULES_EXEC_END[];
20725+
20726+extern unsigned char __LOAD_PHYSICAL_ADDR[];
20727+#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
20728+static inline unsigned long __intentional_overflow(-1) ktla_ktva(unsigned long addr)
20729+{
20730+ return addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET;
20731+
20732+}
20733+static inline unsigned long __intentional_overflow(-1) ktva_ktla(unsigned long addr)
20734+{
20735+ return addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET;
20736+}
20737+#endif
20738+#else
20739+#define ktla_ktva(addr) (addr)
20740+#define ktva_ktla(addr) (addr)
20741+#endif
20742+
20743 #define MODULES_VADDR VMALLOC_START
20744 #define MODULES_END VMALLOC_END
20745 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
20746diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
20747index 2ee7811..afd76c0 100644
20748--- a/arch/x86/include/asm/pgtable_64.h
20749+++ b/arch/x86/include/asm/pgtable_64.h
20750@@ -16,11 +16,17 @@
20751
20752 extern pud_t level3_kernel_pgt[512];
20753 extern pud_t level3_ident_pgt[512];
20754+extern pud_t level3_vmalloc_start_pgt[512];
20755+extern pud_t level3_vmalloc_end_pgt[512];
20756+extern pud_t level3_vmemmap_pgt[512];
20757+extern pud_t level2_vmemmap_pgt[512];
20758 extern pmd_t level2_kernel_pgt[512];
20759 extern pmd_t level2_fixmap_pgt[512];
20760-extern pmd_t level2_ident_pgt[512];
20761-extern pte_t level1_fixmap_pgt[512];
20762-extern pgd_t init_level4_pgt[];
20763+extern pmd_t level2_ident_pgt[2][512];
20764+extern pte_t level1_modules_pgt[4][512];
20765+extern pte_t level1_fixmap_pgt[3][512];
20766+extern pte_t level1_vsyscall_pgt[512];
20767+extern pgd_t init_level4_pgt[512];
20768
20769 #define swapper_pg_dir init_level4_pgt
20770
20771@@ -62,7 +68,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
20772
20773 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
20774 {
20775+ pax_open_kernel();
20776 *pmdp = pmd;
20777+ pax_close_kernel();
20778 }
20779
20780 static inline void native_pmd_clear(pmd_t *pmd)
20781@@ -98,7 +106,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
20782
20783 static inline void native_set_pud(pud_t *pudp, pud_t pud)
20784 {
20785+ pax_open_kernel();
20786 *pudp = pud;
20787+ pax_close_kernel();
20788 }
20789
20790 static inline void native_pud_clear(pud_t *pud)
20791@@ -108,6 +118,13 @@ static inline void native_pud_clear(pud_t *pud)
20792
20793 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
20794 {
20795+ pax_open_kernel();
20796+ *pgdp = pgd;
20797+ pax_close_kernel();
20798+}
20799+
20800+static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
20801+{
20802 *pgdp = pgd;
20803 }
20804
20805diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
20806index e6844df..432b56e 100644
20807--- a/arch/x86/include/asm/pgtable_64_types.h
20808+++ b/arch/x86/include/asm/pgtable_64_types.h
20809@@ -60,11 +60,16 @@ typedef struct { pteval_t pte; } pte_t;
20810 #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
20811 #define MODULES_END _AC(0xffffffffff000000, UL)
20812 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
20813+#define MODULES_EXEC_VADDR MODULES_VADDR
20814+#define MODULES_EXEC_END MODULES_END
20815 #define ESPFIX_PGD_ENTRY _AC(-2, UL)
20816 #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
20817 #define EFI_VA_START ( -4 * (_AC(1, UL) << 30))
20818 #define EFI_VA_END (-68 * (_AC(1, UL) << 30))
20819
20820+#define ktla_ktva(addr) (addr)
20821+#define ktva_ktla(addr) (addr)
20822+
20823 #define EARLY_DYNAMIC_PAGE_TABLES 64
20824
20825 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
20826diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
20827index 13f310b..f0ef42e 100644
20828--- a/arch/x86/include/asm/pgtable_types.h
20829+++ b/arch/x86/include/asm/pgtable_types.h
20830@@ -85,8 +85,10 @@
20831
20832 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
20833 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
20834-#else
20835+#elif defined(CONFIG_KMEMCHECK) || defined(CONFIG_MEM_SOFT_DIRTY)
20836 #define _PAGE_NX (_AT(pteval_t, 0))
20837+#else
20838+#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
20839 #endif
20840
20841 #define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE)
20842@@ -141,6 +143,9 @@ enum page_cache_mode {
20843 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
20844 _PAGE_ACCESSED)
20845
20846+#define PAGE_READONLY_NOEXEC PAGE_READONLY
20847+#define PAGE_SHARED_NOEXEC PAGE_SHARED
20848+
20849 #define __PAGE_KERNEL_EXEC \
20850 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
20851 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
20852@@ -148,7 +153,7 @@ enum page_cache_mode {
20853 #define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW)
20854 #define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW)
20855 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_NOCACHE)
20856-#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
20857+#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
20858 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
20859 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
20860 #define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE)
20861@@ -194,7 +199,7 @@ enum page_cache_mode {
20862 #ifdef CONFIG_X86_64
20863 #define __PAGE_KERNEL_IDENT_LARGE_EXEC __PAGE_KERNEL_LARGE_EXEC
20864 #else
20865-#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
20866+#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
20867 #define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
20868 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
20869 #endif
20870@@ -233,7 +238,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
20871 {
20872 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
20873 }
20874+#endif
20875
20876+#if CONFIG_PGTABLE_LEVELS == 3
20877+#include <asm-generic/pgtable-nopud.h>
20878+#endif
20879+
20880+#if CONFIG_PGTABLE_LEVELS == 2
20881+#include <asm-generic/pgtable-nopmd.h>
20882+#endif
20883+
20884+#ifndef __ASSEMBLY__
20885 #if CONFIG_PGTABLE_LEVELS > 3
20886 typedef struct { pudval_t pud; } pud_t;
20887
20888@@ -247,8 +262,6 @@ static inline pudval_t native_pud_val(pud_t pud)
20889 return pud.pud;
20890 }
20891 #else
20892-#include <asm-generic/pgtable-nopud.h>
20893-
20894 static inline pudval_t native_pud_val(pud_t pud)
20895 {
20896 return native_pgd_val(pud.pgd);
20897@@ -268,8 +281,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
20898 return pmd.pmd;
20899 }
20900 #else
20901-#include <asm-generic/pgtable-nopmd.h>
20902-
20903 static inline pmdval_t native_pmd_val(pmd_t pmd)
20904 {
20905 return native_pgd_val(pmd.pud.pgd);
20906@@ -362,7 +373,6 @@ typedef struct page *pgtable_t;
20907
20908 extern pteval_t __supported_pte_mask;
20909 extern void set_nx(void);
20910-extern int nx_enabled;
20911
20912 #define pgprot_writecombine pgprot_writecombine
20913 extern pgprot_t pgprot_writecombine(pgprot_t prot);
20914diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h
20915index b12f810..aedcc13 100644
20916--- a/arch/x86/include/asm/preempt.h
20917+++ b/arch/x86/include/asm/preempt.h
20918@@ -84,7 +84,7 @@ static __always_inline void __preempt_count_sub(int val)
20919 */
20920 static __always_inline bool __preempt_count_dec_and_test(void)
20921 {
20922- GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), "e");
20923+ GEN_UNARY_RMWcc("decl", "incl", __preempt_count, __percpu_arg(0), "e");
20924 }
20925
20926 /*
20927diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
20928index 944f178..12f1c25 100644
20929--- a/arch/x86/include/asm/processor.h
20930+++ b/arch/x86/include/asm/processor.h
20931@@ -136,7 +136,7 @@ struct cpuinfo_x86 {
20932 /* Index into per_cpu list: */
20933 u16 cpu_index;
20934 u32 microcode;
20935-};
20936+} __randomize_layout;
20937
20938 #define X86_VENDOR_INTEL 0
20939 #define X86_VENDOR_CYRIX 1
20940@@ -206,9 +206,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
20941 : "memory");
20942 }
20943
20944+/* invpcid (%rdx),%rax */
20945+#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
20946+
20947+#define INVPCID_SINGLE_ADDRESS 0UL
20948+#define INVPCID_SINGLE_CONTEXT 1UL
20949+#define INVPCID_ALL_GLOBAL 2UL
20950+#define INVPCID_ALL_NONGLOBAL 3UL
20951+
20952+#define PCID_KERNEL 0UL
20953+#define PCID_USER 1UL
20954+#define PCID_NOFLUSH (1UL << 63)
20955+
20956 static inline void load_cr3(pgd_t *pgdir)
20957 {
20958- write_cr3(__pa(pgdir));
20959+ write_cr3(__pa(pgdir) | PCID_KERNEL);
20960 }
20961
20962 #ifdef CONFIG_X86_32
20963@@ -305,11 +317,9 @@ struct tss_struct {
20964
20965 } ____cacheline_aligned;
20966
20967-DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss);
20968+extern struct tss_struct cpu_tss[NR_CPUS];
20969
20970-#ifdef CONFIG_X86_32
20971 DECLARE_PER_CPU(unsigned long, cpu_current_top_of_stack);
20972-#endif
20973
20974 /*
20975 * Save the original ist values for checking stack pointers during debugging
20976@@ -381,6 +391,7 @@ struct thread_struct {
20977 unsigned short ds;
20978 unsigned short fsindex;
20979 unsigned short gsindex;
20980+ unsigned short ss;
20981 #endif
20982 #ifdef CONFIG_X86_32
20983 unsigned long ip;
20984@@ -463,10 +474,10 @@ static inline void native_swapgs(void)
20985 #endif
20986 }
20987
20988-static inline unsigned long current_top_of_stack(void)
20989+static inline unsigned long current_top_of_stack(unsigned int cpu)
20990 {
20991 #ifdef CONFIG_X86_64
20992- return this_cpu_read_stable(cpu_tss.x86_tss.sp0);
20993+ return cpu_tss[cpu].x86_tss.sp0;
20994 #else
20995 /* sp0 on x86_32 is special in and around vm86 mode. */
20996 return this_cpu_read_stable(cpu_current_top_of_stack);
20997@@ -709,20 +720,30 @@ static inline void spin_lock_prefetch(const void *x)
20998 #define TOP_OF_INIT_STACK ((unsigned long)&init_stack + sizeof(init_stack) - \
20999 TOP_OF_KERNEL_STACK_PADDING)
21000
21001+extern union fpregs_state init_fpregs_state;
21002+
21003 #ifdef CONFIG_X86_32
21004 /*
21005 * User space process size: 3GB (default).
21006 */
21007 #define TASK_SIZE PAGE_OFFSET
21008 #define TASK_SIZE_MAX TASK_SIZE
21009+
21010+#ifdef CONFIG_PAX_SEGMEXEC
21011+#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
21012+#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
21013+#else
21014 #define STACK_TOP TASK_SIZE
21015-#define STACK_TOP_MAX STACK_TOP
21016+#endif
21017+
21018+#define STACK_TOP_MAX TASK_SIZE
21019
21020 #define INIT_THREAD { \
21021 .sp0 = TOP_OF_INIT_STACK, \
21022 .vm86_info = NULL, \
21023 .sysenter_cs = __KERNEL_CS, \
21024 .io_bitmap_ptr = NULL, \
21025+ .fpu.state = &init_fpregs_state, \
21026 }
21027
21028 extern unsigned long thread_saved_pc(struct task_struct *tsk);
21029@@ -737,12 +758,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
21030 * "struct pt_regs" is possible, but they may contain the
21031 * completely wrong values.
21032 */
21033-#define task_pt_regs(task) \
21034-({ \
21035- unsigned long __ptr = (unsigned long)task_stack_page(task); \
21036- __ptr += THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING; \
21037- ((struct pt_regs *)__ptr) - 1; \
21038-})
21039+#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)
21040
21041 #define KSTK_ESP(task) (task_pt_regs(task)->sp)
21042
21043@@ -756,13 +772,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
21044 * particular problem by preventing anything from being mapped
21045 * at the maximum canonical address.
21046 */
21047-#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
21048+#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
21049
21050 /* This decides where the kernel will search for a free chunk of vm
21051 * space during mmap's.
21052 */
21053 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
21054- 0xc0000000 : 0xFFFFe000)
21055+ 0xc0000000 : 0xFFFFf000)
21056
21057 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
21058 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
21059@@ -773,7 +789,8 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
21060 #define STACK_TOP_MAX TASK_SIZE_MAX
21061
21062 #define INIT_THREAD { \
21063- .sp0 = TOP_OF_INIT_STACK \
21064+ .sp0 = TOP_OF_INIT_STACK, \
21065+ .fpu.state = &init_fpregs_state, \
21066 }
21067
21068 /*
21069@@ -796,6 +813,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
21070 */
21071 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
21072
21073+#ifdef CONFIG_PAX_SEGMEXEC
21074+#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
21075+#endif
21076+
21077 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
21078
21079 /* Get/set a process' ability to use the timestamp counter instruction */
21080@@ -841,7 +862,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
21081 return 0;
21082 }
21083
21084-extern unsigned long arch_align_stack(unsigned long sp);
21085+#define arch_align_stack(x) ((x) & ~0xfUL)
21086 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
21087
21088 void default_idle(void);
21089@@ -851,6 +872,6 @@ bool xen_set_default_idle(void);
21090 #define xen_set_default_idle 0
21091 #endif
21092
21093-void stop_this_cpu(void *dummy);
21094+void stop_this_cpu(void *dummy) __noreturn;
21095 void df_debug(struct pt_regs *regs, long error_code);
21096 #endif /* _ASM_X86_PROCESSOR_H */
21097diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
21098index 5fabf13..7388158 100644
21099--- a/arch/x86/include/asm/ptrace.h
21100+++ b/arch/x86/include/asm/ptrace.h
21101@@ -125,15 +125,16 @@ static inline int v8086_mode(struct pt_regs *regs)
21102 #ifdef CONFIG_X86_64
21103 static inline bool user_64bit_mode(struct pt_regs *regs)
21104 {
21105+ unsigned long cs = regs->cs & 0xffff;
21106 #ifndef CONFIG_PARAVIRT
21107 /*
21108 * On non-paravirt systems, this is the only long mode CPL 3
21109 * selector. We do not allow long mode selectors in the LDT.
21110 */
21111- return regs->cs == __USER_CS;
21112+ return cs == __USER_CS;
21113 #else
21114 /* Headers are too twisted for this to go in paravirt.h. */
21115- return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
21116+ return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
21117 #endif
21118 }
21119
21120@@ -180,9 +181,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
21121 * Traps from the kernel do not save sp and ss.
21122 * Use the helper function to retrieve sp.
21123 */
21124- if (offset == offsetof(struct pt_regs, sp) &&
21125- regs->cs == __KERNEL_CS)
21126- return kernel_stack_pointer(regs);
21127+ if (offset == offsetof(struct pt_regs, sp)) {
21128+ unsigned long cs = regs->cs & 0xffff;
21129+ if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
21130+ return kernel_stack_pointer(regs);
21131+ }
21132 #endif
21133 return *(unsigned long *)((unsigned long)regs + offset);
21134 }
21135diff --git a/arch/x86/include/asm/qrwlock.h b/arch/x86/include/asm/qrwlock.h
21136index ae0e241..e80b10b 100644
21137--- a/arch/x86/include/asm/qrwlock.h
21138+++ b/arch/x86/include/asm/qrwlock.h
21139@@ -7,8 +7,8 @@
21140 #define queue_write_unlock queue_write_unlock
21141 static inline void queue_write_unlock(struct qrwlock *lock)
21142 {
21143- barrier();
21144- ACCESS_ONCE(*(u8 *)&lock->cnts) = 0;
21145+ barrier();
21146+ ACCESS_ONCE_RW(*(u8 *)&lock->cnts) = 0;
21147 }
21148 #endif
21149
21150diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
21151index 9c6b890..5305f53 100644
21152--- a/arch/x86/include/asm/realmode.h
21153+++ b/arch/x86/include/asm/realmode.h
21154@@ -22,16 +22,14 @@ struct real_mode_header {
21155 #endif
21156 /* APM/BIOS reboot */
21157 u32 machine_real_restart_asm;
21158-#ifdef CONFIG_X86_64
21159 u32 machine_real_restart_seg;
21160-#endif
21161 };
21162
21163 /* This must match data at trampoline_32/64.S */
21164 struct trampoline_header {
21165 #ifdef CONFIG_X86_32
21166 u32 start;
21167- u16 gdt_pad;
21168+ u16 boot_cs;
21169 u16 gdt_limit;
21170 u32 gdt_base;
21171 #else
21172diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
21173index a82c4f1..ac45053 100644
21174--- a/arch/x86/include/asm/reboot.h
21175+++ b/arch/x86/include/asm/reboot.h
21176@@ -6,13 +6,13 @@
21177 struct pt_regs;
21178
21179 struct machine_ops {
21180- void (*restart)(char *cmd);
21181- void (*halt)(void);
21182- void (*power_off)(void);
21183+ void (* __noreturn restart)(char *cmd);
21184+ void (* __noreturn halt)(void);
21185+ void (* __noreturn power_off)(void);
21186 void (*shutdown)(void);
21187 void (*crash_shutdown)(struct pt_regs *);
21188- void (*emergency_restart)(void);
21189-};
21190+ void (* __noreturn emergency_restart)(void);
21191+} __no_const;
21192
21193 extern struct machine_ops machine_ops;
21194
21195diff --git a/arch/x86/include/asm/rmwcc.h b/arch/x86/include/asm/rmwcc.h
21196index 8f7866a..e442f20 100644
21197--- a/arch/x86/include/asm/rmwcc.h
21198+++ b/arch/x86/include/asm/rmwcc.h
21199@@ -3,7 +3,34 @@
21200
21201 #ifdef CC_HAVE_ASM_GOTO
21202
21203-#define __GEN_RMWcc(fullop, var, cc, ...) \
21204+#ifdef CONFIG_PAX_REFCOUNT
21205+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
21206+do { \
21207+ asm_volatile_goto (fullop \
21208+ ";jno 0f\n" \
21209+ fullantiop \
21210+ ";int $4\n0:\n" \
21211+ _ASM_EXTABLE(0b, 0b) \
21212+ ";j" cc " %l[cc_label]" \
21213+ : : "m" (var), ## __VA_ARGS__ \
21214+ : "memory" : cc_label); \
21215+ return 0; \
21216+cc_label: \
21217+ return 1; \
21218+} while (0)
21219+#else
21220+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
21221+do { \
21222+ asm_volatile_goto (fullop ";j" cc " %l[cc_label]" \
21223+ : : "m" (var), ## __VA_ARGS__ \
21224+ : "memory" : cc_label); \
21225+ return 0; \
21226+cc_label: \
21227+ return 1; \
21228+} while (0)
21229+#endif
21230+
21231+#define __GEN_RMWcc_unchecked(fullop, var, cc, ...) \
21232 do { \
21233 asm_volatile_goto (fullop "; j" cc " %l[cc_label]" \
21234 : : "m" (var), ## __VA_ARGS__ \
21235@@ -13,15 +40,46 @@ cc_label: \
21236 return 1; \
21237 } while (0)
21238
21239-#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
21240- __GEN_RMWcc(op " " arg0, var, cc)
21241+#define GEN_UNARY_RMWcc(op, antiop, var, arg0, cc) \
21242+ __GEN_RMWcc(op " " arg0, antiop " " arg0, var, cc)
21243
21244-#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
21245- __GEN_RMWcc(op " %1, " arg0, var, cc, vcon (val))
21246+#define GEN_UNARY_RMWcc_unchecked(op, var, arg0, cc) \
21247+ __GEN_RMWcc_unchecked(op " " arg0, var, cc)
21248+
21249+#define GEN_BINARY_RMWcc(op, antiop, var, vcon, val, arg0, cc) \
21250+ __GEN_RMWcc(op " %1, " arg0, antiop " %1, " arg0, var, cc, vcon (val))
21251+
21252+#define GEN_BINARY_RMWcc_unchecked(op, var, vcon, val, arg0, cc) \
21253+ __GEN_RMWcc_unchecked(op " %1, " arg0, var, cc, vcon (val))
21254
21255 #else /* !CC_HAVE_ASM_GOTO */
21256
21257-#define __GEN_RMWcc(fullop, var, cc, ...) \
21258+#ifdef CONFIG_PAX_REFCOUNT
21259+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
21260+do { \
21261+ char c; \
21262+ asm volatile (fullop \
21263+ ";jno 0f\n" \
21264+ fullantiop \
21265+ ";int $4\n0:\n" \
21266+ _ASM_EXTABLE(0b, 0b) \
21267+ "; set" cc " %1" \
21268+ : "+m" (var), "=qm" (c) \
21269+ : __VA_ARGS__ : "memory"); \
21270+ return c != 0; \
21271+} while (0)
21272+#else
21273+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
21274+do { \
21275+ char c; \
21276+ asm volatile (fullop "; set" cc " %1" \
21277+ : "+m" (var), "=qm" (c) \
21278+ : __VA_ARGS__ : "memory"); \
21279+ return c != 0; \
21280+} while (0)
21281+#endif
21282+
21283+#define __GEN_RMWcc_unchecked(fullop, var, cc, ...) \
21284 do { \
21285 char c; \
21286 asm volatile (fullop "; set" cc " %1" \
21287@@ -30,11 +88,17 @@ do { \
21288 return c != 0; \
21289 } while (0)
21290
21291-#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
21292- __GEN_RMWcc(op " " arg0, var, cc)
21293+#define GEN_UNARY_RMWcc(op, antiop, var, arg0, cc) \
21294+ __GEN_RMWcc(op " " arg0, antiop " " arg0, var, cc)
21295+
21296+#define GEN_UNARY_RMWcc_unchecked(op, var, arg0, cc) \
21297+ __GEN_RMWcc_unchecked(op " " arg0, var, cc)
21298+
21299+#define GEN_BINARY_RMWcc(op, antiop, var, vcon, val, arg0, cc) \
21300+ __GEN_RMWcc(op " %2, " arg0, antiop " %2, " arg0, var, cc, vcon (val))
21301
21302-#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
21303- __GEN_RMWcc(op " %2, " arg0, var, cc, vcon (val))
21304+#define GEN_BINARY_RMWcc_unchecked(op, var, vcon, val, arg0, cc) \
21305+ __GEN_RMWcc_unchecked(op " %2, " arg0, var, cc, vcon (val))
21306
21307 #endif /* CC_HAVE_ASM_GOTO */
21308
21309diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
21310index cad82c9..2e5c5c1 100644
21311--- a/arch/x86/include/asm/rwsem.h
21312+++ b/arch/x86/include/asm/rwsem.h
21313@@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
21314 {
21315 asm volatile("# beginning down_read\n\t"
21316 LOCK_PREFIX _ASM_INC "(%1)\n\t"
21317+
21318+#ifdef CONFIG_PAX_REFCOUNT
21319+ "jno 0f\n"
21320+ LOCK_PREFIX _ASM_DEC "(%1)\n"
21321+ "int $4\n0:\n"
21322+ _ASM_EXTABLE(0b, 0b)
21323+#endif
21324+
21325 /* adds 0x00000001 */
21326 " jns 1f\n"
21327 " call call_rwsem_down_read_failed\n"
21328@@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
21329 "1:\n\t"
21330 " mov %1,%2\n\t"
21331 " add %3,%2\n\t"
21332+
21333+#ifdef CONFIG_PAX_REFCOUNT
21334+ "jno 0f\n"
21335+ "sub %3,%2\n"
21336+ "int $4\n0:\n"
21337+ _ASM_EXTABLE(0b, 0b)
21338+#endif
21339+
21340 " jle 2f\n\t"
21341 LOCK_PREFIX " cmpxchg %2,%0\n\t"
21342 " jnz 1b\n\t"
21343@@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
21344 long tmp;
21345 asm volatile("# beginning down_write\n\t"
21346 LOCK_PREFIX " xadd %1,(%2)\n\t"
21347+
21348+#ifdef CONFIG_PAX_REFCOUNT
21349+ "jno 0f\n"
21350+ "mov %1,(%2)\n"
21351+ "int $4\n0:\n"
21352+ _ASM_EXTABLE(0b, 0b)
21353+#endif
21354+
21355 /* adds 0xffff0001, returns the old value */
21356 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
21357 /* was the active mask 0 before? */
21358@@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
21359 long tmp;
21360 asm volatile("# beginning __up_read\n\t"
21361 LOCK_PREFIX " xadd %1,(%2)\n\t"
21362+
21363+#ifdef CONFIG_PAX_REFCOUNT
21364+ "jno 0f\n"
21365+ "mov %1,(%2)\n"
21366+ "int $4\n0:\n"
21367+ _ASM_EXTABLE(0b, 0b)
21368+#endif
21369+
21370 /* subtracts 1, returns the old value */
21371 " jns 1f\n\t"
21372 " call call_rwsem_wake\n" /* expects old value in %edx */
21373@@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
21374 long tmp;
21375 asm volatile("# beginning __up_write\n\t"
21376 LOCK_PREFIX " xadd %1,(%2)\n\t"
21377+
21378+#ifdef CONFIG_PAX_REFCOUNT
21379+ "jno 0f\n"
21380+ "mov %1,(%2)\n"
21381+ "int $4\n0:\n"
21382+ _ASM_EXTABLE(0b, 0b)
21383+#endif
21384+
21385 /* subtracts 0xffff0001, returns the old value */
21386 " jns 1f\n\t"
21387 " call call_rwsem_wake\n" /* expects old value in %edx */
21388@@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
21389 {
21390 asm volatile("# beginning __downgrade_write\n\t"
21391 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
21392+
21393+#ifdef CONFIG_PAX_REFCOUNT
21394+ "jno 0f\n"
21395+ LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
21396+ "int $4\n0:\n"
21397+ _ASM_EXTABLE(0b, 0b)
21398+#endif
21399+
21400 /*
21401 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
21402 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
21403@@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
21404 */
21405 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
21406 {
21407- asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
21408+ asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
21409+
21410+#ifdef CONFIG_PAX_REFCOUNT
21411+ "jno 0f\n"
21412+ LOCK_PREFIX _ASM_SUB "%1,%0\n"
21413+ "int $4\n0:\n"
21414+ _ASM_EXTABLE(0b, 0b)
21415+#endif
21416+
21417 : "+m" (sem->count)
21418 : "er" (delta));
21419 }
21420@@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
21421 */
21422 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
21423 {
21424- return delta + xadd(&sem->count, delta);
21425+ return delta + xadd_check_overflow(&sem->count, delta);
21426 }
21427
21428 #endif /* __KERNEL__ */
21429diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
21430index 7d5a192..23ef1aa 100644
21431--- a/arch/x86/include/asm/segment.h
21432+++ b/arch/x86/include/asm/segment.h
21433@@ -82,14 +82,20 @@
21434 * 26 - ESPFIX small SS
21435 * 27 - per-cpu [ offset to per-cpu data area ]
21436 * 28 - stack_canary-20 [ for stack protector ] <=== cacheline #8
21437- * 29 - unused
21438- * 30 - unused
21439+ * 29 - PCI BIOS CS
21440+ * 30 - PCI BIOS DS
21441 * 31 - TSS for double fault handler
21442 */
21443+#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
21444+#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
21445+#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
21446+#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
21447+
21448 #define GDT_ENTRY_TLS_MIN 6
21449 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
21450
21451 #define GDT_ENTRY_KERNEL_CS 12
21452+#define GDT_ENTRY_KERNEXEC_KERNEL_CS 4
21453 #define GDT_ENTRY_KERNEL_DS 13
21454 #define GDT_ENTRY_DEFAULT_USER_CS 14
21455 #define GDT_ENTRY_DEFAULT_USER_DS 15
21456@@ -106,6 +112,12 @@
21457 #define GDT_ENTRY_PERCPU 27
21458 #define GDT_ENTRY_STACK_CANARY 28
21459
21460+#define GDT_ENTRY_PCIBIOS_CS 29
21461+#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
21462+
21463+#define GDT_ENTRY_PCIBIOS_DS 30
21464+#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
21465+
21466 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
21467
21468 /*
21469@@ -118,6 +130,7 @@
21470 */
21471
21472 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
21473+#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
21474 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
21475 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3)
21476 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8 + 3)
21477@@ -129,7 +142,7 @@
21478 #define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16*8)
21479
21480 /* "Is this PNP code selector (PNP_CS32 or PNP_CS16)?" */
21481-#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == PNP_CS32)
21482+#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
21483
21484 /* data segment for BIOS: */
21485 #define PNP_DS (GDT_ENTRY_PNPBIOS_DS*8)
21486@@ -176,6 +189,8 @@
21487 #define GDT_ENTRY_DEFAULT_USER_DS 5
21488 #define GDT_ENTRY_DEFAULT_USER_CS 6
21489
21490+#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
21491+
21492 /* Needs two entries */
21493 #define GDT_ENTRY_TSS 8
21494 /* Needs two entries */
21495@@ -187,10 +202,12 @@
21496 /* Abused to load per CPU data from limit */
21497 #define GDT_ENTRY_PER_CPU 15
21498
21499+#define GDT_ENTRY_UDEREF_KERNEL_DS 16
21500+
21501 /*
21502 * Number of entries in the GDT table:
21503 */
21504-#define GDT_ENTRIES 16
21505+#define GDT_ENTRIES 17
21506
21507 /*
21508 * Segment selector values corresponding to the above entries:
21509@@ -200,7 +217,9 @@
21510 */
21511 #define __KERNEL32_CS (GDT_ENTRY_KERNEL32_CS*8)
21512 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
21513+#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
21514 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
21515+#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
21516 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8 + 3)
21517 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3)
21518 #define __USER32_DS __USER_DS
21519diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
21520index ba665eb..0f72938 100644
21521--- a/arch/x86/include/asm/smap.h
21522+++ b/arch/x86/include/asm/smap.h
21523@@ -25,6 +25,18 @@
21524
21525 #include <asm/alternative-asm.h>
21526
21527+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21528+#define ASM_PAX_OPEN_USERLAND \
21529+ ALTERNATIVE "", "call __pax_open_userland", X86_FEATURE_STRONGUDEREF
21530+
21531+#define ASM_PAX_CLOSE_USERLAND \
21532+ ALTERNATIVE "", "call __pax_close_userland", X86_FEATURE_STRONGUDEREF
21533+
21534+#else
21535+#define ASM_PAX_OPEN_USERLAND
21536+#define ASM_PAX_CLOSE_USERLAND
21537+#endif
21538+
21539 #ifdef CONFIG_X86_SMAP
21540
21541 #define ASM_CLAC \
21542@@ -44,6 +56,37 @@
21543
21544 #include <asm/alternative.h>
21545
21546+#define __HAVE_ARCH_PAX_OPEN_USERLAND
21547+#define __HAVE_ARCH_PAX_CLOSE_USERLAND
21548+
21549+extern void __pax_open_userland(void);
21550+static __always_inline unsigned long pax_open_userland(void)
21551+{
21552+
21553+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21554+ asm volatile(ALTERNATIVE("", "call %P[open]", X86_FEATURE_STRONGUDEREF)
21555+ :
21556+ : [open] "i" (__pax_open_userland)
21557+ : "memory", "rax");
21558+#endif
21559+
21560+ return 0;
21561+}
21562+
21563+extern void __pax_close_userland(void);
21564+static __always_inline unsigned long pax_close_userland(void)
21565+{
21566+
21567+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21568+ asm volatile(ALTERNATIVE("", "call %P[close]", X86_FEATURE_STRONGUDEREF)
21569+ :
21570+ : [close] "i" (__pax_close_userland)
21571+ : "memory", "rax");
21572+#endif
21573+
21574+ return 0;
21575+}
21576+
21577 #ifdef CONFIG_X86_SMAP
21578
21579 static __always_inline void clac(void)
21580diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
21581index 222a6a3..839da8d 100644
21582--- a/arch/x86/include/asm/smp.h
21583+++ b/arch/x86/include/asm/smp.h
21584@@ -35,7 +35,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
21585 /* cpus sharing the last level cache: */
21586 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
21587 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
21588-DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
21589+DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
21590
21591 static inline struct cpumask *cpu_llc_shared_mask(int cpu)
21592 {
21593@@ -68,7 +68,7 @@ struct smp_ops {
21594
21595 void (*send_call_func_ipi)(const struct cpumask *mask);
21596 void (*send_call_func_single_ipi)(int cpu);
21597-};
21598+} __no_const;
21599
21600 /* Globals due to paravirt */
21601 extern void set_cpu_sibling_map(int cpu);
21602@@ -182,14 +182,8 @@ extern unsigned disabled_cpus;
21603 extern int safe_smp_processor_id(void);
21604
21605 #elif defined(CONFIG_X86_64_SMP)
21606-#define raw_smp_processor_id() (this_cpu_read(cpu_number))
21607-
21608-#define stack_smp_processor_id() \
21609-({ \
21610- struct thread_info *ti; \
21611- __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
21612- ti->cpu; \
21613-})
21614+#define raw_smp_processor_id() (this_cpu_read(cpu_number))
21615+#define stack_smp_processor_id() raw_smp_processor_id()
21616 #define safe_smp_processor_id() smp_processor_id()
21617
21618 #endif
21619diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
21620index c2e00bb..a10266e 100644
21621--- a/arch/x86/include/asm/stackprotector.h
21622+++ b/arch/x86/include/asm/stackprotector.h
21623@@ -49,7 +49,7 @@
21624 * head_32 for boot CPU and setup_per_cpu_areas() for others.
21625 */
21626 #define GDT_STACK_CANARY_INIT \
21627- [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
21628+ [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
21629
21630 /*
21631 * Initialize the stackprotector canary value.
21632@@ -114,7 +114,7 @@ static inline void setup_stack_canary_segment(int cpu)
21633
21634 static inline void load_stack_canary_segment(void)
21635 {
21636-#ifdef CONFIG_X86_32
21637+#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
21638 asm volatile ("mov %0, %%gs" : : "r" (0));
21639 #endif
21640 }
21641diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
21642index 70bbe39..4ae2bd4 100644
21643--- a/arch/x86/include/asm/stacktrace.h
21644+++ b/arch/x86/include/asm/stacktrace.h
21645@@ -11,28 +11,20 @@
21646
21647 extern int kstack_depth_to_print;
21648
21649-struct thread_info;
21650+struct task_struct;
21651 struct stacktrace_ops;
21652
21653-typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
21654- unsigned long *stack,
21655- unsigned long bp,
21656- const struct stacktrace_ops *ops,
21657- void *data,
21658- unsigned long *end,
21659- int *graph);
21660+typedef unsigned long walk_stack_t(struct task_struct *task,
21661+ void *stack_start,
21662+ unsigned long *stack,
21663+ unsigned long bp,
21664+ const struct stacktrace_ops *ops,
21665+ void *data,
21666+ unsigned long *end,
21667+ int *graph);
21668
21669-extern unsigned long
21670-print_context_stack(struct thread_info *tinfo,
21671- unsigned long *stack, unsigned long bp,
21672- const struct stacktrace_ops *ops, void *data,
21673- unsigned long *end, int *graph);
21674-
21675-extern unsigned long
21676-print_context_stack_bp(struct thread_info *tinfo,
21677- unsigned long *stack, unsigned long bp,
21678- const struct stacktrace_ops *ops, void *data,
21679- unsigned long *end, int *graph);
21680+extern walk_stack_t print_context_stack;
21681+extern walk_stack_t print_context_stack_bp;
21682
21683 /* Generic stack tracer with callbacks */
21684
21685@@ -40,7 +32,7 @@ struct stacktrace_ops {
21686 void (*address)(void *data, unsigned long address, int reliable);
21687 /* On negative return stop dumping */
21688 int (*stack)(void *data, char *name);
21689- walk_stack_t walk_stack;
21690+ walk_stack_t *walk_stack;
21691 };
21692
21693 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
21694diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
21695index d7f3b3b..3cc39f1 100644
21696--- a/arch/x86/include/asm/switch_to.h
21697+++ b/arch/x86/include/asm/switch_to.h
21698@@ -108,7 +108,7 @@ do { \
21699 "call __switch_to\n\t" \
21700 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
21701 __switch_canary \
21702- "movq %P[thread_info](%%rsi),%%r8\n\t" \
21703+ "movq "__percpu_arg([thread_info])",%%r8\n\t" \
21704 "movq %%rax,%%rdi\n\t" \
21705 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
21706 "jnz ret_from_fork\n\t" \
21707@@ -119,7 +119,7 @@ do { \
21708 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
21709 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
21710 [_tif_fork] "i" (_TIF_FORK), \
21711- [thread_info] "i" (offsetof(struct task_struct, stack)), \
21712+ [thread_info] "m" (current_tinfo), \
21713 [current_task] "m" (current_task) \
21714 __switch_canary_iparam \
21715 : "memory", "cc" __EXTRA_CLOBBER)
21716diff --git a/arch/x86/include/asm/sys_ia32.h b/arch/x86/include/asm/sys_ia32.h
21717index 82c34ee..940fa40 100644
21718--- a/arch/x86/include/asm/sys_ia32.h
21719+++ b/arch/x86/include/asm/sys_ia32.h
21720@@ -20,8 +20,8 @@
21721 #include <asm/ia32.h>
21722
21723 /* ia32/sys_ia32.c */
21724-asmlinkage long sys32_truncate64(const char __user *, unsigned long, unsigned long);
21725-asmlinkage long sys32_ftruncate64(unsigned int, unsigned long, unsigned long);
21726+asmlinkage long sys32_truncate64(const char __user *, unsigned int, unsigned int);
21727+asmlinkage long sys32_ftruncate64(unsigned int, unsigned int, unsigned int);
21728
21729 asmlinkage long sys32_stat64(const char __user *, struct stat64 __user *);
21730 asmlinkage long sys32_lstat64(const char __user *, struct stat64 __user *);
21731@@ -42,7 +42,7 @@ long sys32_vm86_warning(void);
21732 asmlinkage ssize_t sys32_readahead(int, unsigned, unsigned, size_t);
21733 asmlinkage long sys32_sync_file_range(int, unsigned, unsigned,
21734 unsigned, unsigned, int);
21735-asmlinkage long sys32_fadvise64(int, unsigned, unsigned, size_t, int);
21736+asmlinkage long sys32_fadvise64(int, unsigned, unsigned, int, int);
21737 asmlinkage long sys32_fallocate(int, int, unsigned,
21738 unsigned, unsigned, unsigned);
21739
21740diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
21741index 225ee54..fae4566 100644
21742--- a/arch/x86/include/asm/thread_info.h
21743+++ b/arch/x86/include/asm/thread_info.h
21744@@ -36,7 +36,7 @@
21745 #ifdef CONFIG_X86_32
21746 # define TOP_OF_KERNEL_STACK_PADDING 8
21747 #else
21748-# define TOP_OF_KERNEL_STACK_PADDING 0
21749+# define TOP_OF_KERNEL_STACK_PADDING 16
21750 #endif
21751
21752 /*
21753@@ -50,27 +50,26 @@ struct task_struct;
21754 #include <linux/atomic.h>
21755
21756 struct thread_info {
21757- struct task_struct *task; /* main task structure */
21758 __u32 flags; /* low level flags */
21759 __u32 status; /* thread synchronous flags */
21760 __u32 cpu; /* current CPU */
21761 int saved_preempt_count;
21762 mm_segment_t addr_limit;
21763 void __user *sysenter_return;
21764+ unsigned long lowest_stack;
21765 unsigned int sig_on_uaccess_error:1;
21766 unsigned int uaccess_err:1; /* uaccess failed */
21767 };
21768
21769-#define INIT_THREAD_INFO(tsk) \
21770+#define INIT_THREAD_INFO \
21771 { \
21772- .task = &tsk, \
21773 .flags = 0, \
21774 .cpu = 0, \
21775 .saved_preempt_count = INIT_PREEMPT_COUNT, \
21776 .addr_limit = KERNEL_DS, \
21777 }
21778
21779-#define init_thread_info (init_thread_union.thread_info)
21780+#define init_thread_info (init_thread_union.stack)
21781 #define init_stack (init_thread_union.stack)
21782
21783 #else /* !__ASSEMBLY__ */
21784@@ -110,6 +109,7 @@ struct thread_info {
21785 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
21786 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
21787 #define TIF_X32 30 /* 32-bit native x86-64 binary */
21788+#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
21789
21790 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
21791 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
21792@@ -133,17 +133,18 @@ struct thread_info {
21793 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
21794 #define _TIF_ADDR32 (1 << TIF_ADDR32)
21795 #define _TIF_X32 (1 << TIF_X32)
21796+#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
21797
21798 /* work to do in syscall_trace_enter() */
21799 #define _TIF_WORK_SYSCALL_ENTRY \
21800 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
21801 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
21802- _TIF_NOHZ)
21803+ _TIF_NOHZ | _TIF_GRSEC_SETXID)
21804
21805 /* work to do in syscall_trace_leave() */
21806 #define _TIF_WORK_SYSCALL_EXIT \
21807 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
21808- _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
21809+ _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
21810
21811 /* work to do on interrupt/exception return */
21812 #define _TIF_WORK_MASK \
21813@@ -154,7 +155,7 @@ struct thread_info {
21814 /* work to do on any return to user space */
21815 #define _TIF_ALLWORK_MASK \
21816 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
21817- _TIF_NOHZ)
21818+ _TIF_NOHZ | _TIF_GRSEC_SETXID)
21819
21820 /* Only used for 64 bit */
21821 #define _TIF_DO_NOTIFY_MASK \
21822@@ -177,9 +178,11 @@ struct thread_info {
21823 */
21824 #ifndef __ASSEMBLY__
21825
21826+DECLARE_PER_CPU(struct thread_info *, current_tinfo);
21827+
21828 static inline struct thread_info *current_thread_info(void)
21829 {
21830- return (struct thread_info *)(current_top_of_stack() - THREAD_SIZE);
21831+ return this_cpu_read_stable(current_tinfo);
21832 }
21833
21834 static inline unsigned long current_stack_pointer(void)
21835@@ -195,14 +198,9 @@ static inline unsigned long current_stack_pointer(void)
21836
21837 #else /* !__ASSEMBLY__ */
21838
21839-#ifdef CONFIG_X86_64
21840-# define cpu_current_top_of_stack (cpu_tss + TSS_sp0)
21841-#endif
21842-
21843 /* Load thread_info address into "reg" */
21844 #define GET_THREAD_INFO(reg) \
21845- _ASM_MOV PER_CPU_VAR(cpu_current_top_of_stack),reg ; \
21846- _ASM_SUB $(THREAD_SIZE),reg ;
21847+ _ASM_MOV PER_CPU_VAR(current_tinfo),reg ;
21848
21849 /*
21850 * ASM operand which evaluates to a 'thread_info' address of
21851@@ -295,5 +293,12 @@ static inline bool is_ia32_task(void)
21852 extern void arch_task_cache_init(void);
21853 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
21854 extern void arch_release_task_struct(struct task_struct *tsk);
21855+
21856+#define __HAVE_THREAD_FUNCTIONS
21857+#define task_thread_info(task) (&(task)->tinfo)
21858+#define task_stack_page(task) ((task)->stack)
21859+#define setup_thread_stack(p, org) do {} while (0)
21860+#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
21861+
21862 #endif
21863 #endif /* _ASM_X86_THREAD_INFO_H */
21864diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
21865index cd79194..6a9956f 100644
21866--- a/arch/x86/include/asm/tlbflush.h
21867+++ b/arch/x86/include/asm/tlbflush.h
21868@@ -86,18 +86,44 @@ static inline void cr4_set_bits_and_update_boot(unsigned long mask)
21869
21870 static inline void __native_flush_tlb(void)
21871 {
21872+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
21873+ u64 descriptor[2];
21874+
21875+ descriptor[0] = PCID_KERNEL;
21876+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_NONGLOBAL) : "memory");
21877+ return;
21878+ }
21879+
21880+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21881+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF)) {
21882+ unsigned int cpu = raw_get_cpu();
21883+
21884+ native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
21885+ native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
21886+ raw_put_cpu_no_resched();
21887+ return;
21888+ }
21889+#endif
21890+
21891 native_write_cr3(native_read_cr3());
21892 }
21893
21894 static inline void __native_flush_tlb_global_irq_disabled(void)
21895 {
21896- unsigned long cr4;
21897+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
21898+ u64 descriptor[2];
21899
21900- cr4 = this_cpu_read(cpu_tlbstate.cr4);
21901- /* clear PGE */
21902- native_write_cr4(cr4 & ~X86_CR4_PGE);
21903- /* write old PGE again and flush TLBs */
21904- native_write_cr4(cr4);
21905+ descriptor[0] = PCID_KERNEL;
21906+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
21907+ } else {
21908+ unsigned long cr4;
21909+
21910+ cr4 = this_cpu_read(cpu_tlbstate.cr4);
21911+ /* clear PGE */
21912+ native_write_cr4(cr4 & ~X86_CR4_PGE);
21913+ /* write old PGE again and flush TLBs */
21914+ native_write_cr4(cr4);
21915+ }
21916 }
21917
21918 static inline void __native_flush_tlb_global(void)
21919@@ -118,6 +144,43 @@ static inline void __native_flush_tlb_global(void)
21920
21921 static inline void __native_flush_tlb_single(unsigned long addr)
21922 {
21923+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
21924+ u64 descriptor[2];
21925+
21926+ descriptor[0] = PCID_KERNEL;
21927+ descriptor[1] = addr;
21928+
21929+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21930+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF)) {
21931+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
21932+ if (addr < TASK_SIZE_MAX)
21933+ descriptor[1] += pax_user_shadow_base;
21934+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
21935+ }
21936+
21937+ descriptor[0] = PCID_USER;
21938+ descriptor[1] = addr;
21939+ }
21940+#endif
21941+
21942+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
21943+ return;
21944+ }
21945+
21946+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21947+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF)) {
21948+ unsigned int cpu = raw_get_cpu();
21949+
21950+ native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
21951+ asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
21952+ native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
21953+ raw_put_cpu_no_resched();
21954+
21955+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
21956+ addr += pax_user_shadow_base;
21957+ }
21958+#endif
21959+
21960 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
21961 }
21962
21963diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
21964index a8df874..ef0e34f 100644
21965--- a/arch/x86/include/asm/uaccess.h
21966+++ b/arch/x86/include/asm/uaccess.h
21967@@ -7,6 +7,7 @@
21968 #include <linux/compiler.h>
21969 #include <linux/thread_info.h>
21970 #include <linux/string.h>
21971+#include <linux/spinlock.h>
21972 #include <asm/asm.h>
21973 #include <asm/page.h>
21974 #include <asm/smap.h>
21975@@ -29,7 +30,12 @@
21976
21977 #define get_ds() (KERNEL_DS)
21978 #define get_fs() (current_thread_info()->addr_limit)
21979+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
21980+void __set_fs(mm_segment_t x);
21981+void set_fs(mm_segment_t x);
21982+#else
21983 #define set_fs(x) (current_thread_info()->addr_limit = (x))
21984+#endif
21985
21986 #define segment_eq(a, b) ((a).seg == (b).seg)
21987
21988@@ -86,8 +92,36 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
21989 * checks that the pointer is in the user space range - after calling
21990 * this function, memory access functions may still return -EFAULT.
21991 */
21992-#define access_ok(type, addr, size) \
21993- likely(!__range_not_ok(addr, size, user_addr_max()))
21994+extern int _cond_resched(void);
21995+#define access_ok_noprefault(type, addr, size) (likely(!__range_not_ok(addr, size, user_addr_max())))
21996+#define access_ok(type, addr, size) \
21997+({ \
21998+ unsigned long __size = size; \
21999+ unsigned long __addr = (unsigned long)addr; \
22000+ bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
22001+ if (__ret_ao && __size) { \
22002+ unsigned long __addr_ao = __addr & PAGE_MASK; \
22003+ unsigned long __end_ao = __addr + __size - 1; \
22004+ if (unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
22005+ while (__addr_ao <= __end_ao) { \
22006+ char __c_ao; \
22007+ __addr_ao += PAGE_SIZE; \
22008+ if (__size > PAGE_SIZE) \
22009+ _cond_resched(); \
22010+ if (__get_user(__c_ao, (char __user *)__addr)) \
22011+ break; \
22012+ if (type != VERIFY_WRITE) { \
22013+ __addr = __addr_ao; \
22014+ continue; \
22015+ } \
22016+ if (__put_user(__c_ao, (char __user *)__addr)) \
22017+ break; \
22018+ __addr = __addr_ao; \
22019+ } \
22020+ } \
22021+ } \
22022+ __ret_ao; \
22023+})
22024
22025 /*
22026 * The exception table consists of pairs of addresses relative to the
22027@@ -135,11 +169,13 @@ extern int __get_user_8(void);
22028 extern int __get_user_bad(void);
22029
22030 /*
22031- * This is a type: either unsigned long, if the argument fits into
22032- * that type, or otherwise unsigned long long.
22033+ * This is a type: either (un)signed int, if the argument fits into
22034+ * that type, or otherwise (un)signed long long.
22035 */
22036 #define __inttype(x) \
22037-__typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
22038+__typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0U), \
22039+ __builtin_choose_expr(__type_is_unsigned(__typeof__(x)), 0ULL, 0LL),\
22040+ __builtin_choose_expr(__type_is_unsigned(__typeof__(x)), 0U, 0)))
22041
22042 /**
22043 * get_user: - Get a simple variable from user space.
22044@@ -178,10 +214,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
22045 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
22046 __chk_user_ptr(ptr); \
22047 might_fault(); \
22048+ pax_open_userland(); \
22049 asm volatile("call __get_user_%P3" \
22050 : "=a" (__ret_gu), "=r" (__val_gu) \
22051 : "0" (ptr), "i" (sizeof(*(ptr)))); \
22052 (x) = (__force __typeof__(*(ptr))) __val_gu; \
22053+ pax_close_userland(); \
22054 __ret_gu; \
22055 })
22056
22057@@ -189,13 +227,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
22058 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
22059 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
22060
22061-
22062+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
22063+#define __copyuser_seg "gs;"
22064+#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
22065+#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
22066+#else
22067+#define __copyuser_seg
22068+#define __COPYUSER_SET_ES
22069+#define __COPYUSER_RESTORE_ES
22070+#endif
22071
22072 #ifdef CONFIG_X86_32
22073 #define __put_user_asm_u64(x, addr, err, errret) \
22074 asm volatile(ASM_STAC "\n" \
22075- "1: movl %%eax,0(%2)\n" \
22076- "2: movl %%edx,4(%2)\n" \
22077+ "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
22078+ "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
22079 "3: " ASM_CLAC "\n" \
22080 ".section .fixup,\"ax\"\n" \
22081 "4: movl %3,%0\n" \
22082@@ -208,8 +254,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
22083
22084 #define __put_user_asm_ex_u64(x, addr) \
22085 asm volatile(ASM_STAC "\n" \
22086- "1: movl %%eax,0(%1)\n" \
22087- "2: movl %%edx,4(%1)\n" \
22088+ "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
22089+ "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
22090 "3: " ASM_CLAC "\n" \
22091 _ASM_EXTABLE_EX(1b, 2b) \
22092 _ASM_EXTABLE_EX(2b, 3b) \
22093@@ -260,7 +306,8 @@ extern void __put_user_8(void);
22094 __typeof__(*(ptr)) __pu_val; \
22095 __chk_user_ptr(ptr); \
22096 might_fault(); \
22097- __pu_val = x; \
22098+ __pu_val = (x); \
22099+ pax_open_userland(); \
22100 switch (sizeof(*(ptr))) { \
22101 case 1: \
22102 __put_user_x(1, __pu_val, ptr, __ret_pu); \
22103@@ -278,6 +325,7 @@ extern void __put_user_8(void);
22104 __put_user_x(X, __pu_val, ptr, __ret_pu); \
22105 break; \
22106 } \
22107+ pax_close_userland(); \
22108 __ret_pu; \
22109 })
22110
22111@@ -358,8 +406,10 @@ do { \
22112 } while (0)
22113
22114 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
22115+do { \
22116+ pax_open_userland(); \
22117 asm volatile(ASM_STAC "\n" \
22118- "1: mov"itype" %2,%"rtype"1\n" \
22119+ "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
22120 "2: " ASM_CLAC "\n" \
22121 ".section .fixup,\"ax\"\n" \
22122 "3: mov %3,%0\n" \
22123@@ -367,8 +417,10 @@ do { \
22124 " jmp 2b\n" \
22125 ".previous\n" \
22126 _ASM_EXTABLE(1b, 3b) \
22127- : "=r" (err), ltype(x) \
22128- : "m" (__m(addr)), "i" (errret), "0" (err))
22129+ : "=r" (err), ltype (x) \
22130+ : "m" (__m(addr)), "i" (errret), "0" (err)); \
22131+ pax_close_userland(); \
22132+} while (0)
22133
22134 #define __get_user_size_ex(x, ptr, size) \
22135 do { \
22136@@ -392,7 +444,7 @@ do { \
22137 } while (0)
22138
22139 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
22140- asm volatile("1: mov"itype" %1,%"rtype"0\n" \
22141+ asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
22142 "2:\n" \
22143 _ASM_EXTABLE_EX(1b, 2b) \
22144 : ltype(x) : "m" (__m(addr)))
22145@@ -409,13 +461,24 @@ do { \
22146 int __gu_err; \
22147 unsigned long __gu_val; \
22148 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
22149- (x) = (__force __typeof__(*(ptr)))__gu_val; \
22150+ (x) = (__typeof__(*(ptr)))__gu_val; \
22151 __gu_err; \
22152 })
22153
22154 /* FIXME: this hack is definitely wrong -AK */
22155 struct __large_struct { unsigned long buf[100]; };
22156-#define __m(x) (*(struct __large_struct __user *)(x))
22157+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22158+#define ____m(x) \
22159+({ \
22160+ unsigned long ____x = (unsigned long)(x); \
22161+ if (____x < pax_user_shadow_base) \
22162+ ____x += pax_user_shadow_base; \
22163+ (typeof(x))____x; \
22164+})
22165+#else
22166+#define ____m(x) (x)
22167+#endif
22168+#define __m(x) (*(struct __large_struct __user *)____m(x))
22169
22170 /*
22171 * Tell gcc we read from memory instead of writing: this is because
22172@@ -423,8 +486,10 @@ struct __large_struct { unsigned long buf[100]; };
22173 * aliasing issues.
22174 */
22175 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
22176+do { \
22177+ pax_open_userland(); \
22178 asm volatile(ASM_STAC "\n" \
22179- "1: mov"itype" %"rtype"1,%2\n" \
22180+ "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
22181 "2: " ASM_CLAC "\n" \
22182 ".section .fixup,\"ax\"\n" \
22183 "3: mov %3,%0\n" \
22184@@ -432,10 +497,12 @@ struct __large_struct { unsigned long buf[100]; };
22185 ".previous\n" \
22186 _ASM_EXTABLE(1b, 3b) \
22187 : "=r"(err) \
22188- : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
22189+ : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
22190+ pax_close_userland(); \
22191+} while (0)
22192
22193 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
22194- asm volatile("1: mov"itype" %"rtype"0,%1\n" \
22195+ asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
22196 "2:\n" \
22197 _ASM_EXTABLE_EX(1b, 2b) \
22198 : : ltype(x), "m" (__m(addr)))
22199@@ -445,11 +512,13 @@ struct __large_struct { unsigned long buf[100]; };
22200 */
22201 #define uaccess_try do { \
22202 current_thread_info()->uaccess_err = 0; \
22203+ pax_open_userland(); \
22204 stac(); \
22205 barrier();
22206
22207 #define uaccess_catch(err) \
22208 clac(); \
22209+ pax_close_userland(); \
22210 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
22211 } while (0)
22212
22213@@ -475,8 +544,12 @@ struct __large_struct { unsigned long buf[100]; };
22214 * On error, the variable @x is set to zero.
22215 */
22216
22217+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22218+#define __get_user(x, ptr) get_user((x), (ptr))
22219+#else
22220 #define __get_user(x, ptr) \
22221 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
22222+#endif
22223
22224 /**
22225 * __put_user: - Write a simple value into user space, with less checking.
22226@@ -499,8 +572,12 @@ struct __large_struct { unsigned long buf[100]; };
22227 * Returns zero on success, or -EFAULT on error.
22228 */
22229
22230+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22231+#define __put_user(x, ptr) put_user((x), (ptr))
22232+#else
22233 #define __put_user(x, ptr) \
22234 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
22235+#endif
22236
22237 #define __get_user_unaligned __get_user
22238 #define __put_user_unaligned __put_user
22239@@ -518,7 +595,7 @@ struct __large_struct { unsigned long buf[100]; };
22240 #define get_user_ex(x, ptr) do { \
22241 unsigned long __gue_val; \
22242 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
22243- (x) = (__force __typeof__(*(ptr)))__gue_val; \
22244+ (x) = (__typeof__(*(ptr)))__gue_val; \
22245 } while (0)
22246
22247 #define put_user_try uaccess_try
22248@@ -536,7 +613,7 @@ extern __must_check long strlen_user(const char __user *str);
22249 extern __must_check long strnlen_user(const char __user *str, long n);
22250
22251 unsigned long __must_check clear_user(void __user *mem, unsigned long len);
22252-unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
22253+unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
22254
22255 extern void __cmpxchg_wrong_size(void)
22256 __compiletime_error("Bad argument size for cmpxchg");
22257@@ -547,18 +624,19 @@ extern void __cmpxchg_wrong_size(void)
22258 __typeof__(ptr) __uval = (uval); \
22259 __typeof__(*(ptr)) __old = (old); \
22260 __typeof__(*(ptr)) __new = (new); \
22261+ pax_open_userland(); \
22262 switch (size) { \
22263 case 1: \
22264 { \
22265 asm volatile("\t" ASM_STAC "\n" \
22266- "1:\t" LOCK_PREFIX "cmpxchgb %4, %2\n" \
22267+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgb %4, %2\n"\
22268 "2:\t" ASM_CLAC "\n" \
22269 "\t.section .fixup, \"ax\"\n" \
22270 "3:\tmov %3, %0\n" \
22271 "\tjmp 2b\n" \
22272 "\t.previous\n" \
22273 _ASM_EXTABLE(1b, 3b) \
22274- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
22275+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
22276 : "i" (-EFAULT), "q" (__new), "1" (__old) \
22277 : "memory" \
22278 ); \
22279@@ -567,14 +645,14 @@ extern void __cmpxchg_wrong_size(void)
22280 case 2: \
22281 { \
22282 asm volatile("\t" ASM_STAC "\n" \
22283- "1:\t" LOCK_PREFIX "cmpxchgw %4, %2\n" \
22284+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgw %4, %2\n"\
22285 "2:\t" ASM_CLAC "\n" \
22286 "\t.section .fixup, \"ax\"\n" \
22287 "3:\tmov %3, %0\n" \
22288 "\tjmp 2b\n" \
22289 "\t.previous\n" \
22290 _ASM_EXTABLE(1b, 3b) \
22291- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
22292+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
22293 : "i" (-EFAULT), "r" (__new), "1" (__old) \
22294 : "memory" \
22295 ); \
22296@@ -583,14 +661,14 @@ extern void __cmpxchg_wrong_size(void)
22297 case 4: \
22298 { \
22299 asm volatile("\t" ASM_STAC "\n" \
22300- "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n" \
22301+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"\
22302 "2:\t" ASM_CLAC "\n" \
22303 "\t.section .fixup, \"ax\"\n" \
22304 "3:\tmov %3, %0\n" \
22305 "\tjmp 2b\n" \
22306 "\t.previous\n" \
22307 _ASM_EXTABLE(1b, 3b) \
22308- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
22309+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
22310 : "i" (-EFAULT), "r" (__new), "1" (__old) \
22311 : "memory" \
22312 ); \
22313@@ -602,14 +680,14 @@ extern void __cmpxchg_wrong_size(void)
22314 __cmpxchg_wrong_size(); \
22315 \
22316 asm volatile("\t" ASM_STAC "\n" \
22317- "1:\t" LOCK_PREFIX "cmpxchgq %4, %2\n" \
22318+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgq %4, %2\n"\
22319 "2:\t" ASM_CLAC "\n" \
22320 "\t.section .fixup, \"ax\"\n" \
22321 "3:\tmov %3, %0\n" \
22322 "\tjmp 2b\n" \
22323 "\t.previous\n" \
22324 _ASM_EXTABLE(1b, 3b) \
22325- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
22326+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
22327 : "i" (-EFAULT), "r" (__new), "1" (__old) \
22328 : "memory" \
22329 ); \
22330@@ -618,6 +696,7 @@ extern void __cmpxchg_wrong_size(void)
22331 default: \
22332 __cmpxchg_wrong_size(); \
22333 } \
22334+ pax_close_userland(); \
22335 *__uval = __old; \
22336 __ret; \
22337 })
22338@@ -641,17 +720,6 @@ extern struct movsl_mask {
22339
22340 #define ARCH_HAS_NOCACHE_UACCESS 1
22341
22342-#ifdef CONFIG_X86_32
22343-# include <asm/uaccess_32.h>
22344-#else
22345-# include <asm/uaccess_64.h>
22346-#endif
22347-
22348-unsigned long __must_check _copy_from_user(void *to, const void __user *from,
22349- unsigned n);
22350-unsigned long __must_check _copy_to_user(void __user *to, const void *from,
22351- unsigned n);
22352-
22353 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
22354 # define copy_user_diag __compiletime_error
22355 #else
22356@@ -661,7 +729,7 @@ unsigned long __must_check _copy_to_user(void __user *to, const void *from,
22357 extern void copy_user_diag("copy_from_user() buffer size is too small")
22358 copy_from_user_overflow(void);
22359 extern void copy_user_diag("copy_to_user() buffer size is too small")
22360-copy_to_user_overflow(void) __asm__("copy_from_user_overflow");
22361+copy_to_user_overflow(void);
22362
22363 #undef copy_user_diag
22364
22365@@ -674,7 +742,7 @@ __copy_from_user_overflow(void) __asm__("copy_from_user_overflow");
22366
22367 extern void
22368 __compiletime_warning("copy_to_user() buffer size is not provably correct")
22369-__copy_to_user_overflow(void) __asm__("copy_from_user_overflow");
22370+__copy_to_user_overflow(void) __asm__("copy_to_user_overflow");
22371 #define __copy_to_user_overflow(size, count) __copy_to_user_overflow()
22372
22373 #else
22374@@ -689,10 +757,16 @@ __copy_from_user_overflow(int size, unsigned long count)
22375
22376 #endif
22377
22378+#ifdef CONFIG_X86_32
22379+# include <asm/uaccess_32.h>
22380+#else
22381+# include <asm/uaccess_64.h>
22382+#endif
22383+
22384 static inline unsigned long __must_check
22385 copy_from_user(void *to, const void __user *from, unsigned long n)
22386 {
22387- int sz = __compiletime_object_size(to);
22388+ size_t sz = __compiletime_object_size(to);
22389
22390 might_fault();
22391
22392@@ -714,12 +788,15 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
22393 * case, and do only runtime checking for non-constant sizes.
22394 */
22395
22396- if (likely(sz < 0 || sz >= n))
22397- n = _copy_from_user(to, from, n);
22398- else if(__builtin_constant_p(n))
22399- copy_from_user_overflow();
22400- else
22401- __copy_from_user_overflow(sz, n);
22402+ if (likely(sz != (size_t)-1 && sz < n)) {
22403+ if(__builtin_constant_p(n))
22404+ copy_from_user_overflow();
22405+ else
22406+ __copy_from_user_overflow(sz, n);
22407+ } else if (access_ok(VERIFY_READ, from, n))
22408+ n = __copy_from_user(to, from, n);
22409+ else if ((long)n > 0)
22410+ memset(to, 0, n);
22411
22412 return n;
22413 }
22414@@ -727,17 +804,18 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
22415 static inline unsigned long __must_check
22416 copy_to_user(void __user *to, const void *from, unsigned long n)
22417 {
22418- int sz = __compiletime_object_size(from);
22419+ size_t sz = __compiletime_object_size(from);
22420
22421 might_fault();
22422
22423 /* See the comment in copy_from_user() above. */
22424- if (likely(sz < 0 || sz >= n))
22425- n = _copy_to_user(to, from, n);
22426- else if(__builtin_constant_p(n))
22427- copy_to_user_overflow();
22428- else
22429- __copy_to_user_overflow(sz, n);
22430+ if (likely(sz != (size_t)-1 && sz < n)) {
22431+ if(__builtin_constant_p(n))
22432+ copy_to_user_overflow();
22433+ else
22434+ __copy_to_user_overflow(sz, n);
22435+ } else if (access_ok(VERIFY_WRITE, to, n))
22436+ n = __copy_to_user(to, from, n);
22437
22438 return n;
22439 }
22440diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
22441index f5dcb52..da2c15b 100644
22442--- a/arch/x86/include/asm/uaccess_32.h
22443+++ b/arch/x86/include/asm/uaccess_32.h
22444@@ -40,9 +40,14 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
22445 * anything, so this is accurate.
22446 */
22447
22448-static __always_inline unsigned long __must_check
22449+static __always_inline __size_overflow(3) unsigned long __must_check
22450 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
22451 {
22452+ if ((long)n < 0)
22453+ return n;
22454+
22455+ check_object_size(from, n, true);
22456+
22457 if (__builtin_constant_p(n)) {
22458 unsigned long ret;
22459
22460@@ -87,12 +92,16 @@ static __always_inline unsigned long __must_check
22461 __copy_to_user(void __user *to, const void *from, unsigned long n)
22462 {
22463 might_fault();
22464+
22465 return __copy_to_user_inatomic(to, from, n);
22466 }
22467
22468-static __always_inline unsigned long
22469+static __always_inline __size_overflow(3) unsigned long
22470 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
22471 {
22472+ if ((long)n < 0)
22473+ return n;
22474+
22475 /* Avoid zeroing the tail if the copy fails..
22476 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
22477 * but as the zeroing behaviour is only significant when n is not
22478@@ -143,6 +152,12 @@ static __always_inline unsigned long
22479 __copy_from_user(void *to, const void __user *from, unsigned long n)
22480 {
22481 might_fault();
22482+
22483+ if ((long)n < 0)
22484+ return n;
22485+
22486+ check_object_size(to, n, false);
22487+
22488 if (__builtin_constant_p(n)) {
22489 unsigned long ret;
22490
22491@@ -165,6 +180,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
22492 const void __user *from, unsigned long n)
22493 {
22494 might_fault();
22495+
22496+ if ((long)n < 0)
22497+ return n;
22498+
22499 if (__builtin_constant_p(n)) {
22500 unsigned long ret;
22501
22502@@ -187,7 +206,10 @@ static __always_inline unsigned long
22503 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
22504 unsigned long n)
22505 {
22506- return __copy_from_user_ll_nocache_nozero(to, from, n);
22507+ if ((long)n < 0)
22508+ return n;
22509+
22510+ return __copy_from_user_ll_nocache_nozero(to, from, n);
22511 }
22512
22513 #endif /* _ASM_X86_UACCESS_32_H */
22514diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
22515index f2f9b39..2ae1bf8 100644
22516--- a/arch/x86/include/asm/uaccess_64.h
22517+++ b/arch/x86/include/asm/uaccess_64.h
22518@@ -10,6 +10,9 @@
22519 #include <asm/alternative.h>
22520 #include <asm/cpufeature.h>
22521 #include <asm/page.h>
22522+#include <asm/pgtable.h>
22523+
22524+#define set_fs(x) (current_thread_info()->addr_limit = (x))
22525
22526 /*
22527 * Copy To/From Userspace
22528@@ -23,8 +26,8 @@ copy_user_generic_string(void *to, const void *from, unsigned len);
22529 __must_check unsigned long
22530 copy_user_generic_unrolled(void *to, const void *from, unsigned len);
22531
22532-static __always_inline __must_check unsigned long
22533-copy_user_generic(void *to, const void *from, unsigned len)
22534+static __always_inline __must_check __size_overflow(3) unsigned long
22535+copy_user_generic(void *to, const void *from, unsigned long len)
22536 {
22537 unsigned ret;
22538
22539@@ -46,121 +49,170 @@ copy_user_generic(void *to, const void *from, unsigned len)
22540 }
22541
22542 __must_check unsigned long
22543-copy_in_user(void __user *to, const void __user *from, unsigned len);
22544+copy_in_user(void __user *to, const void __user *from, unsigned long len);
22545
22546 static __always_inline __must_check
22547-int __copy_from_user_nocheck(void *dst, const void __user *src, unsigned size)
22548+unsigned long __copy_from_user_nocheck(void *dst, const void __user *src, unsigned long size)
22549 {
22550- int ret = 0;
22551+ size_t sz = __compiletime_object_size(dst);
22552+ unsigned ret = 0;
22553+
22554+ if (size > INT_MAX)
22555+ return size;
22556+
22557+ check_object_size(dst, size, false);
22558+
22559+#ifdef CONFIG_PAX_MEMORY_UDEREF
22560+ if (!access_ok_noprefault(VERIFY_READ, src, size))
22561+ return size;
22562+#endif
22563+
22564+ if (unlikely(sz != (size_t)-1 && sz < size)) {
22565+ if(__builtin_constant_p(size))
22566+ copy_from_user_overflow();
22567+ else
22568+ __copy_from_user_overflow(sz, size);
22569+ return size;
22570+ }
22571
22572 if (!__builtin_constant_p(size))
22573- return copy_user_generic(dst, (__force void *)src, size);
22574+ return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
22575 switch (size) {
22576- case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
22577+ case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
22578 ret, "b", "b", "=q", 1);
22579 return ret;
22580- case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
22581+ case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
22582 ret, "w", "w", "=r", 2);
22583 return ret;
22584- case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
22585+ case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
22586 ret, "l", "k", "=r", 4);
22587 return ret;
22588- case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
22589+ case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
22590 ret, "q", "", "=r", 8);
22591 return ret;
22592 case 10:
22593- __get_user_asm(*(u64 *)dst, (u64 __user *)src,
22594+ __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
22595 ret, "q", "", "=r", 10);
22596 if (unlikely(ret))
22597 return ret;
22598 __get_user_asm(*(u16 *)(8 + (char *)dst),
22599- (u16 __user *)(8 + (char __user *)src),
22600+ (const u16 __user *)(8 + (const char __user *)src),
22601 ret, "w", "w", "=r", 2);
22602 return ret;
22603 case 16:
22604- __get_user_asm(*(u64 *)dst, (u64 __user *)src,
22605+ __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
22606 ret, "q", "", "=r", 16);
22607 if (unlikely(ret))
22608 return ret;
22609 __get_user_asm(*(u64 *)(8 + (char *)dst),
22610- (u64 __user *)(8 + (char __user *)src),
22611+ (const u64 __user *)(8 + (const char __user *)src),
22612 ret, "q", "", "=r", 8);
22613 return ret;
22614 default:
22615- return copy_user_generic(dst, (__force void *)src, size);
22616+ return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
22617 }
22618 }
22619
22620 static __always_inline __must_check
22621-int __copy_from_user(void *dst, const void __user *src, unsigned size)
22622+unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
22623 {
22624 might_fault();
22625 return __copy_from_user_nocheck(dst, src, size);
22626 }
22627
22628 static __always_inline __must_check
22629-int __copy_to_user_nocheck(void __user *dst, const void *src, unsigned size)
22630+unsigned long __copy_to_user_nocheck(void __user *dst, const void *src, unsigned long size)
22631 {
22632- int ret = 0;
22633+ size_t sz = __compiletime_object_size(src);
22634+ unsigned ret = 0;
22635+
22636+ if (size > INT_MAX)
22637+ return size;
22638+
22639+ check_object_size(src, size, true);
22640+
22641+#ifdef CONFIG_PAX_MEMORY_UDEREF
22642+ if (!access_ok_noprefault(VERIFY_WRITE, dst, size))
22643+ return size;
22644+#endif
22645+
22646+ if (unlikely(sz != (size_t)-1 && sz < size)) {
22647+ if(__builtin_constant_p(size))
22648+ copy_to_user_overflow();
22649+ else
22650+ __copy_to_user_overflow(sz, size);
22651+ return size;
22652+ }
22653
22654 if (!__builtin_constant_p(size))
22655- return copy_user_generic((__force void *)dst, src, size);
22656+ return copy_user_generic((__force_kernel void *)____m(dst), src, size);
22657 switch (size) {
22658- case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
22659+ case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
22660 ret, "b", "b", "iq", 1);
22661 return ret;
22662- case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
22663+ case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
22664 ret, "w", "w", "ir", 2);
22665 return ret;
22666- case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
22667+ case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
22668 ret, "l", "k", "ir", 4);
22669 return ret;
22670- case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
22671+ case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
22672 ret, "q", "", "er", 8);
22673 return ret;
22674 case 10:
22675- __put_user_asm(*(u64 *)src, (u64 __user *)dst,
22676+ __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
22677 ret, "q", "", "er", 10);
22678 if (unlikely(ret))
22679 return ret;
22680 asm("":::"memory");
22681- __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
22682+ __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
22683 ret, "w", "w", "ir", 2);
22684 return ret;
22685 case 16:
22686- __put_user_asm(*(u64 *)src, (u64 __user *)dst,
22687+ __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
22688 ret, "q", "", "er", 16);
22689 if (unlikely(ret))
22690 return ret;
22691 asm("":::"memory");
22692- __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
22693+ __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
22694 ret, "q", "", "er", 8);
22695 return ret;
22696 default:
22697- return copy_user_generic((__force void *)dst, src, size);
22698+ return copy_user_generic((__force_kernel void *)____m(dst), src, size);
22699 }
22700 }
22701
22702 static __always_inline __must_check
22703-int __copy_to_user(void __user *dst, const void *src, unsigned size)
22704+unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
22705 {
22706 might_fault();
22707 return __copy_to_user_nocheck(dst, src, size);
22708 }
22709
22710 static __always_inline __must_check
22711-int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22712+unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22713 {
22714- int ret = 0;
22715+ unsigned ret = 0;
22716
22717 might_fault();
22718+
22719+ if (size > INT_MAX)
22720+ return size;
22721+
22722+#ifdef CONFIG_PAX_MEMORY_UDEREF
22723+ if (!access_ok_noprefault(VERIFY_READ, src, size))
22724+ return size;
22725+ if (!access_ok_noprefault(VERIFY_WRITE, dst, size))
22726+ return size;
22727+#endif
22728+
22729 if (!__builtin_constant_p(size))
22730- return copy_user_generic((__force void *)dst,
22731- (__force void *)src, size);
22732+ return copy_user_generic((__force_kernel void *)____m(dst),
22733+ (__force_kernel const void *)____m(src), size);
22734 switch (size) {
22735 case 1: {
22736 u8 tmp;
22737- __get_user_asm(tmp, (u8 __user *)src,
22738+ __get_user_asm(tmp, (const u8 __user *)src,
22739 ret, "b", "b", "=q", 1);
22740 if (likely(!ret))
22741 __put_user_asm(tmp, (u8 __user *)dst,
22742@@ -169,7 +221,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22743 }
22744 case 2: {
22745 u16 tmp;
22746- __get_user_asm(tmp, (u16 __user *)src,
22747+ __get_user_asm(tmp, (const u16 __user *)src,
22748 ret, "w", "w", "=r", 2);
22749 if (likely(!ret))
22750 __put_user_asm(tmp, (u16 __user *)dst,
22751@@ -179,7 +231,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22752
22753 case 4: {
22754 u32 tmp;
22755- __get_user_asm(tmp, (u32 __user *)src,
22756+ __get_user_asm(tmp, (const u32 __user *)src,
22757 ret, "l", "k", "=r", 4);
22758 if (likely(!ret))
22759 __put_user_asm(tmp, (u32 __user *)dst,
22760@@ -188,7 +240,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22761 }
22762 case 8: {
22763 u64 tmp;
22764- __get_user_asm(tmp, (u64 __user *)src,
22765+ __get_user_asm(tmp, (const u64 __user *)src,
22766 ret, "q", "", "=r", 8);
22767 if (likely(!ret))
22768 __put_user_asm(tmp, (u64 __user *)dst,
22769@@ -196,41 +248,58 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22770 return ret;
22771 }
22772 default:
22773- return copy_user_generic((__force void *)dst,
22774- (__force void *)src, size);
22775+ return copy_user_generic((__force_kernel void *)____m(dst),
22776+ (__force_kernel const void *)____m(src), size);
22777 }
22778 }
22779
22780-static __must_check __always_inline int
22781-__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
22782+static __must_check __always_inline unsigned long
22783+__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
22784 {
22785 return __copy_from_user_nocheck(dst, src, size);
22786 }
22787
22788-static __must_check __always_inline int
22789-__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
22790+static __must_check __always_inline unsigned long
22791+__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
22792 {
22793 return __copy_to_user_nocheck(dst, src, size);
22794 }
22795
22796-extern long __copy_user_nocache(void *dst, const void __user *src,
22797- unsigned size, int zerorest);
22798+extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
22799+ unsigned long size, int zerorest);
22800
22801-static inline int
22802-__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
22803+static inline unsigned long
22804+__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
22805 {
22806 might_fault();
22807+
22808+ if (size > INT_MAX)
22809+ return size;
22810+
22811+#ifdef CONFIG_PAX_MEMORY_UDEREF
22812+ if (!access_ok_noprefault(VERIFY_READ, src, size))
22813+ return size;
22814+#endif
22815+
22816 return __copy_user_nocache(dst, src, size, 1);
22817 }
22818
22819-static inline int
22820+static inline unsigned long
22821 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
22822- unsigned size)
22823+ unsigned long size)
22824 {
22825+ if (size > INT_MAX)
22826+ return size;
22827+
22828+#ifdef CONFIG_PAX_MEMORY_UDEREF
22829+ if (!access_ok_noprefault(VERIFY_READ, src, size))
22830+ return size;
22831+#endif
22832+
22833 return __copy_user_nocache(dst, src, size, 0);
22834 }
22835
22836 unsigned long
22837-copy_user_handle_tail(char *to, char *from, unsigned len);
22838+copy_user_handle_tail(char __user *to, char __user *from, unsigned long len) __size_overflow(3);
22839
22840 #endif /* _ASM_X86_UACCESS_64_H */
22841diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
22842index 5b238981..77fdd78 100644
22843--- a/arch/x86/include/asm/word-at-a-time.h
22844+++ b/arch/x86/include/asm/word-at-a-time.h
22845@@ -11,7 +11,7 @@
22846 * and shift, for example.
22847 */
22848 struct word_at_a_time {
22849- const unsigned long one_bits, high_bits;
22850+ unsigned long one_bits, high_bits;
22851 };
22852
22853 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
22854diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
22855index 48d34d2..90671c7 100644
22856--- a/arch/x86/include/asm/x86_init.h
22857+++ b/arch/x86/include/asm/x86_init.h
22858@@ -129,7 +129,7 @@ struct x86_init_ops {
22859 struct x86_init_timers timers;
22860 struct x86_init_iommu iommu;
22861 struct x86_init_pci pci;
22862-};
22863+} __no_const;
22864
22865 /**
22866 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
22867@@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
22868 void (*setup_percpu_clockev)(void);
22869 void (*early_percpu_clock_init)(void);
22870 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
22871-};
22872+} __no_const;
22873
22874 struct timespec;
22875
22876@@ -168,7 +168,7 @@ struct x86_platform_ops {
22877 void (*save_sched_clock_state)(void);
22878 void (*restore_sched_clock_state)(void);
22879 void (*apic_post_init)(void);
22880-};
22881+} __no_const;
22882
22883 struct pci_dev;
22884
22885@@ -177,12 +177,12 @@ struct x86_msi_ops {
22886 void (*teardown_msi_irq)(unsigned int irq);
22887 void (*teardown_msi_irqs)(struct pci_dev *dev);
22888 void (*restore_msi_irqs)(struct pci_dev *dev);
22889-};
22890+} __no_const;
22891
22892 struct x86_io_apic_ops {
22893 unsigned int (*read) (unsigned int apic, unsigned int reg);
22894 void (*disable)(void);
22895-};
22896+} __no_const;
22897
22898 extern struct x86_init_ops x86_init;
22899 extern struct x86_cpuinit_ops x86_cpuinit;
22900diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
22901index c44a5d5..7f83cfc 100644
22902--- a/arch/x86/include/asm/xen/page.h
22903+++ b/arch/x86/include/asm/xen/page.h
22904@@ -82,7 +82,7 @@ static inline int xen_safe_read_ulong(unsigned long *addr, unsigned long *val)
22905 * - get_phys_to_machine() is to be called by __pfn_to_mfn() only in special
22906 * cases needing an extended handling.
22907 */
22908-static inline unsigned long __pfn_to_mfn(unsigned long pfn)
22909+static inline unsigned long __intentional_overflow(-1) __pfn_to_mfn(unsigned long pfn)
22910 {
22911 unsigned long mfn;
22912
22913diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
22914index 0f457e6..5970c0a 100644
22915--- a/arch/x86/include/uapi/asm/e820.h
22916+++ b/arch/x86/include/uapi/asm/e820.h
22917@@ -69,7 +69,7 @@ struct e820map {
22918 #define ISA_START_ADDRESS 0xa0000
22919 #define ISA_END_ADDRESS 0x100000
22920
22921-#define BIOS_BEGIN 0x000a0000
22922+#define BIOS_BEGIN 0x000c0000
22923 #define BIOS_END 0x00100000
22924
22925 #define BIOS_ROM_BASE 0xffe00000
22926diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
22927index 0f15af4..501a76a 100644
22928--- a/arch/x86/kernel/Makefile
22929+++ b/arch/x86/kernel/Makefile
22930@@ -28,7 +28,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
22931 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
22932 obj-$(CONFIG_IRQ_WORK) += irq_work.o
22933 obj-y += probe_roms.o
22934-obj-$(CONFIG_X86_32) += i386_ksyms_32.o
22935+obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
22936 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
22937 obj-$(CONFIG_X86_64) += mcount_64.o
22938 obj-$(CONFIG_X86_ESPFIX64) += espfix_64.o
22939diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
22940index 9393896..adbaa90 100644
22941--- a/arch/x86/kernel/acpi/boot.c
22942+++ b/arch/x86/kernel/acpi/boot.c
22943@@ -1333,7 +1333,7 @@ static void __init acpi_reduced_hw_init(void)
22944 * If your system is blacklisted here, but you find that acpi=force
22945 * works for you, please contact linux-acpi@vger.kernel.org
22946 */
22947-static struct dmi_system_id __initdata acpi_dmi_table[] = {
22948+static const struct dmi_system_id __initconst acpi_dmi_table[] = {
22949 /*
22950 * Boxes that need ACPI disabled
22951 */
22952@@ -1408,7 +1408,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
22953 };
22954
22955 /* second table for DMI checks that should run after early-quirks */
22956-static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
22957+static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
22958 /*
22959 * HP laptops which use a DSDT reporting as HP/SB400/10000,
22960 * which includes some code which overrides all temperature
22961diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
22962index d1daead..acd77e2 100644
22963--- a/arch/x86/kernel/acpi/sleep.c
22964+++ b/arch/x86/kernel/acpi/sleep.c
22965@@ -99,8 +99,12 @@ int x86_acpi_suspend_lowlevel(void)
22966 #else /* CONFIG_64BIT */
22967 #ifdef CONFIG_SMP
22968 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
22969+
22970+ pax_open_kernel();
22971 early_gdt_descr.address =
22972 (unsigned long)get_cpu_gdt_table(smp_processor_id());
22973+ pax_close_kernel();
22974+
22975 initial_gs = per_cpu_offset(smp_processor_id());
22976 #endif
22977 initial_code = (unsigned long)wakeup_long64;
22978diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
22979index 0c26b1b..a766e85 100644
22980--- a/arch/x86/kernel/acpi/wakeup_32.S
22981+++ b/arch/x86/kernel/acpi/wakeup_32.S
22982@@ -31,13 +31,11 @@ wakeup_pmode_return:
22983 # and restore the stack ... but you need gdt for this to work
22984 movl saved_context_esp, %esp
22985
22986- movl %cs:saved_magic, %eax
22987- cmpl $0x12345678, %eax
22988+ cmpl $0x12345678, saved_magic
22989 jne bogus_magic
22990
22991 # jump to place where we left off
22992- movl saved_eip, %eax
22993- jmp *%eax
22994+ jmp *(saved_eip)
22995
22996 bogus_magic:
22997 jmp bogus_magic
22998diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
22999index 25f9093..21d2827 100644
23000--- a/arch/x86/kernel/alternative.c
23001+++ b/arch/x86/kernel/alternative.c
23002@@ -20,6 +20,7 @@
23003 #include <asm/tlbflush.h>
23004 #include <asm/io.h>
23005 #include <asm/fixmap.h>
23006+#include <asm/boot.h>
23007
23008 int __read_mostly alternatives_patched;
23009
23010@@ -261,7 +262,9 @@ static void __init_or_module add_nops(void *insns, unsigned int len)
23011 unsigned int noplen = len;
23012 if (noplen > ASM_NOP_MAX)
23013 noplen = ASM_NOP_MAX;
23014+ pax_open_kernel();
23015 memcpy(insns, ideal_nops[noplen], noplen);
23016+ pax_close_kernel();
23017 insns += noplen;
23018 len -= noplen;
23019 }
23020@@ -289,6 +292,13 @@ recompute_jump(struct alt_instr *a, u8 *orig_insn, u8 *repl_insn, u8 *insnbuf)
23021 if (a->replacementlen != 5)
23022 return;
23023
23024+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23025+ if (orig_insn < (u8 *)_text || (u8 *)_einittext <= orig_insn)
23026+ orig_insn = (u8 *)ktva_ktla((unsigned long)orig_insn);
23027+ else
23028+ orig_insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23029+#endif
23030+
23031 o_dspl = *(s32 *)(insnbuf + 1);
23032
23033 /* next_rip of the replacement JMP */
23034@@ -364,6 +374,7 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
23035 {
23036 struct alt_instr *a;
23037 u8 *instr, *replacement;
23038+ u8 *vinstr, *vreplacement;
23039 u8 insnbuf[MAX_PATCH_LEN];
23040
23041 DPRINTK("alt table %p -> %p", start, end);
23042@@ -379,46 +390,71 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
23043 for (a = start; a < end; a++) {
23044 int insnbuf_sz = 0;
23045
23046- instr = (u8 *)&a->instr_offset + a->instr_offset;
23047- replacement = (u8 *)&a->repl_offset + a->repl_offset;
23048+ vinstr = instr = (u8 *)&a->instr_offset + a->instr_offset;
23049+
23050+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23051+ if ((u8 *)_text - (____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR) <= instr &&
23052+ instr < (u8 *)_einittext - (____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR)) {
23053+ instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23054+ vinstr = (u8 *)ktla_ktva((unsigned long)instr);
23055+ } else if ((u8 *)_text <= instr && instr < (u8 *)_einittext) {
23056+ vinstr = (u8 *)ktla_ktva((unsigned long)instr);
23057+ } else {
23058+ instr = (u8 *)ktva_ktla((unsigned long)instr);
23059+ }
23060+#endif
23061+
23062+ vreplacement = replacement = (u8 *)&a->repl_offset + a->repl_offset;
23063+
23064+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23065+ if ((u8 *)_text - (____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR) <= replacement &&
23066+ replacement < (u8 *)_einittext - (____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR)) {
23067+ replacement += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23068+ vreplacement = (u8 *)ktla_ktva((unsigned long)replacement);
23069+ } else if ((u8 *)_text <= replacement && replacement < (u8 *)_einittext) {
23070+ vreplacement = (u8 *)ktla_ktva((unsigned long)replacement);
23071+ } else
23072+ replacement = (u8 *)ktva_ktla((unsigned long)replacement);
23073+#endif
23074+
23075 BUG_ON(a->instrlen > sizeof(insnbuf));
23076 BUG_ON(a->cpuid >= (NCAPINTS + NBUGINTS) * 32);
23077 if (!boot_cpu_has(a->cpuid)) {
23078 if (a->padlen > 1)
23079- optimize_nops(a, instr);
23080+ optimize_nops(a, vinstr);
23081
23082 continue;
23083 }
23084
23085- DPRINTK("feat: %d*32+%d, old: (%p, len: %d), repl: (%p, len: %d), pad: %d",
23086+ DPRINTK("feat: %d*32+%d, old: (%p/%p, len: %d), repl: (%p, len: %d), pad: %d",
23087 a->cpuid >> 5,
23088 a->cpuid & 0x1f,
23089- instr, a->instrlen,
23090- replacement, a->replacementlen, a->padlen);
23091+ instr, vinstr, a->instrlen,
23092+ vreplacement, a->replacementlen, a->padlen);
23093
23094- DUMP_BYTES(instr, a->instrlen, "%p: old_insn: ", instr);
23095- DUMP_BYTES(replacement, a->replacementlen, "%p: rpl_insn: ", replacement);
23096+ DUMP_BYTES(vinstr, a->instrlen, "%p: old_insn: ", vinstr);
23097+ DUMP_BYTES(vreplacement, a->replacementlen, "%p: rpl_insn: ", vreplacement);
23098
23099- memcpy(insnbuf, replacement, a->replacementlen);
23100+ memcpy(insnbuf, vreplacement, a->replacementlen);
23101 insnbuf_sz = a->replacementlen;
23102
23103 /* 0xe8 is a relative jump; fix the offset. */
23104 if (*insnbuf == 0xe8 && a->replacementlen == 5) {
23105- *(s32 *)(insnbuf + 1) += replacement - instr;
23106+ *(s32 *)(insnbuf + 1) += vreplacement - vinstr;
23107 DPRINTK("Fix CALL offset: 0x%x, CALL 0x%lx",
23108 *(s32 *)(insnbuf + 1),
23109- (unsigned long)instr + *(s32 *)(insnbuf + 1) + 5);
23110+ (unsigned long)vinstr + *(s32 *)(insnbuf + 1) + 5);
23111 }
23112
23113- if (a->replacementlen && is_jmp(replacement[0]))
23114- recompute_jump(a, instr, replacement, insnbuf);
23115+ if (a->replacementlen && is_jmp(vreplacement[0]))
23116+ recompute_jump(a, instr, vreplacement, insnbuf);
23117
23118 if (a->instrlen > a->replacementlen) {
23119 add_nops(insnbuf + a->replacementlen,
23120 a->instrlen - a->replacementlen);
23121 insnbuf_sz += a->instrlen - a->replacementlen;
23122 }
23123- DUMP_BYTES(insnbuf, insnbuf_sz, "%p: final_insn: ", instr);
23124+ DUMP_BYTES(insnbuf, insnbuf_sz, "%p: final_insn: ", vinstr);
23125
23126 text_poke_early(instr, insnbuf, insnbuf_sz);
23127 }
23128@@ -434,10 +470,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
23129 for (poff = start; poff < end; poff++) {
23130 u8 *ptr = (u8 *)poff + *poff;
23131
23132+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23133+ ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23134+ if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
23135+ ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23136+#endif
23137+
23138 if (!*poff || ptr < text || ptr >= text_end)
23139 continue;
23140 /* turn DS segment override prefix into lock prefix */
23141- if (*ptr == 0x3e)
23142+ if (*(u8 *)ktla_ktva((unsigned long)ptr) == 0x3e)
23143 text_poke(ptr, ((unsigned char []){0xf0}), 1);
23144 }
23145 mutex_unlock(&text_mutex);
23146@@ -452,10 +494,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
23147 for (poff = start; poff < end; poff++) {
23148 u8 *ptr = (u8 *)poff + *poff;
23149
23150+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23151+ ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23152+ if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
23153+ ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23154+#endif
23155+
23156 if (!*poff || ptr < text || ptr >= text_end)
23157 continue;
23158 /* turn lock prefix into DS segment override prefix */
23159- if (*ptr == 0xf0)
23160+ if (*(u8 *)ktla_ktva((unsigned long)ptr) == 0xf0)
23161 text_poke(ptr, ((unsigned char []){0x3E}), 1);
23162 }
23163 mutex_unlock(&text_mutex);
23164@@ -592,7 +640,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
23165
23166 BUG_ON(p->len > MAX_PATCH_LEN);
23167 /* prep the buffer with the original instructions */
23168- memcpy(insnbuf, p->instr, p->len);
23169+ memcpy(insnbuf, (const void *)ktla_ktva((unsigned long)p->instr), p->len);
23170 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
23171 (unsigned long)p->instr, p->len);
23172
23173@@ -639,7 +687,7 @@ void __init alternative_instructions(void)
23174 if (!uniproc_patched || num_possible_cpus() == 1)
23175 free_init_pages("SMP alternatives",
23176 (unsigned long)__smp_locks,
23177- (unsigned long)__smp_locks_end);
23178+ PAGE_ALIGN((unsigned long)__smp_locks_end));
23179 #endif
23180
23181 apply_paravirt(__parainstructions, __parainstructions_end);
23182@@ -660,13 +708,17 @@ void __init alternative_instructions(void)
23183 * instructions. And on the local CPU you need to be protected again NMI or MCE
23184 * handlers seeing an inconsistent instruction while you patch.
23185 */
23186-void *__init_or_module text_poke_early(void *addr, const void *opcode,
23187+void *__kprobes text_poke_early(void *addr, const void *opcode,
23188 size_t len)
23189 {
23190 unsigned long flags;
23191 local_irq_save(flags);
23192- memcpy(addr, opcode, len);
23193+
23194+ pax_open_kernel();
23195+ memcpy((void *)ktla_ktva((unsigned long)addr), opcode, len);
23196 sync_core();
23197+ pax_close_kernel();
23198+
23199 local_irq_restore(flags);
23200 /* Could also do a CLFLUSH here to speed up CPU recovery; but
23201 that causes hangs on some VIA CPUs. */
23202@@ -688,36 +740,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
23203 */
23204 void *text_poke(void *addr, const void *opcode, size_t len)
23205 {
23206- unsigned long flags;
23207- char *vaddr;
23208+ unsigned char *vaddr = (void *)ktla_ktva((unsigned long)addr);
23209 struct page *pages[2];
23210- int i;
23211+ size_t i;
23212
23213 if (!core_kernel_text((unsigned long)addr)) {
23214- pages[0] = vmalloc_to_page(addr);
23215- pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
23216+ pages[0] = vmalloc_to_page(vaddr);
23217+ pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
23218 } else {
23219- pages[0] = virt_to_page(addr);
23220+ pages[0] = virt_to_page(vaddr);
23221 WARN_ON(!PageReserved(pages[0]));
23222- pages[1] = virt_to_page(addr + PAGE_SIZE);
23223+ pages[1] = virt_to_page(vaddr + PAGE_SIZE);
23224 }
23225 BUG_ON(!pages[0]);
23226- local_irq_save(flags);
23227- set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
23228- if (pages[1])
23229- set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
23230- vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
23231- memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
23232- clear_fixmap(FIX_TEXT_POKE0);
23233- if (pages[1])
23234- clear_fixmap(FIX_TEXT_POKE1);
23235- local_flush_tlb();
23236- sync_core();
23237- /* Could also do a CLFLUSH here to speed up CPU recovery; but
23238- that causes hangs on some VIA CPUs. */
23239+ text_poke_early(addr, opcode, len);
23240 for (i = 0; i < len; i++)
23241- BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
23242- local_irq_restore(flags);
23243+ BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
23244 return addr;
23245 }
23246
23247@@ -771,7 +809,7 @@ int poke_int3_handler(struct pt_regs *regs)
23248 */
23249 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
23250 {
23251- unsigned char int3 = 0xcc;
23252+ const unsigned char int3 = 0xcc;
23253
23254 bp_int3_handler = handler;
23255 bp_int3_addr = (u8 *)addr + sizeof(int3);
23256diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
23257index 307a498..783e96a 100644
23258--- a/arch/x86/kernel/apic/apic.c
23259+++ b/arch/x86/kernel/apic/apic.c
23260@@ -171,7 +171,7 @@ int first_system_vector = FIRST_SYSTEM_VECTOR;
23261 /*
23262 * Debug level, exported for io_apic.c
23263 */
23264-unsigned int apic_verbosity;
23265+int apic_verbosity;
23266
23267 int pic_mode;
23268
23269@@ -1864,7 +1864,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
23270 apic_write(APIC_ESR, 0);
23271 v = apic_read(APIC_ESR);
23272 ack_APIC_irq();
23273- atomic_inc(&irq_err_count);
23274+ atomic_inc_unchecked(&irq_err_count);
23275
23276 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x",
23277 smp_processor_id(), v);
23278diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
23279index de918c4..32eed23 100644
23280--- a/arch/x86/kernel/apic/apic_flat_64.c
23281+++ b/arch/x86/kernel/apic/apic_flat_64.c
23282@@ -154,7 +154,7 @@ static int flat_probe(void)
23283 return 1;
23284 }
23285
23286-static struct apic apic_flat = {
23287+static struct apic apic_flat __read_only = {
23288 .name = "flat",
23289 .probe = flat_probe,
23290 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
23291@@ -260,7 +260,7 @@ static int physflat_probe(void)
23292 return 0;
23293 }
23294
23295-static struct apic apic_physflat = {
23296+static struct apic apic_physflat __read_only = {
23297
23298 .name = "physical flat",
23299 .probe = physflat_probe,
23300diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
23301index b205cdb..d8503ff 100644
23302--- a/arch/x86/kernel/apic/apic_noop.c
23303+++ b/arch/x86/kernel/apic/apic_noop.c
23304@@ -108,7 +108,7 @@ static void noop_apic_write(u32 reg, u32 v)
23305 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
23306 }
23307
23308-struct apic apic_noop = {
23309+struct apic apic_noop __read_only = {
23310 .name = "noop",
23311 .probe = noop_probe,
23312 .acpi_madt_oem_check = NULL,
23313diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
23314index c4a8d63..fe893ac 100644
23315--- a/arch/x86/kernel/apic/bigsmp_32.c
23316+++ b/arch/x86/kernel/apic/bigsmp_32.c
23317@@ -147,7 +147,7 @@ static int probe_bigsmp(void)
23318 return dmi_bigsmp;
23319 }
23320
23321-static struct apic apic_bigsmp = {
23322+static struct apic apic_bigsmp __read_only = {
23323
23324 .name = "bigsmp",
23325 .probe = probe_bigsmp,
23326diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
23327index 5880b48..5085f3e 100644
23328--- a/arch/x86/kernel/apic/io_apic.c
23329+++ b/arch/x86/kernel/apic/io_apic.c
23330@@ -1682,7 +1682,7 @@ static unsigned int startup_ioapic_irq(struct irq_data *data)
23331 return was_pending;
23332 }
23333
23334-atomic_t irq_mis_count;
23335+atomic_unchecked_t irq_mis_count;
23336
23337 #ifdef CONFIG_GENERIC_PENDING_IRQ
23338 static bool io_apic_level_ack_pending(struct mp_chip_data *data)
23339@@ -1821,7 +1821,7 @@ static void ioapic_ack_level(struct irq_data *irq_data)
23340 * at the cpu.
23341 */
23342 if (!(v & (1 << (i & 0x1f)))) {
23343- atomic_inc(&irq_mis_count);
23344+ atomic_inc_unchecked(&irq_mis_count);
23345 eoi_ioapic_pin(cfg->vector, irq_data->chip_data);
23346 }
23347
23348@@ -1867,7 +1867,7 @@ static int ioapic_set_affinity(struct irq_data *irq_data,
23349 return ret;
23350 }
23351
23352-static struct irq_chip ioapic_chip __read_mostly = {
23353+static struct irq_chip ioapic_chip = {
23354 .name = "IO-APIC",
23355 .irq_startup = startup_ioapic_irq,
23356 .irq_mask = mask_ioapic_irq,
23357@@ -1936,7 +1936,7 @@ static void ack_lapic_irq(struct irq_data *data)
23358 ack_APIC_irq();
23359 }
23360
23361-static struct irq_chip lapic_chip __read_mostly = {
23362+static struct irq_chip lapic_chip = {
23363 .name = "local-APIC",
23364 .irq_mask = mask_lapic_irq,
23365 .irq_unmask = unmask_lapic_irq,
23366diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c
23367index 1a9d735..c58b5c5 100644
23368--- a/arch/x86/kernel/apic/msi.c
23369+++ b/arch/x86/kernel/apic/msi.c
23370@@ -267,7 +267,7 @@ static void hpet_msi_write_msg(struct irq_data *data, struct msi_msg *msg)
23371 hpet_msi_write(data->handler_data, msg);
23372 }
23373
23374-static struct irq_chip hpet_msi_controller = {
23375+static irq_chip_no_const hpet_msi_controller __read_only = {
23376 .name = "HPET-MSI",
23377 .irq_unmask = hpet_msi_unmask,
23378 .irq_mask = hpet_msi_mask,
23379diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
23380index bda4886..f9c7195 100644
23381--- a/arch/x86/kernel/apic/probe_32.c
23382+++ b/arch/x86/kernel/apic/probe_32.c
23383@@ -72,7 +72,7 @@ static int probe_default(void)
23384 return 1;
23385 }
23386
23387-static struct apic apic_default = {
23388+static struct apic apic_default __read_only = {
23389
23390 .name = "default",
23391 .probe = probe_default,
23392diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
23393index 2683f36..0bdc74c 100644
23394--- a/arch/x86/kernel/apic/vector.c
23395+++ b/arch/x86/kernel/apic/vector.c
23396@@ -36,7 +36,7 @@ static struct irq_chip lapic_controller;
23397 static struct apic_chip_data *legacy_irq_data[NR_IRQS_LEGACY];
23398 #endif
23399
23400-void lock_vector_lock(void)
23401+void lock_vector_lock(void) __acquires(vector_lock)
23402 {
23403 /* Used to the online set of cpus does not change
23404 * during assign_irq_vector.
23405@@ -44,7 +44,7 @@ void lock_vector_lock(void)
23406 raw_spin_lock(&vector_lock);
23407 }
23408
23409-void unlock_vector_lock(void)
23410+void unlock_vector_lock(void) __releases(vector_lock)
23411 {
23412 raw_spin_unlock(&vector_lock);
23413 }
23414diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
23415index ab3219b..e8033eb 100644
23416--- a/arch/x86/kernel/apic/x2apic_cluster.c
23417+++ b/arch/x86/kernel/apic/x2apic_cluster.c
23418@@ -182,7 +182,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
23419 return notifier_from_errno(err);
23420 }
23421
23422-static struct notifier_block __refdata x2apic_cpu_notifier = {
23423+static struct notifier_block x2apic_cpu_notifier = {
23424 .notifier_call = update_clusterinfo,
23425 };
23426
23427@@ -234,7 +234,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
23428 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
23429 }
23430
23431-static struct apic apic_x2apic_cluster = {
23432+static struct apic apic_x2apic_cluster __read_only = {
23433
23434 .name = "cluster x2apic",
23435 .probe = x2apic_cluster_probe,
23436diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
23437index 3ffd925..8c0f5a8 100644
23438--- a/arch/x86/kernel/apic/x2apic_phys.c
23439+++ b/arch/x86/kernel/apic/x2apic_phys.c
23440@@ -90,7 +90,7 @@ static int x2apic_phys_probe(void)
23441 return apic == &apic_x2apic_phys;
23442 }
23443
23444-static struct apic apic_x2apic_phys = {
23445+static struct apic apic_x2apic_phys __read_only = {
23446
23447 .name = "physical x2apic",
23448 .probe = x2apic_phys_probe,
23449diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
23450index c8d9295..9af2d03 100644
23451--- a/arch/x86/kernel/apic/x2apic_uv_x.c
23452+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
23453@@ -375,7 +375,7 @@ static int uv_probe(void)
23454 return apic == &apic_x2apic_uv_x;
23455 }
23456
23457-static struct apic __refdata apic_x2apic_uv_x = {
23458+static struct apic apic_x2apic_uv_x __read_only = {
23459
23460 .name = "UV large system",
23461 .probe = uv_probe,
23462diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
23463index 927ec92..de68f32 100644
23464--- a/arch/x86/kernel/apm_32.c
23465+++ b/arch/x86/kernel/apm_32.c
23466@@ -432,7 +432,7 @@ static DEFINE_MUTEX(apm_mutex);
23467 * This is for buggy BIOS's that refer to (real mode) segment 0x40
23468 * even though they are called in protected mode.
23469 */
23470-static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
23471+static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
23472 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
23473
23474 static const char driver_version[] = "1.16ac"; /* no spaces */
23475@@ -610,7 +610,10 @@ static long __apm_bios_call(void *_call)
23476 BUG_ON(cpu != 0);
23477 gdt = get_cpu_gdt_table(cpu);
23478 save_desc_40 = gdt[0x40 / 8];
23479+
23480+ pax_open_kernel();
23481 gdt[0x40 / 8] = bad_bios_desc;
23482+ pax_close_kernel();
23483
23484 apm_irq_save(flags);
23485 APM_DO_SAVE_SEGS;
23486@@ -619,7 +622,11 @@ static long __apm_bios_call(void *_call)
23487 &call->esi);
23488 APM_DO_RESTORE_SEGS;
23489 apm_irq_restore(flags);
23490+
23491+ pax_open_kernel();
23492 gdt[0x40 / 8] = save_desc_40;
23493+ pax_close_kernel();
23494+
23495 put_cpu();
23496
23497 return call->eax & 0xff;
23498@@ -686,7 +693,10 @@ static long __apm_bios_call_simple(void *_call)
23499 BUG_ON(cpu != 0);
23500 gdt = get_cpu_gdt_table(cpu);
23501 save_desc_40 = gdt[0x40 / 8];
23502+
23503+ pax_open_kernel();
23504 gdt[0x40 / 8] = bad_bios_desc;
23505+ pax_close_kernel();
23506
23507 apm_irq_save(flags);
23508 APM_DO_SAVE_SEGS;
23509@@ -694,7 +704,11 @@ static long __apm_bios_call_simple(void *_call)
23510 &call->eax);
23511 APM_DO_RESTORE_SEGS;
23512 apm_irq_restore(flags);
23513+
23514+ pax_open_kernel();
23515 gdt[0x40 / 8] = save_desc_40;
23516+ pax_close_kernel();
23517+
23518 put_cpu();
23519 return error;
23520 }
23521@@ -2039,7 +2053,7 @@ static int __init swab_apm_power_in_minutes(const struct dmi_system_id *d)
23522 return 0;
23523 }
23524
23525-static struct dmi_system_id __initdata apm_dmi_table[] = {
23526+static const struct dmi_system_id __initconst apm_dmi_table[] = {
23527 {
23528 print_if_true,
23529 KERN_WARNING "IBM T23 - BIOS 1.03b+ and controller firmware 1.02+ may be needed for Linux APM.",
23530@@ -2349,12 +2363,15 @@ static int __init apm_init(void)
23531 * code to that CPU.
23532 */
23533 gdt = get_cpu_gdt_table(0);
23534+
23535+ pax_open_kernel();
23536 set_desc_base(&gdt[APM_CS >> 3],
23537 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
23538 set_desc_base(&gdt[APM_CS_16 >> 3],
23539 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
23540 set_desc_base(&gdt[APM_DS >> 3],
23541 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
23542+ pax_close_kernel();
23543
23544 proc_create("apm", 0, NULL, &apm_file_ops);
23545
23546diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
23547index 8e3d22a1..37118b6 100644
23548--- a/arch/x86/kernel/asm-offsets.c
23549+++ b/arch/x86/kernel/asm-offsets.c
23550@@ -32,6 +32,8 @@ void common(void) {
23551 OFFSET(TI_flags, thread_info, flags);
23552 OFFSET(TI_status, thread_info, status);
23553 OFFSET(TI_addr_limit, thread_info, addr_limit);
23554+ OFFSET(TI_lowest_stack, thread_info, lowest_stack);
23555+ DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
23556
23557 BLANK();
23558 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
23559@@ -73,8 +75,26 @@ void common(void) {
23560 #endif
23561 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
23562 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
23563+
23564+#ifdef CONFIG_PAX_KERNEXEC
23565+ OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
23566 #endif
23567
23568+#ifdef CONFIG_PAX_MEMORY_UDEREF
23569+ OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
23570+ OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
23571+#ifdef CONFIG_X86_64
23572+ OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
23573+#endif
23574+#endif
23575+
23576+#endif
23577+
23578+ BLANK();
23579+ DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
23580+ DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
23581+ DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
23582+
23583 #ifdef CONFIG_XEN
23584 BLANK();
23585 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
23586diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
23587index d8f42f9..a46f1fc 100644
23588--- a/arch/x86/kernel/asm-offsets_64.c
23589+++ b/arch/x86/kernel/asm-offsets_64.c
23590@@ -59,6 +59,7 @@ int main(void)
23591 BLANK();
23592 #undef ENTRY
23593
23594+ DEFINE(TSS_size, sizeof(struct tss_struct));
23595 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
23596 OFFSET(TSS_sp0, tss_struct, x86_tss.sp0);
23597 BLANK();
23598diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
23599index 9bff687..5b899fb 100644
23600--- a/arch/x86/kernel/cpu/Makefile
23601+++ b/arch/x86/kernel/cpu/Makefile
23602@@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
23603 CFLAGS_REMOVE_perf_event.o = -pg
23604 endif
23605
23606-# Make sure load_percpu_segment has no stackprotector
23607-nostackp := $(call cc-option, -fno-stack-protector)
23608-CFLAGS_common.o := $(nostackp)
23609-
23610 obj-y := intel_cacheinfo.o scattered.o topology.o
23611 obj-y += common.o
23612 obj-y += rdrand.o
23613diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
23614index dd3a4ba..06672af 100644
23615--- a/arch/x86/kernel/cpu/amd.c
23616+++ b/arch/x86/kernel/cpu/amd.c
23617@@ -750,7 +750,7 @@ static void init_amd(struct cpuinfo_x86 *c)
23618 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
23619 {
23620 /* AMD errata T13 (order #21922) */
23621- if ((c->x86 == 6)) {
23622+ if (c->x86 == 6) {
23623 /* Duron Rev A0 */
23624 if (c->x86_model == 3 && c->x86_mask == 0)
23625 size = 64;
23626diff --git a/arch/x86/kernel/cpu/bugs_64.c b/arch/x86/kernel/cpu/bugs_64.c
23627index 04f0fe5..3c0598c 100644
23628--- a/arch/x86/kernel/cpu/bugs_64.c
23629+++ b/arch/x86/kernel/cpu/bugs_64.c
23630@@ -10,6 +10,7 @@
23631 #include <asm/processor.h>
23632 #include <asm/mtrr.h>
23633 #include <asm/cacheflush.h>
23634+#include <asm/sections.h>
23635
23636 void __init check_bugs(void)
23637 {
23638@@ -18,6 +19,7 @@ void __init check_bugs(void)
23639 printk(KERN_INFO "CPU: ");
23640 print_cpu_info(&boot_cpu_data);
23641 #endif
23642+ set_memory_nx((unsigned long)_sinitdata, (__START_KERNEL_map + KERNEL_IMAGE_SIZE - (unsigned long)_sinitdata) >> PAGE_SHIFT);
23643 alternative_instructions();
23644
23645 /*
23646diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
23647index cb9e5df..0d25636 100644
23648--- a/arch/x86/kernel/cpu/common.c
23649+++ b/arch/x86/kernel/cpu/common.c
23650@@ -91,60 +91,6 @@ static const struct cpu_dev default_cpu = {
23651
23652 static const struct cpu_dev *this_cpu = &default_cpu;
23653
23654-DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
23655-#ifdef CONFIG_X86_64
23656- /*
23657- * We need valid kernel segments for data and code in long mode too
23658- * IRET will check the segment types kkeil 2000/10/28
23659- * Also sysret mandates a special GDT layout
23660- *
23661- * TLS descriptors are currently at a different place compared to i386.
23662- * Hopefully nobody expects them at a fixed place (Wine?)
23663- */
23664- [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
23665- [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
23666- [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
23667- [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
23668- [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
23669- [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
23670-#else
23671- [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
23672- [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
23673- [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
23674- [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
23675- /*
23676- * Segments used for calling PnP BIOS have byte granularity.
23677- * They code segments and data segments have fixed 64k limits,
23678- * the transfer segment sizes are set at run time.
23679- */
23680- /* 32-bit code */
23681- [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
23682- /* 16-bit code */
23683- [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
23684- /* 16-bit data */
23685- [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
23686- /* 16-bit data */
23687- [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
23688- /* 16-bit data */
23689- [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
23690- /*
23691- * The APM segments have byte granularity and their bases
23692- * are set at run time. All have 64k limits.
23693- */
23694- /* 32-bit code */
23695- [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
23696- /* 16-bit code */
23697- [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
23698- /* data */
23699- [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
23700-
23701- [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
23702- [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
23703- GDT_STACK_CANARY_INIT
23704-#endif
23705-} };
23706-EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
23707-
23708 static int __init x86_mpx_setup(char *s)
23709 {
23710 /* require an exact match without trailing characters */
23711@@ -287,6 +233,109 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
23712 }
23713 }
23714
23715+#ifdef CONFIG_PAX_MEMORY_UDEREF
23716+#ifdef CONFIG_X86_64
23717+static bool uderef_enabled __read_only = true;
23718+unsigned long pax_user_shadow_base __read_only;
23719+EXPORT_SYMBOL(pax_user_shadow_base);
23720+extern char pax_enter_kernel_user[];
23721+extern char pax_exit_kernel_user[];
23722+
23723+static int __init setup_pax_weakuderef(char *str)
23724+{
23725+ if (uderef_enabled)
23726+ pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
23727+ return 1;
23728+}
23729+__setup("pax_weakuderef", setup_pax_weakuderef);
23730+#endif
23731+
23732+static int __init setup_pax_nouderef(char *str)
23733+{
23734+#ifdef CONFIG_X86_32
23735+ unsigned int cpu;
23736+ struct desc_struct *gdt;
23737+
23738+ for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
23739+ gdt = get_cpu_gdt_table(cpu);
23740+ gdt[GDT_ENTRY_KERNEL_DS].type = 3;
23741+ gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
23742+ gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
23743+ gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
23744+ }
23745+ loadsegment(ds, __KERNEL_DS);
23746+ loadsegment(es, __KERNEL_DS);
23747+ loadsegment(ss, __KERNEL_DS);
23748+#else
23749+ memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
23750+ memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
23751+ clone_pgd_mask = ~(pgdval_t)0UL;
23752+ pax_user_shadow_base = 0UL;
23753+ setup_clear_cpu_cap(X86_FEATURE_PCIDUDEREF);
23754+ uderef_enabled = false;
23755+#endif
23756+
23757+ return 0;
23758+}
23759+early_param("pax_nouderef", setup_pax_nouderef);
23760+#endif
23761+
23762+#ifdef CONFIG_X86_64
23763+static __init int setup_disable_pcid(char *arg)
23764+{
23765+ setup_clear_cpu_cap(X86_FEATURE_PCID);
23766+ setup_clear_cpu_cap(X86_FEATURE_INVPCID);
23767+
23768+#ifdef CONFIG_PAX_MEMORY_UDEREF
23769+ if (uderef_enabled)
23770+ pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
23771+#endif
23772+
23773+ return 1;
23774+}
23775+__setup("nopcid", setup_disable_pcid);
23776+
23777+static void setup_pcid(struct cpuinfo_x86 *c)
23778+{
23779+ if (cpu_has(c, X86_FEATURE_PCID)) {
23780+ printk("PAX: PCID detected\n");
23781+ cr4_set_bits(X86_CR4_PCIDE);
23782+ } else
23783+ clear_cpu_cap(c, X86_FEATURE_INVPCID);
23784+
23785+ if (cpu_has(c, X86_FEATURE_INVPCID))
23786+ printk("PAX: INVPCID detected\n");
23787+
23788+#ifdef CONFIG_PAX_MEMORY_UDEREF
23789+ if (!uderef_enabled) {
23790+ printk("PAX: UDEREF disabled\n");
23791+ return;
23792+ }
23793+
23794+ if (!cpu_has(c, X86_FEATURE_PCID)) {
23795+ pax_open_kernel();
23796+ pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
23797+ pax_close_kernel();
23798+ printk("PAX: slow and weak UDEREF enabled\n");
23799+ return;
23800+ }
23801+
23802+ set_cpu_cap(c, X86_FEATURE_PCIDUDEREF);
23803+
23804+ pax_open_kernel();
23805+ clone_pgd_mask = ~(pgdval_t)0UL;
23806+ pax_close_kernel();
23807+ if (pax_user_shadow_base)
23808+ printk("PAX: weak UDEREF enabled\n");
23809+ else {
23810+ set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
23811+ printk("PAX: strong UDEREF enabled\n");
23812+ }
23813+#endif
23814+
23815+}
23816+#endif
23817+
23818 /*
23819 * Some CPU features depend on higher CPUID levels, which may not always
23820 * be available due to CPUID level capping or broken virtualization
23821@@ -387,7 +436,7 @@ void switch_to_new_gdt(int cpu)
23822 {
23823 struct desc_ptr gdt_descr;
23824
23825- gdt_descr.address = (long)get_cpu_gdt_table(cpu);
23826+ gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
23827 gdt_descr.size = GDT_SIZE - 1;
23828 load_gdt(&gdt_descr);
23829 /* Reload the per-cpu base */
23830@@ -918,6 +967,20 @@ static void identify_cpu(struct cpuinfo_x86 *c)
23831 setup_smep(c);
23832 setup_smap(c);
23833
23834+#ifdef CONFIG_X86_32
23835+#ifdef CONFIG_PAX_PAGEEXEC
23836+ if (!(__supported_pte_mask & _PAGE_NX))
23837+ clear_cpu_cap(c, X86_FEATURE_PSE);
23838+#endif
23839+#if defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
23840+ clear_cpu_cap(c, X86_FEATURE_SEP);
23841+#endif
23842+#endif
23843+
23844+#ifdef CONFIG_X86_64
23845+ setup_pcid(c);
23846+#endif
23847+
23848 /*
23849 * The vendor-specific functions might have changed features.
23850 * Now we do "generic changes."
23851@@ -992,7 +1055,7 @@ void enable_sep_cpu(void)
23852 int cpu;
23853
23854 cpu = get_cpu();
23855- tss = &per_cpu(cpu_tss, cpu);
23856+ tss = cpu_tss + cpu;
23857
23858 if (!boot_cpu_has(X86_FEATURE_SEP))
23859 goto out;
23860@@ -1138,10 +1201,12 @@ static __init int setup_disablecpuid(char *arg)
23861 }
23862 __setup("clearcpuid=", setup_disablecpuid);
23863
23864+DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
23865+EXPORT_PER_CPU_SYMBOL(current_tinfo);
23866+
23867 #ifdef CONFIG_X86_64
23868-struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
23869-struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
23870- (unsigned long) debug_idt_table };
23871+struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
23872+const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
23873
23874 DEFINE_PER_CPU_FIRST(union irq_stack_union,
23875 irq_stack_union) __aligned(PAGE_SIZE) __visible;
23876@@ -1253,21 +1318,21 @@ EXPORT_PER_CPU_SYMBOL(current_task);
23877 DEFINE_PER_CPU(int, __preempt_count) = INIT_PREEMPT_COUNT;
23878 EXPORT_PER_CPU_SYMBOL(__preempt_count);
23879
23880+#ifdef CONFIG_CC_STACKPROTECTOR
23881+DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
23882+#endif
23883+
23884+#endif /* CONFIG_X86_64 */
23885+
23886 /*
23887 * On x86_32, vm86 modifies tss.sp0, so sp0 isn't a reliable way to find
23888 * the top of the kernel stack. Use an extra percpu variable to track the
23889 * top of the kernel stack directly.
23890 */
23891 DEFINE_PER_CPU(unsigned long, cpu_current_top_of_stack) =
23892- (unsigned long)&init_thread_union + THREAD_SIZE;
23893+ (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
23894 EXPORT_PER_CPU_SYMBOL(cpu_current_top_of_stack);
23895
23896-#ifdef CONFIG_CC_STACKPROTECTOR
23897-DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
23898-#endif
23899-
23900-#endif /* CONFIG_X86_64 */
23901-
23902 /*
23903 * Clear all 6 debug registers:
23904 */
23905@@ -1343,7 +1408,7 @@ void cpu_init(void)
23906 */
23907 load_ucode_ap();
23908
23909- t = &per_cpu(cpu_tss, cpu);
23910+ t = cpu_tss + cpu;
23911 oist = &per_cpu(orig_ist, cpu);
23912
23913 #ifdef CONFIG_NUMA
23914@@ -1375,7 +1440,6 @@ void cpu_init(void)
23915 wrmsrl(MSR_KERNEL_GS_BASE, 0);
23916 barrier();
23917
23918- x86_configure_nx();
23919 x2apic_setup();
23920
23921 /*
23922@@ -1427,7 +1491,7 @@ void cpu_init(void)
23923 {
23924 int cpu = smp_processor_id();
23925 struct task_struct *curr = current;
23926- struct tss_struct *t = &per_cpu(cpu_tss, cpu);
23927+ struct tss_struct *t = cpu_tss + cpu;
23928 struct thread_struct *thread = &curr->thread;
23929
23930 wait_for_master_cpu(cpu);
23931diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
23932index be4febc..f7af533 100644
23933--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
23934+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
23935@@ -519,25 +519,23 @@ cache_private_attrs_is_visible(struct kobject *kobj,
23936 return 0;
23937 }
23938
23939+static struct attribute *amd_l3_attrs[4];
23940+
23941 static struct attribute_group cache_private_group = {
23942 .is_visible = cache_private_attrs_is_visible,
23943+ .attrs = amd_l3_attrs,
23944 };
23945
23946 static void init_amd_l3_attrs(void)
23947 {
23948 int n = 1;
23949- static struct attribute **amd_l3_attrs;
23950-
23951- if (amd_l3_attrs) /* already initialized */
23952- return;
23953
23954 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
23955 n += 2;
23956 if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
23957 n += 1;
23958
23959- amd_l3_attrs = kcalloc(n, sizeof(*amd_l3_attrs), GFP_KERNEL);
23960- if (!amd_l3_attrs)
23961+ if (n > 1 && amd_l3_attrs[0]) /* already initialized */
23962 return;
23963
23964 n = 0;
23965@@ -547,8 +545,6 @@ static void init_amd_l3_attrs(void)
23966 }
23967 if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
23968 amd_l3_attrs[n++] = &dev_attr_subcaches.attr;
23969-
23970- cache_private_group.attrs = amd_l3_attrs;
23971 }
23972
23973 const struct attribute_group *
23974@@ -559,7 +555,7 @@ cache_get_priv_group(struct cacheinfo *this_leaf)
23975 if (this_leaf->level < 3 || !nb)
23976 return NULL;
23977
23978- if (nb && nb->l3_cache.indices)
23979+ if (nb->l3_cache.indices)
23980 init_amd_l3_attrs();
23981
23982 return &cache_private_group;
23983diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
23984index df919ff..3332bf7 100644
23985--- a/arch/x86/kernel/cpu/mcheck/mce.c
23986+++ b/arch/x86/kernel/cpu/mcheck/mce.c
23987@@ -47,6 +47,7 @@
23988 #include <asm/tlbflush.h>
23989 #include <asm/mce.h>
23990 #include <asm/msr.h>
23991+#include <asm/local.h>
23992
23993 #include "mce-internal.h"
23994
23995@@ -259,7 +260,7 @@ static void print_mce(struct mce *m)
23996 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
23997 m->cs, m->ip);
23998
23999- if (m->cs == __KERNEL_CS)
24000+ if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
24001 print_symbol("{%s}", m->ip);
24002 pr_cont("\n");
24003 }
24004@@ -292,10 +293,10 @@ static void print_mce(struct mce *m)
24005
24006 #define PANIC_TIMEOUT 5 /* 5 seconds */
24007
24008-static atomic_t mce_panicked;
24009+static atomic_unchecked_t mce_panicked;
24010
24011 static int fake_panic;
24012-static atomic_t mce_fake_panicked;
24013+static atomic_unchecked_t mce_fake_panicked;
24014
24015 /* Panic in progress. Enable interrupts and wait for final IPI */
24016 static void wait_for_panic(void)
24017@@ -319,7 +320,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp)
24018 /*
24019 * Make sure only one CPU runs in machine check panic
24020 */
24021- if (atomic_inc_return(&mce_panicked) > 1)
24022+ if (atomic_inc_return_unchecked(&mce_panicked) > 1)
24023 wait_for_panic();
24024 barrier();
24025
24026@@ -327,7 +328,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp)
24027 console_verbose();
24028 } else {
24029 /* Don't log too much for fake panic */
24030- if (atomic_inc_return(&mce_fake_panicked) > 1)
24031+ if (atomic_inc_return_unchecked(&mce_fake_panicked) > 1)
24032 return;
24033 }
24034 /* First print corrected ones that are still unlogged */
24035@@ -366,7 +367,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp)
24036 if (!fake_panic) {
24037 if (panic_timeout == 0)
24038 panic_timeout = mca_cfg.panic_timeout;
24039- panic(msg);
24040+ panic("%s", msg);
24041 } else
24042 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
24043 }
24044@@ -752,7 +753,7 @@ static int mce_timed_out(u64 *t, const char *msg)
24045 * might have been modified by someone else.
24046 */
24047 rmb();
24048- if (atomic_read(&mce_panicked))
24049+ if (atomic_read_unchecked(&mce_panicked))
24050 wait_for_panic();
24051 if (!mca_cfg.monarch_timeout)
24052 goto out;
24053@@ -1708,7 +1709,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
24054 }
24055
24056 /* Call the installed machine check handler for this CPU setup. */
24057-void (*machine_check_vector)(struct pt_regs *, long error_code) =
24058+void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
24059 unexpected_machine_check;
24060
24061 /*
24062@@ -1731,7 +1732,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
24063 return;
24064 }
24065
24066+ pax_open_kernel();
24067 machine_check_vector = do_machine_check;
24068+ pax_close_kernel();
24069
24070 __mcheck_cpu_init_generic();
24071 __mcheck_cpu_init_vendor(c);
24072@@ -1745,7 +1748,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
24073 */
24074
24075 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
24076-static int mce_chrdev_open_count; /* #times opened */
24077+static local_t mce_chrdev_open_count; /* #times opened */
24078 static int mce_chrdev_open_exclu; /* already open exclusive? */
24079
24080 static int mce_chrdev_open(struct inode *inode, struct file *file)
24081@@ -1753,7 +1756,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
24082 spin_lock(&mce_chrdev_state_lock);
24083
24084 if (mce_chrdev_open_exclu ||
24085- (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
24086+ (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
24087 spin_unlock(&mce_chrdev_state_lock);
24088
24089 return -EBUSY;
24090@@ -1761,7 +1764,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
24091
24092 if (file->f_flags & O_EXCL)
24093 mce_chrdev_open_exclu = 1;
24094- mce_chrdev_open_count++;
24095+ local_inc(&mce_chrdev_open_count);
24096
24097 spin_unlock(&mce_chrdev_state_lock);
24098
24099@@ -1772,7 +1775,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
24100 {
24101 spin_lock(&mce_chrdev_state_lock);
24102
24103- mce_chrdev_open_count--;
24104+ local_dec(&mce_chrdev_open_count);
24105 mce_chrdev_open_exclu = 0;
24106
24107 spin_unlock(&mce_chrdev_state_lock);
24108@@ -2448,7 +2451,7 @@ static __init void mce_init_banks(void)
24109
24110 for (i = 0; i < mca_cfg.banks; i++) {
24111 struct mce_bank *b = &mce_banks[i];
24112- struct device_attribute *a = &b->attr;
24113+ device_attribute_no_const *a = &b->attr;
24114
24115 sysfs_attr_init(&a->attr);
24116 a->attr.name = b->attrname;
24117@@ -2555,7 +2558,7 @@ struct dentry *mce_get_debugfs_dir(void)
24118 static void mce_reset(void)
24119 {
24120 cpu_missing = 0;
24121- atomic_set(&mce_fake_panicked, 0);
24122+ atomic_set_unchecked(&mce_fake_panicked, 0);
24123 atomic_set(&mce_executing, 0);
24124 atomic_set(&mce_callin, 0);
24125 atomic_set(&global_nwo, 0);
24126diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
24127index 737b0ad..09ec66e 100644
24128--- a/arch/x86/kernel/cpu/mcheck/p5.c
24129+++ b/arch/x86/kernel/cpu/mcheck/p5.c
24130@@ -12,6 +12,7 @@
24131 #include <asm/tlbflush.h>
24132 #include <asm/mce.h>
24133 #include <asm/msr.h>
24134+#include <asm/pgtable.h>
24135
24136 /* By default disabled */
24137 int mce_p5_enabled __read_mostly;
24138@@ -55,7 +56,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
24139 if (!cpu_has(c, X86_FEATURE_MCE))
24140 return;
24141
24142+ pax_open_kernel();
24143 machine_check_vector = pentium_machine_check;
24144+ pax_close_kernel();
24145 /* Make sure the vector pointer is visible before we enable MCEs: */
24146 wmb();
24147
24148diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
24149index 44f1382..315b292 100644
24150--- a/arch/x86/kernel/cpu/mcheck/winchip.c
24151+++ b/arch/x86/kernel/cpu/mcheck/winchip.c
24152@@ -11,6 +11,7 @@
24153 #include <asm/tlbflush.h>
24154 #include <asm/mce.h>
24155 #include <asm/msr.h>
24156+#include <asm/pgtable.h>
24157
24158 /* Machine check handler for WinChip C6: */
24159 static void winchip_machine_check(struct pt_regs *regs, long error_code)
24160@@ -28,7 +29,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
24161 {
24162 u32 lo, hi;
24163
24164+ pax_open_kernel();
24165 machine_check_vector = winchip_machine_check;
24166+ pax_close_kernel();
24167 /* Make sure the vector pointer is visible before we enable MCEs: */
24168 wmb();
24169
24170diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
24171index 6236a54..532026d 100644
24172--- a/arch/x86/kernel/cpu/microcode/core.c
24173+++ b/arch/x86/kernel/cpu/microcode/core.c
24174@@ -460,7 +460,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24175 return NOTIFY_OK;
24176 }
24177
24178-static struct notifier_block __refdata mc_cpu_notifier = {
24179+static struct notifier_block mc_cpu_notifier = {
24180 .notifier_call = mc_cpu_callback,
24181 };
24182
24183diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
24184index 969dc17..a9c3fdd 100644
24185--- a/arch/x86/kernel/cpu/microcode/intel.c
24186+++ b/arch/x86/kernel/cpu/microcode/intel.c
24187@@ -237,13 +237,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24188
24189 static int get_ucode_user(void *to, const void *from, size_t n)
24190 {
24191- return copy_from_user(to, from, n);
24192+ return copy_from_user(to, (const void __force_user *)from, n);
24193 }
24194
24195 static enum ucode_state
24196 request_microcode_user(int cpu, const void __user *buf, size_t size)
24197 {
24198- return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24199+ return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24200 }
24201
24202 static void microcode_fini_cpu(int cpu)
24203diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
24204index e7ed0d8..57a2ab9 100644
24205--- a/arch/x86/kernel/cpu/mtrr/main.c
24206+++ b/arch/x86/kernel/cpu/mtrr/main.c
24207@@ -72,7 +72,7 @@ static DEFINE_MUTEX(mtrr_mutex);
24208 u64 size_or_mask, size_and_mask;
24209 static bool mtrr_aps_delayed_init;
24210
24211-static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
24212+static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
24213
24214 const struct mtrr_ops *mtrr_if;
24215
24216diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
24217index 951884d..4796b75 100644
24218--- a/arch/x86/kernel/cpu/mtrr/mtrr.h
24219+++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
24220@@ -25,7 +25,7 @@ struct mtrr_ops {
24221 int (*validate_add_page)(unsigned long base, unsigned long size,
24222 unsigned int type);
24223 int (*have_wrcomb)(void);
24224-};
24225+} __do_const;
24226
24227 extern int generic_get_free_region(unsigned long base, unsigned long size,
24228 int replace_reg);
24229diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
24230index 9469dfa..2b026bc 100644
24231--- a/arch/x86/kernel/cpu/perf_event.c
24232+++ b/arch/x86/kernel/cpu/perf_event.c
24233@@ -1518,7 +1518,7 @@ static void __init pmu_check_apic(void)
24234
24235 }
24236
24237-static struct attribute_group x86_pmu_format_group = {
24238+static attribute_group_no_const x86_pmu_format_group = {
24239 .name = "format",
24240 .attrs = NULL,
24241 };
24242@@ -1617,7 +1617,7 @@ static struct attribute *events_attr[] = {
24243 NULL,
24244 };
24245
24246-static struct attribute_group x86_pmu_events_group = {
24247+static attribute_group_no_const x86_pmu_events_group = {
24248 .name = "events",
24249 .attrs = events_attr,
24250 };
24251@@ -2176,7 +2176,7 @@ valid_user_frame(const void __user *fp, unsigned long size)
24252 static unsigned long get_segment_base(unsigned int segment)
24253 {
24254 struct desc_struct *desc;
24255- int idx = segment >> 3;
24256+ unsigned int idx = segment >> 3;
24257
24258 if ((segment & SEGMENT_TI_MASK) == SEGMENT_LDT) {
24259 struct ldt_struct *ldt;
24260@@ -2194,7 +2194,7 @@ static unsigned long get_segment_base(unsigned int segment)
24261 if (idx > GDT_ENTRIES)
24262 return 0;
24263
24264- desc = raw_cpu_ptr(gdt_page.gdt) + idx;
24265+ desc = get_cpu_gdt_table(smp_processor_id()) + idx;
24266 }
24267
24268 return get_desc_base(desc);
24269@@ -2284,7 +2284,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
24270 break;
24271
24272 perf_callchain_store(entry, frame.return_address);
24273- fp = frame.next_frame;
24274+ fp = (const void __force_user *)frame.next_frame;
24275 }
24276 }
24277
24278diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
24279index 97242a9..cf9c30e 100644
24280--- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
24281+++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
24282@@ -402,7 +402,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
24283 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
24284 {
24285 struct attribute **attrs;
24286- struct attribute_group *attr_group;
24287+ attribute_group_no_const *attr_group;
24288 int i = 0, j;
24289
24290 while (amd_iommu_v2_event_descs[i].attr.attr.name)
24291diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
24292index 1b09c42..521004d 100644
24293--- a/arch/x86/kernel/cpu/perf_event_intel.c
24294+++ b/arch/x86/kernel/cpu/perf_event_intel.c
24295@@ -3019,10 +3019,10 @@ __init int intel_pmu_init(void)
24296 x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
24297
24298 if (boot_cpu_has(X86_FEATURE_PDCM)) {
24299- u64 capabilities;
24300+ u64 capabilities = x86_pmu.intel_cap.capabilities;
24301
24302- rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
24303- x86_pmu.intel_cap.capabilities = capabilities;
24304+ if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
24305+ x86_pmu.intel_cap.capabilities = capabilities;
24306 }
24307
24308 intel_ds_init();
24309diff --git a/arch/x86/kernel/cpu/perf_event_intel_bts.c b/arch/x86/kernel/cpu/perf_event_intel_bts.c
24310index 43dd672..78c0562 100644
24311--- a/arch/x86/kernel/cpu/perf_event_intel_bts.c
24312+++ b/arch/x86/kernel/cpu/perf_event_intel_bts.c
24313@@ -252,7 +252,7 @@ static void bts_event_start(struct perf_event *event, int flags)
24314 __bts_event_start(event);
24315
24316 /* PMI handler: this counter is running and likely generating PMIs */
24317- ACCESS_ONCE(bts->started) = 1;
24318+ ACCESS_ONCE_RW(bts->started) = 1;
24319 }
24320
24321 static void __bts_event_stop(struct perf_event *event)
24322@@ -266,7 +266,7 @@ static void __bts_event_stop(struct perf_event *event)
24323 if (event->hw.state & PERF_HES_STOPPED)
24324 return;
24325
24326- ACCESS_ONCE(event->hw.state) |= PERF_HES_STOPPED;
24327+ ACCESS_ONCE_RW(event->hw.state) |= PERF_HES_STOPPED;
24328 }
24329
24330 static void bts_event_stop(struct perf_event *event, int flags)
24331@@ -274,7 +274,7 @@ static void bts_event_stop(struct perf_event *event, int flags)
24332 struct bts_ctx *bts = this_cpu_ptr(&bts_ctx);
24333
24334 /* PMI handler: don't restart this counter */
24335- ACCESS_ONCE(bts->started) = 0;
24336+ ACCESS_ONCE_RW(bts->started) = 0;
24337
24338 __bts_event_stop(event);
24339
24340diff --git a/arch/x86/kernel/cpu/perf_event_intel_cqm.c b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
24341index 377e8f8..2982f48 100644
24342--- a/arch/x86/kernel/cpu/perf_event_intel_cqm.c
24343+++ b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
24344@@ -1364,7 +1364,9 @@ static int __init intel_cqm_init(void)
24345 goto out;
24346 }
24347
24348- event_attr_intel_cqm_llc_scale.event_str = str;
24349+ pax_open_kernel();
24350+ *(const char **)&event_attr_intel_cqm_llc_scale.event_str = str;
24351+ pax_close_kernel();
24352
24353 ret = intel_cqm_setup_rmid_cache();
24354 if (ret)
24355diff --git a/arch/x86/kernel/cpu/perf_event_intel_pt.c b/arch/x86/kernel/cpu/perf_event_intel_pt.c
24356index 183de71..bd34d52 100644
24357--- a/arch/x86/kernel/cpu/perf_event_intel_pt.c
24358+++ b/arch/x86/kernel/cpu/perf_event_intel_pt.c
24359@@ -116,16 +116,12 @@ static const struct attribute_group *pt_attr_groups[] = {
24360
24361 static int __init pt_pmu_hw_init(void)
24362 {
24363- struct dev_ext_attribute *de_attrs;
24364- struct attribute **attrs;
24365- size_t size;
24366- int ret;
24367+ static struct dev_ext_attribute de_attrs[ARRAY_SIZE(pt_caps)];
24368+ static struct attribute *attrs[ARRAY_SIZE(pt_caps)];
24369 long i;
24370
24371- attrs = NULL;
24372- ret = -ENODEV;
24373 if (!test_cpu_cap(&boot_cpu_data, X86_FEATURE_INTEL_PT))
24374- goto fail;
24375+ return -ENODEV;
24376
24377 for (i = 0; i < PT_CPUID_LEAVES; i++) {
24378 cpuid_count(20, i,
24379@@ -135,39 +131,25 @@ static int __init pt_pmu_hw_init(void)
24380 &pt_pmu.caps[CR_EDX + i*4]);
24381 }
24382
24383- ret = -ENOMEM;
24384- size = sizeof(struct attribute *) * (ARRAY_SIZE(pt_caps)+1);
24385- attrs = kzalloc(size, GFP_KERNEL);
24386- if (!attrs)
24387- goto fail;
24388-
24389- size = sizeof(struct dev_ext_attribute) * (ARRAY_SIZE(pt_caps)+1);
24390- de_attrs = kzalloc(size, GFP_KERNEL);
24391- if (!de_attrs)
24392- goto fail;
24393-
24394+ pax_open_kernel();
24395 for (i = 0; i < ARRAY_SIZE(pt_caps); i++) {
24396- struct dev_ext_attribute *de_attr = de_attrs + i;
24397+ struct dev_ext_attribute *de_attr = &de_attrs[i];
24398
24399- de_attr->attr.attr.name = pt_caps[i].name;
24400+ *(const char **)&de_attr->attr.attr.name = pt_caps[i].name;
24401
24402 sysfs_attr_init(&de_attr->attr.attr);
24403
24404- de_attr->attr.attr.mode = S_IRUGO;
24405- de_attr->attr.show = pt_cap_show;
24406- de_attr->var = (void *)i;
24407+ *(umode_t *)&de_attr->attr.attr.mode = S_IRUGO;
24408+ *(void **)&de_attr->attr.show = pt_cap_show;
24409+ *(void **)&de_attr->var = (void *)i;
24410
24411 attrs[i] = &de_attr->attr.attr;
24412 }
24413
24414- pt_cap_group.attrs = attrs;
24415+ *(struct attribute ***)&pt_cap_group.attrs = attrs;
24416+ pax_close_kernel();
24417
24418 return 0;
24419-
24420-fail:
24421- kfree(attrs);
24422-
24423- return ret;
24424 }
24425
24426 #define PT_CONFIG_MASK (RTIT_CTL_TSC_EN | RTIT_CTL_DISRETC)
24427@@ -929,7 +911,7 @@ static void pt_event_start(struct perf_event *event, int mode)
24428 return;
24429 }
24430
24431- ACCESS_ONCE(pt->handle_nmi) = 1;
24432+ ACCESS_ONCE_RW(pt->handle_nmi) = 1;
24433 event->hw.state = 0;
24434
24435 pt_config_buffer(buf->cur->table, buf->cur_idx,
24436@@ -946,7 +928,7 @@ static void pt_event_stop(struct perf_event *event, int mode)
24437 * Protect against the PMI racing with disabling wrmsr,
24438 * see comment in intel_pt_interrupt().
24439 */
24440- ACCESS_ONCE(pt->handle_nmi) = 0;
24441+ ACCESS_ONCE_RW(pt->handle_nmi) = 0;
24442 pt_config_start(false);
24443
24444 if (event->hw.state == PERF_HES_STOPPED)
24445diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
24446index 5cbd4e6..ee9388a 100644
24447--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
24448+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
24449@@ -486,7 +486,7 @@ static struct attribute *rapl_events_hsw_attr[] = {
24450 NULL,
24451 };
24452
24453-static struct attribute_group rapl_pmu_events_group = {
24454+static attribute_group_no_const rapl_pmu_events_group __read_only = {
24455 .name = "events",
24456 .attrs = NULL, /* patched at runtime */
24457 };
24458diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
24459index 21b5e38..84f1f82 100644
24460--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
24461+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
24462@@ -731,7 +731,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
24463 static int __init uncore_type_init(struct intel_uncore_type *type)
24464 {
24465 struct intel_uncore_pmu *pmus;
24466- struct attribute_group *attr_group;
24467+ attribute_group_no_const *attr_group;
24468 struct attribute **attrs;
24469 int i, j;
24470
24471diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
24472index 0f77f0a..d3c6b7d 100644
24473--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
24474+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
24475@@ -115,7 +115,7 @@ struct intel_uncore_box {
24476 struct uncore_event_desc {
24477 struct kobj_attribute attr;
24478 const char *config;
24479-};
24480+} __do_const;
24481
24482 ssize_t uncore_event_show(struct kobject *kobj,
24483 struct kobj_attribute *attr, char *buf);
24484diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
24485index 83741a7..bd3507d 100644
24486--- a/arch/x86/kernel/cpuid.c
24487+++ b/arch/x86/kernel/cpuid.c
24488@@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
24489 return notifier_from_errno(err);
24490 }
24491
24492-static struct notifier_block __refdata cpuid_class_cpu_notifier =
24493+static struct notifier_block cpuid_class_cpu_notifier =
24494 {
24495 .notifier_call = cpuid_class_cpu_callback,
24496 };
24497diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
24498index afa64ad..dce67dd 100644
24499--- a/arch/x86/kernel/crash_dump_64.c
24500+++ b/arch/x86/kernel/crash_dump_64.c
24501@@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
24502 return -ENOMEM;
24503
24504 if (userbuf) {
24505- if (copy_to_user(buf, vaddr + offset, csize)) {
24506+ if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
24507 iounmap(vaddr);
24508 return -EFAULT;
24509 }
24510diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
24511index f6dfd93..892ade4 100644
24512--- a/arch/x86/kernel/doublefault.c
24513+++ b/arch/x86/kernel/doublefault.c
24514@@ -12,7 +12,7 @@
24515
24516 #define DOUBLEFAULT_STACKSIZE (1024)
24517 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
24518-#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
24519+#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
24520
24521 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
24522
24523@@ -22,7 +22,7 @@ static void doublefault_fn(void)
24524 unsigned long gdt, tss;
24525
24526 native_store_gdt(&gdt_desc);
24527- gdt = gdt_desc.address;
24528+ gdt = (unsigned long)gdt_desc.address;
24529
24530 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
24531
24532@@ -59,10 +59,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
24533 /* 0x2 bit is always set */
24534 .flags = X86_EFLAGS_SF | 0x2,
24535 .sp = STACK_START,
24536- .es = __USER_DS,
24537+ .es = __KERNEL_DS,
24538 .cs = __KERNEL_CS,
24539 .ss = __KERNEL_DS,
24540- .ds = __USER_DS,
24541+ .ds = __KERNEL_DS,
24542 .fs = __KERNEL_PERCPU,
24543
24544 .__cr3 = __pa_nodebug(swapper_pg_dir),
24545diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
24546index 9c30acf..8cf2411 100644
24547--- a/arch/x86/kernel/dumpstack.c
24548+++ b/arch/x86/kernel/dumpstack.c
24549@@ -2,6 +2,9 @@
24550 * Copyright (C) 1991, 1992 Linus Torvalds
24551 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
24552 */
24553+#ifdef CONFIG_GRKERNSEC_HIDESYM
24554+#define __INCLUDED_BY_HIDESYM 1
24555+#endif
24556 #include <linux/kallsyms.h>
24557 #include <linux/kprobes.h>
24558 #include <linux/uaccess.h>
24559@@ -35,23 +38,21 @@ static void printk_stack_address(unsigned long address, int reliable,
24560
24561 void printk_address(unsigned long address)
24562 {
24563- pr_cont(" [<%p>] %pS\n", (void *)address, (void *)address);
24564+ pr_cont(" [<%p>] %pA\n", (void *)address, (void *)address);
24565 }
24566
24567 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
24568 static void
24569 print_ftrace_graph_addr(unsigned long addr, void *data,
24570 const struct stacktrace_ops *ops,
24571- struct thread_info *tinfo, int *graph)
24572+ struct task_struct *task, int *graph)
24573 {
24574- struct task_struct *task;
24575 unsigned long ret_addr;
24576 int index;
24577
24578 if (addr != (unsigned long)return_to_handler)
24579 return;
24580
24581- task = tinfo->task;
24582 index = task->curr_ret_stack;
24583
24584 if (!task->ret_stack || index < *graph)
24585@@ -68,7 +69,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
24586 static inline void
24587 print_ftrace_graph_addr(unsigned long addr, void *data,
24588 const struct stacktrace_ops *ops,
24589- struct thread_info *tinfo, int *graph)
24590+ struct task_struct *task, int *graph)
24591 { }
24592 #endif
24593
24594@@ -79,10 +80,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
24595 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
24596 */
24597
24598-static inline int valid_stack_ptr(struct thread_info *tinfo,
24599- void *p, unsigned int size, void *end)
24600+static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
24601 {
24602- void *t = tinfo;
24603 if (end) {
24604 if (p < end && p >= (end-THREAD_SIZE))
24605 return 1;
24606@@ -93,14 +92,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
24607 }
24608
24609 unsigned long
24610-print_context_stack(struct thread_info *tinfo,
24611+print_context_stack(struct task_struct *task, void *stack_start,
24612 unsigned long *stack, unsigned long bp,
24613 const struct stacktrace_ops *ops, void *data,
24614 unsigned long *end, int *graph)
24615 {
24616 struct stack_frame *frame = (struct stack_frame *)bp;
24617
24618- while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
24619+ while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
24620 unsigned long addr;
24621
24622 addr = *stack;
24623@@ -112,7 +111,7 @@ print_context_stack(struct thread_info *tinfo,
24624 } else {
24625 ops->address(data, addr, 0);
24626 }
24627- print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
24628+ print_ftrace_graph_addr(addr, data, ops, task, graph);
24629 }
24630 stack++;
24631 }
24632@@ -121,7 +120,7 @@ print_context_stack(struct thread_info *tinfo,
24633 EXPORT_SYMBOL_GPL(print_context_stack);
24634
24635 unsigned long
24636-print_context_stack_bp(struct thread_info *tinfo,
24637+print_context_stack_bp(struct task_struct *task, void *stack_start,
24638 unsigned long *stack, unsigned long bp,
24639 const struct stacktrace_ops *ops, void *data,
24640 unsigned long *end, int *graph)
24641@@ -129,7 +128,7 @@ print_context_stack_bp(struct thread_info *tinfo,
24642 struct stack_frame *frame = (struct stack_frame *)bp;
24643 unsigned long *ret_addr = &frame->return_address;
24644
24645- while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
24646+ while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
24647 unsigned long addr = *ret_addr;
24648
24649 if (!__kernel_text_address(addr))
24650@@ -138,7 +137,7 @@ print_context_stack_bp(struct thread_info *tinfo,
24651 ops->address(data, addr, 1);
24652 frame = frame->next_frame;
24653 ret_addr = &frame->return_address;
24654- print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
24655+ print_ftrace_graph_addr(addr, data, ops, task, graph);
24656 }
24657
24658 return (unsigned long)frame;
24659@@ -226,6 +225,8 @@ unsigned long oops_begin(void)
24660 EXPORT_SYMBOL_GPL(oops_begin);
24661 NOKPROBE_SYMBOL(oops_begin);
24662
24663+extern void gr_handle_kernel_exploit(void);
24664+
24665 void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
24666 {
24667 if (regs && kexec_should_crash(current))
24668@@ -247,7 +248,10 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
24669 panic("Fatal exception in interrupt");
24670 if (panic_on_oops)
24671 panic("Fatal exception");
24672- do_exit(signr);
24673+
24674+ gr_handle_kernel_exploit();
24675+
24676+ do_group_exit(signr);
24677 }
24678 NOKPROBE_SYMBOL(oops_end);
24679
24680diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
24681index 464ffd6..01f2cda 100644
24682--- a/arch/x86/kernel/dumpstack_32.c
24683+++ b/arch/x86/kernel/dumpstack_32.c
24684@@ -61,15 +61,14 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24685 bp = stack_frame(task, regs);
24686
24687 for (;;) {
24688- struct thread_info *context;
24689+ void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
24690 void *end_stack;
24691
24692 end_stack = is_hardirq_stack(stack, cpu);
24693 if (!end_stack)
24694 end_stack = is_softirq_stack(stack, cpu);
24695
24696- context = task_thread_info(task);
24697- bp = ops->walk_stack(context, stack, bp, ops, data,
24698+ bp = ops->walk_stack(task, stack_start, stack, bp, ops, data,
24699 end_stack, &graph);
24700
24701 /* Stop if not on irq stack */
24702@@ -137,16 +136,17 @@ void show_regs(struct pt_regs *regs)
24703 unsigned int code_len = code_bytes;
24704 unsigned char c;
24705 u8 *ip;
24706+ unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
24707
24708 pr_emerg("Stack:\n");
24709 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
24710
24711 pr_emerg("Code:");
24712
24713- ip = (u8 *)regs->ip - code_prologue;
24714+ ip = (u8 *)regs->ip - code_prologue + cs_base;
24715 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
24716 /* try starting at IP */
24717- ip = (u8 *)regs->ip;
24718+ ip = (u8 *)regs->ip + cs_base;
24719 code_len = code_len - code_prologue + 1;
24720 }
24721 for (i = 0; i < code_len; i++, ip++) {
24722@@ -155,7 +155,7 @@ void show_regs(struct pt_regs *regs)
24723 pr_cont(" Bad EIP value.");
24724 break;
24725 }
24726- if (ip == (u8 *)regs->ip)
24727+ if (ip == (u8 *)regs->ip + cs_base)
24728 pr_cont(" <%02x>", c);
24729 else
24730 pr_cont(" %02x", c);
24731@@ -168,6 +168,7 @@ int is_valid_bugaddr(unsigned long ip)
24732 {
24733 unsigned short ud2;
24734
24735+ ip = ktla_ktva(ip);
24736 if (ip < PAGE_OFFSET)
24737 return 0;
24738 if (probe_kernel_address((unsigned short *)ip, ud2))
24739@@ -175,3 +176,15 @@ int is_valid_bugaddr(unsigned long ip)
24740
24741 return ud2 == 0x0b0f;
24742 }
24743+
24744+#if defined(CONFIG_PAX_MEMORY_STACKLEAK) || defined(CONFIG_PAX_USERCOPY)
24745+void __used pax_check_alloca(unsigned long size)
24746+{
24747+ unsigned long sp = (unsigned long)&sp, stack_left;
24748+
24749+ /* all kernel stacks are of the same size */
24750+ stack_left = sp & (THREAD_SIZE - 1);
24751+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
24752+}
24753+EXPORT_SYMBOL(pax_check_alloca);
24754+#endif
24755diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
24756index 5f1c626..1cba97e 100644
24757--- a/arch/x86/kernel/dumpstack_64.c
24758+++ b/arch/x86/kernel/dumpstack_64.c
24759@@ -153,12 +153,12 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24760 const struct stacktrace_ops *ops, void *data)
24761 {
24762 const unsigned cpu = get_cpu();
24763- struct thread_info *tinfo;
24764 unsigned long *irq_stack = (unsigned long *)per_cpu(irq_stack_ptr, cpu);
24765 unsigned long dummy;
24766 unsigned used = 0;
24767 int graph = 0;
24768 int done = 0;
24769+ void *stack_start;
24770
24771 if (!task)
24772 task = current;
24773@@ -179,7 +179,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24774 * current stack address. If the stacks consist of nested
24775 * exceptions
24776 */
24777- tinfo = task_thread_info(task);
24778 while (!done) {
24779 unsigned long *stack_end;
24780 enum stack_type stype;
24781@@ -202,7 +201,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24782 if (ops->stack(data, id) < 0)
24783 break;
24784
24785- bp = ops->walk_stack(tinfo, stack, bp, ops,
24786+ bp = ops->walk_stack(task, stack_end - EXCEPTION_STKSZ, stack, bp, ops,
24787 data, stack_end, &graph);
24788 ops->stack(data, "<EOE>");
24789 /*
24790@@ -210,6 +209,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24791 * second-to-last pointer (index -2 to end) in the
24792 * exception stack:
24793 */
24794+ if ((u16)stack_end[-1] != __KERNEL_DS)
24795+ goto out;
24796 stack = (unsigned long *) stack_end[-2];
24797 done = 0;
24798 break;
24799@@ -218,7 +219,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24800
24801 if (ops->stack(data, "IRQ") < 0)
24802 break;
24803- bp = ops->walk_stack(tinfo, stack, bp,
24804+ bp = ops->walk_stack(task, irq_stack, stack, bp,
24805 ops, data, stack_end, &graph);
24806 /*
24807 * We link to the next stack (which would be
24808@@ -240,7 +241,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24809 /*
24810 * This handles the process stack:
24811 */
24812- bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
24813+ stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
24814+ bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
24815+out:
24816 put_cpu();
24817 }
24818 EXPORT_SYMBOL(dump_trace);
24819@@ -347,8 +350,55 @@ int is_valid_bugaddr(unsigned long ip)
24820 {
24821 unsigned short ud2;
24822
24823- if (__copy_from_user(&ud2, (const void __user *) ip, sizeof(ud2)))
24824+ if (probe_kernel_address((unsigned short *)ip, ud2))
24825 return 0;
24826
24827 return ud2 == 0x0b0f;
24828 }
24829+
24830+#if defined(CONFIG_PAX_MEMORY_STACKLEAK) || defined(CONFIG_PAX_USERCOPY)
24831+void __used pax_check_alloca(unsigned long size)
24832+{
24833+ unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
24834+ unsigned cpu, used;
24835+ char *id;
24836+
24837+ /* check the process stack first */
24838+ stack_start = (unsigned long)task_stack_page(current);
24839+ stack_end = stack_start + THREAD_SIZE;
24840+ if (likely(stack_start <= sp && sp < stack_end)) {
24841+ unsigned long stack_left = sp & (THREAD_SIZE - 1);
24842+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
24843+ return;
24844+ }
24845+
24846+ cpu = get_cpu();
24847+
24848+ /* check the irq stacks */
24849+ stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
24850+ stack_start = stack_end - IRQ_STACK_SIZE;
24851+ if (stack_start <= sp && sp < stack_end) {
24852+ unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
24853+ put_cpu();
24854+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
24855+ return;
24856+ }
24857+
24858+ /* check the exception stacks */
24859+ used = 0;
24860+ stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
24861+ stack_start = stack_end - EXCEPTION_STKSZ;
24862+ if (stack_end && stack_start <= sp && sp < stack_end) {
24863+ unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
24864+ put_cpu();
24865+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
24866+ return;
24867+ }
24868+
24869+ put_cpu();
24870+
24871+ /* unknown stack */
24872+ BUG();
24873+}
24874+EXPORT_SYMBOL(pax_check_alloca);
24875+#endif
24876diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
24877index a102564..d1f0b73 100644
24878--- a/arch/x86/kernel/e820.c
24879+++ b/arch/x86/kernel/e820.c
24880@@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
24881
24882 static void early_panic(char *msg)
24883 {
24884- early_printk(msg);
24885- panic(msg);
24886+ early_printk("%s", msg);
24887+ panic("%s", msg);
24888 }
24889
24890 static int userdef __initdata;
24891diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
24892index eec40f5..4fee808 100644
24893--- a/arch/x86/kernel/early_printk.c
24894+++ b/arch/x86/kernel/early_printk.c
24895@@ -7,6 +7,7 @@
24896 #include <linux/pci_regs.h>
24897 #include <linux/pci_ids.h>
24898 #include <linux/errno.h>
24899+#include <linux/sched.h>
24900 #include <asm/io.h>
24901 #include <asm/processor.h>
24902 #include <asm/fcntl.h>
24903diff --git a/arch/x86/kernel/espfix_64.c b/arch/x86/kernel/espfix_64.c
24904index ce95676..af5c012 100644
24905--- a/arch/x86/kernel/espfix_64.c
24906+++ b/arch/x86/kernel/espfix_64.c
24907@@ -41,6 +41,7 @@
24908 #include <asm/pgalloc.h>
24909 #include <asm/setup.h>
24910 #include <asm/espfix.h>
24911+#include <asm/bug.h>
24912
24913 /*
24914 * Note: we only need 6*8 = 48 bytes for the espfix stack, but round
24915@@ -70,8 +71,10 @@ static DEFINE_MUTEX(espfix_init_mutex);
24916 #define ESPFIX_MAX_PAGES DIV_ROUND_UP(CONFIG_NR_CPUS, ESPFIX_STACKS_PER_PAGE)
24917 static void *espfix_pages[ESPFIX_MAX_PAGES];
24918
24919-static __page_aligned_bss pud_t espfix_pud_page[PTRS_PER_PUD]
24920- __aligned(PAGE_SIZE);
24921+static __page_aligned_rodata pud_t espfix_pud_page[PTRS_PER_PUD];
24922+static __page_aligned_rodata pmd_t espfix_pmd_page[PTRS_PER_PMD];
24923+static __page_aligned_rodata pte_t espfix_pte_page[PTRS_PER_PTE];
24924+static __page_aligned_rodata char espfix_stack_page[ESPFIX_MAX_PAGES][PAGE_SIZE];
24925
24926 static unsigned int page_random, slot_random;
24927
24928@@ -122,10 +125,19 @@ static void init_espfix_random(void)
24929 void __init init_espfix_bsp(void)
24930 {
24931 pgd_t *pgd_p;
24932+ pud_t *pud_p;
24933+ unsigned long index = pgd_index(ESPFIX_BASE_ADDR);
24934
24935 /* Install the espfix pud into the kernel page directory */
24936- pgd_p = &init_level4_pgt[pgd_index(ESPFIX_BASE_ADDR)];
24937- pgd_populate(&init_mm, pgd_p, (pud_t *)espfix_pud_page);
24938+ pgd_p = &init_level4_pgt[index];
24939+ pud_p = espfix_pud_page;
24940+ paravirt_alloc_pud(&init_mm, __pa(pud_p) >> PAGE_SHIFT);
24941+ set_pgd(pgd_p, __pgd(PGTABLE_PROT | __pa(pud_p)));
24942+
24943+#ifdef CONFIG_PAX_PER_CPU_PGD
24944+ clone_pgd_range(get_cpu_pgd(0, kernel) + index, swapper_pg_dir + index, 1);
24945+ clone_pgd_range(get_cpu_pgd(0, user) + index, swapper_pg_dir + index, 1);
24946+#endif
24947
24948 /* Randomize the locations */
24949 init_espfix_random();
24950@@ -170,35 +182,39 @@ void init_espfix_ap(int cpu)
24951 pud_p = &espfix_pud_page[pud_index(addr)];
24952 pud = *pud_p;
24953 if (!pud_present(pud)) {
24954- struct page *page = alloc_pages_node(node, PGALLOC_GFP, 0);
24955-
24956- pmd_p = (pmd_t *)page_address(page);
24957+ if (cpu)
24958+ pmd_p = page_address(alloc_pages_node(node, PGALLOC_GFP, 0));
24959+ else
24960+ pmd_p = espfix_pmd_page;
24961 pud = __pud(__pa(pmd_p) | (PGTABLE_PROT & ptemask));
24962 paravirt_alloc_pmd(&init_mm, __pa(pmd_p) >> PAGE_SHIFT);
24963 for (n = 0; n < ESPFIX_PUD_CLONES; n++)
24964 set_pud(&pud_p[n], pud);
24965- }
24966+ } else
24967+ BUG_ON(!cpu);
24968
24969 pmd_p = pmd_offset(&pud, addr);
24970 pmd = *pmd_p;
24971 if (!pmd_present(pmd)) {
24972- struct page *page = alloc_pages_node(node, PGALLOC_GFP, 0);
24973-
24974- pte_p = (pte_t *)page_address(page);
24975+ if (cpu)
24976+ pte_p = page_address(alloc_pages_node(node, PGALLOC_GFP, 0));
24977+ else
24978+ pte_p = espfix_pte_page;
24979 pmd = __pmd(__pa(pte_p) | (PGTABLE_PROT & ptemask));
24980 paravirt_alloc_pte(&init_mm, __pa(pte_p) >> PAGE_SHIFT);
24981 for (n = 0; n < ESPFIX_PMD_CLONES; n++)
24982 set_pmd(&pmd_p[n], pmd);
24983- }
24984+ } else
24985+ BUG_ON(!cpu);
24986
24987 pte_p = pte_offset_kernel(&pmd, addr);
24988- stack_page = page_address(alloc_pages_node(node, GFP_KERNEL, 0));
24989+ stack_page = espfix_stack_page[page];
24990 pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask));
24991 for (n = 0; n < ESPFIX_PTE_CLONES; n++)
24992 set_pte(&pte_p[n*PTE_STRIDE], pte);
24993
24994 /* Job is done for this CPU and any CPU which shares this page */
24995- ACCESS_ONCE(espfix_pages[page]) = stack_page;
24996+ ACCESS_ONCE_RW(espfix_pages[page]) = stack_page;
24997
24998 unlock_done:
24999 mutex_unlock(&espfix_init_mutex);
25000diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
25001index d25097c..84b0d51 100644
25002--- a/arch/x86/kernel/fpu/core.c
25003+++ b/arch/x86/kernel/fpu/core.c
25004@@ -127,7 +127,7 @@ void __kernel_fpu_end(void)
25005 struct fpu *fpu = &current->thread.fpu;
25006
25007 if (fpu->fpregs_active)
25008- copy_kernel_to_fpregs(&fpu->state);
25009+ copy_kernel_to_fpregs(fpu->state);
25010 else
25011 __fpregs_deactivate_hw();
25012
25013@@ -238,7 +238,7 @@ static void fpu_copy(struct fpu *dst_fpu, struct fpu *src_fpu)
25014 * leak into the child task:
25015 */
25016 if (use_eager_fpu())
25017- memset(&dst_fpu->state.xsave, 0, xstate_size);
25018+ memset(&dst_fpu->state->xsave, 0, xstate_size);
25019
25020 /*
25021 * Save current FPU registers directly into the child
25022@@ -285,7 +285,7 @@ void fpu__activate_curr(struct fpu *fpu)
25023 WARN_ON_FPU(fpu != &current->thread.fpu);
25024
25025 if (!fpu->fpstate_active) {
25026- fpstate_init(&fpu->state);
25027+ fpstate_init(fpu->state);
25028
25029 /* Safe to do for the current task: */
25030 fpu->fpstate_active = 1;
25031@@ -311,7 +311,7 @@ void fpu__activate_fpstate_read(struct fpu *fpu)
25032 fpu__save(fpu);
25033 } else {
25034 if (!fpu->fpstate_active) {
25035- fpstate_init(&fpu->state);
25036+ fpstate_init(fpu->state);
25037
25038 /* Safe to do for current and for stopped child tasks: */
25039 fpu->fpstate_active = 1;
25040@@ -344,7 +344,7 @@ void fpu__activate_fpstate_write(struct fpu *fpu)
25041 /* Invalidate any lazy state: */
25042 fpu->last_cpu = -1;
25043 } else {
25044- fpstate_init(&fpu->state);
25045+ fpstate_init(fpu->state);
25046
25047 /* Safe to do for stopped child tasks: */
25048 fpu->fpstate_active = 1;
25049@@ -368,7 +368,7 @@ void fpu__restore(struct fpu *fpu)
25050 /* Avoid __kernel_fpu_begin() right after fpregs_activate() */
25051 kernel_fpu_disable();
25052 fpregs_activate(fpu);
25053- copy_kernel_to_fpregs(&fpu->state);
25054+ copy_kernel_to_fpregs(fpu->state);
25055 fpu->counter++;
25056 kernel_fpu_enable();
25057 }
25058@@ -442,25 +442,25 @@ void fpu__clear(struct fpu *fpu)
25059 static inline unsigned short get_fpu_cwd(struct fpu *fpu)
25060 {
25061 if (cpu_has_fxsr) {
25062- return fpu->state.fxsave.cwd;
25063+ return fpu->state->fxsave.cwd;
25064 } else {
25065- return (unsigned short)fpu->state.fsave.cwd;
25066+ return (unsigned short)fpu->state->fsave.cwd;
25067 }
25068 }
25069
25070 static inline unsigned short get_fpu_swd(struct fpu *fpu)
25071 {
25072 if (cpu_has_fxsr) {
25073- return fpu->state.fxsave.swd;
25074+ return fpu->state->fxsave.swd;
25075 } else {
25076- return (unsigned short)fpu->state.fsave.swd;
25077+ return (unsigned short)fpu->state->fsave.swd;
25078 }
25079 }
25080
25081 static inline unsigned short get_fpu_mxcsr(struct fpu *fpu)
25082 {
25083 if (cpu_has_xmm) {
25084- return fpu->state.fxsave.mxcsr;
25085+ return fpu->state->fxsave.mxcsr;
25086 } else {
25087 return MXCSR_DEFAULT;
25088 }
25089diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
25090index d14e9ac..8ca141b 100644
25091--- a/arch/x86/kernel/fpu/init.c
25092+++ b/arch/x86/kernel/fpu/init.c
25093@@ -42,7 +42,7 @@ static void fpu__init_cpu_generic(void)
25094 /* Flush out any pending x87 state: */
25095 #ifdef CONFIG_MATH_EMULATION
25096 if (!cpu_has_fpu)
25097- fpstate_init_soft(&current->thread.fpu.state.soft);
25098+ fpstate_init_soft(&current->thread.fpu.state->soft);
25099 else
25100 #endif
25101 asm volatile ("fninit");
25102@@ -147,12 +147,14 @@ EXPORT_SYMBOL_GPL(xstate_size);
25103 #define CHECK_MEMBER_AT_END_OF(TYPE, MEMBER) \
25104 BUILD_BUG_ON(sizeof(TYPE) != offsetofend(TYPE, MEMBER))
25105
25106+union fpregs_state init_fpregs_state;
25107+
25108 /*
25109 * We append the 'struct fpu' to the task_struct:
25110 */
25111 static void __init fpu__init_task_struct_size(void)
25112 {
25113- int task_size = sizeof(struct task_struct);
25114+ size_t task_size = sizeof(struct task_struct);
25115
25116 /*
25117 * Subtract off the static size of the register state.
25118@@ -168,16 +170,12 @@ static void __init fpu__init_task_struct_size(void)
25119
25120 /*
25121 * We dynamically size 'struct fpu', so we require that
25122- * it be at the end of 'thread_struct' and that
25123- * 'thread_struct' be at the end of 'task_struct'. If
25124+ * it be at the end of 'thread_struct'. If
25125 * you hit a compile error here, check the structure to
25126 * see if something got added to the end.
25127 */
25128 CHECK_MEMBER_AT_END_OF(struct fpu, state);
25129 CHECK_MEMBER_AT_END_OF(struct thread_struct, fpu);
25130- CHECK_MEMBER_AT_END_OF(struct task_struct, thread);
25131-
25132- arch_task_struct_size = task_size;
25133 }
25134
25135 /*
25136diff --git a/arch/x86/kernel/fpu/regset.c b/arch/x86/kernel/fpu/regset.c
25137index dc60810..6c8a1fa 100644
25138--- a/arch/x86/kernel/fpu/regset.c
25139+++ b/arch/x86/kernel/fpu/regset.c
25140@@ -37,7 +37,7 @@ int xfpregs_get(struct task_struct *target, const struct user_regset *regset,
25141 fpstate_sanitize_xstate(fpu);
25142
25143 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
25144- &fpu->state.fxsave, 0, -1);
25145+ &fpu->state->fxsave, 0, -1);
25146 }
25147
25148 int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
25149@@ -54,19 +54,19 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
25150 fpstate_sanitize_xstate(fpu);
25151
25152 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
25153- &fpu->state.fxsave, 0, -1);
25154+ &fpu->state->fxsave, 0, -1);
25155
25156 /*
25157 * mxcsr reserved bits must be masked to zero for security reasons.
25158 */
25159- fpu->state.fxsave.mxcsr &= mxcsr_feature_mask;
25160+ fpu->state->fxsave.mxcsr &= mxcsr_feature_mask;
25161
25162 /*
25163 * update the header bits in the xsave header, indicating the
25164 * presence of FP and SSE state.
25165 */
25166 if (cpu_has_xsave)
25167- fpu->state.xsave.header.xfeatures |= XSTATE_FPSSE;
25168+ fpu->state->xsave.header.xfeatures |= XSTATE_FPSSE;
25169
25170 return ret;
25171 }
25172@@ -84,7 +84,7 @@ int xstateregs_get(struct task_struct *target, const struct user_regset *regset,
25173
25174 fpu__activate_fpstate_read(fpu);
25175
25176- xsave = &fpu->state.xsave;
25177+ xsave = &fpu->state->xsave;
25178
25179 /*
25180 * Copy the 48bytes defined by the software first into the xstate
25181@@ -113,7 +113,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
25182
25183 fpu__activate_fpstate_write(fpu);
25184
25185- xsave = &fpu->state.xsave;
25186+ xsave = &fpu->state->xsave;
25187
25188 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, xsave, 0, -1);
25189 /*
25190@@ -204,7 +204,7 @@ static inline u32 twd_fxsr_to_i387(struct fxregs_state *fxsave)
25191 void
25192 convert_from_fxsr(struct user_i387_ia32_struct *env, struct task_struct *tsk)
25193 {
25194- struct fxregs_state *fxsave = &tsk->thread.fpu.state.fxsave;
25195+ struct fxregs_state *fxsave = &tsk->thread.fpu.state->fxsave;
25196 struct _fpreg *to = (struct _fpreg *) &env->st_space[0];
25197 struct _fpxreg *from = (struct _fpxreg *) &fxsave->st_space[0];
25198 int i;
25199@@ -242,7 +242,7 @@ void convert_to_fxsr(struct task_struct *tsk,
25200 const struct user_i387_ia32_struct *env)
25201
25202 {
25203- struct fxregs_state *fxsave = &tsk->thread.fpu.state.fxsave;
25204+ struct fxregs_state *fxsave = &tsk->thread.fpu.state->fxsave;
25205 struct _fpreg *from = (struct _fpreg *) &env->st_space[0];
25206 struct _fpxreg *to = (struct _fpxreg *) &fxsave->st_space[0];
25207 int i;
25208@@ -280,7 +280,7 @@ int fpregs_get(struct task_struct *target, const struct user_regset *regset,
25209
25210 if (!cpu_has_fxsr)
25211 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
25212- &fpu->state.fsave, 0,
25213+ &fpu->state->fsave, 0,
25214 -1);
25215
25216 fpstate_sanitize_xstate(fpu);
25217@@ -311,7 +311,7 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,
25218
25219 if (!cpu_has_fxsr)
25220 return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
25221- &fpu->state.fsave, 0,
25222+ &fpu->state->fsave, 0,
25223 -1);
25224
25225 if (pos > 0 || count < sizeof(env))
25226@@ -326,7 +326,7 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,
25227 * presence of FP.
25228 */
25229 if (cpu_has_xsave)
25230- fpu->state.xsave.header.xfeatures |= XSTATE_FP;
25231+ fpu->state->xsave.header.xfeatures |= XSTATE_FP;
25232 return ret;
25233 }
25234
25235diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
25236index 50ec9af..bb871ca 100644
25237--- a/arch/x86/kernel/fpu/signal.c
25238+++ b/arch/x86/kernel/fpu/signal.c
25239@@ -54,7 +54,7 @@ static inline int check_for_xstate(struct fxregs_state __user *buf,
25240 static inline int save_fsave_header(struct task_struct *tsk, void __user *buf)
25241 {
25242 if (use_fxsr()) {
25243- struct xregs_state *xsave = &tsk->thread.fpu.state.xsave;
25244+ struct xregs_state *xsave = &tsk->thread.fpu.state->xsave;
25245 struct user_i387_ia32_struct env;
25246 struct _fpstate_ia32 __user *fp = buf;
25247
25248@@ -83,18 +83,18 @@ static inline int save_xstate_epilog(void __user *buf, int ia32_frame)
25249
25250 /* Setup the bytes not touched by the [f]xsave and reserved for SW. */
25251 sw_bytes = ia32_frame ? &fx_sw_reserved_ia32 : &fx_sw_reserved;
25252- err = __copy_to_user(&x->i387.sw_reserved, sw_bytes, sizeof(*sw_bytes));
25253+ err = __copy_to_user(x->i387.sw_reserved, sw_bytes, sizeof(*sw_bytes));
25254
25255 if (!use_xsave())
25256 return err;
25257
25258- err |= __put_user(FP_XSTATE_MAGIC2, (__u32 *)(buf + xstate_size));
25259+ err |= __put_user(FP_XSTATE_MAGIC2, (__u32 __user *)(buf + xstate_size));
25260
25261 /*
25262 * Read the xfeatures which we copied (directly from the cpu or
25263 * from the state in task struct) to the user buffers.
25264 */
25265- err |= __get_user(xfeatures, (__u32 *)&x->header.xfeatures);
25266+ err |= __get_user(xfeatures, (__u32 __user *)&x->header.xfeatures);
25267
25268 /*
25269 * For legacy compatible, we always set FP/SSE bits in the bit
25270@@ -109,7 +109,7 @@ static inline int save_xstate_epilog(void __user *buf, int ia32_frame)
25271 */
25272 xfeatures |= XSTATE_FPSSE;
25273
25274- err |= __put_user(xfeatures, (__u32 *)&x->header.xfeatures);
25275+ err |= __put_user(xfeatures, (__u32 __user *)&x->header.xfeatures);
25276
25277 return err;
25278 }
25279@@ -118,6 +118,7 @@ static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf)
25280 {
25281 int err;
25282
25283+ buf = (struct xregs_state __user *)____m(buf);
25284 if (use_xsave())
25285 err = copy_xregs_to_user(buf);
25286 else if (use_fxsr())
25287@@ -152,7 +153,7 @@ static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf)
25288 */
25289 int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size)
25290 {
25291- struct xregs_state *xsave = &current->thread.fpu.state.xsave;
25292+ struct xregs_state *xsave = &current->thread.fpu.state->xsave;
25293 struct task_struct *tsk = current;
25294 int ia32_fxstate = (buf != buf_fx);
25295
25296@@ -195,7 +196,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
25297 struct user_i387_ia32_struct *ia32_env,
25298 u64 xfeatures, int fx_only)
25299 {
25300- struct xregs_state *xsave = &tsk->thread.fpu.state.xsave;
25301+ struct xregs_state *xsave = &tsk->thread.fpu.state->xsave;
25302 struct xstate_header *header = &xsave->header;
25303
25304 if (use_xsave()) {
25305@@ -228,6 +229,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
25306 */
25307 static inline int copy_user_to_fpregs_zeroing(void __user *buf, u64 xbv, int fx_only)
25308 {
25309+ buf = (void __user *)____m(buf);
25310 if (use_xsave()) {
25311 if ((unsigned long)buf % 64 || fx_only) {
25312 u64 init_bv = xfeatures_mask & ~XSTATE_FPSSE;
25313@@ -308,9 +310,9 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
25314 */
25315 fpu__drop(fpu);
25316
25317- if (__copy_from_user(&fpu->state.xsave, buf_fx, state_size) ||
25318+ if (__copy_from_user(&fpu->state->xsave, buf_fx, state_size) ||
25319 __copy_from_user(&env, buf, sizeof(env))) {
25320- fpstate_init(&fpu->state);
25321+ fpstate_init(fpu->state);
25322 err = -1;
25323 } else {
25324 sanitize_restored_xstate(tsk, &env, xfeatures, fx_only);
25325diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
25326index 62fc001..5ce38be 100644
25327--- a/arch/x86/kernel/fpu/xstate.c
25328+++ b/arch/x86/kernel/fpu/xstate.c
25329@@ -93,14 +93,14 @@ EXPORT_SYMBOL_GPL(cpu_has_xfeatures);
25330 */
25331 void fpstate_sanitize_xstate(struct fpu *fpu)
25332 {
25333- struct fxregs_state *fx = &fpu->state.fxsave;
25334+ struct fxregs_state *fx = &fpu->state->fxsave;
25335 int feature_bit;
25336 u64 xfeatures;
25337
25338 if (!use_xsaveopt())
25339 return;
25340
25341- xfeatures = fpu->state.xsave.header.xfeatures;
25342+ xfeatures = fpu->state->xsave.header.xfeatures;
25343
25344 /*
25345 * None of the feature bits are in init state. So nothing else
25346@@ -402,7 +402,7 @@ void *get_xsave_addr(struct xregs_state *xsave, int xstate_feature)
25347 if (!boot_cpu_has(X86_FEATURE_XSAVE))
25348 return NULL;
25349
25350- xsave = &current->thread.fpu.state.xsave;
25351+ xsave = &current->thread.fpu.state->xsave;
25352 /*
25353 * We should not ever be requesting features that we
25354 * have not enabled. Remember that pcntxt_mask is
25355@@ -457,5 +457,5 @@ const void *get_xsave_field_ptr(int xsave_state)
25356 */
25357 fpu__save(fpu);
25358
25359- return get_xsave_addr(&fpu->state.xsave, xsave_state);
25360+ return get_xsave_addr(&fpu->state->xsave, xsave_state);
25361 }
25362diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
25363index 8b7b0a5..02219db 100644
25364--- a/arch/x86/kernel/ftrace.c
25365+++ b/arch/x86/kernel/ftrace.c
25366@@ -89,7 +89,7 @@ static unsigned long text_ip_addr(unsigned long ip)
25367 * kernel identity mapping to modify code.
25368 */
25369 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
25370- ip = (unsigned long)__va(__pa_symbol(ip));
25371+ ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
25372
25373 return ip;
25374 }
25375@@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
25376 {
25377 unsigned char replaced[MCOUNT_INSN_SIZE];
25378
25379+ ip = ktla_ktva(ip);
25380+
25381 /*
25382 * Note: Due to modules and __init, code can
25383 * disappear and change, we need to protect against faulting
25384@@ -230,7 +232,7 @@ static int update_ftrace_func(unsigned long ip, void *new)
25385 unsigned char old[MCOUNT_INSN_SIZE];
25386 int ret;
25387
25388- memcpy(old, (void *)ip, MCOUNT_INSN_SIZE);
25389+ memcpy(old, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE);
25390
25391 ftrace_update_func = ip;
25392 /* Make sure the breakpoints see the ftrace_update_func update */
25393@@ -311,7 +313,7 @@ static int add_break(unsigned long ip, const char *old)
25394 unsigned char replaced[MCOUNT_INSN_SIZE];
25395 unsigned char brk = BREAKPOINT_INSTRUCTION;
25396
25397- if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
25398+ if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
25399 return -EFAULT;
25400
25401 /* Make sure it is what we expect it to be */
25402@@ -670,11 +672,11 @@ static unsigned char *ftrace_jmp_replace(unsigned long ip, unsigned long addr)
25403 /* Module allocation simplifies allocating memory for code */
25404 static inline void *alloc_tramp(unsigned long size)
25405 {
25406- return module_alloc(size);
25407+ return module_alloc_exec(size);
25408 }
25409 static inline void tramp_free(void *tramp)
25410 {
25411- module_memfree(tramp);
25412+ module_memfree_exec(tramp);
25413 }
25414 #else
25415 /* Trampolines can only be created if modules are supported */
25416@@ -753,7 +755,9 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
25417 *tramp_size = size + MCOUNT_INSN_SIZE + sizeof(void *);
25418
25419 /* Copy ftrace_caller onto the trampoline memory */
25420+ pax_open_kernel();
25421 ret = probe_kernel_read(trampoline, (void *)start_offset, size);
25422+ pax_close_kernel();
25423 if (WARN_ON(ret < 0)) {
25424 tramp_free(trampoline);
25425 return 0;
25426@@ -763,6 +767,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
25427
25428 /* The trampoline ends with a jmp to ftrace_return */
25429 jmp = ftrace_jmp_replace(ip, (unsigned long)ftrace_return);
25430+ pax_open_kernel();
25431 memcpy(trampoline + size, jmp, MCOUNT_INSN_SIZE);
25432
25433 /*
25434@@ -775,6 +780,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
25435
25436 ptr = (unsigned long *)(trampoline + size + MCOUNT_INSN_SIZE);
25437 *ptr = (unsigned long)ops;
25438+ pax_close_kernel();
25439
25440 op_offset -= start_offset;
25441 memcpy(&op_ptr, trampoline + op_offset, OP_REF_SIZE);
25442@@ -792,7 +798,9 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
25443 op_ptr.offset = offset;
25444
25445 /* put in the new offset to the ftrace_ops */
25446+ pax_open_kernel();
25447 memcpy(trampoline + op_offset, &op_ptr, OP_REF_SIZE);
25448+ pax_close_kernel();
25449
25450 /* ALLOC_TRAMP flags lets us know we created it */
25451 ops->flags |= FTRACE_OPS_FL_ALLOC_TRAMP;
25452diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
25453index f129a9a..af8f6da 100644
25454--- a/arch/x86/kernel/head64.c
25455+++ b/arch/x86/kernel/head64.c
25456@@ -68,12 +68,12 @@ again:
25457 pgd = *pgd_p;
25458
25459 /*
25460- * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
25461- * critical -- __PAGE_OFFSET would point us back into the dynamic
25462+ * The use of __early_va rather than __va here is critical:
25463+ * __va would point us back into the dynamic
25464 * range and we might end up looping forever...
25465 */
25466 if (pgd)
25467- pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
25468+ pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
25469 else {
25470 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
25471 reset_early_page_tables();
25472@@ -83,13 +83,13 @@ again:
25473 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
25474 for (i = 0; i < PTRS_PER_PUD; i++)
25475 pud_p[i] = 0;
25476- *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
25477+ *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
25478 }
25479 pud_p += pud_index(address);
25480 pud = *pud_p;
25481
25482 if (pud)
25483- pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
25484+ pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
25485 else {
25486 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
25487 reset_early_page_tables();
25488@@ -99,7 +99,7 @@ again:
25489 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
25490 for (i = 0; i < PTRS_PER_PMD; i++)
25491 pmd_p[i] = 0;
25492- *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
25493+ *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
25494 }
25495 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
25496 pmd_p[pmd_index(address)] = pmd;
25497@@ -163,8 +163,6 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)
25498
25499 clear_bss();
25500
25501- clear_page(init_level4_pgt);
25502-
25503 kasan_early_init();
25504
25505 for (i = 0; i < NUM_EXCEPTION_VECTORS; i++)
25506diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
25507index 0e2d96f..5889003 100644
25508--- a/arch/x86/kernel/head_32.S
25509+++ b/arch/x86/kernel/head_32.S
25510@@ -27,6 +27,12 @@
25511 /* Physical address */
25512 #define pa(X) ((X) - __PAGE_OFFSET)
25513
25514+#ifdef CONFIG_PAX_KERNEXEC
25515+#define ta(X) (X)
25516+#else
25517+#define ta(X) ((X) - __PAGE_OFFSET)
25518+#endif
25519+
25520 /*
25521 * References to members of the new_cpu_data structure.
25522 */
25523@@ -56,11 +62,7 @@
25524 * and small than max_low_pfn, otherwise will waste some page table entries
25525 */
25526
25527-#if PTRS_PER_PMD > 1
25528-#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
25529-#else
25530-#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
25531-#endif
25532+#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
25533
25534 /*
25535 * Number of possible pages in the lowmem region.
25536@@ -86,6 +88,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
25537 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
25538
25539 /*
25540+ * Real beginning of normal "text" segment
25541+ */
25542+ENTRY(stext)
25543+ENTRY(_stext)
25544+
25545+/*
25546 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
25547 * %esi points to the real-mode code as a 32-bit pointer.
25548 * CS and DS must be 4 GB flat segments, but we don't depend on
25549@@ -93,6 +101,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
25550 * can.
25551 */
25552 __HEAD
25553+
25554+#ifdef CONFIG_PAX_KERNEXEC
25555+ jmp startup_32
25556+/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
25557+.fill PAGE_SIZE-5,1,0xcc
25558+#endif
25559+
25560 ENTRY(startup_32)
25561 movl pa(stack_start),%ecx
25562
25563@@ -114,6 +129,66 @@ ENTRY(startup_32)
25564 2:
25565 leal -__PAGE_OFFSET(%ecx),%esp
25566
25567+#ifdef CONFIG_SMP
25568+ movl $pa(cpu_gdt_table),%edi
25569+ movl $__per_cpu_load,%eax
25570+ movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
25571+ rorl $16,%eax
25572+ movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
25573+ movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
25574+ movl $__per_cpu_end - 1,%eax
25575+ subl $__per_cpu_start,%eax
25576+ cmpl $0x100000,%eax
25577+ jb 1f
25578+ shrl $PAGE_SHIFT,%eax
25579+ orb $0x80,GDT_ENTRY_PERCPU * 8 + 6(%edi)
25580+1:
25581+ movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
25582+ shrl $16,%eax
25583+ orb %al,GDT_ENTRY_PERCPU * 8 + 6(%edi)
25584+#endif
25585+
25586+#ifdef CONFIG_PAX_MEMORY_UDEREF
25587+ movl $NR_CPUS,%ecx
25588+ movl $pa(cpu_gdt_table),%edi
25589+1:
25590+ movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
25591+ movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
25592+ movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
25593+ addl $PAGE_SIZE_asm,%edi
25594+ loop 1b
25595+#endif
25596+
25597+#ifdef CONFIG_PAX_KERNEXEC
25598+ movl $pa(boot_gdt),%edi
25599+ movl $__LOAD_PHYSICAL_ADDR,%eax
25600+ movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
25601+ rorl $16,%eax
25602+ movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
25603+ movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
25604+ rorl $16,%eax
25605+
25606+ ljmp $(__BOOT_CS),$1f
25607+1:
25608+
25609+ movl $NR_CPUS,%ecx
25610+ movl $pa(cpu_gdt_table),%edi
25611+ addl $__PAGE_OFFSET,%eax
25612+1:
25613+ movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
25614+ movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
25615+ movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
25616+ movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
25617+ rorl $16,%eax
25618+ movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
25619+ movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
25620+ movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
25621+ movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
25622+ rorl $16,%eax
25623+ addl $PAGE_SIZE_asm,%edi
25624+ loop 1b
25625+#endif
25626+
25627 /*
25628 * Clear BSS first so that there are no surprises...
25629 */
25630@@ -209,8 +284,11 @@ ENTRY(startup_32)
25631 movl %eax, pa(max_pfn_mapped)
25632
25633 /* Do early initialization of the fixmap area */
25634- movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
25635- movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
25636+#ifdef CONFIG_COMPAT_VDSO
25637+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
25638+#else
25639+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
25640+#endif
25641 #else /* Not PAE */
25642
25643 page_pde_offset = (__PAGE_OFFSET >> 20);
25644@@ -240,8 +318,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
25645 movl %eax, pa(max_pfn_mapped)
25646
25647 /* Do early initialization of the fixmap area */
25648- movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
25649- movl %eax,pa(initial_page_table+0xffc)
25650+#ifdef CONFIG_COMPAT_VDSO
25651+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
25652+#else
25653+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
25654+#endif
25655 #endif
25656
25657 #ifdef CONFIG_PARAVIRT
25658@@ -255,9 +336,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
25659 cmpl $num_subarch_entries, %eax
25660 jae bad_subarch
25661
25662- movl pa(subarch_entries)(,%eax,4), %eax
25663- subl $__PAGE_OFFSET, %eax
25664- jmp *%eax
25665+ jmp *pa(subarch_entries)(,%eax,4)
25666
25667 bad_subarch:
25668 WEAK(lguest_entry)
25669@@ -269,10 +348,10 @@ WEAK(xen_entry)
25670 __INITDATA
25671
25672 subarch_entries:
25673- .long default_entry /* normal x86/PC */
25674- .long lguest_entry /* lguest hypervisor */
25675- .long xen_entry /* Xen hypervisor */
25676- .long default_entry /* Moorestown MID */
25677+ .long ta(default_entry) /* normal x86/PC */
25678+ .long ta(lguest_entry) /* lguest hypervisor */
25679+ .long ta(xen_entry) /* Xen hypervisor */
25680+ .long ta(default_entry) /* Moorestown MID */
25681 num_subarch_entries = (. - subarch_entries) / 4
25682 .previous
25683 #else
25684@@ -362,6 +441,7 @@ default_entry:
25685 movl pa(mmu_cr4_features),%eax
25686 movl %eax,%cr4
25687
25688+#ifdef CONFIG_X86_PAE
25689 testb $X86_CR4_PAE, %al # check if PAE is enabled
25690 jz enable_paging
25691
25692@@ -390,6 +470,9 @@ default_entry:
25693 /* Make changes effective */
25694 wrmsr
25695
25696+ btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
25697+#endif
25698+
25699 enable_paging:
25700
25701 /*
25702@@ -457,14 +540,20 @@ is486:
25703 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
25704 movl %eax,%ss # after changing gdt.
25705
25706- movl $(__USER_DS),%eax # DS/ES contains default USER segment
25707+# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
25708 movl %eax,%ds
25709 movl %eax,%es
25710
25711 movl $(__KERNEL_PERCPU), %eax
25712 movl %eax,%fs # set this cpu's percpu
25713
25714+#ifdef CONFIG_CC_STACKPROTECTOR
25715 movl $(__KERNEL_STACK_CANARY),%eax
25716+#elif defined(CONFIG_PAX_MEMORY_UDEREF)
25717+ movl $(__USER_DS),%eax
25718+#else
25719+ xorl %eax,%eax
25720+#endif
25721 movl %eax,%gs
25722
25723 xorl %eax,%eax # Clear LDT
25724@@ -521,8 +610,11 @@ setup_once:
25725 * relocation. Manually set base address in stack canary
25726 * segment descriptor.
25727 */
25728- movl $gdt_page,%eax
25729+ movl $cpu_gdt_table,%eax
25730 movl $stack_canary,%ecx
25731+#ifdef CONFIG_SMP
25732+ addl $__per_cpu_load,%ecx
25733+#endif
25734 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
25735 shrl $16, %ecx
25736 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
25737@@ -559,7 +651,7 @@ early_idt_handler_common:
25738 cmpl $2,(%esp) # X86_TRAP_NMI
25739 je .Lis_nmi # Ignore NMI
25740
25741- cmpl $2,%ss:early_recursion_flag
25742+ cmpl $1,%ss:early_recursion_flag
25743 je hlt_loop
25744 incl %ss:early_recursion_flag
25745
25746@@ -597,8 +689,8 @@ early_idt_handler_common:
25747 pushl (20+6*4)(%esp) /* trapno */
25748 pushl $fault_msg
25749 call printk
25750-#endif
25751 call dump_stack
25752+#endif
25753 hlt_loop:
25754 hlt
25755 jmp hlt_loop
25756@@ -618,8 +710,11 @@ ENDPROC(early_idt_handler_common)
25757 /* This is the default interrupt "handler" :-) */
25758 ALIGN
25759 ignore_int:
25760- cld
25761 #ifdef CONFIG_PRINTK
25762+ cmpl $2,%ss:early_recursion_flag
25763+ je hlt_loop
25764+ incl %ss:early_recursion_flag
25765+ cld
25766 pushl %eax
25767 pushl %ecx
25768 pushl %edx
25769@@ -628,9 +723,6 @@ ignore_int:
25770 movl $(__KERNEL_DS),%eax
25771 movl %eax,%ds
25772 movl %eax,%es
25773- cmpl $2,early_recursion_flag
25774- je hlt_loop
25775- incl early_recursion_flag
25776 pushl 16(%esp)
25777 pushl 24(%esp)
25778 pushl 32(%esp)
25779@@ -664,29 +756,34 @@ ENTRY(setup_once_ref)
25780 /*
25781 * BSS section
25782 */
25783-__PAGE_ALIGNED_BSS
25784- .align PAGE_SIZE
25785 #ifdef CONFIG_X86_PAE
25786+.section .initial_pg_pmd,"a",@progbits
25787 initial_pg_pmd:
25788 .fill 1024*KPMDS,4,0
25789 #else
25790+.section .initial_page_table,"a",@progbits
25791 ENTRY(initial_page_table)
25792 .fill 1024,4,0
25793 #endif
25794+.section .initial_pg_fixmap,"a",@progbits
25795 initial_pg_fixmap:
25796 .fill 1024,4,0
25797+.section .empty_zero_page,"a",@progbits
25798 ENTRY(empty_zero_page)
25799 .fill 4096,1,0
25800+.section .swapper_pg_dir,"a",@progbits
25801 ENTRY(swapper_pg_dir)
25802+#ifdef CONFIG_X86_PAE
25803+ .fill 4,8,0
25804+#else
25805 .fill 1024,4,0
25806+#endif
25807
25808 /*
25809 * This starts the data section.
25810 */
25811 #ifdef CONFIG_X86_PAE
25812-__PAGE_ALIGNED_DATA
25813- /* Page-aligned for the benefit of paravirt? */
25814- .align PAGE_SIZE
25815+.section .initial_page_table,"a",@progbits
25816 ENTRY(initial_page_table)
25817 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
25818 # if KPMDS == 3
25819@@ -705,12 +802,20 @@ ENTRY(initial_page_table)
25820 # error "Kernel PMDs should be 1, 2 or 3"
25821 # endif
25822 .align PAGE_SIZE /* needs to be page-sized too */
25823+
25824+#ifdef CONFIG_PAX_PER_CPU_PGD
25825+ENTRY(cpu_pgd)
25826+ .rept 2*NR_CPUS
25827+ .fill 4,8,0
25828+ .endr
25829+#endif
25830+
25831 #endif
25832
25833 .data
25834 .balign 4
25835 ENTRY(stack_start)
25836- .long init_thread_union+THREAD_SIZE
25837+ .long init_thread_union+THREAD_SIZE-8
25838
25839 __INITRODATA
25840 int_msg:
25841@@ -738,7 +843,7 @@ fault_msg:
25842 * segment size, and 32-bit linear address value:
25843 */
25844
25845- .data
25846+.section .rodata,"a",@progbits
25847 .globl boot_gdt_descr
25848 .globl idt_descr
25849
25850@@ -747,7 +852,7 @@ fault_msg:
25851 .word 0 # 32 bit align gdt_desc.address
25852 boot_gdt_descr:
25853 .word __BOOT_DS+7
25854- .long boot_gdt - __PAGE_OFFSET
25855+ .long pa(boot_gdt)
25856
25857 .word 0 # 32-bit align idt_desc.address
25858 idt_descr:
25859@@ -758,7 +863,7 @@ idt_descr:
25860 .word 0 # 32 bit align gdt_desc.address
25861 ENTRY(early_gdt_descr)
25862 .word GDT_ENTRIES*8-1
25863- .long gdt_page /* Overwritten for secondary CPUs */
25864+ .long cpu_gdt_table /* Overwritten for secondary CPUs */
25865
25866 /*
25867 * The boot_gdt must mirror the equivalent in setup.S and is
25868@@ -767,5 +872,65 @@ ENTRY(early_gdt_descr)
25869 .align L1_CACHE_BYTES
25870 ENTRY(boot_gdt)
25871 .fill GDT_ENTRY_BOOT_CS,8,0
25872- .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
25873- .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
25874+ .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
25875+ .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
25876+
25877+ .align PAGE_SIZE_asm
25878+ENTRY(cpu_gdt_table)
25879+ .rept NR_CPUS
25880+ .quad 0x0000000000000000 /* NULL descriptor */
25881+ .quad 0x0000000000000000 /* 0x0b reserved */
25882+ .quad 0x0000000000000000 /* 0x13 reserved */
25883+ .quad 0x0000000000000000 /* 0x1b reserved */
25884+
25885+#ifdef CONFIG_PAX_KERNEXEC
25886+ .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
25887+#else
25888+ .quad 0x0000000000000000 /* 0x20 unused */
25889+#endif
25890+
25891+ .quad 0x0000000000000000 /* 0x28 unused */
25892+ .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
25893+ .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
25894+ .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
25895+ .quad 0x0000000000000000 /* 0x4b reserved */
25896+ .quad 0x0000000000000000 /* 0x53 reserved */
25897+ .quad 0x0000000000000000 /* 0x5b reserved */
25898+
25899+ .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
25900+ .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
25901+ .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
25902+ .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
25903+
25904+ .quad 0x0000000000000000 /* 0x80 TSS descriptor */
25905+ .quad 0x0000000000000000 /* 0x88 LDT descriptor */
25906+
25907+ /*
25908+ * Segments used for calling PnP BIOS have byte granularity.
25909+ * The code segments and data segments have fixed 64k limits,
25910+ * the transfer segment sizes are set at run time.
25911+ */
25912+ .quad 0x00409b000000ffff /* 0x90 32-bit code */
25913+ .quad 0x00009b000000ffff /* 0x98 16-bit code */
25914+ .quad 0x000093000000ffff /* 0xa0 16-bit data */
25915+ .quad 0x0000930000000000 /* 0xa8 16-bit data */
25916+ .quad 0x0000930000000000 /* 0xb0 16-bit data */
25917+
25918+ /*
25919+ * The APM segments have byte granularity and their bases
25920+ * are set at run time. All have 64k limits.
25921+ */
25922+ .quad 0x00409b000000ffff /* 0xb8 APM CS code */
25923+ .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
25924+ .quad 0x004093000000ffff /* 0xc8 APM DS data */
25925+
25926+ .quad 0x00c093000000ffff /* 0xd0 - ESPFIX SS */
25927+ .quad 0x0040930000000000 /* 0xd8 - PERCPU */
25928+ .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
25929+ .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
25930+ .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
25931+ .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
25932+
25933+ /* Be sure this is zeroed to avoid false validations in Xen */
25934+ .fill PAGE_SIZE_asm - GDT_SIZE,1,0
25935+ .endr
25936diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
25937index 1d40ca8..4d38dbd 100644
25938--- a/arch/x86/kernel/head_64.S
25939+++ b/arch/x86/kernel/head_64.S
25940@@ -20,6 +20,8 @@
25941 #include <asm/processor-flags.h>
25942 #include <asm/percpu.h>
25943 #include <asm/nops.h>
25944+#include <asm/cpufeature.h>
25945+#include <asm/alternative-asm.h>
25946
25947 #ifdef CONFIG_PARAVIRT
25948 #include <asm/asm-offsets.h>
25949@@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
25950 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
25951 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
25952 L3_START_KERNEL = pud_index(__START_KERNEL_map)
25953+L4_VMALLOC_START = pgd_index(VMALLOC_START)
25954+L3_VMALLOC_START = pud_index(VMALLOC_START)
25955+L4_VMALLOC_END = pgd_index(VMALLOC_END)
25956+L3_VMALLOC_END = pud_index(VMALLOC_END)
25957+L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
25958+L3_VMEMMAP_START = pud_index(VMEMMAP_START)
25959
25960 .text
25961 __HEAD
25962@@ -89,11 +97,33 @@ startup_64:
25963 * Fixup the physical addresses in the page table
25964 */
25965 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
25966+ addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
25967+ addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
25968+ addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
25969+ addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
25970+ addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
25971
25972- addq %rbp, level3_kernel_pgt + (510*8)(%rip)
25973- addq %rbp, level3_kernel_pgt + (511*8)(%rip)
25974+ addq %rbp, level3_ident_pgt + (0*8)(%rip)
25975+#ifndef CONFIG_XEN
25976+ addq %rbp, level3_ident_pgt + (1*8)(%rip)
25977+#endif
25978
25979+ addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
25980+
25981+ addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
25982+ addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
25983+
25984+ addq %rbp, level2_ident_pgt + (0*8)(%rip)
25985+
25986+ addq %rbp, level2_fixmap_pgt + (0*8)(%rip)
25987+ addq %rbp, level2_fixmap_pgt + (1*8)(%rip)
25988+ addq %rbp, level2_fixmap_pgt + (2*8)(%rip)
25989+ addq %rbp, level2_fixmap_pgt + (3*8)(%rip)
25990+
25991+ addq %rbp, level2_fixmap_pgt + (504*8)(%rip)
25992+ addq %rbp, level2_fixmap_pgt + (505*8)(%rip)
25993 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
25994+ addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
25995
25996 /*
25997 * Set up the identity mapping for the switchover. These
25998@@ -174,11 +204,12 @@ ENTRY(secondary_startup_64)
25999 * after the boot processor executes this code.
26000 */
26001
26002+ orq $-1, %rbp
26003 movq $(init_level4_pgt - __START_KERNEL_map), %rax
26004 1:
26005
26006- /* Enable PAE mode and PGE */
26007- movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
26008+ /* Enable PAE mode and PSE/PGE */
26009+ movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
26010 movq %rcx, %cr4
26011
26012 /* Setup early boot stage 4 level pagetables. */
26013@@ -199,10 +230,21 @@ ENTRY(secondary_startup_64)
26014 movl $MSR_EFER, %ecx
26015 rdmsr
26016 btsl $_EFER_SCE, %eax /* Enable System Call */
26017- btl $20,%edi /* No Execute supported? */
26018+ btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
26019 jnc 1f
26020 btsl $_EFER_NX, %eax
26021+ cmpq $-1, %rbp
26022+ je 1f
26023 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
26024+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
26025+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
26026+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
26027+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
26028+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*504(%rip)
26029+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*505(%rip)
26030+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
26031+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
26032+ btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
26033 1: wrmsr /* Make changes effective */
26034
26035 /* Setup cr0 */
26036@@ -282,6 +324,7 @@ ENTRY(secondary_startup_64)
26037 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
26038 * address given in m16:64.
26039 */
26040+ pax_set_fptr_mask
26041 movq initial_code(%rip),%rax
26042 pushq $0 # fake return address to stop unwinder
26043 pushq $__KERNEL_CS # set correct cs
26044@@ -313,7 +356,7 @@ ENDPROC(start_cpu0)
26045 .quad INIT_PER_CPU_VAR(irq_stack_union)
26046
26047 GLOBAL(stack_start)
26048- .quad init_thread_union+THREAD_SIZE-8
26049+ .quad init_thread_union+THREAD_SIZE-16
26050 .word 0
26051 __FINITDATA
26052
26053@@ -393,7 +436,7 @@ early_idt_handler_common:
26054 call dump_stack
26055 #ifdef CONFIG_KALLSYMS
26056 leaq early_idt_ripmsg(%rip),%rdi
26057- movq 40(%rsp),%rsi # %rip again
26058+ movq 88(%rsp),%rsi # %rip again
26059 call __print_symbol
26060 #endif
26061 #endif /* EARLY_PRINTK */
26062@@ -422,6 +465,7 @@ ENDPROC(early_idt_handler_common)
26063 early_recursion_flag:
26064 .long 0
26065
26066+ .section .rodata,"a",@progbits
26067 #ifdef CONFIG_EARLY_PRINTK
26068 early_idt_msg:
26069 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
26070@@ -444,40 +488,67 @@ GLOBAL(name)
26071 __INITDATA
26072 NEXT_PAGE(early_level4_pgt)
26073 .fill 511,8,0
26074- .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
26075+ .quad level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
26076
26077 NEXT_PAGE(early_dynamic_pgts)
26078 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
26079
26080- .data
26081+ .section .rodata,"a",@progbits
26082
26083-#ifndef CONFIG_XEN
26084 NEXT_PAGE(init_level4_pgt)
26085- .fill 512,8,0
26086-#else
26087-NEXT_PAGE(init_level4_pgt)
26088- .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
26089 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
26090 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
26091+ .org init_level4_pgt + L4_VMALLOC_START*8, 0
26092+ .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
26093+ .org init_level4_pgt + L4_VMALLOC_END*8, 0
26094+ .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
26095+ .org init_level4_pgt + L4_VMEMMAP_START*8, 0
26096+ .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
26097 .org init_level4_pgt + L4_START_KERNEL*8, 0
26098 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
26099- .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
26100+ .quad level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
26101+
26102+#ifdef CONFIG_PAX_PER_CPU_PGD
26103+NEXT_PAGE(cpu_pgd)
26104+ .rept 2*NR_CPUS
26105+ .fill 512,8,0
26106+ .endr
26107+#endif
26108
26109 NEXT_PAGE(level3_ident_pgt)
26110 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
26111+#ifdef CONFIG_XEN
26112 .fill 511, 8, 0
26113+#else
26114+ .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
26115+ .fill 510,8,0
26116+#endif
26117+
26118+NEXT_PAGE(level3_vmalloc_start_pgt)
26119+ .fill 512,8,0
26120+
26121+NEXT_PAGE(level3_vmalloc_end_pgt)
26122+ .fill 512,8,0
26123+
26124+NEXT_PAGE(level3_vmemmap_pgt)
26125+ .fill L3_VMEMMAP_START,8,0
26126+ .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
26127+
26128 NEXT_PAGE(level2_ident_pgt)
26129- /* Since I easily can, map the first 1G.
26130+ .quad level1_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
26131+ /* Since I easily can, map the first 2G.
26132 * Don't set NX because code runs from these pages.
26133 */
26134- PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
26135-#endif
26136+ PMDS(PMD_SIZE, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD - 1)
26137
26138 NEXT_PAGE(level3_kernel_pgt)
26139 .fill L3_START_KERNEL,8,0
26140 /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */
26141 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
26142- .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
26143+ .quad level2_fixmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
26144+
26145+NEXT_PAGE(level2_vmemmap_pgt)
26146+ .fill 512,8,0
26147
26148 NEXT_PAGE(level2_kernel_pgt)
26149 /*
26150@@ -494,31 +565,79 @@ NEXT_PAGE(level2_kernel_pgt)
26151 KERNEL_IMAGE_SIZE/PMD_SIZE)
26152
26153 NEXT_PAGE(level2_fixmap_pgt)
26154- .fill 506,8,0
26155- .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
26156- /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
26157- .fill 5,8,0
26158+ .quad level1_modules_pgt - __START_KERNEL_map + 0 * PAGE_SIZE + _KERNPG_TABLE
26159+ .quad level1_modules_pgt - __START_KERNEL_map + 1 * PAGE_SIZE + _KERNPG_TABLE
26160+ .quad level1_modules_pgt - __START_KERNEL_map + 2 * PAGE_SIZE + _KERNPG_TABLE
26161+ .quad level1_modules_pgt - __START_KERNEL_map + 3 * PAGE_SIZE + _KERNPG_TABLE
26162+ .fill 500,8,0
26163+ .quad level1_fixmap_pgt - __START_KERNEL_map + 0 * PAGE_SIZE + _KERNPG_TABLE
26164+ .quad level1_fixmap_pgt - __START_KERNEL_map + 1 * PAGE_SIZE + _KERNPG_TABLE
26165+ .quad level1_fixmap_pgt - __START_KERNEL_map + 2 * PAGE_SIZE + _KERNPG_TABLE
26166+ .quad level1_vsyscall_pgt - __START_KERNEL_map + _KERNPG_TABLE
26167+ /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
26168+ .fill 4,8,0
26169+
26170+NEXT_PAGE(level1_ident_pgt)
26171+ .fill 512,8,0
26172+
26173+NEXT_PAGE(level1_modules_pgt)
26174+ .fill 4*512,8,0
26175
26176 NEXT_PAGE(level1_fixmap_pgt)
26177+ .fill 3*512,8,0
26178+
26179+NEXT_PAGE(level1_vsyscall_pgt)
26180 .fill 512,8,0
26181
26182 #undef PMDS
26183
26184- .data
26185+ .align PAGE_SIZE
26186+ENTRY(cpu_gdt_table)
26187+ .rept NR_CPUS
26188+ .quad 0x0000000000000000 /* NULL descriptor */
26189+ .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
26190+ .quad 0x00af9b000000ffff /* __KERNEL_CS */
26191+ .quad 0x00cf93000000ffff /* __KERNEL_DS */
26192+ .quad 0x00cffb000000ffff /* __USER32_CS */
26193+ .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
26194+ .quad 0x00affb000000ffff /* __USER_CS */
26195+
26196+#ifdef CONFIG_PAX_KERNEXEC
26197+ .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
26198+#else
26199+ .quad 0x0 /* unused */
26200+#endif
26201+
26202+ .quad 0,0 /* TSS */
26203+ .quad 0,0 /* LDT */
26204+ .quad 0,0,0 /* three TLS descriptors */
26205+ .quad 0x0000f40000000000 /* node/CPU stored in limit */
26206+ /* asm/segment.h:GDT_ENTRIES must match this */
26207+
26208+#ifdef CONFIG_PAX_MEMORY_UDEREF
26209+ .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
26210+#else
26211+ .quad 0x0 /* unused */
26212+#endif
26213+
26214+ /* zero the remaining page */
26215+ .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
26216+ .endr
26217+
26218 .align 16
26219 .globl early_gdt_descr
26220 early_gdt_descr:
26221 .word GDT_ENTRIES*8-1
26222 early_gdt_descr_base:
26223- .quad INIT_PER_CPU_VAR(gdt_page)
26224+ .quad cpu_gdt_table
26225
26226 ENTRY(phys_base)
26227 /* This must match the first entry in level2_kernel_pgt */
26228 .quad 0x0000000000000000
26229
26230 #include "../../x86/xen/xen-head.S"
26231-
26232- __PAGE_ALIGNED_BSS
26233+
26234+ .section .rodata,"a",@progbits
26235 NEXT_PAGE(empty_zero_page)
26236 .skip PAGE_SIZE
26237
26238diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
26239index 64341aa..b1e6632 100644
26240--- a/arch/x86/kernel/i386_ksyms_32.c
26241+++ b/arch/x86/kernel/i386_ksyms_32.c
26242@@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
26243 EXPORT_SYMBOL(cmpxchg8b_emu);
26244 #endif
26245
26246+EXPORT_SYMBOL_GPL(cpu_gdt_table);
26247+
26248 /* Networking helper routines. */
26249 EXPORT_SYMBOL(csum_partial_copy_generic);
26250+EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
26251+EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
26252
26253 EXPORT_SYMBOL(__get_user_1);
26254 EXPORT_SYMBOL(__get_user_2);
26255@@ -42,3 +46,11 @@ EXPORT_SYMBOL(empty_zero_page);
26256 EXPORT_SYMBOL(___preempt_schedule);
26257 EXPORT_SYMBOL(___preempt_schedule_notrace);
26258 #endif
26259+
26260+#ifdef CONFIG_PAX_KERNEXEC
26261+EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
26262+#endif
26263+
26264+#ifdef CONFIG_PAX_PER_CPU_PGD
26265+EXPORT_SYMBOL(cpu_pgd);
26266+#endif
26267diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
26268index 16cb827..372334f 100644
26269--- a/arch/x86/kernel/i8259.c
26270+++ b/arch/x86/kernel/i8259.c
26271@@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
26272 static void make_8259A_irq(unsigned int irq)
26273 {
26274 disable_irq_nosync(irq);
26275- io_apic_irqs &= ~(1<<irq);
26276+ io_apic_irqs &= ~(1UL<<irq);
26277 irq_set_chip_and_handler(irq, &i8259A_chip, handle_level_irq);
26278 enable_irq(irq);
26279 }
26280@@ -208,7 +208,7 @@ spurious_8259A_irq:
26281 "spurious 8259A interrupt: IRQ%d.\n", irq);
26282 spurious_irq_mask |= irqmask;
26283 }
26284- atomic_inc(&irq_err_count);
26285+ atomic_inc_unchecked(&irq_err_count);
26286 /*
26287 * Theoretically we do not have to handle this IRQ,
26288 * but in Linux this does not cause problems and is
26289@@ -349,14 +349,16 @@ static void init_8259A(int auto_eoi)
26290 /* (slave's support for AEOI in flat mode is to be investigated) */
26291 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
26292
26293+ pax_open_kernel();
26294 if (auto_eoi)
26295 /*
26296 * In AEOI mode we just have to mask the interrupt
26297 * when acking.
26298 */
26299- i8259A_chip.irq_mask_ack = disable_8259A_irq;
26300+ *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
26301 else
26302- i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
26303+ *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
26304+ pax_close_kernel();
26305
26306 udelay(100); /* wait for 8259A to initialize */
26307
26308diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
26309index a979b5b..1d6db75 100644
26310--- a/arch/x86/kernel/io_delay.c
26311+++ b/arch/x86/kernel/io_delay.c
26312@@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
26313 * Quirk table for systems that misbehave (lock up, etc.) if port
26314 * 0x80 is used:
26315 */
26316-static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
26317+static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
26318 {
26319 .callback = dmi_io_delay_0xed_port,
26320 .ident = "Compaq Presario V6000",
26321diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
26322index 37dae79..620dd84 100644
26323--- a/arch/x86/kernel/ioport.c
26324+++ b/arch/x86/kernel/ioport.c
26325@@ -6,6 +6,7 @@
26326 #include <linux/sched.h>
26327 #include <linux/kernel.h>
26328 #include <linux/capability.h>
26329+#include <linux/security.h>
26330 #include <linux/errno.h>
26331 #include <linux/types.h>
26332 #include <linux/ioport.h>
26333@@ -30,6 +31,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
26334 return -EINVAL;
26335 if (turn_on && !capable(CAP_SYS_RAWIO))
26336 return -EPERM;
26337+#ifdef CONFIG_GRKERNSEC_IO
26338+ if (turn_on && grsec_disable_privio) {
26339+ gr_handle_ioperm();
26340+ return -ENODEV;
26341+ }
26342+#endif
26343
26344 /*
26345 * If it's the first ioperm() call in this thread's lifetime, set the
26346@@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
26347 * because the ->io_bitmap_max value must match the bitmap
26348 * contents:
26349 */
26350- tss = &per_cpu(cpu_tss, get_cpu());
26351+ tss = cpu_tss + get_cpu();
26352
26353 if (turn_on)
26354 bitmap_clear(t->io_bitmap_ptr, from, num);
26355@@ -105,6 +112,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
26356 if (level > old) {
26357 if (!capable(CAP_SYS_RAWIO))
26358 return -EPERM;
26359+#ifdef CONFIG_GRKERNSEC_IO
26360+ if (grsec_disable_privio) {
26361+ gr_handle_iopl();
26362+ return -ENODEV;
26363+ }
26364+#endif
26365 }
26366 regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
26367 t->iopl = level << 12;
26368diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
26369index c7dfe1b..146f63c 100644
26370--- a/arch/x86/kernel/irq.c
26371+++ b/arch/x86/kernel/irq.c
26372@@ -28,7 +28,7 @@ EXPORT_PER_CPU_SYMBOL(irq_stat);
26373 DEFINE_PER_CPU(struct pt_regs *, irq_regs);
26374 EXPORT_PER_CPU_SYMBOL(irq_regs);
26375
26376-atomic_t irq_err_count;
26377+atomic_unchecked_t irq_err_count;
26378
26379 /* Function pointer for generic interrupt vector handling */
26380 void (*x86_platform_ipi_callback)(void) = NULL;
26381@@ -144,9 +144,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
26382 seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count);
26383 seq_puts(p, " Hypervisor callback interrupts\n");
26384 #endif
26385- seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
26386+ seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
26387 #if defined(CONFIG_X86_IO_APIC)
26388- seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
26389+ seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
26390 #endif
26391 #ifdef CONFIG_HAVE_KVM
26392 seq_printf(p, "%*s: ", prec, "PIN");
26393@@ -198,7 +198,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
26394
26395 u64 arch_irq_stat(void)
26396 {
26397- u64 sum = atomic_read(&irq_err_count);
26398+ u64 sum = atomic_read_unchecked(&irq_err_count);
26399 return sum;
26400 }
26401
26402diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
26403index cd74f59..588af0b 100644
26404--- a/arch/x86/kernel/irq_32.c
26405+++ b/arch/x86/kernel/irq_32.c
26406@@ -23,6 +23,8 @@
26407
26408 #ifdef CONFIG_DEBUG_STACKOVERFLOW
26409
26410+extern void gr_handle_kernel_exploit(void);
26411+
26412 int sysctl_panic_on_stackoverflow __read_mostly;
26413
26414 /* Debugging check for stack overflow: is there less than 1KB free? */
26415@@ -33,13 +35,14 @@ static int check_stack_overflow(void)
26416 __asm__ __volatile__("andl %%esp,%0" :
26417 "=r" (sp) : "0" (THREAD_SIZE - 1));
26418
26419- return sp < (sizeof(struct thread_info) + STACK_WARN);
26420+ return sp < STACK_WARN;
26421 }
26422
26423 static void print_stack_overflow(void)
26424 {
26425 printk(KERN_WARNING "low stack detected by irq handler\n");
26426 dump_stack();
26427+ gr_handle_kernel_exploit();
26428 if (sysctl_panic_on_stackoverflow)
26429 panic("low stack detected by irq handler - check messages\n");
26430 }
26431@@ -71,10 +74,9 @@ static inline void *current_stack(void)
26432 static inline int
26433 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
26434 {
26435- struct irq_stack *curstk, *irqstk;
26436+ struct irq_stack *irqstk;
26437 u32 *isp, *prev_esp, arg1, arg2;
26438
26439- curstk = (struct irq_stack *) current_stack();
26440 irqstk = __this_cpu_read(hardirq_stack);
26441
26442 /*
26443@@ -83,15 +85,19 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
26444 * handler) we can't do that and just have to keep using the
26445 * current stack (which is the irq stack already after all)
26446 */
26447- if (unlikely(curstk == irqstk))
26448+ if (unlikely((void *)current_stack_pointer - (void *)irqstk < THREAD_SIZE))
26449 return 0;
26450
26451- isp = (u32 *) ((char *)irqstk + sizeof(*irqstk));
26452+ isp = (u32 *) ((char *)irqstk + sizeof(*irqstk) - 8);
26453
26454 /* Save the next esp at the bottom of the stack */
26455 prev_esp = (u32 *)irqstk;
26456 *prev_esp = current_stack_pointer();
26457
26458+#ifdef CONFIG_PAX_MEMORY_UDEREF
26459+ __set_fs(MAKE_MM_SEG(0));
26460+#endif
26461+
26462 if (unlikely(overflow))
26463 call_on_stack(print_stack_overflow, isp);
26464
26465@@ -102,6 +108,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
26466 : "0" (irq), "1" (desc), "2" (isp),
26467 "D" (desc->handle_irq)
26468 : "memory", "cc", "ecx");
26469+
26470+#ifdef CONFIG_PAX_MEMORY_UDEREF
26471+ __set_fs(current_thread_info()->addr_limit);
26472+#endif
26473+
26474 return 1;
26475 }
26476
26477@@ -110,32 +121,18 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
26478 */
26479 void irq_ctx_init(int cpu)
26480 {
26481- struct irq_stack *irqstk;
26482-
26483 if (per_cpu(hardirq_stack, cpu))
26484 return;
26485
26486- irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
26487- THREADINFO_GFP,
26488- THREAD_SIZE_ORDER));
26489- per_cpu(hardirq_stack, cpu) = irqstk;
26490-
26491- irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
26492- THREADINFO_GFP,
26493- THREAD_SIZE_ORDER));
26494- per_cpu(softirq_stack, cpu) = irqstk;
26495-
26496- printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
26497- cpu, per_cpu(hardirq_stack, cpu), per_cpu(softirq_stack, cpu));
26498+ per_cpu(hardirq_stack, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
26499+ per_cpu(softirq_stack, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
26500 }
26501
26502 void do_softirq_own_stack(void)
26503 {
26504- struct thread_info *curstk;
26505 struct irq_stack *irqstk;
26506 u32 *isp, *prev_esp;
26507
26508- curstk = current_stack();
26509 irqstk = __this_cpu_read(softirq_stack);
26510
26511 /* build the stack frame on the softirq stack */
26512@@ -145,7 +142,16 @@ void do_softirq_own_stack(void)
26513 prev_esp = (u32 *)irqstk;
26514 *prev_esp = current_stack_pointer();
26515
26516+#ifdef CONFIG_PAX_MEMORY_UDEREF
26517+ __set_fs(MAKE_MM_SEG(0));
26518+#endif
26519+
26520 call_on_stack(__do_softirq, isp);
26521+
26522+#ifdef CONFIG_PAX_MEMORY_UDEREF
26523+ __set_fs(current_thread_info()->addr_limit);
26524+#endif
26525+
26526 }
26527
26528 bool handle_irq(unsigned irq, struct pt_regs *regs)
26529diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
26530index bc4604e..0be227d 100644
26531--- a/arch/x86/kernel/irq_64.c
26532+++ b/arch/x86/kernel/irq_64.c
26533@@ -20,6 +20,8 @@
26534 #include <asm/idle.h>
26535 #include <asm/apic.h>
26536
26537+extern void gr_handle_kernel_exploit(void);
26538+
26539 int sysctl_panic_on_stackoverflow;
26540
26541 /*
26542@@ -63,6 +65,8 @@ static inline void stack_overflow_check(struct pt_regs *regs)
26543 irq_stack_top, irq_stack_bottom,
26544 estack_top, estack_bottom);
26545
26546+ gr_handle_kernel_exploit();
26547+
26548 if (sysctl_panic_on_stackoverflow)
26549 panic("low stack detected by irq handler - check messages\n");
26550 #endif
26551diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
26552index 26d5a55..063fef8 100644
26553--- a/arch/x86/kernel/jump_label.c
26554+++ b/arch/x86/kernel/jump_label.c
26555@@ -31,6 +31,8 @@ static void bug_at(unsigned char *ip, int line)
26556 * Something went wrong. Crash the box, as something could be
26557 * corrupting the kernel.
26558 */
26559+ ip = (unsigned char *)ktla_ktva((unsigned long)ip);
26560+ pr_warning("Unexpected op at %pS [%p] %s:%d\n", ip, ip, __FILE__, line);
26561 pr_warning("Unexpected op at %pS [%p] (%02x %02x %02x %02x %02x) %s:%d\n",
26562 ip, ip, ip[0], ip[1], ip[2], ip[3], ip[4], __FILE__, line);
26563 BUG();
26564@@ -51,7 +53,7 @@ static void __jump_label_transform(struct jump_entry *entry,
26565 * Jump label is enabled for the first time.
26566 * So we expect a default_nop...
26567 */
26568- if (unlikely(memcmp((void *)entry->code, default_nop, 5)
26569+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5)
26570 != 0))
26571 bug_at((void *)entry->code, __LINE__);
26572 } else {
26573@@ -59,7 +61,7 @@ static void __jump_label_transform(struct jump_entry *entry,
26574 * ...otherwise expect an ideal_nop. Otherwise
26575 * something went horribly wrong.
26576 */
26577- if (unlikely(memcmp((void *)entry->code, ideal_nop, 5)
26578+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5)
26579 != 0))
26580 bug_at((void *)entry->code, __LINE__);
26581 }
26582@@ -75,13 +77,13 @@ static void __jump_label_transform(struct jump_entry *entry,
26583 * are converting the default nop to the ideal nop.
26584 */
26585 if (init) {
26586- if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
26587+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
26588 bug_at((void *)entry->code, __LINE__);
26589 } else {
26590 code.jump = 0xe9;
26591 code.offset = entry->target -
26592 (entry->code + JUMP_LABEL_NOP_SIZE);
26593- if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
26594+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
26595 bug_at((void *)entry->code, __LINE__);
26596 }
26597 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
26598diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
26599index d6178d9..598681f 100644
26600--- a/arch/x86/kernel/kgdb.c
26601+++ b/arch/x86/kernel/kgdb.c
26602@@ -228,7 +228,10 @@ static void kgdb_correct_hw_break(void)
26603 bp->attr.bp_addr = breakinfo[breakno].addr;
26604 bp->attr.bp_len = breakinfo[breakno].len;
26605 bp->attr.bp_type = breakinfo[breakno].type;
26606- info->address = breakinfo[breakno].addr;
26607+ if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
26608+ info->address = ktla_ktva(breakinfo[breakno].addr);
26609+ else
26610+ info->address = breakinfo[breakno].addr;
26611 info->len = breakinfo[breakno].len;
26612 info->type = breakinfo[breakno].type;
26613 val = arch_install_hw_breakpoint(bp);
26614@@ -475,12 +478,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
26615 case 'k':
26616 /* clear the trace bit */
26617 linux_regs->flags &= ~X86_EFLAGS_TF;
26618- atomic_set(&kgdb_cpu_doing_single_step, -1);
26619+ atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
26620
26621 /* set the trace bit if we're stepping */
26622 if (remcomInBuffer[0] == 's') {
26623 linux_regs->flags |= X86_EFLAGS_TF;
26624- atomic_set(&kgdb_cpu_doing_single_step,
26625+ atomic_set_unchecked(&kgdb_cpu_doing_single_step,
26626 raw_smp_processor_id());
26627 }
26628
26629@@ -545,7 +548,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
26630
26631 switch (cmd) {
26632 case DIE_DEBUG:
26633- if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
26634+ if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
26635 if (user_mode(regs))
26636 return single_step_cont(regs, args);
26637 break;
26638@@ -750,11 +753,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
26639 #endif /* CONFIG_DEBUG_RODATA */
26640
26641 bpt->type = BP_BREAKPOINT;
26642- err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
26643+ err = probe_kernel_read(bpt->saved_instr, (const void *)ktla_ktva(bpt->bpt_addr),
26644 BREAK_INSTR_SIZE);
26645 if (err)
26646 return err;
26647- err = probe_kernel_write((char *)bpt->bpt_addr,
26648+ err = probe_kernel_write((void *)ktla_ktva(bpt->bpt_addr),
26649 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
26650 #ifdef CONFIG_DEBUG_RODATA
26651 if (!err)
26652@@ -767,7 +770,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
26653 return -EBUSY;
26654 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
26655 BREAK_INSTR_SIZE);
26656- err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
26657+ err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
26658 if (err)
26659 return err;
26660 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
26661@@ -792,13 +795,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
26662 if (mutex_is_locked(&text_mutex))
26663 goto knl_write;
26664 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
26665- err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
26666+ err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
26667 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
26668 goto knl_write;
26669 return err;
26670 knl_write:
26671 #endif /* CONFIG_DEBUG_RODATA */
26672- return probe_kernel_write((char *)bpt->bpt_addr,
26673+ return probe_kernel_write((void *)ktla_ktva(bpt->bpt_addr),
26674 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
26675 }
26676
26677diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
26678index 1deffe6..3be342a 100644
26679--- a/arch/x86/kernel/kprobes/core.c
26680+++ b/arch/x86/kernel/kprobes/core.c
26681@@ -120,9 +120,12 @@ __synthesize_relative_insn(void *from, void *to, u8 op)
26682 s32 raddr;
26683 } __packed *insn;
26684
26685- insn = (struct __arch_relative_insn *)from;
26686+ insn = (struct __arch_relative_insn *)ktla_ktva((unsigned long)from);
26687+
26688+ pax_open_kernel();
26689 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
26690 insn->op = op;
26691+ pax_close_kernel();
26692 }
26693
26694 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
26695@@ -168,7 +171,7 @@ int can_boost(kprobe_opcode_t *opcodes)
26696 kprobe_opcode_t opcode;
26697 kprobe_opcode_t *orig_opcodes = opcodes;
26698
26699- if (search_exception_tables((unsigned long)opcodes))
26700+ if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
26701 return 0; /* Page fault may occur on this address. */
26702
26703 retry:
26704@@ -260,12 +263,12 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
26705 * Fortunately, we know that the original code is the ideal 5-byte
26706 * long NOP.
26707 */
26708- memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
26709+ memcpy(buf, (void *)ktla_ktva(addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
26710 if (faddr)
26711 memcpy(buf, ideal_nops[NOP_ATOMIC5], 5);
26712 else
26713 buf[0] = kp->opcode;
26714- return (unsigned long)buf;
26715+ return ktva_ktla((unsigned long)buf);
26716 }
26717
26718 /*
26719@@ -367,7 +370,9 @@ int __copy_instruction(u8 *dest, u8 *src)
26720 /* Another subsystem puts a breakpoint, failed to recover */
26721 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
26722 return 0;
26723+ pax_open_kernel();
26724 memcpy(dest, insn.kaddr, length);
26725+ pax_close_kernel();
26726
26727 #ifdef CONFIG_X86_64
26728 if (insn_rip_relative(&insn)) {
26729@@ -394,7 +399,9 @@ int __copy_instruction(u8 *dest, u8 *src)
26730 return 0;
26731 }
26732 disp = (u8 *) dest + insn_offset_displacement(&insn);
26733+ pax_open_kernel();
26734 *(s32 *) disp = (s32) newdisp;
26735+ pax_close_kernel();
26736 }
26737 #endif
26738 return length;
26739@@ -536,7 +543,7 @@ static void setup_singlestep(struct kprobe *p, struct pt_regs *regs,
26740 * nor set current_kprobe, because it doesn't use single
26741 * stepping.
26742 */
26743- regs->ip = (unsigned long)p->ainsn.insn;
26744+ regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
26745 preempt_enable_no_resched();
26746 return;
26747 }
26748@@ -553,9 +560,9 @@ static void setup_singlestep(struct kprobe *p, struct pt_regs *regs,
26749 regs->flags &= ~X86_EFLAGS_IF;
26750 /* single step inline if the instruction is an int3 */
26751 if (p->opcode == BREAKPOINT_INSTRUCTION)
26752- regs->ip = (unsigned long)p->addr;
26753+ regs->ip = ktla_ktva((unsigned long)p->addr);
26754 else
26755- regs->ip = (unsigned long)p->ainsn.insn;
26756+ regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
26757 }
26758 NOKPROBE_SYMBOL(setup_singlestep);
26759
26760@@ -640,7 +647,7 @@ int kprobe_int3_handler(struct pt_regs *regs)
26761 setup_singlestep(p, regs, kcb, 0);
26762 return 1;
26763 }
26764- } else if (*addr != BREAKPOINT_INSTRUCTION) {
26765+ } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
26766 /*
26767 * The breakpoint instruction was removed right
26768 * after we hit it. Another cpu has removed
26769@@ -687,6 +694,9 @@ static void __used kretprobe_trampoline_holder(void)
26770 " movq %rax, 152(%rsp)\n"
26771 RESTORE_REGS_STRING
26772 " popfq\n"
26773+#ifdef KERNEXEC_PLUGIN
26774+ " btsq $63,(%rsp)\n"
26775+#endif
26776 #else
26777 " pushf\n"
26778 SAVE_REGS_STRING
26779@@ -827,7 +837,7 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs,
26780 struct kprobe_ctlblk *kcb)
26781 {
26782 unsigned long *tos = stack_addr(regs);
26783- unsigned long copy_ip = (unsigned long)p->ainsn.insn;
26784+ unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
26785 unsigned long orig_ip = (unsigned long)p->addr;
26786 kprobe_opcode_t *insn = p->ainsn.insn;
26787
26788diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
26789index 7b3b9d1..e2478b91 100644
26790--- a/arch/x86/kernel/kprobes/opt.c
26791+++ b/arch/x86/kernel/kprobes/opt.c
26792@@ -79,6 +79,7 @@ found:
26793 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
26794 static void synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
26795 {
26796+ pax_open_kernel();
26797 #ifdef CONFIG_X86_64
26798 *addr++ = 0x48;
26799 *addr++ = 0xbf;
26800@@ -86,6 +87,7 @@ static void synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
26801 *addr++ = 0xb8;
26802 #endif
26803 *(unsigned long *)addr = val;
26804+ pax_close_kernel();
26805 }
26806
26807 asm (
26808@@ -342,7 +344,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
26809 * Verify if the address gap is in 2GB range, because this uses
26810 * a relative jump.
26811 */
26812- rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
26813+ rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
26814 if (abs(rel) > 0x7fffffff) {
26815 __arch_remove_optimized_kprobe(op, 0);
26816 return -ERANGE;
26817@@ -359,16 +361,18 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
26818 op->optinsn.size = ret;
26819
26820 /* Copy arch-dep-instance from template */
26821- memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
26822+ pax_open_kernel();
26823+ memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
26824+ pax_close_kernel();
26825
26826 /* Set probe information */
26827 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
26828
26829 /* Set probe function call */
26830- synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
26831+ synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
26832
26833 /* Set returning jmp instruction at the tail of out-of-line buffer */
26834- synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
26835+ synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
26836 (u8 *)op->kp.addr + op->optinsn.size);
26837
26838 flush_icache_range((unsigned long) buf,
26839@@ -393,7 +397,7 @@ void arch_optimize_kprobes(struct list_head *oplist)
26840 WARN_ON(kprobe_disabled(&op->kp));
26841
26842 /* Backup instructions which will be replaced by jump address */
26843- memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
26844+ memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
26845 RELATIVE_ADDR_SIZE);
26846
26847 insn_buf[0] = RELATIVEJUMP_OPCODE;
26848@@ -441,7 +445,7 @@ int setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
26849 /* This kprobe is really able to run optimized path. */
26850 op = container_of(p, struct optimized_kprobe, kp);
26851 /* Detour through copied instructions */
26852- regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
26853+ regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
26854 if (!reenter)
26855 reset_current_kprobe();
26856 preempt_enable_no_resched();
26857diff --git a/arch/x86/kernel/ksysfs.c b/arch/x86/kernel/ksysfs.c
26858index c2bedae..25e7ab60 100644
26859--- a/arch/x86/kernel/ksysfs.c
26860+++ b/arch/x86/kernel/ksysfs.c
26861@@ -184,7 +184,7 @@ out:
26862
26863 static struct kobj_attribute type_attr = __ATTR_RO(type);
26864
26865-static struct bin_attribute data_attr = {
26866+static bin_attribute_no_const data_attr __read_only = {
26867 .attr = {
26868 .name = "data",
26869 .mode = S_IRUGO,
26870diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
26871index 49487b4..a94a0d3 100644
26872--- a/arch/x86/kernel/kvmclock.c
26873+++ b/arch/x86/kernel/kvmclock.c
26874@@ -29,7 +29,7 @@
26875 #include <asm/x86_init.h>
26876 #include <asm/reboot.h>
26877
26878-static int kvmclock = 1;
26879+static int kvmclock __read_only = 1;
26880 static int msr_kvm_system_time = MSR_KVM_SYSTEM_TIME;
26881 static int msr_kvm_wall_clock = MSR_KVM_WALL_CLOCK;
26882
26883@@ -41,7 +41,7 @@ static int parse_no_kvmclock(char *arg)
26884 early_param("no-kvmclock", parse_no_kvmclock);
26885
26886 /* The hypervisor will put information about time periodically here */
26887-static struct pvclock_vsyscall_time_info *hv_clock;
26888+static struct pvclock_vsyscall_time_info hv_clock[NR_CPUS] __page_aligned_bss;
26889 static struct pvclock_wall_clock wall_clock;
26890
26891 /*
26892@@ -132,7 +132,7 @@ bool kvm_check_and_clear_guest_paused(void)
26893 struct pvclock_vcpu_time_info *src;
26894 int cpu = smp_processor_id();
26895
26896- if (!hv_clock)
26897+ if (!kvmclock)
26898 return ret;
26899
26900 src = &hv_clock[cpu].pvti;
26901@@ -159,7 +159,7 @@ int kvm_register_clock(char *txt)
26902 int low, high, ret;
26903 struct pvclock_vcpu_time_info *src;
26904
26905- if (!hv_clock)
26906+ if (!kvmclock)
26907 return 0;
26908
26909 src = &hv_clock[cpu].pvti;
26910@@ -219,7 +219,6 @@ static void kvm_shutdown(void)
26911 void __init kvmclock_init(void)
26912 {
26913 struct pvclock_vcpu_time_info *vcpu_time;
26914- unsigned long mem;
26915 int size, cpu;
26916 u8 flags;
26917
26918@@ -237,15 +236,8 @@ void __init kvmclock_init(void)
26919 printk(KERN_INFO "kvm-clock: Using msrs %x and %x",
26920 msr_kvm_system_time, msr_kvm_wall_clock);
26921
26922- mem = memblock_alloc(size, PAGE_SIZE);
26923- if (!mem)
26924- return;
26925- hv_clock = __va(mem);
26926- memset(hv_clock, 0, size);
26927-
26928 if (kvm_register_clock("primary cpu clock")) {
26929- hv_clock = NULL;
26930- memblock_free(mem, size);
26931+ kvmclock = 0;
26932 return;
26933 }
26934 pv_time_ops.sched_clock = kvm_clock_read;
26935@@ -286,7 +278,7 @@ int __init kvm_setup_vsyscall_timeinfo(void)
26936 struct pvclock_vcpu_time_info *vcpu_time;
26937 unsigned int size;
26938
26939- if (!hv_clock)
26940+ if (!kvmclock)
26941 return 0;
26942
26943 size = PAGE_ALIGN(sizeof(struct pvclock_vsyscall_time_info)*NR_CPUS);
26944diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
26945index 2bcc052..864eb84 100644
26946--- a/arch/x86/kernel/ldt.c
26947+++ b/arch/x86/kernel/ldt.c
26948@@ -11,6 +11,7 @@
26949 #include <linux/sched.h>
26950 #include <linux/string.h>
26951 #include <linux/mm.h>
26952+#include <linux/ratelimit.h>
26953 #include <linux/smp.h>
26954 #include <linux/slab.h>
26955 #include <linux/vmalloc.h>
26956@@ -21,6 +22,14 @@
26957 #include <asm/mmu_context.h>
26958 #include <asm/syscalls.h>
26959
26960+#ifdef CONFIG_GRKERNSEC
26961+int sysctl_modify_ldt __read_only = 0;
26962+#elif defined(CONFIG_DEFAULT_MODIFY_LDT_SYSCALL)
26963+int sysctl_modify_ldt __read_only = 1;
26964+#else
26965+int sysctl_modify_ldt __read_only = 0;
26966+#endif
26967+
26968 /* context.lock is held for us, so we don't need any locking. */
26969 static void flush_ldt(void *current_mm)
26970 {
26971@@ -109,6 +118,23 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
26972 struct mm_struct *old_mm;
26973 int retval = 0;
26974
26975+ if (tsk == current) {
26976+ mm->context.vdso = 0;
26977+
26978+#ifdef CONFIG_X86_32
26979+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
26980+ mm->context.user_cs_base = 0UL;
26981+ mm->context.user_cs_limit = ~0UL;
26982+
26983+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
26984+ cpumask_clear(&mm->context.cpu_user_cs_mask);
26985+#endif
26986+
26987+#endif
26988+#endif
26989+
26990+ }
26991+
26992 mutex_init(&mm->context.lock);
26993 old_mm = current->mm;
26994 if (!old_mm) {
26995@@ -235,6 +261,14 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
26996 /* The user wants to clear the entry. */
26997 memset(&ldt, 0, sizeof(ldt));
26998 } else {
26999+
27000+#ifdef CONFIG_PAX_SEGMEXEC
27001+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
27002+ error = -EINVAL;
27003+ goto out;
27004+ }
27005+#endif
27006+
27007 if (!IS_ENABLED(CONFIG_X86_16BIT) && !ldt_info.seg_32bit) {
27008 error = -EINVAL;
27009 goto out;
27010@@ -276,6 +310,15 @@ asmlinkage int sys_modify_ldt(int func, void __user *ptr,
27011 {
27012 int ret = -ENOSYS;
27013
27014+ if (!sysctl_modify_ldt) {
27015+ printk_ratelimited(KERN_INFO
27016+ "Denied a call to modify_ldt() from %s[%d] (uid: %d)."
27017+ " Adjust sysctl if this was not an exploit attempt.\n",
27018+ current->comm, task_pid_nr(current),
27019+ from_kuid_munged(current_user_ns(), current_uid()));
27020+ return ret;
27021+ }
27022+
27023 switch (func) {
27024 case 0:
27025 ret = read_ldt(ptr, bytecount);
27026diff --git a/arch/x86/kernel/livepatch.c b/arch/x86/kernel/livepatch.c
27027index ff3c3101d..d7c0cd8 100644
27028--- a/arch/x86/kernel/livepatch.c
27029+++ b/arch/x86/kernel/livepatch.c
27030@@ -41,9 +41,10 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
27031 int ret, numpages, size = 4;
27032 bool readonly;
27033 unsigned long val;
27034- unsigned long core = (unsigned long)mod->module_core;
27035- unsigned long core_ro_size = mod->core_ro_size;
27036- unsigned long core_size = mod->core_size;
27037+ unsigned long core_rx = (unsigned long)mod->module_core_rx;
27038+ unsigned long core_rw = (unsigned long)mod->module_core_rw;
27039+ unsigned long core_size_rx = mod->core_size_rx;
27040+ unsigned long core_size_rw = mod->core_size_rw;
27041
27042 switch (type) {
27043 case R_X86_64_NONE:
27044@@ -66,11 +67,12 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
27045 return -EINVAL;
27046 }
27047
27048- if (loc < core || loc >= core + core_size)
27049+ if ((loc < core_rx || loc >= core_rx + core_size_rx) &&
27050+ (loc < core_rw || loc >= core_rw + core_size_rw))
27051 /* loc does not point to any symbol inside the module */
27052 return -EINVAL;
27053
27054- if (loc < core + core_ro_size)
27055+ if (loc < core_rx + core_size_rx)
27056 readonly = true;
27057 else
27058 readonly = false;
27059diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
27060index 469b23d..5449cfe 100644
27061--- a/arch/x86/kernel/machine_kexec_32.c
27062+++ b/arch/x86/kernel/machine_kexec_32.c
27063@@ -26,7 +26,7 @@
27064 #include <asm/cacheflush.h>
27065 #include <asm/debugreg.h>
27066
27067-static void set_idt(void *newidt, __u16 limit)
27068+static void set_idt(struct desc_struct *newidt, __u16 limit)
27069 {
27070 struct desc_ptr curidt;
27071
27072@@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
27073 }
27074
27075
27076-static void set_gdt(void *newgdt, __u16 limit)
27077+static void set_gdt(struct desc_struct *newgdt, __u16 limit)
27078 {
27079 struct desc_ptr curgdt;
27080
27081@@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
27082 }
27083
27084 control_page = page_address(image->control_code_page);
27085- memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
27086+ memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
27087
27088 relocate_kernel_ptr = control_page;
27089 page_list[PA_CONTROL_PAGE] = __pa(control_page);
27090diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
27091index 94ea120..4154cea 100644
27092--- a/arch/x86/kernel/mcount_64.S
27093+++ b/arch/x86/kernel/mcount_64.S
27094@@ -7,7 +7,7 @@
27095 #include <linux/linkage.h>
27096 #include <asm/ptrace.h>
27097 #include <asm/ftrace.h>
27098-
27099+#include <asm/alternative-asm.h>
27100
27101 .code64
27102 .section .entry.text, "ax"
27103@@ -148,8 +148,9 @@
27104 #ifdef CONFIG_DYNAMIC_FTRACE
27105
27106 ENTRY(function_hook)
27107+ pax_force_retaddr
27108 retq
27109-END(function_hook)
27110+ENDPROC(function_hook)
27111
27112 ENTRY(ftrace_caller)
27113 /* save_mcount_regs fills in first two parameters */
27114@@ -181,8 +182,9 @@ GLOBAL(ftrace_graph_call)
27115 #endif
27116
27117 GLOBAL(ftrace_stub)
27118+ pax_force_retaddr
27119 retq
27120-END(ftrace_caller)
27121+ENDPROC(ftrace_caller)
27122
27123 ENTRY(ftrace_regs_caller)
27124 /* Save the current flags before any operations that can change them */
27125@@ -253,7 +255,7 @@ GLOBAL(ftrace_regs_caller_end)
27126
27127 jmp ftrace_return
27128
27129-END(ftrace_regs_caller)
27130+ENDPROC(ftrace_regs_caller)
27131
27132
27133 #else /* ! CONFIG_DYNAMIC_FTRACE */
27134@@ -272,18 +274,20 @@ fgraph_trace:
27135 #endif
27136
27137 GLOBAL(ftrace_stub)
27138+ pax_force_retaddr
27139 retq
27140
27141 trace:
27142 /* save_mcount_regs fills in first two parameters */
27143 save_mcount_regs
27144
27145+ pax_force_fptr ftrace_trace_function
27146 call *ftrace_trace_function
27147
27148 restore_mcount_regs
27149
27150 jmp fgraph_trace
27151-END(function_hook)
27152+ENDPROC(function_hook)
27153 #endif /* CONFIG_DYNAMIC_FTRACE */
27154 #endif /* CONFIG_FUNCTION_TRACER */
27155
27156@@ -305,8 +309,9 @@ ENTRY(ftrace_graph_caller)
27157
27158 restore_mcount_regs
27159
27160+ pax_force_retaddr
27161 retq
27162-END(ftrace_graph_caller)
27163+ENDPROC(ftrace_graph_caller)
27164
27165 GLOBAL(return_to_handler)
27166 subq $24, %rsp
27167@@ -322,5 +327,7 @@ GLOBAL(return_to_handler)
27168 movq 8(%rsp), %rdx
27169 movq (%rsp), %rax
27170 addq $24, %rsp
27171+ pax_force_fptr %rdi
27172 jmp *%rdi
27173+ENDPROC(return_to_handler)
27174 #endif
27175diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
27176index 005c03e..7000fe4 100644
27177--- a/arch/x86/kernel/module.c
27178+++ b/arch/x86/kernel/module.c
27179@@ -75,17 +75,17 @@ static unsigned long int get_module_load_offset(void)
27180 }
27181 #endif
27182
27183-void *module_alloc(unsigned long size)
27184+static inline void *__module_alloc(unsigned long size, pgprot_t prot)
27185 {
27186 void *p;
27187
27188- if (PAGE_ALIGN(size) > MODULES_LEN)
27189+ if (!size || PAGE_ALIGN(size) > MODULES_LEN)
27190 return NULL;
27191
27192 p = __vmalloc_node_range(size, MODULE_ALIGN,
27193 MODULES_VADDR + get_module_load_offset(),
27194- MODULES_END, GFP_KERNEL | __GFP_HIGHMEM,
27195- PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
27196+ MODULES_END, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
27197+ prot, 0, NUMA_NO_NODE,
27198 __builtin_return_address(0));
27199 if (p && (kasan_module_alloc(p, size) < 0)) {
27200 vfree(p);
27201@@ -95,6 +95,51 @@ void *module_alloc(unsigned long size)
27202 return p;
27203 }
27204
27205+void *module_alloc(unsigned long size)
27206+{
27207+
27208+#ifdef CONFIG_PAX_KERNEXEC
27209+ return __module_alloc(size, PAGE_KERNEL);
27210+#else
27211+ return __module_alloc(size, PAGE_KERNEL_EXEC);
27212+#endif
27213+
27214+}
27215+
27216+#ifdef CONFIG_PAX_KERNEXEC
27217+#ifdef CONFIG_X86_32
27218+void *module_alloc_exec(unsigned long size)
27219+{
27220+ struct vm_struct *area;
27221+
27222+ if (size == 0)
27223+ return NULL;
27224+
27225+ area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
27226+return area ? area->addr : NULL;
27227+}
27228+EXPORT_SYMBOL(module_alloc_exec);
27229+
27230+void module_memfree_exec(void *module_region)
27231+{
27232+ vunmap(module_region);
27233+}
27234+EXPORT_SYMBOL(module_memfree_exec);
27235+#else
27236+void module_memfree_exec(void *module_region)
27237+{
27238+ module_memfree(module_region);
27239+}
27240+EXPORT_SYMBOL(module_memfree_exec);
27241+
27242+void *module_alloc_exec(unsigned long size)
27243+{
27244+ return __module_alloc(size, PAGE_KERNEL_RX);
27245+}
27246+EXPORT_SYMBOL(module_alloc_exec);
27247+#endif
27248+#endif
27249+
27250 #ifdef CONFIG_X86_32
27251 int apply_relocate(Elf32_Shdr *sechdrs,
27252 const char *strtab,
27253@@ -105,14 +150,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
27254 unsigned int i;
27255 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
27256 Elf32_Sym *sym;
27257- uint32_t *location;
27258+ uint32_t *plocation, location;
27259
27260 DEBUGP("Applying relocate section %u to %u\n",
27261 relsec, sechdrs[relsec].sh_info);
27262 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
27263 /* This is where to make the change */
27264- location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
27265- + rel[i].r_offset;
27266+ plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
27267+ location = (uint32_t)plocation;
27268+ if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
27269+ plocation = (uint32_t *)ktla_ktva((unsigned long)plocation);
27270 /* This is the symbol it is referring to. Note that all
27271 undefined symbols have been resolved. */
27272 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
27273@@ -121,11 +168,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
27274 switch (ELF32_R_TYPE(rel[i].r_info)) {
27275 case R_386_32:
27276 /* We add the value into the location given */
27277- *location += sym->st_value;
27278+ pax_open_kernel();
27279+ *plocation += sym->st_value;
27280+ pax_close_kernel();
27281 break;
27282 case R_386_PC32:
27283 /* Add the value, subtract its position */
27284- *location += sym->st_value - (uint32_t)location;
27285+ pax_open_kernel();
27286+ *plocation += sym->st_value - location;
27287+ pax_close_kernel();
27288 break;
27289 default:
27290 pr_err("%s: Unknown relocation: %u\n",
27291@@ -170,21 +221,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
27292 case R_X86_64_NONE:
27293 break;
27294 case R_X86_64_64:
27295+ pax_open_kernel();
27296 *(u64 *)loc = val;
27297+ pax_close_kernel();
27298 break;
27299 case R_X86_64_32:
27300+ pax_open_kernel();
27301 *(u32 *)loc = val;
27302+ pax_close_kernel();
27303 if (val != *(u32 *)loc)
27304 goto overflow;
27305 break;
27306 case R_X86_64_32S:
27307+ pax_open_kernel();
27308 *(s32 *)loc = val;
27309+ pax_close_kernel();
27310 if ((s64)val != *(s32 *)loc)
27311 goto overflow;
27312 break;
27313 case R_X86_64_PC32:
27314 val -= (u64)loc;
27315+ pax_open_kernel();
27316 *(u32 *)loc = val;
27317+ pax_close_kernel();
27318+
27319 #if 0
27320 if ((s64)val != *(s32 *)loc)
27321 goto overflow;
27322diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
27323index 113e707..0a690e1 100644
27324--- a/arch/x86/kernel/msr.c
27325+++ b/arch/x86/kernel/msr.c
27326@@ -39,6 +39,7 @@
27327 #include <linux/notifier.h>
27328 #include <linux/uaccess.h>
27329 #include <linux/gfp.h>
27330+#include <linux/grsecurity.h>
27331
27332 #include <asm/processor.h>
27333 #include <asm/msr.h>
27334@@ -105,6 +106,11 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
27335 int err = 0;
27336 ssize_t bytes = 0;
27337
27338+#ifdef CONFIG_GRKERNSEC_KMEM
27339+ gr_handle_msr_write();
27340+ return -EPERM;
27341+#endif
27342+
27343 if (count % 8)
27344 return -EINVAL; /* Invalid chunk size */
27345
27346@@ -152,6 +158,10 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
27347 err = -EBADF;
27348 break;
27349 }
27350+#ifdef CONFIG_GRKERNSEC_KMEM
27351+ gr_handle_msr_write();
27352+ return -EPERM;
27353+#endif
27354 if (copy_from_user(&regs, uregs, sizeof regs)) {
27355 err = -EFAULT;
27356 break;
27357@@ -235,7 +245,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
27358 return notifier_from_errno(err);
27359 }
27360
27361-static struct notifier_block __refdata msr_class_cpu_notifier = {
27362+static struct notifier_block msr_class_cpu_notifier = {
27363 .notifier_call = msr_class_cpu_callback,
27364 };
27365
27366diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
27367index d05bd2e..f690edd 100644
27368--- a/arch/x86/kernel/nmi.c
27369+++ b/arch/x86/kernel/nmi.c
27370@@ -98,16 +98,16 @@ fs_initcall(nmi_warning_debugfs);
27371
27372 static void nmi_max_handler(struct irq_work *w)
27373 {
27374- struct nmiaction *a = container_of(w, struct nmiaction, irq_work);
27375+ struct nmiwork *n = container_of(w, struct nmiwork, irq_work);
27376 int remainder_ns, decimal_msecs;
27377- u64 whole_msecs = ACCESS_ONCE(a->max_duration);
27378+ u64 whole_msecs = ACCESS_ONCE(n->max_duration);
27379
27380 remainder_ns = do_div(whole_msecs, (1000 * 1000));
27381 decimal_msecs = remainder_ns / 1000;
27382
27383 printk_ratelimited(KERN_INFO
27384 "INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n",
27385- a->handler, whole_msecs, decimal_msecs);
27386+ n->action->handler, whole_msecs, decimal_msecs);
27387 }
27388
27389 static int nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
27390@@ -134,11 +134,11 @@ static int nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
27391 delta = sched_clock() - delta;
27392 trace_nmi_handler(a->handler, (int)delta, thishandled);
27393
27394- if (delta < nmi_longest_ns || delta < a->max_duration)
27395+ if (delta < nmi_longest_ns || delta < a->work->max_duration)
27396 continue;
27397
27398- a->max_duration = delta;
27399- irq_work_queue(&a->irq_work);
27400+ a->work->max_duration = delta;
27401+ irq_work_queue(&a->work->irq_work);
27402 }
27403
27404 rcu_read_unlock();
27405@@ -148,7 +148,7 @@ static int nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
27406 }
27407 NOKPROBE_SYMBOL(nmi_handle);
27408
27409-int __register_nmi_handler(unsigned int type, struct nmiaction *action)
27410+int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
27411 {
27412 struct nmi_desc *desc = nmi_to_desc(type);
27413 unsigned long flags;
27414@@ -156,7 +156,8 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
27415 if (!action->handler)
27416 return -EINVAL;
27417
27418- init_irq_work(&action->irq_work, nmi_max_handler);
27419+ action->work->action = action;
27420+ init_irq_work(&action->work->irq_work, nmi_max_handler);
27421
27422 spin_lock_irqsave(&desc->lock, flags);
27423
27424@@ -174,9 +175,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
27425 * event confuses some handlers (kdump uses this flag)
27426 */
27427 if (action->flags & NMI_FLAG_FIRST)
27428- list_add_rcu(&action->list, &desc->head);
27429+ pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
27430 else
27431- list_add_tail_rcu(&action->list, &desc->head);
27432+ pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
27433
27434 spin_unlock_irqrestore(&desc->lock, flags);
27435 return 0;
27436@@ -199,7 +200,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
27437 if (!strcmp(n->name, name)) {
27438 WARN(in_nmi(),
27439 "Trying to free NMI (%s) from NMI context!\n", n->name);
27440- list_del_rcu(&n->list);
27441+ pax_list_del_rcu((struct list_head *)&n->list);
27442 break;
27443 }
27444 }
27445@@ -481,6 +482,17 @@ static DEFINE_PER_CPU(int, update_debug_stack);
27446 dotraplinkage notrace void
27447 do_nmi(struct pt_regs *regs, long error_code)
27448 {
27449+
27450+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27451+ if (!user_mode(regs)) {
27452+ unsigned long cs = regs->cs & 0xFFFF;
27453+ unsigned long ip = ktva_ktla(regs->ip);
27454+
27455+ if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
27456+ regs->ip = ip;
27457+ }
27458+#endif
27459+
27460 if (this_cpu_read(nmi_state) != NMI_NOT_RUNNING) {
27461 this_cpu_write(nmi_state, NMI_LATCHED);
27462 return;
27463diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
27464index 6d9582e..f746287 100644
27465--- a/arch/x86/kernel/nmi_selftest.c
27466+++ b/arch/x86/kernel/nmi_selftest.c
27467@@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
27468 {
27469 /* trap all the unknown NMIs we may generate */
27470 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
27471- __initdata);
27472+ __initconst);
27473 }
27474
27475 static void __init cleanup_nmi_testsuite(void)
27476@@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
27477 unsigned long timeout;
27478
27479 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
27480- NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
27481+ NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
27482 nmi_fail = FAILURE;
27483 return;
27484 }
27485diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
27486index 33ee3e0..da3519a 100644
27487--- a/arch/x86/kernel/paravirt-spinlocks.c
27488+++ b/arch/x86/kernel/paravirt-spinlocks.c
27489@@ -23,7 +23,7 @@ bool pv_is_native_spin_unlock(void)
27490 }
27491 #endif
27492
27493-struct pv_lock_ops pv_lock_ops = {
27494+struct pv_lock_ops pv_lock_ops __read_only = {
27495 #ifdef CONFIG_SMP
27496 #ifdef CONFIG_QUEUED_SPINLOCKS
27497 .queued_spin_lock_slowpath = native_queued_spin_lock_slowpath,
27498diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
27499index ebb5657..dde2f45 100644
27500--- a/arch/x86/kernel/paravirt.c
27501+++ b/arch/x86/kernel/paravirt.c
27502@@ -64,6 +64,9 @@ u64 _paravirt_ident_64(u64 x)
27503 {
27504 return x;
27505 }
27506+#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
27507+PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
27508+#endif
27509
27510 void __init default_banner(void)
27511 {
27512@@ -150,16 +153,20 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
27513
27514 if (opfunc == NULL)
27515 /* If there's no function, patch it with a ud2a (BUG) */
27516- ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
27517- else if (opfunc == _paravirt_nop)
27518+ ret = paravirt_patch_insns(insnbuf, len, (const char *)ktva_ktla((unsigned long)ud2a), ud2a+sizeof(ud2a));
27519+ else if (opfunc == (void *)_paravirt_nop)
27520 /* If the operation is a nop, then nop the callsite */
27521 ret = paravirt_patch_nop();
27522
27523 /* identity functions just return their single argument */
27524- else if (opfunc == _paravirt_ident_32)
27525+ else if (opfunc == (void *)_paravirt_ident_32)
27526 ret = paravirt_patch_ident_32(insnbuf, len);
27527- else if (opfunc == _paravirt_ident_64)
27528+ else if (opfunc == (void *)_paravirt_ident_64)
27529 ret = paravirt_patch_ident_64(insnbuf, len);
27530+#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
27531+ else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
27532+ ret = paravirt_patch_ident_64(insnbuf, len);
27533+#endif
27534
27535 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
27536 #ifdef CONFIG_X86_32
27537@@ -186,7 +193,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
27538 if (insn_len > len || start == NULL)
27539 insn_len = len;
27540 else
27541- memcpy(insnbuf, start, insn_len);
27542+ memcpy(insnbuf, (const char *)ktla_ktva((unsigned long)start), insn_len);
27543
27544 return insn_len;
27545 }
27546@@ -310,7 +317,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
27547 return this_cpu_read(paravirt_lazy_mode);
27548 }
27549
27550-struct pv_info pv_info = {
27551+struct pv_info pv_info __read_only = {
27552 .name = "bare hardware",
27553 .paravirt_enabled = 0,
27554 .kernel_rpl = 0,
27555@@ -321,16 +328,16 @@ struct pv_info pv_info = {
27556 #endif
27557 };
27558
27559-struct pv_init_ops pv_init_ops = {
27560+struct pv_init_ops pv_init_ops __read_only = {
27561 .patch = native_patch,
27562 };
27563
27564-struct pv_time_ops pv_time_ops = {
27565+struct pv_time_ops pv_time_ops __read_only = {
27566 .sched_clock = native_sched_clock,
27567 .steal_clock = native_steal_clock,
27568 };
27569
27570-__visible struct pv_irq_ops pv_irq_ops = {
27571+__visible struct pv_irq_ops pv_irq_ops __read_only = {
27572 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
27573 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
27574 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
27575@@ -342,7 +349,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
27576 #endif
27577 };
27578
27579-__visible struct pv_cpu_ops pv_cpu_ops = {
27580+__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
27581 .cpuid = native_cpuid,
27582 .get_debugreg = native_get_debugreg,
27583 .set_debugreg = native_set_debugreg,
27584@@ -405,21 +412,26 @@ NOKPROBE_SYMBOL(native_get_debugreg);
27585 NOKPROBE_SYMBOL(native_set_debugreg);
27586 NOKPROBE_SYMBOL(native_load_idt);
27587
27588-struct pv_apic_ops pv_apic_ops = {
27589+struct pv_apic_ops pv_apic_ops __read_only= {
27590 #ifdef CONFIG_X86_LOCAL_APIC
27591 .startup_ipi_hook = paravirt_nop,
27592 #endif
27593 };
27594
27595-#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
27596+#ifdef CONFIG_X86_32
27597+#ifdef CONFIG_X86_PAE
27598+/* 64-bit pagetable entries */
27599+#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
27600+#else
27601 /* 32-bit pagetable entries */
27602 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
27603+#endif
27604 #else
27605 /* 64-bit pagetable entries */
27606 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
27607 #endif
27608
27609-struct pv_mmu_ops pv_mmu_ops = {
27610+struct pv_mmu_ops pv_mmu_ops __read_only = {
27611
27612 .read_cr2 = native_read_cr2,
27613 .write_cr2 = native_write_cr2,
27614@@ -469,6 +481,7 @@ struct pv_mmu_ops pv_mmu_ops = {
27615 .make_pud = PTE_IDENT,
27616
27617 .set_pgd = native_set_pgd,
27618+ .set_pgd_batched = native_set_pgd_batched,
27619 #endif
27620 #endif /* CONFIG_PGTABLE_LEVELS >= 3 */
27621
27622@@ -489,6 +502,12 @@ struct pv_mmu_ops pv_mmu_ops = {
27623 },
27624
27625 .set_fixmap = native_set_fixmap,
27626+
27627+#ifdef CONFIG_PAX_KERNEXEC
27628+ .pax_open_kernel = native_pax_open_kernel,
27629+ .pax_close_kernel = native_pax_close_kernel,
27630+#endif
27631+
27632 };
27633
27634 EXPORT_SYMBOL_GPL(pv_time_ops);
27635diff --git a/arch/x86/kernel/paravirt_patch_64.c b/arch/x86/kernel/paravirt_patch_64.c
27636index 8aa0558..465512e 100644
27637--- a/arch/x86/kernel/paravirt_patch_64.c
27638+++ b/arch/x86/kernel/paravirt_patch_64.c
27639@@ -9,7 +9,11 @@ DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax");
27640 DEF_NATIVE(pv_mmu_ops, read_cr2, "movq %cr2, %rax");
27641 DEF_NATIVE(pv_mmu_ops, read_cr3, "movq %cr3, %rax");
27642 DEF_NATIVE(pv_mmu_ops, write_cr3, "movq %rdi, %cr3");
27643+
27644+#ifndef CONFIG_PAX_MEMORY_UDEREF
27645 DEF_NATIVE(pv_mmu_ops, flush_tlb_single, "invlpg (%rdi)");
27646+#endif
27647+
27648 DEF_NATIVE(pv_cpu_ops, clts, "clts");
27649 DEF_NATIVE(pv_cpu_ops, wbinvd, "wbinvd");
27650
27651@@ -62,7 +66,11 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
27652 PATCH_SITE(pv_mmu_ops, read_cr3);
27653 PATCH_SITE(pv_mmu_ops, write_cr3);
27654 PATCH_SITE(pv_cpu_ops, clts);
27655+
27656+#ifndef CONFIG_PAX_MEMORY_UDEREF
27657 PATCH_SITE(pv_mmu_ops, flush_tlb_single);
27658+#endif
27659+
27660 PATCH_SITE(pv_cpu_ops, wbinvd);
27661 #if defined(CONFIG_PARAVIRT_SPINLOCKS) && defined(CONFIG_QUEUED_SPINLOCKS)
27662 case PARAVIRT_PATCH(pv_lock_ops.queued_spin_unlock):
27663diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
27664index 0497f71..7186c0d 100644
27665--- a/arch/x86/kernel/pci-calgary_64.c
27666+++ b/arch/x86/kernel/pci-calgary_64.c
27667@@ -1347,7 +1347,7 @@ static void __init get_tce_space_from_tar(void)
27668 tce_space = be64_to_cpu(readq(target));
27669 tce_space = tce_space & TAR_SW_BITS;
27670
27671- tce_space = tce_space & (~specified_table_size);
27672+ tce_space = tce_space & (~(unsigned long)specified_table_size);
27673 info->tce_space = (u64 *)__va(tce_space);
27674 }
27675 }
27676diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
27677index 35ccf75..7a15747 100644
27678--- a/arch/x86/kernel/pci-iommu_table.c
27679+++ b/arch/x86/kernel/pci-iommu_table.c
27680@@ -2,7 +2,7 @@
27681 #include <asm/iommu_table.h>
27682 #include <linux/string.h>
27683 #include <linux/kallsyms.h>
27684-
27685+#include <linux/sched.h>
27686
27687 #define DEBUG 1
27688
27689diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
27690index adf0392..88a7576 100644
27691--- a/arch/x86/kernel/pci-swiotlb.c
27692+++ b/arch/x86/kernel/pci-swiotlb.c
27693@@ -40,7 +40,7 @@ void x86_swiotlb_free_coherent(struct device *dev, size_t size,
27694 struct dma_attrs *attrs)
27695 {
27696 if (is_swiotlb_buffer(dma_to_phys(dev, dma_addr)))
27697- swiotlb_free_coherent(dev, size, vaddr, dma_addr);
27698+ swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
27699 else
27700 dma_generic_free_coherent(dev, size, vaddr, dma_addr, attrs);
27701 }
27702diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
27703index c27cad7..47e3f47 100644
27704--- a/arch/x86/kernel/process.c
27705+++ b/arch/x86/kernel/process.c
27706@@ -15,6 +15,7 @@
27707 #include <linux/dmi.h>
27708 #include <linux/utsname.h>
27709 #include <linux/stackprotector.h>
27710+#include <linux/kthread.h>
27711 #include <linux/tick.h>
27712 #include <linux/cpuidle.h>
27713 #include <trace/events/power.h>
27714@@ -37,7 +38,8 @@
27715 * section. Since TSS's are completely CPU-local, we want them
27716 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
27717 */
27718-__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss) = {
27719+struct tss_struct cpu_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = {
27720+ [0 ... NR_CPUS-1] = {
27721 .x86_tss = {
27722 .sp0 = TOP_OF_INIT_STACK,
27723 #ifdef CONFIG_X86_32
27724@@ -55,6 +57,7 @@ __visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss) = {
27725 */
27726 .io_bitmap = { [0 ... IO_BITMAP_LONGS] = ~0 },
27727 #endif
27728+}
27729 };
27730 EXPORT_PER_CPU_SYMBOL(cpu_tss);
27731
27732@@ -75,17 +78,35 @@ void idle_notifier_unregister(struct notifier_block *n)
27733 EXPORT_SYMBOL_GPL(idle_notifier_unregister);
27734 #endif
27735
27736+struct kmem_cache *fpregs_state_cachep;
27737+EXPORT_SYMBOL(fpregs_state_cachep);
27738+
27739+void __init arch_task_cache_init(void)
27740+{
27741+ /* create a slab on which task_structs can be allocated */
27742+ fpregs_state_cachep =
27743+ kmem_cache_create("fpregs_state", xstate_size,
27744+ ARCH_MIN_TASKALIGN, SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
27745+}
27746+
27747 /*
27748 * this gets called so that we can store lazy state into memory and copy the
27749 * current task into the new thread.
27750 */
27751 int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
27752 {
27753- memcpy(dst, src, arch_task_struct_size);
27754+ *dst = *src;
27755
27756+ dst->thread.fpu.state = kmem_cache_alloc_node(fpregs_state_cachep, GFP_KERNEL, tsk_fork_get_node(src));
27757 return fpu__copy(&dst->thread.fpu, &src->thread.fpu);
27758 }
27759
27760+void arch_release_task_struct(struct task_struct *tsk)
27761+{
27762+ kmem_cache_free(fpregs_state_cachep, tsk->thread.fpu.state);
27763+ tsk->thread.fpu.state = NULL;
27764+}
27765+
27766 /*
27767 * Free current thread data structures etc..
27768 */
27769@@ -97,7 +118,7 @@ void exit_thread(void)
27770 struct fpu *fpu = &t->fpu;
27771
27772 if (bp) {
27773- struct tss_struct *tss = &per_cpu(cpu_tss, get_cpu());
27774+ struct tss_struct *tss = cpu_tss + get_cpu();
27775
27776 t->io_bitmap_ptr = NULL;
27777 clear_thread_flag(TIF_IO_BITMAP);
27778@@ -117,6 +138,9 @@ void flush_thread(void)
27779 {
27780 struct task_struct *tsk = current;
27781
27782+#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
27783+ loadsegment(gs, 0);
27784+#endif
27785 flush_ptrace_hw_breakpoint(tsk);
27786 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
27787
27788@@ -258,7 +282,7 @@ static void __exit_idle(void)
27789 void exit_idle(void)
27790 {
27791 /* idle loop has pid 0 */
27792- if (current->pid)
27793+ if (task_pid_nr(current))
27794 return;
27795 __exit_idle();
27796 }
27797@@ -311,7 +335,7 @@ bool xen_set_default_idle(void)
27798 return ret;
27799 }
27800 #endif
27801-void stop_this_cpu(void *dummy)
27802+__noreturn void stop_this_cpu(void *dummy)
27803 {
27804 local_irq_disable();
27805 /*
27806@@ -488,16 +512,40 @@ static int __init idle_setup(char *str)
27807 }
27808 early_param("idle", idle_setup);
27809
27810-unsigned long arch_align_stack(unsigned long sp)
27811-{
27812- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
27813- sp -= get_random_int() % 8192;
27814- return sp & ~0xf;
27815-}
27816-
27817 unsigned long arch_randomize_brk(struct mm_struct *mm)
27818 {
27819 unsigned long range_end = mm->brk + 0x02000000;
27820 return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
27821 }
27822
27823+#ifdef CONFIG_PAX_RANDKSTACK
27824+void pax_randomize_kstack(struct pt_regs *regs)
27825+{
27826+ struct thread_struct *thread = &current->thread;
27827+ unsigned long time;
27828+
27829+ if (!randomize_va_space)
27830+ return;
27831+
27832+ if (v8086_mode(regs))
27833+ return;
27834+
27835+ rdtscl(time);
27836+
27837+ /* P4 seems to return a 0 LSB, ignore it */
27838+#ifdef CONFIG_MPENTIUM4
27839+ time &= 0x3EUL;
27840+ time <<= 2;
27841+#elif defined(CONFIG_X86_64)
27842+ time &= 0xFUL;
27843+ time <<= 4;
27844+#else
27845+ time &= 0x1FUL;
27846+ time <<= 3;
27847+#endif
27848+
27849+ thread->sp0 ^= time;
27850+ load_sp0(cpu_tss + smp_processor_id(), thread);
27851+ this_cpu_write(cpu_current_top_of_stack, thread->sp0);
27852+}
27853+#endif
27854diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
27855index f73c962..6589332 100644
27856--- a/arch/x86/kernel/process_32.c
27857+++ b/arch/x86/kernel/process_32.c
27858@@ -63,6 +63,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
27859 unsigned long thread_saved_pc(struct task_struct *tsk)
27860 {
27861 return ((unsigned long *)tsk->thread.sp)[3];
27862+//XXX return tsk->thread.eip;
27863 }
27864
27865 void __show_regs(struct pt_regs *regs, int all)
27866@@ -75,16 +76,15 @@ void __show_regs(struct pt_regs *regs, int all)
27867 if (user_mode(regs)) {
27868 sp = regs->sp;
27869 ss = regs->ss & 0xffff;
27870- gs = get_user_gs(regs);
27871 } else {
27872 sp = kernel_stack_pointer(regs);
27873 savesegment(ss, ss);
27874- savesegment(gs, gs);
27875 }
27876+ gs = get_user_gs(regs);
27877
27878 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
27879 (u16)regs->cs, regs->ip, regs->flags,
27880- smp_processor_id());
27881+ raw_smp_processor_id());
27882 print_symbol("EIP is at %s\n", regs->ip);
27883
27884 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
27885@@ -131,21 +131,22 @@ void release_thread(struct task_struct *dead_task)
27886 int copy_thread_tls(unsigned long clone_flags, unsigned long sp,
27887 unsigned long arg, struct task_struct *p, unsigned long tls)
27888 {
27889- struct pt_regs *childregs = task_pt_regs(p);
27890+ struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
27891 struct task_struct *tsk;
27892 int err;
27893
27894 p->thread.sp = (unsigned long) childregs;
27895 p->thread.sp0 = (unsigned long) (childregs+1);
27896+ p->tinfo.lowest_stack = (unsigned long)task_stack_page(p) + 2 * sizeof(unsigned long);
27897 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
27898
27899 if (unlikely(p->flags & PF_KTHREAD)) {
27900 /* kernel thread */
27901 memset(childregs, 0, sizeof(struct pt_regs));
27902 p->thread.ip = (unsigned long) ret_from_kernel_thread;
27903- task_user_gs(p) = __KERNEL_STACK_CANARY;
27904- childregs->ds = __USER_DS;
27905- childregs->es = __USER_DS;
27906+ savesegment(gs, childregs->gs);
27907+ childregs->ds = __KERNEL_DS;
27908+ childregs->es = __KERNEL_DS;
27909 childregs->fs = __KERNEL_PERCPU;
27910 childregs->bx = sp; /* function */
27911 childregs->bp = arg;
27912@@ -245,7 +246,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27913 struct fpu *prev_fpu = &prev->fpu;
27914 struct fpu *next_fpu = &next->fpu;
27915 int cpu = smp_processor_id();
27916- struct tss_struct *tss = &per_cpu(cpu_tss, cpu);
27917+ struct tss_struct *tss = cpu_tss + cpu;
27918 fpu_switch_t fpu_switch;
27919
27920 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
27921@@ -264,6 +265,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27922 */
27923 lazy_save_gs(prev->gs);
27924
27925+#ifdef CONFIG_PAX_MEMORY_UDEREF
27926+ __set_fs(task_thread_info(next_p)->addr_limit);
27927+#endif
27928+
27929 /*
27930 * Load the per-thread Thread-Local Storage descriptor.
27931 */
27932@@ -307,9 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27933 * current_thread_info().
27934 */
27935 load_sp0(tss, next);
27936- this_cpu_write(cpu_current_top_of_stack,
27937- (unsigned long)task_stack_page(next_p) +
27938- THREAD_SIZE);
27939+ this_cpu_write(current_task, next_p);
27940+ this_cpu_write(current_tinfo, &next_p->tinfo);
27941+ this_cpu_write(cpu_current_top_of_stack, next->sp0);
27942
27943 /*
27944 * Restore %gs if needed (which is common)
27945@@ -319,8 +324,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27946
27947 switch_fpu_finish(next_fpu, fpu_switch);
27948
27949- this_cpu_write(current_task, next_p);
27950-
27951 return prev_p;
27952 }
27953
27954@@ -350,4 +353,3 @@ unsigned long get_wchan(struct task_struct *p)
27955 } while (count++ < 16);
27956 return 0;
27957 }
27958-
27959diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
27960index a90ac95..ebac33e 100644
27961--- a/arch/x86/kernel/process_64.c
27962+++ b/arch/x86/kernel/process_64.c
27963@@ -157,9 +157,10 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long sp,
27964 struct pt_regs *childregs;
27965 struct task_struct *me = current;
27966
27967- p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
27968+ p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
27969 childregs = task_pt_regs(p);
27970 p->thread.sp = (unsigned long) childregs;
27971+ p->tinfo.lowest_stack = (unsigned long)task_stack_page(p) + 2 * sizeof(unsigned long);
27972 set_tsk_thread_flag(p, TIF_FORK);
27973 p->thread.io_bitmap_ptr = NULL;
27974
27975@@ -169,6 +170,8 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long sp,
27976 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
27977 savesegment(es, p->thread.es);
27978 savesegment(ds, p->thread.ds);
27979+ savesegment(ss, p->thread.ss);
27980+ BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
27981 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
27982
27983 if (unlikely(p->flags & PF_KTHREAD)) {
27984@@ -276,7 +279,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27985 struct fpu *prev_fpu = &prev->fpu;
27986 struct fpu *next_fpu = &next->fpu;
27987 int cpu = smp_processor_id();
27988- struct tss_struct *tss = &per_cpu(cpu_tss, cpu);
27989+ struct tss_struct *tss = cpu_tss + cpu;
27990 unsigned fsindex, gsindex;
27991 fpu_switch_t fpu_switch;
27992
27993@@ -327,6 +330,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27994 if (unlikely(next->ds | prev->ds))
27995 loadsegment(ds, next->ds);
27996
27997+ savesegment(ss, prev->ss);
27998+ if (unlikely(next->ss != prev->ss))
27999+ loadsegment(ss, next->ss);
28000+
28001 /*
28002 * Switch FS and GS.
28003 *
28004@@ -398,6 +405,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28005 * Switch the PDA and FPU contexts.
28006 */
28007 this_cpu_write(current_task, next_p);
28008+ this_cpu_write(current_tinfo, &next_p->tinfo);
28009
28010 /*
28011 * If it were not for PREEMPT_ACTIVE we could guarantee that the
28012@@ -410,6 +418,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28013 /* Reload esp0 and ss1. This changes current_thread_info(). */
28014 load_sp0(tss, next);
28015
28016+ this_cpu_write(cpu_current_top_of_stack, next->sp0);
28017+
28018 /*
28019 * Now maybe reload the debug registers and handle I/O bitmaps
28020 */
28021@@ -510,7 +520,6 @@ unsigned long get_wchan(struct task_struct *p)
28022
28023 if (!p || p == current || p->state == TASK_RUNNING)
28024 return 0;
28025-
28026 start = (unsigned long)task_stack_page(p);
28027 if (!start)
28028 return 0;
28029@@ -535,7 +544,10 @@ unsigned long get_wchan(struct task_struct *p)
28030 */
28031 top = start + THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING;
28032 top -= 2 * sizeof(unsigned long);
28033- bottom = start + sizeof(struct thread_info);
28034+ /* not adding sizeof(thread_info) since it's not located on the stack
28035+ with PaX patched in
28036+ */
28037+ bottom = start;
28038
28039 sp = READ_ONCE(p->thread.sp);
28040 if (sp < bottom || sp > top)
28041diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
28042index 9be72bc..f4329c5 100644
28043--- a/arch/x86/kernel/ptrace.c
28044+++ b/arch/x86/kernel/ptrace.c
28045@@ -186,10 +186,10 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
28046 unsigned long sp = (unsigned long)&regs->sp;
28047 u32 *prev_esp;
28048
28049- if (context == (sp & ~(THREAD_SIZE - 1)))
28050+ if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
28051 return sp;
28052
28053- prev_esp = (u32 *)(context);
28054+ prev_esp = *(u32 **)(context);
28055 if (prev_esp)
28056 return (unsigned long)prev_esp;
28057
28058@@ -446,6 +446,20 @@ static int putreg(struct task_struct *child,
28059 if (child->thread.gs != value)
28060 return do_arch_prctl(child, ARCH_SET_GS, value);
28061 return 0;
28062+
28063+ case offsetof(struct user_regs_struct,ip):
28064+ /*
28065+ * Protect against any attempt to set ip to an
28066+ * impossible address. There are dragons lurking if the
28067+ * address is noncanonical. (This explicitly allows
28068+ * setting ip to TASK_SIZE_MAX, because user code can do
28069+ * that all by itself by running off the end of its
28070+ * address space.
28071+ */
28072+ if (value > TASK_SIZE_MAX)
28073+ return -EIO;
28074+ break;
28075+
28076 #endif
28077 }
28078
28079@@ -582,7 +596,7 @@ static void ptrace_triggered(struct perf_event *bp,
28080 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
28081 {
28082 int i;
28083- int dr7 = 0;
28084+ unsigned long dr7 = 0;
28085 struct arch_hw_breakpoint *info;
28086
28087 for (i = 0; i < HBP_NUM; i++) {
28088@@ -816,7 +830,7 @@ long arch_ptrace(struct task_struct *child, long request,
28089 unsigned long addr, unsigned long data)
28090 {
28091 int ret;
28092- unsigned long __user *datap = (unsigned long __user *)data;
28093+ unsigned long __user *datap = (__force unsigned long __user *)data;
28094
28095 switch (request) {
28096 /* read the word at location addr in the USER area. */
28097@@ -901,14 +915,14 @@ long arch_ptrace(struct task_struct *child, long request,
28098 if ((int) addr < 0)
28099 return -EIO;
28100 ret = do_get_thread_area(child, addr,
28101- (struct user_desc __user *)data);
28102+ (__force struct user_desc __user *) data);
28103 break;
28104
28105 case PTRACE_SET_THREAD_AREA:
28106 if ((int) addr < 0)
28107 return -EIO;
28108 ret = do_set_thread_area(child, addr,
28109- (struct user_desc __user *)data, 0);
28110+ (__force struct user_desc __user *) data, 0);
28111 break;
28112 #endif
28113
28114@@ -1286,7 +1300,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
28115
28116 #ifdef CONFIG_X86_64
28117
28118-static struct user_regset x86_64_regsets[] __read_mostly = {
28119+static user_regset_no_const x86_64_regsets[] __read_only = {
28120 [REGSET_GENERAL] = {
28121 .core_note_type = NT_PRSTATUS,
28122 .n = sizeof(struct user_regs_struct) / sizeof(long),
28123@@ -1327,7 +1341,7 @@ static const struct user_regset_view user_x86_64_view = {
28124 #endif /* CONFIG_X86_64 */
28125
28126 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
28127-static struct user_regset x86_32_regsets[] __read_mostly = {
28128+static user_regset_no_const x86_32_regsets[] __read_only = {
28129 [REGSET_GENERAL] = {
28130 .core_note_type = NT_PRSTATUS,
28131 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
28132@@ -1380,7 +1394,7 @@ static const struct user_regset_view user_x86_32_view = {
28133 */
28134 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
28135
28136-void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
28137+void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
28138 {
28139 #ifdef CONFIG_X86_64
28140 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
28141@@ -1415,7 +1429,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
28142 memset(info, 0, sizeof(*info));
28143 info->si_signo = SIGTRAP;
28144 info->si_code = si_code;
28145- info->si_addr = user_mode(regs) ? (void __user *)regs->ip : NULL;
28146+ info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
28147 }
28148
28149 void user_single_step_siginfo(struct task_struct *tsk,
28150@@ -1449,6 +1463,10 @@ static void do_audit_syscall_entry(struct pt_regs *regs, u32 arch)
28151 }
28152 }
28153
28154+#ifdef CONFIG_GRKERNSEC_SETXID
28155+extern void gr_delayed_cred_worker(void);
28156+#endif
28157+
28158 /*
28159 * We can return 0 to resume the syscall or anything else to go to phase
28160 * 2. If we resume the syscall, we need to put something appropriate in
28161@@ -1556,6 +1574,11 @@ long syscall_trace_enter_phase2(struct pt_regs *regs, u32 arch,
28162
28163 BUG_ON(regs != task_pt_regs(current));
28164
28165+#ifdef CONFIG_GRKERNSEC_SETXID
28166+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
28167+ gr_delayed_cred_worker();
28168+#endif
28169+
28170 /*
28171 * If we stepped into a sysenter/syscall insn, it trapped in
28172 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
28173@@ -1614,6 +1637,11 @@ void syscall_trace_leave(struct pt_regs *regs)
28174 */
28175 user_exit();
28176
28177+#ifdef CONFIG_GRKERNSEC_SETXID
28178+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
28179+ gr_delayed_cred_worker();
28180+#endif
28181+
28182 audit_syscall_exit(regs);
28183
28184 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
28185diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
28186index 2f355d2..e75ed0a 100644
28187--- a/arch/x86/kernel/pvclock.c
28188+++ b/arch/x86/kernel/pvclock.c
28189@@ -51,11 +51,11 @@ void pvclock_touch_watchdogs(void)
28190 reset_hung_task_detector();
28191 }
28192
28193-static atomic64_t last_value = ATOMIC64_INIT(0);
28194+static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
28195
28196 void pvclock_resume(void)
28197 {
28198- atomic64_set(&last_value, 0);
28199+ atomic64_set_unchecked(&last_value, 0);
28200 }
28201
28202 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
28203@@ -105,11 +105,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
28204 * updating at the same time, and one of them could be slightly behind,
28205 * making the assumption that last_value always go forward fail to hold.
28206 */
28207- last = atomic64_read(&last_value);
28208+ last = atomic64_read_unchecked(&last_value);
28209 do {
28210 if (ret < last)
28211 return last;
28212- last = atomic64_cmpxchg(&last_value, last, ret);
28213+ last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
28214 } while (unlikely(last != ret));
28215
28216 return ret;
28217diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
28218index 86db4bc..a50a54a 100644
28219--- a/arch/x86/kernel/reboot.c
28220+++ b/arch/x86/kernel/reboot.c
28221@@ -70,6 +70,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
28222
28223 void __noreturn machine_real_restart(unsigned int type)
28224 {
28225+
28226+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
28227+ struct desc_struct *gdt;
28228+#endif
28229+
28230 local_irq_disable();
28231
28232 /*
28233@@ -97,7 +102,29 @@ void __noreturn machine_real_restart(unsigned int type)
28234
28235 /* Jump to the identity-mapped low memory code */
28236 #ifdef CONFIG_X86_32
28237- asm volatile("jmpl *%0" : :
28238+
28239+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
28240+ gdt = get_cpu_gdt_table(smp_processor_id());
28241+ pax_open_kernel();
28242+#ifdef CONFIG_PAX_MEMORY_UDEREF
28243+ gdt[GDT_ENTRY_KERNEL_DS].type = 3;
28244+ gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
28245+ loadsegment(ds, __KERNEL_DS);
28246+ loadsegment(es, __KERNEL_DS);
28247+ loadsegment(ss, __KERNEL_DS);
28248+#endif
28249+#ifdef CONFIG_PAX_KERNEXEC
28250+ gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
28251+ gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
28252+ gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
28253+ gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
28254+ gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
28255+ gdt[GDT_ENTRY_KERNEL_CS].g = 1;
28256+#endif
28257+ pax_close_kernel();
28258+#endif
28259+
28260+ asm volatile("ljmpl *%0" : :
28261 "rm" (real_mode_header->machine_real_restart_asm),
28262 "a" (type));
28263 #else
28264@@ -137,7 +164,7 @@ static int __init set_kbd_reboot(const struct dmi_system_id *d)
28265 /*
28266 * This is a single dmi_table handling all reboot quirks.
28267 */
28268-static struct dmi_system_id __initdata reboot_dmi_table[] = {
28269+static const struct dmi_system_id __initconst reboot_dmi_table[] = {
28270
28271 /* Acer */
28272 { /* Handle reboot issue on Acer Aspire one */
28273@@ -511,7 +538,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
28274 * This means that this function can never return, it can misbehave
28275 * by not rebooting properly and hanging.
28276 */
28277-static void native_machine_emergency_restart(void)
28278+static void __noreturn native_machine_emergency_restart(void)
28279 {
28280 int i;
28281 int attempt = 0;
28282@@ -631,13 +658,13 @@ void native_machine_shutdown(void)
28283 #endif
28284 }
28285
28286-static void __machine_emergency_restart(int emergency)
28287+static void __noreturn __machine_emergency_restart(int emergency)
28288 {
28289 reboot_emergency = emergency;
28290 machine_ops.emergency_restart();
28291 }
28292
28293-static void native_machine_restart(char *__unused)
28294+static void __noreturn native_machine_restart(char *__unused)
28295 {
28296 pr_notice("machine restart\n");
28297
28298@@ -646,7 +673,7 @@ static void native_machine_restart(char *__unused)
28299 __machine_emergency_restart(0);
28300 }
28301
28302-static void native_machine_halt(void)
28303+static void __noreturn native_machine_halt(void)
28304 {
28305 /* Stop other cpus and apics */
28306 machine_shutdown();
28307@@ -656,7 +683,7 @@ static void native_machine_halt(void)
28308 stop_this_cpu(NULL);
28309 }
28310
28311-static void native_machine_power_off(void)
28312+static void __noreturn native_machine_power_off(void)
28313 {
28314 if (pm_power_off) {
28315 if (!reboot_force)
28316@@ -665,9 +692,10 @@ static void native_machine_power_off(void)
28317 }
28318 /* A fallback in case there is no PM info available */
28319 tboot_shutdown(TB_SHUTDOWN_HALT);
28320+ unreachable();
28321 }
28322
28323-struct machine_ops machine_ops = {
28324+struct machine_ops machine_ops __read_only = {
28325 .power_off = native_machine_power_off,
28326 .shutdown = native_machine_shutdown,
28327 .emergency_restart = native_machine_emergency_restart,
28328diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
28329index c8e41e9..64049ef 100644
28330--- a/arch/x86/kernel/reboot_fixups_32.c
28331+++ b/arch/x86/kernel/reboot_fixups_32.c
28332@@ -57,7 +57,7 @@ struct device_fixup {
28333 unsigned int vendor;
28334 unsigned int device;
28335 void (*reboot_fixup)(struct pci_dev *);
28336-};
28337+} __do_const;
28338
28339 /*
28340 * PCI ids solely used for fixups_table go here
28341diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
28342index 98111b3..73ca125 100644
28343--- a/arch/x86/kernel/relocate_kernel_64.S
28344+++ b/arch/x86/kernel/relocate_kernel_64.S
28345@@ -96,8 +96,7 @@ relocate_kernel:
28346
28347 /* jump to identity mapped page */
28348 addq $(identity_mapped - relocate_kernel), %r8
28349- pushq %r8
28350- ret
28351+ jmp *%r8
28352
28353 identity_mapped:
28354 /* set return address to 0 if not preserving context */
28355diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
28356index 80f874b..b3eff67 100644
28357--- a/arch/x86/kernel/setup.c
28358+++ b/arch/x86/kernel/setup.c
28359@@ -111,6 +111,7 @@
28360 #include <asm/mce.h>
28361 #include <asm/alternative.h>
28362 #include <asm/prom.h>
28363+#include <asm/boot.h>
28364
28365 /*
28366 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
28367@@ -206,10 +207,12 @@ EXPORT_SYMBOL(boot_cpu_data);
28368 #endif
28369
28370
28371-#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
28372-__visible unsigned long mmu_cr4_features;
28373+#ifdef CONFIG_X86_64
28374+__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
28375+#elif defined(CONFIG_X86_PAE)
28376+__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
28377 #else
28378-__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
28379+__visible unsigned long mmu_cr4_features __read_only;
28380 #endif
28381
28382 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
28383@@ -772,7 +775,7 @@ static void __init trim_bios_range(void)
28384 * area (640->1Mb) as ram even though it is not.
28385 * take them out.
28386 */
28387- e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
28388+ e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
28389
28390 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
28391 }
28392@@ -780,7 +783,7 @@ static void __init trim_bios_range(void)
28393 /* called before trim_bios_range() to spare extra sanitize */
28394 static void __init e820_add_kernel_range(void)
28395 {
28396- u64 start = __pa_symbol(_text);
28397+ u64 start = __pa_symbol(ktla_ktva((unsigned long)_text));
28398 u64 size = __pa_symbol(_end) - start;
28399
28400 /*
28401@@ -861,8 +864,8 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
28402
28403 void __init setup_arch(char **cmdline_p)
28404 {
28405- memblock_reserve(__pa_symbol(_text),
28406- (unsigned long)__bss_stop - (unsigned long)_text);
28407+ memblock_reserve(__pa_symbol(ktla_ktva((unsigned long)_text)),
28408+ (unsigned long)__bss_stop - ktla_ktva((unsigned long)_text));
28409
28410 early_reserve_initrd();
28411
28412@@ -960,16 +963,16 @@ void __init setup_arch(char **cmdline_p)
28413
28414 if (!boot_params.hdr.root_flags)
28415 root_mountflags &= ~MS_RDONLY;
28416- init_mm.start_code = (unsigned long) _text;
28417- init_mm.end_code = (unsigned long) _etext;
28418- init_mm.end_data = (unsigned long) _edata;
28419+ init_mm.start_code = ktla_ktva((unsigned long)_text);
28420+ init_mm.end_code = ktla_ktva((unsigned long)_etext);
28421+ init_mm.end_data = (unsigned long)_edata;
28422 init_mm.brk = _brk_end;
28423
28424 mpx_mm_init(&init_mm);
28425
28426- code_resource.start = __pa_symbol(_text);
28427- code_resource.end = __pa_symbol(_etext)-1;
28428- data_resource.start = __pa_symbol(_etext);
28429+ code_resource.start = __pa_symbol(ktla_ktva((unsigned long)_text));
28430+ code_resource.end = __pa_symbol(ktla_ktva((unsigned long)_etext))-1;
28431+ data_resource.start = __pa_symbol(_sdata);
28432 data_resource.end = __pa_symbol(_edata)-1;
28433 bss_resource.start = __pa_symbol(__bss_start);
28434 bss_resource.end = __pa_symbol(__bss_stop)-1;
28435diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
28436index e4fcb87..9c06c55 100644
28437--- a/arch/x86/kernel/setup_percpu.c
28438+++ b/arch/x86/kernel/setup_percpu.c
28439@@ -21,19 +21,17 @@
28440 #include <asm/cpu.h>
28441 #include <asm/stackprotector.h>
28442
28443-DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
28444+#ifdef CONFIG_SMP
28445+DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
28446 EXPORT_PER_CPU_SYMBOL(cpu_number);
28447+#endif
28448
28449-#ifdef CONFIG_X86_64
28450 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
28451-#else
28452-#define BOOT_PERCPU_OFFSET 0
28453-#endif
28454
28455 DEFINE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
28456 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
28457
28458-unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
28459+unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
28460 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
28461 };
28462 EXPORT_SYMBOL(__per_cpu_offset);
28463@@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
28464 {
28465 #ifdef CONFIG_NEED_MULTIPLE_NODES
28466 pg_data_t *last = NULL;
28467- unsigned int cpu;
28468+ int cpu;
28469
28470 for_each_possible_cpu(cpu) {
28471 int node = early_cpu_to_node(cpu);
28472@@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
28473 {
28474 #ifdef CONFIG_X86_32
28475 struct desc_struct gdt;
28476+ unsigned long base = per_cpu_offset(cpu);
28477
28478- pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
28479- 0x2 | DESCTYPE_S, 0x8);
28480- gdt.s = 1;
28481+ pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
28482+ 0x83 | DESCTYPE_S, 0xC);
28483 write_gdt_entry(get_cpu_gdt_table(cpu),
28484 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
28485 #endif
28486@@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
28487 /* alrighty, percpu areas up and running */
28488 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
28489 for_each_possible_cpu(cpu) {
28490+#ifdef CONFIG_CC_STACKPROTECTOR
28491+#ifdef CONFIG_X86_32
28492+ unsigned long canary = per_cpu(stack_canary.canary, cpu);
28493+#endif
28494+#endif
28495 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
28496 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
28497 per_cpu(cpu_number, cpu) = cpu;
28498@@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
28499 */
28500 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
28501 #endif
28502+#ifdef CONFIG_CC_STACKPROTECTOR
28503+#ifdef CONFIG_X86_32
28504+ if (!cpu)
28505+ per_cpu(stack_canary.canary, cpu) = canary;
28506+#endif
28507+#endif
28508 /*
28509 * Up to this point, the boot CPU has been using .init.data
28510 * area. Reload any changed state for the boot CPU.
28511diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
28512index 71820c4..ad16f6b 100644
28513--- a/arch/x86/kernel/signal.c
28514+++ b/arch/x86/kernel/signal.c
28515@@ -189,7 +189,7 @@ static unsigned long align_sigframe(unsigned long sp)
28516 * Align the stack pointer according to the i386 ABI,
28517 * i.e. so that on function entry ((sp + 4) & 15) == 0.
28518 */
28519- sp = ((sp + 4) & -16ul) - 4;
28520+ sp = ((sp - 12) & -16ul) - 4;
28521 #else /* !CONFIG_X86_32 */
28522 sp = round_down(sp, 16) - 8;
28523 #endif
28524@@ -298,10 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
28525 }
28526
28527 if (current->mm->context.vdso)
28528- restorer = current->mm->context.vdso +
28529- selected_vdso32->sym___kernel_sigreturn;
28530+ restorer = (void __force_user *)(current->mm->context.vdso + selected_vdso32->sym___kernel_sigreturn);
28531 else
28532- restorer = &frame->retcode;
28533+ restorer = (void __user *)&frame->retcode;
28534 if (ksig->ka.sa.sa_flags & SA_RESTORER)
28535 restorer = ksig->ka.sa.sa_restorer;
28536
28537@@ -315,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
28538 * reasons and because gdb uses it as a signature to notice
28539 * signal handler stack frames.
28540 */
28541- err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
28542+ err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
28543
28544 if (err)
28545 return -EFAULT;
28546@@ -362,8 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
28547 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
28548
28549 /* Set up to return from userspace. */
28550- restorer = current->mm->context.vdso +
28551- selected_vdso32->sym___kernel_rt_sigreturn;
28552+ if (current->mm->context.vdso)
28553+ restorer = (void __force_user *)(current->mm->context.vdso + selected_vdso32->sym___kernel_rt_sigreturn);
28554+ else
28555+ restorer = (void __user *)&frame->retcode;
28556 if (ksig->ka.sa.sa_flags & SA_RESTORER)
28557 restorer = ksig->ka.sa.sa_restorer;
28558 put_user_ex(restorer, &frame->pretcode);
28559@@ -375,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
28560 * reasons and because gdb uses it as a signature to notice
28561 * signal handler stack frames.
28562 */
28563- put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
28564+ put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
28565 } put_user_catch(err);
28566
28567 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
28568@@ -611,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
28569 {
28570 int usig = ksig->sig;
28571 sigset_t *set = sigmask_to_save();
28572- compat_sigset_t *cset = (compat_sigset_t *) set;
28573+ sigset_t sigcopy;
28574+ compat_sigset_t *cset;
28575+
28576+ sigcopy = *set;
28577+
28578+ cset = (compat_sigset_t *) &sigcopy;
28579
28580 /* Set up the stack frame */
28581 if (is_ia32_frame()) {
28582@@ -622,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
28583 } else if (is_x32_frame()) {
28584 return x32_setup_rt_frame(ksig, cset, regs);
28585 } else {
28586- return __setup_rt_frame(ksig->sig, ksig, set, regs);
28587+ return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
28588 }
28589 }
28590
28591diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
28592index 15aaa69..66103af 100644
28593--- a/arch/x86/kernel/smp.c
28594+++ b/arch/x86/kernel/smp.c
28595@@ -334,7 +334,7 @@ static int __init nonmi_ipi_setup(char *str)
28596
28597 __setup("nonmi_ipi", nonmi_ipi_setup);
28598
28599-struct smp_ops smp_ops = {
28600+struct smp_ops smp_ops __read_only = {
28601 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
28602 .smp_prepare_cpus = native_smp_prepare_cpus,
28603 .smp_cpus_done = native_smp_cpus_done,
28604diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
28605index b1f3ed9c..b76221b 100644
28606--- a/arch/x86/kernel/smpboot.c
28607+++ b/arch/x86/kernel/smpboot.c
28608@@ -220,14 +220,17 @@ static void notrace start_secondary(void *unused)
28609
28610 enable_start_cpu0 = 0;
28611
28612-#ifdef CONFIG_X86_32
28613+ /* otherwise gcc will move up smp_processor_id before the cpu_init */
28614+ barrier();
28615+
28616 /* switch away from the initial page table */
28617+#ifdef CONFIG_PAX_PER_CPU_PGD
28618+ load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
28619+#else
28620 load_cr3(swapper_pg_dir);
28621+#endif
28622 __flush_tlb_all();
28623-#endif
28624
28625- /* otherwise gcc will move up smp_processor_id before the cpu_init */
28626- barrier();
28627 /*
28628 * Check TSC synchronization with the BP:
28629 */
28630@@ -808,16 +811,15 @@ void common_cpu_up(unsigned int cpu, struct task_struct *idle)
28631 alternatives_enable_smp();
28632
28633 per_cpu(current_task, cpu) = idle;
28634+ per_cpu(current_tinfo, cpu) = &idle->tinfo;
28635
28636 #ifdef CONFIG_X86_32
28637- /* Stack for startup_32 can be just as for start_secondary onwards */
28638 irq_ctx_init(cpu);
28639- per_cpu(cpu_current_top_of_stack, cpu) =
28640- (unsigned long)task_stack_page(idle) + THREAD_SIZE;
28641 #else
28642 clear_tsk_thread_flag(idle, TIF_FORK);
28643 initial_gs = per_cpu_offset(cpu);
28644 #endif
28645+ per_cpu(cpu_current_top_of_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
28646 }
28647
28648 /*
28649@@ -838,9 +840,11 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
28650 unsigned long timeout;
28651
28652 idle->thread.sp = (unsigned long) (((struct pt_regs *)
28653- (THREAD_SIZE + task_stack_page(idle))) - 1);
28654+ (THREAD_SIZE - 16 + task_stack_page(idle))) - 1);
28655
28656+ pax_open_kernel();
28657 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
28658+ pax_close_kernel();
28659 initial_code = (unsigned long)start_secondary;
28660 stack_start = idle->thread.sp;
28661
28662@@ -992,6 +996,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
28663
28664 common_cpu_up(cpu, tidle);
28665
28666+#ifdef CONFIG_PAX_PER_CPU_PGD
28667+ clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
28668+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28669+ KERNEL_PGD_PTRS);
28670+ clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
28671+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28672+ KERNEL_PGD_PTRS);
28673+#endif
28674+
28675 /*
28676 * We have to walk the irq descriptors to setup the vector
28677 * space for the cpu which comes online. Prevent irq
28678diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
28679index 0ccb53a..fbc4759 100644
28680--- a/arch/x86/kernel/step.c
28681+++ b/arch/x86/kernel/step.c
28682@@ -44,7 +44,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
28683 addr += base;
28684 }
28685 mutex_unlock(&child->mm->context.lock);
28686- }
28687+ } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
28688+ addr = ktla_ktva(addr);
28689
28690 return addr;
28691 }
28692@@ -55,6 +56,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
28693 unsigned char opcode[15];
28694 unsigned long addr = convert_ip_to_linear(child, regs);
28695
28696+ if (addr == -EINVAL)
28697+ return 0;
28698+
28699 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
28700 for (i = 0; i < copied; i++) {
28701 switch (opcode[i]) {
28702diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
28703new file mode 100644
28704index 0000000..5877189
28705--- /dev/null
28706+++ b/arch/x86/kernel/sys_i386_32.c
28707@@ -0,0 +1,189 @@
28708+/*
28709+ * This file contains various random system calls that
28710+ * have a non-standard calling sequence on the Linux/i386
28711+ * platform.
28712+ */
28713+
28714+#include <linux/errno.h>
28715+#include <linux/sched.h>
28716+#include <linux/mm.h>
28717+#include <linux/fs.h>
28718+#include <linux/smp.h>
28719+#include <linux/sem.h>
28720+#include <linux/msg.h>
28721+#include <linux/shm.h>
28722+#include <linux/stat.h>
28723+#include <linux/syscalls.h>
28724+#include <linux/mman.h>
28725+#include <linux/file.h>
28726+#include <linux/utsname.h>
28727+#include <linux/ipc.h>
28728+#include <linux/elf.h>
28729+
28730+#include <linux/uaccess.h>
28731+#include <linux/unistd.h>
28732+
28733+#include <asm/syscalls.h>
28734+
28735+int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
28736+{
28737+ unsigned long pax_task_size = TASK_SIZE;
28738+
28739+#ifdef CONFIG_PAX_SEGMEXEC
28740+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
28741+ pax_task_size = SEGMEXEC_TASK_SIZE;
28742+#endif
28743+
28744+ if (flags & MAP_FIXED)
28745+ if (len > pax_task_size || addr > pax_task_size - len)
28746+ return -EINVAL;
28747+
28748+ return 0;
28749+}
28750+
28751+/*
28752+ * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
28753+ */
28754+static unsigned long get_align_mask(void)
28755+{
28756+ if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
28757+ return 0;
28758+
28759+ if (!(current->flags & PF_RANDOMIZE))
28760+ return 0;
28761+
28762+ return va_align.mask;
28763+}
28764+
28765+unsigned long
28766+arch_get_unmapped_area(struct file *filp, unsigned long addr,
28767+ unsigned long len, unsigned long pgoff, unsigned long flags)
28768+{
28769+ struct mm_struct *mm = current->mm;
28770+ struct vm_area_struct *vma;
28771+ unsigned long pax_task_size = TASK_SIZE;
28772+ struct vm_unmapped_area_info info;
28773+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28774+
28775+#ifdef CONFIG_PAX_SEGMEXEC
28776+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
28777+ pax_task_size = SEGMEXEC_TASK_SIZE;
28778+#endif
28779+
28780+ pax_task_size -= PAGE_SIZE;
28781+
28782+ if (len > pax_task_size)
28783+ return -ENOMEM;
28784+
28785+ if (flags & MAP_FIXED)
28786+ return addr;
28787+
28788+#ifdef CONFIG_PAX_RANDMMAP
28789+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28790+#endif
28791+
28792+ if (addr) {
28793+ addr = PAGE_ALIGN(addr);
28794+ if (pax_task_size - len >= addr) {
28795+ vma = find_vma(mm, addr);
28796+ if (check_heap_stack_gap(vma, addr, len, offset))
28797+ return addr;
28798+ }
28799+ }
28800+
28801+ info.flags = 0;
28802+ info.length = len;
28803+ info.align_mask = filp ? get_align_mask() : 0;
28804+ info.align_offset = pgoff << PAGE_SHIFT;
28805+ info.threadstack_offset = offset;
28806+
28807+#ifdef CONFIG_PAX_PAGEEXEC
28808+ if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
28809+ info.low_limit = 0x00110000UL;
28810+ info.high_limit = mm->start_code;
28811+
28812+#ifdef CONFIG_PAX_RANDMMAP
28813+ if (mm->pax_flags & MF_PAX_RANDMMAP)
28814+ info.low_limit += mm->delta_mmap & 0x03FFF000UL;
28815+#endif
28816+
28817+ if (info.low_limit < info.high_limit) {
28818+ addr = vm_unmapped_area(&info);
28819+ if (!IS_ERR_VALUE(addr))
28820+ return addr;
28821+ }
28822+ } else
28823+#endif
28824+
28825+ info.low_limit = mm->mmap_base;
28826+ info.high_limit = pax_task_size;
28827+
28828+ return vm_unmapped_area(&info);
28829+}
28830+
28831+unsigned long
28832+arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28833+ const unsigned long len, const unsigned long pgoff,
28834+ const unsigned long flags)
28835+{
28836+ struct vm_area_struct *vma;
28837+ struct mm_struct *mm = current->mm;
28838+ unsigned long addr = addr0, pax_task_size = TASK_SIZE;
28839+ struct vm_unmapped_area_info info;
28840+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28841+
28842+#ifdef CONFIG_PAX_SEGMEXEC
28843+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
28844+ pax_task_size = SEGMEXEC_TASK_SIZE;
28845+#endif
28846+
28847+ pax_task_size -= PAGE_SIZE;
28848+
28849+ /* requested length too big for entire address space */
28850+ if (len > pax_task_size)
28851+ return -ENOMEM;
28852+
28853+ if (flags & MAP_FIXED)
28854+ return addr;
28855+
28856+#ifdef CONFIG_PAX_PAGEEXEC
28857+ if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
28858+ goto bottomup;
28859+#endif
28860+
28861+#ifdef CONFIG_PAX_RANDMMAP
28862+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28863+#endif
28864+
28865+ /* requesting a specific address */
28866+ if (addr) {
28867+ addr = PAGE_ALIGN(addr);
28868+ if (pax_task_size - len >= addr) {
28869+ vma = find_vma(mm, addr);
28870+ if (check_heap_stack_gap(vma, addr, len, offset))
28871+ return addr;
28872+ }
28873+ }
28874+
28875+ info.flags = VM_UNMAPPED_AREA_TOPDOWN;
28876+ info.length = len;
28877+ info.low_limit = PAGE_SIZE;
28878+ info.high_limit = mm->mmap_base;
28879+ info.align_mask = filp ? get_align_mask() : 0;
28880+ info.align_offset = pgoff << PAGE_SHIFT;
28881+ info.threadstack_offset = offset;
28882+
28883+ addr = vm_unmapped_area(&info);
28884+ if (!(addr & ~PAGE_MASK))
28885+ return addr;
28886+ VM_BUG_ON(addr != -ENOMEM);
28887+
28888+bottomup:
28889+ /*
28890+ * A failed mmap() very likely causes application failure,
28891+ * so fall back to the bottom-up function here. This scenario
28892+ * can happen with large stack limits and large mmap()
28893+ * allocations.
28894+ */
28895+ return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
28896+}
28897diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
28898index 10e0272..b4bb9a7 100644
28899--- a/arch/x86/kernel/sys_x86_64.c
28900+++ b/arch/x86/kernel/sys_x86_64.c
28901@@ -97,8 +97,8 @@ out:
28902 return error;
28903 }
28904
28905-static void find_start_end(unsigned long flags, unsigned long *begin,
28906- unsigned long *end)
28907+static void find_start_end(struct mm_struct *mm, unsigned long flags,
28908+ unsigned long *begin, unsigned long *end)
28909 {
28910 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
28911 unsigned long new_begin;
28912@@ -117,7 +117,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
28913 *begin = new_begin;
28914 }
28915 } else {
28916- *begin = current->mm->mmap_legacy_base;
28917+ *begin = mm->mmap_legacy_base;
28918 *end = TASK_SIZE;
28919 }
28920 }
28921@@ -130,20 +130,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
28922 struct vm_area_struct *vma;
28923 struct vm_unmapped_area_info info;
28924 unsigned long begin, end;
28925+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28926
28927 if (flags & MAP_FIXED)
28928 return addr;
28929
28930- find_start_end(flags, &begin, &end);
28931+ find_start_end(mm, flags, &begin, &end);
28932
28933 if (len > end)
28934 return -ENOMEM;
28935
28936+#ifdef CONFIG_PAX_RANDMMAP
28937+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28938+#endif
28939+
28940 if (addr) {
28941 addr = PAGE_ALIGN(addr);
28942 vma = find_vma(mm, addr);
28943- if (end - len >= addr &&
28944- (!vma || addr + len <= vma->vm_start))
28945+ if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28946 return addr;
28947 }
28948
28949@@ -157,6 +161,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
28950 info.align_mask = get_align_mask();
28951 info.align_offset += get_align_bits();
28952 }
28953+ info.threadstack_offset = offset;
28954 return vm_unmapped_area(&info);
28955 }
28956
28957@@ -169,6 +174,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28958 struct mm_struct *mm = current->mm;
28959 unsigned long addr = addr0;
28960 struct vm_unmapped_area_info info;
28961+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28962
28963 /* requested length too big for entire address space */
28964 if (len > TASK_SIZE)
28965@@ -181,12 +187,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28966 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
28967 goto bottomup;
28968
28969+#ifdef CONFIG_PAX_RANDMMAP
28970+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28971+#endif
28972+
28973 /* requesting a specific address */
28974 if (addr) {
28975 addr = PAGE_ALIGN(addr);
28976 vma = find_vma(mm, addr);
28977- if (TASK_SIZE - len >= addr &&
28978- (!vma || addr + len <= vma->vm_start))
28979+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28980 return addr;
28981 }
28982
28983@@ -200,6 +209,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28984 info.align_mask = get_align_mask();
28985 info.align_offset += get_align_bits();
28986 }
28987+ info.threadstack_offset = offset;
28988 addr = vm_unmapped_area(&info);
28989 if (!(addr & ~PAGE_MASK))
28990 return addr;
28991diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
28992index 91a4496..42fc304 100644
28993--- a/arch/x86/kernel/tboot.c
28994+++ b/arch/x86/kernel/tboot.c
28995@@ -44,6 +44,7 @@
28996 #include <asm/setup.h>
28997 #include <asm/e820.h>
28998 #include <asm/io.h>
28999+#include <asm/tlbflush.h>
29000
29001 #include "../realmode/rm/wakeup.h"
29002
29003@@ -221,7 +222,7 @@ static int tboot_setup_sleep(void)
29004
29005 void tboot_shutdown(u32 shutdown_type)
29006 {
29007- void (*shutdown)(void);
29008+ void (* __noreturn shutdown)(void);
29009
29010 if (!tboot_enabled())
29011 return;
29012@@ -242,8 +243,9 @@ void tboot_shutdown(u32 shutdown_type)
29013 tboot->shutdown_type = shutdown_type;
29014
29015 switch_to_tboot_pt();
29016+ cr4_clear_bits(X86_CR4_PCIDE);
29017
29018- shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
29019+ shutdown = (void *)(unsigned long)tboot->shutdown_entry;
29020 shutdown();
29021
29022 /* should not reach here */
29023@@ -310,7 +312,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
29024 return -ENODEV;
29025 }
29026
29027-static atomic_t ap_wfs_count;
29028+static atomic_unchecked_t ap_wfs_count;
29029
29030 static int tboot_wait_for_aps(int num_aps)
29031 {
29032@@ -334,9 +336,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
29033 {
29034 switch (action) {
29035 case CPU_DYING:
29036- atomic_inc(&ap_wfs_count);
29037+ atomic_inc_unchecked(&ap_wfs_count);
29038 if (num_online_cpus() == 1)
29039- if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
29040+ if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
29041 return NOTIFY_BAD;
29042 break;
29043 }
29044@@ -422,7 +424,7 @@ static __init int tboot_late_init(void)
29045
29046 tboot_create_trampoline();
29047
29048- atomic_set(&ap_wfs_count, 0);
29049+ atomic_set_unchecked(&ap_wfs_count, 0);
29050 register_hotcpu_notifier(&tboot_cpu_notifier);
29051
29052 #ifdef CONFIG_DEBUG_FS
29053diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
29054index d39c091..1df4349 100644
29055--- a/arch/x86/kernel/time.c
29056+++ b/arch/x86/kernel/time.c
29057@@ -32,7 +32,7 @@ unsigned long profile_pc(struct pt_regs *regs)
29058
29059 if (!user_mode(regs) && in_lock_functions(pc)) {
29060 #ifdef CONFIG_FRAME_POINTER
29061- return *(unsigned long *)(regs->bp + sizeof(long));
29062+ return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
29063 #else
29064 unsigned long *sp =
29065 (unsigned long *)kernel_stack_pointer(regs);
29066@@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
29067 * or above a saved flags. Eflags has bits 22-31 zero,
29068 * kernel addresses don't.
29069 */
29070+
29071+#ifdef CONFIG_PAX_KERNEXEC
29072+ return ktla_ktva(sp[0]);
29073+#else
29074 if (sp[0] >> 22)
29075 return sp[0];
29076 if (sp[1] >> 22)
29077 return sp[1];
29078 #endif
29079+
29080+#endif
29081 }
29082 return pc;
29083 }
29084diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
29085index 7fc5e84..c6e445a 100644
29086--- a/arch/x86/kernel/tls.c
29087+++ b/arch/x86/kernel/tls.c
29088@@ -139,6 +139,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
29089 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
29090 return -EINVAL;
29091
29092+#ifdef CONFIG_PAX_SEGMEXEC
29093+ if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
29094+ return -EINVAL;
29095+#endif
29096+
29097 set_tls_desc(p, idx, &info, 1);
29098
29099 return 0;
29100@@ -256,7 +261,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
29101
29102 if (kbuf)
29103 info = kbuf;
29104- else if (__copy_from_user(infobuf, ubuf, count))
29105+ else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
29106 return -EFAULT;
29107 else
29108 info = infobuf;
29109diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
29110index 1c113db..287b42e 100644
29111--- a/arch/x86/kernel/tracepoint.c
29112+++ b/arch/x86/kernel/tracepoint.c
29113@@ -9,11 +9,11 @@
29114 #include <linux/atomic.h>
29115
29116 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
29117-struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
29118+const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
29119 (unsigned long) trace_idt_table };
29120
29121 /* No need to be aligned, but done to keep all IDTs defined the same way. */
29122-gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
29123+gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
29124
29125 static int trace_irq_vector_refcount;
29126 static DEFINE_MUTEX(irq_vector_mutex);
29127diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
29128index f579192..aed90b8 100644
29129--- a/arch/x86/kernel/traps.c
29130+++ b/arch/x86/kernel/traps.c
29131@@ -69,7 +69,7 @@
29132 #include <asm/proto.h>
29133
29134 /* No need to be aligned, but done to keep all IDTs defined the same way. */
29135-gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
29136+gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
29137 #else
29138 #include <asm/processor-flags.h>
29139 #include <asm/setup.h>
29140@@ -77,7 +77,7 @@ gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
29141 #endif
29142
29143 /* Must be page-aligned because the real IDT is used in a fixmap. */
29144-gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
29145+gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
29146
29147 DECLARE_BITMAP(used_vectors, NR_VECTORS);
29148 EXPORT_SYMBOL_GPL(used_vectors);
29149@@ -174,7 +174,7 @@ void ist_begin_non_atomic(struct pt_regs *regs)
29150 * will catch asm bugs and any attempt to use ist_preempt_enable
29151 * from double_fault.
29152 */
29153- BUG_ON((unsigned long)(current_top_of_stack() -
29154+ BUG_ON((unsigned long)(current_top_of_stack(smp_processor_id()) -
29155 current_stack_pointer()) >= THREAD_SIZE);
29156
29157 preempt_count_sub(HARDIRQ_OFFSET);
29158@@ -191,7 +191,7 @@ void ist_end_non_atomic(void)
29159 }
29160
29161 static nokprobe_inline int
29162-do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
29163+do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
29164 struct pt_regs *regs, long error_code)
29165 {
29166 if (v8086_mode(regs)) {
29167@@ -211,8 +211,20 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
29168 if (!fixup_exception(regs)) {
29169 tsk->thread.error_code = error_code;
29170 tsk->thread.trap_nr = trapnr;
29171+
29172+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29173+ if (trapnr == X86_TRAP_SS && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
29174+ str = "PAX: suspicious stack segment fault";
29175+#endif
29176+
29177 die(str, regs, error_code);
29178 }
29179+
29180+#ifdef CONFIG_PAX_REFCOUNT
29181+ if (trapnr == X86_TRAP_OF)
29182+ pax_report_refcount_overflow(regs);
29183+#endif
29184+
29185 return 0;
29186 }
29187
29188@@ -251,7 +263,7 @@ static siginfo_t *fill_trap_info(struct pt_regs *regs, int signr, int trapnr,
29189 }
29190
29191 static void
29192-do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
29193+do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
29194 long error_code, siginfo_t *info)
29195 {
29196 struct task_struct *tsk = current;
29197@@ -275,7 +287,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
29198 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
29199 printk_ratelimit()) {
29200 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
29201- tsk->comm, tsk->pid, str,
29202+ tsk->comm, task_pid_nr(tsk), str,
29203 regs->ip, regs->sp, error_code);
29204 print_vma_addr(" in ", regs->ip);
29205 pr_cont("\n");
29206@@ -357,6 +369,11 @@ dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
29207 tsk->thread.error_code = error_code;
29208 tsk->thread.trap_nr = X86_TRAP_DF;
29209
29210+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
29211+ if ((unsigned long)tsk->stack - regs->sp <= PAGE_SIZE)
29212+ die("grsec: kernel stack overflow detected", regs, error_code);
29213+#endif
29214+
29215 #ifdef CONFIG_DOUBLEFAULT
29216 df_debug(regs, error_code);
29217 #endif
29218@@ -473,11 +490,35 @@ do_general_protection(struct pt_regs *regs, long error_code)
29219 tsk->thread.error_code = error_code;
29220 tsk->thread.trap_nr = X86_TRAP_GP;
29221 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
29222- X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
29223+ X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
29224+
29225+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29226+ if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
29227+ die("PAX: suspicious general protection fault", regs, error_code);
29228+ else
29229+#endif
29230+
29231 die("general protection fault", regs, error_code);
29232+ }
29233 goto exit;
29234 }
29235
29236+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
29237+ if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
29238+ struct mm_struct *mm = tsk->mm;
29239+ unsigned long limit;
29240+
29241+ down_write(&mm->mmap_sem);
29242+ limit = mm->context.user_cs_limit;
29243+ if (limit < TASK_SIZE) {
29244+ track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
29245+ up_write(&mm->mmap_sem);
29246+ return;
29247+ }
29248+ up_write(&mm->mmap_sem);
29249+ }
29250+#endif
29251+
29252 tsk->thread.error_code = error_code;
29253 tsk->thread.trap_nr = X86_TRAP_GP;
29254
29255@@ -576,6 +617,9 @@ struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s)
29256 container_of(task_pt_regs(current),
29257 struct bad_iret_stack, regs);
29258
29259+ if ((current->thread.sp0 ^ (unsigned long)s) < THREAD_SIZE)
29260+ new_stack = s;
29261+
29262 /* Copy the IRET target to the new stack. */
29263 memmove(&new_stack->regs.ip, (void *)s->regs.sp, 5*8);
29264
29265diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
29266index dc9af7a..1bc625e 100644
29267--- a/arch/x86/kernel/tsc.c
29268+++ b/arch/x86/kernel/tsc.c
29269@@ -151,7 +151,7 @@ static void cyc2ns_write_end(int cpu, struct cyc2ns_data *data)
29270 */
29271 smp_wmb();
29272
29273- ACCESS_ONCE(c2n->head) = data;
29274+ ACCESS_ONCE_RW(c2n->head) = data;
29275 }
29276
29277 /*
29278diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
29279index 6647624..2056791 100644
29280--- a/arch/x86/kernel/uprobes.c
29281+++ b/arch/x86/kernel/uprobes.c
29282@@ -978,7 +978,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
29283
29284 if (nleft != rasize) {
29285 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
29286- "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
29287+ "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
29288
29289 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
29290 }
29291diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
29292index b9242ba..50c5edd 100644
29293--- a/arch/x86/kernel/verify_cpu.S
29294+++ b/arch/x86/kernel/verify_cpu.S
29295@@ -20,6 +20,7 @@
29296 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
29297 * arch/x86/kernel/trampoline_64.S: secondary processor verification
29298 * arch/x86/kernel/head_32.S: processor startup
29299+ * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
29300 *
29301 * verify_cpu, returns the status of longmode and SSE in register %eax.
29302 * 0: Success 1: Failure
29303diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
29304index fc9db6e..2c5865d 100644
29305--- a/arch/x86/kernel/vm86_32.c
29306+++ b/arch/x86/kernel/vm86_32.c
29307@@ -44,6 +44,7 @@
29308 #include <linux/ptrace.h>
29309 #include <linux/audit.h>
29310 #include <linux/stddef.h>
29311+#include <linux/grsecurity.h>
29312
29313 #include <asm/uaccess.h>
29314 #include <asm/io.h>
29315@@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
29316 do_exit(SIGSEGV);
29317 }
29318
29319- tss = &per_cpu(cpu_tss, get_cpu());
29320+ tss = cpu_tss + get_cpu();
29321 current->thread.sp0 = current->thread.saved_sp0;
29322 current->thread.sysenter_cs = __KERNEL_CS;
29323 load_sp0(tss, &current->thread);
29324@@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
29325
29326 if (tsk->thread.saved_sp0)
29327 return -EPERM;
29328+
29329+#ifdef CONFIG_GRKERNSEC_VM86
29330+ if (!capable(CAP_SYS_RAWIO)) {
29331+ gr_handle_vm86();
29332+ return -EPERM;
29333+ }
29334+#endif
29335+
29336 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
29337 offsetof(struct kernel_vm86_struct, vm86plus) -
29338 sizeof(info.regs));
29339@@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
29340 int tmp;
29341 struct vm86plus_struct __user *v86;
29342
29343+#ifdef CONFIG_GRKERNSEC_VM86
29344+ if (!capable(CAP_SYS_RAWIO)) {
29345+ gr_handle_vm86();
29346+ return -EPERM;
29347+ }
29348+#endif
29349+
29350 tsk = current;
29351 switch (cmd) {
29352 case VM86_REQUEST_IRQ:
29353@@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
29354 tsk->thread.saved_fs = info->regs32->fs;
29355 tsk->thread.saved_gs = get_user_gs(info->regs32);
29356
29357- tss = &per_cpu(cpu_tss, get_cpu());
29358+ tss = cpu_tss + get_cpu();
29359 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
29360 if (cpu_has_sep)
29361 tsk->thread.sysenter_cs = 0;
29362@@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
29363 goto cannot_handle;
29364 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
29365 goto cannot_handle;
29366- intr_ptr = (unsigned long __user *) (i << 2);
29367+ intr_ptr = (__force unsigned long __user *) (i << 2);
29368 if (get_user(segoffs, intr_ptr))
29369 goto cannot_handle;
29370 if ((segoffs >> 16) == BIOSSEG)
29371diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
29372index 00bf300..03e1c3b 100644
29373--- a/arch/x86/kernel/vmlinux.lds.S
29374+++ b/arch/x86/kernel/vmlinux.lds.S
29375@@ -26,6 +26,13 @@
29376 #include <asm/page_types.h>
29377 #include <asm/cache.h>
29378 #include <asm/boot.h>
29379+#include <asm/segment.h>
29380+
29381+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29382+#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
29383+#else
29384+#define __KERNEL_TEXT_OFFSET 0
29385+#endif
29386
29387 #undef i386 /* in case the preprocessor is a 32bit one */
29388
29389@@ -69,30 +76,43 @@ jiffies_64 = jiffies;
29390
29391 PHDRS {
29392 text PT_LOAD FLAGS(5); /* R_E */
29393+#ifdef CONFIG_X86_32
29394+ module PT_LOAD FLAGS(5); /* R_E */
29395+#endif
29396+#ifdef CONFIG_XEN
29397+ rodata PT_LOAD FLAGS(5); /* R_E */
29398+#else
29399+ rodata PT_LOAD FLAGS(4); /* R__ */
29400+#endif
29401 data PT_LOAD FLAGS(6); /* RW_ */
29402-#ifdef CONFIG_X86_64
29403+ init.begin PT_LOAD FLAGS(6); /* RW_ */
29404 #ifdef CONFIG_SMP
29405 percpu PT_LOAD FLAGS(6); /* RW_ */
29406 #endif
29407- init PT_LOAD FLAGS(7); /* RWE */
29408-#endif
29409+ text.init PT_LOAD FLAGS(5); /* R_E */
29410+ text.exit PT_LOAD FLAGS(5); /* R_E */
29411+ init PT_LOAD FLAGS(6); /* RW_ */
29412 note PT_NOTE FLAGS(0); /* ___ */
29413 }
29414
29415 SECTIONS
29416 {
29417 #ifdef CONFIG_X86_32
29418- . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
29419- phys_startup_32 = startup_32 - LOAD_OFFSET;
29420+ . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
29421 #else
29422- . = __START_KERNEL;
29423- phys_startup_64 = startup_64 - LOAD_OFFSET;
29424+ . = __START_KERNEL;
29425 #endif
29426
29427 /* Text and read-only data */
29428- .text : AT(ADDR(.text) - LOAD_OFFSET) {
29429- _text = .;
29430+ .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
29431 /* bootstrapping code */
29432+#ifdef CONFIG_X86_32
29433+ phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
29434+#else
29435+ phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
29436+#endif
29437+ __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
29438+ _text = .;
29439 HEAD_TEXT
29440 . = ALIGN(8);
29441 _stext = .;
29442@@ -104,13 +124,47 @@ SECTIONS
29443 IRQENTRY_TEXT
29444 *(.fixup)
29445 *(.gnu.warning)
29446- /* End of text section */
29447- _etext = .;
29448 } :text = 0x9090
29449
29450- NOTES :text :note
29451+ . += __KERNEL_TEXT_OFFSET;
29452
29453- EXCEPTION_TABLE(16) :text = 0x9090
29454+#ifdef CONFIG_X86_32
29455+ . = ALIGN(PAGE_SIZE);
29456+ .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
29457+
29458+#ifdef CONFIG_PAX_KERNEXEC
29459+ MODULES_EXEC_VADDR = .;
29460+ BYTE(0)
29461+ . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
29462+ . = ALIGN(HPAGE_SIZE) - 1;
29463+ MODULES_EXEC_END = .;
29464+#endif
29465+
29466+ } :module
29467+#endif
29468+
29469+ .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
29470+ /* End of text section */
29471+ BYTE(0)
29472+ _etext = . - __KERNEL_TEXT_OFFSET;
29473+ }
29474+
29475+#ifdef CONFIG_X86_32
29476+ . = ALIGN(PAGE_SIZE);
29477+ .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
29478+ . = ALIGN(PAGE_SIZE);
29479+ *(.empty_zero_page)
29480+ *(.initial_pg_fixmap)
29481+ *(.initial_pg_pmd)
29482+ *(.initial_page_table)
29483+ *(.swapper_pg_dir)
29484+ } :rodata
29485+#endif
29486+
29487+ . = ALIGN(PAGE_SIZE);
29488+ NOTES :rodata :note
29489+
29490+ EXCEPTION_TABLE(16) :rodata
29491
29492 #if defined(CONFIG_DEBUG_RODATA)
29493 /* .text should occupy whole number of pages */
29494@@ -122,16 +176,20 @@ SECTIONS
29495
29496 /* Data */
29497 .data : AT(ADDR(.data) - LOAD_OFFSET) {
29498+
29499+#ifdef CONFIG_PAX_KERNEXEC
29500+ . = ALIGN(HPAGE_SIZE);
29501+#else
29502+ . = ALIGN(PAGE_SIZE);
29503+#endif
29504+
29505 /* Start of data section */
29506 _sdata = .;
29507
29508 /* init_task */
29509 INIT_TASK_DATA(THREAD_SIZE)
29510
29511-#ifdef CONFIG_X86_32
29512- /* 32 bit has nosave before _edata */
29513 NOSAVE_DATA
29514-#endif
29515
29516 PAGE_ALIGNED_DATA(PAGE_SIZE)
29517
29518@@ -174,12 +232,19 @@ SECTIONS
29519 . = ALIGN(__vvar_page + PAGE_SIZE, PAGE_SIZE);
29520
29521 /* Init code and data - will be freed after init */
29522- . = ALIGN(PAGE_SIZE);
29523 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
29524+ BYTE(0)
29525+
29526+#ifdef CONFIG_PAX_KERNEXEC
29527+ . = ALIGN(HPAGE_SIZE);
29528+#else
29529+ . = ALIGN(PAGE_SIZE);
29530+#endif
29531+
29532 __init_begin = .; /* paired with __init_end */
29533- }
29534+ } :init.begin
29535
29536-#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
29537+#ifdef CONFIG_SMP
29538 /*
29539 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
29540 * output PHDR, so the next output section - .init.text - should
29541@@ -190,12 +255,33 @@ SECTIONS
29542 "per-CPU data too large - increase CONFIG_PHYSICAL_START")
29543 #endif
29544
29545- INIT_TEXT_SECTION(PAGE_SIZE)
29546-#ifdef CONFIG_X86_64
29547- :init
29548+ . = ALIGN(PAGE_SIZE);
29549+ init_begin = .;
29550+ .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
29551+ VMLINUX_SYMBOL(_sinittext) = .;
29552+ INIT_TEXT
29553+ . = ALIGN(PAGE_SIZE);
29554+ } :text.init
29555+
29556+ /*
29557+ * .exit.text is discard at runtime, not link time, to deal with
29558+ * references from .altinstructions and .eh_frame
29559+ */
29560+ .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
29561+ EXIT_TEXT
29562+ VMLINUX_SYMBOL(_einittext) = .;
29563+
29564+#ifdef CONFIG_PAX_KERNEXEC
29565+ . = ALIGN(HPAGE_SIZE);
29566+#else
29567+ . = ALIGN(16);
29568 #endif
29569
29570- INIT_DATA_SECTION(16)
29571+ } :text.exit
29572+ . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
29573+
29574+ . = ALIGN(PAGE_SIZE);
29575+ INIT_DATA_SECTION(16) :init
29576
29577 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
29578 __x86_cpu_dev_start = .;
29579@@ -266,19 +352,12 @@ SECTIONS
29580 }
29581
29582 . = ALIGN(8);
29583- /*
29584- * .exit.text is discard at runtime, not link time, to deal with
29585- * references from .altinstructions and .eh_frame
29586- */
29587- .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
29588- EXIT_TEXT
29589- }
29590
29591 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
29592 EXIT_DATA
29593 }
29594
29595-#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
29596+#ifndef CONFIG_SMP
29597 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
29598 #endif
29599
29600@@ -297,16 +376,10 @@ SECTIONS
29601 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
29602 __smp_locks = .;
29603 *(.smp_locks)
29604- . = ALIGN(PAGE_SIZE);
29605 __smp_locks_end = .;
29606+ . = ALIGN(PAGE_SIZE);
29607 }
29608
29609-#ifdef CONFIG_X86_64
29610- .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
29611- NOSAVE_DATA
29612- }
29613-#endif
29614-
29615 /* BSS */
29616 . = ALIGN(PAGE_SIZE);
29617 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
29618@@ -322,6 +395,7 @@ SECTIONS
29619 __brk_base = .;
29620 . += 64 * 1024; /* 64k alignment slop space */
29621 *(.brk_reservation) /* areas brk users have reserved */
29622+ . = ALIGN(HPAGE_SIZE);
29623 __brk_limit = .;
29624 }
29625
29626@@ -348,13 +422,12 @@ SECTIONS
29627 * for the boot processor.
29628 */
29629 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
29630-INIT_PER_CPU(gdt_page);
29631 INIT_PER_CPU(irq_stack_union);
29632
29633 /*
29634 * Build-time check on the image size:
29635 */
29636-. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
29637+. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
29638 "kernel image bigger than KERNEL_IMAGE_SIZE");
29639
29640 #ifdef CONFIG_SMP
29641diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
29642index a0695be..33e180c 100644
29643--- a/arch/x86/kernel/x8664_ksyms_64.c
29644+++ b/arch/x86/kernel/x8664_ksyms_64.c
29645@@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
29646 EXPORT_SYMBOL(copy_user_generic_unrolled);
29647 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
29648 EXPORT_SYMBOL(__copy_user_nocache);
29649-EXPORT_SYMBOL(_copy_from_user);
29650-EXPORT_SYMBOL(_copy_to_user);
29651
29652 EXPORT_SYMBOL(copy_page);
29653 EXPORT_SYMBOL(clear_page);
29654@@ -77,3 +75,7 @@ EXPORT_SYMBOL(native_load_gs_index);
29655 EXPORT_SYMBOL(___preempt_schedule);
29656 EXPORT_SYMBOL(___preempt_schedule_notrace);
29657 #endif
29658+
29659+#ifdef CONFIG_PAX_PER_CPU_PGD
29660+EXPORT_SYMBOL(cpu_pgd);
29661+#endif
29662diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
29663index 3839628..2e5b5b35 100644
29664--- a/arch/x86/kernel/x86_init.c
29665+++ b/arch/x86/kernel/x86_init.c
29666@@ -92,7 +92,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
29667 static void default_nmi_init(void) { };
29668 static int default_i8042_detect(void) { return 1; };
29669
29670-struct x86_platform_ops x86_platform = {
29671+struct x86_platform_ops x86_platform __read_only = {
29672 .calibrate_tsc = native_calibrate_tsc,
29673 .get_wallclock = mach_get_cmos_time,
29674 .set_wallclock = mach_set_rtc_mmss,
29675@@ -108,7 +108,7 @@ struct x86_platform_ops x86_platform = {
29676 EXPORT_SYMBOL_GPL(x86_platform);
29677
29678 #if defined(CONFIG_PCI_MSI)
29679-struct x86_msi_ops x86_msi = {
29680+struct x86_msi_ops x86_msi __read_only = {
29681 .setup_msi_irqs = native_setup_msi_irqs,
29682 .teardown_msi_irq = native_teardown_msi_irq,
29683 .teardown_msi_irqs = default_teardown_msi_irqs,
29684@@ -137,7 +137,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev)
29685 }
29686 #endif
29687
29688-struct x86_io_apic_ops x86_io_apic_ops = {
29689+struct x86_io_apic_ops x86_io_apic_ops __read_only = {
29690 .read = native_io_apic_read,
29691 .disable = native_disable_io_apic,
29692 };
29693diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
29694index 2fbea25..9e0f8c7 100644
29695--- a/arch/x86/kvm/cpuid.c
29696+++ b/arch/x86/kvm/cpuid.c
29697@@ -206,15 +206,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
29698 struct kvm_cpuid2 *cpuid,
29699 struct kvm_cpuid_entry2 __user *entries)
29700 {
29701- int r;
29702+ int r, i;
29703
29704 r = -E2BIG;
29705 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
29706 goto out;
29707 r = -EFAULT;
29708- if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
29709- cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
29710+ if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
29711 goto out;
29712+ for (i = 0; i < cpuid->nent; ++i) {
29713+ struct kvm_cpuid_entry2 cpuid_entry;
29714+ if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
29715+ goto out;
29716+ vcpu->arch.cpuid_entries[i] = cpuid_entry;
29717+ }
29718 vcpu->arch.cpuid_nent = cpuid->nent;
29719 kvm_apic_set_version(vcpu);
29720 kvm_x86_ops->cpuid_update(vcpu);
29721@@ -227,15 +232,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
29722 struct kvm_cpuid2 *cpuid,
29723 struct kvm_cpuid_entry2 __user *entries)
29724 {
29725- int r;
29726+ int r, i;
29727
29728 r = -E2BIG;
29729 if (cpuid->nent < vcpu->arch.cpuid_nent)
29730 goto out;
29731 r = -EFAULT;
29732- if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
29733- vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
29734+ if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
29735 goto out;
29736+ for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
29737+ struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
29738+ if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
29739+ goto out;
29740+ }
29741 return 0;
29742
29743 out:
29744diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
29745index e7a4fde..623af93 100644
29746--- a/arch/x86/kvm/emulate.c
29747+++ b/arch/x86/kvm/emulate.c
29748@@ -3847,7 +3847,7 @@ static int check_cr_write(struct x86_emulate_ctxt *ctxt)
29749 int cr = ctxt->modrm_reg;
29750 u64 efer = 0;
29751
29752- static u64 cr_reserved_bits[] = {
29753+ static const u64 cr_reserved_bits[] = {
29754 0xffffffff00000000ULL,
29755 0, 0, 0, /* CR3 checked later */
29756 CR4_RESERVED_BITS,
29757diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
29758index 2a5ca97..ce8577a 100644
29759--- a/arch/x86/kvm/lapic.c
29760+++ b/arch/x86/kvm/lapic.c
29761@@ -56,7 +56,7 @@
29762 #define APIC_BUS_CYCLE_NS 1
29763
29764 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
29765-#define apic_debug(fmt, arg...)
29766+#define apic_debug(fmt, arg...) do {} while (0)
29767
29768 #define APIC_LVT_NUM 6
29769 /* 14 is the version for Xeon and Pentium 8.4.8*/
29770diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
29771index 0f67d7e..4b9fa11 100644
29772--- a/arch/x86/kvm/paging_tmpl.h
29773+++ b/arch/x86/kvm/paging_tmpl.h
29774@@ -343,7 +343,7 @@ retry_walk:
29775 if (unlikely(kvm_is_error_hva(host_addr)))
29776 goto error;
29777
29778- ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
29779+ ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
29780 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
29781 goto error;
29782 walker->ptep_user[walker->level - 1] = ptep_user;
29783diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
29784index 2d32b67..2cd298b 100644
29785--- a/arch/x86/kvm/svm.c
29786+++ b/arch/x86/kvm/svm.c
29787@@ -3586,7 +3586,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
29788 int cpu = raw_smp_processor_id();
29789
29790 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
29791+
29792+ pax_open_kernel();
29793 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
29794+ pax_close_kernel();
29795+
29796 load_TR_desc();
29797 }
29798
29799@@ -3982,6 +3986,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
29800 #endif
29801 #endif
29802
29803+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
29804+ __set_fs(current_thread_info()->addr_limit);
29805+#endif
29806+
29807 reload_tss(vcpu);
29808
29809 local_irq_disable();
29810diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
29811index aa9e8229..ab09cc4 100644
29812--- a/arch/x86/kvm/vmx.c
29813+++ b/arch/x86/kvm/vmx.c
29814@@ -1440,12 +1440,12 @@ static void vmcs_write64(unsigned long field, u64 value)
29815 #endif
29816 }
29817
29818-static void vmcs_clear_bits(unsigned long field, u32 mask)
29819+static void vmcs_clear_bits(unsigned long field, unsigned long mask)
29820 {
29821 vmcs_writel(field, vmcs_readl(field) & ~mask);
29822 }
29823
29824-static void vmcs_set_bits(unsigned long field, u32 mask)
29825+static void vmcs_set_bits(unsigned long field, unsigned long mask)
29826 {
29827 vmcs_writel(field, vmcs_readl(field) | mask);
29828 }
29829@@ -1705,7 +1705,11 @@ static void reload_tss(void)
29830 struct desc_struct *descs;
29831
29832 descs = (void *)gdt->address;
29833+
29834+ pax_open_kernel();
29835 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
29836+ pax_close_kernel();
29837+
29838 load_TR_desc();
29839 }
29840
29841@@ -1941,6 +1945,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
29842 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
29843 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
29844
29845+#ifdef CONFIG_PAX_PER_CPU_PGD
29846+ vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
29847+#endif
29848+
29849 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
29850 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
29851 vmx->loaded_vmcs->cpu = cpu;
29852@@ -2232,7 +2240,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
29853 * reads and returns guest's timestamp counter "register"
29854 * guest_tsc = host_tsc + tsc_offset -- 21.3
29855 */
29856-static u64 guest_read_tsc(void)
29857+static u64 __intentional_overflow(-1) guest_read_tsc(void)
29858 {
29859 u64 host_tsc, tsc_offset;
29860
29861@@ -4459,7 +4467,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
29862 unsigned long cr4;
29863
29864 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
29865+
29866+#ifndef CONFIG_PAX_PER_CPU_PGD
29867 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
29868+#endif
29869
29870 /* Save the most likely value for this task's CR4 in the VMCS. */
29871 cr4 = cr4_read_shadow();
29872@@ -4486,7 +4497,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
29873 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
29874 vmx->host_idt_base = dt.address;
29875
29876- vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
29877+ vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
29878
29879 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
29880 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
29881@@ -6097,11 +6108,17 @@ static __init int hardware_setup(void)
29882 * page upon invalidation. No need to do anything if not
29883 * using the APIC_ACCESS_ADDR VMCS field.
29884 */
29885- if (!flexpriority_enabled)
29886- kvm_x86_ops->set_apic_access_page_addr = NULL;
29887+ if (!flexpriority_enabled) {
29888+ pax_open_kernel();
29889+ *(void **)&kvm_x86_ops->set_apic_access_page_addr = NULL;
29890+ pax_close_kernel();
29891+ }
29892
29893- if (!cpu_has_vmx_tpr_shadow())
29894- kvm_x86_ops->update_cr8_intercept = NULL;
29895+ if (!cpu_has_vmx_tpr_shadow()) {
29896+ pax_open_kernel();
29897+ *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
29898+ pax_close_kernel();
29899+ }
29900
29901 if (enable_ept && !cpu_has_vmx_ept_2m_page())
29902 kvm_disable_largepages();
29903@@ -6112,14 +6129,16 @@ static __init int hardware_setup(void)
29904 if (!cpu_has_vmx_apicv())
29905 enable_apicv = 0;
29906
29907+ pax_open_kernel();
29908 if (enable_apicv)
29909- kvm_x86_ops->update_cr8_intercept = NULL;
29910+ *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
29911 else {
29912- kvm_x86_ops->hwapic_irr_update = NULL;
29913- kvm_x86_ops->hwapic_isr_update = NULL;
29914- kvm_x86_ops->deliver_posted_interrupt = NULL;
29915- kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
29916+ *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
29917+ *(void **)&kvm_x86_ops->hwapic_isr_update = NULL;
29918+ *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
29919+ *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
29920 }
29921+ pax_close_kernel();
29922
29923 vmx_disable_intercept_for_msr(MSR_FS_BASE, false);
29924 vmx_disable_intercept_for_msr(MSR_GS_BASE, false);
29925@@ -6174,10 +6193,12 @@ static __init int hardware_setup(void)
29926 enable_pml = 0;
29927
29928 if (!enable_pml) {
29929- kvm_x86_ops->slot_enable_log_dirty = NULL;
29930- kvm_x86_ops->slot_disable_log_dirty = NULL;
29931- kvm_x86_ops->flush_log_dirty = NULL;
29932- kvm_x86_ops->enable_log_dirty_pt_masked = NULL;
29933+ pax_open_kernel();
29934+ *(void **)&kvm_x86_ops->slot_enable_log_dirty = NULL;
29935+ *(void **)&kvm_x86_ops->slot_disable_log_dirty = NULL;
29936+ *(void **)&kvm_x86_ops->flush_log_dirty = NULL;
29937+ *(void **)&kvm_x86_ops->enable_log_dirty_pt_masked = NULL;
29938+ pax_close_kernel();
29939 }
29940
29941 return alloc_kvm_area();
29942@@ -8380,6 +8401,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
29943 "jmp 2f \n\t"
29944 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
29945 "2: "
29946+
29947+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29948+ "ljmp %[cs],$3f\n\t"
29949+ "3: "
29950+#endif
29951+
29952 /* Save guest registers, load host registers, keep flags */
29953 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
29954 "pop %0 \n\t"
29955@@ -8432,6 +8459,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
29956 #endif
29957 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
29958 [wordsize]"i"(sizeof(ulong))
29959+
29960+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29961+ ,[cs]"i"(__KERNEL_CS)
29962+#endif
29963+
29964 : "cc", "memory"
29965 #ifdef CONFIG_X86_64
29966 , "rax", "rbx", "rdi", "rsi"
29967@@ -8445,7 +8477,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
29968 if (debugctlmsr)
29969 update_debugctlmsr(debugctlmsr);
29970
29971-#ifndef CONFIG_X86_64
29972+#ifdef CONFIG_X86_32
29973 /*
29974 * The sysexit path does not restore ds/es, so we must set them to
29975 * a reasonable value ourselves.
29976@@ -8454,8 +8486,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
29977 * may be executed in interrupt context, which saves and restore segments
29978 * around it, nullifying its effect.
29979 */
29980- loadsegment(ds, __USER_DS);
29981- loadsegment(es, __USER_DS);
29982+ loadsegment(ds, __KERNEL_DS);
29983+ loadsegment(es, __KERNEL_DS);
29984+ loadsegment(ss, __KERNEL_DS);
29985+
29986+#ifdef CONFIG_PAX_KERNEXEC
29987+ loadsegment(fs, __KERNEL_PERCPU);
29988+#endif
29989+
29990+#ifdef CONFIG_PAX_MEMORY_UDEREF
29991+ __set_fs(current_thread_info()->addr_limit);
29992+#endif
29993+
29994 #endif
29995
29996 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
29997diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
29998index 32c6e6a..d6c5bc2 100644
29999--- a/arch/x86/kvm/x86.c
30000+++ b/arch/x86/kvm/x86.c
30001@@ -1842,8 +1842,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
30002 {
30003 struct kvm *kvm = vcpu->kvm;
30004 int lm = is_long_mode(vcpu);
30005- u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
30006- : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
30007+ u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
30008+ : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
30009 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
30010 : kvm->arch.xen_hvm_config.blob_size_32;
30011 u32 page_num = data & ~PAGE_MASK;
30012@@ -2733,6 +2733,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
30013 if (n < msr_list.nmsrs)
30014 goto out;
30015 r = -EFAULT;
30016+ if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
30017+ goto out;
30018 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
30019 num_msrs_to_save * sizeof(u32)))
30020 goto out;
30021@@ -3093,7 +3095,7 @@ static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu,
30022
30023 static void fill_xsave(u8 *dest, struct kvm_vcpu *vcpu)
30024 {
30025- struct xregs_state *xsave = &vcpu->arch.guest_fpu.state.xsave;
30026+ struct xregs_state *xsave = &vcpu->arch.guest_fpu.state->xsave;
30027 u64 xstate_bv = xsave->header.xfeatures;
30028 u64 valid;
30029
30030@@ -3129,7 +3131,7 @@ static void fill_xsave(u8 *dest, struct kvm_vcpu *vcpu)
30031
30032 static void load_xsave(struct kvm_vcpu *vcpu, u8 *src)
30033 {
30034- struct xregs_state *xsave = &vcpu->arch.guest_fpu.state.xsave;
30035+ struct xregs_state *xsave = &vcpu->arch.guest_fpu.state->xsave;
30036 u64 xstate_bv = *(u64 *)(src + XSAVE_HDR_OFFSET);
30037 u64 valid;
30038
30039@@ -3173,7 +3175,7 @@ static void kvm_vcpu_ioctl_x86_get_xsave(struct kvm_vcpu *vcpu,
30040 fill_xsave((u8 *) guest_xsave->region, vcpu);
30041 } else {
30042 memcpy(guest_xsave->region,
30043- &vcpu->arch.guest_fpu.state.fxsave,
30044+ &vcpu->arch.guest_fpu.state->fxsave,
30045 sizeof(struct fxregs_state));
30046 *(u64 *)&guest_xsave->region[XSAVE_HDR_OFFSET / sizeof(u32)] =
30047 XSTATE_FPSSE;
30048@@ -3198,7 +3200,7 @@ static int kvm_vcpu_ioctl_x86_set_xsave(struct kvm_vcpu *vcpu,
30049 } else {
30050 if (xstate_bv & ~XSTATE_FPSSE)
30051 return -EINVAL;
30052- memcpy(&vcpu->arch.guest_fpu.state.fxsave,
30053+ memcpy(&vcpu->arch.guest_fpu.state->fxsave,
30054 guest_xsave->region, sizeof(struct fxregs_state));
30055 }
30056 return 0;
30057@@ -5788,7 +5790,7 @@ static struct notifier_block pvclock_gtod_notifier = {
30058 };
30059 #endif
30060
30061-int kvm_arch_init(void *opaque)
30062+int kvm_arch_init(const void *opaque)
30063 {
30064 int r;
30065 struct kvm_x86_ops *ops = opaque;
30066@@ -7212,7 +7214,7 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
30067 int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
30068 {
30069 struct fxregs_state *fxsave =
30070- &vcpu->arch.guest_fpu.state.fxsave;
30071+ &vcpu->arch.guest_fpu.state->fxsave;
30072
30073 memcpy(fpu->fpr, fxsave->st_space, 128);
30074 fpu->fcw = fxsave->cwd;
30075@@ -7229,7 +7231,7 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
30076 int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
30077 {
30078 struct fxregs_state *fxsave =
30079- &vcpu->arch.guest_fpu.state.fxsave;
30080+ &vcpu->arch.guest_fpu.state->fxsave;
30081
30082 memcpy(fxsave->st_space, fpu->fpr, 128);
30083 fxsave->cwd = fpu->fcw;
30084@@ -7245,9 +7247,9 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
30085
30086 static void fx_init(struct kvm_vcpu *vcpu)
30087 {
30088- fpstate_init(&vcpu->arch.guest_fpu.state);
30089+ fpstate_init(vcpu->arch.guest_fpu.state);
30090 if (cpu_has_xsaves)
30091- vcpu->arch.guest_fpu.state.xsave.header.xcomp_bv =
30092+ vcpu->arch.guest_fpu.state->xsave.header.xcomp_bv =
30093 host_xcr0 | XSTATE_COMPACTION_ENABLED;
30094
30095 /*
30096@@ -7271,7 +7273,7 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
30097 kvm_put_guest_xcr0(vcpu);
30098 vcpu->guest_fpu_loaded = 1;
30099 __kernel_fpu_begin();
30100- __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu.state);
30101+ __copy_kernel_to_fpregs(vcpu->arch.guest_fpu.state);
30102 trace_kvm_fpu(1);
30103 }
30104
30105@@ -7549,6 +7551,8 @@ bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu)
30106
30107 struct static_key kvm_no_apic_vcpu __read_mostly;
30108
30109+extern struct kmem_cache *fpregs_state_cachep;
30110+
30111 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
30112 {
30113 struct page *page;
30114@@ -7565,11 +7569,14 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
30115 else
30116 vcpu->arch.mp_state = KVM_MP_STATE_UNINITIALIZED;
30117
30118- page = alloc_page(GFP_KERNEL | __GFP_ZERO);
30119- if (!page) {
30120- r = -ENOMEM;
30121+ r = -ENOMEM;
30122+ vcpu->arch.guest_fpu.state = kmem_cache_alloc(fpregs_state_cachep, GFP_KERNEL);
30123+ if (!vcpu->arch.guest_fpu.state)
30124 goto fail;
30125- }
30126+
30127+ page = alloc_page(GFP_KERNEL | __GFP_ZERO);
30128+ if (!page)
30129+ goto fail_free_fpregs;
30130 vcpu->arch.pio_data = page_address(page);
30131
30132 kvm_set_tsc_khz(vcpu, max_tsc_khz);
30133@@ -7623,6 +7630,9 @@ fail_mmu_destroy:
30134 kvm_mmu_destroy(vcpu);
30135 fail_free_pio_data:
30136 free_page((unsigned long)vcpu->arch.pio_data);
30137+fail_free_fpregs:
30138+ kmem_cache_free(fpregs_state_cachep, vcpu->arch.guest_fpu.state);
30139+ vcpu->arch.guest_fpu.state = NULL;
30140 fail:
30141 return r;
30142 }
30143@@ -7640,6 +7650,8 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
30144 free_page((unsigned long)vcpu->arch.pio_data);
30145 if (!irqchip_in_kernel(vcpu->kvm))
30146 static_key_slow_dec(&kvm_no_apic_vcpu);
30147+ kmem_cache_free(fpregs_state_cachep, vcpu->arch.guest_fpu.state);
30148+ vcpu->arch.guest_fpu.state = NULL;
30149 }
30150
30151 void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu)
30152diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
30153index f2dc08c..d85d906 100644
30154--- a/arch/x86/lguest/boot.c
30155+++ b/arch/x86/lguest/boot.c
30156@@ -1341,9 +1341,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
30157 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
30158 * Launcher to reboot us.
30159 */
30160-static void lguest_restart(char *reason)
30161+static __noreturn void lguest_restart(char *reason)
30162 {
30163 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
30164+ BUG();
30165 }
30166
30167 /*G:050
30168diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
30169index 9b0ca8f..bb4af41 100644
30170--- a/arch/x86/lib/atomic64_386_32.S
30171+++ b/arch/x86/lib/atomic64_386_32.S
30172@@ -45,6 +45,10 @@ BEGIN(read)
30173 movl (v), %eax
30174 movl 4(v), %edx
30175 RET_ENDP
30176+BEGIN(read_unchecked)
30177+ movl (v), %eax
30178+ movl 4(v), %edx
30179+RET_ENDP
30180 #undef v
30181
30182 #define v %esi
30183@@ -52,6 +56,10 @@ BEGIN(set)
30184 movl %ebx, (v)
30185 movl %ecx, 4(v)
30186 RET_ENDP
30187+BEGIN(set_unchecked)
30188+ movl %ebx, (v)
30189+ movl %ecx, 4(v)
30190+RET_ENDP
30191 #undef v
30192
30193 #define v %esi
30194@@ -67,6 +75,20 @@ RET_ENDP
30195 BEGIN(add)
30196 addl %eax, (v)
30197 adcl %edx, 4(v)
30198+
30199+#ifdef CONFIG_PAX_REFCOUNT
30200+ jno 0f
30201+ subl %eax, (v)
30202+ sbbl %edx, 4(v)
30203+ int $4
30204+0:
30205+ _ASM_EXTABLE(0b, 0b)
30206+#endif
30207+
30208+RET_ENDP
30209+BEGIN(add_unchecked)
30210+ addl %eax, (v)
30211+ adcl %edx, 4(v)
30212 RET_ENDP
30213 #undef v
30214
30215@@ -74,6 +96,24 @@ RET_ENDP
30216 BEGIN(add_return)
30217 addl (v), %eax
30218 adcl 4(v), %edx
30219+
30220+#ifdef CONFIG_PAX_REFCOUNT
30221+ into
30222+1234:
30223+ _ASM_EXTABLE(1234b, 2f)
30224+#endif
30225+
30226+ movl %eax, (v)
30227+ movl %edx, 4(v)
30228+
30229+#ifdef CONFIG_PAX_REFCOUNT
30230+2:
30231+#endif
30232+
30233+RET_ENDP
30234+BEGIN(add_return_unchecked)
30235+ addl (v), %eax
30236+ adcl 4(v), %edx
30237 movl %eax, (v)
30238 movl %edx, 4(v)
30239 RET_ENDP
30240@@ -83,6 +123,20 @@ RET_ENDP
30241 BEGIN(sub)
30242 subl %eax, (v)
30243 sbbl %edx, 4(v)
30244+
30245+#ifdef CONFIG_PAX_REFCOUNT
30246+ jno 0f
30247+ addl %eax, (v)
30248+ adcl %edx, 4(v)
30249+ int $4
30250+0:
30251+ _ASM_EXTABLE(0b, 0b)
30252+#endif
30253+
30254+RET_ENDP
30255+BEGIN(sub_unchecked)
30256+ subl %eax, (v)
30257+ sbbl %edx, 4(v)
30258 RET_ENDP
30259 #undef v
30260
30261@@ -93,6 +147,27 @@ BEGIN(sub_return)
30262 sbbl $0, %edx
30263 addl (v), %eax
30264 adcl 4(v), %edx
30265+
30266+#ifdef CONFIG_PAX_REFCOUNT
30267+ into
30268+1234:
30269+ _ASM_EXTABLE(1234b, 2f)
30270+#endif
30271+
30272+ movl %eax, (v)
30273+ movl %edx, 4(v)
30274+
30275+#ifdef CONFIG_PAX_REFCOUNT
30276+2:
30277+#endif
30278+
30279+RET_ENDP
30280+BEGIN(sub_return_unchecked)
30281+ negl %edx
30282+ negl %eax
30283+ sbbl $0, %edx
30284+ addl (v), %eax
30285+ adcl 4(v), %edx
30286 movl %eax, (v)
30287 movl %edx, 4(v)
30288 RET_ENDP
30289@@ -102,6 +177,20 @@ RET_ENDP
30290 BEGIN(inc)
30291 addl $1, (v)
30292 adcl $0, 4(v)
30293+
30294+#ifdef CONFIG_PAX_REFCOUNT
30295+ jno 0f
30296+ subl $1, (v)
30297+ sbbl $0, 4(v)
30298+ int $4
30299+0:
30300+ _ASM_EXTABLE(0b, 0b)
30301+#endif
30302+
30303+RET_ENDP
30304+BEGIN(inc_unchecked)
30305+ addl $1, (v)
30306+ adcl $0, 4(v)
30307 RET_ENDP
30308 #undef v
30309
30310@@ -111,6 +200,26 @@ BEGIN(inc_return)
30311 movl 4(v), %edx
30312 addl $1, %eax
30313 adcl $0, %edx
30314+
30315+#ifdef CONFIG_PAX_REFCOUNT
30316+ into
30317+1234:
30318+ _ASM_EXTABLE(1234b, 2f)
30319+#endif
30320+
30321+ movl %eax, (v)
30322+ movl %edx, 4(v)
30323+
30324+#ifdef CONFIG_PAX_REFCOUNT
30325+2:
30326+#endif
30327+
30328+RET_ENDP
30329+BEGIN(inc_return_unchecked)
30330+ movl (v), %eax
30331+ movl 4(v), %edx
30332+ addl $1, %eax
30333+ adcl $0, %edx
30334 movl %eax, (v)
30335 movl %edx, 4(v)
30336 RET_ENDP
30337@@ -120,6 +229,20 @@ RET_ENDP
30338 BEGIN(dec)
30339 subl $1, (v)
30340 sbbl $0, 4(v)
30341+
30342+#ifdef CONFIG_PAX_REFCOUNT
30343+ jno 0f
30344+ addl $1, (v)
30345+ adcl $0, 4(v)
30346+ int $4
30347+0:
30348+ _ASM_EXTABLE(0b, 0b)
30349+#endif
30350+
30351+RET_ENDP
30352+BEGIN(dec_unchecked)
30353+ subl $1, (v)
30354+ sbbl $0, 4(v)
30355 RET_ENDP
30356 #undef v
30357
30358@@ -129,6 +252,26 @@ BEGIN(dec_return)
30359 movl 4(v), %edx
30360 subl $1, %eax
30361 sbbl $0, %edx
30362+
30363+#ifdef CONFIG_PAX_REFCOUNT
30364+ into
30365+1234:
30366+ _ASM_EXTABLE(1234b, 2f)
30367+#endif
30368+
30369+ movl %eax, (v)
30370+ movl %edx, 4(v)
30371+
30372+#ifdef CONFIG_PAX_REFCOUNT
30373+2:
30374+#endif
30375+
30376+RET_ENDP
30377+BEGIN(dec_return_unchecked)
30378+ movl (v), %eax
30379+ movl 4(v), %edx
30380+ subl $1, %eax
30381+ sbbl $0, %edx
30382 movl %eax, (v)
30383 movl %edx, 4(v)
30384 RET_ENDP
30385@@ -140,6 +283,13 @@ BEGIN(add_unless)
30386 adcl %edx, %edi
30387 addl (v), %eax
30388 adcl 4(v), %edx
30389+
30390+#ifdef CONFIG_PAX_REFCOUNT
30391+ into
30392+1234:
30393+ _ASM_EXTABLE(1234b, 2f)
30394+#endif
30395+
30396 cmpl %eax, %ecx
30397 je 3f
30398 1:
30399@@ -165,6 +315,13 @@ BEGIN(inc_not_zero)
30400 1:
30401 addl $1, %eax
30402 adcl $0, %edx
30403+
30404+#ifdef CONFIG_PAX_REFCOUNT
30405+ into
30406+1234:
30407+ _ASM_EXTABLE(1234b, 2f)
30408+#endif
30409+
30410 movl %eax, (v)
30411 movl %edx, 4(v)
30412 movl $1, %eax
30413@@ -183,6 +340,13 @@ BEGIN(dec_if_positive)
30414 movl 4(v), %edx
30415 subl $1, %eax
30416 sbbl $0, %edx
30417+
30418+#ifdef CONFIG_PAX_REFCOUNT
30419+ into
30420+1234:
30421+ _ASM_EXTABLE(1234b, 1f)
30422+#endif
30423+
30424 js 1f
30425 movl %eax, (v)
30426 movl %edx, 4(v)
30427diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
30428index db3ae854..b8ad0de 100644
30429--- a/arch/x86/lib/atomic64_cx8_32.S
30430+++ b/arch/x86/lib/atomic64_cx8_32.S
30431@@ -22,9 +22,16 @@
30432
30433 ENTRY(atomic64_read_cx8)
30434 read64 %ecx
30435+ pax_force_retaddr
30436 ret
30437 ENDPROC(atomic64_read_cx8)
30438
30439+ENTRY(atomic64_read_unchecked_cx8)
30440+ read64 %ecx
30441+ pax_force_retaddr
30442+ ret
30443+ENDPROC(atomic64_read_unchecked_cx8)
30444+
30445 ENTRY(atomic64_set_cx8)
30446 1:
30447 /* we don't need LOCK_PREFIX since aligned 64-bit writes
30448@@ -32,20 +39,33 @@ ENTRY(atomic64_set_cx8)
30449 cmpxchg8b (%esi)
30450 jne 1b
30451
30452+ pax_force_retaddr
30453 ret
30454 ENDPROC(atomic64_set_cx8)
30455
30456+ENTRY(atomic64_set_unchecked_cx8)
30457+1:
30458+/* we don't need LOCK_PREFIX since aligned 64-bit writes
30459+ * are atomic on 586 and newer */
30460+ cmpxchg8b (%esi)
30461+ jne 1b
30462+
30463+ pax_force_retaddr
30464+ ret
30465+ENDPROC(atomic64_set_unchecked_cx8)
30466+
30467 ENTRY(atomic64_xchg_cx8)
30468 1:
30469 LOCK_PREFIX
30470 cmpxchg8b (%esi)
30471 jne 1b
30472
30473+ pax_force_retaddr
30474 ret
30475 ENDPROC(atomic64_xchg_cx8)
30476
30477-.macro addsub_return func ins insc
30478-ENTRY(atomic64_\func\()_return_cx8)
30479+.macro addsub_return func ins insc unchecked=""
30480+ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
30481 pushl %ebp
30482 pushl %ebx
30483 pushl %esi
30484@@ -61,26 +81,43 @@ ENTRY(atomic64_\func\()_return_cx8)
30485 movl %edx, %ecx
30486 \ins\()l %esi, %ebx
30487 \insc\()l %edi, %ecx
30488+
30489+.ifb \unchecked
30490+#ifdef CONFIG_PAX_REFCOUNT
30491+ into
30492+2:
30493+ _ASM_EXTABLE(2b, 3f)
30494+#endif
30495+.endif
30496+
30497 LOCK_PREFIX
30498 cmpxchg8b (%ebp)
30499 jne 1b
30500-
30501-10:
30502 movl %ebx, %eax
30503 movl %ecx, %edx
30504+
30505+.ifb \unchecked
30506+#ifdef CONFIG_PAX_REFCOUNT
30507+3:
30508+#endif
30509+.endif
30510+
30511 popl %edi
30512 popl %esi
30513 popl %ebx
30514 popl %ebp
30515+ pax_force_retaddr
30516 ret
30517-ENDPROC(atomic64_\func\()_return_cx8)
30518+ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
30519 .endm
30520
30521 addsub_return add add adc
30522 addsub_return sub sub sbb
30523+addsub_return add add adc _unchecked
30524+addsub_return sub sub sbb _unchecked
30525
30526-.macro incdec_return func ins insc
30527-ENTRY(atomic64_\func\()_return_cx8)
30528+.macro incdec_return func ins insc unchecked=""
30529+ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
30530 pushl %ebx
30531
30532 read64 %esi
30533@@ -89,20 +126,37 @@ ENTRY(atomic64_\func\()_return_cx8)
30534 movl %edx, %ecx
30535 \ins\()l $1, %ebx
30536 \insc\()l $0, %ecx
30537+
30538+.ifb \unchecked
30539+#ifdef CONFIG_PAX_REFCOUNT
30540+ into
30541+2:
30542+ _ASM_EXTABLE(2b, 3f)
30543+#endif
30544+.endif
30545+
30546 LOCK_PREFIX
30547 cmpxchg8b (%esi)
30548 jne 1b
30549-
30550-10:
30551 movl %ebx, %eax
30552 movl %ecx, %edx
30553+
30554+.ifb \unchecked
30555+#ifdef CONFIG_PAX_REFCOUNT
30556+3:
30557+#endif
30558+.endif
30559+
30560 popl %ebx
30561+ pax_force_retaddr
30562 ret
30563-ENDPROC(atomic64_\func\()_return_cx8)
30564+ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
30565 .endm
30566
30567 incdec_return inc add adc
30568 incdec_return dec sub sbb
30569+incdec_return inc add adc _unchecked
30570+incdec_return dec sub sbb _unchecked
30571
30572 ENTRY(atomic64_dec_if_positive_cx8)
30573 pushl %ebx
30574@@ -113,6 +167,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
30575 movl %edx, %ecx
30576 subl $1, %ebx
30577 sbb $0, %ecx
30578+
30579+#ifdef CONFIG_PAX_REFCOUNT
30580+ into
30581+1234:
30582+ _ASM_EXTABLE(1234b, 2f)
30583+#endif
30584+
30585 js 2f
30586 LOCK_PREFIX
30587 cmpxchg8b (%esi)
30588@@ -122,6 +183,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
30589 movl %ebx, %eax
30590 movl %ecx, %edx
30591 popl %ebx
30592+ pax_force_retaddr
30593 ret
30594 ENDPROC(atomic64_dec_if_positive_cx8)
30595
30596@@ -144,6 +206,13 @@ ENTRY(atomic64_add_unless_cx8)
30597 movl %edx, %ecx
30598 addl %ebp, %ebx
30599 adcl %edi, %ecx
30600+
30601+#ifdef CONFIG_PAX_REFCOUNT
30602+ into
30603+1234:
30604+ _ASM_EXTABLE(1234b, 3f)
30605+#endif
30606+
30607 LOCK_PREFIX
30608 cmpxchg8b (%esi)
30609 jne 1b
30610@@ -153,6 +222,7 @@ ENTRY(atomic64_add_unless_cx8)
30611 addl $8, %esp
30612 popl %ebx
30613 popl %ebp
30614+ pax_force_retaddr
30615 ret
30616 4:
30617 cmpl %edx, 4(%esp)
30618@@ -173,6 +243,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
30619 xorl %ecx, %ecx
30620 addl $1, %ebx
30621 adcl %edx, %ecx
30622+
30623+#ifdef CONFIG_PAX_REFCOUNT
30624+ into
30625+1234:
30626+ _ASM_EXTABLE(1234b, 3f)
30627+#endif
30628+
30629 LOCK_PREFIX
30630 cmpxchg8b (%esi)
30631 jne 1b
30632@@ -180,5 +257,6 @@ ENTRY(atomic64_inc_not_zero_cx8)
30633 movl $1, %eax
30634 3:
30635 popl %ebx
30636+ pax_force_retaddr
30637 ret
30638 ENDPROC(atomic64_inc_not_zero_cx8)
30639diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
30640index c1e6232..ebbeba7 100644
30641--- a/arch/x86/lib/checksum_32.S
30642+++ b/arch/x86/lib/checksum_32.S
30643@@ -28,7 +28,8 @@
30644 #include <linux/linkage.h>
30645 #include <asm/errno.h>
30646 #include <asm/asm.h>
30647-
30648+#include <asm/segment.h>
30649+
30650 /*
30651 * computes a partial checksum, e.g. for TCP/UDP fragments
30652 */
30653@@ -280,7 +281,22 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
30654
30655 #define ARGBASE 16
30656 #define FP 12
30657-
30658+
30659+ENTRY(csum_partial_copy_generic_to_user)
30660+
30661+#ifdef CONFIG_PAX_MEMORY_UDEREF
30662+ pushl %gs
30663+ popl %es
30664+ jmp csum_partial_copy_generic
30665+#endif
30666+
30667+ENTRY(csum_partial_copy_generic_from_user)
30668+
30669+#ifdef CONFIG_PAX_MEMORY_UDEREF
30670+ pushl %gs
30671+ popl %ds
30672+#endif
30673+
30674 ENTRY(csum_partial_copy_generic)
30675 subl $4,%esp
30676 pushl %edi
30677@@ -299,7 +315,7 @@ ENTRY(csum_partial_copy_generic)
30678 jmp 4f
30679 SRC(1: movw (%esi), %bx )
30680 addl $2, %esi
30681-DST( movw %bx, (%edi) )
30682+DST( movw %bx, %es:(%edi) )
30683 addl $2, %edi
30684 addw %bx, %ax
30685 adcl $0, %eax
30686@@ -311,30 +327,30 @@ DST( movw %bx, (%edi) )
30687 SRC(1: movl (%esi), %ebx )
30688 SRC( movl 4(%esi), %edx )
30689 adcl %ebx, %eax
30690-DST( movl %ebx, (%edi) )
30691+DST( movl %ebx, %es:(%edi) )
30692 adcl %edx, %eax
30693-DST( movl %edx, 4(%edi) )
30694+DST( movl %edx, %es:4(%edi) )
30695
30696 SRC( movl 8(%esi), %ebx )
30697 SRC( movl 12(%esi), %edx )
30698 adcl %ebx, %eax
30699-DST( movl %ebx, 8(%edi) )
30700+DST( movl %ebx, %es:8(%edi) )
30701 adcl %edx, %eax
30702-DST( movl %edx, 12(%edi) )
30703+DST( movl %edx, %es:12(%edi) )
30704
30705 SRC( movl 16(%esi), %ebx )
30706 SRC( movl 20(%esi), %edx )
30707 adcl %ebx, %eax
30708-DST( movl %ebx, 16(%edi) )
30709+DST( movl %ebx, %es:16(%edi) )
30710 adcl %edx, %eax
30711-DST( movl %edx, 20(%edi) )
30712+DST( movl %edx, %es:20(%edi) )
30713
30714 SRC( movl 24(%esi), %ebx )
30715 SRC( movl 28(%esi), %edx )
30716 adcl %ebx, %eax
30717-DST( movl %ebx, 24(%edi) )
30718+DST( movl %ebx, %es:24(%edi) )
30719 adcl %edx, %eax
30720-DST( movl %edx, 28(%edi) )
30721+DST( movl %edx, %es:28(%edi) )
30722
30723 lea 32(%esi), %esi
30724 lea 32(%edi), %edi
30725@@ -348,7 +364,7 @@ DST( movl %edx, 28(%edi) )
30726 shrl $2, %edx # This clears CF
30727 SRC(3: movl (%esi), %ebx )
30728 adcl %ebx, %eax
30729-DST( movl %ebx, (%edi) )
30730+DST( movl %ebx, %es:(%edi) )
30731 lea 4(%esi), %esi
30732 lea 4(%edi), %edi
30733 dec %edx
30734@@ -360,12 +376,12 @@ DST( movl %ebx, (%edi) )
30735 jb 5f
30736 SRC( movw (%esi), %cx )
30737 leal 2(%esi), %esi
30738-DST( movw %cx, (%edi) )
30739+DST( movw %cx, %es:(%edi) )
30740 leal 2(%edi), %edi
30741 je 6f
30742 shll $16,%ecx
30743 SRC(5: movb (%esi), %cl )
30744-DST( movb %cl, (%edi) )
30745+DST( movb %cl, %es:(%edi) )
30746 6: addl %ecx, %eax
30747 adcl $0, %eax
30748 7:
30749@@ -376,7 +392,7 @@ DST( movb %cl, (%edi) )
30750
30751 6001:
30752 movl ARGBASE+20(%esp), %ebx # src_err_ptr
30753- movl $-EFAULT, (%ebx)
30754+ movl $-EFAULT, %ss:(%ebx)
30755
30756 # zero the complete destination - computing the rest
30757 # is too much work
30758@@ -389,34 +405,58 @@ DST( movb %cl, (%edi) )
30759
30760 6002:
30761 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
30762- movl $-EFAULT,(%ebx)
30763+ movl $-EFAULT,%ss:(%ebx)
30764 jmp 5000b
30765
30766 .previous
30767
30768+#ifdef CONFIG_PAX_MEMORY_UDEREF
30769+ pushl %ss
30770+ popl %ds
30771+ pushl %ss
30772+ popl %es
30773+#endif
30774+
30775 popl %ebx
30776 popl %esi
30777 popl %edi
30778 popl %ecx # equivalent to addl $4,%esp
30779 ret
30780-ENDPROC(csum_partial_copy_generic)
30781+ENDPROC(csum_partial_copy_generic_to_user)
30782
30783 #else
30784
30785 /* Version for PentiumII/PPro */
30786
30787 #define ROUND1(x) \
30788+ nop; nop; nop; \
30789 SRC(movl x(%esi), %ebx ) ; \
30790 addl %ebx, %eax ; \
30791- DST(movl %ebx, x(%edi) ) ;
30792+ DST(movl %ebx, %es:x(%edi)) ;
30793
30794 #define ROUND(x) \
30795+ nop; nop; nop; \
30796 SRC(movl x(%esi), %ebx ) ; \
30797 adcl %ebx, %eax ; \
30798- DST(movl %ebx, x(%edi) ) ;
30799+ DST(movl %ebx, %es:x(%edi)) ;
30800
30801 #define ARGBASE 12
30802-
30803+
30804+ENTRY(csum_partial_copy_generic_to_user)
30805+
30806+#ifdef CONFIG_PAX_MEMORY_UDEREF
30807+ pushl %gs
30808+ popl %es
30809+ jmp csum_partial_copy_generic
30810+#endif
30811+
30812+ENTRY(csum_partial_copy_generic_from_user)
30813+
30814+#ifdef CONFIG_PAX_MEMORY_UDEREF
30815+ pushl %gs
30816+ popl %ds
30817+#endif
30818+
30819 ENTRY(csum_partial_copy_generic)
30820 pushl %ebx
30821 pushl %edi
30822@@ -435,7 +475,7 @@ ENTRY(csum_partial_copy_generic)
30823 subl %ebx, %edi
30824 lea -1(%esi),%edx
30825 andl $-32,%edx
30826- lea 3f(%ebx,%ebx), %ebx
30827+ lea 3f(%ebx,%ebx,2), %ebx
30828 testl %esi, %esi
30829 jmp *%ebx
30830 1: addl $64,%esi
30831@@ -456,19 +496,19 @@ ENTRY(csum_partial_copy_generic)
30832 jb 5f
30833 SRC( movw (%esi), %dx )
30834 leal 2(%esi), %esi
30835-DST( movw %dx, (%edi) )
30836+DST( movw %dx, %es:(%edi) )
30837 leal 2(%edi), %edi
30838 je 6f
30839 shll $16,%edx
30840 5:
30841 SRC( movb (%esi), %dl )
30842-DST( movb %dl, (%edi) )
30843+DST( movb %dl, %es:(%edi) )
30844 6: addl %edx, %eax
30845 adcl $0, %eax
30846 7:
30847 .section .fixup, "ax"
30848 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
30849- movl $-EFAULT, (%ebx)
30850+ movl $-EFAULT, %ss:(%ebx)
30851 # zero the complete destination (computing the rest is too much work)
30852 movl ARGBASE+8(%esp),%edi # dst
30853 movl ARGBASE+12(%esp),%ecx # len
30854@@ -476,15 +516,22 @@ DST( movb %dl, (%edi) )
30855 rep; stosb
30856 jmp 7b
30857 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
30858- movl $-EFAULT, (%ebx)
30859+ movl $-EFAULT, %ss:(%ebx)
30860 jmp 7b
30861 .previous
30862
30863+#ifdef CONFIG_PAX_MEMORY_UDEREF
30864+ pushl %ss
30865+ popl %ds
30866+ pushl %ss
30867+ popl %es
30868+#endif
30869+
30870 popl %esi
30871 popl %edi
30872 popl %ebx
30873 ret
30874-ENDPROC(csum_partial_copy_generic)
30875+ENDPROC(csum_partial_copy_generic_to_user)
30876
30877 #undef ROUND
30878 #undef ROUND1
30879diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
30880index a2fe51b..507dab0 100644
30881--- a/arch/x86/lib/clear_page_64.S
30882+++ b/arch/x86/lib/clear_page_64.S
30883@@ -21,6 +21,7 @@ ENTRY(clear_page)
30884 movl $4096/8,%ecx
30885 xorl %eax,%eax
30886 rep stosq
30887+ pax_force_retaddr
30888 ret
30889 ENDPROC(clear_page)
30890
30891@@ -43,6 +44,7 @@ ENTRY(clear_page_orig)
30892 leaq 64(%rdi),%rdi
30893 jnz .Lloop
30894 nop
30895+ pax_force_retaddr
30896 ret
30897 ENDPROC(clear_page_orig)
30898
30899@@ -50,5 +52,6 @@ ENTRY(clear_page_c_e)
30900 movl $4096,%ecx
30901 xorl %eax,%eax
30902 rep stosb
30903+ pax_force_retaddr
30904 ret
30905 ENDPROC(clear_page_c_e)
30906diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
30907index 9b33024..e52ee44 100644
30908--- a/arch/x86/lib/cmpxchg16b_emu.S
30909+++ b/arch/x86/lib/cmpxchg16b_emu.S
30910@@ -7,6 +7,7 @@
30911 */
30912 #include <linux/linkage.h>
30913 #include <asm/percpu.h>
30914+#include <asm/alternative-asm.h>
30915
30916 .text
30917
30918@@ -43,11 +44,13 @@ ENTRY(this_cpu_cmpxchg16b_emu)
30919
30920 popfq
30921 mov $1, %al
30922+ pax_force_retaddr
30923 ret
30924
30925 .Lnot_same:
30926 popfq
30927 xor %al,%al
30928+ pax_force_retaddr
30929 ret
30930
30931 ENDPROC(this_cpu_cmpxchg16b_emu)
30932diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
30933index 009f982..9b3db5e 100644
30934--- a/arch/x86/lib/copy_page_64.S
30935+++ b/arch/x86/lib/copy_page_64.S
30936@@ -15,13 +15,14 @@ ENTRY(copy_page)
30937 ALTERNATIVE "jmp copy_page_regs", "", X86_FEATURE_REP_GOOD
30938 movl $4096/8, %ecx
30939 rep movsq
30940+ pax_force_retaddr
30941 ret
30942 ENDPROC(copy_page)
30943
30944 ENTRY(copy_page_regs)
30945 subq $2*8, %rsp
30946 movq %rbx, (%rsp)
30947- movq %r12, 1*8(%rsp)
30948+ movq %r13, 1*8(%rsp)
30949
30950 movl $(4096/64)-5, %ecx
30951 .p2align 4
30952@@ -34,7 +35,7 @@ ENTRY(copy_page_regs)
30953 movq 0x8*4(%rsi), %r9
30954 movq 0x8*5(%rsi), %r10
30955 movq 0x8*6(%rsi), %r11
30956- movq 0x8*7(%rsi), %r12
30957+ movq 0x8*7(%rsi), %r13
30958
30959 prefetcht0 5*64(%rsi)
30960
30961@@ -45,7 +46,7 @@ ENTRY(copy_page_regs)
30962 movq %r9, 0x8*4(%rdi)
30963 movq %r10, 0x8*5(%rdi)
30964 movq %r11, 0x8*6(%rdi)
30965- movq %r12, 0x8*7(%rdi)
30966+ movq %r13, 0x8*7(%rdi)
30967
30968 leaq 64 (%rsi), %rsi
30969 leaq 64 (%rdi), %rdi
30970@@ -64,7 +65,7 @@ ENTRY(copy_page_regs)
30971 movq 0x8*4(%rsi), %r9
30972 movq 0x8*5(%rsi), %r10
30973 movq 0x8*6(%rsi), %r11
30974- movq 0x8*7(%rsi), %r12
30975+ movq 0x8*7(%rsi), %r13
30976
30977 movq %rax, 0x8*0(%rdi)
30978 movq %rbx, 0x8*1(%rdi)
30979@@ -73,14 +74,15 @@ ENTRY(copy_page_regs)
30980 movq %r9, 0x8*4(%rdi)
30981 movq %r10, 0x8*5(%rdi)
30982 movq %r11, 0x8*6(%rdi)
30983- movq %r12, 0x8*7(%rdi)
30984+ movq %r13, 0x8*7(%rdi)
30985
30986 leaq 64(%rdi), %rdi
30987 leaq 64(%rsi), %rsi
30988 jnz .Loop2
30989
30990 movq (%rsp), %rbx
30991- movq 1*8(%rsp), %r12
30992+ movq 1*8(%rsp), %r13
30993 addq $2*8, %rsp
30994+ pax_force_retaddr
30995 ret
30996 ENDPROC(copy_page_regs)
30997diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
30998index 982ce34..8e14731 100644
30999--- a/arch/x86/lib/copy_user_64.S
31000+++ b/arch/x86/lib/copy_user_64.S
31001@@ -14,50 +14,7 @@
31002 #include <asm/alternative-asm.h>
31003 #include <asm/asm.h>
31004 #include <asm/smap.h>
31005-
31006-/* Standard copy_to_user with segment limit checking */
31007-ENTRY(_copy_to_user)
31008- GET_THREAD_INFO(%rax)
31009- movq %rdi,%rcx
31010- addq %rdx,%rcx
31011- jc bad_to_user
31012- cmpq TI_addr_limit(%rax),%rcx
31013- ja bad_to_user
31014- ALTERNATIVE_2 "jmp copy_user_generic_unrolled", \
31015- "jmp copy_user_generic_string", \
31016- X86_FEATURE_REP_GOOD, \
31017- "jmp copy_user_enhanced_fast_string", \
31018- X86_FEATURE_ERMS
31019-ENDPROC(_copy_to_user)
31020-
31021-/* Standard copy_from_user with segment limit checking */
31022-ENTRY(_copy_from_user)
31023- GET_THREAD_INFO(%rax)
31024- movq %rsi,%rcx
31025- addq %rdx,%rcx
31026- jc bad_from_user
31027- cmpq TI_addr_limit(%rax),%rcx
31028- ja bad_from_user
31029- ALTERNATIVE_2 "jmp copy_user_generic_unrolled", \
31030- "jmp copy_user_generic_string", \
31031- X86_FEATURE_REP_GOOD, \
31032- "jmp copy_user_enhanced_fast_string", \
31033- X86_FEATURE_ERMS
31034-ENDPROC(_copy_from_user)
31035-
31036- .section .fixup,"ax"
31037- /* must zero dest */
31038-ENTRY(bad_from_user)
31039-bad_from_user:
31040- movl %edx,%ecx
31041- xorl %eax,%eax
31042- rep
31043- stosb
31044-bad_to_user:
31045- movl %edx,%eax
31046- ret
31047-ENDPROC(bad_from_user)
31048- .previous
31049+#include <asm/pgtable.h>
31050
31051 /*
31052 * copy_user_generic_unrolled - memory copy with exception handling.
31053@@ -73,6 +30,7 @@ ENDPROC(bad_from_user)
31054 * eax uncopied bytes or 0 if successful.
31055 */
31056 ENTRY(copy_user_generic_unrolled)
31057+ ASM_PAX_OPEN_USERLAND
31058 ASM_STAC
31059 cmpl $8,%edx
31060 jb 20f /* less then 8 bytes, go to byte copy loop */
31061@@ -122,6 +80,8 @@ ENTRY(copy_user_generic_unrolled)
31062 jnz 21b
31063 23: xor %eax,%eax
31064 ASM_CLAC
31065+ ASM_PAX_CLOSE_USERLAND
31066+ pax_force_retaddr
31067 ret
31068
31069 .section .fixup,"ax"
31070@@ -175,6 +135,7 @@ ENDPROC(copy_user_generic_unrolled)
31071 * eax uncopied bytes or 0 if successful.
31072 */
31073 ENTRY(copy_user_generic_string)
31074+ ASM_PAX_OPEN_USERLAND
31075 ASM_STAC
31076 cmpl $8,%edx
31077 jb 2f /* less than 8 bytes, go to byte copy loop */
31078@@ -189,6 +150,8 @@ ENTRY(copy_user_generic_string)
31079 movsb
31080 xorl %eax,%eax
31081 ASM_CLAC
31082+ ASM_PAX_CLOSE_USERLAND
31083+ pax_force_retaddr
31084 ret
31085
31086 .section .fixup,"ax"
31087@@ -214,12 +177,15 @@ ENDPROC(copy_user_generic_string)
31088 * eax uncopied bytes or 0 if successful.
31089 */
31090 ENTRY(copy_user_enhanced_fast_string)
31091+ ASM_PAX_OPEN_USERLAND
31092 ASM_STAC
31093 movl %edx,%ecx
31094 1: rep
31095 movsb
31096 xorl %eax,%eax
31097 ASM_CLAC
31098+ ASM_PAX_CLOSE_USERLAND
31099+ pax_force_retaddr
31100 ret
31101
31102 .section .fixup,"ax"
31103@@ -235,6 +201,16 @@ ENDPROC(copy_user_enhanced_fast_string)
31104 * This will force destination/source out of cache for more performance.
31105 */
31106 ENTRY(__copy_user_nocache)
31107+
31108+#ifdef CONFIG_PAX_MEMORY_UDEREF
31109+ mov pax_user_shadow_base,%rcx
31110+ cmp %rcx,%rsi
31111+ jae 1f
31112+ add %rcx,%rsi
31113+1:
31114+#endif
31115+
31116+ ASM_PAX_OPEN_USERLAND
31117 ASM_STAC
31118 cmpl $8,%edx
31119 jb 20f /* less then 8 bytes, go to byte copy loop */
31120@@ -284,7 +260,9 @@ ENTRY(__copy_user_nocache)
31121 jnz 21b
31122 23: xorl %eax,%eax
31123 ASM_CLAC
31124+ ASM_PAX_CLOSE_USERLAND
31125 sfence
31126+ pax_force_retaddr
31127 ret
31128
31129 .section .fixup,"ax"
31130diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
31131index 7e48807..cc966ff 100644
31132--- a/arch/x86/lib/csum-copy_64.S
31133+++ b/arch/x86/lib/csum-copy_64.S
31134@@ -8,6 +8,7 @@
31135 #include <linux/linkage.h>
31136 #include <asm/errno.h>
31137 #include <asm/asm.h>
31138+#include <asm/alternative-asm.h>
31139
31140 /*
31141 * Checksum copy with exception handling.
31142@@ -52,7 +53,7 @@ ENTRY(csum_partial_copy_generic)
31143 .Lignore:
31144 subq $7*8, %rsp
31145 movq %rbx, 2*8(%rsp)
31146- movq %r12, 3*8(%rsp)
31147+ movq %r15, 3*8(%rsp)
31148 movq %r14, 4*8(%rsp)
31149 movq %r13, 5*8(%rsp)
31150 movq %rbp, 6*8(%rsp)
31151@@ -64,16 +65,16 @@ ENTRY(csum_partial_copy_generic)
31152 movl %edx, %ecx
31153
31154 xorl %r9d, %r9d
31155- movq %rcx, %r12
31156+ movq %rcx, %r15
31157
31158- shrq $6, %r12
31159+ shrq $6, %r15
31160 jz .Lhandle_tail /* < 64 */
31161
31162 clc
31163
31164 /* main loop. clear in 64 byte blocks */
31165 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
31166- /* r11: temp3, rdx: temp4, r12 loopcnt */
31167+ /* r11: temp3, rdx: temp4, r15 loopcnt */
31168 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
31169 .p2align 4
31170 .Lloop:
31171@@ -107,7 +108,7 @@ ENTRY(csum_partial_copy_generic)
31172 adcq %r14, %rax
31173 adcq %r13, %rax
31174
31175- decl %r12d
31176+ decl %r15d
31177
31178 dest
31179 movq %rbx, (%rsi)
31180@@ -200,11 +201,12 @@ ENTRY(csum_partial_copy_generic)
31181
31182 .Lende:
31183 movq 2*8(%rsp), %rbx
31184- movq 3*8(%rsp), %r12
31185+ movq 3*8(%rsp), %r15
31186 movq 4*8(%rsp), %r14
31187 movq 5*8(%rsp), %r13
31188 movq 6*8(%rsp), %rbp
31189 addq $7*8, %rsp
31190+ pax_force_retaddr
31191 ret
31192
31193 /* Exception handlers. Very simple, zeroing is done in the wrappers */
31194diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
31195index 1318f75..44c30fd 100644
31196--- a/arch/x86/lib/csum-wrappers_64.c
31197+++ b/arch/x86/lib/csum-wrappers_64.c
31198@@ -52,10 +52,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
31199 len -= 2;
31200 }
31201 }
31202+ pax_open_userland();
31203 stac();
31204- isum = csum_partial_copy_generic((__force const void *)src,
31205+ isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
31206 dst, len, isum, errp, NULL);
31207 clac();
31208+ pax_close_userland();
31209 if (unlikely(*errp))
31210 goto out_err;
31211
31212@@ -109,10 +111,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
31213 }
31214
31215 *errp = 0;
31216+ pax_open_userland();
31217 stac();
31218- ret = csum_partial_copy_generic(src, (void __force *)dst,
31219+ ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
31220 len, isum, NULL, errp);
31221 clac();
31222+ pax_close_userland();
31223 return ret;
31224 }
31225 EXPORT_SYMBOL(csum_partial_copy_to_user);
31226diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
31227index 46668cd..a3bdfb9 100644
31228--- a/arch/x86/lib/getuser.S
31229+++ b/arch/x86/lib/getuser.S
31230@@ -32,42 +32,93 @@
31231 #include <asm/thread_info.h>
31232 #include <asm/asm.h>
31233 #include <asm/smap.h>
31234+#include <asm/segment.h>
31235+#include <asm/pgtable.h>
31236+#include <asm/alternative-asm.h>
31237+
31238+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
31239+#define __copyuser_seg gs;
31240+#else
31241+#define __copyuser_seg
31242+#endif
31243
31244 .text
31245 ENTRY(__get_user_1)
31246+
31247+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31248 GET_THREAD_INFO(%_ASM_DX)
31249 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31250 jae bad_get_user
31251+
31252+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31253+ mov pax_user_shadow_base,%_ASM_DX
31254+ cmp %_ASM_DX,%_ASM_AX
31255+ jae 1234f
31256+ add %_ASM_DX,%_ASM_AX
31257+1234:
31258+#endif
31259+
31260+#endif
31261+
31262 ASM_STAC
31263-1: movzbl (%_ASM_AX),%edx
31264+1: __copyuser_seg movzbl (%_ASM_AX),%edx
31265 xor %eax,%eax
31266 ASM_CLAC
31267+ pax_force_retaddr
31268 ret
31269 ENDPROC(__get_user_1)
31270
31271 ENTRY(__get_user_2)
31272 add $1,%_ASM_AX
31273+
31274+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31275 jc bad_get_user
31276 GET_THREAD_INFO(%_ASM_DX)
31277 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31278 jae bad_get_user
31279+
31280+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31281+ mov pax_user_shadow_base,%_ASM_DX
31282+ cmp %_ASM_DX,%_ASM_AX
31283+ jae 1234f
31284+ add %_ASM_DX,%_ASM_AX
31285+1234:
31286+#endif
31287+
31288+#endif
31289+
31290 ASM_STAC
31291-2: movzwl -1(%_ASM_AX),%edx
31292+2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
31293 xor %eax,%eax
31294 ASM_CLAC
31295+ pax_force_retaddr
31296 ret
31297 ENDPROC(__get_user_2)
31298
31299 ENTRY(__get_user_4)
31300 add $3,%_ASM_AX
31301+
31302+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31303 jc bad_get_user
31304 GET_THREAD_INFO(%_ASM_DX)
31305 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31306 jae bad_get_user
31307+
31308+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31309+ mov pax_user_shadow_base,%_ASM_DX
31310+ cmp %_ASM_DX,%_ASM_AX
31311+ jae 1234f
31312+ add %_ASM_DX,%_ASM_AX
31313+1234:
31314+#endif
31315+
31316+#endif
31317+
31318 ASM_STAC
31319-3: movl -3(%_ASM_AX),%edx
31320+3: __copyuser_seg movl -3(%_ASM_AX),%edx
31321 xor %eax,%eax
31322 ASM_CLAC
31323+ pax_force_retaddr
31324 ret
31325 ENDPROC(__get_user_4)
31326
31327@@ -78,10 +129,20 @@ ENTRY(__get_user_8)
31328 GET_THREAD_INFO(%_ASM_DX)
31329 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31330 jae bad_get_user
31331+
31332+#ifdef CONFIG_PAX_MEMORY_UDEREF
31333+ mov pax_user_shadow_base,%_ASM_DX
31334+ cmp %_ASM_DX,%_ASM_AX
31335+ jae 1234f
31336+ add %_ASM_DX,%_ASM_AX
31337+1234:
31338+#endif
31339+
31340 ASM_STAC
31341 4: movq -7(%_ASM_AX),%rdx
31342 xor %eax,%eax
31343 ASM_CLAC
31344+ pax_force_retaddr
31345 ret
31346 #else
31347 add $7,%_ASM_AX
31348@@ -90,10 +151,11 @@ ENTRY(__get_user_8)
31349 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31350 jae bad_get_user_8
31351 ASM_STAC
31352-4: movl -7(%_ASM_AX),%edx
31353-5: movl -3(%_ASM_AX),%ecx
31354+4: __copyuser_seg movl -7(%_ASM_AX),%edx
31355+5: __copyuser_seg movl -3(%_ASM_AX),%ecx
31356 xor %eax,%eax
31357 ASM_CLAC
31358+ pax_force_retaddr
31359 ret
31360 #endif
31361 ENDPROC(__get_user_8)
31362@@ -103,6 +165,7 @@ bad_get_user:
31363 xor %edx,%edx
31364 mov $(-EFAULT),%_ASM_AX
31365 ASM_CLAC
31366+ pax_force_retaddr
31367 ret
31368 END(bad_get_user)
31369
31370@@ -112,6 +175,7 @@ bad_get_user_8:
31371 xor %ecx,%ecx
31372 mov $(-EFAULT),%_ASM_AX
31373 ASM_CLAC
31374+ pax_force_retaddr
31375 ret
31376 END(bad_get_user_8)
31377 #endif
31378diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
31379index 8f72b33..4667a46 100644
31380--- a/arch/x86/lib/insn.c
31381+++ b/arch/x86/lib/insn.c
31382@@ -20,8 +20,10 @@
31383
31384 #ifdef __KERNEL__
31385 #include <linux/string.h>
31386+#include <asm/pgtable_types.h>
31387 #else
31388 #include <string.h>
31389+#define ktla_ktva(addr) addr
31390 #endif
31391 #include <asm/inat.h>
31392 #include <asm/insn.h>
31393@@ -60,9 +62,9 @@ void insn_init(struct insn *insn, const void *kaddr, int buf_len, int x86_64)
31394 buf_len = MAX_INSN_SIZE;
31395
31396 memset(insn, 0, sizeof(*insn));
31397- insn->kaddr = kaddr;
31398- insn->end_kaddr = kaddr + buf_len;
31399- insn->next_byte = kaddr;
31400+ insn->kaddr = (void *)ktla_ktva((unsigned long)kaddr);
31401+ insn->end_kaddr = insn->kaddr + buf_len;
31402+ insn->next_byte = insn->kaddr;
31403 insn->x86_64 = x86_64 ? 1 : 0;
31404 insn->opnd_bytes = 4;
31405 if (x86_64)
31406diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
31407index 33147fe..12a8815 100644
31408--- a/arch/x86/lib/iomap_copy_64.S
31409+++ b/arch/x86/lib/iomap_copy_64.S
31410@@ -16,6 +16,7 @@
31411 */
31412
31413 #include <linux/linkage.h>
31414+#include <asm/alternative-asm.h>
31415
31416 /*
31417 * override generic version in lib/iomap_copy.c
31418@@ -23,5 +24,6 @@
31419 ENTRY(__iowrite32_copy)
31420 movl %edx,%ecx
31421 rep movsd
31422+ pax_force_retaddr
31423 ret
31424 ENDPROC(__iowrite32_copy)
31425diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
31426index 16698bb..971d300 100644
31427--- a/arch/x86/lib/memcpy_64.S
31428+++ b/arch/x86/lib/memcpy_64.S
31429@@ -36,6 +36,7 @@ ENTRY(memcpy)
31430 rep movsq
31431 movl %edx, %ecx
31432 rep movsb
31433+ pax_force_retaddr
31434 ret
31435 ENDPROC(memcpy)
31436 ENDPROC(__memcpy)
31437@@ -48,6 +49,7 @@ ENTRY(memcpy_erms)
31438 movq %rdi, %rax
31439 movq %rdx, %rcx
31440 rep movsb
31441+ pax_force_retaddr
31442 ret
31443 ENDPROC(memcpy_erms)
31444
31445@@ -132,6 +134,7 @@ ENTRY(memcpy_orig)
31446 movq %r9, 1*8(%rdi)
31447 movq %r10, -2*8(%rdi, %rdx)
31448 movq %r11, -1*8(%rdi, %rdx)
31449+ pax_force_retaddr
31450 retq
31451 .p2align 4
31452 .Lless_16bytes:
31453@@ -144,6 +147,7 @@ ENTRY(memcpy_orig)
31454 movq -1*8(%rsi, %rdx), %r9
31455 movq %r8, 0*8(%rdi)
31456 movq %r9, -1*8(%rdi, %rdx)
31457+ pax_force_retaddr
31458 retq
31459 .p2align 4
31460 .Lless_8bytes:
31461@@ -157,6 +161,7 @@ ENTRY(memcpy_orig)
31462 movl -4(%rsi, %rdx), %r8d
31463 movl %ecx, (%rdi)
31464 movl %r8d, -4(%rdi, %rdx)
31465+ pax_force_retaddr
31466 retq
31467 .p2align 4
31468 .Lless_3bytes:
31469@@ -175,5 +180,6 @@ ENTRY(memcpy_orig)
31470 movb %cl, (%rdi)
31471
31472 .Lend:
31473+ pax_force_retaddr
31474 retq
31475 ENDPROC(memcpy_orig)
31476diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
31477index ca2afdd..2e474fa 100644
31478--- a/arch/x86/lib/memmove_64.S
31479+++ b/arch/x86/lib/memmove_64.S
31480@@ -41,7 +41,7 @@ ENTRY(__memmove)
31481 jg 2f
31482
31483 .Lmemmove_begin_forward:
31484- ALTERNATIVE "", "movq %rdx, %rcx; rep movsb; retq", X86_FEATURE_ERMS
31485+ ALTERNATIVE "", "movq %rdx, %rcx; rep movsb; pax_force_retaddr; retq", X86_FEATURE_ERMS
31486
31487 /*
31488 * movsq instruction have many startup latency
31489@@ -204,6 +204,7 @@ ENTRY(__memmove)
31490 movb (%rsi), %r11b
31491 movb %r11b, (%rdi)
31492 13:
31493+ pax_force_retaddr
31494 retq
31495 ENDPROC(__memmove)
31496 ENDPROC(memmove)
31497diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
31498index 2661fad..b584d5c 100644
31499--- a/arch/x86/lib/memset_64.S
31500+++ b/arch/x86/lib/memset_64.S
31501@@ -40,6 +40,7 @@ ENTRY(__memset)
31502 movl %edx,%ecx
31503 rep stosb
31504 movq %r9,%rax
31505+ pax_force_retaddr
31506 ret
31507 ENDPROC(memset)
31508 ENDPROC(__memset)
31509@@ -61,6 +62,7 @@ ENTRY(memset_erms)
31510 movq %rdx,%rcx
31511 rep stosb
31512 movq %r9,%rax
31513+ pax_force_retaddr
31514 ret
31515 ENDPROC(memset_erms)
31516
31517@@ -123,6 +125,7 @@ ENTRY(memset_orig)
31518
31519 .Lende:
31520 movq %r10,%rax
31521+ pax_force_retaddr
31522 ret
31523
31524 .Lbad_alignment:
31525diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
31526index e5e3ed8..d7c08c2 100644
31527--- a/arch/x86/lib/mmx_32.c
31528+++ b/arch/x86/lib/mmx_32.c
31529@@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
31530 {
31531 void *p;
31532 int i;
31533+ unsigned long cr0;
31534
31535 if (unlikely(in_interrupt()))
31536 return __memcpy(to, from, len);
31537@@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
31538 kernel_fpu_begin();
31539
31540 __asm__ __volatile__ (
31541- "1: prefetch (%0)\n" /* This set is 28 bytes */
31542- " prefetch 64(%0)\n"
31543- " prefetch 128(%0)\n"
31544- " prefetch 192(%0)\n"
31545- " prefetch 256(%0)\n"
31546+ "1: prefetch (%1)\n" /* This set is 28 bytes */
31547+ " prefetch 64(%1)\n"
31548+ " prefetch 128(%1)\n"
31549+ " prefetch 192(%1)\n"
31550+ " prefetch 256(%1)\n"
31551 "2: \n"
31552 ".section .fixup, \"ax\"\n"
31553- "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31554+ "3: \n"
31555+
31556+#ifdef CONFIG_PAX_KERNEXEC
31557+ " movl %%cr0, %0\n"
31558+ " movl %0, %%eax\n"
31559+ " andl $0xFFFEFFFF, %%eax\n"
31560+ " movl %%eax, %%cr0\n"
31561+#endif
31562+
31563+ " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31564+
31565+#ifdef CONFIG_PAX_KERNEXEC
31566+ " movl %0, %%cr0\n"
31567+#endif
31568+
31569 " jmp 2b\n"
31570 ".previous\n"
31571 _ASM_EXTABLE(1b, 3b)
31572- : : "r" (from));
31573+ : "=&r" (cr0) : "r" (from) : "ax");
31574
31575 for ( ; i > 5; i--) {
31576 __asm__ __volatile__ (
31577- "1: prefetch 320(%0)\n"
31578- "2: movq (%0), %%mm0\n"
31579- " movq 8(%0), %%mm1\n"
31580- " movq 16(%0), %%mm2\n"
31581- " movq 24(%0), %%mm3\n"
31582- " movq %%mm0, (%1)\n"
31583- " movq %%mm1, 8(%1)\n"
31584- " movq %%mm2, 16(%1)\n"
31585- " movq %%mm3, 24(%1)\n"
31586- " movq 32(%0), %%mm0\n"
31587- " movq 40(%0), %%mm1\n"
31588- " movq 48(%0), %%mm2\n"
31589- " movq 56(%0), %%mm3\n"
31590- " movq %%mm0, 32(%1)\n"
31591- " movq %%mm1, 40(%1)\n"
31592- " movq %%mm2, 48(%1)\n"
31593- " movq %%mm3, 56(%1)\n"
31594+ "1: prefetch 320(%1)\n"
31595+ "2: movq (%1), %%mm0\n"
31596+ " movq 8(%1), %%mm1\n"
31597+ " movq 16(%1), %%mm2\n"
31598+ " movq 24(%1), %%mm3\n"
31599+ " movq %%mm0, (%2)\n"
31600+ " movq %%mm1, 8(%2)\n"
31601+ " movq %%mm2, 16(%2)\n"
31602+ " movq %%mm3, 24(%2)\n"
31603+ " movq 32(%1), %%mm0\n"
31604+ " movq 40(%1), %%mm1\n"
31605+ " movq 48(%1), %%mm2\n"
31606+ " movq 56(%1), %%mm3\n"
31607+ " movq %%mm0, 32(%2)\n"
31608+ " movq %%mm1, 40(%2)\n"
31609+ " movq %%mm2, 48(%2)\n"
31610+ " movq %%mm3, 56(%2)\n"
31611 ".section .fixup, \"ax\"\n"
31612- "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31613+ "3:\n"
31614+
31615+#ifdef CONFIG_PAX_KERNEXEC
31616+ " movl %%cr0, %0\n"
31617+ " movl %0, %%eax\n"
31618+ " andl $0xFFFEFFFF, %%eax\n"
31619+ " movl %%eax, %%cr0\n"
31620+#endif
31621+
31622+ " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31623+
31624+#ifdef CONFIG_PAX_KERNEXEC
31625+ " movl %0, %%cr0\n"
31626+#endif
31627+
31628 " jmp 2b\n"
31629 ".previous\n"
31630 _ASM_EXTABLE(1b, 3b)
31631- : : "r" (from), "r" (to) : "memory");
31632+ : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
31633
31634 from += 64;
31635 to += 64;
31636@@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
31637 static void fast_copy_page(void *to, void *from)
31638 {
31639 int i;
31640+ unsigned long cr0;
31641
31642 kernel_fpu_begin();
31643
31644@@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
31645 * but that is for later. -AV
31646 */
31647 __asm__ __volatile__(
31648- "1: prefetch (%0)\n"
31649- " prefetch 64(%0)\n"
31650- " prefetch 128(%0)\n"
31651- " prefetch 192(%0)\n"
31652- " prefetch 256(%0)\n"
31653+ "1: prefetch (%1)\n"
31654+ " prefetch 64(%1)\n"
31655+ " prefetch 128(%1)\n"
31656+ " prefetch 192(%1)\n"
31657+ " prefetch 256(%1)\n"
31658 "2: \n"
31659 ".section .fixup, \"ax\"\n"
31660- "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31661+ "3: \n"
31662+
31663+#ifdef CONFIG_PAX_KERNEXEC
31664+ " movl %%cr0, %0\n"
31665+ " movl %0, %%eax\n"
31666+ " andl $0xFFFEFFFF, %%eax\n"
31667+ " movl %%eax, %%cr0\n"
31668+#endif
31669+
31670+ " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31671+
31672+#ifdef CONFIG_PAX_KERNEXEC
31673+ " movl %0, %%cr0\n"
31674+#endif
31675+
31676 " jmp 2b\n"
31677 ".previous\n"
31678- _ASM_EXTABLE(1b, 3b) : : "r" (from));
31679+ _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
31680
31681 for (i = 0; i < (4096-320)/64; i++) {
31682 __asm__ __volatile__ (
31683- "1: prefetch 320(%0)\n"
31684- "2: movq (%0), %%mm0\n"
31685- " movntq %%mm0, (%1)\n"
31686- " movq 8(%0), %%mm1\n"
31687- " movntq %%mm1, 8(%1)\n"
31688- " movq 16(%0), %%mm2\n"
31689- " movntq %%mm2, 16(%1)\n"
31690- " movq 24(%0), %%mm3\n"
31691- " movntq %%mm3, 24(%1)\n"
31692- " movq 32(%0), %%mm4\n"
31693- " movntq %%mm4, 32(%1)\n"
31694- " movq 40(%0), %%mm5\n"
31695- " movntq %%mm5, 40(%1)\n"
31696- " movq 48(%0), %%mm6\n"
31697- " movntq %%mm6, 48(%1)\n"
31698- " movq 56(%0), %%mm7\n"
31699- " movntq %%mm7, 56(%1)\n"
31700+ "1: prefetch 320(%1)\n"
31701+ "2: movq (%1), %%mm0\n"
31702+ " movntq %%mm0, (%2)\n"
31703+ " movq 8(%1), %%mm1\n"
31704+ " movntq %%mm1, 8(%2)\n"
31705+ " movq 16(%1), %%mm2\n"
31706+ " movntq %%mm2, 16(%2)\n"
31707+ " movq 24(%1), %%mm3\n"
31708+ " movntq %%mm3, 24(%2)\n"
31709+ " movq 32(%1), %%mm4\n"
31710+ " movntq %%mm4, 32(%2)\n"
31711+ " movq 40(%1), %%mm5\n"
31712+ " movntq %%mm5, 40(%2)\n"
31713+ " movq 48(%1), %%mm6\n"
31714+ " movntq %%mm6, 48(%2)\n"
31715+ " movq 56(%1), %%mm7\n"
31716+ " movntq %%mm7, 56(%2)\n"
31717 ".section .fixup, \"ax\"\n"
31718- "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31719+ "3:\n"
31720+
31721+#ifdef CONFIG_PAX_KERNEXEC
31722+ " movl %%cr0, %0\n"
31723+ " movl %0, %%eax\n"
31724+ " andl $0xFFFEFFFF, %%eax\n"
31725+ " movl %%eax, %%cr0\n"
31726+#endif
31727+
31728+ " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31729+
31730+#ifdef CONFIG_PAX_KERNEXEC
31731+ " movl %0, %%cr0\n"
31732+#endif
31733+
31734 " jmp 2b\n"
31735 ".previous\n"
31736- _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
31737+ _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
31738
31739 from += 64;
31740 to += 64;
31741@@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
31742 static void fast_copy_page(void *to, void *from)
31743 {
31744 int i;
31745+ unsigned long cr0;
31746
31747 kernel_fpu_begin();
31748
31749 __asm__ __volatile__ (
31750- "1: prefetch (%0)\n"
31751- " prefetch 64(%0)\n"
31752- " prefetch 128(%0)\n"
31753- " prefetch 192(%0)\n"
31754- " prefetch 256(%0)\n"
31755+ "1: prefetch (%1)\n"
31756+ " prefetch 64(%1)\n"
31757+ " prefetch 128(%1)\n"
31758+ " prefetch 192(%1)\n"
31759+ " prefetch 256(%1)\n"
31760 "2: \n"
31761 ".section .fixup, \"ax\"\n"
31762- "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31763+ "3: \n"
31764+
31765+#ifdef CONFIG_PAX_KERNEXEC
31766+ " movl %%cr0, %0\n"
31767+ " movl %0, %%eax\n"
31768+ " andl $0xFFFEFFFF, %%eax\n"
31769+ " movl %%eax, %%cr0\n"
31770+#endif
31771+
31772+ " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31773+
31774+#ifdef CONFIG_PAX_KERNEXEC
31775+ " movl %0, %%cr0\n"
31776+#endif
31777+
31778 " jmp 2b\n"
31779 ".previous\n"
31780- _ASM_EXTABLE(1b, 3b) : : "r" (from));
31781+ _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
31782
31783 for (i = 0; i < 4096/64; i++) {
31784 __asm__ __volatile__ (
31785- "1: prefetch 320(%0)\n"
31786- "2: movq (%0), %%mm0\n"
31787- " movq 8(%0), %%mm1\n"
31788- " movq 16(%0), %%mm2\n"
31789- " movq 24(%0), %%mm3\n"
31790- " movq %%mm0, (%1)\n"
31791- " movq %%mm1, 8(%1)\n"
31792- " movq %%mm2, 16(%1)\n"
31793- " movq %%mm3, 24(%1)\n"
31794- " movq 32(%0), %%mm0\n"
31795- " movq 40(%0), %%mm1\n"
31796- " movq 48(%0), %%mm2\n"
31797- " movq 56(%0), %%mm3\n"
31798- " movq %%mm0, 32(%1)\n"
31799- " movq %%mm1, 40(%1)\n"
31800- " movq %%mm2, 48(%1)\n"
31801- " movq %%mm3, 56(%1)\n"
31802+ "1: prefetch 320(%1)\n"
31803+ "2: movq (%1), %%mm0\n"
31804+ " movq 8(%1), %%mm1\n"
31805+ " movq 16(%1), %%mm2\n"
31806+ " movq 24(%1), %%mm3\n"
31807+ " movq %%mm0, (%2)\n"
31808+ " movq %%mm1, 8(%2)\n"
31809+ " movq %%mm2, 16(%2)\n"
31810+ " movq %%mm3, 24(%2)\n"
31811+ " movq 32(%1), %%mm0\n"
31812+ " movq 40(%1), %%mm1\n"
31813+ " movq 48(%1), %%mm2\n"
31814+ " movq 56(%1), %%mm3\n"
31815+ " movq %%mm0, 32(%2)\n"
31816+ " movq %%mm1, 40(%2)\n"
31817+ " movq %%mm2, 48(%2)\n"
31818+ " movq %%mm3, 56(%2)\n"
31819 ".section .fixup, \"ax\"\n"
31820- "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31821+ "3:\n"
31822+
31823+#ifdef CONFIG_PAX_KERNEXEC
31824+ " movl %%cr0, %0\n"
31825+ " movl %0, %%eax\n"
31826+ " andl $0xFFFEFFFF, %%eax\n"
31827+ " movl %%eax, %%cr0\n"
31828+#endif
31829+
31830+ " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31831+
31832+#ifdef CONFIG_PAX_KERNEXEC
31833+ " movl %0, %%cr0\n"
31834+#endif
31835+
31836 " jmp 2b\n"
31837 ".previous\n"
31838 _ASM_EXTABLE(1b, 3b)
31839- : : "r" (from), "r" (to) : "memory");
31840+ : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
31841
31842 from += 64;
31843 to += 64;
31844diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
31845index c815564..303dcfa 100644
31846--- a/arch/x86/lib/msr-reg.S
31847+++ b/arch/x86/lib/msr-reg.S
31848@@ -2,6 +2,7 @@
31849 #include <linux/errno.h>
31850 #include <asm/asm.h>
31851 #include <asm/msr.h>
31852+#include <asm/alternative-asm.h>
31853
31854 #ifdef CONFIG_X86_64
31855 /*
31856@@ -34,6 +35,7 @@ ENTRY(\op\()_safe_regs)
31857 movl %edi, 28(%r10)
31858 popq %rbp
31859 popq %rbx
31860+ pax_force_retaddr
31861 ret
31862 3:
31863 movl $-EIO, %r11d
31864diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
31865index e0817a1..bc9cf66 100644
31866--- a/arch/x86/lib/putuser.S
31867+++ b/arch/x86/lib/putuser.S
31868@@ -15,7 +15,9 @@
31869 #include <asm/errno.h>
31870 #include <asm/asm.h>
31871 #include <asm/smap.h>
31872-
31873+#include <asm/segment.h>
31874+#include <asm/pgtable.h>
31875+#include <asm/alternative-asm.h>
31876
31877 /*
31878 * __put_user_X
31879@@ -29,55 +31,124 @@
31880 * as they get called from within inline assembly.
31881 */
31882
31883-#define ENTER GET_THREAD_INFO(%_ASM_BX)
31884-#define EXIT ASM_CLAC ; \
31885+#define ENTER
31886+#define EXIT ASM_CLAC ; \
31887+ pax_force_retaddr ; \
31888 ret
31889
31890+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31891+#define _DEST %_ASM_CX,%_ASM_BX
31892+#else
31893+#define _DEST %_ASM_CX
31894+#endif
31895+
31896+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
31897+#define __copyuser_seg gs;
31898+#else
31899+#define __copyuser_seg
31900+#endif
31901+
31902 .text
31903 ENTRY(__put_user_1)
31904 ENTER
31905+
31906+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31907+ GET_THREAD_INFO(%_ASM_BX)
31908 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
31909 jae bad_put_user
31910+
31911+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31912+ mov pax_user_shadow_base,%_ASM_BX
31913+ cmp %_ASM_BX,%_ASM_CX
31914+ jb 1234f
31915+ xor %ebx,%ebx
31916+1234:
31917+#endif
31918+
31919+#endif
31920+
31921 ASM_STAC
31922-1: movb %al,(%_ASM_CX)
31923+1: __copyuser_seg movb %al,(_DEST)
31924 xor %eax,%eax
31925 EXIT
31926 ENDPROC(__put_user_1)
31927
31928 ENTRY(__put_user_2)
31929 ENTER
31930+
31931+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31932+ GET_THREAD_INFO(%_ASM_BX)
31933 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
31934 sub $1,%_ASM_BX
31935 cmp %_ASM_BX,%_ASM_CX
31936 jae bad_put_user
31937+
31938+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31939+ mov pax_user_shadow_base,%_ASM_BX
31940+ cmp %_ASM_BX,%_ASM_CX
31941+ jb 1234f
31942+ xor %ebx,%ebx
31943+1234:
31944+#endif
31945+
31946+#endif
31947+
31948 ASM_STAC
31949-2: movw %ax,(%_ASM_CX)
31950+2: __copyuser_seg movw %ax,(_DEST)
31951 xor %eax,%eax
31952 EXIT
31953 ENDPROC(__put_user_2)
31954
31955 ENTRY(__put_user_4)
31956 ENTER
31957+
31958+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31959+ GET_THREAD_INFO(%_ASM_BX)
31960 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
31961 sub $3,%_ASM_BX
31962 cmp %_ASM_BX,%_ASM_CX
31963 jae bad_put_user
31964+
31965+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31966+ mov pax_user_shadow_base,%_ASM_BX
31967+ cmp %_ASM_BX,%_ASM_CX
31968+ jb 1234f
31969+ xor %ebx,%ebx
31970+1234:
31971+#endif
31972+
31973+#endif
31974+
31975 ASM_STAC
31976-3: movl %eax,(%_ASM_CX)
31977+3: __copyuser_seg movl %eax,(_DEST)
31978 xor %eax,%eax
31979 EXIT
31980 ENDPROC(__put_user_4)
31981
31982 ENTRY(__put_user_8)
31983 ENTER
31984+
31985+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31986+ GET_THREAD_INFO(%_ASM_BX)
31987 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
31988 sub $7,%_ASM_BX
31989 cmp %_ASM_BX,%_ASM_CX
31990 jae bad_put_user
31991+
31992+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31993+ mov pax_user_shadow_base,%_ASM_BX
31994+ cmp %_ASM_BX,%_ASM_CX
31995+ jb 1234f
31996+ xor %ebx,%ebx
31997+1234:
31998+#endif
31999+
32000+#endif
32001+
32002 ASM_STAC
32003-4: mov %_ASM_AX,(%_ASM_CX)
32004+4: __copyuser_seg mov %_ASM_AX,(_DEST)
32005 #ifdef CONFIG_X86_32
32006-5: movl %edx,4(%_ASM_CX)
32007+5: __copyuser_seg movl %edx,4(_DEST)
32008 #endif
32009 xor %eax,%eax
32010 EXIT
32011diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
32012index 40027db..37bb69d 100644
32013--- a/arch/x86/lib/rwsem.S
32014+++ b/arch/x86/lib/rwsem.S
32015@@ -90,6 +90,7 @@ ENTRY(call_rwsem_down_read_failed)
32016 call rwsem_down_read_failed
32017 __ASM_SIZE(pop,) %__ASM_REG(dx)
32018 restore_common_regs
32019+ pax_force_retaddr
32020 ret
32021 ENDPROC(call_rwsem_down_read_failed)
32022
32023@@ -98,6 +99,7 @@ ENTRY(call_rwsem_down_write_failed)
32024 movq %rax,%rdi
32025 call rwsem_down_write_failed
32026 restore_common_regs
32027+ pax_force_retaddr
32028 ret
32029 ENDPROC(call_rwsem_down_write_failed)
32030
32031@@ -109,7 +111,8 @@ ENTRY(call_rwsem_wake)
32032 movq %rax,%rdi
32033 call rwsem_wake
32034 restore_common_regs
32035-1: ret
32036+1: pax_force_retaddr
32037+ ret
32038 ENDPROC(call_rwsem_wake)
32039
32040 ENTRY(call_rwsem_downgrade_wake)
32041@@ -119,5 +122,6 @@ ENTRY(call_rwsem_downgrade_wake)
32042 call rwsem_downgrade_wake
32043 __ASM_SIZE(pop,) %__ASM_REG(dx)
32044 restore_common_regs
32045+ pax_force_retaddr
32046 ret
32047 ENDPROC(call_rwsem_downgrade_wake)
32048diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
32049index 91d93b9..4b22130 100644
32050--- a/arch/x86/lib/usercopy_32.c
32051+++ b/arch/x86/lib/usercopy_32.c
32052@@ -42,11 +42,13 @@ do { \
32053 int __d0; \
32054 might_fault(); \
32055 __asm__ __volatile__( \
32056+ __COPYUSER_SET_ES \
32057 ASM_STAC "\n" \
32058 "0: rep; stosl\n" \
32059 " movl %2,%0\n" \
32060 "1: rep; stosb\n" \
32061 "2: " ASM_CLAC "\n" \
32062+ __COPYUSER_RESTORE_ES \
32063 ".section .fixup,\"ax\"\n" \
32064 "3: lea 0(%2,%0,4),%0\n" \
32065 " jmp 2b\n" \
32066@@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
32067
32068 #ifdef CONFIG_X86_INTEL_USERCOPY
32069 static unsigned long
32070-__copy_user_intel(void __user *to, const void *from, unsigned long size)
32071+__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
32072 {
32073 int d0, d1;
32074 __asm__ __volatile__(
32075@@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
32076 " .align 2,0x90\n"
32077 "3: movl 0(%4), %%eax\n"
32078 "4: movl 4(%4), %%edx\n"
32079- "5: movl %%eax, 0(%3)\n"
32080- "6: movl %%edx, 4(%3)\n"
32081+ "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
32082+ "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
32083 "7: movl 8(%4), %%eax\n"
32084 "8: movl 12(%4),%%edx\n"
32085- "9: movl %%eax, 8(%3)\n"
32086- "10: movl %%edx, 12(%3)\n"
32087+ "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
32088+ "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
32089 "11: movl 16(%4), %%eax\n"
32090 "12: movl 20(%4), %%edx\n"
32091- "13: movl %%eax, 16(%3)\n"
32092- "14: movl %%edx, 20(%3)\n"
32093+ "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
32094+ "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
32095 "15: movl 24(%4), %%eax\n"
32096 "16: movl 28(%4), %%edx\n"
32097- "17: movl %%eax, 24(%3)\n"
32098- "18: movl %%edx, 28(%3)\n"
32099+ "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
32100+ "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
32101 "19: movl 32(%4), %%eax\n"
32102 "20: movl 36(%4), %%edx\n"
32103- "21: movl %%eax, 32(%3)\n"
32104- "22: movl %%edx, 36(%3)\n"
32105+ "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
32106+ "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
32107 "23: movl 40(%4), %%eax\n"
32108 "24: movl 44(%4), %%edx\n"
32109- "25: movl %%eax, 40(%3)\n"
32110- "26: movl %%edx, 44(%3)\n"
32111+ "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
32112+ "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
32113 "27: movl 48(%4), %%eax\n"
32114 "28: movl 52(%4), %%edx\n"
32115- "29: movl %%eax, 48(%3)\n"
32116- "30: movl %%edx, 52(%3)\n"
32117+ "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
32118+ "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
32119 "31: movl 56(%4), %%eax\n"
32120 "32: movl 60(%4), %%edx\n"
32121- "33: movl %%eax, 56(%3)\n"
32122- "34: movl %%edx, 60(%3)\n"
32123+ "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
32124+ "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
32125 " addl $-64, %0\n"
32126 " addl $64, %4\n"
32127 " addl $64, %3\n"
32128@@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
32129 " shrl $2, %0\n"
32130 " andl $3, %%eax\n"
32131 " cld\n"
32132+ __COPYUSER_SET_ES
32133 "99: rep; movsl\n"
32134 "36: movl %%eax, %0\n"
32135 "37: rep; movsb\n"
32136 "100:\n"
32137+ __COPYUSER_RESTORE_ES
32138+ ".section .fixup,\"ax\"\n"
32139+ "101: lea 0(%%eax,%0,4),%0\n"
32140+ " jmp 100b\n"
32141+ ".previous\n"
32142+ _ASM_EXTABLE(1b,100b)
32143+ _ASM_EXTABLE(2b,100b)
32144+ _ASM_EXTABLE(3b,100b)
32145+ _ASM_EXTABLE(4b,100b)
32146+ _ASM_EXTABLE(5b,100b)
32147+ _ASM_EXTABLE(6b,100b)
32148+ _ASM_EXTABLE(7b,100b)
32149+ _ASM_EXTABLE(8b,100b)
32150+ _ASM_EXTABLE(9b,100b)
32151+ _ASM_EXTABLE(10b,100b)
32152+ _ASM_EXTABLE(11b,100b)
32153+ _ASM_EXTABLE(12b,100b)
32154+ _ASM_EXTABLE(13b,100b)
32155+ _ASM_EXTABLE(14b,100b)
32156+ _ASM_EXTABLE(15b,100b)
32157+ _ASM_EXTABLE(16b,100b)
32158+ _ASM_EXTABLE(17b,100b)
32159+ _ASM_EXTABLE(18b,100b)
32160+ _ASM_EXTABLE(19b,100b)
32161+ _ASM_EXTABLE(20b,100b)
32162+ _ASM_EXTABLE(21b,100b)
32163+ _ASM_EXTABLE(22b,100b)
32164+ _ASM_EXTABLE(23b,100b)
32165+ _ASM_EXTABLE(24b,100b)
32166+ _ASM_EXTABLE(25b,100b)
32167+ _ASM_EXTABLE(26b,100b)
32168+ _ASM_EXTABLE(27b,100b)
32169+ _ASM_EXTABLE(28b,100b)
32170+ _ASM_EXTABLE(29b,100b)
32171+ _ASM_EXTABLE(30b,100b)
32172+ _ASM_EXTABLE(31b,100b)
32173+ _ASM_EXTABLE(32b,100b)
32174+ _ASM_EXTABLE(33b,100b)
32175+ _ASM_EXTABLE(34b,100b)
32176+ _ASM_EXTABLE(35b,100b)
32177+ _ASM_EXTABLE(36b,100b)
32178+ _ASM_EXTABLE(37b,100b)
32179+ _ASM_EXTABLE(99b,101b)
32180+ : "=&c"(size), "=&D" (d0), "=&S" (d1)
32181+ : "1"(to), "2"(from), "0"(size)
32182+ : "eax", "edx", "memory");
32183+ return size;
32184+}
32185+
32186+static unsigned long
32187+__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
32188+{
32189+ int d0, d1;
32190+ __asm__ __volatile__(
32191+ " .align 2,0x90\n"
32192+ "1: "__copyuser_seg" movl 32(%4), %%eax\n"
32193+ " cmpl $67, %0\n"
32194+ " jbe 3f\n"
32195+ "2: "__copyuser_seg" movl 64(%4), %%eax\n"
32196+ " .align 2,0x90\n"
32197+ "3: "__copyuser_seg" movl 0(%4), %%eax\n"
32198+ "4: "__copyuser_seg" movl 4(%4), %%edx\n"
32199+ "5: movl %%eax, 0(%3)\n"
32200+ "6: movl %%edx, 4(%3)\n"
32201+ "7: "__copyuser_seg" movl 8(%4), %%eax\n"
32202+ "8: "__copyuser_seg" movl 12(%4),%%edx\n"
32203+ "9: movl %%eax, 8(%3)\n"
32204+ "10: movl %%edx, 12(%3)\n"
32205+ "11: "__copyuser_seg" movl 16(%4), %%eax\n"
32206+ "12: "__copyuser_seg" movl 20(%4), %%edx\n"
32207+ "13: movl %%eax, 16(%3)\n"
32208+ "14: movl %%edx, 20(%3)\n"
32209+ "15: "__copyuser_seg" movl 24(%4), %%eax\n"
32210+ "16: "__copyuser_seg" movl 28(%4), %%edx\n"
32211+ "17: movl %%eax, 24(%3)\n"
32212+ "18: movl %%edx, 28(%3)\n"
32213+ "19: "__copyuser_seg" movl 32(%4), %%eax\n"
32214+ "20: "__copyuser_seg" movl 36(%4), %%edx\n"
32215+ "21: movl %%eax, 32(%3)\n"
32216+ "22: movl %%edx, 36(%3)\n"
32217+ "23: "__copyuser_seg" movl 40(%4), %%eax\n"
32218+ "24: "__copyuser_seg" movl 44(%4), %%edx\n"
32219+ "25: movl %%eax, 40(%3)\n"
32220+ "26: movl %%edx, 44(%3)\n"
32221+ "27: "__copyuser_seg" movl 48(%4), %%eax\n"
32222+ "28: "__copyuser_seg" movl 52(%4), %%edx\n"
32223+ "29: movl %%eax, 48(%3)\n"
32224+ "30: movl %%edx, 52(%3)\n"
32225+ "31: "__copyuser_seg" movl 56(%4), %%eax\n"
32226+ "32: "__copyuser_seg" movl 60(%4), %%edx\n"
32227+ "33: movl %%eax, 56(%3)\n"
32228+ "34: movl %%edx, 60(%3)\n"
32229+ " addl $-64, %0\n"
32230+ " addl $64, %4\n"
32231+ " addl $64, %3\n"
32232+ " cmpl $63, %0\n"
32233+ " ja 1b\n"
32234+ "35: movl %0, %%eax\n"
32235+ " shrl $2, %0\n"
32236+ " andl $3, %%eax\n"
32237+ " cld\n"
32238+ "99: rep; "__copyuser_seg" movsl\n"
32239+ "36: movl %%eax, %0\n"
32240+ "37: rep; "__copyuser_seg" movsb\n"
32241+ "100:\n"
32242 ".section .fixup,\"ax\"\n"
32243 "101: lea 0(%%eax,%0,4),%0\n"
32244 " jmp 100b\n"
32245@@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
32246 int d0, d1;
32247 __asm__ __volatile__(
32248 " .align 2,0x90\n"
32249- "0: movl 32(%4), %%eax\n"
32250+ "0: "__copyuser_seg" movl 32(%4), %%eax\n"
32251 " cmpl $67, %0\n"
32252 " jbe 2f\n"
32253- "1: movl 64(%4), %%eax\n"
32254+ "1: "__copyuser_seg" movl 64(%4), %%eax\n"
32255 " .align 2,0x90\n"
32256- "2: movl 0(%4), %%eax\n"
32257- "21: movl 4(%4), %%edx\n"
32258+ "2: "__copyuser_seg" movl 0(%4), %%eax\n"
32259+ "21: "__copyuser_seg" movl 4(%4), %%edx\n"
32260 " movl %%eax, 0(%3)\n"
32261 " movl %%edx, 4(%3)\n"
32262- "3: movl 8(%4), %%eax\n"
32263- "31: movl 12(%4),%%edx\n"
32264+ "3: "__copyuser_seg" movl 8(%4), %%eax\n"
32265+ "31: "__copyuser_seg" movl 12(%4),%%edx\n"
32266 " movl %%eax, 8(%3)\n"
32267 " movl %%edx, 12(%3)\n"
32268- "4: movl 16(%4), %%eax\n"
32269- "41: movl 20(%4), %%edx\n"
32270+ "4: "__copyuser_seg" movl 16(%4), %%eax\n"
32271+ "41: "__copyuser_seg" movl 20(%4), %%edx\n"
32272 " movl %%eax, 16(%3)\n"
32273 " movl %%edx, 20(%3)\n"
32274- "10: movl 24(%4), %%eax\n"
32275- "51: movl 28(%4), %%edx\n"
32276+ "10: "__copyuser_seg" movl 24(%4), %%eax\n"
32277+ "51: "__copyuser_seg" movl 28(%4), %%edx\n"
32278 " movl %%eax, 24(%3)\n"
32279 " movl %%edx, 28(%3)\n"
32280- "11: movl 32(%4), %%eax\n"
32281- "61: movl 36(%4), %%edx\n"
32282+ "11: "__copyuser_seg" movl 32(%4), %%eax\n"
32283+ "61: "__copyuser_seg" movl 36(%4), %%edx\n"
32284 " movl %%eax, 32(%3)\n"
32285 " movl %%edx, 36(%3)\n"
32286- "12: movl 40(%4), %%eax\n"
32287- "71: movl 44(%4), %%edx\n"
32288+ "12: "__copyuser_seg" movl 40(%4), %%eax\n"
32289+ "71: "__copyuser_seg" movl 44(%4), %%edx\n"
32290 " movl %%eax, 40(%3)\n"
32291 " movl %%edx, 44(%3)\n"
32292- "13: movl 48(%4), %%eax\n"
32293- "81: movl 52(%4), %%edx\n"
32294+ "13: "__copyuser_seg" movl 48(%4), %%eax\n"
32295+ "81: "__copyuser_seg" movl 52(%4), %%edx\n"
32296 " movl %%eax, 48(%3)\n"
32297 " movl %%edx, 52(%3)\n"
32298- "14: movl 56(%4), %%eax\n"
32299- "91: movl 60(%4), %%edx\n"
32300+ "14: "__copyuser_seg" movl 56(%4), %%eax\n"
32301+ "91: "__copyuser_seg" movl 60(%4), %%edx\n"
32302 " movl %%eax, 56(%3)\n"
32303 " movl %%edx, 60(%3)\n"
32304 " addl $-64, %0\n"
32305@@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
32306 " shrl $2, %0\n"
32307 " andl $3, %%eax\n"
32308 " cld\n"
32309- "6: rep; movsl\n"
32310+ "6: rep; "__copyuser_seg" movsl\n"
32311 " movl %%eax,%0\n"
32312- "7: rep; movsb\n"
32313+ "7: rep; "__copyuser_seg" movsb\n"
32314 "8:\n"
32315 ".section .fixup,\"ax\"\n"
32316 "9: lea 0(%%eax,%0,4),%0\n"
32317@@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
32318
32319 __asm__ __volatile__(
32320 " .align 2,0x90\n"
32321- "0: movl 32(%4), %%eax\n"
32322+ "0: "__copyuser_seg" movl 32(%4), %%eax\n"
32323 " cmpl $67, %0\n"
32324 " jbe 2f\n"
32325- "1: movl 64(%4), %%eax\n"
32326+ "1: "__copyuser_seg" movl 64(%4), %%eax\n"
32327 " .align 2,0x90\n"
32328- "2: movl 0(%4), %%eax\n"
32329- "21: movl 4(%4), %%edx\n"
32330+ "2: "__copyuser_seg" movl 0(%4), %%eax\n"
32331+ "21: "__copyuser_seg" movl 4(%4), %%edx\n"
32332 " movnti %%eax, 0(%3)\n"
32333 " movnti %%edx, 4(%3)\n"
32334- "3: movl 8(%4), %%eax\n"
32335- "31: movl 12(%4),%%edx\n"
32336+ "3: "__copyuser_seg" movl 8(%4), %%eax\n"
32337+ "31: "__copyuser_seg" movl 12(%4),%%edx\n"
32338 " movnti %%eax, 8(%3)\n"
32339 " movnti %%edx, 12(%3)\n"
32340- "4: movl 16(%4), %%eax\n"
32341- "41: movl 20(%4), %%edx\n"
32342+ "4: "__copyuser_seg" movl 16(%4), %%eax\n"
32343+ "41: "__copyuser_seg" movl 20(%4), %%edx\n"
32344 " movnti %%eax, 16(%3)\n"
32345 " movnti %%edx, 20(%3)\n"
32346- "10: movl 24(%4), %%eax\n"
32347- "51: movl 28(%4), %%edx\n"
32348+ "10: "__copyuser_seg" movl 24(%4), %%eax\n"
32349+ "51: "__copyuser_seg" movl 28(%4), %%edx\n"
32350 " movnti %%eax, 24(%3)\n"
32351 " movnti %%edx, 28(%3)\n"
32352- "11: movl 32(%4), %%eax\n"
32353- "61: movl 36(%4), %%edx\n"
32354+ "11: "__copyuser_seg" movl 32(%4), %%eax\n"
32355+ "61: "__copyuser_seg" movl 36(%4), %%edx\n"
32356 " movnti %%eax, 32(%3)\n"
32357 " movnti %%edx, 36(%3)\n"
32358- "12: movl 40(%4), %%eax\n"
32359- "71: movl 44(%4), %%edx\n"
32360+ "12: "__copyuser_seg" movl 40(%4), %%eax\n"
32361+ "71: "__copyuser_seg" movl 44(%4), %%edx\n"
32362 " movnti %%eax, 40(%3)\n"
32363 " movnti %%edx, 44(%3)\n"
32364- "13: movl 48(%4), %%eax\n"
32365- "81: movl 52(%4), %%edx\n"
32366+ "13: "__copyuser_seg" movl 48(%4), %%eax\n"
32367+ "81: "__copyuser_seg" movl 52(%4), %%edx\n"
32368 " movnti %%eax, 48(%3)\n"
32369 " movnti %%edx, 52(%3)\n"
32370- "14: movl 56(%4), %%eax\n"
32371- "91: movl 60(%4), %%edx\n"
32372+ "14: "__copyuser_seg" movl 56(%4), %%eax\n"
32373+ "91: "__copyuser_seg" movl 60(%4), %%edx\n"
32374 " movnti %%eax, 56(%3)\n"
32375 " movnti %%edx, 60(%3)\n"
32376 " addl $-64, %0\n"
32377@@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
32378 " shrl $2, %0\n"
32379 " andl $3, %%eax\n"
32380 " cld\n"
32381- "6: rep; movsl\n"
32382+ "6: rep; "__copyuser_seg" movsl\n"
32383 " movl %%eax,%0\n"
32384- "7: rep; movsb\n"
32385+ "7: rep; "__copyuser_seg" movsb\n"
32386 "8:\n"
32387 ".section .fixup,\"ax\"\n"
32388 "9: lea 0(%%eax,%0,4),%0\n"
32389@@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
32390
32391 __asm__ __volatile__(
32392 " .align 2,0x90\n"
32393- "0: movl 32(%4), %%eax\n"
32394+ "0: "__copyuser_seg" movl 32(%4), %%eax\n"
32395 " cmpl $67, %0\n"
32396 " jbe 2f\n"
32397- "1: movl 64(%4), %%eax\n"
32398+ "1: "__copyuser_seg" movl 64(%4), %%eax\n"
32399 " .align 2,0x90\n"
32400- "2: movl 0(%4), %%eax\n"
32401- "21: movl 4(%4), %%edx\n"
32402+ "2: "__copyuser_seg" movl 0(%4), %%eax\n"
32403+ "21: "__copyuser_seg" movl 4(%4), %%edx\n"
32404 " movnti %%eax, 0(%3)\n"
32405 " movnti %%edx, 4(%3)\n"
32406- "3: movl 8(%4), %%eax\n"
32407- "31: movl 12(%4),%%edx\n"
32408+ "3: "__copyuser_seg" movl 8(%4), %%eax\n"
32409+ "31: "__copyuser_seg" movl 12(%4),%%edx\n"
32410 " movnti %%eax, 8(%3)\n"
32411 " movnti %%edx, 12(%3)\n"
32412- "4: movl 16(%4), %%eax\n"
32413- "41: movl 20(%4), %%edx\n"
32414+ "4: "__copyuser_seg" movl 16(%4), %%eax\n"
32415+ "41: "__copyuser_seg" movl 20(%4), %%edx\n"
32416 " movnti %%eax, 16(%3)\n"
32417 " movnti %%edx, 20(%3)\n"
32418- "10: movl 24(%4), %%eax\n"
32419- "51: movl 28(%4), %%edx\n"
32420+ "10: "__copyuser_seg" movl 24(%4), %%eax\n"
32421+ "51: "__copyuser_seg" movl 28(%4), %%edx\n"
32422 " movnti %%eax, 24(%3)\n"
32423 " movnti %%edx, 28(%3)\n"
32424- "11: movl 32(%4), %%eax\n"
32425- "61: movl 36(%4), %%edx\n"
32426+ "11: "__copyuser_seg" movl 32(%4), %%eax\n"
32427+ "61: "__copyuser_seg" movl 36(%4), %%edx\n"
32428 " movnti %%eax, 32(%3)\n"
32429 " movnti %%edx, 36(%3)\n"
32430- "12: movl 40(%4), %%eax\n"
32431- "71: movl 44(%4), %%edx\n"
32432+ "12: "__copyuser_seg" movl 40(%4), %%eax\n"
32433+ "71: "__copyuser_seg" movl 44(%4), %%edx\n"
32434 " movnti %%eax, 40(%3)\n"
32435 " movnti %%edx, 44(%3)\n"
32436- "13: movl 48(%4), %%eax\n"
32437- "81: movl 52(%4), %%edx\n"
32438+ "13: "__copyuser_seg" movl 48(%4), %%eax\n"
32439+ "81: "__copyuser_seg" movl 52(%4), %%edx\n"
32440 " movnti %%eax, 48(%3)\n"
32441 " movnti %%edx, 52(%3)\n"
32442- "14: movl 56(%4), %%eax\n"
32443- "91: movl 60(%4), %%edx\n"
32444+ "14: "__copyuser_seg" movl 56(%4), %%eax\n"
32445+ "91: "__copyuser_seg" movl 60(%4), %%edx\n"
32446 " movnti %%eax, 56(%3)\n"
32447 " movnti %%edx, 60(%3)\n"
32448 " addl $-64, %0\n"
32449@@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
32450 " shrl $2, %0\n"
32451 " andl $3, %%eax\n"
32452 " cld\n"
32453- "6: rep; movsl\n"
32454+ "6: rep; "__copyuser_seg" movsl\n"
32455 " movl %%eax,%0\n"
32456- "7: rep; movsb\n"
32457+ "7: rep; "__copyuser_seg" movsb\n"
32458 "8:\n"
32459 ".section .fixup,\"ax\"\n"
32460 "9: lea 0(%%eax,%0,4),%0\n"
32461@@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
32462 */
32463 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
32464 unsigned long size);
32465-unsigned long __copy_user_intel(void __user *to, const void *from,
32466+unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
32467+ unsigned long size);
32468+unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
32469 unsigned long size);
32470 unsigned long __copy_user_zeroing_intel_nocache(void *to,
32471 const void __user *from, unsigned long size);
32472 #endif /* CONFIG_X86_INTEL_USERCOPY */
32473
32474 /* Generic arbitrary sized copy. */
32475-#define __copy_user(to, from, size) \
32476+#define __copy_user(to, from, size, prefix, set, restore) \
32477 do { \
32478 int __d0, __d1, __d2; \
32479 __asm__ __volatile__( \
32480+ set \
32481 " cmp $7,%0\n" \
32482 " jbe 1f\n" \
32483 " movl %1,%0\n" \
32484 " negl %0\n" \
32485 " andl $7,%0\n" \
32486 " subl %0,%3\n" \
32487- "4: rep; movsb\n" \
32488+ "4: rep; "prefix"movsb\n" \
32489 " movl %3,%0\n" \
32490 " shrl $2,%0\n" \
32491 " andl $3,%3\n" \
32492 " .align 2,0x90\n" \
32493- "0: rep; movsl\n" \
32494+ "0: rep; "prefix"movsl\n" \
32495 " movl %3,%0\n" \
32496- "1: rep; movsb\n" \
32497+ "1: rep; "prefix"movsb\n" \
32498 "2:\n" \
32499+ restore \
32500 ".section .fixup,\"ax\"\n" \
32501 "5: addl %3,%0\n" \
32502 " jmp 2b\n" \
32503@@ -538,14 +650,14 @@ do { \
32504 " negl %0\n" \
32505 " andl $7,%0\n" \
32506 " subl %0,%3\n" \
32507- "4: rep; movsb\n" \
32508+ "4: rep; "__copyuser_seg"movsb\n" \
32509 " movl %3,%0\n" \
32510 " shrl $2,%0\n" \
32511 " andl $3,%3\n" \
32512 " .align 2,0x90\n" \
32513- "0: rep; movsl\n" \
32514+ "0: rep; "__copyuser_seg"movsl\n" \
32515 " movl %3,%0\n" \
32516- "1: rep; movsb\n" \
32517+ "1: rep; "__copyuser_seg"movsb\n" \
32518 "2:\n" \
32519 ".section .fixup,\"ax\"\n" \
32520 "5: addl %3,%0\n" \
32521@@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
32522 {
32523 stac();
32524 if (movsl_is_ok(to, from, n))
32525- __copy_user(to, from, n);
32526+ __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
32527 else
32528- n = __copy_user_intel(to, from, n);
32529+ n = __generic_copy_to_user_intel(to, from, n);
32530 clac();
32531 return n;
32532 }
32533@@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
32534 {
32535 stac();
32536 if (movsl_is_ok(to, from, n))
32537- __copy_user(to, from, n);
32538+ __copy_user(to, from, n, __copyuser_seg, "", "");
32539 else
32540- n = __copy_user_intel((void __user *)to,
32541- (const void *)from, n);
32542+ n = __generic_copy_from_user_intel(to, from, n);
32543 clac();
32544 return n;
32545 }
32546@@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
32547 if (n > 64 && cpu_has_xmm2)
32548 n = __copy_user_intel_nocache(to, from, n);
32549 else
32550- __copy_user(to, from, n);
32551+ __copy_user(to, from, n, __copyuser_seg, "", "");
32552 #else
32553- __copy_user(to, from, n);
32554+ __copy_user(to, from, n, __copyuser_seg, "", "");
32555 #endif
32556 clac();
32557 return n;
32558 }
32559 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
32560
32561-/**
32562- * copy_to_user: - Copy a block of data into user space.
32563- * @to: Destination address, in user space.
32564- * @from: Source address, in kernel space.
32565- * @n: Number of bytes to copy.
32566- *
32567- * Context: User context only. This function may sleep if pagefaults are
32568- * enabled.
32569- *
32570- * Copy data from kernel space to user space.
32571- *
32572- * Returns number of bytes that could not be copied.
32573- * On success, this will be zero.
32574- */
32575-unsigned long _copy_to_user(void __user *to, const void *from, unsigned n)
32576+#ifdef CONFIG_PAX_MEMORY_UDEREF
32577+void __set_fs(mm_segment_t x)
32578 {
32579- if (access_ok(VERIFY_WRITE, to, n))
32580- n = __copy_to_user(to, from, n);
32581- return n;
32582+ switch (x.seg) {
32583+ case 0:
32584+ loadsegment(gs, 0);
32585+ break;
32586+ case TASK_SIZE_MAX:
32587+ loadsegment(gs, __USER_DS);
32588+ break;
32589+ case -1UL:
32590+ loadsegment(gs, __KERNEL_DS);
32591+ break;
32592+ default:
32593+ BUG();
32594+ }
32595 }
32596-EXPORT_SYMBOL(_copy_to_user);
32597+EXPORT_SYMBOL(__set_fs);
32598
32599-/**
32600- * copy_from_user: - Copy a block of data from user space.
32601- * @to: Destination address, in kernel space.
32602- * @from: Source address, in user space.
32603- * @n: Number of bytes to copy.
32604- *
32605- * Context: User context only. This function may sleep if pagefaults are
32606- * enabled.
32607- *
32608- * Copy data from user space to kernel space.
32609- *
32610- * Returns number of bytes that could not be copied.
32611- * On success, this will be zero.
32612- *
32613- * If some data could not be copied, this function will pad the copied
32614- * data to the requested size using zero bytes.
32615- */
32616-unsigned long _copy_from_user(void *to, const void __user *from, unsigned n)
32617+void set_fs(mm_segment_t x)
32618 {
32619- if (access_ok(VERIFY_READ, from, n))
32620- n = __copy_from_user(to, from, n);
32621- else
32622- memset(to, 0, n);
32623- return n;
32624+ current_thread_info()->addr_limit = x;
32625+ __set_fs(x);
32626 }
32627-EXPORT_SYMBOL(_copy_from_user);
32628+EXPORT_SYMBOL(set_fs);
32629+#endif
32630diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
32631index 0a42327..7a82465 100644
32632--- a/arch/x86/lib/usercopy_64.c
32633+++ b/arch/x86/lib/usercopy_64.c
32634@@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
32635 might_fault();
32636 /* no memory constraint because it doesn't change any memory gcc knows
32637 about */
32638+ pax_open_userland();
32639 stac();
32640 asm volatile(
32641 " testq %[size8],%[size8]\n"
32642@@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
32643 _ASM_EXTABLE(0b,3b)
32644 _ASM_EXTABLE(1b,2b)
32645 : [size8] "=&c"(size), [dst] "=&D" (__d0)
32646- : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
32647+ : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
32648 [zero] "r" (0UL), [eight] "r" (8UL));
32649 clac();
32650+ pax_close_userland();
32651 return size;
32652 }
32653 EXPORT_SYMBOL(__clear_user);
32654@@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
32655 }
32656 EXPORT_SYMBOL(clear_user);
32657
32658-unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
32659+unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
32660 {
32661- if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
32662- return copy_user_generic((__force void *)to, (__force void *)from, len);
32663- }
32664- return len;
32665+ if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
32666+ return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
32667+ return len;
32668 }
32669 EXPORT_SYMBOL(copy_in_user);
32670
32671@@ -69,8 +70,10 @@ EXPORT_SYMBOL(copy_in_user);
32672 * it is not necessary to optimize tail handling.
32673 */
32674 __visible unsigned long
32675-copy_user_handle_tail(char *to, char *from, unsigned len)
32676+copy_user_handle_tail(char __user *to, char __user *from, unsigned long len)
32677 {
32678+ clac();
32679+ pax_close_userland();
32680 for (; len; --len, to++) {
32681 char c;
32682
32683@@ -79,10 +82,9 @@ copy_user_handle_tail(char *to, char *from, unsigned len)
32684 if (__put_user_nocheck(c, to, sizeof(char)))
32685 break;
32686 }
32687- clac();
32688
32689 /* If the destination is a kernel buffer, we always clear the end */
32690- if (!__addr_ok(to))
32691+ if (!__addr_ok(to) && (unsigned long)to >= TASK_SIZE_MAX + pax_user_shadow_base)
32692 memset(to, 0, len);
32693 return len;
32694 }
32695diff --git a/arch/x86/math-emu/fpu_aux.c b/arch/x86/math-emu/fpu_aux.c
32696index dd76a05..df65688 100644
32697--- a/arch/x86/math-emu/fpu_aux.c
32698+++ b/arch/x86/math-emu/fpu_aux.c
32699@@ -52,7 +52,7 @@ void fpstate_init_soft(struct swregs_state *soft)
32700
32701 void finit(void)
32702 {
32703- fpstate_init_soft(&current->thread.fpu.state.soft);
32704+ fpstate_init_soft(&current->thread.fpu.state->soft);
32705 }
32706
32707 /*
32708diff --git a/arch/x86/math-emu/fpu_entry.c b/arch/x86/math-emu/fpu_entry.c
32709index 3d8f2e4..ef7cf4e 100644
32710--- a/arch/x86/math-emu/fpu_entry.c
32711+++ b/arch/x86/math-emu/fpu_entry.c
32712@@ -677,7 +677,7 @@ int fpregs_soft_set(struct task_struct *target,
32713 unsigned int pos, unsigned int count,
32714 const void *kbuf, const void __user *ubuf)
32715 {
32716- struct swregs_state *s387 = &target->thread.fpu.state.soft;
32717+ struct swregs_state *s387 = &target->thread.fpu.state->soft;
32718 void *space = s387->st_space;
32719 int ret;
32720 int offset, other, i, tags, regnr, tag, newtop;
32721@@ -729,7 +729,7 @@ int fpregs_soft_get(struct task_struct *target,
32722 unsigned int pos, unsigned int count,
32723 void *kbuf, void __user *ubuf)
32724 {
32725- struct swregs_state *s387 = &target->thread.fpu.state.soft;
32726+ struct swregs_state *s387 = &target->thread.fpu.state->soft;
32727 const void *space = s387->st_space;
32728 int ret;
32729 int offset = (S387->ftop & 7) * 10, other = 80 - offset;
32730diff --git a/arch/x86/math-emu/fpu_system.h b/arch/x86/math-emu/fpu_system.h
32731index 5e044d5..d342fce 100644
32732--- a/arch/x86/math-emu/fpu_system.h
32733+++ b/arch/x86/math-emu/fpu_system.h
32734@@ -46,7 +46,7 @@ static inline struct desc_struct FPU_get_ldt_descriptor(unsigned seg)
32735 #define SEG_EXPAND_DOWN(s) (((s).b & ((1 << 11) | (1 << 10))) \
32736 == (1 << 10))
32737
32738-#define I387 (&current->thread.fpu.state)
32739+#define I387 (current->thread.fpu.state)
32740 #define FPU_info (I387->soft.info)
32741
32742 #define FPU_CS (*(unsigned short *) &(FPU_info->regs->cs))
32743diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
32744index a482d10..1a6edb5 100644
32745--- a/arch/x86/mm/Makefile
32746+++ b/arch/x86/mm/Makefile
32747@@ -33,3 +33,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
32748 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
32749
32750 obj-$(CONFIG_X86_INTEL_MPX) += mpx.o
32751+
32752+quote:="
32753+obj-$(CONFIG_X86_64) += uderef_64.o
32754+CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS)) -fcall-saved-rax
32755diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
32756index 903ec1e..41b4708 100644
32757--- a/arch/x86/mm/extable.c
32758+++ b/arch/x86/mm/extable.c
32759@@ -2,16 +2,29 @@
32760 #include <linux/spinlock.h>
32761 #include <linux/sort.h>
32762 #include <asm/uaccess.h>
32763+#include <asm/boot.h>
32764
32765 static inline unsigned long
32766 ex_insn_addr(const struct exception_table_entry *x)
32767 {
32768- return (unsigned long)&x->insn + x->insn;
32769+ unsigned long reloc = 0;
32770+
32771+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
32772+ reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32773+#endif
32774+
32775+ return (unsigned long)&x->insn + x->insn + reloc;
32776 }
32777 static inline unsigned long
32778 ex_fixup_addr(const struct exception_table_entry *x)
32779 {
32780- return (unsigned long)&x->fixup + x->fixup;
32781+ unsigned long reloc = 0;
32782+
32783+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
32784+ reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32785+#endif
32786+
32787+ return (unsigned long)&x->fixup + x->fixup + reloc;
32788 }
32789
32790 int fixup_exception(struct pt_regs *regs)
32791@@ -20,7 +33,7 @@ int fixup_exception(struct pt_regs *regs)
32792 unsigned long new_ip;
32793
32794 #ifdef CONFIG_PNPBIOS
32795- if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
32796+ if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
32797 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
32798 extern u32 pnp_bios_is_utter_crap;
32799 pnp_bios_is_utter_crap = 1;
32800@@ -145,6 +158,13 @@ void sort_extable(struct exception_table_entry *start,
32801 i += 4;
32802 p->fixup -= i;
32803 i += 4;
32804+
32805+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
32806+ BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
32807+ p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32808+ p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32809+#endif
32810+
32811 }
32812 }
32813
32814diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
32815index 9dc9098..938251a 100644
32816--- a/arch/x86/mm/fault.c
32817+++ b/arch/x86/mm/fault.c
32818@@ -14,12 +14,19 @@
32819 #include <linux/prefetch.h> /* prefetchw */
32820 #include <linux/context_tracking.h> /* exception_enter(), ... */
32821 #include <linux/uaccess.h> /* faulthandler_disabled() */
32822+#include <linux/unistd.h>
32823+#include <linux/compiler.h>
32824
32825 #include <asm/traps.h> /* dotraplinkage, ... */
32826 #include <asm/pgalloc.h> /* pgd_*(), ... */
32827 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
32828 #include <asm/fixmap.h> /* VSYSCALL_ADDR */
32829 #include <asm/vsyscall.h> /* emulate_vsyscall */
32830+#include <asm/tlbflush.h>
32831+
32832+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32833+#include <asm/stacktrace.h>
32834+#endif
32835
32836 #define CREATE_TRACE_POINTS
32837 #include <asm/trace/exceptions.h>
32838@@ -121,7 +128,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
32839 return !instr_lo || (instr_lo>>1) == 1;
32840 case 0x00:
32841 /* Prefetch instruction is 0x0F0D or 0x0F18 */
32842- if (probe_kernel_address(instr, opcode))
32843+ if (user_mode(regs)) {
32844+ if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
32845+ return 0;
32846+ } else if (probe_kernel_address(instr, opcode))
32847 return 0;
32848
32849 *prefetch = (instr_lo == 0xF) &&
32850@@ -155,7 +165,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
32851 while (instr < max_instr) {
32852 unsigned char opcode;
32853
32854- if (probe_kernel_address(instr, opcode))
32855+ if (user_mode(regs)) {
32856+ if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
32857+ break;
32858+ } else if (probe_kernel_address(instr, opcode))
32859 break;
32860
32861 instr++;
32862@@ -186,6 +199,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
32863 force_sig_info(si_signo, &info, tsk);
32864 }
32865
32866+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
32867+static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
32868+#endif
32869+
32870+#ifdef CONFIG_PAX_EMUTRAMP
32871+static int pax_handle_fetch_fault(struct pt_regs *regs);
32872+#endif
32873+
32874+#ifdef CONFIG_PAX_PAGEEXEC
32875+static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
32876+{
32877+ pgd_t *pgd;
32878+ pud_t *pud;
32879+ pmd_t *pmd;
32880+
32881+ pgd = pgd_offset(mm, address);
32882+ if (!pgd_present(*pgd))
32883+ return NULL;
32884+ pud = pud_offset(pgd, address);
32885+ if (!pud_present(*pud))
32886+ return NULL;
32887+ pmd = pmd_offset(pud, address);
32888+ if (!pmd_present(*pmd))
32889+ return NULL;
32890+ return pmd;
32891+}
32892+#endif
32893+
32894 DEFINE_SPINLOCK(pgd_lock);
32895 LIST_HEAD(pgd_list);
32896
32897@@ -236,10 +277,27 @@ void vmalloc_sync_all(void)
32898 for (address = VMALLOC_START & PMD_MASK;
32899 address >= TASK_SIZE && address < FIXADDR_TOP;
32900 address += PMD_SIZE) {
32901+
32902+#ifdef CONFIG_PAX_PER_CPU_PGD
32903+ unsigned long cpu;
32904+#else
32905 struct page *page;
32906+#endif
32907
32908 spin_lock(&pgd_lock);
32909+
32910+#ifdef CONFIG_PAX_PER_CPU_PGD
32911+ for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
32912+ pgd_t *pgd = get_cpu_pgd(cpu, user);
32913+ pmd_t *ret;
32914+
32915+ ret = vmalloc_sync_one(pgd, address);
32916+ if (!ret)
32917+ break;
32918+ pgd = get_cpu_pgd(cpu, kernel);
32919+#else
32920 list_for_each_entry(page, &pgd_list, lru) {
32921+ pgd_t *pgd;
32922 spinlock_t *pgt_lock;
32923 pmd_t *ret;
32924
32925@@ -247,8 +305,14 @@ void vmalloc_sync_all(void)
32926 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
32927
32928 spin_lock(pgt_lock);
32929- ret = vmalloc_sync_one(page_address(page), address);
32930+ pgd = page_address(page);
32931+#endif
32932+
32933+ ret = vmalloc_sync_one(pgd, address);
32934+
32935+#ifndef CONFIG_PAX_PER_CPU_PGD
32936 spin_unlock(pgt_lock);
32937+#endif
32938
32939 if (!ret)
32940 break;
32941@@ -282,6 +346,12 @@ static noinline int vmalloc_fault(unsigned long address)
32942 * an interrupt in the middle of a task switch..
32943 */
32944 pgd_paddr = read_cr3();
32945+
32946+#ifdef CONFIG_PAX_PER_CPU_PGD
32947+ BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
32948+ vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
32949+#endif
32950+
32951 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
32952 if (!pmd_k)
32953 return -1;
32954@@ -378,11 +448,25 @@ static noinline int vmalloc_fault(unsigned long address)
32955 * happen within a race in page table update. In the later
32956 * case just flush:
32957 */
32958- pgd = pgd_offset(current->active_mm, address);
32959+
32960 pgd_ref = pgd_offset_k(address);
32961 if (pgd_none(*pgd_ref))
32962 return -1;
32963
32964+#ifdef CONFIG_PAX_PER_CPU_PGD
32965+ BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
32966+ pgd = pgd_offset_cpu(smp_processor_id(), user, address);
32967+ if (pgd_none(*pgd)) {
32968+ set_pgd(pgd, *pgd_ref);
32969+ arch_flush_lazy_mmu_mode();
32970+ } else {
32971+ BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
32972+ }
32973+ pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
32974+#else
32975+ pgd = pgd_offset(current->active_mm, address);
32976+#endif
32977+
32978 if (pgd_none(*pgd)) {
32979 set_pgd(pgd, *pgd_ref);
32980 arch_flush_lazy_mmu_mode();
32981@@ -549,7 +633,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
32982 static int is_errata100(struct pt_regs *regs, unsigned long address)
32983 {
32984 #ifdef CONFIG_X86_64
32985- if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
32986+ if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
32987 return 1;
32988 #endif
32989 return 0;
32990@@ -576,9 +660,9 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
32991 }
32992
32993 static const char nx_warning[] = KERN_CRIT
32994-"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
32995+"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
32996 static const char smep_warning[] = KERN_CRIT
32997-"unable to execute userspace code (SMEP?) (uid: %d)\n";
32998+"unable to execute userspace code (SMEP?) (uid: %d, task: %s, pid: %d)\n";
32999
33000 static void
33001 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
33002@@ -587,7 +671,7 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
33003 if (!oops_may_print())
33004 return;
33005
33006- if (error_code & PF_INSTR) {
33007+ if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
33008 unsigned int level;
33009 pgd_t *pgd;
33010 pte_t *pte;
33011@@ -598,13 +682,25 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
33012 pte = lookup_address_in_pgd(pgd, address, &level);
33013
33014 if (pte && pte_present(*pte) && !pte_exec(*pte))
33015- printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
33016+ printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
33017 if (pte && pte_present(*pte) && pte_exec(*pte) &&
33018 (pgd_flags(*pgd) & _PAGE_USER) &&
33019 (__read_cr4() & X86_CR4_SMEP))
33020- printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
33021+ printk(smep_warning, from_kuid(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
33022 }
33023
33024+#ifdef CONFIG_PAX_KERNEXEC
33025+ if (init_mm.start_code <= address && address < init_mm.end_code) {
33026+ if (current->signal->curr_ip)
33027+ printk(KERN_EMERG "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
33028+ &current->signal->curr_ip, current->comm, task_pid_nr(current),
33029+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
33030+ else
33031+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
33032+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
33033+ }
33034+#endif
33035+
33036 printk(KERN_ALERT "BUG: unable to handle kernel ");
33037 if (address < PAGE_SIZE)
33038 printk(KERN_CONT "NULL pointer dereference");
33039@@ -783,6 +879,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
33040 return;
33041 }
33042 #endif
33043+
33044+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
33045+ if (pax_is_fetch_fault(regs, error_code, address)) {
33046+
33047+#ifdef CONFIG_PAX_EMUTRAMP
33048+ switch (pax_handle_fetch_fault(regs)) {
33049+ case 2:
33050+ return;
33051+ }
33052+#endif
33053+
33054+ pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
33055+ do_group_exit(SIGKILL);
33056+ }
33057+#endif
33058+
33059 /* Kernel addresses are always protection faults: */
33060 if (address >= TASK_SIZE)
33061 error_code |= PF_PROT;
33062@@ -865,7 +977,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
33063 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
33064 printk(KERN_ERR
33065 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
33066- tsk->comm, tsk->pid, address);
33067+ tsk->comm, task_pid_nr(tsk), address);
33068 code = BUS_MCEERR_AR;
33069 }
33070 #endif
33071@@ -917,6 +1029,107 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
33072 return 1;
33073 }
33074
33075+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
33076+static inline unsigned long get_limit(unsigned long segment)
33077+{
33078+ unsigned long __limit;
33079+
33080+ asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
33081+ return __limit + 1;
33082+}
33083+
33084+static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
33085+{
33086+ pte_t *pte;
33087+ pmd_t *pmd;
33088+ spinlock_t *ptl;
33089+ unsigned char pte_mask;
33090+
33091+ if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
33092+ !(mm->pax_flags & MF_PAX_PAGEEXEC))
33093+ return 0;
33094+
33095+ /* PaX: it's our fault, let's handle it if we can */
33096+
33097+ /* PaX: take a look at read faults before acquiring any locks */
33098+ if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
33099+ /* instruction fetch attempt from a protected page in user mode */
33100+ up_read(&mm->mmap_sem);
33101+
33102+#ifdef CONFIG_PAX_EMUTRAMP
33103+ switch (pax_handle_fetch_fault(regs)) {
33104+ case 2:
33105+ return 1;
33106+ }
33107+#endif
33108+
33109+ pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
33110+ do_group_exit(SIGKILL);
33111+ }
33112+
33113+ pmd = pax_get_pmd(mm, address);
33114+ if (unlikely(!pmd))
33115+ return 0;
33116+
33117+ pte = pte_offset_map_lock(mm, pmd, address, &ptl);
33118+ if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
33119+ pte_unmap_unlock(pte, ptl);
33120+ return 0;
33121+ }
33122+
33123+ if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
33124+ /* write attempt to a protected page in user mode */
33125+ pte_unmap_unlock(pte, ptl);
33126+ return 0;
33127+ }
33128+
33129+#ifdef CONFIG_SMP
33130+ if (likely(address > get_limit(regs->cs) && cpumask_test_cpu(smp_processor_id(), &mm->context.cpu_user_cs_mask)))
33131+#else
33132+ if (likely(address > get_limit(regs->cs)))
33133+#endif
33134+ {
33135+ set_pte(pte, pte_mkread(*pte));
33136+ __flush_tlb_one(address);
33137+ pte_unmap_unlock(pte, ptl);
33138+ up_read(&mm->mmap_sem);
33139+ return 1;
33140+ }
33141+
33142+ pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
33143+
33144+ /*
33145+ * PaX: fill DTLB with user rights and retry
33146+ */
33147+ __asm__ __volatile__ (
33148+ "orb %2,(%1)\n"
33149+#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
33150+/*
33151+ * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
33152+ * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
33153+ * page fault when examined during a TLB load attempt. this is true not only
33154+ * for PTEs holding a non-present entry but also present entries that will
33155+ * raise a page fault (such as those set up by PaX, or the copy-on-write
33156+ * mechanism). in effect it means that we do *not* need to flush the TLBs
33157+ * for our target pages since their PTEs are simply not in the TLBs at all.
33158+
33159+ * the best thing in omitting it is that we gain around 15-20% speed in the
33160+ * fast path of the page fault handler and can get rid of tracing since we
33161+ * can no longer flush unintended entries.
33162+ */
33163+ "invlpg (%0)\n"
33164+#endif
33165+ __copyuser_seg"testb $0,(%0)\n"
33166+ "xorb %3,(%1)\n"
33167+ :
33168+ : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
33169+ : "memory", "cc");
33170+ pte_unmap_unlock(pte, ptl);
33171+ up_read(&mm->mmap_sem);
33172+ return 1;
33173+}
33174+#endif
33175+
33176 /*
33177 * Handle a spurious fault caused by a stale TLB entry.
33178 *
33179@@ -1002,6 +1215,9 @@ int show_unhandled_signals = 1;
33180 static inline int
33181 access_error(unsigned long error_code, struct vm_area_struct *vma)
33182 {
33183+ if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
33184+ return 1;
33185+
33186 if (error_code & PF_WRITE) {
33187 /* write, present and write, not present: */
33188 if (unlikely(!(vma->vm_flags & VM_WRITE)))
33189@@ -1064,6 +1280,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
33190 tsk = current;
33191 mm = tsk->mm;
33192
33193+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
33194+ if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
33195+ if (!search_exception_tables(regs->ip)) {
33196+ printk(KERN_EMERG "PAX: please report this to pageexec@freemail.hu\n");
33197+ bad_area_nosemaphore(regs, error_code, address);
33198+ return;
33199+ }
33200+ if (address < pax_user_shadow_base) {
33201+ printk(KERN_EMERG "PAX: please report this to pageexec@freemail.hu\n");
33202+ printk(KERN_EMERG "PAX: faulting IP: %pS\n", (void *)regs->ip);
33203+ show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_EMERG);
33204+ } else
33205+ address -= pax_user_shadow_base;
33206+ }
33207+#endif
33208+
33209 /*
33210 * Detect and handle instructions that would cause a page fault for
33211 * both a tracked kernel page and a userspace page.
33212@@ -1188,6 +1420,11 @@ retry:
33213 might_sleep();
33214 }
33215
33216+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
33217+ if (pax_handle_pageexec_fault(regs, mm, address, error_code))
33218+ return;
33219+#endif
33220+
33221 vma = find_vma(mm, address);
33222 if (unlikely(!vma)) {
33223 bad_area(regs, error_code, address);
33224@@ -1199,18 +1436,24 @@ retry:
33225 bad_area(regs, error_code, address);
33226 return;
33227 }
33228- if (error_code & PF_USER) {
33229- /*
33230- * Accessing the stack below %sp is always a bug.
33231- * The large cushion allows instructions like enter
33232- * and pusha to work. ("enter $65535, $31" pushes
33233- * 32 pointers and then decrements %sp by 65535.)
33234- */
33235- if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
33236- bad_area(regs, error_code, address);
33237- return;
33238- }
33239+ /*
33240+ * Accessing the stack below %sp is always a bug.
33241+ * The large cushion allows instructions like enter
33242+ * and pusha to work. ("enter $65535, $31" pushes
33243+ * 32 pointers and then decrements %sp by 65535.)
33244+ */
33245+ if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
33246+ bad_area(regs, error_code, address);
33247+ return;
33248 }
33249+
33250+#ifdef CONFIG_PAX_SEGMEXEC
33251+ if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
33252+ bad_area(regs, error_code, address);
33253+ return;
33254+ }
33255+#endif
33256+
33257 if (unlikely(expand_stack(vma, address))) {
33258 bad_area(regs, error_code, address);
33259 return;
33260@@ -1330,3 +1573,292 @@ trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
33261 }
33262 NOKPROBE_SYMBOL(trace_do_page_fault);
33263 #endif /* CONFIG_TRACING */
33264+
33265+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
33266+static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
33267+{
33268+ struct mm_struct *mm = current->mm;
33269+ unsigned long ip = regs->ip;
33270+
33271+ if (v8086_mode(regs))
33272+ ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
33273+
33274+#ifdef CONFIG_PAX_PAGEEXEC
33275+ if (mm->pax_flags & MF_PAX_PAGEEXEC) {
33276+ if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
33277+ return true;
33278+ if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
33279+ return true;
33280+ return false;
33281+ }
33282+#endif
33283+
33284+#ifdef CONFIG_PAX_SEGMEXEC
33285+ if (mm->pax_flags & MF_PAX_SEGMEXEC) {
33286+ if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
33287+ return true;
33288+ return false;
33289+ }
33290+#endif
33291+
33292+ return false;
33293+}
33294+#endif
33295+
33296+#ifdef CONFIG_PAX_EMUTRAMP
33297+static int pax_handle_fetch_fault_32(struct pt_regs *regs)
33298+{
33299+ int err;
33300+
33301+ do { /* PaX: libffi trampoline emulation */
33302+ unsigned char mov, jmp;
33303+ unsigned int addr1, addr2;
33304+
33305+#ifdef CONFIG_X86_64
33306+ if ((regs->ip + 9) >> 32)
33307+ break;
33308+#endif
33309+
33310+ err = get_user(mov, (unsigned char __user *)regs->ip);
33311+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
33312+ err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
33313+ err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
33314+
33315+ if (err)
33316+ break;
33317+
33318+ if (mov == 0xB8 && jmp == 0xE9) {
33319+ regs->ax = addr1;
33320+ regs->ip = (unsigned int)(regs->ip + addr2 + 10);
33321+ return 2;
33322+ }
33323+ } while (0);
33324+
33325+ do { /* PaX: gcc trampoline emulation #1 */
33326+ unsigned char mov1, mov2;
33327+ unsigned short jmp;
33328+ unsigned int addr1, addr2;
33329+
33330+#ifdef CONFIG_X86_64
33331+ if ((regs->ip + 11) >> 32)
33332+ break;
33333+#endif
33334+
33335+ err = get_user(mov1, (unsigned char __user *)regs->ip);
33336+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
33337+ err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
33338+ err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
33339+ err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
33340+
33341+ if (err)
33342+ break;
33343+
33344+ if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
33345+ regs->cx = addr1;
33346+ regs->ax = addr2;
33347+ regs->ip = addr2;
33348+ return 2;
33349+ }
33350+ } while (0);
33351+
33352+ do { /* PaX: gcc trampoline emulation #2 */
33353+ unsigned char mov, jmp;
33354+ unsigned int addr1, addr2;
33355+
33356+#ifdef CONFIG_X86_64
33357+ if ((regs->ip + 9) >> 32)
33358+ break;
33359+#endif
33360+
33361+ err = get_user(mov, (unsigned char __user *)regs->ip);
33362+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
33363+ err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
33364+ err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
33365+
33366+ if (err)
33367+ break;
33368+
33369+ if (mov == 0xB9 && jmp == 0xE9) {
33370+ regs->cx = addr1;
33371+ regs->ip = (unsigned int)(regs->ip + addr2 + 10);
33372+ return 2;
33373+ }
33374+ } while (0);
33375+
33376+ return 1; /* PaX in action */
33377+}
33378+
33379+#ifdef CONFIG_X86_64
33380+static int pax_handle_fetch_fault_64(struct pt_regs *regs)
33381+{
33382+ int err;
33383+
33384+ do { /* PaX: libffi trampoline emulation */
33385+ unsigned short mov1, mov2, jmp1;
33386+ unsigned char stcclc, jmp2;
33387+ unsigned long addr1, addr2;
33388+
33389+ err = get_user(mov1, (unsigned short __user *)regs->ip);
33390+ err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
33391+ err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
33392+ err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
33393+ err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
33394+ err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
33395+ err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
33396+
33397+ if (err)
33398+ break;
33399+
33400+ if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
33401+ regs->r11 = addr1;
33402+ regs->r10 = addr2;
33403+ if (stcclc == 0xF8)
33404+ regs->flags &= ~X86_EFLAGS_CF;
33405+ else
33406+ regs->flags |= X86_EFLAGS_CF;
33407+ regs->ip = addr1;
33408+ return 2;
33409+ }
33410+ } while (0);
33411+
33412+ do { /* PaX: gcc trampoline emulation #1 */
33413+ unsigned short mov1, mov2, jmp1;
33414+ unsigned char jmp2;
33415+ unsigned int addr1;
33416+ unsigned long addr2;
33417+
33418+ err = get_user(mov1, (unsigned short __user *)regs->ip);
33419+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
33420+ err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
33421+ err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
33422+ err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
33423+ err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
33424+
33425+ if (err)
33426+ break;
33427+
33428+ if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
33429+ regs->r11 = addr1;
33430+ regs->r10 = addr2;
33431+ regs->ip = addr1;
33432+ return 2;
33433+ }
33434+ } while (0);
33435+
33436+ do { /* PaX: gcc trampoline emulation #2 */
33437+ unsigned short mov1, mov2, jmp1;
33438+ unsigned char jmp2;
33439+ unsigned long addr1, addr2;
33440+
33441+ err = get_user(mov1, (unsigned short __user *)regs->ip);
33442+ err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
33443+ err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
33444+ err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
33445+ err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
33446+ err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
33447+
33448+ if (err)
33449+ break;
33450+
33451+ if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
33452+ regs->r11 = addr1;
33453+ regs->r10 = addr2;
33454+ regs->ip = addr1;
33455+ return 2;
33456+ }
33457+ } while (0);
33458+
33459+ return 1; /* PaX in action */
33460+}
33461+#endif
33462+
33463+/*
33464+ * PaX: decide what to do with offenders (regs->ip = fault address)
33465+ *
33466+ * returns 1 when task should be killed
33467+ * 2 when gcc trampoline was detected
33468+ */
33469+static int pax_handle_fetch_fault(struct pt_regs *regs)
33470+{
33471+ if (v8086_mode(regs))
33472+ return 1;
33473+
33474+ if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
33475+ return 1;
33476+
33477+#ifdef CONFIG_X86_32
33478+ return pax_handle_fetch_fault_32(regs);
33479+#else
33480+ if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
33481+ return pax_handle_fetch_fault_32(regs);
33482+ else
33483+ return pax_handle_fetch_fault_64(regs);
33484+#endif
33485+}
33486+#endif
33487+
33488+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
33489+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
33490+{
33491+ long i;
33492+
33493+ printk(KERN_ERR "PAX: bytes at PC: ");
33494+ for (i = 0; i < 20; i++) {
33495+ unsigned char c;
33496+ if (get_user(c, (unsigned char __force_user *)pc+i))
33497+ printk(KERN_CONT "?? ");
33498+ else
33499+ printk(KERN_CONT "%02x ", c);
33500+ }
33501+ printk("\n");
33502+
33503+ printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
33504+ for (i = -1; i < 80 / (long)sizeof(long); i++) {
33505+ unsigned long c;
33506+ if (get_user(c, (unsigned long __force_user *)sp+i)) {
33507+#ifdef CONFIG_X86_32
33508+ printk(KERN_CONT "???????? ");
33509+#else
33510+ if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
33511+ printk(KERN_CONT "???????? ???????? ");
33512+ else
33513+ printk(KERN_CONT "???????????????? ");
33514+#endif
33515+ } else {
33516+#ifdef CONFIG_X86_64
33517+ if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
33518+ printk(KERN_CONT "%08x ", (unsigned int)c);
33519+ printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
33520+ } else
33521+#endif
33522+ printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
33523+ }
33524+ }
33525+ printk("\n");
33526+}
33527+#endif
33528+
33529+/**
33530+ * probe_kernel_write(): safely attempt to write to a location
33531+ * @dst: address to write to
33532+ * @src: pointer to the data that shall be written
33533+ * @size: size of the data chunk
33534+ *
33535+ * Safely write to address @dst from the buffer at @src. If a kernel fault
33536+ * happens, handle that and return -EFAULT.
33537+ */
33538+long notrace probe_kernel_write(void *dst, const void *src, size_t size)
33539+{
33540+ long ret;
33541+ mm_segment_t old_fs = get_fs();
33542+
33543+ set_fs(KERNEL_DS);
33544+ pagefault_disable();
33545+ pax_open_kernel();
33546+ ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
33547+ pax_close_kernel();
33548+ pagefault_enable();
33549+ set_fs(old_fs);
33550+
33551+ return ret ? -EFAULT : 0;
33552+}
33553diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
33554index 81bf3d2..7ef25c2 100644
33555--- a/arch/x86/mm/gup.c
33556+++ b/arch/x86/mm/gup.c
33557@@ -268,7 +268,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
33558 addr = start;
33559 len = (unsigned long) nr_pages << PAGE_SHIFT;
33560 end = start + len;
33561- if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
33562+ if (unlikely(!access_ok_noprefault(write ? VERIFY_WRITE : VERIFY_READ,
33563 (void __user *)start, len)))
33564 return 0;
33565
33566@@ -344,6 +344,10 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
33567 goto slow_irqon;
33568 #endif
33569
33570+ if (unlikely(!access_ok_noprefault(write ? VERIFY_WRITE : VERIFY_READ,
33571+ (void __user *)start, len)))
33572+ return 0;
33573+
33574 /*
33575 * XXX: batch / limit 'nr', to avoid large irq off latency
33576 * needs some instrumenting to determine the common sizes used by
33577diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
33578index eecb207a..e76b7f4 100644
33579--- a/arch/x86/mm/highmem_32.c
33580+++ b/arch/x86/mm/highmem_32.c
33581@@ -35,6 +35,8 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
33582 unsigned long vaddr;
33583 int idx, type;
33584
33585+ BUG_ON(pgprot_val(prot) & _PAGE_USER);
33586+
33587 preempt_disable();
33588 pagefault_disable();
33589
33590@@ -45,7 +47,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
33591 idx = type + KM_TYPE_NR*smp_processor_id();
33592 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
33593 BUG_ON(!pte_none(*(kmap_pte-idx)));
33594+
33595+ pax_open_kernel();
33596 set_pte(kmap_pte-idx, mk_pte(page, prot));
33597+ pax_close_kernel();
33598+
33599 arch_flush_lazy_mmu_mode();
33600
33601 return (void *)vaddr;
33602diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
33603index 42982b2..7168fc3 100644
33604--- a/arch/x86/mm/hugetlbpage.c
33605+++ b/arch/x86/mm/hugetlbpage.c
33606@@ -74,23 +74,24 @@ int pud_huge(pud_t pud)
33607 #ifdef CONFIG_HUGETLB_PAGE
33608 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
33609 unsigned long addr, unsigned long len,
33610- unsigned long pgoff, unsigned long flags)
33611+ unsigned long pgoff, unsigned long flags, unsigned long offset)
33612 {
33613 struct hstate *h = hstate_file(file);
33614 struct vm_unmapped_area_info info;
33615-
33616+
33617 info.flags = 0;
33618 info.length = len;
33619 info.low_limit = current->mm->mmap_legacy_base;
33620 info.high_limit = TASK_SIZE;
33621 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
33622 info.align_offset = 0;
33623+ info.threadstack_offset = offset;
33624 return vm_unmapped_area(&info);
33625 }
33626
33627 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
33628 unsigned long addr0, unsigned long len,
33629- unsigned long pgoff, unsigned long flags)
33630+ unsigned long pgoff, unsigned long flags, unsigned long offset)
33631 {
33632 struct hstate *h = hstate_file(file);
33633 struct vm_unmapped_area_info info;
33634@@ -102,6 +103,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
33635 info.high_limit = current->mm->mmap_base;
33636 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
33637 info.align_offset = 0;
33638+ info.threadstack_offset = offset;
33639 addr = vm_unmapped_area(&info);
33640
33641 /*
33642@@ -114,6 +116,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
33643 VM_BUG_ON(addr != -ENOMEM);
33644 info.flags = 0;
33645 info.low_limit = TASK_UNMAPPED_BASE;
33646+
33647+#ifdef CONFIG_PAX_RANDMMAP
33648+ if (current->mm->pax_flags & MF_PAX_RANDMMAP)
33649+ info.low_limit += current->mm->delta_mmap;
33650+#endif
33651+
33652 info.high_limit = TASK_SIZE;
33653 addr = vm_unmapped_area(&info);
33654 }
33655@@ -128,10 +136,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
33656 struct hstate *h = hstate_file(file);
33657 struct mm_struct *mm = current->mm;
33658 struct vm_area_struct *vma;
33659+ unsigned long pax_task_size = TASK_SIZE;
33660+ unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
33661
33662 if (len & ~huge_page_mask(h))
33663 return -EINVAL;
33664- if (len > TASK_SIZE)
33665+
33666+#ifdef CONFIG_PAX_SEGMEXEC
33667+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
33668+ pax_task_size = SEGMEXEC_TASK_SIZE;
33669+#endif
33670+
33671+ pax_task_size -= PAGE_SIZE;
33672+
33673+ if (len > pax_task_size)
33674 return -ENOMEM;
33675
33676 if (flags & MAP_FIXED) {
33677@@ -140,19 +158,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
33678 return addr;
33679 }
33680
33681+#ifdef CONFIG_PAX_RANDMMAP
33682+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33683+#endif
33684+
33685 if (addr) {
33686 addr = ALIGN(addr, huge_page_size(h));
33687 vma = find_vma(mm, addr);
33688- if (TASK_SIZE - len >= addr &&
33689- (!vma || addr + len <= vma->vm_start))
33690+ if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
33691 return addr;
33692 }
33693 if (mm->get_unmapped_area == arch_get_unmapped_area)
33694 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
33695- pgoff, flags);
33696+ pgoff, flags, offset);
33697 else
33698 return hugetlb_get_unmapped_area_topdown(file, addr, len,
33699- pgoff, flags);
33700+ pgoff, flags, offset);
33701 }
33702 #endif /* CONFIG_HUGETLB_PAGE */
33703
33704diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
33705index 8533b46..8c83176 100644
33706--- a/arch/x86/mm/init.c
33707+++ b/arch/x86/mm/init.c
33708@@ -4,6 +4,7 @@
33709 #include <linux/swap.h>
33710 #include <linux/memblock.h>
33711 #include <linux/bootmem.h> /* for max_low_pfn */
33712+#include <linux/tboot.h>
33713
33714 #include <asm/cacheflush.h>
33715 #include <asm/e820.h>
33716@@ -17,6 +18,8 @@
33717 #include <asm/proto.h>
33718 #include <asm/dma.h> /* for MAX_DMA_PFN */
33719 #include <asm/microcode.h>
33720+#include <asm/desc.h>
33721+#include <asm/bios_ebda.h>
33722
33723 /*
33724 * We need to define the tracepoints somewhere, and tlb.c
33725@@ -615,7 +618,18 @@ void __init init_mem_mapping(void)
33726 early_ioremap_page_table_range_init();
33727 #endif
33728
33729+#ifdef CONFIG_PAX_PER_CPU_PGD
33730+ clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
33731+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
33732+ KERNEL_PGD_PTRS);
33733+ clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
33734+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
33735+ KERNEL_PGD_PTRS);
33736+ load_cr3(get_cpu_pgd(0, kernel));
33737+#else
33738 load_cr3(swapper_pg_dir);
33739+#endif
33740+
33741 __flush_tlb_all();
33742
33743 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
33744@@ -631,10 +645,40 @@ void __init init_mem_mapping(void)
33745 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
33746 * mmio resources as well as potential bios/acpi data regions.
33747 */
33748+
33749+#ifdef CONFIG_GRKERNSEC_KMEM
33750+static unsigned int ebda_start __read_only;
33751+static unsigned int ebda_end __read_only;
33752+#endif
33753+
33754 int devmem_is_allowed(unsigned long pagenr)
33755 {
33756- if (pagenr < 256)
33757+#ifdef CONFIG_GRKERNSEC_KMEM
33758+ /* allow BDA */
33759+ if (!pagenr)
33760 return 1;
33761+ /* allow EBDA */
33762+ if (pagenr >= ebda_start && pagenr < ebda_end)
33763+ return 1;
33764+ /* if tboot is in use, allow access to its hardcoded serial log range */
33765+ if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
33766+ return 1;
33767+#else
33768+ if (!pagenr)
33769+ return 1;
33770+#ifdef CONFIG_VM86
33771+ if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
33772+ return 1;
33773+#endif
33774+#endif
33775+
33776+ if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
33777+ return 1;
33778+#ifdef CONFIG_GRKERNSEC_KMEM
33779+ /* throw out everything else below 1MB */
33780+ if (pagenr <= 256)
33781+ return 0;
33782+#endif
33783 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
33784 return 0;
33785 if (!page_is_ram(pagenr))
33786@@ -680,8 +724,127 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
33787 #endif
33788 }
33789
33790+#ifdef CONFIG_GRKERNSEC_KMEM
33791+static inline void gr_init_ebda(void)
33792+{
33793+ unsigned int ebda_addr;
33794+ unsigned int ebda_size = 0;
33795+
33796+ ebda_addr = get_bios_ebda();
33797+ if (ebda_addr) {
33798+ ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
33799+ ebda_size <<= 10;
33800+ }
33801+ if (ebda_addr && ebda_size) {
33802+ ebda_start = ebda_addr >> PAGE_SHIFT;
33803+ ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
33804+ } else {
33805+ ebda_start = 0x9f000 >> PAGE_SHIFT;
33806+ ebda_end = 0xa0000 >> PAGE_SHIFT;
33807+ }
33808+}
33809+#else
33810+static inline void gr_init_ebda(void) { }
33811+#endif
33812+
33813 void free_initmem(void)
33814 {
33815+#ifdef CONFIG_PAX_KERNEXEC
33816+#ifdef CONFIG_X86_32
33817+ /* PaX: limit KERNEL_CS to actual size */
33818+ unsigned long addr, limit;
33819+ struct desc_struct d;
33820+ int cpu;
33821+#else
33822+ pgd_t *pgd;
33823+ pud_t *pud;
33824+ pmd_t *pmd;
33825+ unsigned long addr, end;
33826+#endif
33827+#endif
33828+
33829+ gr_init_ebda();
33830+
33831+#ifdef CONFIG_PAX_KERNEXEC
33832+#ifdef CONFIG_X86_32
33833+ limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
33834+ limit = (limit - 1UL) >> PAGE_SHIFT;
33835+
33836+ memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
33837+ for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
33838+ pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
33839+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
33840+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
33841+ }
33842+
33843+ /* PaX: make KERNEL_CS read-only */
33844+ addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
33845+ if (!paravirt_enabled())
33846+ set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
33847+/*
33848+ for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
33849+ pgd = pgd_offset_k(addr);
33850+ pud = pud_offset(pgd, addr);
33851+ pmd = pmd_offset(pud, addr);
33852+ set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
33853+ }
33854+*/
33855+#ifdef CONFIG_X86_PAE
33856+ set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
33857+/*
33858+ for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
33859+ pgd = pgd_offset_k(addr);
33860+ pud = pud_offset(pgd, addr);
33861+ pmd = pmd_offset(pud, addr);
33862+ set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
33863+ }
33864+*/
33865+#endif
33866+
33867+#ifdef CONFIG_MODULES
33868+ set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
33869+#endif
33870+
33871+#else
33872+ /* PaX: make kernel code/rodata read-only, rest non-executable */
33873+ set_memory_ro((unsigned long)_text, ((unsigned long)(_sdata - _text) >> PAGE_SHIFT));
33874+ set_memory_nx((unsigned long)_sdata, (__START_KERNEL_map + KERNEL_IMAGE_SIZE - (unsigned long)_sdata) >> PAGE_SHIFT);
33875+
33876+ for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
33877+ pgd = pgd_offset_k(addr);
33878+ pud = pud_offset(pgd, addr);
33879+ pmd = pmd_offset(pud, addr);
33880+ if (!pmd_present(*pmd))
33881+ continue;
33882+ if (addr >= (unsigned long)_text)
33883+ BUG_ON(!pmd_large(*pmd));
33884+ if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
33885+ BUG_ON(pmd_write(*pmd));
33886+// set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
33887+ else
33888+ BUG_ON(!(pmd_flags(*pmd) & _PAGE_NX));
33889+// set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
33890+ }
33891+
33892+ addr = (unsigned long)__va(__pa(__START_KERNEL_map));
33893+ end = addr + KERNEL_IMAGE_SIZE;
33894+ for (; addr < end; addr += PMD_SIZE) {
33895+ pgd = pgd_offset_k(addr);
33896+ pud = pud_offset(pgd, addr);
33897+ pmd = pmd_offset(pud, addr);
33898+ if (!pmd_present(*pmd))
33899+ continue;
33900+ if (addr >= (unsigned long)_text)
33901+ BUG_ON(!pmd_large(*pmd));
33902+ if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
33903+ BUG_ON(pmd_write(*pmd));
33904+// set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
33905+ }
33906+#endif
33907+
33908+ flush_tlb_all();
33909+#endif
33910+
33911 free_init_pages("unused kernel",
33912 (unsigned long)(&__init_begin),
33913 (unsigned long)(&__init_end));
33914diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
33915index 68aec42..95ad5d3 100644
33916--- a/arch/x86/mm/init_32.c
33917+++ b/arch/x86/mm/init_32.c
33918@@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
33919 bool __read_mostly __vmalloc_start_set = false;
33920
33921 /*
33922- * Creates a middle page table and puts a pointer to it in the
33923- * given global directory entry. This only returns the gd entry
33924- * in non-PAE compilation mode, since the middle layer is folded.
33925- */
33926-static pmd_t * __init one_md_table_init(pgd_t *pgd)
33927-{
33928- pud_t *pud;
33929- pmd_t *pmd_table;
33930-
33931-#ifdef CONFIG_X86_PAE
33932- if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
33933- pmd_table = (pmd_t *)alloc_low_page();
33934- paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
33935- set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
33936- pud = pud_offset(pgd, 0);
33937- BUG_ON(pmd_table != pmd_offset(pud, 0));
33938-
33939- return pmd_table;
33940- }
33941-#endif
33942- pud = pud_offset(pgd, 0);
33943- pmd_table = pmd_offset(pud, 0);
33944-
33945- return pmd_table;
33946-}
33947-
33948-/*
33949 * Create a page table and place a pointer to it in a middle page
33950 * directory entry:
33951 */
33952@@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
33953 pte_t *page_table = (pte_t *)alloc_low_page();
33954
33955 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
33956+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
33957+ set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
33958+#else
33959 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
33960+#endif
33961 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
33962 }
33963
33964 return pte_offset_kernel(pmd, 0);
33965 }
33966
33967+static pmd_t * __init one_md_table_init(pgd_t *pgd)
33968+{
33969+ pud_t *pud;
33970+ pmd_t *pmd_table;
33971+
33972+ pud = pud_offset(pgd, 0);
33973+ pmd_table = pmd_offset(pud, 0);
33974+
33975+ return pmd_table;
33976+}
33977+
33978 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
33979 {
33980 int pgd_idx = pgd_index(vaddr);
33981@@ -209,6 +197,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
33982 int pgd_idx, pmd_idx;
33983 unsigned long vaddr;
33984 pgd_t *pgd;
33985+ pud_t *pud;
33986 pmd_t *pmd;
33987 pte_t *pte = NULL;
33988 unsigned long count = page_table_range_init_count(start, end);
33989@@ -223,8 +212,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
33990 pgd = pgd_base + pgd_idx;
33991
33992 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
33993- pmd = one_md_table_init(pgd);
33994- pmd = pmd + pmd_index(vaddr);
33995+ pud = pud_offset(pgd, vaddr);
33996+ pmd = pmd_offset(pud, vaddr);
33997+
33998+#ifdef CONFIG_X86_PAE
33999+ paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
34000+#endif
34001+
34002 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
34003 pmd++, pmd_idx++) {
34004 pte = page_table_kmap_check(one_page_table_init(pmd),
34005@@ -236,11 +230,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
34006 }
34007 }
34008
34009-static inline int is_kernel_text(unsigned long addr)
34010+static inline int is_kernel_text(unsigned long start, unsigned long end)
34011 {
34012- if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
34013- return 1;
34014- return 0;
34015+ if ((start >= ktla_ktva((unsigned long)_etext) ||
34016+ end <= ktla_ktva((unsigned long)_stext)) &&
34017+ (start >= ktla_ktva((unsigned long)_einittext) ||
34018+ end <= ktla_ktva((unsigned long)_sinittext)) &&
34019+
34020+#ifdef CONFIG_ACPI_SLEEP
34021+ (start >= (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
34022+#endif
34023+
34024+ (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
34025+ return 0;
34026+ return 1;
34027 }
34028
34029 /*
34030@@ -257,9 +260,10 @@ kernel_physical_mapping_init(unsigned long start,
34031 unsigned long last_map_addr = end;
34032 unsigned long start_pfn, end_pfn;
34033 pgd_t *pgd_base = swapper_pg_dir;
34034- int pgd_idx, pmd_idx, pte_ofs;
34035+ unsigned int pgd_idx, pmd_idx, pte_ofs;
34036 unsigned long pfn;
34037 pgd_t *pgd;
34038+ pud_t *pud;
34039 pmd_t *pmd;
34040 pte_t *pte;
34041 unsigned pages_2m, pages_4k;
34042@@ -292,8 +296,13 @@ repeat:
34043 pfn = start_pfn;
34044 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
34045 pgd = pgd_base + pgd_idx;
34046- for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
34047- pmd = one_md_table_init(pgd);
34048+ for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
34049+ pud = pud_offset(pgd, 0);
34050+ pmd = pmd_offset(pud, 0);
34051+
34052+#ifdef CONFIG_X86_PAE
34053+ paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
34054+#endif
34055
34056 if (pfn >= end_pfn)
34057 continue;
34058@@ -305,14 +314,13 @@ repeat:
34059 #endif
34060 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
34061 pmd++, pmd_idx++) {
34062- unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
34063+ unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
34064
34065 /*
34066 * Map with big pages if possible, otherwise
34067 * create normal page tables:
34068 */
34069 if (use_pse) {
34070- unsigned int addr2;
34071 pgprot_t prot = PAGE_KERNEL_LARGE;
34072 /*
34073 * first pass will use the same initial
34074@@ -323,11 +331,7 @@ repeat:
34075 _PAGE_PSE);
34076
34077 pfn &= PMD_MASK >> PAGE_SHIFT;
34078- addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
34079- PAGE_OFFSET + PAGE_SIZE-1;
34080-
34081- if (is_kernel_text(addr) ||
34082- is_kernel_text(addr2))
34083+ if (is_kernel_text(address, address + PMD_SIZE))
34084 prot = PAGE_KERNEL_LARGE_EXEC;
34085
34086 pages_2m++;
34087@@ -344,7 +348,7 @@ repeat:
34088 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
34089 pte += pte_ofs;
34090 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
34091- pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
34092+ pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
34093 pgprot_t prot = PAGE_KERNEL;
34094 /*
34095 * first pass will use the same initial
34096@@ -352,7 +356,7 @@ repeat:
34097 */
34098 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
34099
34100- if (is_kernel_text(addr))
34101+ if (is_kernel_text(address, address + PAGE_SIZE))
34102 prot = PAGE_KERNEL_EXEC;
34103
34104 pages_4k++;
34105@@ -475,7 +479,7 @@ void __init native_pagetable_init(void)
34106
34107 pud = pud_offset(pgd, va);
34108 pmd = pmd_offset(pud, va);
34109- if (!pmd_present(*pmd))
34110+ if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
34111 break;
34112
34113 /* should not be large page here */
34114@@ -533,12 +537,10 @@ void __init early_ioremap_page_table_range_init(void)
34115
34116 static void __init pagetable_init(void)
34117 {
34118- pgd_t *pgd_base = swapper_pg_dir;
34119-
34120- permanent_kmaps_init(pgd_base);
34121+ permanent_kmaps_init(swapper_pg_dir);
34122 }
34123
34124-pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL);
34125+pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL);
34126 EXPORT_SYMBOL_GPL(__supported_pte_mask);
34127
34128 /* user-defined highmem size */
34129@@ -788,10 +790,10 @@ void __init mem_init(void)
34130 ((unsigned long)&__init_end -
34131 (unsigned long)&__init_begin) >> 10,
34132
34133- (unsigned long)&_etext, (unsigned long)&_edata,
34134- ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
34135+ (unsigned long)&_sdata, (unsigned long)&_edata,
34136+ ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
34137
34138- (unsigned long)&_text, (unsigned long)&_etext,
34139+ ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
34140 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
34141
34142 /*
34143@@ -885,6 +887,7 @@ void set_kernel_text_rw(void)
34144 if (!kernel_set_to_readonly)
34145 return;
34146
34147+ start = ktla_ktva(start);
34148 pr_debug("Set kernel text: %lx - %lx for read write\n",
34149 start, start+size);
34150
34151@@ -899,6 +902,7 @@ void set_kernel_text_ro(void)
34152 if (!kernel_set_to_readonly)
34153 return;
34154
34155+ start = ktla_ktva(start);
34156 pr_debug("Set kernel text: %lx - %lx for read only\n",
34157 start, start+size);
34158
34159@@ -927,6 +931,7 @@ void mark_rodata_ro(void)
34160 unsigned long start = PFN_ALIGN(_text);
34161 unsigned long size = PFN_ALIGN(_etext) - start;
34162
34163+ start = ktla_ktva(start);
34164 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
34165 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
34166 size >> 10);
34167diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
34168index f9977a7..21a5082 100644
34169--- a/arch/x86/mm/init_64.c
34170+++ b/arch/x86/mm/init_64.c
34171@@ -136,7 +136,7 @@ int kernel_ident_mapping_init(struct x86_mapping_info *info, pgd_t *pgd_page,
34172 * around without checking the pgd every time.
34173 */
34174
34175-pteval_t __supported_pte_mask __read_mostly = ~0;
34176+pteval_t __supported_pte_mask __read_only = ~_PAGE_NX;
34177 EXPORT_SYMBOL_GPL(__supported_pte_mask);
34178
34179 int force_personality32;
34180@@ -169,7 +169,12 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
34181
34182 for (address = start; address <= end; address += PGDIR_SIZE) {
34183 const pgd_t *pgd_ref = pgd_offset_k(address);
34184+
34185+#ifdef CONFIG_PAX_PER_CPU_PGD
34186+ unsigned long cpu;
34187+#else
34188 struct page *page;
34189+#endif
34190
34191 /*
34192 * When it is called after memory hot remove, pgd_none()
34193@@ -180,6 +185,25 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
34194 continue;
34195
34196 spin_lock(&pgd_lock);
34197+
34198+#ifdef CONFIG_PAX_PER_CPU_PGD
34199+ for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
34200+ pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
34201+
34202+ if (!pgd_none(*pgd_ref) && !pgd_none(*pgd))
34203+ BUG_ON(pgd_page_vaddr(*pgd)
34204+ != pgd_page_vaddr(*pgd_ref));
34205+
34206+ if (removed) {
34207+ if (pgd_none(*pgd_ref) && !pgd_none(*pgd))
34208+ pgd_clear(pgd);
34209+ } else {
34210+ if (pgd_none(*pgd))
34211+ set_pgd(pgd, *pgd_ref);
34212+ }
34213+
34214+ pgd = pgd_offset_cpu(cpu, kernel, address);
34215+#else
34216 list_for_each_entry(page, &pgd_list, lru) {
34217 pgd_t *pgd;
34218 spinlock_t *pgt_lock;
34219@@ -188,6 +212,7 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
34220 /* the pgt_lock only for Xen */
34221 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
34222 spin_lock(pgt_lock);
34223+#endif
34224
34225 if (!pgd_none(*pgd_ref) && !pgd_none(*pgd))
34226 BUG_ON(pgd_page_vaddr(*pgd)
34227@@ -201,7 +226,10 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
34228 set_pgd(pgd, *pgd_ref);
34229 }
34230
34231+#ifndef CONFIG_PAX_PER_CPU_PGD
34232 spin_unlock(pgt_lock);
34233+#endif
34234+
34235 }
34236 spin_unlock(&pgd_lock);
34237 }
34238@@ -234,7 +262,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
34239 {
34240 if (pgd_none(*pgd)) {
34241 pud_t *pud = (pud_t *)spp_getpage();
34242- pgd_populate(&init_mm, pgd, pud);
34243+ pgd_populate_kernel(&init_mm, pgd, pud);
34244 if (pud != pud_offset(pgd, 0))
34245 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
34246 pud, pud_offset(pgd, 0));
34247@@ -246,7 +274,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
34248 {
34249 if (pud_none(*pud)) {
34250 pmd_t *pmd = (pmd_t *) spp_getpage();
34251- pud_populate(&init_mm, pud, pmd);
34252+ pud_populate_kernel(&init_mm, pud, pmd);
34253 if (pmd != pmd_offset(pud, 0))
34254 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
34255 pmd, pmd_offset(pud, 0));
34256@@ -275,7 +303,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
34257 pmd = fill_pmd(pud, vaddr);
34258 pte = fill_pte(pmd, vaddr);
34259
34260+ pax_open_kernel();
34261 set_pte(pte, new_pte);
34262+ pax_close_kernel();
34263
34264 /*
34265 * It's enough to flush this one mapping.
34266@@ -337,14 +367,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
34267 pgd = pgd_offset_k((unsigned long)__va(phys));
34268 if (pgd_none(*pgd)) {
34269 pud = (pud_t *) spp_getpage();
34270- set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
34271- _PAGE_USER));
34272+ set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
34273 }
34274 pud = pud_offset(pgd, (unsigned long)__va(phys));
34275 if (pud_none(*pud)) {
34276 pmd = (pmd_t *) spp_getpage();
34277- set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
34278- _PAGE_USER));
34279+ set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
34280 }
34281 pmd = pmd_offset(pud, phys);
34282 BUG_ON(!pmd_none(*pmd));
34283@@ -585,7 +613,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
34284 prot);
34285
34286 spin_lock(&init_mm.page_table_lock);
34287- pud_populate(&init_mm, pud, pmd);
34288+ pud_populate_kernel(&init_mm, pud, pmd);
34289 spin_unlock(&init_mm.page_table_lock);
34290 }
34291 __flush_tlb_all();
34292@@ -626,7 +654,7 @@ kernel_physical_mapping_init(unsigned long start,
34293 page_size_mask);
34294
34295 spin_lock(&init_mm.page_table_lock);
34296- pgd_populate(&init_mm, pgd, pud);
34297+ pgd_populate_kernel(&init_mm, pgd, pud);
34298 spin_unlock(&init_mm.page_table_lock);
34299 pgd_changed = true;
34300 }
34301diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
34302index 9c0ff04..9020d5f 100644
34303--- a/arch/x86/mm/iomap_32.c
34304+++ b/arch/x86/mm/iomap_32.c
34305@@ -65,7 +65,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
34306 type = kmap_atomic_idx_push();
34307 idx = type + KM_TYPE_NR * smp_processor_id();
34308 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
34309+
34310+ pax_open_kernel();
34311 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
34312+ pax_close_kernel();
34313+
34314 arch_flush_lazy_mmu_mode();
34315
34316 return (void *)vaddr;
34317diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
34318index b9c78f3..9ca7e24 100644
34319--- a/arch/x86/mm/ioremap.c
34320+++ b/arch/x86/mm/ioremap.c
34321@@ -59,8 +59,8 @@ static int __ioremap_check_ram(unsigned long start_pfn, unsigned long nr_pages,
34322 unsigned long i;
34323
34324 for (i = 0; i < nr_pages; ++i)
34325- if (pfn_valid(start_pfn + i) &&
34326- !PageReserved(pfn_to_page(start_pfn + i)))
34327+ if (pfn_valid(start_pfn + i) && (start_pfn + i >= 0x100 ||
34328+ !PageReserved(pfn_to_page(start_pfn + i))))
34329 return 1;
34330
34331 return 0;
34332@@ -332,7 +332,7 @@ EXPORT_SYMBOL(ioremap_prot);
34333 *
34334 * Caller must ensure there is only one unmapping for the same pointer.
34335 */
34336-void iounmap(volatile void __iomem *addr)
34337+void iounmap(const volatile void __iomem *addr)
34338 {
34339 struct vm_struct *p, *o;
34340
34341@@ -395,31 +395,37 @@ int __init arch_ioremap_pmd_supported(void)
34342 */
34343 void *xlate_dev_mem_ptr(phys_addr_t phys)
34344 {
34345- unsigned long start = phys & PAGE_MASK;
34346- unsigned long offset = phys & ~PAGE_MASK;
34347- void *vaddr;
34348+ phys_addr_t pfn = phys >> PAGE_SHIFT;
34349
34350- /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
34351- if (page_is_ram(start >> PAGE_SHIFT))
34352- return __va(phys);
34353+ if (page_is_ram(pfn)) {
34354+#ifdef CONFIG_HIGHMEM
34355+ if (pfn >= max_low_pfn)
34356+ return kmap_high(pfn_to_page(pfn));
34357+ else
34358+#endif
34359+ return __va(phys);
34360+ }
34361
34362- vaddr = ioremap_cache(start, PAGE_SIZE);
34363- /* Only add the offset on success and return NULL if the ioremap() failed: */
34364- if (vaddr)
34365- vaddr += offset;
34366-
34367- return vaddr;
34368+ return (void __force *)ioremap_cache(phys, 1);
34369 }
34370
34371 void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
34372 {
34373- if (page_is_ram(phys >> PAGE_SHIFT))
34374+ phys_addr_t pfn = phys >> PAGE_SHIFT;
34375+
34376+ if (page_is_ram(pfn)) {
34377+#ifdef CONFIG_HIGHMEM
34378+ if (pfn >= max_low_pfn)
34379+ kunmap_high(pfn_to_page(pfn));
34380+#endif
34381 return;
34382+ }
34383
34384- iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
34385+ iounmap((void __iomem __force *)addr);
34386 }
34387
34388-static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
34389+static pte_t __bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
34390+static pte_t *bm_pte __read_only = __bm_pte;
34391
34392 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
34393 {
34394@@ -455,8 +461,14 @@ void __init early_ioremap_init(void)
34395 early_ioremap_setup();
34396
34397 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
34398- memset(bm_pte, 0, sizeof(bm_pte));
34399- pmd_populate_kernel(&init_mm, pmd, bm_pte);
34400+ if (pmd_none(*pmd))
34401+#ifdef CONFIG_COMPAT_VDSO
34402+ pmd_populate_user(&init_mm, pmd, __bm_pte);
34403+#else
34404+ pmd_populate_kernel(&init_mm, pmd, __bm_pte);
34405+#endif
34406+ else
34407+ bm_pte = (pte_t *)pmd_page_vaddr(*pmd);
34408
34409 /*
34410 * The boot-ioremap range spans multiple pmds, for which
34411diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
34412index b4f2e7e..96c9c3e 100644
34413--- a/arch/x86/mm/kmemcheck/kmemcheck.c
34414+++ b/arch/x86/mm/kmemcheck/kmemcheck.c
34415@@ -628,9 +628,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
34416 * memory (e.g. tracked pages)? For now, we need this to avoid
34417 * invoking kmemcheck for PnP BIOS calls.
34418 */
34419- if (regs->flags & X86_VM_MASK)
34420+ if (v8086_mode(regs))
34421 return false;
34422- if (regs->cs != __KERNEL_CS)
34423+ if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
34424 return false;
34425
34426 pte = kmemcheck_pte_lookup(address);
34427diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
34428index 844b06d..f363c86 100644
34429--- a/arch/x86/mm/mmap.c
34430+++ b/arch/x86/mm/mmap.c
34431@@ -52,7 +52,7 @@ static unsigned long stack_maxrandom_size(void)
34432 * Leave an at least ~128 MB hole with possible stack randomization.
34433 */
34434 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
34435-#define MAX_GAP (TASK_SIZE/6*5)
34436+#define MAX_GAP (pax_task_size/6*5)
34437
34438 static int mmap_is_legacy(void)
34439 {
34440@@ -81,27 +81,40 @@ unsigned long arch_mmap_rnd(void)
34441 return rnd << PAGE_SHIFT;
34442 }
34443
34444-static unsigned long mmap_base(unsigned long rnd)
34445+static unsigned long mmap_base(struct mm_struct *mm, unsigned long rnd)
34446 {
34447 unsigned long gap = rlimit(RLIMIT_STACK);
34448+ unsigned long pax_task_size = TASK_SIZE;
34449+
34450+#ifdef CONFIG_PAX_SEGMEXEC
34451+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
34452+ pax_task_size = SEGMEXEC_TASK_SIZE;
34453+#endif
34454
34455 if (gap < MIN_GAP)
34456 gap = MIN_GAP;
34457 else if (gap > MAX_GAP)
34458 gap = MAX_GAP;
34459
34460- return PAGE_ALIGN(TASK_SIZE - gap - rnd);
34461+ return PAGE_ALIGN(pax_task_size - gap - rnd);
34462 }
34463
34464 /*
34465 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
34466 * does, but not when emulating X86_32
34467 */
34468-static unsigned long mmap_legacy_base(unsigned long rnd)
34469+static unsigned long mmap_legacy_base(struct mm_struct *mm, unsigned long rnd)
34470 {
34471- if (mmap_is_ia32())
34472+ if (mmap_is_ia32()) {
34473+
34474+#ifdef CONFIG_PAX_SEGMEXEC
34475+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
34476+ return SEGMEXEC_TASK_UNMAPPED_BASE;
34477+ else
34478+#endif
34479+
34480 return TASK_UNMAPPED_BASE;
34481- else
34482+ } else
34483 return TASK_UNMAPPED_BASE + rnd;
34484 }
34485
34486@@ -113,18 +126,29 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
34487 {
34488 unsigned long random_factor = 0UL;
34489
34490+#ifdef CONFIG_PAX_RANDMMAP
34491+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
34492+#endif
34493 if (current->flags & PF_RANDOMIZE)
34494 random_factor = arch_mmap_rnd();
34495
34496- mm->mmap_legacy_base = mmap_legacy_base(random_factor);
34497+ mm->mmap_legacy_base = mmap_legacy_base(mm, random_factor);
34498
34499 if (mmap_is_legacy()) {
34500 mm->mmap_base = mm->mmap_legacy_base;
34501 mm->get_unmapped_area = arch_get_unmapped_area;
34502 } else {
34503- mm->mmap_base = mmap_base(random_factor);
34504+ mm->mmap_base = mmap_base(mm, random_factor);
34505 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
34506 }
34507+
34508+#ifdef CONFIG_PAX_RANDMMAP
34509+ if (mm->pax_flags & MF_PAX_RANDMMAP) {
34510+ mm->mmap_legacy_base += mm->delta_mmap;
34511+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
34512+ }
34513+#endif
34514+
34515 }
34516
34517 const char *arch_vma_name(struct vm_area_struct *vma)
34518diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
34519index 0057a7a..95c7edd 100644
34520--- a/arch/x86/mm/mmio-mod.c
34521+++ b/arch/x86/mm/mmio-mod.c
34522@@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
34523 break;
34524 default:
34525 {
34526- unsigned char *ip = (unsigned char *)instptr;
34527+ unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
34528 my_trace->opcode = MMIO_UNKNOWN_OP;
34529 my_trace->width = 0;
34530 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
34531@@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
34532 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
34533 void __iomem *addr)
34534 {
34535- static atomic_t next_id;
34536+ static atomic_unchecked_t next_id;
34537 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
34538 /* These are page-unaligned. */
34539 struct mmiotrace_map map = {
34540@@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
34541 .private = trace
34542 },
34543 .phys = offset,
34544- .id = atomic_inc_return(&next_id)
34545+ .id = atomic_inc_return_unchecked(&next_id)
34546 };
34547 map.map_id = trace->id;
34548
34549@@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
34550 ioremap_trace_core(offset, size, addr);
34551 }
34552
34553-static void iounmap_trace_core(volatile void __iomem *addr)
34554+static void iounmap_trace_core(const volatile void __iomem *addr)
34555 {
34556 struct mmiotrace_map map = {
34557 .phys = 0,
34558@@ -328,7 +328,7 @@ not_enabled:
34559 }
34560 }
34561
34562-void mmiotrace_iounmap(volatile void __iomem *addr)
34563+void mmiotrace_iounmap(const volatile void __iomem *addr)
34564 {
34565 might_sleep();
34566 if (is_enabled()) /* recheck and proper locking in *_core() */
34567diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
34568index 4053bb5..b1ad3dc 100644
34569--- a/arch/x86/mm/numa.c
34570+++ b/arch/x86/mm/numa.c
34571@@ -506,7 +506,7 @@ static void __init numa_clear_kernel_node_hotplug(void)
34572 }
34573 }
34574
34575-static int __init numa_register_memblks(struct numa_meminfo *mi)
34576+static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
34577 {
34578 unsigned long uninitialized_var(pfn_align);
34579 int i, nid;
34580diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
34581index 727158c..54dd3ff 100644
34582--- a/arch/x86/mm/pageattr.c
34583+++ b/arch/x86/mm/pageattr.c
34584@@ -260,7 +260,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
34585 */
34586 #ifdef CONFIG_PCI_BIOS
34587 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
34588- pgprot_val(forbidden) |= _PAGE_NX;
34589+ pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
34590 #endif
34591
34592 /*
34593@@ -268,9 +268,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
34594 * Does not cover __inittext since that is gone later on. On
34595 * 64bit we do not enforce !NX on the low mapping
34596 */
34597- if (within(address, (unsigned long)_text, (unsigned long)_etext))
34598- pgprot_val(forbidden) |= _PAGE_NX;
34599+ if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
34600+ pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
34601
34602+#ifdef CONFIG_DEBUG_RODATA
34603 /*
34604 * The .rodata section needs to be read-only. Using the pfn
34605 * catches all aliases.
34606@@ -278,6 +279,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
34607 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
34608 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
34609 pgprot_val(forbidden) |= _PAGE_RW;
34610+#endif
34611
34612 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
34613 /*
34614@@ -316,6 +318,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
34615 }
34616 #endif
34617
34618+#ifdef CONFIG_PAX_KERNEXEC
34619+ if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
34620+ pgprot_val(forbidden) |= _PAGE_RW;
34621+ pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
34622+ }
34623+#endif
34624+
34625 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
34626
34627 return prot;
34628@@ -436,23 +445,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
34629 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
34630 {
34631 /* change init_mm */
34632+ pax_open_kernel();
34633 set_pte_atomic(kpte, pte);
34634+
34635 #ifdef CONFIG_X86_32
34636 if (!SHARED_KERNEL_PMD) {
34637+
34638+#ifdef CONFIG_PAX_PER_CPU_PGD
34639+ unsigned long cpu;
34640+#else
34641 struct page *page;
34642+#endif
34643
34644+#ifdef CONFIG_PAX_PER_CPU_PGD
34645+ for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
34646+ pgd_t *pgd = get_cpu_pgd(cpu, kernel);
34647+#else
34648 list_for_each_entry(page, &pgd_list, lru) {
34649- pgd_t *pgd;
34650+ pgd_t *pgd = (pgd_t *)page_address(page);
34651+#endif
34652+
34653 pud_t *pud;
34654 pmd_t *pmd;
34655
34656- pgd = (pgd_t *)page_address(page) + pgd_index(address);
34657+ pgd += pgd_index(address);
34658 pud = pud_offset(pgd, address);
34659 pmd = pmd_offset(pud, address);
34660 set_pte_atomic((pte_t *)pmd, pte);
34661 }
34662 }
34663 #endif
34664+ pax_close_kernel();
34665 }
34666
34667 static int
34668@@ -505,7 +528,8 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
34669 * up accordingly.
34670 */
34671 old_pte = *kpte;
34672- old_prot = req_prot = pgprot_large_2_4k(pte_pgprot(old_pte));
34673+ old_prot = pte_pgprot(old_pte);
34674+ req_prot = pgprot_large_2_4k(old_prot);
34675
34676 pgprot_val(req_prot) &= ~pgprot_val(cpa->mask_clr);
34677 pgprot_val(req_prot) |= pgprot_val(cpa->mask_set);
34678@@ -1176,7 +1200,9 @@ repeat:
34679 * Do we really change anything ?
34680 */
34681 if (pte_val(old_pte) != pte_val(new_pte)) {
34682+ pax_open_kernel();
34683 set_pte_atomic(kpte, new_pte);
34684+ pax_close_kernel();
34685 cpa->flags |= CPA_FLUSHTLB;
34686 }
34687 cpa->numpages = 1;
34688diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
34689index 188e3e0..5c75446 100644
34690--- a/arch/x86/mm/pat.c
34691+++ b/arch/x86/mm/pat.c
34692@@ -588,7 +588,7 @@ int free_memtype(u64 start, u64 end)
34693
34694 if (!entry) {
34695 pr_info("x86/PAT: %s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
34696- current->comm, current->pid, start, end - 1);
34697+ current->comm, task_pid_nr(current), start, end - 1);
34698 return -EINVAL;
34699 }
34700
34701@@ -711,8 +711,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34702
34703 while (cursor < to) {
34704 if (!devmem_is_allowed(pfn)) {
34705- pr_info("x86/PAT: Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx], PAT prevents it\n",
34706- current->comm, from, to - 1);
34707+ pr_info("x86/PAT: Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx), PAT prevents it\n",
34708+ current->comm, from, to - 1, cursor);
34709 return 0;
34710 }
34711 cursor += PAGE_SIZE;
34712@@ -782,7 +782,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size,
34713
34714 if (ioremap_change_attr((unsigned long)__va(base), id_sz, pcm) < 0) {
34715 pr_info("x86/PAT: %s:%d ioremap_change_attr failed %s for [mem %#010Lx-%#010Lx]\n",
34716- current->comm, current->pid,
34717+ current->comm, task_pid_nr(current),
34718 cattr_name(pcm),
34719 base, (unsigned long long)(base + size-1));
34720 return -EINVAL;
34721@@ -817,7 +817,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
34722 pcm = lookup_memtype(paddr);
34723 if (want_pcm != pcm) {
34724 pr_warn("x86/PAT: %s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
34725- current->comm, current->pid,
34726+ current->comm, task_pid_nr(current),
34727 cattr_name(want_pcm),
34728 (unsigned long long)paddr,
34729 (unsigned long long)(paddr + size - 1),
34730@@ -838,7 +838,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
34731 !is_new_memtype_allowed(paddr, size, want_pcm, pcm)) {
34732 free_memtype(paddr, paddr + size);
34733 pr_err("x86/PAT: %s:%d map pfn expected mapping type %s for [mem %#010Lx-%#010Lx], got %s\n",
34734- current->comm, current->pid,
34735+ current->comm, task_pid_nr(current),
34736 cattr_name(want_pcm),
34737 (unsigned long long)paddr,
34738 (unsigned long long)(paddr + size - 1),
34739diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
34740index 6393108..890adda 100644
34741--- a/arch/x86/mm/pat_rbtree.c
34742+++ b/arch/x86/mm/pat_rbtree.c
34743@@ -161,7 +161,7 @@ success:
34744
34745 failure:
34746 pr_info("x86/PAT: %s:%d conflicting memory types %Lx-%Lx %s<->%s\n",
34747- current->comm, current->pid, start, end,
34748+ current->comm, task_pid_nr(current), start, end,
34749 cattr_name(found_type), cattr_name(match->type));
34750 return -EBUSY;
34751 }
34752diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
34753index 9f0614d..92ae64a 100644
34754--- a/arch/x86/mm/pf_in.c
34755+++ b/arch/x86/mm/pf_in.c
34756@@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
34757 int i;
34758 enum reason_type rv = OTHERS;
34759
34760- p = (unsigned char *)ins_addr;
34761+ p = (unsigned char *)ktla_ktva(ins_addr);
34762 p += skip_prefix(p, &prf);
34763 p += get_opcode(p, &opcode);
34764
34765@@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
34766 struct prefix_bits prf;
34767 int i;
34768
34769- p = (unsigned char *)ins_addr;
34770+ p = (unsigned char *)ktla_ktva(ins_addr);
34771 p += skip_prefix(p, &prf);
34772 p += get_opcode(p, &opcode);
34773
34774@@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
34775 struct prefix_bits prf;
34776 int i;
34777
34778- p = (unsigned char *)ins_addr;
34779+ p = (unsigned char *)ktla_ktva(ins_addr);
34780 p += skip_prefix(p, &prf);
34781 p += get_opcode(p, &opcode);
34782
34783@@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
34784 struct prefix_bits prf;
34785 int i;
34786
34787- p = (unsigned char *)ins_addr;
34788+ p = (unsigned char *)ktla_ktva(ins_addr);
34789 p += skip_prefix(p, &prf);
34790 p += get_opcode(p, &opcode);
34791 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
34792@@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
34793 struct prefix_bits prf;
34794 int i;
34795
34796- p = (unsigned char *)ins_addr;
34797+ p = (unsigned char *)ktla_ktva(ins_addr);
34798 p += skip_prefix(p, &prf);
34799 p += get_opcode(p, &opcode);
34800 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
34801diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
34802index fb0a9dd..5ab49c4 100644
34803--- a/arch/x86/mm/pgtable.c
34804+++ b/arch/x86/mm/pgtable.c
34805@@ -98,10 +98,75 @@ static inline void pgd_list_del(pgd_t *pgd)
34806 list_del(&page->lru);
34807 }
34808
34809-#define UNSHARED_PTRS_PER_PGD \
34810- (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
34811+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
34812+pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
34813
34814+void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
34815+{
34816+ unsigned int count = USER_PGD_PTRS;
34817
34818+ if (!pax_user_shadow_base)
34819+ return;
34820+
34821+ while (count--)
34822+ *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
34823+}
34824+#endif
34825+
34826+#ifdef CONFIG_PAX_PER_CPU_PGD
34827+void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
34828+{
34829+ unsigned int count = USER_PGD_PTRS;
34830+
34831+ while (count--) {
34832+ pgd_t pgd;
34833+
34834+#ifdef CONFIG_X86_64
34835+ pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
34836+#else
34837+ pgd = *src++;
34838+#endif
34839+
34840+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
34841+ pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
34842+#endif
34843+
34844+ *dst++ = pgd;
34845+ }
34846+
34847+}
34848+#endif
34849+
34850+#ifdef CONFIG_X86_64
34851+#define pxd_t pud_t
34852+#define pyd_t pgd_t
34853+#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
34854+#define pgtable_pxd_page_ctor(page) true
34855+#define pgtable_pxd_page_dtor(page) do {} while (0)
34856+#define pxd_free(mm, pud) pud_free((mm), (pud))
34857+#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
34858+#define pyd_offset(mm, address) pgd_offset((mm), (address))
34859+#define PYD_SIZE PGDIR_SIZE
34860+#define mm_inc_nr_pxds(mm) do {} while (0)
34861+#define mm_dec_nr_pxds(mm) do {} while (0)
34862+#else
34863+#define pxd_t pmd_t
34864+#define pyd_t pud_t
34865+#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
34866+#define pgtable_pxd_page_ctor(page) pgtable_pmd_page_ctor(page)
34867+#define pgtable_pxd_page_dtor(page) pgtable_pmd_page_dtor(page)
34868+#define pxd_free(mm, pud) pmd_free((mm), (pud))
34869+#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
34870+#define pyd_offset(mm, address) pud_offset((mm), (address))
34871+#define PYD_SIZE PUD_SIZE
34872+#define mm_inc_nr_pxds(mm) mm_inc_nr_pmds(mm)
34873+#define mm_dec_nr_pxds(mm) mm_dec_nr_pmds(mm)
34874+#endif
34875+
34876+#ifdef CONFIG_PAX_PER_CPU_PGD
34877+static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
34878+static inline void pgd_dtor(pgd_t *pgd) {}
34879+#else
34880 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
34881 {
34882 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
34883@@ -142,6 +207,7 @@ static void pgd_dtor(pgd_t *pgd)
34884 pgd_list_del(pgd);
34885 spin_unlock(&pgd_lock);
34886 }
34887+#endif
34888
34889 /*
34890 * List of all pgd's needed for non-PAE so it can invalidate entries
34891@@ -154,7 +220,7 @@ static void pgd_dtor(pgd_t *pgd)
34892 * -- nyc
34893 */
34894
34895-#ifdef CONFIG_X86_PAE
34896+#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
34897 /*
34898 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
34899 * updating the top-level pagetable entries to guarantee the
34900@@ -166,7 +232,7 @@ static void pgd_dtor(pgd_t *pgd)
34901 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
34902 * and initialize the kernel pmds here.
34903 */
34904-#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
34905+#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
34906
34907 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
34908 {
34909@@ -184,46 +250,48 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
34910 */
34911 flush_tlb_mm(mm);
34912 }
34913+#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
34914+#define PREALLOCATED_PXDS USER_PGD_PTRS
34915 #else /* !CONFIG_X86_PAE */
34916
34917 /* No need to prepopulate any pagetable entries in non-PAE modes. */
34918-#define PREALLOCATED_PMDS 0
34919+#define PREALLOCATED_PXDS 0
34920
34921 #endif /* CONFIG_X86_PAE */
34922
34923-static void free_pmds(struct mm_struct *mm, pmd_t *pmds[])
34924+static void free_pxds(struct mm_struct *mm, pxd_t *pxds[])
34925 {
34926 int i;
34927
34928- for(i = 0; i < PREALLOCATED_PMDS; i++)
34929- if (pmds[i]) {
34930- pgtable_pmd_page_dtor(virt_to_page(pmds[i]));
34931- free_page((unsigned long)pmds[i]);
34932- mm_dec_nr_pmds(mm);
34933+ for(i = 0; i < PREALLOCATED_PXDS; i++)
34934+ if (pxds[i]) {
34935+ pgtable_pxd_page_dtor(virt_to_page(pxds[i]));
34936+ free_page((unsigned long)pxds[i]);
34937+ mm_dec_nr_pxds(mm);
34938 }
34939 }
34940
34941-static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
34942+static int preallocate_pxds(struct mm_struct *mm, pxd_t *pxds[])
34943 {
34944 int i;
34945 bool failed = false;
34946
34947- for(i = 0; i < PREALLOCATED_PMDS; i++) {
34948- pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
34949- if (!pmd)
34950+ for(i = 0; i < PREALLOCATED_PXDS; i++) {
34951+ pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
34952+ if (!pxd)
34953 failed = true;
34954- if (pmd && !pgtable_pmd_page_ctor(virt_to_page(pmd))) {
34955- free_page((unsigned long)pmd);
34956- pmd = NULL;
34957+ if (pxd && !pgtable_pxd_page_ctor(virt_to_page(pxd))) {
34958+ free_page((unsigned long)pxd);
34959+ pxd = NULL;
34960 failed = true;
34961 }
34962- if (pmd)
34963- mm_inc_nr_pmds(mm);
34964- pmds[i] = pmd;
34965+ if (pxd)
34966+ mm_inc_nr_pxds(mm);
34967+ pxds[i] = pxd;
34968 }
34969
34970 if (failed) {
34971- free_pmds(mm, pmds);
34972+ free_pxds(mm, pxds);
34973 return -ENOMEM;
34974 }
34975
34976@@ -236,43 +304,47 @@ static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
34977 * preallocate which never got a corresponding vma will need to be
34978 * freed manually.
34979 */
34980-static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
34981+static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
34982 {
34983 int i;
34984
34985- for(i = 0; i < PREALLOCATED_PMDS; i++) {
34986+ for(i = 0; i < PREALLOCATED_PXDS; i++) {
34987 pgd_t pgd = pgdp[i];
34988
34989 if (pgd_val(pgd) != 0) {
34990- pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
34991+ pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
34992
34993- pgdp[i] = native_make_pgd(0);
34994+ set_pgd(pgdp + i, native_make_pgd(0));
34995
34996- paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
34997- pmd_free(mm, pmd);
34998- mm_dec_nr_pmds(mm);
34999+ paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
35000+ pxd_free(mm, pxd);
35001+ mm_dec_nr_pxds(mm);
35002 }
35003 }
35004 }
35005
35006-static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
35007+static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
35008 {
35009- pud_t *pud;
35010+ pyd_t *pyd;
35011 int i;
35012
35013- if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
35014+ if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
35015 return;
35016
35017- pud = pud_offset(pgd, 0);
35018+#ifdef CONFIG_X86_64
35019+ pyd = pyd_offset(mm, 0L);
35020+#else
35021+ pyd = pyd_offset(pgd, 0L);
35022+#endif
35023
35024- for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
35025- pmd_t *pmd = pmds[i];
35026+ for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
35027+ pxd_t *pxd = pxds[i];
35028
35029 if (i >= KERNEL_PGD_BOUNDARY)
35030- memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
35031- sizeof(pmd_t) * PTRS_PER_PMD);
35032+ memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
35033+ sizeof(pxd_t) * PTRS_PER_PMD);
35034
35035- pud_populate(mm, pud, pmd);
35036+ pyd_populate(mm, pyd, pxd);
35037 }
35038 }
35039
35040@@ -354,7 +426,7 @@ static inline void _pgd_free(pgd_t *pgd)
35041 pgd_t *pgd_alloc(struct mm_struct *mm)
35042 {
35043 pgd_t *pgd;
35044- pmd_t *pmds[PREALLOCATED_PMDS];
35045+ pxd_t *pxds[PREALLOCATED_PXDS];
35046
35047 pgd = _pgd_alloc();
35048
35049@@ -363,11 +435,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
35050
35051 mm->pgd = pgd;
35052
35053- if (preallocate_pmds(mm, pmds) != 0)
35054+ if (preallocate_pxds(mm, pxds) != 0)
35055 goto out_free_pgd;
35056
35057 if (paravirt_pgd_alloc(mm) != 0)
35058- goto out_free_pmds;
35059+ goto out_free_pxds;
35060
35061 /*
35062 * Make sure that pre-populating the pmds is atomic with
35063@@ -377,14 +449,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
35064 spin_lock(&pgd_lock);
35065
35066 pgd_ctor(mm, pgd);
35067- pgd_prepopulate_pmd(mm, pgd, pmds);
35068+ pgd_prepopulate_pxd(mm, pgd, pxds);
35069
35070 spin_unlock(&pgd_lock);
35071
35072 return pgd;
35073
35074-out_free_pmds:
35075- free_pmds(mm, pmds);
35076+out_free_pxds:
35077+ free_pxds(mm, pxds);
35078 out_free_pgd:
35079 _pgd_free(pgd);
35080 out:
35081@@ -393,7 +465,7 @@ out:
35082
35083 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
35084 {
35085- pgd_mop_up_pmds(mm, pgd);
35086+ pgd_mop_up_pxds(mm, pgd);
35087 pgd_dtor(pgd);
35088 paravirt_pgd_free(mm, pgd);
35089 _pgd_free(pgd);
35090@@ -544,6 +616,55 @@ void __init reserve_top_address(unsigned long reserve)
35091
35092 int fixmaps_set;
35093
35094+static void fix_user_fixmap(enum fixed_addresses idx, unsigned long address)
35095+{
35096+#ifdef CONFIG_X86_64
35097+ pgd_t *pgd;
35098+ pud_t *pud;
35099+ pmd_t *pmd;
35100+
35101+ switch (idx) {
35102+ default:
35103+ return;
35104+
35105+#ifdef CONFIG_X86_VSYSCALL_EMULATION
35106+ case VSYSCALL_PAGE:
35107+ break;
35108+#endif
35109+
35110+#ifdef CONFIG_PARAVIRT_CLOCK
35111+ case PVCLOCK_FIXMAP_BEGIN ... PVCLOCK_FIXMAP_END:
35112+ break;
35113+#endif
35114+ }
35115+
35116+ pgd = pgd_offset_k(address);
35117+ if (!(pgd_val(*pgd) & _PAGE_USER)) {
35118+#ifdef CONFIG_PAX_PER_CPU_PGD
35119+ unsigned int cpu;
35120+ pgd_t *pgd_cpu;
35121+
35122+ for_each_possible_cpu(cpu) {
35123+ pgd_cpu = pgd_offset_cpu(cpu, kernel, address);
35124+ set_pgd(pgd_cpu, __pgd(pgd_val(*pgd_cpu) | _PAGE_USER));
35125+
35126+ pgd_cpu = pgd_offset_cpu(cpu, user, address);
35127+ set_pgd(pgd_cpu, __pgd(pgd_val(*pgd_cpu) | _PAGE_USER));
35128+ }
35129+#endif
35130+ set_pgd(pgd, __pgd(pgd_val(*pgd) | _PAGE_USER));
35131+ }
35132+
35133+ pud = pud_offset(pgd, address);
35134+ if (!(pud_val(*pud) & _PAGE_USER))
35135+ set_pud(pud, __pud(pud_val(*pud) | _PAGE_USER));
35136+
35137+ pmd = pmd_offset(pud, address);
35138+ if (!(pmd_val(*pmd) & _PAGE_USER))
35139+ set_pmd(pmd, __pmd(pmd_val(*pmd) | _PAGE_USER));
35140+#endif
35141+}
35142+
35143 void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
35144 {
35145 unsigned long address = __fix_to_virt(idx);
35146@@ -554,6 +675,7 @@ void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
35147 }
35148 set_pte_vaddr(address, pte);
35149 fixmaps_set++;
35150+ fix_user_fixmap(idx, address);
35151 }
35152
35153 void native_set_fixmap(enum fixed_addresses idx, phys_addr_t phys,
35154@@ -620,9 +742,11 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)
35155
35156 prot = pgprot_4k_2_large(prot);
35157
35158+ pax_open_kernel();
35159 set_pte((pte_t *)pmd, pfn_pte(
35160 (u64)addr >> PAGE_SHIFT,
35161 __pgprot(pgprot_val(prot) | _PAGE_PSE)));
35162+ pax_close_kernel();
35163
35164 return 1;
35165 }
35166diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
35167index 75cc097..79a097f 100644
35168--- a/arch/x86/mm/pgtable_32.c
35169+++ b/arch/x86/mm/pgtable_32.c
35170@@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
35171 return;
35172 }
35173 pte = pte_offset_kernel(pmd, vaddr);
35174+
35175+ pax_open_kernel();
35176 if (pte_val(pteval))
35177 set_pte_at(&init_mm, vaddr, pte, pteval);
35178 else
35179 pte_clear(&init_mm, vaddr, pte);
35180+ pax_close_kernel();
35181
35182 /*
35183 * It's enough to flush this one mapping.
35184diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
35185index 90555bf..f5f1828 100644
35186--- a/arch/x86/mm/setup_nx.c
35187+++ b/arch/x86/mm/setup_nx.c
35188@@ -5,8 +5,10 @@
35189 #include <asm/pgtable.h>
35190 #include <asm/proto.h>
35191
35192+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
35193 static int disable_nx;
35194
35195+#ifndef CONFIG_PAX_PAGEEXEC
35196 /*
35197 * noexec = on|off
35198 *
35199@@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
35200 return 0;
35201 }
35202 early_param("noexec", noexec_setup);
35203+#endif
35204+
35205+#endif
35206
35207 void x86_configure_nx(void)
35208 {
35209+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
35210 if (cpu_has_nx && !disable_nx)
35211 __supported_pte_mask |= _PAGE_NX;
35212 else
35213+#endif
35214 __supported_pte_mask &= ~_PAGE_NX;
35215 }
35216
35217diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
35218index 90b924a..4197ac2 100644
35219--- a/arch/x86/mm/tlb.c
35220+++ b/arch/x86/mm/tlb.c
35221@@ -45,7 +45,11 @@ void leave_mm(int cpu)
35222 BUG();
35223 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
35224 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
35225+
35226+#ifndef CONFIG_PAX_PER_CPU_PGD
35227 load_cr3(swapper_pg_dir);
35228+#endif
35229+
35230 /*
35231 * This gets called in the idle path where RCU
35232 * functions differently. Tracing normally
35233diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
35234new file mode 100644
35235index 0000000..3fda3f3
35236--- /dev/null
35237+++ b/arch/x86/mm/uderef_64.c
35238@@ -0,0 +1,37 @@
35239+#include <linux/mm.h>
35240+#include <asm/pgtable.h>
35241+#include <asm/uaccess.h>
35242+
35243+#ifdef CONFIG_PAX_MEMORY_UDEREF
35244+/* PaX: due to the special call convention these functions must
35245+ * - remain leaf functions under all configurations,
35246+ * - never be called directly, only dereferenced from the wrappers.
35247+ */
35248+void __used __pax_open_userland(void)
35249+{
35250+ unsigned int cpu;
35251+
35252+ if (unlikely(!segment_eq(get_fs(), USER_DS)))
35253+ return;
35254+
35255+ cpu = raw_get_cpu();
35256+ BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
35257+ write_cr3(__pa_nodebug(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
35258+ raw_put_cpu_no_resched();
35259+}
35260+EXPORT_SYMBOL(__pax_open_userland);
35261+
35262+void __used __pax_close_userland(void)
35263+{
35264+ unsigned int cpu;
35265+
35266+ if (unlikely(!segment_eq(get_fs(), USER_DS)))
35267+ return;
35268+
35269+ cpu = raw_get_cpu();
35270+ BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
35271+ write_cr3(__pa_nodebug(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
35272+ raw_put_cpu_no_resched();
35273+}
35274+EXPORT_SYMBOL(__pax_close_userland);
35275+#endif
35276diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
35277index 4093216..44b6b83 100644
35278--- a/arch/x86/net/bpf_jit.S
35279+++ b/arch/x86/net/bpf_jit.S
35280@@ -8,6 +8,7 @@
35281 * of the License.
35282 */
35283 #include <linux/linkage.h>
35284+#include <asm/alternative-asm.h>
35285
35286 /*
35287 * Calling convention :
35288@@ -37,6 +38,7 @@ sk_load_word_positive_offset:
35289 jle bpf_slow_path_word
35290 mov (SKBDATA,%rsi),%eax
35291 bswap %eax /* ntohl() */
35292+ pax_force_retaddr
35293 ret
35294
35295 sk_load_half:
35296@@ -54,6 +56,7 @@ sk_load_half_positive_offset:
35297 jle bpf_slow_path_half
35298 movzwl (SKBDATA,%rsi),%eax
35299 rol $8,%ax # ntohs()
35300+ pax_force_retaddr
35301 ret
35302
35303 sk_load_byte:
35304@@ -68,6 +71,7 @@ sk_load_byte_positive_offset:
35305 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
35306 jle bpf_slow_path_byte
35307 movzbl (SKBDATA,%rsi),%eax
35308+ pax_force_retaddr
35309 ret
35310
35311 /* rsi contains offset and can be scratched */
35312@@ -89,6 +93,7 @@ bpf_slow_path_word:
35313 js bpf_error
35314 mov - MAX_BPF_STACK + 32(%rbp),%eax
35315 bswap %eax
35316+ pax_force_retaddr
35317 ret
35318
35319 bpf_slow_path_half:
35320@@ -97,12 +102,14 @@ bpf_slow_path_half:
35321 mov - MAX_BPF_STACK + 32(%rbp),%ax
35322 rol $8,%ax
35323 movzwl %ax,%eax
35324+ pax_force_retaddr
35325 ret
35326
35327 bpf_slow_path_byte:
35328 bpf_slow_path_common(1)
35329 js bpf_error
35330 movzbl - MAX_BPF_STACK + 32(%rbp),%eax
35331+ pax_force_retaddr
35332 ret
35333
35334 #define sk_negative_common(SIZE) \
35335@@ -125,6 +132,7 @@ sk_load_word_negative_offset:
35336 sk_negative_common(4)
35337 mov (%rax), %eax
35338 bswap %eax
35339+ pax_force_retaddr
35340 ret
35341
35342 bpf_slow_path_half_neg:
35343@@ -136,6 +144,7 @@ sk_load_half_negative_offset:
35344 mov (%rax),%ax
35345 rol $8,%ax
35346 movzwl %ax,%eax
35347+ pax_force_retaddr
35348 ret
35349
35350 bpf_slow_path_byte_neg:
35351@@ -145,6 +154,7 @@ sk_load_byte_negative_offset:
35352 .globl sk_load_byte_negative_offset
35353 sk_negative_common(1)
35354 movzbl (%rax), %eax
35355+ pax_force_retaddr
35356 ret
35357
35358 bpf_error:
35359@@ -155,4 +165,5 @@ bpf_error:
35360 mov - MAX_BPF_STACK + 16(%rbp),%r14
35361 mov - MAX_BPF_STACK + 24(%rbp),%r15
35362 leaveq
35363+ pax_force_retaddr
35364 ret
35365diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
35366index be2e7a2..e6960dd 100644
35367--- a/arch/x86/net/bpf_jit_comp.c
35368+++ b/arch/x86/net/bpf_jit_comp.c
35369@@ -14,7 +14,11 @@
35370 #include <asm/cacheflush.h>
35371 #include <linux/bpf.h>
35372
35373+#ifdef CONFIG_GRKERNSEC_BPF_HARDEN
35374+int bpf_jit_enable __read_only;
35375+#else
35376 int bpf_jit_enable __read_mostly;
35377+#endif
35378
35379 /*
35380 * assembly code in arch/x86/net/bpf_jit.S
35381@@ -176,7 +180,9 @@ static u8 add_2reg(u8 byte, u32 dst_reg, u32 src_reg)
35382 static void jit_fill_hole(void *area, unsigned int size)
35383 {
35384 /* fill whole space with int3 instructions */
35385+ pax_open_kernel();
35386 memset(area, 0xcc, size);
35387+ pax_close_kernel();
35388 }
35389
35390 struct jit_context {
35391@@ -1026,7 +1032,9 @@ common_load:
35392 pr_err("bpf_jit_compile fatal error\n");
35393 return -EFAULT;
35394 }
35395+ pax_open_kernel();
35396 memcpy(image + proglen, temp, ilen);
35397+ pax_close_kernel();
35398 }
35399 proglen += ilen;
35400 addrs[i] = proglen;
35401@@ -1103,7 +1111,6 @@ void bpf_int_jit_compile(struct bpf_prog *prog)
35402
35403 if (image) {
35404 bpf_flush_icache(header, image + proglen);
35405- set_memory_ro((unsigned long)header, header->pages);
35406 prog->bpf_func = (void *)image;
35407 prog->jited = true;
35408 }
35409@@ -1116,12 +1123,8 @@ void bpf_jit_free(struct bpf_prog *fp)
35410 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
35411 struct bpf_binary_header *header = (void *)addr;
35412
35413- if (!fp->jited)
35414- goto free_filter;
35415+ if (fp->jited)
35416+ bpf_jit_binary_free(header);
35417
35418- set_memory_rw(addr, header->pages);
35419- bpf_jit_binary_free(header);
35420-
35421-free_filter:
35422 bpf_prog_unlock_free(fp);
35423 }
35424diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
35425index 4e664bd..2beeaa2 100644
35426--- a/arch/x86/oprofile/backtrace.c
35427+++ b/arch/x86/oprofile/backtrace.c
35428@@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
35429 struct stack_frame_ia32 *fp;
35430 unsigned long bytes;
35431
35432- bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
35433+ bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
35434 if (bytes != 0)
35435 return NULL;
35436
35437- fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
35438+ fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
35439
35440 oprofile_add_trace(bufhead[0].return_address);
35441
35442@@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
35443 struct stack_frame bufhead[2];
35444 unsigned long bytes;
35445
35446- bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
35447+ bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
35448 if (bytes != 0)
35449 return NULL;
35450
35451diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
35452index 1d2e639..f6ef82a 100644
35453--- a/arch/x86/oprofile/nmi_int.c
35454+++ b/arch/x86/oprofile/nmi_int.c
35455@@ -23,6 +23,7 @@
35456 #include <asm/nmi.h>
35457 #include <asm/msr.h>
35458 #include <asm/apic.h>
35459+#include <asm/pgtable.h>
35460
35461 #include "op_counter.h"
35462 #include "op_x86_model.h"
35463@@ -785,8 +786,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
35464 if (ret)
35465 return ret;
35466
35467- if (!model->num_virt_counters)
35468- model->num_virt_counters = model->num_counters;
35469+ if (!model->num_virt_counters) {
35470+ pax_open_kernel();
35471+ *(unsigned int *)&model->num_virt_counters = model->num_counters;
35472+ pax_close_kernel();
35473+ }
35474
35475 mux_init(ops);
35476
35477diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
35478index 50d86c0..7985318 100644
35479--- a/arch/x86/oprofile/op_model_amd.c
35480+++ b/arch/x86/oprofile/op_model_amd.c
35481@@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
35482 num_counters = AMD64_NUM_COUNTERS;
35483 }
35484
35485- op_amd_spec.num_counters = num_counters;
35486- op_amd_spec.num_controls = num_counters;
35487- op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
35488+ pax_open_kernel();
35489+ *(unsigned int *)&op_amd_spec.num_counters = num_counters;
35490+ *(unsigned int *)&op_amd_spec.num_controls = num_counters;
35491+ *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
35492+ pax_close_kernel();
35493
35494 return 0;
35495 }
35496diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
35497index d90528e..0127e2b 100644
35498--- a/arch/x86/oprofile/op_model_ppro.c
35499+++ b/arch/x86/oprofile/op_model_ppro.c
35500@@ -19,6 +19,7 @@
35501 #include <asm/msr.h>
35502 #include <asm/apic.h>
35503 #include <asm/nmi.h>
35504+#include <asm/pgtable.h>
35505
35506 #include "op_x86_model.h"
35507 #include "op_counter.h"
35508@@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
35509
35510 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
35511
35512- op_arch_perfmon_spec.num_counters = num_counters;
35513- op_arch_perfmon_spec.num_controls = num_counters;
35514+ pax_open_kernel();
35515+ *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
35516+ *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
35517+ pax_close_kernel();
35518 }
35519
35520 static int arch_perfmon_init(struct oprofile_operations *ignore)
35521diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
35522index 71e8a67..6a313bb 100644
35523--- a/arch/x86/oprofile/op_x86_model.h
35524+++ b/arch/x86/oprofile/op_x86_model.h
35525@@ -52,7 +52,7 @@ struct op_x86_model_spec {
35526 void (*switch_ctrl)(struct op_x86_model_spec const *model,
35527 struct op_msrs const * const msrs);
35528 #endif
35529-};
35530+} __do_const;
35531
35532 struct op_counter_config;
35533
35534diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c
35535index 7553921..d631bd4 100644
35536--- a/arch/x86/pci/intel_mid_pci.c
35537+++ b/arch/x86/pci/intel_mid_pci.c
35538@@ -278,7 +278,7 @@ int __init intel_mid_pci_init(void)
35539 pci_mmcfg_late_init();
35540 pcibios_enable_irq = intel_mid_pci_irq_enable;
35541 pcibios_disable_irq = intel_mid_pci_irq_disable;
35542- pci_root_ops = intel_mid_pci_ops;
35543+ memcpy((void *)&pci_root_ops, &intel_mid_pci_ops, sizeof pci_root_ops);
35544 pci_soc_mode = 1;
35545 /* Continue with standard init */
35546 return 1;
35547diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
35548index 9bd1154..e9d4656 100644
35549--- a/arch/x86/pci/irq.c
35550+++ b/arch/x86/pci/irq.c
35551@@ -51,7 +51,7 @@ struct irq_router {
35552 struct irq_router_handler {
35553 u16 vendor;
35554 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
35555-};
35556+} __do_const;
35557
35558 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
35559 void (*pcibios_disable_irq)(struct pci_dev *dev) = pirq_disable_irq;
35560@@ -792,7 +792,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
35561 return 0;
35562 }
35563
35564-static __initdata struct irq_router_handler pirq_routers[] = {
35565+static __initconst const struct irq_router_handler pirq_routers[] = {
35566 { PCI_VENDOR_ID_INTEL, intel_router_probe },
35567 { PCI_VENDOR_ID_AL, ali_router_probe },
35568 { PCI_VENDOR_ID_ITE, ite_router_probe },
35569@@ -819,7 +819,7 @@ static struct pci_dev *pirq_router_dev;
35570 static void __init pirq_find_router(struct irq_router *r)
35571 {
35572 struct irq_routing_table *rt = pirq_table;
35573- struct irq_router_handler *h;
35574+ const struct irq_router_handler *h;
35575
35576 #ifdef CONFIG_PCI_BIOS
35577 if (!rt->signature) {
35578@@ -1092,7 +1092,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
35579 return 0;
35580 }
35581
35582-static struct dmi_system_id __initdata pciirq_dmi_table[] = {
35583+static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
35584 {
35585 .callback = fix_broken_hp_bios_irq9,
35586 .ident = "HP Pavilion N5400 Series Laptop",
35587diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
35588index 9b83b90..2c256c5 100644
35589--- a/arch/x86/pci/pcbios.c
35590+++ b/arch/x86/pci/pcbios.c
35591@@ -79,7 +79,7 @@ union bios32 {
35592 static struct {
35593 unsigned long address;
35594 unsigned short segment;
35595-} bios32_indirect __initdata = { 0, __KERNEL_CS };
35596+} bios32_indirect __initdata = { 0, __PCIBIOS_CS };
35597
35598 /*
35599 * Returns the entry point for the given service, NULL on error
35600@@ -92,37 +92,80 @@ static unsigned long __init bios32_service(unsigned long service)
35601 unsigned long length; /* %ecx */
35602 unsigned long entry; /* %edx */
35603 unsigned long flags;
35604+ struct desc_struct d, *gdt;
35605
35606 local_irq_save(flags);
35607- __asm__("lcall *(%%edi); cld"
35608+
35609+ gdt = get_cpu_gdt_table(smp_processor_id());
35610+
35611+ pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
35612+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
35613+ pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
35614+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
35615+
35616+ __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
35617 : "=a" (return_code),
35618 "=b" (address),
35619 "=c" (length),
35620 "=d" (entry)
35621 : "0" (service),
35622 "1" (0),
35623- "D" (&bios32_indirect));
35624+ "D" (&bios32_indirect),
35625+ "r"(__PCIBIOS_DS)
35626+ : "memory");
35627+
35628+ pax_open_kernel();
35629+ gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
35630+ gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
35631+ gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
35632+ gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
35633+ pax_close_kernel();
35634+
35635 local_irq_restore(flags);
35636
35637 switch (return_code) {
35638- case 0:
35639- return address + entry;
35640- case 0x80: /* Not present */
35641- printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
35642- return 0;
35643- default: /* Shouldn't happen */
35644- printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
35645- service, return_code);
35646+ case 0: {
35647+ int cpu;
35648+ unsigned char flags;
35649+
35650+ printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
35651+ if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
35652+ printk(KERN_WARNING "bios32_service: not valid\n");
35653 return 0;
35654+ }
35655+ address = address + PAGE_OFFSET;
35656+ length += 16UL; /* some BIOSs underreport this... */
35657+ flags = 4;
35658+ if (length >= 64*1024*1024) {
35659+ length >>= PAGE_SHIFT;
35660+ flags |= 8;
35661+ }
35662+
35663+ for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
35664+ gdt = get_cpu_gdt_table(cpu);
35665+ pack_descriptor(&d, address, length, 0x9b, flags);
35666+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
35667+ pack_descriptor(&d, address, length, 0x93, flags);
35668+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
35669+ }
35670+ return entry;
35671+ }
35672+ case 0x80: /* Not present */
35673+ printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
35674+ return 0;
35675+ default: /* Shouldn't happen */
35676+ printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
35677+ service, return_code);
35678+ return 0;
35679 }
35680 }
35681
35682 static struct {
35683 unsigned long address;
35684 unsigned short segment;
35685-} pci_indirect = { 0, __KERNEL_CS };
35686+} pci_indirect __read_only = { 0, __PCIBIOS_CS };
35687
35688-static int pci_bios_present;
35689+static int pci_bios_present __read_only;
35690
35691 static int __init check_pcibios(void)
35692 {
35693@@ -131,11 +174,13 @@ static int __init check_pcibios(void)
35694 unsigned long flags, pcibios_entry;
35695
35696 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
35697- pci_indirect.address = pcibios_entry + PAGE_OFFSET;
35698+ pci_indirect.address = pcibios_entry;
35699
35700 local_irq_save(flags);
35701- __asm__(
35702- "lcall *(%%edi); cld\n\t"
35703+ __asm__("movw %w6, %%ds\n\t"
35704+ "lcall *%%ss:(%%edi); cld\n\t"
35705+ "push %%ss\n\t"
35706+ "pop %%ds\n\t"
35707 "jc 1f\n\t"
35708 "xor %%ah, %%ah\n"
35709 "1:"
35710@@ -144,7 +189,8 @@ static int __init check_pcibios(void)
35711 "=b" (ebx),
35712 "=c" (ecx)
35713 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
35714- "D" (&pci_indirect)
35715+ "D" (&pci_indirect),
35716+ "r" (__PCIBIOS_DS)
35717 : "memory");
35718 local_irq_restore(flags);
35719
35720@@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35721
35722 switch (len) {
35723 case 1:
35724- __asm__("lcall *(%%esi); cld\n\t"
35725+ __asm__("movw %w6, %%ds\n\t"
35726+ "lcall *%%ss:(%%esi); cld\n\t"
35727+ "push %%ss\n\t"
35728+ "pop %%ds\n\t"
35729 "jc 1f\n\t"
35730 "xor %%ah, %%ah\n"
35731 "1:"
35732@@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35733 : "1" (PCIBIOS_READ_CONFIG_BYTE),
35734 "b" (bx),
35735 "D" ((long)reg),
35736- "S" (&pci_indirect));
35737+ "S" (&pci_indirect),
35738+ "r" (__PCIBIOS_DS));
35739 /*
35740 * Zero-extend the result beyond 8 bits, do not trust the
35741 * BIOS having done it:
35742@@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35743 *value &= 0xff;
35744 break;
35745 case 2:
35746- __asm__("lcall *(%%esi); cld\n\t"
35747+ __asm__("movw %w6, %%ds\n\t"
35748+ "lcall *%%ss:(%%esi); cld\n\t"
35749+ "push %%ss\n\t"
35750+ "pop %%ds\n\t"
35751 "jc 1f\n\t"
35752 "xor %%ah, %%ah\n"
35753 "1:"
35754@@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35755 : "1" (PCIBIOS_READ_CONFIG_WORD),
35756 "b" (bx),
35757 "D" ((long)reg),
35758- "S" (&pci_indirect));
35759+ "S" (&pci_indirect),
35760+ "r" (__PCIBIOS_DS));
35761 /*
35762 * Zero-extend the result beyond 16 bits, do not trust the
35763 * BIOS having done it:
35764@@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35765 *value &= 0xffff;
35766 break;
35767 case 4:
35768- __asm__("lcall *(%%esi); cld\n\t"
35769+ __asm__("movw %w6, %%ds\n\t"
35770+ "lcall *%%ss:(%%esi); cld\n\t"
35771+ "push %%ss\n\t"
35772+ "pop %%ds\n\t"
35773 "jc 1f\n\t"
35774 "xor %%ah, %%ah\n"
35775 "1:"
35776@@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35777 : "1" (PCIBIOS_READ_CONFIG_DWORD),
35778 "b" (bx),
35779 "D" ((long)reg),
35780- "S" (&pci_indirect));
35781+ "S" (&pci_indirect),
35782+ "r" (__PCIBIOS_DS));
35783 break;
35784 }
35785
35786@@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35787
35788 switch (len) {
35789 case 1:
35790- __asm__("lcall *(%%esi); cld\n\t"
35791+ __asm__("movw %w6, %%ds\n\t"
35792+ "lcall *%%ss:(%%esi); cld\n\t"
35793+ "push %%ss\n\t"
35794+ "pop %%ds\n\t"
35795 "jc 1f\n\t"
35796 "xor %%ah, %%ah\n"
35797 "1:"
35798@@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35799 "c" (value),
35800 "b" (bx),
35801 "D" ((long)reg),
35802- "S" (&pci_indirect));
35803+ "S" (&pci_indirect),
35804+ "r" (__PCIBIOS_DS));
35805 break;
35806 case 2:
35807- __asm__("lcall *(%%esi); cld\n\t"
35808+ __asm__("movw %w6, %%ds\n\t"
35809+ "lcall *%%ss:(%%esi); cld\n\t"
35810+ "push %%ss\n\t"
35811+ "pop %%ds\n\t"
35812 "jc 1f\n\t"
35813 "xor %%ah, %%ah\n"
35814 "1:"
35815@@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35816 "c" (value),
35817 "b" (bx),
35818 "D" ((long)reg),
35819- "S" (&pci_indirect));
35820+ "S" (&pci_indirect),
35821+ "r" (__PCIBIOS_DS));
35822 break;
35823 case 4:
35824- __asm__("lcall *(%%esi); cld\n\t"
35825+ __asm__("movw %w6, %%ds\n\t"
35826+ "lcall *%%ss:(%%esi); cld\n\t"
35827+ "push %%ss\n\t"
35828+ "pop %%ds\n\t"
35829 "jc 1f\n\t"
35830 "xor %%ah, %%ah\n"
35831 "1:"
35832@@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35833 "c" (value),
35834 "b" (bx),
35835 "D" ((long)reg),
35836- "S" (&pci_indirect));
35837+ "S" (&pci_indirect),
35838+ "r" (__PCIBIOS_DS));
35839 break;
35840 }
35841
35842@@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
35843
35844 DBG("PCI: Fetching IRQ routing table... ");
35845 __asm__("push %%es\n\t"
35846+ "movw %w8, %%ds\n\t"
35847 "push %%ds\n\t"
35848 "pop %%es\n\t"
35849- "lcall *(%%esi); cld\n\t"
35850+ "lcall *%%ss:(%%esi); cld\n\t"
35851 "pop %%es\n\t"
35852+ "push %%ss\n\t"
35853+ "pop %%ds\n"
35854 "jc 1f\n\t"
35855 "xor %%ah, %%ah\n"
35856 "1:"
35857@@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
35858 "1" (0),
35859 "D" ((long) &opt),
35860 "S" (&pci_indirect),
35861- "m" (opt)
35862+ "m" (opt),
35863+ "r" (__PCIBIOS_DS)
35864 : "memory");
35865 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
35866 if (ret & 0xff00)
35867@@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
35868 {
35869 int ret;
35870
35871- __asm__("lcall *(%%esi); cld\n\t"
35872+ __asm__("movw %w5, %%ds\n\t"
35873+ "lcall *%%ss:(%%esi); cld\n\t"
35874+ "push %%ss\n\t"
35875+ "pop %%ds\n"
35876 "jc 1f\n\t"
35877 "xor %%ah, %%ah\n"
35878 "1:"
35879@@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
35880 : "0" (PCIBIOS_SET_PCI_HW_INT),
35881 "b" ((dev->bus->number << 8) | dev->devfn),
35882 "c" ((irq << 8) | (pin + 10)),
35883- "S" (&pci_indirect));
35884+ "S" (&pci_indirect),
35885+ "r" (__PCIBIOS_DS));
35886 return !(ret & 0xff00);
35887 }
35888 EXPORT_SYMBOL(pcibios_set_irq_routing);
35889diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
35890index ed5b673..24d2d53 100644
35891--- a/arch/x86/platform/efi/efi_32.c
35892+++ b/arch/x86/platform/efi/efi_32.c
35893@@ -61,11 +61,27 @@ pgd_t * __init efi_call_phys_prolog(void)
35894 struct desc_ptr gdt_descr;
35895 pgd_t *save_pgd;
35896
35897+#ifdef CONFIG_PAX_KERNEXEC
35898+ struct desc_struct d;
35899+#endif
35900+
35901 /* Current pgd is swapper_pg_dir, we'll restore it later: */
35902+#ifdef CONFIG_PAX_PER_CPU_PGD
35903+ save_pgd = get_cpu_pgd(smp_processor_id(), kernel);
35904+#else
35905 save_pgd = swapper_pg_dir;
35906+#endif
35907+
35908 load_cr3(initial_page_table);
35909 __flush_tlb_all();
35910
35911+#ifdef CONFIG_PAX_KERNEXEC
35912+ pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
35913+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
35914+ pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
35915+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
35916+#endif
35917+
35918 gdt_descr.address = __pa(get_cpu_gdt_table(0));
35919 gdt_descr.size = GDT_SIZE - 1;
35920 load_gdt(&gdt_descr);
35921@@ -77,6 +93,14 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
35922 {
35923 struct desc_ptr gdt_descr;
35924
35925+#ifdef CONFIG_PAX_KERNEXEC
35926+ struct desc_struct d;
35927+
35928+ memset(&d, 0, sizeof d);
35929+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
35930+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
35931+#endif
35932+
35933 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
35934 gdt_descr.size = GDT_SIZE - 1;
35935 load_gdt(&gdt_descr);
35936diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
35937index a0ac0f9..f41d324 100644
35938--- a/arch/x86/platform/efi/efi_64.c
35939+++ b/arch/x86/platform/efi/efi_64.c
35940@@ -96,6 +96,11 @@ pgd_t * __init efi_call_phys_prolog(void)
35941 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
35942 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
35943 }
35944+
35945+#ifdef CONFIG_PAX_PER_CPU_PGD
35946+ load_cr3(swapper_pg_dir);
35947+#endif
35948+
35949 __flush_tlb_all();
35950
35951 return save_pgd;
35952@@ -119,6 +124,10 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
35953
35954 kfree(save_pgd);
35955
35956+#ifdef CONFIG_PAX_PER_CPU_PGD
35957+ load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
35958+#endif
35959+
35960 __flush_tlb_all();
35961 early_code_mapping_set_exec(0);
35962 }
35963@@ -148,8 +157,23 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
35964 unsigned npages;
35965 pgd_t *pgd;
35966
35967- if (efi_enabled(EFI_OLD_MEMMAP))
35968+ if (efi_enabled(EFI_OLD_MEMMAP)) {
35969+ /* PaX: We need to disable the NX bit in the PGD, otherwise we won't be
35970+ * able to execute the EFI services.
35971+ */
35972+ if (__supported_pte_mask & _PAGE_NX) {
35973+ unsigned long addr = (unsigned long) __va(0);
35974+ pgd_t pe = __pgd(pgd_val(*pgd_offset_k(addr)) & ~_PAGE_NX);
35975+
35976+ pr_alert("PAX: Disabling NX protection for low memory map. Try booting without \"efi=old_map\"\n");
35977+#ifdef CONFIG_PAX_PER_CPU_PGD
35978+ set_pgd(pgd_offset_cpu(0, kernel, addr), pe);
35979+#endif
35980+ set_pgd(pgd_offset_k(addr), pe);
35981+ }
35982+
35983 return 0;
35984+ }
35985
35986 efi_scratch.efi_pgt = (pgd_t *)(unsigned long)real_mode_header->trampoline_pgd;
35987 pgd = __va(efi_scratch.efi_pgt);
35988diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
35989index 040192b..7d3300f 100644
35990--- a/arch/x86/platform/efi/efi_stub_32.S
35991+++ b/arch/x86/platform/efi/efi_stub_32.S
35992@@ -6,7 +6,9 @@
35993 */
35994
35995 #include <linux/linkage.h>
35996+#include <linux/init.h>
35997 #include <asm/page_types.h>
35998+#include <asm/segment.h>
35999
36000 /*
36001 * efi_call_phys(void *, ...) is a function with variable parameters.
36002@@ -20,7 +22,7 @@
36003 * service functions will comply with gcc calling convention, too.
36004 */
36005
36006-.text
36007+__INIT
36008 ENTRY(efi_call_phys)
36009 /*
36010 * 0. The function can only be called in Linux kernel. So CS has been
36011@@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
36012 * The mapping of lower virtual memory has been created in prolog and
36013 * epilog.
36014 */
36015- movl $1f, %edx
36016- subl $__PAGE_OFFSET, %edx
36017- jmp *%edx
36018+#ifdef CONFIG_PAX_KERNEXEC
36019+ movl $(__KERNEXEC_EFI_DS), %edx
36020+ mov %edx, %ds
36021+ mov %edx, %es
36022+ mov %edx, %ss
36023+ addl $2f,(1f)
36024+ ljmp *(1f)
36025+
36026+__INITDATA
36027+1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
36028+.previous
36029+
36030+2:
36031+ subl $2b,(1b)
36032+#else
36033+ jmp 1f-__PAGE_OFFSET
36034 1:
36035+#endif
36036
36037 /*
36038 * 2. Now on the top of stack is the return
36039@@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
36040 * parameter 2, ..., param n. To make things easy, we save the return
36041 * address of efi_call_phys in a global variable.
36042 */
36043- popl %edx
36044- movl %edx, saved_return_addr
36045- /* get the function pointer into ECX*/
36046- popl %ecx
36047- movl %ecx, efi_rt_function_ptr
36048- movl $2f, %edx
36049- subl $__PAGE_OFFSET, %edx
36050- pushl %edx
36051+ popl (saved_return_addr)
36052+ popl (efi_rt_function_ptr)
36053
36054 /*
36055 * 3. Clear PG bit in %CR0.
36056@@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
36057 /*
36058 * 5. Call the physical function.
36059 */
36060- jmp *%ecx
36061+ call *(efi_rt_function_ptr-__PAGE_OFFSET)
36062
36063-2:
36064 /*
36065 * 6. After EFI runtime service returns, control will return to
36066 * following instruction. We'd better readjust stack pointer first.
36067@@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
36068 movl %cr0, %edx
36069 orl $0x80000000, %edx
36070 movl %edx, %cr0
36071- jmp 1f
36072-1:
36073+
36074 /*
36075 * 8. Now restore the virtual mode from flat mode by
36076 * adding EIP with PAGE_OFFSET.
36077 */
36078- movl $1f, %edx
36079- jmp *%edx
36080+#ifdef CONFIG_PAX_KERNEXEC
36081+ movl $(__KERNEL_DS), %edx
36082+ mov %edx, %ds
36083+ mov %edx, %es
36084+ mov %edx, %ss
36085+ ljmp $(__KERNEL_CS),$1f
36086+#else
36087+ jmp 1f+__PAGE_OFFSET
36088+#endif
36089 1:
36090
36091 /*
36092 * 9. Balance the stack. And because EAX contain the return value,
36093 * we'd better not clobber it.
36094 */
36095- leal efi_rt_function_ptr, %edx
36096- movl (%edx), %ecx
36097- pushl %ecx
36098+ pushl (efi_rt_function_ptr)
36099
36100 /*
36101- * 10. Push the saved return address onto the stack and return.
36102+ * 10. Return to the saved return address.
36103 */
36104- leal saved_return_addr, %edx
36105- movl (%edx), %ecx
36106- pushl %ecx
36107- ret
36108+ jmpl *(saved_return_addr)
36109 ENDPROC(efi_call_phys)
36110 .previous
36111
36112-.data
36113+__INITDATA
36114 saved_return_addr:
36115 .long 0
36116 efi_rt_function_ptr:
36117diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
36118index 86d0f9e..6d499f4 100644
36119--- a/arch/x86/platform/efi/efi_stub_64.S
36120+++ b/arch/x86/platform/efi/efi_stub_64.S
36121@@ -11,6 +11,7 @@
36122 #include <asm/msr.h>
36123 #include <asm/processor-flags.h>
36124 #include <asm/page_types.h>
36125+#include <asm/alternative-asm.h>
36126
36127 #define SAVE_XMM \
36128 mov %rsp, %rax; \
36129@@ -88,6 +89,7 @@ ENTRY(efi_call)
36130 RESTORE_PGT
36131 addq $48, %rsp
36132 RESTORE_XMM
36133+ pax_force_retaddr 0, 1
36134 ret
36135 ENDPROC(efi_call)
36136
36137diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c
36138index 01d54ea..ba1d71c 100644
36139--- a/arch/x86/platform/intel-mid/intel-mid.c
36140+++ b/arch/x86/platform/intel-mid/intel-mid.c
36141@@ -63,7 +63,7 @@ enum intel_mid_timer_options intel_mid_timer_options;
36142 /* intel_mid_ops to store sub arch ops */
36143 struct intel_mid_ops *intel_mid_ops;
36144 /* getter function for sub arch ops*/
36145-static void *(*get_intel_mid_ops[])(void) = INTEL_MID_OPS_INIT;
36146+static const void *(*get_intel_mid_ops[])(void) = INTEL_MID_OPS_INIT;
36147 enum intel_mid_cpu_type __intel_mid_cpu_chip;
36148 EXPORT_SYMBOL_GPL(__intel_mid_cpu_chip);
36149
36150@@ -71,9 +71,10 @@ static void intel_mid_power_off(void)
36151 {
36152 };
36153
36154-static void intel_mid_reboot(void)
36155+static void __noreturn intel_mid_reboot(void)
36156 {
36157 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
36158+ BUG();
36159 }
36160
36161 static unsigned long __init intel_mid_calibrate_tsc(void)
36162diff --git a/arch/x86/platform/intel-mid/intel_mid_weak_decls.h b/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
36163index 3c1c386..59a68ed 100644
36164--- a/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
36165+++ b/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
36166@@ -13,6 +13,6 @@
36167 /* For every CPU addition a new get_<cpuname>_ops interface needs
36168 * to be added.
36169 */
36170-extern void *get_penwell_ops(void);
36171-extern void *get_cloverview_ops(void);
36172-extern void *get_tangier_ops(void);
36173+extern const void *get_penwell_ops(void);
36174+extern const void *get_cloverview_ops(void);
36175+extern const void *get_tangier_ops(void);
36176diff --git a/arch/x86/platform/intel-mid/mfld.c b/arch/x86/platform/intel-mid/mfld.c
36177index 23381d2..8ddc10e 100644
36178--- a/arch/x86/platform/intel-mid/mfld.c
36179+++ b/arch/x86/platform/intel-mid/mfld.c
36180@@ -64,12 +64,12 @@ static void __init penwell_arch_setup(void)
36181 pm_power_off = mfld_power_off;
36182 }
36183
36184-void *get_penwell_ops(void)
36185+const void *get_penwell_ops(void)
36186 {
36187 return &penwell_ops;
36188 }
36189
36190-void *get_cloverview_ops(void)
36191+const void *get_cloverview_ops(void)
36192 {
36193 return &penwell_ops;
36194 }
36195diff --git a/arch/x86/platform/intel-mid/mrfl.c b/arch/x86/platform/intel-mid/mrfl.c
36196index aaca917..66eadbc 100644
36197--- a/arch/x86/platform/intel-mid/mrfl.c
36198+++ b/arch/x86/platform/intel-mid/mrfl.c
36199@@ -97,7 +97,7 @@ static struct intel_mid_ops tangier_ops = {
36200 .arch_setup = tangier_arch_setup,
36201 };
36202
36203-void *get_tangier_ops(void)
36204+const void *get_tangier_ops(void)
36205 {
36206 return &tangier_ops;
36207 }
36208diff --git a/arch/x86/platform/intel-quark/imr_selftest.c b/arch/x86/platform/intel-quark/imr_selftest.c
36209index 278e4da..35db1a9 100644
36210--- a/arch/x86/platform/intel-quark/imr_selftest.c
36211+++ b/arch/x86/platform/intel-quark/imr_selftest.c
36212@@ -55,7 +55,7 @@ static void __init imr_self_test_result(int res, const char *fmt, ...)
36213 */
36214 static void __init imr_self_test(void)
36215 {
36216- phys_addr_t base = virt_to_phys(&_text);
36217+ phys_addr_t base = virt_to_phys((void *)ktla_ktva((unsigned long)_text));
36218 size_t size = virt_to_phys(&__end_rodata) - base;
36219 const char *fmt_over = "overlapped IMR @ (0x%08lx - 0x%08lx)\n";
36220 int ret;
36221diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
36222index d6ee929..3637cb5 100644
36223--- a/arch/x86/platform/olpc/olpc_dt.c
36224+++ b/arch/x86/platform/olpc/olpc_dt.c
36225@@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
36226 return res;
36227 }
36228
36229-static struct of_pdt_ops prom_olpc_ops __initdata = {
36230+static struct of_pdt_ops prom_olpc_ops __initconst = {
36231 .nextprop = olpc_dt_nextprop,
36232 .getproplen = olpc_dt_getproplen,
36233 .getproperty = olpc_dt_getproperty,
36234diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
36235index 9ab5279..8ba4611 100644
36236--- a/arch/x86/power/cpu.c
36237+++ b/arch/x86/power/cpu.c
36238@@ -134,11 +134,8 @@ static void do_fpu_end(void)
36239 static void fix_processor_context(void)
36240 {
36241 int cpu = smp_processor_id();
36242- struct tss_struct *t = &per_cpu(cpu_tss, cpu);
36243-#ifdef CONFIG_X86_64
36244- struct desc_struct *desc = get_cpu_gdt_table(cpu);
36245- tss_desc tss;
36246-#endif
36247+ struct tss_struct *t = cpu_tss + cpu;
36248+
36249 set_tss_desc(cpu, t); /*
36250 * This just modifies memory; should not be
36251 * necessary. But... This is necessary, because
36252@@ -147,10 +144,6 @@ static void fix_processor_context(void)
36253 */
36254
36255 #ifdef CONFIG_X86_64
36256- memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
36257- tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
36258- write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
36259-
36260 syscall_init(); /* This sets MSR_*STAR and related */
36261 #endif
36262 load_TR_desc(); /* This does ltr */
36263diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
36264index 0b7a63d..dff2199 100644
36265--- a/arch/x86/realmode/init.c
36266+++ b/arch/x86/realmode/init.c
36267@@ -68,7 +68,13 @@ void __init setup_real_mode(void)
36268 __va(real_mode_header->trampoline_header);
36269
36270 #ifdef CONFIG_X86_32
36271- trampoline_header->start = __pa_symbol(startup_32_smp);
36272+ trampoline_header->start = __pa_symbol(ktla_ktva((unsigned long)startup_32_smp));
36273+
36274+#ifdef CONFIG_PAX_KERNEXEC
36275+ trampoline_header->start -= LOAD_PHYSICAL_ADDR;
36276+#endif
36277+
36278+ trampoline_header->boot_cs = __BOOT_CS;
36279 trampoline_header->gdt_limit = __BOOT_DS + 7;
36280 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
36281 #else
36282@@ -84,7 +90,7 @@ void __init setup_real_mode(void)
36283 *trampoline_cr4_features = __read_cr4();
36284
36285 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
36286- trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
36287+ trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
36288 trampoline_pgd[511] = init_level4_pgt[511].pgd;
36289 #endif
36290 }
36291diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
36292index 2730d77..2e4cd19 100644
36293--- a/arch/x86/realmode/rm/Makefile
36294+++ b/arch/x86/realmode/rm/Makefile
36295@@ -68,5 +68,8 @@ $(obj)/realmode.relocs: $(obj)/realmode.elf FORCE
36296
36297 KBUILD_CFLAGS := $(LINUXINCLUDE) $(REALMODE_CFLAGS) -D_SETUP -D_WAKEUP \
36298 -I$(srctree)/arch/x86/boot
36299+ifdef CONSTIFY_PLUGIN
36300+KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
36301+endif
36302 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
36303 GCOV_PROFILE := n
36304diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
36305index a28221d..93c40f1 100644
36306--- a/arch/x86/realmode/rm/header.S
36307+++ b/arch/x86/realmode/rm/header.S
36308@@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
36309 #endif
36310 /* APM/BIOS reboot */
36311 .long pa_machine_real_restart_asm
36312-#ifdef CONFIG_X86_64
36313+#ifdef CONFIG_X86_32
36314+ .long __KERNEL_CS
36315+#else
36316 .long __KERNEL32_CS
36317 #endif
36318 END(real_mode_header)
36319diff --git a/arch/x86/realmode/rm/reboot.S b/arch/x86/realmode/rm/reboot.S
36320index d66c607..3def845 100644
36321--- a/arch/x86/realmode/rm/reboot.S
36322+++ b/arch/x86/realmode/rm/reboot.S
36323@@ -27,6 +27,10 @@ ENTRY(machine_real_restart_asm)
36324 lgdtl pa_tr_gdt
36325
36326 /* Disable paging to drop us out of long mode */
36327+ movl %cr4, %eax
36328+ andl $~X86_CR4_PCIDE, %eax
36329+ movl %eax, %cr4
36330+
36331 movl %cr0, %eax
36332 andl $~X86_CR0_PG, %eax
36333 movl %eax, %cr0
36334diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
36335index 48ddd76..c26749f 100644
36336--- a/arch/x86/realmode/rm/trampoline_32.S
36337+++ b/arch/x86/realmode/rm/trampoline_32.S
36338@@ -24,6 +24,12 @@
36339 #include <asm/page_types.h>
36340 #include "realmode.h"
36341
36342+#ifdef CONFIG_PAX_KERNEXEC
36343+#define ta(X) (X)
36344+#else
36345+#define ta(X) (pa_ ## X)
36346+#endif
36347+
36348 .text
36349 .code16
36350
36351@@ -38,8 +44,6 @@ ENTRY(trampoline_start)
36352
36353 cli # We should be safe anyway
36354
36355- movl tr_start, %eax # where we need to go
36356-
36357 movl $0xA5A5A5A5, trampoline_status
36358 # write marker for master knows we're running
36359
36360@@ -55,7 +59,7 @@ ENTRY(trampoline_start)
36361 movw $1, %dx # protected mode (PE) bit
36362 lmsw %dx # into protected mode
36363
36364- ljmpl $__BOOT_CS, $pa_startup_32
36365+ ljmpl *(trampoline_header)
36366
36367 .section ".text32","ax"
36368 .code32
36369@@ -66,7 +70,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
36370 .balign 8
36371 GLOBAL(trampoline_header)
36372 tr_start: .space 4
36373- tr_gdt_pad: .space 2
36374+ tr_boot_cs: .space 2
36375 tr_gdt: .space 6
36376 END(trampoline_header)
36377
36378diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
36379index dac7b20..72dbaca 100644
36380--- a/arch/x86/realmode/rm/trampoline_64.S
36381+++ b/arch/x86/realmode/rm/trampoline_64.S
36382@@ -93,6 +93,7 @@ ENTRY(startup_32)
36383 movl %edx, %gs
36384
36385 movl pa_tr_cr4, %eax
36386+ andl $~X86_CR4_PCIDE, %eax
36387 movl %eax, %cr4 # Enable PAE mode
36388
36389 # Setup trampoline 4 level pagetables
36390@@ -106,7 +107,7 @@ ENTRY(startup_32)
36391 wrmsr
36392
36393 # Enable paging and in turn activate Long Mode
36394- movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
36395+ movl $(X86_CR0_PG | X86_CR0_PE), %eax
36396 movl %eax, %cr0
36397
36398 /*
36399diff --git a/arch/x86/realmode/rm/wakeup_asm.S b/arch/x86/realmode/rm/wakeup_asm.S
36400index 9e7e147..25a4158 100644
36401--- a/arch/x86/realmode/rm/wakeup_asm.S
36402+++ b/arch/x86/realmode/rm/wakeup_asm.S
36403@@ -126,11 +126,10 @@ ENTRY(wakeup_start)
36404 lgdtl pmode_gdt
36405
36406 /* This really couldn't... */
36407- movl pmode_entry, %eax
36408 movl pmode_cr0, %ecx
36409 movl %ecx, %cr0
36410- ljmpl $__KERNEL_CS, $pa_startup_32
36411- /* -> jmp *%eax in trampoline_32.S */
36412+
36413+ ljmpl *pmode_entry
36414 #else
36415 jmp trampoline_start
36416 #endif
36417diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
36418index 604a37e..e49702a 100644
36419--- a/arch/x86/tools/Makefile
36420+++ b/arch/x86/tools/Makefile
36421@@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
36422
36423 $(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
36424
36425-HOST_EXTRACFLAGS += -I$(srctree)/tools/include
36426+HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
36427 hostprogs-y += relocs
36428 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
36429 PHONY += relocs
36430diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
36431index 0c2fae8..88d7719 100644
36432--- a/arch/x86/tools/relocs.c
36433+++ b/arch/x86/tools/relocs.c
36434@@ -1,5 +1,7 @@
36435 /* This is included from relocs_32/64.c */
36436
36437+#include "../../../include/generated/autoconf.h"
36438+
36439 #define ElfW(type) _ElfW(ELF_BITS, type)
36440 #define _ElfW(bits, type) __ElfW(bits, type)
36441 #define __ElfW(bits, type) Elf##bits##_##type
36442@@ -11,6 +13,7 @@
36443 #define Elf_Sym ElfW(Sym)
36444
36445 static Elf_Ehdr ehdr;
36446+static Elf_Phdr *phdr;
36447
36448 struct relocs {
36449 uint32_t *offset;
36450@@ -386,9 +389,39 @@ static void read_ehdr(FILE *fp)
36451 }
36452 }
36453
36454+static void read_phdrs(FILE *fp)
36455+{
36456+ unsigned int i;
36457+
36458+ phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
36459+ if (!phdr) {
36460+ die("Unable to allocate %d program headers\n",
36461+ ehdr.e_phnum);
36462+ }
36463+ if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
36464+ die("Seek to %d failed: %s\n",
36465+ ehdr.e_phoff, strerror(errno));
36466+ }
36467+ if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
36468+ die("Cannot read ELF program headers: %s\n",
36469+ strerror(errno));
36470+ }
36471+ for(i = 0; i < ehdr.e_phnum; i++) {
36472+ phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
36473+ phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
36474+ phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
36475+ phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
36476+ phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
36477+ phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
36478+ phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
36479+ phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
36480+ }
36481+
36482+}
36483+
36484 static void read_shdrs(FILE *fp)
36485 {
36486- int i;
36487+ unsigned int i;
36488 Elf_Shdr shdr;
36489
36490 secs = calloc(ehdr.e_shnum, sizeof(struct section));
36491@@ -423,7 +456,7 @@ static void read_shdrs(FILE *fp)
36492
36493 static void read_strtabs(FILE *fp)
36494 {
36495- int i;
36496+ unsigned int i;
36497 for (i = 0; i < ehdr.e_shnum; i++) {
36498 struct section *sec = &secs[i];
36499 if (sec->shdr.sh_type != SHT_STRTAB) {
36500@@ -448,7 +481,7 @@ static void read_strtabs(FILE *fp)
36501
36502 static void read_symtabs(FILE *fp)
36503 {
36504- int i,j;
36505+ unsigned int i,j;
36506 for (i = 0; i < ehdr.e_shnum; i++) {
36507 struct section *sec = &secs[i];
36508 if (sec->shdr.sh_type != SHT_SYMTAB) {
36509@@ -479,9 +512,11 @@ static void read_symtabs(FILE *fp)
36510 }
36511
36512
36513-static void read_relocs(FILE *fp)
36514+static void read_relocs(FILE *fp, int use_real_mode)
36515 {
36516- int i,j;
36517+ unsigned int i,j;
36518+ uint32_t base;
36519+
36520 for (i = 0; i < ehdr.e_shnum; i++) {
36521 struct section *sec = &secs[i];
36522 if (sec->shdr.sh_type != SHT_REL_TYPE) {
36523@@ -501,9 +536,22 @@ static void read_relocs(FILE *fp)
36524 die("Cannot read symbol table: %s\n",
36525 strerror(errno));
36526 }
36527+ base = 0;
36528+
36529+#ifdef CONFIG_X86_32
36530+ for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
36531+ if (phdr[j].p_type != PT_LOAD )
36532+ continue;
36533+ 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)
36534+ continue;
36535+ base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
36536+ break;
36537+ }
36538+#endif
36539+
36540 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
36541 Elf_Rel *rel = &sec->reltab[j];
36542- rel->r_offset = elf_addr_to_cpu(rel->r_offset);
36543+ rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
36544 rel->r_info = elf_xword_to_cpu(rel->r_info);
36545 #if (SHT_REL_TYPE == SHT_RELA)
36546 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
36547@@ -515,7 +563,7 @@ static void read_relocs(FILE *fp)
36548
36549 static void print_absolute_symbols(void)
36550 {
36551- int i;
36552+ unsigned int i;
36553 const char *format;
36554
36555 if (ELF_BITS == 64)
36556@@ -528,7 +576,7 @@ static void print_absolute_symbols(void)
36557 for (i = 0; i < ehdr.e_shnum; i++) {
36558 struct section *sec = &secs[i];
36559 char *sym_strtab;
36560- int j;
36561+ unsigned int j;
36562
36563 if (sec->shdr.sh_type != SHT_SYMTAB) {
36564 continue;
36565@@ -555,7 +603,7 @@ static void print_absolute_symbols(void)
36566
36567 static void print_absolute_relocs(void)
36568 {
36569- int i, printed = 0;
36570+ unsigned int i, printed = 0;
36571 const char *format;
36572
36573 if (ELF_BITS == 64)
36574@@ -568,7 +616,7 @@ static void print_absolute_relocs(void)
36575 struct section *sec_applies, *sec_symtab;
36576 char *sym_strtab;
36577 Elf_Sym *sh_symtab;
36578- int j;
36579+ unsigned int j;
36580 if (sec->shdr.sh_type != SHT_REL_TYPE) {
36581 continue;
36582 }
36583@@ -645,13 +693,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
36584 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
36585 Elf_Sym *sym, const char *symname))
36586 {
36587- int i;
36588+ unsigned int i;
36589 /* Walk through the relocations */
36590 for (i = 0; i < ehdr.e_shnum; i++) {
36591 char *sym_strtab;
36592 Elf_Sym *sh_symtab;
36593 struct section *sec_applies, *sec_symtab;
36594- int j;
36595+ unsigned int j;
36596 struct section *sec = &secs[i];
36597
36598 if (sec->shdr.sh_type != SHT_REL_TYPE) {
36599@@ -697,7 +745,7 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
36600 * kernel data and does not require special treatment.
36601 *
36602 */
36603-static int per_cpu_shndx = -1;
36604+static unsigned int per_cpu_shndx = ~0;
36605 static Elf_Addr per_cpu_load_addr;
36606
36607 static void percpu_init(void)
36608@@ -830,6 +878,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
36609 {
36610 unsigned r_type = ELF32_R_TYPE(rel->r_info);
36611 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
36612+ char *sym_strtab = sec->link->link->strtab;
36613+
36614+ /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
36615+ if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
36616+ return 0;
36617+
36618+#ifdef CONFIG_PAX_KERNEXEC
36619+ /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
36620+ if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
36621+ return 0;
36622+ if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
36623+ return 0;
36624+ if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
36625+ return 0;
36626+ if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
36627+ return 0;
36628+#endif
36629
36630 switch (r_type) {
36631 case R_386_NONE:
36632@@ -968,7 +1033,7 @@ static int write32_as_text(uint32_t v, FILE *f)
36633
36634 static void emit_relocs(int as_text, int use_real_mode)
36635 {
36636- int i;
36637+ unsigned int i;
36638 int (*write_reloc)(uint32_t, FILE *) = write32;
36639 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
36640 const char *symname);
36641@@ -1078,10 +1143,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
36642 {
36643 regex_init(use_real_mode);
36644 read_ehdr(fp);
36645+ read_phdrs(fp);
36646 read_shdrs(fp);
36647 read_strtabs(fp);
36648 read_symtabs(fp);
36649- read_relocs(fp);
36650+ read_relocs(fp, use_real_mode);
36651 if (ELF_BITS == 64)
36652 percpu_init();
36653 if (show_absolute_syms) {
36654diff --git a/arch/x86/um/mem_32.c b/arch/x86/um/mem_32.c
36655index 744afdc..a0b8a0d 100644
36656--- a/arch/x86/um/mem_32.c
36657+++ b/arch/x86/um/mem_32.c
36658@@ -20,7 +20,7 @@ static int __init gate_vma_init(void)
36659 gate_vma.vm_start = FIXADDR_USER_START;
36660 gate_vma.vm_end = FIXADDR_USER_END;
36661 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
36662- gate_vma.vm_page_prot = __P101;
36663+ gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
36664
36665 return 0;
36666 }
36667diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
36668index 48e3858..ab4458c 100644
36669--- a/arch/x86/um/tls_32.c
36670+++ b/arch/x86/um/tls_32.c
36671@@ -261,7 +261,7 @@ out:
36672 if (unlikely(task == current &&
36673 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
36674 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
36675- "without flushed TLS.", current->pid);
36676+ "without flushed TLS.", task_pid_nr(current));
36677 }
36678
36679 return 0;
36680diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
36681index 4841453..d59a203 100644
36682--- a/arch/x86/xen/Kconfig
36683+++ b/arch/x86/xen/Kconfig
36684@@ -9,6 +9,7 @@ config XEN
36685 select XEN_HAVE_PVMMU
36686 depends on X86_64 || (X86_32 && X86_PAE)
36687 depends on X86_LOCAL_APIC && X86_TSC
36688+ depends on !GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_VIRT_XEN
36689 help
36690 This is the Linux Xen port. Enabling this will allow the
36691 kernel to boot in a paravirtualized environment under the
36692diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
36693index 777ad2f..fa43e03 100644
36694--- a/arch/x86/xen/enlighten.c
36695+++ b/arch/x86/xen/enlighten.c
36696@@ -129,8 +129,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
36697
36698 struct shared_info xen_dummy_shared_info;
36699
36700-void *xen_initial_gdt;
36701-
36702 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
36703 __read_mostly int xen_have_vector_callback;
36704 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
36705@@ -588,8 +586,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
36706 {
36707 unsigned long va = dtr->address;
36708 unsigned int size = dtr->size + 1;
36709- unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
36710- unsigned long frames[pages];
36711+ unsigned long frames[65536 / PAGE_SIZE];
36712 int f;
36713
36714 /*
36715@@ -637,8 +634,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
36716 {
36717 unsigned long va = dtr->address;
36718 unsigned int size = dtr->size + 1;
36719- unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
36720- unsigned long frames[pages];
36721+ unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
36722 int f;
36723
36724 /*
36725@@ -646,7 +642,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
36726 * 8-byte entries, or 16 4k pages..
36727 */
36728
36729- BUG_ON(size > 65536);
36730+ BUG_ON(size > GDT_SIZE);
36731 BUG_ON(va & ~PAGE_MASK);
36732
36733 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
36734@@ -1268,30 +1264,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
36735 #endif
36736 };
36737
36738-static void xen_reboot(int reason)
36739+static __noreturn void xen_reboot(int reason)
36740 {
36741 struct sched_shutdown r = { .reason = reason };
36742
36743- if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
36744- BUG();
36745+ HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
36746+ BUG();
36747 }
36748
36749-static void xen_restart(char *msg)
36750+static __noreturn void xen_restart(char *msg)
36751 {
36752 xen_reboot(SHUTDOWN_reboot);
36753 }
36754
36755-static void xen_emergency_restart(void)
36756+static __noreturn void xen_emergency_restart(void)
36757 {
36758 xen_reboot(SHUTDOWN_reboot);
36759 }
36760
36761-static void xen_machine_halt(void)
36762+static __noreturn void xen_machine_halt(void)
36763 {
36764 xen_reboot(SHUTDOWN_poweroff);
36765 }
36766
36767-static void xen_machine_power_off(void)
36768+static __noreturn void xen_machine_power_off(void)
36769 {
36770 if (pm_power_off)
36771 pm_power_off();
36772@@ -1444,8 +1440,11 @@ static void __ref xen_setup_gdt(int cpu)
36773 pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry_boot;
36774 pv_cpu_ops.load_gdt = xen_load_gdt_boot;
36775
36776- setup_stack_canary_segment(0);
36777- switch_to_new_gdt(0);
36778+ setup_stack_canary_segment(cpu);
36779+#ifdef CONFIG_X86_64
36780+ load_percpu_segment(cpu);
36781+#endif
36782+ switch_to_new_gdt(cpu);
36783
36784 pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry;
36785 pv_cpu_ops.load_gdt = xen_load_gdt;
36786@@ -1561,7 +1560,17 @@ asmlinkage __visible void __init xen_start_kernel(void)
36787 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
36788
36789 /* Work out if we support NX */
36790- x86_configure_nx();
36791+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
36792+ if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
36793+ (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
36794+ unsigned l, h;
36795+
36796+ __supported_pte_mask |= _PAGE_NX;
36797+ rdmsr(MSR_EFER, l, h);
36798+ l |= EFER_NX;
36799+ wrmsr(MSR_EFER, l, h);
36800+ }
36801+#endif
36802
36803 /* Get mfn list */
36804 xen_build_dynamic_phys_to_machine();
36805@@ -1589,13 +1598,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
36806
36807 machine_ops = xen_machine_ops;
36808
36809- /*
36810- * The only reliable way to retain the initial address of the
36811- * percpu gdt_page is to remember it here, so we can go and
36812- * mark it RW later, when the initial percpu area is freed.
36813- */
36814- xen_initial_gdt = &per_cpu(gdt_page, 0);
36815-
36816 xen_smp_init();
36817
36818 #ifdef CONFIG_ACPI_NUMA
36819diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
36820index dd151b2..3291e38 100644
36821--- a/arch/x86/xen/mmu.c
36822+++ b/arch/x86/xen/mmu.c
36823@@ -1835,7 +1835,11 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
36824 * L3_k[511] -> level2_fixmap_pgt */
36825 convert_pfn_mfn(level3_kernel_pgt);
36826
36827+ convert_pfn_mfn(level3_vmalloc_start_pgt);
36828+ convert_pfn_mfn(level3_vmalloc_end_pgt);
36829+ convert_pfn_mfn(level3_vmemmap_pgt);
36830 /* L3_k[511][506] -> level1_fixmap_pgt */
36831+ /* L3_k[511][507] -> level1_vsyscall_pgt */
36832 convert_pfn_mfn(level2_fixmap_pgt);
36833 }
36834 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
36835@@ -1860,11 +1864,22 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
36836 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
36837 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
36838 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
36839+ set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
36840+ set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
36841+ set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
36842 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
36843 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
36844+ set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
36845 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
36846 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
36847- set_page_prot(level1_fixmap_pgt, PAGE_KERNEL_RO);
36848+ set_page_prot(level1_modules_pgt[0], PAGE_KERNEL_RO);
36849+ set_page_prot(level1_modules_pgt[1], PAGE_KERNEL_RO);
36850+ set_page_prot(level1_modules_pgt[2], PAGE_KERNEL_RO);
36851+ set_page_prot(level1_modules_pgt[3], PAGE_KERNEL_RO);
36852+ set_page_prot(level1_fixmap_pgt[0], PAGE_KERNEL_RO);
36853+ set_page_prot(level1_fixmap_pgt[1], PAGE_KERNEL_RO);
36854+ set_page_prot(level1_fixmap_pgt[2], PAGE_KERNEL_RO);
36855+ set_page_prot(level1_vsyscall_pgt, PAGE_KERNEL_RO);
36856
36857 /* Pin down new L4 */
36858 pin_pagetable_pfn(MMUEXT_PIN_L4_TABLE,
36859@@ -2048,6 +2063,7 @@ static void __init xen_post_allocator_init(void)
36860 pv_mmu_ops.set_pud = xen_set_pud;
36861 #if CONFIG_PGTABLE_LEVELS == 4
36862 pv_mmu_ops.set_pgd = xen_set_pgd;
36863+ pv_mmu_ops.set_pgd_batched = xen_set_pgd;
36864 #endif
36865
36866 /* This will work as long as patching hasn't happened yet
36867@@ -2126,6 +2142,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
36868 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
36869 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
36870 .set_pgd = xen_set_pgd_hyper,
36871+ .set_pgd_batched = xen_set_pgd_hyper,
36872
36873 .alloc_pud = xen_alloc_pmd_init,
36874 .release_pud = xen_release_pmd_init,
36875diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
36876index 8648438..18bac20 100644
36877--- a/arch/x86/xen/smp.c
36878+++ b/arch/x86/xen/smp.c
36879@@ -284,17 +284,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
36880
36881 if (xen_pv_domain()) {
36882 if (!xen_feature(XENFEAT_writable_page_tables))
36883- /* We've switched to the "real" per-cpu gdt, so make
36884- * sure the old memory can be recycled. */
36885- make_lowmem_page_readwrite(xen_initial_gdt);
36886-
36887 #ifdef CONFIG_X86_32
36888 /*
36889 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
36890 * expects __USER_DS
36891 */
36892- loadsegment(ds, __USER_DS);
36893- loadsegment(es, __USER_DS);
36894+ loadsegment(ds, __KERNEL_DS);
36895+ loadsegment(es, __KERNEL_DS);
36896 #endif
36897
36898 xen_filter_cpu_maps();
36899@@ -375,7 +371,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
36900 #ifdef CONFIG_X86_32
36901 /* Note: PVH is not yet supported on x86_32. */
36902 ctxt->user_regs.fs = __KERNEL_PERCPU;
36903- ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
36904+ savesegment(gs, ctxt->user_regs.gs);
36905 #endif
36906 memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
36907
36908@@ -383,8 +379,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
36909 ctxt->user_regs.eip = (unsigned long)cpu_bringup_and_idle;
36910 ctxt->flags = VGCF_IN_KERNEL;
36911 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
36912- ctxt->user_regs.ds = __USER_DS;
36913- ctxt->user_regs.es = __USER_DS;
36914+ ctxt->user_regs.ds = __KERNEL_DS;
36915+ ctxt->user_regs.es = __KERNEL_DS;
36916 ctxt->user_regs.ss = __KERNEL_DS;
36917
36918 xen_copy_trap_info(ctxt->trap_ctxt);
36919@@ -720,7 +716,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
36920
36921 void __init xen_smp_init(void)
36922 {
36923- smp_ops = xen_smp_ops;
36924+ memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
36925 xen_fill_possible_map();
36926 }
36927
36928diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
36929index fd92a64..1f72641 100644
36930--- a/arch/x86/xen/xen-asm_32.S
36931+++ b/arch/x86/xen/xen-asm_32.S
36932@@ -99,7 +99,7 @@ ENTRY(xen_iret)
36933 pushw %fs
36934 movl $(__KERNEL_PERCPU), %eax
36935 movl %eax, %fs
36936- movl %fs:xen_vcpu, %eax
36937+ mov PER_CPU_VAR(xen_vcpu), %eax
36938 POP_FS
36939 #else
36940 movl %ss:xen_vcpu, %eax
36941diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
36942index 8afdfcc..79239db 100644
36943--- a/arch/x86/xen/xen-head.S
36944+++ b/arch/x86/xen/xen-head.S
36945@@ -41,6 +41,17 @@ ENTRY(startup_xen)
36946 #ifdef CONFIG_X86_32
36947 mov %esi,xen_start_info
36948 mov $init_thread_union+THREAD_SIZE,%esp
36949+#ifdef CONFIG_SMP
36950+ movl $cpu_gdt_table,%edi
36951+ movl $__per_cpu_load,%eax
36952+ movw %ax,__KERNEL_PERCPU + 2(%edi)
36953+ rorl $16,%eax
36954+ movb %al,__KERNEL_PERCPU + 4(%edi)
36955+ movb %ah,__KERNEL_PERCPU + 7(%edi)
36956+ movl $__per_cpu_end - 1,%eax
36957+ subl $__per_cpu_start,%eax
36958+ movw %ax,__KERNEL_PERCPU + 0(%edi)
36959+#endif
36960 #else
36961 mov %rsi,xen_start_info
36962 mov $init_thread_union+THREAD_SIZE,%rsp
36963diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
36964index 2292721..a9bb18e 100644
36965--- a/arch/x86/xen/xen-ops.h
36966+++ b/arch/x86/xen/xen-ops.h
36967@@ -16,8 +16,6 @@ void xen_syscall_target(void);
36968 void xen_syscall32_target(void);
36969 #endif
36970
36971-extern void *xen_initial_gdt;
36972-
36973 struct trap_info;
36974 void xen_copy_trap_info(struct trap_info *traps);
36975
36976diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
36977index 525bd3d..ef888b1 100644
36978--- a/arch/xtensa/variants/dc232b/include/variant/core.h
36979+++ b/arch/xtensa/variants/dc232b/include/variant/core.h
36980@@ -119,9 +119,9 @@
36981 ----------------------------------------------------------------------*/
36982
36983 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
36984-#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
36985 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
36986 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
36987+#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
36988
36989 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
36990 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
36991diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
36992index 2f33760..835e50a 100644
36993--- a/arch/xtensa/variants/fsf/include/variant/core.h
36994+++ b/arch/xtensa/variants/fsf/include/variant/core.h
36995@@ -11,6 +11,7 @@
36996 #ifndef _XTENSA_CORE_H
36997 #define _XTENSA_CORE_H
36998
36999+#include <linux/const.h>
37000
37001 /****************************************************************************
37002 Parameters Useful for Any Code, USER or PRIVILEGED
37003@@ -112,9 +113,9 @@
37004 ----------------------------------------------------------------------*/
37005
37006 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
37007-#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
37008 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
37009 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
37010+#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
37011
37012 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
37013 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
37014diff --git a/block/bio.c b/block/bio.c
37015index d6e5ba3..2bb142c 100644
37016--- a/block/bio.c
37017+++ b/block/bio.c
37018@@ -1187,7 +1187,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
37019 /*
37020 * Overflow, abort
37021 */
37022- if (end < start)
37023+ if (end < start || end - start > INT_MAX - nr_pages)
37024 return ERR_PTR(-EINVAL);
37025
37026 nr_pages += end - start;
37027@@ -1312,7 +1312,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,
37028 /*
37029 * Overflow, abort
37030 */
37031- if (end < start)
37032+ if (end < start || end - start > INT_MAX - nr_pages)
37033 return ERR_PTR(-EINVAL);
37034
37035 nr_pages += end - start;
37036diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
37037index 0736729..2ec3b48 100644
37038--- a/block/blk-iopoll.c
37039+++ b/block/blk-iopoll.c
37040@@ -74,7 +74,7 @@ void blk_iopoll_complete(struct blk_iopoll *iop)
37041 }
37042 EXPORT_SYMBOL(blk_iopoll_complete);
37043
37044-static void blk_iopoll_softirq(struct softirq_action *h)
37045+static __latent_entropy void blk_iopoll_softirq(void)
37046 {
37047 struct list_head *list = this_cpu_ptr(&blk_cpu_iopoll);
37048 int rearm = 0, budget = blk_iopoll_budget;
37049diff --git a/block/blk-map.c b/block/blk-map.c
37050index da310a1..213b5c9 100644
37051--- a/block/blk-map.c
37052+++ b/block/blk-map.c
37053@@ -192,7 +192,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
37054 if (!len || !kbuf)
37055 return -EINVAL;
37056
37057- do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
37058+ do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
37059 if (do_copy)
37060 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
37061 else
37062diff --git a/block/blk-softirq.c b/block/blk-softirq.c
37063index 53b1737..08177d2e 100644
37064--- a/block/blk-softirq.c
37065+++ b/block/blk-softirq.c
37066@@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
37067 * Softirq action handler - move entries to local list and loop over them
37068 * while passing them to the queue registered handler.
37069 */
37070-static void blk_done_softirq(struct softirq_action *h)
37071+static __latent_entropy void blk_done_softirq(void)
37072 {
37073 struct list_head *cpu_list, local_list;
37074
37075diff --git a/block/bsg.c b/block/bsg.c
37076index d214e92..9649863 100644
37077--- a/block/bsg.c
37078+++ b/block/bsg.c
37079@@ -140,16 +140,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
37080 struct sg_io_v4 *hdr, struct bsg_device *bd,
37081 fmode_t has_write_perm)
37082 {
37083+ unsigned char tmpcmd[sizeof(rq->__cmd)];
37084+ unsigned char *cmdptr;
37085+
37086 if (hdr->request_len > BLK_MAX_CDB) {
37087 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
37088 if (!rq->cmd)
37089 return -ENOMEM;
37090- }
37091+ cmdptr = rq->cmd;
37092+ } else
37093+ cmdptr = tmpcmd;
37094
37095- if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
37096+ if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
37097 hdr->request_len))
37098 return -EFAULT;
37099
37100+ if (cmdptr != rq->cmd)
37101+ memcpy(rq->cmd, cmdptr, hdr->request_len);
37102+
37103 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
37104 if (blk_verify_command(rq->cmd, has_write_perm))
37105 return -EPERM;
37106diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
37107index f678c73..f35aa18 100644
37108--- a/block/compat_ioctl.c
37109+++ b/block/compat_ioctl.c
37110@@ -156,7 +156,7 @@ static int compat_cdrom_generic_command(struct block_device *bdev, fmode_t mode,
37111 cgc = compat_alloc_user_space(sizeof(*cgc));
37112 cgc32 = compat_ptr(arg);
37113
37114- if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) ||
37115+ if (copy_in_user(cgc->cmd, cgc32->cmd, sizeof(cgc->cmd)) ||
37116 get_user(data, &cgc32->buffer) ||
37117 put_user(compat_ptr(data), &cgc->buffer) ||
37118 copy_in_user(&cgc->buflen, &cgc32->buflen,
37119@@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
37120 err |= __get_user(f->spec1, &uf->spec1);
37121 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
37122 err |= __get_user(name, &uf->name);
37123- f->name = compat_ptr(name);
37124+ f->name = (void __force_kernel *)compat_ptr(name);
37125 if (err) {
37126 err = -EFAULT;
37127 goto out;
37128diff --git a/block/genhd.c b/block/genhd.c
37129index 59a1395..54ff187 100644
37130--- a/block/genhd.c
37131+++ b/block/genhd.c
37132@@ -470,21 +470,24 @@ static char *bdevt_str(dev_t devt, char *buf)
37133
37134 /*
37135 * Register device numbers dev..(dev+range-1)
37136- * range must be nonzero
37137+ * Noop if @range is zero.
37138 * The hash chain is sorted on range, so that subranges can override.
37139 */
37140 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
37141 struct kobject *(*probe)(dev_t, int *, void *),
37142 int (*lock)(dev_t, void *), void *data)
37143 {
37144- kobj_map(bdev_map, devt, range, module, probe, lock, data);
37145+ if (range)
37146+ kobj_map(bdev_map, devt, range, module, probe, lock, data);
37147 }
37148
37149 EXPORT_SYMBOL(blk_register_region);
37150
37151+/* undo blk_register_region(), noop if @range is zero */
37152 void blk_unregister_region(dev_t devt, unsigned long range)
37153 {
37154- kobj_unmap(bdev_map, devt, range);
37155+ if (range)
37156+ kobj_unmap(bdev_map, devt, range);
37157 }
37158
37159 EXPORT_SYMBOL(blk_unregister_region);
37160diff --git a/block/partitions/efi.c b/block/partitions/efi.c
37161index 26cb624..a49c3a5 100644
37162--- a/block/partitions/efi.c
37163+++ b/block/partitions/efi.c
37164@@ -293,14 +293,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
37165 if (!gpt)
37166 return NULL;
37167
37168+ if (!le32_to_cpu(gpt->num_partition_entries))
37169+ return NULL;
37170+ pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
37171+ if (!pte)
37172+ return NULL;
37173+
37174 count = le32_to_cpu(gpt->num_partition_entries) *
37175 le32_to_cpu(gpt->sizeof_partition_entry);
37176- if (!count)
37177- return NULL;
37178- pte = kmalloc(count, GFP_KERNEL);
37179- if (!pte)
37180- return NULL;
37181-
37182 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
37183 (u8 *) pte, count) < count) {
37184 kfree(pte);
37185diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
37186index dda653c..028a13ee 100644
37187--- a/block/scsi_ioctl.c
37188+++ b/block/scsi_ioctl.c
37189@@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
37190 return put_user(0, p);
37191 }
37192
37193-static int sg_get_timeout(struct request_queue *q)
37194+static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
37195 {
37196 return jiffies_to_clock_t(q->sg_timeout);
37197 }
37198@@ -227,8 +227,20 @@ EXPORT_SYMBOL(blk_verify_command);
37199 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
37200 struct sg_io_hdr *hdr, fmode_t mode)
37201 {
37202- if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
37203+ unsigned char tmpcmd[sizeof(rq->__cmd)];
37204+ unsigned char *cmdptr;
37205+
37206+ if (rq->cmd != rq->__cmd)
37207+ cmdptr = rq->cmd;
37208+ else
37209+ cmdptr = tmpcmd;
37210+
37211+ if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
37212 return -EFAULT;
37213+
37214+ if (cmdptr != rq->cmd)
37215+ memcpy(rq->cmd, cmdptr, hdr->cmd_len);
37216+
37217 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
37218 return -EPERM;
37219
37220@@ -420,6 +432,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
37221 int err;
37222 unsigned int in_len, out_len, bytes, opcode, cmdlen;
37223 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
37224+ unsigned char tmpcmd[sizeof(rq->__cmd)];
37225+ unsigned char *cmdptr;
37226
37227 if (!sic)
37228 return -EINVAL;
37229@@ -458,9 +472,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
37230 */
37231 err = -EFAULT;
37232 rq->cmd_len = cmdlen;
37233- if (copy_from_user(rq->cmd, sic->data, cmdlen))
37234+
37235+ if (rq->cmd != rq->__cmd)
37236+ cmdptr = rq->cmd;
37237+ else
37238+ cmdptr = tmpcmd;
37239+
37240+ if (copy_from_user(cmdptr, sic->data, cmdlen))
37241 goto error;
37242
37243+ if (rq->cmd != cmdptr)
37244+ memcpy(rq->cmd, cmdptr, cmdlen);
37245+
37246 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
37247 goto error;
37248
37249diff --git a/crypto/cryptd.c b/crypto/cryptd.c
37250index 22ba81f..1acac67 100644
37251--- a/crypto/cryptd.c
37252+++ b/crypto/cryptd.c
37253@@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
37254
37255 struct cryptd_blkcipher_request_ctx {
37256 crypto_completion_t complete;
37257-};
37258+} __no_const;
37259
37260 struct cryptd_hash_ctx {
37261 struct crypto_shash *child;
37262@@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
37263
37264 struct cryptd_aead_request_ctx {
37265 crypto_completion_t complete;
37266-};
37267+} __no_const;
37268
37269 static void cryptd_queue_worker(struct work_struct *work);
37270
37271diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
37272index 45e7d51..2967121 100644
37273--- a/crypto/pcrypt.c
37274+++ b/crypto/pcrypt.c
37275@@ -385,7 +385,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
37276 int ret;
37277
37278 pinst->kobj.kset = pcrypt_kset;
37279- ret = kobject_add(&pinst->kobj, NULL, name);
37280+ ret = kobject_add(&pinst->kobj, NULL, "%s", name);
37281 if (!ret)
37282 kobject_uevent(&pinst->kobj, KOBJ_ADD);
37283
37284diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c
37285index ea5815c..5880da6 100644
37286--- a/crypto/scatterwalk.c
37287+++ b/crypto/scatterwalk.c
37288@@ -109,14 +109,20 @@ void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
37289 {
37290 struct scatter_walk walk;
37291 struct scatterlist tmp[2];
37292+ void *realbuf = buf;
37293
37294 if (!nbytes)
37295 return;
37296
37297 sg = scatterwalk_ffwd(tmp, sg, start);
37298
37299- if (sg_page(sg) == virt_to_page(buf) &&
37300- sg->offset == offset_in_page(buf))
37301+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
37302+ if (object_starts_on_stack(buf))
37303+ realbuf = buf - current->stack + current->lowmem_stack;
37304+#endif
37305+
37306+ if (sg_page(sg) == virt_to_page(realbuf) &&
37307+ sg->offset == offset_in_page(realbuf))
37308 return;
37309
37310 scatterwalk_start(&walk, sg);
37311diff --git a/crypto/zlib.c b/crypto/zlib.c
37312index d51a30a..fb1f8af 100644
37313--- a/crypto/zlib.c
37314+++ b/crypto/zlib.c
37315@@ -95,10 +95,10 @@ static int zlib_compress_setup(struct crypto_pcomp *tfm, const void *params,
37316 zlib_comp_exit(ctx);
37317
37318 window_bits = tb[ZLIB_COMP_WINDOWBITS]
37319- ? nla_get_u32(tb[ZLIB_COMP_WINDOWBITS])
37320+ ? nla_get_s32(tb[ZLIB_COMP_WINDOWBITS])
37321 : MAX_WBITS;
37322 mem_level = tb[ZLIB_COMP_MEMLEVEL]
37323- ? nla_get_u32(tb[ZLIB_COMP_MEMLEVEL])
37324+ ? nla_get_s32(tb[ZLIB_COMP_MEMLEVEL])
37325 : DEF_MEM_LEVEL;
37326
37327 workspacesize = zlib_deflate_workspacesize(window_bits, mem_level);
37328diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
37329index 8c2fe2f..fc47c12 100644
37330--- a/drivers/acpi/acpi_video.c
37331+++ b/drivers/acpi/acpi_video.c
37332@@ -398,7 +398,7 @@ static int video_disable_backlight_sysfs_if(
37333 return 0;
37334 }
37335
37336-static struct dmi_system_id video_dmi_table[] = {
37337+static const struct dmi_system_id video_dmi_table[] = {
37338 /*
37339 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121
37340 */
37341diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
37342index 52dfd0d..8386baf 100644
37343--- a/drivers/acpi/acpica/hwxfsleep.c
37344+++ b/drivers/acpi/acpica/hwxfsleep.c
37345@@ -70,11 +70,12 @@ static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id);
37346 /* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */
37347
37348 static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
37349- {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
37350- acpi_hw_extended_sleep},
37351- {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
37352- acpi_hw_extended_wake_prep},
37353- {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake}
37354+ {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
37355+ .extended_function = acpi_hw_extended_sleep},
37356+ {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
37357+ .extended_function = acpi_hw_extended_wake_prep},
37358+ {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake),
37359+ .extended_function = acpi_hw_extended_wake}
37360 };
37361
37362 /*
37363diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
37364index 16129c7..8b675cd 100644
37365--- a/drivers/acpi/apei/apei-internal.h
37366+++ b/drivers/acpi/apei/apei-internal.h
37367@@ -19,7 +19,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
37368 struct apei_exec_ins_type {
37369 u32 flags;
37370 apei_exec_ins_func_t run;
37371-};
37372+} __do_const;
37373
37374 struct apei_exec_context {
37375 u32 ip;
37376diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
37377index 2bfd53c..391e9a4 100644
37378--- a/drivers/acpi/apei/ghes.c
37379+++ b/drivers/acpi/apei/ghes.c
37380@@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
37381 const struct acpi_hest_generic *generic,
37382 const struct acpi_hest_generic_status *estatus)
37383 {
37384- static atomic_t seqno;
37385+ static atomic_unchecked_t seqno;
37386 unsigned int curr_seqno;
37387 char pfx_seq[64];
37388
37389@@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
37390 else
37391 pfx = KERN_ERR;
37392 }
37393- curr_seqno = atomic_inc_return(&seqno);
37394+ curr_seqno = atomic_inc_return_unchecked(&seqno);
37395 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
37396 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
37397 pfx_seq, generic->header.source_id);
37398diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
37399index a83e3c6..c3d617f 100644
37400--- a/drivers/acpi/bgrt.c
37401+++ b/drivers/acpi/bgrt.c
37402@@ -86,8 +86,10 @@ static int __init bgrt_init(void)
37403 if (!bgrt_image)
37404 return -ENODEV;
37405
37406- bin_attr_image.private = bgrt_image;
37407- bin_attr_image.size = bgrt_image_size;
37408+ pax_open_kernel();
37409+ *(void **)&bin_attr_image.private = bgrt_image;
37410+ *(size_t *)&bin_attr_image.size = bgrt_image_size;
37411+ pax_close_kernel();
37412
37413 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
37414 if (!bgrt_kobj)
37415diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
37416index 278dc4b..976433d 100644
37417--- a/drivers/acpi/blacklist.c
37418+++ b/drivers/acpi/blacklist.c
37419@@ -51,7 +51,7 @@ struct acpi_blacklist_item {
37420 u32 is_critical_error;
37421 };
37422
37423-static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
37424+static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
37425
37426 /*
37427 * POLICY: If *anything* doesn't work, put it on the blacklist.
37428@@ -172,7 +172,7 @@ static int __init dmi_enable_rev_override(const struct dmi_system_id *d)
37429 }
37430 #endif
37431
37432-static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
37433+static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
37434 {
37435 .callback = dmi_disable_osi_vista,
37436 .ident = "Fujitsu Siemens",
37437diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
37438index 513e7230e..802015a 100644
37439--- a/drivers/acpi/bus.c
37440+++ b/drivers/acpi/bus.c
37441@@ -67,7 +67,7 @@ static int set_copy_dsdt(const struct dmi_system_id *id)
37442 }
37443 #endif
37444
37445-static struct dmi_system_id dsdt_dmi_table[] __initdata = {
37446+static const struct dmi_system_id dsdt_dmi_table[] __initconst = {
37447 /*
37448 * Invoke DSDT corruption work-around on all Toshiba Satellite.
37449 * https://bugzilla.kernel.org/show_bug.cgi?id=14679
37450@@ -83,7 +83,7 @@ static struct dmi_system_id dsdt_dmi_table[] __initdata = {
37451 {}
37452 };
37453 #else
37454-static struct dmi_system_id dsdt_dmi_table[] __initdata = {
37455+static const struct dmi_system_id dsdt_dmi_table[] __initconst = {
37456 {}
37457 };
37458 #endif
37459diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
37460index c68e724..e863008 100644
37461--- a/drivers/acpi/custom_method.c
37462+++ b/drivers/acpi/custom_method.c
37463@@ -29,6 +29,10 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
37464 struct acpi_table_header table;
37465 acpi_status status;
37466
37467+#ifdef CONFIG_GRKERNSEC_KMEM
37468+ return -EPERM;
37469+#endif
37470+
37471 if (!(*ppos)) {
37472 /* parse the table header to get the table length */
37473 if (count <= sizeof(struct acpi_table_header))
37474diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
37475index 88dbbb1..90714c0 100644
37476--- a/drivers/acpi/device_pm.c
37477+++ b/drivers/acpi/device_pm.c
37478@@ -1045,6 +1045,8 @@ EXPORT_SYMBOL_GPL(acpi_subsys_freeze);
37479
37480 #endif /* CONFIG_PM_SLEEP */
37481
37482+static void acpi_dev_pm_detach(struct device *dev, bool power_off);
37483+
37484 static struct dev_pm_domain acpi_general_pm_domain = {
37485 .ops = {
37486 .runtime_suspend = acpi_subsys_runtime_suspend,
37487@@ -1061,6 +1063,7 @@ static struct dev_pm_domain acpi_general_pm_domain = {
37488 .restore_early = acpi_subsys_resume_early,
37489 #endif
37490 },
37491+ .detach = acpi_dev_pm_detach
37492 };
37493
37494 /**
37495@@ -1130,7 +1133,6 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
37496 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
37497 }
37498
37499- dev->pm_domain->detach = acpi_dev_pm_detach;
37500 return 0;
37501 }
37502 EXPORT_SYMBOL_GPL(acpi_dev_pm_attach);
37503diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
37504index 9d4761d..ece2163 100644
37505--- a/drivers/acpi/ec.c
37506+++ b/drivers/acpi/ec.c
37507@@ -1434,7 +1434,7 @@ static int ec_clear_on_resume(const struct dmi_system_id *id)
37508 return 0;
37509 }
37510
37511-static struct dmi_system_id ec_dmi_table[] __initdata = {
37512+static const struct dmi_system_id ec_dmi_table[] __initconst = {
37513 {
37514 ec_skip_dsdt_scan, "Compal JFL92", {
37515 DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
37516diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
37517index 139d9e4..9a9d799 100644
37518--- a/drivers/acpi/pci_slot.c
37519+++ b/drivers/acpi/pci_slot.c
37520@@ -195,7 +195,7 @@ static int do_sta_before_sun(const struct dmi_system_id *d)
37521 return 0;
37522 }
37523
37524-static struct dmi_system_id acpi_pci_slot_dmi_table[] __initdata = {
37525+static const struct dmi_system_id acpi_pci_slot_dmi_table[] __initconst = {
37526 /*
37527 * Fujitsu Primequest machines will return 1023 to indicate an
37528 * error if the _SUN method is evaluated on SxFy objects that
37529diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
37530index d9f7158..168e742 100644
37531--- a/drivers/acpi/processor_driver.c
37532+++ b/drivers/acpi/processor_driver.c
37533@@ -159,7 +159,7 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
37534 return NOTIFY_OK;
37535 }
37536
37537-static struct notifier_block __refdata acpi_cpu_notifier = {
37538+static struct notifier_block __refconst acpi_cpu_notifier = {
37539 .notifier_call = acpi_cpu_soft_notify,
37540 };
37541
37542diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
37543index d540f42..d5b32ac 100644
37544--- a/drivers/acpi/processor_idle.c
37545+++ b/drivers/acpi/processor_idle.c
37546@@ -910,7 +910,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
37547 {
37548 int i, count = CPUIDLE_DRIVER_STATE_START;
37549 struct acpi_processor_cx *cx;
37550- struct cpuidle_state *state;
37551+ cpuidle_state_no_const *state;
37552 struct cpuidle_driver *drv = &acpi_idle_driver;
37553
37554 if (!pr->flags.power_setup_done)
37555diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
37556index 7cfbda4..74f738c 100644
37557--- a/drivers/acpi/processor_pdc.c
37558+++ b/drivers/acpi/processor_pdc.c
37559@@ -173,7 +173,7 @@ static int __init set_no_mwait(const struct dmi_system_id *id)
37560 return 0;
37561 }
37562
37563-static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
37564+static const struct dmi_system_id processor_idle_dmi_table[] __initconst = {
37565 {
37566 set_no_mwait, "Extensa 5220", {
37567 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
37568diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
37569index 2f0d4db..b9e9b15 100644
37570--- a/drivers/acpi/sleep.c
37571+++ b/drivers/acpi/sleep.c
37572@@ -148,7 +148,7 @@ static int __init init_nvs_nosave(const struct dmi_system_id *d)
37573 return 0;
37574 }
37575
37576-static struct dmi_system_id acpisleep_dmi_table[] __initdata = {
37577+static const struct dmi_system_id acpisleep_dmi_table[] __initconst = {
37578 {
37579 .callback = init_old_suspend_ordering,
37580 .ident = "Abit KN9 (nForce4 variant)",
37581diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
37582index 0876d77b..3ba0127 100644
37583--- a/drivers/acpi/sysfs.c
37584+++ b/drivers/acpi/sysfs.c
37585@@ -423,11 +423,11 @@ static u32 num_counters;
37586 static struct attribute **all_attrs;
37587 static u32 acpi_gpe_count;
37588
37589-static struct attribute_group interrupt_stats_attr_group = {
37590+static attribute_group_no_const interrupt_stats_attr_group = {
37591 .name = "interrupts",
37592 };
37593
37594-static struct kobj_attribute *counter_attrs;
37595+static kobj_attribute_no_const *counter_attrs;
37596
37597 static void delete_gpe_attr_array(void)
37598 {
37599diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
37600index 6d4e44e..44fb839 100644
37601--- a/drivers/acpi/thermal.c
37602+++ b/drivers/acpi/thermal.c
37603@@ -1212,7 +1212,7 @@ static int thermal_psv(const struct dmi_system_id *d) {
37604 return 0;
37605 }
37606
37607-static struct dmi_system_id thermal_dmi_table[] __initdata = {
37608+static const struct dmi_system_id thermal_dmi_table[] __initconst = {
37609 /*
37610 * Award BIOS on this AOpen makes thermal control almost worthless.
37611 * http://bugzilla.kernel.org/show_bug.cgi?id=8842
37612diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
37613index 2922f1f..26b0c03 100644
37614--- a/drivers/acpi/video_detect.c
37615+++ b/drivers/acpi/video_detect.c
37616@@ -41,7 +41,6 @@ ACPI_MODULE_NAME("video");
37617 void acpi_video_unregister_backlight(void);
37618
37619 static bool backlight_notifier_registered;
37620-static struct notifier_block backlight_nb;
37621 static struct work_struct backlight_notify_work;
37622
37623 static enum acpi_backlight_type acpi_backlight_cmdline = acpi_backlight_undef;
37624@@ -284,6 +283,10 @@ static int acpi_video_backlight_notify(struct notifier_block *nb,
37625 return NOTIFY_OK;
37626 }
37627
37628+static const struct notifier_block backlight_nb = {
37629+ .notifier_call = acpi_video_backlight_notify,
37630+};
37631+
37632 /*
37633 * Determine which type of backlight interface to use on this system,
37634 * First check cmdline, then dmi quirks, then do autodetect.
37635@@ -314,8 +317,6 @@ enum acpi_backlight_type acpi_video_get_backlight_type(void)
37636 &video_caps, NULL);
37637 INIT_WORK(&backlight_notify_work,
37638 acpi_video_backlight_notify_work);
37639- backlight_nb.notifier_call = acpi_video_backlight_notify;
37640- backlight_nb.priority = 0;
37641 if (backlight_register_notifier(&backlight_nb) == 0)
37642 backlight_notifier_registered = true;
37643 init_done = true;
37644diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
37645index 790e0de..6bae378 100644
37646--- a/drivers/ata/libata-core.c
37647+++ b/drivers/ata/libata-core.c
37648@@ -102,7 +102,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
37649 static void ata_dev_xfermask(struct ata_device *dev);
37650 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
37651
37652-atomic_t ata_print_id = ATOMIC_INIT(0);
37653+atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
37654
37655 struct ata_force_param {
37656 const char *name;
37657@@ -4800,7 +4800,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
37658 struct ata_port *ap;
37659 unsigned int tag;
37660
37661- WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37662+ BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37663 ap = qc->ap;
37664
37665 qc->flags = 0;
37666@@ -4817,7 +4817,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
37667 struct ata_port *ap;
37668 struct ata_link *link;
37669
37670- WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37671+ BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37672 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
37673 ap = qc->ap;
37674 link = qc->dev->link;
37675@@ -5924,6 +5924,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
37676 return;
37677
37678 spin_lock(&lock);
37679+ pax_open_kernel();
37680
37681 for (cur = ops->inherits; cur; cur = cur->inherits) {
37682 void **inherit = (void **)cur;
37683@@ -5937,8 +5938,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
37684 if (IS_ERR(*pp))
37685 *pp = NULL;
37686
37687- ops->inherits = NULL;
37688+ *(struct ata_port_operations **)&ops->inherits = NULL;
37689
37690+ pax_close_kernel();
37691 spin_unlock(&lock);
37692 }
37693
37694@@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
37695
37696 /* give ports names and add SCSI hosts */
37697 for (i = 0; i < host->n_ports; i++) {
37698- host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
37699+ host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
37700 host->ports[i]->local_port_no = i + 1;
37701 }
37702
37703diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
37704index 0d7f0da..bc20aa6 100644
37705--- a/drivers/ata/libata-scsi.c
37706+++ b/drivers/ata/libata-scsi.c
37707@@ -4193,7 +4193,7 @@ int ata_sas_port_init(struct ata_port *ap)
37708
37709 if (rc)
37710 return rc;
37711- ap->print_id = atomic_inc_return(&ata_print_id);
37712+ ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
37713 return 0;
37714 }
37715 EXPORT_SYMBOL_GPL(ata_sas_port_init);
37716diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
37717index f840ca1..edd6ef3 100644
37718--- a/drivers/ata/libata.h
37719+++ b/drivers/ata/libata.h
37720@@ -53,7 +53,7 @@ enum {
37721 ATA_DNXFER_QUIET = (1 << 31),
37722 };
37723
37724-extern atomic_t ata_print_id;
37725+extern atomic_unchecked_t ata_print_id;
37726 extern int atapi_passthru16;
37727 extern int libata_fua;
37728 extern int libata_noacpi;
37729diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
37730index 5d9ee99..8fa2585 100644
37731--- a/drivers/ata/pata_arasan_cf.c
37732+++ b/drivers/ata/pata_arasan_cf.c
37733@@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
37734 /* Handle platform specific quirks */
37735 if (quirk) {
37736 if (quirk & CF_BROKEN_PIO) {
37737- ap->ops->set_piomode = NULL;
37738+ pax_open_kernel();
37739+ *(void **)&ap->ops->set_piomode = NULL;
37740+ pax_close_kernel();
37741 ap->pio_mask = 0;
37742 }
37743 if (quirk & CF_BROKEN_MWDMA)
37744diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
37745index f9b983a..887b9d8 100644
37746--- a/drivers/atm/adummy.c
37747+++ b/drivers/atm/adummy.c
37748@@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
37749 vcc->pop(vcc, skb);
37750 else
37751 dev_kfree_skb_any(skb);
37752- atomic_inc(&vcc->stats->tx);
37753+ atomic_inc_unchecked(&vcc->stats->tx);
37754
37755 return 0;
37756 }
37757diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
37758index f1a9198..f466a4a 100644
37759--- a/drivers/atm/ambassador.c
37760+++ b/drivers/atm/ambassador.c
37761@@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
37762 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
37763
37764 // VC layer stats
37765- atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
37766+ atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
37767
37768 // free the descriptor
37769 kfree (tx_descr);
37770@@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
37771 dump_skb ("<<<", vc, skb);
37772
37773 // VC layer stats
37774- atomic_inc(&atm_vcc->stats->rx);
37775+ atomic_inc_unchecked(&atm_vcc->stats->rx);
37776 __net_timestamp(skb);
37777 // end of our responsibility
37778 atm_vcc->push (atm_vcc, skb);
37779@@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
37780 } else {
37781 PRINTK (KERN_INFO, "dropped over-size frame");
37782 // should we count this?
37783- atomic_inc(&atm_vcc->stats->rx_drop);
37784+ atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
37785 }
37786
37787 } else {
37788@@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
37789 }
37790
37791 if (check_area (skb->data, skb->len)) {
37792- atomic_inc(&atm_vcc->stats->tx_err);
37793+ atomic_inc_unchecked(&atm_vcc->stats->tx_err);
37794 return -ENOMEM; // ?
37795 }
37796
37797diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
37798index 480fa6f..947067c 100644
37799--- a/drivers/atm/atmtcp.c
37800+++ b/drivers/atm/atmtcp.c
37801@@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
37802 if (vcc->pop) vcc->pop(vcc,skb);
37803 else dev_kfree_skb(skb);
37804 if (dev_data) return 0;
37805- atomic_inc(&vcc->stats->tx_err);
37806+ atomic_inc_unchecked(&vcc->stats->tx_err);
37807 return -ENOLINK;
37808 }
37809 size = skb->len+sizeof(struct atmtcp_hdr);
37810@@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
37811 if (!new_skb) {
37812 if (vcc->pop) vcc->pop(vcc,skb);
37813 else dev_kfree_skb(skb);
37814- atomic_inc(&vcc->stats->tx_err);
37815+ atomic_inc_unchecked(&vcc->stats->tx_err);
37816 return -ENOBUFS;
37817 }
37818 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
37819@@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
37820 if (vcc->pop) vcc->pop(vcc,skb);
37821 else dev_kfree_skb(skb);
37822 out_vcc->push(out_vcc,new_skb);
37823- atomic_inc(&vcc->stats->tx);
37824- atomic_inc(&out_vcc->stats->rx);
37825+ atomic_inc_unchecked(&vcc->stats->tx);
37826+ atomic_inc_unchecked(&out_vcc->stats->rx);
37827 return 0;
37828 }
37829
37830@@ -300,7 +300,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
37831 read_unlock(&vcc_sklist_lock);
37832 if (!out_vcc) {
37833 result = -EUNATCH;
37834- atomic_inc(&vcc->stats->tx_err);
37835+ atomic_inc_unchecked(&vcc->stats->tx_err);
37836 goto done;
37837 }
37838 skb_pull(skb,sizeof(struct atmtcp_hdr));
37839@@ -312,8 +312,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
37840 __net_timestamp(new_skb);
37841 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
37842 out_vcc->push(out_vcc,new_skb);
37843- atomic_inc(&vcc->stats->tx);
37844- atomic_inc(&out_vcc->stats->rx);
37845+ atomic_inc_unchecked(&vcc->stats->tx);
37846+ atomic_inc_unchecked(&out_vcc->stats->rx);
37847 done:
37848 if (vcc->pop) vcc->pop(vcc,skb);
37849 else dev_kfree_skb(skb);
37850diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
37851index 6339efd..2b441d5 100644
37852--- a/drivers/atm/eni.c
37853+++ b/drivers/atm/eni.c
37854@@ -525,7 +525,7 @@ static int rx_aal0(struct atm_vcc *vcc)
37855 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
37856 vcc->dev->number);
37857 length = 0;
37858- atomic_inc(&vcc->stats->rx_err);
37859+ atomic_inc_unchecked(&vcc->stats->rx_err);
37860 }
37861 else {
37862 length = ATM_CELL_SIZE-1; /* no HEC */
37863@@ -580,7 +580,7 @@ static int rx_aal5(struct atm_vcc *vcc)
37864 size);
37865 }
37866 eff = length = 0;
37867- atomic_inc(&vcc->stats->rx_err);
37868+ atomic_inc_unchecked(&vcc->stats->rx_err);
37869 }
37870 else {
37871 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
37872@@ -597,7 +597,7 @@ static int rx_aal5(struct atm_vcc *vcc)
37873 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
37874 vcc->dev->number,vcc->vci,length,size << 2,descr);
37875 length = eff = 0;
37876- atomic_inc(&vcc->stats->rx_err);
37877+ atomic_inc_unchecked(&vcc->stats->rx_err);
37878 }
37879 }
37880 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
37881@@ -770,7 +770,7 @@ rx_dequeued++;
37882 vcc->push(vcc,skb);
37883 pushed++;
37884 }
37885- atomic_inc(&vcc->stats->rx);
37886+ atomic_inc_unchecked(&vcc->stats->rx);
37887 }
37888 wake_up(&eni_dev->rx_wait);
37889 }
37890@@ -1230,7 +1230,7 @@ static void dequeue_tx(struct atm_dev *dev)
37891 DMA_TO_DEVICE);
37892 if (vcc->pop) vcc->pop(vcc,skb);
37893 else dev_kfree_skb_irq(skb);
37894- atomic_inc(&vcc->stats->tx);
37895+ atomic_inc_unchecked(&vcc->stats->tx);
37896 wake_up(&eni_dev->tx_wait);
37897 dma_complete++;
37898 }
37899diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
37900index 82f2ae0..f205c02 100644
37901--- a/drivers/atm/firestream.c
37902+++ b/drivers/atm/firestream.c
37903@@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
37904 }
37905 }
37906
37907- atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
37908+ atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
37909
37910 fs_dprintk (FS_DEBUG_TXMEM, "i");
37911 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
37912@@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
37913 #endif
37914 skb_put (skb, qe->p1 & 0xffff);
37915 ATM_SKB(skb)->vcc = atm_vcc;
37916- atomic_inc(&atm_vcc->stats->rx);
37917+ atomic_inc_unchecked(&atm_vcc->stats->rx);
37918 __net_timestamp(skb);
37919 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
37920 atm_vcc->push (atm_vcc, skb);
37921@@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
37922 kfree (pe);
37923 }
37924 if (atm_vcc)
37925- atomic_inc(&atm_vcc->stats->rx_drop);
37926+ atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
37927 break;
37928 case 0x1f: /* Reassembly abort: no buffers. */
37929 /* Silently increment error counter. */
37930 if (atm_vcc)
37931- atomic_inc(&atm_vcc->stats->rx_drop);
37932+ atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
37933 break;
37934 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
37935 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
37936diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
37937index 75dde90..4309ead 100644
37938--- a/drivers/atm/fore200e.c
37939+++ b/drivers/atm/fore200e.c
37940@@ -932,9 +932,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
37941 #endif
37942 /* check error condition */
37943 if (*entry->status & STATUS_ERROR)
37944- atomic_inc(&vcc->stats->tx_err);
37945+ atomic_inc_unchecked(&vcc->stats->tx_err);
37946 else
37947- atomic_inc(&vcc->stats->tx);
37948+ atomic_inc_unchecked(&vcc->stats->tx);
37949 }
37950 }
37951
37952@@ -1083,7 +1083,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
37953 if (skb == NULL) {
37954 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
37955
37956- atomic_inc(&vcc->stats->rx_drop);
37957+ atomic_inc_unchecked(&vcc->stats->rx_drop);
37958 return -ENOMEM;
37959 }
37960
37961@@ -1126,14 +1126,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
37962
37963 dev_kfree_skb_any(skb);
37964
37965- atomic_inc(&vcc->stats->rx_drop);
37966+ atomic_inc_unchecked(&vcc->stats->rx_drop);
37967 return -ENOMEM;
37968 }
37969
37970 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
37971
37972 vcc->push(vcc, skb);
37973- atomic_inc(&vcc->stats->rx);
37974+ atomic_inc_unchecked(&vcc->stats->rx);
37975
37976 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
37977
37978@@ -1211,7 +1211,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
37979 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
37980 fore200e->atm_dev->number,
37981 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
37982- atomic_inc(&vcc->stats->rx_err);
37983+ atomic_inc_unchecked(&vcc->stats->rx_err);
37984 }
37985 }
37986
37987@@ -1656,7 +1656,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
37988 goto retry_here;
37989 }
37990
37991- atomic_inc(&vcc->stats->tx_err);
37992+ atomic_inc_unchecked(&vcc->stats->tx_err);
37993
37994 fore200e->tx_sat++;
37995 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
37996diff --git a/drivers/atm/he.c b/drivers/atm/he.c
37997index a8da3a5..67cf6c2 100644
37998--- a/drivers/atm/he.c
37999+++ b/drivers/atm/he.c
38000@@ -1692,7 +1692,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
38001
38002 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
38003 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
38004- atomic_inc(&vcc->stats->rx_drop);
38005+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38006 goto return_host_buffers;
38007 }
38008
38009@@ -1719,7 +1719,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
38010 RBRQ_LEN_ERR(he_dev->rbrq_head)
38011 ? "LEN_ERR" : "",
38012 vcc->vpi, vcc->vci);
38013- atomic_inc(&vcc->stats->rx_err);
38014+ atomic_inc_unchecked(&vcc->stats->rx_err);
38015 goto return_host_buffers;
38016 }
38017
38018@@ -1771,7 +1771,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
38019 vcc->push(vcc, skb);
38020 spin_lock(&he_dev->global_lock);
38021
38022- atomic_inc(&vcc->stats->rx);
38023+ atomic_inc_unchecked(&vcc->stats->rx);
38024
38025 return_host_buffers:
38026 ++pdus_assembled;
38027@@ -2097,7 +2097,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
38028 tpd->vcc->pop(tpd->vcc, tpd->skb);
38029 else
38030 dev_kfree_skb_any(tpd->skb);
38031- atomic_inc(&tpd->vcc->stats->tx_err);
38032+ atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
38033 }
38034 dma_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
38035 return;
38036@@ -2509,7 +2509,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38037 vcc->pop(vcc, skb);
38038 else
38039 dev_kfree_skb_any(skb);
38040- atomic_inc(&vcc->stats->tx_err);
38041+ atomic_inc_unchecked(&vcc->stats->tx_err);
38042 return -EINVAL;
38043 }
38044
38045@@ -2520,7 +2520,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38046 vcc->pop(vcc, skb);
38047 else
38048 dev_kfree_skb_any(skb);
38049- atomic_inc(&vcc->stats->tx_err);
38050+ atomic_inc_unchecked(&vcc->stats->tx_err);
38051 return -EINVAL;
38052 }
38053 #endif
38054@@ -2532,7 +2532,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38055 vcc->pop(vcc, skb);
38056 else
38057 dev_kfree_skb_any(skb);
38058- atomic_inc(&vcc->stats->tx_err);
38059+ atomic_inc_unchecked(&vcc->stats->tx_err);
38060 spin_unlock_irqrestore(&he_dev->global_lock, flags);
38061 return -ENOMEM;
38062 }
38063@@ -2574,7 +2574,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38064 vcc->pop(vcc, skb);
38065 else
38066 dev_kfree_skb_any(skb);
38067- atomic_inc(&vcc->stats->tx_err);
38068+ atomic_inc_unchecked(&vcc->stats->tx_err);
38069 spin_unlock_irqrestore(&he_dev->global_lock, flags);
38070 return -ENOMEM;
38071 }
38072@@ -2605,7 +2605,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38073 __enqueue_tpd(he_dev, tpd, cid);
38074 spin_unlock_irqrestore(&he_dev->global_lock, flags);
38075
38076- atomic_inc(&vcc->stats->tx);
38077+ atomic_inc_unchecked(&vcc->stats->tx);
38078
38079 return 0;
38080 }
38081diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
38082index 527bbd5..96570c8 100644
38083--- a/drivers/atm/horizon.c
38084+++ b/drivers/atm/horizon.c
38085@@ -1018,7 +1018,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
38086 {
38087 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
38088 // VC layer stats
38089- atomic_inc(&vcc->stats->rx);
38090+ atomic_inc_unchecked(&vcc->stats->rx);
38091 __net_timestamp(skb);
38092 // end of our responsibility
38093 vcc->push (vcc, skb);
38094@@ -1170,7 +1170,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
38095 dev->tx_iovec = NULL;
38096
38097 // VC layer stats
38098- atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
38099+ atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
38100
38101 // free the skb
38102 hrz_kfree_skb (skb);
38103diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
38104index 074616b..d6b3d5f 100644
38105--- a/drivers/atm/idt77252.c
38106+++ b/drivers/atm/idt77252.c
38107@@ -811,7 +811,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
38108 else
38109 dev_kfree_skb(skb);
38110
38111- atomic_inc(&vcc->stats->tx);
38112+ atomic_inc_unchecked(&vcc->stats->tx);
38113 }
38114
38115 atomic_dec(&scq->used);
38116@@ -1073,13 +1073,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38117 if ((sb = dev_alloc_skb(64)) == NULL) {
38118 printk("%s: Can't allocate buffers for aal0.\n",
38119 card->name);
38120- atomic_add(i, &vcc->stats->rx_drop);
38121+ atomic_add_unchecked(i, &vcc->stats->rx_drop);
38122 break;
38123 }
38124 if (!atm_charge(vcc, sb->truesize)) {
38125 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
38126 card->name);
38127- atomic_add(i - 1, &vcc->stats->rx_drop);
38128+ atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
38129 dev_kfree_skb(sb);
38130 break;
38131 }
38132@@ -1096,7 +1096,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38133 ATM_SKB(sb)->vcc = vcc;
38134 __net_timestamp(sb);
38135 vcc->push(vcc, sb);
38136- atomic_inc(&vcc->stats->rx);
38137+ atomic_inc_unchecked(&vcc->stats->rx);
38138
38139 cell += ATM_CELL_PAYLOAD;
38140 }
38141@@ -1133,13 +1133,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38142 "(CDC: %08x)\n",
38143 card->name, len, rpp->len, readl(SAR_REG_CDC));
38144 recycle_rx_pool_skb(card, rpp);
38145- atomic_inc(&vcc->stats->rx_err);
38146+ atomic_inc_unchecked(&vcc->stats->rx_err);
38147 return;
38148 }
38149 if (stat & SAR_RSQE_CRC) {
38150 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
38151 recycle_rx_pool_skb(card, rpp);
38152- atomic_inc(&vcc->stats->rx_err);
38153+ atomic_inc_unchecked(&vcc->stats->rx_err);
38154 return;
38155 }
38156 if (skb_queue_len(&rpp->queue) > 1) {
38157@@ -1150,7 +1150,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38158 RXPRINTK("%s: Can't alloc RX skb.\n",
38159 card->name);
38160 recycle_rx_pool_skb(card, rpp);
38161- atomic_inc(&vcc->stats->rx_err);
38162+ atomic_inc_unchecked(&vcc->stats->rx_err);
38163 return;
38164 }
38165 if (!atm_charge(vcc, skb->truesize)) {
38166@@ -1169,7 +1169,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38167 __net_timestamp(skb);
38168
38169 vcc->push(vcc, skb);
38170- atomic_inc(&vcc->stats->rx);
38171+ atomic_inc_unchecked(&vcc->stats->rx);
38172
38173 return;
38174 }
38175@@ -1191,7 +1191,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38176 __net_timestamp(skb);
38177
38178 vcc->push(vcc, skb);
38179- atomic_inc(&vcc->stats->rx);
38180+ atomic_inc_unchecked(&vcc->stats->rx);
38181
38182 if (skb->truesize > SAR_FB_SIZE_3)
38183 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
38184@@ -1302,14 +1302,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
38185 if (vcc->qos.aal != ATM_AAL0) {
38186 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
38187 card->name, vpi, vci);
38188- atomic_inc(&vcc->stats->rx_drop);
38189+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38190 goto drop;
38191 }
38192
38193 if ((sb = dev_alloc_skb(64)) == NULL) {
38194 printk("%s: Can't allocate buffers for AAL0.\n",
38195 card->name);
38196- atomic_inc(&vcc->stats->rx_err);
38197+ atomic_inc_unchecked(&vcc->stats->rx_err);
38198 goto drop;
38199 }
38200
38201@@ -1328,7 +1328,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
38202 ATM_SKB(sb)->vcc = vcc;
38203 __net_timestamp(sb);
38204 vcc->push(vcc, sb);
38205- atomic_inc(&vcc->stats->rx);
38206+ atomic_inc_unchecked(&vcc->stats->rx);
38207
38208 drop:
38209 skb_pull(queue, 64);
38210@@ -1953,13 +1953,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
38211
38212 if (vc == NULL) {
38213 printk("%s: NULL connection in send().\n", card->name);
38214- atomic_inc(&vcc->stats->tx_err);
38215+ atomic_inc_unchecked(&vcc->stats->tx_err);
38216 dev_kfree_skb(skb);
38217 return -EINVAL;
38218 }
38219 if (!test_bit(VCF_TX, &vc->flags)) {
38220 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
38221- atomic_inc(&vcc->stats->tx_err);
38222+ atomic_inc_unchecked(&vcc->stats->tx_err);
38223 dev_kfree_skb(skb);
38224 return -EINVAL;
38225 }
38226@@ -1971,14 +1971,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
38227 break;
38228 default:
38229 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
38230- atomic_inc(&vcc->stats->tx_err);
38231+ atomic_inc_unchecked(&vcc->stats->tx_err);
38232 dev_kfree_skb(skb);
38233 return -EINVAL;
38234 }
38235
38236 if (skb_shinfo(skb)->nr_frags != 0) {
38237 printk("%s: No scatter-gather yet.\n", card->name);
38238- atomic_inc(&vcc->stats->tx_err);
38239+ atomic_inc_unchecked(&vcc->stats->tx_err);
38240 dev_kfree_skb(skb);
38241 return -EINVAL;
38242 }
38243@@ -1986,7 +1986,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
38244
38245 err = queue_skb(card, vc, skb, oam);
38246 if (err) {
38247- atomic_inc(&vcc->stats->tx_err);
38248+ atomic_inc_unchecked(&vcc->stats->tx_err);
38249 dev_kfree_skb(skb);
38250 return err;
38251 }
38252@@ -2009,7 +2009,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
38253 skb = dev_alloc_skb(64);
38254 if (!skb) {
38255 printk("%s: Out of memory in send_oam().\n", card->name);
38256- atomic_inc(&vcc->stats->tx_err);
38257+ atomic_inc_unchecked(&vcc->stats->tx_err);
38258 return -ENOMEM;
38259 }
38260 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
38261diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
38262index 65e6590..df77d04 100644
38263--- a/drivers/atm/iphase.c
38264+++ b/drivers/atm/iphase.c
38265@@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
38266 status = (u_short) (buf_desc_ptr->desc_mode);
38267 if (status & (RX_CER | RX_PTE | RX_OFL))
38268 {
38269- atomic_inc(&vcc->stats->rx_err);
38270+ atomic_inc_unchecked(&vcc->stats->rx_err);
38271 IF_ERR(printk("IA: bad packet, dropping it");)
38272 if (status & RX_CER) {
38273 IF_ERR(printk(" cause: packet CRC error\n");)
38274@@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
38275 len = dma_addr - buf_addr;
38276 if (len > iadev->rx_buf_sz) {
38277 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
38278- atomic_inc(&vcc->stats->rx_err);
38279+ atomic_inc_unchecked(&vcc->stats->rx_err);
38280 goto out_free_desc;
38281 }
38282
38283@@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
38284 ia_vcc = INPH_IA_VCC(vcc);
38285 if (ia_vcc == NULL)
38286 {
38287- atomic_inc(&vcc->stats->rx_err);
38288+ atomic_inc_unchecked(&vcc->stats->rx_err);
38289 atm_return(vcc, skb->truesize);
38290 dev_kfree_skb_any(skb);
38291 goto INCR_DLE;
38292@@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
38293 if ((length > iadev->rx_buf_sz) || (length >
38294 (skb->len - sizeof(struct cpcs_trailer))))
38295 {
38296- atomic_inc(&vcc->stats->rx_err);
38297+ atomic_inc_unchecked(&vcc->stats->rx_err);
38298 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
38299 length, skb->len);)
38300 atm_return(vcc, skb->truesize);
38301@@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
38302
38303 IF_RX(printk("rx_dle_intr: skb push");)
38304 vcc->push(vcc,skb);
38305- atomic_inc(&vcc->stats->rx);
38306+ atomic_inc_unchecked(&vcc->stats->rx);
38307 iadev->rx_pkt_cnt++;
38308 }
38309 INCR_DLE:
38310@@ -2828,15 +2828,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
38311 {
38312 struct k_sonet_stats *stats;
38313 stats = &PRIV(_ia_dev[board])->sonet_stats;
38314- printk("section_bip: %d\n", atomic_read(&stats->section_bip));
38315- printk("line_bip : %d\n", atomic_read(&stats->line_bip));
38316- printk("path_bip : %d\n", atomic_read(&stats->path_bip));
38317- printk("line_febe : %d\n", atomic_read(&stats->line_febe));
38318- printk("path_febe : %d\n", atomic_read(&stats->path_febe));
38319- printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
38320- printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
38321- printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
38322- printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
38323+ printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
38324+ printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
38325+ printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
38326+ printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
38327+ printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
38328+ printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
38329+ printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
38330+ printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
38331+ printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
38332 }
38333 ia_cmds.status = 0;
38334 break;
38335@@ -2941,7 +2941,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
38336 if ((desc == 0) || (desc > iadev->num_tx_desc))
38337 {
38338 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
38339- atomic_inc(&vcc->stats->tx);
38340+ atomic_inc_unchecked(&vcc->stats->tx);
38341 if (vcc->pop)
38342 vcc->pop(vcc, skb);
38343 else
38344@@ -3046,14 +3046,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
38345 ATM_DESC(skb) = vcc->vci;
38346 skb_queue_tail(&iadev->tx_dma_q, skb);
38347
38348- atomic_inc(&vcc->stats->tx);
38349+ atomic_inc_unchecked(&vcc->stats->tx);
38350 iadev->tx_pkt_cnt++;
38351 /* Increment transaction counter */
38352 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
38353
38354 #if 0
38355 /* add flow control logic */
38356- if (atomic_read(&vcc->stats->tx) % 20 == 0) {
38357+ if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
38358 if (iavcc->vc_desc_cnt > 10) {
38359 vcc->tx_quota = vcc->tx_quota * 3 / 4;
38360 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
38361diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
38362index ce43ae3..969de38 100644
38363--- a/drivers/atm/lanai.c
38364+++ b/drivers/atm/lanai.c
38365@@ -1295,7 +1295,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
38366 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
38367 lanai_endtx(lanai, lvcc);
38368 lanai_free_skb(lvcc->tx.atmvcc, skb);
38369- atomic_inc(&lvcc->tx.atmvcc->stats->tx);
38370+ atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
38371 }
38372
38373 /* Try to fill the buffer - don't call unless there is backlog */
38374@@ -1418,7 +1418,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
38375 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
38376 __net_timestamp(skb);
38377 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
38378- atomic_inc(&lvcc->rx.atmvcc->stats->rx);
38379+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
38380 out:
38381 lvcc->rx.buf.ptr = end;
38382 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
38383@@ -1659,7 +1659,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
38384 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
38385 "vcc %d\n", lanai->number, (unsigned int) s, vci);
38386 lanai->stats.service_rxnotaal5++;
38387- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
38388+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
38389 return 0;
38390 }
38391 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
38392@@ -1671,7 +1671,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
38393 int bytes;
38394 read_unlock(&vcc_sklist_lock);
38395 DPRINTK("got trashed rx pdu on vci %d\n", vci);
38396- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
38397+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
38398 lvcc->stats.x.aal5.service_trash++;
38399 bytes = (SERVICE_GET_END(s) * 16) -
38400 (((unsigned long) lvcc->rx.buf.ptr) -
38401@@ -1683,7 +1683,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
38402 }
38403 if (s & SERVICE_STREAM) {
38404 read_unlock(&vcc_sklist_lock);
38405- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
38406+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
38407 lvcc->stats.x.aal5.service_stream++;
38408 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
38409 "PDU on VCI %d!\n", lanai->number, vci);
38410@@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
38411 return 0;
38412 }
38413 DPRINTK("got rx crc error on vci %d\n", vci);
38414- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
38415+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
38416 lvcc->stats.x.aal5.service_rxcrc++;
38417 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
38418 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
38419diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
38420index ddc4ceb..36e29aa 100644
38421--- a/drivers/atm/nicstar.c
38422+++ b/drivers/atm/nicstar.c
38423@@ -1632,7 +1632,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
38424 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
38425 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
38426 card->index);
38427- atomic_inc(&vcc->stats->tx_err);
38428+ atomic_inc_unchecked(&vcc->stats->tx_err);
38429 dev_kfree_skb_any(skb);
38430 return -EINVAL;
38431 }
38432@@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
38433 if (!vc->tx) {
38434 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
38435 card->index);
38436- atomic_inc(&vcc->stats->tx_err);
38437+ atomic_inc_unchecked(&vcc->stats->tx_err);
38438 dev_kfree_skb_any(skb);
38439 return -EINVAL;
38440 }
38441@@ -1648,14 +1648,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
38442 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
38443 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
38444 card->index);
38445- atomic_inc(&vcc->stats->tx_err);
38446+ atomic_inc_unchecked(&vcc->stats->tx_err);
38447 dev_kfree_skb_any(skb);
38448 return -EINVAL;
38449 }
38450
38451 if (skb_shinfo(skb)->nr_frags != 0) {
38452 printk("nicstar%d: No scatter-gather yet.\n", card->index);
38453- atomic_inc(&vcc->stats->tx_err);
38454+ atomic_inc_unchecked(&vcc->stats->tx_err);
38455 dev_kfree_skb_any(skb);
38456 return -EINVAL;
38457 }
38458@@ -1703,11 +1703,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
38459 }
38460
38461 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
38462- atomic_inc(&vcc->stats->tx_err);
38463+ atomic_inc_unchecked(&vcc->stats->tx_err);
38464 dev_kfree_skb_any(skb);
38465 return -EIO;
38466 }
38467- atomic_inc(&vcc->stats->tx);
38468+ atomic_inc_unchecked(&vcc->stats->tx);
38469
38470 return 0;
38471 }
38472@@ -2024,14 +2024,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38473 printk
38474 ("nicstar%d: Can't allocate buffers for aal0.\n",
38475 card->index);
38476- atomic_add(i, &vcc->stats->rx_drop);
38477+ atomic_add_unchecked(i, &vcc->stats->rx_drop);
38478 break;
38479 }
38480 if (!atm_charge(vcc, sb->truesize)) {
38481 RXPRINTK
38482 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
38483 card->index);
38484- atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
38485+ atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
38486 dev_kfree_skb_any(sb);
38487 break;
38488 }
38489@@ -2046,7 +2046,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38490 ATM_SKB(sb)->vcc = vcc;
38491 __net_timestamp(sb);
38492 vcc->push(vcc, sb);
38493- atomic_inc(&vcc->stats->rx);
38494+ atomic_inc_unchecked(&vcc->stats->rx);
38495 cell += ATM_CELL_PAYLOAD;
38496 }
38497
38498@@ -2063,7 +2063,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38499 if (iovb == NULL) {
38500 printk("nicstar%d: Out of iovec buffers.\n",
38501 card->index);
38502- atomic_inc(&vcc->stats->rx_drop);
38503+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38504 recycle_rx_buf(card, skb);
38505 return;
38506 }
38507@@ -2087,7 +2087,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38508 small or large buffer itself. */
38509 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
38510 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
38511- atomic_inc(&vcc->stats->rx_err);
38512+ atomic_inc_unchecked(&vcc->stats->rx_err);
38513 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
38514 NS_MAX_IOVECS);
38515 NS_PRV_IOVCNT(iovb) = 0;
38516@@ -2107,7 +2107,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38517 ("nicstar%d: Expected a small buffer, and this is not one.\n",
38518 card->index);
38519 which_list(card, skb);
38520- atomic_inc(&vcc->stats->rx_err);
38521+ atomic_inc_unchecked(&vcc->stats->rx_err);
38522 recycle_rx_buf(card, skb);
38523 vc->rx_iov = NULL;
38524 recycle_iov_buf(card, iovb);
38525@@ -2120,7 +2120,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38526 ("nicstar%d: Expected a large buffer, and this is not one.\n",
38527 card->index);
38528 which_list(card, skb);
38529- atomic_inc(&vcc->stats->rx_err);
38530+ atomic_inc_unchecked(&vcc->stats->rx_err);
38531 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
38532 NS_PRV_IOVCNT(iovb));
38533 vc->rx_iov = NULL;
38534@@ -2143,7 +2143,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38535 printk(" - PDU size mismatch.\n");
38536 else
38537 printk(".\n");
38538- atomic_inc(&vcc->stats->rx_err);
38539+ atomic_inc_unchecked(&vcc->stats->rx_err);
38540 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
38541 NS_PRV_IOVCNT(iovb));
38542 vc->rx_iov = NULL;
38543@@ -2157,14 +2157,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38544 /* skb points to a small buffer */
38545 if (!atm_charge(vcc, skb->truesize)) {
38546 push_rxbufs(card, skb);
38547- atomic_inc(&vcc->stats->rx_drop);
38548+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38549 } else {
38550 skb_put(skb, len);
38551 dequeue_sm_buf(card, skb);
38552 ATM_SKB(skb)->vcc = vcc;
38553 __net_timestamp(skb);
38554 vcc->push(vcc, skb);
38555- atomic_inc(&vcc->stats->rx);
38556+ atomic_inc_unchecked(&vcc->stats->rx);
38557 }
38558 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
38559 struct sk_buff *sb;
38560@@ -2175,14 +2175,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38561 if (len <= NS_SMBUFSIZE) {
38562 if (!atm_charge(vcc, sb->truesize)) {
38563 push_rxbufs(card, sb);
38564- atomic_inc(&vcc->stats->rx_drop);
38565+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38566 } else {
38567 skb_put(sb, len);
38568 dequeue_sm_buf(card, sb);
38569 ATM_SKB(sb)->vcc = vcc;
38570 __net_timestamp(sb);
38571 vcc->push(vcc, sb);
38572- atomic_inc(&vcc->stats->rx);
38573+ atomic_inc_unchecked(&vcc->stats->rx);
38574 }
38575
38576 push_rxbufs(card, skb);
38577@@ -2191,7 +2191,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38578
38579 if (!atm_charge(vcc, skb->truesize)) {
38580 push_rxbufs(card, skb);
38581- atomic_inc(&vcc->stats->rx_drop);
38582+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38583 } else {
38584 dequeue_lg_buf(card, skb);
38585 skb_push(skb, NS_SMBUFSIZE);
38586@@ -2201,7 +2201,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38587 ATM_SKB(skb)->vcc = vcc;
38588 __net_timestamp(skb);
38589 vcc->push(vcc, skb);
38590- atomic_inc(&vcc->stats->rx);
38591+ atomic_inc_unchecked(&vcc->stats->rx);
38592 }
38593
38594 push_rxbufs(card, sb);
38595@@ -2222,7 +2222,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38596 printk
38597 ("nicstar%d: Out of huge buffers.\n",
38598 card->index);
38599- atomic_inc(&vcc->stats->rx_drop);
38600+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38601 recycle_iovec_rx_bufs(card,
38602 (struct iovec *)
38603 iovb->data,
38604@@ -2273,7 +2273,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38605 card->hbpool.count++;
38606 } else
38607 dev_kfree_skb_any(hb);
38608- atomic_inc(&vcc->stats->rx_drop);
38609+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38610 } else {
38611 /* Copy the small buffer to the huge buffer */
38612 sb = (struct sk_buff *)iov->iov_base;
38613@@ -2307,7 +2307,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38614 ATM_SKB(hb)->vcc = vcc;
38615 __net_timestamp(hb);
38616 vcc->push(vcc, hb);
38617- atomic_inc(&vcc->stats->rx);
38618+ atomic_inc_unchecked(&vcc->stats->rx);
38619 }
38620 }
38621
38622diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
38623index 74e18b0..f16afa0 100644
38624--- a/drivers/atm/solos-pci.c
38625+++ b/drivers/atm/solos-pci.c
38626@@ -838,7 +838,7 @@ static void solos_bh(unsigned long card_arg)
38627 }
38628 atm_charge(vcc, skb->truesize);
38629 vcc->push(vcc, skb);
38630- atomic_inc(&vcc->stats->rx);
38631+ atomic_inc_unchecked(&vcc->stats->rx);
38632 break;
38633
38634 case PKT_STATUS:
38635@@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
38636 vcc = SKB_CB(oldskb)->vcc;
38637
38638 if (vcc) {
38639- atomic_inc(&vcc->stats->tx);
38640+ atomic_inc_unchecked(&vcc->stats->tx);
38641 solos_pop(vcc, oldskb);
38642 } else {
38643 dev_kfree_skb_irq(oldskb);
38644diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
38645index 0215934..ce9f5b1 100644
38646--- a/drivers/atm/suni.c
38647+++ b/drivers/atm/suni.c
38648@@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
38649
38650
38651 #define ADD_LIMITED(s,v) \
38652- atomic_add((v),&stats->s); \
38653- if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
38654+ atomic_add_unchecked((v),&stats->s); \
38655+ if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
38656
38657
38658 static void suni_hz(unsigned long from_timer)
38659diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
38660index 5120a96..e2572bd 100644
38661--- a/drivers/atm/uPD98402.c
38662+++ b/drivers/atm/uPD98402.c
38663@@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
38664 struct sonet_stats tmp;
38665 int error = 0;
38666
38667- atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
38668+ atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
38669 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
38670 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
38671 if (zero && !error) {
38672@@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
38673
38674
38675 #define ADD_LIMITED(s,v) \
38676- { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
38677- if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
38678- atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
38679+ { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
38680+ if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
38681+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
38682
38683
38684 static void stat_event(struct atm_dev *dev)
38685@@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
38686 if (reason & uPD98402_INT_PFM) stat_event(dev);
38687 if (reason & uPD98402_INT_PCO) {
38688 (void) GET(PCOCR); /* clear interrupt cause */
38689- atomic_add(GET(HECCT),
38690+ atomic_add_unchecked(GET(HECCT),
38691 &PRIV(dev)->sonet_stats.uncorr_hcs);
38692 }
38693 if ((reason & uPD98402_INT_RFO) &&
38694@@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
38695 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
38696 uPD98402_INT_LOS),PIMR); /* enable them */
38697 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
38698- atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
38699- atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
38700- atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
38701+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
38702+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
38703+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
38704 return 0;
38705 }
38706
38707diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
38708index cecfb94..87009ec 100644
38709--- a/drivers/atm/zatm.c
38710+++ b/drivers/atm/zatm.c
38711@@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
38712 }
38713 if (!size) {
38714 dev_kfree_skb_irq(skb);
38715- if (vcc) atomic_inc(&vcc->stats->rx_err);
38716+ if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
38717 continue;
38718 }
38719 if (!atm_charge(vcc,skb->truesize)) {
38720@@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
38721 skb->len = size;
38722 ATM_SKB(skb)->vcc = vcc;
38723 vcc->push(vcc,skb);
38724- atomic_inc(&vcc->stats->rx);
38725+ atomic_inc_unchecked(&vcc->stats->rx);
38726 }
38727 zout(pos & 0xffff,MTA(mbx));
38728 #if 0 /* probably a stupid idea */
38729@@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
38730 skb_queue_head(&zatm_vcc->backlog,skb);
38731 break;
38732 }
38733- atomic_inc(&vcc->stats->tx);
38734+ atomic_inc_unchecked(&vcc->stats->tx);
38735 wake_up(&zatm_vcc->tx_wait);
38736 }
38737
38738diff --git a/drivers/base/bus.c b/drivers/base/bus.c
38739index 5005924..9fc06c4 100644
38740--- a/drivers/base/bus.c
38741+++ b/drivers/base/bus.c
38742@@ -1141,7 +1141,7 @@ int subsys_interface_register(struct subsys_interface *sif)
38743 return -EINVAL;
38744
38745 mutex_lock(&subsys->p->mutex);
38746- list_add_tail(&sif->node, &subsys->p->interfaces);
38747+ pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
38748 if (sif->add_dev) {
38749 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
38750 while ((dev = subsys_dev_iter_next(&iter)))
38751@@ -1166,7 +1166,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
38752 subsys = sif->subsys;
38753
38754 mutex_lock(&subsys->p->mutex);
38755- list_del_init(&sif->node);
38756+ pax_list_del_init((struct list_head *)&sif->node);
38757 if (sif->remove_dev) {
38758 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
38759 while ((dev = subsys_dev_iter_next(&iter)))
38760diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
38761index 68f0314..ca2a609 100644
38762--- a/drivers/base/devtmpfs.c
38763+++ b/drivers/base/devtmpfs.c
38764@@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
38765 if (!thread)
38766 return 0;
38767
38768- err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
38769+ err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
38770 if (err)
38771 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
38772 else
38773@@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
38774 *err = sys_unshare(CLONE_NEWNS);
38775 if (*err)
38776 goto out;
38777- *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
38778+ *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
38779 if (*err)
38780 goto out;
38781- sys_chdir("/.."); /* will traverse into overmounted root */
38782- sys_chroot(".");
38783+ sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
38784+ sys_chroot((char __force_user *)".");
38785 complete(&setup_done);
38786 while (1) {
38787 spin_lock(&req_lock);
38788diff --git a/drivers/base/node.c b/drivers/base/node.c
38789index 560751b..3a4847a 100644
38790--- a/drivers/base/node.c
38791+++ b/drivers/base/node.c
38792@@ -627,7 +627,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
38793 struct node_attr {
38794 struct device_attribute attr;
38795 enum node_states state;
38796-};
38797+} __do_const;
38798
38799 static ssize_t show_node_state(struct device *dev,
38800 struct device_attribute *attr, char *buf)
38801diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
38802index 0ee43c1..369dd62 100644
38803--- a/drivers/base/power/domain.c
38804+++ b/drivers/base/power/domain.c
38805@@ -1738,7 +1738,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
38806 {
38807 struct cpuidle_driver *cpuidle_drv;
38808 struct gpd_cpuidle_data *cpuidle_data;
38809- struct cpuidle_state *idle_state;
38810+ cpuidle_state_no_const *idle_state;
38811 int ret = 0;
38812
38813 if (IS_ERR_OR_NULL(genpd) || state < 0)
38814@@ -1806,7 +1806,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
38815 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
38816 {
38817 struct gpd_cpuidle_data *cpuidle_data;
38818- struct cpuidle_state *idle_state;
38819+ cpuidle_state_no_const *idle_state;
38820 int ret = 0;
38821
38822 if (IS_ERR_OR_NULL(genpd))
38823@@ -2241,8 +2241,11 @@ int genpd_dev_pm_attach(struct device *dev)
38824 return ret;
38825 }
38826
38827- dev->pm_domain->detach = genpd_dev_pm_detach;
38828- dev->pm_domain->sync = genpd_dev_pm_sync;
38829+ pax_open_kernel();
38830+ *(void **)&dev->pm_domain->detach = genpd_dev_pm_detach;
38831+ *(void **)&dev->pm_domain->sync = genpd_dev_pm_sync;
38832+ pax_close_kernel();
38833+
38834 pm_genpd_poweron(pd);
38835
38836 return 0;
38837diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
38838index d2be3f9..0a3167a 100644
38839--- a/drivers/base/power/sysfs.c
38840+++ b/drivers/base/power/sysfs.c
38841@@ -181,7 +181,7 @@ static ssize_t rtpm_status_show(struct device *dev,
38842 return -EIO;
38843 }
38844 }
38845- return sprintf(buf, p);
38846+ return sprintf(buf, "%s", p);
38847 }
38848
38849 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
38850diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
38851index 51f15bc..892a668 100644
38852--- a/drivers/base/power/wakeup.c
38853+++ b/drivers/base/power/wakeup.c
38854@@ -33,14 +33,14 @@ static bool pm_abort_suspend __read_mostly;
38855 * They need to be modified together atomically, so it's better to use one
38856 * atomic variable to hold them both.
38857 */
38858-static atomic_t combined_event_count = ATOMIC_INIT(0);
38859+static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
38860
38861 #define IN_PROGRESS_BITS (sizeof(int) * 4)
38862 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
38863
38864 static void split_counters(unsigned int *cnt, unsigned int *inpr)
38865 {
38866- unsigned int comb = atomic_read(&combined_event_count);
38867+ unsigned int comb = atomic_read_unchecked(&combined_event_count);
38868
38869 *cnt = (comb >> IN_PROGRESS_BITS);
38870 *inpr = comb & MAX_IN_PROGRESS;
38871@@ -537,7 +537,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
38872 ws->start_prevent_time = ws->last_time;
38873
38874 /* Increment the counter of events in progress. */
38875- cec = atomic_inc_return(&combined_event_count);
38876+ cec = atomic_inc_return_unchecked(&combined_event_count);
38877
38878 trace_wakeup_source_activate(ws->name, cec);
38879 }
38880@@ -663,7 +663,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
38881 * Increment the counter of registered wakeup events and decrement the
38882 * couter of wakeup events in progress simultaneously.
38883 */
38884- cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
38885+ cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
38886 trace_wakeup_source_deactivate(ws->name, cec);
38887
38888 split_counters(&cnt, &inpr);
38889diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
38890index c8941f3..f7c7a7e 100644
38891--- a/drivers/base/regmap/regmap-debugfs.c
38892+++ b/drivers/base/regmap/regmap-debugfs.c
38893@@ -30,7 +30,7 @@ static LIST_HEAD(regmap_debugfs_early_list);
38894 static DEFINE_MUTEX(regmap_debugfs_early_lock);
38895
38896 /* Calculate the length of a fixed format */
38897-static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size)
38898+static size_t regmap_calc_reg_len(int max_val)
38899 {
38900 return snprintf(NULL, 0, "%x", max_val);
38901 }
38902@@ -173,8 +173,7 @@ static inline void regmap_calc_tot_len(struct regmap *map,
38903 {
38904 /* Calculate the length of a fixed format */
38905 if (!map->debugfs_tot_len) {
38906- map->debugfs_reg_len = regmap_calc_reg_len(map->max_register,
38907- buf, count);
38908+ map->debugfs_reg_len = regmap_calc_reg_len(map->max_register);
38909 map->debugfs_val_len = 2 * map->format.val_bytes;
38910 map->debugfs_tot_len = map->debugfs_reg_len +
38911 map->debugfs_val_len + 3; /* : \n */
38912@@ -404,7 +403,7 @@ static ssize_t regmap_access_read_file(struct file *file,
38913 char __user *user_buf, size_t count,
38914 loff_t *ppos)
38915 {
38916- int reg_len, tot_len;
38917+ size_t reg_len, tot_len;
38918 size_t buf_pos = 0;
38919 loff_t p = 0;
38920 ssize_t ret;
38921@@ -420,7 +419,7 @@ static ssize_t regmap_access_read_file(struct file *file,
38922 return -ENOMEM;
38923
38924 /* Calculate the length of a fixed format */
38925- reg_len = regmap_calc_reg_len(map->max_register, buf, count);
38926+ reg_len = regmap_calc_reg_len(map->max_register);
38927 tot_len = reg_len + 10; /* ': R W V P\n' */
38928
38929 for (i = 0; i <= map->max_register; i += map->reg_stride) {
38930diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
38931index 8d98a32..61d3165 100644
38932--- a/drivers/base/syscore.c
38933+++ b/drivers/base/syscore.c
38934@@ -22,7 +22,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
38935 void register_syscore_ops(struct syscore_ops *ops)
38936 {
38937 mutex_lock(&syscore_ops_lock);
38938- list_add_tail(&ops->node, &syscore_ops_list);
38939+ pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
38940 mutex_unlock(&syscore_ops_lock);
38941 }
38942 EXPORT_SYMBOL_GPL(register_syscore_ops);
38943@@ -34,7 +34,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
38944 void unregister_syscore_ops(struct syscore_ops *ops)
38945 {
38946 mutex_lock(&syscore_ops_lock);
38947- list_del(&ops->node);
38948+ pax_list_del((struct list_head *)&ops->node);
38949 mutex_unlock(&syscore_ops_lock);
38950 }
38951 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
38952diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
38953index 0422c47..b222c7a 100644
38954--- a/drivers/block/cciss.c
38955+++ b/drivers/block/cciss.c
38956@@ -3024,7 +3024,7 @@ static void start_io(ctlr_info_t *h)
38957 while (!list_empty(&h->reqQ)) {
38958 c = list_entry(h->reqQ.next, CommandList_struct, list);
38959 /* can't do anything if fifo is full */
38960- if ((h->access.fifo_full(h))) {
38961+ if ((h->access->fifo_full(h))) {
38962 dev_warn(&h->pdev->dev, "fifo full\n");
38963 break;
38964 }
38965@@ -3034,7 +3034,7 @@ static void start_io(ctlr_info_t *h)
38966 h->Qdepth--;
38967
38968 /* Tell the controller execute command */
38969- h->access.submit_command(h, c);
38970+ h->access->submit_command(h, c);
38971
38972 /* Put job onto the completed Q */
38973 addQ(&h->cmpQ, c);
38974@@ -3460,17 +3460,17 @@ startio:
38975
38976 static inline unsigned long get_next_completion(ctlr_info_t *h)
38977 {
38978- return h->access.command_completed(h);
38979+ return h->access->command_completed(h);
38980 }
38981
38982 static inline int interrupt_pending(ctlr_info_t *h)
38983 {
38984- return h->access.intr_pending(h);
38985+ return h->access->intr_pending(h);
38986 }
38987
38988 static inline long interrupt_not_for_us(ctlr_info_t *h)
38989 {
38990- return ((h->access.intr_pending(h) == 0) ||
38991+ return ((h->access->intr_pending(h) == 0) ||
38992 (h->interrupts_enabled == 0));
38993 }
38994
38995@@ -3503,7 +3503,7 @@ static inline u32 next_command(ctlr_info_t *h)
38996 u32 a;
38997
38998 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
38999- return h->access.command_completed(h);
39000+ return h->access->command_completed(h);
39001
39002 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
39003 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
39004@@ -4060,7 +4060,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
39005 trans_support & CFGTBL_Trans_use_short_tags);
39006
39007 /* Change the access methods to the performant access methods */
39008- h->access = SA5_performant_access;
39009+ h->access = &SA5_performant_access;
39010 h->transMethod = CFGTBL_Trans_Performant;
39011
39012 return;
39013@@ -4334,7 +4334,7 @@ static int cciss_pci_init(ctlr_info_t *h)
39014 if (prod_index < 0)
39015 return -ENODEV;
39016 h->product_name = products[prod_index].product_name;
39017- h->access = *(products[prod_index].access);
39018+ h->access = products[prod_index].access;
39019
39020 if (cciss_board_disabled(h)) {
39021 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
39022@@ -5065,7 +5065,7 @@ reinit_after_soft_reset:
39023 }
39024
39025 /* make sure the board interrupts are off */
39026- h->access.set_intr_mask(h, CCISS_INTR_OFF);
39027+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
39028 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
39029 if (rc)
39030 goto clean2;
39031@@ -5115,7 +5115,7 @@ reinit_after_soft_reset:
39032 * fake ones to scoop up any residual completions.
39033 */
39034 spin_lock_irqsave(&h->lock, flags);
39035- h->access.set_intr_mask(h, CCISS_INTR_OFF);
39036+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
39037 spin_unlock_irqrestore(&h->lock, flags);
39038 free_irq(h->intr[h->intr_mode], h);
39039 rc = cciss_request_irq(h, cciss_msix_discard_completions,
39040@@ -5135,9 +5135,9 @@ reinit_after_soft_reset:
39041 dev_info(&h->pdev->dev, "Board READY.\n");
39042 dev_info(&h->pdev->dev,
39043 "Waiting for stale completions to drain.\n");
39044- h->access.set_intr_mask(h, CCISS_INTR_ON);
39045+ h->access->set_intr_mask(h, CCISS_INTR_ON);
39046 msleep(10000);
39047- h->access.set_intr_mask(h, CCISS_INTR_OFF);
39048+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
39049
39050 rc = controller_reset_failed(h->cfgtable);
39051 if (rc)
39052@@ -5160,7 +5160,7 @@ reinit_after_soft_reset:
39053 cciss_scsi_setup(h);
39054
39055 /* Turn the interrupts on so we can service requests */
39056- h->access.set_intr_mask(h, CCISS_INTR_ON);
39057+ h->access->set_intr_mask(h, CCISS_INTR_ON);
39058
39059 /* Get the firmware version */
39060 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
39061@@ -5232,7 +5232,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
39062 kfree(flush_buf);
39063 if (return_code != IO_OK)
39064 dev_warn(&h->pdev->dev, "Error flushing cache\n");
39065- h->access.set_intr_mask(h, CCISS_INTR_OFF);
39066+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
39067 free_irq(h->intr[h->intr_mode], h);
39068 }
39069
39070diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
39071index 7fda30e..2f27946 100644
39072--- a/drivers/block/cciss.h
39073+++ b/drivers/block/cciss.h
39074@@ -101,7 +101,7 @@ struct ctlr_info
39075 /* information about each logical volume */
39076 drive_info_struct *drv[CISS_MAX_LUN];
39077
39078- struct access_method access;
39079+ struct access_method *access;
39080
39081 /* queue and queue Info */
39082 struct list_head reqQ;
39083@@ -402,27 +402,27 @@ static bool SA5_performant_intr_pending(ctlr_info_t *h)
39084 }
39085
39086 static struct access_method SA5_access = {
39087- SA5_submit_command,
39088- SA5_intr_mask,
39089- SA5_fifo_full,
39090- SA5_intr_pending,
39091- SA5_completed,
39092+ .submit_command = SA5_submit_command,
39093+ .set_intr_mask = SA5_intr_mask,
39094+ .fifo_full = SA5_fifo_full,
39095+ .intr_pending = SA5_intr_pending,
39096+ .command_completed = SA5_completed,
39097 };
39098
39099 static struct access_method SA5B_access = {
39100- SA5_submit_command,
39101- SA5B_intr_mask,
39102- SA5_fifo_full,
39103- SA5B_intr_pending,
39104- SA5_completed,
39105+ .submit_command = SA5_submit_command,
39106+ .set_intr_mask = SA5B_intr_mask,
39107+ .fifo_full = SA5_fifo_full,
39108+ .intr_pending = SA5B_intr_pending,
39109+ .command_completed = SA5_completed,
39110 };
39111
39112 static struct access_method SA5_performant_access = {
39113- SA5_submit_command,
39114- SA5_performant_intr_mask,
39115- SA5_fifo_full,
39116- SA5_performant_intr_pending,
39117- SA5_performant_completed,
39118+ .submit_command = SA5_submit_command,
39119+ .set_intr_mask = SA5_performant_intr_mask,
39120+ .fifo_full = SA5_fifo_full,
39121+ .intr_pending = SA5_performant_intr_pending,
39122+ .command_completed = SA5_performant_completed,
39123 };
39124
39125 struct board_type {
39126diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
39127index f749df9..5f8b9c4 100644
39128--- a/drivers/block/cpqarray.c
39129+++ b/drivers/block/cpqarray.c
39130@@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
39131 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
39132 goto Enomem4;
39133 }
39134- hba[i]->access.set_intr_mask(hba[i], 0);
39135+ hba[i]->access->set_intr_mask(hba[i], 0);
39136 if (request_irq(hba[i]->intr, do_ida_intr, IRQF_SHARED,
39137 hba[i]->devname, hba[i]))
39138 {
39139@@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
39140 add_timer(&hba[i]->timer);
39141
39142 /* Enable IRQ now that spinlock and rate limit timer are set up */
39143- hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
39144+ hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
39145
39146 for(j=0; j<NWD; j++) {
39147 struct gendisk *disk = ida_gendisk[i][j];
39148@@ -694,7 +694,7 @@ DBGINFO(
39149 for(i=0; i<NR_PRODUCTS; i++) {
39150 if (board_id == products[i].board_id) {
39151 c->product_name = products[i].product_name;
39152- c->access = *(products[i].access);
39153+ c->access = products[i].access;
39154 break;
39155 }
39156 }
39157@@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
39158 hba[ctlr]->intr = intr;
39159 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
39160 hba[ctlr]->product_name = products[j].product_name;
39161- hba[ctlr]->access = *(products[j].access);
39162+ hba[ctlr]->access = products[j].access;
39163 hba[ctlr]->ctlr = ctlr;
39164 hba[ctlr]->board_id = board_id;
39165 hba[ctlr]->pci_dev = NULL; /* not PCI */
39166@@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
39167
39168 while((c = h->reqQ) != NULL) {
39169 /* Can't do anything if we're busy */
39170- if (h->access.fifo_full(h) == 0)
39171+ if (h->access->fifo_full(h) == 0)
39172 return;
39173
39174 /* Get the first entry from the request Q */
39175@@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
39176 h->Qdepth--;
39177
39178 /* Tell the controller to do our bidding */
39179- h->access.submit_command(h, c);
39180+ h->access->submit_command(h, c);
39181
39182 /* Get onto the completion Q */
39183 addQ(&h->cmpQ, c);
39184@@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
39185 unsigned long flags;
39186 __u32 a,a1;
39187
39188- istat = h->access.intr_pending(h);
39189+ istat = h->access->intr_pending(h);
39190 /* Is this interrupt for us? */
39191 if (istat == 0)
39192 return IRQ_NONE;
39193@@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
39194 */
39195 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
39196 if (istat & FIFO_NOT_EMPTY) {
39197- while((a = h->access.command_completed(h))) {
39198+ while((a = h->access->command_completed(h))) {
39199 a1 = a; a &= ~3;
39200 if ((c = h->cmpQ) == NULL)
39201 {
39202@@ -1448,11 +1448,11 @@ static int sendcmd(
39203 /*
39204 * Disable interrupt
39205 */
39206- info_p->access.set_intr_mask(info_p, 0);
39207+ info_p->access->set_intr_mask(info_p, 0);
39208 /* Make sure there is room in the command FIFO */
39209 /* Actually it should be completely empty at this time. */
39210 for (i = 200000; i > 0; i--) {
39211- temp = info_p->access.fifo_full(info_p);
39212+ temp = info_p->access->fifo_full(info_p);
39213 if (temp != 0) {
39214 break;
39215 }
39216@@ -1465,7 +1465,7 @@ DBG(
39217 /*
39218 * Send the cmd
39219 */
39220- info_p->access.submit_command(info_p, c);
39221+ info_p->access->submit_command(info_p, c);
39222 complete = pollcomplete(ctlr);
39223
39224 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
39225@@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
39226 * we check the new geometry. Then turn interrupts back on when
39227 * we're done.
39228 */
39229- host->access.set_intr_mask(host, 0);
39230+ host->access->set_intr_mask(host, 0);
39231 getgeometry(ctlr);
39232- host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
39233+ host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
39234
39235 for(i=0; i<NWD; i++) {
39236 struct gendisk *disk = ida_gendisk[ctlr][i];
39237@@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
39238 /* Wait (up to 2 seconds) for a command to complete */
39239
39240 for (i = 200000; i > 0; i--) {
39241- done = hba[ctlr]->access.command_completed(hba[ctlr]);
39242+ done = hba[ctlr]->access->command_completed(hba[ctlr]);
39243 if (done == 0) {
39244 udelay(10); /* a short fixed delay */
39245 } else
39246diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
39247index be73e9d..7fbf140 100644
39248--- a/drivers/block/cpqarray.h
39249+++ b/drivers/block/cpqarray.h
39250@@ -99,7 +99,7 @@ struct ctlr_info {
39251 drv_info_t drv[NWD];
39252 struct proc_dir_entry *proc;
39253
39254- struct access_method access;
39255+ struct access_method *access;
39256
39257 cmdlist_t *reqQ;
39258 cmdlist_t *cmpQ;
39259diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
39260index 434c77d..6d3219a 100644
39261--- a/drivers/block/drbd/drbd_bitmap.c
39262+++ b/drivers/block/drbd/drbd_bitmap.c
39263@@ -1036,7 +1036,7 @@ static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, int page_nr) __must_ho
39264 submit_bio(rw, bio);
39265 /* this should not count as user activity and cause the
39266 * resync to throttle -- see drbd_rs_should_slow_down(). */
39267- atomic_add(len >> 9, &device->rs_sect_ev);
39268+ atomic_add_unchecked(len >> 9, &device->rs_sect_ev);
39269 }
39270 }
39271
39272diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
39273index efd19c2..6ccfa94 100644
39274--- a/drivers/block/drbd/drbd_int.h
39275+++ b/drivers/block/drbd/drbd_int.h
39276@@ -386,7 +386,7 @@ struct drbd_epoch {
39277 struct drbd_connection *connection;
39278 struct list_head list;
39279 unsigned int barrier_nr;
39280- atomic_t epoch_size; /* increased on every request added. */
39281+ atomic_unchecked_t epoch_size; /* increased on every request added. */
39282 atomic_t active; /* increased on every req. added, and dec on every finished. */
39283 unsigned long flags;
39284 };
39285@@ -947,7 +947,7 @@ struct drbd_device {
39286 unsigned int al_tr_number;
39287 int al_tr_cycle;
39288 wait_queue_head_t seq_wait;
39289- atomic_t packet_seq;
39290+ atomic_unchecked_t packet_seq;
39291 unsigned int peer_seq;
39292 spinlock_t peer_seq_lock;
39293 unsigned long comm_bm_set; /* communicated number of set bits. */
39294@@ -956,8 +956,8 @@ struct drbd_device {
39295 struct mutex own_state_mutex;
39296 struct mutex *state_mutex; /* either own_state_mutex or first_peer_device(device)->connection->cstate_mutex */
39297 char congestion_reason; /* Why we where congested... */
39298- atomic_t rs_sect_in; /* for incoming resync data rate, SyncTarget */
39299- atomic_t rs_sect_ev; /* for submitted resync data rate, both */
39300+ atomic_unchecked_t rs_sect_in; /* for incoming resync data rate, SyncTarget */
39301+ atomic_unchecked_t rs_sect_ev; /* for submitted resync data rate, both */
39302 int rs_last_sect_ev; /* counter to compare with */
39303 int rs_last_events; /* counter of read or write "events" (unit sectors)
39304 * on the lower level device when we last looked. */
39305diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
39306index a151853..b9b5baa 100644
39307--- a/drivers/block/drbd/drbd_main.c
39308+++ b/drivers/block/drbd/drbd_main.c
39309@@ -1328,7 +1328,7 @@ static int _drbd_send_ack(struct drbd_peer_device *peer_device, enum drbd_packet
39310 p->sector = sector;
39311 p->block_id = block_id;
39312 p->blksize = blksize;
39313- p->seq_num = cpu_to_be32(atomic_inc_return(&peer_device->device->packet_seq));
39314+ p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&peer_device->device->packet_seq));
39315 return drbd_send_command(peer_device, sock, cmd, sizeof(*p), NULL, 0);
39316 }
39317
39318@@ -1634,7 +1634,7 @@ int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request *
39319 return -EIO;
39320 p->sector = cpu_to_be64(req->i.sector);
39321 p->block_id = (unsigned long)req;
39322- p->seq_num = cpu_to_be32(atomic_inc_return(&device->packet_seq));
39323+ p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&device->packet_seq));
39324 dp_flags = bio_flags_to_wire(peer_device->connection, req->master_bio->bi_rw);
39325 if (device->state.conn >= C_SYNC_SOURCE &&
39326 device->state.conn <= C_PAUSED_SYNC_T)
39327@@ -1915,8 +1915,8 @@ void drbd_init_set_defaults(struct drbd_device *device)
39328 atomic_set(&device->unacked_cnt, 0);
39329 atomic_set(&device->local_cnt, 0);
39330 atomic_set(&device->pp_in_use_by_net, 0);
39331- atomic_set(&device->rs_sect_in, 0);
39332- atomic_set(&device->rs_sect_ev, 0);
39333+ atomic_set_unchecked(&device->rs_sect_in, 0);
39334+ atomic_set_unchecked(&device->rs_sect_ev, 0);
39335 atomic_set(&device->ap_in_flight, 0);
39336 atomic_set(&device->md_io.in_use, 0);
39337
39338@@ -2683,8 +2683,8 @@ void drbd_destroy_connection(struct kref *kref)
39339 struct drbd_connection *connection = container_of(kref, struct drbd_connection, kref);
39340 struct drbd_resource *resource = connection->resource;
39341
39342- if (atomic_read(&connection->current_epoch->epoch_size) != 0)
39343- drbd_err(connection, "epoch_size:%d\n", atomic_read(&connection->current_epoch->epoch_size));
39344+ if (atomic_read_unchecked(&connection->current_epoch->epoch_size) != 0)
39345+ drbd_err(connection, "epoch_size:%d\n", atomic_read_unchecked(&connection->current_epoch->epoch_size));
39346 kfree(connection->current_epoch);
39347
39348 idr_destroy(&connection->peer_devices);
39349diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
39350index 74df8cf..e41fc24 100644
39351--- a/drivers/block/drbd/drbd_nl.c
39352+++ b/drivers/block/drbd/drbd_nl.c
39353@@ -3637,13 +3637,13 @@ finish:
39354
39355 void drbd_bcast_event(struct drbd_device *device, const struct sib_info *sib)
39356 {
39357- static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
39358+ static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
39359 struct sk_buff *msg;
39360 struct drbd_genlmsghdr *d_out;
39361 unsigned seq;
39362 int err = -ENOMEM;
39363
39364- seq = atomic_inc_return(&drbd_genl_seq);
39365+ seq = atomic_inc_return_unchecked(&drbd_genl_seq);
39366 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
39367 if (!msg)
39368 goto failed;
39369diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
39370index c097909..13688e1 100644
39371--- a/drivers/block/drbd/drbd_receiver.c
39372+++ b/drivers/block/drbd/drbd_receiver.c
39373@@ -870,7 +870,7 @@ int drbd_connected(struct drbd_peer_device *peer_device)
39374 struct drbd_device *device = peer_device->device;
39375 int err;
39376
39377- atomic_set(&device->packet_seq, 0);
39378+ atomic_set_unchecked(&device->packet_seq, 0);
39379 device->peer_seq = 0;
39380
39381 device->state_mutex = peer_device->connection->agreed_pro_version < 100 ?
39382@@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connectio
39383 do {
39384 next_epoch = NULL;
39385
39386- epoch_size = atomic_read(&epoch->epoch_size);
39387+ epoch_size = atomic_read_unchecked(&epoch->epoch_size);
39388
39389 switch (ev & ~EV_CLEANUP) {
39390 case EV_PUT:
39391@@ -1273,7 +1273,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connectio
39392 rv = FE_DESTROYED;
39393 } else {
39394 epoch->flags = 0;
39395- atomic_set(&epoch->epoch_size, 0);
39396+ atomic_set_unchecked(&epoch->epoch_size, 0);
39397 /* atomic_set(&epoch->active, 0); is already zero */
39398 if (rv == FE_STILL_LIVE)
39399 rv = FE_RECYCLED;
39400@@ -1550,7 +1550,7 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
39401 conn_wait_active_ee_empty(connection);
39402 drbd_flush(connection);
39403
39404- if (atomic_read(&connection->current_epoch->epoch_size)) {
39405+ if (atomic_read_unchecked(&connection->current_epoch->epoch_size)) {
39406 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
39407 if (epoch)
39408 break;
39409@@ -1564,11 +1564,11 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
39410 }
39411
39412 epoch->flags = 0;
39413- atomic_set(&epoch->epoch_size, 0);
39414+ atomic_set_unchecked(&epoch->epoch_size, 0);
39415 atomic_set(&epoch->active, 0);
39416
39417 spin_lock(&connection->epoch_lock);
39418- if (atomic_read(&connection->current_epoch->epoch_size)) {
39419+ if (atomic_read_unchecked(&connection->current_epoch->epoch_size)) {
39420 list_add(&epoch->list, &connection->current_epoch->list);
39421 connection->current_epoch = epoch;
39422 connection->epochs++;
39423@@ -1802,7 +1802,7 @@ static int recv_resync_read(struct drbd_peer_device *peer_device, sector_t secto
39424 list_add_tail(&peer_req->w.list, &device->sync_ee);
39425 spin_unlock_irq(&device->resource->req_lock);
39426
39427- atomic_add(pi->size >> 9, &device->rs_sect_ev);
39428+ atomic_add_unchecked(pi->size >> 9, &device->rs_sect_ev);
39429 if (drbd_submit_peer_request(device, peer_req, WRITE, DRBD_FAULT_RS_WR) == 0)
39430 return 0;
39431
39432@@ -1900,7 +1900,7 @@ static int receive_RSDataReply(struct drbd_connection *connection, struct packet
39433 drbd_send_ack_dp(peer_device, P_NEG_ACK, p, pi->size);
39434 }
39435
39436- atomic_add(pi->size >> 9, &device->rs_sect_in);
39437+ atomic_add_unchecked(pi->size >> 9, &device->rs_sect_in);
39438
39439 return err;
39440 }
39441@@ -2290,7 +2290,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *
39442
39443 err = wait_for_and_update_peer_seq(peer_device, peer_seq);
39444 drbd_send_ack_dp(peer_device, P_NEG_ACK, p, pi->size);
39445- atomic_inc(&connection->current_epoch->epoch_size);
39446+ atomic_inc_unchecked(&connection->current_epoch->epoch_size);
39447 err2 = drbd_drain_block(peer_device, pi->size);
39448 if (!err)
39449 err = err2;
39450@@ -2334,7 +2334,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *
39451
39452 spin_lock(&connection->epoch_lock);
39453 peer_req->epoch = connection->current_epoch;
39454- atomic_inc(&peer_req->epoch->epoch_size);
39455+ atomic_inc_unchecked(&peer_req->epoch->epoch_size);
39456 atomic_inc(&peer_req->epoch->active);
39457 spin_unlock(&connection->epoch_lock);
39458
39459@@ -2479,7 +2479,7 @@ bool drbd_rs_c_min_rate_throttle(struct drbd_device *device)
39460
39461 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
39462 (int)part_stat_read(&disk->part0, sectors[1]) -
39463- atomic_read(&device->rs_sect_ev);
39464+ atomic_read_unchecked(&device->rs_sect_ev);
39465
39466 if (atomic_read(&device->ap_actlog_cnt)
39467 || curr_events - device->rs_last_events > 64) {
39468@@ -2618,7 +2618,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet
39469 device->use_csums = true;
39470 } else if (pi->cmd == P_OV_REPLY) {
39471 /* track progress, we may need to throttle */
39472- atomic_add(size >> 9, &device->rs_sect_in);
39473+ atomic_add_unchecked(size >> 9, &device->rs_sect_in);
39474 peer_req->w.cb = w_e_end_ov_reply;
39475 dec_rs_pending(device);
39476 /* drbd_rs_begin_io done when we sent this request,
39477@@ -2691,7 +2691,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet
39478 goto out_free_e;
39479
39480 submit_for_resync:
39481- atomic_add(size >> 9, &device->rs_sect_ev);
39482+ atomic_add_unchecked(size >> 9, &device->rs_sect_ev);
39483
39484 submit:
39485 update_receiver_timing_details(connection, drbd_submit_peer_request);
39486@@ -4564,7 +4564,7 @@ struct data_cmd {
39487 int expect_payload;
39488 size_t pkt_size;
39489 int (*fn)(struct drbd_connection *, struct packet_info *);
39490-};
39491+} __do_const;
39492
39493 static struct data_cmd drbd_cmd_handler[] = {
39494 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
39495@@ -4678,7 +4678,7 @@ static void conn_disconnect(struct drbd_connection *connection)
39496 if (!list_empty(&connection->current_epoch->list))
39497 drbd_err(connection, "ASSERTION FAILED: connection->current_epoch->list not empty\n");
39498 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
39499- atomic_set(&connection->current_epoch->epoch_size, 0);
39500+ atomic_set_unchecked(&connection->current_epoch->epoch_size, 0);
39501 connection->send.seen_any_write_yet = false;
39502
39503 drbd_info(connection, "Connection closed\n");
39504@@ -5182,7 +5182,7 @@ static int got_IsInSync(struct drbd_connection *connection, struct packet_info *
39505 put_ldev(device);
39506 }
39507 dec_rs_pending(device);
39508- atomic_add(blksize >> 9, &device->rs_sect_in);
39509+ atomic_add_unchecked(blksize >> 9, &device->rs_sect_in);
39510
39511 return 0;
39512 }
39513@@ -5470,7 +5470,7 @@ static int connection_finish_peer_reqs(struct drbd_connection *connection)
39514 struct asender_cmd {
39515 size_t pkt_size;
39516 int (*fn)(struct drbd_connection *connection, struct packet_info *);
39517-};
39518+} __do_const;
39519
39520 static struct asender_cmd asender_tbl[] = {
39521 [P_PING] = { 0, got_Ping },
39522diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
39523index d0fae55..4469096 100644
39524--- a/drivers/block/drbd/drbd_worker.c
39525+++ b/drivers/block/drbd/drbd_worker.c
39526@@ -408,7 +408,7 @@ static int read_for_csum(struct drbd_peer_device *peer_device, sector_t sector,
39527 list_add_tail(&peer_req->w.list, &device->read_ee);
39528 spin_unlock_irq(&device->resource->req_lock);
39529
39530- atomic_add(size >> 9, &device->rs_sect_ev);
39531+ atomic_add_unchecked(size >> 9, &device->rs_sect_ev);
39532 if (drbd_submit_peer_request(device, peer_req, READ, DRBD_FAULT_RS_RD) == 0)
39533 return 0;
39534
39535@@ -553,7 +553,7 @@ static int drbd_rs_number_requests(struct drbd_device *device)
39536 unsigned int sect_in; /* Number of sectors that came in since the last turn */
39537 int number, mxb;
39538
39539- sect_in = atomic_xchg(&device->rs_sect_in, 0);
39540+ sect_in = atomic_xchg_unchecked(&device->rs_sect_in, 0);
39541 device->rs_in_flight -= sect_in;
39542
39543 rcu_read_lock();
39544@@ -1595,8 +1595,8 @@ void drbd_rs_controller_reset(struct drbd_device *device)
39545 struct gendisk *disk = device->ldev->backing_bdev->bd_contains->bd_disk;
39546 struct fifo_buffer *plan;
39547
39548- atomic_set(&device->rs_sect_in, 0);
39549- atomic_set(&device->rs_sect_ev, 0);
39550+ atomic_set_unchecked(&device->rs_sect_in, 0);
39551+ atomic_set_unchecked(&device->rs_sect_ev, 0);
39552 device->rs_in_flight = 0;
39553 device->rs_last_events =
39554 (int)part_stat_read(&disk->part0, sectors[0]) +
39555diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
39556index 4c20c22..caef1eb 100644
39557--- a/drivers/block/pktcdvd.c
39558+++ b/drivers/block/pktcdvd.c
39559@@ -109,7 +109,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
39560
39561 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
39562 {
39563- return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
39564+ return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
39565 }
39566
39567 /*
39568@@ -1891,7 +1891,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
39569 return -EROFS;
39570 }
39571 pd->settings.fp = ti.fp;
39572- pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
39573+ pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
39574
39575 if (ti.nwa_v) {
39576 pd->nwa = be32_to_cpu(ti.next_writable);
39577diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
39578index bc67a93..d552e86 100644
39579--- a/drivers/block/rbd.c
39580+++ b/drivers/block/rbd.c
39581@@ -64,7 +64,7 @@
39582 * If the counter is already at its maximum value returns
39583 * -EINVAL without updating it.
39584 */
39585-static int atomic_inc_return_safe(atomic_t *v)
39586+static int __intentional_overflow(-1) atomic_inc_return_safe(atomic_t *v)
39587 {
39588 unsigned int counter;
39589
39590diff --git a/drivers/block/smart1,2.h b/drivers/block/smart1,2.h
39591index e5565fb..71be10b4 100644
39592--- a/drivers/block/smart1,2.h
39593+++ b/drivers/block/smart1,2.h
39594@@ -108,11 +108,11 @@ static unsigned long smart4_intr_pending(ctlr_info_t *h)
39595 }
39596
39597 static struct access_method smart4_access = {
39598- smart4_submit_command,
39599- smart4_intr_mask,
39600- smart4_fifo_full,
39601- smart4_intr_pending,
39602- smart4_completed,
39603+ .submit_command = smart4_submit_command,
39604+ .set_intr_mask = smart4_intr_mask,
39605+ .fifo_full = smart4_fifo_full,
39606+ .intr_pending = smart4_intr_pending,
39607+ .command_completed = smart4_completed,
39608 };
39609
39610 /*
39611@@ -144,11 +144,11 @@ static unsigned long smart2_intr_pending(ctlr_info_t *h)
39612 }
39613
39614 static struct access_method smart2_access = {
39615- smart2_submit_command,
39616- smart2_intr_mask,
39617- smart2_fifo_full,
39618- smart2_intr_pending,
39619- smart2_completed,
39620+ .submit_command = smart2_submit_command,
39621+ .set_intr_mask = smart2_intr_mask,
39622+ .fifo_full = smart2_fifo_full,
39623+ .intr_pending = smart2_intr_pending,
39624+ .command_completed = smart2_completed,
39625 };
39626
39627 /*
39628@@ -180,11 +180,11 @@ static unsigned long smart2e_intr_pending(ctlr_info_t *h)
39629 }
39630
39631 static struct access_method smart2e_access = {
39632- smart2e_submit_command,
39633- smart2e_intr_mask,
39634- smart2e_fifo_full,
39635- smart2e_intr_pending,
39636- smart2e_completed,
39637+ .submit_command = smart2e_submit_command,
39638+ .set_intr_mask = smart2e_intr_mask,
39639+ .fifo_full = smart2e_fifo_full,
39640+ .intr_pending = smart2e_intr_pending,
39641+ .command_completed = smart2e_completed,
39642 };
39643
39644 /*
39645@@ -270,9 +270,9 @@ static unsigned long smart1_intr_pending(ctlr_info_t *h)
39646 }
39647
39648 static struct access_method smart1_access = {
39649- smart1_submit_command,
39650- smart1_intr_mask,
39651- smart1_fifo_full,
39652- smart1_intr_pending,
39653- smart1_completed,
39654+ .submit_command = smart1_submit_command,
39655+ .set_intr_mask = smart1_intr_mask,
39656+ .fifo_full = smart1_fifo_full,
39657+ .intr_pending = smart1_intr_pending,
39658+ .command_completed = smart1_completed,
39659 };
39660diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
39661index 7a722df..54b76ab 100644
39662--- a/drivers/bluetooth/btwilink.c
39663+++ b/drivers/bluetooth/btwilink.c
39664@@ -288,7 +288,7 @@ static int ti_st_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
39665
39666 static int bt_ti_probe(struct platform_device *pdev)
39667 {
39668- static struct ti_st *hst;
39669+ struct ti_st *hst;
39670 struct hci_dev *hdev;
39671 int err;
39672
39673diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
39674index 5d28a45..a538f90 100644
39675--- a/drivers/cdrom/cdrom.c
39676+++ b/drivers/cdrom/cdrom.c
39677@@ -610,7 +610,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
39678 ENSURE(reset, CDC_RESET);
39679 ENSURE(generic_packet, CDC_GENERIC_PACKET);
39680 cdi->mc_flags = 0;
39681- cdo->n_minors = 0;
39682 cdi->options = CDO_USE_FFLAGS;
39683
39684 if (autoclose == 1 && CDROM_CAN(CDC_CLOSE_TRAY))
39685@@ -630,8 +629,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
39686 else
39687 cdi->cdda_method = CDDA_OLD;
39688
39689- if (!cdo->generic_packet)
39690- cdo->generic_packet = cdrom_dummy_generic_packet;
39691+ if (!cdo->generic_packet) {
39692+ pax_open_kernel();
39693+ *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
39694+ pax_close_kernel();
39695+ }
39696
39697 cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
39698 mutex_lock(&cdrom_mutex);
39699@@ -652,7 +654,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
39700 if (cdi->exit)
39701 cdi->exit(cdi);
39702
39703- cdi->ops->n_minors--;
39704 cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
39705 }
39706
39707@@ -2126,7 +2127,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
39708 */
39709 nr = nframes;
39710 do {
39711- cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
39712+ cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
39713 if (cgc.buffer)
39714 break;
39715
39716@@ -3434,7 +3435,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
39717 struct cdrom_device_info *cdi;
39718 int ret;
39719
39720- ret = scnprintf(info + *pos, max_size - *pos, header);
39721+ ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
39722 if (!ret)
39723 return 1;
39724
39725diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
39726index 584bc31..e64a12c 100644
39727--- a/drivers/cdrom/gdrom.c
39728+++ b/drivers/cdrom/gdrom.c
39729@@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
39730 .audio_ioctl = gdrom_audio_ioctl,
39731 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
39732 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
39733- .n_minors = 1,
39734 };
39735
39736 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
39737diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
39738index a043107..1263e4a 100644
39739--- a/drivers/char/Kconfig
39740+++ b/drivers/char/Kconfig
39741@@ -17,7 +17,8 @@ config DEVMEM
39742
39743 config DEVKMEM
39744 bool "/dev/kmem virtual device support"
39745- default y
39746+ default n
39747+ depends on !GRKERNSEC_KMEM
39748 help
39749 Say Y here if you want to support the /dev/kmem device. The
39750 /dev/kmem device is rarely used, but can be used for certain
39751@@ -586,6 +587,7 @@ config DEVPORT
39752 bool
39753 depends on !M68K
39754 depends on ISA || PCI
39755+ depends on !GRKERNSEC_KMEM
39756 default y
39757
39758 source "drivers/s390/char/Kconfig"
39759diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
39760index a48e05b..6bac831 100644
39761--- a/drivers/char/agp/compat_ioctl.c
39762+++ b/drivers/char/agp/compat_ioctl.c
39763@@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
39764 return -ENOMEM;
39765 }
39766
39767- if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
39768+ if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
39769 sizeof(*usegment) * ureserve.seg_count)) {
39770 kfree(usegment);
39771 kfree(ksegment);
39772diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
39773index 09f17eb..8531d2f 100644
39774--- a/drivers/char/agp/frontend.c
39775+++ b/drivers/char/agp/frontend.c
39776@@ -806,7 +806,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
39777 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
39778 return -EFAULT;
39779
39780- if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
39781+ if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
39782 return -EFAULT;
39783
39784 client = agp_find_client_by_pid(reserve.pid);
39785@@ -836,7 +836,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
39786 if (segment == NULL)
39787 return -ENOMEM;
39788
39789- if (copy_from_user(segment, (void __user *) reserve.seg_list,
39790+ if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
39791 sizeof(struct agp_segment) * reserve.seg_count)) {
39792 kfree(segment);
39793 return -EFAULT;
39794diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
39795index c6dea3f..72ae4b0 100644
39796--- a/drivers/char/agp/intel-gtt.c
39797+++ b/drivers/char/agp/intel-gtt.c
39798@@ -1408,8 +1408,8 @@ int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
39799 }
39800 EXPORT_SYMBOL(intel_gmch_probe);
39801
39802-void intel_gtt_get(size_t *gtt_total, size_t *stolen_size,
39803- phys_addr_t *mappable_base, unsigned long *mappable_end)
39804+void intel_gtt_get(uint64_t *gtt_total, uint64_t *stolen_size,
39805+ uint64_t *mappable_base, uint64_t *mappable_end)
39806 {
39807 *gtt_total = intel_private.gtt_total_entries << PAGE_SHIFT;
39808 *stolen_size = intel_private.stolen_size;
39809diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
39810index 4f94375..413694e 100644
39811--- a/drivers/char/genrtc.c
39812+++ b/drivers/char/genrtc.c
39813@@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
39814 switch (cmd) {
39815
39816 case RTC_PLL_GET:
39817+ memset(&pll, 0, sizeof(pll));
39818 if (get_rtc_pll(&pll))
39819 return -EINVAL;
39820 else
39821diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
39822index 5c0baa9..44011b1 100644
39823--- a/drivers/char/hpet.c
39824+++ b/drivers/char/hpet.c
39825@@ -575,7 +575,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
39826 }
39827
39828 static int
39829-hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
39830+hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
39831 struct hpet_info *info)
39832 {
39833 struct hpet_timer __iomem *timer;
39834diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
39835index bf75f63..359fa10 100644
39836--- a/drivers/char/ipmi/ipmi_msghandler.c
39837+++ b/drivers/char/ipmi/ipmi_msghandler.c
39838@@ -436,7 +436,7 @@ struct ipmi_smi {
39839 struct proc_dir_entry *proc_dir;
39840 char proc_dir_name[10];
39841
39842- atomic_t stats[IPMI_NUM_STATS];
39843+ atomic_unchecked_t stats[IPMI_NUM_STATS];
39844
39845 /*
39846 * run_to_completion duplicate of smb_info, smi_info
39847@@ -468,9 +468,9 @@ static LIST_HEAD(smi_watchers);
39848 static DEFINE_MUTEX(smi_watchers_mutex);
39849
39850 #define ipmi_inc_stat(intf, stat) \
39851- atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
39852+ atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
39853 #define ipmi_get_stat(intf, stat) \
39854- ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
39855+ ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
39856
39857 static char *addr_src_to_str[] = { "invalid", "hotmod", "hardcoded", "SPMI",
39858 "ACPI", "SMBIOS", "PCI",
39859@@ -2828,7 +2828,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
39860 INIT_LIST_HEAD(&intf->cmd_rcvrs);
39861 init_waitqueue_head(&intf->waitq);
39862 for (i = 0; i < IPMI_NUM_STATS; i++)
39863- atomic_set(&intf->stats[i], 0);
39864+ atomic_set_unchecked(&intf->stats[i], 0);
39865
39866 intf->proc_dir = NULL;
39867
39868diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
39869index 8a45e92..e41b1c7 100644
39870--- a/drivers/char/ipmi/ipmi_si_intf.c
39871+++ b/drivers/char/ipmi/ipmi_si_intf.c
39872@@ -289,7 +289,7 @@ struct smi_info {
39873 unsigned char slave_addr;
39874
39875 /* Counters and things for the proc filesystem. */
39876- atomic_t stats[SI_NUM_STATS];
39877+ atomic_unchecked_t stats[SI_NUM_STATS];
39878
39879 struct task_struct *thread;
39880
39881@@ -298,9 +298,9 @@ struct smi_info {
39882 };
39883
39884 #define smi_inc_stat(smi, stat) \
39885- atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
39886+ atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
39887 #define smi_get_stat(smi, stat) \
39888- ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
39889+ ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
39890
39891 #define SI_MAX_PARMS 4
39892
39893@@ -3500,7 +3500,7 @@ static int try_smi_init(struct smi_info *new_smi)
39894 atomic_set(&new_smi->req_events, 0);
39895 new_smi->run_to_completion = false;
39896 for (i = 0; i < SI_NUM_STATS; i++)
39897- atomic_set(&new_smi->stats[i], 0);
39898+ atomic_set_unchecked(&new_smi->stats[i], 0);
39899
39900 new_smi->interrupt_disabled = true;
39901 atomic_set(&new_smi->need_watch, 0);
39902diff --git a/drivers/char/mem.c b/drivers/char/mem.c
39903index 6b1721f..fda9398 100644
39904--- a/drivers/char/mem.c
39905+++ b/drivers/char/mem.c
39906@@ -18,6 +18,7 @@
39907 #include <linux/raw.h>
39908 #include <linux/tty.h>
39909 #include <linux/capability.h>
39910+#include <linux/security.h>
39911 #include <linux/ptrace.h>
39912 #include <linux/device.h>
39913 #include <linux/highmem.h>
39914@@ -36,6 +37,10 @@
39915
39916 #define DEVPORT_MINOR 4
39917
39918+#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
39919+extern const struct file_operations grsec_fops;
39920+#endif
39921+
39922 static inline unsigned long size_inside_page(unsigned long start,
39923 unsigned long size)
39924 {
39925@@ -67,9 +72,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
39926
39927 while (cursor < to) {
39928 if (!devmem_is_allowed(pfn)) {
39929+#ifdef CONFIG_GRKERNSEC_KMEM
39930+ gr_handle_mem_readwrite(from, to);
39931+#else
39932 printk(KERN_INFO
39933 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
39934 current->comm, from, to);
39935+#endif
39936 return 0;
39937 }
39938 cursor += PAGE_SIZE;
39939@@ -77,6 +86,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
39940 }
39941 return 1;
39942 }
39943+#elif defined(CONFIG_GRKERNSEC_KMEM)
39944+static inline int range_is_allowed(unsigned long pfn, unsigned long size)
39945+{
39946+ return 0;
39947+}
39948 #else
39949 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
39950 {
39951@@ -124,7 +138,8 @@ static ssize_t read_mem(struct file *file, char __user *buf,
39952 #endif
39953
39954 while (count > 0) {
39955- unsigned long remaining;
39956+ unsigned long remaining = 0;
39957+ char *temp;
39958
39959 sz = size_inside_page(p, count);
39960
39961@@ -140,7 +155,24 @@ static ssize_t read_mem(struct file *file, char __user *buf,
39962 if (!ptr)
39963 return -EFAULT;
39964
39965- remaining = copy_to_user(buf, ptr, sz);
39966+#ifdef CONFIG_PAX_USERCOPY
39967+ temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
39968+ if (!temp) {
39969+ unxlate_dev_mem_ptr(p, ptr);
39970+ return -ENOMEM;
39971+ }
39972+ remaining = probe_kernel_read(temp, ptr, sz);
39973+#else
39974+ temp = ptr;
39975+#endif
39976+
39977+ if (!remaining)
39978+ remaining = copy_to_user(buf, temp, sz);
39979+
39980+#ifdef CONFIG_PAX_USERCOPY
39981+ kfree(temp);
39982+#endif
39983+
39984 unxlate_dev_mem_ptr(p, ptr);
39985 if (remaining)
39986 return -EFAULT;
39987@@ -380,9 +412,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
39988 size_t count, loff_t *ppos)
39989 {
39990 unsigned long p = *ppos;
39991- ssize_t low_count, read, sz;
39992+ ssize_t low_count, read, sz, err = 0;
39993 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
39994- int err = 0;
39995
39996 read = 0;
39997 if (p < (unsigned long) high_memory) {
39998@@ -404,6 +435,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
39999 }
40000 #endif
40001 while (low_count > 0) {
40002+ char *temp;
40003+
40004 sz = size_inside_page(p, low_count);
40005
40006 /*
40007@@ -413,7 +446,23 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
40008 */
40009 kbuf = xlate_dev_kmem_ptr((void *)p);
40010
40011- if (copy_to_user(buf, kbuf, sz))
40012+#ifdef CONFIG_PAX_USERCOPY
40013+ temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
40014+ if (!temp)
40015+ return -ENOMEM;
40016+ err = probe_kernel_read(temp, kbuf, sz);
40017+#else
40018+ temp = kbuf;
40019+#endif
40020+
40021+ if (!err)
40022+ err = copy_to_user(buf, temp, sz);
40023+
40024+#ifdef CONFIG_PAX_USERCOPY
40025+ kfree(temp);
40026+#endif
40027+
40028+ if (err)
40029 return -EFAULT;
40030 buf += sz;
40031 p += sz;
40032@@ -802,6 +851,9 @@ static const struct memdev {
40033 #ifdef CONFIG_PRINTK
40034 [11] = { "kmsg", 0644, &kmsg_fops, 0 },
40035 #endif
40036+#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
40037+ [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, 0 },
40038+#endif
40039 };
40040
40041 static int memory_open(struct inode *inode, struct file *filp)
40042@@ -863,7 +915,7 @@ static int __init chr_dev_init(void)
40043 continue;
40044
40045 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
40046- NULL, devlist[minor].name);
40047+ NULL, "%s", devlist[minor].name);
40048 }
40049
40050 return tty_init();
40051diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
40052index 9df78e2..01ba9ae 100644
40053--- a/drivers/char/nvram.c
40054+++ b/drivers/char/nvram.c
40055@@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
40056
40057 spin_unlock_irq(&rtc_lock);
40058
40059- if (copy_to_user(buf, contents, tmp - contents))
40060+ if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
40061 return -EFAULT;
40062
40063 *ppos = i;
40064diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
40065index 7680d52..073f799e 100644
40066--- a/drivers/char/pcmcia/synclink_cs.c
40067+++ b/drivers/char/pcmcia/synclink_cs.c
40068@@ -2345,7 +2345,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
40069
40070 if (debug_level >= DEBUG_LEVEL_INFO)
40071 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
40072- __FILE__, __LINE__, info->device_name, port->count);
40073+ __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
40074
40075 if (tty_port_close_start(port, tty, filp) == 0)
40076 goto cleanup;
40077@@ -2363,7 +2363,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
40078 cleanup:
40079 if (debug_level >= DEBUG_LEVEL_INFO)
40080 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
40081- tty->driver->name, port->count);
40082+ tty->driver->name, atomic_read(&port->count));
40083 }
40084
40085 /* Wait until the transmitter is empty.
40086@@ -2505,7 +2505,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
40087
40088 if (debug_level >= DEBUG_LEVEL_INFO)
40089 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
40090- __FILE__, __LINE__, tty->driver->name, port->count);
40091+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
40092
40093 /* If port is closing, signal caller to try again */
40094 if (port->flags & ASYNC_CLOSING){
40095@@ -2525,11 +2525,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
40096 goto cleanup;
40097 }
40098 spin_lock(&port->lock);
40099- port->count++;
40100+ atomic_inc(&port->count);
40101 spin_unlock(&port->lock);
40102 spin_unlock_irqrestore(&info->netlock, flags);
40103
40104- if (port->count == 1) {
40105+ if (atomic_read(&port->count) == 1) {
40106 /* 1st open on this device, init hardware */
40107 retval = startup(info, tty);
40108 if (retval < 0)
40109@@ -3918,7 +3918,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
40110 unsigned short new_crctype;
40111
40112 /* return error if TTY interface open */
40113- if (info->port.count)
40114+ if (atomic_read(&info->port.count))
40115 return -EBUSY;
40116
40117 switch (encoding)
40118@@ -4022,7 +4022,7 @@ static int hdlcdev_open(struct net_device *dev)
40119
40120 /* arbitrate between network and tty opens */
40121 spin_lock_irqsave(&info->netlock, flags);
40122- if (info->port.count != 0 || info->netcount != 0) {
40123+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
40124 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
40125 spin_unlock_irqrestore(&info->netlock, flags);
40126 return -EBUSY;
40127@@ -4112,7 +4112,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40128 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
40129
40130 /* return error if TTY interface open */
40131- if (info->port.count)
40132+ if (atomic_read(&info->port.count))
40133 return -EBUSY;
40134
40135 if (cmd != SIOCWANDEV)
40136diff --git a/drivers/char/random.c b/drivers/char/random.c
40137index d0da5d8..739fd3a 100644
40138--- a/drivers/char/random.c
40139+++ b/drivers/char/random.c
40140@@ -289,9 +289,6 @@
40141 /*
40142 * To allow fractional bits to be tracked, the entropy_count field is
40143 * denominated in units of 1/8th bits.
40144- *
40145- * 2*(ENTROPY_SHIFT + log2(poolbits)) must <= 31, or the multiply in
40146- * credit_entropy_bits() needs to be 64 bits wide.
40147 */
40148 #define ENTROPY_SHIFT 3
40149 #define ENTROPY_BITS(r) ((r)->entropy_count >> ENTROPY_SHIFT)
40150@@ -442,9 +439,9 @@ struct entropy_store {
40151 };
40152
40153 static void push_to_pool(struct work_struct *work);
40154-static __u32 input_pool_data[INPUT_POOL_WORDS];
40155-static __u32 blocking_pool_data[OUTPUT_POOL_WORDS];
40156-static __u32 nonblocking_pool_data[OUTPUT_POOL_WORDS];
40157+static __u32 input_pool_data[INPUT_POOL_WORDS] __latent_entropy;
40158+static __u32 blocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
40159+static __u32 nonblocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
40160
40161 static struct entropy_store input_pool = {
40162 .poolinfo = &poolinfo_table[0],
40163@@ -654,7 +651,7 @@ retry:
40164 /* The +2 corresponds to the /4 in the denominator */
40165
40166 do {
40167- unsigned int anfrac = min(pnfrac, pool_size/2);
40168+ u64 anfrac = min(pnfrac, pool_size/2);
40169 unsigned int add =
40170 ((pool_size - entropy_count)*anfrac*3) >> s;
40171
40172@@ -1227,7 +1224,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
40173
40174 extract_buf(r, tmp);
40175 i = min_t(int, nbytes, EXTRACT_SIZE);
40176- if (copy_to_user(buf, tmp, i)) {
40177+ if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
40178 ret = -EFAULT;
40179 break;
40180 }
40181@@ -1668,7 +1665,7 @@ static char sysctl_bootid[16];
40182 static int proc_do_uuid(struct ctl_table *table, int write,
40183 void __user *buffer, size_t *lenp, loff_t *ppos)
40184 {
40185- struct ctl_table fake_table;
40186+ ctl_table_no_const fake_table;
40187 unsigned char buf[64], tmp_uuid[16], *uuid;
40188
40189 uuid = table->data;
40190@@ -1698,7 +1695,7 @@ static int proc_do_uuid(struct ctl_table *table, int write,
40191 static int proc_do_entropy(struct ctl_table *table, int write,
40192 void __user *buffer, size_t *lenp, loff_t *ppos)
40193 {
40194- struct ctl_table fake_table;
40195+ ctl_table_no_const fake_table;
40196 int entropy_count;
40197
40198 entropy_count = *(int *)table->data >> ENTROPY_SHIFT;
40199diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
40200index e496dae..3db53b6 100644
40201--- a/drivers/char/sonypi.c
40202+++ b/drivers/char/sonypi.c
40203@@ -54,6 +54,7 @@
40204
40205 #include <asm/uaccess.h>
40206 #include <asm/io.h>
40207+#include <asm/local.h>
40208
40209 #include <linux/sonypi.h>
40210
40211@@ -490,7 +491,7 @@ static struct sonypi_device {
40212 spinlock_t fifo_lock;
40213 wait_queue_head_t fifo_proc_list;
40214 struct fasync_struct *fifo_async;
40215- int open_count;
40216+ local_t open_count;
40217 int model;
40218 struct input_dev *input_jog_dev;
40219 struct input_dev *input_key_dev;
40220@@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
40221 static int sonypi_misc_release(struct inode *inode, struct file *file)
40222 {
40223 mutex_lock(&sonypi_device.lock);
40224- sonypi_device.open_count--;
40225+ local_dec(&sonypi_device.open_count);
40226 mutex_unlock(&sonypi_device.lock);
40227 return 0;
40228 }
40229@@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
40230 {
40231 mutex_lock(&sonypi_device.lock);
40232 /* Flush input queue on first open */
40233- if (!sonypi_device.open_count)
40234+ if (!local_read(&sonypi_device.open_count))
40235 kfifo_reset(&sonypi_device.fifo);
40236- sonypi_device.open_count++;
40237+ local_inc(&sonypi_device.open_count);
40238 mutex_unlock(&sonypi_device.lock);
40239
40240 return 0;
40241@@ -1491,7 +1492,7 @@ static struct platform_driver sonypi_driver = {
40242
40243 static struct platform_device *sonypi_platform_device;
40244
40245-static struct dmi_system_id __initdata sonypi_dmi_table[] = {
40246+static const struct dmi_system_id __initconst sonypi_dmi_table[] = {
40247 {
40248 .ident = "Sony Vaio",
40249 .matches = {
40250diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
40251index 565a947..dcdc06e 100644
40252--- a/drivers/char/tpm/tpm_acpi.c
40253+++ b/drivers/char/tpm/tpm_acpi.c
40254@@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
40255 virt = acpi_os_map_iomem(start, len);
40256 if (!virt) {
40257 kfree(log->bios_event_log);
40258+ log->bios_event_log = NULL;
40259 printk("%s: ERROR - Unable to map memory\n", __func__);
40260 return -EIO;
40261 }
40262
40263- memcpy_fromio(log->bios_event_log, virt, len);
40264+ memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
40265
40266 acpi_os_unmap_iomem(virt, len);
40267 return 0;
40268diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
40269index 3a56a13..f8cbd25 100644
40270--- a/drivers/char/tpm/tpm_eventlog.c
40271+++ b/drivers/char/tpm/tpm_eventlog.c
40272@@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
40273 event = addr;
40274
40275 if ((event->event_type == 0 && event->event_size == 0) ||
40276- ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
40277+ (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
40278 return NULL;
40279
40280 return addr;
40281@@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
40282 return NULL;
40283
40284 if ((event->event_type == 0 && event->event_size == 0) ||
40285- ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
40286+ (event->event_size >= limit - v - sizeof(struct tcpa_event)))
40287 return NULL;
40288
40289 (*pos)++;
40290@@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
40291 int i;
40292
40293 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
40294- seq_putc(m, data[i]);
40295+ if (!seq_putc(m, data[i]))
40296+ return -EFAULT;
40297
40298 return 0;
40299 }
40300diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
40301index d2406fe..243951a 100644
40302--- a/drivers/char/virtio_console.c
40303+++ b/drivers/char/virtio_console.c
40304@@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char __user *out_buf,
40305 if (to_user) {
40306 ssize_t ret;
40307
40308- ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
40309+ ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
40310 if (ret)
40311 return -EFAULT;
40312 } else {
40313@@ -789,7 +789,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
40314 if (!port_has_data(port) && !port->host_connected)
40315 return 0;
40316
40317- return fill_readbuf(port, ubuf, count, true);
40318+ return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
40319 }
40320
40321 static int wait_port_writable(struct port *port, bool nonblock)
40322diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
40323index 616f5ae..747bdd0 100644
40324--- a/drivers/clk/clk-composite.c
40325+++ b/drivers/clk/clk-composite.c
40326@@ -197,7 +197,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
40327 struct clk *clk;
40328 struct clk_init_data init;
40329 struct clk_composite *composite;
40330- struct clk_ops *clk_composite_ops;
40331+ clk_ops_no_const *clk_composite_ops;
40332
40333 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
40334 if (!composite)
40335diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h
40336index b775fc2..2d45b64 100644
40337--- a/drivers/clk/samsung/clk.h
40338+++ b/drivers/clk/samsung/clk.h
40339@@ -260,7 +260,7 @@ struct samsung_gate_clock {
40340 #define GATE_DA(_id, dname, cname, pname, o, b, f, gf, a) \
40341 __GATE(_id, dname, cname, pname, o, b, f, gf, a)
40342
40343-#define PNAME(x) static const char *x[] __initdata
40344+#define PNAME(x) static const char * const x[] __initconst
40345
40346 /**
40347 * struct samsung_clk_reg_dump: register dump of clock controller registers.
40348diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
40349index 82449cd..dcfec30 100644
40350--- a/drivers/clk/socfpga/clk-gate.c
40351+++ b/drivers/clk/socfpga/clk-gate.c
40352@@ -22,6 +22,7 @@
40353 #include <linux/mfd/syscon.h>
40354 #include <linux/of.h>
40355 #include <linux/regmap.h>
40356+#include <asm/pgtable.h>
40357
40358 #include "clk.h"
40359
40360@@ -170,7 +171,7 @@ static int socfpga_clk_prepare(struct clk_hw *hwclk)
40361 return 0;
40362 }
40363
40364-static struct clk_ops gateclk_ops = {
40365+static clk_ops_no_const gateclk_ops __read_only = {
40366 .prepare = socfpga_clk_prepare,
40367 .recalc_rate = socfpga_clk_recalc_rate,
40368 .get_parent = socfpga_clk_get_parent,
40369@@ -203,8 +204,10 @@ static void __init __socfpga_gate_init(struct device_node *node,
40370 socfpga_clk->hw.reg = clk_mgr_base_addr + clk_gate[0];
40371 socfpga_clk->hw.bit_idx = clk_gate[1];
40372
40373- gateclk_ops.enable = clk_gate_ops.enable;
40374- gateclk_ops.disable = clk_gate_ops.disable;
40375+ pax_open_kernel();
40376+ *(void **)&gateclk_ops.enable = clk_gate_ops.enable;
40377+ *(void **)&gateclk_ops.disable = clk_gate_ops.disable;
40378+ pax_close_kernel();
40379 }
40380
40381 rc = of_property_read_u32(node, "fixed-divider", &fixed_div);
40382diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
40383index 8f26b52..29f2a3a 100644
40384--- a/drivers/clk/socfpga/clk-pll.c
40385+++ b/drivers/clk/socfpga/clk-pll.c
40386@@ -21,6 +21,7 @@
40387 #include <linux/io.h>
40388 #include <linux/of.h>
40389 #include <linux/of_address.h>
40390+#include <asm/pgtable.h>
40391
40392 #include "clk.h"
40393
40394@@ -76,7 +77,7 @@ static u8 clk_pll_get_parent(struct clk_hw *hwclk)
40395 CLK_MGR_PLL_CLK_SRC_MASK;
40396 }
40397
40398-static struct clk_ops clk_pll_ops = {
40399+static clk_ops_no_const clk_pll_ops __read_only = {
40400 .recalc_rate = clk_pll_recalc_rate,
40401 .get_parent = clk_pll_get_parent,
40402 };
40403@@ -115,8 +116,10 @@ static __init struct clk *__socfpga_pll_init(struct device_node *node,
40404 pll_clk->hw.hw.init = &init;
40405
40406 pll_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
40407- clk_pll_ops.enable = clk_gate_ops.enable;
40408- clk_pll_ops.disable = clk_gate_ops.disable;
40409+ pax_open_kernel();
40410+ *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
40411+ *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
40412+ pax_close_kernel();
40413
40414 clk = clk_register(NULL, &pll_clk->hw.hw);
40415 if (WARN_ON(IS_ERR(clk))) {
40416diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
40417index 7c2a738..0b84bd6 100644
40418--- a/drivers/cpufreq/acpi-cpufreq.c
40419+++ b/drivers/cpufreq/acpi-cpufreq.c
40420@@ -678,8 +678,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
40421 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
40422 per_cpu(acfreq_data, cpu) = data;
40423
40424- if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
40425- acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
40426+ if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
40427+ pax_open_kernel();
40428+ *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
40429+ pax_close_kernel();
40430+ }
40431
40432 result = acpi_processor_register_performance(data->acpi_data, cpu);
40433 if (result)
40434@@ -813,7 +816,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
40435 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
40436 break;
40437 case ACPI_ADR_SPACE_FIXED_HARDWARE:
40438- acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
40439+ pax_open_kernel();
40440+ *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
40441+ pax_close_kernel();
40442 break;
40443 default:
40444 break;
40445@@ -907,8 +912,10 @@ static void __init acpi_cpufreq_boost_init(void)
40446 if (!msrs)
40447 return;
40448
40449- acpi_cpufreq_driver.boost_supported = true;
40450- acpi_cpufreq_driver.boost_enabled = boost_state(0);
40451+ pax_open_kernel();
40452+ *(bool *)&acpi_cpufreq_driver.boost_supported = true;
40453+ *(bool *)&acpi_cpufreq_driver.boost_enabled = boost_state(0);
40454+ pax_close_kernel();
40455
40456 cpu_notifier_register_begin();
40457
40458diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
40459index 99a4065..f97236c 100644
40460--- a/drivers/cpufreq/cpufreq-dt.c
40461+++ b/drivers/cpufreq/cpufreq-dt.c
40462@@ -393,7 +393,9 @@ static int dt_cpufreq_probe(struct platform_device *pdev)
40463 if (!IS_ERR(cpu_reg))
40464 regulator_put(cpu_reg);
40465
40466- dt_cpufreq_driver.driver_data = dev_get_platdata(&pdev->dev);
40467+ pax_open_kernel();
40468+ *(void **)&dt_cpufreq_driver.driver_data = dev_get_platdata(&pdev->dev);
40469+ pax_close_kernel();
40470
40471 ret = cpufreq_register_driver(&dt_cpufreq_driver);
40472 if (ret)
40473diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
40474index 7a3c30c..bac142e 100644
40475--- a/drivers/cpufreq/cpufreq.c
40476+++ b/drivers/cpufreq/cpufreq.c
40477@@ -2197,7 +2197,7 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor)
40478 read_unlock_irqrestore(&cpufreq_driver_lock, flags);
40479
40480 mutex_lock(&cpufreq_governor_mutex);
40481- list_del(&governor->governor_list);
40482+ pax_list_del(&governor->governor_list);
40483 mutex_unlock(&cpufreq_governor_mutex);
40484 return;
40485 }
40486@@ -2412,7 +2412,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
40487 return NOTIFY_OK;
40488 }
40489
40490-static struct notifier_block __refdata cpufreq_cpu_notifier = {
40491+static struct notifier_block cpufreq_cpu_notifier = {
40492 .notifier_call = cpufreq_cpu_callback,
40493 };
40494
40495@@ -2452,13 +2452,17 @@ int cpufreq_boost_trigger_state(int state)
40496 return 0;
40497
40498 write_lock_irqsave(&cpufreq_driver_lock, flags);
40499- cpufreq_driver->boost_enabled = state;
40500+ pax_open_kernel();
40501+ *(bool *)&cpufreq_driver->boost_enabled = state;
40502+ pax_close_kernel();
40503 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
40504
40505 ret = cpufreq_driver->set_boost(state);
40506 if (ret) {
40507 write_lock_irqsave(&cpufreq_driver_lock, flags);
40508- cpufreq_driver->boost_enabled = !state;
40509+ pax_open_kernel();
40510+ *(bool *)&cpufreq_driver->boost_enabled = !state;
40511+ pax_close_kernel();
40512 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
40513
40514 pr_err("%s: Cannot %s BOOST\n",
40515@@ -2523,16 +2527,22 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
40516 cpufreq_driver = driver_data;
40517 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
40518
40519- if (driver_data->setpolicy)
40520- driver_data->flags |= CPUFREQ_CONST_LOOPS;
40521+ if (driver_data->setpolicy) {
40522+ pax_open_kernel();
40523+ *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
40524+ pax_close_kernel();
40525+ }
40526
40527 if (cpufreq_boost_supported()) {
40528 /*
40529 * Check if driver provides function to enable boost -
40530 * if not, use cpufreq_boost_set_sw as default
40531 */
40532- if (!cpufreq_driver->set_boost)
40533- cpufreq_driver->set_boost = cpufreq_boost_set_sw;
40534+ if (!cpufreq_driver->set_boost) {
40535+ pax_open_kernel();
40536+ *(void **)&cpufreq_driver->set_boost = cpufreq_boost_set_sw;
40537+ pax_close_kernel();
40538+ }
40539
40540 ret = cpufreq_sysfs_create_file(&boost.attr);
40541 if (ret) {
40542diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
40543index 57a39f8..feb9c73 100644
40544--- a/drivers/cpufreq/cpufreq_governor.c
40545+++ b/drivers/cpufreq/cpufreq_governor.c
40546@@ -378,7 +378,7 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy,
40547 cs_dbs_info->enable = 1;
40548 cs_dbs_info->requested_freq = policy->cur;
40549 } else {
40550- struct od_ops *od_ops = cdata->gov_ops;
40551+ const struct od_ops *od_ops = cdata->gov_ops;
40552 struct od_cpu_dbs_info_s *od_dbs_info = cdata->get_cpu_dbs_info_s(cpu);
40553
40554 od_dbs_info->rate_mult = 1;
40555diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
40556index 34736f5..da8cf4a 100644
40557--- a/drivers/cpufreq/cpufreq_governor.h
40558+++ b/drivers/cpufreq/cpufreq_governor.h
40559@@ -212,7 +212,7 @@ struct common_dbs_data {
40560 void (*exit)(struct dbs_data *dbs_data, bool notify);
40561
40562 /* Governor specific ops, see below */
40563- void *gov_ops;
40564+ const void *gov_ops;
40565
40566 /*
40567 * Protects governor's data (struct dbs_data and struct common_dbs_data)
40568@@ -234,7 +234,7 @@ struct od_ops {
40569 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
40570 unsigned int freq_next, unsigned int relation);
40571 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
40572-};
40573+} __no_const;
40574
40575 static inline int delay_for_sampling_rate(unsigned int sampling_rate)
40576 {
40577diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
40578index 3c1e10f..02f17af 100644
40579--- a/drivers/cpufreq/cpufreq_ondemand.c
40580+++ b/drivers/cpufreq/cpufreq_ondemand.c
40581@@ -523,7 +523,7 @@ static void od_exit(struct dbs_data *dbs_data, bool notify)
40582
40583 define_get_cpu_dbs_routines(od_cpu_dbs_info);
40584
40585-static struct od_ops od_ops = {
40586+static struct od_ops od_ops __read_only = {
40587 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
40588 .powersave_bias_target = generic_powersave_bias_target,
40589 .freq_increase = dbs_freq_increase,
40590@@ -579,14 +579,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
40591 (struct cpufreq_policy *, unsigned int, unsigned int),
40592 unsigned int powersave_bias)
40593 {
40594- od_ops.powersave_bias_target = f;
40595+ pax_open_kernel();
40596+ *(void **)&od_ops.powersave_bias_target = f;
40597+ pax_close_kernel();
40598 od_set_powersave_bias(powersave_bias);
40599 }
40600 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
40601
40602 void od_unregister_powersave_bias_handler(void)
40603 {
40604- od_ops.powersave_bias_target = generic_powersave_bias_target;
40605+ pax_open_kernel();
40606+ *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
40607+ pax_close_kernel();
40608 od_set_powersave_bias(0);
40609 }
40610 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
40611diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
40612index fcb929e..e628818 100644
40613--- a/drivers/cpufreq/intel_pstate.c
40614+++ b/drivers/cpufreq/intel_pstate.c
40615@@ -137,10 +137,10 @@ struct pstate_funcs {
40616 struct cpu_defaults {
40617 struct pstate_adjust_policy pid_policy;
40618 struct pstate_funcs funcs;
40619-};
40620+} __do_const;
40621
40622 static struct pstate_adjust_policy pid_params;
40623-static struct pstate_funcs pstate_funcs;
40624+static struct pstate_funcs *pstate_funcs;
40625 static int hwp_active;
40626
40627 struct perf_limits {
40628@@ -726,18 +726,18 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate, bool force)
40629
40630 cpu->pstate.current_pstate = pstate;
40631
40632- pstate_funcs.set(cpu, pstate);
40633+ pstate_funcs->set(cpu, pstate);
40634 }
40635
40636 static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
40637 {
40638- cpu->pstate.min_pstate = pstate_funcs.get_min();
40639- cpu->pstate.max_pstate = pstate_funcs.get_max();
40640- cpu->pstate.turbo_pstate = pstate_funcs.get_turbo();
40641- cpu->pstate.scaling = pstate_funcs.get_scaling();
40642+ cpu->pstate.min_pstate = pstate_funcs->get_min();
40643+ cpu->pstate.max_pstate = pstate_funcs->get_max();
40644+ cpu->pstate.turbo_pstate = pstate_funcs->get_turbo();
40645+ cpu->pstate.scaling = pstate_funcs->get_scaling();
40646
40647- if (pstate_funcs.get_vid)
40648- pstate_funcs.get_vid(cpu);
40649+ if (pstate_funcs->get_vid)
40650+ pstate_funcs->get_vid(cpu);
40651 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate, false);
40652 }
40653
40654@@ -1070,15 +1070,15 @@ static unsigned int force_load;
40655
40656 static int intel_pstate_msrs_not_valid(void)
40657 {
40658- if (!pstate_funcs.get_max() ||
40659- !pstate_funcs.get_min() ||
40660- !pstate_funcs.get_turbo())
40661+ if (!pstate_funcs->get_max() ||
40662+ !pstate_funcs->get_min() ||
40663+ !pstate_funcs->get_turbo())
40664 return -ENODEV;
40665
40666 return 0;
40667 }
40668
40669-static void copy_pid_params(struct pstate_adjust_policy *policy)
40670+static void copy_pid_params(const struct pstate_adjust_policy *policy)
40671 {
40672 pid_params.sample_rate_ms = policy->sample_rate_ms;
40673 pid_params.p_gain_pct = policy->p_gain_pct;
40674@@ -1090,12 +1090,7 @@ static void copy_pid_params(struct pstate_adjust_policy *policy)
40675
40676 static void copy_cpu_funcs(struct pstate_funcs *funcs)
40677 {
40678- pstate_funcs.get_max = funcs->get_max;
40679- pstate_funcs.get_min = funcs->get_min;
40680- pstate_funcs.get_turbo = funcs->get_turbo;
40681- pstate_funcs.get_scaling = funcs->get_scaling;
40682- pstate_funcs.set = funcs->set;
40683- pstate_funcs.get_vid = funcs->get_vid;
40684+ pstate_funcs = funcs;
40685 }
40686
40687 #if IS_ENABLED(CONFIG_ACPI)
40688diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
40689index 5dd95da..abc3837 100644
40690--- a/drivers/cpufreq/p4-clockmod.c
40691+++ b/drivers/cpufreq/p4-clockmod.c
40692@@ -134,10 +134,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
40693 case 0x0F: /* Core Duo */
40694 case 0x16: /* Celeron Core */
40695 case 0x1C: /* Atom */
40696- p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40697+ pax_open_kernel();
40698+ *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40699+ pax_close_kernel();
40700 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
40701 case 0x0D: /* Pentium M (Dothan) */
40702- p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40703+ pax_open_kernel();
40704+ *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40705+ pax_close_kernel();
40706 /* fall through */
40707 case 0x09: /* Pentium M (Banias) */
40708 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
40709@@ -149,7 +153,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
40710
40711 /* on P-4s, the TSC runs with constant frequency independent whether
40712 * throttling is active or not. */
40713- p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40714+ pax_open_kernel();
40715+ *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40716+ pax_close_kernel();
40717
40718 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
40719 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
40720diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
40721index 9bb42ba..b01b4a2 100644
40722--- a/drivers/cpufreq/sparc-us3-cpufreq.c
40723+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
40724@@ -18,14 +18,12 @@
40725 #include <asm/head.h>
40726 #include <asm/timer.h>
40727
40728-static struct cpufreq_driver *cpufreq_us3_driver;
40729-
40730 struct us3_freq_percpu_info {
40731 struct cpufreq_frequency_table table[4];
40732 };
40733
40734 /* Indexed by cpu number. */
40735-static struct us3_freq_percpu_info *us3_freq_table;
40736+static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
40737
40738 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
40739 * in the Safari config register.
40740@@ -156,16 +154,27 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
40741
40742 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
40743 {
40744- if (cpufreq_us3_driver)
40745- us3_freq_target(policy, 0);
40746+ us3_freq_target(policy, 0);
40747
40748 return 0;
40749 }
40750
40751+static int __init us3_freq_init(void);
40752+static void __exit us3_freq_exit(void);
40753+
40754+static struct cpufreq_driver cpufreq_us3_driver = {
40755+ .init = us3_freq_cpu_init,
40756+ .verify = cpufreq_generic_frequency_table_verify,
40757+ .target_index = us3_freq_target,
40758+ .get = us3_freq_get,
40759+ .exit = us3_freq_cpu_exit,
40760+ .name = "UltraSPARC-III",
40761+
40762+};
40763+
40764 static int __init us3_freq_init(void)
40765 {
40766 unsigned long manuf, impl, ver;
40767- int ret;
40768
40769 if (tlb_type != cheetah && tlb_type != cheetah_plus)
40770 return -ENODEV;
40771@@ -178,55 +187,15 @@ static int __init us3_freq_init(void)
40772 (impl == CHEETAH_IMPL ||
40773 impl == CHEETAH_PLUS_IMPL ||
40774 impl == JAGUAR_IMPL ||
40775- impl == PANTHER_IMPL)) {
40776- struct cpufreq_driver *driver;
40777-
40778- ret = -ENOMEM;
40779- driver = kzalloc(sizeof(*driver), GFP_KERNEL);
40780- if (!driver)
40781- goto err_out;
40782-
40783- us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
40784- GFP_KERNEL);
40785- if (!us3_freq_table)
40786- goto err_out;
40787-
40788- driver->init = us3_freq_cpu_init;
40789- driver->verify = cpufreq_generic_frequency_table_verify;
40790- driver->target_index = us3_freq_target;
40791- driver->get = us3_freq_get;
40792- driver->exit = us3_freq_cpu_exit;
40793- strcpy(driver->name, "UltraSPARC-III");
40794-
40795- cpufreq_us3_driver = driver;
40796- ret = cpufreq_register_driver(driver);
40797- if (ret)
40798- goto err_out;
40799-
40800- return 0;
40801-
40802-err_out:
40803- if (driver) {
40804- kfree(driver);
40805- cpufreq_us3_driver = NULL;
40806- }
40807- kfree(us3_freq_table);
40808- us3_freq_table = NULL;
40809- return ret;
40810- }
40811+ impl == PANTHER_IMPL))
40812+ return cpufreq_register_driver(&cpufreq_us3_driver);
40813
40814 return -ENODEV;
40815 }
40816
40817 static void __exit us3_freq_exit(void)
40818 {
40819- if (cpufreq_us3_driver) {
40820- cpufreq_unregister_driver(cpufreq_us3_driver);
40821- kfree(cpufreq_us3_driver);
40822- cpufreq_us3_driver = NULL;
40823- kfree(us3_freq_table);
40824- us3_freq_table = NULL;
40825- }
40826+ cpufreq_unregister_driver(&cpufreq_us3_driver);
40827 }
40828
40829 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
40830diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
40831index 7d4a315..21bb886 100644
40832--- a/drivers/cpufreq/speedstep-centrino.c
40833+++ b/drivers/cpufreq/speedstep-centrino.c
40834@@ -351,8 +351,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
40835 !cpu_has(cpu, X86_FEATURE_EST))
40836 return -ENODEV;
40837
40838- if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
40839- centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
40840+ if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
40841+ pax_open_kernel();
40842+ *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
40843+ pax_close_kernel();
40844+ }
40845
40846 if (policy->cpu != 0)
40847 return -ENODEV;
40848diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
40849index 5db1478..e90e25e 100644
40850--- a/drivers/cpuidle/driver.c
40851+++ b/drivers/cpuidle/driver.c
40852@@ -193,7 +193,7 @@ static int poll_idle(struct cpuidle_device *dev,
40853
40854 static void poll_idle_init(struct cpuidle_driver *drv)
40855 {
40856- struct cpuidle_state *state = &drv->states[0];
40857+ cpuidle_state_no_const *state = &drv->states[0];
40858
40859 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
40860 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
40861diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c
40862index a5c111b..1113002 100644
40863--- a/drivers/cpuidle/dt_idle_states.c
40864+++ b/drivers/cpuidle/dt_idle_states.c
40865@@ -21,7 +21,7 @@
40866
40867 #include "dt_idle_states.h"
40868
40869-static int init_state_node(struct cpuidle_state *idle_state,
40870+static int init_state_node(cpuidle_state_no_const *idle_state,
40871 const struct of_device_id *matches,
40872 struct device_node *state_node)
40873 {
40874diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
40875index fb9f511..213e6cc 100644
40876--- a/drivers/cpuidle/governor.c
40877+++ b/drivers/cpuidle/governor.c
40878@@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
40879 mutex_lock(&cpuidle_lock);
40880 if (__cpuidle_find_governor(gov->name) == NULL) {
40881 ret = 0;
40882- list_add_tail(&gov->governor_list, &cpuidle_governors);
40883+ pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
40884 if (!cpuidle_curr_governor ||
40885 cpuidle_curr_governor->rating < gov->rating)
40886 cpuidle_switch_governor(gov);
40887diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
40888index 832a2c3..1794080 100644
40889--- a/drivers/cpuidle/sysfs.c
40890+++ b/drivers/cpuidle/sysfs.c
40891@@ -135,7 +135,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
40892 NULL
40893 };
40894
40895-static struct attribute_group cpuidle_attr_group = {
40896+static attribute_group_no_const cpuidle_attr_group = {
40897 .attrs = cpuidle_default_attrs,
40898 .name = "cpuidle",
40899 };
40900diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
40901index 8d2a772..33826c9 100644
40902--- a/drivers/crypto/hifn_795x.c
40903+++ b/drivers/crypto/hifn_795x.c
40904@@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
40905 MODULE_PARM_DESC(hifn_pll_ref,
40906 "PLL reference clock (pci[freq] or ext[freq], default ext)");
40907
40908-static atomic_t hifn_dev_number;
40909+static atomic_unchecked_t hifn_dev_number;
40910
40911 #define ACRYPTO_OP_DECRYPT 0
40912 #define ACRYPTO_OP_ENCRYPT 1
40913@@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
40914 goto err_out_disable_pci_device;
40915
40916 snprintf(name, sizeof(name), "hifn%d",
40917- atomic_inc_return(&hifn_dev_number)-1);
40918+ atomic_inc_return_unchecked(&hifn_dev_number)-1);
40919
40920 err = pci_request_regions(pdev, name);
40921 if (err)
40922diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
40923index ca1b362..01cae6a 100644
40924--- a/drivers/devfreq/devfreq.c
40925+++ b/drivers/devfreq/devfreq.c
40926@@ -672,7 +672,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
40927 goto err_out;
40928 }
40929
40930- list_add(&governor->node, &devfreq_governor_list);
40931+ pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
40932
40933 list_for_each_entry(devfreq, &devfreq_list, node) {
40934 int ret = 0;
40935@@ -760,7 +760,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
40936 }
40937 }
40938
40939- list_del(&governor->node);
40940+ pax_list_del((struct list_head *)&governor->node);
40941 err_out:
40942 mutex_unlock(&devfreq_list_lock);
40943
40944diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
40945index 10fcaba..326f709 100644
40946--- a/drivers/dma/sh/shdma-base.c
40947+++ b/drivers/dma/sh/shdma-base.c
40948@@ -227,8 +227,8 @@ static int shdma_alloc_chan_resources(struct dma_chan *chan)
40949 schan->slave_id = -EINVAL;
40950 }
40951
40952- schan->desc = kcalloc(NR_DESCS_PER_CHANNEL,
40953- sdev->desc_size, GFP_KERNEL);
40954+ schan->desc = kcalloc(sdev->desc_size,
40955+ NR_DESCS_PER_CHANNEL, GFP_KERNEL);
40956 if (!schan->desc) {
40957 ret = -ENOMEM;
40958 goto edescalloc;
40959diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
40960index 11707df..2ea96f7 100644
40961--- a/drivers/dma/sh/shdmac.c
40962+++ b/drivers/dma/sh/shdmac.c
40963@@ -513,7 +513,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
40964 return ret;
40965 }
40966
40967-static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
40968+static struct notifier_block sh_dmae_nmi_notifier = {
40969 .notifier_call = sh_dmae_nmi_handler,
40970
40971 /* Run before NMI debug handler and KGDB */
40972diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
40973index 592af5f..bb1d583 100644
40974--- a/drivers/edac/edac_device.c
40975+++ b/drivers/edac/edac_device.c
40976@@ -477,9 +477,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
40977 */
40978 int edac_device_alloc_index(void)
40979 {
40980- static atomic_t device_indexes = ATOMIC_INIT(0);
40981+ static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
40982
40983- return atomic_inc_return(&device_indexes) - 1;
40984+ return atomic_inc_return_unchecked(&device_indexes) - 1;
40985 }
40986 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
40987
40988diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
40989index 33df7d9..0794989 100644
40990--- a/drivers/edac/edac_mc_sysfs.c
40991+++ b/drivers/edac/edac_mc_sysfs.c
40992@@ -154,7 +154,7 @@ static const char * const edac_caps[] = {
40993 struct dev_ch_attribute {
40994 struct device_attribute attr;
40995 int channel;
40996-};
40997+} __do_const;
40998
40999 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
41000 static struct dev_ch_attribute dev_attr_legacy_##_name = \
41001diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
41002index 2cf44b4d..6dd2dc7 100644
41003--- a/drivers/edac/edac_pci.c
41004+++ b/drivers/edac/edac_pci.c
41005@@ -29,7 +29,7 @@
41006
41007 static DEFINE_MUTEX(edac_pci_ctls_mutex);
41008 static LIST_HEAD(edac_pci_list);
41009-static atomic_t pci_indexes = ATOMIC_INIT(0);
41010+static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
41011
41012 /*
41013 * edac_pci_alloc_ctl_info
41014@@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
41015 */
41016 int edac_pci_alloc_index(void)
41017 {
41018- return atomic_inc_return(&pci_indexes) - 1;
41019+ return atomic_inc_return_unchecked(&pci_indexes) - 1;
41020 }
41021 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
41022
41023diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
41024index 24d877f..4e30133 100644
41025--- a/drivers/edac/edac_pci_sysfs.c
41026+++ b/drivers/edac/edac_pci_sysfs.c
41027@@ -23,8 +23,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
41028 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
41029 static int edac_pci_poll_msec = 1000; /* one second workq period */
41030
41031-static atomic_t pci_parity_count = ATOMIC_INIT(0);
41032-static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
41033+static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
41034+static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
41035
41036 static struct kobject *edac_pci_top_main_kobj;
41037 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
41038@@ -232,7 +232,7 @@ struct edac_pci_dev_attribute {
41039 void *value;
41040 ssize_t(*show) (void *, char *);
41041 ssize_t(*store) (void *, const char *, size_t);
41042-};
41043+} __do_const;
41044
41045 /* Set of show/store abstract level functions for PCI Parity object */
41046 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
41047@@ -576,7 +576,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41048 edac_printk(KERN_CRIT, EDAC_PCI,
41049 "Signaled System Error on %s\n",
41050 pci_name(dev));
41051- atomic_inc(&pci_nonparity_count);
41052+ atomic_inc_unchecked(&pci_nonparity_count);
41053 }
41054
41055 if (status & (PCI_STATUS_PARITY)) {
41056@@ -584,7 +584,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41057 "Master Data Parity Error on %s\n",
41058 pci_name(dev));
41059
41060- atomic_inc(&pci_parity_count);
41061+ atomic_inc_unchecked(&pci_parity_count);
41062 }
41063
41064 if (status & (PCI_STATUS_DETECTED_PARITY)) {
41065@@ -592,7 +592,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41066 "Detected Parity Error on %s\n",
41067 pci_name(dev));
41068
41069- atomic_inc(&pci_parity_count);
41070+ atomic_inc_unchecked(&pci_parity_count);
41071 }
41072 }
41073
41074@@ -615,7 +615,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41075 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
41076 "Signaled System Error on %s\n",
41077 pci_name(dev));
41078- atomic_inc(&pci_nonparity_count);
41079+ atomic_inc_unchecked(&pci_nonparity_count);
41080 }
41081
41082 if (status & (PCI_STATUS_PARITY)) {
41083@@ -623,7 +623,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41084 "Master Data Parity Error on "
41085 "%s\n", pci_name(dev));
41086
41087- atomic_inc(&pci_parity_count);
41088+ atomic_inc_unchecked(&pci_parity_count);
41089 }
41090
41091 if (status & (PCI_STATUS_DETECTED_PARITY)) {
41092@@ -631,7 +631,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41093 "Detected Parity Error on %s\n",
41094 pci_name(dev));
41095
41096- atomic_inc(&pci_parity_count);
41097+ atomic_inc_unchecked(&pci_parity_count);
41098 }
41099 }
41100 }
41101@@ -669,7 +669,7 @@ void edac_pci_do_parity_check(void)
41102 if (!check_pci_errors)
41103 return;
41104
41105- before_count = atomic_read(&pci_parity_count);
41106+ before_count = atomic_read_unchecked(&pci_parity_count);
41107
41108 /* scan all PCI devices looking for a Parity Error on devices and
41109 * bridges.
41110@@ -681,7 +681,7 @@ void edac_pci_do_parity_check(void)
41111 /* Only if operator has selected panic on PCI Error */
41112 if (edac_pci_get_panic_on_pe()) {
41113 /* If the count is different 'after' from 'before' */
41114- if (before_count != atomic_read(&pci_parity_count))
41115+ if (before_count != atomic_read_unchecked(&pci_parity_count))
41116 panic("EDAC: PCI Parity Error");
41117 }
41118 }
41119diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
41120index c2359a1..8bd119d 100644
41121--- a/drivers/edac/mce_amd.h
41122+++ b/drivers/edac/mce_amd.h
41123@@ -74,7 +74,7 @@ struct amd_decoder_ops {
41124 bool (*mc0_mce)(u16, u8);
41125 bool (*mc1_mce)(u16, u8);
41126 bool (*mc2_mce)(u16, u8);
41127-};
41128+} __no_const;
41129
41130 void amd_report_gart_errors(bool);
41131 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
41132diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
41133index 57ea7f4..af06b76 100644
41134--- a/drivers/firewire/core-card.c
41135+++ b/drivers/firewire/core-card.c
41136@@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
41137 const struct fw_card_driver *driver,
41138 struct device *device)
41139 {
41140- static atomic_t index = ATOMIC_INIT(-1);
41141+ static atomic_unchecked_t index = ATOMIC_INIT(-1);
41142
41143- card->index = atomic_inc_return(&index);
41144+ card->index = atomic_inc_return_unchecked(&index);
41145 card->driver = driver;
41146 card->device = device;
41147 card->current_tlabel = 0;
41148@@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
41149
41150 void fw_core_remove_card(struct fw_card *card)
41151 {
41152- struct fw_card_driver dummy_driver = dummy_driver_template;
41153+ fw_card_driver_no_const dummy_driver = dummy_driver_template;
41154
41155 card->driver->update_phy_reg(card, 4,
41156 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
41157diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
41158index f9e3aee..269dbdb 100644
41159--- a/drivers/firewire/core-device.c
41160+++ b/drivers/firewire/core-device.c
41161@@ -256,7 +256,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
41162 struct config_rom_attribute {
41163 struct device_attribute attr;
41164 u32 key;
41165-};
41166+} __do_const;
41167
41168 static ssize_t show_immediate(struct device *dev,
41169 struct device_attribute *dattr, char *buf)
41170diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
41171index d6a09b9..18e90dd 100644
41172--- a/drivers/firewire/core-transaction.c
41173+++ b/drivers/firewire/core-transaction.c
41174@@ -38,6 +38,7 @@
41175 #include <linux/timer.h>
41176 #include <linux/types.h>
41177 #include <linux/workqueue.h>
41178+#include <linux/sched.h>
41179
41180 #include <asm/byteorder.h>
41181
41182diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
41183index e1480ff6..1a429bd 100644
41184--- a/drivers/firewire/core.h
41185+++ b/drivers/firewire/core.h
41186@@ -111,6 +111,7 @@ struct fw_card_driver {
41187
41188 int (*stop_iso)(struct fw_iso_context *ctx);
41189 };
41190+typedef struct fw_card_driver __no_const fw_card_driver_no_const;
41191
41192 void fw_card_initialize(struct fw_card *card,
41193 const struct fw_card_driver *driver, struct device *device);
41194diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
41195index f51d376..b118e40 100644
41196--- a/drivers/firewire/ohci.c
41197+++ b/drivers/firewire/ohci.c
41198@@ -2049,10 +2049,12 @@ static void bus_reset_work(struct work_struct *work)
41199 be32_to_cpu(ohci->next_header));
41200 }
41201
41202+#ifndef CONFIG_GRKERNSEC
41203 if (param_remote_dma) {
41204 reg_write(ohci, OHCI1394_PhyReqFilterHiSet, ~0);
41205 reg_write(ohci, OHCI1394_PhyReqFilterLoSet, ~0);
41206 }
41207+#endif
41208
41209 spin_unlock_irq(&ohci->lock);
41210
41211@@ -2584,8 +2586,10 @@ static int ohci_enable_phys_dma(struct fw_card *card,
41212 unsigned long flags;
41213 int n, ret = 0;
41214
41215+#ifndef CONFIG_GRKERNSEC
41216 if (param_remote_dma)
41217 return 0;
41218+#endif
41219
41220 /*
41221 * FIXME: Make sure this bitmask is cleared when we clear the busReset
41222diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
41223index 94a58a0..f5eba42 100644
41224--- a/drivers/firmware/dmi-id.c
41225+++ b/drivers/firmware/dmi-id.c
41226@@ -16,7 +16,7 @@
41227 struct dmi_device_attribute{
41228 struct device_attribute dev_attr;
41229 int field;
41230-};
41231+} __do_const;
41232 #define to_dmi_dev_attr(_dev_attr) \
41233 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
41234
41235diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
41236index ac1ce4a..321745e 100644
41237--- a/drivers/firmware/dmi_scan.c
41238+++ b/drivers/firmware/dmi_scan.c
41239@@ -690,14 +690,18 @@ static int __init dmi_init(void)
41240 if (!dmi_table)
41241 goto err_tables;
41242
41243- bin_attr_smbios_entry_point.size = smbios_entry_point_size;
41244- bin_attr_smbios_entry_point.private = smbios_entry_point;
41245+ pax_open_kernel();
41246+ *(size_t *)&bin_attr_smbios_entry_point.size = smbios_entry_point_size;
41247+ *(void **)&bin_attr_smbios_entry_point.private = smbios_entry_point;
41248+ pax_close_kernel();
41249 ret = sysfs_create_bin_file(tables_kobj, &bin_attr_smbios_entry_point);
41250 if (ret)
41251 goto err_unmap;
41252
41253- bin_attr_DMI.size = dmi_len;
41254- bin_attr_DMI.private = dmi_table;
41255+ pax_open_kernel();
41256+ *(size_t *)&bin_attr_DMI.size = dmi_len;
41257+ *(void **)&bin_attr_DMI.private = dmi_table;
41258+ pax_close_kernel();
41259 ret = sysfs_create_bin_file(tables_kobj, &bin_attr_DMI);
41260 if (!ret)
41261 return 0;
41262diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
41263index d425374..1da1716 100644
41264--- a/drivers/firmware/efi/cper.c
41265+++ b/drivers/firmware/efi/cper.c
41266@@ -44,12 +44,12 @@ static char rcd_decode_str[CPER_REC_LEN];
41267 */
41268 u64 cper_next_record_id(void)
41269 {
41270- static atomic64_t seq;
41271+ static atomic64_unchecked_t seq;
41272
41273- if (!atomic64_read(&seq))
41274- atomic64_set(&seq, ((u64)get_seconds()) << 32);
41275+ if (!atomic64_read_unchecked(&seq))
41276+ atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
41277
41278- return atomic64_inc_return(&seq);
41279+ return atomic64_inc_return_unchecked(&seq);
41280 }
41281 EXPORT_SYMBOL_GPL(cper_next_record_id);
41282
41283diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
41284index d6144e3..23f9686 100644
41285--- a/drivers/firmware/efi/efi.c
41286+++ b/drivers/firmware/efi/efi.c
41287@@ -170,14 +170,16 @@ static struct attribute_group efi_subsys_attr_group = {
41288 };
41289
41290 static struct efivars generic_efivars;
41291-static struct efivar_operations generic_ops;
41292+static efivar_operations_no_const generic_ops __read_only;
41293
41294 static int generic_ops_register(void)
41295 {
41296- generic_ops.get_variable = efi.get_variable;
41297- generic_ops.set_variable = efi.set_variable;
41298- generic_ops.get_next_variable = efi.get_next_variable;
41299- generic_ops.query_variable_store = efi_query_variable_store;
41300+ pax_open_kernel();
41301+ *(void **)&generic_ops.get_variable = efi.get_variable;
41302+ *(void **)&generic_ops.set_variable = efi.set_variable;
41303+ *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
41304+ *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
41305+ pax_close_kernel();
41306
41307 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
41308 }
41309diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
41310index 756eca8..2336d08 100644
41311--- a/drivers/firmware/efi/efivars.c
41312+++ b/drivers/firmware/efi/efivars.c
41313@@ -590,7 +590,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
41314 static int
41315 create_efivars_bin_attributes(void)
41316 {
41317- struct bin_attribute *attr;
41318+ bin_attribute_no_const *attr;
41319 int error;
41320
41321 /* new_var */
41322diff --git a/drivers/firmware/efi/runtime-map.c b/drivers/firmware/efi/runtime-map.c
41323index 5c55227..97f4978 100644
41324--- a/drivers/firmware/efi/runtime-map.c
41325+++ b/drivers/firmware/efi/runtime-map.c
41326@@ -97,7 +97,7 @@ static void map_release(struct kobject *kobj)
41327 kfree(entry);
41328 }
41329
41330-static struct kobj_type __refdata map_ktype = {
41331+static const struct kobj_type __refconst map_ktype = {
41332 .sysfs_ops = &map_attr_ops,
41333 .default_attrs = def_attrs,
41334 .release = map_release,
41335diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
41336index f1ab05e..ab51228 100644
41337--- a/drivers/firmware/google/gsmi.c
41338+++ b/drivers/firmware/google/gsmi.c
41339@@ -709,7 +709,7 @@ static u32 __init hash_oem_table_id(char s[8])
41340 return local_hash_64(input, 32);
41341 }
41342
41343-static struct dmi_system_id gsmi_dmi_table[] __initdata = {
41344+static const struct dmi_system_id gsmi_dmi_table[] __initconst = {
41345 {
41346 .ident = "Google Board",
41347 .matches = {
41348diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
41349index 2f569aa..26e4f39 100644
41350--- a/drivers/firmware/google/memconsole.c
41351+++ b/drivers/firmware/google/memconsole.c
41352@@ -136,7 +136,7 @@ static bool __init found_memconsole(void)
41353 return false;
41354 }
41355
41356-static struct dmi_system_id memconsole_dmi_table[] __initdata = {
41357+static const struct dmi_system_id memconsole_dmi_table[] __initconst = {
41358 {
41359 .ident = "Google Board",
41360 .matches = {
41361@@ -155,7 +155,10 @@ static int __init memconsole_init(void)
41362 if (!found_memconsole())
41363 return -ENODEV;
41364
41365- memconsole_bin_attr.size = memconsole_length;
41366+ pax_open_kernel();
41367+ *(size_t *)&memconsole_bin_attr.size = memconsole_length;
41368+ pax_close_kernel();
41369+
41370 return sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
41371 }
41372
41373diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
41374index 5de3ed2..d839c56 100644
41375--- a/drivers/firmware/memmap.c
41376+++ b/drivers/firmware/memmap.c
41377@@ -124,7 +124,7 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
41378 kfree(entry);
41379 }
41380
41381-static struct kobj_type __refdata memmap_ktype = {
41382+static const struct kobj_type __refconst memmap_ktype = {
41383 .release = release_firmware_map_entry,
41384 .sysfs_ops = &memmap_attr_ops,
41385 .default_attrs = def_attrs,
41386diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
41387index c246ac3..6867ca6 100644
41388--- a/drivers/gpio/gpio-davinci.c
41389+++ b/drivers/gpio/gpio-davinci.c
41390@@ -442,9 +442,9 @@ static struct irq_chip *davinci_gpio_get_irq_chip(unsigned int irq)
41391 return &gpio_unbanked.chip;
41392 };
41393
41394-static struct irq_chip *keystone_gpio_get_irq_chip(unsigned int irq)
41395+static irq_chip_no_const *keystone_gpio_get_irq_chip(unsigned int irq)
41396 {
41397- static struct irq_chip gpio_unbanked;
41398+ static irq_chip_no_const gpio_unbanked;
41399
41400 gpio_unbanked = *irq_get_chip(irq);
41401 return &gpio_unbanked;
41402@@ -474,7 +474,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
41403 struct davinci_gpio_regs __iomem *g;
41404 struct irq_domain *irq_domain = NULL;
41405 const struct of_device_id *match;
41406- struct irq_chip *irq_chip;
41407+ irq_chip_no_const *irq_chip;
41408 gpio_get_irq_chip_cb_t gpio_get_irq_chip;
41409
41410 /*
41411diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c
41412index fbf2873..0a37114 100644
41413--- a/drivers/gpio/gpio-em.c
41414+++ b/drivers/gpio/gpio-em.c
41415@@ -278,7 +278,7 @@ static int em_gio_probe(struct platform_device *pdev)
41416 struct em_gio_priv *p;
41417 struct resource *io[2], *irq[2];
41418 struct gpio_chip *gpio_chip;
41419- struct irq_chip *irq_chip;
41420+ irq_chip_no_const *irq_chip;
41421 const char *name = dev_name(&pdev->dev);
41422 int ret;
41423
41424diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
41425index 4ba7ed5..1536b5d 100644
41426--- a/drivers/gpio/gpio-ich.c
41427+++ b/drivers/gpio/gpio-ich.c
41428@@ -94,7 +94,7 @@ struct ichx_desc {
41429 * this option allows driver caching written output values
41430 */
41431 bool use_outlvl_cache;
41432-};
41433+} __do_const;
41434
41435 static struct {
41436 spinlock_t lock;
41437diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
41438index 61a731f..d5ca6cb 100644
41439--- a/drivers/gpio/gpio-omap.c
41440+++ b/drivers/gpio/gpio-omap.c
41441@@ -1067,7 +1067,7 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
41442 dev_err(bank->dev, "Could not get gpio dbck\n");
41443 }
41444
41445-static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
41446+static int omap_gpio_chip_init(struct gpio_bank *bank, irq_chip_no_const *irqc)
41447 {
41448 static int gpio;
41449 int irq_base = 0;
41450@@ -1150,7 +1150,7 @@ static int omap_gpio_probe(struct platform_device *pdev)
41451 const struct omap_gpio_platform_data *pdata;
41452 struct resource *res;
41453 struct gpio_bank *bank;
41454- struct irq_chip *irqc;
41455+ irq_chip_no_const *irqc;
41456 int ret;
41457
41458 match = of_match_device(of_match_ptr(omap_gpio_match), dev);
41459diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
41460index 1e14a6c..0442450 100644
41461--- a/drivers/gpio/gpio-rcar.c
41462+++ b/drivers/gpio/gpio-rcar.c
41463@@ -379,7 +379,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
41464 struct gpio_rcar_priv *p;
41465 struct resource *io, *irq;
41466 struct gpio_chip *gpio_chip;
41467- struct irq_chip *irq_chip;
41468+ irq_chip_no_const *irq_chip;
41469 struct device *dev = &pdev->dev;
41470 const char *name = dev_name(dev);
41471 int ret;
41472diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
41473index c1caa45..f0f97d2 100644
41474--- a/drivers/gpio/gpio-vr41xx.c
41475+++ b/drivers/gpio/gpio-vr41xx.c
41476@@ -224,7 +224,7 @@ static int giu_get_irq(unsigned int irq)
41477 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
41478 maskl, pendl, maskh, pendh);
41479
41480- atomic_inc(&irq_err_count);
41481+ atomic_inc_unchecked(&irq_err_count);
41482
41483 return -EINVAL;
41484 }
41485diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
41486index bf4bd1d..51154a3 100644
41487--- a/drivers/gpio/gpiolib.c
41488+++ b/drivers/gpio/gpiolib.c
41489@@ -569,8 +569,10 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
41490 }
41491
41492 if (gpiochip->irqchip) {
41493- gpiochip->irqchip->irq_request_resources = NULL;
41494- gpiochip->irqchip->irq_release_resources = NULL;
41495+ pax_open_kernel();
41496+ *(void **)&gpiochip->irqchip->irq_request_resources = NULL;
41497+ *(void **)&gpiochip->irqchip->irq_release_resources = NULL;
41498+ pax_close_kernel();
41499 gpiochip->irqchip = NULL;
41500 }
41501 }
41502@@ -636,8 +638,11 @@ int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
41503 gpiochip->irqchip = NULL;
41504 return -EINVAL;
41505 }
41506- irqchip->irq_request_resources = gpiochip_irq_reqres;
41507- irqchip->irq_release_resources = gpiochip_irq_relres;
41508+
41509+ pax_open_kernel();
41510+ *(void **)&irqchip->irq_request_resources = gpiochip_irq_reqres;
41511+ *(void **)&irqchip->irq_release_resources = gpiochip_irq_relres;
41512+ pax_close_kernel();
41513
41514 /*
41515 * Prepare the mapping since the irqchip shall be orthogonal to
41516diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
41517index 99f158e..20b6c4c 100644
41518--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
41519+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
41520@@ -1071,7 +1071,7 @@ static bool amdgpu_switcheroo_can_switch(struct pci_dev *pdev)
41521 * locking inversion with the driver load path. And the access here is
41522 * completely racy anyway. So don't bother with locking for now.
41523 */
41524- return dev->open_count == 0;
41525+ return local_read(&dev->open_count) == 0;
41526 }
41527
41528 static const struct vga_switcheroo_client_ops amdgpu_switcheroo_ops = {
41529diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
41530index c991973..8eb176b 100644
41531--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
41532+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
41533@@ -419,7 +419,7 @@ static int kfd_ioctl_set_memory_policy(struct file *filep,
41534 (args->alternate_policy == KFD_IOC_CACHE_POLICY_COHERENT)
41535 ? cache_policy_coherent : cache_policy_noncoherent;
41536
41537- if (!dev->dqm->ops.set_cache_memory_policy(dev->dqm,
41538+ if (!dev->dqm->ops->set_cache_memory_policy(dev->dqm,
41539 &pdd->qpd,
41540 default_policy,
41541 alternate_policy,
41542diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
41543index 75312c8..e3684e6 100644
41544--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
41545+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
41546@@ -293,7 +293,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
41547 goto device_queue_manager_error;
41548 }
41549
41550- if (kfd->dqm->ops.start(kfd->dqm) != 0) {
41551+ if (kfd->dqm->ops->start(kfd->dqm) != 0) {
41552 dev_err(kfd_device,
41553 "Error starting queuen manager for device (%x:%x)\n",
41554 kfd->pdev->vendor, kfd->pdev->device);
41555@@ -349,7 +349,7 @@ void kgd2kfd_suspend(struct kfd_dev *kfd)
41556 BUG_ON(kfd == NULL);
41557
41558 if (kfd->init_complete) {
41559- kfd->dqm->ops.stop(kfd->dqm);
41560+ kfd->dqm->ops->stop(kfd->dqm);
41561 amd_iommu_set_invalidate_ctx_cb(kfd->pdev, NULL);
41562 amd_iommu_set_invalid_ppr_cb(kfd->pdev, NULL);
41563 amd_iommu_free_device(kfd->pdev);
41564@@ -372,7 +372,7 @@ int kgd2kfd_resume(struct kfd_dev *kfd)
41565 amd_iommu_set_invalidate_ctx_cb(kfd->pdev,
41566 iommu_pasid_shutdown_callback);
41567 amd_iommu_set_invalid_ppr_cb(kfd->pdev, iommu_invalid_ppr_cb);
41568- kfd->dqm->ops.start(kfd->dqm);
41569+ kfd->dqm->ops->start(kfd->dqm);
41570 }
41571
41572 return 0;
41573diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
41574index 4bb7f42..320fcac 100644
41575--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
41576+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
41577@@ -242,7 +242,7 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm,
41578
41579 BUG_ON(!dqm || !q || !qpd);
41580
41581- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41582+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41583 if (mqd == NULL)
41584 return -ENOMEM;
41585
41586@@ -288,14 +288,14 @@ static int destroy_queue_nocpsch(struct device_queue_manager *dqm,
41587 mutex_lock(&dqm->lock);
41588
41589 if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE) {
41590- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41591+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41592 if (mqd == NULL) {
41593 retval = -ENOMEM;
41594 goto out;
41595 }
41596 deallocate_hqd(dqm, q);
41597 } else if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
41598- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_SDMA);
41599+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_SDMA);
41600 if (mqd == NULL) {
41601 retval = -ENOMEM;
41602 goto out;
41603@@ -347,7 +347,7 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q)
41604 BUG_ON(!dqm || !q || !q->mqd);
41605
41606 mutex_lock(&dqm->lock);
41607- mqd = dqm->ops.get_mqd_manager(dqm,
41608+ mqd = dqm->ops->get_mqd_manager(dqm,
41609 get_mqd_type_from_queue_type(q->properties.type));
41610 if (mqd == NULL) {
41611 mutex_unlock(&dqm->lock);
41612@@ -414,7 +414,7 @@ static int register_process_nocpsch(struct device_queue_manager *dqm,
41613 mutex_lock(&dqm->lock);
41614 list_add(&n->list, &dqm->queues);
41615
41616- retval = dqm->ops_asic_specific.register_process(dqm, qpd);
41617+ retval = dqm->ops_asic_specific->register_process(dqm, qpd);
41618
41619 dqm->processes_count++;
41620
41621@@ -502,7 +502,7 @@ int init_pipelines(struct device_queue_manager *dqm,
41622
41623 memset(hpdptr, 0, CIK_HPD_EOP_BYTES * pipes_num);
41624
41625- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41626+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41627 if (mqd == NULL) {
41628 kfd_gtt_sa_free(dqm->dev, dqm->pipeline_mem);
41629 return -ENOMEM;
41630@@ -635,7 +635,7 @@ static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
41631 struct mqd_manager *mqd;
41632 int retval;
41633
41634- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_SDMA);
41635+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_SDMA);
41636 if (!mqd)
41637 return -ENOMEM;
41638
41639@@ -650,7 +650,7 @@ static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
41640 pr_debug(" sdma queue id: %d\n", q->properties.sdma_queue_id);
41641 pr_debug(" sdma engine id: %d\n", q->properties.sdma_engine_id);
41642
41643- dqm->ops_asic_specific.init_sdma_vm(dqm, q, qpd);
41644+ dqm->ops_asic_specific->init_sdma_vm(dqm, q, qpd);
41645 retval = mqd->init_mqd(mqd, &q->mqd, &q->mqd_mem_obj,
41646 &q->gart_mqd_addr, &q->properties);
41647 if (retval != 0) {
41648@@ -712,7 +712,7 @@ static int initialize_cpsch(struct device_queue_manager *dqm)
41649 dqm->queue_count = dqm->processes_count = 0;
41650 dqm->sdma_queue_count = 0;
41651 dqm->active_runlist = false;
41652- retval = dqm->ops_asic_specific.initialize(dqm);
41653+ retval = dqm->ops_asic_specific->initialize(dqm);
41654 if (retval != 0)
41655 goto fail_init_pipelines;
41656
41657@@ -879,7 +879,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
41658 if (q->properties.type == KFD_QUEUE_TYPE_SDMA)
41659 select_sdma_engine_id(q);
41660
41661- mqd = dqm->ops.get_mqd_manager(dqm,
41662+ mqd = dqm->ops->get_mqd_manager(dqm,
41663 get_mqd_type_from_queue_type(q->properties.type));
41664
41665 if (mqd == NULL) {
41666@@ -887,7 +887,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
41667 return -ENOMEM;
41668 }
41669
41670- dqm->ops_asic_specific.init_sdma_vm(dqm, q, qpd);
41671+ dqm->ops_asic_specific->init_sdma_vm(dqm, q, qpd);
41672 retval = mqd->init_mqd(mqd, &q->mqd, &q->mqd_mem_obj,
41673 &q->gart_mqd_addr, &q->properties);
41674 if (retval != 0)
41675@@ -1060,7 +1060,7 @@ static int destroy_queue_cpsch(struct device_queue_manager *dqm,
41676
41677 }
41678
41679- mqd = dqm->ops.get_mqd_manager(dqm,
41680+ mqd = dqm->ops->get_mqd_manager(dqm,
41681 get_mqd_type_from_queue_type(q->properties.type));
41682 if (!mqd) {
41683 retval = -ENOMEM;
41684@@ -1149,7 +1149,7 @@ static bool set_cache_memory_policy(struct device_queue_manager *dqm,
41685 qpd->sh_mem_ape1_limit = limit >> 16;
41686 }
41687
41688- retval = dqm->ops_asic_specific.set_cache_memory_policy(
41689+ retval = dqm->ops_asic_specific->set_cache_memory_policy(
41690 dqm,
41691 qpd,
41692 default_policy,
41693@@ -1172,6 +1172,36 @@ out:
41694 return false;
41695 }
41696
41697+static const struct device_queue_manager_ops cp_dqm_ops = {
41698+ .create_queue = create_queue_cpsch,
41699+ .initialize = initialize_cpsch,
41700+ .start = start_cpsch,
41701+ .stop = stop_cpsch,
41702+ .destroy_queue = destroy_queue_cpsch,
41703+ .update_queue = update_queue,
41704+ .get_mqd_manager = get_mqd_manager_nocpsch,
41705+ .register_process = register_process_nocpsch,
41706+ .unregister_process = unregister_process_nocpsch,
41707+ .uninitialize = uninitialize_nocpsch,
41708+ .create_kernel_queue = create_kernel_queue_cpsch,
41709+ .destroy_kernel_queue = destroy_kernel_queue_cpsch,
41710+ .set_cache_memory_policy = set_cache_memory_policy,
41711+};
41712+
41713+static const struct device_queue_manager_ops no_cp_dqm_ops = {
41714+ .start = start_nocpsch,
41715+ .stop = stop_nocpsch,
41716+ .create_queue = create_queue_nocpsch,
41717+ .destroy_queue = destroy_queue_nocpsch,
41718+ .update_queue = update_queue,
41719+ .get_mqd_manager = get_mqd_manager_nocpsch,
41720+ .register_process = register_process_nocpsch,
41721+ .unregister_process = unregister_process_nocpsch,
41722+ .initialize = initialize_nocpsch,
41723+ .uninitialize = uninitialize_nocpsch,
41724+ .set_cache_memory_policy = set_cache_memory_policy,
41725+};
41726+
41727 struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
41728 {
41729 struct device_queue_manager *dqm;
41730@@ -1189,33 +1219,11 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
41731 case KFD_SCHED_POLICY_HWS:
41732 case KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION:
41733 /* initialize dqm for cp scheduling */
41734- dqm->ops.create_queue = create_queue_cpsch;
41735- dqm->ops.initialize = initialize_cpsch;
41736- dqm->ops.start = start_cpsch;
41737- dqm->ops.stop = stop_cpsch;
41738- dqm->ops.destroy_queue = destroy_queue_cpsch;
41739- dqm->ops.update_queue = update_queue;
41740- dqm->ops.get_mqd_manager = get_mqd_manager_nocpsch;
41741- dqm->ops.register_process = register_process_nocpsch;
41742- dqm->ops.unregister_process = unregister_process_nocpsch;
41743- dqm->ops.uninitialize = uninitialize_nocpsch;
41744- dqm->ops.create_kernel_queue = create_kernel_queue_cpsch;
41745- dqm->ops.destroy_kernel_queue = destroy_kernel_queue_cpsch;
41746- dqm->ops.set_cache_memory_policy = set_cache_memory_policy;
41747+ dqm->ops = &cp_dqm_ops;
41748 break;
41749 case KFD_SCHED_POLICY_NO_HWS:
41750 /* initialize dqm for no cp scheduling */
41751- dqm->ops.start = start_nocpsch;
41752- dqm->ops.stop = stop_nocpsch;
41753- dqm->ops.create_queue = create_queue_nocpsch;
41754- dqm->ops.destroy_queue = destroy_queue_nocpsch;
41755- dqm->ops.update_queue = update_queue;
41756- dqm->ops.get_mqd_manager = get_mqd_manager_nocpsch;
41757- dqm->ops.register_process = register_process_nocpsch;
41758- dqm->ops.unregister_process = unregister_process_nocpsch;
41759- dqm->ops.initialize = initialize_nocpsch;
41760- dqm->ops.uninitialize = uninitialize_nocpsch;
41761- dqm->ops.set_cache_memory_policy = set_cache_memory_policy;
41762+ dqm->ops = &no_cp_dqm_ops;
41763 break;
41764 default:
41765 BUG();
41766@@ -1224,15 +1232,15 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
41767
41768 switch (dev->device_info->asic_family) {
41769 case CHIP_CARRIZO:
41770- device_queue_manager_init_vi(&dqm->ops_asic_specific);
41771+ device_queue_manager_init_vi(dqm);
41772 break;
41773
41774 case CHIP_KAVERI:
41775- device_queue_manager_init_cik(&dqm->ops_asic_specific);
41776+ device_queue_manager_init_cik(dqm);
41777 break;
41778 }
41779
41780- if (dqm->ops.initialize(dqm) != 0) {
41781+ if (dqm->ops->initialize(dqm) != 0) {
41782 kfree(dqm);
41783 return NULL;
41784 }
41785@@ -1244,6 +1252,6 @@ void device_queue_manager_uninit(struct device_queue_manager *dqm)
41786 {
41787 BUG_ON(!dqm);
41788
41789- dqm->ops.uninitialize(dqm);
41790+ dqm->ops->uninitialize(dqm);
41791 kfree(dqm);
41792 }
41793diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
41794index ec4036a..3ef0646 100644
41795--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
41796+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
41797@@ -154,8 +154,8 @@ struct device_queue_manager_asic_ops {
41798 */
41799
41800 struct device_queue_manager {
41801- struct device_queue_manager_ops ops;
41802- struct device_queue_manager_asic_ops ops_asic_specific;
41803+ struct device_queue_manager_ops *ops;
41804+ struct device_queue_manager_asic_ops *ops_asic_specific;
41805
41806 struct mqd_manager *mqds[KFD_MQD_TYPE_MAX];
41807 struct packet_manager packets;
41808@@ -178,8 +178,8 @@ struct device_queue_manager {
41809 bool active_runlist;
41810 };
41811
41812-void device_queue_manager_init_cik(struct device_queue_manager_asic_ops *ops);
41813-void device_queue_manager_init_vi(struct device_queue_manager_asic_ops *ops);
41814+void device_queue_manager_init_cik(struct device_queue_manager *dqm);
41815+void device_queue_manager_init_vi(struct device_queue_manager *dqm);
41816 void program_sh_mem_settings(struct device_queue_manager *dqm,
41817 struct qcm_process_device *qpd);
41818 int init_pipelines(struct device_queue_manager *dqm,
41819diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c
41820index 9ce8a20..1ca4e22 100644
41821--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c
41822+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c
41823@@ -36,12 +36,16 @@ static int initialize_cpsch_cik(struct device_queue_manager *dqm);
41824 static void init_sdma_vm(struct device_queue_manager *dqm, struct queue *q,
41825 struct qcm_process_device *qpd);
41826
41827-void device_queue_manager_init_cik(struct device_queue_manager_asic_ops *ops)
41828+static const struct device_queue_manager_asic_ops cik_dqm_asic_ops = {
41829+ .set_cache_memory_policy = set_cache_memory_policy_cik,
41830+ .register_process = register_process_cik,
41831+ .initialize = initialize_cpsch_cik,
41832+ .init_sdma_vm = init_sdma_vm,
41833+};
41834+
41835+void device_queue_manager_init_cik(struct device_queue_manager *dqm)
41836 {
41837- ops->set_cache_memory_policy = set_cache_memory_policy_cik;
41838- ops->register_process = register_process_cik;
41839- ops->initialize = initialize_cpsch_cik;
41840- ops->init_sdma_vm = init_sdma_vm;
41841+ dqm->ops_asic_specific = &cik_dqm_asic_ops;
41842 }
41843
41844 static uint32_t compute_sh_mem_bases_64bit(unsigned int top_address_nybble)
41845diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c
41846index 4c15212..61bfab8 100644
41847--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c
41848+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c
41849@@ -35,14 +35,18 @@ static int initialize_cpsch_vi(struct device_queue_manager *dqm);
41850 static void init_sdma_vm(struct device_queue_manager *dqm, struct queue *q,
41851 struct qcm_process_device *qpd);
41852
41853-void device_queue_manager_init_vi(struct device_queue_manager_asic_ops *ops)
41854+static const struct device_queue_manager_asic_ops vi_dqm_asic_ops = {
41855+ .set_cache_memory_policy = set_cache_memory_policy_vi,
41856+ .register_process = register_process_vi,
41857+ .initialize = initialize_cpsch_vi,
41858+ .init_sdma_vm = init_sdma_vm,
41859+};
41860+
41861+void device_queue_manager_init_vi(struct device_queue_manager *dqm)
41862 {
41863 pr_warn("amdkfd: VI DQM is not currently supported\n");
41864
41865- ops->set_cache_memory_policy = set_cache_memory_policy_vi;
41866- ops->register_process = register_process_vi;
41867- ops->initialize = initialize_cpsch_vi;
41868- ops->init_sdma_vm = init_sdma_vm;
41869+ dqm->ops_asic_specific = &vi_dqm_asic_ops;
41870 }
41871
41872 static bool set_cache_memory_policy_vi(struct device_queue_manager *dqm,
41873diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
41874index 7f134aa..cd34d4a 100644
41875--- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
41876+++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
41877@@ -50,8 +50,8 @@ static void interrupt_wq(struct work_struct *);
41878
41879 int kfd_interrupt_init(struct kfd_dev *kfd)
41880 {
41881- void *interrupt_ring = kmalloc_array(KFD_INTERRUPT_RING_SIZE,
41882- kfd->device_info->ih_ring_entry_size,
41883+ void *interrupt_ring = kmalloc_array(kfd->device_info->ih_ring_entry_size,
41884+ KFD_INTERRUPT_RING_SIZE,
41885 GFP_KERNEL);
41886 if (!interrupt_ring)
41887 return -ENOMEM;
41888diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
41889index 8fa8941..5ae07df 100644
41890--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
41891+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
41892@@ -56,7 +56,7 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
41893 switch (type) {
41894 case KFD_QUEUE_TYPE_DIQ:
41895 case KFD_QUEUE_TYPE_HIQ:
41896- kq->mqd = dev->dqm->ops.get_mqd_manager(dev->dqm,
41897+ kq->mqd = dev->dqm->ops->get_mqd_manager(dev->dqm,
41898 KFD_MQD_TYPE_HIQ);
41899 break;
41900 default:
41901diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
41902index 5940531..a75b0e5 100644
41903--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
41904+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
41905@@ -62,7 +62,7 @@ struct kernel_queue_ops {
41906
41907 void (*submit_packet)(struct kernel_queue *kq);
41908 void (*rollback_packet)(struct kernel_queue *kq);
41909-};
41910+} __no_const;
41911
41912 struct kernel_queue {
41913 struct kernel_queue_ops ops;
41914diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
41915index 7b69070..d7bd78b 100644
41916--- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
41917+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
41918@@ -194,7 +194,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
41919
41920 if (list_empty(&pqm->queues)) {
41921 pdd->qpd.pqm = pqm;
41922- dev->dqm->ops.register_process(dev->dqm, &pdd->qpd);
41923+ dev->dqm->ops->register_process(dev->dqm, &pdd->qpd);
41924 }
41925
41926 pqn = kzalloc(sizeof(struct process_queue_node), GFP_KERNEL);
41927@@ -220,7 +220,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
41928 goto err_create_queue;
41929 pqn->q = q;
41930 pqn->kq = NULL;
41931- retval = dev->dqm->ops.create_queue(dev->dqm, q, &pdd->qpd,
41932+ retval = dev->dqm->ops->create_queue(dev->dqm, q, &pdd->qpd,
41933 &q->properties.vmid);
41934 pr_debug("DQM returned %d for create_queue\n", retval);
41935 print_queue(q);
41936@@ -234,7 +234,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
41937 kq->queue->properties.queue_id = *qid;
41938 pqn->kq = kq;
41939 pqn->q = NULL;
41940- retval = dev->dqm->ops.create_kernel_queue(dev->dqm,
41941+ retval = dev->dqm->ops->create_kernel_queue(dev->dqm,
41942 kq, &pdd->qpd);
41943 break;
41944 default:
41945@@ -265,7 +265,7 @@ err_allocate_pqn:
41946 /* check if queues list is empty unregister process from device */
41947 clear_bit(*qid, pqm->queue_slot_bitmap);
41948 if (list_empty(&pqm->queues))
41949- dev->dqm->ops.unregister_process(dev->dqm, &pdd->qpd);
41950+ dev->dqm->ops->unregister_process(dev->dqm, &pdd->qpd);
41951 return retval;
41952 }
41953
41954@@ -306,13 +306,13 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
41955 if (pqn->kq) {
41956 /* destroy kernel queue (DIQ) */
41957 dqm = pqn->kq->dev->dqm;
41958- dqm->ops.destroy_kernel_queue(dqm, pqn->kq, &pdd->qpd);
41959+ dqm->ops->destroy_kernel_queue(dqm, pqn->kq, &pdd->qpd);
41960 kernel_queue_uninit(pqn->kq);
41961 }
41962
41963 if (pqn->q) {
41964 dqm = pqn->q->device->dqm;
41965- retval = dqm->ops.destroy_queue(dqm, &pdd->qpd, pqn->q);
41966+ retval = dqm->ops->destroy_queue(dqm, &pdd->qpd, pqn->q);
41967 if (retval != 0)
41968 return retval;
41969
41970@@ -324,7 +324,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
41971 clear_bit(qid, pqm->queue_slot_bitmap);
41972
41973 if (list_empty(&pqm->queues))
41974- dqm->ops.unregister_process(dqm, &pdd->qpd);
41975+ dqm->ops->unregister_process(dqm, &pdd->qpd);
41976
41977 return retval;
41978 }
41979@@ -349,7 +349,7 @@ int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid,
41980 pqn->q->properties.queue_percent = p->queue_percent;
41981 pqn->q->properties.priority = p->priority;
41982
41983- retval = pqn->q->device->dqm->ops.update_queue(pqn->q->device->dqm,
41984+ retval = pqn->q->device->dqm->ops->update_queue(pqn->q->device->dqm,
41985 pqn->q);
41986 if (retval != 0)
41987 return retval;
41988diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
41989index 9b23525..65f4110 100644
41990--- a/drivers/gpu/drm/drm_context.c
41991+++ b/drivers/gpu/drm/drm_context.c
41992@@ -53,6 +53,9 @@ struct drm_ctx_list {
41993 */
41994 void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
41995 {
41996+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41997+ return;
41998+
41999 mutex_lock(&dev->struct_mutex);
42000 idr_remove(&dev->ctx_idr, ctx_handle);
42001 mutex_unlock(&dev->struct_mutex);
42002@@ -87,6 +90,9 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
42003 */
42004 int drm_legacy_ctxbitmap_init(struct drm_device * dev)
42005 {
42006+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42007+ return -EINVAL;
42008+
42009 idr_init(&dev->ctx_idr);
42010 return 0;
42011 }
42012@@ -101,6 +107,9 @@ int drm_legacy_ctxbitmap_init(struct drm_device * dev)
42013 */
42014 void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
42015 {
42016+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42017+ return;
42018+
42019 mutex_lock(&dev->struct_mutex);
42020 idr_destroy(&dev->ctx_idr);
42021 mutex_unlock(&dev->struct_mutex);
42022@@ -119,11 +128,14 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
42023 {
42024 struct drm_ctx_list *pos, *tmp;
42025
42026+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42027+ return;
42028+
42029 mutex_lock(&dev->ctxlist_mutex);
42030
42031 list_for_each_entry_safe(pos, tmp, &dev->ctxlist, head) {
42032 if (pos->tag == file &&
42033- pos->handle != DRM_KERNEL_CONTEXT) {
42034+ _DRM_LOCKING_CONTEXT(pos->handle) != DRM_KERNEL_CONTEXT) {
42035 if (dev->driver->context_dtor)
42036 dev->driver->context_dtor(dev, pos->handle);
42037
42038@@ -161,6 +173,9 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
42039 struct drm_local_map *map;
42040 struct drm_map_list *_entry;
42041
42042+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42043+ return -EINVAL;
42044+
42045 mutex_lock(&dev->struct_mutex);
42046
42047 map = idr_find(&dev->ctx_idr, request->ctx_id);
42048@@ -205,6 +220,9 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
42049 struct drm_local_map *map = NULL;
42050 struct drm_map_list *r_list = NULL;
42051
42052+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42053+ return -EINVAL;
42054+
42055 mutex_lock(&dev->struct_mutex);
42056 list_for_each_entry(r_list, &dev->maplist, head) {
42057 if (r_list->map
42058@@ -277,7 +295,13 @@ static int drm_context_switch_complete(struct drm_device *dev,
42059 {
42060 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
42061
42062- if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) {
42063+ if (file_priv->master->lock.hw_lock == NULL) {
42064+ DRM_ERROR(
42065+ "Device has been unregistered. Hard exit. Process %d\n",
42066+ task_pid_nr(current));
42067+ send_sig(SIGTERM, current, 0);
42068+ return -EPERM;
42069+ } else if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) {
42070 DRM_ERROR("Lock isn't held after context switch\n");
42071 }
42072
42073@@ -305,6 +329,9 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
42074 struct drm_ctx ctx;
42075 int i;
42076
42077+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42078+ return -EINVAL;
42079+
42080 if (res->count >= DRM_RESERVED_CONTEXTS) {
42081 memset(&ctx, 0, sizeof(ctx));
42082 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
42083@@ -335,8 +362,11 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
42084 struct drm_ctx_list *ctx_entry;
42085 struct drm_ctx *ctx = data;
42086
42087+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42088+ return -EINVAL;
42089+
42090 ctx->handle = drm_legacy_ctxbitmap_next(dev);
42091- if (ctx->handle == DRM_KERNEL_CONTEXT) {
42092+ if (_DRM_LOCKING_CONTEXT(ctx->handle) == DRM_KERNEL_CONTEXT) {
42093 /* Skip kernel's context and get a new one. */
42094 ctx->handle = drm_legacy_ctxbitmap_next(dev);
42095 }
42096@@ -378,6 +408,9 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
42097 {
42098 struct drm_ctx *ctx = data;
42099
42100+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42101+ return -EINVAL;
42102+
42103 /* This is 0, because we don't handle any context flags */
42104 ctx->flags = 0;
42105
42106@@ -400,6 +433,9 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
42107 {
42108 struct drm_ctx *ctx = data;
42109
42110+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42111+ return -EINVAL;
42112+
42113 DRM_DEBUG("%d\n", ctx->handle);
42114 return drm_context_switch(dev, dev->last_context, ctx->handle);
42115 }
42116@@ -420,6 +456,9 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
42117 {
42118 struct drm_ctx *ctx = data;
42119
42120+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42121+ return -EINVAL;
42122+
42123 DRM_DEBUG("%d\n", ctx->handle);
42124 drm_context_switch_complete(dev, file_priv, ctx->handle);
42125
42126@@ -442,8 +481,11 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
42127 {
42128 struct drm_ctx *ctx = data;
42129
42130+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42131+ return -EINVAL;
42132+
42133 DRM_DEBUG("%d\n", ctx->handle);
42134- if (ctx->handle != DRM_KERNEL_CONTEXT) {
42135+ if (_DRM_LOCKING_CONTEXT(ctx->handle) != DRM_KERNEL_CONTEXT) {
42136 if (dev->driver->context_dtor)
42137 dev->driver->context_dtor(dev, ctx->handle);
42138 drm_legacy_ctxbitmap_free(dev, ctx->handle);
42139diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
42140index fed7483..5bc0335 100644
42141--- a/drivers/gpu/drm/drm_crtc.c
42142+++ b/drivers/gpu/drm/drm_crtc.c
42143@@ -4174,7 +4174,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
42144 goto done;
42145 }
42146
42147- if (copy_to_user(&enum_ptr[copied].name,
42148+ if (copy_to_user(enum_ptr[copied].name,
42149 &prop_enum->name, DRM_PROP_NAME_LEN)) {
42150 ret = -EFAULT;
42151 goto done;
42152diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
42153index b7bf4ce..585cf3b 100644
42154--- a/drivers/gpu/drm/drm_drv.c
42155+++ b/drivers/gpu/drm/drm_drv.c
42156@@ -434,7 +434,7 @@ void drm_unplug_dev(struct drm_device *dev)
42157
42158 drm_device_set_unplugged(dev);
42159
42160- if (dev->open_count == 0) {
42161+ if (local_read(&dev->open_count) == 0) {
42162 drm_put_dev(dev);
42163 }
42164 mutex_unlock(&drm_global_mutex);
42165@@ -582,10 +582,13 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
42166 if (drm_ht_create(&dev->map_hash, 12))
42167 goto err_minors;
42168
42169- ret = drm_legacy_ctxbitmap_init(dev);
42170- if (ret) {
42171- DRM_ERROR("Cannot allocate memory for context bitmap.\n");
42172- goto err_ht;
42173+ if (drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT)) {
42174+ ret = drm_legacy_ctxbitmap_init(dev);
42175+ if (ret) {
42176+ DRM_ERROR(
42177+ "Cannot allocate memory for context bitmap.\n");
42178+ goto err_ht;
42179+ }
42180 }
42181
42182 if (drm_core_check_feature(dev, DRIVER_GEM)) {
42183diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
42184index c59ce4d..056d413 100644
42185--- a/drivers/gpu/drm/drm_fops.c
42186+++ b/drivers/gpu/drm/drm_fops.c
42187@@ -89,7 +89,7 @@ int drm_open(struct inode *inode, struct file *filp)
42188 return PTR_ERR(minor);
42189
42190 dev = minor->dev;
42191- if (!dev->open_count++)
42192+ if (local_inc_return(&dev->open_count) == 1)
42193 need_setup = 1;
42194
42195 /* share address_space across all char-devs of a single device */
42196@@ -106,7 +106,7 @@ int drm_open(struct inode *inode, struct file *filp)
42197 return 0;
42198
42199 err_undo:
42200- dev->open_count--;
42201+ local_dec(&dev->open_count);
42202 drm_minor_release(minor);
42203 return retcode;
42204 }
42205@@ -377,7 +377,7 @@ int drm_release(struct inode *inode, struct file *filp)
42206
42207 mutex_lock(&drm_global_mutex);
42208
42209- DRM_DEBUG("open_count = %d\n", dev->open_count);
42210+ DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
42211
42212 mutex_lock(&dev->struct_mutex);
42213 list_del(&file_priv->lhead);
42214@@ -392,10 +392,10 @@ int drm_release(struct inode *inode, struct file *filp)
42215 * Begin inline drm_release
42216 */
42217
42218- DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
42219+ DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
42220 task_pid_nr(current),
42221 (long)old_encode_dev(file_priv->minor->kdev->devt),
42222- dev->open_count);
42223+ local_read(&dev->open_count));
42224
42225 /* if the master has gone away we can't do anything with the lock */
42226 if (file_priv->minor->master)
42227@@ -465,7 +465,7 @@ int drm_release(struct inode *inode, struct file *filp)
42228 * End inline drm_release
42229 */
42230
42231- if (!--dev->open_count) {
42232+ if (local_dec_and_test(&dev->open_count)) {
42233 retcode = drm_lastclose(dev);
42234 if (drm_device_is_unplugged(dev))
42235 drm_put_dev(dev);
42236diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
42237index 3d2e91c..d31c4c9 100644
42238--- a/drivers/gpu/drm/drm_global.c
42239+++ b/drivers/gpu/drm/drm_global.c
42240@@ -36,7 +36,7 @@
42241 struct drm_global_item {
42242 struct mutex mutex;
42243 void *object;
42244- int refcount;
42245+ atomic_t refcount;
42246 };
42247
42248 static struct drm_global_item glob[DRM_GLOBAL_NUM];
42249@@ -49,7 +49,7 @@ void drm_global_init(void)
42250 struct drm_global_item *item = &glob[i];
42251 mutex_init(&item->mutex);
42252 item->object = NULL;
42253- item->refcount = 0;
42254+ atomic_set(&item->refcount, 0);
42255 }
42256 }
42257
42258@@ -59,7 +59,7 @@ void drm_global_release(void)
42259 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
42260 struct drm_global_item *item = &glob[i];
42261 BUG_ON(item->object != NULL);
42262- BUG_ON(item->refcount != 0);
42263+ BUG_ON(atomic_read(&item->refcount) != 0);
42264 }
42265 }
42266
42267@@ -69,7 +69,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
42268 struct drm_global_item *item = &glob[ref->global_type];
42269
42270 mutex_lock(&item->mutex);
42271- if (item->refcount == 0) {
42272+ if (atomic_read(&item->refcount) == 0) {
42273 item->object = kzalloc(ref->size, GFP_KERNEL);
42274 if (unlikely(item->object == NULL)) {
42275 ret = -ENOMEM;
42276@@ -82,7 +82,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
42277 goto out_err;
42278
42279 }
42280- ++item->refcount;
42281+ atomic_inc(&item->refcount);
42282 ref->object = item->object;
42283 mutex_unlock(&item->mutex);
42284 return 0;
42285@@ -98,9 +98,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
42286 struct drm_global_item *item = &glob[ref->global_type];
42287
42288 mutex_lock(&item->mutex);
42289- BUG_ON(item->refcount == 0);
42290+ BUG_ON(atomic_read(&item->refcount) == 0);
42291 BUG_ON(ref->object != item->object);
42292- if (--item->refcount == 0) {
42293+ if (atomic_dec_and_test(&item->refcount)) {
42294 ref->release(ref);
42295 item->object = NULL;
42296 }
42297diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
42298index cbb4fc0..5c756cb9 100644
42299--- a/drivers/gpu/drm/drm_info.c
42300+++ b/drivers/gpu/drm/drm_info.c
42301@@ -77,10 +77,13 @@ int drm_vm_info(struct seq_file *m, void *data)
42302 struct drm_local_map *map;
42303 struct drm_map_list *r_list;
42304
42305- /* Hardcoded from _DRM_FRAME_BUFFER,
42306- _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
42307- _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
42308- const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
42309+ static const char * const types[] = {
42310+ [_DRM_FRAME_BUFFER] = "FB",
42311+ [_DRM_REGISTERS] = "REG",
42312+ [_DRM_SHM] = "SHM",
42313+ [_DRM_AGP] = "AGP",
42314+ [_DRM_SCATTER_GATHER] = "SG",
42315+ [_DRM_CONSISTENT] = "PCI"};
42316 const char *type;
42317 int i;
42318
42319@@ -91,7 +94,7 @@ int drm_vm_info(struct seq_file *m, void *data)
42320 map = r_list->map;
42321 if (!map)
42322 continue;
42323- if (map->type < 0 || map->type > 5)
42324+ if (map->type >= ARRAY_SIZE(types))
42325 type = "??";
42326 else
42327 type = types[map->type];
42328diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
42329index 9cfcd0a..7142a7f 100644
42330--- a/drivers/gpu/drm/drm_ioc32.c
42331+++ b/drivers/gpu/drm/drm_ioc32.c
42332@@ -459,7 +459,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
42333 request = compat_alloc_user_space(nbytes);
42334 if (!access_ok(VERIFY_WRITE, request, nbytes))
42335 return -EFAULT;
42336- list = (struct drm_buf_desc *) (request + 1);
42337+ list = (struct drm_buf_desc __user *) (request + 1);
42338
42339 if (__put_user(count, &request->count)
42340 || __put_user(list, &request->list))
42341@@ -520,7 +520,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
42342 request = compat_alloc_user_space(nbytes);
42343 if (!access_ok(VERIFY_WRITE, request, nbytes))
42344 return -EFAULT;
42345- list = (struct drm_buf_pub *) (request + 1);
42346+ list = (struct drm_buf_pub __user *) (request + 1);
42347
42348 if (__put_user(count, &request->count)
42349 || __put_user(list, &request->list))
42350@@ -1075,7 +1075,7 @@ static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
42351 return 0;
42352 }
42353
42354-static drm_ioctl_compat_t *drm_compat_ioctls[] = {
42355+static drm_ioctl_compat_t drm_compat_ioctls[] = {
42356 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
42357 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
42358 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
42359@@ -1122,7 +1122,6 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = {
42360 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42361 {
42362 unsigned int nr = DRM_IOCTL_NR(cmd);
42363- drm_ioctl_compat_t *fn;
42364 int ret;
42365
42366 /* Assume that ioctls without an explicit compat routine will just
42367@@ -1132,10 +1131,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42368 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
42369 return drm_ioctl(filp, cmd, arg);
42370
42371- fn = drm_compat_ioctls[nr];
42372-
42373- if (fn != NULL)
42374- ret = (*fn) (filp, cmd, arg);
42375+ if (drm_compat_ioctls[nr] != NULL)
42376+ ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
42377 else
42378 ret = drm_ioctl(filp, cmd, arg);
42379
42380diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
42381index b1d303f..c59012c 100644
42382--- a/drivers/gpu/drm/drm_ioctl.c
42383+++ b/drivers/gpu/drm/drm_ioctl.c
42384@@ -650,7 +650,7 @@ long drm_ioctl(struct file *filp,
42385 struct drm_file *file_priv = filp->private_data;
42386 struct drm_device *dev;
42387 const struct drm_ioctl_desc *ioctl = NULL;
42388- drm_ioctl_t *func;
42389+ drm_ioctl_no_const_t func;
42390 unsigned int nr = DRM_IOCTL_NR(cmd);
42391 int retcode = -EINVAL;
42392 char stack_kdata[128];
42393diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
42394index 4924d381..fd3b5ee 100644
42395--- a/drivers/gpu/drm/drm_lock.c
42396+++ b/drivers/gpu/drm/drm_lock.c
42397@@ -61,12 +61,15 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
42398 struct drm_master *master = file_priv->master;
42399 int ret = 0;
42400
42401+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42402+ return -EINVAL;
42403+
42404 if (drm_core_check_feature(dev, DRIVER_MODESET))
42405 return -EINVAL;
42406
42407 ++file_priv->lock_count;
42408
42409- if (lock->context == DRM_KERNEL_CONTEXT) {
42410+ if (_DRM_LOCKING_CONTEXT(lock->context) == DRM_KERNEL_CONTEXT) {
42411 DRM_ERROR("Process %d using kernel context %d\n",
42412 task_pid_nr(current), lock->context);
42413 return -EINVAL;
42414@@ -156,6 +159,9 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
42415 struct drm_lock *lock = data;
42416 struct drm_master *master = file_priv->master;
42417
42418+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42419+ return -EINVAL;
42420+
42421 if (drm_core_check_feature(dev, DRIVER_MODESET))
42422 return -EINVAL;
42423
42424@@ -165,6 +171,14 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
42425 return -EINVAL;
42426 }
42427
42428+ if (!master->lock.hw_lock) {
42429+ DRM_ERROR(
42430+ "Device has been unregistered. Hard exit. Process %d\n",
42431+ task_pid_nr(current));
42432+ send_sig(SIGTERM, current, 0);
42433+ return -EPERM;
42434+ }
42435+
42436 if (drm_legacy_lock_free(&master->lock, lock->context)) {
42437 /* FIXME: Should really bail out here. */
42438 }
42439diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
42440index d4813e0..6c1ab4d 100644
42441--- a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
42442+++ b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
42443@@ -825,10 +825,16 @@ void mdfld_dsi_dpi_mode_set(struct drm_encoder *encoder,
42444 u32 pipeconf_reg = PIPEACONF;
42445 u32 dspcntr_reg = DSPACNTR;
42446
42447- u32 pipeconf = dev_priv->pipeconf[pipe];
42448- u32 dspcntr = dev_priv->dspcntr[pipe];
42449+ u32 pipeconf;
42450+ u32 dspcntr;
42451 u32 mipi = MIPI_PORT_EN | PASS_FROM_SPHY_TO_AFE | SEL_FLOPPED_HSTX;
42452
42453+ if (pipe == -1)
42454+ return;
42455+
42456+ pipeconf = dev_priv->pipeconf[pipe];
42457+ dspcntr = dev_priv->dspcntr[pipe];
42458+
42459 if (pipe) {
42460 pipeconf_reg = PIPECCONF;
42461 dspcntr_reg = DSPCCNTR;
42462diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
42463index 93ec5dc..82acbaf 100644
42464--- a/drivers/gpu/drm/i810/i810_drv.h
42465+++ b/drivers/gpu/drm/i810/i810_drv.h
42466@@ -110,8 +110,8 @@ typedef struct drm_i810_private {
42467 int page_flipping;
42468
42469 wait_queue_head_t irq_queue;
42470- atomic_t irq_received;
42471- atomic_t irq_emitted;
42472+ atomic_unchecked_t irq_received;
42473+ atomic_unchecked_t irq_emitted;
42474
42475 int front_offset;
42476 } drm_i810_private_t;
42477diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
42478index 82bbe3f..ce004bf 100644
42479--- a/drivers/gpu/drm/i915/i915_debugfs.c
42480+++ b/drivers/gpu/drm/i915/i915_debugfs.c
42481@@ -480,7 +480,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
42482 seq_printf(m, "%u fault mappable objects, %zu bytes\n",
42483 count, size);
42484
42485- seq_printf(m, "%zu [%lu] gtt total\n",
42486+ seq_printf(m, "%llu [%llu] gtt total\n",
42487 dev_priv->gtt.base.total,
42488 dev_priv->gtt.mappable_end - dev_priv->gtt.base.start);
42489
42490diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
42491index d2df321..f746478 100644
42492--- a/drivers/gpu/drm/i915/i915_dma.c
42493+++ b/drivers/gpu/drm/i915/i915_dma.c
42494@@ -162,6 +162,8 @@ static int i915_getparam(struct drm_device *dev, void *data,
42495 value = INTEL_INFO(dev)->eu_total;
42496 if (!value)
42497 return -ENODEV;
42498+ case I915_PARAM_HAS_LEGACY_CONTEXT:
42499+ value = drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT);
42500 break;
42501 default:
42502 DRM_DEBUG("Unknown parameter %d\n", param->param);
42503@@ -376,7 +378,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
42504 * locking inversion with the driver load path. And the access here is
42505 * completely racy anyway. So don't bother with locking for now.
42506 */
42507- return dev->open_count == 0;
42508+ return local_read(&dev->open_count) == 0;
42509 }
42510
42511 static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {
42512diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
42513index 5e6b4a2..6ba2c85 100644
42514--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
42515+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
42516@@ -935,12 +935,12 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
42517 static int
42518 validate_exec_list(struct drm_device *dev,
42519 struct drm_i915_gem_exec_object2 *exec,
42520- int count)
42521+ unsigned int count)
42522 {
42523 unsigned relocs_total = 0;
42524 unsigned relocs_max = UINT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
42525 unsigned invalid_flags;
42526- int i;
42527+ unsigned int i;
42528
42529 invalid_flags = __EXEC_OBJECT_UNKNOWN_FLAGS;
42530 if (USES_FULL_PPGTT(dev))
42531diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
42532index 31e8269..7055934 100644
42533--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
42534+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
42535@@ -2360,10 +2360,10 @@ static void chv_setup_private_ppat(struct drm_i915_private *dev_priv)
42536 }
42537
42538 static int gen8_gmch_probe(struct drm_device *dev,
42539- size_t *gtt_total,
42540- size_t *stolen,
42541- phys_addr_t *mappable_base,
42542- unsigned long *mappable_end)
42543+ uint64_t *gtt_total,
42544+ uint64_t *stolen,
42545+ uint64_t *mappable_base,
42546+ uint64_t *mappable_end)
42547 {
42548 struct drm_i915_private *dev_priv = dev->dev_private;
42549 unsigned int gtt_size;
42550@@ -2408,10 +2408,10 @@ static int gen8_gmch_probe(struct drm_device *dev,
42551 }
42552
42553 static int gen6_gmch_probe(struct drm_device *dev,
42554- size_t *gtt_total,
42555- size_t *stolen,
42556- phys_addr_t *mappable_base,
42557- unsigned long *mappable_end)
42558+ uint64_t *gtt_total,
42559+ uint64_t *stolen,
42560+ uint64_t *mappable_base,
42561+ uint64_t *mappable_end)
42562 {
42563 struct drm_i915_private *dev_priv = dev->dev_private;
42564 unsigned int gtt_size;
42565@@ -2425,7 +2425,7 @@ static int gen6_gmch_probe(struct drm_device *dev,
42566 * a coarse sanity check.
42567 */
42568 if ((*mappable_end < (64<<20) || (*mappable_end > (512<<20)))) {
42569- DRM_ERROR("Unknown GMADR size (%lx)\n",
42570+ DRM_ERROR("Unknown GMADR size (%llx)\n",
42571 dev_priv->gtt.mappable_end);
42572 return -ENXIO;
42573 }
42574@@ -2459,10 +2459,10 @@ static void gen6_gmch_remove(struct i915_address_space *vm)
42575 }
42576
42577 static int i915_gmch_probe(struct drm_device *dev,
42578- size_t *gtt_total,
42579- size_t *stolen,
42580- phys_addr_t *mappable_base,
42581- unsigned long *mappable_end)
42582+ uint64_t *gtt_total,
42583+ uint64_t *stolen,
42584+ uint64_t *mappable_base,
42585+ uint64_t *mappable_end)
42586 {
42587 struct drm_i915_private *dev_priv = dev->dev_private;
42588 int ret;
42589@@ -2527,10 +2527,10 @@ int i915_gem_gtt_init(struct drm_device *dev)
42590 gtt->base.dev = dev;
42591
42592 /* GMADR is the PCI mmio aperture into the global GTT. */
42593- DRM_INFO("Memory usable by graphics device = %zdM\n",
42594+ DRM_INFO("Memory usable by graphics device = %lldM\n",
42595 gtt->base.total >> 20);
42596- DRM_DEBUG_DRIVER("GMADR size = %ldM\n", gtt->mappable_end >> 20);
42597- DRM_DEBUG_DRIVER("GTT stolen size = %zdM\n", gtt->stolen_size >> 20);
42598+ DRM_DEBUG_DRIVER("GMADR size = %lldM\n", gtt->mappable_end >> 20);
42599+ DRM_DEBUG_DRIVER("GTT stolen size = %lldM\n", gtt->stolen_size >> 20);
42600 #ifdef CONFIG_INTEL_IOMMU
42601 if (intel_iommu_gfx_mapped)
42602 DRM_INFO("VT-d active for gfx access\n");
42603diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
42604index 0d46dd2..1171c00 100644
42605--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
42606+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
42607@@ -233,8 +233,8 @@ struct i915_address_space {
42608 struct drm_mm mm;
42609 struct drm_device *dev;
42610 struct list_head global_link;
42611- unsigned long start; /* Start offset always 0 for dri2 */
42612- size_t total; /* size addr space maps (ex. 2GB for ggtt) */
42613+ uint64_t start; /* Start offset always 0 for dri2 */
42614+ uint64_t total; /* size addr space maps (ex. 2GB for ggtt) */
42615
42616 struct {
42617 dma_addr_t addr;
42618@@ -300,11 +300,11 @@ struct i915_address_space {
42619 */
42620 struct i915_gtt {
42621 struct i915_address_space base;
42622- size_t stolen_size; /* Total size of stolen memory */
42623+ uint64_t stolen_size; /* Total size of stolen memory */
42624
42625- unsigned long mappable_end; /* End offset that we can CPU map */
42626+ uint64_t mappable_end; /* End offset that we can CPU map */
42627 struct io_mapping *mappable; /* Mapping to our CPU mappable region */
42628- phys_addr_t mappable_base; /* PA of our GMADR */
42629+ uint64_t mappable_base; /* PA of our GMADR */
42630
42631 /** "Graphics Stolen Memory" holds the global PTEs */
42632 void __iomem *gsm;
42633@@ -314,9 +314,9 @@ struct i915_gtt {
42634 int mtrr;
42635
42636 /* global gtt ops */
42637- int (*gtt_probe)(struct drm_device *dev, size_t *gtt_total,
42638- size_t *stolen, phys_addr_t *mappable_base,
42639- unsigned long *mappable_end);
42640+ int (*gtt_probe)(struct drm_device *dev, uint64_t *gtt_total,
42641+ uint64_t *stolen, uint64_t *mappable_base,
42642+ uint64_t *mappable_end);
42643 };
42644
42645 struct i915_hw_ppgtt {
42646diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
42647index 8b5b784..78711f6 100644
42648--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
42649+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
42650@@ -310,7 +310,7 @@ int i915_gem_init_stolen(struct drm_device *dev)
42651 if (dev_priv->mm.stolen_base == 0)
42652 return 0;
42653
42654- DRM_DEBUG_KMS("found %zd bytes of stolen memory at %08lx\n",
42655+ DRM_DEBUG_KMS("found %lld bytes of stolen memory at %08lx\n",
42656 dev_priv->gtt.stolen_size, dev_priv->mm.stolen_base);
42657
42658 if (INTEL_INFO(dev)->gen >= 8) {
42659diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
42660index 23aa04c..1d25960 100644
42661--- a/drivers/gpu/drm/i915/i915_ioc32.c
42662+++ b/drivers/gpu/drm/i915/i915_ioc32.c
42663@@ -62,7 +62,7 @@ static int compat_i915_batchbuffer(struct file *file, unsigned int cmd,
42664 || __put_user(batchbuffer32.DR4, &batchbuffer->DR4)
42665 || __put_user(batchbuffer32.num_cliprects,
42666 &batchbuffer->num_cliprects)
42667- || __put_user((int __user *)(unsigned long)batchbuffer32.cliprects,
42668+ || __put_user((struct drm_clip_rect __user *)(unsigned long)batchbuffer32.cliprects,
42669 &batchbuffer->cliprects))
42670 return -EFAULT;
42671
42672@@ -91,13 +91,13 @@ static int compat_i915_cmdbuffer(struct file *file, unsigned int cmd,
42673
42674 cmdbuffer = compat_alloc_user_space(sizeof(*cmdbuffer));
42675 if (!access_ok(VERIFY_WRITE, cmdbuffer, sizeof(*cmdbuffer))
42676- || __put_user((int __user *)(unsigned long)cmdbuffer32.buf,
42677+ || __put_user((char __user *)(unsigned long)cmdbuffer32.buf,
42678 &cmdbuffer->buf)
42679 || __put_user(cmdbuffer32.sz, &cmdbuffer->sz)
42680 || __put_user(cmdbuffer32.DR1, &cmdbuffer->DR1)
42681 || __put_user(cmdbuffer32.DR4, &cmdbuffer->DR4)
42682 || __put_user(cmdbuffer32.num_cliprects, &cmdbuffer->num_cliprects)
42683- || __put_user((int __user *)(unsigned long)cmdbuffer32.cliprects,
42684+ || __put_user((struct drm_clip_rect __user *)(unsigned long)cmdbuffer32.cliprects,
42685 &cmdbuffer->cliprects))
42686 return -EFAULT;
42687
42688@@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
42689 (unsigned long)request);
42690 }
42691
42692-static drm_ioctl_compat_t *i915_compat_ioctls[] = {
42693+static drm_ioctl_compat_t i915_compat_ioctls[] = {
42694 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
42695 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
42696 [DRM_I915_GETPARAM] = compat_i915_getparam,
42697@@ -201,17 +201,13 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
42698 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42699 {
42700 unsigned int nr = DRM_IOCTL_NR(cmd);
42701- drm_ioctl_compat_t *fn = NULL;
42702 int ret;
42703
42704 if (nr < DRM_COMMAND_BASE || nr >= DRM_COMMAND_END)
42705 return drm_compat_ioctl(filp, cmd, arg);
42706
42707- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(i915_compat_ioctls))
42708- fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
42709-
42710- if (fn != NULL)
42711- ret = (*fn) (filp, cmd, arg);
42712+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(i915_compat_ioctls) && i915_compat_ioctls[nr - DRM_COMMAND_BASE])
42713+ ret = (*i915_compat_ioctls[nr - DRM_COMMAND_BASE])(filp, cmd, arg);
42714 else
42715 ret = drm_ioctl(filp, cmd, arg);
42716
42717diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
42718index 107c6c0..e1926b0 100644
42719--- a/drivers/gpu/drm/i915/intel_display.c
42720+++ b/drivers/gpu/drm/i915/intel_display.c
42721@@ -14501,13 +14501,13 @@ struct intel_quirk {
42722 int subsystem_vendor;
42723 int subsystem_device;
42724 void (*hook)(struct drm_device *dev);
42725-};
42726+} __do_const;
42727
42728 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
42729 struct intel_dmi_quirk {
42730 void (*hook)(struct drm_device *dev);
42731 const struct dmi_system_id (*dmi_id_list)[];
42732-};
42733+} __do_const;
42734
42735 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
42736 {
42737@@ -14515,18 +14515,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
42738 return 1;
42739 }
42740
42741-static const struct intel_dmi_quirk intel_dmi_quirks[] = {
42742+static const struct dmi_system_id intel_dmi_quirks_table[] = {
42743 {
42744- .dmi_id_list = &(const struct dmi_system_id[]) {
42745- {
42746- .callback = intel_dmi_reverse_brightness,
42747- .ident = "NCR Corporation",
42748- .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
42749- DMI_MATCH(DMI_PRODUCT_NAME, ""),
42750- },
42751- },
42752- { } /* terminating entry */
42753+ .callback = intel_dmi_reverse_brightness,
42754+ .ident = "NCR Corporation",
42755+ .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
42756+ DMI_MATCH(DMI_PRODUCT_NAME, ""),
42757 },
42758+ },
42759+ { } /* terminating entry */
42760+};
42761+
42762+static const struct intel_dmi_quirk intel_dmi_quirks[] = {
42763+ {
42764+ .dmi_id_list = &intel_dmi_quirks_table,
42765 .hook = quirk_invert_brightness,
42766 },
42767 };
42768diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
42769index 74f505b..21f6914 100644
42770--- a/drivers/gpu/drm/imx/imx-drm-core.c
42771+++ b/drivers/gpu/drm/imx/imx-drm-core.c
42772@@ -355,7 +355,7 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
42773 if (imxdrm->pipes >= MAX_CRTC)
42774 return -EINVAL;
42775
42776- if (imxdrm->drm->open_count)
42777+ if (local_read(&imxdrm->drm->open_count))
42778 return -EBUSY;
42779
42780 imx_drm_crtc = kzalloc(sizeof(*imx_drm_crtc), GFP_KERNEL);
42781diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
42782index b4a20149..219ab78 100644
42783--- a/drivers/gpu/drm/mga/mga_drv.h
42784+++ b/drivers/gpu/drm/mga/mga_drv.h
42785@@ -122,9 +122,9 @@ typedef struct drm_mga_private {
42786 u32 clear_cmd;
42787 u32 maccess;
42788
42789- atomic_t vbl_received; /**< Number of vblanks received. */
42790+ atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
42791 wait_queue_head_t fence_queue;
42792- atomic_t last_fence_retired;
42793+ atomic_unchecked_t last_fence_retired;
42794 u32 next_fence_to_post;
42795
42796 unsigned int fb_cpp;
42797diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
42798index 729bfd5..14bae78 100644
42799--- a/drivers/gpu/drm/mga/mga_ioc32.c
42800+++ b/drivers/gpu/drm/mga/mga_ioc32.c
42801@@ -190,7 +190,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
42802 return 0;
42803 }
42804
42805-drm_ioctl_compat_t *mga_compat_ioctls[] = {
42806+drm_ioctl_compat_t mga_compat_ioctls[] = {
42807 [DRM_MGA_INIT] = compat_mga_init,
42808 [DRM_MGA_GETPARAM] = compat_mga_getparam,
42809 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
42810@@ -208,17 +208,13 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
42811 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42812 {
42813 unsigned int nr = DRM_IOCTL_NR(cmd);
42814- drm_ioctl_compat_t *fn = NULL;
42815 int ret;
42816
42817 if (nr < DRM_COMMAND_BASE)
42818 return drm_compat_ioctl(filp, cmd, arg);
42819
42820- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(mga_compat_ioctls))
42821- fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
42822-
42823- if (fn != NULL)
42824- ret = (*fn) (filp, cmd, arg);
42825+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(mga_compat_ioctls) && mga_compat_ioctls[nr - DRM_COMMAND_BASE])
42826+ ret = (*mga_compat_ioctls[nr - DRM_COMMAND_BASE]) (filp, cmd, arg);
42827 else
42828 ret = drm_ioctl(filp, cmd, arg);
42829
42830diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
42831index 1b071b8..de8601a 100644
42832--- a/drivers/gpu/drm/mga/mga_irq.c
42833+++ b/drivers/gpu/drm/mga/mga_irq.c
42834@@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
42835 if (crtc != 0)
42836 return 0;
42837
42838- return atomic_read(&dev_priv->vbl_received);
42839+ return atomic_read_unchecked(&dev_priv->vbl_received);
42840 }
42841
42842
42843@@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
42844 /* VBLANK interrupt */
42845 if (status & MGA_VLINEPEN) {
42846 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
42847- atomic_inc(&dev_priv->vbl_received);
42848+ atomic_inc_unchecked(&dev_priv->vbl_received);
42849 drm_handle_vblank(dev, 0);
42850 handled = 1;
42851 }
42852@@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
42853 if ((prim_start & ~0x03) != (prim_end & ~0x03))
42854 MGA_WRITE(MGA_PRIMEND, prim_end);
42855
42856- atomic_inc(&dev_priv->last_fence_retired);
42857+ atomic_inc_unchecked(&dev_priv->last_fence_retired);
42858 wake_up(&dev_priv->fence_queue);
42859 handled = 1;
42860 }
42861@@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
42862 * using fences.
42863 */
42864 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * HZ,
42865- (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
42866+ (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
42867 - *sequence) <= (1 << 23)));
42868
42869 *sequence = cur_fence;
42870diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
42871index 0190b69..60c3eaf 100644
42872--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
42873+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
42874@@ -963,7 +963,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
42875 struct bit_table {
42876 const char id;
42877 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
42878-};
42879+} __no_const;
42880
42881 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
42882
42883diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
42884index 477cbb1..109b826 100644
42885--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
42886+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
42887@@ -946,7 +946,8 @@ static struct drm_driver
42888 driver_stub = {
42889 .driver_features =
42890 DRIVER_USE_AGP |
42891- DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER,
42892+ DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER |
42893+ DRIVER_KMS_LEGACY_CONTEXT,
42894
42895 .load = nouveau_drm_load,
42896 .unload = nouveau_drm_unload,
42897diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
42898index dd72652..1fd2368 100644
42899--- a/drivers/gpu/drm/nouveau/nouveau_drm.h
42900+++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
42901@@ -123,7 +123,6 @@ struct nouveau_drm {
42902 struct drm_global_reference mem_global_ref;
42903 struct ttm_bo_global_ref bo_global_ref;
42904 struct ttm_bo_device bdev;
42905- atomic_t validate_sequence;
42906 int (*move)(struct nouveau_channel *,
42907 struct ttm_buffer_object *,
42908 struct ttm_mem_reg *, struct ttm_mem_reg *);
42909diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
42910index 462679a..88e32a7 100644
42911--- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
42912+++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
42913@@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
42914 unsigned long arg)
42915 {
42916 unsigned int nr = DRM_IOCTL_NR(cmd);
42917- drm_ioctl_compat_t *fn = NULL;
42918+ drm_ioctl_compat_t fn = NULL;
42919 int ret;
42920
42921 if (nr < DRM_COMMAND_BASE)
42922diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
42923index 7464aef3..c63ae4f 100644
42924--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
42925+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
42926@@ -130,11 +130,11 @@ nouveau_vram_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
42927 }
42928
42929 const struct ttm_mem_type_manager_func nouveau_vram_manager = {
42930- nouveau_vram_manager_init,
42931- nouveau_vram_manager_fini,
42932- nouveau_vram_manager_new,
42933- nouveau_vram_manager_del,
42934- nouveau_vram_manager_debug
42935+ .init = nouveau_vram_manager_init,
42936+ .takedown = nouveau_vram_manager_fini,
42937+ .get_node = nouveau_vram_manager_new,
42938+ .put_node = nouveau_vram_manager_del,
42939+ .debug = nouveau_vram_manager_debug
42940 };
42941
42942 static int
42943@@ -207,11 +207,11 @@ nouveau_gart_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
42944 }
42945
42946 const struct ttm_mem_type_manager_func nouveau_gart_manager = {
42947- nouveau_gart_manager_init,
42948- nouveau_gart_manager_fini,
42949- nouveau_gart_manager_new,
42950- nouveau_gart_manager_del,
42951- nouveau_gart_manager_debug
42952+ .init = nouveau_gart_manager_init,
42953+ .takedown = nouveau_gart_manager_fini,
42954+ .get_node = nouveau_gart_manager_new,
42955+ .put_node = nouveau_gart_manager_del,
42956+ .debug = nouveau_gart_manager_debug
42957 };
42958
42959 /*XXX*/
42960@@ -280,11 +280,11 @@ nv04_gart_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
42961 }
42962
42963 const struct ttm_mem_type_manager_func nv04_gart_manager = {
42964- nv04_gart_manager_init,
42965- nv04_gart_manager_fini,
42966- nv04_gart_manager_new,
42967- nv04_gart_manager_del,
42968- nv04_gart_manager_debug
42969+ .init = nv04_gart_manager_init,
42970+ .takedown = nv04_gart_manager_fini,
42971+ .get_node = nv04_gart_manager_new,
42972+ .put_node = nv04_gart_manager_del,
42973+ .debug = nv04_gart_manager_debug
42974 };
42975
42976 int
42977diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
42978index c7592ec..dd45ebc 100644
42979--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
42980+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
42981@@ -72,7 +72,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
42982 * locking inversion with the driver load path. And the access here is
42983 * completely racy anyway. So don't bother with locking for now.
42984 */
42985- return dev->open_count == 0;
42986+ return local_read(&dev->open_count) == 0;
42987 }
42988
42989 static const struct vga_switcheroo_client_ops
42990diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
42991index 778372b..4b81cb4 100644
42992--- a/drivers/gpu/drm/omapdrm/Makefile
42993+++ b/drivers/gpu/drm/omapdrm/Makefile
42994@@ -3,7 +3,7 @@
42995 # Direct Rendering Infrastructure (DRI)
42996 #
42997
42998-ccflags-y := -Iinclude/drm -Werror
42999+ccflags-y := -Iinclude/drm
43000 omapdrm-y := omap_drv.o \
43001 omap_irq.o \
43002 omap_debugfs.o \
43003diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
43004index fdc1833..f307630 100644
43005--- a/drivers/gpu/drm/qxl/qxl_cmd.c
43006+++ b/drivers/gpu/drm/qxl/qxl_cmd.c
43007@@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
43008 int ret;
43009
43010 mutex_lock(&qdev->async_io_mutex);
43011- irq_num = atomic_read(&qdev->irq_received_io_cmd);
43012+ irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
43013 if (qdev->last_sent_io_cmd > irq_num) {
43014 if (intr)
43015 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
43016- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43017+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43018 else
43019 ret = wait_event_timeout(qdev->io_cmd_event,
43020- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43021+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43022 /* 0 is timeout, just bail the "hw" has gone away */
43023 if (ret <= 0)
43024 goto out;
43025- irq_num = atomic_read(&qdev->irq_received_io_cmd);
43026+ irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
43027 }
43028 outb(val, addr);
43029 qdev->last_sent_io_cmd = irq_num + 1;
43030 if (intr)
43031 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
43032- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43033+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43034 else
43035 ret = wait_event_timeout(qdev->io_cmd_event,
43036- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43037+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43038 out:
43039 if (ret > 0)
43040 ret = 0;
43041diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
43042index 6911b8c..89d6867 100644
43043--- a/drivers/gpu/drm/qxl/qxl_debugfs.c
43044+++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
43045@@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
43046 struct drm_info_node *node = (struct drm_info_node *) m->private;
43047 struct qxl_device *qdev = node->minor->dev->dev_private;
43048
43049- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
43050- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
43051- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
43052- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
43053+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
43054+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
43055+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
43056+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
43057 seq_printf(m, "%d\n", qdev->irq_received_error);
43058 return 0;
43059 }
43060diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
43061index 01a8694..584fb48 100644
43062--- a/drivers/gpu/drm/qxl/qxl_drv.h
43063+++ b/drivers/gpu/drm/qxl/qxl_drv.h
43064@@ -290,10 +290,10 @@ struct qxl_device {
43065 unsigned int last_sent_io_cmd;
43066
43067 /* interrupt handling */
43068- atomic_t irq_received;
43069- atomic_t irq_received_display;
43070- atomic_t irq_received_cursor;
43071- atomic_t irq_received_io_cmd;
43072+ atomic_unchecked_t irq_received;
43073+ atomic_unchecked_t irq_received_display;
43074+ atomic_unchecked_t irq_received_cursor;
43075+ atomic_unchecked_t irq_received_io_cmd;
43076 unsigned irq_received_error;
43077 wait_queue_head_t display_event;
43078 wait_queue_head_t cursor_event;
43079diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
43080index bda5c5f..140ac46 100644
43081--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
43082+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
43083@@ -183,7 +183,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
43084
43085 /* TODO copy slow path code from i915 */
43086 fb_cmd = qxl_bo_kmap_atomic_page(qdev, cmd_bo, (release->release_offset & PAGE_SIZE));
43087- 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);
43088+ 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);
43089
43090 {
43091 struct qxl_drawable *draw = fb_cmd;
43092@@ -203,7 +203,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
43093 struct drm_qxl_reloc reloc;
43094
43095 if (copy_from_user(&reloc,
43096- &((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i],
43097+ &((struct drm_qxl_reloc __force_user *)(uintptr_t)cmd->relocs)[i],
43098 sizeof(reloc))) {
43099 ret = -EFAULT;
43100 goto out_free_bos;
43101@@ -282,10 +282,10 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
43102
43103 for (cmd_num = 0; cmd_num < execbuffer->commands_num; ++cmd_num) {
43104
43105- struct drm_qxl_command *commands =
43106- (struct drm_qxl_command *)(uintptr_t)execbuffer->commands;
43107+ struct drm_qxl_command __user *commands =
43108+ (struct drm_qxl_command __user *)(uintptr_t)execbuffer->commands;
43109
43110- if (copy_from_user(&user_cmd, &commands[cmd_num],
43111+ if (copy_from_user(&user_cmd, (struct drm_qxl_command __force_user *)&commands[cmd_num],
43112 sizeof(user_cmd)))
43113 return -EFAULT;
43114
43115diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
43116index 0bf1e20..42a7310 100644
43117--- a/drivers/gpu/drm/qxl/qxl_irq.c
43118+++ b/drivers/gpu/drm/qxl/qxl_irq.c
43119@@ -36,19 +36,19 @@ irqreturn_t qxl_irq_handler(int irq, void *arg)
43120 if (!pending)
43121 return IRQ_NONE;
43122
43123- atomic_inc(&qdev->irq_received);
43124+ atomic_inc_unchecked(&qdev->irq_received);
43125
43126 if (pending & QXL_INTERRUPT_DISPLAY) {
43127- atomic_inc(&qdev->irq_received_display);
43128+ atomic_inc_unchecked(&qdev->irq_received_display);
43129 wake_up_all(&qdev->display_event);
43130 qxl_queue_garbage_collect(qdev, false);
43131 }
43132 if (pending & QXL_INTERRUPT_CURSOR) {
43133- atomic_inc(&qdev->irq_received_cursor);
43134+ atomic_inc_unchecked(&qdev->irq_received_cursor);
43135 wake_up_all(&qdev->cursor_event);
43136 }
43137 if (pending & QXL_INTERRUPT_IO_CMD) {
43138- atomic_inc(&qdev->irq_received_io_cmd);
43139+ atomic_inc_unchecked(&qdev->irq_received_io_cmd);
43140 wake_up_all(&qdev->io_cmd_event);
43141 }
43142 if (pending & QXL_INTERRUPT_ERROR) {
43143@@ -85,10 +85,10 @@ int qxl_irq_init(struct qxl_device *qdev)
43144 init_waitqueue_head(&qdev->io_cmd_event);
43145 INIT_WORK(&qdev->client_monitors_config_work,
43146 qxl_client_monitors_config_work_func);
43147- atomic_set(&qdev->irq_received, 0);
43148- atomic_set(&qdev->irq_received_display, 0);
43149- atomic_set(&qdev->irq_received_cursor, 0);
43150- atomic_set(&qdev->irq_received_io_cmd, 0);
43151+ atomic_set_unchecked(&qdev->irq_received, 0);
43152+ atomic_set_unchecked(&qdev->irq_received_display, 0);
43153+ atomic_set_unchecked(&qdev->irq_received_cursor, 0);
43154+ atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
43155 qdev->irq_received_error = 0;
43156 ret = drm_irq_install(qdev->ddev, qdev->ddev->pdev->irq);
43157 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
43158diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
43159index 0cbc4c9..0e46686 100644
43160--- a/drivers/gpu/drm/qxl/qxl_ttm.c
43161+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
43162@@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
43163 }
43164 }
43165
43166-static struct vm_operations_struct qxl_ttm_vm_ops;
43167+static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
43168 static const struct vm_operations_struct *ttm_vm_ops;
43169
43170 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
43171@@ -145,8 +145,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
43172 return r;
43173 if (unlikely(ttm_vm_ops == NULL)) {
43174 ttm_vm_ops = vma->vm_ops;
43175+ pax_open_kernel();
43176 qxl_ttm_vm_ops = *ttm_vm_ops;
43177 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
43178+ pax_close_kernel();
43179 }
43180 vma->vm_ops = &qxl_ttm_vm_ops;
43181 return 0;
43182@@ -464,25 +466,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
43183 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
43184 {
43185 #if defined(CONFIG_DEBUG_FS)
43186- static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
43187- static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
43188- unsigned i;
43189+ static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
43190+ {
43191+ .name = "qxl_mem_mm",
43192+ .show = &qxl_mm_dump_table,
43193+ },
43194+ {
43195+ .name = "qxl_surf_mm",
43196+ .show = &qxl_mm_dump_table,
43197+ }
43198+ };
43199
43200- for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
43201- if (i == 0)
43202- sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
43203- else
43204- sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
43205- qxl_mem_types_list[i].name = qxl_mem_types_names[i];
43206- qxl_mem_types_list[i].show = &qxl_mm_dump_table;
43207- qxl_mem_types_list[i].driver_features = 0;
43208- if (i == 0)
43209- qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
43210- else
43211- qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
43212+ pax_open_kernel();
43213+ *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
43214+ *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
43215+ pax_close_kernel();
43216
43217- }
43218- return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
43219+ return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
43220 #else
43221 return 0;
43222 #endif
43223diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
43224index 2c45ac9..5d740f8 100644
43225--- a/drivers/gpu/drm/r128/r128_cce.c
43226+++ b/drivers/gpu/drm/r128/r128_cce.c
43227@@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
43228
43229 /* GH: Simple idle check.
43230 */
43231- atomic_set(&dev_priv->idle_count, 0);
43232+ atomic_set_unchecked(&dev_priv->idle_count, 0);
43233
43234 /* We don't support anything other than bus-mastering ring mode,
43235 * but the ring can be in either AGP or PCI space for the ring
43236diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
43237index 723e5d6..102dbaf 100644
43238--- a/drivers/gpu/drm/r128/r128_drv.h
43239+++ b/drivers/gpu/drm/r128/r128_drv.h
43240@@ -93,14 +93,14 @@ typedef struct drm_r128_private {
43241 int is_pci;
43242 unsigned long cce_buffers_offset;
43243
43244- atomic_t idle_count;
43245+ atomic_unchecked_t idle_count;
43246
43247 int page_flipping;
43248 int current_page;
43249 u32 crtc_offset;
43250 u32 crtc_offset_cntl;
43251
43252- atomic_t vbl_received;
43253+ atomic_unchecked_t vbl_received;
43254
43255 u32 color_fmt;
43256 unsigned int front_offset;
43257diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
43258index 663f38c..ec159a1 100644
43259--- a/drivers/gpu/drm/r128/r128_ioc32.c
43260+++ b/drivers/gpu/drm/r128/r128_ioc32.c
43261@@ -178,7 +178,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
43262 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
43263 }
43264
43265-drm_ioctl_compat_t *r128_compat_ioctls[] = {
43266+drm_ioctl_compat_t r128_compat_ioctls[] = {
43267 [DRM_R128_INIT] = compat_r128_init,
43268 [DRM_R128_DEPTH] = compat_r128_depth,
43269 [DRM_R128_STIPPLE] = compat_r128_stipple,
43270@@ -197,17 +197,13 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
43271 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
43272 {
43273 unsigned int nr = DRM_IOCTL_NR(cmd);
43274- drm_ioctl_compat_t *fn = NULL;
43275 int ret;
43276
43277 if (nr < DRM_COMMAND_BASE)
43278 return drm_compat_ioctl(filp, cmd, arg);
43279
43280- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(r128_compat_ioctls))
43281- fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
43282-
43283- if (fn != NULL)
43284- ret = (*fn) (filp, cmd, arg);
43285+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(r128_compat_ioctls) && r128_compat_ioctls[nr - DRM_COMMAND_BASE])
43286+ ret = (*r128_compat_ioctls[nr - DRM_COMMAND_BASE]) (filp, cmd, arg);
43287 else
43288 ret = drm_ioctl(filp, cmd, arg);
43289
43290diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
43291index c2ae496..30b5993 100644
43292--- a/drivers/gpu/drm/r128/r128_irq.c
43293+++ b/drivers/gpu/drm/r128/r128_irq.c
43294@@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
43295 if (crtc != 0)
43296 return 0;
43297
43298- return atomic_read(&dev_priv->vbl_received);
43299+ return atomic_read_unchecked(&dev_priv->vbl_received);
43300 }
43301
43302 irqreturn_t r128_driver_irq_handler(int irq, void *arg)
43303@@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(int irq, void *arg)
43304 /* VBLANK interrupt */
43305 if (status & R128_CRTC_VBLANK_INT) {
43306 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
43307- atomic_inc(&dev_priv->vbl_received);
43308+ atomic_inc_unchecked(&dev_priv->vbl_received);
43309 drm_handle_vblank(dev, 0);
43310 return IRQ_HANDLED;
43311 }
43312diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
43313index 8fd2d9f..18c9660 100644
43314--- a/drivers/gpu/drm/r128/r128_state.c
43315+++ b/drivers/gpu/drm/r128/r128_state.c
43316@@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
43317
43318 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
43319 {
43320- if (atomic_read(&dev_priv->idle_count) == 0)
43321+ if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
43322 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
43323 else
43324- atomic_set(&dev_priv->idle_count, 0);
43325+ atomic_set_unchecked(&dev_priv->idle_count, 0);
43326 }
43327
43328 #endif
43329diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
43330index b928c17..e5d9400 100644
43331--- a/drivers/gpu/drm/radeon/mkregtable.c
43332+++ b/drivers/gpu/drm/radeon/mkregtable.c
43333@@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
43334 regex_t mask_rex;
43335 regmatch_t match[4];
43336 char buf[1024];
43337- size_t end;
43338+ long end;
43339 int len;
43340 int done = 0;
43341 int r;
43342 unsigned o;
43343 struct offset *offset;
43344 char last_reg_s[10];
43345- int last_reg;
43346+ unsigned long last_reg;
43347
43348 if (regcomp
43349 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
43350diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
43351index d8319da..d6e066f 100644
43352--- a/drivers/gpu/drm/radeon/radeon_device.c
43353+++ b/drivers/gpu/drm/radeon/radeon_device.c
43354@@ -1253,7 +1253,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
43355 * locking inversion with the driver load path. And the access here is
43356 * completely racy anyway. So don't bother with locking for now.
43357 */
43358- return dev->open_count == 0;
43359+ return local_read(&dev->open_count) == 0;
43360 }
43361
43362 static const struct vga_switcheroo_client_ops radeon_switcheroo_ops = {
43363diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
43364index 46bd393..6ae4719 100644
43365--- a/drivers/gpu/drm/radeon/radeon_drv.h
43366+++ b/drivers/gpu/drm/radeon/radeon_drv.h
43367@@ -264,7 +264,7 @@ typedef struct drm_radeon_private {
43368
43369 /* SW interrupt */
43370 wait_queue_head_t swi_queue;
43371- atomic_t swi_emitted;
43372+ atomic_unchecked_t swi_emitted;
43373 int vblank_crtc;
43374 uint32_t irq_enable_reg;
43375 uint32_t r500_disp_irq_reg;
43376diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
43377index 0b98ea1..a3c770f 100644
43378--- a/drivers/gpu/drm/radeon/radeon_ioc32.c
43379+++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
43380@@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
43381 request = compat_alloc_user_space(sizeof(*request));
43382 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
43383 || __put_user(req32.param, &request->param)
43384- || __put_user((void __user *)(unsigned long)req32.value,
43385+ || __put_user((unsigned long)req32.value,
43386 &request->value))
43387 return -EFAULT;
43388
43389@@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
43390 #define compat_radeon_cp_setparam NULL
43391 #endif /* X86_64 || IA64 */
43392
43393-static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
43394+static drm_ioctl_compat_t radeon_compat_ioctls[] = {
43395 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
43396 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
43397 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
43398@@ -393,17 +393,13 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
43399 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
43400 {
43401 unsigned int nr = DRM_IOCTL_NR(cmd);
43402- drm_ioctl_compat_t *fn = NULL;
43403 int ret;
43404
43405 if (nr < DRM_COMMAND_BASE)
43406 return drm_compat_ioctl(filp, cmd, arg);
43407
43408- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(radeon_compat_ioctls))
43409- fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
43410-
43411- if (fn != NULL)
43412- ret = (*fn) (filp, cmd, arg);
43413+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(radeon_compat_ioctls) && radeon_compat_ioctls[nr - DRM_COMMAND_BASE])
43414+ ret = (*radeon_compat_ioctls[nr - DRM_COMMAND_BASE]) (filp, cmd, arg);
43415 else
43416 ret = drm_ioctl(filp, cmd, arg);
43417
43418diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
43419index 244b19b..c19226d 100644
43420--- a/drivers/gpu/drm/radeon/radeon_irq.c
43421+++ b/drivers/gpu/drm/radeon/radeon_irq.c
43422@@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
43423 unsigned int ret;
43424 RING_LOCALS;
43425
43426- atomic_inc(&dev_priv->swi_emitted);
43427- ret = atomic_read(&dev_priv->swi_emitted);
43428+ atomic_inc_unchecked(&dev_priv->swi_emitted);
43429+ ret = atomic_read_unchecked(&dev_priv->swi_emitted);
43430
43431 BEGIN_RING(4);
43432 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
43433@@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
43434 drm_radeon_private_t *dev_priv =
43435 (drm_radeon_private_t *) dev->dev_private;
43436
43437- atomic_set(&dev_priv->swi_emitted, 0);
43438+ atomic_set_unchecked(&dev_priv->swi_emitted, 0);
43439 init_waitqueue_head(&dev_priv->swi_queue);
43440
43441 dev->max_vblank_count = 0x001fffff;
43442diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
43443index 15aee72..cda326e 100644
43444--- a/drivers/gpu/drm/radeon/radeon_state.c
43445+++ b/drivers/gpu/drm/radeon/radeon_state.c
43446@@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
43447 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
43448 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
43449
43450- if (copy_from_user(&depth_boxes, clear->depth_boxes,
43451+ if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || copy_from_user(&depth_boxes, clear->depth_boxes,
43452 sarea_priv->nbox * sizeof(depth_boxes[0])))
43453 return -EFAULT;
43454
43455@@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
43456 {
43457 drm_radeon_private_t *dev_priv = dev->dev_private;
43458 drm_radeon_getparam_t *param = data;
43459- int value;
43460+ int value = 0;
43461
43462 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
43463
43464diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
43465index 06ac59fe..57e0681 100644
43466--- a/drivers/gpu/drm/radeon/radeon_ttm.c
43467+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
43468@@ -961,7 +961,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
43469 man->size = size >> PAGE_SHIFT;
43470 }
43471
43472-static struct vm_operations_struct radeon_ttm_vm_ops;
43473+static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
43474 static const struct vm_operations_struct *ttm_vm_ops = NULL;
43475
43476 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
43477@@ -1002,8 +1002,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
43478 }
43479 if (unlikely(ttm_vm_ops == NULL)) {
43480 ttm_vm_ops = vma->vm_ops;
43481+ pax_open_kernel();
43482 radeon_ttm_vm_ops = *ttm_vm_ops;
43483 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
43484+ pax_close_kernel();
43485 }
43486 vma->vm_ops = &radeon_ttm_vm_ops;
43487 return 0;
43488diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
43489index a287e4f..df1d5dd 100644
43490--- a/drivers/gpu/drm/tegra/dc.c
43491+++ b/drivers/gpu/drm/tegra/dc.c
43492@@ -1594,7 +1594,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
43493 }
43494
43495 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
43496- dc->debugfs_files[i].data = dc;
43497+ *(void **)&dc->debugfs_files[i].data = dc;
43498
43499 err = drm_debugfs_create_files(dc->debugfs_files,
43500 ARRAY_SIZE(debugfs_files),
43501diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
43502index ed970f6..4eeea42 100644
43503--- a/drivers/gpu/drm/tegra/dsi.c
43504+++ b/drivers/gpu/drm/tegra/dsi.c
43505@@ -62,7 +62,7 @@ struct tegra_dsi {
43506 struct clk *clk_lp;
43507 struct clk *clk;
43508
43509- struct drm_info_list *debugfs_files;
43510+ drm_info_list_no_const *debugfs_files;
43511 struct drm_minor *minor;
43512 struct dentry *debugfs;
43513
43514diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
43515index 06ab178..b5324e4 100644
43516--- a/drivers/gpu/drm/tegra/hdmi.c
43517+++ b/drivers/gpu/drm/tegra/hdmi.c
43518@@ -64,7 +64,7 @@ struct tegra_hdmi {
43519 bool stereo;
43520 bool dvi;
43521
43522- struct drm_info_list *debugfs_files;
43523+ drm_info_list_no_const *debugfs_files;
43524 struct drm_minor *minor;
43525 struct dentry *debugfs;
43526 };
43527diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
43528index 7591d89..463e2b6 100644
43529--- a/drivers/gpu/drm/tegra/sor.c
43530+++ b/drivers/gpu/drm/tegra/sor.c
43531@@ -826,8 +826,11 @@ static int tegra_sor_debugfs_init(struct tegra_sor *sor,
43532 goto remove;
43533 }
43534
43535- for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
43536- sor->debugfs_files[i].data = sor;
43537+ for (i = 0; i < ARRAY_SIZE(debugfs_files); i++) {
43538+ pax_open_kernel();
43539+ *(void **)&sor->debugfs_files[i].data = sor;
43540+ pax_close_kernel();
43541+ }
43542
43543 err = drm_debugfs_create_files(sor->debugfs_files,
43544 ARRAY_SIZE(debugfs_files),
43545diff --git a/drivers/gpu/drm/tilcdc/Makefile b/drivers/gpu/drm/tilcdc/Makefile
43546index deeca48..54e1b6c 100644
43547--- a/drivers/gpu/drm/tilcdc/Makefile
43548+++ b/drivers/gpu/drm/tilcdc/Makefile
43549@@ -1,7 +1,7 @@
43550 ccflags-y := -Iinclude/drm
43551-ifeq (, $(findstring -W,$(EXTRA_CFLAGS)))
43552- ccflags-y += -Werror
43553-endif
43554+#ifeq (, $(findstring -W,$(EXTRA_CFLAGS)))
43555+# ccflags-y += -Werror
43556+#endif
43557
43558 obj-$(CONFIG_DRM_TILCDC_SLAVE_COMPAT) += tilcdc_slave_compat.o \
43559 tilcdc_slave_compat.dtb.o
43560diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
43561index aa0bd054..aea6a01 100644
43562--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
43563+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
43564@@ -148,10 +148,10 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
43565 }
43566
43567 const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
43568- ttm_bo_man_init,
43569- ttm_bo_man_takedown,
43570- ttm_bo_man_get_node,
43571- ttm_bo_man_put_node,
43572- ttm_bo_man_debug
43573+ .init = ttm_bo_man_init,
43574+ .takedown = ttm_bo_man_takedown,
43575+ .get_node = ttm_bo_man_get_node,
43576+ .put_node = ttm_bo_man_put_node,
43577+ .debug = ttm_bo_man_debug
43578 };
43579 EXPORT_SYMBOL(ttm_bo_manager_func);
43580diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
43581index a1803fb..c53f6b0 100644
43582--- a/drivers/gpu/drm/ttm/ttm_memory.c
43583+++ b/drivers/gpu/drm/ttm/ttm_memory.c
43584@@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
43585 zone->glob = glob;
43586 glob->zone_kernel = zone;
43587 ret = kobject_init_and_add(
43588- &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
43589+ &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
43590 if (unlikely(ret != 0)) {
43591 kobject_put(&zone->kobj);
43592 return ret;
43593@@ -348,7 +348,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
43594 zone->glob = glob;
43595 glob->zone_dma32 = zone;
43596 ret = kobject_init_and_add(
43597- &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
43598+ &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
43599 if (unlikely(ret != 0)) {
43600 kobject_put(&zone->kobj);
43601 return ret;
43602diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
43603index 025c429..314062f 100644
43604--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
43605+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
43606@@ -54,7 +54,7 @@
43607
43608 #define NUM_PAGES_TO_ALLOC (PAGE_SIZE/sizeof(struct page *))
43609 #define SMALL_ALLOCATION 16
43610-#define FREE_ALL_PAGES (~0U)
43611+#define FREE_ALL_PAGES (~0UL)
43612 /* times are in msecs */
43613 #define PAGE_FREE_INTERVAL 1000
43614
43615@@ -299,15 +299,14 @@ static void ttm_pool_update_free_locked(struct ttm_page_pool *pool,
43616 * @free_all: If set to true will free all pages in pool
43617 * @use_static: Safe to use static buffer
43618 **/
43619-static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,
43620+static unsigned long ttm_page_pool_free(struct ttm_page_pool *pool, unsigned long nr_free,
43621 bool use_static)
43622 {
43623 static struct page *static_buf[NUM_PAGES_TO_ALLOC];
43624 unsigned long irq_flags;
43625 struct page *p;
43626 struct page **pages_to_free;
43627- unsigned freed_pages = 0,
43628- npages_to_free = nr_free;
43629+ unsigned long freed_pages = 0, npages_to_free = nr_free;
43630
43631 if (NUM_PAGES_TO_ALLOC < nr_free)
43632 npages_to_free = NUM_PAGES_TO_ALLOC;
43633@@ -371,7 +370,8 @@ restart:
43634 __list_del(&p->lru, &pool->list);
43635
43636 ttm_pool_update_free_locked(pool, freed_pages);
43637- nr_free -= freed_pages;
43638+ if (likely(nr_free != FREE_ALL_PAGES))
43639+ nr_free -= freed_pages;
43640 }
43641
43642 spin_unlock_irqrestore(&pool->lock, irq_flags);
43643@@ -399,7 +399,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43644 unsigned i;
43645 unsigned pool_offset;
43646 struct ttm_page_pool *pool;
43647- int shrink_pages = sc->nr_to_scan;
43648+ unsigned long shrink_pages = sc->nr_to_scan;
43649 unsigned long freed = 0;
43650
43651 if (!mutex_trylock(&lock))
43652@@ -407,7 +407,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43653 pool_offset = ++start_pool % NUM_POOLS;
43654 /* select start pool in round robin fashion */
43655 for (i = 0; i < NUM_POOLS; ++i) {
43656- unsigned nr_free = shrink_pages;
43657+ unsigned long nr_free = shrink_pages;
43658 if (shrink_pages == 0)
43659 break;
43660 pool = &_manager->pools[(i + pool_offset)%NUM_POOLS];
43661@@ -673,7 +673,7 @@ out:
43662 }
43663
43664 /* Put all pages in pages list to correct pool to wait for reuse */
43665-static void ttm_put_pages(struct page **pages, unsigned npages, int flags,
43666+static void ttm_put_pages(struct page **pages, unsigned long npages, int flags,
43667 enum ttm_caching_state cstate)
43668 {
43669 unsigned long irq_flags;
43670@@ -728,7 +728,7 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,
43671 struct list_head plist;
43672 struct page *p = NULL;
43673 gfp_t gfp_flags = GFP_USER;
43674- unsigned count;
43675+ unsigned long count;
43676 int r;
43677
43678 /* set zero flag for page allocation if required */
43679diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
43680index 624d941..106fa1f 100644
43681--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
43682+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
43683@@ -56,7 +56,7 @@
43684
43685 #define NUM_PAGES_TO_ALLOC (PAGE_SIZE/sizeof(struct page *))
43686 #define SMALL_ALLOCATION 4
43687-#define FREE_ALL_PAGES (~0U)
43688+#define FREE_ALL_PAGES (~0UL)
43689 /* times are in msecs */
43690 #define IS_UNDEFINED (0)
43691 #define IS_WC (1<<1)
43692@@ -416,7 +416,7 @@ static void ttm_dma_page_put(struct dma_pool *pool, struct dma_page *d_page)
43693 * @nr_free: If set to true will free all pages in pool
43694 * @use_static: Safe to use static buffer
43695 **/
43696-static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
43697+static unsigned long ttm_dma_page_pool_free(struct dma_pool *pool, unsigned long nr_free,
43698 bool use_static)
43699 {
43700 static struct page *static_buf[NUM_PAGES_TO_ALLOC];
43701@@ -424,8 +424,7 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
43702 struct dma_page *dma_p, *tmp;
43703 struct page **pages_to_free;
43704 struct list_head d_pages;
43705- unsigned freed_pages = 0,
43706- npages_to_free = nr_free;
43707+ unsigned long freed_pages = 0, npages_to_free = nr_free;
43708
43709 if (NUM_PAGES_TO_ALLOC < nr_free)
43710 npages_to_free = NUM_PAGES_TO_ALLOC;
43711@@ -502,7 +501,8 @@ restart:
43712 /* remove range of pages from the pool */
43713 if (freed_pages) {
43714 ttm_pool_update_free_locked(pool, freed_pages);
43715- nr_free -= freed_pages;
43716+ if (likely(nr_free != FREE_ALL_PAGES))
43717+ nr_free -= freed_pages;
43718 }
43719
43720 spin_unlock_irqrestore(&pool->lock, irq_flags);
43721@@ -939,7 +939,7 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)
43722 struct dma_page *d_page, *next;
43723 enum pool_type type;
43724 bool is_cached = false;
43725- unsigned count = 0, i, npages = 0;
43726+ unsigned long count = 0, i, npages = 0;
43727 unsigned long irq_flags;
43728
43729 type = ttm_to_type(ttm->page_flags, ttm->caching_state);
43730@@ -1014,7 +1014,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43731 static unsigned start_pool;
43732 unsigned idx = 0;
43733 unsigned pool_offset;
43734- unsigned shrink_pages = sc->nr_to_scan;
43735+ unsigned long shrink_pages = sc->nr_to_scan;
43736 struct device_pools *p;
43737 unsigned long freed = 0;
43738
43739@@ -1027,7 +1027,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43740 goto out;
43741 pool_offset = ++start_pool % _manager->npools;
43742 list_for_each_entry(p, &_manager->pools, pools) {
43743- unsigned nr_free;
43744+ unsigned long nr_free;
43745
43746 if (!p->dev)
43747 continue;
43748@@ -1041,7 +1041,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43749 shrink_pages = ttm_dma_page_pool_free(p->pool, nr_free, true);
43750 freed += nr_free - shrink_pages;
43751
43752- pr_debug("%s: (%s:%d) Asked to shrink %d, have %d more to go\n",
43753+ pr_debug("%s: (%s:%d) Asked to shrink %lu, have %lu more to go\n",
43754 p->pool->dev_name, p->pool->name, current->pid,
43755 nr_free, shrink_pages);
43756 }
43757diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
43758index 5fc16ce..1bd84ec 100644
43759--- a/drivers/gpu/drm/udl/udl_fb.c
43760+++ b/drivers/gpu/drm/udl/udl_fb.c
43761@@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
43762 fb_deferred_io_cleanup(info);
43763 kfree(info->fbdefio);
43764 info->fbdefio = NULL;
43765- info->fbops->fb_mmap = udl_fb_mmap;
43766 }
43767
43768 pr_warn("released /dev/fb%d user=%d count=%d\n",
43769diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
43770index ef8c500..01030c8 100644
43771--- a/drivers/gpu/drm/via/via_drv.h
43772+++ b/drivers/gpu/drm/via/via_drv.h
43773@@ -53,7 +53,7 @@ typedef struct drm_via_ring_buffer {
43774 typedef uint32_t maskarray_t[5];
43775
43776 typedef struct drm_via_irq {
43777- atomic_t irq_received;
43778+ atomic_unchecked_t irq_received;
43779 uint32_t pending_mask;
43780 uint32_t enable_mask;
43781 wait_queue_head_t irq_queue;
43782@@ -77,7 +77,7 @@ typedef struct drm_via_private {
43783 struct timeval last_vblank;
43784 int last_vblank_valid;
43785 unsigned usec_per_vblank;
43786- atomic_t vbl_received;
43787+ atomic_unchecked_t vbl_received;
43788 drm_via_state_t hc_state;
43789 char pci_buf[VIA_PCI_BUF_SIZE];
43790 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
43791diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
43792index 1319433..a993b0c 100644
43793--- a/drivers/gpu/drm/via/via_irq.c
43794+++ b/drivers/gpu/drm/via/via_irq.c
43795@@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
43796 if (crtc != 0)
43797 return 0;
43798
43799- return atomic_read(&dev_priv->vbl_received);
43800+ return atomic_read_unchecked(&dev_priv->vbl_received);
43801 }
43802
43803 irqreturn_t via_driver_irq_handler(int irq, void *arg)
43804@@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
43805
43806 status = VIA_READ(VIA_REG_INTERRUPT);
43807 if (status & VIA_IRQ_VBLANK_PENDING) {
43808- atomic_inc(&dev_priv->vbl_received);
43809- if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
43810+ atomic_inc_unchecked(&dev_priv->vbl_received);
43811+ if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
43812 do_gettimeofday(&cur_vblank);
43813 if (dev_priv->last_vblank_valid) {
43814 dev_priv->usec_per_vblank =
43815@@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
43816 dev_priv->last_vblank = cur_vblank;
43817 dev_priv->last_vblank_valid = 1;
43818 }
43819- if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
43820+ if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
43821 DRM_DEBUG("US per vblank is: %u\n",
43822 dev_priv->usec_per_vblank);
43823 }
43824@@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
43825
43826 for (i = 0; i < dev_priv->num_irqs; ++i) {
43827 if (status & cur_irq->pending_mask) {
43828- atomic_inc(&cur_irq->irq_received);
43829+ atomic_inc_unchecked(&cur_irq->irq_received);
43830 wake_up(&cur_irq->irq_queue);
43831 handled = 1;
43832 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
43833@@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
43834 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
43835 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
43836 masks[irq][4]));
43837- cur_irq_sequence = atomic_read(&cur_irq->irq_received);
43838+ cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
43839 } else {
43840 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
43841 (((cur_irq_sequence =
43842- atomic_read(&cur_irq->irq_received)) -
43843+ atomic_read_unchecked(&cur_irq->irq_received)) -
43844 *sequence) <= (1 << 23)));
43845 }
43846 *sequence = cur_irq_sequence;
43847@@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
43848 }
43849
43850 for (i = 0; i < dev_priv->num_irqs; ++i) {
43851- atomic_set(&cur_irq->irq_received, 0);
43852+ atomic_set_unchecked(&cur_irq->irq_received, 0);
43853 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
43854 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
43855 init_waitqueue_head(&cur_irq->irq_queue);
43856@@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
43857 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
43858 case VIA_IRQ_RELATIVE:
43859 irqwait->request.sequence +=
43860- atomic_read(&cur_irq->irq_received);
43861+ atomic_read_unchecked(&cur_irq->irq_received);
43862 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
43863 case VIA_IRQ_ABSOLUTE:
43864 break;
43865diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
43866index db8b491..d87b27c 100644
43867--- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c
43868+++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
43869@@ -34,7 +34,7 @@ virtio_gpu_debugfs_irq_info(struct seq_file *m, void *data)
43870 struct drm_info_node *node = (struct drm_info_node *) m->private;
43871 struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
43872
43873- seq_printf(m, "fence %ld %lld\n",
43874+ seq_printf(m, "fence %lld %lld\n",
43875 atomic64_read(&vgdev->fence_drv.last_seq),
43876 vgdev->fence_drv.sync_seq);
43877 return 0;
43878diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c
43879index 1da6326..98dd385 100644
43880--- a/drivers/gpu/drm/virtio/virtgpu_fence.c
43881+++ b/drivers/gpu/drm/virtio/virtgpu_fence.c
43882@@ -61,7 +61,7 @@ static void virtio_timeline_value_str(struct fence *f, char *str, int size)
43883 {
43884 struct virtio_gpu_fence *fence = to_virtio_fence(f);
43885
43886- snprintf(str, size, "%lu", atomic64_read(&fence->drv->last_seq));
43887+ snprintf(str, size, "%llu", atomic64_read(&fence->drv->last_seq));
43888 }
43889
43890 static const struct fence_ops virtio_fence_ops = {
43891diff --git a/drivers/gpu/drm/virtio/virtgpu_ttm.c b/drivers/gpu/drm/virtio/virtgpu_ttm.c
43892index b092d7b..3bbecd9 100644
43893--- a/drivers/gpu/drm/virtio/virtgpu_ttm.c
43894+++ b/drivers/gpu/drm/virtio/virtgpu_ttm.c
43895@@ -197,11 +197,11 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
43896 }
43897
43898 static const struct ttm_mem_type_manager_func virtio_gpu_bo_manager_func = {
43899- ttm_bo_man_init,
43900- ttm_bo_man_takedown,
43901- ttm_bo_man_get_node,
43902- ttm_bo_man_put_node,
43903- ttm_bo_man_debug
43904+ .init = &ttm_bo_man_init,
43905+ .takedown = &ttm_bo_man_takedown,
43906+ .get_node = &ttm_bo_man_get_node,
43907+ .put_node = &ttm_bo_man_put_node,
43908+ .debug = &ttm_bo_man_debug
43909 };
43910
43911 static int virtio_gpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
43912diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
43913index d26a6da..5fa41ed 100644
43914--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
43915+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
43916@@ -447,7 +447,7 @@ struct vmw_private {
43917 * Fencing and IRQs.
43918 */
43919
43920- atomic_t marker_seq;
43921+ atomic_unchecked_t marker_seq;
43922 wait_queue_head_t fence_queue;
43923 wait_queue_head_t fifo_queue;
43924 spinlock_t waiter_lock;
43925diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
43926index 39f2b03..d1b0a64 100644
43927--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
43928+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
43929@@ -152,7 +152,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
43930 (unsigned int) min,
43931 (unsigned int) fifo->capabilities);
43932
43933- atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
43934+ atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
43935 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
43936 vmw_marker_queue_init(&fifo->marker_queue);
43937 return vmw_fifo_send_fence(dev_priv, &dummy);
43938@@ -372,7 +372,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
43939 if (reserveable)
43940 iowrite32(bytes, fifo_mem +
43941 SVGA_FIFO_RESERVED);
43942- return fifo_mem + (next_cmd >> 2);
43943+ return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
43944 } else {
43945 need_bounce = true;
43946 }
43947@@ -492,7 +492,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
43948
43949 fm = vmw_fifo_reserve(dev_priv, bytes);
43950 if (unlikely(fm == NULL)) {
43951- *seqno = atomic_read(&dev_priv->marker_seq);
43952+ *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
43953 ret = -ENOMEM;
43954 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
43955 false, 3*HZ);
43956@@ -500,7 +500,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
43957 }
43958
43959 do {
43960- *seqno = atomic_add_return(1, &dev_priv->marker_seq);
43961+ *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
43962 } while (*seqno == 0);
43963
43964 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
43965diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
43966index 170b61b..fec7348 100644
43967--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
43968+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
43969@@ -164,9 +164,9 @@ static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man,
43970 }
43971
43972 const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
43973- vmw_gmrid_man_init,
43974- vmw_gmrid_man_takedown,
43975- vmw_gmrid_man_get_node,
43976- vmw_gmrid_man_put_node,
43977- vmw_gmrid_man_debug
43978+ .init = vmw_gmrid_man_init,
43979+ .takedown = vmw_gmrid_man_takedown,
43980+ .get_node = vmw_gmrid_man_get_node,
43981+ .put_node = vmw_gmrid_man_put_node,
43982+ .debug = vmw_gmrid_man_debug
43983 };
43984diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
43985index 69c8ce2..cacb0ab 100644
43986--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
43987+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
43988@@ -235,7 +235,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
43989 int ret;
43990
43991 num_clips = arg->num_clips;
43992- clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
43993+ clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
43994
43995 if (unlikely(num_clips == 0))
43996 return 0;
43997@@ -318,7 +318,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
43998 int ret;
43999
44000 num_clips = arg->num_clips;
44001- clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
44002+ clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
44003
44004 if (unlikely(num_clips == 0))
44005 return 0;
44006diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
44007index 9fe9827..0aa2fc0 100644
44008--- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
44009+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
44010@@ -102,7 +102,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
44011 * emitted. Then the fence is stale and signaled.
44012 */
44013
44014- ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
44015+ ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
44016 > VMW_FENCE_WRAP);
44017
44018 return ret;
44019@@ -133,7 +133,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
44020
44021 if (fifo_idle)
44022 down_read(&fifo_state->rwsem);
44023- signal_seq = atomic_read(&dev_priv->marker_seq);
44024+ signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
44025 ret = 0;
44026
44027 for (;;) {
44028diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
44029index efd1ffd..0ae13ca 100644
44030--- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
44031+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
44032@@ -135,7 +135,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
44033 while (!vmw_lag_lt(queue, us)) {
44034 spin_lock(&queue->lock);
44035 if (list_empty(&queue->head))
44036- seqno = atomic_read(&dev_priv->marker_seq);
44037+ seqno = atomic_read_unchecked(&dev_priv->marker_seq);
44038 else {
44039 marker = list_first_entry(&queue->head,
44040 struct vmw_marker, head);
44041diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
44042index 37ac7b5..d52a5c9 100644
44043--- a/drivers/gpu/vga/vga_switcheroo.c
44044+++ b/drivers/gpu/vga/vga_switcheroo.c
44045@@ -644,7 +644,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
44046
44047 /* this version is for the case where the power switch is separate
44048 to the device being powered down. */
44049-int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
44050+int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
44051 {
44052 /* copy over all the bus versions */
44053 if (dev->bus && dev->bus->pm) {
44054@@ -695,7 +695,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
44055 return ret;
44056 }
44057
44058-int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
44059+int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
44060 {
44061 /* copy over all the bus versions */
44062 if (dev->bus && dev->bus->pm) {
44063diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
44064index e6fce23..85949a0 100644
44065--- a/drivers/hid/hid-core.c
44066+++ b/drivers/hid/hid-core.c
44067@@ -2550,7 +2550,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
44068
44069 int hid_add_device(struct hid_device *hdev)
44070 {
44071- static atomic_t id = ATOMIC_INIT(0);
44072+ static atomic_unchecked_t id = ATOMIC_INIT(0);
44073 int ret;
44074
44075 if (WARN_ON(hdev->status & HID_STAT_ADDED))
44076@@ -2593,7 +2593,7 @@ int hid_add_device(struct hid_device *hdev)
44077 /* XXX hack, any other cleaner solution after the driver core
44078 * is converted to allow more than 20 bytes as the device name? */
44079 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
44080- hdev->vendor, hdev->product, atomic_inc_return(&id));
44081+ hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
44082
44083 hid_debug_register(hdev, dev_name(&hdev->dev));
44084 ret = device_add(&hdev->dev);
44085diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
44086index 5614fee..8a6f5f6 100644
44087--- a/drivers/hid/hid-sensor-custom.c
44088+++ b/drivers/hid/hid-sensor-custom.c
44089@@ -590,7 +590,7 @@ static int hid_sensor_custom_add_attributes(struct hid_sensor_custom
44090 j = 0;
44091 while (j < HID_CUSTOM_TOTAL_ATTRS &&
44092 hid_custom_attrs[j].name) {
44093- struct device_attribute *device_attr;
44094+ device_attribute_no_const *device_attr;
44095
44096 device_attr = &sensor_inst->fields[i].sd_attrs[j];
44097
44098diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
44099index c13fb5b..55a3802 100644
44100--- a/drivers/hid/hid-wiimote-debug.c
44101+++ b/drivers/hid/hid-wiimote-debug.c
44102@@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
44103 else if (size == 0)
44104 return -EIO;
44105
44106- if (copy_to_user(u, buf, size))
44107+ if (size > sizeof(buf) || copy_to_user(u, buf, size))
44108 return -EFAULT;
44109
44110 *off += size;
44111diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
44112index 603ce97..7f27468 100644
44113--- a/drivers/hv/channel.c
44114+++ b/drivers/hv/channel.c
44115@@ -382,7 +382,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
44116 int ret = 0;
44117
44118 next_gpadl_handle =
44119- (atomic_inc_return(&vmbus_connection.next_gpadl_handle) - 1);
44120+ (atomic_inc_return_unchecked(&vmbus_connection.next_gpadl_handle) - 1);
44121
44122 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
44123 if (ret)
44124diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
44125index d3943bc..597fd1e 100644
44126--- a/drivers/hv/hv.c
44127+++ b/drivers/hv/hv.c
44128@@ -118,7 +118,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
44129 u64 output_address = (output) ? virt_to_phys(output) : 0;
44130 u32 output_address_hi = output_address >> 32;
44131 u32 output_address_lo = output_address & 0xFFFFFFFF;
44132- void *hypercall_page = hv_context.hypercall_page;
44133+ void *hypercall_page = (void *)ktva_ktla((unsigned long)hv_context.hypercall_page);
44134
44135 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
44136 "=a"(hv_status_lo) : "d" (control_hi),
44137@@ -164,7 +164,7 @@ int hv_init(void)
44138 /* See if the hypercall page is already set */
44139 rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
44140
44141- virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
44142+ virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_RX);
44143
44144 if (!virtaddr)
44145 goto cleanup;
44146diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
44147index 8a725cd..91abaf0 100644
44148--- a/drivers/hv/hv_balloon.c
44149+++ b/drivers/hv/hv_balloon.c
44150@@ -469,7 +469,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
44151
44152 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
44153 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
44154-static atomic_t trans_id = ATOMIC_INIT(0);
44155+static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
44156
44157 static int dm_ring_size = (5 * PAGE_SIZE);
44158
44159@@ -943,7 +943,7 @@ static void hot_add_req(struct work_struct *dummy)
44160 pr_info("Memory hot add failed\n");
44161
44162 dm->state = DM_INITIALIZED;
44163- resp.hdr.trans_id = atomic_inc_return(&trans_id);
44164+ resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44165 vmbus_sendpacket(dm->dev->channel, &resp,
44166 sizeof(struct dm_hot_add_response),
44167 (unsigned long)NULL,
44168@@ -1024,7 +1024,7 @@ static void post_status(struct hv_dynmem_device *dm)
44169 memset(&status, 0, sizeof(struct dm_status));
44170 status.hdr.type = DM_STATUS_REPORT;
44171 status.hdr.size = sizeof(struct dm_status);
44172- status.hdr.trans_id = atomic_inc_return(&trans_id);
44173+ status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44174
44175 /*
44176 * The host expects the guest to report free and committed memory.
44177@@ -1048,7 +1048,7 @@ static void post_status(struct hv_dynmem_device *dm)
44178 * send the status. This can happen if we were interrupted
44179 * after we picked our transaction ID.
44180 */
44181- if (status.hdr.trans_id != atomic_read(&trans_id))
44182+ if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
44183 return;
44184
44185 /*
44186@@ -1193,7 +1193,7 @@ static void balloon_up(struct work_struct *dummy)
44187 */
44188
44189 do {
44190- bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
44191+ bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44192 ret = vmbus_sendpacket(dm_device.dev->channel,
44193 bl_resp,
44194 bl_resp->hdr.size,
44195@@ -1239,7 +1239,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
44196
44197 memset(&resp, 0, sizeof(struct dm_unballoon_response));
44198 resp.hdr.type = DM_UNBALLOON_RESPONSE;
44199- resp.hdr.trans_id = atomic_inc_return(&trans_id);
44200+ resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44201 resp.hdr.size = sizeof(struct dm_unballoon_response);
44202
44203 vmbus_sendpacket(dm_device.dev->channel, &resp,
44204@@ -1300,7 +1300,7 @@ static void version_resp(struct hv_dynmem_device *dm,
44205 memset(&version_req, 0, sizeof(struct dm_version_request));
44206 version_req.hdr.type = DM_VERSION_REQUEST;
44207 version_req.hdr.size = sizeof(struct dm_version_request);
44208- version_req.hdr.trans_id = atomic_inc_return(&trans_id);
44209+ version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44210 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
44211 version_req.is_last_attempt = 1;
44212
44213@@ -1473,7 +1473,7 @@ static int balloon_probe(struct hv_device *dev,
44214 memset(&version_req, 0, sizeof(struct dm_version_request));
44215 version_req.hdr.type = DM_VERSION_REQUEST;
44216 version_req.hdr.size = sizeof(struct dm_version_request);
44217- version_req.hdr.trans_id = atomic_inc_return(&trans_id);
44218+ version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44219 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
44220 version_req.is_last_attempt = 0;
44221
44222@@ -1504,7 +1504,7 @@ static int balloon_probe(struct hv_device *dev,
44223 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
44224 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
44225 cap_msg.hdr.size = sizeof(struct dm_capabilities);
44226- cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
44227+ cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44228
44229 cap_msg.caps.cap_bits.balloon = 1;
44230 cap_msg.caps.cap_bits.hot_add = 1;
44231diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
44232index cddc0c9..2eb587d 100644
44233--- a/drivers/hv/hyperv_vmbus.h
44234+++ b/drivers/hv/hyperv_vmbus.h
44235@@ -645,7 +645,7 @@ enum vmbus_connect_state {
44236 struct vmbus_connection {
44237 enum vmbus_connect_state conn_state;
44238
44239- atomic_t next_gpadl_handle;
44240+ atomic_unchecked_t next_gpadl_handle;
44241
44242 struct completion unload_event;
44243 /*
44244diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
44245index 579bdf9..0dac21d5 100644
44246--- a/drivers/hwmon/acpi_power_meter.c
44247+++ b/drivers/hwmon/acpi_power_meter.c
44248@@ -116,7 +116,7 @@ struct sensor_template {
44249 struct device_attribute *devattr,
44250 const char *buf, size_t count);
44251 int index;
44252-};
44253+} __do_const;
44254
44255 /* Averaging interval */
44256 static int update_avg_interval(struct acpi_power_meter_resource *resource)
44257@@ -631,7 +631,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
44258 struct sensor_template *attrs)
44259 {
44260 struct device *dev = &resource->acpi_dev->dev;
44261- struct sensor_device_attribute *sensors =
44262+ sensor_device_attribute_no_const *sensors =
44263 &resource->sensors[resource->num_sensors];
44264 int res = 0;
44265
44266@@ -973,7 +973,7 @@ static int __init enable_cap_knobs(const struct dmi_system_id *d)
44267 return 0;
44268 }
44269
44270-static struct dmi_system_id __initdata pm_dmi_table[] = {
44271+static const struct dmi_system_id __initconst pm_dmi_table[] = {
44272 {
44273 enable_cap_knobs, "IBM Active Energy Manager",
44274 {
44275diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
44276index 0af63da..05a183a 100644
44277--- a/drivers/hwmon/applesmc.c
44278+++ b/drivers/hwmon/applesmc.c
44279@@ -1105,7 +1105,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
44280 {
44281 struct applesmc_node_group *grp;
44282 struct applesmc_dev_attr *node;
44283- struct attribute *attr;
44284+ attribute_no_const *attr;
44285 int ret, i;
44286
44287 for (grp = groups; grp->format; grp++) {
44288diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
44289index cccef87..06ce8ec 100644
44290--- a/drivers/hwmon/asus_atk0110.c
44291+++ b/drivers/hwmon/asus_atk0110.c
44292@@ -147,10 +147,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
44293 struct atk_sensor_data {
44294 struct list_head list;
44295 struct atk_data *data;
44296- struct device_attribute label_attr;
44297- struct device_attribute input_attr;
44298- struct device_attribute limit1_attr;
44299- struct device_attribute limit2_attr;
44300+ device_attribute_no_const label_attr;
44301+ device_attribute_no_const input_attr;
44302+ device_attribute_no_const limit1_attr;
44303+ device_attribute_no_const limit2_attr;
44304 char label_attr_name[ATTR_NAME_SIZE];
44305 char input_attr_name[ATTR_NAME_SIZE];
44306 char limit1_attr_name[ATTR_NAME_SIZE];
44307@@ -270,7 +270,7 @@ static ssize_t atk_name_show(struct device *dev,
44308 static struct device_attribute atk_name_attr =
44309 __ATTR(name, 0444, atk_name_show, NULL);
44310
44311-static void atk_init_attribute(struct device_attribute *attr, char *name,
44312+static void atk_init_attribute(device_attribute_no_const *attr, char *name,
44313 sysfs_show_func show)
44314 {
44315 sysfs_attr_init(&attr->attr);
44316diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
44317index 3e03379..ec521d3 100644
44318--- a/drivers/hwmon/coretemp.c
44319+++ b/drivers/hwmon/coretemp.c
44320@@ -783,7 +783,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
44321 return NOTIFY_OK;
44322 }
44323
44324-static struct notifier_block coretemp_cpu_notifier __refdata = {
44325+static struct notifier_block coretemp_cpu_notifier = {
44326 .notifier_call = coretemp_cpu_callback,
44327 };
44328
44329diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
44330index c848789..e9e9217 100644
44331--- a/drivers/hwmon/dell-smm-hwmon.c
44332+++ b/drivers/hwmon/dell-smm-hwmon.c
44333@@ -819,7 +819,7 @@ static const struct i8k_config_data i8k_config_data[] = {
44334 },
44335 };
44336
44337-static struct dmi_system_id i8k_dmi_table[] __initdata = {
44338+static const struct dmi_system_id i8k_dmi_table[] __initconst = {
44339 {
44340 .ident = "Dell Inspiron",
44341 .matches = {
44342diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
44343index 7a8a6fb..015c1fd 100644
44344--- a/drivers/hwmon/ibmaem.c
44345+++ b/drivers/hwmon/ibmaem.c
44346@@ -924,7 +924,7 @@ static int aem_register_sensors(struct aem_data *data,
44347 struct aem_rw_sensor_template *rw)
44348 {
44349 struct device *dev = &data->pdev->dev;
44350- struct sensor_device_attribute *sensors = data->sensors;
44351+ sensor_device_attribute_no_const *sensors = data->sensors;
44352 int err;
44353
44354 /* Set up read-only sensors */
44355diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
44356index 17ae2eb..21b71dd 100644
44357--- a/drivers/hwmon/iio_hwmon.c
44358+++ b/drivers/hwmon/iio_hwmon.c
44359@@ -61,7 +61,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
44360 {
44361 struct device *dev = &pdev->dev;
44362 struct iio_hwmon_state *st;
44363- struct sensor_device_attribute *a;
44364+ sensor_device_attribute_no_const *a;
44365 int ret, i;
44366 int in_i = 1, temp_i = 1, curr_i = 1, humidity_i = 1;
44367 enum iio_chan_type type;
44368diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
44369index 37f0170..414ec2c 100644
44370--- a/drivers/hwmon/nct6683.c
44371+++ b/drivers/hwmon/nct6683.c
44372@@ -397,11 +397,11 @@ static struct attribute_group *
44373 nct6683_create_attr_group(struct device *dev, struct sensor_template_group *tg,
44374 int repeat)
44375 {
44376- struct sensor_device_attribute_2 *a2;
44377- struct sensor_device_attribute *a;
44378+ sensor_device_attribute_2_no_const *a2;
44379+ sensor_device_attribute_no_const *a;
44380 struct sensor_device_template **t;
44381 struct sensor_device_attr_u *su;
44382- struct attribute_group *group;
44383+ attribute_group_no_const *group;
44384 struct attribute **attrs;
44385 int i, j, count;
44386
44387diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
44388index 2aaedbe..e944f14 100644
44389--- a/drivers/hwmon/nct6775.c
44390+++ b/drivers/hwmon/nct6775.c
44391@@ -957,10 +957,10 @@ static struct attribute_group *
44392 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
44393 int repeat)
44394 {
44395- struct attribute_group *group;
44396+ attribute_group_no_const *group;
44397 struct sensor_device_attr_u *su;
44398- struct sensor_device_attribute *a;
44399- struct sensor_device_attribute_2 *a2;
44400+ sensor_device_attribute_no_const *a;
44401+ sensor_device_attribute_2_no_const *a2;
44402 struct attribute **attrs;
44403 struct sensor_device_template **t;
44404 int i, count;
44405diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
44406index f2e47c7..45d7941 100644
44407--- a/drivers/hwmon/pmbus/pmbus_core.c
44408+++ b/drivers/hwmon/pmbus/pmbus_core.c
44409@@ -816,7 +816,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
44410 return 0;
44411 }
44412
44413-static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
44414+static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
44415 const char *name,
44416 umode_t mode,
44417 ssize_t (*show)(struct device *dev,
44418@@ -833,7 +833,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
44419 dev_attr->store = store;
44420 }
44421
44422-static void pmbus_attr_init(struct sensor_device_attribute *a,
44423+static void pmbus_attr_init(sensor_device_attribute_no_const *a,
44424 const char *name,
44425 umode_t mode,
44426 ssize_t (*show)(struct device *dev,
44427@@ -855,7 +855,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
44428 u16 reg, u8 mask)
44429 {
44430 struct pmbus_boolean *boolean;
44431- struct sensor_device_attribute *a;
44432+ sensor_device_attribute_no_const *a;
44433
44434 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
44435 if (!boolean)
44436@@ -880,7 +880,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
44437 bool update, bool readonly)
44438 {
44439 struct pmbus_sensor *sensor;
44440- struct device_attribute *a;
44441+ device_attribute_no_const *a;
44442
44443 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
44444 if (!sensor)
44445@@ -911,7 +911,7 @@ static int pmbus_add_label(struct pmbus_data *data,
44446 const char *lstring, int index)
44447 {
44448 struct pmbus_label *label;
44449- struct device_attribute *a;
44450+ device_attribute_no_const *a;
44451
44452 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
44453 if (!label)
44454diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
44455index 497a7f8..3fffedf 100644
44456--- a/drivers/hwmon/sht15.c
44457+++ b/drivers/hwmon/sht15.c
44458@@ -169,7 +169,7 @@ struct sht15_data {
44459 int supply_uv;
44460 bool supply_uv_valid;
44461 struct work_struct update_supply_work;
44462- atomic_t interrupt_handled;
44463+ atomic_unchecked_t interrupt_handled;
44464 };
44465
44466 /**
44467@@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
44468 ret = gpio_direction_input(data->pdata->gpio_data);
44469 if (ret)
44470 return ret;
44471- atomic_set(&data->interrupt_handled, 0);
44472+ atomic_set_unchecked(&data->interrupt_handled, 0);
44473
44474 enable_irq(gpio_to_irq(data->pdata->gpio_data));
44475 if (gpio_get_value(data->pdata->gpio_data) == 0) {
44476 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
44477 /* Only relevant if the interrupt hasn't occurred. */
44478- if (!atomic_read(&data->interrupt_handled))
44479+ if (!atomic_read_unchecked(&data->interrupt_handled))
44480 schedule_work(&data->read_work);
44481 }
44482 ret = wait_event_timeout(data->wait_queue,
44483@@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
44484
44485 /* First disable the interrupt */
44486 disable_irq_nosync(irq);
44487- atomic_inc(&data->interrupt_handled);
44488+ atomic_inc_unchecked(&data->interrupt_handled);
44489 /* Then schedule a reading work struct */
44490 if (data->state != SHT15_READING_NOTHING)
44491 schedule_work(&data->read_work);
44492@@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
44493 * If not, then start the interrupt again - care here as could
44494 * have gone low in meantime so verify it hasn't!
44495 */
44496- atomic_set(&data->interrupt_handled, 0);
44497+ atomic_set_unchecked(&data->interrupt_handled, 0);
44498 enable_irq(gpio_to_irq(data->pdata->gpio_data));
44499 /* If still not occurred or another handler was scheduled */
44500 if (gpio_get_value(data->pdata->gpio_data)
44501- || atomic_read(&data->interrupt_handled))
44502+ || atomic_read_unchecked(&data->interrupt_handled))
44503 return;
44504 }
44505
44506diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
44507index ac91c07..8e69663 100644
44508--- a/drivers/hwmon/via-cputemp.c
44509+++ b/drivers/hwmon/via-cputemp.c
44510@@ -295,7 +295,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
44511 return NOTIFY_OK;
44512 }
44513
44514-static struct notifier_block via_cputemp_cpu_notifier __refdata = {
44515+static struct notifier_block via_cputemp_cpu_notifier = {
44516 .notifier_call = via_cputemp_cpu_callback,
44517 };
44518
44519diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
44520index 65e3240..e6c511d 100644
44521--- a/drivers/i2c/busses/i2c-amd756-s4882.c
44522+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
44523@@ -39,7 +39,7 @@
44524 extern struct i2c_adapter amd756_smbus;
44525
44526 static struct i2c_adapter *s4882_adapter;
44527-static struct i2c_algorithm *s4882_algo;
44528+static i2c_algorithm_no_const *s4882_algo;
44529
44530 /* Wrapper access functions for multiplexed SMBus */
44531 static DEFINE_MUTEX(amd756_lock);
44532diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
44533index 88eda09..cf40434 100644
44534--- a/drivers/i2c/busses/i2c-nforce2-s4985.c
44535+++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
44536@@ -37,7 +37,7 @@
44537 extern struct i2c_adapter *nforce2_smbus;
44538
44539 static struct i2c_adapter *s4985_adapter;
44540-static struct i2c_algorithm *s4985_algo;
44541+static i2c_algorithm_no_const *s4985_algo;
44542
44543 /* Wrapper access functions for multiplexed SMBus */
44544 static DEFINE_MUTEX(nforce2_lock);
44545diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
44546index 71c7a39..71dd3e0 100644
44547--- a/drivers/i2c/i2c-dev.c
44548+++ b/drivers/i2c/i2c-dev.c
44549@@ -272,7 +272,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
44550 break;
44551 }
44552
44553- data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
44554+ data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
44555 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
44556 if (IS_ERR(rdwr_pa[i].buf)) {
44557 res = PTR_ERR(rdwr_pa[i].buf);
44558diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
44559index 64a6b82..a524354 100644
44560--- a/drivers/ide/ide-cd.c
44561+++ b/drivers/ide/ide-cd.c
44562@@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
44563 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
44564 if ((unsigned long)buf & alignment
44565 || blk_rq_bytes(rq) & q->dma_pad_mask
44566- || object_is_on_stack(buf))
44567+ || object_starts_on_stack(buf))
44568 drive->dma = 0;
44569 }
44570 }
44571diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
44572index 56b9708..980b63b 100644
44573--- a/drivers/ide/ide-disk.c
44574+++ b/drivers/ide/ide-disk.c
44575@@ -178,7 +178,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
44576 * 1073741822 == 549756 MB or 48bit addressing fake drive
44577 */
44578
44579-static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
44580+static ide_startstop_t __intentional_overflow(-1) ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
44581 sector_t block)
44582 {
44583 ide_hwif_t *hwif = drive->hwif;
44584diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
44585index 3524b0d..8c14520 100644
44586--- a/drivers/iio/industrialio-core.c
44587+++ b/drivers/iio/industrialio-core.c
44588@@ -576,7 +576,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
44589 }
44590
44591 static
44592-int __iio_device_attr_init(struct device_attribute *dev_attr,
44593+int __iio_device_attr_init(device_attribute_no_const *dev_attr,
44594 const char *postfix,
44595 struct iio_chan_spec const *chan,
44596 ssize_t (*readfunc)(struct device *dev,
44597diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
44598index b13936d..65322b2 100644
44599--- a/drivers/iio/magnetometer/ak8975.c
44600+++ b/drivers/iio/magnetometer/ak8975.c
44601@@ -776,7 +776,7 @@ static int ak8975_probe(struct i2c_client *client,
44602 name = id->name;
44603 } else if (ACPI_HANDLE(&client->dev))
44604 name = ak8975_match_acpi_device(&client->dev, &chipset);
44605- else
44606+ if (!name)
44607 return -ENOSYS;
44608
44609 if (chipset >= AK_MAX_TYPE) {
44610diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
44611index 3a972eb..4126183 100644
44612--- a/drivers/infiniband/core/cm.c
44613+++ b/drivers/infiniband/core/cm.c
44614@@ -115,7 +115,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
44615
44616 struct cm_counter_group {
44617 struct kobject obj;
44618- atomic_long_t counter[CM_ATTR_COUNT];
44619+ atomic_long_unchecked_t counter[CM_ATTR_COUNT];
44620 };
44621
44622 struct cm_counter_attribute {
44623@@ -1411,7 +1411,7 @@ static void cm_dup_req_handler(struct cm_work *work,
44624 struct ib_mad_send_buf *msg = NULL;
44625 int ret;
44626
44627- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44628+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44629 counter[CM_REQ_COUNTER]);
44630
44631 /* Quick state check to discard duplicate REQs. */
44632@@ -1798,7 +1798,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
44633 if (!cm_id_priv)
44634 return;
44635
44636- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44637+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44638 counter[CM_REP_COUNTER]);
44639 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
44640 if (ret)
44641@@ -1965,7 +1965,7 @@ static int cm_rtu_handler(struct cm_work *work)
44642 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
44643 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
44644 spin_unlock_irq(&cm_id_priv->lock);
44645- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44646+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44647 counter[CM_RTU_COUNTER]);
44648 goto out;
44649 }
44650@@ -2148,7 +2148,7 @@ static int cm_dreq_handler(struct cm_work *work)
44651 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
44652 dreq_msg->local_comm_id);
44653 if (!cm_id_priv) {
44654- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44655+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44656 counter[CM_DREQ_COUNTER]);
44657 cm_issue_drep(work->port, work->mad_recv_wc);
44658 return -EINVAL;
44659@@ -2173,7 +2173,7 @@ static int cm_dreq_handler(struct cm_work *work)
44660 case IB_CM_MRA_REP_RCVD:
44661 break;
44662 case IB_CM_TIMEWAIT:
44663- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44664+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44665 counter[CM_DREQ_COUNTER]);
44666 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
44667 goto unlock;
44668@@ -2187,7 +2187,7 @@ static int cm_dreq_handler(struct cm_work *work)
44669 cm_free_msg(msg);
44670 goto deref;
44671 case IB_CM_DREQ_RCVD:
44672- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44673+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44674 counter[CM_DREQ_COUNTER]);
44675 goto unlock;
44676 default:
44677@@ -2554,7 +2554,7 @@ static int cm_mra_handler(struct cm_work *work)
44678 ib_modify_mad(cm_id_priv->av.port->mad_agent,
44679 cm_id_priv->msg, timeout)) {
44680 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
44681- atomic_long_inc(&work->port->
44682+ atomic_long_inc_unchecked(&work->port->
44683 counter_group[CM_RECV_DUPLICATES].
44684 counter[CM_MRA_COUNTER]);
44685 goto out;
44686@@ -2563,7 +2563,7 @@ static int cm_mra_handler(struct cm_work *work)
44687 break;
44688 case IB_CM_MRA_REQ_RCVD:
44689 case IB_CM_MRA_REP_RCVD:
44690- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44691+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44692 counter[CM_MRA_COUNTER]);
44693 /* fall through */
44694 default:
44695@@ -2725,7 +2725,7 @@ static int cm_lap_handler(struct cm_work *work)
44696 case IB_CM_LAP_IDLE:
44697 break;
44698 case IB_CM_MRA_LAP_SENT:
44699- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44700+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44701 counter[CM_LAP_COUNTER]);
44702 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
44703 goto unlock;
44704@@ -2741,7 +2741,7 @@ static int cm_lap_handler(struct cm_work *work)
44705 cm_free_msg(msg);
44706 goto deref;
44707 case IB_CM_LAP_RCVD:
44708- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44709+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44710 counter[CM_LAP_COUNTER]);
44711 goto unlock;
44712 default:
44713@@ -3025,7 +3025,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
44714 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
44715 if (cur_cm_id_priv) {
44716 spin_unlock_irq(&cm.lock);
44717- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44718+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44719 counter[CM_SIDR_REQ_COUNTER]);
44720 goto out; /* Duplicate message. */
44721 }
44722@@ -3237,10 +3237,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
44723 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
44724 msg->retries = 1;
44725
44726- atomic_long_add(1 + msg->retries,
44727+ atomic_long_add_unchecked(1 + msg->retries,
44728 &port->counter_group[CM_XMIT].counter[attr_index]);
44729 if (msg->retries)
44730- atomic_long_add(msg->retries,
44731+ atomic_long_add_unchecked(msg->retries,
44732 &port->counter_group[CM_XMIT_RETRIES].
44733 counter[attr_index]);
44734
44735@@ -3466,7 +3466,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
44736 }
44737
44738 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
44739- atomic_long_inc(&port->counter_group[CM_RECV].
44740+ atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
44741 counter[attr_id - CM_ATTR_ID_OFFSET]);
44742
44743 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
44744@@ -3709,7 +3709,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
44745 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
44746
44747 return sprintf(buf, "%ld\n",
44748- atomic_long_read(&group->counter[cm_attr->index]));
44749+ atomic_long_read_unchecked(&group->counter[cm_attr->index]));
44750 }
44751
44752 static const struct sysfs_ops cm_counter_ops = {
44753diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
44754index 9f5ad7c..588cd84 100644
44755--- a/drivers/infiniband/core/fmr_pool.c
44756+++ b/drivers/infiniband/core/fmr_pool.c
44757@@ -98,8 +98,8 @@ struct ib_fmr_pool {
44758
44759 struct task_struct *thread;
44760
44761- atomic_t req_ser;
44762- atomic_t flush_ser;
44763+ atomic_unchecked_t req_ser;
44764+ atomic_unchecked_t flush_ser;
44765
44766 wait_queue_head_t force_wait;
44767 };
44768@@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
44769 struct ib_fmr_pool *pool = pool_ptr;
44770
44771 do {
44772- if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
44773+ if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
44774 ib_fmr_batch_release(pool);
44775
44776- atomic_inc(&pool->flush_ser);
44777+ atomic_inc_unchecked(&pool->flush_ser);
44778 wake_up_interruptible(&pool->force_wait);
44779
44780 if (pool->flush_function)
44781@@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
44782 }
44783
44784 set_current_state(TASK_INTERRUPTIBLE);
44785- if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
44786+ if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
44787 !kthread_should_stop())
44788 schedule();
44789 __set_current_state(TASK_RUNNING);
44790@@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
44791 pool->dirty_watermark = params->dirty_watermark;
44792 pool->dirty_len = 0;
44793 spin_lock_init(&pool->pool_lock);
44794- atomic_set(&pool->req_ser, 0);
44795- atomic_set(&pool->flush_ser, 0);
44796+ atomic_set_unchecked(&pool->req_ser, 0);
44797+ atomic_set_unchecked(&pool->flush_ser, 0);
44798 init_waitqueue_head(&pool->force_wait);
44799
44800 pool->thread = kthread_run(ib_fmr_cleanup_thread,
44801@@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
44802 }
44803 spin_unlock_irq(&pool->pool_lock);
44804
44805- serial = atomic_inc_return(&pool->req_ser);
44806+ serial = atomic_inc_return_unchecked(&pool->req_ser);
44807 wake_up_process(pool->thread);
44808
44809 if (wait_event_interruptible(pool->force_wait,
44810- atomic_read(&pool->flush_ser) - serial >= 0))
44811+ atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
44812 return -EINTR;
44813
44814 return 0;
44815@@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
44816 } else {
44817 list_add_tail(&fmr->list, &pool->dirty_list);
44818 if (++pool->dirty_len >= pool->dirty_watermark) {
44819- atomic_inc(&pool->req_ser);
44820+ atomic_inc_unchecked(&pool->req_ser);
44821 wake_up_process(pool->thread);
44822 }
44823 }
44824diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
44825index a6ca83b..bd3a726 100644
44826--- a/drivers/infiniband/core/uverbs_cmd.c
44827+++ b/drivers/infiniband/core/uverbs_cmd.c
44828@@ -951,6 +951,9 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
44829 if (copy_from_user(&cmd, buf, sizeof cmd))
44830 return -EFAULT;
44831
44832+ if (!access_ok_noprefault(VERIFY_READ, cmd.start, cmd.length))
44833+ return -EFAULT;
44834+
44835 INIT_UDATA(&udata, buf + sizeof cmd,
44836 (unsigned long) cmd.response + sizeof resp,
44837 in_len - sizeof cmd, out_len - sizeof resp);
44838diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
44839index cff815b..75576dd 100644
44840--- a/drivers/infiniband/hw/cxgb4/mem.c
44841+++ b/drivers/infiniband/hw/cxgb4/mem.c
44842@@ -256,7 +256,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
44843 int err;
44844 struct fw_ri_tpte tpt;
44845 u32 stag_idx;
44846- static atomic_t key;
44847+ static atomic_unchecked_t key;
44848
44849 if (c4iw_fatal_error(rdev))
44850 return -EIO;
44851@@ -277,7 +277,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
44852 if (rdev->stats.stag.cur > rdev->stats.stag.max)
44853 rdev->stats.stag.max = rdev->stats.stag.cur;
44854 mutex_unlock(&rdev->stats.lock);
44855- *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
44856+ *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
44857 }
44858 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
44859 __func__, stag_state, type, pdid, stag_idx);
44860diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
44861index 79b3dbc..96e5fcc 100644
44862--- a/drivers/infiniband/hw/ipath/ipath_rc.c
44863+++ b/drivers/infiniband/hw/ipath/ipath_rc.c
44864@@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
44865 struct ib_atomic_eth *ateth;
44866 struct ipath_ack_entry *e;
44867 u64 vaddr;
44868- atomic64_t *maddr;
44869+ atomic64_unchecked_t *maddr;
44870 u64 sdata;
44871 u32 rkey;
44872 u8 next;
44873@@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
44874 IB_ACCESS_REMOTE_ATOMIC)))
44875 goto nack_acc_unlck;
44876 /* Perform atomic OP and save result. */
44877- maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
44878+ maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
44879 sdata = be64_to_cpu(ateth->swap_data);
44880 e = &qp->s_ack_queue[qp->r_head_ack_queue];
44881 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
44882- (u64) atomic64_add_return(sdata, maddr) - sdata :
44883+ (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
44884 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
44885 be64_to_cpu(ateth->compare_data),
44886 sdata);
44887diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
44888index 1f95bba..9530f87 100644
44889--- a/drivers/infiniband/hw/ipath/ipath_ruc.c
44890+++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
44891@@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
44892 unsigned long flags;
44893 struct ib_wc wc;
44894 u64 sdata;
44895- atomic64_t *maddr;
44896+ atomic64_unchecked_t *maddr;
44897 enum ib_wc_status send_status;
44898
44899 /*
44900@@ -382,11 +382,11 @@ again:
44901 IB_ACCESS_REMOTE_ATOMIC)))
44902 goto acc_err;
44903 /* Perform atomic OP and save result. */
44904- maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
44905+ maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
44906 sdata = wqe->wr.wr.atomic.compare_add;
44907 *(u64 *) sqp->s_sge.sge.vaddr =
44908 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
44909- (u64) atomic64_add_return(sdata, maddr) - sdata :
44910+ (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
44911 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
44912 sdata, wqe->wr.wr.atomic.swap);
44913 goto send_comp;
44914diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
44915index 68b3dfa..3e0c511 100644
44916--- a/drivers/infiniband/hw/mlx4/mad.c
44917+++ b/drivers/infiniband/hw/mlx4/mad.c
44918@@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
44919
44920 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
44921 {
44922- return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
44923+ return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
44924 cpu_to_be64(0xff00000000000000LL);
44925 }
44926
44927diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
44928index a0559a8..86a2320 100644
44929--- a/drivers/infiniband/hw/mlx4/mcg.c
44930+++ b/drivers/infiniband/hw/mlx4/mcg.c
44931@@ -1042,7 +1042,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
44932 {
44933 char name[20];
44934
44935- atomic_set(&ctx->tid, 0);
44936+ atomic_set_unchecked(&ctx->tid, 0);
44937 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
44938 ctx->mcg_wq = create_singlethread_workqueue(name);
44939 if (!ctx->mcg_wq)
44940diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
44941index 334387f..e640d74 100644
44942--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
44943+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
44944@@ -436,7 +436,7 @@ struct mlx4_ib_demux_ctx {
44945 struct list_head mcg_mgid0_list;
44946 struct workqueue_struct *mcg_wq;
44947 struct mlx4_ib_demux_pv_ctx **tun;
44948- atomic_t tid;
44949+ atomic_unchecked_t tid;
44950 int flushing; /* flushing the work queue */
44951 };
44952
44953diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
44954index c7f49bb..6a021bb 100644
44955--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
44956+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
44957@@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
44958 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
44959 }
44960
44961-int mthca_QUERY_FW(struct mthca_dev *dev)
44962+int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
44963 {
44964 struct mthca_mailbox *mailbox;
44965 u32 *outbox;
44966@@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
44967 CMD_TIME_CLASS_B);
44968 }
44969
44970-int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
44971+int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
44972 int num_mtt)
44973 {
44974 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
44975@@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
44976 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
44977 }
44978
44979-int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
44980+int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
44981 int eq_num)
44982 {
44983 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
44984@@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
44985 CMD_TIME_CLASS_B);
44986 }
44987
44988-int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
44989+int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
44990 int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
44991 const void *in_mad, void *response_mad)
44992 {
44993diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
44994index ded76c1..0cf0a08 100644
44995--- a/drivers/infiniband/hw/mthca/mthca_main.c
44996+++ b/drivers/infiniband/hw/mthca/mthca_main.c
44997@@ -692,7 +692,7 @@ err_close:
44998 return err;
44999 }
45000
45001-static int mthca_setup_hca(struct mthca_dev *dev)
45002+static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
45003 {
45004 int err;
45005
45006diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
45007index ed9a989..6aa5dc2 100644
45008--- a/drivers/infiniband/hw/mthca/mthca_mr.c
45009+++ b/drivers/infiniband/hw/mthca/mthca_mr.c
45010@@ -81,7 +81,7 @@ struct mthca_mpt_entry {
45011 * through the bitmaps)
45012 */
45013
45014-static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
45015+static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
45016 {
45017 int o;
45018 int m;
45019@@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
45020 return key;
45021 }
45022
45023-int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
45024+int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
45025 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
45026 {
45027 struct mthca_mailbox *mailbox;
45028@@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
45029 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
45030 }
45031
45032-int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
45033+int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
45034 u64 *buffer_list, int buffer_size_shift,
45035 int list_len, u64 iova, u64 total_size,
45036 u32 access, struct mthca_mr *mr)
45037diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
45038index 93ae51d..84c4a44 100644
45039--- a/drivers/infiniband/hw/mthca/mthca_provider.c
45040+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
45041@@ -771,7 +771,7 @@ unlock:
45042 return 0;
45043 }
45044
45045-static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
45046+static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
45047 {
45048 struct mthca_dev *dev = to_mdev(ibcq->device);
45049 struct mthca_cq *cq = to_mcq(ibcq);
45050diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
45051index 9f9d5c5..3c19aac 100644
45052--- a/drivers/infiniband/hw/nes/nes.c
45053+++ b/drivers/infiniband/hw/nes/nes.c
45054@@ -97,7 +97,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
45055 LIST_HEAD(nes_adapter_list);
45056 static LIST_HEAD(nes_dev_list);
45057
45058-atomic_t qps_destroyed;
45059+atomic_unchecked_t qps_destroyed;
45060
45061 static unsigned int ee_flsh_adapter;
45062 static unsigned int sysfs_nonidx_addr;
45063@@ -279,7 +279,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
45064 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
45065 struct nes_adapter *nesadapter = nesdev->nesadapter;
45066
45067- atomic_inc(&qps_destroyed);
45068+ atomic_inc_unchecked(&qps_destroyed);
45069
45070 /* Free the control structures */
45071
45072diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
45073index bd9d132..70d84f4 100644
45074--- a/drivers/infiniband/hw/nes/nes.h
45075+++ b/drivers/infiniband/hw/nes/nes.h
45076@@ -180,17 +180,17 @@ extern unsigned int nes_debug_level;
45077 extern unsigned int wqm_quanta;
45078 extern struct list_head nes_adapter_list;
45079
45080-extern atomic_t cm_connects;
45081-extern atomic_t cm_accepts;
45082-extern atomic_t cm_disconnects;
45083-extern atomic_t cm_closes;
45084-extern atomic_t cm_connecteds;
45085-extern atomic_t cm_connect_reqs;
45086-extern atomic_t cm_rejects;
45087-extern atomic_t mod_qp_timouts;
45088-extern atomic_t qps_created;
45089-extern atomic_t qps_destroyed;
45090-extern atomic_t sw_qps_destroyed;
45091+extern atomic_unchecked_t cm_connects;
45092+extern atomic_unchecked_t cm_accepts;
45093+extern atomic_unchecked_t cm_disconnects;
45094+extern atomic_unchecked_t cm_closes;
45095+extern atomic_unchecked_t cm_connecteds;
45096+extern atomic_unchecked_t cm_connect_reqs;
45097+extern atomic_unchecked_t cm_rejects;
45098+extern atomic_unchecked_t mod_qp_timouts;
45099+extern atomic_unchecked_t qps_created;
45100+extern atomic_unchecked_t qps_destroyed;
45101+extern atomic_unchecked_t sw_qps_destroyed;
45102 extern u32 mh_detected;
45103 extern u32 mh_pauses_sent;
45104 extern u32 cm_packets_sent;
45105@@ -199,16 +199,16 @@ extern u32 cm_packets_created;
45106 extern u32 cm_packets_received;
45107 extern u32 cm_packets_dropped;
45108 extern u32 cm_packets_retrans;
45109-extern atomic_t cm_listens_created;
45110-extern atomic_t cm_listens_destroyed;
45111+extern atomic_unchecked_t cm_listens_created;
45112+extern atomic_unchecked_t cm_listens_destroyed;
45113 extern u32 cm_backlog_drops;
45114-extern atomic_t cm_loopbacks;
45115-extern atomic_t cm_nodes_created;
45116-extern atomic_t cm_nodes_destroyed;
45117-extern atomic_t cm_accel_dropped_pkts;
45118-extern atomic_t cm_resets_recvd;
45119-extern atomic_t pau_qps_created;
45120-extern atomic_t pau_qps_destroyed;
45121+extern atomic_unchecked_t cm_loopbacks;
45122+extern atomic_unchecked_t cm_nodes_created;
45123+extern atomic_unchecked_t cm_nodes_destroyed;
45124+extern atomic_unchecked_t cm_accel_dropped_pkts;
45125+extern atomic_unchecked_t cm_resets_recvd;
45126+extern atomic_unchecked_t pau_qps_created;
45127+extern atomic_unchecked_t pau_qps_destroyed;
45128
45129 extern u32 int_mod_timer_init;
45130 extern u32 int_mod_cq_depth_256;
45131diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
45132index 8a3ad17..e1ed4bc 100644
45133--- a/drivers/infiniband/hw/nes/nes_cm.c
45134+++ b/drivers/infiniband/hw/nes/nes_cm.c
45135@@ -69,14 +69,14 @@ u32 cm_packets_dropped;
45136 u32 cm_packets_retrans;
45137 u32 cm_packets_created;
45138 u32 cm_packets_received;
45139-atomic_t cm_listens_created;
45140-atomic_t cm_listens_destroyed;
45141+atomic_unchecked_t cm_listens_created;
45142+atomic_unchecked_t cm_listens_destroyed;
45143 u32 cm_backlog_drops;
45144-atomic_t cm_loopbacks;
45145-atomic_t cm_nodes_created;
45146-atomic_t cm_nodes_destroyed;
45147-atomic_t cm_accel_dropped_pkts;
45148-atomic_t cm_resets_recvd;
45149+atomic_unchecked_t cm_loopbacks;
45150+atomic_unchecked_t cm_nodes_created;
45151+atomic_unchecked_t cm_nodes_destroyed;
45152+atomic_unchecked_t cm_accel_dropped_pkts;
45153+atomic_unchecked_t cm_resets_recvd;
45154
45155 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
45156 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
45157@@ -135,28 +135,28 @@ static void record_ird_ord(struct nes_cm_node *, u16, u16);
45158 /* instance of function pointers for client API */
45159 /* set address of this instance to cm_core->cm_ops at cm_core alloc */
45160 static struct nes_cm_ops nes_cm_api = {
45161- mini_cm_accelerated,
45162- mini_cm_listen,
45163- mini_cm_del_listen,
45164- mini_cm_connect,
45165- mini_cm_close,
45166- mini_cm_accept,
45167- mini_cm_reject,
45168- mini_cm_recv_pkt,
45169- mini_cm_dealloc_core,
45170- mini_cm_get,
45171- mini_cm_set
45172+ .accelerated = mini_cm_accelerated,
45173+ .listen = mini_cm_listen,
45174+ .stop_listener = mini_cm_del_listen,
45175+ .connect = mini_cm_connect,
45176+ .close = mini_cm_close,
45177+ .accept = mini_cm_accept,
45178+ .reject = mini_cm_reject,
45179+ .recv_pkt = mini_cm_recv_pkt,
45180+ .destroy_cm_core = mini_cm_dealloc_core,
45181+ .get = mini_cm_get,
45182+ .set = mini_cm_set
45183 };
45184
45185 static struct nes_cm_core *g_cm_core;
45186
45187-atomic_t cm_connects;
45188-atomic_t cm_accepts;
45189-atomic_t cm_disconnects;
45190-atomic_t cm_closes;
45191-atomic_t cm_connecteds;
45192-atomic_t cm_connect_reqs;
45193-atomic_t cm_rejects;
45194+atomic_unchecked_t cm_connects;
45195+atomic_unchecked_t cm_accepts;
45196+atomic_unchecked_t cm_disconnects;
45197+atomic_unchecked_t cm_closes;
45198+atomic_unchecked_t cm_connecteds;
45199+atomic_unchecked_t cm_connect_reqs;
45200+atomic_unchecked_t cm_rejects;
45201
45202 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
45203 {
45204@@ -1461,7 +1461,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
45205 kfree(listener);
45206 listener = NULL;
45207 ret = 0;
45208- atomic_inc(&cm_listens_destroyed);
45209+ atomic_inc_unchecked(&cm_listens_destroyed);
45210 } else {
45211 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
45212 }
45213@@ -1670,7 +1670,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
45214 cm_node->rem_mac);
45215
45216 add_hte_node(cm_core, cm_node);
45217- atomic_inc(&cm_nodes_created);
45218+ atomic_inc_unchecked(&cm_nodes_created);
45219
45220 return cm_node;
45221 }
45222@@ -1731,7 +1731,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
45223 }
45224
45225 atomic_dec(&cm_core->node_cnt);
45226- atomic_inc(&cm_nodes_destroyed);
45227+ atomic_inc_unchecked(&cm_nodes_destroyed);
45228 nesqp = cm_node->nesqp;
45229 if (nesqp) {
45230 nesqp->cm_node = NULL;
45231@@ -1795,7 +1795,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
45232
45233 static void drop_packet(struct sk_buff *skb)
45234 {
45235- atomic_inc(&cm_accel_dropped_pkts);
45236+ atomic_inc_unchecked(&cm_accel_dropped_pkts);
45237 dev_kfree_skb_any(skb);
45238 }
45239
45240@@ -1858,7 +1858,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
45241 {
45242
45243 int reset = 0; /* whether to send reset in case of err.. */
45244- atomic_inc(&cm_resets_recvd);
45245+ atomic_inc_unchecked(&cm_resets_recvd);
45246 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
45247 " refcnt=%d\n", cm_node, cm_node->state,
45248 atomic_read(&cm_node->ref_count));
45249@@ -2526,7 +2526,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
45250 rem_ref_cm_node(cm_node->cm_core, cm_node);
45251 return NULL;
45252 }
45253- atomic_inc(&cm_loopbacks);
45254+ atomic_inc_unchecked(&cm_loopbacks);
45255 loopbackremotenode->loopbackpartner = cm_node;
45256 loopbackremotenode->tcp_cntxt.rcv_wscale =
45257 NES_CM_DEFAULT_RCV_WND_SCALE;
45258@@ -2807,7 +2807,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
45259 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
45260 else {
45261 rem_ref_cm_node(cm_core, cm_node);
45262- atomic_inc(&cm_accel_dropped_pkts);
45263+ atomic_inc_unchecked(&cm_accel_dropped_pkts);
45264 dev_kfree_skb_any(skb);
45265 }
45266 break;
45267@@ -3118,7 +3118,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
45268
45269 if ((cm_id) && (cm_id->event_handler)) {
45270 if (issue_disconn) {
45271- atomic_inc(&cm_disconnects);
45272+ atomic_inc_unchecked(&cm_disconnects);
45273 cm_event.event = IW_CM_EVENT_DISCONNECT;
45274 cm_event.status = disconn_status;
45275 cm_event.local_addr = cm_id->local_addr;
45276@@ -3140,7 +3140,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
45277 }
45278
45279 if (issue_close) {
45280- atomic_inc(&cm_closes);
45281+ atomic_inc_unchecked(&cm_closes);
45282 nes_disconnect(nesqp, 1);
45283
45284 cm_id->provider_data = nesqp;
45285@@ -3278,7 +3278,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
45286
45287 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
45288 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
45289- atomic_inc(&cm_accepts);
45290+ atomic_inc_unchecked(&cm_accepts);
45291
45292 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
45293 netdev_refcnt_read(nesvnic->netdev));
45294@@ -3476,7 +3476,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
45295 struct nes_cm_core *cm_core;
45296 u8 *start_buff;
45297
45298- atomic_inc(&cm_rejects);
45299+ atomic_inc_unchecked(&cm_rejects);
45300 cm_node = (struct nes_cm_node *)cm_id->provider_data;
45301 loopback = cm_node->loopbackpartner;
45302 cm_core = cm_node->cm_core;
45303@@ -3541,7 +3541,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
45304 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
45305 ntohs(laddr->sin_port));
45306
45307- atomic_inc(&cm_connects);
45308+ atomic_inc_unchecked(&cm_connects);
45309 nesqp->active_conn = 1;
45310
45311 /* cache the cm_id in the qp */
45312@@ -3688,7 +3688,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
45313 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
45314 return err;
45315 }
45316- atomic_inc(&cm_listens_created);
45317+ atomic_inc_unchecked(&cm_listens_created);
45318 }
45319
45320 cm_id->add_ref(cm_id);
45321@@ -3795,7 +3795,7 @@ static void cm_event_connected(struct nes_cm_event *event)
45322
45323 if (nesqp->destroyed)
45324 return;
45325- atomic_inc(&cm_connecteds);
45326+ atomic_inc_unchecked(&cm_connecteds);
45327 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
45328 " local port 0x%04X. jiffies = %lu.\n",
45329 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
45330@@ -3980,7 +3980,7 @@ static void cm_event_reset(struct nes_cm_event *event)
45331
45332 cm_id->add_ref(cm_id);
45333 ret = cm_id->event_handler(cm_id, &cm_event);
45334- atomic_inc(&cm_closes);
45335+ atomic_inc_unchecked(&cm_closes);
45336 cm_event.event = IW_CM_EVENT_CLOSE;
45337 cm_event.status = 0;
45338 cm_event.provider_data = cm_id->provider_data;
45339@@ -4020,7 +4020,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
45340 return;
45341 cm_id = cm_node->cm_id;
45342
45343- atomic_inc(&cm_connect_reqs);
45344+ atomic_inc_unchecked(&cm_connect_reqs);
45345 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
45346 cm_node, cm_id, jiffies);
45347
45348@@ -4069,7 +4069,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
45349 return;
45350 cm_id = cm_node->cm_id;
45351
45352- atomic_inc(&cm_connect_reqs);
45353+ atomic_inc_unchecked(&cm_connect_reqs);
45354 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
45355 cm_node, cm_id, jiffies);
45356
45357diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
45358index 4166452..fc952c3 100644
45359--- a/drivers/infiniband/hw/nes/nes_mgt.c
45360+++ b/drivers/infiniband/hw/nes/nes_mgt.c
45361@@ -40,8 +40,8 @@
45362 #include "nes.h"
45363 #include "nes_mgt.h"
45364
45365-atomic_t pau_qps_created;
45366-atomic_t pau_qps_destroyed;
45367+atomic_unchecked_t pau_qps_created;
45368+atomic_unchecked_t pau_qps_destroyed;
45369
45370 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
45371 {
45372@@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
45373 {
45374 struct sk_buff *skb;
45375 unsigned long flags;
45376- atomic_inc(&pau_qps_destroyed);
45377+ atomic_inc_unchecked(&pau_qps_destroyed);
45378
45379 /* Free packets that have not yet been forwarded */
45380 /* Lock is acquired by skb_dequeue when removing the skb */
45381@@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
45382 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
45383 skb_queue_head_init(&nesqp->pau_list);
45384 spin_lock_init(&nesqp->pau_lock);
45385- atomic_inc(&pau_qps_created);
45386+ atomic_inc_unchecked(&pau_qps_created);
45387 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
45388 }
45389
45390diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
45391index 70acda9..a96de9d 100644
45392--- a/drivers/infiniband/hw/nes/nes_nic.c
45393+++ b/drivers/infiniband/hw/nes/nes_nic.c
45394@@ -1274,39 +1274,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
45395 target_stat_values[++index] = mh_detected;
45396 target_stat_values[++index] = mh_pauses_sent;
45397 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
45398- target_stat_values[++index] = atomic_read(&cm_connects);
45399- target_stat_values[++index] = atomic_read(&cm_accepts);
45400- target_stat_values[++index] = atomic_read(&cm_disconnects);
45401- target_stat_values[++index] = atomic_read(&cm_connecteds);
45402- target_stat_values[++index] = atomic_read(&cm_connect_reqs);
45403- target_stat_values[++index] = atomic_read(&cm_rejects);
45404- target_stat_values[++index] = atomic_read(&mod_qp_timouts);
45405- target_stat_values[++index] = atomic_read(&qps_created);
45406- target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
45407- target_stat_values[++index] = atomic_read(&qps_destroyed);
45408- target_stat_values[++index] = atomic_read(&cm_closes);
45409+ target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
45410+ target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
45411+ target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
45412+ target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
45413+ target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
45414+ target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
45415+ target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
45416+ target_stat_values[++index] = atomic_read_unchecked(&qps_created);
45417+ target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
45418+ target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
45419+ target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
45420 target_stat_values[++index] = cm_packets_sent;
45421 target_stat_values[++index] = cm_packets_bounced;
45422 target_stat_values[++index] = cm_packets_created;
45423 target_stat_values[++index] = cm_packets_received;
45424 target_stat_values[++index] = cm_packets_dropped;
45425 target_stat_values[++index] = cm_packets_retrans;
45426- target_stat_values[++index] = atomic_read(&cm_listens_created);
45427- target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
45428+ target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
45429+ target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
45430 target_stat_values[++index] = cm_backlog_drops;
45431- target_stat_values[++index] = atomic_read(&cm_loopbacks);
45432- target_stat_values[++index] = atomic_read(&cm_nodes_created);
45433- target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
45434- target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
45435- target_stat_values[++index] = atomic_read(&cm_resets_recvd);
45436+ target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
45437+ target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
45438+ target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
45439+ target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
45440+ target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
45441 target_stat_values[++index] = nesadapter->free_4kpbl;
45442 target_stat_values[++index] = nesadapter->free_256pbl;
45443 target_stat_values[++index] = int_mod_timer_init;
45444 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
45445 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
45446 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
45447- target_stat_values[++index] = atomic_read(&pau_qps_created);
45448- target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
45449+ target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
45450+ target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
45451 }
45452
45453 /**
45454diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
45455index fbc43e5..3672792 100644
45456--- a/drivers/infiniband/hw/nes/nes_verbs.c
45457+++ b/drivers/infiniband/hw/nes/nes_verbs.c
45458@@ -46,9 +46,9 @@
45459
45460 #include <rdma/ib_umem.h>
45461
45462-atomic_t mod_qp_timouts;
45463-atomic_t qps_created;
45464-atomic_t sw_qps_destroyed;
45465+atomic_unchecked_t mod_qp_timouts;
45466+atomic_unchecked_t qps_created;
45467+atomic_unchecked_t sw_qps_destroyed;
45468
45469 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
45470
45471@@ -1137,7 +1137,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
45472 if (init_attr->create_flags)
45473 return ERR_PTR(-EINVAL);
45474
45475- atomic_inc(&qps_created);
45476+ atomic_inc_unchecked(&qps_created);
45477 switch (init_attr->qp_type) {
45478 case IB_QPT_RC:
45479 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
45480@@ -1471,7 +1471,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
45481 struct iw_cm_event cm_event;
45482 int ret = 0;
45483
45484- atomic_inc(&sw_qps_destroyed);
45485+ atomic_inc_unchecked(&sw_qps_destroyed);
45486 nesqp->destroyed = 1;
45487
45488 /* Blow away the connection if it exists. */
45489diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
45490index 7df16f7..7e1b21e 100644
45491--- a/drivers/infiniband/hw/qib/qib.h
45492+++ b/drivers/infiniband/hw/qib/qib.h
45493@@ -52,6 +52,7 @@
45494 #include <linux/kref.h>
45495 #include <linux/sched.h>
45496 #include <linux/kthread.h>
45497+#include <linux/slab.h>
45498
45499 #include "qib_common.h"
45500 #include "qib_verbs.h"
45501diff --git a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
45502index cdc7df4..a2fdfdb 100644
45503--- a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
45504+++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
45505@@ -156,7 +156,7 @@ static size_t ipoib_get_size(const struct net_device *dev)
45506 nla_total_size(2); /* IFLA_IPOIB_UMCAST */
45507 }
45508
45509-static struct rtnl_link_ops ipoib_link_ops __read_mostly = {
45510+static struct rtnl_link_ops ipoib_link_ops = {
45511 .kind = "ipoib",
45512 .maxtype = IFLA_IPOIB_MAX,
45513 .policy = ipoib_policy,
45514diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
45515index e853a21..56fc5a8 100644
45516--- a/drivers/input/gameport/gameport.c
45517+++ b/drivers/input/gameport/gameport.c
45518@@ -527,14 +527,14 @@ EXPORT_SYMBOL(gameport_set_phys);
45519 */
45520 static void gameport_init_port(struct gameport *gameport)
45521 {
45522- static atomic_t gameport_no = ATOMIC_INIT(-1);
45523+ static atomic_unchecked_t gameport_no = ATOMIC_INIT(-1);
45524
45525 __module_get(THIS_MODULE);
45526
45527 mutex_init(&gameport->drv_mutex);
45528 device_initialize(&gameport->dev);
45529 dev_set_name(&gameport->dev, "gameport%lu",
45530- (unsigned long)atomic_inc_return(&gameport_no));
45531+ (unsigned long)atomic_inc_return_unchecked(&gameport_no));
45532 gameport->dev.bus = &gameport_bus;
45533 gameport->dev.release = gameport_release_port;
45534 if (gameport->parent)
45535diff --git a/drivers/input/input.c b/drivers/input/input.c
45536index 78d2499..1f0318e 100644
45537--- a/drivers/input/input.c
45538+++ b/drivers/input/input.c
45539@@ -1775,7 +1775,7 @@ EXPORT_SYMBOL_GPL(input_class);
45540 */
45541 struct input_dev *input_allocate_device(void)
45542 {
45543- static atomic_t input_no = ATOMIC_INIT(-1);
45544+ static atomic_unchecked_t input_no = ATOMIC_INIT(-1);
45545 struct input_dev *dev;
45546
45547 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
45548@@ -1790,7 +1790,7 @@ struct input_dev *input_allocate_device(void)
45549 INIT_LIST_HEAD(&dev->node);
45550
45551 dev_set_name(&dev->dev, "input%lu",
45552- (unsigned long)atomic_inc_return(&input_no));
45553+ (unsigned long)atomic_inc_return_unchecked(&input_no));
45554
45555 __module_get(THIS_MODULE);
45556 }
45557diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
45558index 4a95b22..874c182 100644
45559--- a/drivers/input/joystick/sidewinder.c
45560+++ b/drivers/input/joystick/sidewinder.c
45561@@ -30,6 +30,7 @@
45562 #include <linux/kernel.h>
45563 #include <linux/module.h>
45564 #include <linux/slab.h>
45565+#include <linux/sched.h>
45566 #include <linux/input.h>
45567 #include <linux/gameport.h>
45568 #include <linux/jiffies.h>
45569diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
45570index f8850f9..9708a2d 100644
45571--- a/drivers/input/joystick/xpad.c
45572+++ b/drivers/input/joystick/xpad.c
45573@@ -959,7 +959,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
45574
45575 static int xpad_led_probe(struct usb_xpad *xpad)
45576 {
45577- static atomic_t led_seq = ATOMIC_INIT(-1);
45578+ static atomic_unchecked_t led_seq = ATOMIC_INIT(-1);
45579 struct xpad_led *led;
45580 struct led_classdev *led_cdev;
45581 int error;
45582@@ -971,7 +971,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
45583 if (!led)
45584 return -ENOMEM;
45585
45586- xpad->led_no = atomic_inc_return(&led_seq);
45587+ xpad->led_no = atomic_inc_return_unchecked(&led_seq);
45588
45589 snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->led_no);
45590 led->xpad = xpad;
45591diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
45592index ac1fa5f..5f7502c 100644
45593--- a/drivers/input/misc/ims-pcu.c
45594+++ b/drivers/input/misc/ims-pcu.c
45595@@ -1851,7 +1851,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
45596
45597 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
45598 {
45599- static atomic_t device_no = ATOMIC_INIT(-1);
45600+ static atomic_unchecked_t device_no = ATOMIC_INIT(-1);
45601
45602 const struct ims_pcu_device_info *info;
45603 int error;
45604@@ -1882,7 +1882,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
45605 }
45606
45607 /* Device appears to be operable, complete initialization */
45608- pcu->device_no = atomic_inc_return(&device_no);
45609+ pcu->device_no = atomic_inc_return_unchecked(&device_no);
45610
45611 /*
45612 * PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor
45613diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
45614index ad5a5a1..5eac214 100644
45615--- a/drivers/input/mouse/psmouse.h
45616+++ b/drivers/input/mouse/psmouse.h
45617@@ -125,7 +125,7 @@ struct psmouse_attribute {
45618 ssize_t (*set)(struct psmouse *psmouse, void *data,
45619 const char *buf, size_t count);
45620 bool protect;
45621-};
45622+} __do_const;
45623 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
45624
45625 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
45626diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
45627index b604564..3f14ae4 100644
45628--- a/drivers/input/mousedev.c
45629+++ b/drivers/input/mousedev.c
45630@@ -744,7 +744,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
45631
45632 spin_unlock_irq(&client->packet_lock);
45633
45634- if (copy_to_user(buffer, data, count))
45635+ if (count > sizeof(data) || copy_to_user(buffer, data, count))
45636 return -EFAULT;
45637
45638 return count;
45639diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
45640index a05a517..323a2fd 100644
45641--- a/drivers/input/serio/serio.c
45642+++ b/drivers/input/serio/serio.c
45643@@ -514,7 +514,7 @@ static void serio_release_port(struct device *dev)
45644 */
45645 static void serio_init_port(struct serio *serio)
45646 {
45647- static atomic_t serio_no = ATOMIC_INIT(-1);
45648+ static atomic_unchecked_t serio_no = ATOMIC_INIT(-1);
45649
45650 __module_get(THIS_MODULE);
45651
45652@@ -525,7 +525,7 @@ static void serio_init_port(struct serio *serio)
45653 mutex_init(&serio->drv_mutex);
45654 device_initialize(&serio->dev);
45655 dev_set_name(&serio->dev, "serio%lu",
45656- (unsigned long)atomic_inc_return(&serio_no));
45657+ (unsigned long)atomic_inc_return_unchecked(&serio_no));
45658 serio->dev.bus = &serio_bus;
45659 serio->dev.release = serio_release_port;
45660 serio->dev.groups = serio_device_attr_groups;
45661diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
45662index 71ef5d6..93380a9 100644
45663--- a/drivers/input/serio/serio_raw.c
45664+++ b/drivers/input/serio/serio_raw.c
45665@@ -292,7 +292,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
45666
45667 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
45668 {
45669- static atomic_t serio_raw_no = ATOMIC_INIT(-1);
45670+ static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(-1);
45671 struct serio_raw *serio_raw;
45672 int err;
45673
45674@@ -303,7 +303,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
45675 }
45676
45677 snprintf(serio_raw->name, sizeof(serio_raw->name),
45678- "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no));
45679+ "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no));
45680 kref_init(&serio_raw->kref);
45681 INIT_LIST_HEAD(&serio_raw->client_list);
45682 init_waitqueue_head(&serio_raw->wait);
45683diff --git a/drivers/input/touchscreen/htcpen.c b/drivers/input/touchscreen/htcpen.c
45684index 92e2243..8fd9092 100644
45685--- a/drivers/input/touchscreen/htcpen.c
45686+++ b/drivers/input/touchscreen/htcpen.c
45687@@ -219,7 +219,7 @@ static struct isa_driver htcpen_isa_driver = {
45688 }
45689 };
45690
45691-static struct dmi_system_id htcshift_dmi_table[] __initdata = {
45692+static const struct dmi_system_id htcshift_dmi_table[] __initconst = {
45693 {
45694 .ident = "Shift",
45695 .matches = {
45696diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
45697index f1fb1d3..82257cc 100644
45698--- a/drivers/iommu/Kconfig
45699+++ b/drivers/iommu/Kconfig
45700@@ -102,6 +102,7 @@ config AMD_IOMMU_STATS
45701 bool "Export AMD IOMMU statistics to debugfs"
45702 depends on AMD_IOMMU
45703 select DEBUG_FS
45704+ depends on !GRKERNSEC_KMEM
45705 ---help---
45706 This option enables code in the AMD IOMMU driver to collect various
45707 statistics about whats happening in the driver and exports that
45708diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
45709index 658ee39..6fde5be 100644
45710--- a/drivers/iommu/amd_iommu.c
45711+++ b/drivers/iommu/amd_iommu.c
45712@@ -794,11 +794,21 @@ static void copy_cmd_to_buffer(struct amd_iommu *iommu,
45713
45714 static void build_completion_wait(struct iommu_cmd *cmd, u64 address)
45715 {
45716+ phys_addr_t physaddr;
45717 WARN_ON(address & 0x7ULL);
45718
45719 memset(cmd, 0, sizeof(*cmd));
45720- cmd->data[0] = lower_32_bits(__pa(address)) | CMD_COMPL_WAIT_STORE_MASK;
45721- cmd->data[1] = upper_32_bits(__pa(address));
45722+
45723+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
45724+ if (object_starts_on_stack((void *)address)) {
45725+ void *adjbuf = (void *)address - current->stack + current->lowmem_stack;
45726+ physaddr = __pa((u64)adjbuf);
45727+ } else
45728+#endif
45729+ physaddr = __pa(address);
45730+
45731+ cmd->data[0] = lower_32_bits(physaddr) | CMD_COMPL_WAIT_STORE_MASK;
45732+ cmd->data[1] = upper_32_bits(physaddr);
45733 cmd->data[2] = 1;
45734 CMD_SET_TYPE(cmd, CMD_COMPL_WAIT);
45735 }
45736diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
45737index 4cd0c29..afd3cbe 100644
45738--- a/drivers/iommu/arm-smmu.c
45739+++ b/drivers/iommu/arm-smmu.c
45740@@ -330,7 +330,7 @@ enum arm_smmu_domain_stage {
45741
45742 struct arm_smmu_domain {
45743 struct arm_smmu_device *smmu;
45744- struct io_pgtable_ops *pgtbl_ops;
45745+ struct io_pgtable *pgtbl;
45746 spinlock_t pgtbl_lock;
45747 struct arm_smmu_cfg cfg;
45748 enum arm_smmu_domain_stage stage;
45749@@ -816,7 +816,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
45750 {
45751 int irq, start, ret = 0;
45752 unsigned long ias, oas;
45753- struct io_pgtable_ops *pgtbl_ops;
45754+ struct io_pgtable *pgtbl;
45755 struct io_pgtable_cfg pgtbl_cfg;
45756 enum io_pgtable_fmt fmt;
45757 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
45758@@ -901,14 +901,16 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
45759 };
45760
45761 smmu_domain->smmu = smmu;
45762- pgtbl_ops = alloc_io_pgtable_ops(fmt, &pgtbl_cfg, smmu_domain);
45763- if (!pgtbl_ops) {
45764+ pgtbl = alloc_io_pgtable(fmt, &pgtbl_cfg, smmu_domain);
45765+ if (!pgtbl) {
45766 ret = -ENOMEM;
45767 goto out_clear_smmu;
45768 }
45769
45770 /* Update our support page sizes to reflect the page table format */
45771- arm_smmu_ops.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
45772+ pax_open_kernel();
45773+ *(unsigned long *)&arm_smmu_ops.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
45774+ pax_close_kernel();
45775
45776 /* Initialise the context bank with our page table cfg */
45777 arm_smmu_init_context_bank(smmu_domain, &pgtbl_cfg);
45778@@ -929,7 +931,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
45779 mutex_unlock(&smmu_domain->init_mutex);
45780
45781 /* Publish page table ops for map/unmap */
45782- smmu_domain->pgtbl_ops = pgtbl_ops;
45783+ smmu_domain->pgtbl = pgtbl;
45784 return 0;
45785
45786 out_clear_smmu:
45787@@ -962,8 +964,7 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain)
45788 free_irq(irq, domain);
45789 }
45790
45791- if (smmu_domain->pgtbl_ops)
45792- free_io_pgtable_ops(smmu_domain->pgtbl_ops);
45793+ free_io_pgtable(smmu_domain->pgtbl);
45794
45795 __arm_smmu_free_bitmap(smmu->context_map, cfg->cbndx);
45796 }
45797@@ -1189,13 +1190,13 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova,
45798 int ret;
45799 unsigned long flags;
45800 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
45801- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
45802+ struct io_pgtable *iop = smmu_domain->pgtbl;
45803
45804- if (!ops)
45805+ if (!iop)
45806 return -ENODEV;
45807
45808 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
45809- ret = ops->map(ops, iova, paddr, size, prot);
45810+ ret = iop->ops->map(iop, iova, paddr, size, prot);
45811 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
45812 return ret;
45813 }
45814@@ -1206,13 +1207,13 @@ static size_t arm_smmu_unmap(struct iommu_domain *domain, unsigned long iova,
45815 size_t ret;
45816 unsigned long flags;
45817 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
45818- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
45819+ struct io_pgtable *iop = smmu_domain->pgtbl;
45820
45821- if (!ops)
45822+ if (!iop)
45823 return 0;
45824
45825 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
45826- ret = ops->unmap(ops, iova, size);
45827+ ret = iop->ops->unmap(iop, iova, size);
45828 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
45829 return ret;
45830 }
45831@@ -1223,7 +1224,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
45832 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
45833 struct arm_smmu_device *smmu = smmu_domain->smmu;
45834 struct arm_smmu_cfg *cfg = &smmu_domain->cfg;
45835- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
45836+ struct io_pgtable *iop = smmu_domain->pgtbl;
45837 struct device *dev = smmu->dev;
45838 void __iomem *cb_base;
45839 u32 tmp;
45840@@ -1246,7 +1247,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
45841 dev_err(dev,
45842 "iova to phys timed out on 0x%pad. Falling back to software table walk.\n",
45843 &iova);
45844- return ops->iova_to_phys(ops, iova);
45845+ return iop->ops->iova_to_phys(iop, iova);
45846 }
45847
45848 phys = readl_relaxed(cb_base + ARM_SMMU_CB_PAR_LO);
45849@@ -1267,9 +1268,9 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
45850 phys_addr_t ret;
45851 unsigned long flags;
45852 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
45853- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
45854+ struct io_pgtable *iop = smmu_domain->pgtbl;
45855
45856- if (!ops)
45857+ if (!iop)
45858 return 0;
45859
45860 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
45861@@ -1277,7 +1278,7 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
45862 smmu_domain->stage == ARM_SMMU_DOMAIN_S1) {
45863 ret = arm_smmu_iova_to_phys_hard(domain, iova);
45864 } else {
45865- ret = ops->iova_to_phys(ops, iova);
45866+ ret = iop->ops->iova_to_phys(iop, iova);
45867 }
45868
45869 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
45870@@ -1667,7 +1668,9 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
45871 size |= SZ_64K | SZ_512M;
45872 }
45873
45874- arm_smmu_ops.pgsize_bitmap &= size;
45875+ pax_open_kernel();
45876+ *(unsigned long *)&arm_smmu_ops.pgsize_bitmap &= size;
45877+ pax_close_kernel();
45878 dev_notice(smmu->dev, "\tSupported page sizes: 0x%08lx\n", size);
45879
45880 if (smmu->features & ARM_SMMU_FEAT_TRANS_S1)
45881diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
45882index e29d5d7..e5eeb3e 100644
45883--- a/drivers/iommu/io-pgtable-arm.c
45884+++ b/drivers/iommu/io-pgtable-arm.c
45885@@ -36,12 +36,6 @@
45886 #define io_pgtable_to_data(x) \
45887 container_of((x), struct arm_lpae_io_pgtable, iop)
45888
45889-#define io_pgtable_ops_to_pgtable(x) \
45890- container_of((x), struct io_pgtable, ops)
45891-
45892-#define io_pgtable_ops_to_data(x) \
45893- io_pgtable_to_data(io_pgtable_ops_to_pgtable(x))
45894-
45895 /*
45896 * For consistency with the architecture, we always consider
45897 * ARM_LPAE_MAX_LEVELS levels, with the walk starting at level n >=0
45898@@ -319,10 +313,10 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data,
45899 return pte;
45900 }
45901
45902-static int arm_lpae_map(struct io_pgtable_ops *ops, unsigned long iova,
45903+static int arm_lpae_map(struct io_pgtable *iop, unsigned long iova,
45904 phys_addr_t paddr, size_t size, int iommu_prot)
45905 {
45906- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
45907+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
45908 arm_lpae_iopte *ptep = data->pgd;
45909 int lvl = ARM_LPAE_START_LVL(data);
45910 arm_lpae_iopte prot;
45911@@ -462,12 +456,11 @@ static int __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,
45912 return __arm_lpae_unmap(data, iova, size, lvl + 1, ptep);
45913 }
45914
45915-static int arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova,
45916+static int arm_lpae_unmap(struct io_pgtable *iop, unsigned long iova,
45917 size_t size)
45918 {
45919 size_t unmapped;
45920- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
45921- struct io_pgtable *iop = &data->iop;
45922+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
45923 arm_lpae_iopte *ptep = data->pgd;
45924 int lvl = ARM_LPAE_START_LVL(data);
45925
45926@@ -478,10 +471,10 @@ static int arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova,
45927 return unmapped;
45928 }
45929
45930-static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable_ops *ops,
45931+static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable *iop,
45932 unsigned long iova)
45933 {
45934- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
45935+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
45936 arm_lpae_iopte pte, *ptep = data->pgd;
45937 int lvl = ARM_LPAE_START_LVL(data);
45938
45939@@ -548,6 +541,12 @@ static void arm_lpae_restrict_pgsizes(struct io_pgtable_cfg *cfg)
45940 }
45941 }
45942
45943+static struct io_pgtable_ops arm_lpae_io_pgtable_ops = {
45944+ .map = arm_lpae_map,
45945+ .unmap = arm_lpae_unmap,
45946+ .iova_to_phys = arm_lpae_iova_to_phys,
45947+};
45948+
45949 static struct arm_lpae_io_pgtable *
45950 arm_lpae_alloc_pgtable(struct io_pgtable_cfg *cfg)
45951 {
45952@@ -579,11 +578,7 @@ arm_lpae_alloc_pgtable(struct io_pgtable_cfg *cfg)
45953 pgd_bits = va_bits - (data->bits_per_level * (data->levels - 1));
45954 data->pgd_size = 1UL << (pgd_bits + ilog2(sizeof(arm_lpae_iopte)));
45955
45956- data->iop.ops = (struct io_pgtable_ops) {
45957- .map = arm_lpae_map,
45958- .unmap = arm_lpae_unmap,
45959- .iova_to_phys = arm_lpae_iova_to_phys,
45960- };
45961+ data->iop.ops = &arm_lpae_io_pgtable_ops;
45962
45963 return data;
45964 }
45965@@ -845,9 +840,9 @@ static struct iommu_gather_ops dummy_tlb_ops __initdata = {
45966 .flush_pgtable = dummy_flush_pgtable,
45967 };
45968
45969-static void __init arm_lpae_dump_ops(struct io_pgtable_ops *ops)
45970+static void __init arm_lpae_dump_ops(struct io_pgtable *iop)
45971 {
45972- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
45973+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
45974 struct io_pgtable_cfg *cfg = &data->iop.cfg;
45975
45976 pr_err("cfg: pgsize_bitmap 0x%lx, ias %u-bit\n",
45977@@ -857,9 +852,9 @@ static void __init arm_lpae_dump_ops(struct io_pgtable_ops *ops)
45978 data->bits_per_level, data->pgd);
45979 }
45980
45981-#define __FAIL(ops, i) ({ \
45982+#define __FAIL(iop, i) ({ \
45983 WARN(1, "selftest: test failed for fmt idx %d\n", (i)); \
45984- arm_lpae_dump_ops(ops); \
45985+ arm_lpae_dump_ops(iop); \
45986 selftest_running = false; \
45987 -EFAULT; \
45988 })
45989@@ -874,30 +869,32 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
45990 int i, j;
45991 unsigned long iova;
45992 size_t size;
45993- struct io_pgtable_ops *ops;
45994+ struct io_pgtable *iop;
45995+ const struct io_pgtable_ops *ops;
45996
45997 selftest_running = true;
45998
45999 for (i = 0; i < ARRAY_SIZE(fmts); ++i) {
46000 cfg_cookie = cfg;
46001- ops = alloc_io_pgtable_ops(fmts[i], cfg, cfg);
46002- if (!ops) {
46003+ iop = alloc_io_pgtable(fmts[i], cfg, cfg);
46004+ if (!iop) {
46005 pr_err("selftest: failed to allocate io pgtable ops\n");
46006 return -ENOMEM;
46007 }
46008+ ops = iop->ops;
46009
46010 /*
46011 * Initial sanity checks.
46012 * Empty page tables shouldn't provide any translations.
46013 */
46014- if (ops->iova_to_phys(ops, 42))
46015- return __FAIL(ops, i);
46016+ if (ops->iova_to_phys(iop, 42))
46017+ return __FAIL(iop, i);
46018
46019- if (ops->iova_to_phys(ops, SZ_1G + 42))
46020- return __FAIL(ops, i);
46021+ if (ops->iova_to_phys(iop, SZ_1G + 42))
46022+ return __FAIL(iop, i);
46023
46024- if (ops->iova_to_phys(ops, SZ_2G + 42))
46025- return __FAIL(ops, i);
46026+ if (ops->iova_to_phys(iop, SZ_2G + 42))
46027+ return __FAIL(iop, i);
46028
46029 /*
46030 * Distinct mappings of different granule sizes.
46031@@ -907,19 +904,19 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
46032 while (j != BITS_PER_LONG) {
46033 size = 1UL << j;
46034
46035- if (ops->map(ops, iova, iova, size, IOMMU_READ |
46036+ if (ops->map(iop, iova, iova, size, IOMMU_READ |
46037 IOMMU_WRITE |
46038 IOMMU_NOEXEC |
46039 IOMMU_CACHE))
46040- return __FAIL(ops, i);
46041+ return __FAIL(iop, i);
46042
46043 /* Overlapping mappings */
46044- if (!ops->map(ops, iova, iova + size, size,
46045+ if (!ops->map(iop, iova, iova + size, size,
46046 IOMMU_READ | IOMMU_NOEXEC))
46047- return __FAIL(ops, i);
46048+ return __FAIL(iop, i);
46049
46050- if (ops->iova_to_phys(ops, iova + 42) != (iova + 42))
46051- return __FAIL(ops, i);
46052+ if (ops->iova_to_phys(iop, iova + 42) != (iova + 42))
46053+ return __FAIL(iop, i);
46054
46055 iova += SZ_1G;
46056 j++;
46057@@ -928,15 +925,15 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
46058
46059 /* Partial unmap */
46060 size = 1UL << __ffs(cfg->pgsize_bitmap);
46061- if (ops->unmap(ops, SZ_1G + size, size) != size)
46062- return __FAIL(ops, i);
46063+ if (ops->unmap(iop, SZ_1G + size, size) != size)
46064+ return __FAIL(iop, i);
46065
46066 /* Remap of partial unmap */
46067- if (ops->map(ops, SZ_1G + size, size, size, IOMMU_READ))
46068- return __FAIL(ops, i);
46069+ if (ops->map(iop, SZ_1G + size, size, size, IOMMU_READ))
46070+ return __FAIL(iop, i);
46071
46072- if (ops->iova_to_phys(ops, SZ_1G + size + 42) != (size + 42))
46073- return __FAIL(ops, i);
46074+ if (ops->iova_to_phys(iop, SZ_1G + size + 42) != (size + 42))
46075+ return __FAIL(iop, i);
46076
46077 /* Full unmap */
46078 iova = 0;
46079@@ -944,25 +941,25 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
46080 while (j != BITS_PER_LONG) {
46081 size = 1UL << j;
46082
46083- if (ops->unmap(ops, iova, size) != size)
46084- return __FAIL(ops, i);
46085+ if (ops->unmap(iop, iova, size) != size)
46086+ return __FAIL(iop, i);
46087
46088- if (ops->iova_to_phys(ops, iova + 42))
46089- return __FAIL(ops, i);
46090+ if (ops->iova_to_phys(iop, iova + 42))
46091+ return __FAIL(iop, i);
46092
46093 /* Remap full block */
46094- if (ops->map(ops, iova, iova, size, IOMMU_WRITE))
46095- return __FAIL(ops, i);
46096+ if (ops->map(iop, iova, iova, size, IOMMU_WRITE))
46097+ return __FAIL(iop, i);
46098
46099- if (ops->iova_to_phys(ops, iova + 42) != (iova + 42))
46100- return __FAIL(ops, i);
46101+ if (ops->iova_to_phys(iop, iova + 42) != (iova + 42))
46102+ return __FAIL(iop, i);
46103
46104 iova += SZ_1G;
46105 j++;
46106 j = find_next_bit(&cfg->pgsize_bitmap, BITS_PER_LONG, j);
46107 }
46108
46109- free_io_pgtable_ops(ops);
46110+ free_io_pgtable(iop);
46111 }
46112
46113 selftest_running = false;
46114diff --git a/drivers/iommu/io-pgtable.c b/drivers/iommu/io-pgtable.c
46115index 6436fe2..088c965 100644
46116--- a/drivers/iommu/io-pgtable.c
46117+++ b/drivers/iommu/io-pgtable.c
46118@@ -40,7 +40,7 @@ io_pgtable_init_table[IO_PGTABLE_NUM_FMTS] =
46119 #endif
46120 };
46121
46122-struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
46123+struct io_pgtable *alloc_io_pgtable(enum io_pgtable_fmt fmt,
46124 struct io_pgtable_cfg *cfg,
46125 void *cookie)
46126 {
46127@@ -62,21 +62,18 @@ struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
46128 iop->cookie = cookie;
46129 iop->cfg = *cfg;
46130
46131- return &iop->ops;
46132+ return iop;
46133 }
46134
46135 /*
46136 * It is the IOMMU driver's responsibility to ensure that the page table
46137 * is no longer accessible to the walker by this point.
46138 */
46139-void free_io_pgtable_ops(struct io_pgtable_ops *ops)
46140+void free_io_pgtable(struct io_pgtable *iop)
46141 {
46142- struct io_pgtable *iop;
46143-
46144- if (!ops)
46145+ if (!iop)
46146 return;
46147
46148- iop = container_of(ops, struct io_pgtable, ops);
46149 iop->cfg.tlb->tlb_flush_all(iop->cookie);
46150 io_pgtable_init_table[iop->fmt]->free(iop);
46151 }
46152diff --git a/drivers/iommu/io-pgtable.h b/drivers/iommu/io-pgtable.h
46153index 10e32f6..0b276c8 100644
46154--- a/drivers/iommu/io-pgtable.h
46155+++ b/drivers/iommu/io-pgtable.h
46156@@ -75,17 +75,18 @@ struct io_pgtable_cfg {
46157 * These functions map directly onto the iommu_ops member functions with
46158 * the same names.
46159 */
46160+struct io_pgtable;
46161 struct io_pgtable_ops {
46162- int (*map)(struct io_pgtable_ops *ops, unsigned long iova,
46163+ int (*map)(struct io_pgtable *iop, unsigned long iova,
46164 phys_addr_t paddr, size_t size, int prot);
46165- int (*unmap)(struct io_pgtable_ops *ops, unsigned long iova,
46166+ int (*unmap)(struct io_pgtable *iop, unsigned long iova,
46167 size_t size);
46168- phys_addr_t (*iova_to_phys)(struct io_pgtable_ops *ops,
46169+ phys_addr_t (*iova_to_phys)(struct io_pgtable *iop,
46170 unsigned long iova);
46171 };
46172
46173 /**
46174- * alloc_io_pgtable_ops() - Allocate a page table allocator for use by an IOMMU.
46175+ * alloc_io_pgtable() - Allocate a page table allocator for use by an IOMMU.
46176 *
46177 * @fmt: The page table format.
46178 * @cfg: The page table configuration. This will be modified to represent
46179@@ -94,9 +95,9 @@ struct io_pgtable_ops {
46180 * @cookie: An opaque token provided by the IOMMU driver and passed back to
46181 * the callback routines in cfg->tlb.
46182 */
46183-struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
46184- struct io_pgtable_cfg *cfg,
46185- void *cookie);
46186+struct io_pgtable *alloc_io_pgtable(enum io_pgtable_fmt fmt,
46187+ struct io_pgtable_cfg *cfg,
46188+ void *cookie);
46189
46190 /**
46191 * free_io_pgtable_ops() - Free an io_pgtable_ops structure. The caller
46192@@ -105,7 +106,7 @@ struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
46193 *
46194 * @ops: The ops returned from alloc_io_pgtable_ops.
46195 */
46196-void free_io_pgtable_ops(struct io_pgtable_ops *ops);
46197+void free_io_pgtable(struct io_pgtable *iop);
46198
46199
46200 /*
46201@@ -125,7 +126,7 @@ struct io_pgtable {
46202 enum io_pgtable_fmt fmt;
46203 void *cookie;
46204 struct io_pgtable_cfg cfg;
46205- struct io_pgtable_ops ops;
46206+ const struct io_pgtable_ops *ops;
46207 };
46208
46209 /**
46210diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
46211index f286090..bac3e7e 100644
46212--- a/drivers/iommu/iommu.c
46213+++ b/drivers/iommu/iommu.c
46214@@ -934,7 +934,7 @@ static int iommu_bus_notifier(struct notifier_block *nb,
46215 static int iommu_bus_init(struct bus_type *bus, const struct iommu_ops *ops)
46216 {
46217 int err;
46218- struct notifier_block *nb;
46219+ notifier_block_no_const *nb;
46220 struct iommu_callback_data cb = {
46221 .ops = ops,
46222 };
46223diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
46224index 1a67c53..23181d8 100644
46225--- a/drivers/iommu/ipmmu-vmsa.c
46226+++ b/drivers/iommu/ipmmu-vmsa.c
46227@@ -41,7 +41,7 @@ struct ipmmu_vmsa_domain {
46228 struct iommu_domain io_domain;
46229
46230 struct io_pgtable_cfg cfg;
46231- struct io_pgtable_ops *iop;
46232+ struct io_pgtable *iop;
46233
46234 unsigned int context_id;
46235 spinlock_t lock; /* Protects mappings */
46236@@ -328,8 +328,7 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
46237 domain->cfg.oas = 40;
46238 domain->cfg.tlb = &ipmmu_gather_ops;
46239
46240- domain->iop = alloc_io_pgtable_ops(ARM_32_LPAE_S1, &domain->cfg,
46241- domain);
46242+ domain->iop = alloc_io_pgtable(ARM_32_LPAE_S1, &domain->cfg, domain);
46243 if (!domain->iop)
46244 return -EINVAL;
46245
46246@@ -487,7 +486,7 @@ static void ipmmu_domain_free(struct iommu_domain *io_domain)
46247 * been detached.
46248 */
46249 ipmmu_domain_destroy_context(domain);
46250- free_io_pgtable_ops(domain->iop);
46251+ free_io_pgtable(domain->iop);
46252 kfree(domain);
46253 }
46254
46255@@ -556,7 +555,7 @@ static int ipmmu_map(struct iommu_domain *io_domain, unsigned long iova,
46256 if (!domain)
46257 return -ENODEV;
46258
46259- return domain->iop->map(domain->iop, iova, paddr, size, prot);
46260+ return domain->iop->ops->map(domain->iop, iova, paddr, size, prot);
46261 }
46262
46263 static size_t ipmmu_unmap(struct iommu_domain *io_domain, unsigned long iova,
46264@@ -564,7 +563,7 @@ static size_t ipmmu_unmap(struct iommu_domain *io_domain, unsigned long iova,
46265 {
46266 struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
46267
46268- return domain->iop->unmap(domain->iop, iova, size);
46269+ return domain->iop->ops->unmap(domain->iop, iova, size);
46270 }
46271
46272 static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,
46273@@ -574,7 +573,7 @@ static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,
46274
46275 /* TODO: Is locking needed ? */
46276
46277- return domain->iop->iova_to_phys(domain->iop, iova);
46278+ return domain->iop->ops->iova_to_phys(domain->iop, iova);
46279 }
46280
46281 static int ipmmu_find_utlbs(struct ipmmu_vmsa_device *mmu, struct device *dev,
46282diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
46283index 2d99930..b8b358c 100644
46284--- a/drivers/iommu/irq_remapping.c
46285+++ b/drivers/iommu/irq_remapping.c
46286@@ -149,7 +149,7 @@ int __init irq_remap_enable_fault_handling(void)
46287 void panic_if_irq_remap(const char *msg)
46288 {
46289 if (irq_remapping_enabled)
46290- panic(msg);
46291+ panic("%s", msg);
46292 }
46293
46294 void ir_ack_apic_edge(struct irq_data *data)
46295diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c
46296index f3d20a2..5dcb85e 100644
46297--- a/drivers/iommu/omap-iommu-debug.c
46298+++ b/drivers/iommu/omap-iommu-debug.c
46299@@ -55,34 +55,22 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
46300 return bytes;
46301 }
46302
46303-static ssize_t debug_read_tlb(struct file *file, char __user *userbuf,
46304- size_t count, loff_t *ppos)
46305+static int debug_read_tlb(struct seq_file *s, void *data)
46306 {
46307- struct omap_iommu *obj = file->private_data;
46308- char *p, *buf;
46309- ssize_t bytes, rest;
46310+ struct omap_iommu *obj = s->private;
46311
46312 if (is_omap_iommu_detached(obj))
46313 return -EPERM;
46314
46315- buf = kmalloc(count, GFP_KERNEL);
46316- if (!buf)
46317- return -ENOMEM;
46318- p = buf;
46319-
46320 mutex_lock(&iommu_debug_lock);
46321
46322- p += sprintf(p, "%8s %8s\n", "cam:", "ram:");
46323- p += sprintf(p, "-----------------------------------------\n");
46324- rest = count - (p - buf);
46325- p += omap_dump_tlb_entries(obj, p, rest);
46326-
46327- bytes = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
46328+ seq_printf(s, "%8s %8s\n", "cam:", "ram:");
46329+ seq_puts(s, "-----------------------------------------\n");
46330+ omap_dump_tlb_entries(obj, s);
46331
46332 mutex_unlock(&iommu_debug_lock);
46333- kfree(buf);
46334
46335- return bytes;
46336+ return 0;
46337 }
46338
46339 static void dump_ioptable(struct seq_file *s)
46340@@ -157,7 +145,7 @@ static int debug_read_pagetable(struct seq_file *s, void *data)
46341 };
46342
46343 DEBUG_FOPS_RO(regs);
46344-DEBUG_FOPS_RO(tlb);
46345+DEBUG_SEQ_FOPS_RO(tlb);
46346 DEBUG_SEQ_FOPS_RO(pagetable);
46347
46348 #define __DEBUG_ADD_FILE(attr, mode) \
46349diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
46350index a22c33d..2247075e2 100644
46351--- a/drivers/iommu/omap-iommu.c
46352+++ b/drivers/iommu/omap-iommu.c
46353@@ -546,36 +546,30 @@ __dump_tlb_entries(struct omap_iommu *obj, struct cr_regs *crs, int num)
46354 }
46355
46356 /**
46357- * iotlb_dump_cr - Dump an iommu tlb entry into buf
46358+ * iotlb_dump_cr - Dump an iommu tlb entry into seq_file
46359 * @obj: target iommu
46360 * @cr: contents of cam and ram register
46361- * @buf: output buffer
46362+ * @s: output seq_file
46363 **/
46364 static ssize_t iotlb_dump_cr(struct omap_iommu *obj, struct cr_regs *cr,
46365- char *buf)
46366+ struct seq_file *s)
46367 {
46368- char *p = buf;
46369-
46370 /* FIXME: Need more detail analysis of cam/ram */
46371- p += sprintf(p, "%08x %08x %01x\n", cr->cam, cr->ram,
46372- (cr->cam & MMU_CAM_P) ? 1 : 0);
46373-
46374- return p - buf;
46375+ return seq_printf(s, "%08x %08x %01x\n", cr->cam, cr->ram,
46376+ (cr->cam & MMU_CAM_P) ? 1 : 0);
46377 }
46378
46379 /**
46380- * omap_dump_tlb_entries - dump cr arrays to given buffer
46381+ * omap_dump_tlb_entries - dump cr arrays to given seq_file
46382 * @obj: target iommu
46383- * @buf: output buffer
46384+ * @s: output seq_file
46385 **/
46386-size_t omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t bytes)
46387+size_t omap_dump_tlb_entries(struct omap_iommu *obj, struct seq_file *s)
46388 {
46389 int i, num;
46390 struct cr_regs *cr;
46391- char *p = buf;
46392
46393- num = bytes / sizeof(*cr);
46394- num = min(obj->nr_tlb_entries, num);
46395+ num = obj->nr_tlb_entries;
46396
46397 cr = kcalloc(num, sizeof(*cr), GFP_KERNEL);
46398 if (!cr)
46399@@ -583,10 +577,10 @@ size_t omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t bytes)
46400
46401 num = __dump_tlb_entries(obj, cr, num);
46402 for (i = 0; i < num; i++)
46403- p += iotlb_dump_cr(obj, cr + i, p);
46404+ iotlb_dump_cr(obj, cr + i, s);
46405 kfree(cr);
46406
46407- return p - buf;
46408+ return 0;
46409 }
46410
46411 #endif /* CONFIG_OMAP_IOMMU_DEBUG */
46412diff --git a/drivers/iommu/omap-iommu.h b/drivers/iommu/omap-iommu.h
46413index d736630..5df9755 100644
46414--- a/drivers/iommu/omap-iommu.h
46415+++ b/drivers/iommu/omap-iommu.h
46416@@ -193,8 +193,7 @@ static inline struct omap_iommu *dev_to_omap_iommu(struct device *dev)
46417 #ifdef CONFIG_OMAP_IOMMU_DEBUG
46418 extern ssize_t
46419 omap_iommu_dump_ctx(struct omap_iommu *obj, char *buf, ssize_t len);
46420-extern size_t
46421-omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t len);
46422+extern size_t omap_dump_tlb_entries(struct omap_iommu *obj, struct seq_file *s);
46423
46424 void omap_iommu_debugfs_init(void);
46425 void omap_iommu_debugfs_exit(void);
46426diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
46427index 4dd8826..1f33400 100644
46428--- a/drivers/irqchip/irq-gic.c
46429+++ b/drivers/irqchip/irq-gic.c
46430@@ -313,7 +313,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
46431 chained_irq_exit(chip, desc);
46432 }
46433
46434-static struct irq_chip gic_chip = {
46435+static irq_chip_no_const gic_chip __read_only = {
46436 .name = "GIC",
46437 .irq_mask = gic_mask_irq,
46438 .irq_unmask = gic_unmask_irq,
46439diff --git a/drivers/irqchip/irq-renesas-intc-irqpin.c b/drivers/irqchip/irq-renesas-intc-irqpin.c
46440index 0670ab4..1094651 100644
46441--- a/drivers/irqchip/irq-renesas-intc-irqpin.c
46442+++ b/drivers/irqchip/irq-renesas-intc-irqpin.c
46443@@ -373,7 +373,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
46444 struct intc_irqpin_iomem *i;
46445 struct resource *io[INTC_IRQPIN_REG_NR];
46446 struct resource *irq;
46447- struct irq_chip *irq_chip;
46448+ irq_chip_no_const *irq_chip;
46449 void (*enable_fn)(struct irq_data *d);
46450 void (*disable_fn)(struct irq_data *d);
46451 const char *name = dev_name(dev);
46452diff --git a/drivers/irqchip/irq-renesas-irqc.c b/drivers/irqchip/irq-renesas-irqc.c
46453index 778bd07..0397152 100644
46454--- a/drivers/irqchip/irq-renesas-irqc.c
46455+++ b/drivers/irqchip/irq-renesas-irqc.c
46456@@ -176,7 +176,7 @@ static int irqc_probe(struct platform_device *pdev)
46457 struct irqc_priv *p;
46458 struct resource *io;
46459 struct resource *irq;
46460- struct irq_chip *irq_chip;
46461+ irq_chip_no_const *irq_chip;
46462 const char *name = dev_name(&pdev->dev);
46463 int ret;
46464 int k;
46465diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
46466index 6a2df32..dc962f1 100644
46467--- a/drivers/isdn/capi/capi.c
46468+++ b/drivers/isdn/capi/capi.c
46469@@ -81,8 +81,8 @@ struct capiminor {
46470
46471 struct capi20_appl *ap;
46472 u32 ncci;
46473- atomic_t datahandle;
46474- atomic_t msgid;
46475+ atomic_unchecked_t datahandle;
46476+ atomic_unchecked_t msgid;
46477
46478 struct tty_port port;
46479 int ttyinstop;
46480@@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
46481 capimsg_setu16(s, 2, mp->ap->applid);
46482 capimsg_setu8 (s, 4, CAPI_DATA_B3);
46483 capimsg_setu8 (s, 5, CAPI_RESP);
46484- capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
46485+ capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
46486 capimsg_setu32(s, 8, mp->ncci);
46487 capimsg_setu16(s, 12, datahandle);
46488 }
46489@@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
46490 mp->outbytes -= len;
46491 spin_unlock_bh(&mp->outlock);
46492
46493- datahandle = atomic_inc_return(&mp->datahandle);
46494+ datahandle = atomic_inc_return_unchecked(&mp->datahandle);
46495 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
46496 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
46497 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
46498 capimsg_setu16(skb->data, 2, mp->ap->applid);
46499 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
46500 capimsg_setu8 (skb->data, 5, CAPI_REQ);
46501- capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
46502+ capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
46503 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
46504 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
46505 capimsg_setu16(skb->data, 16, len); /* Data length */
46506diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
46507index aecec6d..11e13c5 100644
46508--- a/drivers/isdn/gigaset/bas-gigaset.c
46509+++ b/drivers/isdn/gigaset/bas-gigaset.c
46510@@ -2565,22 +2565,22 @@ static int gigaset_post_reset(struct usb_interface *intf)
46511
46512
46513 static const struct gigaset_ops gigops = {
46514- gigaset_write_cmd,
46515- gigaset_write_room,
46516- gigaset_chars_in_buffer,
46517- gigaset_brkchars,
46518- gigaset_init_bchannel,
46519- gigaset_close_bchannel,
46520- gigaset_initbcshw,
46521- gigaset_freebcshw,
46522- gigaset_reinitbcshw,
46523- gigaset_initcshw,
46524- gigaset_freecshw,
46525- gigaset_set_modem_ctrl,
46526- gigaset_baud_rate,
46527- gigaset_set_line_ctrl,
46528- gigaset_isoc_send_skb,
46529- gigaset_isoc_input,
46530+ .write_cmd = gigaset_write_cmd,
46531+ .write_room = gigaset_write_room,
46532+ .chars_in_buffer = gigaset_chars_in_buffer,
46533+ .brkchars = gigaset_brkchars,
46534+ .init_bchannel = gigaset_init_bchannel,
46535+ .close_bchannel = gigaset_close_bchannel,
46536+ .initbcshw = gigaset_initbcshw,
46537+ .freebcshw = gigaset_freebcshw,
46538+ .reinitbcshw = gigaset_reinitbcshw,
46539+ .initcshw = gigaset_initcshw,
46540+ .freecshw = gigaset_freecshw,
46541+ .set_modem_ctrl = gigaset_set_modem_ctrl,
46542+ .baud_rate = gigaset_baud_rate,
46543+ .set_line_ctrl = gigaset_set_line_ctrl,
46544+ .send_skb = gigaset_isoc_send_skb,
46545+ .handle_input = gigaset_isoc_input,
46546 };
46547
46548 /* bas_gigaset_init
46549diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
46550index 600c79b..3752bab 100644
46551--- a/drivers/isdn/gigaset/interface.c
46552+++ b/drivers/isdn/gigaset/interface.c
46553@@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
46554 }
46555 tty->driver_data = cs;
46556
46557- ++cs->port.count;
46558+ atomic_inc(&cs->port.count);
46559
46560- if (cs->port.count == 1) {
46561+ if (atomic_read(&cs->port.count) == 1) {
46562 tty_port_tty_set(&cs->port, tty);
46563 cs->port.low_latency = 1;
46564 }
46565@@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
46566
46567 if (!cs->connected)
46568 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
46569- else if (!cs->port.count)
46570+ else if (!atomic_read(&cs->port.count))
46571 dev_warn(cs->dev, "%s: device not opened\n", __func__);
46572- else if (!--cs->port.count)
46573+ else if (!atomic_dec_return(&cs->port.count))
46574 tty_port_tty_set(&cs->port, NULL);
46575
46576 mutex_unlock(&cs->mutex);
46577diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
46578index 375be50..675293c 100644
46579--- a/drivers/isdn/gigaset/ser-gigaset.c
46580+++ b/drivers/isdn/gigaset/ser-gigaset.c
46581@@ -453,22 +453,22 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
46582 }
46583
46584 static const struct gigaset_ops ops = {
46585- gigaset_write_cmd,
46586- gigaset_write_room,
46587- gigaset_chars_in_buffer,
46588- gigaset_brkchars,
46589- gigaset_init_bchannel,
46590- gigaset_close_bchannel,
46591- gigaset_initbcshw,
46592- gigaset_freebcshw,
46593- gigaset_reinitbcshw,
46594- gigaset_initcshw,
46595- gigaset_freecshw,
46596- gigaset_set_modem_ctrl,
46597- gigaset_baud_rate,
46598- gigaset_set_line_ctrl,
46599- gigaset_m10x_send_skb, /* asyncdata.c */
46600- gigaset_m10x_input, /* asyncdata.c */
46601+ .write_cmd = gigaset_write_cmd,
46602+ .write_room = gigaset_write_room,
46603+ .chars_in_buffer = gigaset_chars_in_buffer,
46604+ .brkchars = gigaset_brkchars,
46605+ .init_bchannel = gigaset_init_bchannel,
46606+ .close_bchannel = gigaset_close_bchannel,
46607+ .initbcshw = gigaset_initbcshw,
46608+ .freebcshw = gigaset_freebcshw,
46609+ .reinitbcshw = gigaset_reinitbcshw,
46610+ .initcshw = gigaset_initcshw,
46611+ .freecshw = gigaset_freecshw,
46612+ .set_modem_ctrl = gigaset_set_modem_ctrl,
46613+ .baud_rate = gigaset_baud_rate,
46614+ .set_line_ctrl = gigaset_set_line_ctrl,
46615+ .send_skb = gigaset_m10x_send_skb, /* asyncdata.c */
46616+ .handle_input = gigaset_m10x_input, /* asyncdata.c */
46617 };
46618
46619
46620diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
46621index 5f306e2..5342f88 100644
46622--- a/drivers/isdn/gigaset/usb-gigaset.c
46623+++ b/drivers/isdn/gigaset/usb-gigaset.c
46624@@ -543,7 +543,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
46625 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
46626 memcpy(cs->hw.usb->bchars, buf, 6);
46627 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
46628- 0, 0, &buf, 6, 2000);
46629+ 0, 0, buf, 6, 2000);
46630 }
46631
46632 static void gigaset_freebcshw(struct bc_state *bcs)
46633@@ -862,22 +862,22 @@ static int gigaset_pre_reset(struct usb_interface *intf)
46634 }
46635
46636 static const struct gigaset_ops ops = {
46637- gigaset_write_cmd,
46638- gigaset_write_room,
46639- gigaset_chars_in_buffer,
46640- gigaset_brkchars,
46641- gigaset_init_bchannel,
46642- gigaset_close_bchannel,
46643- gigaset_initbcshw,
46644- gigaset_freebcshw,
46645- gigaset_reinitbcshw,
46646- gigaset_initcshw,
46647- gigaset_freecshw,
46648- gigaset_set_modem_ctrl,
46649- gigaset_baud_rate,
46650- gigaset_set_line_ctrl,
46651- gigaset_m10x_send_skb,
46652- gigaset_m10x_input,
46653+ .write_cmd = gigaset_write_cmd,
46654+ .write_room = gigaset_write_room,
46655+ .chars_in_buffer = gigaset_chars_in_buffer,
46656+ .brkchars = gigaset_brkchars,
46657+ .init_bchannel = gigaset_init_bchannel,
46658+ .close_bchannel = gigaset_close_bchannel,
46659+ .initbcshw = gigaset_initbcshw,
46660+ .freebcshw = gigaset_freebcshw,
46661+ .reinitbcshw = gigaset_reinitbcshw,
46662+ .initcshw = gigaset_initcshw,
46663+ .freecshw = gigaset_freecshw,
46664+ .set_modem_ctrl = gigaset_set_modem_ctrl,
46665+ .baud_rate = gigaset_baud_rate,
46666+ .set_line_ctrl = gigaset_set_line_ctrl,
46667+ .send_skb = gigaset_m10x_send_skb,
46668+ .handle_input = gigaset_m10x_input,
46669 };
46670
46671 /*
46672diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
46673index 4d9b195..455075c 100644
46674--- a/drivers/isdn/hardware/avm/b1.c
46675+++ b/drivers/isdn/hardware/avm/b1.c
46676@@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
46677 }
46678 if (left) {
46679 if (t4file->user) {
46680- if (copy_from_user(buf, dp, left))
46681+ if (left > sizeof buf || copy_from_user(buf, dp, left))
46682 return -EFAULT;
46683 } else {
46684 memcpy(buf, dp, left);
46685@@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
46686 }
46687 if (left) {
46688 if (config->user) {
46689- if (copy_from_user(buf, dp, left))
46690+ if (left > sizeof buf || copy_from_user(buf, dp, left))
46691 return -EFAULT;
46692 } else {
46693 memcpy(buf, dp, left);
46694diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
46695index 9b856e1..fa03c92 100644
46696--- a/drivers/isdn/i4l/isdn_common.c
46697+++ b/drivers/isdn/i4l/isdn_common.c
46698@@ -1654,6 +1654,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
46699 } else
46700 return -EINVAL;
46701 case IIOCDBGVAR:
46702+ if (!capable(CAP_SYS_RAWIO))
46703+ return -EPERM;
46704 if (arg) {
46705 if (copy_to_user(argp, &dev, sizeof(ulong)))
46706 return -EFAULT;
46707diff --git a/drivers/isdn/i4l/isdn_concap.c b/drivers/isdn/i4l/isdn_concap.c
46708index 91d5730..336523e 100644
46709--- a/drivers/isdn/i4l/isdn_concap.c
46710+++ b/drivers/isdn/i4l/isdn_concap.c
46711@@ -80,9 +80,9 @@ static int isdn_concap_dl_disconn_req(struct concap_proto *concap)
46712 }
46713
46714 struct concap_device_ops isdn_concap_reliable_dl_dops = {
46715- &isdn_concap_dl_data_req,
46716- &isdn_concap_dl_connect_req,
46717- &isdn_concap_dl_disconn_req
46718+ .data_req = &isdn_concap_dl_data_req,
46719+ .connect_req = &isdn_concap_dl_connect_req,
46720+ .disconn_req = &isdn_concap_dl_disconn_req
46721 };
46722
46723 /* The following should better go into a dedicated source file such that
46724diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
46725index bc91261..2ef7e36 100644
46726--- a/drivers/isdn/i4l/isdn_tty.c
46727+++ b/drivers/isdn/i4l/isdn_tty.c
46728@@ -1503,9 +1503,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
46729
46730 #ifdef ISDN_DEBUG_MODEM_OPEN
46731 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
46732- port->count);
46733+ atomic_read(&port->count));
46734 #endif
46735- port->count++;
46736+ atomic_inc(&port->count);
46737 port->tty = tty;
46738 /*
46739 * Start up serial port
46740@@ -1549,7 +1549,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
46741 #endif
46742 return;
46743 }
46744- if ((tty->count == 1) && (port->count != 1)) {
46745+ if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
46746 /*
46747 * Uh, oh. tty->count is 1, which means that the tty
46748 * structure will be freed. Info->count should always
46749@@ -1558,15 +1558,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
46750 * serial port won't be shutdown.
46751 */
46752 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
46753- "info->count is %d\n", port->count);
46754- port->count = 1;
46755+ "info->count is %d\n", atomic_read(&port->count));
46756+ atomic_set(&port->count, 1);
46757 }
46758- if (--port->count < 0) {
46759+ if (atomic_dec_return(&port->count) < 0) {
46760 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
46761- info->line, port->count);
46762- port->count = 0;
46763+ info->line, atomic_read(&port->count));
46764+ atomic_set(&port->count, 0);
46765 }
46766- if (port->count) {
46767+ if (atomic_read(&port->count)) {
46768 #ifdef ISDN_DEBUG_MODEM_OPEN
46769 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
46770 #endif
46771@@ -1620,7 +1620,7 @@ isdn_tty_hangup(struct tty_struct *tty)
46772 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
46773 return;
46774 isdn_tty_shutdown(info);
46775- port->count = 0;
46776+ atomic_set(&port->count, 0);
46777 port->flags &= ~ASYNC_NORMAL_ACTIVE;
46778 port->tty = NULL;
46779 wake_up_interruptible(&port->open_wait);
46780@@ -1965,7 +1965,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
46781 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
46782 modem_info *info = &dev->mdm.info[i];
46783
46784- if (info->port.count == 0)
46785+ if (atomic_read(&info->port.count) == 0)
46786 continue;
46787 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
46788 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
46789diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c
46790index e2d4e58..40cd045 100644
46791--- a/drivers/isdn/i4l/isdn_x25iface.c
46792+++ b/drivers/isdn/i4l/isdn_x25iface.c
46793@@ -53,14 +53,14 @@ static int isdn_x25iface_disconn_ind(struct concap_proto *);
46794
46795
46796 static struct concap_proto_ops ix25_pops = {
46797- &isdn_x25iface_proto_new,
46798- &isdn_x25iface_proto_del,
46799- &isdn_x25iface_proto_restart,
46800- &isdn_x25iface_proto_close,
46801- &isdn_x25iface_xmit,
46802- &isdn_x25iface_receive,
46803- &isdn_x25iface_connect_ind,
46804- &isdn_x25iface_disconn_ind
46805+ .proto_new = &isdn_x25iface_proto_new,
46806+ .proto_del = &isdn_x25iface_proto_del,
46807+ .restart = &isdn_x25iface_proto_restart,
46808+ .close = &isdn_x25iface_proto_close,
46809+ .encap_and_xmit = &isdn_x25iface_xmit,
46810+ .data_ind = &isdn_x25iface_receive,
46811+ .connect_ind = &isdn_x25iface_connect_ind,
46812+ .disconn_ind = &isdn_x25iface_disconn_ind
46813 };
46814
46815 /* error message helper function */
46816diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
46817index 358a574..b4987ea 100644
46818--- a/drivers/isdn/icn/icn.c
46819+++ b/drivers/isdn/icn/icn.c
46820@@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
46821 if (count > len)
46822 count = len;
46823 if (user) {
46824- if (copy_from_user(msg, buf, count))
46825+ if (count > sizeof msg || copy_from_user(msg, buf, count))
46826 return -EFAULT;
46827 } else
46828 memcpy(msg, buf, count);
46829diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
46830index 52c4382..09e0c7c 100644
46831--- a/drivers/isdn/mISDN/dsp_cmx.c
46832+++ b/drivers/isdn/mISDN/dsp_cmx.c
46833@@ -1625,7 +1625,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
46834 static u16 dsp_count; /* last sample count */
46835 static int dsp_count_valid; /* if we have last sample count */
46836
46837-void
46838+void __intentional_overflow(-1)
46839 dsp_cmx_send(void *arg)
46840 {
46841 struct dsp_conf *conf;
46842diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
46843index 312ffd3..9263d05 100644
46844--- a/drivers/lguest/core.c
46845+++ b/drivers/lguest/core.c
46846@@ -96,9 +96,17 @@ static __init int map_switcher(void)
46847 * The end address needs +1 because __get_vm_area allocates an
46848 * extra guard page, so we need space for that.
46849 */
46850+
46851+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
46852+ switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
46853+ VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
46854+ + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
46855+#else
46856 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
46857 VM_ALLOC, switcher_addr, switcher_addr
46858 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
46859+#endif
46860+
46861 if (!switcher_vma) {
46862 err = -ENOMEM;
46863 printk("lguest: could not map switcher pages high\n");
46864@@ -121,7 +129,7 @@ static __init int map_switcher(void)
46865 * Now the Switcher is mapped at the right address, we can't fail!
46866 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
46867 */
46868- memcpy(switcher_vma->addr, start_switcher_text,
46869+ memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
46870 end_switcher_text - start_switcher_text);
46871
46872 printk(KERN_INFO "lguest: mapped switcher at %p\n",
46873diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
46874index e3abebc9..6a35328 100644
46875--- a/drivers/lguest/page_tables.c
46876+++ b/drivers/lguest/page_tables.c
46877@@ -585,7 +585,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
46878 /*:*/
46879
46880 #ifdef CONFIG_X86_PAE
46881-static void release_pmd(pmd_t *spmd)
46882+static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
46883 {
46884 /* If the entry's not present, there's nothing to release. */
46885 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
46886diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
46887index 6a4cd77..c9e2d9f 100644
46888--- a/drivers/lguest/x86/core.c
46889+++ b/drivers/lguest/x86/core.c
46890@@ -60,7 +60,7 @@ static struct {
46891 /* Offset from where switcher.S was compiled to where we've copied it */
46892 static unsigned long switcher_offset(void)
46893 {
46894- return switcher_addr - (unsigned long)start_switcher_text;
46895+ return switcher_addr - ktla_ktva((unsigned long)start_switcher_text);
46896 }
46897
46898 /* This cpu's struct lguest_pages (after the Switcher text page) */
46899@@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
46900 * These copies are pretty cheap, so we do them unconditionally: */
46901 /* Save the current Host top-level page directory.
46902 */
46903+
46904+#ifdef CONFIG_PAX_PER_CPU_PGD
46905+ pages->state.host_cr3 = read_cr3();
46906+#else
46907 pages->state.host_cr3 = __pa(current->mm->pgd);
46908+#endif
46909+
46910 /*
46911 * Set up the Guest's page tables to see this CPU's pages (and no
46912 * other CPU's pages).
46913@@ -494,7 +500,7 @@ void __init lguest_arch_host_init(void)
46914 * compiled-in switcher code and the high-mapped copy we just made.
46915 */
46916 for (i = 0; i < IDT_ENTRIES; i++)
46917- default_idt_entries[i] += switcher_offset();
46918+ default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
46919
46920 /*
46921 * Set up the Switcher's per-cpu areas.
46922@@ -577,7 +583,7 @@ void __init lguest_arch_host_init(void)
46923 * it will be undisturbed when we switch. To change %cs and jump we
46924 * need this structure to feed to Intel's "lcall" instruction.
46925 */
46926- lguest_entry.offset = (long)switch_to_guest + switcher_offset();
46927+ lguest_entry.offset = ktla_ktva((unsigned long)switch_to_guest) + switcher_offset();
46928 lguest_entry.segment = LGUEST_CS;
46929
46930 /*
46931diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
46932index 40634b0..4f5855e 100644
46933--- a/drivers/lguest/x86/switcher_32.S
46934+++ b/drivers/lguest/x86/switcher_32.S
46935@@ -87,6 +87,7 @@
46936 #include <asm/page.h>
46937 #include <asm/segment.h>
46938 #include <asm/lguest.h>
46939+#include <asm/processor-flags.h>
46940
46941 // We mark the start of the code to copy
46942 // It's placed in .text tho it's never run here
46943@@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
46944 // Changes type when we load it: damn Intel!
46945 // For after we switch over our page tables
46946 // That entry will be read-only: we'd crash.
46947+
46948+#ifdef CONFIG_PAX_KERNEXEC
46949+ mov %cr0, %edx
46950+ xor $X86_CR0_WP, %edx
46951+ mov %edx, %cr0
46952+#endif
46953+
46954 movl $(GDT_ENTRY_TSS*8), %edx
46955 ltr %dx
46956
46957@@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
46958 // Let's clear it again for our return.
46959 // The GDT descriptor of the Host
46960 // Points to the table after two "size" bytes
46961- movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
46962+ movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
46963 // Clear "used" from type field (byte 5, bit 2)
46964- andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
46965+ andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
46966+
46967+#ifdef CONFIG_PAX_KERNEXEC
46968+ mov %cr0, %eax
46969+ xor $X86_CR0_WP, %eax
46970+ mov %eax, %cr0
46971+#endif
46972
46973 // Once our page table's switched, the Guest is live!
46974 // The Host fades as we run this final step.
46975@@ -295,13 +309,12 @@ deliver_to_host:
46976 // I consulted gcc, and it gave
46977 // These instructions, which I gladly credit:
46978 leal (%edx,%ebx,8), %eax
46979- movzwl (%eax),%edx
46980- movl 4(%eax), %eax
46981- xorw %ax, %ax
46982- orl %eax, %edx
46983+ movl 4(%eax), %edx
46984+ movw (%eax), %dx
46985 // Now the address of the handler's in %edx
46986 // We call it now: its "iret" drops us home.
46987- jmp *%edx
46988+ ljmp $__KERNEL_CS, $1f
46989+1: jmp *%edx
46990
46991 // Every interrupt can come to us here
46992 // But we must truly tell each apart.
46993diff --git a/drivers/md/bcache/Kconfig b/drivers/md/bcache/Kconfig
46994index 4d20088..de60cb2 100644
46995--- a/drivers/md/bcache/Kconfig
46996+++ b/drivers/md/bcache/Kconfig
46997@@ -20,6 +20,7 @@ config BCACHE_CLOSURES_DEBUG
46998 bool "Debug closures"
46999 depends on BCACHE
47000 select DEBUG_FS
47001+ depends on !GRKERNSEC_KMEM
47002 ---help---
47003 Keeps all active closures in a linked list and provides a debugfs
47004 interface to list them, which makes it possible to see asynchronous
47005diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
47006index 79a6d63..47acff6 100644
47007--- a/drivers/md/bcache/closure.h
47008+++ b/drivers/md/bcache/closure.h
47009@@ -238,7 +238,7 @@ static inline void closure_set_stopped(struct closure *cl)
47010 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
47011 struct workqueue_struct *wq)
47012 {
47013- BUG_ON(object_is_on_stack(cl));
47014+ BUG_ON(object_starts_on_stack(cl));
47015 closure_set_ip(cl);
47016 cl->fn = fn;
47017 cl->wq = wq;
47018diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
47019index 48b5890..b0af0ca 100644
47020--- a/drivers/md/bitmap.c
47021+++ b/drivers/md/bitmap.c
47022@@ -1933,7 +1933,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
47023 chunk_kb ? "KB" : "B");
47024 if (bitmap->storage.file) {
47025 seq_printf(seq, ", file: ");
47026- seq_file_path(seq, bitmap->storage.file, " \t\n");
47027+ seq_file_path(seq, bitmap->storage.file, " \t\n\\");
47028 }
47029
47030 seq_printf(seq, "\n");
47031diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
47032index 720ceeb..030f1d4 100644
47033--- a/drivers/md/dm-ioctl.c
47034+++ b/drivers/md/dm-ioctl.c
47035@@ -1773,7 +1773,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
47036 cmd == DM_LIST_VERSIONS_CMD)
47037 return 0;
47038
47039- if ((cmd == DM_DEV_CREATE_CMD)) {
47040+ if (cmd == DM_DEV_CREATE_CMD) {
47041 if (!*param->name) {
47042 DMWARN("name not supplied when creating device");
47043 return -EINVAL;
47044diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
47045index d83696b..44f22f7 100644
47046--- a/drivers/md/dm-raid1.c
47047+++ b/drivers/md/dm-raid1.c
47048@@ -42,7 +42,7 @@ enum dm_raid1_error {
47049
47050 struct mirror {
47051 struct mirror_set *ms;
47052- atomic_t error_count;
47053+ atomic_unchecked_t error_count;
47054 unsigned long error_type;
47055 struct dm_dev *dev;
47056 sector_t offset;
47057@@ -188,7 +188,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
47058 struct mirror *m;
47059
47060 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
47061- if (!atomic_read(&m->error_count))
47062+ if (!atomic_read_unchecked(&m->error_count))
47063 return m;
47064
47065 return NULL;
47066@@ -220,7 +220,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
47067 * simple way to tell if a device has encountered
47068 * errors.
47069 */
47070- atomic_inc(&m->error_count);
47071+ atomic_inc_unchecked(&m->error_count);
47072
47073 if (test_and_set_bit(error_type, &m->error_type))
47074 return;
47075@@ -378,7 +378,7 @@ static void reset_ms_flags(struct mirror_set *ms)
47076
47077 ms->leg_failure = 0;
47078 for (m = 0; m < ms->nr_mirrors; m++) {
47079- atomic_set(&(ms->mirror[m].error_count), 0);
47080+ atomic_set_unchecked(&(ms->mirror[m].error_count), 0);
47081 ms->mirror[m].error_type = 0;
47082 }
47083 }
47084@@ -423,7 +423,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
47085 struct mirror *m = get_default_mirror(ms);
47086
47087 do {
47088- if (likely(!atomic_read(&m->error_count)))
47089+ if (likely(!atomic_read_unchecked(&m->error_count)))
47090 return m;
47091
47092 if (m-- == ms->mirror)
47093@@ -437,7 +437,7 @@ static int default_ok(struct mirror *m)
47094 {
47095 struct mirror *default_mirror = get_default_mirror(m->ms);
47096
47097- return !atomic_read(&default_mirror->error_count);
47098+ return !atomic_read_unchecked(&default_mirror->error_count);
47099 }
47100
47101 static int mirror_available(struct mirror_set *ms, struct bio *bio)
47102@@ -574,7 +574,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
47103 */
47104 if (likely(region_in_sync(ms, region, 1)))
47105 m = choose_mirror(ms, bio->bi_iter.bi_sector);
47106- else if (m && atomic_read(&m->error_count))
47107+ else if (m && atomic_read_unchecked(&m->error_count))
47108 m = NULL;
47109
47110 if (likely(m))
47111@@ -956,7 +956,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
47112 }
47113
47114 ms->mirror[mirror].ms = ms;
47115- atomic_set(&(ms->mirror[mirror].error_count), 0);
47116+ atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
47117 ms->mirror[mirror].error_type = 0;
47118 ms->mirror[mirror].offset = offset;
47119
47120@@ -1380,7 +1380,7 @@ static void mirror_resume(struct dm_target *ti)
47121 */
47122 static char device_status_char(struct mirror *m)
47123 {
47124- if (!atomic_read(&(m->error_count)))
47125+ if (!atomic_read_unchecked(&(m->error_count)))
47126 return 'A';
47127
47128 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
47129diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
47130index 8289804..12db118 100644
47131--- a/drivers/md/dm-stats.c
47132+++ b/drivers/md/dm-stats.c
47133@@ -435,7 +435,7 @@ do_sync_free:
47134 synchronize_rcu_expedited();
47135 dm_stat_free(&s->rcu_head);
47136 } else {
47137- ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
47138+ ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
47139 call_rcu(&s->rcu_head, dm_stat_free);
47140 }
47141 return 0;
47142@@ -648,8 +648,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
47143 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
47144 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
47145 ));
47146- ACCESS_ONCE(last->last_sector) = end_sector;
47147- ACCESS_ONCE(last->last_rw) = bi_rw;
47148+ ACCESS_ONCE_RW(last->last_sector) = end_sector;
47149+ ACCESS_ONCE_RW(last->last_rw) = bi_rw;
47150 }
47151
47152 rcu_read_lock();
47153diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
47154index a672a15..dc85e99 100644
47155--- a/drivers/md/dm-stripe.c
47156+++ b/drivers/md/dm-stripe.c
47157@@ -21,7 +21,7 @@ struct stripe {
47158 struct dm_dev *dev;
47159 sector_t physical_start;
47160
47161- atomic_t error_count;
47162+ atomic_unchecked_t error_count;
47163 };
47164
47165 struct stripe_c {
47166@@ -188,7 +188,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
47167 kfree(sc);
47168 return r;
47169 }
47170- atomic_set(&(sc->stripe[i].error_count), 0);
47171+ atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
47172 }
47173
47174 ti->private = sc;
47175@@ -332,7 +332,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
47176 DMEMIT("%d ", sc->stripes);
47177 for (i = 0; i < sc->stripes; i++) {
47178 DMEMIT("%s ", sc->stripe[i].dev->name);
47179- buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
47180+ buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
47181 'D' : 'A';
47182 }
47183 buffer[i] = '\0';
47184@@ -377,8 +377,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
47185 */
47186 for (i = 0; i < sc->stripes; i++)
47187 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
47188- atomic_inc(&(sc->stripe[i].error_count));
47189- if (atomic_read(&(sc->stripe[i].error_count)) <
47190+ atomic_inc_unchecked(&(sc->stripe[i].error_count));
47191+ if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
47192 DM_IO_ERROR_THRESHOLD)
47193 schedule_work(&sc->trigger_event);
47194 }
47195diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
47196index 16ba55a..31af906 100644
47197--- a/drivers/md/dm-table.c
47198+++ b/drivers/md/dm-table.c
47199@@ -305,7 +305,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
47200 if (!dev_size)
47201 return 0;
47202
47203- if ((start >= dev_size) || (start + len > dev_size)) {
47204+ if ((start >= dev_size) || (len > dev_size - start)) {
47205 DMWARN("%s: %s too small for target: "
47206 "start=%llu, len=%llu, dev_size=%llu",
47207 dm_device_name(ti->table->md), bdevname(bdev, b),
47208diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
47209index 6ba47cf..a870ba2 100644
47210--- a/drivers/md/dm-thin-metadata.c
47211+++ b/drivers/md/dm-thin-metadata.c
47212@@ -403,7 +403,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
47213 {
47214 pmd->info.tm = pmd->tm;
47215 pmd->info.levels = 2;
47216- pmd->info.value_type.context = pmd->data_sm;
47217+ pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
47218 pmd->info.value_type.size = sizeof(__le64);
47219 pmd->info.value_type.inc = data_block_inc;
47220 pmd->info.value_type.dec = data_block_dec;
47221@@ -422,7 +422,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
47222
47223 pmd->bl_info.tm = pmd->tm;
47224 pmd->bl_info.levels = 1;
47225- pmd->bl_info.value_type.context = pmd->data_sm;
47226+ pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
47227 pmd->bl_info.value_type.size = sizeof(__le64);
47228 pmd->bl_info.value_type.inc = data_block_inc;
47229 pmd->bl_info.value_type.dec = data_block_dec;
47230diff --git a/drivers/md/dm.c b/drivers/md/dm.c
47231index 3e32f4e..01e0a7f 100644
47232--- a/drivers/md/dm.c
47233+++ b/drivers/md/dm.c
47234@@ -194,9 +194,9 @@ struct mapped_device {
47235 /*
47236 * Event handling.
47237 */
47238- atomic_t event_nr;
47239+ atomic_unchecked_t event_nr;
47240 wait_queue_head_t eventq;
47241- atomic_t uevent_seq;
47242+ atomic_unchecked_t uevent_seq;
47243 struct list_head uevent_list;
47244 spinlock_t uevent_lock; /* Protect access to uevent_list */
47245
47246@@ -2339,8 +2339,8 @@ static struct mapped_device *alloc_dev(int minor)
47247 spin_lock_init(&md->deferred_lock);
47248 atomic_set(&md->holders, 1);
47249 atomic_set(&md->open_count, 0);
47250- atomic_set(&md->event_nr, 0);
47251- atomic_set(&md->uevent_seq, 0);
47252+ atomic_set_unchecked(&md->event_nr, 0);
47253+ atomic_set_unchecked(&md->uevent_seq, 0);
47254 INIT_LIST_HEAD(&md->uevent_list);
47255 INIT_LIST_HEAD(&md->table_devices);
47256 spin_lock_init(&md->uevent_lock);
47257@@ -2481,7 +2481,7 @@ static void event_callback(void *context)
47258
47259 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
47260
47261- atomic_inc(&md->event_nr);
47262+ atomic_inc_unchecked(&md->event_nr);
47263 wake_up(&md->eventq);
47264 }
47265
47266@@ -3479,18 +3479,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
47267
47268 uint32_t dm_next_uevent_seq(struct mapped_device *md)
47269 {
47270- return atomic_add_return(1, &md->uevent_seq);
47271+ return atomic_add_return_unchecked(1, &md->uevent_seq);
47272 }
47273
47274 uint32_t dm_get_event_nr(struct mapped_device *md)
47275 {
47276- return atomic_read(&md->event_nr);
47277+ return atomic_read_unchecked(&md->event_nr);
47278 }
47279
47280 int dm_wait_event(struct mapped_device *md, int event_nr)
47281 {
47282 return wait_event_interruptible(md->eventq,
47283- (event_nr != atomic_read(&md->event_nr)));
47284+ (event_nr != atomic_read_unchecked(&md->event_nr)));
47285 }
47286
47287 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
47288diff --git a/drivers/md/md.c b/drivers/md/md.c
47289index e25f00f..12caa60 100644
47290--- a/drivers/md/md.c
47291+++ b/drivers/md/md.c
47292@@ -197,10 +197,10 @@ EXPORT_SYMBOL_GPL(bio_clone_mddev);
47293 * start build, activate spare
47294 */
47295 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
47296-static atomic_t md_event_count;
47297+static atomic_unchecked_t md_event_count;
47298 void md_new_event(struct mddev *mddev)
47299 {
47300- atomic_inc(&md_event_count);
47301+ atomic_inc_unchecked(&md_event_count);
47302 wake_up(&md_event_waiters);
47303 }
47304 EXPORT_SYMBOL_GPL(md_new_event);
47305@@ -210,7 +210,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
47306 */
47307 static void md_new_event_inintr(struct mddev *mddev)
47308 {
47309- atomic_inc(&md_event_count);
47310+ atomic_inc_unchecked(&md_event_count);
47311 wake_up(&md_event_waiters);
47312 }
47313
47314@@ -1449,7 +1449,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
47315 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
47316 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
47317 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
47318- atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
47319+ atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
47320
47321 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
47322 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
47323@@ -1700,7 +1700,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
47324 else
47325 sb->resync_offset = cpu_to_le64(0);
47326
47327- sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
47328+ sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
47329
47330 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
47331 sb->size = cpu_to_le64(mddev->dev_sectors);
47332@@ -2622,7 +2622,7 @@ __ATTR_PREALLOC(state, S_IRUGO|S_IWUSR, state_show, state_store);
47333 static ssize_t
47334 errors_show(struct md_rdev *rdev, char *page)
47335 {
47336- return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
47337+ return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
47338 }
47339
47340 static ssize_t
47341@@ -2634,7 +2634,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
47342 rv = kstrtouint(buf, 10, &n);
47343 if (rv < 0)
47344 return rv;
47345- atomic_set(&rdev->corrected_errors, n);
47346+ atomic_set_unchecked(&rdev->corrected_errors, n);
47347 return len;
47348 }
47349 static struct rdev_sysfs_entry rdev_errors =
47350@@ -3071,8 +3071,8 @@ int md_rdev_init(struct md_rdev *rdev)
47351 rdev->sb_loaded = 0;
47352 rdev->bb_page = NULL;
47353 atomic_set(&rdev->nr_pending, 0);
47354- atomic_set(&rdev->read_errors, 0);
47355- atomic_set(&rdev->corrected_errors, 0);
47356+ atomic_set_unchecked(&rdev->read_errors, 0);
47357+ atomic_set_unchecked(&rdev->corrected_errors, 0);
47358
47359 INIT_LIST_HEAD(&rdev->same_set);
47360 init_waitqueue_head(&rdev->blocked_wait);
47361@@ -7256,7 +7256,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
47362
47363 spin_unlock(&pers_lock);
47364 seq_printf(seq, "\n");
47365- seq->poll_event = atomic_read(&md_event_count);
47366+ seq->poll_event = atomic_read_unchecked(&md_event_count);
47367 return 0;
47368 }
47369 if (v == (void*)2) {
47370@@ -7359,7 +7359,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
47371 return error;
47372
47373 seq = file->private_data;
47374- seq->poll_event = atomic_read(&md_event_count);
47375+ seq->poll_event = atomic_read_unchecked(&md_event_count);
47376 return error;
47377 }
47378
47379@@ -7376,7 +7376,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
47380 /* always allow read */
47381 mask = POLLIN | POLLRDNORM;
47382
47383- if (seq->poll_event != atomic_read(&md_event_count))
47384+ if (seq->poll_event != atomic_read_unchecked(&md_event_count))
47385 mask |= POLLERR | POLLPRI;
47386 return mask;
47387 }
47388@@ -7472,7 +7472,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
47389 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
47390 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
47391 (int)part_stat_read(&disk->part0, sectors[1]) -
47392- atomic_read(&disk->sync_io);
47393+ atomic_read_unchecked(&disk->sync_io);
47394 /* sync IO will cause sync_io to increase before the disk_stats
47395 * as sync_io is counted when a request starts, and
47396 * disk_stats is counted when it completes.
47397diff --git a/drivers/md/md.h b/drivers/md/md.h
47398index 7da6e9c..f0c1f10 100644
47399--- a/drivers/md/md.h
47400+++ b/drivers/md/md.h
47401@@ -96,13 +96,13 @@ struct md_rdev {
47402 * only maintained for arrays that
47403 * support hot removal
47404 */
47405- atomic_t read_errors; /* number of consecutive read errors that
47406+ atomic_unchecked_t read_errors; /* number of consecutive read errors that
47407 * we have tried to ignore.
47408 */
47409 struct timespec last_read_error; /* monotonic time since our
47410 * last read error
47411 */
47412- atomic_t corrected_errors; /* number of corrected read errors,
47413+ atomic_unchecked_t corrected_errors; /* number of corrected read errors,
47414 * for reporting to userspace and storing
47415 * in superblock.
47416 */
47417@@ -487,7 +487,7 @@ extern void mddev_unlock(struct mddev *mddev);
47418
47419 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
47420 {
47421- atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
47422+ atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
47423 }
47424
47425 struct md_personality
47426diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
47427index 5309129..7fb096e 100644
47428--- a/drivers/md/persistent-data/dm-space-map-metadata.c
47429+++ b/drivers/md/persistent-data/dm-space-map-metadata.c
47430@@ -691,7 +691,7 @@ static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
47431 * Flick into a mode where all blocks get allocated in the new area.
47432 */
47433 smm->begin = old_len;
47434- memcpy(sm, &bootstrap_ops, sizeof(*sm));
47435+ memcpy((void *)sm, &bootstrap_ops, sizeof(*sm));
47436
47437 /*
47438 * Extend.
47439@@ -728,7 +728,7 @@ out:
47440 /*
47441 * Switch back to normal behaviour.
47442 */
47443- memcpy(sm, &ops, sizeof(*sm));
47444+ memcpy((void *)sm, &ops, sizeof(*sm));
47445 return r;
47446 }
47447
47448diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
47449index 3e6d115..ffecdeb 100644
47450--- a/drivers/md/persistent-data/dm-space-map.h
47451+++ b/drivers/md/persistent-data/dm-space-map.h
47452@@ -71,6 +71,7 @@ struct dm_space_map {
47453 dm_sm_threshold_fn fn,
47454 void *context);
47455 };
47456+typedef struct dm_space_map __no_const dm_space_map_no_const;
47457
47458 /*----------------------------------------------------------------*/
47459
47460diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
47461index 967a4ed..002d339 100644
47462--- a/drivers/md/raid1.c
47463+++ b/drivers/md/raid1.c
47464@@ -1937,7 +1937,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
47465 if (r1_sync_page_io(rdev, sect, s,
47466 bio->bi_io_vec[idx].bv_page,
47467 READ) != 0)
47468- atomic_add(s, &rdev->corrected_errors);
47469+ atomic_add_unchecked(s, &rdev->corrected_errors);
47470 }
47471 sectors -= s;
47472 sect += s;
47473@@ -2170,7 +2170,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
47474 !test_bit(Faulty, &rdev->flags)) {
47475 if (r1_sync_page_io(rdev, sect, s,
47476 conf->tmppage, READ)) {
47477- atomic_add(s, &rdev->corrected_errors);
47478+ atomic_add_unchecked(s, &rdev->corrected_errors);
47479 printk(KERN_INFO
47480 "md/raid1:%s: read error corrected "
47481 "(%d sectors at %llu on %s)\n",
47482diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
47483index 38c58e1..89c3e0f 100644
47484--- a/drivers/md/raid10.c
47485+++ b/drivers/md/raid10.c
47486@@ -1934,7 +1934,7 @@ static void end_sync_read(struct bio *bio, int error)
47487 /* The write handler will notice the lack of
47488 * R10BIO_Uptodate and record any errors etc
47489 */
47490- atomic_add(r10_bio->sectors,
47491+ atomic_add_unchecked(r10_bio->sectors,
47492 &conf->mirrors[d].rdev->corrected_errors);
47493
47494 /* for reconstruct, we always reschedule after a read.
47495@@ -2281,7 +2281,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
47496 {
47497 struct timespec cur_time_mon;
47498 unsigned long hours_since_last;
47499- unsigned int read_errors = atomic_read(&rdev->read_errors);
47500+ unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
47501
47502 ktime_get_ts(&cur_time_mon);
47503
47504@@ -2303,9 +2303,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
47505 * overflowing the shift of read_errors by hours_since_last.
47506 */
47507 if (hours_since_last >= 8 * sizeof(read_errors))
47508- atomic_set(&rdev->read_errors, 0);
47509+ atomic_set_unchecked(&rdev->read_errors, 0);
47510 else
47511- atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
47512+ atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
47513 }
47514
47515 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
47516@@ -2359,8 +2359,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
47517 return;
47518
47519 check_decay_read_errors(mddev, rdev);
47520- atomic_inc(&rdev->read_errors);
47521- if (atomic_read(&rdev->read_errors) > max_read_errors) {
47522+ atomic_inc_unchecked(&rdev->read_errors);
47523+ if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
47524 char b[BDEVNAME_SIZE];
47525 bdevname(rdev->bdev, b);
47526
47527@@ -2368,7 +2368,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
47528 "md/raid10:%s: %s: Raid device exceeded "
47529 "read_error threshold [cur %d:max %d]\n",
47530 mdname(mddev), b,
47531- atomic_read(&rdev->read_errors), max_read_errors);
47532+ atomic_read_unchecked(&rdev->read_errors), max_read_errors);
47533 printk(KERN_NOTICE
47534 "md/raid10:%s: %s: Failing raid device\n",
47535 mdname(mddev), b);
47536@@ -2523,7 +2523,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
47537 sect +
47538 choose_data_offset(r10_bio, rdev)),
47539 bdevname(rdev->bdev, b));
47540- atomic_add(s, &rdev->corrected_errors);
47541+ atomic_add_unchecked(s, &rdev->corrected_errors);
47542 }
47543
47544 rdev_dec_pending(rdev, mddev);
47545diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
47546index f757023..f958632 100644
47547--- a/drivers/md/raid5.c
47548+++ b/drivers/md/raid5.c
47549@@ -1119,23 +1119,23 @@ async_copy_data(int frombio, struct bio *bio, struct page **page,
47550 struct bio_vec bvl;
47551 struct bvec_iter iter;
47552 struct page *bio_page;
47553- int page_offset;
47554+ s64 page_offset;
47555 struct async_submit_ctl submit;
47556 enum async_tx_flags flags = 0;
47557
47558 if (bio->bi_iter.bi_sector >= sector)
47559- page_offset = (signed)(bio->bi_iter.bi_sector - sector) * 512;
47560+ page_offset = (s64)(bio->bi_iter.bi_sector - sector) * 512;
47561 else
47562- page_offset = (signed)(sector - bio->bi_iter.bi_sector) * -512;
47563+ page_offset = (s64)(sector - bio->bi_iter.bi_sector) * -512;
47564
47565 if (frombio)
47566 flags |= ASYNC_TX_FENCE;
47567 init_async_submit(&submit, flags, tx, NULL, NULL, NULL);
47568
47569 bio_for_each_segment(bvl, bio, iter) {
47570- int len = bvl.bv_len;
47571- int clen;
47572- int b_offset = 0;
47573+ s64 len = bvl.bv_len;
47574+ s64 clen;
47575+ s64 b_offset = 0;
47576
47577 if (page_offset < 0) {
47578 b_offset = -page_offset;
47579@@ -2028,6 +2028,10 @@ static int grow_one_stripe(struct r5conf *conf, gfp_t gfp)
47580 return 1;
47581 }
47582
47583+#ifdef CONFIG_GRKERNSEC_HIDESYM
47584+static atomic_unchecked_t raid5_cache_id = ATOMIC_INIT(0);
47585+#endif
47586+
47587 static int grow_stripes(struct r5conf *conf, int num)
47588 {
47589 struct kmem_cache *sc;
47590@@ -2038,7 +2042,11 @@ static int grow_stripes(struct r5conf *conf, int num)
47591 "raid%d-%s", conf->level, mdname(conf->mddev));
47592 else
47593 sprintf(conf->cache_name[0],
47594+#ifdef CONFIG_GRKERNSEC_HIDESYM
47595+ "raid%d-%08lx", conf->level, atomic_inc_return_unchecked(&raid5_cache_id));
47596+#else
47597 "raid%d-%p", conf->level, conf->mddev);
47598+#endif
47599 sprintf(conf->cache_name[1], "%s-alt", conf->cache_name[0]);
47600
47601 conf->active_name = 0;
47602@@ -2331,21 +2339,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
47603 mdname(conf->mddev), STRIPE_SECTORS,
47604 (unsigned long long)s,
47605 bdevname(rdev->bdev, b));
47606- atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
47607+ atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
47608 clear_bit(R5_ReadError, &sh->dev[i].flags);
47609 clear_bit(R5_ReWrite, &sh->dev[i].flags);
47610 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
47611 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
47612
47613- if (atomic_read(&rdev->read_errors))
47614- atomic_set(&rdev->read_errors, 0);
47615+ if (atomic_read_unchecked(&rdev->read_errors))
47616+ atomic_set_unchecked(&rdev->read_errors, 0);
47617 } else {
47618 const char *bdn = bdevname(rdev->bdev, b);
47619 int retry = 0;
47620 int set_bad = 0;
47621
47622 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
47623- atomic_inc(&rdev->read_errors);
47624+ atomic_inc_unchecked(&rdev->read_errors);
47625 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
47626 printk_ratelimited(
47627 KERN_WARNING
47628@@ -2373,7 +2381,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
47629 mdname(conf->mddev),
47630 (unsigned long long)s,
47631 bdn);
47632- } else if (atomic_read(&rdev->read_errors)
47633+ } else if (atomic_read_unchecked(&rdev->read_errors)
47634 > conf->max_nr_stripes)
47635 printk(KERN_WARNING
47636 "md/raid:%s: Too many read errors, failing device %s.\n",
47637diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
47638index 13bb57f..0ca21b2 100644
47639--- a/drivers/media/dvb-core/dvbdev.c
47640+++ b/drivers/media/dvb-core/dvbdev.c
47641@@ -272,7 +272,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
47642 const struct dvb_device *template, void *priv, int type)
47643 {
47644 struct dvb_device *dvbdev;
47645- struct file_operations *dvbdevfops;
47646+ file_operations_no_const *dvbdevfops;
47647 struct device *clsdev;
47648 int minor;
47649 int id;
47650diff --git a/drivers/media/dvb-frontends/af9033.h b/drivers/media/dvb-frontends/af9033.h
47651index 6ad22b6..6e90e2a 100644
47652--- a/drivers/media/dvb-frontends/af9033.h
47653+++ b/drivers/media/dvb-frontends/af9033.h
47654@@ -96,6 +96,6 @@ struct af9033_ops {
47655 int (*pid_filter_ctrl)(struct dvb_frontend *fe, int onoff);
47656 int (*pid_filter)(struct dvb_frontend *fe, int index, u16 pid,
47657 int onoff);
47658-};
47659+} __no_const;
47660
47661 #endif /* AF9033_H */
47662diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
47663index 6ae9899..07d8543 100644
47664--- a/drivers/media/dvb-frontends/dib3000.h
47665+++ b/drivers/media/dvb-frontends/dib3000.h
47666@@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
47667 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
47668 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
47669 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
47670-};
47671+} __no_const;
47672
47673 #if IS_REACHABLE(CONFIG_DVB_DIB3000MB)
47674 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
47675diff --git a/drivers/media/dvb-frontends/dib7000p.h b/drivers/media/dvb-frontends/dib7000p.h
47676index baa2789..c8de7fe 100644
47677--- a/drivers/media/dvb-frontends/dib7000p.h
47678+++ b/drivers/media/dvb-frontends/dib7000p.h
47679@@ -64,7 +64,7 @@ struct dib7000p_ops {
47680 int (*get_adc_power)(struct dvb_frontend *fe);
47681 int (*slave_reset)(struct dvb_frontend *fe);
47682 struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000p_config *cfg);
47683-};
47684+} __no_const;
47685
47686 #if IS_REACHABLE(CONFIG_DVB_DIB7000P)
47687 void *dib7000p_attach(struct dib7000p_ops *ops);
47688diff --git a/drivers/media/dvb-frontends/dib8000.h b/drivers/media/dvb-frontends/dib8000.h
47689index 2b8b4b1..8cef451 100644
47690--- a/drivers/media/dvb-frontends/dib8000.h
47691+++ b/drivers/media/dvb-frontends/dib8000.h
47692@@ -61,7 +61,7 @@ struct dib8000_ops {
47693 int (*pid_filter_ctrl)(struct dvb_frontend *fe, u8 onoff);
47694 int (*pid_filter)(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff);
47695 struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg);
47696-};
47697+} __no_const;
47698
47699 #if IS_REACHABLE(CONFIG_DVB_DIB8000)
47700 void *dib8000_attach(struct dib8000_ops *ops);
47701diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
47702index 400e5ca..f69f748 100644
47703--- a/drivers/media/pci/cx88/cx88-video.c
47704+++ b/drivers/media/pci/cx88/cx88-video.c
47705@@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
47706
47707 /* ------------------------------------------------------------------ */
47708
47709-static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47710-static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47711-static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47712+static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47713+static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47714+static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47715
47716 module_param_array(video_nr, int, NULL, 0444);
47717 module_param_array(vbi_nr, int, NULL, 0444);
47718diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
47719index 8616fa8..e16eeaf 100644
47720--- a/drivers/media/pci/ivtv/ivtv-driver.c
47721+++ b/drivers/media/pci/ivtv/ivtv-driver.c
47722@@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
47723 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
47724
47725 /* ivtv instance counter */
47726-static atomic_t ivtv_instance = ATOMIC_INIT(0);
47727+static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
47728
47729 /* Parameter declarations */
47730 static int cardtype[IVTV_MAX_CARDS];
47731diff --git a/drivers/media/pci/solo6x10/solo6x10-core.c b/drivers/media/pci/solo6x10/solo6x10-core.c
47732index 570d119..ed25830 100644
47733--- a/drivers/media/pci/solo6x10/solo6x10-core.c
47734+++ b/drivers/media/pci/solo6x10/solo6x10-core.c
47735@@ -424,7 +424,7 @@ static void solo_device_release(struct device *dev)
47736
47737 static int solo_sysfs_init(struct solo_dev *solo_dev)
47738 {
47739- struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47740+ bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47741 struct device *dev = &solo_dev->dev;
47742 const char *driver;
47743 int i;
47744diff --git a/drivers/media/pci/solo6x10/solo6x10-g723.c b/drivers/media/pci/solo6x10/solo6x10-g723.c
47745index 7ddc767..1c24361 100644
47746--- a/drivers/media/pci/solo6x10/solo6x10-g723.c
47747+++ b/drivers/media/pci/solo6x10/solo6x10-g723.c
47748@@ -351,7 +351,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
47749
47750 int solo_g723_init(struct solo_dev *solo_dev)
47751 {
47752- static struct snd_device_ops ops = { NULL };
47753+ static struct snd_device_ops ops = { };
47754 struct snd_card *card;
47755 struct snd_kcontrol_new kctl;
47756 char name[32];
47757diff --git a/drivers/media/pci/solo6x10/solo6x10-p2m.c b/drivers/media/pci/solo6x10/solo6x10-p2m.c
47758index 8c84846..27b4f83 100644
47759--- a/drivers/media/pci/solo6x10/solo6x10-p2m.c
47760+++ b/drivers/media/pci/solo6x10/solo6x10-p2m.c
47761@@ -73,7 +73,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47762
47763 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47764 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47765- p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47766+ p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47767 if (p2m_id < 0)
47768 p2m_id = -p2m_id;
47769 }
47770diff --git a/drivers/media/pci/solo6x10/solo6x10.h b/drivers/media/pci/solo6x10/solo6x10.h
47771index 1ca54b0..7d7cb9a 100644
47772--- a/drivers/media/pci/solo6x10/solo6x10.h
47773+++ b/drivers/media/pci/solo6x10/solo6x10.h
47774@@ -218,7 +218,7 @@ struct solo_dev {
47775
47776 /* P2M DMA Engine */
47777 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47778- atomic_t p2m_count;
47779+ atomic_unchecked_t p2m_count;
47780 int p2m_jiffies;
47781 unsigned int p2m_timeouts;
47782
47783diff --git a/drivers/media/pci/tw68/tw68-core.c b/drivers/media/pci/tw68/tw68-core.c
47784index c135165..dc69499 100644
47785--- a/drivers/media/pci/tw68/tw68-core.c
47786+++ b/drivers/media/pci/tw68/tw68-core.c
47787@@ -60,7 +60,7 @@ static unsigned int card[] = {[0 ... (TW68_MAXBOARDS - 1)] = UNSET };
47788 module_param_array(card, int, NULL, 0444);
47789 MODULE_PARM_DESC(card, "card type");
47790
47791-static atomic_t tw68_instance = ATOMIC_INIT(0);
47792+static atomic_unchecked_t tw68_instance = ATOMIC_INIT(0);
47793
47794 /* ------------------------------------------------------------------ */
47795
47796diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
47797index f09c5f1..38f6d65 100644
47798--- a/drivers/media/platform/omap/omap_vout.c
47799+++ b/drivers/media/platform/omap/omap_vout.c
47800@@ -63,7 +63,6 @@ enum omap_vout_channels {
47801 OMAP_VIDEO2,
47802 };
47803
47804-static struct videobuf_queue_ops video_vbq_ops;
47805 /* Variables configurable through module params*/
47806 static u32 video1_numbuffers = 3;
47807 static u32 video2_numbuffers = 3;
47808@@ -1008,6 +1007,12 @@ static int omap_vout_open(struct file *file)
47809 {
47810 struct videobuf_queue *q;
47811 struct omap_vout_device *vout = NULL;
47812+ static struct videobuf_queue_ops video_vbq_ops = {
47813+ .buf_setup = omap_vout_buffer_setup,
47814+ .buf_prepare = omap_vout_buffer_prepare,
47815+ .buf_release = omap_vout_buffer_release,
47816+ .buf_queue = omap_vout_buffer_queue,
47817+ };
47818
47819 vout = video_drvdata(file);
47820 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
47821@@ -1025,10 +1030,6 @@ static int omap_vout_open(struct file *file)
47822 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
47823
47824 q = &vout->vbq;
47825- video_vbq_ops.buf_setup = omap_vout_buffer_setup;
47826- video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
47827- video_vbq_ops.buf_release = omap_vout_buffer_release;
47828- video_vbq_ops.buf_queue = omap_vout_buffer_queue;
47829 spin_lock_init(&vout->vbq_lock);
47830
47831 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
47832diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
47833index fb2acc5..a2fcbdc4 100644
47834--- a/drivers/media/platform/s5p-tv/mixer.h
47835+++ b/drivers/media/platform/s5p-tv/mixer.h
47836@@ -156,7 +156,7 @@ struct mxr_layer {
47837 /** layer index (unique identifier) */
47838 int idx;
47839 /** callbacks for layer methods */
47840- struct mxr_layer_ops ops;
47841+ struct mxr_layer_ops *ops;
47842 /** format array */
47843 const struct mxr_format **fmt_array;
47844 /** size of format array */
47845diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
47846index 74344c7..a39e70e 100644
47847--- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
47848+++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
47849@@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
47850 {
47851 struct mxr_layer *layer;
47852 int ret;
47853- struct mxr_layer_ops ops = {
47854+ static struct mxr_layer_ops ops = {
47855 .release = mxr_graph_layer_release,
47856 .buffer_set = mxr_graph_buffer_set,
47857 .stream_set = mxr_graph_stream_set,
47858diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
47859index b713403..53cb5ad 100644
47860--- a/drivers/media/platform/s5p-tv/mixer_reg.c
47861+++ b/drivers/media/platform/s5p-tv/mixer_reg.c
47862@@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
47863 layer->update_buf = next;
47864 }
47865
47866- layer->ops.buffer_set(layer, layer->update_buf);
47867+ layer->ops->buffer_set(layer, layer->update_buf);
47868
47869 if (done && done != layer->shadow_buf)
47870 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
47871diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
47872index 751f3b6..d829203 100644
47873--- a/drivers/media/platform/s5p-tv/mixer_video.c
47874+++ b/drivers/media/platform/s5p-tv/mixer_video.c
47875@@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
47876 layer->geo.src.height = layer->geo.src.full_height;
47877
47878 mxr_geometry_dump(mdev, &layer->geo);
47879- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
47880+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
47881 mxr_geometry_dump(mdev, &layer->geo);
47882 }
47883
47884@@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
47885 layer->geo.dst.full_width = mbus_fmt.width;
47886 layer->geo.dst.full_height = mbus_fmt.height;
47887 layer->geo.dst.field = mbus_fmt.field;
47888- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
47889+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
47890
47891 mxr_geometry_dump(mdev, &layer->geo);
47892 }
47893@@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
47894 /* set source size to highest accepted value */
47895 geo->src.full_width = max(geo->dst.full_width, pix->width);
47896 geo->src.full_height = max(geo->dst.full_height, pix->height);
47897- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
47898+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
47899 mxr_geometry_dump(mdev, &layer->geo);
47900 /* set cropping to total visible screen */
47901 geo->src.width = pix->width;
47902@@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
47903 geo->src.x_offset = 0;
47904 geo->src.y_offset = 0;
47905 /* assure consistency of geometry */
47906- layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
47907+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
47908 mxr_geometry_dump(mdev, &layer->geo);
47909 /* set full size to lowest possible value */
47910 geo->src.full_width = 0;
47911 geo->src.full_height = 0;
47912- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
47913+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
47914 mxr_geometry_dump(mdev, &layer->geo);
47915
47916 /* returning results */
47917@@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
47918 target->width = s->r.width;
47919 target->height = s->r.height;
47920
47921- layer->ops.fix_geometry(layer, stage, s->flags);
47922+ layer->ops->fix_geometry(layer, stage, s->flags);
47923
47924 /* retrieve update selection rectangle */
47925 res.left = target->x_offset;
47926@@ -938,13 +938,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
47927 mxr_output_get(mdev);
47928
47929 mxr_layer_update_output(layer);
47930- layer->ops.format_set(layer);
47931+ layer->ops->format_set(layer);
47932 /* enabling layer in hardware */
47933 spin_lock_irqsave(&layer->enq_slock, flags);
47934 layer->state = MXR_LAYER_STREAMING;
47935 spin_unlock_irqrestore(&layer->enq_slock, flags);
47936
47937- layer->ops.stream_set(layer, MXR_ENABLE);
47938+ layer->ops->stream_set(layer, MXR_ENABLE);
47939 mxr_streamer_get(mdev);
47940
47941 return 0;
47942@@ -1014,7 +1014,7 @@ static void stop_streaming(struct vb2_queue *vq)
47943 spin_unlock_irqrestore(&layer->enq_slock, flags);
47944
47945 /* disabling layer in hardware */
47946- layer->ops.stream_set(layer, MXR_DISABLE);
47947+ layer->ops->stream_set(layer, MXR_DISABLE);
47948 /* remove one streamer */
47949 mxr_streamer_put(mdev);
47950 /* allow changes in output configuration */
47951@@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
47952
47953 void mxr_layer_release(struct mxr_layer *layer)
47954 {
47955- if (layer->ops.release)
47956- layer->ops.release(layer);
47957+ if (layer->ops->release)
47958+ layer->ops->release(layer);
47959 }
47960
47961 void mxr_base_layer_release(struct mxr_layer *layer)
47962@@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
47963
47964 layer->mdev = mdev;
47965 layer->idx = idx;
47966- layer->ops = *ops;
47967+ layer->ops = ops;
47968
47969 spin_lock_init(&layer->enq_slock);
47970 INIT_LIST_HEAD(&layer->enq_list);
47971diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
47972index c9388c4..ce71ece 100644
47973--- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
47974+++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
47975@@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
47976 {
47977 struct mxr_layer *layer;
47978 int ret;
47979- struct mxr_layer_ops ops = {
47980+ static struct mxr_layer_ops ops = {
47981 .release = mxr_vp_layer_release,
47982 .buffer_set = mxr_vp_buffer_set,
47983 .stream_set = mxr_vp_stream_set,
47984diff --git a/drivers/media/platform/vivid/vivid-osd.c b/drivers/media/platform/vivid/vivid-osd.c
47985index 084d346..e15eef6 100644
47986--- a/drivers/media/platform/vivid/vivid-osd.c
47987+++ b/drivers/media/platform/vivid/vivid-osd.c
47988@@ -85,6 +85,7 @@ static int vivid_fb_ioctl(struct fb_info *info, unsigned cmd, unsigned long arg)
47989 case FBIOGET_VBLANK: {
47990 struct fb_vblank vblank;
47991
47992+ memset(&vblank, 0, sizeof(vblank));
47993 vblank.flags = FB_VBLANK_HAVE_COUNT | FB_VBLANK_HAVE_VCOUNT |
47994 FB_VBLANK_HAVE_VSYNC;
47995 vblank.count = 0;
47996diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
47997index 82affae..42833ec 100644
47998--- a/drivers/media/radio/radio-cadet.c
47999+++ b/drivers/media/radio/radio-cadet.c
48000@@ -333,6 +333,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
48001 unsigned char readbuf[RDS_BUFFER];
48002 int i = 0;
48003
48004+ if (count > RDS_BUFFER)
48005+ return -EFAULT;
48006 mutex_lock(&dev->lock);
48007 if (dev->rdsstat == 0)
48008 cadet_start_rds(dev);
48009@@ -349,8 +351,9 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
48010 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
48011 mutex_unlock(&dev->lock);
48012
48013- if (i && copy_to_user(data, readbuf, i))
48014- return -EFAULT;
48015+ if (i > sizeof(readbuf) || (i && copy_to_user(data, readbuf, i)))
48016+ i = -EFAULT;
48017+
48018 return i;
48019 }
48020
48021diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
48022index 5236035..c622c74 100644
48023--- a/drivers/media/radio/radio-maxiradio.c
48024+++ b/drivers/media/radio/radio-maxiradio.c
48025@@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
48026 /* TEA5757 pin mappings */
48027 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
48028
48029-static atomic_t maxiradio_instance = ATOMIC_INIT(0);
48030+static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
48031
48032 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
48033 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
48034diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
48035index 050b3bb..79f62b9 100644
48036--- a/drivers/media/radio/radio-shark.c
48037+++ b/drivers/media/radio/radio-shark.c
48038@@ -79,7 +79,7 @@ struct shark_device {
48039 u32 last_val;
48040 };
48041
48042-static atomic_t shark_instance = ATOMIC_INIT(0);
48043+static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
48044
48045 static void shark_write_val(struct snd_tea575x *tea, u32 val)
48046 {
48047diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
48048index 8654e0d..0608a64 100644
48049--- a/drivers/media/radio/radio-shark2.c
48050+++ b/drivers/media/radio/radio-shark2.c
48051@@ -74,7 +74,7 @@ struct shark_device {
48052 u8 *transfer_buffer;
48053 };
48054
48055-static atomic_t shark_instance = ATOMIC_INIT(0);
48056+static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
48057
48058 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
48059 {
48060diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
48061index 9cbb8cd..2bf2ff3 100644
48062--- a/drivers/media/radio/radio-si476x.c
48063+++ b/drivers/media/radio/radio-si476x.c
48064@@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
48065 struct si476x_radio *radio;
48066 struct v4l2_ctrl *ctrl;
48067
48068- static atomic_t instance = ATOMIC_INIT(0);
48069+ static atomic_unchecked_t instance = ATOMIC_INIT(0);
48070
48071 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
48072 if (!radio)
48073diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
48074index 704397f..4d05977 100644
48075--- a/drivers/media/radio/wl128x/fmdrv_common.c
48076+++ b/drivers/media/radio/wl128x/fmdrv_common.c
48077@@ -71,7 +71,7 @@ module_param(default_rds_buf, uint, 0444);
48078 MODULE_PARM_DESC(rds_buf, "RDS buffer entries");
48079
48080 /* Radio Nr */
48081-static u32 radio_nr = -1;
48082+static int radio_nr = -1;
48083 module_param(radio_nr, int, 0444);
48084 MODULE_PARM_DESC(radio_nr, "Radio Nr");
48085
48086diff --git a/drivers/media/usb/dvb-usb/cinergyT2-core.c b/drivers/media/usb/dvb-usb/cinergyT2-core.c
48087index 9fd1527..8927230 100644
48088--- a/drivers/media/usb/dvb-usb/cinergyT2-core.c
48089+++ b/drivers/media/usb/dvb-usb/cinergyT2-core.c
48090@@ -50,29 +50,73 @@ static struct dvb_usb_device_properties cinergyt2_properties;
48091
48092 static int cinergyt2_streaming_ctrl(struct dvb_usb_adapter *adap, int enable)
48093 {
48094- char buf[] = { CINERGYT2_EP1_CONTROL_STREAM_TRANSFER, enable ? 1 : 0 };
48095- char result[64];
48096- return dvb_usb_generic_rw(adap->dev, buf, sizeof(buf), result,
48097- sizeof(result), 0);
48098+ char *buf;
48099+ char *result;
48100+ int retval;
48101+
48102+ buf = kmalloc(2, GFP_KERNEL);
48103+ if (buf == NULL)
48104+ return -ENOMEM;
48105+ result = kmalloc(64, GFP_KERNEL);
48106+ if (result == NULL) {
48107+ kfree(buf);
48108+ return -ENOMEM;
48109+ }
48110+
48111+ buf[0] = CINERGYT2_EP1_CONTROL_STREAM_TRANSFER;
48112+ buf[1] = enable ? 1 : 0;
48113+
48114+ retval = dvb_usb_generic_rw(adap->dev, buf, 2, result, 64, 0);
48115+
48116+ kfree(buf);
48117+ kfree(result);
48118+ return retval;
48119 }
48120
48121 static int cinergyt2_power_ctrl(struct dvb_usb_device *d, int enable)
48122 {
48123- char buf[] = { CINERGYT2_EP1_SLEEP_MODE, enable ? 0 : 1 };
48124- char state[3];
48125- return dvb_usb_generic_rw(d, buf, sizeof(buf), state, sizeof(state), 0);
48126+ char *buf;
48127+ char *state;
48128+ int retval;
48129+
48130+ buf = kmalloc(2, GFP_KERNEL);
48131+ if (buf == NULL)
48132+ return -ENOMEM;
48133+ state = kmalloc(3, GFP_KERNEL);
48134+ if (state == NULL) {
48135+ kfree(buf);
48136+ return -ENOMEM;
48137+ }
48138+
48139+ buf[0] = CINERGYT2_EP1_SLEEP_MODE;
48140+ buf[1] = enable ? 1 : 0;
48141+
48142+ retval = dvb_usb_generic_rw(d, buf, 2, state, 3, 0);
48143+
48144+ kfree(buf);
48145+ kfree(state);
48146+ return retval;
48147 }
48148
48149 static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
48150 {
48151- char query[] = { CINERGYT2_EP1_GET_FIRMWARE_VERSION };
48152- char state[3];
48153+ char *query;
48154+ char *state;
48155 int ret;
48156+ query = kmalloc(1, GFP_KERNEL);
48157+ if (query == NULL)
48158+ return -ENOMEM;
48159+ state = kmalloc(3, GFP_KERNEL);
48160+ if (state == NULL) {
48161+ kfree(query);
48162+ return -ENOMEM;
48163+ }
48164+
48165+ query[0] = CINERGYT2_EP1_GET_FIRMWARE_VERSION;
48166
48167 adap->fe_adap[0].fe = cinergyt2_fe_attach(adap->dev);
48168
48169- ret = dvb_usb_generic_rw(adap->dev, query, sizeof(query), state,
48170- sizeof(state), 0);
48171+ ret = dvb_usb_generic_rw(adap->dev, query, 1, state, 3, 0);
48172 if (ret < 0) {
48173 deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep "
48174 "state info\n");
48175@@ -80,7 +124,8 @@ static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
48176
48177 /* Copy this pointer as we are gonna need it in the release phase */
48178 cinergyt2_usb_device = adap->dev;
48179-
48180+ kfree(query);
48181+ kfree(state);
48182 return 0;
48183 }
48184
48185@@ -141,12 +186,23 @@ static int repeatable_keys[] = {
48186 static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
48187 {
48188 struct cinergyt2_state *st = d->priv;
48189- u8 key[5] = {0, 0, 0, 0, 0}, cmd = CINERGYT2_EP1_GET_RC_EVENTS;
48190+ u8 *key, *cmd;
48191 int i;
48192
48193+ cmd = kmalloc(1, GFP_KERNEL);
48194+ if (cmd == NULL)
48195+ return -EINVAL;
48196+ key = kzalloc(5, GFP_KERNEL);
48197+ if (key == NULL) {
48198+ kfree(cmd);
48199+ return -EINVAL;
48200+ }
48201+
48202+ cmd[0] = CINERGYT2_EP1_GET_RC_EVENTS;
48203+
48204 *state = REMOTE_NO_KEY_PRESSED;
48205
48206- dvb_usb_generic_rw(d, &cmd, 1, key, sizeof(key), 0);
48207+ dvb_usb_generic_rw(d, cmd, 1, key, 5, 0);
48208 if (key[4] == 0xff) {
48209 /* key repeat */
48210 st->rc_counter++;
48211@@ -157,12 +213,12 @@ static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
48212 *event = d->last_event;
48213 deb_rc("repeat key, event %x\n",
48214 *event);
48215- return 0;
48216+ goto out;
48217 }
48218 }
48219 deb_rc("repeated key (non repeatable)\n");
48220 }
48221- return 0;
48222+ goto out;
48223 }
48224
48225 /* hack to pass checksum on the custom field */
48226@@ -174,6 +230,9 @@ static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
48227
48228 deb_rc("key: %*ph\n", 5, key);
48229 }
48230+out:
48231+ kfree(cmd);
48232+ kfree(key);
48233 return 0;
48234 }
48235
48236diff --git a/drivers/media/usb/dvb-usb/cinergyT2-fe.c b/drivers/media/usb/dvb-usb/cinergyT2-fe.c
48237index b3ec743..9c0e418 100644
48238--- a/drivers/media/usb/dvb-usb/cinergyT2-fe.c
48239+++ b/drivers/media/usb/dvb-usb/cinergyT2-fe.c
48240@@ -145,103 +145,176 @@ static int cinergyt2_fe_read_status(struct dvb_frontend *fe,
48241 enum fe_status *status)
48242 {
48243 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48244- struct dvbt_get_status_msg result;
48245- u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48246+ struct dvbt_get_status_msg *result;
48247+ u8 *cmd;
48248 int ret;
48249
48250- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&result,
48251- sizeof(result), 0);
48252+ cmd = kmalloc(1, GFP_KERNEL);
48253+ if (cmd == NULL)
48254+ return -ENOMEM;
48255+ result = kmalloc(sizeof(*result), GFP_KERNEL);
48256+ if (result == NULL) {
48257+ kfree(cmd);
48258+ return -ENOMEM;
48259+ }
48260+
48261+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48262+
48263+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (u8 *)result,
48264+ sizeof(*result), 0);
48265 if (ret < 0)
48266- return ret;
48267+ goto out;
48268
48269 *status = 0;
48270
48271- if (0xffff - le16_to_cpu(result.gain) > 30)
48272+ if (0xffff - le16_to_cpu(result->gain) > 30)
48273 *status |= FE_HAS_SIGNAL;
48274- if (result.lock_bits & (1 << 6))
48275+ if (result->lock_bits & (1 << 6))
48276 *status |= FE_HAS_LOCK;
48277- if (result.lock_bits & (1 << 5))
48278+ if (result->lock_bits & (1 << 5))
48279 *status |= FE_HAS_SYNC;
48280- if (result.lock_bits & (1 << 4))
48281+ if (result->lock_bits & (1 << 4))
48282 *status |= FE_HAS_CARRIER;
48283- if (result.lock_bits & (1 << 1))
48284+ if (result->lock_bits & (1 << 1))
48285 *status |= FE_HAS_VITERBI;
48286
48287 if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
48288 (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
48289 *status &= ~FE_HAS_LOCK;
48290
48291- return 0;
48292+out:
48293+ kfree(cmd);
48294+ kfree(result);
48295+ return ret;
48296 }
48297
48298 static int cinergyt2_fe_read_ber(struct dvb_frontend *fe, u32 *ber)
48299 {
48300 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48301- struct dvbt_get_status_msg status;
48302- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48303+ struct dvbt_get_status_msg *status;
48304+ char *cmd;
48305 int ret;
48306
48307- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
48308- sizeof(status), 0);
48309+ cmd = kmalloc(1, GFP_KERNEL);
48310+ if (cmd == NULL)
48311+ return -ENOMEM;
48312+ status = kmalloc(sizeof(*status), GFP_KERNEL);
48313+ if (status == NULL) {
48314+ kfree(cmd);
48315+ return -ENOMEM;
48316+ }
48317+
48318+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48319+
48320+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status,
48321+ sizeof(*status), 0);
48322 if (ret < 0)
48323- return ret;
48324+ goto out;
48325
48326- *ber = le32_to_cpu(status.viterbi_error_rate);
48327+ *ber = le32_to_cpu(status->viterbi_error_rate);
48328+out:
48329+ kfree(cmd);
48330+ kfree(status);
48331 return 0;
48332 }
48333
48334 static int cinergyt2_fe_read_unc_blocks(struct dvb_frontend *fe, u32 *unc)
48335 {
48336 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48337- struct dvbt_get_status_msg status;
48338- u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48339+ struct dvbt_get_status_msg *status;
48340+ u8 *cmd;
48341 int ret;
48342
48343- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&status,
48344- sizeof(status), 0);
48345+ cmd = kmalloc(1, GFP_KERNEL);
48346+ if (cmd == NULL)
48347+ return -ENOMEM;
48348+ status = kmalloc(sizeof(*status), GFP_KERNEL);
48349+ if (status == NULL) {
48350+ kfree(cmd);
48351+ return -ENOMEM;
48352+ }
48353+
48354+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48355+
48356+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (u8 *)status,
48357+ sizeof(*status), 0);
48358 if (ret < 0) {
48359 err("cinergyt2_fe_read_unc_blocks() Failed! (Error=%d)\n",
48360 ret);
48361- return ret;
48362+ goto out;
48363 }
48364- *unc = le32_to_cpu(status.uncorrected_block_count);
48365- return 0;
48366+ *unc = le32_to_cpu(status->uncorrected_block_count);
48367+
48368+out:
48369+ kfree(cmd);
48370+ kfree(status);
48371+ return ret;
48372 }
48373
48374 static int cinergyt2_fe_read_signal_strength(struct dvb_frontend *fe,
48375 u16 *strength)
48376 {
48377 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48378- struct dvbt_get_status_msg status;
48379- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48380+ struct dvbt_get_status_msg *status;
48381+ char *cmd;
48382 int ret;
48383
48384- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
48385- sizeof(status), 0);
48386+ cmd = kmalloc(1, GFP_KERNEL);
48387+ if (cmd == NULL)
48388+ return -ENOMEM;
48389+ status = kmalloc(sizeof(*status), GFP_KERNEL);
48390+ if (status == NULL) {
48391+ kfree(cmd);
48392+ return -ENOMEM;
48393+ }
48394+
48395+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48396+
48397+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status,
48398+ sizeof(*status), 0);
48399 if (ret < 0) {
48400 err("cinergyt2_fe_read_signal_strength() Failed!"
48401 " (Error=%d)\n", ret);
48402- return ret;
48403+ goto out;
48404 }
48405- *strength = (0xffff - le16_to_cpu(status.gain));
48406+ *strength = (0xffff - le16_to_cpu(status->gain));
48407+
48408+out:
48409+ kfree(cmd);
48410+ kfree(status);
48411 return 0;
48412 }
48413
48414 static int cinergyt2_fe_read_snr(struct dvb_frontend *fe, u16 *snr)
48415 {
48416 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48417- struct dvbt_get_status_msg status;
48418- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48419+ struct dvbt_get_status_msg *status;
48420+ char *cmd;
48421 int ret;
48422
48423- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
48424- sizeof(status), 0);
48425+ cmd = kmalloc(1, GFP_KERNEL);
48426+ if (cmd == NULL)
48427+ return -ENOMEM;
48428+ status = kmalloc(sizeof(*status), GFP_KERNEL);
48429+ if (status == NULL) {
48430+ kfree(cmd);
48431+ return -ENOMEM;
48432+ }
48433+
48434+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48435+
48436+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status,
48437+ sizeof(*status), 0);
48438 if (ret < 0) {
48439 err("cinergyt2_fe_read_snr() Failed! (Error=%d)\n", ret);
48440- return ret;
48441+ goto out;
48442 }
48443- *snr = (status.snr << 8) | status.snr;
48444- return 0;
48445+ *snr = (status->snr << 8) | status->snr;
48446+
48447+out:
48448+ kfree(cmd);
48449+ kfree(status);
48450+ return ret;
48451 }
48452
48453 static int cinergyt2_fe_init(struct dvb_frontend *fe)
48454@@ -266,35 +339,46 @@ static int cinergyt2_fe_set_frontend(struct dvb_frontend *fe)
48455 {
48456 struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
48457 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48458- struct dvbt_set_parameters_msg param;
48459- char result[2];
48460+ struct dvbt_set_parameters_msg *param;
48461+ char *result;
48462 int err;
48463
48464- param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
48465- param.tps = cpu_to_le16(compute_tps(fep));
48466- param.freq = cpu_to_le32(fep->frequency / 1000);
48467- param.flags = 0;
48468+ result = kmalloc(2, GFP_KERNEL);
48469+ if (result == NULL)
48470+ return -ENOMEM;
48471+ param = kmalloc(sizeof(*param), GFP_KERNEL);
48472+ if (param == NULL) {
48473+ kfree(result);
48474+ return -ENOMEM;
48475+ }
48476+
48477+ param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
48478+ param->tps = cpu_to_le16(compute_tps(fep));
48479+ param->freq = cpu_to_le32(fep->frequency / 1000);
48480+ param->flags = 0;
48481
48482 switch (fep->bandwidth_hz) {
48483 default:
48484 case 8000000:
48485- param.bandwidth = 8;
48486+ param->bandwidth = 8;
48487 break;
48488 case 7000000:
48489- param.bandwidth = 7;
48490+ param->bandwidth = 7;
48491 break;
48492 case 6000000:
48493- param.bandwidth = 6;
48494+ param->bandwidth = 6;
48495 break;
48496 }
48497
48498 err = dvb_usb_generic_rw(state->d,
48499- (char *)&param, sizeof(param),
48500- result, sizeof(result), 0);
48501+ (char *)param, sizeof(*param),
48502+ result, 2, 0);
48503 if (err < 0)
48504 err("cinergyt2_fe_set_frontend() Failed! err=%d\n", err);
48505
48506- return (err < 0) ? err : 0;
48507+ kfree(result);
48508+ kfree(param);
48509+ return err;
48510 }
48511
48512 static void cinergyt2_fe_release(struct dvb_frontend *fe)
48513diff --git a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
48514index 733a7ff..f8b52e3 100644
48515--- a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
48516+++ b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
48517@@ -35,42 +35,57 @@ static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 le
48518
48519 int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)
48520 {
48521- struct hexline hx;
48522- u8 reset;
48523+ struct hexline *hx;
48524+ u8 *reset;
48525 int ret,pos=0;
48526
48527+ reset = kmalloc(1, GFP_KERNEL);
48528+ if (reset == NULL)
48529+ return -ENOMEM;
48530+
48531+ hx = kmalloc(sizeof(struct hexline), GFP_KERNEL);
48532+ if (hx == NULL) {
48533+ kfree(reset);
48534+ return -ENOMEM;
48535+ }
48536+
48537 /* stop the CPU */
48538- reset = 1;
48539- if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1)
48540+ reset[0] = 1;
48541+ if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,reset,1)) != 1)
48542 err("could not stop the USB controller CPU.");
48543
48544- while ((ret = dvb_usb_get_hexline(fw,&hx,&pos)) > 0) {
48545- deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk);
48546- ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len);
48547+ while ((ret = dvb_usb_get_hexline(fw,hx,&pos)) > 0) {
48548+ deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx->addr,hx->len,hx->chk);
48549+ ret = usb_cypress_writemem(udev,hx->addr,hx->data,hx->len);
48550
48551- if (ret != hx.len) {
48552+ if (ret != hx->len) {
48553 err("error while transferring firmware "
48554 "(transferred size: %d, block size: %d)",
48555- ret,hx.len);
48556+ ret,hx->len);
48557 ret = -EINVAL;
48558 break;
48559 }
48560 }
48561 if (ret < 0) {
48562 err("firmware download failed at %d with %d",pos,ret);
48563+ kfree(reset);
48564+ kfree(hx);
48565 return ret;
48566 }
48567
48568 if (ret == 0) {
48569 /* restart the CPU */
48570- reset = 0;
48571- if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) {
48572+ reset[0] = 0;
48573+ if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,reset,1) != 1) {
48574 err("could not restart the USB controller CPU.");
48575 ret = -EINVAL;
48576 }
48577 } else
48578 ret = -EIO;
48579
48580+ kfree(reset);
48581+ kfree(hx);
48582+
48583 return ret;
48584 }
48585 EXPORT_SYMBOL(usb_cypress_load_firmware);
48586diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
48587index 03f334d..0986492 100644
48588--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
48589+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
48590@@ -87,8 +87,11 @@ struct technisat_usb2_state {
48591 static int technisat_usb2_i2c_access(struct usb_device *udev,
48592 u8 device_addr, u8 *tx, u8 txlen, u8 *rx, u8 rxlen)
48593 {
48594- u8 b[64];
48595- int ret, actual_length;
48596+ u8 *b = kmalloc(64, GFP_KERNEL);
48597+ int ret, actual_length, error = 0;
48598+
48599+ if (b == NULL)
48600+ return -ENOMEM;
48601
48602 deb_i2c("i2c-access: %02x, tx: ", device_addr);
48603 debug_dump(tx, txlen, deb_i2c);
48604@@ -121,7 +124,8 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
48605
48606 if (ret < 0) {
48607 err("i2c-error: out failed %02x = %d", device_addr, ret);
48608- return -ENODEV;
48609+ error = -ENODEV;
48610+ goto out;
48611 }
48612
48613 ret = usb_bulk_msg(udev,
48614@@ -129,7 +133,8 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
48615 b, 64, &actual_length, 1000);
48616 if (ret < 0) {
48617 err("i2c-error: in failed %02x = %d", device_addr, ret);
48618- return -ENODEV;
48619+ error = -ENODEV;
48620+ goto out;
48621 }
48622
48623 if (b[0] != I2C_STATUS_OK) {
48624@@ -137,8 +142,10 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
48625 /* handle tuner-i2c-nak */
48626 if (!(b[0] == I2C_STATUS_NAK &&
48627 device_addr == 0x60
48628- /* && device_is_technisat_usb2 */))
48629- return -ENODEV;
48630+ /* && device_is_technisat_usb2 */)) {
48631+ error = -ENODEV;
48632+ goto out;
48633+ }
48634 }
48635
48636 deb_i2c("status: %d, ", b[0]);
48637@@ -152,7 +159,9 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
48638
48639 deb_i2c("\n");
48640
48641- return 0;
48642+out:
48643+ kfree(b);
48644+ return error;
48645 }
48646
48647 static int technisat_usb2_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
48648@@ -224,14 +233,16 @@ static int technisat_usb2_set_led(struct dvb_usb_device *d, int red, enum techni
48649 {
48650 int ret;
48651
48652- u8 led[8] = {
48653- red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST,
48654- 0
48655- };
48656+ u8 *led = kzalloc(8, GFP_KERNEL);
48657+
48658+ if (led == NULL)
48659+ return -ENOMEM;
48660
48661 if (disable_led_control && state != TECH_LED_OFF)
48662 return 0;
48663
48664+ led[0] = red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST;
48665+
48666 switch (state) {
48667 case TECH_LED_ON:
48668 led[1] = 0x82;
48669@@ -263,16 +274,22 @@ static int technisat_usb2_set_led(struct dvb_usb_device *d, int red, enum techni
48670 red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST,
48671 USB_TYPE_VENDOR | USB_DIR_OUT,
48672 0, 0,
48673- led, sizeof(led), 500);
48674+ led, 8, 500);
48675
48676 mutex_unlock(&d->i2c_mutex);
48677+
48678+ kfree(led);
48679+
48680 return ret;
48681 }
48682
48683 static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 green)
48684 {
48685 int ret;
48686- u8 b = 0;
48687+ u8 *b = kzalloc(1, GFP_KERNEL);
48688+
48689+ if (b == NULL)
48690+ return -ENOMEM;
48691
48692 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
48693 return -EAGAIN;
48694@@ -281,10 +298,12 @@ static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 gre
48695 SET_LED_TIMER_DIVIDER_VENDOR_REQUEST,
48696 USB_TYPE_VENDOR | USB_DIR_OUT,
48697 (red << 8) | green, 0,
48698- &b, 1, 500);
48699+ b, 1, 500);
48700
48701 mutex_unlock(&d->i2c_mutex);
48702
48703+ kfree(b);
48704+
48705 return ret;
48706 }
48707
48708@@ -328,7 +347,7 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
48709 struct dvb_usb_device_description **desc, int *cold)
48710 {
48711 int ret;
48712- u8 version[3];
48713+ u8 *version = kmalloc(3, GFP_KERNEL);
48714
48715 /* first select the interface */
48716 if (usb_set_interface(udev, 0, 1) != 0)
48717@@ -338,11 +357,14 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
48718
48719 *cold = 0; /* by default do not download a firmware - just in case something is wrong */
48720
48721+ if (version == NULL)
48722+ return 0;
48723+
48724 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
48725 GET_VERSION_INFO_VENDOR_REQUEST,
48726 USB_TYPE_VENDOR | USB_DIR_IN,
48727 0, 0,
48728- version, sizeof(version), 500);
48729+ version, 3, 500);
48730
48731 if (ret < 0)
48732 *cold = 1;
48733@@ -351,6 +373,8 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
48734 *cold = 0;
48735 }
48736
48737+ kfree(version);
48738+
48739 return 0;
48740 }
48741
48742@@ -594,10 +618,15 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
48743
48744 static int technisat_usb2_get_ir(struct dvb_usb_device *d)
48745 {
48746- u8 buf[62], *b;
48747+ u8 *buf, *b;
48748 int ret;
48749 struct ir_raw_event ev;
48750
48751+ buf = kmalloc(62, GFP_KERNEL);
48752+
48753+ if (buf == NULL)
48754+ return -ENOMEM;
48755+
48756 buf[0] = GET_IR_DATA_VENDOR_REQUEST;
48757 buf[1] = 0x08;
48758 buf[2] = 0x8f;
48759@@ -620,16 +649,20 @@ static int technisat_usb2_get_ir(struct dvb_usb_device *d)
48760 GET_IR_DATA_VENDOR_REQUEST,
48761 USB_TYPE_VENDOR | USB_DIR_IN,
48762 0x8080, 0,
48763- buf, sizeof(buf), 500);
48764+ buf, 62, 500);
48765
48766 unlock:
48767 mutex_unlock(&d->i2c_mutex);
48768
48769- if (ret < 0)
48770+ if (ret < 0) {
48771+ kfree(buf);
48772 return ret;
48773+ }
48774
48775- if (ret == 1)
48776+ if (ret == 1) {
48777+ kfree(buf);
48778 return 0; /* no key pressed */
48779+ }
48780
48781 /* decoding */
48782 b = buf+1;
48783@@ -656,6 +689,8 @@ unlock:
48784
48785 ir_raw_event_handle(d->rc_dev);
48786
48787+ kfree(buf);
48788+
48789 return 1;
48790 }
48791
48792diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
48793index af63543..0436f20 100644
48794--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
48795+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
48796@@ -429,7 +429,7 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
48797 * by passing a very big num_planes value */
48798 uplane = compat_alloc_user_space(num_planes *
48799 sizeof(struct v4l2_plane));
48800- kp->m.planes = (__force struct v4l2_plane *)uplane;
48801+ kp->m.planes = (__force_kernel struct v4l2_plane *)uplane;
48802
48803 while (--num_planes >= 0) {
48804 ret = get_v4l2_plane32(uplane, uplane32, kp->memory);
48805@@ -500,7 +500,7 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
48806 if (num_planes == 0)
48807 return 0;
48808
48809- uplane = (__force struct v4l2_plane __user *)kp->m.planes;
48810+ uplane = (struct v4l2_plane __force_user *)kp->m.planes;
48811 if (get_user(p, &up->m.planes))
48812 return -EFAULT;
48813 uplane32 = compat_ptr(p);
48814@@ -564,7 +564,7 @@ static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_frame
48815 get_user(kp->flags, &up->flags) ||
48816 copy_from_user(&kp->fmt, &up->fmt, sizeof(up->fmt)))
48817 return -EFAULT;
48818- kp->base = (__force void *)compat_ptr(tmp);
48819+ kp->base = (__force_kernel void *)compat_ptr(tmp);
48820 return 0;
48821 }
48822
48823@@ -669,7 +669,7 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
48824 n * sizeof(struct v4l2_ext_control32)))
48825 return -EFAULT;
48826 kcontrols = compat_alloc_user_space(n * sizeof(struct v4l2_ext_control));
48827- kp->controls = (__force struct v4l2_ext_control *)kcontrols;
48828+ kp->controls = (__force_kernel struct v4l2_ext_control *)kcontrols;
48829 while (--n >= 0) {
48830 u32 id;
48831
48832@@ -696,7 +696,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
48833 {
48834 struct v4l2_ext_control32 __user *ucontrols;
48835 struct v4l2_ext_control __user *kcontrols =
48836- (__force struct v4l2_ext_control __user *)kp->controls;
48837+ (struct v4l2_ext_control __force_user *)kp->controls;
48838 int n = kp->count;
48839 compat_caddr_t p;
48840
48841@@ -780,7 +780,7 @@ static int get_v4l2_edid32(struct v4l2_edid *kp, struct v4l2_edid32 __user *up)
48842 get_user(tmp, &up->edid) ||
48843 copy_from_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
48844 return -EFAULT;
48845- kp->edid = (__force u8 *)compat_ptr(tmp);
48846+ kp->edid = (__force_kernel u8 *)compat_ptr(tmp);
48847 return 0;
48848 }
48849
48850diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
48851index 5b0a30b..1974b38 100644
48852--- a/drivers/media/v4l2-core/v4l2-device.c
48853+++ b/drivers/media/v4l2-core/v4l2-device.c
48854@@ -74,9 +74,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
48855 EXPORT_SYMBOL_GPL(v4l2_device_put);
48856
48857 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
48858- atomic_t *instance)
48859+ atomic_unchecked_t *instance)
48860 {
48861- int num = atomic_inc_return(instance) - 1;
48862+ int num = atomic_inc_return_unchecked(instance) - 1;
48863 int len = strlen(basename);
48864
48865 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
48866diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
48867index 85de455..4987854 100644
48868--- a/drivers/media/v4l2-core/v4l2-ioctl.c
48869+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
48870@@ -2341,7 +2341,8 @@ struct v4l2_ioctl_info {
48871 struct file *file, void *fh, void *p);
48872 } u;
48873 void (*debug)(const void *arg, bool write_only);
48874-};
48875+} __do_const;
48876+typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
48877
48878 /* This control needs a priority check */
48879 #define INFO_FL_PRIO (1 << 0)
48880@@ -2525,7 +2526,7 @@ static long __video_do_ioctl(struct file *file,
48881 struct video_device *vfd = video_devdata(file);
48882 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
48883 bool write_only = false;
48884- struct v4l2_ioctl_info default_info;
48885+ v4l2_ioctl_info_no_const default_info;
48886 const struct v4l2_ioctl_info *info;
48887 void *fh = file->private_data;
48888 struct v4l2_fh *vfh = NULL;
48889@@ -2616,7 +2617,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
48890 ret = -EINVAL;
48891 break;
48892 }
48893- *user_ptr = (void __user *)buf->m.planes;
48894+ *user_ptr = (void __force_user *)buf->m.planes;
48895 *kernel_ptr = (void **)&buf->m.planes;
48896 *array_size = sizeof(struct v4l2_plane) * buf->length;
48897 ret = 1;
48898@@ -2633,7 +2634,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
48899 ret = -EINVAL;
48900 break;
48901 }
48902- *user_ptr = (void __user *)edid->edid;
48903+ *user_ptr = (void __force_user *)edid->edid;
48904 *kernel_ptr = (void **)&edid->edid;
48905 *array_size = edid->blocks * 128;
48906 ret = 1;
48907@@ -2651,7 +2652,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
48908 ret = -EINVAL;
48909 break;
48910 }
48911- *user_ptr = (void __user *)ctrls->controls;
48912+ *user_ptr = (void __force_user *)ctrls->controls;
48913 *kernel_ptr = (void **)&ctrls->controls;
48914 *array_size = sizeof(struct v4l2_ext_control)
48915 * ctrls->count;
48916@@ -2752,7 +2753,7 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
48917 }
48918
48919 if (has_array_args) {
48920- *kernel_ptr = (void __force *)user_ptr;
48921+ *kernel_ptr = (void __force_kernel *)user_ptr;
48922 if (copy_to_user(user_ptr, mbuf, array_size))
48923 err = -EFAULT;
48924 goto out_array_args;
48925diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
48926index 9426276..9abd11e 100644
48927--- a/drivers/memory/omap-gpmc.c
48928+++ b/drivers/memory/omap-gpmc.c
48929@@ -232,7 +232,6 @@ struct omap3_gpmc_regs {
48930 };
48931
48932 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
48933-static struct irq_chip gpmc_irq_chip;
48934 static int gpmc_irq_start;
48935
48936 static struct resource gpmc_mem_root;
48937@@ -1146,6 +1145,17 @@ static void gpmc_irq_noop(struct irq_data *data) { }
48938
48939 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
48940
48941+static struct irq_chip gpmc_irq_chip = {
48942+ .name = "gpmc",
48943+ .irq_startup = gpmc_irq_noop_ret,
48944+ .irq_enable = gpmc_irq_enable,
48945+ .irq_disable = gpmc_irq_disable,
48946+ .irq_shutdown = gpmc_irq_noop,
48947+ .irq_ack = gpmc_irq_noop,
48948+ .irq_mask = gpmc_irq_noop,
48949+ .irq_unmask = gpmc_irq_noop,
48950+};
48951+
48952 static int gpmc_setup_irq(void)
48953 {
48954 int i;
48955@@ -1160,15 +1170,6 @@ static int gpmc_setup_irq(void)
48956 return gpmc_irq_start;
48957 }
48958
48959- gpmc_irq_chip.name = "gpmc";
48960- gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
48961- gpmc_irq_chip.irq_enable = gpmc_irq_enable;
48962- gpmc_irq_chip.irq_disable = gpmc_irq_disable;
48963- gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
48964- gpmc_irq_chip.irq_ack = gpmc_irq_noop;
48965- gpmc_irq_chip.irq_mask = gpmc_irq_noop;
48966- gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
48967-
48968 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
48969 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
48970
48971diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
48972index 5dcc031..e08ecd2 100644
48973--- a/drivers/message/fusion/mptbase.c
48974+++ b/drivers/message/fusion/mptbase.c
48975@@ -6722,8 +6722,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
48976 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
48977 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
48978
48979+#ifdef CONFIG_GRKERNSEC_HIDESYM
48980+ seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
48981+#else
48982 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
48983 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
48984+#endif
48985+
48986 /*
48987 * Rounding UP to nearest 4-kB boundary here...
48988 */
48989@@ -6736,7 +6741,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
48990 ioc->facts.GlobalCredits);
48991
48992 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
48993+#ifdef CONFIG_GRKERNSEC_HIDESYM
48994+ NULL, NULL);
48995+#else
48996 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
48997+#endif
48998 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
48999 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
49000 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
49001diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
49002index 005a88b..5a90fbb 100644
49003--- a/drivers/message/fusion/mptsas.c
49004+++ b/drivers/message/fusion/mptsas.c
49005@@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
49006 return 0;
49007 }
49008
49009+static inline void
49010+mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
49011+{
49012+ if (phy_info->port_details) {
49013+ phy_info->port_details->rphy = rphy;
49014+ dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
49015+ ioc->name, rphy));
49016+ }
49017+
49018+ if (rphy) {
49019+ dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
49020+ &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
49021+ dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
49022+ ioc->name, rphy, rphy->dev.release));
49023+ }
49024+}
49025+
49026 /* no mutex */
49027 static void
49028 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
49029@@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
49030 return NULL;
49031 }
49032
49033-static inline void
49034-mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
49035-{
49036- if (phy_info->port_details) {
49037- phy_info->port_details->rphy = rphy;
49038- dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
49039- ioc->name, rphy));
49040- }
49041-
49042- if (rphy) {
49043- dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
49044- &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
49045- dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
49046- ioc->name, rphy, rphy->dev.release));
49047- }
49048-}
49049-
49050 static inline struct sas_port *
49051 mptsas_get_port(struct mptsas_phyinfo *phy_info)
49052 {
49053diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
49054index 0236cd7..53b10d7 100644
49055--- a/drivers/mfd/ab8500-debugfs.c
49056+++ b/drivers/mfd/ab8500-debugfs.c
49057@@ -100,7 +100,7 @@ static int irq_last;
49058 static u32 *irq_count;
49059 static int num_irqs;
49060
49061-static struct device_attribute **dev_attr;
49062+static device_attribute_no_const **dev_attr;
49063 static char **event_name;
49064
49065 static u8 avg_sample = SAMPLE_16;
49066diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
49067index 8057849..0550fdf 100644
49068--- a/drivers/mfd/kempld-core.c
49069+++ b/drivers/mfd/kempld-core.c
49070@@ -499,7 +499,7 @@ static struct platform_driver kempld_driver = {
49071 .remove = kempld_remove,
49072 };
49073
49074-static struct dmi_system_id kempld_dmi_table[] __initdata = {
49075+static const struct dmi_system_id kempld_dmi_table[] __initconst = {
49076 {
49077 .ident = "BHL6",
49078 .matches = {
49079diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
49080index c880c89..45a7c68 100644
49081--- a/drivers/mfd/max8925-i2c.c
49082+++ b/drivers/mfd/max8925-i2c.c
49083@@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
49084 const struct i2c_device_id *id)
49085 {
49086 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
49087- static struct max8925_chip *chip;
49088+ struct max8925_chip *chip;
49089 struct device_node *node = client->dev.of_node;
49090
49091 if (node && !pdata) {
49092diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
49093index 7612d89..70549c2 100644
49094--- a/drivers/mfd/tps65910.c
49095+++ b/drivers/mfd/tps65910.c
49096@@ -230,7 +230,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
49097 struct tps65910_platform_data *pdata)
49098 {
49099 int ret = 0;
49100- static struct regmap_irq_chip *tps6591x_irqs_chip;
49101+ struct regmap_irq_chip *tps6591x_irqs_chip;
49102
49103 if (!irq) {
49104 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
49105diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
49106index a3fa7f4..eac02ef 100644
49107--- a/drivers/mfd/twl4030-irq.c
49108+++ b/drivers/mfd/twl4030-irq.c
49109@@ -34,6 +34,7 @@
49110 #include <linux/of.h>
49111 #include <linux/irqdomain.h>
49112 #include <linux/i2c/twl.h>
49113+#include <asm/pgtable.h>
49114
49115 #include "twl-core.h"
49116
49117@@ -729,10 +730,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
49118 * Install an irq handler for each of the SIH modules;
49119 * clone dummy irq_chip since PIH can't *do* anything
49120 */
49121- twl4030_irq_chip = dummy_irq_chip;
49122- twl4030_irq_chip.name = "twl4030";
49123+ pax_open_kernel();
49124+ memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
49125+ *(const char **)&twl4030_irq_chip.name = "twl4030";
49126
49127- twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
49128+ *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
49129+ pax_close_kernel();
49130
49131 for (i = irq_base; i < irq_end; i++) {
49132 irq_set_chip_and_handler(i, &twl4030_irq_chip,
49133diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
49134index 464419b..64bae8d 100644
49135--- a/drivers/misc/c2port/core.c
49136+++ b/drivers/misc/c2port/core.c
49137@@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
49138 goto error_idr_alloc;
49139 c2dev->id = ret;
49140
49141- bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
49142+ pax_open_kernel();
49143+ *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
49144+ pax_close_kernel();
49145
49146 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
49147 "c2port%d", c2dev->id);
49148diff --git a/drivers/misc/eeprom/sunxi_sid.c b/drivers/misc/eeprom/sunxi_sid.c
49149index 8385177..2f54635 100644
49150--- a/drivers/misc/eeprom/sunxi_sid.c
49151+++ b/drivers/misc/eeprom/sunxi_sid.c
49152@@ -126,7 +126,9 @@ static int sunxi_sid_probe(struct platform_device *pdev)
49153
49154 platform_set_drvdata(pdev, sid_data);
49155
49156- sid_bin_attr.size = sid_data->keysize;
49157+ pax_open_kernel();
49158+ *(size_t *)&sid_bin_attr.size = sid_data->keysize;
49159+ pax_close_kernel();
49160 if (device_create_bin_file(&pdev->dev, &sid_bin_attr))
49161 return -ENODEV;
49162
49163diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
49164index 9a60bd4..cee2069 100644
49165--- a/drivers/misc/kgdbts.c
49166+++ b/drivers/misc/kgdbts.c
49167@@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
49168 char before[BREAK_INSTR_SIZE];
49169 char after[BREAK_INSTR_SIZE];
49170
49171- probe_kernel_read(before, (char *)kgdbts_break_test,
49172+ probe_kernel_read(before, (void *)ktla_ktva((unsigned long)kgdbts_break_test),
49173 BREAK_INSTR_SIZE);
49174 init_simple_test();
49175 ts.tst = plant_and_detach_test;
49176@@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
49177 /* Activate test with initial breakpoint */
49178 if (!is_early)
49179 kgdb_breakpoint();
49180- probe_kernel_read(after, (char *)kgdbts_break_test,
49181+ probe_kernel_read(after, (void *)ktla_ktva((unsigned long)kgdbts_break_test),
49182 BREAK_INSTR_SIZE);
49183 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
49184 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
49185diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
49186index fb8705f..dc2f679 100644
49187--- a/drivers/misc/lis3lv02d/lis3lv02d.c
49188+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
49189@@ -497,7 +497,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
49190 * the lid is closed. This leads to interrupts as soon as a little move
49191 * is done.
49192 */
49193- atomic_inc(&lis3->count);
49194+ atomic_inc_unchecked(&lis3->count);
49195
49196 wake_up_interruptible(&lis3->misc_wait);
49197 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
49198@@ -583,7 +583,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
49199 if (lis3->pm_dev)
49200 pm_runtime_get_sync(lis3->pm_dev);
49201
49202- atomic_set(&lis3->count, 0);
49203+ atomic_set_unchecked(&lis3->count, 0);
49204 return 0;
49205 }
49206
49207@@ -615,7 +615,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
49208 add_wait_queue(&lis3->misc_wait, &wait);
49209 while (true) {
49210 set_current_state(TASK_INTERRUPTIBLE);
49211- data = atomic_xchg(&lis3->count, 0);
49212+ data = atomic_xchg_unchecked(&lis3->count, 0);
49213 if (data)
49214 break;
49215
49216@@ -656,7 +656,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
49217 struct lis3lv02d, miscdev);
49218
49219 poll_wait(file, &lis3->misc_wait, wait);
49220- if (atomic_read(&lis3->count))
49221+ if (atomic_read_unchecked(&lis3->count))
49222 return POLLIN | POLLRDNORM;
49223 return 0;
49224 }
49225diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
49226index c439c82..1f20f57 100644
49227--- a/drivers/misc/lis3lv02d/lis3lv02d.h
49228+++ b/drivers/misc/lis3lv02d/lis3lv02d.h
49229@@ -297,7 +297,7 @@ struct lis3lv02d {
49230 struct input_polled_dev *idev; /* input device */
49231 struct platform_device *pdev; /* platform device */
49232 struct regulator_bulk_data regulators[2];
49233- atomic_t count; /* interrupt count after last read */
49234+ atomic_unchecked_t count; /* interrupt count after last read */
49235 union axis_conversion ac; /* hw -> logical axis */
49236 int mapped_btns[3];
49237
49238diff --git a/drivers/misc/mic/scif/scif_rb.c b/drivers/misc/mic/scif/scif_rb.c
49239index 637cc46..4fb1267 100644
49240--- a/drivers/misc/mic/scif/scif_rb.c
49241+++ b/drivers/misc/mic/scif/scif_rb.c
49242@@ -138,7 +138,7 @@ void scif_rb_commit(struct scif_rb *rb)
49243 * the read barrier in scif_rb_count(..)
49244 */
49245 wmb();
49246- ACCESS_ONCE(*rb->write_ptr) = rb->current_write_offset;
49247+ ACCESS_ONCE_RW(*rb->write_ptr) = rb->current_write_offset;
49248 #ifdef CONFIG_INTEL_MIC_CARD
49249 /*
49250 * X100 Si bug: For the case where a Core is performing an EXT_WR
49251@@ -147,7 +147,7 @@ void scif_rb_commit(struct scif_rb *rb)
49252 * This way, if ordering is violated for the Interrupt Message, it will
49253 * fall just behind the first Posted associated with the first EXT_WR.
49254 */
49255- ACCESS_ONCE(*rb->write_ptr) = rb->current_write_offset;
49256+ ACCESS_ONCE_RW(*rb->write_ptr) = rb->current_write_offset;
49257 #endif
49258 }
49259
49260@@ -210,7 +210,7 @@ void scif_rb_update_read_ptr(struct scif_rb *rb)
49261 * scif_rb_space(..)
49262 */
49263 mb();
49264- ACCESS_ONCE(*rb->read_ptr) = new_offset;
49265+ ACCESS_ONCE_RW(*rb->read_ptr) = new_offset;
49266 #ifdef CONFIG_INTEL_MIC_CARD
49267 /*
49268 * X100 Si Bug: For the case where a Core is performing an EXT_WR
49269@@ -219,7 +219,7 @@ void scif_rb_update_read_ptr(struct scif_rb *rb)
49270 * This way, if ordering is violated for the Interrupt Message, it will
49271 * fall just behind the first Posted associated with the first EXT_WR.
49272 */
49273- ACCESS_ONCE(*rb->read_ptr) = new_offset;
49274+ ACCESS_ONCE_RW(*rb->read_ptr) = new_offset;
49275 #endif
49276 }
49277
49278diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
49279index 2f30bad..c4c13d0 100644
49280--- a/drivers/misc/sgi-gru/gruhandles.c
49281+++ b/drivers/misc/sgi-gru/gruhandles.c
49282@@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
49283 unsigned long nsec;
49284
49285 nsec = CLKS2NSEC(clks);
49286- atomic_long_inc(&mcs_op_statistics[op].count);
49287- atomic_long_add(nsec, &mcs_op_statistics[op].total);
49288+ atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
49289+ atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
49290 if (mcs_op_statistics[op].max < nsec)
49291 mcs_op_statistics[op].max = nsec;
49292 }
49293diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
49294index 4f76359..cdfcb2e 100644
49295--- a/drivers/misc/sgi-gru/gruprocfs.c
49296+++ b/drivers/misc/sgi-gru/gruprocfs.c
49297@@ -32,9 +32,9 @@
49298
49299 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
49300
49301-static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
49302+static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
49303 {
49304- unsigned long val = atomic_long_read(v);
49305+ unsigned long val = atomic_long_read_unchecked(v);
49306
49307 seq_printf(s, "%16lu %s\n", val, id);
49308 }
49309@@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
49310
49311 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
49312 for (op = 0; op < mcsop_last; op++) {
49313- count = atomic_long_read(&mcs_op_statistics[op].count);
49314- total = atomic_long_read(&mcs_op_statistics[op].total);
49315+ count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
49316+ total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
49317 max = mcs_op_statistics[op].max;
49318 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
49319 count ? total / count : 0, max);
49320diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
49321index 5c3ce24..4915ccb 100644
49322--- a/drivers/misc/sgi-gru/grutables.h
49323+++ b/drivers/misc/sgi-gru/grutables.h
49324@@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
49325 * GRU statistics.
49326 */
49327 struct gru_stats_s {
49328- atomic_long_t vdata_alloc;
49329- atomic_long_t vdata_free;
49330- atomic_long_t gts_alloc;
49331- atomic_long_t gts_free;
49332- atomic_long_t gms_alloc;
49333- atomic_long_t gms_free;
49334- atomic_long_t gts_double_allocate;
49335- atomic_long_t assign_context;
49336- atomic_long_t assign_context_failed;
49337- atomic_long_t free_context;
49338- atomic_long_t load_user_context;
49339- atomic_long_t load_kernel_context;
49340- atomic_long_t lock_kernel_context;
49341- atomic_long_t unlock_kernel_context;
49342- atomic_long_t steal_user_context;
49343- atomic_long_t steal_kernel_context;
49344- atomic_long_t steal_context_failed;
49345- atomic_long_t nopfn;
49346- atomic_long_t asid_new;
49347- atomic_long_t asid_next;
49348- atomic_long_t asid_wrap;
49349- atomic_long_t asid_reuse;
49350- atomic_long_t intr;
49351- atomic_long_t intr_cbr;
49352- atomic_long_t intr_tfh;
49353- atomic_long_t intr_spurious;
49354- atomic_long_t intr_mm_lock_failed;
49355- atomic_long_t call_os;
49356- atomic_long_t call_os_wait_queue;
49357- atomic_long_t user_flush_tlb;
49358- atomic_long_t user_unload_context;
49359- atomic_long_t user_exception;
49360- atomic_long_t set_context_option;
49361- atomic_long_t check_context_retarget_intr;
49362- atomic_long_t check_context_unload;
49363- atomic_long_t tlb_dropin;
49364- atomic_long_t tlb_preload_page;
49365- atomic_long_t tlb_dropin_fail_no_asid;
49366- atomic_long_t tlb_dropin_fail_upm;
49367- atomic_long_t tlb_dropin_fail_invalid;
49368- atomic_long_t tlb_dropin_fail_range_active;
49369- atomic_long_t tlb_dropin_fail_idle;
49370- atomic_long_t tlb_dropin_fail_fmm;
49371- atomic_long_t tlb_dropin_fail_no_exception;
49372- atomic_long_t tfh_stale_on_fault;
49373- atomic_long_t mmu_invalidate_range;
49374- atomic_long_t mmu_invalidate_page;
49375- atomic_long_t flush_tlb;
49376- atomic_long_t flush_tlb_gru;
49377- atomic_long_t flush_tlb_gru_tgh;
49378- atomic_long_t flush_tlb_gru_zero_asid;
49379+ atomic_long_unchecked_t vdata_alloc;
49380+ atomic_long_unchecked_t vdata_free;
49381+ atomic_long_unchecked_t gts_alloc;
49382+ atomic_long_unchecked_t gts_free;
49383+ atomic_long_unchecked_t gms_alloc;
49384+ atomic_long_unchecked_t gms_free;
49385+ atomic_long_unchecked_t gts_double_allocate;
49386+ atomic_long_unchecked_t assign_context;
49387+ atomic_long_unchecked_t assign_context_failed;
49388+ atomic_long_unchecked_t free_context;
49389+ atomic_long_unchecked_t load_user_context;
49390+ atomic_long_unchecked_t load_kernel_context;
49391+ atomic_long_unchecked_t lock_kernel_context;
49392+ atomic_long_unchecked_t unlock_kernel_context;
49393+ atomic_long_unchecked_t steal_user_context;
49394+ atomic_long_unchecked_t steal_kernel_context;
49395+ atomic_long_unchecked_t steal_context_failed;
49396+ atomic_long_unchecked_t nopfn;
49397+ atomic_long_unchecked_t asid_new;
49398+ atomic_long_unchecked_t asid_next;
49399+ atomic_long_unchecked_t asid_wrap;
49400+ atomic_long_unchecked_t asid_reuse;
49401+ atomic_long_unchecked_t intr;
49402+ atomic_long_unchecked_t intr_cbr;
49403+ atomic_long_unchecked_t intr_tfh;
49404+ atomic_long_unchecked_t intr_spurious;
49405+ atomic_long_unchecked_t intr_mm_lock_failed;
49406+ atomic_long_unchecked_t call_os;
49407+ atomic_long_unchecked_t call_os_wait_queue;
49408+ atomic_long_unchecked_t user_flush_tlb;
49409+ atomic_long_unchecked_t user_unload_context;
49410+ atomic_long_unchecked_t user_exception;
49411+ atomic_long_unchecked_t set_context_option;
49412+ atomic_long_unchecked_t check_context_retarget_intr;
49413+ atomic_long_unchecked_t check_context_unload;
49414+ atomic_long_unchecked_t tlb_dropin;
49415+ atomic_long_unchecked_t tlb_preload_page;
49416+ atomic_long_unchecked_t tlb_dropin_fail_no_asid;
49417+ atomic_long_unchecked_t tlb_dropin_fail_upm;
49418+ atomic_long_unchecked_t tlb_dropin_fail_invalid;
49419+ atomic_long_unchecked_t tlb_dropin_fail_range_active;
49420+ atomic_long_unchecked_t tlb_dropin_fail_idle;
49421+ atomic_long_unchecked_t tlb_dropin_fail_fmm;
49422+ atomic_long_unchecked_t tlb_dropin_fail_no_exception;
49423+ atomic_long_unchecked_t tfh_stale_on_fault;
49424+ atomic_long_unchecked_t mmu_invalidate_range;
49425+ atomic_long_unchecked_t mmu_invalidate_page;
49426+ atomic_long_unchecked_t flush_tlb;
49427+ atomic_long_unchecked_t flush_tlb_gru;
49428+ atomic_long_unchecked_t flush_tlb_gru_tgh;
49429+ atomic_long_unchecked_t flush_tlb_gru_zero_asid;
49430
49431- atomic_long_t copy_gpa;
49432- atomic_long_t read_gpa;
49433+ atomic_long_unchecked_t copy_gpa;
49434+ atomic_long_unchecked_t read_gpa;
49435
49436- atomic_long_t mesq_receive;
49437- atomic_long_t mesq_receive_none;
49438- atomic_long_t mesq_send;
49439- atomic_long_t mesq_send_failed;
49440- atomic_long_t mesq_noop;
49441- atomic_long_t mesq_send_unexpected_error;
49442- atomic_long_t mesq_send_lb_overflow;
49443- atomic_long_t mesq_send_qlimit_reached;
49444- atomic_long_t mesq_send_amo_nacked;
49445- atomic_long_t mesq_send_put_nacked;
49446- atomic_long_t mesq_page_overflow;
49447- atomic_long_t mesq_qf_locked;
49448- atomic_long_t mesq_qf_noop_not_full;
49449- atomic_long_t mesq_qf_switch_head_failed;
49450- atomic_long_t mesq_qf_unexpected_error;
49451- atomic_long_t mesq_noop_unexpected_error;
49452- atomic_long_t mesq_noop_lb_overflow;
49453- atomic_long_t mesq_noop_qlimit_reached;
49454- atomic_long_t mesq_noop_amo_nacked;
49455- atomic_long_t mesq_noop_put_nacked;
49456- atomic_long_t mesq_noop_page_overflow;
49457+ atomic_long_unchecked_t mesq_receive;
49458+ atomic_long_unchecked_t mesq_receive_none;
49459+ atomic_long_unchecked_t mesq_send;
49460+ atomic_long_unchecked_t mesq_send_failed;
49461+ atomic_long_unchecked_t mesq_noop;
49462+ atomic_long_unchecked_t mesq_send_unexpected_error;
49463+ atomic_long_unchecked_t mesq_send_lb_overflow;
49464+ atomic_long_unchecked_t mesq_send_qlimit_reached;
49465+ atomic_long_unchecked_t mesq_send_amo_nacked;
49466+ atomic_long_unchecked_t mesq_send_put_nacked;
49467+ atomic_long_unchecked_t mesq_page_overflow;
49468+ atomic_long_unchecked_t mesq_qf_locked;
49469+ atomic_long_unchecked_t mesq_qf_noop_not_full;
49470+ atomic_long_unchecked_t mesq_qf_switch_head_failed;
49471+ atomic_long_unchecked_t mesq_qf_unexpected_error;
49472+ atomic_long_unchecked_t mesq_noop_unexpected_error;
49473+ atomic_long_unchecked_t mesq_noop_lb_overflow;
49474+ atomic_long_unchecked_t mesq_noop_qlimit_reached;
49475+ atomic_long_unchecked_t mesq_noop_amo_nacked;
49476+ atomic_long_unchecked_t mesq_noop_put_nacked;
49477+ atomic_long_unchecked_t mesq_noop_page_overflow;
49478
49479 };
49480
49481@@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
49482 tghop_invalidate, mcsop_last};
49483
49484 struct mcs_op_statistic {
49485- atomic_long_t count;
49486- atomic_long_t total;
49487+ atomic_long_unchecked_t count;
49488+ atomic_long_unchecked_t total;
49489 unsigned long max;
49490 };
49491
49492@@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
49493
49494 #define STAT(id) do { \
49495 if (gru_options & OPT_STATS) \
49496- atomic_long_inc(&gru_stats.id); \
49497+ atomic_long_inc_unchecked(&gru_stats.id); \
49498 } while (0)
49499
49500 #ifdef CONFIG_SGI_GRU_DEBUG
49501diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
49502index c862cd4..0d176fe 100644
49503--- a/drivers/misc/sgi-xp/xp.h
49504+++ b/drivers/misc/sgi-xp/xp.h
49505@@ -288,7 +288,7 @@ struct xpc_interface {
49506 xpc_notify_func, void *);
49507 void (*received) (short, int, void *);
49508 enum xp_retval (*partid_to_nasids) (short, void *);
49509-};
49510+} __no_const;
49511
49512 extern struct xpc_interface xpc_interface;
49513
49514diff --git a/drivers/misc/sgi-xp/xp_main.c b/drivers/misc/sgi-xp/xp_main.c
49515index 01be66d..e3a0c7e 100644
49516--- a/drivers/misc/sgi-xp/xp_main.c
49517+++ b/drivers/misc/sgi-xp/xp_main.c
49518@@ -78,13 +78,13 @@ xpc_notloaded(void)
49519 }
49520
49521 struct xpc_interface xpc_interface = {
49522- (void (*)(int))xpc_notloaded,
49523- (void (*)(int))xpc_notloaded,
49524- (enum xp_retval(*)(short, int, u32, void *, u16))xpc_notloaded,
49525- (enum xp_retval(*)(short, int, u32, void *, u16, xpc_notify_func,
49526+ .connect = (void (*)(int))xpc_notloaded,
49527+ .disconnect = (void (*)(int))xpc_notloaded,
49528+ .send = (enum xp_retval(*)(short, int, u32, void *, u16))xpc_notloaded,
49529+ .send_notify = (enum xp_retval(*)(short, int, u32, void *, u16, xpc_notify_func,
49530 void *))xpc_notloaded,
49531- (void (*)(short, int, void *))xpc_notloaded,
49532- (enum xp_retval(*)(short, void *))xpc_notloaded
49533+ .received = (void (*)(short, int, void *))xpc_notloaded,
49534+ .partid_to_nasids = (enum xp_retval(*)(short, void *))xpc_notloaded
49535 };
49536 EXPORT_SYMBOL_GPL(xpc_interface);
49537
49538diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
49539index b94d5f7..7f494c5 100644
49540--- a/drivers/misc/sgi-xp/xpc.h
49541+++ b/drivers/misc/sgi-xp/xpc.h
49542@@ -835,6 +835,7 @@ struct xpc_arch_operations {
49543 void (*received_payload) (struct xpc_channel *, void *);
49544 void (*notify_senders_of_disconnect) (struct xpc_channel *);
49545 };
49546+typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
49547
49548 /* struct xpc_partition act_state values (for XPC HB) */
49549
49550@@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
49551 /* found in xpc_main.c */
49552 extern struct device *xpc_part;
49553 extern struct device *xpc_chan;
49554-extern struct xpc_arch_operations xpc_arch_ops;
49555+extern xpc_arch_operations_no_const xpc_arch_ops;
49556 extern int xpc_disengage_timelimit;
49557 extern int xpc_disengage_timedout;
49558 extern int xpc_activate_IRQ_rcvd;
49559diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
49560index 7f32712..8539ab2 100644
49561--- a/drivers/misc/sgi-xp/xpc_main.c
49562+++ b/drivers/misc/sgi-xp/xpc_main.c
49563@@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
49564 .notifier_call = xpc_system_die,
49565 };
49566
49567-struct xpc_arch_operations xpc_arch_ops;
49568+xpc_arch_operations_no_const xpc_arch_ops;
49569
49570 /*
49571 * Timer function to enforce the timelimit on the partition disengage.
49572diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
49573index a1b820f..e299c58 100644
49574--- a/drivers/mmc/card/block.c
49575+++ b/drivers/mmc/card/block.c
49576@@ -579,7 +579,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
49577 if (idata->ic.postsleep_min_us)
49578 usleep_range(idata->ic.postsleep_min_us, idata->ic.postsleep_max_us);
49579
49580- if (copy_to_user(&(ic_ptr->response), cmd.resp, sizeof(cmd.resp))) {
49581+ if (copy_to_user(ic_ptr->response, cmd.resp, sizeof(cmd.resp))) {
49582 err = -EFAULT;
49583 goto cmd_rel_host;
49584 }
49585diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
49586index 8ce4674..a23c858 100644
49587--- a/drivers/mmc/host/dw_mmc.h
49588+++ b/drivers/mmc/host/dw_mmc.h
49589@@ -286,5 +286,5 @@ struct dw_mci_drv_data {
49590 struct mmc_ios *ios);
49591 int (*switch_voltage)(struct mmc_host *mmc,
49592 struct mmc_ios *ios);
49593-};
49594+} __do_const;
49595 #endif /* _DW_MMC_H_ */
49596diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
49597index fb26674..3172c2b 100644
49598--- a/drivers/mmc/host/mmci.c
49599+++ b/drivers/mmc/host/mmci.c
49600@@ -1633,7 +1633,9 @@ static int mmci_probe(struct amba_device *dev,
49601 mmc->caps |= MMC_CAP_CMD23;
49602
49603 if (variant->busy_detect) {
49604- mmci_ops.card_busy = mmci_card_busy;
49605+ pax_open_kernel();
49606+ *(void **)&mmci_ops.card_busy = mmci_card_busy;
49607+ pax_close_kernel();
49608 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
49609 mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
49610 mmc->max_busy_timeout = 0;
49611diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
49612index 4d12032..2b0eb6d 100644
49613--- a/drivers/mmc/host/omap_hsmmc.c
49614+++ b/drivers/mmc/host/omap_hsmmc.c
49615@@ -1984,7 +1984,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
49616
49617 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) {
49618 dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n");
49619- omap_hsmmc_ops.multi_io_quirk = omap_hsmmc_multi_io_quirk;
49620+ pax_open_kernel();
49621+ *(void **)&omap_hsmmc_ops.multi_io_quirk = omap_hsmmc_multi_io_quirk;
49622+ pax_close_kernel();
49623 }
49624
49625 device_init_wakeup(&pdev->dev, true);
49626diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
49627index c6b9f64..00e656c 100644
49628--- a/drivers/mmc/host/sdhci-esdhc-imx.c
49629+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
49630@@ -1088,9 +1088,12 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
49631 host->ioaddr + 0x6c);
49632 }
49633
49634- if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING)
49635- sdhci_esdhc_ops.platform_execute_tuning =
49636+ if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
49637+ pax_open_kernel();
49638+ *(void **)&sdhci_esdhc_ops.platform_execute_tuning =
49639 esdhc_executing_tuning;
49640+ pax_close_kernel();
49641+ }
49642
49643 if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING)
49644 writel(readl(host->ioaddr + ESDHC_TUNING_CTRL) |
49645diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
49646index 70c724b..308aafc 100644
49647--- a/drivers/mmc/host/sdhci-s3c.c
49648+++ b/drivers/mmc/host/sdhci-s3c.c
49649@@ -598,9 +598,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
49650 * we can use overriding functions instead of default.
49651 */
49652 if (sc->no_divider) {
49653- sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
49654- sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
49655- sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
49656+ pax_open_kernel();
49657+ *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
49658+ *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
49659+ *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
49660+ pax_close_kernel();
49661 }
49662
49663 /* It supports additional host capabilities if needed */
49664diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
49665index 9a1a6ff..b8f1a57 100644
49666--- a/drivers/mtd/chips/cfi_cmdset_0020.c
49667+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
49668@@ -666,7 +666,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
49669 size_t totlen = 0, thislen;
49670 int ret = 0;
49671 size_t buflen = 0;
49672- static char *buffer;
49673+ char *buffer;
49674
49675 if (!ECCBUF_SIZE) {
49676 /* We should fall back to a general writev implementation.
49677diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
49678index 870c7fc..c7d6440 100644
49679--- a/drivers/mtd/nand/denali.c
49680+++ b/drivers/mtd/nand/denali.c
49681@@ -24,6 +24,7 @@
49682 #include <linux/slab.h>
49683 #include <linux/mtd/mtd.h>
49684 #include <linux/module.h>
49685+#include <linux/slab.h>
49686
49687 #include "denali.h"
49688
49689diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
49690index 1b8f350..990f2e9 100644
49691--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
49692+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
49693@@ -386,7 +386,7 @@ void prepare_data_dma(struct gpmi_nand_data *this, enum dma_data_direction dr)
49694
49695 /* first try to map the upper buffer directly */
49696 if (virt_addr_valid(this->upper_buf) &&
49697- !object_is_on_stack(this->upper_buf)) {
49698+ !object_starts_on_stack(this->upper_buf)) {
49699 sg_init_one(sgl, this->upper_buf, this->upper_len);
49700 ret = dma_map_sg(this->dev, sgl, 1, dr);
49701 if (ret == 0)
49702diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
49703index a5dfbfb..8042ab4 100644
49704--- a/drivers/mtd/nftlmount.c
49705+++ b/drivers/mtd/nftlmount.c
49706@@ -24,6 +24,7 @@
49707 #include <asm/errno.h>
49708 #include <linux/delay.h>
49709 #include <linux/slab.h>
49710+#include <linux/sched.h>
49711 #include <linux/mtd/mtd.h>
49712 #include <linux/mtd/nand.h>
49713 #include <linux/mtd/nftl.h>
49714diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
49715index c23184a..4115c41 100644
49716--- a/drivers/mtd/sm_ftl.c
49717+++ b/drivers/mtd/sm_ftl.c
49718@@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
49719 #define SM_CIS_VENDOR_OFFSET 0x59
49720 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
49721 {
49722- struct attribute_group *attr_group;
49723+ attribute_group_no_const *attr_group;
49724 struct attribute **attributes;
49725 struct sm_sysfs_attribute *vendor_attribute;
49726 char *vendor;
49727diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
49728index 1bda292..3f4af40 100644
49729--- a/drivers/net/bonding/bond_netlink.c
49730+++ b/drivers/net/bonding/bond_netlink.c
49731@@ -649,7 +649,7 @@ nla_put_failure:
49732 return -EMSGSIZE;
49733 }
49734
49735-struct rtnl_link_ops bond_link_ops __read_mostly = {
49736+struct rtnl_link_ops bond_link_ops = {
49737 .kind = "bond",
49738 .priv_size = sizeof(struct bonding),
49739 .setup = bond_setup,
49740diff --git a/drivers/net/caif/caif_hsi.c b/drivers/net/caif/caif_hsi.c
49741index b3b922a..80bba38 100644
49742--- a/drivers/net/caif/caif_hsi.c
49743+++ b/drivers/net/caif/caif_hsi.c
49744@@ -1444,7 +1444,7 @@ err:
49745 return -ENODEV;
49746 }
49747
49748-static struct rtnl_link_ops caif_hsi_link_ops __read_mostly = {
49749+static struct rtnl_link_ops caif_hsi_link_ops = {
49750 .kind = "cfhsi",
49751 .priv_size = sizeof(struct cfhsi),
49752 .setup = cfhsi_setup,
49753diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
49754index e8c96b8..516a96c 100644
49755--- a/drivers/net/can/Kconfig
49756+++ b/drivers/net/can/Kconfig
49757@@ -98,7 +98,7 @@ config CAN_JANZ_ICAN3
49758
49759 config CAN_FLEXCAN
49760 tristate "Support for Freescale FLEXCAN based chips"
49761- depends on ARM || PPC
49762+ depends on (ARM && CPU_LITTLE_ENDIAN) || PPC
49763 ---help---
49764 Say Y here if you want to support for Freescale FlexCAN.
49765
49766diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
49767index aede704..b516b4d 100644
49768--- a/drivers/net/can/dev.c
49769+++ b/drivers/net/can/dev.c
49770@@ -961,7 +961,7 @@ static int can_newlink(struct net *src_net, struct net_device *dev,
49771 return -EOPNOTSUPP;
49772 }
49773
49774-static struct rtnl_link_ops can_link_ops __read_mostly = {
49775+static struct rtnl_link_ops can_link_ops = {
49776 .kind = "can",
49777 .maxtype = IFLA_CAN_MAX,
49778 .policy = can_policy,
49779diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
49780index 674f367..ec3a31f 100644
49781--- a/drivers/net/can/vcan.c
49782+++ b/drivers/net/can/vcan.c
49783@@ -163,7 +163,7 @@ static void vcan_setup(struct net_device *dev)
49784 dev->destructor = free_netdev;
49785 }
49786
49787-static struct rtnl_link_ops vcan_link_ops __read_mostly = {
49788+static struct rtnl_link_ops vcan_link_ops = {
49789 .kind = "vcan",
49790 .setup = vcan_setup,
49791 };
49792diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
49793index 49adbf1..fff7ff8 100644
49794--- a/drivers/net/dummy.c
49795+++ b/drivers/net/dummy.c
49796@@ -164,7 +164,7 @@ static int dummy_validate(struct nlattr *tb[], struct nlattr *data[])
49797 return 0;
49798 }
49799
49800-static struct rtnl_link_ops dummy_link_ops __read_mostly = {
49801+static struct rtnl_link_ops dummy_link_ops = {
49802 .kind = DRV_NAME,
49803 .setup = dummy_setup,
49804 .validate = dummy_validate,
49805diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
49806index 0443654..4f0aa18 100644
49807--- a/drivers/net/ethernet/8390/ax88796.c
49808+++ b/drivers/net/ethernet/8390/ax88796.c
49809@@ -889,9 +889,11 @@ static int ax_probe(struct platform_device *pdev)
49810 if (ax->plat->reg_offsets)
49811 ei_local->reg_offset = ax->plat->reg_offsets;
49812 else {
49813+ resource_size_t _mem_size = mem_size;
49814+ do_div(_mem_size, 0x18);
49815 ei_local->reg_offset = ax->reg_offsets;
49816 for (ret = 0; ret < 0x18; ret++)
49817- ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
49818+ ax->reg_offsets[ret] = _mem_size * ret;
49819 }
49820
49821 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
49822diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
49823index 8207877..ce13e99 100644
49824--- a/drivers/net/ethernet/altera/altera_tse_main.c
49825+++ b/drivers/net/ethernet/altera/altera_tse_main.c
49826@@ -1255,7 +1255,7 @@ static int tse_shutdown(struct net_device *dev)
49827 return 0;
49828 }
49829
49830-static struct net_device_ops altera_tse_netdev_ops = {
49831+static net_device_ops_no_const altera_tse_netdev_ops __read_only = {
49832 .ndo_open = tse_open,
49833 .ndo_stop = tse_shutdown,
49834 .ndo_start_xmit = tse_start_xmit,
49835@@ -1492,11 +1492,13 @@ static int altera_tse_probe(struct platform_device *pdev)
49836 ndev->netdev_ops = &altera_tse_netdev_ops;
49837 altera_tse_set_ethtool_ops(ndev);
49838
49839+ pax_open_kernel();
49840 altera_tse_netdev_ops.ndo_set_rx_mode = tse_set_rx_mode;
49841
49842 if (priv->hash_filter)
49843 altera_tse_netdev_ops.ndo_set_rx_mode =
49844 tse_set_rx_mode_hashfilter;
49845+ pax_close_kernel();
49846
49847 /* Scatter/gather IO is not supported,
49848 * so it is turned off
49849diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-common.h b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
49850index b6fa891..31ef157 100644
49851--- a/drivers/net/ethernet/amd/xgbe/xgbe-common.h
49852+++ b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
49853@@ -1279,14 +1279,14 @@ do { \
49854 * operations, everything works on mask values.
49855 */
49856 #define XMDIO_READ(_pdata, _mmd, _reg) \
49857- ((_pdata)->hw_if.read_mmd_regs((_pdata), 0, \
49858+ ((_pdata)->hw_if->read_mmd_regs((_pdata), 0, \
49859 MII_ADDR_C45 | (_mmd << 16) | ((_reg) & 0xffff)))
49860
49861 #define XMDIO_READ_BITS(_pdata, _mmd, _reg, _mask) \
49862 (XMDIO_READ((_pdata), _mmd, _reg) & _mask)
49863
49864 #define XMDIO_WRITE(_pdata, _mmd, _reg, _val) \
49865- ((_pdata)->hw_if.write_mmd_regs((_pdata), 0, \
49866+ ((_pdata)->hw_if->write_mmd_regs((_pdata), 0, \
49867 MII_ADDR_C45 | (_mmd << 16) | ((_reg) & 0xffff), (_val)))
49868
49869 #define XMDIO_WRITE_BITS(_pdata, _mmd, _reg, _mask, _val) \
49870diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
49871index a6b9899..2e5e972 100644
49872--- a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
49873+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
49874@@ -190,7 +190,7 @@ static int xgbe_dcb_ieee_setets(struct net_device *netdev,
49875
49876 memcpy(pdata->ets, ets, sizeof(*pdata->ets));
49877
49878- pdata->hw_if.config_dcb_tc(pdata);
49879+ pdata->hw_if->config_dcb_tc(pdata);
49880
49881 return 0;
49882 }
49883@@ -230,7 +230,7 @@ static int xgbe_dcb_ieee_setpfc(struct net_device *netdev,
49884
49885 memcpy(pdata->pfc, pfc, sizeof(*pdata->pfc));
49886
49887- pdata->hw_if.config_dcb_pfc(pdata);
49888+ pdata->hw_if->config_dcb_pfc(pdata);
49889
49890 return 0;
49891 }
49892diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
49893index b3bc87f..5bdfdd3 100644
49894--- a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
49895+++ b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
49896@@ -353,7 +353,7 @@ static int xgbe_map_rx_buffer(struct xgbe_prv_data *pdata,
49897
49898 static void xgbe_wrapper_tx_descriptor_init(struct xgbe_prv_data *pdata)
49899 {
49900- struct xgbe_hw_if *hw_if = &pdata->hw_if;
49901+ struct xgbe_hw_if *hw_if = pdata->hw_if;
49902 struct xgbe_channel *channel;
49903 struct xgbe_ring *ring;
49904 struct xgbe_ring_data *rdata;
49905@@ -394,7 +394,7 @@ static void xgbe_wrapper_tx_descriptor_init(struct xgbe_prv_data *pdata)
49906
49907 static void xgbe_wrapper_rx_descriptor_init(struct xgbe_prv_data *pdata)
49908 {
49909- struct xgbe_hw_if *hw_if = &pdata->hw_if;
49910+ struct xgbe_hw_if *hw_if = pdata->hw_if;
49911 struct xgbe_channel *channel;
49912 struct xgbe_ring *ring;
49913 struct xgbe_ring_desc *rdesc;
49914@@ -628,17 +628,12 @@ err_out:
49915 return 0;
49916 }
49917
49918-void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *desc_if)
49919-{
49920- DBGPR("-->xgbe_init_function_ptrs_desc\n");
49921-
49922- desc_if->alloc_ring_resources = xgbe_alloc_ring_resources;
49923- desc_if->free_ring_resources = xgbe_free_ring_resources;
49924- desc_if->map_tx_skb = xgbe_map_tx_skb;
49925- desc_if->map_rx_buffer = xgbe_map_rx_buffer;
49926- desc_if->unmap_rdata = xgbe_unmap_rdata;
49927- desc_if->wrapper_tx_desc_init = xgbe_wrapper_tx_descriptor_init;
49928- desc_if->wrapper_rx_desc_init = xgbe_wrapper_rx_descriptor_init;
49929-
49930- DBGPR("<--xgbe_init_function_ptrs_desc\n");
49931-}
49932+const struct xgbe_desc_if default_xgbe_desc_if = {
49933+ .alloc_ring_resources = xgbe_alloc_ring_resources,
49934+ .free_ring_resources = xgbe_free_ring_resources,
49935+ .map_tx_skb = xgbe_map_tx_skb,
49936+ .map_rx_buffer = xgbe_map_rx_buffer,
49937+ .unmap_rdata = xgbe_unmap_rdata,
49938+ .wrapper_tx_desc_init = xgbe_wrapper_tx_descriptor_init,
49939+ .wrapper_rx_desc_init = xgbe_wrapper_rx_descriptor_init,
49940+};
49941diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
49942index a4473d8..039a2ab 100644
49943--- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
49944+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
49945@@ -2776,7 +2776,7 @@ static void xgbe_powerdown_rx(struct xgbe_prv_data *pdata)
49946
49947 static int xgbe_init(struct xgbe_prv_data *pdata)
49948 {
49949- struct xgbe_desc_if *desc_if = &pdata->desc_if;
49950+ struct xgbe_desc_if *desc_if = pdata->desc_if;
49951 int ret;
49952
49953 DBGPR("-->xgbe_init\n");
49954@@ -2842,106 +2842,101 @@ static int xgbe_init(struct xgbe_prv_data *pdata)
49955 return 0;
49956 }
49957
49958-void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *hw_if)
49959-{
49960- DBGPR("-->xgbe_init_function_ptrs\n");
49961-
49962- hw_if->tx_complete = xgbe_tx_complete;
49963-
49964- hw_if->set_mac_address = xgbe_set_mac_address;
49965- hw_if->config_rx_mode = xgbe_config_rx_mode;
49966-
49967- hw_if->enable_rx_csum = xgbe_enable_rx_csum;
49968- hw_if->disable_rx_csum = xgbe_disable_rx_csum;
49969-
49970- hw_if->enable_rx_vlan_stripping = xgbe_enable_rx_vlan_stripping;
49971- hw_if->disable_rx_vlan_stripping = xgbe_disable_rx_vlan_stripping;
49972- hw_if->enable_rx_vlan_filtering = xgbe_enable_rx_vlan_filtering;
49973- hw_if->disable_rx_vlan_filtering = xgbe_disable_rx_vlan_filtering;
49974- hw_if->update_vlan_hash_table = xgbe_update_vlan_hash_table;
49975-
49976- hw_if->read_mmd_regs = xgbe_read_mmd_regs;
49977- hw_if->write_mmd_regs = xgbe_write_mmd_regs;
49978-
49979- hw_if->set_gmii_speed = xgbe_set_gmii_speed;
49980- hw_if->set_gmii_2500_speed = xgbe_set_gmii_2500_speed;
49981- hw_if->set_xgmii_speed = xgbe_set_xgmii_speed;
49982-
49983- hw_if->enable_tx = xgbe_enable_tx;
49984- hw_if->disable_tx = xgbe_disable_tx;
49985- hw_if->enable_rx = xgbe_enable_rx;
49986- hw_if->disable_rx = xgbe_disable_rx;
49987-
49988- hw_if->powerup_tx = xgbe_powerup_tx;
49989- hw_if->powerdown_tx = xgbe_powerdown_tx;
49990- hw_if->powerup_rx = xgbe_powerup_rx;
49991- hw_if->powerdown_rx = xgbe_powerdown_rx;
49992-
49993- hw_if->dev_xmit = xgbe_dev_xmit;
49994- hw_if->dev_read = xgbe_dev_read;
49995- hw_if->enable_int = xgbe_enable_int;
49996- hw_if->disable_int = xgbe_disable_int;
49997- hw_if->init = xgbe_init;
49998- hw_if->exit = xgbe_exit;
49999+const struct xgbe_hw_if default_xgbe_hw_if = {
50000+ .tx_complete = xgbe_tx_complete,
50001+
50002+ .set_mac_address = xgbe_set_mac_address,
50003+ .config_rx_mode = xgbe_config_rx_mode,
50004+
50005+ .enable_rx_csum = xgbe_enable_rx_csum,
50006+ .disable_rx_csum = xgbe_disable_rx_csum,
50007+
50008+ .enable_rx_vlan_stripping = xgbe_enable_rx_vlan_stripping,
50009+ .disable_rx_vlan_stripping = xgbe_disable_rx_vlan_stripping,
50010+ .enable_rx_vlan_filtering = xgbe_enable_rx_vlan_filtering,
50011+ .disable_rx_vlan_filtering = xgbe_disable_rx_vlan_filtering,
50012+ .update_vlan_hash_table = xgbe_update_vlan_hash_table,
50013+
50014+ .read_mmd_regs = xgbe_read_mmd_regs,
50015+ .write_mmd_regs = xgbe_write_mmd_regs,
50016+
50017+ .set_gmii_speed = xgbe_set_gmii_speed,
50018+ .set_gmii_2500_speed = xgbe_set_gmii_2500_speed,
50019+ .set_xgmii_speed = xgbe_set_xgmii_speed,
50020+
50021+ .enable_tx = xgbe_enable_tx,
50022+ .disable_tx = xgbe_disable_tx,
50023+ .enable_rx = xgbe_enable_rx,
50024+ .disable_rx = xgbe_disable_rx,
50025+
50026+ .powerup_tx = xgbe_powerup_tx,
50027+ .powerdown_tx = xgbe_powerdown_tx,
50028+ .powerup_rx = xgbe_powerup_rx,
50029+ .powerdown_rx = xgbe_powerdown_rx,
50030+
50031+ .dev_xmit = xgbe_dev_xmit,
50032+ .dev_read = xgbe_dev_read,
50033+ .enable_int = xgbe_enable_int,
50034+ .disable_int = xgbe_disable_int,
50035+ .init = xgbe_init,
50036+ .exit = xgbe_exit,
50037
50038 /* Descriptor related Sequences have to be initialized here */
50039- hw_if->tx_desc_init = xgbe_tx_desc_init;
50040- hw_if->rx_desc_init = xgbe_rx_desc_init;
50041- hw_if->tx_desc_reset = xgbe_tx_desc_reset;
50042- hw_if->rx_desc_reset = xgbe_rx_desc_reset;
50043- hw_if->is_last_desc = xgbe_is_last_desc;
50044- hw_if->is_context_desc = xgbe_is_context_desc;
50045- hw_if->tx_start_xmit = xgbe_tx_start_xmit;
50046+ .tx_desc_init = xgbe_tx_desc_init,
50047+ .rx_desc_init = xgbe_rx_desc_init,
50048+ .tx_desc_reset = xgbe_tx_desc_reset,
50049+ .rx_desc_reset = xgbe_rx_desc_reset,
50050+ .is_last_desc = xgbe_is_last_desc,
50051+ .is_context_desc = xgbe_is_context_desc,
50052+ .tx_start_xmit = xgbe_tx_start_xmit,
50053
50054 /* For FLOW ctrl */
50055- hw_if->config_tx_flow_control = xgbe_config_tx_flow_control;
50056- hw_if->config_rx_flow_control = xgbe_config_rx_flow_control;
50057+ .config_tx_flow_control = xgbe_config_tx_flow_control,
50058+ .config_rx_flow_control = xgbe_config_rx_flow_control,
50059
50060 /* For RX coalescing */
50061- hw_if->config_rx_coalesce = xgbe_config_rx_coalesce;
50062- hw_if->config_tx_coalesce = xgbe_config_tx_coalesce;
50063- hw_if->usec_to_riwt = xgbe_usec_to_riwt;
50064- hw_if->riwt_to_usec = xgbe_riwt_to_usec;
50065+ .config_rx_coalesce = xgbe_config_rx_coalesce,
50066+ .config_tx_coalesce = xgbe_config_tx_coalesce,
50067+ .usec_to_riwt = xgbe_usec_to_riwt,
50068+ .riwt_to_usec = xgbe_riwt_to_usec,
50069
50070 /* For RX and TX threshold config */
50071- hw_if->config_rx_threshold = xgbe_config_rx_threshold;
50072- hw_if->config_tx_threshold = xgbe_config_tx_threshold;
50073+ .config_rx_threshold = xgbe_config_rx_threshold,
50074+ .config_tx_threshold = xgbe_config_tx_threshold,
50075
50076 /* For RX and TX Store and Forward Mode config */
50077- hw_if->config_rsf_mode = xgbe_config_rsf_mode;
50078- hw_if->config_tsf_mode = xgbe_config_tsf_mode;
50079+ .config_rsf_mode = xgbe_config_rsf_mode,
50080+ .config_tsf_mode = xgbe_config_tsf_mode,
50081
50082 /* For TX DMA Operating on Second Frame config */
50083- hw_if->config_osp_mode = xgbe_config_osp_mode;
50084+ .config_osp_mode = xgbe_config_osp_mode,
50085
50086 /* For RX and TX PBL config */
50087- hw_if->config_rx_pbl_val = xgbe_config_rx_pbl_val;
50088- hw_if->get_rx_pbl_val = xgbe_get_rx_pbl_val;
50089- hw_if->config_tx_pbl_val = xgbe_config_tx_pbl_val;
50090- hw_if->get_tx_pbl_val = xgbe_get_tx_pbl_val;
50091- hw_if->config_pblx8 = xgbe_config_pblx8;
50092+ .config_rx_pbl_val = xgbe_config_rx_pbl_val,
50093+ .get_rx_pbl_val = xgbe_get_rx_pbl_val,
50094+ .config_tx_pbl_val = xgbe_config_tx_pbl_val,
50095+ .get_tx_pbl_val = xgbe_get_tx_pbl_val,
50096+ .config_pblx8 = xgbe_config_pblx8,
50097
50098 /* For MMC statistics support */
50099- hw_if->tx_mmc_int = xgbe_tx_mmc_int;
50100- hw_if->rx_mmc_int = xgbe_rx_mmc_int;
50101- hw_if->read_mmc_stats = xgbe_read_mmc_stats;
50102+ .tx_mmc_int = xgbe_tx_mmc_int,
50103+ .rx_mmc_int = xgbe_rx_mmc_int,
50104+ .read_mmc_stats = xgbe_read_mmc_stats,
50105
50106 /* For PTP config */
50107- hw_if->config_tstamp = xgbe_config_tstamp;
50108- hw_if->update_tstamp_addend = xgbe_update_tstamp_addend;
50109- hw_if->set_tstamp_time = xgbe_set_tstamp_time;
50110- hw_if->get_tstamp_time = xgbe_get_tstamp_time;
50111- hw_if->get_tx_tstamp = xgbe_get_tx_tstamp;
50112+ .config_tstamp = xgbe_config_tstamp,
50113+ .update_tstamp_addend = xgbe_update_tstamp_addend,
50114+ .set_tstamp_time = xgbe_set_tstamp_time,
50115+ .get_tstamp_time = xgbe_get_tstamp_time,
50116+ .get_tx_tstamp = xgbe_get_tx_tstamp,
50117
50118 /* For Data Center Bridging config */
50119- hw_if->config_dcb_tc = xgbe_config_dcb_tc;
50120- hw_if->config_dcb_pfc = xgbe_config_dcb_pfc;
50121+ .config_dcb_tc = xgbe_config_dcb_tc,
50122+ .config_dcb_pfc = xgbe_config_dcb_pfc,
50123
50124 /* For Receive Side Scaling */
50125- hw_if->enable_rss = xgbe_enable_rss;
50126- hw_if->disable_rss = xgbe_disable_rss;
50127- hw_if->set_rss_hash_key = xgbe_set_rss_hash_key;
50128- hw_if->set_rss_lookup_table = xgbe_set_rss_lookup_table;
50129-
50130- DBGPR("<--xgbe_init_function_ptrs\n");
50131-}
50132+ .enable_rss = xgbe_enable_rss,
50133+ .disable_rss = xgbe_disable_rss,
50134+ .set_rss_hash_key = xgbe_set_rss_hash_key,
50135+ .set_rss_lookup_table = xgbe_set_rss_lookup_table,
50136+};
50137diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
50138index aae9d5e..29ce58d 100644
50139--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
50140+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
50141@@ -245,7 +245,7 @@ static int xgbe_maybe_stop_tx_queue(struct xgbe_channel *channel,
50142 * support, tell it now
50143 */
50144 if (ring->tx.xmit_more)
50145- pdata->hw_if.tx_start_xmit(channel, ring);
50146+ pdata->hw_if->tx_start_xmit(channel, ring);
50147
50148 return NETDEV_TX_BUSY;
50149 }
50150@@ -273,7 +273,7 @@ static int xgbe_calc_rx_buf_size(struct net_device *netdev, unsigned int mtu)
50151
50152 static void xgbe_enable_rx_tx_ints(struct xgbe_prv_data *pdata)
50153 {
50154- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50155+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50156 struct xgbe_channel *channel;
50157 enum xgbe_int int_id;
50158 unsigned int i;
50159@@ -295,7 +295,7 @@ static void xgbe_enable_rx_tx_ints(struct xgbe_prv_data *pdata)
50160
50161 static void xgbe_disable_rx_tx_ints(struct xgbe_prv_data *pdata)
50162 {
50163- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50164+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50165 struct xgbe_channel *channel;
50166 enum xgbe_int int_id;
50167 unsigned int i;
50168@@ -318,7 +318,7 @@ static void xgbe_disable_rx_tx_ints(struct xgbe_prv_data *pdata)
50169 static irqreturn_t xgbe_isr(int irq, void *data)
50170 {
50171 struct xgbe_prv_data *pdata = data;
50172- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50173+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50174 struct xgbe_channel *channel;
50175 unsigned int dma_isr, dma_ch_isr;
50176 unsigned int mac_isr, mac_tssr;
50177@@ -443,7 +443,7 @@ static void xgbe_service(struct work_struct *work)
50178 struct xgbe_prv_data,
50179 service_work);
50180
50181- pdata->phy_if.phy_status(pdata);
50182+ pdata->phy_if->phy_status(pdata);
50183 }
50184
50185 static void xgbe_service_timer(unsigned long data)
50186@@ -702,7 +702,7 @@ static void xgbe_free_irqs(struct xgbe_prv_data *pdata)
50187
50188 void xgbe_init_tx_coalesce(struct xgbe_prv_data *pdata)
50189 {
50190- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50191+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50192
50193 DBGPR("-->xgbe_init_tx_coalesce\n");
50194
50195@@ -716,7 +716,7 @@ void xgbe_init_tx_coalesce(struct xgbe_prv_data *pdata)
50196
50197 void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata)
50198 {
50199- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50200+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50201
50202 DBGPR("-->xgbe_init_rx_coalesce\n");
50203
50204@@ -731,7 +731,7 @@ void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata)
50205
50206 static void xgbe_free_tx_data(struct xgbe_prv_data *pdata)
50207 {
50208- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50209+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50210 struct xgbe_channel *channel;
50211 struct xgbe_ring *ring;
50212 struct xgbe_ring_data *rdata;
50213@@ -756,7 +756,7 @@ static void xgbe_free_tx_data(struct xgbe_prv_data *pdata)
50214
50215 static void xgbe_free_rx_data(struct xgbe_prv_data *pdata)
50216 {
50217- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50218+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50219 struct xgbe_channel *channel;
50220 struct xgbe_ring *ring;
50221 struct xgbe_ring_data *rdata;
50222@@ -784,13 +784,13 @@ static int xgbe_phy_init(struct xgbe_prv_data *pdata)
50223 pdata->phy_link = -1;
50224 pdata->phy_speed = SPEED_UNKNOWN;
50225
50226- return pdata->phy_if.phy_reset(pdata);
50227+ return pdata->phy_if->phy_reset(pdata);
50228 }
50229
50230 int xgbe_powerdown(struct net_device *netdev, unsigned int caller)
50231 {
50232 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50233- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50234+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50235 unsigned long flags;
50236
50237 DBGPR("-->xgbe_powerdown\n");
50238@@ -829,7 +829,7 @@ int xgbe_powerdown(struct net_device *netdev, unsigned int caller)
50239 int xgbe_powerup(struct net_device *netdev, unsigned int caller)
50240 {
50241 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50242- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50243+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50244 unsigned long flags;
50245
50246 DBGPR("-->xgbe_powerup\n");
50247@@ -866,8 +866,8 @@ int xgbe_powerup(struct net_device *netdev, unsigned int caller)
50248
50249 static int xgbe_start(struct xgbe_prv_data *pdata)
50250 {
50251- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50252- struct xgbe_phy_if *phy_if = &pdata->phy_if;
50253+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50254+ struct xgbe_phy_if *phy_if = pdata->phy_if;
50255 struct net_device *netdev = pdata->netdev;
50256 int ret;
50257
50258@@ -910,8 +910,8 @@ err_phy:
50259
50260 static void xgbe_stop(struct xgbe_prv_data *pdata)
50261 {
50262- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50263- struct xgbe_phy_if *phy_if = &pdata->phy_if;
50264+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50265+ struct xgbe_phy_if *phy_if = pdata->phy_if;
50266 struct xgbe_channel *channel;
50267 struct net_device *netdev = pdata->netdev;
50268 struct netdev_queue *txq;
50269@@ -1139,7 +1139,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
50270 return -ERANGE;
50271 }
50272
50273- pdata->hw_if.config_tstamp(pdata, mac_tscr);
50274+ pdata->hw_if->config_tstamp(pdata, mac_tscr);
50275
50276 memcpy(&pdata->tstamp_config, &config, sizeof(config));
50277
50278@@ -1288,7 +1288,7 @@ static void xgbe_packet_info(struct xgbe_prv_data *pdata,
50279 static int xgbe_open(struct net_device *netdev)
50280 {
50281 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50282- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50283+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50284 int ret;
50285
50286 DBGPR("-->xgbe_open\n");
50287@@ -1360,7 +1360,7 @@ err_sysclk:
50288 static int xgbe_close(struct net_device *netdev)
50289 {
50290 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50291- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50292+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50293
50294 DBGPR("-->xgbe_close\n");
50295
50296@@ -1387,8 +1387,8 @@ static int xgbe_close(struct net_device *netdev)
50297 static int xgbe_xmit(struct sk_buff *skb, struct net_device *netdev)
50298 {
50299 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50300- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50301- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50302+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50303+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50304 struct xgbe_channel *channel;
50305 struct xgbe_ring *ring;
50306 struct xgbe_packet_data *packet;
50307@@ -1457,7 +1457,7 @@ tx_netdev_return:
50308 static void xgbe_set_rx_mode(struct net_device *netdev)
50309 {
50310 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50311- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50312+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50313
50314 DBGPR("-->xgbe_set_rx_mode\n");
50315
50316@@ -1469,7 +1469,7 @@ static void xgbe_set_rx_mode(struct net_device *netdev)
50317 static int xgbe_set_mac_address(struct net_device *netdev, void *addr)
50318 {
50319 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50320- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50321+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50322 struct sockaddr *saddr = addr;
50323
50324 DBGPR("-->xgbe_set_mac_address\n");
50325@@ -1544,7 +1544,7 @@ static struct rtnl_link_stats64 *xgbe_get_stats64(struct net_device *netdev,
50326
50327 DBGPR("-->%s\n", __func__);
50328
50329- pdata->hw_if.read_mmc_stats(pdata);
50330+ pdata->hw_if->read_mmc_stats(pdata);
50331
50332 s->rx_packets = pstats->rxframecount_gb;
50333 s->rx_bytes = pstats->rxoctetcount_gb;
50334@@ -1571,7 +1571,7 @@ static int xgbe_vlan_rx_add_vid(struct net_device *netdev, __be16 proto,
50335 u16 vid)
50336 {
50337 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50338- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50339+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50340
50341 DBGPR("-->%s\n", __func__);
50342
50343@@ -1587,7 +1587,7 @@ static int xgbe_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto,
50344 u16 vid)
50345 {
50346 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50347- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50348+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50349
50350 DBGPR("-->%s\n", __func__);
50351
50352@@ -1654,7 +1654,7 @@ static int xgbe_set_features(struct net_device *netdev,
50353 netdev_features_t features)
50354 {
50355 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50356- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50357+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50358 netdev_features_t rxhash, rxcsum, rxvlan, rxvlan_filter;
50359 int ret = 0;
50360
50361@@ -1720,8 +1720,8 @@ struct net_device_ops *xgbe_get_netdev_ops(void)
50362 static void xgbe_rx_refresh(struct xgbe_channel *channel)
50363 {
50364 struct xgbe_prv_data *pdata = channel->pdata;
50365- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50366- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50367+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50368+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50369 struct xgbe_ring *ring = channel->rx_ring;
50370 struct xgbe_ring_data *rdata;
50371
50372@@ -1798,8 +1798,8 @@ static struct sk_buff *xgbe_create_skb(struct xgbe_prv_data *pdata,
50373 static int xgbe_tx_poll(struct xgbe_channel *channel)
50374 {
50375 struct xgbe_prv_data *pdata = channel->pdata;
50376- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50377- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50378+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50379+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50380 struct xgbe_ring *ring = channel->tx_ring;
50381 struct xgbe_ring_data *rdata;
50382 struct xgbe_ring_desc *rdesc;
50383@@ -1863,7 +1863,7 @@ static int xgbe_tx_poll(struct xgbe_channel *channel)
50384 static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
50385 {
50386 struct xgbe_prv_data *pdata = channel->pdata;
50387- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50388+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50389 struct xgbe_ring *ring = channel->rx_ring;
50390 struct xgbe_ring_data *rdata;
50391 struct xgbe_packet_data *packet;
50392diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
50393index 59e090e..90bc0b4 100644
50394--- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
50395+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
50396@@ -211,7 +211,7 @@ static void xgbe_get_ethtool_stats(struct net_device *netdev,
50397
50398 DBGPR("-->%s\n", __func__);
50399
50400- pdata->hw_if.read_mmc_stats(pdata);
50401+ pdata->hw_if->read_mmc_stats(pdata);
50402 for (i = 0; i < XGBE_STATS_COUNT; i++) {
50403 stat = (u8 *)pdata + xgbe_gstring_stats[i].stat_offset;
50404 *data++ = *(u64 *)stat;
50405@@ -284,7 +284,7 @@ static int xgbe_set_pauseparam(struct net_device *netdev,
50406 pdata->phy.advertising ^= ADVERTISED_Asym_Pause;
50407
50408 if (netif_running(netdev))
50409- ret = pdata->phy_if.phy_config_aneg(pdata);
50410+ ret = pdata->phy_if->phy_config_aneg(pdata);
50411
50412 DBGPR("<--xgbe_set_pauseparam\n");
50413
50414@@ -364,7 +364,7 @@ static int xgbe_set_settings(struct net_device *netdev,
50415 pdata->phy.advertising &= ~ADVERTISED_Autoneg;
50416
50417 if (netif_running(netdev))
50418- ret = pdata->phy_if.phy_config_aneg(pdata);
50419+ ret = pdata->phy_if->phy_config_aneg(pdata);
50420
50421 DBGPR("<--xgbe_set_settings\n");
50422
50423@@ -411,7 +411,7 @@ static int xgbe_set_coalesce(struct net_device *netdev,
50424 struct ethtool_coalesce *ec)
50425 {
50426 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50427- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50428+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50429 unsigned int rx_frames, rx_riwt, rx_usecs;
50430 unsigned int tx_frames;
50431
50432@@ -536,7 +536,7 @@ static int xgbe_set_rxfh(struct net_device *netdev, const u32 *indir,
50433 const u8 *key, const u8 hfunc)
50434 {
50435 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50436- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50437+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50438 unsigned int ret;
50439
50440 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
50441diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
50442index e83bd76..f2d5d56 100644
50443--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
50444+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
50445@@ -202,13 +202,6 @@ static void xgbe_default_config(struct xgbe_prv_data *pdata)
50446 DBGPR("<--xgbe_default_config\n");
50447 }
50448
50449-static void xgbe_init_all_fptrs(struct xgbe_prv_data *pdata)
50450-{
50451- xgbe_init_function_ptrs_dev(&pdata->hw_if);
50452- xgbe_init_function_ptrs_phy(&pdata->phy_if);
50453- xgbe_init_function_ptrs_desc(&pdata->desc_if);
50454-}
50455-
50456 #ifdef CONFIG_ACPI
50457 static int xgbe_acpi_support(struct xgbe_prv_data *pdata)
50458 {
50459@@ -641,10 +634,12 @@ static int xgbe_probe(struct platform_device *pdev)
50460 memcpy(netdev->dev_addr, pdata->mac_addr, netdev->addr_len);
50461
50462 /* Set all the function pointers */
50463- xgbe_init_all_fptrs(pdata);
50464+ pdata->hw_if = &default_xgbe_hw_if;
50465+ pdata->phy_if = &default_xgbe_phy_if;
50466+ pdata->desc_if = &default_xgbe_desc_if;
50467
50468 /* Issue software reset to device */
50469- pdata->hw_if.exit(pdata);
50470+ pdata->hw_if->exit(pdata);
50471
50472 /* Populate the hardware features */
50473 xgbe_get_all_hw_features(pdata);
50474@@ -698,7 +693,7 @@ static int xgbe_probe(struct platform_device *pdev)
50475 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, UDP4TE, 1);
50476
50477 /* Call MDIO/PHY initialization routine */
50478- pdata->phy_if.phy_init(pdata);
50479+ pdata->phy_if->phy_init(pdata);
50480
50481 /* Set device operations */
50482 netdev->netdev_ops = xgbe_get_netdev_ops();
50483diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
50484index 9088c3a..2ffe7c4 100644
50485--- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
50486+++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
50487@@ -202,7 +202,7 @@ static void xgbe_xgmii_mode(struct xgbe_prv_data *pdata)
50488 xgbe_an_enable_kr_training(pdata);
50489
50490 /* Set MAC to 10G speed */
50491- pdata->hw_if.set_xgmii_speed(pdata);
50492+ pdata->hw_if->set_xgmii_speed(pdata);
50493
50494 /* Set PCS to KR/10G speed */
50495 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL2);
50496@@ -250,7 +250,7 @@ static void xgbe_gmii_2500_mode(struct xgbe_prv_data *pdata)
50497 xgbe_an_disable_kr_training(pdata);
50498
50499 /* Set MAC to 2.5G speed */
50500- pdata->hw_if.set_gmii_2500_speed(pdata);
50501+ pdata->hw_if->set_gmii_2500_speed(pdata);
50502
50503 /* Set PCS to KX/1G speed */
50504 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL2);
50505@@ -298,7 +298,7 @@ static void xgbe_gmii_mode(struct xgbe_prv_data *pdata)
50506 xgbe_an_disable_kr_training(pdata);
50507
50508 /* Set MAC to 1G speed */
50509- pdata->hw_if.set_gmii_speed(pdata);
50510+ pdata->hw_if->set_gmii_speed(pdata);
50511
50512 /* Set PCS to KX/1G speed */
50513 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL2);
50514@@ -872,13 +872,13 @@ static void xgbe_phy_adjust_link(struct xgbe_prv_data *pdata)
50515
50516 if (pdata->tx_pause != pdata->phy.tx_pause) {
50517 new_state = 1;
50518- pdata->hw_if.config_tx_flow_control(pdata);
50519+ pdata->hw_if->config_tx_flow_control(pdata);
50520 pdata->tx_pause = pdata->phy.tx_pause;
50521 }
50522
50523 if (pdata->rx_pause != pdata->phy.rx_pause) {
50524 new_state = 1;
50525- pdata->hw_if.config_rx_flow_control(pdata);
50526+ pdata->hw_if->config_rx_flow_control(pdata);
50527 pdata->rx_pause = pdata->phy.rx_pause;
50528 }
50529
50530@@ -1351,14 +1351,13 @@ static void xgbe_phy_init(struct xgbe_prv_data *pdata)
50531 xgbe_dump_phy_registers(pdata);
50532 }
50533
50534-void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *phy_if)
50535-{
50536- phy_if->phy_init = xgbe_phy_init;
50537+const struct xgbe_phy_if default_xgbe_phy_if = {
50538+ .phy_init = xgbe_phy_init,
50539
50540- phy_if->phy_reset = xgbe_phy_reset;
50541- phy_if->phy_start = xgbe_phy_start;
50542- phy_if->phy_stop = xgbe_phy_stop;
50543+ .phy_reset = xgbe_phy_reset,
50544+ .phy_start = xgbe_phy_start,
50545+ .phy_stop = xgbe_phy_stop,
50546
50547- phy_if->phy_status = xgbe_phy_status;
50548- phy_if->phy_config_aneg = xgbe_phy_config_aneg;
50549-}
50550+ .phy_status = xgbe_phy_status,
50551+ .phy_config_aneg = xgbe_phy_config_aneg,
50552+};
50553diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
50554index b03e4f5..78e4cc4 100644
50555--- a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
50556+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
50557@@ -129,7 +129,7 @@ static cycle_t xgbe_cc_read(const struct cyclecounter *cc)
50558 tstamp_cc);
50559 u64 nsec;
50560
50561- nsec = pdata->hw_if.get_tstamp_time(pdata);
50562+ nsec = pdata->hw_if->get_tstamp_time(pdata);
50563
50564 return nsec;
50565 }
50566@@ -158,7 +158,7 @@ static int xgbe_adjfreq(struct ptp_clock_info *info, s32 delta)
50567
50568 spin_lock_irqsave(&pdata->tstamp_lock, flags);
50569
50570- pdata->hw_if.update_tstamp_addend(pdata, addend);
50571+ pdata->hw_if->update_tstamp_addend(pdata, addend);
50572
50573 spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
50574
50575diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
50576index 717ce21..aacd1f3 100644
50577--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
50578+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
50579@@ -801,9 +801,9 @@ struct xgbe_prv_data {
50580 int dev_irq;
50581 unsigned int per_channel_irq;
50582
50583- struct xgbe_hw_if hw_if;
50584- struct xgbe_phy_if phy_if;
50585- struct xgbe_desc_if desc_if;
50586+ struct xgbe_hw_if *hw_if;
50587+ struct xgbe_phy_if *phy_if;
50588+ struct xgbe_desc_if *desc_if;
50589
50590 /* AXI DMA settings */
50591 unsigned int coherent;
50592@@ -964,6 +964,10 @@ struct xgbe_prv_data {
50593 #endif
50594 };
50595
50596+extern const struct xgbe_hw_if default_xgbe_hw_if;
50597+extern const struct xgbe_phy_if default_xgbe_phy_if;
50598+extern const struct xgbe_desc_if default_xgbe_desc_if;
50599+
50600 /* Function prototypes*/
50601
50602 void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *);
50603diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
50604index 03b7404..01ff3b3 100644
50605--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
50606+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
50607@@ -1082,7 +1082,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
50608 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
50609 {
50610 /* RX_MODE controlling object */
50611- bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
50612+ bnx2x_init_rx_mode_obj(bp);
50613
50614 /* multicast configuration controlling object */
50615 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
50616diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
50617index 4ad415a..8e0a040 100644
50618--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
50619+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
50620@@ -2329,15 +2329,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
50621 return rc;
50622 }
50623
50624-void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
50625- struct bnx2x_rx_mode_obj *o)
50626+void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
50627 {
50628 if (CHIP_IS_E1x(bp)) {
50629- o->wait_comp = bnx2x_empty_rx_mode_wait;
50630- o->config_rx_mode = bnx2x_set_rx_mode_e1x;
50631+ bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
50632+ bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
50633 } else {
50634- o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
50635- o->config_rx_mode = bnx2x_set_rx_mode_e2;
50636+ bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
50637+ bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
50638 }
50639 }
50640
50641diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
50642index 86baecb..ff3bb46 100644
50643--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
50644+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
50645@@ -1411,8 +1411,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
50646
50647 /********************* RX MODE ****************/
50648
50649-void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
50650- struct bnx2x_rx_mode_obj *o);
50651+void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
50652
50653 /**
50654 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
50655diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
50656index 31c9f82..e65e986 100644
50657--- a/drivers/net/ethernet/broadcom/tg3.h
50658+++ b/drivers/net/ethernet/broadcom/tg3.h
50659@@ -150,6 +150,7 @@
50660 #define CHIPREV_ID_5750_A0 0x4000
50661 #define CHIPREV_ID_5750_A1 0x4001
50662 #define CHIPREV_ID_5750_A3 0x4003
50663+#define CHIPREV_ID_5750_C1 0x4201
50664 #define CHIPREV_ID_5750_C2 0x4202
50665 #define CHIPREV_ID_5752_A0_HW 0x5000
50666 #define CHIPREV_ID_5752_A0 0x6000
50667diff --git a/drivers/net/ethernet/brocade/bna/bna_enet.c b/drivers/net/ethernet/brocade/bna/bna_enet.c
50668index 4e5c387..bba8173 100644
50669--- a/drivers/net/ethernet/brocade/bna/bna_enet.c
50670+++ b/drivers/net/ethernet/brocade/bna/bna_enet.c
50671@@ -1676,10 +1676,10 @@ bna_cb_ioceth_reset(void *arg)
50672 }
50673
50674 static struct bfa_ioc_cbfn bna_ioceth_cbfn = {
50675- bna_cb_ioceth_enable,
50676- bna_cb_ioceth_disable,
50677- bna_cb_ioceth_hbfail,
50678- bna_cb_ioceth_reset
50679+ .enable_cbfn = bna_cb_ioceth_enable,
50680+ .disable_cbfn = bna_cb_ioceth_disable,
50681+ .hbfail_cbfn = bna_cb_ioceth_hbfail,
50682+ .reset_cbfn = bna_cb_ioceth_reset
50683 };
50684
50685 static void bna_attr_init(struct bna_ioceth *ioceth)
50686diff --git a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
50687index 29f3308..b594c38 100644
50688--- a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
50689+++ b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
50690@@ -265,9 +265,9 @@ static void octnet_mdio_resp_callback(struct octeon_device *oct,
50691 if (status) {
50692 dev_err(&oct->pci_dev->dev, "MIDO instruction failed. Status: %llx\n",
50693 CVM_CAST64(status));
50694- ACCESS_ONCE(mdio_cmd_ctx->cond) = -1;
50695+ ACCESS_ONCE_RW(mdio_cmd_ctx->cond) = -1;
50696 } else {
50697- ACCESS_ONCE(mdio_cmd_ctx->cond) = 1;
50698+ ACCESS_ONCE_RW(mdio_cmd_ctx->cond) = 1;
50699 }
50700 wake_up_interruptible(&mdio_cmd_ctx->wc);
50701 }
50702@@ -298,7 +298,7 @@ octnet_mdio45_access(struct lio *lio, int op, int loc, int *value)
50703 mdio_cmd_rsp = (struct oct_mdio_cmd_resp *)sc->virtrptr;
50704 mdio_cmd = (struct oct_mdio_cmd *)sc->virtdptr;
50705
50706- ACCESS_ONCE(mdio_cmd_ctx->cond) = 0;
50707+ ACCESS_ONCE_RW(mdio_cmd_ctx->cond) = 0;
50708 mdio_cmd_ctx->octeon_id = lio_get_device_id(oct_dev);
50709 mdio_cmd->op = op;
50710 mdio_cmd->mdio_addr = loc;
50711diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
50712index 0660dee..e07895e 100644
50713--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
50714+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
50715@@ -1727,7 +1727,7 @@ static void if_cfg_callback(struct octeon_device *oct,
50716 if (resp->status)
50717 dev_err(&oct->pci_dev->dev, "nic if cfg instruction failed. Status: %llx\n",
50718 CVM_CAST64(resp->status));
50719- ACCESS_ONCE(ctx->cond) = 1;
50720+ ACCESS_ONCE_RW(ctx->cond) = 1;
50721
50722 /* This barrier is required to be sure that the response has been
50723 * written fully before waking up the handler
50724@@ -3177,7 +3177,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
50725 dev_dbg(&octeon_dev->pci_dev->dev,
50726 "requesting config for interface %d, iqs %d, oqs %d\n",
50727 i, num_iqueues, num_oqueues);
50728- ACCESS_ONCE(ctx->cond) = 0;
50729+ ACCESS_ONCE_RW(ctx->cond) = 0;
50730 ctx->octeon_id = lio_get_device_id(octeon_dev);
50731 init_waitqueue_head(&ctx->wc);
50732
50733@@ -3240,8 +3240,11 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
50734 props = &octeon_dev->props[i];
50735 props->netdev = netdev;
50736
50737- if (num_iqueues > 1)
50738- lionetdevops.ndo_select_queue = select_q;
50739+ if (num_iqueues > 1) {
50740+ pax_open_kernel();
50741+ *(void **)&lionetdevops.ndo_select_queue = select_q;
50742+ pax_close_kernel();
50743+ }
50744
50745 /* Associate the routines that will handle different
50746 * netdev tasks.
50747diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
50748index 8cffcdf..aadf043 100644
50749--- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
50750+++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
50751@@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
50752 */
50753 struct l2t_skb_cb {
50754 arp_failure_handler_func arp_failure_handler;
50755-};
50756+} __no_const;
50757
50758 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
50759
50760diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
50761index 8966f31..e15a101 100644
50762--- a/drivers/net/ethernet/dec/tulip/de4x5.c
50763+++ b/drivers/net/ethernet/dec/tulip/de4x5.c
50764@@ -5373,7 +5373,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
50765 for (i=0; i<ETH_ALEN; i++) {
50766 tmp.addr[i] = dev->dev_addr[i];
50767 }
50768- if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
50769+ if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
50770 break;
50771
50772 case DE4X5_SET_HWADDR: /* Set the hardware address */
50773@@ -5413,7 +5413,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
50774 spin_lock_irqsave(&lp->lock, flags);
50775 memcpy(&statbuf, &lp->pktStats, ioc->len);
50776 spin_unlock_irqrestore(&lp->lock, flags);
50777- if (copy_to_user(ioc->data, &statbuf, ioc->len))
50778+ if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
50779 return -EFAULT;
50780 break;
50781 }
50782diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
50783index 6ca693b..fa18c3f 100644
50784--- a/drivers/net/ethernet/emulex/benet/be_main.c
50785+++ b/drivers/net/ethernet/emulex/benet/be_main.c
50786@@ -551,7 +551,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
50787
50788 if (wrapped)
50789 newacc += 65536;
50790- ACCESS_ONCE(*acc) = newacc;
50791+ ACCESS_ONCE_RW(*acc) = newacc;
50792 }
50793
50794 static void populate_erx_stats(struct be_adapter *adapter,
50795diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
50796index 6d0c5d5..55be363 100644
50797--- a/drivers/net/ethernet/faraday/ftgmac100.c
50798+++ b/drivers/net/ethernet/faraday/ftgmac100.c
50799@@ -30,6 +30,8 @@
50800 #include <linux/netdevice.h>
50801 #include <linux/phy.h>
50802 #include <linux/platform_device.h>
50803+#include <linux/interrupt.h>
50804+#include <linux/irqreturn.h>
50805 #include <net/ip.h>
50806
50807 #include "ftgmac100.h"
50808diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
50809index dce5f7b..2433466 100644
50810--- a/drivers/net/ethernet/faraday/ftmac100.c
50811+++ b/drivers/net/ethernet/faraday/ftmac100.c
50812@@ -31,6 +31,8 @@
50813 #include <linux/module.h>
50814 #include <linux/netdevice.h>
50815 #include <linux/platform_device.h>
50816+#include <linux/interrupt.h>
50817+#include <linux/irqreturn.h>
50818
50819 #include "ftmac100.h"
50820
50821diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
50822index a92b772..250fe69 100644
50823--- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
50824+++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
50825@@ -419,7 +419,7 @@ void i40e_ptp_set_increment(struct i40e_pf *pf)
50826 wr32(hw, I40E_PRTTSYN_INC_H, incval >> 32);
50827
50828 /* Update the base adjustement value. */
50829- ACCESS_ONCE(pf->ptp_base_adj) = incval;
50830+ ACCESS_ONCE_RW(pf->ptp_base_adj) = incval;
50831 smp_mb(); /* Force the above update. */
50832 }
50833
50834diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
50835index e5ba040..d47531c 100644
50836--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
50837+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
50838@@ -782,7 +782,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
50839 }
50840
50841 /* update the base incval used to calculate frequency adjustment */
50842- ACCESS_ONCE(adapter->base_incval) = incval;
50843+ ACCESS_ONCE_RW(adapter->base_incval) = incval;
50844 smp_mb();
50845
50846 /* need lock to prevent incorrect read while modifying cyclecounter */
50847diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
50848index c10d98f..72914c6 100644
50849--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
50850+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
50851@@ -475,8 +475,8 @@ static bool mlx4_en_process_tx_cq(struct net_device *dev,
50852 wmb();
50853
50854 /* we want to dirty this cache line once */
50855- ACCESS_ONCE(ring->last_nr_txbb) = last_nr_txbb;
50856- ACCESS_ONCE(ring->cons) = ring_cons + txbbs_skipped;
50857+ ACCESS_ONCE_RW(ring->last_nr_txbb) = last_nr_txbb;
50858+ ACCESS_ONCE_RW(ring->cons) = ring_cons + txbbs_skipped;
50859
50860 netdev_tx_completed_queue(ring->tx_queue, packets, bytes);
50861
50862diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
50863index 40206da..9d94643 100644
50864--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
50865+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
50866@@ -1734,7 +1734,9 @@ static void mlx5e_build_netdev(struct net_device *netdev)
50867 SET_NETDEV_DEV(netdev, &mdev->pdev->dev);
50868
50869 if (priv->num_tc > 1) {
50870- mlx5e_netdev_ops.ndo_select_queue = mlx5e_select_queue;
50871+ pax_open_kernel();
50872+ *(void **)&mlx5e_netdev_ops.ndo_select_queue = mlx5e_select_queue;
50873+ pax_close_kernel();
50874 }
50875
50876 netdev->netdev_ops = &mlx5e_netdev_ops;
50877diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
50878index 6223930..975033d 100644
50879--- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
50880+++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
50881@@ -3457,7 +3457,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
50882 struct __vxge_hw_fifo *fifo;
50883 struct vxge_hw_fifo_config *config;
50884 u32 txdl_size, txdl_per_memblock;
50885- struct vxge_hw_mempool_cbs fifo_mp_callback;
50886+ static struct vxge_hw_mempool_cbs fifo_mp_callback = {
50887+ .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
50888+ };
50889+
50890 struct __vxge_hw_virtualpath *vpath;
50891
50892 if ((vp == NULL) || (attr == NULL)) {
50893@@ -3540,8 +3543,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
50894 goto exit;
50895 }
50896
50897- fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
50898-
50899 fifo->mempool =
50900 __vxge_hw_mempool_create(vpath->hldev,
50901 fifo->config->memblock_size,
50902diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
50903index 753ea8b..674c39a 100644
50904--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
50905+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
50906@@ -2324,7 +2324,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
50907 max_tx_rings = QLCNIC_MAX_VNIC_TX_RINGS;
50908 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
50909 ahw->nic_mode = QLCNIC_DEFAULT_MODE;
50910- adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
50911+ pax_open_kernel();
50912+ *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
50913+ pax_close_kernel();
50914 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
50915 max_sds_rings = QLCNIC_MAX_SDS_RINGS;
50916 max_tx_rings = QLCNIC_MAX_TX_RINGS;
50917diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
50918index be7d7a6..a8983f8 100644
50919--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
50920+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
50921@@ -207,17 +207,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
50922 case QLCNIC_NON_PRIV_FUNC:
50923 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
50924 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
50925- nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
50926+ pax_open_kernel();
50927+ *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
50928+ pax_close_kernel();
50929 break;
50930 case QLCNIC_PRIV_FUNC:
50931 ahw->op_mode = QLCNIC_PRIV_FUNC;
50932 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
50933- nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
50934+ pax_open_kernel();
50935+ *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
50936+ pax_close_kernel();
50937 break;
50938 case QLCNIC_MGMT_FUNC:
50939 ahw->op_mode = QLCNIC_MGMT_FUNC;
50940 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
50941- nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
50942+ pax_open_kernel();
50943+ *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
50944+ pax_close_kernel();
50945 break;
50946 default:
50947 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
50948diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
50949index 332bb8a..e6adcd1 100644
50950--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
50951+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
50952@@ -1285,7 +1285,7 @@ flash_temp:
50953 int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
50954 {
50955 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
50956- static const struct qlcnic_dump_operations *fw_dump_ops;
50957+ const struct qlcnic_dump_operations *fw_dump_ops;
50958 struct qlcnic_83xx_dump_template_hdr *hdr_83xx;
50959 u32 entry_offset, dump, no_entries, buf_offset = 0;
50960 int i, k, ops_cnt, ops_index, dump_size = 0;
50961diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
50962index f790f61..f1faafe 100644
50963--- a/drivers/net/ethernet/realtek/r8169.c
50964+++ b/drivers/net/ethernet/realtek/r8169.c
50965@@ -788,22 +788,22 @@ struct rtl8169_private {
50966 struct mdio_ops {
50967 void (*write)(struct rtl8169_private *, int, int);
50968 int (*read)(struct rtl8169_private *, int);
50969- } mdio_ops;
50970+ } __no_const mdio_ops;
50971
50972 struct pll_power_ops {
50973 void (*down)(struct rtl8169_private *);
50974 void (*up)(struct rtl8169_private *);
50975- } pll_power_ops;
50976+ } __no_const pll_power_ops;
50977
50978 struct jumbo_ops {
50979 void (*enable)(struct rtl8169_private *);
50980 void (*disable)(struct rtl8169_private *);
50981- } jumbo_ops;
50982+ } __no_const jumbo_ops;
50983
50984 struct csi_ops {
50985 void (*write)(struct rtl8169_private *, int, int);
50986 u32 (*read)(struct rtl8169_private *, int);
50987- } csi_ops;
50988+ } __no_const csi_ops;
50989
50990 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
50991 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
50992diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
50993index ad62615..a4c124d 100644
50994--- a/drivers/net/ethernet/sfc/ptp.c
50995+++ b/drivers/net/ethernet/sfc/ptp.c
50996@@ -832,7 +832,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
50997 ptp->start.dma_addr);
50998
50999 /* Clear flag that signals MC ready */
51000- ACCESS_ONCE(*start) = 0;
51001+ ACCESS_ONCE_RW(*start) = 0;
51002 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
51003 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
51004 EFX_BUG_ON_PARANOID(rc);
51005diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
51006index 3f20bb1..59add41 100644
51007--- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
51008+++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
51009@@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
51010
51011 writel(value, ioaddr + MMC_CNTRL);
51012
51013- pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
51014- MMC_CNTRL, value);
51015+// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
51016+// MMC_CNTRL, value);
51017 }
51018
51019 /* To mask all all interrupts.*/
51020diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
51021index a832637..092da0a 100644
51022--- a/drivers/net/ethernet/via/via-rhine.c
51023+++ b/drivers/net/ethernet/via/via-rhine.c
51024@@ -2599,7 +2599,7 @@ static struct platform_driver rhine_driver_platform = {
51025 }
51026 };
51027
51028-static struct dmi_system_id rhine_dmi_table[] __initdata = {
51029+static const struct dmi_system_id rhine_dmi_table[] __initconst = {
51030 {
51031 .ident = "EPIA-M",
51032 .matches = {
51033diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
51034index dd45440..c5f3cae 100644
51035--- a/drivers/net/hyperv/hyperv_net.h
51036+++ b/drivers/net/hyperv/hyperv_net.h
51037@@ -177,7 +177,7 @@ struct rndis_device {
51038 enum rndis_device_state state;
51039 bool link_state;
51040 bool link_change;
51041- atomic_t new_req_id;
51042+ atomic_unchecked_t new_req_id;
51043
51044 spinlock_t request_lock;
51045 struct list_head req_list;
51046diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
51047index 236aeb7..fd695e2 100644
51048--- a/drivers/net/hyperv/rndis_filter.c
51049+++ b/drivers/net/hyperv/rndis_filter.c
51050@@ -101,7 +101,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
51051 * template
51052 */
51053 set = &rndis_msg->msg.set_req;
51054- set->req_id = atomic_inc_return(&dev->new_req_id);
51055+ set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
51056
51057 /* Add to the request list */
51058 spin_lock_irqsave(&dev->request_lock, flags);
51059@@ -924,7 +924,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
51060
51061 /* Setup the rndis set */
51062 halt = &request->request_msg.msg.halt_req;
51063- halt->req_id = atomic_inc_return(&dev->new_req_id);
51064+ halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
51065
51066 /* Ignore return since this msg is optional. */
51067 rndis_filter_send_request(dev, request);
51068diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
51069index 94570aa..1a798e1 100644
51070--- a/drivers/net/ifb.c
51071+++ b/drivers/net/ifb.c
51072@@ -253,7 +253,7 @@ static int ifb_validate(struct nlattr *tb[], struct nlattr *data[])
51073 return 0;
51074 }
51075
51076-static struct rtnl_link_ops ifb_link_ops __read_mostly = {
51077+static struct rtnl_link_ops ifb_link_ops = {
51078 .kind = "ifb",
51079 .priv_size = sizeof(struct ifb_private),
51080 .setup = ifb_setup,
51081diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
51082index 207f62e..af3f5e5 100644
51083--- a/drivers/net/ipvlan/ipvlan_core.c
51084+++ b/drivers/net/ipvlan/ipvlan_core.c
51085@@ -466,7 +466,7 @@ static void ipvlan_multicast_enqueue(struct ipvl_port *port,
51086 schedule_work(&port->wq);
51087 } else {
51088 spin_unlock(&port->backlog.lock);
51089- atomic_long_inc(&skb->dev->rx_dropped);
51090+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
51091 kfree_skb(skb);
51092 }
51093 }
51094diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
51095index 9f59f17..52cb38f 100644
51096--- a/drivers/net/macvlan.c
51097+++ b/drivers/net/macvlan.c
51098@@ -335,7 +335,7 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
51099 free_nskb:
51100 kfree_skb(nskb);
51101 err:
51102- atomic_long_inc(&skb->dev->rx_dropped);
51103+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
51104 }
51105
51106 static void macvlan_flush_sources(struct macvlan_port *port,
51107@@ -1480,13 +1480,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
51108 int macvlan_link_register(struct rtnl_link_ops *ops)
51109 {
51110 /* common fields */
51111- ops->priv_size = sizeof(struct macvlan_dev);
51112- ops->validate = macvlan_validate;
51113- ops->maxtype = IFLA_MACVLAN_MAX;
51114- ops->policy = macvlan_policy;
51115- ops->changelink = macvlan_changelink;
51116- ops->get_size = macvlan_get_size;
51117- ops->fill_info = macvlan_fill_info;
51118+ pax_open_kernel();
51119+ *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
51120+ *(void **)&ops->validate = macvlan_validate;
51121+ *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
51122+ *(const void **)&ops->policy = macvlan_policy;
51123+ *(void **)&ops->changelink = macvlan_changelink;
51124+ *(void **)&ops->get_size = macvlan_get_size;
51125+ *(void **)&ops->fill_info = macvlan_fill_info;
51126+ pax_close_kernel();
51127
51128 return rtnl_link_register(ops);
51129 };
51130@@ -1572,7 +1574,7 @@ static int macvlan_device_event(struct notifier_block *unused,
51131 return NOTIFY_DONE;
51132 }
51133
51134-static struct notifier_block macvlan_notifier_block __read_mostly = {
51135+static struct notifier_block macvlan_notifier_block = {
51136 .notifier_call = macvlan_device_event,
51137 };
51138
51139diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
51140index 248478c..05e8467 100644
51141--- a/drivers/net/macvtap.c
51142+++ b/drivers/net/macvtap.c
51143@@ -485,7 +485,7 @@ static void macvtap_setup(struct net_device *dev)
51144 dev->tx_queue_len = TUN_READQ_SIZE;
51145 }
51146
51147-static struct rtnl_link_ops macvtap_link_ops __read_mostly = {
51148+static struct rtnl_link_ops macvtap_link_ops = {
51149 .kind = "macvtap",
51150 .setup = macvtap_setup,
51151 .newlink = macvtap_newlink,
51152@@ -1090,7 +1090,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
51153
51154 ret = 0;
51155 u = q->flags;
51156- if (copy_to_user(&ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
51157+ if (copy_to_user(ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
51158 put_user(u, &ifr->ifr_flags))
51159 ret = -EFAULT;
51160 macvtap_put_vlan(vlan);
51161@@ -1308,7 +1308,7 @@ static int macvtap_device_event(struct notifier_block *unused,
51162 return NOTIFY_DONE;
51163 }
51164
51165-static struct notifier_block macvtap_notifier_block __read_mostly = {
51166+static struct notifier_block macvtap_notifier_block = {
51167 .notifier_call = macvtap_device_event,
51168 };
51169
51170diff --git a/drivers/net/nlmon.c b/drivers/net/nlmon.c
51171index 34924df..a747360 100644
51172--- a/drivers/net/nlmon.c
51173+++ b/drivers/net/nlmon.c
51174@@ -154,7 +154,7 @@ static int nlmon_validate(struct nlattr *tb[], struct nlattr *data[])
51175 return 0;
51176 }
51177
51178-static struct rtnl_link_ops nlmon_link_ops __read_mostly = {
51179+static struct rtnl_link_ops nlmon_link_ops = {
51180 .kind = "nlmon",
51181 .priv_size = sizeof(struct nlmon),
51182 .setup = nlmon_setup,
51183diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
51184index 55f0178..6220e93 100644
51185--- a/drivers/net/phy/phy_device.c
51186+++ b/drivers/net/phy/phy_device.c
51187@@ -218,7 +218,7 @@ EXPORT_SYMBOL(phy_device_create);
51188 * zero on success.
51189 *
51190 */
51191-static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
51192+static int get_phy_c45_ids(struct mii_bus *bus, int addr, int *phy_id,
51193 struct phy_c45_device_ids *c45_ids) {
51194 int phy_reg;
51195 int i, reg_addr;
51196@@ -296,7 +296,7 @@ retry: reg_addr = MII_ADDR_C45 | i << 16 | MDIO_DEVS2;
51197 * its return value is in turn returned.
51198 *
51199 */
51200-static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
51201+static int get_phy_id(struct mii_bus *bus, int addr, int *phy_id,
51202 bool is_c45, struct phy_c45_device_ids *c45_ids)
51203 {
51204 int phy_reg;
51205@@ -334,7 +334,7 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
51206 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
51207 {
51208 struct phy_c45_device_ids c45_ids = {0};
51209- u32 phy_id = 0;
51210+ int phy_id = 0;
51211 int r;
51212
51213 r = get_phy_id(bus, addr, &phy_id, is_c45, &c45_ids);
51214diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
51215index 487be20..f4c87bc 100644
51216--- a/drivers/net/ppp/ppp_generic.c
51217+++ b/drivers/net/ppp/ppp_generic.c
51218@@ -1035,7 +1035,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
51219 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
51220 struct ppp_stats stats;
51221 struct ppp_comp_stats cstats;
51222- char *vers;
51223
51224 switch (cmd) {
51225 case SIOCGPPPSTATS:
51226@@ -1057,8 +1056,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
51227 break;
51228
51229 case SIOCGPPPVER:
51230- vers = PPP_VERSION;
51231- if (copy_to_user(addr, vers, strlen(vers) + 1))
51232+ if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
51233 break;
51234 err = 0;
51235 break;
51236diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
51237index 079f7ad..7e59810 100644
51238--- a/drivers/net/slip/slhc.c
51239+++ b/drivers/net/slip/slhc.c
51240@@ -94,6 +94,9 @@ slhc_init(int rslots, int tslots)
51241 register struct cstate *ts;
51242 struct slcompress *comp;
51243
51244+ if (rslots <= 0 || tslots <= 0 || rslots >= 256 || tslots >= 256)
51245+ goto out_fail;
51246+
51247 comp = kzalloc(sizeof(struct slcompress), GFP_KERNEL);
51248 if (! comp)
51249 goto out_fail;
51250@@ -487,7 +490,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
51251 register struct tcphdr *thp;
51252 register struct iphdr *ip;
51253 register struct cstate *cs;
51254- int len, hdrlen;
51255+ long len, hdrlen;
51256 unsigned char *cp = icp;
51257
51258 /* We've got a compressed packet; read the change byte */
51259diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
51260index daa054b..07d6b98 100644
51261--- a/drivers/net/team/team.c
51262+++ b/drivers/net/team/team.c
51263@@ -2107,7 +2107,7 @@ static unsigned int team_get_num_rx_queues(void)
51264 return TEAM_DEFAULT_NUM_RX_QUEUES;
51265 }
51266
51267-static struct rtnl_link_ops team_link_ops __read_mostly = {
51268+static struct rtnl_link_ops team_link_ops = {
51269 .kind = DRV_NAME,
51270 .priv_size = sizeof(struct team),
51271 .setup = team_setup,
51272@@ -2897,7 +2897,7 @@ static int team_device_event(struct notifier_block *unused,
51273 return NOTIFY_DONE;
51274 }
51275
51276-static struct notifier_block team_notifier_block __read_mostly = {
51277+static struct notifier_block team_notifier_block = {
51278 .notifier_call = team_device_event,
51279 };
51280
51281diff --git a/drivers/net/tun.c b/drivers/net/tun.c
51282index 06a0394..1756d18 100644
51283--- a/drivers/net/tun.c
51284+++ b/drivers/net/tun.c
51285@@ -1472,7 +1472,7 @@ static int tun_validate(struct nlattr *tb[], struct nlattr *data[])
51286 return -EINVAL;
51287 }
51288
51289-static struct rtnl_link_ops tun_link_ops __read_mostly = {
51290+static struct rtnl_link_ops tun_link_ops = {
51291 .kind = DRV_NAME,
51292 .priv_size = sizeof(struct tun_struct),
51293 .setup = tun_setup,
51294@@ -1871,7 +1871,7 @@ unlock:
51295 }
51296
51297 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
51298- unsigned long arg, int ifreq_len)
51299+ unsigned long arg, size_t ifreq_len)
51300 {
51301 struct tun_file *tfile = file->private_data;
51302 struct tun_struct *tun;
51303@@ -1885,6 +1885,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
51304 int le;
51305 int ret;
51306
51307+ if (ifreq_len > sizeof ifr)
51308+ return -EFAULT;
51309+
51310 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
51311 if (copy_from_user(&ifr, argp, ifreq_len))
51312 return -EFAULT;
51313diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
51314index 111d907..1ee643e 100644
51315--- a/drivers/net/usb/hso.c
51316+++ b/drivers/net/usb/hso.c
51317@@ -70,7 +70,7 @@
51318 #include <asm/byteorder.h>
51319 #include <linux/serial_core.h>
51320 #include <linux/serial.h>
51321-
51322+#include <asm/local.h>
51323
51324 #define MOD_AUTHOR "Option Wireless"
51325 #define MOD_DESCRIPTION "USB High Speed Option driver"
51326@@ -1183,7 +1183,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
51327 struct urb *urb;
51328
51329 urb = serial->rx_urb[0];
51330- if (serial->port.count > 0) {
51331+ if (atomic_read(&serial->port.count) > 0) {
51332 count = put_rxbuf_data(urb, serial);
51333 if (count == -1)
51334 return;
51335@@ -1221,7 +1221,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
51336 DUMP1(urb->transfer_buffer, urb->actual_length);
51337
51338 /* Anyone listening? */
51339- if (serial->port.count == 0)
51340+ if (atomic_read(&serial->port.count) == 0)
51341 return;
51342
51343 if (serial->parent->port_spec & HSO_INFO_CRC_BUG)
51344@@ -1282,8 +1282,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
51345 tty_port_tty_set(&serial->port, tty);
51346
51347 /* check for port already opened, if not set the termios */
51348- serial->port.count++;
51349- if (serial->port.count == 1) {
51350+ if (atomic_inc_return(&serial->port.count) == 1) {
51351 serial->rx_state = RX_IDLE;
51352 /* Force default termio settings */
51353 _hso_serial_set_termios(tty, NULL);
51354@@ -1293,7 +1292,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
51355 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
51356 if (result) {
51357 hso_stop_serial_device(serial->parent);
51358- serial->port.count--;
51359+ atomic_dec(&serial->port.count);
51360 } else {
51361 kref_get(&serial->parent->ref);
51362 }
51363@@ -1331,10 +1330,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
51364
51365 /* reset the rts and dtr */
51366 /* do the actual close */
51367- serial->port.count--;
51368+ atomic_dec(&serial->port.count);
51369
51370- if (serial->port.count <= 0) {
51371- serial->port.count = 0;
51372+ if (atomic_read(&serial->port.count) <= 0) {
51373+ atomic_set(&serial->port.count, 0);
51374 tty_port_tty_set(&serial->port, NULL);
51375 if (!usb_gone)
51376 hso_stop_serial_device(serial->parent);
51377@@ -1417,7 +1416,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
51378
51379 /* the actual setup */
51380 spin_lock_irqsave(&serial->serial_lock, flags);
51381- if (serial->port.count)
51382+ if (atomic_read(&serial->port.count))
51383 _hso_serial_set_termios(tty, old);
51384 else
51385 tty->termios = *old;
51386@@ -1891,7 +1890,7 @@ static void intr_callback(struct urb *urb)
51387 D1("Pending read interrupt on port %d\n", i);
51388 spin_lock(&serial->serial_lock);
51389 if (serial->rx_state == RX_IDLE &&
51390- serial->port.count > 0) {
51391+ atomic_read(&serial->port.count) > 0) {
51392 /* Setup and send a ctrl req read on
51393 * port i */
51394 if (!serial->rx_urb_filled[0]) {
51395@@ -3058,7 +3057,7 @@ static int hso_resume(struct usb_interface *iface)
51396 /* Start all serial ports */
51397 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
51398 if (serial_table[i] && (serial_table[i]->interface == iface)) {
51399- if (dev2ser(serial_table[i])->port.count) {
51400+ if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
51401 result =
51402 hso_start_serial_device(serial_table[i], GFP_NOIO);
51403 hso_kick_transmit(dev2ser(serial_table[i]));
51404diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
51405index ad8cbc6..de80b09 100644
51406--- a/drivers/net/usb/r8152.c
51407+++ b/drivers/net/usb/r8152.c
51408@@ -603,7 +603,7 @@ struct r8152 {
51409 void (*unload)(struct r8152 *);
51410 int (*eee_get)(struct r8152 *, struct ethtool_eee *);
51411 int (*eee_set)(struct r8152 *, struct ethtool_eee *);
51412- } rtl_ops;
51413+ } __no_const rtl_ops;
51414
51415 int intr_interval;
51416 u32 saved_wolopts;
51417diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
51418index a2515887..6d13233 100644
51419--- a/drivers/net/usb/sierra_net.c
51420+++ b/drivers/net/usb/sierra_net.c
51421@@ -51,7 +51,7 @@ static const char driver_name[] = "sierra_net";
51422 /* atomic counter partially included in MAC address to make sure 2 devices
51423 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
51424 */
51425-static atomic_t iface_counter = ATOMIC_INIT(0);
51426+static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
51427
51428 /*
51429 * SYNC Timer Delay definition used to set the expiry time
51430@@ -697,7 +697,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
51431 dev->net->netdev_ops = &sierra_net_device_ops;
51432
51433 /* change MAC addr to include, ifacenum, and to be unique */
51434- dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
51435+ dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
51436 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
51437
51438 /* we will have to manufacture ethernet headers, prepare template */
51439diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
51440index 237f8e5..8dccb91 100644
51441--- a/drivers/net/virtio_net.c
51442+++ b/drivers/net/virtio_net.c
51443@@ -48,7 +48,7 @@ module_param(gso, bool, 0444);
51444 #define RECEIVE_AVG_WEIGHT 64
51445
51446 /* Minimum alignment for mergeable packet buffers. */
51447-#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, 256)
51448+#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, 256UL)
51449
51450 #define VIRTNET_DRIVER_VERSION "1.0.0"
51451
51452diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
51453index 5bc4b1e..d5769f5 100644
51454--- a/drivers/net/vxlan.c
51455+++ b/drivers/net/vxlan.c
51456@@ -2884,7 +2884,7 @@ static struct net *vxlan_get_link_net(const struct net_device *dev)
51457 return vxlan->net;
51458 }
51459
51460-static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
51461+static struct rtnl_link_ops vxlan_link_ops = {
51462 .kind = "vxlan",
51463 .maxtype = IFLA_VXLAN_MAX,
51464 .policy = vxlan_policy,
51465@@ -2932,7 +2932,7 @@ static int vxlan_lowerdev_event(struct notifier_block *unused,
51466 return NOTIFY_DONE;
51467 }
51468
51469-static struct notifier_block vxlan_notifier_block __read_mostly = {
51470+static struct notifier_block vxlan_notifier_block = {
51471 .notifier_call = vxlan_lowerdev_event,
51472 };
51473
51474diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
51475index 5920c99..ff2e4a5 100644
51476--- a/drivers/net/wan/lmc/lmc_media.c
51477+++ b/drivers/net/wan/lmc/lmc_media.c
51478@@ -95,62 +95,63 @@ static inline void write_av9110_bit (lmc_softc_t *, int);
51479 static void write_av9110(lmc_softc_t *, u32, u32, u32, u32, u32);
51480
51481 lmc_media_t lmc_ds3_media = {
51482- lmc_ds3_init, /* special media init stuff */
51483- lmc_ds3_default, /* reset to default state */
51484- lmc_ds3_set_status, /* reset status to state provided */
51485- lmc_dummy_set_1, /* set clock source */
51486- lmc_dummy_set2_1, /* set line speed */
51487- lmc_ds3_set_100ft, /* set cable length */
51488- lmc_ds3_set_scram, /* set scrambler */
51489- lmc_ds3_get_link_status, /* get link status */
51490- lmc_dummy_set_1, /* set link status */
51491- lmc_ds3_set_crc_length, /* set CRC length */
51492- lmc_dummy_set_1, /* set T1 or E1 circuit type */
51493- lmc_ds3_watchdog
51494+ .init = lmc_ds3_init, /* special media init stuff */
51495+ .defaults = lmc_ds3_default, /* reset to default state */
51496+ .set_status = lmc_ds3_set_status, /* reset status to state provided */
51497+ .set_clock_source = lmc_dummy_set_1, /* set clock source */
51498+ .set_speed = lmc_dummy_set2_1, /* set line speed */
51499+ .set_cable_length = lmc_ds3_set_100ft, /* set cable length */
51500+ .set_scrambler = lmc_ds3_set_scram, /* set scrambler */
51501+ .get_link_status = lmc_ds3_get_link_status, /* get link status */
51502+ .set_link_status = lmc_dummy_set_1, /* set link status */
51503+ .set_crc_length = lmc_ds3_set_crc_length, /* set CRC length */
51504+ .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
51505+ .watchdog = lmc_ds3_watchdog
51506 };
51507
51508 lmc_media_t lmc_hssi_media = {
51509- lmc_hssi_init, /* special media init stuff */
51510- lmc_hssi_default, /* reset to default state */
51511- lmc_hssi_set_status, /* reset status to state provided */
51512- lmc_hssi_set_clock, /* set clock source */
51513- lmc_dummy_set2_1, /* set line speed */
51514- lmc_dummy_set_1, /* set cable length */
51515- lmc_dummy_set_1, /* set scrambler */
51516- lmc_hssi_get_link_status, /* get link status */
51517- lmc_hssi_set_link_status, /* set link status */
51518- lmc_hssi_set_crc_length, /* set CRC length */
51519- lmc_dummy_set_1, /* set T1 or E1 circuit type */
51520- lmc_hssi_watchdog
51521+ .init = lmc_hssi_init, /* special media init stuff */
51522+ .defaults = lmc_hssi_default, /* reset to default state */
51523+ .set_status = lmc_hssi_set_status, /* reset status to state provided */
51524+ .set_clock_source = lmc_hssi_set_clock, /* set clock source */
51525+ .set_speed = lmc_dummy_set2_1, /* set line speed */
51526+ .set_cable_length = lmc_dummy_set_1, /* set cable length */
51527+ .set_scrambler = lmc_dummy_set_1, /* set scrambler */
51528+ .get_link_status = lmc_hssi_get_link_status, /* get link status */
51529+ .set_link_status = lmc_hssi_set_link_status, /* set link status */
51530+ .set_crc_length = lmc_hssi_set_crc_length, /* set CRC length */
51531+ .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
51532+ .watchdog = lmc_hssi_watchdog
51533 };
51534
51535-lmc_media_t lmc_ssi_media = { lmc_ssi_init, /* special media init stuff */
51536- lmc_ssi_default, /* reset to default state */
51537- lmc_ssi_set_status, /* reset status to state provided */
51538- lmc_ssi_set_clock, /* set clock source */
51539- lmc_ssi_set_speed, /* set line speed */
51540- lmc_dummy_set_1, /* set cable length */
51541- lmc_dummy_set_1, /* set scrambler */
51542- lmc_ssi_get_link_status, /* get link status */
51543- lmc_ssi_set_link_status, /* set link status */
51544- lmc_ssi_set_crc_length, /* set CRC length */
51545- lmc_dummy_set_1, /* set T1 or E1 circuit type */
51546- lmc_ssi_watchdog
51547+lmc_media_t lmc_ssi_media = {
51548+ .init = lmc_ssi_init, /* special media init stuff */
51549+ .defaults = lmc_ssi_default, /* reset to default state */
51550+ .set_status = lmc_ssi_set_status, /* reset status to state provided */
51551+ .set_clock_source = lmc_ssi_set_clock, /* set clock source */
51552+ .set_speed = lmc_ssi_set_speed, /* set line speed */
51553+ .set_cable_length = lmc_dummy_set_1, /* set cable length */
51554+ .set_scrambler = lmc_dummy_set_1, /* set scrambler */
51555+ .get_link_status = lmc_ssi_get_link_status, /* get link status */
51556+ .set_link_status = lmc_ssi_set_link_status, /* set link status */
51557+ .set_crc_length = lmc_ssi_set_crc_length, /* set CRC length */
51558+ .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
51559+ .watchdog = lmc_ssi_watchdog
51560 };
51561
51562 lmc_media_t lmc_t1_media = {
51563- lmc_t1_init, /* special media init stuff */
51564- lmc_t1_default, /* reset to default state */
51565- lmc_t1_set_status, /* reset status to state provided */
51566- lmc_t1_set_clock, /* set clock source */
51567- lmc_dummy_set2_1, /* set line speed */
51568- lmc_dummy_set_1, /* set cable length */
51569- lmc_dummy_set_1, /* set scrambler */
51570- lmc_t1_get_link_status, /* get link status */
51571- lmc_dummy_set_1, /* set link status */
51572- lmc_t1_set_crc_length, /* set CRC length */
51573- lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */
51574- lmc_t1_watchdog
51575+ .init = lmc_t1_init, /* special media init stuff */
51576+ .defaults = lmc_t1_default, /* reset to default state */
51577+ .set_status = lmc_t1_set_status, /* reset status to state provided */
51578+ .set_clock_source = lmc_t1_set_clock, /* set clock source */
51579+ .set_speed = lmc_dummy_set2_1, /* set line speed */
51580+ .set_cable_length = lmc_dummy_set_1, /* set cable length */
51581+ .set_scrambler = lmc_dummy_set_1, /* set scrambler */
51582+ .get_link_status = lmc_t1_get_link_status, /* get link status */
51583+ .set_link_status = lmc_dummy_set_1, /* set link status */
51584+ .set_crc_length = lmc_t1_set_crc_length, /* set CRC length */
51585+ .set_circuit_type = lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */
51586+ .watchdog = lmc_t1_watchdog
51587 };
51588
51589 static void
51590diff --git a/drivers/net/wan/z85230.c b/drivers/net/wan/z85230.c
51591index 2f0bd69..e46ed7b 100644
51592--- a/drivers/net/wan/z85230.c
51593+++ b/drivers/net/wan/z85230.c
51594@@ -485,9 +485,9 @@ static void z8530_status(struct z8530_channel *chan)
51595
51596 struct z8530_irqhandler z8530_sync =
51597 {
51598- z8530_rx,
51599- z8530_tx,
51600- z8530_status
51601+ .rx = z8530_rx,
51602+ .tx = z8530_tx,
51603+ .status = z8530_status
51604 };
51605
51606 EXPORT_SYMBOL(z8530_sync);
51607@@ -605,15 +605,15 @@ static void z8530_dma_status(struct z8530_channel *chan)
51608 }
51609
51610 static struct z8530_irqhandler z8530_dma_sync = {
51611- z8530_dma_rx,
51612- z8530_dma_tx,
51613- z8530_dma_status
51614+ .rx = z8530_dma_rx,
51615+ .tx = z8530_dma_tx,
51616+ .status = z8530_dma_status
51617 };
51618
51619 static struct z8530_irqhandler z8530_txdma_sync = {
51620- z8530_rx,
51621- z8530_dma_tx,
51622- z8530_dma_status
51623+ .rx = z8530_rx,
51624+ .tx = z8530_dma_tx,
51625+ .status = z8530_dma_status
51626 };
51627
51628 /**
51629@@ -680,9 +680,9 @@ static void z8530_status_clear(struct z8530_channel *chan)
51630
51631 struct z8530_irqhandler z8530_nop=
51632 {
51633- z8530_rx_clear,
51634- z8530_tx_clear,
51635- z8530_status_clear
51636+ .rx = z8530_rx_clear,
51637+ .tx = z8530_tx_clear,
51638+ .status = z8530_status_clear
51639 };
51640
51641
51642diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
51643index 0b60295..b8bfa5b 100644
51644--- a/drivers/net/wimax/i2400m/rx.c
51645+++ b/drivers/net/wimax/i2400m/rx.c
51646@@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
51647 if (i2400m->rx_roq == NULL)
51648 goto error_roq_alloc;
51649
51650- rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
51651+ rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
51652 GFP_KERNEL);
51653 if (rd == NULL) {
51654 result = -ENOMEM;
51655diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
51656index d0c97c2..108f59b 100644
51657--- a/drivers/net/wireless/airo.c
51658+++ b/drivers/net/wireless/airo.c
51659@@ -7846,7 +7846,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
51660 struct airo_info *ai = dev->ml_priv;
51661 int ridcode;
51662 int enabled;
51663- static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
51664+ int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
51665 unsigned char *iobuf;
51666
51667 /* Only super-user can write RIDs */
51668diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
51669index dab2513..4c4b65d 100644
51670--- a/drivers/net/wireless/at76c50x-usb.c
51671+++ b/drivers/net/wireless/at76c50x-usb.c
51672@@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
51673 }
51674
51675 /* Convert timeout from the DFU status to jiffies */
51676-static inline unsigned long at76_get_timeout(struct dfu_status *s)
51677+static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
51678 {
51679 return msecs_to_jiffies((s->poll_timeout[2] << 16)
51680 | (s->poll_timeout[1] << 8)
51681diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c
51682index e508c65..fb0dbae 100644
51683--- a/drivers/net/wireless/ath/ath10k/ce.c
51684+++ b/drivers/net/wireless/ath/ath10k/ce.c
51685@@ -896,7 +896,7 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar,
51686 return 0;
51687 }
51688
51689-static struct ath10k_ce_ring *
51690+static struct ath10k_ce_ring * __intentional_overflow(-1)
51691 ath10k_ce_alloc_src_ring(struct ath10k *ar, unsigned int ce_id,
51692 const struct ce_attr *attr)
51693 {
51694diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
51695index 32d9ff1..0952b33 100644
51696--- a/drivers/net/wireless/ath/ath10k/htc.c
51697+++ b/drivers/net/wireless/ath/ath10k/htc.c
51698@@ -841,7 +841,10 @@ int ath10k_htc_start(struct ath10k_htc *htc)
51699 /* registered target arrival callback from the HIF layer */
51700 int ath10k_htc_init(struct ath10k *ar)
51701 {
51702- struct ath10k_hif_cb htc_callbacks;
51703+ static struct ath10k_hif_cb htc_callbacks = {
51704+ .rx_completion = ath10k_htc_rx_completion_handler,
51705+ .tx_completion = ath10k_htc_tx_completion_handler,
51706+ };
51707 struct ath10k_htc_ep *ep = NULL;
51708 struct ath10k_htc *htc = &ar->htc;
51709
51710@@ -850,8 +853,6 @@ int ath10k_htc_init(struct ath10k *ar)
51711 ath10k_htc_reset_endpoint_states(htc);
51712
51713 /* setup HIF layer callbacks */
51714- htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
51715- htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
51716 htc->ar = ar;
51717
51718 /* Get HIF default pipe for HTC message exchange */
51719diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
51720index 527179c..a890150 100644
51721--- a/drivers/net/wireless/ath/ath10k/htc.h
51722+++ b/drivers/net/wireless/ath/ath10k/htc.h
51723@@ -270,13 +270,13 @@ enum ath10k_htc_ep_id {
51724
51725 struct ath10k_htc_ops {
51726 void (*target_send_suspend_complete)(struct ath10k *ar);
51727-};
51728+} __no_const;
51729
51730 struct ath10k_htc_ep_ops {
51731 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
51732 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
51733 void (*ep_tx_credits)(struct ath10k *);
51734-};
51735+} __no_const;
51736
51737 /* service connection information */
51738 struct ath10k_htc_svc_conn_req {
51739diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
51740index fee0cad..a7a3b63 100644
51741--- a/drivers/net/wireless/ath/ath9k/Kconfig
51742+++ b/drivers/net/wireless/ath/ath9k/Kconfig
51743@@ -3,7 +3,6 @@ config ATH9K_HW
51744 config ATH9K_COMMON
51745 tristate
51746 select ATH_COMMON
51747- select DEBUG_FS
51748 select RELAY
51749 config ATH9K_DFS_DEBUGFS
51750 def_bool y
51751diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
51752index f816909..e56cd8b 100644
51753--- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
51754+++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
51755@@ -220,8 +220,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51756 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
51757 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
51758
51759- ACCESS_ONCE(ads->ds_link) = i->link;
51760- ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
51761+ ACCESS_ONCE_RW(ads->ds_link) = i->link;
51762+ ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
51763
51764 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
51765 ctl6 = SM(i->keytype, AR_EncrType);
51766@@ -235,26 +235,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51767
51768 if ((i->is_first || i->is_last) &&
51769 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
51770- ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
51771+ ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
51772 | set11nTries(i->rates, 1)
51773 | set11nTries(i->rates, 2)
51774 | set11nTries(i->rates, 3)
51775 | (i->dur_update ? AR_DurUpdateEna : 0)
51776 | SM(0, AR_BurstDur);
51777
51778- ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
51779+ ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
51780 | set11nRate(i->rates, 1)
51781 | set11nRate(i->rates, 2)
51782 | set11nRate(i->rates, 3);
51783 } else {
51784- ACCESS_ONCE(ads->ds_ctl2) = 0;
51785- ACCESS_ONCE(ads->ds_ctl3) = 0;
51786+ ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
51787+ ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
51788 }
51789
51790 if (!i->is_first) {
51791- ACCESS_ONCE(ads->ds_ctl0) = 0;
51792- ACCESS_ONCE(ads->ds_ctl1) = ctl1;
51793- ACCESS_ONCE(ads->ds_ctl6) = ctl6;
51794+ ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
51795+ ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
51796+ ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
51797 return;
51798 }
51799
51800@@ -279,7 +279,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51801 break;
51802 }
51803
51804- ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
51805+ ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
51806 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
51807 | SM(i->txpower[0], AR_XmitPower0)
51808 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
51809@@ -289,27 +289,27 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51810 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
51811 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
51812
51813- ACCESS_ONCE(ads->ds_ctl1) = ctl1;
51814- ACCESS_ONCE(ads->ds_ctl6) = ctl6;
51815+ ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
51816+ ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
51817
51818 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
51819 return;
51820
51821- ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
51822+ ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
51823 | set11nPktDurRTSCTS(i->rates, 1);
51824
51825- ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
51826+ ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
51827 | set11nPktDurRTSCTS(i->rates, 3);
51828
51829- ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
51830+ ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
51831 | set11nRateFlags(i->rates, 1)
51832 | set11nRateFlags(i->rates, 2)
51833 | set11nRateFlags(i->rates, 3)
51834 | SM(i->rtscts_rate, AR_RTSCTSRate);
51835
51836- ACCESS_ONCE(ads->ds_ctl9) = SM(i->txpower[1], AR_XmitPower1);
51837- ACCESS_ONCE(ads->ds_ctl10) = SM(i->txpower[2], AR_XmitPower2);
51838- ACCESS_ONCE(ads->ds_ctl11) = SM(i->txpower[3], AR_XmitPower3);
51839+ ACCESS_ONCE_RW(ads->ds_ctl9) = SM(i->txpower[1], AR_XmitPower1);
51840+ ACCESS_ONCE_RW(ads->ds_ctl10) = SM(i->txpower[2], AR_XmitPower2);
51841+ ACCESS_ONCE_RW(ads->ds_ctl11) = SM(i->txpower[3], AR_XmitPower3);
51842 }
51843
51844 static int ar9002_hw_proc_txdesc(struct ath_hw *ah, void *ds,
51845diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
51846index da84b70..83e4978 100644
51847--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
51848+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
51849@@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51850 (i->qcu << AR_TxQcuNum_S) | desc_len;
51851
51852 checksum += val;
51853- ACCESS_ONCE(ads->info) = val;
51854+ ACCESS_ONCE_RW(ads->info) = val;
51855
51856 checksum += i->link;
51857- ACCESS_ONCE(ads->link) = i->link;
51858+ ACCESS_ONCE_RW(ads->link) = i->link;
51859
51860 checksum += i->buf_addr[0];
51861- ACCESS_ONCE(ads->data0) = i->buf_addr[0];
51862+ ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
51863 checksum += i->buf_addr[1];
51864- ACCESS_ONCE(ads->data1) = i->buf_addr[1];
51865+ ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
51866 checksum += i->buf_addr[2];
51867- ACCESS_ONCE(ads->data2) = i->buf_addr[2];
51868+ ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
51869 checksum += i->buf_addr[3];
51870- ACCESS_ONCE(ads->data3) = i->buf_addr[3];
51871+ ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
51872
51873 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
51874- ACCESS_ONCE(ads->ctl3) = val;
51875+ ACCESS_ONCE_RW(ads->ctl3) = val;
51876 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
51877- ACCESS_ONCE(ads->ctl5) = val;
51878+ ACCESS_ONCE_RW(ads->ctl5) = val;
51879 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
51880- ACCESS_ONCE(ads->ctl7) = val;
51881+ ACCESS_ONCE_RW(ads->ctl7) = val;
51882 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
51883- ACCESS_ONCE(ads->ctl9) = val;
51884+ ACCESS_ONCE_RW(ads->ctl9) = val;
51885
51886 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
51887- ACCESS_ONCE(ads->ctl10) = checksum;
51888+ ACCESS_ONCE_RW(ads->ctl10) = checksum;
51889
51890 if (i->is_first || i->is_last) {
51891- ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
51892+ ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
51893 | set11nTries(i->rates, 1)
51894 | set11nTries(i->rates, 2)
51895 | set11nTries(i->rates, 3)
51896 | (i->dur_update ? AR_DurUpdateEna : 0)
51897 | SM(0, AR_BurstDur);
51898
51899- ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
51900+ ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
51901 | set11nRate(i->rates, 1)
51902 | set11nRate(i->rates, 2)
51903 | set11nRate(i->rates, 3);
51904 } else {
51905- ACCESS_ONCE(ads->ctl13) = 0;
51906- ACCESS_ONCE(ads->ctl14) = 0;
51907+ ACCESS_ONCE_RW(ads->ctl13) = 0;
51908+ ACCESS_ONCE_RW(ads->ctl14) = 0;
51909 }
51910
51911 ads->ctl20 = 0;
51912@@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51913
51914 ctl17 = SM(i->keytype, AR_EncrType);
51915 if (!i->is_first) {
51916- ACCESS_ONCE(ads->ctl11) = 0;
51917- ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
51918- ACCESS_ONCE(ads->ctl15) = 0;
51919- ACCESS_ONCE(ads->ctl16) = 0;
51920- ACCESS_ONCE(ads->ctl17) = ctl17;
51921- ACCESS_ONCE(ads->ctl18) = 0;
51922- ACCESS_ONCE(ads->ctl19) = 0;
51923+ ACCESS_ONCE_RW(ads->ctl11) = 0;
51924+ ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
51925+ ACCESS_ONCE_RW(ads->ctl15) = 0;
51926+ ACCESS_ONCE_RW(ads->ctl16) = 0;
51927+ ACCESS_ONCE_RW(ads->ctl17) = ctl17;
51928+ ACCESS_ONCE_RW(ads->ctl18) = 0;
51929+ ACCESS_ONCE_RW(ads->ctl19) = 0;
51930 return;
51931 }
51932
51933- ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
51934+ ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
51935 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
51936 | SM(i->txpower[0], AR_XmitPower0)
51937 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
51938@@ -135,26 +135,26 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51939 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
51940 ctl12 |= SM(val, AR_PAPRDChainMask);
51941
51942- ACCESS_ONCE(ads->ctl12) = ctl12;
51943- ACCESS_ONCE(ads->ctl17) = ctl17;
51944+ ACCESS_ONCE_RW(ads->ctl12) = ctl12;
51945+ ACCESS_ONCE_RW(ads->ctl17) = ctl17;
51946
51947- ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
51948+ ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
51949 | set11nPktDurRTSCTS(i->rates, 1);
51950
51951- ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
51952+ ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
51953 | set11nPktDurRTSCTS(i->rates, 3);
51954
51955- ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
51956+ ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
51957 | set11nRateFlags(i->rates, 1)
51958 | set11nRateFlags(i->rates, 2)
51959 | set11nRateFlags(i->rates, 3)
51960 | SM(i->rtscts_rate, AR_RTSCTSRate);
51961
51962- ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
51963+ ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
51964
51965- ACCESS_ONCE(ads->ctl20) = SM(i->txpower[1], AR_XmitPower1);
51966- ACCESS_ONCE(ads->ctl21) = SM(i->txpower[2], AR_XmitPower2);
51967- ACCESS_ONCE(ads->ctl22) = SM(i->txpower[3], AR_XmitPower3);
51968+ ACCESS_ONCE_RW(ads->ctl20) = SM(i->txpower[1], AR_XmitPower1);
51969+ ACCESS_ONCE_RW(ads->ctl21) = SM(i->txpower[2], AR_XmitPower2);
51970+ ACCESS_ONCE_RW(ads->ctl22) = SM(i->txpower[3], AR_XmitPower3);
51971 }
51972
51973 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
51974diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
51975index e8454db..c7b26fe 100644
51976--- a/drivers/net/wireless/ath/ath9k/hw.h
51977+++ b/drivers/net/wireless/ath/ath9k/hw.h
51978@@ -671,7 +671,7 @@ struct ath_hw_private_ops {
51979 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
51980 bool (*is_aic_enabled)(struct ath_hw *ah);
51981 #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
51982-};
51983+} __no_const;
51984
51985 /**
51986 * struct ath_spec_scan - parameters for Atheros spectral scan
51987@@ -747,7 +747,7 @@ struct ath_hw_ops {
51988 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
51989 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
51990 #endif
51991-};
51992+} __no_const;
51993
51994 struct ath_nf_limits {
51995 s16 max;
51996diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
51997index cfd45cb..6de2be6 100644
51998--- a/drivers/net/wireless/ath/ath9k/main.c
51999+++ b/drivers/net/wireless/ath/ath9k/main.c
52000@@ -2574,16 +2574,18 @@ void ath9k_fill_chanctx_ops(void)
52001 if (!ath9k_is_chanctx_enabled())
52002 return;
52003
52004- ath9k_ops.hw_scan = ath9k_hw_scan;
52005- ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan;
52006- ath9k_ops.remain_on_channel = ath9k_remain_on_channel;
52007- ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel;
52008- ath9k_ops.add_chanctx = ath9k_add_chanctx;
52009- ath9k_ops.remove_chanctx = ath9k_remove_chanctx;
52010- ath9k_ops.change_chanctx = ath9k_change_chanctx;
52011- ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx;
52012- ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx;
52013- ath9k_ops.mgd_prepare_tx = ath9k_mgd_prepare_tx;
52014+ pax_open_kernel();
52015+ *(void **)&ath9k_ops.hw_scan = ath9k_hw_scan;
52016+ *(void **)&ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan;
52017+ *(void **)&ath9k_ops.remain_on_channel = ath9k_remain_on_channel;
52018+ *(void **)&ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel;
52019+ *(void **)&ath9k_ops.add_chanctx = ath9k_add_chanctx;
52020+ *(void **)&ath9k_ops.remove_chanctx = ath9k_remove_chanctx;
52021+ *(void **)&ath9k_ops.change_chanctx = ath9k_change_chanctx;
52022+ *(void **)&ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx;
52023+ *(void **)&ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx;
52024+ *(void **)&ath9k_ops.mgd_prepare_tx = ath9k_mgd_prepare_tx;
52025+ pax_close_kernel();
52026 }
52027
52028 #endif
52029diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
52030index 058a9f2..d5cb1ba 100644
52031--- a/drivers/net/wireless/b43/phy_lp.c
52032+++ b/drivers/net/wireless/b43/phy_lp.c
52033@@ -2502,7 +2502,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
52034 {
52035 struct ssb_bus *bus = dev->dev->sdev->bus;
52036
52037- static const struct b206x_channel *chandata = NULL;
52038+ const struct b206x_channel *chandata = NULL;
52039 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
52040 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
52041 u16 old_comm15, scale;
52042diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
52043index 7f4cb69..16c0825 100644
52044--- a/drivers/net/wireless/iwlegacy/3945-mac.c
52045+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
52046@@ -3633,7 +3633,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
52047 */
52048 if (il3945_mod_params.disable_hw_scan) {
52049 D_INFO("Disabling hw_scan\n");
52050- il3945_mac_ops.hw_scan = NULL;
52051+ pax_open_kernel();
52052+ *(void **)&il3945_mac_ops.hw_scan = NULL;
52053+ pax_close_kernel();
52054 }
52055
52056 D_INFO("*** LOAD DRIVER ***\n");
52057diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
52058index 0ffb6ff..c0b7f0e 100644
52059--- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
52060+++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
52061@@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
52062 {
52063 struct iwl_priv *priv = file->private_data;
52064 char buf[64];
52065- int buf_size;
52066+ size_t buf_size;
52067 u32 offset, len;
52068
52069 memset(buf, 0, sizeof(buf));
52070@@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
52071 struct iwl_priv *priv = file->private_data;
52072
52073 char buf[8];
52074- int buf_size;
52075+ size_t buf_size;
52076 u32 reset_flag;
52077
52078 memset(buf, 0, sizeof(buf));
52079@@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
52080 {
52081 struct iwl_priv *priv = file->private_data;
52082 char buf[8];
52083- int buf_size;
52084+ size_t buf_size;
52085 int ht40;
52086
52087 memset(buf, 0, sizeof(buf));
52088@@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
52089 {
52090 struct iwl_priv *priv = file->private_data;
52091 char buf[8];
52092- int buf_size;
52093+ size_t buf_size;
52094 int value;
52095
52096 memset(buf, 0, sizeof(buf));
52097@@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
52098 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
52099 DEBUGFS_READ_FILE_OPS(current_sleep_command);
52100
52101-static const char *fmt_value = " %-30s %10u\n";
52102-static const char *fmt_hex = " %-30s 0x%02X\n";
52103-static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
52104-static const char *fmt_header =
52105+static const char fmt_value[] = " %-30s %10u\n";
52106+static const char fmt_hex[] = " %-30s 0x%02X\n";
52107+static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
52108+static const char fmt_header[] =
52109 "%-32s current cumulative delta max\n";
52110
52111 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
52112@@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
52113 {
52114 struct iwl_priv *priv = file->private_data;
52115 char buf[8];
52116- int buf_size;
52117+ size_t buf_size;
52118 int clear;
52119
52120 memset(buf, 0, sizeof(buf));
52121@@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
52122 {
52123 struct iwl_priv *priv = file->private_data;
52124 char buf[8];
52125- int buf_size;
52126+ size_t buf_size;
52127 int trace;
52128
52129 memset(buf, 0, sizeof(buf));
52130@@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
52131 {
52132 struct iwl_priv *priv = file->private_data;
52133 char buf[8];
52134- int buf_size;
52135+ size_t buf_size;
52136 int missed;
52137
52138 memset(buf, 0, sizeof(buf));
52139@@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
52140
52141 struct iwl_priv *priv = file->private_data;
52142 char buf[8];
52143- int buf_size;
52144+ size_t buf_size;
52145 int plcp;
52146
52147 memset(buf, 0, sizeof(buf));
52148@@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
52149
52150 struct iwl_priv *priv = file->private_data;
52151 char buf[8];
52152- int buf_size;
52153+ size_t buf_size;
52154 int flush;
52155
52156 memset(buf, 0, sizeof(buf));
52157@@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
52158
52159 struct iwl_priv *priv = file->private_data;
52160 char buf[8];
52161- int buf_size;
52162+ size_t buf_size;
52163 int rts;
52164
52165 if (!priv->cfg->ht_params)
52166@@ -2204,7 +2204,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
52167 {
52168 struct iwl_priv *priv = file->private_data;
52169 char buf[8];
52170- int buf_size;
52171+ size_t buf_size;
52172
52173 memset(buf, 0, sizeof(buf));
52174 buf_size = min(count, sizeof(buf) - 1);
52175@@ -2238,7 +2238,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
52176 struct iwl_priv *priv = file->private_data;
52177 u32 event_log_flag;
52178 char buf[8];
52179- int buf_size;
52180+ size_t buf_size;
52181
52182 /* check that the interface is up */
52183 if (!iwl_is_ready(priv))
52184@@ -2292,7 +2292,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
52185 struct iwl_priv *priv = file->private_data;
52186 char buf[8];
52187 u32 calib_disabled;
52188- int buf_size;
52189+ size_t buf_size;
52190
52191 memset(buf, 0, sizeof(buf));
52192 buf_size = min(count, sizeof(buf) - 1);
52193diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
52194index 9e144e7..2f5511a 100644
52195--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
52196+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
52197@@ -1950,7 +1950,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
52198 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
52199
52200 char buf[8];
52201- int buf_size;
52202+ size_t buf_size;
52203 u32 reset_flag;
52204
52205 memset(buf, 0, sizeof(buf));
52206@@ -1971,7 +1971,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
52207 {
52208 struct iwl_trans *trans = file->private_data;
52209 char buf[8];
52210- int buf_size;
52211+ size_t buf_size;
52212 int csr;
52213
52214 memset(buf, 0, sizeof(buf));
52215diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
52216index 99e873d..0d9aab2 100644
52217--- a/drivers/net/wireless/mac80211_hwsim.c
52218+++ b/drivers/net/wireless/mac80211_hwsim.c
52219@@ -3148,20 +3148,20 @@ static int __init init_mac80211_hwsim(void)
52220 if (channels < 1)
52221 return -EINVAL;
52222
52223- mac80211_hwsim_mchan_ops = mac80211_hwsim_ops;
52224- mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan;
52225- mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
52226- mac80211_hwsim_mchan_ops.sw_scan_start = NULL;
52227- mac80211_hwsim_mchan_ops.sw_scan_complete = NULL;
52228- mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc;
52229- mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
52230- mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx;
52231- mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
52232- mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx;
52233- mac80211_hwsim_mchan_ops.assign_vif_chanctx =
52234- mac80211_hwsim_assign_vif_chanctx;
52235- mac80211_hwsim_mchan_ops.unassign_vif_chanctx =
52236- mac80211_hwsim_unassign_vif_chanctx;
52237+ pax_open_kernel();
52238+ memcpy((void *)&mac80211_hwsim_mchan_ops, &mac80211_hwsim_ops, sizeof mac80211_hwsim_mchan_ops);
52239+ *(void **)&mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan;
52240+ *(void **)&mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
52241+ *(void **)&mac80211_hwsim_mchan_ops.sw_scan_start = NULL;
52242+ *(void **)&mac80211_hwsim_mchan_ops.sw_scan_complete = NULL;
52243+ *(void **)&mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc;
52244+ *(void **)&mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
52245+ *(void **)&mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx;
52246+ *(void **)&mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
52247+ *(void **)&mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx;
52248+ *(void **)&mac80211_hwsim_mchan_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
52249+ *(void **)&mac80211_hwsim_mchan_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
52250+ pax_close_kernel();
52251
52252 spin_lock_init(&hwsim_radio_lock);
52253 INIT_LIST_HEAD(&hwsim_radios);
52254diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
52255index 71a825c..ce7d6c3 100644
52256--- a/drivers/net/wireless/rndis_wlan.c
52257+++ b/drivers/net/wireless/rndis_wlan.c
52258@@ -1236,7 +1236,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
52259
52260 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
52261
52262- if (rts_threshold < 0 || rts_threshold > 2347)
52263+ if (rts_threshold > 2347)
52264 rts_threshold = 2347;
52265
52266 tmp = cpu_to_le32(rts_threshold);
52267diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
52268index 9bb398b..b0cc047 100644
52269--- a/drivers/net/wireless/rt2x00/rt2x00.h
52270+++ b/drivers/net/wireless/rt2x00/rt2x00.h
52271@@ -375,7 +375,7 @@ struct rt2x00_intf {
52272 * for hardware which doesn't support hardware
52273 * sequence counting.
52274 */
52275- atomic_t seqno;
52276+ atomic_unchecked_t seqno;
52277 };
52278
52279 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
52280diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
52281index 68b620b..92ecd9e 100644
52282--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
52283+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
52284@@ -224,9 +224,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
52285 * sequence counter given by mac80211.
52286 */
52287 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
52288- seqno = atomic_add_return(0x10, &intf->seqno);
52289+ seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
52290 else
52291- seqno = atomic_read(&intf->seqno);
52292+ seqno = atomic_read_unchecked(&intf->seqno);
52293
52294 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
52295 hdr->seq_ctrl |= cpu_to_le16(seqno);
52296diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
52297index b661f896..ddf7d2b 100644
52298--- a/drivers/net/wireless/ti/wl1251/sdio.c
52299+++ b/drivers/net/wireless/ti/wl1251/sdio.c
52300@@ -282,13 +282,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
52301
52302 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
52303
52304- wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
52305- wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
52306+ pax_open_kernel();
52307+ *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
52308+ *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
52309+ pax_close_kernel();
52310
52311 wl1251_info("using dedicated interrupt line");
52312 } else {
52313- wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
52314- wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
52315+ pax_open_kernel();
52316+ *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
52317+ *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
52318+ pax_close_kernel();
52319
52320 wl1251_info("using SDIO interrupt");
52321 }
52322diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
52323index af0fe2e..d04986b 100644
52324--- a/drivers/net/wireless/ti/wl12xx/main.c
52325+++ b/drivers/net/wireless/ti/wl12xx/main.c
52326@@ -655,7 +655,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
52327 sizeof(wl->conf.mem));
52328
52329 /* read data preparation is only needed by wl127x */
52330- wl->ops->prepare_read = wl127x_prepare_read;
52331+ pax_open_kernel();
52332+ *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
52333+ pax_close_kernel();
52334
52335 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
52336 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
52337@@ -680,7 +682,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
52338 sizeof(wl->conf.mem));
52339
52340 /* read data preparation is only needed by wl127x */
52341- wl->ops->prepare_read = wl127x_prepare_read;
52342+ pax_open_kernel();
52343+ *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
52344+ pax_close_kernel();
52345
52346 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
52347 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
52348diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
52349index 49aca2c..3b9c10c 100644
52350--- a/drivers/net/wireless/ti/wl18xx/main.c
52351+++ b/drivers/net/wireless/ti/wl18xx/main.c
52352@@ -1952,8 +1952,10 @@ static int wl18xx_setup(struct wl1271 *wl)
52353 }
52354
52355 if (!checksum_param) {
52356- wl18xx_ops.set_rx_csum = NULL;
52357- wl18xx_ops.init_vif = NULL;
52358+ pax_open_kernel();
52359+ *(void **)&wl18xx_ops.set_rx_csum = NULL;
52360+ *(void **)&wl18xx_ops.init_vif = NULL;
52361+ pax_close_kernel();
52362 }
52363
52364 /* Enable 11a Band only if we have 5G antennas */
52365diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
52366index a912dc0..a8225ba 100644
52367--- a/drivers/net/wireless/zd1211rw/zd_usb.c
52368+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
52369@@ -385,7 +385,7 @@ static inline void handle_regs_int(struct urb *urb)
52370 {
52371 struct zd_usb *usb = urb->context;
52372 struct zd_usb_interrupt *intr = &usb->intr;
52373- int len;
52374+ unsigned int len;
52375 u16 int_num;
52376
52377 ZD_ASSERT(in_interrupt());
52378diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
52379index ce2e2cf..f81e500 100644
52380--- a/drivers/nfc/nfcwilink.c
52381+++ b/drivers/nfc/nfcwilink.c
52382@@ -497,7 +497,7 @@ static struct nci_ops nfcwilink_ops = {
52383
52384 static int nfcwilink_probe(struct platform_device *pdev)
52385 {
52386- static struct nfcwilink *drv;
52387+ struct nfcwilink *drv;
52388 int rc;
52389 __u32 protocols;
52390
52391diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
52392index 6e82bc42..ab4145c 100644
52393--- a/drivers/of/fdt.c
52394+++ b/drivers/of/fdt.c
52395@@ -1161,7 +1161,9 @@ static int __init of_fdt_raw_init(void)
52396 pr_warn("fdt: not creating '/sys/firmware/fdt': CRC check failed\n");
52397 return 0;
52398 }
52399- of_fdt_raw_attr.size = fdt_totalsize(initial_boot_params);
52400+ pax_open_kernel();
52401+ *(size_t *)&of_fdt_raw_attr.size = fdt_totalsize(initial_boot_params);
52402+ pax_close_kernel();
52403 return sysfs_create_bin_file(firmware_kobj, &of_fdt_raw_attr);
52404 }
52405 late_initcall(of_fdt_raw_init);
52406diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
52407index 82f7000..d6d0447 100644
52408--- a/drivers/oprofile/buffer_sync.c
52409+++ b/drivers/oprofile/buffer_sync.c
52410@@ -345,7 +345,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
52411 if (cookie == NO_COOKIE)
52412 offset = pc;
52413 if (cookie == INVALID_COOKIE) {
52414- atomic_inc(&oprofile_stats.sample_lost_no_mapping);
52415+ atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
52416 offset = pc;
52417 }
52418 if (cookie != last_cookie) {
52419@@ -389,14 +389,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
52420 /* add userspace sample */
52421
52422 if (!mm) {
52423- atomic_inc(&oprofile_stats.sample_lost_no_mm);
52424+ atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
52425 return 0;
52426 }
52427
52428 cookie = lookup_dcookie(mm, s->eip, &offset);
52429
52430 if (cookie == INVALID_COOKIE) {
52431- atomic_inc(&oprofile_stats.sample_lost_no_mapping);
52432+ atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
52433 return 0;
52434 }
52435
52436@@ -554,7 +554,7 @@ void sync_buffer(int cpu)
52437 /* ignore backtraces if failed to add a sample */
52438 if (state == sb_bt_start) {
52439 state = sb_bt_ignore;
52440- atomic_inc(&oprofile_stats.bt_lost_no_mapping);
52441+ atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
52442 }
52443 }
52444 release_mm(mm);
52445diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
52446index c0cc4e7..44d4e54 100644
52447--- a/drivers/oprofile/event_buffer.c
52448+++ b/drivers/oprofile/event_buffer.c
52449@@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
52450 }
52451
52452 if (buffer_pos == buffer_size) {
52453- atomic_inc(&oprofile_stats.event_lost_overflow);
52454+ atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
52455 return;
52456 }
52457
52458diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
52459index ed2c3ec..deda85a 100644
52460--- a/drivers/oprofile/oprof.c
52461+++ b/drivers/oprofile/oprof.c
52462@@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
52463 if (oprofile_ops.switch_events())
52464 return;
52465
52466- atomic_inc(&oprofile_stats.multiplex_counter);
52467+ atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
52468 start_switch_worker();
52469 }
52470
52471diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
52472index 59659ce..6c860a0 100644
52473--- a/drivers/oprofile/oprofile_stats.c
52474+++ b/drivers/oprofile/oprofile_stats.c
52475@@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
52476 cpu_buf->sample_invalid_eip = 0;
52477 }
52478
52479- atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
52480- atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
52481- atomic_set(&oprofile_stats.event_lost_overflow, 0);
52482- atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
52483- atomic_set(&oprofile_stats.multiplex_counter, 0);
52484+ atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
52485+ atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
52486+ atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
52487+ atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
52488+ atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
52489 }
52490
52491
52492diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
52493index 1fc622b..8c48fc3 100644
52494--- a/drivers/oprofile/oprofile_stats.h
52495+++ b/drivers/oprofile/oprofile_stats.h
52496@@ -13,11 +13,11 @@
52497 #include <linux/atomic.h>
52498
52499 struct oprofile_stat_struct {
52500- atomic_t sample_lost_no_mm;
52501- atomic_t sample_lost_no_mapping;
52502- atomic_t bt_lost_no_mapping;
52503- atomic_t event_lost_overflow;
52504- atomic_t multiplex_counter;
52505+ atomic_unchecked_t sample_lost_no_mm;
52506+ atomic_unchecked_t sample_lost_no_mapping;
52507+ atomic_unchecked_t bt_lost_no_mapping;
52508+ atomic_unchecked_t event_lost_overflow;
52509+ atomic_unchecked_t multiplex_counter;
52510 };
52511
52512 extern struct oprofile_stat_struct oprofile_stats;
52513diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
52514index dd92c5e..dfc04b5 100644
52515--- a/drivers/oprofile/oprofilefs.c
52516+++ b/drivers/oprofile/oprofilefs.c
52517@@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
52518
52519 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
52520 {
52521- atomic_t *val = file->private_data;
52522- return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
52523+ atomic_unchecked_t *val = file->private_data;
52524+ return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
52525 }
52526
52527
52528@@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
52529
52530
52531 int oprofilefs_create_ro_atomic(struct dentry *root,
52532- char const *name, atomic_t *val)
52533+ char const *name, atomic_unchecked_t *val)
52534 {
52535 return __oprofilefs_create_file(root, name,
52536 &atomic_ro_fops, 0444, val);
52537diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
52538index bdef916..88c7dee 100644
52539--- a/drivers/oprofile/timer_int.c
52540+++ b/drivers/oprofile/timer_int.c
52541@@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
52542 return NOTIFY_OK;
52543 }
52544
52545-static struct notifier_block __refdata oprofile_cpu_notifier = {
52546+static struct notifier_block oprofile_cpu_notifier = {
52547 .notifier_call = oprofile_cpu_notify,
52548 };
52549
52550diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
52551index c776333..aa6b325 100644
52552--- a/drivers/parport/procfs.c
52553+++ b/drivers/parport/procfs.c
52554@@ -65,7 +65,7 @@ static int do_active_device(struct ctl_table *table, int write,
52555
52556 *ppos += len;
52557
52558- return copy_to_user(result, buffer, len) ? -EFAULT : 0;
52559+ return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
52560 }
52561
52562 #ifdef CONFIG_PARPORT_1284
52563@@ -107,7 +107,7 @@ static int do_autoprobe(struct ctl_table *table, int write,
52564
52565 *ppos += len;
52566
52567- return copy_to_user (result, buffer, len) ? -EFAULT : 0;
52568+ return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
52569 }
52570 #endif /* IEEE1284.3 support. */
52571
52572diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
52573index ba46e58..90cfc24 100644
52574--- a/drivers/pci/host/pci-host-generic.c
52575+++ b/drivers/pci/host/pci-host-generic.c
52576@@ -26,9 +26,9 @@
52577 #include <linux/platform_device.h>
52578
52579 struct gen_pci_cfg_bus_ops {
52580+ struct pci_ops ops;
52581 u32 bus_shift;
52582- void __iomem *(*map_bus)(struct pci_bus *, unsigned int, int);
52583-};
52584+} __do_const;
52585
52586 struct gen_pci_cfg_windows {
52587 struct resource res;
52588@@ -56,8 +56,12 @@ static void __iomem *gen_pci_map_cfg_bus_cam(struct pci_bus *bus,
52589 }
52590
52591 static struct gen_pci_cfg_bus_ops gen_pci_cfg_cam_bus_ops = {
52592+ .ops = {
52593+ .map_bus = gen_pci_map_cfg_bus_cam,
52594+ .read = pci_generic_config_read,
52595+ .write = pci_generic_config_write,
52596+ },
52597 .bus_shift = 16,
52598- .map_bus = gen_pci_map_cfg_bus_cam,
52599 };
52600
52601 static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus,
52602@@ -72,13 +76,12 @@ static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus,
52603 }
52604
52605 static struct gen_pci_cfg_bus_ops gen_pci_cfg_ecam_bus_ops = {
52606+ .ops = {
52607+ .map_bus = gen_pci_map_cfg_bus_ecam,
52608+ .read = pci_generic_config_read,
52609+ .write = pci_generic_config_write,
52610+ },
52611 .bus_shift = 20,
52612- .map_bus = gen_pci_map_cfg_bus_ecam,
52613-};
52614-
52615-static struct pci_ops gen_pci_ops = {
52616- .read = pci_generic_config_read,
52617- .write = pci_generic_config_write,
52618 };
52619
52620 static const struct of_device_id gen_pci_of_match[] = {
52621@@ -219,7 +222,6 @@ static int gen_pci_probe(struct platform_device *pdev)
52622 .private_data = (void **)&pci,
52623 .setup = gen_pci_setup,
52624 .map_irq = of_irq_parse_and_map_pci,
52625- .ops = &gen_pci_ops,
52626 };
52627
52628 if (!pci)
52629@@ -241,7 +243,7 @@ static int gen_pci_probe(struct platform_device *pdev)
52630
52631 of_id = of_match_node(gen_pci_of_match, np);
52632 pci->cfg.ops = of_id->data;
52633- gen_pci_ops.map_bus = pci->cfg.ops->map_bus;
52634+ hw.ops = &pci->cfg.ops->ops;
52635 pci->host.dev.parent = dev;
52636 INIT_LIST_HEAD(&pci->host.windows);
52637 INIT_LIST_HEAD(&pci->resources);
52638diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
52639index 6ca2399..68d866b 100644
52640--- a/drivers/pci/hotplug/acpiphp_ibm.c
52641+++ b/drivers/pci/hotplug/acpiphp_ibm.c
52642@@ -452,7 +452,9 @@ static int __init ibm_acpiphp_init(void)
52643 goto init_cleanup;
52644 }
52645
52646- ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
52647+ pax_open_kernel();
52648+ *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
52649+ pax_close_kernel();
52650 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
52651
52652 return retval;
52653diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
52654index 66b7bbe..26bee78 100644
52655--- a/drivers/pci/hotplug/cpcihp_generic.c
52656+++ b/drivers/pci/hotplug/cpcihp_generic.c
52657@@ -73,7 +73,6 @@ static u16 port;
52658 static unsigned int enum_bit;
52659 static u8 enum_mask;
52660
52661-static struct cpci_hp_controller_ops generic_hpc_ops;
52662 static struct cpci_hp_controller generic_hpc;
52663
52664 static int __init validate_parameters(void)
52665@@ -139,6 +138,10 @@ static int query_enum(void)
52666 return ((value & enum_mask) == enum_mask);
52667 }
52668
52669+static struct cpci_hp_controller_ops generic_hpc_ops = {
52670+ .query_enum = query_enum,
52671+};
52672+
52673 static int __init cpcihp_generic_init(void)
52674 {
52675 int status;
52676@@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
52677 pci_dev_put(dev);
52678
52679 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
52680- generic_hpc_ops.query_enum = query_enum;
52681 generic_hpc.ops = &generic_hpc_ops;
52682
52683 status = cpci_hp_register_controller(&generic_hpc);
52684diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
52685index 7ecf34e..effed62 100644
52686--- a/drivers/pci/hotplug/cpcihp_zt5550.c
52687+++ b/drivers/pci/hotplug/cpcihp_zt5550.c
52688@@ -59,7 +59,6 @@
52689 /* local variables */
52690 static bool debug;
52691 static bool poll;
52692-static struct cpci_hp_controller_ops zt5550_hpc_ops;
52693 static struct cpci_hp_controller zt5550_hpc;
52694
52695 /* Primary cPCI bus bridge device */
52696@@ -204,6 +203,10 @@ static int zt5550_hc_disable_irq(void)
52697 return 0;
52698 }
52699
52700+static struct cpci_hp_controller_ops zt5550_hpc_ops = {
52701+ .query_enum = zt5550_hc_query_enum,
52702+};
52703+
52704 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
52705 {
52706 int status;
52707@@ -215,16 +218,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
52708 dbg("returned from zt5550_hc_config");
52709
52710 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
52711- zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
52712 zt5550_hpc.ops = &zt5550_hpc_ops;
52713 if (!poll) {
52714 zt5550_hpc.irq = hc_dev->irq;
52715 zt5550_hpc.irq_flags = IRQF_SHARED;
52716 zt5550_hpc.dev_id = hc_dev;
52717
52718- zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
52719- zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
52720- zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
52721+ pax_open_kernel();
52722+ *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
52723+ *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
52724+ *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
52725+ pax_open_kernel();
52726 } else {
52727 info("using ENUM# polling mode");
52728 }
52729diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
52730index 1e08ff8c..3cd145f 100644
52731--- a/drivers/pci/hotplug/cpqphp_nvram.c
52732+++ b/drivers/pci/hotplug/cpqphp_nvram.c
52733@@ -425,8 +425,10 @@ static u32 store_HRT (void __iomem *rom_start)
52734
52735 void compaq_nvram_init (void __iomem *rom_start)
52736 {
52737+#ifndef CONFIG_PAX_KERNEXEC
52738 if (rom_start)
52739 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
52740+#endif
52741
52742 dbg("int15 entry = %p\n", compaq_int15_entry_point);
52743
52744diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
52745index 56d8486..f26113f 100644
52746--- a/drivers/pci/hotplug/pci_hotplug_core.c
52747+++ b/drivers/pci/hotplug/pci_hotplug_core.c
52748@@ -436,8 +436,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
52749 return -EINVAL;
52750 }
52751
52752- slot->ops->owner = owner;
52753- slot->ops->mod_name = mod_name;
52754+ pax_open_kernel();
52755+ *(struct module **)&slot->ops->owner = owner;
52756+ *(const char **)&slot->ops->mod_name = mod_name;
52757+ pax_close_kernel();
52758
52759 mutex_lock(&pci_hp_mutex);
52760 /*
52761diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
52762index 612b21a..9494a5e 100644
52763--- a/drivers/pci/hotplug/pciehp_core.c
52764+++ b/drivers/pci/hotplug/pciehp_core.c
52765@@ -87,7 +87,7 @@ static int init_slot(struct controller *ctrl)
52766 struct slot *slot = ctrl->slot;
52767 struct hotplug_slot *hotplug = NULL;
52768 struct hotplug_slot_info *info = NULL;
52769- struct hotplug_slot_ops *ops = NULL;
52770+ hotplug_slot_ops_no_const *ops = NULL;
52771 char name[SLOT_NAME_SIZE];
52772 int retval = -ENOMEM;
52773
52774diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
52775index f66be86..6cbcabb 100644
52776--- a/drivers/pci/msi.c
52777+++ b/drivers/pci/msi.c
52778@@ -492,8 +492,8 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
52779 {
52780 struct attribute **msi_attrs;
52781 struct attribute *msi_attr;
52782- struct device_attribute *msi_dev_attr;
52783- struct attribute_group *msi_irq_group;
52784+ device_attribute_no_const *msi_dev_attr;
52785+ attribute_group_no_const *msi_irq_group;
52786 const struct attribute_group **msi_irq_groups;
52787 struct msi_desc *entry;
52788 int ret = -ENOMEM;
52789@@ -552,7 +552,7 @@ error_attrs:
52790 count = 0;
52791 msi_attr = msi_attrs[count];
52792 while (msi_attr) {
52793- msi_dev_attr = container_of(msi_attr, struct device_attribute, attr);
52794+ msi_dev_attr = container_of(msi_attr, device_attribute_no_const, attr);
52795 kfree(msi_attr->name);
52796 kfree(msi_dev_attr);
52797 ++count;
52798@@ -1236,12 +1236,14 @@ static void pci_msi_domain_update_dom_ops(struct msi_domain_info *info)
52799 if (ops == NULL) {
52800 info->ops = &pci_msi_domain_ops_default;
52801 } else {
52802+ pax_open_kernel();
52803 if (ops->set_desc == NULL)
52804- ops->set_desc = pci_msi_domain_set_desc;
52805+ *(void **)&ops->set_desc = pci_msi_domain_set_desc;
52806 if (ops->msi_check == NULL)
52807- ops->msi_check = pci_msi_domain_check_cap;
52808+ *(void **)&ops->msi_check = pci_msi_domain_check_cap;
52809 if (ops->handle_error == NULL)
52810- ops->handle_error = pci_msi_domain_handle_error;
52811+ *(void **)&ops->handle_error = pci_msi_domain_handle_error;
52812+ pax_close_kernel();
52813 }
52814 }
52815
52816@@ -1250,8 +1252,11 @@ static void pci_msi_domain_update_chip_ops(struct msi_domain_info *info)
52817 struct irq_chip *chip = info->chip;
52818
52819 BUG_ON(!chip);
52820- if (!chip->irq_write_msi_msg)
52821- chip->irq_write_msi_msg = pci_msi_domain_write_msg;
52822+ if (!chip->irq_write_msi_msg) {
52823+ pax_open_kernel();
52824+ *(void **)&chip->irq_write_msi_msg = pci_msi_domain_write_msg;
52825+ pax_close_kernel();
52826+ }
52827 }
52828
52829 /**
52830diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
52831index 312f23a..d21181c 100644
52832--- a/drivers/pci/pci-sysfs.c
52833+++ b/drivers/pci/pci-sysfs.c
52834@@ -1140,7 +1140,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
52835 {
52836 /* allocate attribute structure, piggyback attribute name */
52837 int name_len = write_combine ? 13 : 10;
52838- struct bin_attribute *res_attr;
52839+ bin_attribute_no_const *res_attr;
52840 int retval;
52841
52842 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
52843@@ -1317,7 +1317,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
52844 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
52845 {
52846 int retval;
52847- struct bin_attribute *attr;
52848+ bin_attribute_no_const *attr;
52849
52850 /* If the device has VPD, try to expose it in sysfs. */
52851 if (dev->vpd) {
52852@@ -1364,7 +1364,7 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
52853 {
52854 int retval;
52855 int rom_size = 0;
52856- struct bin_attribute *attr;
52857+ bin_attribute_no_const *attr;
52858
52859 if (!sysfs_initialized)
52860 return -EACCES;
52861diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
52862index 4ff0ff1..e309fb0 100644
52863--- a/drivers/pci/pci.h
52864+++ b/drivers/pci/pci.h
52865@@ -99,7 +99,7 @@ struct pci_vpd_ops {
52866 struct pci_vpd {
52867 unsigned int len;
52868 const struct pci_vpd_ops *ops;
52869- struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
52870+ bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
52871 };
52872
52873 int pci_vpd_pci22_init(struct pci_dev *dev);
52874diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
52875index 317e355..21f7b91 100644
52876--- a/drivers/pci/pcie/aspm.c
52877+++ b/drivers/pci/pcie/aspm.c
52878@@ -27,9 +27,9 @@
52879 #define MODULE_PARAM_PREFIX "pcie_aspm."
52880
52881 /* Note: those are not register definitions */
52882-#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
52883-#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
52884-#define ASPM_STATE_L1 (4) /* L1 state */
52885+#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
52886+#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
52887+#define ASPM_STATE_L1 (4U) /* L1 state */
52888 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
52889 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
52890
52891diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
52892index be35da2..ec16cdb 100644
52893--- a/drivers/pci/pcie/portdrv_pci.c
52894+++ b/drivers/pci/pcie/portdrv_pci.c
52895@@ -324,7 +324,7 @@ static int __init dmi_pcie_pme_disable_msi(const struct dmi_system_id *d)
52896 return 0;
52897 }
52898
52899-static struct dmi_system_id __initdata pcie_portdrv_dmi_table[] = {
52900+static const struct dmi_system_id __initconst pcie_portdrv_dmi_table[] = {
52901 /*
52902 * Boxes that should not use MSI for PCIe PME signaling.
52903 */
52904diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
52905index f6ae0d0..af897bc 100644
52906--- a/drivers/pci/probe.c
52907+++ b/drivers/pci/probe.c
52908@@ -176,7 +176,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
52909 u16 orig_cmd;
52910 struct pci_bus_region region, inverted_region;
52911
52912- mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
52913+ mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
52914
52915 /* No printks while decoding is disabled! */
52916 if (!dev->mmio_always_on) {
52917diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
52918index 3f155e7..0f4b1f0 100644
52919--- a/drivers/pci/proc.c
52920+++ b/drivers/pci/proc.c
52921@@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
52922 static int __init pci_proc_init(void)
52923 {
52924 struct pci_dev *dev = NULL;
52925+
52926+#ifdef CONFIG_GRKERNSEC_PROC_ADD
52927+#ifdef CONFIG_GRKERNSEC_PROC_USER
52928+ proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
52929+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
52930+ proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
52931+#endif
52932+#else
52933 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
52934+#endif
52935 proc_create("devices", 0, proc_bus_pci_dir,
52936 &proc_bus_pci_dev_operations);
52937 proc_initialized = 1;
52938diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
52939index 2deb130..8194e13 100644
52940--- a/drivers/pinctrl/pinctrl-at91.c
52941+++ b/drivers/pinctrl/pinctrl-at91.c
52942@@ -24,6 +24,7 @@
52943 #include <linux/pinctrl/pinmux.h>
52944 /* Since we request GPIOs from ourself */
52945 #include <linux/pinctrl/consumer.h>
52946+#include <asm/pgtable.h>
52947
52948 #include "pinctrl-at91.h"
52949 #include "core.h"
52950@@ -1656,7 +1657,9 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev,
52951 at91_gpio->pioc_hwirq = irqd_to_hwirq(d);
52952
52953 /* Setup proper .irq_set_type function */
52954- gpio_irqchip.irq_set_type = at91_gpio->ops->irq_type;
52955+ pax_open_kernel();
52956+ *(void **)&gpio_irqchip.irq_set_type = at91_gpio->ops->irq_type;
52957+ pax_close_kernel();
52958
52959 /* Disable irqs of this PIO controller */
52960 writel_relaxed(~0, at91_gpio->regbase + PIO_IDR);
52961diff --git a/drivers/platform/chrome/chromeos_pstore.c b/drivers/platform/chrome/chromeos_pstore.c
52962index 3474920..acc9581 100644
52963--- a/drivers/platform/chrome/chromeos_pstore.c
52964+++ b/drivers/platform/chrome/chromeos_pstore.c
52965@@ -13,7 +13,7 @@
52966 #include <linux/platform_device.h>
52967 #include <linux/pstore_ram.h>
52968
52969-static struct dmi_system_id chromeos_pstore_dmi_table[] __initdata = {
52970+static const struct dmi_system_id chromeos_pstore_dmi_table[] __initconst = {
52971 {
52972 /*
52973 * Today all Chromebooks/boxes ship with Google_* as version and
52974diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c
52975index 1e1e594..8fe59c5 100644
52976--- a/drivers/platform/x86/alienware-wmi.c
52977+++ b/drivers/platform/x86/alienware-wmi.c
52978@@ -150,7 +150,7 @@ struct wmax_led_args {
52979 } __packed;
52980
52981 static struct platform_device *platform_device;
52982-static struct device_attribute *zone_dev_attrs;
52983+static device_attribute_no_const *zone_dev_attrs;
52984 static struct attribute **zone_attrs;
52985 static struct platform_zone *zone_data;
52986
52987@@ -160,7 +160,7 @@ static struct platform_driver platform_driver = {
52988 }
52989 };
52990
52991-static struct attribute_group zone_attribute_group = {
52992+static attribute_group_no_const zone_attribute_group = {
52993 .name = "rgb_zones",
52994 };
52995
52996diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
52997index efbc3f0..18ae682 100644
52998--- a/drivers/platform/x86/asus-wmi.c
52999+++ b/drivers/platform/x86/asus-wmi.c
53000@@ -1868,6 +1868,10 @@ static int show_dsts(struct seq_file *m, void *data)
53001 int err;
53002 u32 retval = -1;
53003
53004+#ifdef CONFIG_GRKERNSEC_KMEM
53005+ return -EPERM;
53006+#endif
53007+
53008 err = asus_wmi_get_devstate(asus, asus->debug.dev_id, &retval);
53009
53010 if (err < 0)
53011@@ -1884,6 +1888,10 @@ static int show_devs(struct seq_file *m, void *data)
53012 int err;
53013 u32 retval = -1;
53014
53015+#ifdef CONFIG_GRKERNSEC_KMEM
53016+ return -EPERM;
53017+#endif
53018+
53019 err = asus_wmi_set_devstate(asus->debug.dev_id, asus->debug.ctrl_param,
53020 &retval);
53021
53022@@ -1908,6 +1916,10 @@ static int show_call(struct seq_file *m, void *data)
53023 union acpi_object *obj;
53024 acpi_status status;
53025
53026+#ifdef CONFIG_GRKERNSEC_KMEM
53027+ return -EPERM;
53028+#endif
53029+
53030 status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID,
53031 1, asus->debug.method_id,
53032 &input, &output);
53033diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c
53034index f2706d2..850edfa4 100644
53035--- a/drivers/platform/x86/compal-laptop.c
53036+++ b/drivers/platform/x86/compal-laptop.c
53037@@ -765,7 +765,7 @@ static int dmi_check_cb_extra(const struct dmi_system_id *id)
53038 return 1;
53039 }
53040
53041-static struct dmi_system_id __initdata compal_dmi_table[] = {
53042+static const struct dmi_system_id __initconst compal_dmi_table[] = {
53043 {
53044 .ident = "FL90/IFL90",
53045 .matches = {
53046diff --git a/drivers/platform/x86/hdaps.c b/drivers/platform/x86/hdaps.c
53047index 458e6c9..089aee7 100644
53048--- a/drivers/platform/x86/hdaps.c
53049+++ b/drivers/platform/x86/hdaps.c
53050@@ -514,7 +514,7 @@ static int __init hdaps_dmi_match_invert(const struct dmi_system_id *id)
53051 "ThinkPad T42p", so the order of the entries matters.
53052 If your ThinkPad is not recognized, please update to latest
53053 BIOS. This is especially the case for some R52 ThinkPads. */
53054-static struct dmi_system_id __initdata hdaps_whitelist[] = {
53055+static const struct dmi_system_id __initconst hdaps_whitelist[] = {
53056 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad R50p", HDAPS_BOTH_AXES),
53057 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R50"),
53058 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R51"),
53059diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c
53060index 97c2be1..2ee50ce 100644
53061--- a/drivers/platform/x86/ibm_rtl.c
53062+++ b/drivers/platform/x86/ibm_rtl.c
53063@@ -227,7 +227,7 @@ static void rtl_teardown_sysfs(void) {
53064 }
53065
53066
53067-static struct dmi_system_id __initdata ibm_rtl_dmi_table[] = {
53068+static const struct dmi_system_id __initconst ibm_rtl_dmi_table[] = {
53069 { \
53070 .matches = { \
53071 DMI_MATCH(DMI_SYS_VENDOR, "IBM"), \
53072diff --git a/drivers/platform/x86/intel_oaktrail.c b/drivers/platform/x86/intel_oaktrail.c
53073index 6aa33c4..cfb5425 100644
53074--- a/drivers/platform/x86/intel_oaktrail.c
53075+++ b/drivers/platform/x86/intel_oaktrail.c
53076@@ -299,7 +299,7 @@ static int dmi_check_cb(const struct dmi_system_id *id)
53077 return 0;
53078 }
53079
53080-static struct dmi_system_id __initdata oaktrail_dmi_table[] = {
53081+static const struct dmi_system_id __initconst oaktrail_dmi_table[] = {
53082 {
53083 .ident = "OakTrail platform",
53084 .matches = {
53085diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
53086index 4231770..10a6caf 100644
53087--- a/drivers/platform/x86/msi-laptop.c
53088+++ b/drivers/platform/x86/msi-laptop.c
53089@@ -605,7 +605,7 @@ static int dmi_check_cb(const struct dmi_system_id *dmi)
53090 return 1;
53091 }
53092
53093-static struct dmi_system_id __initdata msi_dmi_table[] = {
53094+static const struct dmi_system_id __initconst msi_dmi_table[] = {
53095 {
53096 .ident = "MSI S270",
53097 .matches = {
53098@@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
53099
53100 if (!quirks->ec_read_only) {
53101 /* allow userland write sysfs file */
53102- dev_attr_bluetooth.store = store_bluetooth;
53103- dev_attr_wlan.store = store_wlan;
53104- dev_attr_threeg.store = store_threeg;
53105- dev_attr_bluetooth.attr.mode |= S_IWUSR;
53106- dev_attr_wlan.attr.mode |= S_IWUSR;
53107- dev_attr_threeg.attr.mode |= S_IWUSR;
53108+ pax_open_kernel();
53109+ *(void **)&dev_attr_bluetooth.store = store_bluetooth;
53110+ *(void **)&dev_attr_wlan.store = store_wlan;
53111+ *(void **)&dev_attr_threeg.store = store_threeg;
53112+ *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
53113+ *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
53114+ *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
53115+ pax_close_kernel();
53116 }
53117
53118 /* disable hardware control by fn key */
53119diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
53120index 978e6d6..1f0b37d 100644
53121--- a/drivers/platform/x86/msi-wmi.c
53122+++ b/drivers/platform/x86/msi-wmi.c
53123@@ -184,7 +184,7 @@ static const struct backlight_ops msi_backlight_ops = {
53124 static void msi_wmi_notify(u32 value, void *context)
53125 {
53126 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
53127- static struct key_entry *key;
53128+ struct key_entry *key;
53129 union acpi_object *obj;
53130 acpi_status status;
53131
53132diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
53133index 8c146e2..356c62e 100644
53134--- a/drivers/platform/x86/samsung-laptop.c
53135+++ b/drivers/platform/x86/samsung-laptop.c
53136@@ -1567,7 +1567,7 @@ static int __init samsung_dmi_matched(const struct dmi_system_id *d)
53137 return 0;
53138 }
53139
53140-static struct dmi_system_id __initdata samsung_dmi_table[] = {
53141+static const struct dmi_system_id __initconst samsung_dmi_table[] = {
53142 {
53143 .matches = {
53144 DMI_MATCH(DMI_SYS_VENDOR,
53145diff --git a/drivers/platform/x86/samsung-q10.c b/drivers/platform/x86/samsung-q10.c
53146index e6aac72..e11ff24 100644
53147--- a/drivers/platform/x86/samsung-q10.c
53148+++ b/drivers/platform/x86/samsung-q10.c
53149@@ -95,7 +95,7 @@ static int __init dmi_check_callback(const struct dmi_system_id *id)
53150 return 1;
53151 }
53152
53153-static struct dmi_system_id __initdata samsungq10_dmi_table[] = {
53154+static const struct dmi_system_id __initconst samsungq10_dmi_table[] = {
53155 {
53156 .ident = "Samsung Q10",
53157 .matches = {
53158diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
53159index aeb80d1..3eb376b 100644
53160--- a/drivers/platform/x86/sony-laptop.c
53161+++ b/drivers/platform/x86/sony-laptop.c
53162@@ -2527,7 +2527,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
53163 }
53164
53165 /* High speed charging function */
53166-static struct device_attribute *hsc_handle;
53167+static device_attribute_no_const *hsc_handle;
53168
53169 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
53170 struct device_attribute *attr,
53171@@ -2601,7 +2601,7 @@ static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd)
53172 }
53173
53174 /* low battery function */
53175-static struct device_attribute *lowbatt_handle;
53176+static device_attribute_no_const *lowbatt_handle;
53177
53178 static ssize_t sony_nc_lowbatt_store(struct device *dev,
53179 struct device_attribute *attr,
53180@@ -2667,7 +2667,7 @@ static void sony_nc_lowbatt_cleanup(struct platform_device *pd)
53181 }
53182
53183 /* fan speed function */
53184-static struct device_attribute *fan_handle, *hsf_handle;
53185+static device_attribute_no_const *fan_handle, *hsf_handle;
53186
53187 static ssize_t sony_nc_hsfan_store(struct device *dev,
53188 struct device_attribute *attr,
53189@@ -2774,7 +2774,7 @@ static void sony_nc_fanspeed_cleanup(struct platform_device *pd)
53190 }
53191
53192 /* USB charge function */
53193-static struct device_attribute *uc_handle;
53194+static device_attribute_no_const *uc_handle;
53195
53196 static ssize_t sony_nc_usb_charge_store(struct device *dev,
53197 struct device_attribute *attr,
53198@@ -2848,7 +2848,7 @@ static void sony_nc_usb_charge_cleanup(struct platform_device *pd)
53199 }
53200
53201 /* Panel ID function */
53202-static struct device_attribute *panel_handle;
53203+static device_attribute_no_const *panel_handle;
53204
53205 static ssize_t sony_nc_panelid_show(struct device *dev,
53206 struct device_attribute *attr, char *buffer)
53207@@ -2895,7 +2895,7 @@ static void sony_nc_panelid_cleanup(struct platform_device *pd)
53208 }
53209
53210 /* smart connect function */
53211-static struct device_attribute *sc_handle;
53212+static device_attribute_no_const *sc_handle;
53213
53214 static ssize_t sony_nc_smart_conn_store(struct device *dev,
53215 struct device_attribute *attr,
53216@@ -4851,7 +4851,7 @@ static struct acpi_driver sony_pic_driver = {
53217 .drv.pm = &sony_pic_pm,
53218 };
53219
53220-static struct dmi_system_id __initdata sonypi_dmi_table[] = {
53221+static const struct dmi_system_id __initconst sonypi_dmi_table[] = {
53222 {
53223 .ident = "Sony Vaio",
53224 .matches = {
53225diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
53226index 33e488c..417aaea 100644
53227--- a/drivers/platform/x86/thinkpad_acpi.c
53228+++ b/drivers/platform/x86/thinkpad_acpi.c
53229@@ -2460,10 +2460,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
53230 && !tp_features.bright_unkfw)
53231 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
53232 }
53233+}
53234
53235 #undef TPACPI_COMPARE_KEY
53236 #undef TPACPI_MAY_SEND_KEY
53237-}
53238
53239 /*
53240 * Polling driver
53241diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
53242index 438d4c7..ca8a2fb 100644
53243--- a/drivers/pnp/pnpbios/bioscalls.c
53244+++ b/drivers/pnp/pnpbios/bioscalls.c
53245@@ -59,7 +59,7 @@ do { \
53246 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
53247 } while(0)
53248
53249-static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
53250+static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
53251 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
53252
53253 /*
53254@@ -96,7 +96,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
53255
53256 cpu = get_cpu();
53257 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
53258+
53259+ pax_open_kernel();
53260 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
53261+ pax_close_kernel();
53262
53263 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
53264 spin_lock_irqsave(&pnp_bios_lock, flags);
53265@@ -134,7 +137,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
53266 :"memory");
53267 spin_unlock_irqrestore(&pnp_bios_lock, flags);
53268
53269+ pax_open_kernel();
53270 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
53271+ pax_close_kernel();
53272+
53273 put_cpu();
53274
53275 /* If we get here and this is set then the PnP BIOS faulted on us. */
53276@@ -468,7 +474,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
53277 return status;
53278 }
53279
53280-void pnpbios_calls_init(union pnp_bios_install_struct *header)
53281+void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
53282 {
53283 int i;
53284
53285@@ -476,6 +482,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
53286 pnp_bios_callpoint.offset = header->fields.pm16offset;
53287 pnp_bios_callpoint.segment = PNP_CS16;
53288
53289+ pax_open_kernel();
53290+
53291 for_each_possible_cpu(i) {
53292 struct desc_struct *gdt = get_cpu_gdt_table(i);
53293 if (!gdt)
53294@@ -487,4 +495,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
53295 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
53296 (unsigned long)__va(header->fields.pm16dseg));
53297 }
53298+
53299+ pax_close_kernel();
53300 }
53301diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
53302index facd43b..b291260 100644
53303--- a/drivers/pnp/pnpbios/core.c
53304+++ b/drivers/pnp/pnpbios/core.c
53305@@ -494,7 +494,7 @@ static int __init exploding_pnp_bios(const struct dmi_system_id *d)
53306 return 0;
53307 }
53308
53309-static struct dmi_system_id pnpbios_dmi_table[] __initdata = {
53310+static const struct dmi_system_id pnpbios_dmi_table[] __initconst = {
53311 { /* PnPBIOS GPF on boot */
53312 .callback = exploding_pnp_bios,
53313 .ident = "Higraded P14H",
53314diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
53315index dfe1ee8..67e820c 100644
53316--- a/drivers/power/pda_power.c
53317+++ b/drivers/power/pda_power.c
53318@@ -38,7 +38,11 @@ static struct power_supply *pda_psy_ac, *pda_psy_usb;
53319
53320 #if IS_ENABLED(CONFIG_USB_PHY)
53321 static struct usb_phy *transceiver;
53322-static struct notifier_block otg_nb;
53323+static int otg_handle_notification(struct notifier_block *nb,
53324+ unsigned long event, void *unused);
53325+static struct notifier_block otg_nb = {
53326+ .notifier_call = otg_handle_notification
53327+};
53328 #endif
53329
53330 static struct regulator *ac_draw;
53331@@ -373,7 +377,6 @@ static int pda_power_probe(struct platform_device *pdev)
53332
53333 #if IS_ENABLED(CONFIG_USB_PHY)
53334 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
53335- otg_nb.notifier_call = otg_handle_notification;
53336 ret = usb_register_notifier(transceiver, &otg_nb);
53337 if (ret) {
53338 dev_err(dev, "failure to register otg notifier\n");
53339diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
53340index cc439fd..8fa30df 100644
53341--- a/drivers/power/power_supply.h
53342+++ b/drivers/power/power_supply.h
53343@@ -16,12 +16,12 @@ struct power_supply;
53344
53345 #ifdef CONFIG_SYSFS
53346
53347-extern void power_supply_init_attrs(struct device_type *dev_type);
53348+extern void power_supply_init_attrs(void);
53349 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
53350
53351 #else
53352
53353-static inline void power_supply_init_attrs(struct device_type *dev_type) {}
53354+static inline void power_supply_init_attrs(void) {}
53355 #define power_supply_uevent NULL
53356
53357 #endif /* CONFIG_SYSFS */
53358diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
53359index 869284c..38a812b 100644
53360--- a/drivers/power/power_supply_core.c
53361+++ b/drivers/power/power_supply_core.c
53362@@ -28,7 +28,10 @@ EXPORT_SYMBOL_GPL(power_supply_class);
53363 ATOMIC_NOTIFIER_HEAD(power_supply_notifier);
53364 EXPORT_SYMBOL_GPL(power_supply_notifier);
53365
53366-static struct device_type power_supply_dev_type;
53367+extern const struct attribute_group *power_supply_attr_groups[];
53368+static struct device_type power_supply_dev_type = {
53369+ .groups = power_supply_attr_groups,
53370+};
53371
53372 #define POWER_SUPPLY_DEFERRED_REGISTER_TIME msecs_to_jiffies(10)
53373
53374@@ -960,7 +963,7 @@ static int __init power_supply_class_init(void)
53375 return PTR_ERR(power_supply_class);
53376
53377 power_supply_class->dev_uevent = power_supply_uevent;
53378- power_supply_init_attrs(&power_supply_dev_type);
53379+ power_supply_init_attrs();
53380
53381 return 0;
53382 }
53383diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
53384index ed2d7fd..266b28f 100644
53385--- a/drivers/power/power_supply_sysfs.c
53386+++ b/drivers/power/power_supply_sysfs.c
53387@@ -238,17 +238,15 @@ static struct attribute_group power_supply_attr_group = {
53388 .is_visible = power_supply_attr_is_visible,
53389 };
53390
53391-static const struct attribute_group *power_supply_attr_groups[] = {
53392+const struct attribute_group *power_supply_attr_groups[] = {
53393 &power_supply_attr_group,
53394 NULL,
53395 };
53396
53397-void power_supply_init_attrs(struct device_type *dev_type)
53398+void power_supply_init_attrs(void)
53399 {
53400 int i;
53401
53402- dev_type->groups = power_supply_attr_groups;
53403-
53404 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
53405 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
53406 }
53407diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
53408index 36dc52f..e2e8a4b 100644
53409--- a/drivers/power/reset/at91-reset.c
53410+++ b/drivers/power/reset/at91-reset.c
53411@@ -16,6 +16,7 @@
53412 #include <linux/of_address.h>
53413 #include <linux/platform_device.h>
53414 #include <linux/reboot.h>
53415+#include <asm/pgtable.h>
53416
53417 #include <soc/at91/at91sam9_ddrsdr.h>
53418 #include <soc/at91/at91sam9_sdramc.h>
53419@@ -191,7 +192,9 @@ static int at91_reset_of_probe(struct platform_device *pdev)
53420 }
53421
53422 match = of_match_node(at91_reset_of_match, pdev->dev.of_node);
53423- at91_restart_nb.notifier_call = match->data;
53424+ pax_open_kernel();
53425+ *(void **)&at91_restart_nb.notifier_call = match->data;
53426+ pax_close_kernel();
53427 return register_restart_handler(&at91_restart_nb);
53428 }
53429
53430@@ -219,9 +222,11 @@ static int at91_reset_platform_probe(struct platform_device *pdev)
53431 }
53432
53433 match = platform_get_device_id(pdev);
53434- at91_restart_nb.notifier_call =
53435+ pax_open_kernel();
53436+ *(void **)&at91_restart_nb.notifier_call =
53437 (int (*)(struct notifier_block *,
53438 unsigned long, void *)) match->driver_data;
53439+ pax_close_kernel();
53440
53441 return register_restart_handler(&at91_restart_nb);
53442 }
53443diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c
53444index 84419af..268ede8 100644
53445--- a/drivers/powercap/powercap_sys.c
53446+++ b/drivers/powercap/powercap_sys.c
53447@@ -154,8 +154,77 @@ struct powercap_constraint_attr {
53448 struct device_attribute name_attr;
53449 };
53450
53451+static ssize_t show_constraint_name(struct device *dev,
53452+ struct device_attribute *dev_attr,
53453+ char *buf);
53454+
53455 static struct powercap_constraint_attr
53456- constraint_attrs[MAX_CONSTRAINTS_PER_ZONE];
53457+ constraint_attrs[MAX_CONSTRAINTS_PER_ZONE] = {
53458+ [0 ... MAX_CONSTRAINTS_PER_ZONE - 1] = {
53459+ .power_limit_attr = {
53460+ .attr = {
53461+ .name = NULL,
53462+ .mode = S_IWUSR | S_IRUGO
53463+ },
53464+ .show = show_constraint_power_limit_uw,
53465+ .store = store_constraint_power_limit_uw
53466+ },
53467+
53468+ .time_window_attr = {
53469+ .attr = {
53470+ .name = NULL,
53471+ .mode = S_IWUSR | S_IRUGO
53472+ },
53473+ .show = show_constraint_time_window_us,
53474+ .store = store_constraint_time_window_us
53475+ },
53476+
53477+ .max_power_attr = {
53478+ .attr = {
53479+ .name = NULL,
53480+ .mode = S_IRUGO
53481+ },
53482+ .show = show_constraint_max_power_uw,
53483+ .store = NULL
53484+ },
53485+
53486+ .min_power_attr = {
53487+ .attr = {
53488+ .name = NULL,
53489+ .mode = S_IRUGO
53490+ },
53491+ .show = show_constraint_min_power_uw,
53492+ .store = NULL
53493+ },
53494+
53495+ .max_time_window_attr = {
53496+ .attr = {
53497+ .name = NULL,
53498+ .mode = S_IRUGO
53499+ },
53500+ .show = show_constraint_max_time_window_us,
53501+ .store = NULL
53502+ },
53503+
53504+ .min_time_window_attr = {
53505+ .attr = {
53506+ .name = NULL,
53507+ .mode = S_IRUGO
53508+ },
53509+ .show = show_constraint_min_time_window_us,
53510+ .store = NULL
53511+ },
53512+
53513+ .name_attr = {
53514+ .attr = {
53515+ .name = NULL,
53516+ .mode = S_IRUGO
53517+ },
53518+ .show = show_constraint_name,
53519+ .store = NULL
53520+ }
53521+ }
53522+};
53523
53524 /* A list of powercap control_types */
53525 static LIST_HEAD(powercap_cntrl_list);
53526@@ -193,23 +262,16 @@ static ssize_t show_constraint_name(struct device *dev,
53527 }
53528
53529 static int create_constraint_attribute(int id, const char *name,
53530- int mode,
53531- struct device_attribute *dev_attr,
53532- ssize_t (*show)(struct device *,
53533- struct device_attribute *, char *),
53534- ssize_t (*store)(struct device *,
53535- struct device_attribute *,
53536- const char *, size_t)
53537- )
53538+ struct device_attribute *dev_attr)
53539 {
53540+ name = kasprintf(GFP_KERNEL, "constraint_%d_%s", id, name);
53541
53542- dev_attr->attr.name = kasprintf(GFP_KERNEL, "constraint_%d_%s",
53543- id, name);
53544- if (!dev_attr->attr.name)
53545+ if (!name)
53546 return -ENOMEM;
53547- dev_attr->attr.mode = mode;
53548- dev_attr->show = show;
53549- dev_attr->store = store;
53550+
53551+ pax_open_kernel();
53552+ *(const char **)&dev_attr->attr.name = name;
53553+ pax_close_kernel();
53554
53555 return 0;
53556 }
53557@@ -236,49 +298,31 @@ static int seed_constraint_attributes(void)
53558
53559 for (i = 0; i < MAX_CONSTRAINTS_PER_ZONE; ++i) {
53560 ret = create_constraint_attribute(i, "power_limit_uw",
53561- S_IWUSR | S_IRUGO,
53562- &constraint_attrs[i].power_limit_attr,
53563- show_constraint_power_limit_uw,
53564- store_constraint_power_limit_uw);
53565+ &constraint_attrs[i].power_limit_attr);
53566 if (ret)
53567 goto err_alloc;
53568 ret = create_constraint_attribute(i, "time_window_us",
53569- S_IWUSR | S_IRUGO,
53570- &constraint_attrs[i].time_window_attr,
53571- show_constraint_time_window_us,
53572- store_constraint_time_window_us);
53573+ &constraint_attrs[i].time_window_attr);
53574 if (ret)
53575 goto err_alloc;
53576- ret = create_constraint_attribute(i, "name", S_IRUGO,
53577- &constraint_attrs[i].name_attr,
53578- show_constraint_name,
53579- NULL);
53580+ ret = create_constraint_attribute(i, "name",
53581+ &constraint_attrs[i].name_attr);
53582 if (ret)
53583 goto err_alloc;
53584- ret = create_constraint_attribute(i, "max_power_uw", S_IRUGO,
53585- &constraint_attrs[i].max_power_attr,
53586- show_constraint_max_power_uw,
53587- NULL);
53588+ ret = create_constraint_attribute(i, "max_power_uw",
53589+ &constraint_attrs[i].max_power_attr);
53590 if (ret)
53591 goto err_alloc;
53592- ret = create_constraint_attribute(i, "min_power_uw", S_IRUGO,
53593- &constraint_attrs[i].min_power_attr,
53594- show_constraint_min_power_uw,
53595- NULL);
53596+ ret = create_constraint_attribute(i, "min_power_uw",
53597+ &constraint_attrs[i].min_power_attr);
53598 if (ret)
53599 goto err_alloc;
53600 ret = create_constraint_attribute(i, "max_time_window_us",
53601- S_IRUGO,
53602- &constraint_attrs[i].max_time_window_attr,
53603- show_constraint_max_time_window_us,
53604- NULL);
53605+ &constraint_attrs[i].max_time_window_attr);
53606 if (ret)
53607 goto err_alloc;
53608 ret = create_constraint_attribute(i, "min_time_window_us",
53609- S_IRUGO,
53610- &constraint_attrs[i].min_time_window_attr,
53611- show_constraint_min_time_window_us,
53612- NULL);
53613+ &constraint_attrs[i].min_time_window_attr);
53614 if (ret)
53615 goto err_alloc;
53616
53617@@ -378,10 +422,12 @@ static void create_power_zone_common_attributes(
53618 power_zone->zone_dev_attrs[count++] =
53619 &dev_attr_max_energy_range_uj.attr;
53620 if (power_zone->ops->get_energy_uj) {
53621+ pax_open_kernel();
53622 if (power_zone->ops->reset_energy_uj)
53623- dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
53624+ *(umode_t *)&dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
53625 else
53626- dev_attr_energy_uj.attr.mode = S_IRUGO;
53627+ *(umode_t *)&dev_attr_energy_uj.attr.mode = S_IRUGO;
53628+ pax_close_kernel();
53629 power_zone->zone_dev_attrs[count++] =
53630 &dev_attr_energy_uj.attr;
53631 }
53632diff --git a/drivers/ptp/ptp_private.h b/drivers/ptp/ptp_private.h
53633index 9c5d414..c7900ce 100644
53634--- a/drivers/ptp/ptp_private.h
53635+++ b/drivers/ptp/ptp_private.h
53636@@ -51,7 +51,7 @@ struct ptp_clock {
53637 struct mutex pincfg_mux; /* protect concurrent info->pin_config access */
53638 wait_queue_head_t tsev_wq;
53639 int defunct; /* tells readers to go away when clock is being removed */
53640- struct device_attribute *pin_dev_attr;
53641+ device_attribute_no_const *pin_dev_attr;
53642 struct attribute **pin_attr;
53643 struct attribute_group pin_attr_group;
53644 };
53645diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
53646index 302e626..12579af 100644
53647--- a/drivers/ptp/ptp_sysfs.c
53648+++ b/drivers/ptp/ptp_sysfs.c
53649@@ -280,7 +280,7 @@ static int ptp_populate_pins(struct ptp_clock *ptp)
53650 goto no_pin_attr;
53651
53652 for (i = 0; i < n_pins; i++) {
53653- struct device_attribute *da = &ptp->pin_dev_attr[i];
53654+ device_attribute_no_const *da = &ptp->pin_dev_attr[i];
53655 sysfs_attr_init(&da->attr);
53656 da->attr.name = info->pin_config[i].name;
53657 da->attr.mode = 0644;
53658diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
53659index 5081533..794deb2 100644
53660--- a/drivers/regulator/core.c
53661+++ b/drivers/regulator/core.c
53662@@ -3650,7 +3650,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
53663 const struct regulation_constraints *constraints = NULL;
53664 const struct regulator_init_data *init_data;
53665 struct regulator_config *config = NULL;
53666- static atomic_t regulator_no = ATOMIC_INIT(-1);
53667+ static atomic_unchecked_t regulator_no = ATOMIC_INIT(-1);
53668 struct regulator_dev *rdev;
53669 struct device *dev;
53670 int ret, i;
53671@@ -3733,7 +3733,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
53672 rdev->dev.class = &regulator_class;
53673 rdev->dev.parent = dev;
53674 dev_set_name(&rdev->dev, "regulator.%lu",
53675- (unsigned long) atomic_inc_return(&regulator_no));
53676+ (unsigned long) atomic_inc_return_unchecked(&regulator_no));
53677 ret = device_register(&rdev->dev);
53678 if (ret != 0) {
53679 put_device(&rdev->dev);
53680diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
53681index 4071d74..260b15a 100644
53682--- a/drivers/regulator/max8660.c
53683+++ b/drivers/regulator/max8660.c
53684@@ -423,8 +423,10 @@ static int max8660_probe(struct i2c_client *client,
53685 max8660->shadow_regs[MAX8660_OVER1] = 5;
53686 } else {
53687 /* Otherwise devices can be toggled via software */
53688- max8660_dcdc_ops.enable = max8660_dcdc_enable;
53689- max8660_dcdc_ops.disable = max8660_dcdc_disable;
53690+ pax_open_kernel();
53691+ *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
53692+ *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
53693+ pax_close_kernel();
53694 }
53695
53696 /*
53697diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
53698index e94ddcf..bad33ad 100644
53699--- a/drivers/regulator/max8973-regulator.c
53700+++ b/drivers/regulator/max8973-regulator.c
53701@@ -580,9 +580,11 @@ static int max8973_probe(struct i2c_client *client,
53702 if (!pdata->enable_ext_control) {
53703 max->desc.enable_reg = MAX8973_VOUT;
53704 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
53705- max->ops.enable = regulator_enable_regmap;
53706- max->ops.disable = regulator_disable_regmap;
53707- max->ops.is_enabled = regulator_is_enabled_regmap;
53708+ pax_open_kernel();
53709+ *(void **)&max->ops.enable = regulator_enable_regmap;
53710+ *(void **)&max->ops.disable = regulator_disable_regmap;
53711+ *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
53712+ pax_close_kernel();
53713 break;
53714 }
53715
53716@@ -610,9 +612,11 @@ static int max8973_probe(struct i2c_client *client,
53717
53718 max->desc.enable_reg = MAX8973_VOUT;
53719 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
53720- max->ops.enable = regulator_enable_regmap;
53721- max->ops.disable = regulator_disable_regmap;
53722- max->ops.is_enabled = regulator_is_enabled_regmap;
53723+ pax_open_kernel();
53724+ *(void **)&max->ops.enable = regulator_enable_regmap;
53725+ *(void **)&max->ops.disable = regulator_disable_regmap;
53726+ *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
53727+ pax_close_kernel();
53728 break;
53729 default:
53730 break;
53731diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
53732index 0d17c92..a29f627 100644
53733--- a/drivers/regulator/mc13892-regulator.c
53734+++ b/drivers/regulator/mc13892-regulator.c
53735@@ -584,10 +584,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
53736 mc13xxx_unlock(mc13892);
53737
53738 /* update mc13892_vcam ops */
53739- memcpy(&mc13892_vcam_ops, mc13892_regulators[MC13892_VCAM].desc.ops,
53740+ pax_open_kernel();
53741+ memcpy((void *)&mc13892_vcam_ops, mc13892_regulators[MC13892_VCAM].desc.ops,
53742 sizeof(struct regulator_ops));
53743- mc13892_vcam_ops.set_mode = mc13892_vcam_set_mode,
53744- mc13892_vcam_ops.get_mode = mc13892_vcam_get_mode,
53745+ *(void **)&mc13892_vcam_ops.set_mode = mc13892_vcam_set_mode,
53746+ *(void **)&mc13892_vcam_ops.get_mode = mc13892_vcam_get_mode,
53747+ pax_close_kernel();
53748 mc13892_regulators[MC13892_VCAM].desc.ops = &mc13892_vcam_ops;
53749
53750 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
53751diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c
53752index 2b08cac..8942201 100644
53753--- a/drivers/rtc/rtc-armada38x.c
53754+++ b/drivers/rtc/rtc-armada38x.c
53755@@ -18,6 +18,7 @@
53756 #include <linux/of.h>
53757 #include <linux/platform_device.h>
53758 #include <linux/rtc.h>
53759+#include <asm/pgtable.h>
53760
53761 #define RTC_STATUS 0x0
53762 #define RTC_STATUS_ALARM1 BIT(0)
53763@@ -254,8 +255,10 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
53764 * If there is no interrupt available then we can't
53765 * use the alarm
53766 */
53767- armada38x_rtc_ops.set_alarm = NULL;
53768- armada38x_rtc_ops.alarm_irq_enable = NULL;
53769+ pax_open_kernel();
53770+ *(void **)&armada38x_rtc_ops.set_alarm = NULL;
53771+ *(void **)&armada38x_rtc_ops.alarm_irq_enable = NULL;
53772+ pax_close_kernel();
53773 }
53774 platform_set_drvdata(pdev, rtc);
53775 if (rtc->irq != -1)
53776diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
53777index a82556a0..e842923 100644
53778--- a/drivers/rtc/rtc-cmos.c
53779+++ b/drivers/rtc/rtc-cmos.c
53780@@ -793,7 +793,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
53781 hpet_rtc_timer_init();
53782
53783 /* export at least the first block of NVRAM */
53784- nvram.size = address_space - NVRAM_OFFSET;
53785+ pax_open_kernel();
53786+ *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
53787+ pax_close_kernel();
53788 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
53789 if (retval < 0) {
53790 dev_dbg(dev, "can't create nvram file? %d\n", retval);
53791diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
53792index 799c34b..8e9786a 100644
53793--- a/drivers/rtc/rtc-dev.c
53794+++ b/drivers/rtc/rtc-dev.c
53795@@ -16,6 +16,7 @@
53796 #include <linux/module.h>
53797 #include <linux/rtc.h>
53798 #include <linux/sched.h>
53799+#include <linux/grsecurity.h>
53800 #include "rtc-core.h"
53801
53802 static dev_t rtc_devt;
53803@@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
53804 if (copy_from_user(&tm, uarg, sizeof(tm)))
53805 return -EFAULT;
53806
53807+ gr_log_timechange();
53808+
53809 return rtc_set_time(rtc, &tm);
53810
53811 case RTC_PIE_ON:
53812diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
53813index 6e76de1..d38a1e0 100644
53814--- a/drivers/rtc/rtc-ds1307.c
53815+++ b/drivers/rtc/rtc-ds1307.c
53816@@ -107,7 +107,7 @@ struct ds1307 {
53817 u8 offset; /* register's offset */
53818 u8 regs[11];
53819 u16 nvram_offset;
53820- struct bin_attribute *nvram;
53821+ bin_attribute_no_const *nvram;
53822 enum ds_type type;
53823 unsigned long flags;
53824 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
53825diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
53826index 90abb5b..e0bf6dd 100644
53827--- a/drivers/rtc/rtc-m48t59.c
53828+++ b/drivers/rtc/rtc-m48t59.c
53829@@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
53830 if (IS_ERR(m48t59->rtc))
53831 return PTR_ERR(m48t59->rtc);
53832
53833- m48t59_nvram_attr.size = pdata->offset;
53834+ pax_open_kernel();
53835+ *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
53836+ pax_close_kernel();
53837
53838 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
53839 if (ret)
53840diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
53841index 3a2da4c..e88493c 100644
53842--- a/drivers/rtc/rtc-test.c
53843+++ b/drivers/rtc/rtc-test.c
53844@@ -112,8 +112,10 @@ static int test_probe(struct platform_device *plat_dev)
53845 struct rtc_device *rtc;
53846
53847 if (test_mmss64) {
53848- test_rtc_ops.set_mmss64 = test_rtc_set_mmss64;
53849- test_rtc_ops.set_mmss = NULL;
53850+ pax_open_kernel();
53851+ *(void **)&test_rtc_ops.set_mmss64 = test_rtc_set_mmss64;
53852+ *(void **)&test_rtc_ops.set_mmss = NULL;
53853+ pax_close_kernel();
53854 }
53855
53856 rtc = devm_rtc_device_register(&plat_dev->dev, "test",
53857diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
53858index 7a6dbfb..5cdcd29 100644
53859--- a/drivers/scsi/be2iscsi/be_main.c
53860+++ b/drivers/scsi/be2iscsi/be_main.c
53861@@ -3184,7 +3184,7 @@ be_sgl_create_contiguous(void *virtual_address,
53862 {
53863 WARN_ON(!virtual_address);
53864 WARN_ON(!physical_address);
53865- WARN_ON(!length > 0);
53866+ WARN_ON(!length);
53867 WARN_ON(!sgl);
53868
53869 sgl->va = virtual_address;
53870diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
53871index e693af6..2e525b6 100644
53872--- a/drivers/scsi/bfa/bfa_fcpim.h
53873+++ b/drivers/scsi/bfa/bfa_fcpim.h
53874@@ -36,7 +36,7 @@ struct bfa_iotag_s {
53875
53876 struct bfa_itn_s {
53877 bfa_isr_func_t isr;
53878-};
53879+} __no_const;
53880
53881 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
53882 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
53883diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c
53884index 0f19455..ef7adb5 100644
53885--- a/drivers/scsi/bfa/bfa_fcs.c
53886+++ b/drivers/scsi/bfa/bfa_fcs.c
53887@@ -38,10 +38,21 @@ struct bfa_fcs_mod_s {
53888 #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit }
53889
53890 static struct bfa_fcs_mod_s fcs_modules[] = {
53891- { bfa_fcs_port_attach, NULL, NULL },
53892- { bfa_fcs_uf_attach, NULL, NULL },
53893- { bfa_fcs_fabric_attach, bfa_fcs_fabric_modinit,
53894- bfa_fcs_fabric_modexit },
53895+ {
53896+ .attach = bfa_fcs_port_attach,
53897+ .modinit = NULL,
53898+ .modexit = NULL
53899+ },
53900+ {
53901+ .attach = bfa_fcs_uf_attach,
53902+ .modinit = NULL,
53903+ .modexit = NULL
53904+ },
53905+ {
53906+ .attach = bfa_fcs_fabric_attach,
53907+ .modinit = bfa_fcs_fabric_modinit,
53908+ .modexit = bfa_fcs_fabric_modexit
53909+ },
53910 };
53911
53912 /*
53913diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
53914index ff75ef8..2dfe00a 100644
53915--- a/drivers/scsi/bfa/bfa_fcs_lport.c
53916+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
53917@@ -89,15 +89,26 @@ static struct {
53918 void (*offline) (struct bfa_fcs_lport_s *port);
53919 } __port_action[] = {
53920 {
53921- bfa_fcs_lport_unknown_init, bfa_fcs_lport_unknown_online,
53922- bfa_fcs_lport_unknown_offline}, {
53923- bfa_fcs_lport_fab_init, bfa_fcs_lport_fab_online,
53924- bfa_fcs_lport_fab_offline}, {
53925- bfa_fcs_lport_n2n_init, bfa_fcs_lport_n2n_online,
53926- bfa_fcs_lport_n2n_offline}, {
53927- bfa_fcs_lport_loop_init, bfa_fcs_lport_loop_online,
53928- bfa_fcs_lport_loop_offline},
53929- };
53930+ .init = bfa_fcs_lport_unknown_init,
53931+ .online = bfa_fcs_lport_unknown_online,
53932+ .offline = bfa_fcs_lport_unknown_offline
53933+ },
53934+ {
53935+ .init = bfa_fcs_lport_fab_init,
53936+ .online = bfa_fcs_lport_fab_online,
53937+ .offline = bfa_fcs_lport_fab_offline
53938+ },
53939+ {
53940+ .init = bfa_fcs_lport_n2n_init,
53941+ .online = bfa_fcs_lport_n2n_online,
53942+ .offline = bfa_fcs_lport_n2n_offline
53943+ },
53944+ {
53945+ .init = bfa_fcs_lport_loop_init,
53946+ .online = bfa_fcs_lport_loop_online,
53947+ .offline = bfa_fcs_lport_loop_offline
53948+ },
53949+};
53950
53951 /*
53952 * fcs_port_sm FCS logical port state machine
53953diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
53954index a38aafa0..fe8f03b 100644
53955--- a/drivers/scsi/bfa/bfa_ioc.h
53956+++ b/drivers/scsi/bfa/bfa_ioc.h
53957@@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
53958 bfa_ioc_disable_cbfn_t disable_cbfn;
53959 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
53960 bfa_ioc_reset_cbfn_t reset_cbfn;
53961-};
53962+} __no_const;
53963
53964 /*
53965 * IOC event notification mechanism.
53966@@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
53967 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
53968 enum bfi_ioc_state fwstate);
53969 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
53970-};
53971+} __no_const;
53972
53973 /*
53974 * Queue element to wait for room in request queue. FIFO order is
53975diff --git a/drivers/scsi/bfa/bfa_modules.h b/drivers/scsi/bfa/bfa_modules.h
53976index a14c784..6de6790 100644
53977--- a/drivers/scsi/bfa/bfa_modules.h
53978+++ b/drivers/scsi/bfa/bfa_modules.h
53979@@ -78,12 +78,12 @@ enum {
53980 \
53981 extern struct bfa_module_s hal_mod_ ## __mod; \
53982 struct bfa_module_s hal_mod_ ## __mod = { \
53983- bfa_ ## __mod ## _meminfo, \
53984- bfa_ ## __mod ## _attach, \
53985- bfa_ ## __mod ## _detach, \
53986- bfa_ ## __mod ## _start, \
53987- bfa_ ## __mod ## _stop, \
53988- bfa_ ## __mod ## _iocdisable, \
53989+ .meminfo = bfa_ ## __mod ## _meminfo, \
53990+ .attach = bfa_ ## __mod ## _attach, \
53991+ .detach = bfa_ ## __mod ## _detach, \
53992+ .start = bfa_ ## __mod ## _start, \
53993+ .stop = bfa_ ## __mod ## _stop, \
53994+ .iocdisable = bfa_ ## __mod ## _iocdisable, \
53995 }
53996
53997 #define BFA_CACHELINE_SZ (256)
53998diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
53999index 045c4e1..13de803 100644
54000--- a/drivers/scsi/fcoe/fcoe_sysfs.c
54001+++ b/drivers/scsi/fcoe/fcoe_sysfs.c
54002@@ -33,8 +33,8 @@
54003 */
54004 #include "libfcoe.h"
54005
54006-static atomic_t ctlr_num;
54007-static atomic_t fcf_num;
54008+static atomic_unchecked_t ctlr_num;
54009+static atomic_unchecked_t fcf_num;
54010
54011 /*
54012 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
54013@@ -685,7 +685,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
54014 if (!ctlr)
54015 goto out;
54016
54017- ctlr->id = atomic_inc_return(&ctlr_num) - 1;
54018+ ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
54019 ctlr->f = f;
54020 ctlr->mode = FIP_CONN_TYPE_FABRIC;
54021 INIT_LIST_HEAD(&ctlr->fcfs);
54022@@ -902,7 +902,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
54023 fcf->dev.parent = &ctlr->dev;
54024 fcf->dev.bus = &fcoe_bus_type;
54025 fcf->dev.type = &fcoe_fcf_device_type;
54026- fcf->id = atomic_inc_return(&fcf_num) - 1;
54027+ fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
54028 fcf->state = FCOE_FCF_STATE_UNKNOWN;
54029
54030 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
54031@@ -938,8 +938,8 @@ int __init fcoe_sysfs_setup(void)
54032 {
54033 int error;
54034
54035- atomic_set(&ctlr_num, 0);
54036- atomic_set(&fcf_num, 0);
54037+ atomic_set_unchecked(&ctlr_num, 0);
54038+ atomic_set_unchecked(&fcf_num, 0);
54039
54040 error = bus_register(&fcoe_bus_type);
54041 if (error)
54042diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
54043index 8bb173e..20236b4 100644
54044--- a/drivers/scsi/hosts.c
54045+++ b/drivers/scsi/hosts.c
54046@@ -42,7 +42,7 @@
54047 #include "scsi_logging.h"
54048
54049
54050-static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
54051+static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
54052
54053
54054 static void scsi_host_cls_release(struct device *dev)
54055@@ -392,7 +392,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
54056 * subtract one because we increment first then return, but we need to
54057 * know what the next host number was before increment
54058 */
54059- shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
54060+ shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
54061 shost->dma_channel = 0xff;
54062
54063 /* These three are default values which can be overridden */
54064diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
54065index cab4e98..31323f6 100644
54066--- a/drivers/scsi/hpsa.c
54067+++ b/drivers/scsi/hpsa.c
54068@@ -793,10 +793,10 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
54069 struct reply_queue_buffer *rq = &h->reply_queue[q];
54070
54071 if (h->transMethod & CFGTBL_Trans_io_accel1)
54072- return h->access.command_completed(h, q);
54073+ return h->access->command_completed(h, q);
54074
54075 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
54076- return h->access.command_completed(h, q);
54077+ return h->access->command_completed(h, q);
54078
54079 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
54080 a = rq->head[rq->current_entry];
54081@@ -978,7 +978,7 @@ static void __enqueue_cmd_and_start_io(struct ctlr_info *h,
54082 break;
54083 default:
54084 set_performant_mode(h, c, reply_queue);
54085- h->access.submit_command(h, c);
54086+ h->access->submit_command(h, c);
54087 }
54088 }
54089
54090@@ -6343,17 +6343,17 @@ static void __iomem *remap_pci_mem(ulong base, ulong size)
54091
54092 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
54093 {
54094- return h->access.command_completed(h, q);
54095+ return h->access->command_completed(h, q);
54096 }
54097
54098 static inline bool interrupt_pending(struct ctlr_info *h)
54099 {
54100- return h->access.intr_pending(h);
54101+ return h->access->intr_pending(h);
54102 }
54103
54104 static inline long interrupt_not_for_us(struct ctlr_info *h)
54105 {
54106- return (h->access.intr_pending(h) == 0) ||
54107+ return (h->access->intr_pending(h) == 0) ||
54108 (h->interrupts_enabled == 0);
54109 }
54110
54111@@ -7291,7 +7291,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
54112 if (prod_index < 0)
54113 return prod_index;
54114 h->product_name = products[prod_index].product_name;
54115- h->access = *(products[prod_index].access);
54116+ h->access = products[prod_index].access;
54117
54118 h->needs_abort_tags_swizzled =
54119 ctlr_needs_abort_tags_swizzled(h->board_id);
54120@@ -7690,7 +7690,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
54121 unsigned long flags;
54122 u32 lockup_detected;
54123
54124- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54125+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54126 spin_lock_irqsave(&h->lock, flags);
54127 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
54128 if (!lockup_detected) {
54129@@ -7973,7 +7973,7 @@ reinit_after_soft_reset:
54130 }
54131
54132 /* make sure the board interrupts are off */
54133- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54134+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54135
54136 rc = hpsa_request_irqs(h, do_hpsa_intr_msi, do_hpsa_intr_intx);
54137 if (rc)
54138@@ -8032,7 +8032,7 @@ reinit_after_soft_reset:
54139 * fake ones to scoop up any residual completions.
54140 */
54141 spin_lock_irqsave(&h->lock, flags);
54142- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54143+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54144 spin_unlock_irqrestore(&h->lock, flags);
54145 hpsa_free_irqs(h);
54146 rc = hpsa_request_irqs(h, hpsa_msix_discard_completions,
54147@@ -8062,9 +8062,9 @@ reinit_after_soft_reset:
54148 dev_info(&h->pdev->dev, "Board READY.\n");
54149 dev_info(&h->pdev->dev,
54150 "Waiting for stale completions to drain.\n");
54151- h->access.set_intr_mask(h, HPSA_INTR_ON);
54152+ h->access->set_intr_mask(h, HPSA_INTR_ON);
54153 msleep(10000);
54154- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54155+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54156
54157 rc = controller_reset_failed(h->cfgtable);
54158 if (rc)
54159@@ -8089,7 +8089,7 @@ reinit_after_soft_reset:
54160
54161
54162 /* Turn the interrupts on so we can service requests */
54163- h->access.set_intr_mask(h, HPSA_INTR_ON);
54164+ h->access->set_intr_mask(h, HPSA_INTR_ON);
54165
54166 hpsa_hba_inquiry(h);
54167
54168@@ -8107,7 +8107,7 @@ clean9: /* wq, sh, perf, sg, cmd, irq, shost, pci, lu, aer/h */
54169 kfree(h->hba_inquiry_data);
54170 clean7: /* perf, sg, cmd, irq, shost, pci, lu, aer/h */
54171 hpsa_free_performant_mode(h);
54172- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54173+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54174 clean6: /* sg, cmd, irq, pci, lockup, wq/aer/h */
54175 hpsa_free_sg_chain_blocks(h);
54176 clean5: /* cmd, irq, shost, pci, lu, aer/h */
54177@@ -8177,7 +8177,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
54178 * To write all data in the battery backed cache to disks
54179 */
54180 hpsa_flush_cache(h);
54181- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54182+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54183 hpsa_free_irqs(h); /* init_one 4 */
54184 hpsa_disable_interrupt_mode(h); /* pci_init 2 */
54185 }
54186@@ -8309,7 +8309,7 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
54187 CFGTBL_Trans_enable_directed_msix |
54188 (trans_support & (CFGTBL_Trans_io_accel1 |
54189 CFGTBL_Trans_io_accel2));
54190- struct access_method access = SA5_performant_access;
54191+ struct access_method *access = &SA5_performant_access;
54192
54193 /* This is a bit complicated. There are 8 registers on
54194 * the controller which we write to to tell it 8 different
54195@@ -8351,7 +8351,7 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
54196 * perform the superfluous readl() after each command submission.
54197 */
54198 if (trans_support & (CFGTBL_Trans_io_accel1 | CFGTBL_Trans_io_accel2))
54199- access = SA5_performant_access_no_read;
54200+ access = &SA5_performant_access_no_read;
54201
54202 /* Controller spec: zero out this buffer. */
54203 for (i = 0; i < h->nreply_queues; i++)
54204@@ -8381,12 +8381,12 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
54205 * enable outbound interrupt coalescing in accelerator mode;
54206 */
54207 if (trans_support & CFGTBL_Trans_io_accel1) {
54208- access = SA5_ioaccel_mode1_access;
54209+ access = &SA5_ioaccel_mode1_access;
54210 writel(10, &h->cfgtable->HostWrite.CoalIntDelay);
54211 writel(4, &h->cfgtable->HostWrite.CoalIntCount);
54212 } else {
54213 if (trans_support & CFGTBL_Trans_io_accel2) {
54214- access = SA5_ioaccel_mode2_access;
54215+ access = &SA5_ioaccel_mode2_access;
54216 writel(10, &h->cfgtable->HostWrite.CoalIntDelay);
54217 writel(4, &h->cfgtable->HostWrite.CoalIntCount);
54218 }
54219diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
54220index 6ee4da6..dfafb48 100644
54221--- a/drivers/scsi/hpsa.h
54222+++ b/drivers/scsi/hpsa.h
54223@@ -152,7 +152,7 @@ struct ctlr_info {
54224 unsigned int msix_vector;
54225 unsigned int msi_vector;
54226 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
54227- struct access_method access;
54228+ struct access_method *access;
54229 char hba_mode_enabled;
54230
54231 /* queue and queue Info */
54232@@ -542,38 +542,38 @@ static unsigned long SA5_ioaccel_mode1_completed(struct ctlr_info *h, u8 q)
54233 }
54234
54235 static struct access_method SA5_access = {
54236- SA5_submit_command,
54237- SA5_intr_mask,
54238- SA5_intr_pending,
54239- SA5_completed,
54240+ .submit_command = SA5_submit_command,
54241+ .set_intr_mask = SA5_intr_mask,
54242+ .intr_pending = SA5_intr_pending,
54243+ .command_completed = SA5_completed,
54244 };
54245
54246 static struct access_method SA5_ioaccel_mode1_access = {
54247- SA5_submit_command,
54248- SA5_performant_intr_mask,
54249- SA5_ioaccel_mode1_intr_pending,
54250- SA5_ioaccel_mode1_completed,
54251+ .submit_command = SA5_submit_command,
54252+ .set_intr_mask = SA5_performant_intr_mask,
54253+ .intr_pending = SA5_ioaccel_mode1_intr_pending,
54254+ .command_completed = SA5_ioaccel_mode1_completed,
54255 };
54256
54257 static struct access_method SA5_ioaccel_mode2_access = {
54258- SA5_submit_command_ioaccel2,
54259- SA5_performant_intr_mask,
54260- SA5_performant_intr_pending,
54261- SA5_performant_completed,
54262+ .submit_command = SA5_submit_command_ioaccel2,
54263+ .set_intr_mask = SA5_performant_intr_mask,
54264+ .intr_pending = SA5_performant_intr_pending,
54265+ .command_completed = SA5_performant_completed,
54266 };
54267
54268 static struct access_method SA5_performant_access = {
54269- SA5_submit_command,
54270- SA5_performant_intr_mask,
54271- SA5_performant_intr_pending,
54272- SA5_performant_completed,
54273+ .submit_command = SA5_submit_command,
54274+ .set_intr_mask = SA5_performant_intr_mask,
54275+ .intr_pending = SA5_performant_intr_pending,
54276+ .command_completed = SA5_performant_completed,
54277 };
54278
54279 static struct access_method SA5_performant_access_no_read = {
54280- SA5_submit_command_no_read,
54281- SA5_performant_intr_mask,
54282- SA5_performant_intr_pending,
54283- SA5_performant_completed,
54284+ .submit_command = SA5_submit_command_no_read,
54285+ .set_intr_mask = SA5_performant_intr_mask,
54286+ .intr_pending = SA5_performant_intr_pending,
54287+ .command_completed = SA5_performant_completed,
54288 };
54289
54290 struct board_type {
54291diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
54292index 30f9ef0..a1e29ac 100644
54293--- a/drivers/scsi/libfc/fc_exch.c
54294+++ b/drivers/scsi/libfc/fc_exch.c
54295@@ -101,12 +101,12 @@ struct fc_exch_mgr {
54296 u16 pool_max_index;
54297
54298 struct {
54299- atomic_t no_free_exch;
54300- atomic_t no_free_exch_xid;
54301- atomic_t xid_not_found;
54302- atomic_t xid_busy;
54303- atomic_t seq_not_found;
54304- atomic_t non_bls_resp;
54305+ atomic_unchecked_t no_free_exch;
54306+ atomic_unchecked_t no_free_exch_xid;
54307+ atomic_unchecked_t xid_not_found;
54308+ atomic_unchecked_t xid_busy;
54309+ atomic_unchecked_t seq_not_found;
54310+ atomic_unchecked_t non_bls_resp;
54311 } stats;
54312 };
54313
54314@@ -809,7 +809,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
54315 /* allocate memory for exchange */
54316 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
54317 if (!ep) {
54318- atomic_inc(&mp->stats.no_free_exch);
54319+ atomic_inc_unchecked(&mp->stats.no_free_exch);
54320 goto out;
54321 }
54322 memset(ep, 0, sizeof(*ep));
54323@@ -872,7 +872,7 @@ out:
54324 return ep;
54325 err:
54326 spin_unlock_bh(&pool->lock);
54327- atomic_inc(&mp->stats.no_free_exch_xid);
54328+ atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
54329 mempool_free(ep, mp->ep_pool);
54330 return NULL;
54331 }
54332@@ -1021,7 +1021,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
54333 xid = ntohs(fh->fh_ox_id); /* we originated exch */
54334 ep = fc_exch_find(mp, xid);
54335 if (!ep) {
54336- atomic_inc(&mp->stats.xid_not_found);
54337+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54338 reject = FC_RJT_OX_ID;
54339 goto out;
54340 }
54341@@ -1051,7 +1051,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
54342 ep = fc_exch_find(mp, xid);
54343 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
54344 if (ep) {
54345- atomic_inc(&mp->stats.xid_busy);
54346+ atomic_inc_unchecked(&mp->stats.xid_busy);
54347 reject = FC_RJT_RX_ID;
54348 goto rel;
54349 }
54350@@ -1062,7 +1062,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
54351 }
54352 xid = ep->xid; /* get our XID */
54353 } else if (!ep) {
54354- atomic_inc(&mp->stats.xid_not_found);
54355+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54356 reject = FC_RJT_RX_ID; /* XID not found */
54357 goto out;
54358 }
54359@@ -1080,7 +1080,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
54360 } else {
54361 sp = &ep->seq;
54362 if (sp->id != fh->fh_seq_id) {
54363- atomic_inc(&mp->stats.seq_not_found);
54364+ atomic_inc_unchecked(&mp->stats.seq_not_found);
54365 if (f_ctl & FC_FC_END_SEQ) {
54366 /*
54367 * Update sequence_id based on incoming last
54368@@ -1531,22 +1531,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
54369
54370 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
54371 if (!ep) {
54372- atomic_inc(&mp->stats.xid_not_found);
54373+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54374 goto out;
54375 }
54376 if (ep->esb_stat & ESB_ST_COMPLETE) {
54377- atomic_inc(&mp->stats.xid_not_found);
54378+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54379 goto rel;
54380 }
54381 if (ep->rxid == FC_XID_UNKNOWN)
54382 ep->rxid = ntohs(fh->fh_rx_id);
54383 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
54384- atomic_inc(&mp->stats.xid_not_found);
54385+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54386 goto rel;
54387 }
54388 if (ep->did != ntoh24(fh->fh_s_id) &&
54389 ep->did != FC_FID_FLOGI) {
54390- atomic_inc(&mp->stats.xid_not_found);
54391+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54392 goto rel;
54393 }
54394 sof = fr_sof(fp);
54395@@ -1555,7 +1555,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
54396 sp->ssb_stat |= SSB_ST_RESP;
54397 sp->id = fh->fh_seq_id;
54398 } else if (sp->id != fh->fh_seq_id) {
54399- atomic_inc(&mp->stats.seq_not_found);
54400+ atomic_inc_unchecked(&mp->stats.seq_not_found);
54401 goto rel;
54402 }
54403
54404@@ -1618,9 +1618,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
54405 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
54406
54407 if (!sp)
54408- atomic_inc(&mp->stats.xid_not_found);
54409+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54410 else
54411- atomic_inc(&mp->stats.non_bls_resp);
54412+ atomic_inc_unchecked(&mp->stats.non_bls_resp);
54413
54414 fc_frame_free(fp);
54415 }
54416@@ -2261,13 +2261,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
54417
54418 list_for_each_entry(ema, &lport->ema_list, ema_list) {
54419 mp = ema->mp;
54420- st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
54421+ st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
54422 st->fc_no_free_exch_xid +=
54423- atomic_read(&mp->stats.no_free_exch_xid);
54424- st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
54425- st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
54426- st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
54427- st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
54428+ atomic_read_unchecked(&mp->stats.no_free_exch_xid);
54429+ st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
54430+ st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
54431+ st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
54432+ st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
54433 }
54434 }
54435 EXPORT_SYMBOL(fc_exch_update_stats);
54436diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
54437index 9c706d8..d3e3ed2 100644
54438--- a/drivers/scsi/libsas/sas_ata.c
54439+++ b/drivers/scsi/libsas/sas_ata.c
54440@@ -535,7 +535,7 @@ static struct ata_port_operations sas_sata_ops = {
54441 .postreset = ata_std_postreset,
54442 .error_handler = ata_std_error_handler,
54443 .post_internal_cmd = sas_ata_post_internal,
54444- .qc_defer = ata_std_qc_defer,
54445+ .qc_defer = ata_std_qc_defer,
54446 .qc_prep = ata_noop_qc_prep,
54447 .qc_issue = sas_ata_qc_issue,
54448 .qc_fill_rtf = sas_ata_qc_fill_rtf,
54449diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
54450index a5a56fa..43499fd 100644
54451--- a/drivers/scsi/lpfc/lpfc.h
54452+++ b/drivers/scsi/lpfc/lpfc.h
54453@@ -435,7 +435,7 @@ struct lpfc_vport {
54454 struct dentry *debug_nodelist;
54455 struct dentry *vport_debugfs_root;
54456 struct lpfc_debugfs_trc *disc_trc;
54457- atomic_t disc_trc_cnt;
54458+ atomic_unchecked_t disc_trc_cnt;
54459 #endif
54460 uint8_t stat_data_enabled;
54461 uint8_t stat_data_blocked;
54462@@ -885,8 +885,8 @@ struct lpfc_hba {
54463 struct timer_list fabric_block_timer;
54464 unsigned long bit_flags;
54465 #define FABRIC_COMANDS_BLOCKED 0
54466- atomic_t num_rsrc_err;
54467- atomic_t num_cmd_success;
54468+ atomic_unchecked_t num_rsrc_err;
54469+ atomic_unchecked_t num_cmd_success;
54470 unsigned long last_rsrc_error_time;
54471 unsigned long last_ramp_down_time;
54472 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
54473@@ -921,7 +921,7 @@ struct lpfc_hba {
54474
54475 struct dentry *debug_slow_ring_trc;
54476 struct lpfc_debugfs_trc *slow_ring_trc;
54477- atomic_t slow_ring_trc_cnt;
54478+ atomic_unchecked_t slow_ring_trc_cnt;
54479 /* iDiag debugfs sub-directory */
54480 struct dentry *idiag_root;
54481 struct dentry *idiag_pci_cfg;
54482diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
54483index 25aa9b9..d700a65 100644
54484--- a/drivers/scsi/lpfc/lpfc_debugfs.c
54485+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
54486@@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
54487
54488 #include <linux/debugfs.h>
54489
54490-static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
54491+static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
54492 static unsigned long lpfc_debugfs_start_time = 0L;
54493
54494 /* iDiag */
54495@@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
54496 lpfc_debugfs_enable = 0;
54497
54498 len = 0;
54499- index = (atomic_read(&vport->disc_trc_cnt) + 1) &
54500+ index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
54501 (lpfc_debugfs_max_disc_trc - 1);
54502 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
54503 dtp = vport->disc_trc + i;
54504@@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
54505 lpfc_debugfs_enable = 0;
54506
54507 len = 0;
54508- index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
54509+ index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
54510 (lpfc_debugfs_max_slow_ring_trc - 1);
54511 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
54512 dtp = phba->slow_ring_trc + i;
54513@@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
54514 !vport || !vport->disc_trc)
54515 return;
54516
54517- index = atomic_inc_return(&vport->disc_trc_cnt) &
54518+ index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
54519 (lpfc_debugfs_max_disc_trc - 1);
54520 dtp = vport->disc_trc + index;
54521 dtp->fmt = fmt;
54522 dtp->data1 = data1;
54523 dtp->data2 = data2;
54524 dtp->data3 = data3;
54525- dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
54526+ dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
54527 dtp->jif = jiffies;
54528 #endif
54529 return;
54530@@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
54531 !phba || !phba->slow_ring_trc)
54532 return;
54533
54534- index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
54535+ index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
54536 (lpfc_debugfs_max_slow_ring_trc - 1);
54537 dtp = phba->slow_ring_trc + index;
54538 dtp->fmt = fmt;
54539 dtp->data1 = data1;
54540 dtp->data2 = data2;
54541 dtp->data3 = data3;
54542- dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
54543+ dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
54544 dtp->jif = jiffies;
54545 #endif
54546 return;
54547@@ -4268,7 +4268,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
54548 "slow_ring buffer\n");
54549 goto debug_failed;
54550 }
54551- atomic_set(&phba->slow_ring_trc_cnt, 0);
54552+ atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
54553 memset(phba->slow_ring_trc, 0,
54554 (sizeof(struct lpfc_debugfs_trc) *
54555 lpfc_debugfs_max_slow_ring_trc));
54556@@ -4314,7 +4314,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
54557 "buffer\n");
54558 goto debug_failed;
54559 }
54560- atomic_set(&vport->disc_trc_cnt, 0);
54561+ atomic_set_unchecked(&vport->disc_trc_cnt, 0);
54562
54563 snprintf(name, sizeof(name), "discovery_trace");
54564 vport->debug_disc_trc =
54565diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
54566index f962118..6706983 100644
54567--- a/drivers/scsi/lpfc/lpfc_init.c
54568+++ b/drivers/scsi/lpfc/lpfc_init.c
54569@@ -11416,8 +11416,10 @@ lpfc_init(void)
54570 "misc_register returned with status %d", error);
54571
54572 if (lpfc_enable_npiv) {
54573- lpfc_transport_functions.vport_create = lpfc_vport_create;
54574- lpfc_transport_functions.vport_delete = lpfc_vport_delete;
54575+ pax_open_kernel();
54576+ *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
54577+ *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
54578+ pax_close_kernel();
54579 }
54580 lpfc_transport_template =
54581 fc_attach_transport(&lpfc_transport_functions);
54582diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
54583index e5eb40d..056dcd4 100644
54584--- a/drivers/scsi/lpfc/lpfc_scsi.c
54585+++ b/drivers/scsi/lpfc/lpfc_scsi.c
54586@@ -261,7 +261,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
54587 unsigned long expires;
54588
54589 spin_lock_irqsave(&phba->hbalock, flags);
54590- atomic_inc(&phba->num_rsrc_err);
54591+ atomic_inc_unchecked(&phba->num_rsrc_err);
54592 phba->last_rsrc_error_time = jiffies;
54593
54594 expires = phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL;
54595@@ -303,8 +303,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
54596 unsigned long num_rsrc_err, num_cmd_success;
54597 int i;
54598
54599- num_rsrc_err = atomic_read(&phba->num_rsrc_err);
54600- num_cmd_success = atomic_read(&phba->num_cmd_success);
54601+ num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
54602+ num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
54603
54604 /*
54605 * The error and success command counters are global per
54606@@ -331,8 +331,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
54607 }
54608 }
54609 lpfc_destroy_vport_work_array(phba, vports);
54610- atomic_set(&phba->num_rsrc_err, 0);
54611- atomic_set(&phba->num_cmd_success, 0);
54612+ atomic_set_unchecked(&phba->num_rsrc_err, 0);
54613+ atomic_set_unchecked(&phba->num_cmd_success, 0);
54614 }
54615
54616 /**
54617diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
54618index 20c3754..1b05e727 100644
54619--- a/drivers/scsi/megaraid/megaraid_sas.h
54620+++ b/drivers/scsi/megaraid/megaraid_sas.h
54621@@ -1700,7 +1700,7 @@ struct megasas_instance {
54622 s8 init_id;
54623
54624 u16 max_num_sge;
54625- u16 max_fw_cmds;
54626+ u16 max_fw_cmds __intentional_overflow(-1);
54627 u16 max_mfi_cmds;
54628 u16 max_scsi_cmds;
54629 u32 max_sectors_per_req;
54630diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
54631index 3f26147..ee8efd1 100644
54632--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
54633+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
54634@@ -1509,7 +1509,7 @@ _scsih_get_resync(struct device *dev)
54635 {
54636 struct scsi_device *sdev = to_scsi_device(dev);
54637 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
54638- static struct _raid_device *raid_device;
54639+ struct _raid_device *raid_device;
54640 unsigned long flags;
54641 Mpi2RaidVolPage0_t vol_pg0;
54642 Mpi2ConfigReply_t mpi_reply;
54643@@ -1561,7 +1561,7 @@ _scsih_get_state(struct device *dev)
54644 {
54645 struct scsi_device *sdev = to_scsi_device(dev);
54646 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
54647- static struct _raid_device *raid_device;
54648+ struct _raid_device *raid_device;
54649 unsigned long flags;
54650 Mpi2RaidVolPage0_t vol_pg0;
54651 Mpi2ConfigReply_t mpi_reply;
54652@@ -6641,7 +6641,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
54653 Mpi2EventDataIrOperationStatus_t *event_data =
54654 (Mpi2EventDataIrOperationStatus_t *)
54655 fw_event->event_data;
54656- static struct _raid_device *raid_device;
54657+ struct _raid_device *raid_device;
54658 unsigned long flags;
54659 u16 handle;
54660
54661@@ -7112,7 +7112,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
54662 u64 sas_address;
54663 struct _sas_device *sas_device;
54664 struct _sas_node *expander_device;
54665- static struct _raid_device *raid_device;
54666+ struct _raid_device *raid_device;
54667 u8 retry_count;
54668 unsigned long flags;
54669
54670diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
54671index ed31d8c..ab856b3 100644
54672--- a/drivers/scsi/pmcraid.c
54673+++ b/drivers/scsi/pmcraid.c
54674@@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
54675 res->scsi_dev = scsi_dev;
54676 scsi_dev->hostdata = res;
54677 res->change_detected = 0;
54678- atomic_set(&res->read_failures, 0);
54679- atomic_set(&res->write_failures, 0);
54680+ atomic_set_unchecked(&res->read_failures, 0);
54681+ atomic_set_unchecked(&res->write_failures, 0);
54682 rc = 0;
54683 }
54684 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
54685@@ -2640,9 +2640,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
54686
54687 /* If this was a SCSI read/write command keep count of errors */
54688 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
54689- atomic_inc(&res->read_failures);
54690+ atomic_inc_unchecked(&res->read_failures);
54691 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
54692- atomic_inc(&res->write_failures);
54693+ atomic_inc_unchecked(&res->write_failures);
54694
54695 if (!RES_IS_GSCSI(res->cfg_entry) &&
54696 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
54697@@ -3468,7 +3468,7 @@ static int pmcraid_queuecommand_lck(
54698 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
54699 * hrrq_id assigned here in queuecommand
54700 */
54701- ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
54702+ ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
54703 pinstance->num_hrrq;
54704 cmd->cmd_done = pmcraid_io_done;
54705
54706@@ -3782,7 +3782,7 @@ static long pmcraid_ioctl_passthrough(
54707 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
54708 * hrrq_id assigned here in queuecommand
54709 */
54710- ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
54711+ ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
54712 pinstance->num_hrrq;
54713
54714 if (request_size) {
54715@@ -4420,7 +4420,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
54716
54717 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
54718 /* add resources only after host is added into system */
54719- if (!atomic_read(&pinstance->expose_resources))
54720+ if (!atomic_read_unchecked(&pinstance->expose_resources))
54721 return;
54722
54723 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
54724@@ -5237,8 +5237,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
54725 init_waitqueue_head(&pinstance->reset_wait_q);
54726
54727 atomic_set(&pinstance->outstanding_cmds, 0);
54728- atomic_set(&pinstance->last_message_id, 0);
54729- atomic_set(&pinstance->expose_resources, 0);
54730+ atomic_set_unchecked(&pinstance->last_message_id, 0);
54731+ atomic_set_unchecked(&pinstance->expose_resources, 0);
54732
54733 INIT_LIST_HEAD(&pinstance->free_res_q);
54734 INIT_LIST_HEAD(&pinstance->used_res_q);
54735@@ -5951,7 +5951,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
54736 /* Schedule worker thread to handle CCN and take care of adding and
54737 * removing devices to OS
54738 */
54739- atomic_set(&pinstance->expose_resources, 1);
54740+ atomic_set_unchecked(&pinstance->expose_resources, 1);
54741 schedule_work(&pinstance->worker_q);
54742 return rc;
54743
54744diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
54745index e1d150f..6c6df44 100644
54746--- a/drivers/scsi/pmcraid.h
54747+++ b/drivers/scsi/pmcraid.h
54748@@ -748,7 +748,7 @@ struct pmcraid_instance {
54749 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
54750
54751 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
54752- atomic_t last_message_id;
54753+ atomic_unchecked_t last_message_id;
54754
54755 /* configuration table */
54756 struct pmcraid_config_table *cfg_table;
54757@@ -777,7 +777,7 @@ struct pmcraid_instance {
54758 atomic_t outstanding_cmds;
54759
54760 /* should add/delete resources to mid-layer now ?*/
54761- atomic_t expose_resources;
54762+ atomic_unchecked_t expose_resources;
54763
54764
54765
54766@@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
54767 struct pmcraid_config_table_entry_ext cfg_entry_ext;
54768 };
54769 struct scsi_device *scsi_dev; /* Link scsi_device structure */
54770- atomic_t read_failures; /* count of failed READ commands */
54771- atomic_t write_failures; /* count of failed WRITE commands */
54772+ atomic_unchecked_t read_failures; /* count of failed READ commands */
54773+ atomic_unchecked_t write_failures; /* count of failed WRITE commands */
54774
54775 /* To indicate add/delete/modify during CCN */
54776 u8 change_detected;
54777diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
54778index 437254e..a66eb82 100644
54779--- a/drivers/scsi/qla2xxx/qla_attr.c
54780+++ b/drivers/scsi/qla2xxx/qla_attr.c
54781@@ -2192,7 +2192,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
54782 return 0;
54783 }
54784
54785-struct fc_function_template qla2xxx_transport_functions = {
54786+fc_function_template_no_const qla2xxx_transport_functions = {
54787
54788 .show_host_node_name = 1,
54789 .show_host_port_name = 1,
54790@@ -2240,7 +2240,7 @@ struct fc_function_template qla2xxx_transport_functions = {
54791 .bsg_timeout = qla24xx_bsg_timeout,
54792 };
54793
54794-struct fc_function_template qla2xxx_transport_vport_functions = {
54795+fc_function_template_no_const qla2xxx_transport_vport_functions = {
54796
54797 .show_host_node_name = 1,
54798 .show_host_port_name = 1,
54799diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
54800index 7686bfe..4710893 100644
54801--- a/drivers/scsi/qla2xxx/qla_gbl.h
54802+++ b/drivers/scsi/qla2xxx/qla_gbl.h
54803@@ -571,8 +571,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *, size_t);
54804 struct device_attribute;
54805 extern struct device_attribute *qla2x00_host_attrs[];
54806 struct fc_function_template;
54807-extern struct fc_function_template qla2xxx_transport_functions;
54808-extern struct fc_function_template qla2xxx_transport_vport_functions;
54809+extern fc_function_template_no_const qla2xxx_transport_functions;
54810+extern fc_function_template_no_const qla2xxx_transport_vport_functions;
54811 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
54812 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *, bool);
54813 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
54814diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
54815index 8a5cac8..4eba6ab 100644
54816--- a/drivers/scsi/qla2xxx/qla_os.c
54817+++ b/drivers/scsi/qla2xxx/qla_os.c
54818@@ -1435,8 +1435,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
54819 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
54820 /* Ok, a 64bit DMA mask is applicable. */
54821 ha->flags.enable_64bit_addressing = 1;
54822- ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
54823- ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
54824+ pax_open_kernel();
54825+ *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
54826+ *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
54827+ pax_close_kernel();
54828 return;
54829 }
54830 }
54831diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
54832index a7cfc27..151f483 100644
54833--- a/drivers/scsi/qla4xxx/ql4_def.h
54834+++ b/drivers/scsi/qla4xxx/ql4_def.h
54835@@ -306,7 +306,7 @@ struct ddb_entry {
54836 * (4000 only) */
54837 atomic_t relogin_timer; /* Max Time to wait for
54838 * relogin to complete */
54839- atomic_t relogin_retry_count; /* Num of times relogin has been
54840+ atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
54841 * retried */
54842 uint32_t default_time2wait; /* Default Min time between
54843 * relogins (+aens) */
54844diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
54845index 6d25879..3031a9f 100644
54846--- a/drivers/scsi/qla4xxx/ql4_os.c
54847+++ b/drivers/scsi/qla4xxx/ql4_os.c
54848@@ -4491,12 +4491,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
54849 */
54850 if (!iscsi_is_session_online(cls_sess)) {
54851 /* Reset retry relogin timer */
54852- atomic_inc(&ddb_entry->relogin_retry_count);
54853+ atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
54854 DEBUG2(ql4_printk(KERN_INFO, ha,
54855 "%s: index[%d] relogin timed out-retrying"
54856 " relogin (%d), retry (%d)\n", __func__,
54857 ddb_entry->fw_ddb_index,
54858- atomic_read(&ddb_entry->relogin_retry_count),
54859+ atomic_read_unchecked(&ddb_entry->relogin_retry_count),
54860 ddb_entry->default_time2wait + 4));
54861 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
54862 atomic_set(&ddb_entry->retry_relogin_timer,
54863@@ -6604,7 +6604,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
54864
54865 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
54866 atomic_set(&ddb_entry->relogin_timer, 0);
54867- atomic_set(&ddb_entry->relogin_retry_count, 0);
54868+ atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
54869 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
54870 ddb_entry->default_relogin_timeout =
54871 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
54872diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
54873index 207d6a7..bf155b5 100644
54874--- a/drivers/scsi/scsi.c
54875+++ b/drivers/scsi/scsi.c
54876@@ -591,7 +591,7 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
54877
54878 good_bytes = scsi_bufflen(cmd);
54879 if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) {
54880- int old_good_bytes = good_bytes;
54881+ unsigned int old_good_bytes = good_bytes;
54882 drv = scsi_cmd_to_driver(cmd);
54883 if (drv->done)
54884 good_bytes = drv->done(cmd);
54885diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
54886index 448ebda..9bd345f 100644
54887--- a/drivers/scsi/scsi_lib.c
54888+++ b/drivers/scsi/scsi_lib.c
54889@@ -1597,7 +1597,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
54890 shost = sdev->host;
54891 scsi_init_cmd_errh(cmd);
54892 cmd->result = DID_NO_CONNECT << 16;
54893- atomic_inc(&cmd->device->iorequest_cnt);
54894+ atomic_inc_unchecked(&cmd->device->iorequest_cnt);
54895
54896 /*
54897 * SCSI request completion path will do scsi_device_unbusy(),
54898@@ -1620,9 +1620,9 @@ static void scsi_softirq_done(struct request *rq)
54899
54900 INIT_LIST_HEAD(&cmd->eh_entry);
54901
54902- atomic_inc(&cmd->device->iodone_cnt);
54903+ atomic_inc_unchecked(&cmd->device->iodone_cnt);
54904 if (cmd->result)
54905- atomic_inc(&cmd->device->ioerr_cnt);
54906+ atomic_inc_unchecked(&cmd->device->ioerr_cnt);
54907
54908 disposition = scsi_decide_disposition(cmd);
54909 if (disposition != SUCCESS &&
54910@@ -1663,7 +1663,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
54911 struct Scsi_Host *host = cmd->device->host;
54912 int rtn = 0;
54913
54914- atomic_inc(&cmd->device->iorequest_cnt);
54915+ atomic_inc_unchecked(&cmd->device->iorequest_cnt);
54916
54917 /* check if the device is still usable */
54918 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
54919diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
54920index 9ad4116..4e736fc 100644
54921--- a/drivers/scsi/scsi_sysfs.c
54922+++ b/drivers/scsi/scsi_sysfs.c
54923@@ -788,7 +788,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
54924 char *buf) \
54925 { \
54926 struct scsi_device *sdev = to_scsi_device(dev); \
54927- unsigned long long count = atomic_read(&sdev->field); \
54928+ unsigned long long count = atomic_read_unchecked(&sdev->field); \
54929 return snprintf(buf, 20, "0x%llx\n", count); \
54930 } \
54931 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
54932diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
54933index 24eaaf6..de30ec9 100644
54934--- a/drivers/scsi/scsi_transport_fc.c
54935+++ b/drivers/scsi/scsi_transport_fc.c
54936@@ -502,7 +502,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
54937 * Netlink Infrastructure
54938 */
54939
54940-static atomic_t fc_event_seq;
54941+static atomic_unchecked_t fc_event_seq;
54942
54943 /**
54944 * fc_get_event_number - Obtain the next sequential FC event number
54945@@ -515,7 +515,7 @@ static atomic_t fc_event_seq;
54946 u32
54947 fc_get_event_number(void)
54948 {
54949- return atomic_add_return(1, &fc_event_seq);
54950+ return atomic_add_return_unchecked(1, &fc_event_seq);
54951 }
54952 EXPORT_SYMBOL(fc_get_event_number);
54953
54954@@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
54955 {
54956 int error;
54957
54958- atomic_set(&fc_event_seq, 0);
54959+ atomic_set_unchecked(&fc_event_seq, 0);
54960
54961 error = transport_class_register(&fc_host_class);
54962 if (error)
54963@@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
54964 char *cp;
54965
54966 *val = simple_strtoul(buf, &cp, 0);
54967- if ((*cp && (*cp != '\n')) || (*val < 0))
54968+ if (*cp && (*cp != '\n'))
54969 return -EINVAL;
54970 /*
54971 * Check for overflow; dev_loss_tmo is u32
54972diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
54973index 55647aa..b647d05 100644
54974--- a/drivers/scsi/scsi_transport_iscsi.c
54975+++ b/drivers/scsi/scsi_transport_iscsi.c
54976@@ -79,7 +79,7 @@ struct iscsi_internal {
54977 struct transport_container session_cont;
54978 };
54979
54980-static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
54981+static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
54982 static struct workqueue_struct *iscsi_eh_timer_workq;
54983
54984 static DEFINE_IDA(iscsi_sess_ida);
54985@@ -2073,7 +2073,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
54986 int err;
54987
54988 ihost = shost->shost_data;
54989- session->sid = atomic_add_return(1, &iscsi_session_nr);
54990+ session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
54991
54992 if (target_id == ISCSI_MAX_TARGET) {
54993 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
54994@@ -4517,7 +4517,7 @@ static __init int iscsi_transport_init(void)
54995 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
54996 ISCSI_TRANSPORT_VERSION);
54997
54998- atomic_set(&iscsi_session_nr, 0);
54999+ atomic_set_unchecked(&iscsi_session_nr, 0);
55000
55001 err = class_register(&iscsi_transport_class);
55002 if (err)
55003diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
55004index e3cd3ec..00560ec 100644
55005--- a/drivers/scsi/scsi_transport_srp.c
55006+++ b/drivers/scsi/scsi_transport_srp.c
55007@@ -35,7 +35,7 @@
55008 #include "scsi_priv.h"
55009
55010 struct srp_host_attrs {
55011- atomic_t next_port_id;
55012+ atomic_unchecked_t next_port_id;
55013 };
55014 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
55015
55016@@ -105,7 +105,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
55017 struct Scsi_Host *shost = dev_to_shost(dev);
55018 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
55019
55020- atomic_set(&srp_host->next_port_id, 0);
55021+ atomic_set_unchecked(&srp_host->next_port_id, 0);
55022 return 0;
55023 }
55024
55025@@ -752,7 +752,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
55026 rport_fast_io_fail_timedout);
55027 INIT_DELAYED_WORK(&rport->dev_loss_work, rport_dev_loss_timedout);
55028
55029- id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
55030+ id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
55031 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
55032
55033 transport_setup_device(&rport->dev);
55034diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
55035index a20da8c..7f47bac 100644
55036--- a/drivers/scsi/sd.c
55037+++ b/drivers/scsi/sd.c
55038@@ -111,7 +111,7 @@ static int sd_resume(struct device *);
55039 static void sd_rescan(struct device *);
55040 static int sd_init_command(struct scsi_cmnd *SCpnt);
55041 static void sd_uninit_command(struct scsi_cmnd *SCpnt);
55042-static int sd_done(struct scsi_cmnd *);
55043+static unsigned int sd_done(struct scsi_cmnd *);
55044 static int sd_eh_action(struct scsi_cmnd *, int);
55045 static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
55046 static void scsi_disk_release(struct device *cdev);
55047@@ -1646,7 +1646,7 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
55048 *
55049 * Note: potentially run from within an ISR. Must not block.
55050 **/
55051-static int sd_done(struct scsi_cmnd *SCpnt)
55052+static unsigned int sd_done(struct scsi_cmnd *SCpnt)
55053 {
55054 int result = SCpnt->result;
55055 unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt);
55056@@ -2973,7 +2973,7 @@ static int sd_probe(struct device *dev)
55057 sdkp->disk = gd;
55058 sdkp->index = index;
55059 atomic_set(&sdkp->openers, 0);
55060- atomic_set(&sdkp->device->ioerr_cnt, 0);
55061+ atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
55062
55063 if (!sdp->request_queue->rq_timeout) {
55064 if (sdp->type != TYPE_MOD)
55065diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
55066index 9d7b7db..33ecc51 100644
55067--- a/drivers/scsi/sg.c
55068+++ b/drivers/scsi/sg.c
55069@@ -1083,7 +1083,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
55070 sdp->disk->disk_name,
55071 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
55072 NULL,
55073- (char *)arg);
55074+ (char __user *)arg);
55075 case BLKTRACESTART:
55076 return blk_trace_startstop(sdp->device->request_queue, 1);
55077 case BLKTRACESTOP:
55078diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
55079index 8bd54a6..58fa0d6 100644
55080--- a/drivers/scsi/sr.c
55081+++ b/drivers/scsi/sr.c
55082@@ -80,7 +80,7 @@ static DEFINE_MUTEX(sr_mutex);
55083 static int sr_probe(struct device *);
55084 static int sr_remove(struct device *);
55085 static int sr_init_command(struct scsi_cmnd *SCpnt);
55086-static int sr_done(struct scsi_cmnd *);
55087+static unsigned int sr_done(struct scsi_cmnd *);
55088 static int sr_runtime_suspend(struct device *dev);
55089
55090 static struct dev_pm_ops sr_pm_ops = {
55091@@ -312,13 +312,13 @@ do_tur:
55092 * It will be notified on the end of a SCSI read / write, and will take one
55093 * of several actions based on success or failure.
55094 */
55095-static int sr_done(struct scsi_cmnd *SCpnt)
55096+static unsigned int sr_done(struct scsi_cmnd *SCpnt)
55097 {
55098 int result = SCpnt->result;
55099- int this_count = scsi_bufflen(SCpnt);
55100- int good_bytes = (result == 0 ? this_count : 0);
55101- int block_sectors = 0;
55102- long error_sector;
55103+ unsigned int this_count = scsi_bufflen(SCpnt);
55104+ unsigned int good_bytes = (result == 0 ? this_count : 0);
55105+ unsigned int block_sectors = 0;
55106+ sector_t error_sector;
55107 struct scsi_cd *cd = scsi_cd(SCpnt->request->rq_disk);
55108
55109 #ifdef DEBUG
55110@@ -351,9 +351,12 @@ static int sr_done(struct scsi_cmnd *SCpnt)
55111 if (cd->device->sector_size == 2048)
55112 error_sector <<= 2;
55113 error_sector &= ~(block_sectors - 1);
55114- good_bytes = (error_sector -
55115- blk_rq_pos(SCpnt->request)) << 9;
55116- if (good_bytes < 0 || good_bytes >= this_count)
55117+ if (error_sector >= blk_rq_pos(SCpnt->request)) {
55118+ good_bytes = (error_sector -
55119+ blk_rq_pos(SCpnt->request)) << 9;
55120+ if (good_bytes >= this_count)
55121+ good_bytes = 0;
55122+ } else
55123 good_bytes = 0;
55124 /*
55125 * The SCSI specification allows for the value
55126diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
55127index c0d660f..24a5854 100644
55128--- a/drivers/soc/tegra/fuse/fuse-tegra.c
55129+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
55130@@ -71,7 +71,7 @@ static ssize_t fuse_read(struct file *fd, struct kobject *kobj,
55131 return i;
55132 }
55133
55134-static struct bin_attribute fuse_bin_attr = {
55135+static bin_attribute_no_const fuse_bin_attr = {
55136 .attr = { .name = "fuse", .mode = S_IRUGO, },
55137 .read = fuse_read,
55138 };
55139diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
55140index 9ce2f15..1ff9b36 100644
55141--- a/drivers/spi/spi.c
55142+++ b/drivers/spi/spi.c
55143@@ -2215,7 +2215,7 @@ int spi_bus_unlock(struct spi_master *master)
55144 EXPORT_SYMBOL_GPL(spi_bus_unlock);
55145
55146 /* portable code must never pass more than 32 bytes */
55147-#define SPI_BUFSIZ max(32, SMP_CACHE_BYTES)
55148+#define SPI_BUFSIZ max(32UL, SMP_CACHE_BYTES)
55149
55150 static u8 *buf;
55151
55152diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
55153index b41429f..2de5373 100644
55154--- a/drivers/staging/android/timed_output.c
55155+++ b/drivers/staging/android/timed_output.c
55156@@ -25,7 +25,7 @@
55157 #include "timed_output.h"
55158
55159 static struct class *timed_output_class;
55160-static atomic_t device_count;
55161+static atomic_unchecked_t device_count;
55162
55163 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
55164 char *buf)
55165@@ -65,7 +65,7 @@ static int create_timed_output_class(void)
55166 timed_output_class = class_create(THIS_MODULE, "timed_output");
55167 if (IS_ERR(timed_output_class))
55168 return PTR_ERR(timed_output_class);
55169- atomic_set(&device_count, 0);
55170+ atomic_set_unchecked(&device_count, 0);
55171 timed_output_class->dev_groups = timed_output_groups;
55172 }
55173
55174@@ -83,7 +83,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
55175 if (ret < 0)
55176 return ret;
55177
55178- tdev->index = atomic_inc_return(&device_count);
55179+ tdev->index = atomic_inc_return_unchecked(&device_count);
55180 tdev->dev = device_create(timed_output_class, NULL,
55181 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
55182 if (IS_ERR(tdev->dev))
55183diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
55184index 985d94b..49c59fb 100644
55185--- a/drivers/staging/comedi/comedi_fops.c
55186+++ b/drivers/staging/comedi/comedi_fops.c
55187@@ -314,8 +314,8 @@ static void comedi_file_reset(struct file *file)
55188 }
55189 cfp->last_attached = dev->attached;
55190 cfp->last_detach_count = dev->detach_count;
55191- ACCESS_ONCE(cfp->read_subdev) = read_s;
55192- ACCESS_ONCE(cfp->write_subdev) = write_s;
55193+ ACCESS_ONCE_RW(cfp->read_subdev) = read_s;
55194+ ACCESS_ONCE_RW(cfp->write_subdev) = write_s;
55195 }
55196
55197 static void comedi_file_check(struct file *file)
55198@@ -1983,7 +1983,7 @@ static int do_setrsubd_ioctl(struct comedi_device *dev, unsigned long arg,
55199 !(s_old->async->cmd.flags & CMDF_WRITE))
55200 return -EBUSY;
55201
55202- ACCESS_ONCE(cfp->read_subdev) = s_new;
55203+ ACCESS_ONCE_RW(cfp->read_subdev) = s_new;
55204 return 0;
55205 }
55206
55207@@ -2025,7 +2025,7 @@ static int do_setwsubd_ioctl(struct comedi_device *dev, unsigned long arg,
55208 (s_old->async->cmd.flags & CMDF_WRITE))
55209 return -EBUSY;
55210
55211- ACCESS_ONCE(cfp->write_subdev) = s_new;
55212+ ACCESS_ONCE_RW(cfp->write_subdev) = s_new;
55213 return 0;
55214 }
55215
55216diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
55217index b13318a..883e2a8 100644
55218--- a/drivers/staging/dgnc/dgnc_mgmt.c
55219+++ b/drivers/staging/dgnc/dgnc_mgmt.c
55220@@ -115,6 +115,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
55221
55222 spin_lock_irqsave(&dgnc_global_lock, flags);
55223
55224+ memset(&ddi, 0, sizeof(ddi));
55225 ddi.dinfo_nboards = dgnc_NumBoards;
55226 sprintf(ddi.dinfo_version, "%s", DG_PART);
55227
55228diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
55229index 9cc8141..ffd5039 100644
55230--- a/drivers/staging/fbtft/fbtft-core.c
55231+++ b/drivers/staging/fbtft/fbtft-core.c
55232@@ -681,7 +681,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
55233 {
55234 struct fb_info *info;
55235 struct fbtft_par *par;
55236- struct fb_ops *fbops = NULL;
55237+ fb_ops_no_const *fbops = NULL;
55238 struct fb_deferred_io *fbdefio = NULL;
55239 struct fbtft_platform_data *pdata = dev->platform_data;
55240 u8 *vmem = NULL;
55241diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h
55242index 7d817eb..d22e49e 100644
55243--- a/drivers/staging/fbtft/fbtft.h
55244+++ b/drivers/staging/fbtft/fbtft.h
55245@@ -106,7 +106,7 @@ struct fbtft_ops {
55246
55247 int (*set_var)(struct fbtft_par *par);
55248 int (*set_gamma)(struct fbtft_par *par, unsigned long *curves);
55249-};
55250+} __no_const;
55251
55252 /**
55253 * struct fbtft_display - Describes the display properties
55254diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
55255index 001348c..cfaac8a 100644
55256--- a/drivers/staging/gdm724x/gdm_tty.c
55257+++ b/drivers/staging/gdm724x/gdm_tty.c
55258@@ -44,7 +44,7 @@
55259 #define gdm_tty_send_control(n, r, v, d, l) (\
55260 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
55261
55262-#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
55263+#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
55264
55265 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
55266 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
55267diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
55268index b892f2c..9b4898a 100644
55269--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
55270+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
55271@@ -118,7 +118,7 @@ static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev,
55272 int scan_count = bitmap_weight(indio_dev->active_scan_mask,
55273 indio_dev->masklength);
55274
55275- rx_array = kcalloc(4, scan_count, GFP_KERNEL);
55276+ rx_array = kcalloc(scan_count, 4, GFP_KERNEL);
55277 if (!rx_array)
55278 return -ENOMEM;
55279 ret = lis3l02dq_read_all(indio_dev, rx_array);
55280diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
55281index d98e229..9c59bc2 100644
55282--- a/drivers/staging/iio/adc/ad7280a.c
55283+++ b/drivers/staging/iio/adc/ad7280a.c
55284@@ -547,8 +547,8 @@ static int ad7280_attr_init(struct ad7280_state *st)
55285 {
55286 int dev, ch, cnt;
55287
55288- st->iio_attr = kcalloc(2, sizeof(*st->iio_attr) *
55289- (st->slave_num + 1) * AD7280A_CELLS_PER_DEV,
55290+ st->iio_attr = kcalloc(sizeof(*st->iio_attr) *
55291+ (st->slave_num + 1) * AD7280A_CELLS_PER_DEV, 2,
55292 GFP_KERNEL);
55293 if (st->iio_attr == NULL)
55294 return -ENOMEM;
55295diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
55296index de11f1b..f7181cf 100644
55297--- a/drivers/staging/lustre/lnet/selftest/brw_test.c
55298+++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
55299@@ -487,13 +487,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
55300 return 0;
55301 }
55302
55303-sfw_test_client_ops_t brw_test_client;
55304-void brw_init_test_client(void)
55305-{
55306- brw_test_client.tso_init = brw_client_init;
55307- brw_test_client.tso_fini = brw_client_fini;
55308- brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
55309- brw_test_client.tso_done_rpc = brw_client_done_rpc;
55310+sfw_test_client_ops_t brw_test_client = {
55311+ .tso_init = brw_client_init,
55312+ .tso_fini = brw_client_fini,
55313+ .tso_prep_rpc = brw_client_prep_rpc,
55314+ .tso_done_rpc = brw_client_done_rpc,
55315 };
55316
55317 srpc_service_t brw_test_service;
55318diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
55319index 7c5185a..51c2ae7 100644
55320--- a/drivers/staging/lustre/lnet/selftest/framework.c
55321+++ b/drivers/staging/lustre/lnet/selftest/framework.c
55322@@ -1628,12 +1628,10 @@ static srpc_service_t sfw_services[] = {
55323
55324 extern sfw_test_client_ops_t ping_test_client;
55325 extern srpc_service_t ping_test_service;
55326-extern void ping_init_test_client(void);
55327 extern void ping_init_test_service(void);
55328
55329 extern sfw_test_client_ops_t brw_test_client;
55330 extern srpc_service_t brw_test_service;
55331-extern void brw_init_test_client(void);
55332 extern void brw_init_test_service(void);
55333
55334
55335@@ -1675,12 +1673,10 @@ sfw_startup(void)
55336 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
55337 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
55338
55339- brw_init_test_client();
55340 brw_init_test_service();
55341 rc = sfw_register_test(&brw_test_service, &brw_test_client);
55342 LASSERT(rc == 0);
55343
55344- ping_init_test_client();
55345 ping_init_test_service();
55346 rc = sfw_register_test(&ping_test_service, &ping_test_client);
55347 LASSERT(rc == 0);
55348diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
55349index 1dab998..edfe0ac 100644
55350--- a/drivers/staging/lustre/lnet/selftest/ping_test.c
55351+++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
55352@@ -211,14 +211,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
55353 return 0;
55354 }
55355
55356-sfw_test_client_ops_t ping_test_client;
55357-void ping_init_test_client(void)
55358-{
55359- ping_test_client.tso_init = ping_client_init;
55360- ping_test_client.tso_fini = ping_client_fini;
55361- ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
55362- ping_test_client.tso_done_rpc = ping_client_done_rpc;
55363-}
55364+sfw_test_client_ops_t ping_test_client = {
55365+ .tso_init = ping_client_init,
55366+ .tso_fini = ping_client_fini,
55367+ .tso_prep_rpc = ping_client_prep_rpc,
55368+ .tso_done_rpc = ping_client_done_rpc,
55369+};
55370
55371 srpc_service_t ping_test_service;
55372 void ping_init_test_service(void)
55373diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
55374index f6f4c03..cdc3556 100644
55375--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
55376+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
55377@@ -1107,7 +1107,7 @@ struct ldlm_callback_suite {
55378 ldlm_completion_callback lcs_completion;
55379 ldlm_blocking_callback lcs_blocking;
55380 ldlm_glimpse_callback lcs_glimpse;
55381-};
55382+} __no_const;
55383
55384 /* ldlm_lockd.c */
55385 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
55386diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
55387index 55452e5..43b0f2f 100644
55388--- a/drivers/staging/lustre/lustre/include/obd.h
55389+++ b/drivers/staging/lustre/lustre/include/obd.h
55390@@ -1364,7 +1364,7 @@ struct md_ops {
55391 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
55392 * wrapper function in include/linux/obd_class.h.
55393 */
55394-};
55395+} __no_const;
55396
55397 struct lsm_operations {
55398 void (*lsm_free)(struct lov_stripe_md *);
55399diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
55400index a4c252f..b21acac 100644
55401--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
55402+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
55403@@ -258,7 +258,7 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq,
55404 int added = (mode == LCK_NL);
55405 int overlaps = 0;
55406 int splitted = 0;
55407- const struct ldlm_callback_suite null_cbs = { NULL };
55408+ const struct ldlm_callback_suite null_cbs = { };
55409
55410 CDEBUG(D_DLMTRACE,
55411 "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n",
55412diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
55413index e60b2e9..ad9ceb3 100644
55414--- a/drivers/staging/lustre/lustre/libcfs/module.c
55415+++ b/drivers/staging/lustre/lustre/libcfs/module.c
55416@@ -377,11 +377,11 @@ out:
55417
55418
55419 struct cfs_psdev_ops libcfs_psdev_ops = {
55420- libcfs_psdev_open,
55421- libcfs_psdev_release,
55422- NULL,
55423- NULL,
55424- libcfs_ioctl
55425+ .p_open = libcfs_psdev_open,
55426+ .p_close = libcfs_psdev_release,
55427+ .p_read = NULL,
55428+ .p_write = NULL,
55429+ .p_ioctl = libcfs_ioctl
55430 };
55431
55432 static int init_libcfs_module(void)
55433@@ -623,7 +623,7 @@ static int proc_console_max_delay_cs(struct ctl_table *table, int write,
55434 loff_t *ppos)
55435 {
55436 int rc, max_delay_cs;
55437- struct ctl_table dummy = *table;
55438+ ctl_table_no_const dummy = *table;
55439 long d;
55440
55441 dummy.data = &max_delay_cs;
55442@@ -656,7 +656,7 @@ static int proc_console_min_delay_cs(struct ctl_table *table, int write,
55443 loff_t *ppos)
55444 {
55445 int rc, min_delay_cs;
55446- struct ctl_table dummy = *table;
55447+ ctl_table_no_const dummy = *table;
55448 long d;
55449
55450 dummy.data = &min_delay_cs;
55451@@ -688,7 +688,7 @@ static int proc_console_backoff(struct ctl_table *table, int write,
55452 void __user *buffer, size_t *lenp, loff_t *ppos)
55453 {
55454 int rc, backoff;
55455- struct ctl_table dummy = *table;
55456+ ctl_table_no_const dummy = *table;
55457
55458 dummy.data = &backoff;
55459 dummy.proc_handler = &proc_dointvec;
55460diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
55461index 22853d3..cfa3c49 100644
55462--- a/drivers/staging/octeon/ethernet-rx.c
55463+++ b/drivers/staging/octeon/ethernet-rx.c
55464@@ -335,14 +335,14 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
55465 /* Increment RX stats for virtual ports */
55466 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
55467 #ifdef CONFIG_64BIT
55468- atomic64_add(1,
55469+ atomic64_add_unchecked(1,
55470 (atomic64_t *)&priv->stats.rx_packets);
55471- atomic64_add(skb->len,
55472+ atomic64_add_unchecked(skb->len,
55473 (atomic64_t *)&priv->stats.rx_bytes);
55474 #else
55475- atomic_add(1,
55476+ atomic_add_unchecked(1,
55477 (atomic_t *)&priv->stats.rx_packets);
55478- atomic_add(skb->len,
55479+ atomic_add_unchecked(skb->len,
55480 (atomic_t *)&priv->stats.rx_bytes);
55481 #endif
55482 }
55483@@ -354,10 +354,10 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
55484 dev->name);
55485 */
55486 #ifdef CONFIG_64BIT
55487- atomic64_add(1,
55488+ atomic64_add_unchecked(1,
55489 (atomic64_t *)&priv->stats.rx_dropped);
55490 #else
55491- atomic_add(1,
55492+ atomic_add_unchecked(1,
55493 (atomic_t *)&priv->stats.rx_dropped);
55494 #endif
55495 dev_kfree_skb_irq(skb);
55496diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
55497index f9dba23..7bc0ef3 100644
55498--- a/drivers/staging/octeon/ethernet.c
55499+++ b/drivers/staging/octeon/ethernet.c
55500@@ -231,11 +231,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
55501 * since the RX tasklet also increments it.
55502 */
55503 #ifdef CONFIG_64BIT
55504- atomic64_add(rx_status.dropped_packets,
55505- (atomic64_t *)&priv->stats.rx_dropped);
55506+ atomic64_add_unchecked(rx_status.dropped_packets,
55507+ (atomic64_unchecked_t *)&priv->stats.rx_dropped);
55508 #else
55509- atomic_add(rx_status.dropped_packets,
55510- (atomic_t *)&priv->stats.rx_dropped);
55511+ atomic_add_unchecked(rx_status.dropped_packets,
55512+ (atomic_unchecked_t *)&priv->stats.rx_dropped);
55513 #endif
55514 }
55515
55516diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
55517index 3b476d8..f522d68 100644
55518--- a/drivers/staging/rtl8188eu/include/hal_intf.h
55519+++ b/drivers/staging/rtl8188eu/include/hal_intf.h
55520@@ -225,7 +225,7 @@ struct hal_ops {
55521
55522 void (*hal_notch_filter)(struct adapter *adapter, bool enable);
55523 void (*hal_reset_security_engine)(struct adapter *adapter);
55524-};
55525+} __no_const;
55526
55527 enum rt_eeprom_type {
55528 EEPROM_93C46,
55529diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
55530index 070cc03..6806e37 100644
55531--- a/drivers/staging/rtl8712/rtl871x_io.h
55532+++ b/drivers/staging/rtl8712/rtl871x_io.h
55533@@ -108,7 +108,7 @@ struct _io_ops {
55534 u8 *pmem);
55535 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
55536 u8 *pmem);
55537-};
55538+} __no_const;
55539
55540 struct io_req {
55541 struct list_head list;
55542diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
55543index 8e201f1..bf2a28d 100644
55544--- a/drivers/staging/sm750fb/sm750.c
55545+++ b/drivers/staging/sm750fb/sm750.c
55546@@ -775,6 +775,7 @@ static struct fb_ops lynxfb_ops = {
55547 .fb_set_par = lynxfb_ops_set_par,
55548 .fb_setcolreg = lynxfb_ops_setcolreg,
55549 .fb_blank = lynxfb_ops_blank,
55550+ .fb_pan_display = lynxfb_ops_pan_display,
55551 .fb_fillrect = cfb_fillrect,
55552 .fb_imageblit = cfb_imageblit,
55553 .fb_copyarea = cfb_copyarea,
55554@@ -822,8 +823,10 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
55555 par->index = index;
55556 output->channel = &crtc->channel;
55557 sm750fb_set_drv(par);
55558- lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;
55559
55560+ pax_open_kernel();
55561+ *(void **)&lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;
55562+ pax_close_kernel();
55563
55564 /* set current cursor variable and proc pointer,
55565 * must be set after crtc member initialized */
55566@@ -845,7 +848,9 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
55567 crtc->cursor.share = share;
55568 memset_io(crtc->cursor.vstart, 0, crtc->cursor.size);
55569 if (!g_hwcursor) {
55570- lynxfb_ops.fb_cursor = NULL;
55571+ pax_open_kernel();
55572+ *(void **)&lynxfb_ops.fb_cursor = NULL;
55573+ pax_close_kernel();
55574 crtc->cursor.disable(&crtc->cursor);
55575 }
55576
55577@@ -853,9 +858,11 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
55578 /* set info->fbops, must be set before fb_find_mode */
55579 if (!share->accel_off) {
55580 /* use 2d acceleration */
55581- lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
55582- lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
55583- lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit;
55584+ pax_open_kernel();
55585+ *(void **)&lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
55586+ *(void **)&lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
55587+ *(void **)&lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit;
55588+ pax_close_kernel();
55589 }
55590 info->fbops = &lynxfb_ops;
55591
55592diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
55593index 2f12483..6e1b50a 100644
55594--- a/drivers/staging/unisys/visorbus/visorbus_private.h
55595+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
55596@@ -35,7 +35,7 @@ struct visorchipset_busdev_notifiers {
55597 void (*device_destroy)(struct visor_device *bus_info);
55598 void (*device_pause)(struct visor_device *bus_info);
55599 void (*device_resume)(struct visor_device *bus_info);
55600-};
55601+} __no_const;
55602
55603 /* These functions live inside visorchipset, and will be called to indicate
55604 * responses to specific events (by code outside of visorchipset).
55605@@ -50,7 +50,7 @@ struct visorchipset_busdev_responders {
55606 void (*device_destroy)(struct visor_device *p, int response);
55607 void (*device_pause)(struct visor_device *p, int response);
55608 void (*device_resume)(struct visor_device *p, int response);
55609-};
55610+} __no_const;
55611
55612 /** Register functions (in the bus driver) to get called by visorchipset
55613 * whenever a bus or device appears for which this guest is to be the
55614diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
55615index 0edf320..49afe95 100644
55616--- a/drivers/target/sbp/sbp_target.c
55617+++ b/drivers/target/sbp/sbp_target.c
55618@@ -60,7 +60,7 @@ static const u32 sbp_unit_directory_template[] = {
55619
55620 #define SESSION_MAINTENANCE_INTERVAL HZ
55621
55622-static atomic_t login_id = ATOMIC_INIT(0);
55623+static atomic_unchecked_t login_id = ATOMIC_INIT(0);
55624
55625 static void session_maintenance_work(struct work_struct *);
55626 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
55627@@ -441,7 +441,7 @@ static void sbp_management_request_login(
55628 login->login_lun = unpacked_lun;
55629 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
55630 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
55631- login->login_id = atomic_inc_return(&login_id);
55632+ login->login_id = atomic_inc_return_unchecked(&login_id);
55633
55634 login->tgt_agt = sbp_target_agent_register(login);
55635 if (IS_ERR(login->tgt_agt)) {
55636diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
55637index 8f1cd19..ba7a8f1 100644
55638--- a/drivers/target/target_core_device.c
55639+++ b/drivers/target/target_core_device.c
55640@@ -772,7 +772,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
55641 spin_lock_init(&dev->se_tmr_lock);
55642 spin_lock_init(&dev->qf_cmd_lock);
55643 sema_init(&dev->caw_sem, 1);
55644- atomic_set(&dev->dev_ordered_id, 0);
55645+ atomic_set_unchecked(&dev->dev_ordered_id, 0);
55646 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
55647 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
55648 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
55649diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
55650index ce8574b..98d6199 100644
55651--- a/drivers/target/target_core_transport.c
55652+++ b/drivers/target/target_core_transport.c
55653@@ -1181,7 +1181,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
55654 * Used to determine when ORDERED commands should go from
55655 * Dormant to Active status.
55656 */
55657- cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
55658+ cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
55659 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
55660 cmd->se_ordered_id, cmd->sam_task_attr,
55661 dev->transport->name);
55662diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
55663index 42c6f71..1c64309 100644
55664--- a/drivers/thermal/cpu_cooling.c
55665+++ b/drivers/thermal/cpu_cooling.c
55666@@ -838,10 +838,11 @@ __cpufreq_cooling_register(struct device_node *np,
55667 cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus);
55668
55669 if (capacitance) {
55670- cpufreq_cooling_ops.get_requested_power =
55671- cpufreq_get_requested_power;
55672- cpufreq_cooling_ops.state2power = cpufreq_state2power;
55673- cpufreq_cooling_ops.power2state = cpufreq_power2state;
55674+ pax_open_kernel();
55675+ *(void **)&cpufreq_cooling_ops.get_requested_power = cpufreq_get_requested_power;
55676+ *(void **)&cpufreq_cooling_ops.state2power = cpufreq_state2power;
55677+ *(void **)&cpufreq_cooling_ops.power2state = cpufreq_power2state;
55678+ pax_close_kernel();
55679 cpufreq_dev->plat_get_static_power = plat_static_func;
55680
55681 ret = build_dyn_power_table(cpufreq_dev, capacitance);
55682diff --git a/drivers/thermal/int340x_thermal/int3400_thermal.c b/drivers/thermal/int340x_thermal/int3400_thermal.c
55683index 031018e..90981a1 100644
55684--- a/drivers/thermal/int340x_thermal/int3400_thermal.c
55685+++ b/drivers/thermal/int340x_thermal/int3400_thermal.c
55686@@ -272,8 +272,10 @@ static int int3400_thermal_probe(struct platform_device *pdev)
55687 platform_set_drvdata(pdev, priv);
55688
55689 if (priv->uuid_bitmap & 1 << INT3400_THERMAL_PASSIVE_1) {
55690- int3400_thermal_ops.get_mode = int3400_thermal_get_mode;
55691- int3400_thermal_ops.set_mode = int3400_thermal_set_mode;
55692+ pax_open_kernel();
55693+ *(void **)&int3400_thermal_ops.get_mode = int3400_thermal_get_mode;
55694+ *(void **)&int3400_thermal_ops.set_mode = int3400_thermal_set_mode;
55695+ pax_close_kernel();
55696 }
55697 priv->thermal = thermal_zone_device_register("INT3400 Thermal", 0, 0,
55698 priv, &int3400_thermal_ops,
55699diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
55700index b295b2b..f7e2a30 100644
55701--- a/drivers/thermal/of-thermal.c
55702+++ b/drivers/thermal/of-thermal.c
55703@@ -31,6 +31,7 @@
55704 #include <linux/export.h>
55705 #include <linux/string.h>
55706 #include <linux/thermal.h>
55707+#include <linux/mm.h>
55708
55709 #include "thermal_core.h"
55710
55711@@ -417,9 +418,11 @@ thermal_zone_of_add_sensor(struct device_node *zone,
55712 tz->ops = ops;
55713 tz->sensor_data = data;
55714
55715- tzd->ops->get_temp = of_thermal_get_temp;
55716- tzd->ops->get_trend = of_thermal_get_trend;
55717- tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
55718+ pax_open_kernel();
55719+ *(void **)&tzd->ops->get_temp = of_thermal_get_temp;
55720+ *(void **)&tzd->ops->get_trend = of_thermal_get_trend;
55721+ *(void **)&tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
55722+ pax_close_kernel();
55723 mutex_unlock(&tzd->lock);
55724
55725 return tzd;
55726@@ -549,9 +552,11 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
55727 return;
55728
55729 mutex_lock(&tzd->lock);
55730- tzd->ops->get_temp = NULL;
55731- tzd->ops->get_trend = NULL;
55732- tzd->ops->set_emul_temp = NULL;
55733+ pax_open_kernel();
55734+ *(void **)&tzd->ops->get_temp = NULL;
55735+ *(void **)&tzd->ops->get_trend = NULL;
55736+ *(void **)&tzd->ops->set_emul_temp = NULL;
55737+ pax_close_kernel();
55738
55739 tz->ops = NULL;
55740 tz->sensor_data = NULL;
55741diff --git a/drivers/thermal/x86_pkg_temp_thermal.c b/drivers/thermal/x86_pkg_temp_thermal.c
55742index 50d1d2c..39c5ce0 100644
55743--- a/drivers/thermal/x86_pkg_temp_thermal.c
55744+++ b/drivers/thermal/x86_pkg_temp_thermal.c
55745@@ -567,7 +567,7 @@ static int pkg_temp_thermal_cpu_callback(struct notifier_block *nfb,
55746 return NOTIFY_OK;
55747 }
55748
55749-static struct notifier_block pkg_temp_thermal_notifier __refdata = {
55750+static struct notifier_block pkg_temp_thermal_notifier __refconst = {
55751 .notifier_call = pkg_temp_thermal_cpu_callback,
55752 };
55753
55754diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
55755index 87f6578..905c8f8 100644
55756--- a/drivers/tty/cyclades.c
55757+++ b/drivers/tty/cyclades.c
55758@@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
55759 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
55760 info->port.count);
55761 #endif
55762- info->port.count++;
55763+ atomic_inc(&info->port.count);
55764 #ifdef CY_DEBUG_COUNT
55765 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
55766- current->pid, info->port.count);
55767+ current->pid, atomic_read(&info->port.count));
55768 #endif
55769
55770 /*
55771@@ -3970,7 +3970,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
55772 for (j = 0; j < cy_card[i].nports; j++) {
55773 info = &cy_card[i].ports[j];
55774
55775- if (info->port.count) {
55776+ if (atomic_read(&info->port.count)) {
55777 /* XXX is the ldisc num worth this? */
55778 struct tty_struct *tty;
55779 struct tty_ldisc *ld;
55780diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
55781index 4e9c4cc..2199d8f 100644
55782--- a/drivers/tty/hvc/hvc_console.c
55783+++ b/drivers/tty/hvc/hvc_console.c
55784@@ -343,7 +343,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
55785
55786 spin_lock_irqsave(&hp->port.lock, flags);
55787 /* Check and then increment for fast path open. */
55788- if (hp->port.count++ > 0) {
55789+ if (atomic_inc_return(&hp->port.count) > 1) {
55790 spin_unlock_irqrestore(&hp->port.lock, flags);
55791 hvc_kick();
55792 return 0;
55793@@ -398,7 +398,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
55794
55795 spin_lock_irqsave(&hp->port.lock, flags);
55796
55797- if (--hp->port.count == 0) {
55798+ if (atomic_dec_return(&hp->port.count) == 0) {
55799 spin_unlock_irqrestore(&hp->port.lock, flags);
55800 /* We are done with the tty pointer now. */
55801 tty_port_tty_set(&hp->port, NULL);
55802@@ -420,9 +420,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
55803 */
55804 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
55805 } else {
55806- if (hp->port.count < 0)
55807+ if (atomic_read(&hp->port.count) < 0)
55808 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
55809- hp->vtermno, hp->port.count);
55810+ hp->vtermno, atomic_read(&hp->port.count));
55811 spin_unlock_irqrestore(&hp->port.lock, flags);
55812 }
55813 }
55814@@ -452,12 +452,12 @@ static void hvc_hangup(struct tty_struct *tty)
55815 * open->hangup case this can be called after the final close so prevent
55816 * that from happening for now.
55817 */
55818- if (hp->port.count <= 0) {
55819+ if (atomic_read(&hp->port.count) <= 0) {
55820 spin_unlock_irqrestore(&hp->port.lock, flags);
55821 return;
55822 }
55823
55824- hp->port.count = 0;
55825+ atomic_set(&hp->port.count, 0);
55826 spin_unlock_irqrestore(&hp->port.lock, flags);
55827 tty_port_tty_set(&hp->port, NULL);
55828
55829@@ -505,7 +505,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
55830 return -EPIPE;
55831
55832 /* FIXME what's this (unprotected) check for? */
55833- if (hp->port.count <= 0)
55834+ if (atomic_read(&hp->port.count) <= 0)
55835 return -EIO;
55836
55837 spin_lock_irqsave(&hp->lock, flags);
55838diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
55839index f7ff97c..0c0ebbf 100644
55840--- a/drivers/tty/hvc/hvcs.c
55841+++ b/drivers/tty/hvc/hvcs.c
55842@@ -83,6 +83,7 @@
55843 #include <asm/hvcserver.h>
55844 #include <asm/uaccess.h>
55845 #include <asm/vio.h>
55846+#include <asm/local.h>
55847
55848 /*
55849 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
55850@@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
55851
55852 spin_lock_irqsave(&hvcsd->lock, flags);
55853
55854- if (hvcsd->port.count > 0) {
55855+ if (atomic_read(&hvcsd->port.count) > 0) {
55856 spin_unlock_irqrestore(&hvcsd->lock, flags);
55857 printk(KERN_INFO "HVCS: vterm state unchanged. "
55858 "The hvcs device node is still in use.\n");
55859@@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
55860 }
55861 }
55862
55863- hvcsd->port.count = 0;
55864+ atomic_set(&hvcsd->port.count, 0);
55865 hvcsd->port.tty = tty;
55866 tty->driver_data = hvcsd;
55867
55868@@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
55869 unsigned long flags;
55870
55871 spin_lock_irqsave(&hvcsd->lock, flags);
55872- hvcsd->port.count++;
55873+ atomic_inc(&hvcsd->port.count);
55874 hvcsd->todo_mask |= HVCS_SCHED_READ;
55875 spin_unlock_irqrestore(&hvcsd->lock, flags);
55876
55877@@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
55878 hvcsd = tty->driver_data;
55879
55880 spin_lock_irqsave(&hvcsd->lock, flags);
55881- if (--hvcsd->port.count == 0) {
55882+ if (atomic_dec_and_test(&hvcsd->port.count)) {
55883
55884 vio_disable_interrupts(hvcsd->vdev);
55885
55886@@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
55887
55888 free_irq(irq, hvcsd);
55889 return;
55890- } else if (hvcsd->port.count < 0) {
55891+ } else if (atomic_read(&hvcsd->port.count) < 0) {
55892 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
55893 " is missmanaged.\n",
55894- hvcsd->vdev->unit_address, hvcsd->port.count);
55895+ hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
55896 }
55897
55898 spin_unlock_irqrestore(&hvcsd->lock, flags);
55899@@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
55900
55901 spin_lock_irqsave(&hvcsd->lock, flags);
55902 /* Preserve this so that we know how many kref refs to put */
55903- temp_open_count = hvcsd->port.count;
55904+ temp_open_count = atomic_read(&hvcsd->port.count);
55905
55906 /*
55907 * Don't kref put inside the spinlock because the destruction
55908@@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
55909 tty->driver_data = NULL;
55910 hvcsd->port.tty = NULL;
55911
55912- hvcsd->port.count = 0;
55913+ atomic_set(&hvcsd->port.count, 0);
55914
55915 /* This will drop any buffered data on the floor which is OK in a hangup
55916 * scenario. */
55917@@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
55918 * the middle of a write operation? This is a crummy place to do this
55919 * but we want to keep it all in the spinlock.
55920 */
55921- if (hvcsd->port.count <= 0) {
55922+ if (atomic_read(&hvcsd->port.count) <= 0) {
55923 spin_unlock_irqrestore(&hvcsd->lock, flags);
55924 return -ENODEV;
55925 }
55926@@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
55927 {
55928 struct hvcs_struct *hvcsd = tty->driver_data;
55929
55930- if (!hvcsd || hvcsd->port.count <= 0)
55931+ if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
55932 return 0;
55933
55934 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
55935diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
55936index 4190199..06d5bfa 100644
55937--- a/drivers/tty/hvc/hvsi.c
55938+++ b/drivers/tty/hvc/hvsi.c
55939@@ -85,7 +85,7 @@ struct hvsi_struct {
55940 int n_outbuf;
55941 uint32_t vtermno;
55942 uint32_t virq;
55943- atomic_t seqno; /* HVSI packet sequence number */
55944+ atomic_unchecked_t seqno; /* HVSI packet sequence number */
55945 uint16_t mctrl;
55946 uint8_t state; /* HVSI protocol state */
55947 uint8_t flags;
55948@@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
55949
55950 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
55951 packet.hdr.len = sizeof(struct hvsi_query_response);
55952- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
55953+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
55954 packet.verb = VSV_SEND_VERSION_NUMBER;
55955 packet.u.version = HVSI_VERSION;
55956 packet.query_seqno = query_seqno+1;
55957@@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
55958
55959 packet.hdr.type = VS_QUERY_PACKET_HEADER;
55960 packet.hdr.len = sizeof(struct hvsi_query);
55961- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
55962+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
55963 packet.verb = verb;
55964
55965 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
55966@@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
55967 int wrote;
55968
55969 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
55970- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
55971+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
55972 packet.hdr.len = sizeof(struct hvsi_control);
55973 packet.verb = VSV_SET_MODEM_CTL;
55974 packet.mask = HVSI_TSDTR;
55975@@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
55976 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
55977
55978 packet.hdr.type = VS_DATA_PACKET_HEADER;
55979- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
55980+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
55981 packet.hdr.len = count + sizeof(struct hvsi_header);
55982 memcpy(&packet.data, buf, count);
55983
55984@@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
55985 struct hvsi_control packet __ALIGNED__;
55986
55987 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
55988- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
55989+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
55990 packet.hdr.len = 6;
55991 packet.verb = VSV_CLOSE_PROTOCOL;
55992
55993@@ -725,7 +725,7 @@ static int hvsi_open(struct tty_struct *tty, struct file *filp)
55994
55995 tty_port_tty_set(&hp->port, tty);
55996 spin_lock_irqsave(&hp->lock, flags);
55997- hp->port.count++;
55998+ atomic_inc(&hp->port.count);
55999 atomic_set(&hp->seqno, 0);
56000 h_vio_signal(hp->vtermno, VIO_IRQ_ENABLE);
56001 spin_unlock_irqrestore(&hp->lock, flags);
56002@@ -782,7 +782,7 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp)
56003
56004 spin_lock_irqsave(&hp->lock, flags);
56005
56006- if (--hp->port.count == 0) {
56007+ if (atomic_dec_return(&hp->port.count) == 0) {
56008 tty_port_tty_set(&hp->port, NULL);
56009 hp->inbuf_end = hp->inbuf; /* discard remaining partial packets */
56010
56011@@ -815,9 +815,9 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp)
56012
56013 spin_lock_irqsave(&hp->lock, flags);
56014 }
56015- } else if (hp->port.count < 0)
56016+ } else if (atomic_read(&hp->port.count) < 0)
56017 printk(KERN_ERR "hvsi_close %lu: oops, count is %d\n",
56018- hp - hvsi_ports, hp->port.count);
56019+ hp - hvsi_ports, atomic_read(&hp->port.count));
56020
56021 spin_unlock_irqrestore(&hp->lock, flags);
56022 }
56023@@ -832,7 +832,7 @@ static void hvsi_hangup(struct tty_struct *tty)
56024 tty_port_tty_set(&hp->port, NULL);
56025
56026 spin_lock_irqsave(&hp->lock, flags);
56027- hp->port.count = 0;
56028+ atomic_set(&hp->port.count, 0);
56029 hp->n_outbuf = 0;
56030 spin_unlock_irqrestore(&hp->lock, flags);
56031 }
56032diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
56033index a270f04..7c77b5d 100644
56034--- a/drivers/tty/hvc/hvsi_lib.c
56035+++ b/drivers/tty/hvc/hvsi_lib.c
56036@@ -8,7 +8,7 @@
56037
56038 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
56039 {
56040- packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno));
56041+ packet->seqno = cpu_to_be16(atomic_inc_return_unchecked(&pv->seqno));
56042
56043 /* Assumes that always succeeds, works in practice */
56044 return pv->put_chars(pv->termno, (char *)packet, packet->len);
56045@@ -20,7 +20,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
56046
56047 /* Reset state */
56048 pv->established = 0;
56049- atomic_set(&pv->seqno, 0);
56050+ atomic_set_unchecked(&pv->seqno, 0);
56051
56052 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
56053
56054diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
56055index 345cebb..d5a1e9e 100644
56056--- a/drivers/tty/ipwireless/tty.c
56057+++ b/drivers/tty/ipwireless/tty.c
56058@@ -28,6 +28,7 @@
56059 #include <linux/tty_driver.h>
56060 #include <linux/tty_flip.h>
56061 #include <linux/uaccess.h>
56062+#include <asm/local.h>
56063
56064 #include "tty.h"
56065 #include "network.h"
56066@@ -93,10 +94,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
56067 return -ENODEV;
56068
56069 mutex_lock(&tty->ipw_tty_mutex);
56070- if (tty->port.count == 0)
56071+ if (atomic_read(&tty->port.count) == 0)
56072 tty->tx_bytes_queued = 0;
56073
56074- tty->port.count++;
56075+ atomic_inc(&tty->port.count);
56076
56077 tty->port.tty = linux_tty;
56078 linux_tty->driver_data = tty;
56079@@ -112,9 +113,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
56080
56081 static void do_ipw_close(struct ipw_tty *tty)
56082 {
56083- tty->port.count--;
56084-
56085- if (tty->port.count == 0) {
56086+ if (atomic_dec_return(&tty->port.count) == 0) {
56087 struct tty_struct *linux_tty = tty->port.tty;
56088
56089 if (linux_tty != NULL) {
56090@@ -135,7 +134,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
56091 return;
56092
56093 mutex_lock(&tty->ipw_tty_mutex);
56094- if (tty->port.count == 0) {
56095+ if (atomic_read(&tty->port.count) == 0) {
56096 mutex_unlock(&tty->ipw_tty_mutex);
56097 return;
56098 }
56099@@ -158,7 +157,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
56100
56101 mutex_lock(&tty->ipw_tty_mutex);
56102
56103- if (!tty->port.count) {
56104+ if (!atomic_read(&tty->port.count)) {
56105 mutex_unlock(&tty->ipw_tty_mutex);
56106 return;
56107 }
56108@@ -197,7 +196,7 @@ static int ipw_write(struct tty_struct *linux_tty,
56109 return -ENODEV;
56110
56111 mutex_lock(&tty->ipw_tty_mutex);
56112- if (!tty->port.count) {
56113+ if (!atomic_read(&tty->port.count)) {
56114 mutex_unlock(&tty->ipw_tty_mutex);
56115 return -EINVAL;
56116 }
56117@@ -237,7 +236,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
56118 if (!tty)
56119 return -ENODEV;
56120
56121- if (!tty->port.count)
56122+ if (!atomic_read(&tty->port.count))
56123 return -EINVAL;
56124
56125 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
56126@@ -279,7 +278,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
56127 if (!tty)
56128 return 0;
56129
56130- if (!tty->port.count)
56131+ if (!atomic_read(&tty->port.count))
56132 return 0;
56133
56134 return tty->tx_bytes_queued;
56135@@ -360,7 +359,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
56136 if (!tty)
56137 return -ENODEV;
56138
56139- if (!tty->port.count)
56140+ if (!atomic_read(&tty->port.count))
56141 return -EINVAL;
56142
56143 return get_control_lines(tty);
56144@@ -376,7 +375,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
56145 if (!tty)
56146 return -ENODEV;
56147
56148- if (!tty->port.count)
56149+ if (!atomic_read(&tty->port.count))
56150 return -EINVAL;
56151
56152 return set_control_lines(tty, set, clear);
56153@@ -390,7 +389,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
56154 if (!tty)
56155 return -ENODEV;
56156
56157- if (!tty->port.count)
56158+ if (!atomic_read(&tty->port.count))
56159 return -EINVAL;
56160
56161 /* FIXME: Exactly how is the tty object locked here .. */
56162@@ -546,7 +545,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
56163 * are gone */
56164 mutex_lock(&ttyj->ipw_tty_mutex);
56165 }
56166- while (ttyj->port.count)
56167+ while (atomic_read(&ttyj->port.count))
56168 do_ipw_close(ttyj);
56169 ipwireless_disassociate_network_ttys(network,
56170 ttyj->channel_idx);
56171diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
56172index 14c54e0..1efd4f2 100644
56173--- a/drivers/tty/moxa.c
56174+++ b/drivers/tty/moxa.c
56175@@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
56176 }
56177
56178 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
56179- ch->port.count++;
56180+ atomic_inc(&ch->port.count);
56181 tty->driver_data = ch;
56182 tty_port_tty_set(&ch->port, tty);
56183 mutex_lock(&ch->port.mutex);
56184diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
56185index 382d3fc..b16d625 100644
56186--- a/drivers/tty/n_gsm.c
56187+++ b/drivers/tty/n_gsm.c
56188@@ -1644,7 +1644,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
56189 spin_lock_init(&dlci->lock);
56190 mutex_init(&dlci->mutex);
56191 dlci->fifo = &dlci->_fifo;
56192- if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
56193+ if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
56194 kfree(dlci);
56195 return NULL;
56196 }
56197@@ -2957,7 +2957,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
56198 struct gsm_dlci *dlci = tty->driver_data;
56199 struct tty_port *port = &dlci->port;
56200
56201- port->count++;
56202+ atomic_inc(&port->count);
56203 tty_port_tty_set(port, tty);
56204
56205 dlci->modem_rx = 0;
56206diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
56207index afc1879..b605d4b 100644
56208--- a/drivers/tty/n_tty.c
56209+++ b/drivers/tty/n_tty.c
56210@@ -2574,6 +2574,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
56211 {
56212 *ops = tty_ldisc_N_TTY;
56213 ops->owner = NULL;
56214- ops->refcount = ops->flags = 0;
56215+ atomic_set(&ops->refcount, 0);
56216+ ops->flags = 0;
56217 }
56218 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
56219diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
56220index 4d5e840..a2340a6 100644
56221--- a/drivers/tty/pty.c
56222+++ b/drivers/tty/pty.c
56223@@ -849,8 +849,10 @@ static void __init unix98_pty_init(void)
56224 panic("Couldn't register Unix98 pts driver");
56225
56226 /* Now create the /dev/ptmx special device */
56227+ pax_open_kernel();
56228 tty_default_fops(&ptmx_fops);
56229- ptmx_fops.open = ptmx_open;
56230+ *(void **)&ptmx_fops.open = ptmx_open;
56231+ pax_close_kernel();
56232
56233 cdev_init(&ptmx_cdev, &ptmx_fops);
56234 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
56235diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
56236index c8dd8dc..dca6cfd 100644
56237--- a/drivers/tty/rocket.c
56238+++ b/drivers/tty/rocket.c
56239@@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
56240 tty->driver_data = info;
56241 tty_port_tty_set(port, tty);
56242
56243- if (port->count++ == 0) {
56244+ if (atomic_inc_return(&port->count) == 1) {
56245 atomic_inc(&rp_num_ports_open);
56246
56247 #ifdef ROCKET_DEBUG_OPEN
56248@@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
56249 #endif
56250 }
56251 #ifdef ROCKET_DEBUG_OPEN
56252- printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
56253+ printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
56254 #endif
56255
56256 /*
56257@@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
56258 spin_unlock_irqrestore(&info->port.lock, flags);
56259 return;
56260 }
56261- if (info->port.count)
56262+ if (atomic_read(&info->port.count))
56263 atomic_dec(&rp_num_ports_open);
56264 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
56265 spin_unlock_irqrestore(&info->port.lock, flags);
56266diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
56267index c35d96e..f05d689 100644
56268--- a/drivers/tty/serial/8250/8250_core.c
56269+++ b/drivers/tty/serial/8250/8250_core.c
56270@@ -3237,9 +3237,9 @@ static void univ8250_release_port(struct uart_port *port)
56271
56272 static void univ8250_rsa_support(struct uart_ops *ops)
56273 {
56274- ops->config_port = univ8250_config_port;
56275- ops->request_port = univ8250_request_port;
56276- ops->release_port = univ8250_release_port;
56277+ *(void **)&ops->config_port = univ8250_config_port;
56278+ *(void **)&ops->request_port = univ8250_request_port;
56279+ *(void **)&ops->release_port = univ8250_release_port;
56280 }
56281
56282 #else
56283@@ -3282,8 +3282,10 @@ static void __init serial8250_isa_init_ports(void)
56284 }
56285
56286 /* chain base port ops to support Remote Supervisor Adapter */
56287- univ8250_port_ops = *base_ops;
56288+ pax_open_kernel();
56289+ memcpy((void *)&univ8250_port_ops, base_ops, sizeof univ8250_port_ops);
56290 univ8250_rsa_support(&univ8250_port_ops);
56291+ pax_close_kernel();
56292
56293 if (share_irqs)
56294 irqflag = IRQF_SHARED;
56295diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
56296index 536a33b..1b98f43 100644
56297--- a/drivers/tty/serial/ifx6x60.c
56298+++ b/drivers/tty/serial/ifx6x60.c
56299@@ -649,7 +649,7 @@ static void ifx_spi_complete(void *ctx)
56300 struct ifx_spi_device *ifx_dev = ctx;
56301 int length;
56302 int actual_length;
56303- unsigned char more;
56304+ unsigned char more = 0;
56305 unsigned char cts;
56306 int local_write_pending = 0;
56307 int queue_length;
56308diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
56309index e5c42fe..f091b02 100644
56310--- a/drivers/tty/serial/ioc4_serial.c
56311+++ b/drivers/tty/serial/ioc4_serial.c
56312@@ -437,7 +437,7 @@ struct ioc4_soft {
56313 } is_intr_info[MAX_IOC4_INTR_ENTS];
56314
56315 /* Number of entries active in the above array */
56316- atomic_t is_num_intrs;
56317+ atomic_unchecked_t is_num_intrs;
56318 } is_intr_type[IOC4_NUM_INTR_TYPES];
56319
56320 /* is_ir_lock must be held while
56321@@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
56322 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
56323 || (type == IOC4_OTHER_INTR_TYPE)));
56324
56325- i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
56326+ i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
56327 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
56328
56329 /* Save off the lower level interrupt handler */
56330@@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
56331
56332 soft = arg;
56333 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
56334- num_intrs = (int)atomic_read(
56335+ num_intrs = (int)atomic_read_unchecked(
56336 &soft->is_intr_type[intr_type].is_num_intrs);
56337
56338 this_mir = this_ir = pending_intrs(soft, intr_type);
56339diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
56340index 117df15..2f7dfcf 100644
56341--- a/drivers/tty/serial/kgdb_nmi.c
56342+++ b/drivers/tty/serial/kgdb_nmi.c
56343@@ -53,7 +53,9 @@ static int kgdb_nmi_console_setup(struct console *co, char *options)
56344 * I/O utilities that messages sent to the console will automatically
56345 * be displayed on the dbg_io.
56346 */
56347- dbg_io_ops->is_console = true;
56348+ pax_open_kernel();
56349+ *(int *)&dbg_io_ops->is_console = true;
56350+ pax_close_kernel();
56351
56352 return 0;
56353 }
56354diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
56355index a260cde..6b2b5ce 100644
56356--- a/drivers/tty/serial/kgdboc.c
56357+++ b/drivers/tty/serial/kgdboc.c
56358@@ -24,8 +24,9 @@
56359 #define MAX_CONFIG_LEN 40
56360
56361 static struct kgdb_io kgdboc_io_ops;
56362+static struct kgdb_io kgdboc_io_ops_console;
56363
56364-/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
56365+/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
56366 static int configured = -1;
56367
56368 static char config[MAX_CONFIG_LEN];
56369@@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
56370 kgdboc_unregister_kbd();
56371 if (configured == 1)
56372 kgdb_unregister_io_module(&kgdboc_io_ops);
56373+ else if (configured == 2)
56374+ kgdb_unregister_io_module(&kgdboc_io_ops_console);
56375 }
56376
56377 static int configure_kgdboc(void)
56378@@ -160,13 +163,13 @@ static int configure_kgdboc(void)
56379 int err;
56380 char *cptr = config;
56381 struct console *cons;
56382+ int is_console = 0;
56383
56384 err = kgdboc_option_setup(config);
56385 if (err || !strlen(config) || isspace(config[0]))
56386 goto noconfig;
56387
56388 err = -ENODEV;
56389- kgdboc_io_ops.is_console = 0;
56390 kgdb_tty_driver = NULL;
56391
56392 kgdboc_use_kms = 0;
56393@@ -187,7 +190,7 @@ static int configure_kgdboc(void)
56394 int idx;
56395 if (cons->device && cons->device(cons, &idx) == p &&
56396 idx == tty_line) {
56397- kgdboc_io_ops.is_console = 1;
56398+ is_console = 1;
56399 break;
56400 }
56401 cons = cons->next;
56402@@ -197,7 +200,13 @@ static int configure_kgdboc(void)
56403 kgdb_tty_line = tty_line;
56404
56405 do_register:
56406- err = kgdb_register_io_module(&kgdboc_io_ops);
56407+ if (is_console) {
56408+ err = kgdb_register_io_module(&kgdboc_io_ops_console);
56409+ configured = 2;
56410+ } else {
56411+ err = kgdb_register_io_module(&kgdboc_io_ops);
56412+ configured = 1;
56413+ }
56414 if (err)
56415 goto noconfig;
56416
56417@@ -205,8 +214,6 @@ do_register:
56418 if (err)
56419 goto nmi_con_failed;
56420
56421- configured = 1;
56422-
56423 return 0;
56424
56425 nmi_con_failed:
56426@@ -223,7 +230,7 @@ noconfig:
56427 static int __init init_kgdboc(void)
56428 {
56429 /* Already configured? */
56430- if (configured == 1)
56431+ if (configured >= 1)
56432 return 0;
56433
56434 return configure_kgdboc();
56435@@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
56436 if (config[len - 1] == '\n')
56437 config[len - 1] = '\0';
56438
56439- if (configured == 1)
56440+ if (configured >= 1)
56441 cleanup_kgdboc();
56442
56443 /* Go and configure with the new params. */
56444@@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
56445 .post_exception = kgdboc_post_exp_handler,
56446 };
56447
56448+static struct kgdb_io kgdboc_io_ops_console = {
56449+ .name = "kgdboc",
56450+ .read_char = kgdboc_get_char,
56451+ .write_char = kgdboc_put_char,
56452+ .pre_exception = kgdboc_pre_exp_handler,
56453+ .post_exception = kgdboc_post_exp_handler,
56454+ .is_console = 1
56455+};
56456+
56457 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
56458 /* This is only available if kgdboc is a built in for early debugging */
56459 static int __init kgdboc_early_init(char *opt)
56460diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
56461index b73889c..9f74f0a 100644
56462--- a/drivers/tty/serial/msm_serial.c
56463+++ b/drivers/tty/serial/msm_serial.c
56464@@ -1012,7 +1012,7 @@ static struct uart_driver msm_uart_driver = {
56465 .cons = MSM_CONSOLE,
56466 };
56467
56468-static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
56469+static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
56470
56471 static const struct of_device_id msm_uartdm_table[] = {
56472 { .compatible = "qcom,msm-uartdm-v1.1", .data = (void *)UARTDM_1P1 },
56473@@ -1036,7 +1036,7 @@ static int msm_serial_probe(struct platform_device *pdev)
56474 line = pdev->id;
56475
56476 if (line < 0)
56477- line = atomic_inc_return(&msm_uart_next_id) - 1;
56478+ line = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
56479
56480 if (unlikely(line < 0 || line >= UART_NR))
56481 return -ENXIO;
56482diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
56483index 5916311..1e32415 100644
56484--- a/drivers/tty/serial/samsung.c
56485+++ b/drivers/tty/serial/samsung.c
56486@@ -995,11 +995,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
56487 ourport->tx_in_progress = 0;
56488 }
56489
56490+static int s3c64xx_serial_startup(struct uart_port *port);
56491 static int s3c24xx_serial_startup(struct uart_port *port)
56492 {
56493 struct s3c24xx_uart_port *ourport = to_ourport(port);
56494 int ret;
56495
56496+ /* Startup sequence is different for s3c64xx and higher SoC's */
56497+ if (s3c24xx_serial_has_interrupt_mask(port))
56498+ return s3c64xx_serial_startup(port);
56499+
56500 dbg("s3c24xx_serial_startup: port=%p (%08llx,%p)\n",
56501 port, (unsigned long long)port->mapbase, port->membase);
56502
56503@@ -1706,10 +1711,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
56504 /* setup info for port */
56505 port->dev = &platdev->dev;
56506
56507- /* Startup sequence is different for s3c64xx and higher SoC's */
56508- if (s3c24xx_serial_has_interrupt_mask(port))
56509- s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
56510-
56511 port->uartclk = 1;
56512
56513 if (cfg->uart_flags & UPF_CONS_FLOW) {
56514diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
56515index f368520..c7a703a 100644
56516--- a/drivers/tty/serial/serial_core.c
56517+++ b/drivers/tty/serial/serial_core.c
56518@@ -1385,7 +1385,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
56519 state = drv->state + tty->index;
56520 port = &state->port;
56521 spin_lock_irq(&port->lock);
56522- --port->count;
56523+ atomic_dec(&port->count);
56524 spin_unlock_irq(&port->lock);
56525 return;
56526 }
56527@@ -1395,7 +1395,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
56528
56529 pr_debug("uart_close(%d) called\n", uport ? uport->line : -1);
56530
56531- if (!port->count || tty_port_close_start(port, tty, filp) == 0)
56532+ if (!atomic_read(&port->count) || tty_port_close_start(port, tty, filp) == 0)
56533 return;
56534
56535 /*
56536@@ -1520,7 +1520,7 @@ static void uart_hangup(struct tty_struct *tty)
56537 uart_flush_buffer(tty);
56538 uart_shutdown(tty, state);
56539 spin_lock_irqsave(&port->lock, flags);
56540- port->count = 0;
56541+ atomic_set(&port->count, 0);
56542 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
56543 spin_unlock_irqrestore(&port->lock, flags);
56544 tty_port_tty_set(port, NULL);
56545@@ -1607,7 +1607,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
56546 pr_debug("uart_open(%d) called\n", line);
56547
56548 spin_lock_irq(&port->lock);
56549- ++port->count;
56550+ atomic_inc(&port->count);
56551 spin_unlock_irq(&port->lock);
56552
56553 /*
56554diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
56555index b1c6bd3..5f038e2 100644
56556--- a/drivers/tty/serial/uartlite.c
56557+++ b/drivers/tty/serial/uartlite.c
56558@@ -341,13 +341,13 @@ static int ulite_request_port(struct uart_port *port)
56559 return -EBUSY;
56560 }
56561
56562- port->private_data = &uartlite_be;
56563+ port->private_data = (void *)&uartlite_be;
56564 ret = uart_in32(ULITE_CONTROL, port);
56565 uart_out32(ULITE_CONTROL_RST_TX, ULITE_CONTROL, port);
56566 ret = uart_in32(ULITE_STATUS, port);
56567 /* Endianess detection */
56568 if ((ret & ULITE_STATUS_TXEMPTY) != ULITE_STATUS_TXEMPTY)
56569- port->private_data = &uartlite_le;
56570+ port->private_data = (void *)&uartlite_le;
56571
56572 return 0;
56573 }
56574diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
56575index 2fac712..fcd5268 100644
56576--- a/drivers/tty/synclink.c
56577+++ b/drivers/tty/synclink.c
56578@@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
56579
56580 if (debug_level >= DEBUG_LEVEL_INFO)
56581 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
56582- __FILE__,__LINE__, info->device_name, info->port.count);
56583+ __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
56584
56585 if (tty_port_close_start(&info->port, tty, filp) == 0)
56586 goto cleanup;
56587@@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
56588 cleanup:
56589 if (debug_level >= DEBUG_LEVEL_INFO)
56590 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
56591- tty->driver->name, info->port.count);
56592+ tty->driver->name, atomic_read(&info->port.count));
56593
56594 } /* end of mgsl_close() */
56595
56596@@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
56597
56598 mgsl_flush_buffer(tty);
56599 shutdown(info);
56600-
56601- info->port.count = 0;
56602+
56603+ atomic_set(&info->port.count, 0);
56604 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
56605 info->port.tty = NULL;
56606
56607@@ -3296,10 +3296,10 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
56608
56609 if (debug_level >= DEBUG_LEVEL_INFO)
56610 printk("%s(%d):block_til_ready before block on %s count=%d\n",
56611- __FILE__,__LINE__, tty->driver->name, port->count );
56612+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56613
56614 spin_lock_irqsave(&info->irq_spinlock, flags);
56615- port->count--;
56616+ atomic_dec(&port->count);
56617 spin_unlock_irqrestore(&info->irq_spinlock, flags);
56618 port->blocked_open++;
56619
56620@@ -3327,7 +3327,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
56621
56622 if (debug_level >= DEBUG_LEVEL_INFO)
56623 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
56624- __FILE__,__LINE__, tty->driver->name, port->count );
56625+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56626
56627 tty_unlock(tty);
56628 schedule();
56629@@ -3339,12 +3339,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
56630
56631 /* FIXME: Racy on hangup during close wait */
56632 if (!tty_hung_up_p(filp))
56633- port->count++;
56634+ atomic_inc(&port->count);
56635 port->blocked_open--;
56636
56637 if (debug_level >= DEBUG_LEVEL_INFO)
56638 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
56639- __FILE__,__LINE__, tty->driver->name, port->count );
56640+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56641
56642 if (!retval)
56643 port->flags |= ASYNC_NORMAL_ACTIVE;
56644@@ -3396,7 +3396,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
56645
56646 if (debug_level >= DEBUG_LEVEL_INFO)
56647 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
56648- __FILE__,__LINE__,tty->driver->name, info->port.count);
56649+ __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
56650
56651 /* If port is closing, signal caller to try again */
56652 if (info->port.flags & ASYNC_CLOSING){
56653@@ -3415,10 +3415,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
56654 spin_unlock_irqrestore(&info->netlock, flags);
56655 goto cleanup;
56656 }
56657- info->port.count++;
56658+ atomic_inc(&info->port.count);
56659 spin_unlock_irqrestore(&info->netlock, flags);
56660
56661- if (info->port.count == 1) {
56662+ if (atomic_read(&info->port.count) == 1) {
56663 /* 1st open on this device, init hardware */
56664 retval = startup(info);
56665 if (retval < 0)
56666@@ -3442,8 +3442,8 @@ cleanup:
56667 if (retval) {
56668 if (tty->count == 1)
56669 info->port.tty = NULL; /* tty layer will release tty struct */
56670- if(info->port.count)
56671- info->port.count--;
56672+ if (atomic_read(&info->port.count))
56673+ atomic_dec(&info->port.count);
56674 }
56675
56676 return retval;
56677@@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
56678 unsigned short new_crctype;
56679
56680 /* return error if TTY interface open */
56681- if (info->port.count)
56682+ if (atomic_read(&info->port.count))
56683 return -EBUSY;
56684
56685 switch (encoding)
56686@@ -7758,7 +7758,7 @@ static int hdlcdev_open(struct net_device *dev)
56687
56688 /* arbitrate between network and tty opens */
56689 spin_lock_irqsave(&info->netlock, flags);
56690- if (info->port.count != 0 || info->netcount != 0) {
56691+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
56692 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
56693 spin_unlock_irqrestore(&info->netlock, flags);
56694 return -EBUSY;
56695@@ -7844,7 +7844,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
56696 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
56697
56698 /* return error if TTY interface open */
56699- if (info->port.count)
56700+ if (atomic_read(&info->port.count))
56701 return -EBUSY;
56702
56703 if (cmd != SIOCWANDEV)
56704diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
56705index 0ea8eee..b3f1b8f 100644
56706--- a/drivers/tty/synclink_gt.c
56707+++ b/drivers/tty/synclink_gt.c
56708@@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
56709 tty->driver_data = info;
56710 info->port.tty = tty;
56711
56712- DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
56713+ DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
56714
56715 /* If port is closing, signal caller to try again */
56716 if (info->port.flags & ASYNC_CLOSING){
56717@@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
56718 mutex_unlock(&info->port.mutex);
56719 goto cleanup;
56720 }
56721- info->port.count++;
56722+ atomic_inc(&info->port.count);
56723 spin_unlock_irqrestore(&info->netlock, flags);
56724
56725- if (info->port.count == 1) {
56726+ if (atomic_read(&info->port.count) == 1) {
56727 /* 1st open on this device, init hardware */
56728 retval = startup(info);
56729 if (retval < 0) {
56730@@ -715,8 +715,8 @@ cleanup:
56731 if (retval) {
56732 if (tty->count == 1)
56733 info->port.tty = NULL; /* tty layer will release tty struct */
56734- if(info->port.count)
56735- info->port.count--;
56736+ if(atomic_read(&info->port.count))
56737+ atomic_dec(&info->port.count);
56738 }
56739
56740 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
56741@@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
56742
56743 if (sanity_check(info, tty->name, "close"))
56744 return;
56745- DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
56746+ DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
56747
56748 if (tty_port_close_start(&info->port, tty, filp) == 0)
56749 goto cleanup;
56750@@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
56751 tty_port_close_end(&info->port, tty);
56752 info->port.tty = NULL;
56753 cleanup:
56754- DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
56755+ DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
56756 }
56757
56758 static void hangup(struct tty_struct *tty)
56759@@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
56760 shutdown(info);
56761
56762 spin_lock_irqsave(&info->port.lock, flags);
56763- info->port.count = 0;
56764+ atomic_set(&info->port.count, 0);
56765 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
56766 info->port.tty = NULL;
56767 spin_unlock_irqrestore(&info->port.lock, flags);
56768@@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
56769 unsigned short new_crctype;
56770
56771 /* return error if TTY interface open */
56772- if (info->port.count)
56773+ if (atomic_read(&info->port.count))
56774 return -EBUSY;
56775
56776 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
56777@@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
56778
56779 /* arbitrate between network and tty opens */
56780 spin_lock_irqsave(&info->netlock, flags);
56781- if (info->port.count != 0 || info->netcount != 0) {
56782+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
56783 DBGINFO(("%s hdlc_open busy\n", dev->name));
56784 spin_unlock_irqrestore(&info->netlock, flags);
56785 return -EBUSY;
56786@@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
56787 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
56788
56789 /* return error if TTY interface open */
56790- if (info->port.count)
56791+ if (atomic_read(&info->port.count))
56792 return -EBUSY;
56793
56794 if (cmd != SIOCWANDEV)
56795@@ -2417,7 +2417,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
56796 if (port == NULL)
56797 continue;
56798 spin_lock(&port->lock);
56799- if ((port->port.count || port->netcount) &&
56800+ if ((atomic_read(&port->port.count) || port->netcount) &&
56801 port->pending_bh && !port->bh_running &&
56802 !port->bh_requested) {
56803 DBGISR(("%s bh queued\n", port->device_name));
56804@@ -3303,7 +3303,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
56805 add_wait_queue(&port->open_wait, &wait);
56806
56807 spin_lock_irqsave(&info->lock, flags);
56808- port->count--;
56809+ atomic_dec(&port->count);
56810 spin_unlock_irqrestore(&info->lock, flags);
56811 port->blocked_open++;
56812
56813@@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
56814 remove_wait_queue(&port->open_wait, &wait);
56815
56816 if (!tty_hung_up_p(filp))
56817- port->count++;
56818+ atomic_inc(&port->count);
56819 port->blocked_open--;
56820
56821 if (!retval)
56822diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
56823index 08633a8..3d56e14 100644
56824--- a/drivers/tty/synclinkmp.c
56825+++ b/drivers/tty/synclinkmp.c
56826@@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
56827
56828 if (debug_level >= DEBUG_LEVEL_INFO)
56829 printk("%s(%d):%s open(), old ref count = %d\n",
56830- __FILE__,__LINE__,tty->driver->name, info->port.count);
56831+ __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
56832
56833 /* If port is closing, signal caller to try again */
56834 if (info->port.flags & ASYNC_CLOSING){
56835@@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
56836 spin_unlock_irqrestore(&info->netlock, flags);
56837 goto cleanup;
56838 }
56839- info->port.count++;
56840+ atomic_inc(&info->port.count);
56841 spin_unlock_irqrestore(&info->netlock, flags);
56842
56843- if (info->port.count == 1) {
56844+ if (atomic_read(&info->port.count) == 1) {
56845 /* 1st open on this device, init hardware */
56846 retval = startup(info);
56847 if (retval < 0)
56848@@ -796,8 +796,8 @@ cleanup:
56849 if (retval) {
56850 if (tty->count == 1)
56851 info->port.tty = NULL; /* tty layer will release tty struct */
56852- if(info->port.count)
56853- info->port.count--;
56854+ if(atomic_read(&info->port.count))
56855+ atomic_dec(&info->port.count);
56856 }
56857
56858 return retval;
56859@@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
56860
56861 if (debug_level >= DEBUG_LEVEL_INFO)
56862 printk("%s(%d):%s close() entry, count=%d\n",
56863- __FILE__,__LINE__, info->device_name, info->port.count);
56864+ __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
56865
56866 if (tty_port_close_start(&info->port, tty, filp) == 0)
56867 goto cleanup;
56868@@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
56869 cleanup:
56870 if (debug_level >= DEBUG_LEVEL_INFO)
56871 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
56872- tty->driver->name, info->port.count);
56873+ tty->driver->name, atomic_read(&info->port.count));
56874 }
56875
56876 /* Called by tty_hangup() when a hangup is signaled.
56877@@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
56878 shutdown(info);
56879
56880 spin_lock_irqsave(&info->port.lock, flags);
56881- info->port.count = 0;
56882+ atomic_set(&info->port.count, 0);
56883 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
56884 info->port.tty = NULL;
56885 spin_unlock_irqrestore(&info->port.lock, flags);
56886@@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
56887 unsigned short new_crctype;
56888
56889 /* return error if TTY interface open */
56890- if (info->port.count)
56891+ if (atomic_read(&info->port.count))
56892 return -EBUSY;
56893
56894 switch (encoding)
56895@@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
56896
56897 /* arbitrate between network and tty opens */
56898 spin_lock_irqsave(&info->netlock, flags);
56899- if (info->port.count != 0 || info->netcount != 0) {
56900+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
56901 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
56902 spin_unlock_irqrestore(&info->netlock, flags);
56903 return -EBUSY;
56904@@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
56905 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
56906
56907 /* return error if TTY interface open */
56908- if (info->port.count)
56909+ if (atomic_read(&info->port.count))
56910 return -EBUSY;
56911
56912 if (cmd != SIOCWANDEV)
56913@@ -2624,7 +2624,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
56914 * do not request bottom half processing if the
56915 * device is not open in a normal mode.
56916 */
56917- if ( port && (port->port.count || port->netcount) &&
56918+ if ( port && (atomic_read(&port->port.count) || port->netcount) &&
56919 port->pending_bh && !port->bh_running &&
56920 !port->bh_requested ) {
56921 if ( debug_level >= DEBUG_LEVEL_ISR )
56922@@ -3321,10 +3321,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
56923
56924 if (debug_level >= DEBUG_LEVEL_INFO)
56925 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
56926- __FILE__,__LINE__, tty->driver->name, port->count );
56927+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56928
56929 spin_lock_irqsave(&info->lock, flags);
56930- port->count--;
56931+ atomic_dec(&port->count);
56932 spin_unlock_irqrestore(&info->lock, flags);
56933 port->blocked_open++;
56934
56935@@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
56936
56937 if (debug_level >= DEBUG_LEVEL_INFO)
56938 printk("%s(%d):%s block_til_ready() count=%d\n",
56939- __FILE__,__LINE__, tty->driver->name, port->count );
56940+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56941
56942 tty_unlock(tty);
56943 schedule();
56944@@ -3362,12 +3362,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
56945 set_current_state(TASK_RUNNING);
56946 remove_wait_queue(&port->open_wait, &wait);
56947 if (!tty_hung_up_p(filp))
56948- port->count++;
56949+ atomic_inc(&port->count);
56950 port->blocked_open--;
56951
56952 if (debug_level >= DEBUG_LEVEL_INFO)
56953 printk("%s(%d):%s block_til_ready() after, count=%d\n",
56954- __FILE__,__LINE__, tty->driver->name, port->count );
56955+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56956
56957 if (!retval)
56958 port->flags |= ASYNC_NORMAL_ACTIVE;
56959diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
56960index b5b4278..bb9c7b0 100644
56961--- a/drivers/tty/sysrq.c
56962+++ b/drivers/tty/sysrq.c
56963@@ -1072,7 +1072,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
56964 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
56965 size_t count, loff_t *ppos)
56966 {
56967- if (count) {
56968+ if (count && capable(CAP_SYS_ADMIN)) {
56969 char c;
56970
56971 if (get_user(c, buf))
56972diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
56973index 4cf263d..fd011fa 100644
56974--- a/drivers/tty/tty_buffer.c
56975+++ b/drivers/tty/tty_buffer.c
56976@@ -242,7 +242,10 @@ void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld)
56977 atomic_inc(&buf->priority);
56978
56979 mutex_lock(&buf->lock);
56980- while ((next = buf->head->next) != NULL) {
56981+ /* paired w/ release in __tty_buffer_request_room; ensures there are
56982+ * no pending memory accesses to the freed buffer
56983+ */
56984+ while ((next = smp_load_acquire(&buf->head->next)) != NULL) {
56985 tty_buffer_free(port, buf->head);
56986 buf->head = next;
56987 }
56988@@ -290,13 +293,15 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size,
56989 if (n != NULL) {
56990 n->flags = flags;
56991 buf->tail = n;
56992- b->commit = b->used;
56993- /* paired w/ barrier in flush_to_ldisc(); ensures the
56994+ /* paired w/ acquire in flush_to_ldisc(); ensures
56995+ * flush_to_ldisc() sees buffer data.
56996+ */
56997+ smp_store_release(&b->commit, b->used);
56998+ /* paired w/ acquire in flush_to_ldisc(); ensures the
56999 * latest commit value can be read before the head is
57000 * advanced to the next buffer
57001 */
57002- smp_wmb();
57003- b->next = n;
57004+ smp_store_release(&b->next, n);
57005 } else if (change)
57006 size = 0;
57007 else
57008@@ -394,7 +399,10 @@ void tty_schedule_flip(struct tty_port *port)
57009 {
57010 struct tty_bufhead *buf = &port->buf;
57011
57012- buf->tail->commit = buf->tail->used;
57013+ /* paired w/ acquire in flush_to_ldisc(); ensures
57014+ * flush_to_ldisc() sees buffer data.
57015+ */
57016+ smp_store_release(&buf->tail->commit, buf->tail->used);
57017 schedule_work(&buf->work);
57018 }
57019 EXPORT_SYMBOL(tty_schedule_flip);
57020@@ -469,7 +477,7 @@ static void flush_to_ldisc(struct work_struct *work)
57021 struct tty_struct *tty;
57022 struct tty_ldisc *disc;
57023
57024- tty = port->itty;
57025+ tty = READ_ONCE(port->itty);
57026 if (tty == NULL)
57027 return;
57028
57029@@ -488,13 +496,15 @@ static void flush_to_ldisc(struct work_struct *work)
57030 if (atomic_read(&buf->priority))
57031 break;
57032
57033- next = head->next;
57034- /* paired w/ barrier in __tty_buffer_request_room();
57035+ /* paired w/ release in __tty_buffer_request_room();
57036 * ensures commit value read is not stale if the head
57037 * is advancing to the next buffer
57038 */
57039- smp_rmb();
57040- count = head->commit - head->read;
57041+ next = smp_load_acquire(&head->next);
57042+ /* paired w/ release in __tty_buffer_request_room() or in
57043+ * tty_buffer_flush(); ensures we see the committed buffer data
57044+ */
57045+ count = smp_load_acquire(&head->commit) - head->read;
57046 if (!count) {
57047 if (next == NULL) {
57048 check_other_closed(tty);
57049diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
57050index 774df35..62fa290 100644
57051--- a/drivers/tty/tty_io.c
57052+++ b/drivers/tty/tty_io.c
57053@@ -3524,7 +3524,7 @@ EXPORT_SYMBOL(tty_devnum);
57054
57055 void tty_default_fops(struct file_operations *fops)
57056 {
57057- *fops = tty_fops;
57058+ memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
57059 }
57060
57061 /*
57062diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
57063index c07fb5d..942acf7 100644
57064--- a/drivers/tty/tty_ldisc.c
57065+++ b/drivers/tty/tty_ldisc.c
57066@@ -70,7 +70,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
57067 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
57068 tty_ldiscs[disc] = new_ldisc;
57069 new_ldisc->num = disc;
57070- new_ldisc->refcount = 0;
57071+ atomic_set(&new_ldisc->refcount, 0);
57072 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
57073
57074 return ret;
57075@@ -98,7 +98,7 @@ int tty_unregister_ldisc(int disc)
57076 return -EINVAL;
57077
57078 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
57079- if (tty_ldiscs[disc]->refcount)
57080+ if (atomic_read(&tty_ldiscs[disc]->refcount))
57081 ret = -EBUSY;
57082 else
57083 tty_ldiscs[disc] = NULL;
57084@@ -119,7 +119,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
57085 if (ldops) {
57086 ret = ERR_PTR(-EAGAIN);
57087 if (try_module_get(ldops->owner)) {
57088- ldops->refcount++;
57089+ atomic_inc(&ldops->refcount);
57090 ret = ldops;
57091 }
57092 }
57093@@ -132,7 +132,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
57094 unsigned long flags;
57095
57096 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
57097- ldops->refcount--;
57098+ atomic_dec(&ldops->refcount);
57099 module_put(ldops->owner);
57100 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
57101 }
57102diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
57103index 40b31835..94d92ae 100644
57104--- a/drivers/tty/tty_port.c
57105+++ b/drivers/tty/tty_port.c
57106@@ -236,7 +236,7 @@ void tty_port_hangup(struct tty_port *port)
57107 unsigned long flags;
57108
57109 spin_lock_irqsave(&port->lock, flags);
57110- port->count = 0;
57111+ atomic_set(&port->count, 0);
57112 port->flags &= ~ASYNC_NORMAL_ACTIVE;
57113 tty = port->tty;
57114 if (tty)
57115@@ -398,7 +398,7 @@ int tty_port_block_til_ready(struct tty_port *port,
57116
57117 /* The port lock protects the port counts */
57118 spin_lock_irqsave(&port->lock, flags);
57119- port->count--;
57120+ atomic_dec(&port->count);
57121 port->blocked_open++;
57122 spin_unlock_irqrestore(&port->lock, flags);
57123
57124@@ -440,7 +440,7 @@ int tty_port_block_til_ready(struct tty_port *port,
57125 we must not mess that up further */
57126 spin_lock_irqsave(&port->lock, flags);
57127 if (!tty_hung_up_p(filp))
57128- port->count++;
57129+ atomic_inc(&port->count);
57130 port->blocked_open--;
57131 if (retval == 0)
57132 port->flags |= ASYNC_NORMAL_ACTIVE;
57133@@ -476,19 +476,19 @@ int tty_port_close_start(struct tty_port *port,
57134 return 0;
57135
57136 spin_lock_irqsave(&port->lock, flags);
57137- if (tty->count == 1 && port->count != 1) {
57138+ if (tty->count == 1 && atomic_read(&port->count) != 1) {
57139 printk(KERN_WARNING
57140 "tty_port_close_start: tty->count = 1 port count = %d.\n",
57141- port->count);
57142- port->count = 1;
57143+ atomic_read(&port->count));
57144+ atomic_set(&port->count, 1);
57145 }
57146- if (--port->count < 0) {
57147+ if (atomic_dec_return(&port->count) < 0) {
57148 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
57149- port->count);
57150- port->count = 0;
57151+ atomic_read(&port->count));
57152+ atomic_set(&port->count, 0);
57153 }
57154
57155- if (port->count) {
57156+ if (atomic_read(&port->count)) {
57157 spin_unlock_irqrestore(&port->lock, flags);
57158 return 0;
57159 }
57160@@ -590,7 +590,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
57161 struct file *filp)
57162 {
57163 spin_lock_irq(&port->lock);
57164- ++port->count;
57165+ atomic_inc(&port->count);
57166 spin_unlock_irq(&port->lock);
57167 tty_port_tty_set(port, tty);
57168
57169diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
57170index 6f0336f..5818bc1 100644
57171--- a/drivers/tty/vt/keyboard.c
57172+++ b/drivers/tty/vt/keyboard.c
57173@@ -642,6 +642,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
57174 kbd->kbdmode == VC_OFF) &&
57175 value != KVAL(K_SAK))
57176 return; /* SAK is allowed even in raw mode */
57177+
57178+#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
57179+ {
57180+ void *func = fn_handler[value];
57181+ if (func == fn_show_state || func == fn_show_ptregs ||
57182+ func == fn_show_mem)
57183+ return;
57184+ }
57185+#endif
57186+
57187 fn_handler[value](vc);
57188 }
57189
57190@@ -1880,9 +1890,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
57191 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
57192 return -EFAULT;
57193
57194- if (!capable(CAP_SYS_TTY_CONFIG))
57195- perm = 0;
57196-
57197 switch (cmd) {
57198 case KDGKBENT:
57199 /* Ensure another thread doesn't free it under us */
57200@@ -1897,6 +1904,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
57201 spin_unlock_irqrestore(&kbd_event_lock, flags);
57202 return put_user(val, &user_kbe->kb_value);
57203 case KDSKBENT:
57204+ if (!capable(CAP_SYS_TTY_CONFIG))
57205+ perm = 0;
57206+
57207 if (!perm)
57208 return -EPERM;
57209 if (!i && v == K_NOSUCHMAP) {
57210@@ -1987,9 +1997,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
57211 int i, j, k;
57212 int ret;
57213
57214- if (!capable(CAP_SYS_TTY_CONFIG))
57215- perm = 0;
57216-
57217 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
57218 if (!kbs) {
57219 ret = -ENOMEM;
57220@@ -2023,6 +2030,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
57221 kfree(kbs);
57222 return ((p && *p) ? -EOVERFLOW : 0);
57223 case KDSKBSENT:
57224+ if (!capable(CAP_SYS_TTY_CONFIG))
57225+ perm = 0;
57226+
57227 if (!perm) {
57228 ret = -EPERM;
57229 goto reterr;
57230diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
57231index 3257d42..b430b06 100644
57232--- a/drivers/uio/uio.c
57233+++ b/drivers/uio/uio.c
57234@@ -25,6 +25,7 @@
57235 #include <linux/kobject.h>
57236 #include <linux/cdev.h>
57237 #include <linux/uio_driver.h>
57238+#include <asm/local.h>
57239
57240 #define UIO_MAX_DEVICES (1U << MINORBITS)
57241
57242@@ -231,7 +232,7 @@ static ssize_t event_show(struct device *dev,
57243 struct device_attribute *attr, char *buf)
57244 {
57245 struct uio_device *idev = dev_get_drvdata(dev);
57246- return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
57247+ return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
57248 }
57249 static DEVICE_ATTR_RO(event);
57250
57251@@ -393,7 +394,7 @@ void uio_event_notify(struct uio_info *info)
57252 {
57253 struct uio_device *idev = info->uio_dev;
57254
57255- atomic_inc(&idev->event);
57256+ atomic_inc_unchecked(&idev->event);
57257 wake_up_interruptible(&idev->wait);
57258 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
57259 }
57260@@ -446,7 +447,7 @@ static int uio_open(struct inode *inode, struct file *filep)
57261 }
57262
57263 listener->dev = idev;
57264- listener->event_count = atomic_read(&idev->event);
57265+ listener->event_count = atomic_read_unchecked(&idev->event);
57266 filep->private_data = listener;
57267
57268 if (idev->info->open) {
57269@@ -497,7 +498,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
57270 return -EIO;
57271
57272 poll_wait(filep, &idev->wait, wait);
57273- if (listener->event_count != atomic_read(&idev->event))
57274+ if (listener->event_count != atomic_read_unchecked(&idev->event))
57275 return POLLIN | POLLRDNORM;
57276 return 0;
57277 }
57278@@ -522,7 +523,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
57279 do {
57280 set_current_state(TASK_INTERRUPTIBLE);
57281
57282- event_count = atomic_read(&idev->event);
57283+ event_count = atomic_read_unchecked(&idev->event);
57284 if (event_count != listener->event_count) {
57285 if (copy_to_user(buf, &event_count, count))
57286 retval = -EFAULT;
57287@@ -579,9 +580,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
57288 static int uio_find_mem_index(struct vm_area_struct *vma)
57289 {
57290 struct uio_device *idev = vma->vm_private_data;
57291+ unsigned long size;
57292
57293 if (vma->vm_pgoff < MAX_UIO_MAPS) {
57294- if (idev->info->mem[vma->vm_pgoff].size == 0)
57295+ size = idev->info->mem[vma->vm_pgoff].size;
57296+ if (size == 0)
57297+ return -1;
57298+ if (vma->vm_end - vma->vm_start > size)
57299 return -1;
57300 return (int)vma->vm_pgoff;
57301 }
57302@@ -813,7 +818,7 @@ int __uio_register_device(struct module *owner,
57303 idev->owner = owner;
57304 idev->info = info;
57305 init_waitqueue_head(&idev->wait);
57306- atomic_set(&idev->event, 0);
57307+ atomic_set_unchecked(&idev->event, 0);
57308
57309 ret = uio_get_minor(idev);
57310 if (ret)
57311diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
57312index 813d4d3..a71934f 100644
57313--- a/drivers/usb/atm/cxacru.c
57314+++ b/drivers/usb/atm/cxacru.c
57315@@ -472,7 +472,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
57316 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
57317 if (ret < 2)
57318 return -EINVAL;
57319- if (index < 0 || index > 0x7f)
57320+ if (index > 0x7f)
57321 return -EINVAL;
57322 pos += tmp;
57323
57324diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
57325index db322d9..f0f4bc1 100644
57326--- a/drivers/usb/atm/usbatm.c
57327+++ b/drivers/usb/atm/usbatm.c
57328@@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57329 if (printk_ratelimit())
57330 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
57331 __func__, vpi, vci);
57332- atomic_inc(&vcc->stats->rx_err);
57333+ atomic_inc_unchecked(&vcc->stats->rx_err);
57334 return;
57335 }
57336
57337@@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57338 if (length > ATM_MAX_AAL5_PDU) {
57339 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
57340 __func__, length, vcc);
57341- atomic_inc(&vcc->stats->rx_err);
57342+ atomic_inc_unchecked(&vcc->stats->rx_err);
57343 goto out;
57344 }
57345
57346@@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57347 if (sarb->len < pdu_length) {
57348 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
57349 __func__, pdu_length, sarb->len, vcc);
57350- atomic_inc(&vcc->stats->rx_err);
57351+ atomic_inc_unchecked(&vcc->stats->rx_err);
57352 goto out;
57353 }
57354
57355 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
57356 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
57357 __func__, vcc);
57358- atomic_inc(&vcc->stats->rx_err);
57359+ atomic_inc_unchecked(&vcc->stats->rx_err);
57360 goto out;
57361 }
57362
57363@@ -387,7 +387,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57364 if (printk_ratelimit())
57365 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
57366 __func__, length);
57367- atomic_inc(&vcc->stats->rx_drop);
57368+ atomic_inc_unchecked(&vcc->stats->rx_drop);
57369 goto out;
57370 }
57371
57372@@ -415,7 +415,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57373
57374 vcc->push(vcc, skb);
57375
57376- atomic_inc(&vcc->stats->rx);
57377+ atomic_inc_unchecked(&vcc->stats->rx);
57378 out:
57379 skb_trim(sarb, 0);
57380 }
57381@@ -613,7 +613,7 @@ static void usbatm_tx_process(unsigned long data)
57382 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
57383
57384 usbatm_pop(vcc, skb);
57385- atomic_inc(&vcc->stats->tx);
57386+ atomic_inc_unchecked(&vcc->stats->tx);
57387
57388 skb = skb_dequeue(&instance->sndqueue);
57389 }
57390@@ -757,11 +757,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t *pos, char *page
57391 if (!left--)
57392 return sprintf(page,
57393 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
57394- atomic_read(&atm_dev->stats.aal5.tx),
57395- atomic_read(&atm_dev->stats.aal5.tx_err),
57396- atomic_read(&atm_dev->stats.aal5.rx),
57397- atomic_read(&atm_dev->stats.aal5.rx_err),
57398- atomic_read(&atm_dev->stats.aal5.rx_drop));
57399+ atomic_read_unchecked(&atm_dev->stats.aal5.tx),
57400+ atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
57401+ atomic_read_unchecked(&atm_dev->stats.aal5.rx),
57402+ atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
57403+ atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
57404
57405 if (!left--) {
57406 if (instance->disconnected)
57407diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
57408index 2a3bbdf..91d72cf 100644
57409--- a/drivers/usb/core/devices.c
57410+++ b/drivers/usb/core/devices.c
57411@@ -126,7 +126,7 @@ static const char format_endpt[] =
57412 * time it gets called.
57413 */
57414 static struct device_connect_event {
57415- atomic_t count;
57416+ atomic_unchecked_t count;
57417 wait_queue_head_t wait;
57418 } device_event = {
57419 .count = ATOMIC_INIT(1),
57420@@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
57421
57422 void usbfs_conn_disc_event(void)
57423 {
57424- atomic_add(2, &device_event.count);
57425+ atomic_add_unchecked(2, &device_event.count);
57426 wake_up(&device_event.wait);
57427 }
57428
57429@@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
57430
57431 poll_wait(file, &device_event.wait, wait);
57432
57433- event_count = atomic_read(&device_event.count);
57434+ event_count = atomic_read_unchecked(&device_event.count);
57435 if (file->f_version != event_count) {
57436 file->f_version = event_count;
57437 return POLLIN | POLLRDNORM;
57438diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
57439index 986abde..2af59b11 100644
57440--- a/drivers/usb/core/devio.c
57441+++ b/drivers/usb/core/devio.c
57442@@ -187,7 +187,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
57443 struct usb_dev_state *ps = file->private_data;
57444 struct usb_device *dev = ps->dev;
57445 ssize_t ret = 0;
57446- unsigned len;
57447+ size_t len;
57448 loff_t pos;
57449 int i;
57450
57451@@ -229,22 +229,22 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
57452 for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
57453 struct usb_config_descriptor *config =
57454 (struct usb_config_descriptor *)dev->rawdescriptors[i];
57455- unsigned int length = le16_to_cpu(config->wTotalLength);
57456+ size_t length = le16_to_cpu(config->wTotalLength);
57457
57458 if (*ppos < pos + length) {
57459
57460 /* The descriptor may claim to be longer than it
57461 * really is. Here is the actual allocated length. */
57462- unsigned alloclen =
57463+ size_t alloclen =
57464 le16_to_cpu(dev->config[i].desc.wTotalLength);
57465
57466- len = length - (*ppos - pos);
57467+ len = length + pos - *ppos;
57468 if (len > nbytes)
57469 len = nbytes;
57470
57471 /* Simply don't write (skip over) unallocated parts */
57472 if (alloclen > (*ppos - pos)) {
57473- alloclen -= (*ppos - pos);
57474+ alloclen = alloclen + pos - *ppos;
57475 if (copy_to_user(buf,
57476 dev->rawdescriptors[i] + (*ppos - pos),
57477 min(len, alloclen))) {
57478@@ -1499,7 +1499,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
57479 }
57480 }
57481 as->urb->dev = ps->dev;
57482- as->urb->pipe = (uurb->type << 30) |
57483+ as->urb->pipe = ((unsigned int)uurb->type << 30) |
57484 __create_pipe(ps->dev, uurb->endpoint & 0xf) |
57485 (uurb->endpoint & USB_DIR_IN);
57486
57487diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
57488index cbcd092..e783f87 100644
57489--- a/drivers/usb/core/hcd.c
57490+++ b/drivers/usb/core/hcd.c
57491@@ -1554,7 +1554,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
57492 */
57493 usb_get_urb(urb);
57494 atomic_inc(&urb->use_count);
57495- atomic_inc(&urb->dev->urbnum);
57496+ atomic_inc_unchecked(&urb->dev->urbnum);
57497 usbmon_urb_submit(&hcd->self, urb);
57498
57499 /* NOTE requirements on root-hub callers (usbfs and the hub
57500@@ -1581,7 +1581,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
57501 urb->hcpriv = NULL;
57502 INIT_LIST_HEAD(&urb->urb_list);
57503 atomic_dec(&urb->use_count);
57504- atomic_dec(&urb->dev->urbnum);
57505+ atomic_dec_unchecked(&urb->dev->urbnum);
57506 if (atomic_read(&urb->reject))
57507 wake_up(&usb_kill_urb_queue);
57508 usb_put_urb(urb);
57509diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
57510index 73dfa19..c22f1e43 100644
57511--- a/drivers/usb/core/hub.c
57512+++ b/drivers/usb/core/hub.c
57513@@ -26,6 +26,7 @@
57514 #include <linux/mutex.h>
57515 #include <linux/random.h>
57516 #include <linux/pm_qos.h>
57517+#include <linux/grsecurity.h>
57518
57519 #include <asm/uaccess.h>
57520 #include <asm/byteorder.h>
57521@@ -4655,6 +4656,10 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
57522 goto done;
57523 return;
57524 }
57525+
57526+ if (gr_handle_new_usb())
57527+ goto done;
57528+
57529 if (hub_is_superspeed(hub->hdev))
57530 unit_load = 150;
57531 else
57532diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
57533index d269738..7340cd7 100644
57534--- a/drivers/usb/core/sysfs.c
57535+++ b/drivers/usb/core/sysfs.c
57536@@ -244,7 +244,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
57537 struct usb_device *udev;
57538
57539 udev = to_usb_device(dev);
57540- return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
57541+ return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
57542 }
57543 static DEVICE_ATTR_RO(urbnum);
57544
57545diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
57546index 8d5b2f4..3896940 100644
57547--- a/drivers/usb/core/usb.c
57548+++ b/drivers/usb/core/usb.c
57549@@ -447,7 +447,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
57550 set_dev_node(&dev->dev, dev_to_node(bus->controller));
57551 dev->state = USB_STATE_ATTACHED;
57552 dev->lpm_disable_count = 1;
57553- atomic_set(&dev->urbnum, 0);
57554+ atomic_set_unchecked(&dev->urbnum, 0);
57555
57556 INIT_LIST_HEAD(&dev->ep0.urb_list);
57557 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
57558diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
57559index 8cfc319..4868255 100644
57560--- a/drivers/usb/early/ehci-dbgp.c
57561+++ b/drivers/usb/early/ehci-dbgp.c
57562@@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
57563
57564 #ifdef CONFIG_KGDB
57565 static struct kgdb_io kgdbdbgp_io_ops;
57566-#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
57567+static struct kgdb_io kgdbdbgp_io_ops_console;
57568+#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
57569 #else
57570 #define dbgp_kgdb_mode (0)
57571 #endif
57572@@ -1043,6 +1044,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
57573 .write_char = kgdbdbgp_write_char,
57574 };
57575
57576+static struct kgdb_io kgdbdbgp_io_ops_console = {
57577+ .name = "kgdbdbgp",
57578+ .read_char = kgdbdbgp_read_char,
57579+ .write_char = kgdbdbgp_write_char,
57580+ .is_console = 1
57581+};
57582+
57583 static int kgdbdbgp_wait_time;
57584
57585 static int __init kgdbdbgp_parse_config(char *str)
57586@@ -1058,8 +1066,10 @@ static int __init kgdbdbgp_parse_config(char *str)
57587 ptr++;
57588 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
57589 }
57590- kgdb_register_io_module(&kgdbdbgp_io_ops);
57591- kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
57592+ if (early_dbgp_console.index != -1)
57593+ kgdb_register_io_module(&kgdbdbgp_io_ops_console);
57594+ else
57595+ kgdb_register_io_module(&kgdbdbgp_io_ops);
57596
57597 return 0;
57598 }
57599diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c
57600index 7856b33..8b7fe09 100644
57601--- a/drivers/usb/gadget/function/f_uac1.c
57602+++ b/drivers/usb/gadget/function/f_uac1.c
57603@@ -14,6 +14,7 @@
57604 #include <linux/module.h>
57605 #include <linux/device.h>
57606 #include <linux/atomic.h>
57607+#include <linux/module.h>
57608
57609 #include "u_uac1.h"
57610
57611diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
57612index 7ee05793..2e31e99 100644
57613--- a/drivers/usb/gadget/function/u_serial.c
57614+++ b/drivers/usb/gadget/function/u_serial.c
57615@@ -732,9 +732,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
57616 spin_lock_irq(&port->port_lock);
57617
57618 /* already open? Great. */
57619- if (port->port.count) {
57620+ if (atomic_read(&port->port.count)) {
57621 status = 0;
57622- port->port.count++;
57623+ atomic_inc(&port->port.count);
57624
57625 /* currently opening/closing? wait ... */
57626 } else if (port->openclose) {
57627@@ -793,7 +793,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
57628 tty->driver_data = port;
57629 port->port.tty = tty;
57630
57631- port->port.count = 1;
57632+ atomic_set(&port->port.count, 1);
57633 port->openclose = false;
57634
57635 /* if connected, start the I/O stream */
57636@@ -835,11 +835,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
57637
57638 spin_lock_irq(&port->port_lock);
57639
57640- if (port->port.count != 1) {
57641- if (port->port.count == 0)
57642+ if (atomic_read(&port->port.count) != 1) {
57643+ if (atomic_read(&port->port.count) == 0)
57644 WARN_ON(1);
57645 else
57646- --port->port.count;
57647+ atomic_dec(&port->port.count);
57648 goto exit;
57649 }
57650
57651@@ -849,7 +849,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
57652 * and sleep if necessary
57653 */
57654 port->openclose = true;
57655- port->port.count = 0;
57656+ atomic_set(&port->port.count, 0);
57657
57658 gser = port->port_usb;
57659 if (gser && gser->disconnect)
57660@@ -1065,7 +1065,7 @@ static int gs_closed(struct gs_port *port)
57661 int cond;
57662
57663 spin_lock_irq(&port->port_lock);
57664- cond = (port->port.count == 0) && !port->openclose;
57665+ cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
57666 spin_unlock_irq(&port->port_lock);
57667 return cond;
57668 }
57669@@ -1208,7 +1208,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
57670 /* if it's already open, start I/O ... and notify the serial
57671 * protocol about open/close status (connect/disconnect).
57672 */
57673- if (port->port.count) {
57674+ if (atomic_read(&port->port.count)) {
57675 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
57676 gs_start_io(port);
57677 if (gser->connect)
57678@@ -1255,7 +1255,7 @@ void gserial_disconnect(struct gserial *gser)
57679
57680 port->port_usb = NULL;
57681 gser->ioport = NULL;
57682- if (port->port.count > 0 || port->openclose) {
57683+ if (atomic_read(&port->port.count) > 0 || port->openclose) {
57684 wake_up_interruptible(&port->drain_wait);
57685 if (port->port.tty)
57686 tty_hangup(port->port.tty);
57687@@ -1271,7 +1271,7 @@ void gserial_disconnect(struct gserial *gser)
57688
57689 /* finally, free any unused/unusable I/O buffers */
57690 spin_lock_irqsave(&port->port_lock, flags);
57691- if (port->port.count == 0 && !port->openclose)
57692+ if (atomic_read(&port->port.count) == 0 && !port->openclose)
57693 gs_buf_free(&port->port_write_buf);
57694 gs_free_requests(gser->out, &port->read_pool, NULL);
57695 gs_free_requests(gser->out, &port->read_queue, NULL);
57696diff --git a/drivers/usb/gadget/function/u_uac1.c b/drivers/usb/gadget/function/u_uac1.c
57697index c78c841..48fd281 100644
57698--- a/drivers/usb/gadget/function/u_uac1.c
57699+++ b/drivers/usb/gadget/function/u_uac1.c
57700@@ -17,6 +17,7 @@
57701 #include <linux/ctype.h>
57702 #include <linux/random.h>
57703 #include <linux/syscalls.h>
57704+#include <linux/module.h>
57705
57706 #include "u_uac1.h"
57707
57708diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
57709index 181112c..036bcab 100644
57710--- a/drivers/usb/gadget/udc/dummy_hcd.c
57711+++ b/drivers/usb/gadget/udc/dummy_hcd.c
57712@@ -2384,7 +2384,7 @@ static int dummy_setup(struct usb_hcd *hcd)
57713 struct dummy *dum;
57714
57715 dum = *((void **)dev_get_platdata(hcd->self.controller));
57716- hcd->self.sg_tablesize = ~0;
57717+ hcd->self.sg_tablesize = SG_ALL;
57718 if (usb_hcd_is_primary_hcd(hcd)) {
57719 dum->hs_hcd = hcd_to_dummy_hcd(hcd);
57720 dum->hs_hcd->dum = dum;
57721diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
57722index c63d82c..a7e8665 100644
57723--- a/drivers/usb/host/ehci-hcd.c
57724+++ b/drivers/usb/host/ehci-hcd.c
57725@@ -564,7 +564,7 @@ static int ehci_init(struct usb_hcd *hcd)
57726
57727 /* Accept arbitrarily long scatter-gather lists */
57728 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
57729- hcd->self.sg_tablesize = ~0;
57730+ hcd->self.sg_tablesize = SG_ALL;
57731 return 0;
57732 }
57733
57734diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
57735index 22abb68..50b7b84 100644
57736--- a/drivers/usb/host/ehci-hub.c
57737+++ b/drivers/usb/host/ehci-hub.c
57738@@ -773,7 +773,7 @@ static struct urb *request_single_step_set_feature_urb(
57739 urb->transfer_flags = URB_DIR_IN;
57740 usb_get_urb(urb);
57741 atomic_inc(&urb->use_count);
57742- atomic_inc(&urb->dev->urbnum);
57743+ atomic_inc_unchecked(&urb->dev->urbnum);
57744 urb->setup_dma = dma_map_single(
57745 hcd->self.controller,
57746 urb->setup_packet,
57747@@ -840,7 +840,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
57748 urb->status = -EINPROGRESS;
57749 usb_get_urb(urb);
57750 atomic_inc(&urb->use_count);
57751- atomic_inc(&urb->dev->urbnum);
57752+ atomic_inc_unchecked(&urb->dev->urbnum);
57753 retval = submit_single_step_set_feature(hcd, urb, 0);
57754 if (!retval && !wait_for_completion_timeout(&done,
57755 msecs_to_jiffies(2000))) {
57756diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
57757index 54f5332..8b8335c 100644
57758--- a/drivers/usb/host/ehci-q.c
57759+++ b/drivers/usb/host/ehci-q.c
57760@@ -44,9 +44,9 @@
57761
57762 static int
57763 qtd_fill(struct ehci_hcd *ehci, struct ehci_qtd *qtd, dma_addr_t buf,
57764- size_t len, int token, int maxpacket)
57765+ size_t len, u32 token, int maxpacket)
57766 {
57767- int i, count;
57768+ u32 i, count;
57769 u64 addr = buf;
57770
57771 /* one buffer entry per 4K ... first might be short or unaligned */
57772diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
57773index 000ed80..2701154 100644
57774--- a/drivers/usb/host/fotg210-hcd.c
57775+++ b/drivers/usb/host/fotg210-hcd.c
57776@@ -5231,7 +5231,7 @@ static int hcd_fotg210_init(struct usb_hcd *hcd)
57777
57778 /* Accept arbitrarily long scatter-gather lists */
57779 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
57780- hcd->self.sg_tablesize = ~0;
57781+ hcd->self.sg_tablesize = SG_ALL;
57782 return 0;
57783 }
57784
57785diff --git a/drivers/usb/host/fusbh200-hcd.c b/drivers/usb/host/fusbh200-hcd.c
57786index 1fd8718..c7ff47c 100644
57787--- a/drivers/usb/host/fusbh200-hcd.c
57788+++ b/drivers/usb/host/fusbh200-hcd.c
57789@@ -5156,7 +5156,7 @@ static int hcd_fusbh200_init(struct usb_hcd *hcd)
57790
57791 /* Accept arbitrarily long scatter-gather lists */
57792 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
57793- hcd->self.sg_tablesize = ~0;
57794+ hcd->self.sg_tablesize = SG_ALL;
57795 return 0;
57796 }
57797
57798diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
57799index 1db0626..2e9f5ea 100644
57800--- a/drivers/usb/host/hwa-hc.c
57801+++ b/drivers/usb/host/hwa-hc.c
57802@@ -337,7 +337,10 @@ static int __hwahc_op_bwa_set(struct wusbhc *wusbhc, s8 stream_index,
57803 struct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc);
57804 struct wahc *wa = &hwahc->wa;
57805 struct device *dev = &wa->usb_iface->dev;
57806- u8 mas_le[UWB_NUM_MAS/8];
57807+ u8 *mas_le = kmalloc(UWB_NUM_MAS/8, GFP_KERNEL);
57808+
57809+ if (mas_le == NULL)
57810+ return -ENOMEM;
57811
57812 /* Set the stream index */
57813 result = usb_control_msg(wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0),
57814@@ -356,10 +359,12 @@ static int __hwahc_op_bwa_set(struct wusbhc *wusbhc, s8 stream_index,
57815 WUSB_REQ_SET_WUSB_MAS,
57816 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
57817 0, wa->usb_iface->cur_altsetting->desc.bInterfaceNumber,
57818- mas_le, 32, USB_CTRL_SET_TIMEOUT);
57819+ mas_le, UWB_NUM_MAS/8, USB_CTRL_SET_TIMEOUT);
57820 if (result < 0)
57821 dev_err(dev, "Cannot set WUSB MAS allocation: %d\n", result);
57822 out:
57823+ kfree(mas_le);
57824+
57825 return result;
57826 }
57827
57828@@ -812,7 +817,7 @@ static int hwahc_probe(struct usb_interface *usb_iface,
57829 goto error_alloc;
57830 }
57831 usb_hcd->wireless = 1;
57832- usb_hcd->self.sg_tablesize = ~0;
57833+ usb_hcd->self.sg_tablesize = SG_ALL;
57834 wusbhc = usb_hcd_to_wusbhc(usb_hcd);
57835 hwahc = container_of(wusbhc, struct hwahc, wusbhc);
57836 hwahc_init(hwahc);
57837diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
57838index 760cb57..fc7f8ad 100644
57839--- a/drivers/usb/host/ohci-hcd.c
57840+++ b/drivers/usb/host/ohci-hcd.c
57841@@ -444,7 +444,7 @@ static int ohci_init (struct ohci_hcd *ohci)
57842 struct usb_hcd *hcd = ohci_to_hcd(ohci);
57843
57844 /* Accept arbitrarily long scatter-gather lists */
57845- hcd->self.sg_tablesize = ~0;
57846+ hcd->self.sg_tablesize = SG_ALL;
57847
57848 if (distrust_firmware)
57849 ohci->flags |= OHCI_QUIRK_HUB_POWER;
57850diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h
57851index 672cea3..31a730db 100644
57852--- a/drivers/usb/host/r8a66597.h
57853+++ b/drivers/usb/host/r8a66597.h
57854@@ -125,7 +125,7 @@ struct r8a66597 {
57855 unsigned short interval_map;
57856 unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE];
57857 unsigned char dma_map;
57858- unsigned int max_root_hub;
57859+ unsigned char max_root_hub;
57860
57861 struct list_head child_device;
57862 unsigned long child_connect_map[4];
57863diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
57864index a7de8e8..e1ef134 100644
57865--- a/drivers/usb/host/uhci-hcd.c
57866+++ b/drivers/usb/host/uhci-hcd.c
57867@@ -570,7 +570,7 @@ static int uhci_start(struct usb_hcd *hcd)
57868 hcd->uses_new_polling = 1;
57869 /* Accept arbitrarily long scatter-gather lists */
57870 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
57871- hcd->self.sg_tablesize = ~0;
57872+ hcd->self.sg_tablesize = SG_ALL;
57873
57874 spin_lock_init(&uhci->lock);
57875 setup_timer(&uhci->fsbr_timer, uhci_fsbr_timeout,
57876diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
57877index c79d336..8fe41af 100644
57878--- a/drivers/usb/host/xhci-pci.c
57879+++ b/drivers/usb/host/xhci-pci.c
57880@@ -30,7 +30,7 @@
57881
57882 #define PORT2_SSIC_CONFIG_REG2 0x883c
57883 #define PROG_DONE (1 << 30)
57884-#define SSIC_PORT_UNUSED (1 << 31)
57885+#define SSIC_PORT_UNUSED (1U << 31)
57886
57887 /* Device for a quirk */
57888 #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73
57889diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
57890index d7b9f484..8208965 100644
57891--- a/drivers/usb/host/xhci.c
57892+++ b/drivers/usb/host/xhci.c
57893@@ -4837,7 +4837,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
57894 int retval;
57895
57896 /* Accept arbitrarily long scatter-gather lists */
57897- hcd->self.sg_tablesize = ~0;
57898+ hcd->self.sg_tablesize = SG_ALL;
57899
57900 /* support to build packet from discontinuous buffers */
57901 hcd->self.no_sg_constraint = 1;
57902diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
57903index a0a3827..d7ec10b 100644
57904--- a/drivers/usb/misc/appledisplay.c
57905+++ b/drivers/usb/misc/appledisplay.c
57906@@ -84,7 +84,7 @@ struct appledisplay {
57907 struct mutex sysfslock; /* concurrent read and write */
57908 };
57909
57910-static atomic_t count_displays = ATOMIC_INIT(0);
57911+static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
57912 static struct workqueue_struct *wq;
57913
57914 static void appledisplay_complete(struct urb *urb)
57915@@ -288,7 +288,7 @@ static int appledisplay_probe(struct usb_interface *iface,
57916
57917 /* Register backlight device */
57918 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
57919- atomic_inc_return(&count_displays) - 1);
57920+ atomic_inc_return_unchecked(&count_displays) - 1);
57921 memset(&props, 0, sizeof(struct backlight_properties));
57922 props.type = BACKLIGHT_RAW;
57923 props.max_brightness = 0xff;
57924diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
57925index 3806e70..55c508b 100644
57926--- a/drivers/usb/serial/console.c
57927+++ b/drivers/usb/serial/console.c
57928@@ -126,7 +126,7 @@ static int usb_console_setup(struct console *co, char *options)
57929
57930 info->port = port;
57931
57932- ++port->port.count;
57933+ atomic_inc(&port->port.count);
57934 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
57935 if (serial->type->set_termios) {
57936 /*
57937@@ -175,7 +175,7 @@ static int usb_console_setup(struct console *co, char *options)
57938 }
57939 /* Now that any required fake tty operations are completed restore
57940 * the tty port count */
57941- --port->port.count;
57942+ atomic_dec(&port->port.count);
57943 /* The console is special in terms of closing the device so
57944 * indicate this port is now acting as a system console. */
57945 port->port.console = 1;
57946@@ -188,7 +188,7 @@ static int usb_console_setup(struct console *co, char *options)
57947 put_tty:
57948 tty_kref_put(tty);
57949 reset_open_count:
57950- port->port.count = 0;
57951+ atomic_set(&port->port.count, 0);
57952 usb_autopm_put_interface(serial->interface);
57953 error_get_interface:
57954 usb_serial_put(serial);
57955@@ -199,7 +199,7 @@ static int usb_console_setup(struct console *co, char *options)
57956 static void usb_console_write(struct console *co,
57957 const char *buf, unsigned count)
57958 {
57959- static struct usbcons_info *info = &usbcons_info;
57960+ struct usbcons_info *info = &usbcons_info;
57961 struct usb_serial_port *port = info->port;
57962 struct usb_serial *serial;
57963 int retval = -ENODEV;
57964diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
57965index 540add2..2a2c7da 100644
57966--- a/drivers/usb/storage/transport.c
57967+++ b/drivers/usb/storage/transport.c
57968@@ -689,7 +689,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
57969 if (need_auto_sense) {
57970 int temp_result;
57971 struct scsi_eh_save ses;
57972- int sense_size = US_SENSE_SIZE;
57973+ unsigned int sense_size = US_SENSE_SIZE;
57974 struct scsi_sense_hdr sshdr;
57975 const u8 *scdd;
57976 u8 fm_ili;
57977diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
57978index 43576ed..583589d 100644
57979--- a/drivers/usb/storage/usb.c
57980+++ b/drivers/usb/storage/usb.c
57981@@ -912,7 +912,7 @@ static void usb_stor_scan_dwork(struct work_struct *work)
57982 clear_bit(US_FLIDX_SCAN_PENDING, &us->dflags);
57983 }
57984
57985-static unsigned int usb_stor_sg_tablesize(struct usb_interface *intf)
57986+static unsigned short usb_stor_sg_tablesize(struct usb_interface *intf)
57987 {
57988 struct usb_device *usb_dev = interface_to_usbdev(intf);
57989
57990diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
57991index da0ad32..50b5bbe 100644
57992--- a/drivers/usb/storage/usb.h
57993+++ b/drivers/usb/storage/usb.h
57994@@ -63,7 +63,7 @@ struct us_unusual_dev {
57995 __u8 useProtocol;
57996 __u8 useTransport;
57997 int (*initFunction)(struct us_data *);
57998-};
57999+} __do_const;
58000
58001
58002 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
58003diff --git a/drivers/usb/usbip/vhci.h b/drivers/usb/usbip/vhci.h
58004index a863a98..d272795 100644
58005--- a/drivers/usb/usbip/vhci.h
58006+++ b/drivers/usb/usbip/vhci.h
58007@@ -83,7 +83,7 @@ struct vhci_hcd {
58008 unsigned resuming:1;
58009 unsigned long re_timeout;
58010
58011- atomic_t seqnum;
58012+ atomic_unchecked_t seqnum;
58013
58014 /*
58015 * NOTE:
58016diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
58017index e9ef1ec..c3a0b04 100644
58018--- a/drivers/usb/usbip/vhci_hcd.c
58019+++ b/drivers/usb/usbip/vhci_hcd.c
58020@@ -440,7 +440,7 @@ static void vhci_tx_urb(struct urb *urb)
58021
58022 spin_lock(&vdev->priv_lock);
58023
58024- priv->seqnum = atomic_inc_return(&the_controller->seqnum);
58025+ priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
58026 if (priv->seqnum == 0xffff)
58027 dev_info(&urb->dev->dev, "seqnum max\n");
58028
58029@@ -685,7 +685,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
58030 return -ENOMEM;
58031 }
58032
58033- unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
58034+ unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
58035 if (unlink->seqnum == 0xffff)
58036 pr_info("seqnum max\n");
58037
58038@@ -889,7 +889,7 @@ static int vhci_start(struct usb_hcd *hcd)
58039 vdev->rhport = rhport;
58040 }
58041
58042- atomic_set(&vhci->seqnum, 0);
58043+ atomic_set_unchecked(&vhci->seqnum, 0);
58044 spin_lock_init(&vhci->lock);
58045
58046 hcd->power_budget = 0; /* no limit */
58047diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
58048index 00e4a54..d676f85 100644
58049--- a/drivers/usb/usbip/vhci_rx.c
58050+++ b/drivers/usb/usbip/vhci_rx.c
58051@@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
58052 if (!urb) {
58053 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
58054 pr_info("max seqnum %d\n",
58055- atomic_read(&the_controller->seqnum));
58056+ atomic_read_unchecked(&the_controller->seqnum));
58057 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
58058 return;
58059 }
58060diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
58061index 211f43f..6c22ae1 100644
58062--- a/drivers/usb/usbip/vhci_sysfs.c
58063+++ b/drivers/usb/usbip/vhci_sysfs.c
58064@@ -59,7 +59,7 @@ static ssize_t status_show(struct device *dev, struct device_attribute *attr,
58065 if (vdev->ud.status == VDEV_ST_USED) {
58066 out += sprintf(out, "%03u %08x ",
58067 vdev->speed, vdev->devid);
58068- out += sprintf(out, "%16p ", vdev->ud.tcp_socket);
58069+ out += sprintf(out, "%16pK ", vdev->ud.tcp_socket);
58070 out += sprintf(out, "%s", dev_name(&vdev->udev->dev));
58071
58072 } else {
58073diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
58074index edc7267..9f65ce2 100644
58075--- a/drivers/usb/wusbcore/wa-hc.h
58076+++ b/drivers/usb/wusbcore/wa-hc.h
58077@@ -240,7 +240,7 @@ struct wahc {
58078 spinlock_t xfer_list_lock;
58079 struct work_struct xfer_enqueue_work;
58080 struct work_struct xfer_error_work;
58081- atomic_t xfer_id_count;
58082+ atomic_unchecked_t xfer_id_count;
58083
58084 kernel_ulong_t quirks;
58085 };
58086@@ -305,7 +305,7 @@ static inline void wa_init(struct wahc *wa)
58087 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
58088 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
58089 wa->dto_in_use = 0;
58090- atomic_set(&wa->xfer_id_count, 1);
58091+ atomic_set_unchecked(&wa->xfer_id_count, 1);
58092 /* init the buf in URBs */
58093 for (index = 0; index < WA_MAX_BUF_IN_URBS; ++index)
58094 usb_init_urb(&(wa->buf_in_urbs[index]));
58095diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
58096index 69af4fd..da390d7 100644
58097--- a/drivers/usb/wusbcore/wa-xfer.c
58098+++ b/drivers/usb/wusbcore/wa-xfer.c
58099@@ -314,7 +314,7 @@ static void wa_xfer_completion(struct wa_xfer *xfer)
58100 */
58101 static void wa_xfer_id_init(struct wa_xfer *xfer)
58102 {
58103- xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
58104+ xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
58105 }
58106
58107 /* Return the xfer's ID. */
58108diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
58109index 563c510..1fcc957 100644
58110--- a/drivers/vfio/vfio.c
58111+++ b/drivers/vfio/vfio.c
58112@@ -517,7 +517,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
58113 return 0;
58114
58115 /* TODO Prevent device auto probing */
58116- WARN("Device %s added to live group %d!\n", dev_name(dev),
58117+ WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
58118 iommu_group_id(group->iommu_group));
58119
58120 return 0;
58121diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
58122index 3bb02c6..a01ff38 100644
58123--- a/drivers/vhost/vringh.c
58124+++ b/drivers/vhost/vringh.c
58125@@ -551,7 +551,7 @@ static inline void __vringh_notify_disable(struct vringh *vrh,
58126 static inline int getu16_user(const struct vringh *vrh, u16 *val, const __virtio16 *p)
58127 {
58128 __virtio16 v = 0;
58129- int rc = get_user(v, (__force __virtio16 __user *)p);
58130+ int rc = get_user(v, (__force_user __virtio16 *)p);
58131 *val = vringh16_to_cpu(vrh, v);
58132 return rc;
58133 }
58134@@ -559,12 +559,12 @@ static inline int getu16_user(const struct vringh *vrh, u16 *val, const __virtio
58135 static inline int putu16_user(const struct vringh *vrh, __virtio16 *p, u16 val)
58136 {
58137 __virtio16 v = cpu_to_vringh16(vrh, val);
58138- return put_user(v, (__force __virtio16 __user *)p);
58139+ return put_user(v, (__force_user __virtio16 *)p);
58140 }
58141
58142 static inline int copydesc_user(void *dst, const void *src, size_t len)
58143 {
58144- return copy_from_user(dst, (__force void __user *)src, len) ?
58145+ return copy_from_user(dst, (void __force_user *)src, len) ?
58146 -EFAULT : 0;
58147 }
58148
58149@@ -572,19 +572,19 @@ static inline int putused_user(struct vring_used_elem *dst,
58150 const struct vring_used_elem *src,
58151 unsigned int num)
58152 {
58153- return copy_to_user((__force void __user *)dst, src,
58154+ return copy_to_user((void __force_user *)dst, src,
58155 sizeof(*dst) * num) ? -EFAULT : 0;
58156 }
58157
58158 static inline int xfer_from_user(void *src, void *dst, size_t len)
58159 {
58160- return copy_from_user(dst, (__force void __user *)src, len) ?
58161+ return copy_from_user(dst, (void __force_user *)src, len) ?
58162 -EFAULT : 0;
58163 }
58164
58165 static inline int xfer_to_user(void *dst, void *src, size_t len)
58166 {
58167- return copy_to_user((__force void __user *)dst, src, len) ?
58168+ return copy_to_user((void __force_user *)dst, src, len) ?
58169 -EFAULT : 0;
58170 }
58171
58172@@ -621,9 +621,9 @@ int vringh_init_user(struct vringh *vrh, u64 features,
58173 vrh->last_used_idx = 0;
58174 vrh->vring.num = num;
58175 /* vring expects kernel addresses, but only used via accessors. */
58176- vrh->vring.desc = (__force struct vring_desc *)desc;
58177- vrh->vring.avail = (__force struct vring_avail *)avail;
58178- vrh->vring.used = (__force struct vring_used *)used;
58179+ vrh->vring.desc = (__force_kernel struct vring_desc *)desc;
58180+ vrh->vring.avail = (__force_kernel struct vring_avail *)avail;
58181+ vrh->vring.used = (__force_kernel struct vring_used *)used;
58182 return 0;
58183 }
58184 EXPORT_SYMBOL(vringh_init_user);
58185@@ -826,7 +826,7 @@ static inline int getu16_kern(const struct vringh *vrh,
58186
58187 static inline int putu16_kern(const struct vringh *vrh, __virtio16 *p, u16 val)
58188 {
58189- ACCESS_ONCE(*p) = cpu_to_vringh16(vrh, val);
58190+ ACCESS_ONCE_RW(*p) = cpu_to_vringh16(vrh, val);
58191 return 0;
58192 }
58193
58194diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
58195index 84a110a..96312c3 100644
58196--- a/drivers/video/backlight/kb3886_bl.c
58197+++ b/drivers/video/backlight/kb3886_bl.c
58198@@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
58199 static unsigned long kb3886bl_flags;
58200 #define KB3886BL_SUSPENDED 0x01
58201
58202-static struct dmi_system_id kb3886bl_device_table[] __initdata = {
58203+static const struct dmi_system_id kb3886bl_device_table[] __initconst = {
58204 {
58205 .ident = "Sahara Touch-iT",
58206 .matches = {
58207diff --git a/drivers/video/fbdev/arcfb.c b/drivers/video/fbdev/arcfb.c
58208index 1b0b233..6f34c2c 100644
58209--- a/drivers/video/fbdev/arcfb.c
58210+++ b/drivers/video/fbdev/arcfb.c
58211@@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
58212 return -ENOSPC;
58213
58214 err = 0;
58215- if ((count + p) > fbmemlength) {
58216+ if (count > (fbmemlength - p)) {
58217 count = fbmemlength - p;
58218 err = -ENOSPC;
58219 }
58220diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c
58221index c42ce2f..4c8bc59 100644
58222--- a/drivers/video/fbdev/aty/aty128fb.c
58223+++ b/drivers/video/fbdev/aty/aty128fb.c
58224@@ -145,7 +145,7 @@ enum {
58225 };
58226
58227 /* Must match above enum */
58228-static char * const r128_family[] = {
58229+static const char * const r128_family[] = {
58230 "AGP",
58231 "PCI",
58232 "PRO AGP",
58233diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c
58234index 8789e48..698fe4c 100644
58235--- a/drivers/video/fbdev/aty/atyfb_base.c
58236+++ b/drivers/video/fbdev/aty/atyfb_base.c
58237@@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
58238 par->accel_flags = var->accel_flags; /* hack */
58239
58240 if (var->accel_flags) {
58241- info->fbops->fb_sync = atyfb_sync;
58242+ pax_open_kernel();
58243+ *(void **)&info->fbops->fb_sync = atyfb_sync;
58244+ pax_close_kernel();
58245 info->flags &= ~FBINFO_HWACCEL_DISABLED;
58246 } else {
58247- info->fbops->fb_sync = NULL;
58248+ pax_open_kernel();
58249+ *(void **)&info->fbops->fb_sync = NULL;
58250+ pax_close_kernel();
58251 info->flags |= FBINFO_HWACCEL_DISABLED;
58252 }
58253
58254diff --git a/drivers/video/fbdev/aty/mach64_cursor.c b/drivers/video/fbdev/aty/mach64_cursor.c
58255index 2fa0317..4983f2a 100644
58256--- a/drivers/video/fbdev/aty/mach64_cursor.c
58257+++ b/drivers/video/fbdev/aty/mach64_cursor.c
58258@@ -8,6 +8,7 @@
58259 #include "../core/fb_draw.h"
58260
58261 #include <asm/io.h>
58262+#include <asm/pgtable.h>
58263
58264 #ifdef __sparc__
58265 #include <asm/fbio.h>
58266@@ -218,7 +219,9 @@ int aty_init_cursor(struct fb_info *info)
58267 info->sprite.buf_align = 16; /* and 64 lines tall. */
58268 info->sprite.flags = FB_PIXMAP_IO;
58269
58270- info->fbops->fb_cursor = atyfb_cursor;
58271+ pax_open_kernel();
58272+ *(void **)&info->fbops->fb_cursor = atyfb_cursor;
58273+ pax_close_kernel();
58274
58275 return 0;
58276 }
58277diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
58278index 3fc63c2..eec5e49 100644
58279--- a/drivers/video/fbdev/core/fb_defio.c
58280+++ b/drivers/video/fbdev/core/fb_defio.c
58281@@ -207,7 +207,9 @@ void fb_deferred_io_init(struct fb_info *info)
58282
58283 BUG_ON(!fbdefio);
58284 mutex_init(&fbdefio->lock);
58285- info->fbops->fb_mmap = fb_deferred_io_mmap;
58286+ pax_open_kernel();
58287+ *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
58288+ pax_close_kernel();
58289 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
58290 INIT_LIST_HEAD(&fbdefio->pagelist);
58291 if (fbdefio->delay == 0) /* set a default of 1 s */
58292@@ -238,7 +240,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
58293 page->mapping = NULL;
58294 }
58295
58296- info->fbops->fb_mmap = NULL;
58297+ *(void **)&info->fbops->fb_mmap = NULL;
58298 mutex_destroy(&fbdefio->lock);
58299 }
58300 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
58301diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
58302index 0705d88..d9429bf 100644
58303--- a/drivers/video/fbdev/core/fbmem.c
58304+++ b/drivers/video/fbdev/core/fbmem.c
58305@@ -1301,7 +1301,7 @@ static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix,
58306 __u32 data;
58307 int err;
58308
58309- err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id));
58310+ err = copy_to_user(fix32->id, &fix->id, sizeof(fix32->id));
58311
58312 data = (__u32) (unsigned long) fix->smem_start;
58313 err |= put_user(data, &fix32->smem_start);
58314diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c
58315index 807ee22..7814cd6 100644
58316--- a/drivers/video/fbdev/hyperv_fb.c
58317+++ b/drivers/video/fbdev/hyperv_fb.c
58318@@ -240,7 +240,7 @@ static uint screen_fb_size;
58319 static inline int synthvid_send(struct hv_device *hdev,
58320 struct synthvid_msg *msg)
58321 {
58322- static atomic64_t request_id = ATOMIC64_INIT(0);
58323+ static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
58324 int ret;
58325
58326 msg->pipe_hdr.type = PIPE_MSG_DATA;
58327@@ -248,7 +248,7 @@ static inline int synthvid_send(struct hv_device *hdev,
58328
58329 ret = vmbus_sendpacket(hdev->channel, msg,
58330 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
58331- atomic64_inc_return(&request_id),
58332+ atomic64_inc_return_unchecked(&request_id),
58333 VM_PKT_DATA_INBAND, 0);
58334
58335 if (ret)
58336diff --git a/drivers/video/fbdev/i810/i810_accel.c b/drivers/video/fbdev/i810/i810_accel.c
58337index 7672d2e..b56437f 100644
58338--- a/drivers/video/fbdev/i810/i810_accel.c
58339+++ b/drivers/video/fbdev/i810/i810_accel.c
58340@@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
58341 }
58342 }
58343 printk("ringbuffer lockup!!!\n");
58344+ printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
58345 i810_report_error(mmio);
58346 par->dev_flags |= LOCKUP;
58347 info->pixmap.scan_align = 1;
58348diff --git a/drivers/video/fbdev/matrox/matroxfb_DAC1064.c b/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
58349index a01147f..5d896f8 100644
58350--- a/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
58351+++ b/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
58352@@ -1088,14 +1088,20 @@ static void MGAG100_restore(struct matrox_fb_info *minfo)
58353
58354 #ifdef CONFIG_FB_MATROX_MYSTIQUE
58355 struct matrox_switch matrox_mystique = {
58356- MGA1064_preinit, MGA1064_reset, MGA1064_init, MGA1064_restore,
58357+ .preinit = MGA1064_preinit,
58358+ .reset = MGA1064_reset,
58359+ .init = MGA1064_init,
58360+ .restore = MGA1064_restore,
58361 };
58362 EXPORT_SYMBOL(matrox_mystique);
58363 #endif
58364
58365 #ifdef CONFIG_FB_MATROX_G
58366 struct matrox_switch matrox_G100 = {
58367- MGAG100_preinit, MGAG100_reset, MGAG100_init, MGAG100_restore,
58368+ .preinit = MGAG100_preinit,
58369+ .reset = MGAG100_reset,
58370+ .init = MGAG100_init,
58371+ .restore = MGAG100_restore,
58372 };
58373 EXPORT_SYMBOL(matrox_G100);
58374 #endif
58375diff --git a/drivers/video/fbdev/matrox/matroxfb_Ti3026.c b/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
58376index 195ad7c..09743fc 100644
58377--- a/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
58378+++ b/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
58379@@ -738,7 +738,10 @@ static int Ti3026_preinit(struct matrox_fb_info *minfo)
58380 }
58381
58382 struct matrox_switch matrox_millennium = {
58383- Ti3026_preinit, Ti3026_reset, Ti3026_init, Ti3026_restore
58384+ .preinit = Ti3026_preinit,
58385+ .reset = Ti3026_reset,
58386+ .init = Ti3026_init,
58387+ .restore = Ti3026_restore
58388 };
58389 EXPORT_SYMBOL(matrox_millennium);
58390 #endif
58391diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c b/drivers/video/fbdev/matrox/matroxfb_base.c
58392index 11eb094..622ee31 100644
58393--- a/drivers/video/fbdev/matrox/matroxfb_base.c
58394+++ b/drivers/video/fbdev/matrox/matroxfb_base.c
58395@@ -2176,7 +2176,7 @@ static struct pci_driver matroxfb_driver = {
58396 #define RS1056x480 14 /* 132 x 60 text */
58397 #define RSNoxNo 15
58398 /* 10-FF */
58399-static struct { int xres, yres, left, right, upper, lower, hslen, vslen, vfreq; } timmings[] __initdata = {
58400+static struct { unsigned int xres, yres, left, right, upper, lower, hslen, vslen, vfreq; } timmings[] __initdata = {
58401 { 640, 400, 48, 16, 39, 8, 96, 2, 70 },
58402 { 640, 480, 48, 16, 33, 10, 96, 2, 60 },
58403 { 800, 600, 144, 24, 28, 8, 112, 6, 60 },
58404diff --git a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
58405index fe92eed..106e085 100644
58406--- a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
58407+++ b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
58408@@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
58409 struct mb862xxfb_par *par = info->par;
58410
58411 if (info->var.bits_per_pixel == 32) {
58412- info->fbops->fb_fillrect = cfb_fillrect;
58413- info->fbops->fb_copyarea = cfb_copyarea;
58414- info->fbops->fb_imageblit = cfb_imageblit;
58415+ pax_open_kernel();
58416+ *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
58417+ *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
58418+ *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
58419+ pax_close_kernel();
58420 } else {
58421 outreg(disp, GC_L0EM, 3);
58422- info->fbops->fb_fillrect = mb86290fb_fillrect;
58423- info->fbops->fb_copyarea = mb86290fb_copyarea;
58424- info->fbops->fb_imageblit = mb86290fb_imageblit;
58425+ pax_open_kernel();
58426+ *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
58427+ *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
58428+ *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
58429+ pax_close_kernel();
58430 }
58431 outreg(draw, GDC_REG_DRAW_BASE, 0);
58432 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
58433diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c
58434index ce7dab7..a87baf8 100644
58435--- a/drivers/video/fbdev/nvidia/nvidia.c
58436+++ b/drivers/video/fbdev/nvidia/nvidia.c
58437@@ -660,19 +660,23 @@ static int nvidiafb_set_par(struct fb_info *info)
58438 info->fix.line_length = (info->var.xres_virtual *
58439 info->var.bits_per_pixel) >> 3;
58440 if (info->var.accel_flags) {
58441- info->fbops->fb_imageblit = nvidiafb_imageblit;
58442- info->fbops->fb_fillrect = nvidiafb_fillrect;
58443- info->fbops->fb_copyarea = nvidiafb_copyarea;
58444- info->fbops->fb_sync = nvidiafb_sync;
58445+ pax_open_kernel();
58446+ *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
58447+ *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
58448+ *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
58449+ *(void **)&info->fbops->fb_sync = nvidiafb_sync;
58450+ pax_close_kernel();
58451 info->pixmap.scan_align = 4;
58452 info->flags &= ~FBINFO_HWACCEL_DISABLED;
58453 info->flags |= FBINFO_READS_FAST;
58454 NVResetGraphics(info);
58455 } else {
58456- info->fbops->fb_imageblit = cfb_imageblit;
58457- info->fbops->fb_fillrect = cfb_fillrect;
58458- info->fbops->fb_copyarea = cfb_copyarea;
58459- info->fbops->fb_sync = NULL;
58460+ pax_open_kernel();
58461+ *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
58462+ *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
58463+ *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
58464+ *(void **)&info->fbops->fb_sync = NULL;
58465+ pax_close_kernel();
58466 info->pixmap.scan_align = 1;
58467 info->flags |= FBINFO_HWACCEL_DISABLED;
58468 info->flags &= ~FBINFO_READS_FAST;
58469@@ -1164,8 +1168,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
58470 info->pixmap.size = 8 * 1024;
58471 info->pixmap.flags = FB_PIXMAP_SYSTEM;
58472
58473- if (!hwcur)
58474- info->fbops->fb_cursor = NULL;
58475+ if (!hwcur) {
58476+ pax_open_kernel();
58477+ *(void **)&info->fbops->fb_cursor = NULL;
58478+ pax_close_kernel();
58479+ }
58480
58481 info->var.accel_flags = (!noaccel);
58482
58483diff --git a/drivers/video/fbdev/omap2/dss/display.c b/drivers/video/fbdev/omap2/dss/display.c
58484index ef5b902..47cf7f5 100644
58485--- a/drivers/video/fbdev/omap2/dss/display.c
58486+++ b/drivers/video/fbdev/omap2/dss/display.c
58487@@ -161,12 +161,14 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
58488 if (dssdev->name == NULL)
58489 dssdev->name = dssdev->alias;
58490
58491+ pax_open_kernel();
58492 if (drv && drv->get_resolution == NULL)
58493- drv->get_resolution = omapdss_default_get_resolution;
58494+ *(void **)&drv->get_resolution = omapdss_default_get_resolution;
58495 if (drv && drv->get_recommended_bpp == NULL)
58496- drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
58497+ *(void **)&drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
58498 if (drv && drv->get_timings == NULL)
58499- drv->get_timings = omapdss_default_get_timings;
58500+ *(void **)&drv->get_timings = omapdss_default_get_timings;
58501+ pax_close_kernel();
58502
58503 mutex_lock(&panel_list_mutex);
58504 list_add_tail(&dssdev->panel_list, &panel_list);
58505diff --git a/drivers/video/fbdev/s1d13xxxfb.c b/drivers/video/fbdev/s1d13xxxfb.c
58506index 83433cb..71e9b98 100644
58507--- a/drivers/video/fbdev/s1d13xxxfb.c
58508+++ b/drivers/video/fbdev/s1d13xxxfb.c
58509@@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
58510
58511 switch(prod_id) {
58512 case S1D13506_PROD_ID: /* activate acceleration */
58513- s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
58514- s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
58515+ pax_open_kernel();
58516+ *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
58517+ *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
58518+ pax_close_kernel();
58519 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
58520 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
58521 break;
58522diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
58523index 82c0a8c..42499a1 100644
58524--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
58525+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
58526@@ -439,9 +439,9 @@ static unsigned long lcdc_sys_read_data(void *handle)
58527 }
58528
58529 static struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = {
58530- lcdc_sys_write_index,
58531- lcdc_sys_write_data,
58532- lcdc_sys_read_data,
58533+ .write_index = lcdc_sys_write_index,
58534+ .write_data = lcdc_sys_write_data,
58535+ .read_data = lcdc_sys_read_data,
58536 };
58537
58538 static int sh_mobile_lcdc_sginit(struct fb_info *info,
58539diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
58540index 9279e5f..d5f5276 100644
58541--- a/drivers/video/fbdev/smscufx.c
58542+++ b/drivers/video/fbdev/smscufx.c
58543@@ -1174,7 +1174,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
58544 fb_deferred_io_cleanup(info);
58545 kfree(info->fbdefio);
58546 info->fbdefio = NULL;
58547- info->fbops->fb_mmap = ufx_ops_mmap;
58548+ pax_open_kernel();
58549+ *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
58550+ pax_close_kernel();
58551 }
58552
58553 pr_debug("released /dev/fb%d user=%d count=%d",
58554diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
58555index ff2b873..626a8d5 100644
58556--- a/drivers/video/fbdev/udlfb.c
58557+++ b/drivers/video/fbdev/udlfb.c
58558@@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
58559 dlfb_urb_completion(urb);
58560
58561 error:
58562- atomic_add(bytes_sent, &dev->bytes_sent);
58563- atomic_add(bytes_identical, &dev->bytes_identical);
58564- atomic_add(width*height*2, &dev->bytes_rendered);
58565+ atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
58566+ atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
58567+ atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
58568 end_cycles = get_cycles();
58569- atomic_add(((unsigned int) ((end_cycles - start_cycles)
58570+ atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
58571 >> 10)), /* Kcycles */
58572 &dev->cpu_kcycles_used);
58573
58574@@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
58575 dlfb_urb_completion(urb);
58576
58577 error:
58578- atomic_add(bytes_sent, &dev->bytes_sent);
58579- atomic_add(bytes_identical, &dev->bytes_identical);
58580- atomic_add(bytes_rendered, &dev->bytes_rendered);
58581+ atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
58582+ atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
58583+ atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
58584 end_cycles = get_cycles();
58585- atomic_add(((unsigned int) ((end_cycles - start_cycles)
58586+ atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
58587 >> 10)), /* Kcycles */
58588 &dev->cpu_kcycles_used);
58589 }
58590@@ -991,7 +991,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
58591 fb_deferred_io_cleanup(info);
58592 kfree(info->fbdefio);
58593 info->fbdefio = NULL;
58594- info->fbops->fb_mmap = dlfb_ops_mmap;
58595+ pax_open_kernel();
58596+ *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
58597+ pax_close_kernel();
58598 }
58599
58600 pr_warn("released /dev/fb%d user=%d count=%d\n",
58601@@ -1373,7 +1375,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
58602 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58603 struct dlfb_data *dev = fb_info->par;
58604 return snprintf(buf, PAGE_SIZE, "%u\n",
58605- atomic_read(&dev->bytes_rendered));
58606+ atomic_read_unchecked(&dev->bytes_rendered));
58607 }
58608
58609 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
58610@@ -1381,7 +1383,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
58611 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58612 struct dlfb_data *dev = fb_info->par;
58613 return snprintf(buf, PAGE_SIZE, "%u\n",
58614- atomic_read(&dev->bytes_identical));
58615+ atomic_read_unchecked(&dev->bytes_identical));
58616 }
58617
58618 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
58619@@ -1389,7 +1391,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
58620 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58621 struct dlfb_data *dev = fb_info->par;
58622 return snprintf(buf, PAGE_SIZE, "%u\n",
58623- atomic_read(&dev->bytes_sent));
58624+ atomic_read_unchecked(&dev->bytes_sent));
58625 }
58626
58627 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
58628@@ -1397,7 +1399,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
58629 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58630 struct dlfb_data *dev = fb_info->par;
58631 return snprintf(buf, PAGE_SIZE, "%u\n",
58632- atomic_read(&dev->cpu_kcycles_used));
58633+ atomic_read_unchecked(&dev->cpu_kcycles_used));
58634 }
58635
58636 static ssize_t edid_show(
58637@@ -1457,10 +1459,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
58638 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58639 struct dlfb_data *dev = fb_info->par;
58640
58641- atomic_set(&dev->bytes_rendered, 0);
58642- atomic_set(&dev->bytes_identical, 0);
58643- atomic_set(&dev->bytes_sent, 0);
58644- atomic_set(&dev->cpu_kcycles_used, 0);
58645+ atomic_set_unchecked(&dev->bytes_rendered, 0);
58646+ atomic_set_unchecked(&dev->bytes_identical, 0);
58647+ atomic_set_unchecked(&dev->bytes_sent, 0);
58648+ atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
58649
58650 return count;
58651 }
58652diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
58653index 178ae93..624b2eb 100644
58654--- a/drivers/video/fbdev/uvesafb.c
58655+++ b/drivers/video/fbdev/uvesafb.c
58656@@ -19,6 +19,7 @@
58657 #include <linux/io.h>
58658 #include <linux/mutex.h>
58659 #include <linux/slab.h>
58660+#include <linux/moduleloader.h>
58661 #include <video/edid.h>
58662 #include <video/uvesafb.h>
58663 #ifdef CONFIG_X86
58664@@ -565,10 +566,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
58665 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
58666 par->pmi_setpal = par->ypan = 0;
58667 } else {
58668+
58669+#ifdef CONFIG_PAX_KERNEXEC
58670+#ifdef CONFIG_MODULES
58671+ par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
58672+#endif
58673+ if (!par->pmi_code) {
58674+ par->pmi_setpal = par->ypan = 0;
58675+ return 0;
58676+ }
58677+#endif
58678+
58679 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
58680 + task->t.regs.edi);
58681+
58682+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58683+ pax_open_kernel();
58684+ memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
58685+ pax_close_kernel();
58686+
58687+ par->pmi_start = (void *)ktva_ktla((unsigned long)(par->pmi_code + par->pmi_base[1]));
58688+ par->pmi_pal = (void *)ktva_ktla((unsigned long)(par->pmi_code + par->pmi_base[2]));
58689+#else
58690 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
58691 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
58692+#endif
58693+
58694 printk(KERN_INFO "uvesafb: protected mode interface info at "
58695 "%04x:%04x\n",
58696 (u16)task->t.regs.es, (u16)task->t.regs.edi);
58697@@ -813,13 +836,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
58698 par->ypan = ypan;
58699
58700 if (par->pmi_setpal || par->ypan) {
58701+#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
58702 if (__supported_pte_mask & _PAGE_NX) {
58703 par->pmi_setpal = par->ypan = 0;
58704 printk(KERN_WARNING "uvesafb: NX protection is active, "
58705 "better not use the PMI.\n");
58706- } else {
58707+ } else
58708+#endif
58709 uvesafb_vbe_getpmi(task, par);
58710- }
58711 }
58712 #else
58713 /* The protected mode interface is not available on non-x86. */
58714@@ -1452,8 +1476,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
58715 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
58716
58717 /* Disable blanking if the user requested so. */
58718- if (!blank)
58719- info->fbops->fb_blank = NULL;
58720+ if (!blank) {
58721+ pax_open_kernel();
58722+ *(void **)&info->fbops->fb_blank = NULL;
58723+ pax_close_kernel();
58724+ }
58725
58726 /*
58727 * Find out how much IO memory is required for the mode with
58728@@ -1524,8 +1551,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
58729 info->flags = FBINFO_FLAG_DEFAULT |
58730 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
58731
58732- if (!par->ypan)
58733- info->fbops->fb_pan_display = NULL;
58734+ if (!par->ypan) {
58735+ pax_open_kernel();
58736+ *(void **)&info->fbops->fb_pan_display = NULL;
58737+ pax_close_kernel();
58738+ }
58739 }
58740
58741 static void uvesafb_init_mtrr(struct fb_info *info)
58742@@ -1786,6 +1816,11 @@ out_mode:
58743 out:
58744 kfree(par->vbe_modes);
58745
58746+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58747+ if (par->pmi_code)
58748+ module_memfree_exec(par->pmi_code);
58749+#endif
58750+
58751 framebuffer_release(info);
58752 return err;
58753 }
58754@@ -1810,6 +1845,11 @@ static int uvesafb_remove(struct platform_device *dev)
58755 kfree(par->vbe_state_orig);
58756 kfree(par->vbe_state_saved);
58757
58758+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58759+ if (par->pmi_code)
58760+ module_memfree_exec(par->pmi_code);
58761+#endif
58762+
58763 framebuffer_release(info);
58764 }
58765 return 0;
58766diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c
58767index 528fe91..6fd29fe 100644
58768--- a/drivers/video/fbdev/vesafb.c
58769+++ b/drivers/video/fbdev/vesafb.c
58770@@ -9,6 +9,7 @@
58771 */
58772
58773 #include <linux/module.h>
58774+#include <linux/moduleloader.h>
58775 #include <linux/kernel.h>
58776 #include <linux/errno.h>
58777 #include <linux/string.h>
58778@@ -56,8 +57,8 @@ static int vram_remap; /* Set amount of memory to be used */
58779 static int vram_total; /* Set total amount of memory */
58780 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
58781 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
58782-static void (*pmi_start)(void) __read_mostly;
58783-static void (*pmi_pal) (void) __read_mostly;
58784+static void (*pmi_start)(void) __read_only;
58785+static void (*pmi_pal) (void) __read_only;
58786 static int depth __read_mostly;
58787 static int vga_compat __read_mostly;
58788 /* --------------------------------------------------------------------- */
58789@@ -241,6 +242,7 @@ static int vesafb_probe(struct platform_device *dev)
58790 unsigned int size_remap;
58791 unsigned int size_total;
58792 char *option = NULL;
58793+ void *pmi_code = NULL;
58794
58795 /* ignore error return of fb_get_options */
58796 fb_get_options("vesafb", &option);
58797@@ -287,10 +289,6 @@ static int vesafb_probe(struct platform_device *dev)
58798 size_remap = size_total;
58799 vesafb_fix.smem_len = size_remap;
58800
58801-#ifndef __i386__
58802- screen_info.vesapm_seg = 0;
58803-#endif
58804-
58805 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
58806 printk(KERN_WARNING
58807 "vesafb: cannot reserve video memory at 0x%lx\n",
58808@@ -320,9 +318,21 @@ static int vesafb_probe(struct platform_device *dev)
58809 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
58810 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
58811
58812+#ifdef __i386__
58813+
58814+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58815+ pmi_code = module_alloc_exec(screen_info.vesapm_size);
58816+ if (!pmi_code)
58817+#elif !defined(CONFIG_PAX_KERNEXEC)
58818+ if (0)
58819+#endif
58820+
58821+#endif
58822+ screen_info.vesapm_seg = 0;
58823+
58824 if (screen_info.vesapm_seg) {
58825- printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
58826- screen_info.vesapm_seg,screen_info.vesapm_off);
58827+ printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
58828+ screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
58829 }
58830
58831 if (screen_info.vesapm_seg < 0xc000)
58832@@ -330,9 +340,25 @@ static int vesafb_probe(struct platform_device *dev)
58833
58834 if (ypan || pmi_setpal) {
58835 unsigned short *pmi_base;
58836+
58837 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
58838- pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
58839- pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
58840+
58841+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58842+ pax_open_kernel();
58843+ memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
58844+#else
58845+ pmi_code = pmi_base;
58846+#endif
58847+
58848+ pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
58849+ pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
58850+
58851+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58852+ pmi_start = (void *)ktva_ktla((unsigned long)pmi_start);
58853+ pmi_pal = (void *)ktva_ktla((unsigned long)pmi_pal);
58854+ pax_close_kernel();
58855+#endif
58856+
58857 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
58858 if (pmi_base[3]) {
58859 printk(KERN_INFO "vesafb: pmi: ports = ");
58860@@ -452,8 +478,11 @@ static int vesafb_probe(struct platform_device *dev)
58861 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
58862 (ypan ? FBINFO_HWACCEL_YPAN : 0);
58863
58864- if (!ypan)
58865- info->fbops->fb_pan_display = NULL;
58866+ if (!ypan) {
58867+ pax_open_kernel();
58868+ *(void **)&info->fbops->fb_pan_display = NULL;
58869+ pax_close_kernel();
58870+ }
58871
58872 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
58873 err = -ENOMEM;
58874@@ -467,6 +496,11 @@ static int vesafb_probe(struct platform_device *dev)
58875 fb_info(info, "%s frame buffer device\n", info->fix.id);
58876 return 0;
58877 err:
58878+
58879+#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58880+ module_memfree_exec(pmi_code);
58881+#endif
58882+
58883 arch_phys_wc_del(par->wc_cookie);
58884 if (info->screen_base)
58885 iounmap(info->screen_base);
58886diff --git a/drivers/video/fbdev/via/via_clock.h b/drivers/video/fbdev/via/via_clock.h
58887index 88714ae..16c2e11 100644
58888--- a/drivers/video/fbdev/via/via_clock.h
58889+++ b/drivers/video/fbdev/via/via_clock.h
58890@@ -56,7 +56,7 @@ struct via_clock {
58891
58892 void (*set_engine_pll_state)(u8 state);
58893 void (*set_engine_pll)(struct via_pll_config config);
58894-};
58895+} __no_const;
58896
58897
58898 static inline u32 get_pll_internal_frequency(u32 ref_freq,
58899diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
58900index 3c14e43..2630570 100644
58901--- a/drivers/video/logo/logo_linux_clut224.ppm
58902+++ b/drivers/video/logo/logo_linux_clut224.ppm
58903@@ -2,1603 +2,1123 @@ P3
58904 # Standard 224-color Linux logo
58905 80 80
58906 255
58907- 0 0 0 0 0 0 0 0 0 0 0 0
58908- 0 0 0 0 0 0 0 0 0 0 0 0
58909- 0 0 0 0 0 0 0 0 0 0 0 0
58910- 0 0 0 0 0 0 0 0 0 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- 0 0 0 0 0 0 0 0 0 0 0 0
58915- 0 0 0 0 0 0 0 0 0 0 0 0
58916- 6 6 6 6 6 6 10 10 10 10 10 10
58917- 10 10 10 6 6 6 6 6 6 6 6 6
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- 0 0 0 0 0 0 0 0 0 0 0 0
58928- 0 0 0 0 0 0 0 0 0 0 0 0
58929- 0 0 0 0 0 0 0 0 0 0 0 0
58930- 0 0 0 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 0 0 0 0 0 0 0 0 0
58935- 0 0 0 6 6 6 10 10 10 14 14 14
58936- 22 22 22 26 26 26 30 30 30 34 34 34
58937- 30 30 30 30 30 30 26 26 26 18 18 18
58938- 14 14 14 10 10 10 6 6 6 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 0 0 0
58948- 0 0 0 0 0 1 0 0 1 0 0 0
58949- 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0
58955- 6 6 6 14 14 14 26 26 26 42 42 42
58956- 54 54 54 66 66 66 78 78 78 78 78 78
58957- 78 78 78 74 74 74 66 66 66 54 54 54
58958- 42 42 42 26 26 26 18 18 18 10 10 10
58959- 6 6 6 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- 0 0 0 0 0 0 0 0 0 0 0 0
58963- 0 0 0 0 0 0 0 0 0 0 0 0
58964- 0 0 0 0 0 0 0 0 0 0 0 0
58965- 0 0 0 0 0 0 0 0 0 0 0 0
58966- 0 0 0 0 0 0 0 0 0 0 0 0
58967- 0 0 0 0 0 0 0 0 0 0 0 0
58968- 0 0 1 0 0 0 0 0 0 0 0 0
58969- 0 0 0 0 0 0 0 0 0 0 0 0
58970- 0 0 0 0 0 0 0 0 0 0 0 0
58971- 0 0 0 0 0 0 0 0 0 0 0 0
58972- 0 0 0 0 0 0 0 0 0 0 0 0
58973- 0 0 0 0 0 0 0 0 0 0 0 0
58974- 0 0 0 0 0 0 0 0 0 10 10 10
58975- 22 22 22 42 42 42 66 66 66 86 86 86
58976- 66 66 66 38 38 38 38 38 38 22 22 22
58977- 26 26 26 34 34 34 54 54 54 66 66 66
58978- 86 86 86 70 70 70 46 46 46 26 26 26
58979- 14 14 14 6 6 6 0 0 0 0 0 0
58980- 0 0 0 0 0 0 0 0 0 0 0 0
58981- 0 0 0 0 0 0 0 0 0 0 0 0
58982- 0 0 0 0 0 0 0 0 0 0 0 0
58983- 0 0 0 0 0 0 0 0 0 0 0 0
58984- 0 0 0 0 0 0 0 0 0 0 0 0
58985- 0 0 0 0 0 0 0 0 0 0 0 0
58986- 0 0 0 0 0 0 0 0 0 0 0 0
58987- 0 0 0 0 0 0 0 0 0 0 0 0
58988- 0 0 1 0 0 1 0 0 1 0 0 0
58989- 0 0 0 0 0 0 0 0 0 0 0 0
58990- 0 0 0 0 0 0 0 0 0 0 0 0
58991- 0 0 0 0 0 0 0 0 0 0 0 0
58992- 0 0 0 0 0 0 0 0 0 0 0 0
58993- 0 0 0 0 0 0 0 0 0 0 0 0
58994- 0 0 0 0 0 0 10 10 10 26 26 26
58995- 50 50 50 82 82 82 58 58 58 6 6 6
58996- 2 2 6 2 2 6 2 2 6 2 2 6
58997- 2 2 6 2 2 6 2 2 6 2 2 6
58998- 6 6 6 54 54 54 86 86 86 66 66 66
58999- 38 38 38 18 18 18 6 6 6 0 0 0
59000- 0 0 0 0 0 0 0 0 0 0 0 0
59001- 0 0 0 0 0 0 0 0 0 0 0 0
59002- 0 0 0 0 0 0 0 0 0 0 0 0
59003- 0 0 0 0 0 0 0 0 0 0 0 0
59004- 0 0 0 0 0 0 0 0 0 0 0 0
59005- 0 0 0 0 0 0 0 0 0 0 0 0
59006- 0 0 0 0 0 0 0 0 0 0 0 0
59007- 0 0 0 0 0 0 0 0 0 0 0 0
59008- 0 0 0 0 0 0 0 0 0 0 0 0
59009- 0 0 0 0 0 0 0 0 0 0 0 0
59010- 0 0 0 0 0 0 0 0 0 0 0 0
59011- 0 0 0 0 0 0 0 0 0 0 0 0
59012- 0 0 0 0 0 0 0 0 0 0 0 0
59013- 0 0 0 0 0 0 0 0 0 0 0 0
59014- 0 0 0 6 6 6 22 22 22 50 50 50
59015- 78 78 78 34 34 34 2 2 6 2 2 6
59016- 2 2 6 2 2 6 2 2 6 2 2 6
59017- 2 2 6 2 2 6 2 2 6 2 2 6
59018- 2 2 6 2 2 6 6 6 6 70 70 70
59019- 78 78 78 46 46 46 22 22 22 6 6 6
59020- 0 0 0 0 0 0 0 0 0 0 0 0
59021- 0 0 0 0 0 0 0 0 0 0 0 0
59022- 0 0 0 0 0 0 0 0 0 0 0 0
59023- 0 0 0 0 0 0 0 0 0 0 0 0
59024- 0 0 0 0 0 0 0 0 0 0 0 0
59025- 0 0 0 0 0 0 0 0 0 0 0 0
59026- 0 0 0 0 0 0 0 0 0 0 0 0
59027- 0 0 0 0 0 0 0 0 0 0 0 0
59028- 0 0 1 0 0 1 0 0 1 0 0 0
59029- 0 0 0 0 0 0 0 0 0 0 0 0
59030- 0 0 0 0 0 0 0 0 0 0 0 0
59031- 0 0 0 0 0 0 0 0 0 0 0 0
59032- 0 0 0 0 0 0 0 0 0 0 0 0
59033- 0 0 0 0 0 0 0 0 0 0 0 0
59034- 6 6 6 18 18 18 42 42 42 82 82 82
59035- 26 26 26 2 2 6 2 2 6 2 2 6
59036- 2 2 6 2 2 6 2 2 6 2 2 6
59037- 2 2 6 2 2 6 2 2 6 14 14 14
59038- 46 46 46 34 34 34 6 6 6 2 2 6
59039- 42 42 42 78 78 78 42 42 42 18 18 18
59040- 6 6 6 0 0 0 0 0 0 0 0 0
59041- 0 0 0 0 0 0 0 0 0 0 0 0
59042- 0 0 0 0 0 0 0 0 0 0 0 0
59043- 0 0 0 0 0 0 0 0 0 0 0 0
59044- 0 0 0 0 0 0 0 0 0 0 0 0
59045- 0 0 0 0 0 0 0 0 0 0 0 0
59046- 0 0 0 0 0 0 0 0 0 0 0 0
59047- 0 0 0 0 0 0 0 0 0 0 0 0
59048- 0 0 1 0 0 0 0 0 1 0 0 0
59049- 0 0 0 0 0 0 0 0 0 0 0 0
59050- 0 0 0 0 0 0 0 0 0 0 0 0
59051- 0 0 0 0 0 0 0 0 0 0 0 0
59052- 0 0 0 0 0 0 0 0 0 0 0 0
59053- 0 0 0 0 0 0 0 0 0 0 0 0
59054- 10 10 10 30 30 30 66 66 66 58 58 58
59055- 2 2 6 2 2 6 2 2 6 2 2 6
59056- 2 2 6 2 2 6 2 2 6 2 2 6
59057- 2 2 6 2 2 6 2 2 6 26 26 26
59058- 86 86 86 101 101 101 46 46 46 10 10 10
59059- 2 2 6 58 58 58 70 70 70 34 34 34
59060- 10 10 10 0 0 0 0 0 0 0 0 0
59061- 0 0 0 0 0 0 0 0 0 0 0 0
59062- 0 0 0 0 0 0 0 0 0 0 0 0
59063- 0 0 0 0 0 0 0 0 0 0 0 0
59064- 0 0 0 0 0 0 0 0 0 0 0 0
59065- 0 0 0 0 0 0 0 0 0 0 0 0
59066- 0 0 0 0 0 0 0 0 0 0 0 0
59067- 0 0 0 0 0 0 0 0 0 0 0 0
59068- 0 0 1 0 0 1 0 0 1 0 0 0
59069- 0 0 0 0 0 0 0 0 0 0 0 0
59070- 0 0 0 0 0 0 0 0 0 0 0 0
59071- 0 0 0 0 0 0 0 0 0 0 0 0
59072- 0 0 0 0 0 0 0 0 0 0 0 0
59073- 0 0 0 0 0 0 0 0 0 0 0 0
59074- 14 14 14 42 42 42 86 86 86 10 10 10
59075- 2 2 6 2 2 6 2 2 6 2 2 6
59076- 2 2 6 2 2 6 2 2 6 2 2 6
59077- 2 2 6 2 2 6 2 2 6 30 30 30
59078- 94 94 94 94 94 94 58 58 58 26 26 26
59079- 2 2 6 6 6 6 78 78 78 54 54 54
59080- 22 22 22 6 6 6 0 0 0 0 0 0
59081- 0 0 0 0 0 0 0 0 0 0 0 0
59082- 0 0 0 0 0 0 0 0 0 0 0 0
59083- 0 0 0 0 0 0 0 0 0 0 0 0
59084- 0 0 0 0 0 0 0 0 0 0 0 0
59085- 0 0 0 0 0 0 0 0 0 0 0 0
59086- 0 0 0 0 0 0 0 0 0 0 0 0
59087- 0 0 0 0 0 0 0 0 0 0 0 0
59088- 0 0 0 0 0 0 0 0 0 0 0 0
59089- 0 0 0 0 0 0 0 0 0 0 0 0
59090- 0 0 0 0 0 0 0 0 0 0 0 0
59091- 0 0 0 0 0 0 0 0 0 0 0 0
59092- 0 0 0 0 0 0 0 0 0 0 0 0
59093- 0 0 0 0 0 0 0 0 0 6 6 6
59094- 22 22 22 62 62 62 62 62 62 2 2 6
59095- 2 2 6 2 2 6 2 2 6 2 2 6
59096- 2 2 6 2 2 6 2 2 6 2 2 6
59097- 2 2 6 2 2 6 2 2 6 26 26 26
59098- 54 54 54 38 38 38 18 18 18 10 10 10
59099- 2 2 6 2 2 6 34 34 34 82 82 82
59100- 38 38 38 14 14 14 0 0 0 0 0 0
59101- 0 0 0 0 0 0 0 0 0 0 0 0
59102- 0 0 0 0 0 0 0 0 0 0 0 0
59103- 0 0 0 0 0 0 0 0 0 0 0 0
59104- 0 0 0 0 0 0 0 0 0 0 0 0
59105- 0 0 0 0 0 0 0 0 0 0 0 0
59106- 0 0 0 0 0 0 0 0 0 0 0 0
59107- 0 0 0 0 0 0 0 0 0 0 0 0
59108- 0 0 0 0 0 1 0 0 1 0 0 0
59109- 0 0 0 0 0 0 0 0 0 0 0 0
59110- 0 0 0 0 0 0 0 0 0 0 0 0
59111- 0 0 0 0 0 0 0 0 0 0 0 0
59112- 0 0 0 0 0 0 0 0 0 0 0 0
59113- 0 0 0 0 0 0 0 0 0 6 6 6
59114- 30 30 30 78 78 78 30 30 30 2 2 6
59115- 2 2 6 2 2 6 2 2 6 2 2 6
59116- 2 2 6 2 2 6 2 2 6 2 2 6
59117- 2 2 6 2 2 6 2 2 6 10 10 10
59118- 10 10 10 2 2 6 2 2 6 2 2 6
59119- 2 2 6 2 2 6 2 2 6 78 78 78
59120- 50 50 50 18 18 18 6 6 6 0 0 0
59121- 0 0 0 0 0 0 0 0 0 0 0 0
59122- 0 0 0 0 0 0 0 0 0 0 0 0
59123- 0 0 0 0 0 0 0 0 0 0 0 0
59124- 0 0 0 0 0 0 0 0 0 0 0 0
59125- 0 0 0 0 0 0 0 0 0 0 0 0
59126- 0 0 0 0 0 0 0 0 0 0 0 0
59127- 0 0 0 0 0 0 0 0 0 0 0 0
59128- 0 0 1 0 0 0 0 0 0 0 0 0
59129- 0 0 0 0 0 0 0 0 0 0 0 0
59130- 0 0 0 0 0 0 0 0 0 0 0 0
59131- 0 0 0 0 0 0 0 0 0 0 0 0
59132- 0 0 0 0 0 0 0 0 0 0 0 0
59133- 0 0 0 0 0 0 0 0 0 10 10 10
59134- 38 38 38 86 86 86 14 14 14 2 2 6
59135- 2 2 6 2 2 6 2 2 6 2 2 6
59136- 2 2 6 2 2 6 2 2 6 2 2 6
59137- 2 2 6 2 2 6 2 2 6 2 2 6
59138- 2 2 6 2 2 6 2 2 6 2 2 6
59139- 2 2 6 2 2 6 2 2 6 54 54 54
59140- 66 66 66 26 26 26 6 6 6 0 0 0
59141- 0 0 0 0 0 0 0 0 0 0 0 0
59142- 0 0 0 0 0 0 0 0 0 0 0 0
59143- 0 0 0 0 0 0 0 0 0 0 0 0
59144- 0 0 0 0 0 0 0 0 0 0 0 0
59145- 0 0 0 0 0 0 0 0 0 0 0 0
59146- 0 0 0 0 0 0 0 0 0 0 0 0
59147- 0 0 0 0 0 0 0 0 0 0 0 0
59148- 0 0 0 0 0 1 0 0 1 0 0 0
59149- 0 0 0 0 0 0 0 0 0 0 0 0
59150- 0 0 0 0 0 0 0 0 0 0 0 0
59151- 0 0 0 0 0 0 0 0 0 0 0 0
59152- 0 0 0 0 0 0 0 0 0 0 0 0
59153- 0 0 0 0 0 0 0 0 0 14 14 14
59154- 42 42 42 82 82 82 2 2 6 2 2 6
59155- 2 2 6 6 6 6 10 10 10 2 2 6
59156- 2 2 6 2 2 6 2 2 6 2 2 6
59157- 2 2 6 2 2 6 2 2 6 6 6 6
59158- 14 14 14 10 10 10 2 2 6 2 2 6
59159- 2 2 6 2 2 6 2 2 6 18 18 18
59160- 82 82 82 34 34 34 10 10 10 0 0 0
59161- 0 0 0 0 0 0 0 0 0 0 0 0
59162- 0 0 0 0 0 0 0 0 0 0 0 0
59163- 0 0 0 0 0 0 0 0 0 0 0 0
59164- 0 0 0 0 0 0 0 0 0 0 0 0
59165- 0 0 0 0 0 0 0 0 0 0 0 0
59166- 0 0 0 0 0 0 0 0 0 0 0 0
59167- 0 0 0 0 0 0 0 0 0 0 0 0
59168- 0 0 1 0 0 0 0 0 0 0 0 0
59169- 0 0 0 0 0 0 0 0 0 0 0 0
59170- 0 0 0 0 0 0 0 0 0 0 0 0
59171- 0 0 0 0 0 0 0 0 0 0 0 0
59172- 0 0 0 0 0 0 0 0 0 0 0 0
59173- 0 0 0 0 0 0 0 0 0 14 14 14
59174- 46 46 46 86 86 86 2 2 6 2 2 6
59175- 6 6 6 6 6 6 22 22 22 34 34 34
59176- 6 6 6 2 2 6 2 2 6 2 2 6
59177- 2 2 6 2 2 6 18 18 18 34 34 34
59178- 10 10 10 50 50 50 22 22 22 2 2 6
59179- 2 2 6 2 2 6 2 2 6 10 10 10
59180- 86 86 86 42 42 42 14 14 14 0 0 0
59181- 0 0 0 0 0 0 0 0 0 0 0 0
59182- 0 0 0 0 0 0 0 0 0 0 0 0
59183- 0 0 0 0 0 0 0 0 0 0 0 0
59184- 0 0 0 0 0 0 0 0 0 0 0 0
59185- 0 0 0 0 0 0 0 0 0 0 0 0
59186- 0 0 0 0 0 0 0 0 0 0 0 0
59187- 0 0 0 0 0 0 0 0 0 0 0 0
59188- 0 0 1 0 0 1 0 0 1 0 0 0
59189- 0 0 0 0 0 0 0 0 0 0 0 0
59190- 0 0 0 0 0 0 0 0 0 0 0 0
59191- 0 0 0 0 0 0 0 0 0 0 0 0
59192- 0 0 0 0 0 0 0 0 0 0 0 0
59193- 0 0 0 0 0 0 0 0 0 14 14 14
59194- 46 46 46 86 86 86 2 2 6 2 2 6
59195- 38 38 38 116 116 116 94 94 94 22 22 22
59196- 22 22 22 2 2 6 2 2 6 2 2 6
59197- 14 14 14 86 86 86 138 138 138 162 162 162
59198-154 154 154 38 38 38 26 26 26 6 6 6
59199- 2 2 6 2 2 6 2 2 6 2 2 6
59200- 86 86 86 46 46 46 14 14 14 0 0 0
59201- 0 0 0 0 0 0 0 0 0 0 0 0
59202- 0 0 0 0 0 0 0 0 0 0 0 0
59203- 0 0 0 0 0 0 0 0 0 0 0 0
59204- 0 0 0 0 0 0 0 0 0 0 0 0
59205- 0 0 0 0 0 0 0 0 0 0 0 0
59206- 0 0 0 0 0 0 0 0 0 0 0 0
59207- 0 0 0 0 0 0 0 0 0 0 0 0
59208- 0 0 0 0 0 0 0 0 0 0 0 0
59209- 0 0 0 0 0 0 0 0 0 0 0 0
59210- 0 0 0 0 0 0 0 0 0 0 0 0
59211- 0 0 0 0 0 0 0 0 0 0 0 0
59212- 0 0 0 0 0 0 0 0 0 0 0 0
59213- 0 0 0 0 0 0 0 0 0 14 14 14
59214- 46 46 46 86 86 86 2 2 6 14 14 14
59215-134 134 134 198 198 198 195 195 195 116 116 116
59216- 10 10 10 2 2 6 2 2 6 6 6 6
59217-101 98 89 187 187 187 210 210 210 218 218 218
59218-214 214 214 134 134 134 14 14 14 6 6 6
59219- 2 2 6 2 2 6 2 2 6 2 2 6
59220- 86 86 86 50 50 50 18 18 18 6 6 6
59221- 0 0 0 0 0 0 0 0 0 0 0 0
59222- 0 0 0 0 0 0 0 0 0 0 0 0
59223- 0 0 0 0 0 0 0 0 0 0 0 0
59224- 0 0 0 0 0 0 0 0 0 0 0 0
59225- 0 0 0 0 0 0 0 0 0 0 0 0
59226- 0 0 0 0 0 0 0 0 0 0 0 0
59227- 0 0 0 0 0 0 0 0 1 0 0 0
59228- 0 0 1 0 0 1 0 0 1 0 0 0
59229- 0 0 0 0 0 0 0 0 0 0 0 0
59230- 0 0 0 0 0 0 0 0 0 0 0 0
59231- 0 0 0 0 0 0 0 0 0 0 0 0
59232- 0 0 0 0 0 0 0 0 0 0 0 0
59233- 0 0 0 0 0 0 0 0 0 14 14 14
59234- 46 46 46 86 86 86 2 2 6 54 54 54
59235-218 218 218 195 195 195 226 226 226 246 246 246
59236- 58 58 58 2 2 6 2 2 6 30 30 30
59237-210 210 210 253 253 253 174 174 174 123 123 123
59238-221 221 221 234 234 234 74 74 74 2 2 6
59239- 2 2 6 2 2 6 2 2 6 2 2 6
59240- 70 70 70 58 58 58 22 22 22 6 6 6
59241- 0 0 0 0 0 0 0 0 0 0 0 0
59242- 0 0 0 0 0 0 0 0 0 0 0 0
59243- 0 0 0 0 0 0 0 0 0 0 0 0
59244- 0 0 0 0 0 0 0 0 0 0 0 0
59245- 0 0 0 0 0 0 0 0 0 0 0 0
59246- 0 0 0 0 0 0 0 0 0 0 0 0
59247- 0 0 0 0 0 0 0 0 0 0 0 0
59248- 0 0 0 0 0 0 0 0 0 0 0 0
59249- 0 0 0 0 0 0 0 0 0 0 0 0
59250- 0 0 0 0 0 0 0 0 0 0 0 0
59251- 0 0 0 0 0 0 0 0 0 0 0 0
59252- 0 0 0 0 0 0 0 0 0 0 0 0
59253- 0 0 0 0 0 0 0 0 0 14 14 14
59254- 46 46 46 82 82 82 2 2 6 106 106 106
59255-170 170 170 26 26 26 86 86 86 226 226 226
59256-123 123 123 10 10 10 14 14 14 46 46 46
59257-231 231 231 190 190 190 6 6 6 70 70 70
59258- 90 90 90 238 238 238 158 158 158 2 2 6
59259- 2 2 6 2 2 6 2 2 6 2 2 6
59260- 70 70 70 58 58 58 22 22 22 6 6 6
59261- 0 0 0 0 0 0 0 0 0 0 0 0
59262- 0 0 0 0 0 0 0 0 0 0 0 0
59263- 0 0 0 0 0 0 0 0 0 0 0 0
59264- 0 0 0 0 0 0 0 0 0 0 0 0
59265- 0 0 0 0 0 0 0 0 0 0 0 0
59266- 0 0 0 0 0 0 0 0 0 0 0 0
59267- 0 0 0 0 0 0 0 0 1 0 0 0
59268- 0 0 1 0 0 1 0 0 1 0 0 0
59269- 0 0 0 0 0 0 0 0 0 0 0 0
59270- 0 0 0 0 0 0 0 0 0 0 0 0
59271- 0 0 0 0 0 0 0 0 0 0 0 0
59272- 0 0 0 0 0 0 0 0 0 0 0 0
59273- 0 0 0 0 0 0 0 0 0 14 14 14
59274- 42 42 42 86 86 86 6 6 6 116 116 116
59275-106 106 106 6 6 6 70 70 70 149 149 149
59276-128 128 128 18 18 18 38 38 38 54 54 54
59277-221 221 221 106 106 106 2 2 6 14 14 14
59278- 46 46 46 190 190 190 198 198 198 2 2 6
59279- 2 2 6 2 2 6 2 2 6 2 2 6
59280- 74 74 74 62 62 62 22 22 22 6 6 6
59281- 0 0 0 0 0 0 0 0 0 0 0 0
59282- 0 0 0 0 0 0 0 0 0 0 0 0
59283- 0 0 0 0 0 0 0 0 0 0 0 0
59284- 0 0 0 0 0 0 0 0 0 0 0 0
59285- 0 0 0 0 0 0 0 0 0 0 0 0
59286- 0 0 0 0 0 0 0 0 0 0 0 0
59287- 0 0 0 0 0 0 0 0 1 0 0 0
59288- 0 0 1 0 0 0 0 0 1 0 0 0
59289- 0 0 0 0 0 0 0 0 0 0 0 0
59290- 0 0 0 0 0 0 0 0 0 0 0 0
59291- 0 0 0 0 0 0 0 0 0 0 0 0
59292- 0 0 0 0 0 0 0 0 0 0 0 0
59293- 0 0 0 0 0 0 0 0 0 14 14 14
59294- 42 42 42 94 94 94 14 14 14 101 101 101
59295-128 128 128 2 2 6 18 18 18 116 116 116
59296-118 98 46 121 92 8 121 92 8 98 78 10
59297-162 162 162 106 106 106 2 2 6 2 2 6
59298- 2 2 6 195 195 195 195 195 195 6 6 6
59299- 2 2 6 2 2 6 2 2 6 2 2 6
59300- 74 74 74 62 62 62 22 22 22 6 6 6
59301- 0 0 0 0 0 0 0 0 0 0 0 0
59302- 0 0 0 0 0 0 0 0 0 0 0 0
59303- 0 0 0 0 0 0 0 0 0 0 0 0
59304- 0 0 0 0 0 0 0 0 0 0 0 0
59305- 0 0 0 0 0 0 0 0 0 0 0 0
59306- 0 0 0 0 0 0 0 0 0 0 0 0
59307- 0 0 0 0 0 0 0 0 1 0 0 1
59308- 0 0 1 0 0 0 0 0 1 0 0 0
59309- 0 0 0 0 0 0 0 0 0 0 0 0
59310- 0 0 0 0 0 0 0 0 0 0 0 0
59311- 0 0 0 0 0 0 0 0 0 0 0 0
59312- 0 0 0 0 0 0 0 0 0 0 0 0
59313- 0 0 0 0 0 0 0 0 0 10 10 10
59314- 38 38 38 90 90 90 14 14 14 58 58 58
59315-210 210 210 26 26 26 54 38 6 154 114 10
59316-226 170 11 236 186 11 225 175 15 184 144 12
59317-215 174 15 175 146 61 37 26 9 2 2 6
59318- 70 70 70 246 246 246 138 138 138 2 2 6
59319- 2 2 6 2 2 6 2 2 6 2 2 6
59320- 70 70 70 66 66 66 26 26 26 6 6 6
59321- 0 0 0 0 0 0 0 0 0 0 0 0
59322- 0 0 0 0 0 0 0 0 0 0 0 0
59323- 0 0 0 0 0 0 0 0 0 0 0 0
59324- 0 0 0 0 0 0 0 0 0 0 0 0
59325- 0 0 0 0 0 0 0 0 0 0 0 0
59326- 0 0 0 0 0 0 0 0 0 0 0 0
59327- 0 0 0 0 0 0 0 0 0 0 0 0
59328- 0 0 0 0 0 0 0 0 0 0 0 0
59329- 0 0 0 0 0 0 0 0 0 0 0 0
59330- 0 0 0 0 0 0 0 0 0 0 0 0
59331- 0 0 0 0 0 0 0 0 0 0 0 0
59332- 0 0 0 0 0 0 0 0 0 0 0 0
59333- 0 0 0 0 0 0 0 0 0 10 10 10
59334- 38 38 38 86 86 86 14 14 14 10 10 10
59335-195 195 195 188 164 115 192 133 9 225 175 15
59336-239 182 13 234 190 10 232 195 16 232 200 30
59337-245 207 45 241 208 19 232 195 16 184 144 12
59338-218 194 134 211 206 186 42 42 42 2 2 6
59339- 2 2 6 2 2 6 2 2 6 2 2 6
59340- 50 50 50 74 74 74 30 30 30 6 6 6
59341- 0 0 0 0 0 0 0 0 0 0 0 0
59342- 0 0 0 0 0 0 0 0 0 0 0 0
59343- 0 0 0 0 0 0 0 0 0 0 0 0
59344- 0 0 0 0 0 0 0 0 0 0 0 0
59345- 0 0 0 0 0 0 0 0 0 0 0 0
59346- 0 0 0 0 0 0 0 0 0 0 0 0
59347- 0 0 0 0 0 0 0 0 0 0 0 0
59348- 0 0 0 0 0 0 0 0 0 0 0 0
59349- 0 0 0 0 0 0 0 0 0 0 0 0
59350- 0 0 0 0 0 0 0 0 0 0 0 0
59351- 0 0 0 0 0 0 0 0 0 0 0 0
59352- 0 0 0 0 0 0 0 0 0 0 0 0
59353- 0 0 0 0 0 0 0 0 0 10 10 10
59354- 34 34 34 86 86 86 14 14 14 2 2 6
59355-121 87 25 192 133 9 219 162 10 239 182 13
59356-236 186 11 232 195 16 241 208 19 244 214 54
59357-246 218 60 246 218 38 246 215 20 241 208 19
59358-241 208 19 226 184 13 121 87 25 2 2 6
59359- 2 2 6 2 2 6 2 2 6 2 2 6
59360- 50 50 50 82 82 82 34 34 34 10 10 10
59361- 0 0 0 0 0 0 0 0 0 0 0 0
59362- 0 0 0 0 0 0 0 0 0 0 0 0
59363- 0 0 0 0 0 0 0 0 0 0 0 0
59364- 0 0 0 0 0 0 0 0 0 0 0 0
59365- 0 0 0 0 0 0 0 0 0 0 0 0
59366- 0 0 0 0 0 0 0 0 0 0 0 0
59367- 0 0 0 0 0 0 0 0 0 0 0 0
59368- 0 0 0 0 0 0 0 0 0 0 0 0
59369- 0 0 0 0 0 0 0 0 0 0 0 0
59370- 0 0 0 0 0 0 0 0 0 0 0 0
59371- 0 0 0 0 0 0 0 0 0 0 0 0
59372- 0 0 0 0 0 0 0 0 0 0 0 0
59373- 0 0 0 0 0 0 0 0 0 10 10 10
59374- 34 34 34 82 82 82 30 30 30 61 42 6
59375-180 123 7 206 145 10 230 174 11 239 182 13
59376-234 190 10 238 202 15 241 208 19 246 218 74
59377-246 218 38 246 215 20 246 215 20 246 215 20
59378-226 184 13 215 174 15 184 144 12 6 6 6
59379- 2 2 6 2 2 6 2 2 6 2 2 6
59380- 26 26 26 94 94 94 42 42 42 14 14 14
59381- 0 0 0 0 0 0 0 0 0 0 0 0
59382- 0 0 0 0 0 0 0 0 0 0 0 0
59383- 0 0 0 0 0 0 0 0 0 0 0 0
59384- 0 0 0 0 0 0 0 0 0 0 0 0
59385- 0 0 0 0 0 0 0 0 0 0 0 0
59386- 0 0 0 0 0 0 0 0 0 0 0 0
59387- 0 0 0 0 0 0 0 0 0 0 0 0
59388- 0 0 0 0 0 0 0 0 0 0 0 0
59389- 0 0 0 0 0 0 0 0 0 0 0 0
59390- 0 0 0 0 0 0 0 0 0 0 0 0
59391- 0 0 0 0 0 0 0 0 0 0 0 0
59392- 0 0 0 0 0 0 0 0 0 0 0 0
59393- 0 0 0 0 0 0 0 0 0 10 10 10
59394- 30 30 30 78 78 78 50 50 50 104 69 6
59395-192 133 9 216 158 10 236 178 12 236 186 11
59396-232 195 16 241 208 19 244 214 54 245 215 43
59397-246 215 20 246 215 20 241 208 19 198 155 10
59398-200 144 11 216 158 10 156 118 10 2 2 6
59399- 2 2 6 2 2 6 2 2 6 2 2 6
59400- 6 6 6 90 90 90 54 54 54 18 18 18
59401- 6 6 6 0 0 0 0 0 0 0 0 0
59402- 0 0 0 0 0 0 0 0 0 0 0 0
59403- 0 0 0 0 0 0 0 0 0 0 0 0
59404- 0 0 0 0 0 0 0 0 0 0 0 0
59405- 0 0 0 0 0 0 0 0 0 0 0 0
59406- 0 0 0 0 0 0 0 0 0 0 0 0
59407- 0 0 0 0 0 0 0 0 0 0 0 0
59408- 0 0 0 0 0 0 0 0 0 0 0 0
59409- 0 0 0 0 0 0 0 0 0 0 0 0
59410- 0 0 0 0 0 0 0 0 0 0 0 0
59411- 0 0 0 0 0 0 0 0 0 0 0 0
59412- 0 0 0 0 0 0 0 0 0 0 0 0
59413- 0 0 0 0 0 0 0 0 0 10 10 10
59414- 30 30 30 78 78 78 46 46 46 22 22 22
59415-137 92 6 210 162 10 239 182 13 238 190 10
59416-238 202 15 241 208 19 246 215 20 246 215 20
59417-241 208 19 203 166 17 185 133 11 210 150 10
59418-216 158 10 210 150 10 102 78 10 2 2 6
59419- 6 6 6 54 54 54 14 14 14 2 2 6
59420- 2 2 6 62 62 62 74 74 74 30 30 30
59421- 10 10 10 0 0 0 0 0 0 0 0 0
59422- 0 0 0 0 0 0 0 0 0 0 0 0
59423- 0 0 0 0 0 0 0 0 0 0 0 0
59424- 0 0 0 0 0 0 0 0 0 0 0 0
59425- 0 0 0 0 0 0 0 0 0 0 0 0
59426- 0 0 0 0 0 0 0 0 0 0 0 0
59427- 0 0 0 0 0 0 0 0 0 0 0 0
59428- 0 0 0 0 0 0 0 0 0 0 0 0
59429- 0 0 0 0 0 0 0 0 0 0 0 0
59430- 0 0 0 0 0 0 0 0 0 0 0 0
59431- 0 0 0 0 0 0 0 0 0 0 0 0
59432- 0 0 0 0 0 0 0 0 0 0 0 0
59433- 0 0 0 0 0 0 0 0 0 10 10 10
59434- 34 34 34 78 78 78 50 50 50 6 6 6
59435- 94 70 30 139 102 15 190 146 13 226 184 13
59436-232 200 30 232 195 16 215 174 15 190 146 13
59437-168 122 10 192 133 9 210 150 10 213 154 11
59438-202 150 34 182 157 106 101 98 89 2 2 6
59439- 2 2 6 78 78 78 116 116 116 58 58 58
59440- 2 2 6 22 22 22 90 90 90 46 46 46
59441- 18 18 18 6 6 6 0 0 0 0 0 0
59442- 0 0 0 0 0 0 0 0 0 0 0 0
59443- 0 0 0 0 0 0 0 0 0 0 0 0
59444- 0 0 0 0 0 0 0 0 0 0 0 0
59445- 0 0 0 0 0 0 0 0 0 0 0 0
59446- 0 0 0 0 0 0 0 0 0 0 0 0
59447- 0 0 0 0 0 0 0 0 0 0 0 0
59448- 0 0 0 0 0 0 0 0 0 0 0 0
59449- 0 0 0 0 0 0 0 0 0 0 0 0
59450- 0 0 0 0 0 0 0 0 0 0 0 0
59451- 0 0 0 0 0 0 0 0 0 0 0 0
59452- 0 0 0 0 0 0 0 0 0 0 0 0
59453- 0 0 0 0 0 0 0 0 0 10 10 10
59454- 38 38 38 86 86 86 50 50 50 6 6 6
59455-128 128 128 174 154 114 156 107 11 168 122 10
59456-198 155 10 184 144 12 197 138 11 200 144 11
59457-206 145 10 206 145 10 197 138 11 188 164 115
59458-195 195 195 198 198 198 174 174 174 14 14 14
59459- 2 2 6 22 22 22 116 116 116 116 116 116
59460- 22 22 22 2 2 6 74 74 74 70 70 70
59461- 30 30 30 10 10 10 0 0 0 0 0 0
59462- 0 0 0 0 0 0 0 0 0 0 0 0
59463- 0 0 0 0 0 0 0 0 0 0 0 0
59464- 0 0 0 0 0 0 0 0 0 0 0 0
59465- 0 0 0 0 0 0 0 0 0 0 0 0
59466- 0 0 0 0 0 0 0 0 0 0 0 0
59467- 0 0 0 0 0 0 0 0 0 0 0 0
59468- 0 0 0 0 0 0 0 0 0 0 0 0
59469- 0 0 0 0 0 0 0 0 0 0 0 0
59470- 0 0 0 0 0 0 0 0 0 0 0 0
59471- 0 0 0 0 0 0 0 0 0 0 0 0
59472- 0 0 0 0 0 0 0 0 0 0 0 0
59473- 0 0 0 0 0 0 6 6 6 18 18 18
59474- 50 50 50 101 101 101 26 26 26 10 10 10
59475-138 138 138 190 190 190 174 154 114 156 107 11
59476-197 138 11 200 144 11 197 138 11 192 133 9
59477-180 123 7 190 142 34 190 178 144 187 187 187
59478-202 202 202 221 221 221 214 214 214 66 66 66
59479- 2 2 6 2 2 6 50 50 50 62 62 62
59480- 6 6 6 2 2 6 10 10 10 90 90 90
59481- 50 50 50 18 18 18 6 6 6 0 0 0
59482- 0 0 0 0 0 0 0 0 0 0 0 0
59483- 0 0 0 0 0 0 0 0 0 0 0 0
59484- 0 0 0 0 0 0 0 0 0 0 0 0
59485- 0 0 0 0 0 0 0 0 0 0 0 0
59486- 0 0 0 0 0 0 0 0 0 0 0 0
59487- 0 0 0 0 0 0 0 0 0 0 0 0
59488- 0 0 0 0 0 0 0 0 0 0 0 0
59489- 0 0 0 0 0 0 0 0 0 0 0 0
59490- 0 0 0 0 0 0 0 0 0 0 0 0
59491- 0 0 0 0 0 0 0 0 0 0 0 0
59492- 0 0 0 0 0 0 0 0 0 0 0 0
59493- 0 0 0 0 0 0 10 10 10 34 34 34
59494- 74 74 74 74 74 74 2 2 6 6 6 6
59495-144 144 144 198 198 198 190 190 190 178 166 146
59496-154 121 60 156 107 11 156 107 11 168 124 44
59497-174 154 114 187 187 187 190 190 190 210 210 210
59498-246 246 246 253 253 253 253 253 253 182 182 182
59499- 6 6 6 2 2 6 2 2 6 2 2 6
59500- 2 2 6 2 2 6 2 2 6 62 62 62
59501- 74 74 74 34 34 34 14 14 14 0 0 0
59502- 0 0 0 0 0 0 0 0 0 0 0 0
59503- 0 0 0 0 0 0 0 0 0 0 0 0
59504- 0 0 0 0 0 0 0 0 0 0 0 0
59505- 0 0 0 0 0 0 0 0 0 0 0 0
59506- 0 0 0 0 0 0 0 0 0 0 0 0
59507- 0 0 0 0 0 0 0 0 0 0 0 0
59508- 0 0 0 0 0 0 0 0 0 0 0 0
59509- 0 0 0 0 0 0 0 0 0 0 0 0
59510- 0 0 0 0 0 0 0 0 0 0 0 0
59511- 0 0 0 0 0 0 0 0 0 0 0 0
59512- 0 0 0 0 0 0 0 0 0 0 0 0
59513- 0 0 0 10 10 10 22 22 22 54 54 54
59514- 94 94 94 18 18 18 2 2 6 46 46 46
59515-234 234 234 221 221 221 190 190 190 190 190 190
59516-190 190 190 187 187 187 187 187 187 190 190 190
59517-190 190 190 195 195 195 214 214 214 242 242 242
59518-253 253 253 253 253 253 253 253 253 253 253 253
59519- 82 82 82 2 2 6 2 2 6 2 2 6
59520- 2 2 6 2 2 6 2 2 6 14 14 14
59521- 86 86 86 54 54 54 22 22 22 6 6 6
59522- 0 0 0 0 0 0 0 0 0 0 0 0
59523- 0 0 0 0 0 0 0 0 0 0 0 0
59524- 0 0 0 0 0 0 0 0 0 0 0 0
59525- 0 0 0 0 0 0 0 0 0 0 0 0
59526- 0 0 0 0 0 0 0 0 0 0 0 0
59527- 0 0 0 0 0 0 0 0 0 0 0 0
59528- 0 0 0 0 0 0 0 0 0 0 0 0
59529- 0 0 0 0 0 0 0 0 0 0 0 0
59530- 0 0 0 0 0 0 0 0 0 0 0 0
59531- 0 0 0 0 0 0 0 0 0 0 0 0
59532- 0 0 0 0 0 0 0 0 0 0 0 0
59533- 6 6 6 18 18 18 46 46 46 90 90 90
59534- 46 46 46 18 18 18 6 6 6 182 182 182
59535-253 253 253 246 246 246 206 206 206 190 190 190
59536-190 190 190 190 190 190 190 190 190 190 190 190
59537-206 206 206 231 231 231 250 250 250 253 253 253
59538-253 253 253 253 253 253 253 253 253 253 253 253
59539-202 202 202 14 14 14 2 2 6 2 2 6
59540- 2 2 6 2 2 6 2 2 6 2 2 6
59541- 42 42 42 86 86 86 42 42 42 18 18 18
59542- 6 6 6 0 0 0 0 0 0 0 0 0
59543- 0 0 0 0 0 0 0 0 0 0 0 0
59544- 0 0 0 0 0 0 0 0 0 0 0 0
59545- 0 0 0 0 0 0 0 0 0 0 0 0
59546- 0 0 0 0 0 0 0 0 0 0 0 0
59547- 0 0 0 0 0 0 0 0 0 0 0 0
59548- 0 0 0 0 0 0 0 0 0 0 0 0
59549- 0 0 0 0 0 0 0 0 0 0 0 0
59550- 0 0 0 0 0 0 0 0 0 0 0 0
59551- 0 0 0 0 0 0 0 0 0 0 0 0
59552- 0 0 0 0 0 0 0 0 0 6 6 6
59553- 14 14 14 38 38 38 74 74 74 66 66 66
59554- 2 2 6 6 6 6 90 90 90 250 250 250
59555-253 253 253 253 253 253 238 238 238 198 198 198
59556-190 190 190 190 190 190 195 195 195 221 221 221
59557-246 246 246 253 253 253 253 253 253 253 253 253
59558-253 253 253 253 253 253 253 253 253 253 253 253
59559-253 253 253 82 82 82 2 2 6 2 2 6
59560- 2 2 6 2 2 6 2 2 6 2 2 6
59561- 2 2 6 78 78 78 70 70 70 34 34 34
59562- 14 14 14 6 6 6 0 0 0 0 0 0
59563- 0 0 0 0 0 0 0 0 0 0 0 0
59564- 0 0 0 0 0 0 0 0 0 0 0 0
59565- 0 0 0 0 0 0 0 0 0 0 0 0
59566- 0 0 0 0 0 0 0 0 0 0 0 0
59567- 0 0 0 0 0 0 0 0 0 0 0 0
59568- 0 0 0 0 0 0 0 0 0 0 0 0
59569- 0 0 0 0 0 0 0 0 0 0 0 0
59570- 0 0 0 0 0 0 0 0 0 0 0 0
59571- 0 0 0 0 0 0 0 0 0 0 0 0
59572- 0 0 0 0 0 0 0 0 0 14 14 14
59573- 34 34 34 66 66 66 78 78 78 6 6 6
59574- 2 2 6 18 18 18 218 218 218 253 253 253
59575-253 253 253 253 253 253 253 253 253 246 246 246
59576-226 226 226 231 231 231 246 246 246 253 253 253
59577-253 253 253 253 253 253 253 253 253 253 253 253
59578-253 253 253 253 253 253 253 253 253 253 253 253
59579-253 253 253 178 178 178 2 2 6 2 2 6
59580- 2 2 6 2 2 6 2 2 6 2 2 6
59581- 2 2 6 18 18 18 90 90 90 62 62 62
59582- 30 30 30 10 10 10 0 0 0 0 0 0
59583- 0 0 0 0 0 0 0 0 0 0 0 0
59584- 0 0 0 0 0 0 0 0 0 0 0 0
59585- 0 0 0 0 0 0 0 0 0 0 0 0
59586- 0 0 0 0 0 0 0 0 0 0 0 0
59587- 0 0 0 0 0 0 0 0 0 0 0 0
59588- 0 0 0 0 0 0 0 0 0 0 0 0
59589- 0 0 0 0 0 0 0 0 0 0 0 0
59590- 0 0 0 0 0 0 0 0 0 0 0 0
59591- 0 0 0 0 0 0 0 0 0 0 0 0
59592- 0 0 0 0 0 0 10 10 10 26 26 26
59593- 58 58 58 90 90 90 18 18 18 2 2 6
59594- 2 2 6 110 110 110 253 253 253 253 253 253
59595-253 253 253 253 253 253 253 253 253 253 253 253
59596-250 250 250 253 253 253 253 253 253 253 253 253
59597-253 253 253 253 253 253 253 253 253 253 253 253
59598-253 253 253 253 253 253 253 253 253 253 253 253
59599-253 253 253 231 231 231 18 18 18 2 2 6
59600- 2 2 6 2 2 6 2 2 6 2 2 6
59601- 2 2 6 2 2 6 18 18 18 94 94 94
59602- 54 54 54 26 26 26 10 10 10 0 0 0
59603- 0 0 0 0 0 0 0 0 0 0 0 0
59604- 0 0 0 0 0 0 0 0 0 0 0 0
59605- 0 0 0 0 0 0 0 0 0 0 0 0
59606- 0 0 0 0 0 0 0 0 0 0 0 0
59607- 0 0 0 0 0 0 0 0 0 0 0 0
59608- 0 0 0 0 0 0 0 0 0 0 0 0
59609- 0 0 0 0 0 0 0 0 0 0 0 0
59610- 0 0 0 0 0 0 0 0 0 0 0 0
59611- 0 0 0 0 0 0 0 0 0 0 0 0
59612- 0 0 0 6 6 6 22 22 22 50 50 50
59613- 90 90 90 26 26 26 2 2 6 2 2 6
59614- 14 14 14 195 195 195 250 250 250 253 253 253
59615-253 253 253 253 253 253 253 253 253 253 253 253
59616-253 253 253 253 253 253 253 253 253 253 253 253
59617-253 253 253 253 253 253 253 253 253 253 253 253
59618-253 253 253 253 253 253 253 253 253 253 253 253
59619-250 250 250 242 242 242 54 54 54 2 2 6
59620- 2 2 6 2 2 6 2 2 6 2 2 6
59621- 2 2 6 2 2 6 2 2 6 38 38 38
59622- 86 86 86 50 50 50 22 22 22 6 6 6
59623- 0 0 0 0 0 0 0 0 0 0 0 0
59624- 0 0 0 0 0 0 0 0 0 0 0 0
59625- 0 0 0 0 0 0 0 0 0 0 0 0
59626- 0 0 0 0 0 0 0 0 0 0 0 0
59627- 0 0 0 0 0 0 0 0 0 0 0 0
59628- 0 0 0 0 0 0 0 0 0 0 0 0
59629- 0 0 0 0 0 0 0 0 0 0 0 0
59630- 0 0 0 0 0 0 0 0 0 0 0 0
59631- 0 0 0 0 0 0 0 0 0 0 0 0
59632- 6 6 6 14 14 14 38 38 38 82 82 82
59633- 34 34 34 2 2 6 2 2 6 2 2 6
59634- 42 42 42 195 195 195 246 246 246 253 253 253
59635-253 253 253 253 253 253 253 253 253 250 250 250
59636-242 242 242 242 242 242 250 250 250 253 253 253
59637-253 253 253 253 253 253 253 253 253 253 253 253
59638-253 253 253 250 250 250 246 246 246 238 238 238
59639-226 226 226 231 231 231 101 101 101 6 6 6
59640- 2 2 6 2 2 6 2 2 6 2 2 6
59641- 2 2 6 2 2 6 2 2 6 2 2 6
59642- 38 38 38 82 82 82 42 42 42 14 14 14
59643- 6 6 6 0 0 0 0 0 0 0 0 0
59644- 0 0 0 0 0 0 0 0 0 0 0 0
59645- 0 0 0 0 0 0 0 0 0 0 0 0
59646- 0 0 0 0 0 0 0 0 0 0 0 0
59647- 0 0 0 0 0 0 0 0 0 0 0 0
59648- 0 0 0 0 0 0 0 0 0 0 0 0
59649- 0 0 0 0 0 0 0 0 0 0 0 0
59650- 0 0 0 0 0 0 0 0 0 0 0 0
59651- 0 0 0 0 0 0 0 0 0 0 0 0
59652- 10 10 10 26 26 26 62 62 62 66 66 66
59653- 2 2 6 2 2 6 2 2 6 6 6 6
59654- 70 70 70 170 170 170 206 206 206 234 234 234
59655-246 246 246 250 250 250 250 250 250 238 238 238
59656-226 226 226 231 231 231 238 238 238 250 250 250
59657-250 250 250 250 250 250 246 246 246 231 231 231
59658-214 214 214 206 206 206 202 202 202 202 202 202
59659-198 198 198 202 202 202 182 182 182 18 18 18
59660- 2 2 6 2 2 6 2 2 6 2 2 6
59661- 2 2 6 2 2 6 2 2 6 2 2 6
59662- 2 2 6 62 62 62 66 66 66 30 30 30
59663- 10 10 10 0 0 0 0 0 0 0 0 0
59664- 0 0 0 0 0 0 0 0 0 0 0 0
59665- 0 0 0 0 0 0 0 0 0 0 0 0
59666- 0 0 0 0 0 0 0 0 0 0 0 0
59667- 0 0 0 0 0 0 0 0 0 0 0 0
59668- 0 0 0 0 0 0 0 0 0 0 0 0
59669- 0 0 0 0 0 0 0 0 0 0 0 0
59670- 0 0 0 0 0 0 0 0 0 0 0 0
59671- 0 0 0 0 0 0 0 0 0 0 0 0
59672- 14 14 14 42 42 42 82 82 82 18 18 18
59673- 2 2 6 2 2 6 2 2 6 10 10 10
59674- 94 94 94 182 182 182 218 218 218 242 242 242
59675-250 250 250 253 253 253 253 253 253 250 250 250
59676-234 234 234 253 253 253 253 253 253 253 253 253
59677-253 253 253 253 253 253 253 253 253 246 246 246
59678-238 238 238 226 226 226 210 210 210 202 202 202
59679-195 195 195 195 195 195 210 210 210 158 158 158
59680- 6 6 6 14 14 14 50 50 50 14 14 14
59681- 2 2 6 2 2 6 2 2 6 2 2 6
59682- 2 2 6 6 6 6 86 86 86 46 46 46
59683- 18 18 18 6 6 6 0 0 0 0 0 0
59684- 0 0 0 0 0 0 0 0 0 0 0 0
59685- 0 0 0 0 0 0 0 0 0 0 0 0
59686- 0 0 0 0 0 0 0 0 0 0 0 0
59687- 0 0 0 0 0 0 0 0 0 0 0 0
59688- 0 0 0 0 0 0 0 0 0 0 0 0
59689- 0 0 0 0 0 0 0 0 0 0 0 0
59690- 0 0 0 0 0 0 0 0 0 0 0 0
59691- 0 0 0 0 0 0 0 0 0 6 6 6
59692- 22 22 22 54 54 54 70 70 70 2 2 6
59693- 2 2 6 10 10 10 2 2 6 22 22 22
59694-166 166 166 231 231 231 250 250 250 253 253 253
59695-253 253 253 253 253 253 253 253 253 250 250 250
59696-242 242 242 253 253 253 253 253 253 253 253 253
59697-253 253 253 253 253 253 253 253 253 253 253 253
59698-253 253 253 253 253 253 253 253 253 246 246 246
59699-231 231 231 206 206 206 198 198 198 226 226 226
59700- 94 94 94 2 2 6 6 6 6 38 38 38
59701- 30 30 30 2 2 6 2 2 6 2 2 6
59702- 2 2 6 2 2 6 62 62 62 66 66 66
59703- 26 26 26 10 10 10 0 0 0 0 0 0
59704- 0 0 0 0 0 0 0 0 0 0 0 0
59705- 0 0 0 0 0 0 0 0 0 0 0 0
59706- 0 0 0 0 0 0 0 0 0 0 0 0
59707- 0 0 0 0 0 0 0 0 0 0 0 0
59708- 0 0 0 0 0 0 0 0 0 0 0 0
59709- 0 0 0 0 0 0 0 0 0 0 0 0
59710- 0 0 0 0 0 0 0 0 0 0 0 0
59711- 0 0 0 0 0 0 0 0 0 10 10 10
59712- 30 30 30 74 74 74 50 50 50 2 2 6
59713- 26 26 26 26 26 26 2 2 6 106 106 106
59714-238 238 238 253 253 253 253 253 253 253 253 253
59715-253 253 253 253 253 253 253 253 253 253 253 253
59716-253 253 253 253 253 253 253 253 253 253 253 253
59717-253 253 253 253 253 253 253 253 253 253 253 253
59718-253 253 253 253 253 253 253 253 253 253 253 253
59719-253 253 253 246 246 246 218 218 218 202 202 202
59720-210 210 210 14 14 14 2 2 6 2 2 6
59721- 30 30 30 22 22 22 2 2 6 2 2 6
59722- 2 2 6 2 2 6 18 18 18 86 86 86
59723- 42 42 42 14 14 14 0 0 0 0 0 0
59724- 0 0 0 0 0 0 0 0 0 0 0 0
59725- 0 0 0 0 0 0 0 0 0 0 0 0
59726- 0 0 0 0 0 0 0 0 0 0 0 0
59727- 0 0 0 0 0 0 0 0 0 0 0 0
59728- 0 0 0 0 0 0 0 0 0 0 0 0
59729- 0 0 0 0 0 0 0 0 0 0 0 0
59730- 0 0 0 0 0 0 0 0 0 0 0 0
59731- 0 0 0 0 0 0 0 0 0 14 14 14
59732- 42 42 42 90 90 90 22 22 22 2 2 6
59733- 42 42 42 2 2 6 18 18 18 218 218 218
59734-253 253 253 253 253 253 253 253 253 253 253 253
59735-253 253 253 253 253 253 253 253 253 253 253 253
59736-253 253 253 253 253 253 253 253 253 253 253 253
59737-253 253 253 253 253 253 253 253 253 253 253 253
59738-253 253 253 253 253 253 253 253 253 253 253 253
59739-253 253 253 253 253 253 250 250 250 221 221 221
59740-218 218 218 101 101 101 2 2 6 14 14 14
59741- 18 18 18 38 38 38 10 10 10 2 2 6
59742- 2 2 6 2 2 6 2 2 6 78 78 78
59743- 58 58 58 22 22 22 6 6 6 0 0 0
59744- 0 0 0 0 0 0 0 0 0 0 0 0
59745- 0 0 0 0 0 0 0 0 0 0 0 0
59746- 0 0 0 0 0 0 0 0 0 0 0 0
59747- 0 0 0 0 0 0 0 0 0 0 0 0
59748- 0 0 0 0 0 0 0 0 0 0 0 0
59749- 0 0 0 0 0 0 0 0 0 0 0 0
59750- 0 0 0 0 0 0 0 0 0 0 0 0
59751- 0 0 0 0 0 0 6 6 6 18 18 18
59752- 54 54 54 82 82 82 2 2 6 26 26 26
59753- 22 22 22 2 2 6 123 123 123 253 253 253
59754-253 253 253 253 253 253 253 253 253 253 253 253
59755-253 253 253 253 253 253 253 253 253 253 253 253
59756-253 253 253 253 253 253 253 253 253 253 253 253
59757-253 253 253 253 253 253 253 253 253 253 253 253
59758-253 253 253 253 253 253 253 253 253 253 253 253
59759-253 253 253 253 253 253 253 253 253 250 250 250
59760-238 238 238 198 198 198 6 6 6 38 38 38
59761- 58 58 58 26 26 26 38 38 38 2 2 6
59762- 2 2 6 2 2 6 2 2 6 46 46 46
59763- 78 78 78 30 30 30 10 10 10 0 0 0
59764- 0 0 0 0 0 0 0 0 0 0 0 0
59765- 0 0 0 0 0 0 0 0 0 0 0 0
59766- 0 0 0 0 0 0 0 0 0 0 0 0
59767- 0 0 0 0 0 0 0 0 0 0 0 0
59768- 0 0 0 0 0 0 0 0 0 0 0 0
59769- 0 0 0 0 0 0 0 0 0 0 0 0
59770- 0 0 0 0 0 0 0 0 0 0 0 0
59771- 0 0 0 0 0 0 10 10 10 30 30 30
59772- 74 74 74 58 58 58 2 2 6 42 42 42
59773- 2 2 6 22 22 22 231 231 231 253 253 253
59774-253 253 253 253 253 253 253 253 253 253 253 253
59775-253 253 253 253 253 253 253 253 253 250 250 250
59776-253 253 253 253 253 253 253 253 253 253 253 253
59777-253 253 253 253 253 253 253 253 253 253 253 253
59778-253 253 253 253 253 253 253 253 253 253 253 253
59779-253 253 253 253 253 253 253 253 253 253 253 253
59780-253 253 253 246 246 246 46 46 46 38 38 38
59781- 42 42 42 14 14 14 38 38 38 14 14 14
59782- 2 2 6 2 2 6 2 2 6 6 6 6
59783- 86 86 86 46 46 46 14 14 14 0 0 0
59784- 0 0 0 0 0 0 0 0 0 0 0 0
59785- 0 0 0 0 0 0 0 0 0 0 0 0
59786- 0 0 0 0 0 0 0 0 0 0 0 0
59787- 0 0 0 0 0 0 0 0 0 0 0 0
59788- 0 0 0 0 0 0 0 0 0 0 0 0
59789- 0 0 0 0 0 0 0 0 0 0 0 0
59790- 0 0 0 0 0 0 0 0 0 0 0 0
59791- 0 0 0 6 6 6 14 14 14 42 42 42
59792- 90 90 90 18 18 18 18 18 18 26 26 26
59793- 2 2 6 116 116 116 253 253 253 253 253 253
59794-253 253 253 253 253 253 253 253 253 253 253 253
59795-253 253 253 253 253 253 250 250 250 238 238 238
59796-253 253 253 253 253 253 253 253 253 253 253 253
59797-253 253 253 253 253 253 253 253 253 253 253 253
59798-253 253 253 253 253 253 253 253 253 253 253 253
59799-253 253 253 253 253 253 253 253 253 253 253 253
59800-253 253 253 253 253 253 94 94 94 6 6 6
59801- 2 2 6 2 2 6 10 10 10 34 34 34
59802- 2 2 6 2 2 6 2 2 6 2 2 6
59803- 74 74 74 58 58 58 22 22 22 6 6 6
59804- 0 0 0 0 0 0 0 0 0 0 0 0
59805- 0 0 0 0 0 0 0 0 0 0 0 0
59806- 0 0 0 0 0 0 0 0 0 0 0 0
59807- 0 0 0 0 0 0 0 0 0 0 0 0
59808- 0 0 0 0 0 0 0 0 0 0 0 0
59809- 0 0 0 0 0 0 0 0 0 0 0 0
59810- 0 0 0 0 0 0 0 0 0 0 0 0
59811- 0 0 0 10 10 10 26 26 26 66 66 66
59812- 82 82 82 2 2 6 38 38 38 6 6 6
59813- 14 14 14 210 210 210 253 253 253 253 253 253
59814-253 253 253 253 253 253 253 253 253 253 253 253
59815-253 253 253 253 253 253 246 246 246 242 242 242
59816-253 253 253 253 253 253 253 253 253 253 253 253
59817-253 253 253 253 253 253 253 253 253 253 253 253
59818-253 253 253 253 253 253 253 253 253 253 253 253
59819-253 253 253 253 253 253 253 253 253 253 253 253
59820-253 253 253 253 253 253 144 144 144 2 2 6
59821- 2 2 6 2 2 6 2 2 6 46 46 46
59822- 2 2 6 2 2 6 2 2 6 2 2 6
59823- 42 42 42 74 74 74 30 30 30 10 10 10
59824- 0 0 0 0 0 0 0 0 0 0 0 0
59825- 0 0 0 0 0 0 0 0 0 0 0 0
59826- 0 0 0 0 0 0 0 0 0 0 0 0
59827- 0 0 0 0 0 0 0 0 0 0 0 0
59828- 0 0 0 0 0 0 0 0 0 0 0 0
59829- 0 0 0 0 0 0 0 0 0 0 0 0
59830- 0 0 0 0 0 0 0 0 0 0 0 0
59831- 6 6 6 14 14 14 42 42 42 90 90 90
59832- 26 26 26 6 6 6 42 42 42 2 2 6
59833- 74 74 74 250 250 250 253 253 253 253 253 253
59834-253 253 253 253 253 253 253 253 253 253 253 253
59835-253 253 253 253 253 253 242 242 242 242 242 242
59836-253 253 253 253 253 253 253 253 253 253 253 253
59837-253 253 253 253 253 253 253 253 253 253 253 253
59838-253 253 253 253 253 253 253 253 253 253 253 253
59839-253 253 253 253 253 253 253 253 253 253 253 253
59840-253 253 253 253 253 253 182 182 182 2 2 6
59841- 2 2 6 2 2 6 2 2 6 46 46 46
59842- 2 2 6 2 2 6 2 2 6 2 2 6
59843- 10 10 10 86 86 86 38 38 38 10 10 10
59844- 0 0 0 0 0 0 0 0 0 0 0 0
59845- 0 0 0 0 0 0 0 0 0 0 0 0
59846- 0 0 0 0 0 0 0 0 0 0 0 0
59847- 0 0 0 0 0 0 0 0 0 0 0 0
59848- 0 0 0 0 0 0 0 0 0 0 0 0
59849- 0 0 0 0 0 0 0 0 0 0 0 0
59850- 0 0 0 0 0 0 0 0 0 0 0 0
59851- 10 10 10 26 26 26 66 66 66 82 82 82
59852- 2 2 6 22 22 22 18 18 18 2 2 6
59853-149 149 149 253 253 253 253 253 253 253 253 253
59854-253 253 253 253 253 253 253 253 253 253 253 253
59855-253 253 253 253 253 253 234 234 234 242 242 242
59856-253 253 253 253 253 253 253 253 253 253 253 253
59857-253 253 253 253 253 253 253 253 253 253 253 253
59858-253 253 253 253 253 253 253 253 253 253 253 253
59859-253 253 253 253 253 253 253 253 253 253 253 253
59860-253 253 253 253 253 253 206 206 206 2 2 6
59861- 2 2 6 2 2 6 2 2 6 38 38 38
59862- 2 2 6 2 2 6 2 2 6 2 2 6
59863- 6 6 6 86 86 86 46 46 46 14 14 14
59864- 0 0 0 0 0 0 0 0 0 0 0 0
59865- 0 0 0 0 0 0 0 0 0 0 0 0
59866- 0 0 0 0 0 0 0 0 0 0 0 0
59867- 0 0 0 0 0 0 0 0 0 0 0 0
59868- 0 0 0 0 0 0 0 0 0 0 0 0
59869- 0 0 0 0 0 0 0 0 0 0 0 0
59870- 0 0 0 0 0 0 0 0 0 6 6 6
59871- 18 18 18 46 46 46 86 86 86 18 18 18
59872- 2 2 6 34 34 34 10 10 10 6 6 6
59873-210 210 210 253 253 253 253 253 253 253 253 253
59874-253 253 253 253 253 253 253 253 253 253 253 253
59875-253 253 253 253 253 253 234 234 234 242 242 242
59876-253 253 253 253 253 253 253 253 253 253 253 253
59877-253 253 253 253 253 253 253 253 253 253 253 253
59878-253 253 253 253 253 253 253 253 253 253 253 253
59879-253 253 253 253 253 253 253 253 253 253 253 253
59880-253 253 253 253 253 253 221 221 221 6 6 6
59881- 2 2 6 2 2 6 6 6 6 30 30 30
59882- 2 2 6 2 2 6 2 2 6 2 2 6
59883- 2 2 6 82 82 82 54 54 54 18 18 18
59884- 6 6 6 0 0 0 0 0 0 0 0 0
59885- 0 0 0 0 0 0 0 0 0 0 0 0
59886- 0 0 0 0 0 0 0 0 0 0 0 0
59887- 0 0 0 0 0 0 0 0 0 0 0 0
59888- 0 0 0 0 0 0 0 0 0 0 0 0
59889- 0 0 0 0 0 0 0 0 0 0 0 0
59890- 0 0 0 0 0 0 0 0 0 10 10 10
59891- 26 26 26 66 66 66 62 62 62 2 2 6
59892- 2 2 6 38 38 38 10 10 10 26 26 26
59893-238 238 238 253 253 253 253 253 253 253 253 253
59894-253 253 253 253 253 253 253 253 253 253 253 253
59895-253 253 253 253 253 253 231 231 231 238 238 238
59896-253 253 253 253 253 253 253 253 253 253 253 253
59897-253 253 253 253 253 253 253 253 253 253 253 253
59898-253 253 253 253 253 253 253 253 253 253 253 253
59899-253 253 253 253 253 253 253 253 253 253 253 253
59900-253 253 253 253 253 253 231 231 231 6 6 6
59901- 2 2 6 2 2 6 10 10 10 30 30 30
59902- 2 2 6 2 2 6 2 2 6 2 2 6
59903- 2 2 6 66 66 66 58 58 58 22 22 22
59904- 6 6 6 0 0 0 0 0 0 0 0 0
59905- 0 0 0 0 0 0 0 0 0 0 0 0
59906- 0 0 0 0 0 0 0 0 0 0 0 0
59907- 0 0 0 0 0 0 0 0 0 0 0 0
59908- 0 0 0 0 0 0 0 0 0 0 0 0
59909- 0 0 0 0 0 0 0 0 0 0 0 0
59910- 0 0 0 0 0 0 0 0 0 10 10 10
59911- 38 38 38 78 78 78 6 6 6 2 2 6
59912- 2 2 6 46 46 46 14 14 14 42 42 42
59913-246 246 246 253 253 253 253 253 253 253 253 253
59914-253 253 253 253 253 253 253 253 253 253 253 253
59915-253 253 253 253 253 253 231 231 231 242 242 242
59916-253 253 253 253 253 253 253 253 253 253 253 253
59917-253 253 253 253 253 253 253 253 253 253 253 253
59918-253 253 253 253 253 253 253 253 253 253 253 253
59919-253 253 253 253 253 253 253 253 253 253 253 253
59920-253 253 253 253 253 253 234 234 234 10 10 10
59921- 2 2 6 2 2 6 22 22 22 14 14 14
59922- 2 2 6 2 2 6 2 2 6 2 2 6
59923- 2 2 6 66 66 66 62 62 62 22 22 22
59924- 6 6 6 0 0 0 0 0 0 0 0 0
59925- 0 0 0 0 0 0 0 0 0 0 0 0
59926- 0 0 0 0 0 0 0 0 0 0 0 0
59927- 0 0 0 0 0 0 0 0 0 0 0 0
59928- 0 0 0 0 0 0 0 0 0 0 0 0
59929- 0 0 0 0 0 0 0 0 0 0 0 0
59930- 0 0 0 0 0 0 6 6 6 18 18 18
59931- 50 50 50 74 74 74 2 2 6 2 2 6
59932- 14 14 14 70 70 70 34 34 34 62 62 62
59933-250 250 250 253 253 253 253 253 253 253 253 253
59934-253 253 253 253 253 253 253 253 253 253 253 253
59935-253 253 253 253 253 253 231 231 231 246 246 246
59936-253 253 253 253 253 253 253 253 253 253 253 253
59937-253 253 253 253 253 253 253 253 253 253 253 253
59938-253 253 253 253 253 253 253 253 253 253 253 253
59939-253 253 253 253 253 253 253 253 253 253 253 253
59940-253 253 253 253 253 253 234 234 234 14 14 14
59941- 2 2 6 2 2 6 30 30 30 2 2 6
59942- 2 2 6 2 2 6 2 2 6 2 2 6
59943- 2 2 6 66 66 66 62 62 62 22 22 22
59944- 6 6 6 0 0 0 0 0 0 0 0 0
59945- 0 0 0 0 0 0 0 0 0 0 0 0
59946- 0 0 0 0 0 0 0 0 0 0 0 0
59947- 0 0 0 0 0 0 0 0 0 0 0 0
59948- 0 0 0 0 0 0 0 0 0 0 0 0
59949- 0 0 0 0 0 0 0 0 0 0 0 0
59950- 0 0 0 0 0 0 6 6 6 18 18 18
59951- 54 54 54 62 62 62 2 2 6 2 2 6
59952- 2 2 6 30 30 30 46 46 46 70 70 70
59953-250 250 250 253 253 253 253 253 253 253 253 253
59954-253 253 253 253 253 253 253 253 253 253 253 253
59955-253 253 253 253 253 253 231 231 231 246 246 246
59956-253 253 253 253 253 253 253 253 253 253 253 253
59957-253 253 253 253 253 253 253 253 253 253 253 253
59958-253 253 253 253 253 253 253 253 253 253 253 253
59959-253 253 253 253 253 253 253 253 253 253 253 253
59960-253 253 253 253 253 253 226 226 226 10 10 10
59961- 2 2 6 6 6 6 30 30 30 2 2 6
59962- 2 2 6 2 2 6 2 2 6 2 2 6
59963- 2 2 6 66 66 66 58 58 58 22 22 22
59964- 6 6 6 0 0 0 0 0 0 0 0 0
59965- 0 0 0 0 0 0 0 0 0 0 0 0
59966- 0 0 0 0 0 0 0 0 0 0 0 0
59967- 0 0 0 0 0 0 0 0 0 0 0 0
59968- 0 0 0 0 0 0 0 0 0 0 0 0
59969- 0 0 0 0 0 0 0 0 0 0 0 0
59970- 0 0 0 0 0 0 6 6 6 22 22 22
59971- 58 58 58 62 62 62 2 2 6 2 2 6
59972- 2 2 6 2 2 6 30 30 30 78 78 78
59973-250 250 250 253 253 253 253 253 253 253 253 253
59974-253 253 253 253 253 253 253 253 253 253 253 253
59975-253 253 253 253 253 253 231 231 231 246 246 246
59976-253 253 253 253 253 253 253 253 253 253 253 253
59977-253 253 253 253 253 253 253 253 253 253 253 253
59978-253 253 253 253 253 253 253 253 253 253 253 253
59979-253 253 253 253 253 253 253 253 253 253 253 253
59980-253 253 253 253 253 253 206 206 206 2 2 6
59981- 22 22 22 34 34 34 18 14 6 22 22 22
59982- 26 26 26 18 18 18 6 6 6 2 2 6
59983- 2 2 6 82 82 82 54 54 54 18 18 18
59984- 6 6 6 0 0 0 0 0 0 0 0 0
59985- 0 0 0 0 0 0 0 0 0 0 0 0
59986- 0 0 0 0 0 0 0 0 0 0 0 0
59987- 0 0 0 0 0 0 0 0 0 0 0 0
59988- 0 0 0 0 0 0 0 0 0 0 0 0
59989- 0 0 0 0 0 0 0 0 0 0 0 0
59990- 0 0 0 0 0 0 6 6 6 26 26 26
59991- 62 62 62 106 106 106 74 54 14 185 133 11
59992-210 162 10 121 92 8 6 6 6 62 62 62
59993-238 238 238 253 253 253 253 253 253 253 253 253
59994-253 253 253 253 253 253 253 253 253 253 253 253
59995-253 253 253 253 253 253 231 231 231 246 246 246
59996-253 253 253 253 253 253 253 253 253 253 253 253
59997-253 253 253 253 253 253 253 253 253 253 253 253
59998-253 253 253 253 253 253 253 253 253 253 253 253
59999-253 253 253 253 253 253 253 253 253 253 253 253
60000-253 253 253 253 253 253 158 158 158 18 18 18
60001- 14 14 14 2 2 6 2 2 6 2 2 6
60002- 6 6 6 18 18 18 66 66 66 38 38 38
60003- 6 6 6 94 94 94 50 50 50 18 18 18
60004- 6 6 6 0 0 0 0 0 0 0 0 0
60005- 0 0 0 0 0 0 0 0 0 0 0 0
60006- 0 0 0 0 0 0 0 0 0 0 0 0
60007- 0 0 0 0 0 0 0 0 0 0 0 0
60008- 0 0 0 0 0 0 0 0 0 0 0 0
60009- 0 0 0 0 0 0 0 0 0 6 6 6
60010- 10 10 10 10 10 10 18 18 18 38 38 38
60011- 78 78 78 142 134 106 216 158 10 242 186 14
60012-246 190 14 246 190 14 156 118 10 10 10 10
60013- 90 90 90 238 238 238 253 253 253 253 253 253
60014-253 253 253 253 253 253 253 253 253 253 253 253
60015-253 253 253 253 253 253 231 231 231 250 250 250
60016-253 253 253 253 253 253 253 253 253 253 253 253
60017-253 253 253 253 253 253 253 253 253 253 253 253
60018-253 253 253 253 253 253 253 253 253 253 253 253
60019-253 253 253 253 253 253 253 253 253 246 230 190
60020-238 204 91 238 204 91 181 142 44 37 26 9
60021- 2 2 6 2 2 6 2 2 6 2 2 6
60022- 2 2 6 2 2 6 38 38 38 46 46 46
60023- 26 26 26 106 106 106 54 54 54 18 18 18
60024- 6 6 6 0 0 0 0 0 0 0 0 0
60025- 0 0 0 0 0 0 0 0 0 0 0 0
60026- 0 0 0 0 0 0 0 0 0 0 0 0
60027- 0 0 0 0 0 0 0 0 0 0 0 0
60028- 0 0 0 0 0 0 0 0 0 0 0 0
60029- 0 0 0 6 6 6 14 14 14 22 22 22
60030- 30 30 30 38 38 38 50 50 50 70 70 70
60031-106 106 106 190 142 34 226 170 11 242 186 14
60032-246 190 14 246 190 14 246 190 14 154 114 10
60033- 6 6 6 74 74 74 226 226 226 253 253 253
60034-253 253 253 253 253 253 253 253 253 253 253 253
60035-253 253 253 253 253 253 231 231 231 250 250 250
60036-253 253 253 253 253 253 253 253 253 253 253 253
60037-253 253 253 253 253 253 253 253 253 253 253 253
60038-253 253 253 253 253 253 253 253 253 253 253 253
60039-253 253 253 253 253 253 253 253 253 228 184 62
60040-241 196 14 241 208 19 232 195 16 38 30 10
60041- 2 2 6 2 2 6 2 2 6 2 2 6
60042- 2 2 6 6 6 6 30 30 30 26 26 26
60043-203 166 17 154 142 90 66 66 66 26 26 26
60044- 6 6 6 0 0 0 0 0 0 0 0 0
60045- 0 0 0 0 0 0 0 0 0 0 0 0
60046- 0 0 0 0 0 0 0 0 0 0 0 0
60047- 0 0 0 0 0 0 0 0 0 0 0 0
60048- 0 0 0 0 0 0 0 0 0 0 0 0
60049- 6 6 6 18 18 18 38 38 38 58 58 58
60050- 78 78 78 86 86 86 101 101 101 123 123 123
60051-175 146 61 210 150 10 234 174 13 246 186 14
60052-246 190 14 246 190 14 246 190 14 238 190 10
60053-102 78 10 2 2 6 46 46 46 198 198 198
60054-253 253 253 253 253 253 253 253 253 253 253 253
60055-253 253 253 253 253 253 234 234 234 242 242 242
60056-253 253 253 253 253 253 253 253 253 253 253 253
60057-253 253 253 253 253 253 253 253 253 253 253 253
60058-253 253 253 253 253 253 253 253 253 253 253 253
60059-253 253 253 253 253 253 253 253 253 224 178 62
60060-242 186 14 241 196 14 210 166 10 22 18 6
60061- 2 2 6 2 2 6 2 2 6 2 2 6
60062- 2 2 6 2 2 6 6 6 6 121 92 8
60063-238 202 15 232 195 16 82 82 82 34 34 34
60064- 10 10 10 0 0 0 0 0 0 0 0 0
60065- 0 0 0 0 0 0 0 0 0 0 0 0
60066- 0 0 0 0 0 0 0 0 0 0 0 0
60067- 0 0 0 0 0 0 0 0 0 0 0 0
60068- 0 0 0 0 0 0 0 0 0 0 0 0
60069- 14 14 14 38 38 38 70 70 70 154 122 46
60070-190 142 34 200 144 11 197 138 11 197 138 11
60071-213 154 11 226 170 11 242 186 14 246 190 14
60072-246 190 14 246 190 14 246 190 14 246 190 14
60073-225 175 15 46 32 6 2 2 6 22 22 22
60074-158 158 158 250 250 250 253 253 253 253 253 253
60075-253 253 253 253 253 253 253 253 253 253 253 253
60076-253 253 253 253 253 253 253 253 253 253 253 253
60077-253 253 253 253 253 253 253 253 253 253 253 253
60078-253 253 253 253 253 253 253 253 253 253 253 253
60079-253 253 253 250 250 250 242 242 242 224 178 62
60080-239 182 13 236 186 11 213 154 11 46 32 6
60081- 2 2 6 2 2 6 2 2 6 2 2 6
60082- 2 2 6 2 2 6 61 42 6 225 175 15
60083-238 190 10 236 186 11 112 100 78 42 42 42
60084- 14 14 14 0 0 0 0 0 0 0 0 0
60085- 0 0 0 0 0 0 0 0 0 0 0 0
60086- 0 0 0 0 0 0 0 0 0 0 0 0
60087- 0 0 0 0 0 0 0 0 0 0 0 0
60088- 0 0 0 0 0 0 0 0 0 6 6 6
60089- 22 22 22 54 54 54 154 122 46 213 154 11
60090-226 170 11 230 174 11 226 170 11 226 170 11
60091-236 178 12 242 186 14 246 190 14 246 190 14
60092-246 190 14 246 190 14 246 190 14 246 190 14
60093-241 196 14 184 144 12 10 10 10 2 2 6
60094- 6 6 6 116 116 116 242 242 242 253 253 253
60095-253 253 253 253 253 253 253 253 253 253 253 253
60096-253 253 253 253 253 253 253 253 253 253 253 253
60097-253 253 253 253 253 253 253 253 253 253 253 253
60098-253 253 253 253 253 253 253 253 253 253 253 253
60099-253 253 253 231 231 231 198 198 198 214 170 54
60100-236 178 12 236 178 12 210 150 10 137 92 6
60101- 18 14 6 2 2 6 2 2 6 2 2 6
60102- 6 6 6 70 47 6 200 144 11 236 178 12
60103-239 182 13 239 182 13 124 112 88 58 58 58
60104- 22 22 22 6 6 6 0 0 0 0 0 0
60105- 0 0 0 0 0 0 0 0 0 0 0 0
60106- 0 0 0 0 0 0 0 0 0 0 0 0
60107- 0 0 0 0 0 0 0 0 0 0 0 0
60108- 0 0 0 0 0 0 0 0 0 10 10 10
60109- 30 30 30 70 70 70 180 133 36 226 170 11
60110-239 182 13 242 186 14 242 186 14 246 186 14
60111-246 190 14 246 190 14 246 190 14 246 190 14
60112-246 190 14 246 190 14 246 190 14 246 190 14
60113-246 190 14 232 195 16 98 70 6 2 2 6
60114- 2 2 6 2 2 6 66 66 66 221 221 221
60115-253 253 253 253 253 253 253 253 253 253 253 253
60116-253 253 253 253 253 253 253 253 253 253 253 253
60117-253 253 253 253 253 253 253 253 253 253 253 253
60118-253 253 253 253 253 253 253 253 253 253 253 253
60119-253 253 253 206 206 206 198 198 198 214 166 58
60120-230 174 11 230 174 11 216 158 10 192 133 9
60121-163 110 8 116 81 8 102 78 10 116 81 8
60122-167 114 7 197 138 11 226 170 11 239 182 13
60123-242 186 14 242 186 14 162 146 94 78 78 78
60124- 34 34 34 14 14 14 6 6 6 0 0 0
60125- 0 0 0 0 0 0 0 0 0 0 0 0
60126- 0 0 0 0 0 0 0 0 0 0 0 0
60127- 0 0 0 0 0 0 0 0 0 0 0 0
60128- 0 0 0 0 0 0 0 0 0 6 6 6
60129- 30 30 30 78 78 78 190 142 34 226 170 11
60130-239 182 13 246 190 14 246 190 14 246 190 14
60131-246 190 14 246 190 14 246 190 14 246 190 14
60132-246 190 14 246 190 14 246 190 14 246 190 14
60133-246 190 14 241 196 14 203 166 17 22 18 6
60134- 2 2 6 2 2 6 2 2 6 38 38 38
60135-218 218 218 253 253 253 253 253 253 253 253 253
60136-253 253 253 253 253 253 253 253 253 253 253 253
60137-253 253 253 253 253 253 253 253 253 253 253 253
60138-253 253 253 253 253 253 253 253 253 253 253 253
60139-250 250 250 206 206 206 198 198 198 202 162 69
60140-226 170 11 236 178 12 224 166 10 210 150 10
60141-200 144 11 197 138 11 192 133 9 197 138 11
60142-210 150 10 226 170 11 242 186 14 246 190 14
60143-246 190 14 246 186 14 225 175 15 124 112 88
60144- 62 62 62 30 30 30 14 14 14 6 6 6
60145- 0 0 0 0 0 0 0 0 0 0 0 0
60146- 0 0 0 0 0 0 0 0 0 0 0 0
60147- 0 0 0 0 0 0 0 0 0 0 0 0
60148- 0 0 0 0 0 0 0 0 0 10 10 10
60149- 30 30 30 78 78 78 174 135 50 224 166 10
60150-239 182 13 246 190 14 246 190 14 246 190 14
60151-246 190 14 246 190 14 246 190 14 246 190 14
60152-246 190 14 246 190 14 246 190 14 246 190 14
60153-246 190 14 246 190 14 241 196 14 139 102 15
60154- 2 2 6 2 2 6 2 2 6 2 2 6
60155- 78 78 78 250 250 250 253 253 253 253 253 253
60156-253 253 253 253 253 253 253 253 253 253 253 253
60157-253 253 253 253 253 253 253 253 253 253 253 253
60158-253 253 253 253 253 253 253 253 253 253 253 253
60159-250 250 250 214 214 214 198 198 198 190 150 46
60160-219 162 10 236 178 12 234 174 13 224 166 10
60161-216 158 10 213 154 11 213 154 11 216 158 10
60162-226 170 11 239 182 13 246 190 14 246 190 14
60163-246 190 14 246 190 14 242 186 14 206 162 42
60164-101 101 101 58 58 58 30 30 30 14 14 14
60165- 6 6 6 0 0 0 0 0 0 0 0 0
60166- 0 0 0 0 0 0 0 0 0 0 0 0
60167- 0 0 0 0 0 0 0 0 0 0 0 0
60168- 0 0 0 0 0 0 0 0 0 10 10 10
60169- 30 30 30 74 74 74 174 135 50 216 158 10
60170-236 178 12 246 190 14 246 190 14 246 190 14
60171-246 190 14 246 190 14 246 190 14 246 190 14
60172-246 190 14 246 190 14 246 190 14 246 190 14
60173-246 190 14 246 190 14 241 196 14 226 184 13
60174- 61 42 6 2 2 6 2 2 6 2 2 6
60175- 22 22 22 238 238 238 253 253 253 253 253 253
60176-253 253 253 253 253 253 253 253 253 253 253 253
60177-253 253 253 253 253 253 253 253 253 253 253 253
60178-253 253 253 253 253 253 253 253 253 253 253 253
60179-253 253 253 226 226 226 187 187 187 180 133 36
60180-216 158 10 236 178 12 239 182 13 236 178 12
60181-230 174 11 226 170 11 226 170 11 230 174 11
60182-236 178 12 242 186 14 246 190 14 246 190 14
60183-246 190 14 246 190 14 246 186 14 239 182 13
60184-206 162 42 106 106 106 66 66 66 34 34 34
60185- 14 14 14 6 6 6 0 0 0 0 0 0
60186- 0 0 0 0 0 0 0 0 0 0 0 0
60187- 0 0 0 0 0 0 0 0 0 0 0 0
60188- 0 0 0 0 0 0 0 0 0 6 6 6
60189- 26 26 26 70 70 70 163 133 67 213 154 11
60190-236 178 12 246 190 14 246 190 14 246 190 14
60191-246 190 14 246 190 14 246 190 14 246 190 14
60192-246 190 14 246 190 14 246 190 14 246 190 14
60193-246 190 14 246 190 14 246 190 14 241 196 14
60194-190 146 13 18 14 6 2 2 6 2 2 6
60195- 46 46 46 246 246 246 253 253 253 253 253 253
60196-253 253 253 253 253 253 253 253 253 253 253 253
60197-253 253 253 253 253 253 253 253 253 253 253 253
60198-253 253 253 253 253 253 253 253 253 253 253 253
60199-253 253 253 221 221 221 86 86 86 156 107 11
60200-216 158 10 236 178 12 242 186 14 246 186 14
60201-242 186 14 239 182 13 239 182 13 242 186 14
60202-242 186 14 246 186 14 246 190 14 246 190 14
60203-246 190 14 246 190 14 246 190 14 246 190 14
60204-242 186 14 225 175 15 142 122 72 66 66 66
60205- 30 30 30 10 10 10 0 0 0 0 0 0
60206- 0 0 0 0 0 0 0 0 0 0 0 0
60207- 0 0 0 0 0 0 0 0 0 0 0 0
60208- 0 0 0 0 0 0 0 0 0 6 6 6
60209- 26 26 26 70 70 70 163 133 67 210 150 10
60210-236 178 12 246 190 14 246 190 14 246 190 14
60211-246 190 14 246 190 14 246 190 14 246 190 14
60212-246 190 14 246 190 14 246 190 14 246 190 14
60213-246 190 14 246 190 14 246 190 14 246 190 14
60214-232 195 16 121 92 8 34 34 34 106 106 106
60215-221 221 221 253 253 253 253 253 253 253 253 253
60216-253 253 253 253 253 253 253 253 253 253 253 253
60217-253 253 253 253 253 253 253 253 253 253 253 253
60218-253 253 253 253 253 253 253 253 253 253 253 253
60219-242 242 242 82 82 82 18 14 6 163 110 8
60220-216 158 10 236 178 12 242 186 14 246 190 14
60221-246 190 14 246 190 14 246 190 14 246 190 14
60222-246 190 14 246 190 14 246 190 14 246 190 14
60223-246 190 14 246 190 14 246 190 14 246 190 14
60224-246 190 14 246 190 14 242 186 14 163 133 67
60225- 46 46 46 18 18 18 6 6 6 0 0 0
60226- 0 0 0 0 0 0 0 0 0 0 0 0
60227- 0 0 0 0 0 0 0 0 0 0 0 0
60228- 0 0 0 0 0 0 0 0 0 10 10 10
60229- 30 30 30 78 78 78 163 133 67 210 150 10
60230-236 178 12 246 186 14 246 190 14 246 190 14
60231-246 190 14 246 190 14 246 190 14 246 190 14
60232-246 190 14 246 190 14 246 190 14 246 190 14
60233-246 190 14 246 190 14 246 190 14 246 190 14
60234-241 196 14 215 174 15 190 178 144 253 253 253
60235-253 253 253 253 253 253 253 253 253 253 253 253
60236-253 253 253 253 253 253 253 253 253 253 253 253
60237-253 253 253 253 253 253 253 253 253 253 253 253
60238-253 253 253 253 253 253 253 253 253 218 218 218
60239- 58 58 58 2 2 6 22 18 6 167 114 7
60240-216 158 10 236 178 12 246 186 14 246 190 14
60241-246 190 14 246 190 14 246 190 14 246 190 14
60242-246 190 14 246 190 14 246 190 14 246 190 14
60243-246 190 14 246 190 14 246 190 14 246 190 14
60244-246 190 14 246 186 14 242 186 14 190 150 46
60245- 54 54 54 22 22 22 6 6 6 0 0 0
60246- 0 0 0 0 0 0 0 0 0 0 0 0
60247- 0 0 0 0 0 0 0 0 0 0 0 0
60248- 0 0 0 0 0 0 0 0 0 14 14 14
60249- 38 38 38 86 86 86 180 133 36 213 154 11
60250-236 178 12 246 186 14 246 190 14 246 190 14
60251-246 190 14 246 190 14 246 190 14 246 190 14
60252-246 190 14 246 190 14 246 190 14 246 190 14
60253-246 190 14 246 190 14 246 190 14 246 190 14
60254-246 190 14 232 195 16 190 146 13 214 214 214
60255-253 253 253 253 253 253 253 253 253 253 253 253
60256-253 253 253 253 253 253 253 253 253 253 253 253
60257-253 253 253 253 253 253 253 253 253 253 253 253
60258-253 253 253 250 250 250 170 170 170 26 26 26
60259- 2 2 6 2 2 6 37 26 9 163 110 8
60260-219 162 10 239 182 13 246 186 14 246 190 14
60261-246 190 14 246 190 14 246 190 14 246 190 14
60262-246 190 14 246 190 14 246 190 14 246 190 14
60263-246 190 14 246 190 14 246 190 14 246 190 14
60264-246 186 14 236 178 12 224 166 10 142 122 72
60265- 46 46 46 18 18 18 6 6 6 0 0 0
60266- 0 0 0 0 0 0 0 0 0 0 0 0
60267- 0 0 0 0 0 0 0 0 0 0 0 0
60268- 0 0 0 0 0 0 6 6 6 18 18 18
60269- 50 50 50 109 106 95 192 133 9 224 166 10
60270-242 186 14 246 190 14 246 190 14 246 190 14
60271-246 190 14 246 190 14 246 190 14 246 190 14
60272-246 190 14 246 190 14 246 190 14 246 190 14
60273-246 190 14 246 190 14 246 190 14 246 190 14
60274-242 186 14 226 184 13 210 162 10 142 110 46
60275-226 226 226 253 253 253 253 253 253 253 253 253
60276-253 253 253 253 253 253 253 253 253 253 253 253
60277-253 253 253 253 253 253 253 253 253 253 253 253
60278-198 198 198 66 66 66 2 2 6 2 2 6
60279- 2 2 6 2 2 6 50 34 6 156 107 11
60280-219 162 10 239 182 13 246 186 14 246 190 14
60281-246 190 14 246 190 14 246 190 14 246 190 14
60282-246 190 14 246 190 14 246 190 14 246 190 14
60283-246 190 14 246 190 14 246 190 14 242 186 14
60284-234 174 13 213 154 11 154 122 46 66 66 66
60285- 30 30 30 10 10 10 0 0 0 0 0 0
60286- 0 0 0 0 0 0 0 0 0 0 0 0
60287- 0 0 0 0 0 0 0 0 0 0 0 0
60288- 0 0 0 0 0 0 6 6 6 22 22 22
60289- 58 58 58 154 121 60 206 145 10 234 174 13
60290-242 186 14 246 186 14 246 190 14 246 190 14
60291-246 190 14 246 190 14 246 190 14 246 190 14
60292-246 190 14 246 190 14 246 190 14 246 190 14
60293-246 190 14 246 190 14 246 190 14 246 190 14
60294-246 186 14 236 178 12 210 162 10 163 110 8
60295- 61 42 6 138 138 138 218 218 218 250 250 250
60296-253 253 253 253 253 253 253 253 253 250 250 250
60297-242 242 242 210 210 210 144 144 144 66 66 66
60298- 6 6 6 2 2 6 2 2 6 2 2 6
60299- 2 2 6 2 2 6 61 42 6 163 110 8
60300-216 158 10 236 178 12 246 190 14 246 190 14
60301-246 190 14 246 190 14 246 190 14 246 190 14
60302-246 190 14 246 190 14 246 190 14 246 190 14
60303-246 190 14 239 182 13 230 174 11 216 158 10
60304-190 142 34 124 112 88 70 70 70 38 38 38
60305- 18 18 18 6 6 6 0 0 0 0 0 0
60306- 0 0 0 0 0 0 0 0 0 0 0 0
60307- 0 0 0 0 0 0 0 0 0 0 0 0
60308- 0 0 0 0 0 0 6 6 6 22 22 22
60309- 62 62 62 168 124 44 206 145 10 224 166 10
60310-236 178 12 239 182 13 242 186 14 242 186 14
60311-246 186 14 246 190 14 246 190 14 246 190 14
60312-246 190 14 246 190 14 246 190 14 246 190 14
60313-246 190 14 246 190 14 246 190 14 246 190 14
60314-246 190 14 236 178 12 216 158 10 175 118 6
60315- 80 54 7 2 2 6 6 6 6 30 30 30
60316- 54 54 54 62 62 62 50 50 50 38 38 38
60317- 14 14 14 2 2 6 2 2 6 2 2 6
60318- 2 2 6 2 2 6 2 2 6 2 2 6
60319- 2 2 6 6 6 6 80 54 7 167 114 7
60320-213 154 11 236 178 12 246 190 14 246 190 14
60321-246 190 14 246 190 14 246 190 14 246 190 14
60322-246 190 14 242 186 14 239 182 13 239 182 13
60323-230 174 11 210 150 10 174 135 50 124 112 88
60324- 82 82 82 54 54 54 34 34 34 18 18 18
60325- 6 6 6 0 0 0 0 0 0 0 0 0
60326- 0 0 0 0 0 0 0 0 0 0 0 0
60327- 0 0 0 0 0 0 0 0 0 0 0 0
60328- 0 0 0 0 0 0 6 6 6 18 18 18
60329- 50 50 50 158 118 36 192 133 9 200 144 11
60330-216 158 10 219 162 10 224 166 10 226 170 11
60331-230 174 11 236 178 12 239 182 13 239 182 13
60332-242 186 14 246 186 14 246 190 14 246 190 14
60333-246 190 14 246 190 14 246 190 14 246 190 14
60334-246 186 14 230 174 11 210 150 10 163 110 8
60335-104 69 6 10 10 10 2 2 6 2 2 6
60336- 2 2 6 2 2 6 2 2 6 2 2 6
60337- 2 2 6 2 2 6 2 2 6 2 2 6
60338- 2 2 6 2 2 6 2 2 6 2 2 6
60339- 2 2 6 6 6 6 91 60 6 167 114 7
60340-206 145 10 230 174 11 242 186 14 246 190 14
60341-246 190 14 246 190 14 246 186 14 242 186 14
60342-239 182 13 230 174 11 224 166 10 213 154 11
60343-180 133 36 124 112 88 86 86 86 58 58 58
60344- 38 38 38 22 22 22 10 10 10 6 6 6
60345- 0 0 0 0 0 0 0 0 0 0 0 0
60346- 0 0 0 0 0 0 0 0 0 0 0 0
60347- 0 0 0 0 0 0 0 0 0 0 0 0
60348- 0 0 0 0 0 0 0 0 0 14 14 14
60349- 34 34 34 70 70 70 138 110 50 158 118 36
60350-167 114 7 180 123 7 192 133 9 197 138 11
60351-200 144 11 206 145 10 213 154 11 219 162 10
60352-224 166 10 230 174 11 239 182 13 242 186 14
60353-246 186 14 246 186 14 246 186 14 246 186 14
60354-239 182 13 216 158 10 185 133 11 152 99 6
60355-104 69 6 18 14 6 2 2 6 2 2 6
60356- 2 2 6 2 2 6 2 2 6 2 2 6
60357- 2 2 6 2 2 6 2 2 6 2 2 6
60358- 2 2 6 2 2 6 2 2 6 2 2 6
60359- 2 2 6 6 6 6 80 54 7 152 99 6
60360-192 133 9 219 162 10 236 178 12 239 182 13
60361-246 186 14 242 186 14 239 182 13 236 178 12
60362-224 166 10 206 145 10 192 133 9 154 121 60
60363- 94 94 94 62 62 62 42 42 42 22 22 22
60364- 14 14 14 6 6 6 0 0 0 0 0 0
60365- 0 0 0 0 0 0 0 0 0 0 0 0
60366- 0 0 0 0 0 0 0 0 0 0 0 0
60367- 0 0 0 0 0 0 0 0 0 0 0 0
60368- 0 0 0 0 0 0 0 0 0 6 6 6
60369- 18 18 18 34 34 34 58 58 58 78 78 78
60370-101 98 89 124 112 88 142 110 46 156 107 11
60371-163 110 8 167 114 7 175 118 6 180 123 7
60372-185 133 11 197 138 11 210 150 10 219 162 10
60373-226 170 11 236 178 12 236 178 12 234 174 13
60374-219 162 10 197 138 11 163 110 8 130 83 6
60375- 91 60 6 10 10 10 2 2 6 2 2 6
60376- 18 18 18 38 38 38 38 38 38 38 38 38
60377- 38 38 38 38 38 38 38 38 38 38 38 38
60378- 38 38 38 38 38 38 26 26 26 2 2 6
60379- 2 2 6 6 6 6 70 47 6 137 92 6
60380-175 118 6 200 144 11 219 162 10 230 174 11
60381-234 174 13 230 174 11 219 162 10 210 150 10
60382-192 133 9 163 110 8 124 112 88 82 82 82
60383- 50 50 50 30 30 30 14 14 14 6 6 6
60384- 0 0 0 0 0 0 0 0 0 0 0 0
60385- 0 0 0 0 0 0 0 0 0 0 0 0
60386- 0 0 0 0 0 0 0 0 0 0 0 0
60387- 0 0 0 0 0 0 0 0 0 0 0 0
60388- 0 0 0 0 0 0 0 0 0 0 0 0
60389- 6 6 6 14 14 14 22 22 22 34 34 34
60390- 42 42 42 58 58 58 74 74 74 86 86 86
60391-101 98 89 122 102 70 130 98 46 121 87 25
60392-137 92 6 152 99 6 163 110 8 180 123 7
60393-185 133 11 197 138 11 206 145 10 200 144 11
60394-180 123 7 156 107 11 130 83 6 104 69 6
60395- 50 34 6 54 54 54 110 110 110 101 98 89
60396- 86 86 86 82 82 82 78 78 78 78 78 78
60397- 78 78 78 78 78 78 78 78 78 78 78 78
60398- 78 78 78 82 82 82 86 86 86 94 94 94
60399-106 106 106 101 101 101 86 66 34 124 80 6
60400-156 107 11 180 123 7 192 133 9 200 144 11
60401-206 145 10 200 144 11 192 133 9 175 118 6
60402-139 102 15 109 106 95 70 70 70 42 42 42
60403- 22 22 22 10 10 10 0 0 0 0 0 0
60404- 0 0 0 0 0 0 0 0 0 0 0 0
60405- 0 0 0 0 0 0 0 0 0 0 0 0
60406- 0 0 0 0 0 0 0 0 0 0 0 0
60407- 0 0 0 0 0 0 0 0 0 0 0 0
60408- 0 0 0 0 0 0 0 0 0 0 0 0
60409- 0 0 0 0 0 0 6 6 6 10 10 10
60410- 14 14 14 22 22 22 30 30 30 38 38 38
60411- 50 50 50 62 62 62 74 74 74 90 90 90
60412-101 98 89 112 100 78 121 87 25 124 80 6
60413-137 92 6 152 99 6 152 99 6 152 99 6
60414-138 86 6 124 80 6 98 70 6 86 66 30
60415-101 98 89 82 82 82 58 58 58 46 46 46
60416- 38 38 38 34 34 34 34 34 34 34 34 34
60417- 34 34 34 34 34 34 34 34 34 34 34 34
60418- 34 34 34 34 34 34 38 38 38 42 42 42
60419- 54 54 54 82 82 82 94 86 76 91 60 6
60420-134 86 6 156 107 11 167 114 7 175 118 6
60421-175 118 6 167 114 7 152 99 6 121 87 25
60422-101 98 89 62 62 62 34 34 34 18 18 18
60423- 6 6 6 0 0 0 0 0 0 0 0 0
60424- 0 0 0 0 0 0 0 0 0 0 0 0
60425- 0 0 0 0 0 0 0 0 0 0 0 0
60426- 0 0 0 0 0 0 0 0 0 0 0 0
60427- 0 0 0 0 0 0 0 0 0 0 0 0
60428- 0 0 0 0 0 0 0 0 0 0 0 0
60429- 0 0 0 0 0 0 0 0 0 0 0 0
60430- 0 0 0 6 6 6 6 6 6 10 10 10
60431- 18 18 18 22 22 22 30 30 30 42 42 42
60432- 50 50 50 66 66 66 86 86 86 101 98 89
60433-106 86 58 98 70 6 104 69 6 104 69 6
60434-104 69 6 91 60 6 82 62 34 90 90 90
60435- 62 62 62 38 38 38 22 22 22 14 14 14
60436- 10 10 10 10 10 10 10 10 10 10 10 10
60437- 10 10 10 10 10 10 6 6 6 10 10 10
60438- 10 10 10 10 10 10 10 10 10 14 14 14
60439- 22 22 22 42 42 42 70 70 70 89 81 66
60440- 80 54 7 104 69 6 124 80 6 137 92 6
60441-134 86 6 116 81 8 100 82 52 86 86 86
60442- 58 58 58 30 30 30 14 14 14 6 6 6
60443- 0 0 0 0 0 0 0 0 0 0 0 0
60444- 0 0 0 0 0 0 0 0 0 0 0 0
60445- 0 0 0 0 0 0 0 0 0 0 0 0
60446- 0 0 0 0 0 0 0 0 0 0 0 0
60447- 0 0 0 0 0 0 0 0 0 0 0 0
60448- 0 0 0 0 0 0 0 0 0 0 0 0
60449- 0 0 0 0 0 0 0 0 0 0 0 0
60450- 0 0 0 0 0 0 0 0 0 0 0 0
60451- 0 0 0 6 6 6 10 10 10 14 14 14
60452- 18 18 18 26 26 26 38 38 38 54 54 54
60453- 70 70 70 86 86 86 94 86 76 89 81 66
60454- 89 81 66 86 86 86 74 74 74 50 50 50
60455- 30 30 30 14 14 14 6 6 6 0 0 0
60456- 0 0 0 0 0 0 0 0 0 0 0 0
60457- 0 0 0 0 0 0 0 0 0 0 0 0
60458- 0 0 0 0 0 0 0 0 0 0 0 0
60459- 6 6 6 18 18 18 34 34 34 58 58 58
60460- 82 82 82 89 81 66 89 81 66 89 81 66
60461- 94 86 66 94 86 76 74 74 74 50 50 50
60462- 26 26 26 14 14 14 6 6 6 0 0 0
60463- 0 0 0 0 0 0 0 0 0 0 0 0
60464- 0 0 0 0 0 0 0 0 0 0 0 0
60465- 0 0 0 0 0 0 0 0 0 0 0 0
60466- 0 0 0 0 0 0 0 0 0 0 0 0
60467- 0 0 0 0 0 0 0 0 0 0 0 0
60468- 0 0 0 0 0 0 0 0 0 0 0 0
60469- 0 0 0 0 0 0 0 0 0 0 0 0
60470- 0 0 0 0 0 0 0 0 0 0 0 0
60471- 0 0 0 0 0 0 0 0 0 0 0 0
60472- 6 6 6 6 6 6 14 14 14 18 18 18
60473- 30 30 30 38 38 38 46 46 46 54 54 54
60474- 50 50 50 42 42 42 30 30 30 18 18 18
60475- 10 10 10 0 0 0 0 0 0 0 0 0
60476- 0 0 0 0 0 0 0 0 0 0 0 0
60477- 0 0 0 0 0 0 0 0 0 0 0 0
60478- 0 0 0 0 0 0 0 0 0 0 0 0
60479- 0 0 0 6 6 6 14 14 14 26 26 26
60480- 38 38 38 50 50 50 58 58 58 58 58 58
60481- 54 54 54 42 42 42 30 30 30 18 18 18
60482- 10 10 10 0 0 0 0 0 0 0 0 0
60483- 0 0 0 0 0 0 0 0 0 0 0 0
60484- 0 0 0 0 0 0 0 0 0 0 0 0
60485- 0 0 0 0 0 0 0 0 0 0 0 0
60486- 0 0 0 0 0 0 0 0 0 0 0 0
60487- 0 0 0 0 0 0 0 0 0 0 0 0
60488- 0 0 0 0 0 0 0 0 0 0 0 0
60489- 0 0 0 0 0 0 0 0 0 0 0 0
60490- 0 0 0 0 0 0 0 0 0 0 0 0
60491- 0 0 0 0 0 0 0 0 0 0 0 0
60492- 0 0 0 0 0 0 0 0 0 6 6 6
60493- 6 6 6 10 10 10 14 14 14 18 18 18
60494- 18 18 18 14 14 14 10 10 10 6 6 6
60495- 0 0 0 0 0 0 0 0 0 0 0 0
60496- 0 0 0 0 0 0 0 0 0 0 0 0
60497- 0 0 0 0 0 0 0 0 0 0 0 0
60498- 0 0 0 0 0 0 0 0 0 0 0 0
60499- 0 0 0 0 0 0 0 0 0 6 6 6
60500- 14 14 14 18 18 18 22 22 22 22 22 22
60501- 18 18 18 14 14 14 10 10 10 6 6 6
60502- 0 0 0 0 0 0 0 0 0 0 0 0
60503- 0 0 0 0 0 0 0 0 0 0 0 0
60504- 0 0 0 0 0 0 0 0 0 0 0 0
60505- 0 0 0 0 0 0 0 0 0 0 0 0
60506- 0 0 0 0 0 0 0 0 0 0 0 0
60507+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60508+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60509+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60510+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60511+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60512+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60513+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60514+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60515+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60516+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60517+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60518+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60519+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60520+4 4 4 4 4 4
60521+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60522+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60523+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60524+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60525+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60526+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60527+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60528+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60529+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60530+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60531+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60532+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60533+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60534+4 4 4 4 4 4
60535+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60536+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60537+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60538+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60539+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60540+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60541+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60542+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60543+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60544+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60545+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60546+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60547+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60548+4 4 4 4 4 4
60549+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60550+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60551+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60552+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60553+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60554+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60555+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60556+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60557+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60558+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60559+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60560+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60561+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60562+4 4 4 4 4 4
60563+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60564+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60565+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60566+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60567+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60568+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60569+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60570+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60571+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60572+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60573+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60574+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60575+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60576+4 4 4 4 4 4
60577+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60578+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60579+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60580+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60581+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60582+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60583+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60584+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60585+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60586+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60587+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60588+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60589+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60590+4 4 4 4 4 4
60591+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60592+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60593+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60594+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60595+4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
60596+0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
60597+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60598+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60599+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60600+4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
60601+0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
60602+4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
60603+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60604+4 4 4 4 4 4
60605+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60606+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60607+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60608+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60609+4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
60610+37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
60611+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60612+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60613+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60614+4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
60615+2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
60616+4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
60617+1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60618+4 4 4 4 4 4
60619+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60620+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60621+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60622+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60623+2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
60624+153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
60625+0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
60626+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60627+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60628+4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
60629+60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
60630+4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
60631+2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
60632+4 4 4 4 4 4
60633+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60634+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60635+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60636+4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
60637+4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
60638+165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
60639+1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
60640+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60641+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
60642+3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
60643+163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
60644+0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
60645+37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
60646+4 4 4 4 4 4
60647+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60648+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60649+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60650+4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
60651+37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
60652+156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
60653+125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
60654+5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
60655+4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
60656+0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
60657+174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
60658+0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
60659+64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
60660+4 4 4 4 4 4
60661+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60662+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60663+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
60664+5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
60665+156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
60666+156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
60667+174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
60668+1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
60669+4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
60670+13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
60671+174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
60672+22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
60673+90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
60674+4 4 4 4 4 4
60675+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60676+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60677+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
60678+0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
60679+174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
60680+156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
60681+163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
60682+4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
60683+5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
60684+131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
60685+190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
60686+90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
60687+31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
60688+4 4 4 4 4 4
60689+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60690+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60691+4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
60692+4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
60693+155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
60694+167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
60695+153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
60696+41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
60697+1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
60698+177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
60699+125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
60700+136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
60701+7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
60702+4 4 4 4 4 4
60703+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60704+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60705+4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
60706+125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
60707+156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
60708+137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
60709+156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
60710+167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
60711+0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
60712+166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
60713+6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
60714+90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
60715+1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
60716+4 4 4 4 4 4
60717+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60718+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60719+1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
60720+167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
60721+157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
60722+26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
60723+158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
60724+165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
60725+60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
60726+137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
60727+52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
60728+13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
60729+4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
60730+4 4 4 4 4 4
60731+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60732+4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
60733+0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
60734+158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
60735+167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
60736+4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
60737+174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
60738+155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
60739+137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
60740+16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
60741+136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
60742+2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
60743+4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
60744+4 4 4 4 4 4
60745+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60746+4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
60747+37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
60748+157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
60749+153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
60750+4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
60751+125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
60752+156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
60753+174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
60754+4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
60755+136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
60756+1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
60757+2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
60758+0 0 0 4 4 4
60759+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
60760+4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
60761+158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
60762+153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
60763+37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
60764+4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
60765+4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
60766+154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
60767+174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
60768+32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
60769+28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
60770+50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
60771+0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
60772+2 0 0 0 0 0
60773+4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
60774+0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
60775+174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
60776+165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
60777+4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
60778+4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
60779+4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
60780+174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
60781+60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
60782+136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
60783+22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
60784+136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
60785+26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
60786+37 38 37 0 0 0
60787+4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
60788+13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
60789+153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
60790+177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
60791+4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
60792+5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
60793+6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
60794+166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
60795+4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
60796+146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
60797+71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
60798+90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
60799+125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
60800+85 115 134 4 0 0
60801+4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
60802+125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
60803+155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
60804+125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
60805+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
60806+0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
60807+5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
60808+37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
60809+4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
60810+90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
60811+2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
60812+13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
60813+166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
60814+60 73 81 4 0 0
60815+4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
60816+174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
60817+156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
60818+4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
60819+4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
60820+10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
60821+4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
60822+4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
60823+80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
60824+28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
60825+50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
60826+1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
60827+167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
60828+16 19 21 4 0 0
60829+4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
60830+158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
60831+167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
60832+4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
60833+4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
60834+80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
60835+4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
60836+3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
60837+146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
60838+68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
60839+136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
60840+24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
60841+163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
60842+4 0 0 4 3 3
60843+3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
60844+156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
60845+155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
60846+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
60847+2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
60848+136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
60849+0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
60850+0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
60851+136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
60852+28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
60853+22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
60854+137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
60855+60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
60856+3 2 2 4 4 4
60857+3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
60858+157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
60859+37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
60860+4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
60861+0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
60862+101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
60863+14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
60864+22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
60865+136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
60866+17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
60867+2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
60868+166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
60869+13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
60870+4 4 4 4 4 4
60871+1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
60872+163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
60873+4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
60874+4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
60875+40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
60876+101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
60877+101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
60878+136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
60879+136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
60880+136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
60881+3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
60882+174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
60883+4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
60884+4 4 4 4 4 4
60885+4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
60886+155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
60887+4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
60888+4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
60889+101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
60890+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
60891+136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
60892+136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
60893+136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
60894+90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
60895+85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
60896+167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
60897+6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
60898+5 5 5 5 5 5
60899+1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
60900+131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
60901+6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
60902+0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
60903+101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
60904+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
60905+101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
60906+136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
60907+101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
60908+7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
60909+174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
60910+24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
60911+4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
60912+5 5 5 4 4 4
60913+4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
60914+131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
60915+6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
60916+13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
60917+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
60918+101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
60919+101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
60920+136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
60921+136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
60922+2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
60923+174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
60924+4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
60925+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60926+4 4 4 4 4 4
60927+1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
60928+137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
60929+4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
60930+64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
60931+90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
60932+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
60933+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
60934+136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
60935+101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
60936+37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
60937+167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
60938+3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
60939+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60940+4 4 4 4 4 4
60941+4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
60942+153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
60943+4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
60944+90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
60945+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
60946+90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
60947+101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
60948+101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
60949+35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
60950+154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
60951+60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
60952+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60953+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60954+4 4 4 4 4 4
60955+1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
60956+153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
60957+4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
60958+64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
60959+64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
60960+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
60961+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
60962+136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
60963+13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
60964+174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
60965+6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
60966+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60967+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60968+4 4 4 4 4 4
60969+4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
60970+156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
60971+4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
60972+90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
60973+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
60974+90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
60975+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
60976+101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
60977+2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
60978+174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
60979+4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
60980+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60981+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60982+4 4 4 4 4 4
60983+3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
60984+158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
60985+4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
60986+37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
60987+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
60988+90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
60989+101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
60990+90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
60991+5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
60992+167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
60993+6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
60994+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60995+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60996+4 4 4 4 4 4
60997+4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
60998+163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
60999+4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
61000+18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
61001+64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
61002+90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
61003+101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
61004+13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
61005+3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
61006+174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
61007+4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
61008+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61009+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61010+4 4 4 4 4 4
61011+1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
61012+167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
61013+4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
61014+18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
61015+26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
61016+90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
61017+101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
61018+7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
61019+4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
61020+174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
61021+4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61022+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61023+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61024+4 4 4 4 4 4
61025+4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
61026+174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
61027+5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
61028+18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
61029+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61030+90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
61031+101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
61032+2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
61033+3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
61034+153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
61035+4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61036+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61037+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61038+4 4 4 4 4 4
61039+1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
61040+174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
61041+5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
61042+18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
61043+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61044+26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
61045+35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
61046+2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
61047+3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
61048+131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
61049+4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61050+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61051+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61052+4 4 4 4 4 4
61053+3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
61054+174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
61055+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
61056+18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
61057+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61058+26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
61059+7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
61060+4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
61061+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
61062+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61063+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61064+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61065+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61066+4 4 4 4 4 4
61067+1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
61068+174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
61069+5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
61070+18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
61071+18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
61072+26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
61073+28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
61074+3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
61075+4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61076+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61077+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61078+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61079+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61080+4 4 4 4 4 4
61081+4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
61082+174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
61083+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
61084+10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
61085+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61086+18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
61087+90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
61088+3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
61089+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
61090+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61091+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61092+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61093+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61094+4 4 4 4 4 4
61095+1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
61096+177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
61097+5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
61098+10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
61099+26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
61100+6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
61101+10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
61102+2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
61103+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61104+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61105+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61106+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61107+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61108+4 4 4 4 4 4
61109+4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
61110+177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
61111+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
61112+10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
61113+26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
61114+7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
61115+3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
61116+21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
61117+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
61118+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61119+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61120+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61121+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61122+4 4 4 4 4 4
61123+3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
61124+190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
61125+5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
61126+10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
61127+24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
61128+18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
61129+28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
61130+26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
61131+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61132+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61133+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61134+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61135+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61136+4 4 4 4 4 4
61137+4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
61138+190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
61139+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
61140+10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
61141+0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
61142+26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
61143+37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
61144+90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
61145+4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
61146+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61147+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61148+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61149+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61150+4 4 4 4 4 4
61151+4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
61152+193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
61153+5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
61154+10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
61155+1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
61156+26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
61157+22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
61158+26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
61159+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61160+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61161+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61162+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61163+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61164+4 4 4 4 4 4
61165+4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
61166+190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
61167+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
61168+10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
61169+2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
61170+26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
61171+10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
61172+26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
61173+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
61174+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61175+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61176+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61177+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61178+4 4 4 4 4 4
61179+4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
61180+193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
61181+5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
61182+10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
61183+13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
61184+10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
61185+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61186+26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
61187+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61188+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61189+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61190+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61191+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61192+4 4 4 4 4 4
61193+4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
61194+190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
61195+5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
61196+28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
61197+10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
61198+28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
61199+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61200+26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
61201+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
61202+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61203+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61204+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61205+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61206+4 4 4 4 4 4
61207+4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
61208+193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
61209+5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
61210+4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
61211+10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
61212+10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
61213+18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
61214+22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
61215+4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
61216+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61217+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61218+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61219+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61220+4 4 4 4 4 4
61221+4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
61222+190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
61223+6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
61224+1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
61225+18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
61226+10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
61227+26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
61228+1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
61229+5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
61230+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61231+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61232+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61233+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61234+4 4 4 4 4 4
61235+4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
61236+193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
61237+2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
61238+4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
61239+10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
61240+10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
61241+26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
61242+2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
61243+3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
61244+131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61245+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61246+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61247+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61248+4 4 4 4 4 4
61249+4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
61250+193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
61251+0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
61252+4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
61253+13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
61254+10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
61255+28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
61256+4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
61257+0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
61258+125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61259+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61260+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61261+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61262+4 4 4 4 4 4
61263+4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
61264+193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
61265+120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
61266+4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
61267+4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
61268+10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
61269+4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
61270+4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
61271+24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
61272+125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
61273+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61274+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61275+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61276+4 4 4 4 4 4
61277+4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
61278+174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
61279+220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
61280+3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
61281+4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
61282+10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
61283+1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
61284+5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
61285+137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
61286+125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
61287+0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61288+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61289+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61290+4 4 4 4 4 4
61291+5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
61292+193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
61293+220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
61294+4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
61295+4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
61296+22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
61297+4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61298+1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
61299+166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
61300+125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
61301+4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
61302+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61303+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61304+4 4 4 4 4 4
61305+4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
61306+220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
61307+205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
61308+24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
61309+4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
61310+4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
61311+4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
61312+2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
61313+156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
61314+137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
61315+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61316+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61317+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61318+4 4 4 4 4 4
61319+5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
61320+125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
61321+205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
61322+193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
61323+5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
61324+1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
61325+5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
61326+60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
61327+153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
61328+125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
61329+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61330+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61331+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61332+4 4 4 4 4 4
61333+4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
61334+6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
61335+193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
61336+244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
61337+0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
61338+4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
61339+3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
61340+220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
61341+153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
61342+13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
61343+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61344+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61345+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61346+4 4 4 4 4 4
61347+5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
61348+6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
61349+244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
61350+220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
61351+3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
61352+4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
61353+0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
61354+177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
61355+158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
61356+4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
61357+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61358+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61359+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61360+4 4 4 4 4 4
61361+5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
61362+6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
61363+177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
61364+220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
61365+125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
61366+4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
61367+37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
61368+174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
61369+158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
61370+4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
61371+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61372+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61373+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61374+4 4 4 4 4 4
61375+4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
61376+4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
61377+26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
61378+205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
61379+244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
61380+0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
61381+177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
61382+174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
61383+60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
61384+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61385+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61386+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61387+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61388+4 4 4 4 4 4
61389+5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
61390+6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
61391+6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
61392+220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
61393+220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
61394+0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
61395+220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
61396+174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
61397+4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
61398+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61399+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61400+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61401+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61402+4 4 4 4 4 4
61403+4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
61404+6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
61405+4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
61406+220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
61407+205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
61408+60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
61409+177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
61410+190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
61411+4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61412+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61413+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61414+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61415+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61416+4 4 4 4 4 4
61417+4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
61418+4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
61419+6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
61420+125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
61421+205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
61422+193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
61423+190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
61424+153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
61425+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61426+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61427+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61428+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61429+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61430+4 4 4 4 4 4
61431+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
61432+6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
61433+4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
61434+4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
61435+205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
61436+220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
61437+174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
61438+6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
61439+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61440+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61441+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61442+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61443+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61444+4 4 4 4 4 4
61445+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
61446+5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
61447+6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
61448+4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
61449+220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
61450+190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
61451+193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
61452+4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
61453+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61454+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61455+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61456+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61457+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61458+4 4 4 4 4 4
61459+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61460+4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
61461+4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
61462+6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
61463+174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
61464+193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
61465+193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
61466+6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
61467+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61468+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61469+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61470+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61471+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61472+4 4 4 4 4 4
61473+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61474+4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
61475+5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
61476+5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
61477+6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
61478+193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
61479+60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
61480+5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
61481+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61482+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61483+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61484+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61485+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61486+4 4 4 4 4 4
61487+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61488+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61489+4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
61490+5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
61491+4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
61492+193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
61493+6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
61494+4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
61495+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61496+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61497+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61498+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61499+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61500+4 4 4 4 4 4
61501+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61502+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61503+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
61504+4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
61505+6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
61506+153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
61507+6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
61508+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61509+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61510+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61511+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61512+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61513+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61514+4 4 4 4 4 4
61515+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61516+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61517+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61518+4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
61519+6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
61520+24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
61521+6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
61522+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61523+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61524+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61525+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61526+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61527+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61528+4 4 4 4 4 4
61529+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61530+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61531+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61532+4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
61533+4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
61534+6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
61535+4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
61536+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61537+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61538+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61539+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61540+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61541+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61542+4 4 4 4 4 4
61543+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61544+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61545+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61546+4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
61547+5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
61548+6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
61549+6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
61550+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61551+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61552+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61553+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61554+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61555+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61556+4 4 4 4 4 4
61557+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61558+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61559+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61560+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
61561+4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
61562+4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
61563+6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61564+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61565+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61566+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61567+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61568+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61569+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61570+4 4 4 4 4 4
61571+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61572+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61573+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61574+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61575+4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
61576+6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
61577+4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
61578+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61579+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61580+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61581+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61582+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61583+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61584+4 4 4 4 4 4
61585+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61586+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61587+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61588+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61589+4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
61590+4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
61591+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61592+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61593+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61594+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61595+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61596+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61597+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61598+4 4 4 4 4 4
61599+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61600+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61601+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61602+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61603+4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
61604+5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
61605+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61606+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61607+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61608+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61609+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61610+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61611+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61612+4 4 4 4 4 4
61613+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61614+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61615+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61616+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61617+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
61618+5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
61619+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61620+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61621+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61622+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61623+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61624+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61625+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61626+4 4 4 4 4 4
61627diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
61628index 96093ae..b9eed29 100644
61629--- a/drivers/xen/events/events_base.c
61630+++ b/drivers/xen/events/events_base.c
61631@@ -1568,7 +1568,7 @@ void xen_irq_resume(void)
61632 restore_pirqs();
61633 }
61634
61635-static struct irq_chip xen_dynamic_chip __read_mostly = {
61636+static struct irq_chip xen_dynamic_chip = {
61637 .name = "xen-dyn",
61638
61639 .irq_disable = disable_dynirq,
61640@@ -1582,7 +1582,7 @@ static struct irq_chip xen_dynamic_chip __read_mostly = {
61641 .irq_retrigger = retrigger_dynirq,
61642 };
61643
61644-static struct irq_chip xen_pirq_chip __read_mostly = {
61645+static struct irq_chip xen_pirq_chip = {
61646 .name = "xen-pirq",
61647
61648 .irq_startup = startup_pirq,
61649@@ -1602,7 +1602,7 @@ static struct irq_chip xen_pirq_chip __read_mostly = {
61650 .irq_retrigger = retrigger_dynirq,
61651 };
61652
61653-static struct irq_chip xen_percpu_chip __read_mostly = {
61654+static struct irq_chip xen_percpu_chip = {
61655 .name = "xen-percpu",
61656
61657 .irq_disable = disable_dynirq,
61658diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
61659index 00f40f0..e3c0b15 100644
61660--- a/drivers/xen/evtchn.c
61661+++ b/drivers/xen/evtchn.c
61662@@ -201,8 +201,8 @@ static ssize_t evtchn_read(struct file *file, char __user *buf,
61663
61664 /* Byte lengths of two chunks. Chunk split (if any) is at ring wrap. */
61665 if (((c ^ p) & EVTCHN_RING_SIZE) != 0) {
61666- bytes1 = (EVTCHN_RING_SIZE - EVTCHN_RING_MASK(c)) *
61667- sizeof(evtchn_port_t);
61668+ bytes1 = EVTCHN_RING_SIZE - EVTCHN_RING_MASK(c);
61669+ bytes1 *= sizeof(evtchn_port_t);
61670 bytes2 = EVTCHN_RING_MASK(p) * sizeof(evtchn_port_t);
61671 } else {
61672 bytes1 = (p - c) * sizeof(evtchn_port_t);
61673diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
61674index fef20db..d28b1ab 100644
61675--- a/drivers/xen/xenfs/xenstored.c
61676+++ b/drivers/xen/xenfs/xenstored.c
61677@@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
61678 static int xsd_kva_open(struct inode *inode, struct file *file)
61679 {
61680 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
61681+#ifdef CONFIG_GRKERNSEC_HIDESYM
61682+ NULL);
61683+#else
61684 xen_store_interface);
61685+#endif
61686+
61687 if (!file->private_data)
61688 return -ENOMEM;
61689 return 0;
61690diff --git a/firmware/Makefile b/firmware/Makefile
61691index e297e1b..aeb0982 100644
61692--- a/firmware/Makefile
61693+++ b/firmware/Makefile
61694@@ -35,9 +35,11 @@ fw-shipped-$(CONFIG_BNX2X) += bnx2x/bnx2x-e1-6.2.9.0.fw \
61695 bnx2x/bnx2x-e1h-6.2.9.0.fw \
61696 bnx2x/bnx2x-e2-6.2.9.0.fw
61697 fw-shipped-$(CONFIG_BNX2) += bnx2/bnx2-mips-09-6.2.1a.fw \
61698+ bnx2/bnx2-mips-09-6.2.1b.fw \
61699 bnx2/bnx2-rv2p-09-6.0.17.fw \
61700 bnx2/bnx2-rv2p-09ax-6.0.17.fw \
61701 bnx2/bnx2-mips-06-6.2.1.fw \
61702+ bnx2/bnx2-mips-06-6.2.3.fw \
61703 bnx2/bnx2-rv2p-06-6.0.15.fw
61704 fw-shipped-$(CONFIG_CASSINI) += sun/cassini.bin
61705 fw-shipped-$(CONFIG_CHELSIO_T3) += cxgb3/t3b_psram-1.1.0.bin \
61706diff --git a/firmware/WHENCE b/firmware/WHENCE
61707index 0c4d96d..b17700f 100644
61708--- a/firmware/WHENCE
61709+++ b/firmware/WHENCE
61710@@ -653,21 +653,23 @@ Found in hex form in kernel source.
61711 Driver: BNX2 - Broadcom NetXtremeII
61712
61713 File: bnx2/bnx2-mips-06-6.2.1.fw
61714+File: bnx2/bnx2-mips-06-6.2.3.fw
61715 File: bnx2/bnx2-rv2p-06-6.0.15.fw
61716 File: bnx2/bnx2-mips-09-6.2.1a.fw
61717+File: bnx2/bnx2-mips-09-6.2.1b.fw
61718 File: bnx2/bnx2-rv2p-09-6.0.17.fw
61719 File: bnx2/bnx2-rv2p-09ax-6.0.17.fw
61720
61721 Licence:
61722-
61723- This file contains firmware data derived from proprietary unpublished
61724- source code, Copyright (c) 2004 - 2010 Broadcom Corporation.
61725-
61726- Permission is hereby granted for the distribution of this firmware data
61727- in hexadecimal or equivalent format, provided this copyright notice is
61728- accompanying it.
61729-
61730-Found in hex form in kernel source.
61731+
61732+ This file contains firmware data derived from proprietary unpublished
61733+ source code, Copyright (c) 2004 - 2010 Broadcom Corporation.
61734+
61735+ Permission is hereby granted for the distribution of this firmware data
61736+ in hexadecimal or equivalent format, provided this copyright notice is
61737+ accompanying it.
61738+
61739+Found in hex form in kernel source.
61740
61741 --------------------------------------------------------------------------
61742
61743diff --git a/firmware/bnx2/bnx2-mips-06-6.2.3.fw.ihex b/firmware/bnx2/bnx2-mips-06-6.2.3.fw.ihex
61744new file mode 100644
61745index 0000000..da72bf1
61746--- /dev/null
61747+++ b/firmware/bnx2/bnx2-mips-06-6.2.3.fw.ihex
61748@@ -0,0 +1,5804 @@
61749+:10000000080001180800000000004A68000000C84D
61750+:1000100000000000000000000000000008004A6826
61751+:100020000000001400004B30080000A00800000091
61752+:100030000000569400004B44080058200000008443
61753+:100040000000A1D808005694000001580000A25CEE
61754+:100050000800321008000000000072F00000A3B495
61755+:10006000000000000000000000000000080072F026
61756+:1000700000000024000116A40800049008000400F9
61757+:10008000000017D4000116C80000000000000000A6
61758+:100090000000000000000000000000000000000060
61759+:1000A000080000A80800000000003BFC00012E9C96
61760+:1000B0000000000000000000000000000000000040
61761+:1000C00000000000000000000A00004600000000E0
61762+:1000D000000000000000000D636F6D362E322E33DD
61763+:1000E0000000000006020302000000000000000300
61764+:1000F000000000C800000032000000030000000003
61765+:1001000000000000000000000000000000000000EF
61766+:1001100000000010000001360000EA600000000549
61767+:1001200000000000000000000000000000000008C7
61768+:1001300000000000000000000000000000000000BF
61769+:1001400000000000000000000000000000000000AF
61770+:10015000000000000000000000000000000000009F
61771+:10016000000000020000000000000000000000008D
61772+:10017000000000000000000000000000000000007F
61773+:10018000000000000000000000000010000000005F
61774+:10019000000000000000000000000000000000005F
61775+:1001A000000000000000000000000000000000004F
61776+:1001B000000000000000000000000000000000003F
61777+:1001C000000000000000000000000000000000002F
61778+:1001D000000000000000000000000000000000001F
61779+:1001E0000000000010000003000000000000000DEF
61780+:1001F0000000000D3C02080024424AA03C03080015
61781+:1002000024634B9CAC4000000043202B1480FFFD76
61782+:10021000244200043C1D080037BD7FFC03A0F021F0
61783+:100220003C100800261001183C1C0800279C4AA01E
61784+:100230000E000168000000000000000D27470100CB
61785+:1002400090E3000B2402001A94E5000814620028D1
61786+:10025000000020218CE200003C0308008C63004475
61787+:1002600094E60014000211C20002104030A4000203
61788+:10027000005A10212463000130A50004A446008028
61789+:100280003C010800AC23004410A000190004202BFE
61790+:100290008F4202B804410008240400013C02080017
61791+:1002A0008C420060244200013C010800AC22006046
61792+:1002B00003E00008008010218CE2002094E3001687
61793+:1002C00000002021AF4202808CE20004A743028498
61794+:1002D000AF4202883C021000AF4202B83C02080064
61795+:1002E0008C42005C244200013C010800AC22005C0E
61796+:1002F00003E00008008010212747010090E3000B75
61797+:100300002402000394E50008146200280000202164
61798+:100310008CE200003C0308008C63004494E6001467
61799+:10032000000211C20002104030A40002005A102145
61800+:100330002463000130A50004A44600803C010800AD
61801+:10034000AC23004410A000190004202B8F4202B8F7
61802+:1003500004410008240400013C0208008C420060B3
61803+:10036000244200013C010800AC22006003E00008C8
61804+:10037000008010218CE2002094E300160000202170
61805+:10038000AF4202808CE20004A7430284AF4202889D
61806+:100390003C021000AF4202B83C0208008C42005CF4
61807+:1003A000244200013C010800AC22005C03E000088C
61808+:1003B000008010218F4301002402010050620003DD
61809+:1003C000000311C20000000D000311C20002104022
61810+:1003D000005A1021A440008003E000080000102112
61811+:1003E0009362000003E00008AF80000003E0000813
61812+:1003F0000000102103E00008000010212402010089
61813+:1004000014820008000000003C0208008C4200FC3E
61814+:10041000244200013C010800AC2200FC0A0000DD7F
61815+:1004200030A200203C0208008C42008424420001DB
61816+:100430003C010800AC22008430A2002010400008DB
61817+:1004400030A300103C0208008C4201082442000145
61818+:100450003C010800AC22010803E000080000000095
61819+:1004600010600008000000003C0208008C420104FB
61820+:10047000244200013C010800AC22010403E0000812
61821+:10048000000000003C0208008C42010024420001F0
61822+:100490003C010800AC22010003E00008000000005D
61823+:1004A00027BDFFE8AFBF0010274401009483000878
61824+:1004B000306200041040001B306600028F4202B818
61825+:1004C00004410008240500013C0208008C42006041
61826+:1004D000244200013C010800AC2200600A0001290E
61827+:1004E0008FBF00108C82002094830016000028210A
61828+:1004F000AF4202808C820004A7430284AF4202888C
61829+:100500003C021000AF4202B83C0208008C42005C82
61830+:10051000244200013C010800AC22005C0A000129D1
61831+:100520008FBF001010C00006006028218F4401001A
61832+:100530000E0000CD000000000A0001282405000183
61833+:100540008F8200088F4301045043000700002821D8
61834+:100550008F4401000E0000CD000000008F42010416
61835+:10056000AF820008000028218FBF001000A01021DA
61836+:1005700003E0000827BD001827BDFFE8AFBF001447
61837+:10058000AFB00010974201083043700024022000F1
61838+:100590001062000B286220011440002F000010217F
61839+:1005A00024024000106200250000000024026000C8
61840+:1005B00010620026000010210A0001658FBF0014A0
61841+:1005C00027500100920200091040001A2403000184
61842+:1005D0003C0208008C420020104000160000182148
61843+:1005E0000E00049300000000960300083C0608007B
61844+:1005F00094C64B5E8E0400188F8200209605000C76
61845+:1006000000031C0000661825AC440000AC45000443
61846+:1006100024040001AC400008AC40000CAC400010C9
61847+:10062000AC400014AC4000180E0004B8AC43001CF1
61848+:10063000000018210A000164006010210E0003254B
61849+:10064000000000000A000164000010210E000EE905
61850+:1006500000000000000010218FBF00148FB00010B8
61851+:1006600003E0000827BD001827BDFFE0AFB2001867
61852+:100670003C036010AFBF001CAFB10014AFB000105E
61853+:100680008C6450002402FF7F3C1A800000822024EA
61854+:100690003484380C24020037AC6450003C1208004B
61855+:1006A00026524AD8AF42000824020C80AF420024F0
61856+:1006B0003C1B80083C06080024C60324024010218D
61857+:1006C0002404001D2484FFFFAC4600000481FFFDCC
61858+:1006D000244200043C020800244204B03C0108000B
61859+:1006E000AC224AE03C020800244202303C010800EF
61860+:1006F000AC224AE43C020800244201743C03080096
61861+:100700002463032C3C040800248403D83C0508001F
61862+:1007100024A538F03C010800AC224B403C02080004
61863+:10072000244202EC3C010800AC264B243C010800AA
61864+:10073000AC254B343C010800AC234B3C3C01080089
61865+:10074000AC244B443C010800AC224B483C0108005F
61866+:10075000AC234ADC3C010800AC204AE83C0108001C
61867+:10076000AC204AEC3C010800AC204AF03C010800F7
61868+:10077000AC204AF43C010800AC204AF83C010800D7
61869+:10078000AC204AFC3C010800AC204B003C010800B6
61870+:10079000AC244B043C010800AC204B083C01080091
61871+:1007A000AC204B0C3C010800AC204B103C01080075
61872+:1007B000AC204B143C010800AC204B183C01080055
61873+:1007C000AC264B1C3C010800AC264B203C01080029
61874+:1007D000AC254B303C010800AC234B380E000623FF
61875+:1007E000000000003C028000344200708C42000097
61876+:1007F000AF8200143C0308008C6300208F82000449
61877+:10080000104300043C0280000E00045BAF83000430
61878+:100810003C028000344600703C0308008C6300A05A
61879+:100820003C0208008C4200A4104300048F84001492
61880+:100830003C010800AC2300A4A743009E8CCA000022
61881+:100840003C0308008C6300BC3C0208008C4200B8EA
61882+:100850000144202300641821000040210064202B63
61883+:1008600000481021004410213C010800AC2300BCCA
61884+:100870003C010800AC2200B88F5100003222000772
61885+:100880001040FFDCAF8A00148CC600003C05080055
61886+:100890008CA500BC3C0408008C8400B800CA30233E
61887+:1008A00000A628210000102100A6302B0082202164
61888+:1008B00000862021322700013C010800AC2500BC45
61889+:1008C0003C010800AC2400B810E0001F32220002F6
61890+:1008D0008F420100AF4200208F420104AF4200A8C6
61891+:1008E0009342010B0E0000C6305000FF2E02001E86
61892+:1008F00054400004001010800E0000C90A000213CA
61893+:1009000000000000005210218C4200000040F80955
61894+:1009100000000000104000053C0240008F4301042D
61895+:100920003C026020AC4300143C024000AF4201385E
61896+:100930003C0208008C420034244200013C010800C3
61897+:10094000AC220034322200021040000E3222000499
61898+:100950008F4201400E0000C6AF4200200E000295FB
61899+:10096000000000003C024000AF4201783C02080059
61900+:100970008C420038244200013C010800AC220038BF
61901+:10098000322200041040FF983C0280008F42018018
61902+:100990000E0000C6AF4200208F43018024020F00EA
61903+:1009A00014620005000000008F420188A742009CED
61904+:1009B0000A0002483C0240009362000024030050F9
61905+:1009C000304200FF144300083C0240000E00027B4E
61906+:1009D00000000000544000043C0240000E000D7571
61907+:1009E000000000003C024000AF4201B83C02080099
61908+:1009F0008C42003C244200013C010800AC22003C37
61909+:100A00000A0001C83C0280003C0290003442000110
61910+:100A100000822025AF4400208F4200200440FFFECA
61911+:100A20000000000003E00008000000003C0280001D
61912+:100A3000344200010082202503E00008AF4400207A
61913+:100A400027BDFFE0AFB10014AFB0001000808821D7
61914+:100A5000AFBF00180E00025030B000FF9362007D5F
61915+:100A60000220202102028025A370007D8F70007477
61916+:100A70003C0280000E000259020280241600000988
61917+:100A80008FBF00188F4201F80440FFFE24020002CD
61918+:100A9000AF5101C0A34201C43C021000AF4201F8B3
61919+:100AA0008FBF00188FB100148FB0001003E0000852
61920+:100AB00027BD002027BDFFE8AFBF0010974201848B
61921+:100AC0008F440188304202001040000500002821B8
61922+:100AD0000E000FAA000000000A00028D240500018C
61923+:100AE0003C02FF0004800005008218243C02040040
61924+:100AF000506200019362003E240500018FBF001088
61925+:100B000000A0102103E0000827BD0018A360002208
61926+:100B10008F4401400A00025E2405000127BDFFE862
61927+:100B2000AFBF0014AFB0001093620000304400FF6C
61928+:100B300038830020388200300003182B0002102B6D
61929+:100B40000062182410600003240200501482008008
61930+:100B50008FBF001493620005304200011040007CFA
61931+:100B60008FBF0014934201482443FFFF2C6200050D
61932+:100B7000104000788FB00010000310803C03080084
61933+:100B800024634A68004310218C42000000400008A2
61934+:100B9000000000000E0002508F4401408F70000CD6
61935+:100BA0008F4201441602000224020001AF62000CD1
61936+:100BB0000E0002598F4401408F420144145000043A
61937+:100BC0008FBF00148FB000100A000F2027BD00183F
61938+:100BD0008F62000C0A0003040000000097620010FE
61939+:100BE0008F4301443042FFFF1462001A00000000EE
61940+:100BF00024020001A76200108F4202380443001053
61941+:100C00008F4201403C02003F3446F0003C0560004A
61942+:100C10003C04FFC08CA22BBC0044182400461024C6
61943+:100C20000002130200031D82106200390000000060
61944+:100C30008F4202380440FFF7000000008F4201405D
61945+:100C4000AF4202003C021000AF4202380A00032209
61946+:100C50008FBF0014976200100A0003040000000018
61947+:100C60000E0002508F440140976200128F430144EE
61948+:100C70003050FFFF1603000224020001A762001299
61949+:100C80000E0002598F4401408F42014416020004B5
61950+:100C90008FBF00148FB000100A00029127BD00180A
61951+:100CA000976200120A00030400000000976200141B
61952+:100CB0008F4301443042FFFF14620006240200010A
61953+:100CC0008FBF00148FB00010A76200140A00124AF0
61954+:100CD00027BD0018976200141440001D8FBF001438
61955+:100CE0000A00031C00000000976200168F430144B5
61956+:100CF0003042FFFF1462000B240200018FBF00147A
61957+:100D00008FB00010A76200160A000B1227BD001852
61958+:100D10009742007824420004A76200100A000322D0
61959+:100D20008FBF001497620016240300013042FFFFBA
61960+:100D3000144300078FBF00143C0208008C4200706F
61961+:100D4000244200013C010800AC2200708FBF001457
61962+:100D50008FB0001003E0000827BD001827BDFFE892
61963+:100D6000AFBF0014AFB000108F50010093620000BD
61964+:100D700093430109304400FF2402001F106200A5C4
61965+:100D80002862002010400018240200382862000A5F
61966+:100D90001040000C2402000B286200081040002CB8
61967+:100DA00000000000046000E52862000214400028F2
61968+:100DB00024020006106200268FBF00140A00041FE0
61969+:100DC0008FB000101062005E2862000B144000DC3F
61970+:100DD0008FBF00142402000E106200738FB0001049
61971+:100DE0000A00041F00000000106200C028620039E1
61972+:100DF0001040000A2402008024020036106200CA5B
61973+:100E000028620037104000B424020035106200C18F
61974+:100E10008FBF00140A00041F8FB000101062002B57
61975+:100E20002862008110400006240200C82402003914
61976+:100E3000106200B48FBF00140A00041F8FB00010AE
61977+:100E4000106200998FBF00140A00041F8FB00010B9
61978+:100E50003C0208008C420020104000B98FBF0014F3
61979+:100E60000E000493000000008F4201008F830020D9
61980+:100E70009745010C97460108AC6200008F420104BF
61981+:100E80003C04080094844B5E00052C00AC62000416
61982+:100E90008F4201180006340000C43025AC620008FF
61983+:100EA0008F42011C24040001AC62000C9342010A31
61984+:100EB00000A22825AC650010AC600014AC600018DE
61985+:100EC000AC66001C0A0003F58FBF00143C0208004A
61986+:100ED0008C4200201040009A8FBF00140E00049333
61987+:100EE00000000000974401083C03080094634B5E37
61988+:100EF0009745010C000422029746010E8F820020C4
61989+:100F0000000426000083202500052C003C030080FF
61990+:100F100000A6282500832025AC400000AC4000043A
61991+:100F2000AC400008AC40000CAC450010AC400014D4
61992+:100F3000AC400018AC44001C0A0003F42404000177
61993+:100F40009742010C14400015000000009362000558
61994+:100F50003042001014400011000000000E0002504A
61995+:100F6000020020219362000502002021344200107B
61996+:100F70000E000259A36200059362000024030020C2
61997+:100F8000304200FF1043006D020020218FBF00148B
61998+:100F90008FB000100A000FC027BD00180000000D20
61999+:100FA0000A00041E8FBF00143C0208008C4200207F
62000+:100FB000104000638FBF00140E0004930000000077
62001+:100FC0008F4201048F8300209744010C3C050800E8
62002+:100FD00094A54B5EAC6200009762002C00042400D4
62003+:100FE0003042FFFF008220253C02400E00A228254F
62004+:100FF000AC640004AC600008AC60000CAC60001095
62005+:10100000AC600014AC600018AC65001C0A0003F46E
62006+:10101000240400010E00025002002021A7600008F5
62007+:101020000E00025902002021020020210E00025E63
62008+:10103000240500013C0208008C42002010400040C2
62009+:101040008FBF00140E000493000000009742010CB3
62010+:101050008F8300203C05080094A54B5E000214001D
62011+:10106000AC700000AC620004AC6000088F64004CFF
62012+:101070003C02401F00A22825AC64000C8F62005087
62013+:1010800024040001AC6200108F620054AC620014B2
62014+:10109000AC600018AC65001C8FBF00148FB000104E
62015+:1010A0000A0004B827BD0018240200205082002541
62016+:1010B0008FB000100E000F0A020020211040002007
62017+:1010C0008FBF0014020020218FB0001000002821E3
62018+:1010D0000A00025E27BD0018020020218FBF001405
62019+:1010E0008FB000100A00058027BD00189745010C3D
62020+:1010F000020020218FBF00148FB000100A0005A04D
62021+:1011000027BD0018020020218FB000100A0005C57D
62022+:1011100027BD00189345010D020020218FB000105B
62023+:101120000A00060F27BD0018020020218FBF0014FF
62024+:101130008FB000100A0005EB27BD00188FBF001408
62025+:101140008FB0001003E0000827BD00188F4202781E
62026+:101150000440FFFE2402000234840080AF440240B9
62027+:10116000A34202443C02100003E00008AF420278B0
62028+:101170003C04080094844B6A3C0208008C424B7487
62029+:101180003083FFFF000318C000431021AF42003C32
62030+:101190003C0208008C424B70AF4200383C020050C9
62031+:1011A00034420008AF4200300000000000000000A0
62032+:1011B000000000008F420000304200201040FFFD80
62033+:1011C000000000008F4204003C010800AC224B608C
62034+:1011D0008F4204043C010800AC224B643C02002016
62035+:1011E000AF420030000000003C02080094424B680F
62036+:1011F0003C03080094634B6C3C05080094A54B6EBF
62037+:1012000024840001004310213083FFFF3C010800CB
62038+:10121000A4224B683C010800A4244B6A1465000317
62039+:10122000000000003C010800A4204B6A03E0000815
62040+:10123000000000003C05000A27BDFFE80345282107
62041+:101240003C04080024844B50AFBF00100E00051D65
62042+:101250002406000A3C02080094424B523C0308005A
62043+:1012600094634B6E3042000F244200030043180485
62044+:1012700024027FFF0043102B10400002AF83001CAC
62045+:101280000000000D0E00042A000000003C020800CF
62046+:1012900094424B5A8FBF001027BD001803E000088E
62047+:1012A000A74200A23C02000A034210219443000618
62048+:1012B0003C02080094424B5A3C010800A4234B56C0
62049+:1012C000004310238F83001C00021400000214034B
62050+:1012D0000043102B03E000083842000127BDFFE85F
62051+:1012E000AFBF00103C02000A0342102194420006E6
62052+:1012F0003C010800A4224B560E00047700000000B9
62053+:101300005440FFF93C02000A8FBF001003E00008C0
62054+:1013100027BD001827BDFFE8AFBF00100E000477FF
62055+:101320000000000010400003000000000E000485D3
62056+:10133000000000003C0208008C424B608FBF001090
62057+:1013400027430400AF4200383C0208008C424B6443
62058+:1013500027BD0018AF830020AF42003C3C020005CF
62059+:10136000AF42003003E00008AF8000188F82001801
62060+:101370003C0300060002114000431025AF4200303C
62061+:101380000000000000000000000000008F4200008C
62062+:10139000304200101040FFFD27420400AF820020C1
62063+:1013A00003E00008AF8000183C0608008CC64B64C0
62064+:1013B0008F8500188F8300203C02080094424B5A0E
62065+:1013C00027BDFFE024A50001246300202442000182
62066+:1013D00024C70020AFB10014AFB00010AFBF001899
62067+:1013E000AF850018AF8300203C010800A4224B5AAF
62068+:1013F000309000FF3C010800AC274B6404C100089A
62069+:101400000000882104E00006000000003C02080003
62070+:101410008C424B60244200013C010800AC224B602E
62071+:101420003C02080094424B5A3C03080094634B680A
62072+:101430000010202B004310262C42000100441025F0
62073+:10144000144000048F830018240200101462000F5F
62074+:10145000000000000E0004A9241100013C03080054
62075+:1014600094634B5A3C02080094424B681462000398
62076+:10147000000000000E00042A000000001600000317
62077+:10148000000000000E000493000000003C03080070
62078+:1014900094634B5E3C02080094424B5C2463000161
62079+:1014A0003064FFFF3C010800A4234B5E148200035C
62080+:1014B000000000003C010800A4204B5E1200000662
62081+:1014C000000000003C02080094424B5AA74200A2D0
62082+:1014D0000A00050B022010210E0004770000000016
62083+:1014E00010400004022010210E00048500000000BE
62084+:1014F000022010218FBF00188FB100148FB0001090
62085+:1015000003E0000827BD00203084FFFF30A5FFFF67
62086+:101510000000182110800007000000003082000148
62087+:101520001040000200042042006518210A00051343
62088+:101530000005284003E000080060102110C00006EC
62089+:1015400024C6FFFF8CA2000024A50004AC8200008A
62090+:101550000A00051D2484000403E0000800000000C8
62091+:1015600010A0000824A3FFFFAC86000000000000CC
62092+:10157000000000002402FFFF2463FFFF1462FFFA53
62093+:101580002484000403E0000800000000240200019D
62094+:10159000AF62000CA7620010A7620012A7620014DD
62095+:1015A00003E00008A76200163082007F034210218A
62096+:1015B0003C08000E004818213C0208008C42002024
62097+:1015C00027BDFFD82407FF80AFB3001CAFB20018BF
62098+:1015D000AFB10014AFB00010AFBF00200080802179
62099+:1015E00030B100FF0087202430D200FF1040002FD0
62100+:1015F00000009821AF44002C9062000024030050AA
62101+:10160000304200FF1443000E000000003C020800BE
62102+:101610008C4200E00202102100471024AF42002C4F
62103+:101620003C0208008C4200E0020210213042007FA0
62104+:101630000342102100481021944200D43053FFFF90
62105+:101640000E000493000000003C02080094424B5E30
62106+:101650008F8300200011340000C2302500122C00BE
62107+:101660003C02400000C2302534A50001AC700000EF
62108+:101670008FBF0020AC6000048FB20018AC7300086C
62109+:101680008FB10014AC60000C8FB3001CAC6500106F
62110+:101690008FB00010AC60001424040001AC6000188E
62111+:1016A00027BD00280A0004B8AC66001C8FBF0020CC
62112+:1016B0008FB3001C8FB200188FB100148FB00010D0
62113+:1016C00003E0000827BD00289343010F2402001007
62114+:1016D0001062000E2865001110A0000724020012FD
62115+:1016E000240200082405003A1062000600003021A0
62116+:1016F00003E0000800000000240500351462FFFC30
62117+:10170000000030210A000538000000008F420074FC
62118+:1017100024420FA003E00008AF62000C27BDFFE8E1
62119+:10172000AFBF00100E00025E240500018FBF001045
62120+:1017300024020001A762001227BD00182402000144
62121+:1017400003E00008A360002227BDFFE0AFB1001452
62122+:10175000AFB00010AFBF001830B1FFFF0E00025055
62123+:10176000008080219362003F24030004304200FF88
62124+:101770001443000C02002021122000082402000A59
62125+:101780000E00053100000000936200052403FFFEF7
62126+:1017900000431024A362000524020012A362003F4C
62127+:1017A000020020210E000259A360008116200003D0
62128+:1017B000020020210E0005950000000002002021FB
62129+:1017C000322600FF8FBF00188FB100148FB00010B9
62130+:1017D000240500380A00053827BD002027BDFFE09A
62131+:1017E000AFBF001CAFB20018AFB10014AFB0001013
62132+:1017F0000E000250008080210E0005310000000024
62133+:101800009362003F24120018305100FF123200038F
62134+:101810000200202124020012A362003F936200050F
62135+:101820002403FFFE004310240E000259A3620005AA
62136+:10183000020020212405002016320007000030217C
62137+:101840008FBF001C8FB200188FB100148FB0001032
62138+:101850000A00025E27BD00208FBF001C8FB2001857
62139+:101860008FB100148FB00010240500390A0005382C
62140+:1018700027BD002027BDFFE8AFB00010AFBF0014A8
62141+:101880009742010C2405003600808021144000108E
62142+:10189000304600FF0E00025000000000240200123B
62143+:1018A000A362003F93620005344200100E00053130
62144+:1018B000A36200050E00025902002021020020212F
62145+:1018C0000E00025E240500200A000604000000004D
62146+:1018D0000E000538000000000E000250020020211A
62147+:1018E000936200232403FF9F020020210043102461
62148+:1018F0008FBF00148FB00010A36200230A000259AA
62149+:1019000027BD001827BDFFE0AFBF0018AFB100141E
62150+:10191000AFB0001030B100FF0E00025000808021F7
62151+:10192000240200120E000531A362003F0E0002598E
62152+:101930000200202102002021022030218FBF001848
62153+:101940008FB100148FB00010240500350A0005384F
62154+:1019500027BD0020A380002C03E00008A380002DF9
62155+:101960008F4202780440FFFE8F820034AF42024073
62156+:1019700024020002A34202443C02100003E00008DB
62157+:10198000AF4202783C0360008C6254003042000891
62158+:101990001440FFFD000000008C625408AF82000C70
62159+:1019A00024020052AC605408AC645430AC6254342D
62160+:1019B0002402000803E00008AC6254003C0260000E
62161+:1019C0008C42540030420008104000053C03600087
62162+:1019D0008C625400304200081440FFFD00000000FB
62163+:1019E0008F83000C3C02600003E00008AC43540805
62164+:1019F00090A3000024020005008040213063003FD6
62165+:101A000000004821146200050000502190A2001C33
62166+:101A100094A3001E304900FF306AFFFFAD00000CA8
62167+:101A2000AD000010AD000024950200148D05001CCF
62168+:101A30008D0400183042FFFF0049102300021100FE
62169+:101A4000000237C3004038210086202300A2102B5B
62170+:101A50000082202300A72823AD05001CAD04001838
62171+:101A6000A5090014A5090020A50A001603E0000836
62172+:101A7000A50A00228F4201F80440FFFE2402000262
62173+:101A8000AF4401C0A34201C43C02100003E00008BF
62174+:101A9000AF4201F83C0208008C4200B427BDFFE8C9
62175+:101AA000AFBF001424420001AFB000103C01080099
62176+:101AB000AC2200B48F4300243C02001F30AA00FF78
62177+:101AC0003442FF8030D800FF006280240080F8217B
62178+:101AD00030EF00FF1158003B01405821240CFF80DB
62179+:101AE0003C19000A3163007F000310C00003194055
62180+:101AF000006218213C0208008C4200DC25680001CD
62181+:101B0000310D007F03E21021004310213043007F9C
62182+:101B100003431821004C102400794821AF420024CF
62183+:101B20008D220024016C1824006C7026AD22000C5C
62184+:101B30008D220024310800FFAD22001095220014F0
62185+:101B4000952300208D27001C3042FFFF3063FFFFEC
62186+:101B50008D2600180043102300021100000227C345
62187+:101B60000040282100C4302300E2102B00C23023A3
62188+:101B700000E53823AD27001CAD2600189522002073
62189+:101B8000A522001495220022154B000AA52200165A
62190+:101B90008D2300248D220008254600013145008058
62191+:101BA0001462000430C4007F108F000238AA008045
62192+:101BB00000C0502151AF000131C800FF1518FFC906
62193+:101BC000010058218F8400343082007F03421821A5
62194+:101BD0003C02000A006218212402FF8000822024B7
62195+:101BE000AF440024A06A0079A06A00838C62005090
62196+:101BF0008F840034AC6200708C6500743C027FFFFF
62197+:101C00003442FFFF00A228240E00066BAC6500746E
62198+:101C1000AF5000248FBF00148FB0001003E0000805
62199+:101C200027BD001827BDFFC0AFBE0038AFB70034D6
62200+:101C3000AFB5002CAFB20020AFB1001CAFB00018A0
62201+:101C4000AFBF003CAFB60030AFB40028AFB3002444
62202+:101C50008F4500248F4600288F43002C3C02001F34
62203+:101C60003442FF800062182400C230240080A82182
62204+:101C7000AFA3001400A2F0240E00062FAFA60010A0
62205+:101C80003C0208008C4200E02410FF8003608821A1
62206+:101C900002A2102100501024AF4200243C02080090
62207+:101CA0008C4200E002A210213042007F0342182142
62208+:101CB0003C02000A00629021924200D293630084A9
62209+:101CC000305700FF306300FF24020001106200342F
62210+:101CD000036020212402000214620036000000008C
62211+:101CE0000E001216024028219223008392220083C4
62212+:101CF0003063007F3042007F000210C000031940B3
62213+:101D0000006218213C0208008C4200DC02A2102173
62214+:101D10000043382100F01024AF42002892250078BB
62215+:101D20009224008330E2007F034218213C02000C21
62216+:101D300014850007006280212402FFFFA24200F107
62217+:101D40002402FFFFA64200F20A0007272402FFFF39
62218+:101D500096020020A24200F196020022A64200F262
62219+:101D60008E020024AE4200F492220083A24200F0D0
62220+:101D70008E4200C8AE4200FC8E4200C4AE4200F863
62221+:101D80008E220050AE4201008E4200CCAE420104D1
62222+:101D9000922200853042003F0A0007823442004010
62223+:101DA0000E00123902402821922200850A00078283
62224+:101DB0003042003F936200852403FFDF3042003F42
62225+:101DC000A36200859362008500431024A36200850E
62226+:101DD0009363008393620078307400FF304200FF09
62227+:101DE00010540036240AFF803C0C000C3283007F24
62228+:101DF000000310C000031940006218213C020800D3
62229+:101E00008C4200DC268800013109007F02A21021EB
62230+:101E10000043382130E2007F0342182100EA1024F9
62231+:101E2000AF420028006C80218E020024028A182410
62232+:101E3000006A5826AE02000C8E020024310800FF12
62233+:101E4000AE02001096020014960300208E07001CBC
62234+:101E50003042FFFF3063FFFF8E060018004310235F
62235+:101E600000021100000227C30040282100C43023D3
62236+:101E700000E2102B00C2302300E53823AE07001C1F
62237+:101E8000AE06001896020020A60200149602002258
62238+:101E9000A602001692220079304200FF105400077B
62239+:101EA0000000000051370001316800FF92220078E5
62240+:101EB000304200FF1448FFCD0100A0219222008390
62241+:101EC000A22200798E2200500A0007E2AE220070A2
62242+:101ED000A22200858E22004C2405FF80AE42010C18
62243+:101EE0009222008534420020A2220085924200D135
62244+:101EF0003C0308008C6300DC305400FF3C02080007
62245+:101F00008C4200E400143140001420C002A31821C8
62246+:101F100000C4202102A210210064382100461021B3
62247+:101F20000045182400E52824AF450028AF43002CC5
62248+:101F30003042007F924400D030E3007F03422821EA
62249+:101F4000034318213C02000C006280213C02000E79
62250+:101F5000309600FF00A298211296002A000000008F
62251+:101F60008E02000C02002021026028211040002572
62252+:101F7000261000280E00064A000000009262000DA4
62253+:101F800026830001307400FF3042007FA262000D02
62254+:101F90002404FF801697FFF0267300203C020800FF
62255+:101FA0008C4200DC0000A02102A210210044102479
62256+:101FB000AF4200283C0208008C4200E43C030800C9
62257+:101FC0008C6300DC02A2102100441024AF42002CDC
62258+:101FD0003C0208008C4200E402A318213063007F19
62259+:101FE00002A210213042007F034220210343182126
62260+:101FF0003C02000C006280213C02000E0A0007A493
62261+:10200000008298218E4200D8AE2200508E4200D825
62262+:10201000AE22007092250083924600D19223008365
62263+:10202000924400D12402FF8000A228243063007F64
62264+:10203000308400FF00A628250064182A10600002E2
62265+:1020400030A500FF38A50080A2250083A2250079D5
62266+:102050000E00063D000000009222007E02A020211A
62267+:10206000A222007A8E2300743C027FFF3442FFFFDD
62268+:10207000006218240E00066BAE2300748FA20010BD
62269+:10208000AF5E00248FBF003CAF4200288FBE0038F7
62270+:102090008FA200148FB700348FB600308FB5002C9C
62271+:1020A0008FB400288FB300248FB200208FB1001CA2
62272+:1020B0008FB0001827BD004003E00008AF42002C9D
62273+:1020C00090A2000024420001A0A200003C030800EE
62274+:1020D0008C6300F4304200FF1443000F0080302175
62275+:1020E000A0A000003C0208008C4200E48F84003471
62276+:1020F000008220213082007F034218213C02000C24
62277+:10210000006218212402FF8000822024ACC300005A
62278+:1021100003E00008AF4400288C8200002442002025
62279+:1021200003E00008AC82000094C200003C080800F4
62280+:10213000950800CA30E7FFFF008048210102102106
62281+:10214000A4C2000094C200003042FFFF00E2102B46
62282+:1021500054400001A4C7000094A200003C03080002
62283+:102160008C6300CC24420001A4A2000094A20000D1
62284+:102170003042FFFF544300078F8600280107102BD1
62285+:10218000A4A000005440000101003821A4C70000B1
62286+:102190008F8600288CC4001CAF44003C94A2000031
62287+:1021A0008F43003C3042FFFF000210C00062182144
62288+:1021B000AF43003C8F42003C008220231880000483
62289+:1021C000000000008CC200180A00084324420001ED
62290+:1021D0008CC20018AF4200383C020050344200105C
62291+:1021E000AF420030000000000000000000000000CE
62292+:1021F0008F420000304200201040FFFD0000000030
62293+:102200008F420404AD2200048F420400AD2200007E
62294+:102210003C020020AF42003003E000080000000054
62295+:1022200027BDFFE0AFB20018AFB10014AFB000108F
62296+:10223000AFBF001C94C2000000C080213C12080007
62297+:10224000965200C624420001A60200009603000038
62298+:1022500094E2000000E03021144300058FB100300B
62299+:102260000E000818024038210A000875000000001E
62300+:102270008C8300048C820004244200400461000727
62301+:10228000AC8200048C8200040440000400000000C2
62302+:102290008C82000024420001AC8200009602000003
62303+:1022A0003042FFFF50520001A600000096220000BD
62304+:1022B00024420001A62200008F82002896230000FD
62305+:1022C00094420016144300048FBF001C2402000136
62306+:1022D000A62200008FBF001C8FB200188FB100141F
62307+:1022E0008FB0001003E0000827BD00208F89002870
62308+:1022F00027BDFFE0AFBF00188D220028274804004B
62309+:1023000030E700FFAF4200388D22002CAF8800304C
62310+:10231000AF42003C3C020005AF420030000000002C
62311+:1023200000000000000000000000000000000000AD
62312+:10233000000000008C82000C8C82000CAD020000BA
62313+:102340008C820010AD0200048C820018AD020008DF
62314+:102350008C82001CAD02000C8CA20014AD02001097
62315+:102360008C820020AD02001490820005304200FFF4
62316+:1023700000021200AD0200188CA20018AD02001C71
62317+:102380008CA2000CAD0200208CA20010AD02002433
62318+:102390008CA2001CAD0200288CA20020AD02002CF3
62319+:1023A000AD060030AD000034978300263402FFFFF5
62320+:1023B00014620002006020213404FFFF10E00011CD
62321+:1023C000AD04003895230036952400362402000120
62322+:1023D0003063FFFF000318C20069182190650040B8
62323+:1023E000308400070082100400451025A0620040E0
62324+:1023F0008F820028944200563042FFFF0A0008DC1A
62325+:10240000AD02003C952300369524003624020001DD
62326+:102410003063FFFF000318C2006918219065004077
62327+:1024200030840007008210040002102700451024A9
62328+:10243000A0620040AD00003C000000000000000071
62329+:10244000000000003C02000634420040AF42003071
62330+:102450000000000000000000000000008F420000AB
62331+:10246000304200101040FFFD8F860028AF880030FA
62332+:1024700024C2005624C7003C24C4002824C50032CE
62333+:1024800024C600360E000856AFA200108FBF0018F9
62334+:1024900003E0000827BD00208F8300243C060800CD
62335+:1024A0008CC600E88F82003430633FFF0003198040
62336+:1024B00000461021004310212403FF803046007F96
62337+:1024C00000431024AF420028034618213C02000CB0
62338+:1024D0000062302190C2000D30A500FF00003821BD
62339+:1024E00034420010A0C2000D8F8900288F8A00247A
62340+:1024F00095230036000A13823048000324020001AD
62341+:10250000A4C3000E1102000B2902000210400005B6
62342+:10251000240200021100000C240300010A0009201B
62343+:102520000000182111020006000000000A00092026
62344+:10253000000018218CC2002C0A000920244300014D
62345+:102540008CC20014244300018CC200180043102BDD
62346+:1025500050400009240700012402002714A20003B0
62347+:10256000000000000A00092C240700019522003E0B
62348+:1025700024420001A522003E000A138230430003DA
62349+:102580002C62000210400009008028211460000421
62350+:102590000000000094C200360A00093C3046FFFFEC
62351+:1025A0008CC600380A00093C008028210000302138
62352+:1025B0003C04080024844B780A00088900000000CD
62353+:1025C000274901008D22000C9523000601202021BF
62354+:1025D000000216023046003F3063FFFF240200274E
62355+:1025E00000C0282128C7002810C2000EAF83002495
62356+:1025F00010E00008240200312402002110C200096A
62357+:102600002402002510C200079382002D0A00095BF6
62358+:102610000000000010C200059382002D0A00095B33
62359+:10262000000000000A0008F4000000000A0006266E
62360+:102630000000000095230006912400058D25000C64
62361+:102640008D2600108D2700188D28001C8D29002054
62362+:10265000244200013C010800A4234B7E3C010800F9
62363+:10266000A0244B7D3C010800AC254B843C010800B4
62364+:10267000AC264B883C010800AC274B903C0108007D
62365+:10268000AC284B943C010800AC294B9803E00008AF
62366+:10269000A382002D8F87002827BDFFC0AFB3003471
62367+:1026A000AFB20030AFB1002CAFB00028AFBF0038E0
62368+:1026B0003C0208008C4200D094E3003030B0FFFFB1
62369+:1026C000005010073045FFFF3063FFFF00C0982126
62370+:1026D000A7A200103C110800963100C614A3000602
62371+:1026E0003092FFFF8CE2002424420030AF42003CD5
62372+:1026F0000A0009948CE2002094E200323042FFFF8D
62373+:1027000054A2000827A400188CE2002C24420030B8
62374+:10271000AF42003C8CE20028AF4200380A0009A218
62375+:102720008F84002827A5001027A60020022038212A
62376+:102730000E000818A7A000208FA200182442003025
62377+:10274000AF4200388FA2001CAF42003C8F840028AB
62378+:102750003C020005AF42003094820034274304005D
62379+:102760003042FFFF0202102B14400007AF830030FD
62380+:1027700094820054948300340202102100431023F9
62381+:102780000A0009B63043FFFF94830054948200345A
62382+:102790000223182100501023006218233063FFFF2A
62383+:1027A000948200163042FFFF144300030000000033
62384+:1027B0000A0009C424030001948200163042FFFF7E
62385+:1027C0000043102B104000058F82003094820016C9
62386+:1027D000006210233043FFFF8F820030AC530000B3
62387+:1027E000AC400004AC520008AC43000C3C020006B4
62388+:1027F00034420010AF420030000000000000000032
62389+:10280000000000008F420000304200101040FFFD29
62390+:10281000001018C2006418219065004032040007BF
62391+:10282000240200018FBF00388FB300348FB2003014
62392+:102830008FB1002C8FB000280082100400451025B5
62393+:1028400027BD004003E00008A062004027BDFFA8AC
62394+:10285000AFB60050AFB5004CAFB40048AFB30044C2
62395+:10286000AFB1003CAFBF0054AFB20040AFB00038D2
62396+:102870008C9000003C0208008C4200E88F860034F7
62397+:10288000960300022413FF8000C2302130633FFF13
62398+:102890000003198000C3382100F3102490B2000017
62399+:1028A000AF42002C9203000230E2007F034230214D
62400+:1028B0003C02000E00C28821306300C024020040A8
62401+:1028C0000080A82100A0B021146200260000A021F1
62402+:1028D0008E3400388E2200181440000224020001B9
62403+:1028E000AE2200189202000D304200201440001564
62404+:1028F0008F8200343C0308008C6300DC001238C077
62405+:10290000001231400043102100C730210046382119
62406+:1029100030E300073C02008030E6007800C230253A
62407+:102920000343182100F31024AF4208002463090078
62408+:10293000AF4608108E2200188C6300080043102157
62409+:10294000AE2200188E22002C8E2300182442000193
62410+:102950000062182B1060003D000000000A000A7899
62411+:1029600000000000920300022402FFC00043102474
62412+:10297000304200FF1440000524020001AE2200187E
62413+:10298000962200360A000A613054FFFF8E2200149E
62414+:1029900024420001AE22001892020000000216003C
62415+:1029A0000002160304410029000000009602000204
62416+:1029B00027A4001000802821A7A20016960200027A
62417+:1029C00024070001000030213042FFFFAF820024C5
62418+:1029D0000E000889AFA0001C960300023C0408000A
62419+:1029E0008C8400E88F82003430633FFF000319803D
62420+:1029F00000441021004310213043007F3C05000CAF
62421+:102A00000053102403431821AF4200280065182109
62422+:102A10009062000D001221403042007FA062000D44
62423+:102A20003C0308008C6300E48F82003400431021D3
62424+:102A30000044382130E2007F03421021004510217C
62425+:102A400000F31824AF430028AEA200009222000D2C
62426+:102A5000304200101040001302A020218F83002874
62427+:102A60008EA40000028030219462003E2442FFFFC9
62428+:102A7000A462003E948400029625000E3084FFFF7D
62429+:102A80000E00097330A5FFFF8F82002894430034A5
62430+:102A90009622000E1443000302A02021240200010C
62431+:102AA000A382002C02C028210E0007FE00000000B7
62432+:102AB0008FBF00548FB600508FB5004C8FB40048C4
62433+:102AC0008FB300448FB200408FB1003C8FB000380C
62434+:102AD00003E0000827BD00588F82002827BDFFD0E3
62435+:102AE000AFB40028AFB20020AFBF002CAFB30024BA
62436+:102AF000AFB1001CAFB00018904400D0904300D19B
62437+:102B00000000A021309200FFA3A30010306300FF5B
62438+:102B10008C5100D88C5300DC1072002B2402000171
62439+:102B20003C0308008C6300E493A400108F820034FF
62440+:102B30002406FF800004214000431021004410219E
62441+:102B40003043007F00461024AF4200280343182181
62442+:102B50003C02000C006218218C62000427A40014BF
62443+:102B600027A50010022280210270102304400015C6
62444+:102B7000AFA300149062000D00C21024304200FF89
62445+:102B800014400007020088219062000D344200408A
62446+:102B90000E0007FEA062000D0A000ABD93A20010FD
62447+:102BA0000E0009E1241400018F830028AC7000D8C6
62448+:102BB00093A20010A06200D193A200101452FFD87B
62449+:102BC0000000000024020001168200048FBF002CC8
62450+:102BD0000E000626000000008FBF002C8FB40028D6
62451+:102BE0008FB300248FB200208FB1001C8FB000186B
62452+:102BF00003E0000827BD003027BDFFD8AFB3001C9D
62453+:102C0000AFB20018AFB10014AFB00010AFBF0020DA
62454+:102C10000080982100E0802130B1FFFF0E00049376
62455+:102C200030D200FF000000000000000000000000A3
62456+:102C30008F820020AC510000AC520004AC5300085D
62457+:102C4000AC40000CAC400010AC400014AC4000188C
62458+:102C50003C03080094634B5E02038025AC50001CCB
62459+:102C6000000000000000000000000000240400013B
62460+:102C70008FBF00208FB3001C8FB200188FB10014DB
62461+:102C80008FB000100A0004B827BD002827BDFFE858
62462+:102C9000AFB00010AFBF001430A5FFFF30C600FF7B
62463+:102CA0000080802124020C80AF420024000000003C
62464+:102CB0000000000000000000000000000000000014
62465+:102CC0000E000ACC000000003C040800248400E050
62466+:102CD0008C8200002403FF808FBF001402021021A9
62467+:102CE00000431024AF4200248C8200003C03000A01
62468+:102CF000020280213210007F035010218FB000109B
62469+:102D00000043102127BD001803E00008AF8200280F
62470+:102D100027BDFFE8AFBF00108F4401403C0308000F
62471+:102D20008C6300E02402FF80AF840034008318210C
62472+:102D300000621024AF4200243C02000803424021FC
62473+:102D4000950500023063007F3C02000A034318210E
62474+:102D50000062182130A5FFFF3402FFFF0000302180
62475+:102D60003C07602010A20006AF8300282402FFFF6A
62476+:102D7000A5020002946500D40E000AF130A5FFFF01
62477+:102D80008FBF001024020C8027BD001803E000084C
62478+:102D9000AF4200243C020008034240219502000299
62479+:102DA0003C0A0800954A00C63046FFFF14C00007E1
62480+:102DB0003402FFFF8F8200288F8400343C0760209C
62481+:102DC000944500D40A000B5A30A5FFFF10C200241E
62482+:102DD0008F87002894E2005494E400163045FFFFEA
62483+:102DE00000A6102300A6182B3089FFFF10600004F6
62484+:102DF0003044FFFF00C51023012210233044FFFFA1
62485+:102E0000008A102B1040000C012A1023240200011C
62486+:102E1000A50200162402FFFFA502000294E500D4DB
62487+:102E20008F8400340000302130A5FFFF3C07602074
62488+:102E30000A000AF1000000000044102A10400008B7
62489+:102E4000000000009502001630420001104000040E
62490+:102E5000000000009742007E24420014A5020016E4
62491+:102E600003E00008000000008F84002827BDFFE079
62492+:102E7000AFBF0018948200349483003E1060001AA3
62493+:102E80003048FFFF9383002C2402000114620027C6
62494+:102E90008FBF00188F820028000818C23108000771
62495+:102EA000006218212447003A244900542444002099
62496+:102EB000244500302446003490620040304200FF38
62497+:102EC0000102100730420001104000168FBF0018A9
62498+:102ED0000E000856AFA900108F82002894420034DB
62499+:102EE0000A000B733048FFFF94830036948200344D
62500+:102EF0001043000E8FBF001894820036A482003465
62501+:102F000094820056A48200548C82002CAC8200244F
62502+:102F100094820032A48200309482003CA482003A61
62503+:102F20008FBF00180A000B3327BD002003E0000804
62504+:102F300027BD002027BDFFE8AFBF00108F4A01006A
62505+:102F40003C0508008CA500E03C02080090424B8440
62506+:102F50003C0C0800958C4B7E01452821304B003FEE
62507+:102F600030A2007F03424021396900323C02000A4E
62508+:102F70003963003F2C630001010240212D2900012B
62509+:102F80002402FF8000A2282401234825AF8A0034B0
62510+:102F900000801821AF450024000030210080282146
62511+:102FA00024070001AF8800283C04080024844B78E3
62512+:102FB000AF8C002415200007A380002D24020020E0
62513+:102FC0005562000F006020213402FFFF5582000C83
62514+:102FD000006020212402002015620005000000008E
62515+:102FE0008C6300142402FFFF106200070000000041
62516+:102FF0000E000889000000000A000BD0000000004D
62517+:103000000E0008F4016028210E000B68000000008B
62518+:103010008FBF001024020C8027BD001803E00008B9
62519+:10302000AF4200243C0208008C4200E027BDFFA014
62520+:10303000AFB1003C008210212411FF80AFBE0058C8
62521+:10304000AFB70054AFB20040AFB00038AFBF005CC4
62522+:10305000AFB60050AFB5004CAFB40048AFB30044BA
62523+:10306000005110248F4800248F4900288F470028E2
62524+:10307000AF4200243C0208008C4200E00080902116
62525+:1030800024060006008210213042007F03421821EE
62526+:103090003C02000A006280213C02001F3442FF8093
62527+:1030A00000E2382427A40010260500F00122F024B5
62528+:1030B0000102B8240E00051DAFA700308FA2001832
62529+:1030C000AE0200C48FA2001CAE0200C88FA2002472
62530+:1030D000AE0200CC93A40010920300D12402FF8022
62531+:1030E0000082102400431025304900FF3083007F08
62532+:1030F0003122007F0062102A10400004000310C03B
62533+:1031000001311026304900FF000310C000031940B0
62534+:10311000006218213C0208008C4200DC920400D2BC
62535+:10312000024210210043102100511024AF42002818
62536+:1031300093A300103063007F000310C00003194008
62537+:10314000006218213C0208008C4200DC024210217F
62538+:10315000004310213042007F034218213C02000C42
62539+:10316000006240218FA300142402FFFF1062003090
62540+:10317000309500FF93A2001195030014304400FF26
62541+:103180003063FFFF0064182B1060000D000000008A
62542+:10319000950400148D07001C8D0600183084FFFF75
62543+:1031A00000442023000421000000102100E4382105
62544+:1031B00000E4202B00C230210A000C4A00C4302158
62545+:1031C000950400148D07001C8D0600183084FFFF45
62546+:1031D000008220230004210000001021008018211B
62547+:1031E00000C2302300E4202B00C4302300E3382346
62548+:1031F000AD07001CAD06001893A20011A502001433
62549+:1032000097A20012A50200168FA20014AD020010B2
62550+:103210008FA20014AD02000C93A20011A5020020A1
62551+:1032200097A20012A50200228FA20014AD02002472
62552+:103230002406FF80024610243256007FAF4200244D
62553+:10324000035618213C02000A006280218E02004CC5
62554+:103250008FA200203124007F000428C0AE0200505D
62555+:103260008FA200200004214000852821AE020070BA
62556+:1032700093A2001001208821A202008393A20010D3
62557+:10328000A2020079920200853042003FA20200852E
62558+:103290003C0208008C4200DC024210210045102153
62559+:1032A00000461024AF42002C3C0208008C4200E48F
62560+:1032B0003C0308008C6300DC024210210044102112
62561+:1032C00000461024AF4200283C0208008C4200E473
62562+:1032D00002431821006518210242102100441021E8
62563+:1032E0003042007F3063007F93A50010034220210D
62564+:1032F000034318213C02000E006240213C02000CF6
62565+:1033000010B1008C008248213233007F1660001912
62566+:103310002404FF803C0208008C4200DC02421021A1
62567+:1033200000441024AF42002C3C0208008C4200E410
62568+:103330003C0308008C6300DC02421021004410248E
62569+:10334000AF4200283C0208008C4200E402431821EE
62570+:103350003063007F024210213042007F034220216F
62571+:10336000034318213C02000E006240213C02000C85
62572+:10337000008248219124000D2414FF8000001021B8
62573+:1033800000942025A124000D950400029505001449
62574+:103390008D07001C3084FFFF30A5FFFF8D0600184D
62575+:1033A000008520230004210000E4382100C23021E0
62576+:1033B00000E4202B00C43021AD07001CAD0600182E
62577+:1033C00095020002A5020014A50000168D02000857
62578+:1033D000AD0200108D020008AD02000C9502000243
62579+:1033E000A5020020A50000228D020008AD020024E5
62580+:1033F0009122000D30420040104000422622000180
62581+:103400003C0208008C4200E0A3B300283C10000AF4
62582+:103410000242102100541024AF4200243C02080054
62583+:103420008C4200E0A380002C27A4002C0242102133
62584+:103430003042007F03421821007018218C6200D8AE
62585+:103440008D26000427A50028AFA9002C00461021D6
62586+:10345000AC6200D80E0009E1AF83002893A30028D6
62587+:103460008F8200280E000626A04300D10E000B68B4
62588+:103470000000000002541024AF4200243C02080067
62589+:103480008C4200DC00132940001320C000A420213E
62590+:10349000024210210044102100541024AF42002C9D
62591+:1034A0003C0208008C4200E43C0308008C6300DC12
62592+:1034B00003563021024210210045102100541024EF
62593+:1034C000AF4200283C0208008C4200E4024318216D
62594+:1034D0000064182102421021004510213042007F73
62595+:1034E0003063007F03422021034318213C02000E79
62596+:1034F000006240213C02000C00D080210082482163
62597+:10350000262200013043007F14750005304400FF7F
62598+:103510002403FF800223102400431026304400FFC0
62599+:1035200093A2001000808821250800281444FF760B
62600+:103530002529002093A400108FA300142402FFFF6C
62601+:103540001062000A308900FF2482000124830001F8
62602+:103550003042007F14550005306900FF2403FF80CE
62603+:103560000083102400431026304900FF92020078A7
62604+:10357000305300FF11330032012088213C02080043
62605+:103580008C4200DC3225007F000520C00005294068
62606+:1035900000A42021024210212406FF8000441021B3
62607+:1035A00000461024AF42002C3C0308008C6300DC72
62608+:1035B0003C0208008C4200E4024318210242102120
62609+:1035C0000045102100641821004610243063007F5C
62610+:1035D000AF420028034318213C02000E0062402144
62611+:1035E0003C0208008C4200E48D06000C0100202102
62612+:1035F00002421021004510213042007F0342182171
62613+:103600003C02000C0062482110C0000D012028215E
62614+:103610000E00064A000000002402FF800222182447
62615+:1036200026240001006228263082007F1455000203
62616+:10363000308300FF30A300FF1473FFD000608821A7
62617+:103640008E0300743C027FFF3442FFFF00621824A7
62618+:10365000AE0300740E00066B02402021AF57002419
62619+:103660008FA20030AF5E00288FBF005C8FBE005875
62620+:103670008FB700548FB600508FB5004C8FB4004800
62621+:103680008FB300448FB200408FB1003C8FB0003840
62622+:1036900027BD006003E00008AF42002C27BDFFD823
62623+:1036A000AFB1001CAFBF0020AFB000182751018898
62624+:1036B000922200032408FF803C03000A3047007F69
62625+:1036C000A3A700108F4601803C0208008C4200E056
62626+:1036D000AF86003400C2282100A81024AF42002485
62627+:1036E0009224000030A2007F0342102100431021E9
62628+:1036F000AF8200283084007F24020002148200255B
62629+:10370000000719403C0208008C4200E400C210216E
62630+:103710000043282130A2007F0342182100A8102472
62631+:10372000AF4200283C02000C006218219062000D9C
62632+:10373000AFA3001400481025A062000D8FA3001451
62633+:103740009062000D304200405040006A8FBF002060
62634+:103750008F860028A380002C27A400148CC200D8D8
62635+:103760008C63000427A50010004310210E0009E11E
62636+:10377000ACC200D893A300108F8200280E0006264A
62637+:10378000A04300D10E000B68000000000A000E0BE1
62638+:103790008FBF00200E00062F00C020210E00063D26
62639+:1037A000000000003C020008034280219223000137
62640+:1037B0009202007B1443004F8FBF00209222000032
62641+:1037C0003044007F24020004108200172882000584
62642+:1037D00010400006240200052402000310820007A6
62643+:1037E0008FB1001C0A000E0C0000000010820012B5
62644+:1037F0008FBF00200A000E0C8FB1001C92050083C1
62645+:10380000920600788E0700748F84003430A500FF84
62646+:1038100000073E0230C600FF0E00067330E7007F4F
62647+:103820000A000E0B8FBF00200E000BD78F840034D0
62648+:103830000A000E0B8FBF002024020C80AF42002430
62649+:103840009202003E30420040104000200000000084
62650+:103850009202003E00021600000216030441000618
62651+:10386000000000008F8400340E0005A024050093A2
62652+:103870000A000E0B8FBF00209202003F24030018A5
62653+:10388000304200FF1443000C8F84003424050039BB
62654+:103890000E000538000030210E0002508F840034E5
62655+:1038A00024020012A202003F0E0002598F8400344D
62656+:1038B0000A000E0B8FBF0020240500360E000538CD
62657+:1038C000000030210A000E0B8FBF00200E000250B6
62658+:1038D0008F8400349202000534420020A2020005C9
62659+:1038E0000E0002598F8400340E000FC08F84003404
62660+:1038F0008FBF00208FB1001C8FB0001824020C80F5
62661+:1039000027BD002803E00008AF42002427BDFFE8E0
62662+:10391000AFB00010AFBF001427430100946200084D
62663+:103920000002140000021403044100020000802180
62664+:103930002410000194620008304200801040001AF8
62665+:10394000020010219462000830422000104000164E
62666+:10395000020010218C6300183C021C2D344219ED2A
62667+:10396000240600061062000F3C0760213C0208009C
62668+:103970008C4200D4104000078F8200288F830028DB
62669+:10398000906200623042000F34420040A062006248
62670+:103990008F8200288F840034944500D40E000AF1F1
62671+:1039A00030A5FFFF020010218FBF00148FB0001060
62672+:1039B00003E0000827BD001827BDFFE0AFB10014E9
62673+:1039C000AFB00010A380002CAFBF00188F450100DE
62674+:1039D0003C0308008C6300E02402FF80AF850034C4
62675+:1039E00000A318213064007F0344202100621824C2
62676+:1039F0003C02000A00822021AF430024275001002E
62677+:103A00008E0200148C8300DCAF8400280043102356
62678+:103A100018400004000088218E0200140E000A8461
62679+:103A2000AC8200DC9202000B24030002304200FF53
62680+:103A30001443002F0000000096020008304300FFEE
62681+:103A40002402008214620005240200840E00093E54
62682+:103A5000000000000A000E97000000001462000938
62683+:103A6000240200818F8200288F8400343C0760216B
62684+:103A7000944500D49206000530A5FFFF0A000E868B
62685+:103A800030C600FF14620027000000009202000A06
62686+:103A9000304300FF306200201040000430620040DC
62687+:103AA0008F8400340A000E82240600401040000477
62688+:103AB000000316008F8400340A000E8224060041A1
62689+:103AC00000021603044100178F84003424060042CC
62690+:103AD0008F8200283C076019944500D430A5FFFF71
62691+:103AE0000E000AF1000000000A000E97000000001E
62692+:103AF0009202000B24030016304200FF1043000620
62693+:103B0000000000009202000B24030017304200FF67
62694+:103B100014430004000000000E000E11000000001D
62695+:103B2000004088210E000B68000000009202000A8D
62696+:103B3000304200081040000624020C808F850028C7
62697+:103B40003C0400080E0011EE0344202124020C80E6
62698+:103B5000AF4200248FBF0018022010218FB0001048
62699+:103B60008FB1001403E0000827BD002027BDFFE847
62700+:103B7000AFBF0014AFB000108F5000243C0308000A
62701+:103B80008C6300E08F4501002402FF8000A3182110
62702+:103B90003064007F03442021006218243C02000AA4
62703+:103BA00000822021AF850034AF4300249082006260
62704+:103BB000AF8400283042000F34420050A0820062DF
62705+:103BC0003C02001F3442FF800E00062602028024C1
62706+:103BD000AF5000248FBF00148FB0001003E0000826
62707+:103BE00027BD00183C0208008C4200201040001D38
62708+:103BF0002745010090A300093C0200080342202150
62709+:103C000024020018546200033C0200080A000ED887
62710+:103C10002402000803422021240200161462000539
62711+:103C20002402001724020012A082003F0A000EE2C4
62712+:103C300094A700085462000694A700089362000548
62713+:103C40002403FFFE00431024A362000594A700088C
62714+:103C500090A6001B8CA4000094A500060A000ACCC4
62715+:103C600000073C0003E000080000000027440100BA
62716+:103C700094820008304500FF38A3008238A20084F7
62717+:103C80002C6300012C420001006218251060000620
62718+:103C9000240200839382002D1040000D00000000DC
62719+:103CA0000A000B9B0000000014A2000524A2FF8064
62720+:103CB0008F4301043C02602003E00008AC43001481
62721+:103CC000304200FF2C420002104000032402002278
62722+:103CD0000A000E3C0000000014A2000300000000D7
62723+:103CE0000A000EA9000000000A000EC70000000034
62724+:103CF0009363007E9362007A144300090000202140
62725+:103D00009362000024030050304200FF144300047B
62726+:103D1000240400019362007E24420001A362007E1D
62727+:103D200003E00008008010218F4201F80440FFFEEC
62728+:103D300024020002AF4401C0A34201C43C021000AF
62729+:103D400003E00008AF4201F827BDFFE8AFBF001055
62730+:103D50009362003F2403000A304200FF14430046F0
62731+:103D6000000000008F6300548F62004C1062007DE1
62732+:103D7000036030219362000024030050304200FFB2
62733+:103D80001443002F000000008F4401403C02080053
62734+:103D90008C4200E02403FF800082102100431024A5
62735+:103DA000AF4200243C0208008C4200E08F650054C2
62736+:103DB0003C03000A008220213084007F034410214C
62737+:103DC00000431021AC4501089762003C8F63004C12
62738+:103DD0003042FFFF0002104000621821AF63005C18
62739+:103DE0008F6300548F64004C9762003C006418237A
62740+:103DF0003042FFFF00031843000210400043102A26
62741+:103E000010400006000000008F6200548F63004CD9
62742+:103E1000004310230A000F58000210439762003C31
62743+:103E20003042FFFF00021040ACC2006424020001D7
62744+:103E3000A0C0007CA0C2008424020C80AF420024F9
62745+:103E40000E000F0A8F440140104000478FBF001042
62746+:103E50008F4301408F4201F80440FFFE240200021C
62747+:103E6000AF4301C0A34201C43C021000AF4201F8BD
62748+:103E70000A000FA88FBF00109362003F24030010B8
62749+:103E8000304200FF14430004000000008F44014052
62750+:103E90000A000F94000028219362003F24030016BB
62751+:103EA000304200FF1443000424020014A362003FC8
62752+:103EB0000A000FA2000000008F62004C8F630050C8
62753+:103EC00000431023044100288FBF0010936200813B
62754+:103ED00024420001A3620081936200812C4200040D
62755+:103EE00014400010000000009362003F240300040F
62756+:103EF000304200FF14430006000000008F440140E0
62757+:103F00008FBF0010240500930A0005A027BD0018EC
62758+:103F10008F440140240500938FBF00100A00060F54
62759+:103F200027BD00188F4401400E0002500000000021
62760+:103F30008F6200542442FFFFAF6200548F62005032
62761+:103F40002442FFFFAF6200500E0002598F4401402F
62762+:103F50008F4401408FBF0010240500040A00025E58
62763+:103F600027BD00188FBF001003E0000827BD001810
62764+:103F70008F4201889363007E00021402304400FFE8
62765+:103F8000306300FF1464000D0000000093620080A5
62766+:103F9000304200FF1044000900000000A3640080CC
62767+:103FA0009362000024030050304200FF14430004D9
62768+:103FB000000000000A0006D78F440180A36400803F
62769+:103FC00003E000080000000027BDFFE8AFB00010CC
62770+:103FD000AFBF00149362000524030030304200306C
62771+:103FE00014430089008080213C0208008C4200209C
62772+:103FF00010400080020020210E0004930000000009
62773+:104000008F850020ACB000009362003E9363003FB8
62774+:10401000304200FF00021200306300FF0043102511
62775+:10402000ACA2000493620082000216000002160394
62776+:1040300004410005000000003C0308008C630048B8
62777+:104040000A000FE6000000009362003E304200408C
62778+:10405000144000030000182193620081304300FFE8
62779+:104060009362008200031E00304200FF0002140031
62780+:1040700000621825ACA300088F620040ACA2000CBF
62781+:104080008F620048ACA200108F62004CACA20014FA
62782+:104090008F6200508F63004C0043102304410003E3
62783+:1040A000000000000A000FFA8F62004C8F6200507F
62784+:1040B000ACA200183C02080094424B5E3C03C00BCB
62785+:1040C00000002021004310250E0004B8ACA2001C03
62786+:1040D0008F6200548F840020AC8200008F620058F1
62787+:1040E000AC8200048F62005CAC8200088F620060CA
62788+:1040F0008F43007400431021AC82000C8F62006477
62789+:10410000AC820010976300689762006A00031C008D
62790+:104110003042FFFF00621825AC83001493620082D6
62791+:1041200024030080304200FF14430003000000001D
62792+:104130000A00102EAC8000188F63000C24020001CE
62793+:104140001062000E2402FFFF9362003E30420040E6
62794+:104150001440000A2402FFFF8F63000C8F4200749A
62795+:10416000006218233C020800006210241440000280
62796+:10417000000028210060282100051043AC820018AF
62797+:104180003C02080094424B5E3C03C00C000020211E
62798+:10419000004310258F8300200E0004B8AC62001C81
62799+:1041A0008F6200188F8300203C05080094A54B5EA9
62800+:1041B00024040001AC620000AC6000048F66006C57
62801+:1041C0003C02400D00A22825AC6600088F6200DC8E
62802+:1041D000AC62000CAC600010936200050002160097
62803+:1041E000AC620014AC6000180E0004B8AC65001C92
62804+:1041F000020020218FBF00148FB00010A3600005C3
62805+:104200000A00042127BD00188FBF00148FB00010D2
62806+:1042100003E0000827BD00189742007C30C600FF6D
62807+:10422000A08600843047FFFF2402000514C2000B63
62808+:1042300024E3465090A201122C42000710400007D0
62809+:1042400024E30A0090A30112240200140062100467
62810+:1042500000E210210A0010663047FFFF3067FFFFC1
62811+:1042600003E00008A4870014AC87004C8CA201086E
62812+:104270000080402100A0482100E2102330C600FF4A
62813+:104280001840000393AA001324E2FFFCACA201082B
62814+:1042900030C2000110400008000000008D020050F4
62815+:1042A00000E2102304410013240600058D0200548F
62816+:1042B00010E20010000000008D02005414E2001A09
62817+:1042C000000000003C0208008C4200D83042002070
62818+:1042D0001040000A2402000191030078910200833B
62819+:1042E000144300062402000101002021012028219E
62820+:1042F000240600040A00105400000000A1000084FD
62821+:1043000011400009A50200148F4301008F4201F8FB
62822+:104310000440FFFE24020002AF4301C0A34201C4D7
62823+:104320003C021000AF4201F803E00008000000006A
62824+:1043300027BDFFE88FA90028AFBF001000804021F3
62825+:1043400000E918231860007330C600FFA080007CCD
62826+:10435000A08000818CA2010800E210230440004DDF
62827+:10436000000000008C8200509483003C8C84006428
62828+:10437000004748233063FFFF012318210083202BCF
62829+:1043800010800004000000008D0200640A0010B7D5
62830+:1043900000E210219502003C3042FFFF0122102173
62831+:1043A00000E21021AD02005C9502003C8D03005C30
62832+:1043B0003042FFFF0002104000E210210043102BAA
62833+:1043C00010400003000000000A0010C68D02005CCF
62834+:1043D0009502003C3042FFFF0002104000E2102135
62835+:1043E000AD02005CA1000084AD07004C8CA2010866
62836+:1043F00000E210231840000224E2FFFCACA20108F6
62837+:1044000030C200011040000A000000008D02005080
62838+:1044100000E2102304410004010020218D02005419
62839+:1044200014E20003000000000A0010E82406000562
62840+:104430008D02005414E200478FBF00103C020800B8
62841+:104440008C4200D8304200201040000A24020001B3
62842+:1044500091030078910200831443000624020001B6
62843+:1044600001002021240600048FBF00100A00105410
62844+:1044700027BD0018A1000084A50200148F4301008D
62845+:104480008F4201F80440FFFE240200020A00110DD1
62846+:10449000000000008C82005C004910230043102BB8
62847+:1044A00054400001AC87005C9502003C3042FFFFA5
62848+:1044B0000062102B14400007240200029502003C09
62849+:1044C0008D03005C3042FFFF00621821AD03005CE9
62850+:1044D00024020002AD07004CA10200840E000F0A66
62851+:1044E0008F4401001040001B8FBF00108F4301005C
62852+:1044F0008F4201F80440FFFE24020002AF4301C0D6
62853+:10450000A34201C43C021000AF4201F80A0011238B
62854+:104510008FBF001030C200101040000E8FBF00107F
62855+:104520008C83005C9482003C006918233042FFFFBA
62856+:10453000006218213C023FFF3444FFFF0083102B30
62857+:10454000544000010080182101231021AD02005CBD
62858+:104550008FBF001003E0000827BD001827BDFFE84B
62859+:104560008FAA0028AFBF00100080402100EA482336
62860+:104570001920002130C600FF8C83005C8C8200640F
62861+:10458000006A18230043102B5040001000691821C6
62862+:1045900094A2011001221021A4A2011094A20110E2
62863+:1045A0003042FFFF0043102B1440000A3C023FFF43
62864+:1045B00094A2011000431023A4A201109482003C95
62865+:1045C0003042FFFF0A00114200621821A4A001102E
62866+:1045D0003C023FFF3444FFFF0083102B5440000196
62867+:1045E0000080182100671021AD02005CA100007C52
62868+:1045F0000A00118AA100008130C200101040003C66
62869+:10460000000000008C820050004A1023184000383F
62870+:10461000000000009082007C24420001A082007C07
62871+:104620009082007C3C0308008C630024304200FF31
62872+:104630000043102B1440005C8FBF00108CA20108B7
62873+:1046400000E2102318400058000000008C83005442
62874+:104650009482003C006A18233042FFFF0003184395
62875+:10466000000210400043102A104000050000000026
62876+:104670008C820054004A10230A001171000210437A
62877+:104680009482003C3042FFFF00021040AD02006403
62878+:104690009502003C8D0400649503003C3042FFFF0E
62879+:1046A00000021040008220213063FFFF00831821A8
62880+:1046B00001431021AD02005C8D020054ACA2010840
62881+:1046C00024020002A10200840E000F0A8F440100A0
62882+:1046D000104000358FBF00108F4301008F4201F85A
62883+:1046E0000440FFFE240200020A0011B30000000093
62884+:1046F000AD07004C8CA2010800E210231840000214
62885+:1047000024E2FFFCACA2010830C200011040000A04
62886+:10471000000000008D02005000E21023044100045C
62887+:10472000010020218D02005414E20003000000006B
62888+:104730000A0011AA240600058D02005414E2001A92
62889+:104740008FBF00103C0208008C4200D8304200208D
62890+:104750001040000A240200019103007891020083B6
62891+:104760001443000624020001010020212406000455
62892+:104770008FBF00100A00105427BD0018A10000844C
62893+:10478000A50200148F4301008F4201F80440FFFE90
62894+:1047900024020002AF4301C0A34201C43C02100046
62895+:1047A000AF4201F88FBF001003E0000827BD0018DA
62896+:1047B0008FAA00108C8200500080402130C600FF7C
62897+:1047C000004A102300A048211840000700E01821EB
62898+:1047D00024020001A0800084A0A00112A482001481
62899+:1047E0000A001125AFAA0010A0800081AD07004C7F
62900+:1047F0008CA2010800E210231840000224E2FFFC12
62901+:10480000ACA2010830C20001104000080000000006
62902+:104810008D0200500062102304410013240600059D
62903+:104820008D02005410620010000000008D02005440
62904+:1048300014620011000000003C0208008C4200D805
62905+:10484000304200201040000A240200019103007849
62906+:10485000910200831443000624020001010020217C
62907+:1048600001202821240600040A0010540000000042
62908+:10487000A1000084A502001403E00008000000006D
62909+:1048800027BDFFE0AFBF0018274201009046000A95
62910+:104890008C4800148C8B004C9082008430C900FF3F
62911+:1048A00001681823304A00FF1C60001A2D460006DC
62912+:1048B000240200010142100410C00016304300031E
62913+:1048C000012030210100382114600007304C000C19
62914+:1048D00015800009304200301440000B8FBF0018D3
62915+:1048E0000A001214000000000E001125AFAB0010EA
62916+:1048F0000A0012148FBF00180E00109AAFAB001000
62917+:104900000A0012148FBF0018AFAB00100E0011BACE
62918+:10491000AFAA00148FBF001803E0000827BD0020D5
62919+:1049200024020003A08200848C82005403E000086B
62920+:10493000ACA201083C0200080342182190620081E9
62921+:10494000240600433C07601924420001A062008154
62922+:10495000906300813C0208008C4200C0306300FF7D
62923+:10496000146200102403FF803C0208008C4200E027
62924+:104970000082102100431024AF4200243C020800B2
62925+:104980008C4200E03C03000A008210213042007F8C
62926+:104990000342102100431021944500D40A000AF17B
62927+:1049A00030A5FFFF03E000080000000027BDFFE086
62928+:1049B000AFBF0018AFB10014AFB000108F4201803C
62929+:1049C0000080802100A088210E00121B00402021C1
62930+:1049D000A20000848E0200548FBF00188FB0001018
62931+:1049E000AE2201088FB1001403E0000827BD0020AB
62932+:1049F00027BDFFE03C020008AFB00010AFBF0018B9
62933+:104A0000AFB10014034280218F5101409203008412
62934+:104A10008E0400508E02004C14820040306600FF6D
62935+:104A20003C0208008C4200E02403FF800222102197
62936+:104A300000431024AF4200243C0208008C4200E0F6
62937+:104A40009744007C92050081022210213042007FB1
62938+:104A5000034218213C02000A0062182114A0000B36
62939+:104A60003084FFFF2402000554C20014248205DCB8
62940+:104A70009062011224420001A062011224020C8003
62941+:104A8000AF4200240A00127324020005A060011244
62942+:104A90002402000514C20009248205DC9202008170
62943+:104AA0002C4200075040000524820A009203008136
62944+:104AB0002402001400621004008210213044FFFF21
62945+:104AC000A60400140E00121B022020219602003CB6
62946+:104AD0008E03004C022020213042FFFF00021040D4
62947+:104AE000006218210E000250AE03005C9202007DAD
62948+:104AF00002202021344200400E000259A202007D13
62949+:104B00008F4201F80440FFFE24020002AF5101C0B1
62950+:104B1000A34201C43C021000AF4201F88FBF00184D
62951+:104B20008FB100148FB0001003E0000827BD0020F3
62952+:104B300008000ACC08000B1408000B9808000BE4CE
62953+:104B400008000C200A0000280000000000000000FF
62954+:104B50000000000D6370362E322E3300000000007E
62955+:104B60000602030400000000000000000000000036
62956+:104B70000000000000000000000000000000000035
62957+:104B80000000000000000000000000000000002005
62958+:104B90000000000000000000000000000000000015
62959+:104BA0000000000000000000000000000000000005
62960+:104BB00000000000000000000000000000000001F4
62961+:104BC0000000002B000000000000000400030D4066
62962+:104BD00000000000000000000000000000000000D5
62963+:104BE00000000000000000001000000300000000B2
62964+:104BF0000000000D0000000D3C020800244258A4F3
62965+:104C00003C03080024635F70AC4000000043202B8D
62966+:104C10001480FFFD244200043C1D080037BD7FFCCA
62967+:104C200003A0F0213C100800261000A03C1C080046
62968+:104C3000279C58A40E0001AC000000000000000DED
62969+:104C400027BDFFE83C096018AFBF00108D2C500055
62970+:104C5000240DFF7F24080031018D5824356A380C5B
62971+:104C600024070C003C1A8000AD2A50003C04800A46
62972+:104C7000AF4800083C1B8008AF4700240E00091510
62973+:104C8000AF8400100E0008D8000000000E000825B8
62974+:104C9000000000000E001252000000003C046016EC
62975+:104CA0008C8500003C06FFFF3C02535300A61824ED
62976+:104CB0001062004734867C0094C201F2A780002C69
62977+:104CC00010400003A78000CC38581E1EA798002C67
62978+:104CD00094C201F810400004978300CC38591E1E7E
62979+:104CE000A79900CC978300CC2C7F006753E000018C
62980+:104CF000240300669784002C2C82040114400002D7
62981+:104D000000602821240404003C0760008CE904387A
62982+:104D10002403103C3128FFFF1103001F30B9FFFFAF
62983+:104D200057200010A38000CE24020050A38200CEA2
62984+:104D3000939F00CE53E0000FA78500CCA78000CC46
62985+:104D4000978500CC8FBF0010A780002CA78000346F
62986+:104D5000A78000E63C010800AC25008003E00008C5
62987+:104D600027BD0018939F00CE57E0FFF5A78000CC29
62988+:104D7000A78500CC978500CC8FBF0010A784002C9E
62989+:104D8000A7800034A78000E63C010800AC25008025
62990+:104D900003E0000827BD0018A38000CE8CCB003CA8
62991+:104DA000316A00011140000E0000000030A7FFFF33
62992+:104DB00010E0FFDE240200508CCC00C831860001D8
62993+:104DC00014C0FFDC939F00CE0A00007A2402005139
62994+:104DD0008C8F00043C0E60000A00005D01EE302163
62995+:104DE0008CEF0808240D5708000F740211CD000441
62996+:104DF00030B8FFFF240500660A00007B240404008D
62997+:104E00001700FFCC939F00CE0A00007A24020050C6
62998+:104E10008F8600103089FFFF000939408CC30010D5
62999+:104E20003C08005000E82025AF4300388CC5001432
63000+:104E300027420400AF82001CAF45003CAF44003065
63001+:104E40000000000000000000000000000000000062
63002+:104E50000000000000000000000000000000000052
63003+:104E60008F4B0000316A00201140FFFD0000000060
63004+:104E700003E00008000000008F840010948A001AEC
63005+:104E80008C8700243149FFFF000940C000E8302131
63006+:104E9000AF46003C8C8500248F43003C00A31023C8
63007+:104EA00018400029000000008C8B002025620001C2
63008+:104EB0003C0D005035AC0008AF420038AF4C00301C
63009+:104EC00000000000000000000000000000000000E2
63010+:104ED00000000000000000000000000000000000D2
63011+:104EE0008F4F000031EE002011C0FFFD00000000D8
63012+:104EF0008F4A04003C080020AC8A00108F4904044B
63013+:104F0000AC890014AF4800300000000094860018FF
63014+:104F10009487001C00C71821A48300189485001AE8
63015+:104F200024A20001A482001A9498001A9499001EE9
63016+:104F3000133800030000000003E000080000000038
63017+:104F400003E00008A480001A8C8200200A0000DC24
63018+:104F50003C0D00500A0000CD000000003C0308009A
63019+:104F60008C6300208F82001827BDFFE810620008C4
63020+:104F7000AFBF00100E000104AF8300183C0308000F
63021+:104F80008C63002024040001106400048F89001049
63022+:104F90008FBF001003E0000827BD00188FBF00106E
63023+:104FA0003C076012A520000A9528000A34E500108D
63024+:104FB00027BD00183106FFFF03E00008ACA60090F3
63025+:104FC0003C0208008C42002027BDFFC8AFBF003460
63026+:104FD000AFBE0030AFB7002CAFB60028AFB500248D
63027+:104FE000AFB40020AFB3001CAFB20018AFB10014D3
63028+:104FF00010400050AFB000108F840010948600065F
63029+:105000009483000A00C3282330B6FFFF12C0004A71
63030+:105010008FBF003494890018948A000A012A402323
63031+:105020003102FFFF02C2382B14E0000202C020212F
63032+:10503000004020212C8C0005158000020080A0215A
63033+:10504000241400040E0000B3028020218F8700107A
63034+:1050500002809821AF80001494ED000A028088211C
63035+:105060001280004E31B2FFFF3C1770003C1540002B
63036+:105070003C1E60008F8F001C8DEE000001D71824AD
63037+:10508000507500500220202102A3802B160000350D
63038+:105090003C182000507800470220202124100001F5
63039+:1050A0008F83001414600039029158230230F823D2
63040+:1050B0000250C82133F1FFFF1620FFEE3332FFFF0D
63041+:1050C0008F8700103C110020AF510030000000001D
63042+:1050D00094E6000A3C1E601237D5001002662821B3
63043+:1050E000A4E5000A94E2000A94F2000A94F400187D
63044+:1050F0003057FFFF1292003BAEB700908CED0014CA
63045+:105100008CE400100013714001AE4021000E5FC31B
63046+:10511000010E502B008B4821012A1821ACE8001405
63047+:10512000ACE3001002D3382330F6FFFF16C0FFB9FE
63048+:105130008F8400108FBF00348FBE00308FB7002CDB
63049+:105140008FB600288FB500248FB400208FB3001CC9
63050+:105150008FB200188FB100148FB0001003E0000868
63051+:1051600027BD0038107E001B000000001477FFCC24
63052+:10517000241000010E00159B000000008F83001416
63053+:105180001060FFCB0230F823029158238F87001064
63054+:10519000017020210A0001973093FFFF8F830014D4
63055+:1051A0001460FFCB3C110020AF5100300A000163B6
63056+:1051B000000000000E00077D024028210A00015770
63057+:1051C000004080210E00033A024028210A000157C6
63058+:1051D000004080210E001463022020210A000157A4
63059+:1051E000004080210E0000CD000000000A0001797F
63060+:1051F00002D3382327BDFFE8AFB00010AFBF0014C3
63061+:105200000E00003F000000003C028000345000709F
63062+:105210000A0001BA8E0600008F4F000039EE00012F
63063+:1052200031C20001104000248F8600A88E070000C4
63064+:105230003C0C08008D8C003C3C0908008D2900388E
63065+:1052400000E66823018D28210000502100AD302B9D
63066+:10525000012A4021010620213C010800AC25003C28
63067+:10526000AF8700A83C010800AC2400380E000106FE
63068+:10527000000000003C0308008C6300701060FFE633
63069+:10528000006020213C0508008CA500683C06080051
63070+:105290008CC6006C0E00152A000000003C010800BE
63071+:1052A000AC2000708F4F000039EE000131C20001C8
63072+:1052B0001440FFDE8F8600A88E0A00008F8B00A8A6
63073+:1052C0003C0508008CA5003C3C0408008C84003898
63074+:1052D000014B482300A938210082182100E9402B06
63075+:1052E000006810213C010800AC27003C3C0108008C
63076+:1052F000AC2200388F5F01002419FF0024180C0035
63077+:1053000003F9202410980012AF840000AF4400205D
63078+:10531000936D0000240C002031A600FF10CC001279
63079+:10532000240E005010CE00043C194000AF59013843
63080+:105330000A0001B3000000000E0011C800000000C8
63081+:105340003C194000AF5901380A0001B300000000C9
63082+:105350000E00011F000000003C194000AF59013849
63083+:105360000A0001B3000000008F58010000802821CE
63084+:10537000330F00FF01E020210E0002F1AF8F000487
63085+:105380003C194000AF5901380A0001B30000000089
63086+:1053900000A4102B2403000110400009000030215C
63087+:1053A0000005284000A4102B04A0000300031840AF
63088+:1053B0005440FFFC000528405060000A0004182BF0
63089+:1053C0000085382B54E000040003184200C3302548
63090+:1053D00000852023000318421460FFF900052842CD
63091+:1053E0000004182B03E0000800C310218F4201B80D
63092+:1053F0000440FFFE00000000AF4401803C031000A9
63093+:1054000024040040AF450184A3440188A3460189D8
63094+:10541000A747018A03E00008AF4301B83084FFFFCB
63095+:105420000080382130A5FFFF000020210A00022A59
63096+:10543000240600803087FFFF8CA40000240600387B
63097+:105440000A00022A000028218F8300388F8600304E
63098+:105450001066000B008040213C07080024E75A1822
63099+:10546000000328C000A710218C4400002463000121
63100+:10547000108800053063000F5466FFFA000328C04F
63101+:1054800003E00008000010213C07080024E75A1C34
63102+:1054900000A7302103E000088CC200003C0390000C
63103+:1054A0003462000100822025AF4400208F45002097
63104+:1054B00004A0FFFE0000000003E000080000000060
63105+:1054C0003C038000346200010082202503E00008D4
63106+:1054D000AF44002027BDFFE0AFB100143091FFFFC3
63107+:1054E000AFB00010AFBF00181220001300A0802141
63108+:1054F0008CA2000024040002240601401040000F8A
63109+:10550000004028210E000C5C00000000000010216B
63110+:10551000AE000000022038218FBF00188FB10014A8
63111+:105520008FB0001000402021000028210000302111
63112+:105530000A00022A27BD00208CA200000220382188
63113+:105540008FBF00188FB100148FB0001000402021D1
63114+:1055500000002821000030210A00022A27BD002077
63115+:1055600000A010213087FFFF8CA500048C440000B0
63116+:105570000A00022A2406000627BDFFE0AFB0001093
63117+:10558000AFBF0018AFB100149363003E00808021CC
63118+:105590000080282130620040000020211040000FD0
63119+:1055A0008E1100000E000851022020219367000098
63120+:1055B0002404005030E500FF50A400128E0F0000BC
63121+:1055C000022020218FBF00188FB100148FB000106F
63122+:1055D000A762013C0A00091127BD00200E000287C6
63123+:1055E000000000000E0008510220202193670000F7
63124+:1055F0002404005030E500FF14A4FFF20220202113
63125+:105600008E0F00003C1008008E1000503C0D000C66
63126+:10561000240BFF8001F05021314E007F01DA602120
63127+:10562000018D4021014B4824AF4900280220202150
63128+:105630008FBF00188FB100148FB00010A50200D6E4
63129+:1056400027BD00200A000911AF8800D027BDFFE068
63130+:10565000AFBF0018AFB10014AFB0001093660001E7
63131+:10566000008080210E00025630D1000493640005B2
63132+:10567000001029C2A765000034830040A363000521
63133+:105680000E00025F020020210E00091302002021FB
63134+:1056900024020001AF62000C02002821A762001062
63135+:1056A00024040002A762001224060140A76200142D
63136+:1056B0000E000C5CA76200161620000F8FBF0018AA
63137+:1056C000978C00343C0B08008D6B00782588FFFF19
63138+:1056D0003109FFFF256A0001012A382B10E000067E
63139+:1056E000A78800343C0F6006240E001635ED00102C
63140+:1056F000ADAE00508FBF00188FB100148FB00010F6
63141+:1057000003E0000827BD002027BDFFE0AFB1001473
63142+:10571000AFBF0018AFB0001000A088211080000AB1
63143+:105720003C03600024020080108200120000000090
63144+:105730000000000D8FBF00188FB100148FB0001053
63145+:1057400003E0000827BD00208C682BF80500FFFE51
63146+:1057500000000000AC712BC08FBF00188FB1001487
63147+:105760008FB000103C09100027BD002003E00008A6
63148+:10577000AC692BF80E00025600A0202193650005AD
63149+:10578000022020210E00025F30B000FF2403003E03
63150+:105790001603FFE7000000008F4401780480FFFE3D
63151+:1057A000240700073C061000AF51014002202021D1
63152+:1057B000A34701448FBF00188FB100148FB00010B1
63153+:1057C000AF4601780A0002C227BD002027BDFFE8CE
63154+:1057D000AFBF0014AFB000108F50002000000000D9
63155+:1057E0000E000913AF440020AF5000208FBF0014FB
63156+:1057F0008FB0001003E0000827BD00183084FFFFC1
63157+:10580000008038212406003500A020210A00022A49
63158+:10581000000028213084FFFF008038212406003654
63159+:1058200000A020210A00022A0000282127BDFFD065
63160+:10583000AFB3001C3093FFFFAFB50024AFB2001828
63161+:10584000AFBF0028AFB40020AFB10014AFB000105C
63162+:1058500030B5FFFF12600027000090218F90001CE0
63163+:105860008E0300003C0680002402004000033E023C
63164+:1058700000032C0230E4007F006688241482001D9F
63165+:1058800030A500FF8F8300282C68000A510000100B
63166+:105890008F910014000358803C0C0800258C56940E
63167+:1058A000016C50218D49000001200008000000001B
63168+:1058B00002B210213045FFFF0E000236240400849E
63169+:1058C000162000028F90001CAF8000288F910014DA
63170+:1058D000260C002026430001018080213072FFFF4A
63171+:1058E00016200004AF8C001C0253502B1540FFDC27
63172+:1058F00000000000024010218FBF00288FB5002457
63173+:105900008FB400208FB3001C8FB200188FB1001429
63174+:105910008FB0001003E0000827BD0030240E0034D3
63175+:1059200014AE00F9000000009203000E241F168040
63176+:105930003C07000CA36300219202000D0347C8211D
63177+:105940003C066000A3620020961100123C0A7FFF13
63178+:10595000354CFFFFA771003C960B00102403000597
63179+:105960003168FFFFAF6800848E05001CAF5F002820
63180+:105970008F3800008CC4444803057826008F3021FE
63181+:10598000AF66004C8F69004C24CE00013C057F00BF
63182+:10599000AF6900508F740050AF740054AF66007050
63183+:1059A000AF6E00588F6D005824140050AF6D005C2E
63184+:1059B000A3600023AF6C0064A36300378E02001461
63185+:1059C000AF6200488F710048AF7100248E0B001841
63186+:1059D000AF6B006C9208000CA3680036937F003E0A
63187+:1059E00037F90020A379003E8F78007403058024E6
63188+:1059F000360F4000AF6F007493640000308900FFE1
63189+:105A0000513402452404FF803C04080024845A9841
63190+:105A10000E00028D000000003C1008008E105A9805
63191+:105A20000E00025602002021240600042407000173
63192+:105A3000A366007D020020210E00025FA36700051F
63193+:105A40008F5F017807E0FFFE240B0002AF5001409A
63194+:105A5000A34B01448F90001C3C081000AF48017814
63195+:105A60000A000362AF8000282CAD003751A0FF98D8
63196+:105A70008F9100140005A0803C180800271856BC20
63197+:105A8000029878218DEE000001C00008000000009F
63198+:105A90002418000614B80011000000003C0808009B
63199+:105AA0008D085A9824040005AF4800208E1F001866
63200+:105AB000AF7F00188F79004CAF79001C8F650050C4
63201+:105AC000122000C0AF6500700A000362AF84002896
63202+:105AD0002406000710A60083240300063C050800E6
63203+:105AE00024A55A980E000264240400818F90001CA3
63204+:105AF0000011102B0A000362AF8200282407000463
63205+:105B000014A7FFF6240500503C1808008F185A9877
63206+:105B1000AF5800208E0F0008AF6F00408E090008BC
63207+:105B2000AF6900448E14000CAF7400488E0E001054
63208+:105B3000AF6E004C8E0D0010AF6D00848E0A001405
63209+:105B4000AF6A00508E0C0018AF6C00548E04001C1D
63210+:105B5000AF64005893630000306B00FF116501D8FB
63211+:105B6000000000008F7400488F6900400289702394
63212+:105B700005C000042404008C1620FFDE240200036C
63213+:105B8000240400823C05080024A55A980E000287D0
63214+:105B9000000000008F90001C000010210A0003622A
63215+:105BA000AF820028240F000514AFFFCC240520008D
63216+:105BB0003C0708008CE75A98AF4700208E06000487
63217+:105BC000AF66005C9208000824100008A36800215A
63218+:105BD0008F9F001C93F90009A37900208F86001C79
63219+:105BE00090D8000A330400FF10900011000000005C
63220+:105BF0002885000914A0006924020002240A00205C
63221+:105C0000108A000B34058000288D002115A00008A3
63222+:105C100024054000240E0040108E00053C050001C4
63223+:105C200024140080109400023C050002240540006A
63224+:105C30008F7800743C19FF00031980240205782531
63225+:105C4000AF6F007490C4000BA36400818F84001CAC
63226+:105C50009489000C11200192000000009490000C27
63227+:105C60002406FFBF24050004A770003C908F000E9F
63228+:105C7000A36F003E8F84001C9089000FA369003F32
63229+:105C80008F8B001C8D6E00108F54007401D468231C
63230+:105C9000AF6D00608D6A0014AF6A0064956C0018E7
63231+:105CA000A76C00689563001AA763006A8D62001CE8
63232+:105CB000AF62006C9167000EA367003E9368003EE0
63233+:105CC0000106F8241220014BA37F003E8F90001C98
63234+:105CD0000A000362AF8500282407002214A7FF7F73
63235+:105CE000240300073C0B08008D6B5A981220000C0F
63236+:105CF000AF4B00200A000362AF830028240C00335E
63237+:105D000010AC0014240A00283C05080024A55A9869
63238+:105D10000E00023C240400810A0003EB8F90001C5B
63239+:105D20003C04080024845A980E00028D00000000F4
63240+:105D30009363000024110050306200FF10510135C0
63241+:105D4000000000008F90001C000018210A00036270
63242+:105D5000AF8300283C0D08008DAD5A9824040081C3
63243+:105D6000AF4D00203C05080024A55A980E00023CC7
63244+:105D7000A36A00348F90001C240200090A00036209
63245+:105D8000AF82002802B288213225FFFF0E000236C2
63246+:105D9000240400840A0003628F90001C1082FFA478
63247+:105DA00024050400288B000311600170240C0004FA
63248+:105DB000240300015483FF9E240540000A00043B95
63249+:105DC000240501003C04080024845A988F62004C8A
63250+:105DD0000E00028D8F6300508F90001C0000202168
63251+:105DE0000A000362AF8400288E1000042404008A95
63252+:105DF000AF50002093790005333800021700015F8F
63253+:105E0000020028219368002302002821311F00206E
63254+:105E100017E0015A2404008D9367003F2406001206
63255+:105E200030E200FF10460155240400810E000256A6
63256+:105E30000200202193630023240500040200202196
63257+:105E4000346B0042A36B00230E00025FA365007D4C
63258+:105E50008F4401780480FFFE240A0002AF50014005
63259+:105E6000A34A01448F90001C3C0C1000AF4C0178F9
63260+:105E70000A0003EC0011102B8E1000042404008A89
63261+:105E8000AF500020936E000531CD000215A0001622
63262+:105E900002002821936F003F2414000402002821EF
63263+:105EA00031E900FF11340010240400810E00025675
63264+:105EB000020020219362002324080012241FFFFE09
63265+:105EC00034460020A3660023A368003F93790005B1
63266+:105ED00002002021033FC0240E00025FA3780005CA
63267+:105EE00002002821000020210E00033400000000E1
63268+:105EF0000A0003EB8F90001C8E1000043C03000886
63269+:105F00000343A021AF500020928B000024050050D5
63270+:105F1000316400FF10850161240700880200202100
63271+:105F2000000028210E00022A2406000E928D000097
63272+:105F3000240EFF800200282101AE8025A2900000DF
63273+:105F4000240400040E000C5C240600300A0003EB5D
63274+:105F50008F90001C8E0800043C14080026945A9868
63275+:105F60003C010800AC285A98AF480020921F00035B
63276+:105F700033F9000413200002240200122402000658
63277+:105F8000A362003F920B001B2404FFC03165003F59
63278+:105F900000A43825A367003E9206000330C200012A
63279+:105FA00014400132000000008E020008AE8200089A
63280+:105FB0003C0208008C425AA010400131000249C244
63281+:105FC000A76900088E14000C240C0001240300149F
63282+:105FD000AF74002C8E0E0010AF6E0030960D0016C0
63283+:105FE000A76D0038960A0014A76A003AAF6C000C3F
63284+:105FF000A76C0010A76C0012A76C0014A76C001609
63285+:1060000012200136A3630034920F000331F0000226
63286+:106010002E1100018F90001C262200080A00036246
63287+:10602000AF8200288E0400043C0E0008034E30218D
63288+:10603000AF4400208E05000890CD0000240C0050D5
63289+:1060400031AA00FF114C00862407008824060009AD
63290+:106050000E00022A000000000A0003EB8F90001CD3
63291+:106060008E04001C0E00024100000000104000F4ED
63292+:10607000004050218F89001C240700890140202105
63293+:106080008D25001C240600010E00022A00000000DD
63294+:106090000A0003EB8F90001C960D00023C140800D0
63295+:1060A00026945A9831AA0004514000B83C10600070
63296+:1060B0008E0E001C3C010800AC2E5A98AF4E0020FA
63297+:1060C000920700102408001430E200FF144800D6A4
63298+:1060D00000000000960B00023163000114600165AE
63299+:1060E000000000008E020004AE8200083C1408008C
63300+:1060F0008E945AA01280015B000000008F7400741F
63301+:106100003C0380002404000102835825AF6B007417
63302+:10611000A3600005AF64000C3C0708008CE75AA0A0
63303+:106120008F86001CA7640010000711C2A76400122C
63304+:10613000A7640014A7640016A76200088CC80008B2
63305+:1061400024040002AF68002C8CC5000CAF65003041
63306+:1061500090DF0010A37F00348F99001C9330001152
63307+:10616000A37000358F98001C930F0012A36F0036A8
63308+:106170008F89001C912E0013A36E00378F90001C96
63309+:10618000960D0014A76D0038960A0016A76A003A0B
63310+:106190008E0C0018AF6C00245620FDCCAF84002874
63311+:1061A0003C05080024A55A980E0002640000202136
63312+:1061B0008F90001C0A0004A7000020218E1000040C
63313+:1061C00024070081AF500020936900233134001070
63314+:1061D000128000170000000002002021000028218A
63315+:1061E0002406001F0E00022A000000000A0003EB34
63316+:1061F0008F90001C3C05080024A55A980E000287C9
63317+:10620000240400828F90001C000028210A000362F1
63318+:10621000AF8500283C0408008C845A980E0014E8CE
63319+:10622000000000008F90001C0A000482000018216A
63320+:106230000E00025602002021937800230200202144
63321+:10624000370F00100E00025FA36F002300003821FB
63322+:1062500002002021000028210A0005A82406001FB2
63323+:10626000920F000C31E90001112000030000000032
63324+:106270009618000EA4D8002C921F000C33F90002CF
63325+:1062800013200005000038218E0200149608001229
63326+:10629000ACC2001CA4C8001A0A0005432406000969
63327+:1062A0003C05080024A55A980E0002872404008BA0
63328+:1062B0008F90001C0011282B0A000362AF85002874
63329+:1062C000AF6000843C0A08008D4A5A983C0D0800D3
63330+:1062D0008DAD0050240CFF803C02000C014D1821B4
63331+:1062E000006C2024AF4400288E070014306B007F20
63332+:1062F000017A282100A2C821AF2700D88E060014F9
63333+:10630000AF9900D0AF2600DC8E080010251FFFFEDD
63334+:106310000A000408AF3F01083C0508008CA55A9804
63335+:106320003C1908008F39005024CCFFFE00B9C02171
63336+:1063300003047824AF4F00283C1408008E945A9828
63337+:106340003C0908008D2900500289702131CD007F61
63338+:1063500001BA502101478021AE0600D8AF9000D08D
63339+:10636000AE0000DC0A0003B1AE0C0108548CFE3014
63340+:10637000240540000A00043B240510000E00032EF3
63341+:10638000000000000A0003EB8F90001C8E0F442CCD
63342+:106390003C186C62370979703C010800AC205A98AF
63343+:1063A00015E9000824050140979F00349786002CCA
63344+:1063B0000280282103E6C82B132000112404009238
63345+:1063C000240501400E000C7A240400023C01080060
63346+:1063D000AC225A98AF4200203C0508008CA55A9880
63347+:1063E00010A00005240400830E00084500000000F2
63348+:1063F00010400009240400833C05080024A55A9895
63349+:106400000E000264000000008F90001C0011202B81
63350+:106410000A000362AF8400280E0008490000000053
63351+:106420000A00055F8F90001C0E00084D0000000060
63352+:106430003C05080024A55A980A00062F2404008B66
63353+:10644000240400040E000C7A240500301440002AB5
63354+:10645000004050218F89001C240700830140202127
63355+:106460008D25001C0A000551240600018E04000839
63356+:106470000E000241000000000A00051BAE82000869
63357+:106480003C05080024A55A980E00023C240400870D
63358+:106490008F90001C0A0005360011102B8F830038E6
63359+:1064A0008F8600301066FE9D000038213C070800F2
63360+:1064B00024E75A1C000320C0008728218CAC000070
63361+:1064C00011900061246A00013143000F5466FFFA05
63362+:1064D000000320C00A0004F6000038213C05080033
63363+:1064E00024A55A980E000287240400828F90001C75
63364+:1064F0000A000536000010213C0B0008034B202148
63365+:106500002403005024070001AF420020A0830000B4
63366+:10651000A08700018F82001C90480004A08800180A
63367+:106520008F85001C90A60005A08600198F9F001C77
63368+:1065300093F90006A099001A8F90001C921800078A
63369+:10654000A098001B8F94001C928F0008A08F001C45
63370+:106550008F89001C912E0009A08E001D8F8D001CBC
63371+:1065600091AC000AA08C001E8F8B001C3C0C080014
63372+:10657000258C5A1C9163000B3C0B0800256B5A18A4
63373+:10658000A083001F8F87001C90E8000CA0880020CB
63374+:106590008F82001C9045000D24024646A0850021F4
63375+:1065A0008F86001C90DF000EA09F00228F99001C98
63376+:1065B0009330000FA09000238F98001C93140010BC
63377+:1065C000A09400248F8F001C91E90011A089002560
63378+:1065D0008F89001C8F8E00308F900038952D00140D
63379+:1065E000000E18C025C80001A48D002895270016AC
63380+:1065F000006C3021006BC821A487002A9525001863
63381+:106600003108000FA485002CA482002E8D3F001CB1
63382+:10661000ACCA0000AF88003011100006AF3F000088
63383+:10662000000038218D25001C014020210A00055161
63384+:1066300024060001250C00013184000F00003821E0
63385+:106640000A0006B8AF8400383C07080024E75A184F
63386+:106650000087302100003821ACA000000A0004F6B9
63387+:10666000ACC000003C05080024A55A980A00062F7B
63388+:10667000240400878E0400040E0002410000000084
63389+:106680000A00056AAE8200083084FFFF30C600FFB2
63390+:106690008F4201B80440FFFE00064400010430258B
63391+:1066A0003C07200000C720253C031000AF400180BC
63392+:1066B000AF450184AF44018803E00008AF4301B84F
63393+:1066C00027BDFFE8AFB00010AFBF00143C0760006B
63394+:1066D000240600021080000600A080210010102B6C
63395+:1066E0008FBF00148FB0001003E0000827BD001812
63396+:1066F0003C09600EAD2000348CE5201C8F82001C0C
63397+:106700002408FFFC00A81824ACE3201C0E0006D1CE
63398+:106710008C45000C0010102B8FBF00148FB00010A0
63399+:1067200003E0000827BD00183C02600E344701005A
63400+:1067300024090018274A040000000000000000009F
63401+:10674000000000003C06005034C30200AF44003893
63402+:10675000AF45003CAF430030014018218F4B000093
63403+:10676000316800201100FFFD2406007F2408FFFF90
63404+:106770008C6C000024C6FFFF24630004ACEC000016
63405+:1067800014C8FFFB24E70004000000000000000024
63406+:10679000000000003C0F0020AF4F00300000000060
63407+:1067A00024AD020001A5702B2529FFFF008E2021BA
63408+:1067B0001520FFE101A0282103E0000800000000EF
63409+:1067C00027BDFFE0AFB10014AFBF0018AFB000109D
63410+:1067D0003C05600E8CA20034008088211440000625
63411+:1067E0003C0460008C87201C2408FFFC00E8302457
63412+:1067F00034C30001AC83201C8F8B001C24090001D2
63413+:10680000ACA90034956900028D6500148D70000CF0
63414+:106810002D2400818D6700048D660008108000071C
63415+:106820008D6A00102D2C00041580000E30CE00075C
63416+:10683000312D000311A0000B000000002404008B88
63417+:10684000020028210E0006D1240600030011102B9F
63418+:106850008FBF00188FB100148FB0001003E0000844
63419+:1068600027BD002015C0FFF62404008B3C03002048
63420+:10687000AF4300300000000024020001AF8200148A
63421+:106880000000000000000000000000003C1F01505C
63422+:10689000013FC825253800033C0F600EAF47003884
63423+:1068A00000181882AF46003C35E8003CAF59003074
63424+:1068B000274704008F4400003086002010C0FFFDF1
63425+:1068C00000000000106000082466FFFF2403FFFFA3
63426+:1068D0008CEB000024C6FFFF24E70004AD0B000092
63427+:1068E00014C3FFFB250800043C08600EAD09003806
63428+:1068F0000000000000000000000000003C07002035
63429+:10690000AF470030000000000E0006F901402021D2
63430+:1069100002002821000020210E0006D124060003D9
63431+:106920000011102B8FBF00188FB100148FB0001012
63432+:1069300003E0000827BD002027BDFFE0AFB200182C
63433+:106940003092FFFFAFB10014AFBF001CAFB000101A
63434+:106950001640000D000088210A0007AA022010211D
63435+:1069600024050001508500278CE5000C0000000D77
63436+:10697000262300013071FFFF24E200200232382B71
63437+:1069800010E00019AF82001C8F8200141440001622
63438+:106990008F87001C3C0670003C0320008CE5000043
63439+:1069A00000A62024148300108F84003C00054402BC
63440+:1069B0003C09800000A980241480FFE9310600FF13
63441+:1069C0002CCA00095140FFEB262300010006688015
63442+:1069D0003C0E080025CE579801AE60218D8B00003B
63443+:1069E0000160000800000000022010218FBF001C81
63444+:1069F0008FB200188FB100148FB0001003E00008B0
63445+:106A000027BD00200E0006D1240400841600FFD804
63446+:106A10008F87001C0A00078BAF80003C90EF0002BC
63447+:106A200000002021240600090E0006D1000F2E00D0
63448+:106A30008F87001C0010102B0A00078BAF82003CD0
63449+:106A4000020028210E0006DF240400018F87001CAD
63450+:106A50000A00078BAF82003C020028210E0006DFEF
63451+:106A6000000020210A0007C38F87001C0E00071FAB
63452+:106A7000020020210A0007C38F87001C30B0FFFFEF
63453+:106A8000001019C08F5801B80700FFFE3C1F2004FA
63454+:106A90003C191000AF430180AF400184AF5F018813
63455+:106AA000AF5901B80A00078C262300013082FFFF8E
63456+:106AB00014400003000018210004240224030010E5
63457+:106AC000308500FF14A000053087000F2466000801
63458+:106AD0000004220230C300FF3087000F14E00005DD
63459+:106AE000308900032468000400042102310300FF00
63460+:106AF0003089000315200005388B0001246A00024C
63461+:106B000000042082314300FF388B00013164000112
63462+:106B100010800002246C0001318300FF03E00008B4
63463+:106B200000601021308BFFFF000B394230E600FF80
63464+:106B30003C09080025295998000640800109602178
63465+:106B40008D8700003164001F240A0001008A1804A8
63466+:106B500030A500FF00E3202514A000020003102749
63467+:106B600000E22024240F000100CF700401096821F5
63468+:106B7000000E282714800005ADA400008F86000CAD
63469+:106B800000A6102403E00008AF82000C8F88000CE0
63470+:106B900001C8102503E00008AF82000C3C06001F6E
63471+:106BA0003C0360003084FFFF34C5FF8024020020D6
63472+:106BB000AC602008AC60200CAC602010AC652014E8
63473+:106BC000AC642018AC62200000000000000000004F
63474+:106BD00003E000080000000027BDFFE82402FFFFDB
63475+:106BE000AFBF0010AF82000C000020213C0608005F
63476+:106BF00024C659982405FFFF248900010004408021
63477+:106C00003124FFFF010618212C87002014E0FFFA31
63478+:106C1000AC6500000E0008160000202124020001CF
63479+:106C20003C04600024050020AC822018AC852000C4
63480+:106C3000000000000000000000000000244A0001E5
63481+:106C40003142FFFF2C46040014C0FFF78FBF001035
63482+:106C500003E0000827BD00188F8300082C620400A1
63483+:106C600003E00008384200018F830008246200011D
63484+:106C700003E00008AF8200088F8300082462FFFF52
63485+:106C800003E00008AF82000827BDFFE0AFB10014A9
63486+:106C9000AFBF0018AFB000108F6B00303C06600033
63487+:106CA00000808821ACCB20088F6A002C3C02800039
63488+:106CB00024030008ACCA200C9769003A9768003892
63489+:106CC00000092C003107FFFF00A72025ACC42010CD
63490+:106CD000ACC22014ACC32000000000000000000083
63491+:106CE000000000003C0360008C6D200031AC000807
63492+:106CF0001580FFF9000000008C6E201405C00020F4
63493+:106D0000000000000E0007DA8F84000C00024080B3
63494+:106D10003C09080025295998010938218CE4000014
63495+:106D20000E0007DA00028140020220213090FFFFAE
63496+:106D3000020020210E0007F8000028213C0C8000F2
63497+:106D4000022C58253210FFFF3C116000240A00205D
63498+:106D5000AE2B2014AE302018AE2A20000000000018
63499+:106D60000000000000000000020010218FBF00188A
63500+:106D70008FB100148FB0001003E0000827BD002081
63501+:106D80008C6620143C02001F3443FF803C1FFFE848
63502+:106D900000C3C02437F9080003198021001079C20C
63503+:106DA0003C0C8000022C582531F0FFFF3C116000A4
63504+:106DB000240A0020AE2B2014AE302018AE2A20006A
63505+:106DC0000000000000000000000000000200102190
63506+:106DD0008FBF00188FB100148FB0001003E00008BF
63507+:106DE00027BD002027BDFFE8AFB000103402FFFF31
63508+:106DF0003090FFFFAFBF00141202000602002021F6
63509+:106E00000E00081600000000020020210E0007F806
63510+:106E1000240500018F8400088FBF00148FB000107C
63511+:106E20002483FFFF27BD001803E00008AF8300089C
63512+:106E3000000439C230E6003F00043B42000718401E
63513+:106E4000240210002CC4002024C8FFE0AF42002C14
63514+:106E5000246300011480000330A900FF00071840DC
63515+:106E6000310600FF0003608024080001019A5821C8
63516+:106E70003C0A000E00C82804016A382111200005D0
63517+:106E8000000530278CE900000125302503E00008CB
63518+:106E9000ACE600008CEE000001C6682403E00008A8
63519+:106EA000ACED000027BDFFE8AFBF0014AFB000108D
63520+:106EB0003C0460008C8508083403F00030A2F00028
63521+:106EC00050430006240200018C8708083404E000C7
63522+:106ED00030E6F00010C4001E24020002AF82004021
63523+:106EE0003C1060003C0A0200AE0A0814240910009D
63524+:106EF0003C08000E8E03440003482021AF49002CBB
63525+:106F0000240501200E000CC0000030218F830040BA
63526+:106F1000106000043C021691240B0001106B000E5F
63527+:106F20003C023D2C344F0090AE0F44088FBF00143C
63528+:106F30008FB000103C0C6000240E10003C0D0200CD
63529+:106F400027BD0018AD8E442003E00008AD8D081069
63530+:106F50000A0008E7AF8000403C0218DA344F009086
63531+:106F6000AE0F44088FBF00148FB000103C0C6000BF
63532+:106F7000240E10003C0D020027BD0018AD8E4420E9
63533+:106F800003E00008AD8D08100A0008BB24050001CD
63534+:106F90000A0008BB000028213C08080025085DA461
63535+:106FA0002404FFFF010018212402001E2442FFFFD9
63536+:106FB000AC6400000441FFFD246300043C070800AA
63537+:106FC00024E75E208CE5FFFC2404001C240600015D
63538+:106FD000308A001F0146480424840001000910275C
63539+:106FE0002C8300201460FFFA00A22824ACE5FFFCEB
63540+:106FF0003C05666634A4616E3C06080024C65EE06B
63541+:10700000AF840058AF88009C2404FFFF00C0182103
63542+:107010002402001F2442FFFFAC6400000441FFFD76
63543+:10702000246300043C0766663C05080024A55EA0B6
63544+:10703000AF86004834E6616EAF8600982404FFFFF7
63545+:1070400000A018212402000F2442FFFFAC640000BE
63546+:107050000441FFFD246300043C0B66663C06080007
63547+:1070600024C65E203568616EAF8500A4AF880070CD
63548+:107070002404FFFF00C018212402001F2442FFFF48
63549+:10708000AC6400000441FFFD246300043C0D66660F
63550+:107090003C0A0800254A5F6035AC616EAF860090FF
63551+:1070A000AF8C005C2404FFFF014018212402000380
63552+:1070B0002442FFFFAC6400000441FFFD2463000490
63553+:1070C0003C09080025295F708D27FFFC2404000679
63554+:1070D000240500013099001F0325C0042484000109
63555+:1070E000001878272C8E002015C0FFFA00EF3824F6
63556+:1070F000AD27FFFC3C09666624030400240403DC7E
63557+:1071000024050200240600663522616E3C08080052
63558+:1071100025085AA4AF820074AF830044AF83006C8B
63559+:10712000AF830050AF830084AF8A008CAF840064CB
63560+:10713000AF85004CAF860054AF840078AF85006007
63561+:10714000AF86008001001821240200022442FFFFC4
63562+:10715000AC6000000441FFFD24630004240400032C
63563+:107160002403000C3C0A0800254A5AB0AF8A006884
63564+:107170000A00098E2405FFFF000418802484000102
63565+:10718000006858212C8700C014E0FFFBAD650000AB
63566+:107190003C0E666635CD616E240C17A024081800DD
63567+:1071A000AF8D0088AF8C009403E00008AF88007CAE
63568+:1071B0002484007F000421C200004021000030210F
63569+:1071C00000003821000028210A0009A5AF8400A092
63570+:1071D0001060000624E7000100C4302124A500014E
63571+:1071E0002CC20BF51440FFFA2CA300663C090800E2
63572+:1071F00025295F6001201821240200032442FFFF9B
63573+:10720000AC6000000441FFFD2463000410E0001A9C
63574+:1072100024E3FFFF0003294210A0000A0000202100
63575+:107220002406FFFF3C03080024635F602484000100
63576+:107230000085502BAC660000250800011540FFFBBF
63577+:107240002463000430E2001F10400008000868803A
63578+:10725000240C0001004C38040008588001692821E2
63579+:1072600024E6FFFF03E00008ACA6000001A94021CE
63580+:107270002409FFFFAD09000003E000080000000042
63581+:10728000AF4400283C04000C034420210005288260
63582+:107290000A000CC000003021000421803C03600083
63583+:1072A000AC6410080000000000052980AC65100CDB
63584+:1072B0000000000003E000088C62100C27BDFFE80E
63585+:1072C0000080282124040038AFBF00140E0009D527
63586+:1072D000AFB0001024040E00AF4400283C10000C96
63587+:1072E00003502021240500100E000CC000003021A6
63588+:1072F00003501021AC400000AC40000424040038CE
63589+:107300008FBF00148FB0001024053FFF27BD001869
63590+:107310000A0009D58C430000000421803C03600072
63591+:10732000AC641008000000008C62100C03E0000840
63592+:107330000002118227BDFFC8AFB400208F940068FF
63593+:10734000AFBE0030AFB7002CAFB600280000B821A8
63594+:107350000080B021241E00C0AFBF0034AFB50024B0
63595+:10736000AFB3001CAFB20018AFB10014AFB0001043
63596+:107370000A000A12AFA5003C504000018F9400683B
63597+:1073800027DEFFFF13C00028269400048E92000021
63598+:107390003C03080024635DA01240FFF70283102B1A
63599+:1073A0003C04080024845AA4028410230002A8C0CC
63600+:1073B000000098210A000A212411000100118840D0
63601+:1073C000122000260000000002B380210251282470
63602+:1073D0000200202110A0FFF9267300010E0009DE33
63603+:1073E000000000000016684032EC000101AC2021D2
63604+:1073F0000E0009D5020028218F89009426F700018C
63605+:107400008FA6003C3AEB0001316A00012528FFFFFE
63606+:107410000011382702CAB021AF88009416E6FFE7B2
63607+:1074200002479024AE92000002E010218FBF00348A
63608+:107430008FBE00308FB7002C8FB600288FB5002488
63609+:107440008FB400208FB3001C8FB200188FB10014CE
63610+:107450008FB0001003E0000827BD00383C0E080084
63611+:1074600025CE5DA0028E102B0A000A0DAE92000000
63612+:1074700027BDFFD8AFB10014AFB00010AFBF0020E0
63613+:10748000AFB3001CAFB2001800A0882110A0001FED
63614+:10749000000480403C13080026735AA40A000A5ACC
63615+:1074A0002412000112200019261000010E0009F517
63616+:1074B00002002021000231422444FFA0000618806F
63617+:1074C0003045001F2C8217A1007318212631FFFFC1
63618+:1074D0001040FFF400B230048C690000020020214B
63619+:1074E00024053FFF012640241500FFEE0126382524
63620+:1074F0000E0009D5AC6700008F8A009426100001A9
63621+:10750000254700011620FFE9AF8700948FBF0020B8
63622+:107510008FB3001C8FB200188FB100148FB0001011
63623+:1075200003E0000827BD00288F85009C00805821BB
63624+:107530000000402100004821240A001F3C0C0800E4
63625+:10754000258C5E1C3C0D080025AD5DA48CA60000BA
63626+:1075500050C000140000402100AD1023000238C0CC
63627+:10756000240300010A000A930000202115000003F3
63628+:1075700000E410212448202400004821252900018E
63629+:10758000512B00132506DFDC106000062484000167
63630+:1075900000C3702415C0FFF5000318400A000A91CB
63631+:1075A0000000402110AC002624A300040060282124
63632+:1075B000254AFFFF1540FFE5AF85009C512B0004D5
63633+:1075C0002506DFDC0000402103E000080100102157
63634+:1075D0000006614230C5001F000C50803C070800C7
63635+:1075E00024E75DA424040001014730211120000F8D
63636+:1075F00000A420043C05080024A55E20148000059A
63637+:107600002529FFFF24C6000410C50011000000005A
63638+:10761000240400018CCF00000004C0270004204097
63639+:1076200001F868241520FFF5ACCD00008F99007893
63640+:1076300001001021032B482303E00008AF890078E4
63641+:107640003C05080024A55DA40A000A9B0000402117
63642+:107650003C06080024C65DA40A000AB42404000104
63643+:10766000308800FF240200021102000A24030003F4
63644+:107670001103005C8F8900A4240400041104005F3E
63645+:1076800024050005110500670000182103E000082B
63646+:10769000006010218F8900483C0C0800258C5EE0BA
63647+:1076A0003C04080024845F60240300201060000F65
63648+:1076B00000005821240D0002240E00033C0F080096
63649+:1076C00025EF5EE08D27000014E0000B30F9FFFF8E
63650+:1076D000252900040124C02B53000001018048210A
63651+:1076E0002463FFFF5460FFF88D270000016018211C
63652+:1076F00003E0000800601021132000323C0500FF69
63653+:1077000030E200FF004030211040004200005021D4
63654+:1077100024050001000020210005C84000A6C02467
63655+:1077200017000003332500FF14A0FFFB2484000191
63656+:10773000012CC023001828C000AA6021008C502111
63657+:107740003144001F240C0001008C18040003102792
63658+:1077500000E23024110D0041AD260000110E004C56
63659+:10776000000A1840110D00368F87006C510E00562C
63660+:107770008F8C0060240D0004110D005A8F8E008440
63661+:10778000240E0005150EFFDA01601821240B1430B9
63662+:1077900011400006000018218F8400A0246300011E
63663+:1077A000006A402B1500FFFD016458218F8A00807C
63664+:1077B000AF89008C016018212549FFFF0A000AEB00
63665+:1077C000AF89008000E52024000736021080FFD03A
63666+:1077D000240A001800075402314600FF0A000AF389
63667+:1077E000240A00103C0C0800258C5EA03C04080014
63668+:1077F00024845EE00A000ADA240300103C0C08002E
63669+:10780000258C5E203C04080024845EA00A000AD96E
63670+:107810008F89009000071A02306600FF0A000AF301
63671+:10782000240A00088F89008C3C0C0800258C5F60BE
63672+:107830003C04080024845F700A000ADA2403000470
63673+:10784000000A4080250B003024E6FFFF016018216C
63674+:10785000AF8900480A000AEBAF86006C000AC982B3
63675+:10786000001978803C07080024E75EA001E720218A
63676+:10787000000A18428C8F00003079001F032C380456
63677+:107880000007C02701F860240A000B08AC8C000038
63678+:10789000000331420006288000AF28213062001F1B
63679+:1078A0008CB8000024630001004CC804000321428E
63680+:1078B000001938270004108003073024004F2021CE
63681+:1078C0000A000B4CACA60000000A68C025AB0032D1
63682+:1078D000258AFFFF01601821AF8900A40A000AEB86
63683+:1078E000AF8A0060254B1030AF89009001601821ED
63684+:1078F00025C9FFFF0A000AEBAF8900843086000724
63685+:107900002CC2000610400014000000000006408059
63686+:107910003C030800246357BC010338218CE40000B9
63687+:1079200000800008000000002409000310A9000ED8
63688+:1079300000000000240A000510AA000B000000004F
63689+:10794000240B000110AB0008000000008F8C00A089
63690+:1079500010AC00050000000003E00008000010214A
63691+:107960000A000A7900A020210A000AC700C02021CD
63692+:1079700027BDFFE8308400FF240300021083000BC2
63693+:10798000AFBF0010240600031086003A240800044C
63694+:1079900010880068240E0005108E007F2CAF143074
63695+:1079A0008FBF001003E0000827BD00182CA2003094
63696+:1079B0001440FFFC8FBF001024A5FFD0000531C28A
63697+:1079C000000668803C07080024E75EE001A730213C
63698+:1079D0008CC900000005288230AC001F240B000178
63699+:1079E000018B50048F840048012A4025ACC8000058
63700+:1079F0008C83000050600001AF8600488F98006CB7
63701+:107A000030AE000124A6FFFF270F000115C00002C1
63702+:107A1000AF8F006C24A600010006414200082080C0
63703+:107A2000008718218C79000030C2001F2406000155
63704+:107A30000046F804033F382410E0FFDA8FBF00103F
63705+:107A40000005C182001870803C0F080025EF5EA081
63706+:107A500001CF48218D2B00000005684231A5001F91
63707+:107A600000A66004016C502527BD001803E0000843
63708+:107A7000AD2A00002CA7003014E0FFCA8FBF001011
63709+:107A800030B900071723FFC724A8FFCE00086A02F9
63710+:107A9000000D60803C0B0800256B5EA0018B30213F
63711+:107AA0008CC40000000828C230AA001F240800016E
63712+:107AB000014848048F8200A400891825ACC3000047
63713+:107AC0008C5F000053E00001AF8600A40005704009
63714+:107AD000000E7942000F28803C04080024845EE0F8
63715+:107AE00000A418218C6B000025DF000131CD001FA0
63716+:107AF000001F514201A86004016C4825000A108053
63717+:107B0000AC690000004428218CA600008F9800601A
63718+:107B100033F9001F8FBF00100328380400C77825F1
63719+:107B2000270E000127BD0018ACAF000003E00008DD
63720+:107B3000AF8E006024A5EFD02CB804001300FF998D
63721+:107B40008FBF001000053142000658803C0A080033
63722+:107B5000254A5E20016A30218CC4000030A3001F3A
63723+:107B600024090001006910048F9900900082F82513
63724+:107B7000ACDF00008F27000050E00001AF860090CE
63725+:107B80008F8D00848FBF001027BD001825AC000129
63726+:107B900003E00008AF8C008415E0FF828FBF001067
63727+:107BA0008F8600A0000610400046F821001F21002B
63728+:107BB00003E4C8210019384024F8143000B8402BE1
63729+:107BC0001100FF788FBF001024A4EBD00E00021329
63730+:107BD00000C0282100027942000F70803C0D08008F
63731+:107BE00025AD5F6001CD20218C8B0000304C001F43
63732+:107BF00024060001018618048F89008C016350253A
63733+:107C0000AC8A00008D25000050A00001AF84008CDC
63734+:107C10008F9800808FBF001027BD00182708000133
63735+:107C200003E00008AF88008030A5000724030003AC
63736+:107C300010A3001028A2000414400008240700022A
63737+:107C40002403000410A300152408000510A8000F49
63738+:107C50008F8500A003E000080000000014A7FFFDCE
63739+:107C60000080282114C3FFFB240400020A000B8BB0
63740+:107C700000000000240900050080282110C9FFFB36
63741+:107C80002404000303E000080000000014C5FFF115
63742+:107C9000008028210A000B8B24040005240A00011F
63743+:107CA0000080282110CAFFF12404000403E000082A
63744+:107CB0000000000027BDFFE0AFB00010000581C24A
63745+:107CC0002603FFD024C5003F2C6223D024C6007FAA
63746+:107CD000AFB20018AFB10014AFBF001C309100FF6D
63747+:107CE000000691C2000529820200202110400008F0
63748+:107CF0002403FFFF0E000A4B0000000002002021B9
63749+:107D0000022028210E000C390240302100001821E9
63750+:107D10008FBF001C8FB200188FB100148FB00010FD
63751+:107D20000060102103E0000827BD002027BDFFD818
63752+:107D300024A2007FAFB3001CAFB20018000299C2AA
63753+:107D4000309200FF24A3003F02402021026028213E
63754+:107D5000AFB10014AFB00010AFBF00200E000B6E2B
63755+:107D60000003898200408021004020210220282138
63756+:107D700014400009000018218FBF00208FB3001CA1
63757+:107D80008FB200188FB100148FB000100060102166
63758+:107D900003E0000827BD00280E0009FC00000000D9
63759+:107DA00000402821020020211051FFF3001019C0CB
63760+:107DB0000E000A4B00000000020020210240282192
63761+:107DC0000E000C39026030218FBF00208FB3001CE1
63762+:107DD0008FB200188FB100148FB00010000018216E
63763+:107DE0000060102103E0000827BD00283084FFFF59
63764+:107DF00030A5FFFF1080000700001821308200012D
63765+:107E00001040000200042042006518211480FFFB8E
63766+:107E10000005284003E000080060102110C00007A2
63767+:107E2000000000008CA2000024C6FFFF24A500046F
63768+:107E3000AC82000014C0FFFB2484000403E00008AF
63769+:107E40000000000010A0000824A3FFFFAC86000083
63770+:107E500000000000000000002402FFFF2463FFFF79
63771+:107E60001462FFFA2484000403E00008000000000C
63772+:107E700030A5FFFF8F4201B80440FFFE3C076015AC
63773+:107E800000A730253C031000AF440180AF400184BF
63774+:107E9000AF46018803E00008AF4301B88F8500D0EA
63775+:107EA0002C864000008018218CA700840087102BAE
63776+:107EB00014400010000000008CA800842D06400033
63777+:107EC00050C0000F240340008CAA0084008A482B75
63778+:107ED000512000018CA3008400035A42000B208033
63779+:107EE0003C05080024A558200085182103E000085F
63780+:107EF0008C62000014C0FFF4000000002403400066
63781+:107F000000035A42000B20803C05080024A558209D
63782+:107F10000085182103E000088C6200008F8300D0E8
63783+:107F2000906600D024C50001A06500D08F8500D0E8
63784+:107F3000906400D090A200D210440017000000000E
63785+:107F4000936C00788F8B00BC318A00FFA16A000C13
63786+:107F500025490001938700C4312200FF3048007F8B
63787+:107F60001107000B00026827A36200788F4E01788A
63788+:107F700005C0FFFE8F9900B0241800023C0F1000CE
63789+:107F8000AF590140A358014403E00008AF4F017806
63790+:107F90000A000D0931A20080A0A000D00A000CFF49
63791+:107FA000000000008F8700D027BDFFC8AFBF0030A2
63792+:107FB000AFB7002CAFB60028AFB50024AFB4002097
63793+:107FC000AFB3001CAFB20018AFB10014AFB00010D7
63794+:107FD00094E300E094E200E2104300D72405FFFFA1
63795+:107FE0003C047FFF3497FFFF2415FF800A000DF04B
63796+:107FF0003C16000E108A00D18FBF00308F9100B068
63797+:108000003C1808008F18005C001230C0001291402C
63798+:108010000311702101D57824AF4F002C94EC00E2BD
63799+:1080200031CD007F01BA5821318A7FFF0176482186
63800+:10803000000A804002091021945300003C08080007
63801+:108040008D0800580246C02132733FFF001319808B
63802+:10805000010320210224282130BF007F03FAC82118
63803+:1080600000B5A024AF54002C0336A0218E87001049
63804+:108070008E8F003003785821256D008800EF702323
63805+:10808000240C0002AE8E0010AF8D00ACA16C0088F5
63806+:10809000976A003C8E8400308F9100AC0E000CD6A5
63807+:1080A0003150FFFF00024B80020940253C02420094
63808+:1080B00001022025AE2400048E8300048F8D00ACC5
63809+:1080C0008E860000240E0008ADA3001CADA600188B
63810+:1080D000ADA0000CADA00010929F000A33F900FF84
63811+:1080E000A5B90014968500083C1F000CA5A5001634
63812+:1080F0009298000A331100FFA5B100209690000865
63813+:1081000024180005A5B00022ADA00024928F000B1A
63814+:108110002410C00031E700FFA5A70002A1AE0001B6
63815+:108120008E8C00308F8B00AC8F8400B0AD6C00085B
63816+:108130003C0A08008D4A005401444821013540247E
63817+:10814000AF4800283C0208008C4200540044302113
63818+:1081500030C3007F007AC821033F282102458821CF
63819+:10816000AF9100BCAF8500C0A23800008F8A00BC70
63820+:108170002403FFBF2418FFDF954F000201F03824CD
63821+:1081800000F37025A54E0002914D000231AC003F76
63822+:10819000358B0040A14B00028F8600BC8F8900D038
63823+:1081A000ACC000048D28007C3C098000ACC80008ED
63824+:1081B00090C4000D3082007FA0C2000D8F8500BCEE
63825+:1081C00090BF000D03E3C824A0B9000D8F9100BC3F
63826+:1081D0009233000D02789024A232000D8E9000346C
63827+:1081E0008F8B00BCAD7000108E87002C8E8F0030FE
63828+:1081F00000EF7023AD6E0014916D001831AC007F5C
63829+:10820000A16C00188F9F00BC8E8A00308FE8001888
63830+:10821000015720240109302400C41025AFE20018C2
63831+:108220009283000AA3E3001C969900088F8500BC86
63832+:108230008F9800D0A4B9001E8E9000308E8400303C
63833+:108240000E0002138F0500848F8500D0000291403C
63834+:108250000002990090AF00BC0253882100403021F9
63835+:1082600031E7000210E0000302118021000290803B
63836+:108270000212802190B900BC3327000410E00002F4
63837+:108280000006F880021F80218E9800308F8B00BC82
63838+:1082900024068000330F0003000F702331CD00034C
63839+:1082A000020D6021AD6C000494A400E294AA00E2E7
63840+:1082B00094B000E231497FFF2522000130537FFF57
63841+:1082C0000206182400734025A4A800E294A400E24A
63842+:1082D0003C1408008E94006030917FFF123400221D
63843+:1082E000000000000E000CF6000000008F8700D098
63844+:1082F0000000282194F300E094F000E21213000F34
63845+:108300008FBF003090E900D090E800D1313200FFFB
63846+:10831000310400FF0244302B14C0FF36264A00010E
63847+:1083200090EE00D2264B000131CD00FF008D602180
63848+:10833000158BFF338F9100B08FBF00308FB7002CAB
63849+:108340008FB600288FB500248FB400208FB3001C97
63850+:108350008FB200188FB100148FB0001000A0102150
63851+:1083600003E0000827BD003894A300E20066402423
63852+:10837000A4A800E290A400E290B900E2309100FFCE
63853+:108380000011A1C20014F827001F39C03332007F4A
63854+:10839000024730250A000DE8A0A600E23084FFFF66
63855+:1083A00030A5FFFFAF440018AF45001C03E00008F4
63856+:1083B0008F42001427BDFFB8AFB000208F9000D0CF
63857+:1083C0003084FFFFAFA40010AFBF0044AFBE004039
63858+:1083D000AFB7003CAFB60038AFB50034AFB4003033
63859+:1083E000AFB3002CAFB20028AFB10024A7A0001893
63860+:1083F000920600D1920500D030C400FF30A300FFE8
63861+:108400000064102B10400122AFA00014920900D08C
63862+:108410008FB50010312800FF0088382324F4FFFFB7
63863+:108420000014882B0015982B02339024524001260B
63864+:108430008FB40014961E0012961F00108FB7001004
63865+:1084400003DFC823001714000019C400000224032E
63866+:108450000018140302E2B02A52C00001004020219B
63867+:108460000284282B10A0000200801821028018210D
63868+:1084700000033C0000071C033064FFFF2C8600094A
63869+:1084800014C000020060B821241700088E0A0008FA
63870+:10849000001769808E09000C31ABFFFF3C0C001007
63871+:1084A000016C402527520400AF4A0038AF9200B853
63872+:1084B000AF49003CAF480030000000000000000061
63873+:1084C00000000000000000000000000000000000AC
63874+:1084D00000000000000000008F4F000031EE00207F
63875+:1084E00011C0FFFD0017982A027110240A000E83A4
63876+:1084F0000000B02155E001019258000131130080C5
63877+:10850000126001CF012020219655001232A5FFFFF5
63878+:108510000E000CCBA7B500188F9000D00291A023BD
63879+:1085200026CD00018F9100B8000DB4000016B403F1
63880+:108530002638004002D7582A0014882B2405000151
63881+:108540000300902101711024AF9800B8AFA500146A
63882+:10855000104001BC8F8900B03C0C08008D8C005489
63883+:10856000240BFF80921E00D001895021014B28244A
63884+:10857000921900D0AF4500288E4700103C08080033
63885+:108580008D0800583C1808008F18005430E33FFF56
63886+:108590000003218001043021012658212402FF809C
63887+:1085A0000162F824920C00D0AF5F002C92480000CA
63888+:1085B00033D100FF333500FF0309982100117140CA
63889+:1085C000001578C0326D007F01CF382101BA282113
63890+:1085D000318300FF3164007F3C0A000C00AA88212F
63891+:1085E0000367F02100033140009A10213108003F59
63892+:1085F0003C1F000E00D1C021005F982127D90088C0
63893+:108600002D150008AF9100C0AF9900ACAF9800BC29
63894+:10861000AF9300B412A0018A00008821240E00014B
63895+:10862000010E4004310D005D11A0FFB2310F0002B8
63896+:108630008E4A00283C0300803C04FFEFAE6A000035
63897+:108640008E450024A260000A3488FFFFAE65000456
63898+:108650009247002C3C1FFF9F37FEFFFFA267000CD4
63899+:108660008E62000C3C180040A267000B00433025CE
63900+:1086700000C8C824033E88240238A825AE75000C23
63901+:108680008E490004AE6000183C0F00FFAE69001474
63902+:108690008E4D002C35EEFFFF8F8B00B001AE6024B5
63903+:1086A000AE6C00108E470008A660000896450012C8
63904+:1086B000AE6700208E42000C30B03FFF00105180AA
63905+:1086C000AE6200248E5E0014014B182130A400011C
63906+:1086D000AE7E00288E590018000331C2000443808A
63907+:1086E000AE79002C8E51001C00C8F821A67F001C1A
63908+:1086F000AE710030965800028E550020A678001EFC
63909+:10870000AE75003492490033313000045600000544
63910+:10871000925000008F8C00D08D8B007CAE6B0030AF
63911+:10872000925000008F8F00BCA1F00000924E0033E9
63912+:1087300031CD000251A00007925E00018F8900BC7C
63913+:108740002418FF80913100000311A825A1350000F5
63914+:10875000925E00018F9900BC2409FFBF240BFFDF4C
63915+:10876000A33E00018F9500BC92B8000D3311007F2D
63916+:10877000A2B1000D8F8E00BC91D0000D02097824AB
63917+:10878000A1CF000D8F8800BC8E6D0014910A000DE2
63918+:108790002DAC0001000C2940014B382400E51825C0
63919+:1087A000A103000D964200128F8800BC8F8700D075
63920+:1087B000A50200028E45000490FF00BC30A4000317
63921+:1087C0000004302330DE000300BE102133F9000224
63922+:1087D00017200002244400342444003090E200BCFE
63923+:1087E00000A2302430DF000417E0000224830004DC
63924+:1087F000008018218F8F00AC24090002AD03000413
63925+:10880000A1E90000924E003F8F8D00ACA1AE0001A7
63926+:108810008F9500AC924C003F8E440004A6AC000241
63927+:10882000976B003C0E000CD63170FFFF00025380A6
63928+:10883000020A38253C05420000E51825AEA30004D5
63929+:108840008F8600AC8E480038ACC800188E440034C7
63930+:10885000ACC4001CACC0000CACC00010A4C0001420
63931+:10886000A4C00016A4C00020A4C00022ACC00024F4
63932+:108870008E6400145080000124040001ACC4000880
63933+:108880000E000CF6241100010A000E768F9000D025
63934+:10889000920F00D2920E00D08FB5001031EB00FF86
63935+:1088A00031CD00FF008D6023016C50212554FFFF66
63936+:1088B0000014882B0015982B023390241640FEDDFF
63937+:1088C000000000008FB400148FBF00448FBE004032
63938+:1088D0003A8200018FB7003C8FB600388FB5003464
63939+:1088E0008FB400308FB3002C8FB200288FB10024DA
63940+:1088F0008FB0002003E0000827BD0048331100209E
63941+:10890000122000EF24150001921E00BC241F00015C
63942+:108910000000A82133D900011320000DAFBF001CB7
63943+:108920008E4400148E0800840088102B144000022E
63944+:10893000008030218E0600848E03006400C3A82BC3
63945+:1089400016A0000200C020218E0400640080A8212F
63946+:108950008E4700148E05006400E5302B14C0000221
63947+:1089600000E020218E0400640095F02313C0000471
63948+:108970008FAC001C240A0002AFAA001C8FAC001CA4
63949+:10898000028C582B156000A8000018218E4F00386B
63950+:108990008E6D000C3C0E0080AE6F00008E4A0034DD
63951+:1089A0003C10FF9F01AE5825AE6A00049246003F7E
63952+:1089B000360CFFFF016C38243C0500203C03FFEF20
63953+:1089C000A266000B00E510253468FFFF8F8700B812
63954+:1089D0000048F8243C04000803E4C825AE79000CE4
63955+:1089E0008CF80014AE60001802BE7821AE78001436
63956+:1089F0008CF10018AE71001C8CE90008AE690024EF
63957+:108A00008CEE000CAE6F002CAE600028AE6E002025
63958+:108A1000A6600038A660003A8CED001401B58023F2
63959+:108A2000021E902312400011AE72001090EA003D29
63960+:108A30008E6500048E640000000A310000A6C82183
63961+:108A4000000010210326402B0082F82103E8C021FA
63962+:108A5000AE790004AE78000090F1003DA271000AEA
63963+:108A60008F8900B895320006A67200088F9800AC76
63964+:108A70002419000202A02021A31900009769003CDC
63965+:108A80008F9200AC0E000CD63131FFFF00027B80CC
63966+:108A90008F8500B8022F68253C0E420001AE80256C
63967+:108AA000AE5000048F8400AC8CAC0038AC8C001845
63968+:108AB0008CAB0034AC8B001CAC80000CAC80001084
63969+:108AC000A4800014A4800016A4800020A4800022AA
63970+:108AD000AC80002490A7003FA487000212A00135BB
63971+:108AE0002403000153C0000290A2003D90A2003E6A
63972+:108AF00024480001A08800018F9F00ACAFF500085A
63973+:108B00008F8300D024070034906600BC30C500027B
63974+:108B100050A00001240700308F9200B88F8A00BC5B
63975+:108B2000906D00BC924B00002412C00032A50003DF
63976+:108B3000A14B00008F8600B88F8800BC240200047F
63977+:108B400090C400010045182330790003A1040001FE
63978+:108B50008F8A00BC8F9F00B800F53821955800021D
63979+:108B600097E9001200F9382103128824312F3FFFC2
63980+:108B7000022F7025A54E00029150000231A800047A
63981+:108B8000320C003F358B0040A14B000212A00002C6
63982+:108B90008F8500BC00E838218F8E00D0ACA7000480
63983+:108BA000240BFFBF8DCD007C2EA400012403FFDF2A
63984+:108BB000ACAD000890B0000D00044140320C007FC5
63985+:108BC000A0AC000D8F8600BC90CA000D014B102494
63986+:108BD000A0C2000D8F8700BC90E5000D00A3F82413
63987+:108BE00003E8C825A0F9000D8F9100B88F8D00BC57
63988+:108BF0008E380020ADB800108E290024ADA90014D5
63989+:108C00008E2F0028ADAF00188E2E002C0E000CF613
63990+:108C1000ADAE001C8FB0001C240C0002120C00EE44
63991+:108C20008F9000D08FA3001C006088211460000288
63992+:108C30000060A8210000A02156A0FE390291A023C7
63993+:108C40000014882B8FA90010960700103C1E0020EE
63994+:108C50000136402302C750213112FFFFA60A00103F
63995+:108C6000AFB20010AF5E0030000000009617001099
63996+:108C7000961300121277008F000000008E05000C82
63997+:108C80008E0B00080016698000AD7021000DC7C36F
63998+:108C900001CDA82B0178782101F56021AE0E000CE2
63999+:108CA000AE0C00088FB300100013B82B02378024DD
64000+:108CB0001200FF048F9000D00A000E3C000000005C
64001+:108CC0008E4D0038A6600008240B0003AE6D000036
64002+:108CD0008E500034A260000A8F9800B8AE70000475
64003+:108CE0003C0500809311003FA26B000C8E6F000CBE
64004+:108CF0003C0EFF9FA271000B01E5102535CCFFFF54
64005+:108D00003C03FFEF8F9200B8004C30243464FFFF27
64006+:108D100000C4F824AE7F000C8E590014964800124F
64007+:108D20008F8A00B0AE7900108E490014AE60001832
64008+:108D3000AE600020AE690014AE6000248E470018BB
64009+:108D400031093FFF0009F180AE6700288E4D000811
64010+:108D500003CA802131180001AE6D00308E4F000C27
64011+:108D60008F8C00AC001089C200185B80022B282178
64012+:108D7000240E0002A665001CA6600036AE6F002C13
64013+:108D8000A18E00009763003C8F8A00AC3C04420037
64014+:108D90003062FFFF00443025AD4600048F9F00B8CD
64015+:108DA000240700012411C0008FF30038240600348A
64016+:108DB000AD5300188FF90034AD59001CAD40000CC4
64017+:108DC000AD400010A5400014A5400016A5400020AD
64018+:108DD000A5400022AD400024A5550002A147000196
64019+:108DE0008F9E00AC8F8800B88F9200BCAFD5000872
64020+:108DF000910D0000A24D00008F9000B88F8B00BC39
64021+:108E000092180001A17800018F8400BC94850002B3
64022+:108E100000B1782401E97025A48E0002908C000234
64023+:108E20003183003FA08300028F8300D08F8400BC79
64024+:108E3000906200BC305300025260000124060030F2
64025+:108E4000AC8600048C6F007C2403FFBF02A0882145
64026+:108E5000AC8F0008908E000D31CC007FA08C000DEF
64027+:108E60008F8600BC90C2000D00432024A0C4000DDA
64028+:108E70008F8900BC913F000D37F90020A139000D0A
64029+:108E80008F8800B88F9300BC8D070020AE6700105C
64030+:108E90008D0A0024AE6A00148D1E0028AE7E0018D4
64031+:108EA0008D12002C0E000CF6AE72001C0A00103D54
64032+:108EB0008F9000D0960E00148E03000431CCFFFF7B
64033+:108EC000000C10C000622021AF44003C8E1F000443
64034+:108ED0008F46003C03E6C8231B20003C0000000036
64035+:108EE0008E0F000025E200013C05001034B500089B
64036+:108EF000AF420038AF550030000000000000000015
64037+:108F00000000000000000000000000000000000061
64038+:108F100000000000000000008F580000330B00200C
64039+:108F20001160FFFD000000008F5304003C0D002085
64040+:108F3000AE1300088F570404AE17000CAF4D00307D
64041+:108F4000000000003C0608008CC600442416000106
64042+:108F500010D600BD00000000961F00123C0508005E
64043+:108F60008CA5004000BFC821A61900129609001464
64044+:108F700025270001A6070014960A00143144FFFFBC
64045+:108F80005486FF498FB30010A60000140E000E1681
64046+:108F900030A5FFFF3C0408008C84002496030012D7
64047+:108FA0000044102300623023A60600120A00105964
64048+:108FB0008FB30010A08300018F8200AC2404000155
64049+:108FC000AC4400080A000FF08F8300D08E0200002E
64050+:108FD0000A0010EA3C0500108F8200C08FA7001C19
64051+:108FE000921800D0920B00D0920E00D0331100FFE7
64052+:108FF000316900FF00117940000928C001E56021B6
64053+:1090000031C300FF036C50210003314000C2C8216E
64054+:10901000255F0088AF9F00ACAF9900BCA1470088D6
64055+:109020009768003C03C020218F9100AC0E000CD645
64056+:109030003110FFFF00026B80020DC0253C0442008E
64057+:109040008F8D00B803045825AE2B00048DA900387D
64058+:109050008F8B00AC0000882100118100AD690018E1
64059+:109060008DAF00343C087FFF3504FFFFAD6F001C5F
64060+:1090700091AC003E8D65001C8D660018000C190037
64061+:10908000000C770200A33821020E102500E3F82B14
64062+:1090900000C2C821033F5021AD67001CAD6A001813
64063+:1090A000AD60000CAD60001091B8003E24050005D5
64064+:1090B00003C45024A578001495A9000403C02021FE
64065+:1090C000A569001691AF003EA56F002095B1000480
64066+:1090D000A5710022AD60002491AE003FA56E000294
64067+:1090E00091B0003E91AC003D01901023244300015B
64068+:1090F000A16300018F8600AC8F9F00BCACDE00082E
64069+:10910000A3E500008F9000BC8F9900B82405FFBF35
64070+:1091100096070002973800120247782433093FFF70
64071+:1091200001E98825A6110002921200022418FFDF2F
64072+:10913000324E003F35CD0040A20D00028F8600BCAC
64073+:109140008F8C00D02412FFFFACC000048D8B007CFC
64074+:109150003C0C8000ACCB000890C2000D3043007F77
64075+:10916000A0C3000D8F8700BC90FF000D03E5C8244D
64076+:10917000A0F9000D8F9100BC9229000D01387824D0
64077+:10918000A22F000D8F9000BCAE120010AE1500147F
64078+:10919000920E00182415FF8002AE6825A20D00185B
64079+:1091A0008F8500BC8F8300B88CAB0018016C102435
64080+:1091B000004A3025ACA600189068003EA0A8001C0C
64081+:1091C0008F9F00B88F8700BC8F9800D097F900045C
64082+:1091D000A4F9001E0E0002138F0500848F8600D0B4
64083+:1091E000000279400002490090D200BC01E98821C8
64084+:1091F000004028213255000212A0000303D1202193
64085+:109200000002A8800095202190CD00BC31B200045E
64086+:109210001240000333DF0003000540800088202156
64087+:10922000240600048F9E00BC00DFC8233327000300
64088+:1092300000875021AFCA00040E000CF6A665003866
64089+:109240000A0010388F9000D0961E00123C080800CB
64090+:109250008D080024011E9021A61200120A00105948
64091+:109260008FB3001027BDFFE03C1808008F18005096
64092+:10927000AFB00010AFBF0018AFB10014AF8400B0A2
64093+:1092800093710074030478212410FF8031EE007F75
64094+:109290003225007F01F0582401DA68213C0C000AD5
64095+:1092A000A38500C401AC2821AF4B002494A9001071
64096+:1092B0009768000690A600620080382124020030E2
64097+:1092C0000109202330C300F0AF8500D010620019DF
64098+:1092D0003090FFFF90AE0062240DFFF0240A005092
64099+:1092E00001AE6024318B00FF116A002F00000000E6
64100+:1092F00016000007241F0C00AF5F00248FB100147C
64101+:109300008FBF00188FB0001003E0000827BD0020B9
64102+:109310000E000E1C02002021241F0C00AF5F002451
64103+:109320008FB100148FBF00188FB0001003E0000849
64104+:1093300027BD002094A200E094A400E290BF011396
64105+:10934000008218263079FFFF33E700C014E00009DF
64106+:109350002F31000116000038000000005620FFE603
64107+:10936000241F0C000E000D18000000000A0011ED73
64108+:10937000241F0C001620FFDE000000000E000D1858
64109+:10938000000000001440FFDC241F0C001600002227
64110+:109390008F8300D0906901133122003FA062011336
64111+:1093A0000A0011ED241F0C0094AF00D48F8600D466
64112+:1093B00000E02821240400050E000C5C31F0FFFFC2
64113+:1093C0001440000524030003979100E600001821D3
64114+:1093D0002625FFFFA78500E68F5801B80700FFFE8E
64115+:1093E0003C196013AF400180241F0C00AF50018472
64116+:1093F000007938253C101000AF4701888FB1001468
64117+:10940000AF5001B8AF5F00248FB000108FBF0018BD
64118+:1094100003E0000827BD00200E000E1C02002021E2
64119+:109420005040FFB5241F0C008F8300D090690113BA
64120+:109430000A0012163122003F0E000E1C02002021ED
64121+:109440001440FFAD241F0C00122000078F8300D0B2
64122+:10945000906801133106003F34C20040A06201133E
64123+:109460000A0011ED241F0C000E000D180000000072
64124+:109470005040FFA1241F0C008F8300D0906801137F
64125+:109480003106003F0A00124634C20040AF9B00C8BC
64126+:1094900003E00008AF8000EC3089FFFF0009404284
64127+:1094A0002D020041000921801440000200095040B3
64128+:1094B00024080040000830C0000811400046582130
64129+:1094C000256701A800E2C821272F007F2418FF800C
64130+:1094D00001F818240064302100CA702125CC00FF57
64131+:1094E000240DFF00018D202425650088240A0088B2
64132+:1094F0003C010800AC2A004C3C010800AC2500509F
64133+:10950000AF8400D43C010800AC2900603C01080095
64134+:10951000AC2800643C010800AC2700543C01080062
64135+:10952000AC2300583C010800AC26005C03E00008B6
64136+:1095300000000000308300FF30C6FFFF30E400FF72
64137+:109540008F4201B80440FFFE00034C00012438257F
64138+:109550003C08600000E820253C031000AF45018076
64139+:10956000AF460184AF44018803E00008AF4301B86F
64140+:109570008F86001C3C096012352700108CCB00043C
64141+:109580003C0C600E35850010316A00062D48000144
64142+:10959000ACE800C48CC40004ACA431808CC20008C8
64143+:1095A00094C30002ACA2318403E00008A78300E466
64144+:1095B0003C0308008C6300508F8400E88F86001CF9
64145+:1095C0002402FF800064C0210302C824AF59002890
64146+:1095D0008CCD00043305007F00BA78213C0E000CCE
64147+:1095E00001EE2821ACAD00588CC80008AF8500D032
64148+:1095F0003C076012ACA8005C8CCC001034E8001072
64149+:10960000ACAC000C8CCB000CACAB000894AA0014E2
64150+:109610003C0208008C42004425490001A4A9001422
64151+:1096200094A400143083FFFF106200178F8400D0D1
64152+:109630003C0A08008D4A0040A4AA00128CCE0018F3
64153+:10964000AC8E00248CCD0014AC8D00208CC700188B
64154+:10965000AC87002C8CCC001424060001AC8C0028B4
64155+:109660008D0B00BC5166001A8D0200B48D0200B84B
64156+:10967000A482003A948F003AA48F003C948800D4CE
64157+:1096800003E000083102FFFF3C0908008D29002497
64158+:10969000A4A000148F8400D0A4A900128CCE0018BE
64159+:1096A000AC8E00248CCD0014AC8D00208CC700182B
64160+:1096B000AC87002C8CCC001424060001AC8C002854
64161+:1096C0008D0B00BC5566FFEA8D0200B88D0200B418
64162+:1096D000A482003A948F003AA48F003C948800D46E
64163+:1096E00003E000083102FFFF8F86001C3C0C0800DD
64164+:1096F0008D8C0050240BFF808CCD00083C03000CA7
64165+:10970000000D51C0018A4021010B4824AF8A00E8B6
64166+:10971000AF49002890C700073105007F00BA10212B
64167+:109720000043282130E4000410800039AF8500D0C8
64168+:1097300090CF000731EE000811C000380000000093
64169+:109740008CD9000C8CC400140324C02B13000030EF
64170+:10975000000000008CC2000CACA200648CCD00188C
64171+:109760002402FFF8ACAD00688CCC0010ACAC0080DB
64172+:109770008CCB000CACAB00848CCA001CACAA007C67
64173+:1097800090A900BC01224024A0A800BC90C30007FF
64174+:109790003067000810E000048F8500D090AF00BC57
64175+:1097A00035EE0001A0AE00BC90D9000733380001AF
64176+:1097B000130000088F8300D08F8700D0240400346A
64177+:1097C00090E800BC35030002A0E300BC8F8300D00A
64178+:1097D000AC6400C090C900073126000210C000052B
64179+:1097E00000000000906A00BC35420004A06200BC8A
64180+:1097F0008F8300D09065011330AD003FA06D011341
64181+:109800008F8C00D0958B00D403E000083162FFFFFD
64182+:109810008CC200140A001305000000000A001306A1
64183+:10982000ACA0006427BDFFD8AFB000108F90001C23
64184+:10983000AFBF0024AFB40020AFB20018AFB1001426
64185+:10984000AFB3001C9613000E3C07600A3C14600680
64186+:109850003264FFFF369300100E00125534F40410EA
64187+:109860008F8400D43C11600E0E00099B363100102D
64188+:10987000920E00153C0708008CE700603C12601255
64189+:1098800031CD000FA38D00F08E0E00048E0D000868
64190+:1098900096080012961F00109619001A9618001EBE
64191+:1098A000960F001C310CFFFF33EBFFFF332AFFFF45
64192+:1098B0003309FFFF31E6FFFF3C010800AC2B0040FD
64193+:1098C0003C010800AC2C00243C010800AC2A0044F8
64194+:1098D000AE293178AE26317C92020015960300162F
64195+:1098E00036520010304400FF3065FFFF3C06080090
64196+:1098F0008CC60064AE243188AE4500B492080014D2
64197+:1099000096190018241F0001011FC004332FFFFF08
64198+:109910003C0508008CA50058AE5800B8AE4F00BCFE
64199+:10992000920C0014AF8E00D8AF8D00DC318B00FF9D
64200+:10993000AE4B00C0920A0015AE670048AE66004C00
64201+:10994000314900FFAE4900C8AE65007C3C03080009
64202+:109950008C6300503C0408008C84004C3C080800D8
64203+:109960008D0800543C0208008C42005C8FBF00242C
64204+:10997000AE6300808FB00010AE8300748FB3001C04
64205+:10998000AE22319CAE4200DCAE2731A0AE2631A41F
64206+:10999000AE24318CAE233190AE283194AE2531986F
64207+:1099A000AE870050AE860054AE8500708FB10014B3
64208+:1099B000AE4700E0AE4600E4AE4400CCAE4300D07B
64209+:1099C000AE4800D4AE4500D88FB400208FB2001846
64210+:1099D00003E0000827BD002827BDFFE0AFB1001459
64211+:1099E000AFBF0018241100010E000845AFB00010F1
64212+:1099F00010510005978400E6978300CC0083102B5C
64213+:109A0000144000088F8500D4240700028FBF00187F
64214+:109A10008FB100148FB0001000E0102103E00008A7
64215+:109A200027BD00200E000C7A24040005AF8200E858
64216+:109A30001040FFF6240700020E0008498F90001C1A
64217+:109A4000979F00E68F9900E88F8D00C827EF0001EF
64218+:109A5000240E0050AF590020A78F00E6A1AE0000F1
64219+:109A60003C0C08008D8C00648F8600C8240A80009E
64220+:109A7000000C5E00ACCB0074A4C0000694C9000AC0
64221+:109A8000241FFF803C0D000C012AC024A4D8000A2A
64222+:109A900090C8000A24182000011F1825A0C3000A3E
64223+:109AA0008F8700C8A0E000788F8500C800003821AB
64224+:109AB000A0A000833C0208008C4200508F8400E884
64225+:109AC0000044782101FFC824AF590028960B0002FA
64226+:109AD00031EE007F01DA6021018D3021A4CB00D46A
64227+:109AE000960A0002AF8600D03C0E000425492401EE
64228+:109AF000A4C900E68E080004ACC800048E03000868
64229+:109B0000ACC30000A4C00010A4C00014A0C000D0CA
64230+:109B10008F8500D02403FFBFA0A000D13C04080023
64231+:109B20008C8400648F8200D0A04400D28E1F000C71
64232+:109B30008F8A00D0978F00E4AD5F001C8E19001053
64233+:109B400024100030AD590018A5400030A551005434
64234+:109B5000A5510056A54F0016AD4E0068AD580080C7
64235+:109B6000AD580084914D006231AC000F358B001070
64236+:109B7000A14B00628F8600D090C900633128007F1E
64237+:109B8000A0C800638F8400D02406FFFF9085006387
64238+:109B900000A31024A08200638F9100D000E0102168
64239+:109BA000923F00BC37F90001A23900BC8F8A00D077
64240+:109BB000938F00F0AD580064AD5000C0914E00D3BB
64241+:109BC000000F690031CC000F018D5825A14B00D347
64242+:109BD0008F8500D08F8900DCACA900E88F8800D881
64243+:109BE0008FBF00188FB100148FB0001027BD002068
64244+:109BF000ACA800ECA4A600D6A4A000E0A4A000E2BB
64245+:109C000003E000080000000027BDFFE0AFB0001037
64246+:109C10008F90001CAFB10014AFBF00188E19000464
64247+:109C20003C1808008F180050240FFF80001989C0CD
64248+:109C30000238702131CD007F01CF602401BA50215C
64249+:109C40003C0B000CAF4C0028014B4021950900D47F
64250+:109C5000950400D68E0700043131FFFFAF8800D095
64251+:109C60000E000913000721C08E0600048F8300C870
64252+:109C7000000629C0AF4500209064003E30820040BD
64253+:109C8000144000068F8400D0341FFFFF948300D659
64254+:109C90003062FFFF145F000400000000948400D6CF
64255+:109CA0000E0008A83084FFFF8E050004022030213A
64256+:109CB0008FBF00188FB100148FB000102404002251
64257+:109CC00000003821000529C00A00127C27BD0020B1
64258+:109CD00027BDFFE0AFB100143091FFFFAFB000101F
64259+:109CE000AFBF00181220001D000080218F86001CCD
64260+:109CF0008CC500002403000600053F020005140285
64261+:109D000030E4000714830015304500FF2CA800063E
64262+:109D10001100004D000558803C0C0800258C57D4DC
64263+:109D2000016C50218D490000012000080000000056
64264+:109D30008F8E00EC240D000111CD005900000000B1
64265+:109D4000260B00013170FFFF24CA00200211202BD6
64266+:109D5000014030211480FFE6AF8A001C0200102170
64267+:109D60008FBF00188FB100148FB0001003E00008FF
64268+:109D700027BD0020938700CE14E00038240400148F
64269+:109D80000E001338000000008F86001C2402000122
64270+:109D90000A00147FAF8200EC8F8900EC24080002D7
64271+:109DA0001128003B2404001300002821000030216A
64272+:109DB000240700010E00127C000000000A00147F3E
64273+:109DC0008F86001C8F8700EC2405000214E5FFF647
64274+:109DD000240400120E0012E9000000008F8500E844
64275+:109DE00000403021240400120E00127C00003821B3
64276+:109DF0000A00147F8F86001C8F8300EC241F000351
64277+:109E0000147FFFD0260B00010E00129B0000000003
64278+:109E10008F8500E800403021240200022404001055
64279+:109E200000003821AF8200EC0E00127C0000000020
64280+:109E30000A00147F8F86001C8F8F00EC240600021E
64281+:109E400011E6000B0000000024040010000028218F
64282+:109E5000000030210A00149C240700010000282182
64283+:109E60000E00127C000030210A00147F8F86001C37
64284+:109E70000E0013A500000000144000128F99001C72
64285+:109E80008F86001C240200030A00147FAF8200ECBE
64286+:109E90000E001431000000000A00147F8F86001CA1
64287+:109EA0000E00128B000000002402000224040014A3
64288+:109EB0000000282100003021000038210A0014B9D8
64289+:109EC000AF8200EC004038212404001097380002D3
64290+:109ED000000028210E00127C3306FFFF0A00147FC9
64291+:109EE0008F86001C8F8400C83C077FFF34E6FFFF8D
64292+:109EF0008C8500742402000100A61824AC83007431
64293+:109F000003E00008A082000510A000362CA200800B
64294+:109F1000274A04003C0B000524090080104000077C
64295+:109F20002408008030A6000F00C540212D030081C9
64296+:109F30001460000200A0482124080080AF4B0030CC
64297+:109F400000000000000000000000000011000009F7
64298+:109F500000003821014030218C8D000024E70004EE
64299+:109F600000E8602BACCD0000248400041580FFFACB
64300+:109F700024C60004000000000000000000000000F3
64301+:109F80003C0E0006010E3825AF47003000000000EF
64302+:109F900000000000000000008F4F000031E80010BA
64303+:109FA0001100FFFD000000008F42003C8F43003C89
64304+:109FB0000049C8210323C02B130000040000000047
64305+:109FC0008F4C003825860001AF4600388F47003C93
64306+:109FD00000A9282300E96821AF4D003C14A0FFCE62
64307+:109FE0002CA2008003E000080000000027BDFFD085
64308+:109FF0003C020002AFB100143C11000CAF45003828
64309+:10A00000AFB3001CAF46003C00809821AF42003047
64310+:10A0100024050088AF44002803512021AFBF002849
64311+:10A02000AFB50024AFB40020AFB200180E0014F199
64312+:10A03000AFB000103C1F08008FFF004C3C18080018
64313+:10A040008F1800642410FF8003F3A82132B9007F29
64314+:10A0500002B078240018A0C0033A70210018914083
64315+:10A0600001D12021AF4F00280E0014F10254282105
64316+:10A070003C0D08008DAD00502405012001B358218E
64317+:10A08000316C007F01705024019A48210131202158
64318+:10A090000E0014F1AF4A00283C0808008D08005457
64319+:10A0A0003C0508008CA500640113382130E6007FD0
64320+:10A0B00000F0182400DA202100912021AF4300286D
64321+:10A0C0000E0014F1000529403C0208008C420058A3
64322+:10A0D0003C1008008E1000601200001C0053882104
64323+:10A0E0002415FF800A0015743C14000C3226007FF2
64324+:10A0F0000235182400DA202102402821AF4300282D
64325+:10A10000009420210E0014F12610FFC01200000F51
64326+:10A11000023288212E05004110A0FFF42412100005
64327+:10A120003226007F001091800235182400DA2021A9
64328+:10A1300002402821AF430028009420210E0014F192
64329+:10A14000000080211600FFF3023288213C0B08003A
64330+:10A150008D6B005C240AFF802405000201734021FE
64331+:10A16000010A4824AF4900283C0408009484006296
64332+:10A170003110007F021A88213C07000C0E000CAA47
64333+:10A180000227982100402821026020218FBF00284B
64334+:10A190008FB500248FB400208FB3001C8FB200183D
64335+:10A1A0008FB100148FB000100A0014F127BD0030E9
64336+:10A1B0008F83001C8C62000410400003000000002C
64337+:10A1C00003E00008000000008C6400108C650008AB
64338+:10A1D0000A00152A8C66000C000000000000001B1D
64339+:10A1E0000000000F0000000A000000080000000648
64340+:10A1F000000000050000000500000004000000044D
64341+:10A200000000000300000003000000030000000342
64342+:10A210000000000300000002000000020000000235
64343+:10A220000000000200000002000000020000000226
64344+:10A230000000000200000002000000020000000216
64345+:10A240000000000200000002000000020000000206
64346+:10A2500000000001000000010000000108000F24C0
64347+:10A2600008000D6C08000FB80800106008000F4CC3
64348+:10A2700008000F8C0800119408000D88080011B820
64349+:10A2800008000DD8080015540800151C08000D889A
64350+:10A2900008000D8808000D880800124008001240D0
64351+:10A2A00008000D8808000D88080014E008000D88DB
64352+:10A2B00008000D8808000D8808000D88080013B4F8
64353+:10A2C00008000D8808000D8808000D8808000D881A
64354+:10A2D00008000D8808000D8808000D8808000D880A
64355+:10A2E00008000D8808000D8808000D8808000D88FA
64356+:10A2F00008000D8808000D8808000FAC08000D88C4
64357+:10A3000008000D880800167808000D8808000D88E0
64358+:10A3100008000D8808000D8808000D8808000D88C9
64359+:10A3200008000D8808000D8808000D8808000D88B9
64360+:10A3300008000D8808000D8808000D8808000D88A9
64361+:10A3400008000D8808000D8808000D88080014100A
64362+:10A3500008000D8808000D8808001334080012A4B6
64363+:10A3600008001E2C08001EFC08001F1408001F28EF
64364+:10A3700008001F3808001E2C08001E2C08001E2C88
64365+:10A3800008001ED808002E1408002E1C08002DE41A
64366+:10A3900008002DF008002DFC08002E08080052F4DB
64367+:10A3A000080052B40800528008005254080052308D
64368+:10A3B000080051EC0A000C840000000000000000BE
64369+:10A3C0000000000D727870362E322E33000000002F
64370+:10A3D000060203030000000000000001000000006E
64371+:10A3E000000000000000000000000000000000006D
64372+:10A3F000000000000000000000000000000000005D
64373+:10A40000000000000000000000000000000000004C
64374+:10A41000000000000000000000000000000000003C
64375+:10A42000000000000000000000000000000000002C
64376+:10A43000000000000000000000000000000000001C
64377+:10A44000000000000000000000000000000000000C
64378+:10A4500000000000000000000000000000000000FC
64379+:10A4600000000000000000000000000000000000EC
64380+:10A4700000000000000000000000000000000000DC
64381+:10A4800000000000000000000000000000000000CC
64382+:10A4900000000000000000000000000000000000BC
64383+:10A4A00000000000000000000000000000000000AC
64384+:10A4B000000000000000000000000000000000009C
64385+:10A4C000000000000000000000000000000000008C
64386+:10A4D000000000000000000000000000000000007C
64387+:10A4E000000000000000000000000000000000006C
64388+:10A4F000000000000000000000000000000000005C
64389+:10A50000000000000000000000000000000000004B
64390+:10A51000000000000000000000000000000000003B
64391+:10A52000000000000000000000000000000000002B
64392+:10A53000000000000000000000000000000000001B
64393+:10A54000000000000000000000000000000000000B
64394+:10A5500000000000000000000000000000000000FB
64395+:10A5600000000000000000000000000000000000EB
64396+:10A5700000000000000000000000000000000000DB
64397+:10A5800000000000000000000000000000000000CB
64398+:10A5900000000000000000000000000000000000BB
64399+:10A5A00000000000000000000000000000000000AB
64400+:10A5B000000000000000000000000000000000009B
64401+:10A5C000000000000000000000000000000000008B
64402+:10A5D000000000000000000000000000000000007B
64403+:10A5E000000000000000000000000000000000006B
64404+:10A5F000000000000000000000000000000000005B
64405+:10A60000000000000000000000000000000000004A
64406+:10A61000000000000000000000000000000000003A
64407+:10A62000000000000000000000000000000000002A
64408+:10A63000000000000000000000000000000000001A
64409+:10A64000000000000000000000000000000000000A
64410+:10A6500000000000000000000000000000000000FA
64411+:10A6600000000000000000000000000000000000EA
64412+:10A6700000000000000000000000000000000000DA
64413+:10A6800000000000000000000000000000000000CA
64414+:10A6900000000000000000000000000000000000BA
64415+:10A6A00000000000000000000000000000000000AA
64416+:10A6B000000000000000000000000000000000009A
64417+:10A6C000000000000000000000000000000000008A
64418+:10A6D000000000000000000000000000000000007A
64419+:10A6E000000000000000000000000000000000006A
64420+:10A6F000000000000000000000000000000000005A
64421+:10A700000000000000000000000000000000000049
64422+:10A710000000000000000000000000000000000039
64423+:10A720000000000000000000000000000000000029
64424+:10A730000000000000000000000000000000000019
64425+:10A740000000000000000000000000000000000009
64426+:10A7500000000000000000000000000000000000F9
64427+:10A7600000000000000000000000000000000000E9
64428+:10A7700000000000000000000000000000000000D9
64429+:10A7800000000000000000000000000000000000C9
64430+:10A7900000000000000000000000000000000000B9
64431+:10A7A00000000000000000000000000000000000A9
64432+:10A7B0000000000000000000000000000000000099
64433+:10A7C0000000000000000000000000000000000089
64434+:10A7D0000000000000000000000000000000000079
64435+:10A7E0000000000000000000000000000000000069
64436+:10A7F0000000000000000000000000000000000059
64437+:10A800000000000000000000000000000000000048
64438+:10A810000000000000000000000000000000000038
64439+:10A820000000000000000000000000000000000028
64440+:10A830000000000000000000000000000000000018
64441+:10A840000000000000000000000000000000000008
64442+:10A8500000000000000000000000000000000000F8
64443+:10A8600000000000000000000000000000000000E8
64444+:10A8700000000000000000000000000000000000D8
64445+:10A8800000000000000000000000000000000000C8
64446+:10A8900000000000000000000000000000000000B8
64447+:10A8A00000000000000000000000000000000000A8
64448+:10A8B0000000000000000000000000000000000098
64449+:10A8C0000000000000000000000000000000000088
64450+:10A8D0000000000000000000000000000000000078
64451+:10A8E0000000000000000000000000000000000068
64452+:10A8F0000000000000000000000000000000000058
64453+:10A900000000000000000000000000000000000047
64454+:10A910000000000000000000000000000000000037
64455+:10A920000000000000000000000000000000000027
64456+:10A930000000000000000000000000000000000017
64457+:10A940000000000000000000000000000000000007
64458+:10A9500000000000000000000000000000000000F7
64459+:10A9600000000000000000000000000000000000E7
64460+:10A9700000000000000000000000000000000000D7
64461+:10A9800000000000000000000000000000000000C7
64462+:10A9900000000000000000000000000000000000B7
64463+:10A9A00000000000000000000000000000000000A7
64464+:10A9B0000000000000000000000000000000000097
64465+:10A9C0000000000000000000000000000000000087
64466+:10A9D0000000000000000000000000000000000077
64467+:10A9E0000000000000000000000000000000000067
64468+:10A9F0000000000000000000000000000000000057
64469+:10AA00000000000000000000000000000000000046
64470+:10AA10000000000000000000000000000000000036
64471+:10AA20000000000000000000000000000000000026
64472+:10AA30000000000000000000000000000000000016
64473+:10AA40000000000000000000000000000000000006
64474+:10AA500000000000000000000000000000000000F6
64475+:10AA600000000000000000000000000000000000E6
64476+:10AA700000000000000000000000000000000000D6
64477+:10AA800000000000000000000000000000000000C6
64478+:10AA900000000000000000000000000000000000B6
64479+:10AAA00000000000000000000000000000000000A6
64480+:10AAB0000000000000000000000000000000000096
64481+:10AAC0000000000000000000000000000000000086
64482+:10AAD0000000000000000000000000000000000076
64483+:10AAE0000000000000000000000000000000000066
64484+:10AAF0000000000000000000000000000000000056
64485+:10AB00000000000000000000000000000000000045
64486+:10AB10000000000000000000000000000000000035
64487+:10AB20000000000000000000000000000000000025
64488+:10AB30000000000000000000000000000000000015
64489+:10AB40000000000000000000000000000000000005
64490+:10AB500000000000000000000000000000000000F5
64491+:10AB600000000000000000000000000000000000E5
64492+:10AB700000000000000000000000000000000000D5
64493+:10AB800000000000000000000000000000000000C5
64494+:10AB900000000000000000000000000000000000B5
64495+:10ABA00000000000000000000000000000000000A5
64496+:10ABB0000000000000000000000000000000000095
64497+:10ABC0000000000000000000000000000000000085
64498+:10ABD0000000000000000000000000000000000075
64499+:10ABE0000000000000000000000000000000000065
64500+:10ABF0000000000000000000000000000000000055
64501+:10AC00000000000000000000000000000000000044
64502+:10AC10000000000000000000000000000000000034
64503+:10AC20000000000000000000000000000000000024
64504+:10AC30000000000000000000000000000000000014
64505+:10AC40000000000000000000000000000000000004
64506+:10AC500000000000000000000000000000000000F4
64507+:10AC600000000000000000000000000000000000E4
64508+:10AC700000000000000000000000000000000000D4
64509+:10AC800000000000000000000000000000000000C4
64510+:10AC900000000000000000000000000000000000B4
64511+:10ACA00000000000000000000000000000000000A4
64512+:10ACB0000000000000000000000000000000000094
64513+:10ACC0000000000000000000000000000000000084
64514+:10ACD0000000000000000000000000000000000074
64515+:10ACE0000000000000000000000000000000000064
64516+:10ACF0000000000000000000000000000000000054
64517+:10AD00000000000000000000000000000000000043
64518+:10AD10000000000000000000000000000000000033
64519+:10AD20000000000000000000000000000000000023
64520+:10AD30000000000000000000000000000000000013
64521+:10AD40000000000000000000000000000000000003
64522+:10AD500000000000000000000000000000000000F3
64523+:10AD600000000000000000000000000000000000E3
64524+:10AD700000000000000000000000000000000000D3
64525+:10AD800000000000000000000000000000000000C3
64526+:10AD900000000000000000000000000000000000B3
64527+:10ADA00000000000000000000000000000000000A3
64528+:10ADB0000000000000000000000000000000000093
64529+:10ADC0000000000000000000000000000000000083
64530+:10ADD0000000000000000000000000000000000073
64531+:10ADE0000000000000000000000000000000000063
64532+:10ADF0000000000000000000000000000000000053
64533+:10AE00000000000000000000000000000000000042
64534+:10AE10000000000000000000000000000000000032
64535+:10AE20000000000000000000000000000000000022
64536+:10AE30000000000000000000000000000000000012
64537+:10AE40000000000000000000000000000000000002
64538+:10AE500000000000000000000000000000000000F2
64539+:10AE600000000000000000000000000000000000E2
64540+:10AE700000000000000000000000000000000000D2
64541+:10AE800000000000000000000000000000000000C2
64542+:10AE900000000000000000000000000000000000B2
64543+:10AEA00000000000000000000000000000000000A2
64544+:10AEB0000000000000000000000000000000000092
64545+:10AEC0000000000000000000000000000000000082
64546+:10AED0000000000000000000000000000000000072
64547+:10AEE0000000000000000000000000000000000062
64548+:10AEF0000000000000000000000000000000000052
64549+:10AF00000000000000000000000000000000000041
64550+:10AF10000000000000000000000000000000000031
64551+:10AF20000000000000000000000000000000000021
64552+:10AF30000000000000000000000000000000000011
64553+:10AF40000000000000000000000000000000000001
64554+:10AF500000000000000000000000000000000000F1
64555+:10AF600000000000000000000000000000000000E1
64556+:10AF700000000000000000000000000000000000D1
64557+:10AF800000000000000000000000000000000000C1
64558+:10AF900000000000000000000000000000000000B1
64559+:10AFA00000000000000000000000000000000000A1
64560+:10AFB0000000000000000000000000000000000091
64561+:10AFC0000000000000000000000000000000000081
64562+:10AFD0000000000000000000000000000000000071
64563+:10AFE0000000000000000000000000000000000061
64564+:10AFF0000000000000000000000000000000000051
64565+:10B000000000000000000000000000000000000040
64566+:10B010000000000000000000000000000000000030
64567+:10B020000000000000000000000000000000000020
64568+:10B030000000000000000000000000000000000010
64569+:10B040000000000000000000000000000000000000
64570+:10B0500000000000000000000000000000000000F0
64571+:10B0600000000000000000000000000000000000E0
64572+:10B0700000000000000000000000000000000000D0
64573+:10B0800000000000000000000000000000000000C0
64574+:10B0900000000000000000000000000000000000B0
64575+:10B0A00000000000000000000000000000000000A0
64576+:10B0B0000000000000000000000000000000000090
64577+:10B0C0000000000000000000000000000000000080
64578+:10B0D0000000000000000000000000000000000070
64579+:10B0E0000000000000000000000000000000000060
64580+:10B0F0000000000000000000000000000000000050
64581+:10B10000000000000000000000000000000000003F
64582+:10B11000000000000000000000000000000000002F
64583+:10B12000000000000000000000000000000000001F
64584+:10B13000000000000000000000000000000000000F
64585+:10B1400000000000000000000000000000000000FF
64586+:10B1500000000000000000000000000000000000EF
64587+:10B1600000000000000000000000000000000000DF
64588+:10B1700000000000000000000000000000000000CF
64589+:10B1800000000000000000000000000000000000BF
64590+:10B1900000000000000000000000000000000000AF
64591+:10B1A000000000000000000000000000000000009F
64592+:10B1B000000000000000000000000000000000008F
64593+:10B1C000000000000000000000000000000000007F
64594+:10B1D000000000000000000000000000000000006F
64595+:10B1E000000000000000000000000000000000005F
64596+:10B1F000000000000000000000000000000000004F
64597+:10B20000000000000000000000000000000000003E
64598+:10B21000000000000000000000000000000000002E
64599+:10B22000000000000000000000000000000000001E
64600+:10B23000000000000000000000000000000000000E
64601+:10B2400000000000000000000000000000000000FE
64602+:10B2500000000000000000000000000000000000EE
64603+:10B2600000000000000000000000000000000000DE
64604+:10B2700000000000000000000000000000000000CE
64605+:10B2800000000000000000000000000000000000BE
64606+:10B2900000000000000000000000000000000000AE
64607+:10B2A000000000000000000000000000000000009E
64608+:10B2B000000000000000000000000000000000008E
64609+:10B2C000000000000000000000000000000000007E
64610+:10B2D000000000000000000000000000000000006E
64611+:10B2E000000000000000000000000000000000005E
64612+:10B2F000000000000000000000000000000000004E
64613+:10B30000000000000000000000000000000000003D
64614+:10B31000000000000000000000000000000000002D
64615+:10B32000000000000000000000000000000000001D
64616+:10B33000000000000000000000000000000000000D
64617+:10B3400000000000000000000000000000000000FD
64618+:10B3500000000000000000000000000000000000ED
64619+:10B3600000000000000000000000000000000000DD
64620+:10B3700000000000000000000000000000000000CD
64621+:10B3800000000000000000000000000000000000BD
64622+:10B3900000000000000000000000000000000000AD
64623+:10B3A000000000000000000000000000000000009D
64624+:10B3B000000000000000000000000000000000008D
64625+:10B3C000000000000000000000000000000000007D
64626+:10B3D000000000000000000000000000000000006D
64627+:10B3E000000000000000000000000000000000005D
64628+:10B3F000000000000000000000000000000000004D
64629+:10B40000000000000000000000000000000000003C
64630+:10B41000000000000000000000000000000000002C
64631+:10B42000000000000000000000000000000000001C
64632+:10B43000000000000000000000000000000000000C
64633+:10B4400000000000000000000000000000000000FC
64634+:10B4500000000000000000000000000000000000EC
64635+:10B4600000000000000000000000000000000000DC
64636+:10B4700000000000000000000000000000000000CC
64637+:10B4800000000000000000000000000000000000BC
64638+:10B4900000000000000000000000000000000000AC
64639+:10B4A000000000000000000000000000000000009C
64640+:10B4B000000000000000000000000000000000008C
64641+:10B4C000000000000000000000000000000000007C
64642+:10B4D000000000000000000000000000000000006C
64643+:10B4E000000000000000000000000000000000005C
64644+:10B4F000000000000000000000000000000000004C
64645+:10B50000000000000000000000000000000000003B
64646+:10B51000000000000000000000000000000000002B
64647+:10B52000000000000000000000000000000000001B
64648+:10B53000000000000000000000000000000000000B
64649+:10B5400000000000000000000000000000000000FB
64650+:10B5500000000000000000000000000000000000EB
64651+:10B5600000000000000000000000000000000000DB
64652+:10B5700000000000000000000000000000000000CB
64653+:10B5800000000000000000000000000000000000BB
64654+:10B5900000000000000000000000000000000000AB
64655+:10B5A000000000000000000000000000000000009B
64656+:10B5B000000000000000000000000000000000008B
64657+:10B5C000000000000000000000000000000000007B
64658+:10B5D000000000000000000000000000000000006B
64659+:10B5E000000000000000000000000000000000005B
64660+:10B5F000000000000000000000000000000000004B
64661+:10B60000000000000000000000000000000000003A
64662+:10B61000000000000000000000000000000000002A
64663+:10B62000000000000000000000000000000000001A
64664+:10B63000000000000000000000000000000000000A
64665+:10B6400000000000000000000000000000000000FA
64666+:10B6500000000000000000000000000000000000EA
64667+:10B6600000000000000000000000000000000000DA
64668+:10B6700000000000000000000000000000000000CA
64669+:10B6800000000000000000000000000000000000BA
64670+:10B6900000000000000000000000000000000000AA
64671+:10B6A000000000000000000000000000000000009A
64672+:10B6B000000000000000000000000000000000008A
64673+:10B6C000000000000000000000000000000000007A
64674+:10B6D000000000000000000000000000000000006A
64675+:10B6E000000000000000000000000000000000005A
64676+:10B6F000000000000000000000000000000000004A
64677+:10B700000000000000000000000000000000000039
64678+:10B710000000000000000000000000000000000029
64679+:10B720000000000000000000000000000000000019
64680+:10B730000000000000000000000000000000000009
64681+:10B7400000000000000000000000000000000000F9
64682+:10B7500000000000000000000000000000000000E9
64683+:10B7600000000000000000000000000000000000D9
64684+:10B7700000000000000000000000000000000000C9
64685+:10B7800000000000000000000000000000000000B9
64686+:10B7900000000000000000000000000000000000A9
64687+:10B7A0000000000000000000000000000000000099
64688+:10B7B0000000000000000000000000000000000089
64689+:10B7C0000000000000000000000000000000000079
64690+:10B7D0000000000000000000000000000000000069
64691+:10B7E0000000000000000000000000000000000059
64692+:10B7F0000000000000000000000000000000000049
64693+:10B800000000000000000000000000000000000038
64694+:10B810000000000000000000000000000000000028
64695+:10B820000000000000000000000000000000000018
64696+:10B830000000000000000000000000000000000008
64697+:10B8400000000000000000000000000000000000F8
64698+:10B8500000000000000000000000000000000000E8
64699+:10B8600000000000000000000000000000000000D8
64700+:10B8700000000000000000000000000000000000C8
64701+:10B8800000000000000000000000000000000000B8
64702+:10B8900000000000000000000000000000000000A8
64703+:10B8A0000000000000000000000000000000000098
64704+:10B8B0000000000000000000000000000000000088
64705+:10B8C0000000000000000000000000000000000078
64706+:10B8D0000000000000000000000000000000000068
64707+:10B8E0000000000000000000000000000000000058
64708+:10B8F0000000000000000000000000000000000048
64709+:10B900000000000000000000000000000000000037
64710+:10B910000000000000000000000000000000000027
64711+:10B920000000000000000000000000000000000017
64712+:10B930000000000000000000000000000000000007
64713+:10B9400000000000000000000000000000000000F7
64714+:10B9500000000000000000000000000000000000E7
64715+:10B9600000000000000000000000000000000000D7
64716+:10B9700000000000000000000000000000000000C7
64717+:10B9800000000000000000000000000000000000B7
64718+:10B9900000000000000000000000000000000000A7
64719+:10B9A0000000000000000000000000000000000097
64720+:10B9B0000000000000000000000000000000000087
64721+:10B9C0000000000000000000000000000000000077
64722+:10B9D0000000000000000000000000000000000067
64723+:10B9E0000000000000000000000000000000000057
64724+:10B9F0000000000000000000000000000000000047
64725+:10BA00000000000000000000000000000000000036
64726+:10BA10000000000000000000000000000000000026
64727+:10BA20000000000000000000000000000000000016
64728+:10BA30000000000000000000000000000000000006
64729+:10BA400000000000000000000000000000000000F6
64730+:10BA500000000000000000000000000000000000E6
64731+:10BA600000000000000000000000000000000000D6
64732+:10BA700000000000000000000000000000000000C6
64733+:10BA800000000000000000000000000000000000B6
64734+:10BA900000000000000000000000000000000000A6
64735+:10BAA0000000000000000000000000000000000096
64736+:10BAB0000000000000000000000000000000000086
64737+:10BAC0000000000000000000000000000000000076
64738+:10BAD0000000000000000000000000000000000066
64739+:10BAE0000000000000000000000000000000000056
64740+:10BAF0000000000000000000000000000000000046
64741+:10BB00000000000000000000000000000000000035
64742+:10BB10000000000000000000000000000000000025
64743+:10BB20000000000000000000000000000000000015
64744+:10BB30000000000000000000000000000000000005
64745+:10BB400000000000000000000000000000000000F5
64746+:10BB500000000000000000000000000000000000E5
64747+:10BB600000000000000000000000000000000000D5
64748+:10BB700000000000000000000000000000000000C5
64749+:10BB800000000000000000000000000000000000B5
64750+:10BB900000000000000000000000000000000000A5
64751+:10BBA0000000000000000000000000000000000095
64752+:10BBB0000000000000000000000000000000000085
64753+:10BBC0000000000000000000000000000000000075
64754+:10BBD0000000000000000000000000000000000065
64755+:10BBE0000000000000000000000000000000000055
64756+:10BBF0000000000000000000000000000000000045
64757+:10BC00000000000000000000000000000000000034
64758+:10BC10000000000000000000000000000000000024
64759+:10BC20000000000000000000000000000000000014
64760+:10BC30000000000000000000000000000000000004
64761+:10BC400000000000000000000000000000000000F4
64762+:10BC500000000000000000000000000000000000E4
64763+:10BC600000000000000000000000000000000000D4
64764+:10BC700000000000000000000000000000000000C4
64765+:10BC800000000000000000000000000000000000B4
64766+:10BC900000000000000000000000000000000000A4
64767+:10BCA0000000000000000000000000000000000094
64768+:10BCB0000000000000000000000000000000000084
64769+:10BCC0000000000000000000000000000000000074
64770+:10BCD0000000000000000000000000000000000064
64771+:10BCE0000000000000000000000000000000000054
64772+:10BCF0000000000000000000000000000000000044
64773+:10BD00000000000000000000000000000000000033
64774+:10BD10000000000000000000000000000000000023
64775+:10BD20000000000000000000000000000000000013
64776+:10BD30000000000000000000000000000000000003
64777+:10BD400000000000000000000000000000000000F3
64778+:10BD500000000000000000000000000000000000E3
64779+:10BD600000000000000000000000000000000000D3
64780+:10BD700000000000000000000000000000000000C3
64781+:10BD800000000000000000000000000000000000B3
64782+:10BD900000000000000000000000000000000000A3
64783+:10BDA0000000000000000000000000000000000093
64784+:10BDB0000000000000000000000000000000000083
64785+:10BDC0000000000000000000000000000000000073
64786+:10BDD0000000000000000000000000000000000063
64787+:10BDE0000000000000000000000000000000000053
64788+:10BDF0000000000000000000000000000000000043
64789+:10BE00000000000000000000000000000000000032
64790+:10BE10000000000000000000000000000000000022
64791+:10BE20000000000000000000000000000000000012
64792+:10BE30000000000000000000000000000000000002
64793+:10BE400000000000000000000000000000000000F2
64794+:10BE500000000000000000000000000000000000E2
64795+:10BE600000000000000000000000000000000000D2
64796+:10BE700000000000000000000000000000000000C2
64797+:10BE800000000000000000000000000000000000B2
64798+:10BE900000000000000000000000000000000000A2
64799+:10BEA0000000000000000000000000000000000092
64800+:10BEB0000000000000000000000000000000000082
64801+:10BEC0000000000000000000000000000000000072
64802+:10BED0000000000000000000000000000000000062
64803+:10BEE0000000000000000000000000000000000052
64804+:10BEF0000000000000000000000000000000000042
64805+:10BF00000000000000000000000000000000000031
64806+:10BF10000000000000000000000000000000000021
64807+:10BF20000000000000000000000000000000000011
64808+:10BF30000000000000000000000000000000000001
64809+:10BF400000000000000000000000000000000000F1
64810+:10BF500000000000000000000000000000000000E1
64811+:10BF600000000000000000000000000000000000D1
64812+:10BF700000000000000000000000000000000000C1
64813+:10BF800000000000000000000000000000000000B1
64814+:10BF900000000000000000000000000000000000A1
64815+:10BFA0000000000000000000000000000000000091
64816+:10BFB0000000000000000000000000000000000081
64817+:10BFC0000000000000000000000000000000000071
64818+:10BFD0000000000000000000000000000000000061
64819+:10BFE0000000000000000000000000000000000051
64820+:10BFF0000000000000000000000000000000000041
64821+:10C000000000000000000000000000000000000030
64822+:10C010000000000000000000000000000000000020
64823+:10C020000000000000000000000000000000000010
64824+:10C030000000000000000000000000000000000000
64825+:10C0400000000000000000000000000000000000F0
64826+:10C0500000000000000000000000000000000000E0
64827+:10C0600000000000000000000000000000000000D0
64828+:10C0700000000000000000000000000000000000C0
64829+:10C0800000000000000000000000000000000000B0
64830+:10C0900000000000000000000000000000000000A0
64831+:10C0A0000000000000000000000000000000000090
64832+:10C0B0000000000000000000000000000000000080
64833+:10C0C0000000000000000000000000000000000070
64834+:10C0D0000000000000000000000000000000000060
64835+:10C0E0000000000000000000000000000000000050
64836+:10C0F0000000000000000000000000000000000040
64837+:10C10000000000000000000000000000000000002F
64838+:10C11000000000000000000000000000000000001F
64839+:10C12000000000000000000000000000000000000F
64840+:10C1300000000000000000000000000000000000FF
64841+:10C1400000000000000000000000000000000000EF
64842+:10C1500000000000000000000000000000000000DF
64843+:10C1600000000000000000000000000000000000CF
64844+:10C1700000000000000000000000000000000000BF
64845+:10C1800000000000000000000000000000000000AF
64846+:10C19000000000000000000000000000000000009F
64847+:10C1A000000000000000000000000000000000008F
64848+:10C1B000000000000000000000000000000000007F
64849+:10C1C000000000000000000000000000000000006F
64850+:10C1D000000000000000000000000000000000005F
64851+:10C1E000000000000000000000000000000000004F
64852+:10C1F000000000000000000000000000000000003F
64853+:10C20000000000000000000000000000000000002E
64854+:10C21000000000000000000000000000000000001E
64855+:10C22000000000000000000000000000000000000E
64856+:10C2300000000000000000000000000000000000FE
64857+:10C2400000000000000000000000000000000000EE
64858+:10C2500000000000000000000000000000000000DE
64859+:10C2600000000000000000000000000000000000CE
64860+:10C2700000000000000000000000000000000000BE
64861+:10C2800000000000000000000000000000000000AE
64862+:10C29000000000000000000000000000000000009E
64863+:10C2A000000000000000000000000000000000008E
64864+:10C2B000000000000000000000000000000000007E
64865+:10C2C000000000000000000000000000000000006E
64866+:10C2D000000000000000000000000000000000005E
64867+:10C2E000000000000000000000000000000000004E
64868+:10C2F000000000000000000000000000000000003E
64869+:10C30000000000000000000000000000000000002D
64870+:10C31000000000000000000000000000000000001D
64871+:10C32000000000000000000000000000000000000D
64872+:10C3300000000000000000000000000000000000FD
64873+:10C3400000000000000000000000000000000000ED
64874+:10C3500000000000000000000000000000000000DD
64875+:10C3600000000000000000000000000000000000CD
64876+:10C3700000000000000000000000000000000000BD
64877+:10C3800000000000000000000000000000000000AD
64878+:10C39000000000000000000000000000000000009D
64879+:10C3A000000000000000000000000000000000008D
64880+:10C3B000000000000000000000000000000000007D
64881+:10C3C000000000000000000000000000000000006D
64882+:10C3D000000000000000000000000000000000005D
64883+:10C3E000000000000000000000000000000000004D
64884+:10C3F000000000000000000000000000000000003D
64885+:10C40000000000000000000000000000000000002C
64886+:10C41000000000000000000000000000000000001C
64887+:10C42000000000000000000000000000000000000C
64888+:10C4300000000000000000000000000000000000FC
64889+:10C4400000000000000000000000000000000000EC
64890+:10C4500000000000000000000000000000000000DC
64891+:10C4600000000000000000000000000000000000CC
64892+:10C4700000000000000000000000000000000000BC
64893+:10C4800000000000000000000000000000000000AC
64894+:10C49000000000000000000000000000000000009C
64895+:10C4A000000000000000000000000000000000008C
64896+:10C4B000000000000000000000000000000000007C
64897+:10C4C000000000000000000000000000000000006C
64898+:10C4D000000000000000000000000000000000005C
64899+:10C4E000000000000000000000000000000000004C
64900+:10C4F000000000000000000000000000000000003C
64901+:10C50000000000000000000000000000000000002B
64902+:10C51000000000000000000000000000000000001B
64903+:10C52000000000000000000000000000000000000B
64904+:10C5300000000000000000000000000000000000FB
64905+:10C5400000000000000000000000000000000000EB
64906+:10C5500000000000000000000000000000000000DB
64907+:10C5600000000000000000000000000000000000CB
64908+:10C5700000000000000000000000000000000000BB
64909+:10C5800000000000000000000000000000000000AB
64910+:10C59000000000000000000000000000000000009B
64911+:10C5A000000000000000000000000000000000008B
64912+:10C5B000000000000000000000000000000000007B
64913+:10C5C000000000000000000000000000000000006B
64914+:10C5D000000000000000000000000000000000005B
64915+:10C5E000000000000000000000000000000000004B
64916+:10C5F000000000000000000000000000000000003B
64917+:10C60000000000000000000000000000000000002A
64918+:10C61000000000000000000000000000000000001A
64919+:10C62000000000000000000000000000000000000A
64920+:10C6300000000000000000000000000000000000FA
64921+:10C6400000000000000000000000000000000000EA
64922+:10C6500000000000000000000000000000000000DA
64923+:10C6600000000000000000000000000000000000CA
64924+:10C6700000000000000000000000000000000000BA
64925+:10C6800000000000000000000000000000000000AA
64926+:10C69000000000000000000000000000000000009A
64927+:10C6A000000000000000000000000000000000008A
64928+:10C6B000000000000000000000000000000000007A
64929+:10C6C000000000000000000000000000000000006A
64930+:10C6D000000000000000000000000000000000005A
64931+:10C6E000000000000000000000000000000000004A
64932+:10C6F000000000000000000000000000000000003A
64933+:10C700000000000000000000000000000000000029
64934+:10C710000000000000000000000000000000000019
64935+:10C720000000000000000000000000000000000009
64936+:10C7300000000000000000000000000000000000F9
64937+:10C7400000000000000000000000000000000000E9
64938+:10C7500000000000000000000000000000000000D9
64939+:10C7600000000000000000000000000000000000C9
64940+:10C7700000000000000000000000000000000000B9
64941+:10C7800000000000000000000000000000000000A9
64942+:10C790000000000000000000000000000000000099
64943+:10C7A0000000000000000000000000000000000089
64944+:10C7B0000000000000000000000000000000000079
64945+:10C7C0000000000000000000000000000000000069
64946+:10C7D0000000000000000000000000000000000059
64947+:10C7E0000000000000000000000000000000000049
64948+:10C7F0000000000000000000000000000000000039
64949+:10C800000000000000000000000000000000000028
64950+:10C810000000000000000000000000000000000018
64951+:10C820000000000000000000000000000000000008
64952+:10C8300000000000000000000000000000000000F8
64953+:10C8400000000000000000000000000000000000E8
64954+:10C8500000000000000000000000000000000000D8
64955+:10C8600000000000000000000000000000000000C8
64956+:10C8700000000000000000000000000000000000B8
64957+:10C8800000000000000000000000000000000000A8
64958+:10C890000000000000000000000000000000000098
64959+:10C8A0000000000000000000000000000000000088
64960+:10C8B0000000000000000000000000000000000078
64961+:10C8C0000000000000000000000000000000000068
64962+:10C8D0000000000000000000000000000000000058
64963+:10C8E0000000000000000000000000000000000048
64964+:10C8F0000000000000000000000000000000000038
64965+:10C900000000000000000000000000000000000027
64966+:10C910000000000000000000000000000000000017
64967+:10C920000000000000000000000000000000000007
64968+:10C9300000000000000000000000000000000000F7
64969+:10C9400000000000000000000000000000000000E7
64970+:10C9500000000000000000000000000000000000D7
64971+:10C9600000000000000000000000000000000000C7
64972+:10C9700000000000000000000000000000000000B7
64973+:10C9800000000000000000000000000000000000A7
64974+:10C990000000000000000000000000000000000097
64975+:10C9A0000000000000000000000000000000000087
64976+:10C9B0000000000000000000000000000000000077
64977+:10C9C0000000000000000000000000000000000067
64978+:10C9D0000000000000000000000000000000000057
64979+:10C9E0000000000000000000000000000000000047
64980+:10C9F0000000000000000000000000000000000037
64981+:10CA00000000000000000000000000000000000026
64982+:10CA10000000000000000000000000000000000016
64983+:10CA20000000000000000000000000000000000006
64984+:10CA300000000000000000000000000000000000F6
64985+:10CA400000000000000000000000000000000000E6
64986+:10CA500000000000000000000000000000000000D6
64987+:10CA600000000000000000000000000000000000C6
64988+:10CA700000000000000000000000000000000000B6
64989+:10CA800000000000000000000000000000000000A6
64990+:10CA90000000000000000000000000000000000096
64991+:10CAA0000000000000000000000000000000000086
64992+:10CAB0000000000000000000000000000000000076
64993+:10CAC0000000000000000000000000000000000066
64994+:10CAD0000000000000000000000000000000000056
64995+:10CAE0000000000000000000000000000000000046
64996+:10CAF0000000000000000000000000000000000036
64997+:10CB00000000000000000000000000000000000025
64998+:10CB10000000000000000000000000000000000015
64999+:10CB20000000000000000000000000000000000005
65000+:10CB300000000000000000000000000000000000F5
65001+:10CB400000000000000000000000000000000000E5
65002+:10CB500000000000000000000000000000000000D5
65003+:10CB600000000000000000000000000000000000C5
65004+:10CB700000000000000000000000000000000000B5
65005+:10CB800000000000000000000000000000000000A5
65006+:10CB90000000000000000000000000000000000095
65007+:10CBA0000000000000000000000000000000000085
65008+:10CBB0000000000000000000000000000000000075
65009+:10CBC0000000000000000000000000000000000065
65010+:10CBD0000000000000000000000000000000000055
65011+:10CBE0000000000000000000000000000000000045
65012+:10CBF0000000000000000000000000000000000035
65013+:10CC00000000000000000000000000000000000024
65014+:10CC10000000000000000000000000000000000014
65015+:10CC20000000000000000000000000000000000004
65016+:10CC300000000000000000000000000000000000F4
65017+:10CC400000000000000000000000000000000000E4
65018+:10CC500000000000000000000000000000000000D4
65019+:10CC600000000000000000000000000000000000C4
65020+:10CC700000000000000000000000000000000000B4
65021+:10CC800000000000000000000000000000000000A4
65022+:10CC90000000000000000000000000000000000094
65023+:10CCA0000000000000000000000000000000000084
65024+:10CCB0000000000000000000000000000000000074
65025+:10CCC0000000000000000000000000000000000064
65026+:10CCD0000000000000000000000000000000000054
65027+:10CCE0000000000000000000000000000000000044
65028+:10CCF0000000000000000000000000000000000034
65029+:10CD00000000000000000000000000000000000023
65030+:10CD10000000000000000000000000000000000013
65031+:10CD20000000000000000000000000000000000003
65032+:10CD300000000000000000000000000000000000F3
65033+:10CD400000000000000000000000000000000000E3
65034+:10CD500000000000000000000000000000000000D3
65035+:10CD600000000000000000000000000000000000C3
65036+:10CD700000000000000000000000000000000000B3
65037+:10CD800000000000000000000000000000000000A3
65038+:10CD90000000000000000000000000000000000093
65039+:10CDA0000000000000000000000000000000000083
65040+:10CDB0000000000000000000000000000000000073
65041+:10CDC0000000000000000000000000000000000063
65042+:10CDD0000000000000000000000000000000000053
65043+:10CDE0000000000000000000000000000000000043
65044+:10CDF0000000000000000000000000000000000033
65045+:10CE00000000000000000000000000000000000022
65046+:10CE10000000000000000000000000000000000012
65047+:10CE20000000000000000000000000000000000002
65048+:10CE300000000000000000000000000000000000F2
65049+:10CE400000000000000000000000000000000000E2
65050+:10CE500000000000000000000000000000000000D2
65051+:10CE600000000000000000000000000000000000C2
65052+:10CE700000000000000000000000000000000000B2
65053+:10CE800000000000000000000000000000000000A2
65054+:10CE90000000000000000000000000000000000092
65055+:10CEA0000000000000000000000000000000000082
65056+:10CEB0000000000000000000000000000000000072
65057+:10CEC0000000000000000000000000000000000062
65058+:10CED0000000000000000000000000000000000052
65059+:10CEE0000000000000000000000000000000000042
65060+:10CEF0000000000000000000000000000000000032
65061+:10CF00000000000000000000000000000000000021
65062+:10CF10000000000000000000000000000000000011
65063+:10CF20000000000000000000000000000000000001
65064+:10CF300000000000000000000000000000000000F1
65065+:10CF400000000000000000000000000000000000E1
65066+:10CF500000000000000000000000000000000000D1
65067+:10CF600000000000000000000000000000000000C1
65068+:10CF700000000000000000000000000000000000B1
65069+:10CF800000000000000000000000000000000000A1
65070+:10CF90000000000000000000000000000000000091
65071+:10CFA0000000000000000000000000000000000081
65072+:10CFB0000000000000000000000000000000000071
65073+:10CFC0000000000000000000000000000000000061
65074+:10CFD0000000000000000000000000000000000051
65075+:10CFE0000000000000000000000000000000000041
65076+:10CFF0000000000000000000000000000000000031
65077+:10D000000000000000000000000000000000000020
65078+:10D010000000000000000000000000000000000010
65079+:10D020000000000000000000000000000000000000
65080+:10D0300000000000000000000000000000000000F0
65081+:10D0400000000000000000000000000000000000E0
65082+:10D0500000000000000000000000000000000000D0
65083+:10D0600000000000000000000000000000000000C0
65084+:10D0700000000000000000000000000000000000B0
65085+:10D0800000000000000000000000000000000000A0
65086+:10D090000000000000000000000000000000000090
65087+:10D0A0000000000000000000000000000000000080
65088+:10D0B0000000000000000000000000000000000070
65089+:10D0C0000000000000000000000000000000000060
65090+:10D0D0000000000000000000000000000000000050
65091+:10D0E0000000000000000000000000000000000040
65092+:10D0F0000000000000000000000000000000000030
65093+:10D10000000000000000000000000000000000001F
65094+:10D11000000000000000000000000000000000000F
65095+:10D1200000000000000000000000000000000000FF
65096+:10D1300000000000000000000000000000000000EF
65097+:10D1400000000000000000000000000000000000DF
65098+:10D1500000000000000000000000000000000000CF
65099+:10D1600000000000000000000000000000000000BF
65100+:10D1700000000000000000000000000000000000AF
65101+:10D18000000000000000000000000000000000009F
65102+:10D19000000000000000000000000000000000008F
65103+:10D1A000000000000000000000000000000000007F
65104+:10D1B000000000000000000000000000000000006F
65105+:10D1C000000000000000000000000000000000005F
65106+:10D1D000000000000000000000000000000000004F
65107+:10D1E000000000000000000000000000000000003F
65108+:10D1F000000000000000000000000000000000002F
65109+:10D20000000000000000000000000000000000001E
65110+:10D21000000000000000000000000000000000000E
65111+:10D2200000000000000000000000000000000000FE
65112+:10D2300000000000000000000000000000000000EE
65113+:10D2400000000000000000000000000000000000DE
65114+:10D2500000000000000000000000000000000000CE
65115+:10D2600000000000000000000000000000000000BE
65116+:10D2700000000000000000000000000000000000AE
65117+:10D28000000000000000000000000000000000009E
65118+:10D29000000000000000000000000000000000008E
65119+:10D2A000000000000000000000000000000000007E
65120+:10D2B000000000000000000000000000000000006E
65121+:10D2C000000000000000000000000000000000005E
65122+:10D2D000000000000000000000000000000000004E
65123+:10D2E000000000000000000000000000000000003E
65124+:10D2F000000000000000000000000000000000002E
65125+:10D30000000000000000000000000000000000001D
65126+:10D31000000000000000000000000000000000000D
65127+:10D3200000000000000000000000000000000000FD
65128+:10D3300000000000000000000000000000000000ED
65129+:10D3400000000000000000000000000000000000DD
65130+:10D3500000000000000000000000000000000000CD
65131+:10D3600000000000000000000000000000000000BD
65132+:10D3700000000000000000000000000000000000AD
65133+:10D38000000000000000000000000000000000009D
65134+:10D39000000000000000000000000000000000008D
65135+:10D3A000000000000000000000000000000000007D
65136+:10D3B000000000000000000000000000000000006D
65137+:10D3C000000000000000000000000000000000005D
65138+:10D3D000000000000000000000000000000000004D
65139+:10D3E000000000000000000000000000000000003D
65140+:10D3F000000000000000000000000000000000002D
65141+:10D40000000000000000000000000000000000001C
65142+:10D41000000000000000000000000000000000000C
65143+:10D4200000000000000000000000000000000000FC
65144+:10D4300000000000000000000000000000000000EC
65145+:10D4400000000000000000000000000000000000DC
65146+:10D4500000000000000000000000000000000000CC
65147+:10D4600000000000000000000000000000000000BC
65148+:10D4700000000000000000000000000000000000AC
65149+:10D48000000000000000000000000000000000009C
65150+:10D49000000000000000000000000000000000008C
65151+:10D4A000000000000000000000000000000000007C
65152+:10D4B000000000000000000000000000000000006C
65153+:10D4C000000000000000000000000000000000005C
65154+:10D4D000000000000000000000000000000000004C
65155+:10D4E000000000000000000000000000000000003C
65156+:10D4F000000000000000000000000000000000002C
65157+:10D50000000000000000000000000000000000001B
65158+:10D51000000000000000000000000000000000000B
65159+:10D5200000000000000000000000000000000000FB
65160+:10D5300000000000000000000000000000000000EB
65161+:10D5400000000000000000000000000000000000DB
65162+:10D5500000000000000000000000000000000000CB
65163+:10D5600000000000000000000000000000000000BB
65164+:10D5700000000000000000000000000000000000AB
65165+:10D58000000000000000000000000000000000009B
65166+:10D59000000000000000008000000000000000000B
65167+:10D5A000000000000000000000000000000000007B
65168+:10D5B00000000000000000000000000A0000000061
65169+:10D5C0000000000000000000100000030000000048
65170+:10D5D0000000000D0000000D3C02080024427340D2
65171+:10D5E0003C030800246377CCAC4000000043202BB0
65172+:10D5F0001480FFFD244200043C1D080037BD7FFC61
65173+:10D6000003A0F0213C100800261032103C1C08003A
65174+:10D61000279C73400E0010FE000000000000000D6B
65175+:10D6200030A5FFFF30C600FF274301808F4201B8BD
65176+:10D630000440FFFE24020002AC640000A465000860
65177+:10D64000A066000AA062000B3C021000AC67001844
65178+:10D6500003E00008AF4201B83C0360008C624FF861
65179+:10D660000440FFFE3C020200AC644FC0AC624FC4F9
65180+:10D670003C02100003E00008AC624FF89482000CFA
65181+:10D680002486001400A0382100021302000210803A
65182+:10D690000082402100C8102B1040005700000000FD
65183+:10D6A00090C300002C6200095040005190C200015C
65184+:10D6B000000310803C030800246372F00043102133
65185+:10D6C0008C420000004000080000000090C30001F0
65186+:10D6D0002402000A1462003A000000000106102330
65187+:10D6E0002C42000A1440003624C600028CE20000DE
65188+:10D6F00034420100ACE2000090C2000090C300017F
65189+:10D7000090C4000290C5000300031C000002160034
65190+:10D710000043102500042200004410250045102578
65191+:10D7200024C60004ACE2000490C2000090C30001D3
65192+:10D7300090C4000290C500030002160000031C0004
65193+:10D740000043102500042200004410250045102548
65194+:10D7500024C600040A000CB8ACE2000890C3000123
65195+:10D76000240200041462001624C6000290C20000C5
65196+:10D7700090C400018CE30000000212000044102558
65197+:10D780003463000424C60002ACE2000C0A000CB8AA
65198+:10D79000ACE3000090C300012402000314620008FF
65199+:10D7A00024C600028CE2000090C3000024C60001E1
65200+:10D7B00034420008A0E300100A000CB8ACE20000FC
65201+:10D7C00003E000082402000190C3000124020002CB
65202+:10D7D0001062000224C40002010020210A000CB8DB
65203+:10D7E000008030210A000CB824C6000190C200015C
65204+:10D7F0000A000CB800C2302103E00008000010212C
65205+:10D8000027BDFFE8AFBF0014AFB000100E00130239
65206+:10D8100000808021936200052403FFFE0200202186
65207+:10D82000004310248FBF00148FB00010A3620005C6
65208+:10D830000A00130B27BD001827BDFFE8AFB000108A
65209+:10D84000AFBF00140E000F3C0080802193620000E7
65210+:10D8500024030050304200FF14430004240201005E
65211+:10D86000AF4201800A000D3002002021AF4001804C
65212+:10D87000020020218FBF00148FB000100A000FE7B4
65213+:10D8800027BD001827BDFF80AFBE0078AFB700747A
65214+:10D89000AFB20060AFBF007CAFB60070AFB5006C38
65215+:10D8A000AFB40068AFB30064AFB1005CAFB0005874
65216+:10D8B0008F5001283C0208008C4231A02403FF80D5
65217+:10D8C0009365003F0202102100431024AF42002460
65218+:10D8D0003C0208008C4231A09364000530B200FF86
65219+:10D8E000020210213042007F034218210004202749
65220+:10D8F0003C02000A0062182130840001AF8300144A
65221+:10D900000000F0210000B82114800053AFA00050A7
65222+:10D9100093430116934401128F450104306300FFC5
65223+:10D920003C020001308400FF00A2282403431021A0
65224+:10D9300003441821245640002467400014A001CD60
65225+:10D940002402000193620000304300FF2402002003
65226+:10D950001062000524020050106200060000000062
65227+:10D960000A000D74000000000000000D0A000D7D8B
65228+:10D97000AFA000303C1E080027DE738C0A000D7D2E
65229+:10D98000AFA000303C0208008C4200DC24420001C1
65230+:10D990003C010800AC2200DC0E00139F00000000D8
65231+:10D9A0000A000F318FBF007C8F4201043C0300202E
65232+:10D9B00092D3000D004310240002202B00042140CC
65233+:10D9C000AFA400308F4301043C02004000621824E1
65234+:10D9D000146000023485004000802821326200205B
65235+:10D9E000AFA500301440000234A6008000A0302112
65236+:10D9F00010C0000BAFA6003093C500088F67004C25
65237+:10DA00000200202100052B0034A5008130A5F08103
65238+:10DA10000E000C9B30C600FF0A000F2E0000000015
65239+:10DA20009362003E304200401040000F2402000488
65240+:10DA300056420007240200120200202100E02821A3
65241+:10DA40000E0013F702C030210A000F318FBF007C97
65242+:10DA500016420005000000000E000D2100002021EC
65243+:10DA60000A000F318FBF007C9743011A96C4000E45
65244+:10DA700093620035326500043075FFFF00442004D6
65245+:10DA8000AFA400548ED1000410A000158ED400085D
65246+:10DA90009362003E3042004010400007000000004A
65247+:10DAA0000E0013E0022020211040000D00000000B5
65248+:10DAB0000A000F2E000000008F6200440222102393
65249+:10DAC0000440016A000000008F6200480222102317
65250+:10DAD00004410166240400160A000E218FC20004CE
65251+:10DAE0008F6200480222102304400008000000005A
65252+:10DAF0003C0208008C423100244200013C01080035
65253+:10DB0000AC2231000A000F23000000008F620040A9
65254+:10DB100002221023184000128F8400143C020800D7
65255+:10DB20008C423100327300FC0000A8212442000125
65256+:10DB30003C010800AC2231008F6300409482011C3C
65257+:10DB4000022318233042FFFF0043102A50400010E8
65258+:10DB50002402000C8F6200400A000DF20222102302
65259+:10DB60009483011C9762003C0043102B1040000678
65260+:10DB7000000000009482011C00551023A482011CA7
65261+:10DB80000A000DF72402000CA480011C2402000CE2
65262+:10DB9000AFA200308F620040005120231880000D9A
65263+:10DBA00002A4102A1440012600000000149500066B
65264+:10DBB00002A410233A620001304200011440012007
65265+:10DBC0000000000002A41023022488210A000E098C
65266+:10DBD0003055FFFF00002021326200021040001A81
65267+:10DBE000326200109362003E30420040504000110B
65268+:10DBF0008FC200040E00130202002021240200182C
65269+:10DC0000A362003F936200052403FFFE020020216F
65270+:10DC1000004310240E00130BA362000524040039F6
65271+:10DC2000000028210E0013C9240600180A000F3036
65272+:10DC300024020001240400170040F809000000003D
65273+:10DC40000A000F302402000110400108000000000B
65274+:10DC50008F63004C8F620054028210231C4001032A
65275+:10DC600002831023044200010060A021AFA4001829
65276+:10DC7000AFB10010AFB50014934201208F65004092
65277+:10DC80009763003C304200FF034210210044102102
65278+:10DC90008FA400543063FFFF244240000083182B00
65279+:10DCA0008FA40030AFA20020AFA50028008320255C
65280+:10DCB000AFA40030AFA50024AFA0002CAFB4003457
65281+:10DCC0009362003E30420008504000118FC20000B5
65282+:10DCD00002C0202127A500380E000CB2AFA00038EA
65283+:10DCE0005440000B8FC200008FA200383042010068
65284+:10DCF000504000078FC200008FA3003C8F6200607D
65285+:10DD00000062102304430001AF6300608FC2000073
65286+:10DD10000040F80927A400108FA200303042000212
65287+:10DD200054400001327300FE9362003E30420040D6
65288+:10DD3000104000378FA200248F6200541682001A10
65289+:10DD40003262000124020014124200102A4200151F
65290+:10DD500010400006240200162402000C12420007A4
65291+:10DD6000326200010A000E7D000000001242000530
65292+:10DD7000326200010A000E7D000000000A000E78E9
65293+:10DD80002417000E0A000E78241700100A000E7CDB
65294+:10DD900024170012936200232403FFBD00431024C4
65295+:10DDA000A362002332620001104000198FA20024F8
65296+:10DDB0002402000C1242000E2A42000D1040000600
65297+:10DDC0002402000E2402000A124200078FA200243F
65298+:10DDD0000A000E9524420001124200088FA200247E
65299+:10DDE0000A000E95244200010A000E932417000831
65300+:10DDF0002402000E16E20002241700162417001059
65301+:10DE00008FA2002424420001AFA200248FA200248C
65302+:10DE10008FA300148F76004000431021AF620040B2
65303+:10DE20008F8200149442011C104000090000000081
65304+:10DE30008F6200488F6400409763003C00441023C9
65305+:10DE40003063FFFF0043102A104000088FA20054E7
65306+:10DE5000936400368F6300403402FFFC008210049C
65307+:10DE600000621821AF6300488FA200548FA60030D3
65308+:10DE70000282902130C200081040000E0000000015
65309+:10DE80008F6200581642000430C600FF9742011A04
65310+:10DE90005040000134C6001093C500088FA700341D
65311+:10DEA0000200202100052B0034A500800E000C9BF1
65312+:10DEB00030A5F0808F620040005610231840001BF0
65313+:10DEC0008FA200183C0208008C42319830420010AA
65314+:10DED0001040000D24020001976200681440000AFF
65315+:10DEE000240200018F8200149442011C1440000699
65316+:10DEF00024020001A76200689742007A244200646D
65317+:10DF00000A000EE9A7620012A76200120E001302B7
65318+:10DF1000020020219362007D2403000102002021E1
65319+:10DF2000344200010A000EE7AFA300501840000A77
65320+:10DF3000000000000E001302020020219362007D09
65321+:10DF40002403000102002021AFA30050344200044A
65322+:10DF50000E00130BA362007D9362003E304200402E
65323+:10DF60001440000C326200011040000A0000000062
65324+:10DF70008F6300408FC20004240400182463000152
65325+:10DF80000040F809AF6300408FA200300A000F3054
65326+:10DF9000304200048F620058105200100000000050
65327+:10DFA0008F620018022210231C4000082404000184
65328+:10DFB0008F62001816220009000000008F62001C0A
65329+:10DFC000028210230440000500000000AF720058D8
65330+:10DFD000AFA40050AF710018AF74001C12E0000B2A
65331+:10DFE0008FA200500E00130202002021A377003FF1
65332+:10DFF0000E00130B0200202102E030212404003720
65333+:10E000000E0013C9000028218FA200501040000309
65334+:10E01000000000000E000CA90200202112A0000543
65335+:10E02000000018218FA2003030420004504000113F
65336+:10E0300000601021240300010A000F30006010214D
65337+:10E040000E001302020020219362007D02002021B5
65338+:10E05000344200040E00130BA362007D0E000CA9D5
65339+:10E06000020020210A000F3024020001AF400044CA
65340+:10E07000240200018FBF007C8FBE00788FB7007430
65341+:10E080008FB600708FB5006C8FB400688FB30064DA
65342+:10E090008FB200608FB1005C8FB0005803E00008C1
65343+:10E0A00027BD00808F4201B80440FFFE2402080013
65344+:10E0B000AF4201B803E00008000000003C02000885
65345+:10E0C00003421021944200483084FFFF2484001250
65346+:10E0D0003045FFFF10A0001700A4102B10400016C1
65347+:10E0E00024020003934201202403001AA343018B5E
65348+:10E0F000304200FF2446FFFE8F82000000A6182B4E
65349+:10E100003863000100021382004310241040000510
65350+:10E110008F84000434820001A746019403E00008C4
65351+:10E12000AF8200042402FFFE0082102403E00008F6
65352+:10E13000AF8200042402000303E00008A342018B25
65353+:10E1400027BDFFE0AFB10014AFB00010AFBF0018A3
65354+:10E1500030B0FFFF30D1FFFF8F4201B80440FFFE17
65355+:10E1600000000000AF440180AF4400200E000F42C9
65356+:10E17000020020218F8300008F840004A750019AA1
65357+:10E18000A750018EA74301908F8300083082800042
65358+:10E19000AF4301A8A75101881040000E8F820004F0
65359+:10E1A00093420116304200FC24420004005A102120
65360+:10E1B0008C4240003042FFFF144000068F82000472
65361+:10E1C0003C02FFFF34427FFF00821024AF82000434
65362+:10E1D0008F8200042403BFFF00431024A74201A63E
65363+:10E1E0009743010C8F42010400031C003042FFFFE3
65364+:10E1F00000621825AF4301AC3C021000AF4201B8E9
65365+:10E200008FBF00188FB100148FB0001003E000081A
65366+:10E2100027BD00208F470070934201128F830000BA
65367+:10E2200027BDFFF0304200FF00022882306201006B
65368+:10E23000000030211040004324A40003306240005D
65369+:10E24000104000103062200000041080005A10219D
65370+:10E250008C43400024A4000400041080AFA30000FD
65371+:10E26000005A10218C424000AFA2000493420116D4
65372+:10E27000304200FC005A10218C4240000A000FC0BE
65373+:10E28000AFA200081040002F0000302100041080D1
65374+:10E29000005A10218C43400024A400040004108084
65375+:10E2A000AFA30000005A10218C424000AFA000082C
65376+:10E2B000AFA200048FA80008000030210000202138
65377+:10E2C000240A00083C0908002529010003A41021A4
65378+:10E2D000148A000300042A001100000A0000000054
65379+:10E2E00090420000248400012C83000C00A2102125
65380+:10E2F00000021080004910218C4200001460FFF3DE
65381+:10E3000000C230263C0408008C8431048F42007027
65382+:10E310002C83002010600009004738233C030800CC
65383+:10E32000246331080004108000431021248300017D
65384+:10E33000AC4700003C010800AC233104AF86000864
65385+:10E340002406000100C0102103E0000827BD0010D2
65386+:10E350003C0208008C42003827BDFFD0AFB5002436
65387+:10E36000AFB40020AFB10014AFBF0028AFB3001CA2
65388+:10E37000AFB20018AFB00010000088213C150800B3
65389+:10E3800026B50038144000022454FFFF0000A021ED
65390+:10E390009742010E8F8400003042FFFF308340001F
65391+:10E3A0001060000A245200043C0200200082102465
65392+:10E3B00050400007308280008F8200042403BFFF9A
65393+:10E3C000008318240A0010103442100030828000AC
65394+:10E3D0001040000A3C020020008210241040000778
65395+:10E3E0008F8200043C03FFFF34637FFF0083182407
65396+:10E3F00034428000AF820004AF8300000E000F980B
65397+:10E400000000000014400007000000009743011EB8
65398+:10E410009742011C3063FFFF0002140000621825C0
65399+:10E42000AF8300089742010C8F4340003045FFFF47
65400+:10E430003402FFFF14620003000000000A001028ED
65401+:10E44000241100208F42400030420100544000015E
65402+:10E45000241100108F8400003082100050400014FE
65403+:10E4600036310001308200201440000B3C021000C5
65404+:10E47000008210245040000E363100013C030E0093
65405+:10E480003C020DFF008318243442FFFF0043102B91
65406+:10E4900050400007363100013C0208008C42002C3D
65407+:10E4A000244200013C010800AC22002C363100055A
65408+:10E4B0003C0608008CC6003454C000238F85000041
65409+:10E4C0008F820004304240005440001F8F850000BE
65410+:10E4D0003C021F01008210243C0310005443001A28
65411+:10E4E0008F85000030A20200144000178F850000C5
65412+:10E4F0003250FFFF363100028F4201B80440FFFE68
65413+:10E5000000000000AF400180020020210E000F42F9
65414+:10E51000AF4000208F8300042402BFFFA750019A60
65415+:10E52000006218248F820000A750018EA751018835
65416+:10E53000A74301A6A74201903C021000AF4201B8D8
65417+:10E540000A0010F5000010213C02100000A2102467
65418+:10E550001040003A0000000010C0000F0000000052
65419+:10E5600030A201001040000C3C0302003C020F00EE
65420+:10E5700000A2102410430008000000008F82000851
65421+:10E58000005410240055102190420004244200043D
65422+:10E590000A00109F000221C00000000000051602C2
65423+:10E5A0003050000F3A0300022E4203EF38420001C0
65424+:10E5B0002C6300010062182414600073240200011F
65425+:10E5C0003C0308008C6300D02E06000C386200016A
65426+:10E5D0002C4200010046102414400015001021C0F8
65427+:10E5E0002602FFFC2C4200045440001100002021B0
65428+:10E5F000386200022C420001004610241040000343
65429+:10E60000000512420A00109F000020210010182B64
65430+:10E610000043102450400006001021C000002021BB
65431+:10E620003245FFFF0E000F633226FFFB001021C0B2
65432+:10E630003245FFFF0A0010F2362600028F424000EA
65433+:10E640003C0308008C630024304201001040004667
65434+:10E6500030620001322200043070000D14400002CC
65435+:10E660002413000424130002000512C238420001E2
65436+:10E670002E4303EF304200013863000100431025B0
65437+:10E68000104000033231FFFB2402FFFB0202802412
65438+:10E6900010C000183202000130A201001040001525
65439+:10E6A000320200013C020F0000A210243C030200D1
65440+:10E6B0001043000F8F8200082403FFFE0203802412
65441+:10E6C00000541024005510219042000402333025DC
65442+:10E6D0002442000412000002000221C03226FFFF83
65443+:10E6E0000E000F633245FFFF1200002700001021CB
65444+:10E6F000320200011040000D320200042402000129
65445+:10E7000012020002023330253226FFFF00002021D2
65446+:10E710000E000F633245FFFF2402FFFE0202802439
65447+:10E7200012000019000010213202000410400016EF
65448+:10E7300024020001240200041202000202333025E8
65449+:10E740003226FFFF3245FFFF0E000F632404010055
65450+:10E750002402FFFB020280241200000B00001021A3
65451+:10E760000A0010F5240200011040000700001021EB
65452+:10E770003245FFFF36260002000020210E000F6305
65453+:10E7800000000000000010218FBF00288FB500247A
65454+:10E790008FB400208FB3001C8FB200188FB100140B
65455+:10E7A0008FB0001003E0000827BD003027BDFFD068
65456+:10E7B000AFB000103C04600CAFBF002CAFB6002817
65457+:10E7C000AFB50024AFB40020AFB3001CAFB2001847
65458+:10E7D000AFB100148C8250002403FF7F3C1A8000EC
65459+:10E7E000004310243442380CAC8250002402000351
65460+:10E7F0003C106000AF4200088E0208083C1B8008F5
65461+:10E800003C010800AC2000203042FFF038420010EC
65462+:10E810002C4200010E001B8DAF8200183C04FFFF4C
65463+:10E820003C020400348308063442000CAE0219484E
65464+:10E83000AE03194C3C0560168E0219808CA30000B3
65465+:10E840003442020000641824AE0219803C02535383
65466+:10E850001462000334A47C008CA200040050202128
65467+:10E860008C82007C8C830078AF820010AF83000C18
65468+:10E870008F55000032A200031040FFFD32A20001BC
65469+:10E880001040013D32A200028F420128AF42002019
65470+:10E890008F4201048F430100AF8200000E000F3C45
65471+:10E8A000AF8300043C0208008C4200C01040000806
65472+:10E8B0008F8400003C0208008C4200C42442000106
65473+:10E8C0003C010800AC2200C40A00126900000000EC
65474+:10E8D0003C020010008210241440010C8F830004BD
65475+:10E8E0003C0208008C4200203C0308008C63003886
65476+:10E8F00000008821244200013C010800AC220020D5
65477+:10E900003C16080026D60038146000022474FFFF6D
65478+:10E910000000A0219742010E308340003042FFFFEB
65479+:10E920001060000A245200043C02002000821024DF
65480+:10E9300050400007308280008F8200042403BFFF14
65481+:10E94000008318240A0011703442100030828000C5
65482+:10E950001040000A3C0200200082102410400007F2
65483+:10E960008F8200043C03FFFF34637FFF0083182481
65484+:10E9700034428000AF820004AF8300000E000F9885
65485+:10E980000000000014400007000000009743011E33
65486+:10E990009742011C3063FFFF00021400006218253B
65487+:10E9A000AF8300089742010C8F4340003045FFFFC2
65488+:10E9B0003402FFFF14620003000000000A00118807
65489+:10E9C000241100208F4240003042010054400001D9
65490+:10E9D000241100108F840000308210005040001479
65491+:10E9E00036310001308200201440000B3C02100040
65492+:10E9F000008210245040000E363100013C030E000E
65493+:10EA00003C020DFF008318243442FFFF0043102B0B
65494+:10EA100050400007363100013C0208008C42002CB7
65495+:10EA2000244200013C010800AC22002C36310005D4
65496+:10EA30003C0608008CC6003454C000238F850000BB
65497+:10EA40008F820004304240005440001F8F85000038
65498+:10EA50003C021F01008210243C0310005443001AA2
65499+:10EA60008F85000030A20200144000178F8500003F
65500+:10EA70003250FFFF363100028F4201B80440FFFEE2
65501+:10EA800000000000AF400180020020210E000F4274
65502+:10EA9000AF4000208F8300042402BFFFA750019ADB
65503+:10EAA000006218248F820000A750018EA7510188B0
65504+:10EAB000A74301A6A74201903C021000AF4201B853
65505+:10EAC0000A001267000010213C02100000A210246E
65506+:10EAD0001040003A0000000010C0000F00000000CD
65507+:10EAE00030A201001040000C3C0302003C020F0069
65508+:10EAF00000A2102410430008000000008F820008CC
65509+:10EB000000541024005610219042000424420004B6
65510+:10EB10000A0011FF000221C00000000000051602DB
65511+:10EB20003050000F3A0300022E4203EF384200013A
65512+:10EB30002C63000100621824146000852402000187
65513+:10EB40003C0308008C6300D02E06000C38620001E4
65514+:10EB50002C4200010046102414400015001021C072
65515+:10EB60002602FFFC2C42000454400011000020212A
65516+:10EB7000386200022C42000100461024504000037D
65517+:10EB8000000512420A0011FF000020210010182B7E
65518+:10EB90000043102450400006001021C00000202136
65519+:10EBA0003245FFFF0E000F633226FFFB001021C02D
65520+:10EBB0003245FFFF0A001252362600028F42400003
65521+:10EBC0003C0308008C6300243042010010400046E2
65522+:10EBD00030620001322200043070000D1440000247
65523+:10EBE0002413000424130002000512C2384200015D
65524+:10EBF0002E4303EF3042000138630001004310252B
65525+:10EC0000104000033231FFFB2402FFFB020280248C
65526+:10EC100010C000183202000130A20100104000159F
65527+:10EC2000320200013C020F0000A210243C0302004B
65528+:10EC30001043000F8F8200082403FFFE020380248C
65529+:10EC40000054102400561021904200040233302555
65530+:10EC50002442000412000002000221C03226FFFFFD
65531+:10EC60000E000F633245FFFF120000390000102133
65532+:10EC7000320200011040000D3202000424020001A3
65533+:10EC800012020002023330253226FFFF000020214D
65534+:10EC90000E000F633245FFFF2402FFFE02028024B4
65535+:10ECA0001200002B00001021320200041040002846
65536+:10ECB0002402000124020004120200020233302563
65537+:10ECC0003226FFFF3245FFFF0E000F6324040100D0
65538+:10ECD0002402FFFB020280241200001D000010210C
65539+:10ECE0000A001267240200015040001900001021A0
65540+:10ECF0003245FFFF36260002000020210E000F6380
65541+:10ED0000000000000A001267000010212402BFFF6B
65542+:10ED1000006210241040000800000000240287FF59
65543+:10ED200000621024144000083C020060008210249D
65544+:10ED300010400005000000000E000D34000000002F
65545+:10ED40000A001267000000000E0012C70000000059
65546+:10ED5000104000063C0240008F4301243C0260202A
65547+:10ED6000AC430014000000003C024000AF420138F8
65548+:10ED70000000000032A200021040FEBD00000000B2
65549+:10ED80008F4201403C044000AF4200208F430148C5
65550+:10ED90003C02700000621824106400420000000071
65551+:10EDA0000083102B144000063C0260003C0220004F
65552+:10EDB000106200073C0240000A0012C3000000007D
65553+:10EDC0001062003C3C0240000A0012C30000000038
65554+:10EDD0008F4501408F4601448F42014800021402D2
65555+:10EDE000304300FF240200041462000A274401801B
65556+:10EDF0008F4201B80440FFFE2402001CAC850000D5
65557+:10EE0000A082000B3C021000AF4201B80A0012C3FE
65558+:10EE10003C0240002402000914620012000616029F
65559+:10EE2000000229C0AF4500208F4201B80440FFFE18
65560+:10EE30002402000124030003AF450180A343018B9A
65561+:10EE4000A740018EA740019AA7400190AF4001A8BA
65562+:10EE5000A7420188A74201A6AF4001AC3C021000C6
65563+:10EE6000AF4201B88F4201B80440FFFE000000002D
65564+:10EE7000AC8500008F42014800021402A482000801
65565+:10EE800024020002A082000B8F420148A4820010DD
65566+:10EE90003C021000AC860024AF4201B80A0012C345
65567+:10EEA0003C0240000E001310000000000A0012C3D4
65568+:10EEB0003C0240000E001BC2000000003C0240006B
65569+:10EEC000AF420178000000000A00112F000000008E
65570+:10EED0008F4201003042003E144000112402000124
65571+:10EEE000AF4000488F420100304207C0104000058B
65572+:10EEF00000000000AF40004CAF40005003E00008AD
65573+:10EF000024020001AF400054AF4000408F42010096
65574+:10EF10003042380054400001AF4000442402000158
65575+:10EF200003E00008000000008F4201B80440FFFE2B
65576+:10EF300024020001AF440180AF400184A74501884D
65577+:10EF4000A342018A24020002A342018B9742014A94
65578+:10EF500014C00004A7420190AF4001A40A0012EFC0
65579+:10EF60003C0210008F420144AF4201A43C02100059
65580+:10EF7000AF4001A803E00008AF4201B88F4201B8DA
65581+:10EF80000440FFFE24020002AF440180AF4401842C
65582+:10EF9000A7450188A342018AA342018B9742014AF7
65583+:10EFA000A7420190AF4001A48F420144AF4201A8A3
65584+:10EFB0003C02100003E00008AF4201B83C029000A0
65585+:10EFC0003442000100822025AF4400208F420020FF
65586+:10EFD0000440FFFE0000000003E000080000000005
65587+:10EFE0003C028000344200010082202503E000083A
65588+:10EFF000AF44002027BDFFE8AFBF0014AFB0001042
65589+:10F000008F50014093430149934201489344014882
65590+:10F01000306300FF304200FF00021200006228252A
65591+:10F020002402001910620076308400802862001AE1
65592+:10F030001040001C24020020240200081062007707
65593+:10F04000286200091040000E2402000B2402000177
65594+:10F0500010620034286200025040000524020006BD
65595+:10F0600050600034020020210A00139A00000000C2
65596+:10F0700010620030020020210A00139A00000000F4
65597+:10F080001062003B2862000C504000022402000E77
65598+:10F090002402000910620056020020210A00139A7F
65599+:10F0A0000000000010620056286200211040000F8E
65600+:10F0B000240200382402001C106200582862001D3F
65601+:10F0C000104000062402001F2402001B1062004CA6
65602+:10F0D000000000000A00139A000000001062004ABD
65603+:10F0E000020020210A00139A00000000106200456F
65604+:10F0F0002862003910400007240200802462FFCB00
65605+:10F100002C42000210400045020020210A00139604
65606+:10F110000000302110620009000000000A00139A6C
65607+:10F12000000000001480003D020020210A0013901E
65608+:10F130008FBF00140A001396240600018F4201B805
65609+:10F140000440FFFE24020002A342018BA745018870
65610+:10F150009742014AA74201908F420144A74201927F
65611+:10F160003C021000AF4201B80A00139C8FBF00148C
65612+:10F170009742014A144000290000000093620005F4
65613+:10F180003042000414400025000000000E0013026D
65614+:10F190000200202193620005020020213442000475
65615+:10F1A0000E00130BA36200059362000530420004B9
65616+:10F1B00014400002000000000000000D93620000F7
65617+:10F1C00024030020304200FF14430014000000001C
65618+:10F1D0008F4201B80440FFFE24020005AF500180B9
65619+:10F1E000A342018B3C0210000A00139AAF4201B8FF
65620+:10F1F0008FBF00148FB000100A0012F227BD001854
65621+:10F200000000000D02002021000030218FBF0014FB
65622+:10F210008FB000100A0012DD27BD00180000000D9D
65623+:10F220008FBF00148FB0001003E0000827BD001846
65624+:10F2300027BDFFE8AFBF00100E000F3C000000002C
65625+:10F24000AF4001808FBF0010000020210A000FE7AF
65626+:10F2500027BD00183084FFFF30A5FFFF00001821F4
65627+:10F260001080000700000000308200011040000202
65628+:10F2700000042042006518210A0013AB0005284055
65629+:10F2800003E000080060102110C0000624C6FFFF44
65630+:10F290008CA2000024A50004AC8200000A0013B573
65631+:10F2A0002484000403E000080000000010A000080F
65632+:10F2B00024A3FFFFAC860000000000000000000057
65633+:10F2C0002402FFFF2463FFFF1462FFFA248400047A
65634+:10F2D00003E0000800000000308300FF30A500FFBD
65635+:10F2E00030C600FF274701808F4201B80440FFFE6F
65636+:10F2F000000000008F42012834634000ACE20000AF
65637+:10F3000024020001ACE00004A4E30008A0E2000A2B
65638+:10F3100024020002A0E2000B3C021000A4E5001051
65639+:10F32000ACE00024ACE00028A4E6001203E00008F2
65640+:10F33000AF4201B827BDFFE8AFBF00109362003FA6
65641+:10F3400024030012304200FF1043000D00803021E2
65642+:10F350008F620044008210230440000A8FBF001017
65643+:10F360008F620048240400390000282100C21023C5
65644+:10F3700004410004240600120E0013C9000000001E
65645+:10F380008FBF00102402000103E0000827BD001811
65646+:10F3900027BDFFC8AFB20030AFB1002CAFBF003403
65647+:10F3A000AFB0002890C5000D0080902130A400105F
65648+:10F3B0001080000B00C088218CC300088F620054AD
65649+:10F3C0001062000730A20005144000B524040001BB
65650+:10F3D0000E000D21000020210A0014BB0040202156
65651+:10F3E00030A200051040000930A30012108000ACCC
65652+:10F3F000240400018E2300088F620054146200A9C7
65653+:10F400008FBF00340A00142C240400382402001298
65654+:10F41000146200A3240400010220202127A500106B
65655+:10F420000E000CB2AFA000101040001102402021CD
65656+:10F430008E220008AF620084AF6000400E0013020D
65657+:10F44000000000009362007D024020213442002031
65658+:10F450000E00130BA362007D0E000CA902402021B8
65659+:10F46000240400382405008D0A0014B82406001274
65660+:10F470009362003E304200081040000F8FA200103F
65661+:10F4800030420100104000078FA300148F6200601B
65662+:10F490000062102304430008AF6300600A001441B7
65663+:10F4A00000000000AF6000609362003E2403FFF79D
65664+:10F4B00000431024A362003E9362003E30420008E5
65665+:10F4C000144000022406000300003021936200343F
65666+:10F4D000936300378F640084304200FF306300FF85
65667+:10F4E00000661821000318800043282100A4202B67
65668+:10F4F0001080000B000000009763003C8F620084C6
65669+:10F500003063FFFF004510230062182B14600004D5
65670+:10F51000000000008F6200840A00145D0045802313
65671+:10F520009762003C3050FFFF8FA300103062000450
65672+:10F5300010400004000628808FA2001C0A001465F9
65673+:10F540000202102B2E02021850400003240202185F
65674+:10F550000A00146E020510233063000410600003DB
65675+:10F56000004510238FA2001C00451023004080217D
65676+:10F570002C42008054400001241000800E00130231
65677+:10F580000240202124020001AF62000C9362003E81
65678+:10F59000001020403042007FA362003E8E22000413
65679+:10F5A00024420001AF620040A770003C8F6200500F
65680+:10F5B0009623000E00431021AF6200588F62005066
65681+:10F5C00000441021AF62005C8E220004AF6200187C
65682+:10F5D0008E220008AF62001C8FA20010304200088B
65683+:10F5E0005440000A93A20020A360003693620036C4
65684+:10F5F0002403FFDFA36200359362003E0043102422
65685+:10F60000A362003E0A0014988E220008A36200350F
65686+:10F610008E220008AF62004C8F6200248F6300408E
65687+:10F6200000431021AF6200489362000024030050A1
65688+:10F63000304200FF144300122403FF803C02080004
65689+:10F640008C4231A00242102100431024AF42002816
65690+:10F650003C0208008C4231A08E2400083C03000CC0
65691+:10F66000024210213042007F03421021004310214A
65692+:10F67000AC4400D88E230008AF820014AC4300DCF9
65693+:10F680000E00130B02402021240400380000282122
65694+:10F690002406000A0E0013C9000000002404000123
65695+:10F6A0008FBF00348FB200308FB1002C8FB0002894
65696+:10F6B0000080102103E0000827BD003827BDFFF8B7
65697+:10F6C00027420180AFA20000308A00FF8F4201B8BC
65698+:10F6D0000440FFFE000000008F4601283C020800A5
65699+:10F6E0008C4231A02403FF80AF86004800C2102165
65700+:10F6F00000431024AF4200243C0208008C4231A099
65701+:10F700008FA900008FA8000000C210213042007FA6
65702+:10F71000034218213C02000A00621821946400D4BC
65703+:10F720008FA700008FA5000024020002AF83001401
65704+:10F73000A0A2000B8FA30000354260003084FFFFC1
65705+:10F74000A4E200083C021000AD260000AD04000455
65706+:10F75000AC60002427BD0008AF4201B803E00008F8
65707+:10F76000240200018F88003C938200288F830014BC
65708+:10F770003C07080024E7779800481023304200FF38
65709+:10F78000304900FC246500888F860040304A000321
65710+:10F790001120000900002021248200048CA3000015
65711+:10F7A000304400FF0089102AACE3000024A50004C7
65712+:10F7B0001440FFF924E70004114000090000202153
65713+:10F7C0002482000190A30000304400FF008A102B27
65714+:10F7D000A0E3000024A500011440FFF924E7000184
65715+:10F7E00030C20003144000048F85003C3102000346
65716+:10F7F0001040000D0000000010A0000900002021B2
65717+:10F800002482000190C30000304400FF0085102BCB
65718+:10F81000A0E3000024C600011440FFF924E7000122
65719+:10F8200003E00008000000001100FFFD000020219F
65720+:10F83000248200048CC30000304400FF0088102B99
65721+:10F84000ACE3000024C600041440FFF924E70004E0
65722+:10F8500003E00008000000008F83003C9382002832
65723+:10F8600030C600FF30A500FF00431023304300FFE7
65724+:10F870008F820014008038210043102114C0000240
65725+:10F88000244800880083382130E20003144000053A
65726+:10F8900030A2000314400003306200031040000D4A
65727+:10F8A0000000000010A000090000202124820001B7
65728+:10F8B00090E30000304400FF0085102BA1030000FE
65729+:10F8C00024E700011440FFF92508000103E00008C7
65730+:10F8D0000000000010A0FFFD000020212482000491
65731+:10F8E0008CE30000304400FF0085102BAD030000C6
65732+:10F8F00024E700041440FFF92508000403E0000891
65733+:10F90000000000000080482130AAFFFF30C600FF41
65734+:10F9100030E7FFFF274801808F4201B80440FFFE17
65735+:10F920008F820048AD0200008F420124AD02000426
65736+:10F930008D220020A5070008A102000A240200165B
65737+:10F94000A102000B934301208D2200088D240004A6
65738+:10F95000306300FF004310219783003A00441021D8
65739+:10F960008D250024004310233C0308008C6331A044
65740+:10F970008F840014A502000C246300E82402FFFF1A
65741+:10F98000A50A000EA5030010A5060012AD0500187B
65742+:10F99000AD020024948201142403FFF73042FFFFDC
65743+:10F9A000AD0200288C820118AD02002C3C02100030
65744+:10F9B000AD000030AF4201B88D220020004310247A
65745+:10F9C00003E00008AD2200208F82001430E7FFFF23
65746+:10F9D00000804821904200D330A5FFFF30C600FFD1
65747+:10F9E0000002110030420F0000E238252748018054
65748+:10F9F0008F4201B80440FFFE8F820048AD02000034
65749+:10FA00008F420124AD0200048D220020A5070008CA
65750+:10FA1000A102000A24020017A102000B9343012057
65751+:10FA20008D2200088D240004306300FF0043102164
65752+:10FA30009783003A004410218F8400140043102360
65753+:10FA40003C0308008C6331A0A502000CA505000E44
65754+:10FA5000246300E8A5030010A5060012AD00001401
65755+:10FA60008D220024AD0200188C82005CAD02001CC7
65756+:10FA70008C820058AD0200202402FFFFAD0200245A
65757+:10FA8000948200E63042FFFFAD02002894820060BD
65758+:10FA9000948300BE30427FFF3063FFFF00021200FC
65759+:10FAA00000431021AD02002C3C021000AD000030DC
65760+:10FAB000AF4201B8948200BE2403FFF700A21021D8
65761+:10FAC000A48200BE8D2200200043102403E0000821
65762+:10FAD000AD220020274301808F4201B80440FFFE81
65763+:10FAE0008F8200249442001C3042FFFF000211C0AC
65764+:10FAF000AC62000024020019A062000B3C0210005E
65765+:10FB0000AC60003003E00008AF4201B88F87002CE2
65766+:10FB100030C300FF8F4201B80440FFFE8F820048CF
65767+:10FB200034636000ACA2000093820044A0A20005F0
65768+:10FB30008CE20010A4A20006A4A300088C8200207E
65769+:10FB40002403FFF7A0A2000A24020002A0A2000BD7
65770+:10FB50008CE20000ACA200108CE20004ACA2001405
65771+:10FB60008CE2001CACA200248CE20020ACA2002895
65772+:10FB70008CE2002CACA2002C8C820024ACA20018D9
65773+:10FB80003C021000AF4201B88C82002000431024D8
65774+:10FB900003E00008AC8200208F86001427BDFFE838
65775+:10FBA000AFBF0014AFB0001090C20063304200201D
65776+:10FBB0001040000830A500FF8CC2007C2403FFDF4A
65777+:10FBC00024420001ACC2007C90C2006300431024B8
65778+:10FBD000A0C2006310A000238F830014275001806F
65779+:10FBE000020028210E0015D6240600828F82001400
65780+:10FBF000904200633042004050400019A38000440E
65781+:10FC00008F83002C8F4201B80440FFFE8F82004892
65782+:10FC1000AE02000024026082A60200082402000254
65783+:10FC2000A202000B8C620008AE0200108C62000C75
65784+:10FC3000AE0200148C620014AE0200188C62001830
65785+:10FC4000AE0200248C620024AE0200288C620028E0
65786+:10FC5000AE02002C3C021000AF4201B8A380004469
65787+:10FC60008F8300148FBF00148FB000109062006368
65788+:10FC700027BD00183042007FA06200639782003ADF
65789+:10FC80008F86003C8F850014938300280046102344
65790+:10FC9000A782003AA4A000E490A400638F820040F1
65791+:10FCA000AF83003C2403FFBF0046102100832024C3
65792+:10FCB000AF820040A0A400638F820014A04000BD6A
65793+:10FCC0008F82001403E00008A44000BE8F8A001455
65794+:10FCD00027BDFFE0AFB10014AFB000108F88003C2B
65795+:10FCE000AFBF00189389001C954200E430D100FF9B
65796+:10FCF0000109182B0080802130AC00FF3047FFFF46
65797+:10FD00000000582114600003310600FF012030215B
65798+:10FD1000010958239783003A0068102B1440003CD7
65799+:10FD20000000000014680007240200018E02002079
65800+:10FD30002403FFFB34E7800000431024AE020020C0
65801+:10FD40002402000134E70880158200053165FFFFB9
65802+:10FD50000E001554020020210A00169102002021F5
65803+:10FD60000E001585020020218F8400482743018062
65804+:10FD70008F4201B80440FFFE24020018AC6400006A
65805+:10FD8000A062000B8F840014948200E6A46200102D
65806+:10FD90003C021000AC600030AF4201B894820060B9
65807+:10FDA00024420001A4820060948200603C030800A9
65808+:10FDB0008C63318830427FFF5443000F02002021C2
65809+:10FDC000948200602403800000431024A482006019
65810+:10FDD0009082006090830060304200FF000211C2F8
65811+:10FDE00000021027000211C03063007F0062182556
65812+:10FDF000A083006002002021022028218FBF00186C
65813+:10FE00008FB100148FB000100A0015F927BD002033
65814+:10FE1000914200632403FF8000431025A142006348
65815+:10FE20009782003A3048FFFF110000209383001CA6
65816+:10FE30008F840014004B1023304600FF948300E4AD
65817+:10FE40002402EFFF0168282B00621824A48300E439
65818+:10FE500014A000038E020020010058210000302170
65819+:10FE60002403FFFB34E7800000431024AE0200208F
65820+:10FE700024020001158200053165FFFF0E001554B4
65821+:10FE8000020020210A0016B99783003A0E0015855A
65822+:10FE9000020020219783003A8F82003CA780003A1D
65823+:10FEA00000431023AF82003C9383001C8F82001418
65824+:10FEB0008FBF00188FB100148FB0001027BD002035
65825+:10FEC00003E00008A04300BD938200442403000126
65826+:10FED00027BDFFE8004330042C420020AFB00010E3
65827+:10FEE000AFBF00142410FFFE10400005274501801D
65828+:10FEF0003C0208008C4231900A0016D600461024BD
65829+:10FF00003C0208008C423194004610241440000743
65830+:10FF1000240600848F8300142410FFFF9062006287
65831+:10FF20003042000F34420040A06200620E0015D63D
65832+:10FF300000000000020010218FBF00148FB00010DD
65833+:10FF400003E0000827BD00188F83002427BDFFE0D1
65834+:10FF5000AFB20018AFB10014AFB00010AFBF001CBB
65835+:10FF60009062000D00A0902130D100FF3042007F50
65836+:10FF7000A062000D8F8500148E4300180080802140
65837+:10FF80008CA2007C146200052402000E90A2006383
65838+:10FF9000344200200A0016FFA0A200630E0016C51E
65839+:10FFA000A38200442403FFFF104300472404FFFF03
65840+:10FFB00052200045000020218E4300003C0200102A
65841+:10FFC00000621024504000043C020008020020217E
65842+:10FFD0000A00170E24020015006210245040000988
65843+:10FFE0008E45000002002021240200140E0016C5D8
65844+:10FFF000A38200442403FFFF104300332404FFFFC7
65845+:020000021000EC
65846+:100000008E4500003C02000200A2102410400016A1
65847+:100010003C0200048F8600248CC200148CC30010A4
65848+:100020008CC40014004310230044102B50400005E2
65849+:10003000020020218E43002C8CC2001010620003AD
65850+:10004000020020210A00173F240200123C02000493
65851+:1000500000A210245040001C00002021020020219A
65852+:100060000A00173F2402001300A2102410400006CB
65853+:100070008F8300248C620010504000130000202168
65854+:100080000A001739020020218C6200105040000441
65855+:100090008E42002C020020210A00173F240200118A
65856+:1000A00050400009000020210200202124020017F6
65857+:1000B0000E0016C5A38200442403FFFF1043000274
65858+:1000C0002404FFFF000020218FBF001C8FB2001806
65859+:1000D0008FB100148FB000100080102103E00008E1
65860+:1000E00027BD00208F83001427BDFFD8AFB40020A8
65861+:1000F000AFB3001CAFB20018AFB10014AFB0001026
65862+:10010000AFBF0024906200638F91002C2412FFFF88
65863+:100110003442004092250000A06200638E2200104D
65864+:100120000080982130B0003F105200060360A021EB
65865+:100130002402000D0E0016C5A38200441052005484
65866+:100140002404FFFF8F8300148E2200188C63007C30
65867+:1001500010430007026020212402000E0E0016C585
65868+:10016000A38200442403FFFF104300492404FFFF3F
65869+:1001700024040020120400048F83001490620063A2
65870+:1001800034420020A06200638F85003410A000205C
65871+:1001900000000000560400048F8200140260202139
65872+:1001A0000A0017902402000A9683000A9442006015
65873+:1001B0003042FFFF144300048F8200202404FFFD1F
65874+:1001C0000A0017B7AF82003C3C0208008C42318C19
65875+:1001D0000045102B14400006026020210000282159
65876+:1001E0000E001646240600010A0017B70000202161
65877+:1001F0002402002D0E0016C5A38200442403FFFF35
65878+:10020000104300232404FFFF0A0017B70000202139
65879+:10021000160400058F8400148E2300142402FFFFAF
65880+:100220005062001802602021948200602442000184
65881+:10023000A4820060948200603C0308008C633188D3
65882+:1002400030427FFF5443000F0260202194820060FF
65883+:100250002403800000431024A48200609082006088
65884+:1002600090830060304200FF000211C2000210279C
65885+:10027000000211C03063007F00621825A083006077
65886+:10028000026020210E0015F9240500010000202144
65887+:100290008FBF00248FB400208FB3001C8FB20018D2
65888+:1002A0008FB100148FB000100080102103E000080F
65889+:1002B00027BD00288F83001427BDFFE8AFB00010D2
65890+:1002C000AFBF0014906200638F87002C00808021F4
65891+:1002D000344200408CE60010A06200633C0308003A
65892+:1002E0008C6331B030C23FFF0043102B1040004EF2
65893+:1002F0008F8500302402FF8090A3000D004310245E
65894+:10030000304200FF504000490200202100061382C5
65895+:10031000304800032402000255020044020020215C
65896+:1003200094A2001C8F85001424030023A4A20114AE
65897+:100330008CE60000000616023042003F1043001019
65898+:100340003C0300838CE300188CA2007C1062000642
65899+:100350002402000E0E0016C5A38200442403FFFFF2
65900+:10036000104300382404FFFF8F8300149062006361
65901+:1003700034420020A06200630A0017FC8F8300242F
65902+:1003800000C31024144300078F83002490A200624E
65903+:100390003042000F34420020A0A20062A38800383F
65904+:1003A0008F8300249062000D3042007FA062000D18
65905+:1003B0008F83003410600018020020218F840030E9
65906+:1003C0008C8200100043102B1040000924020018FA
65907+:1003D000020020210E0016C5A38200442403FFFF63
65908+:1003E000104300182404FFFF0A00182400002021F5
65909+:1003F0008C820010240500010200202100431023FC
65910+:100400008F830024240600010E001646AC62001003
65911+:100410000A001824000020210E0015F9240500010F
65912+:100420000A00182400002021020020212402000DCF
65913+:100430008FBF00148FB0001027BD00180A0016C52A
65914+:10044000A38200448FBF00148FB0001000801021E1
65915+:1004500003E0000827BD001827BDFFC8AFB2002089
65916+:10046000AFBF0034AFB60030AFB5002CAFB400283A
65917+:10047000AFB30024AFB1001CAFB000188F46012805
65918+:100480003C0308008C6331A02402FF80AF86004843
65919+:1004900000C318213065007F03452821006218241D
65920+:1004A0003C02000AAF43002400A2282190A200626F
65921+:1004B00000809021AF850014304200FF000211023D
65922+:1004C000A382003890A200BC304200021440000217
65923+:1004D00024030034240300308F820014A3830028F7
65924+:1004E000938300388C4200C0A3800044AF82003C5C
65925+:1004F000240200041062031C8F84003C8E4400041C
65926+:10050000508003198F84003C8E4200103083FFFF1F
65927+:10051000A784003A106002FFAF8200408F8400146D
65928+:100520002403FF809082006300621024304200FFA9
65929+:10053000144002CF9785003A9383003824020002CA
65930+:1005400030B6FFFF14620005000088219382002866
65931+:100550002403FFFD0A001B19AF82003C8F82003C80
65932+:1005600002C2102B144002A18F8400400E0014EC34
65933+:1005700000000000938300283C040800248477983E
65934+:10058000240200341462002EAF84002C3C0A0800C0
65935+:100590008D4A77C82402FFFFAFA2001000803821E7
65936+:1005A0002405002F3C09080025297398240800FF22
65937+:1005B0002406FFFF90E2000024A3FFFF00062202B2
65938+:1005C00000C21026304200FF0002108000491021B6
65939+:1005D0008C420000306500FF24E7000114A8FFF5FD
65940+:1005E0000082302600061027AFA20014AFA2001030
65941+:1005F0000000282127A7001027A6001400C51023FB
65942+:100600009044000324A2000100A71821304500FFF8
65943+:100610002CA200041440FFF9A06400008FA2001077
65944+:100620001142000724020005024020210E0016C5D9
65945+:10063000A38200442403FFFF104300642404FFFF4F
65946+:100640003C0208009042779C104000098F82001401
65947+:10065000024020212402000C0E0016C5A382004493
65948+:100660002403FFFF104300592404FFFF8F8200146E
65949+:10067000A380001C3C0308008C63779C8C440080A2
65950+:100680003C0200FF3442FFFF006218240083202B4D
65951+:1006900010800008AF83003402402021240200199A
65952+:1006A0000E0016C5A38200442403FFFF1043004739
65953+:1006B0002404FFFF8F87003C9782003A8F85003427
65954+:1006C000AF8700200047202310A0003BA784003AFA
65955+:1006D0008F86001430A200030002102390C300BCD8
65956+:1006E0003050000300B0282100031882307300014D
65957+:1006F0000013108000A228213C0308008C6331A065
65958+:100700008F8200483084FFFF0085202B004310219A
65959+:1007100010800011244200888F84002C1082000E6B
65960+:100720003C033F013C0208008C42779800431024B0
65961+:100730003C0325001443000630E500FF8C820000D6
65962+:10074000ACC200888C8200100A0018E9ACC2009884
65963+:100750000E001529000030219382001C8F850014A3
65964+:100760008F830040020238218F82003CA387001C47
65965+:1007700094A400E4006218218F82003434841000B5
65966+:10078000AF83004000503021A4A400E41260000EAA
65967+:10079000AF86003C24E20004A382001C94A200E483
65968+:1007A00024C30004AF83003C34422000A4A200E430
65969+:1007B0000A001906000020218F820040AF80003C13
65970+:1007C00000471021AF820040000020212414FFFFC9
65971+:1007D000109402112403FFFF3C0808008D0877A83D
65972+:1007E0003C0208008C4231B03C03080090637798CB
65973+:1007F00031043FFF0082102B1040001B3067003F88
65974+:100800003C0208008C4231A88F83004800042180FC
65975+:1008100000621821006418213062007F0342282101
65976+:100820003C02000C00A228213C020080344200015E
65977+:100830003066007800C230252402FF800062102458
65978+:10084000AF42002830640007AF4208048F820014D2
65979+:100850000344202124840940AF460814AF850024B6
65980+:10086000AF840030AC4301189383003824020003A6
65981+:10087000146201CF240200012402002610E201D1FB
65982+:1008800028E2002710400013240200322402002234
65983+:1008900010E201CC28E200231040000824020024CA
65984+:1008A0002402002010E201B82402002110E20147D6
65985+:1008B000024020210A001AFB2402000B10E201C1B1
65986+:1008C0002402002510E20010024020210A001AFB39
65987+:1008D0002402000B10E201AE28E2003310400006B3
65988+:1008E0002402003F2402003110E2009A024020213D
65989+:1008F0000A001AFB2402000B10E201A5024020218D
65990+:100900000A001AFB2402000B8F90002C3C03080005
65991+:100910008C6331B08F8500308E0400100000A82158
65992+:100920008CB3001430823FFF0043102B8CB10020A9
65993+:100930005040018F0240202190A3000D2402FF802F
65994+:1009400000431024304200FF504001890240202122
65995+:10095000000413823042000314400185024020212C
65996+:1009600094A3001C8F8200148E040028A443011459
65997+:100970008CA20010026218231064000302402021A0
65998+:100980000A00197C2402001F8F82003400621021AB
65999+:100990000262102B104000088F83002402402021A7
66000+:1009A000240200180E0016C5A382004410540174DE
66001+:1009B0002404FFFF8F8300248F8400348C62001096
66002+:1009C0000224882100441023AC6200108F8200149E
66003+:1009D000AC7100208C4200680051102B10400009BF
66004+:1009E0008F830030024020212402001D0E0016C516
66005+:1009F000A38200442403FFFF104301612404FFFF8E
66006+:100A00008F8300308E0200248C6300241043000783
66007+:100A1000024020212402001C0E0016C5A3820044BF
66008+:100A20002403FFFF104301562404FFFF8F8400249A
66009+:100A30008C82002424420001AC8200241233000482
66010+:100A40008F8200148C4200685622000E8E02000035
66011+:100A50008E0200003C030080004310241440000D6F
66012+:100A60002402001A024020210E0016C5A382004471
66013+:100A70002403FFFF104301422404FFFF0A0019BAB8
66014+:100A80008E0200143C0300800043102450400003F9
66015+:100A90008E020014AC8000208E0200142411FFFF8F
66016+:100AA0001051000E3C0308003C0208008C423190BB
66017+:100AB000004310242403001B14400007A3830044B8
66018+:100AC0000E0016C5024020211051012D2404FFFF05
66019+:100AD0000A0019CB8E030000A38000448E0300009F
66020+:100AE0003C02000100621024104000123C02008011
66021+:100AF0000062102414400008024020212402001A41
66022+:100B00000E0016C5A38200442403FFFF1043011CFE
66023+:100B10002404FFFF02402021020028210E0016E5D8
66024+:100B2000240600012403FFFF104301152404FFFFE6
66025+:100B3000241500018F83002402A0302102402021CF
66026+:100B40009462003624050001244200010A001ADFE5
66027+:100B5000A46200368F90002C3C0308008C6331B0F7
66028+:100B60008E13001032623FFF0043102B10400089AB
66029+:100B70008F8400302402FF809083000D00431024F6
66030+:100B8000304200FF104000842402000D0013138245
66031+:100B900030420003240300011443007F2402000DAF
66032+:100BA0009082000D30420008544000048F820034CF
66033+:100BB000024020210A001A102402002450400004A0
66034+:100BC0008E03000C024020210A001A102402002784
66035+:100BD0008C82002054620006024020218E0300080F
66036+:100BE0008C820024506200098E02001402402021F1
66037+:100BF000240200200E0016C5A38200441054007188
66038+:100C00002403FFFF0A001A458F8400242411FFFFEC
66039+:100C1000145100048F860014024020210A001A405B
66040+:100C2000240200258E0300188CC2007C1062000391
66041+:100C30002402000E0A001A40024020218E030024E4
66042+:100C40008C82002810620003240200210A001A404E
66043+:100C5000024020218E0500288C82002C10A2000367
66044+:100C60002402001F0A001A40024020218E03002C9B
66045+:100C700014600003240200230A001A4002402021CD
66046+:100C80008CC200680043102B104000032402002691
66047+:100C90000A001A40024020218C82001400651821AD
66048+:100CA0000043102B104000088F84002402402021B4
66049+:100CB000240200220E0016C5A382004410510041F8
66050+:100CC0002403FFFF8F8400242403FFF79082000D8C
66051+:100CD00000431024A082000D8F8600143C030800FE
66052+:100CE0008C6331AC8F82004894C400E08F8500246F
66053+:100CF0000043102130847FFF000420400044102175
66054+:100D00003043007F034320213C03000E0083202159
66055+:100D10002403FF8000431024AF42002CA493000062
66056+:100D20008CA2002824420001ACA200288CA2002C36
66057+:100D30008E03002C00431021ACA2002C8E02002C4C
66058+:100D4000ACA200308E020014ACA2003494A2003A8F
66059+:100D500024420001A4A2003A94C600E03C0208002C
66060+:100D60008C4231B024C4000130837FFF1462000F35
66061+:100D700000803021240280000082302430C2FFFF36
66062+:100D8000000213C2304200FF000210270A001A7E40
66063+:100D9000000233C02402000D024020210E0016C5BF
66064+:100DA000A38200440A001A84004018218F82001494
66065+:100DB00002402021240500010E0015F9A44600E0A0
66066+:100DC000000018210A001B16006088218F90002C5B
66067+:100DD0003C0308008C6331B08E05001030A23FFF49
66068+:100DE0000043102B104000612402FF808F840030EC
66069+:100DF0009083000D00431024304200FF5040005CFF
66070+:100E0000024020218F8200341040000B0005138225
66071+:100E10008F8200149763000A944200603042FFFF03
66072+:100E200014430005000513828F8200202404FFFD77
66073+:100E30000A001AF3AF82003C304200031440000E57
66074+:100E40000000000092020002104000058E03002402
66075+:100E500050600015920300030A001AAF02402021DF
66076+:100E60008C82002450620010920300030240202173
66077+:100E70000A001AB72402000F9082000D30420008C9
66078+:100E80005440000992030003024020212402001074
66079+:100E90000E0016C5A38200442403FFFF1043003850
66080+:100EA0002404FFFF92030003240200025462000C9A
66081+:100EB000920200038F820034544000099202000322
66082+:100EC000024020212402002C0E0016C5A3820044FB
66083+:100ED0002403FFFF1043002A2404FFFF92020003B3
66084+:100EE0000200282102402021384600102CC60001B3
66085+:100EF0002C4200010E0016E5004630252410FFFFAD
66086+:100F00001050001F2404FFFF8F8300341060001373
66087+:100F1000024020213C0208008C42318C0043102BFF
66088+:100F200014400007000000000000282124060001F2
66089+:100F30000E001646000000000A001AF300002021EF
66090+:100F40002402002D0E0016C5A38200441050000C90
66091+:100F50002404FFFF0A001AF3000020210E0015F9F7
66092+:100F6000240500010A001AF300002021024020217C
66093+:100F70002402000D0E0016C5A3820044004020216B
66094+:100F80000A001B16008088211514000E00000000C6
66095+:100F90000E00174C024020210A001B160040882139
66096+:100FA0000E0016C5A38200440A001B1600408821CB
66097+:100FB00014620017022018212402002314E2000505
66098+:100FC0002402000B0E0017C0024020210A001B164D
66099+:100FD0000040882102402021A38200440E0016C553
66100+:100FE0002411FFFF0A001B170220182130A500FF63
66101+:100FF0000E001529240600019783003A8F82003CD9
66102+:10100000A780003A00431023AF82003C0220182141
66103+:101010001220003E9782003A2402FFFD5462003EF7
66104+:101020008E4300208E4200048F830014005610234C
66105+:10103000AE420004906200633042007FA062006311
66106+:101040008E4200208F840014A780003A34420002B0
66107+:10105000AE420020A48000E4908200632403FFBF1E
66108+:1010600000431024A08200630A001B598E43002015
66109+:101070009082006300621024304200FF1040002381
66110+:101080009782003A90820088908300BD2485008872
66111+:101090003042003F2444FFE02C820020A383001C48
66112+:1010A00010400019AF85002C2402000100821804B2
66113+:1010B000306200191440000C3C02800034420002EF
66114+:1010C000006210241440000B306200201040000F1A
66115+:1010D0009782003A90A600010240202124050001D9
66116+:1010E0000A001B5330C60001024020210A001B5297
66117+:1010F00024050001024020210000282124060001CF
66118+:101100000E001646000000009782003A1440FD04CD
66119+:101110008F8400148E4300203062000410400012BF
66120+:101120008F84003C2402FFFB00621024AE420020AA
66121+:10113000274301808F4201B80440FFFE8F820048A0
66122+:10114000AC6200008F420124AC6200042402608380
66123+:10115000A462000824020002A062000B3C021000FE
66124+:10116000AF4201B88F84003C8F8300148FBF0034DE
66125+:101170008FB600308FB5002C8FB400288FB30024B9
66126+:101180008FB200208FB1001C8FB000182402000124
66127+:1011900027BD003803E00008AC6400C030A500FFA4
66128+:1011A0002403000124A900010069102B1040000C49
66129+:1011B00000004021240A000100A31023004A380443
66130+:1011C00024630001308200010069302B10400002CE
66131+:1011D000000420420107402554C0FFF800A310235B
66132+:1011E00003E00008010010213C020800244260A432
66133+:1011F0003C010800AC22738C3C02080024425308D6
66134+:101200003C010800AC2273902402000627BDFFE0D9
66135+:101210003C010800A02273943C021EDCAFB200180F
66136+:10122000AFB10014AFBF001CAFB0001034526F411B
66137+:1012300000008821240500080E001B7A02202021CE
66138+:10124000001180803C07080024E773980002160014
66139+:1012500002071821AC6200000000282124A200012E
66140+:101260003045FFFF8C6200002CA6000804410002FC
66141+:10127000000220400092202614C0FFF8AC64000059
66142+:10128000020780218E0400000E001B7A2405002036
66143+:10129000262300013071FFFF2E2301001460FFE5BB
66144+:1012A000AE0200008FBF001C8FB200188FB1001477
66145+:1012B0008FB0001003E0000827BD002027BDFFD835
66146+:1012C000AFB3001CAFB20018AFBF0020AFB1001425
66147+:1012D000AFB000108F5101408F48014800089402C0
66148+:1012E000324300FF311300FF8F4201B80440FFFE7C
66149+:1012F00027500180AE1100008F420144AE0200046D
66150+:1013000024020002A6120008A202000B240200140C
66151+:10131000AE1300241062002528620015104000085A
66152+:101320002402001524020010106200302402001272
66153+:10133000106200098FBF00200A001CB58FB3001C8B
66154+:101340001062007024020022106200378FBF00205C
66155+:101350000A001CB58FB3001C3C0208008C4231A06F
66156+:101360002403FF800222102100431024AF420024F6
66157+:101370003C0208008C4231A0022210213042007F42
66158+:10138000034218213C02000A00621821166000BCCA
66159+:10139000AF830014906200623042000F344200308C
66160+:1013A000A06200620A001CB48FBF00203C046000F1
66161+:1013B0008C832C083C02F0033442FFFF00621824A7
66162+:1013C000AC832C083C0208008C4231A08C832C0892
66163+:1013D000244200740002108200021480006218256A
66164+:1013E000AC832C080A001CB48FBF00203C0208000C
66165+:1013F0008C4231A02403FF800222102100431024DC
66166+:10140000AF4200243C0208008C4231A03C03000A99
66167+:10141000022210213042007F03421021004310219C
66168+:101420000A001CB3AF8200143C0208008C4231A0B9
66169+:101430002405FF800222102100451024AF42002421
66170+:101440003C0208008C4231A0022210213042007F71
66171+:10145000034218213C02000A0062182190620063D6
66172+:1014600000A21024304200FF10400085AF8300141A
66173+:1014700024620088944300123C0208008C4231A888
66174+:1014800030633FFF00031980022210210043102126
66175+:101490003043007F03432021004510243C03000C0F
66176+:1014A00000832021AF4200289082000D00A210246A
66177+:1014B000304200FF10400072AF8400249082000D83
66178+:1014C000304200101440006F8FBF00200E0015C87E
66179+:1014D000000000008F4201B80440FFFE0000000041
66180+:1014E000AE1100008F420144AE020004240200024B
66181+:1014F000A6120008A202000BAE1300240A001CB4BE
66182+:101500008FBF00202406FF8002261024AF42002057
66183+:101510003C0208008C4231A031043FFF00042180CE
66184+:101520000222102100461024AF4200243C03080090
66185+:101530008C6331A83C0208008C4231A03227007F26
66186+:101540000223182102221021006418213042007F5A
66187+:101550003064007F034228213C02000A0066182400
66188+:1015600000A22821034420213C02000C00822021FB
66189+:10157000AF4300283C020008034718210062902175
66190+:10158000AF850014AF8400240E0015C8010080212F
66191+:101590008F4201B80440FFFE8F8200248F84001424
66192+:1015A000274501809042000DACB10000A4B00006B8
66193+:1015B000000216000002160300021027000237C2C4
66194+:1015C00014C00016248200889442001232033FFFA8
66195+:1015D00030423FFF14430012240260829083006374
66196+:1015E0002402FF8000431024304200FF5040000CD2
66197+:1015F00024026082908200623042000F3442004038
66198+:10160000A082006224026084A4A200082402000DCB
66199+:10161000A0A200050A001C9E3C0227002402608252
66200+:10162000A4A20008A0A000053C02270000061C00A0
66201+:101630000062182524020002A0A2000BACA3001037
66202+:10164000ACA00014ACA00024ACA00028ACA0002CDE
66203+:101650008E42004C8F840024ACA200189083000DB1
66204+:101660002402FF8000431024304200FF1040000598
66205+:101670008FBF00209082000D3042007FA082000DBD
66206+:101680008FBF00208FB3001C8FB200188FB10014E1
66207+:101690008FB000103C02100027BD002803E00008B6
66208+:1016A000AF4201B80800343008003430080033A8D5
66209+:1016B000080033E0080034140800343808003438D7
66210+:1016C00008003438080033180A0001240000000024
66211+:1016D000000000000000000D747061362E322E33C1
66212+:1016E00000000000060203010000000000000000EE
66213+:1016F00000000000000000000000000000000000EA
66214+:1017000000000000000000000000000000000000D9
66215+:1017100000000000000000000000000000000000C9
66216+:1017200000000000000000000000000000000000B9
66217+:1017300000000000000000000000000000000000A9
66218+:101740000000000000000000000000000000000099
66219+:101750000000000000000000000000001000000376
66220+:10176000000000000000000D0000000D3C02080019
66221+:1017700024421C003C03080024632094AC40000079
66222+:101780000043202B1480FFFD244200043C1D080070
66223+:1017900037BD2FFC03A0F0213C1008002610049058
66224+:1017A0003C1C0800279C1C000E00015C000000008F
66225+:1017B0000000000D3084FFFF308200078F85001885
66226+:1017C00010400002248300073064FFF800853021B8
66227+:1017D00030C41FFF03441821247B4000AF85001C48
66228+:1017E000AF84001803E00008AF4400843084FFFF9A
66229+:1017F000308200078F8500208F860028104000026D
66230+:10180000248300073064FFF8008520210086182B10
66231+:1018100014600002AF8500240086202303442821A1
66232+:1018200034068000AF840020AF44008000A6202151
66233+:1018300003E00008AF84003827BDFFD8AFB3001C19
66234+:10184000AFB20018AFB00010AFBF0024AFB400209B
66235+:10185000AFB100143C0860088D1450002418FF7FBD
66236+:101860003C1A8000029898243672380CAD12500051
66237+:101870008F5100083C07601C3C08600036300001B6
66238+:10188000AF500008AF800018AF400080AF40008428
66239+:101890008CE600088D0F08083C0760168CEC0000F1
66240+:1018A00031EEFFF039CA00103C0DFFFF340B800011
66241+:1018B0003C030080034B48212D440001018D282466
66242+:1018C0003C0253533C010800AC230420AF8900388C
66243+:1018D000AF860028AF840010275B400014A20003ED
66244+:1018E00034E37C008CF90004032818218C7F007CF1
66245+:1018F0008C6500783C0280003C0B08008D6B048CEA
66246+:101900003C0A08008D4A048834520070AF85003CC0
66247+:10191000AF9F00403C13080026731C440240A021E6
66248+:101920008E4800008F46000038C30001306400017B
66249+:1019300010800017AF880034028048218D2F0000EE
66250+:101940003C0508008CA5045C3C1808008F1804585E
66251+:1019500001E8102300A280210000C8210202402BD0
66252+:1019600003198821022838213C010800AC30045CAE
66253+:101970003C010800AC2704588F4E000039CD00010F
66254+:1019800031AC00011580FFED01E04021AF8F003444
66255+:101990008E5100003C0708008CE7045C3C0D0800F9
66256+:1019A0008DAD04580228802300F0602100007021D2
66257+:1019B0000190302B01AE1821006620213C01080067
66258+:1019C000AC2C045C3C010800AC2404588F46010890
66259+:1019D0008F47010030C92000AF860000AF87000CA0
66260+:1019E0001120000A00C040213C1808008F18042C68
66261+:1019F000270800013C010800AC28042C3C184000DA
66262+:101A0000AF5801380A000196000000009749010410
66263+:101A100000002821014550213122FFFF0162582199
66264+:101A20000162F82B015F502130D902003C0108000F
66265+:101A3000AC2B048C3C010800AC2A0488172000154C
66266+:101A400024040F0010E400130000000024080D001F
66267+:101A500010E8023B30CD000611A0FFE93C18400021
66268+:101A6000936E00002409001031C400F01089027147
66269+:101A700024020070108202E58F880014250F0001F7
66270+:101A8000AF8F00143C184000AF5801380A0001968F
66271+:101A900000000000974C01041180FFD93C18400061
66272+:101AA00030C34000146000A1000000008F460178A0
66273+:101AB00004C0FFFE8F87003824100800240F0008A0
66274+:101AC0008CE30008AF500178A74F0140A7400142C6
66275+:101AD000974E01048F86000031C9FFFF30CD000111
66276+:101AE00011A002E1012040212531FFFE241800024F
66277+:101AF000A75801463228FFFFA75101483C190800AA
66278+:101B00008F39043C172002D08F8C000C30DF00206E
66279+:101B100017E00002240400092404000130C20C0074
66280+:101B2000240504005045000134840004A744014A00
66281+:101B30003C1108008E3104203C1800483C10000184
66282+:101B40000238182530CF00020070282511E000046B
66283+:101B5000000018213C19010000B9282524030001C8
66284+:101B600030DF000453E00005AF8300083C0600109E
66285+:101B700000A6282524030001AF830008AF4510000C
66286+:101B80000000000000000000000000000000000055
66287+:101B90008F83000810600023000000008F451000B4
66288+:101BA00004A1FFFE000000001060001E0000000005
66289+:101BB0008F4410003C0C0020008C102410400019B1
66290+:101BC0008F8E000031CD000211A000160000000031
66291+:101BD000974F101415E000130000000097591008EB
66292+:101BE0003338FFFF271100060011188200033080F0
66293+:101BF00000C7282132300001322300031200032CD9
66294+:101C00008CA200000000000D00C7F821AFE2000028
66295+:101C10003C0508008CA5043024A600013C01080006
66296+:101C2000AC2604308F6D00003402FFFFAF8D00043E
66297+:101C30008CEC0000118202A6000020218CED000037
66298+:101C400031AC01001180028A000000003C02080053
66299+:101C50008C4204743C0308008C63044C3C1F080055
66300+:101C60008FFF04703C1808008F1804480048382182
66301+:101C70000068802100E8282B03E430210208402B73
66302+:101C80000304882100C57021022878213C01080046
66303+:101C9000AC30044C3C010800AC2F04483C01080067
66304+:101CA000AC2704743C010800AC2E04708F8400182B
66305+:101CB0000120302131290007249F000833F91FFF3C
66306+:101CC00003594021AF84001CAF990018251B400028
66307+:101CD000AF590084112000038F83002024C2000725
66308+:101CE0003046FFF88F84002800C3282100A4302B41
66309+:101CF00014C00002AF83002400A428230345602100
66310+:101D0000340D8000018D10213C0F1000AF850020A4
66311+:101D1000AF820038AF450080AF4F01788F88001444
66312+:101D2000250F00010A0001EFAF8F00148F62000839
66313+:101D30008F670000240500300007760231C300F0F1
66314+:101D4000106500A7240F0040546FFF4C8F880014CB
66315+:101D50008F4B01780560FFFE0000000030CA0200D2
66316+:101D600015400003000612820000000D00061282DA
66317+:101D7000304D0003000D4900012D18210003808023
66318+:101D8000020D402100086080019380218E1F000019
66319+:101D900017E00002000000000000000D8F6E00043C
66320+:101DA00005C202BD92070006920E000592020004D1
66321+:101DB0003C090001000E18800070F8218FED00181A
66322+:101DC000277100082448000501A96021000830821D
66323+:101DD000AFEC0018022020210E00059E26050014FD
66324+:101DE000920A00068F7900043C0B7FFF000A2080D6
66325+:101DF000009178218DF800043566FFFF0326282422
66326+:101E000003053821ADE70004920E0005920D000491
66327+:101E1000960C0008000E10800051C8218F2300008E
66328+:101E2000974901043C07FFFF006758243128FFFF52
66329+:101E3000010DF82103EC50233144FFFF01643025EC
66330+:101E4000AF260000920300072418000110780275E5
66331+:101E5000240F0003106F0285000000008E050010A3
66332+:101E60002419000AA7590140A7450142921800040D
66333+:101E70008F860000240F0001A7580144A7400146A7
66334+:101E80009747010430D100023C050041A7470148B3
66335+:101E900000001821A74F014A1220000330CB000494
66336+:101EA0003C0501412403000151600005AF83000897
66337+:101EB0003C06001000A6282524030001AF8300087B
66338+:101EC000AF4510000000000000000000000000000E
66339+:101ED000000000008F8A000811400004000000008C
66340+:101EE0008F4410000481FFFE000000008F6B000093
66341+:101EF000920800043C1108008E310444AF8B0004AA
66342+:101F000097590104311800FF3C0E08008DCE0440A3
66343+:101F10003325FFFF0305382102276021000010212F
66344+:101F2000250F000A31E8FFFF0187482B01C2682115
66345+:101F300001A9F821311000073C010800AC2C044431
66346+:101F40003C010800AC3F0440120000038F8C0018D5
66347+:101F50002506000730C8FFF8010C682131BF1FFFBC
66348+:101F6000AF8C001CAF9F0018AF5F00849744010442
66349+:101F7000035F80213084FFFF308A00071140000397
66350+:101F8000261B4000248900073124FFF88F8200209F
66351+:101F90008F850028008220210085702B15C000024B
66352+:101FA000AF820024008520233C0B08008D6B048C3D
66353+:101FB0003C0A08008D4A04880344882134038000C9
66354+:101FC000022310213C0F1000AF840020AF820038A4
66355+:101FD000AF440080AF4F01780A0002968F8800144A
66356+:101FE0008F5001780600FFFE30D10200162000035A
66357+:101FF000000612820000000D00061282305F00030E
66358+:10200000001F1900007F302100062080009FC8219A
66359+:1020100000194880013380218E180000130000024F
66360+:10202000000000000000000D8F6C000C058001FB1B
66361+:102030008F870038240E0001AE0E00008CE30008EC
66362+:10204000A20000078F65000400055402314D00FF17
66363+:1020500025A80005000830822CCB00411560000245
66364+:10206000A20A00040000000D8F7800043C03FFFF6B
66365+:1020700000E02821330BFFFF256C000B000C1082C1
66366+:1020800000022080008748218D3F000026040014B4
66367+:10209000A618000803E3C8240E00059EAD39000011
66368+:1020A0008F4F01083C11100001F1382410E001AB02
66369+:1020B00000000000974D01049208000725AAFFECDC
66370+:1020C000350600023144FFFFA2060007960600080D
66371+:1020D0002CC7001354E0000592030007921100077B
66372+:1020E000362F0001A20F00079203000724180001F9
66373+:1020F000107801C224090003106901D58F880038C7
66374+:1021000030CBFFFF257100020011788331E400FF1E
66375+:1021100000042880A20F000500A848218D2D000092
66376+:10212000974A01043C0EFFFF01AEF8243143FFFF44
66377+:10213000006B1023244CFFFE03ECC825AD390000D2
66378+:10214000920600053C03FFF63462FFFF30D800FF23
66379+:102150000018388000F08821922F00143C04FF7F83
66380+:102160003487FFFF31EE000F01C65821316500FFB3
66381+:1021700000055080015068218DAC00200148F821F5
66382+:10218000A20B00060182C824AE0C000CAFF9000CB3
66383+:10219000920900068E11000C032778240009C080E4
66384+:1021A0000310702195C60026030828210227202449
66385+:1021B000AE04000CADCF0020ADC60024ACA60010CC
66386+:1021C0008F8800003C0B08008D6B048C3C0A0800D3
66387+:1021D0008D4A0488241F001024190002A75F0140C3
66388+:1021E000A7400142A7400144A7590146974901046D
66389+:1021F00024070001310600022538FFFEA7580148D8
66390+:102200003C050009A747014A10C00003000018213F
66391+:102210003C05010924030001310C00045180000534
66392+:10222000AF8300083C08001000A828252403000103
66393+:10223000AF830008AF451000000000000000000060
66394+:1022400000000000000000009205000424AE00021F
66395+:1022500031CD0007000D182330620007AE020010D8
66396+:102260008F90000812000004000000008F4F100043
66397+:1022700005E1FFFE000000008F7100008F8E001846
66398+:102280003C0308008C630444AF91000497450104AB
66399+:1022900025CF001031E61FFF30A2FFFFAF8E001CDC
66400+:1022A000AF860018AF4600842449FFFE3C0C0800AE
66401+:1022B0008D8C0440974D010401208021000947C303
66402+:1022C0000070C02131A9FFFF0310F82B0188C8213D
66403+:1022D000033F202103463821313100073C0108002B
66404+:1022E000AC3804443C010800AC2404401220000334
66405+:1022F00024FB40002527000730E9FFF88F860020E7
66406+:102300008F8400280126382100E4C02B170000022A
66407+:10231000AF86002400E438230347202134198000CD
66408+:10232000009910213C0F1000AF870020AF820038C9
66409+:10233000AF470080AF4F01780A0002968F880014E3
66410+:102340009747010410E0FDAE3C1840008F5801781B
66411+:102350000700FFFE30C5400010A000033C1F00082E
66412+:102360000000000D3C1F0008AF5F01402410080072
66413+:102370008F860000AF5001789744010430D90001E6
66414+:10238000132000ED3086FFFF24CCFFFE240D000259
66415+:10239000A74D0146A74C01488F9100182408000D55
66416+:1023A000A748014A8F630000262F000831E21FFF73
66417+:1023B0000342702130C90007AF830004AF91001CB5
66418+:1023C000AF82001800C03821AF4200841120000302
66419+:1023D00025DB400024D800073307FFF88F85002055
66420+:1023E0008F84002800E5302100C4382B14E000025F
66421+:1023F000AF85002400C430238F8400140346F821E5
66422+:10240000340C8000AF86002003EC8021AF460080B2
66423+:10241000249900013C0610003C184000AF460178AA
66424+:10242000AF900038AF990014AF5801380A000196F8
66425+:10243000000000008F630000975101043067FFFF28
66426+:102440003228FFFF8F4F017805E0FFFE30EC0007D8
66427+:10245000000CF82333F0000724F9FFFE2404000ADF
66428+:10246000A7440140A7500142A7590144A740014693
66429+:10247000A74801488F45010830B800201700000226
66430+:10248000240300092403000130CD0002A743014AC0
66431+:102490003C04004111A00003000018213C0401414C
66432+:1024A0002403000130C9000451200005AF83000857
66433+:1024B0003C0600100086202524030001AF8300089D
66434+:1024C000AF44100000000000000000000000000009
66435+:1024D000000000008F8E000811C000040000000002
66436+:1024E0008F4210000441FFFE000000008F7F0000BB
66437+:1024F000276400088F91003CAF9F0004948500087A
66438+:102500009490000A9499000C30AFFFFF0010C400B3
66439+:102510003323FFFF11F100A6030320253C0E080022
66440+:102520008DCE04443C0C08008D8C044000E88821CA
66441+:102530002626FFFE01C628210000682100A6F82BF0
66442+:10254000018D2021009F80213C010800AC2504441E
66443+:102550003C010800AC30044024E200083042FFFF98
66444+:102560003047000710E000038F830018244F000756
66445+:1025700031E2FFF83106FFFF30C800070043802139
66446+:1025800032191FFF0359C021AF83001CAF990018F7
66447+:10259000271B4000AF590084110000038F8C0020DE
66448+:1025A00024C5000730A6FFF88F84002800CC28211E
66449+:1025B00000A4F82B17E00002AF8C002400A428230D
66450+:1025C000AF850020AF4500803C0408008C840434B3
66451+:1025D00003454821340E8000012E6821108000053B
66452+:1025E000AF8D0038939100172406000E12260011BB
66453+:1025F0002407043F3C021000AF4201788F8800148A
66454+:10260000250F00010A0001EFAF8F00140E0005C472
66455+:1026100000E020218F8800143C0B08008D6B048C97
66456+:102620003C0A08008D4A0488250F00010A0001EFCA
66457+:10263000AF8F00143C021000A7470148AF42017859
66458+:102640000A0004CE8F88001424040F001184003D7A
66459+:1026500030CE002015C0000224030009240300012D
66460+:102660000A00021AA743014A0A00020DA7400146C8
66461+:1026700094EF000894F1000A94F0000C8F8C003C59
66462+:10268000001174003207FFFF31EDFFFF11AC00377E
66463+:1026900001C720253C1808008F1804443C0F08008F
66464+:1026A0008DEF0440000080210308682101A8382B29
66465+:1026B00001F0702101C760213C010800AC2D0444E9
66466+:1026C0003C010800AC2C04400A00027A8F840018F8
66467+:1026D0003C0208008C42047C3C0308008C630454D8
66468+:1026E0003C1F08008FFF04783C1808008F18045026
66469+:1026F000004838210068802100E8282B03E43021BD
66470+:102700000208402B0304882100C57021022878218B
66471+:102710003C010800AC3004543C010800AC2F0450CC
66472+:102720003C010800AC27047C3C010800AC2E047876
66473+:102730000A00027A8F840018A74001460A00043577
66474+:102740008F91001830CD002015A0FFC52403000D87
66475+:10275000240300050A00021AA743014A974E010408
66476+:1027600025C5FFF00A00038130A4FFFF8F980040C9
66477+:102770001498FFC8000010213C0508008CA5046CCB
66478+:102780003C1F08008FFF046800A8C8210328302BD5
66479+:1027900003E22021008640213C010800AC39046C92
66480+:1027A0003C010800AC2804680A00027A8F840018F3
66481+:1027B0008F8C0040148CFF5900E8C8213C18080099
66482+:1027C0008F18046C3C1108008E3104682723FFFE2B
66483+:1027D00003034821000010210123302B0222702125
66484+:1027E00001C668213C010800AC29046C3C010800CA
66485+:1027F000AC2D04680A0004A524E200088F88003884
66486+:102800003C03FFFF8D02000C0043F82403E4C825BD
66487+:10281000AD19000C0A00038F30CBFFFF0A0003C381
66488+:10282000AE000000974A0104920400048E26000CBA
66489+:10283000014458212579FFF200C7C0243325FFFF4A
66490+:1028400003053825AE27000C0A0002E68E050010AD
66491+:102850003C0DFFFF8D0A0010014D582401646025D6
66492+:10286000AD0C00100A00038F30CBFFFF974301042B
66493+:10287000920E00048E290010006E1021244DFFEEF0
66494+:102880000127602431A8FFFF0188F825AE3F001022
66495+:102890000A0002E68E0500108E0F000CAE0000004C
66496+:1028A00000078880023028210A0002B8ACAF00205F
66497+:1028B0001460000D3058FFFF3C04FFFF0044682403
66498+:1028C00001A47026000E602B000D102B004CF82484
66499+:1028D00013E00002000000000000000D8CAF0000BB
66500+:1028E0000A00025001E410253B03FFFF0003882B80
66501+:1028F0000018802B0211202410800002000000002C
66502+:102900000000000D8CB900000A0002503722FFFFC2
66503+:102910003084FFFF30A5FFFF108000070000182162
66504+:10292000308200011040000200042042006518219E
66505+:102930001480FFFB0005284003E000080060102120
66506+:1029400010C00007000000008CA2000024C6FFFF9A
66507+:1029500024A50004AC82000014C0FFFB2484000402
66508+:1029600003E000080000000010A0000824A3FFFFFF
66509+:10297000AC86000000000000000000002402FFFF01
66510+:102980002463FFFF1462FFFA2484000403E00008BC
66511+:1029900000000000308EFFFF30D8FFFF00057C00F4
66512+:1029A00001F8602539CDFFFF01AC5021014C582BB7
66513+:1029B000014B4821000944023127FFFF00E8302184
66514+:1029C0000006240230C5FFFF00A418213862FFFF73
66515+:1029D00003E000083042FFFF3C0C08008D8C0484AB
66516+:1029E000240BFF8027BDFFD001845021014B4824D8
66517+:1029F000AF4900203C0808008D080484AFB20020D5
66518+:102A0000AFB00018AFBF0028AFB30024AFB1001CB7
66519+:102A1000936600040104382130E4007F009A1021FD
66520+:102A20003C0300080043902130C500200360802152
66521+:102A30003C080111277B000814A000022646007004
66522+:102A40002646006C9213000497510104920F000473
66523+:102A50003267000F322EFFFF31ED004001C72823FF
66524+:102A600011A0000500004821925900BC3338000431
66525+:102A70001700009000000000924300BC307F00046B
66526+:102A800013E0000F0000000010A0000D0000000087
66527+:102A9000960E0002240AFF8000A7602125CDFFFECC
66528+:102AA000A74D1016920B0004014B2024308200FF2A
66529+:102AB00010400085010C40253C0F0400010F40250B
66530+:102AC0008F5301780660FFFE2404000AA7440140EA
66531+:102AD000960D00022404000931AC0007000C5823B5
66532+:102AE000316A0007A74A0142960200022443FFFE12
66533+:102AF000A7430144A7400146975F0104A75F01482F
66534+:102B00008F590108333800205300000124040001CC
66535+:102B1000920F000431EE001015C000023483001043
66536+:102B200000801821A743014A0000000000000000B7
66537+:102B30000000000000000000AF481000000000008E
66538+:102B40000000000000000000000000008F51100095
66539+:102B50000621FFFE3113FFFF12600003000000009A
66540+:102B60008F481018ACC8000096030006307FFFFFA6
66541+:102B700027F900020019988200138880023B302157
66542+:102B80008CD800001520005700183402920300046E
66543+:102B90002405FF8000A3F82433F100FF1220002C4D
66544+:102BA00000000000924700BC30F2000212400028F2
66545+:102BB00000000000974B100C2562FFFEA742101684
66546+:102BC000000000003C0A040035490030AF49100005
66547+:102BD00000000000000000000000000000000000F5
66548+:102BE0008F4C10000581FFFE000000009749100C7B
66549+:102BF0008F51101C00C020213127FFFF24F200302C
66550+:102C0000001218820003288000BBF8213226FFFF43
66551+:102C1000AFF100000E0005B300112C020013C880B4
66552+:102C2000033B98218E78000000027400AFB80010BA
66553+:102C30008FA80010310FFFFFAFAF00108FA400105E
66554+:102C400001C46825AFAD00108FA60010AE6600006D
66555+:102C500097730008976D000A9766000C8F8A003CF6
66556+:102C6000000D5C0030CCFFFF3262FFFF104A0036DF
66557+:102C7000016C2025960600023C10100024D30008A9
66558+:102C80000E00013B3264FFFF974C01040E00014926
66559+:102C90003184FFFFAF5001788FBF00288FB300242D
66560+:102CA0008FB200208FB1001C8FB0001803E0000825
66561+:102CB00027BD003010A0FF700000000024A5FFFC1D
66562+:102CC0000A0005EC240900048CD10000AF51101853
66563+:102CD0008F5301780660FF7A2404000A0A00060177
66564+:102CE0000000000000A7C8218F8800388F4E101CFC
66565+:102CF0000019C0820018788001E82021AC8E000005
66566+:102D0000000E2C0200C020210E0005B331C6FFFFCB
66567+:102D1000023B28218CAD000000025400004030210D
66568+:102D2000AFAD00108FAC0010318BFFFFAFAB0010C8
66569+:102D30008FA2001001424825AFA900108FA70010F4
66570+:102D40000A000631ACA700008F8F0040148FFFC926
66571+:102D50000000000097420104960B00023C050800A9
66572+:102D60008CA5046C3049FFFF316AFFFF3C1108005D
66573+:102D70008E310468012A382124F2FFFE00B240217E
66574+:102D80000012FFC30112C82B023FC02103192021EA
66575+:102D90003C010800AC28046C3C010800AC24046829
66576+:102DA0000A00066B0000000000A4102B1040000970
66577+:102DB000240300010005284000A4102B04A00003F8
66578+:102DC000000318405440FFFC000528401060000735
66579+:102DD000000000000085302B14C0000200031842E0
66580+:102DE000008520231460FFFB0005284203E0000853
66581+:102DF000008010218F85002C27BDFFE800053027BB
66582+:102E00002CC300012CA400020083102510400003F5
66583+:102E1000AFBF00102405007FAF85002C00052827D8
66584+:102E200030A5FFFF0E000592240426F58F830030A5
66585+:102E3000240402BD004030210083382B10E000093B
66586+:102E400024050001000420400083102B04800003AF
66587+:102E5000000528405440FFFC0004204010A000085A
66588+:102E600000C350210064402B1500000200052842D9
66589+:102E70000064182314A0FFFB0004204200C350216B
66590+:102E80008FBF0010000A4C02312200FF27BD00183E
66591+:102E9000AF8A002C03E00008AF8900300A00002A46
66592+:102EA00000000000000000000000000D7478703683
66593+:102EB0002E322E3300000000060203000000000046
66594+:102EC000000001360000EA60000000000000000081
66595+:102ED00000000000000000000000000000000000F2
66596+:102EE00000000000000000000000000000000000E2
66597+:102EF00000000000000000000000000000000016BC
66598+:102F000000000000000000000000000000000000C1
66599+:102F100000000000000000000000000000000000B1
66600+:102F200000000000000000000000000000000000A1
66601+:102F3000000000000000138800000000000005DC15
66602+:102F4000000000000000000010000003000000006E
66603+:102F50000000000D0000000D3C02080024423C204F
66604+:102F60003C03080024633DD4AC4000000043202B08
66605+:102F70001480FFFD244200043C1D080037BD7FFC87
66606+:102F800003A0F0213C100800261000A83C1C0800FB
66607+:102F9000279C3C200E0002BA000000000000000D3B
66608+:102FA0008F8300383C088000350700708CE50000F6
66609+:102FB000008330253C02900000C22025AF85003000
66610+:102FC000AF4400208F4900200520FFFE3C03800015
66611+:102FD000346200708C4500008F8600303C19080078
66612+:102FE0008F39007C3C0E08008DCE007800A620238F
66613+:102FF00003245821000078210164682B01CF60214F
66614+:10300000018D50213C010800AC2B007C3C010800E4
66615+:10301000AC2A007803E00008000000000A0000412C
66616+:10302000240400018F8400383C05800034A2000194
66617+:103030000082182503E00008AF43002003E00008E9
66618+:10304000000010213084FFFF30A5FFFF1080000733
66619+:1030500000001821308200011040000200042042CC
66620+:10306000006518211480FFFB0005284003E00008DC
66621+:103070000060102110C00007000000008CA20000BA
66622+:1030800024C6FFFF24A50004AC82000014C0FFFB8F
66623+:103090002484000403E000080000000010A00008E1
66624+:1030A00024A3FFFFAC860000000000000000000029
66625+:1030B0002402FFFF2463FFFF1462FFFA248400044C
66626+:1030C00003E0000800000000308AFFFF93A800130F
66627+:1030D000A74A014497490E1630C600FF3C02100073
66628+:1030E000A7490146AF450148A3460152A748015AE6
66629+:1030F000AF4701608FA400188FA30014A7440158A4
66630+:10310000AF43015403E00008AF42017803E0000838
66631+:10311000000000003C038000346200708C49000015
66632+:103120008F8800002484000727BDFFF83084FFF853
66633+:10313000AF890030974D008A31ACFFFFAFAC000083
66634+:103140008FAB0000016850232547FFFF30E61FFFCB
66635+:1031500000C4282B14A0FFF73C0C8000358B0070B6
66636+:103160008D6A00003C0708008CE700843C060800DC
66637+:103170008CC6008000081082014918230002788064
66638+:1031800000E370210000202101C3C82B00C4C0212E
66639+:1031900001FA4021031948212502400027BD0008FB
66640+:1031A0003C010800AC2E00843C010800AC290080E2
66641+:1031B00003E00008000000008F8200002486000762
66642+:1031C00030C5FFF800A2182130641FFF03E000089B
66643+:1031D000AF8400008F8700388F8A004027BDFFB87A
66644+:1031E0008F860044AFB60040AFBF0044AFB5003C8F
66645+:1031F000AFB40038AFB30034AFB20030AFB1002C81
66646+:10320000AFB000288F4501048D4900ACAF47008066
66647+:103210008CC8002000A938230000B021AF480E1050
66648+:103220008F440E1000004821AF440E148CC20024BD
66649+:10323000AF420E188F430E18AF430E1C10E001254D
66650+:103240002D230001936B0008116000D400000000E2
66651+:10325000976E001031CDFFFF00ED602B158000CF81
66652+:103260000000000097700010320FFFFFAF4F0E00FC
66653+:103270008F520000325100081220FFFD00000000B4
66654+:1032800097540E088F460E043285FFFF30B30001BD
66655+:1032900012600132000000000000000D30B8A040B4
66656+:1032A00024150040131500C030A9A0001120012DE5
66657+:1032B00000000000937F000813E0000800000000F9
66658+:1032C00097630010306BFFFF00CB402B1100000311
66659+:1032D00030AC00401180012300000000A785003CB5
66660+:1032E000AF8600349366000800E02821AFA70020D5
66661+:1032F00014C0012427B30020AF60000C9782003C6B
66662+:103300003047400014E00002240300162403000E9E
66663+:1033100024194007A363000AAF790014938A003E82
66664+:103320008F740014315800070018AA4002959025A8
66665+:10333000AF7200149784003C8F700014309100101D
66666+:1033400002117825AF6F0014978E003C31CD000834
66667+:1033500011A00147000028218F6700143C021000D3
66668+:103360003C0C810000E22825AF65001497460E0A48
66669+:103370002408000E3405FFFC30C3FFFF006C582505
66670+:10338000AF6B0004A3680002937F000A27E90004E2
66671+:10339000A369000A9786003C9363000A30CC1F00A3
66672+:1033A000000C598301634021251F0028A37F0009D9
66673+:1033B00097490E0CA769001093790009272A00028B
66674+:1033C000315800070018A82332B10007A371000B81
66675+:1033D00093740009976400108F910034978F003C1C
66676+:1033E000329200FF024480210205702131ED00403D
66677+:1033F00011A0000531C4FFFF0091282B3C12800072
66678+:1034000010A000140000A0210224382B14E0011B9E
66679+:103410008FA500208F4D0E14AF4D0E108F420E1C45
66680+:10342000AF420E18AF440E008F4F000031EE00087F
66681+:1034300011C0FFFD0000000097540E080080882195
66682+:1034400000009021A794003C8F500E04241400012A
66683+:10345000AF900034976400103095FFFF8E68000035
66684+:103460000111F82317E00009AE7F00008F650014FA
66685+:103470008F8B004434A60040AF6600148F4C0E10B2
66686+:10348000AD6C00208F430E18AD63002493670008D5
66687+:1034900014E000D2000000000E00009E2404001082
66688+:1034A0008F8900483C08320000402821312600FF67
66689+:1034B0000006FC0003E8502525390001AF990048BB
66690+:1034C000AC4A0000937800099370000A330400FFAF
66691+:1034D00000047400320F00FF01CF6825AC4D0004DA
66692+:1034E0008F820048064000EAACA20008ACA0000CA5
66693+:1034F0009783003C306B0008156000022628000608
66694+:1035000026280002974E0E148F450E1C8F6700046C
66695+:10351000936D000231C4FFFF31A200FFAFA2001083
66696+:103520008F6C0014AFA800180E00008BAFAC001415
66697+:10353000240400100E0000C7000000008E7200007E
66698+:1035400016400005000000008F6400142405FFBF32
66699+:1035500000859824AF7300148F79000C033538214F
66700+:10356000AF67000C9375000816A00008000000006B
66701+:1035700012800006000000008F7F00143C0BEFFF5C
66702+:103580003568FFFE03E84824AF690014A3740008FF
66703+:103590008FA500200A00024602202021AF470E001E
66704+:1035A0000A0000F5000000008F5901780720FFFE97
66705+:1035B000241F08008F840000AF5F0178974B008ABA
66706+:1035C000316AFFFF014448232528FFFF31021FFF16
66707+:1035D0002C4300081460FFF9000000008F8E0048A3
66708+:1035E0008F8D003800C048210344202125C60001EA
66709+:1035F000240C0F00AF86004800E9382324864000E1
66710+:1036000031CA00FF11AC0005240800019391003E6F
66711+:103610003230000700107A4035E80001000AAC00A3
66712+:103620003C18010002B8A025AC9440008F930048DC
66713+:1036300030B2003630A40008ACD3000410800097EC
66714+:1036400001123025974E0E0A8F8D00003C0281003A
66715+:1036500031CCFFFF25AB0008018240253C03100060
66716+:1036600031651FFF25390006241F000EAF48016099
66717+:1036700000C33025A75F015AAF850000A759015844
66718+:1036800014E0000A8F93003824120F0052720002D7
66719+:103690002416000134C600408F580E108F94004449
66720+:1036A000AE9800208F550E18AE9500248F450E144D
66721+:1036B000AF4501448F590E1CAF590148A34A01522E
66722+:1036C0003C0A1000AF460154AF4A017814E0FEDD19
66723+:1036D0002D2300010076A025128000178FBF004423
66724+:1036E0008F84003824160F0010960084000000001C
66725+:1036F0008F45017804A0FFFE24150F001095006E81
66726+:10370000000000008F470E14240202403C1F1000EE
66727+:10371000AF4701448F440E1CAF440148A3400152FF
66728+:10372000A740015AAF400160A7400158AF42015481
66729+:10373000AF5F01788FBF00448FB600408FB5003C6B
66730+:103740008FB400388FB300348FB200308FB1002CAB
66731+:103750008FB0002803E0000827BD004814C0FED049
66732+:1037600030B8A0408F420E148F84004400004821DE
66733+:10377000AC8200208F510E1CAC9100240A00020E76
66734+:103780002D2300018F910034978A003C3C12800069
66735+:103790000220A821315800401700FF300000A0216E
66736+:1037A000976900108F9200343139FFFF13320035D2
66737+:1037B00000002021008048211480FEA000A03821B4
66738+:1037C0008F420E148F840044AC8200208F510E1C57
66739+:1037D000AC9100240A00020E2D230001936A000917
66740+:1037E0009378000B315000FF330F00FF020F702160
66741+:1037F00025C2000A3050FFFF0E00009E020020216B
66742+:103800008F8600483C1F410024CD0001AF8D004849
66743+:10381000936C000930C600FF00064400318300FFAE
66744+:10382000246B0002010B4825013FC825AC5900005C
66745+:103830008F67000C97440E1400F22825AC45000455
66746+:103840008F450E1C8F670004936A00023084FFFFCF
66747+:10385000315800FFAFB800108F6F0014AFB10018DF
66748+:103860000E00008BAFAF00140A0001A60200202159
66749+:10387000AF6000040A00013EA36000020A00024695
66750+:1038800000002021000090210A0001702414000192
66751+:103890003C1280000A000195ACB2000C8F91000030
66752+:1038A00025240002A744015826300008320F1FFFCC
66753+:1038B0000A0001F9AF8F0000AF40014C1120002C2D
66754+:1038C000000000008F590E10AF5901448F430E18AD
66755+:1038D000240200403C1F1000AF430148A3400152A6
66756+:1038E000A740015AAF400160A7400158AF420154C0
66757+:1038F000AF5F01780A0002278FBF00441120000645
66758+:103900000000000097460E0830CC004015800002F1
66759+:10391000000000000000000D8F4D017805A0FFFEA3
66760+:103920000000000097530E103C120500240E2000EA
66761+:10393000326AFFFF0152C025AF58014C8F4F0E1461
66762+:103940003C021000AF4F01448F500E1CAF50014895
66763+:10395000A34001528F840038A740015AAF40016054
66764+:10396000A7400158AF4E01540A000215AF4201783A
66765+:103970008F490E14AF4901448F430E1C0A00028E7A
66766+:10398000240200403C0E20FF27BDFFE03C1A8000CF
66767+:103990003C0F800835CDFFFDAFBF001CAFB2001853
66768+:1039A000AFB10014AFB00010AF8F0040AF4D0E00AC
66769+:1039B0000000000000000000000000000000000007
66770+:1039C000000000003C0C00FF358BFFFDAF4B0E00EC
66771+:1039D0003C0660048CC95000240AFF7F3C11600043
66772+:1039E000012A40243507380CACC750008E24043817
66773+:1039F00024050009AF4500083083FFFF38622F71AE
66774+:103A00002450C0B3AF8000480E000068AF800000B3
66775+:103A100052000001AE20442C0E0004353C11800001
66776+:103A20000E000ED9363000708F8A00403C1208001C
66777+:103A300026523C88020088218E0800008F5F00001B
66778+:103A40003BF900013338000113000017AF88003044
66779+:103A5000022048218D2700003C0F08008DEF006CEC
66780+:103A60003C0C08008D8C006800E8C02301F8282178
66781+:103A70000000682100B8302B018D582101664021DB
66782+:103A80003C010800AC25006C3C010800AC28006833
66783+:103A90008F44000038830001306200011440FFEDC4
66784+:103AA00000E04021AF8700308E0C00003C0508008C
66785+:103AB0008CA5006C3C0408008C84006801883023CD
66786+:103AC00000A638210000102100E6402B00821821BA
66787+:103AD0000068F8213C010800AC27006C3C0108009C
66788+:103AE000AC3F00688F49010025590088AF99004418
66789+:103AF000AF890038AF4900208E070000AF87003043
66790+:103B00008F4D017805A0FFFE000000008E0600002A
66791+:103B10003C0B08008D6B00743C0408008C84007022
66792+:103B200000C728230165F8210000102103E5402B80
66793+:103B30000082382100E8C821240908003C0108005F
66794+:103B4000AC3F00743C010800AC390070AF4901780B
66795+:103B500093580108A398003E938F003E31EE000178
66796+:103B600015C000158F830038240E0D00106E00194B
66797+:103B7000240F0F00106F001D00000000915900007D
66798+:103B800024180050332900FF113800043C1F400066
66799+:103B9000AF5F01380A0002E7000000000E00090EC6
66800+:103BA000000000008F8A00403C1F4000AF5F0138DA
66801+:103BB0000A0002E700000000938D003E31AC0006D1
66802+:103BC000000C51000E0000CE0152D8210A00034320
66803+:103BD0008F8A00403C1B0800277B3D080E0000CE6A
66804+:103BE000000000000A0003438F8A00403C1B0800CD
66805+:103BF000277B3D280E0000CE000000000A00034392
66806+:103C00008F8A004090AA00018FAB00108CAC00108E
66807+:103C10003C0300FF8D680004AD6C00208CAD0014E7
66808+:103C200000E060213462FFFFAD6D00248CA7001816
66809+:103C30003C09FF000109C024AD6700288CAE001CC0
66810+:103C40000182C82403197825AD6F0004AD6E002CE5
66811+:103C50008CAD0008314A00FFAD6D001C94A9000234
66812+:103C60003128FFFFAD68001090A70000A56000029A
66813+:103C7000A1600004A167000090A30002306200FF71
66814+:103C80000002198210600005240500011065000E75
66815+:103C90000000000003E00008A16A00018CD80028A1
66816+:103CA000354A0080AD7800188CCF0014AD6F001439
66817+:103CB0008CCE0030AD6E00088CC4002CA16A0001CF
66818+:103CC00003E00008AD64000C8CCD001CAD6D001845
66819+:103CD0008CC90014AD6900148CC80024AD680008BC
66820+:103CE0008CC70020AD67000C8CC200148C8300646C
66821+:103CF0000043C82B13200007000000008CC20014F2
66822+:103D0000144CFFE400000000354A008003E0000886
66823+:103D1000A16A00018C8200640A000399000000007F
66824+:103D200090AA000027BDFFF88FA9001CA3AA0000DD
66825+:103D30008FAE00003C0FFF808FA8001835E2FFFF18
66826+:103D40008CCD002C01C26024AFAC0000A120000487
66827+:103D500000E06021A7A000028FB800008D270004BA
66828+:103D60000188182100A0582100C05021006D28268C
66829+:103D70003C06FF7F3C0F00FF2CAD000135EEFFFF3E
66830+:103D800034D9FFFF3C02FF0003193024000D1DC091
66831+:103D9000010EC82400E2C02400C370250319782551
66832+:103DA000AD2E0000AD2F00048D450024AFAE000005
66833+:103DB000AD2500088D4D00202405FFFFAD2D000C22
66834+:103DC000956800023107FFFFAD27001091660018CB
66835+:103DD00030C200FF000219C2506000018D4500345E
66836+:103DE000AD2500148D67000827BD0008AD27001C15
66837+:103DF0008C8B00CCAD2C0028AD20002CAD2B0024EA
66838+:103E0000AD20001803E00008AD20002027BDFFE032
66839+:103E1000AFB20018AFB10014AFB00010AFBF001CBC
66840+:103E20009098000000C088213C0D00FF330F007FF8
66841+:103E3000A0CF0000908E000135ACFFFF3C0AFF00D0
66842+:103E4000A0CE000194A6001EA22000048CAB00149A
66843+:103E50008E29000400A08021016C2824012A40241E
66844+:103E60000080902101052025A6260002AE24000432
66845+:103E700026050020262400080E00007624060002F5
66846+:103E800092470000260500282624001400071E0083
66847+:103E90000003160324060004044000032403FFFF6C
66848+:103EA000965900023323FFFF0E000076AE23001068
66849+:103EB000262400248FBF001C8FB200188FB100147D
66850+:103EC0008FB0001024050003000030210A0000809C
66851+:103ED00027BD002027BDFFD8AFB1001CAFB0001830
66852+:103EE000AFBF002090A80000240200018FB0003C6A
66853+:103EF0003103003F00808821106200148FAA00382F
66854+:103F0000240B0005506B0016AFAA001000A0202162
66855+:103F100000C028210E0003DC02003021922400BCE6
66856+:103F2000308300021060000326060030ACC00000A1
66857+:103F300024C600048FBF00208FB1001C8FB0001872
66858+:103F400000C0102103E0000827BD002801403821EF
66859+:103F50000E00035AAFB000100A0004200000000059
66860+:103F60000E0003A1AFB000140A00042000000000FE
66861+:103F70003C02000A034218213C04080024843D6CE2
66862+:103F80002405001A000030210A000080AF8300548D
66863+:103F90003C038000346200708C48000000A058216F
66864+:103FA00000C04821308A00FFAF8800308F4401787C
66865+:103FB0000480FFFE3C0C8000358600708CC500003C
66866+:103FC0003C0308008C6300743C1808008F180070D4
66867+:103FD00000A82023006468210000C82101A4782BD8
66868+:103FE0000319702101CF60213C010800AC2D007441
66869+:103FF0003C010800AC2C00708F480E14AF480144FF
66870+:10400000AF47014CA34A0152A74B01589346010800
66871+:1040100030C5000854A0000135291000934B090059
66872+:1040200024070050316A00FF11470007000000001C
66873+:104030008F450E1CAF450148AF4901543C091000A3
66874+:1040400003E00008AF490178934D010831A800084A
66875+:104050001100001000000000934F010831EE001025
66876+:1040600051C00001352900083C04080090843DD06F
66877+:10407000A34401508F4309A4AF4301488F4209A0D4
66878+:10408000AF420144AF4901543C09100003E000086D
66879+:10409000AF4901783C1908008F393D8C333800084E
66880+:1040A0005700FFF1352900080A00047300000000E2
66881+:1040B00024070040AF470814AF4008108F4209445E
66882+:1040C0008F4309508F4409548F45095C8F46094C32
66883+:1040D000AF820064AF830050AF84004CAF85005CBA
66884+:1040E00003E00008AF8600609346010930C5007FF9
66885+:1040F000000518C0000521400083102103E00008DE
66886+:10410000244200883C09080091293D9124A800021E
66887+:104110003C05110000093C0000E8302500C51825C9
66888+:1041200024820008AC83000003E00008AC80000497
66889+:104130009347010B8F4A002C974F09083C18000E3B
66890+:104140000358482131EEFFFF000E41C0AF48002C5C
66891+:1041500097430908952C001A008040212403000190
66892+:10416000318BFFFFAC8B00008D2D001C00A058216F
66893+:1041700000C06021AC8D00048D24002030E7004099
66894+:10418000AD04000891220019304400031083004858
66895+:104190002885000214A00062240600021086005642
66896+:1041A00024190003109900660000000010E0003A96
66897+:1041B000000000003C07080094E73D8624E200016F
66898+:1041C000934F0934934709219525002A31EE00FFCA
66899+:1041D000000E488230ED00FF978700580009360036
66900+:1041E000000D1C003044FFFF00C310250044C02513
66901+:1041F00000A778213C19400003197025000F4C00DE
66902+:10420000AD090004AD0E0000934D09203C030006EB
66903+:1042100025090014000D360000C32025AD04000858
66904+:104220008F59092C24E5000130A27FFFAD19000C45
66905+:104230008F580930A782005825020028AD180010B9
66906+:104240008F4F0938AD0F0014AD2B00048F4E09407D
66907+:10425000AD2E0008934D09373C05080090A53D9010
66908+:104260008F4409488F46094031A700FF00EC182110
66909+:10427000008678230003C7000005CC0003196025E1
66910+:1042800031E8FFFC01885825AD2B000CAD20001053
66911+:1042900003E00008AF4A002C3C0D080095AD3D86B8
66912+:1042A0003C0E080095CE3D800A0004C901AE1021E5
66913+:1042B0003C05080094A53D8A3C06080094C63D8054
66914+:1042C0003C18080097183D7C952E002400A6782104
66915+:1042D00001F86823000E240025A2FFF200821825B1
66916+:1042E00024190800AD03000CAD190014AD00001036
66917+:1042F0000A0004C4250800189526002495250028E6
66918+:104300000006C40000057C00370E810035ED080072
66919+:10431000AD0E000CAD0D00100A0004C425080014F9
66920+:104320001480FFA200000000952400240004140063
66921+:1043300034430800AD03000C0A0004C42508001033
66922+:104340003C03080094633D8A3C05080094A53D8029
66923+:104350003C06080094C63D7C953900249538002819
66924+:10436000006520210086782300196C000018740075
66925+:1043700025E2FFEE01C2202535A3810024190800A3
66926+:10438000AD03000CAD040010AD190018AD00001411
66927+:104390000A0004C42508001C03E00008240201F4FC
66928+:1043A00027BDFFE8AFB00010AFBF00140E000060E3
66929+:1043B0000080802124050040AF4508148F83005001
66930+:1043C0008F84004C8F85005C0070182100641023DE
66931+:1043D00018400004AF830050AF6300548F66005450
66932+:1043E000AF86004C1200000C000000008F440074E7
66933+:1043F000936800813409FA002D07000710E00005DA
66934+:1044000000891021936C0081240B01F4018B50046E
66935+:1044100001441021AF62000C8F4E095C01C5682376
66936+:1044200019A000048FBF00148F4F095CAF8F005C90
66937+:104430008FBF00148FB000100A00006227BD001863
66938+:104440008F8400648F8300508F82004CAF640044DF
66939+:10445000AF63005003E00008AF6200543C038000EB
66940+:10446000346200708C43000027BDFFF8308700FFE6
66941+:1044700030A900FF30C800FFAF8300308F440178BF
66942+:104480000480FFFE3C028000345900708F38000029
66943+:10449000A3A700033C0708008CE700748FAC000062
66944+:1044A0003C0608008CC60070030378233C0E7FFF97
66945+:1044B00000EFC82135CDFFFF00005021018D2824D9
66946+:1044C00000CA1821000847C0032F202B00A8102580
66947+:1044D0000064C021AFA200003C010800AC390074A8
66948+:1044E0003C010800AC380070934F010AA3A0000201
66949+:1044F0003C0E80FFA3AF00018FAC0000312B007F8A
66950+:1045000035CDFFFF018D4824000B5600012A4025C0
66951+:10451000240730002406FF803C05100027BD00085A
66952+:10452000AF48014CAF470154A7400158A346015280
66953+:1045300003E00008AF45017827BDFFE8AFBF0014D6
66954+:10454000AFB000108F6500743C068000309000FF13
66955+:1045500000A620250E000060AF6400749363000580
66956+:10456000346200080E000062A362000502002021F0
66957+:104570008FBF00148FB00010240500052406000131
66958+:104580000A00057027BD001827BDFFE03C0380002E
66959+:10459000AFB00010AFBF0018AFB1001434620070AC
66960+:1045A0008C470000309000FF30A800FFAF8700303C
66961+:1045B0008F4401780480FFFE3C18800037110070A2
66962+:1045C0008E2F00003C0D08008DAD00743C0A0800E1
66963+:1045D0008D4A007001E7702301AE282100005821A8
66964+:1045E00000AE302B014B4821012638213C01080048
66965+:1045F000AC250074000088213C010800AC27007045
66966+:104600001100000F000000008F6200742619FFFFE8
66967+:104610003208007F0002FE0233E5007F150000062D
66968+:10462000332200FF2407FF800207202624A3FFFF78
66969+:1046300000838025320200FF0040802124111008F1
66970+:104640000E000060000000008F49081831250004AA
66971+:1046500014A0FFFD3218007F001878C000187140C8
66972+:1046600001CF682125AC0088AF4C0818274A098083
66973+:104670008D4B0020AF4B01448D460024AF460148CE
66974+:10468000A35001500E000062A740015802201021E3
66975+:104690008FBF00188FB100148FB0001003E0000826
66976+:1046A00027BD002027BDFFE8308400FFAFBF00100A
66977+:1046B0000E0005BB30A500FF8F8300508FBF001098
66978+:1046C000344500402404FF903C02100027BD001830
66979+:1046D000AF43014CA3440152AF45015403E000082D
66980+:1046E000AF4201789343093E306200081040000D4C
66981+:1046F0003C0901013528080AAC8800008F47007486
66982+:10470000AC8700043C06080090C63D9030C5001000
66983+:1047100050A00006AC8000088F6A0060AC8A0008D8
66984+:104720002484000C03E00008008010210A00062207
66985+:104730002484000C27BDFFE8AFBF0014AFB0001009
66986+:104740009346093F00A050210005288000853823AA
66987+:1047500030C200FF240300063C09080095293D866D
66988+:1047600024E8FFD824050004104300372406000283
66989+:104770009750093C3C0F020400063400320EFFFF44
66990+:1047800001CF6825AC8D0000934C093E318B002091
66991+:104790001160000800000000934309363C02010349
66992+:1047A000345F0300307900FF033FC0252405000873
66993+:1047B000AC98000493430934935909210005F88209
66994+:1047C000306200FF0002C082332F00FF00186E002D
66995+:1047D000000F740001AE6025018920253C094000CE
66996+:1047E00000898025ACF0FFD8934309378F4F0948E3
66997+:1047F0008F580940306200FF004AC821033F7021F2
66998+:1048000001F86023000E6F0001A650253185FFFCE2
66999+:10481000001F58800145482501683821AD09002056
67000+:104820000E00006024F00028240400040E00006242
67001+:10483000A364003F020010218FBF00148FB000104E
67002+:1048400003E0000827BD00180A0006352406001200
67003+:1048500027BDFFD024090010AFB60028AFB5002453
67004+:10486000AFB40020AFB10014AFB000103C0108009D
67005+:10487000A0293D90AFBF002CAFB3001CAFB2001811
67006+:1048800097480908309400FF3C02000E3107FFFFF3
67007+:10489000000731C0AF46002C974409089344010B30
67008+:1048A00030B500FF03428021308300300000B0218A
67009+:1048B0001060012500008821240C00043C01080040
67010+:1048C000A02C3D90934B093E000B5600000A2E038E
67011+:1048D00004A0016000000000AF400048934F010BAE
67012+:1048E00031EE002011C00006000000009358093E80
67013+:1048F00000189E0000139603064001890000000086
67014+:104900009344010B30830040106000038F930050EC
67015+:104910008F8200502453FFFF9347093E30E6000882
67016+:1049200014C0000224120003000090219619002CEC
67017+:1049300093580934934F0937A7990058330C00FF57
67018+:1049400031EE00FF024E6821000D5880016C5021AD
67019+:10495000015140213C010800A4283D869205001821
67020+:1049600030A900FF010918213C010800A4233D885B
67021+:104970009211001816200002000000000000000D37
67022+:104980003C010800A4233D8A3C010800A4203D808E
67023+:104990003C010800A4203D7C935F010B3063FFFFC6
67024+:1049A00033F00040120000022464000A2464000B6B
67025+:1049B0003091FFFF0E00009E022020219358010B32
67026+:1049C0003C08080095083D8A0040202100185982C3
67027+:1049D000316700010E00049A01072821934C010B56
67028+:1049E0008F4B002C974E09083C0F000E034F4021BF
67029+:1049F00031CDFFFF000D51C0AF4A002C974309088D
67030+:104A00009505001A004038212404000130A9FFFF59
67031+:104A1000AC4900008D06001C00404821318A00404E
67032+:104A2000AC4600048D020020ACE20008910300199E
67033+:104A300030630003106400EC28790002172001188D
67034+:104A4000241000021070010C241F0003107F011EAF
67035+:104A500000000000114000DE000000003C090800DA
67036+:104A600095293D8625220001935F0934934E092143
67037+:104A70009504002A33F900FF0019C08231CF00FFEE
67038+:104A8000978E005800184600000F6C00010D80251D
67039+:104A90003045FFFF02051025008E50213C034000E9
67040+:104AA00000433025000A6400ACEC0004ACE60000D2
67041+:104AB000935F09203C19000624EC0014001FC60077
67042+:104AC00003197825ACEF00088F48092C25CD00018B
67043+:104AD00031A57FFFACE8000C8F500930A785005846
67044+:104AE00024E80028ACF000108F4409380100802130
67045+:104AF000ACE40014AD9300048F530940AD9300085B
67046+:104B0000934A09373C19080093393D908F4309486F
67047+:104B10008F460940314200FF0052F82100667023A1
67048+:104B2000001F7F000019C40001F8282531CDFFFCCB
67049+:104B300000AD2025AD84000CAD800010AF4B002CE3
67050+:104B4000934B093E317300081260000D3C060101D1
67051+:104B500034CC080AACEC00288F530074AD13000469
67052+:104B60003C0B0800916B3D903167001050E0000352
67053+:104B7000AD0000088F6A0060AD0A00082510000C27
67054+:104B800012C0003D000000009343093F24160006B8
67055+:104B900024060004306200FF105600C924070002FA
67056+:104BA0009758093C3C0F0204330DFFFF01AF40252D
67057+:104BB000AE0800009345093E30A400201080000894
67058+:104BC00000000000935309363C0B0103357F0300BE
67059+:104BD000327900FF033F7025AE0E00042406000862
67060+:104BE000934F093493480921312AFFFF31ED00FF2B
67061+:104BF000000D1082310300FF0002B60000032C00FC
67062+:104C000002C56025018A9825001220803C094000D9
67063+:104C10000204502302695825AD4BFFD8935F093732
67064+:104C20008F4F09488F58094033F900FF0332702134
67065+:104C30000006B08201D668210007440001F828234D
67066+:104C4000000D1F000068302530A2FFFC2547FFD86B
67067+:104C500000C260250016808002074821ACEC0020CD
67068+:104C6000253000280E00006024120004A372003FCB
67069+:104C70000E000062000000009347010B30F200407C
67070+:104C8000124000053C1900FF8E180000372EFFFF70
67071+:104C9000030E3024AE0600000E0000C702202021C3
67072+:104CA0003C10080092103D90321100031220000FBA
67073+:104CB00002A028218F89005025330001AF930050B6
67074+:104CC000AF7300508F6B00540173F8231BE0000298
67075+:104CD000026020218F640054AF6400548F4C007434
67076+:104CE000258401F4AF64000C02A028210280202159
67077+:104CF000A76000680E0005BB3C1410008F850050B3
67078+:104D000034550006AF45014C8F8A00488FBF002CF8
67079+:104D10008FB3001C25560001AF9600488FB20018D3
67080+:104D2000A34A01528FB60028AF5501548FB1001429
67081+:104D3000AF5401788FB500248FB400208FB00010DD
67082+:104D400003E0000827BD00309358093E00189E007C
67083+:104D500000139603064200362411000293440923EF
67084+:104D6000308300021060FEDD8F8600608F8200506D
67085+:104D700014C2FEDA000000000E0000600000000017
67086+:104D80009369003F24070016312800FF1107000C2B
67087+:104D9000240500083C0C0800918C3D90358B0001E7
67088+:104DA0003C010800A02B3D90936A003F314300FF77
67089+:104DB00010650065240D000A106D005E2402000CD1
67090+:104DC0000E000062000000000A00069000000000D3
67091+:104DD0003C09080095293D863C0A0800954A3D801B
67092+:104DE0000A0006F3012A10213C09080095293D8A92
67093+:104DF0003C04080094843D803C06080094C63D7C39
67094+:104E000095030024012410210046F8230003CC0060
67095+:104E100027F0FFF20330C025240F0800ACF8000C87
67096+:104E2000ACEF0014ACE000100A0006EE24E7001816
67097+:104E30003C010800A0313D90935F093E241600011B
67098+:104E400033F900201720FEA5241100080A0006905F
67099+:104E5000241100048F6E00848F4D094011A0FE9E26
67100+:104E6000AF8E0050240F00143C010800A02F3D908D
67101+:104E70000A00068F00000000950E0024950D002802
67102+:104E8000000E6400000D2C003589810034A6080056
67103+:104E9000ACE9000CACE600100A0006EE24E70014B2
67104+:104EA0001460FEEC000000009502002400021C00CB
67105+:104EB00034640800ACE4000C0A0006EE24E700109D
67106+:104EC0000A000741240700123C02080094423D8A70
67107+:104ED0003C06080094C63D803C03080094633D7C7A
67108+:104EE00095100024951900280046F82103E3C023FB
67109+:104EF00000106C0000197400270FFFEE01CF282569
67110+:104F000035AC8100ACEC000CACE5001024070800C7
67111+:104F1000AD2700182527001C0A0006EEAD2000145E
67112+:104F20008F7F004CAF7F00548F7900540A000699A0
67113+:104F3000AF790050A362003F0E0000620000000045
67114+:104F40000A00069000000000240200140A0008274E
67115+:104F5000A362003F27BDFFE8308400FFAFBF001011
67116+:104F60000E0005BB30A500FF9378007E9379007F8B
67117+:104F7000936E00809368007A332F00FF001866005C
67118+:104F8000000F6C0031CB00FF018D4825000B520053
67119+:104F90008FBF0010012A3825310600FF344470000D
67120+:104FA00000E628252402FF813C03100027BD0018DD
67121+:104FB000AF45014CAF440154A342015203E0000845
67122+:104FC000AF43017827BDFFD8AFB20018AFB10014CE
67123+:104FD000AFB00010AFBF0020AFB3001C9342010977
67124+:104FE000308600FF30B000FF000618C23204000215
67125+:104FF0003071000114800005305200FF93670005F6
67126+:1050000030E5000810A0000D30C80010024020213B
67127+:105010000E0005A702202821240400018FBF0020D4
67128+:105020008FB3001C8FB200188FB100148FB0001026
67129+:105030000080102103E0000827BD00281500003281
67130+:105040000000000093430109000028213062007F26
67131+:10505000000220C00002F94003E49821267900886C
67132+:10506000033B98218E7800248E6F0008130F0046B2
67133+:10507000000000008F640084241800020004FD82F8
67134+:1050800033F900031338007C0000000093660083AE
67135+:10509000934A0109514600043205007C10A00060CB
67136+:1050A000000000003205007C14A0005302402021C3
67137+:1050B00016200006320400018E7F00248F5901045F
67138+:1050C00017F9FFD600002021320400011080000AE9
67139+:1050D000024020218F4209408F9300641053000644
67140+:1050E000000000000E00066D022028218F430940B9
67141+:1050F000AF630044024020210E0006020220282156
67142+:105100000A000860240400013C0908008D2900649D
67143+:10511000252600013C010800AC26006416000012A0
67144+:10512000000000008F6D00843C0E00C001AE6024C2
67145+:1051300015800005024020210E00082E02202821A3
67146+:105140000A00086024040001240500040E00057014
67147+:1051500024060001024020210E00082E02202821F2
67148+:105160000A000860240400010E000041240400012C
67149+:10517000936B007D020B50250E000062A36A007D38
67150+:105180000A0008A38F6D00848F6600748F480104A5
67151+:105190008E67002400064E021507FFB63126007FF9
67152+:1051A000936B008326440001308A007F1146004340
67153+:1051B000316300FF5464FFB08F6400842645000112
67154+:1051C00030B1007F30A200FF122600042405000148
67155+:1051D000004090210A00087624110001240FFF806E
67156+:1051E000024F702401CF9026324200FF00409021F0
67157+:1051F0000A000876241100010E00066D0220282105
67158+:10520000321800301300FFAA321000820240202121
67159+:105210000E0005A7022028210A00086024040001CE
67160+:105220008F6E00743C0F80002405000301CF902591
67161+:10523000AF72007493710083240600010E000570A4
67162+:10524000322400FF0E00004124040001936D007D14
67163+:10525000020D60250E000062A36C007D3C0B08006F
67164+:105260008D6B0054257000013C010800AC300054E7
67165+:105270000A000860240400018F6800743C09800063
67166+:105280002405000401093825AF6700749363008387
67167+:10529000240600010E000570306400FF0E0000417E
67168+:1052A000240400019362007D020298250E00006232
67169+:1052B000A373007D0A00086024040001324D0080C1
67170+:1052C00039AC0080546CFF6C8F6400840A0008C9FC
67171+:1052D0002645000127BDFFC83C0A0008AFBF0030CB
67172+:1052E000AFB5002CAFB40028AFB30024AFB200209C
67173+:1052F000AFB1001CAFB00018034AD8212409004008
67174+:10530000AF490814AF4008108F4209448F43095039
67175+:105310008F4609548F47095C8F48094C9344010814
67176+:105320009345010BAF820064308400FF30A500FF7D
67177+:10533000AF830050AF86004CAF87005C0E00084A78
67178+:10534000AF8800601440017D8FBF0030A760006807
67179+:10535000934D0900240B00503C15080026B53D482C
67180+:1053600031AC00FF3C12080026523D58118B00035F
67181+:10537000000000000000A8210000902193510109C5
67182+:105380008F9F005024040010322E007F000E68C052
67183+:10539000000E6140018D282124B40088AF54081804
67184+:1053A0008F4901048F4A09A43C0B000E034BC02116
67185+:1053B000012A10233C010800AC223D6C8F430958A0
67186+:1053C0003C010800A0243D9097470908007F302346
67187+:1053D0003C010800AC263D7030E8FFFF0008C9C062
67188+:1053E0003C010800AC3F3D94AF59002C974209089E
67189+:1053F0009710002C8EB10000930F001803749821B1
67190+:10540000A7900058AF9300440220F80931F000FF44
67191+:10541000304E000215C001B2304F000111E0014FC3
67192+:10542000000000009343093E3066000814C00002EB
67193+:10543000241400030000A0218F5809A424130001A4
67194+:105440003C010800AC383D98934F0934935109371B
67195+:1054500031EC00FF322E00FF028E6821000D288003
67196+:1054600000AC5021015058213C010800A42B3D887C
67197+:105470003C010800A42A3D8693490934312200FFEB
67198+:1054800002022021249000103C010800A4303D8439
67199+:10549000240700068F9F00503C010800AC273D8C7C
67200+:1054A0008F88005C8F59095800008021011F282334
67201+:1054B00004A00149033F20230480014700A4302BAE
67202+:1054C00010C00149000000003C010800AC253D70FF
67203+:1054D0008E4200000040F809000000003043000246
67204+:1054E000146000F80040882130440001548000100E
67205+:1054F0008E4200043C0908008D293D743C0AC0001E
67206+:10550000012A8025AF500E008F45000030AB000807
67207+:105510001160FFFD00000000974D0E0824100001EF
67208+:10552000A78D003C8F4C0E04AF8C00348E420004DB
67209+:105530000040F8090000000002228825322E0002F7
67210+:1055400015C00180000000003C09080095293D7C41
67211+:105550003C06080094C63D883C0A0800954A3D7EFA
67212+:105560003C1908008F393D74012660213C18080061
67213+:105570008F183D983C03080094633D92018A2021D6
67214+:105580008F4E09400329F821248F000203E32821CC
67215+:10559000031968213C010800A42C3D8AAF8E0064E9
67216+:1055A0003C010800AC2D3D983C010800A4253D803D
67217+:1055B0000E00009E31E4FFFF8F870048004020214D
67218+:1055C0003C010800A0273D918E42000824E800011C
67219+:1055D000AF8800480040F809000000009344010B28
67220+:1055E0008F4C002C974A09083C0B000E034B4021BE
67221+:1055F0003149FFFF000919C08F8B0050AF43002CC9
67222+:10560000974309089506001A00403821308A004067
67223+:1056100030DFFFFFAC5F00008D19001C0040482107
67224+:10562000AC5900048D180020AC580008910F0019E7
67225+:1056300031E30003107300F0000000002862000254
67226+:105640001440010924050002106500FD240D00032B
67227+:10565000106D010D00000000114000D90000000095
67228+:105660003C0A0800954A3D8625420001934D0934C5
67229+:1056700093580921950E002A31A300FF00032082D0
67230+:10568000331F00FF9798005800047E00001FCC00D5
67231+:1056900001F940253049FFFF0109102501D83021CB
67232+:1056A0003C0540000045502500066C00ACED0004B0
67233+:1056B000ACEA0000934309203C04000624ED0014EA
67234+:1056C0000003FE0003E4C825ACF900088F49092C4B
67235+:1056D000270F000131EE7FFFACE9000C8F48093045
67236+:1056E000A78E005824E90028ACE800108F4509383F
67237+:1056F00001204021ACE50014ADAB00048F4209400D
67238+:10570000ADA20008934B09373C1F080093FF3D9062
67239+:105710008F4309488F4A0940316600FF00D4202199
67240+:10572000006A78230004C700001FCC000319282555
67241+:1057300031EEFFFC00AE1025ADA2000CADA00010B4
67242+:10574000AF4C002C934C093E318B00085160000F88
67243+:105750008E58000C3C06010134CA080AACEA002845
67244+:105760008F4B0074AD2B00043C0C0800918C3D90D5
67245+:105770003187001050E00003AD2000088F62006008
67246+:10578000AD2200082528000C8E58000C0300F809F3
67247+:10579000010020213C19080097393D8A3C1F080070
67248+:1057A00097FF3D7E033F782125E900020E0000C7E8
67249+:1057B0003124FFFF3C0E08008DCE3D6C3C080800F4
67250+:1057C0008D083D7401C828233C010800AC253D6CC0
67251+:1057D00014A00006000000003C0308008C633D8C10
67252+:1057E000346400403C010800AC243D8C1200007081
67253+:1057F0008F8C00448F470E108F900044AE0700201E
67254+:105800008F4D0E18AE0D00243C10080096103D8000
67255+:105810000E0000600000000024020040AF420814A7
67256+:105820008F8600508F8A004C00D01821006A5823C0
67257+:1058300019600004AF830050AF6300548F650054BB
67258+:10584000AF85004C1200000C000000008F44007473
67259+:10585000936800813409FA002D0E000711C000057D
67260+:1058600000891821937F0081241901F403F9780439
67261+:1058700001E41821AF63000C8F44095C8F83005C46
67262+:105880000083C0231B000003000000008F50095C50
67263+:10589000AF90005C0E000062000000008F8C005092
67264+:1058A0008E4700103C010800AC2C3D9400E0F80944
67265+:1058B000000000003C0D08008DAD3D6C55A0FEF5CC
67266+:1058C000240700068F450024975909088F8B006430
67267+:1058D0008F9400503C0F001F978200588F86005411
67268+:1058E0008F93004C3328FFFF35E9FF8000A9502437
67269+:1058F000000871C032320100AF4E0024A4C2002C57
67270+:10590000AF4A0024AF6B0044AF740050AF73005433
67271+:105910001640008032380010570000868EA4000424
67272+:10592000322300405460001B8EB100088EB0000C82
67273+:105930000200F809000000008FBF00308FB5002C76
67274+:105940008FB400288FB300248FB200208FB1001CC9
67275+:105950008FB0001803E0000827BD00389347010905
67276+:105960008F8800380007FE0003E8C825AF59008083
67277+:105970008F5809A08F5309A4AFB80010AF580E1468
67278+:105980008FB40010AF540E10AF530E1C0A00096202
67279+:10599000AF530E180220F809000000008EB0000C72
67280+:1059A0000200F809000000000A000AA88FBF0030BA
67281+:1059B000A5800020A59300220A000A5BAD93002475
67282+:1059C0003C09080095293D863C06080094C63D80A8
67283+:1059D0000A0009F4012610213C010800AC203D70AA
67284+:1059E0000A00098E8E4200003C010800AC243D7084
67285+:1059F0000A00098E8E4200003C03080094633D8A31
67286+:105A00003C04080094843D803C1F080097FF3D7CC7
67287+:105A1000951800240064C821033F782300186C0007
67288+:105A200025EEFFF201AE2825AC45000C240208004B
67289+:105A3000ACE20014ACE000100A0009EF24E7001803
67290+:105A400095060024950900280006240000091C0082
67291+:105A5000349F810034790800ACFF000CACF90010D1
67292+:105A60000A0009EF24E700141460FEFB00000000A8
67293+:105A70009518002400187C0035EE0800ACEE000CF0
67294+:105A80000A0009EF24E700103C07080094E73D8076
67295+:105A90003C04080094843D8A3C03080094633D7CE8
67296+:105AA00095190024951800280087F82103E378232E
67297+:105AB0002407080000192C0000186C0025EEFFEEEA
67298+:105AC00001AE302534A28100AD2700182527001C27
67299+:105AD000AD22000CAD2600100A0009EFAD20001425
67300+:105AE00093520109000028210E000602324400FFF3
67301+:105AF0008FBF00308FB5002C8FB400288FB30024E7
67302+:105B00008FB200208FB1001C8FB0001803E0000896
67303+:105B100027BD0038935F010933E400FF0E00066DD6
67304+:105B200000002821323800105300FF7E322300404D
67305+:105B30008EA400040080F809000000000A000AA2F8
67306+:105B4000322300401200FF5F000000008F540E144B
67307+:105B50008F920044AE5400208F530E1C0A000A8A14
67308+:105B6000AE5300248F82001C008040213C040100C1
67309+:105B70009047008530E3002010600009000000001D
67310+:105B80003C0708008CE73D948F83001800E3202336
67311+:105B9000048000089389000414E30003010020211D
67312+:105BA00003E00008008010213C04010003E000082D
67313+:105BB000008010211120000B006738238F8C0020FB
67314+:105BC00024090034918B00BC316A0002514000016D
67315+:105BD0002409003000E9682B15A0FFF10100202105
67316+:105BE00000E938232419FFFC00B9C02400F9782407
67317+:105BF00000F8702B15C0FFEA01E8202130C2000335
67318+:105C00000002182314C00012306900030000302184
67319+:105C100000A9702101C6682100ED602B1180FFE012
67320+:105C20003C0401002D2F00010006482B01053821FE
67321+:105C300001E9302414C0FFDA24E4FFFC2419FFFC3E
67322+:105C400000B9C0240308202103E0000800801021CF
67323+:105C50008F8B002024060004916A00BC31440004AC
67324+:105C60001480FFEC00A970210A000B5E00003021B7
67325+:105C700027BDFFE8AFBF00108F460100934A01091E
67326+:105C80003C1F08008FFF00902407FF80314F00FF6A
67327+:105C900031E8007F0008614003E6C821032CC021E1
67328+:105CA00027090120012770243C010800A02F3DD0C6
67329+:105CB000AF4E080C3C0D08008DAD00903C040080F8
67330+:105CC0003482000301A65821016C182124650120AB
67331+:105CD00030AA007801424025AF48081C3C1F08004C
67332+:105CE0008FFF00908F88004003E6C0213319000722
67333+:105CF00003074824033A7821AF49002825E909C061
67334+:105D0000952E00023C0D08008DAD008C3C0A080069
67335+:105D10008D4A009031CC3FFF01A61821000C59801C
67336+:105D2000006B282100A72024AF44002C95220002FC
67337+:105D30003C1F08008FFF008C9107008530593FFF02
67338+:105D400003E678210019C1800146702101F868211D
67339+:105D500031CC007F31AB007F019A2821017A50219C
67340+:105D60003C03000C3C04000E00A328210144102138
67341+:105D700030E6002027470980AF82002CAF88001C46
67342+:105D8000AF890024AF85002010C00006AF8700282F
67343+:105D90008D0200508CA4010C0044302318C0007701
67344+:105DA00000000000910C0085240DFFDF018D3824D8
67345+:105DB000A10700858F8B001C8F8900248F87002806
67346+:105DC0008D65004CAF850018912F000D31EE00203D
67347+:105DD00011C000170000000024090001A38900047D
67348+:105DE000AF80000C8CE400248F85000C240A00088E
67349+:105DF000AF800008AF8000103C010800A42A3D7E5F
67350+:105E00003C010800A4203D920E000B32000030211E
67351+:105E10008F8500248FBF0010AF82001490A8000D62
67352+:105E200027BD00180008394203E0000830E20001F5
67353+:105E3000913F00022418000133F900FF001921826C
67354+:105E400010980039240800021088005B8F86002C0F
67355+:105E50008CE5002414A0001B8F9F002091220000DD
67356+:105E6000240A00053046003F10CA00472404000100
67357+:105E70008F860008A3840004AF860010AF86000C54
67358+:105E80008CE400248F85000C240A00083C010800E3
67359+:105E9000A42A3D7E3C010800A4203D920E000B3256
67360+:105EA000000000008F8500248FBF0010AF82001417
67361+:105EB00090A8000D27BD00180008394203E0000833
67362+:105EC00030E200018CF800088CF900248FEE00C449
67363+:105ED000A38000048CE40024AF8E000C8F85000C9E
67364+:105EE0008F86000803197823240A0008AF8F00105A
67365+:105EF0003C010800A42A3D7E3C010800A4203D92FC
67366+:105F00000E000B32000000008F8500248FBF0010B0
67367+:105F1000AF82001490A8000D27BD00180008394278
67368+:105F200003E0000830E20001912300003062003FEE
67369+:105F3000104400278F8500208CE400241480002169
67370+:105F4000000000008D2E00183C187FFF8F85002078
67371+:105F5000370FFFFF01CF1824AF8300088F9F000881
67372+:105F60008CA8008403E8C82B1720000203E020213E
67373+:105F70008CA400840A000BEDAF8400088CA3010CF4
67374+:105F80000A000BCBAF8300188D2C00188F860008F9
67375+:105F90003C0D7FFF8F89002035A3FFFF018358242C
67376+:105FA00024040001AF8B0010AD2000CCA3840004BA
67377+:105FB0000A000BF9AF86000C8CCA00140A000BED26
67378+:105FC000AF8A00088CA300C80A000C30AF83000819
67379+:105FD0008F84002C8CAC00648C8D0014018D582BA8
67380+:105FE00011600004000000008CA200640A000C3064
67381+:105FF000AF8200088C8200140A000C30AF820008C7
67382+:106000008F85000C27BDFFE0AFBF0018AFB10014B3
67383+:1060100014A00007AFB000108F86002424020005F2
67384+:1060200090C400003083003F106200B68F840020CF
67385+:106030008F91000800A080218F8C00283C0508006B
67386+:106040008CA53D708D8B000431663FFF00C5502B41
67387+:106050005540000100C02821938D000411A0007359
67388+:1060600000B0F82B8F98002024040034930F00BC5C
67389+:1060700031EE000251C000012404003000A4C82BFE
67390+:10608000172000D10000000000A4282300B0F82B46
67391+:106090003C010800A4243D7C17E000680200202198
67392+:1060A0003C0308008C633D6C0083102B54400001BE
67393+:1060B000008018218F8800243C010800AC233D7427
67394+:1060C000000048219104000D308300205060000141
67395+:1060D0008F490E188F8300140123382B10E00059CC
67396+:1060E000000000003C0408008C843D7400895821A5
67397+:1060F000006B502B114000560090602B006930233C
67398+:1061000000C020213C010800AC263D7412000003B1
67399+:10611000241FFFFC1090008A32270003009FC82430
67400+:106120003C010800AC393D743C010800A4203D92BC
67401+:106130008F84000C120400078F830020AF910008A9
67402+:10614000020020218C7100CCAF90000C26300001A1
67403+:10615000AC7000CC3C0208008C423D748F8A001069
67404+:10616000240700180082202301422823AF84000C5A
67405+:1061700010800002AF850010240700108F86001CDD
67406+:106180003C010800A0273D902407004090CC0085EA
67407+:10619000318B00C0116700408F8D001414A00015D2
67408+:1061A00000002021934A01098F420974314500FF04
67409+:1061B0000002260224A300013090007F3071007F8E
67410+:1061C0001230007A2407FF80A0C300833C09080036
67411+:1061D0008D293D8C8F880024240D0002352C000869
67412+:1061E0003C010800A02D3DD13C010800AC2C3D8CA9
67413+:1061F00024040010910E000D31C6002010C00005CF
67414+:1062000000801821240800013C010800AC283D74DE
67415+:10621000348300018FBF00188FB100148FB00010BD
67416+:106220000060102103E0000827BD00203C010800A9
67417+:10623000A4203D7C13E0FF9A020020210A000C817B
67418+:1062400000A020213C0408008C843D740090602B49
67419+:106250001180FFAE000000003C0F080095EF3D7C70
67420+:1062600001E4702101C6682B11A000072C820004F4
67421+:106270003C1F60008FF954043338003F1700FFE5DE
67422+:10628000240300422C8200041040FFA0240300429B
67423+:106290000A000CDF8FBF0018152DFFC000000000A2
67424+:1062A0008CDF00743C0380002405FF8003E3C825D5
67425+:1062B000ACD9007490D80085240E0004240400108A
67426+:1062C000330F003F01E54025A0C800858F880024DA
67427+:1062D0003C010800A02E3DD1240300019106000DD1
67428+:1062E00030C9002015200003000000003C03080016
67429+:1062F0008C633D743C010800AC233D6C0A000CD655
67430+:10630000000000008F8700108C88008400E8282B94
67431+:1063100014A0000200E088218C910084240900016F
67432+:10632000A38900048F440E18022028210E000B328E
67433+:1063300002203021022080210A000C67AF82001465
67434+:1063400000071823306600033C010800A4263D9294
67435+:10635000122000058F8C0020918B00BC316A000454
67436+:106360001540001524CD00043C0F080095EF3D9228
67437+:1063700001E4702100AE302B50C0FF6E8F84000C02
67438+:106380002C85000514A0FFA32403004230980003CD
67439+:1063900017000002009818232483FFFC3C0108002A
67440+:1063A000AC233D740A000CA30000000000A7582491
67441+:1063B0000A000CCB016718263C010800A42D3D9271
67442+:1063C0000A000D33000000003C010800AC203D74C1
67443+:1063D0000A000CDE240300428F83001014600007C3
67444+:1063E000000010218F88002424050005910600007C
67445+:1063F00030C400FF108500030000000003E0000827
67446+:1064000000000000910A0018314900FF000939C25C
67447+:1064100014E0FFFA8F85001C3C04080094843D7C46
67448+:106420003C0308008C633D943C1908008F393D748F
67449+:106430003C0F080095EF3D920064C0218CAD0054E4
67450+:106440000319702101CF6021018D58231960001DAF
67451+:1064500000000000910E001C8F8C002C974B0E103A
67452+:1064600031CD00FF8D850004016D30238D88000043
67453+:1064700030CEFFFF000E510000AAC82100003821D5
67454+:1064800001072021032A182B0083C021AD990004A5
67455+:10649000AD980000918F000A01CF6821A18D000AFC
67456+:1064A0008F88002C974B0E12A50B0008950A003818
67457+:1064B00025490001A50900389107000D34E60008C0
67458+:1064C000A106000D03E000080000000027BDFFE06A
67459+:1064D000938700048F8F00248FAD00143C0E7FFF44
67460+:1064E0008F89000C35C8FFFFAFBF001CAFB000188C
67461+:1064F00001A8182491EA000D000717C03C1FBFFF38
67462+:10650000006258252D2E00018F90001837F9FFFFEB
67463+:106510003C1808008F183D943C0F080095EF3D8A09
67464+:1065200001796824000E47803C07EFFF3C05F0FF2F
67465+:1065300001A818253149002034E2FFFF34ACFFFFE9
67466+:106540000310582327A500102406000225EA0002A4
67467+:1065500000621824008080211520000200004021E4
67468+:106560008F480E1CA7AA0012056000372407000000
67469+:1065700030FF00FF001FCF008F8B001C00793825F3
67470+:10658000AFA70014916F00853C08080091083D9169
67471+:106590003C18DFFF31EE00C0370AFFFF000E182B5A
67472+:1065A0003C1F080097FF3D8400EA6824A3A800115F
67473+:1065B0000003174001A248258FB90010AFA90014AD
67474+:1065C0003C0A0800914A3D93A7BF00168FA800140B
67475+:1065D000032CC0243C0B01003C0F0FFF030B1825BC
67476+:1065E0003147000335EEFFFF010C68240007160059
67477+:1065F000006EF8243C09700001A2C82503E9582563
67478+:10660000AFB90014AFAB00100E000076A3A00015C8
67479+:106610008F8C0024260200089186000D30C40020D3
67480+:10662000108000068FBF001C3C05080094A53D802B
67481+:1066300024B0FFFF3C010800A4303D808FB000185B
67482+:1066400003E0000827BD00208F9800140118502B8C
67483+:106650005540FFC7240700010A000DB630FF00FFB8
67484+:106660009382000427BDFFE0AFBF00181040000F69
67485+:10667000008050218F880024240B00058F8900089A
67486+:10668000910700008F8400200100282130E3003FA3
67487+:106690008F86002C106B000800003821AFA9001075
67488+:1066A0000E00040EAFAA0014A38000048FBF0018D0
67489+:1066B00003E0000827BD00208D1900183C0F0800DA
67490+:1066C0008DEF3D748F9800103C027FFF8D08001401
67491+:1066D000345FFFFF033F682401F8702101AE60239F
67492+:1066E00001883821AFA900100E00040EAFAA0014D3
67493+:1066F0000A000E04A38000048F8700243C050800D4
67494+:1067000094A53D923C0208008C423D8C90E6000D21
67495+:106710000005240030C300201060002C00444025F8
67496+:106720008F85001C00006021240B000190A30085D0
67497+:1067300000004821240A00013C0F800035EE007063
67498+:106740008DC70000AF8700308F5801780700FFFE2B
67499+:106750003C038000347900708F3800003C0508004D
67500+:106760008CA500743C0D08008DAD007003077823E4
67501+:1067700000AF38210000102100EF302B01A22021B2
67502+:10678000008618213C010800AC2700743C01080079
67503+:10679000AC230070AF4B01483C1908008F393D9481
67504+:1067A000A7490144A74A0146AF59014C3C0B0800D8
67505+:1067B000916B3D91A34B0152AF4801543C0810002E
67506+:1067C000A74C015803E00008AF4801788F4B0E1C1E
67507+:1067D0003C0A08008D4A3D7497490E16974D0E14D9
67508+:1067E00001456021312AFFFF0A000E2731A9FFFF72
67509+:1067F0008F8300249064000D308200201040002917
67510+:10680000000000000000482100005021000040214D
67511+:106810003C07800034EB00708D670000AF870030CC
67512+:106820008F4C01780580FFFE3C0D800035AC007078
67513+:106830008D8B00003C0508008CA500743C0408000A
67514+:106840008C8400700167302300A67821000010219D
67515+:1068500001E6C82B0082C021031970213C01080009
67516+:10686000AC2F00743C010800AC2E0070AF49014809
67517+:106870003C0D08008DAD3D94A7480144240900401B
67518+:10688000A74A01463C081000240AFF91AF4D014C75
67519+:10689000A34A0152AF490154A740015803E0000840
67520+:1068A000AF4801788F490E1897460E1297450E1083
67521+:1068B00030CAFFFF0A000E5D30A8FFFF8F8300245F
67522+:1068C00027BDFFF89064000D308200201040003A90
67523+:1068D00000000000240B000100004821240A0001F0
67524+:1068E0003C088000350700708CE30000AF83003067
67525+:1068F0008F4C01780580FFFE3C0E80003C040800B0
67526+:1069000090843DD035C700708CEC00003C05080039
67527+:106910008CA50074A3A400033C1908008F390070F3
67528+:106920008FAD00000183302300A638210000102124
67529+:106930000322782100E6C02B01F8602101AE40253A
67530+:10694000AFA800003C010800AC2700743C0108001F
67531+:10695000AC2C00709346010A3C04080090843DD1A1
67532+:10696000A3A00002A3A600018FA300003C0580FFA6
67533+:106970003099007F34A2FFFF006278240019C6001E
67534+:1069800001F87025240D3000AF4E014C27BD0008E2
67535+:10699000AF4D0154A7400158AF4B0148A7490144EE
67536+:1069A000A74A01463C091000240AFF80A34A01526D
67537+:1069B00003E00008AF4901788F4B0E1897460E127E
67538+:1069C00097450E1030CAFFFF0A000E9130A9FFFF55
67539+:1069D0008F85001C2402008090A40085308300C0B5
67540+:1069E000106200058F8600208F8800088F87000CBA
67541+:1069F000ACC800C8ACC700C403E000080000000039
67542+:106A00003C0A0800254A39543C09080025293A2047
67543+:106A10003C08080025082DD43C07080024E73B3437
67544+:106A20003C06080024C637C43C05080024A5353CB4
67545+:106A30003C040800248431643C0308002463385C6F
67546+:106A40003C020800244236303C010800AC2A3D508C
67547+:106A50003C010800AC293D4C3C010800AC283D48F5
67548+:106A60003C010800AC273D543C010800AC263D64C5
67549+:106A70003C010800AC253D5C3C010800AC243D58BD
67550+:106A80003C010800AC233D683C010800AC223D609D
67551+:086A900003E000080000000013
67552+:00000001FF
67553diff --git a/firmware/bnx2/bnx2-mips-09-6.2.1b.fw.ihex b/firmware/bnx2/bnx2-mips-09-6.2.1b.fw.ihex
67554new file mode 100644
67555index 0000000..43d7c4f
67556--- /dev/null
67557+++ b/firmware/bnx2/bnx2-mips-09-6.2.1b.fw.ihex
67558@@ -0,0 +1,6496 @@
67559+:10000000080001180800000000005594000000C816
67560+:1000100000000000000000000000000008005594EF
67561+:10002000000000380000565C080000A00800000036
67562+:100030000000574400005694080059200000008436
67563+:100040000000ADD808005744000001C00000AE5CBD
67564+:100050000800321008000000000092580000B01C98
67565+:10006000000000000000000000000000080092589E
67566+:100070000000033C000142740800049008000400E2
67567+:10008000000012FC000145B000000000000000006C
67568+:1000900000000000080016FC00000004000158AC3D
67569+:1000A000080000A80800000000003D00000158B052
67570+:1000B00000000000000000000000000008003D00FB
67571+:1000C00000000030000195B00A000046000000006A
67572+:1000D000000000000000000D636F6D362E322E31DF
67573+:1000E00062000000060201020000000000000003A0
67574+:1000F000000000C800000032000000030000000003
67575+:1001000000000000000000000000000000000000EF
67576+:1001100000000010000001360000EA600000000549
67577+:1001200000000000000000000000000000000008C7
67578+:1001300000000000000000000000000000000000BF
67579+:1001400000000000000000000000000000000000AF
67580+:10015000000000000000000000000000000000009F
67581+:10016000000000020000000000000000000000008D
67582+:10017000000000000000000000000000000000007F
67583+:10018000000000000000000000000010000000005F
67584+:10019000000000000000000000000000000000005F
67585+:1001A000000000000000000000000000000000004F
67586+:1001B000000000000000000000000000000000003F
67587+:1001C000000000000000000000000000000000002F
67588+:1001D000000000000000000000000000000000001F
67589+:1001E0000000000010000003000000000000000DEF
67590+:1001F0000000000D3C020800244256083C030800A1
67591+:1002000024635754AC4000000043202B1480FFFDB2
67592+:10021000244200043C1D080037BD9FFC03A0F021D0
67593+:100220003C100800261001183C1C0800279C5608AA
67594+:100230000E000256000000000000000D27BDFFB4B4
67595+:10024000AFA10000AFA20004AFA30008AFA4000C50
67596+:10025000AFA50010AFA60014AFA70018AFA8001CF0
67597+:10026000AFA90020AFAA0024AFAB0028AFAC002C90
67598+:10027000AFAD0030AFAE0034AFAF0038AFB8003C28
67599+:10028000AFB90040AFBC0044AFBF00480E001544FA
67600+:10029000000000008FBF00488FBC00448FB90040B1
67601+:1002A0008FB8003C8FAF00388FAE00348FAD003078
67602+:1002B0008FAC002C8FAB00288FAA00248FA90020C0
67603+:1002C0008FA8001C8FA700188FA600148FA5001000
67604+:1002D0008FA4000C8FA300088FA200048FA1000040
67605+:1002E00027BD004C3C1B60108F7A5030377B502864
67606+:1002F00003400008AF7A00008F82002427BDFFE092
67607+:10030000AFB00010AFBF0018AFB100148C42000CAA
67608+:100310003C1080008E110100104000348FBF001887
67609+:100320000E000D84000000008F85002024047FFF54
67610+:100330000091202BACB100008E030104960201084D
67611+:1003400000031C003042FFFF00621825ACA300042C
67612+:100350009202010A96030114304200FF3063FFFF4E
67613+:100360000002140000431025ACA200089603010C03
67614+:100370009602010E00031C003042FFFF00621825A8
67615+:10038000ACA3000C960301109602011200031C009E
67616+:100390003042FFFF00621825ACA300108E02011846
67617+:1003A000ACA200148E02011CACA20018148000083C
67618+:1003B0008F820024978200003C0420050044182509
67619+:1003C00024420001ACA3001C0A0000C6A782000062
67620+:1003D0003C0340189442001E00431025ACA2001CB0
67621+:1003E0000E000DB8240400018FBF00188FB1001457
67622+:1003F0008FB000100000102103E0000827BD00208E
67623+:100400003C0780008CE202B834E50100044100089A
67624+:10041000240300013C0208008C42006024420001D9
67625+:100420003C010800AC22006003E0000800601021DD
67626+:100430003C0208008C42005C8CA4002094A30016AF
67627+:100440008CA6000494A5000E24420001ACE40280B6
67628+:100450002463FFFC3C010800AC22005C3C0210005D
67629+:10046000A4E30284A4E5028600001821ACE6028819
67630+:10047000ACE202B803E000080060102127BDFFE0F5
67631+:100480003C028000AFB0001034420100AFBF001C3E
67632+:10049000AFB20018AFB100148C43000094450008BF
67633+:1004A0002462FE002C42038110400003000381C23D
67634+:1004B0000A00010226100004240201001462000553
67635+:1004C0003C1180003C02800890420004305000FF44
67636+:1004D0003C11800036320100964300143202000FB6
67637+:1004E00000021500004310253C0308008C63004403
67638+:1004F00030A40004AE220080246300013C01080007
67639+:10050000AC2300441080000730A200028FBF001C03
67640+:100510008FB200188FB100148FB000100A0000CE07
67641+:1005200027BD00201040002D0000182130A20080BF
67642+:1005300010400005362200708E44001C0E000C672F
67643+:10054000240500A0362200708C4400008F82000C2D
67644+:10055000008210232C43012C10600004AF82001095
67645+:10056000240300010A000145AF84000C8E42000400
67646+:100570003C036020AF84000CAC6200143C02080015
67647+:100580008C42005850400015000018218C62000475
67648+:10059000240301FE304203FF144300100000182121
67649+:1005A0002E020004104000032E0200080A00014041
67650+:1005B0000000802114400003000000000A000140F8
67651+:1005C0002610FFF90000000D2402000202021004B0
67652+:1005D0003C036000AC626914000018218FBF001C4E
67653+:1005E0008FB200188FB100148FB00010006010217E
67654+:1005F00003E0000827BD00203C0480008C8301003C
67655+:1006000024020100506200033C0280080000000D3B
67656+:100610003C02800890430004000010213063000F6A
67657+:1006200000031D0003E00008AC8300800004188074
67658+:100630002782FF9C00621821000410C00044102390
67659+:100640008C640000000210C03C030800246356E4E0
67660+:10065000004310213C038000AC64009003E00008DC
67661+:10066000AF8200243C0208008C42011410400019A3
67662+:100670003084400030A2007F000231C03C02020002
67663+:100680001080001400A218253C026020AC43001426
67664+:100690003C0408008C8456B83C0308008C630110AD
67665+:1006A0003C02800024050900AC4500200086202182
67666+:1006B000246300013C028008AC4400643C01080053
67667+:1006C000AC2301103C010800AC2456B803E000083C
67668+:1006D000000000003C02602003E00008AC4500146C
67669+:1006E00003E000080000102103E0000800001021D2
67670+:1006F00030A2000810400008240201003C0208005B
67671+:100700008C42010C244200013C010800AC22010C87
67672+:1007100003E0000800000000148200080000000050
67673+:100720003C0208008C4200FC244200013C0108000D
67674+:10073000AC2200FC0A0001A330A200203C02080009
67675+:100740008C420084244200013C010800AC22008459
67676+:1007500030A200201040000830A200103C02080027
67677+:100760008C420108244200013C010800AC2201082F
67678+:1007700003E0000800000000104000080000000036
67679+:100780003C0208008C420104244200013C010800A4
67680+:10079000AC22010403E00008000000003C02080055
67681+:1007A0008C420100244200013C010800AC220100FF
67682+:1007B00003E000080000000027BDFFE0AFB1001417
67683+:1007C0003C118000AFB20018AFBF001CAFB00010EA
67684+:1007D0003632010096500008320200041040000733
67685+:1007E000320300028FBF001C8FB200188FB10014BB
67686+:1007F0008FB000100A0000CE27BD00201060000B53
67687+:10080000020028218E2401000E00018A0000000051
67688+:100810003202008010400003240500A10E000C6786
67689+:100820008E44001C0A0001E3240200018E2301040F
67690+:100830008F82000810430006020028218E24010048
67691+:100840000E00018A000000008E220104AF82000821
67692+:10085000000010218FBF001C8FB200188FB1001450
67693+:100860008FB0001003E0000827BD00202C82000498
67694+:1008700014400002000018212483FFFD240200021E
67695+:10088000006210043C03600003E00008AC626914DD
67696+:1008900027BDFFE0AFBF001CAFB20018AFB100141E
67697+:1008A000AFB000103C048000948201083043700017
67698+:1008B000240220001062000A2862200154400052E5
67699+:1008C0008FBF001C24024000106200482402600018
67700+:1008D0001062004A8FBF001C0A0002518FB200183C
67701+:1008E00034820100904300098C5000189451000C90
67702+:1008F000240200091062001C0000902128620009F7
67703+:10090000144000218F8200242402000A5062001249
67704+:10091000323100FF2402000B1062000F00000000C3
67705+:100920002402000C146200188F8200243C0208008C
67706+:100930008C4256B824030900AC83002000501021DB
67707+:100940003C038008AC6200643C010800AC2256B84D
67708+:100950000A0002508FBF001C0E0001E900102602A1
67709+:100960000A0002308F8200240E0001E900102602E6
67710+:100970003C0380089462001A8C72000C3042FFFF26
67711+:10098000020280258F8200248C42000C5040001E01
67712+:100990008FBF001C0E000D84000000003C02800090
67713+:1009A00034420100944300088F82002400031C009D
67714+:1009B0009444001E8F82002000641825AC50000073
67715+:1009C00024040001AC510004AC520008AC40000CFF
67716+:1009D000AC400010AC400014AC4000180E000DB844
67717+:1009E000AC43001C0A0002508FBF001C0E000440E4
67718+:1009F000000000000A0002508FBF001C0E000C9F78
67719+:100A0000000000008FBF001C8FB200188FB10014CF
67720+:100A10008FB000100000102103E0000827BD002067
67721+:100A200027BDFFD8AFB400203C036010AFBF002447
67722+:100A3000AFB3001CAFB20018AFB10014AFB00010DC
67723+:100A40008C6450002402FF7F3C1408002694563822
67724+:100A5000008220243484380CAC6450003C028000B6
67725+:100A6000240300370E0014B0AC4300083C07080014
67726+:100A700024E70618028010212404001D2484FFFFAF
67727+:100A8000AC4700000481FFFD244200043C02080042
67728+:100A9000244207C83C010800AC2256403C02080032
67729+:100AA000244202303C030800246306203C04080072
67730+:100AB000248403B43C05080024A506F03C06080085
67731+:100AC00024C62C9C3C010800AC2256803C02080045
67732+:100AD000244205303C010800AC2756843C01080044
67733+:100AE000AC2656943C010800AC23569C3C010800FF
67734+:100AF000AC2456A03C010800AC2556A43C010800DB
67735+:100B0000AC2256A83C010800AC23563C3C0108002E
67736+:100B1000AC2456443C010800AC2056603C0108005F
67737+:100B2000AC2556643C010800AC2056703C0108001E
67738+:100B3000AC27567C3C010800AC2656903C010800CE
67739+:100B4000AC2356980E00056E00000000AF80000C2C
67740+:100B50003C0280008C5300008F8300043C0208009C
67741+:100B60008C420020106200213262000700008821C0
67742+:100B70002792FF9C3C100800261056E43C02080017
67743+:100B80008C42002024050001022518040043202483
67744+:100B90008F820004004310245044000C26310001D1
67745+:100BA00010800008AF9000248E4300003C028000BB
67746+:100BB000AC4300900E000D4BAE05000C0A0002C1C4
67747+:100BC00026310001AE00000C263100012E22000269
67748+:100BD000261000381440FFE9265200043C020800A9
67749+:100BE0008C420020AF820004326200071040FFD91F
67750+:100BF0003C028000326200011040002D326200028F
67751+:100C00003C0580008CA2010000002021ACA2002045
67752+:100C10008CA301042C42078110400008ACA300A85B
67753+:100C200094A2010824032000304270001443000302
67754+:100C30003C02800890420005304400FF0E0001593C
67755+:100C4000000000003C0280009042010B304300FF96
67756+:100C50002C62001E54400004000310800E00018628
67757+:100C60000A0002EC00000000005410218C42000039
67758+:100C70000040F80900000000104000043C02800021
67759+:100C80008C4301043C026020AC4300143C02080089
67760+:100C90008C4200343C0440003C03800024420001AC
67761+:100CA000AC6401383C010800AC220034326200021E
67762+:100CB00010400010326200043C1080008E0201409F
67763+:100CC000000020210E000159AE0200200E00038317
67764+:100CD000000000003C024000AE0201783C02080027
67765+:100CE0008C420038244200013C010800AC2200384C
67766+:100CF000326200041040FF973C0280003C108000EC
67767+:100D00008E020180000020210E000159AE02002059
67768+:100D10008E03018024020F00546200073C02800809
67769+:100D20008E0201883C0300E03042FFFF00431025A3
67770+:100D30000A000328AE020080344200809042000086
67771+:100D400024030050304200FF14430007000000005D
67772+:100D50000E000362000000001440000300000000C9
67773+:100D60000E000971000000003C0208008C42003CAB
67774+:100D70003C0440003C03800024420001AC6401B804
67775+:100D80003C010800AC22003C0A0002A33C028000A7
67776+:100D90003C02900034420001008220253C02800089
67777+:100DA000AC4400203C0380008C6200200440FFFE25
67778+:100DB0000000000003E00008000000003C0280008A
67779+:100DC000344300010083202503E00008AC440020E8
67780+:100DD00027BDFFE0AFB10014AFB000100080882144
67781+:100DE000AFBF00180E00033230B000FF8F83FF94B6
67782+:100DF000022020219062002502028025A07000259B
67783+:100E00008C7000183C0280000E00033D020280241A
67784+:100E10001600000B8FBF00183C0480008C8201F884
67785+:100E20000440FFFE348201C024030002AC510000E4
67786+:100E3000A04300043C021000AC8201F88FBF0018F0
67787+:100E40008FB100148FB0001003E0000827BD002010
67788+:100E500027BDFFE83C028000AFBF00103442018094
67789+:100E6000944300048C4400083063020010600005C5
67790+:100E7000000028210E00100C000000000A0003787A
67791+:100E8000240500013C02FF000480000700821824B2
67792+:100E90003C02040014620004240500018F82FF94C8
67793+:100EA00090420008240500018FBF001000A010210F
67794+:100EB00003E0000827BD00188F82FF982405000179
67795+:100EC000A040001A3C028000344201400A00034264
67796+:100ED0008C4400008F85FF9427BDFFE0AFBF001C4E
67797+:100EE000AFB20018AFB10014AFB0001090A2000074
67798+:100EF000304400FF38830020388200300003182B74
67799+:100F00000002102B0062182410600003240200501D
67800+:100F1000148200A88FBF001C90A20005304200017F
67801+:100F2000104000A48FBF001C3C02800034420140EE
67802+:100F3000904200082443FFFF2C6200051040009EF1
67803+:100F40008FB20018000310803C030800246355ACE6
67804+:100F5000004310218C420000004000080000000007
67805+:100F60003C028000345101400E0003328E24000008
67806+:100F70008F92FF948E2200048E50000C1602000205
67807+:100F800024020001AE42000C0E00033D8E2400003E
67808+:100F90008E220004145000068FBF001C8FB2001870
67809+:100FA0008FB100148FB000100A000F7827BD002009
67810+:100FB0008E42000C0A000419000000003C0480006E
67811+:100FC0003482014094A300108C4200043063FFFF80
67812+:100FD0001443001C0000000024020001A4A2001021
67813+:100FE0008C8202380441000F3C0380003C02003F29
67814+:100FF0003448F0003C0760003C06FFC08CE22BBC8C
67815+:1010000000461824004810240002130200031D8229
67816+:10101000106200583C0280008C8202380440FFF7C6
67817+:101020003C038000346201408C44000034620200C2
67818+:10103000AC4400003C021000AC6202380A00043BE1
67819+:101040008FBF001C94A200100A00041900000000C9
67820+:10105000240200201482000F3C0280003C03800028
67821+:1010600094A20012346301408C6300043042FFFFFD
67822+:10107000146200050000000024020001A4A2001276
67823+:101080000A0004028FBF001C94A200120A00041977
67824+:1010900000000000345101400E0003328E24000095
67825+:1010A0008F92FF948E230004964200123050FFFF6F
67826+:1010B0001603000224020001A64200120E00033DA6
67827+:1010C0008E2400008E220004160200068FBF001C32
67828+:1010D0008FB200188FB100148FB000100A00037C8B
67829+:1010E00027BD0020964200120A00041900000000EB
67830+:1010F0003C03800094A20014346301408C6300041C
67831+:101100003042FFFF14620008240200018FBF001C60
67832+:101110008FB200188FB100148FB00010A4A2001479
67833+:101120000A00146327BD002094A20014144000217B
67834+:101130008FBF001C0A000435000000003C03800043
67835+:1011400094A20016346301408C6300043042FFFF18
67836+:101150001462000D240200018FBF001C8FB2001822
67837+:101160008FB100148FB00010A4A200160A000B1457
67838+:1011700027BD00209442007824420004A4A200105D
67839+:101180000A00043B8FBF001C94A200162403000138
67840+:101190003042FFFF144300078FBF001C3C020800D1
67841+:1011A0008C420070244200013C010800AC22007017
67842+:1011B0008FBF001C8FB200188FB100148FB00010C9
67843+:1011C00003E0000827BD002027BDFFD8AFB20018FC
67844+:1011D0008F92FF94AFB10014AFBF0020AFB3001CDB
67845+:1011E000AFB000103C028000345101008C5001006F
67846+:1011F0009242000092230009304400FF2402001FA5
67847+:10120000106200AB28620020104000192402003850
67848+:101210002862000A1040000D2402000B286200081A
67849+:101220001040002E8F820024046001042862000216
67850+:101230001440002A8F820024240200061062002637
67851+:101240008FBF00200A00055F8FB3001C1062006092
67852+:101250002862000B144000FA8FBF00202402000E09
67853+:10126000106200788F8200240A00055F8FB3001C93
67854+:10127000106200D2286200391040000A2402008067
67855+:1012800024020036106200E528620037104000C3D7
67856+:1012900024020035106200D98FBF00200A00055FCC
67857+:1012A0008FB3001C1062002D2862008110400006E0
67858+:1012B000240200C824020039106200C98FBF002038
67859+:1012C0000A00055F8FB3001C106200A28FBF0020D0
67860+:1012D0000A00055F8FB3001C8F8200248C42000C33
67861+:1012E000104000D78FBF00200E000D8400000000CA
67862+:1012F0003C038000346301008C6200008F85002075
67863+:10130000946700089466000CACA200008C64000492
67864+:101310008F82002400063400ACA400049448001E10
67865+:101320008C62001800073C0000E83825ACA20008D9
67866+:101330008C62001C24040001ACA2000C9062000A24
67867+:1013400000C23025ACA60010ACA00014ACA0001860
67868+:10135000ACA7001C0A00051D8FBF00208F8200244F
67869+:101360008C42000C104000B68FBF00200E000D8490
67870+:10137000000000008F820024962400089625000CAF
67871+:101380009443001E000422029626000E8F82002045
67872+:10139000000426000083202500052C003C0300806B
67873+:1013A00000A6282500832025AC400000AC400004A6
67874+:1013B000AC400008AC40000CAC450010AC40001440
67875+:1013C000AC400018AC44001C0A00051C24040001B9
67876+:1013D0009622000C14400018000000009242000504
67877+:1013E0003042001014400014000000000E000332D0
67878+:1013F0000200202192420005020020213442001008
67879+:101400000E00033DA242000592420000240300208A
67880+:10141000304200FF10430089020020218FBF0020CE
67881+:101420008FB3001C8FB200188FB100148FB0001062
67882+:101430000A00107527BD00280000000D0A00055E97
67883+:101440008FBF00208C42000C1040007D8FBF002019
67884+:101450000E000D84000000008E2200048F84002006
67885+:101460009623000CAC8200003C0280089445002CBE
67886+:101470008F82002400031C0030A5FFFF9446001E4D
67887+:101480003C02400E0065182500C23025AC830004E4
67888+:10149000AC800008AC80000CAC800010AC80001464
67889+:1014A000AC800018AC86001C0A00051C2404000156
67890+:1014B0000E000332020020218F93FF9802002021AA
67891+:1014C0000E00033DA660000C020020210E00034226
67892+:1014D000240500018F8200248C42000C104000582B
67893+:1014E0008FBF00200E000D84000000009622000C2B
67894+:1014F0008F83002000021400AC700000AC62000476
67895+:10150000AC6000088E4400388F820024AC64000C6C
67896+:101510008E46003C9445001E3C02401FAC66001005
67897+:1015200000A228258E62000424040001AC6200148D
67898+:10153000AC600018AC65001C8FBF00208FB3001C8E
67899+:101540008FB200188FB100148FB000100A000DB8D0
67900+:1015500027BD0028240200201082003A8FB3001C0F
67901+:101560000E000F5E00000000104000358FBF00200D
67902+:101570003C0480008C8201F80440FFFE348201C0EC
67903+:1015800024030002AC500000A04300043C02100001
67904+:10159000AC8201F80A00055E8FBF00200200202106
67905+:1015A0008FBF00208FB3001C8FB200188FB10014C2
67906+:1015B0008FB000100A000EA727BD00289625000C4A
67907+:1015C000020020218FBF00208FB3001C8FB20018B3
67908+:1015D0008FB100148FB000100A000ECC27BD002878
67909+:1015E000020020218FB3001C8FB200188FB10014AD
67910+:1015F0008FB000100A000EF727BD00289225000DBD
67911+:10160000020020218FB3001C8FB200188FB100148C
67912+:101610008FB000100A000F4827BD002802002021CB
67913+:101620008FBF00208FB3001C8FB200188FB1001441
67914+:101630008FB000100A000F1F27BD00288FBF0020A9
67915+:101640008FB3001C8FB200188FB100148FB0001040
67916+:1016500003E0000827BD00283C0580008CA202782A
67917+:101660000440FFFE34A2024024030002AC44000008
67918+:10167000A04300043C02100003E00008ACA2027882
67919+:10168000A380001803E00008A38000193C03800039
67920+:101690008C6202780440FFFE8F82001CAC62024024
67921+:1016A00024020002A06202443C02100003E0000891
67922+:1016B000AC6202783C02600003E000088C425404F3
67923+:1016C0009083003024020005008040213063003FF9
67924+:1016D0000000482114620005000050219082004C57
67925+:1016E0009483004E304900FF306AFFFFAD00000CCC
67926+:1016F000AD000010AD000024950200148D05001C03
67927+:101700008D0400183042FFFF004910230002110031
67928+:10171000000237C3004038210086202300A2102B8E
67929+:101720000082202300A72823AD05001CAD0400186B
67930+:10173000A5090014A5090020A50A001603E0000869
67931+:10174000A50A002203E000080000000027BDFFD822
67932+:10175000AFB200183C128008AFB40020AFB3001C39
67933+:10176000AFB10014AFBF0024AFB00010365101007C
67934+:101770003C0260008C4254049222000C3C1408008D
67935+:10178000929400F7304300FF2402000110620032FF
67936+:101790000080982124020002146200353650008037
67937+:1017A0000E00143D000000009202004C2403FF8054
67938+:1017B0003C0480003042007F000211C024420240FD
67939+:1017C0000262102100431824AC8300949245000863
67940+:1017D0009204004C3042007F3C03800614850007D1
67941+:1017E000004380212402FFFFA22200112402FFFFF8
67942+:1017F000A62200120A0005D22402FFFF9602002052
67943+:10180000A222001196020022A62200128E020024BB
67944+:101810003C048008AE2200143485008090A2004C65
67945+:1018200034830100A06200108CA2003CAC6200185E
67946+:101830008C820068AC6200F48C820064AC6200F0C0
67947+:101840008C82006CAC6200F824020001A0A2006847
67948+:101850000A0005EE3C0480080E001456000000004B
67949+:1018600036420080A04000680A0005EE3C04800873
67950+:10187000A2000068A20000690A0006293C02800854
67951+:10188000348300808C62003834850100AC62006CC7
67952+:1018900024020001A062006990A200D59083000894
67953+:1018A000305100FF3072007F12320019001111C058
67954+:1018B00024420240026210212403FF8000431824C6
67955+:1018C0003C048000AC8300943042007F3C038006DF
67956+:1018D000004380218E02000C1040000D02002021E8
67957+:1018E0000E00057E0000000026220001305100FF9E
67958+:1018F0009203003C023410260002102B0002102339
67959+:101900003063007F022288240A0005F8A203003C0D
67960+:101910003C088008350401008C8200E03507008017
67961+:10192000ACE2003C8C8200E0AD02000090E5004C8F
67962+:10193000908600D590E3004C908400D52402FF806F
67963+:1019400000A228243063007F308400FF00A62825F1
67964+:101950000064182A1060000230A500FF38A500803E
67965+:10196000A0E5004CA10500093C0280089043000E50
67966+:10197000344400803C058000A043000A8C8300189A
67967+:101980003C027FFF3442FFFF00621824AC83001842
67968+:101990008CA201F80440FFFE00000000ACB301C0BF
67969+:1019A0008FBF00248FB400208FB3001C8FB20018AB
67970+:1019B0008FB100148FB0001024020002A0A201C455
67971+:1019C00027BD00283C02100003E00008ACA201F88B
67972+:1019D00090A2000024420001A0A200003C030800E5
67973+:1019E0008C6300F4304200FF144300020080302179
67974+:1019F000A0A0000090A200008F84001C000211C073
67975+:101A00002442024024830040008220212402FF80DF
67976+:101A1000008220243063007F3C02800A006218218B
67977+:101A20003C028000AC44002403E00008ACC300008A
67978+:101A300094820006908300058C85000C8C86001033
67979+:101A40008C8700188C88001C8C8400203C010800C6
67980+:101A5000A42256C63C010800A02356C53C0108003C
67981+:101A6000AC2556CC3C010800AC2656D03C01080001
67982+:101A7000AC2756D83C010800AC2856DC3C010800D5
67983+:101A8000AC2456E003E00008000000003C0280089F
67984+:101A9000344201008C4400343C038000346504006F
67985+:101AA000AC6400388C420038AF850028AC62003C42
67986+:101AB0003C020005AC6200300000000000000000A5
67987+:101AC00003E00008000000003C020006308400FF34
67988+:101AD000008220253C028000AC4400300000000061
67989+:101AE00000000000000000003C0380008C62000049
67990+:101AF000304200101040FFFD3462040003E0000893
67991+:101B0000AF82002894C200003C080800950800CA73
67992+:101B100030E7FFFF0080482101021021A4C200002D
67993+:101B200094C200003042FFFF00E2102B544000013D
67994+:101B3000A4C7000094A200003C0308008C6300CC02
67995+:101B400024420001A4A2000094A200003042FFFF42
67996+:101B5000144300073C0280080107102BA4A00000DA
67997+:101B60005440000101003821A4C700003C02800855
67998+:101B7000344601008CC3002894A200003C0480007D
67999+:101B80003042FFFE000210C000621021AC82003C17
68000+:101B90008C82003C006218231860000400000000E2
68001+:101BA0008CC200240A0006BA244200018CC2002420
68002+:101BB000AC8200383C020050344200103C038000EC
68003+:101BC000AC620030000000000000000000000000D7
68004+:101BD0008C620000304200201040FFFD0000000039
68005+:101BE00094A200003C04800030420001000210C0BA
68006+:101BF000004410218C430400AD2300008C420404F7
68007+:101C0000AD2200043C02002003E00008AC8200305A
68008+:101C100027BDFFE0AFB20018AFB10014AFB00010A5
68009+:101C2000AFBF001C94C2000000C080213C1208001D
68010+:101C3000965200C624420001A6020000960300004E
68011+:101C400094E2000000E03021144300058FB1003021
68012+:101C50000E00068F024038210A0006F10000000045
68013+:101C60008C8300048C82000424420040046100073D
68014+:101C7000AC8200048C8200040440000400000000D8
68015+:101C80008C82000024420001AC8200009602000019
68016+:101C90003042FFFF50520001A600000096220000D3
68017+:101CA00024420001A62200003C02800834420100C8
68018+:101CB000962300009442003C144300048FBF001C94
68019+:101CC00024020001A62200008FBF001C8FB2001862
68020+:101CD0008FB100148FB0001003E0000827BD002072
68021+:101CE00027BDFFE03C028008AFBF0018344201006E
68022+:101CF0008C4800343C03800034690400AC68003830
68023+:101D00008C42003830E700FFAF890028AC62003C0D
68024+:101D10003C020005AC620030000000000000000042
68025+:101D200000000000000000000000000000000000B3
68026+:101D30008C82000C8C82000C97830016AD22000070
68027+:101D40008C82001000604021AD2200048C820018BB
68028+:101D5000AD2200088C82001CAD22000C8CA2001465
68029+:101D6000AD2200108C820020AD220014908200056C
68030+:101D7000304200FF00021200AD2200188CA20018B1
68031+:101D8000AD22001C8CA2000CAD2200208CA2001001
68032+:101D9000AD2200248CA2001CAD2200288CA20020C1
68033+:101DA000AD22002C3402FFFFAD260030AD20003400
68034+:101DB000506200013408FFFFAD28003850E00011E8
68035+:101DC0003C0280083C048008348401009482005066
68036+:101DD0003042FFFFAD22003C9483004494850044D0
68037+:101DE000240200013063FFFF000318C200641821C1
68038+:101DF0009064006430A5000700A210040A00075C8C
68039+:101E00000044102534420100AD20003C94430044BE
68040+:101E1000944400443063FFFF000318C2006218219D
68041+:101E200030840007906500642402000100821004E1
68042+:101E30000002102700451024A0620064000000008A
68043+:101E400000000000000000003C0200063442004098
68044+:101E50003C038000AC620030000000000000000085
68045+:101E6000000000008C620000304200101040FFFDB6
68046+:101E70003C06800834C201503463040034C7014A70
68047+:101E800034C4013434C5014034C60144AFA200104B
68048+:101E90000E0006D2AF8300288FBF001803E00008B1
68049+:101EA00027BD00208F8300143C0608008CC600E884
68050+:101EB0008F82001C30633FFF000319800046102111
68051+:101EC000004310212403FF80004318243C068000B7
68052+:101ED000ACC300283042007F3C03800C004330211B
68053+:101EE00090C2000D30A500FF0000382134420010E0
68054+:101EF000A0C2000D8F8900143C028008344201000A
68055+:101F00009443004400091382304800032402000176
68056+:101F1000A4C3000E1102000B2902000210400005AC
68057+:101F2000240200021100000C240300010A0007A48F
68058+:101F30000000182111020006000000000A0007A49A
68059+:101F4000000018218CC2002C0A0007A424430001C1
68060+:101F50008CC20014244300018CC200180043102BD3
68061+:101F60005040000A240700012402002714A20003A5
68062+:101F70003C0380080A0007B1240700013463010014
68063+:101F80009462004C24420001A462004C00091382B8
68064+:101F9000304300032C620002104000090080282119
68065+:101FA000146000040000000094C200340A0007C15D
68066+:101FB0003046FFFF8CC600380A0007C10080282188
68067+:101FC000000030213C040800248456C00A000706A3
68068+:101FD0000000000027BDFF90AFB60068AFB50064F9
68069+:101FE000AFB40060AFB3005CAFB20058AFB1005403
68070+:101FF000AFBF006CAFB000508C9000000080B021EB
68071+:102000003C0208008C4200E8960400328F83001CDA
68072+:102010002414FF8030843FFF0062182100042180D7
68073+:1020200000641821007410243C13800000A090214B
68074+:1020300090A50000AE620028920400323C02800CA1
68075+:102040003063007F00628821308400C02402004099
68076+:10205000148200320000A8218E3500388E2200182C
68077+:102060001440000224020001AE2200189202003C3B
68078+:10207000304200201440000E8F83001C000511C068
68079+:102080002442024000621821306400783C02008043
68080+:102090000082202500741824AE630800AE64081086
68081+:1020A0008E2200188E03000800431021AE22001873
68082+:1020B0008E22002C8E230018244200010062182B6F
68083+:1020C0001060004300000000924200002442000122
68084+:1020D000A24200003C0308008C6300F4304200FF81
68085+:1020E00050430001A2400000924200008F84001C77
68086+:1020F000000211C024420240248300403063007F6C
68087+:10210000008220213C02800A0094202400621821D1
68088+:10211000AE6400240A0008D2AEC30000920300326D
68089+:102120002402FFC000431024304200FF1440000589
68090+:1021300024020001AE220018962200340A00084250
68091+:102140003055FFFF8E22001424420001AE220018F9
68092+:102150009202003000021600000216030441001C27
68093+:10216000000000009602003227A400100080282101
68094+:10217000A7A20016960200320000302124070001B9
68095+:102180003042FFFFAF8200140E000706AFA0001C14
68096+:10219000960200328F83001C3C0408008C8400E807
68097+:1021A00030423FFF000211800064182100621821B4
68098+:1021B00000741024AE62002C3063007F3C02800E5D
68099+:1021C000006218219062000D3042007FA062000D75
68100+:1021D0009222000D304200105040007892420000E0
68101+:1021E0003C028008344401009482004C8EC30000FD
68102+:1021F0003C130800967300C62442FFFFA482004CE3
68103+:10220000946200329623000E3054FFFF3070FFFFBF
68104+:102210003C0308008C6300D000701807A7A30038A7
68105+:102220009482003E3063FFFF3042FFFF14620007DC
68106+:10223000000000008C8200303C038000244200300B
68107+:10224000AC62003C0A00086A8C82002C9482004038
68108+:102250003042FFFF5462000927A400408C820038FE
68109+:102260003C03800024420030AC62003C8C8200348D
68110+:10227000AC6200380A0008793C03800027A50038CA
68111+:1022800027A60048026038210E00068FA7A000484C
68112+:102290008FA300403C02800024630030AC43003830
68113+:1022A0008FA30044AC43003C3C0380003C0200058B
68114+:1022B000AC6200303C028008344401009482004249
68115+:1022C000346304003042FFFF0202102B1440000769
68116+:1022D000AF8300289482004E9483004202021021B2
68117+:1022E000004310230A00088F3043FFFF9483004E01
68118+:1022F00094820042026318210050102300621823C8
68119+:102300003063FFFF3C028008344401009482003CAB
68120+:102310003042FFFF14430003000000000A00089F42
68121+:10232000240300019482003C3042FFFF0062102B26
68122+:10233000144000058F8200289482003C0062102324
68123+:102340003043FFFF8F820028AC550000AC400004F2
68124+:10235000AC540008AC43000C3C02000634420010B0
68125+:102360003C038000AC620030000000000000000070
68126+:10237000000000008C620000304200101040FFFDA1
68127+:102380003C04800834840100001018C20064182145
68128+:102390009065006432020007240600010046100424
68129+:1023A00000451025A0620064948300429622000E2E
68130+:1023B00050430001A386001892420000244200010D
68131+:1023C000A24200003C0308008C6300F4304200FF8E
68132+:1023D00050430001A2400000924200008F84001C84
68133+:1023E000000211C0244202402483004000822021C8
68134+:1023F0002402FF80008220243063007F3C02800A98
68135+:10240000006218213C028000AC440024AEC30000EE
68136+:102410008FBF006C8FB600688FB500648FB400600A
68137+:102420008FB3005C8FB200588FB100548FB0005052
68138+:1024300003E0000827BD007027BDFFD8AFB3001C24
68139+:10244000AFB20018AFB10014AFB00010AFBF0020A2
68140+:102450000080982100E0802130B1FFFF0E000D8444
68141+:1024600030D200FF0000000000000000000000006B
68142+:102470008F8200208F830024AC510000AC520004F6
68143+:10248000AC530008AC40000CAC400010AC40001451
68144+:10249000AC4000189463001E02038025AC50001C61
68145+:1024A0000000000000000000000000002404000103
68146+:1024B0008FBF00208FB3001C8FB200188FB10014A3
68147+:1024C0008FB000100A000DB827BD002830A5FFFF0F
68148+:1024D0000A0008DC30C600FF3C02800834430100DB
68149+:1024E0009462000E3C080800950800C63046FFFFC5
68150+:1024F00014C000043402FFFF946500EA0A000929B1
68151+:102500008F84001C10C20027000000009462004E5F
68152+:102510009464003C3045FFFF00A6102300A6182B52
68153+:102520003087FFFF106000043044FFFF00C5102318
68154+:1025300000E210233044FFFF0088102B1040000EF3
68155+:1025400000E810233C028008344401002403000109
68156+:1025500034420080A44300162402FFFFA482000E30
68157+:10256000948500EA8F84001C0000302130A5FFFF15
68158+:102570000A0009013C0760200044102A10400009AD
68159+:102580003C0280083443008094620016304200010F
68160+:10259000104000043C0280009442007E244200145B
68161+:1025A000A462001603E000080000000027BDFFE061
68162+:1025B0003C028008AFBF001CAFB0001834420100DD
68163+:1025C000944300429442004C104000193068FFFFD1
68164+:1025D0009383001824020001146200298FBF001C9D
68165+:1025E0003C06800834D00100000810C200501021C1
68166+:1025F000904200643103000734C70148304200FFB5
68167+:10260000006210073042000134C9014E34C4012C6D
68168+:1026100034C5013E1040001634C601420E0006D2F9
68169+:10262000AFA90010960200420A0009463048FFFF99
68170+:102630003C028008344401009483004494820042A8
68171+:102640001043000F8FBF001C94820044A4820042FC
68172+:1026500094820050A482004E8C820038AC820030FC
68173+:1026600094820040A482003E9482004AA4820048E2
68174+:102670008FBF001C8FB000180A00090427BD00207E
68175+:102680008FB0001803E0000827BD002027BDFFA081
68176+:10269000AFB1004C3C118000AFBF0058AFB3005445
68177+:1026A000AFB20050AFB000483626018890C2000398
68178+:1026B0003044007FA3A400108E32018090C200003D
68179+:1026C0003043007F240200031062003BAF92001CE5
68180+:1026D00028620004104000062402000424020002C4
68181+:1026E000106200098FBF00580A000B0F8FB300540F
68182+:1026F0001062004D240200051062014E8FBF005889
68183+:102700000A000B0F8FB30054000411C002421021C5
68184+:102710002404FF8024420240004410242643004049
68185+:10272000AE2200243063007F3C02800A0062182140
68186+:102730009062003CAFA3003C00441025A062003C26
68187+:102740008FA3003C9062003C304200401040016C7E
68188+:102750008FBF00583C108008A3800018361001007D
68189+:102760008E0200E08C63003427A4003C27A50010F3
68190+:10277000004310210E0007C3AE0200E093A2001038
68191+:102780003C038000A20200D58C6202780440FFFE68
68192+:102790008F82001CAC62024024020002A06202444C
68193+:1027A0003C021000AC6202780E0009390000000003
68194+:1027B0000A000B0E8FBF00583C05800890C3000133
68195+:1027C00090A2000B1443014E8FBF005834A4008028
68196+:1027D0008C8200189082004C90A200083C0260009D
68197+:1027E0008C4254048C8300183C027FFF3442FFFF6C
68198+:1027F000006218243C0208008C4200B4AC8300182C
68199+:102800003C038000244200013C010800AC2200B4DB
68200+:102810008C6201F80440FFFE8F82001CAC6201C094
68201+:102820000A000AD6240200023C10800890C300016E
68202+:102830009202000B144301328FBF005827A40018E6
68203+:1028400036050110240600033C0260008C4254044B
68204+:102850000E000E470000000027A40028360501F0F6
68205+:102860000E000E47240600038FA200283603010045
68206+:10287000AE0200648FA2002CAE0200688FA200306E
68207+:10288000AE02006C93A40018906300D52402FF8070
68208+:102890000082102400431025304900FF3084007F5F
68209+:1028A0003122007F0082102A544000013929008023
68210+:1028B000000411C0244202402403FF800242102180
68211+:1028C00000431024AE220094264200403042007F94
68212+:1028D0003C038006004340218FA3001C2402FFFF1D
68213+:1028E000AFA800403C130800927300F71062003359
68214+:1028F00093A2001995030014304400FF3063FFFFDA
68215+:102900000064182B106000100000000095040014F3
68216+:102910008D07001C8D0600183084FFFF0044202323
68217+:102920000004210000E438210000102100E4202BE5
68218+:1029300000C2302100C43021AD07001CAD060018D4
68219+:102940000A000A2F93A20019950400148D07001C99
68220+:102950008D0600183084FFFF008220230004210030
68221+:10296000000010210080182100C2302300E4202B39
68222+:1029700000C4302300E33823AD07001CAD06001867
68223+:1029800093A200198FA30040A462001497A2001A1A
68224+:10299000A46200168FA2001CAC6200108FA2001C63
68225+:1029A000AC62000C93A20019A462002097A2001A46
68226+:1029B000A46200228FA2001CAC6200243C048008A8
68227+:1029C000348300808C6200388FA20020012088218F
68228+:1029D000AC62003C8FA20020AC82000093A20018E1
68229+:1029E000A062004C93A20018A0820009A0600068B9
68230+:1029F00093A20018105100512407FF803229007F54
68231+:102A0000000911C024420240024210213046007FDA
68232+:102A10003C03800000471024AC6200943C02800616
68233+:102A200000C2302190C2003CAFA60040000020212F
68234+:102A300000471025A0C2003C8FA80040950200026C
68235+:102A4000950300148D07001C3042FFFF3063FFFF29
68236+:102A50008D060018004310230002110000E2382107
68237+:102A600000E2102B00C4302100C23021AD07001C51
68238+:102A7000AD06001895020002A5020014A50000167C
68239+:102A80008D020008AD0200108D020008AD02000C9E
68240+:102A900095020002A5020020A50000228D02000878
68241+:102AA000AD0200249102003C304200401040001A68
68242+:102AB000262200013C108008A3A90038A38000183A
68243+:102AC000361001008E0200E08D03003427A4004080
68244+:102AD00027A50038004310210E0007C3AE0200E016
68245+:102AE00093A200383C038000A20200D58C620278D9
68246+:102AF0000440FFFE8F82001CAC62024024020002F0
68247+:102B0000A06202443C021000AC6202780E00093957
68248+:102B100000000000262200013043007F14730004EF
68249+:102B2000004020212403FF8002231024004320269C
68250+:102B300093A200180A000A4B309100FF93A40018DA
68251+:102B40008FA3001C2402FFFF1062000A308900FFDF
68252+:102B500024820001248300013042007F14530005C9
68253+:102B6000306900FF2403FF800083102400431026F7
68254+:102B7000304900FF3C028008904200080120882173
68255+:102B8000305000FF123000193222007F000211C0C5
68256+:102B900002421021244202402403FF8000431824F3
68257+:102BA0003C048000AC8300943042007F3C038006EC
68258+:102BB000004310218C43000C004020211060000BCA
68259+:102BC000AFA200400E00057E000000002623000199
68260+:102BD0002405FF803062007F145300020225202468
68261+:102BE000008518260A000AAF307100FF3C048008F7
68262+:102BF000348400808C8300183C027FFF3442FFFF46
68263+:102C000000621824AC8300183C0380008C6201F839
68264+:102C10000440FFFE00000000AC7201C0240200026C
68265+:102C2000A06201C43C021000AC6201F80A000B0E65
68266+:102C30008FBF00583C04800890C300019082000BB5
68267+:102C40001443002F8FBF0058349000809202000878
68268+:102C500030420040104000200000000092020008B6
68269+:102C60000002160000021603044100050240202164
68270+:102C70000E000ECC240500930A000B0E8FBF0058E7
68271+:102C80009202000924030018304200FF1443000D93
68272+:102C900002402021240500390E000E64000030217E
68273+:102CA0000E0003328F84001C8F82FF9424030012D5
68274+:102CB000A04300090E00033D8F84001C0A000B0E88
68275+:102CC0008FBF0058240500360E000E64000030212E
68276+:102CD0000A000B0E8FBF00580E0003320240202165
68277+:102CE000920200058F84001C344200200E00033D38
68278+:102CF000A20200050E0010758F84001C8FBF0058C3
68279+:102D00008FB300548FB200508FB1004C8FB0004889
68280+:102D100003E0000827BD00603C0280083445010044
68281+:102D20003C0280008C42014094A3000E0000302140
68282+:102D300000402021AF82001C3063FFFF3402FFFF00
68283+:102D4000106200063C0760202402FFFFA4A2000ED0
68284+:102D500094A500EA0A00090130A5FFFF03E000087E
68285+:102D60000000000027BDFFC83C0280003C06800830
68286+:102D7000AFB5002CAFB1001CAFBF0030AFB400281E
68287+:102D8000AFB30024AFB20020AFB00018345101003F
68288+:102D900034C501008C4301008E2200148CA400E491
68289+:102DA0000000A821AF83001C0044102318400052EB
68290+:102DB000A38000188E22001400005021ACA200E471
68291+:102DC00090C3000890A200D53073007FA3A200102A
68292+:102DD0008CB200E08CB400E4304200FF1053003BA2
68293+:102DE00093A200108F83001C2407FF80000211C0F3
68294+:102DF0000062102124420240246300400047102456
68295+:102E00003063007F3C0980003C08800A006818217C
68296+:102E1000AD2200248C62003427A4001427A50010E2
68297+:102E2000024280210290102304400028AFA3001426
68298+:102E30009062003C00E21024304200FF1440001970
68299+:102E4000020090219062003C34420040A062003CAD
68300+:102E50008F86001C93A3001024C200403042007FE4
68301+:102E6000004828213C0208008C4200F42463000141
68302+:102E7000306400FF14820002A3A30010A3A000107E
68303+:102E800093A20010AFA50014000211C0244202401A
68304+:102E900000C2102100471024AD2200240A000B4577
68305+:102EA00093A200100E0007C3000000003C0280083F
68306+:102EB00034420100AC5000E093A30010240A00014A
68307+:102EC000A04300D50A000B4593A200102402000184
68308+:102ED000154200093C0380008C6202780440FFFE2A
68309+:102EE0008F82001CAC62024024020002A0620244F5
68310+:102EF0003C021000AC6202789222000B2403000214
68311+:102F0000304200FF144300720000000096220008C7
68312+:102F1000304300FF24020082146200402402008437
68313+:102F20003C028000344901008D22000C95230006EC
68314+:102F3000000216023063FFFF3045003F24020027E5
68315+:102F400010A2000FAF83001428A200281040000830
68316+:102F5000240200312402002110A2000924020025CD
68317+:102F600010A20007938200190A000BBD00000000A8
68318+:102F700010A20007938200190A000BBD0000000098
68319+:102F80000E000777012020210A000C3D0000000000
68320+:102F90003C0380008C6202780440FFFE8F82001C9C
68321+:102FA000AC62024024020002A06202443C02100013
68322+:102FB000AC6202780A000C3D000000009523000678
68323+:102FC000912400058D25000C8D2600108D270018FA
68324+:102FD0008D28001C8D290020244200013C0108009E
68325+:102FE000A42356C63C010800A02456C53C01080095
68326+:102FF000AC2556CC3C010800AC2656D03C0108005C
68327+:10300000AC2756D83C010800AC2856DC3C0108002F
68328+:10301000AC2956E00A000C3DA38200191462000A94
68329+:10302000240200813C02800834420100944500EAF9
68330+:10303000922600058F84001C30A5FFFF30C600FFDC
68331+:103040000A000BFE3C0760211462005C00000000D7
68332+:103050009222000A304300FF306200201040000737
68333+:10306000306200403C02800834420100944500EA8E
68334+:103070008F84001C0A000BFC24060040104000074F
68335+:10308000000316003C02800834420100944500EA27
68336+:103090008F84001C0A000BFC24060041000216036A
68337+:1030A000044100463C02800834420100944500EA95
68338+:1030B0008F84001C2406004230A5FFFF3C076019E6
68339+:1030C0000E000901000000000A000C3D0000000095
68340+:1030D0009222000B24040016304200FF1044000628
68341+:1030E0003C0680009222000B24030017304200FFB0
68342+:1030F000144300320000000034C5010090A2000B10
68343+:10310000304200FF1444000B000080218CA20020FC
68344+:103110008CA400202403FF800043102400021140EF
68345+:103120003084007F004410253C032000004310251C
68346+:10313000ACC2083094A2000800021400000214037C
68347+:10314000044200012410000194A2000830420080D3
68348+:103150005040001A0200A82194A20008304220002A
68349+:10316000504000160200A8218CA300183C021C2D20
68350+:10317000344219ED106200110200A8213C0208003F
68351+:103180008C4200D4104000053C0280082403000457
68352+:1031900034420100A04300FC3C028008344201009C
68353+:1031A000944500EA8F84001C2406000630A5FFFF2A
68354+:1031B0000E0009013C0760210200A8210E00093918
68355+:1031C000000000009222000A304200081040000473
68356+:1031D00002A010210E0013790000000002A01021AF
68357+:1031E0008FBF00308FB5002C8FB400288FB3002420
68358+:1031F0008FB200208FB1001C8FB0001803E00008D0
68359+:1032000027BD00382402FF80008220243C02900069
68360+:1032100034420007008220253C028000AC4400209C
68361+:103220003C0380008C6200200440FFFE0000000090
68362+:1032300003E00008000000003C0380002402FF803F
68363+:10324000008220243462000700822025AC64002024
68364+:103250008C6200200440FFFE0000000003E0000834
68365+:103260000000000027BDFFD8AFB3001CAFB10014B1
68366+:10327000AFB00010AFBF0020AFB200183C1180000B
68367+:103280003C0280088E32002034530100AE2400201E
68368+:10329000966300EA000514003C074000004738250B
68369+:1032A00000A08021000030210E0009013065FFFFE1
68370+:1032B000240200A1160200022402FFFFA2620009FC
68371+:1032C000AE3200208FBF00208FB3001C8FB20018D9
68372+:1032D0008FB100148FB0001003E0000827BD002854
68373+:1032E0003C0280082403000527BDFFE834420100AA
68374+:1032F000A04300FCAFBF00103C0280008C420100E4
68375+:10330000240500A1004020210E000C67AF82001CA4
68376+:103310003C0380008C6202780440FFFE8F82001C18
68377+:103320008FBF001027BD0018AC62024024020002CB
68378+:10333000A06202443C021000AC62027803E0000884
68379+:103340000000000027BDFFE83C068000AFBF001072
68380+:1033500034C7010094E20008304400FF3883008243
68381+:10336000388200842C6300012C4200010062182581
68382+:103370001060002D24020083938200195040003B0E
68383+:103380008FBF00103C020800904256CC8CC4010054
68384+:103390003C06080094C656C63045003F38A30032AC
68385+:1033A00038A2003F2C6300012C4200010062182566
68386+:1033B000AF84001CAF860014A380001914600007BE
68387+:1033C00000E020212402002014A2001200000000CE
68388+:1033D0003402FFFF14C2000F00000000240200208E
68389+:1033E00014A2000500E028218CE300142402FFFF52
68390+:1033F0005062000B8FBF00103C040800248456C0AC
68391+:10340000000030210E000706240700010A000CD638
68392+:103410008FBF00100E000777000000008FBF001064
68393+:103420000A00093927BD001814820004240200850F
68394+:103430008CC501040A000CE1000020211482000662
68395+:103440002482FF808CC50104240440008FBF00103B
68396+:103450000A00016727BD0018304200FF2C4200021D
68397+:1034600010400004240200228FBF00100A000B2726
68398+:1034700027BD0018148200048F8200248FBF001023
68399+:103480000A000C8627BD00188C42000C1040001E5C
68400+:1034900000E0282190E300092402001814620003D0
68401+:1034A000240200160A000CFC240300081462000722
68402+:1034B00024020017240300123C02800834420080DA
68403+:1034C000A04300090A000D0994A7000854620007F0
68404+:1034D00094A700088F82FF942404FFFE9043000508
68405+:1034E00000641824A043000594A7000890A6001BC0
68406+:1034F0008CA4000094A500068FBF001000073C00BC
68407+:103500000A0008DC27BD00188FBF001003E0000888
68408+:1035100027BD00188F8500243C04800094A2002A57
68409+:103520008CA30034000230C02402FFF000C210243B
68410+:1035300000621821AC83003C8CA200303C03800068
68411+:10354000AC8200383C02005034420010AC620030C3
68412+:103550000000000000000000000000008C6200007D
68413+:10356000304200201040FFFD30C20008104000062D
68414+:103570003C0280008C620408ACA200208C62040C27
68415+:103580000A000D34ACA200248C430400ACA300203C
68416+:103590008C420404ACA200243C0300203C028000C6
68417+:1035A000AC4300303C0480008C8200300043102487
68418+:1035B0001440FFFD8F8600243C020040AC820030A6
68419+:1035C00094C3002A94C2002894C4002C94C5002EF1
68420+:1035D00024630001004410213064FFFFA4C20028CE
68421+:1035E00014850002A4C3002AA4C0002A03E0000836
68422+:1035F000000000008F84002427BDFFE83C05800404
68423+:1036000024840010AFBF00100E000E472406000AED
68424+:103610008F840024948200129483002E3042000F85
68425+:10362000244200030043180424027FFF0043102BB0
68426+:1036300010400002AC8300000000000D0E000D13CE
68427+:10364000000000008F8300248FBF001027BD0018EA
68428+:10365000946200149463001A3042000F00021500B7
68429+:10366000006218253C02800003E00008AC4300A083
68430+:103670008F8300243C028004944400069462001A64
68431+:103680008C650000A4640016004410233042FFFF44
68432+:103690000045102B03E00008384200018F8400240D
68433+:1036A0003C0780049486001A8C85000094E2000692
68434+:1036B000A482001694E3000600C310233042FFFFEB
68435+:1036C0000045102B384200011440FFF8A483001677
68436+:1036D00003E00008000000008F8400243C02800406
68437+:1036E000944200069483001A8C850000A482001680
68438+:1036F000006210233042FFFF0045102B38420001CA
68439+:103700005040000D8F850024006030213C0780046C
68440+:1037100094E20006A482001694E3000600C310237E
68441+:103720003042FFFF0045102B384200011440FFF8E3
68442+:10373000A48300168F8500243C03800034620400BB
68443+:103740008CA40020AF820020AC6400388CA200243E
68444+:10375000AC62003C3C020005AC62003003E00008B3
68445+:10376000ACA000048F8400243C0300068C8200047B
68446+:1037700000021140004310253C038000AC62003081
68447+:103780000000000000000000000000008C6200004B
68448+:10379000304200101040FFFD34620400AC80000491
68449+:1037A00003E00008AF8200208F86002427BDFFE0E1
68450+:1037B000AFB10014AFB00010AFBF00188CC300044D
68451+:1037C0008CC500248F820020309000FF94C4001A22
68452+:1037D00024630001244200202484000124A7002047
68453+:1037E000ACC30004AF820020A4C4001AACC70024FC
68454+:1037F00004A100060000882104E2000594C2001A1A
68455+:103800008CC2002024420001ACC2002094C2001AE5
68456+:1038100094C300282E040001004310262C4200010E
68457+:10382000004410245040000594C2001A24020001F4
68458+:10383000ACC2000894C2001A94C300280010202BC8
68459+:10384000004310262C4200010044102514400007BC
68460+:10385000000000008CC20008144000042402001084
68461+:103860008CC300041462000F8F8500240E000DA786
68462+:10387000241100018F820024944300289442001AEE
68463+:1038800014430003000000000E000D1300000000B0
68464+:10389000160000048F8500240E000D840000000037
68465+:1038A0008F85002494A2001E94A4001C24420001D1
68466+:1038B0003043FFFF14640002A4A2001EA4A0001E57
68467+:1038C0001200000A3C02800494A2001494A3001A7F
68468+:1038D0003042000F00021500006218253C028000F3
68469+:1038E000AC4300A00A000E1EACA0000894420006E3
68470+:1038F00094A3001A8CA40000A4A200160062102356
68471+:103900003042FFFF0044102B384200011040000DF0
68472+:1039100002201021006030213C07800494E2000660
68473+:10392000A4A2001694E3000600C310233042FFFF58
68474+:103930000044102B384200011440FFF8A4A30016E5
68475+:10394000022010218FBF00188FB100148FB000101B
68476+:1039500003E0000827BD002003E00008000000008D
68477+:103960008F82002C3C03000600021140004310250A
68478+:103970003C038000AC62003000000000000000004A
68479+:10398000000000008C620000304200101040FFFD7B
68480+:1039900034620400AF82002803E00008AF80002CEE
68481+:1039A00003E000080000102103E000080000000010
68482+:1039B0003084FFFF30A5FFFF0000182110800007B2
68483+:1039C000000000003082000110400002000420428C
68484+:1039D000006518210A000E3D0005284003E000089C
68485+:1039E0000060102110C0000624C6FFFF8CA200005A
68486+:1039F00024A50004AC8200000A000E4724840004C1
68487+:103A000003E000080000000010A0000824A3FFFF4E
68488+:103A1000AC86000000000000000000002402FFFF50
68489+:103A20002463FFFF1462FFFA2484000403E000080B
68490+:103A3000000000003C0280083442008024030001A2
68491+:103A4000AC43000CA4430010A4430012A443001490
68492+:103A500003E00008A44300168F82002427BDFFD88E
68493+:103A6000AFB3001CAFB20018AFB10014AFB000107C
68494+:103A7000AFBF00208C47000C248200802409FF8007
68495+:103A80003C08800E3043007F008080213C0A80008B
68496+:103A9000004920240068182130B100FF30D200FF17
68497+:103AA00010E000290000982126020100AD44002CFE
68498+:103AB000004928243042007F004820219062000005
68499+:103AC00024030050304200FF1443000400000000B3
68500+:103AD000AD45002C948200EA3053FFFF0E000D84A8
68501+:103AE000000000008F8200248F83002000112C0032
68502+:103AF0009442001E001224003484000100A22825F4
68503+:103B00003C02400000A22825AC7000008FBF0020BE
68504+:103B1000AC6000048FB20018AC7300088FB10014C1
68505+:103B2000AC60000C8FB3001CAC6400108FB00010B0
68506+:103B3000AC60001424040001AC60001827BD00280C
68507+:103B40000A000DB8AC65001C8FBF00208FB3001CAD
68508+:103B50008FB200188FB100148FB0001003E000087E
68509+:103B600027BD00283C06800034C201009043000FAE
68510+:103B7000240200101062000E2865001110A000073A
68511+:103B800024020012240200082405003A10620006F4
68512+:103B90000000302103E0000800000000240500358B
68513+:103BA0001462FFFC000030210A000E6400000000D7
68514+:103BB0008CC200748F83FF9424420FA003E000089E
68515+:103BC000AC62000C27BDFFE8AFBF00100E0003423F
68516+:103BD000240500013C0480088FBF0010240200016E
68517+:103BE00034830080A462001227BD00182402000163
68518+:103BF00003E00008A080001A27BDFFE0AFB2001864
68519+:103C0000AFB10014AFB00010AFBF001C30B2FFFF67
68520+:103C10000E000332008088213C028008345000806E
68521+:103C20009202000924030004304200FF1443000CF8
68522+:103C30003C028008124000082402000A0E000E5BBD
68523+:103C400000000000920200052403FFFE0043102440
68524+:103C5000A202000524020012A20200093C02800810
68525+:103C600034420080022020210E00033DA0400027A6
68526+:103C700016400003022020210E000EBF00000000AD
68527+:103C800002202021324600FF8FBF001C8FB2001897
68528+:103C90008FB100148FB00010240500380A000E64A4
68529+:103CA00027BD002027BDFFE0AFBF001CAFB200184A
68530+:103CB000AFB10014AFB000100E00033200808021BD
68531+:103CC0000E000E5B000000003C02800834450080BE
68532+:103CD00090A2000924120018305100FF1232000394
68533+:103CE0000200202124020012A0A2000990A20005D7
68534+:103CF0002403FFFE004310240E00033DA0A2000594
68535+:103D00000200202124050020163200070000302187
68536+:103D10008FBF001C8FB200188FB100148FB000103D
68537+:103D20000A00034227BD00208FBF001C8FB200187D
68538+:103D30008FB100148FB00010240500390A000E6402
68539+:103D400027BD002027BDFFE83C028000AFB0001077
68540+:103D5000AFBF0014344201009442000C2405003629
68541+:103D60000080802114400012304600FF0E00033214
68542+:103D7000000000003C02800834420080240300124E
68543+:103D8000A043000990430005346300100E000E5B51
68544+:103D9000A04300050E00033D020020210200202167
68545+:103DA0000E000342240500200A000F3C0000000022
68546+:103DB0000E000E64000000000E00033202002021FD
68547+:103DC0003C0280089043001B2405FF9F0200202135
68548+:103DD000006518248FBF00148FB00010A043001B93
68549+:103DE0000A00033D27BD001827BDFFE0AFBF001844
68550+:103DF000AFB10014AFB0001030B100FF0E000332BD
68551+:103E0000008080213C02800824030012344200809C
68552+:103E10000E000E5BA04300090E00033D02002021AE
68553+:103E200002002021022030218FBF00188FB1001422
68554+:103E30008FB00010240500350A000E6427BD002055
68555+:103E40003C0480089083000E9082000A1443000B0B
68556+:103E5000000028218F82FF942403005024050001D4
68557+:103E600090420000304200FF1443000400000000B4
68558+:103E70009082000E24420001A082000E03E00008A0
68559+:103E800000A010213C0380008C6201F80440FFFE7A
68560+:103E900024020002AC6401C0A06201C43C02100014
68561+:103EA00003E00008AC6201F827BDFFE0AFB20018E4
68562+:103EB0003C128008AFB10014AFBF001CAFB00010BF
68563+:103EC00036510080922200092403000A304200FF8C
68564+:103ED0001443003E000000008E4300048E22003890
68565+:103EE000506200808FBF001C92220000240300500B
68566+:103EF000304200FF144300253C0280008C42014008
68567+:103F00008E4300043642010002202821AC43001CED
68568+:103F10009622005C8E2300383042FFFF00021040E2
68569+:103F200000621821AE23001C8E4300048E2400384A
68570+:103F30009622005C006418233042FFFF0003184300
68571+:103F4000000210400043102A10400006000000004C
68572+:103F50008E4200048E230038004310230A000FAA6B
68573+:103F6000000220439622005C3042FFFF0002204006
68574+:103F70003C0280083443010034420080ACA4002C91
68575+:103F8000A040002424020001A062000C0E000F5E7D
68576+:103F900000000000104000538FBF001C3C02800056
68577+:103FA0008C4401403C0380008C6201F80440FFFE19
68578+:103FB00024020002AC6401C0A06201C43C021000F3
68579+:103FC000AC6201F80A0010078FBF001C92220009A2
68580+:103FD00024030010304200FF144300043C02800020
68581+:103FE0008C4401400A000FEE0000282192220009B3
68582+:103FF00024030016304200FF14430006240200147C
68583+:10400000A22200093C0280008C4401400A001001F9
68584+:104010008FBF001C8E2200388E23003C00431023EB
68585+:10402000044100308FBF001C92220027244200016F
68586+:10403000A2220027922200272C42000414400016DE
68587+:104040003C1080009222000924030004304200FF4B
68588+:10405000144300093C0280008C4401408FBF001CC7
68589+:104060008FB200188FB100148FB000102405009398
68590+:104070000A000ECC27BD00208C440140240500938B
68591+:104080008FBF001C8FB200188FB100148FB00010CA
68592+:104090000A000F4827BD00208E0401400E000332A5
68593+:1040A000000000008E4200042442FFFFAE420004E4
68594+:1040B0008E22003C2442FFFFAE22003C0E00033D56
68595+:1040C0008E0401408E0401408FBF001C8FB2001887
68596+:1040D0008FB100148FB00010240500040A000342C1
68597+:1040E00027BD00208FB200188FB100148FB00010D0
68598+:1040F00003E0000827BD00203C0680008CC2018838
68599+:104100003C038008346500809063000E00021402B6
68600+:10411000304400FF306300FF1464000E3C0280084E
68601+:1041200090A20026304200FF104400098F82FF94C5
68602+:10413000A0A400262403005090420000304200FF5B
68603+:1041400014430006000000000A0005A18CC4018091
68604+:104150003C02800834420080A044002603E00008AE
68605+:104160000000000027BDFFE030E700FFAFB20018FD
68606+:10417000AFBF001CAFB10014AFB0001000809021A1
68607+:1041800014E0000630C600FF000000000000000D33
68608+:10419000000000000A001060240001163C038008A3
68609+:1041A0009062000E304200FF14460023346200800B
68610+:1041B00090420026304200FF1446001F000000001D
68611+:1041C0009062000F304200FF1446001B0000000008
68612+:1041D0009062000A304200FF144600038F90FF9463
68613+:1041E0000000000D8F90FF948F82FF983C1180009B
68614+:1041F000AE05003CAC450000A066000A0E0003328C
68615+:104200008E240100A20000240E00033D8E24010034
68616+:104210003C0380008C6201F80440FFFE240200028F
68617+:10422000AC7201C0A06201C43C021000AC6201F893
68618+:104230000A0010618FBF001C000000000000000D8C
68619+:10424000000000002400013F8FBF001C8FB2001847
68620+:104250008FB100148FB0001003E0000827BD0020CC
68621+:104260008F83FF943C0280008C44010034420100A3
68622+:104270008C65003C9046001B0A00102724070001B3
68623+:104280003C0280089043000E9042000A0043102632
68624+:10429000304200FF03E000080002102B27BDFFE0C2
68625+:1042A0003C028008AFB10014AFB00010AFBF0018DF
68626+:1042B0003450008092020005240300303042003068
68627+:1042C00014430085008088218F8200248C42000CDA
68628+:1042D000104000828FBF00180E000D840000000007
68629+:1042E0008F860020ACD100009202000892030009E2
68630+:1042F000304200FF00021200306300FF004310252F
68631+:10430000ACC200049202004D000216000002160327
68632+:1043100004410005000000003C0308008C630048D5
68633+:104320000A00109F3C1080089202000830420040B2
68634+:10433000144000030000182192020027304300FFC0
68635+:104340003C108008361100809222004D00031E00B0
68636+:10435000304200FF0002140000621825ACC30008C0
68637+:104360008E2400308F820024ACC4000C8E250034D3
68638+:104370009443001E3C02C00BACC50010006218251F
68639+:104380008E22003800002021ACC200148E22003C96
68640+:10439000ACC200180E000DB8ACC3001C8E020004A5
68641+:1043A0008F8400203C058000AC8200008E2200201B
68642+:1043B000AC8200048E22001CAC8200088E220058C1
68643+:1043C0008CA3007400431021AC82000C8E22002CC0
68644+:1043D000AC8200108E2200408E23004400021400A4
68645+:1043E00000431025AC8200149222004D240300806B
68646+:1043F000304200FF1443000400000000AC800018AD
68647+:104400000A0010E38F8200248E23000C2402000196
68648+:104410001062000E2402FFFF92220008304200408A
68649+:104420001440000A2402FFFF8E23000C8CA20074AB
68650+:10443000006218233C0208000062102414400002AD
68651+:10444000000028210060282100051043AC820018DC
68652+:104450008F820024000020219443001E3C02C00CE7
68653+:10446000006218258F8200200E000DB8AC43001C9E
68654+:104470003C038008346201008C4200008F850020DC
68655+:10448000346300808FBF0018ACA20000ACA0000411
68656+:104490008C6400488F8200248FB10014ACA4000803
68657+:1044A000ACA0000CACA00010906300059446001E68
68658+:1044B0003C02400D00031E0000C23025ACA30014D6
68659+:1044C0008FB00010ACA0001824040001ACA6001CA2
68660+:1044D0000A000DB827BD00208FBF00188FB100144F
68661+:1044E0008FB0001003E0000827BD00203C028000D0
68662+:1044F0009443007C3C02800834460100308400FF75
68663+:104500003065FFFF2402000524A34650A0C4000C20
68664+:104510005482000C3065FFFF90C2000D2C42000752
68665+:104520001040000724A30A0090C3000D24020014C9
68666+:104530000062100400A210210A00111F3045FFFF85
68667+:104540003065FFFF3C0280083442008003E0000831
68668+:10455000A44500143C03800834680080AD05003891
68669+:10456000346701008CE2001C308400FF00A210239D
68670+:104570001840000330C600FF24A2FFFCACE2001C80
68671+:1045800030820001504000083C0380088D02003C4E
68672+:1045900000A2102304410012240400058C620004D0
68673+:1045A00010A2000F3C0380088C62000414A2001EBD
68674+:1045B000000000003C0208008C4200D8304200207D
68675+:1045C000104000093C0280083462008090630008BB
68676+:1045D0009042004C144300043C0280082404000470
68677+:1045E0000A00110900000000344300803442010039
68678+:1045F000A040000C24020001A462001410C0000AB4
68679+:104600003C0280008C4401003C0380008C6201F875
68680+:104610000440FFFE24020002AC6401C0A06201C499
68681+:104620003C021000AC6201F803E00008000000004A
68682+:1046300027BDFFE800A61823AFBF00101860008058
68683+:10464000308800FF3C02800834470080A0E000244E
68684+:1046500034440100A0E000278C82001C00A210233B
68685+:1046600004400056000000008CE2003C94E3005C33
68686+:104670008CE4002C004530233063FFFF00C3182179
68687+:104680000083202B1080000400E018218CE2002C15
68688+:104690000A00117800A2102194E2005C3042FFFF72
68689+:1046A00000C2102100A21021AC62001C3C02800854
68690+:1046B000344400809482005C8C83001C3042FFFFF5
68691+:1046C0000002104000A210210043102B10400004F3
68692+:1046D000000000008C82001C0A00118B3C06800840
68693+:1046E0009482005C3042FFFF0002104000A21021C3
68694+:1046F0003C06800834C3010034C70080AC82001C33
68695+:10470000A060000CACE500388C62001C00A21023F5
68696+:104710001840000224A2FFFCAC62001C3102000120
68697+:10472000104000083C0380088CE2003C00A21023EB
68698+:1047300004410012240400058CC2000410A20010E1
68699+:104740008FBF00108C62000414A2004F8FBF0010B6
68700+:104750003C0208008C4200D8304200201040000A81
68701+:104760003C02800834620080906300089042004C54
68702+:10477000144300053C028008240400048FBF00108D
68703+:104780000A00110927BD001834430080344201009B
68704+:10479000A040000C24020001A46200143C0280002E
68705+:1047A0008C4401003C0380008C6201F80440FFFE51
68706+:1047B000240200020A0011D8000000008CE2001C54
68707+:1047C000004610230043102B54400001ACE5001CB0
68708+:1047D00094E2005C3042FFFF0062102B144000079F
68709+:1047E0002402000294E2005C8CE3001C3042FFFFD4
68710+:1047F00000621821ACE3001C24020002ACE5003882
68711+:104800000E000F5EA082000C1040001F8FBF001032
68712+:104810003C0280008C4401003C0380008C6201F863
68713+:104820000440FFFE24020002AC6401C0A06201C487
68714+:104830003C021000AC6201F80A0011F08FBF0010BA
68715+:1048400031020010104000108FBF00103C028008A1
68716+:10485000344500808CA3001C94A2005C00661823E1
68717+:104860003042FFFF006218213C023FFF3444FFFF4B
68718+:104870000083102B544000010080182100C3102138
68719+:10488000ACA2001C8FBF001003E0000827BD001879
68720+:1048900027BDFFE800C0402100A63023AFBF0010B5
68721+:1048A00018C00026308A00FF3C028008344900808E
68722+:1048B0008D24001C8D23002C008820230064182BDD
68723+:1048C0001060000F344701008CE2002000461021E8
68724+:1048D000ACE200208CE200200044102B1440000BBE
68725+:1048E0003C023FFF8CE2002000441023ACE2002099
68726+:1048F0009522005C3042FFFF0A0012100082202146
68727+:10490000ACE00020008620213C023FFF3443FFFF43
68728+:104910000064102B54400001006020213C028008FC
68729+:104920003442008000851821AC43001CA0400024C4
68730+:10493000A04000270A0012623C03800831420010A8
68731+:10494000104000433C0380083C06800834C40080CB
68732+:104950008C82003C004810235840003E34660080A2
68733+:104960009082002424420001A0820024908200242E
68734+:104970003C0308008C630024304200FF0043102BEE
68735+:10498000144000688FBF001034C201008C42001C2C
68736+:1049900000A2102318400063000000008CC3000434
68737+:1049A0009482005C006818233042FFFF0003184324
68738+:1049B000000210400043102A1040000500000000D3
68739+:1049C0008CC20004004810230A0012450002104364
68740+:1049D0009482005C3042FFFF000210403C068008D9
68741+:1049E000AC82002C34C5008094A2005C8CA4002C06
68742+:1049F00094A3005C3042FFFF00021040008220219F
68743+:104A00003063FFFF0083202101041021ACA2001CB1
68744+:104A10008CC2000434C60100ACC2001C2402000297
68745+:104A20000E000F5EA0C2000C1040003E8FBF0010B1
68746+:104A30003C0280008C4401003C0380008C6201F841
68747+:104A40000440FFFE240200020A001292000000004F
68748+:104A500034660080ACC50038346401008C82001CD0
68749+:104A600000A210231840000224A2FFFCAC82001C0C
68750+:104A7000314200015040000A3C0380088CC2003CD7
68751+:104A800000A2102304430014240400058C620004D7
68752+:104A900014A200033C0380080A00128424040005C9
68753+:104AA0008C62000414A2001F8FBF00103C0208009B
68754+:104AB0008C4200D8304200201040000A3C0280089E
68755+:104AC00034620080906300089042004C144300055B
68756+:104AD0003C028008240400048FBF00100A00110962
68757+:104AE00027BD00183443008034420100A040000C70
68758+:104AF00024020001A46200143C0280008C440100E6
68759+:104B00003C0380008C6201F80440FFFE2402000296
68760+:104B1000AC6401C0A06201C43C021000AC6201F8A8
68761+:104B20008FBF001003E0000827BD001827BDFFE875
68762+:104B30003C0A8008AFBF0010354900808D22003C40
68763+:104B400000C04021308400FF004610231840009D23
68764+:104B500030E700FF354701002402000100A63023A2
68765+:104B6000A0E0000CA0E0000DA522001418C0002455
68766+:104B7000308200108D23001C8D22002C0068182329
68767+:104B80000043102B1040000F000000008CE20020BA
68768+:104B900000461021ACE200208CE200200043102BE4
68769+:104BA0001440000B3C023FFF8CE200200043102326
68770+:104BB000ACE200209522005C3042FFFF0A0012C1E7
68771+:104BC00000621821ACE00020006618213C023FFF83
68772+:104BD0003446FFFF00C3102B5440000100C01821D1
68773+:104BE0003C0280083442008000651821AC43001C60
68774+:104BF000A0400024A04000270A00130F3C038008B7
68775+:104C0000104000403C0380088D22003C00481023E7
68776+:104C10005840003D34670080912200242442000166
68777+:104C2000A1220024912200243C0308008C6300246C
68778+:104C3000304200FF0043102B1440009A8FBF001039
68779+:104C40008CE2001C00A21023184000960000000017
68780+:104C50008D4300049522005C006818233042FFFF5A
68781+:104C600000031843000210400043102A10400005C2
68782+:104C7000012020218D420004004810230A0012F276
68783+:104C8000000210439522005C3042FFFF00021040FA
68784+:104C90003C068008AC82002C34C5008094A2005CE5
68785+:104CA0008CA4002C94A3005C3042FFFF0002104053
68786+:104CB000008220213063FFFF0083182101031021AF
68787+:104CC000ACA2001C8CC2000434C60100ACC2001CA3
68788+:104CD000240200020E000F5EA0C2000C1040007102
68789+:104CE0008FBF00103C0280008C4401003C03800018
68790+:104CF0008C6201F80440FFFE240200020A0013390E
68791+:104D00000000000034670080ACE500383466010024
68792+:104D10008CC2001C00A210231840000224A2FFFC39
68793+:104D2000ACC2001C30820001504000083C038008E7
68794+:104D30008CE2003C00A2102304430051240400052F
68795+:104D40008C62000410A2003E3C0380088C620004C8
68796+:104D500054A200548FBF00103C0208008C4200D8BF
68797+:104D600030420020104000063C028008346200807F
68798+:104D7000906300089042004C104300403C028008C1
68799+:104D80003443008034420100A040000C24020001A2
68800+:104D9000A46200143C0280008C4401003C038000AB
68801+:104DA0008C6201F80440FFFE24020002AC6401C0E2
68802+:104DB000A06201C43C021000AC6201F80A00137743
68803+:104DC0008FBF001024020005A120002714E2000A72
68804+:104DD0003C038008354301009062000D2C42000620
68805+:104DE000504000053C0380089062000D2442000101
68806+:104DF000A062000D3C03800834670080ACE50038F9
68807+:104E0000346601008CC2001C00A21023184000026E
68808+:104E100024A2FFFCACC2001C308200015040000AFA
68809+:104E20003C0380088CE2003C00A2102304410014E3
68810+:104E3000240400058C62000414A200033C038008D3
68811+:104E40000A00136E240400058C62000414A20015ED
68812+:104E50008FBF00103C0208008C4200D83042002076
68813+:104E60001040000A3C028008346200809063000811
68814+:104E70009042004C144300053C02800824040004C6
68815+:104E80008FBF00100A00110927BD001834430080AD
68816+:104E900034420100A040000C24020001A46200146E
68817+:104EA0008FBF001003E0000827BD00183C0B8008EE
68818+:104EB00027BDFFE83C028000AFBF00103442010074
68819+:104EC000356A00809044000A356901008C45001461
68820+:104ED0008D4800389123000C308400FF0105102319
68821+:104EE0001C4000B3306700FF2CE20006504000B1C8
68822+:104EF0008FBF00102402000100E2300430C2000322
68823+:104F00005440000800A8302330C2000C144000A117
68824+:104F100030C20030144000A38FBF00100A00143BC1
68825+:104F20000000000018C00024308200108D43001CD7
68826+:104F30008D42002C006818230043102B1040000FF6
68827+:104F4000000000008D22002000461021AD2200202C
68828+:104F50008D2200200043102B1440000B3C023FFF29
68829+:104F60008D22002000431023AD2200209542005CDA
68830+:104F70003042FFFF0A0013AF00621821AD2000206D
68831+:104F8000006618213C023FFF3446FFFF00C3102B90
68832+:104F90005440000100C018213C02800834420080C7
68833+:104FA00000651821AC43001CA0400024A04000274D
68834+:104FB0000A0013FD3C038008104000403C038008B9
68835+:104FC0008D42003C004810231840003D34670080AB
68836+:104FD0009142002424420001A14200249142002475
68837+:104FE0003C0308008C630024304200FF0043102B78
68838+:104FF000144000708FBF00108D22001C00A21023EF
68839+:105000001840006C000000008D6300049542005CB5
68840+:10501000006818233042FFFF0003184300021040CD
68841+:105020000043102A10400005014020218D62000439
68842+:10503000004810230A0013E0000210439542005C70
68843+:105040003042FFFF000210403C068008AC82002C7A
68844+:1050500034C5008094A2005C8CA4002C94A3005C56
68845+:105060003042FFFF00021040008220213063FFFF2A
68846+:105070000083182101031021ACA2001C8CC2000483
68847+:1050800034C60100ACC2001C240200020E000F5EF8
68848+:10509000A0C2000C104000478FBF00103C028000EF
68849+:1050A0008C4401003C0380008C6201F80440FFFE48
68850+:1050B000240200020A00142D000000003467008062
68851+:1050C000ACE50038346601008CC2001C00A210233D
68852+:1050D0001840000224A2FFFCACC2001C3082000178
68853+:1050E0005040000A3C0380088CE2003C00A21023E0
68854+:1050F00004430014240400058C62000414A200037D
68855+:105100003C0380080A00141F240400058C6200047C
68856+:1051100014A200288FBF00103C0208008C4200D867
68857+:10512000304200201040000A3C02800834620080B7
68858+:10513000906300089042004C144300053C02800834
68859+:10514000240400048FBF00100A00110927BD0018B5
68860+:105150003443008034420100A040000C24020001CE
68861+:10516000A46200143C0280008C4401003C038000D7
68862+:105170008C6201F80440FFFE24020002AC6401C00E
68863+:10518000A06201C43C021000AC6201F80A00143BAA
68864+:105190008FBF00108FBF0010010030210A00115A8C
68865+:1051A00027BD0018010030210A00129927BD001800
68866+:1051B0008FBF001003E0000827BD00183C038008E3
68867+:1051C0003464010024020003A082000C8C620004FD
68868+:1051D00003E00008AC82001C3C05800834A300807A
68869+:1051E0009062002734A501002406004324420001F8
68870+:1051F000A0620027906300273C0208008C42004810
68871+:10520000306300FF146200043C07602194A500EAAB
68872+:105210000A00090130A5FFFF03E0000800000000BC
68873+:1052200027BDFFE8AFBF00103C0280000E00144411
68874+:105230008C4401803C02800834430100A060000CD3
68875+:105240008C4200048FBF001027BD001803E0000847
68876+:10525000AC62001C27BDFFE03C028008AFBF001815
68877+:10526000AFB10014AFB000103445008034460100E7
68878+:105270003C0880008D09014090C3000C8CA4003CC8
68879+:105280008CA200381482003B306700FF9502007C3E
68880+:1052900090A30027146000093045FFFF2402000599
68881+:1052A00054E200083C04800890C2000D2442000132
68882+:1052B000A0C2000D0A00147F3C048008A0C0000DAD
68883+:1052C0003C048008348201009042000C2403000555
68884+:1052D000304200FF1443000A24A205DC348300801E
68885+:1052E000906200272C4200075040000524A20A00CB
68886+:1052F00090630027240200140062100400A2102111
68887+:105300003C108008361000803045FFFF012020212E
68888+:105310000E001444A60500149602005C8E030038AB
68889+:105320003C1180003042FFFF000210400062182153
68890+:10533000AE03001C0E0003328E24014092020025B1
68891+:1053400034420040A20200250E00033D8E2401409D
68892+:105350008E2401403C0380008C6201F80440FFFE73
68893+:1053600024020002AC6401C0A06201C43C0210002F
68894+:10537000AC6201F88FBF00188FB100148FB000101D
68895+:1053800003E0000827BD00203C0360103C02080039
68896+:1053900024420174AC62502C8C6250003C048000AA
68897+:1053A00034420080AC6250003C0208002442547C2D
68898+:1053B0003C010800AC2256003C020800244254384C
68899+:1053C0003C010800AC2256043C020002AC840008F8
68900+:1053D000AC82000C03E000082402000100A0302190
68901+:1053E0003C1C0800279C56083C0200023C050400B7
68902+:1053F00000852826008220260004102B2CA5000101
68903+:105400002C840001000210803C0308002463560035
68904+:105410000085202500431821108000030000102182
68905+:10542000AC6600002402000103E000080000000058
68906+:105430003C1C0800279C56083C0200023C05040066
68907+:1054400000852826008220260004102B2CA50001B0
68908+:105450002C840001000210803C03080024635600E5
68909+:105460000085202500431821108000050000102130
68910+:105470003C02080024425438AC62000024020001BF
68911+:1054800003E00008000000003C0200023C030400AE
68912+:1054900000821026008318262C4200012C63000194
68913+:1054A000004310251040000B000028213C1C080080
68914+:1054B000279C56083C0380008C62000824050001EC
68915+:1054C00000431025AC6200088C62000C00441025DB
68916+:1054D000AC62000C03E0000800A010213C1C080096
68917+:1054E000279C56083C0580008CA3000C0004202754
68918+:1054F000240200010064182403E00008ACA3000C9F
68919+:105500003C020002148200063C0560008CA208D018
68920+:105510002403FFFE0043102403E00008ACA208D0DF
68921+:105520003C02040014820005000000008CA208D098
68922+:105530002403FFFD00431024ACA208D003E00008C0
68923+:10554000000000003C02601A344200108C430080CE
68924+:1055500027BDFFF88C440084AFA3000093A3000094
68925+:10556000240200041462001AAFA4000493A20001F4
68926+:105570001040000797A300023062FFFC3C0380004C
68927+:10558000004310218C4200000A001536AFA200042F
68928+:105590003062FFFC3C03800000431021AC4400005B
68929+:1055A000A3A000003C0560008CA208D02403FFFEED
68930+:1055B0003C04601A00431024ACA208D08FA300045E
68931+:1055C0008FA2000034840010AC830084AC82008081
68932+:1055D00003E0000827BD000827BDFFE8AFBF0010AB
68933+:1055E0003C1C0800279C56083C0280008C43000CA1
68934+:1055F0008C420004004318243C0200021060001496
68935+:10560000006228243C0204003C04000210A00005B3
68936+:10561000006210243C0208008C4256000A00155B10
68937+:1056200000000000104000073C0404003C02080099
68938+:105630008C4256040040F809000000000A00156082
68939+:10564000000000000000000D3C1C0800279C5608CC
68940+:105650008FBF001003E0000827BD0018800802403B
68941+:1056600080080100800800808008000000000C8095
68942+:105670000000320008000E9808000EF408000F88A1
68943+:1056800008001028080010748008010080080080BD
68944+:10569000800800000A000028000000000000000050
68945+:1056A0000000000D6370362E322E316200000000C3
68946+:1056B00006020104000000000000000000000000DD
68947+:1056C000000000000000000038003C000000000066
68948+:1056D00000000000000000000000000000000020AA
68949+:1056E00000000000000000000000000000000000BA
68950+:1056F00000000000000000000000000000000000AA
68951+:10570000000000000000000021003800000000013F
68952+:105710000000002B000000000000000400030D400A
68953+:105720000000000000000000000000000000000079
68954+:105730000000000000000000100000030000000056
68955+:105740000000000D0000000D3C020800244259AC8E
68956+:105750003C03080024635BF4AC4000000043202BB2
68957+:105760001480FFFD244200043C1D080037BD9FFC4F
68958+:1057700003A0F0213C100800261000A03C1C0800EB
68959+:10578000279C59AC0E0002F6000000000000000D3E
68960+:1057900027BDFFB4AFA10000AFA20004AFA3000873
68961+:1057A000AFA4000CAFA50010AFA60014AFA700185F
68962+:1057B000AFA8001CAFA90020AFAA0024AFAB0028FF
68963+:1057C000AFAC002CAFAD0030AFAE0034AFAF00389F
68964+:1057D000AFB8003CAFB90040AFBC0044AFBF004819
68965+:1057E0000E000820000000008FBF00488FBC00445E
68966+:1057F0008FB900408FB8003C8FAF00388FAE0034B7
68967+:105800008FAD00308FAC002C8FAB00288FAA002406
68968+:105810008FA900208FA8001C8FA700188FA6001446
68969+:105820008FA500108FA4000C8FA300088FA2000486
68970+:105830008FA1000027BD004C3C1B60188F7A5030B0
68971+:10584000377B502803400008AF7A000000A01821E1
68972+:1058500000801021008028213C0460003C0760008B
68973+:105860002406000810600006348420788C42000072
68974+:10587000ACE220088C63000003E00008ACE3200CDD
68975+:105880000A000F8100000000240300403C02600079
68976+:1058900003E00008AC4320003C0760008F86000452
68977+:1058A0008CE520740086102100A2182B14600007DC
68978+:1058B000000028218F8AFDA024050001A1440013C7
68979+:1058C0008F89000401244021AF88000403E0000810
68980+:1058D00000A010218F84FDA08F8500049086001306
68981+:1058E00030C300FF00A31023AF82000403E00008D0
68982+:1058F000A08000138F84FDA027BDFFE8AFB000108B
68983+:10590000AFBF001490890011908700112402002875
68984+:10591000312800FF3906002830E300FF2485002CE1
68985+:105920002CD00001106200162484001C0E00006EB2
68986+:10593000000000008F8FFDA03C05600024020204DF
68987+:1059400095EE003E95ED003C000E5C0031ACFFFF93
68988+:10595000016C5025ACAA2010520000012402000462
68989+:10596000ACA22000000000000000000000000000C9
68990+:105970008FBF00148FB0001003E0000827BD00188F
68991+:105980000A0000A6000028218F85FDA027BDFFD8B2
68992+:10599000AFBF0020AFB3001CAFB20018AFB100140E
68993+:1059A000AFB000100080982190A4001124B0001C1A
68994+:1059B00024B1002C308300FF386200280E000090D4
68995+:1059C0002C5200010E00009800000000020020216F
68996+:1059D0001240000202202821000028210E00006E43
68997+:1059E000000000008F8DFDA03C0880003C05600099
68998+:1059F00095AC003E95AB003C02683025000C4C0095
68999+:105A0000316AFFFF012A3825ACA7201024020202C8
69000+:105A1000ACA6201452400001240200028FBF0020D7
69001+:105A20008FB3001C8FB200188FB100148FB000101C
69002+:105A300027BD002803E00008ACA2200027BDFFE03E
69003+:105A4000AFB20018AFB10014AFB00010AFBF001C70
69004+:105A50003C1160008E2320748F82000430D0FFFF41
69005+:105A600030F2FFFF1062000C2406008F0E00006E63
69006+:105A7000000000003C06801F0010440034C5FF00F9
69007+:105A80000112382524040002AE2720100000302126
69008+:105A9000AE252014AE2420008FBF001C8FB200184A
69009+:105AA0008FB100148FB0001000C0102103E0000877
69010+:105AB00027BD002027BDFFE0AFB0001030D0FFFFB2
69011+:105AC000AFBF0018AFB100140E00006E30F1FFFF41
69012+:105AD00000102400009180253C036000AC70201071
69013+:105AE0008FBF00188FB100148FB000102402000483
69014+:105AF000AC62200027BD002003E000080000102158
69015+:105B000027BDFFE03C046018AFBF0018AFB1001420
69016+:105B1000AFB000108C8850002403FF7F34028071E6
69017+:105B20000103382434E5380C241F00313C1980006F
69018+:105B3000AC8550003C11800AAC8253BCAF3F0008DA
69019+:105B40000E00054CAF9100400E00050A3C116000AC
69020+:105B50000E00007D000000008E3008083C0F570941
69021+:105B60002418FFF00218602435EEE00035EDF00057
69022+:105B7000018E5026018D58262D4600012D69000109
69023+:105B8000AF86004C0E000D09AF8900503C06601630
69024+:105B90008CC700003C0860148D0500A03C03FFFF8B
69025+:105BA00000E320243C02535300052FC2108200550D
69026+:105BB00034D07C00960201F2A780006C10400003F4
69027+:105BC000A780007C384B1E1EA78B006C960201F844
69028+:105BD000104000048F8D0050384C1E1EA78C007C96
69029+:105BE0008F8D005011A000058F83004C240E0020E3
69030+:105BF000A78E007CA78E006C8F83004C1060000580
69031+:105C00009785007C240F0020A78F007CA78F006C55
69032+:105C10009785007C2CB8008153000001240500808A
69033+:105C20009784006C2C91040152200001240404008C
69034+:105C30001060000B3C0260008FBF00188FB1001491
69035+:105C40008FB0001027BD0020A784006CA785007CC2
69036+:105C5000A380007EA780007403E00008A780009264
69037+:105C60008C4704382419103C30FFFFFF13F9000360
69038+:105C700030A8FFFF1100004624030050A380007EDF
69039+:105C80009386007E50C00024A785007CA780007CFE
69040+:105C90009798007CA780006CA7800074A780009272
69041+:105CA0003C010800AC3800800E00078700000000AF
69042+:105CB0003C0F60008DED0808240EFFF03C0B600ED9
69043+:105CC000260C0388356A00100000482100002821B6
69044+:105CD00001AE20243C105709AF8C0010AF8A004859
69045+:105CE000AF89001810900023AF8500148FBF0018F3
69046+:105CF0008FB100148FB0001027BD002003E0000812
69047+:105D0000AF80005400055080014648218D260004D4
69048+:105D10000A00014800D180219798007CA784006C7C
69049+:105D2000A7800074A78000923C010800AC38008076
69050+:105D30000E000787000000003C0F60008DED080892
69051+:105D4000240EFFF03C0B600E260C0388356A001011
69052+:105D5000000048210000282101AE20243C105709F2
69053+:105D6000AF8C0010AF8A0048AF8900181490FFDF95
69054+:105D7000AF85001424110001AF9100548FBF0018AB
69055+:105D80008FB100148FB0001003E0000827BD002081
69056+:105D90000A00017BA383007E3083FFFF8F880040D1
69057+:105DA0008F87003C000321403C0580003C020050EE
69058+:105DB000008248253C0660003C0A010034AC040027
69059+:105DC0008CCD08E001AA58241160000500000000F5
69060+:105DD0008CCF08E024E7000101EA7025ACCE08E092
69061+:105DE0008D19001001805821ACB900388D180014AD
69062+:105DF000ACB8003CACA9003000000000000000007E
69063+:105E00000000000000000000000000000000000092
69064+:105E100000000000000000003C0380008C640000D3
69065+:105E2000308200201040FFFD3C0F60008DED08E047
69066+:105E30003C0E010001AE18241460FFE100000000D8
69067+:105E4000AF87003C03E00008AF8B00588F8500400F
69068+:105E5000240BFFF03C06800094A7001A8CA90024B4
69069+:105E600030ECFFFF000C38C000EB5024012A402129
69070+:105E7000ACC8003C8CA400248CC3003C00831023DD
69071+:105E800018400033000000008CAD002025A2000166
69072+:105E90003C0F0050ACC2003835EE00103C068000CC
69073+:105EA000ACCE003000000000000000000000000048
69074+:105EB00000000000000000000000000000000000E2
69075+:105EC000000000003C0480008C9900003338002062
69076+:105ED0001300FFFD30E20008104000173C0980006D
69077+:105EE0008C880408ACA800108C83040CACA30014AC
69078+:105EF0003C1900203C188000AF19003094AE001807
69079+:105F000094AF001C01CF3021A4A6001894AD001A54
69080+:105F100025A70001A4A7001A94AB001A94AC001E98
69081+:105F2000118B00030000000003E0000800000000E7
69082+:105F300003E00008A4A0001A8D2A0400ACAA0010F7
69083+:105F40008D240404ACA400140A0002183C1900209B
69084+:105F50008CA200200A0002003C0F00500A0001EE53
69085+:105F60000000000027BDFFE8AFBF00100E000232A6
69086+:105F7000000000008F8900408FBF00103C038000AC
69087+:105F8000A520000A9528000A9527000427BD0018BF
69088+:105F90003105FFFF30E6000F0006150000A22025A6
69089+:105FA00003E00008AC6400803C0508008CA50020DC
69090+:105FB0008F83000C27BDFFE8AFB00010AFBF001407
69091+:105FC00010A300100000802124040001020430040A
69092+:105FD00000A6202400C3102450440006261000010F
69093+:105FE000001018802787FDA41480000A006718217C
69094+:105FF000261000012E0900025520FFF38F83000CAC
69095+:10600000AF85000C8FBF00148FB0001003E00008B4
69096+:1060100027BD00188C6800003C058000ACA8002457
69097+:106020000E000234261000013C0508008CA500205B
69098+:106030000A0002592E0900022405000100851804F7
69099+:106040003C0408008C84002027BDFFC8AFBF00348B
69100+:1060500000831024AFBE0030AFB7002CAFB60028CD
69101+:10606000AFB50024AFB40020AFB3001CAFB200182E
69102+:10607000AFB1001410400051AFB000108F84004049
69103+:10608000948700069488000A00E8302330D5FFFF8B
69104+:1060900012A0004B8FBF0034948B0018948C000A20
69105+:1060A000016C50233142FFFF02A2482B1520000251
69106+:1060B00002A02021004020212C8F000515E00002C5
69107+:1060C00000809821241300040E0001C102602021E9
69108+:1060D0008F87004002609021AF80004494F4000A52
69109+:1060E000026080211260004E3291FFFF3C1670006A
69110+:1060F0003C1440003C1E20003C1760008F99005863
69111+:106100008F380000031618241074004F0283F82BF8
69112+:1061100017E0003600000000107E00478F86004424
69113+:1061200014C0003A2403000102031023022320219B
69114+:106130003050FFFF1600FFF13091FFFF8F870040C6
69115+:106140003C1100203C108000AE11003094EB000A9E
69116+:106150003C178000024B5021A4EA000A94E9000A8F
69117+:1061600094E800043123FFFF3106000F00062D00E4
69118+:106170000065F025AEFE008094F3000A94F6001846
69119+:1061800012D30036001221408CFF00148CF4001052
69120+:1061900003E468210000C02101A4782B029870213B
69121+:1061A00001CF6021ACED0014ACEC001002B238233A
69122+:1061B00030F5FFFF16A0FFB88F8400408FBF00347A
69123+:1061C0008FBE00308FB7002C8FB600288FB500240B
69124+:1061D0008FB400208FB3001C8FB200188FB1001451
69125+:1061E0008FB0001003E0000827BD00381477FFCC03
69126+:1061F0008F8600440E000EE202002021004018218C
69127+:106200008F86004410C0FFC9020310230270702360
69128+:106210008F87004001C368210A0002E431B2FFFF0A
69129+:106220008F86004414C0FFC93C1100203C10800040
69130+:106230000A0002AEAE1100300E00046602002021FA
69131+:106240000A0002DB00401821020020210E0009395B
69132+:10625000022028210A0002DB004018210E0001EE76
69133+:10626000000000000A0002C702B2382327BDFFC8A1
69134+:10627000AFB7002CAFB60028AFB50024AFB40020F4
69135+:10628000AFB3001CAFB20018AFB10014AFB0001034
69136+:10629000AFBF00300E00011B241300013C047FFF40
69137+:1062A0003C0380083C0220003C010800AC20007048
69138+:1062B0003496FFFF34770080345200033C1512C03F
69139+:1062C000241400013C1080002411FF800E000245C0
69140+:1062D000000000008F8700488F8B00188F89001402
69141+:1062E0008CEA00EC8CE800E8014B302B01092823F4
69142+:1062F00000A6102314400006014B18231440000E82
69143+:106300003C05800002A3602B1180000B0000000000
69144+:106310003C0560008CEE00EC8CED00E88CA4180CC1
69145+:10632000AF8E001804800053AF8D00148F8F0010C3
69146+:10633000ADF400003C0580008CBF00003BF900017B
69147+:10634000333800011700FFE13C0380008C6201003C
69148+:1063500024060C0010460009000000008C680100B3
69149+:106360002D043080548000103C0480008C690100B2
69150+:106370002D2331811060000C3C0480008CAA0100A8
69151+:1063800011460004000020218CA6010024C5FF81D5
69152+:1063900030A400FF8E0B01000E000269AE0B00243A
69153+:1063A0000A00034F3C0480008C8D01002DAC3300AB
69154+:1063B00011800022000000003C0708008CE70098D4
69155+:1063C00024EE00013C010800AC2E00983C04800043
69156+:1063D0008C8201001440000300000000566000148D
69157+:1063E0003C0440008C9F01008C9801000000982123
69158+:1063F00003F1C82400193940330F007F00EF7025E6
69159+:1064000001D26825AC8D08308C8C01008C85010090
69160+:10641000258B0100017130240006514030A3007F1C
69161+:106420000143482501324025AC8808303C04400037
69162+:10643000AE0401380A00030E000000008C99010030
69163+:10644000240F0020AC99002092F80000330300FFD5
69164+:10645000106F000C241F0050547FFFDD3C048000AF
69165+:106460008C8401000E00154E000000000A00034F4E
69166+:106470003C04800000963824ACA7180C0A000327BF
69167+:106480008F8F00108C8501000E0008F72404008017
69168+:106490000A00034F3C04800000A4102B24030001D9
69169+:1064A00010400009000030210005284000A4102BF6
69170+:1064B00004A00003000318405440FFFC00052840DE
69171+:1064C0005060000A0004182B0085382B54E00004AB
69172+:1064D0000003184200C33025008520230003184222
69173+:1064E0001460FFF9000528420004182B03E000089F
69174+:1064F00000C310213084FFFF30C600FF3C0780003E
69175+:106500008CE201B80440FFFE00064C000124302557
69176+:106510003C08200000C820253C031000ACE00180AE
69177+:10652000ACE50184ACE4018803E00008ACE301B809
69178+:106530003C0660008CC5201C2402FFF03083020062
69179+:10654000308601001060000E00A2282434A500014E
69180+:106550003087300010E0000530830C0034A50004C3
69181+:106560003C04600003E00008AC85201C1060FFFDC7
69182+:106570003C04600034A5000803E00008AC85201C42
69183+:1065800054C0FFF334A500020A0003B03087300086
69184+:1065900027BDFFE8AFB00010AFBF00143C0760009C
69185+:1065A000240600021080001100A080218F83005873
69186+:1065B0000E0003A78C6400188F8200580000202171
69187+:1065C000240600018C45000C0E000398000000001A
69188+:1065D0001600000224020003000010218FBF0014E7
69189+:1065E0008FB0001003E0000827BD00188CE8201CC5
69190+:1065F0002409FFF001092824ACE5201C8F870058EE
69191+:106600000A0003CD8CE5000C3C02600E00804021A6
69192+:1066100034460100240900180000000000000000BA
69193+:10662000000000003C0A00503C0380003547020097
69194+:10663000AC68003834640400AC65003CAC670030E2
69195+:106640008C6C0000318B00201160FFFD2407FFFFE0
69196+:106650002403007F8C8D00002463FFFF248400044A
69197+:10666000ACCD00001467FFFB24C60004000000004E
69198+:10667000000000000000000024A402000085282B78
69199+:106680003C0300203C0E80002529FFFF010540212E
69200+:10669000ADC300301520FFE00080282103E0000892
69201+:1066A000000000008F82005827BDFFD8AFB3001C48
69202+:1066B000AFBF0020AFB20018AFB10014AFB00010F0
69203+:1066C00094460002008098218C5200182CC300814F
69204+:1066D0008C4800048C4700088C51000C8C49001039
69205+:1066E000106000078C4A00142CC4000414800013AE
69206+:1066F00030EB000730C5000310A0001000000000C0
69207+:106700002410008B02002021022028210E00039873
69208+:10671000240600031660000224020003000010217A
69209+:106720008FBF00208FB3001C8FB200188FB10014F0
69210+:106730008FB0001003E0000827BD00281560FFF1AE
69211+:106740002410008B3C0C80003C030020241F00011F
69212+:10675000AD830030AF9F0044000000000000000047
69213+:10676000000000002419FFF024D8000F031978243A
69214+:106770003C1000D0AD88003801F0702524CD000316
69215+:106780003C08600EAD87003C35850400AD8E0030BE
69216+:10679000000D38823504003C3C0380008C6B000007
69217+:1067A000316200201040FFFD0000000010E00008F2
69218+:1067B00024E3FFFF2407FFFF8CA800002463FFFFF2
69219+:1067C00024A50004AC8800001467FFFB24840004A7
69220+:1067D0003C05600EACA60038000000000000000080
69221+:1067E000000000008F8600543C0400203C0780001D
69222+:1067F000ACE4003054C000060120202102402021DA
69223+:106800000E0003A7000080210A00041D02002021C1
69224+:106810000E0003DD01402821024020210E0003A7C5
69225+:10682000000080210A00041D0200202127BDFFE096
69226+:10683000AFB200183092FFFFAFB10014AFBF001C21
69227+:10684000AFB000101640000D000088210A0004932C
69228+:106850000220102124050003508500278CE5000C40
69229+:106860000000000D262800013111FFFF24E2002066
69230+:106870000232802B12000019AF8200588F82004430
69231+:10688000144000168F8700583C0670003C0320001F
69232+:106890008CE5000000A62024148300108F84006083
69233+:1068A000000544023C09800000A980241480FFE90F
69234+:1068B000310600FF2CCA000B5140FFEB26280001D7
69235+:1068C000000668803C0E080025CE575801AE6021B6
69236+:1068D0008D8B0000016000080000000002201021E4
69237+:1068E0008FBF001C8FB200188FB100148FB0001042
69238+:1068F00003E0000827BD00200E0003982404008454
69239+:106900001600FFD88F8700580A000474AF8000601B
69240+:10691000020028210E0003BF240400018F870058C5
69241+:106920000A000474AF820060020028210E0003BF39
69242+:10693000000020210A0004A38F8700580E000404E1
69243+:10694000020020218F8700580A000474AF82006083
69244+:1069500030AFFFFF000F19C03C0480008C9001B8DD
69245+:106960000600FFFE3C1920043C181000AC83018097
69246+:10697000AC800184AC990188AC9801B80A00047518
69247+:106980002628000190E2000390E30002000020218D
69248+:106990000002FE0000033A0000FF2825240600083C
69249+:1069A0000E000398000000001600FFDC2402000324
69250+:1069B0008F870058000010210A000474AF82006025
69251+:1069C00090E8000200002021240600090A0004C308
69252+:1069D00000082E0090E4000C240900FF308500FF21
69253+:1069E00010A900150000302190F9000290F8000372
69254+:1069F000308F00FF94EB000400196E000018740043
69255+:106A0000000F62000186202501AE5025014B28258C
69256+:106A10003084FF8B0A0004C32406000A90E30002BE
69257+:106A200090FF0004000020210003360000DF28252D
69258+:106A30000A0004C32406000B0A0004D52406008BB8
69259+:106A4000000449C23127003F000443423C02800059
69260+:106A500000082040240316802CE60020AC43002CC4
69261+:106A600024EAFFE02482000114C0000330A900FFE3
69262+:106A700000801021314700FF000260803C0D800043
69263+:106A8000240A0001018D20213C0B000E00EA28049D
69264+:106A9000008B302111200005000538278CCE000026
69265+:106AA00001C5382503E00008ACC700008CD8000001
69266+:106AB0000307782403E00008ACCF000027BDFFE007
69267+:106AC000AFB10014AFB00010AFBF00183C076000BA
69268+:106AD0008CE408083402F0003C1160003083F000C0
69269+:106AE000240501C03C04800E000030211062000625
69270+:106AF000241000018CEA08083149F0003928E00030
69271+:106B00000008382B000780403C0D0200AE2D081411
69272+:106B1000240C16803C0B80008E2744000E000F8B47
69273+:106B2000AD6C002C120000043C02169124050001FB
69274+:106B3000120500103C023D2C345800E0AE384408E9
69275+:106B40003C1108008E31007C8FBF00183C066000AD
69276+:106B500000118540360F16808FB100148FB00010E1
69277+:106B60003C0E020027BD0020ACCF442003E000080B
69278+:106B7000ACCE08103C0218DA345800E0AE384408B5
69279+:106B80003C1108008E31007C8FBF00183C0660006D
69280+:106B900000118540360F16808FB100148FB00010A1
69281+:106BA0003C0E020027BD0020ACCF442003E00008CB
69282+:106BB000ACCE08100A0004EB240500010A0004EB27
69283+:106BC0000000282124020400A7820024A780001CC2
69284+:106BD000000020213C06080024C65A582405FFFF67
69285+:106BE00024890001000440803124FFFF01061821A0
69286+:106BF0002C87002014E0FFFAAC6500002404040098
69287+:106C0000A7840026A780001E000020213C06080063
69288+:106C100024C65AD82405FFFF248D0001000460809B
69289+:106C200031A4FFFF018658212C8A00201540FFFA6D
69290+:106C3000AD650000A7800028A7800020A780002263
69291+:106C4000000020213C06080024C65B582405FFFFF5
69292+:106C5000249900010004C0803324FFFF030678213B
69293+:106C60002C8E000415C0FFFAADE500003C05600065
69294+:106C70008CA73D002403E08F00E31024344601403C
69295+:106C800003E00008ACA63D002487007F000731C266
69296+:106C900024C5FFFF000518C2246400013082FFFFF5
69297+:106CA000000238C0A78400303C010800AC27003047
69298+:106CB000AF80002C0000282100002021000030219E
69299+:106CC0002489000100A728213124FFFF2CA81701E7
69300+:106CD000110000032C8300801460FFF924C600011A
69301+:106CE00000C02821AF86002C10C0001DA786002AF6
69302+:106CF00024CAFFFF000A11423C08080025085B581F
69303+:106D00001040000A00002021004030212407FFFF2E
69304+:106D1000248E00010004688031C4FFFF01A86021B7
69305+:106D20000086582B1560FFFAAD87000030A2001FC7
69306+:106D30005040000800043080240300010043C804D0
69307+:106D400000041080004878212738FFFF03E0000886
69308+:106D5000ADF8000000C820212405FFFFAC8500002D
69309+:106D600003E000080000000030A5FFFF30C6FFFF71
69310+:106D700030A8001F0080602130E700FF0005294295
69311+:106D80000000502110C0001D24090001240B000147
69312+:106D900025180001010B2004330800FF0126782686
69313+:106DA000390E00202DED00012DC2000101A2182591
69314+:106DB0001060000D014450250005C880032C4021BF
69315+:106DC0000100182110E0000F000A20278D040000A8
69316+:106DD000008A1825AD03000024AD00010000402109
69317+:106DE0000000502131A5FFFF252E000131C9FFFF12
69318+:106DF00000C9102B1040FFE72518000103E0000830
69319+:106E0000000000008D0A0000014440240A0005D162
69320+:106E1000AC68000027BDFFE830A5FFFF30C6FFFFCC
69321+:106E2000AFB00010AFBF001430E7FFFF00005021EB
69322+:106E30003410FFFF0000602124AF001F00C0482174
69323+:106E4000241800012419002005E0001601E010219B
69324+:106E50000002F943019F682A0009702B01AE40240B
69325+:106E600011000017000C18800064102110E00005CC
69326+:106E70008C4B000000F840040008382301675824B8
69327+:106E800000003821154000410000402155600016E7
69328+:106E90003169FFFF258B0001316CFFFF05E1FFEC3D
69329+:106EA00001E0102124A2003E0002F943019F682A5C
69330+:106EB0000009702B01AE40241500FFEB000C188078
69331+:106EC000154600053402FFFF020028210E0005B51B
69332+:106ED00000003821020010218FBF00148FB0001075
69333+:106EE00003E0000827BD00181520000301601821E9
69334+:106EF000000B1C0224080010306A00FF154000053A
69335+:106F0000306E000F250D000800031A0231A800FFA3
69336+:106F1000306E000F15C00005307F000325100004FF
69337+:106F200000031902320800FF307F000317E000055C
69338+:106F3000386900012502000200031882304800FF72
69339+:106F4000386900013123000110600004310300FFA3
69340+:106F5000250A0001314800FF310300FF000C6940A1
69341+:106F600001A34021240A000110CAFFD53110FFFF00
69342+:106F7000246E000131C800FF1119FFC638C9000195
69343+:106F80002D1F002053E0001C258B0001240D000163
69344+:106F90000A000648240E002051460017258B0001E8
69345+:106FA00025090001312800FF2D0900205120001281
69346+:106FB000258B000125430001010D5004014B1024D5
69347+:106FC000250900011440FFF4306AFFFF3127FFFF5D
69348+:106FD00010EE000C2582FFFF304CFFFF0000502117
69349+:106FE0003410FFFF312800FF2D0900205520FFF24B
69350+:106FF00025430001258B0001014648260A000602B0
69351+:10700000316CFFFF00003821000050210A000654B7
69352+:107010003410FFFF27BDFFD8AFB0001030F0FFFFE6
69353+:10702000AFB10014001039423211FFE000071080A8
69354+:10703000AFB3001C00B1282330D3FFFFAFB200185C
69355+:1070400030A5FFFF00809021026030210044202104
69356+:10705000AFBF00200E0005E03207001F022288218A
69357+:107060003403FFFF0240202102002821026030216A
69358+:1070700000003821104300093231FFFF02201021A7
69359+:107080008FBF00208FB3001C8FB200188FB1001487
69360+:107090008FB0001003E0000827BD00280E0005E0B7
69361+:1070A0000000000000408821022010218FBF002036
69362+:1070B0008FB3001C8FB200188FB100148FB0001076
69363+:1070C00003E0000827BD0028000424003C03600002
69364+:1070D000AC603D0810A00002348210063482101605
69365+:1070E00003E00008AC623D0427BDFFE0AFB0001034
69366+:1070F000309000FF2E020006AFBF001810400008BD
69367+:10710000AFB10014001030803C03080024635784A2
69368+:1071100000C328218CA400000080000800000000AB
69369+:10712000000020218FBF00188FB100148FB0001015
69370+:107130000080102103E0000827BD00209791002A5D
69371+:1071400016200051000020213C020800904200332C
69372+:107150000A0006BB00000000978D002615A0003134
69373+:10716000000020210A0006BB2402000897870024A3
69374+:1071700014E0001A00001821006020212402000100
69375+:107180001080FFE98FBF0018000429C2004530219C
69376+:1071900000A6582B1160FFE43C0880003C0720004B
69377+:1071A000000569C001A76025AD0C00203C038008E4
69378+:1071B0002402001F2442FFFFAC6000000441FFFDD9
69379+:1071C0002463000424A5000100A6702B15C0FFF560
69380+:1071D000000569C00A0006A58FBF00189787001C2C
69381+:1071E0003C04080024845A58240504000E0006605C
69382+:1071F00024060001978B002424440001308AFFFFFD
69383+:107200002569FFFF2D48040000402821150000409B
69384+:10721000A789002424AC3800000C19C00A0006B964
69385+:10722000A780001C9787001E3C04080024845AD8BD
69386+:10723000240504000E00066024060001979900262C
69387+:10724000244400013098FFFF272FFFFF2F0E04007A
69388+:107250000040882115C0002CA78F0026A780001EA3
69389+:107260003A020003262401003084FFFF0E00068D41
69390+:107270002C4500010011F8C027F00100001021C0CA
69391+:107280000A0006BB240200089785002E978700227B
69392+:107290003C04080024845B580E00066024060001AC
69393+:1072A0009787002A8F89002C2445000130A8FFFF12
69394+:1072B00024E3FFFF0109302B0040802114C0001897
69395+:1072C000A783002AA7800022978500300E000F7543
69396+:1072D00002002021244A05003144FFFF0E00068DE4
69397+:1072E000240500013C05080094A500320E000F752E
69398+:1072F00002002021244521003C0208009042003376
69399+:107300000A0006BB000521C00A0006F3A784001E80
69400+:1073100024AC3800000C19C00A0006B9A784001C70
69401+:107320000A00070DA7850022308400FF27BDFFE873
69402+:107330002C820006AFBF0014AFB000101040001543
69403+:1073400000A03821000440803C0308002463579CBF
69404+:10735000010328218CA40000008000080000000028
69405+:1073600024CC007F000751C2000C59C23170FFFFCE
69406+:107370002547C40030E5FFFF2784001C02003021B0
69407+:107380000E0005B52407000197860028020620217B
69408+:10739000A78400288FBF00148FB0001003E00008FE
69409+:1073A00027BD00183C0508008CA50030000779C2F5
69410+:1073B0000E00038125E4DF003045FFFF3C04080098
69411+:1073C00024845B58240600010E0005B52407000143
69412+:1073D000978E002A8FBF00148FB0001025CD0001BA
69413+:1073E00027BD001803E00008A78D002A0007C9C2C6
69414+:1073F0002738FF00001878C231F0FFFF3C04080076
69415+:1074000024845AD802002821240600010E0005B564
69416+:1074100024070001978D0026260E0100000E84002F
69417+:1074200025AC00013C0B6000A78C0026AD603D0838
69418+:1074300036040006000030213C0760008CE23D0469
69419+:10744000305F000617E0FFFD24C9000100061B00A5
69420+:10745000312600FF006440252CC50004ACE83D0443
69421+:1074600014A0FFF68FBF00148FB0001003E00008D7
69422+:1074700027BD0018000751C22549C8002406000195
69423+:10748000240700013C04080024845A580E0005B566
69424+:107490003125FFFF978700248FBF00148FB00010A5
69425+:1074A00024E6000127BD001803E00008A786002499
69426+:1074B0003C0660183C090800252900FCACC9502C8A
69427+:1074C0008CC850003C0580003C020002350700805B
69428+:1074D000ACC750003C04080024841FE03C030800B3
69429+:1074E00024631F98ACA50008ACA2000C3C01080066
69430+:1074F000AC2459A43C010800AC2359A803E00008BF
69431+:107500002402000100A030213C1C0800279C59AC3B
69432+:107510003C0C04003C0B0002008B3826008C4026FB
69433+:107520002CE200010007502B2D050001000A4880C5
69434+:107530003C030800246359A4004520250123182199
69435+:107540001080000300001021AC660000240200013E
69436+:1075500003E00008000000003C1C0800279C59AC18
69437+:107560003C0B04003C0A0002008A3026008B3826BF
69438+:107570002CC200010006482B2CE5000100094080C8
69439+:107580003C030800246359A4004520250103182169
69440+:1075900010800005000010213C0C0800258C1F986D
69441+:1075A000AC6C00002402000103E0000800000000B1
69442+:1075B0003C0900023C080400008830260089382677
69443+:1075C0002CC30001008028212CE400010083102539
69444+:1075D0001040000B000030213C1C0800279C59ACD7
69445+:1075E0003C0A80008D4E00082406000101CA68256F
69446+:1075F000AD4D00088D4C000C01855825AD4B000C9D
69447+:1076000003E0000800C010213C1C0800279C59AC76
69448+:107610003C0580008CA6000C0004202724020001F9
69449+:1076200000C4182403E00008ACA3000C3C020002D4
69450+:107630001082000B3C0560003C070400108700032B
69451+:107640000000000003E00008000000008CA908D042
69452+:10765000240AFFFD012A402403E00008ACA808D05A
69453+:107660008CA408D02406FFFE0086182403E000083E
69454+:10767000ACA308D03C05601A34A600108CC300806F
69455+:1076800027BDFFF88CC50084AFA3000093A40000C1
69456+:107690002402001010820003AFA5000403E00008DC
69457+:1076A00027BD000893A7000114E0001497AC000266
69458+:1076B00097B800023C0F8000330EFFFC01CF682119
69459+:1076C000ADA50000A3A000003C0660008CC708D058
69460+:1076D0002408FFFE3C04601A00E82824ACC508D04A
69461+:1076E0008FA300048FA200003499001027BD00086A
69462+:1076F000AF22008003E00008AF2300843C0B800031
69463+:10770000318AFFFC014B48218D2800000A00080C3B
69464+:10771000AFA8000427BDFFE8AFBF00103C1C080065
69465+:10772000279C59AC3C0580008CA4000C8CA2000462
69466+:107730003C0300020044282410A0000A00A31824DF
69467+:107740003C0604003C0400021460000900A610245A
69468+:107750001440000F3C0404000000000D3C1C080015
69469+:10776000279C59AC8FBF001003E0000827BD00180C
69470+:107770003C0208008C4259A40040F80900000000B7
69471+:107780003C1C0800279C59AC0A0008358FBF00102C
69472+:107790003C0208008C4259A80040F8090000000093
69473+:1077A0000A00083B000000003C0880008D0201B880
69474+:1077B0000440FFFE35090180AD2400003C031000A9
69475+:1077C00024040040AD250004A1240008A1260009DE
69476+:1077D000A527000A03E00008AD0301B83084FFFFCD
69477+:1077E0000080382130A5FFFF000020210A00084555
69478+:1077F000240600803087FFFF8CA400002406003898
69479+:107800000A000845000028218F8300788F860070C9
69480+:107810001066000B008040213C07080024E75B68ED
69481+:10782000000328C000A710218C440000246300013D
69482+:10783000108800053063000F5466FFFA000328C06B
69483+:1078400003E00008000010213C07080024E75B6CFF
69484+:1078500000A7302103E000088CC200003C03900028
69485+:1078600034620001008220253C038000AC640020CB
69486+:107870008C65002004A0FFFE0000000003E000086B
69487+:10788000000000003C0280003443000100832025FA
69488+:1078900003E00008AC44002027BDFFE0AFB10014B6
69489+:1078A0003091FFFFAFB00010AFBF001812200013DF
69490+:1078B00000A080218CA20000240400022406020003
69491+:1078C0001040000F004028210E0007250000000096
69492+:1078D00000001021AE000000022038218FBF0018E8
69493+:1078E0008FB100148FB0001000402021000028212B
69494+:1078F000000030210A00084527BD00208CA20000AE
69495+:10790000022038218FBF00188FB100148FB00010F3
69496+:107910000040202100002821000030210A000845F5
69497+:1079200027BD002000A010213087FFFF8CA5000498
69498+:107930008C4400000A000845240600068F83FD9C45
69499+:1079400027BDFFE8AFBF0014AFB00010906700087C
69500+:10795000008010210080282130E600400000202116
69501+:1079600010C000088C5000000E0000BD0200202155
69502+:10797000020020218FBF00148FB000100A000548BC
69503+:1079800027BD00180E0008A4000000000E0000BD76
69504+:1079900002002021020020218FBF00148FB00010B0
69505+:1079A0000A00054827BD001827BDFFE0AFB0001052
69506+:1079B0008F90FD9CAFBF001CAFB20018AFB1001498
69507+:1079C00092060001008088210E00087230D2000467
69508+:1079D00092040005001129C2A6050000348300406E
69509+:1079E000A20300050E00087C022020210E00054A9B
69510+:1079F0000220202124020001AE02000C02202821D6
69511+:107A0000A602001024040002A602001224060200AE
69512+:107A1000A60200140E000725A60200161640000F4D
69513+:107A20008FBF001C978C00743C0B08008D6B007896
69514+:107A30002588FFFF3109FFFF256A0001012A382B45
69515+:107A400010E00006A78800743C0F6006240E0016A4
69516+:107A500035ED0010ADAE00508FBF001C8FB2001886
69517+:107A60008FB100148FB0001003E0000827BD002084
69518+:107A700027BDFFE0AFB10014AFBF0018AFB00010DA
69519+:107A80001080000400A088212402008010820007DA
69520+:107A9000000000000000000D8FBF00188FB100141F
69521+:107AA0008FB0001003E0000827BD00200E00087210
69522+:107AB00000A020218F86FD9C0220202190C500057A
69523+:107AC0000E00087C30B000FF2403003E1603FFF1D7
69524+:107AD0003C0680008CC401780480FFFE34C801405D
69525+:107AE000240900073C071000AD11000002202021EE
69526+:107AF000A10900048FBF00188FB100148FB00010CF
69527+:107B0000ACC701780A0008C527BD002027BDFFE0EB
69528+:107B1000AFB00010AFBF0018AFB100143C10800030
69529+:107B20008E110020000000000E00054AAE04002067
69530+:107B3000AE1100208FBF00188FB100148FB000105D
69531+:107B400003E0000827BD00203084FFFF00803821BB
69532+:107B50002406003500A020210A0008450000282145
69533+:107B60003084FFFF008038212406003600A0202149
69534+:107B70000A0008450000282127BDFFD0AFB500242A
69535+:107B80003095FFFFAFB60028AFB40020AFBF002C88
69536+:107B9000AFB3001CAFB20018AFB10014AFB000100B
69537+:107BA00030B6FFFF12A000270000A0218F920058DE
69538+:107BB0008E4300003C0680002402004000033E0289
69539+:107BC00000032C0230E4007F006698241482001D1C
69540+:107BD00030A500FF8F8300682C68000A1100001098
69541+:107BE0008F8D0044000358803C0C0800258C57B84A
69542+:107BF000016C50218D4900000120000800000000A8
69543+:107C000002D4302130C5FFFF0E0008522404008446
69544+:107C1000166000028F920058AF8000688F8D00447C
69545+:107C20002659002026980001032090213314FFFFDD
69546+:107C300015A00004AF9900580295202B1480FFDC9A
69547+:107C400000000000028010218FBF002C8FB600289A
69548+:107C50008FB500248FB400208FB3001C8FB20018A2
69549+:107C60008FB100148FB0001003E0000827BD003072
69550+:107C70002407003414A70149000000009247000EB9
69551+:107C80008F9FFDA08F90FD9C24181600A3E700197C
69552+:107C90009242000D3C0880003C07800CA3E20018D3
69553+:107CA000964A00123C0D60003C117FFFA60A005C62
69554+:107CB000964400103623FFFF240200053099FFFF91
69555+:107CC000AE1900548E46001CAD1800288CEF000041
69556+:107CD0008DAE444801E6482601C93021AE06003881
69557+:107CE0008E05003824CB00013C0E7F00AE05003C21
69558+:107CF0008E0C003CAFEC0004AE0B00208E13002075
69559+:107D0000AE13001CA3E0001BAE03002CA3E2001284
69560+:107D10008E4A001424130050AE0A00348E0400343E
69561+:107D2000AFE400148E590018AE1900489258000CA8
69562+:107D3000A218004E920D000835AF0020A20F0008D7
69563+:107D40008E090018012E282434AC4000AE0C001817
69564+:107D5000920B0000317200FF1253027F2403FF8058
69565+:107D60003C04080024845BE80E0008AA0000000020
69566+:107D70003C1108008E315BE80E00087202202021C1
69567+:107D80002405000424080001A2050025022020216A
69568+:107D90000E00087CA20800053C0580008CB001782C
69569+:107DA0000600FFFE8F92005834AE0140240F0002FF
69570+:107DB0003C091000ADD10000A1CF0004ACA90178AE
69571+:107DC0000A000962AF8000682CAD003751A0FF9413
69572+:107DD0008F8D0044000580803C110800263157E05B
69573+:107DE000021178218DEE000001C0000800000000A3
69574+:107DF0002411000414B1008C3C0780003C080800EA
69575+:107E00008D085BE88F86FD9CACE800208E4500085D
69576+:107E10008F99FDA0240D0050ACC500308E4C000899
69577+:107E2000ACCC00508E4B000CACCB00348E43001019
69578+:107E3000ACC300388E4A0010ACCA00548E42001405
69579+:107E4000ACC2003C8E5F0018AF3F00048E50001C97
69580+:107E5000ACD0002090C40000309800FF130D024AFF
69581+:107E6000000000008CC400348CD00030009030231F
69582+:107E700004C000F12404008C126000EE2402000310
69583+:107E80000A000962AF8200682419000514B900666F
69584+:107E90003C0580003C0808008D085BE88F86FD9C4F
69585+:107EA000ACA800208E4C00048F8AFDA0240720007F
69586+:107EB000ACCC001C924B000824120008A14B001906
69587+:107EC0008F82005890430009A14300188F85005805
69588+:107ED00090BF000A33E400FF1092001028890009C7
69589+:107EE000152000BA240E0002240D0020108D000B76
69590+:107EF000340780002898002117000008240740005C
69591+:107F000024100040109000053C0700012419008057
69592+:107F1000109900023C070002240740008CC20018A0
69593+:107F20003C03FF00004350240147F825ACDF001854
69594+:107F300090B2000BA0D200278F8300589464000CED
69595+:107F4000108001FE000000009467000C3C1F8000C0
69596+:107F50002405FFBFA4C7005C9063000E2407000443
69597+:107F6000A0C300088F820058904A000FA0CA0009E1
69598+:107F70008F8900588D3200108FE400740244C823AA
69599+:107F8000ACD900588D300014ACD0002C95380018B6
69600+:107F9000330DFFFFACCD00409531001A322FFFFFAB
69601+:107FA000ACCF00448D2E001CACCE00489128000EB2
69602+:107FB000A0C8000890CC000801855824126001B6C2
69603+:107FC000A0CB00088F9200580A000962AF870068B2
69604+:107FD0002406000614A600143C0E80003C0F080086
69605+:107FE0008DEF5BE88F85FD98ADCF00208E4900189E
69606+:107FF0008F86FD9C8F8BFDA0ACA900008CC800383B
69607+:1080000024040005ACA800048CCC003C1260008164
69608+:10801000AD6C00000A000962AF84006824110007FB
69609+:1080200010B1004B240400063C05080024A55BE8C1
69610+:108030000E000881240400818F9200580013102B39
69611+:108040000A000962AF820068241F002314BFFFF6F4
69612+:108050003C0C80003C0508008CA55BE88F8BFDA0E4
69613+:10806000AD8500208F91FD9C8E4600042564002084
69614+:1080700026450014AE260028240600030E000F81BA
69615+:10808000257000308F87005802002021240600034D
69616+:108090000E000F8124E500083C04080024845BE8FE
69617+:1080A0000E0008AA0000000092230000240A0050DD
69618+:1080B000306200FF544AFFE18F9200580E000F6CAF
69619+:1080C000000000000A000A6A8F920058240800335A
69620+:1080D00014A800323C0380003C1108008E315BE89C
69621+:1080E0008F8FFDA0AC7100208E420008240D002867
69622+:1080F0008F89FD9CADE200308E4A000C24060009F9
69623+:10810000ADEA00348E5F0010ADFF00388E440014DD
69624+:10811000ADE400208E590018ADF900248E58001CE3
69625+:10812000ADF80028A1ED00118E4E00041260003160
69626+:10813000AD2E00288F9200580A000962AF860068B1
69627+:10814000240D002214ADFFB8000000002404000735
69628+:108150003C1008008E105BE83C188000AF10002037
69629+:108160005660FEAEAF8400683C04080024845BE8DF
69630+:108170000E0008AA241300508F84FD9C90920000EA
69631+:10818000325900FF1333014B000000008F9200585A
69632+:10819000000020210A000962AF8400683C05080045
69633+:1081A00024A55BE80E000858240400810A000A6A2E
69634+:1081B0008F92005802D498213265FFFF0E000852BA
69635+:1081C000240400840A0009628F920058108EFF5325
69636+:1081D000240704002887000310E00179241100041B
69637+:1081E000240F0001548FFF4D240740000A000A228B
69638+:1081F000240701003C05080024A55BE80E0008A444
69639+:10820000240400828F920058000030210A00096285
69640+:10821000AF8600683C04080024845BE88CC2003808
69641+:108220000E0008AA8CC3003C8F9200580A000AC0B6
69642+:1082300000002021240400823C05080024A55BE8FE
69643+:108240000E0008A4000000008F92005800001021CA
69644+:108250000A000962AF8200688E5000048F91FD9C75
69645+:108260003C078000ACF00020922C00050200282181
69646+:10827000318B0002156001562404008A8F92FDA004
69647+:108280002404008D9245001B30A6002014C001502C
69648+:1082900002002821922E00092408001231C900FF93
69649+:1082A0001128014B240400810E00087202002021D5
69650+:1082B0009258001B240F000402002021370D0042B9
69651+:1082C000A24D001B0E00087CA22F00253C0580005B
69652+:1082D0008CA401780480FFFE34B90140241F000201
69653+:1082E000AF300000A33F00048F9200583C101000F4
69654+:1082F000ACB001780A000A6B0013102B8E500004FA
69655+:108300008F91FD9C3C038000AC700020922A0005F8
69656+:108310000200282131420002144000172404008A80
69657+:10832000922C00092412000402002821318B00FF46
69658+:1083300011720011240400810E0008720200202135
69659+:108340008F89FDA0240800122405FFFE912F001B39
69660+:108350000200202135EE0020A12E001BA2280009DA
69661+:108360009226000500C538240E00087CA2270005CF
69662+:1083700002002821000020210E0009330000000027
69663+:108380000A000A6A8F9200588E4C00043C07800055
69664+:108390003C10080026105BE8ACEC00203C01080013
69665+:1083A000AC2C5BE8924B0003317100041220013BBE
69666+:1083B0008F84FD9C24020006A0820009924F001BBE
69667+:1083C000240EFFC031E9003F012E4025A08800089F
69668+:1083D0009245000330A6000114C0013200000000E5
69669+:1083E0008E420008AE0200083C0208008C425BF09E
69670+:1083F000104001318F90FDA0000219C28F8DFD9CAD
69671+:10840000A603000C8E4A000C24180001240400145A
69672+:10841000AE0A002C8E420010AE02001C965F0016C1
69673+:10842000A61F003C96590014A619003EADB8000CDA
69674+:10843000A5B80010A5B80012A5B80014A5B800167C
69675+:1084400012600144A2040011925100033232000272
69676+:108450002E5300018F920058266200080A0009621C
69677+:10846000AF8200688E4400043C1980003C068008FE
69678+:10847000AF2400208E45000890D80000240D005045
69679+:10848000331100FF122D009C2407008824060009E8
69680+:108490000E000845000000000A000A6A8F9200588A
69681+:1084A0008E5000043C0980003C118008AD30002053
69682+:1084B0009228000024050050310400FF10850110AF
69683+:1084C0002407008802002021000028210E00084512
69684+:1084D0002406000E922D00002418FF80020028219F
69685+:1084E00001B8802524040004240600300E0007256E
69686+:1084F000A23000000A000A6A8F9200588E500004D1
69687+:108500008F91FDA03C028000AC500020923F001BE8
69688+:1085100033F900101320006C240700810200202191
69689+:10852000000028212406001F0E000845000000005E
69690+:108530000A000A6A8F9200588E44001C0E00085DE3
69691+:1085400000000000104000E3004048218F880058E0
69692+:1085500024070089012020218D05001C240600012C
69693+:108560000E000845000000000A000A6A8F920058B9
69694+:10857000964900023C10080026105BE831280004F0
69695+:10858000110000973C0460008E4E001C3C0F8000E0
69696+:10859000ADEE00203C010800AC2E5BE896470002DF
69697+:1085A00030E40001148000E6000000008E42000468
69698+:1085B000AE0200083C1008008E105BF0120000ECC8
69699+:1085C0003C0F80008F92FD9C241000018E4E0018FD
69700+:1085D0008F8DFDA08F9FFD9801CF4825AE490018D3
69701+:1085E000A2400005AE50000C3C0808008D085BF06E
69702+:1085F0008F840058A6500010000839C2A6500012FF
69703+:10860000A6500014A6500016A5A7000C8C8C0008DC
69704+:108610008F8B00588F8A0058ADAC002C8D63000CF6
69705+:1086200024070002ADA3001C91460010A1A6001172
69706+:108630008F82005890450011A3E500088F990058DB
69707+:1086400093380012A258004E8F910058922F0013B9
69708+:10865000A1AF00128F920058964E0014A5AE003CB8
69709+:1086600096490016A5A9003E8E480018ADA8001432
69710+:108670005660FD6AAF8700683C05080024A55BE8EA
69711+:108680000E000881000020218F9200580000382140
69712+:108690000A000962AF8700683C05080024A55BE872
69713+:1086A0000E0008A4240400828F9200580A000A4D8C
69714+:1086B000000038210E000F6C000000008F9200585F
69715+:1086C0000A000AC0000020210E00087202002021CA
69716+:1086D0009223001B02002021346A00100E00087C47
69717+:1086E000A22A001B000038210200202100002821BE
69718+:1086F0000A000BA52406001F9242000C305F000107
69719+:1087000013E0000300000000964A000EA4CA002CEB
69720+:10871000924B000C316300025060000600003821CB
69721+:108720008E470014964C0012ACC7001CA4CC001A53
69722+:10873000000038210A000B7F240600093C050800D0
69723+:1087400024A55BE80E0008A42404008B8F92005837
69724+:108750000A000A4D0013382B3C0C08008D8C5BE896
69725+:1087600024DFFFFE25930100326B007F016790211B
69726+:1087700002638824AD110028AE4600E0AE4000E45C
69727+:108780000A0009B3AE5F001CACC000543C0D0800E9
69728+:108790008DAD5BE83C18800C37090100ACED00287A
69729+:1087A0008E510014AD3100E08E4F0014AD2F00E467
69730+:1087B0008E4E001025C7FFFE0A0009F4AD27001CED
69731+:1087C0005491FDD6240740000A000A222407100015
69732+:1087D0000E00092D000000000A000A6A8F9200585E
69733+:1087E0008C83442C3C12DEAD3651BEEF3C010800B8
69734+:1087F000AC205BE810710062000000003C196C6264
69735+:1088000037387970147800082404000297850074C2
69736+:108810009782006C2404009200A2F82B13E0001948
69737+:1088200002002821240400020E00069524050200FF
69738+:108830003C068000ACC200203C010800AC225BE892
69739+:108840001040000D8F8C0058240A002824040003D7
69740+:10885000918B0010316300FF546A00012404000171
69741+:108860000E0000810000000010400004240400837A
69742+:108870000A000BC28F920058240400833C050800B4
69743+:1088800024A55BE80E000881000000008F920058CC
69744+:108890000013382B0A000962AF8700680A000B49F1
69745+:1088A000240200128E4400080E00085D0000000043
69746+:1088B0000A000B55AE0200083C05080024A55BE841
69747+:1088C0000E000858240400878F9200580A000B728B
69748+:1088D0000013102B240400040E000695240500301C
69749+:1088E0001440002A004048218F8800582407008344
69750+:1088F000012020218D05001C0A000BB32406000175
69751+:108900008F8300788F8600701066FEEE000038219D
69752+:108910003C07080024E75B6C000320C00087282187
69753+:108920008CAE000011D0005D246F000131E3000F18
69754+:108930005466FFFA000320C00A000B8C00003821A7
69755+:108940008E4400040E00085D000000000A000BC801
69756+:10895000AE0200083C05080024A55BE80E0008A450
69757+:10896000240400828F9200580A000B72000010212C
69758+:108970003C05080024A55BE80A000C7C2404008761
69759+:108980008C83442C0A000C5B3C196C628F88005865
69760+:108990003C0780083C0C8000240B0050240A000196
69761+:1089A000AD820020A0EB0000A0EA000191030004CA
69762+:1089B000A0E3001891040005A0E400199106000648
69763+:1089C0003C04080024845B6CA0E6001A91020007B6
69764+:1089D0003C06080024C65B68A0E2001B9105000865
69765+:1089E000A0E5001C911F0009A0FF001D9119000ABD
69766+:1089F000A0F9001E9118000BA0F8001F9112000CA6
69767+:108A0000A0F200209111000DA0F100219110000EA4
69768+:108A1000A0F00022910F000FA0EF0023910E001094
69769+:108A2000A0EE0024910D0011A0ED0025950C00147E
69770+:108A3000A4EC0028950B00168F8A00708F920078A6
69771+:108A4000A4EB002A95030018000A10C02545000178
69772+:108A5000A4E3002C8D1F001C0044C0210046C82147
69773+:108A600030A5000FAF3F0000AF09000010B20006B4
69774+:108A7000AF850070000038218D05001C01202021E9
69775+:108A80000A000BB32406000124AD000131A7000F3A
69776+:108A9000AF8700780A000CF9000038213C06080076
69777+:108AA00024C65B680086902100003821ACA000003D
69778+:108AB0000A000B8CAE4000003C0482013C036000C5
69779+:108AC00034820E02AC603D68AF80009803E000087D
69780+:108AD000AC623D6C27BDFFE8AFB000103090FFFFE7
69781+:108AE000001018422C620041AFBF00141440000275
69782+:108AF00024040080240300403C010800AC300060E6
69783+:108B00003C010800AC2300640E000F7500602821B2
69784+:108B1000244802BF2409FF8001092824001039805D
69785+:108B2000001030408FBF00148FB0001000A720212C
69786+:108B300000861821AF8300803C010800AC25005856
69787+:108B40003C010800AC24005C03E0000827BD0018CD
69788+:108B5000308300FF30C6FFFF30E400FF3C08800098
69789+:108B60008D0201B80440FFFE000354000144382583
69790+:108B70003C09600000E920253C031000AD050180A0
69791+:108B8000AD060184AD04018803E00008AD0301B81F
69792+:108B90008F8500583C0A6012354800108CAC0004E8
69793+:108BA0003C0D600E35A60010318B00062D690001CA
69794+:108BB000AD0900C48CA70004ACC731808CA20008AA
69795+:108BC00094A40002ACC231848CA3001C0460000396
69796+:108BD000A784009003E00008000000008CAF00189C
69797+:108BE000ACCF31D08CAE001C03E00008ACCE31D449
69798+:108BF0008F8500588F87FF288F86FF308CAE00044A
69799+:108C00003C0F601235E80010ACEE00788CAD000827
69800+:108C1000ACED007C8CAC0010ACCC004C8CAB000CF0
69801+:108C2000ACCB004894CA00543C0208008C4200447B
69802+:108C300025490001A4C9005494C400543083FFFFA7
69803+:108C400010620017000000003C0208008C42004047
69804+:108C5000A4C200528CA30018ACE300308CA2001414
69805+:108C6000ACE2002C8CB90018ACF900388CB80014B8
69806+:108C700024050001ACF800348D0600BC50C5001975
69807+:108C80008D0200B48D0200B8A4E2004894E40048CC
69808+:108C9000A4E4004A94E800EA03E000083102FFFF80
69809+:108CA0003C0208008C420024A4C00054A4C200521C
69810+:108CB0008CA30018ACE300308CA20014ACE2002CB2
69811+:108CC0008CB90018ACF900388CB8001424050001E8
69812+:108CD000ACF800348D0600BC54C5FFEB8D0200B823
69813+:108CE0008D0200B4A4E2004894E40048A4E4004AE1
69814+:108CF00094E800EA03E000083102FFFF8F86005885
69815+:108D00003C0480008CC900088CC80008000929C0F8
69816+:108D1000000839C0AC87002090C30007306200040F
69817+:108D20001040003EAF85009490CB0007316A0008E8
69818+:108D30001140003D8F87FF2C8CCD000C8CCE001491
69819+:108D400001AE602B11800036000000008CC2000CC8
69820+:108D5000ACE200708CCB00188F85FF288F88FF3025
69821+:108D6000ACEB00748CCA00102402FFF8ACAA00D847
69822+:108D70008CC9000CAD0900608CC4001CACA400D0F0
69823+:108D800090E3007C0062C824A0F9007C90D8000722
69824+:108D9000330F000811E000040000000090ED007C9B
69825+:108DA00035AC0001A0EC007C90CF000731EE000153
69826+:108DB00011C000060000000090E3007C241800347D
69827+:108DC00034790002A0F9007CACB800DC90C2000746
69828+:108DD0003046000210C000040000000090E8007C53
69829+:108DE00035040004A0E4007C90ED007D3C0B600E97
69830+:108DF000356A001031AC003FA0EC007D8D4931D4C4
69831+:108E00003127000110E00002240E0001A0AE00098D
69832+:108E100094AF00EA03E0000831E2FFFF8F87FF2CE8
69833+:108E20000A000DAF8CC200140A000DB0ACE0007057
69834+:108E30008F8C005827BDFFD8AFB3001CAFB200180D
69835+:108E4000AFB00010AFBF0020AFB10014918F00157C
69836+:108E50003C13600E3673001031EB000FA38B009CA7
69837+:108E60008D8F00048D8B0008959F0012959900103E
69838+:108E70009584001A9598001E958E001C33EDFFFF17
69839+:108E8000332AFFFF3089FFFF3308FFFF31C7FFFFA1
69840+:108E90003C010800AC2D00243C010800AC29004432
69841+:108EA0003C010800AC2A0040AE683178AE67317CE6
69842+:108EB00091850015959100163C12601236520010F3
69843+:108EC00030A200FF3230FFFFAE623188AE5000B4F6
69844+:108ED00091830014959F0018240600010066C804C1
69845+:108EE00033F8FFFFAE5900B8AE5800BC918E0014A5
69846+:108EF000AF8F00843C08600631CD00FFAE4D00C04E
69847+:108F0000918A00159584000E3C07600A314900FFE4
69848+:108F1000AF8B00883084FFFFAE4900C835110010C8
69849+:108F20000E000D1034F004103C0208008C4200606A
69850+:108F30003C0308008C6300643C0608008CC60058A3
69851+:108F40003C0508008CA5005C8F8400808FBF00204A
69852+:108F5000AE23004CAE65319CAE030054AE4500DC40
69853+:108F6000AE6231A0AE6331A4AE663198AE22004845
69854+:108F70008FB3001CAE0200508FB10014AE4200E06F
69855+:108F8000AE4300E4AE4600D88FB000108FB2001898
69856+:108F90000A00057D27BD0028978500929783007CF5
69857+:108FA00027BDFFE8AFB0001000A3102BAFBF001427
69858+:108FB000240400058F900058104000552409000239
69859+:108FC0000E0006958F850080AF8200942404000374
69860+:108FD0001040004F240900023C0680000E00008172
69861+:108FE000ACC2002024070001240820001040004DDE
69862+:108FF00024040005978E00928F8AFF2C24090050CC
69863+:1090000025C50001A7850092A14900003C0D08007C
69864+:109010008DAD0064240380008F84FF28000D66005E
69865+:10902000AD4C0018A5400006954B000A8F85FF3017
69866+:109030002402FF8001633024A546000A915F000AE4
69867+:109040000000482103E2C825A159000AA0A0000899
69868+:10905000A140004CA08000D5961800029783009094
69869+:109060003C020004A49800EA960F00022418FFBFF7
69870+:1090700025EE2401A48E00BE8E0D0004ACAD00448C
69871+:109080008E0C0008ACAC0040A4A00050A4A000547A
69872+:109090008E0B000C240C0030AC8B00288E060010C8
69873+:1090A000AC860024A480003EA487004EA487005014
69874+:1090B000A483003CAD420074AC8800D8ACA800602A
69875+:1090C000A08700FC909F00D433F9007FA09900D4C2
69876+:1090D000909000D402187824A08F00D4914E007C88
69877+:1090E00035CD0001A14D007C938B009CAD480070F4
69878+:1090F000AC8C00DCA08B00D68F8800888F87008422
69879+:10910000AC8800C4AC8700C8A5400078A540007AB0
69880+:109110008FBF00148FB000100120102103E0000861
69881+:1091200027BD00188F8500940E0007258F860080CC
69882+:109130000A000E9F2409000227BDFFE0AFB0001017
69883+:109140008F900058AFB10014AFBF00188E09000413
69884+:109150000E00054A000921C08E0800048F84FF28F4
69885+:109160008F82FF30000839C03C068000ACC7002069
69886+:10917000948500EA904300131460001C30B1FFFF97
69887+:109180008F8CFF2C918B0008316A00401540000B3A
69888+:10919000000000008E0D0004022030218FBF001857
69889+:1091A0008FB100148FB00010240400220000382179
69890+:1091B000000D29C00A000D2F27BD00200E000098C9
69891+:1091C000000000008E0D0004022030218FBF001827
69892+:1091D0008FB100148FB00010240400220000382149
69893+:1091E000000D29C00A000D2F27BD00200E000090A1
69894+:1091F000000000008E0D0004022030218FBF0018F7
69895+:109200008FB100148FB00010240400220000382118
69896+:10921000000D29C00A000D2F27BD002027BDFFE04B
69897+:10922000AFB200183092FFFFAFB00010AFBF001C0C
69898+:10923000AFB100141240001E000080218F8600583C
69899+:109240008CC500002403000600053F02000514023F
69900+:1092500030E4000714830016304500FF2CA80006F8
69901+:1092600011000040000558803C0C0800258C58BCBB
69902+:10927000016C50218D490000012000080000000011
69903+:109280008F8E0098240D000111CD005024020002A1
69904+:10929000AF820098260900013130FFFF24C800206A
69905+:1092A0000212202B010030211480FFE5AF88005806
69906+:1092B000020010218FBF001C8FB200188FB1001464
69907+:1092C0008FB0001003E0000827BD00209387007EC8
69908+:1092D00054E00034000030210E000DE700000000D3
69909+:1092E0008F8600580A000EFF240200018F87009825
69910+:1092F0002405000210E50031240400130000282199
69911+:1093000000003021240700010E000D2F0000000096
69912+:109310000A000F008F8600588F83009824020002F5
69913+:109320001462FFF6240400120E000D9A00000000E3
69914+:109330008F85009400403021240400120E000D2F70
69915+:10934000000038210A000F008F8600588F83009894
69916+:109350002411000310710029241F0002107FFFCE8A
69917+:1093600026090001240400100000282100003021FB
69918+:109370000A000F1D240700018F91009824060002A7
69919+:109380001626FFF9240400100E000E410000000014
69920+:10939000144000238F9800588F8600580A000EFF53
69921+:1093A00024020003240400140E000D2F00002821C5
69922+:1093B0008F8600580A000EFF240200020E000EA93C
69923+:1093C000000000000A000F008F8600580E000D3FBD
69924+:1093D00000000000241900022404001400002821C9
69925+:1093E0000000302100003821AF9900980E000D2FA9
69926+:1093F000000000000A000F008F8600580E000D5775
69927+:10940000000000008F8500942419000200403021E4
69928+:1094100024040010000038210A000F56AF9900986C
69929+:109420000040382124040010970F0002000028217A
69930+:109430000E000D2F31E6FFFF8F8600580A000F0047
69931+:10944000AF9100988F84FF2C3C077FFF34E6FFFF2D
69932+:109450008C8500182402000100A61824AC83001893
69933+:1094600003E00008A08200053084FFFF30A5FFFF65
69934+:109470001080000700001821308200011040000217
69935+:1094800000042042006518211480FFFB00052840DD
69936+:1094900003E000080060102110C000070000000079
69937+:1094A0008CA2000024C6FFFF24A50004AC820000AB
69938+:1094B00014C0FFFB2484000403E000080000000047
69939+:1094C00010A0000824A3FFFFAC86000000000000ED
69940+:1094D000000000002402FFFF2463FFFF1462FFFA74
69941+:1094E0002484000403E0000800000000000411C010
69942+:1094F00003E000082442024027BDFFE8AFB000109F
69943+:1095000000808021AFBF00140E000F9600A0202124
69944+:1095100000504821240AFF808FBF00148FB0001034
69945+:10952000012A30243127007F3C08800A3C042100B6
69946+:1095300000E8102100C428253C03800027BD001846
69947+:10954000AC650024AF820038AC400000AC6500245C
69948+:1095500003E00008AC4000403C0D08008DAD005811
69949+:1095600000056180240AFF8001A45821016C482174
69950+:10957000012A30243127007F3C08800C3C04210064
69951+:1095800000E8102100C428253C038000AC650028B9
69952+:10959000AF82003403E00008AC40002430A5FFFF98
69953+:1095A0003C0680008CC201B80440FFFE3C086015F8
69954+:1095B00000A838253C031000ACC40180ACC0018475
69955+:1095C000ACC7018803E00008ACC301B83C0D08003B
69956+:1095D0008DAD005800056180240AFF8001A4582148
69957+:1095E000016C4021010A4824000931403107007F05
69958+:1095F00000C728253C04200000A418253C02800058
69959+:10960000AC43083003E00008AF80003427BDFFE81A
69960+:10961000AFB0001000808021AFBF00140E000F9685
69961+:1096200000A0202100504821240BFF80012B502452
69962+:10963000000A39403128007F3C0620008FBF00140B
69963+:109640008FB0001000E8282534C2000100A21825C0
69964+:109650003C04800027BD0018AC83083003E00008FC
69965+:10966000AF8000383C0580088CA700603C0680086D
69966+:109670000087102B144000112C8340008CA8006040
69967+:109680002D0340001060000F240340008CC90060CF
69968+:109690000089282B14A00002008018218CC30060D0
69969+:1096A00000035A42000B30803C0A0800254A59202A
69970+:1096B00000CA202103E000088C8200001460FFF340
69971+:1096C0002403400000035A42000B30803C0A08008B
69972+:1096D000254A592000CA202103E000088C8200009E
69973+:1096E0003C05800890A60008938400AB24C20001CA
69974+:1096F000304200FF3043007F1064000C0002382726
69975+:10970000A0A200083C0480008C85017804A0FFFE24
69976+:109710008F8A00A0240900023C081000AC8A014096
69977+:10972000A089014403E00008AC8801780A00101BFE
69978+:1097300030E2008027BDFFD8AFB200188F9200A49E
69979+:10974000AFBF0020AFB3001CAFB00010AFB100142A
69980+:109750008F9300348E5900283C1000803C0EFFEFA0
69981+:10976000AE7900008E580024A260000A35CDFFFFBC
69982+:10977000AE7800049251002C3C0BFF9F356AFFFF2E
69983+:10978000A271000C8E6F000C3C080040A271000B0F
69984+:1097900001F06025018D4824012A382400E8302595
69985+:1097A000AE66000C8E450004AE6000183C0400FF5D
69986+:1097B000AE6500148E43002C3482FFFFA6600008C3
69987+:1097C0000062F824AE7F00108E5900088F9000A030
69988+:1097D000964E0012AE7900208E51000C31D83FFF1A
69989+:1097E00000187980AE7100248E4D001401F06021C4
69990+:1097F00031CB0001AE6D00288E4A0018000C41C22A
69991+:10980000000B4B80AE6A002C8E46001C01093821EB
69992+:10981000A667001CAE660030964500028E4400200C
69993+:10982000A665001EAE64003492430033306200042B
69994+:1098300054400006924700003C0280083443010077
69995+:109840008C7F00D0AE7F0030924700008F860038BA
69996+:10985000A0C700309245003330A4000250800007BA
69997+:10986000925100018F880038240BFF80910A00304C
69998+:10987000014B4825A1090030925100018F9000381A
69999+:10988000240CFFBF2404FFDFA21100318F8D0038AC
70000+:109890003C1880083711008091AF003C31EE007F0A
70001+:1098A000A1AE003C8F890038912B003C016C502404
70002+:1098B000A12A003C8F9F00388E68001493E6003C7C
70003+:1098C0002D0700010007114000C4282400A218251C
70004+:1098D000A3E3003C8F87003896590012A4F90032A8
70005+:1098E0008E450004922E007C30B0000300107823D7
70006+:1098F00031ED000300AD102131CC000215800002D3
70007+:1099000024460034244600303C0280083443008062
70008+:10991000907F007C00BFC824333800041700000289
70009+:1099200024C2000400C010218F98003824190002BE
70010+:10993000ACE20034A3190000924F003F8F8E003834
70011+:109940003C0C8008358B0080A1CF00018F9100383E
70012+:10995000924D003F8E440004A62D0002956A005CE3
70013+:109960000E000FF43150FFFF00024B800209382532
70014+:109970003C08420000E82825AE2500048E4400384B
70015+:109980008F850038ACA400188E460034ACA6001CAD
70016+:10999000ACA0000CACA00010A4A00014A4A0001661
70017+:1099A000A4A00020A4A00022ACA000248E62001479
70018+:1099B00050400001240200018FBF00208FB3001C23
70019+:1099C0008FB200188FB100148FB00010ACA2000845
70020+:1099D0000A00101327BD002827BDFFC83C058008DA
70021+:1099E00034A40080AFBF0034AFBE0030AFB7002C4E
70022+:1099F000AFB60028AFB50024AFB40020AFB3001C51
70023+:109A0000AFB20018AFB10014AFB00010948300786B
70024+:109A10009482007A104300512405FFFF0080F0215A
70025+:109A20000A0011230080B821108B004D8FBF003435
70026+:109A30008F8600A03C1808008F18005C2411FF805E
70027+:109A40003C1680000306782101F18024AED0002C62
70028+:109A500096EE007A31EC007F3C0D800E31CB7FFF1B
70029+:109A6000018D5021000B4840012AA82196A4000036
70030+:109A70003C0808008D0800582405FF8030953FFF02
70031+:109A800001061821001539800067C8210325F82434
70032+:109A90003C02010003E290253338007F3C11800C2A
70033+:109AA000AED20028031190219250000D320F000415
70034+:109AB00011E0003702E0982196E3007A96E8007AF8
70035+:109AC00096E5007A2404800031077FFF24E300013B
70036+:109AD00030627FFF00A4F82403E2C825A6F9007ACB
70037+:109AE00096E6007A3C1408008E94006030D67FFF22
70038+:109AF00012D400C1000000008E5800188F8400A00E
70039+:109B000002A028212713FFFF0E000FCEAE53002C1A
70040+:109B100097D5007897D4007A12950010000028217C
70041+:109B20003C098008352401003C0A8008914800085F
70042+:109B3000908700D53114007F30E400FF0284302B81
70043+:109B400014C0FFB9268B0001938E00AB268C000158
70044+:109B5000008E682115ACFFB78F8600A08FBF003440
70045+:109B60008FBE00308FB7002C8FB600288FB5002431
70046+:109B70008FB400208FB3001C8FB200188FB1001477
70047+:109B80008FB0001000A0102103E0000827BD0038AE
70048+:109B900000C020210E000F99028028218E4B00105A
70049+:109BA0008E4C00308F84003824090002016C502351
70050+:109BB000AE4A0010A089000096E3005C8E4400309D
70051+:109BC0008F9100380E000FF43070FFFF00024380C9
70052+:109BD000020838253C02420000E22825AE25000498
70053+:109BE0008E5F00048F8A00388E590000240B000815
70054+:109BF000AD5F001CAD590018AD40000CAD40001029
70055+:109C00009246000A240400052408C00030D000FF5A
70056+:109C1000A550001496580008A55800169251000A45
70057+:109C20003C188008322F00FFA54F0020964E0008F8
70058+:109C300037110100A54E0022AD400024924D000BCB
70059+:109C400031AC00FFA54C0002A14B00018E49003051
70060+:109C50008F830038240BFFBFAC690008A06400307C
70061+:109C60008F9000382403FFDF9607003200E8282495
70062+:109C700000B51025A6020032921F003233F9003FD2
70063+:109C800037260040A20600328F8C0038AD800034A9
70064+:109C90008E2F00D0AD8F0038918E003C3C0F7FFF9F
70065+:109CA00031CD007FA18D003C8F84003835EEFFFF61
70066+:109CB000908A003C014B4824A089003C8F850038E5
70067+:109CC00090A8003C01033824A0A7003C8E42003439
70068+:109CD0008F9100383C038008AE2200408E59002C42
70069+:109CE0008E5F0030033F3023AE26004492300048A0
70070+:109CF0003218007FA23800488F8800388E4D00301F
70071+:109D00008D0C004801AE582401965024014B482583
70072+:109D1000AD0900489244000AA104004C964700088F
70073+:109D20008F850038A4A7004E8E5000308E4400303E
70074+:109D30000E0003818C65006092F9007C0002F940FE
70075+:109D4000004028210002110003E2302133360002D6
70076+:109D500012C00003020680210005B0800216802197
70077+:109D6000926D007C31B30004126000020005708027
70078+:109D7000020E80218E4B00308F8800382405800031
70079+:109D8000316A0003000A4823312400030204182129
70080+:109D9000AD03003496E4007A96F0007A96F1007AEA
70081+:109DA00032027FFF2447000130FF7FFF0225C824D5
70082+:109DB000033F3025A6E6007A96F8007A3C120800A8
70083+:109DC0008E520060330F7FFF11F200180000000078
70084+:109DD0008F8400A00E000FCE02A028218F8400A047
70085+:109DE0000E000FDE028028210E001013000000007C
70086+:109DF0000A00111F0000000096F1007A022480245E
70087+:109E0000A6F0007A92EF007A92EB007A31EE00FF32
70088+:109E1000000E69C2000D6027000C51C03169007F3F
70089+:109E2000012A20250A001119A2E4007A96E6007A98
70090+:109E300000C5C024A6F8007A92EF007A92F3007A67
70091+:109E400031F200FF001271C2000E6827000DB1C090
70092+:109E5000326C007F01962825A2E5007A0A0011D015
70093+:109E60008F8400A03C0380003084FFFF30A5FFFFFB
70094+:109E7000AC640018AC65001C03E000088C620014A0
70095+:109E800027BDFFA03C068008AFBF005CAFBE0058F6
70096+:109E9000AFB70054AFB60050AFB5004CAFB40048F8
70097+:109EA000AFB30044AFB20040AFB1003CAFB0003838
70098+:109EB00034C80100910500D590C700083084FFFF29
70099+:109EC00030A500FF30E2007F0045182AAFA4001043
70100+:109ED000A7A00018A7A0002610600055AFA000148E
70101+:109EE00090CA00083149007F00A9302324D3FFFF26
70102+:109EF0000013802B8FB400100014902B02128824C2
70103+:109F0000522000888FB300143C03800894790052DB
70104+:109F1000947E00508FB60010033EC0230018BC0092
70105+:109F2000001714030016FC0002C2A82A16A00002A3
70106+:109F3000001F2C030040282100133C0000072403CD
70107+:109F400000A4102A5440000100A020212885000907
70108+:109F500014A000020080A021241400083C0C8008FA
70109+:109F60008D860048001459808D88004C3C03800089
70110+:109F70003169FFFF3C0A0010012A202534710400DA
70111+:109F8000AC660038AF9100A4AC68003CAC64003013
70112+:109F900000000000000000000000000000000000C1
70113+:109FA00000000000000000000000000000000000B1
70114+:109FB0008C6E000031CD002011A0FFFD0014782A26
70115+:109FC00001F01024104000390000A8213C16800840
70116+:109FD00092D700083C1280008E44010032F6007FC8
70117+:109FE0000E000F9902C028218E3900108E44010006
70118+:109FF0000000902133373FFF0E000FB102E028210F
70119+:10A00000923800003302003F2C500008520000102C
70120+:10A0100000008821000210803C030800246358E4FB
70121+:10A020000043F8218FFE000003C00008000000007C
70122+:10A0300090CF0008938C00AB31EE007F00AE682318
70123+:10A04000018D58210A0012172573FFFF0000882197
70124+:10A050003C1E80008FC401000E000FCE02E02821BC
70125+:10A060008FC401000E000FDE02C028211220000F55
70126+:10A070000013802B8F8B00A426A400010004AC00E9
70127+:10A08000027298230015AC032578004002B4B02A70
70128+:10A090000013802B241700010300882102D0102414
70129+:10A0A000AF9800A41440FFC9AFB700143C07800864
70130+:10A0B00094E200508FAE00103C05800002A288217F
70131+:10A0C0003C060020A4F10050ACA6003094F40050EF
70132+:10A0D00094EF005201D51823306CFFFF11F4001EDD
70133+:10A0E000AFAC00108CEF004C001561808CF500487F
70134+:10A0F00001EC28210000202100AC582B02A4C02133
70135+:10A10000030BB021ACE5004CACF600488FB4001056
70136+:10A110000014902B021288241620FF7C3C03800838
70137+:10A120008FB300148FBF005C8FBE00583A620001ED
70138+:10A130008FB700548FB600508FB5004C8FB40048D5
70139+:10A140008FB300448FB200408FB1003C8FB0003815
70140+:10A1500003E0000827BD006094FE00548CF2004428
70141+:10A1600033C9FFFE0009C8C00259F821ACBF003C4A
70142+:10A170008CE800448CAD003C010D50231940003B9D
70143+:10A18000000000008CF7004026E20001ACA200387D
70144+:10A190003C05005034A700103C038000AC67003041
70145+:10A1A00000000000000000000000000000000000AF
70146+:10A1B000000000000000000000000000000000009F
70147+:10A1C0008C7800003316002012C0FFFD3C1180087F
70148+:10A1D000962200543C1580003C068008304E000159
70149+:10A1E000000E18C0007578218DEC04003C070800B3
70150+:10A1F0008CE700443C040020ACCC00488DF40404FF
70151+:10A20000240B0001ACD4004C10EB0260AEA4003073
70152+:10A21000963900523C0508008CA5004000B99021F9
70153+:10A22000A6320052963F005427ED0001A62D00549F
70154+:10A230009626005430C4FFFF5487FF2F8FB40010C0
70155+:10A2400030A5FFFF0E0011F4A62000543C070800C3
70156+:10A250008CE70024963E00520047B82303D74823DA
70157+:10A26000A62900520A0012198FB400108CE2004097
70158+:10A270000A0012BE00000000922400012407000121
70159+:10A280003085007F14A7001C97AD00268E2B00148C
70160+:10A29000240CC000316A3FFF01AC48243C06080092
70161+:10A2A0008CC60060012A402531043FFF0086882BC0
70162+:10A2B00012200011A7A800263C0508008CA5005814
70163+:10A2C0008F9100A0000439802402FF8000B1182182
70164+:10A2D0000067F82103E2F02433F8007F3C1280008D
70165+:10A2E0003C19800EAE5E002C0319702191D0000D38
70166+:10A2F000360F0004A1CF000D0E001028241200011B
70167+:10A30000241100013C1E80008FC401000E000FCEFE
70168+:10A3100002E028218FC401000E000FDE02C02821B8
70169+:10A320001620FF558F8B00A40A0012860013802B85
70170+:10A330008F8600A490C80001310400201080019194
70171+:10A34000241000013C048008348B0080916A007C5A
70172+:10A350008F9E0034AFA0002C314900011120000F66
70173+:10A36000AFB000288CCD00148C8E006001AE602B45
70174+:10A370001580000201A038218C8700603C188008FD
70175+:10A38000370300808C70007000F0782B15E000021D
70176+:10A3900000E020218C640070AFA4002C3C028008F7
70177+:10A3A000344500808CD200148CBF0070025FC82B33
70178+:10A3B00017200002024020218CA400708FA7002CDF
70179+:10A3C0000087182310600003AFA3003024050002AB
70180+:10A3D000AFA500288FA400280264882B162000BA9D
70181+:10A3E000000018218CD000388FCE000C3C0F00806C
70182+:10A3F000AFD000008CCD00343C0CFF9F01CF58251E
70183+:10A40000AFCD000490CA003F3586FFFF01662024CF
70184+:10A410003C0900203C08FFEFA3CA000B0089382547
70185+:10A420003511FFFF00F118243C0500088F8700A4B8
70186+:10A430000065C825AFD9000C8CE20014AFC000182D
70187+:10A440008FA60030AFC200148CF800188FB0002C1B
70188+:10A450003C1FFFFBAFD8001C8CEF000837F2FFFF5A
70189+:10A4600003326824AFCF00248CEC000C020670216C
70190+:10A47000AFCD000CA7C00038A7C0003AAFCE002C6B
70191+:10A48000AFCC0020AFC000288CEA00148FAB002CAA
70192+:10A49000014B48230126402311000011AFC80010D2
70193+:10A4A00090EB003D8FC900048FC80000000B5100E5
70194+:10A4B000012A28210000102100AA882B010218215E
70195+:10A4C0000071F821AFC50004AFDF000090F2003D3D
70196+:10A4D000A3D2000A8F9900A497380006A7D80008D5
70197+:10A4E0008F910038240800023C038008A228000055
70198+:10A4F0003465008094BF005C8FA4002C33F0FFFF14
70199+:10A500000E000FF48F9200380002CB808F8500A4DC
70200+:10A51000021978253C18420001F87025AE4E00045F
70201+:10A520008F8400388CAD0038AC8D00188CAC0034B2
70202+:10A53000AC8C001CAC80000CAC800010A48000141B
70203+:10A54000A4800016A4800020A4800022AC800024F7
70204+:10A5500090A6003F8FA7002CA486000250E0019235
70205+:10A56000240700018FA200305040000290A2003D5D
70206+:10A5700090A2003E244A0001A08A00018F84003886
70207+:10A580008FA9002CAC8900083C128008364D008051
70208+:10A5900091AC007C3186000214C000022407003414
70209+:10A5A000240700308F8500A43C198008373F0080C5
70210+:10A5B00090B0000093F9007C240E0004A0900030BD
70211+:10A5C0008F8F00A48FB8002C8F8D003891F200017E
70212+:10A5D0003304000301C46023A1B200318F8E003820
70213+:10A5E0008F8600A42402C00095CA003294C90012CC
70214+:10A5F0008FAB002C0142402431233FFF010388250B
70215+:10A60000A5D1003291D000323185000300EBF82152
70216+:10A610003218003F370F0040A1CF00328FA4002C2A
70217+:10A6200003E5382133280004108000028F850038AC
70218+:10A6300000E838213C0A8008ACA700343549010005
70219+:10A640008D2800D08FA3002C2419FFBFACA80038A0
70220+:10A6500090B1003C2C640001240FFFDF3227007F03
70221+:10A66000A0A7003C8F98003800049140931F003C45
70222+:10A6700003F98024A310003C8F8C0038918E003C9D
70223+:10A6800001CF682401B23025A186003C8F8900A447
70224+:10A690008F8800388D2B0020AD0B00408D220024C8
70225+:10A6A000AD0200448D2A0028AD0A00488D23002CFD
70226+:10A6B0000E001013AD03004C8FB1002824070002D8
70227+:10A6C000122700118FA300280003282B00058023E8
70228+:10A6D0000270982400608021006090210A00126FAF
70229+:10A6E0000010882B962900128F8400A00000902172
70230+:10A6F0003125FFFFA7A900180E000FC22411000189
70231+:10A700000A00131D3C1E80003C0B80003C12800898
70232+:10A710008D640100924900088F92FF340E000F995A
70233+:10A720003125007F8F9900388FA700288FA4003033
70234+:10A73000A3270000965F005C33F0FFFF0E000FF4CC
70235+:10A740008F91003800026B80020D80253C0842008A
70236+:10A750008F8D00A402085025AE2A00048DA5003874
70237+:10A760008F8A003800007821000F1100AD450018D5
70238+:10A770008DB800343C047FFF3488FFFFAD58001CC7
70239+:10A7800091A6003E8D4C001C8D4900180006190052
70240+:10A79000000677020183C821004E58250323882B29
70241+:10A7A000012B382100F1F821AD59001CAD5F0018D4
70242+:10A7B000AD40000CAD40001091B0003E8FA40030C1
70243+:10A7C00024090005A550001495A500042419C00013
70244+:10A7D00000884024A545001691B8003EA5580020E9
70245+:10A7E00095AF0004A54F0022AD40002491AE003F7C
70246+:10A7F000A54E000291A6003E91AC003D01861023BB
70247+:10A80000244B0001A14B00018F9100388FA3003031
70248+:10A810003C028008344B0100AE230008A22900301E
70249+:10A820008F8C00388F8700A4959F003294F000121F
70250+:10A830002407FFBF033FC02432053FFF03057825EF
70251+:10A84000A58F0032918E00322418FFDF31CD003FFA
70252+:10A8500035A60040A18600328F910038240DFFFFFD
70253+:10A86000240CFF80AE2000348D6A00D0AE2A003860
70254+:10A870009223003C3069007FA229003C8F90003871
70255+:10A880003C0380009219003C0327F824A21F003CDF
70256+:10A890008F8E003891C5003C00B87824A1CF003CD1
70257+:10A8A0008F8A00383C0E8008AD4D00408FA6002CEA
70258+:10A8B000AD46004491420048004C5825A14B004849
70259+:10A8C0008F9000388F9900A48E09004801238824B6
70260+:10A8D00002283825AE070048933F003EA21F004CD7
70261+:10A8E0008F9800A48F8F003897050004A5E5004ECF
70262+:10A8F0000E0003818DC500609246007C8FAC003055
70263+:10A9000000026940000291000040282130CB000283
70264+:10A9100001B21021156000AA018230213C0E80088E
70265+:10A9200035C20080904C007C31830004106000032D
70266+:10A930008FB900300005788000CF3021241F00043B
70267+:10A940008F910038332D000303ED8023320800037C
70268+:10A9500000C85021AE2A00343C188000A7C500383A
70269+:10A960003C0680088F04010090DE00080E000FDE18
70270+:10A9700033C5007F0E001013000000000A00140D04
70271+:10A980008FA300288F9800348CC90038241F00033F
70272+:10A99000A7000008AF0900008CC50034A300000A1E
70273+:10A9A0008F9900A4AF0500043C080080932D003F60
70274+:10A9B000A31F000C8F0A000C3C02FF9FA30D000B8D
70275+:10A9C0000148F0253451FFFF3C12FFEF8F9900A49E
70276+:10A9D00003D170243646FFFF01C61824AF03000CD4
70277+:10A9E0008F2C0014972900128F8400A0AF0C001048
70278+:10A9F0008F2F0014AF000018AF000020AF0F00141D
70279+:10AA0000AF0000248F270018312F3FFF000F59801F
70280+:10AA1000AF0700288F2500080164F821312D0001BF
70281+:10AA2000AF0500308F31000C8F920038001F51C2EB
70282+:10AA3000000D438001481021241E00023C068008BE
70283+:10AA4000A702001CA7000034AF11002CA25E00007A
70284+:10AA500034D20080964E005C8F9900383C0342004F
70285+:10AA600031CCFFFF01833825AF2700048F8B00A472
70286+:10AA7000240500012402C0008D640038240700343E
70287+:10AA8000AF2400188D690034AF29001CAF20000CE2
70288+:10AA9000AF200010A7200014A7200016A720002038
70289+:10AAA000A7200022AF200024A7300002A325000128
70290+:10AAB0008F8800388F9F00A4AD10000893ED000030
70291+:10AAC000A10D00308F8A00A48F98003891510001A9
70292+:10AAD000A31100318F8B0038957E003203C27024A1
70293+:10AAE00001CF6025A56C0032916300323064003FD5
70294+:10AAF000A16400329249007C3125000214A00002BA
70295+:10AB00008F840038240700303C198008AC8700345B
70296+:10AB1000373201008E5F00D0240AFFBF020090216F
70297+:10AB2000AC9F0038908D003C31A8007FA088003C8D
70298+:10AB30008F9E003893C2003C004A8824A3D1003C79
70299+:10AB40008F8300380010882B9066003C34CE0020A4
70300+:10AB5000A06E003C8F8400A48F9800388C8C00205D
70301+:10AB6000AF0C00408C8F0024AF0F00448C8700286E
70302+:10AB7000AF0700488C8B002CAF0B004C0E0010135D
70303+:10AB80003C1E80000A0012700000000094C80052B1
70304+:10AB90003C0A08008D4A002401488821A4D10052B3
70305+:10ABA0000A0012198FB40010A08700018F840038AA
70306+:10ABB000240B0001AC8B00080A0013BE3C12800875
70307+:10ABC000000520800A0014A200C4302127BDFFE048
70308+:10ABD0003C0D8008AFB20018AFB00010AFBF001C32
70309+:10ABE000AFB1001435B200808E4C001835A80100BA
70310+:10ABF000964B000695A70050910900FC000C5602E8
70311+:10AC0000016728233143007F312600FF240200031F
70312+:10AC1000AF8300A8AF8400A010C2001B30B0FFFFBC
70313+:10AC2000910600FC2412000530C200FF10520033D0
70314+:10AC300000000000160000098FBF001C8FB2001832
70315+:10AC40008FB100148FB00010240D0C003C0C80005C
70316+:10AC500027BD002003E00008AD8D00240E0011FB8D
70317+:10AC6000020020218FBF001C8FB200188FB100148A
70318+:10AC70008FB00010240D0C003C0C800027BD00207C
70319+:10AC800003E00008AD8D0024965800789651007AB4
70320+:10AC9000924E007D0238782631E8FFFF31C400C0B3
70321+:10ACA000148000092D11000116000037000000007B
70322+:10ACB0005620FFE28FBF001C0E0010D100000000E4
70323+:10ACC0000A00156A8FBF001C1620FFDA0000000082
70324+:10ACD0000E0010D1000000001440FFD88FBF001CF0
70325+:10ACE0001600002200000000925F007D33E2003F6A
70326+:10ACF000A242007D0A00156A8FBF001C950900EA78
70327+:10AD00008F86008000802821240400050E0007257E
70328+:10AD10003130FFFF978300923C0480002465FFFFE1
70329+:10AD2000A78500928C8A01B80540FFFE0000000054
70330+:10AD3000AC8001808FBF001CAC9001848FB20018E2
70331+:10AD40008FB100148FB000103C0760133C0B100053
70332+:10AD5000240D0C003C0C800027BD0020AC8701882E
70333+:10AD6000AC8B01B803E00008AD8D00240E0011FB90
70334+:10AD7000020020215040FFB18FBF001C925F007D78
70335+:10AD80000A00159733E2003F0E0011FB020020215C
70336+:10AD90001440FFAA8FBF001C122000070000000013
70337+:10ADA0009259007D3330003F36020040A242007DC0
70338+:10ADB0000A00156A8FBF001C0E0010D100000000B1
70339+:10ADC0005040FF9E8FBF001C9259007D3330003FE2
70340+:10ADD0000A0015C636020040000000000000001BFB
70341+:10ADE0000000000F0000000A00000008000000063C
70342+:10ADF0000000000500000005000000040000000441
70343+:10AE00000000000300000003000000030000000336
70344+:10AE10000000000300000002000000020000000229
70345+:10AE2000000000020000000200000002000000021A
70346+:10AE3000000000020000000200000002000000020A
70347+:10AE400000000002000000020000000200000002FA
70348+:10AE50000000000100000001000000018008010066
70349+:10AE6000800800808008000000000C000000308096
70350+:10AE7000080011D00800127C08001294080012A8E3
70351+:10AE8000080012BC080011D0080011D0080012F010
70352+:10AE90000800132C080013400800138808001A8CBF
70353+:10AEA00008001A8C08001AC408001AC408001AD82E
70354+:10AEB00008001AA808001D0008001CCC08001D5836
70355+:10AEC00008001D5808001DE008001D108008024001
70356+:10AED000080027340800256C0800275C080027F4C8
70357+:10AEE0000800293C0800298808002AAC080029B479
70358+:10AEF00008002A38080025DC08002EDC08002EA4F3
70359+:10AF000008002588080025880800258808002B20CF
70360+:10AF100008002B20080025880800258808002DD06F
70361+:10AF2000080025880800258808002588080025884D
70362+:10AF300008002E0C080025880800258808002588B0
70363+:10AF4000080025880800258808002588080025882D
70364+:10AF5000080025880800258808002588080025881D
70365+:10AF6000080025880800258808002588080029A8E9
70366+:10AF7000080025880800258808002E680800258814
70367+:10AF800008002588080025880800258808002588ED
70368+:10AF900008002588080025880800258808002588DD
70369+:10AFA00008002588080025880800258808002588CD
70370+:10AFB00008002588080025880800258808002588BD
70371+:10AFC00008002CF4080025880800258808002C6853
70372+:10AFD00008002BC408003CE408003CB808003C848E
70373+:10AFE00008003C5808003C3808003BEC8008010091
70374+:10AFF00080080080800800008008008008004C6401
70375+:10B0000008004C9C08004BE408004C6408004C64A9
70376+:10B01000080049B808004C64080050500A000C842D
70377+:10B0200000000000000000000000000D7278703683
70378+:10B030002E322E31620000000602010300000000E3
70379+:10B0400000000001000000000000000000000000FF
70380+:10B0500000000000000000000000000000000000F0
70381+:10B0600000000000000000000000000000000000E0
70382+:10B0700000000000000000000000000000000000D0
70383+:10B0800000000000000000000000000000000000C0
70384+:10B0900000000000000000000000000000000000B0
70385+:10B0A00000000000000000000000000000000000A0
70386+:10B0B0000000000000000000000000000000000090
70387+:10B0C0000000000000000000000000000000000080
70388+:10B0D0000000000000000000000000000000000070
70389+:10B0E0000000000000000000000000000000000060
70390+:10B0F0000000000000000000000000000000000050
70391+:10B10000000000000000000000000000000000003F
70392+:10B11000000000000000000000000000000000002F
70393+:10B12000000000000000000000000000000000001F
70394+:10B13000000000000000000000000000000000000F
70395+:10B1400000000000000000000000000000000000FF
70396+:10B1500000000000000000000000000000000000EF
70397+:10B1600000000000000000000000000000000000DF
70398+:10B1700000000000000000000000000000000000CF
70399+:10B1800000000000000000000000000000000000BF
70400+:10B1900000000000000000000000000000000000AF
70401+:10B1A000000000000000000000000000000000009F
70402+:10B1B000000000000000000000000000000000008F
70403+:10B1C000000000000000000000000000000000007F
70404+:10B1D000000000000000000000000000000000006F
70405+:10B1E000000000000000000000000000000000005F
70406+:10B1F000000000000000000000000000000000004F
70407+:10B20000000000000000000000000000000000003E
70408+:10B21000000000000000000000000000000000002E
70409+:10B22000000000000000000000000000000000001E
70410+:10B23000000000000000000000000000000000000E
70411+:10B2400000000000000000000000000000000000FE
70412+:10B2500000000000000000000000000000000000EE
70413+:10B2600000000000000000000000000000000000DE
70414+:10B2700000000000000000000000000000000000CE
70415+:10B2800000000000000000000000000000000000BE
70416+:10B2900000000000000000000000000000000000AE
70417+:10B2A000000000000000000000000000000000009E
70418+:10B2B000000000000000000000000000000000008E
70419+:10B2C000000000000000000000000000000000007E
70420+:10B2D000000000000000000000000000000000006E
70421+:10B2E000000000000000000000000000000000005E
70422+:10B2F000000000000000000000000000000000004E
70423+:10B30000000000000000000000000000000000003D
70424+:10B31000000000000000000000000000000000002D
70425+:10B32000000000000000000000000000000000001D
70426+:10B33000000000000000000000000000000000000D
70427+:10B3400000000000000000000000000000000000FD
70428+:10B3500000000000000000000000000000000000ED
70429+:10B3600000000000000000000000000000000000DD
70430+:10B3700000000000000000000000000000000000CD
70431+:10B3800000000000000000000000000000000000BD
70432+:10B3900000000000000000000000000000000000AD
70433+:10B3A000000000000000000000000000000000009D
70434+:10B3B000000000000000000000000000000000008D
70435+:10B3C000000000000000000000000000000000007D
70436+:10B3D000000000000000000000000000000000006D
70437+:10B3E000000000000000000000000000000000005D
70438+:10B3F000000000000000000000000000000000004D
70439+:10B40000000000000000000000000000000000003C
70440+:10B41000000000000000000000000000000000002C
70441+:10B42000000000000000000000000000000000001C
70442+:10B43000000000000000000000000000000000000C
70443+:10B4400000000000000000000000000000000000FC
70444+:10B4500000000000000000000000000000000000EC
70445+:10B4600000000000000000000000000000000000DC
70446+:10B4700000000000000000000000000000000000CC
70447+:10B4800000000000000000000000000000000000BC
70448+:10B4900000000000000000000000000000000000AC
70449+:10B4A000000000000000000000000000000000009C
70450+:10B4B000000000000000000000000000000000008C
70451+:10B4C000000000000000000000000000000000007C
70452+:10B4D000000000000000000000000000000000006C
70453+:10B4E000000000000000000000000000000000005C
70454+:10B4F000000000000000000000000000000000004C
70455+:10B50000000000000000000000000000000000003B
70456+:10B51000000000000000000000000000000000002B
70457+:10B52000000000000000000000000000000000001B
70458+:10B53000000000000000000000000000000000000B
70459+:10B5400000000000000000000000000000000000FB
70460+:10B5500000000000000000000000000000000000EB
70461+:10B5600000000000000000000000000000000000DB
70462+:10B5700000000000000000000000000000000000CB
70463+:10B5800000000000000000000000000000000000BB
70464+:10B5900000000000000000000000000000000000AB
70465+:10B5A000000000000000000000000000000000009B
70466+:10B5B000000000000000000000000000000000008B
70467+:10B5C000000000000000000000000000000000007B
70468+:10B5D000000000000000000000000000000000006B
70469+:10B5E000000000000000000000000000000000005B
70470+:10B5F000000000000000000000000000000000004B
70471+:10B60000000000000000000000000000000000003A
70472+:10B61000000000000000000000000000000000002A
70473+:10B62000000000000000000000000000000000001A
70474+:10B63000000000000000000000000000000000000A
70475+:10B6400000000000000000000000000000000000FA
70476+:10B6500000000000000000000000000000000000EA
70477+:10B6600000000000000000000000000000000000DA
70478+:10B6700000000000000000000000000000000000CA
70479+:10B6800000000000000000000000000000000000BA
70480+:10B6900000000000000000000000000000000000AA
70481+:10B6A000000000000000000000000000000000009A
70482+:10B6B000000000000000000000000000000000008A
70483+:10B6C000000000000000000000000000000000007A
70484+:10B6D000000000000000000000000000000000006A
70485+:10B6E000000000000000000000000000000000005A
70486+:10B6F000000000000000000000000000000000004A
70487+:10B700000000000000000000000000000000000039
70488+:10B710000000000000000000000000000000000029
70489+:10B720000000000000000000000000000000000019
70490+:10B730000000000000000000000000000000000009
70491+:10B7400000000000000000000000000000000000F9
70492+:10B7500000000000000000000000000000000000E9
70493+:10B7600000000000000000000000000000000000D9
70494+:10B7700000000000000000000000000000000000C9
70495+:10B7800000000000000000000000000000000000B9
70496+:10B7900000000000000000000000000000000000A9
70497+:10B7A0000000000000000000000000000000000099
70498+:10B7B0000000000000000000000000000000000089
70499+:10B7C0000000000000000000000000000000000079
70500+:10B7D0000000000000000000000000000000000069
70501+:10B7E0000000000000000000000000000000000059
70502+:10B7F0000000000000000000000000000000000049
70503+:10B800000000000000000000000000000000000038
70504+:10B810000000000000000000000000000000000028
70505+:10B820000000000000000000000000000000000018
70506+:10B830000000000000000000000000000000000008
70507+:10B8400000000000000000000000000000000000F8
70508+:10B8500000000000000000000000000000000000E8
70509+:10B8600000000000000000000000000000000000D8
70510+:10B8700000000000000000000000000000000000C8
70511+:10B8800000000000000000000000000000000000B8
70512+:10B8900000000000000000000000000000000000A8
70513+:10B8A0000000000000000000000000000000000098
70514+:10B8B0000000000000000000000000000000000088
70515+:10B8C0000000000000000000000000000000000078
70516+:10B8D0000000000000000000000000000000000068
70517+:10B8E0000000000000000000000000000000000058
70518+:10B8F0000000000000000000000000000000000048
70519+:10B900000000000000000000000000000000000037
70520+:10B910000000000000000000000000000000000027
70521+:10B920000000000000000000000000000000000017
70522+:10B930000000000000000000000000000000000007
70523+:10B9400000000000000000000000000000000000F7
70524+:10B9500000000000000000000000000000000000E7
70525+:10B9600000000000000000000000000000000000D7
70526+:10B9700000000000000000000000000000000000C7
70527+:10B9800000000000000000000000000000000000B7
70528+:10B9900000000000000000000000000000000000A7
70529+:10B9A0000000000000000000000000000000000097
70530+:10B9B0000000000000000000000000000000000087
70531+:10B9C0000000000000000000000000000000000077
70532+:10B9D0000000000000000000000000000000000067
70533+:10B9E0000000000000000000000000000000000057
70534+:10B9F0000000000000000000000000000000000047
70535+:10BA00000000000000000000000000000000000036
70536+:10BA10000000000000000000000000000000000026
70537+:10BA20000000000000000000000000000000000016
70538+:10BA30000000000000000000000000000000000006
70539+:10BA400000000000000000000000000000000000F6
70540+:10BA500000000000000000000000000000000000E6
70541+:10BA600000000000000000000000000000000000D6
70542+:10BA700000000000000000000000000000000000C6
70543+:10BA800000000000000000000000000000000000B6
70544+:10BA900000000000000000000000000000000000A6
70545+:10BAA0000000000000000000000000000000000096
70546+:10BAB0000000000000000000000000000000000086
70547+:10BAC0000000000000000000000000000000000076
70548+:10BAD0000000000000000000000000000000000066
70549+:10BAE0000000000000000000000000000000000056
70550+:10BAF0000000000000000000000000000000000046
70551+:10BB00000000000000000000000000000000000035
70552+:10BB10000000000000000000000000000000000025
70553+:10BB20000000000000000000000000000000000015
70554+:10BB30000000000000000000000000000000000005
70555+:10BB400000000000000000000000000000000000F5
70556+:10BB500000000000000000000000000000000000E5
70557+:10BB600000000000000000000000000000000000D5
70558+:10BB700000000000000000000000000000000000C5
70559+:10BB800000000000000000000000000000000000B5
70560+:10BB900000000000000000000000000000000000A5
70561+:10BBA0000000000000000000000000000000000095
70562+:10BBB0000000000000000000000000000000000085
70563+:10BBC0000000000000000000000000000000000075
70564+:10BBD0000000000000000000000000000000000065
70565+:10BBE0000000000000000000000000000000000055
70566+:10BBF0000000000000000000000000000000000045
70567+:10BC00000000000000000000000000000000000034
70568+:10BC10000000000000000000000000000000000024
70569+:10BC20000000000000000000000000000000000014
70570+:10BC30000000000000000000000000000000000004
70571+:10BC400000000000000000000000000000000000F4
70572+:10BC500000000000000000000000000000000000E4
70573+:10BC600000000000000000000000000000000000D4
70574+:10BC700000000000000000000000000000000000C4
70575+:10BC800000000000000000000000000000000000B4
70576+:10BC900000000000000000000000000000000000A4
70577+:10BCA0000000000000000000000000000000000094
70578+:10BCB0000000000000000000000000000000000084
70579+:10BCC0000000000000000000000000000000000074
70580+:10BCD0000000000000000000000000000000000064
70581+:10BCE0000000000000000000000000000000000054
70582+:10BCF0000000000000000000000000000000000044
70583+:10BD00000000000000000000000000000000000033
70584+:10BD10000000000000000000000000000000000023
70585+:10BD20000000000000000000000000000000000013
70586+:10BD30000000000000000000000000000000000003
70587+:10BD400000000000000000000000000000000000F3
70588+:10BD500000000000000000000000000000000000E3
70589+:10BD600000000000000000000000000000000000D3
70590+:10BD700000000000000000000000000000000000C3
70591+:10BD800000000000000000000000000000000000B3
70592+:10BD900000000000000000000000000000000000A3
70593+:10BDA0000000000000000000000000000000000093
70594+:10BDB0000000000000000000000000000000000083
70595+:10BDC0000000000000000000000000000000000073
70596+:10BDD0000000000000000000000000000000000063
70597+:10BDE0000000000000000000000000000000000053
70598+:10BDF0000000000000000000000000000000000043
70599+:10BE00000000000000000000000000000000000032
70600+:10BE10000000000000000000000000000000000022
70601+:10BE20000000000000000000000000000000000012
70602+:10BE30000000000000000000000000000000000002
70603+:10BE400000000000000000000000000000000000F2
70604+:10BE500000000000000000000000000000000000E2
70605+:10BE600000000000000000000000000000000000D2
70606+:10BE700000000000000000000000000000000000C2
70607+:10BE800000000000000000000000000000000000B2
70608+:10BE900000000000000000000000000000000000A2
70609+:10BEA0000000000000000000000000000000000092
70610+:10BEB0000000000000000000000000000000000082
70611+:10BEC0000000000000000000000000000000000072
70612+:10BED0000000000000000000000000000000000062
70613+:10BEE0000000000000000000000000000000000052
70614+:10BEF0000000000000000000000000000000000042
70615+:10BF00000000000000000000000000000000000031
70616+:10BF10000000000000000000000000000000000021
70617+:10BF20000000000000000000000000000000000011
70618+:10BF30000000000000000000000000000000000001
70619+:10BF400000000000000000000000000000000000F1
70620+:10BF500000000000000000000000000000000000E1
70621+:10BF600000000000000000000000000000000000D1
70622+:10BF700000000000000000000000000000000000C1
70623+:10BF800000000000000000000000000000000000B1
70624+:10BF900000000000000000000000000000000000A1
70625+:10BFA0000000000000000000000000000000000091
70626+:10BFB0000000000000000000000000000000000081
70627+:10BFC0000000000000000000000000000000000071
70628+:10BFD0000000000000000000000000000000000061
70629+:10BFE0000000000000000000000000000000000051
70630+:10BFF0000000000000000000000000000000000041
70631+:10C000000000000000000000000000000000000030
70632+:10C010000000000000000000000000000000000020
70633+:10C020000000000000000000000000000000000010
70634+:10C030000000000000000000000000000000000000
70635+:10C0400000000000000000000000000000000000F0
70636+:10C0500000000000000000000000000000000000E0
70637+:10C0600000000000000000000000000000000000D0
70638+:10C0700000000000000000000000000000000000C0
70639+:10C0800000000000000000000000000000000000B0
70640+:10C0900000000000000000000000000000000000A0
70641+:10C0A0000000000000000000000000000000000090
70642+:10C0B0000000000000000000000000000000000080
70643+:10C0C0000000000000000000000000000000000070
70644+:10C0D0000000000000000000000000000000000060
70645+:10C0E0000000000000000000000000000000000050
70646+:10C0F0000000000000000000000000000000000040
70647+:10C10000000000000000000000000000000000002F
70648+:10C11000000000000000000000000000000000001F
70649+:10C12000000000000000000000000000000000000F
70650+:10C1300000000000000000000000000000000000FF
70651+:10C1400000000000000000000000000000000000EF
70652+:10C1500000000000000000000000000000000000DF
70653+:10C1600000000000000000000000000000000000CF
70654+:10C1700000000000000000000000000000000000BF
70655+:10C1800000000000000000000000000000000000AF
70656+:10C19000000000000000000000000000000000009F
70657+:10C1A000000000000000000000000000000000008F
70658+:10C1B000000000000000000000000000000000007F
70659+:10C1C000000000000000000000000000000000006F
70660+:10C1D000000000000000000000000000000000005F
70661+:10C1E000000000000000000000000000000000004F
70662+:10C1F000000000000000000000000000000000003F
70663+:10C20000000000000000000000000000000000002E
70664+:10C21000000000000000000000000000000000001E
70665+:10C22000000000000000000000000000000000000E
70666+:10C2300000000000000000000000000000000000FE
70667+:10C2400000000000000000000000000000000000EE
70668+:10C2500000000000000000000000000000000000DE
70669+:10C2600000000000000000000000000000000000CE
70670+:10C2700000000000000000000000000000000000BE
70671+:10C2800000000000000000000000000000000000AE
70672+:10C29000000000000000000000000000000000009E
70673+:10C2A000000000000000000000000000000000008E
70674+:10C2B000000000000000000000000000000000007E
70675+:10C2C000000000000000000000000000000000006E
70676+:10C2D000000000000000000000000000000000005E
70677+:10C2E000000000000000000000000000000000004E
70678+:10C2F000000000000000000000000000000000003E
70679+:10C30000000000000000000000000000000000002D
70680+:10C31000000000000000000000000000000000001D
70681+:10C32000000000000000000000000000000000000D
70682+:10C3300000000000000000000000000000000000FD
70683+:10C3400000000000000000000000000000000000ED
70684+:10C3500000000000000000000000000000000000DD
70685+:10C3600000000000000000000000000000000000CD
70686+:10C3700000000000000000000000000000000000BD
70687+:10C3800000000000000000000000000000000000AD
70688+:10C39000000000000000000000000000000000009D
70689+:10C3A000000000000000000000000000000000008D
70690+:10C3B000000000000000000000000000000000007D
70691+:10C3C000000000000000000000000000000000006D
70692+:10C3D000000000000000000000000000000000005D
70693+:10C3E000000000000000000000000000000000004D
70694+:10C3F000000000000000000000000000000000003D
70695+:10C40000000000000000000000000000000000002C
70696+:10C41000000000000000000000000000000000001C
70697+:10C42000000000000000000000000000000000000C
70698+:10C4300000000000000000000000000000000000FC
70699+:10C4400000000000000000000000000000000000EC
70700+:10C4500000000000000000000000000000000000DC
70701+:10C4600000000000000000000000000000000000CC
70702+:10C4700000000000000000000000000000000000BC
70703+:10C4800000000000000000000000000000000000AC
70704+:10C49000000000000000000000000000000000009C
70705+:10C4A000000000000000000000000000000000008C
70706+:10C4B000000000000000000000000000000000007C
70707+:10C4C000000000000000000000000000000000006C
70708+:10C4D000000000000000000000000000000000005C
70709+:10C4E000000000000000000000000000000000004C
70710+:10C4F000000000000000000000000000000000003C
70711+:10C50000000000000000000000000000000000002B
70712+:10C51000000000000000000000000000000000001B
70713+:10C52000000000000000000000000000000000000B
70714+:10C5300000000000000000000000000000000000FB
70715+:10C5400000000000000000000000000000000000EB
70716+:10C5500000000000000000000000000000000000DB
70717+:10C5600000000000000000000000000000000000CB
70718+:10C5700000000000000000000000000000000000BB
70719+:10C5800000000000000000000000000000000000AB
70720+:10C59000000000000000000000000000000000009B
70721+:10C5A000000000000000000000000000000000008B
70722+:10C5B000000000000000000000000000000000007B
70723+:10C5C000000000000000000000000000000000006B
70724+:10C5D000000000000000000000000000000000005B
70725+:10C5E000000000000000000000000000000000004B
70726+:10C5F000000000000000000000000000000000003B
70727+:10C60000000000000000000000000000000000002A
70728+:10C61000000000000000000000000000000000001A
70729+:10C62000000000000000000000000000000000000A
70730+:10C6300000000000000000000000000000000000FA
70731+:10C6400000000000000000000000000000000000EA
70732+:10C6500000000000000000000000000000000000DA
70733+:10C6600000000000000000000000000000000000CA
70734+:10C6700000000000000000000000000000000000BA
70735+:10C6800000000000000000000000000000000000AA
70736+:10C69000000000000000000000000000000000009A
70737+:10C6A000000000000000000000000000000000008A
70738+:10C6B000000000000000000000000000000000007A
70739+:10C6C000000000000000000000000000000000006A
70740+:10C6D000000000000000000000000000000000005A
70741+:10C6E000000000000000000000000000000000004A
70742+:10C6F000000000000000000000000000000000003A
70743+:10C700000000000000000000000000000000000029
70744+:10C710000000000000000000000000000000000019
70745+:10C720000000000000000000000000000000000009
70746+:10C7300000000000000000000000000000000000F9
70747+:10C7400000000000000000000000000000000000E9
70748+:10C7500000000000000000000000000000000000D9
70749+:10C7600000000000000000000000000000000000C9
70750+:10C7700000000000000000000000000000000000B9
70751+:10C7800000000000000000000000000000000000A9
70752+:10C790000000000000000000000000000000000099
70753+:10C7A0000000000000000000000000000000000089
70754+:10C7B0000000000000000000000000000000000079
70755+:10C7C0000000000000000000000000000000000069
70756+:10C7D0000000000000000000000000000000000059
70757+:10C7E0000000000000000000000000000000000049
70758+:10C7F0000000000000000000000000000000000039
70759+:10C800000000000000000000000000000000000028
70760+:10C810000000000000000000000000000000000018
70761+:10C820000000000000000000000000000000000008
70762+:10C8300000000000000000000000000000000000F8
70763+:10C8400000000000000000000000000000000000E8
70764+:10C8500000000000000000000000000000000000D8
70765+:10C8600000000000000000000000000000000000C8
70766+:10C8700000000000000000000000000000000000B8
70767+:10C8800000000000000000000000000000000000A8
70768+:10C890000000000000000000000000000000000098
70769+:10C8A0000000000000000000000000000000000088
70770+:10C8B0000000000000000000000000000000000078
70771+:10C8C0000000000000000000000000000000000068
70772+:10C8D0000000000000000000000000000000000058
70773+:10C8E0000000000000000000000000000000000048
70774+:10C8F0000000000000000000000000000000000038
70775+:10C900000000000000000000000000000000000027
70776+:10C910000000000000000000000000000000000017
70777+:10C920000000000000000000000000000000000007
70778+:10C9300000000000000000000000000000000000F7
70779+:10C9400000000000000000000000000000000000E7
70780+:10C9500000000000000000000000000000000000D7
70781+:10C9600000000000000000000000000000000000C7
70782+:10C9700000000000000000000000000000000000B7
70783+:10C9800000000000000000000000000000000000A7
70784+:10C990000000000000000000000000000000000097
70785+:10C9A0000000000000000000000000000000000087
70786+:10C9B0000000000000000000000000000000000077
70787+:10C9C0000000000000000000000000000000000067
70788+:10C9D0000000000000000000000000000000000057
70789+:10C9E0000000000000000000000000000000000047
70790+:10C9F0000000000000000000000000000000000037
70791+:10CA00000000000000000000000000000000000026
70792+:10CA10000000000000000000000000000000000016
70793+:10CA20000000000000000000000000000000000006
70794+:10CA300000000000000000000000000000000000F6
70795+:10CA400000000000000000000000000000000000E6
70796+:10CA500000000000000000000000000000000000D6
70797+:10CA600000000000000000000000000000000000C6
70798+:10CA700000000000000000000000000000000000B6
70799+:10CA800000000000000000000000000000000000A6
70800+:10CA90000000000000000000000000000000000096
70801+:10CAA0000000000000000000000000000000000086
70802+:10CAB0000000000000000000000000000000000076
70803+:10CAC0000000000000000000000000000000000066
70804+:10CAD0000000000000000000000000000000000056
70805+:10CAE0000000000000000000000000000000000046
70806+:10CAF0000000000000000000000000000000000036
70807+:10CB00000000000000000000000000000000000025
70808+:10CB10000000000000000000000000000000000015
70809+:10CB20000000000000000000000000000000000005
70810+:10CB300000000000000000000000000000000000F5
70811+:10CB400000000000000000000000000000000000E5
70812+:10CB500000000000000000000000000000000000D5
70813+:10CB600000000000000000000000000000000000C5
70814+:10CB700000000000000000000000000000000000B5
70815+:10CB800000000000000000000000000000000000A5
70816+:10CB90000000000000000000000000000000000095
70817+:10CBA0000000000000000000000000000000000085
70818+:10CBB0000000000000000000000000000000000075
70819+:10CBC0000000000000000000000000000000000065
70820+:10CBD0000000000000000000000000000000000055
70821+:10CBE0000000000000000000000000000000000045
70822+:10CBF0000000000000000000000000000000000035
70823+:10CC00000000000000000000000000000000000024
70824+:10CC10000000000000000000000000000000000014
70825+:10CC20000000000000000000000000000000000004
70826+:10CC300000000000000000000000000000000000F4
70827+:10CC400000000000000000000000000000000000E4
70828+:10CC500000000000000000000000000000000000D4
70829+:10CC600000000000000000000000000000000000C4
70830+:10CC700000000000000000000000000000000000B4
70831+:10CC800000000000000000000000000000000000A4
70832+:10CC90000000000000000000000000000000000094
70833+:10CCA0000000000000000000000000000000000084
70834+:10CCB0000000000000000000000000000000000074
70835+:10CCC0000000000000000000000000000000000064
70836+:10CCD0000000000000000000000000000000000054
70837+:10CCE0000000000000000000000000000000000044
70838+:10CCF0000000000000000000000000000000000034
70839+:10CD00000000000000000000000000000000000023
70840+:10CD10000000000000000000000000000000000013
70841+:10CD20000000000000000000000000000000000003
70842+:10CD300000000000000000000000000000000000F3
70843+:10CD400000000000000000000000000000000000E3
70844+:10CD500000000000000000000000000000000000D3
70845+:10CD600000000000000000000000000000000000C3
70846+:10CD700000000000000000000000000000000000B3
70847+:10CD800000000000000000000000000000000000A3
70848+:10CD90000000000000000000000000000000000093
70849+:10CDA0000000000000000000000000000000000083
70850+:10CDB0000000000000000000000000000000000073
70851+:10CDC0000000000000000000000000000000000063
70852+:10CDD0000000000000000000000000000000000053
70853+:10CDE0000000000000000000000000000000000043
70854+:10CDF0000000000000000000000000000000000033
70855+:10CE00000000000000000000000000000000000022
70856+:10CE10000000000000000000000000000000000012
70857+:10CE20000000000000000000000000000000000002
70858+:10CE300000000000000000000000000000000000F2
70859+:10CE400000000000000000000000000000000000E2
70860+:10CE500000000000000000000000000000000000D2
70861+:10CE600000000000000000000000000000000000C2
70862+:10CE700000000000000000000000000000000000B2
70863+:10CE800000000000000000000000000000000000A2
70864+:10CE90000000000000000000000000000000000092
70865+:10CEA0000000000000000000000000000000000082
70866+:10CEB0000000000000000000000000000000000072
70867+:10CEC0000000000000000000000000000000000062
70868+:10CED0000000000000000000000000000000000052
70869+:10CEE0000000000000000000000000000000000042
70870+:10CEF0000000000000000000000000000000000032
70871+:10CF00000000000000000000000000000000000021
70872+:10CF10000000000000000000000000000000000011
70873+:10CF20000000000000000000000000000000000001
70874+:10CF300000000000000000000000000000000000F1
70875+:10CF400000000000000000000000000000000000E1
70876+:10CF500000000000000000000000000000000000D1
70877+:10CF600000000000000000000000000000000000C1
70878+:10CF700000000000000000000000000000000000B1
70879+:10CF800000000000000000000000000000000000A1
70880+:10CF90000000000000000000000000000000000091
70881+:10CFA0000000000000000000000000000000000081
70882+:10CFB0000000000000000000000000000000000071
70883+:10CFC0000000000000000000000000000000000061
70884+:10CFD0000000000000000000000000000000000051
70885+:10CFE0000000000000000000000000000000000041
70886+:10CFF0000000000000000000000000000000000031
70887+:10D000000000000000000000000000000000000020
70888+:10D010000000000000000000000000000000000010
70889+:10D020000000000000000000000000000000000000
70890+:10D0300000000000000000000000000000000000F0
70891+:10D0400000000000000000000000000000000000E0
70892+:10D0500000000000000000000000000000000000D0
70893+:10D0600000000000000000000000000000000000C0
70894+:10D0700000000000000000000000000000000000B0
70895+:10D0800000000000000000000000000000000000A0
70896+:10D090000000000000000000000000000000000090
70897+:10D0A0000000000000000000000000000000000080
70898+:10D0B0000000000000000000000000000000000070
70899+:10D0C0000000000000000000000000000000000060
70900+:10D0D0000000000000000000000000000000000050
70901+:10D0E0000000000000000000000000000000000040
70902+:10D0F0000000000000000000000000000000000030
70903+:10D10000000000000000000000000000000000001F
70904+:10D11000000000000000000000000000000000000F
70905+:10D1200000000000000000000000000000000000FF
70906+:10D1300000000000000000000000000000000000EF
70907+:10D1400000000000000000000000000000000000DF
70908+:10D1500000000000000000000000000000000000CF
70909+:10D1600000000000000000000000000000000000BF
70910+:10D1700000000000000000000000000000000000AF
70911+:10D18000000000000000000000000000000000009F
70912+:10D19000000000000000000000000000000000008F
70913+:10D1A000000000000000000000000000000000007F
70914+:10D1B000000000000000000000000000000000006F
70915+:10D1C000000000000000000000000000000000005F
70916+:10D1D000000000000000000000000000000000004F
70917+:10D1E000000000000000000000000000000000003F
70918+:10D1F000000000000000000000000000000000002F
70919+:10D20000000000000000000000000000000000001E
70920+:10D21000000000000000000000000000000000000E
70921+:10D2200000000000000000000000000000000000FE
70922+:10D2300000000000000000000000000000000000EE
70923+:10D2400000000000000000000000000000000000DE
70924+:10D2500000000000000000000000000000000000CE
70925+:10D2600000000000000000000000000000000000BE
70926+:10D2700000000000000000000000000000000000AE
70927+:10D28000000000000000000000000000000000009E
70928+:10D29000000000000000000000000000000000008E
70929+:10D2A000000000000000000000000000000000007E
70930+:10D2B000000000000000000000000000000000006E
70931+:10D2C000000000000000000000000000000000005E
70932+:10D2D000000000000000000000000000000000004E
70933+:10D2E000000000000000000000000000000000003E
70934+:10D2F000000000000000000000000000000000002E
70935+:10D30000000000000000000000000000000000001D
70936+:10D31000000000000000000000000000000000000D
70937+:10D3200000000000000000000000000000000000FD
70938+:10D3300000000000000000000000000000000000ED
70939+:10D3400000000000000000000000000000000000DD
70940+:10D3500000000000000000000000000000000000CD
70941+:10D3600000000000000000000000000000000000BD
70942+:10D3700000000000000000000000000000000000AD
70943+:10D38000000000000000000000000000000000009D
70944+:10D39000000000000000000000000000000000008D
70945+:10D3A000000000000000000000000000000000007D
70946+:10D3B000000000000000000000000000000000006D
70947+:10D3C000000000000000000000000000000000005D
70948+:10D3D000000000000000000000000000000000004D
70949+:10D3E000000000000000000000000000000000003D
70950+:10D3F000000000000000000000000000000000002D
70951+:10D40000000000000000000000000000000000001C
70952+:10D41000000000000000000000000000000000000C
70953+:10D4200000000000000000000000000000000000FC
70954+:10D4300000000000000000000000000000000000EC
70955+:10D4400000000000000000000000000000000000DC
70956+:10D4500000000000000000000000000000000000CC
70957+:10D4600000000000000000000000000000000000BC
70958+:10D4700000000000000000000000000000000000AC
70959+:10D48000000000000000000000000000000000009C
70960+:10D49000000000000000000000000000000000008C
70961+:10D4A000000000000000000000000000000000007C
70962+:10D4B000000000000000000000000000000000006C
70963+:10D4C000000000000000000000000000000000005C
70964+:10D4D000000000000000000000000000000000004C
70965+:10D4E000000000000000000000000000000000003C
70966+:10D4F000000000000000000000000000000000002C
70967+:10D50000000000000000000000000000000000001B
70968+:10D51000000000000000000000000000000000000B
70969+:10D5200000000000000000000000000000000000FB
70970+:10D5300000000000000000000000000000000000EB
70971+:10D5400000000000000000000000000000000000DB
70972+:10D5500000000000000000000000000000000000CB
70973+:10D5600000000000000000000000000000000000BB
70974+:10D5700000000000000000000000000000000000AB
70975+:10D58000000000000000000000000000000000009B
70976+:10D59000000000000000000000000000000000008B
70977+:10D5A000000000000000000000000000000000007B
70978+:10D5B000000000000000000000000000000000006B
70979+:10D5C000000000000000000000000000000000005B
70980+:10D5D000000000000000000000000000000000004B
70981+:10D5E000000000000000000000000000000000003B
70982+:10D5F000000000000000000000000000000000002B
70983+:10D60000000000000000000000000000000000001A
70984+:10D61000000000000000000000000000000000000A
70985+:10D6200000000000000000000000000000000000FA
70986+:10D6300000000000000000000000000000000000EA
70987+:10D6400000000000000000000000000000000000DA
70988+:10D6500000000000000000000000000000000000CA
70989+:10D6600000000000000000000000000000000000BA
70990+:10D6700000000000000000000000000000000000AA
70991+:10D68000000000000000000000000000000000009A
70992+:10D69000000000000000000000000000000000008A
70993+:10D6A000000000000000000000000000000000007A
70994+:10D6B000000000000000000000000000000000006A
70995+:10D6C000000000000000000000000000000000005A
70996+:10D6D000000000000000000000000000000000004A
70997+:10D6E000000000000000000000000000000000003A
70998+:10D6F000000000000000000000000000000000002A
70999+:10D700000000000000000000000000000000000019
71000+:10D710000000000000000000000000000000000009
71001+:10D7200000000000000000000000000000000000F9
71002+:10D7300000000000000000000000000000000000E9
71003+:10D7400000000000000000000000000000000000D9
71004+:10D7500000000000000000000000000000000000C9
71005+:10D7600000000000000000000000000000000000B9
71006+:10D7700000000000000000000000000000000000A9
71007+:10D780000000000000000000000000000000000099
71008+:10D790000000000000000000000000000000000089
71009+:10D7A0000000000000000000000000000000000079
71010+:10D7B0000000000000000000000000000000000069
71011+:10D7C0000000000000000000000000000000000059
71012+:10D7D0000000000000000000000000000000000049
71013+:10D7E0000000000000000000000000000000000039
71014+:10D7F0000000000000000000000000000000000029
71015+:10D800000000000000000000000000000000000018
71016+:10D810000000000000000000000000000000000008
71017+:10D8200000000000000000000000000000000000F8
71018+:10D8300000000000000000000000000000000000E8
71019+:10D8400000000000000000000000000000000000D8
71020+:10D8500000000000000000000000000000000000C8
71021+:10D8600000000000000000000000000000000000B8
71022+:10D8700000000000000000000000000000000000A8
71023+:10D880000000000000000000000000000000000098
71024+:10D890000000000000000000000000000000000088
71025+:10D8A0000000000000000000000000000000000078
71026+:10D8B0000000000000000000000000000000000068
71027+:10D8C0000000000000000000000000000000000058
71028+:10D8D0000000000000000000000000000000000048
71029+:10D8E0000000000000000000000000000000000038
71030+:10D8F0000000000000000000000000000000000028
71031+:10D900000000000000000000000000000000000017
71032+:10D910000000000000000000000000000000000007
71033+:10D9200000000000000000000000000000000000F7
71034+:10D9300000000000000000000000000000000000E7
71035+:10D9400000000000000000000000000000000000D7
71036+:10D9500000000000000000000000000000000000C7
71037+:10D9600000000000000000000000000000000000B7
71038+:10D9700000000000000000000000000000000000A7
71039+:10D980000000000000000000000000000000000097
71040+:10D990000000000000000000000000000000000087
71041+:10D9A0000000000000000000000000000000000077
71042+:10D9B0000000000000000000000000000000000067
71043+:10D9C0000000000000000000000000000000000057
71044+:10D9D0000000000000000000000000000000000047
71045+:10D9E0000000000000000000000000000000000037
71046+:10D9F0000000000000000000000000000000000027
71047+:10DA00000000000000000000000000000000000016
71048+:10DA10000000000000000000000000000000000006
71049+:10DA200000000000000000000000000000000000F6
71050+:10DA300000000000000000000000000000000000E6
71051+:10DA400000000000000000000000000000000000D6
71052+:10DA500000000000000000000000000000000000C6
71053+:10DA600000000000000000000000000000000000B6
71054+:10DA700000000000000000000000000000000000A6
71055+:10DA80000000000000000000000000000000000096
71056+:10DA90000000000000000000000000000000000086
71057+:10DAA0000000000000000000000000000000000076
71058+:10DAB0000000000000000000000000000000000066
71059+:10DAC0000000000000000000000000000000000056
71060+:10DAD0000000000000000000000000000000000046
71061+:10DAE0000000000000000000000000000000000036
71062+:10DAF0000000000000000000000000000000000026
71063+:10DB00000000000000000000000000000000000015
71064+:10DB10000000000000000000000000000000000005
71065+:10DB200000000000000000000000000000000000F5
71066+:10DB300000000000000000000000000000000000E5
71067+:10DB400000000000000000000000000000000000D5
71068+:10DB500000000000000000000000000000000000C5
71069+:10DB600000000000000000000000000000000000B5
71070+:10DB700000000000000000000000000000000000A5
71071+:10DB80000000000000000000000000000000000095
71072+:10DB90000000000000000000000000000000000085
71073+:10DBA0000000000000000000000000000000000075
71074+:10DBB0000000000000000000000000000000000065
71075+:10DBC0000000000000000000000000000000000055
71076+:10DBD0000000000000000000000000000000000045
71077+:10DBE0000000000000000000000000000000000035
71078+:10DBF0000000000000000000000000000000000025
71079+:10DC00000000000000000000000000000000000014
71080+:10DC10000000000000000000000000000000000004
71081+:10DC200000000000000000000000000000000000F4
71082+:10DC300000000000000000000000000000000000E4
71083+:10DC400000000000000000000000000000000000D4
71084+:10DC500000000000000000000000000000000000C4
71085+:10DC600000000000000000000000000000000000B4
71086+:10DC700000000000000000000000000000000000A4
71087+:10DC80000000000000000000000000000000000094
71088+:10DC90000000000000000000000000000000000084
71089+:10DCA0000000000000000000000000000000000074
71090+:10DCB0000000000000000000000000000000000064
71091+:10DCC0000000000000000000000000000000000054
71092+:10DCD0000000000000000000000000000000000044
71093+:10DCE0000000000000000000000000000000000034
71094+:10DCF0000000000000000000000000000000000024
71095+:10DD00000000000000000000000000000000000013
71096+:10DD10000000000000000000000000000000000003
71097+:10DD200000000000000000000000000000000000F3
71098+:10DD300000000000000000000000000000000000E3
71099+:10DD400000000000000000000000000000000000D3
71100+:10DD500000000000000000000000000000000000C3
71101+:10DD600000000000000000000000000000000000B3
71102+:10DD700000000000000000000000000000000000A3
71103+:10DD80000000000000000000000000000000000093
71104+:10DD90000000000000000000000000000000000083
71105+:10DDA0000000000000000000000000000000000073
71106+:10DDB0000000000000000000000000000000000063
71107+:10DDC0000000000000000000000000000000000053
71108+:10DDD0000000000000000000000000000000000043
71109+:10DDE0000000000000000000000000000000000033
71110+:10DDF0000000000000000000000000000000000023
71111+:10DE00000000000000000000000000000000000012
71112+:10DE10000000000000000000000000000000000002
71113+:10DE200000000000000000000000000000000000F2
71114+:10DE300000000000000000000000000000000000E2
71115+:10DE400000000000000000000000000000000000D2
71116+:10DE500000000000000000000000000000000000C2
71117+:10DE600000000000000000000000000000000000B2
71118+:10DE700000000000000000000000000000000000A2
71119+:10DE80000000000000000000000000000000000092
71120+:10DE90000000000000000000000000000000000082
71121+:10DEA0000000000000000000000000000000000072
71122+:10DEB0000000000000000000000000000000000062
71123+:10DEC0000000000000000000000000000000000052
71124+:10DED0000000000000000000000000000000000042
71125+:10DEE0000000000000000000000000000000000032
71126+:10DEF0000000000000000000000000000000000022
71127+:10DF00000000000000000000000000000000000011
71128+:10DF10000000000000000000000000000000000001
71129+:10DF200000000000000000000000000000000000F1
71130+:10DF300000000000000000000000000000000000E1
71131+:10DF400000000000000000000000000000000000D1
71132+:10DF500000000000000000000000000000000000C1
71133+:10DF600000000000000000000000000000000000B1
71134+:10DF700000000000000000000000000000000000A1
71135+:10DF80000000000000000000000000000000000091
71136+:10DF90000000000000000000000000000000000081
71137+:10DFA0000000000000000000000000000000000071
71138+:10DFB0000000000000000000000000000000000061
71139+:10DFC0000000000000000000000000000000000051
71140+:10DFD0000000000000000000000000000000000041
71141+:10DFE0000000000000000000000000000000000031
71142+:10DFF0000000000000000000000000000000000021
71143+:10E000000000000000000000000000000000000010
71144+:10E010000000000000000000000000000000000000
71145+:10E0200000000000000000000000000000000000F0
71146+:10E0300000000000000000000000000000000000E0
71147+:10E0400000000000000000000000000000000000D0
71148+:10E0500000000000000000000000000000000000C0
71149+:10E0600000000000000000000000000000000000B0
71150+:10E0700000000000000000000000000000000000A0
71151+:10E080000000000000000000000000000000000090
71152+:10E090000000000000000000000000000000000080
71153+:10E0A0000000000000000000000000000000000070
71154+:10E0B0000000000000000000000000000000000060
71155+:10E0C0000000000000000000000000000000000050
71156+:10E0D0000000000000000000000000000000000040
71157+:10E0E0000000000000000000000000000000000030
71158+:10E0F0000000000000000000000000000000000020
71159+:10E10000000000000000000000000000000000000F
71160+:10E1100000000000000000000000000000000000FF
71161+:10E1200000000000000000000000000000000000EF
71162+:10E1300000000000000000000000000000000000DF
71163+:10E1400000000000000000000000000000000000CF
71164+:10E1500000000000000000000000000000000000BF
71165+:10E1600000000000000000000000000000000000AF
71166+:10E17000000000000000000000000000000000009F
71167+:10E18000000000000000000000000000000000008F
71168+:10E19000000000000000000000000000000000007F
71169+:10E1A000000000000000000000000000000000006F
71170+:10E1B000000000000000000000000000000000005F
71171+:10E1C000000000000000000000000000000000004F
71172+:10E1D000000000000000000000000000000000003F
71173+:10E1E000000000000000000000000000000000002F
71174+:10E1F000000000000000000000000000000000809F
71175+:10E20000000000000000000000000000000000000E
71176+:10E2100000000000000000000000000000000000FE
71177+:10E220000000000A000000000000000000000000E4
71178+:10E2300010000003000000000000000D0000000DB1
71179+:10E240003C020801244295C03C030801246397FC6A
71180+:10E25000AC4000000043202B1480FFFD244200044A
71181+:10E260003C1D080037BD9FFC03A0F0213C100800B6
71182+:10E27000261032103C1C0801279C95C00E0012BECF
71183+:10E28000000000000000000D3C02800030A5FFFFF0
71184+:10E2900030C600FF344301803C0880008D0901B87E
71185+:10E2A0000520FFFE00000000AC6400002404000212
71186+:10E2B000A4650008A066000AA064000BAC67001803
71187+:10E2C0003C03100003E00008AD0301B83C0560000A
71188+:10E2D0008CA24FF80440FFFE00000000ACA44FC029
71189+:10E2E0003C0310003C040200ACA44FC403E000084F
71190+:10E2F000ACA34FF89486000C00A050212488001491
71191+:10E3000000062B0200051080004448210109182B4B
71192+:10E310001060001100000000910300002C6400094F
71193+:10E320005080000991190001000360803C0D080134
71194+:10E3300025AD9258018D58218D67000000E000083E
71195+:10E340000000000091190001011940210109302B42
71196+:10E3500054C0FFF29103000003E000080000102108
71197+:10E360000A000CCC25080001910F0001240E000AC0
71198+:10E3700015EE00400128C8232F38000A1700003D81
71199+:10E38000250D00028D580000250F0006370E0100F4
71200+:10E39000AD4E0000910C000291AB000191A400026F
71201+:10E3A00091A60003000C2E00000B3C0000A71025D6
71202+:10E3B00000041A000043C8250326C025AD580004F8
71203+:10E3C000910E000691ED000191E7000291E5000336
71204+:10E3D000000E5E00000D6400016C30250007220075
71205+:10E3E00000C41025004518252508000A0A000CCC99
71206+:10E3F000AD430008910F000125040002240800022B
71207+:10E4000055E80001012020210A000CCC00804021A9
71208+:10E41000910C0001240B0003158B00160000000076
71209+:10E420008D580000910E000225080003370D0008EA
71210+:10E43000A14E00100A000CCCAD4D00009119000156
71211+:10E44000240F0004172F000B0000000091070002AA
71212+:10E45000910400038D43000000072A0000A410254A
71213+:10E460003466000425080004AD42000C0A000CCC00
71214+:10E47000AD46000003E000082402000127BDFFE8CC
71215+:10E48000AFBF0014AFB000100E00164E0080802108
71216+:10E490003C0480083485008090A600052403FFFE1C
71217+:10E4A0000200202100C310248FBF00148FB0001081
71218+:10E4B000A0A200050A00165827BD001827BDFFE8D6
71219+:10E4C000AFB00010AFBF00140E000FD40080802149
71220+:10E4D0003C06800834C5008090A40000240200504F
71221+:10E4E000308300FF106200073C09800002002021F9
71222+:10E4F0008FBF00148FB00010AD2001800A00108F74
71223+:10E5000027BD0018240801003C07800002002021DC
71224+:10E510008FBF00148FB00010ACE801800A00108F8C
71225+:10E5200027BD001827BDFF783C058008AFBE0080DE
71226+:10E53000AFB7007CAFB3006CAFB10064AFBF008475
71227+:10E54000AFB60078AFB50074AFB40070AFB200687A
71228+:10E55000AFB0006034A600803C0580008CB201287A
71229+:10E5600090C400098CA701043C020001309100FF17
71230+:10E5700000E218240000B8210000F021106000071C
71231+:10E58000000098213C0908008D2931F02413000176
71232+:10E59000252800013C010800AC2831F0ACA0008423
71233+:10E5A00090CC0005000C5827316A0001154000721C
71234+:10E5B000AFA0005090CD00002406002031A400FF41
71235+:10E5C00010860018240E0050108E009300000000EA
71236+:10E5D0003C1008008E1000DC260F00013C010800F2
71237+:10E5E000AC2F00DC0E0016C7000000000040182110
71238+:10E5F0008FBF00848FBE00808FB7007C8FB60078FD
71239+:10E600008FB500748FB400708FB3006C8FB2006848
71240+:10E610008FB100648FB000600060102103E000083B
71241+:10E6200027BD00880000000D3C1F8000AFA0003017
71242+:10E6300097E501168FE201043C04002030B9FFFF8A
71243+:10E64000004438240007182B00033140AFA60030E7
71244+:10E650008FF5010437F80C003C1600400338802188
71245+:10E6600002B6A02434C40040128000479215000D69
71246+:10E6700032A800201500000234860080008030217E
71247+:10E6800014C0009FAFA600303C0D800835A6008066
71248+:10E6900090CC0008318B0040516000063C06800899
71249+:10E6A000240E0004122E00A8240F0012122F003294
71250+:10E6B0003C06800834C401003C0280009447011AE3
71251+:10E6C0009619000E909F00088E18000830E3FFFF97
71252+:10E6D00003F9B00432B40004AFB6005CAFA3005835
71253+:10E6E0008E1600041280002EAFB8005434C3008090
71254+:10E6F000906800083105004014A0002500000000CB
71255+:10E700008C70005002D090230640000500000000ED
71256+:10E710008C71003402D1A82306A201678EE20008A2
71257+:10E72000126000063C1280003C1508008EB531F4E2
71258+:10E7300026B600013C010800AC3631F4AE4000447E
71259+:10E74000240300018FBF00848FBE00808FB7007C40
71260+:10E750008FB600788FB500748FB400708FB3006CE3
71261+:10E760008FB200688FB100648FB00060006010212C
71262+:10E7700003E0000827BD00880E000D2800002021BE
71263+:10E780000A000D75004018210A000D9500C02021D7
71264+:10E790000E00171702C020211440FFE10000000006
71265+:10E7A0003C0B8008356400808C8A003402CA482300
71266+:10E7B0000520001D000000003C1E08008FDE310017
71267+:10E7C00027D700013C010800AC3731001260000679
71268+:10E7D000024020213C1408008E9431F42690000160
71269+:10E7E0003C010800AC3031F40E00164E3C1E80088F
71270+:10E7F00037CD008091B700250240202136EE00047D
71271+:10E800000E001658A1AE00250E000CAC02402021CF
71272+:10E810000A000DCA240300013C17080126F796C020
71273+:10E820000A000D843C1F80008C86003002C66023E5
71274+:10E830001980000C2419000C908F004F3C14080024
71275+:10E840008E94310032B500FC35ED0001268E0001BA
71276+:10E850003C010800AC2E3100A08D004FAFA0005845
71277+:10E860002419000CAFB900308C9800300316A02397
71278+:10E870001A80010B8FA300580074F82A17E0FFD309
71279+:10E88000000000001074002A8FA5005802D4B021A7
71280+:10E8900000B410233044FFFFAFA4005832A8000298
71281+:10E8A0001100002E32AB00103C15800836B00080FD
71282+:10E8B0009216000832D30040526000FB8EE200083E
71283+:10E8C0000E00164E02402021240A0018A20A000958
71284+:10E8D000921100052409FFFE024020210229902404
71285+:10E8E0000E001658A2120005240400390000282149
71286+:10E8F0000E0016F2240600180A000DCA24030001B7
71287+:10E9000092FE000C3C0A800835490080001EBB00C6
71288+:10E910008D27003836F10081024020213225F08118
71289+:10E920000E000C9B30C600FF0A000DC10000000065
71290+:10E930003AA7000130E300011460FFA402D4B02123
71291+:10E940000A000E1D00000000024020210E001734B6
71292+:10E95000020028210A000D75004018211160FF7087
71293+:10E960003C0F80083C0D800835EE00808DC40038D7
71294+:10E970008FA300548DA60004006660231D80FF68ED
71295+:10E98000000000000064C02307020001AFA400548F
71296+:10E990003C1F08008FFF31E433F9000113200015FC
71297+:10E9A0008FAC00583C07800094E3011A10600012FD
71298+:10E9B0003C0680080E00216A024020213C03080129
71299+:10E9C000906396F13064000214800145000000005D
71300+:10E9D000306C0004118000078FAC0058306600FBDB
71301+:10E9E0003C010801A02696F132B500FCAFA000580A
71302+:10E9F0008FAC00583C06800834D30080AFB40018B8
71303+:10EA0000AFB60010AFAC00143C088000950B01209D
71304+:10EA10008E6F0030966A005C8FA3005C8FBF003061
71305+:10EA20003169FFFF3144FFFF8FAE005401341021E4
71306+:10EA3000350540000064382B0045C82103E7C02598
71307+:10EA4000AFB90020AFAF0028AFB80030AFAF00249F
71308+:10EA5000AFA0002CAFAE0034926D000831B40008B6
71309+:10EA6000168000BB020020218EE200040040F8095D
71310+:10EA700027A400108FAF003031F300025660000170
71311+:10EA800032B500FE3C048008349F008093F90008F2
71312+:10EA900033380040530000138FA400248C850004F9
71313+:10EAA0008FA7005410A700D52404001432B0000131
71314+:10EAB0001200000C8FA400242414000C1234011A3C
71315+:10EAC0002A2D000D11A001022413000E240E000AAD
71316+:10EAD000522E0001241E00088FAF002425E40001FF
71317+:10EAE000AFA400248FAA00143C0B80083565008079
71318+:10EAF000008A48218CB10030ACA9003090A4004EAF
71319+:10EB00008CA700303408FFFF0088180400E3F821C8
71320+:10EB1000ACBF00348FA600308FB900548FB8005CB2
71321+:10EB200030C200081040000B033898218CAC002044
71322+:10EB3000119300D330C600FF92EE000C8FA7003473
71323+:10EB400002402021000E6B0035B400800E000C9BAB
71324+:10EB50003285F0803C028008345000808E0F0030F7
71325+:10EB600001F1302318C00097264800803C070800B8
71326+:10EB70008CE731E42404FF80010418243118007F5D
71327+:10EB80003C1F80003C19800430F10001AFE300908D
71328+:10EB900012200006031928213C030801906396F116
71329+:10EBA00030690008152000C6306A00F73C10800864
71330+:10EBB00036040080908C004F318B000115600042BC
71331+:10EBC000000000003C0608008CC6319830CE0010D2
71332+:10EBD00051C0004230F9000190AF006B55E0003F9A
71333+:10EBE00030F9000124180001A0B8006B3C1180002E
71334+:10EBF0009622007A24470064A48700123C0D800806
71335+:10EC000035A5008090B40008329000401600000442
71336+:10EC10003C03800832AE000115C0008B00000000EC
71337+:10EC2000346400808C86002010D3000A3463010015
71338+:10EC30008C67000002C7782319E000978FBF00544B
71339+:10EC4000AC93002024130001AC760000AFB3005059
71340+:10EC5000AC7F000417C0004E000000008FA90050D8
71341+:10EC60001520000B000000003C030801906396F1A2
71342+:10EC7000306A00011140002E8FAB0058306400FE56
71343+:10EC80003C010801A02496F10A000D75000018212E
71344+:10EC90000E000CAC024020210A000F1300000000FF
71345+:10ECA0000A000E200000A0210040F80924040017EB
71346+:10ECB0000A000DCA240300010040F80924040016CC
71347+:10ECC0000A000DCA240300019094004F240DFFFE9A
71348+:10ECD000028D2824A085004F30F900011320000682
71349+:10ECE0003C0480083C030801906396F1307F0010DB
71350+:10ECF00017E00051306800EF34900080240A0001D2
71351+:10ED0000024020210E00164EA60A00129203002592
71352+:10ED100024090001AFA90050346200010240202103
71353+:10ED20000E001658A20200250A000EF93C0D8008BC
71354+:10ED30001160FE83000018218FA5003030AC000464
71355+:10ED40001180FE2C8FBF00840A000DCB240300012C
71356+:10ED500027A500380E000CB6AFA000385440FF4382
71357+:10ED60008EE200048FB40038329001005200FF3F61
71358+:10ED70008EE200048FA3003C8E6E0058006E682364
71359+:10ED800005A3FF39AE6300580A000E948EE200041A
71360+:10ED90000E00164E024020213C038008346800809B
71361+:10EDA000024020210E001658A11E000903C0302188
71362+:10EDB000240400370E0016F2000028210A000F116B
71363+:10EDC0008FA900508FAB00185960FF8D3C0D800853
71364+:10EDD0000E00164E02402021920C00252405000151
71365+:10EDE000AFA5005035820004024020210E001658C5
71366+:10EDF000A20200250A000EF93C0D800812240059D9
71367+:10EE00002A2300151060004D240900162408000C68
71368+:10EE10005628FF2732B000013C0A8008914C001BA5
71369+:10EE20002406FFBD241E000E01865824A14B001BA2
71370+:10EE30000A000EA532B000013C010801A02896F19D
71371+:10EE40000A000EF93C0D80088CB500308EFE0008DB
71372+:10EE50002404001826B6000103C0F809ACB600303F
71373+:10EE60003C030801906396F13077000116E0FF81C2
71374+:10EE7000306A00018FB200300A000D753243000481
71375+:10EE80003C1080009605011A50A0FF2B34C60010DC
71376+:10EE90000A000EC892EE000C8C6200001456FF6D42
71377+:10EEA000000000008C7800048FB9005403388823D8
71378+:10EEB0000621FF638FBF00540A000F0E0000000000
71379+:10EEC0003C010801A02A96F10A000F3030F9000138
71380+:10EED0001633FF028FAF00240A000EB0241E00106C
71381+:10EEE0000E00164E024020213C0B80083568008041
71382+:10EEF00091090025240A0001AFAA0050353300040F
71383+:10EF0000024020210E001658A11300253C050801DF
71384+:10EF100090A596F130A200FD3C010801A02296F1D7
71385+:10EF20000A000E6D004018212411000E53D1FEEA94
71386+:10EF3000241E00100A000EAF241E00165629FEDC07
71387+:10EF400032B000013C0A8008914C001B2406FFBD32
71388+:10EF5000241E001001865824A14B001B0A000EA598
71389+:10EF600032B000010A000EA4241E00123C038000EF
71390+:10EF70008C6201B80440FFFE24040800AC6401B8B0
71391+:10EF800003E000080000000030A5FFFF30C6FFFFCF
71392+:10EF90003C0780008CE201B80440FFFE34EA0180A7
71393+:10EFA000AD440000ACE400203C0480089483004899
71394+:10EFB0003068FFFF11000016AF88000824AB001274
71395+:10EFC000010B482B512000133C04800034EF01005A
71396+:10EFD00095EE00208F890000240D001A31CCFFFF30
71397+:10EFE00031274000A14D000B10E000362583FFFEC5
71398+:10EFF0000103C02B170000348F9900048F88000490
71399+:10F00000A5430014350700010A001003AF87000470
71400+:10F010003C04800024030003348201808F890000B7
71401+:10F020008F870004A043000B3C088000350C018052
71402+:10F03000A585000EA585001A8F85000C30EB800099
71403+:10F04000A5890010AD850028A58600081160000F75
71404+:10F050008F85001435190100972A00163158FFFCDE
71405+:10F06000270F000401E870218DCD400031A6FFFF7D
71406+:10F0700014C000072403BFFF3C02FFFF34487FFF9A
71407+:10F0800000E83824AF8700048F8500142403BFFFF5
71408+:10F090003C04800000E3582434830180A46B0026E4
71409+:10F0A000AC69002C10A0000300054C02A465001000
71410+:10F0B000A46900263C071000AC8701B803E00008F3
71411+:10F0C000000000008F990004240AFFFE032A382460
71412+:10F0D0000A001003AF87000427BDFFE88FA20028B5
71413+:10F0E00030A5FFFF30C6FFFFAFBF0010AF87000C99
71414+:10F0F000AF820014AF8000040E000FDBAF80000071
71415+:10F100008FBF001027BD001803E00008AF80001477
71416+:10F110003C06800034C4007034C701008C8A0000B3
71417+:10F1200090E500128F84000027BDFFF030A300FFA0
71418+:10F13000000318823082400010400037246500032D
71419+:10F140000005C8800326C0218F0E4000246F0004F4
71420+:10F15000000F6880AFAE000001A660218D8B4000DB
71421+:10F16000AFAB000494E900163128FFFC01063821FA
71422+:10F170008CE64000AFA600088FA9000800003021EF
71423+:10F18000000028213C07080024E701000A0010675E
71424+:10F19000240800089059000024A500012CAC000CA4
71425+:10F1A0000079C0210018788001E770218DCD000022
71426+:10F1B0001180000600CD302603A5102114A8FFF50C
71427+:10F1C00000051A005520FFF4905900003C0480000F
71428+:10F1D000348700703C0508008CA531048CE30000E6
71429+:10F1E0002CA2002010400009006A38230005488046
71430+:10F1F0003C0B0800256B3108012B402124AA00019B
71431+:10F20000AD0700003C010800AC2A310400C0102109
71432+:10F2100003E0000827BD0010308220001040000BE2
71433+:10F2200000055880016648218D24400024680004B0
71434+:10F2300000083880AFA4000000E618218C6540006B
71435+:10F24000AFA000080A001057AFA500040000000D91
71436+:10F250000A0010588FA9000827BDFFE03C07800076
71437+:10F2600034E60100AFBF001CAFB20018AFB100140C
71438+:10F27000AFB0001094C5000E8F87000030A4FFFFD0
71439+:10F280002483000430E2400010400010AF830028C7
71440+:10F290003C09002000E940241100000D30EC800002
71441+:10F2A0008F8A0004240BBFFF00EB38243543100085
71442+:10F2B000AF87000030F220001640000B3C1900041C
71443+:10F2C000241FFFBF0A0010B7007F102430EC80001D
71444+:10F2D000158000423C0E002030F220001240FFF862
71445+:10F2E0008F8300043C19000400F9C0241300FFF5CB
71446+:10F2F000241FFFBF34620040AF82000430E20100EF
71447+:10F300001040001130F010008F83002C10600006B8
71448+:10F310003C0F80003C05002000E52024148000C044
71449+:10F320003C0800043C0F800035EE010095CD001E26
71450+:10F3300095CC001C31AAFFFF000C5C00014B482556
71451+:10F34000AF89000C30F010001200000824110001F9
71452+:10F3500030F100201620008B3C18100000F890249B
71453+:10F36000164000823C040C002411000130E801002A
71454+:10F370001500000B3C0900018F85000430A94000F6
71455+:10F38000152000073C0900013C0C1F0100EC58242B
71456+:10F390003C0A1000116A01183C1080003C09000171
71457+:10F3A00000E9302410C000173C0B10003C18080086
71458+:10F3B0008F1800243307000214E0014024030001E9
71459+:10F3C0008FBF001C8FB200188FB100148FB00010D7
71460+:10F3D0000060102103E0000827BD002000EE682433
71461+:10F3E00011A0FFBE30F220008F8F00043C11FFFF00
71462+:10F3F00036307FFF00F0382435E380000A0010A685
71463+:10F40000AF87000000EB102450400065AF8000245F
71464+:10F410008F8C002C3C0D0F0000ED18241580008807
71465+:10F42000AF83001030E8010011000086938F0010B8
71466+:10F430003C0A0200106A00833C1280003650010032
71467+:10F44000920500139789002A3626000230AF00FF8C
71468+:10F4500025EE0004000E19C03C0480008C9801B811
71469+:10F460000700FFFE34880180AD0300003C198008CE
71470+:10F47000AC830020973100483225FFFF10A0015CCB
71471+:10F48000AF8500082523001200A3F82B53E0015993
71472+:10F490008F850004348D010095AC00202402001AF1
71473+:10F4A00030E44000318BFFFFA102000B108001927D
71474+:10F4B0002563FFFE00A3502B154001908F8F0004A1
71475+:10F4C000A50300148F88000435050001AF850004F2
71476+:10F4D0003C08800035190180A729000EA729001AD1
71477+:10F4E0008F89000C30B18000A7270010AF290028B9
71478+:10F4F000A72600081220000E3C04800035020100FF
71479+:10F50000944C0016318BFFFC256400040088182100
71480+:10F510008C7F400033E6FFFF14C000053C048000F0
71481+:10F520003C0AFFFF354D7FFF00AD2824AF85000466
71482+:10F53000240EBFFF00AE402434850180A4A800261D
71483+:10F54000ACA7002C3C071000AC8701B800001821C4
71484+:10F550008FBF001C8FB200188FB100148FB0001045
71485+:10F560000060102103E0000827BD00203C020BFFD3
71486+:10F5700000E41824345FFFFF03E3C82B5320FF7B14
71487+:10F58000241100013C0608008CC6002C24C5000193
71488+:10F590003C010800AC25002C0A0010D42411000501
71489+:10F5A0008F85002410A0002FAF80001090A30000D2
71490+:10F5B000146000792419000310A0002A30E601002D
71491+:10F5C00010C000CC8F860010241F000210DF00C97D
71492+:10F5D0008F8B000C3C0708008CE7003824E4FFFF09
71493+:10F5E00014E0000201641824000018213C0D0800FA
71494+:10F5F00025AD0038006D1021904C00048F85002847
71495+:10F6000025830004000321C030A5FFFF3626000239
71496+:10F610000E000FDB000000000A00114D0000182151
71497+:10F6200000E8302414C0FF403C0F80000E00103D65
71498+:10F63000000000008F8700000A0010CAAF82000C93
71499+:10F64000938F00103C18080127189640000F90C0B7
71500+:10F6500002588021AF9000248F85002414A0FFD38E
71501+:10F66000AF8F00103C0480008C86400030C5010044
71502+:10F6700010A000BC322300043C0C08008D8C002438
71503+:10F6800024120004106000C23190000D3C04800080
71504+:10F690008C8D40003402FFFF11A201003231FFFBCC
71505+:10F6A0008C884000310A01005540000124110010EF
71506+:10F6B00030EE080011C000BE2419FFFB8F9800280F
71507+:10F6C0002F0F03EF51E000010219802430E90100FF
71508+:10F6D00011200014320800018F87002C14E000FB79
71509+:10F6E0008F8C000C3C05800034AB0100917F00132F
71510+:10F6F00033E300FF246A00042403FFFE0203802496
71511+:10F70000000A21C012000002023230253226FFFF1B
71512+:10F710000E000FDB9785002A1200FF290000182138
71513+:10F72000320800011100000D32180004240E0001FF
71514+:10F73000120E0002023230253226FFFF9785002A82
71515+:10F740000E000FDB00002021240FFFFE020F80249B
71516+:10F750001200FF1B00001821321800045300FF188C
71517+:10F760002403000102323025241200045612000145
71518+:10F770003226FFFF9785002A0E000FDB24040100CC
71519+:10F780002419FFFB021988241220FF0D0000182104
71520+:10F790000A0010E9240300011079009C00003021C8
71521+:10F7A00090AD00012402000211A200BE30EA004028
71522+:10F7B00090B90001241800011338007F30E900409F
71523+:10F7C0008CA600049785002A00C020210E000FDBC4
71524+:10F7D0003626000200004021010018218FBF001CC6
71525+:10F7E0008FB200188FB100148FB00010006010218C
71526+:10F7F00003E0000827BD0020360F010095EE000C45
71527+:10F8000031CD020015A0FEE63C0900013C1880083D
71528+:10F81000971200489789002A362600023248FFFFD7
71529+:10F82000AF8800083C0380008C7101B80620FFFE01
71530+:10F83000346A0180AD4000001100008E3C0F800052
71531+:10F84000253F0012011FC82B1320008B240E00033C
71532+:10F85000346C0100958B00202402001A30E4400033
71533+:10F860003163FFFFA142000B108000A72463FFFE5D
71534+:10F870000103682B15A000A52408FFFE34A5000194
71535+:10F88000A5430014AF8500043C0480002412BFFF90
71536+:10F8900000B2802434850180A4A9000EA4A9001A16
71537+:10F8A000A4A60008A4B00026A4A700103C071000DE
71538+:10F8B000AC8701B80A00114D000018213C038000FC
71539+:10F8C00034640100949F000E3C1908008F3900D861
71540+:10F8D0002404008033E5FFFF273100013C010800CC
71541+:10F8E000AC3100D80E000FDB240600030A00114DD6
71542+:10F8F00000001821240A000210CA00598F85002830
71543+:10F900003C0308008C6300D0240E0001106E005EE2
71544+:10F910002CCF000C24D2FFFC2E5000041600002136
71545+:10F9200000002021241800021078001B2CD9000CA4
71546+:10F9300024DFFFF82FE900041520FF330000202109
71547+:10F9400030EB020051600004000621C054C00022C8
71548+:10F9500030A5FFFF000621C030A5FFFF0A00117D82
71549+:10F96000362600023C0908008D29002431300001B0
71550+:10F970005200FEF7000018219785002A3626000263
71551+:10F980000E000FDB000020210A00114D000018219D
71552+:10F990000A00119C241200021320FFE624DFFFF866
71553+:10F9A0000000202130A5FFFF0A00117D362600024D
71554+:10F9B0000A0011AC021980245120FF828CA6000499
71555+:10F9C0003C05080190A5964110A0FF7E2408000187
71556+:10F9D0000A0011F0010018210E000FDB3226000191
71557+:10F9E0008F8600108F8500280A00124F000621C064
71558+:10F9F0008F8500043C18800024120003371001801A
71559+:10FA0000A212000B0A00112E3C08800090A30001F6
71560+:10FA1000241100011071FF70240800012409000264
71561+:10FA20005069000430E60040240800010A0011F08B
71562+:10FA30000100182150C0FFFD240800013C0C80008B
71563+:10FA4000358B01009563001094A40002307FFFFF06
71564+:10FA5000509FFF62010018210A001284240800014F
71565+:10FA60002CA803EF1100FE56240300010A001239EE
71566+:10FA700000000000240E000335EA0180A14E000BB7
71567+:10FA80000A00121C3C04800011E0FFA2000621C005
71568+:10FA900030A5FFFF0A00117D362600020A0011A5DD
71569+:10FAA000241100201140FFC63C1280003650010096
71570+:10FAB000960F001094AE000231E80FFF15C8FFC08A
71571+:10FAC000000000000A0011E690B900013C060800A1
71572+:10FAD0008CC6003824C4FFFF14C00002018418241F
71573+:10FAE000000018213C0D080025AD0038006D1021E4
71574+:10FAF0000A0011B6904300048F8F0004240EFFFE0D
71575+:10FB00000A00112C01EE28242408FFFE0A00121A14
71576+:10FB100000A8282427BDFFC8AFB00010AFBF003435
71577+:10FB20003C10600CAFBE0030AFB7002CAFB6002861
71578+:10FB3000AFB50024AFB40020AFB3001CAFB20018C3
71579+:10FB4000AFB100148E0E5000240FFF7F3C068000E2
71580+:10FB500001CF682435AC380C240B0003AE0C5000E8
71581+:10FB6000ACCB00083C010800AC2000200E001819A6
71582+:10FB7000000000003C0A0010354980513C06601628
71583+:10FB8000AE09537C8CC700003C0860148D0500A0B2
71584+:10FB90003C03FFFF00E320243C02535300051FC237
71585+:10FBA0001482000634C57C000003A08002869821E0
71586+:10FBB0008E7200043C116000025128218CBF007C31
71587+:10FBC0008CA200783C1E600037C420203C05080150
71588+:10FBD00024A59288AF820018AF9F001C0E0016DD8E
71589+:10FBE0002406000A3C190001273996403C01080010
71590+:10FBF000AC3931DC0E0020DDAF8000148FD708084F
71591+:10FC00002418FFF03C15570902F8B02412D502F56C
71592+:10FC100024040001AF80002C3C1480003697018042
71593+:10FC20003C1E080127DE9644369301008E900000AA
71594+:10FC30003205000310A0FFFD3207000110E000882C
71595+:10FC4000320600028E7100283C048000AE91002034
71596+:10FC50008E6500048E66000000A0382100C040219F
71597+:10FC60008C8301B80460FFFE3C0B0010240A0800DE
71598+:10FC700000AB4824AC8A01B8552000E0240BBFFF3C
71599+:10FC80009675000E3C1208008E52002030AC4000E9
71600+:10FC900032AFFFFF264E000125ED00043C010800B5
71601+:10FCA000AC2E0020118000E8AF8D00283C18002009
71602+:10FCB00000B8B02412C000E530B980002408BFFFAE
71603+:10FCC00000A8382434C81000AF87000030E62000B8
71604+:10FCD00010C000E92409FFBF3C03000400E328240E
71605+:10FCE00010A00002010910243502004030EA010092
71606+:10FCF00011400010AF8200048F8B002C11600007B0
71607+:10FD00003C0D002000ED6024118000043C0F000435
71608+:10FD100000EF702411C00239000000009668001E38
71609+:10FD20009678001C3115FFFF0018B40002B690252C
71610+:10FD3000AF92000C30F910001320001324150001BD
71611+:10FD400030FF002017E0000A3C04100000E41024FB
71612+:10FD50001040000D3C0A0C003C090BFF00EA18247F
71613+:10FD60003525FFFF00A3302B10C0000830ED010047
71614+:10FD70003C0C08008D8C002C24150005258B0001FF
71615+:10FD80003C010800AC2B002C30ED010015A0000B4D
71616+:10FD90003C0500018F85000430AE400055C00007CF
71617+:10FDA0003C0500013C161F0100F690243C0F10009A
71618+:10FDB000124F01CE000000003C05000100E5302498
71619+:10FDC00010C000AF3C0C10003C1F08008FFF002447
71620+:10FDD00033E90002152000712403000100601021A6
71621+:10FDE000104000083C0680003C08800035180100E7
71622+:10FDF0008F0F00243C056020ACAF00140000000011
71623+:10FE00003C0680003C194000ACD9013800000000DD
71624+:10FE10005220001332060002262B0140262C0080BF
71625+:10FE2000240EFF80016E2024018E6824000D1940ED
71626+:10FE3000318A007F0004A9403172007F3C16200007
71627+:10FE400036C20002006A482502B2382500E2882541
71628+:10FE50000122F825ACDF0830ACD1083032060002B0
71629+:10FE600010C0FF723C188000370501408CA80000CC
71630+:10FE700024100040AF08002090AF000831E300706C
71631+:10FE8000107000D428790041532000082405006038
71632+:10FE9000241100201071000E3C0A40003C09800033
71633+:10FEA000AD2A01780A001304000000001465FFFB6E
71634+:10FEB0003C0A40000E001FFA000000003C0A40000F
71635+:10FEC0003C098000AD2A01780A00130400000000FC
71636+:10FED00090A90009241F00048CA70000312800FF0E
71637+:10FEE000111F01B22503FFFA2C7200061240001404
71638+:10FEF0003C0680008CA9000494A4000A310500FF90
71639+:10FF000000095E022D6A00083086FFFF15400002DE
71640+:10FF10002567000424070003240C000910AC01FA33
71641+:10FF200028AD000A11A001DE2410000A240E0008EA
71642+:10FF300010AE0028000731C000C038213C06800008
71643+:10FF40008CD501B806A0FFFE34D20180AE47000078
71644+:10FF500034CB0140916E0008240300023C0A4000AB
71645+:10FF600031C400FF00046A0001A86025A64C000807
71646+:10FF7000A243000B9562000A3C0810003C09800077
71647+:10FF8000A64200108D670004AE470024ACC801B83B
71648+:10FF9000AD2A01780A001304000000003C0A80002A
71649+:10FFA000354401009483000E3C0208008C4200D8C6
71650+:10FFB000240400803065FFFF245500013C01080047
71651+:10FFC000AC3500D80E000FDB240600030A001370C6
71652+:10FFD000000018210009320230D900FF2418000166
71653+:10FFE0001738FFD5000731C08F910020262200016D
71654+:10FFF000AF8200200A0013C800C0382100CB2024A3
71655+:020000021000EC
71656+:10000000AF85000010800008AF860004240D87FF34
71657+:1000100000CD6024158000083C0E006000AE302446
71658+:1000200010C00005000000000E000D42000000009E
71659+:100030000A001371000000000E0016050000000009
71660+:100040000A0013710000000030B980005320FF1F28
71661+:10005000AF8500003C02002000A2F82453E0FF1B03
71662+:10006000AF8500003C07FFFF34E47FFF00A4382485
71663+:100070000A00132B34C880000A001334010910242D
71664+:1000800000EC58245160005AAF8000248F8D002C62
71665+:100090003C0E0F0000EE182415A00075AF83001071
71666+:1000A00030EF010011E00073939800103C12020041
71667+:1000B000107200703C06800034D9010093280013B0
71668+:1000C0009789002A36A60002311800FF271600047F
71669+:1000D000001619C03C0480008C8501B804A0FFFE06
71670+:1000E00034880180AD0300003C158008AC830020FB
71671+:1000F00096BF004833E5FFFF10A001BCAF850008A4
71672+:100100002523001200A3102B504001B98F85000455
71673+:10011000348D010095AC0020240B001A30E440001F
71674+:10012000318AFFFFA10B000B108001BA2543FFFEAF
71675+:1001300000A3702B15C001B88F9600048F8F0004A8
71676+:10014000A503001435E50001AF8500043C088000DC
71677+:1001500035150180A6A9000EA6A9001A8F89000CEA
71678+:1001600030BF8000A6A70010AEA90028A6A60008F0
71679+:1001700013E0000F3C0F8000350C0100958B00163A
71680+:10018000316AFFFC25440004008818218C6240007D
71681+:100190003046FFFF14C000072416BFFF3C0EFFFFD0
71682+:1001A00035CD7FFF00AD2824AF8500043C0F8000D3
71683+:1001B0002416BFFF00B6902435E50180A4B20026C6
71684+:1001C000ACA7002C3C071000ADE701B80A00137083
71685+:1001D000000018210E00165D000000003C0A4000DF
71686+:1001E0003C098000AD2A01780A00130400000000D9
71687+:1001F0008F85002410A00027AF80001090A300007E
71688+:10020000106000742409000310690101000030210E
71689+:1002100090AE0001240D000211CD014230EF0040EC
71690+:1002200090A90001241F0001113F000930E20040A5
71691+:100230008CA600049785002A00C020210E000FDB49
71692+:1002400036A60002000040210A00137001001821A8
71693+:100250005040FFF88CA600043C07080190E7964147
71694+:1002600010E0FFF4240800010A00137001001821B7
71695+:10027000939800103C1F080127FF96400018C8C043
71696+:10028000033F4021AF8800248F85002414A0FFDBAA
71697+:10029000AF9800103C0480008C86400030C50100FF
71698+:1002A00010A0008732AB00043C0C08008D8C0024A9
71699+:1002B00024160004156000033192000D241600027C
71700+:1002C0003C0480008C8E4000340DFFFF11CD0113E3
71701+:1002D00032B5FFFB8C984000330F010055E0000160
71702+:1002E0002415001030E80800110000382409FFFB35
71703+:1002F0008F9F00282FF903EF53200001024990241B
71704+:1003000030E2010010400014325F00018F87002CA2
71705+:1003100014E0010E8F8C000C3C0480003486010038
71706+:1003200090C5001330AA00FF25430004000321C03C
71707+:100330002419FFFE025990241240000202B6302513
71708+:1003400032A6FFFF0E000FDB9785002A1240FEA3A6
71709+:1003500000001821325F000113E0000D3247000455
71710+:10036000240900011249000202B6302532A6FFFF1F
71711+:100370009785002A0E000FDB000020212402FFFEDB
71712+:10038000024290241240FE950000182132470004DA
71713+:1003900050E0FE922403000102B63025241600042A
71714+:1003A0005656000132A6FFFF9785002A0E000FDB8C
71715+:1003B000240401002403FFFB0243A82412A0FE87AB
71716+:1003C000000018210A001370240300010A0014B968
71717+:1003D0000249902410A0FFAF30E5010010A00017E3
71718+:1003E0008F8600102403000210C300148F84000CB9
71719+:1003F0003C0608008CC6003824CAFFFF14C0000267
71720+:10040000008A1024000010213C0E080025CE003880
71721+:10041000004E682191AC00048F850028258B0004D4
71722+:10042000000B21C030A5FFFF36A600020E000FDB37
71723+:10043000000000000A00137000001821240F0002C1
71724+:1004400010CF0088241600013C0308008C6300D004
71725+:100450001076008D8F85002824D9FFFC2F280004FA
71726+:100460001500006300002021241F0002107F005DA2
71727+:100470002CC9000C24C3FFF82C6200041440FFE9CF
71728+:100480000000202130EA020051400004000621C093
71729+:1004900054C0000530A5FFFF000621C030A5FFFFB6
71730+:1004A0000A00150436A600020E000FDB32A600017A
71731+:1004B0008F8600108F8500280A001520000621C0B5
71732+:1004C0003C0A08008D4A0024315200015240FE438C
71733+:1004D000000018219785002A36A600020E000FDBC7
71734+:1004E000000020210A001370000018219668000CFB
71735+:1004F000311802005700FE313C0500013C1F800806
71736+:1005000097F900489789002A36A600023328FFFF92
71737+:10051000AF8800083C0380008C7501B806A0FFFE80
71738+:100520003C04800034820180AC400000110000B621
71739+:1005300024180003252A0012010A182B106000B2AB
71740+:1005400000000000966F00203C0E8000240D001A71
71741+:1005500031ECFFFF35CA018030EB4000A14D000BAC
71742+:10056000116000B02583FFFE0103902B164000AE02
71743+:100570002416FFFE34A50001A5430014AF85000436
71744+:100580002419BFFF00B94024A6E9000EA6E9001A0D
71745+:10059000A6E60008A6E80026A6E700103C07100023
71746+:1005A000AE8701B80A001370000018213C048000D7
71747+:1005B0008C8201B80440FFFE349601802415001C93
71748+:1005C000AEC70000A2D5000B3C071000AC8701B8F5
71749+:1005D0003C0A40003C098000AD2A01780A0013045F
71750+:1005E000000000005120FFA424C3FFF800002021D8
71751+:1005F00030A5FFFF0A00150436A600020E00103DCC
71752+:10060000000000008F8700000A001346AF82000C34
71753+:1006100090A30001241500011075FF0B24080001B0
71754+:10062000240600021066000430E2004024080001A5
71755+:100630000A001370010018215040FFFD240800013A
71756+:100640003C0C8000358B0100956A001094A40002D8
71757+:100650003143FFFF5083FDE1010018210A00158599
71758+:10066000240800018F8500282CB203EF1240FDDB27
71759+:10067000240300013C0308008C6300D02416000111
71760+:100680001476FF7624D9FFFC2CD8000C1300FF72DF
71761+:10069000000621C030A5FFFF0A00150436A600029F
71762+:1006A00010B00037240F000B14AFFE23000731C039
71763+:1006B000312600FF00065600000A4E0305220047BF
71764+:1006C00030C6007F0006F8C03C16080126D69640CA
71765+:1006D00003F68021A2000001A20000003C0F600090
71766+:1006E0008DF918202405000100C588040011302769
71767+:1006F0000326C024000731C000C03821ADF81820FF
71768+:100700000A0013C8A60000028F850020000731C030
71769+:1007100024A2FFFF0A0013F6AF8200200A0014B2E1
71770+:100720002415002011E0FECC3C1980003728010080
71771+:100730009518001094B6000233120FFF16D2FEC6B1
71772+:10074000000000000A00148290A900013C0B080080
71773+:100750008D6B0038256DFFFF15600002018D1024A0
71774+:10076000000010213C080800250800380048C0217E
71775+:10077000930F000425EE00040A0014C5000E21C0EA
71776+:1007800000065202241F00FF115FFDEB000731C07D
71777+:10079000000A20C03C0E080125CE9640008EA821FC
71778+:1007A000009E602100095C02240D00013C076000EE
71779+:1007B000A2AD0000AD860000A2AB00018CF21820B3
71780+:1007C00024030001014310040242B025ACF61820B6
71781+:1007D00000C038210A0013C8A6A900020A0015AA01
71782+:1007E000AF8000200A0012FFAF84002C8F85000428
71783+:1007F0003C1980002408000337380180A308000B4F
71784+:100800000A00144D3C088000A2F8000B0A00155A9B
71785+:100810002419BFFF8F9600042412FFFE0A00144B18
71786+:1008200002D228242416FFFE0A00155800B62824F8
71787+:100830003C038000346401008C85000030A2003E3F
71788+:100840001440000800000000AC6000488C870000E5
71789+:1008500030E607C010C0000500000000AC60004C8E
71790+:10086000AC60005003E0000824020001AC600054BA
71791+:10087000AC6000408C880000310438001080FFF923
71792+:10088000000000002402000103E00008AC60004406
71793+:100890003C0380008C6201B80440FFFE3467018095
71794+:1008A000ACE4000024080001ACE00004A4E500086A
71795+:1008B00024050002A0E8000A34640140A0E5000B12
71796+:1008C0009483000A14C00008A4E30010ACE00024E4
71797+:1008D0003C07800034E901803C041000AD20002872
71798+:1008E00003E00008ACE401B88C8600043C0410006E
71799+:1008F000ACE600243C07800034E90180AD200028EC
71800+:1009000003E00008ACE401B83C0680008CC201B8EA
71801+:100910000440FFFE34C7018024090002ACE400005B
71802+:10092000ACE40004A4E50008A0E9000A34C50140D5
71803+:10093000A0E9000B94A8000A3C041000A4E80010F1
71804+:10094000ACE000248CA30004ACE3002803E0000822
71805+:10095000ACC401B83C039000346200010082202541
71806+:100960003C038000AC6400208C65002004A0FFFEE6
71807+:100970000000000003E00008000000003C028000CE
71808+:10098000344300010083202503E00008AC4400202C
71809+:1009900027BDFFE03C098000AFBF0018AFB10014D5
71810+:1009A000AFB00010352801408D10000091040009FF
71811+:1009B0009107000891050008308400FF30E600FF31
71812+:1009C00000061A002C820081008330251040002A86
71813+:1009D00030A50080000460803C0D080125AD92B078
71814+:1009E000018D58218D6A00000140000800000000C0
71815+:1009F0003C038000346201409445000A14A0001EAC
71816+:100A00008F91FCC09227000530E6000414C0001A44
71817+:100A1000000000000E00164E02002021922A000560
71818+:100A200002002021354900040E001658A2290005B5
71819+:100A30009228000531040004148000020000000028
71820+:100A40000000000D922D0000240B002031AC00FFAF
71821+:100A5000158B00093C0580008CAE01B805C0FFFE77
71822+:100A600034B10180AE3000003C0F100024100005AE
71823+:100A7000A230000BACAF01B80000000D8FBF001812
71824+:100A80008FB100148FB0001003E0000827BD0020D4
71825+:100A90000200202100C028218FBF00188FB1001450
71826+:100AA0008FB00010240600010A00161D27BD00208B
71827+:100AB0000000000D0200202100C028218FBF001877
71828+:100AC0008FB100148FB00010000030210A00161DF5
71829+:100AD00027BD002014A0FFE8000000000200202134
71830+:100AE0008FBF00188FB100148FB0001000C02821F4
71831+:100AF0000A00163B27BD00203C0780008CEE01B8A1
71832+:100B000005C0FFFE34F00180241F0002A21F000B6D
71833+:100B100034F80140A60600089719000A3C0F10009F
71834+:100B2000A61900108F110004A6110012ACEF01B835
71835+:100B30000A0016998FBF001827BDFFE8AFBF00104D
71836+:100B40000E000FD4000000003C0280008FBF001098
71837+:100B500000002021AC4001800A00108F27BD001842
71838+:100B60003084FFFF30A5FFFF108000070000182130
71839+:100B7000308200011040000200042042006518216C
71840+:100B80001480FFFB0005284003E0000800601021EE
71841+:100B900010C00007000000008CA2000024C6FFFF68
71842+:100BA00024A50004AC82000014C0FFFB24840004D0
71843+:100BB00003E000080000000010A0000824A3FFFFCD
71844+:100BC000AC86000000000000000000002402FFFFCF
71845+:100BD0002463FFFF1462FFFA2484000403E000088A
71846+:100BE000000000003C03800027BDFFF83462018054
71847+:100BF000AFA20000308C00FF30AD00FF30CE00FF10
71848+:100C00003C0B80008D6401B80480FFFE00000000F2
71849+:100C10008FA900008D6801288FAA00008FA700000F
71850+:100C20008FA400002405000124020002A085000A10
71851+:100C30008FA30000359940003C051000A062000B16
71852+:100C40008FB800008FAC00008FA600008FAF0000AF
71853+:100C500027BD0008AD280000AD400004AD80002491
71854+:100C6000ACC00028A4F90008A70D0010A5EE0012E2
71855+:100C700003E00008AD6501B83C06800827BDFFE829
71856+:100C800034C50080AFBF001090A7000924020012F5
71857+:100C900030E300FF1062000B008030218CA8005070
71858+:100CA00000882023048000088FBF00108CAA003425
71859+:100CB000240400390000282100CA4823052000052B
71860+:100CC000240600128FBF00102402000103E0000878
71861+:100CD00027BD00180E0016F2000000008FBF0010A4
71862+:100CE0002402000103E0000827BD001827BDFFC84B
71863+:100CF000AFB20030AFB00028AFBF0034AFB1002CAE
71864+:100D000000A0802190A5000D30A6001010C000109A
71865+:100D1000008090213C0280088C4400048E0300086F
71866+:100D20001064000C30A7000530A6000510C0009329
71867+:100D3000240400018FBF00348FB200308FB1002C2B
71868+:100D40008FB000280080102103E0000827BD003884
71869+:100D500030A7000510E0000F30AB001210C00006F5
71870+:100D6000240400013C0980088E0800088D25000439
71871+:100D70005105009C240400388FBF00348FB200302E
71872+:100D80008FB1002C8FB000280080102103E00008F4
71873+:100D900027BD0038240A0012156AFFE6240400016A
71874+:100DA0000200202127A500100E000CB6AFA00010F5
71875+:100DB0001440007C3C19800837240080909800087B
71876+:100DC000331100081220000A8FA7001030FF010025
71877+:100DD00013E000A48FA300148C8600580066102333
71878+:100DE000044000043C0A8008AC8300588FA7001020
71879+:100DF0003C0A800835480080910900083124000829
71880+:100E00001480000224080003000040213C1F8008D9
71881+:100E100093F1001193F9001237E600808CCC005456
71882+:100E2000333800FF03087821322D00FF000F708057
71883+:100E300001AE282100AC582B1160006F00000000AB
71884+:100E400094CA005C8CC900543144FFFF0125102373
71885+:100E50000082182B14600068000000008CCB005446
71886+:100E60000165182330EC00041180006C000830800C
71887+:100E70008FA8001C0068102B1040006230ED0004A9
71888+:100E8000006610232C46008010C00002004088211C
71889+:100E9000241100800E00164E024020213C0D8008D7
71890+:100EA00035A6008024070001ACC7000C90C80008DC
71891+:100EB0000011484035A70100310C007FA0CC00088C
71892+:100EC0008E05000424AB0001ACCB0030A4D1005C43
71893+:100ED0008CCA003C9602000E01422021ACC40020C6
71894+:100EE0008CC3003C0069F821ACDF001C8E190004A3
71895+:100EF000ACF900008E180008ACF800048FB10010A7
71896+:100F0000322F000855E0004793A60020A0C0004EF5
71897+:100F100090D8004E2411FFDFA0F8000890CF000801
71898+:100F200001F17024A0CE00088E0500083C0B80085B
71899+:100F300035690080AD2500388D6A00148D2200309F
71900+:100F40002419005001422021AD24003491230000D7
71901+:100F5000307F00FF13F90036264F01000E001658AF
71902+:100F60000240202124040038000028210E0016F23F
71903+:100F70002406000A0A001757240400010E000D2859
71904+:100F8000000020218FBF00348FB200308FB1002CC1
71905+:100F90008FB00028004020210080102103E00008CD
71906+:100FA00027BD00388E0E00083C0F800835F0008009
71907+:100FB000AE0E005402402021AE0000300E00164E4E
71908+:100FC00000000000920D00250240202135AC0020D9
71909+:100FD0000E001658A20C00250E000CAC0240202179
71910+:100FE000240400382405008D0E0016F22406001299
71911+:100FF0000A0017572404000194C5005C0A001792E8
71912+:1010000030A3FFFF2407021811A0FF9E00E6102363
71913+:101010008FAE001C0A00179A01C610230A0017970A
71914+:101020002C620218A0E600080A0017C48E0500080A
71915+:101030002406FF8001E6C0243C118000AE38002861
71916+:101040008E0D000831E7007F3C0E800C00EE602121
71917+:10105000AD8D00E08E080008AF8C00380A0017D074
71918+:10106000AD8800E4AC800058908500082403FFF7A9
71919+:1010700000A33824A08700080A0017758FA7001066
71920+:101080003C05080024A560A83C04080024846FF4F3
71921+:101090003C020800244260B0240300063C01080121
71922+:1010A000AC2596C03C010801AC2496C43C01080163
71923+:1010B000AC2296C83C010801A02396CC03E00008AE
71924+:1010C0000000000003E00008240200013C02800050
71925+:1010D000308800FF344701803C0680008CC301B893
71926+:1010E0000460FFFE000000008CC501282418FF806A
71927+:1010F0003C0D800A24AF010001F8702431EC007F20
71928+:10110000ACCE0024018D2021ACE50000948B00EAD8
71929+:101110003509600024080002316AFFFFACEA0004D0
71930+:1011200024020001A4E90008A0E8000BACE00024C0
71931+:101130003C071000ACC701B8AF84003803E00008DA
71932+:10114000AF85006C938800488F8900608F820038DB
71933+:1011500030C600FF0109382330E900FF01221821C1
71934+:1011600030A500FF2468008810C000020124382147
71935+:101170000080382130E400031480000330AA00030B
71936+:101180001140000D312B000310A0000900001021B8
71937+:1011900090ED0000244E000131C200FF0045602B9D
71938+:1011A000A10D000024E700011580FFF925080001CA
71939+:1011B00003E00008000000001560FFF300000000DD
71940+:1011C00010A0FFFB000010218CF80000245900043F
71941+:1011D000332200FF0045782BAD18000024E70004FF
71942+:1011E00015E0FFF92508000403E0000800000000F6
71943+:1011F00093850048938800588F8700600004320070
71944+:101200003103007F00E5102B30C47F001040000F39
71945+:10121000006428258F8400383C0980008C8A00EC0B
71946+:10122000AD2A00A43C03800000A35825AC6B00A0AD
71947+:101230008C6C00A00580FFFE000000008C6D00ACEF
71948+:10124000AC8D00EC03E000088C6200A80A00188254
71949+:101250008F840038938800593C0280000080502120
71950+:10126000310300FEA383005930ABFFFF30CC00FFF9
71951+:1012700030E7FFFF344801803C0980008D2401B82D
71952+:101280000480FFFE8F8D006C24180016AD0D000049
71953+:101290008D2201248F8D0038AD0200048D5900206D
71954+:1012A000A5070008240201C4A119000AA118000B17
71955+:1012B000952F01208D4E00088D4700049783005C18
71956+:1012C0008D59002401CF302100C7282100A32023FD
71957+:1012D0002418FFFFA504000CA50B000EA5020010AA
71958+:1012E000A50C0012AD190018AD18002495AF00E848
71959+:1012F0003C0B10002407FFF731EEFFFFAD0E002876
71960+:101300008DAC0084AD0C002CAD2B01B88D460020B7
71961+:1013100000C7282403E00008AD4500208F8800386E
71962+:101320000080582130E7FFFF910900D63C02800081
71963+:1013300030A5FFFF312400FF00041A00006750258C
71964+:1013400030C600FF344701803C0980008D2C01B875
71965+:101350000580FFFE8F82006C240F0017ACE20000B6
71966+:101360008D390124ACF900048D780020A4EA00082E
71967+:10137000241901C4A0F8000AA0EF000B9523012056
71968+:101380008D6E00088D6D00049784005C01C35021B0
71969+:10139000014D602101841023A4E2000CA4E5000E9D
71970+:1013A000A4F90010A4E60012ACE000148D7800242B
71971+:1013B000240DFFFFACF800188D0F007CACEF001C73
71972+:1013C0008D0E00783C0F1000ACEE0020ACED002438
71973+:1013D000950A00BE240DFFF73146FFFFACE600285A
71974+:1013E000950C00809504008231837FFF0003CA00C2
71975+:1013F0003082FFFF0322C021ACF8002CAD2F01B8D2
71976+:10140000950E00828D6A002000AE3021014D282407
71977+:10141000A506008203E00008AD6500203C028000C4
71978+:10142000344501803C0480008C8301B80460FFFED9
71979+:101430008F8A0044240600199549001C3128FFFFBB
71980+:10144000000839C0ACA70000A0A6000B3C051000A6
71981+:1014500003E00008AC8501B88F87004C0080402174
71982+:1014600030C400FF3C0680008CC201B80440FFFE7F
71983+:101470008F89006C9383006834996000ACA90000E8
71984+:10148000A0A300058CE20010240F00022403FFF744
71985+:10149000A4A20006A4B900088D180020A0B8000A74
71986+:1014A000A0AF000B8CEE0000ACAE00108CED000481
71987+:1014B000ACAD00148CEC001CACAC00248CEB002018
71988+:1014C000ACAB00288CEA002C3C071000ACAA002C26
71989+:1014D0008D090024ACA90018ACC701B88D05002007
71990+:1014E00000A3202403E00008AD0400208F8600380C
71991+:1014F00027BDFFE0AFB10014AFBF0018AFB00010C0
71992+:1015000090C300D430A500FF3062002010400008D6
71993+:10151000008088218CCB00D02409FFDF256A0001E0
71994+:10152000ACCA00D090C800D401093824A0C700D4A8
71995+:1015300014A000403C0C80008F840038908700D4B9
71996+:101540002418FFBF2406FFEF30E3007FA08300D400
71997+:10155000979F005C8F8200608F8D003803E2C82364
71998+:10156000A799005CA5A000BC91AF00D401F870243D
71999+:10157000A1AE00D48F8C0038A18000D78F8A0038AC
72000+:10158000A5400082AD4000EC914500D400A658244F
72001+:10159000A14B00D48F9000348F8400609786005C4C
72002+:1015A0000204282110C0000FAF850034A38000582A
72003+:1015B0003C0780008E2C000894ED01208E2B000447
72004+:1015C000018D5021014B8021020620233086FFFF30
72005+:1015D00030C8000F3909000131310001162000091F
72006+:1015E000A3880058938600488FBF00188FB100145D
72007+:1015F0008FB0001027BD0020AF85006403E0000815
72008+:10160000AF86006000C870238FBF00189386004823
72009+:101610008FB100148FB0001034EF0C00010F28219F
72010+:1016200027BD0020ACEE0084AF85006403E0000815
72011+:10163000AF86006035900180020028210E00190F4E
72012+:10164000240600828F840038908600D430C5004084
72013+:1016500050A0FFBAA38000688F85004C3C06800034
72014+:101660008CCD01B805A0FFFE8F89006C2408608234
72015+:1016700024070002AE090000A6080008A207000B1C
72016+:101680008CA300083C0E1000AE0300108CA2000CCE
72017+:10169000AE0200148CBF0014AE1F00188CB90018E5
72018+:1016A000AE1900248CB80024AE1800288CAF002896
72019+:1016B000AE0F002CACCE01B80A001948A380006818
72020+:1016C0008F8A003827BDFFE0AFB10014AFB0001023
72021+:1016D0008F880060AFBF00189389003C954200BC22
72022+:1016E00030D100FF0109182B0080802130AC00FFB1
72023+:1016F0003047FFFF0000582114600003310600FF4F
72024+:1017000001203021010958239783005C0068202BB9
72025+:101710001480002700000000106800562419000102
72026+:101720001199006334E708803165FFFF0E0018C08F
72027+:10173000020020218F83006C3C07800034E601808A
72028+:101740003C0580008CAB01B80560FFFE240A001840
72029+:101750008F840038ACC30000A0CA000B948900BE7F
72030+:101760003C081000A4C90010ACC00030ACA801B8FF
72031+:101770009482008024430001A4830080949F008011
72032+:101780003C0608008CC6318833EC7FFF1186005E72
72033+:101790000000000002002021022028218FBF001835
72034+:1017A0008FB100148FB000100A00193427BD00203B
72035+:1017B000914400D42403FF8000838825A15100D4E4
72036+:1017C0009784005C3088FFFF51000023938C003C1D
72037+:1017D0008F8500382402EFFF008B782394AE00BC85
72038+:1017E0000168502B31E900FF01C26824A4AD00BCA0
72039+:1017F00051400039010058213C1F800037E60100AC
72040+:101800008CD800043C190001031940245500000144
72041+:1018100034E740008E0A00202403FFFB241100015E
72042+:1018200001432024AE0400201191002D34E78000F4
72043+:1018300002002021012030210E0018C03165FFFF79
72044+:101840009787005C8F890060A780005C0127802358
72045+:10185000AF900060938C003C8F8B00388FBF0018D6
72046+:101860008FB100148FB0001027BD002003E00008E6
72047+:10187000A16C00D73C0D800035AA01008D48000402
72048+:101880003C0900010109282454A0000134E740006C
72049+:101890008E0F00202418FFFB34E7800001F870242D
72050+:1018A00024190001AE0E00201599FF9F34E708802F
72051+:1018B000020020210E00188E3165FFFF020020215A
72052+:1018C000022028218FBF00188FB100148FB00010A4
72053+:1018D0000A00193427BD00200A0019F7000048212A
72054+:1018E00002002021012030210E00188E3165FFFFFB
72055+:1018F0009787005C8F890060A780005C01278023A8
72056+:101900000A001A0EAF900060948C0080241F8000A3
72057+:10191000019F3024A4860080908B0080908F0080EF
72058+:10192000316700FF0007C9C20019C027001871C045
72059+:1019300031ED007F01AE2825A08500800A0019DF67
72060+:1019400002002021938500682403000127BDFFE8E1
72061+:1019500000A330042CA20020AFB00010AFBF0014D1
72062+:1019600000C01821104000132410FFFE3C0708009F
72063+:101970008CE7319000E610243C088000350501809A
72064+:1019800014400005240600848F890038240A0004CE
72065+:101990002410FFFFA12A00FC0E00190F0000000018
72066+:1019A000020010218FBF00148FB0001003E0000868
72067+:1019B00027BD00183C0608008CC631940A001A574F
72068+:1019C00000C310248F87004427BDFFE0AFB200188A
72069+:1019D000AFB10014AFB00010AFBF001C30D000FF9B
72070+:1019E00090E6000D00A088210080902130C5007F86
72071+:1019F000A0E5000D8F8500388E2300188CA200D042
72072+:101A00001062002E240A000E0E001A4AA38A0068F3
72073+:101A10002409FFFF104900222404FFFF5200002088
72074+:101A2000000020218E2600003C0C001000CC582421
72075+:101A3000156000393C0E000800CE682455A0003F18
72076+:101A4000024020213C18000200D880241200001F10
72077+:101A50003C0A00048F8700448CE200148CE30010E1
72078+:101A60008CE500140043F82303E5C82B1320000580
72079+:101A7000024020218E24002C8CF1001010910031A6
72080+:101A80000240202124020012A38200680E001A4A9C
72081+:101A90002412FFFF105200022404FFFF0000202147
72082+:101AA0008FBF001C8FB200188FB100148FB00010D0
72083+:101AB0000080102103E0000827BD002090A800D47A
72084+:101AC000350400200A001A80A0A400D400CA4824CB
72085+:101AD0001520000B8F8B00448F8D00448DAC0010BF
72086+:101AE0001580000B024020218E2E002C51C0FFECEF
72087+:101AF00000002021024020210A001A9B2402001726
72088+:101B00008D66001050C0FFE6000020210240202119
72089+:101B10000A001A9B24020011024020212402001511
72090+:101B20000E001A4AA3820068240FFFFF104FFFDC4B
72091+:101B30002404FFFF0A001A8A8E2600000A001AC138
72092+:101B4000240200143C08000400C8382450E0FFD4EC
72093+:101B500000002021024020210A001A9B24020013C9
72094+:101B60008F85003827BDFFD8AFB3001CAFB2001877
72095+:101B7000AFB10014AFB00010AFBF002090A700D4E9
72096+:101B80008F90004C2412FFFF34E2004092060000C8
72097+:101B9000A0A200D48E0300100080982110720006CD
72098+:101BA00030D1003F2408000D0E001A4AA3880068B7
72099+:101BB000105200252404FFFF8F8A00388E09001878
72100+:101BC0008D4400D01124000702602021240C000E57
72101+:101BD0000E001A4AA38C0068240BFFFF104B001A5A
72102+:101BE0002404FFFF24040020122400048F8D0038F9
72103+:101BF00091AF00D435EE0020A1AE00D48F85005403
72104+:101C000010A00019000000001224004A8F9800382C
72105+:101C10008F92FCC0971000809651000A5230004805
72106+:101C20008F9300403C1F08008FFF318C03E5C82BC9
72107+:101C30001720001E02602021000028210E0019A993
72108+:101C400024060001000020218FBF00208FB3001C5C
72109+:101C50008FB200188FB100148FB0001000801021D7
72110+:101C600003E0000827BD00285224002A8E05001436
72111+:101C70008F840038948A008025490001A48900805F
72112+:101C8000948800803C0208008C42318831077FFF35
72113+:101C900010E2000E00000000026020210E00193446
72114+:101CA000240500010A001B0B000020212402002D46
72115+:101CB0000E001A4AA38200682403FFFF1443FFE1C9
72116+:101CC0002404FFFF0A001B0C8FBF002094990080A2
72117+:101CD000241F800024050001033FC024A498008035
72118+:101CE00090920080908E0080325100FF001181C2DE
72119+:101CF00000107827000F69C031CC007F018D582576
72120+:101D0000A08B00800E001934026020210A001B0BFA
72121+:101D1000000020212406FFFF54A6FFD68F84003840
72122+:101D2000026020210E001934240500010A001B0B5B
72123+:101D300000002021026020210A001B252402000A45
72124+:101D40002404FFFD0A001B0BAF9300608F8800384E
72125+:101D500027BDFFE8AFB00010AFBF0014910A00D458
72126+:101D60008F87004C00808021354900408CE60010B0
72127+:101D7000A10900D43C0208008C4231B030C53FFFBD
72128+:101D800000A2182B106000078F850050240DFF80E3
72129+:101D900090AE000D01AE6024318B00FF156000088D
72130+:101DA0000006C382020020212403000D8FBF00140F
72131+:101DB0008FB0001027BD00180A001A4AA3830068DC
72132+:101DC00033060003240F000254CFFFF70200202146
72133+:101DD00094A2001C8F85003824190023A4A200E8D7
72134+:101DE0008CE8000000081E02307F003F13F9003528
72135+:101DF0003C0A00838CE800188CA600D0110600086D
72136+:101E0000000000002405000E0E001A4AA385006899
72137+:101E10002407FFFF104700182404FFFF8F850038B8
72138+:101E200090A900D435240020A0A400D48F8C0044B5
72139+:101E3000918E000D31CD007FA18D000D8F83005458
72140+:101E40001060001C020020218F8400508C9800102C
72141+:101E50000303782B11E0000D241900180200202143
72142+:101E6000A39900680E001A4A2410FFFF10500002C8
72143+:101E70002404FFFF000020218FBF00148FB000104A
72144+:101E80000080102103E0000827BD00188C86001098
72145+:101E90008F9F00440200202100C31023AFE20010F6
72146+:101EA000240500010E0019A9240600010A001B9751
72147+:101EB000000020210E001934240500010A001B97A0
72148+:101EC00000002021010A5824156AFFD98F8C004494
72149+:101ED000A0A600FC0A001B84A386005A30A500FFC0
72150+:101EE0002406000124A9000100C9102B1040000C99
72151+:101EF00000004021240A000100A61823308B0001B5
72152+:101F000024C60001006A3804000420421160000267
72153+:101F100000C9182B010740251460FFF800A61823FC
72154+:101F200003E000080100102127BDFFD8AFB0001862
72155+:101F30008F90004CAFB1001CAFBF00202403FFFF07
72156+:101F40002411002FAFA30010920600002405000802
72157+:101F500026100001006620260E001BB0308400FF12
72158+:101F600000021E003C021EDC34466F410A001BD8F2
72159+:101F70000000102110A00009008018212445000154
72160+:101F800030A2FFFF2C4500080461FFFA0003204047
72161+:101F90000086202614A0FFF9008018210E001BB037
72162+:101FA000240500208FA300102629FFFF313100FFF8
72163+:101FB00000034202240700FF1627FFE20102182651
72164+:101FC00000035027AFAA0014AFAA00100000302170
72165+:101FD00027A8001027A7001400E6782391ED00033E
72166+:101FE00024CE000100C8602131C600FF2CCB0004C4
72167+:101FF0001560FFF9A18D00008FA200108FBF002097
72168+:102000008FB1001C8FB0001803E0000827BD002826
72169+:1020100027BDFFD0AFB3001CAFB00010AFBF00288A
72170+:10202000AFB50024AFB40020AFB20018AFB10014B8
72171+:102030003C0C80008D880128240FFF803C06800A1C
72172+:1020400025100100250B0080020F68243205007F57
72173+:10205000016F7024AD8E009000A62821AD8D002464
72174+:1020600090A600FC3169007F3C0A8004012A1821F7
72175+:10207000A386005A9067007C00809821AF830030CF
72176+:1020800030E20002AF88006CAF85003800A0182154
72177+:10209000144000022404003424040030A3840048C7
72178+:1020A0008C7200DC30D100FF24040004AF92006089
72179+:1020B00012240004A38000688E7400041680001EA1
72180+:1020C0003C0880009386005930C7000110E0000FE3
72181+:1020D0008F9300608CB000848CA800842404FF805F
72182+:1020E000020410240002F940310A007F03EA482567
72183+:1020F0003C0C2000012C902530CD00FE3C038000DC
72184+:10210000AC720830A38D00598F9300608FBF0028F8
72185+:102110008FB50024ACB300DC8FB400208FB3001C5B
72186+:102120008FB200188FB100148FB00010240200018C
72187+:1021300003E0000827BD00308E7F000895020120D3
72188+:102140008E67001003E2C8213326FFFF30D8000F4E
72189+:1021500033150001AF87003416A00058A39800582B
72190+:1021600035090C000309382100D81823AD03008479
72191+:10217000AF8700648E6A00043148FFFF1100007EC3
72192+:10218000A78A005C90AC00D42407FF8000EC3024C8
72193+:1021900030CB00FF1560004B9786005C938E005A91
72194+:1021A000240D000230D5FFFF11CD02A20000A021B6
72195+:1021B0008F85006002A5802B160000BC9388004824
72196+:1021C0003C11800096240120310400FF1485008812
72197+:1021D0008F8400648F9800343312000356400085CA
72198+:1021E00030A500FF8F900064310C00FF24060034FE
72199+:1021F00011860095AF90004C9204000414800118E1
72200+:102200008F8E0038A380003C8E0D00048DC800D84E
72201+:102210003C0600FF34CCFFFF01AC30240106182B34
72202+:1022200014600120AF8600548F8700609798005C8F
72203+:10223000AF8700400307402310C000C7A788005C99
72204+:102240008F91003030C3000300035823922A007C92
72205+:102250003171000302261021000A20823092000111
72206+:102260000012488000492821311FFFFF03E5C82BD9
72207+:10227000132001208F8800388F8500348F880064F8
72208+:102280001105025A3C0E3F018E0600003C0C250051
72209+:1022900000CE682411AC01638F84004C30E500FF50
72210+:1022A0000E00184A000030218F8800388F870060A8
72211+:1022B0008F8500340A001DB78F8600540A001C5613
72212+:1022C000AF87006490A400D400E48024320200FFB1
72213+:1022D000104000169386005990A6008890AE00D753
72214+:1022E00024A8008830D4003F2686FFE02CD10020AF
72215+:1022F000A38E003C1220000CAF88004C240B000180
72216+:1023000000CB20043095001916A0012B3C0680005C
72217+:1023100034CF0002008FC0241700022E3099002015
72218+:1023200017200234000000009386005930CB0001D2
72219+:102330001160000F9788005C8CBF00848CA900841A
72220+:10234000240AFF8003EA6024000C19403132007F28
72221+:10235000007238253C0D200000EDC82530D800FE65
72222+:102360003C0F8000ADF90830A39800599788005CB5
72223+:102370001500FF84000000008E630020306200041E
72224+:102380001040FF51938600592404FFFB0064802411
72225+:102390003C038000AE700020346601808C7301B86D
72226+:1023A0000660FFFE8F98006C347501003C1400013C
72227+:1023B000ACD800008C6B012424076085ACCB0004F2
72228+:1023C0008EAE000401D488245220000124076083CB
72229+:1023D00024190002A4C700083C0F1000A0D9000B6C
72230+:1023E0003C068000ACCF01B80A001C2B9386005934
72231+:1023F00030A500FF0E00184A240600018F88006CEB
72232+:102400003C05800034A90900250201889388004812
72233+:10241000304A0007304B00783C0340802407FF809F
72234+:102420000163C825014980210047F824310C00FFD1
72235+:1024300024060034ACBF0800AF90004CACB90810C3
72236+:102440005586FF6E920400048F8400388E11003090
72237+:10245000908E00D431CD001015A000108F83006045
72238+:102460002C6F000515E000E400000000909800D4F7
72239+:102470002465FFFC331200101640000830A400FF52
72240+:102480008F9F00648F99003413F90004388700018E
72241+:1024900030E20001144001C8000000000E001BC320
72242+:1024A000000000000A001DF8000000008F84006496
72243+:1024B00030C500FF0E00184A24060001939800481A
72244+:1024C000240B0034130B00A08F8500388F8600602A
72245+:1024D0009783005C306EFFFF00CE8823AF910060D1
72246+:1024E000A780005C1280FF90028018212414FFFD59
72247+:1024F0005474FFA28E6300208E6A00042403FFBF81
72248+:102500002408FFEF0155F823AE7F000490AC00D4FF
72249+:102510003189007FA0A900D48E7200208F8F0038EF
72250+:10252000A780005C364D0002AE6D0020A5E000BC27
72251+:1025300091E500D400A3C824A1F900D48F950038F8
72252+:10254000AEA000EC92B800D403085824A2AB00D48B
72253+:102550000A001CD78F8500388F910034AF8000604F
72254+:1025600002275821AF8B0034000020212403FFFFF5
72255+:10257000108301B48F8500388E0C00103C0D0800CC
72256+:102580008DAD31B09208000031843FFF008D802B6B
72257+:1025900012000023310D003F3C1908008F3931A88B
72258+:1025A0008F9F006C000479802408FF80033F202166
72259+:1025B000008FC821938500590328F8243C06008029
72260+:1025C0003C0F800034D80001001F91403331007F60
72261+:1025D0008F8600380251502535EE0940332B0078A4
72262+:1025E000333000073C0310003C02800C017890253A
72263+:1025F000020E48210143C0250222382134AE0001D9
72264+:10260000ADFF0804AF890050ADF20814AF87004455
72265+:10261000ADFF0028ACD90084ADF80830A38E005976
72266+:102620009383005A24070003106700272407000142
72267+:102630001467FFAC8F8500382411002311B1008589
72268+:1026400000000000240E000B026020210E001A4A38
72269+:10265000A38E00680040A0210A001D328F8500383B
72270+:1026600002602021240B000C0E001A4AA38B006884
72271+:10267000240AFFFF104AFFBD2404FFFF8F8E00389D
72272+:10268000A380003C8E0D00048DC800D83C0600FFDE
72273+:1026900034CCFFFF01AC30240106182B1060FEE2A1
72274+:1026A000AF86005402602021241200190E001A4A3D
72275+:1026B000A3920068240FFFFF104FFFAC2404FFFF1C
72276+:1026C0000A001C838F86005425A3FFE02C74002091
72277+:1026D0001280FFDD240E000B000328803C1108014E
72278+:1026E000263194B400B148218D2D000001A00008CE
72279+:1026F000000000008F85003400A710219385003C66
72280+:10270000AF82003402251821A383003C951F00BC32
72281+:102710000226282137F91000A51900BC5240FF926B
72282+:10272000AF850060246A0004A38A003C950900BCC0
72283+:1027300024A40004AF84006035322000A51200BC40
72284+:102740000A001D54000020218F8600602CC800055F
72285+:102750001500FF609783005C3065FFFF00C5C8234C
72286+:102760002F2F000511E00003306400FF24CDFFFC93
72287+:1027700031A400FF8F8900648F920034113200046D
72288+:10278000389F000133EC0001158001380000000083
72289+:102790008F840038908700D434E60010A08600D4DF
72290+:1027A0008F8500388F8600609783005CACA000ECBA
72291+:1027B0000A001D2F306EFFFF8CB500848CB400849E
72292+:1027C0003C04100002A7302400068940328E007FAE
72293+:1027D000022E8025020410253C08800024050001FB
72294+:1027E00002602021240600010E0019A9AD02083064
72295+:1027F0000A001CC38F8500388C8200EC1222FE7EFA
72296+:102800000260202124090005A38900680E001A4AED
72297+:102810002411FFFF1451FE782404FFFF0A001D5508
72298+:102820002403FFFF8F8F004C8F8800388DF8000045
72299+:10283000AD1800888DE70010AD0700988F87006005
72300+:102840000A001DB78F8600542406FFFF118600057D
72301+:10285000000000000E001B4C026020210A001D8FAA
72302+:102860000040A0210E001AD1026020210A001D8F15
72303+:102870000040A0218F90004C3C0208008C4231B0F7
72304+:102880008E110010322C3FFF0182282B10A0000C6B
72305+:10289000240BFF808F85005090A3000D01637024EE
72306+:1028A00031CA00FF1140000702602021001143825D
72307+:1028B000310600032418000110D8010600000000B2
72308+:1028C000026020212403000D0E001A4AA383006831
72309+:1028D000004020218F8500380A001D320080A02191
72310+:1028E0008F90004C3C0A08008D4A31B08F85005013
72311+:1028F0008E0400100000A0218CB1001430823FFF34
72312+:10290000004A602B8CB200205180FFEE0260202133
72313+:1029100090B8000D240BFF800178702431C300FFB4
72314+:102920005060FFE80260202100044382310600036A
72315+:1029300014C0FFE40260202194BF001C8F9900386E
72316+:102940008E060028A73F00E88CAF0010022F20233E
72317+:1029500014C4013A026020218F83005400C368210F
72318+:10296000022D382B14E00136240200188F8A00440F
72319+:102970008F820030024390218D4B00100163702341
72320+:10298000AD4E0010AD5200208C4C00740192282BEB
72321+:1029900014A0015F026020218F8400508E08002463
72322+:1029A0008C86002411060007026020212419001CD7
72323+:1029B0000E001A4AA3990068240FFFFF104FFFC5AD
72324+:1029C0002404FFFF8F8400448C87002424FF00012F
72325+:1029D000AC9F00241251012F8F8D00308DB10074F7
72326+:1029E0001232012C3C0B00808E0E000001CB5024D3
72327+:1029F00015400075000000008E0300142411FFFF35
72328+:102A0000107100073C0808003C0608008CC6319095
72329+:102A100000C8C0241300015202602021A380006876
72330+:102A20008E0300003C19000100792024108000135F
72331+:102A30003C1F0080007FA02416800009020028218E
72332+:102A4000026020212411001A0E001A4AA391006886
72333+:102A50002407FFFF1047FF9F2404FFFF02002821E7
72334+:102A6000026020210E001A6A240600012410FFFFD4
72335+:102A70001050FF982404FFFF241400018F8D0044A0
72336+:102A8000026020210280302195A900342405000134
72337+:102A9000253200010E0019A9A5B200340000202142
72338+:102AA0008F8500380A001D320080A0218F90004CD5
72339+:102AB0003C1408008E9431B08E07001030E53FFFC3
72340+:102AC00000B4C82B132000618F8600502412FF80B1
72341+:102AD00090C9000D0249682431A400FF5080005CB9
72342+:102AE000026020218F8C00541180000700078B8228
72343+:102AF0008F8500388F82FCC094BF0080944A000A02
72344+:102B0000515F00F78F8600403227000314E0006415
72345+:102B100000000000920E000211C000D8000000006A
72346+:102B20008E0B0024156000D902602021920400035E
72347+:102B300024190002308500FF14B90005308900FF18
72348+:102B40008F940054128000EA240D002C308900FF7D
72349+:102B5000392C00102D8400012D3200010244302553
72350+:102B6000020028210E001A6A026020212410FFFFB3
72351+:102B7000105000BF8F8500388F830054106000D341
72352+:102B8000240500013C0A08008D4A318C0143F82BD2
72353+:102B900017E000B22402002D02602021000028214D
72354+:102BA0000E0019A9240600018F85003800001821A5
72355+:102BB0000A001D320060A0210E0018750000000000
72356+:102BC0000A001DF800000000AC8000200A001E78FA
72357+:102BD0008E03001400002821026020210E0019A994
72358+:102BE000240600010A001CC38F8500380A001DB7A7
72359+:102BF0008F8800388CAA00848CAC00843C031000C1
72360+:102C00000147F824001F91403189007F024968255F
72361+:102C100001A32825ACC50830910700012405000157
72362+:102C2000026020210E0019A930E600010A001CC331
72363+:102C30008F850038938F00482403FFFD0A001D3460
72364+:102C4000AF8F00600A001D342403FFFF02602021C3
72365+:102C50002410000D0E001A4AA390006800401821AD
72366+:102C60008F8500380A001D320060A0210E00187503
72367+:102C7000000000009783005C8F86006000402021E8
72368+:102C80003070FFFF00D010232C4A00051140FE11C8
72369+:102C90008F850038ACA400EC0A001D2F306EFFFFBA
72370+:102CA00090CF000D31E300085460FFA192040003AF
72371+:102CB00002602021240200100E001A4AA38200683C
72372+:102CC0002403FFFF5443FF9A920400030A001F12DB
72373+:102CD0008F85003890A4000D308F000811E000951A
72374+:102CE0008F990054572000A6026020218E1F000CEF
72375+:102CF0008CB4002057F40005026020218E0D0008DE
72376+:102D00008CA7002411A7003A026020212402002091
72377+:102D1000A38200680E001A4A2412FFFF1052FEED33
72378+:102D20002404FFFF8F9F00442402FFF73C14800E11
72379+:102D300093EA000D2419FF803C03800001423824EF
72380+:102D4000A3E7000D8F9F00303C0908008D2931ACAE
72381+:102D50008F8C006C97F200788F870044012C302113
72382+:102D6000324D7FFF000D204000C4782131E5007F07
72383+:102D700000B4C02101F94024AC68002CA711000068
72384+:102D80008CEB0028256E0001ACEE00288CEA002CAC
72385+:102D90008E02002C01426021ACEC002C8E09002C2C
72386+:102DA000ACE900308E120014ACF2003494ED003A1D
72387+:102DB00025A40001A4E4003A97E600783C1108003D
72388+:102DC0008E3131B024C3000130707FFF1211005CDE
72389+:102DD000006030218F8F0030026020212405000127
72390+:102DE0000E001934A5E600780A001EA1000020217B
72391+:102DF0008E0900142412FFFF1132006B8F8A0038F5
72392+:102E00008E0200188D4C00D0144C00650260202109
72393+:102E10008E0B00248CAE0028116E005B2402002172
72394+:102E20000E001A4AA38200681452FFBE2404FFFF5A
72395+:102E30008F8500380A001D320080A0212402001F67
72396+:102E40000E001A4AA38200682409FFFF1049FEA160
72397+:102E50002404FFFF0A001E548F83005402602021C7
72398+:102E60000E001A4AA38200681450FF508F85003864
72399+:102E70002403FFFF0A001D320060A0218CD800242B
72400+:102E80008E0800241118FF29026020210A001F2744
72401+:102E90002402000F8E0900003C05008001259024CB
72402+:102EA0001640FF492402001A026020210E001A4A2F
72403+:102EB000A3820068240CFFFF144CFECF2404FFFF04
72404+:102EC0008F8500380A001D320080A0210E001934C1
72405+:102ED000026020218F8500380A001EE500001821BD
72406+:102EE0002403FFFD0060A0210A001D32AF860060B0
72407+:102EF000026020210E001A4AA38D00682403FFFF00
72408+:102F00001043FF588F8500380A001ECC920400033E
72409+:102F10002418001D0E001A4AA39800682403FFFF1E
72410+:102F20001443FE9D2404FFFF8F8500380A001D32E4
72411+:102F30000080A021026020210A001F3D24020024FD
72412+:102F4000240880000068C024330BFFFF000B73C20D
72413+:102F500031D000FF001088270A001F6E001133C017
72414+:102F6000240F001B0E001A4AA38F00681451FEACF8
72415+:102F70002404FFFF8F8500380A001D320080A02145
72416+:102F80000A001F3D240200278E0600288CA3002C77
72417+:102F900010C30008026020210A001F812402001FC4
72418+:102FA0000A001F812402000E026020210A001F81F6
72419+:102FB000240200258E04002C1080000D8F8F00301D
72420+:102FC0008DE800740104C02B5700000C0260202122
72421+:102FD0008CB900140086A0210334282B10A0FF52C6
72422+:102FE0008F9F0044026020210A001F8124020022DA
72423+:102FF000026020210A001F81240200230A001F8191
72424+:103000002402002627BDFFD8AFB3001CAFB10014C7
72425+:10301000AFBF0020AFB20018AFB000103C0280007C
72426+:103020008C5201408C4B01483C048000000B8C0208
72427+:10303000322300FF317300FF8C8501B804A0FFFE2E
72428+:1030400034900180AE1200008C8701442464FFF0AC
72429+:10305000240600022C830013AE070004A61100080A
72430+:10306000A206000BAE1300241060004F8FBF00209B
72431+:10307000000448803C0A0801254A9534012A402171
72432+:103080008D04000000800008000000003C030800E0
72433+:103090008C6331A831693FFF00099980007280215B
72434+:1030A000021370212405FF80264D0100264C00806C
72435+:1030B0003C02800031B1007F3198007F31CA007F2F
72436+:1030C0003C1F800A3C1980043C0F800C01C5202461
72437+:1030D00001A5302401853824014F1821AC46002475
72438+:1030E000023F402103194821AC470090AC4400281E
72439+:1030F000AF830044AF880038AF8900300E0019005C
72440+:10310000016080213C0380008C6B01B80560FFFEEC
72441+:103110008F8700448F8600383465018090E8000D69
72442+:10312000ACB20000A4B0000600082600000416039C
72443+:1031300000029027001227C21080008124C200885C
72444+:10314000241F6082A4BF0008A0A000052402000282
72445+:10315000A0A2000B8F8B0030000424003C08270045
72446+:1031600000889025ACB20010ACA00014ACA00024E4
72447+:10317000ACA00028ACA0002C8D6900382413FF807F
72448+:10318000ACA9001890E3000D02638024320500FF13
72449+:1031900010A000058FBF002090ED000D31AC007F26
72450+:1031A000A0EC000D8FBF00208FB3001C8FB2001861
72451+:1031B0008FB100148FB000103C0A10003C0E80004C
72452+:1031C00027BD002803E00008ADCA01B8265F010052
72453+:1031D0002405FF8033F8007F3C06800003E5782457
72454+:1031E0003C19800A03192021ACCF0024908E00D412
72455+:1031F00000AE682431AC00FF11800024AF84003899
72456+:10320000248E008895CD00123C0C08008D8C31A8CE
72457+:1032100031AB3FFF01924821000B5180012A402130
72458+:1032200001052024ACC400283107007F3C06800C37
72459+:1032300000E620219083000D00A31024304500FFFC
72460+:1032400010A0FFD8AF8400449098000D330F0010F9
72461+:1032500015E0FFD58FBF00200E0019000000000010
72462+:103260003C0380008C7901B80720FFFE00000000BD
72463+:10327000AE1200008C7F0144AE1F0004A6110008AE
72464+:1032800024110002A211000BAE1300243C1308010C
72465+:10329000927396F0327000015200FFC38FBF00207E
72466+:1032A0000E002146024020210A0020638FBF00202B
72467+:1032B0003C1260008E452C083C03F0033462FFFF93
72468+:1032C00000A2F824AE5F2C088E582C083C1901C0CF
72469+:1032D00003199825AE532C080A0020638FBF0020E5
72470+:1032E000264D010031AF007F3C10800A240EFF8084
72471+:1032F00001F0282101AE60243C0B8000AD6C00245D
72472+:103300001660FFA8AF85003824110003A0B100FCAF
72473+:103310000A0020638FBF002026480100310A007F89
72474+:103320003C0B800A2409FF80014B30210109202435
72475+:103330003C078000ACE400240A002062AF8600381D
72476+:10334000944E0012320C3FFF31CD3FFF15ACFF7D94
72477+:10335000241F608290D900D42418FF800319782498
72478+:1033600031EA00FF1140FF7700000000240700044D
72479+:10337000A0C700FC8F870044241160842406000D40
72480+:10338000A4B10008A0A600050A00204D24020002F6
72481+:103390003C040001248496DC24030014240200FE73
72482+:1033A0003C010800AC2431EC3C010800AC2331E8BE
72483+:1033B0003C010801A42296F83C040801248496F8F4
72484+:1033C0000000182100643021A0C300042463000120
72485+:1033D0002C6500FF54A0FFFC006430213C0708006E
72486+:1033E00024E7010003E00008AF87007800A058211F
72487+:1033F000008048210000102114A00012000050217C
72488+:103400000A002142000000003C010801A42096F8B7
72489+:103410003C05080194A596F88F8200783C0C0801C1
72490+:10342000258C96F800E2182100AC2021014B302BAE
72491+:10343000A089000400001021A460000810C0003919
72492+:10344000010048218F8600780009384000E94021BA
72493+:103450000008388000E6282190A8000B90B9000AE7
72494+:103460000008204000881021000218800066C0215A
72495+:10347000A319000A8F85007800E5782191EE000AF3
72496+:1034800091E6000B000E684001AE6021000C208028
72497+:1034900000851021A046000B3C030801906396F2C2
72498+:1034A000106000222462FFFF8F8300383C01080176
72499+:1034B000A02296F2906C00FF118000040000000032
72500+:1034C000906E00FF25CDFFFFA06D00FF3C190801A5
72501+:1034D000973996F8272300013078FFFF2F0F00FF60
72502+:1034E00011E0FFC9254A00013C010801A42396F818
72503+:1034F0003C05080194A596F88F8200783C0C0801E1
72504+:10350000258C96F800E2182100AC2021014B302BCD
72505+:10351000A089000400001021A460000814C0FFC9A5
72506+:103520000100482103E000080000000003E000085B
72507+:103530002402000227BDFFE0248501002407FF804C
72508+:10354000AFB00010AFBF0018AFB1001400A718242F
72509+:103550003C10800030A4007F3C06800A00862821B1
72510+:103560008E110024AE03002490A200FF1440000836
72511+:10357000AF850038A0A000098FBF0018AE1100244D
72512+:103580008FB100148FB0001003E0000827BD0020A9
72513+:1035900090A900FD90A800FF312400FF0E0020F448
72514+:1035A000310500FF8F8500388FBF0018A0A00009EB
72515+:1035B000AE1100248FB100148FB0001003E000089A
72516+:1035C00027BD002027BDFFD0AFB20020AFB1001C47
72517+:1035D000AFB00018AFBF002CAFB40028AFB30024C9
72518+:1035E0003C0980009533011635320C00952F011AE5
72519+:1035F0003271FFFF023280218E08000431EEFFFF9E
72520+:10360000248B0100010E6821240CFF8025A5FFFFFB
72521+:10361000016C50243166007F3C07800AAD2A0024EB
72522+:1036200000C73021AF850074AF8800703C010801ED
72523+:10363000A02096F190C300090200D02100809821BB
72524+:10364000306300FF2862000510400048AF86003854
72525+:10365000286400021480008E24140001240D00054B
72526+:103660003C010801A02D96D590CC00FD3C0108013D
72527+:10367000A02096D63C010801A02096D790CB000A46
72528+:10368000240AFF80318500FF014B4824312700FFC9
72529+:1036900010E0000C000058213C12800836510080D8
72530+:1036A0008E2F00308CD0005C01F0702305C0018E9D
72531+:1036B0008F87007090D4000A3284007FA0C4000A73
72532+:1036C0008F8600383C118008363000808E0F003025
72533+:1036D0008F87007000EF702319C000EE000000001B
72534+:1036E00090D4000924120002328400FF1092024795
72535+:1036F000000000008CC2005800E2F82327F9FFFF09
72536+:103700001B2001300000000090C5000924080004BF
72537+:1037100030A300FF10680057240A00013C01080193
72538+:10372000A02A96D590C900FF252700013C01080179
72539+:10373000A02796D43C030801906396D52406000583
72540+:103740001066006A2C780005130000C40000902168
72541+:103750000003F8803C0408012484958003E4C82118
72542+:103760008F25000000A0000800000000241800FFC2
72543+:103770001078005C0000000090CC000A90CA00099C
72544+:103780003C080801910896F13187008000EA48253D
72545+:103790003C010801A02996DC90C500FD3C140801FD
72546+:1037A000929496F2311100013C010801A02596DDAA
72547+:1037B00090DF00FE3C010801A03F96DE90D200FFA2
72548+:1037C0003C010801A03296DF8CD900543C0108016D
72549+:1037D000AC3996E08CD000583C010801AC3096E43E
72550+:1037E0008CC3005C3C010801AC3496EC3C01080140
72551+:1037F000AC2396E8162000088FBF002C8FB4002859
72552+:103800008FB300248FB200208FB1001C8FB000183E
72553+:1038100003E0000827BD00303C1180009624010E13
72554+:103820000E000FD43094FFFF3C0B08018D6B96F413
72555+:103830000260382102802821AE2B01803C13080150
72556+:103840008E7396D401602021240600830E00102F71
72557+:10385000AFB300108FBF002C8FB400288FB30024AB
72558+:103860008FB200208FB1001C8FB0001803E0000859
72559+:1038700027BD00303C1808008F1831FC270F0001CD
72560+:103880003C010800AC2F31FC0A0021D700000000E9
72561+:103890001474FFB900000000A0C000FF3C05080040
72562+:1038A0008CA531E43C0308008C6331E03C02080045
72563+:1038B0008C4232048F99003834A80001241F000282
72564+:1038C0003C010801AC2396F43C010801A02896F0C5
72565+:1038D0003C010801A02296F3A33F00090A002190B1
72566+:1038E0008F8600380E002146000000000A0021D714
72567+:1038F0008F8600383C1F080193FF96D424190001DD
72568+:1039000013F902298F8700703C100801921096D895
72569+:103910003C06080190C696D610C000050200A02102
72570+:103920003C040801908496D9109001E48F870078B8
72571+:10393000001088408F9F0078023048210009C8801D
72572+:10394000033F702195D80008270F0001A5CF00087C
72573+:103950003C040801908496D93C05080190A596D6B0
72574+:103960000E0020F4000000008F8700780230202134
72575+:103970000004308000C720218C8500048F820074F1
72576+:1039800000A2402305020006AC8200048C8A0000DD
72577+:103990008F830070014310235C400001AC83000062
72578+:1039A0008F86003890CB00FF2D6C00025580002DD3
72579+:1039B000241400010230F821001F40800107282153
72580+:1039C00090B9000B8CAE00040019C0400319782197
72581+:1039D000000F1880006710218C4D000001AE882375
72582+:1039E0002630FFFF5E00001F241400018C440004F9
72583+:1039F0008CAA0000008A482319200019240E000414
72584+:103A00003C010801A02E96D590AD000B8CAB0004B4
72585+:103A1000000D8840022D80210010108000471021E9
72586+:103A20008C44000401646023058202009443000872
72587+:103A300090DF00FE90B9000B33E500FF54B900049D
72588+:103A40000107A021A0D400FE8F8700780107A021E4
72589+:103A50009284000B0E0020F4240500018F860038AC
72590+:103A600024140001125400962E500001160000424A
72591+:103A70003C08FFFF241900021659FF3F0000000018
72592+:103A8000A0C000FF8F860038A0D200090A0021D70D
72593+:103A90008F86003890C700092404000230E300FF3D
72594+:103AA0001064016F24090004106901528F880074AA
72595+:103AB0008CCE0054010E682325B10001062001754B
72596+:103AC000241800043C010801A03896D53C010801E7
72597+:103AD000A02096D490D400FD90D200FF2E4F00027B
72598+:103AE00015E0FF14328400FF000438408F8900780D
72599+:103AF00090DF00FF00E41021000220800089C8212F
72600+:103B00002FE500029324000B14A0FF0A24070002F3
72601+:103B100000041840006480210010588001692821A9
72602+:103B20008CAC0004010C50230540FF020000000093
72603+:103B30003C030801906396D614600005246F0001D1
72604+:103B40003C010801A02496D93C010801A02796D782
72605+:103B50003C010801A02F96D690CE00FF24E700017B
72606+:103B600031CD00FF01A7882B1220FFE990A4000BA4
72607+:103B70000A0021C6000000003C0508018CA596D46F
72608+:103B80003C12000400A8F82413F2000624020005E9
72609+:103B90003C090801912996D5152000022402000352
72610+:103BA000240200053C010801A02296F190C700FF05
72611+:103BB00014E0012024020002A0C200090A0021D75B
72612+:103BC0008F86003890CC00FF1180FEDA240A0001B5
72613+:103BD0008F8C00748F890078240F00030180682186
72614+:103BE0001160001E240E0002000540400105A021C6
72615+:103BF00000142080008990218E51000401918023BF
72616+:103C00000600FECC000000003C020801904296D65F
72617+:103C100014400005245800013C010801A02A96D751
72618+:103C20003C010801A02596D93C010801A03896D690
72619+:103C300090DF00FF010510210002C88033E500FF7E
72620+:103C4000254A00010329202100AA402B1500FEB9B6
72621+:103C50009085000B1560FFE50005404000054040E1
72622+:103C600001051821000310803C010801A02A96D408
72623+:103C70003C010801A02596D8004918218C64000455
72624+:103C800000E4F82327F9FFFF1F20FFE900000000F0
72625+:103C90008C63000000E358230560013A01A38823E8
72626+:103CA00010E301170184C0231B00FEA200000000E6
72627+:103CB0003C010801A02E96D50A002305240B000123
72628+:103CC000240E0004A0CE00093C0D08008DAD31F893
72629+:103CD0008F86003825A200013C010800AC2231F893
72630+:103CE0000A0021D7000000008CD9005C00F9C02335
72631+:103CF0001F00FE7B000000008CDF005C10FFFF65F2
72632+:103D00008F8400748CC3005C008340232502000173
72633+:103D10001C40FF60000000008CC9005C248700018B
72634+:103D200000E9282B10A0FE943C0D80008DAB01040F
72635+:103D30003C0C0001016C50241140FE8F2402001045
72636+:103D40003C010801A02296F10A0021D700000000E2
72637+:103D50008F9100748F86003826220001ACC2005C6F
72638+:103D60000A002292241400018F8700382404FF8067
72639+:103D70000000882190E9000A241400010124302564
72640+:103D8000A0E6000A3C05080190A596D63C0408016F
72641+:103D9000908496D90E0020F4000000008F86003831
72642+:103DA0008F85007890C800FD310700FF0007404074
72643+:103DB0000107F821001FC0800305C8219323000BD1
72644+:103DC000A0C300FD8F8500788F8600380305602131
72645+:103DD000918F000B000F704001CF6821000D808093
72646+:103DE000020510218C4B0000ACCB00548D840004E4
72647+:103DF0008F83007400645023194000022482000164
72648+:103E00002462000101074821ACC2005C0009308037
72649+:103E100000C5402100E02021240500010E0020F40F
72650+:103E20009110000B8F86003890C500FF10A0FF0C8A
72651+:103E3000001070408F85007801D06821000D10803F
72652+:103E4000004558218D6400008F8C0074018450233C
72653+:103E50002547000104E0FF02263100013C03080170
72654+:103E6000906396D62E2F0002247800013C010801B1
72655+:103E7000A03896D63C010801A03496D711E0FEF890
72656+:103E8000020038210A002365000740408F84003873
72657+:103E90008F8300748C85005800A340230502FE9A8E
72658+:103EA000AC8300580A00223B000000003C070801D8
72659+:103EB00090E796F2240200FF10E200BE8F860038E1
72660+:103EC0003C110801963196FA3C030801246396F8E8
72661+:103ED000262500013230FFFF30ABFFFF02036021D7
72662+:103EE0002D6A00FF1540008D918700043C010801F8
72663+:103EF000A42096FA8F88003800074840012728211F
72664+:103F0000911800FF000530802405000127140001EE
72665+:103F1000A11400FF3C120801925296F28F8800789B
72666+:103F20008F8E0070264F000100C820213C0108013F
72667+:103F3000A02F96F2AC8E00008F8D0074A48500082F
72668+:103F4000AC8D00043C030801906396D414600077A4
72669+:103F5000000090213C010801A02596D4A087000B09
72670+:103F60008F8C007800CC5021A147000A8F82003846
72671+:103F7000A04700FD8F840038A08700FE8F860038A0
72672+:103F80008F9F0070ACDF00548F990074ACD900583B
72673+:103F90008F8D00780127C02100185880016DA02165
72674+:103FA000928F000A000F704001CF18210003888013
72675+:103FB000022D8021A207000B8F8600780166602108
72676+:103FC000918A000B000A1040004A2021000428803A
72677+:103FD00000A64021A107000A3C07800834E90080C0
72678+:103FE0008D2200308F860038ACC2005C0A0022921D
72679+:103FF0002414000190CA00FF1540FEAD8F880074A4
72680+:10400000A0C400090A0021D78F860038A0C000FD97
72681+:104010008F98003824060001A30000FE3C0108012F
72682+:10402000A02696D53C010801A02096D40A0021C6FE
72683+:104030000000000090CB00FF3C040801908496F340
72684+:10404000316C00FF0184502B1540000F2402000347
72685+:1040500024020004A0C200090A0021D78F8600387C
72686+:1040600090C3000A2410FF8002035824316C00FF23
72687+:104070001180FDC1000000003C010801A02096D580
72688+:104080000A0021C600000000A0C200090A0021D7D2
72689+:104090008F86003890D4000A2412FF8002544824EE
72690+:1040A000312800FF1500FFF4240200083C0108013C
72691+:1040B000A02296F10A0021D70000000000108840DD
72692+:1040C0008F8B0070023018210003688001A7202127
72693+:1040D000AC8B00008F8A0074240C0001A48C0008B3
72694+:1040E000AC8A00043C05080190A596D62402000184
72695+:1040F00010A2FE1E24A5FFFF0A0022519084000B8F
72696+:104100000184A0231A80FD8B000000003C010801FF
72697+:10411000A02E96D50A002305240B00013C010801BE
72698+:10412000A42596FA0A0023B78F880038240B0001D3
72699+:10413000106B00228F9800388F85003890BF00FFE9
72700+:1041400033F900FF1079002B000000003C1F08012C
72701+:1041500093FF96D8001FC840033FC0210018A080DD
72702+:104160000288782191EE000AA08E000A8F8D0078D7
72703+:104170003C030801906396D800CD88210A0023DD16
72704+:10418000A223000B263000010600003101A4902379
72705+:104190000640002B240200033C010801A02F96D505
72706+:1041A0000A002305240B00018F8900380A00223BF6
72707+:1041B000AD2700540A00229124120001931400FD3F
72708+:1041C000A094000B8F8800388F8F0078910E00FE2E
72709+:1041D00000CF6821A1AE000A8F910038A22700FD10
72710+:1041E0008F8300708F900038AE0300540A0023DEE6
72711+:1041F0008F8D007890B000FEA090000A8F8B003861
72712+:104200008F8C0078916A00FD00CC1021A04A000B31
72713+:104210008F840038A08700FE8F8600748F85003859
72714+:10422000ACA600580A0023DE8F8D007894B80008F1
72715+:10423000ACA40004030378210A002285A4AF00087F
72716+:104240003C010801A02296D50A0021C6000000000A
72717+:1042500090CF0009240D000431EE00FF11CDFD8543
72718+:10426000240200013C010801A02296D50A0021C6C3
72719+:1042700000000000080033440800334408003420E4
72720+:10428000080033F4080033D8080033280800332826
72721+:10429000080033280800334C8008010080080080A3
72722+:1042A000800800005F865437E4AC62CC50103A4579
72723+:1042B00036621985BF14C0E81BC27A1E84F4B55655
72724+:1042C000094EA6FE7DDA01E7C04D748108005A74DC
72725+:1042D00008005AB808005A5C08005A5C08005A5C8A
72726+:1042E00008005A5C08005A7408005A5C08005A5CBE
72727+:1042F00008005AC008005A5C080059D408005A5CEB
72728+:1043000008005A5C08005AC008005A5C08005A5C51
72729+:1043100008005A5C08005A5C08005A5C08005A5CA5
72730+:1043200008005A5C08005A5C08005A5C08005A5C95
72731+:1043300008005A9408005A5C08005A9408005A5C15
72732+:1043400008005A5C08005A5C08005A9808005A9401
72733+:1043500008005A5C08005A5C08005A5C08005A5C65
72734+:1043600008005A5C08005A5C08005A5C08005A5C55
72735+:1043700008005A5C08005A5C08005A5C08005A5C45
72736+:1043800008005A5C08005A5C08005A5C08005A5C35
72737+:1043900008005A5C08005A5C08005A5C08005A5C25
72738+:1043A00008005A9808005A9808005A5C08005A9861
72739+:1043B00008005A5C08005A5C08005A5C08005A5C05
72740+:1043C00008005A5C08005A5C08005A5C08005A5CF5
72741+:1043D00008005A5C08005A5C08005A5C08005A5CE5
72742+:1043E00008005A5C08005A5C08005A5C08005A5CD5
72743+:1043F00008005A5C08005A5C08005A5C08005A5CC5
72744+:1044000008005A5C08005A5C08005A5C08005A5CB4
72745+:1044100008005A5C08005A5C08005A5C08005A5CA4
72746+:1044200008005A5C08005A5C08005A5C08005A5C94
72747+:1044300008005A5C08005A5C08005A5C08005A5C84
72748+:1044400008005A5C08005A5C08005A5C08005A5C74
72749+:1044500008005A5C08005A5C08005A5C08005A5C64
72750+:1044600008005A5C08005A5C08005A5C08005A5C54
72751+:1044700008005A5C08005A5C08005A5C08005A5C44
72752+:1044800008005A5C08005A5C08005A5C08005A5C34
72753+:1044900008005A5C08005A5C08005A5C08005A5C24
72754+:1044A00008005A5C08005A5C08005A5C08005A5C14
72755+:1044B00008005A5C08005A5C08005A5C08005A5C04
72756+:1044C00008005A5C08005A5C08005A5C08005ADC74
72757+:1044D0000800782C08007A900800783808007628C0
72758+:1044E00008007838080078C4080078380800762872
72759+:1044F0000800762808007628080076280800762824
72760+:104500000800762808007628080076280800762813
72761+:1045100008007628080078580800784808007628AF
72762+:1045200008007628080076280800762808007628F3
72763+:1045300008007628080076280800762808007628E3
72764+:1045400008007628080076280800762808007848B1
72765+:10455000080082FC08008188080082C40800818865
72766+:104560000800829408008070080081880800818813
72767+:1045700008008188080081880800818808008188F7
72768+:1045800008008188080081880800818808008188E7
72769+:104590000800818808008188080081B008008D34F7
72770+:1045A00008008E9008008E70080088D808008D4C96
72771+:1045B0000A00012400000000000000000000000DBF
72772+:1045C000747061362E322E31620000000602010145
72773+:1045D00000000000000000000000000000000000DB
72774+:1045E00000000000000000000000000000000000CB
72775+:1045F00000000000000000000000000000000000BB
72776+:1046000000000000000000000000000000000000AA
72777+:10461000000000000000000000000000000000009A
72778+:10462000000000000000000000000000000000008A
72779+:10463000000000000000000000000000000000007A
72780+:104640000000000010000003000000000000000D4A
72781+:104650000000000D3C020800244217203C03080023
72782+:1046600024632A10AC4000000043202B1480FFFD7F
72783+:10467000244200043C1D080037BD2FFC03A0F0219C
72784+:104680003C100800261004903C1C0800279C1720B2
72785+:104690000E000262000000000000000D2402FF80F6
72786+:1046A00027BDFFE000821024AFB00010AF42002011
72787+:1046B000AFBF0018AFB10014936500043084007FD1
72788+:1046C000034418213C0200080062182130A5002094
72789+:1046D000036080213C080111277B000814A0000220
72790+:1046E0002466005C2466005892020004974301048B
72791+:1046F000920400043047000F3063FFFF3084004015
72792+:10470000006728231080000900004821920200055C
72793+:1047100030420004104000050000000010A000031B
72794+:104720000000000024A5FFFC2409000492020005FB
72795+:1047300030420004104000120000000010A00010E1
72796+:10474000000000009602000200A72021010440257D
72797+:104750002442FFFEA7421016920300042402FF80A9
72798+:1047600000431024304200FF104000033C020400CC
72799+:104770000A000174010240258CC20000AF421018EB
72800+:104780008F4201780440FFFE2402000AA742014044
72801+:1047900096020002240400093042000700021023A0
72802+:1047A00030420007A7420142960200022442FFFE67
72803+:1047B000A7420144A740014697420104A74201488D
72804+:1047C0008F420108304200205040000124040001C3
72805+:1047D00092020004304200101440000234830010A2
72806+:1047E00000801821A743014A0000000000000000DB
72807+:1047F0000000000000000000AF48100000000000B2
72808+:104800000000000000000000000000008F421000C7
72809+:104810000441FFFE3102FFFF1040000700000000CE
72810+:1048200092020004304200401440000300000000E7
72811+:104830008F421018ACC20000960200063042FFFF03
72812+:10484000244200020002104300021040036288214B
72813+:10485000962200001120000D3044FFFF00A7102118
72814+:104860008F8300388F45101C0002108200021080D8
72815+:1048700000431021AC45000030A6FFFF0E00058D5F
72816+:1048800000052C0200402021A62200009203000413
72817+:104890002402FF8000431024304200FF1040001F1C
72818+:1048A0000000000092020005304200021040001B90
72819+:1048B000000000009742100C2442FFFEA742101691
72820+:1048C000000000003C02040034420030AF421000FF
72821+:1048D00000000000000000000000000000000000D8
72822+:1048E0008F4210000441FFFE000000009742100CB0
72823+:1048F0008F45101C3042FFFF24420030000210821E
72824+:1049000000021080005B1021AC45000030A6FFFFC4
72825+:104910000E00058D00052C02A62200009604000260
72826+:10492000248400080E0001E93084FFFF974401044D
72827+:104930000E0001F73084FFFF8FBF00188FB1001405
72828+:104940008FB000103C02100027BD002003E00008DB
72829+:10495000AF4201783084FFFF308200078F8500244A
72830+:1049600010400002248300073064FFF800A41021E7
72831+:1049700030421FFF03421821247B4000AF850028EE
72832+:10498000AF82002403E00008AF4200843084FFFFC0
72833+:104990003082000F8F85002C8F860034104000027B
72834+:1049A0002483000F3064FFF000A410210046182B70
72835+:1049B000AF8500300046202314600002AF82002C37
72836+:1049C000AF84002C8F82002C340480000342182115
72837+:1049D00000641821AF83003803E00008AF42008074
72838+:1049E0008F820014104000088F8200048F82FFDC49
72839+:1049F000144000058F8200043C02FFBF3442FFFFD9
72840+:104A0000008220248F82000430430006240200022A
72841+:104A10001062000F3C0201012C62000350400005AF
72842+:104A2000240200041060000F3C0200010A00023062
72843+:104A30000000000010620005240200061462000C51
72844+:104A40003C0201110A000229008210253C020011DB
72845+:104A500000821025AF421000240200010A0002303B
72846+:104A6000AF82000C00821025AF421000AF80000C16
72847+:104A700000000000000000000000000003E000084B
72848+:104A8000000000008F82000C1040000400000000B5
72849+:104A90008F4210000441FFFE0000000003E0000808
72850+:104AA000000000008F8200102443F800000231C291
72851+:104AB00024C2FFF02C6303011060000300021042C7
72852+:104AC0000A000257AC8200008F85001800C5102B29
72853+:104AD0001440000B0000182100C5102324470001DA
72854+:104AE0008F82001C00A210212442FFFF0046102BE1
72855+:104AF000544000042402FFFF0A000257AC87000064
72856+:104B00002402FFFF0A000260AC8200008C820000D9
72857+:104B10000002194000621821000318800062182169
72858+:104B2000000318803C0208002442175C0062182130
72859+:104B300003E000080060102127BDFFD8AFBF0020B0
72860+:104B4000AFB1001CAFB000183C0460088C8250006C
72861+:104B50002403FF7F3C066000004310243442380CDD
72862+:104B6000AC8250008CC24C1C3C1A80000002160221
72863+:104B70003042000F10400007AF82001C8CC34C1C59
72864+:104B80003C02001F3442FC0000621824000319C2DA
72865+:104B9000AF8300188F420008275B400034420001B9
72866+:104BA000AF420008AF8000243C02601CAF40008090
72867+:104BB000AF4000848C4500088CC308083402800094
72868+:104BC000034220212402FFF0006218243C020080EE
72869+:104BD0003C010800AC2204203C025709AF84003895
72870+:104BE00014620004AF850034240200010A0002921E
72871+:104BF000AF820014AF8000148F42000038420001E1
72872+:104C0000304200011440FFFC8F8200141040001657
72873+:104C10000000000097420104104000058F8300004F
72874+:104C2000146000072462FFFF0A0002A72C62000A3A
72875+:104C30002C620010504000048F83000024620001A9
72876+:104C4000AF8200008F8300002C62000A1440000332
72877+:104C50002C6200070A0002AEAF80FFDC10400002A9
72878+:104C600024020001AF82FFDC8F4301088F44010062
72879+:104C700030622000AF83000410400008AF840010B1
72880+:104C80003C0208008C42042C244200013C01080034
72881+:104C9000AC22042C0A00058A3C0240003065020068
72882+:104CA00014A0000324020F001482026024020D00ED
72883+:104CB00097420104104002C83C02400030624000AC
72884+:104CC000144000AD8F8200388C4400088F42017878
72885+:104CD0000440FFFE24020800AF42017824020008CD
72886+:104CE000A7420140A7400142974201048F8400047B
72887+:104CF0003051FFFF30820001104000070220802168
72888+:104D00002623FFFE240200023070FFFFA742014667
72889+:104D10000A0002DBA7430148A74001463C02080005
72890+:104D20008C42043C1440000D8F8300103082002020
72891+:104D30001440000224030009240300010060202124
72892+:104D40008F830010240209005062000134840004A3
72893+:104D5000A744014A0A0002F60000000024020F00E6
72894+:104D60001462000530820020144000062403000D68
72895+:104D70000A0002F524030005144000022403000980
72896+:104D800024030001A743014A3C0208008C4204208E
72897+:104D90003C0400480E00020C004420250E000235A1
72898+:104DA000000000008F82000C1040003E0000000058
72899+:104DB0008F4210003C0300200043102410400039B3
72900+:104DC0008F820004304200021040003600000000D4
72901+:104DD000974210141440003300000000974210085E
72902+:104DE0008F8800383042FFFF2442000600021882FC
72903+:104DF0000003388000E83021304300018CC40000FB
72904+:104E000010600004304200030000000D0A00033768
72905+:104E100000E81021544000103084FFFF3C05FFFFE4
72906+:104E200000852024008518260003182B0004102B71
72907+:104E300000431024104000050000000000000000A6
72908+:104E40000000000D00000000240002228CC20000BF
72909+:104E50000A000336004520253883FFFF0003182B86
72910+:104E60000004102B00431024104000050000000037
72911+:104E7000000000000000000D000000002400022BD4
72912+:104E80008CC200003444FFFF00E81021AC44000055
72913+:104E90003C0208008C420430244200013C0108001E
72914+:104EA000AC2204308F6200008F840038AF8200088B
72915+:104EB0008C8300003402FFFF1462000F00001021F9
72916+:104EC0003C0508008CA504543C0408008C84045064
72917+:104ED00000B0282100B0302B008220210086202144
72918+:104EE0003C010800AC2504543C010800AC240450EB
72919+:104EF0000A000580240400088C8200003042010072
72920+:104F00001040000F000010213C0508008CA5044C47
72921+:104F10003C0408008C84044800B0282100B0302BE9
72922+:104F200000822021008620213C010800AC25044C91
72923+:104F30003C010800AC2404480A0005802404000851
72924+:104F40003C0508008CA504443C0408008C84044003
72925+:104F500000B0282100B0302B0082202100862021C3
72926+:104F60003C010800AC2504443C010800AC2404408A
72927+:104F70000A000580240400088F6200088F62000088
72928+:104F800000021602304300F02402003010620005D7
72929+:104F900024020040106200E08F8200200A00058891
72930+:104FA0002442000114A000050000000000000000E1
72931+:104FB0000000000D00000000240002568F4201781E
72932+:104FC0000440FFFE000000000E00023D27A4001078
72933+:104FD0001440000500408021000000000000000D8A
72934+:104FE000000000002400025D8E0200001040000559
72935+:104FF00000000000000000000000000D00000000A4
72936+:10500000240002608F62000C0443000324020001AC
72937+:105010000A00042EAE000000AE0200008F820038AD
72938+:105020008C480008A20000078F65000C8F64000404
72939+:1050300030A3FFFF0004240200852023308200FFFC
72940+:105040000043102124420005000230832CC200815D
72941+:10505000A605000A14400005A20400040000000098
72942+:105060000000000D00000000240002788F85003849
72943+:105070000E0005AB260400148F6200048F43010864
72944+:10508000A60200083C02100000621824106000080C
72945+:105090000000000097420104920300072442FFEC45
72946+:1050A000346300023045FFFF0A0003C3A203000778
72947+:1050B000974201042442FFF03045FFFF96060008A6
72948+:1050C0002CC200135440000592030007920200070F
72949+:1050D00034420001A20200079203000724020001EB
72950+:1050E00010620005240200031062000B8F8200385A
72951+:1050F0000A0003E030C6FFFF8F8200383C04FFFF48
72952+:105100008C43000C0064182400651825AC43000C87
72953+:105110000A0003E030C6FFFF3C04FFFF8C43001091
72954+:105120000064182400651825AC43001030C6FFFF4A
72955+:1051300024C2000200021083A20200058F830038FF
72956+:10514000304200FF00021080004328218CA800009C
72957+:105150008CA2000024030004000217021443001272
72958+:1051600000000000974201043C03FFFF01031824E4
72959+:105170003042FFFF004610232442FFFE006240251C
72960+:10518000ACA8000092030005306200FF000210800E
72961+:1051900000501021904200143042000F00431021B3
72962+:1051A0000A000415A20200068CA400049742010420
72963+:1051B0009603000A3088FFFF3042FFFF00461023AD
72964+:1051C0002442FFD60002140001024025ACA80004CE
72965+:1051D000920200079204000524630028000318834C
72966+:1051E0000064182134420004A2030006A202000752
72967+:1051F0008F8200042403FFFB34420002004310248A
72968+:10520000AF820004920300068F87003800031880E5
72969+:10521000007010218C4400203C02FFF63442FFFF56
72970+:105220000082402400671821AE04000CAC68000C1A
72971+:10523000920500063C03FF7F8E02000C00052880CB
72972+:1052400000B020213463FFFF01033024948800263E
72973+:1052500000A7282100431024AE02000CAC860020D9
72974+:10526000AC880024ACA8001024020010A742014022
72975+:1052700024020002A7400142A7400144A742014680
72976+:10528000974201043C0400082442FFFEA742014863
72977+:10529000240200010E00020CA742014A9603000AF4
72978+:1052A0009202000400431021244200023042000711
72979+:1052B00000021023304200070E000235AE0200103B
72980+:1052C0008F6200003C0308008C6304442404001037
72981+:1052D000AF820008974201043042FFFF2442FFFEE4
72982+:1052E00000403821000237C33C0208008C420440D1
72983+:1052F000006718210067282B004610210045102167
72984+:105300003C010800AC2304443C010800AC220440EA
72985+:105310000A0005150000000014A0000500000000B0
72986+:10532000000000000000000D000000002400030A3F
72987+:105330008F4201780440FFFE000000000E00023D95
72988+:1053400027A4001414400005004080210000000044
72989+:105350000000000D00000000240003118E02000078
72990+:105360005440000692020007000000000000000DFB
72991+:10537000000000002400031C9202000730420004D9
72992+:10538000104000058F8200042403FFFB344200021A
72993+:1053900000431024AF8200048F620004044300081D
72994+:1053A00092020007920200068E03000CAE0000007D
72995+:1053B0000002108000501021AC4300209202000730
72996+:1053C00030420004544000099602000A920200058F
72997+:1053D0003C03000100021080005010218C46001890
72998+:1053E00000C33021AC4600189602000A9206000461
72999+:1053F000277100080220202100C2302124C60005A8
73000+:10540000260500140E0005AB00063082920400064B
73001+:105410008F6500043C027FFF000420800091202162
73002+:105420008C8300043442FFFF00A228240065182169
73003+:10543000AC8300049202000792040005920300046A
73004+:10544000304200041040001496070008308400FF2A
73005+:1054500000042080009120218C86000497420104E2
73006+:105460009605000A306300FF3042FFFF0043102121
73007+:105470000045102130E3FFFF004310232442FFD8F2
73008+:1054800030C6FFFF0002140000C23025AC860004C5
73009+:105490000A0004C992030007308500FF0005288038
73010+:1054A00000B128218CA4000097420104306300FF62
73011+:1054B0003042FFFF00431021004710233C03FFFF51
73012+:1054C000008320243042FFFF00822025ACA400008E
73013+:1054D0009203000724020001106200060000000091
73014+:1054E0002402000310620011000000000A0004EC16
73015+:1054F0008E03001097420104920300049605000AEF
73016+:105500008E24000C00431021004510212442FFF29C
73017+:105510003C03FFFF008320243042FFFF0082202550
73018+:10552000AE24000C0A0004EC8E0300109742010424
73019+:10553000920300049605000A8E24001000431021F7
73020+:10554000004510212442FFEE3C03FFFF008320248E
73021+:105550003042FFFF00822025AE2400108E03001091
73022+:105560002402000AA7420140A74301429603000A11
73023+:10557000920200043C04004000431021A742014471
73024+:10558000A740014697420104A742014824020001B6
73025+:105590000E00020CA742014A0E0002350000000076
73026+:1055A0008F6200009203000400002021AF820008F7
73027+:1055B000974201049606000A3042FFFF006218215C
73028+:1055C000006028213C0308008C6304443C0208006E
73029+:1055D0008C42044000651821004410210065382BDE
73030+:1055E000004710213C010800AC2304443C010800A2
73031+:1055F000AC22044092040004008620212484000A86
73032+:105600003084FFFF0E0001E9000000009744010410
73033+:105610003084FFFF0E0001F7000000003C02100084
73034+:10562000AF4201780A0005878F820020148200278C
73035+:105630003062000697420104104000673C024000BF
73036+:105640003062400010400005000000000000000033
73037+:105650000000000D00000000240004208F420178AB
73038+:105660000440FFFE24020800AF4201782402000833
73039+:10567000A7420140A74001428F82000497430104E2
73040+:1056800030420001104000073070FFFF2603FFFE8C
73041+:1056900024020002A7420146A74301480A00053F31
73042+:1056A0002402000DA74001462402000DA742014A32
73043+:1056B0008F62000024040008AF8200080E0001E998
73044+:1056C000000000000A0005190200202110400042DD
73045+:1056D0003C02400093620000304300F024020010BE
73046+:1056E0001062000524020070106200358F820020D5
73047+:1056F0000A000588244200018F62000097430104DC
73048+:105700003050FFFF3071FFFF8F4201780440FFFEF1
73049+:105710003202000700021023304200072403000A6F
73050+:105720002604FFFEA7430140A7420142A7440144CB
73051+:10573000A7400146A75101488F420108304200208E
73052+:10574000144000022403000924030001A743014A76
73053+:105750000E00020C3C0400400E0002350000000068
73054+:105760003C0708008CE70444021110212442FFFE8C
73055+:105770003C0608008CC604400040182100E3382194
73056+:10578000000010218F65000000E3402B00C2302193
73057+:105790002604000800C830213084FFFFAF850008D0
73058+:1057A0003C010800AC2704443C010800AC2604403E
73059+:1057B0000E0001E9000000000A0005190220202166
73060+:1057C0000E00013B000000008F82002024420001F7
73061+:1057D000AF8200203C024000AF4201380A00029232
73062+:1057E000000000003084FFFF30C6FFFF00052C00E2
73063+:1057F00000A628253882FFFF004510210045282BF0
73064+:105800000045102100021C023042FFFF004310211E
73065+:1058100000021C023042FFFF004310213842FFFF0C
73066+:1058200003E000083042FFFF3084FFFF30A5FFFF98
73067+:1058300000001821108000070000000030820001E5
73068+:105840001040000200042042006518210A0005A152
73069+:105850000005284003E000080060102110C0000689
73070+:1058600024C6FFFF8CA2000024A50004AC82000027
73071+:105870000A0005AB2484000403E0000800000000D7
73072+:1058800010A0000824A3FFFFAC8600000000000069
73073+:10589000000000002402FFFF2463FFFF1462FFFAF0
73074+:1058A0002484000403E00008000000000000000160
73075+:1058B0000A00002A00000000000000000000000DA7
73076+:1058C000747870362E322E3162000000060201001C
73077+:1058D00000000000000001360000EA600000000047
73078+:1058E00000000000000000000000000000000000B8
73079+:1058F00000000000000000000000000000000000A8
73080+:105900000000000000000000000000000000000097
73081+:105910000000001600000000000000000000000071
73082+:105920000000000000000000000000000000000077
73083+:105930000000000000000000000000000000000067
73084+:1059400000000000000000000000138800000000BC
73085+:10595000000005DC00000000000000001000000353
73086+:10596000000000000000000D0000000D3C020800D7
73087+:1059700024423D683C0308002463401CAC40000006
73088+:105980000043202B1480FFFD244200043C1D08002E
73089+:1059900037BD7FFC03A0F0213C100800261000A8B2
73090+:1059A0003C1C0800279C3D680E00044E00000000CF
73091+:1059B0000000000D27BDFFB4AFA10000AFA200049E
73092+:1059C000AFA30008AFA4000CAFA50010AFA6001451
73093+:1059D000AFA70018AFA8001CAFA90020AFAA0024F1
73094+:1059E000AFAB0028AFAC002CAFAD0030AFAE003491
73095+:1059F000AFAF0038AFB8003CAFB90040AFBC004417
73096+:105A0000AFBF00480E000591000000008FBF0048A6
73097+:105A10008FBC00448FB900408FB8003C8FAF003876
73098+:105A20008FAE00348FAD00308FAC002C8FAB0028D0
73099+:105A30008FAA00248FA900208FA8001C8FA7001810
73100+:105A40008FA600148FA500108FA4000C8FA3000850
73101+:105A50008FA200048FA1000027BD004C3C1B6004F6
73102+:105A60008F7A5030377B502803400008AF7A00000F
73103+:105A70008F86003C3C0390003C0280000086282575
73104+:105A800000A32025AC4400203C0380008C6700204C
73105+:105A900004E0FFFE0000000003E00008000000003A
73106+:105AA0000A000070240400018F85003C3C04800043
73107+:105AB0003483000100A3102503E00008AC8200201D
73108+:105AC00003E00008000010213084FFFF30A5FFFF35
73109+:105AD00010800007000018213082000110400002F1
73110+:105AE00000042042006518211480FFFB00052840B7
73111+:105AF00003E000080060102110C000070000000053
73112+:105B00008CA2000024C6FFFF24A50004AC82000084
73113+:105B100014C0FFFB2484000403E000080000000020
73114+:105B200010A0000824A3FFFFAC86000000000000C6
73115+:105B3000000000002402FFFF2463FFFF1462FFFA4D
73116+:105B40002484000403E000080000000090AA003153
73117+:105B50008FAB00108CAC00403C0300FF8D6800044C
73118+:105B6000AD6C00208CAD004400E060213462FFFF8A
73119+:105B7000AD6D00248CA700483C09FF000109C0243A
73120+:105B8000AD6700288CAE004C0182C824031978252B
73121+:105B9000AD6F0004AD6E002C8CAD0038314A00FFB3
73122+:105BA000AD6D001C94A900323128FFFFAD680010D4
73123+:105BB00090A70030A5600002A1600004A16700006A
73124+:105BC00090A30032306200FF0002198210600005CD
73125+:105BD000240500011065000E0000000003E000082D
73126+:105BE000A16A00018CD80028354A0080AD780018E1
73127+:105BF0008CCF0014AD6F00148CCE0030AD6E000859
73128+:105C00008CC4002CA16A000103E00008AD64000C04
73129+:105C10008CCD001CAD6D00188CC90014AD6900144A
73130+:105C20008CC80024AD6800088CC70020AD67000C4C
73131+:105C30008CC200148C8300700043C82B1320000713
73132+:105C4000000000008CC20014144CFFE400000000AF
73133+:105C5000354A008003E00008A16A00018C820070D0
73134+:105C60000A0000E6000000009089003027BDFFF820
73135+:105C70008FA8001CA3A900008FA300003C0DFF808B
73136+:105C800035A2FFFF8CAC002C00625824AFAB0000A3
73137+:105C9000A100000400C05821A7A000028D06000446
73138+:105CA00000A048210167C8218FA500000080502175
73139+:105CB0003C18FF7F032C20263C0E00FF2C8C00019B
73140+:105CC000370FFFFF35CDFFFF3C02FF0000AFC824B8
73141+:105CD00000EDC02400C27824000C1DC003236825F9
73142+:105CE00001F87025AD0D0000AD0E00048D240024D8
73143+:105CF000AFAD0000AD0400088D2C00202404FFFF90
73144+:105D0000AD0C000C9547003230E6FFFFAD060010E9
73145+:105D10009145004830A200FF000219C25060000106
73146+:105D20008D240034AD0400148D4700388FAA00186C
73147+:105D300027BD0008AD0B0028AD0A0024AD07001CEC
73148+:105D4000AD00002CAD00001803E00008AD000020FD
73149+:105D500027BDFFE0AFB20018AFB10014AFB0001024
73150+:105D6000AFBF001C9098003000C088213C0D00FFA0
73151+:105D7000330F007FA0CF0000908E003135ACFFFFC5
73152+:105D80003C0AFF00A0CE000194A6001EA220000441
73153+:105D90008CAB00148E29000400A08021016C282403
73154+:105DA000012A40240080902101052025A62600021A
73155+:105DB000AE24000426050020262400080E000092D0
73156+:105DC00024060002924700302605002826240014ED
73157+:105DD00000071E000003160324060004044000030D
73158+:105DE0002403FFFF965900323323FFFF0E00009279
73159+:105DF000AE230010262400248FBF001C8FB2001891
73160+:105E00008FB100148FB00010240500030000302172
73161+:105E10000A00009C27BD002027BDFFD8AFB1001CA1
73162+:105E2000AFB00018AFBF002090A9003024020001DD
73163+:105E300000E050213123003F00A040218FB00040FE
73164+:105E40000080882100C04821106200148FA700380C
73165+:105E5000240B000500A0202100C02821106B001396
73166+:105E6000020030210E000128000000009225007C75
73167+:105E700030A400021080000326030030AE00003082
73168+:105E8000260300348FBF00208FB1001C8FB0001894
73169+:105E90000060102103E0000827BD00280E0000A7C5
73170+:105EA000AFB000100A00016F000000008FA3003C9B
73171+:105EB000010020210120282101403021AFA3001042
73172+:105EC0000E0000EEAFB000140A00016F00000000E9
73173+:105ED0003C06800034C20E008C4400108F850044C4
73174+:105EE000ACA400208C43001803E00008ACA30024FD
73175+:105EF0003C06800034C20E008C4400148F850044A0
73176+:105F0000ACA400208C43001C03E00008ACA30024D8
73177+:105F10009382000C1040001B2483000F2404FFF028
73178+:105F20000064382410E00019978B00109784000E4D
73179+:105F30009389000D3C0A601C0A0001AC01644023F7
73180+:105F400001037021006428231126000231C2FFFFE3
73181+:105F500030A2FFFF0047302B50C0000E00E4482164
73182+:105F60008D4D000C31A3FFFF00036400000C2C03D7
73183+:105F700004A1FFF30000302130637FFF0A0001A479
73184+:105F80002406000103E00008000000009784000ED2
73185+:105F900000E448213123FFFF3168FFFF0068382B00
73186+:105FA00054E0FFF8A783000E938A000D114000050E
73187+:105FB000240F0001006BC023A380000D03E0000844
73188+:105FC000A798000E006BC023A38F000D03E000080C
73189+:105FD000A798000E03E000080000000027BDFFE8BE
73190+:105FE000AFB000103C10800036030140308BFFFF43
73191+:105FF00093AA002BAFBF0014A46B000436040E005C
73192+:106000009488001630C600FF8FA90030A4680006EF
73193+:10601000AC650008A0660012A46A001AAC670020F4
73194+:106020008FA5002CA4690018012020210E000198E2
73195+:10603000AC6500143C021000AE0201788FBF001462
73196+:106040008FB0001003E0000827BD00188F85000006
73197+:106050002484000727BDFFF83084FFF83C06800049
73198+:1060600094CB008A316AFFFFAFAA00008FA900001D
73199+:10607000012540232507FFFF30E31FFF0064102B9D
73200+:106080001440FFF700056882000D288034CC4000E2
73201+:1060900000AC102103E0000827BD00088F8200003B
73202+:1060A0002486000730C5FFF800A2182130641FFFC6
73203+:1060B00003E00008AF8400008F87003C8F84004419
73204+:1060C00027BDFFB0AFB70044AFB40038AFB1002C6C
73205+:1060D000AFBF0048AFB60040AFB5003CAFB300342F
73206+:1060E000AFB20030AFB000283C0B80008C8600249B
73207+:1060F000AD6700808C8A002035670E00356901008D
73208+:10610000ACEA00108C8800248D2500040000B82122
73209+:10611000ACE800188CE3001000A688230000A02142
73210+:10612000ACE300148CE20018ACE2001C122000FE6C
73211+:1061300000E0B021936C0008118000F40000000022
73212+:10614000976F001031EEFFFF022E682B15A000EFB5
73213+:1061500000000000977200103250FFFFAED0000028
73214+:106160003C0380008C740000329300081260FFFD35
73215+:106170000000000096D800088EC700043305FFFF1A
73216+:1061800030B5000112A000E4000000000000000D86
73217+:1061900030BFA0402419004013F9011B30B4A00007
73218+:1061A000128000DF000000009373000812600008F6
73219+:1061B00000000000976D001031ACFFFF00EC202BB9
73220+:1061C0001080000330AE004011C000D50000000078
73221+:1061D000A7850040AF87003893630008022028217C
73222+:1061E000AFB10020146000F527B40020AF60000CB0
73223+:1061F000978F004031F14000162000022403001662
73224+:106200002403000E24054007A363000AAF650014B1
73225+:10621000938A00428F70001431550001001512401E
73226+:1062200002024825AF690014979F00408F78001440
73227+:1062300033F9001003194025AF680014979200400D
73228+:106240003247000810E0016E000000008F67001464
73229+:106250003C1210003C11800000F27825AF6F001452
73230+:1062600036230E00946E000A3C0D81002406000EB9
73231+:1062700031CCFFFF018D2025AF640004A36600022E
73232+:106280009373000A3406FFFC266B0004A36B000A1C
73233+:1062900097980040330820001100015F00000000C3
73234+:1062A0003C05800034A90E00979900409538000CF9
73235+:1062B00097870040001940423312C00031030003A9
73236+:1062C00000127B0330F11000006F6825001172038B
73237+:1062D00001AE6025000C20C0A76400129793004017
73238+:1062E000936A000A001359823175003C02AA1021FA
73239+:1062F0002450003CA3700009953F000C33F93FFF88
73240+:10630000A779001097700012936900090130F821F5
73241+:1063100027E5000230B900070019C0233308000741
73242+:10632000A368000B9371000997720012976F001019
73243+:10633000322700FF8F910038978D004000F218211E
73244+:10634000006F702101C6602131A6004010C0000519
73245+:106350003185FFFF00B1102B3C1280001040001768
73246+:10636000000098210225A82B56A0013E8FA50020F1
73247+:106370003C048000348A0E008D5300143C068000DB
73248+:10638000AD5300108D4B001CAD4B0018AD45000007
73249+:106390008CCD000031AC00081180FFFD34CE0E0022
73250+:1063A00095C3000800A0882100009021A783004029
73251+:1063B0008DC6000424130001AF860038976F0010CB
73252+:1063C00031F5FFFF8E9F000003F1282310A0011F6D
73253+:1063D000AE85000093620008144000DD000000005C
73254+:1063E0000E0001E7240400108F900048004028218F
73255+:1063F0003C023200320600FF000654000142F8253C
73256+:1064000026090001AF890048ACBF0000937900095C
73257+:1064100097780012936F000A332800FF3303FFFFC1
73258+:106420000103382100076C0031EE00FF01AE60254A
73259+:10643000ACAC00048F840048978B0040316A200088
73260+:106440001140010AACA4000897640012308BFFFFD2
73261+:1064500006400108ACAB000C978E004031C5000827
73262+:1064600014A0000226280006262800023C1F8000F7
73263+:1064700037E70E0094F900148CE5001C8F670004C8
73264+:10648000937800023324FFFF330300FFAFA3001013
73265+:106490008F6F0014AFA800180E0001CBAFAF00142F
73266+:1064A000240400100E0001FB000000008E9200008A
73267+:1064B00016400005000000008F7800142403FFBF81
73268+:1064C0000303A024AF7400148F67000C00F5C821EB
73269+:1064D000AF79000C9375000816A0000800000000BA
73270+:1064E00012600006000000008F6800143C0AEFFFF5
73271+:1064F0003549FFFE0109F824AF7F0014A37300089B
73272+:106500008FA500200A00034F02202021AED10000F9
73273+:106510000A00022D3C03800014E0FF1E30BFA040A3
73274+:106520000E0001900000A0212E9100010237B0253D
73275+:1065300012C000188FBF00488F87003C24170F003F
73276+:1065400010F700D43C0680008CD901780720FFFEAC
73277+:10655000241F0F0010FF00F634CA0E008D560014E1
73278+:1065600034C7014024080240ACF600048D49001CE9
73279+:106570003C141000ACE90008A0E00012A4E0001AEE
73280+:10658000ACE00020A4E00018ACE80014ACD4017822
73281+:106590008FBF00488FB700448FB600408FB5003CD6
73282+:1065A0008FB400388FB300348FB200308FB1002C1D
73283+:1065B0008FB0002803E0000827BD00508F910038FD
73284+:1065C000978800403C1280000220A821310700403B
73285+:1065D00014E0FF7C00009821977900108F9200381A
73286+:1065E0003338FFFF131200A8000020210080A021F3
73287+:1065F000108000F300A088211620FECE00000000CD
73288+:106600000A00031F2E9100013C0380008C62017878
73289+:106610000440FFFE240808008F860000AC68017863
73290+:106620003C038000946D008A31ACFFFF0186582343
73291+:10663000256AFFFF31441FFF2C8900081520FFF950
73292+:10664000000000008F8F0048347040008F83003CB2
73293+:1066500000E0A021240E0F0025E70001AF870048CD
73294+:1066600000D03021023488233C08800031F500FF3F
73295+:10667000106E0005240700019398004233130001B7
73296+:106680000013924036470001001524003C0A010027
73297+:10669000008A4825ACC900008F82004830BF003610
73298+:1066A00030B90008ACC200041320009900FF9825FF
73299+:1066B00035120E009650000A8F8700003C0F8100B3
73300+:1066C0003203FFFF24ED000835060140006F60250E
73301+:1066D0003C0E100031AB1FFF269200062405000E71
73302+:1066E000ACCC0020026E9825A4C5001AAF8B000028
73303+:1066F000A4D20018162000083C1080008F89003CAE
73304+:1067000024020F00512200022417000136730040BA
73305+:106710000E0001883C10800036060E008CCB001461
73306+:10672000360A014002402021AD4B00048CC5001CFC
73307+:10673000AD450008A1550012AD5300140E0001989C
73308+:106740003C151000AE1501780A000352000000004D
73309+:10675000936F0009976E0012936D000B31E500FFF7
73310+:1067600000AE202131AC00FF008C80212602000AFF
73311+:106770003050FFFF0E0001E7020020218F86004805
73312+:106780003C0341003C05800024CB0001AF8B004856
73313+:10679000936A00099769001230C600FF315F00FF5D
73314+:1067A0003128FFFF03E8382124F900020006C40065
73315+:1067B0000319782501E37025AC4E00008F6D000CA5
73316+:1067C00034A40E00948B001401B26025AC4C00047C
73317+:1067D0008C85001C8F670004936A00023164FFFF00
73318+:1067E000314900FFAFA900108F680014AFB1001845
73319+:1067F0000E0001CBAFA800140A0002FD0200202108
73320+:10680000AF600004A36000029798004033082000A6
73321+:106810001500FEA300003021A760001297840040FD
73322+:10682000936B000A3C10800030931F0000135183CB
73323+:10683000014BA82126A20028A362000936090E00F8
73324+:10684000953F000C0A000295A77F00108F7000147E
73325+:10685000360900400E000188AF6900140A0002C921
73326+:10686000000000000A00034F000020210641FEFA4C
73327+:10687000ACA0000C8CAC000C3C0D8000018D902570
73328+:106880000A0002EAACB2000C000090210A0002C526
73329+:1068900024130001128000073C028000344B0E00DC
73330+:1068A0009566000830D300401260004900000000E7
73331+:1068B0003C0680008CD001780600FFFE34C50E0037
73332+:1068C00094B500103C03050034CC014032B8FFFF02
73333+:1068D00003039025AD92000C8CAF0014240D200012
73334+:1068E0003C041000AD8F00048CAE001CAD8E00087F
73335+:1068F000A1800012A580001AAD800020A58000189C
73336+:10690000AD8D0014ACC401780A0003263C0680005B
73337+:106910008F9F0000351801402692000227F90008D9
73338+:1069200033281FFFA71200180A000391AF88000048
73339+:106930003C02800034450140ACA0000C1280001BDA
73340+:1069400034530E0034510E008E370010ACB70004E3
73341+:106950008E2400183C0B8000ACA400083570014068
73342+:1069600024040040A20000128FBF0048A600001AB5
73343+:106970008FB70044AE0000208FB60040A60000187C
73344+:106980008FB5003CAE0400148FB400388FB30034D0
73345+:106990008FB200308FB1002C8FB000283C02100065
73346+:1069A00027BD005003E00008AD6201788E66001438
73347+:1069B000ACA600048E64001C0A00042A3C0B800074
73348+:1069C0000E0001902E9100010A0003200237B0252D
73349+:1069D000000000000000000D00000000240003691A
73350+:1069E0000A0004013C06800027BDFFD8AFBF00208D
73351+:1069F0003C0980003C1F20FFAFB200183C0760003C
73352+:106A000035320E002402001037F9FFFDACE23008E9
73353+:106A1000AFB3001CAFB10014AFB00010AE5900000E
73354+:106A20000000000000000000000000000000000066
73355+:106A3000000000003C1800FF3713FFFDAE530000BC
73356+:106A40003C0B60048D7050002411FF7F3C0E00024F
73357+:106A50000211782435EC380C35CD0109ACED4C1819
73358+:106A6000240A0009AD6C50008CE80438AD2A0008F7
73359+:106A7000AD2000148CE54C1C3106FFFF38C42F718B
73360+:106A800000051E023062000F2486C0B310400007CC
73361+:106A9000AF8200088CE54C1C3C09001F3528FC0027
73362+:106AA00000A81824000321C2AF8400048CF1080858
73363+:106AB0003C0F57092412F0000232702435F0001008
73364+:106AC00001D0602601CF68262DAA00012D8B000180
73365+:106AD000014B382550E00009A380000C3C1F601CCE
73366+:106AE0008FF8000824190001A399000C33137C00CF
73367+:106AF000A7930010A780000EA380000DAF80004870
73368+:106B000014C00003AF8000003C066000ACC0442C01
73369+:106B10000E0005B93C1080000E000F1A361101005E
73370+:106B20003C12080026523DD03C13080026733E500C
73371+:106B30008E03000038640001308200011440FFFC25
73372+:106B40003C0B800A8E2600002407FF8024C90240E7
73373+:106B5000312A007F014B402101272824AE06002066
73374+:106B6000AF880044AE0500243C048000AF86003CA2
73375+:106B70008C8C01780580FFFE24180800922F0008F5
73376+:106B8000AC980178A38F0042938E004231CD000172
73377+:106B900011A0000F24050D0024DFF8002FF90301D8
73378+:106BA0001320001C000629C224A4FFF00004104298
73379+:106BB000000231400E00020200D2D8213C02400007
73380+:106BC0003C068000ACC201380A0004A000000000AE
73381+:106BD00010C50023240D0F0010CD00273C1F800896
73382+:106BE00037F9008093380000240E0050330F00FF67
73383+:106BF00015EEFFF33C0240000E000A3600000000D4
73384+:106C00003C0240003C068000ACC201380A0004A0EF
73385+:106C1000000000008F83000400A3402B1500000B30
73386+:106C20008F8B0008006B50212547FFFF00E5482BA4
73387+:106C30001520000600A36023000C19400E0002027C
73388+:106C40000073D8210A0004C43C0240000000000D7B
73389+:106C50000E000202000000000A0004C43C024000D2
73390+:106C60003C1B0800277B3F500E0002020000000082
73391+:106C70000A0004C43C0240003C1B0800277B3F7014
73392+:106C80000E000202000000000A0004C43C024000A2
73393+:106C90003C0660043C09080025290104ACC9502CBD
73394+:106CA0008CC850003C0580003C0200023507008083
73395+:106CB000ACC750003C040800248415A43C03080021
73396+:106CC0002463155CACA50008ACA2000C3C010800D4
73397+:106CD000AC243D603C010800AC233D6403E00008A7
73398+:106CE0002402000100A030213C1C0800279C3D68C4
73399+:106CF0003C0C04003C0B0002008B3826008C402624
73400+:106D00002CE200010007502B2D050001000A4880ED
73401+:106D10003C03080024633D60004520250123182121
73402+:106D20001080000300001021AC6600002402000166
73403+:106D300003E00008000000003C1C0800279C3D68A0
73404+:106D40003C0B04003C0A0002008A3026008B3826E7
73405+:106D50002CC200010006482B2CE5000100094080F0
73406+:106D60003C03080024633D600045202501031821F1
73407+:106D700010800005000010213C0C0800258C155CDB
73408+:106D8000AC6C00002402000103E0000800000000D9
73409+:106D90003C0900023C08040000883026008938269F
73410+:106DA0002CC30001008028212CE400010083102561
73411+:106DB0001040000B000030213C1C0800279C3D685F
73412+:106DC0003C0A80008D4E00082406000101CA682597
73413+:106DD000AD4D00088D4C000C01855825AD4B000CC5
73414+:106DE00003E0000800C010213C1C0800279C3D68FF
73415+:106DF0003C0580008CA6000C000420272402000122
73416+:106E000000C4182403E00008ACA3000C3C020002FC
73417+:106E10001082000B3C0560003C0704001087000353
73418+:106E20000000000003E00008000000008CA908D06A
73419+:106E3000240AFFFD012A402403E00008ACA808D082
73420+:106E40008CA408D02406FFFE0086182403E0000866
73421+:106E5000ACA308D03C05601A34A600108CC3008097
73422+:106E600027BDFFF88CC50084AFA3000093A40000E9
73423+:106E70002402000110820003AFA5000403E0000813
73424+:106E800027BD000893A7000114E0001497AC00028E
73425+:106E900097B800023C0F8000330EFFFC01CF682141
73426+:106EA000ADA50000A3A000003C0660008CC708D080
73427+:106EB0002408FFFE3C04601A00E82824ACC508D072
73428+:106EC0008FA300048FA200003499001027BD000892
73429+:106ED000AF22008003E00008AF2300843C0B800059
73430+:106EE000318AFFFC014B48218D2800000A00057DF6
73431+:106EF000AFA8000427BDFFE8AFBF00103C1C08008E
73432+:106F0000279C3D683C0580008CA4000C8CA20004EA
73433+:106F10003C0300020044282410A0000A00A3182407
73434+:106F20003C0604003C0400021460000900A6102482
73435+:106F30001440000F3C0404000000000D3C1C08003D
73436+:106F4000279C3D688FBF001003E0000827BD001894
73437+:106F50003C0208008C423D600040F809000000003F
73438+:106F60003C1C0800279C3D680A0005A68FBF001046
73439+:106F70003C0208008C423D640040F809000000001B
73440+:106F80000A0005AC00000000000411C003E0000886
73441+:106F9000244202403C04080024843FB42405001A23
73442+:106FA0000A00009C0000302127BDFFE0AFB00010B8
73443+:106FB0003C108000AFBF0018AFB1001436110100C3
73444+:106FC000922200090E0005B63044007F8E3F00007B
73445+:106FD0008F89003C3C0F008003E26021258800403F
73446+:106FE0000049F821240DFF80310E00783198007897
73447+:106FF00035F9000135F100020319382501D1482582
73448+:10700000010D302403ED5824018D2824240A00406A
73449+:1070100024040080240300C0AE0B0024AE0008103E
73450+:10702000AE0A0814AE040818AE03081CAE05080426
73451+:10703000AE070820AE060808AE0908243609090084
73452+:107040009539000C3605098033ED007F3338FFFF9A
73453+:10705000001889C0AE110800AE0F0828952C000C4E
73454+:107060008FBF00188FB10014318BFFFF000B51C090
73455+:10707000AE0A002C8CA400508FB000108CA3003CF2
73456+:107080008D2700048CA8001C8CA600383C0E800ABA
73457+:1070900001AE102127BD0020AF820044AF84005014
73458+:1070A000AF830054AF87004CAF88005C03E000085A
73459+:1070B000AF8600603C09080091293FD924A800024E
73460+:1070C0003C05110000093C0000E8302500C51825EA
73461+:1070D00024820008AC83000003E00008AC800004B8
73462+:1070E0003C098000352309009128010B906A0011AA
73463+:1070F0002402002800804821314700FF00A07021B1
73464+:1071000000C068213108004010E20002340C86DD26
73465+:10711000240C08003C0A800035420A9A944700007B
73466+:10712000354B0A9C35460AA030F9FFFFAD39000007
73467+:107130008D780000354B0A8024040001AD3800042E
73468+:107140008CCF0000AD2F00089165001930A300031B
73469+:107150001064009028640002148000AF240500022F
73470+:107160001065009E240F0003106F00B435450AA47B
73471+:10717000240A0800118A0048000000005100003D68
73472+:107180003C0B80003C0480003483090090670012AF
73473+:1071900030E200FF004D7821000FC8802724000155
73474+:1071A0003C0A8000354F090091E50019354C0980F3
73475+:1071B0008D87002830A300FF0003150000475825E5
73476+:1071C0000004C4003C19600001793025370806FF2F
73477+:1071D000AD260000AD2800048DEA002C25280028EB
73478+:1071E000AD2A00088DEC0030AD2C000C8DE500348C
73479+:1071F000AD2500108DE400383C05800034AC093C1E
73480+:10720000AD2400148DE3001CAD2300188DE7002091
73481+:10721000AD27001C8DE20024AD2200208DF900284E
73482+:1072200034A20100AD3900248D830000AD0E0004AE
73483+:1072300034B90900AD0300008C47000C250200148E
73484+:10724000AD070008932B00123C04080090843FD83F
73485+:10725000AD000010317800FF030D302100064F0013
73486+:1072600000047C00012F702535CDFFFC03E00008F1
73487+:10727000AD0D000C35780900930600123C0508009E
73488+:1072800094A53FC830C800FF010D5021000A60805E
73489+:107290000A00063C018520211500005B000000006B
73490+:1072A0003C08080095083FCE3C06080094C63FC83D
73491+:1072B000010610213C0B800035790900933800113C
73492+:1072C000932A001935660A80330800FF94CF002AFC
73493+:1072D00000086082314500FF978A0058000C1E00AC
73494+:1072E000000524003047FFFF006410250047C0253B
73495+:1072F00001EA30213C0B4000030B402500066400EE
73496+:10730000AD280000AD2C0004932500183C030006B6
73497+:107310002528001400053E0000E31025AD220008DA
73498+:107320008F24002C3C05800034AC093CAD24000CBB
73499+:107330008F38001C34A20100254F0001AD38001029
73500+:107340008D830000AD0E000431EB7FFFAD03000024
73501+:107350008C47000C34B90900A78B0058AD07000812
73502+:10736000932B00123C04080090843FD8250200149F
73503+:10737000317800FF030D302100064F0000047C002F
73504+:10738000012F702535CDFFFCAD00001003E0000893
73505+:10739000AD0D000C3C02080094423FD23C050800B1
73506+:1073A00094A53FC835440AA43C07080094E73FC4AD
73507+:1073B000948B00000045C8210327C023000B1C004C
73508+:1073C0002706FFF200665025AD2A000CAD20001004
73509+:1073D000AD2C00140A00063025290018354F0AA4E8
73510+:1073E00095E50000956400280005140000043C00A9
73511+:1073F0003459810000EC5825AD39000CAD2B00103C
73512+:107400000A000630252900143C0C0800958C3FCE5C
73513+:107410000A000681258200015460FF56240A0800F4
73514+:1074200035580AA49706000000061C00006C502581
73515+:10743000AD2A000C0A000630252900103C03080084
73516+:1074400094633FD23C07080094E73FC83C0F080014
73517+:1074500095EF3FC494A4000095790028006710219F
73518+:10746000004F582300041C00001934002578FFEE5B
73519+:1074700000D87825346A8100AD2A000CAD2F0010A9
73520+:10748000AD200014AD2C00180A0006302529001C80
73521+:1074900003E00008240207D027BDFFE0AFB20018C8
73522+:1074A000AFB10014AFB00010AFBF001C0E00007CE5
73523+:1074B000008088218F8800548F87004C3C0580080D
73524+:1074C00034B20080011128213C1080002402008089
73525+:1074D000240300C000A72023AE0208183C06800841
73526+:1074E000AE03081C18800004AF850054ACC500042E
73527+:1074F0008CC90004AF89004C1220000936040980B1
73528+:107500000E0006F800000000924C00278E0B00745D
73529+:1075100001825004014B3021AE46000C3604098034
73530+:107520008C8E001C8F8F005C01CF682319A0000493
73531+:107530008FBF001C8C90001CAF90005C8FBF001CA4
73532+:107540008FB200188FB100148FB000100A00007EB7
73533+:1075500027BD00208F8600508F8300548F82004CFF
73534+:107560003C05800834A40080AC860050AC83003C0D
73535+:1075700003E00008ACA200043C0308008C63005444
73536+:1075800027BDFFF8308400FF2462000130A500FF12
73537+:107590003C010800AC22005430C600FF3C078000CC
73538+:1075A0008CE801780500FFFE3C0C7FFFA3A40003DC
73539+:1075B0008FAA0000358BFFFF014B4824000627C02F
73540+:1075C00001244025AFA8000034E201009043000AE6
73541+:1075D000A3A000023C1980FFA3A300018FAF00000D
73542+:1075E00030AE007F3738FFFF01F86024000E6E00D8
73543+:1075F0003C0A002034E50140018D58253549200022
73544+:107600002406FF803C04100027BD0008ACAB000C32
73545+:10761000ACA90014A4A00018A0A6001203E0000862
73546+:10762000ACE40178308800FF30A700FF3C03800005
73547+:107630008C6201780440FFFE3C0C8000358A0A0011
73548+:107640008D4B00203584014035850980AC8B0004CA
73549+:107650008D4900240007302B00061540AC89000836
73550+:10766000A088001090A3004CA083002D03E0000828
73551+:10767000A480001827BDFFE8308400FFAFBF0010D2
73552+:107680000E00075D30A500FF8F8300548FBF0010F0
73553+:107690003C06800034C50140344700402404FF907C
73554+:1076A0003C02100027BD0018ACA3000CA0A40012DF
73555+:1076B000ACA7001403E00008ACC2017827BDFFE0CE
73556+:1076C0003C088008AFBF001CAFB20018AFB1001477
73557+:1076D000AFB00010351000808E0600183C07800007
73558+:1076E000309200FF00C72025AE0400180E00007C79
73559+:1076F00030B100FF92030005346200080E00007EE6
73560+:10770000A2020005024020210E000771022028215C
73561+:10771000024020218FBF001C8FB200188FB10014CF
73562+:107720008FB0001024050005240600010A0007326E
73563+:1077300027BD00203C05800034A309809066000826
73564+:1077400030C200081040000F3C0A01013549080A08
73565+:10775000AC8900008CA80074AC8800043C070800C9
73566+:1077600090E73FD830E5001050A00008AC8000083A
73567+:107770003C0D800835AC00808D8B0058AC8B000828
73568+:107780002484000C03E00008008010210A0007B5E3
73569+:107790002484000C27BDFFE83C098000AFB0001036
73570+:1077A000AFBF00143526098090C8000924020006E6
73571+:1077B00000A05821310300FF3527090000808021F7
73572+:1077C000240500041062007B2408000294CF005CB2
73573+:1077D0003C0E020431EDFFFF01AE6025AE0C00004F
73574+:1077E00090CA00083144002010800008000000000A
73575+:1077F00090C2004E3C1F010337F90300305800FFD0
73576+:107800000319302524050008AE06000490F9001184
73577+:1078100090E6001290E40011333800FF00187082E7
73578+:1078200030CF00FF01CF5021014B6821308900FF8C
73579+:1078300031AAFFFF39230028000A60801460002C61
73580+:10784000020C482390E400123C198000372F0100FD
73581+:10785000308C00FF018B1821000310800045F821B7
73582+:10786000001F8400360706FFAD270004373F0900DC
73583+:1078700093EC001193EE0012372609800005C082B8
73584+:107880008DE4000C8CC5003431CD00FF01AB10211C
73585+:107890000058182100A4F8230008840000033F00CA
73586+:1078A00000F0302533F9FFFF318F00FC00D970253F
73587+:1078B0000158202101E9682100045080ADAE000C80
73588+:1078C0000E00007C012A80213C088008240B000463
73589+:1078D000350500800E00007EA0AB000902001021DB
73590+:1078E0008FBF00148FB0001003E0000827BD001800
73591+:1078F00090EC001190E300193C18080097183FCE57
73592+:10790000318200FF0002F882307000FF001FCE00BD
73593+:1079100000103C000327302500D870253C0F4000A4
73594+:1079200001CF68253C198000AD2D0000373F0900CC
73595+:1079300093EC001193EE0012372F010037260980D7
73596+:107940000005C0828DE4000C8CC5003431CD00FFF1
73597+:1079500001AB10210058182100A4F823000884006E
73598+:1079600000033F0000F0302533F9FFFF318F00FCAA
73599+:1079700000D970250158202101E9682100045080B8
73600+:10798000ADAE000C0E00007C012A80213C0880086E
73601+:10799000240B0004350500800E00007EA0AB00091A
73602+:1079A000020010218FBF00148FB0001003E0000808
73603+:1079B00027BD00180A0007C72408001227BDFFD002
73604+:1079C0003C038000AFB60028AFB50024AFB4002060
73605+:1079D000AFB10014AFBF002CAFB3001CAFB20018A2
73606+:1079E000AFB000103467010090E6000B309400FF48
73607+:1079F00030B500FF30C200300000B02110400099C7
73608+:107A000000008821346409809088000800082E0056
73609+:107A100000051E03046000C0240400048F86005487
73610+:107A20003C010800A0243FD83C0C8000AD800048F9
73611+:107A30003C048000348E010091CD000B31A5002064
73612+:107A400010A000073C078000349309809272000860
73613+:107A50000012860000107E0305E000C43C1F800871
73614+:107A600034EC0100918A000B34EB09809169000825
73615+:107A7000314400400004402B3123000800C8982303
73616+:107A80001460000224120003000090213C108000CA
73617+:107A900036180A8036040900970E002C90830011D6
73618+:107AA0009089001293050018307F00FF312800FFF5
73619+:107AB000024810210002C880930D0018033F78216E
73620+:107AC00001F1302130B100FF00D11821A78E0058FC
73621+:107AD0003C010800A4263FCE3C010800A4233FD06F
73622+:107AE00015A00002000000000000000D920B010B29
73623+:107AF0003065FFFF3C010800A4233FD2316A0040FB
73624+:107B00003C010800A4203FC83C010800A4203FC459
73625+:107B10001140000224A4000A24A4000B3091FFFFAE
73626+:107B20000E0001E7022020219206010B3C0C080008
73627+:107B3000958C3FD2004020210006698231A70001C8
73628+:107B40000E00060101872821004020210260282123
73629+:107B50000E00060C024030210E0007A1004020213B
73630+:107B600016C00069004020219212010B32560040DD
73631+:107B700012C000053C0500FF8C93000034AEFFFFEF
73632+:107B8000026E8024AC9000000E0001FB0220202138
73633+:107B90003C0F080091EF3FD831F10003122000168E
73634+:107BA0003C1380088F8200543C09800835280080EF
73635+:107BB000245F0001AD1F003C3C0580088CB9000427
73636+:107BC00003E02021033FC0231B000002AF9F0054AD
73637+:107BD0008CA400040E0006F8ACA400043C0780004E
73638+:107BE0008CEB00743C04800834830080004B5021EF
73639+:107BF000AC6A000C3C1380083670008002802021A3
73640+:107C000002A02821A200006B0E00075D3C1480003A
73641+:107C10008F920054368C0140AD92000C8F86004844
73642+:107C20003C151000344D000624D60001AF960048E4
73643+:107C30008FBF002CA18600128FB60028AD8D0014D6
73644+:107C40008FB3001CAE9501788FB200188FB5002459
73645+:107C50008FB400208FB100148FB0001003E0000833
73646+:107C600027BD003034640980908F0008000F760033
73647+:107C7000000E6E0305A00033347F090093F8001B4B
73648+:107C8000241900103C010800A0393FD8331300022A
73649+:107C90001260FF678F8600548F8200601446FF6574
73650+:107CA0003C0480000E00007C000000003C048008C2
73651+:107CB0003485008090A8000924060016310300FFD7
73652+:107CC0001066000D0000000090AB00093C070800A2
73653+:107CD00090E73FD824090008316400FF34EA00012E
73654+:107CE0003C010800A02A3FD81089002F240C000A6C
73655+:107CF000108C00282402000C0E00007E0000000002
73656+:107D00000A0008608F8600540E0007B9024028213F
73657+:107D10000A0008AE004020213C0B8008356A008034
73658+:107D20008D4600548CE9000C1120FF3DAF860054B5
73659+:107D3000240700143C010800A0273FD80A00085F70
73660+:107D40003C0C800090910008241200023C010800C5
73661+:107D5000A0323FD8323000201200000B2416000160
73662+:107D60008F8600540A0008602411000837F800804C
73663+:107D70008F020038AFE200048FF90004AF19003C15
73664+:107D80000A00086C3C0780008F8600540A000860D7
73665+:107D900024110004A0A200090E00007E00000000D3
73666+:107DA0000A0008608F860054240200140A00093A71
73667+:107DB000A0A2000927BDFFE8AFB000103C10800072
73668+:107DC000AFBF001436020100904400090E00075DA9
73669+:107DD000240500013C0480089099000E3483008043
73670+:107DE000909F000F906F00269089000A33F800FFE3
73671+:107DF00000196E000018740031EC00FF01AE502530
73672+:107E0000000C5A00014B3825312800FF3603014091
73673+:107E10003445600000E830252402FF813C04100056
73674+:107E2000AC66000C8FBF0014AC650014A062001299
73675+:107E3000AE0401788FB0001003E0000827BD0018E1
73676+:107E400027BDFFE8308400FFAFBF00100E00075DC4
73677+:107E500030A500FF3C05800034A4014034470040B9
73678+:107E60002406FF92AC870014A08600128F83005472
73679+:107E70008FBF00103C02100027BD0018AC83000C1F
73680+:107E800003E00008ACA2017827BDFFD8AFB0001016
73681+:107E9000308400FF30B000FF3C058000AFB100141B
73682+:107EA000AFBF0020AFB3001CAFB20018000410C277
73683+:107EB00034A60100320300023051000114600007B3
73684+:107EC00090D200093C098008353300809268000593
73685+:107ED0003107000810E0000C308A00100240202119
73686+:107EE0000E00078302202821240200018FBF0020FA
73687+:107EF0008FB3001C8FB200188FB100148FB0001028
73688+:107F000003E0000827BD00281540003434A50A000E
73689+:107F10008CB800248CAF0008130F004B00003821F0
73690+:107F20003C0D800835B30080926C00682406000286
73691+:107F3000318B00FF116600843C06800034C20100D2
73692+:107F40009263004C90590009307F00FF53F9000400
73693+:107F50003213007C10E00069000000003213007C46
73694+:107F60005660005C0240202116200009320D0001FD
73695+:107F70003C0C800035840100358B0A008D6500249F
73696+:107F80008C86000414A6FFD900001021320D0001D8
73697+:107F900011A0000E024020213C1880003710010083
73698+:107FA0008E0F000C8F8E005011EE000800000000B4
73699+:107FB0000E000843022028218E19000C3C1F800867
73700+:107FC00037F00080AE190050024020210E000771EA
73701+:107FD000022028210A00098F240200013C05080024
73702+:107FE0008CA5006424A400013C010800AC240064BA
73703+:107FF0001600000D00000000022028210E0007716D
73704+:1080000002402021926E0068240C000231CD00FF56
73705+:1080100011AC0022024020210E00094100000000A6
73706+:108020000A00098F240200010E00007024040001E0
73707+:10803000926B0025020B30250E00007EA266002503
73708+:108040000A0009D3022028218E6200188CDF000468
73709+:108050008CB9002400021E0217F9FFB13065007FC1
73710+:108060009268004C264400013093007F1265004066
73711+:10807000310300FF1464FFAB3C0D8008264700016C
73712+:1080800030F1007F30E200FF1225000B24070001D1
73713+:10809000004090210A00099C2411000124050004DD
73714+:1080A0000E000732240600010E0009410000000006
73715+:1080B0000A00098F240200012405FF8002452024C4
73716+:1080C00000859026324200FF004090210A00099C62
73717+:1080D000241100010E00084302202821320700303D
73718+:1080E00010E0FFA132100082024020210E00078321
73719+:1080F000022028210A00098F240200018E6900183D
73720+:108100000240202102202821012640250E0009647A
73721+:10811000AE6800189264004C240500032406000198
73722+:108120000E000732308400FF0E00007024040001AE
73723+:1081300092710025021150250E00007EA26A0025D2
73724+:108140000A00098F240200018E6F00183C1880007D
73725+:108150000240202101F87025022028210E0007711D
73726+:10816000AE6E00189264004C0A000A1B240500043D
73727+:10817000324A0080394900801469FF6A3C0D80084A
73728+:108180000A0009F42647000127BDFFC0AFB0001860
73729+:108190003C108000AFBF0038AFB70034AFB600303E
73730+:1081A000AFB5002CAFB40028AFB30024AFB20020AD
73731+:1081B0000E0005BEAFB1001C360201009045000B59
73732+:1081C0000E00097690440008144000E78FBF003885
73733+:1081D0003C08800835070080A0E0006B3606098067
73734+:1081E00090C50000240300503C17080026F73F907C
73735+:1081F00030A400FF3C13080026733FA01083000347
73736+:108200003C1080000000B82100009821241F0010BD
73737+:108210003611010036120A00361509808E580024E6
73738+:108220008E3400048EAF00208F8C00543C01080077
73739+:10823000A03F3FD836190A80972B002C8EF60000FD
73740+:10824000932A00180298702301EC68233C0108006F
73741+:10825000AC2E3FB43C010800AC2D3FB83C010800F7
73742+:10826000AC2C3FDCA78B005802C0F809315400FF4A
73743+:1082700030490002152000E930420001504000C49E
73744+:108280009227000992A90008312800081500000271
73745+:10829000241500030000A8213C0A80003543090092
73746+:1082A00035440A008C8D00249072001190700012E9
73747+:1082B000907F0011325900FF321100FF02B11021EE
73748+:1082C0000002C08033EF00FF0319B021028F70213C
73749+:1082D00002D4602125CB00103C010800A4363FCE1B
73750+:1082E0003C010800AC2D3FE03C010800A42C3FD02D
73751+:1082F0003C010800A42B3FCC3556010035540980C1
73752+:1083000035510E008F8700548F89005C8E850020C8
73753+:1083100024080006012730233C010800AC283FD484
73754+:1083200000A7282304C000B50000902104A000B3DA
73755+:1083300000C5502B114000B5000000003C010800B2
73756+:10834000AC263FB88E6200000040F8090000000033
73757+:108350003046000214C0007400408021304B000100
73758+:10836000556000118E6200043C0D08008DAD3FBCCD
73759+:108370003C0EC0003C04800001AE6025AE2C000025
73760+:108380008C980000330F000811E0FFFD0000000092
73761+:10839000963F000824120001A79F00408E39000478
73762+:1083A000AF9900388E6200040040F8090000000018
73763+:1083B0000202802532030002146000B300000000B6
73764+:1083C0003C09080095293FC43C06080094C63FD0EC
73765+:1083D0003C0A0800954A3FC63C0708008CE73FBCB2
73766+:1083E000012670213C0308008C633FE03C08080034
73767+:1083F00095083FDA01CA20218ED9000C00E9282116
73768+:10840000249F000200A878210067C02133E4FFFF09
73769+:10841000AF9900503C010800AC383FE03C01080037
73770+:10842000A42F3FC83C010800A42E3FD20E0001E754
73771+:10843000000000008F8D0048004020213C01080012
73772+:10844000A02D3FD98E62000825AC0001AF8C0048FA
73773+:108450000040F809000000008F85005402A0302180
73774+:108460000E00060C004020210E0007A10040202134
73775+:108470008E6B000C0160F809004020213C0A0800C6
73776+:10848000954A3FD23C06080094C63FC601464821A3
73777+:10849000252800020E0001FB3104FFFF3C05080007
73778+:1084A0008CA53FB43C0708008CE73FBC00A7202305
73779+:1084B0003C010800AC243FB414800006000000001A
73780+:1084C0003C0208008C423FD4344B00403C01080081
73781+:1084D000AC2B3FD4124000438F8E00448E2D0010F1
73782+:1084E0008F920044AE4D00208E2C0018AE4C00241C
73783+:1084F0003C04080094843FC80E0006FA0000000007
73784+:108500008F9F00548E6700103C010800AC3F3FDC99
73785+:1085100000E0F809000000003C1908008F393FB462
73786+:108520001720FF798F870054979300583C11800ED5
73787+:10853000321601000E000729A633002C16C0004594
73788+:10854000320300105460004C8EE5000432080040F5
73789+:108550005500001D8EF000088EE4000C0080F80924
73790+:10856000000000008FBF00388FB700348FB6003096
73791+:108570008FB5002C8FB400288FB300248FB2002059
73792+:108580008FB1001C8FB0001803E0000827BD004029
73793+:108590008F86003C36110E0000072E0000A6202515
73794+:1085A000AE0400808E4300208E500024AFA3001044
73795+:1085B000AE2300148FB20010AE320010AE30001C9B
73796+:1085C0000A000A75AE3000180200F8090000000029
73797+:1085D0008EE4000C0080F809000000000A000B2E59
73798+:1085E0008FBF003824180001240F0001A5C000200F
73799+:1085F000A5D800220A000B10ADCF00243C010800D2
73800+:10860000AC203FB80A000AA68E6200003C010800B8
73801+:10861000AC253FB80A000AA68E6200009224000929
73802+:108620000E000771000028218FBF00388FB700347B
73803+:108630008FB600308FB5002C8FB400288FB3002484
73804+:108640008FB200208FB1001C8FB0001803E000082B
73805+:1086500027BD00403C1480009295010900002821AC
73806+:108660000E00084332A400FF320300105060FFB830
73807+:10867000320800408EE5000400A0F8090000000068
73808+:108680000A000B28320800405240FFA89793005878
73809+:108690008E3400148F930044AE7400208E35001C7D
73810+:1086A000AE7500240A000B1F979300588F820014A8
73811+:1086B0000004218003E00008008210213C078008AC
73812+:1086C00034E200809043006900804021106000097E
73813+:1086D0003C0401003C0708008CE73FDC8F8300303E
73814+:1086E00000E32023048000089389001C14E30003A6
73815+:1086F0000100202103E00008008010213C0401005B
73816+:1087000003E00008008010211120000B00673823CF
73817+:108710003C0D800035AC0980918B007C316A0002F1
73818+:10872000114000202409003400E9702B15C0FFF12E
73819+:108730000100202100E938232403FFFC00A3C82402
73820+:1087400000E3C02400F9782B15E0FFEA030820219C
73821+:1087500030C400030004102314C000143049000387
73822+:108760000000302100A9782101E6702100EE682B7D
73823+:1087700011A0FFE03C0401002D3800010006C82BC9
73824+:10878000010548210319382414E0FFDA2524FFFCF1
73825+:108790002402FFFC00A218240068202103E0000846
73826+:1087A000008010210A000B9E240900303C0C800040
73827+:1087B0003586098090CB007C316A00041540FFE9C2
73828+:1087C000240600040A000BAD000030213C03080021
73829+:1087D0008C63005C8F82001827BDFFE0AFBF0018DC
73830+:1087E000AFB1001410620005AFB00010000329C043
73831+:1087F00024A40280AF840014AF8300183C108000D2
73832+:1088000036020A0094450032361101000E000B7F3B
73833+:1088100030A43FFF8E240000241FFF803C11008005
73834+:108820000082C021031F60243309007F000CC9406F
73835+:1088300003294025330E0078362F00033C0D10002D
73836+:10884000010D502501CF5825AE0C002836080980AF
73837+:10885000AE0C080CAE0B082CAE0A08309103006970
73838+:108860003C06800C0126382110600006AF870034DA
73839+:108870008D09003C8D03006C0123382318E0008231
73840+:10888000000000003C0B8008356A00803C1080002E
73841+:10889000A1400069360609808CC200383C06800081
73842+:1088A00034C50A0090A8003C310C00201180001A49
73843+:1088B000AF820030240D00013C0E800035D10A004B
73844+:1088C000A38D001CAF8000248E2400248F850024FB
73845+:1088D000240D0008AF800020AF8000283C01080074
73846+:1088E000A42D3FC63C010800A4203FDA0E000B83F4
73847+:1088F000000030219228003C8FBF00188FB1001477
73848+:108900008FB0001000086142AF82002C27BD00200C
73849+:1089100003E000083182000190B80032240E00010B
73850+:10892000330F00FF000F2182108E00412419000236
73851+:108930001099006434C40AC03C03800034640A0007
73852+:108940008C8F002415E0001E34660900909F0030D3
73853+:108950002418000533F9003F1338004E24030001AA
73854+:108960008F860020A383001CAF860028AF860024DA
73855+:108970003C0E800035D10A008E2400248F8500240F
73856+:10898000240D00083C010800A42D3FC63C0108004E
73857+:10899000A4203FDA0E000B83000000009228003C68
73858+:1089A0008FBF00188FB100148FB000100008614213
73859+:1089B000AF82002C27BD002003E0000831820001B7
73860+:1089C0008C8A00088C8B00248CD000643C0E8000C4
73861+:1089D00035D10A00014B2823AF900024A380001C4E
73862+:1089E000AF8500288E2400248F8600208F850024E8
73863+:1089F000240D00083C010800A42D3FC63C010800DE
73864+:108A0000A4203FDA0E000B83000000009228003CF7
73865+:108A10008FBF00188FB100148FB0001000086142A2
73866+:108A2000AF82002C27BD002003E000083182000146
73867+:108A300090A200303051003F5224002834C50AC0B3
73868+:108A40008CB000241600002234CB09008CA600480C
73869+:108A50003C0A7FFF3545FFFF00C510243C0E800017
73870+:108A6000AF82002035C509008F8800208CAD0060E2
73871+:108A7000010D602B15800002010020218CA40060F4
73872+:108A80000A000C22AF8400208D02006C0A000BFC4F
73873+:108A90003C0680008C8200488F8600203C097FFFC6
73874+:108AA0003527FFFF004788243C0480082403000189
73875+:108AB000AF910028AC80006CA383001C0A000C302E
73876+:108AC000AF8600248C9F00140A000C22AF9F002068
73877+:108AD0008D6200680A000C6C3C0E800034C4098072
73878+:108AE0008C8900708CA300140123382B10E0000443
73879+:108AF000000000008C8200700A000C6C3C0E8000AC
73880+:108B00008CA200140A000C6C3C0E80008F8500249F
73881+:108B100027BDFFE0AFBF0018AFB1001414A00008DC
73882+:108B2000AFB000103C04800034870A0090E60030AB
73883+:108B30002402000530C3003F106200B934840900EC
73884+:108B40008F91002000A080213C048000348E0A0018
73885+:108B50008DCD00043C0608008CC63FB831A73FFF0E
73886+:108B600000E6602B5580000100E03021938F001C4F
73887+:108B700011E0007800D0282B349F098093F9007C05
73888+:108B800033380002130000792403003400C3102B93
73889+:108B9000144000D90000000000C3302300D0282B6F
73890+:108BA0003C010800A4233FC414A0006E0200182159
73891+:108BB0003C0408008C843FB40064402B5500000145
73892+:108BC000006020213C05800034A90A00912A003C65
73893+:108BD0003C010800AC243FBC31430020146000037A
73894+:108BE0000000482134AB0E008D6900188F88002CDE
73895+:108BF0000128202B1080005F000000003C050800C9
73896+:108C00008CA53FBC00A96821010D602B1180005C80
73897+:108C100000B0702B0109382300E028213C01080036
73898+:108C2000AC273FBC12000003240AFFFC10B0008DEB
73899+:108C30003224000300AA18243C010800A4203FDAD3
73900+:108C40003C010800AC233FBC006028218F84002435
73901+:108C5000120400063C0B80088D6C006C0200202181
73902+:108C6000AF91002025900001AD70006C8F8D002821
73903+:108C700000858823AF91002401A52023AF8400281C
73904+:108C80001220000224070018240700103C18800856
73905+:108C90003706008090CF00683C010800A0273FD82D
73906+:108CA0002407000131EE00FF11C70047000000005B
73907+:108CB00014800018000028213C06800034D109806F
73908+:108CC00034CD010091A600098E2C001824C40001A7
73909+:108CD000000C86023205007F308B007F1165007F1B
73910+:108CE0002407FF803C19800837290080A124004C0C
73911+:108CF0003C0808008D083FD4241800023C010800FD
73912+:108D0000A0384019350F00083C010800AC2F3FD4B3
73913+:108D1000240500103C02800034440A009083003C8B
73914+:108D2000307F002013E0000500A02021240A00016C
73915+:108D30003C010800AC2A3FBC34A400018FBF0018DE
73916+:108D40008FB100148FB000100080102103E00008E4
73917+:108D500027BD00203C010800A4203FC410A0FF94C0
73918+:108D6000020018210A000CC000C018210A000CB72C
73919+:108D7000240300303C0508008CA53FBC00B0702BDC
73920+:108D800011C0FFA8000000003C19080097393FC43B
73921+:108D90000325C0210307782B11E000072CAA00044B
73922+:108DA0003C0360008C625404305F003F17E0FFE337
73923+:108DB000240400422CAA00041140FF9A240400421B
73924+:108DC0000A000D248FBF00181528FFB9000000000D
73925+:108DD0008CCA00183C1F800024020002015F182585
73926+:108DE000ACC3001837F90A00A0C200689329003C00
73927+:108DF0002404000400A01021312800203C010800B8
73928+:108E0000A0244019110000022405001024020001D2
73929+:108E10003C010800AC223FB40A000D1A3C0280005D
73930+:108E20008F8800288C8900600109282B14A000027B
73931+:108E3000010088218C9100603C048000348B0E007E
73932+:108E40008D640018240A000102202821022030210C
73933+:108E5000A38A001C0E000B83022080210A000CA6AE
73934+:108E6000AF82002C00045823122000073164000355
73935+:108E70003C0E800035C7098090ED007C31AC0004C9
73936+:108E800015800019248F00043C010800A4243FDA57
73937+:108E90003C1F080097FF3FDA03E5C82100D9C02B2B
73938+:108EA0001300FF6B8F8400242CA6000514C0FFA3C1
73939+:108EB0002404004230A200031440000200A2182340
73940+:108EC00024A3FFFC3C010800AC233FBC3C0108008C
73941+:108ED000A4203FDA0A000CE70060282100C77024B4
73942+:108EE0000A000D0D01C720263C010800A42F3FDA1F
73943+:108EF0000A000D78000000003C010800AC203FBCD7
73944+:108F00000A000D23240400428F8300283C058000C2
73945+:108F100034AA0A00146000060000102191470030B6
73946+:108F20002406000530E400FF108600030000000066
73947+:108F300003E0000800000000914B0048316900FF89
73948+:108F4000000941C21500FFFA3C0680083C040800F5
73949+:108F500094843FC43C0308008C633FDC3C19080048
73950+:108F60008F393FBC3C0F080095EF3FDA0064C02109
73951+:108F70008CCD00040319702101CF602134AB0E00A9
73952+:108F8000018D282318A0001D00000000914F004C07
73953+:108F90008F8C0034956D001031EE00FF8D89000438
73954+:108FA00001AE30238D8A000030CEFFFF000E290075
73955+:108FB0000125C82100003821014720210325182B55
73956+:108FC0000083C021AD990004AD980000918F000A84
73957+:108FD00001CF6821A18D000A956500128F8A0034A7
73958+:108FE000A5450008954B003825690001A5490038C2
73959+:108FF0009148000D35070008A147000D03E0000867
73960+:109000000000000027BDFFD8AFB000189388001CF7
73961+:109010008FB000143C0A80003C197FFF8F8700242A
73962+:109020003738FFFFAFBF0020AFB1001C355F0A002B
73963+:109030000218182493EB003C00087FC03C02BFFFDD
73964+:10904000006F60252CF000013449FFFF3C1F080031
73965+:109050008FFF3FDC8F9900303C18080097183FD2F3
73966+:1090600001897824001047803C07EFFF3C05F0FFA2
73967+:1090700001E818253C1180003169002034E2FFFF2F
73968+:1090800034ADFFFF362E098027A50010240600020C
73969+:1090900003F96023270B0002354A0E0000621824F2
73970+:1090A0000080802115200002000040218D48001C16
73971+:1090B000A7AB0012058000392407000030E800FF4C
73972+:1090C00000083F00006758253C028008AFAB001441
73973+:1090D000344F008091EA00683C08080091083FD9AD
73974+:1090E0003C09DFFF352CFFFF000AF82B3C0208008B
73975+:1090F00094423FCCA3A80011016CC024001FCF40B4
73976+:10910000031918258FA70010AFA300143C0C08000A
73977+:10911000918C3FDBA7A200168FAB001400ED482412
73978+:109120003C0F01003C0A0FFF012FC82531980003B6
73979+:10913000355FFFFF016D40243C027000033F38247F
73980+:1091400000181E0000E2482501037825AFAF001487
73981+:10915000AFA9001091CC007C0E000092A3AC0015CA
73982+:10916000362D0A0091A6003C30C400201080000675
73983+:10917000260200083C11080096313FC8262EFFFF4A
73984+:109180003C010800A42E3FC88FBF00208FB1001CF7
73985+:109190008FB0001803E0000827BD00288F8B002C3B
73986+:1091A000010B502B5540FFC5240700010A000E0497
73987+:1091B00030E800FF9383001C3C02800027BDFFD8ED
73988+:1091C00034480A0000805021AFBF002034460AC056
73989+:1091D000010028211060000E3444098091070030FE
73990+:1091E000240B00058F89002030EC003F118B000B11
73991+:1091F00000003821AFA900103C0B80088D69006C7D
73992+:10920000AFAA00180E00015AAFA90014A380001CD9
73993+:109210008FBF002003E0000827BD00288D1F0048F5
73994+:109220003C1808008F183FBC8F9900283C027FFF34
73995+:109230008D0800443443FFFFAFA900103C0B8008A9
73996+:109240008D69006C03E370240319782101CF682332
73997+:1092500001A83821AFAA00180E00015AAFA90014C6
73998+:109260000A000E58A380001C3C05800034A60A00AA
73999+:1092700090C7003C3C06080094C63FDA3C02080058
74000+:109280008C423FD430E30020000624001060001E12
74001+:10929000004438253C0880083505008090A300680C
74002+:1092A00000004821240800010000282124040001B6
74003+:1092B0003C0680008CCD017805A0FFFE34CF014034
74004+:1092C000ADE800083C0208008C423FDCA5E5000444
74005+:1092D000A5E40006ADE2000C3C04080090843FD9F0
74006+:1092E0003C03800834790080A1E40012ADE700144B
74007+:1092F000A5E900189338004C3C0E1000A1F8002D91
74008+:1093000003E00008ACCE017834A90E008D28001CC3
74009+:109310003C0C08008D8C3FBC952B0016952A001440
74010+:10932000018648213164FFFF0A000E803145FFFFAE
74011+:109330003C04800034830A009065003C30A2002089
74012+:109340001040001934870E00000040210000382131
74013+:10935000000020213C0680008CC901780520FFFE1A
74014+:1093600034CA014034CF010091EB0009AD48000838
74015+:109370003C0E08008DCE3FDC240DFF91240C0040F4
74016+:109380003C081000A5440004A5470006AD4E000CA3
74017+:10939000A14D0012AD4C0014A5400018A14B002DAA
74018+:1093A00003E00008ACC801788CE8001894E60012CD
74019+:1093B00094E4001030C7FFFF0A000EA93084FFFFBD
74020+:1093C0003C04800034830A009065003C30A20020F9
74021+:1093D0001040002727BDFFF82409000100003821B4
74022+:1093E000240800013C0680008CCA01780540FFFE7D
74023+:1093F0003C0280FF34C40100908D00093C0C080041
74024+:10940000918C4019A3AD00038FAB00003185007F24
74025+:109410003459FFFF01665025AFAA00009083000A6F
74026+:10942000A3A0000200057E00A3A300018FB80000E6
74027+:1094300034CB0140240C30000319702401CF68257F
74028+:10944000AD6D000C27BD0008AD6C0014A5600018C0
74029+:10945000AD690008A56700042409FF80A56800061F
74030+:109460003C081000A169001203E00008ACC80178B4
74031+:1094700034870E008CE9001894E6001294E4001082
74032+:1094800030C8FFFF0A000ECD3087FFFF27BDFFE089
74033+:10949000AFB100143C118000AFB00010AFBF001896
74034+:1094A00036380A00970F0032363001000E000B7F6D
74035+:1094B00031E43FFF8E0E0000240DFF803C042000AD
74036+:1094C00001C25821016D6024000C4940316A007FBF
74037+:1094D000012A4025010438253C048008AE270830C5
74038+:1094E0003486008090C500682403000230A200FF8B
74039+:1094F000104300048F9F00208F990024AC9F0068C8
74040+:10950000AC9900648FBF00188FB100148FB00010A9
74041+:1095100003E0000827BD00203C0A0800254A3A80E5
74042+:109520003C09080025293B103C08080025082F1C91
74043+:109530003C07080024E73BDC3C06080024C639044D
74044+:109540003C05080024A536583C0408002484325CFD
74045+:109550003C030800246339B83C0208002442375415
74046+:109560003C010800AC2A3F983C010800AC293F941C
74047+:109570003C010800AC283F903C010800AC273F9C10
74048+:109580003C010800AC263FAC3C010800AC253FA4E0
74049+:109590003C010800AC243FA03C010800AC233FB0D4
74050+:1095A0003C010800AC223FA803E0000800000000D6
74051+:1095B00080000940800009008008010080080080C8
74052+:1095C00080080000800E00008008008080080000F5
74053+:1095D00080000A8080000A00800009808000090065
74054+:00000001FF
74055diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
74056index 2d0cbbd..a6d6149 100644
74057--- a/fs/Kconfig.binfmt
74058+++ b/fs/Kconfig.binfmt
74059@@ -103,7 +103,7 @@ config HAVE_AOUT
74060
74061 config BINFMT_AOUT
74062 tristate "Kernel support for a.out and ECOFF binaries"
74063- depends on HAVE_AOUT
74064+ depends on HAVE_AOUT && BROKEN
74065 ---help---
74066 A.out (Assembler.OUTput) is a set of formats for libraries and
74067 executables used in the earliest versions of UNIX. Linux used
74068diff --git a/fs/afs/inode.c b/fs/afs/inode.c
74069index e06f5a2..81d07ac 100644
74070--- a/fs/afs/inode.c
74071+++ b/fs/afs/inode.c
74072@@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
74073 struct afs_vnode *vnode;
74074 struct super_block *sb;
74075 struct inode *inode;
74076- static atomic_t afs_autocell_ino;
74077+ static atomic_unchecked_t afs_autocell_ino;
74078
74079 _enter("{%x:%u},%*.*s,",
74080 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
74081@@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
74082 data.fid.unique = 0;
74083 data.fid.vnode = 0;
74084
74085- inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
74086+ inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
74087 afs_iget5_autocell_test, afs_iget5_set,
74088 &data);
74089 if (!inode) {
74090diff --git a/fs/aio.c b/fs/aio.c
74091index 480440f..623fd88 100644
74092--- a/fs/aio.c
74093+++ b/fs/aio.c
74094@@ -441,7 +441,7 @@ static int aio_setup_ring(struct kioctx *ctx)
74095 size += sizeof(struct io_event) * nr_events;
74096
74097 nr_pages = PFN_UP(size);
74098- if (nr_pages < 0)
74099+ if (nr_pages <= 0)
74100 return -EINVAL;
74101
74102 file = aio_private_file(ctx, nr_pages);
74103diff --git a/fs/attr.c b/fs/attr.c
74104index 6530ced..4a827e2 100644
74105--- a/fs/attr.c
74106+++ b/fs/attr.c
74107@@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
74108 unsigned long limit;
74109
74110 limit = rlimit(RLIMIT_FSIZE);
74111+ gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
74112 if (limit != RLIM_INFINITY && offset > limit)
74113 goto out_sig;
74114 if (offset > inode->i_sb->s_maxbytes)
74115diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
74116index 35b755e..f4b9e0a 100644
74117--- a/fs/autofs4/waitq.c
74118+++ b/fs/autofs4/waitq.c
74119@@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
74120 {
74121 unsigned long sigpipe, flags;
74122 mm_segment_t fs;
74123- const char *data = (const char *)addr;
74124+ const char __user *data = (const char __force_user *)addr;
74125 ssize_t wr = 0;
74126
74127 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
74128@@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
74129 return 1;
74130 }
74131
74132+#ifdef CONFIG_GRKERNSEC_HIDESYM
74133+static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
74134+#endif
74135+
74136 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
74137 enum autofs_notify notify)
74138 {
74139@@ -385,7 +389,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
74140
74141 /* If this is a direct mount request create a dummy name */
74142 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
74143+#ifdef CONFIG_GRKERNSEC_HIDESYM
74144+ /* this name does get written to userland via autofs4_write() */
74145+ qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
74146+#else
74147 qstr.len = sprintf(name, "%p", dentry);
74148+#endif
74149 else {
74150 qstr.len = autofs4_getpath(sbi, dentry, &name);
74151 if (!qstr.len) {
74152diff --git a/fs/befs/endian.h b/fs/befs/endian.h
74153index 2722387..56059b5 100644
74154--- a/fs/befs/endian.h
74155+++ b/fs/befs/endian.h
74156@@ -11,7 +11,7 @@
74157
74158 #include <asm/byteorder.h>
74159
74160-static inline u64
74161+static inline u64 __intentional_overflow(-1)
74162 fs64_to_cpu(const struct super_block *sb, fs64 n)
74163 {
74164 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
74165@@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
74166 return (__force fs64)cpu_to_be64(n);
74167 }
74168
74169-static inline u32
74170+static inline u32 __intentional_overflow(-1)
74171 fs32_to_cpu(const struct super_block *sb, fs32 n)
74172 {
74173 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
74174@@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
74175 return (__force fs32)cpu_to_be32(n);
74176 }
74177
74178-static inline u16
74179+static inline u16 __intentional_overflow(-1)
74180 fs16_to_cpu(const struct super_block *sb, fs16 n)
74181 {
74182 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
74183diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
74184index 4c55668..eeae150 100644
74185--- a/fs/binfmt_aout.c
74186+++ b/fs/binfmt_aout.c
74187@@ -16,6 +16,7 @@
74188 #include <linux/string.h>
74189 #include <linux/fs.h>
74190 #include <linux/file.h>
74191+#include <linux/security.h>
74192 #include <linux/stat.h>
74193 #include <linux/fcntl.h>
74194 #include <linux/ptrace.h>
74195@@ -58,6 +59,8 @@ static int aout_core_dump(struct coredump_params *cprm)
74196 #endif
74197 # define START_STACK(u) ((void __user *)u.start_stack)
74198
74199+ memset(&dump, 0, sizeof(dump));
74200+
74201 fs = get_fs();
74202 set_fs(KERNEL_DS);
74203 has_dumped = 1;
74204@@ -68,10 +71,12 @@ static int aout_core_dump(struct coredump_params *cprm)
74205
74206 /* If the size of the dump file exceeds the rlimit, then see what would happen
74207 if we wrote the stack, but not the data area. */
74208+ gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
74209 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
74210 dump.u_dsize = 0;
74211
74212 /* Make sure we have enough room to write the stack and data areas. */
74213+ gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
74214 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
74215 dump.u_ssize = 0;
74216
74217@@ -232,6 +237,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
74218 rlim = rlimit(RLIMIT_DATA);
74219 if (rlim >= RLIM_INFINITY)
74220 rlim = ~0;
74221+
74222+ gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
74223 if (ex.a_data + ex.a_bss > rlim)
74224 return -ENOMEM;
74225
74226@@ -261,6 +268,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
74227
74228 install_exec_creds(bprm);
74229
74230+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74231+ current->mm->pax_flags = 0UL;
74232+#endif
74233+
74234+#ifdef CONFIG_PAX_PAGEEXEC
74235+ if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
74236+ current->mm->pax_flags |= MF_PAX_PAGEEXEC;
74237+
74238+#ifdef CONFIG_PAX_EMUTRAMP
74239+ if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
74240+ current->mm->pax_flags |= MF_PAX_EMUTRAMP;
74241+#endif
74242+
74243+#ifdef CONFIG_PAX_MPROTECT
74244+ if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
74245+ current->mm->pax_flags |= MF_PAX_MPROTECT;
74246+#endif
74247+
74248+ }
74249+#endif
74250+
74251 if (N_MAGIC(ex) == OMAGIC) {
74252 unsigned long text_addr, map_size;
74253 loff_t pos;
74254@@ -312,7 +340,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
74255 return error;
74256
74257 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
74258- PROT_READ | PROT_WRITE | PROT_EXEC,
74259+ PROT_READ | PROT_WRITE,
74260 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
74261 fd_offset + ex.a_text);
74262 if (error != N_DATADDR(ex))
74263diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
74264index 6b65996..17bd3c4 100644
74265--- a/fs/binfmt_elf.c
74266+++ b/fs/binfmt_elf.c
74267@@ -35,6 +35,7 @@
74268 #include <linux/utsname.h>
74269 #include <linux/coredump.h>
74270 #include <linux/sched.h>
74271+#include <linux/xattr.h>
74272 #include <asm/uaccess.h>
74273 #include <asm/param.h>
74274 #include <asm/page.h>
74275@@ -66,6 +67,14 @@ static int elf_core_dump(struct coredump_params *cprm);
74276 #define elf_core_dump NULL
74277 #endif
74278
74279+#ifdef CONFIG_PAX_MPROTECT
74280+static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
74281+#endif
74282+
74283+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
74284+static void elf_handle_mmap(struct file *file);
74285+#endif
74286+
74287 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
74288 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
74289 #else
74290@@ -85,6 +94,15 @@ static struct linux_binfmt elf_format = {
74291 .load_binary = load_elf_binary,
74292 .load_shlib = load_elf_library,
74293 .core_dump = elf_core_dump,
74294+
74295+#ifdef CONFIG_PAX_MPROTECT
74296+ .handle_mprotect= elf_handle_mprotect,
74297+#endif
74298+
74299+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
74300+ .handle_mmap = elf_handle_mmap,
74301+#endif
74302+
74303 .min_coredump = ELF_EXEC_PAGESIZE,
74304 };
74305
74306@@ -92,6 +110,8 @@ static struct linux_binfmt elf_format = {
74307
74308 static int set_brk(unsigned long start, unsigned long end)
74309 {
74310+ unsigned long e = end;
74311+
74312 start = ELF_PAGEALIGN(start);
74313 end = ELF_PAGEALIGN(end);
74314 if (end > start) {
74315@@ -100,7 +120,7 @@ static int set_brk(unsigned long start, unsigned long end)
74316 if (BAD_ADDR(addr))
74317 return addr;
74318 }
74319- current->mm->start_brk = current->mm->brk = end;
74320+ current->mm->start_brk = current->mm->brk = e;
74321 return 0;
74322 }
74323
74324@@ -161,12 +181,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
74325 elf_addr_t __user *u_rand_bytes;
74326 const char *k_platform = ELF_PLATFORM;
74327 const char *k_base_platform = ELF_BASE_PLATFORM;
74328- unsigned char k_rand_bytes[16];
74329+ u32 k_rand_bytes[4];
74330 int items;
74331 elf_addr_t *elf_info;
74332 int ei_index = 0;
74333 const struct cred *cred = current_cred();
74334 struct vm_area_struct *vma;
74335+ unsigned long saved_auxv[AT_VECTOR_SIZE];
74336
74337 /*
74338 * In some cases (e.g. Hyper-Threading), we want to avoid L1
74339@@ -208,8 +229,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
74340 * Generate 16 random bytes for userspace PRNG seeding.
74341 */
74342 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
74343- u_rand_bytes = (elf_addr_t __user *)
74344- STACK_ALLOC(p, sizeof(k_rand_bytes));
74345+ prandom_seed(k_rand_bytes[0] ^ prandom_u32());
74346+ prandom_seed(k_rand_bytes[1] ^ prandom_u32());
74347+ prandom_seed(k_rand_bytes[2] ^ prandom_u32());
74348+ prandom_seed(k_rand_bytes[3] ^ prandom_u32());
74349+ p = STACK_ROUND(p, sizeof(k_rand_bytes));
74350+ u_rand_bytes = (elf_addr_t __user *) p;
74351 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
74352 return -EFAULT;
74353
74354@@ -324,9 +349,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
74355 return -EFAULT;
74356 current->mm->env_end = p;
74357
74358+ memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
74359+
74360 /* Put the elf_info on the stack in the right place. */
74361 sp = (elf_addr_t __user *)envp + 1;
74362- if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
74363+ if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
74364 return -EFAULT;
74365 return 0;
74366 }
74367@@ -515,14 +542,14 @@ static inline int arch_check_elf(struct elfhdr *ehdr, bool has_interp,
74368 an ELF header */
74369
74370 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74371- struct file *interpreter, unsigned long *interp_map_addr,
74372+ struct file *interpreter,
74373 unsigned long no_base, struct elf_phdr *interp_elf_phdata)
74374 {
74375 struct elf_phdr *eppnt;
74376- unsigned long load_addr = 0;
74377+ unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
74378 int load_addr_set = 0;
74379 unsigned long last_bss = 0, elf_bss = 0;
74380- unsigned long error = ~0UL;
74381+ unsigned long error = -EINVAL;
74382 unsigned long total_size;
74383 int i;
74384
74385@@ -542,6 +569,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74386 goto out;
74387 }
74388
74389+#ifdef CONFIG_PAX_SEGMEXEC
74390+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
74391+ pax_task_size = SEGMEXEC_TASK_SIZE;
74392+#endif
74393+
74394 eppnt = interp_elf_phdata;
74395 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
74396 if (eppnt->p_type == PT_LOAD) {
74397@@ -565,8 +597,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74398 map_addr = elf_map(interpreter, load_addr + vaddr,
74399 eppnt, elf_prot, elf_type, total_size);
74400 total_size = 0;
74401- if (!*interp_map_addr)
74402- *interp_map_addr = map_addr;
74403 error = map_addr;
74404 if (BAD_ADDR(map_addr))
74405 goto out;
74406@@ -585,8 +615,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74407 k = load_addr + eppnt->p_vaddr;
74408 if (BAD_ADDR(k) ||
74409 eppnt->p_filesz > eppnt->p_memsz ||
74410- eppnt->p_memsz > TASK_SIZE ||
74411- TASK_SIZE - eppnt->p_memsz < k) {
74412+ eppnt->p_memsz > pax_task_size ||
74413+ pax_task_size - eppnt->p_memsz < k) {
74414 error = -ENOMEM;
74415 goto out;
74416 }
74417@@ -625,9 +655,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74418 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
74419
74420 /* Map the last of the bss segment */
74421- error = vm_brk(elf_bss, last_bss - elf_bss);
74422- if (BAD_ADDR(error))
74423- goto out;
74424+ if (last_bss > elf_bss) {
74425+ error = vm_brk(elf_bss, last_bss - elf_bss);
74426+ if (BAD_ADDR(error))
74427+ goto out;
74428+ }
74429 }
74430
74431 error = load_addr;
74432@@ -635,6 +667,336 @@ out:
74433 return error;
74434 }
74435
74436+#ifdef CONFIG_PAX_PT_PAX_FLAGS
74437+#ifdef CONFIG_PAX_SOFTMODE
74438+static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
74439+{
74440+ unsigned long pax_flags = 0UL;
74441+
74442+#ifdef CONFIG_PAX_PAGEEXEC
74443+ if (elf_phdata->p_flags & PF_PAGEEXEC)
74444+ pax_flags |= MF_PAX_PAGEEXEC;
74445+#endif
74446+
74447+#ifdef CONFIG_PAX_SEGMEXEC
74448+ if (elf_phdata->p_flags & PF_SEGMEXEC)
74449+ pax_flags |= MF_PAX_SEGMEXEC;
74450+#endif
74451+
74452+#ifdef CONFIG_PAX_EMUTRAMP
74453+ if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
74454+ pax_flags |= MF_PAX_EMUTRAMP;
74455+#endif
74456+
74457+#ifdef CONFIG_PAX_MPROTECT
74458+ if (elf_phdata->p_flags & PF_MPROTECT)
74459+ pax_flags |= MF_PAX_MPROTECT;
74460+#endif
74461+
74462+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
74463+ if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
74464+ pax_flags |= MF_PAX_RANDMMAP;
74465+#endif
74466+
74467+ return pax_flags;
74468+}
74469+#endif
74470+
74471+static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
74472+{
74473+ unsigned long pax_flags = 0UL;
74474+
74475+#ifdef CONFIG_PAX_PAGEEXEC
74476+ if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
74477+ pax_flags |= MF_PAX_PAGEEXEC;
74478+#endif
74479+
74480+#ifdef CONFIG_PAX_SEGMEXEC
74481+ if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
74482+ pax_flags |= MF_PAX_SEGMEXEC;
74483+#endif
74484+
74485+#ifdef CONFIG_PAX_EMUTRAMP
74486+ if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
74487+ pax_flags |= MF_PAX_EMUTRAMP;
74488+#endif
74489+
74490+#ifdef CONFIG_PAX_MPROTECT
74491+ if (!(elf_phdata->p_flags & PF_NOMPROTECT))
74492+ pax_flags |= MF_PAX_MPROTECT;
74493+#endif
74494+
74495+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
74496+ if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
74497+ pax_flags |= MF_PAX_RANDMMAP;
74498+#endif
74499+
74500+ return pax_flags;
74501+}
74502+#endif
74503+
74504+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
74505+#ifdef CONFIG_PAX_SOFTMODE
74506+static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
74507+{
74508+ unsigned long pax_flags = 0UL;
74509+
74510+#ifdef CONFIG_PAX_PAGEEXEC
74511+ if (pax_flags_softmode & MF_PAX_PAGEEXEC)
74512+ pax_flags |= MF_PAX_PAGEEXEC;
74513+#endif
74514+
74515+#ifdef CONFIG_PAX_SEGMEXEC
74516+ if (pax_flags_softmode & MF_PAX_SEGMEXEC)
74517+ pax_flags |= MF_PAX_SEGMEXEC;
74518+#endif
74519+
74520+#ifdef CONFIG_PAX_EMUTRAMP
74521+ if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
74522+ pax_flags |= MF_PAX_EMUTRAMP;
74523+#endif
74524+
74525+#ifdef CONFIG_PAX_MPROTECT
74526+ if (pax_flags_softmode & MF_PAX_MPROTECT)
74527+ pax_flags |= MF_PAX_MPROTECT;
74528+#endif
74529+
74530+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
74531+ if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
74532+ pax_flags |= MF_PAX_RANDMMAP;
74533+#endif
74534+
74535+ return pax_flags;
74536+}
74537+#endif
74538+
74539+static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
74540+{
74541+ unsigned long pax_flags = 0UL;
74542+
74543+#ifdef CONFIG_PAX_PAGEEXEC
74544+ if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
74545+ pax_flags |= MF_PAX_PAGEEXEC;
74546+#endif
74547+
74548+#ifdef CONFIG_PAX_SEGMEXEC
74549+ if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
74550+ pax_flags |= MF_PAX_SEGMEXEC;
74551+#endif
74552+
74553+#ifdef CONFIG_PAX_EMUTRAMP
74554+ if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
74555+ pax_flags |= MF_PAX_EMUTRAMP;
74556+#endif
74557+
74558+#ifdef CONFIG_PAX_MPROTECT
74559+ if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
74560+ pax_flags |= MF_PAX_MPROTECT;
74561+#endif
74562+
74563+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
74564+ if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
74565+ pax_flags |= MF_PAX_RANDMMAP;
74566+#endif
74567+
74568+ return pax_flags;
74569+}
74570+#endif
74571+
74572+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74573+static unsigned long pax_parse_defaults(void)
74574+{
74575+ unsigned long pax_flags = 0UL;
74576+
74577+#ifdef CONFIG_PAX_SOFTMODE
74578+ if (pax_softmode)
74579+ return pax_flags;
74580+#endif
74581+
74582+#ifdef CONFIG_PAX_PAGEEXEC
74583+ pax_flags |= MF_PAX_PAGEEXEC;
74584+#endif
74585+
74586+#ifdef CONFIG_PAX_SEGMEXEC
74587+ pax_flags |= MF_PAX_SEGMEXEC;
74588+#endif
74589+
74590+#ifdef CONFIG_PAX_MPROTECT
74591+ pax_flags |= MF_PAX_MPROTECT;
74592+#endif
74593+
74594+#ifdef CONFIG_PAX_RANDMMAP
74595+ if (randomize_va_space)
74596+ pax_flags |= MF_PAX_RANDMMAP;
74597+#endif
74598+
74599+ return pax_flags;
74600+}
74601+
74602+static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
74603+{
74604+ unsigned long pax_flags = PAX_PARSE_FLAGS_FALLBACK;
74605+
74606+#ifdef CONFIG_PAX_EI_PAX
74607+
74608+#ifdef CONFIG_PAX_SOFTMODE
74609+ if (pax_softmode)
74610+ return pax_flags;
74611+#endif
74612+
74613+ pax_flags = 0UL;
74614+
74615+#ifdef CONFIG_PAX_PAGEEXEC
74616+ if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
74617+ pax_flags |= MF_PAX_PAGEEXEC;
74618+#endif
74619+
74620+#ifdef CONFIG_PAX_SEGMEXEC
74621+ if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
74622+ pax_flags |= MF_PAX_SEGMEXEC;
74623+#endif
74624+
74625+#ifdef CONFIG_PAX_EMUTRAMP
74626+ if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
74627+ pax_flags |= MF_PAX_EMUTRAMP;
74628+#endif
74629+
74630+#ifdef CONFIG_PAX_MPROTECT
74631+ if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
74632+ pax_flags |= MF_PAX_MPROTECT;
74633+#endif
74634+
74635+#ifdef CONFIG_PAX_ASLR
74636+ if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
74637+ pax_flags |= MF_PAX_RANDMMAP;
74638+#endif
74639+
74640+#endif
74641+
74642+ return pax_flags;
74643+
74644+}
74645+
74646+static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
74647+{
74648+
74649+#ifdef CONFIG_PAX_PT_PAX_FLAGS
74650+ unsigned long i;
74651+
74652+ for (i = 0UL; i < elf_ex->e_phnum; i++)
74653+ if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
74654+ if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
74655+ ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
74656+ ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
74657+ ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
74658+ ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
74659+ return PAX_PARSE_FLAGS_FALLBACK;
74660+
74661+#ifdef CONFIG_PAX_SOFTMODE
74662+ if (pax_softmode)
74663+ return pax_parse_pt_pax_softmode(&elf_phdata[i]);
74664+ else
74665+#endif
74666+
74667+ return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
74668+ break;
74669+ }
74670+#endif
74671+
74672+ return PAX_PARSE_FLAGS_FALLBACK;
74673+}
74674+
74675+static unsigned long pax_parse_xattr_pax(struct file * const file)
74676+{
74677+
74678+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
74679+ ssize_t xattr_size, i;
74680+ unsigned char xattr_value[sizeof("pemrs") - 1];
74681+ unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
74682+
74683+ xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
74684+ if (xattr_size < 0 || xattr_size > sizeof xattr_value)
74685+ return PAX_PARSE_FLAGS_FALLBACK;
74686+
74687+ for (i = 0; i < xattr_size; i++)
74688+ switch (xattr_value[i]) {
74689+ default:
74690+ return PAX_PARSE_FLAGS_FALLBACK;
74691+
74692+#define parse_flag(option1, option2, flag) \
74693+ case option1: \
74694+ if (pax_flags_hardmode & MF_PAX_##flag) \
74695+ return PAX_PARSE_FLAGS_FALLBACK;\
74696+ pax_flags_hardmode |= MF_PAX_##flag; \
74697+ break; \
74698+ case option2: \
74699+ if (pax_flags_softmode & MF_PAX_##flag) \
74700+ return PAX_PARSE_FLAGS_FALLBACK;\
74701+ pax_flags_softmode |= MF_PAX_##flag; \
74702+ break;
74703+
74704+ parse_flag('p', 'P', PAGEEXEC);
74705+ parse_flag('e', 'E', EMUTRAMP);
74706+ parse_flag('m', 'M', MPROTECT);
74707+ parse_flag('r', 'R', RANDMMAP);
74708+ parse_flag('s', 'S', SEGMEXEC);
74709+
74710+#undef parse_flag
74711+ }
74712+
74713+ if (pax_flags_hardmode & pax_flags_softmode)
74714+ return PAX_PARSE_FLAGS_FALLBACK;
74715+
74716+#ifdef CONFIG_PAX_SOFTMODE
74717+ if (pax_softmode)
74718+ return pax_parse_xattr_pax_softmode(pax_flags_softmode);
74719+ else
74720+#endif
74721+
74722+ return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
74723+#else
74724+ return PAX_PARSE_FLAGS_FALLBACK;
74725+#endif
74726+
74727+}
74728+
74729+static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
74730+{
74731+ unsigned long pax_flags, ei_pax_flags, pt_pax_flags, xattr_pax_flags;
74732+
74733+ pax_flags = pax_parse_defaults();
74734+ ei_pax_flags = pax_parse_ei_pax(elf_ex);
74735+ pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
74736+ xattr_pax_flags = pax_parse_xattr_pax(file);
74737+
74738+ if (pt_pax_flags != PAX_PARSE_FLAGS_FALLBACK &&
74739+ xattr_pax_flags != PAX_PARSE_FLAGS_FALLBACK &&
74740+ pt_pax_flags != xattr_pax_flags)
74741+ return -EINVAL;
74742+ if (xattr_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
74743+ pax_flags = xattr_pax_flags;
74744+ else if (pt_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
74745+ pax_flags = pt_pax_flags;
74746+ else if (ei_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
74747+ pax_flags = ei_pax_flags;
74748+
74749+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
74750+ if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
74751+ if ((__supported_pte_mask & _PAGE_NX))
74752+ pax_flags &= ~MF_PAX_SEGMEXEC;
74753+ else
74754+ pax_flags &= ~MF_PAX_PAGEEXEC;
74755+ }
74756+#endif
74757+
74758+ if (0 > pax_check_flags(&pax_flags))
74759+ return -EINVAL;
74760+
74761+ current->mm->pax_flags = pax_flags;
74762+ return 0;
74763+}
74764+#endif
74765+
74766 /*
74767 * These are the functions used to load ELF style executables and shared
74768 * libraries. There is no binary dependent code anywhere else.
74769@@ -648,6 +1010,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
74770 {
74771 unsigned long random_variable = 0;
74772
74773+#ifdef CONFIG_PAX_RANDUSTACK
74774+ if (current->mm->pax_flags & MF_PAX_RANDMMAP)
74775+ return stack_top - current->mm->delta_stack;
74776+#endif
74777+
74778 if ((current->flags & PF_RANDOMIZE) &&
74779 !(current->personality & ADDR_NO_RANDOMIZE)) {
74780 random_variable = (unsigned long) get_random_int();
74781@@ -667,7 +1034,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
74782 unsigned long load_addr = 0, load_bias = 0;
74783 int load_addr_set = 0;
74784 char * elf_interpreter = NULL;
74785- unsigned long error;
74786+ unsigned long error = 0;
74787 struct elf_phdr *elf_ppnt, *elf_phdata, *interp_elf_phdata = NULL;
74788 unsigned long elf_bss, elf_brk;
74789 int retval, i;
74790@@ -682,6 +1049,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
74791 struct elfhdr interp_elf_ex;
74792 } *loc;
74793 struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE;
74794+ unsigned long pax_task_size;
74795
74796 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
74797 if (!loc) {
74798@@ -840,6 +1208,77 @@ static int load_elf_binary(struct linux_binprm *bprm)
74799 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
74800 may depend on the personality. */
74801 SET_PERSONALITY2(loc->elf_ex, &arch_state);
74802+
74803+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74804+ current->mm->pax_flags = 0UL;
74805+#endif
74806+
74807+#ifdef CONFIG_PAX_DLRESOLVE
74808+ current->mm->call_dl_resolve = 0UL;
74809+#endif
74810+
74811+#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
74812+ current->mm->call_syscall = 0UL;
74813+#endif
74814+
74815+#ifdef CONFIG_PAX_ASLR
74816+ current->mm->delta_mmap = 0UL;
74817+ current->mm->delta_stack = 0UL;
74818+#endif
74819+
74820+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74821+ if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
74822+ retval = -EINVAL;
74823+ goto out_free_dentry;
74824+ }
74825+#endif
74826+
74827+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
74828+ pax_set_initial_flags(bprm);
74829+#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
74830+ if (pax_set_initial_flags_func)
74831+ (pax_set_initial_flags_func)(bprm);
74832+#endif
74833+
74834+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
74835+ if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
74836+ current->mm->context.user_cs_limit = PAGE_SIZE;
74837+ current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
74838+ }
74839+#endif
74840+
74841+#ifdef CONFIG_PAX_SEGMEXEC
74842+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
74843+ current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
74844+ current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
74845+ pax_task_size = SEGMEXEC_TASK_SIZE;
74846+ current->mm->def_flags |= VM_NOHUGEPAGE;
74847+ } else
74848+#endif
74849+
74850+ pax_task_size = TASK_SIZE;
74851+
74852+#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
74853+ if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
74854+ set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
74855+ put_cpu();
74856+ }
74857+#endif
74858+
74859+#ifdef CONFIG_PAX_ASLR
74860+ if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
74861+ current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
74862+ current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
74863+ }
74864+#endif
74865+
74866+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
74867+ if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
74868+ executable_stack = EXSTACK_DISABLE_X;
74869+ current->personality &= ~READ_IMPLIES_EXEC;
74870+ } else
74871+#endif
74872+
74873 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
74874 current->personality |= READ_IMPLIES_EXEC;
74875
74876@@ -915,8 +1354,21 @@ static int load_elf_binary(struct linux_binprm *bprm)
74877 if (current->flags & PF_RANDOMIZE)
74878 load_bias += arch_mmap_rnd();
74879 load_bias = ELF_PAGESTART(load_bias);
74880- total_size = total_mapping_size(elf_phdata,
74881- loc->elf_ex.e_phnum);
74882+
74883+#ifdef CONFIG_PAX_RANDMMAP
74884+ /* PaX: randomize base address at the default exe base if requested */
74885+ if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
74886+#ifdef CONFIG_SPARC64
74887+ load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
74888+#else
74889+ load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
74890+#endif
74891+ load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
74892+ elf_flags |= MAP_FIXED;
74893+ }
74894+#endif
74895+
74896+ total_size = total_mapping_size(elf_phdata, loc->elf_ex.e_phnum);
74897 if (!total_size) {
74898 retval = -EINVAL;
74899 goto out_free_dentry;
74900@@ -952,9 +1404,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
74901 * allowed task size. Note that p_filesz must always be
74902 * <= p_memsz so it is only necessary to check p_memsz.
74903 */
74904- if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
74905- elf_ppnt->p_memsz > TASK_SIZE ||
74906- TASK_SIZE - elf_ppnt->p_memsz < k) {
74907+ if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
74908+ elf_ppnt->p_memsz > pax_task_size ||
74909+ pax_task_size - elf_ppnt->p_memsz < k) {
74910 /* set_brk can never work. Avoid overflows. */
74911 retval = -EINVAL;
74912 goto out_free_dentry;
74913@@ -990,16 +1442,43 @@ static int load_elf_binary(struct linux_binprm *bprm)
74914 if (retval)
74915 goto out_free_dentry;
74916 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
74917- retval = -EFAULT; /* Nobody gets to see this, but.. */
74918- goto out_free_dentry;
74919+ /*
74920+ * This bss-zeroing can fail if the ELF
74921+ * file specifies odd protections. So
74922+ * we don't check the return value
74923+ */
74924 }
74925
74926+#ifdef CONFIG_PAX_RANDMMAP
74927+ if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
74928+ unsigned long start, size, flags;
74929+ vm_flags_t vm_flags;
74930+
74931+ start = ELF_PAGEALIGN(elf_brk);
74932+ size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
74933+ flags = MAP_FIXED | MAP_PRIVATE;
74934+ vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
74935+
74936+ down_write(&current->mm->mmap_sem);
74937+ start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
74938+ retval = -ENOMEM;
74939+ if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
74940+// if (current->personality & ADDR_NO_RANDOMIZE)
74941+// vm_flags |= VM_READ | VM_MAYREAD;
74942+ start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
74943+ retval = IS_ERR_VALUE(start) ? start : 0;
74944+ }
74945+ up_write(&current->mm->mmap_sem);
74946+ if (retval == 0)
74947+ retval = set_brk(start + size, start + size + PAGE_SIZE);
74948+ if (retval < 0)
74949+ goto out_free_dentry;
74950+ }
74951+#endif
74952+
74953 if (elf_interpreter) {
74954- unsigned long interp_map_addr = 0;
74955-
74956 elf_entry = load_elf_interp(&loc->interp_elf_ex,
74957 interpreter,
74958- &interp_map_addr,
74959 load_bias, interp_elf_phdata);
74960 if (!IS_ERR((void *)elf_entry)) {
74961 /*
74962@@ -1050,6 +1529,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
74963 current->mm->end_data = end_data;
74964 current->mm->start_stack = bprm->p;
74965
74966+#ifndef CONFIG_PAX_RANDMMAP
74967 if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1)) {
74968 current->mm->brk = current->mm->start_brk =
74969 arch_randomize_brk(current->mm);
74970@@ -1057,6 +1537,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
74971 current->brk_randomized = 1;
74972 #endif
74973 }
74974+#endif
74975
74976 if (current->personality & MMAP_PAGE_ZERO) {
74977 /* Why this, you ask??? Well SVr4 maps page 0 as read-only,
74978@@ -1225,7 +1706,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
74979 * Decide what to dump of a segment, part, all or none.
74980 */
74981 static unsigned long vma_dump_size(struct vm_area_struct *vma,
74982- unsigned long mm_flags)
74983+ unsigned long mm_flags, long signr)
74984 {
74985 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
74986
74987@@ -1263,7 +1744,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
74988 if (vma->vm_file == NULL)
74989 return 0;
74990
74991- if (FILTER(MAPPED_PRIVATE))
74992+ if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
74993 goto whole;
74994
74995 /*
74996@@ -1363,7 +1844,7 @@ static void fill_elf_header(struct elfhdr *elf, int segs,
74997 return;
74998 }
74999
75000-static void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, loff_t offset)
75001+static void fill_elf_note_phdr(struct elf_phdr *phdr, size_t sz, loff_t offset)
75002 {
75003 phdr->p_type = PT_NOTE;
75004 phdr->p_offset = offset;
75005@@ -1470,9 +1951,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
75006 {
75007 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
75008 int i = 0;
75009- do
75010+ do {
75011 i += 2;
75012- while (auxv[i - 2] != AT_NULL);
75013+ } while (auxv[i - 2] != AT_NULL);
75014 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
75015 }
75016
75017@@ -1481,7 +1962,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
75018 {
75019 mm_segment_t old_fs = get_fs();
75020 set_fs(KERNEL_DS);
75021- copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
75022+ copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
75023 set_fs(old_fs);
75024 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
75025 }
75026@@ -2201,7 +2682,7 @@ static int elf_core_dump(struct coredump_params *cprm)
75027 vma = next_vma(vma, gate_vma)) {
75028 unsigned long dump_size;
75029
75030- dump_size = vma_dump_size(vma, cprm->mm_flags);
75031+ dump_size = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
75032 vma_filesz[i++] = dump_size;
75033 vma_data_size += dump_size;
75034 }
75035@@ -2309,6 +2790,167 @@ out:
75036
75037 #endif /* CONFIG_ELF_CORE */
75038
75039+#ifdef CONFIG_PAX_MPROTECT
75040+/* PaX: non-PIC ELF libraries need relocations on their executable segments
75041+ * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
75042+ * we'll remove VM_MAYWRITE for good on RELRO segments.
75043+ *
75044+ * The checks favour ld-linux.so behaviour which operates on a per ELF segment
75045+ * basis because we want to allow the common case and not the special ones.
75046+ */
75047+static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
75048+{
75049+ struct elfhdr elf_h;
75050+ struct elf_phdr elf_p;
75051+ unsigned long i;
75052+ unsigned long oldflags;
75053+ bool is_textrel_rw, is_textrel_rx, is_relro;
75054+
75055+ if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
75056+ return;
75057+
75058+ oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
75059+ newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
75060+
75061+#ifdef CONFIG_PAX_ELFRELOCS
75062+ /* possible TEXTREL */
75063+ is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
75064+ is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
75065+#else
75066+ is_textrel_rw = false;
75067+ is_textrel_rx = false;
75068+#endif
75069+
75070+ /* possible RELRO */
75071+ is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
75072+
75073+ if (!is_textrel_rw && !is_textrel_rx && !is_relro)
75074+ return;
75075+
75076+ if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
75077+ memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
75078+
75079+#ifdef CONFIG_PAX_ETEXECRELOCS
75080+ ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
75081+#else
75082+ ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
75083+#endif
75084+
75085+ (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
75086+ !elf_check_arch(&elf_h) ||
75087+ elf_h.e_phentsize != sizeof(struct elf_phdr) ||
75088+ elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
75089+ return;
75090+
75091+ for (i = 0UL; i < elf_h.e_phnum; i++) {
75092+ if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
75093+ return;
75094+ switch (elf_p.p_type) {
75095+ case PT_DYNAMIC:
75096+ if (!is_textrel_rw && !is_textrel_rx)
75097+ continue;
75098+ i = 0UL;
75099+ while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
75100+ elf_dyn dyn;
75101+
75102+ if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
75103+ break;
75104+ if (dyn.d_tag == DT_NULL)
75105+ break;
75106+ if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
75107+ gr_log_textrel(vma, is_textrel_rw);
75108+ if (is_textrel_rw)
75109+ vma->vm_flags |= VM_MAYWRITE;
75110+ else
75111+ /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
75112+ vma->vm_flags &= ~VM_MAYWRITE;
75113+ break;
75114+ }
75115+ i++;
75116+ }
75117+ is_textrel_rw = false;
75118+ is_textrel_rx = false;
75119+ continue;
75120+
75121+ case PT_GNU_RELRO:
75122+ if (!is_relro)
75123+ continue;
75124+ if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
75125+ vma->vm_flags &= ~VM_MAYWRITE;
75126+ is_relro = false;
75127+ continue;
75128+
75129+#ifdef CONFIG_PAX_PT_PAX_FLAGS
75130+ case PT_PAX_FLAGS: {
75131+ const char *msg_mprotect = "", *msg_emutramp = "";
75132+ char *buffer_lib, *buffer_exe;
75133+
75134+ if (elf_p.p_flags & PF_NOMPROTECT)
75135+ msg_mprotect = "MPROTECT disabled";
75136+
75137+#ifdef CONFIG_PAX_EMUTRAMP
75138+ if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
75139+ msg_emutramp = "EMUTRAMP enabled";
75140+#endif
75141+
75142+ if (!msg_mprotect[0] && !msg_emutramp[0])
75143+ continue;
75144+
75145+ if (!printk_ratelimit())
75146+ continue;
75147+
75148+ buffer_lib = (char *)__get_free_page(GFP_KERNEL);
75149+ buffer_exe = (char *)__get_free_page(GFP_KERNEL);
75150+ if (buffer_lib && buffer_exe) {
75151+ char *path_lib, *path_exe;
75152+
75153+ path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
75154+ path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
75155+
75156+ pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
75157+ (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
75158+
75159+ }
75160+ free_page((unsigned long)buffer_exe);
75161+ free_page((unsigned long)buffer_lib);
75162+ continue;
75163+ }
75164+#endif
75165+
75166+ }
75167+ }
75168+}
75169+#endif
75170+
75171+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
75172+
75173+extern int grsec_enable_log_rwxmaps;
75174+
75175+static void elf_handle_mmap(struct file *file)
75176+{
75177+ struct elfhdr elf_h;
75178+ struct elf_phdr elf_p;
75179+ unsigned long i;
75180+
75181+ if (!grsec_enable_log_rwxmaps)
75182+ return;
75183+
75184+ if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
75185+ memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
75186+ (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
75187+ elf_h.e_phentsize != sizeof(struct elf_phdr) ||
75188+ elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
75189+ return;
75190+
75191+ for (i = 0UL; i < elf_h.e_phnum; i++) {
75192+ if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
75193+ return;
75194+ if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
75195+ gr_log_ptgnustack(file);
75196+ }
75197+}
75198+#endif
75199+
75200 static int __init init_elf_binfmt(void)
75201 {
75202 register_binfmt(&elf_format);
75203diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
75204index d3634bf..10fc244 100644
75205--- a/fs/binfmt_elf_fdpic.c
75206+++ b/fs/binfmt_elf_fdpic.c
75207@@ -1296,7 +1296,7 @@ static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs)
75208 return;
75209 }
75210
75211-static inline void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, loff_t offset)
75212+static inline void fill_elf_note_phdr(struct elf_phdr *phdr, size_t sz, loff_t offset)
75213 {
75214 phdr->p_type = PT_NOTE;
75215 phdr->p_offset = offset;
75216@@ -1667,7 +1667,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
75217
75218 /* Write notes phdr entry */
75219 {
75220- int sz = 0;
75221+ size_t sz = 0;
75222
75223 for (i = 0; i < numnote; i++)
75224 sz += notesize(notes + i);
75225diff --git a/fs/block_dev.c b/fs/block_dev.c
75226index 1170f8c..2a8acc1 100644
75227--- a/fs/block_dev.c
75228+++ b/fs/block_dev.c
75229@@ -738,7 +738,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
75230 else if (bdev->bd_contains == bdev)
75231 return true; /* is a whole device which isn't held */
75232
75233- else if (whole->bd_holder == bd_may_claim)
75234+ else if (whole->bd_holder == (void *)bd_may_claim)
75235 return true; /* is a partition of a device that is being partitioned */
75236 else if (whole->bd_holder != NULL)
75237 return false; /* is a partition of a held device */
75238diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
75239index 54114b4..580cfc9 100644
75240--- a/fs/btrfs/ctree.c
75241+++ b/fs/btrfs/ctree.c
75242@@ -1180,9 +1180,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
75243 free_extent_buffer(buf);
75244 add_root_to_dirty_list(root);
75245 } else {
75246- if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
75247- parent_start = parent->start;
75248- else
75249+ if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
75250+ if (parent)
75251+ parent_start = parent->start;
75252+ else
75253+ parent_start = 0;
75254+ } else
75255 parent_start = 0;
75256
75257 WARN_ON(trans->transid != btrfs_header_generation(parent));
75258diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
75259index a2ae427..53c2e98 100644
75260--- a/fs/btrfs/delayed-inode.c
75261+++ b/fs/btrfs/delayed-inode.c
75262@@ -462,7 +462,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
75263
75264 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
75265 {
75266- int seq = atomic_inc_return(&delayed_root->items_seq);
75267+ int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
75268 if ((atomic_dec_return(&delayed_root->items) <
75269 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
75270 waitqueue_active(&delayed_root->wait))
75271@@ -1412,7 +1412,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
75272
75273 static int could_end_wait(struct btrfs_delayed_root *delayed_root, int seq)
75274 {
75275- int val = atomic_read(&delayed_root->items_seq);
75276+ int val = atomic_read_unchecked(&delayed_root->items_seq);
75277
75278 if (val < seq || val >= seq + BTRFS_DELAYED_BATCH)
75279 return 1;
75280@@ -1437,7 +1437,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
75281 int seq;
75282 int ret;
75283
75284- seq = atomic_read(&delayed_root->items_seq);
75285+ seq = atomic_read_unchecked(&delayed_root->items_seq);
75286
75287 ret = btrfs_wq_run_delayed_node(delayed_root, fs_info, 0);
75288 if (ret)
75289diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
75290index f70119f..ab5894d 100644
75291--- a/fs/btrfs/delayed-inode.h
75292+++ b/fs/btrfs/delayed-inode.h
75293@@ -43,7 +43,7 @@ struct btrfs_delayed_root {
75294 */
75295 struct list_head prepare_list;
75296 atomic_t items; /* for delayed items */
75297- atomic_t items_seq; /* for delayed items */
75298+ atomic_unchecked_t items_seq; /* for delayed items */
75299 int nodes; /* for delayed nodes */
75300 wait_queue_head_t wait;
75301 };
75302@@ -90,7 +90,7 @@ static inline void btrfs_init_delayed_root(
75303 struct btrfs_delayed_root *delayed_root)
75304 {
75305 atomic_set(&delayed_root->items, 0);
75306- atomic_set(&delayed_root->items_seq, 0);
75307+ atomic_set_unchecked(&delayed_root->items_seq, 0);
75308 delayed_root->nodes = 0;
75309 spin_lock_init(&delayed_root->lock);
75310 init_waitqueue_head(&delayed_root->wait);
75311diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
75312index cd7ef34..1e31ae3 100644
75313--- a/fs/btrfs/super.c
75314+++ b/fs/btrfs/super.c
75315@@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
75316 function, line, errstr);
75317 return;
75318 }
75319- ACCESS_ONCE(trans->transaction->aborted) = errno;
75320+ ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
75321 /* Wake up anybody who may be waiting on this transaction */
75322 wake_up(&root->fs_info->transaction_wait);
75323 wake_up(&root->fs_info->transaction_blocked_wait);
75324diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
75325index 603b0cc..8e3f600 100644
75326--- a/fs/btrfs/sysfs.c
75327+++ b/fs/btrfs/sysfs.c
75328@@ -481,7 +481,7 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
75329 for (set = 0; set < FEAT_MAX; set++) {
75330 int i;
75331 struct attribute *attrs[2];
75332- struct attribute_group agroup = {
75333+ attribute_group_no_const agroup = {
75334 .name = "features",
75335 .attrs = attrs,
75336 };
75337diff --git a/fs/btrfs/tests/free-space-tests.c b/fs/btrfs/tests/free-space-tests.c
75338index 2299bfd..4098e72 100644
75339--- a/fs/btrfs/tests/free-space-tests.c
75340+++ b/fs/btrfs/tests/free-space-tests.c
75341@@ -463,7 +463,9 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache)
75342 * extent entry.
75343 */
75344 use_bitmap_op = cache->free_space_ctl->op->use_bitmap;
75345- cache->free_space_ctl->op->use_bitmap = test_use_bitmap;
75346+ pax_open_kernel();
75347+ *(void **)&cache->free_space_ctl->op->use_bitmap = test_use_bitmap;
75348+ pax_close_kernel();
75349
75350 /*
75351 * Extent entry covering free space range [128Mb - 256Kb, 128Mb - 128Kb[
75352@@ -870,7 +872,9 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache)
75353 if (ret)
75354 return ret;
75355
75356- cache->free_space_ctl->op->use_bitmap = use_bitmap_op;
75357+ pax_open_kernel();
75358+ *(void **)&cache->free_space_ctl->op->use_bitmap = use_bitmap_op;
75359+ pax_close_kernel();
75360 __btrfs_remove_free_space_cache(cache->free_space_ctl);
75361
75362 return 0;
75363diff --git a/fs/btrfs/tree-log.h b/fs/btrfs/tree-log.h
75364index 6916a78..4598936 100644
75365--- a/fs/btrfs/tree-log.h
75366+++ b/fs/btrfs/tree-log.h
75367@@ -45,7 +45,7 @@ static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx)
75368 static inline void btrfs_set_log_full_commit(struct btrfs_fs_info *fs_info,
75369 struct btrfs_trans_handle *trans)
75370 {
75371- ACCESS_ONCE(fs_info->last_trans_log_full_commit) = trans->transid;
75372+ ACCESS_ONCE_RW(fs_info->last_trans_log_full_commit) = trans->transid;
75373 }
75374
75375 static inline int btrfs_need_log_full_commit(struct btrfs_fs_info *fs_info,
75376diff --git a/fs/buffer.c b/fs/buffer.c
75377index 1cf7a53..b49f8c0 100644
75378--- a/fs/buffer.c
75379+++ b/fs/buffer.c
75380@@ -3440,7 +3440,7 @@ void __init buffer_init(void)
75381 bh_cachep = kmem_cache_create("buffer_head",
75382 sizeof(struct buffer_head), 0,
75383 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
75384- SLAB_MEM_SPREAD),
75385+ SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
75386 NULL);
75387
75388 /*
75389diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
75390index 6af790f..ec4c1e6 100644
75391--- a/fs/cachefiles/bind.c
75392+++ b/fs/cachefiles/bind.c
75393@@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
75394 args);
75395
75396 /* start by checking things over */
75397- ASSERT(cache->fstop_percent >= 0 &&
75398- cache->fstop_percent < cache->fcull_percent &&
75399+ ASSERT(cache->fstop_percent < cache->fcull_percent &&
75400 cache->fcull_percent < cache->frun_percent &&
75401 cache->frun_percent < 100);
75402
75403- ASSERT(cache->bstop_percent >= 0 &&
75404- cache->bstop_percent < cache->bcull_percent &&
75405+ ASSERT(cache->bstop_percent < cache->bcull_percent &&
75406 cache->bcull_percent < cache->brun_percent &&
75407 cache->brun_percent < 100);
75408
75409diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
75410index f601def..b2cf704 100644
75411--- a/fs/cachefiles/daemon.c
75412+++ b/fs/cachefiles/daemon.c
75413@@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
75414 if (n > buflen)
75415 return -EMSGSIZE;
75416
75417- if (copy_to_user(_buffer, buffer, n) != 0)
75418+ if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
75419 return -EFAULT;
75420
75421 return n;
75422@@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
75423 if (test_bit(CACHEFILES_DEAD, &cache->flags))
75424 return -EIO;
75425
75426- if (datalen < 0 || datalen > PAGE_SIZE - 1)
75427+ if (datalen > PAGE_SIZE - 1)
75428 return -EOPNOTSUPP;
75429
75430 /* drag the command string into the kernel so we can parse it */
75431@@ -385,7 +385,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
75432 if (args[0] != '%' || args[1] != '\0')
75433 return -EINVAL;
75434
75435- if (fstop < 0 || fstop >= cache->fcull_percent)
75436+ if (fstop >= cache->fcull_percent)
75437 return cachefiles_daemon_range_error(cache, args);
75438
75439 cache->fstop_percent = fstop;
75440@@ -457,7 +457,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
75441 if (args[0] != '%' || args[1] != '\0')
75442 return -EINVAL;
75443
75444- if (bstop < 0 || bstop >= cache->bcull_percent)
75445+ if (bstop >= cache->bcull_percent)
75446 return cachefiles_daemon_range_error(cache, args);
75447
75448 cache->bstop_percent = bstop;
75449diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
75450index aecd085..3584e2f 100644
75451--- a/fs/cachefiles/internal.h
75452+++ b/fs/cachefiles/internal.h
75453@@ -65,7 +65,7 @@ struct cachefiles_cache {
75454 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
75455 struct rb_root active_nodes; /* active nodes (can't be culled) */
75456 rwlock_t active_lock; /* lock for active_nodes */
75457- atomic_t gravecounter; /* graveyard uniquifier */
75458+ atomic_unchecked_t gravecounter; /* graveyard uniquifier */
75459 unsigned frun_percent; /* when to stop culling (% files) */
75460 unsigned fcull_percent; /* when to start culling (% files) */
75461 unsigned fstop_percent; /* when to stop allocating (% files) */
75462@@ -177,19 +177,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
75463 * proc.c
75464 */
75465 #ifdef CONFIG_CACHEFILES_HISTOGRAM
75466-extern atomic_t cachefiles_lookup_histogram[HZ];
75467-extern atomic_t cachefiles_mkdir_histogram[HZ];
75468-extern atomic_t cachefiles_create_histogram[HZ];
75469+extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
75470+extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
75471+extern atomic_unchecked_t cachefiles_create_histogram[HZ];
75472
75473 extern int __init cachefiles_proc_init(void);
75474 extern void cachefiles_proc_cleanup(void);
75475 static inline
75476-void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
75477+void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
75478 {
75479 unsigned long jif = jiffies - start_jif;
75480 if (jif >= HZ)
75481 jif = HZ - 1;
75482- atomic_inc(&histogram[jif]);
75483+ atomic_inc_unchecked(&histogram[jif]);
75484 }
75485
75486 #else
75487diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
75488index fc1056f..501a546 100644
75489--- a/fs/cachefiles/namei.c
75490+++ b/fs/cachefiles/namei.c
75491@@ -312,7 +312,7 @@ try_again:
75492 /* first step is to make up a grave dentry in the graveyard */
75493 sprintf(nbuffer, "%08x%08x",
75494 (uint32_t) get_seconds(),
75495- (uint32_t) atomic_inc_return(&cache->gravecounter));
75496+ (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
75497
75498 /* do the multiway lock magic */
75499 trap = lock_rename(cache->graveyard, dir);
75500diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
75501index eccd339..4c1d995 100644
75502--- a/fs/cachefiles/proc.c
75503+++ b/fs/cachefiles/proc.c
75504@@ -14,9 +14,9 @@
75505 #include <linux/seq_file.h>
75506 #include "internal.h"
75507
75508-atomic_t cachefiles_lookup_histogram[HZ];
75509-atomic_t cachefiles_mkdir_histogram[HZ];
75510-atomic_t cachefiles_create_histogram[HZ];
75511+atomic_unchecked_t cachefiles_lookup_histogram[HZ];
75512+atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
75513+atomic_unchecked_t cachefiles_create_histogram[HZ];
75514
75515 /*
75516 * display the latency histogram
75517@@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
75518 return 0;
75519 default:
75520 index = (unsigned long) v - 3;
75521- x = atomic_read(&cachefiles_lookup_histogram[index]);
75522- y = atomic_read(&cachefiles_mkdir_histogram[index]);
75523- z = atomic_read(&cachefiles_create_histogram[index]);
75524+ x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
75525+ y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
75526+ z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
75527 if (x == 0 && y == 0 && z == 0)
75528 return 0;
75529
75530diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
75531index 9314b4e..4a1f602 100644
75532--- a/fs/ceph/dir.c
75533+++ b/fs/ceph/dir.c
75534@@ -214,10 +214,18 @@ static int __dcache_readdir(struct file *file, struct dir_context *ctx,
75535 spin_unlock(&dentry->d_lock);
75536
75537 if (emit_dentry) {
75538+ char d_name[DNAME_INLINE_LEN];
75539+ const unsigned char *name;
75540+
75541 dout(" %llu (%llu) dentry %p %pd %p\n", di->offset, ctx->pos,
75542 dentry, dentry, d_inode(dentry));
75543 ctx->pos = di->offset;
75544- if (!dir_emit(ctx, dentry->d_name.name,
75545+ name = dentry->d_name.name;
75546+ if (name == dentry->d_iname) {
75547+ memcpy(d_name, name, dentry->d_name.len);
75548+ name = d_name;
75549+ }
75550+ if (!dir_emit(ctx, name,
75551 dentry->d_name.len,
75552 ceph_translate_ino(dentry->d_sb,
75553 d_inode(dentry)->i_ino),
75554@@ -259,7 +267,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
75555 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
75556 struct ceph_mds_client *mdsc = fsc->mdsc;
75557 unsigned frag = fpos_frag(ctx->pos);
75558- int off = fpos_off(ctx->pos);
75559+ unsigned int off = fpos_off(ctx->pos);
75560 int err;
75561 u32 ftype;
75562 struct ceph_mds_reply_info_parsed *rinfo;
75563diff --git a/fs/ceph/super.c b/fs/ceph/super.c
75564index 7b6bfcb..f8d5416 100644
75565--- a/fs/ceph/super.c
75566+++ b/fs/ceph/super.c
75567@@ -906,7 +906,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
75568 /*
75569 * construct our own bdi so we can control readahead, etc.
75570 */
75571-static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
75572+static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
75573
75574 static int ceph_register_bdi(struct super_block *sb,
75575 struct ceph_fs_client *fsc)
75576@@ -923,7 +923,7 @@ static int ceph_register_bdi(struct super_block *sb,
75577 VM_MAX_READAHEAD * 1024 / PAGE_CACHE_SIZE;
75578
75579 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
75580- atomic_long_inc_return(&bdi_seq));
75581+ atomic_long_inc_return_unchecked(&bdi_seq));
75582 if (!err)
75583 sb->s_bdi = &fsc->backing_dev_info;
75584 return err;
75585diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
75586index 7febcf2..62a5721 100644
75587--- a/fs/cifs/cifs_debug.c
75588+++ b/fs/cifs/cifs_debug.c
75589@@ -269,8 +269,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
75590
75591 if (strtobool(&c, &bv) == 0) {
75592 #ifdef CONFIG_CIFS_STATS2
75593- atomic_set(&totBufAllocCount, 0);
75594- atomic_set(&totSmBufAllocCount, 0);
75595+ atomic_set_unchecked(&totBufAllocCount, 0);
75596+ atomic_set_unchecked(&totSmBufAllocCount, 0);
75597 #endif /* CONFIG_CIFS_STATS2 */
75598 spin_lock(&cifs_tcp_ses_lock);
75599 list_for_each(tmp1, &cifs_tcp_ses_list) {
75600@@ -283,7 +283,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
75601 tcon = list_entry(tmp3,
75602 struct cifs_tcon,
75603 tcon_list);
75604- atomic_set(&tcon->num_smbs_sent, 0);
75605+ atomic_set_unchecked(&tcon->num_smbs_sent, 0);
75606 if (server->ops->clear_stats)
75607 server->ops->clear_stats(tcon);
75608 }
75609@@ -315,8 +315,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
75610 smBufAllocCount.counter, cifs_min_small);
75611 #ifdef CONFIG_CIFS_STATS2
75612 seq_printf(m, "Total Large %d Small %d Allocations\n",
75613- atomic_read(&totBufAllocCount),
75614- atomic_read(&totSmBufAllocCount));
75615+ atomic_read_unchecked(&totBufAllocCount),
75616+ atomic_read_unchecked(&totSmBufAllocCount));
75617 #endif /* CONFIG_CIFS_STATS2 */
75618
75619 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
75620@@ -345,7 +345,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
75621 if (tcon->need_reconnect)
75622 seq_puts(m, "\tDISCONNECTED ");
75623 seq_printf(m, "\nSMBs: %d",
75624- atomic_read(&tcon->num_smbs_sent));
75625+ atomic_read_unchecked(&tcon->num_smbs_sent));
75626 if (server->ops->print_stats)
75627 server->ops->print_stats(m, tcon);
75628 }
75629diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
75630index 6a1119e..b2f2160 100644
75631--- a/fs/cifs/cifsfs.c
75632+++ b/fs/cifs/cifsfs.c
75633@@ -1082,7 +1082,7 @@ cifs_init_request_bufs(void)
75634 */
75635 cifs_req_cachep = kmem_cache_create("cifs_request",
75636 CIFSMaxBufSize + max_hdr_size, 0,
75637- SLAB_HWCACHE_ALIGN, NULL);
75638+ SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
75639 if (cifs_req_cachep == NULL)
75640 return -ENOMEM;
75641
75642@@ -1109,7 +1109,7 @@ cifs_init_request_bufs(void)
75643 efficient to alloc 1 per page off the slab compared to 17K (5page)
75644 alloc of large cifs buffers even when page debugging is on */
75645 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
75646- MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
75647+ MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
75648 NULL);
75649 if (cifs_sm_req_cachep == NULL) {
75650 mempool_destroy(cifs_req_poolp);
75651@@ -1194,8 +1194,8 @@ init_cifs(void)
75652 atomic_set(&bufAllocCount, 0);
75653 atomic_set(&smBufAllocCount, 0);
75654 #ifdef CONFIG_CIFS_STATS2
75655- atomic_set(&totBufAllocCount, 0);
75656- atomic_set(&totSmBufAllocCount, 0);
75657+ atomic_set_unchecked(&totBufAllocCount, 0);
75658+ atomic_set_unchecked(&totSmBufAllocCount, 0);
75659 #endif /* CONFIG_CIFS_STATS2 */
75660
75661 atomic_set(&midCount, 0);
75662diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
75663index b406a32..243eb1c 100644
75664--- a/fs/cifs/cifsglob.h
75665+++ b/fs/cifs/cifsglob.h
75666@@ -832,35 +832,35 @@ struct cifs_tcon {
75667 __u16 Flags; /* optional support bits */
75668 enum statusEnum tidStatus;
75669 #ifdef CONFIG_CIFS_STATS
75670- atomic_t num_smbs_sent;
75671+ atomic_unchecked_t num_smbs_sent;
75672 union {
75673 struct {
75674- atomic_t num_writes;
75675- atomic_t num_reads;
75676- atomic_t num_flushes;
75677- atomic_t num_oplock_brks;
75678- atomic_t num_opens;
75679- atomic_t num_closes;
75680- atomic_t num_deletes;
75681- atomic_t num_mkdirs;
75682- atomic_t num_posixopens;
75683- atomic_t num_posixmkdirs;
75684- atomic_t num_rmdirs;
75685- atomic_t num_renames;
75686- atomic_t num_t2renames;
75687- atomic_t num_ffirst;
75688- atomic_t num_fnext;
75689- atomic_t num_fclose;
75690- atomic_t num_hardlinks;
75691- atomic_t num_symlinks;
75692- atomic_t num_locks;
75693- atomic_t num_acl_get;
75694- atomic_t num_acl_set;
75695+ atomic_unchecked_t num_writes;
75696+ atomic_unchecked_t num_reads;
75697+ atomic_unchecked_t num_flushes;
75698+ atomic_unchecked_t num_oplock_brks;
75699+ atomic_unchecked_t num_opens;
75700+ atomic_unchecked_t num_closes;
75701+ atomic_unchecked_t num_deletes;
75702+ atomic_unchecked_t num_mkdirs;
75703+ atomic_unchecked_t num_posixopens;
75704+ atomic_unchecked_t num_posixmkdirs;
75705+ atomic_unchecked_t num_rmdirs;
75706+ atomic_unchecked_t num_renames;
75707+ atomic_unchecked_t num_t2renames;
75708+ atomic_unchecked_t num_ffirst;
75709+ atomic_unchecked_t num_fnext;
75710+ atomic_unchecked_t num_fclose;
75711+ atomic_unchecked_t num_hardlinks;
75712+ atomic_unchecked_t num_symlinks;
75713+ atomic_unchecked_t num_locks;
75714+ atomic_unchecked_t num_acl_get;
75715+ atomic_unchecked_t num_acl_set;
75716 } cifs_stats;
75717 #ifdef CONFIG_CIFS_SMB2
75718 struct {
75719- atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
75720- atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
75721+ atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
75722+ atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
75723 } smb2_stats;
75724 #endif /* CONFIG_CIFS_SMB2 */
75725 } stats;
75726@@ -1207,7 +1207,7 @@ convert_delimiter(char *path, char delim)
75727 }
75728
75729 #ifdef CONFIG_CIFS_STATS
75730-#define cifs_stats_inc atomic_inc
75731+#define cifs_stats_inc atomic_inc_unchecked
75732
75733 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
75734 unsigned int bytes)
75735@@ -1574,8 +1574,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
75736 /* Various Debug counters */
75737 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
75738 #ifdef CONFIG_CIFS_STATS2
75739-GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
75740-GLOBAL_EXTERN atomic_t totSmBufAllocCount;
75741+GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
75742+GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
75743 #endif
75744 GLOBAL_EXTERN atomic_t smBufAllocCount;
75745 GLOBAL_EXTERN atomic_t midCount;
75746diff --git a/fs/cifs/file.c b/fs/cifs/file.c
75747index 3f50cee..7741620 100644
75748--- a/fs/cifs/file.c
75749+++ b/fs/cifs/file.c
75750@@ -2054,10 +2054,14 @@ static int cifs_writepages(struct address_space *mapping,
75751 index = mapping->writeback_index; /* Start from prev offset */
75752 end = -1;
75753 } else {
75754- index = wbc->range_start >> PAGE_CACHE_SHIFT;
75755- end = wbc->range_end >> PAGE_CACHE_SHIFT;
75756- if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
75757+ if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) {
75758 range_whole = true;
75759+ index = 0;
75760+ end = ULONG_MAX;
75761+ } else {
75762+ index = wbc->range_start >> PAGE_CACHE_SHIFT;
75763+ end = wbc->range_end >> PAGE_CACHE_SHIFT;
75764+ }
75765 scanned = true;
75766 }
75767 server = cifs_sb_master_tcon(cifs_sb)->ses->server;
75768diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
75769index 8442b8b..ea6986f 100644
75770--- a/fs/cifs/misc.c
75771+++ b/fs/cifs/misc.c
75772@@ -170,7 +170,7 @@ cifs_buf_get(void)
75773 memset(ret_buf, 0, buf_size + 3);
75774 atomic_inc(&bufAllocCount);
75775 #ifdef CONFIG_CIFS_STATS2
75776- atomic_inc(&totBufAllocCount);
75777+ atomic_inc_unchecked(&totBufAllocCount);
75778 #endif /* CONFIG_CIFS_STATS2 */
75779 }
75780
75781@@ -205,7 +205,7 @@ cifs_small_buf_get(void)
75782 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
75783 atomic_inc(&smBufAllocCount);
75784 #ifdef CONFIG_CIFS_STATS2
75785- atomic_inc(&totSmBufAllocCount);
75786+ atomic_inc_unchecked(&totSmBufAllocCount);
75787 #endif /* CONFIG_CIFS_STATS2 */
75788
75789 }
75790diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
75791index fc537c2..47d654c 100644
75792--- a/fs/cifs/smb1ops.c
75793+++ b/fs/cifs/smb1ops.c
75794@@ -622,27 +622,27 @@ static void
75795 cifs_clear_stats(struct cifs_tcon *tcon)
75796 {
75797 #ifdef CONFIG_CIFS_STATS
75798- atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
75799- atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
75800- atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
75801- atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
75802- atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
75803- atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
75804- atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
75805- atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
75806- atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
75807- atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
75808- atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
75809- atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
75810- atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
75811- atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
75812- atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
75813- atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
75814- atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
75815- atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
75816- atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
75817- atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
75818- atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
75819+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
75820+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
75821+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
75822+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
75823+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
75824+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
75825+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
75826+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
75827+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
75828+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
75829+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
75830+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
75831+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
75832+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
75833+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
75834+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
75835+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
75836+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
75837+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
75838+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
75839+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
75840 #endif
75841 }
75842
75843@@ -651,36 +651,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
75844 {
75845 #ifdef CONFIG_CIFS_STATS
75846 seq_printf(m, " Oplocks breaks: %d",
75847- atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
75848+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
75849 seq_printf(m, "\nReads: %d Bytes: %llu",
75850- atomic_read(&tcon->stats.cifs_stats.num_reads),
75851+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
75852 (long long)(tcon->bytes_read));
75853 seq_printf(m, "\nWrites: %d Bytes: %llu",
75854- atomic_read(&tcon->stats.cifs_stats.num_writes),
75855+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
75856 (long long)(tcon->bytes_written));
75857 seq_printf(m, "\nFlushes: %d",
75858- atomic_read(&tcon->stats.cifs_stats.num_flushes));
75859+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
75860 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
75861- atomic_read(&tcon->stats.cifs_stats.num_locks),
75862- atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
75863- atomic_read(&tcon->stats.cifs_stats.num_symlinks));
75864+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
75865+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
75866+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
75867 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
75868- atomic_read(&tcon->stats.cifs_stats.num_opens),
75869- atomic_read(&tcon->stats.cifs_stats.num_closes),
75870- atomic_read(&tcon->stats.cifs_stats.num_deletes));
75871+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
75872+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
75873+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
75874 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
75875- atomic_read(&tcon->stats.cifs_stats.num_posixopens),
75876- atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
75877+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
75878+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
75879 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
75880- atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
75881- atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
75882+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
75883+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
75884 seq_printf(m, "\nRenames: %d T2 Renames %d",
75885- atomic_read(&tcon->stats.cifs_stats.num_renames),
75886- atomic_read(&tcon->stats.cifs_stats.num_t2renames));
75887+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
75888+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
75889 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
75890- atomic_read(&tcon->stats.cifs_stats.num_ffirst),
75891- atomic_read(&tcon->stats.cifs_stats.num_fnext),
75892- atomic_read(&tcon->stats.cifs_stats.num_fclose));
75893+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
75894+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
75895+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
75896 #endif
75897 }
75898
75899diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
75900index 18da19f..38a3a79 100644
75901--- a/fs/cifs/smb2ops.c
75902+++ b/fs/cifs/smb2ops.c
75903@@ -422,8 +422,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
75904 #ifdef CONFIG_CIFS_STATS
75905 int i;
75906 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
75907- atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
75908- atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
75909+ atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
75910+ atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
75911 }
75912 #endif
75913 }
75914@@ -463,65 +463,65 @@ static void
75915 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
75916 {
75917 #ifdef CONFIG_CIFS_STATS
75918- atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
75919- atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
75920+ atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
75921+ atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
75922 seq_printf(m, "\nNegotiates: %d sent %d failed",
75923- atomic_read(&sent[SMB2_NEGOTIATE_HE]),
75924- atomic_read(&failed[SMB2_NEGOTIATE_HE]));
75925+ atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
75926+ atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
75927 seq_printf(m, "\nSessionSetups: %d sent %d failed",
75928- atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
75929- atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
75930+ atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
75931+ atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
75932 seq_printf(m, "\nLogoffs: %d sent %d failed",
75933- atomic_read(&sent[SMB2_LOGOFF_HE]),
75934- atomic_read(&failed[SMB2_LOGOFF_HE]));
75935+ atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
75936+ atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
75937 seq_printf(m, "\nTreeConnects: %d sent %d failed",
75938- atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
75939- atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
75940+ atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
75941+ atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
75942 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
75943- atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
75944- atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
75945+ atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
75946+ atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
75947 seq_printf(m, "\nCreates: %d sent %d failed",
75948- atomic_read(&sent[SMB2_CREATE_HE]),
75949- atomic_read(&failed[SMB2_CREATE_HE]));
75950+ atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
75951+ atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
75952 seq_printf(m, "\nCloses: %d sent %d failed",
75953- atomic_read(&sent[SMB2_CLOSE_HE]),
75954- atomic_read(&failed[SMB2_CLOSE_HE]));
75955+ atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
75956+ atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
75957 seq_printf(m, "\nFlushes: %d sent %d failed",
75958- atomic_read(&sent[SMB2_FLUSH_HE]),
75959- atomic_read(&failed[SMB2_FLUSH_HE]));
75960+ atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
75961+ atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
75962 seq_printf(m, "\nReads: %d sent %d failed",
75963- atomic_read(&sent[SMB2_READ_HE]),
75964- atomic_read(&failed[SMB2_READ_HE]));
75965+ atomic_read_unchecked(&sent[SMB2_READ_HE]),
75966+ atomic_read_unchecked(&failed[SMB2_READ_HE]));
75967 seq_printf(m, "\nWrites: %d sent %d failed",
75968- atomic_read(&sent[SMB2_WRITE_HE]),
75969- atomic_read(&failed[SMB2_WRITE_HE]));
75970+ atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
75971+ atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
75972 seq_printf(m, "\nLocks: %d sent %d failed",
75973- atomic_read(&sent[SMB2_LOCK_HE]),
75974- atomic_read(&failed[SMB2_LOCK_HE]));
75975+ atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
75976+ atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
75977 seq_printf(m, "\nIOCTLs: %d sent %d failed",
75978- atomic_read(&sent[SMB2_IOCTL_HE]),
75979- atomic_read(&failed[SMB2_IOCTL_HE]));
75980+ atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
75981+ atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
75982 seq_printf(m, "\nCancels: %d sent %d failed",
75983- atomic_read(&sent[SMB2_CANCEL_HE]),
75984- atomic_read(&failed[SMB2_CANCEL_HE]));
75985+ atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
75986+ atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
75987 seq_printf(m, "\nEchos: %d sent %d failed",
75988- atomic_read(&sent[SMB2_ECHO_HE]),
75989- atomic_read(&failed[SMB2_ECHO_HE]));
75990+ atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
75991+ atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
75992 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
75993- atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
75994- atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
75995+ atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
75996+ atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
75997 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
75998- atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
75999- atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
76000+ atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
76001+ atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
76002 seq_printf(m, "\nQueryInfos: %d sent %d failed",
76003- atomic_read(&sent[SMB2_QUERY_INFO_HE]),
76004- atomic_read(&failed[SMB2_QUERY_INFO_HE]));
76005+ atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
76006+ atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
76007 seq_printf(m, "\nSetInfos: %d sent %d failed",
76008- atomic_read(&sent[SMB2_SET_INFO_HE]),
76009- atomic_read(&failed[SMB2_SET_INFO_HE]));
76010+ atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
76011+ atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
76012 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
76013- atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
76014- atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
76015+ atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
76016+ atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
76017 #endif
76018 }
76019
76020diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
76021index 60dd831..42f911c 100644
76022--- a/fs/cifs/smb2pdu.c
76023+++ b/fs/cifs/smb2pdu.c
76024@@ -2252,8 +2252,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
76025 default:
76026 cifs_dbg(VFS, "info level %u isn't supported\n",
76027 srch_inf->info_level);
76028- rc = -EINVAL;
76029- goto qdir_exit;
76030+ return -EINVAL;
76031 }
76032
76033 req->FileIndex = cpu_to_le32(index);
76034diff --git a/fs/coda/cache.c b/fs/coda/cache.c
76035index 5bb630a..043dc70 100644
76036--- a/fs/coda/cache.c
76037+++ b/fs/coda/cache.c
76038@@ -24,7 +24,7 @@
76039 #include "coda_linux.h"
76040 #include "coda_cache.h"
76041
76042-static atomic_t permission_epoch = ATOMIC_INIT(0);
76043+static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
76044
76045 /* replace or extend an acl cache hit */
76046 void coda_cache_enter(struct inode *inode, int mask)
76047@@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
76048 struct coda_inode_info *cii = ITOC(inode);
76049
76050 spin_lock(&cii->c_lock);
76051- cii->c_cached_epoch = atomic_read(&permission_epoch);
76052+ cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
76053 if (!uid_eq(cii->c_uid, current_fsuid())) {
76054 cii->c_uid = current_fsuid();
76055 cii->c_cached_perm = mask;
76056@@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
76057 {
76058 struct coda_inode_info *cii = ITOC(inode);
76059 spin_lock(&cii->c_lock);
76060- cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
76061+ cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
76062 spin_unlock(&cii->c_lock);
76063 }
76064
76065 /* remove all acl caches */
76066 void coda_cache_clear_all(struct super_block *sb)
76067 {
76068- atomic_inc(&permission_epoch);
76069+ atomic_inc_unchecked(&permission_epoch);
76070 }
76071
76072
76073@@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
76074 spin_lock(&cii->c_lock);
76075 hit = (mask & cii->c_cached_perm) == mask &&
76076 uid_eq(cii->c_uid, current_fsuid()) &&
76077- cii->c_cached_epoch == atomic_read(&permission_epoch);
76078+ cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
76079 spin_unlock(&cii->c_lock);
76080
76081 return hit;
76082diff --git a/fs/compat.c b/fs/compat.c
76083index 6fd272d..dd34ba2 100644
76084--- a/fs/compat.c
76085+++ b/fs/compat.c
76086@@ -54,7 +54,7 @@
76087 #include <asm/ioctls.h>
76088 #include "internal.h"
76089
76090-int compat_log = 1;
76091+int compat_log = 0;
76092
76093 int compat_printk(const char *fmt, ...)
76094 {
76095@@ -512,7 +512,7 @@ COMPAT_SYSCALL_DEFINE2(io_setup, unsigned, nr_reqs, u32 __user *, ctx32p)
76096
76097 set_fs(KERNEL_DS);
76098 /* The __user pointer cast is valid because of the set_fs() */
76099- ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
76100+ ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
76101 set_fs(oldfs);
76102 /* truncating is ok because it's a user address */
76103 if (!ret)
76104@@ -562,7 +562,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
76105 goto out;
76106
76107 ret = -EINVAL;
76108- if (nr_segs > UIO_MAXIOV || nr_segs < 0)
76109+ if (nr_segs > UIO_MAXIOV)
76110 goto out;
76111 if (nr_segs > fast_segs) {
76112 ret = -ENOMEM;
76113@@ -844,6 +844,7 @@ struct compat_old_linux_dirent {
76114 struct compat_readdir_callback {
76115 struct dir_context ctx;
76116 struct compat_old_linux_dirent __user *dirent;
76117+ struct file * file;
76118 int result;
76119 };
76120
76121@@ -863,6 +864,10 @@ static int compat_fillonedir(struct dir_context *ctx, const char *name,
76122 buf->result = -EOVERFLOW;
76123 return -EOVERFLOW;
76124 }
76125+
76126+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
76127+ return 0;
76128+
76129 buf->result++;
76130 dirent = buf->dirent;
76131 if (!access_ok(VERIFY_WRITE, dirent,
76132@@ -894,6 +899,7 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
76133 if (!f.file)
76134 return -EBADF;
76135
76136+ buf.file = f.file;
76137 error = iterate_dir(f.file, &buf.ctx);
76138 if (buf.result)
76139 error = buf.result;
76140@@ -913,6 +919,7 @@ struct compat_getdents_callback {
76141 struct dir_context ctx;
76142 struct compat_linux_dirent __user *current_dir;
76143 struct compat_linux_dirent __user *previous;
76144+ struct file * file;
76145 int count;
76146 int error;
76147 };
76148@@ -935,6 +942,10 @@ static int compat_filldir(struct dir_context *ctx, const char *name, int namlen,
76149 buf->error = -EOVERFLOW;
76150 return -EOVERFLOW;
76151 }
76152+
76153+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
76154+ return 0;
76155+
76156 dirent = buf->previous;
76157 if (dirent) {
76158 if (__put_user(offset, &dirent->d_off))
76159@@ -980,6 +991,7 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd,
76160 if (!f.file)
76161 return -EBADF;
76162
76163+ buf.file = f.file;
76164 error = iterate_dir(f.file, &buf.ctx);
76165 if (error >= 0)
76166 error = buf.error;
76167@@ -1000,6 +1012,7 @@ struct compat_getdents_callback64 {
76168 struct dir_context ctx;
76169 struct linux_dirent64 __user *current_dir;
76170 struct linux_dirent64 __user *previous;
76171+ struct file * file;
76172 int count;
76173 int error;
76174 };
76175@@ -1018,6 +1031,10 @@ static int compat_filldir64(struct dir_context *ctx, const char *name,
76176 buf->error = -EINVAL; /* only used if we fail.. */
76177 if (reclen > buf->count)
76178 return -EINVAL;
76179+
76180+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
76181+ return 0;
76182+
76183 dirent = buf->previous;
76184
76185 if (dirent) {
76186@@ -1067,6 +1084,7 @@ COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd,
76187 if (!f.file)
76188 return -EBADF;
76189
76190+ buf.file = f.file;
76191 error = iterate_dir(f.file, &buf.ctx);
76192 if (error >= 0)
76193 error = buf.error;
76194diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
76195index 4d24d17..4f8c09e 100644
76196--- a/fs/compat_binfmt_elf.c
76197+++ b/fs/compat_binfmt_elf.c
76198@@ -30,11 +30,13 @@
76199 #undef elf_phdr
76200 #undef elf_shdr
76201 #undef elf_note
76202+#undef elf_dyn
76203 #undef elf_addr_t
76204 #define elfhdr elf32_hdr
76205 #define elf_phdr elf32_phdr
76206 #define elf_shdr elf32_shdr
76207 #define elf_note elf32_note
76208+#define elf_dyn Elf32_Dyn
76209 #define elf_addr_t Elf32_Addr
76210
76211 /*
76212diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
76213index 48851f6..6c79d32 100644
76214--- a/fs/compat_ioctl.c
76215+++ b/fs/compat_ioctl.c
76216@@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
76217 return -EFAULT;
76218 if (__get_user(udata, &ss32->iomem_base))
76219 return -EFAULT;
76220- ss.iomem_base = compat_ptr(udata);
76221+ ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
76222 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
76223 __get_user(ss.port_high, &ss32->port_high))
76224 return -EFAULT;
76225@@ -704,8 +704,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
76226 for (i = 0; i < nmsgs; i++) {
76227 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
76228 return -EFAULT;
76229- if (get_user(datap, &umsgs[i].buf) ||
76230- put_user(compat_ptr(datap), &tmsgs[i].buf))
76231+ if (get_user(datap, (compat_caddr_t __user *)&umsgs[i].buf) ||
76232+ put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
76233 return -EFAULT;
76234 }
76235 return sys_ioctl(fd, cmd, (unsigned long)tdata);
76236@@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
76237 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
76238 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
76239 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
76240- copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
76241+ copy_in_user(p->l_pad, p32->l_pad, 4*sizeof(u32)))
76242 return -EFAULT;
76243
76244 return ioctl_preallocate(file, p);
76245@@ -1621,8 +1621,8 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
76246 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
76247 {
76248 unsigned int a, b;
76249- a = *(unsigned int *)p;
76250- b = *(unsigned int *)q;
76251+ a = *(const unsigned int *)p;
76252+ b = *(const unsigned int *)q;
76253 if (a > b)
76254 return 1;
76255 if (a < b)
76256diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
76257index c81ce7f..f3de5fd 100644
76258--- a/fs/configfs/dir.c
76259+++ b/fs/configfs/dir.c
76260@@ -1540,7 +1540,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
76261 }
76262 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
76263 struct configfs_dirent *next;
76264- const char *name;
76265+ const unsigned char * name;
76266+ char d_name[sizeof(next->s_dentry->d_iname)];
76267 int len;
76268 struct inode *inode = NULL;
76269
76270@@ -1549,7 +1550,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
76271 continue;
76272
76273 name = configfs_get_name(next);
76274- len = strlen(name);
76275+ if (next->s_dentry && name == next->s_dentry->d_iname) {
76276+ len = next->s_dentry->d_name.len;
76277+ memcpy(d_name, name, len);
76278+ name = d_name;
76279+ } else
76280+ len = strlen(name);
76281
76282 /*
76283 * We'll have a dentry and an inode for
76284diff --git a/fs/coredump.c b/fs/coredump.c
76285index a8f7564..3dde349 100644
76286--- a/fs/coredump.c
76287+++ b/fs/coredump.c
76288@@ -457,8 +457,8 @@ static void wait_for_dump_helpers(struct file *file)
76289 struct pipe_inode_info *pipe = file->private_data;
76290
76291 pipe_lock(pipe);
76292- pipe->readers++;
76293- pipe->writers--;
76294+ atomic_inc(&pipe->readers);
76295+ atomic_dec(&pipe->writers);
76296 wake_up_interruptible_sync(&pipe->wait);
76297 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
76298 pipe_unlock(pipe);
76299@@ -467,11 +467,11 @@ static void wait_for_dump_helpers(struct file *file)
76300 * We actually want wait_event_freezable() but then we need
76301 * to clear TIF_SIGPENDING and improve dump_interrupted().
76302 */
76303- wait_event_interruptible(pipe->wait, pipe->readers == 1);
76304+ wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
76305
76306 pipe_lock(pipe);
76307- pipe->readers--;
76308- pipe->writers++;
76309+ atomic_dec(&pipe->readers);
76310+ atomic_inc(&pipe->writers);
76311 pipe_unlock(pipe);
76312 }
76313
76314@@ -518,7 +518,9 @@ void do_coredump(const siginfo_t *siginfo)
76315 /* require nonrelative corefile path and be extra careful */
76316 bool need_suid_safe = false;
76317 bool core_dumped = false;
76318- static atomic_t core_dump_count = ATOMIC_INIT(0);
76319+ static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
76320+ long signr = siginfo->si_signo;
76321+ int dumpable;
76322 struct coredump_params cprm = {
76323 .siginfo = siginfo,
76324 .regs = signal_pt_regs(),
76325@@ -531,12 +533,17 @@ void do_coredump(const siginfo_t *siginfo)
76326 .mm_flags = mm->flags,
76327 };
76328
76329- audit_core_dumps(siginfo->si_signo);
76330+ audit_core_dumps(signr);
76331+
76332+ dumpable = __get_dumpable(cprm.mm_flags);
76333+
76334+ if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
76335+ gr_handle_brute_attach(dumpable);
76336
76337 binfmt = mm->binfmt;
76338 if (!binfmt || !binfmt->core_dump)
76339 goto fail;
76340- if (!__get_dumpable(cprm.mm_flags))
76341+ if (!dumpable)
76342 goto fail;
76343
76344 cred = prepare_creds();
76345@@ -554,7 +561,7 @@ void do_coredump(const siginfo_t *siginfo)
76346 need_suid_safe = true;
76347 }
76348
76349- retval = coredump_wait(siginfo->si_signo, &core_state);
76350+ retval = coredump_wait(signr, &core_state);
76351 if (retval < 0)
76352 goto fail_creds;
76353
76354@@ -597,7 +604,7 @@ void do_coredump(const siginfo_t *siginfo)
76355 }
76356 cprm.limit = RLIM_INFINITY;
76357
76358- dump_count = atomic_inc_return(&core_dump_count);
76359+ dump_count = atomic_inc_return_unchecked(&core_dump_count);
76360 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
76361 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
76362 task_tgid_vnr(current), current->comm);
76363@@ -629,6 +636,8 @@ void do_coredump(const siginfo_t *siginfo)
76364 } else {
76365 struct inode *inode;
76366
76367+ gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
76368+
76369 if (cprm.limit < binfmt->min_coredump)
76370 goto fail_unlock;
76371
76372@@ -718,7 +727,7 @@ close_fail:
76373 filp_close(cprm.file, NULL);
76374 fail_dropcount:
76375 if (ispipe)
76376- atomic_dec(&core_dump_count);
76377+ atomic_dec_unchecked(&core_dump_count);
76378 fail_unlock:
76379 kfree(cn.corename);
76380 coredump_finish(mm, core_dumped);
76381@@ -739,6 +748,8 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
76382 struct file *file = cprm->file;
76383 loff_t pos = file->f_pos;
76384 ssize_t n;
76385+
76386+ gr_learn_resource(current, RLIMIT_CORE, cprm->written + nr, 1);
76387 if (cprm->written + nr > cprm->limit)
76388 return 0;
76389 while (nr) {
76390diff --git a/fs/dcache.c b/fs/dcache.c
76391index e3b44ca..e0d94f1 100644
76392--- a/fs/dcache.c
76393+++ b/fs/dcache.c
76394@@ -545,7 +545,7 @@ static void __dentry_kill(struct dentry *dentry)
76395 * dentry_iput drops the locks, at which point nobody (except
76396 * transient RCU lookups) can reach this dentry.
76397 */
76398- BUG_ON(dentry->d_lockref.count > 0);
76399+ BUG_ON(__lockref_read(&dentry->d_lockref) > 0);
76400 this_cpu_dec(nr_dentry);
76401 if (dentry->d_op && dentry->d_op->d_release)
76402 dentry->d_op->d_release(dentry);
76403@@ -598,7 +598,7 @@ static inline struct dentry *lock_parent(struct dentry *dentry)
76404 struct dentry *parent = dentry->d_parent;
76405 if (IS_ROOT(dentry))
76406 return NULL;
76407- if (unlikely(dentry->d_lockref.count < 0))
76408+ if (unlikely(__lockref_read(&dentry->d_lockref) < 0))
76409 return NULL;
76410 if (likely(spin_trylock(&parent->d_lock)))
76411 return parent;
76412@@ -660,8 +660,8 @@ static inline bool fast_dput(struct dentry *dentry)
76413 */
76414 if (unlikely(ret < 0)) {
76415 spin_lock(&dentry->d_lock);
76416- if (dentry->d_lockref.count > 1) {
76417- dentry->d_lockref.count--;
76418+ if (__lockref_read(&dentry->d_lockref) > 1) {
76419+ __lockref_dec(&dentry->d_lockref);
76420 spin_unlock(&dentry->d_lock);
76421 return 1;
76422 }
76423@@ -716,7 +716,7 @@ static inline bool fast_dput(struct dentry *dentry)
76424 * else could have killed it and marked it dead. Either way, we
76425 * don't need to do anything else.
76426 */
76427- if (dentry->d_lockref.count) {
76428+ if (__lockref_read(&dentry->d_lockref)) {
76429 spin_unlock(&dentry->d_lock);
76430 return 1;
76431 }
76432@@ -726,7 +726,7 @@ static inline bool fast_dput(struct dentry *dentry)
76433 * lock, and we just tested that it was zero, so we can just
76434 * set it to 1.
76435 */
76436- dentry->d_lockref.count = 1;
76437+ __lockref_set(&dentry->d_lockref, 1);
76438 return 0;
76439 }
76440
76441@@ -788,7 +788,7 @@ repeat:
76442 dentry->d_flags |= DCACHE_REFERENCED;
76443 dentry_lru_add(dentry);
76444
76445- dentry->d_lockref.count--;
76446+ __lockref_dec(&dentry->d_lockref);
76447 spin_unlock(&dentry->d_lock);
76448 return;
76449
76450@@ -803,7 +803,7 @@ EXPORT_SYMBOL(dput);
76451 /* This must be called with d_lock held */
76452 static inline void __dget_dlock(struct dentry *dentry)
76453 {
76454- dentry->d_lockref.count++;
76455+ __lockref_inc(&dentry->d_lockref);
76456 }
76457
76458 static inline void __dget(struct dentry *dentry)
76459@@ -844,8 +844,8 @@ repeat:
76460 goto repeat;
76461 }
76462 rcu_read_unlock();
76463- BUG_ON(!ret->d_lockref.count);
76464- ret->d_lockref.count++;
76465+ BUG_ON(!__lockref_read(&ret->d_lockref));
76466+ __lockref_inc(&ret->d_lockref);
76467 spin_unlock(&ret->d_lock);
76468 return ret;
76469 }
76470@@ -923,9 +923,9 @@ restart:
76471 spin_lock(&inode->i_lock);
76472 hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
76473 spin_lock(&dentry->d_lock);
76474- if (!dentry->d_lockref.count) {
76475+ if (!__lockref_read(&dentry->d_lockref)) {
76476 struct dentry *parent = lock_parent(dentry);
76477- if (likely(!dentry->d_lockref.count)) {
76478+ if (likely(!__lockref_read(&dentry->d_lockref))) {
76479 __dentry_kill(dentry);
76480 dput(parent);
76481 goto restart;
76482@@ -960,7 +960,7 @@ static void shrink_dentry_list(struct list_head *list)
76483 * We found an inuse dentry which was not removed from
76484 * the LRU because of laziness during lookup. Do not free it.
76485 */
76486- if (dentry->d_lockref.count > 0) {
76487+ if (__lockref_read(&dentry->d_lockref) > 0) {
76488 spin_unlock(&dentry->d_lock);
76489 if (parent)
76490 spin_unlock(&parent->d_lock);
76491@@ -998,8 +998,8 @@ static void shrink_dentry_list(struct list_head *list)
76492 dentry = parent;
76493 while (dentry && !lockref_put_or_lock(&dentry->d_lockref)) {
76494 parent = lock_parent(dentry);
76495- if (dentry->d_lockref.count != 1) {
76496- dentry->d_lockref.count--;
76497+ if (__lockref_read(&dentry->d_lockref) != 1) {
76498+ __lockref_inc(&dentry->d_lockref);
76499 spin_unlock(&dentry->d_lock);
76500 if (parent)
76501 spin_unlock(&parent->d_lock);
76502@@ -1039,7 +1039,7 @@ static enum lru_status dentry_lru_isolate(struct list_head *item,
76503 * counts, just remove them from the LRU. Otherwise give them
76504 * another pass through the LRU.
76505 */
76506- if (dentry->d_lockref.count) {
76507+ if (__lockref_read(&dentry->d_lockref)) {
76508 d_lru_isolate(lru, dentry);
76509 spin_unlock(&dentry->d_lock);
76510 return LRU_REMOVED;
76511@@ -1373,7 +1373,7 @@ static enum d_walk_ret select_collect(void *_data, struct dentry *dentry)
76512 } else {
76513 if (dentry->d_flags & DCACHE_LRU_LIST)
76514 d_lru_del(dentry);
76515- if (!dentry->d_lockref.count) {
76516+ if (!__lockref_read(&dentry->d_lockref)) {
76517 d_shrink_add(dentry, &data->dispose);
76518 data->found++;
76519 }
76520@@ -1421,7 +1421,7 @@ static enum d_walk_ret umount_check(void *_data, struct dentry *dentry)
76521 return D_WALK_CONTINUE;
76522
76523 /* root with refcount 1 is fine */
76524- if (dentry == _data && dentry->d_lockref.count == 1)
76525+ if (dentry == _data && __lockref_read(&dentry->d_lockref) == 1)
76526 return D_WALK_CONTINUE;
76527
76528 printk(KERN_ERR "BUG: Dentry %p{i=%lx,n=%pd} "
76529@@ -1430,7 +1430,7 @@ static enum d_walk_ret umount_check(void *_data, struct dentry *dentry)
76530 dentry->d_inode ?
76531 dentry->d_inode->i_ino : 0UL,
76532 dentry,
76533- dentry->d_lockref.count,
76534+ __lockref_read(&dentry->d_lockref),
76535 dentry->d_sb->s_type->name,
76536 dentry->d_sb->s_id);
76537 WARN_ON(1);
76538@@ -1571,7 +1571,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
76539 dentry->d_iname[DNAME_INLINE_LEN-1] = 0;
76540 if (name->len > DNAME_INLINE_LEN-1) {
76541 size_t size = offsetof(struct external_name, name[1]);
76542- struct external_name *p = kmalloc(size + name->len, GFP_KERNEL);
76543+ struct external_name *p = kmalloc(round_up(size + name->len, sizeof(unsigned long)), GFP_KERNEL);
76544 if (!p) {
76545 kmem_cache_free(dentry_cache, dentry);
76546 return NULL;
76547@@ -1594,7 +1594,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
76548 smp_wmb();
76549 dentry->d_name.name = dname;
76550
76551- dentry->d_lockref.count = 1;
76552+ __lockref_set(&dentry->d_lockref, 1);
76553 dentry->d_flags = 0;
76554 spin_lock_init(&dentry->d_lock);
76555 seqcount_init(&dentry->d_seq);
76556@@ -1603,6 +1603,9 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
76557 dentry->d_sb = sb;
76558 dentry->d_op = NULL;
76559 dentry->d_fsdata = NULL;
76560+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
76561+ atomic_set(&dentry->chroot_refcnt, 0);
76562+#endif
76563 INIT_HLIST_BL_NODE(&dentry->d_hash);
76564 INIT_LIST_HEAD(&dentry->d_lru);
76565 INIT_LIST_HEAD(&dentry->d_subdirs);
76566@@ -2327,7 +2330,7 @@ struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name)
76567 goto next;
76568 }
76569
76570- dentry->d_lockref.count++;
76571+ __lockref_inc(&dentry->d_lockref);
76572 found = dentry;
76573 spin_unlock(&dentry->d_lock);
76574 break;
76575@@ -2395,7 +2398,7 @@ again:
76576 spin_lock(&dentry->d_lock);
76577 inode = dentry->d_inode;
76578 isdir = S_ISDIR(inode->i_mode);
76579- if (dentry->d_lockref.count == 1) {
76580+ if (__lockref_read(&dentry->d_lockref) == 1) {
76581 if (!spin_trylock(&inode->i_lock)) {
76582 spin_unlock(&dentry->d_lock);
76583 cpu_relax();
76584@@ -3344,7 +3347,7 @@ static enum d_walk_ret d_genocide_kill(void *data, struct dentry *dentry)
76585
76586 if (!(dentry->d_flags & DCACHE_GENOCIDE)) {
76587 dentry->d_flags |= DCACHE_GENOCIDE;
76588- dentry->d_lockref.count--;
76589+ __lockref_dec(&dentry->d_lockref);
76590 }
76591 }
76592 return D_WALK_CONTINUE;
76593@@ -3452,7 +3455,8 @@ void __init vfs_caches_init_early(void)
76594 void __init vfs_caches_init(void)
76595 {
76596 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
76597- SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
76598+ SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
76599+ SLAB_NO_SANITIZE, NULL);
76600
76601 dcache_init();
76602 inode_init();
76603diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
76604index c711be8..23b8df9 100644
76605--- a/fs/debugfs/inode.c
76606+++ b/fs/debugfs/inode.c
76607@@ -402,6 +402,10 @@ EXPORT_SYMBOL_GPL(debugfs_create_file_size);
76608 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
76609 * returned.
76610 */
76611+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
76612+extern int grsec_enable_sysfs_restrict;
76613+#endif
76614+
76615 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
76616 {
76617 struct dentry *dentry = start_creating(name, parent);
76618@@ -414,7 +418,12 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
76619 if (unlikely(!inode))
76620 return failed_creating(dentry);
76621
76622- inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
76623+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
76624+ if (grsec_enable_sysfs_restrict)
76625+ inode->i_mode = S_IFDIR | S_IRWXU;
76626+ else
76627+#endif
76628+ inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
76629 inode->i_op = &simple_dir_inode_operations;
76630 inode->i_fop = &simple_dir_operations;
76631
76632diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
76633index 754fd6c..ed6acbe 100644
76634--- a/fs/dlm/lowcomms.c
76635+++ b/fs/dlm/lowcomms.c
76636@@ -538,7 +538,7 @@ static void close_connection(struct connection *con, bool and_other)
76637 /* We only send shutdown messages to nodes that are not part of the cluster */
76638 static void sctp_send_shutdown(sctp_assoc_t associd)
76639 {
76640- static char outcmsg[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
76641+ char outcmsg[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
76642 struct msghdr outmessage;
76643 struct cmsghdr *cmsg;
76644 struct sctp_sndrcvinfo *sinfo;
76645diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
76646index 3c4db11..a43976f 100644
76647--- a/fs/ecryptfs/inode.c
76648+++ b/fs/ecryptfs/inode.c
76649@@ -662,7 +662,7 @@ static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
76650 old_fs = get_fs();
76651 set_fs(get_ds());
76652 rc = d_inode(lower_dentry)->i_op->readlink(lower_dentry,
76653- (char __user *)lower_buf,
76654+ (char __force_user *)lower_buf,
76655 PATH_MAX);
76656 set_fs(old_fs);
76657 if (rc < 0)
76658diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
76659index e4141f2..d8263e8 100644
76660--- a/fs/ecryptfs/miscdev.c
76661+++ b/fs/ecryptfs/miscdev.c
76662@@ -304,7 +304,7 @@ check_list:
76663 goto out_unlock_msg_ctx;
76664 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
76665 if (msg_ctx->msg) {
76666- if (copy_to_user(&buf[i], packet_length, packet_length_size))
76667+ if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
76668 goto out_unlock_msg_ctx;
76669 i += packet_length_size;
76670 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
76671diff --git a/fs/exec.c b/fs/exec.c
76672index 1977c2a..b6b953a 100644
76673--- a/fs/exec.c
76674+++ b/fs/exec.c
76675@@ -56,8 +56,20 @@
76676 #include <linux/pipe_fs_i.h>
76677 #include <linux/oom.h>
76678 #include <linux/compat.h>
76679+#include <linux/random.h>
76680+#include <linux/seq_file.h>
76681+#include <linux/coredump.h>
76682+#include <linux/mman.h>
76683+
76684+#ifdef CONFIG_PAX_REFCOUNT
76685+#include <linux/kallsyms.h>
76686+#include <linux/kdebug.h>
76687+#endif
76688+
76689+#include <trace/events/fs.h>
76690
76691 #include <asm/uaccess.h>
76692+#include <asm/sections.h>
76693 #include <asm/mmu_context.h>
76694 #include <asm/tlb.h>
76695
76696@@ -66,19 +78,34 @@
76697
76698 #include <trace/events/sched.h>
76699
76700+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76701+void __weak pax_set_initial_flags(struct linux_binprm *bprm)
76702+{
76703+ 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");
76704+}
76705+#endif
76706+
76707+#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
76708+void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76709+EXPORT_SYMBOL(pax_set_initial_flags_func);
76710+#endif
76711+
76712 int suid_dumpable = 0;
76713
76714 static LIST_HEAD(formats);
76715 static DEFINE_RWLOCK(binfmt_lock);
76716
76717+extern int gr_process_kernel_exec_ban(void);
76718+extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
76719+
76720 void __register_binfmt(struct linux_binfmt * fmt, int insert)
76721 {
76722 BUG_ON(!fmt);
76723 if (WARN_ON(!fmt->load_binary))
76724 return;
76725 write_lock(&binfmt_lock);
76726- insert ? list_add(&fmt->lh, &formats) :
76727- list_add_tail(&fmt->lh, &formats);
76728+ insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
76729+ pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
76730 write_unlock(&binfmt_lock);
76731 }
76732
76733@@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
76734 void unregister_binfmt(struct linux_binfmt * fmt)
76735 {
76736 write_lock(&binfmt_lock);
76737- list_del(&fmt->lh);
76738+ pax_list_del((struct list_head *)&fmt->lh);
76739 write_unlock(&binfmt_lock);
76740 }
76741
76742@@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
76743 int write)
76744 {
76745 struct page *page;
76746- int ret;
76747
76748-#ifdef CONFIG_STACK_GROWSUP
76749- if (write) {
76750- ret = expand_downwards(bprm->vma, pos);
76751- if (ret < 0)
76752- return NULL;
76753- }
76754-#endif
76755- ret = get_user_pages(current, bprm->mm, pos,
76756- 1, write, 1, &page, NULL);
76757- if (ret <= 0)
76758+ if (0 > expand_downwards(bprm->vma, pos))
76759+ return NULL;
76760+ if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
76761 return NULL;
76762
76763 if (write) {
76764@@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
76765 if (size <= ARG_MAX)
76766 return page;
76767
76768+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76769+ // only allow 512KB for argv+env on suid/sgid binaries
76770+ // to prevent easy ASLR exhaustion
76771+ if (((!uid_eq(bprm->cred->euid, current_euid())) ||
76772+ (!gid_eq(bprm->cred->egid, current_egid()))) &&
76773+ (size > (512 * 1024))) {
76774+ put_page(page);
76775+ return NULL;
76776+ }
76777+#endif
76778+
76779 /*
76780 * Limit to 1/4-th the stack size for the argv+env strings.
76781 * This ensures that:
76782@@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
76783 vma->vm_end = STACK_TOP_MAX;
76784 vma->vm_start = vma->vm_end - PAGE_SIZE;
76785 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
76786+
76787+#ifdef CONFIG_PAX_SEGMEXEC
76788+ vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
76789+#endif
76790+
76791 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
76792 INIT_LIST_HEAD(&vma->anon_vma_chain);
76793
76794@@ -280,6 +315,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
76795 arch_bprm_mm_init(mm, vma);
76796 up_write(&mm->mmap_sem);
76797 bprm->p = vma->vm_end - sizeof(void *);
76798+
76799+#ifdef CONFIG_PAX_RANDUSTACK
76800+ if (randomize_va_space)
76801+ bprm->p ^= prandom_u32() & ~PAGE_MASK;
76802+#endif
76803+
76804 return 0;
76805 err:
76806 up_write(&mm->mmap_sem);
76807@@ -396,7 +437,7 @@ struct user_arg_ptr {
76808 } ptr;
76809 };
76810
76811-static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
76812+const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
76813 {
76814 const char __user *native;
76815
76816@@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
76817 compat_uptr_t compat;
76818
76819 if (get_user(compat, argv.ptr.compat + nr))
76820- return ERR_PTR(-EFAULT);
76821+ return (const char __force_user *)ERR_PTR(-EFAULT);
76822
76823 return compat_ptr(compat);
76824 }
76825 #endif
76826
76827 if (get_user(native, argv.ptr.native + nr))
76828- return ERR_PTR(-EFAULT);
76829+ return (const char __force_user *)ERR_PTR(-EFAULT);
76830
76831 return native;
76832 }
76833@@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
76834 if (!p)
76835 break;
76836
76837- if (IS_ERR(p))
76838+ if (IS_ERR((const char __force_kernel *)p))
76839 return -EFAULT;
76840
76841 if (i >= max)
76842@@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
76843
76844 ret = -EFAULT;
76845 str = get_user_arg_ptr(argv, argc);
76846- if (IS_ERR(str))
76847+ if (IS_ERR((const char __force_kernel *)str))
76848 goto out;
76849
76850 len = strnlen_user(str, MAX_ARG_STRLEN);
76851@@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
76852 int r;
76853 mm_segment_t oldfs = get_fs();
76854 struct user_arg_ptr argv = {
76855- .ptr.native = (const char __user *const __user *)__argv,
76856+ .ptr.native = (const char __user * const __force_user *)__argv,
76857 };
76858
76859 set_fs(KERNEL_DS);
76860@@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
76861 unsigned long new_end = old_end - shift;
76862 struct mmu_gather tlb;
76863
76864- BUG_ON(new_start > new_end);
76865+ if (new_start >= new_end || new_start < mmap_min_addr)
76866+ return -ENOMEM;
76867
76868 /*
76869 * ensure there are no vmas between where we want to go
76870@@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
76871 if (vma != find_vma(mm, new_start))
76872 return -EFAULT;
76873
76874+#ifdef CONFIG_PAX_SEGMEXEC
76875+ BUG_ON(pax_find_mirror_vma(vma));
76876+#endif
76877+
76878 /*
76879 * cover the whole range: [new_start, old_end)
76880 */
76881@@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
76882 stack_top = arch_align_stack(stack_top);
76883 stack_top = PAGE_ALIGN(stack_top);
76884
76885- if (unlikely(stack_top < mmap_min_addr) ||
76886- unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
76887- return -ENOMEM;
76888-
76889 stack_shift = vma->vm_end - stack_top;
76890
76891 bprm->p -= stack_shift;
76892@@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
76893 bprm->exec -= stack_shift;
76894
76895 down_write(&mm->mmap_sem);
76896+
76897+ /* Move stack pages down in memory. */
76898+ if (stack_shift) {
76899+ ret = shift_arg_pages(vma, stack_shift);
76900+ if (ret)
76901+ goto out_unlock;
76902+ }
76903+
76904 vm_flags = VM_STACK_FLAGS;
76905
76906+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
76907+ if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
76908+ vm_flags &= ~VM_EXEC;
76909+
76910+#ifdef CONFIG_PAX_MPROTECT
76911+ if (mm->pax_flags & MF_PAX_MPROTECT)
76912+ vm_flags &= ~VM_MAYEXEC;
76913+#endif
76914+
76915+ }
76916+#endif
76917+
76918 /*
76919 * Adjust stack execute permissions; explicitly enable for
76920 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
76921@@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
76922 goto out_unlock;
76923 BUG_ON(prev != vma);
76924
76925- /* Move stack pages down in memory. */
76926- if (stack_shift) {
76927- ret = shift_arg_pages(vma, stack_shift);
76928- if (ret)
76929- goto out_unlock;
76930- }
76931-
76932 /* mprotect_fixup is overkill to remove the temporary stack flags */
76933 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
76934
76935@@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
76936 #endif
76937 current->mm->start_stack = bprm->p;
76938 ret = expand_stack(vma, stack_base);
76939+
76940+#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
76941+ if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
76942+ unsigned long size;
76943+ vm_flags_t vm_flags;
76944+
76945+ size = STACK_TOP - vma->vm_end;
76946+ vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
76947+
76948+ ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
76949+
76950+#ifdef CONFIG_X86
76951+ if (!ret) {
76952+ size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
76953+ ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
76954+ }
76955+#endif
76956+
76957+ }
76958+#endif
76959+
76960 if (ret)
76961 ret = -EFAULT;
76962
76963@@ -784,8 +860,10 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
76964 if (err)
76965 goto exit;
76966
76967- if (name->name[0] != '\0')
76968+ if (name->name[0] != '\0') {
76969 fsnotify_open(file);
76970+ trace_open_exec(name->name);
76971+ }
76972
76973 out:
76974 return file;
76975@@ -818,7 +896,7 @@ int kernel_read(struct file *file, loff_t offset,
76976 old_fs = get_fs();
76977 set_fs(get_ds());
76978 /* The cast to a user pointer is valid due to the set_fs() */
76979- result = vfs_read(file, (void __user *)addr, count, &pos);
76980+ result = vfs_read(file, (void __force_user *)addr, count, &pos);
76981 set_fs(old_fs);
76982 return result;
76983 }
76984@@ -863,6 +941,7 @@ static int exec_mmap(struct mm_struct *mm)
76985 tsk->mm = mm;
76986 tsk->active_mm = mm;
76987 activate_mm(active_mm, mm);
76988+ populate_stack();
76989 tsk->mm->vmacache_seqnum = 0;
76990 vmacache_flush(tsk);
76991 task_unlock(tsk);
76992@@ -1271,7 +1350,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm)
76993 }
76994 rcu_read_unlock();
76995
76996- if (p->fs->users > n_fs)
76997+ if (atomic_read(&p->fs->users) > n_fs)
76998 bprm->unsafe |= LSM_UNSAFE_SHARE;
76999 else
77000 p->fs->in_exec = 1;
77001@@ -1472,6 +1551,31 @@ static int exec_binprm(struct linux_binprm *bprm)
77002 return ret;
77003 }
77004
77005+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77006+static DEFINE_PER_CPU(u64, exec_counter);
77007+static int __init init_exec_counters(void)
77008+{
77009+ unsigned int cpu;
77010+
77011+ for_each_possible_cpu(cpu) {
77012+ per_cpu(exec_counter, cpu) = (u64)cpu;
77013+ }
77014+
77015+ return 0;
77016+}
77017+early_initcall(init_exec_counters);
77018+static inline void increment_exec_counter(void)
77019+{
77020+ BUILD_BUG_ON(NR_CPUS > (1 << 16));
77021+ current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
77022+}
77023+#else
77024+static inline void increment_exec_counter(void) {}
77025+#endif
77026+
77027+extern void gr_handle_exec_args(struct linux_binprm *bprm,
77028+ struct user_arg_ptr argv);
77029+
77030 /*
77031 * sys_execve() executes a new program.
77032 */
77033@@ -1480,6 +1584,11 @@ static int do_execveat_common(int fd, struct filename *filename,
77034 struct user_arg_ptr envp,
77035 int flags)
77036 {
77037+#ifdef CONFIG_GRKERNSEC
77038+ struct file *old_exec_file;
77039+ struct acl_subject_label *old_acl;
77040+ struct rlimit old_rlim[RLIM_NLIMITS];
77041+#endif
77042 char *pathbuf = NULL;
77043 struct linux_binprm *bprm;
77044 struct file *file;
77045@@ -1489,6 +1598,8 @@ static int do_execveat_common(int fd, struct filename *filename,
77046 if (IS_ERR(filename))
77047 return PTR_ERR(filename);
77048
77049+ gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
77050+
77051 /*
77052 * We move the actual failure in case of RLIMIT_NPROC excess from
77053 * set*uid() to execve() because too many poorly written programs
77054@@ -1526,6 +1637,11 @@ static int do_execveat_common(int fd, struct filename *filename,
77055 if (IS_ERR(file))
77056 goto out_unmark;
77057
77058+ if (gr_ptrace_readexec(file, bprm->unsafe)) {
77059+ retval = -EPERM;
77060+ goto out_unmark;
77061+ }
77062+
77063 sched_exec();
77064
77065 bprm->file = file;
77066@@ -1552,6 +1668,11 @@ static int do_execveat_common(int fd, struct filename *filename,
77067 }
77068 bprm->interp = bprm->filename;
77069
77070+ if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
77071+ retval = -EACCES;
77072+ goto out_unmark;
77073+ }
77074+
77075 retval = bprm_mm_init(bprm);
77076 if (retval)
77077 goto out_unmark;
77078@@ -1568,24 +1689,70 @@ static int do_execveat_common(int fd, struct filename *filename,
77079 if (retval < 0)
77080 goto out;
77081
77082+#ifdef CONFIG_GRKERNSEC
77083+ old_acl = current->acl;
77084+ memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
77085+ old_exec_file = current->exec_file;
77086+ get_file(file);
77087+ current->exec_file = file;
77088+#endif
77089+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77090+ /* limit suid stack to 8MB
77091+ * we saved the old limits above and will restore them if this exec fails
77092+ */
77093+ if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
77094+ (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
77095+ current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
77096+#endif
77097+
77098+ if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
77099+ retval = -EPERM;
77100+ goto out_fail;
77101+ }
77102+
77103+ if (!gr_tpe_allow(file)) {
77104+ retval = -EACCES;
77105+ goto out_fail;
77106+ }
77107+
77108+ if (gr_check_crash_exec(file)) {
77109+ retval = -EACCES;
77110+ goto out_fail;
77111+ }
77112+
77113+ retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
77114+ bprm->unsafe);
77115+ if (retval < 0)
77116+ goto out_fail;
77117+
77118 retval = copy_strings_kernel(1, &bprm->filename, bprm);
77119 if (retval < 0)
77120- goto out;
77121+ goto out_fail;
77122
77123 bprm->exec = bprm->p;
77124 retval = copy_strings(bprm->envc, envp, bprm);
77125 if (retval < 0)
77126- goto out;
77127+ goto out_fail;
77128
77129 retval = copy_strings(bprm->argc, argv, bprm);
77130 if (retval < 0)
77131- goto out;
77132+ goto out_fail;
77133+
77134+ gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
77135+
77136+ gr_handle_exec_args(bprm, argv);
77137
77138 retval = exec_binprm(bprm);
77139 if (retval < 0)
77140- goto out;
77141+ goto out_fail;
77142+#ifdef CONFIG_GRKERNSEC
77143+ if (old_exec_file)
77144+ fput(old_exec_file);
77145+#endif
77146
77147 /* execve succeeded */
77148+
77149+ increment_exec_counter();
77150 current->fs->in_exec = 0;
77151 current->in_execve = 0;
77152 acct_update_integrals(current);
77153@@ -1597,6 +1764,14 @@ static int do_execveat_common(int fd, struct filename *filename,
77154 put_files_struct(displaced);
77155 return retval;
77156
77157+out_fail:
77158+#ifdef CONFIG_GRKERNSEC
77159+ current->acl = old_acl;
77160+ memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
77161+ fput(current->exec_file);
77162+ current->exec_file = old_exec_file;
77163+#endif
77164+
77165 out:
77166 if (bprm->mm) {
77167 acct_arg_size(bprm, 0);
77168@@ -1743,3 +1918,324 @@ COMPAT_SYSCALL_DEFINE5(execveat, int, fd,
77169 argv, envp, flags);
77170 }
77171 #endif
77172+
77173+int pax_check_flags(unsigned long *flags)
77174+{
77175+ int retval = 0;
77176+
77177+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
77178+ if (*flags & MF_PAX_SEGMEXEC)
77179+ {
77180+ *flags &= ~MF_PAX_SEGMEXEC;
77181+ retval = -EINVAL;
77182+ }
77183+#endif
77184+
77185+ if ((*flags & MF_PAX_PAGEEXEC)
77186+
77187+#ifdef CONFIG_PAX_PAGEEXEC
77188+ && (*flags & MF_PAX_SEGMEXEC)
77189+#endif
77190+
77191+ )
77192+ {
77193+ *flags &= ~MF_PAX_PAGEEXEC;
77194+ retval = -EINVAL;
77195+ }
77196+
77197+ if ((*flags & MF_PAX_MPROTECT)
77198+
77199+#ifdef CONFIG_PAX_MPROTECT
77200+ && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
77201+#endif
77202+
77203+ )
77204+ {
77205+ *flags &= ~MF_PAX_MPROTECT;
77206+ retval = -EINVAL;
77207+ }
77208+
77209+ if ((*flags & MF_PAX_EMUTRAMP)
77210+
77211+#ifdef CONFIG_PAX_EMUTRAMP
77212+ && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
77213+#endif
77214+
77215+ )
77216+ {
77217+ *flags &= ~MF_PAX_EMUTRAMP;
77218+ retval = -EINVAL;
77219+ }
77220+
77221+ return retval;
77222+}
77223+
77224+EXPORT_SYMBOL(pax_check_flags);
77225+
77226+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
77227+char *pax_get_path(const struct path *path, char *buf, int buflen)
77228+{
77229+ char *pathname = d_path(path, buf, buflen);
77230+
77231+ if (IS_ERR(pathname))
77232+ goto toolong;
77233+
77234+ pathname = mangle_path(buf, pathname, "\t\n\\");
77235+ if (!pathname)
77236+ goto toolong;
77237+
77238+ *pathname = 0;
77239+ return buf;
77240+
77241+toolong:
77242+ return "<path too long>";
77243+}
77244+EXPORT_SYMBOL(pax_get_path);
77245+
77246+void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
77247+{
77248+ struct task_struct *tsk = current;
77249+ struct mm_struct *mm = current->mm;
77250+ char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
77251+ char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
77252+ char *path_exec = NULL;
77253+ char *path_fault = NULL;
77254+ unsigned long start = 0UL, end = 0UL, offset = 0UL;
77255+ siginfo_t info = { };
77256+
77257+ if (buffer_exec && buffer_fault) {
77258+ struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
77259+
77260+ down_read(&mm->mmap_sem);
77261+ vma = mm->mmap;
77262+ while (vma && (!vma_exec || !vma_fault)) {
77263+ if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
77264+ vma_exec = vma;
77265+ if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
77266+ vma_fault = vma;
77267+ vma = vma->vm_next;
77268+ }
77269+ if (vma_exec)
77270+ path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
77271+ if (vma_fault) {
77272+ start = vma_fault->vm_start;
77273+ end = vma_fault->vm_end;
77274+ offset = vma_fault->vm_pgoff << PAGE_SHIFT;
77275+ if (vma_fault->vm_file)
77276+ path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
77277+ else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
77278+ path_fault = "<heap>";
77279+ else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
77280+ path_fault = "<stack>";
77281+ else
77282+ path_fault = "<anonymous mapping>";
77283+ }
77284+ up_read(&mm->mmap_sem);
77285+ }
77286+ if (tsk->signal->curr_ip)
77287+ printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
77288+ else
77289+ printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
77290+ 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),
77291+ from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
77292+ free_page((unsigned long)buffer_exec);
77293+ free_page((unsigned long)buffer_fault);
77294+ pax_report_insns(regs, pc, sp);
77295+ info.si_signo = SIGKILL;
77296+ info.si_errno = 0;
77297+ info.si_code = SI_KERNEL;
77298+ info.si_pid = 0;
77299+ info.si_uid = 0;
77300+ do_coredump(&info);
77301+}
77302+#endif
77303+
77304+#ifdef CONFIG_PAX_REFCOUNT
77305+void pax_report_refcount_overflow(struct pt_regs *regs)
77306+{
77307+ if (current->signal->curr_ip)
77308+ printk(KERN_EMERG "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
77309+ &current->signal->curr_ip, current->comm, task_pid_nr(current),
77310+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
77311+ else
77312+ printk(KERN_EMERG "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
77313+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
77314+ print_symbol(KERN_EMERG "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
77315+ preempt_disable();
77316+ show_regs(regs);
77317+ preempt_enable();
77318+ force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
77319+}
77320+#endif
77321+
77322+#ifdef CONFIG_PAX_USERCOPY
77323+/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
77324+static noinline int check_stack_object(const void *obj, unsigned long len)
77325+{
77326+ const void * const stack = task_stack_page(current);
77327+ const void * const stackend = stack + THREAD_SIZE;
77328+
77329+#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
77330+ const void *frame = NULL;
77331+ const void *oldframe;
77332+#endif
77333+
77334+ if (obj + len < obj)
77335+ return -1;
77336+
77337+ if (obj + len <= stack || stackend <= obj)
77338+ return 0;
77339+
77340+ if (obj < stack || stackend < obj + len)
77341+ return -1;
77342+
77343+#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
77344+ oldframe = __builtin_frame_address(1);
77345+ if (oldframe)
77346+ frame = __builtin_frame_address(2);
77347+ /*
77348+ low ----------------------------------------------> high
77349+ [saved bp][saved ip][args][local vars][saved bp][saved ip]
77350+ ^----------------^
77351+ allow copies only within here
77352+ */
77353+ while (stack <= frame && frame < stackend) {
77354+ /* if obj + len extends past the last frame, this
77355+ check won't pass and the next frame will be 0,
77356+ causing us to bail out and correctly report
77357+ the copy as invalid
77358+ */
77359+ if (obj + len <= frame)
77360+ return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
77361+ oldframe = frame;
77362+ frame = *(const void * const *)frame;
77363+ }
77364+ return -1;
77365+#else
77366+ return 1;
77367+#endif
77368+}
77369+
77370+static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
77371+{
77372+ if (current->signal->curr_ip)
77373+ printk(KERN_EMERG "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
77374+ &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
77375+ else
77376+ printk(KERN_EMERG "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
77377+ to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
77378+ dump_stack();
77379+ gr_handle_kernel_exploit();
77380+ do_group_exit(SIGKILL);
77381+}
77382+#endif
77383+
77384+#ifdef CONFIG_PAX_USERCOPY
77385+
77386+static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
77387+{
77388+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
77389+ unsigned long textlow = ktla_ktva((unsigned long)_stext);
77390+#ifdef CONFIG_MODULES
77391+ unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
77392+#else
77393+ unsigned long texthigh = ktla_ktva((unsigned long)_etext);
77394+#endif
77395+
77396+#else
77397+ unsigned long textlow = (unsigned long)_stext;
77398+ unsigned long texthigh = (unsigned long)_etext;
77399+
77400+#ifdef CONFIG_X86_64
77401+ /* check against linear mapping as well */
77402+ if (high > (unsigned long)__va(__pa(textlow)) &&
77403+ low < (unsigned long)__va(__pa(texthigh)))
77404+ return true;
77405+#endif
77406+
77407+#endif
77408+
77409+ if (high <= textlow || low >= texthigh)
77410+ return false;
77411+ else
77412+ return true;
77413+}
77414+#endif
77415+
77416+void __check_object_size(const void *ptr, unsigned long n, bool to_user, bool const_size)
77417+{
77418+#ifdef CONFIG_PAX_USERCOPY
77419+ const char *type;
77420+#endif
77421+
77422+#if !defined(CONFIG_STACK_GROWSUP) && !defined(CONFIG_X86_64)
77423+ unsigned long stackstart = (unsigned long)task_stack_page(current);
77424+ unsigned long currentsp = (unsigned long)&stackstart;
77425+ if (unlikely((currentsp < stackstart + 512 ||
77426+ currentsp >= stackstart + THREAD_SIZE) && !in_interrupt()))
77427+ BUG();
77428+#endif
77429+
77430+#ifndef CONFIG_PAX_USERCOPY_DEBUG
77431+ if (const_size)
77432+ return;
77433+#endif
77434+
77435+#ifdef CONFIG_PAX_USERCOPY
77436+ if (!n)
77437+ return;
77438+
77439+ type = check_heap_object(ptr, n);
77440+ if (!type) {
77441+ int ret = check_stack_object(ptr, n);
77442+ if (ret == 1 || ret == 2)
77443+ return;
77444+ if (ret == 0) {
77445+ if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
77446+ type = "<kernel text>";
77447+ else
77448+ return;
77449+ } else
77450+ type = "<process stack>";
77451+ }
77452+
77453+ pax_report_usercopy(ptr, n, to_user, type);
77454+#endif
77455+
77456+}
77457+EXPORT_SYMBOL(__check_object_size);
77458+
77459+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
77460+void __used pax_track_stack(void)
77461+{
77462+ unsigned long sp = (unsigned long)&sp;
77463+ if (sp < current_thread_info()->lowest_stack &&
77464+ sp >= (unsigned long)task_stack_page(current) + 2 * sizeof(unsigned long))
77465+ current_thread_info()->lowest_stack = sp;
77466+ if (unlikely((sp & ~(THREAD_SIZE - 1)) < (THREAD_SIZE/16)))
77467+ BUG();
77468+}
77469+EXPORT_SYMBOL(pax_track_stack);
77470+#endif
77471+
77472+#ifdef CONFIG_PAX_SIZE_OVERFLOW
77473+
77474+#ifdef CONFIG_PAX_SIZE_OVERFLOW_DISABLE_KILL
77475+static DEFINE_RATELIMIT_STATE(size_overflow_ratelimit, 15 * HZ, 3);
77476+#endif
77477+
77478+void __nocapture(1, 3, 4) __used report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
77479+{
77480+#ifdef CONFIG_PAX_SIZE_OVERFLOW_DISABLE_KILL
77481+ if (__ratelimit(&size_overflow_ratelimit)) {
77482+ printk(KERN_EMERG "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
77483+ dump_stack();
77484+ }
77485+#else
77486+ printk(KERN_EMERG "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
77487+ dump_stack();
77488+ do_group_exit(SIGKILL);
77489+#endif
77490+}
77491+EXPORT_SYMBOL(report_size_overflow);
77492+#endif
77493diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
77494index 9f9992b..8b59411 100644
77495--- a/fs/ext2/balloc.c
77496+++ b/fs/ext2/balloc.c
77497@@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
77498
77499 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
77500 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
77501- if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
77502+ if (free_blocks < root_blocks + 1 &&
77503 !uid_eq(sbi->s_resuid, current_fsuid()) &&
77504 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
77505- !in_group_p (sbi->s_resgid))) {
77506+ !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
77507 return 0;
77508 }
77509 return 1;
77510diff --git a/fs/ext2/super.c b/fs/ext2/super.c
77511index 900e19c..f7dc2b8 100644
77512--- a/fs/ext2/super.c
77513+++ b/fs/ext2/super.c
77514@@ -267,10 +267,8 @@ static int ext2_show_options(struct seq_file *seq, struct dentry *root)
77515 #ifdef CONFIG_EXT2_FS_XATTR
77516 if (test_opt(sb, XATTR_USER))
77517 seq_puts(seq, ",user_xattr");
77518- if (!test_opt(sb, XATTR_USER) &&
77519- (def_mount_opts & EXT2_DEFM_XATTR_USER)) {
77520+ if (!test_opt(sb, XATTR_USER))
77521 seq_puts(seq, ",nouser_xattr");
77522- }
77523 #endif
77524
77525 #ifdef CONFIG_EXT2_FS_POSIX_ACL
77526@@ -856,8 +854,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
77527 if (def_mount_opts & EXT2_DEFM_UID16)
77528 set_opt(sbi->s_mount_opt, NO_UID32);
77529 #ifdef CONFIG_EXT2_FS_XATTR
77530- if (def_mount_opts & EXT2_DEFM_XATTR_USER)
77531- set_opt(sbi->s_mount_opt, XATTR_USER);
77532+ /* always enable user xattrs */
77533+ set_opt(sbi->s_mount_opt, XATTR_USER);
77534 #endif
77535 #ifdef CONFIG_EXT2_FS_POSIX_ACL
77536 if (def_mount_opts & EXT2_DEFM_ACL)
77537diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
77538index 0b6bfd3..93a2964 100644
77539--- a/fs/ext2/xattr.c
77540+++ b/fs/ext2/xattr.c
77541@@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
77542 struct buffer_head *bh = NULL;
77543 struct ext2_xattr_entry *entry;
77544 char *end;
77545- size_t rest = buffer_size;
77546+ size_t rest = buffer_size, total_size = 0;
77547 int error;
77548
77549 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
77550@@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
77551 buffer += size;
77552 }
77553 rest -= size;
77554+ total_size += size;
77555 }
77556 }
77557- error = buffer_size - rest; /* total size */
77558+ error = total_size;
77559
77560 cleanup:
77561 brelse(bh);
77562diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
77563index 158b5d4..2432610 100644
77564--- a/fs/ext3/balloc.c
77565+++ b/fs/ext3/balloc.c
77566@@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
77567
77568 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
77569 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
77570- if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
77571+ if (free_blocks < root_blocks + 1 &&
77572 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
77573 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
77574- !in_group_p (sbi->s_resgid))) {
77575+ !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
77576 return 0;
77577 }
77578 return 1;
77579diff --git a/fs/ext3/super.c b/fs/ext3/super.c
77580index 5ed0044..656e3d2 100644
77581--- a/fs/ext3/super.c
77582+++ b/fs/ext3/super.c
77583@@ -655,10 +655,8 @@ static int ext3_show_options(struct seq_file *seq, struct dentry *root)
77584 #ifdef CONFIG_EXT3_FS_XATTR
77585 if (test_opt(sb, XATTR_USER))
77586 seq_puts(seq, ",user_xattr");
77587- if (!test_opt(sb, XATTR_USER) &&
77588- (def_mount_opts & EXT3_DEFM_XATTR_USER)) {
77589+ if (!test_opt(sb, XATTR_USER))
77590 seq_puts(seq, ",nouser_xattr");
77591- }
77592 #endif
77593 #ifdef CONFIG_EXT3_FS_POSIX_ACL
77594 if (test_opt(sb, POSIX_ACL))
77595@@ -1760,8 +1758,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
77596 if (def_mount_opts & EXT3_DEFM_UID16)
77597 set_opt(sbi->s_mount_opt, NO_UID32);
77598 #ifdef CONFIG_EXT3_FS_XATTR
77599- if (def_mount_opts & EXT3_DEFM_XATTR_USER)
77600- set_opt(sbi->s_mount_opt, XATTR_USER);
77601+ /* always enable user xattrs */
77602+ set_opt(sbi->s_mount_opt, XATTR_USER);
77603 #endif
77604 #ifdef CONFIG_EXT3_FS_POSIX_ACL
77605 if (def_mount_opts & EXT3_DEFM_ACL)
77606diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
77607index 7cf3650..e3f4a51 100644
77608--- a/fs/ext3/xattr.c
77609+++ b/fs/ext3/xattr.c
77610@@ -330,7 +330,7 @@ static int
77611 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
77612 char *buffer, size_t buffer_size)
77613 {
77614- size_t rest = buffer_size;
77615+ size_t rest = buffer_size, total_size = 0;
77616
77617 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
77618 const struct xattr_handler *handler =
77619@@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
77620 buffer += size;
77621 }
77622 rest -= size;
77623+ total_size += size;
77624 }
77625 }
77626- return buffer_size - rest;
77627+ return total_size;
77628 }
77629
77630 static int
77631diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
77632index cd6ea29..1cd2a97 100644
77633--- a/fs/ext4/balloc.c
77634+++ b/fs/ext4/balloc.c
77635@@ -556,8 +556,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
77636 /* Hm, nope. Are (enough) root reserved clusters available? */
77637 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
77638 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
77639- capable(CAP_SYS_RESOURCE) ||
77640- (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
77641+ (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
77642+ capable_nolog(CAP_SYS_RESOURCE)) {
77643
77644 if (free_clusters >= (nclusters + dirty_clusters +
77645 resv_clusters))
77646diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
77647index f5e9f04..91296b9 100644
77648--- a/fs/ext4/ext4.h
77649+++ b/fs/ext4/ext4.h
77650@@ -1305,19 +1305,19 @@ struct ext4_sb_info {
77651 unsigned long s_mb_last_start;
77652
77653 /* stats for buddy allocator */
77654- atomic_t s_bal_reqs; /* number of reqs with len > 1 */
77655- atomic_t s_bal_success; /* we found long enough chunks */
77656- atomic_t s_bal_allocated; /* in blocks */
77657- atomic_t s_bal_ex_scanned; /* total extents scanned */
77658- atomic_t s_bal_goals; /* goal hits */
77659- atomic_t s_bal_breaks; /* too long searches */
77660- atomic_t s_bal_2orders; /* 2^order hits */
77661+ atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
77662+ atomic_unchecked_t s_bal_success; /* we found long enough chunks */
77663+ atomic_unchecked_t s_bal_allocated; /* in blocks */
77664+ atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
77665+ atomic_unchecked_t s_bal_goals; /* goal hits */
77666+ atomic_unchecked_t s_bal_breaks; /* too long searches */
77667+ atomic_unchecked_t s_bal_2orders; /* 2^order hits */
77668 spinlock_t s_bal_lock;
77669 unsigned long s_mb_buddies_generated;
77670 unsigned long long s_mb_generation_time;
77671- atomic_t s_mb_lost_chunks;
77672- atomic_t s_mb_preallocated;
77673- atomic_t s_mb_discarded;
77674+ atomic_unchecked_t s_mb_lost_chunks;
77675+ atomic_unchecked_t s_mb_preallocated;
77676+ atomic_unchecked_t s_mb_discarded;
77677 atomic_t s_lock_busy;
77678
77679 /* locality groups */
77680diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
77681index 34b610e..ecc47cb 100644
77682--- a/fs/ext4/mballoc.c
77683+++ b/fs/ext4/mballoc.c
77684@@ -1905,7 +1905,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
77685 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
77686
77687 if (EXT4_SB(sb)->s_mb_stats)
77688- atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
77689+ atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
77690
77691 break;
77692 }
77693@@ -2228,7 +2228,7 @@ repeat:
77694 ac->ac_status = AC_STATUS_CONTINUE;
77695 ac->ac_flags |= EXT4_MB_HINT_FIRST;
77696 cr = 3;
77697- atomic_inc(&sbi->s_mb_lost_chunks);
77698+ atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
77699 goto repeat;
77700 }
77701 }
77702@@ -2732,25 +2732,25 @@ int ext4_mb_release(struct super_block *sb)
77703 if (sbi->s_mb_stats) {
77704 ext4_msg(sb, KERN_INFO,
77705 "mballoc: %u blocks %u reqs (%u success)",
77706- atomic_read(&sbi->s_bal_allocated),
77707- atomic_read(&sbi->s_bal_reqs),
77708- atomic_read(&sbi->s_bal_success));
77709+ atomic_read_unchecked(&sbi->s_bal_allocated),
77710+ atomic_read_unchecked(&sbi->s_bal_reqs),
77711+ atomic_read_unchecked(&sbi->s_bal_success));
77712 ext4_msg(sb, KERN_INFO,
77713 "mballoc: %u extents scanned, %u goal hits, "
77714 "%u 2^N hits, %u breaks, %u lost",
77715- atomic_read(&sbi->s_bal_ex_scanned),
77716- atomic_read(&sbi->s_bal_goals),
77717- atomic_read(&sbi->s_bal_2orders),
77718- atomic_read(&sbi->s_bal_breaks),
77719- atomic_read(&sbi->s_mb_lost_chunks));
77720+ atomic_read_unchecked(&sbi->s_bal_ex_scanned),
77721+ atomic_read_unchecked(&sbi->s_bal_goals),
77722+ atomic_read_unchecked(&sbi->s_bal_2orders),
77723+ atomic_read_unchecked(&sbi->s_bal_breaks),
77724+ atomic_read_unchecked(&sbi->s_mb_lost_chunks));
77725 ext4_msg(sb, KERN_INFO,
77726 "mballoc: %lu generated and it took %Lu",
77727 sbi->s_mb_buddies_generated,
77728 sbi->s_mb_generation_time);
77729 ext4_msg(sb, KERN_INFO,
77730 "mballoc: %u preallocated, %u discarded",
77731- atomic_read(&sbi->s_mb_preallocated),
77732- atomic_read(&sbi->s_mb_discarded));
77733+ atomic_read_unchecked(&sbi->s_mb_preallocated),
77734+ atomic_read_unchecked(&sbi->s_mb_discarded));
77735 }
77736
77737 free_percpu(sbi->s_locality_groups);
77738@@ -3206,16 +3206,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
77739 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
77740
77741 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
77742- atomic_inc(&sbi->s_bal_reqs);
77743- atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
77744+ atomic_inc_unchecked(&sbi->s_bal_reqs);
77745+ atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
77746 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
77747- atomic_inc(&sbi->s_bal_success);
77748- atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
77749+ atomic_inc_unchecked(&sbi->s_bal_success);
77750+ atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
77751 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
77752 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
77753- atomic_inc(&sbi->s_bal_goals);
77754+ atomic_inc_unchecked(&sbi->s_bal_goals);
77755 if (ac->ac_found > sbi->s_mb_max_to_scan)
77756- atomic_inc(&sbi->s_bal_breaks);
77757+ atomic_inc_unchecked(&sbi->s_bal_breaks);
77758 }
77759
77760 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
77761@@ -3642,7 +3642,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
77762 trace_ext4_mb_new_inode_pa(ac, pa);
77763
77764 ext4_mb_use_inode_pa(ac, pa);
77765- atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
77766+ atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
77767
77768 ei = EXT4_I(ac->ac_inode);
77769 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
77770@@ -3702,7 +3702,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
77771 trace_ext4_mb_new_group_pa(ac, pa);
77772
77773 ext4_mb_use_group_pa(ac, pa);
77774- atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
77775+ atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
77776
77777 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
77778 lg = ac->ac_lg;
77779@@ -3791,7 +3791,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
77780 * from the bitmap and continue.
77781 */
77782 }
77783- atomic_add(free, &sbi->s_mb_discarded);
77784+ atomic_add_unchecked(free, &sbi->s_mb_discarded);
77785
77786 return err;
77787 }
77788@@ -3809,7 +3809,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
77789 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
77790 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
77791 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
77792- atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
77793+ atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
77794 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
77795
77796 return 0;
77797diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
77798index 8313ca3..8a37d08 100644
77799--- a/fs/ext4/mmp.c
77800+++ b/fs/ext4/mmp.c
77801@@ -111,7 +111,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
77802 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
77803 const char *function, unsigned int line, const char *msg)
77804 {
77805- __ext4_warning(sb, function, line, msg);
77806+ __ext4_warning(sb, function, line, "%s", msg);
77807 __ext4_warning(sb, function, line,
77808 "MMP failure info: last update time: %llu, last update "
77809 "node: %s, last update device: %s\n",
77810diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
77811index cf0c472..ddf284d 100644
77812--- a/fs/ext4/resize.c
77813+++ b/fs/ext4/resize.c
77814@@ -413,7 +413,7 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
77815
77816 ext4_debug("mark blocks [%llu/%u] used\n", block, count);
77817 for (count2 = count; count > 0; count -= count2, block += count2) {
77818- ext4_fsblk_t start;
77819+ ext4_fsblk_t start, diff;
77820 struct buffer_head *bh;
77821 ext4_group_t group;
77822 int err;
77823@@ -422,10 +422,6 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
77824 start = ext4_group_first_block_no(sb, group);
77825 group -= flex_gd->groups[0].group;
77826
77827- count2 = EXT4_BLOCKS_PER_GROUP(sb) - (block - start);
77828- if (count2 > count)
77829- count2 = count;
77830-
77831 if (flex_gd->bg_flags[group] & EXT4_BG_BLOCK_UNINIT) {
77832 BUG_ON(flex_gd->count > 1);
77833 continue;
77834@@ -443,9 +439,15 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
77835 err = ext4_journal_get_write_access(handle, bh);
77836 if (err)
77837 return err;
77838+
77839+ diff = block - start;
77840+ count2 = EXT4_BLOCKS_PER_GROUP(sb) - diff;
77841+ if (count2 > count)
77842+ count2 = count;
77843+
77844 ext4_debug("mark block bitmap %#04llx (+%llu/%u)\n", block,
77845- block - start, count2);
77846- ext4_set_bits(bh->b_data, block - start, count2);
77847+ diff, count2);
77848+ ext4_set_bits(bh->b_data, diff, count2);
77849
77850 err = ext4_handle_dirty_metadata(handle, NULL, bh);
77851 if (unlikely(err))
77852diff --git a/fs/ext4/super.c b/fs/ext4/super.c
77853index a5e8c74..a7711a8 100644
77854--- a/fs/ext4/super.c
77855+++ b/fs/ext4/super.c
77856@@ -1274,7 +1274,7 @@ static ext4_fsblk_t get_sb_block(void **data)
77857 }
77858
77859 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
77860-static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
77861+static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
77862 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
77863
77864 #ifdef CONFIG_QUOTA
77865@@ -2484,7 +2484,7 @@ struct ext4_attr {
77866 int offset;
77867 int deprecated_val;
77868 } u;
77869-};
77870+} __do_const;
77871
77872 static int parse_strtoull(const char *buf,
77873 unsigned long long max, unsigned long long *value)
77874diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
77875index 16e28c0..728c282 100644
77876--- a/fs/ext4/xattr.c
77877+++ b/fs/ext4/xattr.c
77878@@ -398,7 +398,7 @@ static int
77879 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
77880 char *buffer, size_t buffer_size)
77881 {
77882- size_t rest = buffer_size;
77883+ size_t rest = buffer_size, total_size = 0;
77884
77885 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
77886 const struct xattr_handler *handler =
77887@@ -415,9 +415,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
77888 buffer += size;
77889 }
77890 rest -= size;
77891+ total_size += size;
77892 }
77893 }
77894- return buffer_size - rest;
77895+ return total_size;
77896 }
77897
77898 static int
77899diff --git a/fs/fcntl.c b/fs/fcntl.c
77900index ee85cd4..9dd0d20 100644
77901--- a/fs/fcntl.c
77902+++ b/fs/fcntl.c
77903@@ -102,6 +102,10 @@ void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
77904 int force)
77905 {
77906 security_file_set_fowner(filp);
77907+ if (gr_handle_chroot_fowner(pid, type))
77908+ return;
77909+ if (gr_check_protected_task_fowner(pid, type))
77910+ return;
77911 f_modown(filp, pid, type, force);
77912 }
77913 EXPORT_SYMBOL(__f_setown);
77914diff --git a/fs/fhandle.c b/fs/fhandle.c
77915index d59712d..2281df9 100644
77916--- a/fs/fhandle.c
77917+++ b/fs/fhandle.c
77918@@ -8,6 +8,7 @@
77919 #include <linux/fs_struct.h>
77920 #include <linux/fsnotify.h>
77921 #include <linux/personality.h>
77922+#include <linux/grsecurity.h>
77923 #include <asm/uaccess.h>
77924 #include "internal.h"
77925 #include "mount.h"
77926@@ -67,8 +68,7 @@ static long do_sys_name_to_handle(struct path *path,
77927 } else
77928 retval = 0;
77929 /* copy the mount id */
77930- if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
77931- sizeof(*mnt_id)) ||
77932+ if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
77933 copy_to_user(ufh, handle,
77934 sizeof(struct file_handle) + handle_bytes))
77935 retval = -EFAULT;
77936@@ -175,7 +175,7 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh,
77937 * the directory. Ideally we would like CAP_DAC_SEARCH.
77938 * But we don't have that
77939 */
77940- if (!capable(CAP_DAC_READ_SEARCH)) {
77941+ if (!capable(CAP_DAC_READ_SEARCH) || !gr_chroot_fhandle()) {
77942 retval = -EPERM;
77943 goto out_err;
77944 }
77945diff --git a/fs/file.c b/fs/file.c
77946index 6c672ad..bf787b0 100644
77947--- a/fs/file.c
77948+++ b/fs/file.c
77949@@ -16,6 +16,7 @@
77950 #include <linux/slab.h>
77951 #include <linux/vmalloc.h>
77952 #include <linux/file.h>
77953+#include <linux/security.h>
77954 #include <linux/fdtable.h>
77955 #include <linux/bitops.h>
77956 #include <linux/interrupt.h>
77957@@ -139,7 +140,7 @@ out:
77958 * Return <0 error code on error; 1 on successful completion.
77959 * The files->file_lock should be held on entry, and will be held on exit.
77960 */
77961-static int expand_fdtable(struct files_struct *files, int nr)
77962+static int expand_fdtable(struct files_struct *files, unsigned int nr)
77963 __releases(files->file_lock)
77964 __acquires(files->file_lock)
77965 {
77966@@ -184,7 +185,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
77967 * expanded and execution may have blocked.
77968 * The files->file_lock should be held on entry, and will be held on exit.
77969 */
77970-static int expand_files(struct files_struct *files, int nr)
77971+static int expand_files(struct files_struct *files, unsigned int nr)
77972 __releases(files->file_lock)
77973 __acquires(files->file_lock)
77974 {
77975@@ -834,6 +835,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
77976 if (!file)
77977 return __close_fd(files, fd);
77978
77979+ gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
77980 if (fd >= rlimit(RLIMIT_NOFILE))
77981 return -EBADF;
77982
77983@@ -860,6 +862,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
77984 if (unlikely(oldfd == newfd))
77985 return -EINVAL;
77986
77987+ gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
77988 if (newfd >= rlimit(RLIMIT_NOFILE))
77989 return -EBADF;
77990
77991@@ -915,6 +918,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
77992 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
77993 {
77994 int err;
77995+ gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
77996 if (from >= rlimit(RLIMIT_NOFILE))
77997 return -EINVAL;
77998 err = alloc_fd(from, flags);
77999diff --git a/fs/filesystems.c b/fs/filesystems.c
78000index 5797d45..7d7d79a 100644
78001--- a/fs/filesystems.c
78002+++ b/fs/filesystems.c
78003@@ -275,7 +275,11 @@ struct file_system_type *get_fs_type(const char *name)
78004 int len = dot ? dot - name : strlen(name);
78005
78006 fs = __get_fs_type(name, len);
78007+#ifdef CONFIG_GRKERNSEC_MODHARDEN
78008+ if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
78009+#else
78010 if (!fs && (request_module("fs-%.*s", len, name) == 0))
78011+#endif
78012 fs = __get_fs_type(name, len);
78013
78014 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
78015diff --git a/fs/fs_struct.c b/fs/fs_struct.c
78016index 7dca743..1ff87ae 100644
78017--- a/fs/fs_struct.c
78018+++ b/fs/fs_struct.c
78019@@ -4,6 +4,7 @@
78020 #include <linux/path.h>
78021 #include <linux/slab.h>
78022 #include <linux/fs_struct.h>
78023+#include <linux/grsecurity.h>
78024 #include "internal.h"
78025
78026 /*
78027@@ -15,14 +16,18 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
78028 struct path old_root;
78029
78030 path_get(path);
78031+ gr_inc_chroot_refcnts(path->dentry, path->mnt);
78032 spin_lock(&fs->lock);
78033 write_seqcount_begin(&fs->seq);
78034 old_root = fs->root;
78035 fs->root = *path;
78036+ gr_set_chroot_entries(current, path);
78037 write_seqcount_end(&fs->seq);
78038 spin_unlock(&fs->lock);
78039- if (old_root.dentry)
78040+ if (old_root.dentry) {
78041+ gr_dec_chroot_refcnts(old_root.dentry, old_root.mnt);
78042 path_put(&old_root);
78043+ }
78044 }
78045
78046 /*
78047@@ -67,6 +72,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
78048 int hits = 0;
78049 spin_lock(&fs->lock);
78050 write_seqcount_begin(&fs->seq);
78051+ /* this root replacement is only done by pivot_root,
78052+ leave grsec's chroot tagging alone for this task
78053+ so that a pivoted root isn't treated as a chroot
78054+ */
78055 hits += replace_path(&fs->root, old_root, new_root);
78056 hits += replace_path(&fs->pwd, old_root, new_root);
78057 write_seqcount_end(&fs->seq);
78058@@ -85,6 +94,7 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
78059
78060 void free_fs_struct(struct fs_struct *fs)
78061 {
78062+ gr_dec_chroot_refcnts(fs->root.dentry, fs->root.mnt);
78063 path_put(&fs->root);
78064 path_put(&fs->pwd);
78065 kmem_cache_free(fs_cachep, fs);
78066@@ -99,7 +109,8 @@ void exit_fs(struct task_struct *tsk)
78067 task_lock(tsk);
78068 spin_lock(&fs->lock);
78069 tsk->fs = NULL;
78070- kill = !--fs->users;
78071+ gr_clear_chroot_entries(tsk);
78072+ kill = !atomic_dec_return(&fs->users);
78073 spin_unlock(&fs->lock);
78074 task_unlock(tsk);
78075 if (kill)
78076@@ -112,7 +123,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
78077 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
78078 /* We don't need to lock fs - think why ;-) */
78079 if (fs) {
78080- fs->users = 1;
78081+ atomic_set(&fs->users, 1);
78082 fs->in_exec = 0;
78083 spin_lock_init(&fs->lock);
78084 seqcount_init(&fs->seq);
78085@@ -121,9 +132,13 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
78086 spin_lock(&old->lock);
78087 fs->root = old->root;
78088 path_get(&fs->root);
78089+ /* instead of calling gr_set_chroot_entries here,
78090+ we call it from every caller of this function
78091+ */
78092 fs->pwd = old->pwd;
78093 path_get(&fs->pwd);
78094 spin_unlock(&old->lock);
78095+ gr_inc_chroot_refcnts(fs->root.dentry, fs->root.mnt);
78096 }
78097 return fs;
78098 }
78099@@ -139,8 +154,9 @@ int unshare_fs_struct(void)
78100
78101 task_lock(current);
78102 spin_lock(&fs->lock);
78103- kill = !--fs->users;
78104+ kill = !atomic_dec_return(&fs->users);
78105 current->fs = new_fs;
78106+ gr_set_chroot_entries(current, &new_fs->root);
78107 spin_unlock(&fs->lock);
78108 task_unlock(current);
78109
78110@@ -153,13 +169,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
78111
78112 int current_umask(void)
78113 {
78114- return current->fs->umask;
78115+ return current->fs->umask | gr_acl_umask();
78116 }
78117 EXPORT_SYMBOL(current_umask);
78118
78119 /* to be mentioned only in INIT_TASK */
78120 struct fs_struct init_fs = {
78121- .users = 1,
78122+ .users = ATOMIC_INIT(1),
78123 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
78124 .seq = SEQCNT_ZERO(init_fs.seq),
78125 .umask = 0022,
78126diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
78127index d403c69..30be0a9 100644
78128--- a/fs/fscache/cookie.c
78129+++ b/fs/fscache/cookie.c
78130@@ -19,7 +19,7 @@
78131
78132 struct kmem_cache *fscache_cookie_jar;
78133
78134-static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
78135+static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
78136
78137 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
78138 static int fscache_alloc_object(struct fscache_cache *cache,
78139@@ -69,11 +69,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
78140 parent ? (char *) parent->def->name : "<no-parent>",
78141 def->name, netfs_data, enable);
78142
78143- fscache_stat(&fscache_n_acquires);
78144+ fscache_stat_unchecked(&fscache_n_acquires);
78145
78146 /* if there's no parent cookie, then we don't create one here either */
78147 if (!parent) {
78148- fscache_stat(&fscache_n_acquires_null);
78149+ fscache_stat_unchecked(&fscache_n_acquires_null);
78150 _leave(" [no parent]");
78151 return NULL;
78152 }
78153@@ -88,7 +88,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
78154 /* allocate and initialise a cookie */
78155 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
78156 if (!cookie) {
78157- fscache_stat(&fscache_n_acquires_oom);
78158+ fscache_stat_unchecked(&fscache_n_acquires_oom);
78159 _leave(" [ENOMEM]");
78160 return NULL;
78161 }
78162@@ -115,13 +115,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
78163
78164 switch (cookie->def->type) {
78165 case FSCACHE_COOKIE_TYPE_INDEX:
78166- fscache_stat(&fscache_n_cookie_index);
78167+ fscache_stat_unchecked(&fscache_n_cookie_index);
78168 break;
78169 case FSCACHE_COOKIE_TYPE_DATAFILE:
78170- fscache_stat(&fscache_n_cookie_data);
78171+ fscache_stat_unchecked(&fscache_n_cookie_data);
78172 break;
78173 default:
78174- fscache_stat(&fscache_n_cookie_special);
78175+ fscache_stat_unchecked(&fscache_n_cookie_special);
78176 break;
78177 }
78178
78179@@ -135,7 +135,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
78180 } else {
78181 atomic_dec(&parent->n_children);
78182 __fscache_cookie_put(cookie);
78183- fscache_stat(&fscache_n_acquires_nobufs);
78184+ fscache_stat_unchecked(&fscache_n_acquires_nobufs);
78185 _leave(" = NULL");
78186 return NULL;
78187 }
78188@@ -144,7 +144,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
78189 }
78190 }
78191
78192- fscache_stat(&fscache_n_acquires_ok);
78193+ fscache_stat_unchecked(&fscache_n_acquires_ok);
78194 _leave(" = %p", cookie);
78195 return cookie;
78196 }
78197@@ -213,7 +213,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
78198 cache = fscache_select_cache_for_object(cookie->parent);
78199 if (!cache) {
78200 up_read(&fscache_addremove_sem);
78201- fscache_stat(&fscache_n_acquires_no_cache);
78202+ fscache_stat_unchecked(&fscache_n_acquires_no_cache);
78203 _leave(" = -ENOMEDIUM [no cache]");
78204 return -ENOMEDIUM;
78205 }
78206@@ -297,14 +297,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
78207 object = cache->ops->alloc_object(cache, cookie);
78208 fscache_stat_d(&fscache_n_cop_alloc_object);
78209 if (IS_ERR(object)) {
78210- fscache_stat(&fscache_n_object_no_alloc);
78211+ fscache_stat_unchecked(&fscache_n_object_no_alloc);
78212 ret = PTR_ERR(object);
78213 goto error;
78214 }
78215
78216- fscache_stat(&fscache_n_object_alloc);
78217+ fscache_stat_unchecked(&fscache_n_object_alloc);
78218
78219- object->debug_id = atomic_inc_return(&fscache_object_debug_id);
78220+ object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
78221
78222 _debug("ALLOC OBJ%x: %s {%lx}",
78223 object->debug_id, cookie->def->name, object->events);
78224@@ -419,7 +419,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
78225
78226 _enter("{%s}", cookie->def->name);
78227
78228- fscache_stat(&fscache_n_invalidates);
78229+ fscache_stat_unchecked(&fscache_n_invalidates);
78230
78231 /* Only permit invalidation of data files. Invalidating an index will
78232 * require the caller to release all its attachments to the tree rooted
78233@@ -477,10 +477,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
78234 {
78235 struct fscache_object *object;
78236
78237- fscache_stat(&fscache_n_updates);
78238+ fscache_stat_unchecked(&fscache_n_updates);
78239
78240 if (!cookie) {
78241- fscache_stat(&fscache_n_updates_null);
78242+ fscache_stat_unchecked(&fscache_n_updates_null);
78243 _leave(" [no cookie]");
78244 return;
78245 }
78246@@ -581,12 +581,12 @@ EXPORT_SYMBOL(__fscache_disable_cookie);
78247 */
78248 void __fscache_relinquish_cookie(struct fscache_cookie *cookie, bool retire)
78249 {
78250- fscache_stat(&fscache_n_relinquishes);
78251+ fscache_stat_unchecked(&fscache_n_relinquishes);
78252 if (retire)
78253- fscache_stat(&fscache_n_relinquishes_retire);
78254+ fscache_stat_unchecked(&fscache_n_relinquishes_retire);
78255
78256 if (!cookie) {
78257- fscache_stat(&fscache_n_relinquishes_null);
78258+ fscache_stat_unchecked(&fscache_n_relinquishes_null);
78259 _leave(" [no cookie]");
78260 return;
78261 }
78262@@ -687,7 +687,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
78263 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
78264 goto inconsistent;
78265
78266- op->debug_id = atomic_inc_return(&fscache_op_debug_id);
78267+ op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
78268
78269 __fscache_use_cookie(cookie);
78270 if (fscache_submit_op(object, op) < 0)
78271diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
78272index 97ec451..f722cee 100644
78273--- a/fs/fscache/internal.h
78274+++ b/fs/fscache/internal.h
78275@@ -136,8 +136,8 @@ extern void fscache_operation_gc(struct work_struct *);
78276 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
78277 extern int fscache_wait_for_operation_activation(struct fscache_object *,
78278 struct fscache_operation *,
78279- atomic_t *,
78280- atomic_t *);
78281+ atomic_unchecked_t *,
78282+ atomic_unchecked_t *);
78283 extern void fscache_invalidate_writes(struct fscache_cookie *);
78284
78285 /*
78286@@ -155,102 +155,102 @@ extern void fscache_proc_cleanup(void);
78287 * stats.c
78288 */
78289 #ifdef CONFIG_FSCACHE_STATS
78290-extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
78291-extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
78292+extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
78293+extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
78294
78295-extern atomic_t fscache_n_op_pend;
78296-extern atomic_t fscache_n_op_run;
78297-extern atomic_t fscache_n_op_enqueue;
78298-extern atomic_t fscache_n_op_deferred_release;
78299-extern atomic_t fscache_n_op_initialised;
78300-extern atomic_t fscache_n_op_release;
78301-extern atomic_t fscache_n_op_gc;
78302-extern atomic_t fscache_n_op_cancelled;
78303-extern atomic_t fscache_n_op_rejected;
78304+extern atomic_unchecked_t fscache_n_op_pend;
78305+extern atomic_unchecked_t fscache_n_op_run;
78306+extern atomic_unchecked_t fscache_n_op_enqueue;
78307+extern atomic_unchecked_t fscache_n_op_deferred_release;
78308+extern atomic_unchecked_t fscache_n_op_initialised;
78309+extern atomic_unchecked_t fscache_n_op_release;
78310+extern atomic_unchecked_t fscache_n_op_gc;
78311+extern atomic_unchecked_t fscache_n_op_cancelled;
78312+extern atomic_unchecked_t fscache_n_op_rejected;
78313
78314-extern atomic_t fscache_n_attr_changed;
78315-extern atomic_t fscache_n_attr_changed_ok;
78316-extern atomic_t fscache_n_attr_changed_nobufs;
78317-extern atomic_t fscache_n_attr_changed_nomem;
78318-extern atomic_t fscache_n_attr_changed_calls;
78319+extern atomic_unchecked_t fscache_n_attr_changed;
78320+extern atomic_unchecked_t fscache_n_attr_changed_ok;
78321+extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
78322+extern atomic_unchecked_t fscache_n_attr_changed_nomem;
78323+extern atomic_unchecked_t fscache_n_attr_changed_calls;
78324
78325-extern atomic_t fscache_n_allocs;
78326-extern atomic_t fscache_n_allocs_ok;
78327-extern atomic_t fscache_n_allocs_wait;
78328-extern atomic_t fscache_n_allocs_nobufs;
78329-extern atomic_t fscache_n_allocs_intr;
78330-extern atomic_t fscache_n_allocs_object_dead;
78331-extern atomic_t fscache_n_alloc_ops;
78332-extern atomic_t fscache_n_alloc_op_waits;
78333+extern atomic_unchecked_t fscache_n_allocs;
78334+extern atomic_unchecked_t fscache_n_allocs_ok;
78335+extern atomic_unchecked_t fscache_n_allocs_wait;
78336+extern atomic_unchecked_t fscache_n_allocs_nobufs;
78337+extern atomic_unchecked_t fscache_n_allocs_intr;
78338+extern atomic_unchecked_t fscache_n_allocs_object_dead;
78339+extern atomic_unchecked_t fscache_n_alloc_ops;
78340+extern atomic_unchecked_t fscache_n_alloc_op_waits;
78341
78342-extern atomic_t fscache_n_retrievals;
78343-extern atomic_t fscache_n_retrievals_ok;
78344-extern atomic_t fscache_n_retrievals_wait;
78345-extern atomic_t fscache_n_retrievals_nodata;
78346-extern atomic_t fscache_n_retrievals_nobufs;
78347-extern atomic_t fscache_n_retrievals_intr;
78348-extern atomic_t fscache_n_retrievals_nomem;
78349-extern atomic_t fscache_n_retrievals_object_dead;
78350-extern atomic_t fscache_n_retrieval_ops;
78351-extern atomic_t fscache_n_retrieval_op_waits;
78352+extern atomic_unchecked_t fscache_n_retrievals;
78353+extern atomic_unchecked_t fscache_n_retrievals_ok;
78354+extern atomic_unchecked_t fscache_n_retrievals_wait;
78355+extern atomic_unchecked_t fscache_n_retrievals_nodata;
78356+extern atomic_unchecked_t fscache_n_retrievals_nobufs;
78357+extern atomic_unchecked_t fscache_n_retrievals_intr;
78358+extern atomic_unchecked_t fscache_n_retrievals_nomem;
78359+extern atomic_unchecked_t fscache_n_retrievals_object_dead;
78360+extern atomic_unchecked_t fscache_n_retrieval_ops;
78361+extern atomic_unchecked_t fscache_n_retrieval_op_waits;
78362
78363-extern atomic_t fscache_n_stores;
78364-extern atomic_t fscache_n_stores_ok;
78365-extern atomic_t fscache_n_stores_again;
78366-extern atomic_t fscache_n_stores_nobufs;
78367-extern atomic_t fscache_n_stores_oom;
78368-extern atomic_t fscache_n_store_ops;
78369-extern atomic_t fscache_n_store_calls;
78370-extern atomic_t fscache_n_store_pages;
78371-extern atomic_t fscache_n_store_radix_deletes;
78372-extern atomic_t fscache_n_store_pages_over_limit;
78373+extern atomic_unchecked_t fscache_n_stores;
78374+extern atomic_unchecked_t fscache_n_stores_ok;
78375+extern atomic_unchecked_t fscache_n_stores_again;
78376+extern atomic_unchecked_t fscache_n_stores_nobufs;
78377+extern atomic_unchecked_t fscache_n_stores_oom;
78378+extern atomic_unchecked_t fscache_n_store_ops;
78379+extern atomic_unchecked_t fscache_n_store_calls;
78380+extern atomic_unchecked_t fscache_n_store_pages;
78381+extern atomic_unchecked_t fscache_n_store_radix_deletes;
78382+extern atomic_unchecked_t fscache_n_store_pages_over_limit;
78383
78384-extern atomic_t fscache_n_store_vmscan_not_storing;
78385-extern atomic_t fscache_n_store_vmscan_gone;
78386-extern atomic_t fscache_n_store_vmscan_busy;
78387-extern atomic_t fscache_n_store_vmscan_cancelled;
78388-extern atomic_t fscache_n_store_vmscan_wait;
78389+extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
78390+extern atomic_unchecked_t fscache_n_store_vmscan_gone;
78391+extern atomic_unchecked_t fscache_n_store_vmscan_busy;
78392+extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
78393+extern atomic_unchecked_t fscache_n_store_vmscan_wait;
78394
78395-extern atomic_t fscache_n_marks;
78396-extern atomic_t fscache_n_uncaches;
78397+extern atomic_unchecked_t fscache_n_marks;
78398+extern atomic_unchecked_t fscache_n_uncaches;
78399
78400-extern atomic_t fscache_n_acquires;
78401-extern atomic_t fscache_n_acquires_null;
78402-extern atomic_t fscache_n_acquires_no_cache;
78403-extern atomic_t fscache_n_acquires_ok;
78404-extern atomic_t fscache_n_acquires_nobufs;
78405-extern atomic_t fscache_n_acquires_oom;
78406+extern atomic_unchecked_t fscache_n_acquires;
78407+extern atomic_unchecked_t fscache_n_acquires_null;
78408+extern atomic_unchecked_t fscache_n_acquires_no_cache;
78409+extern atomic_unchecked_t fscache_n_acquires_ok;
78410+extern atomic_unchecked_t fscache_n_acquires_nobufs;
78411+extern atomic_unchecked_t fscache_n_acquires_oom;
78412
78413-extern atomic_t fscache_n_invalidates;
78414-extern atomic_t fscache_n_invalidates_run;
78415+extern atomic_unchecked_t fscache_n_invalidates;
78416+extern atomic_unchecked_t fscache_n_invalidates_run;
78417
78418-extern atomic_t fscache_n_updates;
78419-extern atomic_t fscache_n_updates_null;
78420-extern atomic_t fscache_n_updates_run;
78421+extern atomic_unchecked_t fscache_n_updates;
78422+extern atomic_unchecked_t fscache_n_updates_null;
78423+extern atomic_unchecked_t fscache_n_updates_run;
78424
78425-extern atomic_t fscache_n_relinquishes;
78426-extern atomic_t fscache_n_relinquishes_null;
78427-extern atomic_t fscache_n_relinquishes_waitcrt;
78428-extern atomic_t fscache_n_relinquishes_retire;
78429+extern atomic_unchecked_t fscache_n_relinquishes;
78430+extern atomic_unchecked_t fscache_n_relinquishes_null;
78431+extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
78432+extern atomic_unchecked_t fscache_n_relinquishes_retire;
78433
78434-extern atomic_t fscache_n_cookie_index;
78435-extern atomic_t fscache_n_cookie_data;
78436-extern atomic_t fscache_n_cookie_special;
78437+extern atomic_unchecked_t fscache_n_cookie_index;
78438+extern atomic_unchecked_t fscache_n_cookie_data;
78439+extern atomic_unchecked_t fscache_n_cookie_special;
78440
78441-extern atomic_t fscache_n_object_alloc;
78442-extern atomic_t fscache_n_object_no_alloc;
78443-extern atomic_t fscache_n_object_lookups;
78444-extern atomic_t fscache_n_object_lookups_negative;
78445-extern atomic_t fscache_n_object_lookups_positive;
78446-extern atomic_t fscache_n_object_lookups_timed_out;
78447-extern atomic_t fscache_n_object_created;
78448-extern atomic_t fscache_n_object_avail;
78449-extern atomic_t fscache_n_object_dead;
78450+extern atomic_unchecked_t fscache_n_object_alloc;
78451+extern atomic_unchecked_t fscache_n_object_no_alloc;
78452+extern atomic_unchecked_t fscache_n_object_lookups;
78453+extern atomic_unchecked_t fscache_n_object_lookups_negative;
78454+extern atomic_unchecked_t fscache_n_object_lookups_positive;
78455+extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
78456+extern atomic_unchecked_t fscache_n_object_created;
78457+extern atomic_unchecked_t fscache_n_object_avail;
78458+extern atomic_unchecked_t fscache_n_object_dead;
78459
78460-extern atomic_t fscache_n_checkaux_none;
78461-extern atomic_t fscache_n_checkaux_okay;
78462-extern atomic_t fscache_n_checkaux_update;
78463-extern atomic_t fscache_n_checkaux_obsolete;
78464+extern atomic_unchecked_t fscache_n_checkaux_none;
78465+extern atomic_unchecked_t fscache_n_checkaux_okay;
78466+extern atomic_unchecked_t fscache_n_checkaux_update;
78467+extern atomic_unchecked_t fscache_n_checkaux_obsolete;
78468
78469 extern atomic_t fscache_n_cop_alloc_object;
78470 extern atomic_t fscache_n_cop_lookup_object;
78471@@ -280,6 +280,11 @@ static inline void fscache_stat(atomic_t *stat)
78472 atomic_inc(stat);
78473 }
78474
78475+static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
78476+{
78477+ atomic_inc_unchecked(stat);
78478+}
78479+
78480 static inline void fscache_stat_d(atomic_t *stat)
78481 {
78482 atomic_dec(stat);
78483@@ -292,6 +297,7 @@ extern const struct file_operations fscache_stats_fops;
78484
78485 #define __fscache_stat(stat) (NULL)
78486 #define fscache_stat(stat) do {} while (0)
78487+#define fscache_stat_unchecked(stat) do {} while (0)
78488 #define fscache_stat_d(stat) do {} while (0)
78489 #endif
78490
78491diff --git a/fs/fscache/object.c b/fs/fscache/object.c
78492index 9e792e3..6b2affb 100644
78493--- a/fs/fscache/object.c
78494+++ b/fs/fscache/object.c
78495@@ -465,7 +465,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
78496 _debug("LOOKUP \"%s\" in \"%s\"",
78497 cookie->def->name, object->cache->tag->name);
78498
78499- fscache_stat(&fscache_n_object_lookups);
78500+ fscache_stat_unchecked(&fscache_n_object_lookups);
78501 fscache_stat(&fscache_n_cop_lookup_object);
78502 ret = object->cache->ops->lookup_object(object);
78503 fscache_stat_d(&fscache_n_cop_lookup_object);
78504@@ -475,7 +475,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
78505 if (ret == -ETIMEDOUT) {
78506 /* probably stuck behind another object, so move this one to
78507 * the back of the queue */
78508- fscache_stat(&fscache_n_object_lookups_timed_out);
78509+ fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
78510 _leave(" [timeout]");
78511 return NO_TRANSIT;
78512 }
78513@@ -503,7 +503,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
78514 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
78515
78516 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
78517- fscache_stat(&fscache_n_object_lookups_negative);
78518+ fscache_stat_unchecked(&fscache_n_object_lookups_negative);
78519
78520 /* Allow write requests to begin stacking up and read requests to begin
78521 * returning ENODATA.
78522@@ -538,7 +538,7 @@ void fscache_obtained_object(struct fscache_object *object)
78523 /* if we were still looking up, then we must have a positive lookup
78524 * result, in which case there may be data available */
78525 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
78526- fscache_stat(&fscache_n_object_lookups_positive);
78527+ fscache_stat_unchecked(&fscache_n_object_lookups_positive);
78528
78529 /* We do (presumably) have data */
78530 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
78531@@ -550,7 +550,7 @@ void fscache_obtained_object(struct fscache_object *object)
78532 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
78533 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
78534 } else {
78535- fscache_stat(&fscache_n_object_created);
78536+ fscache_stat_unchecked(&fscache_n_object_created);
78537 }
78538
78539 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
78540@@ -586,7 +586,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
78541 fscache_stat_d(&fscache_n_cop_lookup_complete);
78542
78543 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
78544- fscache_stat(&fscache_n_object_avail);
78545+ fscache_stat_unchecked(&fscache_n_object_avail);
78546
78547 _leave("");
78548 return transit_to(JUMPSTART_DEPS);
78549@@ -735,7 +735,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
78550
78551 /* this just shifts the object release to the work processor */
78552 fscache_put_object(object);
78553- fscache_stat(&fscache_n_object_dead);
78554+ fscache_stat_unchecked(&fscache_n_object_dead);
78555
78556 _leave("");
78557 return transit_to(OBJECT_DEAD);
78558@@ -900,7 +900,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
78559 enum fscache_checkaux result;
78560
78561 if (!object->cookie->def->check_aux) {
78562- fscache_stat(&fscache_n_checkaux_none);
78563+ fscache_stat_unchecked(&fscache_n_checkaux_none);
78564 return FSCACHE_CHECKAUX_OKAY;
78565 }
78566
78567@@ -909,17 +909,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
78568 switch (result) {
78569 /* entry okay as is */
78570 case FSCACHE_CHECKAUX_OKAY:
78571- fscache_stat(&fscache_n_checkaux_okay);
78572+ fscache_stat_unchecked(&fscache_n_checkaux_okay);
78573 break;
78574
78575 /* entry requires update */
78576 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
78577- fscache_stat(&fscache_n_checkaux_update);
78578+ fscache_stat_unchecked(&fscache_n_checkaux_update);
78579 break;
78580
78581 /* entry requires deletion */
78582 case FSCACHE_CHECKAUX_OBSOLETE:
78583- fscache_stat(&fscache_n_checkaux_obsolete);
78584+ fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
78585 break;
78586
78587 default:
78588@@ -1007,7 +1007,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
78589 {
78590 const struct fscache_state *s;
78591
78592- fscache_stat(&fscache_n_invalidates_run);
78593+ fscache_stat_unchecked(&fscache_n_invalidates_run);
78594 fscache_stat(&fscache_n_cop_invalidate_object);
78595 s = _fscache_invalidate_object(object, event);
78596 fscache_stat_d(&fscache_n_cop_invalidate_object);
78597@@ -1022,7 +1022,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
78598 {
78599 _enter("{OBJ%x},%d", object->debug_id, event);
78600
78601- fscache_stat(&fscache_n_updates_run);
78602+ fscache_stat_unchecked(&fscache_n_updates_run);
78603 fscache_stat(&fscache_n_cop_update_object);
78604 object->cache->ops->update_object(object);
78605 fscache_stat_d(&fscache_n_cop_update_object);
78606diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
78607index de67745..6a3a9b6 100644
78608--- a/fs/fscache/operation.c
78609+++ b/fs/fscache/operation.c
78610@@ -17,7 +17,7 @@
78611 #include <linux/slab.h>
78612 #include "internal.h"
78613
78614-atomic_t fscache_op_debug_id;
78615+atomic_unchecked_t fscache_op_debug_id;
78616 EXPORT_SYMBOL(fscache_op_debug_id);
78617
78618 static void fscache_operation_dummy_cancel(struct fscache_operation *op)
78619@@ -40,12 +40,12 @@ void fscache_operation_init(struct fscache_operation *op,
78620 INIT_WORK(&op->work, fscache_op_work_func);
78621 atomic_set(&op->usage, 1);
78622 op->state = FSCACHE_OP_ST_INITIALISED;
78623- op->debug_id = atomic_inc_return(&fscache_op_debug_id);
78624+ op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
78625 op->processor = processor;
78626 op->cancel = cancel ?: fscache_operation_dummy_cancel;
78627 op->release = release;
78628 INIT_LIST_HEAD(&op->pend_link);
78629- fscache_stat(&fscache_n_op_initialised);
78630+ fscache_stat_unchecked(&fscache_n_op_initialised);
78631 }
78632 EXPORT_SYMBOL(fscache_operation_init);
78633
78634@@ -68,7 +68,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
78635 ASSERTCMP(atomic_read(&op->usage), >, 0);
78636 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
78637
78638- fscache_stat(&fscache_n_op_enqueue);
78639+ fscache_stat_unchecked(&fscache_n_op_enqueue);
78640 switch (op->flags & FSCACHE_OP_TYPE) {
78641 case FSCACHE_OP_ASYNC:
78642 _debug("queue async");
78643@@ -101,7 +101,7 @@ static void fscache_run_op(struct fscache_object *object,
78644 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
78645 if (op->processor)
78646 fscache_enqueue_operation(op);
78647- fscache_stat(&fscache_n_op_run);
78648+ fscache_stat_unchecked(&fscache_n_op_run);
78649 }
78650
78651 /*
78652@@ -169,7 +169,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
78653 op->state = FSCACHE_OP_ST_PENDING;
78654 flags = READ_ONCE(object->flags);
78655 if (unlikely(!(flags & BIT(FSCACHE_OBJECT_IS_LIVE)))) {
78656- fscache_stat(&fscache_n_op_rejected);
78657+ fscache_stat_unchecked(&fscache_n_op_rejected);
78658 op->cancel(op);
78659 op->state = FSCACHE_OP_ST_CANCELLED;
78660 ret = -ENOBUFS;
78661@@ -185,11 +185,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
78662 if (object->n_in_progress > 0) {
78663 atomic_inc(&op->usage);
78664 list_add_tail(&op->pend_link, &object->pending_ops);
78665- fscache_stat(&fscache_n_op_pend);
78666+ fscache_stat_unchecked(&fscache_n_op_pend);
78667 } else if (!list_empty(&object->pending_ops)) {
78668 atomic_inc(&op->usage);
78669 list_add_tail(&op->pend_link, &object->pending_ops);
78670- fscache_stat(&fscache_n_op_pend);
78671+ fscache_stat_unchecked(&fscache_n_op_pend);
78672 fscache_start_operations(object);
78673 } else {
78674 ASSERTCMP(object->n_in_progress, ==, 0);
78675@@ -205,7 +205,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
78676 object->n_exclusive++; /* reads and writes must wait */
78677 atomic_inc(&op->usage);
78678 list_add_tail(&op->pend_link, &object->pending_ops);
78679- fscache_stat(&fscache_n_op_pend);
78680+ fscache_stat_unchecked(&fscache_n_op_pend);
78681 ret = 0;
78682 } else if (flags & BIT(FSCACHE_OBJECT_KILLED_BY_CACHE)) {
78683 op->cancel(op);
78684@@ -254,7 +254,7 @@ int fscache_submit_op(struct fscache_object *object,
78685 op->state = FSCACHE_OP_ST_PENDING;
78686 flags = READ_ONCE(object->flags);
78687 if (unlikely(!(flags & BIT(FSCACHE_OBJECT_IS_LIVE)))) {
78688- fscache_stat(&fscache_n_op_rejected);
78689+ fscache_stat_unchecked(&fscache_n_op_rejected);
78690 op->cancel(op);
78691 op->state = FSCACHE_OP_ST_CANCELLED;
78692 ret = -ENOBUFS;
78693@@ -269,11 +269,11 @@ int fscache_submit_op(struct fscache_object *object,
78694 if (object->n_exclusive > 0) {
78695 atomic_inc(&op->usage);
78696 list_add_tail(&op->pend_link, &object->pending_ops);
78697- fscache_stat(&fscache_n_op_pend);
78698+ fscache_stat_unchecked(&fscache_n_op_pend);
78699 } else if (!list_empty(&object->pending_ops)) {
78700 atomic_inc(&op->usage);
78701 list_add_tail(&op->pend_link, &object->pending_ops);
78702- fscache_stat(&fscache_n_op_pend);
78703+ fscache_stat_unchecked(&fscache_n_op_pend);
78704 fscache_start_operations(object);
78705 } else {
78706 ASSERTCMP(object->n_exclusive, ==, 0);
78707@@ -285,7 +285,7 @@ int fscache_submit_op(struct fscache_object *object,
78708 object->n_ops++;
78709 atomic_inc(&op->usage);
78710 list_add_tail(&op->pend_link, &object->pending_ops);
78711- fscache_stat(&fscache_n_op_pend);
78712+ fscache_stat_unchecked(&fscache_n_op_pend);
78713 ret = 0;
78714 } else if (flags & BIT(FSCACHE_OBJECT_KILLED_BY_CACHE)) {
78715 op->cancel(op);
78716@@ -369,7 +369,7 @@ int fscache_cancel_op(struct fscache_operation *op,
78717 list_del_init(&op->pend_link);
78718 put = true;
78719
78720- fscache_stat(&fscache_n_op_cancelled);
78721+ fscache_stat_unchecked(&fscache_n_op_cancelled);
78722 op->cancel(op);
78723 op->state = FSCACHE_OP_ST_CANCELLED;
78724 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
78725@@ -385,7 +385,7 @@ int fscache_cancel_op(struct fscache_operation *op,
78726 if (object->n_in_progress == 0)
78727 fscache_start_operations(object);
78728
78729- fscache_stat(&fscache_n_op_cancelled);
78730+ fscache_stat_unchecked(&fscache_n_op_cancelled);
78731 op->cancel(op);
78732 op->state = FSCACHE_OP_ST_CANCELLED;
78733 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
78734@@ -416,7 +416,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
78735 while (!list_empty(&object->pending_ops)) {
78736 op = list_entry(object->pending_ops.next,
78737 struct fscache_operation, pend_link);
78738- fscache_stat(&fscache_n_op_cancelled);
78739+ fscache_stat_unchecked(&fscache_n_op_cancelled);
78740 list_del_init(&op->pend_link);
78741
78742 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
78743@@ -493,7 +493,7 @@ void fscache_put_operation(struct fscache_operation *op)
78744 op->state != FSCACHE_OP_ST_COMPLETE,
78745 op->state, ==, FSCACHE_OP_ST_CANCELLED);
78746
78747- fscache_stat(&fscache_n_op_release);
78748+ fscache_stat_unchecked(&fscache_n_op_release);
78749
78750 if (op->release) {
78751 op->release(op);
78752@@ -513,7 +513,7 @@ void fscache_put_operation(struct fscache_operation *op)
78753 * lock, and defer it otherwise */
78754 if (!spin_trylock(&object->lock)) {
78755 _debug("defer put");
78756- fscache_stat(&fscache_n_op_deferred_release);
78757+ fscache_stat_unchecked(&fscache_n_op_deferred_release);
78758
78759 cache = object->cache;
78760 spin_lock(&cache->op_gc_list_lock);
78761@@ -567,7 +567,7 @@ void fscache_operation_gc(struct work_struct *work)
78762
78763 _debug("GC DEFERRED REL OBJ%x OP%x",
78764 object->debug_id, op->debug_id);
78765- fscache_stat(&fscache_n_op_gc);
78766+ fscache_stat_unchecked(&fscache_n_op_gc);
78767
78768 ASSERTCMP(atomic_read(&op->usage), ==, 0);
78769 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
78770diff --git a/fs/fscache/page.c b/fs/fscache/page.c
78771index 483bbc6..ba36737 100644
78772--- a/fs/fscache/page.c
78773+++ b/fs/fscache/page.c
78774@@ -74,7 +74,7 @@ try_again:
78775 val = radix_tree_lookup(&cookie->stores, page->index);
78776 if (!val) {
78777 rcu_read_unlock();
78778- fscache_stat(&fscache_n_store_vmscan_not_storing);
78779+ fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
78780 __fscache_uncache_page(cookie, page);
78781 return true;
78782 }
78783@@ -104,11 +104,11 @@ try_again:
78784 spin_unlock(&cookie->stores_lock);
78785
78786 if (xpage) {
78787- fscache_stat(&fscache_n_store_vmscan_cancelled);
78788- fscache_stat(&fscache_n_store_radix_deletes);
78789+ fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
78790+ fscache_stat_unchecked(&fscache_n_store_radix_deletes);
78791 ASSERTCMP(xpage, ==, page);
78792 } else {
78793- fscache_stat(&fscache_n_store_vmscan_gone);
78794+ fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
78795 }
78796
78797 wake_up_bit(&cookie->flags, 0);
78798@@ -123,11 +123,11 @@ page_busy:
78799 * sleeping on memory allocation, so we may need to impose a timeout
78800 * too. */
78801 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
78802- fscache_stat(&fscache_n_store_vmscan_busy);
78803+ fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
78804 return false;
78805 }
78806
78807- fscache_stat(&fscache_n_store_vmscan_wait);
78808+ fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
78809 if (!release_page_wait_timeout(cookie, page))
78810 _debug("fscache writeout timeout page: %p{%lx}",
78811 page, page->index);
78812@@ -156,7 +156,7 @@ static void fscache_end_page_write(struct fscache_object *object,
78813 FSCACHE_COOKIE_STORING_TAG);
78814 if (!radix_tree_tag_get(&cookie->stores, page->index,
78815 FSCACHE_COOKIE_PENDING_TAG)) {
78816- fscache_stat(&fscache_n_store_radix_deletes);
78817+ fscache_stat_unchecked(&fscache_n_store_radix_deletes);
78818 xpage = radix_tree_delete(&cookie->stores, page->index);
78819 }
78820 spin_unlock(&cookie->stores_lock);
78821@@ -177,7 +177,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
78822
78823 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
78824
78825- fscache_stat(&fscache_n_attr_changed_calls);
78826+ fscache_stat_unchecked(&fscache_n_attr_changed_calls);
78827
78828 if (fscache_object_is_active(object)) {
78829 fscache_stat(&fscache_n_cop_attr_changed);
78830@@ -204,11 +204,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
78831
78832 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
78833
78834- fscache_stat(&fscache_n_attr_changed);
78835+ fscache_stat_unchecked(&fscache_n_attr_changed);
78836
78837 op = kzalloc(sizeof(*op), GFP_KERNEL);
78838 if (!op) {
78839- fscache_stat(&fscache_n_attr_changed_nomem);
78840+ fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
78841 _leave(" = -ENOMEM");
78842 return -ENOMEM;
78843 }
78844@@ -230,7 +230,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
78845 if (fscache_submit_exclusive_op(object, op) < 0)
78846 goto nobufs_dec;
78847 spin_unlock(&cookie->lock);
78848- fscache_stat(&fscache_n_attr_changed_ok);
78849+ fscache_stat_unchecked(&fscache_n_attr_changed_ok);
78850 fscache_put_operation(op);
78851 _leave(" = 0");
78852 return 0;
78853@@ -242,7 +242,7 @@ nobufs:
78854 fscache_put_operation(op);
78855 if (wake_cookie)
78856 __fscache_wake_unused_cookie(cookie);
78857- fscache_stat(&fscache_n_attr_changed_nobufs);
78858+ fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
78859 _leave(" = %d", -ENOBUFS);
78860 return -ENOBUFS;
78861 }
78862@@ -293,7 +293,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
78863 /* allocate a retrieval operation and attempt to submit it */
78864 op = kzalloc(sizeof(*op), GFP_NOIO);
78865 if (!op) {
78866- fscache_stat(&fscache_n_retrievals_nomem);
78867+ fscache_stat_unchecked(&fscache_n_retrievals_nomem);
78868 return NULL;
78869 }
78870
78871@@ -332,12 +332,12 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
78872 return 0;
78873 }
78874
78875- fscache_stat(&fscache_n_retrievals_wait);
78876+ fscache_stat_unchecked(&fscache_n_retrievals_wait);
78877
78878 jif = jiffies;
78879 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
78880 TASK_INTERRUPTIBLE) != 0) {
78881- fscache_stat(&fscache_n_retrievals_intr);
78882+ fscache_stat_unchecked(&fscache_n_retrievals_intr);
78883 _leave(" = -ERESTARTSYS");
78884 return -ERESTARTSYS;
78885 }
78886@@ -355,8 +355,8 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
78887 */
78888 int fscache_wait_for_operation_activation(struct fscache_object *object,
78889 struct fscache_operation *op,
78890- atomic_t *stat_op_waits,
78891- atomic_t *stat_object_dead)
78892+ atomic_unchecked_t *stat_op_waits,
78893+ atomic_unchecked_t *stat_object_dead)
78894 {
78895 int ret;
78896
78897@@ -365,7 +365,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
78898
78899 _debug(">>> WT");
78900 if (stat_op_waits)
78901- fscache_stat(stat_op_waits);
78902+ fscache_stat_unchecked(stat_op_waits);
78903 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
78904 TASK_INTERRUPTIBLE) != 0) {
78905 ret = fscache_cancel_op(op, false);
78906@@ -382,7 +382,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
78907 check_if_dead:
78908 if (op->state == FSCACHE_OP_ST_CANCELLED) {
78909 if (stat_object_dead)
78910- fscache_stat(stat_object_dead);
78911+ fscache_stat_unchecked(stat_object_dead);
78912 _leave(" = -ENOBUFS [cancelled]");
78913 return -ENOBUFS;
78914 }
78915@@ -391,7 +391,7 @@ check_if_dead:
78916 enum fscache_operation_state state = op->state;
78917 fscache_cancel_op(op, true);
78918 if (stat_object_dead)
78919- fscache_stat(stat_object_dead);
78920+ fscache_stat_unchecked(stat_object_dead);
78921 _leave(" = -ENOBUFS [obj dead %d]", state);
78922 return -ENOBUFS;
78923 }
78924@@ -420,7 +420,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
78925
78926 _enter("%p,%p,,,", cookie, page);
78927
78928- fscache_stat(&fscache_n_retrievals);
78929+ fscache_stat_unchecked(&fscache_n_retrievals);
78930
78931 if (hlist_empty(&cookie->backing_objects))
78932 goto nobufs;
78933@@ -462,7 +462,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
78934 goto nobufs_unlock_dec;
78935 spin_unlock(&cookie->lock);
78936
78937- fscache_stat(&fscache_n_retrieval_ops);
78938+ fscache_stat_unchecked(&fscache_n_retrieval_ops);
78939
78940 /* we wait for the operation to become active, and then process it
78941 * *here*, in this thread, and not in the thread pool */
78942@@ -488,15 +488,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
78943
78944 error:
78945 if (ret == -ENOMEM)
78946- fscache_stat(&fscache_n_retrievals_nomem);
78947+ fscache_stat_unchecked(&fscache_n_retrievals_nomem);
78948 else if (ret == -ERESTARTSYS)
78949- fscache_stat(&fscache_n_retrievals_intr);
78950+ fscache_stat_unchecked(&fscache_n_retrievals_intr);
78951 else if (ret == -ENODATA)
78952- fscache_stat(&fscache_n_retrievals_nodata);
78953+ fscache_stat_unchecked(&fscache_n_retrievals_nodata);
78954 else if (ret < 0)
78955- fscache_stat(&fscache_n_retrievals_nobufs);
78956+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
78957 else
78958- fscache_stat(&fscache_n_retrievals_ok);
78959+ fscache_stat_unchecked(&fscache_n_retrievals_ok);
78960
78961 fscache_put_retrieval(op);
78962 _leave(" = %d", ret);
78963@@ -511,7 +511,7 @@ nobufs_unlock:
78964 __fscache_wake_unused_cookie(cookie);
78965 fscache_put_retrieval(op);
78966 nobufs:
78967- fscache_stat(&fscache_n_retrievals_nobufs);
78968+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
78969 _leave(" = -ENOBUFS");
78970 return -ENOBUFS;
78971 }
78972@@ -550,7 +550,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
78973
78974 _enter("%p,,%d,,,", cookie, *nr_pages);
78975
78976- fscache_stat(&fscache_n_retrievals);
78977+ fscache_stat_unchecked(&fscache_n_retrievals);
78978
78979 if (hlist_empty(&cookie->backing_objects))
78980 goto nobufs;
78981@@ -588,7 +588,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
78982 goto nobufs_unlock_dec;
78983 spin_unlock(&cookie->lock);
78984
78985- fscache_stat(&fscache_n_retrieval_ops);
78986+ fscache_stat_unchecked(&fscache_n_retrieval_ops);
78987
78988 /* we wait for the operation to become active, and then process it
78989 * *here*, in this thread, and not in the thread pool */
78990@@ -614,15 +614,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
78991
78992 error:
78993 if (ret == -ENOMEM)
78994- fscache_stat(&fscache_n_retrievals_nomem);
78995+ fscache_stat_unchecked(&fscache_n_retrievals_nomem);
78996 else if (ret == -ERESTARTSYS)
78997- fscache_stat(&fscache_n_retrievals_intr);
78998+ fscache_stat_unchecked(&fscache_n_retrievals_intr);
78999 else if (ret == -ENODATA)
79000- fscache_stat(&fscache_n_retrievals_nodata);
79001+ fscache_stat_unchecked(&fscache_n_retrievals_nodata);
79002 else if (ret < 0)
79003- fscache_stat(&fscache_n_retrievals_nobufs);
79004+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
79005 else
79006- fscache_stat(&fscache_n_retrievals_ok);
79007+ fscache_stat_unchecked(&fscache_n_retrievals_ok);
79008
79009 fscache_put_retrieval(op);
79010 _leave(" = %d", ret);
79011@@ -637,7 +637,7 @@ nobufs_unlock:
79012 if (wake_cookie)
79013 __fscache_wake_unused_cookie(cookie);
79014 nobufs:
79015- fscache_stat(&fscache_n_retrievals_nobufs);
79016+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
79017 _leave(" = -ENOBUFS");
79018 return -ENOBUFS;
79019 }
79020@@ -662,7 +662,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
79021
79022 _enter("%p,%p,,,", cookie, page);
79023
79024- fscache_stat(&fscache_n_allocs);
79025+ fscache_stat_unchecked(&fscache_n_allocs);
79026
79027 if (hlist_empty(&cookie->backing_objects))
79028 goto nobufs;
79029@@ -696,7 +696,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
79030 goto nobufs_unlock_dec;
79031 spin_unlock(&cookie->lock);
79032
79033- fscache_stat(&fscache_n_alloc_ops);
79034+ fscache_stat_unchecked(&fscache_n_alloc_ops);
79035
79036 ret = fscache_wait_for_operation_activation(
79037 object, &op->op,
79038@@ -712,11 +712,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
79039
79040 error:
79041 if (ret == -ERESTARTSYS)
79042- fscache_stat(&fscache_n_allocs_intr);
79043+ fscache_stat_unchecked(&fscache_n_allocs_intr);
79044 else if (ret < 0)
79045- fscache_stat(&fscache_n_allocs_nobufs);
79046+ fscache_stat_unchecked(&fscache_n_allocs_nobufs);
79047 else
79048- fscache_stat(&fscache_n_allocs_ok);
79049+ fscache_stat_unchecked(&fscache_n_allocs_ok);
79050
79051 fscache_put_retrieval(op);
79052 _leave(" = %d", ret);
79053@@ -730,7 +730,7 @@ nobufs_unlock:
79054 if (wake_cookie)
79055 __fscache_wake_unused_cookie(cookie);
79056 nobufs:
79057- fscache_stat(&fscache_n_allocs_nobufs);
79058+ fscache_stat_unchecked(&fscache_n_allocs_nobufs);
79059 _leave(" = -ENOBUFS");
79060 return -ENOBUFS;
79061 }
79062@@ -806,7 +806,7 @@ static void fscache_write_op(struct fscache_operation *_op)
79063
79064 spin_lock(&cookie->stores_lock);
79065
79066- fscache_stat(&fscache_n_store_calls);
79067+ fscache_stat_unchecked(&fscache_n_store_calls);
79068
79069 /* find a page to store */
79070 page = NULL;
79071@@ -817,7 +817,7 @@ static void fscache_write_op(struct fscache_operation *_op)
79072 page = results[0];
79073 _debug("gang %d [%lx]", n, page->index);
79074 if (page->index > op->store_limit) {
79075- fscache_stat(&fscache_n_store_pages_over_limit);
79076+ fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
79077 goto superseded;
79078 }
79079
79080@@ -829,7 +829,7 @@ static void fscache_write_op(struct fscache_operation *_op)
79081 spin_unlock(&cookie->stores_lock);
79082 spin_unlock(&object->lock);
79083
79084- fscache_stat(&fscache_n_store_pages);
79085+ fscache_stat_unchecked(&fscache_n_store_pages);
79086 fscache_stat(&fscache_n_cop_write_page);
79087 ret = object->cache->ops->write_page(op, page);
79088 fscache_stat_d(&fscache_n_cop_write_page);
79089@@ -933,7 +933,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
79090 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
79091 ASSERT(PageFsCache(page));
79092
79093- fscache_stat(&fscache_n_stores);
79094+ fscache_stat_unchecked(&fscache_n_stores);
79095
79096 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
79097 _leave(" = -ENOBUFS [invalidating]");
79098@@ -992,7 +992,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
79099 spin_unlock(&cookie->stores_lock);
79100 spin_unlock(&object->lock);
79101
79102- op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
79103+ op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
79104 op->store_limit = object->store_limit;
79105
79106 __fscache_use_cookie(cookie);
79107@@ -1001,8 +1001,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
79108
79109 spin_unlock(&cookie->lock);
79110 radix_tree_preload_end();
79111- fscache_stat(&fscache_n_store_ops);
79112- fscache_stat(&fscache_n_stores_ok);
79113+ fscache_stat_unchecked(&fscache_n_store_ops);
79114+ fscache_stat_unchecked(&fscache_n_stores_ok);
79115
79116 /* the work queue now carries its own ref on the object */
79117 fscache_put_operation(&op->op);
79118@@ -1010,14 +1010,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
79119 return 0;
79120
79121 already_queued:
79122- fscache_stat(&fscache_n_stores_again);
79123+ fscache_stat_unchecked(&fscache_n_stores_again);
79124 already_pending:
79125 spin_unlock(&cookie->stores_lock);
79126 spin_unlock(&object->lock);
79127 spin_unlock(&cookie->lock);
79128 radix_tree_preload_end();
79129 fscache_put_operation(&op->op);
79130- fscache_stat(&fscache_n_stores_ok);
79131+ fscache_stat_unchecked(&fscache_n_stores_ok);
79132 _leave(" = 0");
79133 return 0;
79134
79135@@ -1039,14 +1039,14 @@ nobufs:
79136 fscache_put_operation(&op->op);
79137 if (wake_cookie)
79138 __fscache_wake_unused_cookie(cookie);
79139- fscache_stat(&fscache_n_stores_nobufs);
79140+ fscache_stat_unchecked(&fscache_n_stores_nobufs);
79141 _leave(" = -ENOBUFS");
79142 return -ENOBUFS;
79143
79144 nomem_free:
79145 fscache_put_operation(&op->op);
79146 nomem:
79147- fscache_stat(&fscache_n_stores_oom);
79148+ fscache_stat_unchecked(&fscache_n_stores_oom);
79149 _leave(" = -ENOMEM");
79150 return -ENOMEM;
79151 }
79152@@ -1064,7 +1064,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
79153 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
79154 ASSERTCMP(page, !=, NULL);
79155
79156- fscache_stat(&fscache_n_uncaches);
79157+ fscache_stat_unchecked(&fscache_n_uncaches);
79158
79159 /* cache withdrawal may beat us to it */
79160 if (!PageFsCache(page))
79161@@ -1115,7 +1115,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
79162 struct fscache_cookie *cookie = op->op.object->cookie;
79163
79164 #ifdef CONFIG_FSCACHE_STATS
79165- atomic_inc(&fscache_n_marks);
79166+ atomic_inc_unchecked(&fscache_n_marks);
79167 #endif
79168
79169 _debug("- mark %p{%lx}", page, page->index);
79170diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
79171index 7cfa0aa..d5ef97b7 100644
79172--- a/fs/fscache/stats.c
79173+++ b/fs/fscache/stats.c
79174@@ -18,100 +18,100 @@
79175 /*
79176 * operation counters
79177 */
79178-atomic_t fscache_n_op_pend;
79179-atomic_t fscache_n_op_run;
79180-atomic_t fscache_n_op_enqueue;
79181-atomic_t fscache_n_op_requeue;
79182-atomic_t fscache_n_op_deferred_release;
79183-atomic_t fscache_n_op_initialised;
79184-atomic_t fscache_n_op_release;
79185-atomic_t fscache_n_op_gc;
79186-atomic_t fscache_n_op_cancelled;
79187-atomic_t fscache_n_op_rejected;
79188+atomic_unchecked_t fscache_n_op_pend;
79189+atomic_unchecked_t fscache_n_op_run;
79190+atomic_unchecked_t fscache_n_op_enqueue;
79191+atomic_unchecked_t fscache_n_op_requeue;
79192+atomic_unchecked_t fscache_n_op_deferred_release;
79193+atomic_unchecked_t fscache_n_op_initialised;
79194+atomic_unchecked_t fscache_n_op_release;
79195+atomic_unchecked_t fscache_n_op_gc;
79196+atomic_unchecked_t fscache_n_op_cancelled;
79197+atomic_unchecked_t fscache_n_op_rejected;
79198
79199-atomic_t fscache_n_attr_changed;
79200-atomic_t fscache_n_attr_changed_ok;
79201-atomic_t fscache_n_attr_changed_nobufs;
79202-atomic_t fscache_n_attr_changed_nomem;
79203-atomic_t fscache_n_attr_changed_calls;
79204+atomic_unchecked_t fscache_n_attr_changed;
79205+atomic_unchecked_t fscache_n_attr_changed_ok;
79206+atomic_unchecked_t fscache_n_attr_changed_nobufs;
79207+atomic_unchecked_t fscache_n_attr_changed_nomem;
79208+atomic_unchecked_t fscache_n_attr_changed_calls;
79209
79210-atomic_t fscache_n_allocs;
79211-atomic_t fscache_n_allocs_ok;
79212-atomic_t fscache_n_allocs_wait;
79213-atomic_t fscache_n_allocs_nobufs;
79214-atomic_t fscache_n_allocs_intr;
79215-atomic_t fscache_n_allocs_object_dead;
79216-atomic_t fscache_n_alloc_ops;
79217-atomic_t fscache_n_alloc_op_waits;
79218+atomic_unchecked_t fscache_n_allocs;
79219+atomic_unchecked_t fscache_n_allocs_ok;
79220+atomic_unchecked_t fscache_n_allocs_wait;
79221+atomic_unchecked_t fscache_n_allocs_nobufs;
79222+atomic_unchecked_t fscache_n_allocs_intr;
79223+atomic_unchecked_t fscache_n_allocs_object_dead;
79224+atomic_unchecked_t fscache_n_alloc_ops;
79225+atomic_unchecked_t fscache_n_alloc_op_waits;
79226
79227-atomic_t fscache_n_retrievals;
79228-atomic_t fscache_n_retrievals_ok;
79229-atomic_t fscache_n_retrievals_wait;
79230-atomic_t fscache_n_retrievals_nodata;
79231-atomic_t fscache_n_retrievals_nobufs;
79232-atomic_t fscache_n_retrievals_intr;
79233-atomic_t fscache_n_retrievals_nomem;
79234-atomic_t fscache_n_retrievals_object_dead;
79235-atomic_t fscache_n_retrieval_ops;
79236-atomic_t fscache_n_retrieval_op_waits;
79237+atomic_unchecked_t fscache_n_retrievals;
79238+atomic_unchecked_t fscache_n_retrievals_ok;
79239+atomic_unchecked_t fscache_n_retrievals_wait;
79240+atomic_unchecked_t fscache_n_retrievals_nodata;
79241+atomic_unchecked_t fscache_n_retrievals_nobufs;
79242+atomic_unchecked_t fscache_n_retrievals_intr;
79243+atomic_unchecked_t fscache_n_retrievals_nomem;
79244+atomic_unchecked_t fscache_n_retrievals_object_dead;
79245+atomic_unchecked_t fscache_n_retrieval_ops;
79246+atomic_unchecked_t fscache_n_retrieval_op_waits;
79247
79248-atomic_t fscache_n_stores;
79249-atomic_t fscache_n_stores_ok;
79250-atomic_t fscache_n_stores_again;
79251-atomic_t fscache_n_stores_nobufs;
79252-atomic_t fscache_n_stores_oom;
79253-atomic_t fscache_n_store_ops;
79254-atomic_t fscache_n_store_calls;
79255-atomic_t fscache_n_store_pages;
79256-atomic_t fscache_n_store_radix_deletes;
79257-atomic_t fscache_n_store_pages_over_limit;
79258+atomic_unchecked_t fscache_n_stores;
79259+atomic_unchecked_t fscache_n_stores_ok;
79260+atomic_unchecked_t fscache_n_stores_again;
79261+atomic_unchecked_t fscache_n_stores_nobufs;
79262+atomic_unchecked_t fscache_n_stores_oom;
79263+atomic_unchecked_t fscache_n_store_ops;
79264+atomic_unchecked_t fscache_n_store_calls;
79265+atomic_unchecked_t fscache_n_store_pages;
79266+atomic_unchecked_t fscache_n_store_radix_deletes;
79267+atomic_unchecked_t fscache_n_store_pages_over_limit;
79268
79269-atomic_t fscache_n_store_vmscan_not_storing;
79270-atomic_t fscache_n_store_vmscan_gone;
79271-atomic_t fscache_n_store_vmscan_busy;
79272-atomic_t fscache_n_store_vmscan_cancelled;
79273-atomic_t fscache_n_store_vmscan_wait;
79274+atomic_unchecked_t fscache_n_store_vmscan_not_storing;
79275+atomic_unchecked_t fscache_n_store_vmscan_gone;
79276+atomic_unchecked_t fscache_n_store_vmscan_busy;
79277+atomic_unchecked_t fscache_n_store_vmscan_cancelled;
79278+atomic_unchecked_t fscache_n_store_vmscan_wait;
79279
79280-atomic_t fscache_n_marks;
79281-atomic_t fscache_n_uncaches;
79282+atomic_unchecked_t fscache_n_marks;
79283+atomic_unchecked_t fscache_n_uncaches;
79284
79285-atomic_t fscache_n_acquires;
79286-atomic_t fscache_n_acquires_null;
79287-atomic_t fscache_n_acquires_no_cache;
79288-atomic_t fscache_n_acquires_ok;
79289-atomic_t fscache_n_acquires_nobufs;
79290-atomic_t fscache_n_acquires_oom;
79291+atomic_unchecked_t fscache_n_acquires;
79292+atomic_unchecked_t fscache_n_acquires_null;
79293+atomic_unchecked_t fscache_n_acquires_no_cache;
79294+atomic_unchecked_t fscache_n_acquires_ok;
79295+atomic_unchecked_t fscache_n_acquires_nobufs;
79296+atomic_unchecked_t fscache_n_acquires_oom;
79297
79298-atomic_t fscache_n_invalidates;
79299-atomic_t fscache_n_invalidates_run;
79300+atomic_unchecked_t fscache_n_invalidates;
79301+atomic_unchecked_t fscache_n_invalidates_run;
79302
79303-atomic_t fscache_n_updates;
79304-atomic_t fscache_n_updates_null;
79305-atomic_t fscache_n_updates_run;
79306+atomic_unchecked_t fscache_n_updates;
79307+atomic_unchecked_t fscache_n_updates_null;
79308+atomic_unchecked_t fscache_n_updates_run;
79309
79310-atomic_t fscache_n_relinquishes;
79311-atomic_t fscache_n_relinquishes_null;
79312-atomic_t fscache_n_relinquishes_waitcrt;
79313-atomic_t fscache_n_relinquishes_retire;
79314+atomic_unchecked_t fscache_n_relinquishes;
79315+atomic_unchecked_t fscache_n_relinquishes_null;
79316+atomic_unchecked_t fscache_n_relinquishes_waitcrt;
79317+atomic_unchecked_t fscache_n_relinquishes_retire;
79318
79319-atomic_t fscache_n_cookie_index;
79320-atomic_t fscache_n_cookie_data;
79321-atomic_t fscache_n_cookie_special;
79322+atomic_unchecked_t fscache_n_cookie_index;
79323+atomic_unchecked_t fscache_n_cookie_data;
79324+atomic_unchecked_t fscache_n_cookie_special;
79325
79326-atomic_t fscache_n_object_alloc;
79327-atomic_t fscache_n_object_no_alloc;
79328-atomic_t fscache_n_object_lookups;
79329-atomic_t fscache_n_object_lookups_negative;
79330-atomic_t fscache_n_object_lookups_positive;
79331-atomic_t fscache_n_object_lookups_timed_out;
79332-atomic_t fscache_n_object_created;
79333-atomic_t fscache_n_object_avail;
79334-atomic_t fscache_n_object_dead;
79335+atomic_unchecked_t fscache_n_object_alloc;
79336+atomic_unchecked_t fscache_n_object_no_alloc;
79337+atomic_unchecked_t fscache_n_object_lookups;
79338+atomic_unchecked_t fscache_n_object_lookups_negative;
79339+atomic_unchecked_t fscache_n_object_lookups_positive;
79340+atomic_unchecked_t fscache_n_object_lookups_timed_out;
79341+atomic_unchecked_t fscache_n_object_created;
79342+atomic_unchecked_t fscache_n_object_avail;
79343+atomic_unchecked_t fscache_n_object_dead;
79344
79345-atomic_t fscache_n_checkaux_none;
79346-atomic_t fscache_n_checkaux_okay;
79347-atomic_t fscache_n_checkaux_update;
79348-atomic_t fscache_n_checkaux_obsolete;
79349+atomic_unchecked_t fscache_n_checkaux_none;
79350+atomic_unchecked_t fscache_n_checkaux_okay;
79351+atomic_unchecked_t fscache_n_checkaux_update;
79352+atomic_unchecked_t fscache_n_checkaux_obsolete;
79353
79354 atomic_t fscache_n_cop_alloc_object;
79355 atomic_t fscache_n_cop_lookup_object;
79356@@ -144,119 +144,119 @@ static int fscache_stats_show(struct seq_file *m, void *v)
79357 seq_puts(m, "FS-Cache statistics\n");
79358
79359 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
79360- atomic_read(&fscache_n_cookie_index),
79361- atomic_read(&fscache_n_cookie_data),
79362- atomic_read(&fscache_n_cookie_special));
79363+ atomic_read_unchecked(&fscache_n_cookie_index),
79364+ atomic_read_unchecked(&fscache_n_cookie_data),
79365+ atomic_read_unchecked(&fscache_n_cookie_special));
79366
79367 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
79368- atomic_read(&fscache_n_object_alloc),
79369- atomic_read(&fscache_n_object_no_alloc),
79370- atomic_read(&fscache_n_object_avail),
79371- atomic_read(&fscache_n_object_dead));
79372+ atomic_read_unchecked(&fscache_n_object_alloc),
79373+ atomic_read_unchecked(&fscache_n_object_no_alloc),
79374+ atomic_read_unchecked(&fscache_n_object_avail),
79375+ atomic_read_unchecked(&fscache_n_object_dead));
79376 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
79377- atomic_read(&fscache_n_checkaux_none),
79378- atomic_read(&fscache_n_checkaux_okay),
79379- atomic_read(&fscache_n_checkaux_update),
79380- atomic_read(&fscache_n_checkaux_obsolete));
79381+ atomic_read_unchecked(&fscache_n_checkaux_none),
79382+ atomic_read_unchecked(&fscache_n_checkaux_okay),
79383+ atomic_read_unchecked(&fscache_n_checkaux_update),
79384+ atomic_read_unchecked(&fscache_n_checkaux_obsolete));
79385
79386 seq_printf(m, "Pages : mrk=%u unc=%u\n",
79387- atomic_read(&fscache_n_marks),
79388- atomic_read(&fscache_n_uncaches));
79389+ atomic_read_unchecked(&fscache_n_marks),
79390+ atomic_read_unchecked(&fscache_n_uncaches));
79391
79392 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
79393 " oom=%u\n",
79394- atomic_read(&fscache_n_acquires),
79395- atomic_read(&fscache_n_acquires_null),
79396- atomic_read(&fscache_n_acquires_no_cache),
79397- atomic_read(&fscache_n_acquires_ok),
79398- atomic_read(&fscache_n_acquires_nobufs),
79399- atomic_read(&fscache_n_acquires_oom));
79400+ atomic_read_unchecked(&fscache_n_acquires),
79401+ atomic_read_unchecked(&fscache_n_acquires_null),
79402+ atomic_read_unchecked(&fscache_n_acquires_no_cache),
79403+ atomic_read_unchecked(&fscache_n_acquires_ok),
79404+ atomic_read_unchecked(&fscache_n_acquires_nobufs),
79405+ atomic_read_unchecked(&fscache_n_acquires_oom));
79406
79407 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
79408- atomic_read(&fscache_n_object_lookups),
79409- atomic_read(&fscache_n_object_lookups_negative),
79410- atomic_read(&fscache_n_object_lookups_positive),
79411- atomic_read(&fscache_n_object_created),
79412- atomic_read(&fscache_n_object_lookups_timed_out));
79413+ atomic_read_unchecked(&fscache_n_object_lookups),
79414+ atomic_read_unchecked(&fscache_n_object_lookups_negative),
79415+ atomic_read_unchecked(&fscache_n_object_lookups_positive),
79416+ atomic_read_unchecked(&fscache_n_object_created),
79417+ atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
79418
79419 seq_printf(m, "Invals : n=%u run=%u\n",
79420- atomic_read(&fscache_n_invalidates),
79421- atomic_read(&fscache_n_invalidates_run));
79422+ atomic_read_unchecked(&fscache_n_invalidates),
79423+ atomic_read_unchecked(&fscache_n_invalidates_run));
79424
79425 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
79426- atomic_read(&fscache_n_updates),
79427- atomic_read(&fscache_n_updates_null),
79428- atomic_read(&fscache_n_updates_run));
79429+ atomic_read_unchecked(&fscache_n_updates),
79430+ atomic_read_unchecked(&fscache_n_updates_null),
79431+ atomic_read_unchecked(&fscache_n_updates_run));
79432
79433 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
79434- atomic_read(&fscache_n_relinquishes),
79435- atomic_read(&fscache_n_relinquishes_null),
79436- atomic_read(&fscache_n_relinquishes_waitcrt),
79437- atomic_read(&fscache_n_relinquishes_retire));
79438+ atomic_read_unchecked(&fscache_n_relinquishes),
79439+ atomic_read_unchecked(&fscache_n_relinquishes_null),
79440+ atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
79441+ atomic_read_unchecked(&fscache_n_relinquishes_retire));
79442
79443 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
79444- atomic_read(&fscache_n_attr_changed),
79445- atomic_read(&fscache_n_attr_changed_ok),
79446- atomic_read(&fscache_n_attr_changed_nobufs),
79447- atomic_read(&fscache_n_attr_changed_nomem),
79448- atomic_read(&fscache_n_attr_changed_calls));
79449+ atomic_read_unchecked(&fscache_n_attr_changed),
79450+ atomic_read_unchecked(&fscache_n_attr_changed_ok),
79451+ atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
79452+ atomic_read_unchecked(&fscache_n_attr_changed_nomem),
79453+ atomic_read_unchecked(&fscache_n_attr_changed_calls));
79454
79455 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
79456- atomic_read(&fscache_n_allocs),
79457- atomic_read(&fscache_n_allocs_ok),
79458- atomic_read(&fscache_n_allocs_wait),
79459- atomic_read(&fscache_n_allocs_nobufs),
79460- atomic_read(&fscache_n_allocs_intr));
79461+ atomic_read_unchecked(&fscache_n_allocs),
79462+ atomic_read_unchecked(&fscache_n_allocs_ok),
79463+ atomic_read_unchecked(&fscache_n_allocs_wait),
79464+ atomic_read_unchecked(&fscache_n_allocs_nobufs),
79465+ atomic_read_unchecked(&fscache_n_allocs_intr));
79466 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
79467- atomic_read(&fscache_n_alloc_ops),
79468- atomic_read(&fscache_n_alloc_op_waits),
79469- atomic_read(&fscache_n_allocs_object_dead));
79470+ atomic_read_unchecked(&fscache_n_alloc_ops),
79471+ atomic_read_unchecked(&fscache_n_alloc_op_waits),
79472+ atomic_read_unchecked(&fscache_n_allocs_object_dead));
79473
79474 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
79475 " int=%u oom=%u\n",
79476- atomic_read(&fscache_n_retrievals),
79477- atomic_read(&fscache_n_retrievals_ok),
79478- atomic_read(&fscache_n_retrievals_wait),
79479- atomic_read(&fscache_n_retrievals_nodata),
79480- atomic_read(&fscache_n_retrievals_nobufs),
79481- atomic_read(&fscache_n_retrievals_intr),
79482- atomic_read(&fscache_n_retrievals_nomem));
79483+ atomic_read_unchecked(&fscache_n_retrievals),
79484+ atomic_read_unchecked(&fscache_n_retrievals_ok),
79485+ atomic_read_unchecked(&fscache_n_retrievals_wait),
79486+ atomic_read_unchecked(&fscache_n_retrievals_nodata),
79487+ atomic_read_unchecked(&fscache_n_retrievals_nobufs),
79488+ atomic_read_unchecked(&fscache_n_retrievals_intr),
79489+ atomic_read_unchecked(&fscache_n_retrievals_nomem));
79490 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
79491- atomic_read(&fscache_n_retrieval_ops),
79492- atomic_read(&fscache_n_retrieval_op_waits),
79493- atomic_read(&fscache_n_retrievals_object_dead));
79494+ atomic_read_unchecked(&fscache_n_retrieval_ops),
79495+ atomic_read_unchecked(&fscache_n_retrieval_op_waits),
79496+ atomic_read_unchecked(&fscache_n_retrievals_object_dead));
79497
79498 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
79499- atomic_read(&fscache_n_stores),
79500- atomic_read(&fscache_n_stores_ok),
79501- atomic_read(&fscache_n_stores_again),
79502- atomic_read(&fscache_n_stores_nobufs),
79503- atomic_read(&fscache_n_stores_oom));
79504+ atomic_read_unchecked(&fscache_n_stores),
79505+ atomic_read_unchecked(&fscache_n_stores_ok),
79506+ atomic_read_unchecked(&fscache_n_stores_again),
79507+ atomic_read_unchecked(&fscache_n_stores_nobufs),
79508+ atomic_read_unchecked(&fscache_n_stores_oom));
79509 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
79510- atomic_read(&fscache_n_store_ops),
79511- atomic_read(&fscache_n_store_calls),
79512- atomic_read(&fscache_n_store_pages),
79513- atomic_read(&fscache_n_store_radix_deletes),
79514- atomic_read(&fscache_n_store_pages_over_limit));
79515+ atomic_read_unchecked(&fscache_n_store_ops),
79516+ atomic_read_unchecked(&fscache_n_store_calls),
79517+ atomic_read_unchecked(&fscache_n_store_pages),
79518+ atomic_read_unchecked(&fscache_n_store_radix_deletes),
79519+ atomic_read_unchecked(&fscache_n_store_pages_over_limit));
79520
79521 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
79522- atomic_read(&fscache_n_store_vmscan_not_storing),
79523- atomic_read(&fscache_n_store_vmscan_gone),
79524- atomic_read(&fscache_n_store_vmscan_busy),
79525- atomic_read(&fscache_n_store_vmscan_cancelled),
79526- atomic_read(&fscache_n_store_vmscan_wait));
79527+ atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
79528+ atomic_read_unchecked(&fscache_n_store_vmscan_gone),
79529+ atomic_read_unchecked(&fscache_n_store_vmscan_busy),
79530+ atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
79531+ atomic_read_unchecked(&fscache_n_store_vmscan_wait));
79532
79533 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
79534- atomic_read(&fscache_n_op_pend),
79535- atomic_read(&fscache_n_op_run),
79536- atomic_read(&fscache_n_op_enqueue),
79537- atomic_read(&fscache_n_op_cancelled),
79538- atomic_read(&fscache_n_op_rejected));
79539+ atomic_read_unchecked(&fscache_n_op_pend),
79540+ atomic_read_unchecked(&fscache_n_op_run),
79541+ atomic_read_unchecked(&fscache_n_op_enqueue),
79542+ atomic_read_unchecked(&fscache_n_op_cancelled),
79543+ atomic_read_unchecked(&fscache_n_op_rejected));
79544 seq_printf(m, "Ops : ini=%u dfr=%u rel=%u gc=%u\n",
79545- atomic_read(&fscache_n_op_initialised),
79546- atomic_read(&fscache_n_op_deferred_release),
79547- atomic_read(&fscache_n_op_release),
79548- atomic_read(&fscache_n_op_gc));
79549+ atomic_read_unchecked(&fscache_n_op_initialised),
79550+ atomic_read_unchecked(&fscache_n_op_deferred_release),
79551+ atomic_read_unchecked(&fscache_n_op_release),
79552+ atomic_read_unchecked(&fscache_n_op_gc));
79553
79554 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
79555 atomic_read(&fscache_n_cop_alloc_object),
79556diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
79557index eae2c11..b277a45 100644
79558--- a/fs/fuse/cuse.c
79559+++ b/fs/fuse/cuse.c
79560@@ -609,10 +609,12 @@ static int __init cuse_init(void)
79561 INIT_LIST_HEAD(&cuse_conntbl[i]);
79562
79563 /* inherit and extend fuse_dev_operations */
79564- cuse_channel_fops = fuse_dev_operations;
79565- cuse_channel_fops.owner = THIS_MODULE;
79566- cuse_channel_fops.open = cuse_channel_open;
79567- cuse_channel_fops.release = cuse_channel_release;
79568+ pax_open_kernel();
79569+ memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
79570+ *(void **)&cuse_channel_fops.owner = THIS_MODULE;
79571+ *(void **)&cuse_channel_fops.open = cuse_channel_open;
79572+ *(void **)&cuse_channel_fops.release = cuse_channel_release;
79573+ pax_close_kernel();
79574
79575 cuse_class = class_create(THIS_MODULE, "cuse");
79576 if (IS_ERR(cuse_class))
79577diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
79578index ebb5e37..beae05b 100644
79579--- a/fs/fuse/dev.c
79580+++ b/fs/fuse/dev.c
79581@@ -1390,7 +1390,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
79582 ret = 0;
79583 pipe_lock(pipe);
79584
79585- if (!pipe->readers) {
79586+ if (!atomic_read(&pipe->readers)) {
79587 send_sig(SIGPIPE, current, 0);
79588 if (!ret)
79589 ret = -EPIPE;
79590@@ -1419,7 +1419,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
79591 page_nr++;
79592 ret += buf->len;
79593
79594- if (pipe->files)
79595+ if (atomic_read(&pipe->files))
79596 do_wakeup = 1;
79597 }
79598
79599diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
79600index a38e38f..6dbdcf6 100644
79601--- a/fs/gfs2/glock.c
79602+++ b/fs/gfs2/glock.c
79603@@ -385,9 +385,9 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state)
79604 if (held1 != held2) {
79605 GLOCK_BUG_ON(gl, __lockref_is_dead(&gl->gl_lockref));
79606 if (held2)
79607- gl->gl_lockref.count++;
79608+ __lockref_inc(&gl->gl_lockref);
79609 else
79610- gl->gl_lockref.count--;
79611+ __lockref_dec(&gl->gl_lockref);
79612 }
79613 if (held1 && held2 && list_empty(&gl->gl_holders))
79614 clear_bit(GLF_QUEUED, &gl->gl_flags);
79615@@ -614,9 +614,9 @@ out:
79616 out_sched:
79617 clear_bit(GLF_LOCK, &gl->gl_flags);
79618 smp_mb__after_atomic();
79619- gl->gl_lockref.count++;
79620+ __lockref_inc(&gl->gl_lockref);
79621 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
79622- gl->gl_lockref.count--;
79623+ __lockref_dec(&gl->gl_lockref);
79624 return;
79625
79626 out_unlock:
79627@@ -742,7 +742,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
79628 gl->gl_sbd = sdp;
79629 gl->gl_flags = 0;
79630 gl->gl_name = name;
79631- gl->gl_lockref.count = 1;
79632+ __lockref_set(&gl->gl_lockref, 1);
79633 gl->gl_state = LM_ST_UNLOCKED;
79634 gl->gl_target = LM_ST_UNLOCKED;
79635 gl->gl_demote_state = LM_ST_EXCLUSIVE;
79636@@ -1020,9 +1020,9 @@ int gfs2_glock_nq(struct gfs2_holder *gh)
79637 if (unlikely((LM_FLAG_NOEXP & gh->gh_flags) &&
79638 test_and_clear_bit(GLF_FROZEN, &gl->gl_flags))) {
79639 set_bit(GLF_REPLY_PENDING, &gl->gl_flags);
79640- gl->gl_lockref.count++;
79641+ __lockref_inc(&gl->gl_lockref);
79642 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
79643- gl->gl_lockref.count--;
79644+ __lockref_dec(&gl->gl_lockref);
79645 }
79646 run_queue(gl, 1);
79647 spin_unlock(&gl->gl_spin);
79648@@ -1326,7 +1326,7 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret)
79649 }
79650 }
79651
79652- gl->gl_lockref.count++;
79653+ __lockref_inc(&gl->gl_lockref);
79654 set_bit(GLF_REPLY_PENDING, &gl->gl_flags);
79655 spin_unlock(&gl->gl_spin);
79656
79657@@ -1385,12 +1385,12 @@ add_back_to_lru:
79658 goto add_back_to_lru;
79659 }
79660 clear_bit(GLF_LRU, &gl->gl_flags);
79661- gl->gl_lockref.count++;
79662+ __lockref_inc(&gl->gl_lockref);
79663 if (demote_ok(gl))
79664 handle_callback(gl, LM_ST_UNLOCKED, 0, false);
79665 WARN_ON(!test_and_clear_bit(GLF_LOCK, &gl->gl_flags));
79666 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
79667- gl->gl_lockref.count--;
79668+ __lockref_dec(&gl->gl_lockref);
79669 spin_unlock(&gl->gl_spin);
79670 cond_resched_lock(&lru_lock);
79671 }
79672@@ -1720,7 +1720,7 @@ void gfs2_dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
79673 state2str(gl->gl_demote_state), dtime,
79674 atomic_read(&gl->gl_ail_count),
79675 atomic_read(&gl->gl_revokes),
79676- (int)gl->gl_lockref.count, gl->gl_hold_time);
79677+ __lockref_read(&gl->gl_lockref), gl->gl_hold_time);
79678
79679 list_for_each_entry(gh, &gl->gl_holders, gh_list)
79680 dump_holder(seq, gh);
79681diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
79682index fa3fa5e..9fe2272 100644
79683--- a/fs/gfs2/glops.c
79684+++ b/fs/gfs2/glops.c
79685@@ -552,9 +552,9 @@ static void iopen_go_callback(struct gfs2_glock *gl, bool remote)
79686
79687 if (gl->gl_demote_state == LM_ST_UNLOCKED &&
79688 gl->gl_state == LM_ST_SHARED && ip) {
79689- gl->gl_lockref.count++;
79690+ __lockref_inc(&gl->gl_lockref);
79691 if (queue_work(gfs2_delete_workqueue, &gl->gl_delete) == 0)
79692- gl->gl_lockref.count--;
79693+ __lockref_dec(&gl->gl_lockref);
79694 }
79695 }
79696
79697diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
79698index 9b61f92..ab84778 100644
79699--- a/fs/gfs2/quota.c
79700+++ b/fs/gfs2/quota.c
79701@@ -154,7 +154,7 @@ static enum lru_status gfs2_qd_isolate(struct list_head *item,
79702 if (!spin_trylock(&qd->qd_lockref.lock))
79703 return LRU_SKIP;
79704
79705- if (qd->qd_lockref.count == 0) {
79706+ if (__lockref_read(&qd->qd_lockref) == 0) {
79707 lockref_mark_dead(&qd->qd_lockref);
79708 list_lru_isolate_move(lru, &qd->qd_lru, dispose);
79709 }
79710@@ -221,7 +221,7 @@ static struct gfs2_quota_data *qd_alloc(unsigned hash, struct gfs2_sbd *sdp, str
79711 return NULL;
79712
79713 qd->qd_sbd = sdp;
79714- qd->qd_lockref.count = 1;
79715+ __lockref_set(&qd->qd_lockref, 1);
79716 spin_lock_init(&qd->qd_lockref.lock);
79717 qd->qd_id = qid;
79718 qd->qd_slot = -1;
79719@@ -312,7 +312,7 @@ static void qd_put(struct gfs2_quota_data *qd)
79720 if (lockref_put_or_lock(&qd->qd_lockref))
79721 return;
79722
79723- qd->qd_lockref.count = 0;
79724+ __lockref_set(&qd->qd_lockref, 0);
79725 list_lru_add(&gfs2_qd_lru, &qd->qd_lru);
79726 spin_unlock(&qd->qd_lockref.lock);
79727
79728diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
79729index 973c24c..a3cbeb3 100644
79730--- a/fs/hugetlbfs/inode.c
79731+++ b/fs/hugetlbfs/inode.c
79732@@ -150,6 +150,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
79733 struct mm_struct *mm = current->mm;
79734 struct vm_area_struct *vma;
79735 struct hstate *h = hstate_file(file);
79736+ unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
79737 struct vm_unmapped_area_info info;
79738
79739 if (len & ~huge_page_mask(h))
79740@@ -163,17 +164,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
79741 return addr;
79742 }
79743
79744+#ifdef CONFIG_PAX_RANDMMAP
79745+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
79746+#endif
79747+
79748 if (addr) {
79749 addr = ALIGN(addr, huge_page_size(h));
79750 vma = find_vma(mm, addr);
79751- if (TASK_SIZE - len >= addr &&
79752- (!vma || addr + len <= vma->vm_start))
79753+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
79754 return addr;
79755 }
79756
79757 info.flags = 0;
79758 info.length = len;
79759 info.low_limit = TASK_UNMAPPED_BASE;
79760+
79761+#ifdef CONFIG_PAX_RANDMMAP
79762+ if (mm->pax_flags & MF_PAX_RANDMMAP)
79763+ info.low_limit += mm->delta_mmap;
79764+#endif
79765+
79766 info.high_limit = TASK_SIZE;
79767 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
79768 info.align_offset = 0;
79769@@ -938,7 +948,7 @@ static struct file_system_type hugetlbfs_fs_type = {
79770 };
79771 MODULE_ALIAS_FS("hugetlbfs");
79772
79773-static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
79774+struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
79775
79776 static int can_do_hugetlb_shm(void)
79777 {
79778diff --git a/fs/inode.c b/fs/inode.c
79779index d30640f..9d909a7 100644
79780--- a/fs/inode.c
79781+++ b/fs/inode.c
79782@@ -832,19 +832,19 @@ unsigned int get_next_ino(void)
79783 unsigned int *p = &get_cpu_var(last_ino);
79784 unsigned int res = *p;
79785
79786+start:
79787+
79788 #ifdef CONFIG_SMP
79789 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
79790- static atomic_t shared_last_ino;
79791- int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
79792+ static atomic_unchecked_t shared_last_ino;
79793+ int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
79794
79795 res = next - LAST_INO_BATCH;
79796 }
79797 #endif
79798
79799- res++;
79800- /* get_next_ino should not provide a 0 inode number */
79801- if (unlikely(!res))
79802- res++;
79803+ if (unlikely(!++res))
79804+ goto start; /* never zero */
79805 *p = res;
79806 put_cpu_var(last_ino);
79807 return res;
79808diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
79809index 4a6cf28..d3a29d3 100644
79810--- a/fs/jffs2/erase.c
79811+++ b/fs/jffs2/erase.c
79812@@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
79813 struct jffs2_unknown_node marker = {
79814 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
79815 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
79816- .totlen = cpu_to_je32(c->cleanmarker_size)
79817+ .totlen = cpu_to_je32(c->cleanmarker_size),
79818+ .hdr_crc = cpu_to_je32(0)
79819 };
79820
79821 jffs2_prealloc_raw_node_refs(c, jeb, 1);
79822diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
79823index 09ed551..45684f8 100644
79824--- a/fs/jffs2/wbuf.c
79825+++ b/fs/jffs2/wbuf.c
79826@@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
79827 {
79828 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
79829 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
79830- .totlen = constant_cpu_to_je32(8)
79831+ .totlen = constant_cpu_to_je32(8),
79832+ .hdr_crc = constant_cpu_to_je32(0)
79833 };
79834
79835 /*
79836diff --git a/fs/jfs/super.c b/fs/jfs/super.c
79837index 4cd9798..8dfe86a 100644
79838--- a/fs/jfs/super.c
79839+++ b/fs/jfs/super.c
79840@@ -901,7 +901,7 @@ static int __init init_jfs_fs(void)
79841
79842 jfs_inode_cachep =
79843 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
79844- SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
79845+ SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
79846 init_once);
79847 if (jfs_inode_cachep == NULL)
79848 return -ENOMEM;
79849diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
79850index 2d48d28..82eddad 100644
79851--- a/fs/kernfs/dir.c
79852+++ b/fs/kernfs/dir.c
79853@@ -182,7 +182,7 @@ struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn)
79854 *
79855 * Returns 31 bit hash of ns + name (so it fits in an off_t )
79856 */
79857-static unsigned int kernfs_name_hash(const char *name, const void *ns)
79858+static unsigned int kernfs_name_hash(const unsigned char *name, const void *ns)
79859 {
79860 unsigned long hash = init_name_hash();
79861 unsigned int len = strlen(name);
79862@@ -873,6 +873,12 @@ static int kernfs_iop_mkdir(struct inode *dir, struct dentry *dentry,
79863 ret = scops->mkdir(parent, dentry->d_name.name, mode);
79864
79865 kernfs_put_active(parent);
79866+
79867+ if (!ret) {
79868+ struct dentry *dentry_ret = kernfs_iop_lookup(dir, dentry, 0);
79869+ ret = PTR_ERR_OR_ZERO(dentry_ret);
79870+ }
79871+
79872 return ret;
79873 }
79874
79875diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
79876index 7247252..c73808e 100644
79877--- a/fs/kernfs/file.c
79878+++ b/fs/kernfs/file.c
79879@@ -34,7 +34,7 @@ static DEFINE_MUTEX(kernfs_open_file_mutex);
79880
79881 struct kernfs_open_node {
79882 atomic_t refcnt;
79883- atomic_t event;
79884+ atomic_unchecked_t event;
79885 wait_queue_head_t poll;
79886 struct list_head files; /* goes through kernfs_open_file.list */
79887 };
79888@@ -163,7 +163,7 @@ static int kernfs_seq_show(struct seq_file *sf, void *v)
79889 {
79890 struct kernfs_open_file *of = sf->private;
79891
79892- of->event = atomic_read(&of->kn->attr.open->event);
79893+ of->event = atomic_read_unchecked(&of->kn->attr.open->event);
79894
79895 return of->kn->attr.ops->seq_show(sf, v);
79896 }
79897@@ -207,7 +207,7 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
79898 goto out_free;
79899 }
79900
79901- of->event = atomic_read(&of->kn->attr.open->event);
79902+ of->event = atomic_read_unchecked(&of->kn->attr.open->event);
79903 ops = kernfs_ops(of->kn);
79904 if (ops->read)
79905 len = ops->read(of, buf, len, *ppos);
79906@@ -272,7 +272,7 @@ static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf,
79907 {
79908 struct kernfs_open_file *of = kernfs_of(file);
79909 const struct kernfs_ops *ops;
79910- size_t len;
79911+ ssize_t len;
79912 char *buf;
79913
79914 if (of->atomic_write_len) {
79915@@ -385,12 +385,12 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma,
79916 return ret;
79917 }
79918
79919-static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
79920- void *buf, int len, int write)
79921+static ssize_t kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
79922+ void *buf, size_t len, int write)
79923 {
79924 struct file *file = vma->vm_file;
79925 struct kernfs_open_file *of = kernfs_of(file);
79926- int ret;
79927+ ssize_t ret;
79928
79929 if (!of->vm_ops)
79930 return -EINVAL;
79931@@ -569,7 +569,7 @@ static int kernfs_get_open_node(struct kernfs_node *kn,
79932 return -ENOMEM;
79933
79934 atomic_set(&new_on->refcnt, 0);
79935- atomic_set(&new_on->event, 1);
79936+ atomic_set_unchecked(&new_on->event, 1);
79937 init_waitqueue_head(&new_on->poll);
79938 INIT_LIST_HEAD(&new_on->files);
79939 goto retry;
79940@@ -792,7 +792,7 @@ static unsigned int kernfs_fop_poll(struct file *filp, poll_table *wait)
79941
79942 kernfs_put_active(kn);
79943
79944- if (of->event != atomic_read(&on->event))
79945+ if (of->event != atomic_read_unchecked(&on->event))
79946 goto trigger;
79947
79948 return DEFAULT_POLLMASK;
79949@@ -823,7 +823,7 @@ repeat:
79950
79951 on = kn->attr.open;
79952 if (on) {
79953- atomic_inc(&on->event);
79954+ atomic_inc_unchecked(&on->event);
79955 wake_up_interruptible(&on->poll);
79956 }
79957
79958diff --git a/fs/libfs.c b/fs/libfs.c
79959index c7cbfb0..fc3636d4 100644
79960--- a/fs/libfs.c
79961+++ b/fs/libfs.c
79962@@ -155,6 +155,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
79963
79964 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
79965 struct dentry *next = list_entry(p, struct dentry, d_child);
79966+ char d_name[sizeof(next->d_iname)];
79967+ const unsigned char *name;
79968+
79969 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
79970 if (!simple_positive(next)) {
79971 spin_unlock(&next->d_lock);
79972@@ -163,7 +166,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
79973
79974 spin_unlock(&next->d_lock);
79975 spin_unlock(&dentry->d_lock);
79976- if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
79977+ name = next->d_name.name;
79978+ if (name == next->d_iname) {
79979+ memcpy(d_name, name, next->d_name.len);
79980+ name = d_name;
79981+ }
79982+ if (!dir_emit(ctx, name, next->d_name.len,
79983 d_inode(next)->i_ino, dt_type(d_inode(next))))
79984 return 0;
79985 spin_lock(&dentry->d_lock);
79986diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
79987index acd3947..1f896e2 100644
79988--- a/fs/lockd/clntproc.c
79989+++ b/fs/lockd/clntproc.c
79990@@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
79991 /*
79992 * Cookie counter for NLM requests
79993 */
79994-static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
79995+static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
79996
79997 void nlmclnt_next_cookie(struct nlm_cookie *c)
79998 {
79999- u32 cookie = atomic_inc_return(&nlm_cookie);
80000+ u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
80001
80002 memcpy(c->data, &cookie, 4);
80003 c->len=4;
80004diff --git a/fs/mount.h b/fs/mount.h
80005index 14db05d..687f6d8 100644
80006--- a/fs/mount.h
80007+++ b/fs/mount.h
80008@@ -13,7 +13,7 @@ struct mnt_namespace {
80009 u64 seq; /* Sequence number to prevent loops */
80010 wait_queue_head_t poll;
80011 u64 event;
80012-};
80013+} __randomize_layout;
80014
80015 struct mnt_pcp {
80016 int mnt_count;
80017@@ -65,7 +65,7 @@ struct mount {
80018 struct hlist_head mnt_pins;
80019 struct fs_pin mnt_umount;
80020 struct dentry *mnt_ex_mountpoint;
80021-};
80022+} __randomize_layout;
80023
80024 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
80025
80026diff --git a/fs/namei.c b/fs/namei.c
80027index 36df481..c3045fd 100644
80028--- a/fs/namei.c
80029+++ b/fs/namei.c
80030@@ -336,17 +336,32 @@ int generic_permission(struct inode *inode, int mask)
80031 if (ret != -EACCES)
80032 return ret;
80033
80034+#ifdef CONFIG_GRKERNSEC
80035+ /* we'll block if we have to log due to a denied capability use */
80036+ if (mask & MAY_NOT_BLOCK)
80037+ return -ECHILD;
80038+#endif
80039+
80040 if (S_ISDIR(inode->i_mode)) {
80041 /* DACs are overridable for directories */
80042- if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
80043- return 0;
80044 if (!(mask & MAY_WRITE))
80045- if (capable_wrt_inode_uidgid(inode,
80046- CAP_DAC_READ_SEARCH))
80047+ if (capable_wrt_inode_uidgid_nolog(inode, CAP_DAC_OVERRIDE) ||
80048+ capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
80049 return 0;
80050+ if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
80051+ return 0;
80052 return -EACCES;
80053 }
80054 /*
80055+ * Searching includes executable on directories, else just read.
80056+ */
80057+ mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
80058+ if (mask == MAY_READ)
80059+ if (capable_wrt_inode_uidgid_nolog(inode, CAP_DAC_OVERRIDE) ||
80060+ capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
80061+ return 0;
80062+
80063+ /*
80064 * Read/write DACs are always overridable.
80065 * Executable DACs are overridable when there is
80066 * at least one exec bit set.
80067@@ -355,14 +370,6 @@ int generic_permission(struct inode *inode, int mask)
80068 if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
80069 return 0;
80070
80071- /*
80072- * Searching includes executable on directories, else just read.
80073- */
80074- mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
80075- if (mask == MAY_READ)
80076- if (capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
80077- return 0;
80078-
80079 return -EACCES;
80080 }
80081 EXPORT_SYMBOL(generic_permission);
80082@@ -514,12 +521,35 @@ struct nameidata {
80083 struct nameidata *saved;
80084 unsigned root_seq;
80085 int dfd;
80086-};
80087+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80088+ struct path *symlinkown_stack;
80089+ struct path symlinkown_internal[EMBEDDED_LEVELS];
80090+ unsigned symlinkown_depth;
80091+ int symlinkown_enabled;
80092+#endif
80093+} __randomize_layout;
80094+
80095+static int gr_handle_nameidata_symlinkowner(const struct nameidata *nd, const struct inode *target)
80096+{
80097+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80098+ int i;
80099+
80100+ for (i = 0; i < nd->symlinkown_depth; i++) {
80101+ if (gr_handle_symlink_owner(&nd->symlinkown_stack[i], target))
80102+ return -EACCES;
80103+ }
80104+#endif
80105+ return 0;
80106+}
80107
80108 static void set_nameidata(struct nameidata *p, int dfd, struct filename *name)
80109 {
80110 struct nameidata *old = current->nameidata;
80111 p->stack = p->internal;
80112+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80113+ p->symlinkown_stack = p->symlinkown_internal;
80114+ p->symlinkown_enabled = -1;
80115+#endif
80116 p->dfd = dfd;
80117 p->name = name;
80118 p->total_link_count = old ? old->total_link_count : 0;
80119@@ -538,6 +568,12 @@ static void restore_nameidata(void)
80120 kfree(now->stack);
80121 now->stack = now->internal;
80122 }
80123+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80124+ if (now->symlinkown_stack != now->symlinkown_internal) {
80125+ kfree(now->symlinkown_stack);
80126+ now->symlinkown_stack = now->symlinkown_internal;
80127+ }
80128+#endif
80129 }
80130
80131 static int __nd_alloc_stack(struct nameidata *nd)
80132@@ -557,9 +593,29 @@ static int __nd_alloc_stack(struct nameidata *nd)
80133 }
80134 memcpy(p, nd->internal, sizeof(nd->internal));
80135 nd->stack = p;
80136+
80137 return 0;
80138 }
80139
80140+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80141+static int nd_alloc_symlinkown_stack(struct nameidata *nd)
80142+{
80143+ struct path *p;
80144+
80145+ if (likely(nd->symlinkown_depth != EMBEDDED_LEVELS))
80146+ return 0;
80147+ if (nd->symlinkown_stack != nd->symlinkown_internal)
80148+ return 0;
80149+
80150+ p = kmalloc(MAXSYMLINKS * sizeof(struct path), GFP_KERNEL);
80151+ if (unlikely(!p))
80152+ return -ENOMEM;
80153+ memcpy(p, nd->symlinkown_internal, sizeof(nd->symlinkown_internal));
80154+ nd->symlinkown_stack = p;
80155+ return 0;
80156+}
80157+#endif
80158+
80159 /**
80160 * path_connected - Verify that a path->dentry is below path->mnt.mnt_root
80161 * @path: nameidate to verify
80162@@ -580,6 +636,11 @@ static bool path_connected(const struct path *path)
80163
80164 static inline int nd_alloc_stack(struct nameidata *nd)
80165 {
80166+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80167+ if (nd->flags & LOOKUP_RCU)
80168+ return -ECHILD;
80169+#endif
80170+
80171 if (likely(nd->depth != EMBEDDED_LEVELS))
80172 return 0;
80173 if (likely(nd->stack != nd->internal))
80174@@ -608,6 +669,14 @@ static void terminate_walk(struct nameidata *nd)
80175 path_put(&nd->path);
80176 for (i = 0; i < nd->depth; i++)
80177 path_put(&nd->stack[i].link);
80178+
80179+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80180+ /* we'll only ever set our values in ref-walk mode */
80181+ for (i = 0; i < nd->symlinkown_depth; i++)
80182+ path_put(&nd->symlinkown_stack[i]);
80183+ nd->symlinkown_depth = 0;
80184+#endif
80185+
80186 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) {
80187 path_put(&nd->root);
80188 nd->root.mnt = NULL;
80189@@ -1004,6 +1073,9 @@ const char *get_link(struct nameidata *nd)
80190 if (unlikely(error))
80191 return ERR_PTR(error);
80192
80193+ if (gr_handle_follow_link(dentry, last->link.mnt))
80194+ return ERR_PTR(-EACCES);
80195+
80196 nd->last_type = LAST_BIND;
80197 res = inode->i_link;
80198 if (!res) {
80199@@ -1692,6 +1764,23 @@ static int pick_link(struct nameidata *nd, struct path *link,
80200 }
80201 }
80202
80203+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80204+ if (unlikely(nd->symlinkown_enabled == -1))
80205+ nd->symlinkown_enabled = gr_get_symlinkown_enabled();
80206+ if (nd->symlinkown_enabled && gr_is_global_nonroot(inode->i_uid)) {
80207+ struct path *symlinkownlast;
80208+ error = nd_alloc_symlinkown_stack(nd);
80209+ if (unlikely(error)) {
80210+ path_put(link);
80211+ return error;
80212+ }
80213+ symlinkownlast = nd->symlinkown_stack + nd->symlinkown_depth++;
80214+ symlinkownlast->dentry = link->dentry;
80215+ symlinkownlast->mnt = link->mnt;
80216+ path_get(symlinkownlast);
80217+ }
80218+#endif
80219+
80220 last = nd->stack + nd->depth++;
80221 last->link = *link;
80222 last->cookie = NULL;
80223@@ -1831,7 +1920,7 @@ EXPORT_SYMBOL(full_name_hash);
80224 static inline u64 hash_name(const char *name)
80225 {
80226 unsigned long a, b, adata, bdata, mask, hash, len;
80227- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80228+ static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80229
80230 hash = a = 0;
80231 len = -sizeof(unsigned long);
80232@@ -2000,6 +2089,9 @@ static const char *path_init(struct nameidata *nd, unsigned flags)
80233 nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT;
80234 nd->depth = 0;
80235 nd->total_link_count = 0;
80236+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80237+ nd->symlinkown_depth = 0;
80238+#endif
80239 if (flags & LOOKUP_ROOT) {
80240 struct dentry *root = nd->root.dentry;
80241 struct inode *inode = root->d_inode;
80242@@ -2137,6 +2229,11 @@ static int path_lookupat(struct nameidata *nd, unsigned flags, struct path *path
80243 if (!err)
80244 err = complete_walk(nd);
80245
80246+ if (!err && !(nd->flags & LOOKUP_PARENT)) {
80247+ if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt))
80248+ err = -ENOENT;
80249+ }
80250+
80251 if (!err && nd->flags & LOOKUP_DIRECTORY)
80252 if (!d_can_lookup(nd->path.dentry))
80253 err = -ENOTDIR;
80254@@ -2185,6 +2282,10 @@ static int path_parentat(struct nameidata *nd, unsigned flags,
80255 err = link_path_walk(s, nd);
80256 if (!err)
80257 err = complete_walk(nd);
80258+
80259+ if (!err && gr_handle_nameidata_symlinkowner(nd, nd->inode))
80260+ err = -EACCES;
80261+
80262 if (!err) {
80263 *parent = nd->path;
80264 nd->path.mnt = NULL;
80265@@ -2716,6 +2817,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
80266 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
80267 return -EPERM;
80268
80269+ if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
80270+ return -EPERM;
80271+ if (gr_handle_rawio(inode))
80272+ return -EPERM;
80273+ if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
80274+ return -EACCES;
80275+
80276 return 0;
80277 }
80278
80279@@ -2982,6 +3090,18 @@ static int lookup_open(struct nameidata *nd, struct path *path,
80280 /* Negative dentry, just create the file */
80281 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
80282 umode_t mode = op->mode;
80283+
80284+
80285+ if (gr_handle_nameidata_symlinkowner(nd, dir_inode)) {
80286+ error = -EACCES;
80287+ goto out_dput;
80288+ }
80289+
80290+ if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
80291+ error = -EACCES;
80292+ goto out_dput;
80293+ }
80294+
80295 if (!IS_POSIXACL(dir->d_inode))
80296 mode &= ~current_umask();
80297 /*
80298@@ -3003,6 +3123,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
80299 nd->flags & LOOKUP_EXCL);
80300 if (error)
80301 goto out_dput;
80302+ else
80303+ gr_handle_create(dentry, nd->path.mnt);
80304 }
80305 out_no_open:
80306 path->dentry = dentry;
80307@@ -3066,6 +3188,9 @@ static int do_last(struct nameidata *nd,
80308 if (error)
80309 return error;
80310
80311+ if (!gr_acl_handle_hidden_file(dir, nd->path.mnt))
80312+ return -ENOENT;
80313+
80314 audit_inode(nd->name, dir, LOOKUP_PARENT);
80315 /* trailing slashes? */
80316 if (unlikely(nd->last.name[nd->last.len]))
80317@@ -3108,11 +3233,24 @@ retry_lookup:
80318 goto finish_open_created;
80319 }
80320
80321+ if (!gr_acl_handle_hidden_file(path.dentry, nd->path.mnt)) {
80322+ path_to_nameidata(&path, nd);
80323+ return -ENOENT;
80324+ }
80325+
80326 /*
80327 * create/update audit record if it already exists.
80328 */
80329- if (d_is_positive(path.dentry))
80330+ if (d_is_positive(path.dentry)) {
80331+ /* only check if O_CREAT is specified, all other checks need to go
80332+ into may_open */
80333+ if (gr_handle_fifo(path.dentry, path.mnt, dir, open_flag, acc_mode)) {
80334+ path_to_nameidata(&path, nd);
80335+ return -EACCES;
80336+ }
80337+
80338 audit_inode(nd->name, path.dentry, 0);
80339+ }
80340
80341 /*
80342 * If atomic_open() acquired write access it is dropped now due to
80343@@ -3148,6 +3286,11 @@ finish_lookup:
80344 if (unlikely(error))
80345 return error;
80346
80347+ if (gr_handle_nameidata_symlinkowner(nd, inode)) {
80348+ path_to_nameidata(&path, nd);
80349+ return -EACCES;
80350+ }
80351+
80352 if (unlikely(d_is_symlink(path.dentry)) && !(open_flag & O_PATH)) {
80353 path_to_nameidata(&path, nd);
80354 return -ELOOP;
80355@@ -3170,6 +3313,12 @@ finish_open:
80356 path_put(&save_parent);
80357 return error;
80358 }
80359+
80360+ if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
80361+ error = -ENOENT;
80362+ goto out;
80363+ }
80364+
80365 audit_inode(nd->name, nd->path.dentry, 0);
80366 error = -EISDIR;
80367 if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry))
80368@@ -3436,9 +3585,11 @@ static struct dentry *filename_create(int dfd, struct filename *name,
80369 goto unlock;
80370
80371 error = -EEXIST;
80372- if (d_is_positive(dentry))
80373+ if (d_is_positive(dentry)) {
80374+ if (!gr_acl_handle_hidden_file(dentry, path->mnt))
80375+ error = -ENOENT;
80376 goto fail;
80377-
80378+ }
80379 /*
80380 * Special case - lookup gave negative, but... we had foo/bar/
80381 * From the vfs_mknod() POV we just have a negative dentry -
80382@@ -3492,6 +3643,20 @@ inline struct dentry *user_path_create(int dfd, const char __user *pathname,
80383 }
80384 EXPORT_SYMBOL(user_path_create);
80385
80386+static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
80387+{
80388+ struct filename *tmp = getname(pathname);
80389+ struct dentry *res;
80390+ if (IS_ERR(tmp))
80391+ return ERR_CAST(tmp);
80392+ res = kern_path_create(dfd, tmp->name, path, lookup_flags);
80393+ if (IS_ERR(res))
80394+ putname(tmp);
80395+ else
80396+ *to = tmp;
80397+ return res;
80398+}
80399+
80400 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
80401 {
80402 int error = may_create(dir, dentry);
80403@@ -3555,6 +3720,17 @@ retry:
80404
80405 if (!IS_POSIXACL(path.dentry->d_inode))
80406 mode &= ~current_umask();
80407+
80408+ if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
80409+ error = -EPERM;
80410+ goto out;
80411+ }
80412+
80413+ if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
80414+ error = -EACCES;
80415+ goto out;
80416+ }
80417+
80418 error = security_path_mknod(&path, dentry, mode, dev);
80419 if (error)
80420 goto out;
80421@@ -3570,6 +3746,8 @@ retry:
80422 error = vfs_mknod(path.dentry->d_inode,dentry,mode,0);
80423 break;
80424 }
80425+ if (!error)
80426+ gr_handle_create(dentry, path.mnt);
80427 out:
80428 done_path_create(&path, dentry);
80429 if (retry_estale(error, lookup_flags)) {
80430@@ -3624,9 +3802,16 @@ retry:
80431
80432 if (!IS_POSIXACL(path.dentry->d_inode))
80433 mode &= ~current_umask();
80434+ if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
80435+ error = -EACCES;
80436+ goto out;
80437+ }
80438 error = security_path_mkdir(&path, dentry, mode);
80439 if (!error)
80440 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
80441+ if (!error)
80442+ gr_handle_create(dentry, path.mnt);
80443+out:
80444 done_path_create(&path, dentry);
80445 if (retry_estale(error, lookup_flags)) {
80446 lookup_flags |= LOOKUP_REVAL;
80447@@ -3659,7 +3844,7 @@ void dentry_unhash(struct dentry *dentry)
80448 {
80449 shrink_dcache_parent(dentry);
80450 spin_lock(&dentry->d_lock);
80451- if (dentry->d_lockref.count == 1)
80452+ if (__lockref_read(&dentry->d_lockref) == 1)
80453 __d_drop(dentry);
80454 spin_unlock(&dentry->d_lock);
80455 }
80456@@ -3712,6 +3897,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
80457 struct path path;
80458 struct qstr last;
80459 int type;
80460+ u64 saved_ino = 0;
80461+ dev_t saved_dev = 0;
80462 unsigned int lookup_flags = 0;
80463 retry:
80464 name = user_path_parent(dfd, pathname,
80465@@ -3744,10 +3931,20 @@ retry:
80466 error = -ENOENT;
80467 goto exit3;
80468 }
80469+ saved_ino = gr_get_ino_from_dentry(dentry);
80470+ saved_dev = gr_get_dev_from_dentry(dentry);
80471+
80472+ if (!gr_acl_handle_rmdir(dentry, path.mnt)) {
80473+ error = -EACCES;
80474+ goto exit3;
80475+ }
80476+
80477 error = security_path_rmdir(&path, dentry);
80478 if (error)
80479 goto exit3;
80480 error = vfs_rmdir(path.dentry->d_inode, dentry);
80481+ if (!error && (saved_dev || saved_ino))
80482+ gr_handle_delete(saved_ino, saved_dev);
80483 exit3:
80484 dput(dentry);
80485 exit2:
80486@@ -3842,6 +4039,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
80487 int type;
80488 struct inode *inode = NULL;
80489 struct inode *delegated_inode = NULL;
80490+ u64 saved_ino = 0;
80491+ dev_t saved_dev = 0;
80492 unsigned int lookup_flags = 0;
80493 retry:
80494 name = user_path_parent(dfd, pathname,
80495@@ -3868,10 +4067,21 @@ retry_deleg:
80496 if (d_is_negative(dentry))
80497 goto slashes;
80498 ihold(inode);
80499+ if (inode->i_nlink <= 1) {
80500+ saved_ino = gr_get_ino_from_dentry(dentry);
80501+ saved_dev = gr_get_dev_from_dentry(dentry);
80502+ }
80503+ if (!gr_acl_handle_unlink(dentry, path.mnt)) {
80504+ error = -EACCES;
80505+ goto exit2;
80506+ }
80507+
80508 error = security_path_unlink(&path, dentry);
80509 if (error)
80510 goto exit2;
80511 error = vfs_unlink(path.dentry->d_inode, dentry, &delegated_inode);
80512+ if (!error && (saved_ino || saved_dev))
80513+ gr_handle_delete(saved_ino, saved_dev);
80514 exit2:
80515 dput(dentry);
80516 }
80517@@ -3960,9 +4170,17 @@ retry:
80518 if (IS_ERR(dentry))
80519 goto out_putname;
80520
80521+ if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
80522+ error = -EACCES;
80523+ goto out;
80524+ }
80525+
80526 error = security_path_symlink(&path, dentry, from->name);
80527 if (!error)
80528 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
80529+ if (!error)
80530+ gr_handle_create(dentry, path.mnt);
80531+out:
80532 done_path_create(&path, dentry);
80533 if (retry_estale(error, lookup_flags)) {
80534 lookup_flags |= LOOKUP_REVAL;
80535@@ -4066,6 +4284,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
80536 struct dentry *new_dentry;
80537 struct path old_path, new_path;
80538 struct inode *delegated_inode = NULL;
80539+ struct filename *to = NULL;
80540 int how = 0;
80541 int error;
80542
80543@@ -4089,7 +4308,7 @@ retry:
80544 if (error)
80545 return error;
80546
80547- new_dentry = user_path_create(newdfd, newname, &new_path,
80548+ new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
80549 (how & LOOKUP_REVAL));
80550 error = PTR_ERR(new_dentry);
80551 if (IS_ERR(new_dentry))
80552@@ -4101,11 +4320,26 @@ retry:
80553 error = may_linkat(&old_path);
80554 if (unlikely(error))
80555 goto out_dput;
80556+
80557+ if (gr_handle_hardlink(old_path.dentry, old_path.mnt, to)) {
80558+ error = -EACCES;
80559+ goto out_dput;
80560+ }
80561+
80562+ if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
80563+ old_path.dentry, old_path.mnt, to)) {
80564+ error = -EACCES;
80565+ goto out_dput;
80566+ }
80567+
80568 error = security_path_link(old_path.dentry, &new_path, new_dentry);
80569 if (error)
80570 goto out_dput;
80571 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry, &delegated_inode);
80572+ if (!error)
80573+ gr_handle_create(new_dentry, new_path.mnt);
80574 out_dput:
80575+ putname(to);
80576 done_path_create(&new_path, new_dentry);
80577 if (delegated_inode) {
80578 error = break_deleg_wait(&delegated_inode);
80579@@ -4420,6 +4654,20 @@ retry_deleg:
80580 if (new_dentry == trap)
80581 goto exit5;
80582
80583+ if (gr_bad_chroot_rename(old_dentry, old_path.mnt, new_dentry, new_path.mnt)) {
80584+ /* use EXDEV error to cause 'mv' to switch to an alternative
80585+ * method for usability
80586+ */
80587+ error = -EXDEV;
80588+ goto exit5;
80589+ }
80590+
80591+ error = gr_acl_handle_rename(new_dentry, new_path.dentry, new_path.mnt,
80592+ old_dentry, d_backing_inode(old_path.dentry), old_path.mnt,
80593+ to, flags);
80594+ if (error)
80595+ goto exit5;
80596+
80597 error = security_path_rename(&old_path, old_dentry,
80598 &new_path, new_dentry, flags);
80599 if (error)
80600@@ -4427,6 +4675,9 @@ retry_deleg:
80601 error = vfs_rename(old_path.dentry->d_inode, old_dentry,
80602 new_path.dentry->d_inode, new_dentry,
80603 &delegated_inode, flags);
80604+ if (!error)
80605+ gr_handle_rename(d_backing_inode(old_path.dentry), d_backing_inode(new_path.dentry), old_dentry,
80606+ new_dentry, old_path.mnt, d_is_positive(new_dentry) ? 1 : 0, flags);
80607 exit5:
80608 dput(new_dentry);
80609 exit4:
80610@@ -4483,14 +4734,24 @@ EXPORT_SYMBOL(vfs_whiteout);
80611
80612 int readlink_copy(char __user *buffer, int buflen, const char *link)
80613 {
80614+ char tmpbuf[64];
80615+ const char *newlink;
80616 int len = PTR_ERR(link);
80617+
80618 if (IS_ERR(link))
80619 goto out;
80620
80621 len = strlen(link);
80622 if (len > (unsigned) buflen)
80623 len = buflen;
80624- if (copy_to_user(buffer, link, len))
80625+
80626+ if (len < sizeof(tmpbuf)) {
80627+ memcpy(tmpbuf, link, len);
80628+ newlink = tmpbuf;
80629+ } else
80630+ newlink = link;
80631+
80632+ if (copy_to_user(buffer, newlink, len))
80633 len = -EFAULT;
80634 out:
80635 return len;
80636diff --git a/fs/namespace.c b/fs/namespace.c
80637index 2b8aa15..3230081 100644
80638--- a/fs/namespace.c
80639+++ b/fs/namespace.c
80640@@ -1516,6 +1516,9 @@ static int do_umount(struct mount *mnt, int flags)
80641 if (!(sb->s_flags & MS_RDONLY))
80642 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
80643 up_write(&sb->s_umount);
80644+
80645+ gr_log_remount(mnt->mnt_devname, retval);
80646+
80647 return retval;
80648 }
80649
80650@@ -1538,6 +1541,9 @@ static int do_umount(struct mount *mnt, int flags)
80651 }
80652 unlock_mount_hash();
80653 namespace_unlock();
80654+
80655+ gr_log_unmount(mnt->mnt_devname, retval);
80656+
80657 return retval;
80658 }
80659
80660@@ -1592,7 +1598,7 @@ static inline bool may_mount(void)
80661 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
80662 */
80663
80664-SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
80665+SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
80666 {
80667 struct path path;
80668 struct mount *mnt;
80669@@ -1637,7 +1643,7 @@ out:
80670 /*
80671 * The 2.0 compatible umount. No flags.
80672 */
80673-SYSCALL_DEFINE1(oldumount, char __user *, name)
80674+SYSCALL_DEFINE1(oldumount, const char __user *, name)
80675 {
80676 return sys_umount(name, 0);
80677 }
80678@@ -2712,6 +2718,16 @@ long do_mount(const char *dev_name, const char __user *dir_name,
80679 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
80680 MS_STRICTATIME);
80681
80682+ if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
80683+ retval = -EPERM;
80684+ goto dput_out;
80685+ }
80686+
80687+ if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
80688+ retval = -EPERM;
80689+ goto dput_out;
80690+ }
80691+
80692 if (flags & MS_REMOUNT)
80693 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
80694 data_page);
80695@@ -2725,7 +2741,10 @@ long do_mount(const char *dev_name, const char __user *dir_name,
80696 retval = do_new_mount(&path, type_page, flags, mnt_flags,
80697 dev_name, data_page);
80698 dput_out:
80699+ gr_log_mount(dev_name, &path, retval);
80700+
80701 path_put(&path);
80702+
80703 return retval;
80704 }
80705
80706@@ -2743,7 +2762,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
80707 * number incrementing at 10Ghz will take 12,427 years to wrap which
80708 * is effectively never, so we can ignore the possibility.
80709 */
80710-static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
80711+static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
80712
80713 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
80714 {
80715@@ -2759,7 +2778,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
80716 return ERR_PTR(ret);
80717 }
80718 new_ns->ns.ops = &mntns_operations;
80719- new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
80720+ new_ns->seq = atomic64_add_return_unchecked(1, &mnt_ns_seq);
80721 atomic_set(&new_ns->count, 1);
80722 new_ns->root = NULL;
80723 INIT_LIST_HEAD(&new_ns->list);
80724@@ -2769,7 +2788,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
80725 return new_ns;
80726 }
80727
80728-struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
80729+__latent_entropy struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
80730 struct user_namespace *user_ns, struct fs_struct *new_fs)
80731 {
80732 struct mnt_namespace *new_ns;
80733@@ -2890,8 +2909,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
80734 }
80735 EXPORT_SYMBOL(mount_subtree);
80736
80737-SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
80738- char __user *, type, unsigned long, flags, void __user *, data)
80739+SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
80740+ const char __user *, type, unsigned long, flags, void __user *, data)
80741 {
80742 int ret;
80743 char *kernel_type;
80744@@ -2997,6 +3016,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
80745 if (error)
80746 goto out2;
80747
80748+ if (gr_handle_chroot_pivot()) {
80749+ error = -EPERM;
80750+ goto out2;
80751+ }
80752+
80753 get_fs_root(current->fs, &root);
80754 old_mp = lock_mount(&old);
80755 error = PTR_ERR(old_mp);
80756@@ -3298,7 +3322,7 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
80757 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
80758 return -EPERM;
80759
80760- if (fs->users != 1)
80761+ if (atomic_read(&fs->users) != 1)
80762 return -EINVAL;
80763
80764 get_mnt_ns(mnt_ns);
80765diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
80766index 6b1697a..6d5787c 100644
80767--- a/fs/nfs/callback_xdr.c
80768+++ b/fs/nfs/callback_xdr.c
80769@@ -51,7 +51,7 @@ struct callback_op {
80770 callback_decode_arg_t decode_args;
80771 callback_encode_res_t encode_res;
80772 long res_maxsize;
80773-};
80774+} __do_const;
80775
80776 static struct callback_op callback_ops[];
80777
80778diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
80779index 4afbe13..a6a26ce 100644
80780--- a/fs/nfs/inode.c
80781+++ b/fs/nfs/inode.c
80782@@ -1273,16 +1273,16 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
80783 return 0;
80784 }
80785
80786-static atomic_long_t nfs_attr_generation_counter;
80787+static atomic_long_unchecked_t nfs_attr_generation_counter;
80788
80789 static unsigned long nfs_read_attr_generation_counter(void)
80790 {
80791- return atomic_long_read(&nfs_attr_generation_counter);
80792+ return atomic_long_read_unchecked(&nfs_attr_generation_counter);
80793 }
80794
80795 unsigned long nfs_inc_attr_generation_counter(void)
80796 {
80797- return atomic_long_inc_return(&nfs_attr_generation_counter);
80798+ return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
80799 }
80800 EXPORT_SYMBOL_GPL(nfs_inc_attr_generation_counter);
80801
80802diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
80803index 90cfda7..e4b50df 100644
80804--- a/fs/nfsd/nfs4proc.c
80805+++ b/fs/nfsd/nfs4proc.c
80806@@ -1487,7 +1487,7 @@ struct nfsd4_operation {
80807 nfsd4op_rsize op_rsize_bop;
80808 stateid_getter op_get_currentstateid;
80809 stateid_setter op_set_currentstateid;
80810-};
80811+} __do_const;
80812
80813 static struct nfsd4_operation nfsd4_ops[];
80814
80815diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
80816index b81f725..8e36601 100644
80817--- a/fs/nfsd/nfs4xdr.c
80818+++ b/fs/nfsd/nfs4xdr.c
80819@@ -1704,7 +1704,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
80820
80821 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
80822
80823-static nfsd4_dec nfsd4_dec_ops[] = {
80824+static const nfsd4_dec nfsd4_dec_ops[] = {
80825 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
80826 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
80827 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
80828diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
80829index 46ec934..f384e41 100644
80830--- a/fs/nfsd/nfscache.c
80831+++ b/fs/nfsd/nfscache.c
80832@@ -541,7 +541,7 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
80833 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
80834 u32 hash;
80835 struct nfsd_drc_bucket *b;
80836- int len;
80837+ long len;
80838 size_t bufsize = 0;
80839
80840 if (!rp)
80841@@ -550,11 +550,14 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
80842 hash = nfsd_cache_hash(rp->c_xid);
80843 b = &drc_hashtbl[hash];
80844
80845- len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
80846- len >>= 2;
80847+ if (statp) {
80848+ len = (char*)statp - (char*)resv->iov_base;
80849+ len = resv->iov_len - len;
80850+ len >>= 2;
80851+ }
80852
80853 /* Don't cache excessive amounts of data and XDR failures */
80854- if (!statp || len > (256 >> 2)) {
80855+ if (!statp || len > (256 >> 2) || len < 0) {
80856 nfsd_reply_cache_free(b, rp);
80857 return;
80858 }
80859@@ -562,7 +565,7 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
80860 switch (cachetype) {
80861 case RC_REPLSTAT:
80862 if (len != 1)
80863- printk("nfsd: RC_REPLSTAT/reply len %d!\n",len);
80864+ printk("nfsd: RC_REPLSTAT/reply len %ld!\n",len);
80865 rp->c_replstat = *statp;
80866 break;
80867 case RC_REPLBUFF:
80868diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
80869index b5e077a..50cf549 100644
80870--- a/fs/nfsd/vfs.c
80871+++ b/fs/nfsd/vfs.c
80872@@ -855,7 +855,7 @@ __be32 nfsd_readv(struct file *file, loff_t offset, struct kvec *vec, int vlen,
80873
80874 oldfs = get_fs();
80875 set_fs(KERNEL_DS);
80876- host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
80877+ host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
80878 set_fs(oldfs);
80879 return nfsd_finish_read(file, count, host_err);
80880 }
80881@@ -942,7 +942,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
80882
80883 /* Write the data. */
80884 oldfs = get_fs(); set_fs(KERNEL_DS);
80885- host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
80886+ host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
80887 set_fs(oldfs);
80888 if (host_err < 0)
80889 goto out_nfserr;
80890@@ -1455,7 +1455,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
80891 */
80892
80893 oldfs = get_fs(); set_fs(KERNEL_DS);
80894- host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
80895+ host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
80896 set_fs(oldfs);
80897
80898 if (host_err < 0)
80899diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
80900index 52ccd34..7a6b202 100644
80901--- a/fs/nls/nls_base.c
80902+++ b/fs/nls/nls_base.c
80903@@ -234,21 +234,25 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
80904
80905 int __register_nls(struct nls_table *nls, struct module *owner)
80906 {
80907- struct nls_table ** tmp = &tables;
80908+ struct nls_table *tmp = tables;
80909
80910 if (nls->next)
80911 return -EBUSY;
80912
80913- nls->owner = owner;
80914+ pax_open_kernel();
80915+ *(void **)&nls->owner = owner;
80916+ pax_close_kernel();
80917 spin_lock(&nls_lock);
80918- while (*tmp) {
80919- if (nls == *tmp) {
80920+ while (tmp) {
80921+ if (nls == tmp) {
80922 spin_unlock(&nls_lock);
80923 return -EBUSY;
80924 }
80925- tmp = &(*tmp)->next;
80926+ tmp = tmp->next;
80927 }
80928- nls->next = tables;
80929+ pax_open_kernel();
80930+ *(struct nls_table **)&nls->next = tables;
80931+ pax_close_kernel();
80932 tables = nls;
80933 spin_unlock(&nls_lock);
80934 return 0;
80935@@ -257,12 +261,14 @@ EXPORT_SYMBOL(__register_nls);
80936
80937 int unregister_nls(struct nls_table * nls)
80938 {
80939- struct nls_table ** tmp = &tables;
80940+ struct nls_table * const * tmp = &tables;
80941
80942 spin_lock(&nls_lock);
80943 while (*tmp) {
80944 if (nls == *tmp) {
80945- *tmp = nls->next;
80946+ pax_open_kernel();
80947+ *(struct nls_table **)tmp = nls->next;
80948+ pax_close_kernel();
80949 spin_unlock(&nls_lock);
80950 return 0;
80951 }
80952@@ -272,7 +278,7 @@ int unregister_nls(struct nls_table * nls)
80953 return -EINVAL;
80954 }
80955
80956-static struct nls_table *find_nls(char *charset)
80957+static struct nls_table *find_nls(const char *charset)
80958 {
80959 struct nls_table *nls;
80960 spin_lock(&nls_lock);
80961@@ -288,7 +294,7 @@ static struct nls_table *find_nls(char *charset)
80962 return nls;
80963 }
80964
80965-struct nls_table *load_nls(char *charset)
80966+struct nls_table *load_nls(const char *charset)
80967 {
80968 return try_then_request_module(find_nls(charset), "nls_%s", charset);
80969 }
80970diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
80971index 162b3f1..6076a7c 100644
80972--- a/fs/nls/nls_euc-jp.c
80973+++ b/fs/nls/nls_euc-jp.c
80974@@ -560,8 +560,10 @@ static int __init init_nls_euc_jp(void)
80975 p_nls = load_nls("cp932");
80976
80977 if (p_nls) {
80978- table.charset2upper = p_nls->charset2upper;
80979- table.charset2lower = p_nls->charset2lower;
80980+ pax_open_kernel();
80981+ *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
80982+ *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
80983+ pax_close_kernel();
80984 return register_nls(&table);
80985 }
80986
80987diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
80988index a80a741..7b96e1b 100644
80989--- a/fs/nls/nls_koi8-ru.c
80990+++ b/fs/nls/nls_koi8-ru.c
80991@@ -62,8 +62,10 @@ static int __init init_nls_koi8_ru(void)
80992 p_nls = load_nls("koi8-u");
80993
80994 if (p_nls) {
80995- table.charset2upper = p_nls->charset2upper;
80996- table.charset2lower = p_nls->charset2lower;
80997+ pax_open_kernel();
80998+ *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
80999+ *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
81000+ pax_close_kernel();
81001 return register_nls(&table);
81002 }
81003
81004diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
81005index cf27550..6c70f29d 100644
81006--- a/fs/notify/fanotify/fanotify_user.c
81007+++ b/fs/notify/fanotify/fanotify_user.c
81008@@ -216,8 +216,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
81009
81010 fd = fanotify_event_metadata.fd;
81011 ret = -EFAULT;
81012- if (copy_to_user(buf, &fanotify_event_metadata,
81013- fanotify_event_metadata.event_len))
81014+ if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
81015+ copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
81016 goto out_close_fd;
81017
81018 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
81019diff --git a/fs/notify/notification.c b/fs/notify/notification.c
81020index a95d8e0..a91a5fd 100644
81021--- a/fs/notify/notification.c
81022+++ b/fs/notify/notification.c
81023@@ -48,7 +48,7 @@
81024 #include <linux/fsnotify_backend.h>
81025 #include "fsnotify.h"
81026
81027-static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
81028+static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
81029
81030 /**
81031 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
81032@@ -56,7 +56,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
81033 */
81034 u32 fsnotify_get_cookie(void)
81035 {
81036- return atomic_inc_return(&fsnotify_sync_cookie);
81037+ return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
81038 }
81039 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
81040
81041diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
81042index 9e38daf..5727cae 100644
81043--- a/fs/ntfs/dir.c
81044+++ b/fs/ntfs/dir.c
81045@@ -1310,7 +1310,7 @@ find_next_index_buffer:
81046 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
81047 ~(s64)(ndir->itype.index.block_size - 1)));
81048 /* Bounds checks. */
81049- if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
81050+ if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
81051 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
81052 "inode 0x%lx or driver bug.", vdir->i_ino);
81053 goto err_out;
81054diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
81055index 9e1e112..241a52a 100644
81056--- a/fs/ntfs/super.c
81057+++ b/fs/ntfs/super.c
81058@@ -688,7 +688,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
81059 if (!silent)
81060 ntfs_error(sb, "Primary boot sector is invalid.");
81061 } else if (!silent)
81062- ntfs_error(sb, read_err_str, "primary");
81063+ ntfs_error(sb, read_err_str, "%s", "primary");
81064 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
81065 if (bh_primary)
81066 brelse(bh_primary);
81067@@ -704,7 +704,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
81068 goto hotfix_primary_boot_sector;
81069 brelse(bh_backup);
81070 } else if (!silent)
81071- ntfs_error(sb, read_err_str, "backup");
81072+ ntfs_error(sb, read_err_str, "%s", "backup");
81073 /* Try to read NT3.51- backup boot sector. */
81074 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
81075 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
81076@@ -715,7 +715,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
81077 "sector.");
81078 brelse(bh_backup);
81079 } else if (!silent)
81080- ntfs_error(sb, read_err_str, "backup");
81081+ ntfs_error(sb, read_err_str, "%s", "backup");
81082 /* We failed. Cleanup and return. */
81083 if (bh_primary)
81084 brelse(bh_primary);
81085diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
81086index 857bbbc..3c47d15 100644
81087--- a/fs/ocfs2/localalloc.c
81088+++ b/fs/ocfs2/localalloc.c
81089@@ -1320,7 +1320,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
81090 goto bail;
81091 }
81092
81093- atomic_inc(&osb->alloc_stats.moves);
81094+ atomic_inc_unchecked(&osb->alloc_stats.moves);
81095
81096 bail:
81097 if (handle)
81098diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
81099index 690ddc6..f2d4c4d 100644
81100--- a/fs/ocfs2/ocfs2.h
81101+++ b/fs/ocfs2/ocfs2.h
81102@@ -247,11 +247,11 @@ enum ocfs2_vol_state
81103
81104 struct ocfs2_alloc_stats
81105 {
81106- atomic_t moves;
81107- atomic_t local_data;
81108- atomic_t bitmap_data;
81109- atomic_t bg_allocs;
81110- atomic_t bg_extends;
81111+ atomic_unchecked_t moves;
81112+ atomic_unchecked_t local_data;
81113+ atomic_unchecked_t bitmap_data;
81114+ atomic_unchecked_t bg_allocs;
81115+ atomic_unchecked_t bg_extends;
81116 };
81117
81118 enum ocfs2_local_alloc_state
81119diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
81120index 4479029..5de740b 100644
81121--- a/fs/ocfs2/suballoc.c
81122+++ b/fs/ocfs2/suballoc.c
81123@@ -867,7 +867,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
81124 mlog_errno(status);
81125 goto bail;
81126 }
81127- atomic_inc(&osb->alloc_stats.bg_extends);
81128+ atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
81129
81130 /* You should never ask for this much metadata */
81131 BUG_ON(bits_wanted >
81132@@ -2014,7 +2014,7 @@ int ocfs2_claim_metadata(handle_t *handle,
81133 mlog_errno(status);
81134 goto bail;
81135 }
81136- atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81137+ atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81138
81139 *suballoc_loc = res.sr_bg_blkno;
81140 *suballoc_bit_start = res.sr_bit_offset;
81141@@ -2180,7 +2180,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
81142 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
81143 res->sr_bits);
81144
81145- atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81146+ atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81147
81148 BUG_ON(res->sr_bits != 1);
81149
81150@@ -2222,7 +2222,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
81151 mlog_errno(status);
81152 goto bail;
81153 }
81154- atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81155+ atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81156
81157 BUG_ON(res.sr_bits != 1);
81158
81159@@ -2326,7 +2326,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
81160 cluster_start,
81161 num_clusters);
81162 if (!status)
81163- atomic_inc(&osb->alloc_stats.local_data);
81164+ atomic_inc_unchecked(&osb->alloc_stats.local_data);
81165 } else {
81166 if (min_clusters > (osb->bitmap_cpg - 1)) {
81167 /* The only paths asking for contiguousness
81168@@ -2352,7 +2352,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
81169 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
81170 res.sr_bg_blkno,
81171 res.sr_bit_offset);
81172- atomic_inc(&osb->alloc_stats.bitmap_data);
81173+ atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
81174 *num_clusters = res.sr_bits;
81175 }
81176 }
81177diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
81178index a482e31..81b251d 100644
81179--- a/fs/ocfs2/super.c
81180+++ b/fs/ocfs2/super.c
81181@@ -308,11 +308,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
81182 "%10s => GlobalAllocs: %d LocalAllocs: %d "
81183 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
81184 "Stats",
81185- atomic_read(&osb->alloc_stats.bitmap_data),
81186- atomic_read(&osb->alloc_stats.local_data),
81187- atomic_read(&osb->alloc_stats.bg_allocs),
81188- atomic_read(&osb->alloc_stats.moves),
81189- atomic_read(&osb->alloc_stats.bg_extends));
81190+ atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
81191+ atomic_read_unchecked(&osb->alloc_stats.local_data),
81192+ atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
81193+ atomic_read_unchecked(&osb->alloc_stats.moves),
81194+ atomic_read_unchecked(&osb->alloc_stats.bg_extends));
81195
81196 out += snprintf(buf + out, len - out,
81197 "%10s => State: %u Descriptor: %llu Size: %u bits "
81198@@ -2095,11 +2095,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
81199
81200 mutex_init(&osb->system_file_mutex);
81201
81202- atomic_set(&osb->alloc_stats.moves, 0);
81203- atomic_set(&osb->alloc_stats.local_data, 0);
81204- atomic_set(&osb->alloc_stats.bitmap_data, 0);
81205- atomic_set(&osb->alloc_stats.bg_allocs, 0);
81206- atomic_set(&osb->alloc_stats.bg_extends, 0);
81207+ atomic_set_unchecked(&osb->alloc_stats.moves, 0);
81208+ atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
81209+ atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
81210+ atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
81211+ atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
81212
81213 /* Copy the blockcheck stats from the superblock probe */
81214 osb->osb_ecc_stats = *stats;
81215diff --git a/fs/open.c b/fs/open.c
81216index e33dab2..cdbdad9 100644
81217--- a/fs/open.c
81218+++ b/fs/open.c
81219@@ -32,6 +32,8 @@
81220 #include <linux/dnotify.h>
81221 #include <linux/compat.h>
81222
81223+#define CREATE_TRACE_POINTS
81224+#include <trace/events/fs.h>
81225 #include "internal.h"
81226
81227 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
81228@@ -105,6 +107,8 @@ long vfs_truncate(struct path *path, loff_t length)
81229 error = locks_verify_truncate(inode, NULL, length);
81230 if (!error)
81231 error = security_path_truncate(path);
81232+ if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
81233+ error = -EACCES;
81234 if (!error)
81235 error = do_truncate(path->dentry, length, 0, NULL);
81236
81237@@ -189,6 +193,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
81238 error = locks_verify_truncate(inode, f.file, length);
81239 if (!error)
81240 error = security_path_truncate(&f.file->f_path);
81241+ if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
81242+ error = -EACCES;
81243 if (!error)
81244 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
81245 sb_end_write(inode->i_sb);
81246@@ -398,6 +404,9 @@ retry:
81247 if (__mnt_is_readonly(path.mnt))
81248 res = -EROFS;
81249
81250+ if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
81251+ res = -EACCES;
81252+
81253 out_path_release:
81254 path_put(&path);
81255 if (retry_estale(res, lookup_flags)) {
81256@@ -429,6 +438,8 @@ retry:
81257 if (error)
81258 goto dput_and_out;
81259
81260+ gr_log_chdir(path.dentry, path.mnt);
81261+
81262 set_fs_pwd(current->fs, &path);
81263
81264 dput_and_out:
81265@@ -458,6 +469,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
81266 goto out_putf;
81267
81268 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
81269+
81270+ if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
81271+ error = -EPERM;
81272+
81273+ if (!error)
81274+ gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
81275+
81276 if (!error)
81277 set_fs_pwd(current->fs, &f.file->f_path);
81278 out_putf:
81279@@ -487,7 +505,13 @@ retry:
81280 if (error)
81281 goto dput_and_out;
81282
81283+ if (gr_handle_chroot_chroot(path.dentry, path.mnt))
81284+ goto dput_and_out;
81285+
81286 set_fs_root(current->fs, &path);
81287+
81288+ gr_handle_chroot_chdir(&path);
81289+
81290 error = 0;
81291 dput_and_out:
81292 path_put(&path);
81293@@ -511,6 +535,16 @@ static int chmod_common(struct path *path, umode_t mode)
81294 return error;
81295 retry_deleg:
81296 mutex_lock(&inode->i_mutex);
81297+
81298+ if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
81299+ error = -EACCES;
81300+ goto out_unlock;
81301+ }
81302+ if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
81303+ error = -EACCES;
81304+ goto out_unlock;
81305+ }
81306+
81307 error = security_path_chmod(path, mode);
81308 if (error)
81309 goto out_unlock;
81310@@ -576,6 +610,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
81311 uid = make_kuid(current_user_ns(), user);
81312 gid = make_kgid(current_user_ns(), group);
81313
81314+ if (!gr_acl_handle_chown(path->dentry, path->mnt))
81315+ return -EACCES;
81316+
81317 retry_deleg:
81318 newattrs.ia_valid = ATTR_CTIME;
81319 if (user != (uid_t) -1) {
81320@@ -1029,6 +1066,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
81321 } else {
81322 fsnotify_open(f);
81323 fd_install(fd, f);
81324+ trace_do_sys_open(tmp->name, flags, mode);
81325 }
81326 }
81327 putname(tmp);
81328diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
81329index d9da5a4..7ced3c7 100644
81330--- a/fs/overlayfs/inode.c
81331+++ b/fs/overlayfs/inode.c
81332@@ -346,6 +346,9 @@ struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags)
81333 if (d_is_dir(dentry))
81334 return d_backing_inode(dentry);
81335
81336+ if (d_is_dir(dentry))
81337+ return d_backing_inode(dentry);
81338+
81339 type = ovl_path_real(dentry, &realpath);
81340 if (ovl_open_need_copy_up(file_flags, type, realpath.dentry)) {
81341 err = ovl_want_write(dentry);
81342diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
81343index 79073d6..0eb5c27 100644
81344--- a/fs/overlayfs/super.c
81345+++ b/fs/overlayfs/super.c
81346@@ -172,7 +172,7 @@ void ovl_path_lower(struct dentry *dentry, struct path *path)
81347 {
81348 struct ovl_entry *oe = dentry->d_fsdata;
81349
81350- *path = oe->numlower ? oe->lowerstack[0] : (struct path) { NULL, NULL };
81351+ *path = oe->numlower ? oe->lowerstack[0] : (struct path) { .dentry = NULL, .mnt = NULL };
81352 }
81353
81354 int ovl_want_write(struct dentry *dentry)
81355@@ -879,8 +879,8 @@ static unsigned int ovl_split_lowerdirs(char *str)
81356
81357 static int ovl_fill_super(struct super_block *sb, void *data, int silent)
81358 {
81359- struct path upperpath = { NULL, NULL };
81360- struct path workpath = { NULL, NULL };
81361+ struct path upperpath = { .dentry = NULL, .mnt = NULL };
81362+ struct path workpath = { .dentry = NULL, .mnt = NULL };
81363 struct dentry *root_dentry;
81364 struct ovl_entry *oe;
81365 struct ovl_fs *ufs;
81366diff --git a/fs/pipe.c b/fs/pipe.c
81367index 8865f79..bd2c79b 100644
81368--- a/fs/pipe.c
81369+++ b/fs/pipe.c
81370@@ -36,7 +36,7 @@ unsigned int pipe_max_size = 1048576;
81371 /*
81372 * Minimum pipe size, as required by POSIX
81373 */
81374-unsigned int pipe_min_size = PAGE_SIZE;
81375+unsigned int pipe_min_size __read_only = PAGE_SIZE;
81376
81377 /*
81378 * We use a start+len construction, which provides full use of the
81379@@ -55,7 +55,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
81380
81381 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
81382 {
81383- if (pipe->files)
81384+ if (atomic_read(&pipe->files))
81385 mutex_lock_nested(&pipe->mutex, subclass);
81386 }
81387
81388@@ -70,7 +70,7 @@ EXPORT_SYMBOL(pipe_lock);
81389
81390 void pipe_unlock(struct pipe_inode_info *pipe)
81391 {
81392- if (pipe->files)
81393+ if (atomic_read(&pipe->files))
81394 mutex_unlock(&pipe->mutex);
81395 }
81396 EXPORT_SYMBOL(pipe_unlock);
81397@@ -291,9 +291,9 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)
81398 }
81399 if (bufs) /* More to do? */
81400 continue;
81401- if (!pipe->writers)
81402+ if (!atomic_read(&pipe->writers))
81403 break;
81404- if (!pipe->waiting_writers) {
81405+ if (!atomic_read(&pipe->waiting_writers)) {
81406 /* syscall merging: Usually we must not sleep
81407 * if O_NONBLOCK is set, or if we got some data.
81408 * But if a writer sleeps in kernel space, then
81409@@ -350,7 +350,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
81410
81411 __pipe_lock(pipe);
81412
81413- if (!pipe->readers) {
81414+ if (!atomic_read(&pipe->readers)) {
81415 send_sig(SIGPIPE, current, 0);
81416 ret = -EPIPE;
81417 goto out;
81418@@ -386,7 +386,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
81419 for (;;) {
81420 int bufs;
81421
81422- if (!pipe->readers) {
81423+ if (!atomic_read(&pipe->readers)) {
81424 send_sig(SIGPIPE, current, 0);
81425 if (!ret)
81426 ret = -EPIPE;
81427@@ -454,9 +454,9 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
81428 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
81429 do_wakeup = 0;
81430 }
81431- pipe->waiting_writers++;
81432+ atomic_inc(&pipe->waiting_writers);
81433 pipe_wait(pipe);
81434- pipe->waiting_writers--;
81435+ atomic_dec(&pipe->waiting_writers);
81436 }
81437 out:
81438 __pipe_unlock(pipe);
81439@@ -511,7 +511,7 @@ pipe_poll(struct file *filp, poll_table *wait)
81440 mask = 0;
81441 if (filp->f_mode & FMODE_READ) {
81442 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
81443- if (!pipe->writers && filp->f_version != pipe->w_counter)
81444+ if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
81445 mask |= POLLHUP;
81446 }
81447
81448@@ -521,7 +521,7 @@ pipe_poll(struct file *filp, poll_table *wait)
81449 * Most Unices do not set POLLERR for FIFOs but on Linux they
81450 * behave exactly like pipes for poll().
81451 */
81452- if (!pipe->readers)
81453+ if (!atomic_read(&pipe->readers))
81454 mask |= POLLERR;
81455 }
81456
81457@@ -533,7 +533,7 @@ static void put_pipe_info(struct inode *inode, struct pipe_inode_info *pipe)
81458 int kill = 0;
81459
81460 spin_lock(&inode->i_lock);
81461- if (!--pipe->files) {
81462+ if (atomic_dec_and_test(&pipe->files)) {
81463 inode->i_pipe = NULL;
81464 kill = 1;
81465 }
81466@@ -550,11 +550,11 @@ pipe_release(struct inode *inode, struct file *file)
81467
81468 __pipe_lock(pipe);
81469 if (file->f_mode & FMODE_READ)
81470- pipe->readers--;
81471+ atomic_dec(&pipe->readers);
81472 if (file->f_mode & FMODE_WRITE)
81473- pipe->writers--;
81474+ atomic_dec(&pipe->writers);
81475
81476- if (pipe->readers || pipe->writers) {
81477+ if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
81478 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
81479 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
81480 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
81481@@ -619,7 +619,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
81482 kfree(pipe);
81483 }
81484
81485-static struct vfsmount *pipe_mnt __read_mostly;
81486+struct vfsmount *pipe_mnt __read_mostly;
81487
81488 /*
81489 * pipefs_dname() is called from d_path().
81490@@ -649,8 +649,9 @@ static struct inode * get_pipe_inode(void)
81491 goto fail_iput;
81492
81493 inode->i_pipe = pipe;
81494- pipe->files = 2;
81495- pipe->readers = pipe->writers = 1;
81496+ atomic_set(&pipe->files, 2);
81497+ atomic_set(&pipe->readers, 1);
81498+ atomic_set(&pipe->writers, 1);
81499 inode->i_fop = &pipefifo_fops;
81500
81501 /*
81502@@ -829,17 +830,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
81503 spin_lock(&inode->i_lock);
81504 if (inode->i_pipe) {
81505 pipe = inode->i_pipe;
81506- pipe->files++;
81507+ atomic_inc(&pipe->files);
81508 spin_unlock(&inode->i_lock);
81509 } else {
81510 spin_unlock(&inode->i_lock);
81511 pipe = alloc_pipe_info();
81512 if (!pipe)
81513 return -ENOMEM;
81514- pipe->files = 1;
81515+ atomic_set(&pipe->files, 1);
81516 spin_lock(&inode->i_lock);
81517 if (unlikely(inode->i_pipe)) {
81518- inode->i_pipe->files++;
81519+ atomic_inc(&inode->i_pipe->files);
81520 spin_unlock(&inode->i_lock);
81521 free_pipe_info(pipe);
81522 pipe = inode->i_pipe;
81523@@ -864,10 +865,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
81524 * opened, even when there is no process writing the FIFO.
81525 */
81526 pipe->r_counter++;
81527- if (pipe->readers++ == 0)
81528+ if (atomic_inc_return(&pipe->readers) == 1)
81529 wake_up_partner(pipe);
81530
81531- if (!is_pipe && !pipe->writers) {
81532+ if (!is_pipe && !atomic_read(&pipe->writers)) {
81533 if ((filp->f_flags & O_NONBLOCK)) {
81534 /* suppress POLLHUP until we have
81535 * seen a writer */
81536@@ -886,14 +887,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
81537 * errno=ENXIO when there is no process reading the FIFO.
81538 */
81539 ret = -ENXIO;
81540- if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
81541+ if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
81542 goto err;
81543
81544 pipe->w_counter++;
81545- if (!pipe->writers++)
81546+ if (atomic_inc_return(&pipe->writers) == 1)
81547 wake_up_partner(pipe);
81548
81549- if (!is_pipe && !pipe->readers) {
81550+ if (!is_pipe && !atomic_read(&pipe->readers)) {
81551 if (wait_for_partner(pipe, &pipe->r_counter))
81552 goto err_wr;
81553 }
81554@@ -907,11 +908,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
81555 * the process can at least talk to itself.
81556 */
81557
81558- pipe->readers++;
81559- pipe->writers++;
81560+ atomic_inc(&pipe->readers);
81561+ atomic_inc(&pipe->writers);
81562 pipe->r_counter++;
81563 pipe->w_counter++;
81564- if (pipe->readers == 1 || pipe->writers == 1)
81565+ if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
81566 wake_up_partner(pipe);
81567 break;
81568
81569@@ -925,13 +926,13 @@ static int fifo_open(struct inode *inode, struct file *filp)
81570 return 0;
81571
81572 err_rd:
81573- if (!--pipe->readers)
81574+ if (atomic_dec_and_test(&pipe->readers))
81575 wake_up_interruptible(&pipe->wait);
81576 ret = -ERESTARTSYS;
81577 goto err;
81578
81579 err_wr:
81580- if (!--pipe->writers)
81581+ if (atomic_dec_and_test(&pipe->writers))
81582 wake_up_interruptible(&pipe->wait);
81583 ret = -ERESTARTSYS;
81584 goto err;
81585@@ -1007,7 +1008,7 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long nr_pages)
81586 * Currently we rely on the pipe array holding a power-of-2 number
81587 * of pages.
81588 */
81589-static inline unsigned int round_pipe_size(unsigned int size)
81590+static inline unsigned long round_pipe_size(unsigned long size)
81591 {
81592 unsigned long nr_pages;
81593
81594@@ -1055,13 +1056,16 @@ long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
81595
81596 switch (cmd) {
81597 case F_SETPIPE_SZ: {
81598- unsigned int size, nr_pages;
81599+ unsigned long size, nr_pages;
81600+
81601+ ret = -EINVAL;
81602+ if (arg < pipe_min_size)
81603+ goto out;
81604
81605 size = round_pipe_size(arg);
81606 nr_pages = size >> PAGE_SHIFT;
81607
81608- ret = -EINVAL;
81609- if (!nr_pages)
81610+ if (size < pipe_min_size)
81611 goto out;
81612
81613 if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) {
81614diff --git a/fs/posix_acl.c b/fs/posix_acl.c
81615index 4fb17de..13d8c0f 100644
81616--- a/fs/posix_acl.c
81617+++ b/fs/posix_acl.c
81618@@ -20,6 +20,7 @@
81619 #include <linux/xattr.h>
81620 #include <linux/export.h>
81621 #include <linux/user_namespace.h>
81622+#include <linux/grsecurity.h>
81623
81624 struct posix_acl **acl_by_type(struct inode *inode, int type)
81625 {
81626@@ -277,7 +278,7 @@ posix_acl_equiv_mode(const struct posix_acl *acl, umode_t *mode_p)
81627 }
81628 }
81629 if (mode_p)
81630- *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
81631+ *mode_p = ((*mode_p & ~S_IRWXUGO) | mode) & ~gr_acl_umask();
81632 return not_equiv;
81633 }
81634 EXPORT_SYMBOL(posix_acl_equiv_mode);
81635@@ -427,7 +428,7 @@ static int posix_acl_create_masq(struct posix_acl *acl, umode_t *mode_p)
81636 mode &= (group_obj->e_perm << 3) | ~S_IRWXG;
81637 }
81638
81639- *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
81640+ *mode_p = ((*mode_p & ~S_IRWXUGO) | mode) & ~gr_acl_umask();
81641 return not_equiv;
81642 }
81643
81644@@ -485,6 +486,8 @@ __posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p)
81645 struct posix_acl *clone = posix_acl_clone(*acl, gfp);
81646 int err = -ENOMEM;
81647 if (clone) {
81648+ *mode_p &= ~gr_acl_umask();
81649+
81650 err = posix_acl_create_masq(clone, mode_p);
81651 if (err < 0) {
81652 posix_acl_release(clone);
81653@@ -657,11 +660,12 @@ struct posix_acl *
81654 posix_acl_from_xattr(struct user_namespace *user_ns,
81655 const void *value, size_t size)
81656 {
81657- posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
81658- posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
81659+ const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
81660+ const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
81661 int count;
81662 struct posix_acl *acl;
81663 struct posix_acl_entry *acl_e;
81664+ umode_t umask = gr_acl_umask();
81665
81666 if (!value)
81667 return NULL;
81668@@ -687,12 +691,18 @@ posix_acl_from_xattr(struct user_namespace *user_ns,
81669
81670 switch(acl_e->e_tag) {
81671 case ACL_USER_OBJ:
81672+ acl_e->e_perm &= ~((umask & S_IRWXU) >> 6);
81673+ break;
81674 case ACL_GROUP_OBJ:
81675 case ACL_MASK:
81676+ acl_e->e_perm &= ~((umask & S_IRWXG) >> 3);
81677+ break;
81678 case ACL_OTHER:
81679+ acl_e->e_perm &= ~(umask & S_IRWXO);
81680 break;
81681
81682 case ACL_USER:
81683+ acl_e->e_perm &= ~((umask & S_IRWXU) >> 6);
81684 acl_e->e_uid =
81685 make_kuid(user_ns,
81686 le32_to_cpu(entry->e_id));
81687@@ -700,6 +710,7 @@ posix_acl_from_xattr(struct user_namespace *user_ns,
81688 goto fail;
81689 break;
81690 case ACL_GROUP:
81691+ acl_e->e_perm &= ~((umask & S_IRWXG) >> 3);
81692 acl_e->e_gid =
81693 make_kgid(user_ns,
81694 le32_to_cpu(entry->e_id));
81695diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
81696index 1ade120..a86f1a2 100644
81697--- a/fs/proc/Kconfig
81698+++ b/fs/proc/Kconfig
81699@@ -30,7 +30,7 @@ config PROC_FS
81700
81701 config PROC_KCORE
81702 bool "/proc/kcore support" if !ARM
81703- depends on PROC_FS && MMU
81704+ depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
81705 help
81706 Provides a virtual ELF core file of the live kernel. This can
81707 be read with gdb and other ELF tools. No modifications can be
81708@@ -38,8 +38,8 @@ config PROC_KCORE
81709
81710 config PROC_VMCORE
81711 bool "/proc/vmcore support"
81712- depends on PROC_FS && CRASH_DUMP
81713- default y
81714+ depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
81715+ default n
81716 help
81717 Exports the dump image of crashed kernel in ELF format.
81718
81719@@ -63,8 +63,8 @@ config PROC_SYSCTL
81720 limited in memory.
81721
81722 config PROC_PAGE_MONITOR
81723- default y
81724- depends on PROC_FS && MMU
81725+ default n
81726+ depends on PROC_FS && MMU && !GRKERNSEC
81727 bool "Enable /proc page monitoring" if EXPERT
81728 help
81729 Various /proc files exist to monitor process memory utilization:
81730diff --git a/fs/proc/array.c b/fs/proc/array.c
81731index ce065cf..8974fed 100644
81732--- a/fs/proc/array.c
81733+++ b/fs/proc/array.c
81734@@ -60,6 +60,7 @@
81735 #include <linux/tty.h>
81736 #include <linux/string.h>
81737 #include <linux/mman.h>
81738+#include <linux/grsecurity.h>
81739 #include <linux/proc_fs.h>
81740 #include <linux/ioport.h>
81741 #include <linux/uaccess.h>
81742@@ -348,6 +349,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
81743 cpumask_pr_args(&task->cpus_allowed));
81744 }
81745
81746+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
81747+static inline void task_pax(struct seq_file *m, struct task_struct *p)
81748+{
81749+ if (p->mm)
81750+ seq_printf(m, "PaX:\t%c%c%c%c%c\n",
81751+ p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
81752+ p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
81753+ p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
81754+ p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
81755+ p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
81756+ else
81757+ seq_printf(m, "PaX:\t-----\n");
81758+}
81759+#endif
81760+
81761 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
81762 struct pid *pid, struct task_struct *task)
81763 {
81764@@ -366,9 +382,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
81765 task_cpus_allowed(m, task);
81766 cpuset_task_status_allowed(m, task);
81767 task_context_switch_counts(m, task);
81768+
81769+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
81770+ task_pax(m, task);
81771+#endif
81772+
81773+#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
81774+ task_grsec_rbac(m, task);
81775+#endif
81776+
81777 return 0;
81778 }
81779
81780+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81781+#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
81782+ (_mm->pax_flags & MF_PAX_RANDMMAP || \
81783+ _mm->pax_flags & MF_PAX_SEGMEXEC))
81784+#endif
81785+
81786 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
81787 struct pid *pid, struct task_struct *task, int whole)
81788 {
81789@@ -390,6 +421,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
81790 char tcomm[sizeof(task->comm)];
81791 unsigned long flags;
81792
81793+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81794+ if (current->exec_id != m->exec_id) {
81795+ gr_log_badprocpid("stat");
81796+ return 0;
81797+ }
81798+#endif
81799+
81800 state = *get_task_state(task);
81801 vsize = eip = esp = 0;
81802 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
81803@@ -460,6 +498,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
81804 gtime = task_gtime(task);
81805 }
81806
81807+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81808+ if (PAX_RAND_FLAGS(mm)) {
81809+ eip = 0;
81810+ esp = 0;
81811+ wchan = 0;
81812+ }
81813+#endif
81814+#ifdef CONFIG_GRKERNSEC_HIDESYM
81815+ wchan = 0;
81816+ eip =0;
81817+ esp =0;
81818+#endif
81819+
81820 /* scale priority and nice values from timeslices to -20..20 */
81821 /* to make it look like a "normal" Unix priority/nice value */
81822 priority = task_prio(task);
81823@@ -491,9 +542,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
81824 seq_put_decimal_ull(m, ' ', vsize);
81825 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
81826 seq_put_decimal_ull(m, ' ', rsslim);
81827+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81828+ seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
81829+ seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
81830+ seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
81831+#else
81832 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
81833 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
81834 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
81835+#endif
81836 seq_put_decimal_ull(m, ' ', esp);
81837 seq_put_decimal_ull(m, ' ', eip);
81838 /* The signal information here is obsolete.
81839@@ -515,7 +572,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
81840 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
81841 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
81842
81843- if (mm && permitted) {
81844+ if (mm && permitted
81845+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81846+ && !PAX_RAND_FLAGS(mm)
81847+#endif
81848+ ) {
81849 seq_put_decimal_ull(m, ' ', mm->start_data);
81850 seq_put_decimal_ull(m, ' ', mm->end_data);
81851 seq_put_decimal_ull(m, ' ', mm->start_brk);
81852@@ -553,8 +614,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
81853 struct pid *pid, struct task_struct *task)
81854 {
81855 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
81856- struct mm_struct *mm = get_task_mm(task);
81857+ struct mm_struct *mm;
81858
81859+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81860+ if (current->exec_id != m->exec_id) {
81861+ gr_log_badprocpid("statm");
81862+ return 0;
81863+ }
81864+#endif
81865+ mm = get_task_mm(task);
81866 if (mm) {
81867 size = task_statm(mm, &shared, &text, &data, &resident);
81868 mmput(mm);
81869@@ -577,6 +645,20 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
81870 return 0;
81871 }
81872
81873+#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
81874+int proc_pid_ipaddr(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task)
81875+{
81876+ unsigned long flags;
81877+ u32 curr_ip = 0;
81878+
81879+ if (lock_task_sighand(task, &flags)) {
81880+ curr_ip = task->signal->curr_ip;
81881+ unlock_task_sighand(task, &flags);
81882+ }
81883+ return seq_printf(m, "%pI4\n", &curr_ip);
81884+}
81885+#endif
81886+
81887 #ifdef CONFIG_PROC_CHILDREN
81888 static struct pid *
81889 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
81890diff --git a/fs/proc/base.c b/fs/proc/base.c
81891index aa50d1a..7a62b7a 100644
81892--- a/fs/proc/base.c
81893+++ b/fs/proc/base.c
81894@@ -113,6 +113,14 @@ struct pid_entry {
81895 union proc_op op;
81896 };
81897
81898+struct getdents_callback {
81899+ struct linux_dirent __user * current_dir;
81900+ struct linux_dirent __user * previous;
81901+ struct file * file;
81902+ int count;
81903+ int error;
81904+};
81905+
81906 #define NOD(NAME, MODE, IOP, FOP, OP) { \
81907 .name = (NAME), \
81908 .len = sizeof(NAME) - 1, \
81909@@ -224,6 +232,11 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
81910 goto out_mmput;
81911 }
81912
81913+ if (gr_acl_handle_procpidmem(tsk)) {
81914+ rv = 0;
81915+ goto out_mmput;
81916+ }
81917+
81918 page = (char *)__get_free_page(GFP_TEMPORARY);
81919 if (!page) {
81920 rv = -ENOMEM;
81921@@ -400,12 +413,28 @@ static const struct file_operations proc_pid_cmdline_ops = {
81922 .llseek = generic_file_llseek,
81923 };
81924
81925+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81926+#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
81927+ (_mm->pax_flags & MF_PAX_RANDMMAP || \
81928+ _mm->pax_flags & MF_PAX_SEGMEXEC))
81929+#endif
81930+
81931 static int proc_pid_auxv(struct seq_file *m, struct pid_namespace *ns,
81932 struct pid *pid, struct task_struct *task)
81933 {
81934 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
81935 if (mm && !IS_ERR(mm)) {
81936 unsigned int nwords = 0;
81937+
81938+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81939+ /* allow if we're currently ptracing this task */
81940+ if (PAX_RAND_FLAGS(mm) &&
81941+ (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
81942+ mmput(mm);
81943+ return 0;
81944+ }
81945+#endif
81946+
81947 do {
81948 nwords += 2;
81949 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
81950@@ -417,7 +446,7 @@ static int proc_pid_auxv(struct seq_file *m, struct pid_namespace *ns,
81951 }
81952
81953
81954-#ifdef CONFIG_KALLSYMS
81955+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81956 /*
81957 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
81958 * Returns the resolved symbol. If that fails, simply return the address.
81959@@ -459,7 +488,7 @@ static void unlock_trace(struct task_struct *task)
81960 mutex_unlock(&task->signal->cred_guard_mutex);
81961 }
81962
81963-#ifdef CONFIG_STACKTRACE
81964+#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81965
81966 #define MAX_STACK_TRACE_DEPTH 64
81967
81968@@ -657,7 +686,7 @@ static int proc_pid_limits(struct seq_file *m, struct pid_namespace *ns,
81969 return 0;
81970 }
81971
81972-#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
81973+#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
81974 static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
81975 struct pid *pid, struct task_struct *task)
81976 {
81977@@ -690,7 +719,7 @@ static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
81978 /************************************************************************/
81979
81980 /* permission checks */
81981-static int proc_fd_access_allowed(struct inode *inode)
81982+static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
81983 {
81984 struct task_struct *task;
81985 int allowed = 0;
81986@@ -700,7 +729,10 @@ static int proc_fd_access_allowed(struct inode *inode)
81987 */
81988 task = get_proc_task(inode);
81989 if (task) {
81990- allowed = ptrace_may_access(task, PTRACE_MODE_READ);
81991+ if (log)
81992+ allowed = ptrace_may_access(task, PTRACE_MODE_READ);
81993+ else
81994+ allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
81995 put_task_struct(task);
81996 }
81997 return allowed;
81998@@ -731,10 +763,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
81999 struct task_struct *task,
82000 int hide_pid_min)
82001 {
82002+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
82003+ return false;
82004+
82005+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82006+ rcu_read_lock();
82007+ {
82008+ const struct cred *tmpcred = current_cred();
82009+ const struct cred *cred = __task_cred(task);
82010+
82011+ if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
82012+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82013+ || in_group_p(grsec_proc_gid)
82014+#endif
82015+ ) {
82016+ rcu_read_unlock();
82017+ return true;
82018+ }
82019+ }
82020+ rcu_read_unlock();
82021+
82022+ if (!pid->hide_pid)
82023+ return false;
82024+#endif
82025+
82026 if (pid->hide_pid < hide_pid_min)
82027 return true;
82028 if (in_group_p(pid->pid_gid))
82029 return true;
82030+
82031 return ptrace_may_access(task, PTRACE_MODE_READ);
82032 }
82033
82034@@ -752,7 +809,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
82035 put_task_struct(task);
82036
82037 if (!has_perms) {
82038+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82039+ {
82040+#else
82041 if (pid->hide_pid == 2) {
82042+#endif
82043 /*
82044 * Let's make getdents(), stat(), and open()
82045 * consistent with each other. If a process
82046@@ -813,6 +874,10 @@ struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode)
82047
82048 if (task) {
82049 mm = mm_access(task, mode);
82050+ if (!IS_ERR_OR_NULL(mm) && gr_acl_handle_procpidmem(task)) {
82051+ mmput(mm);
82052+ mm = ERR_PTR(-EPERM);
82053+ }
82054 put_task_struct(task);
82055
82056 if (!IS_ERR_OR_NULL(mm)) {
82057@@ -834,6 +899,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
82058 return PTR_ERR(mm);
82059
82060 file->private_data = mm;
82061+
82062+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82063+ file->f_version = current->exec_id;
82064+#endif
82065+
82066 return 0;
82067 }
82068
82069@@ -855,6 +925,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
82070 ssize_t copied;
82071 char *page;
82072
82073+#ifdef CONFIG_GRKERNSEC
82074+ if (write)
82075+ return -EPERM;
82076+#endif
82077+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82078+ if (file->f_version != current->exec_id) {
82079+ gr_log_badprocpid("mem");
82080+ return 0;
82081+ }
82082+#endif
82083+
82084 if (!mm)
82085 return 0;
82086
82087@@ -867,7 +948,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
82088 goto free;
82089
82090 while (count > 0) {
82091- int this_len = min_t(int, count, PAGE_SIZE);
82092+ ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
82093
82094 if (write && copy_from_user(page, buf, this_len)) {
82095 copied = -EFAULT;
82096@@ -959,6 +1040,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
82097 if (!mm)
82098 return 0;
82099
82100+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82101+ if (file->f_version != current->exec_id) {
82102+ gr_log_badprocpid("environ");
82103+ return 0;
82104+ }
82105+#endif
82106+
82107 page = (char *)__get_free_page(GFP_TEMPORARY);
82108 if (!page)
82109 return -ENOMEM;
82110@@ -968,7 +1056,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
82111 goto free;
82112 while (count > 0) {
82113 size_t this_len, max_len;
82114- int retval;
82115+ ssize_t retval;
82116
82117 if (src >= (mm->env_end - mm->env_start))
82118 break;
82119@@ -1582,7 +1670,7 @@ static const char *proc_pid_follow_link(struct dentry *dentry, void **cookie)
82120 int error = -EACCES;
82121
82122 /* Are we allowed to snoop on the tasks file descriptors? */
82123- if (!proc_fd_access_allowed(inode))
82124+ if (!proc_fd_access_allowed(inode, 0))
82125 goto out;
82126
82127 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
82128@@ -1626,8 +1714,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
82129 struct path path;
82130
82131 /* Are we allowed to snoop on the tasks file descriptors? */
82132- if (!proc_fd_access_allowed(inode))
82133- goto out;
82134+ /* logging this is needed for learning on chromium to work properly,
82135+ but we don't want to flood the logs from 'ps' which does a readlink
82136+ on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
82137+ CAP_SYS_PTRACE as it's not necessary for its basic functionality
82138+ */
82139+ if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
82140+ if (!proc_fd_access_allowed(inode,0))
82141+ goto out;
82142+ } else {
82143+ if (!proc_fd_access_allowed(inode,1))
82144+ goto out;
82145+ }
82146
82147 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
82148 if (error)
82149@@ -1677,7 +1775,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
82150 rcu_read_lock();
82151 cred = __task_cred(task);
82152 inode->i_uid = cred->euid;
82153+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82154+ inode->i_gid = grsec_proc_gid;
82155+#else
82156 inode->i_gid = cred->egid;
82157+#endif
82158 rcu_read_unlock();
82159 }
82160 security_task_to_inode(task, inode);
82161@@ -1713,10 +1815,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
82162 return -ENOENT;
82163 }
82164 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
82165+#ifdef CONFIG_GRKERNSEC_PROC_USER
82166+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
82167+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82168+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
82169+#endif
82170 task_dumpable(task)) {
82171 cred = __task_cred(task);
82172 stat->uid = cred->euid;
82173+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82174+ stat->gid = grsec_proc_gid;
82175+#else
82176 stat->gid = cred->egid;
82177+#endif
82178 }
82179 }
82180 rcu_read_unlock();
82181@@ -1754,11 +1865,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
82182
82183 if (task) {
82184 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
82185+#ifdef CONFIG_GRKERNSEC_PROC_USER
82186+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
82187+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82188+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
82189+#endif
82190 task_dumpable(task)) {
82191 rcu_read_lock();
82192 cred = __task_cred(task);
82193 inode->i_uid = cred->euid;
82194+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82195+ inode->i_gid = grsec_proc_gid;
82196+#else
82197 inode->i_gid = cred->egid;
82198+#endif
82199 rcu_read_unlock();
82200 } else {
82201 inode->i_uid = GLOBAL_ROOT_UID;
82202@@ -2290,6 +2410,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
82203 if (!task)
82204 goto out_no_task;
82205
82206+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
82207+ goto out;
82208+
82209 /*
82210 * Yes, it does not scale. And it should not. Don't add
82211 * new entries into /proc/<tgid>/ without very good reasons.
82212@@ -2320,6 +2443,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
82213 if (!task)
82214 return -ENOENT;
82215
82216+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
82217+ goto out;
82218+
82219 if (!dir_emit_dots(file, ctx))
82220 goto out;
82221
82222@@ -2764,7 +2890,7 @@ static const struct pid_entry tgid_base_stuff[] = {
82223 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
82224 #endif
82225 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
82226-#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
82227+#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
82228 ONE("syscall", S_IRUSR, proc_pid_syscall),
82229 #endif
82230 REG("cmdline", S_IRUGO, proc_pid_cmdline_ops),
82231@@ -2789,10 +2915,10 @@ static const struct pid_entry tgid_base_stuff[] = {
82232 #ifdef CONFIG_SECURITY
82233 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
82234 #endif
82235-#ifdef CONFIG_KALLSYMS
82236+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82237 ONE("wchan", S_IRUGO, proc_pid_wchan),
82238 #endif
82239-#ifdef CONFIG_STACKTRACE
82240+#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82241 ONE("stack", S_IRUSR, proc_pid_stack),
82242 #endif
82243 #ifdef CONFIG_SCHED_INFO
82244@@ -2826,6 +2952,9 @@ static const struct pid_entry tgid_base_stuff[] = {
82245 #ifdef CONFIG_HARDWALL
82246 ONE("hardwall", S_IRUGO, proc_pid_hardwall),
82247 #endif
82248+#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
82249+ ONE("ipaddr", S_IRUSR, proc_pid_ipaddr),
82250+#endif
82251 #ifdef CONFIG_USER_NS
82252 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
82253 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
82254@@ -2958,7 +3087,14 @@ static int proc_pid_instantiate(struct inode *dir,
82255 if (!inode)
82256 goto out;
82257
82258+#ifdef CONFIG_GRKERNSEC_PROC_USER
82259+ inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
82260+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82261+ inode->i_gid = grsec_proc_gid;
82262+ inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
82263+#else
82264 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
82265+#endif
82266 inode->i_op = &proc_tgid_base_inode_operations;
82267 inode->i_fop = &proc_tgid_base_operations;
82268 inode->i_flags|=S_IMMUTABLE;
82269@@ -2996,7 +3132,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
82270 if (!task)
82271 goto out;
82272
82273+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
82274+ goto out_put_task;
82275+
82276 result = proc_pid_instantiate(dir, dentry, task, NULL);
82277+out_put_task:
82278 put_task_struct(task);
82279 out:
82280 return ERR_PTR(result);
82281@@ -3110,7 +3250,7 @@ static const struct pid_entry tid_base_stuff[] = {
82282 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
82283 #endif
82284 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
82285-#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
82286+#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
82287 ONE("syscall", S_IRUSR, proc_pid_syscall),
82288 #endif
82289 REG("cmdline", S_IRUGO, proc_pid_cmdline_ops),
82290@@ -3137,10 +3277,10 @@ static const struct pid_entry tid_base_stuff[] = {
82291 #ifdef CONFIG_SECURITY
82292 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
82293 #endif
82294-#ifdef CONFIG_KALLSYMS
82295+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82296 ONE("wchan", S_IRUGO, proc_pid_wchan),
82297 #endif
82298-#ifdef CONFIG_STACKTRACE
82299+#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82300 ONE("stack", S_IRUSR, proc_pid_stack),
82301 #endif
82302 #ifdef CONFIG_SCHED_INFO
82303diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
82304index cbd82df..c0407d2 100644
82305--- a/fs/proc/cmdline.c
82306+++ b/fs/proc/cmdline.c
82307@@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
82308
82309 static int __init proc_cmdline_init(void)
82310 {
82311+#ifdef CONFIG_GRKERNSEC_PROC_ADD
82312+ proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
82313+#else
82314 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
82315+#endif
82316 return 0;
82317 }
82318 fs_initcall(proc_cmdline_init);
82319diff --git a/fs/proc/devices.c b/fs/proc/devices.c
82320index 50493ed..248166b 100644
82321--- a/fs/proc/devices.c
82322+++ b/fs/proc/devices.c
82323@@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
82324
82325 static int __init proc_devices_init(void)
82326 {
82327+#ifdef CONFIG_GRKERNSEC_PROC_ADD
82328+ proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
82329+#else
82330 proc_create("devices", 0, NULL, &proc_devinfo_operations);
82331+#endif
82332 return 0;
82333 }
82334 fs_initcall(proc_devices_init);
82335diff --git a/fs/proc/fd.c b/fs/proc/fd.c
82336index 6e5fcd0..06ea074 100644
82337--- a/fs/proc/fd.c
82338+++ b/fs/proc/fd.c
82339@@ -27,7 +27,8 @@ static int seq_show(struct seq_file *m, void *v)
82340 if (!task)
82341 return -ENOENT;
82342
82343- files = get_files_struct(task);
82344+ if (!gr_acl_handle_procpidmem(task))
82345+ files = get_files_struct(task);
82346 put_task_struct(task);
82347
82348 if (files) {
82349@@ -291,11 +292,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
82350 */
82351 int proc_fd_permission(struct inode *inode, int mask)
82352 {
82353+ struct task_struct *task;
82354 int rv = generic_permission(inode, mask);
82355- if (rv == 0)
82356- return 0;
82357+
82358 if (task_tgid(current) == proc_pid(inode))
82359 rv = 0;
82360+
82361+ task = get_proc_task(inode);
82362+ if (task == NULL)
82363+ return rv;
82364+
82365+ if (gr_acl_handle_procpidmem(task))
82366+ rv = -EACCES;
82367+
82368+ put_task_struct(task);
82369+
82370 return rv;
82371 }
82372
82373diff --git a/fs/proc/generic.c b/fs/proc/generic.c
82374index e5dee5c..dafe21b 100644
82375--- a/fs/proc/generic.c
82376+++ b/fs/proc/generic.c
82377@@ -22,6 +22,7 @@
82378 #include <linux/bitops.h>
82379 #include <linux/spinlock.h>
82380 #include <linux/completion.h>
82381+#include <linux/grsecurity.h>
82382 #include <asm/uaccess.h>
82383
82384 #include "internal.h"
82385@@ -253,6 +254,15 @@ struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
82386 return proc_lookup_de(PDE(dir), dir, dentry);
82387 }
82388
82389+struct dentry *proc_lookup_restrict(struct inode *dir, struct dentry *dentry,
82390+ unsigned int flags)
82391+{
82392+ if (gr_proc_is_restricted())
82393+ return ERR_PTR(-EACCES);
82394+
82395+ return proc_lookup_de(PDE(dir), dir, dentry);
82396+}
82397+
82398 /*
82399 * This returns non-zero if at EOF, so that the /proc
82400 * root directory can use this and check if it should
82401@@ -310,6 +320,16 @@ int proc_readdir(struct file *file, struct dir_context *ctx)
82402 return proc_readdir_de(PDE(inode), file, ctx);
82403 }
82404
82405+int proc_readdir_restrict(struct file *file, struct dir_context *ctx)
82406+{
82407+ struct inode *inode = file_inode(file);
82408+
82409+ if (gr_proc_is_restricted())
82410+ return -EACCES;
82411+
82412+ return proc_readdir_de(PDE(inode), file, ctx);
82413+}
82414+
82415 /*
82416 * These are the generic /proc directory operations. They
82417 * use the in-memory "struct proc_dir_entry" tree to parse
82418@@ -321,6 +341,12 @@ static const struct file_operations proc_dir_operations = {
82419 .iterate = proc_readdir,
82420 };
82421
82422+static const struct file_operations proc_dir_restricted_operations = {
82423+ .llseek = generic_file_llseek,
82424+ .read = generic_read_dir,
82425+ .iterate = proc_readdir_restrict,
82426+};
82427+
82428 /*
82429 * proc directories can do almost nothing..
82430 */
82431@@ -330,6 +356,12 @@ static const struct inode_operations proc_dir_inode_operations = {
82432 .setattr = proc_notify_change,
82433 };
82434
82435+static const struct inode_operations proc_dir_restricted_inode_operations = {
82436+ .lookup = proc_lookup_restrict,
82437+ .getattr = proc_getattr,
82438+ .setattr = proc_notify_change,
82439+};
82440+
82441 static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp)
82442 {
82443 int ret;
82444@@ -445,6 +477,31 @@ struct proc_dir_entry *proc_mkdir_data(const char *name, umode_t mode,
82445 }
82446 EXPORT_SYMBOL_GPL(proc_mkdir_data);
82447
82448+struct proc_dir_entry *proc_mkdir_data_restrict(const char *name, umode_t mode,
82449+ struct proc_dir_entry *parent, void *data)
82450+{
82451+ struct proc_dir_entry *ent;
82452+
82453+ if (mode == 0)
82454+ mode = S_IRUGO | S_IXUGO;
82455+
82456+ ent = __proc_create(&parent, name, S_IFDIR | mode, 2);
82457+ if (ent) {
82458+ ent->data = data;
82459+ ent->restricted = 1;
82460+ ent->proc_fops = &proc_dir_restricted_operations;
82461+ ent->proc_iops = &proc_dir_restricted_inode_operations;
82462+ parent->nlink++;
82463+ if (proc_register(parent, ent) < 0) {
82464+ kfree(ent);
82465+ parent->nlink--;
82466+ ent = NULL;
82467+ }
82468+ }
82469+ return ent;
82470+}
82471+EXPORT_SYMBOL_GPL(proc_mkdir_data_restrict);
82472+
82473 struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
82474 struct proc_dir_entry *parent)
82475 {
82476@@ -459,6 +516,13 @@ struct proc_dir_entry *proc_mkdir(const char *name,
82477 }
82478 EXPORT_SYMBOL(proc_mkdir);
82479
82480+struct proc_dir_entry *proc_mkdir_restrict(const char *name,
82481+ struct proc_dir_entry *parent)
82482+{
82483+ return proc_mkdir_data_restrict(name, 0, parent, NULL);
82484+}
82485+EXPORT_SYMBOL(proc_mkdir_restrict);
82486+
82487 struct proc_dir_entry *proc_create_mount_point(const char *name)
82488 {
82489 umode_t mode = S_IFDIR | S_IRUGO | S_IXUGO;
82490diff --git a/fs/proc/inode.c b/fs/proc/inode.c
82491index bd95b9f..a64a773 100644
82492--- a/fs/proc/inode.c
82493+++ b/fs/proc/inode.c
82494@@ -23,11 +23,17 @@
82495 #include <linux/slab.h>
82496 #include <linux/mount.h>
82497 #include <linux/magic.h>
82498+#include <linux/grsecurity.h>
82499
82500 #include <asm/uaccess.h>
82501
82502 #include "internal.h"
82503
82504+#ifdef CONFIG_PROC_SYSCTL
82505+extern const struct inode_operations proc_sys_inode_operations;
82506+extern const struct inode_operations proc_sys_dir_operations;
82507+#endif
82508+
82509 static void proc_evict_inode(struct inode *inode)
82510 {
82511 struct proc_dir_entry *de;
82512@@ -48,6 +54,13 @@ static void proc_evict_inode(struct inode *inode)
82513 RCU_INIT_POINTER(PROC_I(inode)->sysctl, NULL);
82514 sysctl_head_put(head);
82515 }
82516+
82517+#ifdef CONFIG_PROC_SYSCTL
82518+ if (inode->i_op == &proc_sys_inode_operations ||
82519+ inode->i_op == &proc_sys_dir_operations)
82520+ gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
82521+#endif
82522+
82523 }
82524
82525 static struct kmem_cache * proc_inode_cachep;
82526@@ -429,7 +442,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
82527 if (de->mode) {
82528 inode->i_mode = de->mode;
82529 inode->i_uid = de->uid;
82530+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82531+ inode->i_gid = grsec_proc_gid;
82532+#else
82533 inode->i_gid = de->gid;
82534+#endif
82535 }
82536 if (de->size)
82537 inode->i_size = de->size;
82538diff --git a/fs/proc/internal.h b/fs/proc/internal.h
82539index aa27810..9f2d3b2 100644
82540--- a/fs/proc/internal.h
82541+++ b/fs/proc/internal.h
82542@@ -47,9 +47,10 @@ struct proc_dir_entry {
82543 struct completion *pde_unload_completion;
82544 struct list_head pde_openers; /* who did ->open, but not ->release */
82545 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
82546+ u8 restricted; /* a directory in /proc/net that should be restricted via GRKERNSEC_PROC */
82547 u8 namelen;
82548 char name[];
82549-};
82550+} __randomize_layout;
82551
82552 union proc_op {
82553 int (*proc_get_link)(struct dentry *, struct path *);
82554@@ -67,7 +68,7 @@ struct proc_inode {
82555 struct ctl_table *sysctl_entry;
82556 const struct proc_ns_operations *ns_ops;
82557 struct inode vfs_inode;
82558-};
82559+} __randomize_layout;
82560
82561 /*
82562 * General functions
82563@@ -155,6 +156,10 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
82564 struct pid *, struct task_struct *);
82565 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
82566 struct pid *, struct task_struct *);
82567+#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
82568+extern int proc_pid_ipaddr(struct seq_file *, struct pid_namespace *,
82569+ struct pid *, struct task_struct *);
82570+#endif
82571
82572 /*
82573 * base.c
82574@@ -179,9 +184,11 @@ extern bool proc_fill_cache(struct file *, struct dir_context *, const char *, i
82575 * generic.c
82576 */
82577 extern struct dentry *proc_lookup(struct inode *, struct dentry *, unsigned int);
82578+extern struct dentry *proc_lookup_restrict(struct inode *, struct dentry *, unsigned int);
82579 extern struct dentry *proc_lookup_de(struct proc_dir_entry *, struct inode *,
82580 struct dentry *);
82581 extern int proc_readdir(struct file *, struct dir_context *);
82582+extern int proc_readdir_restrict(struct file *, struct dir_context *);
82583 extern int proc_readdir_de(struct proc_dir_entry *, struct file *, struct dir_context *);
82584
82585 static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde)
82586diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
82587index a352d57..cb94a5c 100644
82588--- a/fs/proc/interrupts.c
82589+++ b/fs/proc/interrupts.c
82590@@ -47,7 +47,11 @@ static const struct file_operations proc_interrupts_operations = {
82591
82592 static int __init proc_interrupts_init(void)
82593 {
82594+#ifdef CONFIG_GRKERNSEC_PROC_ADD
82595+ proc_create_grsec("interrupts", 0, NULL, &proc_interrupts_operations);
82596+#else
82597 proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
82598+#endif
82599 return 0;
82600 }
82601 fs_initcall(proc_interrupts_init);
82602diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
82603index 92e6726..a600d4fa 100644
82604--- a/fs/proc/kcore.c
82605+++ b/fs/proc/kcore.c
82606@@ -483,9 +483,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
82607 * the addresses in the elf_phdr on our list.
82608 */
82609 start = kc_offset_to_vaddr(*fpos - elf_buflen);
82610- if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
82611+ tsz = PAGE_SIZE - (start & ~PAGE_MASK);
82612+ if (tsz > buflen)
82613 tsz = buflen;
82614-
82615+
82616 while (buflen) {
82617 struct kcore_list *m;
82618
82619@@ -515,19 +516,20 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
82620 } else {
82621 if (kern_addr_valid(start)) {
82622 unsigned long n;
82623+ char *elf_buf;
82624+ mm_segment_t oldfs;
82625
82626- n = copy_to_user(buffer, (char *)start, tsz);
82627- /*
82628- * We cannot distinguish between fault on source
82629- * and fault on destination. When this happens
82630- * we clear too and hope it will trigger the
82631- * EFAULT again.
82632- */
82633- if (n) {
82634- if (clear_user(buffer + tsz - n,
82635- n))
82636- return -EFAULT;
82637- }
82638+ elf_buf = kzalloc(tsz, GFP_KERNEL);
82639+ if (!elf_buf)
82640+ return -ENOMEM;
82641+ oldfs = get_fs();
82642+ set_fs(KERNEL_DS);
82643+ n = __copy_from_user(elf_buf, (const void __user *)start, tsz);
82644+ set_fs(oldfs);
82645+ n = copy_to_user(buffer, elf_buf, tsz);
82646+ kfree(elf_buf);
82647+ if (n)
82648+ return -EFAULT;
82649 } else {
82650 if (clear_user(buffer, tsz))
82651 return -EFAULT;
82652@@ -547,6 +549,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
82653
82654 static int open_kcore(struct inode *inode, struct file *filp)
82655 {
82656+#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
82657+ return -EPERM;
82658+#endif
82659 if (!capable(CAP_SYS_RAWIO))
82660 return -EPERM;
82661 if (kcore_need_update)
82662@@ -580,7 +585,7 @@ static int __meminit kcore_callback(struct notifier_block *self,
82663 return NOTIFY_OK;
82664 }
82665
82666-static struct notifier_block kcore_callback_nb __meminitdata = {
82667+static struct notifier_block kcore_callback_nb __meminitconst = {
82668 .notifier_call = kcore_callback,
82669 .priority = 0,
82670 };
82671diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
82672index d3ebf2e..6ad42d1 100644
82673--- a/fs/proc/meminfo.c
82674+++ b/fs/proc/meminfo.c
82675@@ -194,7 +194,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
82676 vmi.used >> 10,
82677 vmi.largest_chunk >> 10
82678 #ifdef CONFIG_MEMORY_FAILURE
82679- , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
82680+ , atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
82681 #endif
82682 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
82683 , K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
82684diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
82685index f8595e8..e0d13cbd 100644
82686--- a/fs/proc/nommu.c
82687+++ b/fs/proc/nommu.c
82688@@ -64,7 +64,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
82689
82690 if (file) {
82691 seq_pad(m, ' ');
82692- seq_file_path(m, file, "");
82693+ seq_file_path(m, file, "\n\\");
82694 }
82695
82696 seq_putc(m, '\n');
82697diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
82698index 350984a..0fb02a9 100644
82699--- a/fs/proc/proc_net.c
82700+++ b/fs/proc/proc_net.c
82701@@ -23,9 +23,27 @@
82702 #include <linux/nsproxy.h>
82703 #include <net/net_namespace.h>
82704 #include <linux/seq_file.h>
82705+#include <linux/grsecurity.h>
82706
82707 #include "internal.h"
82708
82709+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
82710+static struct seq_operations *ipv6_seq_ops_addr;
82711+
82712+void register_ipv6_seq_ops_addr(struct seq_operations *addr)
82713+{
82714+ ipv6_seq_ops_addr = addr;
82715+}
82716+
82717+void unregister_ipv6_seq_ops_addr(void)
82718+{
82719+ ipv6_seq_ops_addr = NULL;
82720+}
82721+
82722+EXPORT_SYMBOL_GPL(register_ipv6_seq_ops_addr);
82723+EXPORT_SYMBOL_GPL(unregister_ipv6_seq_ops_addr);
82724+#endif
82725+
82726 static inline struct net *PDE_NET(struct proc_dir_entry *pde)
82727 {
82728 return pde->parent->data;
82729@@ -36,6 +54,8 @@ static struct net *get_proc_net(const struct inode *inode)
82730 return maybe_get_net(PDE_NET(PDE(inode)));
82731 }
82732
82733+extern const struct seq_operations dev_seq_ops;
82734+
82735 int seq_open_net(struct inode *ino, struct file *f,
82736 const struct seq_operations *ops, int size)
82737 {
82738@@ -44,6 +64,14 @@ int seq_open_net(struct inode *ino, struct file *f,
82739
82740 BUG_ON(size < sizeof(*p));
82741
82742+ /* only permit access to /proc/net/dev */
82743+ if (
82744+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
82745+ ops != ipv6_seq_ops_addr &&
82746+#endif
82747+ ops != &dev_seq_ops && gr_proc_is_restricted())
82748+ return -EACCES;
82749+
82750 net = get_proc_net(ino);
82751 if (net == NULL)
82752 return -ENXIO;
82753@@ -66,6 +94,9 @@ int single_open_net(struct inode *inode, struct file *file,
82754 int err;
82755 struct net *net;
82756
82757+ if (gr_proc_is_restricted())
82758+ return -EACCES;
82759+
82760 err = -ENXIO;
82761 net = get_proc_net(inode);
82762 if (net == NULL)
82763diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
82764index fdda62e..cd7c75f 100644
82765--- a/fs/proc/proc_sysctl.c
82766+++ b/fs/proc/proc_sysctl.c
82767@@ -11,13 +11,21 @@
82768 #include <linux/namei.h>
82769 #include <linux/mm.h>
82770 #include <linux/module.h>
82771+#include <linux/nsproxy.h>
82772+#ifdef CONFIG_GRKERNSEC
82773+#include <net/net_namespace.h>
82774+#endif
82775 #include "internal.h"
82776
82777+extern int gr_handle_chroot_sysctl(const int op);
82778+extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
82779+ const int op);
82780+
82781 static const struct dentry_operations proc_sys_dentry_operations;
82782 static const struct file_operations proc_sys_file_operations;
82783-static const struct inode_operations proc_sys_inode_operations;
82784+const struct inode_operations proc_sys_inode_operations;
82785 static const struct file_operations proc_sys_dir_file_operations;
82786-static const struct inode_operations proc_sys_dir_operations;
82787+const struct inode_operations proc_sys_dir_operations;
82788
82789 /* Support for permanently empty directories */
82790
82791@@ -32,13 +40,17 @@ static bool is_empty_dir(struct ctl_table_header *head)
82792
82793 static void set_empty_dir(struct ctl_dir *dir)
82794 {
82795- dir->header.ctl_table[0].child = sysctl_mount_point;
82796+ pax_open_kernel();
82797+ *(const void **)&dir->header.ctl_table[0].child = sysctl_mount_point;
82798+ pax_close_kernel();
82799 }
82800
82801 static void clear_empty_dir(struct ctl_dir *dir)
82802
82803 {
82804- dir->header.ctl_table[0].child = NULL;
82805+ pax_open_kernel();
82806+ *(void **)&dir->header.ctl_table[0].child = NULL;
82807+ pax_close_kernel();
82808 }
82809
82810 void proc_sys_poll_notify(struct ctl_table_poll *poll)
82811@@ -504,6 +516,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
82812
82813 err = NULL;
82814 d_set_d_op(dentry, &proc_sys_dentry_operations);
82815+
82816+ gr_handle_proc_create(dentry, inode);
82817+
82818 d_add(dentry, inode);
82819
82820 out:
82821@@ -519,6 +534,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
82822 struct inode *inode = file_inode(filp);
82823 struct ctl_table_header *head = grab_header(inode);
82824 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
82825+ int op = write ? MAY_WRITE : MAY_READ;
82826 ssize_t error;
82827 size_t res;
82828
82829@@ -530,7 +546,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
82830 * and won't be until we finish.
82831 */
82832 error = -EPERM;
82833- if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
82834+ if (sysctl_perm(head, table, op))
82835 goto out;
82836
82837 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
82838@@ -538,6 +554,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
82839 if (!table->proc_handler)
82840 goto out;
82841
82842+#ifdef CONFIG_GRKERNSEC
82843+ error = -EPERM;
82844+ if (gr_handle_chroot_sysctl(op))
82845+ goto out;
82846+ dget(filp->f_path.dentry);
82847+ if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
82848+ dput(filp->f_path.dentry);
82849+ goto out;
82850+ }
82851+ dput(filp->f_path.dentry);
82852+ if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
82853+ goto out;
82854+ if (write) {
82855+ if (current->nsproxy->net_ns != table->extra2) {
82856+ if (!capable(CAP_SYS_ADMIN))
82857+ goto out;
82858+ } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
82859+ goto out;
82860+ }
82861+#endif
82862+
82863 /* careful: calling conventions are nasty here */
82864 res = count;
82865 error = table->proc_handler(table, write, buf, &res, ppos);
82866@@ -635,6 +672,9 @@ static bool proc_sys_fill_cache(struct file *file,
82867 return false;
82868 } else {
82869 d_set_d_op(child, &proc_sys_dentry_operations);
82870+
82871+ gr_handle_proc_create(child, inode);
82872+
82873 d_add(child, inode);
82874 }
82875 } else {
82876@@ -678,6 +718,9 @@ static int scan(struct ctl_table_header *head, struct ctl_table *table,
82877 if ((*pos)++ < ctx->pos)
82878 return true;
82879
82880+ if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
82881+ return 0;
82882+
82883 if (unlikely(S_ISLNK(table->mode)))
82884 res = proc_sys_link_fill_cache(file, ctx, head, table);
82885 else
82886@@ -771,6 +814,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
82887 if (IS_ERR(head))
82888 return PTR_ERR(head);
82889
82890+ if (table && !gr_acl_handle_hidden_file(dentry, mnt))
82891+ return -ENOENT;
82892+
82893 generic_fillattr(inode, stat);
82894 if (table)
82895 stat->mode = (stat->mode & S_IFMT) | table->mode;
82896@@ -793,13 +839,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
82897 .llseek = generic_file_llseek,
82898 };
82899
82900-static const struct inode_operations proc_sys_inode_operations = {
82901+const struct inode_operations proc_sys_inode_operations = {
82902 .permission = proc_sys_permission,
82903 .setattr = proc_sys_setattr,
82904 .getattr = proc_sys_getattr,
82905 };
82906
82907-static const struct inode_operations proc_sys_dir_operations = {
82908+const struct inode_operations proc_sys_dir_operations = {
82909 .lookup = proc_sys_lookup,
82910 .permission = proc_sys_permission,
82911 .setattr = proc_sys_setattr,
82912@@ -876,7 +922,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
82913 static struct ctl_dir *new_dir(struct ctl_table_set *set,
82914 const char *name, int namelen)
82915 {
82916- struct ctl_table *table;
82917+ ctl_table_no_const *table;
82918 struct ctl_dir *new;
82919 struct ctl_node *node;
82920 char *new_name;
82921@@ -888,7 +934,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
82922 return NULL;
82923
82924 node = (struct ctl_node *)(new + 1);
82925- table = (struct ctl_table *)(node + 1);
82926+ table = (ctl_table_no_const *)(node + 1);
82927 new_name = (char *)(table + 2);
82928 memcpy(new_name, name, namelen);
82929 new_name[namelen] = '\0';
82930@@ -1057,7 +1103,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
82931 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
82932 struct ctl_table_root *link_root)
82933 {
82934- struct ctl_table *link_table, *entry, *link;
82935+ ctl_table_no_const *link_table, *link;
82936+ struct ctl_table *entry;
82937 struct ctl_table_header *links;
82938 struct ctl_node *node;
82939 char *link_name;
82940@@ -1080,7 +1127,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
82941 return NULL;
82942
82943 node = (struct ctl_node *)(links + 1);
82944- link_table = (struct ctl_table *)(node + nr_entries);
82945+ link_table = (ctl_table_no_const *)(node + nr_entries);
82946 link_name = (char *)&link_table[nr_entries + 1];
82947
82948 for (link = link_table, entry = table; entry->procname; link++, entry++) {
82949@@ -1328,8 +1375,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
82950 struct ctl_table_header ***subheader, struct ctl_table_set *set,
82951 struct ctl_table *table)
82952 {
82953- struct ctl_table *ctl_table_arg = NULL;
82954- struct ctl_table *entry, *files;
82955+ ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
82956+ struct ctl_table *entry;
82957 int nr_files = 0;
82958 int nr_dirs = 0;
82959 int err = -ENOMEM;
82960@@ -1341,10 +1388,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
82961 nr_files++;
82962 }
82963
82964- files = table;
82965 /* If there are mixed files and directories we need a new table */
82966 if (nr_dirs && nr_files) {
82967- struct ctl_table *new;
82968+ ctl_table_no_const *new;
82969 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
82970 GFP_KERNEL);
82971 if (!files)
82972@@ -1362,7 +1408,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
82973 /* Register everything except a directory full of subdirectories */
82974 if (nr_files || !nr_dirs) {
82975 struct ctl_table_header *header;
82976- header = __register_sysctl_table(set, path, files);
82977+ header = __register_sysctl_table(set, path, files ? files : table);
82978 if (!header) {
82979 kfree(ctl_table_arg);
82980 goto out;
82981diff --git a/fs/proc/root.c b/fs/proc/root.c
82982index 68feb0f..2c04780 100644
82983--- a/fs/proc/root.c
82984+++ b/fs/proc/root.c
82985@@ -185,7 +185,15 @@ void __init proc_root_init(void)
82986 proc_create_mount_point("openprom");
82987 #endif
82988 proc_tty_init();
82989+#ifdef CONFIG_GRKERNSEC_PROC_ADD
82990+#ifdef CONFIG_GRKERNSEC_PROC_USER
82991+ proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
82992+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82993+ proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
82994+#endif
82995+#else
82996 proc_mkdir("bus", NULL);
82997+#endif
82998 proc_sys_init();
82999 }
83000
83001diff --git a/fs/proc/stat.c b/fs/proc/stat.c
83002index 510413eb..34d9a8c 100644
83003--- a/fs/proc/stat.c
83004+++ b/fs/proc/stat.c
83005@@ -11,6 +11,7 @@
83006 #include <linux/irqnr.h>
83007 #include <linux/cputime.h>
83008 #include <linux/tick.h>
83009+#include <linux/grsecurity.h>
83010
83011 #ifndef arch_irq_stat_cpu
83012 #define arch_irq_stat_cpu(cpu) 0
83013@@ -87,6 +88,18 @@ static int show_stat(struct seq_file *p, void *v)
83014 u64 sum_softirq = 0;
83015 unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
83016 struct timespec boottime;
83017+ int unrestricted = 1;
83018+
83019+#ifdef CONFIG_GRKERNSEC_PROC_ADD
83020+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83021+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
83022+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
83023+ && !in_group_p(grsec_proc_gid)
83024+#endif
83025+ )
83026+ unrestricted = 0;
83027+#endif
83028+#endif
83029
83030 user = nice = system = idle = iowait =
83031 irq = softirq = steal = 0;
83032@@ -99,23 +112,25 @@ static int show_stat(struct seq_file *p, void *v)
83033 nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE];
83034 system += kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
83035 idle += get_idle_time(i);
83036- iowait += get_iowait_time(i);
83037- irq += kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
83038- softirq += kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
83039- steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
83040- guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
83041- guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
83042- sum += kstat_cpu_irqs_sum(i);
83043- sum += arch_irq_stat_cpu(i);
83044+ if (unrestricted) {
83045+ iowait += get_iowait_time(i);
83046+ irq += kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
83047+ softirq += kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
83048+ steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
83049+ guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
83050+ guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
83051+ sum += kstat_cpu_irqs_sum(i);
83052+ sum += arch_irq_stat_cpu(i);
83053+ for (j = 0; j < NR_SOFTIRQS; j++) {
83054+ unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
83055
83056- for (j = 0; j < NR_SOFTIRQS; j++) {
83057- unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
83058-
83059- per_softirq_sums[j] += softirq_stat;
83060- sum_softirq += softirq_stat;
83061+ per_softirq_sums[j] += softirq_stat;
83062+ sum_softirq += softirq_stat;
83063+ }
83064 }
83065 }
83066- sum += arch_irq_stat();
83067+ if (unrestricted)
83068+ sum += arch_irq_stat();
83069
83070 seq_puts(p, "cpu ");
83071 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
83072@@ -136,12 +151,14 @@ static int show_stat(struct seq_file *p, void *v)
83073 nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE];
83074 system = kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
83075 idle = get_idle_time(i);
83076- iowait = get_iowait_time(i);
83077- irq = kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
83078- softirq = kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
83079- steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
83080- guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
83081- guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
83082+ if (unrestricted) {
83083+ iowait = get_iowait_time(i);
83084+ irq = kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
83085+ softirq = kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
83086+ steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
83087+ guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
83088+ guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
83089+ }
83090 seq_printf(p, "cpu%d", i);
83091 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
83092 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(nice));
83093@@ -159,7 +176,7 @@ static int show_stat(struct seq_file *p, void *v)
83094
83095 /* sum again ? it could be updated? */
83096 for_each_irq_nr(j)
83097- seq_put_decimal_ull(p, ' ', kstat_irqs_usr(j));
83098+ seq_put_decimal_ull(p, ' ', unrestricted ? kstat_irqs_usr(j) : 0ULL);
83099
83100 seq_printf(p,
83101 "\nctxt %llu\n"
83102@@ -167,11 +184,11 @@ static int show_stat(struct seq_file *p, void *v)
83103 "processes %lu\n"
83104 "procs_running %lu\n"
83105 "procs_blocked %lu\n",
83106- nr_context_switches(),
83107+ unrestricted ? nr_context_switches() : 0ULL,
83108 (unsigned long)jif,
83109- total_forks,
83110- nr_running(),
83111- nr_iowait());
83112+ unrestricted ? total_forks : 0UL,
83113+ unrestricted ? nr_running() : 0UL,
83114+ unrestricted ? nr_iowait() : 0UL);
83115
83116 seq_printf(p, "softirq %llu", (unsigned long long)sum_softirq);
83117
83118diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
83119index ca1e091..a048795 100644
83120--- a/fs/proc/task_mmu.c
83121+++ b/fs/proc/task_mmu.c
83122@@ -13,12 +13,19 @@
83123 #include <linux/swap.h>
83124 #include <linux/swapops.h>
83125 #include <linux/mmu_notifier.h>
83126+#include <linux/grsecurity.h>
83127
83128 #include <asm/elf.h>
83129 #include <asm/uaccess.h>
83130 #include <asm/tlbflush.h>
83131 #include "internal.h"
83132
83133+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83134+#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
83135+ (_mm->pax_flags & MF_PAX_RANDMMAP || \
83136+ _mm->pax_flags & MF_PAX_SEGMEXEC))
83137+#endif
83138+
83139 void task_mem(struct seq_file *m, struct mm_struct *mm)
83140 {
83141 unsigned long data, text, lib, swap, ptes, pmds;
83142@@ -57,8 +64,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
83143 "VmLib:\t%8lu kB\n"
83144 "VmPTE:\t%8lu kB\n"
83145 "VmPMD:\t%8lu kB\n"
83146- "VmSwap:\t%8lu kB\n",
83147- hiwater_vm << (PAGE_SHIFT-10),
83148+ "VmSwap:\t%8lu kB\n"
83149+
83150+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83151+ "CsBase:\t%8lx\nCsLim:\t%8lx\n"
83152+#endif
83153+
83154+ ,hiwater_vm << (PAGE_SHIFT-10),
83155 total_vm << (PAGE_SHIFT-10),
83156 mm->locked_vm << (PAGE_SHIFT-10),
83157 mm->pinned_vm << (PAGE_SHIFT-10),
83158@@ -68,7 +80,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
83159 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
83160 ptes >> 10,
83161 pmds >> 10,
83162- swap << (PAGE_SHIFT-10));
83163+ swap << (PAGE_SHIFT-10)
83164+
83165+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83166+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83167+ , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
83168+ , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
83169+#else
83170+ , mm->context.user_cs_base
83171+ , mm->context.user_cs_limit
83172+#endif
83173+#endif
83174+
83175+ );
83176 }
83177
83178 unsigned long task_vsize(struct mm_struct *mm)
83179@@ -285,13 +309,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
83180 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
83181 }
83182
83183- /* We don't show the stack guard page in /proc/maps */
83184+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83185+ start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
83186+ end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
83187+#else
83188 start = vma->vm_start;
83189- if (stack_guard_page_start(vma, start))
83190- start += PAGE_SIZE;
83191 end = vma->vm_end;
83192- if (stack_guard_page_end(vma, end))
83193- end -= PAGE_SIZE;
83194+#endif
83195
83196 seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
83197 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
83198@@ -301,7 +325,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
83199 flags & VM_WRITE ? 'w' : '-',
83200 flags & VM_EXEC ? 'x' : '-',
83201 flags & VM_MAYSHARE ? 's' : 'p',
83202+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83203+ PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
83204+#else
83205 pgoff,
83206+#endif
83207 MAJOR(dev), MINOR(dev), ino);
83208
83209 /*
83210@@ -310,7 +338,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
83211 */
83212 if (file) {
83213 seq_pad(m, ' ');
83214- seq_file_path(m, file, "\n");
83215+ seq_file_path(m, file, "\n\\");
83216 goto done;
83217 }
83218
83219@@ -341,8 +369,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
83220 * Thread stack in /proc/PID/task/TID/maps or
83221 * the main process stack.
83222 */
83223- if (!is_pid || (vma->vm_start <= mm->start_stack &&
83224- vma->vm_end >= mm->start_stack)) {
83225+ if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
83226+ (vma->vm_start <= mm->start_stack &&
83227+ vma->vm_end >= mm->start_stack)) {
83228 name = "[stack]";
83229 } else {
83230 /* Thread stack in /proc/PID/maps */
83231@@ -362,6 +391,12 @@ done:
83232
83233 static int show_map(struct seq_file *m, void *v, int is_pid)
83234 {
83235+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83236+ if (current->exec_id != m->exec_id) {
83237+ gr_log_badprocpid("maps");
83238+ return 0;
83239+ }
83240+#endif
83241 show_map_vma(m, v, is_pid);
83242 m_cache_vma(m, v);
83243 return 0;
83244@@ -620,9 +655,18 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
83245 .private = &mss,
83246 };
83247
83248+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83249+ if (current->exec_id != m->exec_id) {
83250+ gr_log_badprocpid("smaps");
83251+ return 0;
83252+ }
83253+#endif
83254 memset(&mss, 0, sizeof mss);
83255- /* mmap_sem is held in m_start */
83256- walk_page_vma(vma, &smaps_walk);
83257+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83258+ if (!PAX_RAND_FLAGS(vma->vm_mm))
83259+#endif
83260+ /* mmap_sem is held in m_start */
83261+ walk_page_vma(vma, &smaps_walk);
83262
83263 show_map_vma(m, vma, is_pid);
83264
83265@@ -641,7 +685,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
83266 "KernelPageSize: %8lu kB\n"
83267 "MMUPageSize: %8lu kB\n"
83268 "Locked: %8lu kB\n",
83269+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83270+ PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
83271+#else
83272 (vma->vm_end - vma->vm_start) >> 10,
83273+#endif
83274 mss.resident >> 10,
83275 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
83276 mss.shared_clean >> 10,
83277@@ -1491,6 +1539,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
83278 char buffer[64];
83279 int nid;
83280
83281+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83282+ if (current->exec_id != m->exec_id) {
83283+ gr_log_badprocpid("numa_maps");
83284+ return 0;
83285+ }
83286+#endif
83287+
83288 if (!mm)
83289 return 0;
83290
83291@@ -1505,11 +1560,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
83292 mpol_to_str(buffer, sizeof(buffer), proc_priv->task_mempolicy);
83293 }
83294
83295+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83296+ seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
83297+#else
83298 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
83299+#endif
83300
83301 if (file) {
83302 seq_puts(m, " file=");
83303- seq_file_path(m, file, "\n\t= ");
83304+ seq_file_path(m, file, "\n\t\\= ");
83305 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
83306 seq_puts(m, " heap");
83307 } else {
83308diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
83309index e0d64c9..c44c96e 100644
83310--- a/fs/proc/task_nommu.c
83311+++ b/fs/proc/task_nommu.c
83312@@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
83313 else
83314 bytes += kobjsize(mm);
83315
83316- if (current->fs && current->fs->users > 1)
83317+ if (current->fs && atomic_read(&current->fs->users) > 1)
83318 sbytes += kobjsize(current->fs);
83319 else
83320 bytes += kobjsize(current->fs);
83321@@ -180,7 +180,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
83322
83323 if (file) {
83324 seq_pad(m, ' ');
83325- seq_file_path(m, file, "");
83326+ seq_file_path(m, file, "\n\\");
83327 } else if (mm) {
83328 pid_t tid = pid_of_stack(priv, vma, is_pid);
83329
83330diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
83331index 4e61388..1a2523d 100644
83332--- a/fs/proc/vmcore.c
83333+++ b/fs/proc/vmcore.c
83334@@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
83335 nr_bytes = count;
83336
83337 /* If pfn is not ram, return zeros for sparse dump files */
83338- if (pfn_is_ram(pfn) == 0)
83339- memset(buf, 0, nr_bytes);
83340- else {
83341+ if (pfn_is_ram(pfn) == 0) {
83342+ if (userbuf) {
83343+ if (clear_user((char __force_user *)buf, nr_bytes))
83344+ return -EFAULT;
83345+ } else
83346+ memset(buf, 0, nr_bytes);
83347+ } else {
83348 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
83349 offset, userbuf);
83350 if (tmp < 0)
83351@@ -170,7 +174,7 @@ int __weak remap_oldmem_pfn_range(struct vm_area_struct *vma,
83352 static int copy_to(void *target, void *src, size_t size, int userbuf)
83353 {
83354 if (userbuf) {
83355- if (copy_to_user((char __user *) target, src, size))
83356+ if (copy_to_user((char __force_user *) target, src, size))
83357 return -EFAULT;
83358 } else {
83359 memcpy(target, src, size);
83360@@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
83361 if (*fpos < m->offset + m->size) {
83362 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
83363 start = m->paddr + *fpos - m->offset;
83364- tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
83365+ tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
83366 if (tmp < 0)
83367 return tmp;
83368 buflen -= tsz;
83369@@ -253,7 +257,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
83370 static ssize_t read_vmcore(struct file *file, char __user *buffer,
83371 size_t buflen, loff_t *fpos)
83372 {
83373- return __read_vmcore((__force char *) buffer, buflen, fpos, 1);
83374+ return __read_vmcore((__force_kernel char *) buffer, buflen, fpos, 1);
83375 }
83376
83377 /*
83378diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
83379index d3fb2b6..43a8140 100644
83380--- a/fs/qnx6/qnx6.h
83381+++ b/fs/qnx6/qnx6.h
83382@@ -74,7 +74,7 @@ enum {
83383 BYTESEX_BE,
83384 };
83385
83386-static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
83387+static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
83388 {
83389 if (sbi->s_bytesex == BYTESEX_LE)
83390 return le64_to_cpu((__force __le64)n);
83391@@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
83392 return (__force __fs64)cpu_to_be64(n);
83393 }
83394
83395-static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
83396+static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
83397 {
83398 if (sbi->s_bytesex == BYTESEX_LE)
83399 return le32_to_cpu((__force __le32)n);
83400diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
83401index bb2869f..d34ada8 100644
83402--- a/fs/quota/netlink.c
83403+++ b/fs/quota/netlink.c
83404@@ -44,7 +44,7 @@ static struct genl_family quota_genl_family = {
83405 void quota_send_warning(struct kqid qid, dev_t dev,
83406 const char warntype)
83407 {
83408- static atomic_t seq;
83409+ static atomic_unchecked_t seq;
83410 struct sk_buff *skb;
83411 void *msg_head;
83412 int ret;
83413@@ -60,7 +60,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
83414 "VFS: Not enough memory to send quota warning.\n");
83415 return;
83416 }
83417- msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
83418+ msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
83419 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
83420 if (!msg_head) {
83421 printk(KERN_ERR
83422diff --git a/fs/read_write.c b/fs/read_write.c
83423index 819ef3f..f07222d 100644
83424--- a/fs/read_write.c
83425+++ b/fs/read_write.c
83426@@ -505,7 +505,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
83427
83428 old_fs = get_fs();
83429 set_fs(get_ds());
83430- p = (__force const char __user *)buf;
83431+ p = (const char __force_user *)buf;
83432 if (count > MAX_RW_COUNT)
83433 count = MAX_RW_COUNT;
83434 ret = __vfs_write(file, p, count, pos);
83435diff --git a/fs/readdir.c b/fs/readdir.c
83436index ced6791..936687b 100644
83437--- a/fs/readdir.c
83438+++ b/fs/readdir.c
83439@@ -18,6 +18,7 @@
83440 #include <linux/security.h>
83441 #include <linux/syscalls.h>
83442 #include <linux/unistd.h>
83443+#include <linux/namei.h>
83444
83445 #include <asm/uaccess.h>
83446
83447@@ -71,6 +72,7 @@ struct old_linux_dirent {
83448 struct readdir_callback {
83449 struct dir_context ctx;
83450 struct old_linux_dirent __user * dirent;
83451+ struct file * file;
83452 int result;
83453 };
83454
83455@@ -89,6 +91,10 @@ static int fillonedir(struct dir_context *ctx, const char *name, int namlen,
83456 buf->result = -EOVERFLOW;
83457 return -EOVERFLOW;
83458 }
83459+
83460+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
83461+ return 0;
83462+
83463 buf->result++;
83464 dirent = buf->dirent;
83465 if (!access_ok(VERIFY_WRITE, dirent,
83466@@ -120,6 +126,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
83467 if (!f.file)
83468 return -EBADF;
83469
83470+ buf.file = f.file;
83471 error = iterate_dir(f.file, &buf.ctx);
83472 if (buf.result)
83473 error = buf.result;
83474@@ -145,6 +152,7 @@ struct getdents_callback {
83475 struct dir_context ctx;
83476 struct linux_dirent __user * current_dir;
83477 struct linux_dirent __user * previous;
83478+ struct file * file;
83479 int count;
83480 int error;
83481 };
83482@@ -167,6 +175,10 @@ static int filldir(struct dir_context *ctx, const char *name, int namlen,
83483 buf->error = -EOVERFLOW;
83484 return -EOVERFLOW;
83485 }
83486+
83487+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
83488+ return 0;
83489+
83490 dirent = buf->previous;
83491 if (dirent) {
83492 if (__put_user(offset, &dirent->d_off))
83493@@ -212,6 +224,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
83494 if (!f.file)
83495 return -EBADF;
83496
83497+ buf.file = f.file;
83498 error = iterate_dir(f.file, &buf.ctx);
83499 if (error >= 0)
83500 error = buf.error;
83501@@ -230,6 +243,7 @@ struct getdents_callback64 {
83502 struct dir_context ctx;
83503 struct linux_dirent64 __user * current_dir;
83504 struct linux_dirent64 __user * previous;
83505+ struct file *file;
83506 int count;
83507 int error;
83508 };
83509@@ -246,6 +260,10 @@ static int filldir64(struct dir_context *ctx, const char *name, int namlen,
83510 buf->error = -EINVAL; /* only used if we fail.. */
83511 if (reclen > buf->count)
83512 return -EINVAL;
83513+
83514+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
83515+ return 0;
83516+
83517 dirent = buf->previous;
83518 if (dirent) {
83519 if (__put_user(offset, &dirent->d_off))
83520@@ -293,6 +311,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
83521 if (!f.file)
83522 return -EBADF;
83523
83524+ buf.file = f.file;
83525 error = iterate_dir(f.file, &buf.ctx);
83526 if (error >= 0)
83527 error = buf.error;
83528diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
83529index 9c02d96..6562c10 100644
83530--- a/fs/reiserfs/do_balan.c
83531+++ b/fs/reiserfs/do_balan.c
83532@@ -1887,7 +1887,7 @@ void do_balance(struct tree_balance *tb, struct item_head *ih,
83533 return;
83534 }
83535
83536- atomic_inc(&fs_generation(tb->tb_sb));
83537+ atomic_inc_unchecked(&fs_generation(tb->tb_sb));
83538 do_balance_starts(tb);
83539
83540 /*
83541diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
83542index aca73dd..e3c558d 100644
83543--- a/fs/reiserfs/item_ops.c
83544+++ b/fs/reiserfs/item_ops.c
83545@@ -724,18 +724,18 @@ static void errcatch_print_vi(struct virtual_item *vi)
83546 }
83547
83548 static struct item_operations errcatch_ops = {
83549- errcatch_bytes_number,
83550- errcatch_decrement_key,
83551- errcatch_is_left_mergeable,
83552- errcatch_print_item,
83553- errcatch_check_item,
83554+ .bytes_number = errcatch_bytes_number,
83555+ .decrement_key = errcatch_decrement_key,
83556+ .is_left_mergeable = errcatch_is_left_mergeable,
83557+ .print_item = errcatch_print_item,
83558+ .check_item = errcatch_check_item,
83559
83560- errcatch_create_vi,
83561- errcatch_check_left,
83562- errcatch_check_right,
83563- errcatch_part_size,
83564- errcatch_unit_num,
83565- errcatch_print_vi
83566+ .create_vi = errcatch_create_vi,
83567+ .check_left = errcatch_check_left,
83568+ .check_right = errcatch_check_right,
83569+ .part_size = errcatch_part_size,
83570+ .unit_num = errcatch_unit_num,
83571+ .print_vi = errcatch_print_vi
83572 };
83573
83574 #if ! (TYPE_STAT_DATA == 0 && TYPE_INDIRECT == 1 && TYPE_DIRECT == 2 && TYPE_DIRENTRY == 3)
83575diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
83576index 621b9f3..af527fd 100644
83577--- a/fs/reiserfs/procfs.c
83578+++ b/fs/reiserfs/procfs.c
83579@@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
83580 "SMALL_TAILS " : "NO_TAILS ",
83581 replay_only(sb) ? "REPLAY_ONLY " : "",
83582 convert_reiserfs(sb) ? "CONV " : "",
83583- atomic_read(&r->s_generation_counter),
83584+ atomic_read_unchecked(&r->s_generation_counter),
83585 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
83586 SF(s_do_balance), SF(s_unneeded_left_neighbor),
83587 SF(s_good_search_by_key_reada), SF(s_bmaps),
83588diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
83589index 2adcde1..7d27bc8 100644
83590--- a/fs/reiserfs/reiserfs.h
83591+++ b/fs/reiserfs/reiserfs.h
83592@@ -580,7 +580,7 @@ struct reiserfs_sb_info {
83593 /* Comment? -Hans */
83594 wait_queue_head_t s_wait;
83595 /* increased by one every time the tree gets re-balanced */
83596- atomic_t s_generation_counter;
83597+ atomic_unchecked_t s_generation_counter;
83598
83599 /* File system properties. Currently holds on-disk FS format */
83600 unsigned long s_properties;
83601@@ -2300,7 +2300,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
83602 #define REISERFS_USER_MEM 1 /* user memory mode */
83603
83604 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
83605-#define get_generation(s) atomic_read (&fs_generation(s))
83606+#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
83607 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
83608 #define __fs_changed(gen,s) (gen != get_generation (s))
83609 #define fs_changed(gen,s) \
83610diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
83611index 4a62fe8..5dc2f5f 100644
83612--- a/fs/reiserfs/super.c
83613+++ b/fs/reiserfs/super.c
83614@@ -1870,6 +1870,10 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
83615 sbi->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
83616 sbi->s_mount_opt |= (1 << REISERFS_ERROR_RO);
83617 sbi->s_mount_opt |= (1 << REISERFS_BARRIER_FLUSH);
83618+#ifdef CONFIG_REISERFS_FS_XATTR
83619+ /* turn on user xattrs by default */
83620+ sbi->s_mount_opt |= (1 << REISERFS_XATTRS_USER);
83621+#endif
83622 /* no preallocation minimum, be smart in reiserfs_file_write instead */
83623 sbi->s_alloc_options.preallocmin = 0;
83624 /* Preallocate by 16 blocks (17-1) at once */
83625diff --git a/fs/select.c b/fs/select.c
83626index 0155473..29d751f 100644
83627--- a/fs/select.c
83628+++ b/fs/select.c
83629@@ -20,6 +20,7 @@
83630 #include <linux/export.h>
83631 #include <linux/slab.h>
83632 #include <linux/poll.h>
83633+#include <linux/security.h>
83634 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
83635 #include <linux/file.h>
83636 #include <linux/fdtable.h>
83637@@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
83638 struct poll_list *walk = head;
83639 unsigned long todo = nfds;
83640
83641+ gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
83642 if (nfds > rlimit(RLIMIT_NOFILE))
83643 return -EINVAL;
83644
83645diff --git a/fs/seq_file.c b/fs/seq_file.c
83646index ce9e39f..5c5a436 100644
83647--- a/fs/seq_file.c
83648+++ b/fs/seq_file.c
83649@@ -12,6 +12,8 @@
83650 #include <linux/slab.h>
83651 #include <linux/cred.h>
83652 #include <linux/mm.h>
83653+#include <linux/sched.h>
83654+#include <linux/grsecurity.h>
83655
83656 #include <asm/uaccess.h>
83657 #include <asm/page.h>
83658@@ -29,9 +31,9 @@ static void *seq_buf_alloc(unsigned long size)
83659 * __GFP_NORETRY to avoid oom-killings with high-order allocations -
83660 * it's better to fall back to vmalloc() than to kill things.
83661 */
83662- buf = kmalloc(size, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
83663+ buf = kmalloc(size, GFP_KERNEL | GFP_USERCOPY | __GFP_NORETRY | __GFP_NOWARN);
83664 if (!buf && size > PAGE_SIZE)
83665- buf = vmalloc(size);
83666+ buf = vmalloc_usercopy(size);
83667 return buf;
83668 }
83669
83670@@ -68,6 +70,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
83671 #ifdef CONFIG_USER_NS
83672 p->user_ns = file->f_cred->user_ns;
83673 #endif
83674+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83675+ p->exec_id = current->exec_id;
83676+#endif
83677
83678 /*
83679 * Wrappers around seq_open(e.g. swaps_open) need to be
83680@@ -90,6 +95,16 @@ int seq_open(struct file *file, const struct seq_operations *op)
83681 }
83682 EXPORT_SYMBOL(seq_open);
83683
83684+
83685+int seq_open_restrict(struct file *file, const struct seq_operations *op)
83686+{
83687+ if (gr_proc_is_restricted())
83688+ return -EACCES;
83689+
83690+ return seq_open(file, op);
83691+}
83692+EXPORT_SYMBOL(seq_open_restrict);
83693+
83694 static int traverse(struct seq_file *m, loff_t offset)
83695 {
83696 loff_t pos = 0, index;
83697@@ -161,7 +176,7 @@ Eoverflow:
83698 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
83699 {
83700 struct seq_file *m = file->private_data;
83701- size_t copied = 0;
83702+ ssize_t copied = 0;
83703 loff_t pos;
83704 size_t n;
83705 void *p;
83706@@ -575,7 +590,7 @@ static void single_stop(struct seq_file *p, void *v)
83707 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
83708 void *data)
83709 {
83710- struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
83711+ seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
83712 int res = -ENOMEM;
83713
83714 if (op) {
83715@@ -611,6 +626,17 @@ int single_open_size(struct file *file, int (*show)(struct seq_file *, void *),
83716 }
83717 EXPORT_SYMBOL(single_open_size);
83718
83719+int single_open_restrict(struct file *file, int (*show)(struct seq_file *, void *),
83720+ void *data)
83721+{
83722+ if (gr_proc_is_restricted())
83723+ return -EACCES;
83724+
83725+ return single_open(file, show, data);
83726+}
83727+EXPORT_SYMBOL(single_open_restrict);
83728+
83729+
83730 int single_release(struct inode *inode, struct file *file)
83731 {
83732 const struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
83733diff --git a/fs/splice.c b/fs/splice.c
83734index 5fc1e50..6ae8957 100644
83735--- a/fs/splice.c
83736+++ b/fs/splice.c
83737@@ -192,7 +192,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
83738 pipe_lock(pipe);
83739
83740 for (;;) {
83741- if (!pipe->readers) {
83742+ if (!atomic_read(&pipe->readers)) {
83743 send_sig(SIGPIPE, current, 0);
83744 if (!ret)
83745 ret = -EPIPE;
83746@@ -215,7 +215,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
83747 page_nr++;
83748 ret += buf->len;
83749
83750- if (pipe->files)
83751+ if (atomic_read(&pipe->files))
83752 do_wakeup = 1;
83753
83754 if (!--spd->nr_pages)
83755@@ -246,9 +246,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
83756 do_wakeup = 0;
83757 }
83758
83759- pipe->waiting_writers++;
83760+ atomic_inc(&pipe->waiting_writers);
83761 pipe_wait(pipe);
83762- pipe->waiting_writers--;
83763+ atomic_dec(&pipe->waiting_writers);
83764 }
83765
83766 pipe_unlock(pipe);
83767@@ -579,7 +579,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
83768 old_fs = get_fs();
83769 set_fs(get_ds());
83770 /* The cast to a user pointer is valid due to the set_fs() */
83771- res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
83772+ res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
83773 set_fs(old_fs);
83774
83775 return res;
83776@@ -594,7 +594,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
83777 old_fs = get_fs();
83778 set_fs(get_ds());
83779 /* The cast to a user pointer is valid due to the set_fs() */
83780- res = vfs_write(file, (__force const char __user *)buf, count, &pos);
83781+ res = vfs_write(file, (const char __force_user *)buf, count, &pos);
83782 set_fs(old_fs);
83783
83784 return res;
83785@@ -647,7 +647,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
83786 goto err;
83787
83788 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
83789- vec[i].iov_base = (void __user *) page_address(page);
83790+ vec[i].iov_base = (void __force_user *) page_address(page);
83791 vec[i].iov_len = this_len;
83792 spd.pages[i] = page;
83793 spd.nr_pages++;
83794@@ -786,7 +786,7 @@ static int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_des
83795 ops->release(pipe, buf);
83796 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
83797 pipe->nrbufs--;
83798- if (pipe->files)
83799+ if (atomic_read(&pipe->files))
83800 sd->need_wakeup = true;
83801 }
83802
83803@@ -810,10 +810,10 @@ static int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_des
83804 static int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
83805 {
83806 while (!pipe->nrbufs) {
83807- if (!pipe->writers)
83808+ if (!atomic_read(&pipe->writers))
83809 return 0;
83810
83811- if (!pipe->waiting_writers && sd->num_spliced)
83812+ if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
83813 return 0;
83814
83815 if (sd->flags & SPLICE_F_NONBLOCK)
83816@@ -1028,7 +1028,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
83817 ops->release(pipe, buf);
83818 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
83819 pipe->nrbufs--;
83820- if (pipe->files)
83821+ if (atomic_read(&pipe->files))
83822 sd.need_wakeup = true;
83823 } else {
83824 buf->offset += ret;
83825@@ -1188,7 +1188,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
83826 * out of the pipe right after the splice_to_pipe(). So set
83827 * PIPE_READERS appropriately.
83828 */
83829- pipe->readers = 1;
83830+ atomic_set(&pipe->readers, 1);
83831
83832 current->splice_pipe = pipe;
83833 }
83834@@ -1495,6 +1495,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
83835
83836 partial[buffers].offset = off;
83837 partial[buffers].len = plen;
83838+ partial[buffers].private = 0;
83839
83840 off = 0;
83841 len -= plen;
83842@@ -1726,9 +1727,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
83843 ret = -ERESTARTSYS;
83844 break;
83845 }
83846- if (!pipe->writers)
83847+ if (!atomic_read(&pipe->writers))
83848 break;
83849- if (!pipe->waiting_writers) {
83850+ if (!atomic_read(&pipe->waiting_writers)) {
83851 if (flags & SPLICE_F_NONBLOCK) {
83852 ret = -EAGAIN;
83853 break;
83854@@ -1760,7 +1761,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
83855 pipe_lock(pipe);
83856
83857 while (pipe->nrbufs >= pipe->buffers) {
83858- if (!pipe->readers) {
83859+ if (!atomic_read(&pipe->readers)) {
83860 send_sig(SIGPIPE, current, 0);
83861 ret = -EPIPE;
83862 break;
83863@@ -1773,9 +1774,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
83864 ret = -ERESTARTSYS;
83865 break;
83866 }
83867- pipe->waiting_writers++;
83868+ atomic_inc(&pipe->waiting_writers);
83869 pipe_wait(pipe);
83870- pipe->waiting_writers--;
83871+ atomic_dec(&pipe->waiting_writers);
83872 }
83873
83874 pipe_unlock(pipe);
83875@@ -1811,14 +1812,14 @@ retry:
83876 pipe_double_lock(ipipe, opipe);
83877
83878 do {
83879- if (!opipe->readers) {
83880+ if (!atomic_read(&opipe->readers)) {
83881 send_sig(SIGPIPE, current, 0);
83882 if (!ret)
83883 ret = -EPIPE;
83884 break;
83885 }
83886
83887- if (!ipipe->nrbufs && !ipipe->writers)
83888+ if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
83889 break;
83890
83891 /*
83892@@ -1915,7 +1916,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
83893 pipe_double_lock(ipipe, opipe);
83894
83895 do {
83896- if (!opipe->readers) {
83897+ if (!atomic_read(&opipe->readers)) {
83898 send_sig(SIGPIPE, current, 0);
83899 if (!ret)
83900 ret = -EPIPE;
83901@@ -1960,7 +1961,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
83902 * return EAGAIN if we have the potential of some data in the
83903 * future, otherwise just return 0
83904 */
83905- if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
83906+ if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
83907 ret = -EAGAIN;
83908
83909 pipe_unlock(ipipe);
83910diff --git a/fs/squashfs/xattr.c b/fs/squashfs/xattr.c
83911index e5e0ddf..09598c4 100644
83912--- a/fs/squashfs/xattr.c
83913+++ b/fs/squashfs/xattr.c
83914@@ -46,8 +46,8 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
83915 + msblk->xattr_table;
83916 int offset = SQUASHFS_XATTR_OFFSET(squashfs_i(inode)->xattr);
83917 int count = squashfs_i(inode)->xattr_count;
83918- size_t rest = buffer_size;
83919- int err;
83920+ size_t used = 0;
83921+ ssize_t err;
83922
83923 /* check that the file system has xattrs */
83924 if (msblk->xattr_id_table == NULL)
83925@@ -68,11 +68,11 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
83926 name_size = le16_to_cpu(entry.size);
83927 handler = squashfs_xattr_handler(le16_to_cpu(entry.type));
83928 if (handler)
83929- prefix_size = handler->list(d, buffer, rest, NULL,
83930+ prefix_size = handler->list(d, buffer, buffer ? buffer_size - used : 0, NULL,
83931 name_size, handler->flags);
83932 if (prefix_size) {
83933 if (buffer) {
83934- if (prefix_size + name_size + 1 > rest) {
83935+ if (prefix_size + name_size + 1 > buffer_size - used) {
83936 err = -ERANGE;
83937 goto failed;
83938 }
83939@@ -86,7 +86,7 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
83940 buffer[name_size] = '\0';
83941 buffer += name_size + 1;
83942 }
83943- rest -= prefix_size + name_size + 1;
83944+ used += prefix_size + name_size + 1;
83945 } else {
83946 /* no handler or insuffficient privileges, so skip */
83947 err = squashfs_read_metadata(sb, NULL, &start,
83948@@ -107,7 +107,7 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
83949 if (err < 0)
83950 goto failed;
83951 }
83952- err = buffer_size - rest;
83953+ err = used;
83954
83955 failed:
83956 return err;
83957diff --git a/fs/stat.c b/fs/stat.c
83958index cccc1aa..7fe8951 100644
83959--- a/fs/stat.c
83960+++ b/fs/stat.c
83961@@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
83962 stat->gid = inode->i_gid;
83963 stat->rdev = inode->i_rdev;
83964 stat->size = i_size_read(inode);
83965- stat->atime = inode->i_atime;
83966- stat->mtime = inode->i_mtime;
83967+ if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
83968+ stat->atime = inode->i_ctime;
83969+ stat->mtime = inode->i_ctime;
83970+ } else {
83971+ stat->atime = inode->i_atime;
83972+ stat->mtime = inode->i_mtime;
83973+ }
83974 stat->ctime = inode->i_ctime;
83975 stat->blksize = (1 << inode->i_blkbits);
83976 stat->blocks = inode->i_blocks;
83977@@ -52,9 +57,16 @@ EXPORT_SYMBOL(generic_fillattr);
83978 int vfs_getattr_nosec(struct path *path, struct kstat *stat)
83979 {
83980 struct inode *inode = d_backing_inode(path->dentry);
83981+ int retval;
83982
83983- if (inode->i_op->getattr)
83984- return inode->i_op->getattr(path->mnt, path->dentry, stat);
83985+ if (inode->i_op->getattr) {
83986+ retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
83987+ if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
83988+ stat->atime = stat->ctime;
83989+ stat->mtime = stat->ctime;
83990+ }
83991+ return retval;
83992+ }
83993
83994 generic_fillattr(inode, stat);
83995 return 0;
83996diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
83997index 94374e4..b5da3a1 100644
83998--- a/fs/sysfs/dir.c
83999+++ b/fs/sysfs/dir.c
84000@@ -33,6 +33,10 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
84001 kfree(buf);
84002 }
84003
84004+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
84005+extern int grsec_enable_sysfs_restrict;
84006+#endif
84007+
84008 /**
84009 * sysfs_create_dir_ns - create a directory for an object with a namespace tag
84010 * @kobj: object we're creating directory for
84011@@ -41,9 +45,16 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
84012 int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
84013 {
84014 struct kernfs_node *parent, *kn;
84015+ const char *name;
84016+ umode_t mode = S_IRWXU | S_IRUGO | S_IXUGO;
84017+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
84018+ const char *parent_name;
84019+#endif
84020
84021 BUG_ON(!kobj);
84022
84023+ name = kobject_name(kobj);
84024+
84025 if (kobj->parent)
84026 parent = kobj->parent->sd;
84027 else
84028@@ -52,11 +63,24 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
84029 if (!parent)
84030 return -ENOENT;
84031
84032- kn = kernfs_create_dir_ns(parent, kobject_name(kobj),
84033- S_IRWXU | S_IRUGO | S_IXUGO, kobj, ns);
84034+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
84035+ parent_name = parent->name;
84036+ mode = S_IRWXU;
84037+
84038+ if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
84039+ (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
84040+ (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
84041+ (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
84042+ mode = S_IRWXU | S_IRUGO | S_IXUGO;
84043+ if (!grsec_enable_sysfs_restrict)
84044+ mode = S_IRWXU | S_IRUGO | S_IXUGO;
84045+#endif
84046+
84047+ kn = kernfs_create_dir_ns(parent, name,
84048+ mode, kobj, ns);
84049 if (IS_ERR(kn)) {
84050 if (PTR_ERR(kn) == -EEXIST)
84051- sysfs_warn_dup(parent, kobject_name(kobj));
84052+ sysfs_warn_dup(parent, name);
84053 return PTR_ERR(kn);
84054 }
84055
84056diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
84057index 6c21228..9afd5fe 100644
84058--- a/fs/sysv/sysv.h
84059+++ b/fs/sysv/sysv.h
84060@@ -187,7 +187,7 @@ static inline u32 PDP_swab(u32 x)
84061 #endif
84062 }
84063
84064-static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
84065+static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
84066 {
84067 if (sbi->s_bytesex == BYTESEX_PDP)
84068 return PDP_swab((__force __u32)n);
84069diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
84070index cbc8d5d..56d2600 100644
84071--- a/fs/tracefs/inode.c
84072+++ b/fs/tracefs/inode.c
84073@@ -53,7 +53,7 @@ static const struct file_operations tracefs_file_operations = {
84074 static struct tracefs_dir_ops {
84075 int (*mkdir)(const char *name);
84076 int (*rmdir)(const char *name);
84077-} tracefs_ops;
84078+} __no_const tracefs_ops __read_only;
84079
84080 static char *get_dname(struct dentry *dentry)
84081 {
84082@@ -490,8 +490,10 @@ struct dentry *tracefs_create_instance_dir(const char *name, struct dentry *pare
84083 if (!dentry)
84084 return NULL;
84085
84086- tracefs_ops.mkdir = mkdir;
84087- tracefs_ops.rmdir = rmdir;
84088+ pax_open_kernel();
84089+ *(void **)&tracefs_ops.mkdir = mkdir;
84090+ *(void **)&tracefs_ops.rmdir = rmdir;
84091+ pax_close_kernel();
84092
84093 return dentry;
84094 }
84095diff --git a/fs/udf/misc.c b/fs/udf/misc.c
84096index 71d1c25..084e2ad 100644
84097--- a/fs/udf/misc.c
84098+++ b/fs/udf/misc.c
84099@@ -288,7 +288,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
84100
84101 u8 udf_tag_checksum(const struct tag *t)
84102 {
84103- u8 *data = (u8 *)t;
84104+ const u8 *data = (const u8 *)t;
84105 u8 checksum = 0;
84106 int i;
84107 for (i = 0; i < sizeof(struct tag); ++i)
84108diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
84109index 8d974c4..b82f6ec 100644
84110--- a/fs/ufs/swab.h
84111+++ b/fs/ufs/swab.h
84112@@ -22,7 +22,7 @@ enum {
84113 BYTESEX_BE
84114 };
84115
84116-static inline u64
84117+static inline u64 __intentional_overflow(-1)
84118 fs64_to_cpu(struct super_block *sbp, __fs64 n)
84119 {
84120 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
84121@@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
84122 return (__force __fs64)cpu_to_be64(n);
84123 }
84124
84125-static inline u32
84126+static inline u32 __intentional_overflow(-1)
84127 fs32_to_cpu(struct super_block *sbp, __fs32 n)
84128 {
84129 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
84130diff --git a/fs/utimes.c b/fs/utimes.c
84131index aa138d6..5f3a811 100644
84132--- a/fs/utimes.c
84133+++ b/fs/utimes.c
84134@@ -1,6 +1,7 @@
84135 #include <linux/compiler.h>
84136 #include <linux/file.h>
84137 #include <linux/fs.h>
84138+#include <linux/security.h>
84139 #include <linux/linkage.h>
84140 #include <linux/mount.h>
84141 #include <linux/namei.h>
84142@@ -103,6 +104,12 @@ static int utimes_common(struct path *path, struct timespec *times)
84143 }
84144 }
84145 retry_deleg:
84146+
84147+ if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
84148+ error = -EACCES;
84149+ goto mnt_drop_write_and_out;
84150+ }
84151+
84152 mutex_lock(&inode->i_mutex);
84153 error = notify_change(path->dentry, &newattrs, &delegated_inode);
84154 mutex_unlock(&inode->i_mutex);
84155diff --git a/fs/xattr.c b/fs/xattr.c
84156index 072fee1..9e497b0 100644
84157--- a/fs/xattr.c
84158+++ b/fs/xattr.c
84159@@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
84160 return rc;
84161 }
84162
84163+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84164+ssize_t
84165+pax_getxattr(struct dentry *dentry, void *value, size_t size)
84166+{
84167+ struct inode *inode = dentry->d_inode;
84168+ ssize_t error;
84169+
84170+ error = inode_permission(inode, MAY_EXEC);
84171+ if (error)
84172+ return error;
84173+
84174+ if (inode->i_op->getxattr)
84175+ error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
84176+ else
84177+ error = -EOPNOTSUPP;
84178+
84179+ return error;
84180+}
84181+EXPORT_SYMBOL(pax_getxattr);
84182+#endif
84183+
84184 ssize_t
84185 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
84186 {
84187@@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
84188 * Extended attribute SET operations
84189 */
84190 static long
84191-setxattr(struct dentry *d, const char __user *name, const void __user *value,
84192+setxattr(struct path *path, const char __user *name, const void __user *value,
84193 size_t size, int flags)
84194 {
84195 int error;
84196@@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
84197 posix_acl_fix_xattr_from_user(kvalue, size);
84198 }
84199
84200- error = vfs_setxattr(d, kname, kvalue, size, flags);
84201+ if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
84202+ error = -EACCES;
84203+ goto out;
84204+ }
84205+
84206+ error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
84207 out:
84208 if (vvalue)
84209 vfree(vvalue);
84210@@ -376,7 +402,7 @@ retry:
84211 return error;
84212 error = mnt_want_write(path.mnt);
84213 if (!error) {
84214- error = setxattr(path.dentry, name, value, size, flags);
84215+ error = setxattr(&path, name, value, size, flags);
84216 mnt_drop_write(path.mnt);
84217 }
84218 path_put(&path);
84219@@ -412,7 +438,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
84220 audit_file(f.file);
84221 error = mnt_want_write_file(f.file);
84222 if (!error) {
84223- error = setxattr(f.file->f_path.dentry, name, value, size, flags);
84224+ error = setxattr(&f.file->f_path, name, value, size, flags);
84225 mnt_drop_write_file(f.file);
84226 }
84227 fdput(f);
84228@@ -598,7 +624,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
84229 * Extended attribute REMOVE operations
84230 */
84231 static long
84232-removexattr(struct dentry *d, const char __user *name)
84233+removexattr(struct path *path, const char __user *name)
84234 {
84235 int error;
84236 char kname[XATTR_NAME_MAX + 1];
84237@@ -609,7 +635,10 @@ removexattr(struct dentry *d, const char __user *name)
84238 if (error < 0)
84239 return error;
84240
84241- return vfs_removexattr(d, kname);
84242+ if (!gr_acl_handle_removexattr(path->dentry, path->mnt))
84243+ return -EACCES;
84244+
84245+ return vfs_removexattr(path->dentry, kname);
84246 }
84247
84248 static int path_removexattr(const char __user *pathname,
84249@@ -623,7 +652,7 @@ retry:
84250 return error;
84251 error = mnt_want_write(path.mnt);
84252 if (!error) {
84253- error = removexattr(path.dentry, name);
84254+ error = removexattr(&path, name);
84255 mnt_drop_write(path.mnt);
84256 }
84257 path_put(&path);
84258@@ -649,14 +678,16 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
84259 SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
84260 {
84261 struct fd f = fdget(fd);
84262+ struct path *path;
84263 int error = -EBADF;
84264
84265 if (!f.file)
84266 return error;
84267+ path = &f.file->f_path;
84268 audit_file(f.file);
84269 error = mnt_want_write_file(f.file);
84270 if (!error) {
84271- error = removexattr(f.file->f_path.dentry, name);
84272+ error = removexattr(path, name);
84273 mnt_drop_write_file(f.file);
84274 }
84275 fdput(f);
84276diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
84277index 63e05b6..249b043 100644
84278--- a/fs/xfs/libxfs/xfs_bmap.c
84279+++ b/fs/xfs/libxfs/xfs_bmap.c
84280@@ -554,7 +554,7 @@ xfs_bmap_validate_ret(
84281
84282 #else
84283 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
84284-#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
84285+#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
84286 #endif /* DEBUG */
84287
84288 /*
84289diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
84290index 098cd78..724d3f8 100644
84291--- a/fs/xfs/xfs_dir2_readdir.c
84292+++ b/fs/xfs/xfs_dir2_readdir.c
84293@@ -140,7 +140,12 @@ xfs_dir2_sf_getdents(
84294 ino = dp->d_ops->sf_get_ino(sfp, sfep);
84295 filetype = dp->d_ops->sf_get_ftype(sfep);
84296 ctx->pos = off & 0x7fffffff;
84297- if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
84298+ if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
84299+ char name[sfep->namelen];
84300+ memcpy(name, sfep->name, sfep->namelen);
84301+ if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(dp->i_mount, filetype)))
84302+ return 0;
84303+ } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
84304 xfs_dir3_get_dtype(dp->i_mount, filetype)))
84305 return 0;
84306 sfep = dp->d_ops->sf_nextentry(sfp, sfep);
84307diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
84308index ea7d85a..6d4b24b 100644
84309--- a/fs/xfs/xfs_ioctl.c
84310+++ b/fs/xfs/xfs_ioctl.c
84311@@ -120,7 +120,7 @@ xfs_find_handle(
84312 }
84313
84314 error = -EFAULT;
84315- if (copy_to_user(hreq->ohandle, &handle, hsize) ||
84316+ if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
84317 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
84318 goto out_put;
84319
84320diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
84321index 85f883d..db6eecc 100644
84322--- a/fs/xfs/xfs_linux.h
84323+++ b/fs/xfs/xfs_linux.h
84324@@ -211,7 +211,7 @@ static inline kgid_t xfs_gid_to_kgid(__uint32_t gid)
84325 * of the compiler which do not like us using do_div in the middle
84326 * of large functions.
84327 */
84328-static inline __u32 xfs_do_div(void *a, __u32 b, int n)
84329+static inline __u32 __intentional_overflow(-1) xfs_do_div(void *a, __u32 b, int n)
84330 {
84331 __u32 mod;
84332
84333@@ -267,7 +267,7 @@ static inline __u32 xfs_do_mod(void *a, __u32 b, int n)
84334 return 0;
84335 }
84336 #else
84337-static inline __u32 xfs_do_div(void *a, __u32 b, int n)
84338+static inline __u32 __intentional_overflow(-1) xfs_do_div(void *a, __u32 b, int n)
84339 {
84340 __u32 mod;
84341
84342diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
84343new file mode 100644
84344index 0000000..31f8fe4
84345--- /dev/null
84346+++ b/grsecurity/Kconfig
84347@@ -0,0 +1,1182 @@
84348+#
84349+# grecurity configuration
84350+#
84351+menu "Memory Protections"
84352+depends on GRKERNSEC
84353+
84354+config GRKERNSEC_KMEM
84355+ bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
84356+ default y if GRKERNSEC_CONFIG_AUTO
84357+ select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
84358+ help
84359+ If you say Y here, /dev/kmem and /dev/mem won't be allowed to
84360+ be written to or read from to modify or leak the contents of the running
84361+ kernel. /dev/port will also not be allowed to be opened, writing to
84362+ /dev/cpu/*/msr will be prevented, and support for kexec will be removed.
84363+ If you have module support disabled, enabling this will close up several
84364+ ways that are currently used to insert malicious code into the running
84365+ kernel.
84366+
84367+ Even with this feature enabled, we still highly recommend that
84368+ you use the RBAC system, as it is still possible for an attacker to
84369+ modify the running kernel through other more obscure methods.
84370+
84371+ It is highly recommended that you say Y here if you meet all the
84372+ conditions above.
84373+
84374+config GRKERNSEC_VM86
84375+ bool "Restrict VM86 mode"
84376+ default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
84377+ depends on X86_32
84378+
84379+ help
84380+ If you say Y here, only processes with CAP_SYS_RAWIO will be able to
84381+ make use of a special execution mode on 32bit x86 processors called
84382+ Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
84383+ video cards and will still work with this option enabled. The purpose
84384+ of the option is to prevent exploitation of emulation errors in
84385+ virtualization of vm86 mode like the one discovered in VMWare in 2009.
84386+ Nearly all users should be able to enable this option.
84387+
84388+config GRKERNSEC_IO
84389+ bool "Disable privileged I/O"
84390+ default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
84391+ depends on X86
84392+ select RTC_CLASS
84393+ select RTC_INTF_DEV
84394+ select RTC_DRV_CMOS
84395+
84396+ help
84397+ If you say Y here, all ioperm and iopl calls will return an error.
84398+ Ioperm and iopl can be used to modify the running kernel.
84399+ Unfortunately, some programs need this access to operate properly,
84400+ the most notable of which are XFree86 and hwclock. hwclock can be
84401+ remedied by having RTC support in the kernel, so real-time
84402+ clock support is enabled if this option is enabled, to ensure
84403+ that hwclock operates correctly. If hwclock still does not work,
84404+ either update udev or symlink /dev/rtc to /dev/rtc0.
84405+
84406+ If you're using XFree86 or a version of Xorg from 2012 or earlier,
84407+ you may not be able to boot into a graphical environment with this
84408+ option enabled. In this case, you should use the RBAC system instead.
84409+
84410+config GRKERNSEC_BPF_HARDEN
84411+ bool "Harden BPF interpreter"
84412+ default y if GRKERNSEC_CONFIG_AUTO
84413+ help
84414+ Unlike previous versions of grsecurity that hardened both the BPF
84415+ interpreted code against corruption at rest as well as the JIT code
84416+ against JIT-spray attacks and attacker-controlled immediate values
84417+ for ROP, this feature will enforce disabling of the new eBPF JIT engine
84418+ and will ensure the interpreted code is read-only at rest. This feature
84419+ may be removed at a later time when eBPF stabilizes to entirely revert
84420+ back to the more secure pre-3.16 BPF interpreter/JIT.
84421+
84422+ If you're using KERNEXEC, it's recommended that you enable this option
84423+ to supplement the hardening of the kernel.
84424+
84425+config GRKERNSEC_PERF_HARDEN
84426+ bool "Disable unprivileged PERF_EVENTS usage by default"
84427+ default y if GRKERNSEC_CONFIG_AUTO
84428+ depends on PERF_EVENTS
84429+ help
84430+ If you say Y here, the range of acceptable values for the
84431+ /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
84432+ default to a new value: 3. When the sysctl is set to this value, no
84433+ unprivileged use of the PERF_EVENTS syscall interface will be permitted.
84434+
84435+ Though PERF_EVENTS can be used legitimately for performance monitoring
84436+ and low-level application profiling, it is forced on regardless of
84437+ configuration, has been at fault for several vulnerabilities, and
84438+ creates new opportunities for side channels and other information leaks.
84439+
84440+ This feature puts PERF_EVENTS into a secure default state and permits
84441+ the administrator to change out of it temporarily if unprivileged
84442+ application profiling is needed.
84443+
84444+config GRKERNSEC_RAND_THREADSTACK
84445+ bool "Insert random gaps between thread stacks"
84446+ default y if GRKERNSEC_CONFIG_AUTO
84447+ depends on PAX_RANDMMAP && !PPC
84448+ help
84449+ If you say Y here, a random-sized gap will be enforced between allocated
84450+ thread stacks. Glibc's NPTL and other threading libraries that
84451+ pass MAP_STACK to the kernel for thread stack allocation are supported.
84452+ The implementation currently provides 8 bits of entropy for the gap.
84453+
84454+ Many distributions do not compile threaded remote services with the
84455+ -fstack-check argument to GCC, causing the variable-sized stack-based
84456+ allocator, alloca(), to not probe the stack on allocation. This
84457+ permits an unbounded alloca() to skip over any guard page and potentially
84458+ modify another thread's stack reliably. An enforced random gap
84459+ reduces the reliability of such an attack and increases the chance
84460+ that such a read/write to another thread's stack instead lands in
84461+ an unmapped area, causing a crash and triggering grsecurity's
84462+ anti-bruteforcing logic.
84463+
84464+config GRKERNSEC_PROC_MEMMAP
84465+ bool "Harden ASLR against information leaks and entropy reduction"
84466+ default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
84467+ depends on PAX_NOEXEC || PAX_ASLR
84468+ help
84469+ If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
84470+ give no information about the addresses of its mappings if
84471+ PaX features that rely on random addresses are enabled on the task.
84472+ In addition to sanitizing this information and disabling other
84473+ dangerous sources of information, this option causes reads of sensitive
84474+ /proc/<pid> entries where the file descriptor was opened in a different
84475+ task than the one performing the read. Such attempts are logged.
84476+ This option also limits argv/env strings for suid/sgid binaries
84477+ to 512KB to prevent a complete exhaustion of the stack entropy provided
84478+ by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
84479+ binaries to prevent alternative mmap layouts from being abused.
84480+
84481+ If you use PaX it is essential that you say Y here as it closes up
84482+ several holes that make full ASLR useless locally.
84483+
84484+
84485+config GRKERNSEC_KSTACKOVERFLOW
84486+ bool "Prevent kernel stack overflows"
84487+ default y if GRKERNSEC_CONFIG_AUTO
84488+ depends on !IA64 && 64BIT
84489+ help
84490+ If you say Y here, the kernel's process stacks will be allocated
84491+ with vmalloc instead of the kernel's default allocator. This
84492+ introduces guard pages that in combination with the alloca checking
84493+ of the STACKLEAK feature prevents all forms of kernel process stack
84494+ overflow abuse. Note that this is different from kernel stack
84495+ buffer overflows.
84496+
84497+config GRKERNSEC_BRUTE
84498+ bool "Deter exploit bruteforcing"
84499+ default y if GRKERNSEC_CONFIG_AUTO
84500+ help
84501+ If you say Y here, attempts to bruteforce exploits against forking
84502+ daemons such as apache or sshd, as well as against suid/sgid binaries
84503+ will be deterred. When a child of a forking daemon is killed by PaX
84504+ or crashes due to an illegal instruction or other suspicious signal,
84505+ the parent process will be delayed 30 seconds upon every subsequent
84506+ fork until the administrator is able to assess the situation and
84507+ restart the daemon.
84508+ In the suid/sgid case, the attempt is logged, the user has all their
84509+ existing instances of the suid/sgid binary terminated and will
84510+ be unable to execute any suid/sgid binaries for 15 minutes.
84511+
84512+ It is recommended that you also enable signal logging in the auditing
84513+ section so that logs are generated when a process triggers a suspicious
84514+ signal.
84515+ If the sysctl option is enabled, a sysctl option with name
84516+ "deter_bruteforce" is created.
84517+
84518+config GRKERNSEC_MODHARDEN
84519+ bool "Harden module auto-loading"
84520+ default y if GRKERNSEC_CONFIG_AUTO
84521+ depends on MODULES
84522+ help
84523+ If you say Y here, module auto-loading in response to use of some
84524+ feature implemented by an unloaded module will be restricted to
84525+ root users. Enabling this option helps defend against attacks
84526+ by unprivileged users who abuse the auto-loading behavior to
84527+ cause a vulnerable module to load that is then exploited.
84528+
84529+ If this option prevents a legitimate use of auto-loading for a
84530+ non-root user, the administrator can execute modprobe manually
84531+ with the exact name of the module mentioned in the alert log.
84532+ Alternatively, the administrator can add the module to the list
84533+ of modules loaded at boot by modifying init scripts.
84534+
84535+ Modification of init scripts will most likely be needed on
84536+ Ubuntu servers with encrypted home directory support enabled,
84537+ as the first non-root user logging in will cause the ecb(aes),
84538+ ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
84539+
84540+config GRKERNSEC_HIDESYM
84541+ bool "Hide kernel symbols"
84542+ default y if GRKERNSEC_CONFIG_AUTO
84543+ select PAX_USERCOPY_SLABS
84544+ help
84545+ If you say Y here, getting information on loaded modules, and
84546+ displaying all kernel symbols through a syscall will be restricted
84547+ to users with CAP_SYS_MODULE. For software compatibility reasons,
84548+ /proc/kallsyms will be restricted to the root user. The RBAC
84549+ system can hide that entry even from root.
84550+
84551+ This option also prevents leaking of kernel addresses through
84552+ several /proc entries.
84553+
84554+ Note that this option is only effective provided the following
84555+ conditions are met:
84556+ 1) The kernel using grsecurity is not precompiled by some distribution
84557+ 2) You have also enabled GRKERNSEC_DMESG
84558+ 3) You are using the RBAC system and hiding other files such as your
84559+ kernel image and System.map. Alternatively, enabling this option
84560+ causes the permissions on /boot, /lib/modules, and the kernel
84561+ source directory to change at compile time to prevent
84562+ reading by non-root users.
84563+ If the above conditions are met, this option will aid in providing a
84564+ useful protection against local kernel exploitation of overflows
84565+ and arbitrary read/write vulnerabilities.
84566+
84567+ It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
84568+ in addition to this feature.
84569+
84570+config GRKERNSEC_RANDSTRUCT
84571+ bool "Randomize layout of sensitive kernel structures"
84572+ default y if GRKERNSEC_CONFIG_AUTO
84573+ select GRKERNSEC_HIDESYM
84574+ select MODVERSIONS if MODULES
84575+ help
84576+ If you say Y here, the layouts of a number of sensitive kernel
84577+ structures (task, fs, cred, etc) and all structures composed entirely
84578+ of function pointers (aka "ops" structs) will be randomized at compile-time.
84579+ This can introduce the requirement of an additional infoleak
84580+ vulnerability for exploits targeting these structure types.
84581+
84582+ Enabling this feature will introduce some performance impact, slightly
84583+ increase memory usage, and prevent the use of forensic tools like
84584+ Volatility against the system (unless the kernel source tree isn't
84585+ cleaned after kernel installation).
84586+
84587+ The seed used for compilation is located at tools/gcc/randomize_layout_seed.h.
84588+ It remains after a make clean to allow for external modules to be compiled
84589+ with the existing seed and will be removed by a make mrproper or
84590+ make distclean.
84591+
84592+ Note that the implementation requires gcc 4.6.4. or newer. You may need
84593+ to install the supporting headers explicitly in addition to the normal
84594+ gcc package.
84595+
84596+config GRKERNSEC_RANDSTRUCT_PERFORMANCE
84597+ bool "Use cacheline-aware structure randomization"
84598+ depends on GRKERNSEC_RANDSTRUCT
84599+ default y if GRKERNSEC_CONFIG_PRIORITY_PERF
84600+ help
84601+ If you say Y here, the RANDSTRUCT randomization will make a best effort
84602+ at restricting randomization to cacheline-sized groups of elements. It
84603+ will further not randomize bitfields in structures. This reduces the
84604+ performance hit of RANDSTRUCT at the cost of weakened randomization.
84605+
84606+config GRKERNSEC_KERN_LOCKOUT
84607+ bool "Active kernel exploit response"
84608+ default y if GRKERNSEC_CONFIG_AUTO
84609+ depends on X86 || ARM || PPC || SPARC
84610+ help
84611+ If you say Y here, when a PaX alert is triggered due to suspicious
84612+ activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
84613+ or an OOPS occurs due to bad memory accesses, instead of just
84614+ terminating the offending process (and potentially allowing
84615+ a subsequent exploit from the same user), we will take one of two
84616+ actions:
84617+ If the user was root, we will panic the system
84618+ If the user was non-root, we will log the attempt, terminate
84619+ all processes owned by the user, then prevent them from creating
84620+ any new processes until the system is restarted
84621+ This deters repeated kernel exploitation/bruteforcing attempts
84622+ and is useful for later forensics.
84623+
84624+config GRKERNSEC_OLD_ARM_USERLAND
84625+ bool "Old ARM userland compatibility"
84626+ depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
84627+ help
84628+ If you say Y here, stubs of executable code to perform such operations
84629+ as "compare-exchange" will be placed at fixed locations in the ARM vector
84630+ table. This is unfortunately needed for old ARM userland meant to run
84631+ across a wide range of processors. Without this option enabled,
84632+ the get_tls and data memory barrier stubs will be emulated by the kernel,
84633+ which is enough for Linaro userlands or other userlands designed for v6
84634+ and newer ARM CPUs. It's recommended that you try without this option enabled
84635+ first, and only enable it if your userland does not boot (it will likely fail
84636+ at init time).
84637+
84638+endmenu
84639+menu "Role Based Access Control Options"
84640+depends on GRKERNSEC
84641+
84642+config GRKERNSEC_RBAC_DEBUG
84643+ bool
84644+
84645+config GRKERNSEC_NO_RBAC
84646+ bool "Disable RBAC system"
84647+ help
84648+ If you say Y here, the /dev/grsec device will be removed from the kernel,
84649+ preventing the RBAC system from being enabled. You should only say Y
84650+ here if you have no intention of using the RBAC system, so as to prevent
84651+ an attacker with root access from misusing the RBAC system to hide files
84652+ and processes when loadable module support and /dev/[k]mem have been
84653+ locked down.
84654+
84655+config GRKERNSEC_ACL_HIDEKERN
84656+ bool "Hide kernel processes"
84657+ help
84658+ If you say Y here, all kernel threads will be hidden to all
84659+ processes but those whose subject has the "view hidden processes"
84660+ flag.
84661+
84662+config GRKERNSEC_ACL_MAXTRIES
84663+ int "Maximum tries before password lockout"
84664+ default 3
84665+ help
84666+ This option enforces the maximum number of times a user can attempt
84667+ to authorize themselves with the grsecurity RBAC system before being
84668+ denied the ability to attempt authorization again for a specified time.
84669+ The lower the number, the harder it will be to brute-force a password.
84670+
84671+config GRKERNSEC_ACL_TIMEOUT
84672+ int "Time to wait after max password tries, in seconds"
84673+ default 30
84674+ help
84675+ This option specifies the time the user must wait after attempting to
84676+ authorize to the RBAC system with the maximum number of invalid
84677+ passwords. The higher the number, the harder it will be to brute-force
84678+ a password.
84679+
84680+endmenu
84681+menu "Filesystem Protections"
84682+depends on GRKERNSEC
84683+
84684+config GRKERNSEC_PROC
84685+ bool "Proc restrictions"
84686+ default y if GRKERNSEC_CONFIG_AUTO
84687+ help
84688+ If you say Y here, the permissions of the /proc filesystem
84689+ will be altered to enhance system security and privacy. You MUST
84690+ choose either a user only restriction or a user and group restriction.
84691+ Depending upon the option you choose, you can either restrict users to
84692+ see only the processes they themselves run, or choose a group that can
84693+ view all processes and files normally restricted to root if you choose
84694+ the "restrict to user only" option. NOTE: If you're running identd or
84695+ ntpd as a non-root user, you will have to run it as the group you
84696+ specify here.
84697+
84698+config GRKERNSEC_PROC_USER
84699+ bool "Restrict /proc to user only"
84700+ depends on GRKERNSEC_PROC
84701+ help
84702+ If you say Y here, non-root users will only be able to view their own
84703+ processes, and restricts them from viewing network-related information,
84704+ and viewing kernel symbol and module information.
84705+
84706+config GRKERNSEC_PROC_USERGROUP
84707+ bool "Allow special group"
84708+ default y if GRKERNSEC_CONFIG_AUTO
84709+ depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
84710+ help
84711+ If you say Y here, you will be able to select a group that will be
84712+ able to view all processes and network-related information. If you've
84713+ enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
84714+ remain hidden. This option is useful if you want to run identd as
84715+ a non-root user. The group you select may also be chosen at boot time
84716+ via "grsec_proc_gid=" on the kernel commandline.
84717+
84718+config GRKERNSEC_PROC_GID
84719+ int "GID for special group"
84720+ depends on GRKERNSEC_PROC_USERGROUP
84721+ default 1001
84722+
84723+config GRKERNSEC_PROC_ADD
84724+ bool "Additional restrictions"
84725+ default y if GRKERNSEC_CONFIG_AUTO
84726+ depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
84727+ help
84728+ If you say Y here, additional restrictions will be placed on
84729+ /proc that keep normal users from viewing device information and
84730+ slabinfo information that could be useful for exploits.
84731+
84732+config GRKERNSEC_LINK
84733+ bool "Linking restrictions"
84734+ default y if GRKERNSEC_CONFIG_AUTO
84735+ help
84736+ If you say Y here, /tmp race exploits will be prevented, since users
84737+ will no longer be able to follow symlinks owned by other users in
84738+ world-writable +t directories (e.g. /tmp), unless the owner of the
84739+ symlink is the owner of the directory. users will also not be
84740+ able to hardlink to files they do not own. If the sysctl option is
84741+ enabled, a sysctl option with name "linking_restrictions" is created.
84742+
84743+config GRKERNSEC_SYMLINKOWN
84744+ bool "Kernel-enforced SymlinksIfOwnerMatch"
84745+ default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
84746+ help
84747+ Apache's SymlinksIfOwnerMatch option has an inherent race condition
84748+ that prevents it from being used as a security feature. As Apache
84749+ verifies the symlink by performing a stat() against the target of
84750+ the symlink before it is followed, an attacker can setup a symlink
84751+ to point to a same-owned file, then replace the symlink with one
84752+ that targets another user's file just after Apache "validates" the
84753+ symlink -- a classic TOCTOU race. If you say Y here, a complete,
84754+ race-free replacement for Apache's "SymlinksIfOwnerMatch" option
84755+ will be in place for the group you specify. If the sysctl option
84756+ is enabled, a sysctl option with name "enforce_symlinksifowner" is
84757+ created.
84758+
84759+config GRKERNSEC_SYMLINKOWN_GID
84760+ int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
84761+ depends on GRKERNSEC_SYMLINKOWN
84762+ default 1006
84763+ help
84764+ Setting this GID determines what group kernel-enforced
84765+ SymlinksIfOwnerMatch will be enabled for. If the sysctl option
84766+ is enabled, a sysctl option with name "symlinkown_gid" is created.
84767+
84768+config GRKERNSEC_FIFO
84769+ bool "FIFO restrictions"
84770+ default y if GRKERNSEC_CONFIG_AUTO
84771+ help
84772+ If you say Y here, users will not be able to write to FIFOs they don't
84773+ own in world-writable +t directories (e.g. /tmp), unless the owner of
84774+ the FIFO is the same owner of the directory it's held in. If the sysctl
84775+ option is enabled, a sysctl option with name "fifo_restrictions" is
84776+ created.
84777+
84778+config GRKERNSEC_SYSFS_RESTRICT
84779+ bool "Sysfs/debugfs restriction"
84780+ default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
84781+ depends on SYSFS
84782+ help
84783+ If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
84784+ any filesystem normally mounted under it (e.g. debugfs) will be
84785+ mostly accessible only by root. These filesystems generally provide access
84786+ to hardware and debug information that isn't appropriate for unprivileged
84787+ users of the system. Sysfs and debugfs have also become a large source
84788+ of new vulnerabilities, ranging from infoleaks to local compromise.
84789+ There has been very little oversight with an eye toward security involved
84790+ in adding new exporters of information to these filesystems, so their
84791+ use is discouraged.
84792+ For reasons of compatibility, a few directories have been whitelisted
84793+ for access by non-root users:
84794+ /sys/fs/selinux
84795+ /sys/fs/fuse
84796+ /sys/devices/system/cpu
84797+
84798+config GRKERNSEC_ROFS
84799+ bool "Runtime read-only mount protection"
84800+ depends on SYSCTL
84801+ help
84802+ If you say Y here, a sysctl option with name "romount_protect" will
84803+ be created. By setting this option to 1 at runtime, filesystems
84804+ will be protected in the following ways:
84805+ * No new writable mounts will be allowed
84806+ * Existing read-only mounts won't be able to be remounted read/write
84807+ * Write operations will be denied on all block devices
84808+ This option acts independently of grsec_lock: once it is set to 1,
84809+ it cannot be turned off. Therefore, please be mindful of the resulting
84810+ behavior if this option is enabled in an init script on a read-only
84811+ filesystem.
84812+ Also be aware that as with other root-focused features, GRKERNSEC_KMEM
84813+ and GRKERNSEC_IO should be enabled and module loading disabled via
84814+ config or at runtime.
84815+ This feature is mainly intended for secure embedded systems.
84816+
84817+
84818+config GRKERNSEC_DEVICE_SIDECHANNEL
84819+ bool "Eliminate stat/notify-based device sidechannels"
84820+ default y if GRKERNSEC_CONFIG_AUTO
84821+ help
84822+ If you say Y here, timing analyses on block or character
84823+ devices like /dev/ptmx using stat or inotify/dnotify/fanotify
84824+ will be thwarted for unprivileged users. If a process without
84825+ CAP_MKNOD stats such a device, the last access and last modify times
84826+ will match the device's create time. No access or modify events
84827+ will be triggered through inotify/dnotify/fanotify for such devices.
84828+ This feature will prevent attacks that may at a minimum
84829+ allow an attacker to determine the administrator's password length.
84830+
84831+config GRKERNSEC_CHROOT
84832+ bool "Chroot jail restrictions"
84833+ default y if GRKERNSEC_CONFIG_AUTO
84834+ help
84835+ If you say Y here, you will be able to choose several options that will
84836+ make breaking out of a chrooted jail much more difficult. If you
84837+ encounter no software incompatibilities with the following options, it
84838+ is recommended that you enable each one.
84839+
84840+ Note that the chroot restrictions are not intended to apply to "chroots"
84841+ to directories that are simple bind mounts of the global root filesystem.
84842+ For several other reasons, a user shouldn't expect any significant
84843+ security by performing such a chroot.
84844+
84845+config GRKERNSEC_CHROOT_MOUNT
84846+ bool "Deny mounts"
84847+ default y if GRKERNSEC_CONFIG_AUTO
84848+ depends on GRKERNSEC_CHROOT
84849+ help
84850+ If you say Y here, processes inside a chroot will not be able to
84851+ mount or remount filesystems. If the sysctl option is enabled, a
84852+ sysctl option with name "chroot_deny_mount" is created.
84853+
84854+config GRKERNSEC_CHROOT_DOUBLE
84855+ bool "Deny double-chroots"
84856+ default y if GRKERNSEC_CONFIG_AUTO
84857+ depends on GRKERNSEC_CHROOT
84858+ help
84859+ If you say Y here, processes inside a chroot will not be able to chroot
84860+ again outside the chroot. This is a widely used method of breaking
84861+ out of a chroot jail and should not be allowed. If the sysctl
84862+ option is enabled, a sysctl option with name
84863+ "chroot_deny_chroot" is created.
84864+
84865+config GRKERNSEC_CHROOT_PIVOT
84866+ bool "Deny pivot_root in chroot"
84867+ default y if GRKERNSEC_CONFIG_AUTO
84868+ depends on GRKERNSEC_CHROOT
84869+ help
84870+ If you say Y here, processes inside a chroot will not be able to use
84871+ a function called pivot_root() that was introduced in Linux 2.3.41. It
84872+ works similar to chroot in that it changes the root filesystem. This
84873+ function could be misused in a chrooted process to attempt to break out
84874+ of the chroot, and therefore should not be allowed. If the sysctl
84875+ option is enabled, a sysctl option with name "chroot_deny_pivot" is
84876+ created.
84877+
84878+config GRKERNSEC_CHROOT_CHDIR
84879+ bool "Enforce chdir(\"/\") on all chroots"
84880+ default y if GRKERNSEC_CONFIG_AUTO
84881+ depends on GRKERNSEC_CHROOT
84882+ help
84883+ If you say Y here, the current working directory of all newly-chrooted
84884+ applications will be set to the the root directory of the chroot.
84885+ The man page on chroot(2) states:
84886+ Note that this call does not change the current working
84887+ directory, so that `.' can be outside the tree rooted at
84888+ `/'. In particular, the super-user can escape from a
84889+ `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
84890+
84891+ It is recommended that you say Y here, since it's not known to break
84892+ any software. If the sysctl option is enabled, a sysctl option with
84893+ name "chroot_enforce_chdir" is created.
84894+
84895+config GRKERNSEC_CHROOT_CHMOD
84896+ bool "Deny (f)chmod +s"
84897+ default y if GRKERNSEC_CONFIG_AUTO
84898+ depends on GRKERNSEC_CHROOT
84899+ help
84900+ If you say Y here, processes inside a chroot will not be able to chmod
84901+ or fchmod files to make them have suid or sgid bits. This protects
84902+ against another published method of breaking a chroot. If the sysctl
84903+ option is enabled, a sysctl option with name "chroot_deny_chmod" is
84904+ created.
84905+
84906+config GRKERNSEC_CHROOT_FCHDIR
84907+ bool "Deny fchdir and fhandle out of chroot"
84908+ default y if GRKERNSEC_CONFIG_AUTO
84909+ depends on GRKERNSEC_CHROOT
84910+ help
84911+ If you say Y here, a well-known method of breaking chroots by fchdir'ing
84912+ to a file descriptor of the chrooting process that points to a directory
84913+ outside the filesystem will be stopped. Additionally, this option prevents
84914+ use of the recently-created syscall for opening files by a guessable "file
84915+ handle" inside a chroot. If the sysctl option is enabled, a sysctl option
84916+ with name "chroot_deny_fchdir" is created.
84917+
84918+config GRKERNSEC_CHROOT_MKNOD
84919+ bool "Deny mknod"
84920+ default y if GRKERNSEC_CONFIG_AUTO
84921+ depends on GRKERNSEC_CHROOT
84922+ help
84923+ If you say Y here, processes inside a chroot will not be allowed to
84924+ mknod. The problem with using mknod inside a chroot is that it
84925+ would allow an attacker to create a device entry that is the same
84926+ as one on the physical root of your system, which could range from
84927+ anything from the console device to a device for your harddrive (which
84928+ they could then use to wipe the drive or steal data). It is recommended
84929+ that you say Y here, unless you run into software incompatibilities.
84930+ If the sysctl option is enabled, a sysctl option with name
84931+ "chroot_deny_mknod" is created.
84932+
84933+config GRKERNSEC_CHROOT_SHMAT
84934+ bool "Deny shmat() out of chroot"
84935+ default y if GRKERNSEC_CONFIG_AUTO
84936+ depends on GRKERNSEC_CHROOT
84937+ help
84938+ If you say Y here, processes inside a chroot will not be able to attach
84939+ to shared memory segments that were created outside of the chroot jail.
84940+ It is recommended that you say Y here. If the sysctl option is enabled,
84941+ a sysctl option with name "chroot_deny_shmat" is created.
84942+
84943+config GRKERNSEC_CHROOT_UNIX
84944+ bool "Deny access to abstract AF_UNIX sockets out of chroot"
84945+ default y if GRKERNSEC_CONFIG_AUTO
84946+ depends on GRKERNSEC_CHROOT
84947+ help
84948+ If you say Y here, processes inside a chroot will not be able to
84949+ connect to abstract (meaning not belonging to a filesystem) Unix
84950+ domain sockets that were bound outside of a chroot. It is recommended
84951+ that you say Y here. If the sysctl option is enabled, a sysctl option
84952+ with name "chroot_deny_unix" is created.
84953+
84954+config GRKERNSEC_CHROOT_FINDTASK
84955+ bool "Protect outside processes"
84956+ default y if GRKERNSEC_CONFIG_AUTO
84957+ depends on GRKERNSEC_CHROOT
84958+ help
84959+ If you say Y here, processes inside a chroot will not be able to
84960+ kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
84961+ getsid, or view any process outside of the chroot. If the sysctl
84962+ option is enabled, a sysctl option with name "chroot_findtask" is
84963+ created.
84964+
84965+config GRKERNSEC_CHROOT_NICE
84966+ bool "Restrict priority changes"
84967+ default y if GRKERNSEC_CONFIG_AUTO
84968+ depends on GRKERNSEC_CHROOT
84969+ help
84970+ If you say Y here, processes inside a chroot will not be able to raise
84971+ the priority of processes in the chroot, or alter the priority of
84972+ processes outside the chroot. This provides more security than simply
84973+ removing CAP_SYS_NICE from the process' capability set. If the
84974+ sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
84975+ is created.
84976+
84977+config GRKERNSEC_CHROOT_SYSCTL
84978+ bool "Deny sysctl writes"
84979+ default y if GRKERNSEC_CONFIG_AUTO
84980+ depends on GRKERNSEC_CHROOT
84981+ help
84982+ If you say Y here, an attacker in a chroot will not be able to
84983+ write to sysctl entries, either by sysctl(2) or through a /proc
84984+ interface. It is strongly recommended that you say Y here. If the
84985+ sysctl option is enabled, a sysctl option with name
84986+ "chroot_deny_sysctl" is created.
84987+
84988+config GRKERNSEC_CHROOT_RENAME
84989+ bool "Deny bad renames"
84990+ default y if GRKERNSEC_CONFIG_AUTO
84991+ depends on GRKERNSEC_CHROOT
84992+ help
84993+ If you say Y here, an attacker in a chroot will not be able to
84994+ abuse the ability to create double chroots to break out of the
84995+ chroot by exploiting a race condition between a rename of a directory
84996+ within a chroot against an open of a symlink with relative path
84997+ components. This feature will likewise prevent an accomplice outside
84998+ a chroot from enabling a user inside the chroot to break out and make
84999+ use of their credentials on the global filesystem. Enabling this
85000+ feature is essential to prevent root users from breaking out of a
85001+ chroot. If the sysctl option is enabled, a sysctl option with name
85002+ "chroot_deny_bad_rename" is created.
85003+
85004+config GRKERNSEC_CHROOT_CAPS
85005+ bool "Capability restrictions"
85006+ default y if GRKERNSEC_CONFIG_AUTO
85007+ depends on GRKERNSEC_CHROOT
85008+ help
85009+ If you say Y here, the capabilities on all processes within a
85010+ chroot jail will be lowered to stop module insertion, raw i/o,
85011+ system and net admin tasks, rebooting the system, modifying immutable
85012+ files, modifying IPC owned by another, and changing the system time.
85013+ This is left an option because it can break some apps. Disable this
85014+ if your chrooted apps are having problems performing those kinds of
85015+ tasks. If the sysctl option is enabled, a sysctl option with
85016+ name "chroot_caps" is created.
85017+
85018+config GRKERNSEC_CHROOT_INITRD
85019+ bool "Exempt initrd tasks from restrictions"
85020+ default y if GRKERNSEC_CONFIG_AUTO
85021+ depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
85022+ help
85023+ If you say Y here, tasks started prior to init will be exempted from
85024+ grsecurity's chroot restrictions. This option is mainly meant to
85025+ resolve Plymouth's performing privileged operations unnecessarily
85026+ in a chroot.
85027+
85028+endmenu
85029+menu "Kernel Auditing"
85030+depends on GRKERNSEC
85031+
85032+config GRKERNSEC_AUDIT_GROUP
85033+ bool "Single group for auditing"
85034+ help
85035+ If you say Y here, the exec and chdir logging features will only operate
85036+ on a group you specify. This option is recommended if you only want to
85037+ watch certain users instead of having a large amount of logs from the
85038+ entire system. If the sysctl option is enabled, a sysctl option with
85039+ name "audit_group" is created.
85040+
85041+config GRKERNSEC_AUDIT_GID
85042+ int "GID for auditing"
85043+ depends on GRKERNSEC_AUDIT_GROUP
85044+ default 1007
85045+
85046+config GRKERNSEC_EXECLOG
85047+ bool "Exec logging"
85048+ help
85049+ If you say Y here, all execve() calls will be logged (since the
85050+ other exec*() calls are frontends to execve(), all execution
85051+ will be logged). Useful for shell-servers that like to keep track
85052+ of their users. If the sysctl option is enabled, a sysctl option with
85053+ name "exec_logging" is created.
85054+ WARNING: This option when enabled will produce a LOT of logs, especially
85055+ on an active system.
85056+
85057+config GRKERNSEC_RESLOG
85058+ bool "Resource logging"
85059+ default y if GRKERNSEC_CONFIG_AUTO
85060+ help
85061+ If you say Y here, all attempts to overstep resource limits will
85062+ be logged with the resource name, the requested size, and the current
85063+ limit. It is highly recommended that you say Y here. If the sysctl
85064+ option is enabled, a sysctl option with name "resource_logging" is
85065+ created. If the RBAC system is enabled, the sysctl value is ignored.
85066+
85067+config GRKERNSEC_CHROOT_EXECLOG
85068+ bool "Log execs within chroot"
85069+ help
85070+ If you say Y here, all executions inside a chroot jail will be logged
85071+ to syslog. This can cause a large amount of logs if certain
85072+ applications (eg. djb's daemontools) are installed on the system, and
85073+ is therefore left as an option. If the sysctl option is enabled, a
85074+ sysctl option with name "chroot_execlog" is created.
85075+
85076+config GRKERNSEC_AUDIT_PTRACE
85077+ bool "Ptrace logging"
85078+ help
85079+ If you say Y here, all attempts to attach to a process via ptrace
85080+ will be logged. If the sysctl option is enabled, a sysctl option
85081+ with name "audit_ptrace" is created.
85082+
85083+config GRKERNSEC_AUDIT_CHDIR
85084+ bool "Chdir logging"
85085+ help
85086+ If you say Y here, all chdir() calls will be logged. If the sysctl
85087+ option is enabled, a sysctl option with name "audit_chdir" is created.
85088+
85089+config GRKERNSEC_AUDIT_MOUNT
85090+ bool "(Un)Mount logging"
85091+ help
85092+ If you say Y here, all mounts and unmounts will be logged. If the
85093+ sysctl option is enabled, a sysctl option with name "audit_mount" is
85094+ created.
85095+
85096+config GRKERNSEC_SIGNAL
85097+ bool "Signal logging"
85098+ default y if GRKERNSEC_CONFIG_AUTO
85099+ help
85100+ If you say Y here, certain important signals will be logged, such as
85101+ SIGSEGV, which will as a result inform you of when a error in a program
85102+ occurred, which in some cases could mean a possible exploit attempt.
85103+ If the sysctl option is enabled, a sysctl option with name
85104+ "signal_logging" is created.
85105+
85106+config GRKERNSEC_FORKFAIL
85107+ bool "Fork failure logging"
85108+ help
85109+ If you say Y here, all failed fork() attempts will be logged.
85110+ This could suggest a fork bomb, or someone attempting to overstep
85111+ their process limit. If the sysctl option is enabled, a sysctl option
85112+ with name "forkfail_logging" is created.
85113+
85114+config GRKERNSEC_TIME
85115+ bool "Time change logging"
85116+ default y if GRKERNSEC_CONFIG_AUTO
85117+ help
85118+ If you say Y here, any changes of the system clock will be logged.
85119+ If the sysctl option is enabled, a sysctl option with name
85120+ "timechange_logging" is created.
85121+
85122+config GRKERNSEC_PROC_IPADDR
85123+ bool "/proc/<pid>/ipaddr support"
85124+ default y if GRKERNSEC_CONFIG_AUTO
85125+ help
85126+ If you say Y here, a new entry will be added to each /proc/<pid>
85127+ directory that contains the IP address of the person using the task.
85128+ The IP is carried across local TCP and AF_UNIX stream sockets.
85129+ This information can be useful for IDS/IPSes to perform remote response
85130+ to a local attack. The entry is readable by only the owner of the
85131+ process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
85132+ the RBAC system), and thus does not create privacy concerns.
85133+
85134+config GRKERNSEC_RWXMAP_LOG
85135+ bool 'Denied RWX mmap/mprotect logging'
85136+ default y if GRKERNSEC_CONFIG_AUTO
85137+ depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
85138+ help
85139+ If you say Y here, calls to mmap() and mprotect() with explicit
85140+ usage of PROT_WRITE and PROT_EXEC together will be logged when
85141+ denied by the PAX_MPROTECT feature. This feature will also
85142+ log other problematic scenarios that can occur when PAX_MPROTECT
85143+ is enabled on a binary, like textrels and PT_GNU_STACK. If the
85144+ sysctl option is enabled, a sysctl option with name "rwxmap_logging"
85145+ is created.
85146+
85147+endmenu
85148+
85149+menu "Executable Protections"
85150+depends on GRKERNSEC
85151+
85152+config GRKERNSEC_DMESG
85153+ bool "Dmesg(8) restriction"
85154+ default y if GRKERNSEC_CONFIG_AUTO
85155+ help
85156+ If you say Y here, non-root users will not be able to use dmesg(8)
85157+ to view the contents of the kernel's circular log buffer.
85158+ The kernel's log buffer often contains kernel addresses and other
85159+ identifying information useful to an attacker in fingerprinting a
85160+ system for a targeted exploit.
85161+ If the sysctl option is enabled, a sysctl option with name "dmesg" is
85162+ created.
85163+
85164+config GRKERNSEC_HARDEN_PTRACE
85165+ bool "Deter ptrace-based process snooping"
85166+ default y if GRKERNSEC_CONFIG_AUTO
85167+ help
85168+ If you say Y here, TTY sniffers and other malicious monitoring
85169+ programs implemented through ptrace will be defeated. If you
85170+ have been using the RBAC system, this option has already been
85171+ enabled for several years for all users, with the ability to make
85172+ fine-grained exceptions.
85173+
85174+ This option only affects the ability of non-root users to ptrace
85175+ processes that are not a descendent of the ptracing process.
85176+ This means that strace ./binary and gdb ./binary will still work,
85177+ but attaching to arbitrary processes will not. If the sysctl
85178+ option is enabled, a sysctl option with name "harden_ptrace" is
85179+ created.
85180+
85181+config GRKERNSEC_PTRACE_READEXEC
85182+ bool "Require read access to ptrace sensitive binaries"
85183+ default y if GRKERNSEC_CONFIG_AUTO
85184+ help
85185+ If you say Y here, unprivileged users will not be able to ptrace unreadable
85186+ binaries. This option is useful in environments that
85187+ remove the read bits (e.g. file mode 4711) from suid binaries to
85188+ prevent infoleaking of their contents. This option adds
85189+ consistency to the use of that file mode, as the binary could normally
85190+ be read out when run without privileges while ptracing.
85191+
85192+ If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
85193+ is created.
85194+
85195+config GRKERNSEC_SETXID
85196+ bool "Enforce consistent multithreaded privileges"
85197+ default y if GRKERNSEC_CONFIG_AUTO
85198+ depends on (X86 || SPARC64 || PPC || ARM || MIPS)
85199+ help
85200+ If you say Y here, a change from a root uid to a non-root uid
85201+ in a multithreaded application will cause the resulting uids,
85202+ gids, supplementary groups, and capabilities in that thread
85203+ to be propagated to the other threads of the process. In most
85204+ cases this is unnecessary, as glibc will emulate this behavior
85205+ on behalf of the application. Other libcs do not act in the
85206+ same way, allowing the other threads of the process to continue
85207+ running with root privileges. If the sysctl option is enabled,
85208+ a sysctl option with name "consistent_setxid" is created.
85209+
85210+config GRKERNSEC_HARDEN_IPC
85211+ bool "Disallow access to overly-permissive IPC objects"
85212+ default y if GRKERNSEC_CONFIG_AUTO
85213+ depends on SYSVIPC
85214+ help
85215+ If you say Y here, access to overly-permissive IPC objects (shared
85216+ memory, message queues, and semaphores) will be denied for processes
85217+ given the following criteria beyond normal permission checks:
85218+ 1) If the IPC object is world-accessible and the euid doesn't match
85219+ that of the creator or current uid for the IPC object
85220+ 2) If the IPC object is group-accessible and the egid doesn't
85221+ match that of the creator or current gid for the IPC object
85222+ It's a common error to grant too much permission to these objects,
85223+ with impact ranging from denial of service and information leaking to
85224+ privilege escalation. This feature was developed in response to
85225+ research by Tim Brown:
85226+ http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
85227+ who found hundreds of such insecure usages. Processes with
85228+ CAP_IPC_OWNER are still permitted to access these IPC objects.
85229+ If the sysctl option is enabled, a sysctl option with name
85230+ "harden_ipc" is created.
85231+
85232+config GRKERNSEC_TPE
85233+ bool "Trusted Path Execution (TPE)"
85234+ default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
85235+ help
85236+ If you say Y here, you will be able to choose a gid to add to the
85237+ supplementary groups of users you want to mark as "untrusted."
85238+ These users will not be able to execute any files that are not in
85239+ root-owned directories writable only by root. If the sysctl option
85240+ is enabled, a sysctl option with name "tpe" is created.
85241+
85242+config GRKERNSEC_TPE_ALL
85243+ bool "Partially restrict all non-root users"
85244+ depends on GRKERNSEC_TPE
85245+ help
85246+ If you say Y here, all non-root users will be covered under
85247+ a weaker TPE restriction. This is separate from, and in addition to,
85248+ the main TPE options that you have selected elsewhere. Thus, if a
85249+ "trusted" GID is chosen, this restriction applies to even that GID.
85250+ Under this restriction, all non-root users will only be allowed to
85251+ execute files in directories they own that are not group or
85252+ world-writable, or in directories owned by root and writable only by
85253+ root. If the sysctl option is enabled, a sysctl option with name
85254+ "tpe_restrict_all" is created.
85255+
85256+config GRKERNSEC_TPE_INVERT
85257+ bool "Invert GID option"
85258+ depends on GRKERNSEC_TPE
85259+ help
85260+ If you say Y here, the group you specify in the TPE configuration will
85261+ decide what group TPE restrictions will be *disabled* for. This
85262+ option is useful if you want TPE restrictions to be applied to most
85263+ users on the system. If the sysctl option is enabled, a sysctl option
85264+ with name "tpe_invert" is created. Unlike other sysctl options, this
85265+ entry will default to on for backward-compatibility.
85266+
85267+config GRKERNSEC_TPE_GID
85268+ int
85269+ default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
85270+ default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
85271+
85272+config GRKERNSEC_TPE_UNTRUSTED_GID
85273+ int "GID for TPE-untrusted users"
85274+ depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
85275+ default 1005
85276+ help
85277+ Setting this GID determines what group TPE restrictions will be
85278+ *enabled* for. If the sysctl option is enabled, a sysctl option
85279+ with name "tpe_gid" is created.
85280+
85281+config GRKERNSEC_TPE_TRUSTED_GID
85282+ int "GID for TPE-trusted users"
85283+ depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
85284+ default 1005
85285+ help
85286+ Setting this GID determines what group TPE restrictions will be
85287+ *disabled* for. If the sysctl option is enabled, a sysctl option
85288+ with name "tpe_gid" is created.
85289+
85290+endmenu
85291+menu "Network Protections"
85292+depends on GRKERNSEC
85293+
85294+config GRKERNSEC_BLACKHOLE
85295+ bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
85296+ default y if GRKERNSEC_CONFIG_AUTO
85297+ depends on NET
85298+ help
85299+ If you say Y here, neither TCP resets nor ICMP
85300+ destination-unreachable packets will be sent in response to packets
85301+ sent to ports for which no associated listening process exists.
85302+ It will also prevent the sending of ICMP protocol unreachable packets
85303+ in response to packets with unknown protocols.
85304+ This feature supports both IPV4 and IPV6 and exempts the
85305+ loopback interface from blackholing. Enabling this feature
85306+ makes a host more resilient to DoS attacks and reduces network
85307+ visibility against scanners.
85308+
85309+ The blackhole feature as-implemented is equivalent to the FreeBSD
85310+ blackhole feature, as it prevents RST responses to all packets, not
85311+ just SYNs. Under most application behavior this causes no
85312+ problems, but applications (like haproxy) may not close certain
85313+ connections in a way that cleanly terminates them on the remote
85314+ end, leaving the remote host in LAST_ACK state. Because of this
85315+ side-effect and to prevent intentional LAST_ACK DoSes, this
85316+ feature also adds automatic mitigation against such attacks.
85317+ The mitigation drastically reduces the amount of time a socket
85318+ can spend in LAST_ACK state. If you're using haproxy and not
85319+ all servers it connects to have this option enabled, consider
85320+ disabling this feature on the haproxy host.
85321+
85322+ If the sysctl option is enabled, two sysctl options with names
85323+ "ip_blackhole" and "lastack_retries" will be created.
85324+ While "ip_blackhole" takes the standard zero/non-zero on/off
85325+ toggle, "lastack_retries" uses the same kinds of values as
85326+ "tcp_retries1" and "tcp_retries2". The default value of 4
85327+ prevents a socket from lasting more than 45 seconds in LAST_ACK
85328+ state.
85329+
85330+config GRKERNSEC_NO_SIMULT_CONNECT
85331+ bool "Disable TCP Simultaneous Connect"
85332+ default y if GRKERNSEC_CONFIG_AUTO
85333+ depends on NET
85334+ help
85335+ If you say Y here, a feature by Willy Tarreau will be enabled that
85336+ removes a weakness in Linux's strict implementation of TCP that
85337+ allows two clients to connect to each other without either entering
85338+ a listening state. The weakness allows an attacker to easily prevent
85339+ a client from connecting to a known server provided the source port
85340+ for the connection is guessed correctly.
85341+
85342+ As the weakness could be used to prevent an antivirus or IPS from
85343+ fetching updates, or prevent an SSL gateway from fetching a CRL,
85344+ it should be eliminated by enabling this option. Though Linux is
85345+ one of few operating systems supporting simultaneous connect, it
85346+ has no legitimate use in practice and is rarely supported by firewalls.
85347+
85348+config GRKERNSEC_SOCKET
85349+ bool "Socket restrictions"
85350+ depends on NET
85351+ help
85352+ If you say Y here, you will be able to choose from several options.
85353+ If you assign a GID on your system and add it to the supplementary
85354+ groups of users you want to restrict socket access to, this patch
85355+ will perform up to three things, based on the option(s) you choose.
85356+
85357+config GRKERNSEC_SOCKET_ALL
85358+ bool "Deny any sockets to group"
85359+ depends on GRKERNSEC_SOCKET
85360+ help
85361+ If you say Y here, you will be able to choose a GID of whose users will
85362+ be unable to connect to other hosts from your machine or run server
85363+ applications from your machine. If the sysctl option is enabled, a
85364+ sysctl option with name "socket_all" is created.
85365+
85366+config GRKERNSEC_SOCKET_ALL_GID
85367+ int "GID to deny all sockets for"
85368+ depends on GRKERNSEC_SOCKET_ALL
85369+ default 1004
85370+ help
85371+ Here you can choose the GID to disable socket access for. Remember to
85372+ add the users you want socket access disabled for to the GID
85373+ specified here. If the sysctl option is enabled, a sysctl option
85374+ with name "socket_all_gid" is created.
85375+
85376+config GRKERNSEC_SOCKET_CLIENT
85377+ bool "Deny client sockets to group"
85378+ depends on GRKERNSEC_SOCKET
85379+ help
85380+ If you say Y here, you will be able to choose a GID of whose users will
85381+ be unable to connect to other hosts from your machine, but will be
85382+ able to run servers. If this option is enabled, all users in the group
85383+ you specify will have to use passive mode when initiating ftp transfers
85384+ from the shell on your machine. If the sysctl option is enabled, a
85385+ sysctl option with name "socket_client" is created.
85386+
85387+config GRKERNSEC_SOCKET_CLIENT_GID
85388+ int "GID to deny client sockets for"
85389+ depends on GRKERNSEC_SOCKET_CLIENT
85390+ default 1003
85391+ help
85392+ Here you can choose the GID to disable client socket access for.
85393+ Remember to add the users you want client socket access disabled for to
85394+ the GID specified here. If the sysctl option is enabled, a sysctl
85395+ option with name "socket_client_gid" is created.
85396+
85397+config GRKERNSEC_SOCKET_SERVER
85398+ bool "Deny server sockets to group"
85399+ depends on GRKERNSEC_SOCKET
85400+ help
85401+ If you say Y here, you will be able to choose a GID of whose users will
85402+ be unable to run server applications from your machine. If the sysctl
85403+ option is enabled, a sysctl option with name "socket_server" is created.
85404+
85405+config GRKERNSEC_SOCKET_SERVER_GID
85406+ int "GID to deny server sockets for"
85407+ depends on GRKERNSEC_SOCKET_SERVER
85408+ default 1002
85409+ help
85410+ Here you can choose the GID to disable server socket access for.
85411+ Remember to add the users you want server socket access disabled for to
85412+ the GID specified here. If the sysctl option is enabled, a sysctl
85413+ option with name "socket_server_gid" is created.
85414+
85415+endmenu
85416+
85417+menu "Physical Protections"
85418+depends on GRKERNSEC
85419+
85420+config GRKERNSEC_DENYUSB
85421+ bool "Deny new USB connections after toggle"
85422+ default y if GRKERNSEC_CONFIG_AUTO
85423+ depends on SYSCTL && USB_SUPPORT
85424+ help
85425+ If you say Y here, a new sysctl option with name "deny_new_usb"
85426+ will be created. Setting its value to 1 will prevent any new
85427+ USB devices from being recognized by the OS. Any attempted USB
85428+ device insertion will be logged. This option is intended to be
85429+ used against custom USB devices designed to exploit vulnerabilities
85430+ in various USB device drivers.
85431+
85432+ For greatest effectiveness, this sysctl should be set after any
85433+ relevant init scripts. This option is safe to enable in distros
85434+ as each user can choose whether or not to toggle the sysctl.
85435+
85436+config GRKERNSEC_DENYUSB_FORCE
85437+ bool "Reject all USB devices not connected at boot"
85438+ select USB
85439+ depends on GRKERNSEC_DENYUSB
85440+ help
85441+ If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
85442+ that doesn't involve a sysctl entry. This option should only be
85443+ enabled if you're sure you want to deny all new USB connections
85444+ at runtime and don't want to modify init scripts. This should not
85445+ be enabled by distros. It forces the core USB code to be built
85446+ into the kernel image so that all devices connected at boot time
85447+ can be recognized and new USB device connections can be prevented
85448+ prior to init running.
85449+
85450+endmenu
85451+
85452+menu "Sysctl Support"
85453+depends on GRKERNSEC && SYSCTL
85454+
85455+config GRKERNSEC_SYSCTL
85456+ bool "Sysctl support"
85457+ default y if GRKERNSEC_CONFIG_AUTO
85458+ help
85459+ If you say Y here, you will be able to change the options that
85460+ grsecurity runs with at bootup, without having to recompile your
85461+ kernel. You can echo values to files in /proc/sys/kernel/grsecurity
85462+ to enable (1) or disable (0) various features. All the sysctl entries
85463+ are mutable until the "grsec_lock" entry is set to a non-zero value.
85464+ All features enabled in the kernel configuration are disabled at boot
85465+ if you do not say Y to the "Turn on features by default" option.
85466+ All options should be set at startup, and the grsec_lock entry should
85467+ be set to a non-zero value after all the options are set.
85468+ *THIS IS EXTREMELY IMPORTANT*
85469+
85470+config GRKERNSEC_SYSCTL_DISTRO
85471+ bool "Extra sysctl support for distro makers (READ HELP)"
85472+ depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
85473+ help
85474+ If you say Y here, additional sysctl options will be created
85475+ for features that affect processes running as root. Therefore,
85476+ it is critical when using this option that the grsec_lock entry be
85477+ enabled after boot. Only distros with prebuilt kernel packages
85478+ with this option enabled that can ensure grsec_lock is enabled
85479+ after boot should use this option.
85480+ *Failure to set grsec_lock after boot makes all grsec features
85481+ this option covers useless*
85482+
85483+ Currently this option creates the following sysctl entries:
85484+ "Disable Privileged I/O": "disable_priv_io"
85485+
85486+config GRKERNSEC_SYSCTL_ON
85487+ bool "Turn on features by default"
85488+ default y if GRKERNSEC_CONFIG_AUTO
85489+ depends on GRKERNSEC_SYSCTL
85490+ help
85491+ If you say Y here, instead of having all features enabled in the
85492+ kernel configuration disabled at boot time, the features will be
85493+ enabled at boot time. It is recommended you say Y here unless
85494+ there is some reason you would want all sysctl-tunable features to
85495+ be disabled by default. As mentioned elsewhere, it is important
85496+ to enable the grsec_lock entry once you have finished modifying
85497+ the sysctl entries.
85498+
85499+endmenu
85500+menu "Logging Options"
85501+depends on GRKERNSEC
85502+
85503+config GRKERNSEC_FLOODTIME
85504+ int "Seconds in between log messages (minimum)"
85505+ default 10
85506+ help
85507+ This option allows you to enforce the number of seconds between
85508+ grsecurity log messages. The default should be suitable for most
85509+ people, however, if you choose to change it, choose a value small enough
85510+ to allow informative logs to be produced, but large enough to
85511+ prevent flooding.
85512+
85513+ Setting both this value and GRKERNSEC_FLOODBURST to 0 will disable
85514+ any rate limiting on grsecurity log messages.
85515+
85516+config GRKERNSEC_FLOODBURST
85517+ int "Number of messages in a burst (maximum)"
85518+ default 6
85519+ help
85520+ This option allows you to choose the maximum number of messages allowed
85521+ within the flood time interval you chose in a separate option. The
85522+ default should be suitable for most people, however if you find that
85523+ many of your logs are being interpreted as flooding, you may want to
85524+ raise this value.
85525+
85526+ Setting both this value and GRKERNSEC_FLOODTIME to 0 will disable
85527+ any rate limiting on grsecurity log messages.
85528+
85529+endmenu
85530diff --git a/grsecurity/Makefile b/grsecurity/Makefile
85531new file mode 100644
85532index 0000000..30ababb
85533--- /dev/null
85534+++ b/grsecurity/Makefile
85535@@ -0,0 +1,54 @@
85536+# grsecurity – access control and security hardening for Linux
85537+# All code in this directory and various hooks located throughout the Linux kernel are
85538+# Copyright (C) 2001-2014 Bradley Spengler, Open Source Security, Inc.
85539+# http://www.grsecurity.net spender@grsecurity.net
85540+#
85541+# This program is free software; you can redistribute it and/or
85542+# modify it under the terms of the GNU General Public License version 2
85543+# as published by the Free Software Foundation.
85544+#
85545+# This program is distributed in the hope that it will be useful,
85546+# but WITHOUT ANY WARRANTY; without even the implied warranty of
85547+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
85548+# GNU General Public License for more details.
85549+#
85550+# You should have received a copy of the GNU General Public License
85551+# along with this program; if not, write to the Free Software
85552+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
85553+
85554+KBUILD_CFLAGS += -Werror
85555+
85556+obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
85557+ grsec_mount.o grsec_sig.o grsec_sysctl.o \
85558+ grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
85559+ grsec_usb.o grsec_ipc.o grsec_proc.o
85560+
85561+obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
85562+ gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
85563+ gracl_learn.o grsec_log.o gracl_policy.o
85564+ifdef CONFIG_COMPAT
85565+obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
85566+endif
85567+
85568+obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
85569+
85570+ifdef CONFIG_NET
85571+obj-y += grsec_sock.o
85572+obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
85573+endif
85574+
85575+ifndef CONFIG_GRKERNSEC
85576+obj-y += grsec_disabled.o
85577+endif
85578+
85579+ifdef CONFIG_GRKERNSEC_HIDESYM
85580+extra-y := grsec_hidesym.o
85581+$(obj)/grsec_hidesym.o:
85582+ @-chmod -f 500 /boot
85583+ @-chmod -f 500 /lib/modules
85584+ @-chmod -f 500 /lib64/modules
85585+ @-chmod -f 500 /lib32/modules
85586+ @-chmod -f 700 .
85587+ @-chmod -f 700 $(objtree)
85588+ @echo ' grsec: protected kernel image paths'
85589+endif
85590diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
85591new file mode 100644
85592index 0000000..7ad630a
85593--- /dev/null
85594+++ b/grsecurity/gracl.c
85595@@ -0,0 +1,2757 @@
85596+#include <linux/kernel.h>
85597+#include <linux/module.h>
85598+#include <linux/sched.h>
85599+#include <linux/mm.h>
85600+#include <linux/file.h>
85601+#include <linux/fs.h>
85602+#include <linux/namei.h>
85603+#include <linux/mount.h>
85604+#include <linux/tty.h>
85605+#include <linux/proc_fs.h>
85606+#include <linux/lglock.h>
85607+#include <linux/slab.h>
85608+#include <linux/vmalloc.h>
85609+#include <linux/types.h>
85610+#include <linux/sysctl.h>
85611+#include <linux/netdevice.h>
85612+#include <linux/ptrace.h>
85613+#include <linux/gracl.h>
85614+#include <linux/gralloc.h>
85615+#include <linux/security.h>
85616+#include <linux/grinternal.h>
85617+#include <linux/pid_namespace.h>
85618+#include <linux/stop_machine.h>
85619+#include <linux/fdtable.h>
85620+#include <linux/percpu.h>
85621+#include <linux/lglock.h>
85622+#include <linux/hugetlb.h>
85623+#include <linux/posix-timers.h>
85624+#include <linux/prefetch.h>
85625+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
85626+#include <linux/magic.h>
85627+#include <linux/pagemap.h>
85628+#include "../fs/btrfs/async-thread.h"
85629+#include "../fs/btrfs/ctree.h"
85630+#include "../fs/btrfs/btrfs_inode.h"
85631+#endif
85632+#include "../fs/mount.h"
85633+
85634+#include <asm/uaccess.h>
85635+#include <asm/errno.h>
85636+#include <asm/mman.h>
85637+
85638+#define FOR_EACH_ROLE_START(role) \
85639+ role = running_polstate.role_list; \
85640+ while (role) {
85641+
85642+#define FOR_EACH_ROLE_END(role) \
85643+ role = role->prev; \
85644+ }
85645+
85646+extern struct path gr_real_root;
85647+
85648+static struct gr_policy_state running_polstate;
85649+struct gr_policy_state *polstate = &running_polstate;
85650+extern struct gr_alloc_state *current_alloc_state;
85651+
85652+extern char *gr_shared_page[4];
85653+DEFINE_RWLOCK(gr_inode_lock);
85654+
85655+static unsigned int gr_status __read_only = GR_STATUS_INIT;
85656+
85657+#ifdef CONFIG_NET
85658+extern struct vfsmount *sock_mnt;
85659+#endif
85660+
85661+extern struct vfsmount *pipe_mnt;
85662+extern struct vfsmount *shm_mnt;
85663+
85664+#ifdef CONFIG_HUGETLBFS
85665+extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
85666+#endif
85667+
85668+extern u16 acl_sp_role_value;
85669+extern struct acl_object_label *fakefs_obj_rw;
85670+extern struct acl_object_label *fakefs_obj_rwx;
85671+
85672+int gr_acl_is_enabled(void)
85673+{
85674+ return (gr_status & GR_READY);
85675+}
85676+
85677+void gr_enable_rbac_system(void)
85678+{
85679+ pax_open_kernel();
85680+ gr_status |= GR_READY;
85681+ pax_close_kernel();
85682+}
85683+
85684+int gr_rbac_disable(void *unused)
85685+{
85686+ pax_open_kernel();
85687+ gr_status &= ~GR_READY;
85688+ pax_close_kernel();
85689+
85690+ return 0;
85691+}
85692+
85693+static inline dev_t __get_dev(const struct dentry *dentry)
85694+{
85695+ struct dentry *ldentry = d_backing_dentry((struct dentry *)dentry);
85696+
85697+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
85698+ if (ldentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
85699+ return BTRFS_I(d_inode(ldentry))->root->anon_dev;
85700+ else
85701+#endif
85702+ return d_inode(ldentry)->i_sb->s_dev;
85703+}
85704+
85705+static inline u64 __get_ino(const struct dentry *dentry)
85706+{
85707+ struct dentry *ldentry = d_backing_dentry((struct dentry *)dentry);
85708+
85709+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
85710+ if (ldentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
85711+ return btrfs_ino(d_inode(dentry));
85712+ else
85713+#endif
85714+ return d_inode(ldentry)->i_ino;
85715+}
85716+
85717+dev_t gr_get_dev_from_dentry(struct dentry *dentry)
85718+{
85719+ return __get_dev(dentry);
85720+}
85721+
85722+u64 gr_get_ino_from_dentry(struct dentry *dentry)
85723+{
85724+ return __get_ino(dentry);
85725+}
85726+
85727+static char gr_task_roletype_to_char(struct task_struct *task)
85728+{
85729+ switch (task->role->roletype &
85730+ (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
85731+ GR_ROLE_SPECIAL)) {
85732+ case GR_ROLE_DEFAULT:
85733+ return 'D';
85734+ case GR_ROLE_USER:
85735+ return 'U';
85736+ case GR_ROLE_GROUP:
85737+ return 'G';
85738+ case GR_ROLE_SPECIAL:
85739+ return 'S';
85740+ }
85741+
85742+ return 'X';
85743+}
85744+
85745+char gr_roletype_to_char(void)
85746+{
85747+ return gr_task_roletype_to_char(current);
85748+}
85749+
85750+int
85751+gr_acl_tpe_check(void)
85752+{
85753+ if (unlikely(!(gr_status & GR_READY)))
85754+ return 0;
85755+ if (current->role->roletype & GR_ROLE_TPE)
85756+ return 1;
85757+ else
85758+ return 0;
85759+}
85760+
85761+int
85762+gr_handle_rawio(const struct inode *inode)
85763+{
85764+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
85765+ if (inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR)) &&
85766+ grsec_enable_chroot_caps && proc_is_chrooted(current) &&
85767+ !capable(CAP_SYS_RAWIO))
85768+ return 1;
85769+#endif
85770+ return 0;
85771+}
85772+
85773+int
85774+gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
85775+{
85776+ if (likely(lena != lenb))
85777+ return 0;
85778+
85779+ return !memcmp(a, b, lena);
85780+}
85781+
85782+static int prepend(char **buffer, int *buflen, const char *str, int namelen)
85783+{
85784+ *buflen -= namelen;
85785+ if (*buflen < 0)
85786+ return -ENAMETOOLONG;
85787+ *buffer -= namelen;
85788+ memcpy(*buffer, str, namelen);
85789+ return 0;
85790+}
85791+
85792+static int prepend_name(char **buffer, int *buflen, struct qstr *name)
85793+{
85794+ return prepend(buffer, buflen, name->name, name->len);
85795+}
85796+
85797+static int prepend_path(const struct path *path, struct path *root,
85798+ char **buffer, int *buflen)
85799+{
85800+ struct dentry *dentry = path->dentry;
85801+ struct vfsmount *vfsmnt = path->mnt;
85802+ struct mount *mnt = real_mount(vfsmnt);
85803+ bool slash = false;
85804+ int error = 0;
85805+
85806+ while (dentry != root->dentry || vfsmnt != root->mnt) {
85807+ struct dentry * parent;
85808+
85809+ if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
85810+ /* Global root? */
85811+ if (!mnt_has_parent(mnt)) {
85812+ goto out;
85813+ }
85814+ dentry = mnt->mnt_mountpoint;
85815+ mnt = mnt->mnt_parent;
85816+ vfsmnt = &mnt->mnt;
85817+ continue;
85818+ }
85819+ parent = dentry->d_parent;
85820+ prefetch(parent);
85821+ spin_lock(&dentry->d_lock);
85822+ error = prepend_name(buffer, buflen, &dentry->d_name);
85823+ spin_unlock(&dentry->d_lock);
85824+ if (!error)
85825+ error = prepend(buffer, buflen, "/", 1);
85826+ if (error)
85827+ break;
85828+
85829+ slash = true;
85830+ dentry = parent;
85831+ }
85832+
85833+out:
85834+ if (!error && !slash)
85835+ error = prepend(buffer, buflen, "/", 1);
85836+
85837+ return error;
85838+}
85839+
85840+/* this must be called with mount_lock and rename_lock held */
85841+
85842+static char *__our_d_path(const struct path *path, struct path *root,
85843+ char *buf, int buflen)
85844+{
85845+ char *res = buf + buflen;
85846+ int error;
85847+
85848+ prepend(&res, &buflen, "\0", 1);
85849+ error = prepend_path(path, root, &res, &buflen);
85850+ if (error)
85851+ return ERR_PTR(error);
85852+
85853+ return res;
85854+}
85855+
85856+static char *
85857+gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
85858+{
85859+ char *retval;
85860+
85861+ retval = __our_d_path(path, root, buf, buflen);
85862+ if (unlikely(IS_ERR(retval)))
85863+ retval = strcpy(buf, "<path too long>");
85864+ else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
85865+ retval[1] = '\0';
85866+
85867+ return retval;
85868+}
85869+
85870+static char *
85871+__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
85872+ char *buf, int buflen)
85873+{
85874+ struct path path;
85875+ char *res;
85876+
85877+ path.dentry = (struct dentry *)dentry;
85878+ path.mnt = (struct vfsmount *)vfsmnt;
85879+
85880+ /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
85881+ by the RBAC system */
85882+ res = gen_full_path(&path, &gr_real_root, buf, buflen);
85883+
85884+ return res;
85885+}
85886+
85887+static char *
85888+d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
85889+ char *buf, int buflen)
85890+{
85891+ char *res;
85892+ struct path path;
85893+ struct path root;
85894+ struct task_struct *reaper = init_pid_ns.child_reaper;
85895+
85896+ path.dentry = (struct dentry *)dentry;
85897+ path.mnt = (struct vfsmount *)vfsmnt;
85898+
85899+ /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
85900+ get_fs_root(reaper->fs, &root);
85901+
85902+ read_seqlock_excl(&mount_lock);
85903+ write_seqlock(&rename_lock);
85904+ res = gen_full_path(&path, &root, buf, buflen);
85905+ write_sequnlock(&rename_lock);
85906+ read_sequnlock_excl(&mount_lock);
85907+
85908+ path_put(&root);
85909+ return res;
85910+}
85911+
85912+char *
85913+gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
85914+{
85915+ char *ret;
85916+ read_seqlock_excl(&mount_lock);
85917+ write_seqlock(&rename_lock);
85918+ ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
85919+ PAGE_SIZE);
85920+ write_sequnlock(&rename_lock);
85921+ read_sequnlock_excl(&mount_lock);
85922+ return ret;
85923+}
85924+
85925+static char *
85926+gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
85927+{
85928+ char *ret;
85929+ char *buf;
85930+ int buflen;
85931+
85932+ read_seqlock_excl(&mount_lock);
85933+ write_seqlock(&rename_lock);
85934+ buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
85935+ ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
85936+ buflen = (int)(ret - buf);
85937+ if (buflen >= 5)
85938+ prepend(&ret, &buflen, "/proc", 5);
85939+ else
85940+ ret = strcpy(buf, "<path too long>");
85941+ write_sequnlock(&rename_lock);
85942+ read_sequnlock_excl(&mount_lock);
85943+ return ret;
85944+}
85945+
85946+char *
85947+gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
85948+{
85949+ return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
85950+ PAGE_SIZE);
85951+}
85952+
85953+char *
85954+gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
85955+{
85956+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
85957+ PAGE_SIZE);
85958+}
85959+
85960+char *
85961+gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
85962+{
85963+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
85964+ PAGE_SIZE);
85965+}
85966+
85967+char *
85968+gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
85969+{
85970+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
85971+ PAGE_SIZE);
85972+}
85973+
85974+char *
85975+gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
85976+{
85977+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
85978+ PAGE_SIZE);
85979+}
85980+
85981+__u32
85982+to_gr_audit(const __u32 reqmode)
85983+{
85984+ /* masks off auditable permission flags, then shifts them to create
85985+ auditing flags, and adds the special case of append auditing if
85986+ we're requesting write */
85987+ return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
85988+}
85989+
85990+struct acl_role_label *
85991+__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
85992+ const gid_t gid)
85993+{
85994+ unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
85995+ struct acl_role_label *match;
85996+ struct role_allowed_ip *ipp;
85997+ unsigned int x;
85998+ u32 curr_ip = task->signal->saved_ip;
85999+
86000+ match = state->acl_role_set.r_hash[index];
86001+
86002+ while (match) {
86003+ if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
86004+ for (x = 0; x < match->domain_child_num; x++) {
86005+ if (match->domain_children[x] == uid)
86006+ goto found;
86007+ }
86008+ } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
86009+ break;
86010+ match = match->next;
86011+ }
86012+found:
86013+ if (match == NULL) {
86014+ try_group:
86015+ index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
86016+ match = state->acl_role_set.r_hash[index];
86017+
86018+ while (match) {
86019+ if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
86020+ for (x = 0; x < match->domain_child_num; x++) {
86021+ if (match->domain_children[x] == gid)
86022+ goto found2;
86023+ }
86024+ } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
86025+ break;
86026+ match = match->next;
86027+ }
86028+found2:
86029+ if (match == NULL)
86030+ match = state->default_role;
86031+ if (match->allowed_ips == NULL)
86032+ return match;
86033+ else {
86034+ for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
86035+ if (likely
86036+ ((ntohl(curr_ip) & ipp->netmask) ==
86037+ (ntohl(ipp->addr) & ipp->netmask)))
86038+ return match;
86039+ }
86040+ match = state->default_role;
86041+ }
86042+ } else if (match->allowed_ips == NULL) {
86043+ return match;
86044+ } else {
86045+ for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
86046+ if (likely
86047+ ((ntohl(curr_ip) & ipp->netmask) ==
86048+ (ntohl(ipp->addr) & ipp->netmask)))
86049+ return match;
86050+ }
86051+ goto try_group;
86052+ }
86053+
86054+ return match;
86055+}
86056+
86057+static struct acl_role_label *
86058+lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
86059+ const gid_t gid)
86060+{
86061+ return __lookup_acl_role_label(&running_polstate, task, uid, gid);
86062+}
86063+
86064+struct acl_subject_label *
86065+lookup_acl_subj_label(const u64 ino, const dev_t dev,
86066+ const struct acl_role_label *role)
86067+{
86068+ unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
86069+ struct acl_subject_label *match;
86070+
86071+ match = role->subj_hash[index];
86072+
86073+ while (match && (match->inode != ino || match->device != dev ||
86074+ (match->mode & GR_DELETED))) {
86075+ match = match->next;
86076+ }
86077+
86078+ if (match && !(match->mode & GR_DELETED))
86079+ return match;
86080+ else
86081+ return NULL;
86082+}
86083+
86084+struct acl_subject_label *
86085+lookup_acl_subj_label_deleted(const u64 ino, const dev_t dev,
86086+ const struct acl_role_label *role)
86087+{
86088+ unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
86089+ struct acl_subject_label *match;
86090+
86091+ match = role->subj_hash[index];
86092+
86093+ while (match && (match->inode != ino || match->device != dev ||
86094+ !(match->mode & GR_DELETED))) {
86095+ match = match->next;
86096+ }
86097+
86098+ if (match && (match->mode & GR_DELETED))
86099+ return match;
86100+ else
86101+ return NULL;
86102+}
86103+
86104+static struct acl_object_label *
86105+lookup_acl_obj_label(const u64 ino, const dev_t dev,
86106+ const struct acl_subject_label *subj)
86107+{
86108+ unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
86109+ struct acl_object_label *match;
86110+
86111+ match = subj->obj_hash[index];
86112+
86113+ while (match && (match->inode != ino || match->device != dev ||
86114+ (match->mode & GR_DELETED))) {
86115+ match = match->next;
86116+ }
86117+
86118+ if (match && !(match->mode & GR_DELETED))
86119+ return match;
86120+ else
86121+ return NULL;
86122+}
86123+
86124+static struct acl_object_label *
86125+lookup_acl_obj_label_create(const u64 ino, const dev_t dev,
86126+ const struct acl_subject_label *subj)
86127+{
86128+ unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
86129+ struct acl_object_label *match;
86130+
86131+ match = subj->obj_hash[index];
86132+
86133+ while (match && (match->inode != ino || match->device != dev ||
86134+ !(match->mode & GR_DELETED))) {
86135+ match = match->next;
86136+ }
86137+
86138+ if (match && (match->mode & GR_DELETED))
86139+ return match;
86140+
86141+ match = subj->obj_hash[index];
86142+
86143+ while (match && (match->inode != ino || match->device != dev ||
86144+ (match->mode & GR_DELETED))) {
86145+ match = match->next;
86146+ }
86147+
86148+ if (match && !(match->mode & GR_DELETED))
86149+ return match;
86150+ else
86151+ return NULL;
86152+}
86153+
86154+struct name_entry *
86155+__lookup_name_entry(const struct gr_policy_state *state, const char *name)
86156+{
86157+ unsigned int len = strlen(name);
86158+ unsigned int key = full_name_hash(name, len);
86159+ unsigned int index = key % state->name_set.n_size;
86160+ struct name_entry *match;
86161+
86162+ match = state->name_set.n_hash[index];
86163+
86164+ while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
86165+ match = match->next;
86166+
86167+ return match;
86168+}
86169+
86170+static struct name_entry *
86171+lookup_name_entry(const char *name)
86172+{
86173+ return __lookup_name_entry(&running_polstate, name);
86174+}
86175+
86176+static struct name_entry *
86177+lookup_name_entry_create(const char *name)
86178+{
86179+ unsigned int len = strlen(name);
86180+ unsigned int key = full_name_hash(name, len);
86181+ unsigned int index = key % running_polstate.name_set.n_size;
86182+ struct name_entry *match;
86183+
86184+ match = running_polstate.name_set.n_hash[index];
86185+
86186+ while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
86187+ !match->deleted))
86188+ match = match->next;
86189+
86190+ if (match && match->deleted)
86191+ return match;
86192+
86193+ match = running_polstate.name_set.n_hash[index];
86194+
86195+ while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
86196+ match->deleted))
86197+ match = match->next;
86198+
86199+ if (match && !match->deleted)
86200+ return match;
86201+ else
86202+ return NULL;
86203+}
86204+
86205+static struct inodev_entry *
86206+lookup_inodev_entry(const u64 ino, const dev_t dev)
86207+{
86208+ unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
86209+ struct inodev_entry *match;
86210+
86211+ match = running_polstate.inodev_set.i_hash[index];
86212+
86213+ while (match && (match->nentry->inode != ino || match->nentry->device != dev))
86214+ match = match->next;
86215+
86216+ return match;
86217+}
86218+
86219+void
86220+__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
86221+{
86222+ unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
86223+ state->inodev_set.i_size);
86224+ struct inodev_entry **curr;
86225+
86226+ entry->prev = NULL;
86227+
86228+ curr = &state->inodev_set.i_hash[index];
86229+ if (*curr != NULL)
86230+ (*curr)->prev = entry;
86231+
86232+ entry->next = *curr;
86233+ *curr = entry;
86234+
86235+ return;
86236+}
86237+
86238+static void
86239+insert_inodev_entry(struct inodev_entry *entry)
86240+{
86241+ __insert_inodev_entry(&running_polstate, entry);
86242+}
86243+
86244+void
86245+insert_acl_obj_label(struct acl_object_label *obj,
86246+ struct acl_subject_label *subj)
86247+{
86248+ unsigned int index =
86249+ gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
86250+ struct acl_object_label **curr;
86251+
86252+ obj->prev = NULL;
86253+
86254+ curr = &subj->obj_hash[index];
86255+ if (*curr != NULL)
86256+ (*curr)->prev = obj;
86257+
86258+ obj->next = *curr;
86259+ *curr = obj;
86260+
86261+ return;
86262+}
86263+
86264+void
86265+insert_acl_subj_label(struct acl_subject_label *obj,
86266+ struct acl_role_label *role)
86267+{
86268+ unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
86269+ struct acl_subject_label **curr;
86270+
86271+ obj->prev = NULL;
86272+
86273+ curr = &role->subj_hash[index];
86274+ if (*curr != NULL)
86275+ (*curr)->prev = obj;
86276+
86277+ obj->next = *curr;
86278+ *curr = obj;
86279+
86280+ return;
86281+}
86282+
86283+/* derived from glibc fnmatch() 0: match, 1: no match*/
86284+
86285+static int
86286+glob_match(const char *p, const char *n)
86287+{
86288+ char c;
86289+
86290+ while ((c = *p++) != '\0') {
86291+ switch (c) {
86292+ case '?':
86293+ if (*n == '\0')
86294+ return 1;
86295+ else if (*n == '/')
86296+ return 1;
86297+ break;
86298+ case '\\':
86299+ if (*n != c)
86300+ return 1;
86301+ break;
86302+ case '*':
86303+ for (c = *p++; c == '?' || c == '*'; c = *p++) {
86304+ if (*n == '/')
86305+ return 1;
86306+ else if (c == '?') {
86307+ if (*n == '\0')
86308+ return 1;
86309+ else
86310+ ++n;
86311+ }
86312+ }
86313+ if (c == '\0') {
86314+ return 0;
86315+ } else {
86316+ const char *endp;
86317+
86318+ if ((endp = strchr(n, '/')) == NULL)
86319+ endp = n + strlen(n);
86320+
86321+ if (c == '[') {
86322+ for (--p; n < endp; ++n)
86323+ if (!glob_match(p, n))
86324+ return 0;
86325+ } else if (c == '/') {
86326+ while (*n != '\0' && *n != '/')
86327+ ++n;
86328+ if (*n == '/' && !glob_match(p, n + 1))
86329+ return 0;
86330+ } else {
86331+ for (--p; n < endp; ++n)
86332+ if (*n == c && !glob_match(p, n))
86333+ return 0;
86334+ }
86335+
86336+ return 1;
86337+ }
86338+ case '[':
86339+ {
86340+ int not;
86341+ char cold;
86342+
86343+ if (*n == '\0' || *n == '/')
86344+ return 1;
86345+
86346+ not = (*p == '!' || *p == '^');
86347+ if (not)
86348+ ++p;
86349+
86350+ c = *p++;
86351+ for (;;) {
86352+ unsigned char fn = (unsigned char)*n;
86353+
86354+ if (c == '\0')
86355+ return 1;
86356+ else {
86357+ if (c == fn)
86358+ goto matched;
86359+ cold = c;
86360+ c = *p++;
86361+
86362+ if (c == '-' && *p != ']') {
86363+ unsigned char cend = *p++;
86364+
86365+ if (cend == '\0')
86366+ return 1;
86367+
86368+ if (cold <= fn && fn <= cend)
86369+ goto matched;
86370+
86371+ c = *p++;
86372+ }
86373+ }
86374+
86375+ if (c == ']')
86376+ break;
86377+ }
86378+ if (!not)
86379+ return 1;
86380+ break;
86381+ matched:
86382+ while (c != ']') {
86383+ if (c == '\0')
86384+ return 1;
86385+
86386+ c = *p++;
86387+ }
86388+ if (not)
86389+ return 1;
86390+ }
86391+ break;
86392+ default:
86393+ if (c != *n)
86394+ return 1;
86395+ }
86396+
86397+ ++n;
86398+ }
86399+
86400+ if (*n == '\0')
86401+ return 0;
86402+
86403+ if (*n == '/')
86404+ return 0;
86405+
86406+ return 1;
86407+}
86408+
86409+static struct acl_object_label *
86410+chk_glob_label(struct acl_object_label *globbed,
86411+ const struct dentry *dentry, const struct vfsmount *mnt, char **path)
86412+{
86413+ struct acl_object_label *tmp;
86414+
86415+ if (*path == NULL)
86416+ *path = gr_to_filename_nolock(dentry, mnt);
86417+
86418+ tmp = globbed;
86419+
86420+ while (tmp) {
86421+ if (!glob_match(tmp->filename, *path))
86422+ return tmp;
86423+ tmp = tmp->next;
86424+ }
86425+
86426+ return NULL;
86427+}
86428+
86429+static struct acl_object_label *
86430+__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
86431+ const u64 curr_ino, const dev_t curr_dev,
86432+ const struct acl_subject_label *subj, char **path, const int checkglob)
86433+{
86434+ struct acl_subject_label *tmpsubj;
86435+ struct acl_object_label *retval;
86436+ struct acl_object_label *retval2;
86437+
86438+ tmpsubj = (struct acl_subject_label *) subj;
86439+ read_lock(&gr_inode_lock);
86440+ do {
86441+ retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
86442+ if (retval) {
86443+ if (checkglob && retval->globbed) {
86444+ retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
86445+ if (retval2)
86446+ retval = retval2;
86447+ }
86448+ break;
86449+ }
86450+ } while ((tmpsubj = tmpsubj->parent_subject));
86451+ read_unlock(&gr_inode_lock);
86452+
86453+ return retval;
86454+}
86455+
86456+static struct acl_object_label *
86457+full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
86458+ struct dentry *curr_dentry,
86459+ const struct acl_subject_label *subj, char **path, const int checkglob)
86460+{
86461+ int newglob = checkglob;
86462+ u64 inode;
86463+ dev_t device;
86464+
86465+ /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
86466+ as we don't want a / * rule to match instead of the / object
86467+ don't do this for create lookups that call this function though, since they're looking up
86468+ on the parent and thus need globbing checks on all paths
86469+ */
86470+ if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
86471+ newglob = GR_NO_GLOB;
86472+
86473+ spin_lock(&curr_dentry->d_lock);
86474+ inode = __get_ino(curr_dentry);
86475+ device = __get_dev(curr_dentry);
86476+ spin_unlock(&curr_dentry->d_lock);
86477+
86478+ return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
86479+}
86480+
86481+#ifdef CONFIG_HUGETLBFS
86482+static inline bool
86483+is_hugetlbfs_mnt(const struct vfsmount *mnt)
86484+{
86485+ int i;
86486+ for (i = 0; i < HUGE_MAX_HSTATE; i++) {
86487+ if (unlikely(hugetlbfs_vfsmount[i] == mnt))
86488+ return true;
86489+ }
86490+
86491+ return false;
86492+}
86493+#endif
86494+
86495+static struct acl_object_label *
86496+__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86497+ const struct acl_subject_label *subj, char *path, const int checkglob)
86498+{
86499+ struct dentry *dentry = (struct dentry *) l_dentry;
86500+ struct vfsmount *mnt = (struct vfsmount *) l_mnt;
86501+ struct inode * inode = d_backing_inode(dentry);
86502+ struct mount *real_mnt = real_mount(mnt);
86503+ struct acl_object_label *retval;
86504+ struct dentry *parent;
86505+
86506+ read_seqlock_excl(&mount_lock);
86507+ write_seqlock(&rename_lock);
86508+
86509+ if (unlikely((mnt == shm_mnt && inode->i_nlink == 0) || mnt == pipe_mnt ||
86510+#ifdef CONFIG_NET
86511+ mnt == sock_mnt ||
86512+#endif
86513+#ifdef CONFIG_HUGETLBFS
86514+ (is_hugetlbfs_mnt(mnt) && inode->i_nlink == 0) ||
86515+#endif
86516+ /* ignore Eric Biederman */
86517+ IS_PRIVATE(inode))) {
86518+ retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
86519+ goto out;
86520+ }
86521+
86522+ for (;;) {
86523+ if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
86524+ break;
86525+
86526+ if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
86527+ if (!mnt_has_parent(real_mnt))
86528+ break;
86529+
86530+ retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
86531+ if (retval != NULL)
86532+ goto out;
86533+
86534+ dentry = real_mnt->mnt_mountpoint;
86535+ real_mnt = real_mnt->mnt_parent;
86536+ mnt = &real_mnt->mnt;
86537+ continue;
86538+ }
86539+
86540+ parent = dentry->d_parent;
86541+ retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
86542+ if (retval != NULL)
86543+ goto out;
86544+
86545+ dentry = parent;
86546+ }
86547+
86548+ retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
86549+
86550+ /* gr_real_root is pinned so we don't have to hold a reference */
86551+ if (retval == NULL)
86552+ retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
86553+out:
86554+ write_sequnlock(&rename_lock);
86555+ read_sequnlock_excl(&mount_lock);
86556+
86557+ BUG_ON(retval == NULL);
86558+
86559+ return retval;
86560+}
86561+
86562+static struct acl_object_label *
86563+chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86564+ const struct acl_subject_label *subj)
86565+{
86566+ char *path = NULL;
86567+ return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
86568+}
86569+
86570+static struct acl_object_label *
86571+chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86572+ const struct acl_subject_label *subj)
86573+{
86574+ char *path = NULL;
86575+ return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
86576+}
86577+
86578+static struct acl_object_label *
86579+chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86580+ const struct acl_subject_label *subj, char *path)
86581+{
86582+ return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
86583+}
86584+
86585+struct acl_subject_label *
86586+chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86587+ const struct acl_role_label *role)
86588+{
86589+ struct dentry *dentry = (struct dentry *) l_dentry;
86590+ struct vfsmount *mnt = (struct vfsmount *) l_mnt;
86591+ struct mount *real_mnt = real_mount(mnt);
86592+ struct acl_subject_label *retval;
86593+ struct dentry *parent;
86594+
86595+ read_seqlock_excl(&mount_lock);
86596+ write_seqlock(&rename_lock);
86597+
86598+ for (;;) {
86599+ if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
86600+ break;
86601+ if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
86602+ if (!mnt_has_parent(real_mnt))
86603+ break;
86604+
86605+ spin_lock(&dentry->d_lock);
86606+ read_lock(&gr_inode_lock);
86607+ retval =
86608+ lookup_acl_subj_label(__get_ino(dentry),
86609+ __get_dev(dentry), role);
86610+ read_unlock(&gr_inode_lock);
86611+ spin_unlock(&dentry->d_lock);
86612+ if (retval != NULL)
86613+ goto out;
86614+
86615+ dentry = real_mnt->mnt_mountpoint;
86616+ real_mnt = real_mnt->mnt_parent;
86617+ mnt = &real_mnt->mnt;
86618+ continue;
86619+ }
86620+
86621+ spin_lock(&dentry->d_lock);
86622+ read_lock(&gr_inode_lock);
86623+ retval = lookup_acl_subj_label(__get_ino(dentry),
86624+ __get_dev(dentry), role);
86625+ read_unlock(&gr_inode_lock);
86626+ parent = dentry->d_parent;
86627+ spin_unlock(&dentry->d_lock);
86628+
86629+ if (retval != NULL)
86630+ goto out;
86631+
86632+ dentry = parent;
86633+ }
86634+
86635+ spin_lock(&dentry->d_lock);
86636+ read_lock(&gr_inode_lock);
86637+ retval = lookup_acl_subj_label(__get_ino(dentry),
86638+ __get_dev(dentry), role);
86639+ read_unlock(&gr_inode_lock);
86640+ spin_unlock(&dentry->d_lock);
86641+
86642+ if (unlikely(retval == NULL)) {
86643+ /* gr_real_root is pinned, we don't need to hold a reference */
86644+ read_lock(&gr_inode_lock);
86645+ retval = lookup_acl_subj_label(__get_ino(gr_real_root.dentry),
86646+ __get_dev(gr_real_root.dentry), role);
86647+ read_unlock(&gr_inode_lock);
86648+ }
86649+out:
86650+ write_sequnlock(&rename_lock);
86651+ read_sequnlock_excl(&mount_lock);
86652+
86653+ BUG_ON(retval == NULL);
86654+
86655+ return retval;
86656+}
86657+
86658+void
86659+assign_special_role(const char *rolename)
86660+{
86661+ struct acl_object_label *obj;
86662+ struct acl_role_label *r;
86663+ struct acl_role_label *assigned = NULL;
86664+ struct task_struct *tsk;
86665+ struct file *filp;
86666+
86667+ FOR_EACH_ROLE_START(r)
86668+ if (!strcmp(rolename, r->rolename) &&
86669+ (r->roletype & GR_ROLE_SPECIAL)) {
86670+ assigned = r;
86671+ break;
86672+ }
86673+ FOR_EACH_ROLE_END(r)
86674+
86675+ if (!assigned)
86676+ return;
86677+
86678+ read_lock(&tasklist_lock);
86679+ read_lock(&grsec_exec_file_lock);
86680+
86681+ tsk = current->real_parent;
86682+ if (tsk == NULL)
86683+ goto out_unlock;
86684+
86685+ filp = tsk->exec_file;
86686+ if (filp == NULL)
86687+ goto out_unlock;
86688+
86689+ tsk->is_writable = 0;
86690+ tsk->inherited = 0;
86691+
86692+ tsk->acl_sp_role = 1;
86693+ tsk->acl_role_id = ++acl_sp_role_value;
86694+ tsk->role = assigned;
86695+ tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
86696+
86697+ /* ignore additional mmap checks for processes that are writable
86698+ by the default ACL */
86699+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
86700+ if (unlikely(obj->mode & GR_WRITE))
86701+ tsk->is_writable = 1;
86702+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
86703+ if (unlikely(obj->mode & GR_WRITE))
86704+ tsk->is_writable = 1;
86705+
86706+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
86707+ printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
86708+ tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
86709+#endif
86710+
86711+out_unlock:
86712+ read_unlock(&grsec_exec_file_lock);
86713+ read_unlock(&tasklist_lock);
86714+ return;
86715+}
86716+
86717+
86718+static void
86719+gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
86720+{
86721+ struct task_struct *task = current;
86722+ const struct cred *cred = current_cred();
86723+
86724+ security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
86725+ GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
86726+ task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
86727+ 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
86728+
86729+ return;
86730+}
86731+
86732+static void
86733+gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
86734+{
86735+ struct task_struct *task = current;
86736+ const struct cred *cred = current_cred();
86737+
86738+ security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
86739+ GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
86740+ task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
86741+ 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
86742+
86743+ return;
86744+}
86745+
86746+static void
86747+gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
86748+{
86749+ struct task_struct *task = current;
86750+ const struct cred *cred = current_cred();
86751+
86752+ security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
86753+ GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
86754+ task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
86755+ 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
86756+
86757+ return;
86758+}
86759+
86760+static void
86761+gr_set_proc_res(struct task_struct *task)
86762+{
86763+ struct acl_subject_label *proc;
86764+ unsigned short i;
86765+
86766+ proc = task->acl;
86767+
86768+ if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
86769+ return;
86770+
86771+ for (i = 0; i < RLIM_NLIMITS; i++) {
86772+ unsigned long rlim_cur, rlim_max;
86773+
86774+ if (!(proc->resmask & (1U << i)))
86775+ continue;
86776+
86777+ rlim_cur = proc->res[i].rlim_cur;
86778+ rlim_max = proc->res[i].rlim_max;
86779+
86780+ if (i == RLIMIT_NOFILE) {
86781+ unsigned long saved_sysctl_nr_open = sysctl_nr_open;
86782+ if (rlim_cur > saved_sysctl_nr_open)
86783+ rlim_cur = saved_sysctl_nr_open;
86784+ if (rlim_max > saved_sysctl_nr_open)
86785+ rlim_max = saved_sysctl_nr_open;
86786+ }
86787+
86788+ task->signal->rlim[i].rlim_cur = rlim_cur;
86789+ task->signal->rlim[i].rlim_max = rlim_max;
86790+
86791+ if (i == RLIMIT_CPU)
86792+ update_rlimit_cpu(task, rlim_cur);
86793+ }
86794+
86795+ return;
86796+}
86797+
86798+/* both of the below must be called with
86799+ rcu_read_lock();
86800+ read_lock(&tasklist_lock);
86801+ read_lock(&grsec_exec_file_lock);
86802+ except in the case of gr_set_role_label() (for __gr_get_subject_for_task)
86803+*/
86804+
86805+struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename, int fallback)
86806+{
86807+ char *tmpname;
86808+ struct acl_subject_label *tmpsubj;
86809+ struct file *filp;
86810+ struct name_entry *nmatch;
86811+
86812+ filp = task->exec_file;
86813+ if (filp == NULL)
86814+ return NULL;
86815+
86816+ /* the following is to apply the correct subject
86817+ on binaries running when the RBAC system
86818+ is enabled, when the binaries have been
86819+ replaced or deleted since their execution
86820+ -----
86821+ when the RBAC system starts, the inode/dev
86822+ from exec_file will be one the RBAC system
86823+ is unaware of. It only knows the inode/dev
86824+ of the present file on disk, or the absence
86825+ of it.
86826+ */
86827+
86828+ if (filename)
86829+ nmatch = __lookup_name_entry(state, filename);
86830+ else {
86831+ preempt_disable();
86832+ tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
86833+
86834+ nmatch = __lookup_name_entry(state, tmpname);
86835+ preempt_enable();
86836+ }
86837+ tmpsubj = NULL;
86838+ if (nmatch) {
86839+ if (nmatch->deleted)
86840+ tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
86841+ else
86842+ tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
86843+ }
86844+ /* this also works for the reload case -- if we don't match a potentially inherited subject
86845+ then we fall back to a normal lookup based on the binary's ino/dev
86846+ */
86847+ if (tmpsubj == NULL && fallback)
86848+ tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, task->role);
86849+
86850+ return tmpsubj;
86851+}
86852+
86853+static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename, int fallback)
86854+{
86855+ return __gr_get_subject_for_task(&running_polstate, task, filename, fallback);
86856+}
86857+
86858+void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
86859+{
86860+ struct acl_object_label *obj;
86861+ struct file *filp;
86862+
86863+ filp = task->exec_file;
86864+
86865+ task->acl = subj;
86866+ task->is_writable = 0;
86867+ /* ignore additional mmap checks for processes that are writable
86868+ by the default ACL */
86869+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
86870+ if (unlikely(obj->mode & GR_WRITE))
86871+ task->is_writable = 1;
86872+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
86873+ if (unlikely(obj->mode & GR_WRITE))
86874+ task->is_writable = 1;
86875+
86876+ gr_set_proc_res(task);
86877+
86878+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
86879+ 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);
86880+#endif
86881+}
86882+
86883+static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
86884+{
86885+ __gr_apply_subject_to_task(&running_polstate, task, subj);
86886+}
86887+
86888+__u32
86889+gr_search_file(const struct dentry * dentry, const __u32 mode,
86890+ const struct vfsmount * mnt)
86891+{
86892+ __u32 retval = mode;
86893+ struct acl_subject_label *curracl;
86894+ struct acl_object_label *currobj;
86895+
86896+ if (unlikely(!(gr_status & GR_READY)))
86897+ return (mode & ~GR_AUDITS);
86898+
86899+ curracl = current->acl;
86900+
86901+ currobj = chk_obj_label(dentry, mnt, curracl);
86902+ retval = currobj->mode & mode;
86903+
86904+ /* if we're opening a specified transfer file for writing
86905+ (e.g. /dev/initctl), then transfer our role to init
86906+ */
86907+ if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
86908+ current->role->roletype & GR_ROLE_PERSIST)) {
86909+ struct task_struct *task = init_pid_ns.child_reaper;
86910+
86911+ if (task->role != current->role) {
86912+ struct acl_subject_label *subj;
86913+
86914+ task->acl_sp_role = 0;
86915+ task->acl_role_id = current->acl_role_id;
86916+ task->role = current->role;
86917+ rcu_read_lock();
86918+ read_lock(&grsec_exec_file_lock);
86919+ subj = gr_get_subject_for_task(task, NULL, 1);
86920+ gr_apply_subject_to_task(task, subj);
86921+ read_unlock(&grsec_exec_file_lock);
86922+ rcu_read_unlock();
86923+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
86924+ }
86925+ }
86926+
86927+ if (unlikely
86928+ ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
86929+ && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
86930+ __u32 new_mode = mode;
86931+
86932+ new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
86933+
86934+ retval = new_mode;
86935+
86936+ if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
86937+ new_mode |= GR_INHERIT;
86938+
86939+ if (!(mode & GR_NOLEARN))
86940+ gr_log_learn(dentry, mnt, new_mode);
86941+ }
86942+
86943+ return retval;
86944+}
86945+
86946+struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
86947+ const struct dentry *parent,
86948+ const struct vfsmount *mnt)
86949+{
86950+ struct name_entry *match;
86951+ struct acl_object_label *matchpo;
86952+ struct acl_subject_label *curracl;
86953+ char *path;
86954+
86955+ if (unlikely(!(gr_status & GR_READY)))
86956+ return NULL;
86957+
86958+ preempt_disable();
86959+ path = gr_to_filename_rbac(new_dentry, mnt);
86960+ match = lookup_name_entry_create(path);
86961+
86962+ curracl = current->acl;
86963+
86964+ if (match) {
86965+ read_lock(&gr_inode_lock);
86966+ matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
86967+ read_unlock(&gr_inode_lock);
86968+
86969+ if (matchpo) {
86970+ preempt_enable();
86971+ return matchpo;
86972+ }
86973+ }
86974+
86975+ // lookup parent
86976+
86977+ matchpo = chk_obj_create_label(parent, mnt, curracl, path);
86978+
86979+ preempt_enable();
86980+ return matchpo;
86981+}
86982+
86983+__u32
86984+gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
86985+ const struct vfsmount * mnt, const __u32 mode)
86986+{
86987+ struct acl_object_label *matchpo;
86988+ __u32 retval;
86989+
86990+ if (unlikely(!(gr_status & GR_READY)))
86991+ return (mode & ~GR_AUDITS);
86992+
86993+ matchpo = gr_get_create_object(new_dentry, parent, mnt);
86994+
86995+ retval = matchpo->mode & mode;
86996+
86997+ if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
86998+ && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
86999+ __u32 new_mode = mode;
87000+
87001+ new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
87002+
87003+ gr_log_learn(new_dentry, mnt, new_mode);
87004+ return new_mode;
87005+ }
87006+
87007+ return retval;
87008+}
87009+
87010+__u32
87011+gr_check_link(const struct dentry * new_dentry,
87012+ const struct dentry * parent_dentry,
87013+ const struct vfsmount * parent_mnt,
87014+ const struct dentry * old_dentry, const struct vfsmount * old_mnt)
87015+{
87016+ struct acl_object_label *obj;
87017+ __u32 oldmode, newmode;
87018+ __u32 needmode;
87019+ __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
87020+ GR_DELETE | GR_INHERIT;
87021+
87022+ if (unlikely(!(gr_status & GR_READY)))
87023+ return (GR_CREATE | GR_LINK);
87024+
87025+ obj = chk_obj_label(old_dentry, old_mnt, current->acl);
87026+ oldmode = obj->mode;
87027+
87028+ obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
87029+ newmode = obj->mode;
87030+
87031+ needmode = newmode & checkmodes;
87032+
87033+ // old name for hardlink must have at least the permissions of the new name
87034+ if ((oldmode & needmode) != needmode)
87035+ goto bad;
87036+
87037+ // if old name had restrictions/auditing, make sure the new name does as well
87038+ needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
87039+
87040+ // don't allow hardlinking of suid/sgid/fcapped files without permission
87041+ if (is_privileged_binary(old_dentry))
87042+ needmode |= GR_SETID;
87043+
87044+ if ((newmode & needmode) != needmode)
87045+ goto bad;
87046+
87047+ // enforce minimum permissions
87048+ if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
87049+ return newmode;
87050+bad:
87051+ needmode = oldmode;
87052+ if (is_privileged_binary(old_dentry))
87053+ needmode |= GR_SETID;
87054+
87055+ if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
87056+ gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
87057+ return (GR_CREATE | GR_LINK);
87058+ } else if (newmode & GR_SUPPRESS)
87059+ return GR_SUPPRESS;
87060+ else
87061+ return 0;
87062+}
87063+
87064+int
87065+gr_check_hidden_task(const struct task_struct *task)
87066+{
87067+ if (unlikely(!(gr_status & GR_READY)))
87068+ return 0;
87069+
87070+ if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
87071+ return 1;
87072+
87073+ return 0;
87074+}
87075+
87076+int
87077+gr_check_protected_task(const struct task_struct *task)
87078+{
87079+ if (unlikely(!(gr_status & GR_READY) || !task))
87080+ return 0;
87081+
87082+ if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
87083+ task->acl != current->acl)
87084+ return 1;
87085+
87086+ return 0;
87087+}
87088+
87089+int
87090+gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
87091+{
87092+ struct task_struct *p;
87093+ int ret = 0;
87094+
87095+ if (unlikely(!(gr_status & GR_READY) || !pid))
87096+ return ret;
87097+
87098+ read_lock(&tasklist_lock);
87099+ do_each_pid_task(pid, type, p) {
87100+ if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
87101+ p->acl != current->acl) {
87102+ ret = 1;
87103+ goto out;
87104+ }
87105+ } while_each_pid_task(pid, type, p);
87106+out:
87107+ read_unlock(&tasklist_lock);
87108+
87109+ return ret;
87110+}
87111+
87112+void
87113+gr_copy_label(struct task_struct *tsk)
87114+{
87115+ struct task_struct *p = current;
87116+
87117+ tsk->inherited = p->inherited;
87118+ tsk->acl_sp_role = 0;
87119+ tsk->acl_role_id = p->acl_role_id;
87120+ tsk->acl = p->acl;
87121+ tsk->role = p->role;
87122+ tsk->signal->used_accept = 0;
87123+ tsk->signal->curr_ip = p->signal->curr_ip;
87124+ tsk->signal->saved_ip = p->signal->saved_ip;
87125+ if (p->exec_file)
87126+ get_file(p->exec_file);
87127+ tsk->exec_file = p->exec_file;
87128+ tsk->is_writable = p->is_writable;
87129+ if (unlikely(p->signal->used_accept)) {
87130+ p->signal->curr_ip = 0;
87131+ p->signal->saved_ip = 0;
87132+ }
87133+
87134+ return;
87135+}
87136+
87137+extern int gr_process_kernel_setuid_ban(struct user_struct *user);
87138+
87139+int
87140+gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
87141+{
87142+ unsigned int i;
87143+ __u16 num;
87144+ uid_t *uidlist;
87145+ uid_t curuid;
87146+ int realok = 0;
87147+ int effectiveok = 0;
87148+ int fsok = 0;
87149+ uid_t globalreal, globaleffective, globalfs;
87150+
87151+#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
87152+ struct user_struct *user;
87153+
87154+ if (!uid_valid(real))
87155+ goto skipit;
87156+
87157+ /* find user based on global namespace */
87158+
87159+ globalreal = GR_GLOBAL_UID(real);
87160+
87161+ user = find_user(make_kuid(&init_user_ns, globalreal));
87162+ if (user == NULL)
87163+ goto skipit;
87164+
87165+ if (gr_process_kernel_setuid_ban(user)) {
87166+ /* for find_user */
87167+ free_uid(user);
87168+ return 1;
87169+ }
87170+
87171+ /* for find_user */
87172+ free_uid(user);
87173+
87174+skipit:
87175+#endif
87176+
87177+ if (unlikely(!(gr_status & GR_READY)))
87178+ return 0;
87179+
87180+ if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
87181+ gr_log_learn_uid_change(real, effective, fs);
87182+
87183+ num = current->acl->user_trans_num;
87184+ uidlist = current->acl->user_transitions;
87185+
87186+ if (uidlist == NULL)
87187+ return 0;
87188+
87189+ if (!uid_valid(real)) {
87190+ realok = 1;
87191+ globalreal = (uid_t)-1;
87192+ } else {
87193+ globalreal = GR_GLOBAL_UID(real);
87194+ }
87195+ if (!uid_valid(effective)) {
87196+ effectiveok = 1;
87197+ globaleffective = (uid_t)-1;
87198+ } else {
87199+ globaleffective = GR_GLOBAL_UID(effective);
87200+ }
87201+ if (!uid_valid(fs)) {
87202+ fsok = 1;
87203+ globalfs = (uid_t)-1;
87204+ } else {
87205+ globalfs = GR_GLOBAL_UID(fs);
87206+ }
87207+
87208+ if (current->acl->user_trans_type & GR_ID_ALLOW) {
87209+ for (i = 0; i < num; i++) {
87210+ curuid = uidlist[i];
87211+ if (globalreal == curuid)
87212+ realok = 1;
87213+ if (globaleffective == curuid)
87214+ effectiveok = 1;
87215+ if (globalfs == curuid)
87216+ fsok = 1;
87217+ }
87218+ } else if (current->acl->user_trans_type & GR_ID_DENY) {
87219+ for (i = 0; i < num; i++) {
87220+ curuid = uidlist[i];
87221+ if (globalreal == curuid)
87222+ break;
87223+ if (globaleffective == curuid)
87224+ break;
87225+ if (globalfs == curuid)
87226+ break;
87227+ }
87228+ /* not in deny list */
87229+ if (i == num) {
87230+ realok = 1;
87231+ effectiveok = 1;
87232+ fsok = 1;
87233+ }
87234+ }
87235+
87236+ if (realok && effectiveok && fsok)
87237+ return 0;
87238+ else {
87239+ gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
87240+ return 1;
87241+ }
87242+}
87243+
87244+int
87245+gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
87246+{
87247+ unsigned int i;
87248+ __u16 num;
87249+ gid_t *gidlist;
87250+ gid_t curgid;
87251+ int realok = 0;
87252+ int effectiveok = 0;
87253+ int fsok = 0;
87254+ gid_t globalreal, globaleffective, globalfs;
87255+
87256+ if (unlikely(!(gr_status & GR_READY)))
87257+ return 0;
87258+
87259+ if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
87260+ gr_log_learn_gid_change(real, effective, fs);
87261+
87262+ num = current->acl->group_trans_num;
87263+ gidlist = current->acl->group_transitions;
87264+
87265+ if (gidlist == NULL)
87266+ return 0;
87267+
87268+ if (!gid_valid(real)) {
87269+ realok = 1;
87270+ globalreal = (gid_t)-1;
87271+ } else {
87272+ globalreal = GR_GLOBAL_GID(real);
87273+ }
87274+ if (!gid_valid(effective)) {
87275+ effectiveok = 1;
87276+ globaleffective = (gid_t)-1;
87277+ } else {
87278+ globaleffective = GR_GLOBAL_GID(effective);
87279+ }
87280+ if (!gid_valid(fs)) {
87281+ fsok = 1;
87282+ globalfs = (gid_t)-1;
87283+ } else {
87284+ globalfs = GR_GLOBAL_GID(fs);
87285+ }
87286+
87287+ if (current->acl->group_trans_type & GR_ID_ALLOW) {
87288+ for (i = 0; i < num; i++) {
87289+ curgid = gidlist[i];
87290+ if (globalreal == curgid)
87291+ realok = 1;
87292+ if (globaleffective == curgid)
87293+ effectiveok = 1;
87294+ if (globalfs == curgid)
87295+ fsok = 1;
87296+ }
87297+ } else if (current->acl->group_trans_type & GR_ID_DENY) {
87298+ for (i = 0; i < num; i++) {
87299+ curgid = gidlist[i];
87300+ if (globalreal == curgid)
87301+ break;
87302+ if (globaleffective == curgid)
87303+ break;
87304+ if (globalfs == curgid)
87305+ break;
87306+ }
87307+ /* not in deny list */
87308+ if (i == num) {
87309+ realok = 1;
87310+ effectiveok = 1;
87311+ fsok = 1;
87312+ }
87313+ }
87314+
87315+ if (realok && effectiveok && fsok)
87316+ return 0;
87317+ else {
87318+ gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
87319+ return 1;
87320+ }
87321+}
87322+
87323+extern int gr_acl_is_capable(const int cap);
87324+
87325+void
87326+gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
87327+{
87328+ struct acl_role_label *role = task->role;
87329+ struct acl_role_label *origrole = role;
87330+ struct acl_subject_label *subj = NULL;
87331+ struct acl_object_label *obj;
87332+ struct file *filp;
87333+ uid_t uid;
87334+ gid_t gid;
87335+
87336+ if (unlikely(!(gr_status & GR_READY)))
87337+ return;
87338+
87339+ uid = GR_GLOBAL_UID(kuid);
87340+ gid = GR_GLOBAL_GID(kgid);
87341+
87342+ filp = task->exec_file;
87343+
87344+ /* kernel process, we'll give them the kernel role */
87345+ if (unlikely(!filp)) {
87346+ task->role = running_polstate.kernel_role;
87347+ task->acl = running_polstate.kernel_role->root_label;
87348+ return;
87349+ } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
87350+ /* save the current ip at time of role lookup so that the proper
87351+ IP will be learned for role_allowed_ip */
87352+ task->signal->saved_ip = task->signal->curr_ip;
87353+ role = lookup_acl_role_label(task, uid, gid);
87354+ }
87355+
87356+ /* don't change the role if we're not a privileged process */
87357+ if (role && task->role != role &&
87358+ (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
87359+ ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
87360+ return;
87361+
87362+ task->role = role;
87363+
87364+ if (task->inherited) {
87365+ /* if we reached our subject through inheritance, then first see
87366+ if there's a subject of the same name in the new role that has
87367+ an object that would result in the same inherited subject
87368+ */
87369+ subj = gr_get_subject_for_task(task, task->acl->filename, 0);
87370+ if (subj) {
87371+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, subj);
87372+ if (!(obj->mode & GR_INHERIT))
87373+ subj = NULL;
87374+ }
87375+
87376+ }
87377+ if (subj == NULL) {
87378+ /* otherwise:
87379+ perform subject lookup in possibly new role
87380+ we can use this result below in the case where role == task->role
87381+ */
87382+ subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
87383+ }
87384+
87385+ /* if we changed uid/gid, but result in the same role
87386+ and are using inheritance, don't lose the inherited subject
87387+ if current subject is other than what normal lookup
87388+ would result in, we arrived via inheritance, don't
87389+ lose subject
87390+ */
87391+ if (role != origrole || (!(task->acl->mode & GR_INHERITLEARN) &&
87392+ (subj == task->acl)))
87393+ task->acl = subj;
87394+
87395+ /* leave task->inherited unaffected */
87396+
87397+ task->is_writable = 0;
87398+
87399+ /* ignore additional mmap checks for processes that are writable
87400+ by the default ACL */
87401+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
87402+ if (unlikely(obj->mode & GR_WRITE))
87403+ task->is_writable = 1;
87404+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
87405+ if (unlikely(obj->mode & GR_WRITE))
87406+ task->is_writable = 1;
87407+
87408+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
87409+ 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);
87410+#endif
87411+
87412+ gr_set_proc_res(task);
87413+
87414+ return;
87415+}
87416+
87417+int
87418+gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
87419+ const int unsafe_flags)
87420+{
87421+ struct task_struct *task = current;
87422+ struct acl_subject_label *newacl;
87423+ struct acl_object_label *obj;
87424+ __u32 retmode;
87425+
87426+ if (unlikely(!(gr_status & GR_READY)))
87427+ return 0;
87428+
87429+ newacl = chk_subj_label(dentry, mnt, task->role);
87430+
87431+ /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
87432+ did an exec
87433+ */
87434+ rcu_read_lock();
87435+ read_lock(&tasklist_lock);
87436+ if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
87437+ (task->parent->acl->mode & GR_POVERRIDE))) {
87438+ read_unlock(&tasklist_lock);
87439+ rcu_read_unlock();
87440+ goto skip_check;
87441+ }
87442+ read_unlock(&tasklist_lock);
87443+ rcu_read_unlock();
87444+
87445+ if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
87446+ !(task->role->roletype & GR_ROLE_GOD) &&
87447+ !gr_search_file(dentry, GR_PTRACERD, mnt) &&
87448+ !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
87449+ if (unsafe_flags & LSM_UNSAFE_SHARE)
87450+ gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
87451+ else
87452+ gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
87453+ return -EACCES;
87454+ }
87455+
87456+skip_check:
87457+
87458+ obj = chk_obj_label(dentry, mnt, task->acl);
87459+ retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
87460+
87461+ if (!(task->acl->mode & GR_INHERITLEARN) &&
87462+ ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
87463+ if (obj->nested)
87464+ task->acl = obj->nested;
87465+ else
87466+ task->acl = newacl;
87467+ task->inherited = 0;
87468+ } else {
87469+ task->inherited = 1;
87470+ if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
87471+ gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
87472+ }
87473+
87474+ task->is_writable = 0;
87475+
87476+ /* ignore additional mmap checks for processes that are writable
87477+ by the default ACL */
87478+ obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
87479+ if (unlikely(obj->mode & GR_WRITE))
87480+ task->is_writable = 1;
87481+ obj = chk_obj_label(dentry, mnt, task->role->root_label);
87482+ if (unlikely(obj->mode & GR_WRITE))
87483+ task->is_writable = 1;
87484+
87485+ gr_set_proc_res(task);
87486+
87487+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
87488+ 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);
87489+#endif
87490+ return 0;
87491+}
87492+
87493+/* always called with valid inodev ptr */
87494+static void
87495+do_handle_delete(struct inodev_entry *inodev, const u64 ino, const dev_t dev)
87496+{
87497+ struct acl_object_label *matchpo;
87498+ struct acl_subject_label *matchps;
87499+ struct acl_subject_label *subj;
87500+ struct acl_role_label *role;
87501+ unsigned int x;
87502+
87503+ FOR_EACH_ROLE_START(role)
87504+ FOR_EACH_SUBJECT_START(role, subj, x)
87505+ if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
87506+ matchpo->mode |= GR_DELETED;
87507+ FOR_EACH_SUBJECT_END(subj,x)
87508+ FOR_EACH_NESTED_SUBJECT_START(role, subj)
87509+ /* nested subjects aren't in the role's subj_hash table */
87510+ if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
87511+ matchpo->mode |= GR_DELETED;
87512+ FOR_EACH_NESTED_SUBJECT_END(subj)
87513+ if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
87514+ matchps->mode |= GR_DELETED;
87515+ FOR_EACH_ROLE_END(role)
87516+
87517+ inodev->nentry->deleted = 1;
87518+
87519+ return;
87520+}
87521+
87522+void
87523+gr_handle_delete(const u64 ino, const dev_t dev)
87524+{
87525+ struct inodev_entry *inodev;
87526+
87527+ if (unlikely(!(gr_status & GR_READY)))
87528+ return;
87529+
87530+ write_lock(&gr_inode_lock);
87531+ inodev = lookup_inodev_entry(ino, dev);
87532+ if (inodev != NULL)
87533+ do_handle_delete(inodev, ino, dev);
87534+ write_unlock(&gr_inode_lock);
87535+
87536+ return;
87537+}
87538+
87539+static void
87540+update_acl_obj_label(const u64 oldinode, const dev_t olddevice,
87541+ const u64 newinode, const dev_t newdevice,
87542+ struct acl_subject_label *subj)
87543+{
87544+ unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
87545+ struct acl_object_label *match;
87546+
87547+ match = subj->obj_hash[index];
87548+
87549+ while (match && (match->inode != oldinode ||
87550+ match->device != olddevice ||
87551+ !(match->mode & GR_DELETED)))
87552+ match = match->next;
87553+
87554+ if (match && (match->inode == oldinode)
87555+ && (match->device == olddevice)
87556+ && (match->mode & GR_DELETED)) {
87557+ if (match->prev == NULL) {
87558+ subj->obj_hash[index] = match->next;
87559+ if (match->next != NULL)
87560+ match->next->prev = NULL;
87561+ } else {
87562+ match->prev->next = match->next;
87563+ if (match->next != NULL)
87564+ match->next->prev = match->prev;
87565+ }
87566+ match->prev = NULL;
87567+ match->next = NULL;
87568+ match->inode = newinode;
87569+ match->device = newdevice;
87570+ match->mode &= ~GR_DELETED;
87571+
87572+ insert_acl_obj_label(match, subj);
87573+ }
87574+
87575+ return;
87576+}
87577+
87578+static void
87579+update_acl_subj_label(const u64 oldinode, const dev_t olddevice,
87580+ const u64 newinode, const dev_t newdevice,
87581+ struct acl_role_label *role)
87582+{
87583+ unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
87584+ struct acl_subject_label *match;
87585+
87586+ match = role->subj_hash[index];
87587+
87588+ while (match && (match->inode != oldinode ||
87589+ match->device != olddevice ||
87590+ !(match->mode & GR_DELETED)))
87591+ match = match->next;
87592+
87593+ if (match && (match->inode == oldinode)
87594+ && (match->device == olddevice)
87595+ && (match->mode & GR_DELETED)) {
87596+ if (match->prev == NULL) {
87597+ role->subj_hash[index] = match->next;
87598+ if (match->next != NULL)
87599+ match->next->prev = NULL;
87600+ } else {
87601+ match->prev->next = match->next;
87602+ if (match->next != NULL)
87603+ match->next->prev = match->prev;
87604+ }
87605+ match->prev = NULL;
87606+ match->next = NULL;
87607+ match->inode = newinode;
87608+ match->device = newdevice;
87609+ match->mode &= ~GR_DELETED;
87610+
87611+ insert_acl_subj_label(match, role);
87612+ }
87613+
87614+ return;
87615+}
87616+
87617+static void
87618+update_inodev_entry(const u64 oldinode, const dev_t olddevice,
87619+ const u64 newinode, const dev_t newdevice)
87620+{
87621+ unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
87622+ struct inodev_entry *match;
87623+
87624+ match = running_polstate.inodev_set.i_hash[index];
87625+
87626+ while (match && (match->nentry->inode != oldinode ||
87627+ match->nentry->device != olddevice || !match->nentry->deleted))
87628+ match = match->next;
87629+
87630+ if (match && (match->nentry->inode == oldinode)
87631+ && (match->nentry->device == olddevice) &&
87632+ match->nentry->deleted) {
87633+ if (match->prev == NULL) {
87634+ running_polstate.inodev_set.i_hash[index] = match->next;
87635+ if (match->next != NULL)
87636+ match->next->prev = NULL;
87637+ } else {
87638+ match->prev->next = match->next;
87639+ if (match->next != NULL)
87640+ match->next->prev = match->prev;
87641+ }
87642+ match->prev = NULL;
87643+ match->next = NULL;
87644+ match->nentry->inode = newinode;
87645+ match->nentry->device = newdevice;
87646+ match->nentry->deleted = 0;
87647+
87648+ insert_inodev_entry(match);
87649+ }
87650+
87651+ return;
87652+}
87653+
87654+static void
87655+__do_handle_create(const struct name_entry *matchn, u64 ino, dev_t dev)
87656+{
87657+ struct acl_subject_label *subj;
87658+ struct acl_role_label *role;
87659+ unsigned int x;
87660+
87661+ FOR_EACH_ROLE_START(role)
87662+ update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
87663+
87664+ FOR_EACH_NESTED_SUBJECT_START(role, subj)
87665+ if ((subj->inode == ino) && (subj->device == dev)) {
87666+ subj->inode = ino;
87667+ subj->device = dev;
87668+ }
87669+ /* nested subjects aren't in the role's subj_hash table */
87670+ update_acl_obj_label(matchn->inode, matchn->device,
87671+ ino, dev, subj);
87672+ FOR_EACH_NESTED_SUBJECT_END(subj)
87673+ FOR_EACH_SUBJECT_START(role, subj, x)
87674+ update_acl_obj_label(matchn->inode, matchn->device,
87675+ ino, dev, subj);
87676+ FOR_EACH_SUBJECT_END(subj,x)
87677+ FOR_EACH_ROLE_END(role)
87678+
87679+ update_inodev_entry(matchn->inode, matchn->device, ino, dev);
87680+
87681+ return;
87682+}
87683+
87684+static void
87685+do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
87686+ const struct vfsmount *mnt)
87687+{
87688+ u64 ino = __get_ino(dentry);
87689+ dev_t dev = __get_dev(dentry);
87690+
87691+ __do_handle_create(matchn, ino, dev);
87692+
87693+ return;
87694+}
87695+
87696+void
87697+gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
87698+{
87699+ struct name_entry *matchn;
87700+
87701+ if (unlikely(!(gr_status & GR_READY)))
87702+ return;
87703+
87704+ preempt_disable();
87705+ matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
87706+
87707+ if (unlikely((unsigned long)matchn)) {
87708+ write_lock(&gr_inode_lock);
87709+ do_handle_create(matchn, dentry, mnt);
87710+ write_unlock(&gr_inode_lock);
87711+ }
87712+ preempt_enable();
87713+
87714+ return;
87715+}
87716+
87717+void
87718+gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
87719+{
87720+ struct name_entry *matchn;
87721+
87722+ if (unlikely(!(gr_status & GR_READY)))
87723+ return;
87724+
87725+ preempt_disable();
87726+ matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
87727+
87728+ if (unlikely((unsigned long)matchn)) {
87729+ write_lock(&gr_inode_lock);
87730+ __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
87731+ write_unlock(&gr_inode_lock);
87732+ }
87733+ preempt_enable();
87734+
87735+ return;
87736+}
87737+
87738+void
87739+gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
87740+ struct dentry *old_dentry,
87741+ struct dentry *new_dentry,
87742+ struct vfsmount *mnt, const __u8 replace, unsigned int flags)
87743+{
87744+ struct name_entry *matchn;
87745+ struct name_entry *matchn2 = NULL;
87746+ struct inodev_entry *inodev;
87747+ struct inode *inode = d_backing_inode(new_dentry);
87748+ struct inode *old_inode = d_backing_inode(old_dentry);
87749+ u64 old_ino = __get_ino(old_dentry);
87750+ dev_t old_dev = __get_dev(old_dentry);
87751+ unsigned int exchange = flags & RENAME_EXCHANGE;
87752+
87753+ /* vfs_rename swaps the name and parent link for old_dentry and
87754+ new_dentry
87755+ at this point, old_dentry has the new name, parent link, and inode
87756+ for the renamed file
87757+ if a file is being replaced by a rename, new_dentry has the inode
87758+ and name for the replaced file
87759+ */
87760+
87761+ if (unlikely(!(gr_status & GR_READY)))
87762+ return;
87763+
87764+ preempt_disable();
87765+ matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
87766+
87767+ /* exchange cases:
87768+ a filename exists for the source, but not dest
87769+ do a recreate on source
87770+ a filename exists for the dest, but not source
87771+ do a recreate on dest
87772+ a filename exists for both source and dest
87773+ delete source and dest, then create source and dest
87774+ a filename exists for neither source nor dest
87775+ no updates needed
87776+
87777+ the name entry lookups get us the old inode/dev associated with
87778+ each name, so do the deletes first (if possible) so that when
87779+ we do the create, we pick up on the right entries
87780+ */
87781+
87782+ if (exchange)
87783+ matchn2 = lookup_name_entry(gr_to_filename_rbac(new_dentry, mnt));
87784+
87785+ /* we wouldn't have to check d_inode if it weren't for
87786+ NFS silly-renaming
87787+ */
87788+
87789+ write_lock(&gr_inode_lock);
87790+ if (unlikely((replace || exchange) && inode)) {
87791+ u64 new_ino = __get_ino(new_dentry);
87792+ dev_t new_dev = __get_dev(new_dentry);
87793+
87794+ inodev = lookup_inodev_entry(new_ino, new_dev);
87795+ if (inodev != NULL && ((inode->i_nlink <= 1) || d_is_dir(new_dentry)))
87796+ do_handle_delete(inodev, new_ino, new_dev);
87797+ }
87798+
87799+ inodev = lookup_inodev_entry(old_ino, old_dev);
87800+ if (inodev != NULL && ((old_inode->i_nlink <= 1) || d_is_dir(old_dentry)))
87801+ do_handle_delete(inodev, old_ino, old_dev);
87802+
87803+ if (unlikely(matchn != NULL))
87804+ do_handle_create(matchn, old_dentry, mnt);
87805+
87806+ if (unlikely(matchn2 != NULL))
87807+ do_handle_create(matchn2, new_dentry, mnt);
87808+
87809+ write_unlock(&gr_inode_lock);
87810+ preempt_enable();
87811+
87812+ return;
87813+}
87814+
87815+#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
87816+static const unsigned long res_learn_bumps[GR_NLIMITS] = {
87817+ [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
87818+ [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
87819+ [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
87820+ [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
87821+ [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
87822+ [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
87823+ [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
87824+ [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
87825+ [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
87826+ [RLIMIT_AS] = GR_RLIM_AS_BUMP,
87827+ [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
87828+ [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
87829+ [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
87830+ [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
87831+ [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
87832+ [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
87833+};
87834+
87835+void
87836+gr_learn_resource(const struct task_struct *task,
87837+ const int res, const unsigned long wanted, const int gt)
87838+{
87839+ struct acl_subject_label *acl;
87840+ const struct cred *cred;
87841+
87842+ if (unlikely((gr_status & GR_READY) &&
87843+ task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
87844+ goto skip_reslog;
87845+
87846+ gr_log_resource(task, res, wanted, gt);
87847+skip_reslog:
87848+
87849+ if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
87850+ return;
87851+
87852+ acl = task->acl;
87853+
87854+ if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
87855+ !(acl->resmask & (1U << (unsigned short) res))))
87856+ return;
87857+
87858+ if (wanted >= acl->res[res].rlim_cur) {
87859+ unsigned long res_add;
87860+
87861+ res_add = wanted + res_learn_bumps[res];
87862+
87863+ acl->res[res].rlim_cur = res_add;
87864+
87865+ if (wanted > acl->res[res].rlim_max)
87866+ acl->res[res].rlim_max = res_add;
87867+
87868+ /* only log the subject filename, since resource logging is supported for
87869+ single-subject learning only */
87870+ rcu_read_lock();
87871+ cred = __task_cred(task);
87872+ security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
87873+ task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
87874+ acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
87875+ "", (unsigned long) res, &task->signal->saved_ip);
87876+ rcu_read_unlock();
87877+ }
87878+
87879+ return;
87880+}
87881+EXPORT_SYMBOL_GPL(gr_learn_resource);
87882+#endif
87883+
87884+#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
87885+void
87886+pax_set_initial_flags(struct linux_binprm *bprm)
87887+{
87888+ struct task_struct *task = current;
87889+ struct acl_subject_label *proc;
87890+ unsigned long flags;
87891+
87892+ if (unlikely(!(gr_status & GR_READY)))
87893+ return;
87894+
87895+ flags = pax_get_flags(task);
87896+
87897+ proc = task->acl;
87898+
87899+ if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
87900+ flags &= ~MF_PAX_PAGEEXEC;
87901+ if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
87902+ flags &= ~MF_PAX_SEGMEXEC;
87903+ if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
87904+ flags &= ~MF_PAX_RANDMMAP;
87905+ if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
87906+ flags &= ~MF_PAX_EMUTRAMP;
87907+ if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
87908+ flags &= ~MF_PAX_MPROTECT;
87909+
87910+ if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
87911+ flags |= MF_PAX_PAGEEXEC;
87912+ if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
87913+ flags |= MF_PAX_SEGMEXEC;
87914+ if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
87915+ flags |= MF_PAX_RANDMMAP;
87916+ if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
87917+ flags |= MF_PAX_EMUTRAMP;
87918+ if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
87919+ flags |= MF_PAX_MPROTECT;
87920+
87921+ pax_set_flags(task, flags);
87922+
87923+ return;
87924+}
87925+#endif
87926+
87927+int
87928+gr_handle_proc_ptrace(struct task_struct *task)
87929+{
87930+ struct file *filp;
87931+ struct task_struct *tmp = task;
87932+ struct task_struct *curtemp = current;
87933+ __u32 retmode;
87934+
87935+#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
87936+ if (unlikely(!(gr_status & GR_READY)))
87937+ return 0;
87938+#endif
87939+
87940+ read_lock(&tasklist_lock);
87941+ read_lock(&grsec_exec_file_lock);
87942+ filp = task->exec_file;
87943+
87944+ while (task_pid_nr(tmp) > 0) {
87945+ if (tmp == curtemp)
87946+ break;
87947+ tmp = tmp->real_parent;
87948+ }
87949+
87950+ if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
87951+ ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
87952+ read_unlock(&grsec_exec_file_lock);
87953+ read_unlock(&tasklist_lock);
87954+ return 1;
87955+ }
87956+
87957+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
87958+ if (!(gr_status & GR_READY)) {
87959+ read_unlock(&grsec_exec_file_lock);
87960+ read_unlock(&tasklist_lock);
87961+ return 0;
87962+ }
87963+#endif
87964+
87965+ retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
87966+ read_unlock(&grsec_exec_file_lock);
87967+ read_unlock(&tasklist_lock);
87968+
87969+ if (retmode & GR_NOPTRACE)
87970+ return 1;
87971+
87972+ if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
87973+ && (current->acl != task->acl || (current->acl != current->role->root_label
87974+ && task_pid_nr(current) != task_pid_nr(task))))
87975+ return 1;
87976+
87977+ return 0;
87978+}
87979+
87980+void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
87981+{
87982+ if (unlikely(!(gr_status & GR_READY)))
87983+ return;
87984+
87985+ if (!(current->role->roletype & GR_ROLE_GOD))
87986+ return;
87987+
87988+ seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
87989+ p->role->rolename, gr_task_roletype_to_char(p),
87990+ p->acl->filename);
87991+}
87992+
87993+int
87994+gr_handle_ptrace(struct task_struct *task, const long request)
87995+{
87996+ struct task_struct *tmp = task;
87997+ struct task_struct *curtemp = current;
87998+ __u32 retmode;
87999+
88000+#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
88001+ if (unlikely(!(gr_status & GR_READY)))
88002+ return 0;
88003+#endif
88004+ if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
88005+ read_lock(&tasklist_lock);
88006+ while (task_pid_nr(tmp) > 0) {
88007+ if (tmp == curtemp)
88008+ break;
88009+ tmp = tmp->real_parent;
88010+ }
88011+
88012+ if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
88013+ ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
88014+ read_unlock(&tasklist_lock);
88015+ gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
88016+ return 1;
88017+ }
88018+ read_unlock(&tasklist_lock);
88019+ }
88020+
88021+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
88022+ if (!(gr_status & GR_READY))
88023+ return 0;
88024+#endif
88025+
88026+ read_lock(&grsec_exec_file_lock);
88027+ if (unlikely(!task->exec_file)) {
88028+ read_unlock(&grsec_exec_file_lock);
88029+ return 0;
88030+ }
88031+
88032+ retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
88033+ read_unlock(&grsec_exec_file_lock);
88034+
88035+ if (retmode & GR_NOPTRACE) {
88036+ gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
88037+ return 1;
88038+ }
88039+
88040+ if (retmode & GR_PTRACERD) {
88041+ switch (request) {
88042+ case PTRACE_SEIZE:
88043+ case PTRACE_POKETEXT:
88044+ case PTRACE_POKEDATA:
88045+ case PTRACE_POKEUSR:
88046+#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
88047+ case PTRACE_SETREGS:
88048+ case PTRACE_SETFPREGS:
88049+#endif
88050+#ifdef CONFIG_X86
88051+ case PTRACE_SETFPXREGS:
88052+#endif
88053+#ifdef CONFIG_ALTIVEC
88054+ case PTRACE_SETVRREGS:
88055+#endif
88056+ return 1;
88057+ default:
88058+ return 0;
88059+ }
88060+ } else if (!(current->acl->mode & GR_POVERRIDE) &&
88061+ !(current->role->roletype & GR_ROLE_GOD) &&
88062+ (current->acl != task->acl)) {
88063+ gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
88064+ return 1;
88065+ }
88066+
88067+ return 0;
88068+}
88069+
88070+static int is_writable_mmap(const struct file *filp)
88071+{
88072+ struct task_struct *task = current;
88073+ struct acl_object_label *obj, *obj2;
88074+ struct dentry *dentry = filp->f_path.dentry;
88075+ struct vfsmount *mnt = filp->f_path.mnt;
88076+ struct inode *inode = d_backing_inode(dentry);
88077+
88078+ if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
88079+ !task->is_writable && d_is_reg(dentry) && (mnt != shm_mnt || (inode->i_nlink > 0))) {
88080+ obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
88081+ obj2 = chk_obj_label(dentry, mnt, task->role->root_label);
88082+ if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
88083+ gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, dentry, mnt);
88084+ return 1;
88085+ }
88086+ }
88087+ return 0;
88088+}
88089+
88090+int
88091+gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
88092+{
88093+ __u32 mode;
88094+
88095+ if (unlikely(!file || !(prot & PROT_EXEC)))
88096+ return 1;
88097+
88098+ if (is_writable_mmap(file))
88099+ return 0;
88100+
88101+ mode =
88102+ gr_search_file(file->f_path.dentry,
88103+ GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
88104+ file->f_path.mnt);
88105+
88106+ if (!gr_tpe_allow(file))
88107+ return 0;
88108+
88109+ if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
88110+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
88111+ return 0;
88112+ } else if (unlikely(!(mode & GR_EXEC))) {
88113+ return 0;
88114+ } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
88115+ gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
88116+ return 1;
88117+ }
88118+
88119+ return 1;
88120+}
88121+
88122+int
88123+gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
88124+{
88125+ __u32 mode;
88126+
88127+ if (unlikely(!file || !(prot & PROT_EXEC)))
88128+ return 1;
88129+
88130+ if (is_writable_mmap(file))
88131+ return 0;
88132+
88133+ mode =
88134+ gr_search_file(file->f_path.dentry,
88135+ GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
88136+ file->f_path.mnt);
88137+
88138+ if (!gr_tpe_allow(file))
88139+ return 0;
88140+
88141+ if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
88142+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
88143+ return 0;
88144+ } else if (unlikely(!(mode & GR_EXEC))) {
88145+ return 0;
88146+ } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
88147+ gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
88148+ return 1;
88149+ }
88150+
88151+ return 1;
88152+}
88153+
88154+void
88155+gr_acl_handle_psacct(struct task_struct *task, const long code)
88156+{
88157+ unsigned long runtime, cputime;
88158+ cputime_t utime, stime;
88159+ unsigned int wday, cday;
88160+ __u8 whr, chr;
88161+ __u8 wmin, cmin;
88162+ __u8 wsec, csec;
88163+ struct timespec curtime, starttime;
88164+
88165+ if (unlikely(!(gr_status & GR_READY) || !task->acl ||
88166+ !(task->acl->mode & GR_PROCACCT)))
88167+ return;
88168+
88169+ curtime = ns_to_timespec(ktime_get_ns());
88170+ starttime = ns_to_timespec(task->start_time);
88171+ runtime = curtime.tv_sec - starttime.tv_sec;
88172+ wday = runtime / (60 * 60 * 24);
88173+ runtime -= wday * (60 * 60 * 24);
88174+ whr = runtime / (60 * 60);
88175+ runtime -= whr * (60 * 60);
88176+ wmin = runtime / 60;
88177+ runtime -= wmin * 60;
88178+ wsec = runtime;
88179+
88180+ task_cputime(task, &utime, &stime);
88181+ cputime = cputime_to_secs(utime + stime);
88182+ cday = cputime / (60 * 60 * 24);
88183+ cputime -= cday * (60 * 60 * 24);
88184+ chr = cputime / (60 * 60);
88185+ cputime -= chr * (60 * 60);
88186+ cmin = cputime / 60;
88187+ cputime -= cmin * 60;
88188+ csec = cputime;
88189+
88190+ gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
88191+
88192+ return;
88193+}
88194+
88195+#ifdef CONFIG_TASKSTATS
88196+int gr_is_taskstats_denied(int pid)
88197+{
88198+ struct task_struct *task;
88199+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
88200+ const struct cred *cred;
88201+#endif
88202+ int ret = 0;
88203+
88204+ /* restrict taskstats viewing to un-chrooted root users
88205+ who have the 'view' subject flag if the RBAC system is enabled
88206+ */
88207+
88208+ rcu_read_lock();
88209+ read_lock(&tasklist_lock);
88210+ task = find_task_by_vpid(pid);
88211+ if (task) {
88212+#ifdef CONFIG_GRKERNSEC_CHROOT
88213+ if (proc_is_chrooted(task))
88214+ ret = -EACCES;
88215+#endif
88216+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
88217+ cred = __task_cred(task);
88218+#ifdef CONFIG_GRKERNSEC_PROC_USER
88219+ if (gr_is_global_nonroot(cred->uid))
88220+ ret = -EACCES;
88221+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
88222+ if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
88223+ ret = -EACCES;
88224+#endif
88225+#endif
88226+ if (gr_status & GR_READY) {
88227+ if (!(task->acl->mode & GR_VIEW))
88228+ ret = -EACCES;
88229+ }
88230+ } else
88231+ ret = -ENOENT;
88232+
88233+ read_unlock(&tasklist_lock);
88234+ rcu_read_unlock();
88235+
88236+ return ret;
88237+}
88238+#endif
88239+
88240+/* AUXV entries are filled via a descendant of search_binary_handler
88241+ after we've already applied the subject for the target
88242+*/
88243+int gr_acl_enable_at_secure(void)
88244+{
88245+ if (unlikely(!(gr_status & GR_READY)))
88246+ return 0;
88247+
88248+ if (current->acl->mode & GR_ATSECURE)
88249+ return 1;
88250+
88251+ return 0;
88252+}
88253+
88254+int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const u64 ino)
88255+{
88256+ struct task_struct *task = current;
88257+ struct dentry *dentry = file->f_path.dentry;
88258+ struct vfsmount *mnt = file->f_path.mnt;
88259+ struct acl_object_label *obj, *tmp;
88260+ struct acl_subject_label *subj;
88261+ unsigned int bufsize;
88262+ int is_not_root;
88263+ char *path;
88264+ dev_t dev = __get_dev(dentry);
88265+
88266+ if (unlikely(!(gr_status & GR_READY)))
88267+ return 1;
88268+
88269+ if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
88270+ return 1;
88271+
88272+ /* ignore Eric Biederman */
88273+ if (IS_PRIVATE(d_backing_inode(dentry)))
88274+ return 1;
88275+
88276+ subj = task->acl;
88277+ read_lock(&gr_inode_lock);
88278+ do {
88279+ obj = lookup_acl_obj_label(ino, dev, subj);
88280+ if (obj != NULL) {
88281+ read_unlock(&gr_inode_lock);
88282+ return (obj->mode & GR_FIND) ? 1 : 0;
88283+ }
88284+ } while ((subj = subj->parent_subject));
88285+ read_unlock(&gr_inode_lock);
88286+
88287+ /* this is purely an optimization since we're looking for an object
88288+ for the directory we're doing a readdir on
88289+ if it's possible for any globbed object to match the entry we're
88290+ filling into the directory, then the object we find here will be
88291+ an anchor point with attached globbed objects
88292+ */
88293+ obj = chk_obj_label_noglob(dentry, mnt, task->acl);
88294+ if (obj->globbed == NULL)
88295+ return (obj->mode & GR_FIND) ? 1 : 0;
88296+
88297+ is_not_root = ((obj->filename[0] == '/') &&
88298+ (obj->filename[1] == '\0')) ? 0 : 1;
88299+ bufsize = PAGE_SIZE - namelen - is_not_root;
88300+
88301+ /* check bufsize > PAGE_SIZE || bufsize == 0 */
88302+ if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
88303+ return 1;
88304+
88305+ preempt_disable();
88306+ path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
88307+ bufsize);
88308+
88309+ bufsize = strlen(path);
88310+
88311+ /* if base is "/", don't append an additional slash */
88312+ if (is_not_root)
88313+ *(path + bufsize) = '/';
88314+ memcpy(path + bufsize + is_not_root, name, namelen);
88315+ *(path + bufsize + namelen + is_not_root) = '\0';
88316+
88317+ tmp = obj->globbed;
88318+ while (tmp) {
88319+ if (!glob_match(tmp->filename, path)) {
88320+ preempt_enable();
88321+ return (tmp->mode & GR_FIND) ? 1 : 0;
88322+ }
88323+ tmp = tmp->next;
88324+ }
88325+ preempt_enable();
88326+ return (obj->mode & GR_FIND) ? 1 : 0;
88327+}
88328+
88329+void gr_put_exec_file(struct task_struct *task)
88330+{
88331+ struct file *filp;
88332+
88333+ write_lock(&grsec_exec_file_lock);
88334+ filp = task->exec_file;
88335+ task->exec_file = NULL;
88336+ write_unlock(&grsec_exec_file_lock);
88337+
88338+ if (filp)
88339+ fput(filp);
88340+
88341+ return;
88342+}
88343+
88344+
88345+#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
88346+EXPORT_SYMBOL_GPL(gr_acl_is_enabled);
88347+#endif
88348+#ifdef CONFIG_SECURITY
88349+EXPORT_SYMBOL_GPL(gr_check_user_change);
88350+EXPORT_SYMBOL_GPL(gr_check_group_change);
88351+#endif
88352+
88353diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
88354new file mode 100644
88355index 0000000..9adc75c
88356--- /dev/null
88357+++ b/grsecurity/gracl_alloc.c
88358@@ -0,0 +1,105 @@
88359+#include <linux/kernel.h>
88360+#include <linux/mm.h>
88361+#include <linux/slab.h>
88362+#include <linux/vmalloc.h>
88363+#include <linux/gracl.h>
88364+#include <linux/grsecurity.h>
88365+
88366+static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
88367+struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
88368+
88369+static int
88370+alloc_pop(void)
88371+{
88372+ if (current_alloc_state->alloc_stack_next == 1)
88373+ return 0;
88374+
88375+ kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
88376+
88377+ current_alloc_state->alloc_stack_next--;
88378+
88379+ return 1;
88380+}
88381+
88382+static int
88383+alloc_push(void *buf)
88384+{
88385+ if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
88386+ return 1;
88387+
88388+ current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
88389+
88390+ current_alloc_state->alloc_stack_next++;
88391+
88392+ return 0;
88393+}
88394+
88395+void *
88396+acl_alloc(unsigned long len)
88397+{
88398+ void *ret = NULL;
88399+
88400+ if (!len || len > PAGE_SIZE)
88401+ goto out;
88402+
88403+ ret = kmalloc(len, GFP_KERNEL);
88404+
88405+ if (ret) {
88406+ if (alloc_push(ret)) {
88407+ kfree(ret);
88408+ ret = NULL;
88409+ }
88410+ }
88411+
88412+out:
88413+ return ret;
88414+}
88415+
88416+void *
88417+acl_alloc_num(unsigned long num, unsigned long len)
88418+{
88419+ if (!len || (num > (PAGE_SIZE / len)))
88420+ return NULL;
88421+
88422+ return acl_alloc(num * len);
88423+}
88424+
88425+void
88426+acl_free_all(void)
88427+{
88428+ if (!current_alloc_state->alloc_stack)
88429+ return;
88430+
88431+ while (alloc_pop()) ;
88432+
88433+ if (current_alloc_state->alloc_stack) {
88434+ if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
88435+ kfree(current_alloc_state->alloc_stack);
88436+ else
88437+ vfree(current_alloc_state->alloc_stack);
88438+ }
88439+
88440+ current_alloc_state->alloc_stack = NULL;
88441+ current_alloc_state->alloc_stack_size = 1;
88442+ current_alloc_state->alloc_stack_next = 1;
88443+
88444+ return;
88445+}
88446+
88447+int
88448+acl_alloc_stack_init(unsigned long size)
88449+{
88450+ if ((size * sizeof (void *)) <= PAGE_SIZE)
88451+ current_alloc_state->alloc_stack =
88452+ (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
88453+ else
88454+ current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
88455+
88456+ current_alloc_state->alloc_stack_size = size;
88457+ current_alloc_state->alloc_stack_next = 1;
88458+
88459+ if (!current_alloc_state->alloc_stack)
88460+ return 0;
88461+ else
88462+ return 1;
88463+}
88464diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
88465new file mode 100644
88466index 0000000..1a94c11
88467--- /dev/null
88468+++ b/grsecurity/gracl_cap.c
88469@@ -0,0 +1,127 @@
88470+#include <linux/kernel.h>
88471+#include <linux/module.h>
88472+#include <linux/sched.h>
88473+#include <linux/gracl.h>
88474+#include <linux/grsecurity.h>
88475+#include <linux/grinternal.h>
88476+
88477+extern const char *captab_log[];
88478+extern int captab_log_entries;
88479+
88480+int gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap)
88481+{
88482+ struct acl_subject_label *curracl;
88483+
88484+ if (!gr_acl_is_enabled())
88485+ return 1;
88486+
88487+ curracl = task->acl;
88488+
88489+ if (curracl->mode & (GR_LEARN | GR_INHERITLEARN)) {
88490+ security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
88491+ task->role->roletype, GR_GLOBAL_UID(cred->uid),
88492+ GR_GLOBAL_GID(cred->gid), task->exec_file ?
88493+ gr_to_filename(task->exec_file->f_path.dentry,
88494+ task->exec_file->f_path.mnt) : curracl->filename,
88495+ curracl->filename, 0UL,
88496+ 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
88497+ return 1;
88498+ }
88499+
88500+ return 0;
88501+}
88502+
88503+int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
88504+{
88505+ struct acl_subject_label *curracl;
88506+ kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
88507+ kernel_cap_t cap_audit = __cap_empty_set;
88508+
88509+ if (!gr_acl_is_enabled())
88510+ return 1;
88511+
88512+ curracl = task->acl;
88513+
88514+ cap_drop = curracl->cap_lower;
88515+ cap_mask = curracl->cap_mask;
88516+ cap_audit = curracl->cap_invert_audit;
88517+
88518+ while ((curracl = curracl->parent_subject)) {
88519+ /* if the cap isn't specified in the current computed mask but is specified in the
88520+ current level subject, and is lowered in the current level subject, then add
88521+ it to the set of dropped capabilities
88522+ otherwise, add the current level subject's mask to the current computed mask
88523+ */
88524+ if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
88525+ cap_raise(cap_mask, cap);
88526+ if (cap_raised(curracl->cap_lower, cap))
88527+ cap_raise(cap_drop, cap);
88528+ if (cap_raised(curracl->cap_invert_audit, cap))
88529+ cap_raise(cap_audit, cap);
88530+ }
88531+ }
88532+
88533+ if (!cap_raised(cap_drop, cap)) {
88534+ if (cap_raised(cap_audit, cap))
88535+ gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
88536+ return 1;
88537+ }
88538+
88539+ /* only learn the capability use if the process has the capability in the
88540+ general case, the two uses in sys.c of gr_learn_cap are an exception
88541+ to this rule to ensure any role transition involves what the full-learned
88542+ policy believes in a privileged process
88543+ */
88544+ if (cap_raised(cred->cap_effective, cap) && gr_learn_cap(task, cred, cap))
88545+ return 1;
88546+
88547+ if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
88548+ gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
88549+
88550+ return 0;
88551+}
88552+
88553+int
88554+gr_acl_is_capable(const int cap)
88555+{
88556+ return gr_task_acl_is_capable(current, current_cred(), cap);
88557+}
88558+
88559+int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
88560+{
88561+ struct acl_subject_label *curracl;
88562+ kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
88563+
88564+ if (!gr_acl_is_enabled())
88565+ return 1;
88566+
88567+ curracl = task->acl;
88568+
88569+ cap_drop = curracl->cap_lower;
88570+ cap_mask = curracl->cap_mask;
88571+
88572+ while ((curracl = curracl->parent_subject)) {
88573+ /* if the cap isn't specified in the current computed mask but is specified in the
88574+ current level subject, and is lowered in the current level subject, then add
88575+ it to the set of dropped capabilities
88576+ otherwise, add the current level subject's mask to the current computed mask
88577+ */
88578+ if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
88579+ cap_raise(cap_mask, cap);
88580+ if (cap_raised(curracl->cap_lower, cap))
88581+ cap_raise(cap_drop, cap);
88582+ }
88583+ }
88584+
88585+ if (!cap_raised(cap_drop, cap))
88586+ return 1;
88587+
88588+ return 0;
88589+}
88590+
88591+int
88592+gr_acl_is_capable_nolog(const int cap)
88593+{
88594+ return gr_task_acl_is_capable_nolog(current, cap);
88595+}
88596+
88597diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
88598new file mode 100644
88599index 0000000..a43dd06
88600--- /dev/null
88601+++ b/grsecurity/gracl_compat.c
88602@@ -0,0 +1,269 @@
88603+#include <linux/kernel.h>
88604+#include <linux/gracl.h>
88605+#include <linux/compat.h>
88606+#include <linux/gracl_compat.h>
88607+
88608+#include <asm/uaccess.h>
88609+
88610+int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
88611+{
88612+ struct gr_arg_wrapper_compat uwrapcompat;
88613+
88614+ if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
88615+ return -EFAULT;
88616+
88617+ if ((uwrapcompat.version != GRSECURITY_VERSION) ||
88618+ (uwrapcompat.size != sizeof(struct gr_arg_compat)))
88619+ return -EINVAL;
88620+
88621+ uwrap->arg = compat_ptr(uwrapcompat.arg);
88622+ uwrap->version = uwrapcompat.version;
88623+ uwrap->size = sizeof(struct gr_arg);
88624+
88625+ return 0;
88626+}
88627+
88628+int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
88629+{
88630+ struct gr_arg_compat argcompat;
88631+
88632+ if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
88633+ return -EFAULT;
88634+
88635+ arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
88636+ arg->role_db.num_pointers = argcompat.role_db.num_pointers;
88637+ arg->role_db.num_roles = argcompat.role_db.num_roles;
88638+ arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
88639+ arg->role_db.num_subjects = argcompat.role_db.num_subjects;
88640+ arg->role_db.num_objects = argcompat.role_db.num_objects;
88641+
88642+ memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
88643+ memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
88644+ memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
88645+ memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
88646+ arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
88647+ arg->segv_device = argcompat.segv_device;
88648+ arg->segv_inode = argcompat.segv_inode;
88649+ arg->segv_uid = argcompat.segv_uid;
88650+ arg->num_sprole_pws = argcompat.num_sprole_pws;
88651+ arg->mode = argcompat.mode;
88652+
88653+ return 0;
88654+}
88655+
88656+int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
88657+{
88658+ struct acl_object_label_compat objcompat;
88659+
88660+ if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
88661+ return -EFAULT;
88662+
88663+ obj->filename = compat_ptr(objcompat.filename);
88664+ obj->inode = objcompat.inode;
88665+ obj->device = objcompat.device;
88666+ obj->mode = objcompat.mode;
88667+
88668+ obj->nested = compat_ptr(objcompat.nested);
88669+ obj->globbed = compat_ptr(objcompat.globbed);
88670+
88671+ obj->prev = compat_ptr(objcompat.prev);
88672+ obj->next = compat_ptr(objcompat.next);
88673+
88674+ return 0;
88675+}
88676+
88677+int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
88678+{
88679+ unsigned int i;
88680+ struct acl_subject_label_compat subjcompat;
88681+
88682+ if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
88683+ return -EFAULT;
88684+
88685+ subj->filename = compat_ptr(subjcompat.filename);
88686+ subj->inode = subjcompat.inode;
88687+ subj->device = subjcompat.device;
88688+ subj->mode = subjcompat.mode;
88689+ subj->cap_mask = subjcompat.cap_mask;
88690+ subj->cap_lower = subjcompat.cap_lower;
88691+ subj->cap_invert_audit = subjcompat.cap_invert_audit;
88692+
88693+ for (i = 0; i < GR_NLIMITS; i++) {
88694+ if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
88695+ subj->res[i].rlim_cur = RLIM_INFINITY;
88696+ else
88697+ subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
88698+ if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
88699+ subj->res[i].rlim_max = RLIM_INFINITY;
88700+ else
88701+ subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
88702+ }
88703+ subj->resmask = subjcompat.resmask;
88704+
88705+ subj->user_trans_type = subjcompat.user_trans_type;
88706+ subj->group_trans_type = subjcompat.group_trans_type;
88707+ subj->user_transitions = compat_ptr(subjcompat.user_transitions);
88708+ subj->group_transitions = compat_ptr(subjcompat.group_transitions);
88709+ subj->user_trans_num = subjcompat.user_trans_num;
88710+ subj->group_trans_num = subjcompat.group_trans_num;
88711+
88712+ memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
88713+ memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
88714+ subj->ip_type = subjcompat.ip_type;
88715+ subj->ips = compat_ptr(subjcompat.ips);
88716+ subj->ip_num = subjcompat.ip_num;
88717+ subj->inaddr_any_override = subjcompat.inaddr_any_override;
88718+
88719+ subj->crashes = subjcompat.crashes;
88720+ subj->expires = subjcompat.expires;
88721+
88722+ subj->parent_subject = compat_ptr(subjcompat.parent_subject);
88723+ subj->hash = compat_ptr(subjcompat.hash);
88724+ subj->prev = compat_ptr(subjcompat.prev);
88725+ subj->next = compat_ptr(subjcompat.next);
88726+
88727+ subj->obj_hash = compat_ptr(subjcompat.obj_hash);
88728+ subj->obj_hash_size = subjcompat.obj_hash_size;
88729+ subj->pax_flags = subjcompat.pax_flags;
88730+
88731+ return 0;
88732+}
88733+
88734+int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
88735+{
88736+ struct acl_role_label_compat rolecompat;
88737+
88738+ if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
88739+ return -EFAULT;
88740+
88741+ role->rolename = compat_ptr(rolecompat.rolename);
88742+ role->uidgid = rolecompat.uidgid;
88743+ role->roletype = rolecompat.roletype;
88744+
88745+ role->auth_attempts = rolecompat.auth_attempts;
88746+ role->expires = rolecompat.expires;
88747+
88748+ role->root_label = compat_ptr(rolecompat.root_label);
88749+ role->hash = compat_ptr(rolecompat.hash);
88750+
88751+ role->prev = compat_ptr(rolecompat.prev);
88752+ role->next = compat_ptr(rolecompat.next);
88753+
88754+ role->transitions = compat_ptr(rolecompat.transitions);
88755+ role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
88756+ role->domain_children = compat_ptr(rolecompat.domain_children);
88757+ role->domain_child_num = rolecompat.domain_child_num;
88758+
88759+ role->umask = rolecompat.umask;
88760+
88761+ role->subj_hash = compat_ptr(rolecompat.subj_hash);
88762+ role->subj_hash_size = rolecompat.subj_hash_size;
88763+
88764+ return 0;
88765+}
88766+
88767+int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
88768+{
88769+ struct role_allowed_ip_compat roleip_compat;
88770+
88771+ if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
88772+ return -EFAULT;
88773+
88774+ roleip->addr = roleip_compat.addr;
88775+ roleip->netmask = roleip_compat.netmask;
88776+
88777+ roleip->prev = compat_ptr(roleip_compat.prev);
88778+ roleip->next = compat_ptr(roleip_compat.next);
88779+
88780+ return 0;
88781+}
88782+
88783+int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
88784+{
88785+ struct role_transition_compat trans_compat;
88786+
88787+ if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
88788+ return -EFAULT;
88789+
88790+ trans->rolename = compat_ptr(trans_compat.rolename);
88791+
88792+ trans->prev = compat_ptr(trans_compat.prev);
88793+ trans->next = compat_ptr(trans_compat.next);
88794+
88795+ return 0;
88796+
88797+}
88798+
88799+int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
88800+{
88801+ struct gr_hash_struct_compat hash_compat;
88802+
88803+ if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
88804+ return -EFAULT;
88805+
88806+ hash->table = compat_ptr(hash_compat.table);
88807+ hash->nametable = compat_ptr(hash_compat.nametable);
88808+ hash->first = compat_ptr(hash_compat.first);
88809+
88810+ hash->table_size = hash_compat.table_size;
88811+ hash->used_size = hash_compat.used_size;
88812+
88813+ hash->type = hash_compat.type;
88814+
88815+ return 0;
88816+}
88817+
88818+int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
88819+{
88820+ compat_uptr_t ptrcompat;
88821+
88822+ if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
88823+ return -EFAULT;
88824+
88825+ *(void **)ptr = compat_ptr(ptrcompat);
88826+
88827+ return 0;
88828+}
88829+
88830+int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
88831+{
88832+ struct acl_ip_label_compat ip_compat;
88833+
88834+ if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
88835+ return -EFAULT;
88836+
88837+ ip->iface = compat_ptr(ip_compat.iface);
88838+ ip->addr = ip_compat.addr;
88839+ ip->netmask = ip_compat.netmask;
88840+ ip->low = ip_compat.low;
88841+ ip->high = ip_compat.high;
88842+ ip->mode = ip_compat.mode;
88843+ ip->type = ip_compat.type;
88844+
88845+ memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
88846+
88847+ ip->prev = compat_ptr(ip_compat.prev);
88848+ ip->next = compat_ptr(ip_compat.next);
88849+
88850+ return 0;
88851+}
88852+
88853+int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
88854+{
88855+ struct sprole_pw_compat pw_compat;
88856+
88857+ if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
88858+ return -EFAULT;
88859+
88860+ pw->rolename = compat_ptr(pw_compat.rolename);
88861+ memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
88862+ memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
88863+
88864+ return 0;
88865+}
88866+
88867+size_t get_gr_arg_wrapper_size_compat(void)
88868+{
88869+ return sizeof(struct gr_arg_wrapper_compat);
88870+}
88871+
88872diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
88873new file mode 100644
88874index 0000000..fce7f71
88875--- /dev/null
88876+++ b/grsecurity/gracl_fs.c
88877@@ -0,0 +1,448 @@
88878+#include <linux/kernel.h>
88879+#include <linux/sched.h>
88880+#include <linux/types.h>
88881+#include <linux/fs.h>
88882+#include <linux/file.h>
88883+#include <linux/stat.h>
88884+#include <linux/grsecurity.h>
88885+#include <linux/grinternal.h>
88886+#include <linux/gracl.h>
88887+
88888+umode_t
88889+gr_acl_umask(void)
88890+{
88891+ if (unlikely(!gr_acl_is_enabled()))
88892+ return 0;
88893+
88894+ return current->role->umask;
88895+}
88896+
88897+__u32
88898+gr_acl_handle_hidden_file(const struct dentry * dentry,
88899+ const struct vfsmount * mnt)
88900+{
88901+ __u32 mode;
88902+
88903+ if (unlikely(d_is_negative(dentry)))
88904+ return GR_FIND;
88905+
88906+ mode =
88907+ gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
88908+
88909+ if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
88910+ gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
88911+ return mode;
88912+ } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
88913+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
88914+ return 0;
88915+ } else if (unlikely(!(mode & GR_FIND)))
88916+ return 0;
88917+
88918+ return GR_FIND;
88919+}
88920+
88921+__u32
88922+gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
88923+ int acc_mode)
88924+{
88925+ __u32 reqmode = GR_FIND;
88926+ __u32 mode;
88927+
88928+ if (unlikely(d_is_negative(dentry)))
88929+ return reqmode;
88930+
88931+ if (acc_mode & MAY_APPEND)
88932+ reqmode |= GR_APPEND;
88933+ else if (acc_mode & MAY_WRITE)
88934+ reqmode |= GR_WRITE;
88935+ if ((acc_mode & MAY_READ) && !d_is_dir(dentry))
88936+ reqmode |= GR_READ;
88937+
88938+ mode =
88939+ gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
88940+ mnt);
88941+
88942+ if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
88943+ gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
88944+ reqmode & GR_READ ? " reading" : "",
88945+ reqmode & GR_WRITE ? " writing" : reqmode &
88946+ GR_APPEND ? " appending" : "");
88947+ return reqmode;
88948+ } else
88949+ if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
88950+ {
88951+ gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
88952+ reqmode & GR_READ ? " reading" : "",
88953+ reqmode & GR_WRITE ? " writing" : reqmode &
88954+ GR_APPEND ? " appending" : "");
88955+ return 0;
88956+ } else if (unlikely((mode & reqmode) != reqmode))
88957+ return 0;
88958+
88959+ return reqmode;
88960+}
88961+
88962+__u32
88963+gr_acl_handle_creat(const struct dentry * dentry,
88964+ const struct dentry * p_dentry,
88965+ const struct vfsmount * p_mnt, int open_flags, int acc_mode,
88966+ const int imode)
88967+{
88968+ __u32 reqmode = GR_WRITE | GR_CREATE;
88969+ __u32 mode;
88970+
88971+ if (acc_mode & MAY_APPEND)
88972+ reqmode |= GR_APPEND;
88973+ // if a directory was required or the directory already exists, then
88974+ // don't count this open as a read
88975+ if ((acc_mode & MAY_READ) &&
88976+ !((open_flags & O_DIRECTORY) || d_is_dir(dentry)))
88977+ reqmode |= GR_READ;
88978+ if ((open_flags & O_CREAT) &&
88979+ ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
88980+ reqmode |= GR_SETID;
88981+
88982+ mode =
88983+ gr_check_create(dentry, p_dentry, p_mnt,
88984+ reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
88985+
88986+ if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
88987+ gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
88988+ reqmode & GR_READ ? " reading" : "",
88989+ reqmode & GR_WRITE ? " writing" : reqmode &
88990+ GR_APPEND ? " appending" : "");
88991+ return reqmode;
88992+ } else
88993+ if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
88994+ {
88995+ gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
88996+ reqmode & GR_READ ? " reading" : "",
88997+ reqmode & GR_WRITE ? " writing" : reqmode &
88998+ GR_APPEND ? " appending" : "");
88999+ return 0;
89000+ } else if (unlikely((mode & reqmode) != reqmode))
89001+ return 0;
89002+
89003+ return reqmode;
89004+}
89005+
89006+__u32
89007+gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
89008+ const int fmode)
89009+{
89010+ __u32 mode, reqmode = GR_FIND;
89011+
89012+ if ((fmode & S_IXOTH) && !d_is_dir(dentry))
89013+ reqmode |= GR_EXEC;
89014+ if (fmode & S_IWOTH)
89015+ reqmode |= GR_WRITE;
89016+ if (fmode & S_IROTH)
89017+ reqmode |= GR_READ;
89018+
89019+ mode =
89020+ gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
89021+ mnt);
89022+
89023+ if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
89024+ gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
89025+ reqmode & GR_READ ? " reading" : "",
89026+ reqmode & GR_WRITE ? " writing" : "",
89027+ reqmode & GR_EXEC ? " executing" : "");
89028+ return reqmode;
89029+ } else
89030+ if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
89031+ {
89032+ gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
89033+ reqmode & GR_READ ? " reading" : "",
89034+ reqmode & GR_WRITE ? " writing" : "",
89035+ reqmode & GR_EXEC ? " executing" : "");
89036+ return 0;
89037+ } else if (unlikely((mode & reqmode) != reqmode))
89038+ return 0;
89039+
89040+ return reqmode;
89041+}
89042+
89043+static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
89044+{
89045+ __u32 mode;
89046+
89047+ mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
89048+
89049+ if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
89050+ gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
89051+ return mode;
89052+ } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
89053+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
89054+ return 0;
89055+ } else if (unlikely((mode & (reqmode)) != (reqmode)))
89056+ return 0;
89057+
89058+ return (reqmode);
89059+}
89060+
89061+__u32
89062+gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
89063+{
89064+ return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
89065+}
89066+
89067+__u32
89068+gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
89069+{
89070+ return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
89071+}
89072+
89073+__u32
89074+gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
89075+{
89076+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
89077+}
89078+
89079+__u32
89080+gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
89081+{
89082+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
89083+}
89084+
89085+__u32
89086+gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
89087+ umode_t *modeptr)
89088+{
89089+ umode_t mode;
89090+ struct inode *inode = d_backing_inode(dentry);
89091+
89092+ *modeptr &= ~gr_acl_umask();
89093+ mode = *modeptr;
89094+
89095+ if (unlikely(inode && S_ISSOCK(inode->i_mode)))
89096+ return 1;
89097+
89098+ if (unlikely(!d_is_dir(dentry) &&
89099+ ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
89100+ return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
89101+ GR_CHMOD_ACL_MSG);
89102+ } else {
89103+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
89104+ }
89105+}
89106+
89107+__u32
89108+gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
89109+{
89110+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
89111+}
89112+
89113+__u32
89114+gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
89115+{
89116+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
89117+}
89118+
89119+__u32
89120+gr_acl_handle_removexattr(const struct dentry *dentry, const struct vfsmount *mnt)
89121+{
89122+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_REMOVEXATTR_ACL_MSG);
89123+}
89124+
89125+__u32
89126+gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
89127+{
89128+ return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
89129+}
89130+
89131+__u32
89132+gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
89133+{
89134+ return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
89135+ GR_UNIXCONNECT_ACL_MSG);
89136+}
89137+
89138+/* hardlinks require at minimum create and link permission,
89139+ any additional privilege required is based on the
89140+ privilege of the file being linked to
89141+*/
89142+__u32
89143+gr_acl_handle_link(const struct dentry * new_dentry,
89144+ const struct dentry * parent_dentry,
89145+ const struct vfsmount * parent_mnt,
89146+ const struct dentry * old_dentry,
89147+ const struct vfsmount * old_mnt, const struct filename *to)
89148+{
89149+ __u32 mode;
89150+ __u32 needmode = GR_CREATE | GR_LINK;
89151+ __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
89152+
89153+ mode =
89154+ gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
89155+ old_mnt);
89156+
89157+ if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
89158+ gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
89159+ return mode;
89160+ } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
89161+ gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
89162+ return 0;
89163+ } else if (unlikely((mode & needmode) != needmode))
89164+ return 0;
89165+
89166+ return 1;
89167+}
89168+
89169+__u32
89170+gr_acl_handle_symlink(const struct dentry * new_dentry,
89171+ const struct dentry * parent_dentry,
89172+ const struct vfsmount * parent_mnt, const struct filename *from)
89173+{
89174+ __u32 needmode = GR_WRITE | GR_CREATE;
89175+ __u32 mode;
89176+
89177+ mode =
89178+ gr_check_create(new_dentry, parent_dentry, parent_mnt,
89179+ GR_CREATE | GR_AUDIT_CREATE |
89180+ GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
89181+
89182+ if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
89183+ gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
89184+ return mode;
89185+ } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
89186+ gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
89187+ return 0;
89188+ } else if (unlikely((mode & needmode) != needmode))
89189+ return 0;
89190+
89191+ return (GR_WRITE | GR_CREATE);
89192+}
89193+
89194+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)
89195+{
89196+ __u32 mode;
89197+
89198+ mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
89199+
89200+ if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
89201+ gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
89202+ return mode;
89203+ } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
89204+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
89205+ return 0;
89206+ } else if (unlikely((mode & (reqmode)) != (reqmode)))
89207+ return 0;
89208+
89209+ return (reqmode);
89210+}
89211+
89212+__u32
89213+gr_acl_handle_mknod(const struct dentry * new_dentry,
89214+ const struct dentry * parent_dentry,
89215+ const struct vfsmount * parent_mnt,
89216+ const int mode)
89217+{
89218+ __u32 reqmode = GR_WRITE | GR_CREATE;
89219+ if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
89220+ reqmode |= GR_SETID;
89221+
89222+ return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
89223+ reqmode, GR_MKNOD_ACL_MSG);
89224+}
89225+
89226+__u32
89227+gr_acl_handle_mkdir(const struct dentry *new_dentry,
89228+ const struct dentry *parent_dentry,
89229+ const struct vfsmount *parent_mnt)
89230+{
89231+ return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
89232+ GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
89233+}
89234+
89235+#define RENAME_CHECK_SUCCESS(old, new) \
89236+ (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
89237+ ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
89238+
89239+int
89240+gr_acl_handle_rename(struct dentry *new_dentry,
89241+ struct dentry *parent_dentry,
89242+ const struct vfsmount *parent_mnt,
89243+ struct dentry *old_dentry,
89244+ struct inode *old_parent_inode,
89245+ struct vfsmount *old_mnt, const struct filename *newname, unsigned int flags)
89246+{
89247+ __u32 comp1, comp2;
89248+ int error = 0;
89249+
89250+ if (unlikely(!gr_acl_is_enabled()))
89251+ return 0;
89252+
89253+ if (flags & RENAME_EXCHANGE) {
89254+ comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
89255+ GR_AUDIT_READ | GR_AUDIT_WRITE |
89256+ GR_SUPPRESS, parent_mnt);
89257+ comp2 =
89258+ gr_search_file(old_dentry,
89259+ GR_READ | GR_WRITE | GR_AUDIT_READ |
89260+ GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
89261+ } else if (d_is_negative(new_dentry)) {
89262+ comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
89263+ GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
89264+ GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
89265+ comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
89266+ GR_DELETE | GR_AUDIT_DELETE |
89267+ GR_AUDIT_READ | GR_AUDIT_WRITE |
89268+ GR_SUPPRESS, old_mnt);
89269+ } else {
89270+ comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
89271+ GR_CREATE | GR_DELETE |
89272+ GR_AUDIT_CREATE | GR_AUDIT_DELETE |
89273+ GR_AUDIT_READ | GR_AUDIT_WRITE |
89274+ GR_SUPPRESS, parent_mnt);
89275+ comp2 =
89276+ gr_search_file(old_dentry,
89277+ GR_READ | GR_WRITE | GR_AUDIT_READ |
89278+ GR_DELETE | GR_AUDIT_DELETE |
89279+ GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
89280+ }
89281+
89282+ if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
89283+ ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
89284+ gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
89285+ else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
89286+ && !(comp2 & GR_SUPPRESS)) {
89287+ gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
89288+ error = -EACCES;
89289+ } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
89290+ error = -EACCES;
89291+
89292+ return error;
89293+}
89294+
89295+void
89296+gr_acl_handle_exit(void)
89297+{
89298+ u16 id;
89299+ char *rolename;
89300+
89301+ if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
89302+ !(current->role->roletype & GR_ROLE_PERSIST))) {
89303+ id = current->acl_role_id;
89304+ rolename = current->role->rolename;
89305+ gr_set_acls(1);
89306+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
89307+ }
89308+
89309+ gr_put_exec_file(current);
89310+ return;
89311+}
89312+
89313+int
89314+gr_acl_handle_procpidmem(const struct task_struct *task)
89315+{
89316+ if (unlikely(!gr_acl_is_enabled()))
89317+ return 0;
89318+
89319+ if (task != current && (task->acl->mode & GR_PROTPROCFD) &&
89320+ !(current->acl->mode & GR_POVERRIDE) &&
89321+ !(current->role->roletype & GR_ROLE_GOD))
89322+ return -EACCES;
89323+
89324+ return 0;
89325+}
89326diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
89327new file mode 100644
89328index 0000000..ed6ee43
89329--- /dev/null
89330+++ b/grsecurity/gracl_ip.c
89331@@ -0,0 +1,386 @@
89332+#include <linux/kernel.h>
89333+#include <asm/uaccess.h>
89334+#include <asm/errno.h>
89335+#include <net/sock.h>
89336+#include <linux/file.h>
89337+#include <linux/fs.h>
89338+#include <linux/net.h>
89339+#include <linux/in.h>
89340+#include <linux/skbuff.h>
89341+#include <linux/ip.h>
89342+#include <linux/udp.h>
89343+#include <linux/types.h>
89344+#include <linux/sched.h>
89345+#include <linux/netdevice.h>
89346+#include <linux/inetdevice.h>
89347+#include <linux/gracl.h>
89348+#include <linux/grsecurity.h>
89349+#include <linux/grinternal.h>
89350+
89351+#define GR_BIND 0x01
89352+#define GR_CONNECT 0x02
89353+#define GR_INVERT 0x04
89354+#define GR_BINDOVERRIDE 0x08
89355+#define GR_CONNECTOVERRIDE 0x10
89356+#define GR_SOCK_FAMILY 0x20
89357+
89358+static const char * gr_protocols[IPPROTO_MAX] = {
89359+ "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
89360+ "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
89361+ "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
89362+ "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
89363+ "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
89364+ "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
89365+ "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
89366+ "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
89367+ "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
89368+ "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
89369+ "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
89370+ "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
89371+ "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
89372+ "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
89373+ "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
89374+ "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
89375+ "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
89376+ "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
89377+ "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
89378+ "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
89379+ "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
89380+ "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
89381+ "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
89382+ "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
89383+ "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
89384+ "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
89385+ "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
89386+ "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
89387+ "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
89388+ "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
89389+ "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
89390+ "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
89391+ };
89392+
89393+static const char * gr_socktypes[SOCK_MAX] = {
89394+ "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
89395+ "unknown:7", "unknown:8", "unknown:9", "packet"
89396+ };
89397+
89398+static const char * gr_sockfamilies[AF_MAX+1] = {
89399+ "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
89400+ "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
89401+ "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
89402+ "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf", "alg", "nfc", "vsock"
89403+ };
89404+
89405+const char *
89406+gr_proto_to_name(unsigned char proto)
89407+{
89408+ return gr_protocols[proto];
89409+}
89410+
89411+const char *
89412+gr_socktype_to_name(unsigned char type)
89413+{
89414+ return gr_socktypes[type];
89415+}
89416+
89417+const char *
89418+gr_sockfamily_to_name(unsigned char family)
89419+{
89420+ return gr_sockfamilies[family];
89421+}
89422+
89423+extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
89424+
89425+int
89426+gr_search_socket(const int domain, const int type, const int protocol)
89427+{
89428+ struct acl_subject_label *curr;
89429+ const struct cred *cred = current_cred();
89430+
89431+ if (unlikely(!gr_acl_is_enabled()))
89432+ goto exit;
89433+
89434+ if ((domain < 0) || (type < 0) || (protocol < 0) ||
89435+ (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
89436+ goto exit; // let the kernel handle it
89437+
89438+ curr = current->acl;
89439+
89440+ if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
89441+ /* the family is allowed, if this is PF_INET allow it only if
89442+ the extra sock type/protocol checks pass */
89443+ if (domain == PF_INET)
89444+ goto inet_check;
89445+ goto exit;
89446+ } else {
89447+ if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
89448+ __u32 fakeip = 0;
89449+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
89450+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
89451+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
89452+ gr_to_filename(current->exec_file->f_path.dentry,
89453+ current->exec_file->f_path.mnt) :
89454+ curr->filename, curr->filename,
89455+ &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
89456+ &current->signal->saved_ip);
89457+ goto exit;
89458+ }
89459+ goto exit_fail;
89460+ }
89461+
89462+inet_check:
89463+ /* the rest of this checking is for IPv4 only */
89464+ if (!curr->ips)
89465+ goto exit;
89466+
89467+ if ((curr->ip_type & (1U << type)) &&
89468+ (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
89469+ goto exit;
89470+
89471+ if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
89472+ /* we don't place acls on raw sockets , and sometimes
89473+ dgram/ip sockets are opened for ioctl and not
89474+ bind/connect, so we'll fake a bind learn log */
89475+ if (type == SOCK_RAW || type == SOCK_PACKET) {
89476+ __u32 fakeip = 0;
89477+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
89478+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
89479+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
89480+ gr_to_filename(current->exec_file->f_path.dentry,
89481+ current->exec_file->f_path.mnt) :
89482+ curr->filename, curr->filename,
89483+ &fakeip, 0, type,
89484+ protocol, GR_CONNECT, &current->signal->saved_ip);
89485+ } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
89486+ __u32 fakeip = 0;
89487+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
89488+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
89489+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
89490+ gr_to_filename(current->exec_file->f_path.dentry,
89491+ current->exec_file->f_path.mnt) :
89492+ curr->filename, curr->filename,
89493+ &fakeip, 0, type,
89494+ protocol, GR_BIND, &current->signal->saved_ip);
89495+ }
89496+ /* we'll log when they use connect or bind */
89497+ goto exit;
89498+ }
89499+
89500+exit_fail:
89501+ if (domain == PF_INET)
89502+ gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
89503+ gr_socktype_to_name(type), gr_proto_to_name(protocol));
89504+ else if (rcu_access_pointer(net_families[domain]) != NULL)
89505+ gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
89506+ gr_socktype_to_name(type), protocol);
89507+
89508+ return 0;
89509+exit:
89510+ return 1;
89511+}
89512+
89513+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)
89514+{
89515+ if ((ip->mode & mode) &&
89516+ (ip_port >= ip->low) &&
89517+ (ip_port <= ip->high) &&
89518+ ((ntohl(ip_addr) & our_netmask) ==
89519+ (ntohl(our_addr) & our_netmask))
89520+ && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
89521+ && (ip->type & (1U << type))) {
89522+ if (ip->mode & GR_INVERT)
89523+ return 2; // specifically denied
89524+ else
89525+ return 1; // allowed
89526+ }
89527+
89528+ return 0; // not specifically allowed, may continue parsing
89529+}
89530+
89531+static int
89532+gr_search_connectbind(const int full_mode, struct sock *sk,
89533+ struct sockaddr_in *addr, const int type)
89534+{
89535+ char iface[IFNAMSIZ] = {0};
89536+ struct acl_subject_label *curr;
89537+ struct acl_ip_label *ip;
89538+ struct inet_sock *isk;
89539+ struct net_device *dev;
89540+ struct in_device *idev;
89541+ unsigned long i;
89542+ int ret;
89543+ int mode = full_mode & (GR_BIND | GR_CONNECT);
89544+ __u32 ip_addr = 0;
89545+ __u32 our_addr;
89546+ __u32 our_netmask;
89547+ char *p;
89548+ __u16 ip_port = 0;
89549+ const struct cred *cred = current_cred();
89550+
89551+ if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
89552+ return 0;
89553+
89554+ curr = current->acl;
89555+ isk = inet_sk(sk);
89556+
89557+ /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
89558+ if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
89559+ addr->sin_addr.s_addr = curr->inaddr_any_override;
89560+ if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
89561+ struct sockaddr_in saddr;
89562+ int err;
89563+
89564+ saddr.sin_family = AF_INET;
89565+ saddr.sin_addr.s_addr = curr->inaddr_any_override;
89566+ saddr.sin_port = isk->inet_sport;
89567+
89568+ err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
89569+ if (err)
89570+ return err;
89571+
89572+ err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
89573+ if (err)
89574+ return err;
89575+ }
89576+
89577+ if (!curr->ips)
89578+ return 0;
89579+
89580+ ip_addr = addr->sin_addr.s_addr;
89581+ ip_port = ntohs(addr->sin_port);
89582+
89583+ if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
89584+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
89585+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
89586+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
89587+ gr_to_filename(current->exec_file->f_path.dentry,
89588+ current->exec_file->f_path.mnt) :
89589+ curr->filename, curr->filename,
89590+ &ip_addr, ip_port, type,
89591+ sk->sk_protocol, mode, &current->signal->saved_ip);
89592+ return 0;
89593+ }
89594+
89595+ for (i = 0; i < curr->ip_num; i++) {
89596+ ip = *(curr->ips + i);
89597+ if (ip->iface != NULL) {
89598+ strncpy(iface, ip->iface, IFNAMSIZ - 1);
89599+ p = strchr(iface, ':');
89600+ if (p != NULL)
89601+ *p = '\0';
89602+ dev = dev_get_by_name(sock_net(sk), iface);
89603+ if (dev == NULL)
89604+ continue;
89605+ idev = in_dev_get(dev);
89606+ if (idev == NULL) {
89607+ dev_put(dev);
89608+ continue;
89609+ }
89610+ rcu_read_lock();
89611+ for_ifa(idev) {
89612+ if (!strcmp(ip->iface, ifa->ifa_label)) {
89613+ our_addr = ifa->ifa_address;
89614+ our_netmask = 0xffffffff;
89615+ ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
89616+ if (ret == 1) {
89617+ rcu_read_unlock();
89618+ in_dev_put(idev);
89619+ dev_put(dev);
89620+ return 0;
89621+ } else if (ret == 2) {
89622+ rcu_read_unlock();
89623+ in_dev_put(idev);
89624+ dev_put(dev);
89625+ goto denied;
89626+ }
89627+ }
89628+ } endfor_ifa(idev);
89629+ rcu_read_unlock();
89630+ in_dev_put(idev);
89631+ dev_put(dev);
89632+ } else {
89633+ our_addr = ip->addr;
89634+ our_netmask = ip->netmask;
89635+ ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
89636+ if (ret == 1)
89637+ return 0;
89638+ else if (ret == 2)
89639+ goto denied;
89640+ }
89641+ }
89642+
89643+denied:
89644+ if (mode == GR_BIND)
89645+ 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));
89646+ else if (mode == GR_CONNECT)
89647+ 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));
89648+
89649+ return -EACCES;
89650+}
89651+
89652+int
89653+gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
89654+{
89655+ /* always allow disconnection of dgram sockets with connect */
89656+ if (addr->sin_family == AF_UNSPEC)
89657+ return 0;
89658+ return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
89659+}
89660+
89661+int
89662+gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
89663+{
89664+ return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
89665+}
89666+
89667+int gr_search_listen(struct socket *sock)
89668+{
89669+ struct sock *sk = sock->sk;
89670+ struct sockaddr_in addr;
89671+
89672+ addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
89673+ addr.sin_port = inet_sk(sk)->inet_sport;
89674+
89675+ return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
89676+}
89677+
89678+int gr_search_accept(struct socket *sock)
89679+{
89680+ struct sock *sk = sock->sk;
89681+ struct sockaddr_in addr;
89682+
89683+ addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
89684+ addr.sin_port = inet_sk(sk)->inet_sport;
89685+
89686+ return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
89687+}
89688+
89689+int
89690+gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
89691+{
89692+ if (addr)
89693+ return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
89694+ else {
89695+ struct sockaddr_in sin;
89696+ const struct inet_sock *inet = inet_sk(sk);
89697+
89698+ sin.sin_addr.s_addr = inet->inet_daddr;
89699+ sin.sin_port = inet->inet_dport;
89700+
89701+ return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
89702+ }
89703+}
89704+
89705+int
89706+gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
89707+{
89708+ struct sockaddr_in sin;
89709+
89710+ if (unlikely(skb->len < sizeof (struct udphdr)))
89711+ return 0; // skip this packet
89712+
89713+ sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
89714+ sin.sin_port = udp_hdr(skb)->source;
89715+
89716+ return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
89717+}
89718diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
89719new file mode 100644
89720index 0000000..25f54ef
89721--- /dev/null
89722+++ b/grsecurity/gracl_learn.c
89723@@ -0,0 +1,207 @@
89724+#include <linux/kernel.h>
89725+#include <linux/mm.h>
89726+#include <linux/sched.h>
89727+#include <linux/poll.h>
89728+#include <linux/string.h>
89729+#include <linux/file.h>
89730+#include <linux/types.h>
89731+#include <linux/vmalloc.h>
89732+#include <linux/grinternal.h>
89733+
89734+extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
89735+ size_t count, loff_t *ppos);
89736+extern int gr_acl_is_enabled(void);
89737+
89738+static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
89739+static int gr_learn_attached;
89740+
89741+/* use a 512k buffer */
89742+#define LEARN_BUFFER_SIZE (512 * 1024)
89743+
89744+static DEFINE_SPINLOCK(gr_learn_lock);
89745+static DEFINE_MUTEX(gr_learn_user_mutex);
89746+
89747+/* we need to maintain two buffers, so that the kernel context of grlearn
89748+ uses a semaphore around the userspace copying, and the other kernel contexts
89749+ use a spinlock when copying into the buffer, since they cannot sleep
89750+*/
89751+static char *learn_buffer;
89752+static char *learn_buffer_user;
89753+static int learn_buffer_len;
89754+static int learn_buffer_user_len;
89755+
89756+static ssize_t
89757+read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
89758+{
89759+ DECLARE_WAITQUEUE(wait, current);
89760+ ssize_t retval = 0;
89761+
89762+ add_wait_queue(&learn_wait, &wait);
89763+ set_current_state(TASK_INTERRUPTIBLE);
89764+ do {
89765+ mutex_lock(&gr_learn_user_mutex);
89766+ spin_lock(&gr_learn_lock);
89767+ if (learn_buffer_len)
89768+ break;
89769+ spin_unlock(&gr_learn_lock);
89770+ mutex_unlock(&gr_learn_user_mutex);
89771+ if (file->f_flags & O_NONBLOCK) {
89772+ retval = -EAGAIN;
89773+ goto out;
89774+ }
89775+ if (signal_pending(current)) {
89776+ retval = -ERESTARTSYS;
89777+ goto out;
89778+ }
89779+
89780+ schedule();
89781+ } while (1);
89782+
89783+ memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
89784+ learn_buffer_user_len = learn_buffer_len;
89785+ retval = learn_buffer_len;
89786+ learn_buffer_len = 0;
89787+
89788+ spin_unlock(&gr_learn_lock);
89789+
89790+ if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
89791+ retval = -EFAULT;
89792+
89793+ mutex_unlock(&gr_learn_user_mutex);
89794+out:
89795+ set_current_state(TASK_RUNNING);
89796+ remove_wait_queue(&learn_wait, &wait);
89797+ return retval;
89798+}
89799+
89800+static unsigned int
89801+poll_learn(struct file * file, poll_table * wait)
89802+{
89803+ poll_wait(file, &learn_wait, wait);
89804+
89805+ if (learn_buffer_len)
89806+ return (POLLIN | POLLRDNORM);
89807+
89808+ return 0;
89809+}
89810+
89811+void
89812+gr_clear_learn_entries(void)
89813+{
89814+ char *tmp;
89815+
89816+ mutex_lock(&gr_learn_user_mutex);
89817+ spin_lock(&gr_learn_lock);
89818+ tmp = learn_buffer;
89819+ learn_buffer = NULL;
89820+ spin_unlock(&gr_learn_lock);
89821+ if (tmp)
89822+ vfree(tmp);
89823+ if (learn_buffer_user != NULL) {
89824+ vfree(learn_buffer_user);
89825+ learn_buffer_user = NULL;
89826+ }
89827+ learn_buffer_len = 0;
89828+ mutex_unlock(&gr_learn_user_mutex);
89829+
89830+ return;
89831+}
89832+
89833+void
89834+gr_add_learn_entry(const char *fmt, ...)
89835+{
89836+ va_list args;
89837+ unsigned int len;
89838+
89839+ if (!gr_learn_attached)
89840+ return;
89841+
89842+ spin_lock(&gr_learn_lock);
89843+
89844+ /* leave a gap at the end so we know when it's "full" but don't have to
89845+ compute the exact length of the string we're trying to append
89846+ */
89847+ if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
89848+ spin_unlock(&gr_learn_lock);
89849+ wake_up_interruptible(&learn_wait);
89850+ return;
89851+ }
89852+ if (learn_buffer == NULL) {
89853+ spin_unlock(&gr_learn_lock);
89854+ return;
89855+ }
89856+
89857+ va_start(args, fmt);
89858+ len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
89859+ va_end(args);
89860+
89861+ learn_buffer_len += len + 1;
89862+
89863+ spin_unlock(&gr_learn_lock);
89864+ wake_up_interruptible(&learn_wait);
89865+
89866+ return;
89867+}
89868+
89869+static int
89870+open_learn(struct inode *inode, struct file *file)
89871+{
89872+ if (file->f_mode & FMODE_READ && gr_learn_attached)
89873+ return -EBUSY;
89874+ if (file->f_mode & FMODE_READ) {
89875+ int retval = 0;
89876+ mutex_lock(&gr_learn_user_mutex);
89877+ if (learn_buffer == NULL)
89878+ learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
89879+ if (learn_buffer_user == NULL)
89880+ learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
89881+ if (learn_buffer == NULL) {
89882+ retval = -ENOMEM;
89883+ goto out_error;
89884+ }
89885+ if (learn_buffer_user == NULL) {
89886+ retval = -ENOMEM;
89887+ goto out_error;
89888+ }
89889+ learn_buffer_len = 0;
89890+ learn_buffer_user_len = 0;
89891+ gr_learn_attached = 1;
89892+out_error:
89893+ mutex_unlock(&gr_learn_user_mutex);
89894+ return retval;
89895+ }
89896+ return 0;
89897+}
89898+
89899+static int
89900+close_learn(struct inode *inode, struct file *file)
89901+{
89902+ if (file->f_mode & FMODE_READ) {
89903+ char *tmp = NULL;
89904+ mutex_lock(&gr_learn_user_mutex);
89905+ spin_lock(&gr_learn_lock);
89906+ tmp = learn_buffer;
89907+ learn_buffer = NULL;
89908+ spin_unlock(&gr_learn_lock);
89909+ if (tmp)
89910+ vfree(tmp);
89911+ if (learn_buffer_user != NULL) {
89912+ vfree(learn_buffer_user);
89913+ learn_buffer_user = NULL;
89914+ }
89915+ learn_buffer_len = 0;
89916+ learn_buffer_user_len = 0;
89917+ gr_learn_attached = 0;
89918+ mutex_unlock(&gr_learn_user_mutex);
89919+ }
89920+
89921+ return 0;
89922+}
89923+
89924+const struct file_operations grsec_fops = {
89925+ .read = read_learn,
89926+ .write = write_grsec_handler,
89927+ .open = open_learn,
89928+ .release = close_learn,
89929+ .poll = poll_learn,
89930+};
89931diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
89932new file mode 100644
89933index 0000000..0773423
89934--- /dev/null
89935+++ b/grsecurity/gracl_policy.c
89936@@ -0,0 +1,1786 @@
89937+#include <linux/kernel.h>
89938+#include <linux/module.h>
89939+#include <linux/sched.h>
89940+#include <linux/mm.h>
89941+#include <linux/file.h>
89942+#include <linux/fs.h>
89943+#include <linux/namei.h>
89944+#include <linux/mount.h>
89945+#include <linux/tty.h>
89946+#include <linux/proc_fs.h>
89947+#include <linux/lglock.h>
89948+#include <linux/slab.h>
89949+#include <linux/vmalloc.h>
89950+#include <linux/types.h>
89951+#include <linux/sysctl.h>
89952+#include <linux/netdevice.h>
89953+#include <linux/ptrace.h>
89954+#include <linux/gracl.h>
89955+#include <linux/gralloc.h>
89956+#include <linux/security.h>
89957+#include <linux/grinternal.h>
89958+#include <linux/pid_namespace.h>
89959+#include <linux/stop_machine.h>
89960+#include <linux/fdtable.h>
89961+#include <linux/percpu.h>
89962+#include <linux/lglock.h>
89963+#include <linux/hugetlb.h>
89964+#include <linux/posix-timers.h>
89965+#include "../fs/mount.h"
89966+
89967+#include <asm/uaccess.h>
89968+#include <asm/errno.h>
89969+#include <asm/mman.h>
89970+
89971+extern struct gr_policy_state *polstate;
89972+
89973+#define FOR_EACH_ROLE_START(role) \
89974+ role = polstate->role_list; \
89975+ while (role) {
89976+
89977+#define FOR_EACH_ROLE_END(role) \
89978+ role = role->prev; \
89979+ }
89980+
89981+struct path gr_real_root;
89982+
89983+extern struct gr_alloc_state *current_alloc_state;
89984+
89985+u16 acl_sp_role_value;
89986+
89987+static DEFINE_MUTEX(gr_dev_mutex);
89988+
89989+extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
89990+extern void gr_clear_learn_entries(void);
89991+
89992+struct gr_arg *gr_usermode __read_only;
89993+unsigned char *gr_system_salt __read_only;
89994+unsigned char *gr_system_sum __read_only;
89995+
89996+static unsigned int gr_auth_attempts = 0;
89997+static unsigned long gr_auth_expires = 0UL;
89998+
89999+struct acl_object_label *fakefs_obj_rw;
90000+struct acl_object_label *fakefs_obj_rwx;
90001+
90002+extern int gr_init_uidset(void);
90003+extern void gr_free_uidset(void);
90004+extern void gr_remove_uid(uid_t uid);
90005+extern int gr_find_uid(uid_t uid);
90006+
90007+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);
90008+extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
90009+extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
90010+extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
90011+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);
90012+extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
90013+extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
90014+extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
90015+extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
90016+extern struct acl_subject_label *lookup_acl_subj_label(const u64 ino, const dev_t dev, const struct acl_role_label *role);
90017+extern struct acl_subject_label *lookup_acl_subj_label_deleted(const u64 ino, const dev_t dev, const struct acl_role_label *role);
90018+extern void assign_special_role(const char *rolename);
90019+extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
90020+extern int gr_rbac_disable(void *unused);
90021+extern void gr_enable_rbac_system(void);
90022+
90023+static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
90024+{
90025+ if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
90026+ return -EFAULT;
90027+
90028+ return 0;
90029+}
90030+
90031+static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
90032+{
90033+ if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
90034+ return -EFAULT;
90035+
90036+ return 0;
90037+}
90038+
90039+static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
90040+{
90041+ if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
90042+ return -EFAULT;
90043+
90044+ return 0;
90045+}
90046+
90047+static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
90048+{
90049+ if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
90050+ return -EFAULT;
90051+
90052+ return 0;
90053+}
90054+
90055+static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
90056+{
90057+ if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
90058+ return -EFAULT;
90059+
90060+ return 0;
90061+}
90062+
90063+static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
90064+{
90065+ if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
90066+ return -EFAULT;
90067+
90068+ return 0;
90069+}
90070+
90071+static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
90072+{
90073+ if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
90074+ return -EFAULT;
90075+
90076+ return 0;
90077+}
90078+
90079+static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
90080+{
90081+ if (copy_from_user(trans, userp, sizeof(struct role_transition)))
90082+ return -EFAULT;
90083+
90084+ return 0;
90085+}
90086+
90087+int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
90088+{
90089+ if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
90090+ return -EFAULT;
90091+
90092+ return 0;
90093+}
90094+
90095+static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
90096+{
90097+ if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
90098+ return -EFAULT;
90099+
90100+ if ((uwrap->version != GRSECURITY_VERSION) ||
90101+ (uwrap->size != sizeof(struct gr_arg)))
90102+ return -EINVAL;
90103+
90104+ return 0;
90105+}
90106+
90107+static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
90108+{
90109+ if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
90110+ return -EFAULT;
90111+
90112+ return 0;
90113+}
90114+
90115+static size_t get_gr_arg_wrapper_size_normal(void)
90116+{
90117+ return sizeof(struct gr_arg_wrapper);
90118+}
90119+
90120+#ifdef CONFIG_COMPAT
90121+extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
90122+extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
90123+extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
90124+extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
90125+extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
90126+extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
90127+extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
90128+extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
90129+extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
90130+extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
90131+extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
90132+extern size_t get_gr_arg_wrapper_size_compat(void);
90133+
90134+int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
90135+int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
90136+int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
90137+int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
90138+int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
90139+int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
90140+int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
90141+int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
90142+int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
90143+int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
90144+int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
90145+size_t (* get_gr_arg_wrapper_size)(void) __read_only;
90146+
90147+#else
90148+#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
90149+#define copy_gr_arg copy_gr_arg_normal
90150+#define copy_gr_hash_struct copy_gr_hash_struct_normal
90151+#define copy_acl_object_label copy_acl_object_label_normal
90152+#define copy_acl_subject_label copy_acl_subject_label_normal
90153+#define copy_acl_role_label copy_acl_role_label_normal
90154+#define copy_acl_ip_label copy_acl_ip_label_normal
90155+#define copy_pointer_from_array copy_pointer_from_array_normal
90156+#define copy_sprole_pw copy_sprole_pw_normal
90157+#define copy_role_transition copy_role_transition_normal
90158+#define copy_role_allowed_ip copy_role_allowed_ip_normal
90159+#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
90160+#endif
90161+
90162+static struct acl_subject_label *
90163+lookup_subject_map(const struct acl_subject_label *userp)
90164+{
90165+ unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
90166+ struct subject_map *match;
90167+
90168+ match = polstate->subj_map_set.s_hash[index];
90169+
90170+ while (match && match->user != userp)
90171+ match = match->next;
90172+
90173+ if (match != NULL)
90174+ return match->kernel;
90175+ else
90176+ return NULL;
90177+}
90178+
90179+static void
90180+insert_subj_map_entry(struct subject_map *subjmap)
90181+{
90182+ unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
90183+ struct subject_map **curr;
90184+
90185+ subjmap->prev = NULL;
90186+
90187+ curr = &polstate->subj_map_set.s_hash[index];
90188+ if (*curr != NULL)
90189+ (*curr)->prev = subjmap;
90190+
90191+ subjmap->next = *curr;
90192+ *curr = subjmap;
90193+
90194+ return;
90195+}
90196+
90197+static void
90198+__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
90199+{
90200+ unsigned int index =
90201+ gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
90202+ struct acl_role_label **curr;
90203+ struct acl_role_label *tmp, *tmp2;
90204+
90205+ curr = &polstate->acl_role_set.r_hash[index];
90206+
90207+ /* simple case, slot is empty, just set it to our role */
90208+ if (*curr == NULL) {
90209+ *curr = role;
90210+ } else {
90211+ /* example:
90212+ 1 -> 2 -> 3 (adding 2 -> 3 to here)
90213+ 2 -> 3
90214+ */
90215+ /* first check to see if we can already be reached via this slot */
90216+ tmp = *curr;
90217+ while (tmp && tmp != role)
90218+ tmp = tmp->next;
90219+ if (tmp == role) {
90220+ /* we don't need to add ourselves to this slot's chain */
90221+ return;
90222+ }
90223+ /* we need to add ourselves to this chain, two cases */
90224+ if (role->next == NULL) {
90225+ /* simple case, append the current chain to our role */
90226+ role->next = *curr;
90227+ *curr = role;
90228+ } else {
90229+ /* 1 -> 2 -> 3 -> 4
90230+ 2 -> 3 -> 4
90231+ 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
90232+ */
90233+ /* trickier case: walk our role's chain until we find
90234+ the role for the start of the current slot's chain */
90235+ tmp = role;
90236+ tmp2 = *curr;
90237+ while (tmp->next && tmp->next != tmp2)
90238+ tmp = tmp->next;
90239+ if (tmp->next == tmp2) {
90240+ /* from example above, we found 3, so just
90241+ replace this slot's chain with ours */
90242+ *curr = role;
90243+ } else {
90244+ /* we didn't find a subset of our role's chain
90245+ in the current slot's chain, so append their
90246+ chain to ours, and set us as the first role in
90247+ the slot's chain
90248+
90249+ we could fold this case with the case above,
90250+ but making it explicit for clarity
90251+ */
90252+ tmp->next = tmp2;
90253+ *curr = role;
90254+ }
90255+ }
90256+ }
90257+
90258+ return;
90259+}
90260+
90261+static void
90262+insert_acl_role_label(struct acl_role_label *role)
90263+{
90264+ int i;
90265+
90266+ if (polstate->role_list == NULL) {
90267+ polstate->role_list = role;
90268+ role->prev = NULL;
90269+ } else {
90270+ role->prev = polstate->role_list;
90271+ polstate->role_list = role;
90272+ }
90273+
90274+ /* used for hash chains */
90275+ role->next = NULL;
90276+
90277+ if (role->roletype & GR_ROLE_DOMAIN) {
90278+ for (i = 0; i < role->domain_child_num; i++)
90279+ __insert_acl_role_label(role, role->domain_children[i]);
90280+ } else
90281+ __insert_acl_role_label(role, role->uidgid);
90282+}
90283+
90284+static int
90285+insert_name_entry(char *name, const u64 inode, const dev_t device, __u8 deleted)
90286+{
90287+ struct name_entry **curr, *nentry;
90288+ struct inodev_entry *ientry;
90289+ unsigned int len = strlen(name);
90290+ unsigned int key = full_name_hash(name, len);
90291+ unsigned int index = key % polstate->name_set.n_size;
90292+
90293+ curr = &polstate->name_set.n_hash[index];
90294+
90295+ while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
90296+ curr = &((*curr)->next);
90297+
90298+ if (*curr != NULL)
90299+ return 1;
90300+
90301+ nentry = acl_alloc(sizeof (struct name_entry));
90302+ if (nentry == NULL)
90303+ return 0;
90304+ ientry = acl_alloc(sizeof (struct inodev_entry));
90305+ if (ientry == NULL)
90306+ return 0;
90307+ ientry->nentry = nentry;
90308+
90309+ nentry->key = key;
90310+ nentry->name = name;
90311+ nentry->inode = inode;
90312+ nentry->device = device;
90313+ nentry->len = len;
90314+ nentry->deleted = deleted;
90315+
90316+ nentry->prev = NULL;
90317+ curr = &polstate->name_set.n_hash[index];
90318+ if (*curr != NULL)
90319+ (*curr)->prev = nentry;
90320+ nentry->next = *curr;
90321+ *curr = nentry;
90322+
90323+ /* insert us into the table searchable by inode/dev */
90324+ __insert_inodev_entry(polstate, ientry);
90325+
90326+ return 1;
90327+}
90328+
90329+/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
90330+
90331+static void *
90332+create_table(__u32 * len, int elementsize)
90333+{
90334+ unsigned int table_sizes[] = {
90335+ 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
90336+ 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
90337+ 4194301, 8388593, 16777213, 33554393, 67108859
90338+ };
90339+ void *newtable = NULL;
90340+ unsigned int pwr = 0;
90341+
90342+ while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
90343+ table_sizes[pwr] <= *len)
90344+ pwr++;
90345+
90346+ if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
90347+ return newtable;
90348+
90349+ if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
90350+ newtable =
90351+ kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
90352+ else
90353+ newtable = vmalloc(table_sizes[pwr] * elementsize);
90354+
90355+ *len = table_sizes[pwr];
90356+
90357+ return newtable;
90358+}
90359+
90360+static int
90361+init_variables(const struct gr_arg *arg, bool reload)
90362+{
90363+ struct task_struct *reaper = init_pid_ns.child_reaper;
90364+ unsigned int stacksize;
90365+
90366+ polstate->subj_map_set.s_size = arg->role_db.num_subjects;
90367+ polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
90368+ polstate->name_set.n_size = arg->role_db.num_objects;
90369+ polstate->inodev_set.i_size = arg->role_db.num_objects;
90370+
90371+ if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
90372+ !polstate->name_set.n_size || !polstate->inodev_set.i_size)
90373+ return 1;
90374+
90375+ if (!reload) {
90376+ if (!gr_init_uidset())
90377+ return 1;
90378+ }
90379+
90380+ /* set up the stack that holds allocation info */
90381+
90382+ stacksize = arg->role_db.num_pointers + 5;
90383+
90384+ if (!acl_alloc_stack_init(stacksize))
90385+ return 1;
90386+
90387+ if (!reload) {
90388+ /* grab reference for the real root dentry and vfsmount */
90389+ get_fs_root(reaper->fs, &gr_real_root);
90390+
90391+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
90392+ 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));
90393+#endif
90394+
90395+ fakefs_obj_rw = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
90396+ if (fakefs_obj_rw == NULL)
90397+ return 1;
90398+ fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
90399+
90400+ fakefs_obj_rwx = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
90401+ if (fakefs_obj_rwx == NULL)
90402+ return 1;
90403+ fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
90404+ }
90405+
90406+ polstate->subj_map_set.s_hash =
90407+ (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
90408+ polstate->acl_role_set.r_hash =
90409+ (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
90410+ polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
90411+ polstate->inodev_set.i_hash =
90412+ (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
90413+
90414+ if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
90415+ !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
90416+ return 1;
90417+
90418+ memset(polstate->subj_map_set.s_hash, 0,
90419+ sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
90420+ memset(polstate->acl_role_set.r_hash, 0,
90421+ sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
90422+ memset(polstate->name_set.n_hash, 0,
90423+ sizeof (struct name_entry *) * polstate->name_set.n_size);
90424+ memset(polstate->inodev_set.i_hash, 0,
90425+ sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
90426+
90427+ return 0;
90428+}
90429+
90430+/* free information not needed after startup
90431+ currently contains user->kernel pointer mappings for subjects
90432+*/
90433+
90434+static void
90435+free_init_variables(void)
90436+{
90437+ __u32 i;
90438+
90439+ if (polstate->subj_map_set.s_hash) {
90440+ for (i = 0; i < polstate->subj_map_set.s_size; i++) {
90441+ if (polstate->subj_map_set.s_hash[i]) {
90442+ kfree(polstate->subj_map_set.s_hash[i]);
90443+ polstate->subj_map_set.s_hash[i] = NULL;
90444+ }
90445+ }
90446+
90447+ if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
90448+ PAGE_SIZE)
90449+ kfree(polstate->subj_map_set.s_hash);
90450+ else
90451+ vfree(polstate->subj_map_set.s_hash);
90452+ }
90453+
90454+ return;
90455+}
90456+
90457+static void
90458+free_variables(bool reload)
90459+{
90460+ struct acl_subject_label *s;
90461+ struct acl_role_label *r;
90462+ struct task_struct *task, *task2;
90463+ unsigned int x;
90464+
90465+ if (!reload) {
90466+ gr_clear_learn_entries();
90467+
90468+ read_lock(&tasklist_lock);
90469+ do_each_thread(task2, task) {
90470+ task->acl_sp_role = 0;
90471+ task->acl_role_id = 0;
90472+ task->inherited = 0;
90473+ task->acl = NULL;
90474+ task->role = NULL;
90475+ } while_each_thread(task2, task);
90476+ read_unlock(&tasklist_lock);
90477+
90478+ kfree(fakefs_obj_rw);
90479+ fakefs_obj_rw = NULL;
90480+ kfree(fakefs_obj_rwx);
90481+ fakefs_obj_rwx = NULL;
90482+
90483+ /* release the reference to the real root dentry and vfsmount */
90484+ path_put(&gr_real_root);
90485+ memset(&gr_real_root, 0, sizeof(gr_real_root));
90486+ }
90487+
90488+ /* free all object hash tables */
90489+
90490+ FOR_EACH_ROLE_START(r)
90491+ if (r->subj_hash == NULL)
90492+ goto next_role;
90493+ FOR_EACH_SUBJECT_START(r, s, x)
90494+ if (s->obj_hash == NULL)
90495+ break;
90496+ if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
90497+ kfree(s->obj_hash);
90498+ else
90499+ vfree(s->obj_hash);
90500+ FOR_EACH_SUBJECT_END(s, x)
90501+ FOR_EACH_NESTED_SUBJECT_START(r, s)
90502+ if (s->obj_hash == NULL)
90503+ break;
90504+ if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
90505+ kfree(s->obj_hash);
90506+ else
90507+ vfree(s->obj_hash);
90508+ FOR_EACH_NESTED_SUBJECT_END(s)
90509+ if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
90510+ kfree(r->subj_hash);
90511+ else
90512+ vfree(r->subj_hash);
90513+ r->subj_hash = NULL;
90514+next_role:
90515+ FOR_EACH_ROLE_END(r)
90516+
90517+ acl_free_all();
90518+
90519+ if (polstate->acl_role_set.r_hash) {
90520+ if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
90521+ PAGE_SIZE)
90522+ kfree(polstate->acl_role_set.r_hash);
90523+ else
90524+ vfree(polstate->acl_role_set.r_hash);
90525+ }
90526+ if (polstate->name_set.n_hash) {
90527+ if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
90528+ PAGE_SIZE)
90529+ kfree(polstate->name_set.n_hash);
90530+ else
90531+ vfree(polstate->name_set.n_hash);
90532+ }
90533+
90534+ if (polstate->inodev_set.i_hash) {
90535+ if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
90536+ PAGE_SIZE)
90537+ kfree(polstate->inodev_set.i_hash);
90538+ else
90539+ vfree(polstate->inodev_set.i_hash);
90540+ }
90541+
90542+ if (!reload)
90543+ gr_free_uidset();
90544+
90545+ memset(&polstate->name_set, 0, sizeof (struct name_db));
90546+ memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
90547+ memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
90548+ memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
90549+
90550+ polstate->default_role = NULL;
90551+ polstate->kernel_role = NULL;
90552+ polstate->role_list = NULL;
90553+
90554+ return;
90555+}
90556+
90557+static struct acl_subject_label *
90558+do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
90559+
90560+static int alloc_and_copy_string(char **name, unsigned int maxlen)
90561+{
90562+ unsigned int len = strnlen_user(*name, maxlen);
90563+ char *tmp;
90564+
90565+ if (!len || len >= maxlen)
90566+ return -EINVAL;
90567+
90568+ if ((tmp = (char *) acl_alloc(len)) == NULL)
90569+ return -ENOMEM;
90570+
90571+ if (copy_from_user(tmp, *name, len))
90572+ return -EFAULT;
90573+
90574+ tmp[len-1] = '\0';
90575+ *name = tmp;
90576+
90577+ return 0;
90578+}
90579+
90580+static int
90581+copy_user_glob(struct acl_object_label *obj)
90582+{
90583+ struct acl_object_label *g_tmp, **guser;
90584+ int error;
90585+
90586+ if (obj->globbed == NULL)
90587+ return 0;
90588+
90589+ guser = &obj->globbed;
90590+ while (*guser) {
90591+ g_tmp = (struct acl_object_label *)
90592+ acl_alloc(sizeof (struct acl_object_label));
90593+ if (g_tmp == NULL)
90594+ return -ENOMEM;
90595+
90596+ if (copy_acl_object_label(g_tmp, *guser))
90597+ return -EFAULT;
90598+
90599+ error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
90600+ if (error)
90601+ return error;
90602+
90603+ *guser = g_tmp;
90604+ guser = &(g_tmp->next);
90605+ }
90606+
90607+ return 0;
90608+}
90609+
90610+static int
90611+copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
90612+ struct acl_role_label *role)
90613+{
90614+ struct acl_object_label *o_tmp;
90615+ int ret;
90616+
90617+ while (userp) {
90618+ if ((o_tmp = (struct acl_object_label *)
90619+ acl_alloc(sizeof (struct acl_object_label))) == NULL)
90620+ return -ENOMEM;
90621+
90622+ if (copy_acl_object_label(o_tmp, userp))
90623+ return -EFAULT;
90624+
90625+ userp = o_tmp->prev;
90626+
90627+ ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
90628+ if (ret)
90629+ return ret;
90630+
90631+ insert_acl_obj_label(o_tmp, subj);
90632+ if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
90633+ o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
90634+ return -ENOMEM;
90635+
90636+ ret = copy_user_glob(o_tmp);
90637+ if (ret)
90638+ return ret;
90639+
90640+ if (o_tmp->nested) {
90641+ int already_copied;
90642+
90643+ o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
90644+ if (IS_ERR(o_tmp->nested))
90645+ return PTR_ERR(o_tmp->nested);
90646+
90647+ /* insert into nested subject list if we haven't copied this one yet
90648+ to prevent duplicate entries */
90649+ if (!already_copied) {
90650+ o_tmp->nested->next = role->hash->first;
90651+ role->hash->first = o_tmp->nested;
90652+ }
90653+ }
90654+ }
90655+
90656+ return 0;
90657+}
90658+
90659+static __u32
90660+count_user_subjs(struct acl_subject_label *userp)
90661+{
90662+ struct acl_subject_label s_tmp;
90663+ __u32 num = 0;
90664+
90665+ while (userp) {
90666+ if (copy_acl_subject_label(&s_tmp, userp))
90667+ break;
90668+
90669+ userp = s_tmp.prev;
90670+ }
90671+
90672+ return num;
90673+}
90674+
90675+static int
90676+copy_user_allowedips(struct acl_role_label *rolep)
90677+{
90678+ struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
90679+
90680+ ruserip = rolep->allowed_ips;
90681+
90682+ while (ruserip) {
90683+ rlast = rtmp;
90684+
90685+ if ((rtmp = (struct role_allowed_ip *)
90686+ acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
90687+ return -ENOMEM;
90688+
90689+ if (copy_role_allowed_ip(rtmp, ruserip))
90690+ return -EFAULT;
90691+
90692+ ruserip = rtmp->prev;
90693+
90694+ if (!rlast) {
90695+ rtmp->prev = NULL;
90696+ rolep->allowed_ips = rtmp;
90697+ } else {
90698+ rlast->next = rtmp;
90699+ rtmp->prev = rlast;
90700+ }
90701+
90702+ if (!ruserip)
90703+ rtmp->next = NULL;
90704+ }
90705+
90706+ return 0;
90707+}
90708+
90709+static int
90710+copy_user_transitions(struct acl_role_label *rolep)
90711+{
90712+ struct role_transition *rusertp, *rtmp = NULL, *rlast;
90713+ int error;
90714+
90715+ rusertp = rolep->transitions;
90716+
90717+ while (rusertp) {
90718+ rlast = rtmp;
90719+
90720+ if ((rtmp = (struct role_transition *)
90721+ acl_alloc(sizeof (struct role_transition))) == NULL)
90722+ return -ENOMEM;
90723+
90724+ if (copy_role_transition(rtmp, rusertp))
90725+ return -EFAULT;
90726+
90727+ rusertp = rtmp->prev;
90728+
90729+ error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
90730+ if (error)
90731+ return error;
90732+
90733+ if (!rlast) {
90734+ rtmp->prev = NULL;
90735+ rolep->transitions = rtmp;
90736+ } else {
90737+ rlast->next = rtmp;
90738+ rtmp->prev = rlast;
90739+ }
90740+
90741+ if (!rusertp)
90742+ rtmp->next = NULL;
90743+ }
90744+
90745+ return 0;
90746+}
90747+
90748+static __u32 count_user_objs(const struct acl_object_label __user *userp)
90749+{
90750+ struct acl_object_label o_tmp;
90751+ __u32 num = 0;
90752+
90753+ while (userp) {
90754+ if (copy_acl_object_label(&o_tmp, userp))
90755+ break;
90756+
90757+ userp = o_tmp.prev;
90758+ num++;
90759+ }
90760+
90761+ return num;
90762+}
90763+
90764+static struct acl_subject_label *
90765+do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
90766+{
90767+ struct acl_subject_label *s_tmp = NULL, *s_tmp2;
90768+ __u32 num_objs;
90769+ struct acl_ip_label **i_tmp, *i_utmp2;
90770+ struct gr_hash_struct ghash;
90771+ struct subject_map *subjmap;
90772+ unsigned int i_num;
90773+ int err;
90774+
90775+ if (already_copied != NULL)
90776+ *already_copied = 0;
90777+
90778+ s_tmp = lookup_subject_map(userp);
90779+
90780+ /* we've already copied this subject into the kernel, just return
90781+ the reference to it, and don't copy it over again
90782+ */
90783+ if (s_tmp) {
90784+ if (already_copied != NULL)
90785+ *already_copied = 1;
90786+ return(s_tmp);
90787+ }
90788+
90789+ if ((s_tmp = (struct acl_subject_label *)
90790+ acl_alloc(sizeof (struct acl_subject_label))) == NULL)
90791+ return ERR_PTR(-ENOMEM);
90792+
90793+ subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
90794+ if (subjmap == NULL)
90795+ return ERR_PTR(-ENOMEM);
90796+
90797+ subjmap->user = userp;
90798+ subjmap->kernel = s_tmp;
90799+ insert_subj_map_entry(subjmap);
90800+
90801+ if (copy_acl_subject_label(s_tmp, userp))
90802+ return ERR_PTR(-EFAULT);
90803+
90804+ err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
90805+ if (err)
90806+ return ERR_PTR(err);
90807+
90808+ if (!strcmp(s_tmp->filename, "/"))
90809+ role->root_label = s_tmp;
90810+
90811+ if (copy_gr_hash_struct(&ghash, s_tmp->hash))
90812+ return ERR_PTR(-EFAULT);
90813+
90814+ /* copy user and group transition tables */
90815+
90816+ if (s_tmp->user_trans_num) {
90817+ uid_t *uidlist;
90818+
90819+ uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
90820+ if (uidlist == NULL)
90821+ return ERR_PTR(-ENOMEM);
90822+ if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
90823+ return ERR_PTR(-EFAULT);
90824+
90825+ s_tmp->user_transitions = uidlist;
90826+ }
90827+
90828+ if (s_tmp->group_trans_num) {
90829+ gid_t *gidlist;
90830+
90831+ gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
90832+ if (gidlist == NULL)
90833+ return ERR_PTR(-ENOMEM);
90834+ if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
90835+ return ERR_PTR(-EFAULT);
90836+
90837+ s_tmp->group_transitions = gidlist;
90838+ }
90839+
90840+ /* set up object hash table */
90841+ num_objs = count_user_objs(ghash.first);
90842+
90843+ s_tmp->obj_hash_size = num_objs;
90844+ s_tmp->obj_hash =
90845+ (struct acl_object_label **)
90846+ create_table(&(s_tmp->obj_hash_size), sizeof(void *));
90847+
90848+ if (!s_tmp->obj_hash)
90849+ return ERR_PTR(-ENOMEM);
90850+
90851+ memset(s_tmp->obj_hash, 0,
90852+ s_tmp->obj_hash_size *
90853+ sizeof (struct acl_object_label *));
90854+
90855+ /* add in objects */
90856+ err = copy_user_objs(ghash.first, s_tmp, role);
90857+
90858+ if (err)
90859+ return ERR_PTR(err);
90860+
90861+ /* set pointer for parent subject */
90862+ if (s_tmp->parent_subject) {
90863+ s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
90864+
90865+ if (IS_ERR(s_tmp2))
90866+ return s_tmp2;
90867+
90868+ s_tmp->parent_subject = s_tmp2;
90869+ }
90870+
90871+ /* add in ip acls */
90872+
90873+ if (!s_tmp->ip_num) {
90874+ s_tmp->ips = NULL;
90875+ goto insert;
90876+ }
90877+
90878+ i_tmp =
90879+ (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
90880+ sizeof (struct acl_ip_label *));
90881+
90882+ if (!i_tmp)
90883+ return ERR_PTR(-ENOMEM);
90884+
90885+ for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
90886+ *(i_tmp + i_num) =
90887+ (struct acl_ip_label *)
90888+ acl_alloc(sizeof (struct acl_ip_label));
90889+ if (!*(i_tmp + i_num))
90890+ return ERR_PTR(-ENOMEM);
90891+
90892+ if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
90893+ return ERR_PTR(-EFAULT);
90894+
90895+ if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
90896+ return ERR_PTR(-EFAULT);
90897+
90898+ if ((*(i_tmp + i_num))->iface == NULL)
90899+ continue;
90900+
90901+ err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
90902+ if (err)
90903+ return ERR_PTR(err);
90904+ }
90905+
90906+ s_tmp->ips = i_tmp;
90907+
90908+insert:
90909+ if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
90910+ s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
90911+ return ERR_PTR(-ENOMEM);
90912+
90913+ return s_tmp;
90914+}
90915+
90916+static int
90917+copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
90918+{
90919+ struct acl_subject_label s_pre;
90920+ struct acl_subject_label * ret;
90921+ int err;
90922+
90923+ while (userp) {
90924+ if (copy_acl_subject_label(&s_pre, userp))
90925+ return -EFAULT;
90926+
90927+ ret = do_copy_user_subj(userp, role, NULL);
90928+
90929+ err = PTR_ERR(ret);
90930+ if (IS_ERR(ret))
90931+ return err;
90932+
90933+ insert_acl_subj_label(ret, role);
90934+
90935+ userp = s_pre.prev;
90936+ }
90937+
90938+ return 0;
90939+}
90940+
90941+static int
90942+copy_user_acl(struct gr_arg *arg)
90943+{
90944+ struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
90945+ struct acl_subject_label *subj_list;
90946+ struct sprole_pw *sptmp;
90947+ struct gr_hash_struct *ghash;
90948+ uid_t *domainlist;
90949+ unsigned int r_num;
90950+ int err = 0;
90951+ __u16 i;
90952+ __u32 num_subjs;
90953+
90954+ /* we need a default and kernel role */
90955+ if (arg->role_db.num_roles < 2)
90956+ return -EINVAL;
90957+
90958+ /* copy special role authentication info from userspace */
90959+
90960+ polstate->num_sprole_pws = arg->num_sprole_pws;
90961+ polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
90962+
90963+ if (!polstate->acl_special_roles && polstate->num_sprole_pws)
90964+ return -ENOMEM;
90965+
90966+ for (i = 0; i < polstate->num_sprole_pws; i++) {
90967+ sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
90968+ if (!sptmp)
90969+ return -ENOMEM;
90970+ if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
90971+ return -EFAULT;
90972+
90973+ err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
90974+ if (err)
90975+ return err;
90976+
90977+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
90978+ printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
90979+#endif
90980+
90981+ polstate->acl_special_roles[i] = sptmp;
90982+ }
90983+
90984+ r_utmp = (struct acl_role_label **) arg->role_db.r_table;
90985+
90986+ for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
90987+ r_tmp = acl_alloc(sizeof (struct acl_role_label));
90988+
90989+ if (!r_tmp)
90990+ return -ENOMEM;
90991+
90992+ if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
90993+ return -EFAULT;
90994+
90995+ if (copy_acl_role_label(r_tmp, r_utmp2))
90996+ return -EFAULT;
90997+
90998+ err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
90999+ if (err)
91000+ return err;
91001+
91002+ if (!strcmp(r_tmp->rolename, "default")
91003+ && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
91004+ polstate->default_role = r_tmp;
91005+ } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
91006+ polstate->kernel_role = r_tmp;
91007+ }
91008+
91009+ if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
91010+ return -ENOMEM;
91011+
91012+ if (copy_gr_hash_struct(ghash, r_tmp->hash))
91013+ return -EFAULT;
91014+
91015+ r_tmp->hash = ghash;
91016+
91017+ num_subjs = count_user_subjs(r_tmp->hash->first);
91018+
91019+ r_tmp->subj_hash_size = num_subjs;
91020+ r_tmp->subj_hash =
91021+ (struct acl_subject_label **)
91022+ create_table(&(r_tmp->subj_hash_size), sizeof(void *));
91023+
91024+ if (!r_tmp->subj_hash)
91025+ return -ENOMEM;
91026+
91027+ err = copy_user_allowedips(r_tmp);
91028+ if (err)
91029+ return err;
91030+
91031+ /* copy domain info */
91032+ if (r_tmp->domain_children != NULL) {
91033+ domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
91034+ if (domainlist == NULL)
91035+ return -ENOMEM;
91036+
91037+ if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
91038+ return -EFAULT;
91039+
91040+ r_tmp->domain_children = domainlist;
91041+ }
91042+
91043+ err = copy_user_transitions(r_tmp);
91044+ if (err)
91045+ return err;
91046+
91047+ memset(r_tmp->subj_hash, 0,
91048+ r_tmp->subj_hash_size *
91049+ sizeof (struct acl_subject_label *));
91050+
91051+ /* acquire the list of subjects, then NULL out
91052+ the list prior to parsing the subjects for this role,
91053+ as during this parsing the list is replaced with a list
91054+ of *nested* subjects for the role
91055+ */
91056+ subj_list = r_tmp->hash->first;
91057+
91058+ /* set nested subject list to null */
91059+ r_tmp->hash->first = NULL;
91060+
91061+ err = copy_user_subjs(subj_list, r_tmp);
91062+
91063+ if (err)
91064+ return err;
91065+
91066+ insert_acl_role_label(r_tmp);
91067+ }
91068+
91069+ if (polstate->default_role == NULL || polstate->kernel_role == NULL)
91070+ return -EINVAL;
91071+
91072+ return err;
91073+}
91074+
91075+static int gracl_reload_apply_policies(void *reload)
91076+{
91077+ struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
91078+ struct task_struct *task, *task2;
91079+ struct acl_role_label *role, *rtmp;
91080+ struct acl_subject_label *subj;
91081+ const struct cred *cred;
91082+ int role_applied;
91083+ int ret = 0;
91084+
91085+ memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_policy_state));
91086+ memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
91087+
91088+ /* first make sure we'll be able to apply the new policy cleanly */
91089+ do_each_thread(task2, task) {
91090+ if (task->exec_file == NULL)
91091+ continue;
91092+ role_applied = 0;
91093+ if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
91094+ /* preserve special roles */
91095+ FOR_EACH_ROLE_START(role)
91096+ if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
91097+ rtmp = task->role;
91098+ task->role = role;
91099+ role_applied = 1;
91100+ break;
91101+ }
91102+ FOR_EACH_ROLE_END(role)
91103+ }
91104+ if (!role_applied) {
91105+ cred = __task_cred(task);
91106+ rtmp = task->role;
91107+ task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
91108+ }
91109+ /* this handles non-nested inherited subjects, nested subjects will still
91110+ be dropped currently */
91111+ subj = __gr_get_subject_for_task(polstate, task, task->acl->filename, 1);
91112+ task->tmpacl = __gr_get_subject_for_task(polstate, task, NULL, 1);
91113+ /* change the role back so that we've made no modifications to the policy */
91114+ task->role = rtmp;
91115+
91116+ if (subj == NULL || task->tmpacl == NULL) {
91117+ ret = -EINVAL;
91118+ goto out;
91119+ }
91120+ } while_each_thread(task2, task);
91121+
91122+ /* now actually apply the policy */
91123+
91124+ do_each_thread(task2, task) {
91125+ if (task->exec_file) {
91126+ role_applied = 0;
91127+ if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
91128+ /* preserve special roles */
91129+ FOR_EACH_ROLE_START(role)
91130+ if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
91131+ task->role = role;
91132+ role_applied = 1;
91133+ break;
91134+ }
91135+ FOR_EACH_ROLE_END(role)
91136+ }
91137+ if (!role_applied) {
91138+ cred = __task_cred(task);
91139+ task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
91140+ }
91141+ /* this handles non-nested inherited subjects, nested subjects will still
91142+ be dropped currently */
91143+ if (!reload_state->oldmode && task->inherited)
91144+ subj = __gr_get_subject_for_task(polstate, task, task->acl->filename, 1);
91145+ else {
91146+ /* looked up and tagged to the task previously */
91147+ subj = task->tmpacl;
91148+ }
91149+ /* subj will be non-null */
91150+ __gr_apply_subject_to_task(polstate, task, subj);
91151+ if (reload_state->oldmode) {
91152+ task->acl_role_id = 0;
91153+ task->acl_sp_role = 0;
91154+ task->inherited = 0;
91155+ }
91156+ } else {
91157+ // it's a kernel process
91158+ task->role = polstate->kernel_role;
91159+ task->acl = polstate->kernel_role->root_label;
91160+#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
91161+ task->acl->mode &= ~GR_PROCFIND;
91162+#endif
91163+ }
91164+ } while_each_thread(task2, task);
91165+
91166+ memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
91167+ memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
91168+
91169+out:
91170+
91171+ return ret;
91172+}
91173+
91174+static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
91175+{
91176+ struct gr_reload_state new_reload_state = { };
91177+ int err;
91178+
91179+ new_reload_state.oldpolicy_ptr = polstate;
91180+ new_reload_state.oldalloc_ptr = current_alloc_state;
91181+ new_reload_state.oldmode = oldmode;
91182+
91183+ current_alloc_state = &new_reload_state.newalloc;
91184+ polstate = &new_reload_state.newpolicy;
91185+
91186+ /* everything relevant is now saved off, copy in the new policy */
91187+ if (init_variables(args, true)) {
91188+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
91189+ err = -ENOMEM;
91190+ goto error;
91191+ }
91192+
91193+ err = copy_user_acl(args);
91194+ free_init_variables();
91195+ if (err)
91196+ goto error;
91197+ /* the new policy is copied in, with the old policy available via saved_state
91198+ first go through applying roles, making sure to preserve special roles
91199+ then apply new subjects, making sure to preserve inherited and nested subjects,
91200+ though currently only inherited subjects will be preserved
91201+ */
91202+ err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
91203+ if (err)
91204+ goto error;
91205+
91206+ /* we've now applied the new policy, so restore the old policy state to free it */
91207+ polstate = &new_reload_state.oldpolicy;
91208+ current_alloc_state = &new_reload_state.oldalloc;
91209+ free_variables(true);
91210+
91211+ /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
91212+ to running_polstate/current_alloc_state inside stop_machine
91213+ */
91214+ err = 0;
91215+ goto out;
91216+error:
91217+ /* on error of loading the new policy, we'll just keep the previous
91218+ policy set around
91219+ */
91220+ free_variables(true);
91221+
91222+ /* doesn't affect runtime, but maintains consistent state */
91223+out:
91224+ polstate = new_reload_state.oldpolicy_ptr;
91225+ current_alloc_state = new_reload_state.oldalloc_ptr;
91226+
91227+ return err;
91228+}
91229+
91230+static int
91231+gracl_init(struct gr_arg *args)
91232+{
91233+ int error = 0;
91234+
91235+ memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
91236+ memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
91237+
91238+ if (init_variables(args, false)) {
91239+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
91240+ error = -ENOMEM;
91241+ goto out;
91242+ }
91243+
91244+ error = copy_user_acl(args);
91245+ free_init_variables();
91246+ if (error)
91247+ goto out;
91248+
91249+ error = gr_set_acls(0);
91250+ if (error)
91251+ goto out;
91252+
91253+ gr_enable_rbac_system();
91254+
91255+ return 0;
91256+
91257+out:
91258+ free_variables(false);
91259+ return error;
91260+}
91261+
91262+static int
91263+lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
91264+ unsigned char **sum)
91265+{
91266+ struct acl_role_label *r;
91267+ struct role_allowed_ip *ipp;
91268+ struct role_transition *trans;
91269+ unsigned int i;
91270+ int found = 0;
91271+ u32 curr_ip = current->signal->curr_ip;
91272+
91273+ current->signal->saved_ip = curr_ip;
91274+
91275+ /* check transition table */
91276+
91277+ for (trans = current->role->transitions; trans; trans = trans->next) {
91278+ if (!strcmp(rolename, trans->rolename)) {
91279+ found = 1;
91280+ break;
91281+ }
91282+ }
91283+
91284+ if (!found)
91285+ return 0;
91286+
91287+ /* handle special roles that do not require authentication
91288+ and check ip */
91289+
91290+ FOR_EACH_ROLE_START(r)
91291+ if (!strcmp(rolename, r->rolename) &&
91292+ (r->roletype & GR_ROLE_SPECIAL)) {
91293+ found = 0;
91294+ if (r->allowed_ips != NULL) {
91295+ for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
91296+ if ((ntohl(curr_ip) & ipp->netmask) ==
91297+ (ntohl(ipp->addr) & ipp->netmask))
91298+ found = 1;
91299+ }
91300+ } else
91301+ found = 2;
91302+ if (!found)
91303+ return 0;
91304+
91305+ if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
91306+ ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
91307+ *salt = NULL;
91308+ *sum = NULL;
91309+ return 1;
91310+ }
91311+ }
91312+ FOR_EACH_ROLE_END(r)
91313+
91314+ for (i = 0; i < polstate->num_sprole_pws; i++) {
91315+ if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
91316+ *salt = polstate->acl_special_roles[i]->salt;
91317+ *sum = polstate->acl_special_roles[i]->sum;
91318+ return 1;
91319+ }
91320+ }
91321+
91322+ return 0;
91323+}
91324+
91325+int gr_check_secure_terminal(struct task_struct *task)
91326+{
91327+ struct task_struct *p, *p2, *p3;
91328+ struct files_struct *files;
91329+ struct fdtable *fdt;
91330+ struct file *our_file = NULL, *file;
91331+ struct inode *our_inode = NULL;
91332+ int i;
91333+
91334+ if (task->signal->tty == NULL)
91335+ return 1;
91336+
91337+ files = get_files_struct(task);
91338+ if (files != NULL) {
91339+ rcu_read_lock();
91340+ fdt = files_fdtable(files);
91341+ for (i=0; i < fdt->max_fds; i++) {
91342+ file = fcheck_files(files, i);
91343+ if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
91344+ get_file(file);
91345+ our_file = file;
91346+ }
91347+ }
91348+ rcu_read_unlock();
91349+ put_files_struct(files);
91350+ }
91351+
91352+ if (our_file == NULL)
91353+ return 1;
91354+
91355+ our_inode = d_backing_inode(our_file->f_path.dentry);
91356+
91357+ read_lock(&tasklist_lock);
91358+ do_each_thread(p2, p) {
91359+ files = get_files_struct(p);
91360+ if (files == NULL ||
91361+ (p->signal && p->signal->tty == task->signal->tty)) {
91362+ if (files != NULL)
91363+ put_files_struct(files);
91364+ continue;
91365+ }
91366+ rcu_read_lock();
91367+ fdt = files_fdtable(files);
91368+ for (i=0; i < fdt->max_fds; i++) {
91369+ struct inode *inode = NULL;
91370+ file = fcheck_files(files, i);
91371+ if (file)
91372+ inode = d_backing_inode(file->f_path.dentry);
91373+ if (inode && S_ISCHR(inode->i_mode) && inode->i_rdev == our_inode->i_rdev) {
91374+ p3 = task;
91375+ while (task_pid_nr(p3) > 0) {
91376+ if (p3 == p)
91377+ break;
91378+ p3 = p3->real_parent;
91379+ }
91380+ if (p3 == p)
91381+ break;
91382+ gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
91383+ gr_handle_alertkill(p);
91384+ rcu_read_unlock();
91385+ put_files_struct(files);
91386+ read_unlock(&tasklist_lock);
91387+ fput(our_file);
91388+ return 0;
91389+ }
91390+ }
91391+ rcu_read_unlock();
91392+ put_files_struct(files);
91393+ } while_each_thread(p2, p);
91394+ read_unlock(&tasklist_lock);
91395+
91396+ fput(our_file);
91397+ return 1;
91398+}
91399+
91400+ssize_t
91401+write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
91402+{
91403+ struct gr_arg_wrapper uwrap;
91404+ unsigned char *sprole_salt = NULL;
91405+ unsigned char *sprole_sum = NULL;
91406+ int error = 0;
91407+ int error2 = 0;
91408+ size_t req_count = 0;
91409+ unsigned char oldmode = 0;
91410+
91411+ mutex_lock(&gr_dev_mutex);
91412+
91413+ if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
91414+ error = -EPERM;
91415+ goto out;
91416+ }
91417+
91418+#ifdef CONFIG_COMPAT
91419+ pax_open_kernel();
91420+ if (is_compat_task()) {
91421+ copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
91422+ copy_gr_arg = &copy_gr_arg_compat;
91423+ copy_acl_object_label = &copy_acl_object_label_compat;
91424+ copy_acl_subject_label = &copy_acl_subject_label_compat;
91425+ copy_acl_role_label = &copy_acl_role_label_compat;
91426+ copy_acl_ip_label = &copy_acl_ip_label_compat;
91427+ copy_role_allowed_ip = &copy_role_allowed_ip_compat;
91428+ copy_role_transition = &copy_role_transition_compat;
91429+ copy_sprole_pw = &copy_sprole_pw_compat;
91430+ copy_gr_hash_struct = &copy_gr_hash_struct_compat;
91431+ copy_pointer_from_array = &copy_pointer_from_array_compat;
91432+ get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
91433+ } else {
91434+ copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
91435+ copy_gr_arg = &copy_gr_arg_normal;
91436+ copy_acl_object_label = &copy_acl_object_label_normal;
91437+ copy_acl_subject_label = &copy_acl_subject_label_normal;
91438+ copy_acl_role_label = &copy_acl_role_label_normal;
91439+ copy_acl_ip_label = &copy_acl_ip_label_normal;
91440+ copy_role_allowed_ip = &copy_role_allowed_ip_normal;
91441+ copy_role_transition = &copy_role_transition_normal;
91442+ copy_sprole_pw = &copy_sprole_pw_normal;
91443+ copy_gr_hash_struct = &copy_gr_hash_struct_normal;
91444+ copy_pointer_from_array = &copy_pointer_from_array_normal;
91445+ get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
91446+ }
91447+ pax_close_kernel();
91448+#endif
91449+
91450+ req_count = get_gr_arg_wrapper_size();
91451+
91452+ if (count != req_count) {
91453+ gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
91454+ error = -EINVAL;
91455+ goto out;
91456+ }
91457+
91458+
91459+ if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
91460+ gr_auth_expires = 0;
91461+ gr_auth_attempts = 0;
91462+ }
91463+
91464+ error = copy_gr_arg_wrapper(buf, &uwrap);
91465+ if (error)
91466+ goto out;
91467+
91468+ error = copy_gr_arg(uwrap.arg, gr_usermode);
91469+ if (error)
91470+ goto out;
91471+
91472+ if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
91473+ gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
91474+ time_after(gr_auth_expires, get_seconds())) {
91475+ error = -EBUSY;
91476+ goto out;
91477+ }
91478+
91479+ /* if non-root trying to do anything other than use a special role,
91480+ do not attempt authentication, do not count towards authentication
91481+ locking
91482+ */
91483+
91484+ if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
91485+ gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
91486+ gr_is_global_nonroot(current_uid())) {
91487+ error = -EPERM;
91488+ goto out;
91489+ }
91490+
91491+ /* ensure pw and special role name are null terminated */
91492+
91493+ gr_usermode->pw[GR_PW_LEN - 1] = '\0';
91494+ gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
91495+
91496+ /* Okay.
91497+ * We have our enough of the argument structure..(we have yet
91498+ * to copy_from_user the tables themselves) . Copy the tables
91499+ * only if we need them, i.e. for loading operations. */
91500+
91501+ switch (gr_usermode->mode) {
91502+ case GR_STATUS:
91503+ if (gr_acl_is_enabled()) {
91504+ error = 1;
91505+ if (!gr_check_secure_terminal(current))
91506+ error = 3;
91507+ } else
91508+ error = 2;
91509+ goto out;
91510+ case GR_SHUTDOWN:
91511+ if (gr_acl_is_enabled() && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
91512+ stop_machine(gr_rbac_disable, NULL, NULL);
91513+ free_variables(false);
91514+ memset(gr_usermode, 0, sizeof(struct gr_arg));
91515+ memset(gr_system_salt, 0, GR_SALT_LEN);
91516+ memset(gr_system_sum, 0, GR_SHA_LEN);
91517+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
91518+ } else if (gr_acl_is_enabled()) {
91519+ gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
91520+ error = -EPERM;
91521+ } else {
91522+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
91523+ error = -EAGAIN;
91524+ }
91525+ break;
91526+ case GR_ENABLE:
91527+ if (!gr_acl_is_enabled() && !(error2 = gracl_init(gr_usermode)))
91528+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
91529+ else {
91530+ if (gr_acl_is_enabled())
91531+ error = -EAGAIN;
91532+ else
91533+ error = error2;
91534+ gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
91535+ }
91536+ break;
91537+ case GR_OLDRELOAD:
91538+ oldmode = 1;
91539+ case GR_RELOAD:
91540+ if (!gr_acl_is_enabled()) {
91541+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
91542+ error = -EAGAIN;
91543+ } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
91544+ error2 = gracl_reload(gr_usermode, oldmode);
91545+ if (!error2)
91546+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
91547+ else {
91548+ gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
91549+ error = error2;
91550+ }
91551+ } else {
91552+ gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
91553+ error = -EPERM;
91554+ }
91555+ break;
91556+ case GR_SEGVMOD:
91557+ if (unlikely(!gr_acl_is_enabled())) {
91558+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
91559+ error = -EAGAIN;
91560+ break;
91561+ }
91562+
91563+ if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
91564+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
91565+ if (gr_usermode->segv_device && gr_usermode->segv_inode) {
91566+ struct acl_subject_label *segvacl;
91567+ segvacl =
91568+ lookup_acl_subj_label(gr_usermode->segv_inode,
91569+ gr_usermode->segv_device,
91570+ current->role);
91571+ if (segvacl) {
91572+ segvacl->crashes = 0;
91573+ segvacl->expires = 0;
91574+ }
91575+ } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
91576+ gr_remove_uid(gr_usermode->segv_uid);
91577+ }
91578+ } else {
91579+ gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
91580+ error = -EPERM;
91581+ }
91582+ break;
91583+ case GR_SPROLE:
91584+ case GR_SPROLEPAM:
91585+ if (unlikely(!gr_acl_is_enabled())) {
91586+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
91587+ error = -EAGAIN;
91588+ break;
91589+ }
91590+
91591+ if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
91592+ current->role->expires = 0;
91593+ current->role->auth_attempts = 0;
91594+ }
91595+
91596+ if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
91597+ time_after(current->role->expires, get_seconds())) {
91598+ error = -EBUSY;
91599+ goto out;
91600+ }
91601+
91602+ if (lookup_special_role_auth
91603+ (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
91604+ && ((!sprole_salt && !sprole_sum)
91605+ || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
91606+ char *p = "";
91607+ assign_special_role(gr_usermode->sp_role);
91608+ read_lock(&tasklist_lock);
91609+ if (current->real_parent)
91610+ p = current->real_parent->role->rolename;
91611+ read_unlock(&tasklist_lock);
91612+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
91613+ p, acl_sp_role_value);
91614+ } else {
91615+ gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
91616+ error = -EPERM;
91617+ if(!(current->role->auth_attempts++))
91618+ current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
91619+
91620+ goto out;
91621+ }
91622+ break;
91623+ case GR_UNSPROLE:
91624+ if (unlikely(!gr_acl_is_enabled())) {
91625+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
91626+ error = -EAGAIN;
91627+ break;
91628+ }
91629+
91630+ if (current->role->roletype & GR_ROLE_SPECIAL) {
91631+ char *p = "";
91632+ int i = 0;
91633+
91634+ read_lock(&tasklist_lock);
91635+ if (current->real_parent) {
91636+ p = current->real_parent->role->rolename;
91637+ i = current->real_parent->acl_role_id;
91638+ }
91639+ read_unlock(&tasklist_lock);
91640+
91641+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
91642+ gr_set_acls(1);
91643+ } else {
91644+ error = -EPERM;
91645+ goto out;
91646+ }
91647+ break;
91648+ default:
91649+ gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
91650+ error = -EINVAL;
91651+ break;
91652+ }
91653+
91654+ if (error != -EPERM)
91655+ goto out;
91656+
91657+ if(!(gr_auth_attempts++))
91658+ gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
91659+
91660+ out:
91661+ mutex_unlock(&gr_dev_mutex);
91662+
91663+ if (!error)
91664+ error = req_count;
91665+
91666+ return error;
91667+}
91668+
91669+int
91670+gr_set_acls(const int type)
91671+{
91672+ struct task_struct *task, *task2;
91673+ struct acl_role_label *role = current->role;
91674+ struct acl_subject_label *subj;
91675+ __u16 acl_role_id = current->acl_role_id;
91676+ const struct cred *cred;
91677+ int ret;
91678+
91679+ rcu_read_lock();
91680+ read_lock(&tasklist_lock);
91681+ read_lock(&grsec_exec_file_lock);
91682+ do_each_thread(task2, task) {
91683+ /* check to see if we're called from the exit handler,
91684+ if so, only replace ACLs that have inherited the admin
91685+ ACL */
91686+
91687+ if (type && (task->role != role ||
91688+ task->acl_role_id != acl_role_id))
91689+ continue;
91690+
91691+ task->acl_role_id = 0;
91692+ task->acl_sp_role = 0;
91693+ task->inherited = 0;
91694+
91695+ if (task->exec_file) {
91696+ cred = __task_cred(task);
91697+ task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
91698+ subj = __gr_get_subject_for_task(polstate, task, NULL, 1);
91699+ if (subj == NULL) {
91700+ ret = -EINVAL;
91701+ read_unlock(&grsec_exec_file_lock);
91702+ read_unlock(&tasklist_lock);
91703+ rcu_read_unlock();
91704+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
91705+ return ret;
91706+ }
91707+ __gr_apply_subject_to_task(polstate, task, subj);
91708+ } else {
91709+ // it's a kernel process
91710+ task->role = polstate->kernel_role;
91711+ task->acl = polstate->kernel_role->root_label;
91712+#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
91713+ task->acl->mode &= ~GR_PROCFIND;
91714+#endif
91715+ }
91716+ } while_each_thread(task2, task);
91717+ read_unlock(&grsec_exec_file_lock);
91718+ read_unlock(&tasklist_lock);
91719+ rcu_read_unlock();
91720+
91721+ return 0;
91722+}
91723diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
91724new file mode 100644
91725index 0000000..39645c9
91726--- /dev/null
91727+++ b/grsecurity/gracl_res.c
91728@@ -0,0 +1,68 @@
91729+#include <linux/kernel.h>
91730+#include <linux/sched.h>
91731+#include <linux/gracl.h>
91732+#include <linux/grinternal.h>
91733+
91734+static const char *restab_log[] = {
91735+ [RLIMIT_CPU] = "RLIMIT_CPU",
91736+ [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
91737+ [RLIMIT_DATA] = "RLIMIT_DATA",
91738+ [RLIMIT_STACK] = "RLIMIT_STACK",
91739+ [RLIMIT_CORE] = "RLIMIT_CORE",
91740+ [RLIMIT_RSS] = "RLIMIT_RSS",
91741+ [RLIMIT_NPROC] = "RLIMIT_NPROC",
91742+ [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
91743+ [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
91744+ [RLIMIT_AS] = "RLIMIT_AS",
91745+ [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
91746+ [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
91747+ [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
91748+ [RLIMIT_NICE] = "RLIMIT_NICE",
91749+ [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
91750+ [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
91751+ [GR_CRASH_RES] = "RLIMIT_CRASH"
91752+};
91753+
91754+void
91755+gr_log_resource(const struct task_struct *task,
91756+ const int res, const unsigned long wanted, const int gt)
91757+{
91758+ const struct cred *cred;
91759+ unsigned long rlim;
91760+
91761+ if (!gr_acl_is_enabled() && !grsec_resource_logging)
91762+ return;
91763+
91764+ // not yet supported resource
91765+ if (unlikely(!restab_log[res]))
91766+ return;
91767+
91768+ if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
91769+ rlim = task_rlimit_max(task, res);
91770+ else
91771+ rlim = task_rlimit(task, res);
91772+
91773+ if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
91774+ return;
91775+
91776+ rcu_read_lock();
91777+ cred = __task_cred(task);
91778+
91779+ if (res == RLIMIT_NPROC &&
91780+ (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
91781+ cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
91782+ goto out_rcu_unlock;
91783+ else if (res == RLIMIT_MEMLOCK &&
91784+ cap_raised(cred->cap_effective, CAP_IPC_LOCK))
91785+ goto out_rcu_unlock;
91786+ else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
91787+ goto out_rcu_unlock;
91788+ rcu_read_unlock();
91789+
91790+ gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
91791+
91792+ return;
91793+out_rcu_unlock:
91794+ rcu_read_unlock();
91795+ return;
91796+}
91797diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
91798new file mode 100644
91799index 0000000..21646aa
91800--- /dev/null
91801+++ b/grsecurity/gracl_segv.c
91802@@ -0,0 +1,304 @@
91803+#include <linux/kernel.h>
91804+#include <linux/mm.h>
91805+#include <asm/uaccess.h>
91806+#include <asm/errno.h>
91807+#include <asm/mman.h>
91808+#include <net/sock.h>
91809+#include <linux/file.h>
91810+#include <linux/fs.h>
91811+#include <linux/net.h>
91812+#include <linux/in.h>
91813+#include <linux/slab.h>
91814+#include <linux/types.h>
91815+#include <linux/sched.h>
91816+#include <linux/timer.h>
91817+#include <linux/gracl.h>
91818+#include <linux/grsecurity.h>
91819+#include <linux/grinternal.h>
91820+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
91821+#include <linux/magic.h>
91822+#include <linux/pagemap.h>
91823+#include "../fs/btrfs/async-thread.h"
91824+#include "../fs/btrfs/ctree.h"
91825+#include "../fs/btrfs/btrfs_inode.h"
91826+#endif
91827+
91828+static struct crash_uid *uid_set;
91829+static unsigned short uid_used;
91830+static DEFINE_SPINLOCK(gr_uid_lock);
91831+extern rwlock_t gr_inode_lock;
91832+extern struct acl_subject_label *
91833+ lookup_acl_subj_label(const u64 inode, const dev_t dev,
91834+ struct acl_role_label *role);
91835+
91836+int
91837+gr_init_uidset(void)
91838+{
91839+ uid_set =
91840+ kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
91841+ uid_used = 0;
91842+
91843+ return uid_set ? 1 : 0;
91844+}
91845+
91846+void
91847+gr_free_uidset(void)
91848+{
91849+ if (uid_set) {
91850+ struct crash_uid *tmpset;
91851+ spin_lock(&gr_uid_lock);
91852+ tmpset = uid_set;
91853+ uid_set = NULL;
91854+ uid_used = 0;
91855+ spin_unlock(&gr_uid_lock);
91856+ if (tmpset)
91857+ kfree(tmpset);
91858+ }
91859+
91860+ return;
91861+}
91862+
91863+int
91864+gr_find_uid(const uid_t uid)
91865+{
91866+ struct crash_uid *tmp = uid_set;
91867+ uid_t buid;
91868+ int low = 0, high = uid_used - 1, mid;
91869+
91870+ while (high >= low) {
91871+ mid = (low + high) >> 1;
91872+ buid = tmp[mid].uid;
91873+ if (buid == uid)
91874+ return mid;
91875+ if (buid > uid)
91876+ high = mid - 1;
91877+ if (buid < uid)
91878+ low = mid + 1;
91879+ }
91880+
91881+ return -1;
91882+}
91883+
91884+static void
91885+gr_insertsort(void)
91886+{
91887+ unsigned short i, j;
91888+ struct crash_uid index;
91889+
91890+ for (i = 1; i < uid_used; i++) {
91891+ index = uid_set[i];
91892+ j = i;
91893+ while ((j > 0) && uid_set[j - 1].uid > index.uid) {
91894+ uid_set[j] = uid_set[j - 1];
91895+ j--;
91896+ }
91897+ uid_set[j] = index;
91898+ }
91899+
91900+ return;
91901+}
91902+
91903+static void
91904+gr_insert_uid(const kuid_t kuid, const unsigned long expires)
91905+{
91906+ int loc;
91907+ uid_t uid = GR_GLOBAL_UID(kuid);
91908+
91909+ if (uid_used == GR_UIDTABLE_MAX)
91910+ return;
91911+
91912+ loc = gr_find_uid(uid);
91913+
91914+ if (loc >= 0) {
91915+ uid_set[loc].expires = expires;
91916+ return;
91917+ }
91918+
91919+ uid_set[uid_used].uid = uid;
91920+ uid_set[uid_used].expires = expires;
91921+ uid_used++;
91922+
91923+ gr_insertsort();
91924+
91925+ return;
91926+}
91927+
91928+void
91929+gr_remove_uid(const unsigned short loc)
91930+{
91931+ unsigned short i;
91932+
91933+ for (i = loc + 1; i < uid_used; i++)
91934+ uid_set[i - 1] = uid_set[i];
91935+
91936+ uid_used--;
91937+
91938+ return;
91939+}
91940+
91941+int
91942+gr_check_crash_uid(const kuid_t kuid)
91943+{
91944+ int loc;
91945+ int ret = 0;
91946+ uid_t uid;
91947+
91948+ if (unlikely(!gr_acl_is_enabled()))
91949+ return 0;
91950+
91951+ uid = GR_GLOBAL_UID(kuid);
91952+
91953+ spin_lock(&gr_uid_lock);
91954+ loc = gr_find_uid(uid);
91955+
91956+ if (loc < 0)
91957+ goto out_unlock;
91958+
91959+ if (time_before_eq(uid_set[loc].expires, get_seconds()))
91960+ gr_remove_uid(loc);
91961+ else
91962+ ret = 1;
91963+
91964+out_unlock:
91965+ spin_unlock(&gr_uid_lock);
91966+ return ret;
91967+}
91968+
91969+static int
91970+proc_is_setxid(const struct cred *cred)
91971+{
91972+ if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
91973+ !uid_eq(cred->uid, cred->fsuid))
91974+ return 1;
91975+ if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
91976+ !gid_eq(cred->gid, cred->fsgid))
91977+ return 1;
91978+
91979+ return 0;
91980+}
91981+
91982+extern int gr_fake_force_sig(int sig, struct task_struct *t);
91983+
91984+void
91985+gr_handle_crash(struct task_struct *task, const int sig)
91986+{
91987+ struct acl_subject_label *curr;
91988+ struct task_struct *tsk, *tsk2;
91989+ const struct cred *cred;
91990+ const struct cred *cred2;
91991+
91992+ if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
91993+ return;
91994+
91995+ if (unlikely(!gr_acl_is_enabled()))
91996+ return;
91997+
91998+ curr = task->acl;
91999+
92000+ if (!(curr->resmask & (1U << GR_CRASH_RES)))
92001+ return;
92002+
92003+ if (time_before_eq(curr->expires, get_seconds())) {
92004+ curr->expires = 0;
92005+ curr->crashes = 0;
92006+ }
92007+
92008+ curr->crashes++;
92009+
92010+ if (!curr->expires)
92011+ curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
92012+
92013+ if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
92014+ time_after(curr->expires, get_seconds())) {
92015+ rcu_read_lock();
92016+ cred = __task_cred(task);
92017+ if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
92018+ gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
92019+ spin_lock(&gr_uid_lock);
92020+ gr_insert_uid(cred->uid, curr->expires);
92021+ spin_unlock(&gr_uid_lock);
92022+ curr->expires = 0;
92023+ curr->crashes = 0;
92024+ read_lock(&tasklist_lock);
92025+ do_each_thread(tsk2, tsk) {
92026+ cred2 = __task_cred(tsk);
92027+ if (tsk != task && uid_eq(cred2->uid, cred->uid))
92028+ gr_fake_force_sig(SIGKILL, tsk);
92029+ } while_each_thread(tsk2, tsk);
92030+ read_unlock(&tasklist_lock);
92031+ } else {
92032+ gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
92033+ read_lock(&tasklist_lock);
92034+ read_lock(&grsec_exec_file_lock);
92035+ do_each_thread(tsk2, tsk) {
92036+ if (likely(tsk != task)) {
92037+ // if this thread has the same subject as the one that triggered
92038+ // RES_CRASH and it's the same binary, kill it
92039+ if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
92040+ gr_fake_force_sig(SIGKILL, tsk);
92041+ }
92042+ } while_each_thread(tsk2, tsk);
92043+ read_unlock(&grsec_exec_file_lock);
92044+ read_unlock(&tasklist_lock);
92045+ }
92046+ rcu_read_unlock();
92047+ }
92048+
92049+ return;
92050+}
92051+
92052+int
92053+gr_check_crash_exec(const struct file *filp)
92054+{
92055+ struct acl_subject_label *curr;
92056+ struct dentry *dentry;
92057+
92058+ if (unlikely(!gr_acl_is_enabled()))
92059+ return 0;
92060+
92061+ read_lock(&gr_inode_lock);
92062+ dentry = filp->f_path.dentry;
92063+ curr = lookup_acl_subj_label(gr_get_ino_from_dentry(dentry), gr_get_dev_from_dentry(dentry),
92064+ current->role);
92065+ read_unlock(&gr_inode_lock);
92066+
92067+ if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
92068+ (!curr->crashes && !curr->expires))
92069+ return 0;
92070+
92071+ if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
92072+ time_after(curr->expires, get_seconds()))
92073+ return 1;
92074+ else if (time_before_eq(curr->expires, get_seconds())) {
92075+ curr->crashes = 0;
92076+ curr->expires = 0;
92077+ }
92078+
92079+ return 0;
92080+}
92081+
92082+void
92083+gr_handle_alertkill(struct task_struct *task)
92084+{
92085+ struct acl_subject_label *curracl;
92086+ __u32 curr_ip;
92087+ struct task_struct *p, *p2;
92088+
92089+ if (unlikely(!gr_acl_is_enabled()))
92090+ return;
92091+
92092+ curracl = task->acl;
92093+ curr_ip = task->signal->curr_ip;
92094+
92095+ if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
92096+ read_lock(&tasklist_lock);
92097+ do_each_thread(p2, p) {
92098+ if (p->signal->curr_ip == curr_ip)
92099+ gr_fake_force_sig(SIGKILL, p);
92100+ } while_each_thread(p2, p);
92101+ read_unlock(&tasklist_lock);
92102+ } else if (curracl->mode & GR_KILLPROC)
92103+ gr_fake_force_sig(SIGKILL, task);
92104+
92105+ return;
92106+}
92107diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
92108new file mode 100644
92109index 0000000..6b0c9cc
92110--- /dev/null
92111+++ b/grsecurity/gracl_shm.c
92112@@ -0,0 +1,40 @@
92113+#include <linux/kernel.h>
92114+#include <linux/mm.h>
92115+#include <linux/sched.h>
92116+#include <linux/file.h>
92117+#include <linux/ipc.h>
92118+#include <linux/gracl.h>
92119+#include <linux/grsecurity.h>
92120+#include <linux/grinternal.h>
92121+
92122+int
92123+gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
92124+ const u64 shm_createtime, const kuid_t cuid, const int shmid)
92125+{
92126+ struct task_struct *task;
92127+
92128+ if (!gr_acl_is_enabled())
92129+ return 1;
92130+
92131+ rcu_read_lock();
92132+ read_lock(&tasklist_lock);
92133+
92134+ task = find_task_by_vpid(shm_cprid);
92135+
92136+ if (unlikely(!task))
92137+ task = find_task_by_vpid(shm_lapid);
92138+
92139+ if (unlikely(task && (time_before_eq64(task->start_time, shm_createtime) ||
92140+ (task_pid_nr(task) == shm_lapid)) &&
92141+ (task->acl->mode & GR_PROTSHM) &&
92142+ (task->acl != current->acl))) {
92143+ read_unlock(&tasklist_lock);
92144+ rcu_read_unlock();
92145+ gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
92146+ return 0;
92147+ }
92148+ read_unlock(&tasklist_lock);
92149+ rcu_read_unlock();
92150+
92151+ return 1;
92152+}
92153diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
92154new file mode 100644
92155index 0000000..bc0be01
92156--- /dev/null
92157+++ b/grsecurity/grsec_chdir.c
92158@@ -0,0 +1,19 @@
92159+#include <linux/kernel.h>
92160+#include <linux/sched.h>
92161+#include <linux/fs.h>
92162+#include <linux/file.h>
92163+#include <linux/grsecurity.h>
92164+#include <linux/grinternal.h>
92165+
92166+void
92167+gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
92168+{
92169+#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
92170+ if ((grsec_enable_chdir && grsec_enable_group &&
92171+ in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
92172+ !grsec_enable_group)) {
92173+ gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
92174+ }
92175+#endif
92176+ return;
92177+}
92178diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
92179new file mode 100644
92180index 0000000..652ab45
92181--- /dev/null
92182+++ b/grsecurity/grsec_chroot.c
92183@@ -0,0 +1,467 @@
92184+#include <linux/kernel.h>
92185+#include <linux/module.h>
92186+#include <linux/sched.h>
92187+#include <linux/file.h>
92188+#include <linux/fs.h>
92189+#include <linux/mount.h>
92190+#include <linux/types.h>
92191+#include "../fs/mount.h"
92192+#include <linux/grsecurity.h>
92193+#include <linux/grinternal.h>
92194+
92195+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
92196+int gr_init_ran;
92197+#endif
92198+
92199+void gr_inc_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt)
92200+{
92201+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92202+ struct dentry *tmpd = dentry;
92203+
92204+ read_seqlock_excl(&mount_lock);
92205+ write_seqlock(&rename_lock);
92206+
92207+ while (tmpd != mnt->mnt_root) {
92208+ atomic_inc(&tmpd->chroot_refcnt);
92209+ tmpd = tmpd->d_parent;
92210+ }
92211+ atomic_inc(&tmpd->chroot_refcnt);
92212+
92213+ write_sequnlock(&rename_lock);
92214+ read_sequnlock_excl(&mount_lock);
92215+#endif
92216+}
92217+
92218+void gr_dec_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt)
92219+{
92220+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92221+ struct dentry *tmpd = dentry;
92222+
92223+ read_seqlock_excl(&mount_lock);
92224+ write_seqlock(&rename_lock);
92225+
92226+ while (tmpd != mnt->mnt_root) {
92227+ atomic_dec(&tmpd->chroot_refcnt);
92228+ tmpd = tmpd->d_parent;
92229+ }
92230+ atomic_dec(&tmpd->chroot_refcnt);
92231+
92232+ write_sequnlock(&rename_lock);
92233+ read_sequnlock_excl(&mount_lock);
92234+#endif
92235+}
92236+
92237+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92238+static struct dentry *get_closest_chroot(struct dentry *dentry)
92239+{
92240+ write_seqlock(&rename_lock);
92241+ do {
92242+ if (atomic_read(&dentry->chroot_refcnt)) {
92243+ write_sequnlock(&rename_lock);
92244+ return dentry;
92245+ }
92246+ dentry = dentry->d_parent;
92247+ } while (!IS_ROOT(dentry));
92248+ write_sequnlock(&rename_lock);
92249+ return NULL;
92250+}
92251+#endif
92252+
92253+int gr_bad_chroot_rename(struct dentry *olddentry, struct vfsmount *oldmnt,
92254+ struct dentry *newdentry, struct vfsmount *newmnt)
92255+{
92256+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92257+ struct dentry *chroot;
92258+
92259+ if (unlikely(!grsec_enable_chroot_rename))
92260+ return 0;
92261+
92262+ if (likely(!proc_is_chrooted(current) && gr_is_global_root(current_uid())))
92263+ return 0;
92264+
92265+ chroot = get_closest_chroot(olddentry);
92266+
92267+ if (chroot == NULL)
92268+ return 0;
92269+
92270+ if (is_subdir(newdentry, chroot))
92271+ return 0;
92272+
92273+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_RENAME_MSG, olddentry, oldmnt);
92274+
92275+ return 1;
92276+#else
92277+ return 0;
92278+#endif
92279+}
92280+
92281+void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
92282+{
92283+#ifdef CONFIG_GRKERNSEC
92284+ if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
92285+ path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
92286+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
92287+ && gr_init_ran
92288+#endif
92289+ )
92290+ task->gr_is_chrooted = 1;
92291+ else {
92292+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
92293+ if (task_pid_nr(task) == 1 && !gr_init_ran)
92294+ gr_init_ran = 1;
92295+#endif
92296+ task->gr_is_chrooted = 0;
92297+ }
92298+
92299+ task->gr_chroot_dentry = path->dentry;
92300+#endif
92301+ return;
92302+}
92303+
92304+void gr_clear_chroot_entries(struct task_struct *task)
92305+{
92306+#ifdef CONFIG_GRKERNSEC
92307+ task->gr_is_chrooted = 0;
92308+ task->gr_chroot_dentry = NULL;
92309+#endif
92310+ return;
92311+}
92312+
92313+int
92314+gr_handle_chroot_unix(const pid_t pid)
92315+{
92316+#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
92317+ struct task_struct *p;
92318+
92319+ if (unlikely(!grsec_enable_chroot_unix))
92320+ return 1;
92321+
92322+ if (likely(!proc_is_chrooted(current)))
92323+ return 1;
92324+
92325+ rcu_read_lock();
92326+ read_lock(&tasklist_lock);
92327+ p = find_task_by_vpid_unrestricted(pid);
92328+ if (unlikely(p && !have_same_root(current, p))) {
92329+ read_unlock(&tasklist_lock);
92330+ rcu_read_unlock();
92331+ gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
92332+ return 0;
92333+ }
92334+ read_unlock(&tasklist_lock);
92335+ rcu_read_unlock();
92336+#endif
92337+ return 1;
92338+}
92339+
92340+int
92341+gr_handle_chroot_nice(void)
92342+{
92343+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
92344+ if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
92345+ gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
92346+ return -EPERM;
92347+ }
92348+#endif
92349+ return 0;
92350+}
92351+
92352+int
92353+gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
92354+{
92355+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
92356+ if (grsec_enable_chroot_nice && (niceval < task_nice(p))
92357+ && proc_is_chrooted(current)) {
92358+ gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
92359+ return -EACCES;
92360+ }
92361+#endif
92362+ return 0;
92363+}
92364+
92365+int
92366+gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
92367+{
92368+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
92369+ struct task_struct *p;
92370+ int ret = 0;
92371+ if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
92372+ return ret;
92373+
92374+ read_lock(&tasklist_lock);
92375+ do_each_pid_task(pid, type, p) {
92376+ if (!have_same_root(current, p)) {
92377+ ret = 1;
92378+ goto out;
92379+ }
92380+ } while_each_pid_task(pid, type, p);
92381+out:
92382+ read_unlock(&tasklist_lock);
92383+ return ret;
92384+#endif
92385+ return 0;
92386+}
92387+
92388+int
92389+gr_pid_is_chrooted(struct task_struct *p)
92390+{
92391+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
92392+ if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
92393+ return 0;
92394+
92395+ if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
92396+ !have_same_root(current, p)) {
92397+ return 1;
92398+ }
92399+#endif
92400+ return 0;
92401+}
92402+
92403+EXPORT_SYMBOL_GPL(gr_pid_is_chrooted);
92404+
92405+#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
92406+int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
92407+{
92408+ struct path path, currentroot;
92409+ int ret = 0;
92410+
92411+ path.dentry = (struct dentry *)u_dentry;
92412+ path.mnt = (struct vfsmount *)u_mnt;
92413+ get_fs_root(current->fs, &currentroot);
92414+ if (path_is_under(&path, &currentroot))
92415+ ret = 1;
92416+ path_put(&currentroot);
92417+
92418+ return ret;
92419+}
92420+#endif
92421+
92422+int
92423+gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
92424+{
92425+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
92426+ if (!grsec_enable_chroot_fchdir)
92427+ return 1;
92428+
92429+ if (!proc_is_chrooted(current))
92430+ return 1;
92431+ else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
92432+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
92433+ return 0;
92434+ }
92435+#endif
92436+ return 1;
92437+}
92438+
92439+int
92440+gr_chroot_fhandle(void)
92441+{
92442+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
92443+ if (!grsec_enable_chroot_fchdir)
92444+ return 1;
92445+
92446+ if (!proc_is_chrooted(current))
92447+ return 1;
92448+ else {
92449+ gr_log_noargs(GR_DONT_AUDIT, GR_CHROOT_FHANDLE_MSG);
92450+ return 0;
92451+ }
92452+#endif
92453+ return 1;
92454+}
92455+
92456+int
92457+gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
92458+ const u64 shm_createtime)
92459+{
92460+#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
92461+ struct task_struct *p;
92462+
92463+ if (unlikely(!grsec_enable_chroot_shmat))
92464+ return 1;
92465+
92466+ if (likely(!proc_is_chrooted(current)))
92467+ return 1;
92468+
92469+ rcu_read_lock();
92470+ read_lock(&tasklist_lock);
92471+
92472+ if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
92473+ if (time_before_eq64(p->start_time, shm_createtime)) {
92474+ if (have_same_root(current, p)) {
92475+ goto allow;
92476+ } else {
92477+ read_unlock(&tasklist_lock);
92478+ rcu_read_unlock();
92479+ gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
92480+ return 0;
92481+ }
92482+ }
92483+ /* creator exited, pid reuse, fall through to next check */
92484+ }
92485+ if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
92486+ if (unlikely(!have_same_root(current, p))) {
92487+ read_unlock(&tasklist_lock);
92488+ rcu_read_unlock();
92489+ gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
92490+ return 0;
92491+ }
92492+ }
92493+
92494+allow:
92495+ read_unlock(&tasklist_lock);
92496+ rcu_read_unlock();
92497+#endif
92498+ return 1;
92499+}
92500+
92501+void
92502+gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
92503+{
92504+#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
92505+ if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
92506+ gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
92507+#endif
92508+ return;
92509+}
92510+
92511+int
92512+gr_handle_chroot_mknod(const struct dentry *dentry,
92513+ const struct vfsmount *mnt, const int mode)
92514+{
92515+#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
92516+ if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
92517+ proc_is_chrooted(current)) {
92518+ gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
92519+ return -EPERM;
92520+ }
92521+#endif
92522+ return 0;
92523+}
92524+
92525+int
92526+gr_handle_chroot_mount(const struct dentry *dentry,
92527+ const struct vfsmount *mnt, const char *dev_name)
92528+{
92529+#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
92530+ if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
92531+ gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
92532+ return -EPERM;
92533+ }
92534+#endif
92535+ return 0;
92536+}
92537+
92538+int
92539+gr_handle_chroot_pivot(void)
92540+{
92541+#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
92542+ if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
92543+ gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
92544+ return -EPERM;
92545+ }
92546+#endif
92547+ return 0;
92548+}
92549+
92550+int
92551+gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
92552+{
92553+#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
92554+ if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
92555+ !gr_is_outside_chroot(dentry, mnt)) {
92556+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
92557+ return -EPERM;
92558+ }
92559+#endif
92560+ return 0;
92561+}
92562+
92563+extern const char *captab_log[];
92564+extern int captab_log_entries;
92565+
92566+int
92567+gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
92568+{
92569+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92570+ if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
92571+ kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
92572+ if (cap_raised(chroot_caps, cap)) {
92573+ if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
92574+ gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
92575+ }
92576+ return 0;
92577+ }
92578+ }
92579+#endif
92580+ return 1;
92581+}
92582+
92583+int
92584+gr_chroot_is_capable(const int cap)
92585+{
92586+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92587+ return gr_task_chroot_is_capable(current, current_cred(), cap);
92588+#endif
92589+ return 1;
92590+}
92591+
92592+int
92593+gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
92594+{
92595+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92596+ if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
92597+ kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
92598+ if (cap_raised(chroot_caps, cap)) {
92599+ return 0;
92600+ }
92601+ }
92602+#endif
92603+ return 1;
92604+}
92605+
92606+int
92607+gr_chroot_is_capable_nolog(const int cap)
92608+{
92609+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92610+ return gr_task_chroot_is_capable_nolog(current, cap);
92611+#endif
92612+ return 1;
92613+}
92614+
92615+int
92616+gr_handle_chroot_sysctl(const int op)
92617+{
92618+#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
92619+ if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
92620+ proc_is_chrooted(current))
92621+ return -EACCES;
92622+#endif
92623+ return 0;
92624+}
92625+
92626+void
92627+gr_handle_chroot_chdir(const struct path *path)
92628+{
92629+#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
92630+ if (grsec_enable_chroot_chdir)
92631+ set_fs_pwd(current->fs, path);
92632+#endif
92633+ return;
92634+}
92635+
92636+int
92637+gr_handle_chroot_chmod(const struct dentry *dentry,
92638+ const struct vfsmount *mnt, const int mode)
92639+{
92640+#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
92641+ /* allow chmod +s on directories, but not files */
92642+ if (grsec_enable_chroot_chmod && !d_is_dir(dentry) &&
92643+ ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
92644+ proc_is_chrooted(current)) {
92645+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
92646+ return -EPERM;
92647+ }
92648+#endif
92649+ return 0;
92650+}
92651diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
92652new file mode 100644
92653index 0000000..e723c08
92654--- /dev/null
92655+++ b/grsecurity/grsec_disabled.c
92656@@ -0,0 +1,445 @@
92657+#include <linux/kernel.h>
92658+#include <linux/module.h>
92659+#include <linux/sched.h>
92660+#include <linux/file.h>
92661+#include <linux/fs.h>
92662+#include <linux/kdev_t.h>
92663+#include <linux/net.h>
92664+#include <linux/in.h>
92665+#include <linux/ip.h>
92666+#include <linux/skbuff.h>
92667+#include <linux/sysctl.h>
92668+
92669+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
92670+void
92671+pax_set_initial_flags(struct linux_binprm *bprm)
92672+{
92673+ return;
92674+}
92675+#endif
92676+
92677+#ifdef CONFIG_SYSCTL
92678+__u32
92679+gr_handle_sysctl(const struct ctl_table * table, const int op)
92680+{
92681+ return 0;
92682+}
92683+#endif
92684+
92685+#ifdef CONFIG_TASKSTATS
92686+int gr_is_taskstats_denied(int pid)
92687+{
92688+ return 0;
92689+}
92690+#endif
92691+
92692+int
92693+gr_acl_is_enabled(void)
92694+{
92695+ return 0;
92696+}
92697+
92698+int
92699+gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap)
92700+{
92701+ return 0;
92702+}
92703+
92704+void
92705+gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
92706+{
92707+ return;
92708+}
92709+
92710+int
92711+gr_handle_rawio(const struct inode *inode)
92712+{
92713+ return 0;
92714+}
92715+
92716+void
92717+gr_acl_handle_psacct(struct task_struct *task, const long code)
92718+{
92719+ return;
92720+}
92721+
92722+int
92723+gr_handle_ptrace(struct task_struct *task, const long request)
92724+{
92725+ return 0;
92726+}
92727+
92728+int
92729+gr_handle_proc_ptrace(struct task_struct *task)
92730+{
92731+ return 0;
92732+}
92733+
92734+int
92735+gr_set_acls(const int type)
92736+{
92737+ return 0;
92738+}
92739+
92740+int
92741+gr_check_hidden_task(const struct task_struct *tsk)
92742+{
92743+ return 0;
92744+}
92745+
92746+int
92747+gr_check_protected_task(const struct task_struct *task)
92748+{
92749+ return 0;
92750+}
92751+
92752+int
92753+gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
92754+{
92755+ return 0;
92756+}
92757+
92758+void
92759+gr_copy_label(struct task_struct *tsk)
92760+{
92761+ return;
92762+}
92763+
92764+void
92765+gr_set_pax_flags(struct task_struct *task)
92766+{
92767+ return;
92768+}
92769+
92770+int
92771+gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
92772+ const int unsafe_share)
92773+{
92774+ return 0;
92775+}
92776+
92777+void
92778+gr_handle_delete(const u64 ino, const dev_t dev)
92779+{
92780+ return;
92781+}
92782+
92783+void
92784+gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
92785+{
92786+ return;
92787+}
92788+
92789+void
92790+gr_handle_crash(struct task_struct *task, const int sig)
92791+{
92792+ return;
92793+}
92794+
92795+int
92796+gr_check_crash_exec(const struct file *filp)
92797+{
92798+ return 0;
92799+}
92800+
92801+int
92802+gr_check_crash_uid(const kuid_t uid)
92803+{
92804+ return 0;
92805+}
92806+
92807+void
92808+gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
92809+ struct dentry *old_dentry,
92810+ struct dentry *new_dentry,
92811+ struct vfsmount *mnt, const __u8 replace, unsigned int flags)
92812+{
92813+ return;
92814+}
92815+
92816+int
92817+gr_search_socket(const int family, const int type, const int protocol)
92818+{
92819+ return 1;
92820+}
92821+
92822+int
92823+gr_search_connectbind(const int mode, const struct socket *sock,
92824+ const struct sockaddr_in *addr)
92825+{
92826+ return 0;
92827+}
92828+
92829+void
92830+gr_handle_alertkill(struct task_struct *task)
92831+{
92832+ return;
92833+}
92834+
92835+__u32
92836+gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
92837+{
92838+ return 1;
92839+}
92840+
92841+__u32
92842+gr_acl_handle_hidden_file(const struct dentry * dentry,
92843+ const struct vfsmount * mnt)
92844+{
92845+ return 1;
92846+}
92847+
92848+__u32
92849+gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
92850+ int acc_mode)
92851+{
92852+ return 1;
92853+}
92854+
92855+__u32
92856+gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
92857+{
92858+ return 1;
92859+}
92860+
92861+__u32
92862+gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
92863+{
92864+ return 1;
92865+}
92866+
92867+int
92868+gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
92869+ unsigned int *vm_flags)
92870+{
92871+ return 1;
92872+}
92873+
92874+__u32
92875+gr_acl_handle_truncate(const struct dentry * dentry,
92876+ const struct vfsmount * mnt)
92877+{
92878+ return 1;
92879+}
92880+
92881+__u32
92882+gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
92883+{
92884+ return 1;
92885+}
92886+
92887+__u32
92888+gr_acl_handle_access(const struct dentry * dentry,
92889+ const struct vfsmount * mnt, const int fmode)
92890+{
92891+ return 1;
92892+}
92893+
92894+__u32
92895+gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
92896+ umode_t *mode)
92897+{
92898+ return 1;
92899+}
92900+
92901+__u32
92902+gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
92903+{
92904+ return 1;
92905+}
92906+
92907+__u32
92908+gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
92909+{
92910+ return 1;
92911+}
92912+
92913+__u32
92914+gr_acl_handle_removexattr(const struct dentry * dentry, const struct vfsmount * mnt)
92915+{
92916+ return 1;
92917+}
92918+
92919+void
92920+grsecurity_init(void)
92921+{
92922+ return;
92923+}
92924+
92925+umode_t gr_acl_umask(void)
92926+{
92927+ return 0;
92928+}
92929+
92930+__u32
92931+gr_acl_handle_mknod(const struct dentry * new_dentry,
92932+ const struct dentry * parent_dentry,
92933+ const struct vfsmount * parent_mnt,
92934+ const int mode)
92935+{
92936+ return 1;
92937+}
92938+
92939+__u32
92940+gr_acl_handle_mkdir(const struct dentry * new_dentry,
92941+ const struct dentry * parent_dentry,
92942+ const struct vfsmount * parent_mnt)
92943+{
92944+ return 1;
92945+}
92946+
92947+__u32
92948+gr_acl_handle_symlink(const struct dentry * new_dentry,
92949+ const struct dentry * parent_dentry,
92950+ const struct vfsmount * parent_mnt, const struct filename *from)
92951+{
92952+ return 1;
92953+}
92954+
92955+__u32
92956+gr_acl_handle_link(const struct dentry * new_dentry,
92957+ const struct dentry * parent_dentry,
92958+ const struct vfsmount * parent_mnt,
92959+ const struct dentry * old_dentry,
92960+ const struct vfsmount * old_mnt, const struct filename *to)
92961+{
92962+ return 1;
92963+}
92964+
92965+int
92966+gr_acl_handle_rename(const struct dentry *new_dentry,
92967+ const struct dentry *parent_dentry,
92968+ const struct vfsmount *parent_mnt,
92969+ const struct dentry *old_dentry,
92970+ const struct inode *old_parent_inode,
92971+ const struct vfsmount *old_mnt, const struct filename *newname,
92972+ unsigned int flags)
92973+{
92974+ return 0;
92975+}
92976+
92977+int
92978+gr_acl_handle_filldir(const struct file *file, const char *name,
92979+ const int namelen, const u64 ino)
92980+{
92981+ return 1;
92982+}
92983+
92984+int
92985+gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
92986+ const u64 shm_createtime, const kuid_t cuid, const int shmid)
92987+{
92988+ return 1;
92989+}
92990+
92991+int
92992+gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
92993+{
92994+ return 0;
92995+}
92996+
92997+int
92998+gr_search_accept(const struct socket *sock)
92999+{
93000+ return 0;
93001+}
93002+
93003+int
93004+gr_search_listen(const struct socket *sock)
93005+{
93006+ return 0;
93007+}
93008+
93009+int
93010+gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
93011+{
93012+ return 0;
93013+}
93014+
93015+__u32
93016+gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
93017+{
93018+ return 1;
93019+}
93020+
93021+__u32
93022+gr_acl_handle_creat(const struct dentry * dentry,
93023+ const struct dentry * p_dentry,
93024+ const struct vfsmount * p_mnt, int open_flags, int acc_mode,
93025+ const int imode)
93026+{
93027+ return 1;
93028+}
93029+
93030+void
93031+gr_acl_handle_exit(void)
93032+{
93033+ return;
93034+}
93035+
93036+int
93037+gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
93038+{
93039+ return 1;
93040+}
93041+
93042+void
93043+gr_set_role_label(const kuid_t uid, const kgid_t gid)
93044+{
93045+ return;
93046+}
93047+
93048+int
93049+gr_acl_handle_procpidmem(const struct task_struct *task)
93050+{
93051+ return 0;
93052+}
93053+
93054+int
93055+gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
93056+{
93057+ return 0;
93058+}
93059+
93060+int
93061+gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
93062+{
93063+ return 0;
93064+}
93065+
93066+int
93067+gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
93068+{
93069+ return 0;
93070+}
93071+
93072+int
93073+gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
93074+{
93075+ return 0;
93076+}
93077+
93078+int gr_acl_enable_at_secure(void)
93079+{
93080+ return 0;
93081+}
93082+
93083+dev_t gr_get_dev_from_dentry(struct dentry *dentry)
93084+{
93085+ return d_backing_inode(dentry)->i_sb->s_dev;
93086+}
93087+
93088+u64 gr_get_ino_from_dentry(struct dentry *dentry)
93089+{
93090+ return d_backing_inode(dentry)->i_ino;
93091+}
93092+
93093+void gr_put_exec_file(struct task_struct *task)
93094+{
93095+ return;
93096+}
93097+
93098+#ifdef CONFIG_SECURITY
93099+EXPORT_SYMBOL_GPL(gr_check_user_change);
93100+EXPORT_SYMBOL_GPL(gr_check_group_change);
93101+#endif
93102diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
93103new file mode 100644
93104index 0000000..fb7531e
93105--- /dev/null
93106+++ b/grsecurity/grsec_exec.c
93107@@ -0,0 +1,189 @@
93108+#include <linux/kernel.h>
93109+#include <linux/sched.h>
93110+#include <linux/file.h>
93111+#include <linux/binfmts.h>
93112+#include <linux/fs.h>
93113+#include <linux/types.h>
93114+#include <linux/grdefs.h>
93115+#include <linux/grsecurity.h>
93116+#include <linux/grinternal.h>
93117+#include <linux/capability.h>
93118+#include <linux/module.h>
93119+#include <linux/compat.h>
93120+
93121+#include <asm/uaccess.h>
93122+
93123+#ifdef CONFIG_GRKERNSEC_EXECLOG
93124+static char gr_exec_arg_buf[132];
93125+static DEFINE_MUTEX(gr_exec_arg_mutex);
93126+#endif
93127+
93128+struct user_arg_ptr {
93129+#ifdef CONFIG_COMPAT
93130+ bool is_compat;
93131+#endif
93132+ union {
93133+ const char __user *const __user *native;
93134+#ifdef CONFIG_COMPAT
93135+ const compat_uptr_t __user *compat;
93136+#endif
93137+ } ptr;
93138+};
93139+
93140+extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
93141+
93142+void
93143+gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
93144+{
93145+#ifdef CONFIG_GRKERNSEC_EXECLOG
93146+ char *grarg = gr_exec_arg_buf;
93147+ unsigned int i, x, execlen = 0;
93148+ char c;
93149+
93150+ if (!((grsec_enable_execlog && grsec_enable_group &&
93151+ in_group_p(grsec_audit_gid))
93152+ || (grsec_enable_execlog && !grsec_enable_group)))
93153+ return;
93154+
93155+ mutex_lock(&gr_exec_arg_mutex);
93156+ memset(grarg, 0, sizeof(gr_exec_arg_buf));
93157+
93158+ for (i = 0; i < bprm->argc && execlen < 128; i++) {
93159+ const char __user *p;
93160+ unsigned int len;
93161+
93162+ p = get_user_arg_ptr(argv, i);
93163+ if (IS_ERR(p))
93164+ goto log;
93165+
93166+ len = strnlen_user(p, 128 - execlen);
93167+ if (len > 128 - execlen)
93168+ len = 128 - execlen;
93169+ else if (len > 0)
93170+ len--;
93171+ if (copy_from_user(grarg + execlen, p, len))
93172+ goto log;
93173+
93174+ /* rewrite unprintable characters */
93175+ for (x = 0; x < len; x++) {
93176+ c = *(grarg + execlen + x);
93177+ if (c < 32 || c > 126)
93178+ *(grarg + execlen + x) = ' ';
93179+ }
93180+
93181+ execlen += len;
93182+ *(grarg + execlen) = ' ';
93183+ *(grarg + execlen + 1) = '\0';
93184+ execlen++;
93185+ }
93186+
93187+ log:
93188+ gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
93189+ bprm->file->f_path.mnt, grarg);
93190+ mutex_unlock(&gr_exec_arg_mutex);
93191+#endif
93192+ return;
93193+}
93194+
93195+#ifdef CONFIG_GRKERNSEC
93196+extern int gr_acl_is_capable(const int cap);
93197+extern int gr_acl_is_capable_nolog(const int cap);
93198+extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
93199+extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
93200+extern int gr_chroot_is_capable(const int cap);
93201+extern int gr_chroot_is_capable_nolog(const int cap);
93202+extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
93203+extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
93204+#endif
93205+
93206+const char *captab_log[] = {
93207+ "CAP_CHOWN",
93208+ "CAP_DAC_OVERRIDE",
93209+ "CAP_DAC_READ_SEARCH",
93210+ "CAP_FOWNER",
93211+ "CAP_FSETID",
93212+ "CAP_KILL",
93213+ "CAP_SETGID",
93214+ "CAP_SETUID",
93215+ "CAP_SETPCAP",
93216+ "CAP_LINUX_IMMUTABLE",
93217+ "CAP_NET_BIND_SERVICE",
93218+ "CAP_NET_BROADCAST",
93219+ "CAP_NET_ADMIN",
93220+ "CAP_NET_RAW",
93221+ "CAP_IPC_LOCK",
93222+ "CAP_IPC_OWNER",
93223+ "CAP_SYS_MODULE",
93224+ "CAP_SYS_RAWIO",
93225+ "CAP_SYS_CHROOT",
93226+ "CAP_SYS_PTRACE",
93227+ "CAP_SYS_PACCT",
93228+ "CAP_SYS_ADMIN",
93229+ "CAP_SYS_BOOT",
93230+ "CAP_SYS_NICE",
93231+ "CAP_SYS_RESOURCE",
93232+ "CAP_SYS_TIME",
93233+ "CAP_SYS_TTY_CONFIG",
93234+ "CAP_MKNOD",
93235+ "CAP_LEASE",
93236+ "CAP_AUDIT_WRITE",
93237+ "CAP_AUDIT_CONTROL",
93238+ "CAP_SETFCAP",
93239+ "CAP_MAC_OVERRIDE",
93240+ "CAP_MAC_ADMIN",
93241+ "CAP_SYSLOG",
93242+ "CAP_WAKE_ALARM",
93243+ "CAP_BLOCK_SUSPEND",
93244+ "CAP_AUDIT_READ"
93245+};
93246+
93247+int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
93248+
93249+int gr_is_capable(const int cap)
93250+{
93251+#ifdef CONFIG_GRKERNSEC
93252+ if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
93253+ return 1;
93254+ return 0;
93255+#else
93256+ return 1;
93257+#endif
93258+}
93259+
93260+int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
93261+{
93262+#ifdef CONFIG_GRKERNSEC
93263+ if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
93264+ return 1;
93265+ return 0;
93266+#else
93267+ return 1;
93268+#endif
93269+}
93270+
93271+int gr_is_capable_nolog(const int cap)
93272+{
93273+#ifdef CONFIG_GRKERNSEC
93274+ if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
93275+ return 1;
93276+ return 0;
93277+#else
93278+ return 1;
93279+#endif
93280+}
93281+
93282+int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
93283+{
93284+#ifdef CONFIG_GRKERNSEC
93285+ if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
93286+ return 1;
93287+ return 0;
93288+#else
93289+ return 1;
93290+#endif
93291+}
93292+
93293+EXPORT_SYMBOL_GPL(gr_is_capable);
93294+EXPORT_SYMBOL_GPL(gr_is_capable_nolog);
93295+EXPORT_SYMBOL_GPL(gr_task_is_capable);
93296+EXPORT_SYMBOL_GPL(gr_task_is_capable_nolog);
93297diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
93298new file mode 100644
93299index 0000000..cdec49b
93300--- /dev/null
93301+++ b/grsecurity/grsec_fifo.c
93302@@ -0,0 +1,26 @@
93303+#include <linux/kernel.h>
93304+#include <linux/sched.h>
93305+#include <linux/fs.h>
93306+#include <linux/file.h>
93307+#include <linux/grinternal.h>
93308+
93309+int
93310+gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
93311+ const struct dentry *dir, const int flag, const int acc_mode)
93312+{
93313+#ifdef CONFIG_GRKERNSEC_FIFO
93314+ const struct cred *cred = current_cred();
93315+ struct inode *inode = d_backing_inode(dentry);
93316+ struct inode *dir_inode = d_backing_inode(dir);
93317+
93318+ if (grsec_enable_fifo && S_ISFIFO(inode->i_mode) &&
93319+ !(flag & O_EXCL) && (dir_inode->i_mode & S_ISVTX) &&
93320+ !uid_eq(inode->i_uid, dir_inode->i_uid) &&
93321+ !uid_eq(cred->fsuid, inode->i_uid)) {
93322+ if (!inode_permission(inode, acc_mode))
93323+ gr_log_fs_int2(GR_DONT_AUDIT, GR_FIFO_MSG, dentry, mnt, GR_GLOBAL_UID(inode->i_uid), GR_GLOBAL_GID(inode->i_gid));
93324+ return -EACCES;
93325+ }
93326+#endif
93327+ return 0;
93328+}
93329diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
93330new file mode 100644
93331index 0000000..8ca18bf
93332--- /dev/null
93333+++ b/grsecurity/grsec_fork.c
93334@@ -0,0 +1,23 @@
93335+#include <linux/kernel.h>
93336+#include <linux/sched.h>
93337+#include <linux/grsecurity.h>
93338+#include <linux/grinternal.h>
93339+#include <linux/errno.h>
93340+
93341+void
93342+gr_log_forkfail(const int retval)
93343+{
93344+#ifdef CONFIG_GRKERNSEC_FORKFAIL
93345+ if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
93346+ switch (retval) {
93347+ case -EAGAIN:
93348+ gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
93349+ break;
93350+ case -ENOMEM:
93351+ gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
93352+ break;
93353+ }
93354+ }
93355+#endif
93356+ return;
93357+}
93358diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
93359new file mode 100644
93360index 0000000..a364c58
93361--- /dev/null
93362+++ b/grsecurity/grsec_init.c
93363@@ -0,0 +1,290 @@
93364+#include <linux/kernel.h>
93365+#include <linux/sched.h>
93366+#include <linux/mm.h>
93367+#include <linux/gracl.h>
93368+#include <linux/slab.h>
93369+#include <linux/vmalloc.h>
93370+#include <linux/percpu.h>
93371+#include <linux/module.h>
93372+
93373+int grsec_enable_ptrace_readexec __read_only;
93374+int grsec_enable_setxid __read_only;
93375+int grsec_enable_symlinkown __read_only;
93376+kgid_t grsec_symlinkown_gid __read_only;
93377+int grsec_enable_brute __read_only;
93378+int grsec_enable_link __read_only;
93379+int grsec_enable_dmesg __read_only;
93380+int grsec_enable_harden_ptrace __read_only;
93381+int grsec_enable_harden_ipc __read_only;
93382+int grsec_enable_fifo __read_only;
93383+int grsec_enable_execlog __read_only;
93384+int grsec_enable_signal __read_only;
93385+int grsec_enable_forkfail __read_only;
93386+int grsec_enable_audit_ptrace __read_only;
93387+int grsec_enable_time __read_only;
93388+int grsec_enable_group __read_only;
93389+kgid_t grsec_audit_gid __read_only;
93390+int grsec_enable_chdir __read_only;
93391+int grsec_enable_mount __read_only;
93392+int grsec_enable_rofs __read_only;
93393+int grsec_deny_new_usb __read_only;
93394+int grsec_enable_chroot_findtask __read_only;
93395+int grsec_enable_chroot_mount __read_only;
93396+int grsec_enable_chroot_shmat __read_only;
93397+int grsec_enable_chroot_fchdir __read_only;
93398+int grsec_enable_chroot_double __read_only;
93399+int grsec_enable_chroot_pivot __read_only;
93400+int grsec_enable_chroot_chdir __read_only;
93401+int grsec_enable_chroot_chmod __read_only;
93402+int grsec_enable_chroot_mknod __read_only;
93403+int grsec_enable_chroot_nice __read_only;
93404+int grsec_enable_chroot_execlog __read_only;
93405+int grsec_enable_chroot_caps __read_only;
93406+int grsec_enable_chroot_rename __read_only;
93407+int grsec_enable_chroot_sysctl __read_only;
93408+int grsec_enable_chroot_unix __read_only;
93409+int grsec_enable_tpe __read_only;
93410+kgid_t grsec_tpe_gid __read_only;
93411+int grsec_enable_blackhole __read_only;
93412+#ifdef CONFIG_IPV6_MODULE
93413+EXPORT_SYMBOL_GPL(grsec_enable_blackhole);
93414+#endif
93415+int grsec_lastack_retries __read_only;
93416+int grsec_enable_tpe_all __read_only;
93417+int grsec_enable_tpe_invert __read_only;
93418+int grsec_enable_socket_all __read_only;
93419+kgid_t grsec_socket_all_gid __read_only;
93420+int grsec_enable_socket_client __read_only;
93421+kgid_t grsec_socket_client_gid __read_only;
93422+int grsec_enable_socket_server __read_only;
93423+kgid_t grsec_socket_server_gid __read_only;
93424+int grsec_resource_logging __read_only;
93425+int grsec_disable_privio __read_only;
93426+int grsec_enable_log_rwxmaps __read_only;
93427+int grsec_lock __read_only;
93428+
93429+DEFINE_SPINLOCK(grsec_alert_lock);
93430+unsigned long grsec_alert_wtime = 0;
93431+unsigned long grsec_alert_fyet = 0;
93432+
93433+DEFINE_SPINLOCK(grsec_audit_lock);
93434+
93435+DEFINE_RWLOCK(grsec_exec_file_lock);
93436+
93437+char *gr_shared_page[4];
93438+
93439+char *gr_alert_log_fmt;
93440+char *gr_audit_log_fmt;
93441+char *gr_alert_log_buf;
93442+char *gr_audit_log_buf;
93443+
93444+extern struct gr_arg *gr_usermode;
93445+extern unsigned char *gr_system_salt;
93446+extern unsigned char *gr_system_sum;
93447+
93448+void __init
93449+grsecurity_init(void)
93450+{
93451+ int j;
93452+ /* create the per-cpu shared pages */
93453+
93454+#ifdef CONFIG_X86
93455+ memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
93456+#endif
93457+
93458+ for (j = 0; j < 4; j++) {
93459+ gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
93460+ if (gr_shared_page[j] == NULL) {
93461+ panic("Unable to allocate grsecurity shared page");
93462+ return;
93463+ }
93464+ }
93465+
93466+ /* allocate log buffers */
93467+ gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
93468+ if (!gr_alert_log_fmt) {
93469+ panic("Unable to allocate grsecurity alert log format buffer");
93470+ return;
93471+ }
93472+ gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
93473+ if (!gr_audit_log_fmt) {
93474+ panic("Unable to allocate grsecurity audit log format buffer");
93475+ return;
93476+ }
93477+ gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
93478+ if (!gr_alert_log_buf) {
93479+ panic("Unable to allocate grsecurity alert log buffer");
93480+ return;
93481+ }
93482+ gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
93483+ if (!gr_audit_log_buf) {
93484+ panic("Unable to allocate grsecurity audit log buffer");
93485+ return;
93486+ }
93487+
93488+ /* allocate memory for authentication structure */
93489+ gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
93490+ gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
93491+ gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
93492+
93493+ if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
93494+ panic("Unable to allocate grsecurity authentication structure");
93495+ return;
93496+ }
93497+
93498+#ifdef CONFIG_GRKERNSEC_IO
93499+#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
93500+ grsec_disable_privio = 1;
93501+#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
93502+ grsec_disable_privio = 1;
93503+#else
93504+ grsec_disable_privio = 0;
93505+#endif
93506+#endif
93507+
93508+#ifdef CONFIG_GRKERNSEC_TPE_INVERT
93509+ /* for backward compatibility, tpe_invert always defaults to on if
93510+ enabled in the kernel
93511+ */
93512+ grsec_enable_tpe_invert = 1;
93513+#endif
93514+
93515+#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
93516+#ifndef CONFIG_GRKERNSEC_SYSCTL
93517+ grsec_lock = 1;
93518+#endif
93519+
93520+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
93521+ grsec_enable_log_rwxmaps = 1;
93522+#endif
93523+#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
93524+ grsec_enable_group = 1;
93525+ grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
93526+#endif
93527+#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
93528+ grsec_enable_ptrace_readexec = 1;
93529+#endif
93530+#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
93531+ grsec_enable_chdir = 1;
93532+#endif
93533+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
93534+ grsec_enable_harden_ptrace = 1;
93535+#endif
93536+#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
93537+ grsec_enable_harden_ipc = 1;
93538+#endif
93539+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
93540+ grsec_enable_mount = 1;
93541+#endif
93542+#ifdef CONFIG_GRKERNSEC_LINK
93543+ grsec_enable_link = 1;
93544+#endif
93545+#ifdef CONFIG_GRKERNSEC_BRUTE
93546+ grsec_enable_brute = 1;
93547+#endif
93548+#ifdef CONFIG_GRKERNSEC_DMESG
93549+ grsec_enable_dmesg = 1;
93550+#endif
93551+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93552+ grsec_enable_blackhole = 1;
93553+ grsec_lastack_retries = 4;
93554+#endif
93555+#ifdef CONFIG_GRKERNSEC_FIFO
93556+ grsec_enable_fifo = 1;
93557+#endif
93558+#ifdef CONFIG_GRKERNSEC_EXECLOG
93559+ grsec_enable_execlog = 1;
93560+#endif
93561+#ifdef CONFIG_GRKERNSEC_SETXID
93562+ grsec_enable_setxid = 1;
93563+#endif
93564+#ifdef CONFIG_GRKERNSEC_SIGNAL
93565+ grsec_enable_signal = 1;
93566+#endif
93567+#ifdef CONFIG_GRKERNSEC_FORKFAIL
93568+ grsec_enable_forkfail = 1;
93569+#endif
93570+#ifdef CONFIG_GRKERNSEC_TIME
93571+ grsec_enable_time = 1;
93572+#endif
93573+#ifdef CONFIG_GRKERNSEC_RESLOG
93574+ grsec_resource_logging = 1;
93575+#endif
93576+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
93577+ grsec_enable_chroot_findtask = 1;
93578+#endif
93579+#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
93580+ grsec_enable_chroot_unix = 1;
93581+#endif
93582+#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
93583+ grsec_enable_chroot_mount = 1;
93584+#endif
93585+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
93586+ grsec_enable_chroot_fchdir = 1;
93587+#endif
93588+#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
93589+ grsec_enable_chroot_shmat = 1;
93590+#endif
93591+#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
93592+ grsec_enable_audit_ptrace = 1;
93593+#endif
93594+#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
93595+ grsec_enable_chroot_double = 1;
93596+#endif
93597+#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
93598+ grsec_enable_chroot_pivot = 1;
93599+#endif
93600+#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
93601+ grsec_enable_chroot_chdir = 1;
93602+#endif
93603+#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
93604+ grsec_enable_chroot_chmod = 1;
93605+#endif
93606+#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
93607+ grsec_enable_chroot_mknod = 1;
93608+#endif
93609+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
93610+ grsec_enable_chroot_nice = 1;
93611+#endif
93612+#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
93613+ grsec_enable_chroot_execlog = 1;
93614+#endif
93615+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
93616+ grsec_enable_chroot_caps = 1;
93617+#endif
93618+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
93619+ grsec_enable_chroot_rename = 1;
93620+#endif
93621+#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
93622+ grsec_enable_chroot_sysctl = 1;
93623+#endif
93624+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
93625+ grsec_enable_symlinkown = 1;
93626+ grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
93627+#endif
93628+#ifdef CONFIG_GRKERNSEC_TPE
93629+ grsec_enable_tpe = 1;
93630+ grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
93631+#ifdef CONFIG_GRKERNSEC_TPE_ALL
93632+ grsec_enable_tpe_all = 1;
93633+#endif
93634+#endif
93635+#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
93636+ grsec_enable_socket_all = 1;
93637+ grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
93638+#endif
93639+#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
93640+ grsec_enable_socket_client = 1;
93641+ grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
93642+#endif
93643+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
93644+ grsec_enable_socket_server = 1;
93645+ grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
93646+#endif
93647+#endif
93648+#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
93649+ grsec_deny_new_usb = 1;
93650+#endif
93651+
93652+ return;
93653+}
93654diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
93655new file mode 100644
93656index 0000000..1773300
93657--- /dev/null
93658+++ b/grsecurity/grsec_ipc.c
93659@@ -0,0 +1,48 @@
93660+#include <linux/kernel.h>
93661+#include <linux/mm.h>
93662+#include <linux/sched.h>
93663+#include <linux/file.h>
93664+#include <linux/ipc.h>
93665+#include <linux/ipc_namespace.h>
93666+#include <linux/grsecurity.h>
93667+#include <linux/grinternal.h>
93668+
93669+int
93670+gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
93671+{
93672+#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
93673+ int write;
93674+ int orig_granted_mode;
93675+ kuid_t euid;
93676+ kgid_t egid;
93677+
93678+ if (!grsec_enable_harden_ipc)
93679+ return 1;
93680+
93681+ euid = current_euid();
93682+ egid = current_egid();
93683+
93684+ write = requested_mode & 00002;
93685+ orig_granted_mode = ipcp->mode;
93686+
93687+ if (uid_eq(euid, ipcp->cuid) || uid_eq(euid, ipcp->uid))
93688+ orig_granted_mode >>= 6;
93689+ else {
93690+ /* if likely wrong permissions, lock to user */
93691+ if (orig_granted_mode & 0007)
93692+ orig_granted_mode = 0;
93693+ /* otherwise do a egid-only check */
93694+ else if (gid_eq(egid, ipcp->cgid) || gid_eq(egid, ipcp->gid))
93695+ orig_granted_mode >>= 3;
93696+ /* otherwise, no access */
93697+ else
93698+ orig_granted_mode = 0;
93699+ }
93700+ if (!(requested_mode & ~granted_mode & 0007) && (requested_mode & ~orig_granted_mode & 0007) &&
93701+ !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
93702+ gr_log_str_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", GR_GLOBAL_UID(ipcp->cuid));
93703+ return 0;
93704+ }
93705+#endif
93706+ return 1;
93707+}
93708diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
93709new file mode 100644
93710index 0000000..84c44a0
93711--- /dev/null
93712+++ b/grsecurity/grsec_link.c
93713@@ -0,0 +1,65 @@
93714+#include <linux/kernel.h>
93715+#include <linux/sched.h>
93716+#include <linux/fs.h>
93717+#include <linux/file.h>
93718+#include <linux/grinternal.h>
93719+
93720+int gr_get_symlinkown_enabled(void)
93721+{
93722+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
93723+ if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid))
93724+ return 1;
93725+#endif
93726+ return 0;
93727+}
93728+
93729+int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
93730+{
93731+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
93732+ const struct inode *link_inode = d_backing_inode(link->dentry);
93733+
93734+ if (target && !uid_eq(link_inode->i_uid, target->i_uid)) {
93735+ gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, GR_GLOBAL_UID(link_inode->i_uid), GR_GLOBAL_UID(target->i_uid));
93736+ return 1;
93737+ }
93738+#endif
93739+ return 0;
93740+}
93741+
93742+int
93743+gr_handle_follow_link(const struct dentry *dentry, const struct vfsmount *mnt)
93744+{
93745+#ifdef CONFIG_GRKERNSEC_LINK
93746+ struct inode *inode = d_backing_inode(dentry);
93747+ struct inode *parent = d_backing_inode(dentry->d_parent);
93748+ const struct cred *cred = current_cred();
93749+
93750+ if (grsec_enable_link && d_is_symlink(dentry) &&
93751+ (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
93752+ (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
93753+ gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, GR_GLOBAL_UID(inode->i_uid), GR_GLOBAL_GID(inode->i_gid));
93754+ return -EACCES;
93755+ }
93756+#endif
93757+ return 0;
93758+}
93759+
93760+int
93761+gr_handle_hardlink(const struct dentry *dentry,
93762+ const struct vfsmount *mnt,
93763+ const struct filename *to)
93764+{
93765+#ifdef CONFIG_GRKERNSEC_LINK
93766+ struct inode *inode = d_backing_inode(dentry);
93767+ const struct cred *cred = current_cred();
93768+
93769+ if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
93770+ (!d_is_reg(dentry) || is_privileged_binary(dentry) ||
93771+ (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
93772+ !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
93773+ gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, GR_GLOBAL_UID(inode->i_uid), GR_GLOBAL_GID(inode->i_gid), to->name);
93774+ return -EPERM;
93775+ }
93776+#endif
93777+ return 0;
93778+}
93779diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
93780new file mode 100644
93781index 0000000..a24b338
93782--- /dev/null
93783+++ b/grsecurity/grsec_log.c
93784@@ -0,0 +1,340 @@
93785+#include <linux/kernel.h>
93786+#include <linux/sched.h>
93787+#include <linux/file.h>
93788+#include <linux/tty.h>
93789+#include <linux/fs.h>
93790+#include <linux/mm.h>
93791+#include <linux/grinternal.h>
93792+
93793+#ifdef CONFIG_TREE_PREEMPT_RCU
93794+#define DISABLE_PREEMPT() preempt_disable()
93795+#define ENABLE_PREEMPT() preempt_enable()
93796+#else
93797+#define DISABLE_PREEMPT()
93798+#define ENABLE_PREEMPT()
93799+#endif
93800+
93801+#define BEGIN_LOCKS(x) \
93802+ DISABLE_PREEMPT(); \
93803+ rcu_read_lock(); \
93804+ read_lock(&tasklist_lock); \
93805+ read_lock(&grsec_exec_file_lock); \
93806+ if (x != GR_DO_AUDIT) \
93807+ spin_lock(&grsec_alert_lock); \
93808+ else \
93809+ spin_lock(&grsec_audit_lock)
93810+
93811+#define END_LOCKS(x) \
93812+ if (x != GR_DO_AUDIT) \
93813+ spin_unlock(&grsec_alert_lock); \
93814+ else \
93815+ spin_unlock(&grsec_audit_lock); \
93816+ read_unlock(&grsec_exec_file_lock); \
93817+ read_unlock(&tasklist_lock); \
93818+ rcu_read_unlock(); \
93819+ ENABLE_PREEMPT(); \
93820+ if (x == GR_DONT_AUDIT) \
93821+ gr_handle_alertkill(current)
93822+
93823+enum {
93824+ FLOODING,
93825+ NO_FLOODING
93826+};
93827+
93828+extern char *gr_alert_log_fmt;
93829+extern char *gr_audit_log_fmt;
93830+extern char *gr_alert_log_buf;
93831+extern char *gr_audit_log_buf;
93832+
93833+static int gr_log_start(int audit)
93834+{
93835+ char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
93836+ char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
93837+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
93838+#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
93839+ unsigned long curr_secs = get_seconds();
93840+
93841+ if (audit == GR_DO_AUDIT)
93842+ goto set_fmt;
93843+
93844+ if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
93845+ grsec_alert_wtime = curr_secs;
93846+ grsec_alert_fyet = 0;
93847+ } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
93848+ && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
93849+ grsec_alert_fyet++;
93850+ } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
93851+ grsec_alert_wtime = curr_secs;
93852+ grsec_alert_fyet++;
93853+ printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
93854+ return FLOODING;
93855+ }
93856+ else return FLOODING;
93857+
93858+set_fmt:
93859+#endif
93860+ memset(buf, 0, PAGE_SIZE);
93861+ if (current->signal->curr_ip && gr_acl_is_enabled()) {
93862+ sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
93863+ snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
93864+ } else if (current->signal->curr_ip) {
93865+ sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
93866+ snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
93867+ } else if (gr_acl_is_enabled()) {
93868+ sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
93869+ snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
93870+ } else {
93871+ sprintf(fmt, "%s%s", loglevel, "grsec: ");
93872+ strcpy(buf, fmt);
93873+ }
93874+
93875+ return NO_FLOODING;
93876+}
93877+
93878+static void gr_log_middle(int audit, const char *msg, va_list ap)
93879+ __attribute__ ((format (printf, 2, 0)));
93880+
93881+static void gr_log_middle(int audit, const char *msg, va_list ap)
93882+{
93883+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
93884+ unsigned int len = strlen(buf);
93885+
93886+ vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
93887+
93888+ return;
93889+}
93890+
93891+static void gr_log_middle_varargs(int audit, const char *msg, ...)
93892+ __attribute__ ((format (printf, 2, 3)));
93893+
93894+static void gr_log_middle_varargs(int audit, const char *msg, ...)
93895+{
93896+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
93897+ unsigned int len = strlen(buf);
93898+ va_list ap;
93899+
93900+ va_start(ap, msg);
93901+ vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
93902+ va_end(ap);
93903+
93904+ return;
93905+}
93906+
93907+static void gr_log_end(int audit, int append_default)
93908+{
93909+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
93910+ if (append_default) {
93911+ struct task_struct *task = current;
93912+ struct task_struct *parent = task->real_parent;
93913+ const struct cred *cred = __task_cred(task);
93914+ const struct cred *pcred = __task_cred(parent);
93915+ unsigned int len = strlen(buf);
93916+
93917+ 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));
93918+ }
93919+
93920+ printk("%s\n", buf);
93921+
93922+ return;
93923+}
93924+
93925+void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
93926+{
93927+ int logtype;
93928+ char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
93929+ char *str1 = NULL, *str2 = NULL, *str3 = NULL;
93930+ void *voidptr = NULL;
93931+ int num1 = 0, num2 = 0;
93932+ unsigned long ulong1 = 0, ulong2 = 0;
93933+ struct dentry *dentry = NULL;
93934+ struct vfsmount *mnt = NULL;
93935+ struct file *file = NULL;
93936+ struct task_struct *task = NULL;
93937+ struct vm_area_struct *vma = NULL;
93938+ const struct cred *cred, *pcred;
93939+ va_list ap;
93940+
93941+ BEGIN_LOCKS(audit);
93942+ logtype = gr_log_start(audit);
93943+ if (logtype == FLOODING) {
93944+ END_LOCKS(audit);
93945+ return;
93946+ }
93947+ va_start(ap, argtypes);
93948+ switch (argtypes) {
93949+ case GR_TTYSNIFF:
93950+ task = va_arg(ap, struct task_struct *);
93951+ 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));
93952+ break;
93953+ case GR_SYSCTL_HIDDEN:
93954+ str1 = va_arg(ap, char *);
93955+ gr_log_middle_varargs(audit, msg, result, str1);
93956+ break;
93957+ case GR_RBAC:
93958+ dentry = va_arg(ap, struct dentry *);
93959+ mnt = va_arg(ap, struct vfsmount *);
93960+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
93961+ break;
93962+ case GR_RBAC_STR:
93963+ dentry = va_arg(ap, struct dentry *);
93964+ mnt = va_arg(ap, struct vfsmount *);
93965+ str1 = va_arg(ap, char *);
93966+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
93967+ break;
93968+ case GR_STR_RBAC:
93969+ str1 = va_arg(ap, char *);
93970+ dentry = va_arg(ap, struct dentry *);
93971+ mnt = va_arg(ap, struct vfsmount *);
93972+ gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
93973+ break;
93974+ case GR_RBAC_MODE2:
93975+ dentry = va_arg(ap, struct dentry *);
93976+ mnt = va_arg(ap, struct vfsmount *);
93977+ str1 = va_arg(ap, char *);
93978+ str2 = va_arg(ap, char *);
93979+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
93980+ break;
93981+ case GR_RBAC_MODE3:
93982+ dentry = va_arg(ap, struct dentry *);
93983+ mnt = va_arg(ap, struct vfsmount *);
93984+ str1 = va_arg(ap, char *);
93985+ str2 = va_arg(ap, char *);
93986+ str3 = va_arg(ap, char *);
93987+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
93988+ break;
93989+ case GR_FILENAME:
93990+ dentry = va_arg(ap, struct dentry *);
93991+ mnt = va_arg(ap, struct vfsmount *);
93992+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
93993+ break;
93994+ case GR_STR_FILENAME:
93995+ str1 = va_arg(ap, char *);
93996+ dentry = va_arg(ap, struct dentry *);
93997+ mnt = va_arg(ap, struct vfsmount *);
93998+ gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
93999+ break;
94000+ case GR_FILENAME_STR:
94001+ dentry = va_arg(ap, struct dentry *);
94002+ mnt = va_arg(ap, struct vfsmount *);
94003+ str1 = va_arg(ap, char *);
94004+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
94005+ break;
94006+ case GR_FILENAME_TWO_INT:
94007+ dentry = va_arg(ap, struct dentry *);
94008+ mnt = va_arg(ap, struct vfsmount *);
94009+ num1 = va_arg(ap, int);
94010+ num2 = va_arg(ap, int);
94011+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
94012+ break;
94013+ case GR_FILENAME_TWO_INT_STR:
94014+ dentry = va_arg(ap, struct dentry *);
94015+ mnt = va_arg(ap, struct vfsmount *);
94016+ num1 = va_arg(ap, int);
94017+ num2 = va_arg(ap, int);
94018+ str1 = va_arg(ap, char *);
94019+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
94020+ break;
94021+ case GR_TEXTREL:
94022+ str1 = va_arg(ap, char *);
94023+ file = va_arg(ap, struct file *);
94024+ ulong1 = va_arg(ap, unsigned long);
94025+ ulong2 = va_arg(ap, unsigned long);
94026+ gr_log_middle_varargs(audit, msg, str1, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
94027+ break;
94028+ case GR_PTRACE:
94029+ task = va_arg(ap, struct task_struct *);
94030+ 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));
94031+ break;
94032+ case GR_RESOURCE:
94033+ task = va_arg(ap, struct task_struct *);
94034+ cred = __task_cred(task);
94035+ pcred = __task_cred(task->real_parent);
94036+ ulong1 = va_arg(ap, unsigned long);
94037+ str1 = va_arg(ap, char *);
94038+ ulong2 = va_arg(ap, unsigned long);
94039+ 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));
94040+ break;
94041+ case GR_CAP:
94042+ task = va_arg(ap, struct task_struct *);
94043+ cred = __task_cred(task);
94044+ pcred = __task_cred(task->real_parent);
94045+ str1 = va_arg(ap, char *);
94046+ 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));
94047+ break;
94048+ case GR_SIG:
94049+ str1 = va_arg(ap, char *);
94050+ voidptr = va_arg(ap, void *);
94051+ gr_log_middle_varargs(audit, msg, str1, voidptr);
94052+ break;
94053+ case GR_SIG2:
94054+ task = va_arg(ap, struct task_struct *);
94055+ cred = __task_cred(task);
94056+ pcred = __task_cred(task->real_parent);
94057+ num1 = va_arg(ap, int);
94058+ 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));
94059+ break;
94060+ case GR_CRASH1:
94061+ task = va_arg(ap, struct task_struct *);
94062+ cred = __task_cred(task);
94063+ pcred = __task_cred(task->real_parent);
94064+ ulong1 = va_arg(ap, unsigned long);
94065+ 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);
94066+ break;
94067+ case GR_CRASH2:
94068+ task = va_arg(ap, struct task_struct *);
94069+ cred = __task_cred(task);
94070+ pcred = __task_cred(task->real_parent);
94071+ ulong1 = va_arg(ap, unsigned long);
94072+ 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);
94073+ break;
94074+ case GR_RWXMAP:
94075+ file = va_arg(ap, struct file *);
94076+ gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
94077+ break;
94078+ case GR_RWXMAPVMA:
94079+ vma = va_arg(ap, struct vm_area_struct *);
94080+ if (vma->vm_file)
94081+ str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
94082+ else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
94083+ str1 = "<stack>";
94084+ else if (vma->vm_start <= current->mm->brk &&
94085+ vma->vm_end >= current->mm->start_brk)
94086+ str1 = "<heap>";
94087+ else
94088+ str1 = "<anonymous mapping>";
94089+ gr_log_middle_varargs(audit, msg, str1);
94090+ break;
94091+ case GR_PSACCT:
94092+ {
94093+ unsigned int wday, cday;
94094+ __u8 whr, chr;
94095+ __u8 wmin, cmin;
94096+ __u8 wsec, csec;
94097+
94098+ task = va_arg(ap, struct task_struct *);
94099+ wday = va_arg(ap, unsigned int);
94100+ cday = va_arg(ap, unsigned int);
94101+ whr = va_arg(ap, int);
94102+ chr = va_arg(ap, int);
94103+ wmin = va_arg(ap, int);
94104+ cmin = va_arg(ap, int);
94105+ wsec = va_arg(ap, int);
94106+ csec = va_arg(ap, int);
94107+ ulong1 = va_arg(ap, unsigned long);
94108+ cred = __task_cred(task);
94109+ pcred = __task_cred(task->real_parent);
94110+
94111+ 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), 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), GR_GLOBAL_UID(pcred->uid), GR_GLOBAL_UID(pcred->euid), GR_GLOBAL_GID(pcred->gid), GR_GLOBAL_GID(pcred->egid));
94112+ }
94113+ break;
94114+ default:
94115+ gr_log_middle(audit, msg, ap);
94116+ }
94117+ va_end(ap);
94118+ // these don't need DEFAULTSECARGS printed on the end
94119+ if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
94120+ gr_log_end(audit, 0);
94121+ else
94122+ gr_log_end(audit, 1);
94123+ END_LOCKS(audit);
94124+}
94125diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
94126new file mode 100644
94127index 0000000..0e39d8c7
94128--- /dev/null
94129+++ b/grsecurity/grsec_mem.c
94130@@ -0,0 +1,48 @@
94131+#include <linux/kernel.h>
94132+#include <linux/sched.h>
94133+#include <linux/mm.h>
94134+#include <linux/mman.h>
94135+#include <linux/module.h>
94136+#include <linux/grinternal.h>
94137+
94138+void gr_handle_msr_write(void)
94139+{
94140+ gr_log_noargs(GR_DONT_AUDIT, GR_MSRWRITE_MSG);
94141+ return;
94142+}
94143+EXPORT_SYMBOL_GPL(gr_handle_msr_write);
94144+
94145+void
94146+gr_handle_ioperm(void)
94147+{
94148+ gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
94149+ return;
94150+}
94151+
94152+void
94153+gr_handle_iopl(void)
94154+{
94155+ gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
94156+ return;
94157+}
94158+
94159+void
94160+gr_handle_mem_readwrite(u64 from, u64 to)
94161+{
94162+ gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
94163+ return;
94164+}
94165+
94166+void
94167+gr_handle_vm86(void)
94168+{
94169+ gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
94170+ return;
94171+}
94172+
94173+void
94174+gr_log_badprocpid(const char *entry)
94175+{
94176+ gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
94177+ return;
94178+}
94179diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
94180new file mode 100644
94181index 0000000..fe02bf4
94182--- /dev/null
94183+++ b/grsecurity/grsec_mount.c
94184@@ -0,0 +1,65 @@
94185+#include <linux/kernel.h>
94186+#include <linux/sched.h>
94187+#include <linux/mount.h>
94188+#include <linux/major.h>
94189+#include <linux/grsecurity.h>
94190+#include <linux/grinternal.h>
94191+
94192+void
94193+gr_log_remount(const char *devname, const int retval)
94194+{
94195+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
94196+ if (grsec_enable_mount && (retval >= 0))
94197+ gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
94198+#endif
94199+ return;
94200+}
94201+
94202+void
94203+gr_log_unmount(const char *devname, const int retval)
94204+{
94205+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
94206+ if (grsec_enable_mount && (retval >= 0))
94207+ gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
94208+#endif
94209+ return;
94210+}
94211+
94212+void
94213+gr_log_mount(const char *from, struct path *to, const int retval)
94214+{
94215+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
94216+ if (grsec_enable_mount && (retval >= 0))
94217+ gr_log_str_fs(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to->dentry, to->mnt);
94218+#endif
94219+ return;
94220+}
94221+
94222+int
94223+gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
94224+{
94225+#ifdef CONFIG_GRKERNSEC_ROFS
94226+ if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
94227+ gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
94228+ return -EPERM;
94229+ } else
94230+ return 0;
94231+#endif
94232+ return 0;
94233+}
94234+
94235+int
94236+gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
94237+{
94238+#ifdef CONFIG_GRKERNSEC_ROFS
94239+ struct inode *inode = d_backing_inode(dentry);
94240+
94241+ if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
94242+ inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR))) {
94243+ gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
94244+ return -EPERM;
94245+ } else
94246+ return 0;
94247+#endif
94248+ return 0;
94249+}
94250diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
94251new file mode 100644
94252index 0000000..2ad7b96
94253--- /dev/null
94254+++ b/grsecurity/grsec_pax.c
94255@@ -0,0 +1,47 @@
94256+#include <linux/kernel.h>
94257+#include <linux/sched.h>
94258+#include <linux/mm.h>
94259+#include <linux/file.h>
94260+#include <linux/grinternal.h>
94261+#include <linux/grsecurity.h>
94262+
94263+void
94264+gr_log_textrel(struct vm_area_struct * vma, bool is_textrel_rw)
94265+{
94266+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94267+ if (grsec_enable_log_rwxmaps)
94268+ gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG,
94269+ is_textrel_rw ? "executable to writable" : "writable to executable",
94270+ vma->vm_file, vma->vm_start, vma->vm_pgoff);
94271+#endif
94272+ return;
94273+}
94274+
94275+void gr_log_ptgnustack(struct file *file)
94276+{
94277+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94278+ if (grsec_enable_log_rwxmaps)
94279+ gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
94280+#endif
94281+ return;
94282+}
94283+
94284+void
94285+gr_log_rwxmmap(struct file *file)
94286+{
94287+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94288+ if (grsec_enable_log_rwxmaps)
94289+ gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
94290+#endif
94291+ return;
94292+}
94293+
94294+void
94295+gr_log_rwxmprotect(struct vm_area_struct *vma)
94296+{
94297+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94298+ if (grsec_enable_log_rwxmaps)
94299+ gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
94300+#endif
94301+ return;
94302+}
94303diff --git a/grsecurity/grsec_proc.c b/grsecurity/grsec_proc.c
94304new file mode 100644
94305index 0000000..2005a3a
94306--- /dev/null
94307+++ b/grsecurity/grsec_proc.c
94308@@ -0,0 +1,20 @@
94309+#include <linux/kernel.h>
94310+#include <linux/sched.h>
94311+#include <linux/grsecurity.h>
94312+#include <linux/grinternal.h>
94313+
94314+int gr_proc_is_restricted(void)
94315+{
94316+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
94317+ const struct cred *cred = current_cred();
94318+#endif
94319+
94320+#ifdef CONFIG_GRKERNSEC_PROC_USER
94321+ if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
94322+ return -EACCES;
94323+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
94324+ if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
94325+ return -EACCES;
94326+#endif
94327+ return 0;
94328+}
94329diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
94330new file mode 100644
94331index 0000000..304c518
94332--- /dev/null
94333+++ b/grsecurity/grsec_ptrace.c
94334@@ -0,0 +1,30 @@
94335+#include <linux/kernel.h>
94336+#include <linux/sched.h>
94337+#include <linux/grinternal.h>
94338+#include <linux/security.h>
94339+
94340+void
94341+gr_audit_ptrace(struct task_struct *task)
94342+{
94343+#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
94344+ if (grsec_enable_audit_ptrace)
94345+ gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
94346+#endif
94347+ return;
94348+}
94349+
94350+int
94351+gr_ptrace_readexec(struct file *file, int unsafe_flags)
94352+{
94353+#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
94354+ const struct dentry *dentry = file->f_path.dentry;
94355+ const struct vfsmount *mnt = file->f_path.mnt;
94356+
94357+ if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
94358+ (inode_permission(d_backing_inode(dentry), MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
94359+ gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
94360+ return -EACCES;
94361+ }
94362+#endif
94363+ return 0;
94364+}
94365diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
94366new file mode 100644
94367index 0000000..3860c7e
94368--- /dev/null
94369+++ b/grsecurity/grsec_sig.c
94370@@ -0,0 +1,236 @@
94371+#include <linux/kernel.h>
94372+#include <linux/sched.h>
94373+#include <linux/fs.h>
94374+#include <linux/delay.h>
94375+#include <linux/grsecurity.h>
94376+#include <linux/grinternal.h>
94377+#include <linux/hardirq.h>
94378+
94379+char *signames[] = {
94380+ [SIGSEGV] = "Segmentation fault",
94381+ [SIGILL] = "Illegal instruction",
94382+ [SIGABRT] = "Abort",
94383+ [SIGBUS] = "Invalid alignment/Bus error"
94384+};
94385+
94386+void
94387+gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
94388+{
94389+#ifdef CONFIG_GRKERNSEC_SIGNAL
94390+ if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
94391+ (sig == SIGABRT) || (sig == SIGBUS))) {
94392+ if (task_pid_nr(t) == task_pid_nr(current)) {
94393+ gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
94394+ } else {
94395+ gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
94396+ }
94397+ }
94398+#endif
94399+ return;
94400+}
94401+
94402+int
94403+gr_handle_signal(const struct task_struct *p, const int sig)
94404+{
94405+#ifdef CONFIG_GRKERNSEC
94406+ /* ignore the 0 signal for protected task checks */
94407+ if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
94408+ gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
94409+ return -EPERM;
94410+ } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
94411+ return -EPERM;
94412+ }
94413+#endif
94414+ return 0;
94415+}
94416+
94417+#ifdef CONFIG_GRKERNSEC
94418+extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
94419+
94420+int gr_fake_force_sig(int sig, struct task_struct *t)
94421+{
94422+ unsigned long int flags;
94423+ int ret, blocked, ignored;
94424+ struct k_sigaction *action;
94425+
94426+ spin_lock_irqsave(&t->sighand->siglock, flags);
94427+ action = &t->sighand->action[sig-1];
94428+ ignored = action->sa.sa_handler == SIG_IGN;
94429+ blocked = sigismember(&t->blocked, sig);
94430+ if (blocked || ignored) {
94431+ action->sa.sa_handler = SIG_DFL;
94432+ if (blocked) {
94433+ sigdelset(&t->blocked, sig);
94434+ recalc_sigpending_and_wake(t);
94435+ }
94436+ }
94437+ if (action->sa.sa_handler == SIG_DFL)
94438+ t->signal->flags &= ~SIGNAL_UNKILLABLE;
94439+ ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
94440+
94441+ spin_unlock_irqrestore(&t->sighand->siglock, flags);
94442+
94443+ return ret;
94444+}
94445+#endif
94446+
94447+#define GR_USER_BAN_TIME (15 * 60)
94448+#define GR_DAEMON_BRUTE_TIME (30 * 60)
94449+
94450+void gr_handle_brute_attach(int dumpable)
94451+{
94452+#ifdef CONFIG_GRKERNSEC_BRUTE
94453+ struct task_struct *p = current;
94454+ kuid_t uid = GLOBAL_ROOT_UID;
94455+ int daemon = 0;
94456+
94457+ if (!grsec_enable_brute)
94458+ return;
94459+
94460+ rcu_read_lock();
94461+ read_lock(&tasklist_lock);
94462+ read_lock(&grsec_exec_file_lock);
94463+ if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
94464+ p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
94465+ p->real_parent->brute = 1;
94466+ daemon = 1;
94467+ } else {
94468+ const struct cred *cred = __task_cred(p), *cred2;
94469+ struct task_struct *tsk, *tsk2;
94470+
94471+ if (dumpable != SUID_DUMP_USER && gr_is_global_nonroot(cred->uid)) {
94472+ struct user_struct *user;
94473+
94474+ uid = cred->uid;
94475+
94476+ /* this is put upon execution past expiration */
94477+ user = find_user(uid);
94478+ if (user == NULL)
94479+ goto unlock;
94480+ user->suid_banned = 1;
94481+ user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
94482+ if (user->suid_ban_expires == ~0UL)
94483+ user->suid_ban_expires--;
94484+
94485+ /* only kill other threads of the same binary, from the same user */
94486+ do_each_thread(tsk2, tsk) {
94487+ cred2 = __task_cred(tsk);
94488+ if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
94489+ gr_fake_force_sig(SIGKILL, tsk);
94490+ } while_each_thread(tsk2, tsk);
94491+ }
94492+ }
94493+unlock:
94494+ read_unlock(&grsec_exec_file_lock);
94495+ read_unlock(&tasklist_lock);
94496+ rcu_read_unlock();
94497+
94498+ if (gr_is_global_nonroot(uid))
94499+ 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);
94500+ else if (daemon)
94501+ gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
94502+
94503+#endif
94504+ return;
94505+}
94506+
94507+void gr_handle_brute_check(void)
94508+{
94509+#ifdef CONFIG_GRKERNSEC_BRUTE
94510+ struct task_struct *p = current;
94511+
94512+ if (unlikely(p->brute)) {
94513+ if (!grsec_enable_brute)
94514+ p->brute = 0;
94515+ else if (time_before(get_seconds(), p->brute_expires))
94516+ msleep(30 * 1000);
94517+ }
94518+#endif
94519+ return;
94520+}
94521+
94522+void gr_handle_kernel_exploit(void)
94523+{
94524+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
94525+ const struct cred *cred;
94526+ struct task_struct *tsk, *tsk2;
94527+ struct user_struct *user;
94528+ kuid_t uid;
94529+
94530+ if (in_irq() || in_serving_softirq() || in_nmi())
94531+ panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
94532+
94533+ uid = current_uid();
94534+
94535+ if (gr_is_global_root(uid))
94536+ panic("grsec: halting the system due to suspicious kernel crash caused by root");
94537+ else {
94538+ /* kill all the processes of this user, hold a reference
94539+ to their creds struct, and prevent them from creating
94540+ another process until system reset
94541+ */
94542+ printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
94543+ GR_GLOBAL_UID(uid));
94544+ /* we intentionally leak this ref */
94545+ user = get_uid(current->cred->user);
94546+ if (user)
94547+ user->kernel_banned = 1;
94548+
94549+ /* kill all processes of this user */
94550+ read_lock(&tasklist_lock);
94551+ do_each_thread(tsk2, tsk) {
94552+ cred = __task_cred(tsk);
94553+ if (uid_eq(cred->uid, uid))
94554+ gr_fake_force_sig(SIGKILL, tsk);
94555+ } while_each_thread(tsk2, tsk);
94556+ read_unlock(&tasklist_lock);
94557+ }
94558+#endif
94559+}
94560+
94561+#ifdef CONFIG_GRKERNSEC_BRUTE
94562+static bool suid_ban_expired(struct user_struct *user)
94563+{
94564+ if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
94565+ user->suid_banned = 0;
94566+ user->suid_ban_expires = 0;
94567+ free_uid(user);
94568+ return true;
94569+ }
94570+
94571+ return false;
94572+}
94573+#endif
94574+
94575+int gr_process_kernel_exec_ban(void)
94576+{
94577+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
94578+ if (unlikely(current->cred->user->kernel_banned))
94579+ return -EPERM;
94580+#endif
94581+ return 0;
94582+}
94583+
94584+int gr_process_kernel_setuid_ban(struct user_struct *user)
94585+{
94586+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
94587+ if (unlikely(user->kernel_banned))
94588+ gr_fake_force_sig(SIGKILL, current);
94589+#endif
94590+ return 0;
94591+}
94592+
94593+int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
94594+{
94595+#ifdef CONFIG_GRKERNSEC_BRUTE
94596+ struct user_struct *user = current->cred->user;
94597+ if (unlikely(user->suid_banned)) {
94598+ if (suid_ban_expired(user))
94599+ return 0;
94600+ /* disallow execution of suid binaries only */
94601+ else if (!uid_eq(bprm->cred->euid, current->cred->uid))
94602+ return -EPERM;
94603+ }
94604+#endif
94605+ return 0;
94606+}
94607diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
94608new file mode 100644
94609index 0000000..a523bd2
94610--- /dev/null
94611+++ b/grsecurity/grsec_sock.c
94612@@ -0,0 +1,244 @@
94613+#include <linux/kernel.h>
94614+#include <linux/module.h>
94615+#include <linux/sched.h>
94616+#include <linux/file.h>
94617+#include <linux/net.h>
94618+#include <linux/in.h>
94619+#include <linux/ip.h>
94620+#include <net/sock.h>
94621+#include <net/inet_sock.h>
94622+#include <linux/grsecurity.h>
94623+#include <linux/grinternal.h>
94624+#include <linux/gracl.h>
94625+
94626+extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
94627+extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
94628+
94629+EXPORT_SYMBOL_GPL(gr_search_udp_recvmsg);
94630+EXPORT_SYMBOL_GPL(gr_search_udp_sendmsg);
94631+
94632+#ifdef CONFIG_UNIX_MODULE
94633+EXPORT_SYMBOL_GPL(gr_acl_handle_unix);
94634+EXPORT_SYMBOL_GPL(gr_acl_handle_mknod);
94635+EXPORT_SYMBOL_GPL(gr_handle_chroot_unix);
94636+EXPORT_SYMBOL_GPL(gr_handle_create);
94637+#endif
94638+
94639+#ifdef CONFIG_GRKERNSEC
94640+#define gr_conn_table_size 32749
94641+struct conn_table_entry {
94642+ struct conn_table_entry *next;
94643+ struct signal_struct *sig;
94644+};
94645+
94646+struct conn_table_entry *gr_conn_table[gr_conn_table_size];
94647+DEFINE_SPINLOCK(gr_conn_table_lock);
94648+
94649+extern const char * gr_socktype_to_name(unsigned char type);
94650+extern const char * gr_proto_to_name(unsigned char proto);
94651+extern const char * gr_sockfamily_to_name(unsigned char family);
94652+
94653+static int
94654+conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
94655+{
94656+ return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
94657+}
94658+
94659+static int
94660+conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
94661+ __u16 sport, __u16 dport)
94662+{
94663+ if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
94664+ sig->gr_sport == sport && sig->gr_dport == dport))
94665+ return 1;
94666+ else
94667+ return 0;
94668+}
94669+
94670+static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
94671+{
94672+ struct conn_table_entry **match;
94673+ unsigned int index;
94674+
94675+ index = conn_hash(sig->gr_saddr, sig->gr_daddr,
94676+ sig->gr_sport, sig->gr_dport,
94677+ gr_conn_table_size);
94678+
94679+ newent->sig = sig;
94680+
94681+ match = &gr_conn_table[index];
94682+ newent->next = *match;
94683+ *match = newent;
94684+
94685+ return;
94686+}
94687+
94688+static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
94689+{
94690+ struct conn_table_entry *match, *last = NULL;
94691+ unsigned int index;
94692+
94693+ index = conn_hash(sig->gr_saddr, sig->gr_daddr,
94694+ sig->gr_sport, sig->gr_dport,
94695+ gr_conn_table_size);
94696+
94697+ match = gr_conn_table[index];
94698+ while (match && !conn_match(match->sig,
94699+ sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
94700+ sig->gr_dport)) {
94701+ last = match;
94702+ match = match->next;
94703+ }
94704+
94705+ if (match) {
94706+ if (last)
94707+ last->next = match->next;
94708+ else
94709+ gr_conn_table[index] = NULL;
94710+ kfree(match);
94711+ }
94712+
94713+ return;
94714+}
94715+
94716+static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
94717+ __u16 sport, __u16 dport)
94718+{
94719+ struct conn_table_entry *match;
94720+ unsigned int index;
94721+
94722+ index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
94723+
94724+ match = gr_conn_table[index];
94725+ while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
94726+ match = match->next;
94727+
94728+ if (match)
94729+ return match->sig;
94730+ else
94731+ return NULL;
94732+}
94733+
94734+#endif
94735+
94736+void gr_update_task_in_ip_table(const struct inet_sock *inet)
94737+{
94738+#ifdef CONFIG_GRKERNSEC
94739+ struct signal_struct *sig = current->signal;
94740+ struct conn_table_entry *newent;
94741+
94742+ newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
94743+ if (newent == NULL)
94744+ return;
94745+ /* no bh lock needed since we are called with bh disabled */
94746+ spin_lock(&gr_conn_table_lock);
94747+ gr_del_task_from_ip_table_nolock(sig);
94748+ sig->gr_saddr = inet->inet_rcv_saddr;
94749+ sig->gr_daddr = inet->inet_daddr;
94750+ sig->gr_sport = inet->inet_sport;
94751+ sig->gr_dport = inet->inet_dport;
94752+ gr_add_to_task_ip_table_nolock(sig, newent);
94753+ spin_unlock(&gr_conn_table_lock);
94754+#endif
94755+ return;
94756+}
94757+
94758+void gr_del_task_from_ip_table(struct task_struct *task)
94759+{
94760+#ifdef CONFIG_GRKERNSEC
94761+ spin_lock_bh(&gr_conn_table_lock);
94762+ gr_del_task_from_ip_table_nolock(task->signal);
94763+ spin_unlock_bh(&gr_conn_table_lock);
94764+#endif
94765+ return;
94766+}
94767+
94768+void
94769+gr_attach_curr_ip(const struct sock *sk)
94770+{
94771+#ifdef CONFIG_GRKERNSEC
94772+ struct signal_struct *p, *set;
94773+ const struct inet_sock *inet = inet_sk(sk);
94774+
94775+ if (unlikely(sk->sk_protocol != IPPROTO_TCP))
94776+ return;
94777+
94778+ set = current->signal;
94779+
94780+ spin_lock_bh(&gr_conn_table_lock);
94781+ p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
94782+ inet->inet_dport, inet->inet_sport);
94783+ if (unlikely(p != NULL)) {
94784+ set->curr_ip = p->curr_ip;
94785+ set->used_accept = 1;
94786+ gr_del_task_from_ip_table_nolock(p);
94787+ spin_unlock_bh(&gr_conn_table_lock);
94788+ return;
94789+ }
94790+ spin_unlock_bh(&gr_conn_table_lock);
94791+
94792+ set->curr_ip = inet->inet_daddr;
94793+ set->used_accept = 1;
94794+#endif
94795+ return;
94796+}
94797+
94798+int
94799+gr_handle_sock_all(const int family, const int type, const int protocol)
94800+{
94801+#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
94802+ if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
94803+ (family != AF_UNIX)) {
94804+ if (family == AF_INET)
94805+ gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
94806+ else
94807+ gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
94808+ return -EACCES;
94809+ }
94810+#endif
94811+ return 0;
94812+}
94813+
94814+int
94815+gr_handle_sock_server(const struct sockaddr *sck)
94816+{
94817+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
94818+ if (grsec_enable_socket_server &&
94819+ in_group_p(grsec_socket_server_gid) &&
94820+ sck && (sck->sa_family != AF_UNIX) &&
94821+ (sck->sa_family != AF_LOCAL)) {
94822+ gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
94823+ return -EACCES;
94824+ }
94825+#endif
94826+ return 0;
94827+}
94828+
94829+int
94830+gr_handle_sock_server_other(const struct sock *sck)
94831+{
94832+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
94833+ if (grsec_enable_socket_server &&
94834+ in_group_p(grsec_socket_server_gid) &&
94835+ sck && (sck->sk_family != AF_UNIX) &&
94836+ (sck->sk_family != AF_LOCAL)) {
94837+ gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
94838+ return -EACCES;
94839+ }
94840+#endif
94841+ return 0;
94842+}
94843+
94844+int
94845+gr_handle_sock_client(const struct sockaddr *sck)
94846+{
94847+#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
94848+ if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
94849+ sck && (sck->sa_family != AF_UNIX) &&
94850+ (sck->sa_family != AF_LOCAL)) {
94851+ gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
94852+ return -EACCES;
94853+ }
94854+#endif
94855+ return 0;
94856+}
94857diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
94858new file mode 100644
94859index 0000000..aaec43c
94860--- /dev/null
94861+++ b/grsecurity/grsec_sysctl.c
94862@@ -0,0 +1,488 @@
94863+#include <linux/kernel.h>
94864+#include <linux/sched.h>
94865+#include <linux/sysctl.h>
94866+#include <linux/grsecurity.h>
94867+#include <linux/grinternal.h>
94868+
94869+int
94870+gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
94871+{
94872+#ifdef CONFIG_GRKERNSEC_SYSCTL
94873+ if (dirname == NULL || name == NULL)
94874+ return 0;
94875+ if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
94876+ gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
94877+ return -EACCES;
94878+ }
94879+#endif
94880+ return 0;
94881+}
94882+
94883+#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
94884+static int __maybe_unused __read_only one = 1;
94885+#endif
94886+
94887+#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
94888+ defined(CONFIG_GRKERNSEC_DENYUSB)
94889+struct ctl_table grsecurity_table[] = {
94890+#ifdef CONFIG_GRKERNSEC_SYSCTL
94891+#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
94892+#ifdef CONFIG_GRKERNSEC_IO
94893+ {
94894+ .procname = "disable_priv_io",
94895+ .data = &grsec_disable_privio,
94896+ .maxlen = sizeof(int),
94897+ .mode = 0600,
94898+ .proc_handler = &proc_dointvec_secure,
94899+ },
94900+#endif
94901+#endif
94902+#ifdef CONFIG_GRKERNSEC_LINK
94903+ {
94904+ .procname = "linking_restrictions",
94905+ .data = &grsec_enable_link,
94906+ .maxlen = sizeof(int),
94907+ .mode = 0600,
94908+ .proc_handler = &proc_dointvec_secure,
94909+ },
94910+#endif
94911+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
94912+ {
94913+ .procname = "enforce_symlinksifowner",
94914+ .data = &grsec_enable_symlinkown,
94915+ .maxlen = sizeof(int),
94916+ .mode = 0600,
94917+ .proc_handler = &proc_dointvec_secure,
94918+ },
94919+ {
94920+ .procname = "symlinkown_gid",
94921+ .data = &grsec_symlinkown_gid,
94922+ .maxlen = sizeof(int),
94923+ .mode = 0600,
94924+ .proc_handler = &proc_dointvec_secure,
94925+ },
94926+#endif
94927+#ifdef CONFIG_GRKERNSEC_BRUTE
94928+ {
94929+ .procname = "deter_bruteforce",
94930+ .data = &grsec_enable_brute,
94931+ .maxlen = sizeof(int),
94932+ .mode = 0600,
94933+ .proc_handler = &proc_dointvec_secure,
94934+ },
94935+#endif
94936+#ifdef CONFIG_GRKERNSEC_FIFO
94937+ {
94938+ .procname = "fifo_restrictions",
94939+ .data = &grsec_enable_fifo,
94940+ .maxlen = sizeof(int),
94941+ .mode = 0600,
94942+ .proc_handler = &proc_dointvec_secure,
94943+ },
94944+#endif
94945+#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
94946+ {
94947+ .procname = "ptrace_readexec",
94948+ .data = &grsec_enable_ptrace_readexec,
94949+ .maxlen = sizeof(int),
94950+ .mode = 0600,
94951+ .proc_handler = &proc_dointvec_secure,
94952+ },
94953+#endif
94954+#ifdef CONFIG_GRKERNSEC_SETXID
94955+ {
94956+ .procname = "consistent_setxid",
94957+ .data = &grsec_enable_setxid,
94958+ .maxlen = sizeof(int),
94959+ .mode = 0600,
94960+ .proc_handler = &proc_dointvec_secure,
94961+ },
94962+#endif
94963+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94964+ {
94965+ .procname = "ip_blackhole",
94966+ .data = &grsec_enable_blackhole,
94967+ .maxlen = sizeof(int),
94968+ .mode = 0600,
94969+ .proc_handler = &proc_dointvec_secure,
94970+ },
94971+ {
94972+ .procname = "lastack_retries",
94973+ .data = &grsec_lastack_retries,
94974+ .maxlen = sizeof(int),
94975+ .mode = 0600,
94976+ .proc_handler = &proc_dointvec_secure,
94977+ },
94978+#endif
94979+#ifdef CONFIG_GRKERNSEC_EXECLOG
94980+ {
94981+ .procname = "exec_logging",
94982+ .data = &grsec_enable_execlog,
94983+ .maxlen = sizeof(int),
94984+ .mode = 0600,
94985+ .proc_handler = &proc_dointvec_secure,
94986+ },
94987+#endif
94988+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94989+ {
94990+ .procname = "rwxmap_logging",
94991+ .data = &grsec_enable_log_rwxmaps,
94992+ .maxlen = sizeof(int),
94993+ .mode = 0600,
94994+ .proc_handler = &proc_dointvec_secure,
94995+ },
94996+#endif
94997+#ifdef CONFIG_GRKERNSEC_SIGNAL
94998+ {
94999+ .procname = "signal_logging",
95000+ .data = &grsec_enable_signal,
95001+ .maxlen = sizeof(int),
95002+ .mode = 0600,
95003+ .proc_handler = &proc_dointvec_secure,
95004+ },
95005+#endif
95006+#ifdef CONFIG_GRKERNSEC_FORKFAIL
95007+ {
95008+ .procname = "forkfail_logging",
95009+ .data = &grsec_enable_forkfail,
95010+ .maxlen = sizeof(int),
95011+ .mode = 0600,
95012+ .proc_handler = &proc_dointvec_secure,
95013+ },
95014+#endif
95015+#ifdef CONFIG_GRKERNSEC_TIME
95016+ {
95017+ .procname = "timechange_logging",
95018+ .data = &grsec_enable_time,
95019+ .maxlen = sizeof(int),
95020+ .mode = 0600,
95021+ .proc_handler = &proc_dointvec_secure,
95022+ },
95023+#endif
95024+#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
95025+ {
95026+ .procname = "chroot_deny_shmat",
95027+ .data = &grsec_enable_chroot_shmat,
95028+ .maxlen = sizeof(int),
95029+ .mode = 0600,
95030+ .proc_handler = &proc_dointvec_secure,
95031+ },
95032+#endif
95033+#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
95034+ {
95035+ .procname = "chroot_deny_unix",
95036+ .data = &grsec_enable_chroot_unix,
95037+ .maxlen = sizeof(int),
95038+ .mode = 0600,
95039+ .proc_handler = &proc_dointvec_secure,
95040+ },
95041+#endif
95042+#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
95043+ {
95044+ .procname = "chroot_deny_mount",
95045+ .data = &grsec_enable_chroot_mount,
95046+ .maxlen = sizeof(int),
95047+ .mode = 0600,
95048+ .proc_handler = &proc_dointvec_secure,
95049+ },
95050+#endif
95051+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
95052+ {
95053+ .procname = "chroot_deny_fchdir",
95054+ .data = &grsec_enable_chroot_fchdir,
95055+ .maxlen = sizeof(int),
95056+ .mode = 0600,
95057+ .proc_handler = &proc_dointvec_secure,
95058+ },
95059+#endif
95060+#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
95061+ {
95062+ .procname = "chroot_deny_chroot",
95063+ .data = &grsec_enable_chroot_double,
95064+ .maxlen = sizeof(int),
95065+ .mode = 0600,
95066+ .proc_handler = &proc_dointvec_secure,
95067+ },
95068+#endif
95069+#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
95070+ {
95071+ .procname = "chroot_deny_pivot",
95072+ .data = &grsec_enable_chroot_pivot,
95073+ .maxlen = sizeof(int),
95074+ .mode = 0600,
95075+ .proc_handler = &proc_dointvec_secure,
95076+ },
95077+#endif
95078+#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
95079+ {
95080+ .procname = "chroot_enforce_chdir",
95081+ .data = &grsec_enable_chroot_chdir,
95082+ .maxlen = sizeof(int),
95083+ .mode = 0600,
95084+ .proc_handler = &proc_dointvec_secure,
95085+ },
95086+#endif
95087+#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
95088+ {
95089+ .procname = "chroot_deny_chmod",
95090+ .data = &grsec_enable_chroot_chmod,
95091+ .maxlen = sizeof(int),
95092+ .mode = 0600,
95093+ .proc_handler = &proc_dointvec_secure,
95094+ },
95095+#endif
95096+#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
95097+ {
95098+ .procname = "chroot_deny_mknod",
95099+ .data = &grsec_enable_chroot_mknod,
95100+ .maxlen = sizeof(int),
95101+ .mode = 0600,
95102+ .proc_handler = &proc_dointvec_secure,
95103+ },
95104+#endif
95105+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
95106+ {
95107+ .procname = "chroot_restrict_nice",
95108+ .data = &grsec_enable_chroot_nice,
95109+ .maxlen = sizeof(int),
95110+ .mode = 0600,
95111+ .proc_handler = &proc_dointvec_secure,
95112+ },
95113+#endif
95114+#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
95115+ {
95116+ .procname = "chroot_execlog",
95117+ .data = &grsec_enable_chroot_execlog,
95118+ .maxlen = sizeof(int),
95119+ .mode = 0600,
95120+ .proc_handler = &proc_dointvec_secure,
95121+ },
95122+#endif
95123+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
95124+ {
95125+ .procname = "chroot_caps",
95126+ .data = &grsec_enable_chroot_caps,
95127+ .maxlen = sizeof(int),
95128+ .mode = 0600,
95129+ .proc_handler = &proc_dointvec_secure,
95130+ },
95131+#endif
95132+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
95133+ {
95134+ .procname = "chroot_deny_bad_rename",
95135+ .data = &grsec_enable_chroot_rename,
95136+ .maxlen = sizeof(int),
95137+ .mode = 0600,
95138+ .proc_handler = &proc_dointvec_secure,
95139+ },
95140+#endif
95141+#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
95142+ {
95143+ .procname = "chroot_deny_sysctl",
95144+ .data = &grsec_enable_chroot_sysctl,
95145+ .maxlen = sizeof(int),
95146+ .mode = 0600,
95147+ .proc_handler = &proc_dointvec_secure,
95148+ },
95149+#endif
95150+#ifdef CONFIG_GRKERNSEC_TPE
95151+ {
95152+ .procname = "tpe",
95153+ .data = &grsec_enable_tpe,
95154+ .maxlen = sizeof(int),
95155+ .mode = 0600,
95156+ .proc_handler = &proc_dointvec_secure,
95157+ },
95158+ {
95159+ .procname = "tpe_gid",
95160+ .data = &grsec_tpe_gid,
95161+ .maxlen = sizeof(int),
95162+ .mode = 0600,
95163+ .proc_handler = &proc_dointvec_secure,
95164+ },
95165+#endif
95166+#ifdef CONFIG_GRKERNSEC_TPE_INVERT
95167+ {
95168+ .procname = "tpe_invert",
95169+ .data = &grsec_enable_tpe_invert,
95170+ .maxlen = sizeof(int),
95171+ .mode = 0600,
95172+ .proc_handler = &proc_dointvec_secure,
95173+ },
95174+#endif
95175+#ifdef CONFIG_GRKERNSEC_TPE_ALL
95176+ {
95177+ .procname = "tpe_restrict_all",
95178+ .data = &grsec_enable_tpe_all,
95179+ .maxlen = sizeof(int),
95180+ .mode = 0600,
95181+ .proc_handler = &proc_dointvec_secure,
95182+ },
95183+#endif
95184+#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
95185+ {
95186+ .procname = "socket_all",
95187+ .data = &grsec_enable_socket_all,
95188+ .maxlen = sizeof(int),
95189+ .mode = 0600,
95190+ .proc_handler = &proc_dointvec_secure,
95191+ },
95192+ {
95193+ .procname = "socket_all_gid",
95194+ .data = &grsec_socket_all_gid,
95195+ .maxlen = sizeof(int),
95196+ .mode = 0600,
95197+ .proc_handler = &proc_dointvec_secure,
95198+ },
95199+#endif
95200+#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
95201+ {
95202+ .procname = "socket_client",
95203+ .data = &grsec_enable_socket_client,
95204+ .maxlen = sizeof(int),
95205+ .mode = 0600,
95206+ .proc_handler = &proc_dointvec_secure,
95207+ },
95208+ {
95209+ .procname = "socket_client_gid",
95210+ .data = &grsec_socket_client_gid,
95211+ .maxlen = sizeof(int),
95212+ .mode = 0600,
95213+ .proc_handler = &proc_dointvec_secure,
95214+ },
95215+#endif
95216+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
95217+ {
95218+ .procname = "socket_server",
95219+ .data = &grsec_enable_socket_server,
95220+ .maxlen = sizeof(int),
95221+ .mode = 0600,
95222+ .proc_handler = &proc_dointvec_secure,
95223+ },
95224+ {
95225+ .procname = "socket_server_gid",
95226+ .data = &grsec_socket_server_gid,
95227+ .maxlen = sizeof(int),
95228+ .mode = 0600,
95229+ .proc_handler = &proc_dointvec_secure,
95230+ },
95231+#endif
95232+#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
95233+ {
95234+ .procname = "audit_group",
95235+ .data = &grsec_enable_group,
95236+ .maxlen = sizeof(int),
95237+ .mode = 0600,
95238+ .proc_handler = &proc_dointvec_secure,
95239+ },
95240+ {
95241+ .procname = "audit_gid",
95242+ .data = &grsec_audit_gid,
95243+ .maxlen = sizeof(int),
95244+ .mode = 0600,
95245+ .proc_handler = &proc_dointvec_secure,
95246+ },
95247+#endif
95248+#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
95249+ {
95250+ .procname = "audit_chdir",
95251+ .data = &grsec_enable_chdir,
95252+ .maxlen = sizeof(int),
95253+ .mode = 0600,
95254+ .proc_handler = &proc_dointvec_secure,
95255+ },
95256+#endif
95257+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
95258+ {
95259+ .procname = "audit_mount",
95260+ .data = &grsec_enable_mount,
95261+ .maxlen = sizeof(int),
95262+ .mode = 0600,
95263+ .proc_handler = &proc_dointvec_secure,
95264+ },
95265+#endif
95266+#ifdef CONFIG_GRKERNSEC_DMESG
95267+ {
95268+ .procname = "dmesg",
95269+ .data = &grsec_enable_dmesg,
95270+ .maxlen = sizeof(int),
95271+ .mode = 0600,
95272+ .proc_handler = &proc_dointvec_secure,
95273+ },
95274+#endif
95275+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
95276+ {
95277+ .procname = "chroot_findtask",
95278+ .data = &grsec_enable_chroot_findtask,
95279+ .maxlen = sizeof(int),
95280+ .mode = 0600,
95281+ .proc_handler = &proc_dointvec_secure,
95282+ },
95283+#endif
95284+#ifdef CONFIG_GRKERNSEC_RESLOG
95285+ {
95286+ .procname = "resource_logging",
95287+ .data = &grsec_resource_logging,
95288+ .maxlen = sizeof(int),
95289+ .mode = 0600,
95290+ .proc_handler = &proc_dointvec_secure,
95291+ },
95292+#endif
95293+#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
95294+ {
95295+ .procname = "audit_ptrace",
95296+ .data = &grsec_enable_audit_ptrace,
95297+ .maxlen = sizeof(int),
95298+ .mode = 0600,
95299+ .proc_handler = &proc_dointvec_secure,
95300+ },
95301+#endif
95302+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
95303+ {
95304+ .procname = "harden_ptrace",
95305+ .data = &grsec_enable_harden_ptrace,
95306+ .maxlen = sizeof(int),
95307+ .mode = 0600,
95308+ .proc_handler = &proc_dointvec_secure,
95309+ },
95310+#endif
95311+#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
95312+ {
95313+ .procname = "harden_ipc",
95314+ .data = &grsec_enable_harden_ipc,
95315+ .maxlen = sizeof(int),
95316+ .mode = 0600,
95317+ .proc_handler = &proc_dointvec_secure,
95318+ },
95319+#endif
95320+ {
95321+ .procname = "grsec_lock",
95322+ .data = &grsec_lock,
95323+ .maxlen = sizeof(int),
95324+ .mode = 0600,
95325+ .proc_handler = &proc_dointvec_secure,
95326+ },
95327+#endif
95328+#ifdef CONFIG_GRKERNSEC_ROFS
95329+ {
95330+ .procname = "romount_protect",
95331+ .data = &grsec_enable_rofs,
95332+ .maxlen = sizeof(int),
95333+ .mode = 0600,
95334+ .proc_handler = &proc_dointvec_minmax_secure,
95335+ .extra1 = &one,
95336+ .extra2 = &one,
95337+ },
95338+#endif
95339+#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
95340+ {
95341+ .procname = "deny_new_usb",
95342+ .data = &grsec_deny_new_usb,
95343+ .maxlen = sizeof(int),
95344+ .mode = 0600,
95345+ .proc_handler = &proc_dointvec_secure,
95346+ },
95347+#endif
95348+ { }
95349+};
95350+#endif
95351diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
95352new file mode 100644
95353index 0000000..61b514e
95354--- /dev/null
95355+++ b/grsecurity/grsec_time.c
95356@@ -0,0 +1,16 @@
95357+#include <linux/kernel.h>
95358+#include <linux/sched.h>
95359+#include <linux/grinternal.h>
95360+#include <linux/module.h>
95361+
95362+void
95363+gr_log_timechange(void)
95364+{
95365+#ifdef CONFIG_GRKERNSEC_TIME
95366+ if (grsec_enable_time)
95367+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
95368+#endif
95369+ return;
95370+}
95371+
95372+EXPORT_SYMBOL_GPL(gr_log_timechange);
95373diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
95374new file mode 100644
95375index 0000000..9786671
95376--- /dev/null
95377+++ b/grsecurity/grsec_tpe.c
95378@@ -0,0 +1,78 @@
95379+#include <linux/kernel.h>
95380+#include <linux/sched.h>
95381+#include <linux/file.h>
95382+#include <linux/fs.h>
95383+#include <linux/grinternal.h>
95384+
95385+extern int gr_acl_tpe_check(void);
95386+
95387+int
95388+gr_tpe_allow(const struct file *file)
95389+{
95390+#ifdef CONFIG_GRKERNSEC
95391+ struct inode *inode = d_backing_inode(file->f_path.dentry->d_parent);
95392+ struct inode *file_inode = d_backing_inode(file->f_path.dentry);
95393+ const struct cred *cred = current_cred();
95394+ char *msg = NULL;
95395+ char *msg2 = NULL;
95396+
95397+ // never restrict root
95398+ if (gr_is_global_root(cred->uid))
95399+ return 1;
95400+
95401+ if (grsec_enable_tpe) {
95402+#ifdef CONFIG_GRKERNSEC_TPE_INVERT
95403+ if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
95404+ msg = "not being in trusted group";
95405+ else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
95406+ msg = "being in untrusted group";
95407+#else
95408+ if (in_group_p(grsec_tpe_gid))
95409+ msg = "being in untrusted group";
95410+#endif
95411+ }
95412+ if (!msg && gr_acl_tpe_check())
95413+ msg = "being in untrusted role";
95414+
95415+ // not in any affected group/role
95416+ if (!msg)
95417+ goto next_check;
95418+
95419+ if (gr_is_global_nonroot(inode->i_uid))
95420+ msg2 = "file in non-root-owned directory";
95421+ else if (inode->i_mode & S_IWOTH)
95422+ msg2 = "file in world-writable directory";
95423+ else if (inode->i_mode & S_IWGRP)
95424+ msg2 = "file in group-writable directory";
95425+ else if (file_inode->i_mode & S_IWOTH)
95426+ msg2 = "file is world-writable";
95427+
95428+ if (msg && msg2) {
95429+ char fullmsg[70] = {0};
95430+ snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
95431+ gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
95432+ return 0;
95433+ }
95434+ msg = NULL;
95435+next_check:
95436+#ifdef CONFIG_GRKERNSEC_TPE_ALL
95437+ if (!grsec_enable_tpe || !grsec_enable_tpe_all)
95438+ return 1;
95439+
95440+ if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
95441+ msg = "directory not owned by user";
95442+ else if (inode->i_mode & S_IWOTH)
95443+ msg = "file in world-writable directory";
95444+ else if (inode->i_mode & S_IWGRP)
95445+ msg = "file in group-writable directory";
95446+ else if (file_inode->i_mode & S_IWOTH)
95447+ msg = "file is world-writable";
95448+
95449+ if (msg) {
95450+ gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
95451+ return 0;
95452+ }
95453+#endif
95454+#endif
95455+ return 1;
95456+}
95457diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
95458new file mode 100644
95459index 0000000..ae02d8e
95460--- /dev/null
95461+++ b/grsecurity/grsec_usb.c
95462@@ -0,0 +1,15 @@
95463+#include <linux/kernel.h>
95464+#include <linux/grinternal.h>
95465+#include <linux/module.h>
95466+
95467+int gr_handle_new_usb(void)
95468+{
95469+#ifdef CONFIG_GRKERNSEC_DENYUSB
95470+ if (grsec_deny_new_usb) {
95471+ printk(KERN_ALERT "grsec: denied insert of new USB device\n");
95472+ return 1;
95473+ }
95474+#endif
95475+ return 0;
95476+}
95477+EXPORT_SYMBOL_GPL(gr_handle_new_usb);
95478diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
95479new file mode 100644
95480index 0000000..158b330
95481--- /dev/null
95482+++ b/grsecurity/grsum.c
95483@@ -0,0 +1,64 @@
95484+#include <linux/err.h>
95485+#include <linux/kernel.h>
95486+#include <linux/sched.h>
95487+#include <linux/mm.h>
95488+#include <linux/scatterlist.h>
95489+#include <linux/crypto.h>
95490+#include <linux/gracl.h>
95491+
95492+
95493+#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
95494+#error "crypto and sha256 must be built into the kernel"
95495+#endif
95496+
95497+int
95498+chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
95499+{
95500+ struct crypto_hash *tfm;
95501+ struct hash_desc desc;
95502+ struct scatterlist sg[2];
95503+ unsigned char temp_sum[GR_SHA_LEN] __attribute__((aligned(__alignof__(unsigned long))));
95504+ unsigned long *tmpsumptr = (unsigned long *)temp_sum;
95505+ unsigned long *sumptr = (unsigned long *)sum;
95506+ int cryptres;
95507+ int retval = 1;
95508+ volatile int mismatched = 0;
95509+ volatile int dummy = 0;
95510+ unsigned int i;
95511+
95512+ tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
95513+ if (IS_ERR(tfm)) {
95514+ /* should never happen, since sha256 should be built in */
95515+ memset(entry->pw, 0, GR_PW_LEN);
95516+ return 1;
95517+ }
95518+
95519+ sg_init_table(sg, 2);
95520+ sg_set_buf(&sg[0], salt, GR_SALT_LEN);
95521+ sg_set_buf(&sg[1], entry->pw, strlen(entry->pw));
95522+
95523+ desc.tfm = tfm;
95524+ desc.flags = 0;
95525+
95526+ cryptres = crypto_hash_digest(&desc, sg, GR_SALT_LEN + strlen(entry->pw),
95527+ temp_sum);
95528+
95529+ memset(entry->pw, 0, GR_PW_LEN);
95530+
95531+ if (cryptres)
95532+ goto out;
95533+
95534+ for (i = 0; i < GR_SHA_LEN/sizeof(tmpsumptr[0]); i++)
95535+ if (sumptr[i] != tmpsumptr[i])
95536+ mismatched = 1;
95537+ else
95538+ dummy = 1; // waste a cycle
95539+
95540+ if (!mismatched)
95541+ retval = dummy - 1;
95542+
95543+out:
95544+ crypto_free_hash(tfm);
95545+
95546+ return retval;
95547+}
95548diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
95549index 5bdab6b..9ae82fe 100644
95550--- a/include/asm-generic/4level-fixup.h
95551+++ b/include/asm-generic/4level-fixup.h
95552@@ -14,8 +14,10 @@
95553 #define pmd_alloc(mm, pud, address) \
95554 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
95555 NULL: pmd_offset(pud, address))
95556+#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
95557
95558 #define pud_alloc(mm, pgd, address) (pgd)
95559+#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
95560 #define pud_offset(pgd, start) (pgd)
95561 #define pud_none(pud) 0
95562 #define pud_bad(pud) 0
95563diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
95564index b7babf0..1e4b4f1 100644
95565--- a/include/asm-generic/atomic-long.h
95566+++ b/include/asm-generic/atomic-long.h
95567@@ -22,6 +22,12 @@
95568
95569 typedef atomic64_t atomic_long_t;
95570
95571+#ifdef CONFIG_PAX_REFCOUNT
95572+typedef atomic64_unchecked_t atomic_long_unchecked_t;
95573+#else
95574+typedef atomic64_t atomic_long_unchecked_t;
95575+#endif
95576+
95577 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
95578
95579 static inline long atomic_long_read(atomic_long_t *l)
95580@@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
95581 return (long)atomic64_read(v);
95582 }
95583
95584+#ifdef CONFIG_PAX_REFCOUNT
95585+static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
95586+{
95587+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95588+
95589+ return (long)atomic64_read_unchecked(v);
95590+}
95591+#endif
95592+
95593 static inline void atomic_long_set(atomic_long_t *l, long i)
95594 {
95595 atomic64_t *v = (atomic64_t *)l;
95596@@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
95597 atomic64_set(v, i);
95598 }
95599
95600+#ifdef CONFIG_PAX_REFCOUNT
95601+static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
95602+{
95603+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95604+
95605+ atomic64_set_unchecked(v, i);
95606+}
95607+#endif
95608+
95609 static inline void atomic_long_inc(atomic_long_t *l)
95610 {
95611 atomic64_t *v = (atomic64_t *)l;
95612@@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
95613 atomic64_inc(v);
95614 }
95615
95616+#ifdef CONFIG_PAX_REFCOUNT
95617+static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
95618+{
95619+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95620+
95621+ atomic64_inc_unchecked(v);
95622+}
95623+#endif
95624+
95625 static inline void atomic_long_dec(atomic_long_t *l)
95626 {
95627 atomic64_t *v = (atomic64_t *)l;
95628@@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
95629 atomic64_dec(v);
95630 }
95631
95632+#ifdef CONFIG_PAX_REFCOUNT
95633+static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
95634+{
95635+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95636+
95637+ atomic64_dec_unchecked(v);
95638+}
95639+#endif
95640+
95641 static inline void atomic_long_add(long i, atomic_long_t *l)
95642 {
95643 atomic64_t *v = (atomic64_t *)l;
95644@@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
95645 atomic64_add(i, v);
95646 }
95647
95648+#ifdef CONFIG_PAX_REFCOUNT
95649+static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
95650+{
95651+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95652+
95653+ atomic64_add_unchecked(i, v);
95654+}
95655+#endif
95656+
95657 static inline void atomic_long_sub(long i, atomic_long_t *l)
95658 {
95659 atomic64_t *v = (atomic64_t *)l;
95660@@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
95661 atomic64_sub(i, v);
95662 }
95663
95664+#ifdef CONFIG_PAX_REFCOUNT
95665+static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
95666+{
95667+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95668+
95669+ atomic64_sub_unchecked(i, v);
95670+}
95671+#endif
95672+
95673 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
95674 {
95675 atomic64_t *v = (atomic64_t *)l;
95676@@ -94,13 +154,22 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
95677 return atomic64_add_negative(i, v);
95678 }
95679
95680-static inline long atomic_long_add_return(long i, atomic_long_t *l)
95681+static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
95682 {
95683 atomic64_t *v = (atomic64_t *)l;
95684
95685 return (long)atomic64_add_return(i, v);
95686 }
95687
95688+#ifdef CONFIG_PAX_REFCOUNT
95689+static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
95690+{
95691+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95692+
95693+ return (long)atomic64_add_return_unchecked(i, v);
95694+}
95695+#endif
95696+
95697 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
95698 {
95699 atomic64_t *v = (atomic64_t *)l;
95700@@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
95701 return (long)atomic64_inc_return(v);
95702 }
95703
95704+#ifdef CONFIG_PAX_REFCOUNT
95705+static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
95706+{
95707+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95708+
95709+ return (long)atomic64_inc_return_unchecked(v);
95710+}
95711+#endif
95712+
95713 static inline long atomic_long_dec_return(atomic_long_t *l)
95714 {
95715 atomic64_t *v = (atomic64_t *)l;
95716@@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
95717
95718 typedef atomic_t atomic_long_t;
95719
95720+#ifdef CONFIG_PAX_REFCOUNT
95721+typedef atomic_unchecked_t atomic_long_unchecked_t;
95722+#else
95723+typedef atomic_t atomic_long_unchecked_t;
95724+#endif
95725+
95726 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
95727 static inline long atomic_long_read(atomic_long_t *l)
95728 {
95729@@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
95730 return (long)atomic_read(v);
95731 }
95732
95733+#ifdef CONFIG_PAX_REFCOUNT
95734+static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
95735+{
95736+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95737+
95738+ return (long)atomic_read_unchecked(v);
95739+}
95740+#endif
95741+
95742 static inline void atomic_long_set(atomic_long_t *l, long i)
95743 {
95744 atomic_t *v = (atomic_t *)l;
95745@@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
95746 atomic_set(v, i);
95747 }
95748
95749+#ifdef CONFIG_PAX_REFCOUNT
95750+static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
95751+{
95752+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95753+
95754+ atomic_set_unchecked(v, i);
95755+}
95756+#endif
95757+
95758 static inline void atomic_long_inc(atomic_long_t *l)
95759 {
95760 atomic_t *v = (atomic_t *)l;
95761@@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
95762 atomic_inc(v);
95763 }
95764
95765+#ifdef CONFIG_PAX_REFCOUNT
95766+static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
95767+{
95768+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95769+
95770+ atomic_inc_unchecked(v);
95771+}
95772+#endif
95773+
95774 static inline void atomic_long_dec(atomic_long_t *l)
95775 {
95776 atomic_t *v = (atomic_t *)l;
95777@@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
95778 atomic_dec(v);
95779 }
95780
95781+#ifdef CONFIG_PAX_REFCOUNT
95782+static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
95783+{
95784+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95785+
95786+ atomic_dec_unchecked(v);
95787+}
95788+#endif
95789+
95790 static inline void atomic_long_add(long i, atomic_long_t *l)
95791 {
95792 atomic_t *v = (atomic_t *)l;
95793@@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
95794 atomic_add(i, v);
95795 }
95796
95797+#ifdef CONFIG_PAX_REFCOUNT
95798+static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
95799+{
95800+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95801+
95802+ atomic_add_unchecked(i, v);
95803+}
95804+#endif
95805+
95806 static inline void atomic_long_sub(long i, atomic_long_t *l)
95807 {
95808 atomic_t *v = (atomic_t *)l;
95809@@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
95810 atomic_sub(i, v);
95811 }
95812
95813+#ifdef CONFIG_PAX_REFCOUNT
95814+static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
95815+{
95816+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95817+
95818+ atomic_sub_unchecked(i, v);
95819+}
95820+#endif
95821+
95822 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
95823 {
95824 atomic_t *v = (atomic_t *)l;
95825@@ -211,13 +349,23 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
95826 return atomic_add_negative(i, v);
95827 }
95828
95829-static inline long atomic_long_add_return(long i, atomic_long_t *l)
95830+static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
95831 {
95832 atomic_t *v = (atomic_t *)l;
95833
95834 return (long)atomic_add_return(i, v);
95835 }
95836
95837+#ifdef CONFIG_PAX_REFCOUNT
95838+static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
95839+{
95840+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95841+
95842+ return (long)atomic_add_return_unchecked(i, v);
95843+}
95844+
95845+#endif
95846+
95847 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
95848 {
95849 atomic_t *v = (atomic_t *)l;
95850@@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
95851 return (long)atomic_inc_return(v);
95852 }
95853
95854+#ifdef CONFIG_PAX_REFCOUNT
95855+static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
95856+{
95857+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95858+
95859+ return (long)atomic_inc_return_unchecked(v);
95860+}
95861+#endif
95862+
95863 static inline long atomic_long_dec_return(atomic_long_t *l)
95864 {
95865 atomic_t *v = (atomic_t *)l;
95866@@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
95867
95868 #endif /* BITS_PER_LONG == 64 */
95869
95870+#ifdef CONFIG_PAX_REFCOUNT
95871+static inline void pax_refcount_needs_these_functions(void)
95872+{
95873+ atomic_read_unchecked((atomic_unchecked_t *)NULL);
95874+ atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
95875+ atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
95876+ atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
95877+ atomic_inc_unchecked((atomic_unchecked_t *)NULL);
95878+ (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
95879+ atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
95880+ atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
95881+ atomic_dec_unchecked((atomic_unchecked_t *)NULL);
95882+ atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
95883+ (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
95884+#ifdef CONFIG_X86
95885+ atomic_clear_mask_unchecked(0, NULL);
95886+ atomic_set_mask_unchecked(0, NULL);
95887+#endif
95888+
95889+ atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
95890+ atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
95891+ atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
95892+ atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
95893+ atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
95894+ atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
95895+ atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
95896+ atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
95897+}
95898+#else
95899+#define atomic_read_unchecked(v) atomic_read(v)
95900+#define atomic_set_unchecked(v, i) atomic_set((v), (i))
95901+#define atomic_add_unchecked(i, v) atomic_add((i), (v))
95902+#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
95903+#define atomic_inc_unchecked(v) atomic_inc(v)
95904+#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
95905+#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
95906+#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
95907+#define atomic_dec_unchecked(v) atomic_dec(v)
95908+#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
95909+#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
95910+#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
95911+#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
95912+
95913+#define atomic_long_read_unchecked(v) atomic_long_read(v)
95914+#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
95915+#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
95916+#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
95917+#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
95918+#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
95919+#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
95920+#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
95921+#endif
95922+
95923 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
95924diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
95925index 30ad9c8..c70c170 100644
95926--- a/include/asm-generic/atomic64.h
95927+++ b/include/asm-generic/atomic64.h
95928@@ -16,6 +16,8 @@ typedef struct {
95929 long long counter;
95930 } atomic64_t;
95931
95932+typedef atomic64_t atomic64_unchecked_t;
95933+
95934 #define ATOMIC64_INIT(i) { (i) }
95935
95936 extern long long atomic64_read(const atomic64_t *v);
95937@@ -51,4 +53,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
95938 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
95939 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
95940
95941+#define atomic64_read_unchecked(v) atomic64_read(v)
95942+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
95943+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
95944+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
95945+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
95946+#define atomic64_inc_unchecked(v) atomic64_inc(v)
95947+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
95948+#define atomic64_dec_unchecked(v) atomic64_dec(v)
95949+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
95950+
95951 #endif /* _ASM_GENERIC_ATOMIC64_H */
95952diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h
95953index 55e3abc..104e2a1 100644
95954--- a/include/asm-generic/barrier.h
95955+++ b/include/asm-generic/barrier.h
95956@@ -108,7 +108,7 @@
95957 do { \
95958 compiletime_assert_atomic_type(*p); \
95959 smp_mb(); \
95960- ACCESS_ONCE(*p) = (v); \
95961+ ACCESS_ONCE_RW(*p) = (v); \
95962 } while (0)
95963
95964 #define smp_load_acquire(p) \
95965diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h
95966index a60a7cc..0fe12f2 100644
95967--- a/include/asm-generic/bitops/__fls.h
95968+++ b/include/asm-generic/bitops/__fls.h
95969@@ -9,7 +9,7 @@
95970 *
95971 * Undefined if no set bit exists, so code should check against 0 first.
95972 */
95973-static __always_inline unsigned long __fls(unsigned long word)
95974+static __always_inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
95975 {
95976 int num = BITS_PER_LONG - 1;
95977
95978diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
95979index 0576d1f..dad6c71 100644
95980--- a/include/asm-generic/bitops/fls.h
95981+++ b/include/asm-generic/bitops/fls.h
95982@@ -9,7 +9,7 @@
95983 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
95984 */
95985
95986-static __always_inline int fls(int x)
95987+static __always_inline int __intentional_overflow(-1) fls(int x)
95988 {
95989 int r = 32;
95990
95991diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h
95992index b097cf8..3d40e14 100644
95993--- a/include/asm-generic/bitops/fls64.h
95994+++ b/include/asm-generic/bitops/fls64.h
95995@@ -15,7 +15,7 @@
95996 * at position 64.
95997 */
95998 #if BITS_PER_LONG == 32
95999-static __always_inline int fls64(__u64 x)
96000+static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
96001 {
96002 __u32 h = x >> 32;
96003 if (h)
96004@@ -23,7 +23,7 @@ static __always_inline int fls64(__u64 x)
96005 return fls(x);
96006 }
96007 #elif BITS_PER_LONG == 64
96008-static __always_inline int fls64(__u64 x)
96009+static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
96010 {
96011 if (x == 0)
96012 return 0;
96013diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
96014index 630dd23..8c1dcb6b 100644
96015--- a/include/asm-generic/bug.h
96016+++ b/include/asm-generic/bug.h
96017@@ -62,13 +62,13 @@ struct bug_entry {
96018 * to provide better diagnostics.
96019 */
96020 #ifndef __WARN_TAINT
96021-extern __printf(3, 4)
96022+extern __printf(3, 4) __nocapture(1, 3, 4)
96023 void warn_slowpath_fmt(const char *file, const int line,
96024 const char *fmt, ...);
96025-extern __printf(4, 5)
96026+extern __printf(4, 5) __nocapture(1, 4, 5)
96027 void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint,
96028 const char *fmt, ...);
96029-extern void warn_slowpath_null(const char *file, const int line);
96030+extern __nocapture(1) void warn_slowpath_null(const char *file, const int line);
96031 #define WANT_WARN_ON_SLOWPATH
96032 #define __WARN() warn_slowpath_null(__FILE__, __LINE__)
96033 #define __WARN_printf(arg...) warn_slowpath_fmt(__FILE__, __LINE__, arg)
96034diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
96035index 1bfcfe5..e04c5c9 100644
96036--- a/include/asm-generic/cache.h
96037+++ b/include/asm-generic/cache.h
96038@@ -6,7 +6,7 @@
96039 * cache lines need to provide their own cache.h.
96040 */
96041
96042-#define L1_CACHE_SHIFT 5
96043-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
96044+#define L1_CACHE_SHIFT 5UL
96045+#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
96046
96047 #endif /* __ASM_GENERIC_CACHE_H */
96048diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
96049index 0d68a1e..b74a761 100644
96050--- a/include/asm-generic/emergency-restart.h
96051+++ b/include/asm-generic/emergency-restart.h
96052@@ -1,7 +1,7 @@
96053 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
96054 #define _ASM_GENERIC_EMERGENCY_RESTART_H
96055
96056-static inline void machine_emergency_restart(void)
96057+static inline __noreturn void machine_emergency_restart(void)
96058 {
96059 machine_restart(NULL);
96060 }
96061diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
96062index 90f99c7..00ce236 100644
96063--- a/include/asm-generic/kmap_types.h
96064+++ b/include/asm-generic/kmap_types.h
96065@@ -2,9 +2,9 @@
96066 #define _ASM_GENERIC_KMAP_TYPES_H
96067
96068 #ifdef __WITH_KM_FENCE
96069-# define KM_TYPE_NR 41
96070+# define KM_TYPE_NR 42
96071 #else
96072-# define KM_TYPE_NR 20
96073+# define KM_TYPE_NR 21
96074 #endif
96075
96076 #endif
96077diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
96078index 9ceb03b..62b0b8f 100644
96079--- a/include/asm-generic/local.h
96080+++ b/include/asm-generic/local.h
96081@@ -23,24 +23,37 @@ typedef struct
96082 atomic_long_t a;
96083 } local_t;
96084
96085+typedef struct {
96086+ atomic_long_unchecked_t a;
96087+} local_unchecked_t;
96088+
96089 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
96090
96091 #define local_read(l) atomic_long_read(&(l)->a)
96092+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
96093 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
96094+#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
96095 #define local_inc(l) atomic_long_inc(&(l)->a)
96096+#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
96097 #define local_dec(l) atomic_long_dec(&(l)->a)
96098+#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
96099 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
96100+#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
96101 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
96102+#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
96103
96104 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
96105 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
96106 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
96107 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
96108 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
96109+#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
96110 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
96111 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
96112+#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
96113
96114 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
96115+#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
96116 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
96117 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
96118 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
96119diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
96120index 725612b..9cc513a 100644
96121--- a/include/asm-generic/pgtable-nopmd.h
96122+++ b/include/asm-generic/pgtable-nopmd.h
96123@@ -1,14 +1,19 @@
96124 #ifndef _PGTABLE_NOPMD_H
96125 #define _PGTABLE_NOPMD_H
96126
96127-#ifndef __ASSEMBLY__
96128-
96129 #include <asm-generic/pgtable-nopud.h>
96130
96131-struct mm_struct;
96132-
96133 #define __PAGETABLE_PMD_FOLDED
96134
96135+#define PMD_SHIFT PUD_SHIFT
96136+#define PTRS_PER_PMD 1
96137+#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
96138+#define PMD_MASK (~(PMD_SIZE-1))
96139+
96140+#ifndef __ASSEMBLY__
96141+
96142+struct mm_struct;
96143+
96144 /*
96145 * Having the pmd type consist of a pud gets the size right, and allows
96146 * us to conceptually access the pud entry that this pmd is folded into
96147@@ -16,11 +21,6 @@ struct mm_struct;
96148 */
96149 typedef struct { pud_t pud; } pmd_t;
96150
96151-#define PMD_SHIFT PUD_SHIFT
96152-#define PTRS_PER_PMD 1
96153-#define PMD_SIZE (1UL << PMD_SHIFT)
96154-#define PMD_MASK (~(PMD_SIZE-1))
96155-
96156 /*
96157 * The "pud_xxx()" functions here are trivial for a folded two-level
96158 * setup: the pmd is never bad, and a pmd always exists (as it's folded
96159diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
96160index 810431d..0ec4804f 100644
96161--- a/include/asm-generic/pgtable-nopud.h
96162+++ b/include/asm-generic/pgtable-nopud.h
96163@@ -1,10 +1,15 @@
96164 #ifndef _PGTABLE_NOPUD_H
96165 #define _PGTABLE_NOPUD_H
96166
96167-#ifndef __ASSEMBLY__
96168-
96169 #define __PAGETABLE_PUD_FOLDED
96170
96171+#define PUD_SHIFT PGDIR_SHIFT
96172+#define PTRS_PER_PUD 1
96173+#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
96174+#define PUD_MASK (~(PUD_SIZE-1))
96175+
96176+#ifndef __ASSEMBLY__
96177+
96178 /*
96179 * Having the pud type consist of a pgd gets the size right, and allows
96180 * us to conceptually access the pgd entry that this pud is folded into
96181@@ -12,11 +17,6 @@
96182 */
96183 typedef struct { pgd_t pgd; } pud_t;
96184
96185-#define PUD_SHIFT PGDIR_SHIFT
96186-#define PTRS_PER_PUD 1
96187-#define PUD_SIZE (1UL << PUD_SHIFT)
96188-#define PUD_MASK (~(PUD_SIZE-1))
96189-
96190 /*
96191 * The "pgd_xxx()" functions here are trivial for a folded two-level
96192 * setup: the pud is never bad, and a pud always exists (as it's folded
96193@@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
96194 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
96195
96196 #define pgd_populate(mm, pgd, pud) do { } while (0)
96197+#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
96198 /*
96199 * (puds are folded into pgds so this doesn't get actually called,
96200 * but the define is needed for a generic inline function.)
96201diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
96202index 29c57b2..da571a2 100644
96203--- a/include/asm-generic/pgtable.h
96204+++ b/include/asm-generic/pgtable.h
96205@@ -715,6 +715,22 @@ static inline int pmd_protnone(pmd_t pmd)
96206 }
96207 #endif /* CONFIG_NUMA_BALANCING */
96208
96209+#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
96210+#ifdef CONFIG_PAX_KERNEXEC
96211+#error KERNEXEC requires pax_open_kernel
96212+#else
96213+static inline unsigned long pax_open_kernel(void) { return 0; }
96214+#endif
96215+#endif
96216+
96217+#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
96218+#ifdef CONFIG_PAX_KERNEXEC
96219+#error KERNEXEC requires pax_close_kernel
96220+#else
96221+static inline unsigned long pax_close_kernel(void) { return 0; }
96222+#endif
96223+#endif
96224+
96225 #endif /* CONFIG_MMU */
96226
96227 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
96228diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
96229index b58fd66..6cfae67 100644
96230--- a/include/asm-generic/sections.h
96231+++ b/include/asm-generic/sections.h
96232@@ -30,6 +30,7 @@ extern char _data[], _sdata[], _edata[];
96233 extern char __bss_start[], __bss_stop[];
96234 extern char __init_begin[], __init_end[];
96235 extern char _sinittext[], _einittext[];
96236+extern char _sinitdata[], _einitdata[];
96237 extern char _end[];
96238 extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[];
96239 extern char __kprobes_text_start[], __kprobes_text_end[];
96240diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
96241index 72d8803..cb9749c 100644
96242--- a/include/asm-generic/uaccess.h
96243+++ b/include/asm-generic/uaccess.h
96244@@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
96245 return __clear_user(to, n);
96246 }
96247
96248+#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
96249+#ifdef CONFIG_PAX_MEMORY_UDEREF
96250+#error UDEREF requires pax_open_userland
96251+#else
96252+static inline unsigned long pax_open_userland(void) { return 0; }
96253+#endif
96254+#endif
96255+
96256+#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
96257+#ifdef CONFIG_PAX_MEMORY_UDEREF
96258+#error UDEREF requires pax_close_userland
96259+#else
96260+static inline unsigned long pax_close_userland(void) { return 0; }
96261+#endif
96262+#endif
96263+
96264 #endif /* __ASM_GENERIC_UACCESS_H */
96265diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
96266index 8bd374d..2665ce3 100644
96267--- a/include/asm-generic/vmlinux.lds.h
96268+++ b/include/asm-generic/vmlinux.lds.h
96269@@ -246,6 +246,7 @@
96270 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
96271 VMLINUX_SYMBOL(__start_rodata) = .; \
96272 *(.rodata) *(.rodata.*) \
96273+ *(.data..read_only) \
96274 *(__vermagic) /* Kernel version magic */ \
96275 . = ALIGN(8); \
96276 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
96277@@ -504,6 +505,7 @@
96278 KERNEL_CTORS() \
96279 MCOUNT_REC() \
96280 *(.init.rodata) \
96281+ *(.init.rodata.*) \
96282 FTRACE_EVENTS() \
96283 TRACE_SYSCALLS() \
96284 KPROBE_BLACKLIST() \
96285@@ -525,6 +527,8 @@
96286
96287 #define EXIT_DATA \
96288 *(.exit.data) \
96289+ *(.exit.rodata) \
96290+ *(.exit.rodata.*) \
96291 MEM_DISCARD(exit.data) \
96292 MEM_DISCARD(exit.rodata)
96293
96294@@ -741,17 +745,18 @@
96295 * section in the linker script will go there too. @phdr should have
96296 * a leading colon.
96297 *
96298- * Note that this macros defines __per_cpu_load as an absolute symbol.
96299+ * Note that this macros defines per_cpu_load as an absolute symbol.
96300 * If there is no need to put the percpu section at a predetermined
96301 * address, use PERCPU_SECTION.
96302 */
96303 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
96304- VMLINUX_SYMBOL(__per_cpu_load) = .; \
96305- .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
96306+ per_cpu_load = .; \
96307+ .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
96308 - LOAD_OFFSET) { \
96309+ VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
96310 PERCPU_INPUT(cacheline) \
96311 } phdr \
96312- . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
96313+ . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
96314
96315 /**
96316 * PERCPU_SECTION - define output section for percpu area, simple version
96317@@ -813,12 +818,14 @@
96318
96319 #define INIT_DATA_SECTION(initsetup_align) \
96320 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \
96321+ VMLINUX_SYMBOL(_sinitdata) = .; \
96322 INIT_DATA \
96323 INIT_SETUP(initsetup_align) \
96324 INIT_CALLS \
96325 CON_INITCALL \
96326 SECURITY_INITCALL \
96327 INIT_RAM_FS \
96328+ VMLINUX_SYMBOL(_einitdata) = .; \
96329 }
96330
96331 #define BSS_SECTION(sbss_align, bss_align, stop_align) \
96332diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
96333index d4ebf6e..ca4bd35 100644
96334--- a/include/crypto/algapi.h
96335+++ b/include/crypto/algapi.h
96336@@ -35,7 +35,7 @@ struct crypto_type {
96337 unsigned int maskclear;
96338 unsigned int maskset;
96339 unsigned int tfmsize;
96340-};
96341+} __do_const;
96342
96343 struct crypto_instance {
96344 struct crypto_alg alg;
96345diff --git a/include/drm/drmP.h b/include/drm/drmP.h
96346index 5aa5197..e4ca348 100644
96347--- a/include/drm/drmP.h
96348+++ b/include/drm/drmP.h
96349@@ -59,6 +59,7 @@
96350
96351 #include <asm/mman.h>
96352 #include <asm/pgalloc.h>
96353+#include <asm/local.h>
96354 #include <asm/uaccess.h>
96355
96356 #include <uapi/drm/drm.h>
96357@@ -137,17 +138,18 @@ void drm_err(const char *format, ...);
96358 /*@{*/
96359
96360 /* driver capabilities and requirements mask */
96361-#define DRIVER_USE_AGP 0x1
96362-#define DRIVER_PCI_DMA 0x8
96363-#define DRIVER_SG 0x10
96364-#define DRIVER_HAVE_DMA 0x20
96365-#define DRIVER_HAVE_IRQ 0x40
96366-#define DRIVER_IRQ_SHARED 0x80
96367-#define DRIVER_GEM 0x1000
96368-#define DRIVER_MODESET 0x2000
96369-#define DRIVER_PRIME 0x4000
96370-#define DRIVER_RENDER 0x8000
96371-#define DRIVER_ATOMIC 0x10000
96372+#define DRIVER_USE_AGP 0x1
96373+#define DRIVER_PCI_DMA 0x8
96374+#define DRIVER_SG 0x10
96375+#define DRIVER_HAVE_DMA 0x20
96376+#define DRIVER_HAVE_IRQ 0x40
96377+#define DRIVER_IRQ_SHARED 0x80
96378+#define DRIVER_GEM 0x1000
96379+#define DRIVER_MODESET 0x2000
96380+#define DRIVER_PRIME 0x4000
96381+#define DRIVER_RENDER 0x8000
96382+#define DRIVER_ATOMIC 0x10000
96383+#define DRIVER_KMS_LEGACY_CONTEXT 0x20000
96384
96385 /***********************************************************************/
96386 /** \name Macros to make printk easier */
96387@@ -233,10 +235,12 @@ void drm_err(const char *format, ...);
96388 * \param cmd command.
96389 * \param arg argument.
96390 */
96391-typedef int drm_ioctl_t(struct drm_device *dev, void *data,
96392+typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
96393+ struct drm_file *file_priv);
96394+typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
96395 struct drm_file *file_priv);
96396
96397-typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
96398+typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
96399 unsigned long arg);
96400
96401 #define DRM_IOCTL_NR(n) _IOC_NR(n)
96402@@ -252,9 +256,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
96403 struct drm_ioctl_desc {
96404 unsigned int cmd;
96405 int flags;
96406- drm_ioctl_t *func;
96407+ drm_ioctl_t func;
96408 const char *name;
96409-};
96410+} __do_const;
96411
96412 /**
96413 * Creates a driver or general drm_ioctl_desc array entry for the given
96414@@ -647,7 +651,8 @@ struct drm_info_list {
96415 int (*show)(struct seq_file*, void*); /** show callback */
96416 u32 driver_features; /**< Required driver features for this entry */
96417 void *data;
96418-};
96419+} __do_const;
96420+typedef struct drm_info_list __no_const drm_info_list_no_const;
96421
96422 /**
96423 * debugfs node structure. This structure represents a debugfs file.
96424@@ -735,7 +740,7 @@ struct drm_device {
96425
96426 /** \name Usage Counters */
96427 /*@{ */
96428- int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
96429+ local_t open_count; /**< Outstanding files open, protected by drm_global_mutex. */
96430 spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
96431 int buf_use; /**< Buffers in use -- cannot alloc */
96432 atomic_t buf_alloc; /**< Buffer allocation in progress */
96433diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
96434index 918aa68..f162a8a 100644
96435--- a/include/drm/drm_crtc_helper.h
96436+++ b/include/drm/drm_crtc_helper.h
96437@@ -161,7 +161,7 @@ struct drm_encoder_helper_funcs {
96438 int (*atomic_check)(struct drm_encoder *encoder,
96439 struct drm_crtc_state *crtc_state,
96440 struct drm_connector_state *conn_state);
96441-};
96442+} __no_const;
96443
96444 /**
96445 * struct drm_connector_helper_funcs - helper operations for connectors
96446diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
96447index 0de6290..2a2c125 100644
96448--- a/include/drm/drm_mm.h
96449+++ b/include/drm/drm_mm.h
96450@@ -297,7 +297,7 @@ void drm_mm_remove_node(struct drm_mm_node *node);
96451 void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new);
96452 void drm_mm_init(struct drm_mm *mm,
96453 u64 start,
96454- u64 size);
96455+ u64 size) __intentional_overflow(3);
96456 void drm_mm_takedown(struct drm_mm *mm);
96457 bool drm_mm_clean(struct drm_mm *mm);
96458
96459diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
96460index 17c4456..da0c5eb 100644
96461--- a/include/drm/i915_pciids.h
96462+++ b/include/drm/i915_pciids.h
96463@@ -37,7 +37,7 @@
96464 */
96465 #define INTEL_VGA_DEVICE(id, info) { \
96466 0x8086, id, \
96467- ~0, ~0, \
96468+ PCI_ANY_ID, PCI_ANY_ID, \
96469 0x030000, 0xff0000, \
96470 (unsigned long) info }
96471
96472diff --git a/include/drm/intel-gtt.h b/include/drm/intel-gtt.h
96473index b08bdad..21e6054 100644
96474--- a/include/drm/intel-gtt.h
96475+++ b/include/drm/intel-gtt.h
96476@@ -3,8 +3,8 @@
96477 #ifndef _DRM_INTEL_GTT_H
96478 #define _DRM_INTEL_GTT_H
96479
96480-void intel_gtt_get(size_t *gtt_total, size_t *stolen_size,
96481- phys_addr_t *mappable_base, unsigned long *mappable_end);
96482+void intel_gtt_get(uint64_t *gtt_total, uint64_t *stolen_size,
96483+ uint64_t *mappable_base, uint64_t *mappable_end);
96484
96485 int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
96486 struct agp_bridge_data *bridge);
96487diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
96488index 72dcbe8..8db58d7 100644
96489--- a/include/drm/ttm/ttm_memory.h
96490+++ b/include/drm/ttm/ttm_memory.h
96491@@ -48,7 +48,7 @@
96492
96493 struct ttm_mem_shrink {
96494 int (*do_shrink) (struct ttm_mem_shrink *);
96495-};
96496+} __no_const;
96497
96498 /**
96499 * struct ttm_mem_global - Global memory accounting structure.
96500diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
96501index 49a8284..9643967 100644
96502--- a/include/drm/ttm/ttm_page_alloc.h
96503+++ b/include/drm/ttm/ttm_page_alloc.h
96504@@ -80,6 +80,7 @@ void ttm_dma_page_alloc_fini(void);
96505 */
96506 extern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);
96507
96508+struct device;
96509 extern int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev);
96510 extern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev);
96511
96512diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
96513index 4b840e8..155d235 100644
96514--- a/include/keys/asymmetric-subtype.h
96515+++ b/include/keys/asymmetric-subtype.h
96516@@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
96517 /* Verify the signature on a key of this subtype (optional) */
96518 int (*verify_signature)(const struct key *key,
96519 const struct public_key_signature *sig);
96520-};
96521+} __do_const;
96522
96523 /**
96524 * asymmetric_key_subtype - Get the subtype from an asymmetric key
96525diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
96526index c1da539..1dcec55 100644
96527--- a/include/linux/atmdev.h
96528+++ b/include/linux/atmdev.h
96529@@ -28,7 +28,7 @@ struct compat_atm_iobuf {
96530 #endif
96531
96532 struct k_atm_aal_stats {
96533-#define __HANDLE_ITEM(i) atomic_t i
96534+#define __HANDLE_ITEM(i) atomic_unchecked_t i
96535 __AAL_STAT_ITEMS
96536 #undef __HANDLE_ITEM
96537 };
96538@@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
96539 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
96540 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
96541 struct module *owner;
96542-};
96543+} __do_const ;
96544
96545 struct atmphy_ops {
96546 int (*start)(struct atm_dev *dev);
96547diff --git a/include/linux/atomic.h b/include/linux/atomic.h
96548index 5b08a85..60922fb 100644
96549--- a/include/linux/atomic.h
96550+++ b/include/linux/atomic.h
96551@@ -12,7 +12,7 @@
96552 * Atomically adds @a to @v, so long as @v was not already @u.
96553 * Returns non-zero if @v was not @u, and zero otherwise.
96554 */
96555-static inline int atomic_add_unless(atomic_t *v, int a, int u)
96556+static inline int __intentional_overflow(-1) atomic_add_unless(atomic_t *v, int a, int u)
96557 {
96558 return __atomic_add_unless(v, a, u) != u;
96559 }
96560diff --git a/include/linux/audit.h b/include/linux/audit.h
96561index c2e7e3a..8bfc0e1 100644
96562--- a/include/linux/audit.h
96563+++ b/include/linux/audit.h
96564@@ -223,7 +223,7 @@ static inline void audit_ptrace(struct task_struct *t)
96565 extern unsigned int audit_serial(void);
96566 extern int auditsc_get_stamp(struct audit_context *ctx,
96567 struct timespec *t, unsigned int *serial);
96568-extern int audit_set_loginuid(kuid_t loginuid);
96569+extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
96570
96571 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
96572 {
96573diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
96574index 576e463..28fd926 100644
96575--- a/include/linux/binfmts.h
96576+++ b/include/linux/binfmts.h
96577@@ -44,7 +44,7 @@ struct linux_binprm {
96578 unsigned interp_flags;
96579 unsigned interp_data;
96580 unsigned long loader, exec;
96581-};
96582+} __randomize_layout;
96583
96584 #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
96585 #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
96586@@ -77,8 +77,10 @@ struct linux_binfmt {
96587 int (*load_binary)(struct linux_binprm *);
96588 int (*load_shlib)(struct file *);
96589 int (*core_dump)(struct coredump_params *cprm);
96590+ void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
96591+ void (*handle_mmap)(struct file *);
96592 unsigned long min_coredump; /* minimal dump size */
96593-};
96594+} __do_const __randomize_layout;
96595
96596 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
96597
96598diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
96599index ea17cca..dd56e56 100644
96600--- a/include/linux/bitmap.h
96601+++ b/include/linux/bitmap.h
96602@@ -295,7 +295,7 @@ static inline int bitmap_full(const unsigned long *src, unsigned int nbits)
96603 return find_first_zero_bit(src, nbits) == nbits;
96604 }
96605
96606-static inline int bitmap_weight(const unsigned long *src, unsigned int nbits)
96607+static inline int __intentional_overflow(-1) bitmap_weight(const unsigned long *src, unsigned int nbits)
96608 {
96609 if (small_const_nbits(nbits))
96610 return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
96611diff --git a/include/linux/bitops.h b/include/linux/bitops.h
96612index 297f5bd..5892caa 100644
96613--- a/include/linux/bitops.h
96614+++ b/include/linux/bitops.h
96615@@ -75,7 +75,7 @@ static __inline__ int get_count_order(unsigned int count)
96616 return order;
96617 }
96618
96619-static inline unsigned long hweight_long(unsigned long w)
96620+static inline unsigned long __intentional_overflow(-1) hweight_long(unsigned long w)
96621 {
96622 return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
96623 }
96624@@ -105,7 +105,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
96625 * @word: value to rotate
96626 * @shift: bits to roll
96627 */
96628-static inline __u32 rol32(__u32 word, unsigned int shift)
96629+static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
96630 {
96631 return (word << shift) | (word >> (32 - shift));
96632 }
96633@@ -115,7 +115,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
96634 * @word: value to rotate
96635 * @shift: bits to roll
96636 */
96637-static inline __u32 ror32(__u32 word, unsigned int shift)
96638+static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
96639 {
96640 return (word >> shift) | (word << (32 - shift));
96641 }
96642@@ -171,7 +171,7 @@ static inline __s32 sign_extend32(__u32 value, int index)
96643 return (__s32)(value << shift) >> shift;
96644 }
96645
96646-static inline unsigned fls_long(unsigned long l)
96647+static inline unsigned __intentional_overflow(-1) fls_long(unsigned long l)
96648 {
96649 if (sizeof(l) == 4)
96650 return fls(l);
96651diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
96652index d4068c1..77159a1 100644
96653--- a/include/linux/blkdev.h
96654+++ b/include/linux/blkdev.h
96655@@ -1567,7 +1567,7 @@ struct block_device_operations {
96656 /* this callback is with swap_lock and sometimes page table lock held */
96657 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
96658 struct module *owner;
96659-};
96660+} __do_const;
96661
96662 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
96663 unsigned long);
96664diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
96665index afc1343..9735539 100644
96666--- a/include/linux/blktrace_api.h
96667+++ b/include/linux/blktrace_api.h
96668@@ -25,7 +25,7 @@ struct blk_trace {
96669 struct dentry *dropped_file;
96670 struct dentry *msg_file;
96671 struct list_head running_list;
96672- atomic_t dropped;
96673+ atomic_unchecked_t dropped;
96674 };
96675
96676 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
96677diff --git a/include/linux/cache.h b/include/linux/cache.h
96678index 17e7e82..1d7da26 100644
96679--- a/include/linux/cache.h
96680+++ b/include/linux/cache.h
96681@@ -16,6 +16,14 @@
96682 #define __read_mostly
96683 #endif
96684
96685+#ifndef __read_only
96686+#ifdef CONFIG_PAX_KERNEXEC
96687+#error KERNEXEC requires __read_only
96688+#else
96689+#define __read_only __read_mostly
96690+#endif
96691+#endif
96692+
96693 #ifndef ____cacheline_aligned
96694 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
96695 #endif
96696diff --git a/include/linux/capability.h b/include/linux/capability.h
96697index af9f0b9..71a5e5c 100644
96698--- a/include/linux/capability.h
96699+++ b/include/linux/capability.h
96700@@ -237,15 +237,28 @@ static inline bool capable(int cap)
96701 {
96702 return true;
96703 }
96704+static inline bool capable_nolog(int cap)
96705+{
96706+ return true;
96707+}
96708 static inline bool ns_capable(struct user_namespace *ns, int cap)
96709 {
96710 return true;
96711 }
96712+static inline bool ns_capable_nolog(struct user_namespace *ns, int cap)
96713+{
96714+ return true;
96715+}
96716 #endif /* CONFIG_MULTIUSER */
96717 extern bool capable_wrt_inode_uidgid(const struct inode *inode, int cap);
96718+extern bool capable_wrt_inode_uidgid_nolog(const struct inode *inode, int cap);
96719 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
96720+extern bool capable_nolog(int cap);
96721+extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
96722
96723 /* audit system wants to get cap info from files as well */
96724 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
96725
96726+extern int is_privileged_binary(const struct dentry *dentry);
96727+
96728 #endif /* !_LINUX_CAPABILITY_H */
96729diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
96730index 8609d57..86e4d79 100644
96731--- a/include/linux/cdrom.h
96732+++ b/include/linux/cdrom.h
96733@@ -87,7 +87,6 @@ struct cdrom_device_ops {
96734
96735 /* driver specifications */
96736 const int capability; /* capability flags */
96737- int n_minors; /* number of active minor devices */
96738 /* handle uniform packets for scsi type devices (scsi,atapi) */
96739 int (*generic_packet) (struct cdrom_device_info *,
96740 struct packet_command *);
96741diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
96742index bda5ec0b4..51d8ea1 100644
96743--- a/include/linux/cleancache.h
96744+++ b/include/linux/cleancache.h
96745@@ -35,7 +35,7 @@ struct cleancache_ops {
96746 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
96747 void (*invalidate_inode)(int, struct cleancache_filekey);
96748 void (*invalidate_fs)(int);
96749-};
96750+} __no_const;
96751
96752 extern int cleancache_register_ops(struct cleancache_ops *ops);
96753 extern void __cleancache_init_fs(struct super_block *);
96754diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
96755index 78842f4..7e7f81f 100644
96756--- a/include/linux/clk-provider.h
96757+++ b/include/linux/clk-provider.h
96758@@ -196,6 +196,7 @@ struct clk_ops {
96759 void (*init)(struct clk_hw *hw);
96760 int (*debug_init)(struct clk_hw *hw, struct dentry *dentry);
96761 };
96762+typedef struct clk_ops __no_const clk_ops_no_const;
96763
96764 /**
96765 * struct clk_init_data - holds init data that's common to all clocks and is
96766diff --git a/include/linux/compat.h b/include/linux/compat.h
96767index a76c917..63b52db 100644
96768--- a/include/linux/compat.h
96769+++ b/include/linux/compat.h
96770@@ -316,7 +316,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
96771 compat_size_t __user *len_ptr);
96772
96773 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
96774-asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
96775+asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
96776 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
96777 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
96778 compat_ssize_t msgsz, int msgflg);
96779@@ -325,7 +325,7 @@ asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp,
96780 long compat_sys_msgctl(int first, int second, void __user *uptr);
96781 long compat_sys_shmctl(int first, int second, void __user *uptr);
96782 long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
96783- unsigned nsems, const struct compat_timespec __user *timeout);
96784+ compat_long_t nsems, const struct compat_timespec __user *timeout);
96785 asmlinkage long compat_sys_keyctl(u32 option,
96786 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
96787 asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
96788@@ -439,7 +439,7 @@ extern int compat_ptrace_request(struct task_struct *child,
96789 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
96790 compat_ulong_t addr, compat_ulong_t data);
96791 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
96792- compat_long_t addr, compat_long_t data);
96793+ compat_ulong_t addr, compat_ulong_t data);
96794
96795 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t);
96796 /*
96797diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
96798index dfaa7b3..58cebfb 100644
96799--- a/include/linux/compiler-gcc.h
96800+++ b/include/linux/compiler-gcc.h
96801@@ -116,8 +116,8 @@
96802 */
96803 #define __pure __attribute__((pure))
96804 #define __aligned(x) __attribute__((aligned(x)))
96805-#define __printf(a, b) __attribute__((format(printf, a, b)))
96806-#define __scanf(a, b) __attribute__((format(scanf, a, b)))
96807+#define __printf(a, b) __attribute__((format(printf, a, b))) __nocapture(a, b)
96808+#define __scanf(a, b) __attribute__((format(scanf, a, b))) __nocapture(a, b)
96809 #define __attribute_const__ __attribute__((__const__))
96810 #define __maybe_unused __attribute__((unused))
96811 #define __always_unused __attribute__((unused))
96812@@ -184,9 +184,38 @@
96813 # define __compiletime_warning(message) __attribute__((warning(message)))
96814 # define __compiletime_error(message) __attribute__((error(message)))
96815 #endif /* __CHECKER__ */
96816+
96817+#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
96818+#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
96819+#define __bos0(ptr) __bos((ptr), 0)
96820+#define __bos1(ptr) __bos((ptr), 1)
96821 #endif /* GCC_VERSION >= 40300 */
96822
96823 #if GCC_VERSION >= 40500
96824+
96825+#ifdef RANDSTRUCT_PLUGIN
96826+#define __randomize_layout __attribute__((randomize_layout))
96827+#define __no_randomize_layout __attribute__((no_randomize_layout))
96828+#endif
96829+
96830+#ifdef CONSTIFY_PLUGIN
96831+#define __no_const __attribute__((no_const))
96832+#define __do_const __attribute__((do_const))
96833+#endif
96834+
96835+#ifdef SIZE_OVERFLOW_PLUGIN
96836+#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
96837+#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
96838+#endif
96839+
96840+#ifdef LATENT_ENTROPY_PLUGIN
96841+#define __latent_entropy __attribute__((latent_entropy))
96842+#endif
96843+
96844+#ifdef INITIFY_PLUGIN
96845+#define __nocapture(...) __attribute__((nocapture(__VA_ARGS__)))
96846+#endif
96847+
96848 /*
96849 * Mark a position in code as unreachable. This can be used to
96850 * suppress control flow warnings after asm blocks that transfer
96851diff --git a/include/linux/compiler.h b/include/linux/compiler.h
96852index e08a6ae..2e5e776 100644
96853--- a/include/linux/compiler.h
96854+++ b/include/linux/compiler.h
96855@@ -5,11 +5,14 @@
96856
96857 #ifdef __CHECKER__
96858 # define __user __attribute__((noderef, address_space(1)))
96859+# define __force_user __force __user
96860 # define __kernel __attribute__((address_space(0)))
96861+# define __force_kernel __force __kernel
96862 # define __safe __attribute__((safe))
96863 # define __force __attribute__((force))
96864 # define __nocast __attribute__((nocast))
96865 # define __iomem __attribute__((noderef, address_space(2)))
96866+# define __force_iomem __force __iomem
96867 # define __must_hold(x) __attribute__((context(x,1,1)))
96868 # define __acquires(x) __attribute__((context(x,0,1)))
96869 # define __releases(x) __attribute__((context(x,1,0)))
96870@@ -17,21 +20,39 @@
96871 # define __release(x) __context__(x,-1)
96872 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
96873 # define __percpu __attribute__((noderef, address_space(3)))
96874+# define __force_percpu __force __percpu
96875 # define __pmem __attribute__((noderef, address_space(5)))
96876+# define __force_pmem __force __pmem
96877 #ifdef CONFIG_SPARSE_RCU_POINTER
96878 # define __rcu __attribute__((noderef, address_space(4)))
96879+# define __force_rcu __force __rcu
96880 #else
96881 # define __rcu
96882+# define __force_rcu
96883 #endif
96884 extern void __chk_user_ptr(const volatile void __user *);
96885 extern void __chk_io_ptr(const volatile void __iomem *);
96886 #else
96887-# define __user
96888-# define __kernel
96889+# ifdef CHECKER_PLUGIN
96890+//# define __user
96891+//# define __force_user
96892+//# define __kernel
96893+//# define __force_kernel
96894+# else
96895+# ifdef STRUCTLEAK_PLUGIN
96896+# define __user __attribute__((user))
96897+# else
96898+# define __user
96899+# endif
96900+# define __force_user
96901+# define __kernel
96902+# define __force_kernel
96903+# endif
96904 # define __safe
96905 # define __force
96906 # define __nocast
96907 # define __iomem
96908+# define __force_iomem
96909 # define __chk_user_ptr(x) (void)0
96910 # define __chk_io_ptr(x) (void)0
96911 # define __builtin_warning(x, y...) (1)
96912@@ -42,8 +63,11 @@ extern void __chk_io_ptr(const volatile void __iomem *);
96913 # define __release(x) (void)0
96914 # define __cond_lock(x,c) (c)
96915 # define __percpu
96916+# define __force_percpu
96917 # define __rcu
96918+# define __force_rcu
96919 # define __pmem
96920+# define __force_pmem
96921 #endif
96922
96923 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
96924@@ -201,27 +225,27 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
96925 static __always_inline void __read_once_size(const volatile void *p, void *res, int size)
96926 {
96927 switch (size) {
96928- case 1: *(__u8 *)res = *(volatile __u8 *)p; break;
96929- case 2: *(__u16 *)res = *(volatile __u16 *)p; break;
96930- case 4: *(__u32 *)res = *(volatile __u32 *)p; break;
96931- case 8: *(__u64 *)res = *(volatile __u64 *)p; break;
96932+ case 1: *(__u8 *)res = *(const volatile __u8 *)p; break;
96933+ case 2: *(__u16 *)res = *(const volatile __u16 *)p; break;
96934+ case 4: *(__u32 *)res = *(const volatile __u32 *)p; break;
96935+ case 8: *(__u64 *)res = *(const volatile __u64 *)p; break;
96936 default:
96937 barrier();
96938- __builtin_memcpy((void *)res, (const void *)p, size);
96939+ __builtin_memcpy(res, (const void *)p, size);
96940 barrier();
96941 }
96942 }
96943
96944-static __always_inline void __write_once_size(volatile void *p, void *res, int size)
96945+static __always_inline void __write_once_size(volatile void *p, const void *res, int size)
96946 {
96947 switch (size) {
96948- case 1: *(volatile __u8 *)p = *(__u8 *)res; break;
96949- case 2: *(volatile __u16 *)p = *(__u16 *)res; break;
96950- case 4: *(volatile __u32 *)p = *(__u32 *)res; break;
96951- case 8: *(volatile __u64 *)p = *(__u64 *)res; break;
96952+ case 1: *(volatile __u8 *)p = *(const __u8 *)res; break;
96953+ case 2: *(volatile __u16 *)p = *(const __u16 *)res; break;
96954+ case 4: *(volatile __u32 *)p = *(const __u32 *)res; break;
96955+ case 8: *(volatile __u64 *)p = *(const __u64 *)res; break;
96956 default:
96957 barrier();
96958- __builtin_memcpy((void *)p, (const void *)res, size);
96959+ __builtin_memcpy((void *)p, res, size);
96960 barrier();
96961 }
96962 }
96963@@ -370,6 +394,38 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
96964 # define __attribute_const__ /* unimplemented */
96965 #endif
96966
96967+#ifndef __randomize_layout
96968+# define __randomize_layout
96969+#endif
96970+
96971+#ifndef __no_randomize_layout
96972+# define __no_randomize_layout
96973+#endif
96974+
96975+#ifndef __no_const
96976+# define __no_const
96977+#endif
96978+
96979+#ifndef __do_const
96980+# define __do_const
96981+#endif
96982+
96983+#ifndef __size_overflow
96984+# define __size_overflow(...)
96985+#endif
96986+
96987+#ifndef __intentional_overflow
96988+# define __intentional_overflow(...)
96989+#endif
96990+
96991+#ifndef __latent_entropy
96992+# define __latent_entropy
96993+#endif
96994+
96995+#ifndef __nocapture
96996+# define __nocapture(...)
96997+#endif
96998+
96999 /*
97000 * Tell gcc if a function is cold. The compiler will assume any path
97001 * directly leading to the call is unlikely.
97002@@ -379,6 +435,22 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
97003 #define __cold
97004 #endif
97005
97006+#ifndef __alloc_size
97007+#define __alloc_size(...)
97008+#endif
97009+
97010+#ifndef __bos
97011+#define __bos(ptr, arg)
97012+#endif
97013+
97014+#ifndef __bos0
97015+#define __bos0(ptr)
97016+#endif
97017+
97018+#ifndef __bos1
97019+#define __bos1(ptr)
97020+#endif
97021+
97022 /* Simple shorthand for a section definition */
97023 #ifndef __section
97024 # define __section(S) __attribute__ ((__section__(#S)))
97025@@ -393,6 +465,8 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
97026 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
97027 #endif
97028
97029+#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))
97030+
97031 /* Is this type a native word size -- useful for atomic operations */
97032 #ifndef __native_word
97033 # define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
97034@@ -472,8 +546,9 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
97035 */
97036 #define __ACCESS_ONCE(x) ({ \
97037 __maybe_unused typeof(x) __var = (__force typeof(x)) 0; \
97038- (volatile typeof(x) *)&(x); })
97039+ (volatile const typeof(x) *)&(x); })
97040 #define ACCESS_ONCE(x) (*__ACCESS_ONCE(x))
97041+#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
97042
97043 /**
97044 * lockless_dereference() - safely load a pointer for later dereference
97045diff --git a/include/linux/configfs.h b/include/linux/configfs.h
97046index 63a36e8..26b0825 100644
97047--- a/include/linux/configfs.h
97048+++ b/include/linux/configfs.h
97049@@ -125,7 +125,7 @@ struct configfs_attribute {
97050 const char *ca_name;
97051 struct module *ca_owner;
97052 umode_t ca_mode;
97053-};
97054+} __do_const;
97055
97056 /*
97057 * Users often need to create attribute structures for their configurable
97058diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
97059index bde1e56..168de74 100644
97060--- a/include/linux/cpufreq.h
97061+++ b/include/linux/cpufreq.h
97062@@ -211,6 +211,7 @@ struct global_attr {
97063 ssize_t (*store)(struct kobject *a, struct attribute *b,
97064 const char *c, size_t count);
97065 };
97066+typedef struct global_attr __no_const global_attr_no_const;
97067
97068 #define define_one_global_ro(_name) \
97069 static struct global_attr _name = \
97070@@ -282,7 +283,7 @@ struct cpufreq_driver {
97071 bool boost_supported;
97072 bool boost_enabled;
97073 int (*set_boost)(int state);
97074-};
97075+} __do_const;
97076
97077 /* flags */
97078 #define CPUFREQ_STICKY (1 << 0) /* driver isn't removed even if
97079diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
97080index d075d34..3b6734a 100644
97081--- a/include/linux/cpuidle.h
97082+++ b/include/linux/cpuidle.h
97083@@ -59,7 +59,8 @@ struct cpuidle_state {
97084 void (*enter_freeze) (struct cpuidle_device *dev,
97085 struct cpuidle_driver *drv,
97086 int index);
97087-};
97088+} __do_const;
97089+typedef struct cpuidle_state __no_const cpuidle_state_no_const;
97090
97091 /* Idle State Flags */
97092 #define CPUIDLE_FLAG_COUPLED (0x02) /* state applies to multiple cpus */
97093@@ -235,7 +236,7 @@ struct cpuidle_governor {
97094 void (*reflect) (struct cpuidle_device *dev, int index);
97095
97096 struct module *owner;
97097-};
97098+} __do_const;
97099
97100 #ifdef CONFIG_CPU_IDLE
97101 extern int cpuidle_register_governor(struct cpuidle_governor *gov);
97102diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
97103index 59915ea..81ebec0 100644
97104--- a/include/linux/cpumask.h
97105+++ b/include/linux/cpumask.h
97106@@ -127,17 +127,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
97107 }
97108
97109 /* Valid inputs for n are -1 and 0. */
97110-static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
97111+static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
97112 {
97113 return n+1;
97114 }
97115
97116-static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
97117+static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
97118 {
97119 return n+1;
97120 }
97121
97122-static inline unsigned int cpumask_next_and(int n,
97123+static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
97124 const struct cpumask *srcp,
97125 const struct cpumask *andp)
97126 {
97127@@ -181,7 +181,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
97128 *
97129 * Returns >= nr_cpu_ids if no further cpus set.
97130 */
97131-static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
97132+static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
97133 {
97134 /* -1 is a legal arg here. */
97135 if (n != -1)
97136@@ -196,7 +196,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
97137 *
97138 * Returns >= nr_cpu_ids if no further cpus unset.
97139 */
97140-static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
97141+static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
97142 {
97143 /* -1 is a legal arg here. */
97144 if (n != -1)
97145@@ -204,7 +204,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
97146 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
97147 }
97148
97149-int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
97150+int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
97151 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
97152 unsigned int cpumask_local_spread(unsigned int i, int node);
97153
97154@@ -471,7 +471,7 @@ static inline bool cpumask_full(const struct cpumask *srcp)
97155 * cpumask_weight - Count of bits in *srcp
97156 * @srcp: the cpumask to count bits (< nr_cpu_ids) in.
97157 */
97158-static inline unsigned int cpumask_weight(const struct cpumask *srcp)
97159+static inline unsigned int __intentional_overflow(-1) cpumask_weight(const struct cpumask *srcp)
97160 {
97161 return bitmap_weight(cpumask_bits(srcp), nr_cpumask_bits);
97162 }
97163diff --git a/include/linux/cred.h b/include/linux/cred.h
97164index 8b6c083..51cb9f5 100644
97165--- a/include/linux/cred.h
97166+++ b/include/linux/cred.h
97167@@ -35,7 +35,7 @@ struct group_info {
97168 int nblocks;
97169 kgid_t small_block[NGROUPS_SMALL];
97170 kgid_t *blocks[0];
97171-};
97172+} __randomize_layout;
97173
97174 /**
97175 * get_group_info - Get a reference to a group info structure
97176@@ -152,7 +152,7 @@ struct cred {
97177 struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */
97178 struct group_info *group_info; /* supplementary groups for euid/fsgid */
97179 struct rcu_head rcu; /* RCU deletion hook */
97180-};
97181+} __randomize_layout;
97182
97183 extern void __put_cred(struct cred *);
97184 extern void exit_creds(struct task_struct *);
97185@@ -210,6 +210,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
97186 static inline void validate_process_creds(void)
97187 {
97188 }
97189+static inline void validate_task_creds(struct task_struct *task)
97190+{
97191+}
97192 #endif
97193
97194 /**
97195@@ -347,6 +350,7 @@ static inline void put_cred(const struct cred *_cred)
97196
97197 #define task_uid(task) (task_cred_xxx((task), uid))
97198 #define task_euid(task) (task_cred_xxx((task), euid))
97199+#define task_securebits(task) (task_cred_xxx((task), securebits))
97200
97201 #define current_cred_xxx(xxx) \
97202 ({ \
97203diff --git a/include/linux/crypto.h b/include/linux/crypto.h
97204index 81ef938..9ec0fdb 100644
97205--- a/include/linux/crypto.h
97206+++ b/include/linux/crypto.h
97207@@ -569,7 +569,7 @@ struct cipher_tfm {
97208 const u8 *key, unsigned int keylen);
97209 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
97210 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
97211-};
97212+} __no_const;
97213
97214 struct hash_tfm {
97215 int (*init)(struct hash_desc *desc);
97216@@ -590,7 +590,7 @@ struct compress_tfm {
97217 int (*cot_decompress)(struct crypto_tfm *tfm,
97218 const u8 *src, unsigned int slen,
97219 u8 *dst, unsigned int *dlen);
97220-};
97221+} __no_const;
97222
97223 #define crt_ablkcipher crt_u.ablkcipher
97224 #define crt_blkcipher crt_u.blkcipher
97225diff --git a/include/linux/ctype.h b/include/linux/ctype.h
97226index 653589e..4ef254a 100644
97227--- a/include/linux/ctype.h
97228+++ b/include/linux/ctype.h
97229@@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
97230 * Fast implementation of tolower() for internal usage. Do not use in your
97231 * code.
97232 */
97233-static inline char _tolower(const char c)
97234+static inline unsigned char _tolower(const unsigned char c)
97235 {
97236 return c | 0x20;
97237 }
97238diff --git a/include/linux/dcache.h b/include/linux/dcache.h
97239index d67ae11..9ec20d2 100644
97240--- a/include/linux/dcache.h
97241+++ b/include/linux/dcache.h
97242@@ -123,6 +123,9 @@ struct dentry {
97243 unsigned long d_time; /* used by d_revalidate */
97244 void *d_fsdata; /* fs-specific data */
97245
97246+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
97247+ atomic_t chroot_refcnt; /* tracks use of directory in chroot */
97248+#endif
97249 struct list_head d_lru; /* LRU list */
97250 struct list_head d_child; /* child of parent list */
97251 struct list_head d_subdirs; /* our children */
97252@@ -133,7 +136,7 @@ struct dentry {
97253 struct hlist_node d_alias; /* inode alias list */
97254 struct rcu_head d_rcu;
97255 } d_u;
97256-};
97257+} __randomize_layout;
97258
97259 /*
97260 * dentry->d_lock spinlock nesting subclasses:
97261@@ -321,7 +324,7 @@ extern struct dentry *__d_lookup_rcu(const struct dentry *parent,
97262
97263 static inline unsigned d_count(const struct dentry *dentry)
97264 {
97265- return dentry->d_lockref.count;
97266+ return __lockref_read(&dentry->d_lockref);
97267 }
97268
97269 /*
97270@@ -350,7 +353,7 @@ extern char *dentry_path(struct dentry *, char *, int);
97271 static inline struct dentry *dget_dlock(struct dentry *dentry)
97272 {
97273 if (dentry)
97274- dentry->d_lockref.count++;
97275+ __lockref_inc(&dentry->d_lockref);
97276 return dentry;
97277 }
97278
97279diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
97280index 7925bf0..d5143d2 100644
97281--- a/include/linux/decompress/mm.h
97282+++ b/include/linux/decompress/mm.h
97283@@ -77,7 +77,7 @@ static void free(void *where)
97284 * warnings when not needed (indeed large_malloc / large_free are not
97285 * needed by inflate */
97286
97287-#define malloc(a) kmalloc(a, GFP_KERNEL)
97288+#define malloc(a) kmalloc((a), GFP_KERNEL)
97289 #define free(a) kfree(a)
97290
97291 #define large_malloc(a) vmalloc(a)
97292diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
97293index ce447f0..83c66bd 100644
97294--- a/include/linux/devfreq.h
97295+++ b/include/linux/devfreq.h
97296@@ -114,7 +114,7 @@ struct devfreq_governor {
97297 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
97298 int (*event_handler)(struct devfreq *devfreq,
97299 unsigned int event, void *data);
97300-};
97301+} __do_const;
97302
97303 /**
97304 * struct devfreq - Device devfreq structure
97305diff --git a/include/linux/device.h b/include/linux/device.h
97306index a2b4ea7..b07dddd 100644
97307--- a/include/linux/device.h
97308+++ b/include/linux/device.h
97309@@ -342,7 +342,7 @@ struct subsys_interface {
97310 struct list_head node;
97311 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
97312 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
97313-};
97314+} __do_const;
97315
97316 int subsys_interface_register(struct subsys_interface *sif);
97317 void subsys_interface_unregister(struct subsys_interface *sif);
97318@@ -538,7 +538,7 @@ struct device_type {
97319 void (*release)(struct device *dev);
97320
97321 const struct dev_pm_ops *pm;
97322-};
97323+} __do_const;
97324
97325 /* interface for exporting device attributes */
97326 struct device_attribute {
97327@@ -548,11 +548,12 @@ struct device_attribute {
97328 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
97329 const char *buf, size_t count);
97330 };
97331+typedef struct device_attribute __no_const device_attribute_no_const;
97332
97333 struct dev_ext_attribute {
97334 struct device_attribute attr;
97335 void *var;
97336-};
97337+} __do_const;
97338
97339 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
97340 char *buf);
97341diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
97342index ac07ff0..edff186 100644
97343--- a/include/linux/dma-mapping.h
97344+++ b/include/linux/dma-mapping.h
97345@@ -64,7 +64,7 @@ struct dma_map_ops {
97346 u64 (*get_required_mask)(struct device *dev);
97347 #endif
97348 int is_phys;
97349-};
97350+} __do_const;
97351
97352 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
97353
97354diff --git a/include/linux/efi.h b/include/linux/efi.h
97355index 85ef051..2714c3b 100644
97356--- a/include/linux/efi.h
97357+++ b/include/linux/efi.h
97358@@ -1073,6 +1073,7 @@ struct efivar_operations {
97359 efi_set_variable_nonblocking_t *set_variable_nonblocking;
97360 efi_query_variable_store_t *query_variable_store;
97361 };
97362+typedef struct efivar_operations __no_const efivar_operations_no_const;
97363
97364 struct efivars {
97365 /*
97366diff --git a/include/linux/elf.h b/include/linux/elf.h
97367index 20fa8d8..3d0dd18 100644
97368--- a/include/linux/elf.h
97369+++ b/include/linux/elf.h
97370@@ -29,6 +29,7 @@ extern Elf32_Dyn _DYNAMIC [];
97371 #define elf_note elf32_note
97372 #define elf_addr_t Elf32_Off
97373 #define Elf_Half Elf32_Half
97374+#define elf_dyn Elf32_Dyn
97375
97376 #else
97377
97378@@ -39,6 +40,7 @@ extern Elf64_Dyn _DYNAMIC [];
97379 #define elf_note elf64_note
97380 #define elf_addr_t Elf64_Off
97381 #define Elf_Half Elf64_Half
97382+#define elf_dyn Elf64_Dyn
97383
97384 #endif
97385
97386diff --git a/include/linux/err.h b/include/linux/err.h
97387index a729120..6ede2c9 100644
97388--- a/include/linux/err.h
97389+++ b/include/linux/err.h
97390@@ -20,12 +20,12 @@
97391
97392 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
97393
97394-static inline void * __must_check ERR_PTR(long error)
97395+static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
97396 {
97397 return (void *) error;
97398 }
97399
97400-static inline long __must_check PTR_ERR(__force const void *ptr)
97401+static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
97402 {
97403 return (long) ptr;
97404 }
97405diff --git a/include/linux/extcon.h b/include/linux/extcon.h
97406index b16d929..d389bf1 100644
97407--- a/include/linux/extcon.h
97408+++ b/include/linux/extcon.h
97409@@ -120,7 +120,7 @@ struct extcon_dev {
97410 /* /sys/class/extcon/.../mutually_exclusive/... */
97411 struct attribute_group attr_g_muex;
97412 struct attribute **attrs_muex;
97413- struct device_attribute *d_attrs_muex;
97414+ device_attribute_no_const *d_attrs_muex;
97415 };
97416
97417 /**
97418diff --git a/include/linux/fb.h b/include/linux/fb.h
97419index 043f328..180ccbf 100644
97420--- a/include/linux/fb.h
97421+++ b/include/linux/fb.h
97422@@ -305,7 +305,8 @@ struct fb_ops {
97423 /* called at KDB enter and leave time to prepare the console */
97424 int (*fb_debug_enter)(struct fb_info *info);
97425 int (*fb_debug_leave)(struct fb_info *info);
97426-};
97427+} __do_const;
97428+typedef struct fb_ops __no_const fb_ops_no_const;
97429
97430 #ifdef CONFIG_FB_TILEBLITTING
97431 #define FB_TILE_CURSOR_NONE 0
97432diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
97433index fbb8874..15c61e7 100644
97434--- a/include/linux/fdtable.h
97435+++ b/include/linux/fdtable.h
97436@@ -103,7 +103,7 @@ struct files_struct *get_files_struct(struct task_struct *);
97437 void put_files_struct(struct files_struct *fs);
97438 void reset_files_struct(struct files_struct *);
97439 int unshare_files(struct files_struct **);
97440-struct files_struct *dup_fd(struct files_struct *, int *);
97441+struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
97442 void do_close_on_exec(struct files_struct *);
97443 int iterate_fd(struct files_struct *, unsigned,
97444 int (*)(const void *, struct file *, unsigned),
97445diff --git a/include/linux/fs.h b/include/linux/fs.h
97446index 84b783f..b31767d 100644
97447--- a/include/linux/fs.h
97448+++ b/include/linux/fs.h
97449@@ -439,7 +439,7 @@ struct address_space {
97450 spinlock_t private_lock; /* for use by the address_space */
97451 struct list_head private_list; /* ditto */
97452 void *private_data; /* ditto */
97453-} __attribute__((aligned(sizeof(long))));
97454+} __attribute__((aligned(sizeof(long)))) __randomize_layout;
97455 /*
97456 * On most architectures that alignment is already the case; but
97457 * must be enforced here for CRIS, to let the least significant bit
97458@@ -482,7 +482,7 @@ struct block_device {
97459 int bd_fsfreeze_count;
97460 /* Mutex for freeze */
97461 struct mutex bd_fsfreeze_mutex;
97462-};
97463+} __randomize_layout;
97464
97465 /*
97466 * Radix-tree tags, for tagging dirty and writeback pages within the pagecache
97467@@ -677,7 +677,7 @@ struct inode {
97468 #endif
97469
97470 void *i_private; /* fs or device private pointer */
97471-};
97472+} __randomize_layout;
97473
97474 static inline int inode_unhashed(struct inode *inode)
97475 {
97476@@ -872,7 +872,7 @@ struct file {
97477 struct list_head f_tfile_llink;
97478 #endif /* #ifdef CONFIG_EPOLL */
97479 struct address_space *f_mapping;
97480-} __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */
97481+} __attribute__((aligned(4))) __randomize_layout; /* lest something weird decides that 2 is OK */
97482
97483 struct file_handle {
97484 __u32 handle_bytes;
97485@@ -1001,7 +1001,7 @@ struct file_lock {
97486 int state; /* state of grant or error if -ve */
97487 } afs;
97488 } fl_u;
97489-};
97490+} __randomize_layout;
97491
97492 struct file_lock_context {
97493 spinlock_t flc_lock;
97494@@ -1380,7 +1380,7 @@ struct super_block {
97495 * Indicates how deep in a filesystem stack this SB is
97496 */
97497 int s_stack_depth;
97498-};
97499+} __randomize_layout;
97500
97501 extern struct timespec current_fs_time(struct super_block *sb);
97502
97503@@ -1632,7 +1632,8 @@ struct file_operations {
97504 #ifndef CONFIG_MMU
97505 unsigned (*mmap_capabilities)(struct file *);
97506 #endif
97507-};
97508+} __do_const __randomize_layout;
97509+typedef struct file_operations __no_const file_operations_no_const;
97510
97511 struct inode_operations {
97512 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
97513@@ -2341,7 +2342,7 @@ extern int register_chrdev_region(dev_t, unsigned, const char *);
97514 extern int __register_chrdev(unsigned int major, unsigned int baseminor,
97515 unsigned int count, const char *name,
97516 const struct file_operations *fops);
97517-extern void __unregister_chrdev(unsigned int major, unsigned int baseminor,
97518+extern __nocapture(4) void __unregister_chrdev(unsigned int major, unsigned int baseminor,
97519 unsigned int count, const char *name);
97520 extern void unregister_chrdev_region(dev_t, unsigned);
97521 extern void chrdev_show(struct seq_file *,off_t);
97522@@ -3041,4 +3042,14 @@ static inline bool dir_relax(struct inode *inode)
97523 return !IS_DEADDIR(inode);
97524 }
97525
97526+static inline bool is_sidechannel_device(const struct inode *inode)
97527+{
97528+#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
97529+ umode_t mode = inode->i_mode;
97530+ return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
97531+#else
97532+ return false;
97533+#endif
97534+}
97535+
97536 #endif /* _LINUX_FS_H */
97537diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
97538index 0efc3e6..fd23610 100644
97539--- a/include/linux/fs_struct.h
97540+++ b/include/linux/fs_struct.h
97541@@ -6,13 +6,13 @@
97542 #include <linux/seqlock.h>
97543
97544 struct fs_struct {
97545- int users;
97546+ atomic_t users;
97547 spinlock_t lock;
97548 seqcount_t seq;
97549 int umask;
97550 int in_exec;
97551 struct path root, pwd;
97552-};
97553+} __randomize_layout;
97554
97555 extern struct kmem_cache *fs_cachep;
97556
97557diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
97558index 604e152..5954d0d 100644
97559--- a/include/linux/fscache-cache.h
97560+++ b/include/linux/fscache-cache.h
97561@@ -117,7 +117,7 @@ struct fscache_operation {
97562 fscache_operation_release_t release;
97563 };
97564
97565-extern atomic_t fscache_op_debug_id;
97566+extern atomic_unchecked_t fscache_op_debug_id;
97567 extern void fscache_op_work_func(struct work_struct *work);
97568
97569 extern void fscache_enqueue_operation(struct fscache_operation *);
97570diff --git a/include/linux/fscache.h b/include/linux/fscache.h
97571index 115bb81..e7b812b 100644
97572--- a/include/linux/fscache.h
97573+++ b/include/linux/fscache.h
97574@@ -152,7 +152,7 @@ struct fscache_cookie_def {
97575 * - this is mandatory for any object that may have data
97576 */
97577 void (*now_uncached)(void *cookie_netfs_data);
97578-};
97579+} __do_const;
97580
97581 /*
97582 * fscache cached network filesystem type
97583diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
97584index 7ee1774..72505b8 100644
97585--- a/include/linux/fsnotify.h
97586+++ b/include/linux/fsnotify.h
97587@@ -197,6 +197,9 @@ static inline void fsnotify_access(struct file *file)
97588 struct inode *inode = file_inode(file);
97589 __u32 mask = FS_ACCESS;
97590
97591+ if (is_sidechannel_device(inode))
97592+ return;
97593+
97594 if (S_ISDIR(inode->i_mode))
97595 mask |= FS_ISDIR;
97596
97597@@ -215,6 +218,9 @@ static inline void fsnotify_modify(struct file *file)
97598 struct inode *inode = file_inode(file);
97599 __u32 mask = FS_MODIFY;
97600
97601+ if (is_sidechannel_device(inode))
97602+ return;
97603+
97604 if (S_ISDIR(inode->i_mode))
97605 mask |= FS_ISDIR;
97606
97607@@ -317,7 +323,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
97608 */
97609 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
97610 {
97611- return kstrdup(name, GFP_KERNEL);
97612+ return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
97613 }
97614
97615 /*
97616diff --git a/include/linux/genhd.h b/include/linux/genhd.h
97617index ec274e0..e678159 100644
97618--- a/include/linux/genhd.h
97619+++ b/include/linux/genhd.h
97620@@ -194,7 +194,7 @@ struct gendisk {
97621 struct kobject *slave_dir;
97622
97623 struct timer_rand_state *random;
97624- atomic_t sync_io; /* RAID */
97625+ atomic_unchecked_t sync_io; /* RAID */
97626 struct disk_events *ev;
97627 #ifdef CONFIG_BLK_DEV_INTEGRITY
97628 struct blk_integrity *integrity;
97629@@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
97630 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
97631
97632 /* drivers/char/random.c */
97633-extern void add_disk_randomness(struct gendisk *disk);
97634+extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
97635 extern void rand_initialize_disk(struct gendisk *disk);
97636
97637 static inline sector_t get_start_sect(struct block_device *bdev)
97638diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
97639index 667c311..abac2a7 100644
97640--- a/include/linux/genl_magic_func.h
97641+++ b/include/linux/genl_magic_func.h
97642@@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
97643 },
97644
97645 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
97646-static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
97647+static struct genl_ops ZZZ_genl_ops[] = {
97648 #include GENL_MAGIC_INCLUDE_FILE
97649 };
97650
97651diff --git a/include/linux/gfp.h b/include/linux/gfp.h
97652index ad35f30..30b1916 100644
97653--- a/include/linux/gfp.h
97654+++ b/include/linux/gfp.h
97655@@ -35,6 +35,13 @@ struct vm_area_struct;
97656 #define ___GFP_NO_KSWAPD 0x400000u
97657 #define ___GFP_OTHER_NODE 0x800000u
97658 #define ___GFP_WRITE 0x1000000u
97659+
97660+#ifdef CONFIG_PAX_USERCOPY_SLABS
97661+#define ___GFP_USERCOPY 0x2000000u
97662+#else
97663+#define ___GFP_USERCOPY 0
97664+#endif
97665+
97666 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
97667
97668 /*
97669@@ -94,6 +101,7 @@ struct vm_area_struct;
97670 #define __GFP_NO_KSWAPD ((__force gfp_t)___GFP_NO_KSWAPD)
97671 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
97672 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
97673+#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
97674
97675 /*
97676 * This may seem redundant, but it's a way of annotating false positives vs.
97677@@ -101,7 +109,7 @@ struct vm_area_struct;
97678 */
97679 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
97680
97681-#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
97682+#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
97683 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
97684
97685 /* This equals 0, but use constants in case they ever change */
97686@@ -146,6 +154,8 @@ struct vm_area_struct;
97687 /* 4GB DMA on some platforms */
97688 #define GFP_DMA32 __GFP_DMA32
97689
97690+#define GFP_USERCOPY __GFP_USERCOPY
97691+
97692 /* Convert GFP flags to their corresponding migrate type */
97693 static inline int gfpflags_to_migratetype(const gfp_t gfp_flags)
97694 {
97695diff --git a/include/linux/gracl.h b/include/linux/gracl.h
97696new file mode 100644
97697index 0000000..91858e4
97698--- /dev/null
97699+++ b/include/linux/gracl.h
97700@@ -0,0 +1,342 @@
97701+#ifndef GR_ACL_H
97702+#define GR_ACL_H
97703+
97704+#include <linux/grdefs.h>
97705+#include <linux/resource.h>
97706+#include <linux/capability.h>
97707+#include <linux/dcache.h>
97708+#include <asm/resource.h>
97709+
97710+/* Major status information */
97711+
97712+#define GR_VERSION "grsecurity 3.1"
97713+#define GRSECURITY_VERSION 0x3100
97714+
97715+enum {
97716+ GR_SHUTDOWN = 0,
97717+ GR_ENABLE = 1,
97718+ GR_SPROLE = 2,
97719+ GR_OLDRELOAD = 3,
97720+ GR_SEGVMOD = 4,
97721+ GR_STATUS = 5,
97722+ GR_UNSPROLE = 6,
97723+ GR_PASSSET = 7,
97724+ GR_SPROLEPAM = 8,
97725+ GR_RELOAD = 9,
97726+};
97727+
97728+/* Password setup definitions
97729+ * kernel/grhash.c */
97730+enum {
97731+ GR_PW_LEN = 128,
97732+ GR_SALT_LEN = 16,
97733+ GR_SHA_LEN = 32,
97734+};
97735+
97736+enum {
97737+ GR_SPROLE_LEN = 64,
97738+};
97739+
97740+enum {
97741+ GR_NO_GLOB = 0,
97742+ GR_REG_GLOB,
97743+ GR_CREATE_GLOB
97744+};
97745+
97746+#define GR_NLIMITS 32
97747+
97748+/* Begin Data Structures */
97749+
97750+struct sprole_pw {
97751+ unsigned char *rolename;
97752+ unsigned char salt[GR_SALT_LEN];
97753+ unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
97754+};
97755+
97756+struct name_entry {
97757+ __u32 key;
97758+ u64 inode;
97759+ dev_t device;
97760+ char *name;
97761+ __u16 len;
97762+ __u8 deleted;
97763+ struct name_entry *prev;
97764+ struct name_entry *next;
97765+};
97766+
97767+struct inodev_entry {
97768+ struct name_entry *nentry;
97769+ struct inodev_entry *prev;
97770+ struct inodev_entry *next;
97771+};
97772+
97773+struct acl_role_db {
97774+ struct acl_role_label **r_hash;
97775+ __u32 r_size;
97776+};
97777+
97778+struct inodev_db {
97779+ struct inodev_entry **i_hash;
97780+ __u32 i_size;
97781+};
97782+
97783+struct name_db {
97784+ struct name_entry **n_hash;
97785+ __u32 n_size;
97786+};
97787+
97788+struct crash_uid {
97789+ uid_t uid;
97790+ unsigned long expires;
97791+};
97792+
97793+struct gr_hash_struct {
97794+ void **table;
97795+ void **nametable;
97796+ void *first;
97797+ __u32 table_size;
97798+ __u32 used_size;
97799+ int type;
97800+};
97801+
97802+/* Userspace Grsecurity ACL data structures */
97803+
97804+struct acl_subject_label {
97805+ char *filename;
97806+ u64 inode;
97807+ dev_t device;
97808+ __u32 mode;
97809+ kernel_cap_t cap_mask;
97810+ kernel_cap_t cap_lower;
97811+ kernel_cap_t cap_invert_audit;
97812+
97813+ struct rlimit res[GR_NLIMITS];
97814+ __u32 resmask;
97815+
97816+ __u8 user_trans_type;
97817+ __u8 group_trans_type;
97818+ uid_t *user_transitions;
97819+ gid_t *group_transitions;
97820+ __u16 user_trans_num;
97821+ __u16 group_trans_num;
97822+
97823+ __u32 sock_families[2];
97824+ __u32 ip_proto[8];
97825+ __u32 ip_type;
97826+ struct acl_ip_label **ips;
97827+ __u32 ip_num;
97828+ __u32 inaddr_any_override;
97829+
97830+ __u32 crashes;
97831+ unsigned long expires;
97832+
97833+ struct acl_subject_label *parent_subject;
97834+ struct gr_hash_struct *hash;
97835+ struct acl_subject_label *prev;
97836+ struct acl_subject_label *next;
97837+
97838+ struct acl_object_label **obj_hash;
97839+ __u32 obj_hash_size;
97840+ __u16 pax_flags;
97841+};
97842+
97843+struct role_allowed_ip {
97844+ __u32 addr;
97845+ __u32 netmask;
97846+
97847+ struct role_allowed_ip *prev;
97848+ struct role_allowed_ip *next;
97849+};
97850+
97851+struct role_transition {
97852+ char *rolename;
97853+
97854+ struct role_transition *prev;
97855+ struct role_transition *next;
97856+};
97857+
97858+struct acl_role_label {
97859+ char *rolename;
97860+ uid_t uidgid;
97861+ __u16 roletype;
97862+
97863+ __u16 auth_attempts;
97864+ unsigned long expires;
97865+
97866+ struct acl_subject_label *root_label;
97867+ struct gr_hash_struct *hash;
97868+
97869+ struct acl_role_label *prev;
97870+ struct acl_role_label *next;
97871+
97872+ struct role_transition *transitions;
97873+ struct role_allowed_ip *allowed_ips;
97874+ uid_t *domain_children;
97875+ __u16 domain_child_num;
97876+
97877+ umode_t umask;
97878+
97879+ struct acl_subject_label **subj_hash;
97880+ __u32 subj_hash_size;
97881+};
97882+
97883+struct user_acl_role_db {
97884+ struct acl_role_label **r_table;
97885+ __u32 num_pointers; /* Number of allocations to track */
97886+ __u32 num_roles; /* Number of roles */
97887+ __u32 num_domain_children; /* Number of domain children */
97888+ __u32 num_subjects; /* Number of subjects */
97889+ __u32 num_objects; /* Number of objects */
97890+};
97891+
97892+struct acl_object_label {
97893+ char *filename;
97894+ u64 inode;
97895+ dev_t device;
97896+ __u32 mode;
97897+
97898+ struct acl_subject_label *nested;
97899+ struct acl_object_label *globbed;
97900+
97901+ /* next two structures not used */
97902+
97903+ struct acl_object_label *prev;
97904+ struct acl_object_label *next;
97905+};
97906+
97907+struct acl_ip_label {
97908+ char *iface;
97909+ __u32 addr;
97910+ __u32 netmask;
97911+ __u16 low, high;
97912+ __u8 mode;
97913+ __u32 type;
97914+ __u32 proto[8];
97915+
97916+ /* next two structures not used */
97917+
97918+ struct acl_ip_label *prev;
97919+ struct acl_ip_label *next;
97920+};
97921+
97922+struct gr_arg {
97923+ struct user_acl_role_db role_db;
97924+ unsigned char pw[GR_PW_LEN];
97925+ unsigned char salt[GR_SALT_LEN];
97926+ unsigned char sum[GR_SHA_LEN];
97927+ unsigned char sp_role[GR_SPROLE_LEN];
97928+ struct sprole_pw *sprole_pws;
97929+ dev_t segv_device;
97930+ u64 segv_inode;
97931+ uid_t segv_uid;
97932+ __u16 num_sprole_pws;
97933+ __u16 mode;
97934+};
97935+
97936+struct gr_arg_wrapper {
97937+ struct gr_arg *arg;
97938+ __u32 version;
97939+ __u32 size;
97940+};
97941+
97942+struct subject_map {
97943+ struct acl_subject_label *user;
97944+ struct acl_subject_label *kernel;
97945+ struct subject_map *prev;
97946+ struct subject_map *next;
97947+};
97948+
97949+struct acl_subj_map_db {
97950+ struct subject_map **s_hash;
97951+ __u32 s_size;
97952+};
97953+
97954+struct gr_policy_state {
97955+ struct sprole_pw **acl_special_roles;
97956+ __u16 num_sprole_pws;
97957+ struct acl_role_label *kernel_role;
97958+ struct acl_role_label *role_list;
97959+ struct acl_role_label *default_role;
97960+ struct acl_role_db acl_role_set;
97961+ struct acl_subj_map_db subj_map_set;
97962+ struct name_db name_set;
97963+ struct inodev_db inodev_set;
97964+};
97965+
97966+struct gr_alloc_state {
97967+ unsigned long alloc_stack_next;
97968+ unsigned long alloc_stack_size;
97969+ void **alloc_stack;
97970+};
97971+
97972+struct gr_reload_state {
97973+ struct gr_policy_state oldpolicy;
97974+ struct gr_alloc_state oldalloc;
97975+ struct gr_policy_state newpolicy;
97976+ struct gr_alloc_state newalloc;
97977+ struct gr_policy_state *oldpolicy_ptr;
97978+ struct gr_alloc_state *oldalloc_ptr;
97979+ unsigned char oldmode;
97980+};
97981+
97982+/* End Data Structures Section */
97983+
97984+/* Hash functions generated by empirical testing by Brad Spengler
97985+ Makes good use of the low bits of the inode. Generally 0-1 times
97986+ in loop for successful match. 0-3 for unsuccessful match.
97987+ Shift/add algorithm with modulus of table size and an XOR*/
97988+
97989+static __inline__ unsigned int
97990+gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
97991+{
97992+ return ((((uid + type) << (16 + type)) ^ uid) % sz);
97993+}
97994+
97995+ static __inline__ unsigned int
97996+gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
97997+{
97998+ return ((const unsigned long)userp % sz);
97999+}
98000+
98001+static __inline__ unsigned int
98002+gr_fhash(const u64 ino, const dev_t dev, const unsigned int sz)
98003+{
98004+ unsigned int rem;
98005+ div_u64_rem((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9)), sz, &rem);
98006+ return rem;
98007+}
98008+
98009+static __inline__ unsigned int
98010+gr_nhash(const char *name, const __u16 len, const unsigned int sz)
98011+{
98012+ return full_name_hash((const unsigned char *)name, len) % sz;
98013+}
98014+
98015+#define FOR_EACH_SUBJECT_START(role,subj,iter) \
98016+ subj = NULL; \
98017+ iter = 0; \
98018+ while (iter < role->subj_hash_size) { \
98019+ if (subj == NULL) \
98020+ subj = role->subj_hash[iter]; \
98021+ if (subj == NULL) { \
98022+ iter++; \
98023+ continue; \
98024+ }
98025+
98026+#define FOR_EACH_SUBJECT_END(subj,iter) \
98027+ subj = subj->next; \
98028+ if (subj == NULL) \
98029+ iter++; \
98030+ }
98031+
98032+
98033+#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
98034+ subj = role->hash->first; \
98035+ while (subj != NULL) {
98036+
98037+#define FOR_EACH_NESTED_SUBJECT_END(subj) \
98038+ subj = subj->next; \
98039+ }
98040+
98041+#endif
98042+
98043diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
98044new file mode 100644
98045index 0000000..af64092
98046--- /dev/null
98047+++ b/include/linux/gracl_compat.h
98048@@ -0,0 +1,156 @@
98049+#ifndef GR_ACL_COMPAT_H
98050+#define GR_ACL_COMPAT_H
98051+
98052+#include <linux/resource.h>
98053+#include <asm/resource.h>
98054+
98055+struct sprole_pw_compat {
98056+ compat_uptr_t rolename;
98057+ unsigned char salt[GR_SALT_LEN];
98058+ unsigned char sum[GR_SHA_LEN];
98059+};
98060+
98061+struct gr_hash_struct_compat {
98062+ compat_uptr_t table;
98063+ compat_uptr_t nametable;
98064+ compat_uptr_t first;
98065+ __u32 table_size;
98066+ __u32 used_size;
98067+ int type;
98068+};
98069+
98070+struct acl_subject_label_compat {
98071+ compat_uptr_t filename;
98072+ compat_u64 inode;
98073+ __u32 device;
98074+ __u32 mode;
98075+ kernel_cap_t cap_mask;
98076+ kernel_cap_t cap_lower;
98077+ kernel_cap_t cap_invert_audit;
98078+
98079+ struct compat_rlimit res[GR_NLIMITS];
98080+ __u32 resmask;
98081+
98082+ __u8 user_trans_type;
98083+ __u8 group_trans_type;
98084+ compat_uptr_t user_transitions;
98085+ compat_uptr_t group_transitions;
98086+ __u16 user_trans_num;
98087+ __u16 group_trans_num;
98088+
98089+ __u32 sock_families[2];
98090+ __u32 ip_proto[8];
98091+ __u32 ip_type;
98092+ compat_uptr_t ips;
98093+ __u32 ip_num;
98094+ __u32 inaddr_any_override;
98095+
98096+ __u32 crashes;
98097+ compat_ulong_t expires;
98098+
98099+ compat_uptr_t parent_subject;
98100+ compat_uptr_t hash;
98101+ compat_uptr_t prev;
98102+ compat_uptr_t next;
98103+
98104+ compat_uptr_t obj_hash;
98105+ __u32 obj_hash_size;
98106+ __u16 pax_flags;
98107+};
98108+
98109+struct role_allowed_ip_compat {
98110+ __u32 addr;
98111+ __u32 netmask;
98112+
98113+ compat_uptr_t prev;
98114+ compat_uptr_t next;
98115+};
98116+
98117+struct role_transition_compat {
98118+ compat_uptr_t rolename;
98119+
98120+ compat_uptr_t prev;
98121+ compat_uptr_t next;
98122+};
98123+
98124+struct acl_role_label_compat {
98125+ compat_uptr_t rolename;
98126+ uid_t uidgid;
98127+ __u16 roletype;
98128+
98129+ __u16 auth_attempts;
98130+ compat_ulong_t expires;
98131+
98132+ compat_uptr_t root_label;
98133+ compat_uptr_t hash;
98134+
98135+ compat_uptr_t prev;
98136+ compat_uptr_t next;
98137+
98138+ compat_uptr_t transitions;
98139+ compat_uptr_t allowed_ips;
98140+ compat_uptr_t domain_children;
98141+ __u16 domain_child_num;
98142+
98143+ umode_t umask;
98144+
98145+ compat_uptr_t subj_hash;
98146+ __u32 subj_hash_size;
98147+};
98148+
98149+struct user_acl_role_db_compat {
98150+ compat_uptr_t r_table;
98151+ __u32 num_pointers;
98152+ __u32 num_roles;
98153+ __u32 num_domain_children;
98154+ __u32 num_subjects;
98155+ __u32 num_objects;
98156+};
98157+
98158+struct acl_object_label_compat {
98159+ compat_uptr_t filename;
98160+ compat_u64 inode;
98161+ __u32 device;
98162+ __u32 mode;
98163+
98164+ compat_uptr_t nested;
98165+ compat_uptr_t globbed;
98166+
98167+ compat_uptr_t prev;
98168+ compat_uptr_t next;
98169+};
98170+
98171+struct acl_ip_label_compat {
98172+ compat_uptr_t iface;
98173+ __u32 addr;
98174+ __u32 netmask;
98175+ __u16 low, high;
98176+ __u8 mode;
98177+ __u32 type;
98178+ __u32 proto[8];
98179+
98180+ compat_uptr_t prev;
98181+ compat_uptr_t next;
98182+};
98183+
98184+struct gr_arg_compat {
98185+ struct user_acl_role_db_compat role_db;
98186+ unsigned char pw[GR_PW_LEN];
98187+ unsigned char salt[GR_SALT_LEN];
98188+ unsigned char sum[GR_SHA_LEN];
98189+ unsigned char sp_role[GR_SPROLE_LEN];
98190+ compat_uptr_t sprole_pws;
98191+ __u32 segv_device;
98192+ compat_u64 segv_inode;
98193+ uid_t segv_uid;
98194+ __u16 num_sprole_pws;
98195+ __u16 mode;
98196+};
98197+
98198+struct gr_arg_wrapper_compat {
98199+ compat_uptr_t arg;
98200+ __u32 version;
98201+ __u32 size;
98202+};
98203+
98204+#endif
98205diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
98206new file mode 100644
98207index 0000000..323ecf2
98208--- /dev/null
98209+++ b/include/linux/gralloc.h
98210@@ -0,0 +1,9 @@
98211+#ifndef __GRALLOC_H
98212+#define __GRALLOC_H
98213+
98214+void acl_free_all(void);
98215+int acl_alloc_stack_init(unsigned long size);
98216+void *acl_alloc(unsigned long len);
98217+void *acl_alloc_num(unsigned long num, unsigned long len);
98218+
98219+#endif
98220diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
98221new file mode 100644
98222index 0000000..be66033
98223--- /dev/null
98224+++ b/include/linux/grdefs.h
98225@@ -0,0 +1,140 @@
98226+#ifndef GRDEFS_H
98227+#define GRDEFS_H
98228+
98229+/* Begin grsecurity status declarations */
98230+
98231+enum {
98232+ GR_READY = 0x01,
98233+ GR_STATUS_INIT = 0x00 // disabled state
98234+};
98235+
98236+/* Begin ACL declarations */
98237+
98238+/* Role flags */
98239+
98240+enum {
98241+ GR_ROLE_USER = 0x0001,
98242+ GR_ROLE_GROUP = 0x0002,
98243+ GR_ROLE_DEFAULT = 0x0004,
98244+ GR_ROLE_SPECIAL = 0x0008,
98245+ GR_ROLE_AUTH = 0x0010,
98246+ GR_ROLE_NOPW = 0x0020,
98247+ GR_ROLE_GOD = 0x0040,
98248+ GR_ROLE_LEARN = 0x0080,
98249+ GR_ROLE_TPE = 0x0100,
98250+ GR_ROLE_DOMAIN = 0x0200,
98251+ GR_ROLE_PAM = 0x0400,
98252+ GR_ROLE_PERSIST = 0x0800
98253+};
98254+
98255+/* ACL Subject and Object mode flags */
98256+enum {
98257+ GR_DELETED = 0x80000000
98258+};
98259+
98260+/* ACL Object-only mode flags */
98261+enum {
98262+ GR_READ = 0x00000001,
98263+ GR_APPEND = 0x00000002,
98264+ GR_WRITE = 0x00000004,
98265+ GR_EXEC = 0x00000008,
98266+ GR_FIND = 0x00000010,
98267+ GR_INHERIT = 0x00000020,
98268+ GR_SETID = 0x00000040,
98269+ GR_CREATE = 0x00000080,
98270+ GR_DELETE = 0x00000100,
98271+ GR_LINK = 0x00000200,
98272+ GR_AUDIT_READ = 0x00000400,
98273+ GR_AUDIT_APPEND = 0x00000800,
98274+ GR_AUDIT_WRITE = 0x00001000,
98275+ GR_AUDIT_EXEC = 0x00002000,
98276+ GR_AUDIT_FIND = 0x00004000,
98277+ GR_AUDIT_INHERIT= 0x00008000,
98278+ GR_AUDIT_SETID = 0x00010000,
98279+ GR_AUDIT_CREATE = 0x00020000,
98280+ GR_AUDIT_DELETE = 0x00040000,
98281+ GR_AUDIT_LINK = 0x00080000,
98282+ GR_PTRACERD = 0x00100000,
98283+ GR_NOPTRACE = 0x00200000,
98284+ GR_SUPPRESS = 0x00400000,
98285+ GR_NOLEARN = 0x00800000,
98286+ GR_INIT_TRANSFER= 0x01000000
98287+};
98288+
98289+#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
98290+ GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
98291+ GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
98292+
98293+/* ACL subject-only mode flags */
98294+enum {
98295+ GR_KILL = 0x00000001,
98296+ GR_VIEW = 0x00000002,
98297+ GR_PROTECTED = 0x00000004,
98298+ GR_LEARN = 0x00000008,
98299+ GR_OVERRIDE = 0x00000010,
98300+ /* just a placeholder, this mode is only used in userspace */
98301+ GR_DUMMY = 0x00000020,
98302+ GR_PROTSHM = 0x00000040,
98303+ GR_KILLPROC = 0x00000080,
98304+ GR_KILLIPPROC = 0x00000100,
98305+ /* just a placeholder, this mode is only used in userspace */
98306+ GR_NOTROJAN = 0x00000200,
98307+ GR_PROTPROCFD = 0x00000400,
98308+ GR_PROCACCT = 0x00000800,
98309+ GR_RELAXPTRACE = 0x00001000,
98310+ //GR_NESTED = 0x00002000,
98311+ GR_INHERITLEARN = 0x00004000,
98312+ GR_PROCFIND = 0x00008000,
98313+ GR_POVERRIDE = 0x00010000,
98314+ GR_KERNELAUTH = 0x00020000,
98315+ GR_ATSECURE = 0x00040000,
98316+ GR_SHMEXEC = 0x00080000
98317+};
98318+
98319+enum {
98320+ GR_PAX_ENABLE_SEGMEXEC = 0x0001,
98321+ GR_PAX_ENABLE_PAGEEXEC = 0x0002,
98322+ GR_PAX_ENABLE_MPROTECT = 0x0004,
98323+ GR_PAX_ENABLE_RANDMMAP = 0x0008,
98324+ GR_PAX_ENABLE_EMUTRAMP = 0x0010,
98325+ GR_PAX_DISABLE_SEGMEXEC = 0x0100,
98326+ GR_PAX_DISABLE_PAGEEXEC = 0x0200,
98327+ GR_PAX_DISABLE_MPROTECT = 0x0400,
98328+ GR_PAX_DISABLE_RANDMMAP = 0x0800,
98329+ GR_PAX_DISABLE_EMUTRAMP = 0x1000,
98330+};
98331+
98332+enum {
98333+ GR_ID_USER = 0x01,
98334+ GR_ID_GROUP = 0x02,
98335+};
98336+
98337+enum {
98338+ GR_ID_ALLOW = 0x01,
98339+ GR_ID_DENY = 0x02,
98340+};
98341+
98342+#define GR_CRASH_RES 31
98343+#define GR_UIDTABLE_MAX 500
98344+
98345+/* begin resource learning section */
98346+enum {
98347+ GR_RLIM_CPU_BUMP = 60,
98348+ GR_RLIM_FSIZE_BUMP = 50000,
98349+ GR_RLIM_DATA_BUMP = 10000,
98350+ GR_RLIM_STACK_BUMP = 1000,
98351+ GR_RLIM_CORE_BUMP = 10000,
98352+ GR_RLIM_RSS_BUMP = 500000,
98353+ GR_RLIM_NPROC_BUMP = 1,
98354+ GR_RLIM_NOFILE_BUMP = 5,
98355+ GR_RLIM_MEMLOCK_BUMP = 50000,
98356+ GR_RLIM_AS_BUMP = 500000,
98357+ GR_RLIM_LOCKS_BUMP = 2,
98358+ GR_RLIM_SIGPENDING_BUMP = 5,
98359+ GR_RLIM_MSGQUEUE_BUMP = 10000,
98360+ GR_RLIM_NICE_BUMP = 1,
98361+ GR_RLIM_RTPRIO_BUMP = 1,
98362+ GR_RLIM_RTTIME_BUMP = 1000000
98363+};
98364+
98365+#endif
98366diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
98367new file mode 100644
98368index 0000000..6245f9e
98369--- /dev/null
98370+++ b/include/linux/grinternal.h
98371@@ -0,0 +1,230 @@
98372+#ifndef __GRINTERNAL_H
98373+#define __GRINTERNAL_H
98374+
98375+#ifdef CONFIG_GRKERNSEC
98376+
98377+#include <linux/fs.h>
98378+#include <linux/mnt_namespace.h>
98379+#include <linux/nsproxy.h>
98380+#include <linux/gracl.h>
98381+#include <linux/grdefs.h>
98382+#include <linux/grmsg.h>
98383+
98384+void gr_add_learn_entry(const char *fmt, ...)
98385+ __attribute__ ((format (printf, 1, 2)));
98386+__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
98387+ const struct vfsmount *mnt);
98388+__u32 gr_check_create(const struct dentry *new_dentry,
98389+ const struct dentry *parent,
98390+ const struct vfsmount *mnt, const __u32 mode);
98391+int gr_check_protected_task(const struct task_struct *task);
98392+__u32 to_gr_audit(const __u32 reqmode);
98393+int gr_set_acls(const int type);
98394+int gr_acl_is_enabled(void);
98395+char gr_roletype_to_char(void);
98396+
98397+void gr_handle_alertkill(struct task_struct *task);
98398+char *gr_to_filename(const struct dentry *dentry,
98399+ const struct vfsmount *mnt);
98400+char *gr_to_filename1(const struct dentry *dentry,
98401+ const struct vfsmount *mnt);
98402+char *gr_to_filename2(const struct dentry *dentry,
98403+ const struct vfsmount *mnt);
98404+char *gr_to_filename3(const struct dentry *dentry,
98405+ const struct vfsmount *mnt);
98406+
98407+extern int grsec_enable_ptrace_readexec;
98408+extern int grsec_enable_harden_ptrace;
98409+extern int grsec_enable_link;
98410+extern int grsec_enable_fifo;
98411+extern int grsec_enable_execve;
98412+extern int grsec_enable_shm;
98413+extern int grsec_enable_execlog;
98414+extern int grsec_enable_signal;
98415+extern int grsec_enable_audit_ptrace;
98416+extern int grsec_enable_forkfail;
98417+extern int grsec_enable_time;
98418+extern int grsec_enable_rofs;
98419+extern int grsec_deny_new_usb;
98420+extern int grsec_enable_chroot_shmat;
98421+extern int grsec_enable_chroot_mount;
98422+extern int grsec_enable_chroot_double;
98423+extern int grsec_enable_chroot_pivot;
98424+extern int grsec_enable_chroot_chdir;
98425+extern int grsec_enable_chroot_chmod;
98426+extern int grsec_enable_chroot_mknod;
98427+extern int grsec_enable_chroot_fchdir;
98428+extern int grsec_enable_chroot_nice;
98429+extern int grsec_enable_chroot_execlog;
98430+extern int grsec_enable_chroot_caps;
98431+extern int grsec_enable_chroot_rename;
98432+extern int grsec_enable_chroot_sysctl;
98433+extern int grsec_enable_chroot_unix;
98434+extern int grsec_enable_symlinkown;
98435+extern kgid_t grsec_symlinkown_gid;
98436+extern int grsec_enable_tpe;
98437+extern kgid_t grsec_tpe_gid;
98438+extern int grsec_enable_tpe_all;
98439+extern int grsec_enable_tpe_invert;
98440+extern int grsec_enable_socket_all;
98441+extern kgid_t grsec_socket_all_gid;
98442+extern int grsec_enable_socket_client;
98443+extern kgid_t grsec_socket_client_gid;
98444+extern int grsec_enable_socket_server;
98445+extern kgid_t grsec_socket_server_gid;
98446+extern kgid_t grsec_audit_gid;
98447+extern int grsec_enable_group;
98448+extern int grsec_enable_log_rwxmaps;
98449+extern int grsec_enable_mount;
98450+extern int grsec_enable_chdir;
98451+extern int grsec_resource_logging;
98452+extern int grsec_enable_blackhole;
98453+extern int grsec_lastack_retries;
98454+extern int grsec_enable_brute;
98455+extern int grsec_enable_harden_ipc;
98456+extern int grsec_lock;
98457+
98458+extern spinlock_t grsec_alert_lock;
98459+extern unsigned long grsec_alert_wtime;
98460+extern unsigned long grsec_alert_fyet;
98461+
98462+extern spinlock_t grsec_audit_lock;
98463+
98464+extern rwlock_t grsec_exec_file_lock;
98465+
98466+#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
98467+ gr_to_filename2((tsk)->exec_file->f_path.dentry, \
98468+ (tsk)->exec_file->f_path.mnt) : "/")
98469+
98470+#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
98471+ gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
98472+ (tsk)->real_parent->exec_file->f_path.mnt) : "/")
98473+
98474+#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
98475+ gr_to_filename((tsk)->exec_file->f_path.dentry, \
98476+ (tsk)->exec_file->f_path.mnt) : "/")
98477+
98478+#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
98479+ gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
98480+ (tsk)->real_parent->exec_file->f_path.mnt) : "/")
98481+
98482+#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
98483+
98484+#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
98485+
98486+static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
98487+{
98488+ if (file1 && file2) {
98489+ const struct inode *inode1 = file1->f_path.dentry->d_inode;
98490+ const struct inode *inode2 = file2->f_path.dentry->d_inode;
98491+ if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
98492+ return true;
98493+ }
98494+
98495+ return false;
98496+}
98497+
98498+#define GR_CHROOT_CAPS {{ \
98499+ CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
98500+ CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
98501+ CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
98502+ CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
98503+ CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
98504+ CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
98505+ CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
98506+
98507+#define security_learn(normal_msg,args...) \
98508+({ \
98509+ read_lock(&grsec_exec_file_lock); \
98510+ gr_add_learn_entry(normal_msg "\n", ## args); \
98511+ read_unlock(&grsec_exec_file_lock); \
98512+})
98513+
98514+enum {
98515+ GR_DO_AUDIT,
98516+ GR_DONT_AUDIT,
98517+ /* used for non-audit messages that we shouldn't kill the task on */
98518+ GR_DONT_AUDIT_GOOD
98519+};
98520+
98521+enum {
98522+ GR_TTYSNIFF,
98523+ GR_RBAC,
98524+ GR_RBAC_STR,
98525+ GR_STR_RBAC,
98526+ GR_RBAC_MODE2,
98527+ GR_RBAC_MODE3,
98528+ GR_FILENAME,
98529+ GR_SYSCTL_HIDDEN,
98530+ GR_NOARGS,
98531+ GR_ONE_INT,
98532+ GR_ONE_INT_TWO_STR,
98533+ GR_ONE_STR,
98534+ GR_STR_INT,
98535+ GR_TWO_STR_INT,
98536+ GR_TWO_INT,
98537+ GR_TWO_U64,
98538+ GR_THREE_INT,
98539+ GR_FIVE_INT_TWO_STR,
98540+ GR_TWO_STR,
98541+ GR_THREE_STR,
98542+ GR_FOUR_STR,
98543+ GR_STR_FILENAME,
98544+ GR_FILENAME_STR,
98545+ GR_FILENAME_TWO_INT,
98546+ GR_FILENAME_TWO_INT_STR,
98547+ GR_TEXTREL,
98548+ GR_PTRACE,
98549+ GR_RESOURCE,
98550+ GR_CAP,
98551+ GR_SIG,
98552+ GR_SIG2,
98553+ GR_CRASH1,
98554+ GR_CRASH2,
98555+ GR_PSACCT,
98556+ GR_RWXMAP,
98557+ GR_RWXMAPVMA
98558+};
98559+
98560+#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
98561+#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
98562+#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
98563+#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
98564+#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
98565+#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
98566+#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)
98567+#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
98568+#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
98569+#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
98570+#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
98571+#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
98572+#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
98573+#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
98574+#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
98575+#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
98576+#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)
98577+#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
98578+#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
98579+#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
98580+#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
98581+#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
98582+#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
98583+#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
98584+#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)
98585+#define gr_log_textrel_ulong_ulong(audit, msg, str, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, str, file, ulong1, ulong2)
98586+#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
98587+#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
98588+#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
98589+#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
98590+#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
98591+#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
98592+#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
98593+#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)
98594+#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
98595+#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
98596+
98597+void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
98598+
98599+#endif
98600+
98601+#endif
98602diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
98603new file mode 100644
98604index 0000000..3092b3c
98605--- /dev/null
98606+++ b/include/linux/grmsg.h
98607@@ -0,0 +1,118 @@
98608+#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"
98609+#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"
98610+#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
98611+#define GR_STOPMOD_MSG "denied modification of module state by "
98612+#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
98613+#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
98614+#define GR_IOPERM_MSG "denied use of ioperm() by "
98615+#define GR_IOPL_MSG "denied use of iopl() by "
98616+#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
98617+#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
98618+#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
98619+#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
98620+#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
98621+#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"
98622+#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"
98623+#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
98624+#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
98625+#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
98626+#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
98627+#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
98628+#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
98629+#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
98630+#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
98631+#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
98632+#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
98633+#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
98634+#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
98635+#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
98636+#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
98637+#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
98638+#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
98639+#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
98640+#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
98641+#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
98642+#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
98643+#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
98644+#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
98645+#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
98646+#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
98647+#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
98648+#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
98649+#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
98650+#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
98651+#define GR_CHROOT_RENAME_MSG "denied bad rename of %.950s out of a chroot by "
98652+#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
98653+#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
98654+#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
98655+#define GR_CHROOT_FHANDLE_MSG "denied use of file handles inside chroot by "
98656+#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
98657+#define GR_SETXATTR_ACL_MSG "%s setting extended attribute of %.950s by "
98658+#define GR_REMOVEXATTR_ACL_MSG "%s removing extended attribute of %.950s by "
98659+#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
98660+#define GR_INITF_ACL_MSG "init_variables() failed %s by "
98661+#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"
98662+#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
98663+#define GR_SHUTS_ACL_MSG "shutdown auth success for "
98664+#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
98665+#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
98666+#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
98667+#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
98668+#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
98669+#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
98670+#define GR_ENABLEF_ACL_MSG "unable to load %s for "
98671+#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
98672+#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
98673+#define GR_RELOADF_ACL_MSG "failed reload of %s for "
98674+#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
98675+#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
98676+#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
98677+#define GR_SPROLEF_ACL_MSG "special role %s failure for "
98678+#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
98679+#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
98680+#define GR_INVMODE_ACL_MSG "invalid mode %d by "
98681+#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
98682+#define GR_FAILFORK_MSG "failed fork with errno %s by "
98683+#define GR_NICE_CHROOT_MSG "denied priority change by "
98684+#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
98685+#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
98686+#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
98687+#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
98688+#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
98689+#define GR_TIME_MSG "time set by "
98690+#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
98691+#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
98692+#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
98693+#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
98694+#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
98695+#define GR_BIND_MSG "denied bind() by "
98696+#define GR_CONNECT_MSG "denied connect() by "
98697+#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
98698+#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
98699+#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"
98700+#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
98701+#define GR_CAP_ACL_MSG "use of %s denied for "
98702+#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
98703+#define GR_CAP_ACL_MSG2 "use of %s permitted for "
98704+#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
98705+#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
98706+#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
98707+#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
98708+#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
98709+#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
98710+#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
98711+#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
98712+#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
98713+#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
98714+#define GR_TEXTREL_AUDIT_MSG "allowed %s text relocation transition in %.950s, VMA:0x%08lx 0x%08lx by "
98715+#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
98716+#define GR_VM86_MSG "denied use of vm86 by "
98717+#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
98718+#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
98719+#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
98720+#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
98721+#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
98722+#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 "
98723+#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 "
98724+#define GR_IPC_DENIED_MSG "denied %s of overly-permissive IPC object with creator uid %u by "
98725+#define GR_MSRWRITE_MSG "denied write to CPU MSR by "
98726diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
98727new file mode 100644
98728index 0000000..0ea4a82
98729--- /dev/null
98730+++ b/include/linux/grsecurity.h
98731@@ -0,0 +1,255 @@
98732+#ifndef GR_SECURITY_H
98733+#define GR_SECURITY_H
98734+#include <linux/fs.h>
98735+#include <linux/fs_struct.h>
98736+#include <linux/binfmts.h>
98737+#include <linux/gracl.h>
98738+
98739+/* notify of brain-dead configs */
98740+#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_GRKERNSEC_KMEM)
98741+#error "CONFIG_DEBUG_FS being enabled is a security risk when CONFIG_GRKERNSEC_KMEM is enabled"
98742+#endif
98743+#if defined(CONFIG_PROC_PAGE_MONITOR) && defined(CONFIG_GRKERNSEC)
98744+#error "CONFIG_PROC_PAGE_MONITOR is a security risk"
98745+#endif
98746+#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
98747+#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
98748+#endif
98749+#if defined(CONFIG_GRKERNSEC_PROC) && !defined(CONFIG_GRKERNSEC_PROC_USER) && !defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
98750+#error "CONFIG_GRKERNSEC_PROC enabled, but neither CONFIG_GRKERNSEC_PROC_USER nor CONFIG_GRKERNSEC_PROC_USERGROUP enabled"
98751+#endif
98752+#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
98753+#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
98754+#endif
98755+#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
98756+#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
98757+#endif
98758+#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
98759+#error "CONFIG_PAX enabled, but no PaX options are enabled."
98760+#endif
98761+
98762+int gr_handle_new_usb(void);
98763+
98764+void gr_handle_brute_attach(int dumpable);
98765+void gr_handle_brute_check(void);
98766+void gr_handle_kernel_exploit(void);
98767+
98768+char gr_roletype_to_char(void);
98769+
98770+int gr_proc_is_restricted(void);
98771+
98772+int gr_acl_enable_at_secure(void);
98773+
98774+int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
98775+int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
98776+
98777+int gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap);
98778+
98779+void gr_del_task_from_ip_table(struct task_struct *p);
98780+
98781+int gr_pid_is_chrooted(struct task_struct *p);
98782+int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
98783+int gr_handle_chroot_nice(void);
98784+int gr_handle_chroot_sysctl(const int op);
98785+int gr_handle_chroot_setpriority(struct task_struct *p,
98786+ const int niceval);
98787+int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
98788+int gr_chroot_fhandle(void);
98789+int gr_handle_chroot_chroot(const struct dentry *dentry,
98790+ const struct vfsmount *mnt);
98791+void gr_handle_chroot_chdir(const struct path *path);
98792+int gr_handle_chroot_chmod(const struct dentry *dentry,
98793+ const struct vfsmount *mnt, const int mode);
98794+int gr_handle_chroot_mknod(const struct dentry *dentry,
98795+ const struct vfsmount *mnt, const int mode);
98796+int gr_handle_chroot_mount(const struct dentry *dentry,
98797+ const struct vfsmount *mnt,
98798+ const char *dev_name);
98799+int gr_handle_chroot_pivot(void);
98800+int gr_handle_chroot_unix(const pid_t pid);
98801+
98802+int gr_handle_rawio(const struct inode *inode);
98803+
98804+void gr_handle_ioperm(void);
98805+void gr_handle_iopl(void);
98806+void gr_handle_msr_write(void);
98807+
98808+umode_t gr_acl_umask(void);
98809+
98810+int gr_tpe_allow(const struct file *file);
98811+
98812+void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
98813+void gr_clear_chroot_entries(struct task_struct *task);
98814+
98815+void gr_log_forkfail(const int retval);
98816+void gr_log_timechange(void);
98817+void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
98818+void gr_log_chdir(const struct dentry *dentry,
98819+ const struct vfsmount *mnt);
98820+void gr_log_chroot_exec(const struct dentry *dentry,
98821+ const struct vfsmount *mnt);
98822+void gr_log_remount(const char *devname, const int retval);
98823+void gr_log_unmount(const char *devname, const int retval);
98824+void gr_log_mount(const char *from, struct path *to, const int retval);
98825+void gr_log_textrel(struct vm_area_struct *vma, bool is_textrel_rw);
98826+void gr_log_ptgnustack(struct file *file);
98827+void gr_log_rwxmmap(struct file *file);
98828+void gr_log_rwxmprotect(struct vm_area_struct *vma);
98829+
98830+int gr_handle_follow_link(const struct dentry *dentry,
98831+ const struct vfsmount *mnt);
98832+int gr_handle_fifo(const struct dentry *dentry,
98833+ const struct vfsmount *mnt,
98834+ const struct dentry *dir, const int flag,
98835+ const int acc_mode);
98836+int gr_handle_hardlink(const struct dentry *dentry,
98837+ const struct vfsmount *mnt,
98838+ const struct filename *to);
98839+
98840+int gr_is_capable(const int cap);
98841+int gr_is_capable_nolog(const int cap);
98842+int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
98843+int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
98844+
98845+void gr_copy_label(struct task_struct *tsk);
98846+void gr_handle_crash(struct task_struct *task, const int sig);
98847+int gr_handle_signal(const struct task_struct *p, const int sig);
98848+int gr_check_crash_uid(const kuid_t uid);
98849+int gr_check_protected_task(const struct task_struct *task);
98850+int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
98851+int gr_acl_handle_mmap(const struct file *file,
98852+ const unsigned long prot);
98853+int gr_acl_handle_mprotect(const struct file *file,
98854+ const unsigned long prot);
98855+int gr_check_hidden_task(const struct task_struct *tsk);
98856+__u32 gr_acl_handle_truncate(const struct dentry *dentry,
98857+ const struct vfsmount *mnt);
98858+__u32 gr_acl_handle_utime(const struct dentry *dentry,
98859+ const struct vfsmount *mnt);
98860+__u32 gr_acl_handle_access(const struct dentry *dentry,
98861+ const struct vfsmount *mnt, const int fmode);
98862+__u32 gr_acl_handle_chmod(const struct dentry *dentry,
98863+ const struct vfsmount *mnt, umode_t *mode);
98864+__u32 gr_acl_handle_chown(const struct dentry *dentry,
98865+ const struct vfsmount *mnt);
98866+__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
98867+ const struct vfsmount *mnt);
98868+__u32 gr_acl_handle_removexattr(const struct dentry *dentry,
98869+ const struct vfsmount *mnt);
98870+int gr_handle_ptrace(struct task_struct *task, const long request);
98871+int gr_handle_proc_ptrace(struct task_struct *task);
98872+__u32 gr_acl_handle_execve(const struct dentry *dentry,
98873+ const struct vfsmount *mnt);
98874+int gr_check_crash_exec(const struct file *filp);
98875+int gr_acl_is_enabled(void);
98876+void gr_set_role_label(struct task_struct *task, const kuid_t uid,
98877+ const kgid_t gid);
98878+int gr_set_proc_label(const struct dentry *dentry,
98879+ const struct vfsmount *mnt,
98880+ const int unsafe_flags);
98881+__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
98882+ const struct vfsmount *mnt);
98883+__u32 gr_acl_handle_open(const struct dentry *dentry,
98884+ const struct vfsmount *mnt, int acc_mode);
98885+__u32 gr_acl_handle_creat(const struct dentry *dentry,
98886+ const struct dentry *p_dentry,
98887+ const struct vfsmount *p_mnt,
98888+ int open_flags, int acc_mode, const int imode);
98889+void gr_handle_create(const struct dentry *dentry,
98890+ const struct vfsmount *mnt);
98891+void gr_handle_proc_create(const struct dentry *dentry,
98892+ const struct inode *inode);
98893+__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
98894+ const struct dentry *parent_dentry,
98895+ const struct vfsmount *parent_mnt,
98896+ const int mode);
98897+__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
98898+ const struct dentry *parent_dentry,
98899+ const struct vfsmount *parent_mnt);
98900+__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
98901+ const struct vfsmount *mnt);
98902+void gr_handle_delete(const u64 ino, const dev_t dev);
98903+__u32 gr_acl_handle_unlink(const struct dentry *dentry,
98904+ const struct vfsmount *mnt);
98905+__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
98906+ const struct dentry *parent_dentry,
98907+ const struct vfsmount *parent_mnt,
98908+ const struct filename *from);
98909+__u32 gr_acl_handle_link(const struct dentry *new_dentry,
98910+ const struct dentry *parent_dentry,
98911+ const struct vfsmount *parent_mnt,
98912+ const struct dentry *old_dentry,
98913+ const struct vfsmount *old_mnt, const struct filename *to);
98914+int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
98915+int gr_acl_handle_rename(struct dentry *new_dentry,
98916+ struct dentry *parent_dentry,
98917+ const struct vfsmount *parent_mnt,
98918+ struct dentry *old_dentry,
98919+ struct inode *old_parent_inode,
98920+ struct vfsmount *old_mnt, const struct filename *newname, unsigned int flags);
98921+void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
98922+ struct dentry *old_dentry,
98923+ struct dentry *new_dentry,
98924+ struct vfsmount *mnt, const __u8 replace, unsigned int flags);
98925+__u32 gr_check_link(const struct dentry *new_dentry,
98926+ const struct dentry *parent_dentry,
98927+ const struct vfsmount *parent_mnt,
98928+ const struct dentry *old_dentry,
98929+ const struct vfsmount *old_mnt);
98930+int gr_acl_handle_filldir(const struct file *file, const char *name,
98931+ const unsigned int namelen, const u64 ino);
98932+
98933+__u32 gr_acl_handle_unix(const struct dentry *dentry,
98934+ const struct vfsmount *mnt);
98935+void gr_acl_handle_exit(void);
98936+void gr_acl_handle_psacct(struct task_struct *task, const long code);
98937+int gr_acl_handle_procpidmem(const struct task_struct *task);
98938+int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
98939+int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
98940+void gr_audit_ptrace(struct task_struct *task);
98941+dev_t gr_get_dev_from_dentry(struct dentry *dentry);
98942+u64 gr_get_ino_from_dentry(struct dentry *dentry);
98943+void gr_put_exec_file(struct task_struct *task);
98944+
98945+int gr_get_symlinkown_enabled(void);
98946+
98947+int gr_ptrace_readexec(struct file *file, int unsafe_flags);
98948+
98949+void gr_inc_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt);
98950+void gr_dec_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt);
98951+int gr_bad_chroot_rename(struct dentry *olddentry, struct vfsmount *oldmnt,
98952+ struct dentry *newdentry, struct vfsmount *newmnt);
98953+
98954+#ifdef CONFIG_GRKERNSEC_RESLOG
98955+extern void gr_log_resource(const struct task_struct *task, const int res,
98956+ const unsigned long wanted, const int gt);
98957+#else
98958+static inline void gr_log_resource(const struct task_struct *task, const int res,
98959+ const unsigned long wanted, const int gt)
98960+{
98961+}
98962+#endif
98963+
98964+#ifdef CONFIG_GRKERNSEC
98965+void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
98966+void gr_handle_vm86(void);
98967+void gr_handle_mem_readwrite(u64 from, u64 to);
98968+
98969+void gr_log_badprocpid(const char *entry);
98970+
98971+extern int grsec_enable_dmesg;
98972+extern int grsec_disable_privio;
98973+
98974+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
98975+extern kgid_t grsec_proc_gid;
98976+#endif
98977+
98978+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
98979+extern int grsec_enable_chroot_findtask;
98980+#endif
98981+#ifdef CONFIG_GRKERNSEC_SETXID
98982+extern int grsec_enable_setxid;
98983+#endif
98984+#endif
98985+
98986+#endif
98987diff --git a/include/linux/grsock.h b/include/linux/grsock.h
98988new file mode 100644
98989index 0000000..e7ffaaf
98990--- /dev/null
98991+++ b/include/linux/grsock.h
98992@@ -0,0 +1,19 @@
98993+#ifndef __GRSOCK_H
98994+#define __GRSOCK_H
98995+
98996+extern void gr_attach_curr_ip(const struct sock *sk);
98997+extern int gr_handle_sock_all(const int family, const int type,
98998+ const int protocol);
98999+extern int gr_handle_sock_server(const struct sockaddr *sck);
99000+extern int gr_handle_sock_server_other(const struct sock *sck);
99001+extern int gr_handle_sock_client(const struct sockaddr *sck);
99002+extern int gr_search_connect(struct socket * sock,
99003+ struct sockaddr_in * addr);
99004+extern int gr_search_bind(struct socket * sock,
99005+ struct sockaddr_in * addr);
99006+extern int gr_search_listen(struct socket * sock);
99007+extern int gr_search_accept(struct socket * sock);
99008+extern int gr_search_socket(const int domain, const int type,
99009+ const int protocol);
99010+
99011+#endif
99012diff --git a/include/linux/highmem.h b/include/linux/highmem.h
99013index 6aefcd0..98b81dc 100644
99014--- a/include/linux/highmem.h
99015+++ b/include/linux/highmem.h
99016@@ -191,6 +191,18 @@ static inline void clear_highpage(struct page *page)
99017 kunmap_atomic(kaddr);
99018 }
99019
99020+static inline void sanitize_highpage(struct page *page)
99021+{
99022+ void *kaddr;
99023+ unsigned long flags;
99024+
99025+ local_irq_save(flags);
99026+ kaddr = kmap_atomic(page);
99027+ clear_page(kaddr);
99028+ kunmap_atomic(kaddr);
99029+ local_irq_restore(flags);
99030+}
99031+
99032 static inline void zero_user_segments(struct page *page,
99033 unsigned start1, unsigned end1,
99034 unsigned start2, unsigned end2)
99035diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
99036index 1c7b89a..7dda400 100644
99037--- a/include/linux/hwmon-sysfs.h
99038+++ b/include/linux/hwmon-sysfs.h
99039@@ -25,7 +25,8 @@
99040 struct sensor_device_attribute{
99041 struct device_attribute dev_attr;
99042 int index;
99043-};
99044+} __do_const;
99045+typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
99046 #define to_sensor_dev_attr(_dev_attr) \
99047 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
99048
99049@@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
99050 struct device_attribute dev_attr;
99051 u8 index;
99052 u8 nr;
99053-};
99054+} __do_const;
99055+typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
99056 #define to_sensor_dev_attr_2(_dev_attr) \
99057 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
99058
99059diff --git a/include/linux/i2c.h b/include/linux/i2c.h
99060index e83a738..8b323fa 100644
99061--- a/include/linux/i2c.h
99062+++ b/include/linux/i2c.h
99063@@ -409,6 +409,7 @@ struct i2c_algorithm {
99064 int (*unreg_slave)(struct i2c_client *client);
99065 #endif
99066 };
99067+typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
99068
99069 /**
99070 * struct i2c_bus_recovery_info - I2C bus recovery information
99071diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
99072index b49cf92..0c29072 100644
99073--- a/include/linux/if_pppox.h
99074+++ b/include/linux/if_pppox.h
99075@@ -78,7 +78,7 @@ struct pppox_proto {
99076 int (*ioctl)(struct socket *sock, unsigned int cmd,
99077 unsigned long arg);
99078 struct module *owner;
99079-};
99080+} __do_const;
99081
99082 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
99083 extern void unregister_pppox_proto(int proto_num);
99084diff --git a/include/linux/init.h b/include/linux/init.h
99085index b449f37..61005b3 100644
99086--- a/include/linux/init.h
99087+++ b/include/linux/init.h
99088@@ -37,9 +37,17 @@
99089 * section.
99090 */
99091
99092+#define add_init_latent_entropy __latent_entropy
99093+
99094+#ifdef CONFIG_MEMORY_HOTPLUG
99095+#define add_meminit_latent_entropy
99096+#else
99097+#define add_meminit_latent_entropy __latent_entropy
99098+#endif
99099+
99100 /* These are for everybody (although not all archs will actually
99101 discard it in modules) */
99102-#define __init __section(.init.text) __cold notrace
99103+#define __init __section(.init.text) __cold notrace add_init_latent_entropy
99104 #define __initdata __section(.init.data)
99105 #define __initconst __constsection(.init.rodata)
99106 #define __exitdata __section(.exit.data)
99107@@ -92,7 +100,7 @@
99108 #define __exit __section(.exit.text) __exitused __cold notrace
99109
99110 /* Used for MEMORY_HOTPLUG */
99111-#define __meminit __section(.meminit.text) __cold notrace
99112+#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
99113 #define __meminitdata __section(.meminit.data)
99114 #define __meminitconst __constsection(.meminit.rodata)
99115 #define __memexit __section(.memexit.text) __exitused __cold notrace
99116diff --git a/include/linux/init_task.h b/include/linux/init_task.h
99117index bb9b075..ecac42c 100644
99118--- a/include/linux/init_task.h
99119+++ b/include/linux/init_task.h
99120@@ -157,6 +157,12 @@ extern struct task_group root_task_group;
99121
99122 #define INIT_TASK_COMM "swapper"
99123
99124+#ifdef CONFIG_X86
99125+#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
99126+#else
99127+#define INIT_TASK_THREAD_INFO
99128+#endif
99129+
99130 #ifdef CONFIG_RT_MUTEXES
99131 # define INIT_RT_MUTEXES(tsk) \
99132 .pi_waiters = RB_ROOT, \
99133@@ -223,6 +229,7 @@ extern struct task_group root_task_group;
99134 RCU_POINTER_INITIALIZER(cred, &init_cred), \
99135 .comm = INIT_TASK_COMM, \
99136 .thread = INIT_THREAD, \
99137+ INIT_TASK_THREAD_INFO \
99138 .fs = &init_fs, \
99139 .files = &init_files, \
99140 .signal = &init_signals, \
99141diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
99142index be7e75c..09bec77 100644
99143--- a/include/linux/interrupt.h
99144+++ b/include/linux/interrupt.h
99145@@ -433,8 +433,8 @@ extern const char * const softirq_to_name[NR_SOFTIRQS];
99146
99147 struct softirq_action
99148 {
99149- void (*action)(struct softirq_action *);
99150-};
99151+ void (*action)(void);
99152+} __no_const;
99153
99154 asmlinkage void do_softirq(void);
99155 asmlinkage void __do_softirq(void);
99156@@ -448,7 +448,7 @@ static inline void do_softirq_own_stack(void)
99157 }
99158 #endif
99159
99160-extern void open_softirq(int nr, void (*action)(struct softirq_action *));
99161+extern void open_softirq(int nr, void (*action)(void));
99162 extern void softirq_init(void);
99163 extern void __raise_softirq_irqoff(unsigned int nr);
99164
99165diff --git a/include/linux/iommu.h b/include/linux/iommu.h
99166index f9c1b6d..db7d6f5 100644
99167--- a/include/linux/iommu.h
99168+++ b/include/linux/iommu.h
99169@@ -192,7 +192,7 @@ struct iommu_ops {
99170
99171 unsigned long pgsize_bitmap;
99172 void *priv;
99173-};
99174+} __do_const;
99175
99176 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
99177 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
99178diff --git a/include/linux/ioport.h b/include/linux/ioport.h
99179index 388e3ae..d7e45a1 100644
99180--- a/include/linux/ioport.h
99181+++ b/include/linux/ioport.h
99182@@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
99183 int adjust_resource(struct resource *res, resource_size_t start,
99184 resource_size_t size);
99185 resource_size_t resource_alignment(struct resource *res);
99186-static inline resource_size_t resource_size(const struct resource *res)
99187+static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
99188 {
99189 return res->end - res->start + 1;
99190 }
99191diff --git a/include/linux/ipc.h b/include/linux/ipc.h
99192index 9d84942..12d5bdf 100644
99193--- a/include/linux/ipc.h
99194+++ b/include/linux/ipc.h
99195@@ -19,8 +19,8 @@ struct kern_ipc_perm
99196 kuid_t cuid;
99197 kgid_t cgid;
99198 umode_t mode;
99199- unsigned long seq;
99200+ unsigned long seq __intentional_overflow(-1);
99201 void *security;
99202-};
99203+} __randomize_layout;
99204
99205 #endif /* _LINUX_IPC_H */
99206diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
99207index 1eee6bc..9cf4912 100644
99208--- a/include/linux/ipc_namespace.h
99209+++ b/include/linux/ipc_namespace.h
99210@@ -60,7 +60,7 @@ struct ipc_namespace {
99211 struct user_namespace *user_ns;
99212
99213 struct ns_common ns;
99214-};
99215+} __randomize_layout;
99216
99217 extern struct ipc_namespace init_ipc_ns;
99218 extern atomic_t nr_ipc_ns;
99219diff --git a/include/linux/irq.h b/include/linux/irq.h
99220index 51744bc..e902653 100644
99221--- a/include/linux/irq.h
99222+++ b/include/linux/irq.h
99223@@ -383,7 +383,10 @@ struct irq_chip {
99224 int (*irq_set_vcpu_affinity)(struct irq_data *data, void *vcpu_info);
99225
99226 unsigned long flags;
99227-};
99228+} __do_const;
99229+#ifndef _LINUX_IRQDOMAIN_H
99230+typedef struct irq_chip __no_const irq_chip_no_const;
99231+#endif
99232
99233 /*
99234 * irq_chip specific flags
99235diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
99236index fcea4e4..cff381d 100644
99237--- a/include/linux/irqdesc.h
99238+++ b/include/linux/irqdesc.h
99239@@ -59,7 +59,7 @@ struct irq_desc {
99240 unsigned int irq_count; /* For detecting broken IRQs */
99241 unsigned long last_unhandled; /* Aging timer for unhandled count */
99242 unsigned int irqs_unhandled;
99243- atomic_t threads_handled;
99244+ atomic_unchecked_t threads_handled;
99245 int threads_handled_last;
99246 raw_spinlock_t lock;
99247 struct cpumask *percpu_enabled;
99248diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
99249index 744ac0e..382b1a6 100644
99250--- a/include/linux/irqdomain.h
99251+++ b/include/linux/irqdomain.h
99252@@ -40,6 +40,9 @@ struct device_node;
99253 struct irq_domain;
99254 struct of_device_id;
99255 struct irq_chip;
99256+#ifndef _LINUX_IRQ_H
99257+typedef struct irq_chip __no_const irq_chip_no_const;
99258+#endif
99259 struct irq_data;
99260
99261 /* Number of irqs reserved for a legacy isa controller */
99262diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
99263index 535fd3b..e5c356e 100644
99264--- a/include/linux/jiffies.h
99265+++ b/include/linux/jiffies.h
99266@@ -284,19 +284,19 @@ extern unsigned long preset_lpj;
99267 extern unsigned int jiffies_to_msecs(const unsigned long j);
99268 extern unsigned int jiffies_to_usecs(const unsigned long j);
99269
99270-static inline u64 jiffies_to_nsecs(const unsigned long j)
99271+static inline u64 __intentional_overflow(-1) jiffies_to_nsecs(const unsigned long j)
99272 {
99273 return (u64)jiffies_to_usecs(j) * NSEC_PER_USEC;
99274 }
99275
99276-extern unsigned long __msecs_to_jiffies(const unsigned int m);
99277+extern unsigned long __msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
99278 #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
99279 /*
99280 * HZ is equal to or smaller than 1000, and 1000 is a nice round
99281 * multiple of HZ, divide with the factor between them, but round
99282 * upwards:
99283 */
99284-static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99285+static inline unsigned long __intentional_overflow(-1) _msecs_to_jiffies(const unsigned int m)
99286 {
99287 return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
99288 }
99289@@ -307,7 +307,7 @@ static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99290 *
99291 * But first make sure the multiplication result cannot overflow:
99292 */
99293-static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99294+static inline unsigned long __intentional_overflow(-1) _msecs_to_jiffies(const unsigned int m)
99295 {
99296 if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
99297 return MAX_JIFFY_OFFSET;
99298@@ -318,7 +318,7 @@ static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99299 * Generic case - multiply, round and divide. But first check that if
99300 * we are doing a net multiplication, that we wouldn't overflow:
99301 */
99302-static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99303+static inline unsigned long __intentional_overflow(-1) _msecs_to_jiffies(const unsigned int m)
99304 {
99305 if (HZ > MSEC_PER_SEC && m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
99306 return MAX_JIFFY_OFFSET;
99307@@ -362,21 +362,19 @@ static inline unsigned long msecs_to_jiffies(const unsigned int m)
99308 }
99309 }
99310
99311-extern unsigned long __usecs_to_jiffies(const unsigned int u);
99312+extern unsigned long __usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
99313 #if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ)
99314-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
99315+static inline unsigned long __intentional_overflow(-1) _usecs_to_jiffies(const unsigned int u)
99316 {
99317 return (u + (USEC_PER_SEC / HZ) - 1) / (USEC_PER_SEC / HZ);
99318 }
99319 #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC)
99320-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
99321+static inline unsigned long __intentional_overflow(-1) _usecs_to_jiffies(const unsigned int u)
99322 {
99323 return u * (HZ / USEC_PER_SEC);
99324 }
99325-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
99326-{
99327 #else
99328-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
99329+static inline unsigned long __intentional_overflow(-1) _usecs_to_jiffies(const unsigned int u)
99330 {
99331 return (USEC_TO_HZ_MUL32 * u + USEC_TO_HZ_ADJ32)
99332 >> USEC_TO_HZ_SHR32;
99333diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
99334index 6883e19..e854fcb 100644
99335--- a/include/linux/kallsyms.h
99336+++ b/include/linux/kallsyms.h
99337@@ -15,7 +15,8 @@
99338
99339 struct module;
99340
99341-#ifdef CONFIG_KALLSYMS
99342+#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
99343+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
99344 /* Lookup the address for a symbol. Returns 0 if not found. */
99345 unsigned long kallsyms_lookup_name(const char *name);
99346
99347@@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
99348 /* Stupid that this does nothing, but I didn't create this mess. */
99349 #define __print_symbol(fmt, addr)
99350 #endif /*CONFIG_KALLSYMS*/
99351+#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
99352+ arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
99353+extern unsigned long kallsyms_lookup_name(const char *name);
99354+extern void __print_symbol(const char *fmt, unsigned long address);
99355+extern int sprint_backtrace(char *buffer, unsigned long address);
99356+extern int sprint_symbol(char *buffer, unsigned long address);
99357+extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
99358+const char *kallsyms_lookup(unsigned long addr,
99359+ unsigned long *symbolsize,
99360+ unsigned long *offset,
99361+ char **modname, char *namebuf);
99362+extern int kallsyms_lookup_size_offset(unsigned long addr,
99363+ unsigned long *symbolsize,
99364+ unsigned long *offset);
99365+#endif
99366
99367 /* This macro allows us to keep printk typechecking */
99368 static __printf(1, 2)
99369diff --git a/include/linux/key-type.h b/include/linux/key-type.h
99370index ff9f1d3..6712be5 100644
99371--- a/include/linux/key-type.h
99372+++ b/include/linux/key-type.h
99373@@ -152,7 +152,7 @@ struct key_type {
99374 /* internal fields */
99375 struct list_head link; /* link in types list */
99376 struct lock_class_key lock_class; /* key->sem lock class */
99377-};
99378+} __do_const;
99379
99380 extern struct key_type key_type_keyring;
99381
99382diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
99383index e465bb1..19f605fd 100644
99384--- a/include/linux/kgdb.h
99385+++ b/include/linux/kgdb.h
99386@@ -52,7 +52,7 @@ extern int kgdb_connected;
99387 extern int kgdb_io_module_registered;
99388
99389 extern atomic_t kgdb_setting_breakpoint;
99390-extern atomic_t kgdb_cpu_doing_single_step;
99391+extern atomic_unchecked_t kgdb_cpu_doing_single_step;
99392
99393 extern struct task_struct *kgdb_usethread;
99394 extern struct task_struct *kgdb_contthread;
99395@@ -254,7 +254,7 @@ struct kgdb_arch {
99396 void (*correct_hw_break)(void);
99397
99398 void (*enable_nmi)(bool on);
99399-};
99400+} __do_const;
99401
99402 /**
99403 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
99404@@ -279,7 +279,7 @@ struct kgdb_io {
99405 void (*pre_exception) (void);
99406 void (*post_exception) (void);
99407 int is_console;
99408-};
99409+} __do_const;
99410
99411 extern struct kgdb_arch arch_kgdb_ops;
99412
99413diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h
99414index d0a1f99..0bd8b7c 100644
99415--- a/include/linux/kmemleak.h
99416+++ b/include/linux/kmemleak.h
99417@@ -27,7 +27,7 @@
99418
99419 extern void kmemleak_init(void) __ref;
99420 extern void kmemleak_alloc(const void *ptr, size_t size, int min_count,
99421- gfp_t gfp) __ref;
99422+ gfp_t gfp) __ref __size_overflow(2);
99423 extern void kmemleak_alloc_percpu(const void __percpu *ptr, size_t size,
99424 gfp_t gfp) __ref;
99425 extern void kmemleak_free(const void *ptr) __ref;
99426@@ -63,7 +63,7 @@ static inline void kmemleak_erase(void **ptr)
99427 static inline void kmemleak_init(void)
99428 {
99429 }
99430-static inline void kmemleak_alloc(const void *ptr, size_t size, int min_count,
99431+static inline void __size_overflow(2) kmemleak_alloc(const void *ptr, size_t size, int min_count,
99432 gfp_t gfp)
99433 {
99434 }
99435diff --git a/include/linux/kmod.h b/include/linux/kmod.h
99436index 0555cc6..40116ce 100644
99437--- a/include/linux/kmod.h
99438+++ b/include/linux/kmod.h
99439@@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
99440 * usually useless though. */
99441 extern __printf(2, 3)
99442 int __request_module(bool wait, const char *name, ...);
99443+extern __printf(3, 4)
99444+int ___request_module(bool wait, char *param_name, const char *name, ...);
99445 #define request_module(mod...) __request_module(true, mod)
99446 #define request_module_nowait(mod...) __request_module(false, mod)
99447 #define try_then_request_module(x, mod...) \
99448@@ -57,6 +59,9 @@ struct subprocess_info {
99449 struct work_struct work;
99450 struct completion *complete;
99451 char *path;
99452+#ifdef CONFIG_GRKERNSEC
99453+ char *origpath;
99454+#endif
99455 char **argv;
99456 char **envp;
99457 int wait;
99458diff --git a/include/linux/kobject.h b/include/linux/kobject.h
99459index 637f670..3d69945 100644
99460--- a/include/linux/kobject.h
99461+++ b/include/linux/kobject.h
99462@@ -119,7 +119,7 @@ struct kobj_type {
99463 struct attribute **default_attrs;
99464 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
99465 const void *(*namespace)(struct kobject *kobj);
99466-};
99467+} __do_const;
99468
99469 struct kobj_uevent_env {
99470 char *argv[3];
99471@@ -143,6 +143,7 @@ struct kobj_attribute {
99472 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
99473 const char *buf, size_t count);
99474 };
99475+typedef struct kobj_attribute __no_const kobj_attribute_no_const;
99476
99477 extern const struct sysfs_ops kobj_sysfs_ops;
99478
99479@@ -170,7 +171,7 @@ struct kset {
99480 spinlock_t list_lock;
99481 struct kobject kobj;
99482 const struct kset_uevent_ops *uevent_ops;
99483-};
99484+} __randomize_layout;
99485
99486 extern void kset_init(struct kset *kset);
99487 extern int __must_check kset_register(struct kset *kset);
99488diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
99489index df32d25..fb52e27 100644
99490--- a/include/linux/kobject_ns.h
99491+++ b/include/linux/kobject_ns.h
99492@@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
99493 const void *(*netlink_ns)(struct sock *sk);
99494 const void *(*initial_ns)(void);
99495 void (*drop_ns)(void *);
99496-};
99497+} __do_const;
99498
99499 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
99500 int kobj_ns_type_registered(enum kobj_ns_type type);
99501diff --git a/include/linux/kref.h b/include/linux/kref.h
99502index 484604d..0f6c5b6 100644
99503--- a/include/linux/kref.h
99504+++ b/include/linux/kref.h
99505@@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
99506 static inline int kref_sub(struct kref *kref, unsigned int count,
99507 void (*release)(struct kref *kref))
99508 {
99509- WARN_ON(release == NULL);
99510+ BUG_ON(release == NULL);
99511
99512 if (atomic_sub_and_test((int) count, &kref->refcount)) {
99513 release(kref);
99514diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
99515index 05e99b8..484b1f97 100644
99516--- a/include/linux/kvm_host.h
99517+++ b/include/linux/kvm_host.h
99518@@ -468,7 +468,7 @@ static inline void kvm_irqfd_exit(void)
99519 {
99520 }
99521 #endif
99522-int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
99523+int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
99524 struct module *module);
99525 void kvm_exit(void);
99526
99527@@ -678,7 +678,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
99528 struct kvm_guest_debug *dbg);
99529 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
99530
99531-int kvm_arch_init(void *opaque);
99532+int kvm_arch_init(const void *opaque);
99533 void kvm_arch_exit(void);
99534
99535 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
99536diff --git a/include/linux/libata.h b/include/linux/libata.h
99537index c9cfbcd..46986db 100644
99538--- a/include/linux/libata.h
99539+++ b/include/linux/libata.h
99540@@ -990,7 +990,7 @@ struct ata_port_operations {
99541 * fields must be pointers.
99542 */
99543 const struct ata_port_operations *inherits;
99544-};
99545+} __do_const;
99546
99547 struct ata_port_info {
99548 unsigned long flags;
99549diff --git a/include/linux/linkage.h b/include/linux/linkage.h
99550index a6a42dd..6c5ebce 100644
99551--- a/include/linux/linkage.h
99552+++ b/include/linux/linkage.h
99553@@ -36,6 +36,7 @@
99554 #endif
99555
99556 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
99557+#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
99558 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
99559
99560 /*
99561diff --git a/include/linux/list.h b/include/linux/list.h
99562index feb773c..98f3075 100644
99563--- a/include/linux/list.h
99564+++ b/include/linux/list.h
99565@@ -113,6 +113,19 @@ extern void __list_del_entry(struct list_head *entry);
99566 extern void list_del(struct list_head *entry);
99567 #endif
99568
99569+extern void __pax_list_add(struct list_head *new,
99570+ struct list_head *prev,
99571+ struct list_head *next);
99572+static inline void pax_list_add(struct list_head *new, struct list_head *head)
99573+{
99574+ __pax_list_add(new, head, head->next);
99575+}
99576+static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
99577+{
99578+ __pax_list_add(new, head->prev, head);
99579+}
99580+extern void pax_list_del(struct list_head *entry);
99581+
99582 /**
99583 * list_replace - replace old entry by new one
99584 * @old : the element to be replaced
99585@@ -146,6 +159,8 @@ static inline void list_del_init(struct list_head *entry)
99586 INIT_LIST_HEAD(entry);
99587 }
99588
99589+extern void pax_list_del_init(struct list_head *entry);
99590+
99591 /**
99592 * list_move - delete from one list and add as another's head
99593 * @list: the entry to move
99594diff --git a/include/linux/lockref.h b/include/linux/lockref.h
99595index b10b122..d37b3de 100644
99596--- a/include/linux/lockref.h
99597+++ b/include/linux/lockref.h
99598@@ -28,7 +28,7 @@ struct lockref {
99599 #endif
99600 struct {
99601 spinlock_t lock;
99602- int count;
99603+ atomic_t count;
99604 };
99605 };
99606 };
99607@@ -43,9 +43,29 @@ extern void lockref_mark_dead(struct lockref *);
99608 extern int lockref_get_not_dead(struct lockref *);
99609
99610 /* Must be called under spinlock for reliable results */
99611-static inline int __lockref_is_dead(const struct lockref *l)
99612+static inline int __lockref_is_dead(const struct lockref *lockref)
99613 {
99614- return ((int)l->count < 0);
99615+ return atomic_read(&lockref->count) < 0;
99616+}
99617+
99618+static inline int __lockref_read(const struct lockref *lockref)
99619+{
99620+ return atomic_read(&lockref->count);
99621+}
99622+
99623+static inline void __lockref_set(struct lockref *lockref, int count)
99624+{
99625+ atomic_set(&lockref->count, count);
99626+}
99627+
99628+static inline void __lockref_inc(struct lockref *lockref)
99629+{
99630+ atomic_inc(&lockref->count);
99631+}
99632+
99633+static inline void __lockref_dec(struct lockref *lockref)
99634+{
99635+ atomic_dec(&lockref->count);
99636 }
99637
99638 #endif /* __LINUX_LOCKREF_H */
99639diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
99640index 9429f05..a5d5425 100644
99641--- a/include/linux/lsm_hooks.h
99642+++ b/include/linux/lsm_hooks.h
99643@@ -1824,7 +1824,7 @@ struct security_hook_heads {
99644 struct list_head audit_rule_match;
99645 struct list_head audit_rule_free;
99646 #endif /* CONFIG_AUDIT */
99647-};
99648+} __randomize_layout;
99649
99650 /*
99651 * Security module hook list structure.
99652@@ -1834,7 +1834,7 @@ struct security_hook_list {
99653 struct list_head list;
99654 struct list_head *head;
99655 union security_list_options hook;
99656-};
99657+} __randomize_layout;
99658
99659 /*
99660 * Initializing a security_hook_list structure takes
99661diff --git a/include/linux/math64.h b/include/linux/math64.h
99662index c45c089..298841c 100644
99663--- a/include/linux/math64.h
99664+++ b/include/linux/math64.h
99665@@ -15,7 +15,7 @@
99666 * This is commonly provided by 32bit archs to provide an optimized 64bit
99667 * divide.
99668 */
99669-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
99670+static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
99671 {
99672 *remainder = dividend % divisor;
99673 return dividend / divisor;
99674@@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
99675 /**
99676 * div64_u64 - unsigned 64bit divide with 64bit divisor
99677 */
99678-static inline u64 div64_u64(u64 dividend, u64 divisor)
99679+static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
99680 {
99681 return dividend / divisor;
99682 }
99683@@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
99684 #define div64_ul(x, y) div_u64((x), (y))
99685
99686 #ifndef div_u64_rem
99687-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
99688+static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
99689 {
99690 *remainder = do_div(dividend, divisor);
99691 return dividend;
99692@@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
99693 #endif
99694
99695 #ifndef div64_u64
99696-extern u64 div64_u64(u64 dividend, u64 divisor);
99697+extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
99698 #endif
99699
99700 #ifndef div64_s64
99701@@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
99702 * divide.
99703 */
99704 #ifndef div_u64
99705-static inline u64 div_u64(u64 dividend, u32 divisor)
99706+static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
99707 {
99708 u32 remainder;
99709 return div_u64_rem(dividend, divisor, &remainder);
99710diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
99711index 3d385c8..deacb6a 100644
99712--- a/include/linux/mempolicy.h
99713+++ b/include/linux/mempolicy.h
99714@@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
99715 }
99716
99717 #define vma_policy(vma) ((vma)->vm_policy)
99718+static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
99719+{
99720+ vma->vm_policy = pol;
99721+}
99722
99723 static inline void mpol_get(struct mempolicy *pol)
99724 {
99725@@ -229,6 +233,9 @@ static inline void mpol_free_shared_policy(struct shared_policy *p)
99726 }
99727
99728 #define vma_policy(vma) NULL
99729+static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
99730+{
99731+}
99732
99733 static inline int
99734 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
99735diff --git a/include/linux/mm.h b/include/linux/mm.h
99736index 2b05068..c58989c 100644
99737--- a/include/linux/mm.h
99738+++ b/include/linux/mm.h
99739@@ -136,6 +136,11 @@ extern unsigned int kobjsize(const void *objp);
99740
99741 #define VM_DONTCOPY 0x00020000 /* Do not copy this vma on fork */
99742 #define VM_DONTEXPAND 0x00040000 /* Cannot expand with mremap() */
99743+
99744+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
99745+#define VM_PAGEEXEC 0x00080000 /* vma->vm_page_prot needs special handling */
99746+#endif
99747+
99748 #define VM_ACCOUNT 0x00100000 /* Is a VM accounted object */
99749 #define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */
99750 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
99751@@ -258,8 +263,8 @@ struct vm_operations_struct {
99752 /* called by access_process_vm when get_user_pages() fails, typically
99753 * for use by special VMAs that can switch between memory and hardware
99754 */
99755- int (*access)(struct vm_area_struct *vma, unsigned long addr,
99756- void *buf, int len, int write);
99757+ ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
99758+ void *buf, size_t len, int write);
99759
99760 /* Called by the /proc/PID/maps code to ask the vma whether it
99761 * has a special name. Returning non-NULL will also cause this
99762@@ -297,6 +302,7 @@ struct vm_operations_struct {
99763 struct page *(*find_special_page)(struct vm_area_struct *vma,
99764 unsigned long addr);
99765 };
99766+typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
99767
99768 struct mmu_gather;
99769 struct inode;
99770@@ -1181,8 +1187,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
99771 unsigned long *pfn);
99772 int follow_phys(struct vm_area_struct *vma, unsigned long address,
99773 unsigned int flags, unsigned long *prot, resource_size_t *phys);
99774-int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
99775- void *buf, int len, int write);
99776+ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
99777+ void *buf, size_t len, int write);
99778
99779 static inline void unmap_shared_mapping_range(struct address_space *mapping,
99780 loff_t const holebegin, loff_t const holelen)
99781@@ -1222,9 +1228,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
99782 }
99783 #endif
99784
99785-extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
99786-extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
99787- void *buf, int len, int write);
99788+extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
99789+extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
99790+ void *buf, size_t len, int write);
99791
99792 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
99793 unsigned long start, unsigned long nr_pages,
99794@@ -1272,34 +1278,6 @@ int clear_page_dirty_for_io(struct page *page);
99795
99796 int get_cmdline(struct task_struct *task, char *buffer, int buflen);
99797
99798-/* Is the vma a continuation of the stack vma above it? */
99799-static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
99800-{
99801- return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
99802-}
99803-
99804-static inline int stack_guard_page_start(struct vm_area_struct *vma,
99805- unsigned long addr)
99806-{
99807- return (vma->vm_flags & VM_GROWSDOWN) &&
99808- (vma->vm_start == addr) &&
99809- !vma_growsdown(vma->vm_prev, addr);
99810-}
99811-
99812-/* Is the vma a continuation of the stack vma below it? */
99813-static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
99814-{
99815- return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
99816-}
99817-
99818-static inline int stack_guard_page_end(struct vm_area_struct *vma,
99819- unsigned long addr)
99820-{
99821- return (vma->vm_flags & VM_GROWSUP) &&
99822- (vma->vm_end == addr) &&
99823- !vma_growsup(vma->vm_next, addr);
99824-}
99825-
99826 extern struct task_struct *task_of_stack(struct task_struct *task,
99827 struct vm_area_struct *vma, bool in_group);
99828
99829@@ -1422,8 +1400,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
99830 {
99831 return 0;
99832 }
99833+
99834+static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
99835+ unsigned long address)
99836+{
99837+ return 0;
99838+}
99839 #else
99840 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
99841+int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
99842 #endif
99843
99844 #if defined(__PAGETABLE_PMD_FOLDED) || !defined(CONFIG_MMU)
99845@@ -1433,6 +1418,12 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
99846 return 0;
99847 }
99848
99849+static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
99850+ unsigned long address)
99851+{
99852+ return 0;
99853+}
99854+
99855 static inline void mm_nr_pmds_init(struct mm_struct *mm) {}
99856
99857 static inline unsigned long mm_nr_pmds(struct mm_struct *mm)
99858@@ -1445,6 +1436,7 @@ static inline void mm_dec_nr_pmds(struct mm_struct *mm) {}
99859
99860 #else
99861 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
99862+int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
99863
99864 static inline void mm_nr_pmds_init(struct mm_struct *mm)
99865 {
99866@@ -1482,11 +1474,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
99867 NULL: pud_offset(pgd, address);
99868 }
99869
99870+static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
99871+{
99872+ return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
99873+ NULL: pud_offset(pgd, address);
99874+}
99875+
99876 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
99877 {
99878 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
99879 NULL: pmd_offset(pud, address);
99880 }
99881+
99882+static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
99883+{
99884+ return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
99885+ NULL: pmd_offset(pud, address);
99886+}
99887 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
99888
99889 #if USE_SPLIT_PTE_PTLOCKS
99890@@ -1867,12 +1871,23 @@ extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
99891 bool *need_rmap_locks);
99892 extern void exit_mmap(struct mm_struct *);
99893
99894+#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
99895+extern void gr_learn_resource(const struct task_struct *task, const int res,
99896+ const unsigned long wanted, const int gt);
99897+#else
99898+static inline void gr_learn_resource(const struct task_struct *task, const int res,
99899+ const unsigned long wanted, const int gt)
99900+{
99901+}
99902+#endif
99903+
99904 static inline int check_data_rlimit(unsigned long rlim,
99905 unsigned long new,
99906 unsigned long start,
99907 unsigned long end_data,
99908 unsigned long start_data)
99909 {
99910+ gr_learn_resource(current, RLIMIT_DATA, (new - start) + (end_data - start_data), 1);
99911 if (rlim < RLIM_INFINITY) {
99912 if (((new - start) + (end_data - start_data)) > rlim)
99913 return -ENOSPC;
99914@@ -1905,6 +1920,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
99915 unsigned long len, unsigned long prot, unsigned long flags,
99916 unsigned long pgoff, unsigned long *populate);
99917 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
99918+extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
99919
99920 #ifdef CONFIG_MMU
99921 extern int __mm_populate(unsigned long addr, unsigned long len,
99922@@ -1933,10 +1949,11 @@ struct vm_unmapped_area_info {
99923 unsigned long high_limit;
99924 unsigned long align_mask;
99925 unsigned long align_offset;
99926+ unsigned long threadstack_offset;
99927 };
99928
99929-extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
99930-extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
99931+extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
99932+extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
99933
99934 /*
99935 * Search for an unmapped address range.
99936@@ -1948,7 +1965,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
99937 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
99938 */
99939 static inline unsigned long
99940-vm_unmapped_area(struct vm_unmapped_area_info *info)
99941+vm_unmapped_area(const struct vm_unmapped_area_info *info)
99942 {
99943 if (info->flags & VM_UNMAPPED_AREA_TOPDOWN)
99944 return unmapped_area_topdown(info);
99945@@ -2010,6 +2027,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
99946 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
99947 struct vm_area_struct **pprev);
99948
99949+extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
99950+extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
99951+extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
99952+
99953 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
99954 NULL if none. Assume start_addr < end_addr. */
99955 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
99956@@ -2039,10 +2060,10 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
99957 }
99958
99959 #ifdef CONFIG_MMU
99960-pgprot_t vm_get_page_prot(unsigned long vm_flags);
99961+pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
99962 void vma_set_page_prot(struct vm_area_struct *vma);
99963 #else
99964-static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
99965+static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
99966 {
99967 return __pgprot(0);
99968 }
99969@@ -2104,6 +2125,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
99970 static inline void vm_stat_account(struct mm_struct *mm,
99971 unsigned long flags, struct file *file, long pages)
99972 {
99973+
99974+#ifdef CONFIG_PAX_RANDMMAP
99975+ if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
99976+#endif
99977+
99978 mm->total_vm += pages;
99979 }
99980 #endif /* CONFIG_PROC_FS */
99981@@ -2207,7 +2233,7 @@ extern int get_hwpoison_page(struct page *page);
99982 extern int sysctl_memory_failure_early_kill;
99983 extern int sysctl_memory_failure_recovery;
99984 extern void shake_page(struct page *p, int access);
99985-extern atomic_long_t num_poisoned_pages;
99986+extern atomic_long_unchecked_t num_poisoned_pages;
99987 extern int soft_offline_page(struct page *page, int flags);
99988
99989
99990@@ -2292,5 +2318,11 @@ void __init setup_nr_node_ids(void);
99991 static inline void setup_nr_node_ids(void) {}
99992 #endif
99993
99994+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
99995+extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
99996+#else
99997+static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
99998+#endif
99999+
100000 #endif /* __KERNEL__ */
100001 #endif /* _LINUX_MM_H */
100002diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
100003index 1554957..0973bc5 100644
100004--- a/include/linux/mm_types.h
100005+++ b/include/linux/mm_types.h
100006@@ -322,7 +322,9 @@ struct vm_area_struct {
100007 #ifdef CONFIG_NUMA
100008 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
100009 #endif
100010-};
100011+
100012+ struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
100013+} __randomize_layout;
100014
100015 struct core_thread {
100016 struct task_struct *task;
100017@@ -475,7 +477,25 @@ struct mm_struct {
100018 /* address of the bounds directory */
100019 void __user *bd_addr;
100020 #endif
100021-};
100022+
100023+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
100024+ unsigned long pax_flags;
100025+#endif
100026+
100027+#ifdef CONFIG_PAX_DLRESOLVE
100028+ unsigned long call_dl_resolve;
100029+#endif
100030+
100031+#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
100032+ unsigned long call_syscall;
100033+#endif
100034+
100035+#ifdef CONFIG_PAX_ASLR
100036+ unsigned long delta_mmap; /* randomized offset */
100037+ unsigned long delta_stack; /* randomized offset */
100038+#endif
100039+
100040+} __randomize_layout;
100041
100042 static inline void mm_init_cpumask(struct mm_struct *mm)
100043 {
100044diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
100045index 3ba327a..85cd5ce 100644
100046--- a/include/linux/mmiotrace.h
100047+++ b/include/linux/mmiotrace.h
100048@@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
100049 /* Called from ioremap.c */
100050 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
100051 void __iomem *addr);
100052-extern void mmiotrace_iounmap(volatile void __iomem *addr);
100053+extern void mmiotrace_iounmap(const volatile void __iomem *addr);
100054
100055 /* For anyone to insert markers. Remember trailing newline. */
100056 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
100057@@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
100058 {
100059 }
100060
100061-static inline void mmiotrace_iounmap(volatile void __iomem *addr)
100062+static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
100063 {
100064 }
100065
100066diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
100067index 754c259..7b65ac6 100644
100068--- a/include/linux/mmzone.h
100069+++ b/include/linux/mmzone.h
100070@@ -526,7 +526,7 @@ struct zone {
100071
100072 ZONE_PADDING(_pad3_)
100073 /* Zone statistics */
100074- atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
100075+ atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
100076 } ____cacheline_internodealigned_in_smp;
100077
100078 enum zone_flags {
100079diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
100080index 34f25b7..0586069 100644
100081--- a/include/linux/mod_devicetable.h
100082+++ b/include/linux/mod_devicetable.h
100083@@ -139,7 +139,7 @@ struct usb_device_id {
100084 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
100085 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
100086
100087-#define HID_ANY_ID (~0)
100088+#define HID_ANY_ID (~0U)
100089 #define HID_BUS_ANY 0xffff
100090 #define HID_GROUP_ANY 0x0000
100091
100092@@ -472,7 +472,7 @@ struct dmi_system_id {
100093 const char *ident;
100094 struct dmi_strmatch matches[4];
100095 void *driver_data;
100096-};
100097+} __do_const;
100098 /*
100099 * struct dmi_device_id appears during expansion of
100100 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
100101diff --git a/include/linux/module.h b/include/linux/module.h
100102index 3a19c79..dea8c47 100644
100103--- a/include/linux/module.h
100104+++ b/include/linux/module.h
100105@@ -19,9 +19,11 @@
100106 #include <linux/jump_label.h>
100107 #include <linux/export.h>
100108 #include <linux/rbtree_latch.h>
100109+#include <linux/fs.h>
100110
100111 #include <linux/percpu.h>
100112 #include <asm/module.h>
100113+#include <asm/pgtable.h>
100114
100115 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
100116 #define MODULE_SIG_STRING "~Module signature appended~\n"
100117@@ -44,7 +46,7 @@ struct module_kobject {
100118 struct kobject *drivers_dir;
100119 struct module_param_attrs *mp;
100120 struct completion *kobj_completion;
100121-};
100122+} __randomize_layout;
100123
100124 struct module_attribute {
100125 struct attribute attr;
100126@@ -56,12 +58,13 @@ struct module_attribute {
100127 int (*test)(struct module *);
100128 void (*free)(struct module *);
100129 };
100130+typedef struct module_attribute __no_const module_attribute_no_const;
100131
100132 struct module_version_attribute {
100133 struct module_attribute mattr;
100134 const char *module_name;
100135 const char *version;
100136-} __attribute__ ((__aligned__(sizeof(void *))));
100137+} __do_const __attribute__ ((__aligned__(sizeof(void *))));
100138
100139 extern ssize_t __modver_version_show(struct module_attribute *,
100140 struct module_kobject *, char *);
100141@@ -313,7 +316,7 @@ struct module {
100142
100143 /* Sysfs stuff. */
100144 struct module_kobject mkobj;
100145- struct module_attribute *modinfo_attrs;
100146+ module_attribute_no_const *modinfo_attrs;
100147 const char *version;
100148 const char *srcversion;
100149 struct kobject *holders_dir;
100150@@ -370,20 +373,21 @@ struct module {
100151 * If this is non-NULL, vfree() after init() returns.
100152 *
100153 * Cacheline align here, such that:
100154- * module_init, module_core, init_size, core_size,
100155+ * module_init_*, module_core_*, init_size_*, core_size_*,
100156 * init_text_size, core_text_size and mtn_core::{mod,node[0]}
100157 * are on the same cacheline.
100158 */
100159- void *module_init ____cacheline_aligned;
100160+ void *module_init_rw ____cacheline_aligned;
100161+ void *module_init_rx;
100162
100163 /* Here is the actual code + data, vfree'd on unload. */
100164- void *module_core;
100165+ void *module_core_rx, *module_core_rw;
100166
100167 /* Here are the sizes of the init and core sections */
100168- unsigned int init_size, core_size;
100169+ unsigned int init_size_rw, core_size_rw;
100170
100171 /* The size of the executable code in each section. */
100172- unsigned int init_text_size, core_text_size;
100173+ unsigned int init_size_rx, core_size_rx;
100174
100175 #ifdef CONFIG_MODULES_TREE_LOOKUP
100176 /*
100177@@ -391,13 +395,12 @@ struct module {
100178 * above entries such that a regular lookup will only touch one
100179 * cacheline.
100180 */
100181- struct mod_tree_node mtn_core;
100182- struct mod_tree_node mtn_init;
100183+ struct mod_tree_node mtn_core_rw;
100184+ struct mod_tree_node mtn_core_rx;
100185+ struct mod_tree_node mtn_init_rw;
100186+ struct mod_tree_node mtn_init_rx;
100187 #endif
100188
100189- /* Size of RO sections of the module (text+rodata) */
100190- unsigned int init_ro_size, core_ro_size;
100191-
100192 /* Arch-specific module values */
100193 struct mod_arch_specific arch;
100194
100195@@ -454,6 +457,10 @@ struct module {
100196 unsigned int num_trace_events;
100197 struct trace_enum_map **trace_enums;
100198 unsigned int num_trace_enums;
100199+ struct file_operations trace_id;
100200+ struct file_operations trace_enable;
100201+ struct file_operations trace_format;
100202+ struct file_operations trace_filter;
100203 #endif
100204 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
100205 unsigned int num_ftrace_callsites;
100206@@ -481,7 +488,8 @@ struct module {
100207 ctor_fn_t *ctors;
100208 unsigned int num_ctors;
100209 #endif
100210-} ____cacheline_aligned;
100211+} ____cacheline_aligned __randomize_layout;
100212+
100213 #ifndef MODULE_ARCH_INIT
100214 #define MODULE_ARCH_INIT {}
100215 #endif
100216@@ -502,18 +510,48 @@ bool is_module_address(unsigned long addr);
100217 bool is_module_percpu_address(unsigned long addr);
100218 bool is_module_text_address(unsigned long addr);
100219
100220+static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
100221+{
100222+
100223+#ifdef CONFIG_PAX_KERNEXEC
100224+ if (ktla_ktva(addr) >= (unsigned long)start &&
100225+ ktla_ktva(addr) < (unsigned long)start + size)
100226+ return 1;
100227+#endif
100228+
100229+ return ((void *)addr >= start && (void *)addr < start + size);
100230+}
100231+
100232+static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
100233+{
100234+ return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
100235+}
100236+
100237+static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
100238+{
100239+ return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
100240+}
100241+
100242+static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
100243+{
100244+ return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
100245+}
100246+
100247+static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
100248+{
100249+ return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
100250+}
100251+
100252 static inline bool within_module_core(unsigned long addr,
100253 const struct module *mod)
100254 {
100255- return (unsigned long)mod->module_core <= addr &&
100256- addr < (unsigned long)mod->module_core + mod->core_size;
100257+ return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
100258 }
100259
100260 static inline bool within_module_init(unsigned long addr,
100261 const struct module *mod)
100262 {
100263- return (unsigned long)mod->module_init <= addr &&
100264- addr < (unsigned long)mod->module_init + mod->init_size;
100265+ return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
100266 }
100267
100268 static inline bool within_module(unsigned long addr, const struct module *mod)
100269diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
100270index 4d0cb9b..3169ac7 100644
100271--- a/include/linux/moduleloader.h
100272+++ b/include/linux/moduleloader.h
100273@@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
100274 sections. Returns NULL on failure. */
100275 void *module_alloc(unsigned long size);
100276
100277+#ifdef CONFIG_PAX_KERNEXEC
100278+void *module_alloc_exec(unsigned long size);
100279+#else
100280+#define module_alloc_exec(x) module_alloc(x)
100281+#endif
100282+
100283 /* Free memory returned from module_alloc. */
100284 void module_memfree(void *module_region);
100285
100286+#ifdef CONFIG_PAX_KERNEXEC
100287+void module_memfree_exec(void *module_region);
100288+#else
100289+#define module_memfree_exec(x) module_memfree((x))
100290+#endif
100291+
100292 /*
100293 * Apply the given relocation to the (simplified) ELF. Return -error
100294 * or 0.
100295@@ -45,8 +57,10 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
100296 unsigned int relsec,
100297 struct module *me)
100298 {
100299+#ifdef CONFIG_MODULES
100300 printk(KERN_ERR "module %s: REL relocation unsupported\n",
100301 module_name(me));
100302+#endif
100303 return -ENOEXEC;
100304 }
100305 #endif
100306@@ -68,8 +82,10 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
100307 unsigned int relsec,
100308 struct module *me)
100309 {
100310+#ifdef CONFIG_MODULES
100311 printk(KERN_ERR "module %s: REL relocation unsupported\n",
100312 module_name(me));
100313+#endif
100314 return -ENOEXEC;
100315 }
100316 #endif
100317diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
100318index c12f214..3ef907f 100644
100319--- a/include/linux/moduleparam.h
100320+++ b/include/linux/moduleparam.h
100321@@ -289,7 +289,7 @@ static inline void kernel_param_unlock(struct module *mod)
100322 * @len is usually just sizeof(string).
100323 */
100324 #define module_param_string(name, string, len, perm) \
100325- static const struct kparam_string __param_string_##name \
100326+ static const struct kparam_string __param_string_##name __used \
100327 = { len, string }; \
100328 __module_param_call(MODULE_PARAM_PREFIX, name, \
100329 &param_ops_string, \
100330@@ -440,7 +440,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
100331 */
100332 #define module_param_array_named(name, array, type, nump, perm) \
100333 param_check_##type(name, &(array)[0]); \
100334- static const struct kparam_array __param_arr_##name \
100335+ static const struct kparam_array __param_arr_##name __used \
100336 = { .max = ARRAY_SIZE(array), .num = nump, \
100337 .ops = &param_ops_##type, \
100338 .elemsize = sizeof(array[0]), .elem = array }; \
100339diff --git a/include/linux/mount.h b/include/linux/mount.h
100340index f822c3c..958ca0a 100644
100341--- a/include/linux/mount.h
100342+++ b/include/linux/mount.h
100343@@ -67,7 +67,7 @@ struct vfsmount {
100344 struct dentry *mnt_root; /* root of the mounted tree */
100345 struct super_block *mnt_sb; /* pointer to superblock */
100346 int mnt_flags;
100347-};
100348+} __randomize_layout;
100349
100350 struct file; /* forward dec */
100351 struct path;
100352diff --git a/include/linux/net.h b/include/linux/net.h
100353index 04aa068..8a24df5 100644
100354--- a/include/linux/net.h
100355+++ b/include/linux/net.h
100356@@ -189,7 +189,7 @@ struct net_proto_family {
100357 int (*create)(struct net *net, struct socket *sock,
100358 int protocol, int kern);
100359 struct module *owner;
100360-};
100361+} __do_const;
100362
100363 struct iovec;
100364 struct kvec;
100365diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
100366index e20979d..3c7827b 100644
100367--- a/include/linux/netdevice.h
100368+++ b/include/linux/netdevice.h
100369@@ -1212,6 +1212,7 @@ struct net_device_ops {
100370 u32 maxrate);
100371 int (*ndo_get_iflink)(const struct net_device *dev);
100372 };
100373+typedef struct net_device_ops __no_const net_device_ops_no_const;
100374
100375 /**
100376 * enum net_device_priv_flags - &struct net_device priv_flags
100377@@ -1519,7 +1520,7 @@ struct net_device {
100378 unsigned long base_addr;
100379 int irq;
100380
100381- atomic_t carrier_changes;
100382+ atomic_unchecked_t carrier_changes;
100383
100384 /*
100385 * Some hardware also needs these fields (state,dev_list,
100386@@ -1558,8 +1559,8 @@ struct net_device {
100387
100388 struct net_device_stats stats;
100389
100390- atomic_long_t rx_dropped;
100391- atomic_long_t tx_dropped;
100392+ atomic_long_unchecked_t rx_dropped;
100393+ atomic_long_unchecked_t tx_dropped;
100394
100395 #ifdef CONFIG_WIRELESS_EXT
100396 const struct iw_handler_def * wireless_handlers;
100397diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
100398index 00050df..0bc7081 100644
100399--- a/include/linux/netfilter.h
100400+++ b/include/linux/netfilter.h
100401@@ -115,7 +115,7 @@ struct nf_sockopt_ops {
100402 #endif
100403 /* Use the module struct to lock set/get code in place */
100404 struct module *owner;
100405-};
100406+} __do_const;
100407
100408 /* Function to register/unregister hook points. */
100409 int nf_register_hook(struct nf_hook_ops *reg);
100410diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
100411index e955d47..04a5338 100644
100412--- a/include/linux/netfilter/nfnetlink.h
100413+++ b/include/linux/netfilter/nfnetlink.h
100414@@ -19,7 +19,7 @@ struct nfnl_callback {
100415 const struct nlattr * const cda[]);
100416 const struct nla_policy *policy; /* netlink attribute policy */
100417 const u_int16_t attr_count; /* number of nlattr's */
100418-};
100419+} __do_const;
100420
100421 struct nfnetlink_subsystem {
100422 const char *name;
100423diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
100424new file mode 100644
100425index 0000000..33f4af8
100426--- /dev/null
100427+++ b/include/linux/netfilter/xt_gradm.h
100428@@ -0,0 +1,9 @@
100429+#ifndef _LINUX_NETFILTER_XT_GRADM_H
100430+#define _LINUX_NETFILTER_XT_GRADM_H 1
100431+
100432+struct xt_gradm_mtinfo {
100433+ __u16 flags;
100434+ __u16 invflags;
100435+};
100436+
100437+#endif
100438diff --git a/include/linux/nls.h b/include/linux/nls.h
100439index 520681b..2b7fabb 100644
100440--- a/include/linux/nls.h
100441+++ b/include/linux/nls.h
100442@@ -31,7 +31,7 @@ struct nls_table {
100443 const unsigned char *charset2upper;
100444 struct module *owner;
100445 struct nls_table *next;
100446-};
100447+} __do_const;
100448
100449 /* this value hold the maximum octet of charset */
100450 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
100451@@ -46,7 +46,7 @@ enum utf16_endian {
100452 /* nls_base.c */
100453 extern int __register_nls(struct nls_table *, struct module *);
100454 extern int unregister_nls(struct nls_table *);
100455-extern struct nls_table *load_nls(char *);
100456+extern struct nls_table *load_nls(const char *);
100457 extern void unload_nls(struct nls_table *);
100458 extern struct nls_table *load_nls_default(void);
100459 #define register_nls(nls) __register_nls((nls), THIS_MODULE)
100460diff --git a/include/linux/notifier.h b/include/linux/notifier.h
100461index d14a4c3..a078786 100644
100462--- a/include/linux/notifier.h
100463+++ b/include/linux/notifier.h
100464@@ -54,7 +54,8 @@ struct notifier_block {
100465 notifier_fn_t notifier_call;
100466 struct notifier_block __rcu *next;
100467 int priority;
100468-};
100469+} __do_const;
100470+typedef struct notifier_block __no_const notifier_block_no_const;
100471
100472 struct atomic_notifier_head {
100473 spinlock_t lock;
100474diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
100475index b2a0f15..4d7da32 100644
100476--- a/include/linux/oprofile.h
100477+++ b/include/linux/oprofile.h
100478@@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
100479 int oprofilefs_create_ro_ulong(struct dentry * root,
100480 char const * name, ulong * val);
100481
100482-/** Create a file for read-only access to an atomic_t. */
100483+/** Create a file for read-only access to an atomic_unchecked_t. */
100484 int oprofilefs_create_ro_atomic(struct dentry * root,
100485- char const * name, atomic_t * val);
100486+ char const * name, atomic_unchecked_t * val);
100487
100488 /** create a directory */
100489 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
100490diff --git a/include/linux/padata.h b/include/linux/padata.h
100491index 4386946..f50c615 100644
100492--- a/include/linux/padata.h
100493+++ b/include/linux/padata.h
100494@@ -129,7 +129,7 @@ struct parallel_data {
100495 struct padata_serial_queue __percpu *squeue;
100496 atomic_t reorder_objects;
100497 atomic_t refcnt;
100498- atomic_t seq_nr;
100499+ atomic_unchecked_t seq_nr;
100500 struct padata_cpumask cpumask;
100501 spinlock_t lock ____cacheline_aligned;
100502 unsigned int processed;
100503diff --git a/include/linux/path.h b/include/linux/path.h
100504index d137218..be0c176 100644
100505--- a/include/linux/path.h
100506+++ b/include/linux/path.h
100507@@ -1,13 +1,15 @@
100508 #ifndef _LINUX_PATH_H
100509 #define _LINUX_PATH_H
100510
100511+#include <linux/compiler.h>
100512+
100513 struct dentry;
100514 struct vfsmount;
100515
100516 struct path {
100517 struct vfsmount *mnt;
100518 struct dentry *dentry;
100519-};
100520+} __randomize_layout;
100521
100522 extern void path_get(const struct path *);
100523 extern void path_put(const struct path *);
100524diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
100525index 8c78950..0d74ed9 100644
100526--- a/include/linux/pci_hotplug.h
100527+++ b/include/linux/pci_hotplug.h
100528@@ -71,7 +71,8 @@ struct hotplug_slot_ops {
100529 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
100530 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
100531 int (*reset_slot) (struct hotplug_slot *slot, int probe);
100532-};
100533+} __do_const;
100534+typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
100535
100536 /**
100537 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
100538diff --git a/include/linux/percpu.h b/include/linux/percpu.h
100539index caebf2a..4c3ae9d 100644
100540--- a/include/linux/percpu.h
100541+++ b/include/linux/percpu.h
100542@@ -34,7 +34,7 @@
100543 * preallocate for this. Keep PERCPU_DYNAMIC_RESERVE equal to or
100544 * larger than PERCPU_DYNAMIC_EARLY_SIZE.
100545 */
100546-#define PERCPU_DYNAMIC_EARLY_SLOTS 128
100547+#define PERCPU_DYNAMIC_EARLY_SLOTS 256
100548 #define PERCPU_DYNAMIC_EARLY_SIZE (12 << 10)
100549
100550 /*
100551diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
100552index 2027809..c9cd38e 100644
100553--- a/include/linux/perf_event.h
100554+++ b/include/linux/perf_event.h
100555@@ -384,8 +384,8 @@ struct perf_event {
100556
100557 enum perf_event_active_state state;
100558 unsigned int attach_state;
100559- local64_t count;
100560- atomic64_t child_count;
100561+ local64_t count; /* PaX: fix it one day */
100562+ atomic64_unchecked_t child_count;
100563
100564 /*
100565 * These are the total time in nanoseconds that the event
100566@@ -436,8 +436,8 @@ struct perf_event {
100567 * These accumulate total time (in nanoseconds) that children
100568 * events have been enabled and running, respectively.
100569 */
100570- atomic64_t child_total_time_enabled;
100571- atomic64_t child_total_time_running;
100572+ atomic64_unchecked_t child_total_time_enabled;
100573+ atomic64_unchecked_t child_total_time_running;
100574
100575 /*
100576 * Protect attach/detach and child_list:
100577@@ -859,7 +859,7 @@ static inline void perf_event_task_sched_out(struct task_struct *prev,
100578
100579 static inline u64 __perf_event_count(struct perf_event *event)
100580 {
100581- return local64_read(&event->count) + atomic64_read(&event->child_count);
100582+ return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
100583 }
100584
100585 extern void perf_event_mmap(struct vm_area_struct *vma);
100586@@ -883,7 +883,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
100587 entry->ip[entry->nr++] = ip;
100588 }
100589
100590-extern int sysctl_perf_event_paranoid;
100591+extern int sysctl_perf_event_legitimately_concerned;
100592 extern int sysctl_perf_event_mlock;
100593 extern int sysctl_perf_event_sample_rate;
100594 extern int sysctl_perf_cpu_time_max_percent;
100595@@ -898,19 +898,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
100596 loff_t *ppos);
100597
100598
100599+static inline bool perf_paranoid_any(void)
100600+{
100601+ return sysctl_perf_event_legitimately_concerned > 2;
100602+}
100603+
100604 static inline bool perf_paranoid_tracepoint_raw(void)
100605 {
100606- return sysctl_perf_event_paranoid > -1;
100607+ return sysctl_perf_event_legitimately_concerned > -1;
100608 }
100609
100610 static inline bool perf_paranoid_cpu(void)
100611 {
100612- return sysctl_perf_event_paranoid > 0;
100613+ return sysctl_perf_event_legitimately_concerned > 0;
100614 }
100615
100616 static inline bool perf_paranoid_kernel(void)
100617 {
100618- return sysctl_perf_event_paranoid > 1;
100619+ return sysctl_perf_event_legitimately_concerned > 1;
100620 }
100621
100622 extern void perf_event_init(void);
100623@@ -1066,7 +1071,7 @@ struct perf_pmu_events_attr {
100624 struct device_attribute attr;
100625 u64 id;
100626 const char *event_str;
100627-};
100628+} __do_const;
100629
100630 ssize_t perf_event_sysfs_show(struct device *dev, struct device_attribute *attr,
100631 char *page);
100632diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
100633index 918b117..7af374b7 100644
100634--- a/include/linux/pid_namespace.h
100635+++ b/include/linux/pid_namespace.h
100636@@ -45,7 +45,7 @@ struct pid_namespace {
100637 int hide_pid;
100638 int reboot; /* group exit code if this pidns was rebooted */
100639 struct ns_common ns;
100640-};
100641+} __randomize_layout;
100642
100643 extern struct pid_namespace init_pid_ns;
100644
100645diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
100646index eb8b8ac..62649e1 100644
100647--- a/include/linux/pipe_fs_i.h
100648+++ b/include/linux/pipe_fs_i.h
100649@@ -47,10 +47,10 @@ struct pipe_inode_info {
100650 struct mutex mutex;
100651 wait_queue_head_t wait;
100652 unsigned int nrbufs, curbuf, buffers;
100653- unsigned int readers;
100654- unsigned int writers;
100655- unsigned int files;
100656- unsigned int waiting_writers;
100657+ atomic_t readers;
100658+ atomic_t writers;
100659+ atomic_t files;
100660+ atomic_t waiting_writers;
100661 unsigned int r_counter;
100662 unsigned int w_counter;
100663 struct page *tmp_page;
100664diff --git a/include/linux/pm.h b/include/linux/pm.h
100665index 35d599e..c604209 100644
100666--- a/include/linux/pm.h
100667+++ b/include/linux/pm.h
100668@@ -630,6 +630,7 @@ struct dev_pm_domain {
100669 void (*sync)(struct device *dev);
100670 void (*dismiss)(struct device *dev);
100671 };
100672+typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
100673
100674 /*
100675 * The PM_EVENT_ messages are also used by drivers implementing the legacy
100676diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
100677index 681ccb0..a90e0b7 100644
100678--- a/include/linux/pm_domain.h
100679+++ b/include/linux/pm_domain.h
100680@@ -39,11 +39,11 @@ struct gpd_dev_ops {
100681 int (*save_state)(struct device *dev);
100682 int (*restore_state)(struct device *dev);
100683 bool (*active_wakeup)(struct device *dev);
100684-};
100685+} __no_const;
100686
100687 struct gpd_cpuidle_data {
100688 unsigned int saved_exit_latency;
100689- struct cpuidle_state *idle_state;
100690+ cpuidle_state_no_const *idle_state;
100691 };
100692
100693 struct generic_pm_domain {
100694diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
100695index 30e84d4..22278b4 100644
100696--- a/include/linux/pm_runtime.h
100697+++ b/include/linux/pm_runtime.h
100698@@ -115,7 +115,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
100699
100700 static inline void pm_runtime_mark_last_busy(struct device *dev)
100701 {
100702- ACCESS_ONCE(dev->power.last_busy) = jiffies;
100703+ ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
100704 }
100705
100706 static inline bool pm_runtime_is_irq_safe(struct device *dev)
100707diff --git a/include/linux/pnp.h b/include/linux/pnp.h
100708index 5df733b..d55f252 100644
100709--- a/include/linux/pnp.h
100710+++ b/include/linux/pnp.h
100711@@ -298,7 +298,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
100712 struct pnp_fixup {
100713 char id[7];
100714 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
100715-};
100716+} __do_const;
100717
100718 /* config parameters */
100719 #define PNP_CONFIG_NORMAL 0x0001
100720diff --git a/include/linux/poison.h b/include/linux/poison.h
100721index 2110a81..13a11bb 100644
100722--- a/include/linux/poison.h
100723+++ b/include/linux/poison.h
100724@@ -19,8 +19,8 @@
100725 * under normal circumstances, used to verify that nobody uses
100726 * non-initialized list entries.
100727 */
100728-#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
100729-#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
100730+#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
100731+#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
100732
100733 /********** include/linux/timer.h **********/
100734 /*
100735diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
100736index d8b187c3..9a9257a 100644
100737--- a/include/linux/power/smartreflex.h
100738+++ b/include/linux/power/smartreflex.h
100739@@ -238,7 +238,7 @@ struct omap_sr_class_data {
100740 int (*notify)(struct omap_sr *sr, u32 status);
100741 u8 notify_flags;
100742 u8 class_type;
100743-};
100744+} __do_const;
100745
100746 /**
100747 * struct omap_sr_nvalue_table - Smartreflex n-target value info
100748diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
100749index 4ea1d37..80f4b33 100644
100750--- a/include/linux/ppp-comp.h
100751+++ b/include/linux/ppp-comp.h
100752@@ -84,7 +84,7 @@ struct compressor {
100753 struct module *owner;
100754 /* Extra skb space needed by the compressor algorithm */
100755 unsigned int comp_extra;
100756-};
100757+} __do_const;
100758
100759 /*
100760 * The return value from decompress routine is the length of the
100761diff --git a/include/linux/preempt.h b/include/linux/preempt.h
100762index bea8dd8..534a23d 100644
100763--- a/include/linux/preempt.h
100764+++ b/include/linux/preempt.h
100765@@ -140,11 +140,16 @@ extern void preempt_count_sub(int val);
100766 #define preempt_count_dec_and_test() __preempt_count_dec_and_test()
100767 #endif
100768
100769+#define raw_preempt_count_add(val) __preempt_count_add(val)
100770+#define raw_preempt_count_sub(val) __preempt_count_sub(val)
100771+
100772 #define __preempt_count_inc() __preempt_count_add(1)
100773 #define __preempt_count_dec() __preempt_count_sub(1)
100774
100775 #define preempt_count_inc() preempt_count_add(1)
100776+#define raw_preempt_count_inc() raw_preempt_count_add(1)
100777 #define preempt_count_dec() preempt_count_sub(1)
100778+#define raw_preempt_count_dec() raw_preempt_count_sub(1)
100779
100780 #define preempt_active_enter() \
100781 do { \
100782@@ -166,6 +171,12 @@ do { \
100783 barrier(); \
100784 } while (0)
100785
100786+#define raw_preempt_disable() \
100787+do { \
100788+ raw_preempt_count_inc(); \
100789+ barrier(); \
100790+} while (0)
100791+
100792 #define sched_preempt_enable_no_resched() \
100793 do { \
100794 barrier(); \
100795@@ -174,6 +185,12 @@ do { \
100796
100797 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
100798
100799+#define raw_preempt_enable_no_resched() \
100800+do { \
100801+ barrier(); \
100802+ raw_preempt_count_dec(); \
100803+} while (0)
100804+
100805 #define preemptible() (preempt_count() == 0 && !irqs_disabled())
100806
100807 #ifdef CONFIG_PREEMPT
100808@@ -234,8 +251,10 @@ do { \
100809 * region.
100810 */
100811 #define preempt_disable() barrier()
100812+#define raw_preempt_disable() barrier()
100813 #define sched_preempt_enable_no_resched() barrier()
100814 #define preempt_enable_no_resched() barrier()
100815+#define raw_preempt_enable_no_resched() barrier()
100816 #define preempt_enable() barrier()
100817 #define preempt_check_resched() do { } while (0)
100818
100819@@ -250,11 +269,13 @@ do { \
100820 /*
100821 * Modules have no business playing preemption tricks.
100822 */
100823+#ifndef CONFIG_PAX_KERNEXEC
100824 #undef sched_preempt_enable_no_resched
100825 #undef preempt_enable_no_resched
100826 #undef preempt_enable_no_resched_notrace
100827 #undef preempt_check_resched
100828 #endif
100829+#endif
100830
100831 #define preempt_set_need_resched() \
100832 do { \
100833diff --git a/include/linux/printk.h b/include/linux/printk.h
100834index a6298b2..57fe982 100644
100835--- a/include/linux/printk.h
100836+++ b/include/linux/printk.h
100837@@ -123,6 +123,7 @@ void early_printk(const char *s, ...) { }
100838 #endif
100839
100840 typedef __printf(1, 0) int (*printk_func_t)(const char *fmt, va_list args);
100841+extern int kptr_restrict;
100842
100843 #ifdef CONFIG_PRINTK
100844 asmlinkage __printf(5, 0)
100845@@ -158,7 +159,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
100846
100847 extern int printk_delay_msec;
100848 extern int dmesg_restrict;
100849-extern int kptr_restrict;
100850
100851 extern void wake_up_klogd(void);
100852
100853diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
100854index b97bf2e..f14c92d4 100644
100855--- a/include/linux/proc_fs.h
100856+++ b/include/linux/proc_fs.h
100857@@ -17,8 +17,11 @@ extern void proc_flush_task(struct task_struct *);
100858 extern struct proc_dir_entry *proc_symlink(const char *,
100859 struct proc_dir_entry *, const char *);
100860 extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
100861+extern struct proc_dir_entry *proc_mkdir_restrict(const char *, struct proc_dir_entry *);
100862 extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
100863 struct proc_dir_entry *, void *);
100864+extern struct proc_dir_entry *proc_mkdir_data_restrict(const char *, umode_t,
100865+ struct proc_dir_entry *, void *);
100866 extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
100867 struct proc_dir_entry *);
100868
100869@@ -34,6 +37,19 @@ static inline struct proc_dir_entry *proc_create(
100870 return proc_create_data(name, mode, parent, proc_fops, NULL);
100871 }
100872
100873+static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
100874+ struct proc_dir_entry *parent, const struct file_operations *proc_fops)
100875+{
100876+#ifdef CONFIG_GRKERNSEC_PROC_USER
100877+ return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
100878+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
100879+ return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
100880+#else
100881+ return proc_create_data(name, mode, parent, proc_fops, NULL);
100882+#endif
100883+}
100884+
100885+
100886 extern void proc_set_size(struct proc_dir_entry *, loff_t);
100887 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
100888 extern void *PDE_DATA(const struct inode *);
100889@@ -56,8 +72,12 @@ static inline struct proc_dir_entry *proc_symlink(const char *name,
100890 struct proc_dir_entry *parent,const char *dest) { return NULL;}
100891 static inline struct proc_dir_entry *proc_mkdir(const char *name,
100892 struct proc_dir_entry *parent) {return NULL;}
100893+static inline struct proc_dir_entry *proc_mkdir_restrict(const char *name,
100894+ struct proc_dir_entry *parent) { return NULL; }
100895 static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
100896 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
100897+static inline struct proc_dir_entry *proc_mkdir_data_restrict(const char *name,
100898+ umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
100899 static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
100900 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
100901 #define proc_create(name, mode, parent, proc_fops) ({NULL;})
100902@@ -79,7 +99,7 @@ struct net;
100903 static inline struct proc_dir_entry *proc_net_mkdir(
100904 struct net *net, const char *name, struct proc_dir_entry *parent)
100905 {
100906- return proc_mkdir_data(name, 0, parent, net);
100907+ return proc_mkdir_data_restrict(name, 0, parent, net);
100908 }
100909
100910 #endif /* _LINUX_PROC_FS_H */
100911diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
100912index 42dfc61..8113a99 100644
100913--- a/include/linux/proc_ns.h
100914+++ b/include/linux/proc_ns.h
100915@@ -16,7 +16,7 @@ struct proc_ns_operations {
100916 struct ns_common *(*get)(struct task_struct *task);
100917 void (*put)(struct ns_common *ns);
100918 int (*install)(struct nsproxy *nsproxy, struct ns_common *ns);
100919-};
100920+} __do_const __randomize_layout;
100921
100922 extern const struct proc_ns_operations netns_operations;
100923 extern const struct proc_ns_operations utsns_operations;
100924diff --git a/include/linux/quota.h b/include/linux/quota.h
100925index b2505ac..5f7ab55 100644
100926--- a/include/linux/quota.h
100927+++ b/include/linux/quota.h
100928@@ -76,7 +76,7 @@ struct kqid { /* Type in which we store the quota identifier */
100929
100930 extern bool qid_eq(struct kqid left, struct kqid right);
100931 extern bool qid_lt(struct kqid left, struct kqid right);
100932-extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
100933+extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
100934 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
100935 extern bool qid_valid(struct kqid qid);
100936
100937diff --git a/include/linux/random.h b/include/linux/random.h
100938index e651874..a872186 100644
100939--- a/include/linux/random.h
100940+++ b/include/linux/random.h
100941@@ -16,9 +16,19 @@ struct random_ready_callback {
100942 };
100943
100944 extern void add_device_randomness(const void *, unsigned int);
100945+
100946+static inline void add_latent_entropy(void)
100947+{
100948+
100949+#ifdef LATENT_ENTROPY_PLUGIN
100950+ add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
100951+#endif
100952+
100953+}
100954+
100955 extern void add_input_randomness(unsigned int type, unsigned int code,
100956- unsigned int value);
100957-extern void add_interrupt_randomness(int irq, int irq_flags);
100958+ unsigned int value) __latent_entropy;
100959+extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
100960
100961 extern void get_random_bytes(void *buf, int nbytes);
100962 extern int add_random_ready_callback(struct random_ready_callback *rdy);
100963@@ -46,6 +56,11 @@ struct rnd_state {
100964 u32 prandom_u32_state(struct rnd_state *state);
100965 void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes);
100966
100967+static inline unsigned long __intentional_overflow(-1) pax_get_random_long(void)
100968+{
100969+ return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
100970+}
100971+
100972 /**
100973 * prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro)
100974 * @ep_ro: right open interval endpoint
100975@@ -58,7 +73,7 @@ void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes);
100976 *
100977 * Returns: pseudo-random number in interval [0, ep_ro)
100978 */
100979-static inline u32 prandom_u32_max(u32 ep_ro)
100980+static inline u32 __intentional_overflow(-1) prandom_u32_max(u32 ep_ro)
100981 {
100982 return (u32)(((u64) prandom_u32() * ep_ro) >> 32);
100983 }
100984diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
100985index 14d7b83..a1edf56 100644
100986--- a/include/linux/rbtree_augmented.h
100987+++ b/include/linux/rbtree_augmented.h
100988@@ -90,7 +90,9 @@ rbname ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \
100989 old->rbaugmented = rbcompute(old); \
100990 } \
100991 rbstatic const struct rb_augment_callbacks rbname = { \
100992- rbname ## _propagate, rbname ## _copy, rbname ## _rotate \
100993+ .propagate = rbname ## _propagate, \
100994+ .copy = rbname ## _copy, \
100995+ .rotate = rbname ## _rotate \
100996 };
100997
100998
100999diff --git a/include/linux/rculist.h b/include/linux/rculist.h
101000index 17c6b1f..a65e3f8 100644
101001--- a/include/linux/rculist.h
101002+++ b/include/linux/rculist.h
101003@@ -59,6 +59,9 @@ void __list_add_rcu(struct list_head *new,
101004 struct list_head *prev, struct list_head *next);
101005 #endif
101006
101007+void __pax_list_add_rcu(struct list_head *new,
101008+ struct list_head *prev, struct list_head *next);
101009+
101010 /**
101011 * list_add_rcu - add a new entry to rcu-protected list
101012 * @new: new entry to be added
101013@@ -80,6 +83,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
101014 __list_add_rcu(new, head, head->next);
101015 }
101016
101017+static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
101018+{
101019+ __pax_list_add_rcu(new, head, head->next);
101020+}
101021+
101022 /**
101023 * list_add_tail_rcu - add a new entry to rcu-protected list
101024 * @new: new entry to be added
101025@@ -102,6 +110,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
101026 __list_add_rcu(new, head->prev, head);
101027 }
101028
101029+static inline void pax_list_add_tail_rcu(struct list_head *new,
101030+ struct list_head *head)
101031+{
101032+ __pax_list_add_rcu(new, head->prev, head);
101033+}
101034+
101035 /**
101036 * list_del_rcu - deletes entry from list without re-initialization
101037 * @entry: the element to delete from the list.
101038@@ -132,6 +146,8 @@ static inline void list_del_rcu(struct list_head *entry)
101039 entry->prev = LIST_POISON2;
101040 }
101041
101042+extern void pax_list_del_rcu(struct list_head *entry);
101043+
101044 /**
101045 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
101046 * @n: the element to delete from the hash list.
101047diff --git a/include/linux/reboot.h b/include/linux/reboot.h
101048index a7ff409..03e2fa8 100644
101049--- a/include/linux/reboot.h
101050+++ b/include/linux/reboot.h
101051@@ -47,9 +47,9 @@ extern void do_kernel_restart(char *cmd);
101052 */
101053
101054 extern void migrate_to_reboot_cpu(void);
101055-extern void machine_restart(char *cmd);
101056-extern void machine_halt(void);
101057-extern void machine_power_off(void);
101058+extern void machine_restart(char *cmd) __noreturn;
101059+extern void machine_halt(void) __noreturn;
101060+extern void machine_power_off(void) __noreturn;
101061
101062 extern void machine_shutdown(void);
101063 struct pt_regs;
101064@@ -60,9 +60,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
101065 */
101066
101067 extern void kernel_restart_prepare(char *cmd);
101068-extern void kernel_restart(char *cmd);
101069-extern void kernel_halt(void);
101070-extern void kernel_power_off(void);
101071+extern void kernel_restart(char *cmd) __noreturn;
101072+extern void kernel_halt(void) __noreturn;
101073+extern void kernel_power_off(void) __noreturn;
101074
101075 extern int C_A_D; /* for sysctl */
101076 void ctrl_alt_del(void);
101077@@ -77,7 +77,7 @@ extern void orderly_reboot(void);
101078 * Emergency restart, callable from an interrupt handler.
101079 */
101080
101081-extern void emergency_restart(void);
101082+extern void emergency_restart(void) __noreturn;
101083 #include <asm/emergency-restart.h>
101084
101085 #endif /* _LINUX_REBOOT_H */
101086diff --git a/include/linux/regset.h b/include/linux/regset.h
101087index 8e0c9fe..ac4d221 100644
101088--- a/include/linux/regset.h
101089+++ b/include/linux/regset.h
101090@@ -161,7 +161,8 @@ struct user_regset {
101091 unsigned int align;
101092 unsigned int bias;
101093 unsigned int core_note_type;
101094-};
101095+} __do_const;
101096+typedef struct user_regset __no_const user_regset_no_const;
101097
101098 /**
101099 * struct user_regset_view - available regsets
101100diff --git a/include/linux/relay.h b/include/linux/relay.h
101101index d7c8359..818daf5 100644
101102--- a/include/linux/relay.h
101103+++ b/include/linux/relay.h
101104@@ -157,7 +157,7 @@ struct rchan_callbacks
101105 * The callback should return 0 if successful, negative if not.
101106 */
101107 int (*remove_buf_file)(struct dentry *dentry);
101108-};
101109+} __no_const;
101110
101111 /*
101112 * CONFIG_RELAY kernel API, kernel/relay.c
101113diff --git a/include/linux/rio.h b/include/linux/rio.h
101114index cde976e..ebd6033 100644
101115--- a/include/linux/rio.h
101116+++ b/include/linux/rio.h
101117@@ -358,7 +358,7 @@ struct rio_ops {
101118 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
101119 u64 rstart, u32 size, u32 flags);
101120 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
101121-};
101122+} __no_const;
101123
101124 #define RIO_RESOURCE_MEM 0x00000100
101125 #define RIO_RESOURCE_DOORBELL 0x00000200
101126diff --git a/include/linux/rmap.h b/include/linux/rmap.h
101127index c89c53a..aa0a65a 100644
101128--- a/include/linux/rmap.h
101129+++ b/include/linux/rmap.h
101130@@ -146,8 +146,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
101131 void anon_vma_init(void); /* create anon_vma_cachep */
101132 int anon_vma_prepare(struct vm_area_struct *);
101133 void unlink_anon_vmas(struct vm_area_struct *);
101134-int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
101135-int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
101136+int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
101137+int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
101138
101139 static inline void anon_vma_merge(struct vm_area_struct *vma,
101140 struct vm_area_struct *next)
101141diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
101142index 9b1ef0c..9fa3feb 100644
101143--- a/include/linux/scatterlist.h
101144+++ b/include/linux/scatterlist.h
101145@@ -1,6 +1,7 @@
101146 #ifndef _LINUX_SCATTERLIST_H
101147 #define _LINUX_SCATTERLIST_H
101148
101149+#include <linux/sched.h>
101150 #include <linux/string.h>
101151 #include <linux/types.h>
101152 #include <linux/bug.h>
101153@@ -136,10 +137,17 @@ static inline struct page *sg_page(struct scatterlist *sg)
101154 static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
101155 unsigned int buflen)
101156 {
101157+ const void *realbuf = buf;
101158+
101159+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
101160+ if (object_starts_on_stack(buf))
101161+ realbuf = buf - current->stack + current->lowmem_stack;
101162+#endif
101163+
101164 #ifdef CONFIG_DEBUG_SG
101165- BUG_ON(!virt_addr_valid(buf));
101166+ BUG_ON(!virt_addr_valid(realbuf));
101167 #endif
101168- sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
101169+ sg_set_page(sg, virt_to_page(realbuf), buflen, offset_in_page(realbuf));
101170 }
101171
101172 /*
101173diff --git a/include/linux/sched.h b/include/linux/sched.h
101174index bfca8aa..c8b327c 100644
101175--- a/include/linux/sched.h
101176+++ b/include/linux/sched.h
101177@@ -7,7 +7,7 @@
101178
101179
101180 struct sched_param {
101181- int sched_priority;
101182+ unsigned int sched_priority;
101183 };
101184
101185 #include <asm/param.h> /* for HZ */
101186@@ -134,6 +134,7 @@ struct perf_event_context;
101187 struct blk_plug;
101188 struct filename;
101189 struct nameidata;
101190+struct linux_binprm;
101191
101192 #define VMACACHE_BITS 2
101193 #define VMACACHE_SIZE (1U << VMACACHE_BITS)
101194@@ -436,6 +437,19 @@ struct nsproxy;
101195 struct user_namespace;
101196
101197 #ifdef CONFIG_MMU
101198+
101199+#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
101200+extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
101201+#else
101202+static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
101203+{
101204+ return 0;
101205+}
101206+#endif
101207+
101208+extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
101209+extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
101210+
101211 extern void arch_pick_mmap_layout(struct mm_struct *mm);
101212 extern unsigned long
101213 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
101214@@ -749,6 +763,17 @@ struct signal_struct {
101215 #ifdef CONFIG_TASKSTATS
101216 struct taskstats *stats;
101217 #endif
101218+
101219+#ifdef CONFIG_GRKERNSEC
101220+ u32 curr_ip;
101221+ u32 saved_ip;
101222+ u32 gr_saddr;
101223+ u32 gr_daddr;
101224+ u16 gr_sport;
101225+ u16 gr_dport;
101226+ u8 used_accept:1;
101227+#endif
101228+
101229 #ifdef CONFIG_AUDIT
101230 unsigned audit_tty;
101231 unsigned audit_tty_log_passwd;
101232@@ -775,7 +800,7 @@ struct signal_struct {
101233 struct mutex cred_guard_mutex; /* guard against foreign influences on
101234 * credential calculations
101235 * (notably. ptrace) */
101236-};
101237+} __randomize_layout;
101238
101239 /*
101240 * Bits in flags field of signal_struct.
101241@@ -828,6 +853,14 @@ struct user_struct {
101242 struct key *session_keyring; /* UID's default session keyring */
101243 #endif
101244
101245+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
101246+ unsigned char kernel_banned;
101247+#endif
101248+#ifdef CONFIG_GRKERNSEC_BRUTE
101249+ unsigned char suid_banned;
101250+ unsigned long suid_ban_expires;
101251+#endif
101252+
101253 /* Hash table maintenance information */
101254 struct hlist_node uidhash_node;
101255 kuid_t uid;
101256@@ -835,7 +868,7 @@ struct user_struct {
101257 #ifdef CONFIG_PERF_EVENTS
101258 atomic_long_t locked_vm;
101259 #endif
101260-};
101261+} __randomize_layout;
101262
101263 extern int uids_sysfs_init(void);
101264
101265@@ -1356,6 +1389,9 @@ enum perf_event_task_context {
101266 struct task_struct {
101267 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
101268 void *stack;
101269+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
101270+ void *lowmem_stack;
101271+#endif
101272 atomic_t usage;
101273 unsigned int flags; /* per process flags, defined below */
101274 unsigned int ptrace;
101275@@ -1488,8 +1524,8 @@ struct task_struct {
101276 struct list_head thread_node;
101277
101278 struct completion *vfork_done; /* for vfork() */
101279- int __user *set_child_tid; /* CLONE_CHILD_SETTID */
101280- int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
101281+ pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
101282+ pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
101283
101284 cputime_t utime, stime, utimescaled, stimescaled;
101285 cputime_t gtime;
101286@@ -1514,11 +1550,6 @@ struct task_struct {
101287 struct task_cputime cputime_expires;
101288 struct list_head cpu_timers[3];
101289
101290-/* process credentials */
101291- const struct cred __rcu *real_cred; /* objective and real subjective task
101292- * credentials (COW) */
101293- const struct cred __rcu *cred; /* effective (overridable) subjective task
101294- * credentials (COW) */
101295 char comm[TASK_COMM_LEN]; /* executable name excluding path
101296 - access with [gs]et_task_comm (which lock
101297 it with task_lock())
101298@@ -1610,6 +1641,10 @@ struct task_struct {
101299 gfp_t lockdep_reclaim_gfp;
101300 #endif
101301
101302+/* process credentials */
101303+ const struct cred __rcu *real_cred; /* objective and real subjective task
101304+ * credentials (COW) */
101305+
101306 /* journalling filesystem info */
101307 void *journal_info;
101308
101309@@ -1648,6 +1683,10 @@ struct task_struct {
101310 /* cg_list protected by css_set_lock and tsk->alloc_lock */
101311 struct list_head cg_list;
101312 #endif
101313+
101314+ const struct cred __rcu *cred; /* effective (overridable) subjective task
101315+ * credentials (COW) */
101316+
101317 #ifdef CONFIG_FUTEX
101318 struct robust_list_head __user *robust_list;
101319 #ifdef CONFIG_COMPAT
101320@@ -1759,7 +1798,7 @@ struct task_struct {
101321 * Number of functions that haven't been traced
101322 * because of depth overrun.
101323 */
101324- atomic_t trace_overrun;
101325+ atomic_unchecked_t trace_overrun;
101326 /* Pause for the tracing */
101327 atomic_t tracing_graph_pause;
101328 #endif
101329@@ -1788,22 +1827,91 @@ struct task_struct {
101330 unsigned long task_state_change;
101331 #endif
101332 int pagefault_disabled;
101333+
101334+#ifdef CONFIG_GRKERNSEC
101335+ /* grsecurity */
101336+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
101337+ u64 exec_id;
101338+#endif
101339+#ifdef CONFIG_GRKERNSEC_SETXID
101340+ const struct cred *delayed_cred;
101341+#endif
101342+ struct dentry *gr_chroot_dentry;
101343+ struct acl_subject_label *acl;
101344+ struct acl_subject_label *tmpacl;
101345+ struct acl_role_label *role;
101346+ struct file *exec_file;
101347+ unsigned long brute_expires;
101348+ u16 acl_role_id;
101349+ u8 inherited;
101350+ /* is this the task that authenticated to the special role */
101351+ u8 acl_sp_role;
101352+ u8 is_writable;
101353+ u8 brute;
101354+ u8 gr_is_chrooted;
101355+#endif
101356+
101357+/* thread_info moved to task_struct */
101358+#ifdef CONFIG_X86
101359+ struct thread_info tinfo;
101360+#endif
101361 /* CPU-specific state of this task */
101362 struct thread_struct thread;
101363-/*
101364- * WARNING: on x86, 'thread_struct' contains a variable-sized
101365- * structure. It *MUST* be at the end of 'task_struct'.
101366- *
101367- * Do not put anything below here!
101368- */
101369-};
101370+} __randomize_layout;
101371
101372 #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT
101373-extern int arch_task_struct_size __read_mostly;
101374+extern size_t arch_task_struct_size __read_mostly;
101375 #else
101376 # define arch_task_struct_size (sizeof(struct task_struct))
101377 #endif
101378
101379+#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
101380+#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
101381+#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
101382+#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
101383+/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
101384+#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
101385+
101386+#ifdef CONFIG_PAX_SOFTMODE
101387+extern int pax_softmode;
101388+#endif
101389+
101390+extern int pax_check_flags(unsigned long *);
101391+#define PAX_PARSE_FLAGS_FALLBACK (~0UL)
101392+
101393+/* if tsk != current then task_lock must be held on it */
101394+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
101395+static inline unsigned long pax_get_flags(struct task_struct *tsk)
101396+{
101397+ if (likely(tsk->mm))
101398+ return tsk->mm->pax_flags;
101399+ else
101400+ return 0UL;
101401+}
101402+
101403+/* if tsk != current then task_lock must be held on it */
101404+static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
101405+{
101406+ if (likely(tsk->mm)) {
101407+ tsk->mm->pax_flags = flags;
101408+ return 0;
101409+ }
101410+ return -EINVAL;
101411+}
101412+#endif
101413+
101414+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
101415+extern void pax_set_initial_flags(struct linux_binprm *bprm);
101416+#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
101417+extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
101418+#endif
101419+
101420+struct path;
101421+extern char *pax_get_path(const struct path *path, char *buf, int buflen);
101422+extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
101423+extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
101424+extern void pax_report_refcount_overflow(struct pt_regs *regs);
101425+
101426 /* Future-safe accessor for struct task_struct's cpus_allowed. */
101427 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
101428
101429@@ -1885,7 +1993,7 @@ struct pid_namespace;
101430 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
101431 struct pid_namespace *ns);
101432
101433-static inline pid_t task_pid_nr(struct task_struct *tsk)
101434+static inline pid_t task_pid_nr(const struct task_struct *tsk)
101435 {
101436 return tsk->pid;
101437 }
101438@@ -2253,6 +2361,25 @@ extern u64 sched_clock_cpu(int cpu);
101439
101440 extern void sched_clock_init(void);
101441
101442+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
101443+static inline void populate_stack(void)
101444+{
101445+ struct task_struct *curtask = current;
101446+ int c;
101447+ int *ptr = curtask->stack;
101448+ int *end = curtask->stack + THREAD_SIZE;
101449+
101450+ while (ptr < end) {
101451+ c = *(volatile int *)ptr;
101452+ ptr += PAGE_SIZE/sizeof(int);
101453+ }
101454+}
101455+#else
101456+static inline void populate_stack(void)
101457+{
101458+}
101459+#endif
101460+
101461 #ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
101462 static inline void sched_clock_tick(void)
101463 {
101464@@ -2381,7 +2508,9 @@ extern void set_curr_task(int cpu, struct task_struct *p);
101465 void yield(void);
101466
101467 union thread_union {
101468+#ifndef CONFIG_X86
101469 struct thread_info thread_info;
101470+#endif
101471 unsigned long stack[THREAD_SIZE/sizeof(long)];
101472 };
101473
101474@@ -2414,6 +2543,7 @@ extern struct pid_namespace init_pid_ns;
101475 */
101476
101477 extern struct task_struct *find_task_by_vpid(pid_t nr);
101478+extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
101479 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
101480 struct pid_namespace *ns);
101481
101482@@ -2591,7 +2721,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
101483 extern void exit_itimers(struct signal_struct *);
101484 extern void flush_itimer_signals(void);
101485
101486-extern void do_group_exit(int);
101487+extern __noreturn void do_group_exit(int);
101488
101489 extern int do_execve(struct filename *,
101490 const char __user * const __user *,
101491@@ -2796,9 +2926,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
101492 #define task_stack_end_corrupted(task) \
101493 (*(end_of_stack(task)) != STACK_END_MAGIC)
101494
101495-static inline int object_is_on_stack(void *obj)
101496+static inline int object_starts_on_stack(const void *obj)
101497 {
101498- void *stack = task_stack_page(current);
101499+ const void *stack = task_stack_page(current);
101500
101501 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
101502 }
101503diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
101504index c9e4731..c716293 100644
101505--- a/include/linux/sched/sysctl.h
101506+++ b/include/linux/sched/sysctl.h
101507@@ -34,6 +34,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
101508 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
101509
101510 extern int sysctl_max_map_count;
101511+extern unsigned long sysctl_heap_stack_gap;
101512
101513 extern unsigned int sysctl_sched_latency;
101514 extern unsigned int sysctl_sched_min_granularity;
101515diff --git a/include/linux/security.h b/include/linux/security.h
101516index 2f4c1f7..5bc05d7 100644
101517--- a/include/linux/security.h
101518+++ b/include/linux/security.h
101519@@ -28,6 +28,7 @@
101520 #include <linux/err.h>
101521 #include <linux/string.h>
101522 #include <linux/mm.h>
101523+#include <linux/grsecurity.h>
101524
101525 struct linux_binprm;
101526 struct cred;
101527diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
101528index dc368b8..e895209 100644
101529--- a/include/linux/semaphore.h
101530+++ b/include/linux/semaphore.h
101531@@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
101532 }
101533
101534 extern void down(struct semaphore *sem);
101535-extern int __must_check down_interruptible(struct semaphore *sem);
101536+extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
101537 extern int __must_check down_killable(struct semaphore *sem);
101538 extern int __must_check down_trylock(struct semaphore *sem);
101539 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
101540diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
101541index d4c7271..abf5706 100644
101542--- a/include/linux/seq_file.h
101543+++ b/include/linux/seq_file.h
101544@@ -27,6 +27,9 @@ struct seq_file {
101545 struct mutex lock;
101546 const struct seq_operations *op;
101547 int poll_event;
101548+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
101549+ u64 exec_id;
101550+#endif
101551 #ifdef CONFIG_USER_NS
101552 struct user_namespace *user_ns;
101553 #endif
101554@@ -39,6 +42,7 @@ struct seq_operations {
101555 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
101556 int (*show) (struct seq_file *m, void *v);
101557 };
101558+typedef struct seq_operations __no_const seq_operations_no_const;
101559
101560 #define SEQ_SKIP 1
101561
101562@@ -111,6 +115,7 @@ void seq_pad(struct seq_file *m, char c);
101563
101564 char *mangle_path(char *s, const char *p, const char *esc);
101565 int seq_open(struct file *, const struct seq_operations *);
101566+int seq_open_restrict(struct file *, const struct seq_operations *);
101567 ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
101568 loff_t seq_lseek(struct file *, loff_t, int);
101569 int seq_release(struct inode *, struct file *);
101570@@ -129,6 +134,7 @@ int seq_path_root(struct seq_file *m, const struct path *path,
101571 const struct path *root, const char *esc);
101572
101573 int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
101574+int single_open_restrict(struct file *, int (*)(struct seq_file *, void *), void *);
101575 int single_open_size(struct file *, int (*)(struct seq_file *, void *), void *, size_t);
101576 int single_release(struct inode *, struct file *);
101577 void *__seq_open_private(struct file *, const struct seq_operations *, int);
101578diff --git a/include/linux/shm.h b/include/linux/shm.h
101579index 6fb8016..2cf60e7 100644
101580--- a/include/linux/shm.h
101581+++ b/include/linux/shm.h
101582@@ -22,7 +22,11 @@ struct shmid_kernel /* private to the kernel */
101583 /* The task created the shm object. NULL if the task is dead. */
101584 struct task_struct *shm_creator;
101585 struct list_head shm_clist; /* list by creator */
101586-};
101587+#ifdef CONFIG_GRKERNSEC
101588+ u64 shm_createtime;
101589+ pid_t shm_lapid;
101590+#endif
101591+} __randomize_layout;
101592
101593 /* shm_mode upper byte flags */
101594 #define SHM_DEST 01000 /* segment will be destroyed on last detach */
101595diff --git a/include/linux/signal.h b/include/linux/signal.h
101596index ab1e039..ad4229e 100644
101597--- a/include/linux/signal.h
101598+++ b/include/linux/signal.h
101599@@ -289,7 +289,7 @@ static inline void allow_signal(int sig)
101600 * know it'll be handled, so that they don't get converted to
101601 * SIGKILL or just silently dropped.
101602 */
101603- kernel_sigaction(sig, (__force __sighandler_t)2);
101604+ kernel_sigaction(sig, (__force_user __sighandler_t)2);
101605 }
101606
101607 static inline void disallow_signal(int sig)
101608diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
101609index 9b88536..6a15c44 100644
101610--- a/include/linux/skbuff.h
101611+++ b/include/linux/skbuff.h
101612@@ -784,7 +784,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t priority, int flags,
101613 int node);
101614 struct sk_buff *__build_skb(void *data, unsigned int frag_size);
101615 struct sk_buff *build_skb(void *data, unsigned int frag_size);
101616-static inline struct sk_buff *alloc_skb(unsigned int size,
101617+static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
101618 gfp_t priority)
101619 {
101620 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
101621@@ -1979,7 +1979,7 @@ static inline u32 skb_inner_network_header_len(const struct sk_buff *skb)
101622 return skb->inner_transport_header - skb->inner_network_header;
101623 }
101624
101625-static inline int skb_network_offset(const struct sk_buff *skb)
101626+static inline int __intentional_overflow(0) skb_network_offset(const struct sk_buff *skb)
101627 {
101628 return skb_network_header(skb) - skb->data;
101629 }
101630@@ -2039,7 +2039,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
101631 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
101632 */
101633 #ifndef NET_SKB_PAD
101634-#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
101635+#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
101636 #endif
101637
101638 int ___pskb_trim(struct sk_buff *skb, unsigned int len);
101639@@ -2682,9 +2682,9 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
101640 int *err);
101641 unsigned int datagram_poll(struct file *file, struct socket *sock,
101642 struct poll_table_struct *wait);
101643-int skb_copy_datagram_iter(const struct sk_buff *from, int offset,
101644+int __intentional_overflow(0) skb_copy_datagram_iter(const struct sk_buff *from, int offset,
101645 struct iov_iter *to, int size);
101646-static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset,
101647+static inline int __intentional_overflow(2,4) skb_copy_datagram_msg(const struct sk_buff *from, int offset,
101648 struct msghdr *msg, int size)
101649 {
101650 return skb_copy_datagram_iter(from, offset, &msg->msg_iter, size);
101651@@ -3213,6 +3213,9 @@ static inline void nf_reset(struct sk_buff *skb)
101652 nf_bridge_put(skb->nf_bridge);
101653 skb->nf_bridge = NULL;
101654 #endif
101655+#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
101656+ skb->nf_trace = 0;
101657+#endif
101658 }
101659
101660 static inline void nf_reset_trace(struct sk_buff *skb)
101661diff --git a/include/linux/slab.h b/include/linux/slab.h
101662index a99f0e5..4efa730 100644
101663--- a/include/linux/slab.h
101664+++ b/include/linux/slab.h
101665@@ -15,14 +15,29 @@
101666 #include <linux/types.h>
101667 #include <linux/workqueue.h>
101668
101669+#include <linux/err.h>
101670
101671 /*
101672 * Flags to pass to kmem_cache_create().
101673 * The ones marked DEBUG are only valid if CONFIG_DEBUG_SLAB is set.
101674 */
101675 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
101676+
101677+#ifdef CONFIG_PAX_USERCOPY_SLABS
101678+#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
101679+#else
101680+#define SLAB_USERCOPY 0x00000000UL
101681+#endif
101682+
101683 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
101684 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
101685+
101686+#ifdef CONFIG_PAX_MEMORY_SANITIZE
101687+#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
101688+#else
101689+#define SLAB_NO_SANITIZE 0x00000000UL
101690+#endif
101691+
101692 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
101693 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
101694 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
101695@@ -98,10 +113,13 @@
101696 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
101697 * Both make kfree a no-op.
101698 */
101699-#define ZERO_SIZE_PTR ((void *)16)
101700+#define ZERO_SIZE_PTR \
101701+({ \
101702+ BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
101703+ (void *)(-MAX_ERRNO-1L); \
101704+})
101705
101706-#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
101707- (unsigned long)ZERO_SIZE_PTR)
101708+#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
101709
101710 #include <linux/kmemleak.h>
101711 #include <linux/kasan.h>
101712@@ -143,6 +161,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
101713 void kfree(const void *);
101714 void kzfree(const void *);
101715 size_t ksize(const void *);
101716+const char *check_heap_object(const void *ptr, unsigned long n);
101717+bool is_usercopy_object(const void *ptr);
101718
101719 /*
101720 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
101721@@ -235,6 +255,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
101722 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
101723 #endif
101724
101725+#ifdef CONFIG_PAX_USERCOPY_SLABS
101726+extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
101727+#endif
101728+
101729 /*
101730 * Figure out which kmalloc slab an allocation of a certain size
101731 * belongs to.
101732@@ -243,7 +267,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
101733 * 2 = 129 .. 192 bytes
101734 * n = 2^(n-1)+1 .. 2^n
101735 */
101736-static __always_inline int kmalloc_index(size_t size)
101737+static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
101738 {
101739 if (!size)
101740 return 0;
101741@@ -286,15 +310,15 @@ static __always_inline int kmalloc_index(size_t size)
101742 }
101743 #endif /* !CONFIG_SLOB */
101744
101745-void *__kmalloc(size_t size, gfp_t flags);
101746+void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
101747 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
101748 void kmem_cache_free(struct kmem_cache *, void *);
101749
101750 #ifdef CONFIG_NUMA
101751-void *__kmalloc_node(size_t size, gfp_t flags, int node);
101752+void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1) __size_overflow(1);
101753 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
101754 #else
101755-static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
101756+static __always_inline void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t flags, int node)
101757 {
101758 return __kmalloc(size, flags);
101759 }
101760diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
101761index 33d0490..70a6313 100644
101762--- a/include/linux/slab_def.h
101763+++ b/include/linux/slab_def.h
101764@@ -40,7 +40,7 @@ struct kmem_cache {
101765 /* 4) cache creation/removal */
101766 const char *name;
101767 struct list_head list;
101768- int refcount;
101769+ atomic_t refcount;
101770 int object_size;
101771 int align;
101772
101773@@ -56,10 +56,14 @@ struct kmem_cache {
101774 unsigned long node_allocs;
101775 unsigned long node_frees;
101776 unsigned long node_overflow;
101777- atomic_t allochit;
101778- atomic_t allocmiss;
101779- atomic_t freehit;
101780- atomic_t freemiss;
101781+ atomic_unchecked_t allochit;
101782+ atomic_unchecked_t allocmiss;
101783+ atomic_unchecked_t freehit;
101784+ atomic_unchecked_t freemiss;
101785+#ifdef CONFIG_PAX_MEMORY_SANITIZE
101786+ atomic_unchecked_t sanitized;
101787+ atomic_unchecked_t not_sanitized;
101788+#endif
101789
101790 /*
101791 * If debugging is enabled, then the allocator can add additional
101792diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
101793index 3388511..6252f90 100644
101794--- a/include/linux/slub_def.h
101795+++ b/include/linux/slub_def.h
101796@@ -74,7 +74,7 @@ struct kmem_cache {
101797 struct kmem_cache_order_objects max;
101798 struct kmem_cache_order_objects min;
101799 gfp_t allocflags; /* gfp flags to use on each alloc */
101800- int refcount; /* Refcount for slab cache destroy */
101801+ atomic_t refcount; /* Refcount for slab cache destroy */
101802 void (*ctor)(void *);
101803 int inuse; /* Offset to metadata */
101804 int align; /* Alignment */
101805diff --git a/include/linux/smp.h b/include/linux/smp.h
101806index c441407..f487b83 100644
101807--- a/include/linux/smp.h
101808+++ b/include/linux/smp.h
101809@@ -183,7 +183,9 @@ static inline void smp_init(void) { }
101810 #endif
101811
101812 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
101813+#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
101814 #define put_cpu() preempt_enable()
101815+#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
101816
101817 /*
101818 * Callback to arch code if there's nosmp or maxcpus=0 on the
101819diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
101820index fddebc6..6f0ae39 100644
101821--- a/include/linux/sock_diag.h
101822+++ b/include/linux/sock_diag.h
101823@@ -15,7 +15,7 @@ struct sock_diag_handler {
101824 __u8 family;
101825 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
101826 int (*get_info)(struct sk_buff *skb, struct sock *sk);
101827-};
101828+} __do_const;
101829
101830 int sock_diag_register(const struct sock_diag_handler *h);
101831 void sock_diag_unregister(const struct sock_diag_handler *h);
101832diff --git a/include/linux/sonet.h b/include/linux/sonet.h
101833index 680f9a3..f13aeb0 100644
101834--- a/include/linux/sonet.h
101835+++ b/include/linux/sonet.h
101836@@ -7,7 +7,7 @@
101837 #include <uapi/linux/sonet.h>
101838
101839 struct k_sonet_stats {
101840-#define __HANDLE_ITEM(i) atomic_t i
101841+#define __HANDLE_ITEM(i) atomic_unchecked_t i
101842 __SONET_ITEMS
101843 #undef __HANDLE_ITEM
101844 };
101845diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
101846index 07d8e53..dc934c9 100644
101847--- a/include/linux/sunrpc/addr.h
101848+++ b/include/linux/sunrpc/addr.h
101849@@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
101850 {
101851 switch (sap->sa_family) {
101852 case AF_INET:
101853- return ntohs(((struct sockaddr_in *)sap)->sin_port);
101854+ return ntohs(((const struct sockaddr_in *)sap)->sin_port);
101855 case AF_INET6:
101856- return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
101857+ return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
101858 }
101859 return 0;
101860 }
101861@@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
101862 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
101863 const struct sockaddr *src)
101864 {
101865- const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
101866+ const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
101867 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
101868
101869 dsin->sin_family = ssin->sin_family;
101870@@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
101871 if (sa->sa_family != AF_INET6)
101872 return 0;
101873
101874- return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
101875+ return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
101876 }
101877
101878 #endif /* _LINUX_SUNRPC_ADDR_H */
101879diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
101880index 131032f..5f9378a 100644
101881--- a/include/linux/sunrpc/clnt.h
101882+++ b/include/linux/sunrpc/clnt.h
101883@@ -101,7 +101,7 @@ struct rpc_procinfo {
101884 unsigned int p_timer; /* Which RTT timer to use */
101885 u32 p_statidx; /* Which procedure to account */
101886 const char * p_name; /* name of procedure */
101887-};
101888+} __do_const;
101889
101890 #ifdef __KERNEL__
101891
101892diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
101893index fae6fb9..023fbcd 100644
101894--- a/include/linux/sunrpc/svc.h
101895+++ b/include/linux/sunrpc/svc.h
101896@@ -420,7 +420,7 @@ struct svc_procedure {
101897 unsigned int pc_count; /* call count */
101898 unsigned int pc_cachetype; /* cache info (NFS) */
101899 unsigned int pc_xdrressize; /* maximum size of XDR reply */
101900-};
101901+} __do_const;
101902
101903 /*
101904 * Function prototypes.
101905diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
101906index 4929a8a..b8f29e9 100644
101907--- a/include/linux/sunrpc/svc_rdma.h
101908+++ b/include/linux/sunrpc/svc_rdma.h
101909@@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
101910 extern unsigned int svcrdma_max_requests;
101911 extern unsigned int svcrdma_max_req_size;
101912
101913-extern atomic_t rdma_stat_recv;
101914-extern atomic_t rdma_stat_read;
101915-extern atomic_t rdma_stat_write;
101916-extern atomic_t rdma_stat_sq_starve;
101917-extern atomic_t rdma_stat_rq_starve;
101918-extern atomic_t rdma_stat_rq_poll;
101919-extern atomic_t rdma_stat_rq_prod;
101920-extern atomic_t rdma_stat_sq_poll;
101921-extern atomic_t rdma_stat_sq_prod;
101922+extern atomic_unchecked_t rdma_stat_recv;
101923+extern atomic_unchecked_t rdma_stat_read;
101924+extern atomic_unchecked_t rdma_stat_write;
101925+extern atomic_unchecked_t rdma_stat_sq_starve;
101926+extern atomic_unchecked_t rdma_stat_rq_starve;
101927+extern atomic_unchecked_t rdma_stat_rq_poll;
101928+extern atomic_unchecked_t rdma_stat_rq_prod;
101929+extern atomic_unchecked_t rdma_stat_sq_poll;
101930+extern atomic_unchecked_t rdma_stat_sq_prod;
101931
101932 /*
101933 * Contexts are built when an RDMA request is created and are a
101934diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
101935index 8d71d65..f79586e 100644
101936--- a/include/linux/sunrpc/svcauth.h
101937+++ b/include/linux/sunrpc/svcauth.h
101938@@ -120,7 +120,7 @@ struct auth_ops {
101939 int (*release)(struct svc_rqst *rq);
101940 void (*domain_release)(struct auth_domain *);
101941 int (*set_client)(struct svc_rqst *rq);
101942-};
101943+} __do_const;
101944
101945 #define SVC_GARBAGE 1
101946 #define SVC_SYSERR 2
101947diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
101948index e7a018e..49f8b17 100644
101949--- a/include/linux/swiotlb.h
101950+++ b/include/linux/swiotlb.h
101951@@ -60,7 +60,8 @@ extern void
101952
101953 extern void
101954 swiotlb_free_coherent(struct device *hwdev, size_t size,
101955- void *vaddr, dma_addr_t dma_handle);
101956+ void *vaddr, dma_addr_t dma_handle,
101957+ struct dma_attrs *attrs);
101958
101959 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
101960 unsigned long offset, size_t size,
101961diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
101962index b45c45b..a6ae64c 100644
101963--- a/include/linux/syscalls.h
101964+++ b/include/linux/syscalls.h
101965@@ -102,7 +102,12 @@ union bpf_attr;
101966 #define __TYPE_IS_L(t) (__same_type((t)0, 0L))
101967 #define __TYPE_IS_UL(t) (__same_type((t)0, 0UL))
101968 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
101969-#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
101970+#define __SC_LONG(t, a) __typeof__( \
101971+ __builtin_choose_expr( \
101972+ sizeof(t) > sizeof(int), \
101973+ (t) 0, \
101974+ __builtin_choose_expr(__type_is_unsigned(t), 0UL, 0L) \
101975+ )) a
101976 #define __SC_CAST(t, a) (t) a
101977 #define __SC_ARGS(t, a) a
101978 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
101979@@ -384,11 +389,11 @@ asmlinkage long sys_sync(void);
101980 asmlinkage long sys_fsync(unsigned int fd);
101981 asmlinkage long sys_fdatasync(unsigned int fd);
101982 asmlinkage long sys_bdflush(int func, long data);
101983-asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
101984- char __user *type, unsigned long flags,
101985+asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
101986+ const char __user *type, unsigned long flags,
101987 void __user *data);
101988-asmlinkage long sys_umount(char __user *name, int flags);
101989-asmlinkage long sys_oldumount(char __user *name);
101990+asmlinkage long sys_umount(const char __user *name, int flags);
101991+asmlinkage long sys_oldumount(const char __user *name);
101992 asmlinkage long sys_truncate(const char __user *path, long length);
101993 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
101994 asmlinkage long sys_stat(const char __user *filename,
101995@@ -604,7 +609,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
101996 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
101997 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
101998 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
101999- struct sockaddr __user *, int);
102000+ struct sockaddr __user *, int) __intentional_overflow(0);
102001 asmlinkage long sys_sendmsg(int fd, struct user_msghdr __user *msg, unsigned flags);
102002 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
102003 unsigned int vlen, unsigned flags);
102004@@ -663,10 +668,10 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf);
102005
102006 asmlinkage long sys_semget(key_t key, int nsems, int semflg);
102007 asmlinkage long sys_semop(int semid, struct sembuf __user *sops,
102008- unsigned nsops);
102009+ long nsops);
102010 asmlinkage long sys_semctl(int semid, int semnum, int cmd, unsigned long arg);
102011 asmlinkage long sys_semtimedop(int semid, struct sembuf __user *sops,
102012- unsigned nsops,
102013+ long nsops,
102014 const struct timespec __user *timeout);
102015 asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg);
102016 asmlinkage long sys_shmget(key_t key, size_t size, int flag);
102017diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
102018index 27b3b0b..e093dd9 100644
102019--- a/include/linux/syscore_ops.h
102020+++ b/include/linux/syscore_ops.h
102021@@ -16,7 +16,7 @@ struct syscore_ops {
102022 int (*suspend)(void);
102023 void (*resume)(void);
102024 void (*shutdown)(void);
102025-};
102026+} __do_const;
102027
102028 extern void register_syscore_ops(struct syscore_ops *ops);
102029 extern void unregister_syscore_ops(struct syscore_ops *ops);
102030diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
102031index fa7bc29..0d96561 100644
102032--- a/include/linux/sysctl.h
102033+++ b/include/linux/sysctl.h
102034@@ -39,10 +39,16 @@ typedef int proc_handler (struct ctl_table *ctl, int write,
102035
102036 extern int proc_dostring(struct ctl_table *, int,
102037 void __user *, size_t *, loff_t *);
102038+extern int proc_dostring_modpriv(struct ctl_table *, int,
102039+ void __user *, size_t *, loff_t *);
102040 extern int proc_dointvec(struct ctl_table *, int,
102041 void __user *, size_t *, loff_t *);
102042+extern int proc_dointvec_secure(struct ctl_table *, int,
102043+ void __user *, size_t *, loff_t *);
102044 extern int proc_dointvec_minmax(struct ctl_table *, int,
102045 void __user *, size_t *, loff_t *);
102046+extern int proc_dointvec_minmax_secure(struct ctl_table *, int,
102047+ void __user *, size_t *, loff_t *);
102048 extern int proc_dointvec_jiffies(struct ctl_table *, int,
102049 void __user *, size_t *, loff_t *);
102050 extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int,
102051@@ -113,7 +119,8 @@ struct ctl_table
102052 struct ctl_table_poll *poll;
102053 void *extra1;
102054 void *extra2;
102055-};
102056+} __do_const __randomize_layout;
102057+typedef struct ctl_table __no_const ctl_table_no_const;
102058
102059 struct ctl_node {
102060 struct rb_node node;
102061diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
102062index 9f65758..487a6f1 100644
102063--- a/include/linux/sysfs.h
102064+++ b/include/linux/sysfs.h
102065@@ -34,7 +34,8 @@ struct attribute {
102066 struct lock_class_key *key;
102067 struct lock_class_key skey;
102068 #endif
102069-};
102070+} __do_const;
102071+typedef struct attribute __no_const attribute_no_const;
102072
102073 /**
102074 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
102075@@ -78,7 +79,8 @@ struct attribute_group {
102076 struct attribute *, int);
102077 struct attribute **attrs;
102078 struct bin_attribute **bin_attrs;
102079-};
102080+} __do_const;
102081+typedef struct attribute_group __no_const attribute_group_no_const;
102082
102083 /**
102084 * Use these macros to make defining attributes easier. See include/linux/device.h
102085@@ -152,7 +154,8 @@ struct bin_attribute {
102086 char *, loff_t, size_t);
102087 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
102088 struct vm_area_struct *vma);
102089-};
102090+} __do_const;
102091+typedef struct bin_attribute __no_const bin_attribute_no_const;
102092
102093 /**
102094 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
102095diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
102096index 387fa7d..3fcde6b 100644
102097--- a/include/linux/sysrq.h
102098+++ b/include/linux/sysrq.h
102099@@ -16,6 +16,7 @@
102100
102101 #include <linux/errno.h>
102102 #include <linux/types.h>
102103+#include <linux/compiler.h>
102104
102105 /* Possible values of bitmask for enabling sysrq functions */
102106 /* 0x0001 is reserved for enable everything */
102107@@ -33,7 +34,7 @@ struct sysrq_key_op {
102108 char *help_msg;
102109 char *action_msg;
102110 int enable_mask;
102111-};
102112+} __do_const;
102113
102114 #ifdef CONFIG_MAGIC_SYSRQ
102115
102116diff --git a/include/linux/tcp.h b/include/linux/tcp.h
102117index 48c3696..e7a7ba6 100644
102118--- a/include/linux/tcp.h
102119+++ b/include/linux/tcp.h
102120@@ -63,13 +63,13 @@ struct tcp_fastopen_cookie {
102121
102122 /* This defines a selective acknowledgement block. */
102123 struct tcp_sack_block_wire {
102124- __be32 start_seq;
102125- __be32 end_seq;
102126+ __be32 start_seq __intentional_overflow(-1);
102127+ __be32 end_seq __intentional_overflow(-1);
102128 };
102129
102130 struct tcp_sack_block {
102131- u32 start_seq;
102132- u32 end_seq;
102133+ u32 start_seq __intentional_overflow(-1);
102134+ u32 end_seq __intentional_overflow(-1);
102135 };
102136
102137 /*These are used to set the sack_ok field in struct tcp_options_received */
102138@@ -153,7 +153,7 @@ struct tcp_sock {
102139 * total number of segments in.
102140 */
102141 u32 rcv_nxt; /* What we want to receive next */
102142- u32 copied_seq; /* Head of yet unread data */
102143+ u32 copied_seq __intentional_overflow(-1); /* Head of yet unread data */
102144 u32 rcv_wup; /* rcv_nxt on last window update sent */
102145 u32 snd_nxt; /* Next sequence we send */
102146 u32 segs_out; /* RFC4898 tcpEStatsPerfSegsOut
102147@@ -248,7 +248,7 @@ struct tcp_sock {
102148 u32 prr_out; /* Total number of pkts sent during Recovery. */
102149
102150 u32 rcv_wnd; /* Current receiver window */
102151- u32 write_seq; /* Tail(+1) of data held in tcp send buffer */
102152+ u32 write_seq __intentional_overflow(-1); /* Tail(+1) of data held in tcp send buffer */
102153 u32 notsent_lowat; /* TCP_NOTSENT_LOWAT */
102154 u32 pushed_seq; /* Last pushed seq, required to talk to windows */
102155 u32 lost_out; /* Lost packets */
102156@@ -291,7 +291,7 @@ struct tcp_sock {
102157 int undo_retrans; /* number of undoable retransmissions. */
102158 u32 total_retrans; /* Total retransmits for entire connection */
102159
102160- u32 urg_seq; /* Seq of received urgent pointer */
102161+ u32 urg_seq __intentional_overflow(-1); /* Seq of received urgent pointer */
102162 unsigned int keepalive_time; /* time before keep alive takes place */
102163 unsigned int keepalive_intvl; /* time interval between keep alive probes */
102164
102165diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
102166index ff307b5..f1a4468 100644
102167--- a/include/linux/thread_info.h
102168+++ b/include/linux/thread_info.h
102169@@ -145,6 +145,13 @@ static inline bool test_and_clear_restore_sigmask(void)
102170 #error "no set_restore_sigmask() provided and default one won't work"
102171 #endif
102172
102173+extern void __check_object_size(const void *ptr, unsigned long n, bool to_user, bool const_size);
102174+
102175+static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
102176+{
102177+ __check_object_size(ptr, n, to_user, __builtin_constant_p(n));
102178+}
102179+
102180 #endif /* __KERNEL__ */
102181
102182 #endif /* _LINUX_THREAD_INFO_H */
102183diff --git a/include/linux/tty.h b/include/linux/tty.h
102184index ad6c891..93a8f45 100644
102185--- a/include/linux/tty.h
102186+++ b/include/linux/tty.h
102187@@ -225,7 +225,7 @@ struct tty_port {
102188 const struct tty_port_operations *ops; /* Port operations */
102189 spinlock_t lock; /* Lock protecting tty field */
102190 int blocked_open; /* Waiting to open */
102191- int count; /* Usage count */
102192+ atomic_t count; /* Usage count */
102193 wait_queue_head_t open_wait; /* Open waiters */
102194 wait_queue_head_t close_wait; /* Close waiters */
102195 wait_queue_head_t delta_msr_wait; /* Modem status change */
102196@@ -313,7 +313,7 @@ struct tty_struct {
102197 /* If the tty has a pending do_SAK, queue it here - akpm */
102198 struct work_struct SAK_work;
102199 struct tty_port *port;
102200-};
102201+} __randomize_layout;
102202
102203 /* Each of a tty's open files has private_data pointing to tty_file_private */
102204 struct tty_file_private {
102205@@ -573,7 +573,7 @@ extern int tty_port_open(struct tty_port *port,
102206 struct tty_struct *tty, struct file *filp);
102207 static inline int tty_port_users(struct tty_port *port)
102208 {
102209- return port->count + port->blocked_open;
102210+ return atomic_read(&port->count) + port->blocked_open;
102211 }
102212
102213 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
102214diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
102215index 92e337c..f46757b 100644
102216--- a/include/linux/tty_driver.h
102217+++ b/include/linux/tty_driver.h
102218@@ -291,7 +291,7 @@ struct tty_operations {
102219 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
102220 #endif
102221 const struct file_operations *proc_fops;
102222-};
102223+} __do_const __randomize_layout;
102224
102225 struct tty_driver {
102226 int magic; /* magic number for this structure */
102227@@ -325,7 +325,7 @@ struct tty_driver {
102228
102229 const struct tty_operations *ops;
102230 struct list_head tty_drivers;
102231-};
102232+} __randomize_layout;
102233
102234 extern struct list_head tty_drivers;
102235
102236diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
102237index 00c9d68..bc0188b 100644
102238--- a/include/linux/tty_ldisc.h
102239+++ b/include/linux/tty_ldisc.h
102240@@ -215,7 +215,7 @@ struct tty_ldisc_ops {
102241
102242 struct module *owner;
102243
102244- int refcount;
102245+ atomic_t refcount;
102246 };
102247
102248 struct tty_ldisc {
102249diff --git a/include/linux/types.h b/include/linux/types.h
102250index 8715287..1be77ee 100644
102251--- a/include/linux/types.h
102252+++ b/include/linux/types.h
102253@@ -176,10 +176,26 @@ typedef struct {
102254 int counter;
102255 } atomic_t;
102256
102257+#ifdef CONFIG_PAX_REFCOUNT
102258+typedef struct {
102259+ int counter;
102260+} atomic_unchecked_t;
102261+#else
102262+typedef atomic_t atomic_unchecked_t;
102263+#endif
102264+
102265 #ifdef CONFIG_64BIT
102266 typedef struct {
102267 long counter;
102268 } atomic64_t;
102269+
102270+#ifdef CONFIG_PAX_REFCOUNT
102271+typedef struct {
102272+ long counter;
102273+} atomic64_unchecked_t;
102274+#else
102275+typedef atomic64_t atomic64_unchecked_t;
102276+#endif
102277 #endif
102278
102279 struct list_head {
102280diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
102281index ae572c1..73bd4ec 100644
102282--- a/include/linux/uaccess.h
102283+++ b/include/linux/uaccess.h
102284@@ -97,11 +97,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
102285 long ret; \
102286 mm_segment_t old_fs = get_fs(); \
102287 \
102288- set_fs(KERNEL_DS); \
102289 pagefault_disable(); \
102290- ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
102291- pagefault_enable(); \
102292+ set_fs(KERNEL_DS); \
102293+ ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
102294 set_fs(old_fs); \
102295+ pagefault_enable(); \
102296 ret; \
102297 })
102298
102299diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
102300index 0383552..a0125dd 100644
102301--- a/include/linux/uidgid.h
102302+++ b/include/linux/uidgid.h
102303@@ -187,4 +187,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
102304
102305 #endif /* CONFIG_USER_NS */
102306
102307+#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
102308+#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
102309+#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
102310+#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
102311+
102312 #endif /* _LINUX_UIDGID_H */
102313diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
102314index 32c0e83..671eb35 100644
102315--- a/include/linux/uio_driver.h
102316+++ b/include/linux/uio_driver.h
102317@@ -67,7 +67,7 @@ struct uio_device {
102318 struct module *owner;
102319 struct device *dev;
102320 int minor;
102321- atomic_t event;
102322+ atomic_unchecked_t event;
102323 struct fasync_struct *async_queue;
102324 wait_queue_head_t wait;
102325 struct uio_info *info;
102326diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
102327index 99c1b4d..562e6f3 100644
102328--- a/include/linux/unaligned/access_ok.h
102329+++ b/include/linux/unaligned/access_ok.h
102330@@ -4,34 +4,34 @@
102331 #include <linux/kernel.h>
102332 #include <asm/byteorder.h>
102333
102334-static inline u16 get_unaligned_le16(const void *p)
102335+static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
102336 {
102337- return le16_to_cpup((__le16 *)p);
102338+ return le16_to_cpup((const __le16 *)p);
102339 }
102340
102341-static inline u32 get_unaligned_le32(const void *p)
102342+static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
102343 {
102344- return le32_to_cpup((__le32 *)p);
102345+ return le32_to_cpup((const __le32 *)p);
102346 }
102347
102348-static inline u64 get_unaligned_le64(const void *p)
102349+static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
102350 {
102351- return le64_to_cpup((__le64 *)p);
102352+ return le64_to_cpup((const __le64 *)p);
102353 }
102354
102355-static inline u16 get_unaligned_be16(const void *p)
102356+static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
102357 {
102358- return be16_to_cpup((__be16 *)p);
102359+ return be16_to_cpup((const __be16 *)p);
102360 }
102361
102362-static inline u32 get_unaligned_be32(const void *p)
102363+static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
102364 {
102365- return be32_to_cpup((__be32 *)p);
102366+ return be32_to_cpup((const __be32 *)p);
102367 }
102368
102369-static inline u64 get_unaligned_be64(const void *p)
102370+static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
102371 {
102372- return be64_to_cpup((__be64 *)p);
102373+ return be64_to_cpup((const __be64 *)p);
102374 }
102375
102376 static inline void put_unaligned_le16(u16 val, void *p)
102377diff --git a/include/linux/usb.h b/include/linux/usb.h
102378index 447fe29..fc8bf1e 100644
102379--- a/include/linux/usb.h
102380+++ b/include/linux/usb.h
102381@@ -363,7 +363,7 @@ struct usb_bus {
102382 * with the URB_SHORT_NOT_OK flag set.
102383 */
102384 unsigned no_sg_constraint:1; /* no sg constraint */
102385- unsigned sg_tablesize; /* 0 or largest number of sg list entries */
102386+ unsigned short sg_tablesize; /* 0 or largest number of sg list entries */
102387
102388 int devnum_next; /* Next open device number in
102389 * round-robin allocation */
102390@@ -592,7 +592,7 @@ struct usb_device {
102391 int maxchild;
102392
102393 u32 quirks;
102394- atomic_t urbnum;
102395+ atomic_unchecked_t urbnum;
102396
102397 unsigned long active_duration;
102398
102399diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
102400index c9aa779..46d6f69 100644
102401--- a/include/linux/usb/hcd.h
102402+++ b/include/linux/usb/hcd.h
102403@@ -23,6 +23,7 @@
102404
102405 #include <linux/rwsem.h>
102406 #include <linux/interrupt.h>
102407+#include <scsi/scsi_host.h>
102408
102409 #define MAX_TOPO_LEVEL 6
102410
102411diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
102412index 3dd5a78..ed69d7b 100644
102413--- a/include/linux/usb/renesas_usbhs.h
102414+++ b/include/linux/usb/renesas_usbhs.h
102415@@ -39,7 +39,7 @@ enum {
102416 */
102417 struct renesas_usbhs_driver_callback {
102418 int (*notify_hotplug)(struct platform_device *pdev);
102419-};
102420+} __no_const;
102421
102422 /*
102423 * callback functions for platform
102424diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
102425index 8297e5b..0dfae27 100644
102426--- a/include/linux/user_namespace.h
102427+++ b/include/linux/user_namespace.h
102428@@ -39,7 +39,7 @@ struct user_namespace {
102429 struct key *persistent_keyring_register;
102430 struct rw_semaphore persistent_keyring_register_sem;
102431 #endif
102432-};
102433+} __randomize_layout;
102434
102435 extern struct user_namespace init_user_ns;
102436
102437diff --git a/include/linux/utsname.h b/include/linux/utsname.h
102438index 5093f58..c103e58 100644
102439--- a/include/linux/utsname.h
102440+++ b/include/linux/utsname.h
102441@@ -25,7 +25,7 @@ struct uts_namespace {
102442 struct new_utsname name;
102443 struct user_namespace *user_ns;
102444 struct ns_common ns;
102445-};
102446+} __randomize_layout;
102447 extern struct uts_namespace init_uts_ns;
102448
102449 #ifdef CONFIG_UTS_NS
102450diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
102451index 6f8fbcf..4efc177 100644
102452--- a/include/linux/vermagic.h
102453+++ b/include/linux/vermagic.h
102454@@ -25,9 +25,42 @@
102455 #define MODULE_ARCH_VERMAGIC ""
102456 #endif
102457
102458+#ifdef CONFIG_PAX_REFCOUNT
102459+#define MODULE_PAX_REFCOUNT "REFCOUNT "
102460+#else
102461+#define MODULE_PAX_REFCOUNT ""
102462+#endif
102463+
102464+#ifdef CONSTIFY_PLUGIN
102465+#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
102466+#else
102467+#define MODULE_CONSTIFY_PLUGIN ""
102468+#endif
102469+
102470+#ifdef STACKLEAK_PLUGIN
102471+#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
102472+#else
102473+#define MODULE_STACKLEAK_PLUGIN ""
102474+#endif
102475+
102476+#ifdef RANDSTRUCT_PLUGIN
102477+#include <generated/randomize_layout_hash.h>
102478+#define MODULE_RANDSTRUCT_PLUGIN "RANDSTRUCT_PLUGIN_" RANDSTRUCT_HASHED_SEED
102479+#else
102480+#define MODULE_RANDSTRUCT_PLUGIN
102481+#endif
102482+
102483+#ifdef CONFIG_GRKERNSEC
102484+#define MODULE_GRSEC "GRSEC "
102485+#else
102486+#define MODULE_GRSEC ""
102487+#endif
102488+
102489 #define VERMAGIC_STRING \
102490 UTS_RELEASE " " \
102491 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
102492 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
102493- MODULE_ARCH_VERMAGIC
102494+ MODULE_ARCH_VERMAGIC \
102495+ MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
102496+ MODULE_GRSEC MODULE_RANDSTRUCT_PLUGIN
102497
102498diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
102499index b483abd..af305ad 100644
102500--- a/include/linux/vga_switcheroo.h
102501+++ b/include/linux/vga_switcheroo.h
102502@@ -63,9 +63,9 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
102503
102504 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
102505
102506-int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
102507+int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
102508 void vga_switcheroo_fini_domain_pm_ops(struct device *dev);
102509-int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
102510+int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
102511 #else
102512
102513 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
102514@@ -82,9 +82,9 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
102515
102516 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
102517
102518-static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
102519+static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
102520 static inline void vga_switcheroo_fini_domain_pm_ops(struct device *dev) {}
102521-static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
102522+static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
102523
102524 #endif
102525 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
102526diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
102527index 0ec5983..d5888bb 100644
102528--- a/include/linux/vmalloc.h
102529+++ b/include/linux/vmalloc.h
102530@@ -18,6 +18,14 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
102531 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
102532 #define VM_NO_GUARD 0x00000040 /* don't add guard page */
102533 #define VM_KASAN 0x00000080 /* has allocated kasan shadow memory */
102534+
102535+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
102536+#define VM_KERNEXEC 0x00000100 /* allocate from executable kernel memory range */
102537+#endif
102538+
102539+#define VM_USERCOPY 0x00000200 /* allocation intended for copies to userland */
102540+
102541+
102542 /* bits [20..32] reserved for arch specific ioremap internals */
102543
102544 /*
102545@@ -67,6 +75,7 @@ static inline void vmalloc_init(void)
102546 #endif
102547
102548 extern void *vmalloc(unsigned long size);
102549+extern void *vmalloc_usercopy(unsigned long size);
102550 extern void *vzalloc(unsigned long size);
102551 extern void *vmalloc_user(unsigned long size);
102552 extern void *vmalloc_node(unsigned long size, int node);
102553@@ -86,6 +95,10 @@ extern void *vmap(struct page **pages, unsigned int count,
102554 unsigned long flags, pgprot_t prot);
102555 extern void vunmap(const void *addr);
102556
102557+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
102558+extern void unmap_process_stacks(struct task_struct *task);
102559+#endif
102560+
102561 extern int remap_vmalloc_range_partial(struct vm_area_struct *vma,
102562 unsigned long uaddr, void *kaddr,
102563 unsigned long size);
102564@@ -150,7 +163,7 @@ extern void free_vm_area(struct vm_struct *area);
102565
102566 /* for /dev/kmem */
102567 extern long vread(char *buf, char *addr, unsigned long count);
102568-extern long vwrite(char *buf, char *addr, unsigned long count);
102569+extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
102570
102571 /*
102572 * Internals. Dont't use..
102573diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
102574index 82e7db7..f8ce3d0 100644
102575--- a/include/linux/vmstat.h
102576+++ b/include/linux/vmstat.h
102577@@ -108,18 +108,18 @@ static inline void vm_events_fold_cpu(int cpu)
102578 /*
102579 * Zone based page accounting with per cpu differentials.
102580 */
102581-extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
102582+extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
102583
102584 static inline void zone_page_state_add(long x, struct zone *zone,
102585 enum zone_stat_item item)
102586 {
102587- atomic_long_add(x, &zone->vm_stat[item]);
102588- atomic_long_add(x, &vm_stat[item]);
102589+ atomic_long_add_unchecked(x, &zone->vm_stat[item]);
102590+ atomic_long_add_unchecked(x, &vm_stat[item]);
102591 }
102592
102593-static inline unsigned long global_page_state(enum zone_stat_item item)
102594+static inline unsigned long __intentional_overflow(-1) global_page_state(enum zone_stat_item item)
102595 {
102596- long x = atomic_long_read(&vm_stat[item]);
102597+ long x = atomic_long_read_unchecked(&vm_stat[item]);
102598 #ifdef CONFIG_SMP
102599 if (x < 0)
102600 x = 0;
102601@@ -127,10 +127,10 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
102602 return x;
102603 }
102604
102605-static inline unsigned long zone_page_state(struct zone *zone,
102606+static inline unsigned long __intentional_overflow(-1) zone_page_state(struct zone *zone,
102607 enum zone_stat_item item)
102608 {
102609- long x = atomic_long_read(&zone->vm_stat[item]);
102610+ long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
102611 #ifdef CONFIG_SMP
102612 if (x < 0)
102613 x = 0;
102614@@ -147,7 +147,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
102615 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
102616 enum zone_stat_item item)
102617 {
102618- long x = atomic_long_read(&zone->vm_stat[item]);
102619+ long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
102620
102621 #ifdef CONFIG_SMP
102622 int cpu;
102623@@ -234,14 +234,14 @@ static inline void __mod_zone_page_state(struct zone *zone,
102624
102625 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
102626 {
102627- atomic_long_inc(&zone->vm_stat[item]);
102628- atomic_long_inc(&vm_stat[item]);
102629+ atomic_long_inc_unchecked(&zone->vm_stat[item]);
102630+ atomic_long_inc_unchecked(&vm_stat[item]);
102631 }
102632
102633 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
102634 {
102635- atomic_long_dec(&zone->vm_stat[item]);
102636- atomic_long_dec(&vm_stat[item]);
102637+ atomic_long_dec_unchecked(&zone->vm_stat[item]);
102638+ atomic_long_dec_unchecked(&vm_stat[item]);
102639 }
102640
102641 static inline void __inc_zone_page_state(struct page *page,
102642diff --git a/include/linux/xattr.h b/include/linux/xattr.h
102643index 91b0a68..0e9adf6 100644
102644--- a/include/linux/xattr.h
102645+++ b/include/linux/xattr.h
102646@@ -28,7 +28,7 @@ struct xattr_handler {
102647 size_t size, int handler_flags);
102648 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
102649 size_t size, int flags, int handler_flags);
102650-};
102651+} __do_const;
102652
102653 struct xattr {
102654 const char *name;
102655@@ -37,6 +37,9 @@ struct xattr {
102656 };
102657
102658 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
102659+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
102660+ssize_t pax_getxattr(struct dentry *, void *, size_t);
102661+#endif
102662 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
102663 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
102664 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
102665diff --git a/include/linux/zlib.h b/include/linux/zlib.h
102666index 92dbbd3..13ab0b3 100644
102667--- a/include/linux/zlib.h
102668+++ b/include/linux/zlib.h
102669@@ -31,6 +31,7 @@
102670 #define _ZLIB_H
102671
102672 #include <linux/zconf.h>
102673+#include <linux/compiler.h>
102674
102675 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
102676 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
102677@@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
102678
102679 /* basic functions */
102680
102681-extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
102682+extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
102683 /*
102684 Returns the number of bytes that needs to be allocated for a per-
102685 stream workspace with the specified parameters. A pointer to this
102686diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
102687index acbcd2f..c3abe84 100644
102688--- a/include/media/v4l2-dev.h
102689+++ b/include/media/v4l2-dev.h
102690@@ -74,7 +74,7 @@ struct v4l2_file_operations {
102691 int (*mmap) (struct file *, struct vm_area_struct *);
102692 int (*open) (struct file *);
102693 int (*release) (struct file *);
102694-};
102695+} __do_const;
102696
102697 /*
102698 * Newer version of video_device, handled by videodev2.c
102699diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
102700index 9c58157..d86ebf5 100644
102701--- a/include/media/v4l2-device.h
102702+++ b/include/media/v4l2-device.h
102703@@ -93,7 +93,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
102704 this function returns 0. If the name ends with a digit (e.g. cx18),
102705 then the name will be set to cx18-0 since cx180 looks really odd. */
102706 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
102707- atomic_t *instance);
102708+ atomic_unchecked_t *instance);
102709
102710 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
102711 Since the parent disappears this ensures that v4l2_dev doesn't have an
102712diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
102713index 5122b5e..598b440 100644
102714--- a/include/net/9p/transport.h
102715+++ b/include/net/9p/transport.h
102716@@ -62,7 +62,7 @@ struct p9_trans_module {
102717 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
102718 int (*zc_request)(struct p9_client *, struct p9_req_t *,
102719 struct iov_iter *, struct iov_iter *, int , int, int);
102720-};
102721+} __do_const;
102722
102723 void v9fs_register_trans(struct p9_trans_module *m);
102724 void v9fs_unregister_trans(struct p9_trans_module *m);
102725diff --git a/include/net/af_unix.h b/include/net/af_unix.h
102726index 4a167b3..73dcbb3 100644
102727--- a/include/net/af_unix.h
102728+++ b/include/net/af_unix.h
102729@@ -36,7 +36,7 @@ struct unix_skb_parms {
102730 u32 secid; /* Security ID */
102731 #endif
102732 u32 consumed;
102733-};
102734+} __randomize_layout;
102735
102736 #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))
102737
102738diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
102739index 2239a37..a83461f 100644
102740--- a/include/net/bluetooth/l2cap.h
102741+++ b/include/net/bluetooth/l2cap.h
102742@@ -609,7 +609,7 @@ struct l2cap_ops {
102743 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
102744 unsigned long hdr_len,
102745 unsigned long len, int nb);
102746-};
102747+} __do_const;
102748
102749 struct l2cap_conn {
102750 struct hci_conn *hcon;
102751diff --git a/include/net/bonding.h b/include/net/bonding.h
102752index 20defc0..3072903 100644
102753--- a/include/net/bonding.h
102754+++ b/include/net/bonding.h
102755@@ -661,7 +661,7 @@ extern struct rtnl_link_ops bond_link_ops;
102756
102757 static inline void bond_tx_drop(struct net_device *dev, struct sk_buff *skb)
102758 {
102759- atomic_long_inc(&dev->tx_dropped);
102760+ atomic_long_inc_unchecked(&dev->tx_dropped);
102761 dev_kfree_skb_any(skb);
102762 }
102763
102764diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
102765index f2ae33d..c457cf0 100644
102766--- a/include/net/caif/cfctrl.h
102767+++ b/include/net/caif/cfctrl.h
102768@@ -52,7 +52,7 @@ struct cfctrl_rsp {
102769 void (*radioset_rsp)(void);
102770 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
102771 struct cflayer *client_layer);
102772-};
102773+} __no_const;
102774
102775 /* Link Setup Parameters for CAIF-Links. */
102776 struct cfctrl_link_param {
102777@@ -101,8 +101,8 @@ struct cfctrl_request_info {
102778 struct cfctrl {
102779 struct cfsrvl serv;
102780 struct cfctrl_rsp res;
102781- atomic_t req_seq_no;
102782- atomic_t rsp_seq_no;
102783+ atomic_unchecked_t req_seq_no;
102784+ atomic_unchecked_t rsp_seq_no;
102785 struct list_head list;
102786 /* Protects from simultaneous access to first_req list */
102787 spinlock_t info_list_lock;
102788diff --git a/include/net/flow.h b/include/net/flow.h
102789index 8109a15..504466d 100644
102790--- a/include/net/flow.h
102791+++ b/include/net/flow.h
102792@@ -231,6 +231,6 @@ void flow_cache_fini(struct net *net);
102793
102794 void flow_cache_flush(struct net *net);
102795 void flow_cache_flush_deferred(struct net *net);
102796-extern atomic_t flow_cache_genid;
102797+extern atomic_unchecked_t flow_cache_genid;
102798
102799 #endif
102800diff --git a/include/net/genetlink.h b/include/net/genetlink.h
102801index a9af1cc..1f3fa7b 100644
102802--- a/include/net/genetlink.h
102803+++ b/include/net/genetlink.h
102804@@ -128,7 +128,7 @@ struct genl_ops {
102805 u8 cmd;
102806 u8 internal_flags;
102807 u8 flags;
102808-};
102809+} __do_const;
102810
102811 int __genl_register_family(struct genl_family *family);
102812
102813diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
102814index 0f712c0..cd762c4 100644
102815--- a/include/net/gro_cells.h
102816+++ b/include/net/gro_cells.h
102817@@ -27,7 +27,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
102818 cell = this_cpu_ptr(gcells->cells);
102819
102820 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
102821- atomic_long_inc(&dev->rx_dropped);
102822+ atomic_long_inc_unchecked(&dev->rx_dropped);
102823 kfree_skb(skb);
102824 return;
102825 }
102826diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
102827index 0320bbb..938789c 100644
102828--- a/include/net/inet_connection_sock.h
102829+++ b/include/net/inet_connection_sock.h
102830@@ -63,7 +63,7 @@ struct inet_connection_sock_af_ops {
102831 int (*bind_conflict)(const struct sock *sk,
102832 const struct inet_bind_bucket *tb, bool relax);
102833 void (*mtu_reduced)(struct sock *sk);
102834-};
102835+} __do_const;
102836
102837 /** inet_connection_sock - INET connection oriented sock
102838 *
102839diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
102840index 47eb67b..0e733b2 100644
102841--- a/include/net/inet_sock.h
102842+++ b/include/net/inet_sock.h
102843@@ -43,7 +43,7 @@
102844 struct ip_options {
102845 __be32 faddr;
102846 __be32 nexthop;
102847- unsigned char optlen;
102848+ unsigned char optlen __intentional_overflow(0);
102849 unsigned char srr;
102850 unsigned char rr;
102851 unsigned char ts;
102852diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
102853index d5332dd..10a5c3c 100644
102854--- a/include/net/inetpeer.h
102855+++ b/include/net/inetpeer.h
102856@@ -48,7 +48,7 @@ struct inet_peer {
102857 */
102858 union {
102859 struct {
102860- atomic_t rid; /* Frag reception counter */
102861+ atomic_unchecked_t rid; /* Frag reception counter */
102862 };
102863 struct rcu_head rcu;
102864 struct inet_peer *gc_next;
102865diff --git a/include/net/ip.h b/include/net/ip.h
102866index d5fe9f2..8da10ed 100644
102867--- a/include/net/ip.h
102868+++ b/include/net/ip.h
102869@@ -319,7 +319,7 @@ static inline unsigned int ip_skb_dst_mtu(const struct sk_buff *skb)
102870 }
102871 }
102872
102873-u32 ip_idents_reserve(u32 hash, int segs);
102874+u32 ip_idents_reserve(u32 hash, int segs) __intentional_overflow(-1);
102875 void __ip_select_ident(struct net *net, struct iphdr *iph, int segs);
102876
102877 static inline void ip_select_ident_segs(struct net *net, struct sk_buff *skb,
102878diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
102879index 5fa643b..d871e20 100644
102880--- a/include/net/ip_fib.h
102881+++ b/include/net/ip_fib.h
102882@@ -170,7 +170,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
102883
102884 #define FIB_RES_SADDR(net, res) \
102885 ((FIB_RES_NH(res).nh_saddr_genid == \
102886- atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
102887+ atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
102888 FIB_RES_NH(res).nh_saddr : \
102889 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
102890 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
102891diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
102892index 4e3731e..a242e28 100644
102893--- a/include/net/ip_vs.h
102894+++ b/include/net/ip_vs.h
102895@@ -551,7 +551,7 @@ struct ip_vs_conn {
102896 struct ip_vs_conn *control; /* Master control connection */
102897 atomic_t n_control; /* Number of controlled ones */
102898 struct ip_vs_dest *dest; /* real server */
102899- atomic_t in_pkts; /* incoming packet counter */
102900+ atomic_unchecked_t in_pkts; /* incoming packet counter */
102901
102902 /* Packet transmitter for different forwarding methods. If it
102903 * mangles the packet, it must return NF_DROP or better NF_STOLEN,
102904@@ -699,7 +699,7 @@ struct ip_vs_dest {
102905 __be16 port; /* port number of the server */
102906 union nf_inet_addr addr; /* IP address of the server */
102907 volatile unsigned int flags; /* dest status flags */
102908- atomic_t conn_flags; /* flags to copy to conn */
102909+ atomic_unchecked_t conn_flags; /* flags to copy to conn */
102910 atomic_t weight; /* server weight */
102911
102912 atomic_t refcnt; /* reference counter */
102913@@ -946,11 +946,11 @@ struct netns_ipvs {
102914 /* ip_vs_lblc */
102915 int sysctl_lblc_expiration;
102916 struct ctl_table_header *lblc_ctl_header;
102917- struct ctl_table *lblc_ctl_table;
102918+ ctl_table_no_const *lblc_ctl_table;
102919 /* ip_vs_lblcr */
102920 int sysctl_lblcr_expiration;
102921 struct ctl_table_header *lblcr_ctl_header;
102922- struct ctl_table *lblcr_ctl_table;
102923+ ctl_table_no_const *lblcr_ctl_table;
102924 /* ip_vs_est */
102925 struct list_head est_list; /* estimator list */
102926 spinlock_t est_lock;
102927diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
102928index 8d4f588..2e37ad2 100644
102929--- a/include/net/irda/ircomm_tty.h
102930+++ b/include/net/irda/ircomm_tty.h
102931@@ -33,6 +33,7 @@
102932 #include <linux/termios.h>
102933 #include <linux/timer.h>
102934 #include <linux/tty.h> /* struct tty_struct */
102935+#include <asm/local.h>
102936
102937 #include <net/irda/irias_object.h>
102938 #include <net/irda/ircomm_core.h>
102939diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
102940index 714cc9a..ea05f3e 100644
102941--- a/include/net/iucv/af_iucv.h
102942+++ b/include/net/iucv/af_iucv.h
102943@@ -149,7 +149,7 @@ struct iucv_skb_cb {
102944 struct iucv_sock_list {
102945 struct hlist_head head;
102946 rwlock_t lock;
102947- atomic_t autobind_name;
102948+ atomic_unchecked_t autobind_name;
102949 };
102950
102951 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
102952diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
102953index f3be818..bf46196 100644
102954--- a/include/net/llc_c_ac.h
102955+++ b/include/net/llc_c_ac.h
102956@@ -87,7 +87,7 @@
102957 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
102958 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
102959
102960-typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
102961+typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
102962
102963 int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
102964 int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
102965diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
102966index 3948cf1..83b28c4 100644
102967--- a/include/net/llc_c_ev.h
102968+++ b/include/net/llc_c_ev.h
102969@@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
102970 return (struct llc_conn_state_ev *)skb->cb;
102971 }
102972
102973-typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
102974-typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
102975+typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
102976+typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
102977
102978 int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
102979 int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
102980diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
102981index 48f3f89..0e92c50 100644
102982--- a/include/net/llc_c_st.h
102983+++ b/include/net/llc_c_st.h
102984@@ -37,7 +37,7 @@ struct llc_conn_state_trans {
102985 u8 next_state;
102986 const llc_conn_ev_qfyr_t *ev_qualifiers;
102987 const llc_conn_action_t *ev_actions;
102988-};
102989+} __do_const;
102990
102991 struct llc_conn_state {
102992 u8 current_state;
102993diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
102994index a61b98c..aade1eb 100644
102995--- a/include/net/llc_s_ac.h
102996+++ b/include/net/llc_s_ac.h
102997@@ -23,7 +23,7 @@
102998 #define SAP_ACT_TEST_IND 9
102999
103000 /* All action functions must look like this */
103001-typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
103002+typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
103003
103004 int llc_sap_action_unitdata_ind(struct llc_sap *sap, struct sk_buff *skb);
103005 int llc_sap_action_send_ui(struct llc_sap *sap, struct sk_buff *skb);
103006diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
103007index c4359e2..76dbc4a 100644
103008--- a/include/net/llc_s_st.h
103009+++ b/include/net/llc_s_st.h
103010@@ -20,7 +20,7 @@ struct llc_sap_state_trans {
103011 llc_sap_ev_t ev;
103012 u8 next_state;
103013 const llc_sap_action_t *ev_actions;
103014-};
103015+} __do_const;
103016
103017 struct llc_sap_state {
103018 u8 curr_state;
103019diff --git a/include/net/mac80211.h b/include/net/mac80211.h
103020index 6b1077c..7b72f67 100644
103021--- a/include/net/mac80211.h
103022+++ b/include/net/mac80211.h
103023@@ -5106,7 +5106,7 @@ struct ieee80211_tx_rate_control {
103024 struct sk_buff *skb;
103025 struct ieee80211_tx_rate reported_rate;
103026 bool rts, short_preamble;
103027- u8 max_rate_idx;
103028+ s8 max_rate_idx;
103029 u32 rate_idx_mask;
103030 u8 *rate_idx_mcs_mask;
103031 bool bss;
103032@@ -5143,7 +5143,7 @@ struct rate_control_ops {
103033 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
103034
103035 u32 (*get_expected_throughput)(void *priv_sta);
103036-};
103037+} __do_const;
103038
103039 static inline int rate_supported(struct ieee80211_sta *sta,
103040 enum ieee80211_band band,
103041diff --git a/include/net/neighbour.h b/include/net/neighbour.h
103042index bd33e66..6508d00 100644
103043--- a/include/net/neighbour.h
103044+++ b/include/net/neighbour.h
103045@@ -162,7 +162,7 @@ struct neigh_ops {
103046 void (*error_report)(struct neighbour *, struct sk_buff *);
103047 int (*output)(struct neighbour *, struct sk_buff *);
103048 int (*connected_output)(struct neighbour *, struct sk_buff *);
103049-};
103050+} __do_const;
103051
103052 struct pneigh_entry {
103053 struct pneigh_entry *next;
103054@@ -216,7 +216,7 @@ struct neigh_table {
103055 struct neigh_statistics __percpu *stats;
103056 struct neigh_hash_table __rcu *nht;
103057 struct pneigh_entry **phash_buckets;
103058-};
103059+} __randomize_layout;
103060
103061 enum {
103062 NEIGH_ARP_TABLE = 0,
103063diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
103064index e951453..0685f5b 100644
103065--- a/include/net/net_namespace.h
103066+++ b/include/net/net_namespace.h
103067@@ -53,7 +53,7 @@ struct net {
103068 */
103069 spinlock_t rules_mod_lock;
103070
103071- atomic64_t cookie_gen;
103072+ atomic64_unchecked_t cookie_gen;
103073
103074 struct list_head list; /* list of network namespaces */
103075 struct list_head cleanup_list; /* namespaces on death row */
103076@@ -135,8 +135,8 @@ struct net {
103077 struct netns_mpls mpls;
103078 #endif
103079 struct sock *diag_nlsk;
103080- atomic_t fnhe_genid;
103081-};
103082+ atomic_unchecked_t fnhe_genid;
103083+} __randomize_layout;
103084
103085 #include <linux/seq_file_net.h>
103086
103087@@ -271,7 +271,11 @@ static inline struct net *read_pnet(const possible_net_t *pnet)
103088 #define __net_init __init
103089 #define __net_exit __exit_refok
103090 #define __net_initdata __initdata
103091+#ifdef CONSTIFY_PLUGIN
103092 #define __net_initconst __initconst
103093+#else
103094+#define __net_initconst __initdata
103095+#endif
103096 #endif
103097
103098 int peernet2id_alloc(struct net *net, struct net *peer);
103099@@ -286,7 +290,7 @@ struct pernet_operations {
103100 void (*exit_batch)(struct list_head *net_exit_list);
103101 int *id;
103102 size_t size;
103103-};
103104+} __do_const;
103105
103106 /*
103107 * Use these carefully. If you implement a network device and it
103108@@ -334,12 +338,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
103109
103110 static inline int rt_genid_ipv4(struct net *net)
103111 {
103112- return atomic_read(&net->ipv4.rt_genid);
103113+ return atomic_read_unchecked(&net->ipv4.rt_genid);
103114 }
103115
103116 static inline void rt_genid_bump_ipv4(struct net *net)
103117 {
103118- atomic_inc(&net->ipv4.rt_genid);
103119+ atomic_inc_unchecked(&net->ipv4.rt_genid);
103120 }
103121
103122 extern void (*__fib6_flush_trees)(struct net *net);
103123@@ -366,12 +370,12 @@ static inline void rt_genid_bump_all(struct net *net)
103124
103125 static inline int fnhe_genid(struct net *net)
103126 {
103127- return atomic_read(&net->fnhe_genid);
103128+ return atomic_read_unchecked(&net->fnhe_genid);
103129 }
103130
103131 static inline void fnhe_genid_bump(struct net *net)
103132 {
103133- atomic_inc(&net->fnhe_genid);
103134+ atomic_inc_unchecked(&net->fnhe_genid);
103135 }
103136
103137 #endif /* __NET_NET_NAMESPACE_H */
103138diff --git a/include/net/netlink.h b/include/net/netlink.h
103139index 2a5dbcc..8243656 100644
103140--- a/include/net/netlink.h
103141+++ b/include/net/netlink.h
103142@@ -521,7 +521,7 @@ static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
103143 {
103144 if (mark) {
103145 WARN_ON((unsigned char *) mark < skb->data);
103146- skb_trim(skb, (unsigned char *) mark - skb->data);
103147+ skb_trim(skb, (const unsigned char *) mark - skb->data);
103148 }
103149 }
103150
103151diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
103152index 723b61c..4386367 100644
103153--- a/include/net/netns/conntrack.h
103154+++ b/include/net/netns/conntrack.h
103155@@ -14,10 +14,10 @@ struct nf_conntrack_ecache;
103156 struct nf_proto_net {
103157 #ifdef CONFIG_SYSCTL
103158 struct ctl_table_header *ctl_table_header;
103159- struct ctl_table *ctl_table;
103160+ ctl_table_no_const *ctl_table;
103161 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
103162 struct ctl_table_header *ctl_compat_header;
103163- struct ctl_table *ctl_compat_table;
103164+ ctl_table_no_const *ctl_compat_table;
103165 #endif
103166 #endif
103167 unsigned int users;
103168@@ -60,7 +60,7 @@ struct nf_ip_net {
103169 struct nf_icmp_net icmpv6;
103170 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
103171 struct ctl_table_header *ctl_table_header;
103172- struct ctl_table *ctl_table;
103173+ ctl_table_no_const *ctl_table;
103174 #endif
103175 };
103176
103177diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
103178index c68926b..106c147 100644
103179--- a/include/net/netns/ipv4.h
103180+++ b/include/net/netns/ipv4.h
103181@@ -93,7 +93,7 @@ struct netns_ipv4 {
103182
103183 struct ping_group_range ping_group_range;
103184
103185- atomic_t dev_addr_genid;
103186+ atomic_unchecked_t dev_addr_genid;
103187
103188 #ifdef CONFIG_SYSCTL
103189 unsigned long *sysctl_local_reserved_ports;
103190@@ -107,6 +107,6 @@ struct netns_ipv4 {
103191 struct fib_rules_ops *mr_rules_ops;
103192 #endif
103193 #endif
103194- atomic_t rt_genid;
103195+ atomic_unchecked_t rt_genid;
103196 };
103197 #endif
103198diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
103199index 8d93544..05c3e89 100644
103200--- a/include/net/netns/ipv6.h
103201+++ b/include/net/netns/ipv6.h
103202@@ -79,8 +79,8 @@ struct netns_ipv6 {
103203 struct fib_rules_ops *mr6_rules_ops;
103204 #endif
103205 #endif
103206- atomic_t dev_addr_genid;
103207- atomic_t fib6_sernum;
103208+ atomic_unchecked_t dev_addr_genid;
103209+ atomic_unchecked_t fib6_sernum;
103210 };
103211
103212 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
103213diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h
103214index 730d82a..045f2c4 100644
103215--- a/include/net/netns/xfrm.h
103216+++ b/include/net/netns/xfrm.h
103217@@ -78,7 +78,7 @@ struct netns_xfrm {
103218
103219 /* flow cache part */
103220 struct flow_cache flow_cache_global;
103221- atomic_t flow_cache_genid;
103222+ atomic_unchecked_t flow_cache_genid;
103223 struct list_head flow_cache_gc_list;
103224 spinlock_t flow_cache_gc_lock;
103225 struct work_struct flow_cache_gc_work;
103226diff --git a/include/net/ping.h b/include/net/ping.h
103227index ac80cb4..ec1ed09 100644
103228--- a/include/net/ping.h
103229+++ b/include/net/ping.h
103230@@ -54,7 +54,7 @@ struct ping_iter_state {
103231
103232 extern struct proto ping_prot;
103233 #if IS_ENABLED(CONFIG_IPV6)
103234-extern struct pingv6_ops pingv6_ops;
103235+extern struct pingv6_ops *pingv6_ops;
103236 #endif
103237
103238 struct pingfakehdr {
103239diff --git a/include/net/protocol.h b/include/net/protocol.h
103240index d6fcc1f..ca277058 100644
103241--- a/include/net/protocol.h
103242+++ b/include/net/protocol.h
103243@@ -49,7 +49,7 @@ struct net_protocol {
103244 * socket lookup?
103245 */
103246 icmp_strict_tag_validation:1;
103247-};
103248+} __do_const;
103249
103250 #if IS_ENABLED(CONFIG_IPV6)
103251 struct inet6_protocol {
103252@@ -62,7 +62,7 @@ struct inet6_protocol {
103253 u8 type, u8 code, int offset,
103254 __be32 info);
103255 unsigned int flags; /* INET6_PROTO_xxx */
103256-};
103257+} __do_const;
103258
103259 #define INET6_PROTO_NOPOLICY 0x1
103260 #define INET6_PROTO_FINAL 0x2
103261diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
103262index 343d922..7959cde 100644
103263--- a/include/net/rtnetlink.h
103264+++ b/include/net/rtnetlink.h
103265@@ -95,7 +95,7 @@ struct rtnl_link_ops {
103266 const struct net_device *dev,
103267 const struct net_device *slave_dev);
103268 struct net *(*get_link_net)(const struct net_device *dev);
103269-};
103270+} __do_const;
103271
103272 int __rtnl_link_register(struct rtnl_link_ops *ops);
103273 void __rtnl_link_unregister(struct rtnl_link_ops *ops);
103274diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h
103275index 4a5b9a3..ca27d73 100644
103276--- a/include/net/sctp/checksum.h
103277+++ b/include/net/sctp/checksum.h
103278@@ -61,8 +61,8 @@ static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
103279 unsigned int offset)
103280 {
103281 struct sctphdr *sh = sctp_hdr(skb);
103282- __le32 ret, old = sh->checksum;
103283- const struct skb_checksum_ops ops = {
103284+ __le32 ret, old = sh->checksum;
103285+ static const struct skb_checksum_ops ops = {
103286 .update = sctp_csum_update,
103287 .combine = sctp_csum_combine,
103288 };
103289diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
103290index 487ef34..d457f98 100644
103291--- a/include/net/sctp/sm.h
103292+++ b/include/net/sctp/sm.h
103293@@ -80,7 +80,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
103294 typedef struct {
103295 sctp_state_fn_t *fn;
103296 const char *name;
103297-} sctp_sm_table_entry_t;
103298+} __do_const sctp_sm_table_entry_t;
103299
103300 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
103301 * currently in use.
103302@@ -292,7 +292,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
103303 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
103304
103305 /* Extern declarations for major data structures. */
103306-extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
103307+extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
103308
103309
103310 /* Get the size of a DATA chunk payload. */
103311diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
103312index 495c87e..5b327ff 100644
103313--- a/include/net/sctp/structs.h
103314+++ b/include/net/sctp/structs.h
103315@@ -513,7 +513,7 @@ struct sctp_pf {
103316 void (*to_sk_saddr)(union sctp_addr *, struct sock *sk);
103317 void (*to_sk_daddr)(union sctp_addr *, struct sock *sk);
103318 struct sctp_af *af;
103319-};
103320+} __do_const;
103321
103322
103323 /* Structure to track chunk fragments that have been acked, but peer
103324diff --git a/include/net/sock.h b/include/net/sock.h
103325index f21f070..29ac73e 100644
103326--- a/include/net/sock.h
103327+++ b/include/net/sock.h
103328@@ -198,7 +198,7 @@ struct sock_common {
103329 struct in6_addr skc_v6_rcv_saddr;
103330 #endif
103331
103332- atomic64_t skc_cookie;
103333+ atomic64_unchecked_t skc_cookie;
103334
103335 /*
103336 * fields between dontcopy_begin/dontcopy_end
103337@@ -364,7 +364,7 @@ struct sock {
103338 unsigned int sk_napi_id;
103339 unsigned int sk_ll_usec;
103340 #endif
103341- atomic_t sk_drops;
103342+ atomic_unchecked_t sk_drops;
103343 int sk_rcvbuf;
103344
103345 struct sk_filter __rcu *sk_filter;
103346@@ -1038,7 +1038,7 @@ struct proto {
103347 void (*destroy_cgroup)(struct mem_cgroup *memcg);
103348 struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg);
103349 #endif
103350-};
103351+} __randomize_layout;
103352
103353 /*
103354 * Bits in struct cg_proto.flags
103355@@ -1211,7 +1211,7 @@ static inline void memcg_memory_allocated_sub(struct cg_proto *prot,
103356 page_counter_uncharge(&prot->memory_allocated, amt);
103357 }
103358
103359-static inline long
103360+static inline long __intentional_overflow(-1)
103361 sk_memory_allocated(const struct sock *sk)
103362 {
103363 struct proto *prot = sk->sk_prot;
103364@@ -1776,7 +1776,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
103365 }
103366
103367 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
103368- struct iov_iter *from, char *to,
103369+ struct iov_iter *from, unsigned char *to,
103370 int copy, int offset)
103371 {
103372 if (skb->ip_summed == CHECKSUM_NONE) {
103373@@ -2023,7 +2023,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
103374 }
103375 }
103376
103377-struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
103378+struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
103379 bool force_schedule);
103380
103381 /**
103382@@ -2099,7 +2099,7 @@ struct sock_skb_cb {
103383 static inline void
103384 sock_skb_set_dropcount(const struct sock *sk, struct sk_buff *skb)
103385 {
103386- SOCK_SKB_CB(skb)->dropcount = atomic_read(&sk->sk_drops);
103387+ SOCK_SKB_CB(skb)->dropcount = atomic_read_unchecked(&sk->sk_drops);
103388 }
103389
103390 void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
103391diff --git a/include/net/tcp.h b/include/net/tcp.h
103392index 950cfec..0bf9d85 100644
103393--- a/include/net/tcp.h
103394+++ b/include/net/tcp.h
103395@@ -546,7 +546,7 @@ void tcp_retransmit_timer(struct sock *sk);
103396 void tcp_xmit_retransmit_queue(struct sock *);
103397 void tcp_simple_retransmit(struct sock *);
103398 int tcp_trim_head(struct sock *, struct sk_buff *, u32);
103399-int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int, gfp_t);
103400+int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int, gfp_t) __intentional_overflow(3);
103401
103402 void tcp_send_probe0(struct sock *);
103403 void tcp_send_partial(struct sock *);
103404@@ -724,8 +724,8 @@ static inline u32 tcp_skb_timestamp(const struct sk_buff *skb)
103405 * If this grows please adjust skbuff.h:skbuff->cb[xxx] size appropriately.
103406 */
103407 struct tcp_skb_cb {
103408- __u32 seq; /* Starting sequence number */
103409- __u32 end_seq; /* SEQ + FIN + SYN + datalen */
103410+ __u32 seq __intentional_overflow(-1); /* Starting sequence number */
103411+ __u32 end_seq __intentional_overflow(-1); /* SEQ + FIN + SYN + datalen */
103412 union {
103413 /* Note : tcp_tw_isn is used in input path only
103414 * (isn chosen by tcp_timewait_state_process())
103415@@ -753,7 +753,7 @@ struct tcp_skb_cb {
103416
103417 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
103418 /* 1 byte hole */
103419- __u32 ack_seq; /* Sequence number ACK'd */
103420+ __u32 ack_seq __intentional_overflow(-1); /* Sequence number ACK'd */
103421 union {
103422 struct inet_skb_parm h4;
103423 #if IS_ENABLED(CONFIG_IPV6)
103424diff --git a/include/net/xfrm.h b/include/net/xfrm.h
103425index f0ee97e..73e2b5a 100644
103426--- a/include/net/xfrm.h
103427+++ b/include/net/xfrm.h
103428@@ -284,7 +284,6 @@ struct xfrm_dst;
103429 struct xfrm_policy_afinfo {
103430 unsigned short family;
103431 struct dst_ops *dst_ops;
103432- void (*garbage_collect)(struct net *net);
103433 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
103434 const xfrm_address_t *saddr,
103435 const xfrm_address_t *daddr);
103436@@ -302,7 +301,7 @@ struct xfrm_policy_afinfo {
103437 struct net_device *dev,
103438 const struct flowi *fl);
103439 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
103440-};
103441+} __do_const;
103442
103443 int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
103444 int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
103445@@ -341,7 +340,7 @@ struct xfrm_state_afinfo {
103446 int (*transport_finish)(struct sk_buff *skb,
103447 int async);
103448 void (*local_error)(struct sk_buff *skb, u32 mtu);
103449-};
103450+} __do_const;
103451
103452 int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
103453 int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
103454@@ -436,7 +435,7 @@ struct xfrm_mode {
103455 struct module *owner;
103456 unsigned int encap;
103457 int flags;
103458-};
103459+} __do_const;
103460
103461 /* Flags for xfrm_mode. */
103462 enum {
103463@@ -531,7 +530,7 @@ struct xfrm_policy {
103464 struct timer_list timer;
103465
103466 struct flow_cache_object flo;
103467- atomic_t genid;
103468+ atomic_unchecked_t genid;
103469 u32 priority;
103470 u32 index;
103471 struct xfrm_mark mark;
103472@@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
103473 }
103474
103475 void xfrm_garbage_collect(struct net *net);
103476+void xfrm_garbage_collect_deferred(struct net *net);
103477
103478 #else
103479
103480@@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
103481 static inline void xfrm_garbage_collect(struct net *net)
103482 {
103483 }
103484+static inline void xfrm_garbage_collect_deferred(struct net *net)
103485+{
103486+}
103487 #endif
103488
103489 static __inline__
103490diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
103491index 036bd27..c0d7f17 100644
103492--- a/include/rdma/iw_cm.h
103493+++ b/include/rdma/iw_cm.h
103494@@ -123,7 +123,7 @@ struct iw_cm_verbs {
103495 int backlog);
103496
103497 int (*destroy_listen)(struct iw_cm_id *cm_id);
103498-};
103499+} __no_const;
103500
103501 /**
103502 * iw_create_cm_id - Create an IW CM identifier.
103503diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
103504index 93d14da..734b3d8 100644
103505--- a/include/scsi/libfc.h
103506+++ b/include/scsi/libfc.h
103507@@ -771,6 +771,7 @@ struct libfc_function_template {
103508 */
103509 void (*disc_stop_final) (struct fc_lport *);
103510 };
103511+typedef struct libfc_function_template __no_const libfc_function_template_no_const;
103512
103513 /**
103514 * struct fc_disc - Discovery context
103515@@ -875,7 +876,7 @@ struct fc_lport {
103516 struct fc_vport *vport;
103517
103518 /* Operational Information */
103519- struct libfc_function_template tt;
103520+ libfc_function_template_no_const tt;
103521 u8 link_up;
103522 u8 qfull;
103523 enum fc_lport_state state;
103524diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
103525index ae84b22..7954097 100644
103526--- a/include/scsi/scsi_device.h
103527+++ b/include/scsi/scsi_device.h
103528@@ -185,9 +185,9 @@ struct scsi_device {
103529 unsigned int max_device_blocked; /* what device_blocked counts down from */
103530 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
103531
103532- atomic_t iorequest_cnt;
103533- atomic_t iodone_cnt;
103534- atomic_t ioerr_cnt;
103535+ atomic_unchecked_t iorequest_cnt;
103536+ atomic_unchecked_t iodone_cnt;
103537+ atomic_unchecked_t ioerr_cnt;
103538
103539 struct device sdev_gendev,
103540 sdev_dev;
103541diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h
103542index 891a658..fcd68df 100644
103543--- a/include/scsi/scsi_driver.h
103544+++ b/include/scsi/scsi_driver.h
103545@@ -14,7 +14,7 @@ struct scsi_driver {
103546 void (*rescan)(struct device *);
103547 int (*init_command)(struct scsi_cmnd *);
103548 void (*uninit_command)(struct scsi_cmnd *);
103549- int (*done)(struct scsi_cmnd *);
103550+ unsigned int (*done)(struct scsi_cmnd *);
103551 int (*eh_action)(struct scsi_cmnd *, int);
103552 };
103553 #define to_scsi_driver(drv) \
103554diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
103555index 784bc2c..855a04c 100644
103556--- a/include/scsi/scsi_transport_fc.h
103557+++ b/include/scsi/scsi_transport_fc.h
103558@@ -757,7 +757,8 @@ struct fc_function_template {
103559 unsigned long show_host_system_hostname:1;
103560
103561 unsigned long disable_target_scan:1;
103562-};
103563+} __do_const;
103564+typedef struct fc_function_template __no_const fc_function_template_no_const;
103565
103566
103567 /**
103568diff --git a/include/scsi/sg.h b/include/scsi/sg.h
103569index 3afec70..b196b43 100644
103570--- a/include/scsi/sg.h
103571+++ b/include/scsi/sg.h
103572@@ -52,7 +52,7 @@ typedef struct sg_io_hdr
103573 or scatter gather list */
103574 unsigned char __user *cmdp; /* [i], [*i] points to command to perform */
103575 void __user *sbp; /* [i], [*o] points to sense_buffer memory */
103576- unsigned int timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
103577+ unsigned int timeout __intentional_overflow(-1); /* [i] MAX_UINT->no timeout (unit: millisec) */
103578 unsigned int flags; /* [i] 0 -> default, see SG_FLAG... */
103579 int pack_id; /* [i->o] unused internally (normally) */
103580 void __user * usr_ptr; /* [i->o] unused internally */
103581diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
103582index fa1d055..3647940 100644
103583--- a/include/sound/compress_driver.h
103584+++ b/include/sound/compress_driver.h
103585@@ -130,7 +130,7 @@ struct snd_compr_ops {
103586 struct snd_compr_caps *caps);
103587 int (*get_codec_caps) (struct snd_compr_stream *stream,
103588 struct snd_compr_codec_caps *codec);
103589-};
103590+} __no_const;
103591
103592 /**
103593 * struct snd_compr: Compressed device
103594diff --git a/include/sound/soc.h b/include/sound/soc.h
103595index 93df8bf..c84577b 100644
103596--- a/include/sound/soc.h
103597+++ b/include/sound/soc.h
103598@@ -883,7 +883,7 @@ struct snd_soc_codec_driver {
103599 enum snd_soc_dapm_type, int);
103600
103601 bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */
103602-};
103603+} __do_const;
103604
103605 /* SoC platform interface */
103606 struct snd_soc_platform_driver {
103607@@ -910,7 +910,7 @@ struct snd_soc_platform_driver {
103608 const struct snd_compr_ops *compr_ops;
103609
103610 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
103611-};
103612+} __do_const;
103613
103614 struct snd_soc_dai_link_component {
103615 const char *name;
103616diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
103617index 17ae2d6..2c06382 100644
103618--- a/include/target/target_core_base.h
103619+++ b/include/target/target_core_base.h
103620@@ -751,7 +751,7 @@ struct se_device {
103621 atomic_long_t write_bytes;
103622 /* Active commands on this virtual SE device */
103623 atomic_t simple_cmds;
103624- atomic_t dev_ordered_id;
103625+ atomic_unchecked_t dev_ordered_id;
103626 atomic_t dev_ordered_sync;
103627 atomic_t dev_qf_count;
103628 u32 export_count;
103629diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
103630new file mode 100644
103631index 0000000..fb634b7
103632--- /dev/null
103633+++ b/include/trace/events/fs.h
103634@@ -0,0 +1,53 @@
103635+#undef TRACE_SYSTEM
103636+#define TRACE_SYSTEM fs
103637+
103638+#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
103639+#define _TRACE_FS_H
103640+
103641+#include <linux/fs.h>
103642+#include <linux/tracepoint.h>
103643+
103644+TRACE_EVENT(do_sys_open,
103645+
103646+ TP_PROTO(const char *filename, int flags, int mode),
103647+
103648+ TP_ARGS(filename, flags, mode),
103649+
103650+ TP_STRUCT__entry(
103651+ __string( filename, filename )
103652+ __field( int, flags )
103653+ __field( int, mode )
103654+ ),
103655+
103656+ TP_fast_assign(
103657+ __assign_str(filename, filename);
103658+ __entry->flags = flags;
103659+ __entry->mode = mode;
103660+ ),
103661+
103662+ TP_printk("\"%s\" %x %o",
103663+ __get_str(filename), __entry->flags, __entry->mode)
103664+);
103665+
103666+TRACE_EVENT(open_exec,
103667+
103668+ TP_PROTO(const char *filename),
103669+
103670+ TP_ARGS(filename),
103671+
103672+ TP_STRUCT__entry(
103673+ __string( filename, filename )
103674+ ),
103675+
103676+ TP_fast_assign(
103677+ __assign_str(filename, filename);
103678+ ),
103679+
103680+ TP_printk("\"%s\"",
103681+ __get_str(filename))
103682+);
103683+
103684+#endif /* _TRACE_FS_H */
103685+
103686+/* This part must be outside protection */
103687+#include <trace/define_trace.h>
103688diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
103689index ff8f6c0..6b6bae3 100644
103690--- a/include/trace/events/irq.h
103691+++ b/include/trace/events/irq.h
103692@@ -51,7 +51,7 @@ SOFTIRQ_NAME_LIST
103693 */
103694 TRACE_EVENT(irq_handler_entry,
103695
103696- TP_PROTO(int irq, struct irqaction *action),
103697+ TP_PROTO(int irq, const struct irqaction *action),
103698
103699 TP_ARGS(irq, action),
103700
103701@@ -81,7 +81,7 @@ TRACE_EVENT(irq_handler_entry,
103702 */
103703 TRACE_EVENT(irq_handler_exit,
103704
103705- TP_PROTO(int irq, struct irqaction *action, int ret),
103706+ TP_PROTO(int irq, const struct irqaction *action, int ret),
103707
103708 TP_ARGS(irq, action, ret),
103709
103710diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
103711index db809b7..05a44aa 100644
103712--- a/include/uapi/drm/i915_drm.h
103713+++ b/include/uapi/drm/i915_drm.h
103714@@ -354,6 +354,7 @@ typedef struct drm_i915_irq_wait {
103715 #define I915_PARAM_REVISION 32
103716 #define I915_PARAM_SUBSLICE_TOTAL 33
103717 #define I915_PARAM_EU_TOTAL 34
103718+#define I915_PARAM_HAS_LEGACY_CONTEXT 35
103719
103720 typedef struct drm_i915_getparam {
103721 int param;
103722diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
103723index 7caf44c..23c6f27 100644
103724--- a/include/uapi/linux/a.out.h
103725+++ b/include/uapi/linux/a.out.h
103726@@ -39,6 +39,14 @@ enum machine_type {
103727 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
103728 };
103729
103730+/* Constants for the N_FLAGS field */
103731+#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
103732+#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
103733+#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
103734+#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
103735+/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
103736+#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
103737+
103738 #if !defined (N_MAGIC)
103739 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
103740 #endif
103741diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
103742index 22b6ad3..aeba37e 100644
103743--- a/include/uapi/linux/bcache.h
103744+++ b/include/uapi/linux/bcache.h
103745@@ -5,6 +5,7 @@
103746 * Bcache on disk data structures
103747 */
103748
103749+#include <linux/compiler.h>
103750 #include <asm/types.h>
103751
103752 #define BITMASK(name, type, field, offset, size) \
103753@@ -20,8 +21,8 @@ static inline void SET_##name(type *k, __u64 v) \
103754 /* Btree keys - all units are in sectors */
103755
103756 struct bkey {
103757- __u64 high;
103758- __u64 low;
103759+ __u64 high __intentional_overflow(-1);
103760+ __u64 low __intentional_overflow(-1);
103761 __u64 ptr[];
103762 };
103763
103764diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
103765index d876736..ccce5c0 100644
103766--- a/include/uapi/linux/byteorder/little_endian.h
103767+++ b/include/uapi/linux/byteorder/little_endian.h
103768@@ -42,51 +42,51 @@
103769
103770 static inline __le64 __cpu_to_le64p(const __u64 *p)
103771 {
103772- return (__force __le64)*p;
103773+ return (__force const __le64)*p;
103774 }
103775-static inline __u64 __le64_to_cpup(const __le64 *p)
103776+static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
103777 {
103778- return (__force __u64)*p;
103779+ return (__force const __u64)*p;
103780 }
103781 static inline __le32 __cpu_to_le32p(const __u32 *p)
103782 {
103783- return (__force __le32)*p;
103784+ return (__force const __le32)*p;
103785 }
103786 static inline __u32 __le32_to_cpup(const __le32 *p)
103787 {
103788- return (__force __u32)*p;
103789+ return (__force const __u32)*p;
103790 }
103791 static inline __le16 __cpu_to_le16p(const __u16 *p)
103792 {
103793- return (__force __le16)*p;
103794+ return (__force const __le16)*p;
103795 }
103796 static inline __u16 __le16_to_cpup(const __le16 *p)
103797 {
103798- return (__force __u16)*p;
103799+ return (__force const __u16)*p;
103800 }
103801 static inline __be64 __cpu_to_be64p(const __u64 *p)
103802 {
103803- return (__force __be64)__swab64p(p);
103804+ return (__force const __be64)__swab64p(p);
103805 }
103806 static inline __u64 __be64_to_cpup(const __be64 *p)
103807 {
103808- return __swab64p((__u64 *)p);
103809+ return __swab64p((const __u64 *)p);
103810 }
103811 static inline __be32 __cpu_to_be32p(const __u32 *p)
103812 {
103813- return (__force __be32)__swab32p(p);
103814+ return (__force const __be32)__swab32p(p);
103815 }
103816-static inline __u32 __be32_to_cpup(const __be32 *p)
103817+static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
103818 {
103819- return __swab32p((__u32 *)p);
103820+ return __swab32p((const __u32 *)p);
103821 }
103822 static inline __be16 __cpu_to_be16p(const __u16 *p)
103823 {
103824- return (__force __be16)__swab16p(p);
103825+ return (__force const __be16)__swab16p(p);
103826 }
103827 static inline __u16 __be16_to_cpup(const __be16 *p)
103828 {
103829- return __swab16p((__u16 *)p);
103830+ return __swab16p((const __u16 *)p);
103831 }
103832 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
103833 #define __le64_to_cpus(x) do { (void)(x); } while (0)
103834diff --git a/include/uapi/linux/connector.h b/include/uapi/linux/connector.h
103835index 4cb2835..cfbc4e2 100644
103836--- a/include/uapi/linux/connector.h
103837+++ b/include/uapi/linux/connector.h
103838@@ -69,7 +69,7 @@ struct cb_id {
103839 struct cn_msg {
103840 struct cb_id id;
103841
103842- __u32 seq;
103843+ __u32 seq __intentional_overflow(-1);
103844 __u32 ack;
103845
103846 __u16 len; /* Length of the following data */
103847diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
103848index 71e1d0e..6cc9caf 100644
103849--- a/include/uapi/linux/elf.h
103850+++ b/include/uapi/linux/elf.h
103851@@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
103852 #define PT_GNU_EH_FRAME 0x6474e550
103853
103854 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
103855+#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
103856+
103857+#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
103858+
103859+/* Constants for the e_flags field */
103860+#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
103861+#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
103862+#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
103863+#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
103864+/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
103865+#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
103866
103867 /*
103868 * Extended Numbering
103869@@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
103870 #define DT_DEBUG 21
103871 #define DT_TEXTREL 22
103872 #define DT_JMPREL 23
103873+#define DT_FLAGS 30
103874+ #define DF_TEXTREL 0x00000004
103875 #define DT_ENCODING 32
103876 #define OLD_DT_LOOS 0x60000000
103877 #define DT_LOOS 0x6000000d
103878@@ -240,6 +253,19 @@ typedef struct elf64_hdr {
103879 #define PF_W 0x2
103880 #define PF_X 0x1
103881
103882+#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
103883+#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
103884+#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
103885+#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
103886+#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
103887+#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
103888+/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
103889+/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
103890+#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
103891+#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
103892+#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
103893+#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
103894+
103895 typedef struct elf32_phdr{
103896 Elf32_Word p_type;
103897 Elf32_Off p_offset;
103898@@ -332,6 +358,8 @@ typedef struct elf64_shdr {
103899 #define EI_OSABI 7
103900 #define EI_PAD 8
103901
103902+#define EI_PAX 14
103903+
103904 #define ELFMAG0 0x7f /* EI_MAG */
103905 #define ELFMAG1 'E'
103906 #define ELFMAG2 'L'
103907diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
103908index aa169c4..6a2771d 100644
103909--- a/include/uapi/linux/personality.h
103910+++ b/include/uapi/linux/personality.h
103911@@ -30,6 +30,7 @@ enum {
103912 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
103913 ADDR_NO_RANDOMIZE | \
103914 ADDR_COMPAT_LAYOUT | \
103915+ ADDR_LIMIT_3GB | \
103916 MMAP_PAGE_ZERO)
103917
103918 /*
103919diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
103920index 7530e74..e714828 100644
103921--- a/include/uapi/linux/screen_info.h
103922+++ b/include/uapi/linux/screen_info.h
103923@@ -43,7 +43,8 @@ struct screen_info {
103924 __u16 pages; /* 0x32 */
103925 __u16 vesa_attributes; /* 0x34 */
103926 __u32 capabilities; /* 0x36 */
103927- __u8 _reserved[6]; /* 0x3a */
103928+ __u16 vesapm_size; /* 0x3a */
103929+ __u8 _reserved[4]; /* 0x3c */
103930 } __attribute__((packed));
103931
103932 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
103933diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
103934index 0e011eb..82681b1 100644
103935--- a/include/uapi/linux/swab.h
103936+++ b/include/uapi/linux/swab.h
103937@@ -43,7 +43,7 @@
103938 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
103939 */
103940
103941-static inline __attribute_const__ __u16 __fswab16(__u16 val)
103942+static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
103943 {
103944 #ifdef __HAVE_BUILTIN_BSWAP16__
103945 return __builtin_bswap16(val);
103946@@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
103947 #endif
103948 }
103949
103950-static inline __attribute_const__ __u32 __fswab32(__u32 val)
103951+static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
103952 {
103953 #ifdef __HAVE_BUILTIN_BSWAP32__
103954 return __builtin_bswap32(val);
103955@@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
103956 #endif
103957 }
103958
103959-static inline __attribute_const__ __u64 __fswab64(__u64 val)
103960+static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
103961 {
103962 #ifdef __HAVE_BUILTIN_BSWAP64__
103963 return __builtin_bswap64(val);
103964diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
103965index 1590c49..5eab462 100644
103966--- a/include/uapi/linux/xattr.h
103967+++ b/include/uapi/linux/xattr.h
103968@@ -73,5 +73,9 @@
103969 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
103970 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
103971
103972+/* User namespace */
103973+#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
103974+#define XATTR_PAX_FLAGS_SUFFIX "flags"
103975+#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
103976
103977 #endif /* _UAPI_LINUX_XATTR_H */
103978diff --git a/include/video/udlfb.h b/include/video/udlfb.h
103979index f9466fa..f4e2b81 100644
103980--- a/include/video/udlfb.h
103981+++ b/include/video/udlfb.h
103982@@ -53,10 +53,10 @@ struct dlfb_data {
103983 u32 pseudo_palette[256];
103984 int blank_mode; /*one of FB_BLANK_ */
103985 /* blit-only rendering path metrics, exposed through sysfs */
103986- atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
103987- atomic_t bytes_identical; /* saved effort with backbuffer comparison */
103988- atomic_t bytes_sent; /* to usb, after compression including overhead */
103989- atomic_t cpu_kcycles_used; /* transpired during pixel processing */
103990+ atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
103991+ atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
103992+ atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
103993+ atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
103994 };
103995
103996 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
103997diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
103998index 30f5362..8ed8ac9 100644
103999--- a/include/video/uvesafb.h
104000+++ b/include/video/uvesafb.h
104001@@ -122,6 +122,7 @@ struct uvesafb_par {
104002 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
104003 u8 pmi_setpal; /* PMI for palette changes */
104004 u16 *pmi_base; /* protected mode interface location */
104005+ u8 *pmi_code; /* protected mode code location */
104006 void *pmi_start;
104007 void *pmi_pal;
104008 u8 *vbe_state_orig; /*
104009diff --git a/init/Kconfig b/init/Kconfig
104010index af09b4f..5ee6e6a 100644
104011--- a/init/Kconfig
104012+++ b/init/Kconfig
104013@@ -642,6 +642,7 @@ config RCU_FAST_NO_HZ
104014 config TREE_RCU_TRACE
104015 def_bool RCU_TRACE && ( TREE_RCU || PREEMPT_RCU )
104016 select DEBUG_FS
104017+ depends on !GRKERNSEC_KMEM
104018 help
104019 This option provides tracing for the TREE_RCU and
104020 PREEMPT_RCU implementations, permitting Makefile to
104021@@ -1139,6 +1140,7 @@ endif # CGROUPS
104022 config CHECKPOINT_RESTORE
104023 bool "Checkpoint/restore support" if EXPERT
104024 select PROC_CHILDREN
104025+ depends on !GRKERNSEC
104026 default n
104027 help
104028 Enables additional kernel features in a sake of checkpoint/restore.
104029@@ -1664,7 +1666,7 @@ config SLUB_DEBUG
104030
104031 config COMPAT_BRK
104032 bool "Disable heap randomization"
104033- default y
104034+ default n
104035 help
104036 Randomizing heap placement makes heap exploits harder, but it
104037 also breaks ancient binaries (including anything libc5 based).
104038@@ -1994,7 +1996,7 @@ config INIT_ALL_POSSIBLE
104039 config STOP_MACHINE
104040 bool
104041 default y
104042- depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
104043+ depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
104044 help
104045 Need stop_machine() primitive.
104046
104047diff --git a/init/Makefile b/init/Makefile
104048index 7bc47ee..6da2dc7 100644
104049--- a/init/Makefile
104050+++ b/init/Makefile
104051@@ -2,6 +2,9 @@
104052 # Makefile for the linux kernel.
104053 #
104054
104055+ccflags-y := $(GCC_PLUGINS_CFLAGS)
104056+asflags-y := $(GCC_PLUGINS_AFLAGS)
104057+
104058 obj-y := main.o version.o mounts.o
104059 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
104060 obj-y += noinitramfs.o
104061diff --git a/init/do_mounts.c b/init/do_mounts.c
104062index dea5de9..bbdbb5f 100644
104063--- a/init/do_mounts.c
104064+++ b/init/do_mounts.c
104065@@ -363,11 +363,11 @@ static void __init get_fs_names(char *page)
104066 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
104067 {
104068 struct super_block *s;
104069- int err = sys_mount(name, "/root", fs, flags, data);
104070+ int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
104071 if (err)
104072 return err;
104073
104074- sys_chdir("/root");
104075+ sys_chdir((const char __force_user *)"/root");
104076 s = current->fs->pwd.dentry->d_sb;
104077 ROOT_DEV = s->s_dev;
104078 printk(KERN_INFO
104079@@ -490,18 +490,18 @@ void __init change_floppy(char *fmt, ...)
104080 va_start(args, fmt);
104081 vsprintf(buf, fmt, args);
104082 va_end(args);
104083- fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
104084+ fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
104085 if (fd >= 0) {
104086 sys_ioctl(fd, FDEJECT, 0);
104087 sys_close(fd);
104088 }
104089 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
104090- fd = sys_open("/dev/console", O_RDWR, 0);
104091+ fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
104092 if (fd >= 0) {
104093 sys_ioctl(fd, TCGETS, (long)&termios);
104094 termios.c_lflag &= ~ICANON;
104095 sys_ioctl(fd, TCSETSF, (long)&termios);
104096- sys_read(fd, &c, 1);
104097+ sys_read(fd, (char __user *)&c, 1);
104098 termios.c_lflag |= ICANON;
104099 sys_ioctl(fd, TCSETSF, (long)&termios);
104100 sys_close(fd);
104101@@ -600,8 +600,8 @@ void __init prepare_namespace(void)
104102 mount_root();
104103 out:
104104 devtmpfs_mount("dev");
104105- sys_mount(".", "/", NULL, MS_MOVE, NULL);
104106- sys_chroot(".");
104107+ sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
104108+ sys_chroot((const char __force_user *)".");
104109 }
104110
104111 static bool is_tmpfs;
104112diff --git a/init/do_mounts.h b/init/do_mounts.h
104113index f5b978a..69dbfe8 100644
104114--- a/init/do_mounts.h
104115+++ b/init/do_mounts.h
104116@@ -15,15 +15,15 @@ extern int root_mountflags;
104117
104118 static inline int create_dev(char *name, dev_t dev)
104119 {
104120- sys_unlink(name);
104121- return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
104122+ sys_unlink((char __force_user *)name);
104123+ return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
104124 }
104125
104126 #if BITS_PER_LONG == 32
104127 static inline u32 bstat(char *name)
104128 {
104129 struct stat64 stat;
104130- if (sys_stat64(name, &stat) != 0)
104131+ if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
104132 return 0;
104133 if (!S_ISBLK(stat.st_mode))
104134 return 0;
104135@@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
104136 static inline u32 bstat(char *name)
104137 {
104138 struct stat stat;
104139- if (sys_newstat(name, &stat) != 0)
104140+ if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
104141 return 0;
104142 if (!S_ISBLK(stat.st_mode))
104143 return 0;
104144diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
104145index 3e0878e..8a9d7a0 100644
104146--- a/init/do_mounts_initrd.c
104147+++ b/init/do_mounts_initrd.c
104148@@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
104149 {
104150 sys_unshare(CLONE_FS | CLONE_FILES);
104151 /* stdin/stdout/stderr for /linuxrc */
104152- sys_open("/dev/console", O_RDWR, 0);
104153+ sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
104154 sys_dup(0);
104155 sys_dup(0);
104156 /* move initrd over / and chdir/chroot in initrd root */
104157- sys_chdir("/root");
104158- sys_mount(".", "/", NULL, MS_MOVE, NULL);
104159- sys_chroot(".");
104160+ sys_chdir((const char __force_user *)"/root");
104161+ sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
104162+ sys_chroot((const char __force_user *)".");
104163 sys_setsid();
104164 return 0;
104165 }
104166@@ -59,8 +59,8 @@ static void __init handle_initrd(void)
104167 create_dev("/dev/root.old", Root_RAM0);
104168 /* mount initrd on rootfs' /root */
104169 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
104170- sys_mkdir("/old", 0700);
104171- sys_chdir("/old");
104172+ sys_mkdir((const char __force_user *)"/old", 0700);
104173+ sys_chdir((const char __force_user *)"/old");
104174
104175 /* try loading default modules from initrd */
104176 load_default_modules();
104177@@ -80,31 +80,31 @@ static void __init handle_initrd(void)
104178 current->flags &= ~PF_FREEZER_SKIP;
104179
104180 /* move initrd to rootfs' /old */
104181- sys_mount("..", ".", NULL, MS_MOVE, NULL);
104182+ sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
104183 /* switch root and cwd back to / of rootfs */
104184- sys_chroot("..");
104185+ sys_chroot((const char __force_user *)"..");
104186
104187 if (new_decode_dev(real_root_dev) == Root_RAM0) {
104188- sys_chdir("/old");
104189+ sys_chdir((const char __force_user *)"/old");
104190 return;
104191 }
104192
104193- sys_chdir("/");
104194+ sys_chdir((const char __force_user *)"/");
104195 ROOT_DEV = new_decode_dev(real_root_dev);
104196 mount_root();
104197
104198 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
104199- error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
104200+ error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
104201 if (!error)
104202 printk("okay\n");
104203 else {
104204- int fd = sys_open("/dev/root.old", O_RDWR, 0);
104205+ int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
104206 if (error == -ENOENT)
104207 printk("/initrd does not exist. Ignored.\n");
104208 else
104209 printk("failed\n");
104210 printk(KERN_NOTICE "Unmounting old root\n");
104211- sys_umount("/old", MNT_DETACH);
104212+ sys_umount((char __force_user *)"/old", MNT_DETACH);
104213 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
104214 if (fd < 0) {
104215 error = fd;
104216@@ -127,11 +127,11 @@ int __init initrd_load(void)
104217 * mounted in the normal path.
104218 */
104219 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
104220- sys_unlink("/initrd.image");
104221+ sys_unlink((const char __force_user *)"/initrd.image");
104222 handle_initrd();
104223 return 1;
104224 }
104225 }
104226- sys_unlink("/initrd.image");
104227+ sys_unlink((const char __force_user *)"/initrd.image");
104228 return 0;
104229 }
104230diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
104231index 8cb6db5..d729f50 100644
104232--- a/init/do_mounts_md.c
104233+++ b/init/do_mounts_md.c
104234@@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
104235 partitioned ? "_d" : "", minor,
104236 md_setup_args[ent].device_names);
104237
104238- fd = sys_open(name, 0, 0);
104239+ fd = sys_open((char __force_user *)name, 0, 0);
104240 if (fd < 0) {
104241 printk(KERN_ERR "md: open failed - cannot start "
104242 "array %s\n", name);
104243@@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
104244 * array without it
104245 */
104246 sys_close(fd);
104247- fd = sys_open(name, 0, 0);
104248+ fd = sys_open((char __force_user *)name, 0, 0);
104249 sys_ioctl(fd, BLKRRPART, 0);
104250 }
104251 sys_close(fd);
104252@@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
104253
104254 wait_for_device_probe();
104255
104256- fd = sys_open("/dev/md0", 0, 0);
104257+ fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
104258 if (fd >= 0) {
104259 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
104260 sys_close(fd);
104261diff --git a/init/init_task.c b/init/init_task.c
104262index ba0a7f36..2bcf1d5 100644
104263--- a/init/init_task.c
104264+++ b/init/init_task.c
104265@@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
104266 * Initial thread structure. Alignment of this is handled by a special
104267 * linker map entry.
104268 */
104269+#ifdef CONFIG_X86
104270+union thread_union init_thread_union __init_task_data;
104271+#else
104272 union thread_union init_thread_union __init_task_data =
104273 { INIT_THREAD_INFO(init_task) };
104274+#endif
104275diff --git a/init/initramfs.c b/init/initramfs.c
104276index ad1bd77..dca2c1b 100644
104277--- a/init/initramfs.c
104278+++ b/init/initramfs.c
104279@@ -25,7 +25,7 @@ static ssize_t __init xwrite(int fd, const char *p, size_t count)
104280
104281 /* sys_write only can write MAX_RW_COUNT aka 2G-4K bytes at most */
104282 while (count) {
104283- ssize_t rv = sys_write(fd, p, count);
104284+ ssize_t rv = sys_write(fd, (char __force_user *)p, count);
104285
104286 if (rv < 0) {
104287 if (rv == -EINTR || rv == -EAGAIN)
104288@@ -107,7 +107,7 @@ static void __init free_hash(void)
104289 }
104290 }
104291
104292-static long __init do_utime(char *filename, time_t mtime)
104293+static long __init do_utime(char __force_user *filename, time_t mtime)
104294 {
104295 struct timespec t[2];
104296
104297@@ -142,7 +142,7 @@ static void __init dir_utime(void)
104298 struct dir_entry *de, *tmp;
104299 list_for_each_entry_safe(de, tmp, &dir_list, list) {
104300 list_del(&de->list);
104301- do_utime(de->name, de->mtime);
104302+ do_utime((char __force_user *)de->name, de->mtime);
104303 kfree(de->name);
104304 kfree(de);
104305 }
104306@@ -304,7 +304,7 @@ static int __init maybe_link(void)
104307 if (nlink >= 2) {
104308 char *old = find_link(major, minor, ino, mode, collected);
104309 if (old)
104310- return (sys_link(old, collected) < 0) ? -1 : 1;
104311+ return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
104312 }
104313 return 0;
104314 }
104315@@ -313,11 +313,11 @@ static void __init clean_path(char *path, umode_t fmode)
104316 {
104317 struct stat st;
104318
104319- if (!sys_newlstat(path, &st) && (st.st_mode ^ fmode) & S_IFMT) {
104320+ if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode ^ fmode) & S_IFMT) {
104321 if (S_ISDIR(st.st_mode))
104322- sys_rmdir(path);
104323+ sys_rmdir((char __force_user *)path);
104324 else
104325- sys_unlink(path);
104326+ sys_unlink((char __force_user *)path);
104327 }
104328 }
104329
104330@@ -338,7 +338,7 @@ static int __init do_name(void)
104331 int openflags = O_WRONLY|O_CREAT;
104332 if (ml != 1)
104333 openflags |= O_TRUNC;
104334- wfd = sys_open(collected, openflags, mode);
104335+ wfd = sys_open((char __force_user *)collected, openflags, mode);
104336
104337 if (wfd >= 0) {
104338 sys_fchown(wfd, uid, gid);
104339@@ -350,17 +350,17 @@ static int __init do_name(void)
104340 }
104341 }
104342 } else if (S_ISDIR(mode)) {
104343- sys_mkdir(collected, mode);
104344- sys_chown(collected, uid, gid);
104345- sys_chmod(collected, mode);
104346+ sys_mkdir((char __force_user *)collected, mode);
104347+ sys_chown((char __force_user *)collected, uid, gid);
104348+ sys_chmod((char __force_user *)collected, mode);
104349 dir_add(collected, mtime);
104350 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
104351 S_ISFIFO(mode) || S_ISSOCK(mode)) {
104352 if (maybe_link() == 0) {
104353- sys_mknod(collected, mode, rdev);
104354- sys_chown(collected, uid, gid);
104355- sys_chmod(collected, mode);
104356- do_utime(collected, mtime);
104357+ sys_mknod((char __force_user *)collected, mode, rdev);
104358+ sys_chown((char __force_user *)collected, uid, gid);
104359+ sys_chmod((char __force_user *)collected, mode);
104360+ do_utime((char __force_user *)collected, mtime);
104361 }
104362 }
104363 return 0;
104364@@ -372,7 +372,7 @@ static int __init do_copy(void)
104365 if (xwrite(wfd, victim, body_len) != body_len)
104366 error("write error");
104367 sys_close(wfd);
104368- do_utime(vcollected, mtime);
104369+ do_utime((char __force_user *)vcollected, mtime);
104370 kfree(vcollected);
104371 eat(body_len);
104372 state = SkipIt;
104373@@ -390,9 +390,9 @@ static int __init do_symlink(void)
104374 {
104375 collected[N_ALIGN(name_len) + body_len] = '\0';
104376 clean_path(collected, 0);
104377- sys_symlink(collected + N_ALIGN(name_len), collected);
104378- sys_lchown(collected, uid, gid);
104379- do_utime(collected, mtime);
104380+ sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
104381+ sys_lchown((char __force_user *)collected, uid, gid);
104382+ do_utime((char __force_user *)collected, mtime);
104383 state = SkipIt;
104384 next_state = Reset;
104385 return 0;
104386diff --git a/init/main.c b/init/main.c
104387index 5650655..937d1b1 100644
104388--- a/init/main.c
104389+++ b/init/main.c
104390@@ -97,6 +97,8 @@ extern void radix_tree_init(void);
104391 static inline void mark_rodata_ro(void) { }
104392 #endif
104393
104394+extern void grsecurity_init(void);
104395+
104396 /*
104397 * Debug helper: via this flag we know that we are in 'early bootup code'
104398 * where only the boot processor is running with IRQ disabled. This means
104399@@ -158,6 +160,37 @@ static int __init set_reset_devices(char *str)
104400
104401 __setup("reset_devices", set_reset_devices);
104402
104403+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
104404+kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
104405+static int __init setup_grsec_proc_gid(char *str)
104406+{
104407+ grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
104408+ return 1;
104409+}
104410+__setup("grsec_proc_gid=", setup_grsec_proc_gid);
104411+#endif
104412+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
104413+int grsec_enable_sysfs_restrict = 1;
104414+static int __init setup_grsec_sysfs_restrict(char *str)
104415+{
104416+ if (!simple_strtol(str, NULL, 0))
104417+ grsec_enable_sysfs_restrict = 0;
104418+ return 1;
104419+}
104420+__setup("grsec_sysfs_restrict", setup_grsec_sysfs_restrict);
104421+#endif
104422+
104423+#ifdef CONFIG_PAX_SOFTMODE
104424+int pax_softmode;
104425+
104426+static int __init setup_pax_softmode(char *str)
104427+{
104428+ get_option(&str, &pax_softmode);
104429+ return 1;
104430+}
104431+__setup("pax_softmode=", setup_pax_softmode);
104432+#endif
104433+
104434 static const char *argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
104435 const char *envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
104436 static const char *panic_later, *panic_param;
104437@@ -731,7 +764,7 @@ static bool __init_or_module initcall_blacklisted(initcall_t fn)
104438 struct blacklist_entry *entry;
104439 char *fn_name;
104440
104441- fn_name = kasprintf(GFP_KERNEL, "%pf", fn);
104442+ fn_name = kasprintf(GFP_KERNEL, "%pX", fn);
104443 if (!fn_name)
104444 return false;
104445
104446@@ -783,7 +816,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
104447 {
104448 int count = preempt_count();
104449 int ret;
104450- char msgbuf[64];
104451+ const char *msg1 = "", *msg2 = "";
104452
104453 if (initcall_blacklisted(fn))
104454 return -EPERM;
104455@@ -793,18 +826,17 @@ int __init_or_module do_one_initcall(initcall_t fn)
104456 else
104457 ret = fn();
104458
104459- msgbuf[0] = 0;
104460-
104461 if (preempt_count() != count) {
104462- sprintf(msgbuf, "preemption imbalance ");
104463+ msg1 = " preemption imbalance";
104464 preempt_count_set(count);
104465 }
104466 if (irqs_disabled()) {
104467- strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
104468+ msg2 = " disabled interrupts";
104469 local_irq_enable();
104470 }
104471- WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
104472+ WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
104473
104474+ add_latent_entropy();
104475 return ret;
104476 }
104477
104478@@ -910,8 +942,8 @@ static int run_init_process(const char *init_filename)
104479 {
104480 argv_init[0] = init_filename;
104481 return do_execve(getname_kernel(init_filename),
104482- (const char __user *const __user *)argv_init,
104483- (const char __user *const __user *)envp_init);
104484+ (const char __user *const __force_user *)argv_init,
104485+ (const char __user *const __force_user *)envp_init);
104486 }
104487
104488 static int try_to_run_init_process(const char *init_filename)
104489@@ -928,6 +960,10 @@ static int try_to_run_init_process(const char *init_filename)
104490 return ret;
104491 }
104492
104493+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
104494+extern int gr_init_ran;
104495+#endif
104496+
104497 static noinline void __init kernel_init_freeable(void);
104498
104499 static int __ref kernel_init(void *unused)
104500@@ -952,6 +988,11 @@ static int __ref kernel_init(void *unused)
104501 ramdisk_execute_command, ret);
104502 }
104503
104504+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
104505+ /* if no initrd was used, be extra sure we enforce chroot restrictions */
104506+ gr_init_ran = 1;
104507+#endif
104508+
104509 /*
104510 * We try each of these until one succeeds.
104511 *
104512@@ -1009,7 +1050,7 @@ static noinline void __init kernel_init_freeable(void)
104513 do_basic_setup();
104514
104515 /* Open the /dev/console on the rootfs, this should never fail */
104516- if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
104517+ if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
104518 pr_err("Warning: unable to open an initial console.\n");
104519
104520 (void) sys_dup(0);
104521@@ -1022,11 +1063,13 @@ static noinline void __init kernel_init_freeable(void)
104522 if (!ramdisk_execute_command)
104523 ramdisk_execute_command = "/init";
104524
104525- if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
104526+ if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
104527 ramdisk_execute_command = NULL;
104528 prepare_namespace();
104529 }
104530
104531+ grsecurity_init();
104532+
104533 /*
104534 * Ok, we have completed the initial bootup, and
104535 * we're essentially up and running. Get rid of the
104536diff --git a/ipc/compat.c b/ipc/compat.c
104537index 9b3c85f..5266b0f 100644
104538--- a/ipc/compat.c
104539+++ b/ipc/compat.c
104540@@ -396,7 +396,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
104541 COMPAT_SHMLBA);
104542 if (err < 0)
104543 return err;
104544- return put_user(raddr, (compat_ulong_t *)compat_ptr(third));
104545+ return put_user(raddr, (compat_ulong_t __user *)compat_ptr(third));
104546 }
104547 case SHMDT:
104548 return sys_shmdt(compat_ptr(ptr));
104549@@ -747,7 +747,7 @@ COMPAT_SYSCALL_DEFINE3(shmctl, int, first, int, second, void __user *, uptr)
104550 }
104551
104552 COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems,
104553- unsigned, nsops,
104554+ compat_long_t, nsops,
104555 const struct compat_timespec __user *, timeout)
104556 {
104557 struct timespec __user *ts64;
104558diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
104559index 8ad93c2..efd80f8 100644
104560--- a/ipc/ipc_sysctl.c
104561+++ b/ipc/ipc_sysctl.c
104562@@ -30,7 +30,7 @@ static void *get_ipc(struct ctl_table *table)
104563 static int proc_ipc_dointvec(struct ctl_table *table, int write,
104564 void __user *buffer, size_t *lenp, loff_t *ppos)
104565 {
104566- struct ctl_table ipc_table;
104567+ ctl_table_no_const ipc_table;
104568
104569 memcpy(&ipc_table, table, sizeof(ipc_table));
104570 ipc_table.data = get_ipc(table);
104571@@ -41,7 +41,7 @@ static int proc_ipc_dointvec(struct ctl_table *table, int write,
104572 static int proc_ipc_dointvec_minmax(struct ctl_table *table, int write,
104573 void __user *buffer, size_t *lenp, loff_t *ppos)
104574 {
104575- struct ctl_table ipc_table;
104576+ ctl_table_no_const ipc_table;
104577
104578 memcpy(&ipc_table, table, sizeof(ipc_table));
104579 ipc_table.data = get_ipc(table);
104580@@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(struct ctl_table *table, int write,
104581 static int proc_ipc_doulongvec_minmax(struct ctl_table *table, int write,
104582 void __user *buffer, size_t *lenp, loff_t *ppos)
104583 {
104584- struct ctl_table ipc_table;
104585+ ctl_table_no_const ipc_table;
104586 memcpy(&ipc_table, table, sizeof(ipc_table));
104587 ipc_table.data = get_ipc(table);
104588
104589@@ -76,7 +76,7 @@ static int proc_ipc_doulongvec_minmax(struct ctl_table *table, int write,
104590 static int proc_ipc_auto_msgmni(struct ctl_table *table, int write,
104591 void __user *buffer, size_t *lenp, loff_t *ppos)
104592 {
104593- struct ctl_table ipc_table;
104594+ ctl_table_no_const ipc_table;
104595 int dummy = 0;
104596
104597 memcpy(&ipc_table, table, sizeof(ipc_table));
104598diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
104599index 68d4e95..1477ded 100644
104600--- a/ipc/mq_sysctl.c
104601+++ b/ipc/mq_sysctl.c
104602@@ -25,7 +25,7 @@ static void *get_mq(struct ctl_table *table)
104603 static int proc_mq_dointvec(struct ctl_table *table, int write,
104604 void __user *buffer, size_t *lenp, loff_t *ppos)
104605 {
104606- struct ctl_table mq_table;
104607+ ctl_table_no_const mq_table;
104608 memcpy(&mq_table, table, sizeof(mq_table));
104609 mq_table.data = get_mq(table);
104610
104611@@ -35,7 +35,7 @@ static int proc_mq_dointvec(struct ctl_table *table, int write,
104612 static int proc_mq_dointvec_minmax(struct ctl_table *table, int write,
104613 void __user *buffer, size_t *lenp, loff_t *ppos)
104614 {
104615- struct ctl_table mq_table;
104616+ ctl_table_no_const mq_table;
104617 memcpy(&mq_table, table, sizeof(mq_table));
104618 mq_table.data = get_mq(table);
104619
104620diff --git a/ipc/mqueue.c b/ipc/mqueue.c
104621index 161a180..be31d93 100644
104622--- a/ipc/mqueue.c
104623+++ b/ipc/mqueue.c
104624@@ -274,6 +274,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
104625 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
104626 info->attr.mq_msgsize);
104627
104628+ gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
104629 spin_lock(&mq_lock);
104630 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
104631 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
104632diff --git a/ipc/sem.c b/ipc/sem.c
104633index b471e5a..89aef1d 100644
104634--- a/ipc/sem.c
104635+++ b/ipc/sem.c
104636@@ -1790,7 +1790,7 @@ static int get_queue_result(struct sem_queue *q)
104637 }
104638
104639 SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
104640- unsigned, nsops, const struct timespec __user *, timeout)
104641+ long, nsops, const struct timespec __user *, timeout)
104642 {
104643 int error = -EINVAL;
104644 struct sem_array *sma;
104645@@ -2025,7 +2025,7 @@ out_free:
104646 }
104647
104648 SYSCALL_DEFINE3(semop, int, semid, struct sembuf __user *, tsops,
104649- unsigned, nsops)
104650+ long, nsops)
104651 {
104652 return sys_semtimedop(semid, tsops, nsops, NULL);
104653 }
104654diff --git a/ipc/shm.c b/ipc/shm.c
104655index 0e61fd4..c545631 100644
104656--- a/ipc/shm.c
104657+++ b/ipc/shm.c
104658@@ -72,6 +72,14 @@ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp);
104659 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
104660 #endif
104661
104662+#ifdef CONFIG_GRKERNSEC
104663+extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
104664+ const u64 shm_createtime, const kuid_t cuid,
104665+ const int shmid);
104666+extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
104667+ const u64 shm_createtime);
104668+#endif
104669+
104670 void shm_init_ns(struct ipc_namespace *ns)
104671 {
104672 ns->shm_ctlmax = SHMMAX;
104673@@ -555,6 +563,9 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
104674 shp->shm_lprid = 0;
104675 shp->shm_atim = shp->shm_dtim = 0;
104676 shp->shm_ctim = get_seconds();
104677+#ifdef CONFIG_GRKERNSEC
104678+ shp->shm_createtime = ktime_get_ns();
104679+#endif
104680 shp->shm_segsz = size;
104681 shp->shm_nattch = 0;
104682 shp->shm_file = file;
104683@@ -1098,6 +1109,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
104684 f_mode = FMODE_READ | FMODE_WRITE;
104685 }
104686 if (shmflg & SHM_EXEC) {
104687+
104688+#ifdef CONFIG_PAX_MPROTECT
104689+ if (current->mm->pax_flags & MF_PAX_MPROTECT)
104690+ goto out;
104691+#endif
104692+
104693 prot |= PROT_EXEC;
104694 acc_mode |= S_IXUGO;
104695 }
104696@@ -1122,6 +1139,15 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
104697 if (err)
104698 goto out_unlock;
104699
104700+#ifdef CONFIG_GRKERNSEC
104701+ if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
104702+ shp->shm_perm.cuid, shmid) ||
104703+ !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
104704+ err = -EACCES;
104705+ goto out_unlock;
104706+ }
104707+#endif
104708+
104709 ipc_lock_object(&shp->shm_perm);
104710
104711 /* check if shm_destroy() is tearing down shp */
104712@@ -1134,6 +1160,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
104713 path = shp->shm_file->f_path;
104714 path_get(&path);
104715 shp->shm_nattch++;
104716+#ifdef CONFIG_GRKERNSEC
104717+ shp->shm_lapid = current->pid;
104718+#endif
104719 size = i_size_read(d_inode(path.dentry));
104720 ipc_unlock_object(&shp->shm_perm);
104721 rcu_read_unlock();
104722diff --git a/ipc/util.c b/ipc/util.c
104723index 0f401d9..049b0ff 100644
104724--- a/ipc/util.c
104725+++ b/ipc/util.c
104726@@ -71,6 +71,8 @@ struct ipc_proc_iface {
104727 int (*show)(struct seq_file *, void *);
104728 };
104729
104730+extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
104731+
104732 /**
104733 * ipc_init - initialise ipc subsystem
104734 *
104735@@ -494,6 +496,10 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
104736 granted_mode >>= 6;
104737 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
104738 granted_mode >>= 3;
104739+
104740+ if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
104741+ return -1;
104742+
104743 /* is there some bit set in requested_mode but not in granted_mode? */
104744 if ((requested_mode & ~granted_mode & 0007) &&
104745 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
104746diff --git a/kernel/audit.c b/kernel/audit.c
104747index f9e6065..3fcb6ab 100644
104748--- a/kernel/audit.c
104749+++ b/kernel/audit.c
104750@@ -124,7 +124,7 @@ u32 audit_sig_sid = 0;
104751 3) suppressed due to audit_rate_limit
104752 4) suppressed due to audit_backlog_limit
104753 */
104754-static atomic_t audit_lost = ATOMIC_INIT(0);
104755+static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
104756
104757 /* The netlink socket. */
104758 static struct sock *audit_sock;
104759@@ -258,7 +258,7 @@ void audit_log_lost(const char *message)
104760 unsigned long now;
104761 int print;
104762
104763- atomic_inc(&audit_lost);
104764+ atomic_inc_unchecked(&audit_lost);
104765
104766 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
104767
104768@@ -275,7 +275,7 @@ void audit_log_lost(const char *message)
104769 if (print) {
104770 if (printk_ratelimit())
104771 pr_warn("audit_lost=%u audit_rate_limit=%u audit_backlog_limit=%u\n",
104772- atomic_read(&audit_lost),
104773+ atomic_read_unchecked(&audit_lost),
104774 audit_rate_limit,
104775 audit_backlog_limit);
104776 audit_panic(message);
104777@@ -833,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
104778 s.pid = audit_pid;
104779 s.rate_limit = audit_rate_limit;
104780 s.backlog_limit = audit_backlog_limit;
104781- s.lost = atomic_read(&audit_lost);
104782+ s.lost = atomic_read_unchecked(&audit_lost);
104783 s.backlog = skb_queue_len(&audit_skb_queue);
104784 s.feature_bitmap = AUDIT_FEATURE_BITMAP_ALL;
104785 s.backlog_wait_time = audit_backlog_wait_time_master;
104786diff --git a/kernel/auditsc.c b/kernel/auditsc.c
104787index e85bdfd..441a638 100644
104788--- a/kernel/auditsc.c
104789+++ b/kernel/auditsc.c
104790@@ -1021,7 +1021,7 @@ static int audit_log_single_execve_arg(struct audit_context *context,
104791 * for strings that are too long, we should not have created
104792 * any.
104793 */
104794- if (WARN_ON_ONCE(len < 0 || len > MAX_ARG_STRLEN - 1)) {
104795+ if (WARN_ON_ONCE(len > MAX_ARG_STRLEN - 1)) {
104796 send_sig(SIGKILL, current, 0);
104797 return -1;
104798 }
104799@@ -1952,7 +1952,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
104800 }
104801
104802 /* global counter which is incremented every time something logs in */
104803-static atomic_t session_id = ATOMIC_INIT(0);
104804+static atomic_unchecked_t session_id = ATOMIC_INIT(0);
104805
104806 static int audit_set_loginuid_perm(kuid_t loginuid)
104807 {
104808@@ -2019,7 +2019,7 @@ int audit_set_loginuid(kuid_t loginuid)
104809
104810 /* are we setting or clearing? */
104811 if (uid_valid(loginuid))
104812- sessionid = (unsigned int)atomic_inc_return(&session_id);
104813+ sessionid = (unsigned int)atomic_inc_return_unchecked(&session_id);
104814
104815 task->sessionid = sessionid;
104816 task->loginuid = loginuid;
104817diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
104818index c5bedc8..6ec8715 100644
104819--- a/kernel/bpf/core.c
104820+++ b/kernel/bpf/core.c
104821@@ -145,14 +145,17 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
104822 * random section of illegal instructions.
104823 */
104824 size = round_up(proglen + sizeof(*hdr) + 128, PAGE_SIZE);
104825- hdr = module_alloc(size);
104826+ hdr = module_alloc_exec(size);
104827 if (hdr == NULL)
104828 return NULL;
104829
104830 /* Fill space with illegal/arch-dep instructions. */
104831 bpf_fill_ill_insns(hdr, size);
104832
104833+ pax_open_kernel();
104834 hdr->pages = size / PAGE_SIZE;
104835+ pax_close_kernel();
104836+
104837 hole = min_t(unsigned int, size - (proglen + sizeof(*hdr)),
104838 PAGE_SIZE - sizeof(*hdr));
104839 start = (prandom_u32() % hole) & ~(alignment - 1);
104840@@ -165,7 +168,7 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
104841
104842 void bpf_jit_binary_free(struct bpf_binary_header *hdr)
104843 {
104844- module_memfree(hdr);
104845+ module_memfree_exec(hdr);
104846 }
104847 #endif /* CONFIG_BPF_JIT */
104848
104849diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
104850index a1b14d1..7dce5d9 100644
104851--- a/kernel/bpf/syscall.c
104852+++ b/kernel/bpf/syscall.c
104853@@ -592,11 +592,15 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, siz
104854 int err;
104855
104856 /* the syscall is limited to root temporarily. This restriction will be
104857- * lifted when security audit is clean. Note that eBPF+tracing must have
104858- * this restriction, since it may pass kernel data to user space
104859+ * lifted by upstream when a half-assed security audit is clean. Note
104860+ * that eBPF+tracing must have this restriction, since it may pass
104861+ * kernel data to user space
104862 */
104863 if (!capable(CAP_SYS_ADMIN))
104864 return -EPERM;
104865+#ifdef CONFIG_GRKERNSEC
104866+ return -EPERM;
104867+#endif
104868
104869 if (!access_ok(VERIFY_READ, uattr, 1))
104870 return -EFAULT;
104871diff --git a/kernel/capability.c b/kernel/capability.c
104872index 45432b5..988f1e4 100644
104873--- a/kernel/capability.c
104874+++ b/kernel/capability.c
104875@@ -193,6 +193,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
104876 * before modification is attempted and the application
104877 * fails.
104878 */
104879+ if (tocopy > ARRAY_SIZE(kdata))
104880+ return -EFAULT;
104881+
104882 if (copy_to_user(dataptr, kdata, tocopy
104883 * sizeof(struct __user_cap_data_struct))) {
104884 return -EFAULT;
104885@@ -298,10 +301,11 @@ bool has_ns_capability(struct task_struct *t,
104886 int ret;
104887
104888 rcu_read_lock();
104889- ret = security_capable(__task_cred(t), ns, cap);
104890+ ret = security_capable(__task_cred(t), ns, cap) == 0 &&
104891+ gr_task_is_capable(t, __task_cred(t), cap);
104892 rcu_read_unlock();
104893
104894- return (ret == 0);
104895+ return ret;
104896 }
104897
104898 /**
104899@@ -338,10 +342,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
104900 int ret;
104901
104902 rcu_read_lock();
104903- ret = security_capable_noaudit(__task_cred(t), ns, cap);
104904+ ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
104905 rcu_read_unlock();
104906
104907- return (ret == 0);
104908+ return ret;
104909 }
104910
104911 /**
104912@@ -379,7 +383,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
104913 BUG();
104914 }
104915
104916- if (security_capable(current_cred(), ns, cap) == 0) {
104917+ if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
104918 current->flags |= PF_SUPERPRIV;
104919 return true;
104920 }
104921@@ -387,6 +391,20 @@ bool ns_capable(struct user_namespace *ns, int cap)
104922 }
104923 EXPORT_SYMBOL(ns_capable);
104924
104925+bool ns_capable_nolog(struct user_namespace *ns, int cap)
104926+{
104927+ if (unlikely(!cap_valid(cap))) {
104928+ pr_crit("capable_nolog() called with invalid cap=%u\n", cap);
104929+ BUG();
104930+ }
104931+
104932+ if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
104933+ current->flags |= PF_SUPERPRIV;
104934+ return true;
104935+ }
104936+ return false;
104937+}
104938+EXPORT_SYMBOL(ns_capable_nolog);
104939
104940 /**
104941 * capable - Determine if the current task has a superior capability in effect
104942@@ -403,6 +421,13 @@ bool capable(int cap)
104943 return ns_capable(&init_user_ns, cap);
104944 }
104945 EXPORT_SYMBOL(capable);
104946+
104947+bool capable_nolog(int cap)
104948+{
104949+ return ns_capable_nolog(&init_user_ns, cap);
104950+}
104951+EXPORT_SYMBOL(capable_nolog);
104952+
104953 #endif /* CONFIG_MULTIUSER */
104954
104955 /**
104956@@ -447,3 +472,12 @@ bool capable_wrt_inode_uidgid(const struct inode *inode, int cap)
104957 kgid_has_mapping(ns, inode->i_gid);
104958 }
104959 EXPORT_SYMBOL(capable_wrt_inode_uidgid);
104960+
104961+bool capable_wrt_inode_uidgid_nolog(const struct inode *inode, int cap)
104962+{
104963+ struct user_namespace *ns = current_user_ns();
104964+
104965+ return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid) &&
104966+ kgid_has_mapping(ns, inode->i_gid);
104967+}
104968+EXPORT_SYMBOL(capable_wrt_inode_uidgid_nolog);
104969diff --git a/kernel/cgroup.c b/kernel/cgroup.c
104970index fe6f855..7dba913 100644
104971--- a/kernel/cgroup.c
104972+++ b/kernel/cgroup.c
104973@@ -5425,6 +5425,9 @@ static void cgroup_release_agent(struct work_struct *work)
104974 if (!pathbuf || !agentbuf)
104975 goto out;
104976
104977+ if (agentbuf[0] == '\0')
104978+ goto out;
104979+
104980 path = cgroup_path(cgrp, pathbuf, PATH_MAX);
104981 if (!path)
104982 goto out;
104983@@ -5610,7 +5613,7 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v)
104984 struct task_struct *task;
104985 int count = 0;
104986
104987- seq_printf(seq, "css_set %p\n", cset);
104988+ seq_printf(seq, "css_set %pK\n", cset);
104989
104990 list_for_each_entry(task, &cset->tasks, cg_list) {
104991 if (count++ > MAX_TASKS_SHOWN_PER_CSS)
104992diff --git a/kernel/compat.c b/kernel/compat.c
104993index 333d364..762ec00 100644
104994--- a/kernel/compat.c
104995+++ b/kernel/compat.c
104996@@ -13,6 +13,7 @@
104997
104998 #include <linux/linkage.h>
104999 #include <linux/compat.h>
105000+#include <linux/module.h>
105001 #include <linux/errno.h>
105002 #include <linux/time.h>
105003 #include <linux/signal.h>
105004@@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
105005 mm_segment_t oldfs;
105006 long ret;
105007
105008- restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
105009+ restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
105010 oldfs = get_fs();
105011 set_fs(KERNEL_DS);
105012 ret = hrtimer_nanosleep_restart(restart);
105013@@ -252,7 +253,7 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
105014 oldfs = get_fs();
105015 set_fs(KERNEL_DS);
105016 ret = hrtimer_nanosleep(&tu,
105017- rmtp ? (struct timespec __user *)&rmt : NULL,
105018+ rmtp ? (struct timespec __force_user *)&rmt : NULL,
105019 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
105020 set_fs(oldfs);
105021
105022@@ -378,7 +379,7 @@ COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set)
105023 mm_segment_t old_fs = get_fs();
105024
105025 set_fs(KERNEL_DS);
105026- ret = sys_sigpending((old_sigset_t __user *) &s);
105027+ ret = sys_sigpending((old_sigset_t __force_user *) &s);
105028 set_fs(old_fs);
105029 if (ret == 0)
105030 ret = put_user(s, set);
105031@@ -468,7 +469,7 @@ COMPAT_SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
105032 mm_segment_t old_fs = get_fs();
105033
105034 set_fs(KERNEL_DS);
105035- ret = sys_old_getrlimit(resource, (struct rlimit __user *)&r);
105036+ ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
105037 set_fs(old_fs);
105038
105039 if (!ret) {
105040@@ -550,8 +551,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
105041 set_fs (KERNEL_DS);
105042 ret = sys_wait4(pid,
105043 (stat_addr ?
105044- (unsigned int __user *) &status : NULL),
105045- options, (struct rusage __user *) &r);
105046+ (unsigned int __force_user *) &status : NULL),
105047+ options, (struct rusage __force_user *) &r);
105048 set_fs (old_fs);
105049
105050 if (ret > 0) {
105051@@ -577,8 +578,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
105052 memset(&info, 0, sizeof(info));
105053
105054 set_fs(KERNEL_DS);
105055- ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
105056- uru ? (struct rusage __user *)&ru : NULL);
105057+ ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
105058+ uru ? (struct rusage __force_user *)&ru : NULL);
105059 set_fs(old_fs);
105060
105061 if ((ret < 0) || (info.si_signo == 0))
105062@@ -712,8 +713,8 @@ COMPAT_SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
105063 oldfs = get_fs();
105064 set_fs(KERNEL_DS);
105065 err = sys_timer_settime(timer_id, flags,
105066- (struct itimerspec __user *) &newts,
105067- (struct itimerspec __user *) &oldts);
105068+ (struct itimerspec __force_user *) &newts,
105069+ (struct itimerspec __force_user *) &oldts);
105070 set_fs(oldfs);
105071 if (!err && old && put_compat_itimerspec(old, &oldts))
105072 return -EFAULT;
105073@@ -730,7 +731,7 @@ COMPAT_SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
105074 oldfs = get_fs();
105075 set_fs(KERNEL_DS);
105076 err = sys_timer_gettime(timer_id,
105077- (struct itimerspec __user *) &ts);
105078+ (struct itimerspec __force_user *) &ts);
105079 set_fs(oldfs);
105080 if (!err && put_compat_itimerspec(setting, &ts))
105081 return -EFAULT;
105082@@ -749,7 +750,7 @@ COMPAT_SYSCALL_DEFINE2(clock_settime, clockid_t, which_clock,
105083 oldfs = get_fs();
105084 set_fs(KERNEL_DS);
105085 err = sys_clock_settime(which_clock,
105086- (struct timespec __user *) &ts);
105087+ (struct timespec __force_user *) &ts);
105088 set_fs(oldfs);
105089 return err;
105090 }
105091@@ -764,7 +765,7 @@ COMPAT_SYSCALL_DEFINE2(clock_gettime, clockid_t, which_clock,
105092 oldfs = get_fs();
105093 set_fs(KERNEL_DS);
105094 err = sys_clock_gettime(which_clock,
105095- (struct timespec __user *) &ts);
105096+ (struct timespec __force_user *) &ts);
105097 set_fs(oldfs);
105098 if (!err && compat_put_timespec(&ts, tp))
105099 return -EFAULT;
105100@@ -784,7 +785,7 @@ COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
105101
105102 oldfs = get_fs();
105103 set_fs(KERNEL_DS);
105104- ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
105105+ ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
105106 set_fs(oldfs);
105107
105108 err = compat_put_timex(utp, &txc);
105109@@ -804,7 +805,7 @@ COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock,
105110 oldfs = get_fs();
105111 set_fs(KERNEL_DS);
105112 err = sys_clock_getres(which_clock,
105113- (struct timespec __user *) &ts);
105114+ (struct timespec __force_user *) &ts);
105115 set_fs(oldfs);
105116 if (!err && tp && compat_put_timespec(&ts, tp))
105117 return -EFAULT;
105118@@ -818,7 +819,7 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
105119 struct timespec tu;
105120 struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
105121
105122- restart->nanosleep.rmtp = (struct timespec __user *) &tu;
105123+ restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
105124 oldfs = get_fs();
105125 set_fs(KERNEL_DS);
105126 err = clock_nanosleep_restart(restart);
105127@@ -850,8 +851,8 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
105128 oldfs = get_fs();
105129 set_fs(KERNEL_DS);
105130 err = sys_clock_nanosleep(which_clock, flags,
105131- (struct timespec __user *) &in,
105132- (struct timespec __user *) &out);
105133+ (struct timespec __force_user *) &in,
105134+ (struct timespec __force_user *) &out);
105135 set_fs(oldfs);
105136
105137 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
105138@@ -1147,7 +1148,7 @@ COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval,
105139 mm_segment_t old_fs = get_fs();
105140
105141 set_fs(KERNEL_DS);
105142- ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
105143+ ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
105144 set_fs(old_fs);
105145 if (compat_put_timespec(&t, interval))
105146 return -EFAULT;
105147diff --git a/kernel/configs.c b/kernel/configs.c
105148index c18b1f1..b9a0132 100644
105149--- a/kernel/configs.c
105150+++ b/kernel/configs.c
105151@@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
105152 struct proc_dir_entry *entry;
105153
105154 /* create the current config file */
105155+#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
105156+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
105157+ entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
105158+ &ikconfig_file_ops);
105159+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
105160+ entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
105161+ &ikconfig_file_ops);
105162+#endif
105163+#else
105164 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
105165 &ikconfig_file_ops);
105166+#endif
105167+
105168 if (!entry)
105169 return -ENOMEM;
105170
105171diff --git a/kernel/cred.c b/kernel/cred.c
105172index ec1c076..7da8a0e 100644
105173--- a/kernel/cred.c
105174+++ b/kernel/cred.c
105175@@ -167,6 +167,15 @@ void exit_creds(struct task_struct *tsk)
105176 validate_creds(cred);
105177 alter_cred_subscribers(cred, -1);
105178 put_cred(cred);
105179+
105180+#ifdef CONFIG_GRKERNSEC_SETXID
105181+ cred = (struct cred *) tsk->delayed_cred;
105182+ if (cred != NULL) {
105183+ tsk->delayed_cred = NULL;
105184+ validate_creds(cred);
105185+ put_cred(cred);
105186+ }
105187+#endif
105188 }
105189
105190 /**
105191@@ -414,7 +423,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
105192 * Always returns 0 thus allowing this function to be tail-called at the end
105193 * of, say, sys_setgid().
105194 */
105195-int commit_creds(struct cred *new)
105196+static int __commit_creds(struct cred *new)
105197 {
105198 struct task_struct *task = current;
105199 const struct cred *old = task->real_cred;
105200@@ -433,6 +442,8 @@ int commit_creds(struct cred *new)
105201
105202 get_cred(new); /* we will require a ref for the subj creds too */
105203
105204+ gr_set_role_label(task, new->uid, new->gid);
105205+
105206 /* dumpability changes */
105207 if (!uid_eq(old->euid, new->euid) ||
105208 !gid_eq(old->egid, new->egid) ||
105209@@ -482,6 +493,105 @@ int commit_creds(struct cred *new)
105210 put_cred(old);
105211 return 0;
105212 }
105213+#ifdef CONFIG_GRKERNSEC_SETXID
105214+extern int set_user(struct cred *new);
105215+
105216+void gr_delayed_cred_worker(void)
105217+{
105218+ const struct cred *new = current->delayed_cred;
105219+ struct cred *ncred;
105220+
105221+ current->delayed_cred = NULL;
105222+
105223+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
105224+ // from doing get_cred on it when queueing this
105225+ put_cred(new);
105226+ return;
105227+ } else if (new == NULL)
105228+ return;
105229+
105230+ ncred = prepare_creds();
105231+ if (!ncred)
105232+ goto die;
105233+ // uids
105234+ ncred->uid = new->uid;
105235+ ncred->euid = new->euid;
105236+ ncred->suid = new->suid;
105237+ ncred->fsuid = new->fsuid;
105238+ // gids
105239+ ncred->gid = new->gid;
105240+ ncred->egid = new->egid;
105241+ ncred->sgid = new->sgid;
105242+ ncred->fsgid = new->fsgid;
105243+ // groups
105244+ set_groups(ncred, new->group_info);
105245+ // caps
105246+ ncred->securebits = new->securebits;
105247+ ncred->cap_inheritable = new->cap_inheritable;
105248+ ncred->cap_permitted = new->cap_permitted;
105249+ ncred->cap_effective = new->cap_effective;
105250+ ncred->cap_bset = new->cap_bset;
105251+
105252+ if (set_user(ncred)) {
105253+ abort_creds(ncred);
105254+ goto die;
105255+ }
105256+
105257+ // from doing get_cred on it when queueing this
105258+ put_cred(new);
105259+
105260+ __commit_creds(ncred);
105261+ return;
105262+die:
105263+ // from doing get_cred on it when queueing this
105264+ put_cred(new);
105265+ do_group_exit(SIGKILL);
105266+}
105267+#endif
105268+
105269+int commit_creds(struct cred *new)
105270+{
105271+#ifdef CONFIG_GRKERNSEC_SETXID
105272+ int ret;
105273+ int schedule_it = 0;
105274+ struct task_struct *t;
105275+ unsigned oldsecurebits = current_cred()->securebits;
105276+
105277+ /* we won't get called with tasklist_lock held for writing
105278+ and interrupts disabled as the cred struct in that case is
105279+ init_cred
105280+ */
105281+ if (grsec_enable_setxid && !current_is_single_threaded() &&
105282+ uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
105283+ !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
105284+ schedule_it = 1;
105285+ }
105286+ ret = __commit_creds(new);
105287+ if (schedule_it) {
105288+ rcu_read_lock();
105289+ read_lock(&tasklist_lock);
105290+ for (t = next_thread(current); t != current;
105291+ t = next_thread(t)) {
105292+ /* we'll check if the thread has uid 0 in
105293+ * the delayed worker routine
105294+ */
105295+ if (task_securebits(t) == oldsecurebits &&
105296+ t->delayed_cred == NULL) {
105297+ t->delayed_cred = get_cred(new);
105298+ set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
105299+ set_tsk_need_resched(t);
105300+ }
105301+ }
105302+ read_unlock(&tasklist_lock);
105303+ rcu_read_unlock();
105304+ }
105305+
105306+ return ret;
105307+#else
105308+ return __commit_creds(new);
105309+#endif
105310+}
105311+
105312 EXPORT_SYMBOL(commit_creds);
105313
105314 /**
105315diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
105316index 0874e2e..5b32cc9 100644
105317--- a/kernel/debug/debug_core.c
105318+++ b/kernel/debug/debug_core.c
105319@@ -127,7 +127,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
105320 */
105321 static atomic_t masters_in_kgdb;
105322 static atomic_t slaves_in_kgdb;
105323-static atomic_t kgdb_break_tasklet_var;
105324+static atomic_unchecked_t kgdb_break_tasklet_var;
105325 atomic_t kgdb_setting_breakpoint;
105326
105327 struct task_struct *kgdb_usethread;
105328@@ -137,7 +137,7 @@ int kgdb_single_step;
105329 static pid_t kgdb_sstep_pid;
105330
105331 /* to keep track of the CPU which is doing the single stepping*/
105332-atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
105333+atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
105334
105335 /*
105336 * If you are debugging a problem where roundup (the collection of
105337@@ -552,7 +552,7 @@ return_normal:
105338 * kernel will only try for the value of sstep_tries before
105339 * giving up and continuing on.
105340 */
105341- if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
105342+ if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
105343 (kgdb_info[cpu].task &&
105344 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
105345 atomic_set(&kgdb_active, -1);
105346@@ -654,8 +654,8 @@ cpu_master_loop:
105347 }
105348
105349 kgdb_restore:
105350- if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
105351- int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
105352+ if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
105353+ int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
105354 if (kgdb_info[sstep_cpu].task)
105355 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
105356 else
105357@@ -949,18 +949,18 @@ static void kgdb_unregister_callbacks(void)
105358 static void kgdb_tasklet_bpt(unsigned long ing)
105359 {
105360 kgdb_breakpoint();
105361- atomic_set(&kgdb_break_tasklet_var, 0);
105362+ atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
105363 }
105364
105365 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
105366
105367 void kgdb_schedule_breakpoint(void)
105368 {
105369- if (atomic_read(&kgdb_break_tasklet_var) ||
105370+ if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
105371 atomic_read(&kgdb_active) != -1 ||
105372 atomic_read(&kgdb_setting_breakpoint))
105373 return;
105374- atomic_inc(&kgdb_break_tasklet_var);
105375+ atomic_inc_unchecked(&kgdb_break_tasklet_var);
105376 tasklet_schedule(&kgdb_tasklet_breakpoint);
105377 }
105378 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
105379diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
105380index 41213454..861e178 100644
105381--- a/kernel/debug/kdb/kdb_main.c
105382+++ b/kernel/debug/kdb/kdb_main.c
105383@@ -2021,7 +2021,7 @@ static int kdb_lsmod(int argc, const char **argv)
105384 continue;
105385
105386 kdb_printf("%-20s%8u 0x%p ", mod->name,
105387- mod->core_size, (void *)mod);
105388+ mod->core_size_rx + mod->core_size_rw, (void *)mod);
105389 #ifdef CONFIG_MODULE_UNLOAD
105390 kdb_printf("%4d ", module_refcount(mod));
105391 #endif
105392@@ -2031,7 +2031,7 @@ static int kdb_lsmod(int argc, const char **argv)
105393 kdb_printf(" (Loading)");
105394 else
105395 kdb_printf(" (Live)");
105396- kdb_printf(" 0x%p", mod->module_core);
105397+ kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
105398
105399 #ifdef CONFIG_MODULE_UNLOAD
105400 {
105401diff --git a/kernel/events/core.c b/kernel/events/core.c
105402index e6feb51..470c853 100644
105403--- a/kernel/events/core.c
105404+++ b/kernel/events/core.c
105405@@ -174,8 +174,15 @@ static struct srcu_struct pmus_srcu;
105406 * 0 - disallow raw tracepoint access for unpriv
105407 * 1 - disallow cpu events for unpriv
105408 * 2 - disallow kernel profiling for unpriv
105409+ * 3 - disallow all unpriv perf event use
105410 */
105411-int sysctl_perf_event_paranoid __read_mostly = 1;
105412+#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
105413+int sysctl_perf_event_legitimately_concerned __read_only = 3;
105414+#elif defined(CONFIG_GRKERNSEC_HIDESYM)
105415+int sysctl_perf_event_legitimately_concerned __read_only = 2;
105416+#else
105417+int sysctl_perf_event_legitimately_concerned __read_only = 1;
105418+#endif
105419
105420 /* Minimum for 512 kiB + 1 user control page */
105421 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
105422@@ -201,7 +208,7 @@ void update_perf_cpu_limits(void)
105423
105424 tmp *= sysctl_perf_cpu_time_max_percent;
105425 do_div(tmp, 100);
105426- ACCESS_ONCE(perf_sample_allowed_ns) = tmp;
105427+ ACCESS_ONCE_RW(perf_sample_allowed_ns) = tmp;
105428 }
105429
105430 static int perf_rotate_context(struct perf_cpu_context *cpuctx);
105431@@ -307,7 +314,7 @@ void perf_sample_event_took(u64 sample_len_ns)
105432 }
105433 }
105434
105435-static atomic64_t perf_event_id;
105436+static atomic64_unchecked_t perf_event_id;
105437
105438 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
105439 enum event_type_t event_type);
105440@@ -3753,9 +3760,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
105441 mutex_lock(&event->child_mutex);
105442 total += perf_event_read(event);
105443 *enabled += event->total_time_enabled +
105444- atomic64_read(&event->child_total_time_enabled);
105445+ atomic64_read_unchecked(&event->child_total_time_enabled);
105446 *running += event->total_time_running +
105447- atomic64_read(&event->child_total_time_running);
105448+ atomic64_read_unchecked(&event->child_total_time_running);
105449
105450 list_for_each_entry(child, &event->child_list, child_list) {
105451 total += perf_event_read(child);
105452@@ -4285,10 +4292,10 @@ void perf_event_update_userpage(struct perf_event *event)
105453 userpg->offset -= local64_read(&event->hw.prev_count);
105454
105455 userpg->time_enabled = enabled +
105456- atomic64_read(&event->child_total_time_enabled);
105457+ atomic64_read_unchecked(&event->child_total_time_enabled);
105458
105459 userpg->time_running = running +
105460- atomic64_read(&event->child_total_time_running);
105461+ atomic64_read_unchecked(&event->child_total_time_running);
105462
105463 arch_perf_update_userpage(event, userpg, now);
105464
105465@@ -4963,7 +4970,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
105466
105467 /* Data. */
105468 sp = perf_user_stack_pointer(regs);
105469- rem = __output_copy_user(handle, (void *) sp, dump_size);
105470+ rem = __output_copy_user(handle, (void __user *) sp, dump_size);
105471 dyn_size = dump_size - rem;
105472
105473 perf_output_skip(handle, rem);
105474@@ -5054,11 +5061,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
105475 values[n++] = perf_event_count(event);
105476 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
105477 values[n++] = enabled +
105478- atomic64_read(&event->child_total_time_enabled);
105479+ atomic64_read_unchecked(&event->child_total_time_enabled);
105480 }
105481 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
105482 values[n++] = running +
105483- atomic64_read(&event->child_total_time_running);
105484+ atomic64_read_unchecked(&event->child_total_time_running);
105485 }
105486 if (read_format & PERF_FORMAT_ID)
105487 values[n++] = primary_event_id(event);
105488@@ -7588,7 +7595,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
105489 event->parent = parent_event;
105490
105491 event->ns = get_pid_ns(task_active_pid_ns(current));
105492- event->id = atomic64_inc_return(&perf_event_id);
105493+ event->id = atomic64_inc_return_unchecked(&perf_event_id);
105494
105495 event->state = PERF_EVENT_STATE_INACTIVE;
105496
105497@@ -7947,6 +7954,11 @@ SYSCALL_DEFINE5(perf_event_open,
105498 if (flags & ~PERF_FLAG_ALL)
105499 return -EINVAL;
105500
105501+#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
105502+ if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
105503+ return -EACCES;
105504+#endif
105505+
105506 err = perf_copy_attr(attr_uptr, &attr);
105507 if (err)
105508 return err;
105509@@ -8395,10 +8407,10 @@ static void sync_child_event(struct perf_event *child_event,
105510 /*
105511 * Add back the child's count to the parent's count:
105512 */
105513- atomic64_add(child_val, &parent_event->child_count);
105514- atomic64_add(child_event->total_time_enabled,
105515+ atomic64_add_unchecked(child_val, &parent_event->child_count);
105516+ atomic64_add_unchecked(child_event->total_time_enabled,
105517 &parent_event->child_total_time_enabled);
105518- atomic64_add(child_event->total_time_running,
105519+ atomic64_add_unchecked(child_event->total_time_running,
105520 &parent_event->child_total_time_running);
105521
105522 /*
105523diff --git a/kernel/events/internal.h b/kernel/events/internal.h
105524index 2bbad9c..056f20c 100644
105525--- a/kernel/events/internal.h
105526+++ b/kernel/events/internal.h
105527@@ -115,10 +115,10 @@ static inline unsigned long perf_aux_size(struct ring_buffer *rb)
105528 return rb->aux_nr_pages << PAGE_SHIFT;
105529 }
105530
105531-#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
105532+#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
105533 static inline unsigned long \
105534 func_name(struct perf_output_handle *handle, \
105535- const void *buf, unsigned long len) \
105536+ const void user *buf, unsigned long len) \
105537 { \
105538 unsigned long size, written; \
105539 \
105540@@ -151,7 +151,7 @@ memcpy_common(void *dst, const void *src, unsigned long n)
105541 return 0;
105542 }
105543
105544-DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
105545+DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
105546
105547 static inline unsigned long
105548 memcpy_skip(void *dst, const void *src, unsigned long n)
105549@@ -159,7 +159,7 @@ memcpy_skip(void *dst, const void *src, unsigned long n)
105550 return 0;
105551 }
105552
105553-DEFINE_OUTPUT_COPY(__output_skip, memcpy_skip)
105554+DEFINE_OUTPUT_COPY(__output_skip, memcpy_skip, )
105555
105556 #ifndef arch_perf_out_copy_user
105557 #define arch_perf_out_copy_user arch_perf_out_copy_user
105558@@ -177,7 +177,7 @@ arch_perf_out_copy_user(void *dst, const void *src, unsigned long n)
105559 }
105560 #endif
105561
105562-DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
105563+DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
105564
105565 /* Callchain handling */
105566 extern struct perf_callchain_entry *
105567diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
105568index cb346f2..e4dc317 100644
105569--- a/kernel/events/uprobes.c
105570+++ b/kernel/events/uprobes.c
105571@@ -1670,7 +1670,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
105572 {
105573 struct page *page;
105574 uprobe_opcode_t opcode;
105575- int result;
105576+ long result;
105577
105578 pagefault_disable();
105579 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
105580diff --git a/kernel/exit.c b/kernel/exit.c
105581index 031325e..c6342c4 100644
105582--- a/kernel/exit.c
105583+++ b/kernel/exit.c
105584@@ -171,6 +171,10 @@ void release_task(struct task_struct *p)
105585 struct task_struct *leader;
105586 int zap_leader;
105587 repeat:
105588+#ifdef CONFIG_NET
105589+ gr_del_task_from_ip_table(p);
105590+#endif
105591+
105592 /* don't need to get the RCU readlock here - the process is dead and
105593 * can't be modifying its own credentials. But shut RCU-lockdep up */
105594 rcu_read_lock();
105595@@ -656,6 +660,8 @@ void do_exit(long code)
105596 int group_dead;
105597 TASKS_RCU(int tasks_rcu_i);
105598
105599+ set_fs(USER_DS);
105600+
105601 profile_task_exit(tsk);
105602
105603 WARN_ON(blk_needs_flush_plug(tsk));
105604@@ -672,7 +678,6 @@ void do_exit(long code)
105605 * mm_release()->clear_child_tid() from writing to a user-controlled
105606 * kernel address.
105607 */
105608- set_fs(USER_DS);
105609
105610 ptrace_event(PTRACE_EVENT_EXIT, code);
105611
105612@@ -730,6 +735,9 @@ void do_exit(long code)
105613 tsk->exit_code = code;
105614 taskstats_exit(tsk, group_dead);
105615
105616+ gr_acl_handle_psacct(tsk, code);
105617+ gr_acl_handle_exit();
105618+
105619 exit_mm(tsk);
105620
105621 if (group_dead)
105622@@ -847,7 +855,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
105623 * Take down every thread in the group. This is called by fatal signals
105624 * as well as by sys_exit_group (below).
105625 */
105626-void
105627+__noreturn void
105628 do_group_exit(int exit_code)
105629 {
105630 struct signal_struct *sig = current->signal;
105631diff --git a/kernel/fork.c b/kernel/fork.c
105632index e769c8c..9fa1de5 100644
105633--- a/kernel/fork.c
105634+++ b/kernel/fork.c
105635@@ -188,12 +188,54 @@ static void free_thread_info(struct thread_info *ti)
105636 void thread_info_cache_init(void)
105637 {
105638 thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE,
105639- THREAD_SIZE, 0, NULL);
105640+ THREAD_SIZE, SLAB_USERCOPY, NULL);
105641 BUG_ON(thread_info_cache == NULL);
105642 }
105643 # endif
105644 #endif
105645
105646+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
105647+static inline struct thread_info *gr_alloc_thread_info_node(struct task_struct *tsk,
105648+ int node, void **lowmem_stack)
105649+{
105650+ struct page *pages[THREAD_SIZE / PAGE_SIZE];
105651+ void *ret = NULL;
105652+ unsigned int i;
105653+
105654+ *lowmem_stack = alloc_thread_info_node(tsk, node);
105655+ if (*lowmem_stack == NULL)
105656+ goto out;
105657+
105658+ for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++)
105659+ pages[i] = virt_to_page(*lowmem_stack + (i * PAGE_SIZE));
105660+
105661+ /* use VM_IOREMAP to gain THREAD_SIZE alignment */
105662+ ret = vmap(pages, THREAD_SIZE / PAGE_SIZE, VM_IOREMAP, PAGE_KERNEL);
105663+ if (ret == NULL) {
105664+ free_thread_info(*lowmem_stack);
105665+ *lowmem_stack = NULL;
105666+ }
105667+
105668+out:
105669+ return ret;
105670+}
105671+
105672+static inline void gr_free_thread_info(struct task_struct *tsk, struct thread_info *ti)
105673+{
105674+ unmap_process_stacks(tsk);
105675+}
105676+#else
105677+static inline struct thread_info *gr_alloc_thread_info_node(struct task_struct *tsk,
105678+ int node, void **lowmem_stack)
105679+{
105680+ return alloc_thread_info_node(tsk, node);
105681+}
105682+static inline void gr_free_thread_info(struct task_struct *tsk, struct thread_info *ti)
105683+{
105684+ free_thread_info(ti);
105685+}
105686+#endif
105687+
105688 /* SLAB cache for signal_struct structures (tsk->signal) */
105689 static struct kmem_cache *signal_cachep;
105690
105691@@ -212,18 +254,22 @@ struct kmem_cache *vm_area_cachep;
105692 /* SLAB cache for mm_struct structures (tsk->mm) */
105693 static struct kmem_cache *mm_cachep;
105694
105695-static void account_kernel_stack(struct thread_info *ti, int account)
105696+static void account_kernel_stack(struct task_struct *tsk, struct thread_info *ti, int account)
105697 {
105698+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
105699+ struct zone *zone = page_zone(virt_to_page(tsk->lowmem_stack));
105700+#else
105701 struct zone *zone = page_zone(virt_to_page(ti));
105702+#endif
105703
105704 mod_zone_page_state(zone, NR_KERNEL_STACK, account);
105705 }
105706
105707 void free_task(struct task_struct *tsk)
105708 {
105709- account_kernel_stack(tsk->stack, -1);
105710+ account_kernel_stack(tsk, tsk->stack, -1);
105711 arch_release_thread_info(tsk->stack);
105712- free_thread_info(tsk->stack);
105713+ gr_free_thread_info(tsk, tsk->stack);
105714 rt_mutex_debug_task_free(tsk);
105715 ftrace_graph_exit_task(tsk);
105716 put_seccomp_filter(tsk);
105717@@ -289,7 +335,7 @@ static void set_max_threads(unsigned int max_threads_suggested)
105718
105719 #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT
105720 /* Initialized by the architecture: */
105721-int arch_task_struct_size __read_mostly;
105722+size_t arch_task_struct_size __read_mostly;
105723 #endif
105724
105725 void __init fork_init(void)
105726@@ -334,6 +380,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
105727 {
105728 struct task_struct *tsk;
105729 struct thread_info *ti;
105730+ void *lowmem_stack;
105731 int node = tsk_fork_get_node(orig);
105732 int err;
105733
105734@@ -341,7 +388,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
105735 if (!tsk)
105736 return NULL;
105737
105738- ti = alloc_thread_info_node(tsk, node);
105739+ ti = gr_alloc_thread_info_node(tsk, node, &lowmem_stack);
105740 if (!ti)
105741 goto free_tsk;
105742
105743@@ -350,6 +397,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
105744 goto free_ti;
105745
105746 tsk->stack = ti;
105747+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
105748+ tsk->lowmem_stack = lowmem_stack;
105749+#endif
105750 #ifdef CONFIG_SECCOMP
105751 /*
105752 * We must handle setting up seccomp filters once we're under
105753@@ -366,7 +416,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
105754 set_task_stack_end_magic(tsk);
105755
105756 #ifdef CONFIG_CC_STACKPROTECTOR
105757- tsk->stack_canary = get_random_int();
105758+ tsk->stack_canary = pax_get_random_long();
105759 #endif
105760
105761 /*
105762@@ -380,24 +430,89 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
105763 tsk->splice_pipe = NULL;
105764 tsk->task_frag.page = NULL;
105765
105766- account_kernel_stack(ti, 1);
105767+ account_kernel_stack(tsk, ti, 1);
105768
105769 return tsk;
105770
105771 free_ti:
105772- free_thread_info(ti);
105773+ gr_free_thread_info(tsk, ti);
105774 free_tsk:
105775 free_task_struct(tsk);
105776 return NULL;
105777 }
105778
105779 #ifdef CONFIG_MMU
105780-static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
105781+static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
105782+{
105783+ struct vm_area_struct *tmp;
105784+ unsigned long charge;
105785+ struct file *file;
105786+ int retval;
105787+
105788+ charge = 0;
105789+ if (mpnt->vm_flags & VM_ACCOUNT) {
105790+ unsigned long len = vma_pages(mpnt);
105791+
105792+ if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
105793+ goto fail_nomem;
105794+ charge = len;
105795+ }
105796+ tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
105797+ if (!tmp)
105798+ goto fail_nomem;
105799+ *tmp = *mpnt;
105800+ tmp->vm_mm = mm;
105801+ INIT_LIST_HEAD(&tmp->anon_vma_chain);
105802+ retval = vma_dup_policy(mpnt, tmp);
105803+ if (retval)
105804+ goto fail_nomem_policy;
105805+ if (anon_vma_fork(tmp, mpnt))
105806+ goto fail_nomem_anon_vma_fork;
105807+ tmp->vm_flags &= ~VM_LOCKED;
105808+ tmp->vm_next = tmp->vm_prev = NULL;
105809+ tmp->vm_mirror = NULL;
105810+ file = tmp->vm_file;
105811+ if (file) {
105812+ struct inode *inode = file_inode(file);
105813+ struct address_space *mapping = file->f_mapping;
105814+
105815+ get_file(file);
105816+ if (tmp->vm_flags & VM_DENYWRITE)
105817+ atomic_dec(&inode->i_writecount);
105818+ i_mmap_lock_write(mapping);
105819+ if (tmp->vm_flags & VM_SHARED)
105820+ atomic_inc(&mapping->i_mmap_writable);
105821+ flush_dcache_mmap_lock(mapping);
105822+ /* insert tmp into the share list, just after mpnt */
105823+ vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
105824+ flush_dcache_mmap_unlock(mapping);
105825+ i_mmap_unlock_write(mapping);
105826+ }
105827+
105828+ /*
105829+ * Clear hugetlb-related page reserves for children. This only
105830+ * affects MAP_PRIVATE mappings. Faults generated by the child
105831+ * are not guaranteed to succeed, even if read-only
105832+ */
105833+ if (is_vm_hugetlb_page(tmp))
105834+ reset_vma_resv_huge_pages(tmp);
105835+
105836+ return tmp;
105837+
105838+fail_nomem_anon_vma_fork:
105839+ mpol_put(vma_policy(tmp));
105840+fail_nomem_policy:
105841+ kmem_cache_free(vm_area_cachep, tmp);
105842+fail_nomem:
105843+ vm_unacct_memory(charge);
105844+ return NULL;
105845+}
105846+
105847+static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
105848 {
105849 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
105850 struct rb_node **rb_link, *rb_parent;
105851 int retval;
105852- unsigned long charge;
105853
105854 uprobe_start_dup_mmap();
105855 down_write(&oldmm->mmap_sem);
105856@@ -428,51 +543,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
105857
105858 prev = NULL;
105859 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
105860- struct file *file;
105861-
105862 if (mpnt->vm_flags & VM_DONTCOPY) {
105863 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
105864 -vma_pages(mpnt));
105865 continue;
105866 }
105867- charge = 0;
105868- if (mpnt->vm_flags & VM_ACCOUNT) {
105869- unsigned long len = vma_pages(mpnt);
105870-
105871- if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
105872- goto fail_nomem;
105873- charge = len;
105874- }
105875- tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
105876- if (!tmp)
105877- goto fail_nomem;
105878- *tmp = *mpnt;
105879- INIT_LIST_HEAD(&tmp->anon_vma_chain);
105880- retval = vma_dup_policy(mpnt, tmp);
105881- if (retval)
105882- goto fail_nomem_policy;
105883- tmp->vm_mm = mm;
105884- if (anon_vma_fork(tmp, mpnt))
105885- goto fail_nomem_anon_vma_fork;
105886- tmp->vm_flags &= ~VM_LOCKED;
105887- tmp->vm_next = tmp->vm_prev = NULL;
105888- file = tmp->vm_file;
105889- if (file) {
105890- struct inode *inode = file_inode(file);
105891- struct address_space *mapping = file->f_mapping;
105892-
105893- get_file(file);
105894- if (tmp->vm_flags & VM_DENYWRITE)
105895- atomic_dec(&inode->i_writecount);
105896- i_mmap_lock_write(mapping);
105897- if (tmp->vm_flags & VM_SHARED)
105898- atomic_inc(&mapping->i_mmap_writable);
105899- flush_dcache_mmap_lock(mapping);
105900- /* insert tmp into the share list, just after mpnt */
105901- vma_interval_tree_insert_after(tmp, mpnt,
105902- &mapping->i_mmap);
105903- flush_dcache_mmap_unlock(mapping);
105904- i_mmap_unlock_write(mapping);
105905+ tmp = dup_vma(mm, oldmm, mpnt);
105906+ if (!tmp) {
105907+ retval = -ENOMEM;
105908+ goto out;
105909 }
105910
105911 /*
105912@@ -504,6 +583,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
105913 if (retval)
105914 goto out;
105915 }
105916+
105917+#ifdef CONFIG_PAX_SEGMEXEC
105918+ if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
105919+ struct vm_area_struct *mpnt_m;
105920+
105921+ for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
105922+ BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
105923+
105924+ if (!mpnt->vm_mirror)
105925+ continue;
105926+
105927+ if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
105928+ BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
105929+ mpnt->vm_mirror = mpnt_m;
105930+ } else {
105931+ BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
105932+ mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
105933+ mpnt_m->vm_mirror->vm_mirror = mpnt_m;
105934+ mpnt->vm_mirror->vm_mirror = mpnt;
105935+ }
105936+ }
105937+ BUG_ON(mpnt_m);
105938+ }
105939+#endif
105940+
105941 /* a new mm has just been created */
105942 arch_dup_mmap(oldmm, mm);
105943 retval = 0;
105944@@ -513,14 +617,6 @@ out:
105945 up_write(&oldmm->mmap_sem);
105946 uprobe_end_dup_mmap();
105947 return retval;
105948-fail_nomem_anon_vma_fork:
105949- mpol_put(vma_policy(tmp));
105950-fail_nomem_policy:
105951- kmem_cache_free(vm_area_cachep, tmp);
105952-fail_nomem:
105953- retval = -ENOMEM;
105954- vm_unacct_memory(charge);
105955- goto out;
105956 }
105957
105958 static inline int mm_alloc_pgd(struct mm_struct *mm)
105959@@ -795,8 +891,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
105960 return ERR_PTR(err);
105961
105962 mm = get_task_mm(task);
105963- if (mm && mm != current->mm &&
105964- !ptrace_may_access(task, mode)) {
105965+ if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
105966+ (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
105967 mmput(mm);
105968 mm = ERR_PTR(-EACCES);
105969 }
105970@@ -997,13 +1093,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
105971 spin_unlock(&fs->lock);
105972 return -EAGAIN;
105973 }
105974- fs->users++;
105975+ atomic_inc(&fs->users);
105976 spin_unlock(&fs->lock);
105977 return 0;
105978 }
105979 tsk->fs = copy_fs_struct(fs);
105980 if (!tsk->fs)
105981 return -ENOMEM;
105982+ /* Carry through gr_chroot_dentry and is_chrooted instead
105983+ of recomputing it here. Already copied when the task struct
105984+ is duplicated. This allows pivot_root to not be treated as
105985+ a chroot
105986+ */
105987+ //gr_set_chroot_entries(tsk, &tsk->fs->root);
105988+
105989 return 0;
105990 }
105991
105992@@ -1238,7 +1341,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
105993 * parts of the process environment (as per the clone
105994 * flags). The actual kick-off is left to the caller.
105995 */
105996-static struct task_struct *copy_process(unsigned long clone_flags,
105997+static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
105998 unsigned long stack_start,
105999 unsigned long stack_size,
106000 int __user *child_tidptr,
106001@@ -1310,6 +1413,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
106002 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
106003 #endif
106004 retval = -EAGAIN;
106005+
106006+ gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
106007+
106008 if (atomic_read(&p->real_cred->user->processes) >=
106009 task_rlimit(p, RLIMIT_NPROC)) {
106010 if (p->real_cred->user != INIT_USER &&
106011@@ -1560,6 +1666,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
106012 goto bad_fork_free_pid;
106013 }
106014
106015+ /* synchronizes with gr_set_acls()
106016+ we need to call this past the point of no return for fork()
106017+ */
106018+ gr_copy_label(p);
106019+
106020 if (likely(p->pid)) {
106021 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
106022
106023@@ -1649,6 +1760,8 @@ bad_fork_cleanup_count:
106024 bad_fork_free:
106025 free_task(p);
106026 fork_out:
106027+ gr_log_forkfail(retval);
106028+
106029 return ERR_PTR(retval);
106030 }
106031
106032@@ -1711,6 +1824,7 @@ long _do_fork(unsigned long clone_flags,
106033
106034 p = copy_process(clone_flags, stack_start, stack_size,
106035 child_tidptr, NULL, trace, tls);
106036+ add_latent_entropy();
106037 /*
106038 * Do this prior waking up the new thread - the thread pointer
106039 * might get invalid after that point, if the thread exits quickly.
106040@@ -1727,6 +1841,8 @@ long _do_fork(unsigned long clone_flags,
106041 if (clone_flags & CLONE_PARENT_SETTID)
106042 put_user(nr, parent_tidptr);
106043
106044+ gr_handle_brute_check();
106045+
106046 if (clone_flags & CLONE_VFORK) {
106047 p->vfork_done = &vfork;
106048 init_completion(&vfork);
106049@@ -1859,7 +1975,7 @@ void __init proc_caches_init(void)
106050 mm_cachep = kmem_cache_create("mm_struct",
106051 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
106052 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
106053- vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
106054+ vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
106055 mmap_init();
106056 nsproxy_cache_init();
106057 }
106058@@ -1907,7 +2023,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
106059 return 0;
106060
106061 /* don't need lock here; in the worst case we'll do useless copy */
106062- if (fs->users == 1)
106063+ if (atomic_read(&fs->users) == 1)
106064 return 0;
106065
106066 *new_fsp = copy_fs_struct(fs);
106067@@ -2019,7 +2135,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
106068 fs = current->fs;
106069 spin_lock(&fs->lock);
106070 current->fs = new_fs;
106071- if (--fs->users)
106072+ gr_set_chroot_entries(current, &current->fs->root);
106073+ if (atomic_dec_return(&fs->users))
106074 new_fs = NULL;
106075 else
106076 new_fs = fs;
106077@@ -2083,7 +2200,7 @@ int unshare_files(struct files_struct **displaced)
106078 int sysctl_max_threads(struct ctl_table *table, int write,
106079 void __user *buffer, size_t *lenp, loff_t *ppos)
106080 {
106081- struct ctl_table t;
106082+ ctl_table_no_const t;
106083 int ret;
106084 int threads = max_threads;
106085 int min = MIN_THREADS;
106086diff --git a/kernel/futex.c b/kernel/futex.c
106087index c4a182f..e789324 100644
106088--- a/kernel/futex.c
106089+++ b/kernel/futex.c
106090@@ -201,7 +201,7 @@ struct futex_pi_state {
106091 atomic_t refcount;
106092
106093 union futex_key key;
106094-};
106095+} __randomize_layout;
106096
106097 /**
106098 * struct futex_q - The hashed futex queue entry, one per waiting task
106099@@ -235,7 +235,7 @@ struct futex_q {
106100 struct rt_mutex_waiter *rt_waiter;
106101 union futex_key *requeue_pi_key;
106102 u32 bitset;
106103-};
106104+} __randomize_layout;
106105
106106 static const struct futex_q futex_q_init = {
106107 /* list gets initialized in queue_me()*/
106108@@ -402,6 +402,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
106109 struct page *page, *page_head;
106110 int err, ro = 0;
106111
106112+#ifdef CONFIG_PAX_SEGMEXEC
106113+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
106114+ return -EFAULT;
106115+#endif
106116+
106117 /*
106118 * The futex address must be "naturally" aligned.
106119 */
106120@@ -601,7 +606,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
106121
106122 static int get_futex_value_locked(u32 *dest, u32 __user *from)
106123 {
106124- int ret;
106125+ unsigned long ret;
106126
106127 pagefault_disable();
106128 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
106129@@ -3030,6 +3035,7 @@ static void __init futex_detect_cmpxchg(void)
106130 {
106131 #ifndef CONFIG_HAVE_FUTEX_CMPXCHG
106132 u32 curval;
106133+ mm_segment_t oldfs;
106134
106135 /*
106136 * This will fail and we want it. Some arch implementations do
106137@@ -3041,8 +3047,11 @@ static void __init futex_detect_cmpxchg(void)
106138 * implementation, the non-functional ones will return
106139 * -ENOSYS.
106140 */
106141+ oldfs = get_fs();
106142+ set_fs(USER_DS);
106143 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
106144 futex_cmpxchg_enabled = 1;
106145+ set_fs(oldfs);
106146 #endif
106147 }
106148
106149diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
106150index 55c8c93..9ba7ad6 100644
106151--- a/kernel/futex_compat.c
106152+++ b/kernel/futex_compat.c
106153@@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
106154 return 0;
106155 }
106156
106157-static void __user *futex_uaddr(struct robust_list __user *entry,
106158+static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
106159 compat_long_t futex_offset)
106160 {
106161 compat_uptr_t base = ptr_to_compat(entry);
106162diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
106163index 7080ae1..c9b3761 100644
106164--- a/kernel/gcov/base.c
106165+++ b/kernel/gcov/base.c
106166@@ -123,11 +123,6 @@ void gcov_enable_events(void)
106167 }
106168
106169 #ifdef CONFIG_MODULES
106170-static inline int within(void *addr, void *start, unsigned long size)
106171-{
106172- return ((addr >= start) && (addr < start + size));
106173-}
106174-
106175 /* Update list and generate events when modules are unloaded. */
106176 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
106177 void *data)
106178@@ -142,7 +137,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
106179
106180 /* Remove entries located in module from linked list. */
106181 while ((info = gcov_info_next(info))) {
106182- if (within(info, mod->module_core, mod->core_size)) {
106183+ if (within_module_core_rw((unsigned long)info, mod)) {
106184 gcov_info_unlink(prev, info);
106185 if (gcov_events_enabled)
106186 gcov_event(GCOV_REMOVE, info);
106187diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
106188index f974485..c5b8afd 100644
106189--- a/kernel/irq/manage.c
106190+++ b/kernel/irq/manage.c
106191@@ -937,7 +937,7 @@ static int irq_thread(void *data)
106192
106193 action_ret = handler_fn(desc, action);
106194 if (action_ret == IRQ_HANDLED)
106195- atomic_inc(&desc->threads_handled);
106196+ atomic_inc_unchecked(&desc->threads_handled);
106197
106198 wake_threads_waitq(desc);
106199 }
106200diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
106201index 7bf1f1b..d73e508 100644
106202--- a/kernel/irq/msi.c
106203+++ b/kernel/irq/msi.c
106204@@ -195,16 +195,18 @@ static void msi_domain_update_dom_ops(struct msi_domain_info *info)
106205 return;
106206 }
106207
106208+ pax_open_kernel();
106209 if (ops->get_hwirq == NULL)
106210- ops->get_hwirq = msi_domain_ops_default.get_hwirq;
106211+ *(void **)&ops->get_hwirq = msi_domain_ops_default.get_hwirq;
106212 if (ops->msi_init == NULL)
106213- ops->msi_init = msi_domain_ops_default.msi_init;
106214+ *(void **)&ops->msi_init = msi_domain_ops_default.msi_init;
106215 if (ops->msi_check == NULL)
106216- ops->msi_check = msi_domain_ops_default.msi_check;
106217+ *(void **)&ops->msi_check = msi_domain_ops_default.msi_check;
106218 if (ops->msi_prepare == NULL)
106219- ops->msi_prepare = msi_domain_ops_default.msi_prepare;
106220+ *(void **)&ops->msi_prepare = msi_domain_ops_default.msi_prepare;
106221 if (ops->set_desc == NULL)
106222- ops->set_desc = msi_domain_ops_default.set_desc;
106223+ *(void **)&ops->set_desc = msi_domain_ops_default.set_desc;
106224+ pax_close_kernel();
106225 }
106226
106227 static void msi_domain_update_chip_ops(struct msi_domain_info *info)
106228@@ -212,12 +214,14 @@ static void msi_domain_update_chip_ops(struct msi_domain_info *info)
106229 struct irq_chip *chip = info->chip;
106230
106231 BUG_ON(!chip);
106232+ pax_open_kernel();
106233 if (!chip->irq_mask)
106234- chip->irq_mask = pci_msi_mask_irq;
106235+ *(void **)&chip->irq_mask = pci_msi_mask_irq;
106236 if (!chip->irq_unmask)
106237- chip->irq_unmask = pci_msi_unmask_irq;
106238+ *(void **)&chip->irq_unmask = pci_msi_unmask_irq;
106239 if (!chip->irq_set_affinity)
106240- chip->irq_set_affinity = msi_domain_set_affinity;
106241+ *(void **)&chip->irq_set_affinity = msi_domain_set_affinity;
106242+ pax_close_kernel();
106243 }
106244
106245 /**
106246diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
106247index e2514b0..de3dfe0 100644
106248--- a/kernel/irq/spurious.c
106249+++ b/kernel/irq/spurious.c
106250@@ -337,7 +337,7 @@ void note_interrupt(unsigned int irq, struct irq_desc *desc,
106251 * count. We just care about the count being
106252 * different than the one we saw before.
106253 */
106254- handled = atomic_read(&desc->threads_handled);
106255+ handled = atomic_read_unchecked(&desc->threads_handled);
106256 handled |= SPURIOUS_DEFERRED;
106257 if (handled != desc->threads_handled_last) {
106258 action_ret = IRQ_HANDLED;
106259diff --git a/kernel/jump_label.c b/kernel/jump_label.c
106260index 52ebaca..ec6f5cb 100644
106261--- a/kernel/jump_label.c
106262+++ b/kernel/jump_label.c
106263@@ -14,6 +14,7 @@
106264 #include <linux/err.h>
106265 #include <linux/static_key.h>
106266 #include <linux/jump_label_ratelimit.h>
106267+#include <linux/mm.h>
106268
106269 #ifdef HAVE_JUMP_LABEL
106270
106271@@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
106272
106273 size = (((unsigned long)stop - (unsigned long)start)
106274 / sizeof(struct jump_entry));
106275+ pax_open_kernel();
106276 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
106277+ pax_close_kernel();
106278 }
106279
106280 static void jump_label_update(struct static_key *key, int enable);
106281@@ -363,10 +366,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
106282 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
106283 struct jump_entry *iter;
106284
106285+ pax_open_kernel();
106286 for (iter = iter_start; iter < iter_stop; iter++) {
106287 if (within_module_init(iter->code, mod))
106288 iter->code = 0;
106289 }
106290+ pax_close_kernel();
106291 }
106292
106293 static int
106294diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
106295index 5c5987f..bc502b0 100644
106296--- a/kernel/kallsyms.c
106297+++ b/kernel/kallsyms.c
106298@@ -11,6 +11,9 @@
106299 * Changed the compression method from stem compression to "table lookup"
106300 * compression (see scripts/kallsyms.c for a more complete description)
106301 */
106302+#ifdef CONFIG_GRKERNSEC_HIDESYM
106303+#define __INCLUDED_BY_HIDESYM 1
106304+#endif
106305 #include <linux/kallsyms.h>
106306 #include <linux/module.h>
106307 #include <linux/init.h>
106308@@ -54,12 +57,33 @@ extern const unsigned long kallsyms_markers[] __weak;
106309
106310 static inline int is_kernel_inittext(unsigned long addr)
106311 {
106312+ if (system_state != SYSTEM_BOOTING)
106313+ return 0;
106314+
106315 if (addr >= (unsigned long)_sinittext
106316 && addr <= (unsigned long)_einittext)
106317 return 1;
106318 return 0;
106319 }
106320
106321+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
106322+#ifdef CONFIG_MODULES
106323+static inline int is_module_text(unsigned long addr)
106324+{
106325+ if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
106326+ return 1;
106327+
106328+ addr = ktla_ktva(addr);
106329+ return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
106330+}
106331+#else
106332+static inline int is_module_text(unsigned long addr)
106333+{
106334+ return 0;
106335+}
106336+#endif
106337+#endif
106338+
106339 static inline int is_kernel_text(unsigned long addr)
106340 {
106341 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
106342@@ -70,13 +94,28 @@ static inline int is_kernel_text(unsigned long addr)
106343
106344 static inline int is_kernel(unsigned long addr)
106345 {
106346+
106347+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
106348+ if (is_kernel_text(addr) || is_kernel_inittext(addr))
106349+ return 1;
106350+
106351+ if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
106352+#else
106353 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
106354+#endif
106355+
106356 return 1;
106357 return in_gate_area_no_mm(addr);
106358 }
106359
106360 static int is_ksym_addr(unsigned long addr)
106361 {
106362+
106363+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
106364+ if (is_module_text(addr))
106365+ return 0;
106366+#endif
106367+
106368 if (all_var)
106369 return is_kernel(addr);
106370
106371@@ -481,7 +520,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
106372
106373 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
106374 {
106375- iter->name[0] = '\0';
106376 iter->nameoff = get_symbol_offset(new_pos);
106377 iter->pos = new_pos;
106378 }
106379@@ -529,6 +567,11 @@ static int s_show(struct seq_file *m, void *p)
106380 {
106381 struct kallsym_iter *iter = m->private;
106382
106383+#ifdef CONFIG_GRKERNSEC_HIDESYM
106384+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
106385+ return 0;
106386+#endif
106387+
106388 /* Some debugging symbols have no name. Ignore them. */
106389 if (!iter->name[0])
106390 return 0;
106391@@ -542,6 +585,7 @@ static int s_show(struct seq_file *m, void *p)
106392 */
106393 type = iter->exported ? toupper(iter->type) :
106394 tolower(iter->type);
106395+
106396 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
106397 type, iter->name, iter->module_name);
106398 } else
106399diff --git a/kernel/kcmp.c b/kernel/kcmp.c
106400index 0aa69ea..a7fcafb 100644
106401--- a/kernel/kcmp.c
106402+++ b/kernel/kcmp.c
106403@@ -100,6 +100,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
106404 struct task_struct *task1, *task2;
106405 int ret;
106406
106407+#ifdef CONFIG_GRKERNSEC
106408+ return -ENOSYS;
106409+#endif
106410+
106411 rcu_read_lock();
106412
106413 /*
106414diff --git a/kernel/kexec.c b/kernel/kexec.c
106415index a785c10..6dbb06f 100644
106416--- a/kernel/kexec.c
106417+++ b/kernel/kexec.c
106418@@ -1243,7 +1243,7 @@ static int kimage_load_segment(struct kimage *image,
106419 */
106420 struct kimage *kexec_image;
106421 struct kimage *kexec_crash_image;
106422-int kexec_load_disabled;
106423+int kexec_load_disabled __read_only;
106424
106425 static DEFINE_MUTEX(kexec_mutex);
106426
106427@@ -1359,7 +1359,8 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,
106428 compat_ulong_t, flags)
106429 {
106430 struct compat_kexec_segment in;
106431- struct kexec_segment out, __user *ksegments;
106432+ struct kexec_segment out;
106433+ struct kexec_segment __user *ksegments;
106434 unsigned long i, result;
106435
106436 /* Don't allow clients that don't understand the native
106437diff --git a/kernel/kmod.c b/kernel/kmod.c
106438index 2777f40..a689506 100644
106439--- a/kernel/kmod.c
106440+++ b/kernel/kmod.c
106441@@ -68,7 +68,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
106442 kfree(info->argv);
106443 }
106444
106445-static int call_modprobe(char *module_name, int wait)
106446+static int call_modprobe(char *module_name, char *module_param, int wait)
106447 {
106448 struct subprocess_info *info;
106449 static char *envp[] = {
106450@@ -78,7 +78,7 @@ static int call_modprobe(char *module_name, int wait)
106451 NULL
106452 };
106453
106454- char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
106455+ char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
106456 if (!argv)
106457 goto out;
106458
106459@@ -90,7 +90,8 @@ static int call_modprobe(char *module_name, int wait)
106460 argv[1] = "-q";
106461 argv[2] = "--";
106462 argv[3] = module_name; /* check free_modprobe_argv() */
106463- argv[4] = NULL;
106464+ argv[4] = module_param;
106465+ argv[5] = NULL;
106466
106467 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
106468 NULL, free_modprobe_argv, NULL);
106469@@ -122,9 +123,8 @@ out:
106470 * If module auto-loading support is disabled then this function
106471 * becomes a no-operation.
106472 */
106473-int __request_module(bool wait, const char *fmt, ...)
106474+static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
106475 {
106476- va_list args;
106477 char module_name[MODULE_NAME_LEN];
106478 unsigned int max_modprobes;
106479 int ret;
106480@@ -143,9 +143,7 @@ int __request_module(bool wait, const char *fmt, ...)
106481 if (!modprobe_path[0])
106482 return 0;
106483
106484- va_start(args, fmt);
106485- ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
106486- va_end(args);
106487+ ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
106488 if (ret >= MODULE_NAME_LEN)
106489 return -ENAMETOOLONG;
106490
106491@@ -153,6 +151,20 @@ int __request_module(bool wait, const char *fmt, ...)
106492 if (ret)
106493 return ret;
106494
106495+#ifdef CONFIG_GRKERNSEC_MODHARDEN
106496+ if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
106497+ /* hack to workaround consolekit/udisks stupidity */
106498+ read_lock(&tasklist_lock);
106499+ if (!strcmp(current->comm, "mount") &&
106500+ current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
106501+ read_unlock(&tasklist_lock);
106502+ printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
106503+ return -EPERM;
106504+ }
106505+ read_unlock(&tasklist_lock);
106506+ }
106507+#endif
106508+
106509 /* If modprobe needs a service that is in a module, we get a recursive
106510 * loop. Limit the number of running kmod threads to max_threads/2 or
106511 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
106512@@ -181,16 +193,61 @@ int __request_module(bool wait, const char *fmt, ...)
106513
106514 trace_module_request(module_name, wait, _RET_IP_);
106515
106516- ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
106517+ ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
106518
106519 atomic_dec(&kmod_concurrent);
106520 return ret;
106521 }
106522+
106523+int ___request_module(bool wait, char *module_param, const char *fmt, ...)
106524+{
106525+ va_list args;
106526+ int ret;
106527+
106528+ va_start(args, fmt);
106529+ ret = ____request_module(wait, module_param, fmt, args);
106530+ va_end(args);
106531+
106532+ return ret;
106533+}
106534+
106535+int __request_module(bool wait, const char *fmt, ...)
106536+{
106537+ va_list args;
106538+ int ret;
106539+
106540+#ifdef CONFIG_GRKERNSEC_MODHARDEN
106541+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
106542+ char module_param[MODULE_NAME_LEN];
106543+
106544+ memset(module_param, 0, sizeof(module_param));
106545+
106546+ snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
106547+
106548+ va_start(args, fmt);
106549+ ret = ____request_module(wait, module_param, fmt, args);
106550+ va_end(args);
106551+
106552+ return ret;
106553+ }
106554+#endif
106555+
106556+ va_start(args, fmt);
106557+ ret = ____request_module(wait, NULL, fmt, args);
106558+ va_end(args);
106559+
106560+ return ret;
106561+}
106562+
106563 EXPORT_SYMBOL(__request_module);
106564 #endif /* CONFIG_MODULES */
106565
106566 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
106567 {
106568+#ifdef CONFIG_GRKERNSEC
106569+ kfree(info->path);
106570+ info->path = info->origpath;
106571+#endif
106572 if (info->cleanup)
106573 (*info->cleanup)(info);
106574 kfree(info);
106575@@ -232,6 +289,21 @@ static int ____call_usermodehelper(void *data)
106576 */
106577 set_user_nice(current, 0);
106578
106579+#ifdef CONFIG_GRKERNSEC
106580+ /* this is race-free as far as userland is concerned as we copied
106581+ out the path to be used prior to this point and are now operating
106582+ on that copy
106583+ */
106584+ if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/", 9) &&
106585+ strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7) &&
106586+ strncmp(sub_info->path, "/usr/libexec/", 13) && strncmp(sub_info->path, "/usr/bin/", 9) &&
106587+ strcmp(sub_info->path, "/usr/share/apport/apport")) || strstr(sub_info->path, "..")) {
106588+ printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of permitted system paths\n", sub_info->path);
106589+ retval = -EPERM;
106590+ goto out;
106591+ }
106592+#endif
106593+
106594 retval = -ENOMEM;
106595 new = prepare_kernel_cred(current);
106596 if (!new)
106597@@ -254,8 +326,8 @@ static int ____call_usermodehelper(void *data)
106598 commit_creds(new);
106599
106600 retval = do_execve(getname_kernel(sub_info->path),
106601- (const char __user *const __user *)sub_info->argv,
106602- (const char __user *const __user *)sub_info->envp);
106603+ (const char __user *const __force_user *)sub_info->argv,
106604+ (const char __user *const __force_user *)sub_info->envp);
106605 out:
106606 sub_info->retval = retval;
106607 /* wait_for_helper() will call umh_complete if UHM_WAIT_PROC. */
106608@@ -288,7 +360,7 @@ static int wait_for_helper(void *data)
106609 *
106610 * Thus the __user pointer cast is valid here.
106611 */
106612- sys_wait4(pid, (int __user *)&ret, 0, NULL);
106613+ sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
106614
106615 /*
106616 * If ret is 0, either ____call_usermodehelper failed and the
106617@@ -510,7 +582,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
106618 goto out;
106619
106620 INIT_WORK(&sub_info->work, __call_usermodehelper);
106621+#ifdef CONFIG_GRKERNSEC
106622+ sub_info->origpath = path;
106623+ sub_info->path = kstrdup(path, gfp_mask);
106624+#else
106625 sub_info->path = path;
106626+#endif
106627 sub_info->argv = argv;
106628 sub_info->envp = envp;
106629
106630@@ -612,7 +689,7 @@ EXPORT_SYMBOL(call_usermodehelper);
106631 static int proc_cap_handler(struct ctl_table *table, int write,
106632 void __user *buffer, size_t *lenp, loff_t *ppos)
106633 {
106634- struct ctl_table t;
106635+ ctl_table_no_const t;
106636 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
106637 kernel_cap_t new_cap;
106638 int err, i;
106639diff --git a/kernel/kprobes.c b/kernel/kprobes.c
106640index c90e417..e6c515d 100644
106641--- a/kernel/kprobes.c
106642+++ b/kernel/kprobes.c
106643@@ -31,6 +31,9 @@
106644 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
106645 * <prasanna@in.ibm.com> added function-return probes.
106646 */
106647+#ifdef CONFIG_GRKERNSEC_HIDESYM
106648+#define __INCLUDED_BY_HIDESYM 1
106649+#endif
106650 #include <linux/kprobes.h>
106651 #include <linux/hash.h>
106652 #include <linux/init.h>
106653@@ -122,12 +125,12 @@ enum kprobe_slot_state {
106654
106655 static void *alloc_insn_page(void)
106656 {
106657- return module_alloc(PAGE_SIZE);
106658+ return module_alloc_exec(PAGE_SIZE);
106659 }
106660
106661 static void free_insn_page(void *page)
106662 {
106663- module_memfree(page);
106664+ module_memfree_exec(page);
106665 }
106666
106667 struct kprobe_insn_cache kprobe_insn_slots = {
106668@@ -2198,11 +2201,11 @@ static void report_probe(struct seq_file *pi, struct kprobe *p,
106669 kprobe_type = "k";
106670
106671 if (sym)
106672- seq_printf(pi, "%p %s %s+0x%x %s ",
106673+ seq_printf(pi, "%pK %s %s+0x%x %s ",
106674 p->addr, kprobe_type, sym, offset,
106675 (modname ? modname : " "));
106676 else
106677- seq_printf(pi, "%p %s %p ",
106678+ seq_printf(pi, "%pK %s %pK ",
106679 p->addr, kprobe_type, p->addr);
106680
106681 if (!pp)
106682diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
106683index 6683cce..daf8999 100644
106684--- a/kernel/ksysfs.c
106685+++ b/kernel/ksysfs.c
106686@@ -50,6 +50,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
106687 {
106688 if (count+1 > UEVENT_HELPER_PATH_LEN)
106689 return -ENOENT;
106690+ if (!capable(CAP_SYS_ADMIN))
106691+ return -EPERM;
106692 memcpy(uevent_helper, buf, count);
106693 uevent_helper[count] = '\0';
106694 if (count && uevent_helper[count-1] == '\n')
106695@@ -176,7 +178,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
106696 return count;
106697 }
106698
106699-static struct bin_attribute notes_attr = {
106700+static bin_attribute_no_const notes_attr __read_only = {
106701 .attr = {
106702 .name = "notes",
106703 .mode = S_IRUGO,
106704diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
106705index 8acfbf7..0c5a34a 100644
106706--- a/kernel/locking/lockdep.c
106707+++ b/kernel/locking/lockdep.c
106708@@ -613,6 +613,10 @@ static int static_obj(void *obj)
106709 end = (unsigned long) &_end,
106710 addr = (unsigned long) obj;
106711
106712+#ifdef CONFIG_PAX_KERNEXEC
106713+ start = ktla_ktva(start);
106714+#endif
106715+
106716 /*
106717 * static variable?
106718 */
106719@@ -757,6 +761,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
106720 if (!static_obj(lock->key)) {
106721 debug_locks_off();
106722 printk("INFO: trying to register non-static key.\n");
106723+ printk("lock:%pS key:%pS.\n", lock, lock->key);
106724 printk("the code is fine but needs lockdep annotation.\n");
106725 printk("turning off the locking correctness validator.\n");
106726 dump_stack();
106727@@ -3102,7 +3107,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
106728 if (!class)
106729 return 0;
106730 }
106731- atomic_inc((atomic_t *)&class->ops);
106732+ atomic_long_inc_unchecked((atomic_long_unchecked_t *)&class->ops);
106733 if (very_verbose(class)) {
106734 printk("\nacquire class [%p] %s", class->key, class->name);
106735 if (class->name_version > 1)
106736diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
106737index d83d798..ea3120d 100644
106738--- a/kernel/locking/lockdep_proc.c
106739+++ b/kernel/locking/lockdep_proc.c
106740@@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
106741 return 0;
106742 }
106743
106744- seq_printf(m, "%p", class->key);
106745+ seq_printf(m, "%pK", class->key);
106746 #ifdef CONFIG_DEBUG_LOCKDEP
106747 seq_printf(m, " OPS:%8ld", class->ops);
106748 #endif
106749@@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
106750
106751 list_for_each_entry(entry, &class->locks_after, entry) {
106752 if (entry->distance == 1) {
106753- seq_printf(m, " -> [%p] ", entry->class->key);
106754+ seq_printf(m, " -> [%pK] ", entry->class->key);
106755 print_name(m, entry->class);
106756 seq_puts(m, "\n");
106757 }
106758@@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
106759 if (!class->key)
106760 continue;
106761
106762- seq_printf(m, "[%p] ", class->key);
106763+ seq_printf(m, "[%pK] ", class->key);
106764 print_name(m, class);
106765 seq_puts(m, "\n");
106766 }
106767@@ -508,7 +508,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
106768 if (!i)
106769 seq_line(m, '-', 40-namelen, namelen);
106770
106771- snprintf(ip, sizeof(ip), "[<%p>]",
106772+ snprintf(ip, sizeof(ip), "[<%pK>]",
106773 (void *)class->contention_point[i]);
106774 seq_printf(m, "%40s %14lu %29s %pS\n",
106775 name, stats->contention_point[i],
106776@@ -523,7 +523,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
106777 if (!i)
106778 seq_line(m, '-', 40-namelen, namelen);
106779
106780- snprintf(ip, sizeof(ip), "[<%p>]",
106781+ snprintf(ip, sizeof(ip), "[<%pK>]",
106782 (void *)class->contending_point[i]);
106783 seq_printf(m, "%40s %14lu %29s %pS\n",
106784 name, stats->contending_point[i],
106785diff --git a/kernel/locking/mutex-debug.c b/kernel/locking/mutex-debug.c
106786index 3ef3736..9c951fa 100644
106787--- a/kernel/locking/mutex-debug.c
106788+++ b/kernel/locking/mutex-debug.c
106789@@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
106790 }
106791
106792 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
106793- struct thread_info *ti)
106794+ struct task_struct *task)
106795 {
106796 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
106797
106798 /* Mark the current thread as blocked on the lock: */
106799- ti->task->blocked_on = waiter;
106800+ task->blocked_on = waiter;
106801 }
106802
106803 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
106804- struct thread_info *ti)
106805+ struct task_struct *task)
106806 {
106807 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
106808- DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
106809- DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
106810- ti->task->blocked_on = NULL;
106811+ DEBUG_LOCKS_WARN_ON(waiter->task != task);
106812+ DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
106813+ task->blocked_on = NULL;
106814
106815 list_del_init(&waiter->list);
106816 waiter->task = NULL;
106817diff --git a/kernel/locking/mutex-debug.h b/kernel/locking/mutex-debug.h
106818index 0799fd3..d06ae3b 100644
106819--- a/kernel/locking/mutex-debug.h
106820+++ b/kernel/locking/mutex-debug.h
106821@@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
106822 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
106823 extern void debug_mutex_add_waiter(struct mutex *lock,
106824 struct mutex_waiter *waiter,
106825- struct thread_info *ti);
106826+ struct task_struct *task);
106827 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
106828- struct thread_info *ti);
106829+ struct task_struct *task);
106830 extern void debug_mutex_unlock(struct mutex *lock);
106831 extern void debug_mutex_init(struct mutex *lock, const char *name,
106832 struct lock_class_key *key);
106833diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
106834index 4cccea6..4382db9 100644
106835--- a/kernel/locking/mutex.c
106836+++ b/kernel/locking/mutex.c
106837@@ -533,7 +533,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
106838 goto skip_wait;
106839
106840 debug_mutex_lock_common(lock, &waiter);
106841- debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
106842+ debug_mutex_add_waiter(lock, &waiter, task);
106843
106844 /* add waiting tasks to the end of the waitqueue (FIFO): */
106845 list_add_tail(&waiter.list, &lock->wait_list);
106846@@ -580,7 +580,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
106847 }
106848 __set_task_state(task, TASK_RUNNING);
106849
106850- mutex_remove_waiter(lock, &waiter, current_thread_info());
106851+ mutex_remove_waiter(lock, &waiter, task);
106852 /* set it to 0 if there are no waiters left: */
106853 if (likely(list_empty(&lock->wait_list)))
106854 atomic_set(&lock->count, 0);
106855@@ -601,7 +601,7 @@ skip_wait:
106856 return 0;
106857
106858 err:
106859- mutex_remove_waiter(lock, &waiter, task_thread_info(task));
106860+ mutex_remove_waiter(lock, &waiter, task);
106861 spin_unlock_mutex(&lock->wait_lock, flags);
106862 debug_mutex_free_waiter(&waiter);
106863 mutex_release(&lock->dep_map, 1, ip);
106864diff --git a/kernel/locking/rtmutex-tester.c b/kernel/locking/rtmutex-tester.c
106865index 1d96dd0..994ff19 100644
106866--- a/kernel/locking/rtmutex-tester.c
106867+++ b/kernel/locking/rtmutex-tester.c
106868@@ -22,7 +22,7 @@
106869 #define MAX_RT_TEST_MUTEXES 8
106870
106871 static spinlock_t rttest_lock;
106872-static atomic_t rttest_event;
106873+static atomic_unchecked_t rttest_event;
106874
106875 struct test_thread_data {
106876 int opcode;
106877@@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
106878
106879 case RTTEST_LOCKCONT:
106880 td->mutexes[td->opdata] = 1;
106881- td->event = atomic_add_return(1, &rttest_event);
106882+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106883 return 0;
106884
106885 case RTTEST_RESET:
106886@@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
106887 return 0;
106888
106889 case RTTEST_RESETEVENT:
106890- atomic_set(&rttest_event, 0);
106891+ atomic_set_unchecked(&rttest_event, 0);
106892 return 0;
106893
106894 default:
106895@@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
106896 return ret;
106897
106898 td->mutexes[id] = 1;
106899- td->event = atomic_add_return(1, &rttest_event);
106900+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106901 rt_mutex_lock(&mutexes[id]);
106902- td->event = atomic_add_return(1, &rttest_event);
106903+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106904 td->mutexes[id] = 4;
106905 return 0;
106906
106907@@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
106908 return ret;
106909
106910 td->mutexes[id] = 1;
106911- td->event = atomic_add_return(1, &rttest_event);
106912+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106913 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
106914- td->event = atomic_add_return(1, &rttest_event);
106915+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106916 td->mutexes[id] = ret ? 0 : 4;
106917 return ret ? -EINTR : 0;
106918
106919@@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
106920 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
106921 return ret;
106922
106923- td->event = atomic_add_return(1, &rttest_event);
106924+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106925 rt_mutex_unlock(&mutexes[id]);
106926- td->event = atomic_add_return(1, &rttest_event);
106927+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106928 td->mutexes[id] = 0;
106929 return 0;
106930
106931@@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
106932 break;
106933
106934 td->mutexes[dat] = 2;
106935- td->event = atomic_add_return(1, &rttest_event);
106936+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106937 break;
106938
106939 default:
106940@@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
106941 return;
106942
106943 td->mutexes[dat] = 3;
106944- td->event = atomic_add_return(1, &rttest_event);
106945+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106946 break;
106947
106948 case RTTEST_LOCKNOWAIT:
106949@@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
106950 return;
106951
106952 td->mutexes[dat] = 1;
106953- td->event = atomic_add_return(1, &rttest_event);
106954+ td->event = atomic_add_return_unchecked(1, &rttest_event);
106955 return;
106956
106957 default:
106958diff --git a/kernel/module.c b/kernel/module.c
106959index b86b7bf..f5eaa56 100644
106960--- a/kernel/module.c
106961+++ b/kernel/module.c
106962@@ -59,6 +59,7 @@
106963 #include <linux/jump_label.h>
106964 #include <linux/pfn.h>
106965 #include <linux/bsearch.h>
106966+#include <linux/grsecurity.h>
106967 #include <uapi/linux/module.h>
106968 #include "module-internal.h"
106969
106970@@ -108,7 +109,7 @@ static LIST_HEAD(modules);
106971 * Use a latched RB-tree for __module_address(); this allows us to use
106972 * RCU-sched lookups of the address from any context.
106973 *
106974- * Because modules have two address ranges: init and core, we need two
106975+ * Because modules have four address ranges: init_{rw,rx} and core_{rw,rx}, we need four
106976 * latch_tree_nodes entries. Therefore we need the back-pointer from
106977 * mod_tree_node.
106978 *
106979@@ -125,10 +126,14 @@ static __always_inline unsigned long __mod_tree_val(struct latch_tree_node *n)
106980 struct mod_tree_node *mtn = container_of(n, struct mod_tree_node, node);
106981 struct module *mod = mtn->mod;
106982
106983- if (unlikely(mtn == &mod->mtn_init))
106984- return (unsigned long)mod->module_init;
106985+ if (unlikely(mtn == &mod->mtn_init_rw))
106986+ return (unsigned long)mod->module_init_rw;
106987+ if (unlikely(mtn == &mod->mtn_init_rx))
106988+ return (unsigned long)mod->module_init_rx;
106989
106990- return (unsigned long)mod->module_core;
106991+ if (unlikely(mtn == &mod->mtn_core_rw))
106992+ return (unsigned long)mod->module_core_rw;
106993+ return (unsigned long)mod->module_core_rx;
106994 }
106995
106996 static __always_inline unsigned long __mod_tree_size(struct latch_tree_node *n)
106997@@ -136,10 +141,14 @@ static __always_inline unsigned long __mod_tree_size(struct latch_tree_node *n)
106998 struct mod_tree_node *mtn = container_of(n, struct mod_tree_node, node);
106999 struct module *mod = mtn->mod;
107000
107001- if (unlikely(mtn == &mod->mtn_init))
107002- return (unsigned long)mod->init_size;
107003+ if (unlikely(mtn == &mod->mtn_init_rw))
107004+ return (unsigned long)mod->init_size_rw;
107005+ if (unlikely(mtn == &mod->mtn_init_rx))
107006+ return (unsigned long)mod->init_size_rx;
107007
107008- return (unsigned long)mod->core_size;
107009+ if (unlikely(mtn == &mod->mtn_core_rw))
107010+ return (unsigned long)mod->core_size_rw;
107011+ return (unsigned long)mod->core_size_rx;
107012 }
107013
107014 static __always_inline bool
107015@@ -172,14 +181,19 @@ static const struct latch_tree_ops mod_tree_ops = {
107016
107017 static struct mod_tree_root {
107018 struct latch_tree_root root;
107019- unsigned long addr_min;
107020- unsigned long addr_max;
107021+ unsigned long addr_min_rw;
107022+ unsigned long addr_min_rx;
107023+ unsigned long addr_max_rw;
107024+ unsigned long addr_max_rx;
107025 } mod_tree __cacheline_aligned = {
107026- .addr_min = -1UL,
107027+ .addr_min_rw = -1UL,
107028+ .addr_min_rx = -1UL,
107029 };
107030
107031-#define module_addr_min mod_tree.addr_min
107032-#define module_addr_max mod_tree.addr_max
107033+#define module_addr_min_rw mod_tree.addr_min_rw
107034+#define module_addr_min_rx mod_tree.addr_min_rx
107035+#define module_addr_max_rw mod_tree.addr_max_rw
107036+#define module_addr_max_rx mod_tree.addr_max_rx
107037
107038 static noinline void __mod_tree_insert(struct mod_tree_node *node)
107039 {
107040@@ -197,23 +211,31 @@ static void __mod_tree_remove(struct mod_tree_node *node)
107041 */
107042 static void mod_tree_insert(struct module *mod)
107043 {
107044- mod->mtn_core.mod = mod;
107045- mod->mtn_init.mod = mod;
107046+ mod->mtn_core_rw.mod = mod;
107047+ mod->mtn_core_rx.mod = mod;
107048+ mod->mtn_init_rw.mod = mod;
107049+ mod->mtn_init_rx.mod = mod;
107050
107051- __mod_tree_insert(&mod->mtn_core);
107052- if (mod->init_size)
107053- __mod_tree_insert(&mod->mtn_init);
107054+ __mod_tree_insert(&mod->mtn_core_rw);
107055+ __mod_tree_insert(&mod->mtn_core_rx);
107056+ if (mod->init_size_rw)
107057+ __mod_tree_insert(&mod->mtn_init_rw);
107058+ if (mod->init_size_rx)
107059+ __mod_tree_insert(&mod->mtn_init_rx);
107060 }
107061
107062 static void mod_tree_remove_init(struct module *mod)
107063 {
107064- if (mod->init_size)
107065- __mod_tree_remove(&mod->mtn_init);
107066+ if (mod->init_size_rw)
107067+ __mod_tree_remove(&mod->mtn_init_rw);
107068+ if (mod->init_size_rx)
107069+ __mod_tree_remove(&mod->mtn_init_rx);
107070 }
107071
107072 static void mod_tree_remove(struct module *mod)
107073 {
107074- __mod_tree_remove(&mod->mtn_core);
107075+ __mod_tree_remove(&mod->mtn_core_rw);
107076+ __mod_tree_remove(&mod->mtn_core_rx);
107077 mod_tree_remove_init(mod);
107078 }
107079
107080@@ -230,7 +252,8 @@ static struct module *mod_find(unsigned long addr)
107081
107082 #else /* MODULES_TREE_LOOKUP */
107083
107084-static unsigned long module_addr_min = -1UL, module_addr_max = 0;
107085+static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
107086+static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
107087
107088 static void mod_tree_insert(struct module *mod) { }
107089 static void mod_tree_remove_init(struct module *mod) { }
107090@@ -254,22 +277,36 @@ static struct module *mod_find(unsigned long addr)
107091 * Bounds of module text, for speeding up __module_address.
107092 * Protected by module_mutex.
107093 */
107094-static void __mod_update_bounds(void *base, unsigned int size)
107095+static void __mod_update_bounds_rw(void *base, unsigned int size)
107096 {
107097 unsigned long min = (unsigned long)base;
107098 unsigned long max = min + size;
107099
107100- if (min < module_addr_min)
107101- module_addr_min = min;
107102- if (max > module_addr_max)
107103- module_addr_max = max;
107104+ if (min < module_addr_min_rw)
107105+ module_addr_min_rw = min;
107106+ if (max > module_addr_max_rw)
107107+ module_addr_max_rw = max;
107108+}
107109+
107110+static void __mod_update_bounds_rx(void *base, unsigned int size)
107111+{
107112+ unsigned long min = (unsigned long)base;
107113+ unsigned long max = min + size;
107114+
107115+ if (min < module_addr_min_rx)
107116+ module_addr_min_rx = min;
107117+ if (max > module_addr_max_rx)
107118+ module_addr_max_rx = max;
107119 }
107120
107121 static void mod_update_bounds(struct module *mod)
107122 {
107123- __mod_update_bounds(mod->module_core, mod->core_size);
107124- if (mod->init_size)
107125- __mod_update_bounds(mod->module_init, mod->init_size);
107126+ __mod_update_bounds_rw(mod->module_core_rw, mod->core_size_rw);
107127+ __mod_update_bounds_rx(mod->module_core_rx, mod->core_size_rx);
107128+ if (mod->init_size_rw)
107129+ __mod_update_bounds_rw(mod->module_init_rw, mod->init_size_rw);
107130+ if (mod->init_size_rx)
107131+ __mod_update_bounds_rx(mod->module_init_rx, mod->init_size_rx);
107132 }
107133
107134 #ifdef CONFIG_KGDB_KDB
107135@@ -298,7 +335,7 @@ module_param(sig_enforce, bool_enable_only, 0644);
107136 #endif /* !CONFIG_MODULE_SIG_FORCE */
107137
107138 /* Block module loading/unloading? */
107139-int modules_disabled = 0;
107140+int modules_disabled __read_only = 0;
107141 core_param(nomodule, modules_disabled, bint, 0);
107142
107143 /* Waiting for a module to finish initializing? */
107144@@ -473,7 +510,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
107145 return true;
107146
107147 list_for_each_entry_rcu(mod, &modules, list) {
107148- struct symsearch arr[] = {
107149+ struct symsearch modarr[] = {
107150 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
107151 NOT_GPL_ONLY, false },
107152 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
107153@@ -498,7 +535,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
107154 if (mod->state == MODULE_STATE_UNFORMED)
107155 continue;
107156
107157- if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
107158+ if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
107159 return true;
107160 }
107161 return false;
107162@@ -644,7 +681,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
107163 if (!pcpusec->sh_size)
107164 return 0;
107165
107166- if (align > PAGE_SIZE) {
107167+ if (align-1 >= PAGE_SIZE) {
107168 pr_warn("%s: per-cpu alignment %li > %li\n",
107169 mod->name, align, PAGE_SIZE);
107170 align = PAGE_SIZE;
107171@@ -1210,7 +1247,7 @@ struct module_attribute module_uevent =
107172 static ssize_t show_coresize(struct module_attribute *mattr,
107173 struct module_kobject *mk, char *buffer)
107174 {
107175- return sprintf(buffer, "%u\n", mk->mod->core_size);
107176+ return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
107177 }
107178
107179 static struct module_attribute modinfo_coresize =
107180@@ -1219,7 +1256,7 @@ static struct module_attribute modinfo_coresize =
107181 static ssize_t show_initsize(struct module_attribute *mattr,
107182 struct module_kobject *mk, char *buffer)
107183 {
107184- return sprintf(buffer, "%u\n", mk->mod->init_size);
107185+ return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
107186 }
107187
107188 static struct module_attribute modinfo_initsize =
107189@@ -1311,12 +1348,29 @@ static int check_version(Elf_Shdr *sechdrs,
107190 goto bad_version;
107191 }
107192
107193+#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
107194+ /*
107195+ * avoid potentially printing jibberish on attempted load
107196+ * of a module randomized with a different seed
107197+ */
107198+ pr_warn("no symbol version for %s\n", symname);
107199+#else
107200 pr_warn("%s: no symbol version for %s\n", mod->name, symname);
107201+#endif
107202 return 0;
107203
107204 bad_version:
107205+#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
107206+ /*
107207+ * avoid potentially printing jibberish on attempted load
107208+ * of a module randomized with a different seed
107209+ */
107210+ pr_warn("attempted module disagrees about version of symbol %s\n",
107211+ symname);
107212+#else
107213 pr_warn("%s: disagrees about version of symbol %s\n",
107214 mod->name, symname);
107215+#endif
107216 return 0;
107217 }
107218
107219@@ -1444,7 +1498,7 @@ resolve_symbol_wait(struct module *mod,
107220 */
107221 #ifdef CONFIG_SYSFS
107222
107223-#ifdef CONFIG_KALLSYMS
107224+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
107225 static inline bool sect_empty(const Elf_Shdr *sect)
107226 {
107227 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
107228@@ -1582,7 +1636,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
107229 {
107230 unsigned int notes, loaded, i;
107231 struct module_notes_attrs *notes_attrs;
107232- struct bin_attribute *nattr;
107233+ bin_attribute_no_const *nattr;
107234
107235 /* failed to create section attributes, so can't create notes */
107236 if (!mod->sect_attrs)
107237@@ -1694,7 +1748,7 @@ static void del_usage_links(struct module *mod)
107238 static int module_add_modinfo_attrs(struct module *mod)
107239 {
107240 struct module_attribute *attr;
107241- struct module_attribute *temp_attr;
107242+ module_attribute_no_const *temp_attr;
107243 int error = 0;
107244 int i;
107245
107246@@ -1911,21 +1965,21 @@ static void set_section_ro_nx(void *base,
107247
107248 static void unset_module_core_ro_nx(struct module *mod)
107249 {
107250- set_page_attributes(mod->module_core + mod->core_text_size,
107251- mod->module_core + mod->core_size,
107252+ set_page_attributes(mod->module_core_rw,
107253+ mod->module_core_rw + mod->core_size_rw,
107254 set_memory_x);
107255- set_page_attributes(mod->module_core,
107256- mod->module_core + mod->core_ro_size,
107257+ set_page_attributes(mod->module_core_rx,
107258+ mod->module_core_rx + mod->core_size_rx,
107259 set_memory_rw);
107260 }
107261
107262 static void unset_module_init_ro_nx(struct module *mod)
107263 {
107264- set_page_attributes(mod->module_init + mod->init_text_size,
107265- mod->module_init + mod->init_size,
107266+ set_page_attributes(mod->module_init_rw,
107267+ mod->module_init_rw + mod->init_size_rw,
107268 set_memory_x);
107269- set_page_attributes(mod->module_init,
107270- mod->module_init + mod->init_ro_size,
107271+ set_page_attributes(mod->module_init_rx,
107272+ mod->module_init_rx + mod->init_size_rx,
107273 set_memory_rw);
107274 }
107275
107276@@ -1938,14 +1992,14 @@ void set_all_modules_text_rw(void)
107277 list_for_each_entry_rcu(mod, &modules, list) {
107278 if (mod->state == MODULE_STATE_UNFORMED)
107279 continue;
107280- if ((mod->module_core) && (mod->core_text_size)) {
107281- set_page_attributes(mod->module_core,
107282- mod->module_core + mod->core_text_size,
107283+ if ((mod->module_core_rx) && (mod->core_size_rx)) {
107284+ set_page_attributes(mod->module_core_rx,
107285+ mod->module_core_rx + mod->core_size_rx,
107286 set_memory_rw);
107287 }
107288- if ((mod->module_init) && (mod->init_text_size)) {
107289- set_page_attributes(mod->module_init,
107290- mod->module_init + mod->init_text_size,
107291+ if ((mod->module_init_rx) && (mod->init_size_rx)) {
107292+ set_page_attributes(mod->module_init_rx,
107293+ mod->module_init_rx + mod->init_size_rx,
107294 set_memory_rw);
107295 }
107296 }
107297@@ -1961,14 +2015,14 @@ void set_all_modules_text_ro(void)
107298 list_for_each_entry_rcu(mod, &modules, list) {
107299 if (mod->state == MODULE_STATE_UNFORMED)
107300 continue;
107301- if ((mod->module_core) && (mod->core_text_size)) {
107302- set_page_attributes(mod->module_core,
107303- mod->module_core + mod->core_text_size,
107304+ if ((mod->module_core_rx) && (mod->core_size_rx)) {
107305+ set_page_attributes(mod->module_core_rx,
107306+ mod->module_core_rx + mod->core_size_rx,
107307 set_memory_ro);
107308 }
107309- if ((mod->module_init) && (mod->init_text_size)) {
107310- set_page_attributes(mod->module_init,
107311- mod->module_init + mod->init_text_size,
107312+ if ((mod->module_init_rx) && (mod->init_size_rx)) {
107313+ set_page_attributes(mod->module_init_rx,
107314+ mod->module_init_rx + mod->init_size_rx,
107315 set_memory_ro);
107316 }
107317 }
107318@@ -1977,7 +2031,15 @@ void set_all_modules_text_ro(void)
107319 #else
107320 static inline void set_section_ro_nx(void *base, unsigned long text_size, unsigned long ro_size, unsigned long total_size) { }
107321 static void unset_module_core_ro_nx(struct module *mod) { }
107322-static void unset_module_init_ro_nx(struct module *mod) { }
107323+static void unset_module_init_ro_nx(struct module *mod)
107324+{
107325+
107326+#ifdef CONFIG_PAX_KERNEXEC
107327+ set_memory_nx((unsigned long)mod->module_init_rx, PFN_UP(mod->init_size_rx));
107328+ set_memory_rw((unsigned long)mod->module_init_rx, PFN_UP(mod->init_size_rx));
107329+#endif
107330+
107331+}
107332 #endif
107333
107334 void __weak module_memfree(void *module_region)
107335@@ -2032,16 +2094,19 @@ static void free_module(struct module *mod)
107336 /* This may be NULL, but that's OK */
107337 unset_module_init_ro_nx(mod);
107338 module_arch_freeing_init(mod);
107339- module_memfree(mod->module_init);
107340+ module_memfree(mod->module_init_rw);
107341+ module_memfree_exec(mod->module_init_rx);
107342 kfree(mod->args);
107343 percpu_modfree(mod);
107344
107345 /* Free lock-classes; relies on the preceding sync_rcu(). */
107346- lockdep_free_key_range(mod->module_core, mod->core_size);
107347+ lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
107348+ lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
107349
107350 /* Finally, free the core (containing the module structure) */
107351 unset_module_core_ro_nx(mod);
107352- module_memfree(mod->module_core);
107353+ module_memfree_exec(mod->module_core_rx);
107354+ module_memfree(mod->module_core_rw);
107355
107356 #ifdef CONFIG_MPU
107357 update_protections(current->mm);
107358@@ -2110,9 +2175,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
107359 int ret = 0;
107360 const struct kernel_symbol *ksym;
107361
107362+#ifdef CONFIG_GRKERNSEC_MODHARDEN
107363+ int is_fs_load = 0;
107364+ int register_filesystem_found = 0;
107365+ char *p;
107366+
107367+ p = strstr(mod->args, "grsec_modharden_fs");
107368+ if (p) {
107369+ char *endptr = p + sizeof("grsec_modharden_fs") - 1;
107370+ /* copy \0 as well */
107371+ memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
107372+ is_fs_load = 1;
107373+ }
107374+#endif
107375+
107376 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
107377 const char *name = info->strtab + sym[i].st_name;
107378
107379+#ifdef CONFIG_GRKERNSEC_MODHARDEN
107380+ /* it's a real shame this will never get ripped and copied
107381+ upstream! ;(
107382+ */
107383+ if (is_fs_load && !strcmp(name, "register_filesystem"))
107384+ register_filesystem_found = 1;
107385+#endif
107386+
107387 switch (sym[i].st_shndx) {
107388 case SHN_COMMON:
107389 /* Ignore common symbols */
107390@@ -2137,7 +2224,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
107391 ksym = resolve_symbol_wait(mod, info, name);
107392 /* Ok if resolved. */
107393 if (ksym && !IS_ERR(ksym)) {
107394+ pax_open_kernel();
107395 sym[i].st_value = ksym->value;
107396+ pax_close_kernel();
107397 break;
107398 }
107399
107400@@ -2156,11 +2245,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
107401 secbase = (unsigned long)mod_percpu(mod);
107402 else
107403 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
107404+ pax_open_kernel();
107405 sym[i].st_value += secbase;
107406+ pax_close_kernel();
107407 break;
107408 }
107409 }
107410
107411+#ifdef CONFIG_GRKERNSEC_MODHARDEN
107412+ if (is_fs_load && !register_filesystem_found) {
107413+ printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
107414+ ret = -EPERM;
107415+ }
107416+#endif
107417+
107418 return ret;
107419 }
107420
107421@@ -2244,22 +2342,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
107422 || s->sh_entsize != ~0UL
107423 || strstarts(sname, ".init"))
107424 continue;
107425- s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
107426+ if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
107427+ s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
107428+ else
107429+ s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
107430 pr_debug("\t%s\n", sname);
107431 }
107432- switch (m) {
107433- case 0: /* executable */
107434- mod->core_size = debug_align(mod->core_size);
107435- mod->core_text_size = mod->core_size;
107436- break;
107437- case 1: /* RO: text and ro-data */
107438- mod->core_size = debug_align(mod->core_size);
107439- mod->core_ro_size = mod->core_size;
107440- break;
107441- case 3: /* whole core */
107442- mod->core_size = debug_align(mod->core_size);
107443- break;
107444- }
107445 }
107446
107447 pr_debug("Init section allocation order:\n");
107448@@ -2273,23 +2361,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
107449 || s->sh_entsize != ~0UL
107450 || !strstarts(sname, ".init"))
107451 continue;
107452- s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
107453- | INIT_OFFSET_MASK);
107454+ if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
107455+ s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
107456+ else
107457+ s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
107458+ s->sh_entsize |= INIT_OFFSET_MASK;
107459 pr_debug("\t%s\n", sname);
107460 }
107461- switch (m) {
107462- case 0: /* executable */
107463- mod->init_size = debug_align(mod->init_size);
107464- mod->init_text_size = mod->init_size;
107465- break;
107466- case 1: /* RO: text and ro-data */
107467- mod->init_size = debug_align(mod->init_size);
107468- mod->init_ro_size = mod->init_size;
107469- break;
107470- case 3: /* whole init */
107471- mod->init_size = debug_align(mod->init_size);
107472- break;
107473- }
107474 }
107475 }
107476
107477@@ -2462,7 +2540,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
107478
107479 /* Put symbol section at end of init part of module. */
107480 symsect->sh_flags |= SHF_ALLOC;
107481- symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
107482+ symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
107483 info->index.sym) | INIT_OFFSET_MASK;
107484 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
107485
107486@@ -2479,16 +2557,16 @@ static void layout_symtab(struct module *mod, struct load_info *info)
107487 }
107488
107489 /* Append room for core symbols at end of core part. */
107490- info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
107491- info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
107492- mod->core_size += strtab_size;
107493- mod->core_size = debug_align(mod->core_size);
107494+ info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
107495+ info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
107496+ mod->core_size_rx += strtab_size;
107497+ mod->core_size_rx = debug_align(mod->core_size_rx);
107498
107499 /* Put string table section at end of init part of module. */
107500 strsect->sh_flags |= SHF_ALLOC;
107501- strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
107502+ strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
107503 info->index.str) | INIT_OFFSET_MASK;
107504- mod->init_size = debug_align(mod->init_size);
107505+ mod->init_size_rx = debug_align(mod->init_size_rx);
107506 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
107507 }
107508
107509@@ -2505,12 +2583,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
107510 /* Make sure we get permanent strtab: don't use info->strtab. */
107511 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
107512
107513+ pax_open_kernel();
107514+
107515 /* Set types up while we still have access to sections. */
107516 for (i = 0; i < mod->num_symtab; i++)
107517 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
107518
107519- mod->core_symtab = dst = mod->module_core + info->symoffs;
107520- mod->core_strtab = s = mod->module_core + info->stroffs;
107521+ mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
107522+ mod->core_strtab = s = mod->module_core_rx + info->stroffs;
107523 src = mod->symtab;
107524 for (ndst = i = 0; i < mod->num_symtab; i++) {
107525 if (i == 0 ||
107526@@ -2522,6 +2602,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
107527 }
107528 }
107529 mod->core_num_syms = ndst;
107530+
107531+ pax_close_kernel();
107532 }
107533 #else
107534 static inline void layout_symtab(struct module *mod, struct load_info *info)
107535@@ -2821,7 +2903,15 @@ static struct module *setup_load_info(struct load_info *info, int flags)
107536 mod = (void *)info->sechdrs[info->index.mod].sh_addr;
107537
107538 if (info->index.sym == 0) {
107539+#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
107540+ /*
107541+ * avoid potentially printing jibberish on attempted load
107542+ * of a module randomized with a different seed
107543+ */
107544+ pr_warn("module has no symbols (stripped?)\n");
107545+#else
107546 pr_warn("%s: module has no symbols (stripped?)\n", mod->name);
107547+#endif
107548 return ERR_PTR(-ENOEXEC);
107549 }
107550
107551@@ -2837,8 +2927,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
107552 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
107553 {
107554 const char *modmagic = get_modinfo(info, "vermagic");
107555+ const char *license = get_modinfo(info, "license");
107556 int err;
107557
107558+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
107559+ if (!license || !license_is_gpl_compatible(license))
107560+ return -ENOEXEC;
107561+#endif
107562+
107563 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
107564 modmagic = NULL;
107565
107566@@ -2863,7 +2959,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
107567 }
107568
107569 /* Set up license info based on the info section */
107570- set_license(mod, get_modinfo(info, "license"));
107571+ set_license(mod, license);
107572
107573 return 0;
107574 }
107575@@ -2960,7 +3056,7 @@ static int move_module(struct module *mod, struct load_info *info)
107576 void *ptr;
107577
107578 /* Do the allocs. */
107579- ptr = module_alloc(mod->core_size);
107580+ ptr = module_alloc(mod->core_size_rw);
107581 /*
107582 * The pointer to this block is stored in the module structure
107583 * which is inside the block. Just mark it as not being a
107584@@ -2970,11 +3066,11 @@ static int move_module(struct module *mod, struct load_info *info)
107585 if (!ptr)
107586 return -ENOMEM;
107587
107588- memset(ptr, 0, mod->core_size);
107589- mod->module_core = ptr;
107590+ memset(ptr, 0, mod->core_size_rw);
107591+ mod->module_core_rw = ptr;
107592
107593- if (mod->init_size) {
107594- ptr = module_alloc(mod->init_size);
107595+ if (mod->init_size_rw) {
107596+ ptr = module_alloc(mod->init_size_rw);
107597 /*
107598 * The pointer to this block is stored in the module structure
107599 * which is inside the block. This block doesn't need to be
107600@@ -2983,13 +3079,45 @@ static int move_module(struct module *mod, struct load_info *info)
107601 */
107602 kmemleak_ignore(ptr);
107603 if (!ptr) {
107604- module_memfree(mod->module_core);
107605+ module_memfree(mod->module_core_rw);
107606 return -ENOMEM;
107607 }
107608- memset(ptr, 0, mod->init_size);
107609- mod->module_init = ptr;
107610+ memset(ptr, 0, mod->init_size_rw);
107611+ mod->module_init_rw = ptr;
107612 } else
107613- mod->module_init = NULL;
107614+ mod->module_init_rw = NULL;
107615+
107616+ ptr = module_alloc_exec(mod->core_size_rx);
107617+ kmemleak_not_leak(ptr);
107618+ if (!ptr) {
107619+ if (mod->module_init_rw)
107620+ module_memfree(mod->module_init_rw);
107621+ module_memfree(mod->module_core_rw);
107622+ return -ENOMEM;
107623+ }
107624+
107625+ pax_open_kernel();
107626+ memset(ptr, 0, mod->core_size_rx);
107627+ pax_close_kernel();
107628+ mod->module_core_rx = ptr;
107629+
107630+ if (mod->init_size_rx) {
107631+ ptr = module_alloc_exec(mod->init_size_rx);
107632+ kmemleak_ignore(ptr);
107633+ if (!ptr && mod->init_size_rx) {
107634+ module_memfree_exec(mod->module_core_rx);
107635+ if (mod->module_init_rw)
107636+ module_memfree(mod->module_init_rw);
107637+ module_memfree(mod->module_core_rw);
107638+ return -ENOMEM;
107639+ }
107640+
107641+ pax_open_kernel();
107642+ memset(ptr, 0, mod->init_size_rx);
107643+ pax_close_kernel();
107644+ mod->module_init_rx = ptr;
107645+ } else
107646+ mod->module_init_rx = NULL;
107647
107648 /* Transfer each section which specifies SHF_ALLOC */
107649 pr_debug("final section addresses:\n");
107650@@ -3000,16 +3128,45 @@ static int move_module(struct module *mod, struct load_info *info)
107651 if (!(shdr->sh_flags & SHF_ALLOC))
107652 continue;
107653
107654- if (shdr->sh_entsize & INIT_OFFSET_MASK)
107655- dest = mod->module_init
107656- + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
107657- else
107658- dest = mod->module_core + shdr->sh_entsize;
107659+ if (shdr->sh_entsize & INIT_OFFSET_MASK) {
107660+ if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
107661+ dest = mod->module_init_rw
107662+ + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
107663+ else
107664+ dest = mod->module_init_rx
107665+ + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
107666+ } else {
107667+ if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
107668+ dest = mod->module_core_rw + shdr->sh_entsize;
107669+ else
107670+ dest = mod->module_core_rx + shdr->sh_entsize;
107671+ }
107672+
107673+ if (shdr->sh_type != SHT_NOBITS) {
107674+
107675+#ifdef CONFIG_PAX_KERNEXEC
107676+#ifdef CONFIG_X86_64
107677+ if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
107678+ set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
107679+#endif
107680+ if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
107681+ pax_open_kernel();
107682+ memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
107683+ pax_close_kernel();
107684+ } else
107685+#endif
107686
107687- if (shdr->sh_type != SHT_NOBITS)
107688 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
107689+ }
107690 /* Update sh_addr to point to copy in image. */
107691- shdr->sh_addr = (unsigned long)dest;
107692+
107693+#ifdef CONFIG_PAX_KERNEXEC
107694+ if (shdr->sh_flags & SHF_EXECINSTR)
107695+ shdr->sh_addr = ktva_ktla((unsigned long)dest);
107696+ else
107697+#endif
107698+
107699+ shdr->sh_addr = (unsigned long)dest;
107700 pr_debug("\t0x%lx %s\n",
107701 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
107702 }
107703@@ -3066,12 +3223,12 @@ static void flush_module_icache(const struct module *mod)
107704 * Do it before processing of module parameters, so the module
107705 * can provide parameter accessor functions of its own.
107706 */
107707- if (mod->module_init)
107708- flush_icache_range((unsigned long)mod->module_init,
107709- (unsigned long)mod->module_init
107710- + mod->init_size);
107711- flush_icache_range((unsigned long)mod->module_core,
107712- (unsigned long)mod->module_core + mod->core_size);
107713+ if (mod->module_init_rx)
107714+ flush_icache_range((unsigned long)mod->module_init_rx,
107715+ (unsigned long)mod->module_init_rx
107716+ + mod->init_size_rx);
107717+ flush_icache_range((unsigned long)mod->module_core_rx,
107718+ (unsigned long)mod->module_core_rx + mod->core_size_rx);
107719
107720 set_fs(old_fs);
107721 }
107722@@ -3129,8 +3286,10 @@ static void module_deallocate(struct module *mod, struct load_info *info)
107723 {
107724 percpu_modfree(mod);
107725 module_arch_freeing_init(mod);
107726- module_memfree(mod->module_init);
107727- module_memfree(mod->module_core);
107728+ module_memfree_exec(mod->module_init_rx);
107729+ module_memfree_exec(mod->module_core_rx);
107730+ module_memfree(mod->module_init_rw);
107731+ module_memfree(mod->module_core_rw);
107732 }
107733
107734 int __weak module_finalize(const Elf_Ehdr *hdr,
107735@@ -3143,7 +3302,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
107736 static int post_relocation(struct module *mod, const struct load_info *info)
107737 {
107738 /* Sort exception table now relocations are done. */
107739+ pax_open_kernel();
107740 sort_extable(mod->extable, mod->extable + mod->num_exentries);
107741+ pax_close_kernel();
107742
107743 /* Copy relocated percpu area over. */
107744 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
107745@@ -3191,13 +3352,15 @@ static void do_mod_ctors(struct module *mod)
107746 /* For freeing module_init on success, in case kallsyms traversing */
107747 struct mod_initfree {
107748 struct rcu_head rcu;
107749- void *module_init;
107750+ void *module_init_rw;
107751+ void *module_init_rx;
107752 };
107753
107754 static void do_free_init(struct rcu_head *head)
107755 {
107756 struct mod_initfree *m = container_of(head, struct mod_initfree, rcu);
107757- module_memfree(m->module_init);
107758+ module_memfree(m->module_init_rw);
107759+ module_memfree_exec(m->module_init_rx);
107760 kfree(m);
107761 }
107762
107763@@ -3217,7 +3380,8 @@ static noinline int do_init_module(struct module *mod)
107764 ret = -ENOMEM;
107765 goto fail;
107766 }
107767- freeinit->module_init = mod->module_init;
107768+ freeinit->module_init_rw = mod->module_init_rw;
107769+ freeinit->module_init_rx = mod->module_init_rx;
107770
107771 /*
107772 * We want to find out whether @mod uses async during init. Clear
107773@@ -3277,10 +3441,10 @@ static noinline int do_init_module(struct module *mod)
107774 mod_tree_remove_init(mod);
107775 unset_module_init_ro_nx(mod);
107776 module_arch_freeing_init(mod);
107777- mod->module_init = NULL;
107778- mod->init_size = 0;
107779- mod->init_ro_size = 0;
107780- mod->init_text_size = 0;
107781+ mod->module_init_rw = NULL;
107782+ mod->module_init_rx = NULL;
107783+ mod->init_size_rw = 0;
107784+ mod->init_size_rx = 0;
107785 /*
107786 * We want to free module_init, but be aware that kallsyms may be
107787 * walking this with preempt disabled. In all the failure paths, we
107788@@ -3370,16 +3534,16 @@ static int complete_formation(struct module *mod, struct load_info *info)
107789 module_bug_finalize(info->hdr, info->sechdrs, mod);
107790
107791 /* Set RO and NX regions for core */
107792- set_section_ro_nx(mod->module_core,
107793- mod->core_text_size,
107794- mod->core_ro_size,
107795- mod->core_size);
107796+ set_section_ro_nx(mod->module_core_rx,
107797+ mod->core_size_rx,
107798+ mod->core_size_rx,
107799+ mod->core_size_rx);
107800
107801 /* Set RO and NX regions for init */
107802- set_section_ro_nx(mod->module_init,
107803- mod->init_text_size,
107804- mod->init_ro_size,
107805- mod->init_size);
107806+ set_section_ro_nx(mod->module_init_rx,
107807+ mod->init_size_rx,
107808+ mod->init_size_rx,
107809+ mod->init_size_rx);
107810
107811 /* Mark state as coming so strong_try_module_get() ignores us,
107812 * but kallsyms etc. can see us. */
107813@@ -3474,9 +3638,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
107814 if (err)
107815 goto free_unload;
107816
107817+ /* Now copy in args */
107818+ mod->args = strndup_user(uargs, ~0UL >> 1);
107819+ if (IS_ERR(mod->args)) {
107820+ err = PTR_ERR(mod->args);
107821+ goto free_unload;
107822+ }
107823+
107824 /* Set up MODINFO_ATTR fields */
107825 setup_modinfo(mod, info);
107826
107827+#ifdef CONFIG_GRKERNSEC_MODHARDEN
107828+ {
107829+ char *p, *p2;
107830+
107831+ if (strstr(mod->args, "grsec_modharden_netdev")) {
107832+ 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);
107833+ err = -EPERM;
107834+ goto free_modinfo;
107835+ } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
107836+ p += sizeof("grsec_modharden_normal") - 1;
107837+ p2 = strstr(p, "_");
107838+ if (p2) {
107839+ *p2 = '\0';
107840+ printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
107841+ *p2 = '_';
107842+ }
107843+ err = -EPERM;
107844+ goto free_modinfo;
107845+ }
107846+ }
107847+#endif
107848+
107849 /* Fix up syms, so that st_value is a pointer to location. */
107850 err = simplify_symbols(mod, info);
107851 if (err < 0)
107852@@ -3492,13 +3685,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
107853
107854 flush_module_icache(mod);
107855
107856- /* Now copy in args */
107857- mod->args = strndup_user(uargs, ~0UL >> 1);
107858- if (IS_ERR(mod->args)) {
107859- err = PTR_ERR(mod->args);
107860- goto free_arch_cleanup;
107861- }
107862-
107863 dynamic_debug_setup(info->debug, info->num_debug);
107864
107865 /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
107866@@ -3550,11 +3736,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
107867 ddebug_cleanup:
107868 dynamic_debug_remove(info->debug);
107869 synchronize_sched();
107870- kfree(mod->args);
107871- free_arch_cleanup:
107872 module_arch_cleanup(mod);
107873 free_modinfo:
107874 free_modinfo(mod);
107875+ kfree(mod->args);
107876 free_unload:
107877 module_unload_free(mod);
107878 unlink_mod:
107879@@ -3568,7 +3753,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
107880 mutex_unlock(&module_mutex);
107881 free_module:
107882 /* Free lock-classes; relies on the preceding sync_rcu() */
107883- lockdep_free_key_range(mod->module_core, mod->core_size);
107884+ lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
107885+ lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
107886
107887 module_deallocate(mod, info);
107888 free_copy:
107889@@ -3645,10 +3831,16 @@ static const char *get_ksymbol(struct module *mod,
107890 unsigned long nextval;
107891
107892 /* At worse, next value is at end of module */
107893- if (within_module_init(addr, mod))
107894- nextval = (unsigned long)mod->module_init+mod->init_text_size;
107895+ if (within_module_init_rx(addr, mod))
107896+ nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
107897+ else if (within_module_init_rw(addr, mod))
107898+ nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
107899+ else if (within_module_core_rx(addr, mod))
107900+ nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
107901+ else if (within_module_core_rw(addr, mod))
107902+ nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
107903 else
107904- nextval = (unsigned long)mod->module_core+mod->core_text_size;
107905+ return NULL;
107906
107907 /* Scan for closest preceding symbol, and next symbol. (ELF
107908 starts real symbols at 1). */
107909@@ -3895,7 +4087,7 @@ static int m_show(struct seq_file *m, void *p)
107910 return 0;
107911
107912 seq_printf(m, "%s %u",
107913- mod->name, mod->init_size + mod->core_size);
107914+ mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
107915 print_unload_info(m, mod);
107916
107917 /* Informative for users. */
107918@@ -3904,7 +4096,7 @@ static int m_show(struct seq_file *m, void *p)
107919 mod->state == MODULE_STATE_COMING ? "Loading" :
107920 "Live");
107921 /* Used by oprofile and other similar tools. */
107922- seq_printf(m, " 0x%pK", mod->module_core);
107923+ seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
107924
107925 /* Taints info */
107926 if (mod->taints)
107927@@ -3940,7 +4132,17 @@ static const struct file_operations proc_modules_operations = {
107928
107929 static int __init proc_modules_init(void)
107930 {
107931+#ifndef CONFIG_GRKERNSEC_HIDESYM
107932+#ifdef CONFIG_GRKERNSEC_PROC_USER
107933+ proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
107934+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
107935+ proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
107936+#else
107937 proc_create("modules", 0, NULL, &proc_modules_operations);
107938+#endif
107939+#else
107940+ proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
107941+#endif
107942 return 0;
107943 }
107944 module_init(proc_modules_init);
107945@@ -4001,7 +4203,8 @@ struct module *__module_address(unsigned long addr)
107946 {
107947 struct module *mod;
107948
107949- if (addr < module_addr_min || addr > module_addr_max)
107950+ if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
107951+ (addr < module_addr_min_rw || addr > module_addr_max_rw))
107952 return NULL;
107953
107954 module_assert_mutex_or_preempt();
107955@@ -4044,11 +4247,20 @@ bool is_module_text_address(unsigned long addr)
107956 */
107957 struct module *__module_text_address(unsigned long addr)
107958 {
107959- struct module *mod = __module_address(addr);
107960+ struct module *mod;
107961+
107962+#ifdef CONFIG_X86_32
107963+ addr = ktla_ktva(addr);
107964+#endif
107965+
107966+ if (addr < module_addr_min_rx || addr > module_addr_max_rx)
107967+ return NULL;
107968+
107969+ mod = __module_address(addr);
107970+
107971 if (mod) {
107972 /* Make sure it's within the text section. */
107973- if (!within(addr, mod->module_init, mod->init_text_size)
107974- && !within(addr, mod->module_core, mod->core_text_size))
107975+ if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
107976 mod = NULL;
107977 }
107978 return mod;
107979diff --git a/kernel/notifier.c b/kernel/notifier.c
107980index ae9fc7c..5085fbf 100644
107981--- a/kernel/notifier.c
107982+++ b/kernel/notifier.c
107983@@ -5,6 +5,7 @@
107984 #include <linux/rcupdate.h>
107985 #include <linux/vmalloc.h>
107986 #include <linux/reboot.h>
107987+#include <linux/mm.h>
107988
107989 /*
107990 * Notifier list for kernel code which wants to be called
107991@@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
107992 while ((*nl) != NULL) {
107993 if (n->priority > (*nl)->priority)
107994 break;
107995- nl = &((*nl)->next);
107996+ nl = (struct notifier_block **)&((*nl)->next);
107997 }
107998- n->next = *nl;
107999+ pax_open_kernel();
108000+ *(const void **)&n->next = *nl;
108001 rcu_assign_pointer(*nl, n);
108002+ pax_close_kernel();
108003 return 0;
108004 }
108005
108006@@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
108007 return 0;
108008 if (n->priority > (*nl)->priority)
108009 break;
108010- nl = &((*nl)->next);
108011+ nl = (struct notifier_block **)&((*nl)->next);
108012 }
108013- n->next = *nl;
108014+ pax_open_kernel();
108015+ *(const void **)&n->next = *nl;
108016 rcu_assign_pointer(*nl, n);
108017+ pax_close_kernel();
108018 return 0;
108019 }
108020
108021@@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
108022 {
108023 while ((*nl) != NULL) {
108024 if ((*nl) == n) {
108025+ pax_open_kernel();
108026 rcu_assign_pointer(*nl, n->next);
108027+ pax_close_kernel();
108028 return 0;
108029 }
108030- nl = &((*nl)->next);
108031+ nl = (struct notifier_block **)&((*nl)->next);
108032 }
108033 return -ENOENT;
108034 }
108035diff --git a/kernel/padata.c b/kernel/padata.c
108036index b38bea9..91acfbe 100644
108037--- a/kernel/padata.c
108038+++ b/kernel/padata.c
108039@@ -54,7 +54,7 @@ static int padata_cpu_hash(struct parallel_data *pd)
108040 * seq_nr mod. number of cpus in use.
108041 */
108042
108043- seq_nr = atomic_inc_return(&pd->seq_nr);
108044+ seq_nr = atomic_inc_return_unchecked(&pd->seq_nr);
108045 cpu_index = seq_nr % cpumask_weight(pd->cpumask.pcpu);
108046
108047 return padata_index_to_cpu(pd, cpu_index);
108048@@ -428,7 +428,7 @@ static struct parallel_data *padata_alloc_pd(struct padata_instance *pinst,
108049 padata_init_pqueues(pd);
108050 padata_init_squeues(pd);
108051 setup_timer(&pd->timer, padata_reorder_timer, (unsigned long)pd);
108052- atomic_set(&pd->seq_nr, -1);
108053+ atomic_set_unchecked(&pd->seq_nr, -1);
108054 atomic_set(&pd->reorder_objects, 0);
108055 atomic_set(&pd->refcnt, 0);
108056 pd->pinst = pinst;
108057diff --git a/kernel/panic.c b/kernel/panic.c
108058index 04e91ff..2419384 100644
108059--- a/kernel/panic.c
108060+++ b/kernel/panic.c
108061@@ -54,7 +54,7 @@ EXPORT_SYMBOL(panic_blink);
108062 /*
108063 * Stop ourself in panic -- architecture code may override this
108064 */
108065-void __weak panic_smp_self_stop(void)
108066+void __weak __noreturn panic_smp_self_stop(void)
108067 {
108068 while (1)
108069 cpu_relax();
108070@@ -426,7 +426,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
108071 disable_trace_on_warning();
108072
108073 pr_warn("------------[ cut here ]------------\n");
108074- pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
108075+ pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
108076 raw_smp_processor_id(), current->pid, file, line, caller);
108077
108078 if (args)
108079@@ -491,7 +491,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
108080 */
108081 __visible void __stack_chk_fail(void)
108082 {
108083- panic("stack-protector: Kernel stack is corrupted in: %p\n",
108084+ dump_stack();
108085+ panic("stack-protector: Kernel stack is corrupted in: %pA\n",
108086 __builtin_return_address(0));
108087 }
108088 EXPORT_SYMBOL(__stack_chk_fail);
108089diff --git a/kernel/pid.c b/kernel/pid.c
108090index 4fd07d5..02bce4f 100644
108091--- a/kernel/pid.c
108092+++ b/kernel/pid.c
108093@@ -33,6 +33,7 @@
108094 #include <linux/rculist.h>
108095 #include <linux/bootmem.h>
108096 #include <linux/hash.h>
108097+#include <linux/security.h>
108098 #include <linux/pid_namespace.h>
108099 #include <linux/init_task.h>
108100 #include <linux/syscalls.h>
108101@@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
108102
108103 int pid_max = PID_MAX_DEFAULT;
108104
108105-#define RESERVED_PIDS 300
108106+#define RESERVED_PIDS 500
108107
108108 int pid_max_min = RESERVED_PIDS + 1;
108109 int pid_max_max = PID_MAX_LIMIT;
108110@@ -451,10 +452,18 @@ EXPORT_SYMBOL(pid_task);
108111 */
108112 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
108113 {
108114+ struct task_struct *task;
108115+
108116 rcu_lockdep_assert(rcu_read_lock_held(),
108117 "find_task_by_pid_ns() needs rcu_read_lock()"
108118 " protection");
108119- return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
108120+
108121+ task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
108122+
108123+ if (gr_pid_is_chrooted(task))
108124+ return NULL;
108125+
108126+ return task;
108127 }
108128
108129 struct task_struct *find_task_by_vpid(pid_t vnr)
108130@@ -462,6 +471,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
108131 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
108132 }
108133
108134+struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
108135+{
108136+ rcu_lockdep_assert(rcu_read_lock_held(),
108137+ "find_task_by_pid_ns() needs rcu_read_lock()"
108138+ " protection");
108139+ return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
108140+}
108141+
108142 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
108143 {
108144 struct pid *pid;
108145diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
108146index a65ba13..f600dbb 100644
108147--- a/kernel/pid_namespace.c
108148+++ b/kernel/pid_namespace.c
108149@@ -274,7 +274,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
108150 void __user *buffer, size_t *lenp, loff_t *ppos)
108151 {
108152 struct pid_namespace *pid_ns = task_active_pid_ns(current);
108153- struct ctl_table tmp = *table;
108154+ ctl_table_no_const tmp = *table;
108155
108156 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
108157 return -EPERM;
108158diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
108159index 9e30231..75a6d97 100644
108160--- a/kernel/power/Kconfig
108161+++ b/kernel/power/Kconfig
108162@@ -24,6 +24,8 @@ config HIBERNATE_CALLBACKS
108163 config HIBERNATION
108164 bool "Hibernation (aka 'suspend to disk')"
108165 depends on SWAP && ARCH_HIBERNATION_POSSIBLE
108166+ depends on !GRKERNSEC_KMEM
108167+ depends on !PAX_MEMORY_SANITIZE
108168 select HIBERNATE_CALLBACKS
108169 select LZO_COMPRESS
108170 select LZO_DECOMPRESS
108171diff --git a/kernel/power/process.c b/kernel/power/process.c
108172index 564f786..361a18e 100644
108173--- a/kernel/power/process.c
108174+++ b/kernel/power/process.c
108175@@ -35,6 +35,7 @@ static int try_to_freeze_tasks(bool user_only)
108176 unsigned int elapsed_msecs;
108177 bool wakeup = false;
108178 int sleep_usecs = USEC_PER_MSEC;
108179+ bool timedout = false;
108180
108181 do_gettimeofday(&start);
108182
108183@@ -45,13 +46,20 @@ static int try_to_freeze_tasks(bool user_only)
108184
108185 while (true) {
108186 todo = 0;
108187+ if (time_after(jiffies, end_time))
108188+ timedout = true;
108189 read_lock(&tasklist_lock);
108190 for_each_process_thread(g, p) {
108191 if (p == current || !freeze_task(p))
108192 continue;
108193
108194- if (!freezer_should_skip(p))
108195+ if (!freezer_should_skip(p)) {
108196 todo++;
108197+ if (timedout) {
108198+ printk(KERN_ERR "Task refusing to freeze:\n");
108199+ sched_show_task(p);
108200+ }
108201+ }
108202 }
108203 read_unlock(&tasklist_lock);
108204
108205@@ -60,7 +68,7 @@ static int try_to_freeze_tasks(bool user_only)
108206 todo += wq_busy;
108207 }
108208
108209- if (!todo || time_after(jiffies, end_time))
108210+ if (!todo || timedout)
108211 break;
108212
108213 if (pm_wakeup_pending()) {
108214diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
108215index cf8c242..84e7843 100644
108216--- a/kernel/printk/printk.c
108217+++ b/kernel/printk/printk.c
108218@@ -475,7 +475,7 @@ static int log_store(int facility, int level,
108219 return msg->text_len;
108220 }
108221
108222-int dmesg_restrict = IS_ENABLED(CONFIG_SECURITY_DMESG_RESTRICT);
108223+int dmesg_restrict __read_only = IS_ENABLED(CONFIG_SECURITY_DMESG_RESTRICT);
108224
108225 static int syslog_action_restricted(int type)
108226 {
108227@@ -498,6 +498,11 @@ int check_syslog_permissions(int type, int source)
108228 if (source == SYSLOG_FROM_PROC && type != SYSLOG_ACTION_OPEN)
108229 goto ok;
108230
108231+#ifdef CONFIG_GRKERNSEC_DMESG
108232+ if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
108233+ return -EPERM;
108234+#endif
108235+
108236 if (syslog_action_restricted(type)) {
108237 if (capable(CAP_SYSLOG))
108238 goto ok;
108239diff --git a/kernel/profile.c b/kernel/profile.c
108240index a7bcd28..5b368fa 100644
108241--- a/kernel/profile.c
108242+++ b/kernel/profile.c
108243@@ -37,7 +37,7 @@ struct profile_hit {
108244 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
108245 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
108246
108247-static atomic_t *prof_buffer;
108248+static atomic_unchecked_t *prof_buffer;
108249 static unsigned long prof_len, prof_shift;
108250
108251 int prof_on __read_mostly;
108252@@ -256,7 +256,7 @@ static void profile_flip_buffers(void)
108253 hits[i].pc = 0;
108254 continue;
108255 }
108256- atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
108257+ atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
108258 hits[i].hits = hits[i].pc = 0;
108259 }
108260 }
108261@@ -317,9 +317,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
108262 * Add the current hit(s) and flush the write-queue out
108263 * to the global buffer:
108264 */
108265- atomic_add(nr_hits, &prof_buffer[pc]);
108266+ atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
108267 for (i = 0; i < NR_PROFILE_HIT; ++i) {
108268- atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
108269+ atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
108270 hits[i].pc = hits[i].hits = 0;
108271 }
108272 out:
108273@@ -394,7 +394,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
108274 {
108275 unsigned long pc;
108276 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
108277- atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
108278+ atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
108279 }
108280 #endif /* !CONFIG_SMP */
108281
108282@@ -489,7 +489,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
108283 return -EFAULT;
108284 buf++; p++; count--; read++;
108285 }
108286- pnt = (char *)prof_buffer + p - sizeof(atomic_t);
108287+ pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
108288 if (copy_to_user(buf, (void *)pnt, count))
108289 return -EFAULT;
108290 read += count;
108291@@ -520,7 +520,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
108292 }
108293 #endif
108294 profile_discard_flip_buffers();
108295- memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
108296+ memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
108297 return count;
108298 }
108299
108300diff --git a/kernel/ptrace.c b/kernel/ptrace.c
108301index c8e0e05..2be5614 100644
108302--- a/kernel/ptrace.c
108303+++ b/kernel/ptrace.c
108304@@ -321,7 +321,7 @@ static int ptrace_attach(struct task_struct *task, long request,
108305 if (seize)
108306 flags |= PT_SEIZED;
108307 rcu_read_lock();
108308- if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
108309+ if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
108310 flags |= PT_PTRACE_CAP;
108311 rcu_read_unlock();
108312 task->ptrace = flags;
108313@@ -514,7 +514,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
108314 break;
108315 return -EIO;
108316 }
108317- if (copy_to_user(dst, buf, retval))
108318+ if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
108319 return -EFAULT;
108320 copied += retval;
108321 src += retval;
108322@@ -802,7 +802,7 @@ int ptrace_request(struct task_struct *child, long request,
108323 bool seized = child->ptrace & PT_SEIZED;
108324 int ret = -EIO;
108325 siginfo_t siginfo, *si;
108326- void __user *datavp = (void __user *) data;
108327+ void __user *datavp = (__force void __user *) data;
108328 unsigned long __user *datalp = datavp;
108329 unsigned long flags;
108330
108331@@ -1048,14 +1048,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
108332 goto out;
108333 }
108334
108335+ if (gr_handle_ptrace(child, request)) {
108336+ ret = -EPERM;
108337+ goto out_put_task_struct;
108338+ }
108339+
108340 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
108341 ret = ptrace_attach(child, request, addr, data);
108342 /*
108343 * Some architectures need to do book-keeping after
108344 * a ptrace attach.
108345 */
108346- if (!ret)
108347+ if (!ret) {
108348 arch_ptrace_attach(child);
108349+ gr_audit_ptrace(child);
108350+ }
108351 goto out_put_task_struct;
108352 }
108353
108354@@ -1083,7 +1090,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
108355 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
108356 if (copied != sizeof(tmp))
108357 return -EIO;
108358- return put_user(tmp, (unsigned long __user *)data);
108359+ return put_user(tmp, (__force unsigned long __user *)data);
108360 }
108361
108362 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
108363@@ -1176,7 +1183,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
108364 }
108365
108366 COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid,
108367- compat_long_t, addr, compat_long_t, data)
108368+ compat_ulong_t, addr, compat_ulong_t, data)
108369 {
108370 struct task_struct *child;
108371 long ret;
108372@@ -1192,14 +1199,21 @@ COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid,
108373 goto out;
108374 }
108375
108376+ if (gr_handle_ptrace(child, request)) {
108377+ ret = -EPERM;
108378+ goto out_put_task_struct;
108379+ }
108380+
108381 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
108382 ret = ptrace_attach(child, request, addr, data);
108383 /*
108384 * Some architectures need to do book-keeping after
108385 * a ptrace attach.
108386 */
108387- if (!ret)
108388+ if (!ret) {
108389 arch_ptrace_attach(child);
108390+ gr_audit_ptrace(child);
108391+ }
108392 goto out_put_task_struct;
108393 }
108394
108395diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
108396index 59e32684..d2eb3d9 100644
108397--- a/kernel/rcu/rcutorture.c
108398+++ b/kernel/rcu/rcutorture.c
108399@@ -134,12 +134,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1],
108400 rcu_torture_count) = { 0 };
108401 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1],
108402 rcu_torture_batch) = { 0 };
108403-static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
108404-static atomic_t n_rcu_torture_alloc;
108405-static atomic_t n_rcu_torture_alloc_fail;
108406-static atomic_t n_rcu_torture_free;
108407-static atomic_t n_rcu_torture_mberror;
108408-static atomic_t n_rcu_torture_error;
108409+static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
108410+static atomic_unchecked_t n_rcu_torture_alloc;
108411+static atomic_unchecked_t n_rcu_torture_alloc_fail;
108412+static atomic_unchecked_t n_rcu_torture_free;
108413+static atomic_unchecked_t n_rcu_torture_mberror;
108414+static atomic_unchecked_t n_rcu_torture_error;
108415 static long n_rcu_torture_barrier_error;
108416 static long n_rcu_torture_boost_ktrerror;
108417 static long n_rcu_torture_boost_rterror;
108418@@ -148,7 +148,7 @@ static long n_rcu_torture_boosts;
108419 static long n_rcu_torture_timers;
108420 static long n_barrier_attempts;
108421 static long n_barrier_successes;
108422-static atomic_long_t n_cbfloods;
108423+static atomic_long_unchecked_t n_cbfloods;
108424 static struct list_head rcu_torture_removed;
108425
108426 static int rcu_torture_writer_state;
108427@@ -211,11 +211,11 @@ rcu_torture_alloc(void)
108428
108429 spin_lock_bh(&rcu_torture_lock);
108430 if (list_empty(&rcu_torture_freelist)) {
108431- atomic_inc(&n_rcu_torture_alloc_fail);
108432+ atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
108433 spin_unlock_bh(&rcu_torture_lock);
108434 return NULL;
108435 }
108436- atomic_inc(&n_rcu_torture_alloc);
108437+ atomic_inc_unchecked(&n_rcu_torture_alloc);
108438 p = rcu_torture_freelist.next;
108439 list_del_init(p);
108440 spin_unlock_bh(&rcu_torture_lock);
108441@@ -228,7 +228,7 @@ rcu_torture_alloc(void)
108442 static void
108443 rcu_torture_free(struct rcu_torture *p)
108444 {
108445- atomic_inc(&n_rcu_torture_free);
108446+ atomic_inc_unchecked(&n_rcu_torture_free);
108447 spin_lock_bh(&rcu_torture_lock);
108448 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
108449 spin_unlock_bh(&rcu_torture_lock);
108450@@ -309,7 +309,7 @@ rcu_torture_pipe_update_one(struct rcu_torture *rp)
108451 i = rp->rtort_pipe_count;
108452 if (i > RCU_TORTURE_PIPE_LEN)
108453 i = RCU_TORTURE_PIPE_LEN;
108454- atomic_inc(&rcu_torture_wcount[i]);
108455+ atomic_inc_unchecked(&rcu_torture_wcount[i]);
108456 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
108457 rp->rtort_mbtest = 0;
108458 return true;
108459@@ -830,7 +830,7 @@ rcu_torture_cbflood(void *arg)
108460 VERBOSE_TOROUT_STRING("rcu_torture_cbflood task started");
108461 do {
108462 schedule_timeout_interruptible(cbflood_inter_holdoff);
108463- atomic_long_inc(&n_cbfloods);
108464+ atomic_long_inc_unchecked(&n_cbfloods);
108465 WARN_ON(signal_pending(current));
108466 for (i = 0; i < cbflood_n_burst; i++) {
108467 for (j = 0; j < cbflood_n_per_burst; j++) {
108468@@ -957,7 +957,7 @@ rcu_torture_writer(void *arg)
108469 i = old_rp->rtort_pipe_count;
108470 if (i > RCU_TORTURE_PIPE_LEN)
108471 i = RCU_TORTURE_PIPE_LEN;
108472- atomic_inc(&rcu_torture_wcount[i]);
108473+ atomic_inc_unchecked(&rcu_torture_wcount[i]);
108474 old_rp->rtort_pipe_count++;
108475 switch (synctype[torture_random(&rand) % nsynctypes]) {
108476 case RTWS_DEF_FREE:
108477@@ -1095,7 +1095,7 @@ static void rcu_torture_timer(unsigned long unused)
108478 return;
108479 }
108480 if (p->rtort_mbtest == 0)
108481- atomic_inc(&n_rcu_torture_mberror);
108482+ atomic_inc_unchecked(&n_rcu_torture_mberror);
108483 spin_lock(&rand_lock);
108484 cur_ops->read_delay(&rand);
108485 n_rcu_torture_timers++;
108486@@ -1170,7 +1170,7 @@ rcu_torture_reader(void *arg)
108487 continue;
108488 }
108489 if (p->rtort_mbtest == 0)
108490- atomic_inc(&n_rcu_torture_mberror);
108491+ atomic_inc_unchecked(&n_rcu_torture_mberror);
108492 cur_ops->read_delay(&rand);
108493 preempt_disable();
108494 pipe_count = p->rtort_pipe_count;
108495@@ -1239,11 +1239,11 @@ rcu_torture_stats_print(void)
108496 rcu_torture_current,
108497 rcu_torture_current_version,
108498 list_empty(&rcu_torture_freelist),
108499- atomic_read(&n_rcu_torture_alloc),
108500- atomic_read(&n_rcu_torture_alloc_fail),
108501- atomic_read(&n_rcu_torture_free));
108502+ atomic_read_unchecked(&n_rcu_torture_alloc),
108503+ atomic_read_unchecked(&n_rcu_torture_alloc_fail),
108504+ atomic_read_unchecked(&n_rcu_torture_free));
108505 pr_cont("rtmbe: %d rtbke: %ld rtbre: %ld ",
108506- atomic_read(&n_rcu_torture_mberror),
108507+ atomic_read_unchecked(&n_rcu_torture_mberror),
108508 n_rcu_torture_boost_ktrerror,
108509 n_rcu_torture_boost_rterror);
108510 pr_cont("rtbf: %ld rtb: %ld nt: %ld ",
108511@@ -1255,17 +1255,17 @@ rcu_torture_stats_print(void)
108512 n_barrier_successes,
108513 n_barrier_attempts,
108514 n_rcu_torture_barrier_error);
108515- pr_cont("cbflood: %ld\n", atomic_long_read(&n_cbfloods));
108516+ pr_cont("cbflood: %ld\n", atomic_long_read_unchecked(&n_cbfloods));
108517
108518 pr_alert("%s%s ", torture_type, TORTURE_FLAG);
108519- if (atomic_read(&n_rcu_torture_mberror) != 0 ||
108520+ if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
108521 n_rcu_torture_barrier_error != 0 ||
108522 n_rcu_torture_boost_ktrerror != 0 ||
108523 n_rcu_torture_boost_rterror != 0 ||
108524 n_rcu_torture_boost_failure != 0 ||
108525 i > 1) {
108526 pr_cont("%s", "!!! ");
108527- atomic_inc(&n_rcu_torture_error);
108528+ atomic_inc_unchecked(&n_rcu_torture_error);
108529 WARN_ON_ONCE(1);
108530 }
108531 pr_cont("Reader Pipe: ");
108532@@ -1282,7 +1282,7 @@ rcu_torture_stats_print(void)
108533 pr_alert("%s%s ", torture_type, TORTURE_FLAG);
108534 pr_cont("Free-Block Circulation: ");
108535 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
108536- pr_cont(" %d", atomic_read(&rcu_torture_wcount[i]));
108537+ pr_cont(" %d", atomic_read_unchecked(&rcu_torture_wcount[i]));
108538 }
108539 pr_cont("\n");
108540
108541@@ -1636,7 +1636,7 @@ rcu_torture_cleanup(void)
108542
108543 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
108544
108545- if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
108546+ if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
108547 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
108548 else if (torture_onoff_failures())
108549 rcu_torture_print_module_parms(cur_ops,
108550@@ -1761,18 +1761,18 @@ rcu_torture_init(void)
108551
108552 rcu_torture_current = NULL;
108553 rcu_torture_current_version = 0;
108554- atomic_set(&n_rcu_torture_alloc, 0);
108555- atomic_set(&n_rcu_torture_alloc_fail, 0);
108556- atomic_set(&n_rcu_torture_free, 0);
108557- atomic_set(&n_rcu_torture_mberror, 0);
108558- atomic_set(&n_rcu_torture_error, 0);
108559+ atomic_set_unchecked(&n_rcu_torture_alloc, 0);
108560+ atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
108561+ atomic_set_unchecked(&n_rcu_torture_free, 0);
108562+ atomic_set_unchecked(&n_rcu_torture_mberror, 0);
108563+ atomic_set_unchecked(&n_rcu_torture_error, 0);
108564 n_rcu_torture_barrier_error = 0;
108565 n_rcu_torture_boost_ktrerror = 0;
108566 n_rcu_torture_boost_rterror = 0;
108567 n_rcu_torture_boost_failure = 0;
108568 n_rcu_torture_boosts = 0;
108569 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
108570- atomic_set(&rcu_torture_wcount[i], 0);
108571+ atomic_set_unchecked(&rcu_torture_wcount[i], 0);
108572 for_each_possible_cpu(cpu) {
108573 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
108574 per_cpu(rcu_torture_count, cpu)[i] = 0;
108575diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
108576index c291bd6..8a01679 100644
108577--- a/kernel/rcu/tiny.c
108578+++ b/kernel/rcu/tiny.c
108579@@ -42,7 +42,7 @@
108580 /* Forward declarations for tiny_plugin.h. */
108581 struct rcu_ctrlblk;
108582 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
108583-static void rcu_process_callbacks(struct softirq_action *unused);
108584+static void rcu_process_callbacks(void);
108585 static void __call_rcu(struct rcu_head *head,
108586 void (*func)(struct rcu_head *rcu),
108587 struct rcu_ctrlblk *rcp);
108588@@ -170,7 +170,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
108589 false));
108590 }
108591
108592-static void rcu_process_callbacks(struct softirq_action *unused)
108593+static __latent_entropy void rcu_process_callbacks(void)
108594 {
108595 __rcu_process_callbacks(&rcu_sched_ctrlblk);
108596 __rcu_process_callbacks(&rcu_bh_ctrlblk);
108597diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
108598index 65137bc..775d7ad 100644
108599--- a/kernel/rcu/tree.c
108600+++ b/kernel/rcu/tree.c
108601@@ -326,7 +326,7 @@ static void rcu_momentary_dyntick_idle(void)
108602 */
108603 rdtp = this_cpu_ptr(&rcu_dynticks);
108604 smp_mb__before_atomic(); /* Earlier stuff before QS. */
108605- atomic_add(2, &rdtp->dynticks); /* QS. */
108606+ atomic_add_unchecked(2, &rdtp->dynticks); /* QS. */
108607 smp_mb__after_atomic(); /* Later stuff after QS. */
108608 break;
108609 }
108610@@ -639,10 +639,10 @@ static void rcu_eqs_enter_common(long long oldval, bool user)
108611 rcu_prepare_for_idle();
108612 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
108613 smp_mb__before_atomic(); /* See above. */
108614- atomic_inc(&rdtp->dynticks);
108615+ atomic_inc_unchecked(&rdtp->dynticks);
108616 smp_mb__after_atomic(); /* Force ordering with next sojourn. */
108617 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) &&
108618- atomic_read(&rdtp->dynticks) & 0x1);
108619+ atomic_read_unchecked(&rdtp->dynticks) & 0x1);
108620 rcu_dynticks_task_enter();
108621
108622 /*
108623@@ -765,11 +765,11 @@ static void rcu_eqs_exit_common(long long oldval, int user)
108624
108625 rcu_dynticks_task_exit();
108626 smp_mb__before_atomic(); /* Force ordering w/previous sojourn. */
108627- atomic_inc(&rdtp->dynticks);
108628+ atomic_inc_unchecked(&rdtp->dynticks);
108629 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
108630 smp_mb__after_atomic(); /* See above. */
108631 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) &&
108632- !(atomic_read(&rdtp->dynticks) & 0x1));
108633+ !(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
108634 rcu_cleanup_after_idle();
108635 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
108636 if (IS_ENABLED(CONFIG_RCU_EQS_DEBUG) &&
108637@@ -905,12 +905,12 @@ void rcu_nmi_enter(void)
108638 * to be in the outermost NMI handler that interrupted an RCU-idle
108639 * period (observation due to Andy Lutomirski).
108640 */
108641- if (!(atomic_read(&rdtp->dynticks) & 0x1)) {
108642+ if (!(atomic_read_unchecked(&rdtp->dynticks) & 0x1)) {
108643 smp_mb__before_atomic(); /* Force delay from prior write. */
108644- atomic_inc(&rdtp->dynticks);
108645+ atomic_inc_unchecked(&rdtp->dynticks);
108646 /* atomic_inc() before later RCU read-side crit sects */
108647 smp_mb__after_atomic(); /* See above. */
108648- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
108649+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
108650 incby = 1;
108651 }
108652 rdtp->dynticks_nmi_nesting += incby;
108653@@ -935,7 +935,7 @@ void rcu_nmi_exit(void)
108654 * to us!)
108655 */
108656 WARN_ON_ONCE(rdtp->dynticks_nmi_nesting <= 0);
108657- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
108658+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
108659
108660 /*
108661 * If the nesting level is not 1, the CPU wasn't RCU-idle, so
108662@@ -950,9 +950,9 @@ void rcu_nmi_exit(void)
108663 rdtp->dynticks_nmi_nesting = 0;
108664 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
108665 smp_mb__before_atomic(); /* See above. */
108666- atomic_inc(&rdtp->dynticks);
108667+ atomic_inc_unchecked(&rdtp->dynticks);
108668 smp_mb__after_atomic(); /* Force delay to next write. */
108669- WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
108670+ WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
108671 }
108672
108673 /**
108674@@ -965,7 +965,7 @@ void rcu_nmi_exit(void)
108675 */
108676 bool notrace __rcu_is_watching(void)
108677 {
108678- return atomic_read(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1;
108679+ return atomic_read_unchecked(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1;
108680 }
108681
108682 /**
108683@@ -1048,7 +1048,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
108684 static int dyntick_save_progress_counter(struct rcu_data *rdp,
108685 bool *isidle, unsigned long *maxj)
108686 {
108687- rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
108688+ rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
108689 rcu_sysidle_check_cpu(rdp, isidle, maxj);
108690 if ((rdp->dynticks_snap & 0x1) == 0) {
108691 trace_rcu_fqs(rdp->rsp->name, rdp->gpnum, rdp->cpu, TPS("dti"));
108692@@ -1074,7 +1074,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
108693 int *rcrmp;
108694 unsigned int snap;
108695
108696- curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
108697+ curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
108698 snap = (unsigned int)rdp->dynticks_snap;
108699
108700 /*
108701@@ -2895,7 +2895,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
108702 /*
108703 * Do RCU core processing for the current CPU.
108704 */
108705-static void rcu_process_callbacks(struct softirq_action *unused)
108706+static void rcu_process_callbacks(void)
108707 {
108708 struct rcu_state *rsp;
108709
108710@@ -3319,11 +3319,11 @@ void synchronize_sched_expedited(void)
108711 * counter wrap on a 32-bit system. Quite a few more CPUs would of
108712 * course be required on a 64-bit system.
108713 */
108714- if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
108715+ if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
108716 (ulong)atomic_long_read(&rsp->expedited_done) +
108717 ULONG_MAX / 8)) {
108718 wait_rcu_gp(call_rcu_sched);
108719- atomic_long_inc(&rsp->expedited_wrap);
108720+ atomic_long_inc_return_unchecked(&rsp->expedited_wrap);
108721 return;
108722 }
108723
108724@@ -3331,12 +3331,12 @@ void synchronize_sched_expedited(void)
108725 * Take a ticket. Note that atomic_inc_return() implies a
108726 * full memory barrier.
108727 */
108728- snap = atomic_long_inc_return(&rsp->expedited_start);
108729+ snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
108730 firstsnap = snap;
108731 if (!try_get_online_cpus()) {
108732 /* CPU hotplug operation in flight, fall back to normal GP. */
108733 wait_rcu_gp(call_rcu_sched);
108734- atomic_long_inc(&rsp->expedited_normal);
108735+ atomic_long_inc_unchecked(&rsp->expedited_normal);
108736 return;
108737 }
108738 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
108739@@ -3349,7 +3349,7 @@ void synchronize_sched_expedited(void)
108740 for_each_cpu(cpu, cm) {
108741 struct rcu_dynticks *rdtp = &per_cpu(rcu_dynticks, cpu);
108742
108743- if (!(atomic_add_return(0, &rdtp->dynticks) & 0x1))
108744+ if (!(atomic_add_return_unchecked(0, &rdtp->dynticks) & 0x1))
108745 cpumask_clear_cpu(cpu, cm);
108746 }
108747 if (cpumask_weight(cm) == 0)
108748@@ -3364,14 +3364,14 @@ void synchronize_sched_expedited(void)
108749 synchronize_sched_expedited_cpu_stop,
108750 NULL) == -EAGAIN) {
108751 put_online_cpus();
108752- atomic_long_inc(&rsp->expedited_tryfail);
108753+ atomic_long_inc_unchecked(&rsp->expedited_tryfail);
108754
108755 /* Check to see if someone else did our work for us. */
108756 s = atomic_long_read(&rsp->expedited_done);
108757 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
108758 /* ensure test happens before caller kfree */
108759 smp_mb__before_atomic(); /* ^^^ */
108760- atomic_long_inc(&rsp->expedited_workdone1);
108761+ atomic_long_inc_unchecked(&rsp->expedited_workdone1);
108762 free_cpumask_var(cm);
108763 return;
108764 }
108765@@ -3381,7 +3381,7 @@ void synchronize_sched_expedited(void)
108766 udelay(trycount * num_online_cpus());
108767 } else {
108768 wait_rcu_gp(call_rcu_sched);
108769- atomic_long_inc(&rsp->expedited_normal);
108770+ atomic_long_inc_unchecked(&rsp->expedited_normal);
108771 free_cpumask_var(cm);
108772 return;
108773 }
108774@@ -3391,7 +3391,7 @@ void synchronize_sched_expedited(void)
108775 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
108776 /* ensure test happens before caller kfree */
108777 smp_mb__before_atomic(); /* ^^^ */
108778- atomic_long_inc(&rsp->expedited_workdone2);
108779+ atomic_long_inc_unchecked(&rsp->expedited_workdone2);
108780 free_cpumask_var(cm);
108781 return;
108782 }
108783@@ -3406,14 +3406,14 @@ void synchronize_sched_expedited(void)
108784 if (!try_get_online_cpus()) {
108785 /* CPU hotplug operation in flight, use normal GP. */
108786 wait_rcu_gp(call_rcu_sched);
108787- atomic_long_inc(&rsp->expedited_normal);
108788+ atomic_long_inc_unchecked(&rsp->expedited_normal);
108789 free_cpumask_var(cm);
108790 return;
108791 }
108792- snap = atomic_long_read(&rsp->expedited_start);
108793+ snap = atomic_long_read_unchecked(&rsp->expedited_start);
108794 smp_mb(); /* ensure read is before try_stop_cpus(). */
108795 }
108796- atomic_long_inc(&rsp->expedited_stoppedcpus);
108797+ atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
108798
108799 all_cpus_idle:
108800 free_cpumask_var(cm);
108801@@ -3425,16 +3425,16 @@ all_cpus_idle:
108802 * than we did already did their update.
108803 */
108804 do {
108805- atomic_long_inc(&rsp->expedited_done_tries);
108806+ atomic_long_inc_unchecked(&rsp->expedited_done_tries);
108807 s = atomic_long_read(&rsp->expedited_done);
108808 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
108809 /* ensure test happens before caller kfree */
108810 smp_mb__before_atomic(); /* ^^^ */
108811- atomic_long_inc(&rsp->expedited_done_lost);
108812+ atomic_long_inc_unchecked(&rsp->expedited_done_lost);
108813 break;
108814 }
108815 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
108816- atomic_long_inc(&rsp->expedited_done_exit);
108817+ atomic_long_inc_unchecked(&rsp->expedited_done_exit);
108818
108819 put_online_cpus();
108820 }
108821@@ -3767,7 +3767,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
108822 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
108823 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
108824 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
108825- WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
108826+ WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
108827 rdp->cpu = cpu;
108828 rdp->rsp = rsp;
108829 rcu_boot_init_nocb_percpu_data(rdp);
108830@@ -3798,8 +3798,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp)
108831 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
108832 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
108833 rcu_sysidle_init_percpu_data(rdp->dynticks);
108834- atomic_set(&rdp->dynticks->dynticks,
108835- (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
108836+ atomic_set_unchecked(&rdp->dynticks->dynticks,
108837+ (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
108838 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
108839
108840 /*
108841diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
108842index 4adb7ca..20910e6 100644
108843--- a/kernel/rcu/tree.h
108844+++ b/kernel/rcu/tree.h
108845@@ -108,11 +108,11 @@ struct rcu_dynticks {
108846 long long dynticks_nesting; /* Track irq/process nesting level. */
108847 /* Process level is worth LLONG_MAX/2. */
108848 int dynticks_nmi_nesting; /* Track NMI nesting level. */
108849- atomic_t dynticks; /* Even value for idle, else odd. */
108850+ atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
108851 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
108852 long long dynticks_idle_nesting;
108853 /* irq/process nesting level from idle. */
108854- atomic_t dynticks_idle; /* Even value for idle, else odd. */
108855+ atomic_unchecked_t dynticks_idle;/* Even value for idle, else odd. */
108856 /* "Idle" excludes userspace execution. */
108857 unsigned long dynticks_idle_jiffies;
108858 /* End of last non-NMI non-idle period. */
108859@@ -483,17 +483,17 @@ struct rcu_state {
108860 /* _rcu_barrier(). */
108861 /* End of fields guarded by barrier_mutex. */
108862
108863- atomic_long_t expedited_start; /* Starting ticket. */
108864- atomic_long_t expedited_done; /* Done ticket. */
108865- atomic_long_t expedited_wrap; /* # near-wrap incidents. */
108866- atomic_long_t expedited_tryfail; /* # acquisition failures. */
108867- atomic_long_t expedited_workdone1; /* # done by others #1. */
108868- atomic_long_t expedited_workdone2; /* # done by others #2. */
108869- atomic_long_t expedited_normal; /* # fallbacks to normal. */
108870- atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
108871- atomic_long_t expedited_done_tries; /* # tries to update _done. */
108872- atomic_long_t expedited_done_lost; /* # times beaten to _done. */
108873- atomic_long_t expedited_done_exit; /* # times exited _done loop. */
108874+ atomic_long_unchecked_t expedited_start; /* Starting ticket. */
108875+ atomic_long_t expedited_done; /* Done ticket. */
108876+ atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
108877+ atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
108878+ atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
108879+ atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
108880+ atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
108881+ atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
108882+ atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
108883+ atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
108884+ atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
108885
108886 unsigned long jiffies_force_qs; /* Time at which to invoke */
108887 /* force_quiescent_state(). */
108888diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
108889index 013485f..2e678db 100644
108890--- a/kernel/rcu/tree_plugin.h
108891+++ b/kernel/rcu/tree_plugin.h
108892@@ -1294,7 +1294,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
108893 free_cpumask_var(cm);
108894 }
108895
108896-static struct smp_hotplug_thread rcu_cpu_thread_spec = {
108897+static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
108898 .store = &rcu_cpu_kthread_task,
108899 .thread_should_run = rcu_cpu_kthread_should_run,
108900 .thread_fn = rcu_cpu_kthread,
108901@@ -1767,7 +1767,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
108902 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
108903 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u fqs=%ld %s\n",
108904 cpu, ticks_value, ticks_title,
108905- atomic_read(&rdtp->dynticks) & 0xfff,
108906+ atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
108907 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
108908 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
108909 READ_ONCE(rsp->n_force_qs) - rsp->n_force_qs_gpstart,
108910@@ -2675,9 +2675,9 @@ static void rcu_sysidle_enter(int irq)
108911 j = jiffies;
108912 WRITE_ONCE(rdtp->dynticks_idle_jiffies, j);
108913 smp_mb__before_atomic();
108914- atomic_inc(&rdtp->dynticks_idle);
108915+ atomic_inc_unchecked(&rdtp->dynticks_idle);
108916 smp_mb__after_atomic();
108917- WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
108918+ WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
108919 }
108920
108921 /*
108922@@ -2748,9 +2748,9 @@ static void rcu_sysidle_exit(int irq)
108923
108924 /* Record end of idle period. */
108925 smp_mb__before_atomic();
108926- atomic_inc(&rdtp->dynticks_idle);
108927+ atomic_inc_unchecked(&rdtp->dynticks_idle);
108928 smp_mb__after_atomic();
108929- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
108930+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
108931
108932 /*
108933 * If we are the timekeeping CPU, we are permitted to be non-idle
108934@@ -2796,7 +2796,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
108935 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
108936
108937 /* Pick up current idle and NMI-nesting counter and check. */
108938- cur = atomic_read(&rdtp->dynticks_idle);
108939+ cur = atomic_read_unchecked(&rdtp->dynticks_idle);
108940 if (cur & 0x1) {
108941 *isidle = false; /* We are not idle! */
108942 return;
108943diff --git a/kernel/rcu/tree_trace.c b/kernel/rcu/tree_trace.c
108944index 3ea7ffc..cb06f2d 100644
108945--- a/kernel/rcu/tree_trace.c
108946+++ b/kernel/rcu/tree_trace.c
108947@@ -125,7 +125,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
108948 rdp->rcu_qs_ctr_snap == per_cpu(rcu_qs_ctr, rdp->cpu),
108949 rdp->qs_pending);
108950 seq_printf(m, " dt=%d/%llx/%d df=%lu",
108951- atomic_read(&rdp->dynticks->dynticks),
108952+ atomic_read_unchecked(&rdp->dynticks->dynticks),
108953 rdp->dynticks->dynticks_nesting,
108954 rdp->dynticks->dynticks_nmi_nesting,
108955 rdp->dynticks_fqs);
108956@@ -186,17 +186,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
108957 struct rcu_state *rsp = (struct rcu_state *)m->private;
108958
108959 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",
108960- atomic_long_read(&rsp->expedited_start),
108961+ atomic_long_read_unchecked(&rsp->expedited_start),
108962 atomic_long_read(&rsp->expedited_done),
108963- atomic_long_read(&rsp->expedited_wrap),
108964- atomic_long_read(&rsp->expedited_tryfail),
108965- atomic_long_read(&rsp->expedited_workdone1),
108966- atomic_long_read(&rsp->expedited_workdone2),
108967- atomic_long_read(&rsp->expedited_normal),
108968- atomic_long_read(&rsp->expedited_stoppedcpus),
108969- atomic_long_read(&rsp->expedited_done_tries),
108970- atomic_long_read(&rsp->expedited_done_lost),
108971- atomic_long_read(&rsp->expedited_done_exit));
108972+ atomic_long_read_unchecked(&rsp->expedited_wrap),
108973+ atomic_long_read_unchecked(&rsp->expedited_tryfail),
108974+ atomic_long_read_unchecked(&rsp->expedited_workdone1),
108975+ atomic_long_read_unchecked(&rsp->expedited_workdone2),
108976+ atomic_long_read_unchecked(&rsp->expedited_normal),
108977+ atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
108978+ atomic_long_read_unchecked(&rsp->expedited_done_tries),
108979+ atomic_long_read_unchecked(&rsp->expedited_done_lost),
108980+ atomic_long_read_unchecked(&rsp->expedited_done_exit));
108981 return 0;
108982 }
108983
108984diff --git a/kernel/resource.c b/kernel/resource.c
108985index fed052a..ad13346 100644
108986--- a/kernel/resource.c
108987+++ b/kernel/resource.c
108988@@ -162,8 +162,18 @@ static const struct file_operations proc_iomem_operations = {
108989
108990 static int __init ioresources_init(void)
108991 {
108992+#ifdef CONFIG_GRKERNSEC_PROC_ADD
108993+#ifdef CONFIG_GRKERNSEC_PROC_USER
108994+ proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
108995+ proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
108996+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
108997+ proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
108998+ proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
108999+#endif
109000+#else
109001 proc_create("ioports", 0, NULL, &proc_ioports_operations);
109002 proc_create("iomem", 0, NULL, &proc_iomem_operations);
109003+#endif
109004 return 0;
109005 }
109006 __initcall(ioresources_init);
109007diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
109008index 750ed60..eb01466 100644
109009--- a/kernel/sched/auto_group.c
109010+++ b/kernel/sched/auto_group.c
109011@@ -9,7 +9,7 @@
109012
109013 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
109014 static struct autogroup autogroup_default;
109015-static atomic_t autogroup_seq_nr;
109016+static atomic_unchecked_t autogroup_seq_nr;
109017
109018 void __init autogroup_init(struct task_struct *init_task)
109019 {
109020@@ -77,7 +77,7 @@ static inline struct autogroup *autogroup_create(void)
109021
109022 kref_init(&ag->kref);
109023 init_rwsem(&ag->lock);
109024- ag->id = atomic_inc_return(&autogroup_seq_nr);
109025+ ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
109026 ag->tg = tg;
109027 #ifdef CONFIG_RT_GROUP_SCHED
109028 /*
109029diff --git a/kernel/sched/core.c b/kernel/sched/core.c
109030index 6776631..45eb6ee 100644
109031--- a/kernel/sched/core.c
109032+++ b/kernel/sched/core.c
109033@@ -2080,7 +2080,7 @@ void set_numabalancing_state(bool enabled)
109034 int sysctl_numa_balancing(struct ctl_table *table, int write,
109035 void __user *buffer, size_t *lenp, loff_t *ppos)
109036 {
109037- struct ctl_table t;
109038+ ctl_table_no_const t;
109039 int err;
109040 int state = numabalancing_enabled;
109041
109042@@ -2573,8 +2573,10 @@ context_switch(struct rq *rq, struct task_struct *prev,
109043 next->active_mm = oldmm;
109044 atomic_inc(&oldmm->mm_count);
109045 enter_lazy_tlb(oldmm, next);
109046- } else
109047+ } else {
109048 switch_mm(oldmm, mm, next);
109049+ populate_stack();
109050+ }
109051
109052 if (!prev->mm) {
109053 prev->active_mm = NULL;
109054@@ -3393,6 +3395,8 @@ int can_nice(const struct task_struct *p, const int nice)
109055 /* convert nice value [19,-20] to rlimit style value [1,40] */
109056 int nice_rlim = nice_to_rlimit(nice);
109057
109058+ gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
109059+
109060 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
109061 capable(CAP_SYS_NICE));
109062 }
109063@@ -3419,7 +3423,8 @@ SYSCALL_DEFINE1(nice, int, increment)
109064 nice = task_nice(current) + increment;
109065
109066 nice = clamp_val(nice, MIN_NICE, MAX_NICE);
109067- if (increment < 0 && !can_nice(current, nice))
109068+ if (increment < 0 && (!can_nice(current, nice) ||
109069+ gr_handle_chroot_nice()))
109070 return -EPERM;
109071
109072 retval = security_task_setnice(current, nice);
109073@@ -3731,6 +3736,7 @@ recheck:
109074 if (policy != p->policy && !rlim_rtprio)
109075 return -EPERM;
109076
109077+ gr_learn_resource(p, RLIMIT_RTPRIO, attr->sched_priority, 1);
109078 /* can't increase priority */
109079 if (attr->sched_priority > p->rt_priority &&
109080 attr->sched_priority > rlim_rtprio)
109081@@ -5055,6 +5061,7 @@ void idle_task_exit(void)
109082
109083 if (mm != &init_mm) {
109084 switch_mm(mm, &init_mm, current);
109085+ populate_stack();
109086 finish_arch_post_lock_switch();
109087 }
109088 mmdrop(mm);
109089@@ -5157,7 +5164,7 @@ static void migrate_tasks(struct rq *dead_rq)
109090
109091 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
109092
109093-static struct ctl_table sd_ctl_dir[] = {
109094+static ctl_table_no_const sd_ctl_dir[] __read_only = {
109095 {
109096 .procname = "sched_domain",
109097 .mode = 0555,
109098@@ -5174,17 +5181,17 @@ static struct ctl_table sd_ctl_root[] = {
109099 {}
109100 };
109101
109102-static struct ctl_table *sd_alloc_ctl_entry(int n)
109103+static ctl_table_no_const *sd_alloc_ctl_entry(int n)
109104 {
109105- struct ctl_table *entry =
109106+ ctl_table_no_const *entry =
109107 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
109108
109109 return entry;
109110 }
109111
109112-static void sd_free_ctl_entry(struct ctl_table **tablep)
109113+static void sd_free_ctl_entry(ctl_table_no_const *tablep)
109114 {
109115- struct ctl_table *entry;
109116+ ctl_table_no_const *entry;
109117
109118 /*
109119 * In the intermediate directories, both the child directory and
109120@@ -5192,22 +5199,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
109121 * will always be set. In the lowest directory the names are
109122 * static strings and all have proc handlers.
109123 */
109124- for (entry = *tablep; entry->mode; entry++) {
109125- if (entry->child)
109126- sd_free_ctl_entry(&entry->child);
109127+ for (entry = tablep; entry->mode; entry++) {
109128+ if (entry->child) {
109129+ sd_free_ctl_entry(entry->child);
109130+ pax_open_kernel();
109131+ entry->child = NULL;
109132+ pax_close_kernel();
109133+ }
109134 if (entry->proc_handler == NULL)
109135 kfree(entry->procname);
109136 }
109137
109138- kfree(*tablep);
109139- *tablep = NULL;
109140+ kfree(tablep);
109141 }
109142
109143 static int min_load_idx = 0;
109144 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
109145
109146 static void
109147-set_table_entry(struct ctl_table *entry,
109148+set_table_entry(ctl_table_no_const *entry,
109149 const char *procname, void *data, int maxlen,
109150 umode_t mode, proc_handler *proc_handler,
109151 bool load_idx)
109152@@ -5227,7 +5237,7 @@ set_table_entry(struct ctl_table *entry,
109153 static struct ctl_table *
109154 sd_alloc_ctl_domain_table(struct sched_domain *sd)
109155 {
109156- struct ctl_table *table = sd_alloc_ctl_entry(14);
109157+ ctl_table_no_const *table = sd_alloc_ctl_entry(14);
109158
109159 if (table == NULL)
109160 return NULL;
109161@@ -5265,9 +5275,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
109162 return table;
109163 }
109164
109165-static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
109166+static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
109167 {
109168- struct ctl_table *entry, *table;
109169+ ctl_table_no_const *entry, *table;
109170 struct sched_domain *sd;
109171 int domain_num = 0, i;
109172 char buf[32];
109173@@ -5294,11 +5304,13 @@ static struct ctl_table_header *sd_sysctl_header;
109174 static void register_sched_domain_sysctl(void)
109175 {
109176 int i, cpu_num = num_possible_cpus();
109177- struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
109178+ ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
109179 char buf[32];
109180
109181 WARN_ON(sd_ctl_dir[0].child);
109182+ pax_open_kernel();
109183 sd_ctl_dir[0].child = entry;
109184+ pax_close_kernel();
109185
109186 if (entry == NULL)
109187 return;
109188@@ -5321,8 +5333,12 @@ static void unregister_sched_domain_sysctl(void)
109189 if (sd_sysctl_header)
109190 unregister_sysctl_table(sd_sysctl_header);
109191 sd_sysctl_header = NULL;
109192- if (sd_ctl_dir[0].child)
109193- sd_free_ctl_entry(&sd_ctl_dir[0].child);
109194+ if (sd_ctl_dir[0].child) {
109195+ sd_free_ctl_entry(sd_ctl_dir[0].child);
109196+ pax_open_kernel();
109197+ sd_ctl_dir[0].child = NULL;
109198+ pax_close_kernel();
109199+ }
109200 }
109201 #else
109202 static void register_sched_domain_sysctl(void)
109203diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
109204index d113c3b..91a6fcc 100644
109205--- a/kernel/sched/fair.c
109206+++ b/kernel/sched/fair.c
109207@@ -7958,7 +7958,7 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) { }
109208 * run_rebalance_domains is triggered when needed from the scheduler tick.
109209 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
109210 */
109211-static void run_rebalance_domains(struct softirq_action *h)
109212+static __latent_entropy void run_rebalance_domains(void)
109213 {
109214 struct rq *this_rq = this_rq();
109215 enum cpu_idle_type idle = this_rq->idle_balance ?
109216diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
109217index 08ab96b..82ab34c 100644
109218--- a/kernel/sched/sched.h
109219+++ b/kernel/sched/sched.h
109220@@ -1242,7 +1242,7 @@ struct sched_class {
109221 #ifdef CONFIG_FAIR_GROUP_SCHED
109222 void (*task_move_group) (struct task_struct *p, int on_rq);
109223 #endif
109224-};
109225+} __do_const;
109226
109227 static inline void put_prev_task(struct rq *rq, struct task_struct *prev)
109228 {
109229diff --git a/kernel/signal.c b/kernel/signal.c
109230index 0f6bbbe..d77d2c3 100644
109231--- a/kernel/signal.c
109232+++ b/kernel/signal.c
109233@@ -53,12 +53,12 @@ static struct kmem_cache *sigqueue_cachep;
109234
109235 int print_fatal_signals __read_mostly;
109236
109237-static void __user *sig_handler(struct task_struct *t, int sig)
109238+static __sighandler_t sig_handler(struct task_struct *t, int sig)
109239 {
109240 return t->sighand->action[sig - 1].sa.sa_handler;
109241 }
109242
109243-static int sig_handler_ignored(void __user *handler, int sig)
109244+static int sig_handler_ignored(__sighandler_t handler, int sig)
109245 {
109246 /* Is it explicitly or implicitly ignored? */
109247 return handler == SIG_IGN ||
109248@@ -67,7 +67,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
109249
109250 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
109251 {
109252- void __user *handler;
109253+ __sighandler_t handler;
109254
109255 handler = sig_handler(t, sig);
109256
109257@@ -372,6 +372,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
109258 atomic_inc(&user->sigpending);
109259 rcu_read_unlock();
109260
109261+ if (!override_rlimit)
109262+ gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
109263+
109264 if (override_rlimit ||
109265 atomic_read(&user->sigpending) <=
109266 task_rlimit(t, RLIMIT_SIGPENDING)) {
109267@@ -494,7 +497,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
109268
109269 int unhandled_signal(struct task_struct *tsk, int sig)
109270 {
109271- void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
109272+ __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
109273 if (is_global_init(tsk))
109274 return 1;
109275 if (handler != SIG_IGN && handler != SIG_DFL)
109276@@ -788,6 +791,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
109277 }
109278 }
109279
109280+ /* allow glibc communication via tgkill to other threads in our
109281+ thread group */
109282+ if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
109283+ sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
109284+ && gr_handle_signal(t, sig))
109285+ return -EPERM;
109286+
109287 return security_task_kill(t, info, sig, 0);
109288 }
109289
109290@@ -1171,7 +1181,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
109291 return send_signal(sig, info, p, 1);
109292 }
109293
109294-static int
109295+int
109296 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
109297 {
109298 return send_signal(sig, info, t, 0);
109299@@ -1208,6 +1218,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
109300 unsigned long int flags;
109301 int ret, blocked, ignored;
109302 struct k_sigaction *action;
109303+ int is_unhandled = 0;
109304
109305 spin_lock_irqsave(&t->sighand->siglock, flags);
109306 action = &t->sighand->action[sig-1];
109307@@ -1222,9 +1233,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
109308 }
109309 if (action->sa.sa_handler == SIG_DFL)
109310 t->signal->flags &= ~SIGNAL_UNKILLABLE;
109311+ if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
109312+ is_unhandled = 1;
109313 ret = specific_send_sig_info(sig, info, t);
109314 spin_unlock_irqrestore(&t->sighand->siglock, flags);
109315
109316+ /* only deal with unhandled signals, java etc trigger SIGSEGV during
109317+ normal operation */
109318+ if (is_unhandled) {
109319+ gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
109320+ gr_handle_crash(t, sig);
109321+ }
109322+
109323 return ret;
109324 }
109325
109326@@ -1305,8 +1325,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
109327 ret = check_kill_permission(sig, info, p);
109328 rcu_read_unlock();
109329
109330- if (!ret && sig)
109331+ if (!ret && sig) {
109332 ret = do_send_sig_info(sig, info, p, true);
109333+ if (!ret)
109334+ gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
109335+ }
109336
109337 return ret;
109338 }
109339@@ -2913,7 +2936,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
109340 int error = -ESRCH;
109341
109342 rcu_read_lock();
109343- p = find_task_by_vpid(pid);
109344+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
109345+ /* allow glibc communication via tgkill to other threads in our
109346+ thread group */
109347+ if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
109348+ sig == (SIGRTMIN+1) && tgid == info->si_pid)
109349+ p = find_task_by_vpid_unrestricted(pid);
109350+ else
109351+#endif
109352+ p = find_task_by_vpid(pid);
109353 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
109354 error = check_kill_permission(sig, info, p);
109355 /*
109356@@ -3242,8 +3273,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
109357 }
109358 seg = get_fs();
109359 set_fs(KERNEL_DS);
109360- ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
109361- (stack_t __force __user *) &uoss,
109362+ ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
109363+ (stack_t __force_user *) &uoss,
109364 compat_user_stack_pointer());
109365 set_fs(seg);
109366 if (ret >= 0 && uoss_ptr) {
109367diff --git a/kernel/smpboot.c b/kernel/smpboot.c
109368index 7c434c3..155d90a 100644
109369--- a/kernel/smpboot.c
109370+++ b/kernel/smpboot.c
109371@@ -305,7 +305,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
109372 }
109373 smpboot_unpark_thread(plug_thread, cpu);
109374 }
109375- list_add(&plug_thread->list, &hotplug_threads);
109376+ pax_list_add(&plug_thread->list, &hotplug_threads);
109377 out:
109378 mutex_unlock(&smpboot_threads_lock);
109379 put_online_cpus();
109380@@ -323,7 +323,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
109381 {
109382 get_online_cpus();
109383 mutex_lock(&smpboot_threads_lock);
109384- list_del(&plug_thread->list);
109385+ pax_list_del(&plug_thread->list);
109386 smpboot_destroy_threads(plug_thread);
109387 mutex_unlock(&smpboot_threads_lock);
109388 put_online_cpus();
109389diff --git a/kernel/softirq.c b/kernel/softirq.c
109390index 479e443..66d845e1 100644
109391--- a/kernel/softirq.c
109392+++ b/kernel/softirq.c
109393@@ -53,7 +53,7 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
109394 EXPORT_SYMBOL(irq_stat);
109395 #endif
109396
109397-static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
109398+static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
109399
109400 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
109401
109402@@ -270,7 +270,7 @@ restart:
109403 kstat_incr_softirqs_this_cpu(vec_nr);
109404
109405 trace_softirq_entry(vec_nr);
109406- h->action(h);
109407+ h->action();
109408 trace_softirq_exit(vec_nr);
109409 if (unlikely(prev_count != preempt_count())) {
109410 pr_err("huh, entered softirq %u %s %p with preempt_count %08x, exited with %08x?\n",
109411@@ -430,7 +430,7 @@ void __raise_softirq_irqoff(unsigned int nr)
109412 or_softirq_pending(1UL << nr);
109413 }
109414
109415-void open_softirq(int nr, void (*action)(struct softirq_action *))
109416+void __init open_softirq(int nr, void (*action)(void))
109417 {
109418 softirq_vec[nr].action = action;
109419 }
109420@@ -482,7 +482,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
109421 }
109422 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
109423
109424-static void tasklet_action(struct softirq_action *a)
109425+static void tasklet_action(void)
109426 {
109427 struct tasklet_struct *list;
109428
109429@@ -518,7 +518,7 @@ static void tasklet_action(struct softirq_action *a)
109430 }
109431 }
109432
109433-static void tasklet_hi_action(struct softirq_action *a)
109434+static __latent_entropy void tasklet_hi_action(void)
109435 {
109436 struct tasklet_struct *list;
109437
109438@@ -744,7 +744,7 @@ static struct notifier_block cpu_nfb = {
109439 .notifier_call = cpu_callback
109440 };
109441
109442-static struct smp_hotplug_thread softirq_threads = {
109443+static struct smp_hotplug_thread softirq_threads __read_only = {
109444 .store = &ksoftirqd,
109445 .thread_should_run = ksoftirqd_should_run,
109446 .thread_fn = run_ksoftirqd,
109447diff --git a/kernel/sys.c b/kernel/sys.c
109448index 259fda2..e824a93 100644
109449--- a/kernel/sys.c
109450+++ b/kernel/sys.c
109451@@ -160,6 +160,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
109452 error = -EACCES;
109453 goto out;
109454 }
109455+
109456+ if (gr_handle_chroot_setpriority(p, niceval)) {
109457+ error = -EACCES;
109458+ goto out;
109459+ }
109460+
109461 no_nice = security_task_setnice(p, niceval);
109462 if (no_nice) {
109463 error = no_nice;
109464@@ -366,6 +372,20 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
109465 goto error;
109466 }
109467
109468+ if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
109469+ goto error;
109470+
109471+ if (!gid_eq(new->gid, old->gid)) {
109472+ /* make sure we generate a learn log for what will
109473+ end up being a role transition after a full-learning
109474+ policy is generated
109475+ CAP_SETGID is required to perform a transition
109476+ we may not log a CAP_SETGID check above, e.g.
109477+ in the case where new rgid = old egid
109478+ */
109479+ gr_learn_cap(current, new, CAP_SETGID);
109480+ }
109481+
109482 if (rgid != (gid_t) -1 ||
109483 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
109484 new->sgid = new->egid;
109485@@ -401,6 +421,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
109486 old = current_cred();
109487
109488 retval = -EPERM;
109489+
109490+ if (gr_check_group_change(kgid, kgid, kgid))
109491+ goto error;
109492+
109493 if (ns_capable(old->user_ns, CAP_SETGID))
109494 new->gid = new->egid = new->sgid = new->fsgid = kgid;
109495 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
109496@@ -418,7 +442,7 @@ error:
109497 /*
109498 * change the user struct in a credentials set to match the new UID
109499 */
109500-static int set_user(struct cred *new)
109501+int set_user(struct cred *new)
109502 {
109503 struct user_struct *new_user;
109504
109505@@ -498,7 +522,18 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
109506 goto error;
109507 }
109508
109509+ if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
109510+ goto error;
109511+
109512 if (!uid_eq(new->uid, old->uid)) {
109513+ /* make sure we generate a learn log for what will
109514+ end up being a role transition after a full-learning
109515+ policy is generated
109516+ CAP_SETUID is required to perform a transition
109517+ we may not log a CAP_SETUID check above, e.g.
109518+ in the case where new ruid = old euid
109519+ */
109520+ gr_learn_cap(current, new, CAP_SETUID);
109521 retval = set_user(new);
109522 if (retval < 0)
109523 goto error;
109524@@ -548,6 +583,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
109525 old = current_cred();
109526
109527 retval = -EPERM;
109528+
109529+ if (gr_check_crash_uid(kuid))
109530+ goto error;
109531+ if (gr_check_user_change(kuid, kuid, kuid))
109532+ goto error;
109533+
109534 if (ns_capable(old->user_ns, CAP_SETUID)) {
109535 new->suid = new->uid = kuid;
109536 if (!uid_eq(kuid, old->uid)) {
109537@@ -617,6 +658,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
109538 goto error;
109539 }
109540
109541+ if (gr_check_user_change(kruid, keuid, INVALID_UID))
109542+ goto error;
109543+
109544 if (ruid != (uid_t) -1) {
109545 new->uid = kruid;
109546 if (!uid_eq(kruid, old->uid)) {
109547@@ -701,6 +745,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
109548 goto error;
109549 }
109550
109551+ if (gr_check_group_change(krgid, kegid, INVALID_GID))
109552+ goto error;
109553+
109554 if (rgid != (gid_t) -1)
109555 new->gid = krgid;
109556 if (egid != (gid_t) -1)
109557@@ -765,12 +812,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
109558 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
109559 ns_capable(old->user_ns, CAP_SETUID)) {
109560 if (!uid_eq(kuid, old->fsuid)) {
109561+ if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
109562+ goto error;
109563+
109564 new->fsuid = kuid;
109565 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
109566 goto change_okay;
109567 }
109568 }
109569
109570+error:
109571 abort_creds(new);
109572 return old_fsuid;
109573
109574@@ -803,12 +854,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
109575 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
109576 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
109577 ns_capable(old->user_ns, CAP_SETGID)) {
109578+ if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
109579+ goto error;
109580+
109581 if (!gid_eq(kgid, old->fsgid)) {
109582 new->fsgid = kgid;
109583 goto change_okay;
109584 }
109585 }
109586
109587+error:
109588 abort_creds(new);
109589 return old_fsgid;
109590
109591@@ -1187,19 +1242,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
109592 return -EFAULT;
109593
109594 down_read(&uts_sem);
109595- error = __copy_to_user(&name->sysname, &utsname()->sysname,
109596+ error = __copy_to_user(name->sysname, &utsname()->sysname,
109597 __OLD_UTS_LEN);
109598 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
109599- error |= __copy_to_user(&name->nodename, &utsname()->nodename,
109600+ error |= __copy_to_user(name->nodename, &utsname()->nodename,
109601 __OLD_UTS_LEN);
109602 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
109603- error |= __copy_to_user(&name->release, &utsname()->release,
109604+ error |= __copy_to_user(name->release, &utsname()->release,
109605 __OLD_UTS_LEN);
109606 error |= __put_user(0, name->release + __OLD_UTS_LEN);
109607- error |= __copy_to_user(&name->version, &utsname()->version,
109608+ error |= __copy_to_user(name->version, &utsname()->version,
109609 __OLD_UTS_LEN);
109610 error |= __put_user(0, name->version + __OLD_UTS_LEN);
109611- error |= __copy_to_user(&name->machine, &utsname()->machine,
109612+ error |= __copy_to_user(name->machine, &utsname()->machine,
109613 __OLD_UTS_LEN);
109614 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
109615 up_read(&uts_sem);
109616@@ -1400,6 +1455,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
109617 */
109618 new_rlim->rlim_cur = 1;
109619 }
109620+ /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
109621+ is changed to a lower value. Since tasks can be created by the same
109622+ user in between this limit change and an execve by this task, force
109623+ a recheck only for this task by setting PF_NPROC_EXCEEDED
109624+ */
109625+ if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
109626+ tsk->flags |= PF_NPROC_EXCEEDED;
109627 }
109628 if (!retval) {
109629 if (old_rlim)
109630diff --git a/kernel/sysctl.c b/kernel/sysctl.c
109631index 19b62b5..74cc287 100644
109632--- a/kernel/sysctl.c
109633+++ b/kernel/sysctl.c
109634@@ -94,7 +94,6 @@
109635 #endif
109636
109637 #if defined(CONFIG_SYSCTL)
109638-
109639 /* External variables not in a header file. */
109640 extern int suid_dumpable;
109641 #ifdef CONFIG_COREDUMP
109642@@ -111,22 +110,24 @@ extern int sysctl_nr_open_min, sysctl_nr_open_max;
109643 #ifndef CONFIG_MMU
109644 extern int sysctl_nr_trim_pages;
109645 #endif
109646+extern int sysctl_modify_ldt;
109647
109648 /* Constants used for minimum and maximum */
109649 #ifdef CONFIG_LOCKUP_DETECTOR
109650-static int sixty = 60;
109651+static int sixty __read_only = 60;
109652 #endif
109653
109654-static int __maybe_unused neg_one = -1;
109655+static int __maybe_unused neg_one __read_only = -1;
109656
109657-static int zero;
109658-static int __maybe_unused one = 1;
109659-static int __maybe_unused two = 2;
109660-static int __maybe_unused four = 4;
109661-static unsigned long one_ul = 1;
109662-static int one_hundred = 100;
109663+static int zero __read_only = 0;
109664+static int __maybe_unused one __read_only = 1;
109665+static int __maybe_unused two __read_only = 2;
109666+static int __maybe_unused three __read_only = 3;
109667+static int __maybe_unused four __read_only = 4;
109668+static unsigned long one_ul __read_only = 1;
109669+static int one_hundred __read_only = 100;
109670 #ifdef CONFIG_PRINTK
109671-static int ten_thousand = 10000;
109672+static int ten_thousand __read_only = 10000;
109673 #endif
109674
109675 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
109676@@ -180,10 +181,8 @@ static int proc_taint(struct ctl_table *table, int write,
109677 void __user *buffer, size_t *lenp, loff_t *ppos);
109678 #endif
109679
109680-#ifdef CONFIG_PRINTK
109681-static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
109682+static int proc_dointvec_minmax_secure_sysadmin(struct ctl_table *table, int write,
109683 void __user *buffer, size_t *lenp, loff_t *ppos);
109684-#endif
109685
109686 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
109687 void __user *buffer, size_t *lenp, loff_t *ppos);
109688@@ -214,6 +213,8 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write,
109689
109690 #endif
109691
109692+extern struct ctl_table grsecurity_table[];
109693+
109694 static struct ctl_table kern_table[];
109695 static struct ctl_table vm_table[];
109696 static struct ctl_table fs_table[];
109697@@ -228,6 +229,20 @@ extern struct ctl_table epoll_table[];
109698 int sysctl_legacy_va_layout;
109699 #endif
109700
109701+#ifdef CONFIG_PAX_SOFTMODE
109702+static struct ctl_table pax_table[] = {
109703+ {
109704+ .procname = "softmode",
109705+ .data = &pax_softmode,
109706+ .maxlen = sizeof(unsigned int),
109707+ .mode = 0600,
109708+ .proc_handler = &proc_dointvec,
109709+ },
109710+
109711+ { }
109712+};
109713+#endif
109714+
109715 /* The default sysctl tables: */
109716
109717 static struct ctl_table sysctl_base_table[] = {
109718@@ -276,6 +291,22 @@ static int max_extfrag_threshold = 1000;
109719 #endif
109720
109721 static struct ctl_table kern_table[] = {
109722+#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
109723+ {
109724+ .procname = "grsecurity",
109725+ .mode = 0500,
109726+ .child = grsecurity_table,
109727+ },
109728+#endif
109729+
109730+#ifdef CONFIG_PAX_SOFTMODE
109731+ {
109732+ .procname = "pax",
109733+ .mode = 0500,
109734+ .child = pax_table,
109735+ },
109736+#endif
109737+
109738 {
109739 .procname = "sched_child_runs_first",
109740 .data = &sysctl_sched_child_runs_first,
109741@@ -628,7 +659,7 @@ static struct ctl_table kern_table[] = {
109742 .maxlen = sizeof(int),
109743 .mode = 0644,
109744 /* only handle a transition from default "0" to "1" */
109745- .proc_handler = proc_dointvec_minmax,
109746+ .proc_handler = proc_dointvec_minmax_secure,
109747 .extra1 = &one,
109748 .extra2 = &one,
109749 },
109750@@ -639,7 +670,7 @@ static struct ctl_table kern_table[] = {
109751 .data = &modprobe_path,
109752 .maxlen = KMOD_PATH_LEN,
109753 .mode = 0644,
109754- .proc_handler = proc_dostring,
109755+ .proc_handler = proc_dostring_modpriv,
109756 },
109757 {
109758 .procname = "modules_disabled",
109759@@ -647,7 +678,7 @@ static struct ctl_table kern_table[] = {
109760 .maxlen = sizeof(int),
109761 .mode = 0644,
109762 /* only handle a transition from default "0" to "1" */
109763- .proc_handler = proc_dointvec_minmax,
109764+ .proc_handler = proc_dointvec_minmax_secure,
109765 .extra1 = &one,
109766 .extra2 = &one,
109767 },
109768@@ -802,20 +833,24 @@ static struct ctl_table kern_table[] = {
109769 .data = &dmesg_restrict,
109770 .maxlen = sizeof(int),
109771 .mode = 0644,
109772- .proc_handler = proc_dointvec_minmax_sysadmin,
109773+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
109774 .extra1 = &zero,
109775 .extra2 = &one,
109776 },
109777+#endif
109778 {
109779 .procname = "kptr_restrict",
109780 .data = &kptr_restrict,
109781 .maxlen = sizeof(int),
109782 .mode = 0644,
109783- .proc_handler = proc_dointvec_minmax_sysadmin,
109784+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
109785+#ifdef CONFIG_GRKERNSEC_HIDESYM
109786+ .extra1 = &two,
109787+#else
109788 .extra1 = &zero,
109789+#endif
109790 .extra2 = &two,
109791 },
109792-#endif
109793 {
109794 .procname = "ngroups_max",
109795 .data = &ngroups_max,
109796@@ -960,6 +995,15 @@ static struct ctl_table kern_table[] = {
109797 .mode = 0644,
109798 .proc_handler = proc_dointvec,
109799 },
109800+ {
109801+ .procname = "modify_ldt",
109802+ .data = &sysctl_modify_ldt,
109803+ .maxlen = sizeof(int),
109804+ .mode = 0644,
109805+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
109806+ .extra1 = &zero,
109807+ .extra2 = &one,
109808+ },
109809 #endif
109810 #if defined(CONFIG_MMU)
109811 {
109812@@ -1082,10 +1126,17 @@ static struct ctl_table kern_table[] = {
109813 */
109814 {
109815 .procname = "perf_event_paranoid",
109816- .data = &sysctl_perf_event_paranoid,
109817- .maxlen = sizeof(sysctl_perf_event_paranoid),
109818+ .data = &sysctl_perf_event_legitimately_concerned,
109819+ .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
109820 .mode = 0644,
109821- .proc_handler = proc_dointvec,
109822+ /* go ahead, be a hero */
109823+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
109824+ .extra1 = &neg_one,
109825+#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
109826+ .extra2 = &three,
109827+#else
109828+ .extra2 = &two,
109829+#endif
109830 },
109831 {
109832 .procname = "perf_event_mlock_kb",
109833@@ -1376,6 +1427,13 @@ static struct ctl_table vm_table[] = {
109834 .proc_handler = proc_dointvec_minmax,
109835 .extra1 = &zero,
109836 },
109837+ {
109838+ .procname = "heap_stack_gap",
109839+ .data = &sysctl_heap_stack_gap,
109840+ .maxlen = sizeof(sysctl_heap_stack_gap),
109841+ .mode = 0644,
109842+ .proc_handler = proc_doulongvec_minmax,
109843+ },
109844 #else
109845 {
109846 .procname = "nr_trim_pages",
109847@@ -1852,6 +1910,16 @@ int proc_dostring(struct ctl_table *table, int write,
109848 (char __user *)buffer, lenp, ppos);
109849 }
109850
109851+int proc_dostring_modpriv(struct ctl_table *table, int write,
109852+ void __user *buffer, size_t *lenp, loff_t *ppos)
109853+{
109854+ if (write && !capable(CAP_SYS_MODULE))
109855+ return -EPERM;
109856+
109857+ return _proc_do_string(table->data, table->maxlen, write,
109858+ buffer, lenp, ppos);
109859+}
109860+
109861 static size_t proc_skip_spaces(char **buf)
109862 {
109863 size_t ret;
109864@@ -1957,6 +2025,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
109865 len = strlen(tmp);
109866 if (len > *size)
109867 len = *size;
109868+ if (len > sizeof(tmp))
109869+ len = sizeof(tmp);
109870 if (copy_to_user(*buf, tmp, len))
109871 return -EFAULT;
109872 *size -= len;
109873@@ -1995,7 +2065,7 @@ static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
109874 int val = *valp;
109875 if (val < 0) {
109876 *negp = true;
109877- *lvalp = (unsigned long)-val;
109878+ *lvalp = -(unsigned long)val;
109879 } else {
109880 *negp = false;
109881 *lvalp = (unsigned long)val;
109882@@ -2135,6 +2205,44 @@ int proc_dointvec(struct ctl_table *table, int write,
109883 NULL,NULL);
109884 }
109885
109886+static int do_proc_dointvec_conv_secure(bool *negp, unsigned long *lvalp,
109887+ int *valp,
109888+ int write, void *data)
109889+{
109890+ if (write) {
109891+ if (*negp) {
109892+ if (*lvalp > (unsigned long) INT_MAX + 1)
109893+ return -EINVAL;
109894+ pax_open_kernel();
109895+ *valp = -*lvalp;
109896+ pax_close_kernel();
109897+ } else {
109898+ if (*lvalp > (unsigned long) INT_MAX)
109899+ return -EINVAL;
109900+ pax_open_kernel();
109901+ *valp = *lvalp;
109902+ pax_close_kernel();
109903+ }
109904+ } else {
109905+ int val = *valp;
109906+ if (val < 0) {
109907+ *negp = true;
109908+ *lvalp = -(unsigned long)val;
109909+ } else {
109910+ *negp = false;
109911+ *lvalp = (unsigned long)val;
109912+ }
109913+ }
109914+ return 0;
109915+}
109916+
109917+int proc_dointvec_secure(struct ctl_table *table, int write,
109918+ void __user *buffer, size_t *lenp, loff_t *ppos)
109919+{
109920+ return do_proc_dointvec(table,write,buffer,lenp,ppos,
109921+ do_proc_dointvec_conv_secure,NULL);
109922+}
109923+
109924 /*
109925 * Taint values can only be increased
109926 * This means we can safely use a temporary.
109927@@ -2142,7 +2250,7 @@ int proc_dointvec(struct ctl_table *table, int write,
109928 static int proc_taint(struct ctl_table *table, int write,
109929 void __user *buffer, size_t *lenp, loff_t *ppos)
109930 {
109931- struct ctl_table t;
109932+ ctl_table_no_const t;
109933 unsigned long tmptaint = get_taint();
109934 int err;
109935
109936@@ -2170,16 +2278,14 @@ static int proc_taint(struct ctl_table *table, int write,
109937 return err;
109938 }
109939
109940-#ifdef CONFIG_PRINTK
109941-static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
109942+static int proc_dointvec_minmax_secure_sysadmin(struct ctl_table *table, int write,
109943 void __user *buffer, size_t *lenp, loff_t *ppos)
109944 {
109945 if (write && !capable(CAP_SYS_ADMIN))
109946 return -EPERM;
109947
109948- return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
109949+ return proc_dointvec_minmax_secure(table, write, buffer, lenp, ppos);
109950 }
109951-#endif
109952
109953 struct do_proc_dointvec_minmax_conv_param {
109954 int *min;
109955@@ -2201,7 +2307,33 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
109956 int val = *valp;
109957 if (val < 0) {
109958 *negp = true;
109959- *lvalp = (unsigned long)-val;
109960+ *lvalp = -(unsigned long)val;
109961+ } else {
109962+ *negp = false;
109963+ *lvalp = (unsigned long)val;
109964+ }
109965+ }
109966+ return 0;
109967+}
109968+
109969+static int do_proc_dointvec_minmax_conv_secure(bool *negp, unsigned long *lvalp,
109970+ int *valp,
109971+ int write, void *data)
109972+{
109973+ struct do_proc_dointvec_minmax_conv_param *param = data;
109974+ if (write) {
109975+ int val = *negp ? -*lvalp : *lvalp;
109976+ if ((param->min && *param->min > val) ||
109977+ (param->max && *param->max < val))
109978+ return -EINVAL;
109979+ pax_open_kernel();
109980+ *valp = val;
109981+ pax_close_kernel();
109982+ } else {
109983+ int val = *valp;
109984+ if (val < 0) {
109985+ *negp = true;
109986+ *lvalp = -(unsigned long)val;
109987 } else {
109988 *negp = false;
109989 *lvalp = (unsigned long)val;
109990@@ -2237,6 +2369,17 @@ int proc_dointvec_minmax(struct ctl_table *table, int write,
109991 do_proc_dointvec_minmax_conv, &param);
109992 }
109993
109994+int proc_dointvec_minmax_secure(struct ctl_table *table, int write,
109995+ void __user *buffer, size_t *lenp, loff_t *ppos)
109996+{
109997+ struct do_proc_dointvec_minmax_conv_param param = {
109998+ .min = (int *) table->extra1,
109999+ .max = (int *) table->extra2,
110000+ };
110001+ return do_proc_dointvec(table, write, buffer, lenp, ppos,
110002+ do_proc_dointvec_minmax_conv_secure, &param);
110003+}
110004+
110005 static void validate_coredump_safety(void)
110006 {
110007 #ifdef CONFIG_COREDUMP
110008@@ -2436,7 +2579,7 @@ static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
110009 unsigned long lval;
110010 if (val < 0) {
110011 *negp = true;
110012- lval = (unsigned long)-val;
110013+ lval = -(unsigned long)val;
110014 } else {
110015 *negp = false;
110016 lval = (unsigned long)val;
110017@@ -2459,7 +2602,7 @@ static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp
110018 unsigned long lval;
110019 if (val < 0) {
110020 *negp = true;
110021- lval = (unsigned long)-val;
110022+ lval = -(unsigned long)val;
110023 } else {
110024 *negp = false;
110025 lval = (unsigned long)val;
110026@@ -2484,7 +2627,7 @@ static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
110027 unsigned long lval;
110028 if (val < 0) {
110029 *negp = true;
110030- lval = (unsigned long)-val;
110031+ lval = -(unsigned long)val;
110032 } else {
110033 *negp = false;
110034 lval = (unsigned long)val;
110035@@ -2739,6 +2882,12 @@ int proc_dostring(struct ctl_table *table, int write,
110036 return -ENOSYS;
110037 }
110038
110039+int proc_dostring_modpriv(struct ctl_table *table, int write,
110040+ void __user *buffer, size_t *lenp, loff_t *ppos)
110041+{
110042+ return -ENOSYS;
110043+}
110044+
110045 int proc_dointvec(struct ctl_table *table, int write,
110046 void __user *buffer, size_t *lenp, loff_t *ppos)
110047 {
110048@@ -2795,5 +2944,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
110049 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
110050 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
110051 EXPORT_SYMBOL(proc_dostring);
110052+EXPORT_SYMBOL(proc_dostring_modpriv);
110053 EXPORT_SYMBOL(proc_doulongvec_minmax);
110054 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
110055diff --git a/kernel/taskstats.c b/kernel/taskstats.c
110056index 21f82c2..c1984e5 100644
110057--- a/kernel/taskstats.c
110058+++ b/kernel/taskstats.c
110059@@ -28,9 +28,12 @@
110060 #include <linux/fs.h>
110061 #include <linux/file.h>
110062 #include <linux/pid_namespace.h>
110063+#include <linux/grsecurity.h>
110064 #include <net/genetlink.h>
110065 #include <linux/atomic.h>
110066
110067+extern int gr_is_taskstats_denied(int pid);
110068+
110069 /*
110070 * Maximum length of a cpumask that can be specified in
110071 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
110072@@ -567,6 +570,9 @@ err:
110073
110074 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
110075 {
110076+ if (gr_is_taskstats_denied(current->pid))
110077+ return -EACCES;
110078+
110079 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
110080 return cmd_attr_register_cpumask(info);
110081 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
110082diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
110083index 7fbba635..7cc64ae 100644
110084--- a/kernel/time/alarmtimer.c
110085+++ b/kernel/time/alarmtimer.c
110086@@ -820,7 +820,7 @@ static int __init alarmtimer_init(void)
110087 struct platform_device *pdev;
110088 int error = 0;
110089 int i;
110090- struct k_clock alarm_clock = {
110091+ static struct k_clock alarm_clock = {
110092 .clock_getres = alarm_clock_getres,
110093 .clock_get = alarm_clock_get,
110094 .timer_create = alarm_timer_create,
110095diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
110096index 892e3da..cb71aa5 100644
110097--- a/kernel/time/posix-cpu-timers.c
110098+++ b/kernel/time/posix-cpu-timers.c
110099@@ -1470,14 +1470,14 @@ struct k_clock clock_posix_cpu = {
110100
110101 static __init int init_posix_cpu_timers(void)
110102 {
110103- struct k_clock process = {
110104+ static struct k_clock process = {
110105 .clock_getres = process_cpu_clock_getres,
110106 .clock_get = process_cpu_clock_get,
110107 .timer_create = process_cpu_timer_create,
110108 .nsleep = process_cpu_nsleep,
110109 .nsleep_restart = process_cpu_nsleep_restart,
110110 };
110111- struct k_clock thread = {
110112+ static struct k_clock thread = {
110113 .clock_getres = thread_cpu_clock_getres,
110114 .clock_get = thread_cpu_clock_get,
110115 .timer_create = thread_cpu_timer_create,
110116diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
110117index 31d11ac..5a3bb13 100644
110118--- a/kernel/time/posix-timers.c
110119+++ b/kernel/time/posix-timers.c
110120@@ -43,6 +43,7 @@
110121 #include <linux/hash.h>
110122 #include <linux/posix-clock.h>
110123 #include <linux/posix-timers.h>
110124+#include <linux/grsecurity.h>
110125 #include <linux/syscalls.h>
110126 #include <linux/wait.h>
110127 #include <linux/workqueue.h>
110128@@ -124,7 +125,7 @@ static DEFINE_SPINLOCK(hash_lock);
110129 * which we beg off on and pass to do_sys_settimeofday().
110130 */
110131
110132-static struct k_clock posix_clocks[MAX_CLOCKS];
110133+static struct k_clock *posix_clocks[MAX_CLOCKS];
110134
110135 /*
110136 * These ones are defined below.
110137@@ -284,7 +285,7 @@ static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec *tp)
110138 */
110139 static __init int init_posix_timers(void)
110140 {
110141- struct k_clock clock_realtime = {
110142+ static struct k_clock clock_realtime = {
110143 .clock_getres = posix_get_hrtimer_res,
110144 .clock_get = posix_clock_realtime_get,
110145 .clock_set = posix_clock_realtime_set,
110146@@ -296,7 +297,7 @@ static __init int init_posix_timers(void)
110147 .timer_get = common_timer_get,
110148 .timer_del = common_timer_del,
110149 };
110150- struct k_clock clock_monotonic = {
110151+ static struct k_clock clock_monotonic = {
110152 .clock_getres = posix_get_hrtimer_res,
110153 .clock_get = posix_ktime_get_ts,
110154 .nsleep = common_nsleep,
110155@@ -306,19 +307,19 @@ static __init int init_posix_timers(void)
110156 .timer_get = common_timer_get,
110157 .timer_del = common_timer_del,
110158 };
110159- struct k_clock clock_monotonic_raw = {
110160+ static struct k_clock clock_monotonic_raw = {
110161 .clock_getres = posix_get_hrtimer_res,
110162 .clock_get = posix_get_monotonic_raw,
110163 };
110164- struct k_clock clock_realtime_coarse = {
110165+ static struct k_clock clock_realtime_coarse = {
110166 .clock_getres = posix_get_coarse_res,
110167 .clock_get = posix_get_realtime_coarse,
110168 };
110169- struct k_clock clock_monotonic_coarse = {
110170+ static struct k_clock clock_monotonic_coarse = {
110171 .clock_getres = posix_get_coarse_res,
110172 .clock_get = posix_get_monotonic_coarse,
110173 };
110174- struct k_clock clock_tai = {
110175+ static struct k_clock clock_tai = {
110176 .clock_getres = posix_get_hrtimer_res,
110177 .clock_get = posix_get_tai,
110178 .nsleep = common_nsleep,
110179@@ -328,7 +329,7 @@ static __init int init_posix_timers(void)
110180 .timer_get = common_timer_get,
110181 .timer_del = common_timer_del,
110182 };
110183- struct k_clock clock_boottime = {
110184+ static struct k_clock clock_boottime = {
110185 .clock_getres = posix_get_hrtimer_res,
110186 .clock_get = posix_get_boottime,
110187 .nsleep = common_nsleep,
110188@@ -540,7 +541,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
110189 return;
110190 }
110191
110192- posix_clocks[clock_id] = *new_clock;
110193+ posix_clocks[clock_id] = new_clock;
110194 }
110195 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
110196
110197@@ -586,9 +587,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
110198 return (id & CLOCKFD_MASK) == CLOCKFD ?
110199 &clock_posix_dynamic : &clock_posix_cpu;
110200
110201- if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
110202+ if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
110203 return NULL;
110204- return &posix_clocks[id];
110205+ return posix_clocks[id];
110206 }
110207
110208 static int common_timer_create(struct k_itimer *new_timer)
110209@@ -606,7 +607,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
110210 struct k_clock *kc = clockid_to_kclock(which_clock);
110211 struct k_itimer *new_timer;
110212 int error, new_timer_id;
110213- sigevent_t event;
110214+ sigevent_t event = { };
110215 int it_id_set = IT_ID_NOT_SET;
110216
110217 if (!kc)
110218@@ -1021,6 +1022,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
110219 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
110220 return -EFAULT;
110221
110222+ /* only the CLOCK_REALTIME clock can be set, all other clocks
110223+ have their clock_set fptr set to a nosettime dummy function
110224+ CLOCK_REALTIME has a NULL clock_set fptr which causes it to
110225+ call common_clock_set, which calls do_sys_settimeofday, which
110226+ we hook
110227+ */
110228+
110229 return kc->clock_set(which_clock, &new_tp);
110230 }
110231
110232diff --git a/kernel/time/time.c b/kernel/time/time.c
110233index 85d5bb1..aeca463 100644
110234--- a/kernel/time/time.c
110235+++ b/kernel/time/time.c
110236@@ -177,6 +177,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
110237 if (tz->tz_minuteswest > 15*60 || tz->tz_minuteswest < -15*60)
110238 return -EINVAL;
110239
110240+ /* we log in do_settimeofday called below, so don't log twice
110241+ */
110242+ if (!tv)
110243+ gr_log_timechange();
110244+
110245 sys_tz = *tz;
110246 update_vsyscall_tz();
110247 if (firsttime) {
110248diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
110249index a20d411..255b10a 100644
110250--- a/kernel/time/timekeeping.c
110251+++ b/kernel/time/timekeeping.c
110252@@ -15,6 +15,7 @@
110253 #include <linux/init.h>
110254 #include <linux/mm.h>
110255 #include <linux/sched.h>
110256+#include <linux/grsecurity.h>
110257 #include <linux/syscore_ops.h>
110258 #include <linux/clocksource.h>
110259 #include <linux/jiffies.h>
110260@@ -915,6 +916,8 @@ int do_settimeofday64(const struct timespec64 *ts)
110261 if (!timespec64_valid_strict(ts))
110262 return -EINVAL;
110263
110264+ gr_log_timechange();
110265+
110266 raw_spin_lock_irqsave(&timekeeper_lock, flags);
110267 write_seqcount_begin(&tk_core.seq);
110268
110269diff --git a/kernel/time/timer.c b/kernel/time/timer.c
110270index 84190f0..6f4ccad 100644
110271--- a/kernel/time/timer.c
110272+++ b/kernel/time/timer.c
110273@@ -1406,7 +1406,7 @@ void update_process_times(int user_tick)
110274 /*
110275 * This function runs timers and the timer-tq in bottom half context.
110276 */
110277-static void run_timer_softirq(struct softirq_action *h)
110278+static __latent_entropy void run_timer_softirq(void)
110279 {
110280 struct tvec_base *base = this_cpu_ptr(&tvec_bases);
110281
110282diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
110283index a4536e1..5d8774c 100644
110284--- a/kernel/time/timer_list.c
110285+++ b/kernel/time/timer_list.c
110286@@ -50,12 +50,16 @@ static void SEQ_printf(struct seq_file *m, const char *fmt, ...)
110287
110288 static void print_name_offset(struct seq_file *m, void *sym)
110289 {
110290+#ifdef CONFIG_GRKERNSEC_HIDESYM
110291+ SEQ_printf(m, "<%p>", NULL);
110292+#else
110293 char symname[KSYM_NAME_LEN];
110294
110295 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
110296 SEQ_printf(m, "<%pK>", sym);
110297 else
110298 SEQ_printf(m, "%s", symname);
110299+#endif
110300 }
110301
110302 static void
110303@@ -124,11 +128,14 @@ next_one:
110304 static void
110305 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
110306 {
110307+#ifdef CONFIG_GRKERNSEC_HIDESYM
110308+ SEQ_printf(m, " .base: %p\n", NULL);
110309+#else
110310 SEQ_printf(m, " .base: %pK\n", base);
110311+#endif
110312 SEQ_printf(m, " .index: %d\n", base->index);
110313
110314 SEQ_printf(m, " .resolution: %u nsecs\n", (unsigned) hrtimer_resolution);
110315-
110316 SEQ_printf(m, " .get_time: ");
110317 print_name_offset(m, base->get_time);
110318 SEQ_printf(m, "\n");
110319@@ -399,7 +406,11 @@ static int __init init_timer_list_procfs(void)
110320 {
110321 struct proc_dir_entry *pe;
110322
110323+#ifdef CONFIG_GRKERNSEC_PROC_ADD
110324+ pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
110325+#else
110326 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
110327+#endif
110328 if (!pe)
110329 return -ENOMEM;
110330 return 0;
110331diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
110332index 1adecb4..b4fb631 100644
110333--- a/kernel/time/timer_stats.c
110334+++ b/kernel/time/timer_stats.c
110335@@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
110336 static unsigned long nr_entries;
110337 static struct entry entries[MAX_ENTRIES];
110338
110339-static atomic_t overflow_count;
110340+static atomic_unchecked_t overflow_count;
110341
110342 /*
110343 * The entries are in a hash-table, for fast lookup:
110344@@ -140,7 +140,7 @@ static void reset_entries(void)
110345 nr_entries = 0;
110346 memset(entries, 0, sizeof(entries));
110347 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
110348- atomic_set(&overflow_count, 0);
110349+ atomic_set_unchecked(&overflow_count, 0);
110350 }
110351
110352 static struct entry *alloc_entry(void)
110353@@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
110354 if (likely(entry))
110355 entry->count++;
110356 else
110357- atomic_inc(&overflow_count);
110358+ atomic_inc_unchecked(&overflow_count);
110359
110360 out_unlock:
110361 raw_spin_unlock_irqrestore(lock, flags);
110362@@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
110363
110364 static void print_name_offset(struct seq_file *m, unsigned long addr)
110365 {
110366+#ifdef CONFIG_GRKERNSEC_HIDESYM
110367+ seq_printf(m, "<%p>", NULL);
110368+#else
110369 char symname[KSYM_NAME_LEN];
110370
110371 if (lookup_symbol_name(addr, symname) < 0)
110372- seq_printf(m, "<%p>", (void *)addr);
110373+ seq_printf(m, "<%pK>", (void *)addr);
110374 else
110375 seq_printf(m, "%s", symname);
110376+#endif
110377 }
110378
110379 static int tstats_show(struct seq_file *m, void *v)
110380@@ -300,8 +304,8 @@ static int tstats_show(struct seq_file *m, void *v)
110381
110382 seq_puts(m, "Timer Stats Version: v0.3\n");
110383 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
110384- if (atomic_read(&overflow_count))
110385- seq_printf(m, "Overflow: %d entries\n", atomic_read(&overflow_count));
110386+ if (atomic_read_unchecked(&overflow_count))
110387+ seq_printf(m, "Overflow: %d entries\n", atomic_read_unchecked(&overflow_count));
110388 seq_printf(m, "Collection: %s\n", timer_stats_active ? "active" : "inactive");
110389
110390 for (i = 0; i < nr_entries; i++) {
110391@@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
110392 {
110393 struct proc_dir_entry *pe;
110394
110395+#ifdef CONFIG_GRKERNSEC_PROC_ADD
110396+ pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
110397+#else
110398 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
110399+#endif
110400 if (!pe)
110401 return -ENOMEM;
110402 return 0;
110403diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
110404index 3b9a48a..6125816 100644
110405--- a/kernel/trace/Kconfig
110406+++ b/kernel/trace/Kconfig
110407@@ -120,6 +120,7 @@ config TRACING_SUPPORT
110408 # irqflags tracing for your architecture.
110409 depends on TRACE_IRQFLAGS_SUPPORT || PPC32
110410 depends on STACKTRACE_SUPPORT
110411+ depends on !GRKERNSEC_KMEM
110412 default y
110413
110414 if TRACING_SUPPORT
110415@@ -378,6 +379,7 @@ config BLK_DEV_IO_TRACE
110416 depends on BLOCK
110417 select RELAY
110418 select DEBUG_FS
110419+ depends on !GRKERNSEC_KMEM
110420 select TRACEPOINTS
110421 select GENERIC_TRACER
110422 select STACKTRACE
110423diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
110424index b3e6b39..719099b 100644
110425--- a/kernel/trace/blktrace.c
110426+++ b/kernel/trace/blktrace.c
110427@@ -328,7 +328,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
110428 struct blk_trace *bt = filp->private_data;
110429 char buf[16];
110430
110431- snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
110432+ snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
110433
110434 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
110435 }
110436@@ -386,7 +386,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
110437 return 1;
110438
110439 bt = buf->chan->private_data;
110440- atomic_inc(&bt->dropped);
110441+ atomic_inc_unchecked(&bt->dropped);
110442 return 0;
110443 }
110444
110445@@ -485,7 +485,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
110446
110447 bt->dir = dir;
110448 bt->dev = dev;
110449- atomic_set(&bt->dropped, 0);
110450+ atomic_set_unchecked(&bt->dropped, 0);
110451 INIT_LIST_HEAD(&bt->running_list);
110452
110453 ret = -EIO;
110454diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
110455index eb11011..43adc29 100644
110456--- a/kernel/trace/ftrace.c
110457+++ b/kernel/trace/ftrace.c
110458@@ -2413,12 +2413,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
110459 if (unlikely(ftrace_disabled))
110460 return 0;
110461
110462+ ret = ftrace_arch_code_modify_prepare();
110463+ FTRACE_WARN_ON(ret);
110464+ if (ret)
110465+ return 0;
110466+
110467 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
110468+ FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
110469 if (ret) {
110470 ftrace_bug(ret, rec);
110471- return 0;
110472 }
110473- return 1;
110474+ return ret ? 0 : 1;
110475 }
110476
110477 /*
110478@@ -4807,8 +4812,10 @@ static int ftrace_process_locs(struct module *mod,
110479 if (!count)
110480 return 0;
110481
110482+ pax_open_kernel();
110483 sort(start, count, sizeof(*start),
110484 ftrace_cmp_ips, ftrace_swap_ips);
110485+ pax_close_kernel();
110486
110487 start_pg = ftrace_allocate_pages(count);
110488 if (!start_pg)
110489@@ -5675,7 +5682,7 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list)
110490
110491 if (t->ret_stack == NULL) {
110492 atomic_set(&t->tracing_graph_pause, 0);
110493- atomic_set(&t->trace_overrun, 0);
110494+ atomic_set_unchecked(&t->trace_overrun, 0);
110495 t->curr_ret_stack = -1;
110496 /* Make sure the tasks see the -1 first: */
110497 smp_wmb();
110498@@ -5898,7 +5905,7 @@ static void
110499 graph_init_task(struct task_struct *t, struct ftrace_ret_stack *ret_stack)
110500 {
110501 atomic_set(&t->tracing_graph_pause, 0);
110502- atomic_set(&t->trace_overrun, 0);
110503+ atomic_set_unchecked(&t->trace_overrun, 0);
110504 t->ftrace_timestamp = 0;
110505 /* make curr_ret_stack visible before we add the ret_stack */
110506 smp_wmb();
110507diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
110508index 6260717..b9bd83c 100644
110509--- a/kernel/trace/ring_buffer.c
110510+++ b/kernel/trace/ring_buffer.c
110511@@ -296,9 +296,9 @@ struct buffer_data_page {
110512 */
110513 struct buffer_page {
110514 struct list_head list; /* list of buffer pages */
110515- local_t write; /* index for next write */
110516+ local_unchecked_t write; /* index for next write */
110517 unsigned read; /* index for next read */
110518- local_t entries; /* entries on this page */
110519+ local_unchecked_t entries; /* entries on this page */
110520 unsigned long real_end; /* real end of data */
110521 struct buffer_data_page *page; /* Actual data page */
110522 };
110523@@ -437,11 +437,11 @@ struct ring_buffer_per_cpu {
110524 unsigned long last_overrun;
110525 local_t entries_bytes;
110526 local_t entries;
110527- local_t overrun;
110528- local_t commit_overrun;
110529- local_t dropped_events;
110530+ local_unchecked_t overrun;
110531+ local_unchecked_t commit_overrun;
110532+ local_unchecked_t dropped_events;
110533 local_t committing;
110534- local_t commits;
110535+ local_unchecked_t commits;
110536 unsigned long read;
110537 unsigned long read_bytes;
110538 u64 write_stamp;
110539@@ -1011,8 +1011,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
110540 *
110541 * We add a counter to the write field to denote this.
110542 */
110543- old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
110544- old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
110545+ old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
110546+ old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
110547
110548 /*
110549 * Just make sure we have seen our old_write and synchronize
110550@@ -1040,8 +1040,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
110551 * cmpxchg to only update if an interrupt did not already
110552 * do it for us. If the cmpxchg fails, we don't care.
110553 */
110554- (void)local_cmpxchg(&next_page->write, old_write, val);
110555- (void)local_cmpxchg(&next_page->entries, old_entries, eval);
110556+ (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
110557+ (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
110558
110559 /*
110560 * No need to worry about races with clearing out the commit.
110561@@ -1409,12 +1409,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
110562
110563 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
110564 {
110565- return local_read(&bpage->entries) & RB_WRITE_MASK;
110566+ return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
110567 }
110568
110569 static inline unsigned long rb_page_write(struct buffer_page *bpage)
110570 {
110571- return local_read(&bpage->write) & RB_WRITE_MASK;
110572+ return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
110573 }
110574
110575 static int
110576@@ -1509,7 +1509,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
110577 * bytes consumed in ring buffer from here.
110578 * Increment overrun to account for the lost events.
110579 */
110580- local_add(page_entries, &cpu_buffer->overrun);
110581+ local_add_unchecked(page_entries, &cpu_buffer->overrun);
110582 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
110583 }
110584
110585@@ -2071,7 +2071,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
110586 * it is our responsibility to update
110587 * the counters.
110588 */
110589- local_add(entries, &cpu_buffer->overrun);
110590+ local_add_unchecked(entries, &cpu_buffer->overrun);
110591 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
110592
110593 /*
110594@@ -2221,7 +2221,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
110595 if (tail == BUF_PAGE_SIZE)
110596 tail_page->real_end = 0;
110597
110598- local_sub(length, &tail_page->write);
110599+ local_sub_unchecked(length, &tail_page->write);
110600 return;
110601 }
110602
110603@@ -2256,7 +2256,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
110604 rb_event_set_padding(event);
110605
110606 /* Set the write back to the previous setting */
110607- local_sub(length, &tail_page->write);
110608+ local_sub_unchecked(length, &tail_page->write);
110609 return;
110610 }
110611
110612@@ -2268,7 +2268,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
110613
110614 /* Set write to end of buffer */
110615 length = (tail + length) - BUF_PAGE_SIZE;
110616- local_sub(length, &tail_page->write);
110617+ local_sub_unchecked(length, &tail_page->write);
110618 }
110619
110620 /*
110621@@ -2294,7 +2294,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
110622 * about it.
110623 */
110624 if (unlikely(next_page == commit_page)) {
110625- local_inc(&cpu_buffer->commit_overrun);
110626+ local_inc_unchecked(&cpu_buffer->commit_overrun);
110627 goto out_reset;
110628 }
110629
110630@@ -2324,7 +2324,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
110631 * this is easy, just stop here.
110632 */
110633 if (!(buffer->flags & RB_FL_OVERWRITE)) {
110634- local_inc(&cpu_buffer->dropped_events);
110635+ local_inc_unchecked(&cpu_buffer->dropped_events);
110636 goto out_reset;
110637 }
110638
110639@@ -2350,7 +2350,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
110640 cpu_buffer->tail_page) &&
110641 (cpu_buffer->commit_page ==
110642 cpu_buffer->reader_page))) {
110643- local_inc(&cpu_buffer->commit_overrun);
110644+ local_inc_unchecked(&cpu_buffer->commit_overrun);
110645 goto out_reset;
110646 }
110647 }
110648@@ -2398,7 +2398,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
110649 length += RB_LEN_TIME_EXTEND;
110650
110651 tail_page = cpu_buffer->tail_page;
110652- write = local_add_return(length, &tail_page->write);
110653+ write = local_add_return_unchecked(length, &tail_page->write);
110654
110655 /* set write to only the index of the write */
110656 write &= RB_WRITE_MASK;
110657@@ -2422,7 +2422,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
110658 kmemcheck_annotate_bitfield(event, bitfield);
110659 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
110660
110661- local_inc(&tail_page->entries);
110662+ local_inc_unchecked(&tail_page->entries);
110663
110664 /*
110665 * If this is the first commit on the page, then update
110666@@ -2455,7 +2455,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
110667
110668 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
110669 unsigned long write_mask =
110670- local_read(&bpage->write) & ~RB_WRITE_MASK;
110671+ local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
110672 unsigned long event_length = rb_event_length(event);
110673 /*
110674 * This is on the tail page. It is possible that
110675@@ -2465,7 +2465,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
110676 */
110677 old_index += write_mask;
110678 new_index += write_mask;
110679- index = local_cmpxchg(&bpage->write, old_index, new_index);
110680+ index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
110681 if (index == old_index) {
110682 /* update counters */
110683 local_sub(event_length, &cpu_buffer->entries_bytes);
110684@@ -2480,7 +2480,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
110685 static void rb_start_commit(struct ring_buffer_per_cpu *cpu_buffer)
110686 {
110687 local_inc(&cpu_buffer->committing);
110688- local_inc(&cpu_buffer->commits);
110689+ local_inc_unchecked(&cpu_buffer->commits);
110690 }
110691
110692 static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
110693@@ -2492,7 +2492,7 @@ static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
110694 return;
110695
110696 again:
110697- commits = local_read(&cpu_buffer->commits);
110698+ commits = local_read_unchecked(&cpu_buffer->commits);
110699 /* synchronize with interrupts */
110700 barrier();
110701 if (local_read(&cpu_buffer->committing) == 1)
110702@@ -2508,7 +2508,7 @@ static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
110703 * updating of the commit page and the clearing of the
110704 * committing counter.
110705 */
110706- if (unlikely(local_read(&cpu_buffer->commits) != commits) &&
110707+ if (unlikely(local_read_unchecked(&cpu_buffer->commits) != commits) &&
110708 !local_read(&cpu_buffer->committing)) {
110709 local_inc(&cpu_buffer->committing);
110710 goto again;
110711@@ -2538,7 +2538,7 @@ rb_reserve_next_event(struct ring_buffer *buffer,
110712 barrier();
110713 if (unlikely(ACCESS_ONCE(cpu_buffer->buffer) != buffer)) {
110714 local_dec(&cpu_buffer->committing);
110715- local_dec(&cpu_buffer->commits);
110716+ local_dec_unchecked(&cpu_buffer->commits);
110717 return NULL;
110718 }
110719 #endif
110720@@ -2852,7 +2852,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
110721
110722 /* Do the likely case first */
110723 if (likely(bpage->page == (void *)addr)) {
110724- local_dec(&bpage->entries);
110725+ local_dec_unchecked(&bpage->entries);
110726 return;
110727 }
110728
110729@@ -2864,7 +2864,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
110730 start = bpage;
110731 do {
110732 if (bpage->page == (void *)addr) {
110733- local_dec(&bpage->entries);
110734+ local_dec_unchecked(&bpage->entries);
110735 return;
110736 }
110737 rb_inc_page(cpu_buffer, &bpage);
110738@@ -3152,7 +3152,7 @@ static inline unsigned long
110739 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
110740 {
110741 return local_read(&cpu_buffer->entries) -
110742- (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
110743+ (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
110744 }
110745
110746 /**
110747@@ -3241,7 +3241,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
110748 return 0;
110749
110750 cpu_buffer = buffer->buffers[cpu];
110751- ret = local_read(&cpu_buffer->overrun);
110752+ ret = local_read_unchecked(&cpu_buffer->overrun);
110753
110754 return ret;
110755 }
110756@@ -3264,7 +3264,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
110757 return 0;
110758
110759 cpu_buffer = buffer->buffers[cpu];
110760- ret = local_read(&cpu_buffer->commit_overrun);
110761+ ret = local_read_unchecked(&cpu_buffer->commit_overrun);
110762
110763 return ret;
110764 }
110765@@ -3286,7 +3286,7 @@ ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu)
110766 return 0;
110767
110768 cpu_buffer = buffer->buffers[cpu];
110769- ret = local_read(&cpu_buffer->dropped_events);
110770+ ret = local_read_unchecked(&cpu_buffer->dropped_events);
110771
110772 return ret;
110773 }
110774@@ -3349,7 +3349,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
110775 /* if you care about this being correct, lock the buffer */
110776 for_each_buffer_cpu(buffer, cpu) {
110777 cpu_buffer = buffer->buffers[cpu];
110778- overruns += local_read(&cpu_buffer->overrun);
110779+ overruns += local_read_unchecked(&cpu_buffer->overrun);
110780 }
110781
110782 return overruns;
110783@@ -3520,8 +3520,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
110784 /*
110785 * Reset the reader page to size zero.
110786 */
110787- local_set(&cpu_buffer->reader_page->write, 0);
110788- local_set(&cpu_buffer->reader_page->entries, 0);
110789+ local_set_unchecked(&cpu_buffer->reader_page->write, 0);
110790+ local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
110791 local_set(&cpu_buffer->reader_page->page->commit, 0);
110792 cpu_buffer->reader_page->real_end = 0;
110793
110794@@ -3555,7 +3555,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
110795 * want to compare with the last_overrun.
110796 */
110797 smp_mb();
110798- overwrite = local_read(&(cpu_buffer->overrun));
110799+ overwrite = local_read_unchecked(&(cpu_buffer->overrun));
110800
110801 /*
110802 * Here's the tricky part.
110803@@ -4137,8 +4137,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
110804
110805 cpu_buffer->head_page
110806 = list_entry(cpu_buffer->pages, struct buffer_page, list);
110807- local_set(&cpu_buffer->head_page->write, 0);
110808- local_set(&cpu_buffer->head_page->entries, 0);
110809+ local_set_unchecked(&cpu_buffer->head_page->write, 0);
110810+ local_set_unchecked(&cpu_buffer->head_page->entries, 0);
110811 local_set(&cpu_buffer->head_page->page->commit, 0);
110812
110813 cpu_buffer->head_page->read = 0;
110814@@ -4148,18 +4148,18 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
110815
110816 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
110817 INIT_LIST_HEAD(&cpu_buffer->new_pages);
110818- local_set(&cpu_buffer->reader_page->write, 0);
110819- local_set(&cpu_buffer->reader_page->entries, 0);
110820+ local_set_unchecked(&cpu_buffer->reader_page->write, 0);
110821+ local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
110822 local_set(&cpu_buffer->reader_page->page->commit, 0);
110823 cpu_buffer->reader_page->read = 0;
110824
110825 local_set(&cpu_buffer->entries_bytes, 0);
110826- local_set(&cpu_buffer->overrun, 0);
110827- local_set(&cpu_buffer->commit_overrun, 0);
110828- local_set(&cpu_buffer->dropped_events, 0);
110829+ local_set_unchecked(&cpu_buffer->overrun, 0);
110830+ local_set_unchecked(&cpu_buffer->commit_overrun, 0);
110831+ local_set_unchecked(&cpu_buffer->dropped_events, 0);
110832 local_set(&cpu_buffer->entries, 0);
110833 local_set(&cpu_buffer->committing, 0);
110834- local_set(&cpu_buffer->commits, 0);
110835+ local_set_unchecked(&cpu_buffer->commits, 0);
110836 cpu_buffer->read = 0;
110837 cpu_buffer->read_bytes = 0;
110838
110839@@ -4549,8 +4549,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
110840 rb_init_page(bpage);
110841 bpage = reader->page;
110842 reader->page = *data_page;
110843- local_set(&reader->write, 0);
110844- local_set(&reader->entries, 0);
110845+ local_set_unchecked(&reader->write, 0);
110846+ local_set_unchecked(&reader->entries, 0);
110847 reader->read = 0;
110848 *data_page = bpage;
110849
110850diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
110851index abcbf7f..ef8b6fe 100644
110852--- a/kernel/trace/trace.c
110853+++ b/kernel/trace/trace.c
110854@@ -3539,7 +3539,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
110855 return 0;
110856 }
110857
110858-int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
110859+int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
110860 {
110861 /* do nothing if flag is already set */
110862 if (!!(trace_flags & mask) == !!enabled)
110863diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
110864index 74bde81..f9abfd4 100644
110865--- a/kernel/trace/trace.h
110866+++ b/kernel/trace/trace.h
110867@@ -1272,7 +1272,7 @@ extern const char *__stop___tracepoint_str[];
110868 void trace_printk_init_buffers(void);
110869 void trace_printk_start_comm(void);
110870 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
110871-int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
110872+int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
110873
110874 /*
110875 * Normal trace_printk() and friends allocates special buffers
110876diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
110877index 0f06532..247c8e7 100644
110878--- a/kernel/trace/trace_clock.c
110879+++ b/kernel/trace/trace_clock.c
110880@@ -127,7 +127,7 @@ u64 notrace trace_clock_global(void)
110881 }
110882 EXPORT_SYMBOL_GPL(trace_clock_global);
110883
110884-static atomic64_t trace_counter;
110885+static atomic64_unchecked_t trace_counter;
110886
110887 /*
110888 * trace_clock_counter(): simply an atomic counter.
110889@@ -136,5 +136,5 @@ static atomic64_t trace_counter;
110890 */
110891 u64 notrace trace_clock_counter(void)
110892 {
110893- return atomic64_add_return(1, &trace_counter);
110894+ return atomic64_inc_return_unchecked(&trace_counter);
110895 }
110896diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
110897index 404a372..d9e5547 100644
110898--- a/kernel/trace/trace_events.c
110899+++ b/kernel/trace/trace_events.c
110900@@ -1887,7 +1887,6 @@ __trace_early_add_new_event(struct trace_event_call *call,
110901 return 0;
110902 }
110903
110904-struct ftrace_module_file_ops;
110905 static void __add_event_to_tracers(struct trace_event_call *call);
110906
110907 /* Add an additional event_call dynamically */
110908diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
110909index 8968bf7..e6623fc 100644
110910--- a/kernel/trace/trace_functions_graph.c
110911+++ b/kernel/trace/trace_functions_graph.c
110912@@ -132,7 +132,7 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
110913
110914 /* The return trace stack is full */
110915 if (current->curr_ret_stack == FTRACE_RETFUNC_DEPTH - 1) {
110916- atomic_inc(&current->trace_overrun);
110917+ atomic_inc_unchecked(&current->trace_overrun);
110918 return -EBUSY;
110919 }
110920
110921@@ -229,7 +229,7 @@ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret,
110922 *ret = current->ret_stack[index].ret;
110923 trace->func = current->ret_stack[index].func;
110924 trace->calltime = current->ret_stack[index].calltime;
110925- trace->overrun = atomic_read(&current->trace_overrun);
110926+ trace->overrun = atomic_read_unchecked(&current->trace_overrun);
110927 trace->depth = index;
110928 }
110929
110930diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
110931index 638e110..99b73b2 100644
110932--- a/kernel/trace/trace_mmiotrace.c
110933+++ b/kernel/trace/trace_mmiotrace.c
110934@@ -24,7 +24,7 @@ struct header_iter {
110935 static struct trace_array *mmio_trace_array;
110936 static bool overrun_detected;
110937 static unsigned long prev_overruns;
110938-static atomic_t dropped_count;
110939+static atomic_unchecked_t dropped_count;
110940
110941 static void mmio_reset_data(struct trace_array *tr)
110942 {
110943@@ -124,7 +124,7 @@ static void mmio_close(struct trace_iterator *iter)
110944
110945 static unsigned long count_overruns(struct trace_iterator *iter)
110946 {
110947- unsigned long cnt = atomic_xchg(&dropped_count, 0);
110948+ unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
110949 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
110950
110951 if (over > prev_overruns)
110952@@ -307,7 +307,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
110953 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
110954 sizeof(*entry), 0, pc);
110955 if (!event) {
110956- atomic_inc(&dropped_count);
110957+ atomic_inc_unchecked(&dropped_count);
110958 return;
110959 }
110960 entry = ring_buffer_event_data(event);
110961@@ -337,7 +337,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
110962 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
110963 sizeof(*entry), 0, pc);
110964 if (!event) {
110965- atomic_inc(&dropped_count);
110966+ atomic_inc_unchecked(&dropped_count);
110967 return;
110968 }
110969 entry = ring_buffer_event_data(event);
110970diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
110971index dfab253..8e9b477 100644
110972--- a/kernel/trace/trace_output.c
110973+++ b/kernel/trace/trace_output.c
110974@@ -752,14 +752,16 @@ int register_trace_event(struct trace_event *event)
110975 goto out;
110976 }
110977
110978+ pax_open_kernel();
110979 if (event->funcs->trace == NULL)
110980- event->funcs->trace = trace_nop_print;
110981+ *(void **)&event->funcs->trace = trace_nop_print;
110982 if (event->funcs->raw == NULL)
110983- event->funcs->raw = trace_nop_print;
110984+ *(void **)&event->funcs->raw = trace_nop_print;
110985 if (event->funcs->hex == NULL)
110986- event->funcs->hex = trace_nop_print;
110987+ *(void **)&event->funcs->hex = trace_nop_print;
110988 if (event->funcs->binary == NULL)
110989- event->funcs->binary = trace_nop_print;
110990+ *(void **)&event->funcs->binary = trace_nop_print;
110991+ pax_close_kernel();
110992
110993 key = event->type & (EVENT_HASHSIZE - 1);
110994
110995diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c
110996index e694c9f..6775a38 100644
110997--- a/kernel/trace/trace_seq.c
110998+++ b/kernel/trace/trace_seq.c
110999@@ -337,7 +337,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
111000 return 0;
111001 }
111002
111003- seq_buf_path(&s->seq, path, "\n");
111004+ seq_buf_path(&s->seq, path, "\n\\");
111005
111006 if (unlikely(seq_buf_has_overflowed(&s->seq))) {
111007 s->seq.len = save_len;
111008diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
111009index 3f34496..0492d95 100644
111010--- a/kernel/trace/trace_stack.c
111011+++ b/kernel/trace/trace_stack.c
111012@@ -88,7 +88,7 @@ check_stack(unsigned long ip, unsigned long *stack)
111013 return;
111014
111015 /* we do not handle interrupt stacks yet */
111016- if (!object_is_on_stack(stack))
111017+ if (!object_starts_on_stack(stack))
111018 return;
111019
111020 local_irq_save(flags);
111021diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
111022index 7d567a4..407a28d 100644
111023--- a/kernel/trace/trace_syscalls.c
111024+++ b/kernel/trace/trace_syscalls.c
111025@@ -590,6 +590,8 @@ static int perf_sysenter_enable(struct trace_event_call *call)
111026 int num;
111027
111028 num = ((struct syscall_metadata *)call->data)->syscall_nr;
111029+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
111030+ return -EINVAL;
111031
111032 mutex_lock(&syscall_trace_lock);
111033 if (!sys_perf_refcount_enter)
111034@@ -610,6 +612,8 @@ static void perf_sysenter_disable(struct trace_event_call *call)
111035 int num;
111036
111037 num = ((struct syscall_metadata *)call->data)->syscall_nr;
111038+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
111039+ return;
111040
111041 mutex_lock(&syscall_trace_lock);
111042 sys_perf_refcount_enter--;
111043@@ -662,6 +666,8 @@ static int perf_sysexit_enable(struct trace_event_call *call)
111044 int num;
111045
111046 num = ((struct syscall_metadata *)call->data)->syscall_nr;
111047+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
111048+ return -EINVAL;
111049
111050 mutex_lock(&syscall_trace_lock);
111051 if (!sys_perf_refcount_exit)
111052@@ -682,6 +688,8 @@ static void perf_sysexit_disable(struct trace_event_call *call)
111053 int num;
111054
111055 num = ((struct syscall_metadata *)call->data)->syscall_nr;
111056+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
111057+ return;
111058
111059 mutex_lock(&syscall_trace_lock);
111060 sys_perf_refcount_exit--;
111061diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
111062index 4109f83..fe1f830 100644
111063--- a/kernel/user_namespace.c
111064+++ b/kernel/user_namespace.c
111065@@ -83,6 +83,21 @@ int create_user_ns(struct cred *new)
111066 !kgid_has_mapping(parent_ns, group))
111067 return -EPERM;
111068
111069+#ifdef CONFIG_GRKERNSEC
111070+ /*
111071+ * This doesn't really inspire confidence:
111072+ * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
111073+ * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
111074+ * Increases kernel attack surface in areas developers
111075+ * previously cared little about ("low importance due
111076+ * to requiring "root" capability")
111077+ * To be removed when this code receives *proper* review
111078+ */
111079+ if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
111080+ !capable(CAP_SETGID))
111081+ return -EPERM;
111082+#endif
111083+
111084 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
111085 if (!ns)
111086 return -ENOMEM;
111087@@ -980,7 +995,7 @@ static int userns_install(struct nsproxy *nsproxy, struct ns_common *ns)
111088 if (atomic_read(&current->mm->mm_users) > 1)
111089 return -EINVAL;
111090
111091- if (current->fs->users != 1)
111092+ if (atomic_read(&current->fs->users) != 1)
111093 return -EINVAL;
111094
111095 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
111096diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
111097index c8eac43..4b5f08f 100644
111098--- a/kernel/utsname_sysctl.c
111099+++ b/kernel/utsname_sysctl.c
111100@@ -47,7 +47,7 @@ static void put_uts(struct ctl_table *table, int write, void *which)
111101 static int proc_do_uts_string(struct ctl_table *table, int write,
111102 void __user *buffer, size_t *lenp, loff_t *ppos)
111103 {
111104- struct ctl_table uts_table;
111105+ ctl_table_no_const uts_table;
111106 int r;
111107 memcpy(&uts_table, table, sizeof(uts_table));
111108 uts_table.data = get_uts(table, write);
111109diff --git a/kernel/watchdog.c b/kernel/watchdog.c
111110index a6ffa43..e48103b 100644
111111--- a/kernel/watchdog.c
111112+++ b/kernel/watchdog.c
111113@@ -655,7 +655,7 @@ void watchdog_nmi_enable_all(void) {}
111114 void watchdog_nmi_disable_all(void) {}
111115 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
111116
111117-static struct smp_hotplug_thread watchdog_threads = {
111118+static struct smp_hotplug_thread watchdog_threads __read_only = {
111119 .store = &softlockup_watchdog,
111120 .thread_should_run = watchdog_should_run,
111121 .thread_fn = watchdog,
111122diff --git a/kernel/workqueue.c b/kernel/workqueue.c
111123index a413acb..9c3d36a 100644
111124--- a/kernel/workqueue.c
111125+++ b/kernel/workqueue.c
111126@@ -4452,7 +4452,7 @@ static void rebind_workers(struct worker_pool *pool)
111127 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
111128 worker_flags |= WORKER_REBOUND;
111129 worker_flags &= ~WORKER_UNBOUND;
111130- ACCESS_ONCE(worker->flags) = worker_flags;
111131+ ACCESS_ONCE_RW(worker->flags) = worker_flags;
111132 }
111133
111134 spin_unlock_irq(&pool->lock);
111135diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
111136index e2894b2..23751b3 100644
111137--- a/lib/Kconfig.debug
111138+++ b/lib/Kconfig.debug
111139@@ -242,6 +242,7 @@ config PAGE_OWNER
111140 bool "Track page owner"
111141 depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
111142 select DEBUG_FS
111143+ depends on !GRKERNSEC_KMEM
111144 select STACKTRACE
111145 select PAGE_EXTENSION
111146 help
111147@@ -256,6 +257,7 @@ config PAGE_OWNER
111148
111149 config DEBUG_FS
111150 bool "Debug Filesystem"
111151+ depends on !GRKERNSEC_KMEM
111152 help
111153 debugfs is a virtual file system that kernel developers use to put
111154 debugging files into. Enable this option to be able to read and
111155@@ -488,6 +490,7 @@ config DEBUG_KMEMLEAK
111156 bool "Kernel memory leak detector"
111157 depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK
111158 select DEBUG_FS
111159+ depends on !GRKERNSEC_KMEM
111160 select STACKTRACE if STACKTRACE_SUPPORT
111161 select KALLSYMS
111162 select CRC32
111163@@ -941,7 +944,7 @@ config DEBUG_MUTEXES
111164
111165 config DEBUG_WW_MUTEX_SLOWPATH
111166 bool "Wait/wound mutex debugging: Slowpath testing"
111167- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
111168+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
111169 select DEBUG_LOCK_ALLOC
111170 select DEBUG_SPINLOCK
111171 select DEBUG_MUTEXES
111172@@ -958,7 +961,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
111173
111174 config DEBUG_LOCK_ALLOC
111175 bool "Lock debugging: detect incorrect freeing of live locks"
111176- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
111177+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
111178 select DEBUG_SPINLOCK
111179 select DEBUG_MUTEXES
111180 select LOCKDEP
111181@@ -972,7 +975,7 @@ config DEBUG_LOCK_ALLOC
111182
111183 config PROVE_LOCKING
111184 bool "Lock debugging: prove locking correctness"
111185- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
111186+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
111187 select LOCKDEP
111188 select DEBUG_SPINLOCK
111189 select DEBUG_MUTEXES
111190@@ -1023,7 +1026,7 @@ config LOCKDEP
111191
111192 config LOCK_STAT
111193 bool "Lock usage statistics"
111194- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
111195+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
111196 select LOCKDEP
111197 select DEBUG_SPINLOCK
111198 select DEBUG_MUTEXES
111199@@ -1422,6 +1425,7 @@ config NOTIFIER_ERROR_INJECTION
111200 tristate "Notifier error injection"
111201 depends on DEBUG_KERNEL
111202 select DEBUG_FS
111203+ depends on !GRKERNSEC_KMEM
111204 help
111205 This option provides the ability to inject artificial errors to
111206 specified notifier chain callbacks. It is useful to test the error
111207@@ -1534,6 +1538,7 @@ config FAIL_IO_TIMEOUT
111208 config FAIL_MMC_REQUEST
111209 bool "Fault-injection capability for MMC IO"
111210 select DEBUG_FS
111211+ depends on !GRKERNSEC_KMEM
111212 depends on FAULT_INJECTION && MMC
111213 help
111214 Provide fault-injection capability for MMC IO.
111215@@ -1563,6 +1568,7 @@ config LATENCYTOP
111216 depends on DEBUG_KERNEL
111217 depends on STACKTRACE_SUPPORT
111218 depends on PROC_FS
111219+ depends on !GRKERNSEC_HIDESYM
111220 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
111221 select KALLSYMS
111222 select KALLSYMS_ALL
111223@@ -1579,7 +1585,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
111224 config DEBUG_STRICT_USER_COPY_CHECKS
111225 bool "Strict user copy size checks"
111226 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
111227- depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
111228+ depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
111229 help
111230 Enabling this option turns a certain set of sanity checks for user
111231 copy operations into compile time failures.
111232@@ -1710,7 +1716,7 @@ endmenu # runtime tests
111233
111234 config PROVIDE_OHCI1394_DMA_INIT
111235 bool "Remote debugging over FireWire early on boot"
111236- depends on PCI && X86
111237+ depends on PCI && X86 && !GRKERNSEC
111238 help
111239 If you want to debug problems which hang or crash the kernel early
111240 on boot and the crashing machine has a FireWire port, you can use
111241diff --git a/lib/Makefile b/lib/Makefile
111242index 6897b52..466bda9 100644
111243--- a/lib/Makefile
111244+++ b/lib/Makefile
111245@@ -62,7 +62,7 @@ obj-$(CONFIG_BTREE) += btree.o
111246 obj-$(CONFIG_INTERVAL_TREE) += interval_tree.o
111247 obj-$(CONFIG_ASSOCIATIVE_ARRAY) += assoc_array.o
111248 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
111249-obj-$(CONFIG_DEBUG_LIST) += list_debug.o
111250+obj-y += list_debug.o
111251 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
111252
111253 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
111254diff --git a/lib/average.c b/lib/average.c
111255index 114d1be..ab0350c 100644
111256--- a/lib/average.c
111257+++ b/lib/average.c
111258@@ -55,7 +55,7 @@ struct ewma *ewma_add(struct ewma *avg, unsigned long val)
111259 {
111260 unsigned long internal = ACCESS_ONCE(avg->internal);
111261
111262- ACCESS_ONCE(avg->internal) = internal ?
111263+ ACCESS_ONCE_RW(avg->internal) = internal ?
111264 (((internal << avg->weight) - internal) +
111265 (val << avg->factor)) >> avg->weight :
111266 (val << avg->factor);
111267diff --git a/lib/bitmap.c b/lib/bitmap.c
111268index a578a01..2198e50 100644
111269--- a/lib/bitmap.c
111270+++ b/lib/bitmap.c
111271@@ -361,7 +361,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
111272 {
111273 int c, old_c, totaldigits, ndigits, nchunks, nbits;
111274 u32 chunk;
111275- const char __user __force *ubuf = (const char __user __force *)buf;
111276+ const char __user *ubuf = (const char __force_user *)buf;
111277
111278 bitmap_zero(maskp, nmaskbits);
111279
111280@@ -446,7 +446,7 @@ int bitmap_parse_user(const char __user *ubuf,
111281 {
111282 if (!access_ok(VERIFY_READ, ubuf, ulen))
111283 return -EFAULT;
111284- return __bitmap_parse((const char __force *)ubuf,
111285+ return __bitmap_parse((const char __force_kernel *)ubuf,
111286 ulen, 1, maskp, nmaskbits);
111287
111288 }
111289@@ -506,7 +506,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
111290 {
111291 unsigned a, b;
111292 int c, old_c, totaldigits;
111293- const char __user __force *ubuf = (const char __user __force *)buf;
111294+ const char __user *ubuf = (const char __force_user *)buf;
111295 int at_start, in_range;
111296
111297 totaldigits = c = 0;
111298@@ -602,7 +602,7 @@ int bitmap_parselist_user(const char __user *ubuf,
111299 {
111300 if (!access_ok(VERIFY_READ, ubuf, ulen))
111301 return -EFAULT;
111302- return __bitmap_parselist((const char __force *)ubuf,
111303+ return __bitmap_parselist((const char __force_kernel *)ubuf,
111304 ulen, 1, maskp, nmaskbits);
111305 }
111306 EXPORT_SYMBOL(bitmap_parselist_user);
111307diff --git a/lib/bug.c b/lib/bug.c
111308index cff145f..724a0b8 100644
111309--- a/lib/bug.c
111310+++ b/lib/bug.c
111311@@ -148,6 +148,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
111312 return BUG_TRAP_TYPE_NONE;
111313
111314 bug = find_bug(bugaddr);
111315+ if (!bug)
111316+ return BUG_TRAP_TYPE_NONE;
111317
111318 file = NULL;
111319 line = 0;
111320diff --git a/lib/debugobjects.c b/lib/debugobjects.c
111321index 547f7f9..a6d4ba0 100644
111322--- a/lib/debugobjects.c
111323+++ b/lib/debugobjects.c
111324@@ -289,7 +289,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
111325 if (limit > 4)
111326 return;
111327
111328- is_on_stack = object_is_on_stack(addr);
111329+ is_on_stack = object_starts_on_stack(addr);
111330 if (is_on_stack == onstack)
111331 return;
111332
111333diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c
111334index 0234361..41a411c 100644
111335--- a/lib/decompress_bunzip2.c
111336+++ b/lib/decompress_bunzip2.c
111337@@ -665,7 +665,8 @@ static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, long len,
111338
111339 /* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
111340 uncompressed data. Allocate intermediate buffer for block. */
111341- bd->dbufSize = 100000*(i-BZh0);
111342+ i -= BZh0;
111343+ bd->dbufSize = 100000 * i;
111344
111345 bd->dbuf = large_malloc(bd->dbufSize * sizeof(int));
111346 if (!bd->dbuf)
111347diff --git a/lib/decompress_unlzma.c b/lib/decompress_unlzma.c
111348index decb646..8d6441a 100644
111349--- a/lib/decompress_unlzma.c
111350+++ b/lib/decompress_unlzma.c
111351@@ -39,10 +39,10 @@
111352
111353 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
111354
111355-static long long INIT read_int(unsigned char *ptr, int size)
111356+static unsigned long long INIT read_int(unsigned char *ptr, int size)
111357 {
111358 int i;
111359- long long ret = 0;
111360+ unsigned long long ret = 0;
111361
111362 for (i = 0; i < size; i++)
111363 ret = (ret << 8) | ptr[size-i-1];
111364diff --git a/lib/div64.c b/lib/div64.c
111365index 19ea7ed..20cac21 100644
111366--- a/lib/div64.c
111367+++ b/lib/div64.c
111368@@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
111369 EXPORT_SYMBOL(__div64_32);
111370
111371 #ifndef div_s64_rem
111372-s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
111373+s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
111374 {
111375 u64 quotient;
111376
111377@@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
111378 * 'http://www.hackersdelight.org/hdcodetxt/divDouble.c.txt'
111379 */
111380 #ifndef div64_u64
111381-u64 div64_u64(u64 dividend, u64 divisor)
111382+u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
111383 {
111384 u32 high = divisor >> 32;
111385 u64 quot;
111386diff --git a/lib/dma-debug.c b/lib/dma-debug.c
111387index dace71f..13da37b 100644
111388--- a/lib/dma-debug.c
111389+++ b/lib/dma-debug.c
111390@@ -982,7 +982,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
111391
111392 void dma_debug_add_bus(struct bus_type *bus)
111393 {
111394- struct notifier_block *nb;
111395+ notifier_block_no_const *nb;
111396
111397 if (dma_debug_disabled())
111398 return;
111399@@ -1164,7 +1164,7 @@ static void check_unmap(struct dma_debug_entry *ref)
111400
111401 static void check_for_stack(struct device *dev, void *addr)
111402 {
111403- if (object_is_on_stack(addr))
111404+ if (object_starts_on_stack(addr))
111405 err_printk(dev, NULL, "DMA-API: device driver maps memory from "
111406 "stack [addr=%p]\n", addr);
111407 }
111408diff --git a/lib/inflate.c b/lib/inflate.c
111409index 013a761..c28f3fc 100644
111410--- a/lib/inflate.c
111411+++ b/lib/inflate.c
111412@@ -269,7 +269,7 @@ static void free(void *where)
111413 malloc_ptr = free_mem_ptr;
111414 }
111415 #else
111416-#define malloc(a) kmalloc(a, GFP_KERNEL)
111417+#define malloc(a) kmalloc((a), GFP_KERNEL)
111418 #define free(a) kfree(a)
111419 #endif
111420
111421diff --git a/lib/ioremap.c b/lib/ioremap.c
111422index 86c8911..f5bfc34 100644
111423--- a/lib/ioremap.c
111424+++ b/lib/ioremap.c
111425@@ -75,7 +75,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
111426 unsigned long next;
111427
111428 phys_addr -= addr;
111429- pmd = pmd_alloc(&init_mm, pud, addr);
111430+ pmd = pmd_alloc_kernel(&init_mm, pud, addr);
111431 if (!pmd)
111432 return -ENOMEM;
111433 do {
111434@@ -101,7 +101,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
111435 unsigned long next;
111436
111437 phys_addr -= addr;
111438- pud = pud_alloc(&init_mm, pgd, addr);
111439+ pud = pud_alloc_kernel(&init_mm, pgd, addr);
111440 if (!pud)
111441 return -ENOMEM;
111442 do {
111443diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
111444index bd2bea9..6b3c95e 100644
111445--- a/lib/is_single_threaded.c
111446+++ b/lib/is_single_threaded.c
111447@@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
111448 struct task_struct *p, *t;
111449 bool ret;
111450
111451+ if (!mm)
111452+ return true;
111453+
111454 if (atomic_read(&task->signal->live) != 1)
111455 return false;
111456
111457diff --git a/lib/kobject.c b/lib/kobject.c
111458index 3e3a5c3..4a12109 100644
111459--- a/lib/kobject.c
111460+++ b/lib/kobject.c
111461@@ -935,9 +935,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
111462
111463
111464 static DEFINE_SPINLOCK(kobj_ns_type_lock);
111465-static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
111466+static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
111467
111468-int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
111469+int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
111470 {
111471 enum kobj_ns_type type = ops->type;
111472 int error;
111473diff --git a/lib/list_debug.c b/lib/list_debug.c
111474index c24c2f7..f0296f4 100644
111475--- a/lib/list_debug.c
111476+++ b/lib/list_debug.c
111477@@ -11,7 +11,9 @@
111478 #include <linux/bug.h>
111479 #include <linux/kernel.h>
111480 #include <linux/rculist.h>
111481+#include <linux/mm.h>
111482
111483+#ifdef CONFIG_DEBUG_LIST
111484 /*
111485 * Insert a new entry between two known consecutive entries.
111486 *
111487@@ -19,21 +21,40 @@
111488 * the prev/next entries already!
111489 */
111490
111491+static bool __list_add_debug(struct list_head *new,
111492+ struct list_head *prev,
111493+ struct list_head *next)
111494+{
111495+ if (unlikely(next->prev != prev)) {
111496+ printk(KERN_ERR "list_add corruption. next->prev should be "
111497+ "prev (%p), but was %p. (next=%p).\n",
111498+ prev, next->prev, next);
111499+ BUG();
111500+ return false;
111501+ }
111502+ if (unlikely(prev->next != next)) {
111503+ printk(KERN_ERR "list_add corruption. prev->next should be "
111504+ "next (%p), but was %p. (prev=%p).\n",
111505+ next, prev->next, prev);
111506+ BUG();
111507+ return false;
111508+ }
111509+ if (unlikely(new == prev || new == next)) {
111510+ printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
111511+ new, prev, next);
111512+ BUG();
111513+ return false;
111514+ }
111515+ return true;
111516+}
111517+
111518 void __list_add(struct list_head *new,
111519- struct list_head *prev,
111520- struct list_head *next)
111521+ struct list_head *prev,
111522+ struct list_head *next)
111523 {
111524- WARN(next->prev != prev,
111525- "list_add corruption. next->prev should be "
111526- "prev (%p), but was %p. (next=%p).\n",
111527- prev, next->prev, next);
111528- WARN(prev->next != next,
111529- "list_add corruption. prev->next should be "
111530- "next (%p), but was %p. (prev=%p).\n",
111531- next, prev->next, prev);
111532- WARN(new == prev || new == next,
111533- "list_add double add: new=%p, prev=%p, next=%p.\n",
111534- new, prev, next);
111535+ if (!__list_add_debug(new, prev, next))
111536+ return;
111537+
111538 next->prev = new;
111539 new->next = next;
111540 new->prev = prev;
111541@@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
111542 }
111543 EXPORT_SYMBOL(__list_add);
111544
111545-void __list_del_entry(struct list_head *entry)
111546+static bool __list_del_entry_debug(struct list_head *entry)
111547 {
111548 struct list_head *prev, *next;
111549
111550 prev = entry->prev;
111551 next = entry->next;
111552
111553- if (WARN(next == LIST_POISON1,
111554- "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
111555- entry, LIST_POISON1) ||
111556- WARN(prev == LIST_POISON2,
111557- "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
111558- entry, LIST_POISON2) ||
111559- WARN(prev->next != entry,
111560- "list_del corruption. prev->next should be %p, "
111561- "but was %p\n", entry, prev->next) ||
111562- WARN(next->prev != entry,
111563- "list_del corruption. next->prev should be %p, "
111564- "but was %p\n", entry, next->prev))
111565+ if (unlikely(next == LIST_POISON1)) {
111566+ printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
111567+ entry, LIST_POISON1);
111568+ BUG();
111569+ return false;
111570+ }
111571+ if (unlikely(prev == LIST_POISON2)) {
111572+ printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
111573+ entry, LIST_POISON2);
111574+ BUG();
111575+ return false;
111576+ }
111577+ if (unlikely(entry->prev->next != entry)) {
111578+ printk(KERN_ERR "list_del corruption. prev->next should be %p, "
111579+ "but was %p\n", entry, prev->next);
111580+ BUG();
111581+ return false;
111582+ }
111583+ if (unlikely(entry->next->prev != entry)) {
111584+ printk(KERN_ERR "list_del corruption. next->prev should be %p, "
111585+ "but was %p\n", entry, next->prev);
111586+ BUG();
111587+ return false;
111588+ }
111589+ return true;
111590+}
111591+
111592+void __list_del_entry(struct list_head *entry)
111593+{
111594+ if (!__list_del_entry_debug(entry))
111595 return;
111596
111597- __list_del(prev, next);
111598+ __list_del(entry->prev, entry->next);
111599 }
111600 EXPORT_SYMBOL(__list_del_entry);
111601
111602@@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
111603 void __list_add_rcu(struct list_head *new,
111604 struct list_head *prev, struct list_head *next)
111605 {
111606- WARN(next->prev != prev,
111607- "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
111608- prev, next->prev, next);
111609- WARN(prev->next != next,
111610- "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
111611- next, prev->next, prev);
111612+ if (!__list_add_debug(new, prev, next))
111613+ return;
111614+
111615 new->next = next;
111616 new->prev = prev;
111617 rcu_assign_pointer(list_next_rcu(prev), new);
111618 next->prev = new;
111619 }
111620 EXPORT_SYMBOL(__list_add_rcu);
111621+#endif
111622+
111623+void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
111624+{
111625+#ifdef CONFIG_DEBUG_LIST
111626+ if (!__list_add_debug(new, prev, next))
111627+ return;
111628+#endif
111629+
111630+ pax_open_kernel();
111631+ next->prev = new;
111632+ new->next = next;
111633+ new->prev = prev;
111634+ prev->next = new;
111635+ pax_close_kernel();
111636+}
111637+EXPORT_SYMBOL(__pax_list_add);
111638+
111639+void pax_list_del(struct list_head *entry)
111640+{
111641+#ifdef CONFIG_DEBUG_LIST
111642+ if (!__list_del_entry_debug(entry))
111643+ return;
111644+#endif
111645+
111646+ pax_open_kernel();
111647+ __list_del(entry->prev, entry->next);
111648+ entry->next = LIST_POISON1;
111649+ entry->prev = LIST_POISON2;
111650+ pax_close_kernel();
111651+}
111652+EXPORT_SYMBOL(pax_list_del);
111653+
111654+void pax_list_del_init(struct list_head *entry)
111655+{
111656+ pax_open_kernel();
111657+ __list_del(entry->prev, entry->next);
111658+ INIT_LIST_HEAD(entry);
111659+ pax_close_kernel();
111660+}
111661+EXPORT_SYMBOL(pax_list_del_init);
111662+
111663+void __pax_list_add_rcu(struct list_head *new,
111664+ struct list_head *prev, struct list_head *next)
111665+{
111666+#ifdef CONFIG_DEBUG_LIST
111667+ if (!__list_add_debug(new, prev, next))
111668+ return;
111669+#endif
111670+
111671+ pax_open_kernel();
111672+ new->next = next;
111673+ new->prev = prev;
111674+ rcu_assign_pointer(list_next_rcu(prev), new);
111675+ next->prev = new;
111676+ pax_close_kernel();
111677+}
111678+EXPORT_SYMBOL(__pax_list_add_rcu);
111679+
111680+void pax_list_del_rcu(struct list_head *entry)
111681+{
111682+#ifdef CONFIG_DEBUG_LIST
111683+ if (!__list_del_entry_debug(entry))
111684+ return;
111685+#endif
111686+
111687+ pax_open_kernel();
111688+ __list_del(entry->prev, entry->next);
111689+ entry->next = LIST_POISON1;
111690+ entry->prev = LIST_POISON2;
111691+ pax_close_kernel();
111692+}
111693+EXPORT_SYMBOL(pax_list_del_rcu);
111694diff --git a/lib/lockref.c b/lib/lockref.c
111695index 494994b..65caf94 100644
111696--- a/lib/lockref.c
111697+++ b/lib/lockref.c
111698@@ -48,13 +48,13 @@
111699 void lockref_get(struct lockref *lockref)
111700 {
111701 CMPXCHG_LOOP(
111702- new.count++;
111703+ __lockref_inc(&new);
111704 ,
111705 return;
111706 );
111707
111708 spin_lock(&lockref->lock);
111709- lockref->count++;
111710+ __lockref_inc(lockref);
111711 spin_unlock(&lockref->lock);
111712 }
111713 EXPORT_SYMBOL(lockref_get);
111714@@ -69,8 +69,8 @@ int lockref_get_not_zero(struct lockref *lockref)
111715 int retval;
111716
111717 CMPXCHG_LOOP(
111718- new.count++;
111719- if (old.count <= 0)
111720+ __lockref_inc(&new);
111721+ if (__lockref_read(&old) <= 0)
111722 return 0;
111723 ,
111724 return 1;
111725@@ -78,8 +78,8 @@ int lockref_get_not_zero(struct lockref *lockref)
111726
111727 spin_lock(&lockref->lock);
111728 retval = 0;
111729- if (lockref->count > 0) {
111730- lockref->count++;
111731+ if (__lockref_read(lockref) > 0) {
111732+ __lockref_inc(lockref);
111733 retval = 1;
111734 }
111735 spin_unlock(&lockref->lock);
111736@@ -96,17 +96,17 @@ EXPORT_SYMBOL(lockref_get_not_zero);
111737 int lockref_get_or_lock(struct lockref *lockref)
111738 {
111739 CMPXCHG_LOOP(
111740- new.count++;
111741- if (old.count <= 0)
111742+ __lockref_inc(&new);
111743+ if (__lockref_read(&old) <= 0)
111744 break;
111745 ,
111746 return 1;
111747 );
111748
111749 spin_lock(&lockref->lock);
111750- if (lockref->count <= 0)
111751+ if (__lockref_read(lockref) <= 0)
111752 return 0;
111753- lockref->count++;
111754+ __lockref_inc(lockref);
111755 spin_unlock(&lockref->lock);
111756 return 1;
111757 }
111758@@ -122,11 +122,11 @@ EXPORT_SYMBOL(lockref_get_or_lock);
111759 int lockref_put_return(struct lockref *lockref)
111760 {
111761 CMPXCHG_LOOP(
111762- new.count--;
111763- if (old.count <= 0)
111764+ __lockref_dec(&new);
111765+ if (__lockref_read(&old) <= 0)
111766 return -1;
111767 ,
111768- return new.count;
111769+ return __lockref_read(&new);
111770 );
111771 return -1;
111772 }
111773@@ -140,17 +140,17 @@ EXPORT_SYMBOL(lockref_put_return);
111774 int lockref_put_or_lock(struct lockref *lockref)
111775 {
111776 CMPXCHG_LOOP(
111777- new.count--;
111778- if (old.count <= 1)
111779+ __lockref_dec(&new);
111780+ if (__lockref_read(&old) <= 1)
111781 break;
111782 ,
111783 return 1;
111784 );
111785
111786 spin_lock(&lockref->lock);
111787- if (lockref->count <= 1)
111788+ if (__lockref_read(lockref) <= 1)
111789 return 0;
111790- lockref->count--;
111791+ __lockref_dec(lockref);
111792 spin_unlock(&lockref->lock);
111793 return 1;
111794 }
111795@@ -163,7 +163,7 @@ EXPORT_SYMBOL(lockref_put_or_lock);
111796 void lockref_mark_dead(struct lockref *lockref)
111797 {
111798 assert_spin_locked(&lockref->lock);
111799- lockref->count = -128;
111800+ __lockref_set(lockref, -128);
111801 }
111802 EXPORT_SYMBOL(lockref_mark_dead);
111803
111804@@ -177,8 +177,8 @@ int lockref_get_not_dead(struct lockref *lockref)
111805 int retval;
111806
111807 CMPXCHG_LOOP(
111808- new.count++;
111809- if (old.count < 0)
111810+ __lockref_inc(&new);
111811+ if (__lockref_read(&old) < 0)
111812 return 0;
111813 ,
111814 return 1;
111815@@ -186,8 +186,8 @@ int lockref_get_not_dead(struct lockref *lockref)
111816
111817 spin_lock(&lockref->lock);
111818 retval = 0;
111819- if (lockref->count >= 0) {
111820- lockref->count++;
111821+ if (__lockref_read(lockref) >= 0) {
111822+ __lockref_inc(lockref);
111823 retval = 1;
111824 }
111825 spin_unlock(&lockref->lock);
111826diff --git a/lib/nlattr.c b/lib/nlattr.c
111827index f5907d2..36072be 100644
111828--- a/lib/nlattr.c
111829+++ b/lib/nlattr.c
111830@@ -278,6 +278,8 @@ int nla_memcpy(void *dest, const struct nlattr *src, int count)
111831 {
111832 int minlen = min_t(int, count, nla_len(src));
111833
111834+ BUG_ON(minlen < 0);
111835+
111836 memcpy(dest, nla_data(src), minlen);
111837 if (count > minlen)
111838 memset(dest + minlen, 0, count - minlen);
111839diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
111840index 6111bcb..02e816b 100644
111841--- a/lib/percpu-refcount.c
111842+++ b/lib/percpu-refcount.c
111843@@ -31,7 +31,7 @@
111844 * atomic_long_t can't hit 0 before we've added up all the percpu refs.
111845 */
111846
111847-#define PERCPU_COUNT_BIAS (1LU << (BITS_PER_LONG - 1))
111848+#define PERCPU_COUNT_BIAS (1LU << (BITS_PER_LONG - 2))
111849
111850 static DECLARE_WAIT_QUEUE_HEAD(percpu_ref_switch_waitq);
111851
111852diff --git a/lib/radix-tree.c b/lib/radix-tree.c
111853index f9ebe1c..e985666 100644
111854--- a/lib/radix-tree.c
111855+++ b/lib/radix-tree.c
111856@@ -68,7 +68,7 @@ struct radix_tree_preload {
111857 /* nodes->private_data points to next preallocated node */
111858 struct radix_tree_node *nodes;
111859 };
111860-static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
111861+static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
111862
111863 static inline void *ptr_to_indirect(void *ptr)
111864 {
111865diff --git a/lib/random32.c b/lib/random32.c
111866index 0bee183..526f12f 100644
111867--- a/lib/random32.c
111868+++ b/lib/random32.c
111869@@ -47,7 +47,7 @@ static inline void prandom_state_selftest(void)
111870 }
111871 #endif
111872
111873-static DEFINE_PER_CPU(struct rnd_state, net_rand_state);
111874+static DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy;
111875
111876 /**
111877 * prandom_u32_state - seeded pseudo-random number generator.
111878diff --git a/lib/rbtree.c b/lib/rbtree.c
111879index 1356454..70ce6c6 100644
111880--- a/lib/rbtree.c
111881+++ b/lib/rbtree.c
111882@@ -412,7 +412,9 @@ static inline void dummy_copy(struct rb_node *old, struct rb_node *new) {}
111883 static inline void dummy_rotate(struct rb_node *old, struct rb_node *new) {}
111884
111885 static const struct rb_augment_callbacks dummy_callbacks = {
111886- dummy_propagate, dummy_copy, dummy_rotate
111887+ .propagate = dummy_propagate,
111888+ .copy = dummy_copy,
111889+ .rotate = dummy_rotate
111890 };
111891
111892 void rb_insert_color(struct rb_node *node, struct rb_root *root)
111893diff --git a/lib/show_mem.c b/lib/show_mem.c
111894index adc98e18..0ce83c2 100644
111895--- a/lib/show_mem.c
111896+++ b/lib/show_mem.c
111897@@ -49,6 +49,6 @@ void show_mem(unsigned int filter)
111898 quicklist_total_size());
111899 #endif
111900 #ifdef CONFIG_MEMORY_FAILURE
111901- printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
111902+ printk("%lu pages hwpoisoned\n", atomic_long_read_unchecked(&num_poisoned_pages));
111903 #endif
111904 }
111905diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
111906index e0af6ff..fcc9f15 100644
111907--- a/lib/strncpy_from_user.c
111908+++ b/lib/strncpy_from_user.c
111909@@ -22,7 +22,7 @@
111910 */
111911 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
111912 {
111913- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
111914+ static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
111915 long res = 0;
111916
111917 /*
111918diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
111919index 3a5f2b3..102f1ff 100644
111920--- a/lib/strnlen_user.c
111921+++ b/lib/strnlen_user.c
111922@@ -26,7 +26,7 @@
111923 */
111924 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
111925 {
111926- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
111927+ static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
111928 long align, res = 0;
111929 unsigned long c;
111930
111931diff --git a/lib/swiotlb.c b/lib/swiotlb.c
111932index 76f29ec..1a5316f 100644
111933--- a/lib/swiotlb.c
111934+++ b/lib/swiotlb.c
111935@@ -690,7 +690,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
111936
111937 void
111938 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
111939- dma_addr_t dev_addr)
111940+ dma_addr_t dev_addr, struct dma_attrs *attrs)
111941 {
111942 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
111943
111944diff --git a/lib/usercopy.c b/lib/usercopy.c
111945index 4f5b1dd..7cab418 100644
111946--- a/lib/usercopy.c
111947+++ b/lib/usercopy.c
111948@@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
111949 WARN(1, "Buffer overflow detected!\n");
111950 }
111951 EXPORT_SYMBOL(copy_from_user_overflow);
111952+
111953+void copy_to_user_overflow(void)
111954+{
111955+ WARN(1, "Buffer overflow detected!\n");
111956+}
111957+EXPORT_SYMBOL(copy_to_user_overflow);
111958diff --git a/lib/vsprintf.c b/lib/vsprintf.c
111959index da39c60..ac91239 100644
111960--- a/lib/vsprintf.c
111961+++ b/lib/vsprintf.c
111962@@ -16,6 +16,9 @@
111963 * - scnprintf and vscnprintf
111964 */
111965
111966+#ifdef CONFIG_GRKERNSEC_HIDESYM
111967+#define __INCLUDED_BY_HIDESYM 1
111968+#endif
111969 #include <stdarg.h>
111970 #include <linux/clk-provider.h>
111971 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
111972@@ -628,7 +631,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
111973 #ifdef CONFIG_KALLSYMS
111974 if (*fmt == 'B')
111975 sprint_backtrace(sym, value);
111976- else if (*fmt != 'f' && *fmt != 's')
111977+ else if (*fmt != 'f' && *fmt != 's' && *fmt != 'X')
111978 sprint_symbol(sym, value);
111979 else
111980 sprint_symbol_no_offset(sym, value);
111981@@ -1360,7 +1363,11 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
111982 }
111983 }
111984
111985-int kptr_restrict __read_mostly;
111986+#ifdef CONFIG_GRKERNSEC_HIDESYM
111987+int kptr_restrict __read_only = 2;
111988+#else
111989+int kptr_restrict __read_only;
111990+#endif
111991
111992 /*
111993 * Show a '%p' thing. A kernel extension is that the '%p' is followed
111994@@ -1371,8 +1378,10 @@ int kptr_restrict __read_mostly;
111995 *
111996 * - 'F' For symbolic function descriptor pointers with offset
111997 * - 'f' For simple symbolic function names without offset
111998+ * - 'X' For simple symbolic function names without offset approved for use with GRKERNSEC_HIDESYM
111999 * - 'S' For symbolic direct pointers with offset
112000 * - 's' For symbolic direct pointers without offset
112001+ * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
112002 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
112003 * - 'B' For backtraced symbolic direct pointers with offset
112004 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
112005@@ -1460,12 +1469,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
112006
112007 if (!ptr && *fmt != 'K') {
112008 /*
112009- * Print (null) with the same width as a pointer so it makes
112010+ * Print (nil) with the same width as a pointer so it makes
112011 * tabular output look nice.
112012 */
112013 if (spec.field_width == -1)
112014 spec.field_width = default_width;
112015- return string(buf, end, "(null)", spec);
112016+ return string(buf, end, "(nil)", spec);
112017 }
112018
112019 switch (*fmt) {
112020@@ -1475,6 +1484,14 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
112021 /* Fallthrough */
112022 case 'S':
112023 case 's':
112024+#ifdef CONFIG_GRKERNSEC_HIDESYM
112025+ break;
112026+#else
112027+ return symbol_string(buf, end, ptr, spec, fmt);
112028+#endif
112029+ case 'X':
112030+ ptr = dereference_function_descriptor(ptr);
112031+ case 'A':
112032 case 'B':
112033 return symbol_string(buf, end, ptr, spec, fmt);
112034 case 'R':
112035@@ -1539,6 +1556,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
112036 va_end(va);
112037 return buf;
112038 }
112039+ case 'P':
112040+ break;
112041 case 'K':
112042 /*
112043 * %pK cannot be used in IRQ context because its test
112044@@ -1598,6 +1617,22 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
112045 ((const struct file *)ptr)->f_path.dentry,
112046 spec, fmt);
112047 }
112048+
112049+#ifdef CONFIG_GRKERNSEC_HIDESYM
112050+ /* 'P' = approved pointers to copy to userland,
112051+ as in the /proc/kallsyms case, as we make it display nothing
112052+ for non-root users, and the real contents for root users
112053+ 'X' = approved simple symbols
112054+ Also ignore 'K' pointers, since we force their NULLing for non-root users
112055+ above
112056+ */
112057+ if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'X' && *fmt != 'K' && is_usercopy_object(buf)) {
112058+ printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
112059+ dump_stack();
112060+ ptr = NULL;
112061+ }
112062+#endif
112063+
112064 spec.flags |= SMALL;
112065 if (spec.field_width == -1) {
112066 spec.field_width = default_width;
112067@@ -2296,11 +2331,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
112068 typeof(type) value; \
112069 if (sizeof(type) == 8) { \
112070 args = PTR_ALIGN(args, sizeof(u32)); \
112071- *(u32 *)&value = *(u32 *)args; \
112072- *((u32 *)&value + 1) = *(u32 *)(args + 4); \
112073+ *(u32 *)&value = *(const u32 *)args; \
112074+ *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
112075 } else { \
112076 args = PTR_ALIGN(args, sizeof(type)); \
112077- value = *(typeof(type) *)args; \
112078+ value = *(const typeof(type) *)args; \
112079 } \
112080 args += sizeof(type); \
112081 value; \
112082@@ -2363,7 +2398,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
112083 case FORMAT_TYPE_STR: {
112084 const char *str_arg = args;
112085 args += strlen(str_arg) + 1;
112086- str = string(str, end, (char *)str_arg, spec);
112087+ str = string(str, end, str_arg, spec);
112088 break;
112089 }
112090
112091diff --git a/localversion-grsec b/localversion-grsec
112092new file mode 100644
112093index 0000000..7cd6065
112094--- /dev/null
112095+++ b/localversion-grsec
112096@@ -0,0 +1 @@
112097+-grsec
112098diff --git a/mm/Kconfig b/mm/Kconfig
112099index e79de2b..fba3116 100644
112100--- a/mm/Kconfig
112101+++ b/mm/Kconfig
112102@@ -342,10 +342,11 @@ config KSM
112103 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
112104
112105 config DEFAULT_MMAP_MIN_ADDR
112106- int "Low address space to protect from user allocation"
112107+ int "Low address space to protect from user allocation"
112108 depends on MMU
112109- default 4096
112110- help
112111+ default 32768 if ALPHA || ARM || PARISC || SPARC32
112112+ default 65536
112113+ help
112114 This is the portion of low virtual memory which should be protected
112115 from userspace allocation. Keeping a user from writing to low pages
112116 can help reduce the impact of kernel NULL pointer bugs.
112117@@ -377,8 +378,9 @@ config MEMORY_FAILURE
112118
112119 config HWPOISON_INJECT
112120 tristate "HWPoison pages injector"
112121- depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
112122+ depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
112123 select PROC_PAGE_MONITOR
112124+ depends on !GRKERNSEC
112125
112126 config NOMMU_INITIAL_TRIM_EXCESS
112127 int "Turn on mmap() excess space trimming before booting"
112128@@ -539,6 +541,7 @@ config MEM_SOFT_DIRTY
112129 bool "Track memory changes"
112130 depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY && PROC_FS
112131 select PROC_PAGE_MONITOR
112132+ depends on !GRKERNSEC
112133 help
112134 This option enables memory changes tracking by introducing a
112135 soft-dirty bit on pte-s. This bit it set when someone writes
112136@@ -613,6 +616,7 @@ config ZSMALLOC_STAT
112137 bool "Export zsmalloc statistics"
112138 depends on ZSMALLOC
112139 select DEBUG_FS
112140+ depends on !GRKERNSEC_KMEM
112141 help
112142 This option enables code in the zsmalloc to collect various
112143 statistics about whats happening in zsmalloc and exports that
112144diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug
112145index 957d3da..1d34e20 100644
112146--- a/mm/Kconfig.debug
112147+++ b/mm/Kconfig.debug
112148@@ -10,6 +10,7 @@ config PAGE_EXTENSION
112149 config DEBUG_PAGEALLOC
112150 bool "Debug page memory allocations"
112151 depends on DEBUG_KERNEL
112152+ depends on !PAX_MEMORY_SANITIZE
112153 depends on !HIBERNATION || ARCH_SUPPORTS_DEBUG_PAGEALLOC && !PPC && !SPARC
112154 depends on !KMEMCHECK
112155 select PAGE_EXTENSION
112156diff --git a/mm/backing-dev.c b/mm/backing-dev.c
112157index dac5bf5..d8c02ce 100644
112158--- a/mm/backing-dev.c
112159+++ b/mm/backing-dev.c
112160@@ -12,7 +12,7 @@
112161 #include <linux/device.h>
112162 #include <trace/events/writeback.h>
112163
112164-static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
112165+static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
112166
112167 struct backing_dev_info noop_backing_dev_info = {
112168 .name = "noop",
112169@@ -855,7 +855,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name)
112170 return err;
112171
112172 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
112173- atomic_long_inc_return(&bdi_seq));
112174+ atomic_long_inc_return_unchecked(&bdi_seq));
112175 if (err) {
112176 bdi_destroy(bdi);
112177 return err;
112178diff --git a/mm/dmapool.c b/mm/dmapool.c
112179index fd5fe43..39ea317 100644
112180--- a/mm/dmapool.c
112181+++ b/mm/dmapool.c
112182@@ -386,7 +386,7 @@ static struct dma_page *pool_find_page(struct dma_pool *pool, dma_addr_t dma)
112183 list_for_each_entry(page, &pool->page_list, page_list) {
112184 if (dma < page->dma)
112185 continue;
112186- if (dma < (page->dma + pool->allocation))
112187+ if ((dma - page->dma) < pool->allocation)
112188 return page;
112189 }
112190 return NULL;
112191diff --git a/mm/filemap.c b/mm/filemap.c
112192index 1283fc8..a0347d5 100644
112193--- a/mm/filemap.c
112194+++ b/mm/filemap.c
112195@@ -2122,7 +2122,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
112196 struct address_space *mapping = file->f_mapping;
112197
112198 if (!mapping->a_ops->readpage)
112199- return -ENOEXEC;
112200+ return -ENODEV;
112201 file_accessed(file);
112202 vma->vm_ops = &generic_file_vm_ops;
112203 return 0;
112204@@ -2303,6 +2303,7 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)
112205 pos = iocb->ki_pos;
112206
112207 if (limit != RLIM_INFINITY) {
112208+ gr_learn_resource(current, RLIMIT_FSIZE, iocb->ki_pos, 0);
112209 if (iocb->ki_pos >= limit) {
112210 send_sig(SIGXFSZ, current, 0);
112211 return -EFBIG;
112212diff --git a/mm/gup.c b/mm/gup.c
112213index 6297f6b..7652403 100644
112214--- a/mm/gup.c
112215+++ b/mm/gup.c
112216@@ -265,11 +265,6 @@ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma,
112217 unsigned int fault_flags = 0;
112218 int ret;
112219
112220- /* For mm_populate(), just skip the stack guard page. */
112221- if ((*flags & FOLL_POPULATE) &&
112222- (stack_guard_page_start(vma, address) ||
112223- stack_guard_page_end(vma, address + PAGE_SIZE)))
112224- return -ENOENT;
112225 if (*flags & FOLL_WRITE)
112226 fault_flags |= FAULT_FLAG_WRITE;
112227 if (nonblocking)
112228@@ -435,14 +430,14 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
112229 if (!(gup_flags & FOLL_FORCE))
112230 gup_flags |= FOLL_NUMA;
112231
112232- do {
112233+ while (nr_pages) {
112234 struct page *page;
112235 unsigned int foll_flags = gup_flags;
112236 unsigned int page_increm;
112237
112238 /* first iteration or cross vma bound */
112239 if (!vma || start >= vma->vm_end) {
112240- vma = find_extend_vma(mm, start);
112241+ vma = find_vma(mm, start);
112242 if (!vma && in_gate_area(mm, start)) {
112243 int ret;
112244 ret = get_gate_page(mm, start & PAGE_MASK,
112245@@ -454,7 +449,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
112246 goto next_page;
112247 }
112248
112249- if (!vma || check_vma_flags(vma, gup_flags))
112250+ if (!vma || start < vma->vm_start || check_vma_flags(vma, gup_flags))
112251 return i ? : -EFAULT;
112252 if (is_vm_hugetlb_page(vma)) {
112253 i = follow_hugetlb_page(mm, vma, pages, vmas,
112254@@ -509,7 +504,7 @@ next_page:
112255 i += page_increm;
112256 start += page_increm * PAGE_SIZE;
112257 nr_pages -= page_increm;
112258- } while (nr_pages);
112259+ }
112260 return i;
112261 }
112262 EXPORT_SYMBOL(__get_user_pages);
112263diff --git a/mm/highmem.c b/mm/highmem.c
112264index 123bcd3..c2c85db 100644
112265--- a/mm/highmem.c
112266+++ b/mm/highmem.c
112267@@ -195,8 +195,9 @@ static void flush_all_zero_pkmaps(void)
112268 * So no dangers, even with speculative execution.
112269 */
112270 page = pte_page(pkmap_page_table[i]);
112271+ pax_open_kernel();
112272 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
112273-
112274+ pax_close_kernel();
112275 set_page_address(page, NULL);
112276 need_flush = 1;
112277 }
112278@@ -259,8 +260,11 @@ start:
112279 }
112280 }
112281 vaddr = PKMAP_ADDR(last_pkmap_nr);
112282+
112283+ pax_open_kernel();
112284 set_pte_at(&init_mm, vaddr,
112285 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
112286+ pax_close_kernel();
112287
112288 pkmap_count[last_pkmap_nr] = 1;
112289 set_page_address(page, (void *)vaddr);
112290diff --git a/mm/hugetlb.c b/mm/hugetlb.c
112291index 62c1ec5..ec431dc 100644
112292--- a/mm/hugetlb.c
112293+++ b/mm/hugetlb.c
112294@@ -2442,6 +2442,7 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
112295 struct ctl_table *table, int write,
112296 void __user *buffer, size_t *length, loff_t *ppos)
112297 {
112298+ ctl_table_no_const t;
112299 struct hstate *h = &default_hstate;
112300 unsigned long tmp = h->max_huge_pages;
112301 int ret;
112302@@ -2449,9 +2450,10 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
112303 if (!hugepages_supported())
112304 return -ENOTSUPP;
112305
112306- table->data = &tmp;
112307- table->maxlen = sizeof(unsigned long);
112308- ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
112309+ t = *table;
112310+ t.data = &tmp;
112311+ t.maxlen = sizeof(unsigned long);
112312+ ret = proc_doulongvec_minmax(&t, write, buffer, length, ppos);
112313 if (ret)
112314 goto out;
112315
112316@@ -2486,6 +2488,7 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
112317 struct hstate *h = &default_hstate;
112318 unsigned long tmp;
112319 int ret;
112320+ ctl_table_no_const hugetlb_table;
112321
112322 if (!hugepages_supported())
112323 return -ENOTSUPP;
112324@@ -2495,9 +2498,10 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
112325 if (write && hstate_is_gigantic(h))
112326 return -EINVAL;
112327
112328- table->data = &tmp;
112329- table->maxlen = sizeof(unsigned long);
112330- ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
112331+ hugetlb_table = *table;
112332+ hugetlb_table.data = &tmp;
112333+ hugetlb_table.maxlen = sizeof(unsigned long);
112334+ ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
112335 if (ret)
112336 goto out;
112337
112338@@ -2995,6 +2999,27 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
112339 i_mmap_unlock_write(mapping);
112340 }
112341
112342+#ifdef CONFIG_PAX_SEGMEXEC
112343+static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
112344+{
112345+ struct mm_struct *mm = vma->vm_mm;
112346+ struct vm_area_struct *vma_m;
112347+ unsigned long address_m;
112348+ pte_t *ptep_m;
112349+
112350+ vma_m = pax_find_mirror_vma(vma);
112351+ if (!vma_m)
112352+ return;
112353+
112354+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
112355+ address_m = address + SEGMEXEC_TASK_SIZE;
112356+ ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
112357+ get_page(page_m);
112358+ hugepage_add_anon_rmap(page_m, vma_m, address_m);
112359+ set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
112360+}
112361+#endif
112362+
112363 /*
112364 * Hugetlb_cow() should be called with page lock of the original hugepage held.
112365 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
112366@@ -3108,6 +3133,11 @@ retry_avoidcopy:
112367 make_huge_pte(vma, new_page, 1));
112368 page_remove_rmap(old_page);
112369 hugepage_add_new_anon_rmap(new_page, vma, address);
112370+
112371+#ifdef CONFIG_PAX_SEGMEXEC
112372+ pax_mirror_huge_pte(vma, address, new_page);
112373+#endif
112374+
112375 /* Make the old page be freed below */
112376 new_page = old_page;
112377 }
112378@@ -3269,6 +3299,10 @@ retry:
112379 && (vma->vm_flags & VM_SHARED)));
112380 set_huge_pte_at(mm, address, ptep, new_pte);
112381
112382+#ifdef CONFIG_PAX_SEGMEXEC
112383+ pax_mirror_huge_pte(vma, address, page);
112384+#endif
112385+
112386 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
112387 /* Optimization, do the COW without a second fault */
112388 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page, ptl);
112389@@ -3336,6 +3370,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
112390 struct address_space *mapping;
112391 int need_wait_lock = 0;
112392
112393+#ifdef CONFIG_PAX_SEGMEXEC
112394+ struct vm_area_struct *vma_m;
112395+#endif
112396+
112397 address &= huge_page_mask(h);
112398
112399 ptep = huge_pte_offset(mm, address);
112400@@ -3349,6 +3387,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
112401 VM_FAULT_SET_HINDEX(hstate_index(h));
112402 }
112403
112404+#ifdef CONFIG_PAX_SEGMEXEC
112405+ vma_m = pax_find_mirror_vma(vma);
112406+ if (vma_m) {
112407+ unsigned long address_m;
112408+
112409+ if (vma->vm_start > vma_m->vm_start) {
112410+ address_m = address;
112411+ address -= SEGMEXEC_TASK_SIZE;
112412+ vma = vma_m;
112413+ h = hstate_vma(vma);
112414+ } else
112415+ address_m = address + SEGMEXEC_TASK_SIZE;
112416+
112417+ if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
112418+ return VM_FAULT_OOM;
112419+ address_m &= HPAGE_MASK;
112420+ unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
112421+ }
112422+#endif
112423+
112424 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
112425 if (!ptep)
112426 return VM_FAULT_OOM;
112427diff --git a/mm/internal.h b/mm/internal.h
112428index 36b23f1..673a6c7 100644
112429--- a/mm/internal.h
112430+++ b/mm/internal.h
112431@@ -157,6 +157,7 @@ __find_buddy_index(unsigned long page_idx, unsigned int order)
112432 extern int __isolate_free_page(struct page *page, unsigned int order);
112433 extern void __free_pages_bootmem(struct page *page, unsigned long pfn,
112434 unsigned int order);
112435+extern void free_compound_page(struct page *page);
112436 extern void prep_compound_page(struct page *page, unsigned long order);
112437 #ifdef CONFIG_MEMORY_FAILURE
112438 extern bool is_free_buddy_page(struct page *page);
112439diff --git a/mm/kmemleak.c b/mm/kmemleak.c
112440index cf79f11..254224e 100644
112441--- a/mm/kmemleak.c
112442+++ b/mm/kmemleak.c
112443@@ -375,7 +375,7 @@ static void print_unreferenced(struct seq_file *seq,
112444
112445 for (i = 0; i < object->trace_len; i++) {
112446 void *ptr = (void *)object->trace[i];
112447- seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
112448+ seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
112449 }
112450 }
112451
112452@@ -1966,7 +1966,7 @@ static int __init kmemleak_late_init(void)
112453 return -ENOMEM;
112454 }
112455
112456- dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
112457+ dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
112458 &kmemleak_fops);
112459 if (!dentry)
112460 pr_warning("Failed to create the debugfs kmemleak file\n");
112461diff --git a/mm/maccess.c b/mm/maccess.c
112462index d53adf9..03a24bf 100644
112463--- a/mm/maccess.c
112464+++ b/mm/maccess.c
112465@@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
112466 set_fs(KERNEL_DS);
112467 pagefault_disable();
112468 ret = __copy_from_user_inatomic(dst,
112469- (__force const void __user *)src, size);
112470+ (const void __force_user *)src, size);
112471 pagefault_enable();
112472 set_fs(old_fs);
112473
112474@@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
112475
112476 set_fs(KERNEL_DS);
112477 pagefault_disable();
112478- ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
112479+ ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
112480 pagefault_enable();
112481 set_fs(old_fs);
112482
112483diff --git a/mm/madvise.c b/mm/madvise.c
112484index 64bb8a2..68e4be5 100644
112485--- a/mm/madvise.c
112486+++ b/mm/madvise.c
112487@@ -52,6 +52,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
112488 pgoff_t pgoff;
112489 unsigned long new_flags = vma->vm_flags;
112490
112491+#ifdef CONFIG_PAX_SEGMEXEC
112492+ struct vm_area_struct *vma_m;
112493+#endif
112494+
112495 switch (behavior) {
112496 case MADV_NORMAL:
112497 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
112498@@ -127,6 +131,13 @@ success:
112499 /*
112500 * vm_flags is protected by the mmap_sem held in write mode.
112501 */
112502+
112503+#ifdef CONFIG_PAX_SEGMEXEC
112504+ vma_m = pax_find_mirror_vma(vma);
112505+ if (vma_m)
112506+ vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
112507+#endif
112508+
112509 vma->vm_flags = new_flags;
112510
112511 out:
112512@@ -278,11 +289,27 @@ static long madvise_dontneed(struct vm_area_struct *vma,
112513 struct vm_area_struct **prev,
112514 unsigned long start, unsigned long end)
112515 {
112516+
112517+#ifdef CONFIG_PAX_SEGMEXEC
112518+ struct vm_area_struct *vma_m;
112519+#endif
112520+
112521 *prev = vma;
112522 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
112523 return -EINVAL;
112524
112525 zap_page_range(vma, start, end - start, NULL);
112526+
112527+#ifdef CONFIG_PAX_SEGMEXEC
112528+ vma_m = pax_find_mirror_vma(vma);
112529+ if (vma_m) {
112530+ if (vma_m->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
112531+ return -EINVAL;
112532+
112533+ zap_page_range(vma_m, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
112534+ }
112535+#endif
112536+
112537 return 0;
112538 }
112539
112540@@ -485,6 +512,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
112541 if (end < start)
112542 return error;
112543
112544+#ifdef CONFIG_PAX_SEGMEXEC
112545+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
112546+ if (end > SEGMEXEC_TASK_SIZE)
112547+ return error;
112548+ } else
112549+#endif
112550+
112551+ if (end > TASK_SIZE)
112552+ return error;
112553+
112554 error = 0;
112555 if (end == start)
112556 return error;
112557diff --git a/mm/memory-failure.c b/mm/memory-failure.c
112558index 1f4446a..47abb4e 100644
112559--- a/mm/memory-failure.c
112560+++ b/mm/memory-failure.c
112561@@ -63,7 +63,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
112562
112563 int sysctl_memory_failure_recovery __read_mostly = 1;
112564
112565-atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
112566+atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
112567
112568 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
112569
112570@@ -200,7 +200,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
112571 pfn, t->comm, t->pid);
112572 si.si_signo = SIGBUS;
112573 si.si_errno = 0;
112574- si.si_addr = (void *)addr;
112575+ si.si_addr = (void __user *)addr;
112576 #ifdef __ARCH_SI_TRAPNO
112577 si.si_trapno = trapno;
112578 #endif
112579@@ -797,7 +797,7 @@ static struct page_state {
112580 unsigned long res;
112581 enum mf_action_page_type type;
112582 int (*action)(struct page *p, unsigned long pfn);
112583-} error_states[] = {
112584+} __do_const error_states[] = {
112585 { reserved, reserved, MF_MSG_KERNEL, me_kernel },
112586 /*
112587 * free pages are specially detected outside this table:
112588@@ -1100,7 +1100,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
112589 nr_pages = 1 << compound_order(hpage);
112590 else /* normal page or thp */
112591 nr_pages = 1;
112592- atomic_long_add(nr_pages, &num_poisoned_pages);
112593+ atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
112594
112595 /*
112596 * We need/can do nothing about count=0 pages.
112597@@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
112598 if (PageHWPoison(hpage)) {
112599 if ((hwpoison_filter(p) && TestClearPageHWPoison(p))
112600 || (p != hpage && TestSetPageHWPoison(hpage))) {
112601- atomic_long_sub(nr_pages, &num_poisoned_pages);
112602+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112603 unlock_page(hpage);
112604 return 0;
112605 }
112606@@ -1152,7 +1152,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
112607 else
112608 pr_err("MCE: %#lx: thp split failed\n", pfn);
112609 if (TestClearPageHWPoison(p))
112610- atomic_long_sub(nr_pages, &num_poisoned_pages);
112611+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112612 put_page(p);
112613 if (p != hpage)
112614 put_page(hpage);
112615@@ -1214,14 +1214,14 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
112616 */
112617 if (!PageHWPoison(p)) {
112618 printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn);
112619- atomic_long_sub(nr_pages, &num_poisoned_pages);
112620+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112621 unlock_page(hpage);
112622 put_page(hpage);
112623 return 0;
112624 }
112625 if (hwpoison_filter(p)) {
112626 if (TestClearPageHWPoison(p))
112627- atomic_long_sub(nr_pages, &num_poisoned_pages);
112628+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112629 unlock_page(hpage);
112630 put_page(hpage);
112631 return 0;
112632@@ -1450,7 +1450,7 @@ int unpoison_memory(unsigned long pfn)
112633 return 0;
112634 }
112635 if (TestClearPageHWPoison(p))
112636- atomic_long_dec(&num_poisoned_pages);
112637+ atomic_long_dec_unchecked(&num_poisoned_pages);
112638 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
112639 return 0;
112640 }
112641@@ -1464,7 +1464,7 @@ int unpoison_memory(unsigned long pfn)
112642 */
112643 if (TestClearPageHWPoison(page)) {
112644 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
112645- atomic_long_sub(nr_pages, &num_poisoned_pages);
112646+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112647 freeit = 1;
112648 if (PageHuge(page))
112649 clear_page_hwpoison_huge_page(page);
112650@@ -1600,11 +1600,11 @@ static int soft_offline_huge_page(struct page *page, int flags)
112651 if (PageHuge(page)) {
112652 set_page_hwpoison_huge_page(hpage);
112653 dequeue_hwpoisoned_huge_page(hpage);
112654- atomic_long_add(1 << compound_order(hpage),
112655+ atomic_long_add_unchecked(1 << compound_order(hpage),
112656 &num_poisoned_pages);
112657 } else {
112658 SetPageHWPoison(page);
112659- atomic_long_inc(&num_poisoned_pages);
112660+ atomic_long_inc_unchecked(&num_poisoned_pages);
112661 }
112662 }
112663 return ret;
112664@@ -1643,7 +1643,7 @@ static int __soft_offline_page(struct page *page, int flags)
112665 put_page(page);
112666 pr_info("soft_offline: %#lx: invalidated\n", pfn);
112667 SetPageHWPoison(page);
112668- atomic_long_inc(&num_poisoned_pages);
112669+ atomic_long_inc_unchecked(&num_poisoned_pages);
112670 return 0;
112671 }
112672
112673@@ -1664,7 +1664,7 @@ static int __soft_offline_page(struct page *page, int flags)
112674 page_is_file_cache(page));
112675 list_add(&page->lru, &pagelist);
112676 if (!TestSetPageHWPoison(page))
112677- atomic_long_inc(&num_poisoned_pages);
112678+ atomic_long_inc_unchecked(&num_poisoned_pages);
112679 ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL,
112680 MIGRATE_SYNC, MR_MEMORY_FAILURE);
112681 if (ret) {
112682@@ -1680,7 +1680,7 @@ static int __soft_offline_page(struct page *page, int flags)
112683 if (ret > 0)
112684 ret = -EIO;
112685 if (TestClearPageHWPoison(page))
112686- atomic_long_dec(&num_poisoned_pages);
112687+ atomic_long_dec_unchecked(&num_poisoned_pages);
112688 }
112689 } else {
112690 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
112691@@ -1742,11 +1742,11 @@ int soft_offline_page(struct page *page, int flags)
112692 if (PageHuge(page)) {
112693 set_page_hwpoison_huge_page(hpage);
112694 if (!dequeue_hwpoisoned_huge_page(hpage))
112695- atomic_long_add(1 << compound_order(hpage),
112696+ atomic_long_add_unchecked(1 << compound_order(hpage),
112697 &num_poisoned_pages);
112698 } else {
112699 if (!TestSetPageHWPoison(page))
112700- atomic_long_inc(&num_poisoned_pages);
112701+ atomic_long_inc_unchecked(&num_poisoned_pages);
112702 }
112703 }
112704 return ret;
112705diff --git a/mm/memory.c b/mm/memory.c
112706index 388dcf9..82aa351 100644
112707--- a/mm/memory.c
112708+++ b/mm/memory.c
112709@@ -414,6 +414,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
112710 free_pte_range(tlb, pmd, addr);
112711 } while (pmd++, addr = next, addr != end);
112712
112713+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
112714 start &= PUD_MASK;
112715 if (start < floor)
112716 return;
112717@@ -429,6 +430,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
112718 pud_clear(pud);
112719 pmd_free_tlb(tlb, pmd, start);
112720 mm_dec_nr_pmds(tlb->mm);
112721+#endif
112722 }
112723
112724 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
112725@@ -448,6 +450,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
112726 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
112727 } while (pud++, addr = next, addr != end);
112728
112729+#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
112730 start &= PGDIR_MASK;
112731 if (start < floor)
112732 return;
112733@@ -462,6 +465,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
112734 pud = pud_offset(pgd, start);
112735 pgd_clear(pgd);
112736 pud_free_tlb(tlb, pud, start);
112737+#endif
112738+
112739 }
112740
112741 /*
112742@@ -690,7 +695,7 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
112743 /*
112744 * Choose text because data symbols depend on CONFIG_KALLSYMS_ALL=y
112745 */
112746- pr_alert("file:%pD fault:%pf mmap:%pf readpage:%pf\n",
112747+ pr_alert("file:%pD fault:%pX mmap:%pX readpage:%pX\n",
112748 vma->vm_file,
112749 vma->vm_ops ? vma->vm_ops->fault : NULL,
112750 vma->vm_file ? vma->vm_file->f_op->mmap : NULL,
112751@@ -1463,6 +1468,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
112752 page_add_file_rmap(page);
112753 set_pte_at(mm, addr, pte, mk_pte(page, prot));
112754
112755+#ifdef CONFIG_PAX_SEGMEXEC
112756+ pax_mirror_file_pte(vma, addr, page, ptl);
112757+#endif
112758+
112759 retval = 0;
112760 pte_unmap_unlock(pte, ptl);
112761 return retval;
112762@@ -1507,9 +1516,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
112763 if (!page_count(page))
112764 return -EINVAL;
112765 if (!(vma->vm_flags & VM_MIXEDMAP)) {
112766+
112767+#ifdef CONFIG_PAX_SEGMEXEC
112768+ struct vm_area_struct *vma_m;
112769+#endif
112770+
112771 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
112772 BUG_ON(vma->vm_flags & VM_PFNMAP);
112773 vma->vm_flags |= VM_MIXEDMAP;
112774+
112775+#ifdef CONFIG_PAX_SEGMEXEC
112776+ vma_m = pax_find_mirror_vma(vma);
112777+ if (vma_m)
112778+ vma_m->vm_flags |= VM_MIXEDMAP;
112779+#endif
112780+
112781 }
112782 return insert_page(vma, addr, page, vma->vm_page_prot);
112783 }
112784@@ -1592,6 +1613,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
112785 unsigned long pfn)
112786 {
112787 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
112788+ BUG_ON(vma->vm_mirror);
112789
112790 if (addr < vma->vm_start || addr >= vma->vm_end)
112791 return -EFAULT;
112792@@ -1839,7 +1861,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
112793
112794 BUG_ON(pud_huge(*pud));
112795
112796- pmd = pmd_alloc(mm, pud, addr);
112797+ pmd = (mm == &init_mm) ?
112798+ pmd_alloc_kernel(mm, pud, addr) :
112799+ pmd_alloc(mm, pud, addr);
112800 if (!pmd)
112801 return -ENOMEM;
112802 do {
112803@@ -1859,7 +1883,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
112804 unsigned long next;
112805 int err;
112806
112807- pud = pud_alloc(mm, pgd, addr);
112808+ pud = (mm == &init_mm) ?
112809+ pud_alloc_kernel(mm, pgd, addr) :
112810+ pud_alloc(mm, pgd, addr);
112811 if (!pud)
112812 return -ENOMEM;
112813 do {
112814@@ -2040,6 +2066,196 @@ static inline int wp_page_reuse(struct mm_struct *mm,
112815 return VM_FAULT_WRITE;
112816 }
112817
112818+#ifdef CONFIG_PAX_SEGMEXEC
112819+static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
112820+{
112821+ struct mm_struct *mm = vma->vm_mm;
112822+ spinlock_t *ptl;
112823+ pte_t *pte, entry;
112824+
112825+ pte = pte_offset_map_lock(mm, pmd, address, &ptl);
112826+ entry = *pte;
112827+ if (pte_none(entry))
112828+ ;
112829+ else if (!pte_present(entry)) {
112830+ swp_entry_t swapentry;
112831+
112832+ swapentry = pte_to_swp_entry(entry);
112833+ if (!non_swap_entry(swapentry))
112834+ dec_mm_counter_fast(mm, MM_SWAPENTS);
112835+ else if (is_migration_entry(swapentry)) {
112836+ if (PageAnon(migration_entry_to_page(swapentry)))
112837+ dec_mm_counter_fast(mm, MM_ANONPAGES);
112838+ else
112839+ dec_mm_counter_fast(mm, MM_FILEPAGES);
112840+ }
112841+ free_swap_and_cache(swapentry);
112842+ pte_clear_not_present_full(mm, address, pte, 0);
112843+ } else {
112844+ struct page *page;
112845+
112846+ flush_cache_page(vma, address, pte_pfn(entry));
112847+ entry = ptep_clear_flush(vma, address, pte);
112848+ BUG_ON(pte_dirty(entry));
112849+ page = vm_normal_page(vma, address, entry);
112850+ if (page) {
112851+ update_hiwater_rss(mm);
112852+ if (PageAnon(page))
112853+ dec_mm_counter_fast(mm, MM_ANONPAGES);
112854+ else
112855+ dec_mm_counter_fast(mm, MM_FILEPAGES);
112856+ page_remove_rmap(page);
112857+ page_cache_release(page);
112858+ }
112859+ }
112860+ pte_unmap_unlock(pte, ptl);
112861+}
112862+
112863+/* PaX: if vma is mirrored, synchronize the mirror's PTE
112864+ *
112865+ * the ptl of the lower mapped page is held on entry and is not released on exit
112866+ * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
112867+ */
112868+static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
112869+{
112870+ struct mm_struct *mm = vma->vm_mm;
112871+ unsigned long address_m;
112872+ spinlock_t *ptl_m;
112873+ struct vm_area_struct *vma_m;
112874+ pmd_t *pmd_m;
112875+ pte_t *pte_m, entry_m;
112876+
112877+ BUG_ON(!page_m || !PageAnon(page_m));
112878+
112879+ vma_m = pax_find_mirror_vma(vma);
112880+ if (!vma_m)
112881+ return;
112882+
112883+ BUG_ON(!PageLocked(page_m));
112884+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
112885+ address_m = address + SEGMEXEC_TASK_SIZE;
112886+ pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
112887+ pte_m = pte_offset_map(pmd_m, address_m);
112888+ ptl_m = pte_lockptr(mm, pmd_m);
112889+ if (ptl != ptl_m) {
112890+ spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
112891+ if (!pte_none(*pte_m))
112892+ goto out;
112893+ }
112894+
112895+ entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
112896+ page_cache_get(page_m);
112897+ page_add_anon_rmap(page_m, vma_m, address_m);
112898+ inc_mm_counter_fast(mm, MM_ANONPAGES);
112899+ set_pte_at(mm, address_m, pte_m, entry_m);
112900+ update_mmu_cache(vma_m, address_m, pte_m);
112901+out:
112902+ if (ptl != ptl_m)
112903+ spin_unlock(ptl_m);
112904+ pte_unmap(pte_m);
112905+ unlock_page(page_m);
112906+}
112907+
112908+void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
112909+{
112910+ struct mm_struct *mm = vma->vm_mm;
112911+ unsigned long address_m;
112912+ spinlock_t *ptl_m;
112913+ struct vm_area_struct *vma_m;
112914+ pmd_t *pmd_m;
112915+ pte_t *pte_m, entry_m;
112916+
112917+ BUG_ON(!page_m || PageAnon(page_m));
112918+
112919+ vma_m = pax_find_mirror_vma(vma);
112920+ if (!vma_m)
112921+ return;
112922+
112923+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
112924+ address_m = address + SEGMEXEC_TASK_SIZE;
112925+ pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
112926+ pte_m = pte_offset_map(pmd_m, address_m);
112927+ ptl_m = pte_lockptr(mm, pmd_m);
112928+ if (ptl != ptl_m) {
112929+ spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
112930+ if (!pte_none(*pte_m))
112931+ goto out;
112932+ }
112933+
112934+ entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
112935+ page_cache_get(page_m);
112936+ page_add_file_rmap(page_m);
112937+ inc_mm_counter_fast(mm, MM_FILEPAGES);
112938+ set_pte_at(mm, address_m, pte_m, entry_m);
112939+ update_mmu_cache(vma_m, address_m, pte_m);
112940+out:
112941+ if (ptl != ptl_m)
112942+ spin_unlock(ptl_m);
112943+ pte_unmap(pte_m);
112944+}
112945+
112946+static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
112947+{
112948+ struct mm_struct *mm = vma->vm_mm;
112949+ unsigned long address_m;
112950+ spinlock_t *ptl_m;
112951+ struct vm_area_struct *vma_m;
112952+ pmd_t *pmd_m;
112953+ pte_t *pte_m, entry_m;
112954+
112955+ vma_m = pax_find_mirror_vma(vma);
112956+ if (!vma_m)
112957+ return;
112958+
112959+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
112960+ address_m = address + SEGMEXEC_TASK_SIZE;
112961+ pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
112962+ pte_m = pte_offset_map(pmd_m, address_m);
112963+ ptl_m = pte_lockptr(mm, pmd_m);
112964+ if (ptl != ptl_m) {
112965+ spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
112966+ if (!pte_none(*pte_m))
112967+ goto out;
112968+ }
112969+
112970+ entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
112971+ set_pte_at(mm, address_m, pte_m, entry_m);
112972+out:
112973+ if (ptl != ptl_m)
112974+ spin_unlock(ptl_m);
112975+ pte_unmap(pte_m);
112976+}
112977+
112978+static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
112979+{
112980+ struct page *page_m;
112981+ pte_t entry;
112982+
112983+ if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
112984+ goto out;
112985+
112986+ entry = *pte;
112987+ page_m = vm_normal_page(vma, address, entry);
112988+ if (!page_m)
112989+ pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
112990+ else if (PageAnon(page_m)) {
112991+ if (pax_find_mirror_vma(vma)) {
112992+ pte_unmap_unlock(pte, ptl);
112993+ lock_page(page_m);
112994+ pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
112995+ if (pte_same(entry, *pte))
112996+ pax_mirror_anon_pte(vma, address, page_m, ptl);
112997+ else
112998+ unlock_page(page_m);
112999+ }
113000+ } else
113001+ pax_mirror_file_pte(vma, address, page_m, ptl);
113002+
113003+out:
113004+ pte_unmap_unlock(pte, ptl);
113005+}
113006+#endif
113007+
113008 /*
113009 * Handle the case of a page which we actually need to copy to a new page.
113010 *
113011@@ -2094,6 +2310,12 @@ static int wp_page_copy(struct mm_struct *mm, struct vm_area_struct *vma,
113012 */
113013 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
113014 if (likely(pte_same(*page_table, orig_pte))) {
113015+
113016+#ifdef CONFIG_PAX_SEGMEXEC
113017+ if (pax_find_mirror_vma(vma))
113018+ BUG_ON(!trylock_page(new_page));
113019+#endif
113020+
113021 if (old_page) {
113022 if (!PageAnon(old_page)) {
113023 dec_mm_counter_fast(mm, MM_FILEPAGES);
113024@@ -2148,6 +2370,10 @@ static int wp_page_copy(struct mm_struct *mm, struct vm_area_struct *vma,
113025 page_remove_rmap(old_page);
113026 }
113027
113028+#ifdef CONFIG_PAX_SEGMEXEC
113029+ pax_mirror_anon_pte(vma, address, new_page, ptl);
113030+#endif
113031+
113032 /* Free the old page.. */
113033 new_page = old_page;
113034 page_copied = 1;
113035@@ -2579,6 +2805,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
113036 swap_free(entry);
113037 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
113038 try_to_free_swap(page);
113039+
113040+#ifdef CONFIG_PAX_SEGMEXEC
113041+ if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
113042+#endif
113043+
113044 unlock_page(page);
113045 if (page != swapcache) {
113046 /*
113047@@ -2602,6 +2833,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
113048
113049 /* No need to invalidate - it was non-present before */
113050 update_mmu_cache(vma, address, page_table);
113051+
113052+#ifdef CONFIG_PAX_SEGMEXEC
113053+ pax_mirror_anon_pte(vma, address, page, ptl);
113054+#endif
113055+
113056 unlock:
113057 pte_unmap_unlock(page_table, ptl);
113058 out:
113059@@ -2621,40 +2857,6 @@ out_release:
113060 }
113061
113062 /*
113063- * This is like a special single-page "expand_{down|up}wards()",
113064- * except we must first make sure that 'address{-|+}PAGE_SIZE'
113065- * doesn't hit another vma.
113066- */
113067-static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
113068-{
113069- address &= PAGE_MASK;
113070- if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
113071- struct vm_area_struct *prev = vma->vm_prev;
113072-
113073- /*
113074- * Is there a mapping abutting this one below?
113075- *
113076- * That's only ok if it's the same stack mapping
113077- * that has gotten split..
113078- */
113079- if (prev && prev->vm_end == address)
113080- return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
113081-
113082- return expand_downwards(vma, address - PAGE_SIZE);
113083- }
113084- if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
113085- struct vm_area_struct *next = vma->vm_next;
113086-
113087- /* As VM_GROWSDOWN but s/below/above/ */
113088- if (next && next->vm_start == address + PAGE_SIZE)
113089- return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
113090-
113091- return expand_upwards(vma, address + PAGE_SIZE);
113092- }
113093- return 0;
113094-}
113095-
113096-/*
113097 * We enter with non-exclusive mmap_sem (to exclude vma changes,
113098 * but allow concurrent faults), and pte mapped but not yet locked.
113099 * We return with mmap_sem still held, but pte unmapped and unlocked.
113100@@ -2664,31 +2866,29 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
113101 unsigned int flags)
113102 {
113103 struct mem_cgroup *memcg;
113104- struct page *page;
113105+ struct page *page = NULL;
113106 spinlock_t *ptl;
113107 pte_t entry;
113108
113109- pte_unmap(page_table);
113110-
113111 /* File mapping without ->vm_ops ? */
113112- if (vma->vm_flags & VM_SHARED)
113113+ if (vma->vm_flags & VM_SHARED) {
113114+ pte_unmap(page_table);
113115 return VM_FAULT_SIGBUS;
113116+ }
113117
113118- /* Check if we need to add a guard page to the stack */
113119- if (check_stack_guard_page(vma, address) < 0)
113120- return VM_FAULT_SIGSEGV;
113121-
113122- /* Use the zero-page for reads */
113123 if (!(flags & FAULT_FLAG_WRITE) && !mm_forbids_zeropage(mm)) {
113124 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
113125 vma->vm_page_prot));
113126- page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
113127+ ptl = pte_lockptr(mm, pmd);
113128+ spin_lock(ptl);
113129 if (!pte_none(*page_table))
113130 goto unlock;
113131 goto setpte;
113132 }
113133
113134 /* Allocate our own private page. */
113135+ pte_unmap(page_table);
113136+
113137 if (unlikely(anon_vma_prepare(vma)))
113138 goto oom;
113139 page = alloc_zeroed_user_highpage_movable(vma, address);
113140@@ -2713,6 +2913,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
113141 if (!pte_none(*page_table))
113142 goto release;
113143
113144+#ifdef CONFIG_PAX_SEGMEXEC
113145+ if (pax_find_mirror_vma(vma))
113146+ BUG_ON(!trylock_page(page));
113147+#endif
113148+
113149 inc_mm_counter_fast(mm, MM_ANONPAGES);
113150 page_add_new_anon_rmap(page, vma, address);
113151 mem_cgroup_commit_charge(page, memcg, false);
113152@@ -2722,6 +2927,12 @@ setpte:
113153
113154 /* No need to invalidate - it was non-present before */
113155 update_mmu_cache(vma, address, page_table);
113156+
113157+#ifdef CONFIG_PAX_SEGMEXEC
113158+ if (page)
113159+ pax_mirror_anon_pte(vma, address, page, ptl);
113160+#endif
113161+
113162 unlock:
113163 pte_unmap_unlock(page_table, ptl);
113164 return 0;
113165@@ -2954,6 +3165,11 @@ static int do_read_fault(struct mm_struct *mm, struct vm_area_struct *vma,
113166 return ret;
113167 }
113168 do_set_pte(vma, address, fault_page, pte, false, false);
113169+
113170+#ifdef CONFIG_PAX_SEGMEXEC
113171+ pax_mirror_file_pte(vma, address, fault_page, ptl);
113172+#endif
113173+
113174 unlock_page(fault_page);
113175 unlock_out:
113176 pte_unmap_unlock(pte, ptl);
113177@@ -3005,7 +3221,18 @@ static int do_cow_fault(struct mm_struct *mm, struct vm_area_struct *vma,
113178 }
113179 goto uncharge_out;
113180 }
113181+
113182+#ifdef CONFIG_PAX_SEGMEXEC
113183+ if (pax_find_mirror_vma(vma))
113184+ BUG_ON(!trylock_page(new_page));
113185+#endif
113186+
113187 do_set_pte(vma, address, new_page, pte, true, true);
113188+
113189+#ifdef CONFIG_PAX_SEGMEXEC
113190+ pax_mirror_anon_pte(vma, address, new_page, ptl);
113191+#endif
113192+
113193 mem_cgroup_commit_charge(new_page, memcg, false);
113194 lru_cache_add_active_or_unevictable(new_page, vma);
113195 pte_unmap_unlock(pte, ptl);
113196@@ -3063,6 +3290,11 @@ static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma,
113197 return ret;
113198 }
113199 do_set_pte(vma, address, fault_page, pte, true, false);
113200+
113201+#ifdef CONFIG_PAX_SEGMEXEC
113202+ pax_mirror_file_pte(vma, address, fault_page, ptl);
113203+#endif
113204+
113205 pte_unmap_unlock(pte, ptl);
113206
113207 if (set_page_dirty(fault_page))
113208@@ -3288,6 +3520,12 @@ static int handle_pte_fault(struct mm_struct *mm,
113209 if (flags & FAULT_FLAG_WRITE)
113210 flush_tlb_fix_spurious_fault(vma, address);
113211 }
113212+
113213+#ifdef CONFIG_PAX_SEGMEXEC
113214+ pax_mirror_pte(vma, address, pte, pmd, ptl);
113215+ return 0;
113216+#endif
113217+
113218 unlock:
113219 pte_unmap_unlock(pte, ptl);
113220 return 0;
113221@@ -3307,9 +3545,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
113222 pmd_t *pmd;
113223 pte_t *pte;
113224
113225+#ifdef CONFIG_PAX_SEGMEXEC
113226+ struct vm_area_struct *vma_m;
113227+#endif
113228+
113229 if (unlikely(is_vm_hugetlb_page(vma)))
113230 return hugetlb_fault(mm, vma, address, flags);
113231
113232+#ifdef CONFIG_PAX_SEGMEXEC
113233+ vma_m = pax_find_mirror_vma(vma);
113234+ if (vma_m) {
113235+ unsigned long address_m;
113236+ pgd_t *pgd_m;
113237+ pud_t *pud_m;
113238+ pmd_t *pmd_m;
113239+
113240+ if (vma->vm_start > vma_m->vm_start) {
113241+ address_m = address;
113242+ address -= SEGMEXEC_TASK_SIZE;
113243+ vma = vma_m;
113244+ } else
113245+ address_m = address + SEGMEXEC_TASK_SIZE;
113246+
113247+ pgd_m = pgd_offset(mm, address_m);
113248+ pud_m = pud_alloc(mm, pgd_m, address_m);
113249+ if (!pud_m)
113250+ return VM_FAULT_OOM;
113251+ pmd_m = pmd_alloc(mm, pud_m, address_m);
113252+ if (!pmd_m)
113253+ return VM_FAULT_OOM;
113254+ if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
113255+ return VM_FAULT_OOM;
113256+ pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
113257+ }
113258+#endif
113259+
113260 pgd = pgd_offset(mm, address);
113261 pud = pud_alloc(mm, pgd, address);
113262 if (!pud)
113263@@ -3444,6 +3714,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
113264 spin_unlock(&mm->page_table_lock);
113265 return 0;
113266 }
113267+
113268+int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
113269+{
113270+ pud_t *new = pud_alloc_one(mm, address);
113271+ if (!new)
113272+ return -ENOMEM;
113273+
113274+ smp_wmb(); /* See comment in __pte_alloc */
113275+
113276+ spin_lock(&mm->page_table_lock);
113277+ if (pgd_present(*pgd)) /* Another has populated it */
113278+ pud_free(mm, new);
113279+ else
113280+ pgd_populate_kernel(mm, pgd, new);
113281+ spin_unlock(&mm->page_table_lock);
113282+ return 0;
113283+}
113284 #endif /* __PAGETABLE_PUD_FOLDED */
113285
113286 #ifndef __PAGETABLE_PMD_FOLDED
113287@@ -3476,6 +3763,32 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
113288 spin_unlock(&mm->page_table_lock);
113289 return 0;
113290 }
113291+
113292+int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
113293+{
113294+ pmd_t *new = pmd_alloc_one(mm, address);
113295+ if (!new)
113296+ return -ENOMEM;
113297+
113298+ smp_wmb(); /* See comment in __pte_alloc */
113299+
113300+ spin_lock(&mm->page_table_lock);
113301+#ifndef __ARCH_HAS_4LEVEL_HACK
113302+ if (!pud_present(*pud)) {
113303+ mm_inc_nr_pmds(mm);
113304+ pud_populate_kernel(mm, pud, new);
113305+ } else /* Another has populated it */
113306+ pmd_free(mm, new);
113307+#else
113308+ if (!pgd_present(*pud)) {
113309+ mm_inc_nr_pmds(mm);
113310+ pgd_populate_kernel(mm, pud, new);
113311+ } else /* Another has populated it */
113312+ pmd_free(mm, new);
113313+#endif /* __ARCH_HAS_4LEVEL_HACK */
113314+ spin_unlock(&mm->page_table_lock);
113315+ return 0;
113316+}
113317 #endif /* __PAGETABLE_PMD_FOLDED */
113318
113319 static int __follow_pte(struct mm_struct *mm, unsigned long address,
113320@@ -3585,8 +3898,8 @@ out:
113321 return ret;
113322 }
113323
113324-int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
113325- void *buf, int len, int write)
113326+ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
113327+ void *buf, size_t len, int write)
113328 {
113329 resource_size_t phys_addr;
113330 unsigned long prot = 0;
113331@@ -3612,8 +3925,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
113332 * Access another process' address space as given in mm. If non-NULL, use the
113333 * given task for page fault accounting.
113334 */
113335-static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
113336- unsigned long addr, void *buf, int len, int write)
113337+static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
113338+ unsigned long addr, void *buf, size_t len, int write)
113339 {
113340 struct vm_area_struct *vma;
113341 void *old_buf = buf;
113342@@ -3621,7 +3934,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
113343 down_read(&mm->mmap_sem);
113344 /* ignore errors, just check how much was successfully transferred */
113345 while (len) {
113346- int bytes, ret, offset;
113347+ ssize_t bytes, ret, offset;
113348 void *maddr;
113349 struct page *page = NULL;
113350
113351@@ -3682,8 +3995,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
113352 *
113353 * The caller must hold a reference on @mm.
113354 */
113355-int access_remote_vm(struct mm_struct *mm, unsigned long addr,
113356- void *buf, int len, int write)
113357+ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
113358+ void *buf, size_t len, int write)
113359 {
113360 return __access_remote_vm(NULL, mm, addr, buf, len, write);
113361 }
113362@@ -3693,11 +4006,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
113363 * Source/target buffer must be kernel space,
113364 * Do not walk the page table directly, use get_user_pages
113365 */
113366-int access_process_vm(struct task_struct *tsk, unsigned long addr,
113367- void *buf, int len, int write)
113368+ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
113369+ void *buf, size_t len, int write)
113370 {
113371 struct mm_struct *mm;
113372- int ret;
113373+ ssize_t ret;
113374
113375 mm = get_task_mm(tsk);
113376 if (!mm)
113377diff --git a/mm/mempolicy.c b/mm/mempolicy.c
113378index 99d4c1d..a577817 100644
113379--- a/mm/mempolicy.c
113380+++ b/mm/mempolicy.c
113381@@ -703,6 +703,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
113382 unsigned long vmstart;
113383 unsigned long vmend;
113384
113385+#ifdef CONFIG_PAX_SEGMEXEC
113386+ struct vm_area_struct *vma_m;
113387+#endif
113388+
113389 vma = find_vma(mm, start);
113390 if (!vma || vma->vm_start > start)
113391 return -EFAULT;
113392@@ -746,6 +750,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
113393 err = vma_replace_policy(vma, new_pol);
113394 if (err)
113395 goto out;
113396+
113397+#ifdef CONFIG_PAX_SEGMEXEC
113398+ vma_m = pax_find_mirror_vma(vma);
113399+ if (vma_m) {
113400+ err = vma_replace_policy(vma_m, new_pol);
113401+ if (err)
113402+ goto out;
113403+ }
113404+#endif
113405+
113406 }
113407
113408 out:
113409@@ -1161,6 +1175,17 @@ static long do_mbind(unsigned long start, unsigned long len,
113410
113411 if (end < start)
113412 return -EINVAL;
113413+
113414+#ifdef CONFIG_PAX_SEGMEXEC
113415+ if (mm->pax_flags & MF_PAX_SEGMEXEC) {
113416+ if (end > SEGMEXEC_TASK_SIZE)
113417+ return -EINVAL;
113418+ } else
113419+#endif
113420+
113421+ if (end > TASK_SIZE)
113422+ return -EINVAL;
113423+
113424 if (end == start)
113425 return 0;
113426
113427@@ -1386,8 +1411,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
113428 */
113429 tcred = __task_cred(task);
113430 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
113431- !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
113432- !capable(CAP_SYS_NICE)) {
113433+ !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
113434 rcu_read_unlock();
113435 err = -EPERM;
113436 goto out_put;
113437@@ -1418,6 +1442,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
113438 goto out;
113439 }
113440
113441+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
113442+ if (mm != current->mm &&
113443+ (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
113444+ mmput(mm);
113445+ err = -EPERM;
113446+ goto out;
113447+ }
113448+#endif
113449+
113450 err = do_migrate_pages(mm, old, new,
113451 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
113452
113453diff --git a/mm/migrate.c b/mm/migrate.c
113454index fcb6204..b3f1a44 100644
113455--- a/mm/migrate.c
113456+++ b/mm/migrate.c
113457@@ -1501,8 +1501,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
113458 */
113459 tcred = __task_cred(task);
113460 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
113461- !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
113462- !capable(CAP_SYS_NICE)) {
113463+ !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
113464 rcu_read_unlock();
113465 err = -EPERM;
113466 goto out;
113467diff --git a/mm/mlock.c b/mm/mlock.c
113468index 6fd2cf1..cbae765 100644
113469--- a/mm/mlock.c
113470+++ b/mm/mlock.c
113471@@ -14,6 +14,7 @@
113472 #include <linux/pagevec.h>
113473 #include <linux/mempolicy.h>
113474 #include <linux/syscalls.h>
113475+#include <linux/security.h>
113476 #include <linux/sched.h>
113477 #include <linux/export.h>
113478 #include <linux/rmap.h>
113479@@ -557,7 +558,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
113480 {
113481 unsigned long nstart, end, tmp;
113482 struct vm_area_struct * vma, * prev;
113483- int error;
113484+ int error = 0;
113485
113486 VM_BUG_ON(start & ~PAGE_MASK);
113487 VM_BUG_ON(len != PAGE_ALIGN(len));
113488@@ -566,6 +567,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
113489 return -EINVAL;
113490 if (end == start)
113491 return 0;
113492+ if (end > TASK_SIZE)
113493+ return -EINVAL;
113494+
113495 vma = find_vma(current->mm, start);
113496 if (!vma || vma->vm_start > start)
113497 return -ENOMEM;
113498@@ -577,6 +581,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
113499 for (nstart = start ; ; ) {
113500 vm_flags_t newflags;
113501
113502+#ifdef CONFIG_PAX_SEGMEXEC
113503+ if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
113504+ break;
113505+#endif
113506+
113507 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
113508
113509 newflags = vma->vm_flags & ~VM_LOCKED;
113510@@ -627,6 +636,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
113511 locked += current->mm->locked_vm;
113512
113513 /* check against resource limits */
113514+ gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
113515 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
113516 error = do_mlock(start, len, 1);
113517
113518@@ -668,6 +678,11 @@ static int do_mlockall(int flags)
113519 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
113520 vm_flags_t newflags;
113521
113522+#ifdef CONFIG_PAX_SEGMEXEC
113523+ if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
113524+ break;
113525+#endif
113526+
113527 newflags = vma->vm_flags & ~VM_LOCKED;
113528 if (flags & MCL_CURRENT)
113529 newflags |= VM_LOCKED;
113530@@ -699,8 +714,10 @@ SYSCALL_DEFINE1(mlockall, int, flags)
113531 lock_limit >>= PAGE_SHIFT;
113532
113533 ret = -ENOMEM;
113534+
113535+ gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
113536+
113537 down_write(&current->mm->mmap_sem);
113538-
113539 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
113540 capable(CAP_IPC_LOCK))
113541 ret = do_mlockall(flags);
113542diff --git a/mm/mm_init.c b/mm/mm_init.c
113543index fdadf91..5f527d1 100644
113544--- a/mm/mm_init.c
113545+++ b/mm/mm_init.c
113546@@ -170,7 +170,7 @@ static int __meminit mm_compute_batch_notifier(struct notifier_block *self,
113547 return NOTIFY_OK;
113548 }
113549
113550-static struct notifier_block compute_batch_nb __meminitdata = {
113551+static struct notifier_block compute_batch_nb __meminitconst = {
113552 .notifier_call = mm_compute_batch_notifier,
113553 .priority = IPC_CALLBACK_PRI, /* use lowest priority */
113554 };
113555diff --git a/mm/mmap.c b/mm/mmap.c
113556index aa632ad..13456342 100644
113557--- a/mm/mmap.c
113558+++ b/mm/mmap.c
113559@@ -41,6 +41,7 @@
113560 #include <linux/notifier.h>
113561 #include <linux/memory.h>
113562 #include <linux/printk.h>
113563+#include <linux/random.h>
113564
113565 #include <asm/uaccess.h>
113566 #include <asm/cacheflush.h>
113567@@ -57,6 +58,16 @@
113568 #define arch_rebalance_pgtables(addr, len) (addr)
113569 #endif
113570
113571+static inline void verify_mm_writelocked(struct mm_struct *mm)
113572+{
113573+#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
113574+ if (unlikely(down_read_trylock(&mm->mmap_sem))) {
113575+ up_read(&mm->mmap_sem);
113576+ BUG();
113577+ }
113578+#endif
113579+}
113580+
113581 static void unmap_region(struct mm_struct *mm,
113582 struct vm_area_struct *vma, struct vm_area_struct *prev,
113583 unsigned long start, unsigned long end);
113584@@ -76,16 +87,25 @@ static void unmap_region(struct mm_struct *mm,
113585 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
113586 *
113587 */
113588-pgprot_t protection_map[16] = {
113589+pgprot_t protection_map[16] __read_only = {
113590 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
113591 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
113592 };
113593
113594-pgprot_t vm_get_page_prot(unsigned long vm_flags)
113595+pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
113596 {
113597- return __pgprot(pgprot_val(protection_map[vm_flags &
113598+ pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
113599 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
113600 pgprot_val(arch_vm_get_page_prot(vm_flags)));
113601+
113602+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
113603+ if (!(__supported_pte_mask & _PAGE_NX) &&
113604+ (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
113605+ (vm_flags & (VM_READ | VM_WRITE)))
113606+ prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
113607+#endif
113608+
113609+ return prot;
113610 }
113611 EXPORT_SYMBOL(vm_get_page_prot);
113612
113613@@ -114,6 +134,7 @@ unsigned long sysctl_overcommit_kbytes __read_mostly;
113614 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
113615 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
113616 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
113617+unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
113618 /*
113619 * Make sure vm_committed_as in one cacheline and not cacheline shared with
113620 * other variables. It can be updated by several CPUs frequently.
113621@@ -271,6 +292,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
113622 struct vm_area_struct *next = vma->vm_next;
113623
113624 might_sleep();
113625+ BUG_ON(vma->vm_mirror);
113626 if (vma->vm_ops && vma->vm_ops->close)
113627 vma->vm_ops->close(vma);
113628 if (vma->vm_file)
113629@@ -284,6 +306,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len);
113630
113631 SYSCALL_DEFINE1(brk, unsigned long, brk)
113632 {
113633+ unsigned long rlim;
113634 unsigned long retval;
113635 unsigned long newbrk, oldbrk;
113636 struct mm_struct *mm = current->mm;
113637@@ -314,7 +337,13 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
113638 * segment grow beyond its set limit the in case where the limit is
113639 * not page aligned -Ram Gupta
113640 */
113641- if (check_data_rlimit(rlimit(RLIMIT_DATA), brk, mm->start_brk,
113642+ rlim = rlimit(RLIMIT_DATA);
113643+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
113644+ /* force a minimum 16MB brk heap on setuid/setgid binaries */
113645+ if (rlim < PAGE_SIZE && (get_dumpable(mm) != SUID_DUMP_USER) && gr_is_global_nonroot(current_uid()))
113646+ rlim = 4096 * PAGE_SIZE;
113647+#endif
113648+ if (check_data_rlimit(rlim, brk, mm->start_brk,
113649 mm->end_data, mm->start_data))
113650 goto out;
113651
113652@@ -967,6 +996,12 @@ static int
113653 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
113654 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
113655 {
113656+
113657+#ifdef CONFIG_PAX_SEGMEXEC
113658+ if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
113659+ return 0;
113660+#endif
113661+
113662 if (is_mergeable_vma(vma, file, vm_flags) &&
113663 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
113664 if (vma->vm_pgoff == vm_pgoff)
113665@@ -986,6 +1021,12 @@ static int
113666 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
113667 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
113668 {
113669+
113670+#ifdef CONFIG_PAX_SEGMEXEC
113671+ if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
113672+ return 0;
113673+#endif
113674+
113675 if (is_mergeable_vma(vma, file, vm_flags) &&
113676 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
113677 pgoff_t vm_pglen;
113678@@ -1035,6 +1076,13 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113679 struct vm_area_struct *area, *next;
113680 int err;
113681
113682+#ifdef CONFIG_PAX_SEGMEXEC
113683+ unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
113684+ struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
113685+
113686+ BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
113687+#endif
113688+
113689 /*
113690 * We later require that vma->vm_flags == vm_flags,
113691 * so this tests vma->vm_flags & VM_SPECIAL, too.
113692@@ -1050,6 +1098,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113693 if (next && next->vm_end == end) /* cases 6, 7, 8 */
113694 next = next->vm_next;
113695
113696+#ifdef CONFIG_PAX_SEGMEXEC
113697+ if (prev)
113698+ prev_m = pax_find_mirror_vma(prev);
113699+ if (area)
113700+ area_m = pax_find_mirror_vma(area);
113701+ if (next)
113702+ next_m = pax_find_mirror_vma(next);
113703+#endif
113704+
113705 /*
113706 * Can it merge with the predecessor?
113707 */
113708@@ -1069,9 +1126,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113709 /* cases 1, 6 */
113710 err = vma_adjust(prev, prev->vm_start,
113711 next->vm_end, prev->vm_pgoff, NULL);
113712- } else /* cases 2, 5, 7 */
113713+
113714+#ifdef CONFIG_PAX_SEGMEXEC
113715+ if (!err && prev_m)
113716+ err = vma_adjust(prev_m, prev_m->vm_start,
113717+ next_m->vm_end, prev_m->vm_pgoff, NULL);
113718+#endif
113719+
113720+ } else { /* cases 2, 5, 7 */
113721 err = vma_adjust(prev, prev->vm_start,
113722 end, prev->vm_pgoff, NULL);
113723+
113724+#ifdef CONFIG_PAX_SEGMEXEC
113725+ if (!err && prev_m)
113726+ err = vma_adjust(prev_m, prev_m->vm_start,
113727+ end_m, prev_m->vm_pgoff, NULL);
113728+#endif
113729+
113730+ }
113731 if (err)
113732 return NULL;
113733 khugepaged_enter_vma_merge(prev, vm_flags);
113734@@ -1085,12 +1157,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113735 mpol_equal(policy, vma_policy(next)) &&
113736 can_vma_merge_before(next, vm_flags,
113737 anon_vma, file, pgoff+pglen)) {
113738- if (prev && addr < prev->vm_end) /* case 4 */
113739+ if (prev && addr < prev->vm_end) { /* case 4 */
113740 err = vma_adjust(prev, prev->vm_start,
113741 addr, prev->vm_pgoff, NULL);
113742- else /* cases 3, 8 */
113743+
113744+#ifdef CONFIG_PAX_SEGMEXEC
113745+ if (!err && prev_m)
113746+ err = vma_adjust(prev_m, prev_m->vm_start,
113747+ addr_m, prev_m->vm_pgoff, NULL);
113748+#endif
113749+
113750+ } else { /* cases 3, 8 */
113751 err = vma_adjust(area, addr, next->vm_end,
113752 next->vm_pgoff - pglen, NULL);
113753+
113754+#ifdef CONFIG_PAX_SEGMEXEC
113755+ if (!err && area_m)
113756+ err = vma_adjust(area_m, addr_m, next_m->vm_end,
113757+ next_m->vm_pgoff - pglen, NULL);
113758+#endif
113759+
113760+ }
113761 if (err)
113762 return NULL;
113763 khugepaged_enter_vma_merge(area, vm_flags);
113764@@ -1199,8 +1286,10 @@ none:
113765 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
113766 struct file *file, long pages)
113767 {
113768- const unsigned long stack_flags
113769- = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
113770+
113771+#ifdef CONFIG_PAX_RANDMMAP
113772+ if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
113773+#endif
113774
113775 mm->total_vm += pages;
113776
113777@@ -1208,7 +1297,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
113778 mm->shared_vm += pages;
113779 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
113780 mm->exec_vm += pages;
113781- } else if (flags & stack_flags)
113782+ } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
113783 mm->stack_vm += pages;
113784 }
113785 #endif /* CONFIG_PROC_FS */
113786@@ -1238,6 +1327,7 @@ static inline int mlock_future_check(struct mm_struct *mm,
113787 locked += mm->locked_vm;
113788 lock_limit = rlimit(RLIMIT_MEMLOCK);
113789 lock_limit >>= PAGE_SHIFT;
113790+ gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
113791 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
113792 return -EAGAIN;
113793 }
113794@@ -1267,7 +1357,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
113795 * (the exception is when the underlying filesystem is noexec
113796 * mounted, in which case we dont add PROT_EXEC.)
113797 */
113798- if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
113799+ if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
113800 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
113801 prot |= PROT_EXEC;
113802
113803@@ -1290,7 +1380,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
113804 /* Obtain the address to map to. we verify (or select) it and ensure
113805 * that it represents a valid section of the address space.
113806 */
113807- addr = get_unmapped_area(file, addr, len, pgoff, flags);
113808+ addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
113809 if (addr & ~PAGE_MASK)
113810 return addr;
113811
113812@@ -1301,6 +1391,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
113813 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
113814 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
113815
113816+#ifdef CONFIG_PAX_MPROTECT
113817+ if (mm->pax_flags & MF_PAX_MPROTECT) {
113818+
113819+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
113820+ if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
113821+ mm->binfmt->handle_mmap)
113822+ mm->binfmt->handle_mmap(file);
113823+#endif
113824+
113825+#ifndef CONFIG_PAX_MPROTECT_COMPAT
113826+ if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
113827+ gr_log_rwxmmap(file);
113828+
113829+#ifdef CONFIG_PAX_EMUPLT
113830+ vm_flags &= ~VM_EXEC;
113831+#else
113832+ return -EPERM;
113833+#endif
113834+
113835+ }
113836+
113837+ if (!(vm_flags & VM_EXEC))
113838+ vm_flags &= ~VM_MAYEXEC;
113839+#else
113840+ if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
113841+ vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
113842+#endif
113843+ else
113844+ vm_flags &= ~VM_MAYWRITE;
113845+ }
113846+#endif
113847+
113848+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
113849+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
113850+ vm_flags &= ~VM_PAGEEXEC;
113851+#endif
113852+
113853 if (flags & MAP_LOCKED)
113854 if (!can_do_mlock())
113855 return -EPERM;
113856@@ -1388,6 +1515,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
113857 vm_flags |= VM_NORESERVE;
113858 }
113859
113860+ if (!gr_acl_handle_mmap(file, prot))
113861+ return -EACCES;
113862+
113863 addr = mmap_region(file, addr, len, vm_flags, pgoff);
113864 if (!IS_ERR_VALUE(addr) &&
113865 ((vm_flags & VM_LOCKED) ||
113866@@ -1481,7 +1611,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
113867 vm_flags_t vm_flags = vma->vm_flags;
113868
113869 /* If it was private or non-writable, the write bit is already clear */
113870- if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
113871+ if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
113872 return 0;
113873
113874 /* The backer wishes to know when pages are first written to? */
113875@@ -1532,7 +1662,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113876 struct rb_node **rb_link, *rb_parent;
113877 unsigned long charged = 0;
113878
113879+#ifdef CONFIG_PAX_SEGMEXEC
113880+ struct vm_area_struct *vma_m = NULL;
113881+#endif
113882+
113883+ /*
113884+ * mm->mmap_sem is required to protect against another thread
113885+ * changing the mappings in case we sleep.
113886+ */
113887+ verify_mm_writelocked(mm);
113888+
113889 /* Check against address space limit. */
113890+
113891+#ifdef CONFIG_PAX_RANDMMAP
113892+ if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
113893+#endif
113894+
113895 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
113896 unsigned long nr_pages;
113897
113898@@ -1555,6 +1700,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113899 &rb_parent)) {
113900 if (do_munmap(mm, addr, len))
113901 return -ENOMEM;
113902+ BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
113903 }
113904
113905 /*
113906@@ -1586,6 +1732,16 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113907 goto unacct_error;
113908 }
113909
113910+#ifdef CONFIG_PAX_SEGMEXEC
113911+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
113912+ vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
113913+ if (!vma_m) {
113914+ error = -ENOMEM;
113915+ goto free_vma;
113916+ }
113917+ }
113918+#endif
113919+
113920 vma->vm_mm = mm;
113921 vma->vm_start = addr;
113922 vma->vm_end = addr + len;
113923@@ -1616,6 +1772,13 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113924 if (error)
113925 goto unmap_and_free_vma;
113926
113927+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
113928+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
113929+ vma->vm_flags |= VM_PAGEEXEC;
113930+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
113931+ }
113932+#endif
113933+
113934 /* Can addr have changed??
113935 *
113936 * Answer: Yes, several device drivers can do it in their
113937@@ -1634,6 +1797,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113938 }
113939
113940 vma_link(mm, vma, prev, rb_link, rb_parent);
113941+
113942+#ifdef CONFIG_PAX_SEGMEXEC
113943+ if (vma_m)
113944+ BUG_ON(pax_mirror_vma(vma_m, vma));
113945+#endif
113946+
113947 /* Once vma denies write, undo our temporary denial count */
113948 if (file) {
113949 if (vm_flags & VM_SHARED)
113950@@ -1646,6 +1815,7 @@ out:
113951 perf_event_mmap(vma);
113952
113953 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
113954+ track_exec_limit(mm, addr, addr + len, vm_flags);
113955 if (vm_flags & VM_LOCKED) {
113956 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
113957 vma == get_gate_vma(current->mm)))
113958@@ -1683,6 +1853,12 @@ allow_write_and_free_vma:
113959 if (vm_flags & VM_DENYWRITE)
113960 allow_write_access(file);
113961 free_vma:
113962+
113963+#ifdef CONFIG_PAX_SEGMEXEC
113964+ if (vma_m)
113965+ kmem_cache_free(vm_area_cachep, vma_m);
113966+#endif
113967+
113968 kmem_cache_free(vm_area_cachep, vma);
113969 unacct_error:
113970 if (charged)
113971@@ -1690,7 +1866,63 @@ unacct_error:
113972 return error;
113973 }
113974
113975-unsigned long unmapped_area(struct vm_unmapped_area_info *info)
113976+#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
113977+unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
113978+{
113979+ if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
113980+ return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
113981+
113982+ return 0;
113983+}
113984+#endif
113985+
113986+bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
113987+{
113988+ if (!vma) {
113989+#ifdef CONFIG_STACK_GROWSUP
113990+ if (addr > sysctl_heap_stack_gap)
113991+ vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
113992+ else
113993+ vma = find_vma(current->mm, 0);
113994+ if (vma && (vma->vm_flags & VM_GROWSUP))
113995+ return false;
113996+#endif
113997+ return true;
113998+ }
113999+
114000+ if (addr + len > vma->vm_start)
114001+ return false;
114002+
114003+ if (vma->vm_flags & VM_GROWSDOWN)
114004+ return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
114005+#ifdef CONFIG_STACK_GROWSUP
114006+ else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
114007+ return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
114008+#endif
114009+ else if (offset)
114010+ return offset <= vma->vm_start - addr - len;
114011+
114012+ return true;
114013+}
114014+
114015+unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
114016+{
114017+ if (vma->vm_start < len)
114018+ return -ENOMEM;
114019+
114020+ if (!(vma->vm_flags & VM_GROWSDOWN)) {
114021+ if (offset <= vma->vm_start - len)
114022+ return vma->vm_start - len - offset;
114023+ else
114024+ return -ENOMEM;
114025+ }
114026+
114027+ if (sysctl_heap_stack_gap <= vma->vm_start - len)
114028+ return vma->vm_start - len - sysctl_heap_stack_gap;
114029+ return -ENOMEM;
114030+}
114031+
114032+unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
114033 {
114034 /*
114035 * We implement the search by looking for an rbtree node that
114036@@ -1738,11 +1970,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
114037 }
114038 }
114039
114040- gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
114041+ gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
114042 check_current:
114043 /* Check if current node has a suitable gap */
114044 if (gap_start > high_limit)
114045 return -ENOMEM;
114046+
114047+ if (gap_end - gap_start > info->threadstack_offset)
114048+ gap_start += info->threadstack_offset;
114049+ else
114050+ gap_start = gap_end;
114051+
114052+ if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
114053+ if (gap_end - gap_start > sysctl_heap_stack_gap)
114054+ gap_start += sysctl_heap_stack_gap;
114055+ else
114056+ gap_start = gap_end;
114057+ }
114058+ if (vma->vm_flags & VM_GROWSDOWN) {
114059+ if (gap_end - gap_start > sysctl_heap_stack_gap)
114060+ gap_end -= sysctl_heap_stack_gap;
114061+ else
114062+ gap_end = gap_start;
114063+ }
114064 if (gap_end >= low_limit && gap_end - gap_start >= length)
114065 goto found;
114066
114067@@ -1792,7 +2042,7 @@ found:
114068 return gap_start;
114069 }
114070
114071-unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
114072+unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
114073 {
114074 struct mm_struct *mm = current->mm;
114075 struct vm_area_struct *vma;
114076@@ -1846,6 +2096,24 @@ check_current:
114077 gap_end = vma->vm_start;
114078 if (gap_end < low_limit)
114079 return -ENOMEM;
114080+
114081+ if (gap_end - gap_start > info->threadstack_offset)
114082+ gap_end -= info->threadstack_offset;
114083+ else
114084+ gap_end = gap_start;
114085+
114086+ if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
114087+ if (gap_end - gap_start > sysctl_heap_stack_gap)
114088+ gap_start += sysctl_heap_stack_gap;
114089+ else
114090+ gap_start = gap_end;
114091+ }
114092+ if (vma->vm_flags & VM_GROWSDOWN) {
114093+ if (gap_end - gap_start > sysctl_heap_stack_gap)
114094+ gap_end -= sysctl_heap_stack_gap;
114095+ else
114096+ gap_end = gap_start;
114097+ }
114098 if (gap_start <= high_limit && gap_end - gap_start >= length)
114099 goto found;
114100
114101@@ -1909,6 +2177,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
114102 struct mm_struct *mm = current->mm;
114103 struct vm_area_struct *vma;
114104 struct vm_unmapped_area_info info;
114105+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
114106
114107 if (len > TASK_SIZE - mmap_min_addr)
114108 return -ENOMEM;
114109@@ -1916,11 +2185,15 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
114110 if (flags & MAP_FIXED)
114111 return addr;
114112
114113+#ifdef CONFIG_PAX_RANDMMAP
114114+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
114115+#endif
114116+
114117 if (addr) {
114118 addr = PAGE_ALIGN(addr);
114119 vma = find_vma(mm, addr);
114120 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
114121- (!vma || addr + len <= vma->vm_start))
114122+ check_heap_stack_gap(vma, addr, len, offset))
114123 return addr;
114124 }
114125
114126@@ -1929,6 +2202,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
114127 info.low_limit = mm->mmap_base;
114128 info.high_limit = TASK_SIZE;
114129 info.align_mask = 0;
114130+ info.threadstack_offset = offset;
114131 return vm_unmapped_area(&info);
114132 }
114133 #endif
114134@@ -1947,6 +2221,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
114135 struct mm_struct *mm = current->mm;
114136 unsigned long addr = addr0;
114137 struct vm_unmapped_area_info info;
114138+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
114139
114140 /* requested length too big for entire address space */
114141 if (len > TASK_SIZE - mmap_min_addr)
114142@@ -1955,12 +2230,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
114143 if (flags & MAP_FIXED)
114144 return addr;
114145
114146+#ifdef CONFIG_PAX_RANDMMAP
114147+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
114148+#endif
114149+
114150 /* requesting a specific address */
114151 if (addr) {
114152 addr = PAGE_ALIGN(addr);
114153 vma = find_vma(mm, addr);
114154 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
114155- (!vma || addr + len <= vma->vm_start))
114156+ check_heap_stack_gap(vma, addr, len, offset))
114157 return addr;
114158 }
114159
114160@@ -1969,6 +2248,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
114161 info.low_limit = max(PAGE_SIZE, mmap_min_addr);
114162 info.high_limit = mm->mmap_base;
114163 info.align_mask = 0;
114164+ info.threadstack_offset = offset;
114165 addr = vm_unmapped_area(&info);
114166
114167 /*
114168@@ -1981,6 +2261,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
114169 VM_BUG_ON(addr != -ENOMEM);
114170 info.flags = 0;
114171 info.low_limit = TASK_UNMAPPED_BASE;
114172+
114173+#ifdef CONFIG_PAX_RANDMMAP
114174+ if (mm->pax_flags & MF_PAX_RANDMMAP)
114175+ info.low_limit += mm->delta_mmap;
114176+#endif
114177+
114178 info.high_limit = TASK_SIZE;
114179 addr = vm_unmapped_area(&info);
114180 }
114181@@ -2081,6 +2367,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
114182 return vma;
114183 }
114184
114185+#ifdef CONFIG_PAX_SEGMEXEC
114186+struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
114187+{
114188+ struct vm_area_struct *vma_m;
114189+
114190+ BUG_ON(!vma || vma->vm_start >= vma->vm_end);
114191+ if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
114192+ BUG_ON(vma->vm_mirror);
114193+ return NULL;
114194+ }
114195+ BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
114196+ vma_m = vma->vm_mirror;
114197+ BUG_ON(!vma_m || vma_m->vm_mirror != vma);
114198+ BUG_ON(vma->vm_file != vma_m->vm_file);
114199+ BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
114200+ BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
114201+ BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
114202+ BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
114203+ return vma_m;
114204+}
114205+#endif
114206+
114207 /*
114208 * Verify that the stack growth is acceptable and
114209 * update accounting. This is shared with both the
114210@@ -2098,8 +2406,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
114211
114212 /* Stack limit test */
114213 actual_size = size;
114214- if (size && (vma->vm_flags & (VM_GROWSUP | VM_GROWSDOWN)))
114215- actual_size -= PAGE_SIZE;
114216+ gr_learn_resource(current, RLIMIT_STACK, actual_size, 1);
114217 if (actual_size > READ_ONCE(rlim[RLIMIT_STACK].rlim_cur))
114218 return -ENOMEM;
114219
114220@@ -2110,6 +2417,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
114221 locked = mm->locked_vm + grow;
114222 limit = READ_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
114223 limit >>= PAGE_SHIFT;
114224+ gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
114225 if (locked > limit && !capable(CAP_IPC_LOCK))
114226 return -ENOMEM;
114227 }
114228@@ -2139,37 +2447,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
114229 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
114230 * vma is the last one with address > vma->vm_end. Have to extend vma.
114231 */
114232+#ifndef CONFIG_IA64
114233+static
114234+#endif
114235 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
114236 {
114237 int error;
114238+ bool locknext;
114239
114240 if (!(vma->vm_flags & VM_GROWSUP))
114241 return -EFAULT;
114242
114243+ /* Also guard against wrapping around to address 0. */
114244+ if (address < PAGE_ALIGN(address+1))
114245+ address = PAGE_ALIGN(address+1);
114246+ else
114247+ return -ENOMEM;
114248+
114249 /*
114250 * We must make sure the anon_vma is allocated
114251 * so that the anon_vma locking is not a noop.
114252 */
114253 if (unlikely(anon_vma_prepare(vma)))
114254 return -ENOMEM;
114255+ locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
114256+ if (locknext && anon_vma_prepare(vma->vm_next))
114257+ return -ENOMEM;
114258 vma_lock_anon_vma(vma);
114259+ if (locknext)
114260+ vma_lock_anon_vma(vma->vm_next);
114261
114262 /*
114263 * vma->vm_start/vm_end cannot change under us because the caller
114264 * is required to hold the mmap_sem in read mode. We need the
114265- * anon_vma lock to serialize against concurrent expand_stacks.
114266- * Also guard against wrapping around to address 0.
114267+ * anon_vma locks to serialize against concurrent expand_stacks
114268+ * and expand_upwards.
114269 */
114270- if (address < PAGE_ALIGN(address+4))
114271- address = PAGE_ALIGN(address+4);
114272- else {
114273- vma_unlock_anon_vma(vma);
114274- return -ENOMEM;
114275- }
114276 error = 0;
114277
114278 /* Somebody else might have raced and expanded it already */
114279- if (address > vma->vm_end) {
114280+ 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)
114281+ error = -ENOMEM;
114282+ else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
114283 unsigned long size, grow;
114284
114285 size = address - vma->vm_start;
114286@@ -2204,6 +2523,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
114287 }
114288 }
114289 }
114290+ if (locknext)
114291+ vma_unlock_anon_vma(vma->vm_next);
114292 vma_unlock_anon_vma(vma);
114293 khugepaged_enter_vma_merge(vma, vma->vm_flags);
114294 validate_mm(vma->vm_mm);
114295@@ -2218,6 +2539,8 @@ int expand_downwards(struct vm_area_struct *vma,
114296 unsigned long address)
114297 {
114298 int error;
114299+ bool lockprev = false;
114300+ struct vm_area_struct *prev;
114301
114302 /*
114303 * We must make sure the anon_vma is allocated
114304@@ -2231,6 +2554,15 @@ int expand_downwards(struct vm_area_struct *vma,
114305 if (error)
114306 return error;
114307
114308+ prev = vma->vm_prev;
114309+#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
114310+ lockprev = prev && (prev->vm_flags & VM_GROWSUP);
114311+#endif
114312+ if (lockprev && anon_vma_prepare(prev))
114313+ return -ENOMEM;
114314+ if (lockprev)
114315+ vma_lock_anon_vma(prev);
114316+
114317 vma_lock_anon_vma(vma);
114318
114319 /*
114320@@ -2240,9 +2572,17 @@ int expand_downwards(struct vm_area_struct *vma,
114321 */
114322
114323 /* Somebody else might have raced and expanded it already */
114324- if (address < vma->vm_start) {
114325+ if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
114326+ error = -ENOMEM;
114327+ else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
114328 unsigned long size, grow;
114329
114330+#ifdef CONFIG_PAX_SEGMEXEC
114331+ struct vm_area_struct *vma_m;
114332+
114333+ vma_m = pax_find_mirror_vma(vma);
114334+#endif
114335+
114336 size = vma->vm_end - address;
114337 grow = (vma->vm_start - address) >> PAGE_SHIFT;
114338
114339@@ -2267,13 +2607,27 @@ int expand_downwards(struct vm_area_struct *vma,
114340 vma->vm_pgoff -= grow;
114341 anon_vma_interval_tree_post_update_vma(vma);
114342 vma_gap_update(vma);
114343+
114344+#ifdef CONFIG_PAX_SEGMEXEC
114345+ if (vma_m) {
114346+ anon_vma_interval_tree_pre_update_vma(vma_m);
114347+ vma_m->vm_start -= grow << PAGE_SHIFT;
114348+ vma_m->vm_pgoff -= grow;
114349+ anon_vma_interval_tree_post_update_vma(vma_m);
114350+ vma_gap_update(vma_m);
114351+ }
114352+#endif
114353+
114354 spin_unlock(&vma->vm_mm->page_table_lock);
114355
114356+ track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
114357 perf_event_mmap(vma);
114358 }
114359 }
114360 }
114361 vma_unlock_anon_vma(vma);
114362+ if (lockprev)
114363+ vma_unlock_anon_vma(prev);
114364 khugepaged_enter_vma_merge(vma, vma->vm_flags);
114365 validate_mm(vma->vm_mm);
114366 return error;
114367@@ -2373,6 +2727,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
114368 do {
114369 long nrpages = vma_pages(vma);
114370
114371+#ifdef CONFIG_PAX_SEGMEXEC
114372+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
114373+ vma = remove_vma(vma);
114374+ continue;
114375+ }
114376+#endif
114377+
114378 if (vma->vm_flags & VM_ACCOUNT)
114379 nr_accounted += nrpages;
114380 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
114381@@ -2417,6 +2778,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
114382 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
114383 vma->vm_prev = NULL;
114384 do {
114385+
114386+#ifdef CONFIG_PAX_SEGMEXEC
114387+ if (vma->vm_mirror) {
114388+ BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
114389+ vma->vm_mirror->vm_mirror = NULL;
114390+ vma->vm_mirror->vm_flags &= ~VM_EXEC;
114391+ vma->vm_mirror = NULL;
114392+ }
114393+#endif
114394+
114395 vma_rb_erase(vma, &mm->mm_rb);
114396 mm->map_count--;
114397 tail_vma = vma;
114398@@ -2444,14 +2815,33 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114399 struct vm_area_struct *new;
114400 int err = -ENOMEM;
114401
114402+#ifdef CONFIG_PAX_SEGMEXEC
114403+ struct vm_area_struct *vma_m, *new_m = NULL;
114404+ unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
114405+#endif
114406+
114407 if (is_vm_hugetlb_page(vma) && (addr &
114408 ~(huge_page_mask(hstate_vma(vma)))))
114409 return -EINVAL;
114410
114411+#ifdef CONFIG_PAX_SEGMEXEC
114412+ vma_m = pax_find_mirror_vma(vma);
114413+#endif
114414+
114415 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
114416 if (!new)
114417 goto out_err;
114418
114419+#ifdef CONFIG_PAX_SEGMEXEC
114420+ if (vma_m) {
114421+ new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
114422+ if (!new_m) {
114423+ kmem_cache_free(vm_area_cachep, new);
114424+ goto out_err;
114425+ }
114426+ }
114427+#endif
114428+
114429 /* most fields are the same, copy all, and then fixup */
114430 *new = *vma;
114431
114432@@ -2464,6 +2854,22 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114433 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
114434 }
114435
114436+#ifdef CONFIG_PAX_SEGMEXEC
114437+ if (vma_m) {
114438+ *new_m = *vma_m;
114439+ INIT_LIST_HEAD(&new_m->anon_vma_chain);
114440+ new_m->vm_mirror = new;
114441+ new->vm_mirror = new_m;
114442+
114443+ if (new_below)
114444+ new_m->vm_end = addr_m;
114445+ else {
114446+ new_m->vm_start = addr_m;
114447+ new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
114448+ }
114449+ }
114450+#endif
114451+
114452 err = vma_dup_policy(vma, new);
114453 if (err)
114454 goto out_free_vma;
114455@@ -2484,6 +2890,38 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114456 else
114457 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
114458
114459+#ifdef CONFIG_PAX_SEGMEXEC
114460+ if (!err && vma_m) {
114461+ struct mempolicy *pol = vma_policy(new);
114462+
114463+ if (anon_vma_clone(new_m, vma_m))
114464+ goto out_free_mpol;
114465+
114466+ mpol_get(pol);
114467+ set_vma_policy(new_m, pol);
114468+
114469+ if (new_m->vm_file)
114470+ get_file(new_m->vm_file);
114471+
114472+ if (new_m->vm_ops && new_m->vm_ops->open)
114473+ new_m->vm_ops->open(new_m);
114474+
114475+ if (new_below)
114476+ err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
114477+ ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
114478+ else
114479+ err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
114480+
114481+ if (err) {
114482+ if (new_m->vm_ops && new_m->vm_ops->close)
114483+ new_m->vm_ops->close(new_m);
114484+ if (new_m->vm_file)
114485+ fput(new_m->vm_file);
114486+ mpol_put(pol);
114487+ }
114488+ }
114489+#endif
114490+
114491 /* Success. */
114492 if (!err)
114493 return 0;
114494@@ -2493,10 +2931,18 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114495 new->vm_ops->close(new);
114496 if (new->vm_file)
114497 fput(new->vm_file);
114498- unlink_anon_vmas(new);
114499 out_free_mpol:
114500 mpol_put(vma_policy(new));
114501 out_free_vma:
114502+
114503+#ifdef CONFIG_PAX_SEGMEXEC
114504+ if (new_m) {
114505+ unlink_anon_vmas(new_m);
114506+ kmem_cache_free(vm_area_cachep, new_m);
114507+ }
114508+#endif
114509+
114510+ unlink_anon_vmas(new);
114511 kmem_cache_free(vm_area_cachep, new);
114512 out_err:
114513 return err;
114514@@ -2509,6 +2955,15 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114515 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114516 unsigned long addr, int new_below)
114517 {
114518+
114519+#ifdef CONFIG_PAX_SEGMEXEC
114520+ if (mm->pax_flags & MF_PAX_SEGMEXEC) {
114521+ BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
114522+ if (mm->map_count >= sysctl_max_map_count-1)
114523+ return -ENOMEM;
114524+ } else
114525+#endif
114526+
114527 if (mm->map_count >= sysctl_max_map_count)
114528 return -ENOMEM;
114529
114530@@ -2520,11 +2975,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114531 * work. This now handles partial unmappings.
114532 * Jeremy Fitzhardinge <jeremy@goop.org>
114533 */
114534+#ifdef CONFIG_PAX_SEGMEXEC
114535 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
114536 {
114537+ int ret = __do_munmap(mm, start, len);
114538+ if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
114539+ return ret;
114540+
114541+ return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
114542+}
114543+
114544+int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
114545+#else
114546+int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
114547+#endif
114548+{
114549 unsigned long end;
114550 struct vm_area_struct *vma, *prev, *last;
114551
114552+ /*
114553+ * mm->mmap_sem is required to protect against another thread
114554+ * changing the mappings in case we sleep.
114555+ */
114556+ verify_mm_writelocked(mm);
114557+
114558 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
114559 return -EINVAL;
114560
114561@@ -2602,6 +3076,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
114562 /* Fix up all other VM information */
114563 remove_vma_list(mm, vma);
114564
114565+ track_exec_limit(mm, start, end, 0UL);
114566+
114567 return 0;
114568 }
114569
114570@@ -2610,6 +3086,13 @@ int vm_munmap(unsigned long start, size_t len)
114571 int ret;
114572 struct mm_struct *mm = current->mm;
114573
114574+
114575+#ifdef CONFIG_PAX_SEGMEXEC
114576+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
114577+ (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
114578+ return -EINVAL;
114579+#endif
114580+
114581 down_write(&mm->mmap_sem);
114582 ret = do_munmap(mm, start, len);
114583 up_write(&mm->mmap_sem);
114584@@ -2656,6 +3139,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
114585 down_write(&mm->mmap_sem);
114586 vma = find_vma(mm, start);
114587
114588+#ifdef CONFIG_PAX_SEGMEXEC
114589+ if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
114590+ goto out;
114591+#endif
114592+
114593 if (!vma || !(vma->vm_flags & VM_SHARED))
114594 goto out;
114595
114596@@ -2692,16 +3180,6 @@ out:
114597 return ret;
114598 }
114599
114600-static inline void verify_mm_writelocked(struct mm_struct *mm)
114601-{
114602-#ifdef CONFIG_DEBUG_VM
114603- if (unlikely(down_read_trylock(&mm->mmap_sem))) {
114604- WARN_ON(1);
114605- up_read(&mm->mmap_sem);
114606- }
114607-#endif
114608-}
114609-
114610 /*
114611 * this is really a simplified "do_mmap". it only handles
114612 * anonymous maps. eventually we may be able to do some
114613@@ -2715,6 +3193,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114614 struct rb_node **rb_link, *rb_parent;
114615 pgoff_t pgoff = addr >> PAGE_SHIFT;
114616 int error;
114617+ unsigned long charged;
114618
114619 len = PAGE_ALIGN(len);
114620 if (!len)
114621@@ -2722,10 +3201,24 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114622
114623 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
114624
114625+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
114626+ if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
114627+ flags &= ~VM_EXEC;
114628+
114629+#ifdef CONFIG_PAX_MPROTECT
114630+ if (mm->pax_flags & MF_PAX_MPROTECT)
114631+ flags &= ~VM_MAYEXEC;
114632+#endif
114633+
114634+ }
114635+#endif
114636+
114637 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
114638 if (error & ~PAGE_MASK)
114639 return error;
114640
114641+ charged = len >> PAGE_SHIFT;
114642+
114643 error = mlock_future_check(mm, mm->def_flags, len);
114644 if (error)
114645 return error;
114646@@ -2743,16 +3236,17 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114647 &rb_parent)) {
114648 if (do_munmap(mm, addr, len))
114649 return -ENOMEM;
114650+ BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
114651 }
114652
114653 /* Check against address space limits *after* clearing old maps... */
114654- if (!may_expand_vm(mm, len >> PAGE_SHIFT))
114655+ if (!may_expand_vm(mm, charged))
114656 return -ENOMEM;
114657
114658 if (mm->map_count > sysctl_max_map_count)
114659 return -ENOMEM;
114660
114661- if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
114662+ if (security_vm_enough_memory_mm(mm, charged))
114663 return -ENOMEM;
114664
114665 /* Can we just expand an old private anonymous mapping? */
114666@@ -2766,7 +3260,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114667 */
114668 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
114669 if (!vma) {
114670- vm_unacct_memory(len >> PAGE_SHIFT);
114671+ vm_unacct_memory(charged);
114672 return -ENOMEM;
114673 }
114674
114675@@ -2780,10 +3274,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114676 vma_link(mm, vma, prev, rb_link, rb_parent);
114677 out:
114678 perf_event_mmap(vma);
114679- mm->total_vm += len >> PAGE_SHIFT;
114680+ mm->total_vm += charged;
114681 if (flags & VM_LOCKED)
114682- mm->locked_vm += (len >> PAGE_SHIFT);
114683+ mm->locked_vm += charged;
114684 vma->vm_flags |= VM_SOFTDIRTY;
114685+ track_exec_limit(mm, addr, addr + len, flags);
114686 return addr;
114687 }
114688
114689@@ -2845,6 +3340,7 @@ void exit_mmap(struct mm_struct *mm)
114690 while (vma) {
114691 if (vma->vm_flags & VM_ACCOUNT)
114692 nr_accounted += vma_pages(vma);
114693+ vma->vm_mirror = NULL;
114694 vma = remove_vma(vma);
114695 }
114696 vm_unacct_memory(nr_accounted);
114697@@ -2859,6 +3355,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
114698 struct vm_area_struct *prev;
114699 struct rb_node **rb_link, *rb_parent;
114700
114701+#ifdef CONFIG_PAX_SEGMEXEC
114702+ struct vm_area_struct *vma_m = NULL;
114703+#endif
114704+
114705+ if (security_mmap_addr(vma->vm_start))
114706+ return -EPERM;
114707+
114708 /*
114709 * The vm_pgoff of a purely anonymous vma should be irrelevant
114710 * until its first write fault, when page's anon_vma and index
114711@@ -2882,7 +3385,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
114712 security_vm_enough_memory_mm(mm, vma_pages(vma)))
114713 return -ENOMEM;
114714
114715+#ifdef CONFIG_PAX_SEGMEXEC
114716+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
114717+ vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
114718+ if (!vma_m)
114719+ return -ENOMEM;
114720+ }
114721+#endif
114722+
114723 vma_link(mm, vma, prev, rb_link, rb_parent);
114724+
114725+#ifdef CONFIG_PAX_SEGMEXEC
114726+ if (vma_m)
114727+ BUG_ON(pax_mirror_vma(vma_m, vma));
114728+#endif
114729+
114730 return 0;
114731 }
114732
114733@@ -2901,6 +3418,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
114734 struct rb_node **rb_link, *rb_parent;
114735 bool faulted_in_anon_vma = true;
114736
114737+ BUG_ON(vma->vm_mirror);
114738+
114739 /*
114740 * If anonymous vma has not yet been faulted, update new pgoff
114741 * to match new location, to increase its chance of merging.
114742@@ -2965,6 +3484,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
114743 return NULL;
114744 }
114745
114746+#ifdef CONFIG_PAX_SEGMEXEC
114747+long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
114748+{
114749+ struct vm_area_struct *prev_m;
114750+ struct rb_node **rb_link_m, *rb_parent_m;
114751+ struct mempolicy *pol_m;
114752+
114753+ BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
114754+ BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
114755+ BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
114756+ *vma_m = *vma;
114757+ INIT_LIST_HEAD(&vma_m->anon_vma_chain);
114758+ if (anon_vma_clone(vma_m, vma))
114759+ return -ENOMEM;
114760+ pol_m = vma_policy(vma_m);
114761+ mpol_get(pol_m);
114762+ set_vma_policy(vma_m, pol_m);
114763+ vma_m->vm_start += SEGMEXEC_TASK_SIZE;
114764+ vma_m->vm_end += SEGMEXEC_TASK_SIZE;
114765+ vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
114766+ vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
114767+ if (vma_m->vm_file)
114768+ get_file(vma_m->vm_file);
114769+ if (vma_m->vm_ops && vma_m->vm_ops->open)
114770+ vma_m->vm_ops->open(vma_m);
114771+ BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
114772+ vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
114773+ vma_m->vm_mirror = vma;
114774+ vma->vm_mirror = vma_m;
114775+ return 0;
114776+}
114777+#endif
114778+
114779 /*
114780 * Return true if the calling process may expand its vm space by the passed
114781 * number of pages
114782@@ -2976,6 +3528,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
114783
114784 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
114785
114786+ gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
114787 if (cur + npages > lim)
114788 return 0;
114789 return 1;
114790@@ -3058,6 +3611,22 @@ static struct vm_area_struct *__install_special_mapping(
114791 vma->vm_start = addr;
114792 vma->vm_end = addr + len;
114793
114794+#ifdef CONFIG_PAX_MPROTECT
114795+ if (mm->pax_flags & MF_PAX_MPROTECT) {
114796+#ifndef CONFIG_PAX_MPROTECT_COMPAT
114797+ if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
114798+ return ERR_PTR(-EPERM);
114799+ if (!(vm_flags & VM_EXEC))
114800+ vm_flags &= ~VM_MAYEXEC;
114801+#else
114802+ if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
114803+ vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
114804+#endif
114805+ else
114806+ vm_flags &= ~VM_MAYWRITE;
114807+ }
114808+#endif
114809+
114810 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
114811 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
114812
114813diff --git a/mm/mprotect.c b/mm/mprotect.c
114814index e7d6f11..6116007 100644
114815--- a/mm/mprotect.c
114816+++ b/mm/mprotect.c
114817@@ -24,10 +24,18 @@
114818 #include <linux/migrate.h>
114819 #include <linux/perf_event.h>
114820 #include <linux/ksm.h>
114821+#include <linux/sched/sysctl.h>
114822+
114823+#ifdef CONFIG_PAX_MPROTECT
114824+#include <linux/elf.h>
114825+#include <linux/binfmts.h>
114826+#endif
114827+
114828 #include <asm/uaccess.h>
114829 #include <asm/pgtable.h>
114830 #include <asm/cacheflush.h>
114831 #include <asm/tlbflush.h>
114832+#include <asm/mmu_context.h>
114833
114834 #include "internal.h"
114835
114836@@ -254,6 +262,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
114837 return pages;
114838 }
114839
114840+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
114841+/* called while holding the mmap semaphor for writing except stack expansion */
114842+void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
114843+{
114844+ unsigned long oldlimit, newlimit = 0UL;
114845+
114846+ if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
114847+ return;
114848+
114849+ spin_lock(&mm->page_table_lock);
114850+ oldlimit = mm->context.user_cs_limit;
114851+ if ((prot & VM_EXEC) && oldlimit < end)
114852+ /* USER_CS limit moved up */
114853+ newlimit = end;
114854+ else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
114855+ /* USER_CS limit moved down */
114856+ newlimit = start;
114857+
114858+ if (newlimit) {
114859+ mm->context.user_cs_limit = newlimit;
114860+
114861+#ifdef CONFIG_SMP
114862+ wmb();
114863+ cpumask_clear(&mm->context.cpu_user_cs_mask);
114864+ cpumask_set_cpu(smp_processor_id(), &mm->context.cpu_user_cs_mask);
114865+#endif
114866+
114867+ set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
114868+ }
114869+ spin_unlock(&mm->page_table_lock);
114870+ if (newlimit == end) {
114871+ struct vm_area_struct *vma = find_vma(mm, oldlimit);
114872+
114873+ for (; vma && vma->vm_start < end; vma = vma->vm_next)
114874+ if (is_vm_hugetlb_page(vma))
114875+ hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
114876+ else
114877+ change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
114878+ }
114879+}
114880+#endif
114881+
114882 int
114883 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
114884 unsigned long start, unsigned long end, unsigned long newflags)
114885@@ -266,11 +316,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
114886 int error;
114887 int dirty_accountable = 0;
114888
114889+#ifdef CONFIG_PAX_SEGMEXEC
114890+ struct vm_area_struct *vma_m = NULL;
114891+ unsigned long start_m, end_m;
114892+
114893+ start_m = start + SEGMEXEC_TASK_SIZE;
114894+ end_m = end + SEGMEXEC_TASK_SIZE;
114895+#endif
114896+
114897 if (newflags == oldflags) {
114898 *pprev = vma;
114899 return 0;
114900 }
114901
114902+ if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
114903+ struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
114904+
114905+ if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
114906+ return -ENOMEM;
114907+
114908+ if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
114909+ return -ENOMEM;
114910+ }
114911+
114912 /*
114913 * If we make a private mapping writable we increase our commit;
114914 * but (without finer accounting) cannot reduce our commit if we
114915@@ -287,6 +355,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
114916 }
114917 }
114918
114919+#ifdef CONFIG_PAX_SEGMEXEC
114920+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
114921+ if (start != vma->vm_start) {
114922+ error = split_vma(mm, vma, start, 1);
114923+ if (error)
114924+ goto fail;
114925+ BUG_ON(!*pprev || (*pprev)->vm_next == vma);
114926+ *pprev = (*pprev)->vm_next;
114927+ }
114928+
114929+ if (end != vma->vm_end) {
114930+ error = split_vma(mm, vma, end, 0);
114931+ if (error)
114932+ goto fail;
114933+ }
114934+
114935+ if (pax_find_mirror_vma(vma)) {
114936+ error = __do_munmap(mm, start_m, end_m - start_m);
114937+ if (error)
114938+ goto fail;
114939+ } else {
114940+ vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
114941+ if (!vma_m) {
114942+ error = -ENOMEM;
114943+ goto fail;
114944+ }
114945+ vma->vm_flags = newflags;
114946+ error = pax_mirror_vma(vma_m, vma);
114947+ if (error) {
114948+ vma->vm_flags = oldflags;
114949+ goto fail;
114950+ }
114951+ }
114952+ }
114953+#endif
114954+
114955 /*
114956 * First try to merge with previous and/or next vma.
114957 */
114958@@ -317,7 +421,19 @@ success:
114959 * vm_flags and vm_page_prot are protected by the mmap_sem
114960 * held in write mode.
114961 */
114962+
114963+#ifdef CONFIG_PAX_SEGMEXEC
114964+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
114965+ pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
114966+#endif
114967+
114968 vma->vm_flags = newflags;
114969+
114970+#ifdef CONFIG_PAX_MPROTECT
114971+ if (mm->binfmt && mm->binfmt->handle_mprotect)
114972+ mm->binfmt->handle_mprotect(vma, newflags);
114973+#endif
114974+
114975 dirty_accountable = vma_wants_writenotify(vma);
114976 vma_set_page_prot(vma);
114977
114978@@ -362,6 +478,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
114979 end = start + len;
114980 if (end <= start)
114981 return -ENOMEM;
114982+
114983+#ifdef CONFIG_PAX_SEGMEXEC
114984+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
114985+ if (end > SEGMEXEC_TASK_SIZE)
114986+ return -EINVAL;
114987+ } else
114988+#endif
114989+
114990+ if (end > TASK_SIZE)
114991+ return -EINVAL;
114992+
114993 if (!arch_validate_prot(prot))
114994 return -EINVAL;
114995
114996@@ -369,7 +496,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
114997 /*
114998 * Does the application expect PROT_READ to imply PROT_EXEC:
114999 */
115000- if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
115001+ if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
115002 prot |= PROT_EXEC;
115003
115004 vm_flags = calc_vm_prot_bits(prot);
115005@@ -401,6 +528,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115006 if (start > vma->vm_start)
115007 prev = vma;
115008
115009+#ifdef CONFIG_PAX_MPROTECT
115010+ if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
115011+ current->mm->binfmt->handle_mprotect(vma, vm_flags);
115012+#endif
115013+
115014 for (nstart = start ; ; ) {
115015 unsigned long newflags;
115016
115017@@ -411,6 +543,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115018
115019 /* newflags >> 4 shift VM_MAY% in place of VM_% */
115020 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
115021+ if (prot & (PROT_WRITE | PROT_EXEC))
115022+ gr_log_rwxmprotect(vma);
115023+
115024+ error = -EACCES;
115025+ goto out;
115026+ }
115027+
115028+ if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
115029 error = -EACCES;
115030 goto out;
115031 }
115032@@ -425,6 +565,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115033 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
115034 if (error)
115035 goto out;
115036+
115037+ track_exec_limit(current->mm, nstart, tmp, vm_flags);
115038+
115039 nstart = tmp;
115040
115041 if (nstart < prev->vm_end)
115042diff --git a/mm/mremap.c b/mm/mremap.c
115043index a7c93ec..69c2949 100644
115044--- a/mm/mremap.c
115045+++ b/mm/mremap.c
115046@@ -143,6 +143,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
115047 continue;
115048 pte = ptep_get_and_clear(mm, old_addr, old_pte);
115049 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
115050+
115051+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
115052+ if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
115053+ pte = pte_exprotect(pte);
115054+#endif
115055+
115056 pte = move_soft_dirty_pte(pte);
115057 set_pte_at(mm, new_addr, new_pte, pte);
115058 }
115059@@ -355,6 +361,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
115060 if (is_vm_hugetlb_page(vma))
115061 return ERR_PTR(-EINVAL);
115062
115063+#ifdef CONFIG_PAX_SEGMEXEC
115064+ if (pax_find_mirror_vma(vma))
115065+ return ERR_PTR(-EINVAL);
115066+#endif
115067+
115068 /* We can't remap across vm area boundaries */
115069 if (old_len > vma->vm_end - addr)
115070 return ERR_PTR(-EFAULT);
115071@@ -401,20 +412,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
115072 unsigned long ret = -EINVAL;
115073 unsigned long charged = 0;
115074 unsigned long map_flags;
115075+ unsigned long pax_task_size = TASK_SIZE;
115076
115077 if (new_addr & ~PAGE_MASK)
115078 goto out;
115079
115080- if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
115081+#ifdef CONFIG_PAX_SEGMEXEC
115082+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
115083+ pax_task_size = SEGMEXEC_TASK_SIZE;
115084+#endif
115085+
115086+ pax_task_size -= PAGE_SIZE;
115087+
115088+ if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
115089 goto out;
115090
115091 /* Check if the location we're moving into overlaps the
115092 * old location at all, and fail if it does.
115093 */
115094- if ((new_addr <= addr) && (new_addr+new_len) > addr)
115095- goto out;
115096-
115097- if ((addr <= new_addr) && (addr+old_len) > new_addr)
115098+ if (addr + old_len > new_addr && new_addr + new_len > addr)
115099 goto out;
115100
115101 ret = do_munmap(mm, new_addr, new_len);
115102@@ -483,6 +499,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
115103 unsigned long ret = -EINVAL;
115104 unsigned long charged = 0;
115105 bool locked = false;
115106+ unsigned long pax_task_size = TASK_SIZE;
115107
115108 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
115109 return ret;
115110@@ -504,6 +521,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
115111 if (!new_len)
115112 return ret;
115113
115114+#ifdef CONFIG_PAX_SEGMEXEC
115115+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
115116+ pax_task_size = SEGMEXEC_TASK_SIZE;
115117+#endif
115118+
115119+ pax_task_size -= PAGE_SIZE;
115120+
115121+ if (new_len > pax_task_size || addr > pax_task_size-new_len ||
115122+ old_len > pax_task_size || addr > pax_task_size-old_len)
115123+ return ret;
115124+
115125 down_write(&current->mm->mmap_sem);
115126
115127 if (flags & MREMAP_FIXED) {
115128@@ -554,6 +582,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
115129 new_addr = addr;
115130 }
115131 ret = addr;
115132+ track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
115133 goto out;
115134 }
115135 }
115136@@ -577,7 +606,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
115137 goto out;
115138 }
115139
115140+ map_flags = vma->vm_flags;
115141 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
115142+ if (!(ret & ~PAGE_MASK)) {
115143+ track_exec_limit(current->mm, addr, addr + old_len, 0UL);
115144+ track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
115145+ }
115146 }
115147 out:
115148 if (ret & ~PAGE_MASK)
115149diff --git a/mm/nommu.c b/mm/nommu.c
115150index 58ea364..7b01d28 100644
115151--- a/mm/nommu.c
115152+++ b/mm/nommu.c
115153@@ -56,7 +56,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
115154 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
115155 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
115156 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
115157-int heap_stack_gap = 0;
115158
115159 atomic_long_t mmap_pages_allocated;
115160
115161@@ -863,15 +862,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
115162 EXPORT_SYMBOL(find_vma);
115163
115164 /*
115165- * find a VMA
115166- * - we don't extend stack VMAs under NOMMU conditions
115167- */
115168-struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
115169-{
115170- return find_vma(mm, addr);
115171-}
115172-
115173-/*
115174 * expand a stack to a given address
115175 * - not supported under NOMMU conditions
115176 */
115177@@ -1535,6 +1525,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
115178
115179 /* most fields are the same, copy all, and then fixup */
115180 *new = *vma;
115181+ INIT_LIST_HEAD(&new->anon_vma_chain);
115182 *region = *vma->vm_region;
115183 new->vm_region = region;
115184
115185@@ -1935,8 +1926,8 @@ void filemap_map_pages(struct vm_area_struct *vma, struct vm_fault *vmf)
115186 }
115187 EXPORT_SYMBOL(filemap_map_pages);
115188
115189-static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
115190- unsigned long addr, void *buf, int len, int write)
115191+static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
115192+ unsigned long addr, void *buf, size_t len, int write)
115193 {
115194 struct vm_area_struct *vma;
115195
115196@@ -1977,8 +1968,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
115197 *
115198 * The caller must hold a reference on @mm.
115199 */
115200-int access_remote_vm(struct mm_struct *mm, unsigned long addr,
115201- void *buf, int len, int write)
115202+ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
115203+ void *buf, size_t len, int write)
115204 {
115205 return __access_remote_vm(NULL, mm, addr, buf, len, write);
115206 }
115207@@ -1987,7 +1978,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
115208 * Access another process' address space.
115209 * - source/target buffer must be kernel space
115210 */
115211-int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
115212+ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
115213 {
115214 struct mm_struct *mm;
115215
115216diff --git a/mm/page-writeback.c b/mm/page-writeback.c
115217index 5cccc12..1872e56 100644
115218--- a/mm/page-writeback.c
115219+++ b/mm/page-writeback.c
115220@@ -852,7 +852,7 @@ static long long pos_ratio_polynom(unsigned long setpoint,
115221 * card's wb_dirty may rush to many times higher than wb_setpoint.
115222 * - the wb dirty thresh drops quickly due to change of JBOD workload
115223 */
115224-static void wb_position_ratio(struct dirty_throttle_control *dtc)
115225+static void __intentional_overflow(-1) wb_position_ratio(struct dirty_throttle_control *dtc)
115226 {
115227 struct bdi_writeback *wb = dtc->wb;
115228 unsigned long write_bw = wb->avg_write_bandwidth;
115229diff --git a/mm/page_alloc.c b/mm/page_alloc.c
115230index 5b5240b..2bc0996 100644
115231--- a/mm/page_alloc.c
115232+++ b/mm/page_alloc.c
115233@@ -62,6 +62,7 @@
115234 #include <linux/sched/rt.h>
115235 #include <linux/page_owner.h>
115236 #include <linux/kthread.h>
115237+#include <linux/random.h>
115238
115239 #include <asm/sections.h>
115240 #include <asm/tlbflush.h>
115241@@ -427,7 +428,7 @@ out:
115242 * This usage means that zero-order pages may not be compound.
115243 */
115244
115245-static void free_compound_page(struct page *page)
115246+void free_compound_page(struct page *page)
115247 {
115248 __free_pages_ok(page, compound_order(page));
115249 }
115250@@ -536,7 +537,7 @@ static inline void clear_page_guard(struct zone *zone, struct page *page,
115251 __mod_zone_freepage_state(zone, (1 << order), migratetype);
115252 }
115253 #else
115254-struct page_ext_operations debug_guardpage_ops = { NULL, };
115255+struct page_ext_operations debug_guardpage_ops = { .need = NULL, .init = NULL };
115256 static inline void set_page_guard(struct zone *zone, struct page *page,
115257 unsigned int order, int migratetype) {}
115258 static inline void clear_page_guard(struct zone *zone, struct page *page,
115259@@ -908,6 +909,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
115260 bool compound = PageCompound(page);
115261 int i, bad = 0;
115262
115263+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115264+ unsigned long index = 1UL << order;
115265+#endif
115266+
115267 VM_BUG_ON_PAGE(PageTail(page), page);
115268 VM_BUG_ON_PAGE(compound && compound_order(page) != order, page);
115269
115270@@ -934,6 +939,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
115271 debug_check_no_obj_freed(page_address(page),
115272 PAGE_SIZE << order);
115273 }
115274+
115275+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115276+ for (; index; --index)
115277+ sanitize_highpage(page + index - 1);
115278+#endif
115279+
115280 arch_free_page(page, order);
115281 kernel_map_pages(page, 1 << order, 0);
115282
115283@@ -957,6 +968,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
115284 local_irq_restore(flags);
115285 }
115286
115287+#ifdef CONFIG_PAX_LATENT_ENTROPY
115288+bool __meminitdata extra_latent_entropy;
115289+
115290+static int __init setup_pax_extra_latent_entropy(char *str)
115291+{
115292+ extra_latent_entropy = true;
115293+ return 0;
115294+}
115295+early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
115296+
115297+volatile u64 latent_entropy __latent_entropy;
115298+EXPORT_SYMBOL(latent_entropy);
115299+#endif
115300+
115301 static void __init __free_pages_boot_core(struct page *page,
115302 unsigned long pfn, unsigned int order)
115303 {
115304@@ -973,6 +998,19 @@ static void __init __free_pages_boot_core(struct page *page,
115305 __ClearPageReserved(p);
115306 set_page_count(p, 0);
115307
115308+#ifdef CONFIG_PAX_LATENT_ENTROPY
115309+ if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
115310+ u64 hash = 0;
115311+ size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
115312+ const u64 *data = lowmem_page_address(page);
115313+
115314+ for (index = 0; index < end; index++)
115315+ hash ^= hash + data[index];
115316+ latent_entropy ^= hash;
115317+ add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
115318+ }
115319+#endif
115320+
115321 page_zone(page)->managed_pages += nr_pages;
115322 set_page_refcounted(page);
115323 __free_pages(page, order);
115324@@ -1029,7 +1067,6 @@ static inline bool __meminit meminit_pfn_in_nid(unsigned long pfn, int node,
115325 }
115326 #endif
115327
115328-
115329 void __init __free_pages_bootmem(struct page *page, unsigned long pfn,
115330 unsigned int order)
115331 {
115332@@ -1333,9 +1370,11 @@ static int prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags,
115333 kernel_map_pages(page, 1 << order, 1);
115334 kasan_alloc_pages(page, order);
115335
115336+#ifndef CONFIG_PAX_MEMORY_SANITIZE
115337 if (gfp_flags & __GFP_ZERO)
115338 for (i = 0; i < (1 << order); i++)
115339 clear_highpage(page + i);
115340+#endif
115341
115342 if (order && (gfp_flags & __GFP_COMP))
115343 prep_compound_page(page, order);
115344@@ -2116,7 +2155,7 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
115345 }
115346
115347 __mod_zone_page_state(zone, NR_ALLOC_BATCH, -(1 << order));
115348- if (atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]) <= 0 &&
115349+ if (atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]) <= 0 &&
115350 !test_bit(ZONE_FAIR_DEPLETED, &zone->flags))
115351 set_bit(ZONE_FAIR_DEPLETED, &zone->flags);
115352
115353@@ -2435,7 +2474,7 @@ static void reset_alloc_batches(struct zone *preferred_zone)
115354 do {
115355 mod_zone_page_state(zone, NR_ALLOC_BATCH,
115356 high_wmark_pages(zone) - low_wmark_pages(zone) -
115357- atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]));
115358+ atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]));
115359 clear_bit(ZONE_FAIR_DEPLETED, &zone->flags);
115360 } while (zone++ != preferred_zone);
115361 }
115362@@ -6184,7 +6223,7 @@ static void __setup_per_zone_wmarks(void)
115363
115364 __mod_zone_page_state(zone, NR_ALLOC_BATCH,
115365 high_wmark_pages(zone) - low_wmark_pages(zone) -
115366- atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]));
115367+ atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]));
115368
115369 setup_zone_migrate_reserve(zone);
115370 spin_unlock_irqrestore(&zone->lock, flags);
115371diff --git a/mm/percpu.c b/mm/percpu.c
115372index 2dd7448..9bb6305 100644
115373--- a/mm/percpu.c
115374+++ b/mm/percpu.c
115375@@ -131,7 +131,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
115376 static unsigned int pcpu_high_unit_cpu __read_mostly;
115377
115378 /* the address of the first chunk which starts with the kernel static area */
115379-void *pcpu_base_addr __read_mostly;
115380+void *pcpu_base_addr __read_only;
115381 EXPORT_SYMBOL_GPL(pcpu_base_addr);
115382
115383 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
115384diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
115385index e88d071..d80e01a 100644
115386--- a/mm/process_vm_access.c
115387+++ b/mm/process_vm_access.c
115388@@ -13,6 +13,7 @@
115389 #include <linux/uio.h>
115390 #include <linux/sched.h>
115391 #include <linux/highmem.h>
115392+#include <linux/security.h>
115393 #include <linux/ptrace.h>
115394 #include <linux/slab.h>
115395 #include <linux/syscalls.h>
115396@@ -154,19 +155,19 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
115397 ssize_t iov_len;
115398 size_t total_len = iov_iter_count(iter);
115399
115400+ return -ENOSYS; // PaX: until properly audited
115401+
115402 /*
115403 * Work out how many pages of struct pages we're going to need
115404 * when eventually calling get_user_pages
115405 */
115406 for (i = 0; i < riovcnt; i++) {
115407 iov_len = rvec[i].iov_len;
115408- if (iov_len > 0) {
115409- nr_pages_iov = ((unsigned long)rvec[i].iov_base
115410- + iov_len)
115411- / PAGE_SIZE - (unsigned long)rvec[i].iov_base
115412- / PAGE_SIZE + 1;
115413- nr_pages = max(nr_pages, nr_pages_iov);
115414- }
115415+ if (iov_len <= 0)
115416+ continue;
115417+ nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
115418+ (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
115419+ nr_pages = max(nr_pages, nr_pages_iov);
115420 }
115421
115422 if (nr_pages == 0)
115423@@ -194,6 +195,11 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
115424 goto free_proc_pages;
115425 }
115426
115427+ if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
115428+ rc = -EPERM;
115429+ goto put_task_struct;
115430+ }
115431+
115432 mm = mm_access(task, PTRACE_MODE_ATTACH);
115433 if (!mm || IS_ERR(mm)) {
115434 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
115435diff --git a/mm/rmap.c b/mm/rmap.c
115436index 171b687..1a4b7e8 100644
115437--- a/mm/rmap.c
115438+++ b/mm/rmap.c
115439@@ -168,6 +168,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
115440 struct anon_vma *anon_vma = vma->anon_vma;
115441 struct anon_vma_chain *avc;
115442
115443+#ifdef CONFIG_PAX_SEGMEXEC
115444+ struct anon_vma_chain *avc_m = NULL;
115445+#endif
115446+
115447 might_sleep();
115448 if (unlikely(!anon_vma)) {
115449 struct mm_struct *mm = vma->vm_mm;
115450@@ -177,6 +181,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
115451 if (!avc)
115452 goto out_enomem;
115453
115454+#ifdef CONFIG_PAX_SEGMEXEC
115455+ avc_m = anon_vma_chain_alloc(GFP_KERNEL);
115456+ if (!avc_m)
115457+ goto out_enomem_free_avc;
115458+#endif
115459+
115460 anon_vma = find_mergeable_anon_vma(vma);
115461 allocated = NULL;
115462 if (!anon_vma) {
115463@@ -190,6 +200,19 @@ int anon_vma_prepare(struct vm_area_struct *vma)
115464 /* page_table_lock to protect against threads */
115465 spin_lock(&mm->page_table_lock);
115466 if (likely(!vma->anon_vma)) {
115467+
115468+#ifdef CONFIG_PAX_SEGMEXEC
115469+ struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
115470+
115471+ if (vma_m) {
115472+ BUG_ON(vma_m->anon_vma);
115473+ vma_m->anon_vma = anon_vma;
115474+ anon_vma_chain_link(vma_m, avc_m, anon_vma);
115475+ anon_vma->degree++;
115476+ avc_m = NULL;
115477+ }
115478+#endif
115479+
115480 vma->anon_vma = anon_vma;
115481 anon_vma_chain_link(vma, avc, anon_vma);
115482 /* vma reference or self-parent link for new root */
115483@@ -202,12 +225,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
115484
115485 if (unlikely(allocated))
115486 put_anon_vma(allocated);
115487+
115488+#ifdef CONFIG_PAX_SEGMEXEC
115489+ if (unlikely(avc_m))
115490+ anon_vma_chain_free(avc_m);
115491+#endif
115492+
115493 if (unlikely(avc))
115494 anon_vma_chain_free(avc);
115495 }
115496 return 0;
115497
115498 out_enomem_free_avc:
115499+
115500+#ifdef CONFIG_PAX_SEGMEXEC
115501+ if (avc_m)
115502+ anon_vma_chain_free(avc_m);
115503+#endif
115504+
115505 anon_vma_chain_free(avc);
115506 out_enomem:
115507 return -ENOMEM;
115508@@ -251,7 +286,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
115509 * good chance of avoiding scanning the whole hierarchy when it searches where
115510 * page is mapped.
115511 */
115512-int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
115513+int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
115514 {
115515 struct anon_vma_chain *avc, *pavc;
115516 struct anon_vma *root = NULL;
115517@@ -305,7 +340,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
115518 * the corresponding VMA in the parent process is attached to.
115519 * Returns 0 on success, non-zero on failure.
115520 */
115521-int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
115522+int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
115523 {
115524 struct anon_vma_chain *avc;
115525 struct anon_vma *anon_vma;
115526@@ -425,8 +460,10 @@ static void anon_vma_ctor(void *data)
115527 void __init anon_vma_init(void)
115528 {
115529 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
115530- 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
115531- anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
115532+ 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
115533+ anon_vma_ctor);
115534+ anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
115535+ SLAB_PANIC|SLAB_NO_SANITIZE);
115536 }
115537
115538 /*
115539diff --git a/mm/shmem.c b/mm/shmem.c
115540index dbe0c1e..22c16c7 100644
115541--- a/mm/shmem.c
115542+++ b/mm/shmem.c
115543@@ -33,7 +33,7 @@
115544 #include <linux/swap.h>
115545 #include <linux/uio.h>
115546
115547-static struct vfsmount *shm_mnt;
115548+struct vfsmount *shm_mnt;
115549
115550 #ifdef CONFIG_SHMEM
115551 /*
115552@@ -80,7 +80,7 @@ static struct vfsmount *shm_mnt;
115553 #define BOGO_DIRENT_SIZE 20
115554
115555 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
115556-#define SHORT_SYMLINK_LEN 128
115557+#define SHORT_SYMLINK_LEN 64
115558
115559 /*
115560 * shmem_fallocate communicates with shmem_fault or shmem_writepage via
115561@@ -2549,6 +2549,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
115562 static int shmem_xattr_validate(const char *name)
115563 {
115564 struct { const char *prefix; size_t len; } arr[] = {
115565+
115566+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
115567+ { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
115568+#endif
115569+
115570 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
115571 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
115572 };
115573@@ -2604,6 +2609,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
115574 if (err)
115575 return err;
115576
115577+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
115578+ if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
115579+ if (strcmp(name, XATTR_NAME_PAX_FLAGS))
115580+ return -EOPNOTSUPP;
115581+ if (size > 8)
115582+ return -EINVAL;
115583+ }
115584+#endif
115585+
115586 return simple_xattr_set(&info->xattrs, name, value, size, flags);
115587 }
115588
115589@@ -2987,8 +3001,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
115590 int err = -ENOMEM;
115591
115592 /* Round up to L1_CACHE_BYTES to resist false sharing */
115593- sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
115594- L1_CACHE_BYTES), GFP_KERNEL);
115595+ sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
115596 if (!sbinfo)
115597 return -ENOMEM;
115598
115599diff --git a/mm/slab.c b/mm/slab.c
115600index ae36028..eb6af9e 100644
115601--- a/mm/slab.c
115602+++ b/mm/slab.c
115603@@ -116,6 +116,7 @@
115604 #include <linux/kmemcheck.h>
115605 #include <linux/memory.h>
115606 #include <linux/prefetch.h>
115607+#include <linux/vmalloc.h>
115608
115609 #include <net/sock.h>
115610
115611@@ -314,10 +315,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
115612 if ((x)->max_freeable < i) \
115613 (x)->max_freeable = i; \
115614 } while (0)
115615-#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
115616-#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
115617-#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
115618-#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
115619+#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
115620+#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
115621+#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
115622+#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
115623+#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
115624+#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
115625 #else
115626 #define STATS_INC_ACTIVE(x) do { } while (0)
115627 #define STATS_DEC_ACTIVE(x) do { } while (0)
115628@@ -334,6 +337,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
115629 #define STATS_INC_ALLOCMISS(x) do { } while (0)
115630 #define STATS_INC_FREEHIT(x) do { } while (0)
115631 #define STATS_INC_FREEMISS(x) do { } while (0)
115632+#define STATS_INC_SANITIZED(x) do { } while (0)
115633+#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
115634 #endif
115635
115636 #if DEBUG
115637@@ -450,7 +455,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct page *page,
115638 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
115639 */
115640 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
115641- const struct page *page, void *obj)
115642+ const struct page *page, const void *obj)
115643 {
115644 u32 offset = (obj - page->s_mem);
115645 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
115646@@ -1452,7 +1457,7 @@ void __init kmem_cache_init(void)
115647 * structures first. Without this, further allocations will bug.
115648 */
115649 kmalloc_caches[INDEX_NODE] = create_kmalloc_cache("kmalloc-node",
115650- kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
115651+ kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
115652 slab_state = PARTIAL_NODE;
115653 setup_kmalloc_cache_index_table();
115654
115655@@ -2074,7 +2079,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
115656
115657 cachep = find_mergeable(size, align, flags, name, ctor);
115658 if (cachep) {
115659- cachep->refcount++;
115660+ atomic_inc(&cachep->refcount);
115661
115662 /*
115663 * Adjust the object sizes so that we clear
115664@@ -3379,6 +3384,20 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
115665 struct array_cache *ac = cpu_cache_get(cachep);
115666
115667 check_irq_off();
115668+
115669+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115670+ if (cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))
115671+ STATS_INC_NOT_SANITIZED(cachep);
115672+ else {
115673+ memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
115674+
115675+ if (cachep->ctor)
115676+ cachep->ctor(objp);
115677+
115678+ STATS_INC_SANITIZED(cachep);
115679+ }
115680+#endif
115681+
115682 kmemleak_free_recursive(objp, cachep->flags);
115683 objp = cache_free_debugcheck(cachep, objp, caller);
115684
115685@@ -3491,7 +3510,7 @@ __do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller)
115686 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
115687 }
115688
115689-void *__kmalloc_node(size_t size, gfp_t flags, int node)
115690+void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t flags, int node)
115691 {
115692 return __do_kmalloc_node(size, flags, node, _RET_IP_);
115693 }
115694@@ -3511,7 +3530,7 @@ EXPORT_SYMBOL(__kmalloc_node_track_caller);
115695 * @flags: the type of memory to allocate (see kmalloc).
115696 * @caller: function caller for debug tracking of the caller
115697 */
115698-static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,
115699+static __always_inline void * __size_overflow(1) __do_kmalloc(size_t size, gfp_t flags,
115700 unsigned long caller)
115701 {
115702 struct kmem_cache *cachep;
115703@@ -3584,6 +3603,7 @@ void kfree(const void *objp)
115704
115705 if (unlikely(ZERO_OR_NULL_PTR(objp)))
115706 return;
115707+ VM_BUG_ON(!virt_addr_valid(objp));
115708 local_irq_save(flags);
115709 kfree_debugcheck(objp);
115710 c = virt_to_cache(objp);
115711@@ -4003,14 +4023,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
115712 }
115713 /* cpu stats */
115714 {
115715- unsigned long allochit = atomic_read(&cachep->allochit);
115716- unsigned long allocmiss = atomic_read(&cachep->allocmiss);
115717- unsigned long freehit = atomic_read(&cachep->freehit);
115718- unsigned long freemiss = atomic_read(&cachep->freemiss);
115719+ unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
115720+ unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
115721+ unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
115722+ unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
115723
115724 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
115725 allochit, allocmiss, freehit, freemiss);
115726 }
115727+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115728+ {
115729+ unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
115730+ unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
115731+
115732+ seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
115733+ }
115734+#endif
115735 #endif
115736 }
115737
115738@@ -4218,13 +4246,80 @@ static const struct file_operations proc_slabstats_operations = {
115739 static int __init slab_proc_init(void)
115740 {
115741 #ifdef CONFIG_DEBUG_SLAB_LEAK
115742- proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
115743+ proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
115744 #endif
115745 return 0;
115746 }
115747 module_init(slab_proc_init);
115748 #endif
115749
115750+bool is_usercopy_object(const void *ptr)
115751+{
115752+ struct page *page;
115753+ struct kmem_cache *cachep;
115754+
115755+ if (ZERO_OR_NULL_PTR(ptr))
115756+ return false;
115757+
115758+ if (!slab_is_available())
115759+ return false;
115760+
115761+ if (is_vmalloc_addr(ptr)
115762+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
115763+ && !object_starts_on_stack(ptr)
115764+#endif
115765+ ) {
115766+ struct vm_struct *vm = find_vm_area(ptr);
115767+ if (vm && (vm->flags & VM_USERCOPY))
115768+ return true;
115769+ return false;
115770+ }
115771+
115772+ if (!virt_addr_valid(ptr))
115773+ return false;
115774+
115775+ page = virt_to_head_page(ptr);
115776+
115777+ if (!PageSlab(page))
115778+ return false;
115779+
115780+ cachep = page->slab_cache;
115781+ return cachep->flags & SLAB_USERCOPY;
115782+}
115783+
115784+#ifdef CONFIG_PAX_USERCOPY
115785+const char *check_heap_object(const void *ptr, unsigned long n)
115786+{
115787+ struct page *page;
115788+ struct kmem_cache *cachep;
115789+ unsigned int objnr;
115790+ unsigned long offset;
115791+
115792+ if (ZERO_OR_NULL_PTR(ptr))
115793+ return "<null>";
115794+
115795+ if (!virt_addr_valid(ptr))
115796+ return NULL;
115797+
115798+ page = virt_to_head_page(ptr);
115799+
115800+ if (!PageSlab(page))
115801+ return NULL;
115802+
115803+ cachep = page->slab_cache;
115804+ if (!(cachep->flags & SLAB_USERCOPY))
115805+ return cachep->name;
115806+
115807+ objnr = obj_to_index(cachep, page, ptr);
115808+ BUG_ON(objnr >= cachep->num);
115809+ offset = ptr - index_to_obj(cachep, page, objnr) - obj_offset(cachep);
115810+ if (offset <= cachep->object_size && n <= cachep->object_size - offset)
115811+ return NULL;
115812+
115813+ return cachep->name;
115814+}
115815+#endif
115816+
115817 /**
115818 * ksize - get the actual amount of memory allocated for a given object
115819 * @objp: Pointer to the object
115820diff --git a/mm/slab.h b/mm/slab.h
115821index 8da63e4..50c423b 100644
115822--- a/mm/slab.h
115823+++ b/mm/slab.h
115824@@ -22,7 +22,7 @@ struct kmem_cache {
115825 unsigned int align; /* Alignment as calculated */
115826 unsigned long flags; /* Active flags on the slab */
115827 const char *name; /* Slab name for sysfs */
115828- int refcount; /* Use counter */
115829+ atomic_t refcount; /* Use counter */
115830 void (*ctor)(void *); /* Called on object slot creation */
115831 struct list_head list; /* List of all slab caches on the system */
115832 };
115833@@ -66,6 +66,20 @@ extern struct list_head slab_caches;
115834 /* The slab cache that manages slab cache information */
115835 extern struct kmem_cache *kmem_cache;
115836
115837+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115838+#ifdef CONFIG_X86_64
115839+#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
115840+#else
115841+#define PAX_MEMORY_SANITIZE_VALUE '\xff'
115842+#endif
115843+enum pax_sanitize_mode {
115844+ PAX_SANITIZE_SLAB_OFF = 0,
115845+ PAX_SANITIZE_SLAB_FAST,
115846+ PAX_SANITIZE_SLAB_FULL,
115847+};
115848+extern enum pax_sanitize_mode pax_sanitize_slab;
115849+#endif
115850+
115851 unsigned long calculate_alignment(unsigned long flags,
115852 unsigned long align, unsigned long size);
115853
115854@@ -115,7 +129,8 @@ static inline unsigned long kmem_cache_flags(unsigned long object_size,
115855
115856 /* Legal flag mask for kmem_cache_create(), for various configurations */
115857 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
115858- SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
115859+ SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
115860+ SLAB_USERCOPY | SLAB_NO_SANITIZE)
115861
115862 #if defined(CONFIG_DEBUG_SLAB)
115863 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
115864@@ -316,6 +331,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
115865 return s;
115866
115867 page = virt_to_head_page(x);
115868+
115869+ BUG_ON(!PageSlab(page));
115870+
115871 cachep = page->slab_cache;
115872 if (slab_equal_or_root(cachep, s))
115873 return cachep;
115874diff --git a/mm/slab_common.c b/mm/slab_common.c
115875index 8683110..916e2c5 100644
115876--- a/mm/slab_common.c
115877+++ b/mm/slab_common.c
115878@@ -25,11 +25,35 @@
115879
115880 #include "slab.h"
115881
115882-enum slab_state slab_state;
115883+enum slab_state slab_state __read_only;
115884 LIST_HEAD(slab_caches);
115885 DEFINE_MUTEX(slab_mutex);
115886 struct kmem_cache *kmem_cache;
115887
115888+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115889+enum pax_sanitize_mode pax_sanitize_slab __read_only = PAX_SANITIZE_SLAB_FAST;
115890+static int __init pax_sanitize_slab_setup(char *str)
115891+{
115892+ if (!str)
115893+ return 0;
115894+
115895+ if (!strcmp(str, "0") || !strcmp(str, "off")) {
115896+ pr_info("PaX slab sanitization: %s\n", "disabled");
115897+ pax_sanitize_slab = PAX_SANITIZE_SLAB_OFF;
115898+ } else if (!strcmp(str, "1") || !strcmp(str, "fast")) {
115899+ pr_info("PaX slab sanitization: %s\n", "fast");
115900+ pax_sanitize_slab = PAX_SANITIZE_SLAB_FAST;
115901+ } else if (!strcmp(str, "full")) {
115902+ pr_info("PaX slab sanitization: %s\n", "full");
115903+ pax_sanitize_slab = PAX_SANITIZE_SLAB_FULL;
115904+ } else
115905+ pr_err("PaX slab sanitization: unsupported option '%s'\n", str);
115906+
115907+ return 0;
115908+}
115909+early_param("pax_sanitize_slab", pax_sanitize_slab_setup);
115910+#endif
115911+
115912 /*
115913 * Set of flags that will prevent slab merging
115914 */
115915@@ -43,7 +67,7 @@ struct kmem_cache *kmem_cache;
115916 * Merge control. If this is set then no merging of slab caches will occur.
115917 * (Could be removed. This was introduced to pacify the merge skeptics.)
115918 */
115919-static int slab_nomerge;
115920+static int slab_nomerge = 1;
115921
115922 static int __init setup_slab_nomerge(char *str)
115923 {
115924@@ -216,7 +240,7 @@ int slab_unmergeable(struct kmem_cache *s)
115925 /*
115926 * We may have set a slab to be unmergeable during bootstrap.
115927 */
115928- if (s->refcount < 0)
115929+ if (atomic_read(&s->refcount) < 0)
115930 return 1;
115931
115932 return 0;
115933@@ -320,7 +344,7 @@ do_kmem_cache_create(const char *name, size_t object_size, size_t size,
115934 if (err)
115935 goto out_free_cache;
115936
115937- s->refcount = 1;
115938+ atomic_set(&s->refcount, 1);
115939 list_add(&s->list, &slab_caches);
115940 out:
115941 if (err)
115942@@ -385,6 +409,13 @@ kmem_cache_create(const char *name, size_t size, size_t align,
115943 */
115944 flags &= CACHE_CREATE_MASK;
115945
115946+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115947+ if (pax_sanitize_slab == PAX_SANITIZE_SLAB_OFF || (flags & SLAB_DESTROY_BY_RCU))
115948+ flags |= SLAB_NO_SANITIZE;
115949+ else if (pax_sanitize_slab == PAX_SANITIZE_SLAB_FULL)
115950+ flags &= ~SLAB_NO_SANITIZE;
115951+#endif
115952+
115953 s = __kmem_cache_alias(name, size, align, flags, ctor);
115954 if (s)
115955 goto out_unlock;
115956@@ -455,7 +486,7 @@ static void do_kmem_cache_release(struct list_head *release,
115957 rcu_barrier();
115958
115959 list_for_each_entry_safe(s, s2, release, list) {
115960-#ifdef SLAB_SUPPORTS_SYSFS
115961+#if defined(SLAB_SUPPORTS_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
115962 sysfs_slab_remove(s);
115963 #else
115964 slab_kmem_cache_release(s);
115965@@ -624,8 +655,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
115966
115967 mutex_lock(&slab_mutex);
115968
115969- s->refcount--;
115970- if (s->refcount)
115971+ if (!atomic_dec_and_test(&s->refcount))
115972 goto out_unlock;
115973
115974 for_each_memcg_cache_safe(c, c2, s) {
115975@@ -690,7 +720,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
115976 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
115977 name, size, err);
115978
115979- s->refcount = -1; /* Exempt from merging for now */
115980+ atomic_set(&s->refcount, -1); /* Exempt from merging for now */
115981 }
115982
115983 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
115984@@ -703,7 +733,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
115985
115986 create_boot_cache(s, name, size, flags);
115987 list_add(&s->list, &slab_caches);
115988- s->refcount = 1;
115989+ atomic_set(&s->refcount, 1);
115990 return s;
115991 }
115992
115993@@ -715,6 +745,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
115994 EXPORT_SYMBOL(kmalloc_dma_caches);
115995 #endif
115996
115997+#ifdef CONFIG_PAX_USERCOPY_SLABS
115998+struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
115999+EXPORT_SYMBOL(kmalloc_usercopy_caches);
116000+#endif
116001+
116002 /*
116003 * Conversion table for small slabs sizes / 8 to the index in the
116004 * kmalloc array. This is necessary for slabs < 192 since we have non power
116005@@ -779,6 +814,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
116006 return kmalloc_dma_caches[index];
116007
116008 #endif
116009+
116010+#ifdef CONFIG_PAX_USERCOPY_SLABS
116011+ if (unlikely((flags & GFP_USERCOPY)))
116012+ return kmalloc_usercopy_caches[index];
116013+
116014+#endif
116015+
116016 return kmalloc_caches[index];
116017 }
116018
116019@@ -871,7 +913,7 @@ void __init create_kmalloc_caches(unsigned long flags)
116020
116021 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
116022 if (!kmalloc_caches[i])
116023- new_kmalloc_cache(i, flags);
116024+ new_kmalloc_cache(i, SLAB_USERCOPY | flags);
116025
116026 /*
116027 * Caches that are not of the two-to-the-power-of size.
116028@@ -879,9 +921,9 @@ void __init create_kmalloc_caches(unsigned long flags)
116029 * earlier power of two caches
116030 */
116031 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
116032- new_kmalloc_cache(1, flags);
116033+ new_kmalloc_cache(1, SLAB_USERCOPY | flags);
116034 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
116035- new_kmalloc_cache(2, flags);
116036+ new_kmalloc_cache(2, SLAB_USERCOPY | flags);
116037 }
116038
116039 /* Kmalloc array is now usable */
116040@@ -902,6 +944,23 @@ void __init create_kmalloc_caches(unsigned long flags)
116041 }
116042 }
116043 #endif
116044+
116045+#ifdef CONFIG_PAX_USERCOPY_SLABS
116046+ for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
116047+ struct kmem_cache *s = kmalloc_caches[i];
116048+
116049+ if (s) {
116050+ int size = kmalloc_size(i);
116051+ char *n = kasprintf(GFP_NOWAIT,
116052+ "usercopy-kmalloc-%d", size);
116053+
116054+ BUG_ON(!n);
116055+ kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
116056+ size, SLAB_USERCOPY | flags);
116057+ }
116058+ }
116059+#endif
116060+
116061 }
116062 #endif /* !CONFIG_SLOB */
116063
116064@@ -961,6 +1020,9 @@ static void print_slabinfo_header(struct seq_file *m)
116065 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
116066 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
116067 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
116068+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116069+ seq_puts(m, " : pax <sanitized> <not_sanitized>");
116070+#endif
116071 #endif
116072 seq_putc(m, '\n');
116073 }
116074@@ -1090,7 +1152,7 @@ static int __init slab_proc_init(void)
116075 module_init(slab_proc_init);
116076 #endif /* CONFIG_SLABINFO */
116077
116078-static __always_inline void *__do_krealloc(const void *p, size_t new_size,
116079+static __always_inline void * __size_overflow(2) __do_krealloc(const void *p, size_t new_size,
116080 gfp_t flags)
116081 {
116082 void *ret;
116083diff --git a/mm/slob.c b/mm/slob.c
116084index 4765f65..5dec45e 100644
116085--- a/mm/slob.c
116086+++ b/mm/slob.c
116087@@ -67,6 +67,7 @@
116088 #include <linux/rcupdate.h>
116089 #include <linux/list.h>
116090 #include <linux/kmemleak.h>
116091+#include <linux/vmalloc.h>
116092
116093 #include <trace/events/kmem.h>
116094
116095@@ -157,7 +158,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
116096 /*
116097 * Return the size of a slob block.
116098 */
116099-static slobidx_t slob_units(slob_t *s)
116100+static slobidx_t slob_units(const slob_t *s)
116101 {
116102 if (s->units > 0)
116103 return s->units;
116104@@ -167,7 +168,7 @@ static slobidx_t slob_units(slob_t *s)
116105 /*
116106 * Return the next free slob block pointer after this one.
116107 */
116108-static slob_t *slob_next(slob_t *s)
116109+static slob_t *slob_next(const slob_t *s)
116110 {
116111 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
116112 slobidx_t next;
116113@@ -182,14 +183,14 @@ static slob_t *slob_next(slob_t *s)
116114 /*
116115 * Returns true if s is the last free block in its page.
116116 */
116117-static int slob_last(slob_t *s)
116118+static int slob_last(const slob_t *s)
116119 {
116120 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
116121 }
116122
116123-static void *slob_new_pages(gfp_t gfp, int order, int node)
116124+static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
116125 {
116126- void *page;
116127+ struct page *page;
116128
116129 #ifdef CONFIG_NUMA
116130 if (node != NUMA_NO_NODE)
116131@@ -201,14 +202,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
116132 if (!page)
116133 return NULL;
116134
116135- return page_address(page);
116136+ __SetPageSlab(page);
116137+ return page;
116138 }
116139
116140-static void slob_free_pages(void *b, int order)
116141+static void slob_free_pages(struct page *sp, int order)
116142 {
116143 if (current->reclaim_state)
116144 current->reclaim_state->reclaimed_slab += 1 << order;
116145- free_pages((unsigned long)b, order);
116146+ __ClearPageSlab(sp);
116147+ page_mapcount_reset(sp);
116148+ sp->private = 0;
116149+ __free_pages(sp, order);
116150 }
116151
116152 /*
116153@@ -313,15 +318,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
116154
116155 /* Not enough space: must allocate a new page */
116156 if (!b) {
116157- b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
116158- if (!b)
116159+ sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
116160+ if (!sp)
116161 return NULL;
116162- sp = virt_to_page(b);
116163- __SetPageSlab(sp);
116164+ b = page_address(sp);
116165
116166 spin_lock_irqsave(&slob_lock, flags);
116167 sp->units = SLOB_UNITS(PAGE_SIZE);
116168 sp->freelist = b;
116169+ sp->private = 0;
116170 INIT_LIST_HEAD(&sp->lru);
116171 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
116172 set_slob_page_free(sp, slob_list);
116173@@ -337,7 +342,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
116174 /*
116175 * slob_free: entry point into the slob allocator.
116176 */
116177-static void slob_free(void *block, int size)
116178+static void slob_free(struct kmem_cache *c, void *block, int size)
116179 {
116180 struct page *sp;
116181 slob_t *prev, *next, *b = (slob_t *)block;
116182@@ -359,12 +364,15 @@ static void slob_free(void *block, int size)
116183 if (slob_page_free(sp))
116184 clear_slob_page_free(sp);
116185 spin_unlock_irqrestore(&slob_lock, flags);
116186- __ClearPageSlab(sp);
116187- page_mapcount_reset(sp);
116188- slob_free_pages(b, 0);
116189+ slob_free_pages(sp, 0);
116190 return;
116191 }
116192
116193+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116194+ if (pax_sanitize_slab && !(c && (c->flags & SLAB_NO_SANITIZE)))
116195+ memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
116196+#endif
116197+
116198 if (!slob_page_free(sp)) {
116199 /* This slob page is about to become partially free. Easy! */
116200 sp->units = units;
116201@@ -424,11 +432,10 @@ out:
116202 */
116203
116204 static __always_inline void *
116205-__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
116206+__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
116207 {
116208- unsigned int *m;
116209- int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
116210- void *ret;
116211+ slob_t *m;
116212+ void *ret = NULL;
116213
116214 gfp &= gfp_allowed_mask;
116215
116216@@ -442,27 +449,45 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
116217
116218 if (!m)
116219 return NULL;
116220- *m = size;
116221+ BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
116222+ BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
116223+ m[0].units = size;
116224+ m[1].units = align;
116225 ret = (void *)m + align;
116226
116227 trace_kmalloc_node(caller, ret,
116228 size, size + align, gfp, node);
116229 } else {
116230 unsigned int order = get_order(size);
116231+ struct page *page;
116232
116233 if (likely(order))
116234 gfp |= __GFP_COMP;
116235- ret = slob_new_pages(gfp, order, node);
116236+ page = slob_new_pages(gfp, order, node);
116237+ if (page) {
116238+ ret = page_address(page);
116239+ page->private = size;
116240+ }
116241
116242 trace_kmalloc_node(caller, ret,
116243 size, PAGE_SIZE << order, gfp, node);
116244 }
116245
116246- kmemleak_alloc(ret, size, 1, gfp);
116247 return ret;
116248 }
116249
116250-void *__kmalloc(size_t size, gfp_t gfp)
116251+static __always_inline void *
116252+__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
116253+{
116254+ int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
116255+ void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
116256+
116257+ if (!ZERO_OR_NULL_PTR(ret))
116258+ kmemleak_alloc(ret, size, 1, gfp);
116259+ return ret;
116260+}
116261+
116262+void * __size_overflow(1) __kmalloc(size_t size, gfp_t gfp)
116263 {
116264 return __do_kmalloc_node(size, gfp, NUMA_NO_NODE, _RET_IP_);
116265 }
116266@@ -491,34 +516,123 @@ void kfree(const void *block)
116267 return;
116268 kmemleak_free(block);
116269
116270+ VM_BUG_ON(!virt_addr_valid(block));
116271 sp = virt_to_page(block);
116272- if (PageSlab(sp)) {
116273+ VM_BUG_ON(!PageSlab(sp));
116274+ if (!sp->private) {
116275 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
116276- unsigned int *m = (unsigned int *)(block - align);
116277- slob_free(m, *m + align);
116278- } else
116279+ slob_t *m = (slob_t *)(block - align);
116280+ slob_free(NULL, m, m[0].units + align);
116281+ } else {
116282+ __ClearPageSlab(sp);
116283+ page_mapcount_reset(sp);
116284+ sp->private = 0;
116285 __free_pages(sp, compound_order(sp));
116286+ }
116287 }
116288 EXPORT_SYMBOL(kfree);
116289
116290+bool is_usercopy_object(const void *ptr)
116291+{
116292+ if (!slab_is_available())
116293+ return false;
116294+
116295+ if (is_vmalloc_addr(ptr)
116296+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116297+ && !object_starts_on_stack(ptr)
116298+#endif
116299+ ) {
116300+ struct vm_struct *vm = find_vm_area(ptr);
116301+ if (vm && (vm->flags & VM_USERCOPY))
116302+ return true;
116303+ return false;
116304+ }
116305+
116306+ // PAX: TODO
116307+
116308+ return false;
116309+}
116310+
116311+#ifdef CONFIG_PAX_USERCOPY
116312+const char *check_heap_object(const void *ptr, unsigned long n)
116313+{
116314+ struct page *page;
116315+ const slob_t *free;
116316+ const void *base;
116317+ unsigned long flags;
116318+
116319+ if (ZERO_OR_NULL_PTR(ptr))
116320+ return "<null>";
116321+
116322+ if (!virt_addr_valid(ptr))
116323+ return NULL;
116324+
116325+ page = virt_to_head_page(ptr);
116326+ if (!PageSlab(page))
116327+ return NULL;
116328+
116329+ if (page->private) {
116330+ base = page;
116331+ if (base <= ptr && n <= page->private - (ptr - base))
116332+ return NULL;
116333+ return "<slob>";
116334+ }
116335+
116336+ /* some tricky double walking to find the chunk */
116337+ spin_lock_irqsave(&slob_lock, flags);
116338+ base = (void *)((unsigned long)ptr & PAGE_MASK);
116339+ free = page->freelist;
116340+
116341+ while (!slob_last(free) && (void *)free <= ptr) {
116342+ base = free + slob_units(free);
116343+ free = slob_next(free);
116344+ }
116345+
116346+ while (base < (void *)free) {
116347+ slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
116348+ int size = SLOB_UNIT * SLOB_UNITS(m + align);
116349+ int offset;
116350+
116351+ if (ptr < base + align)
116352+ break;
116353+
116354+ offset = ptr - base - align;
116355+ if (offset >= m) {
116356+ base += size;
116357+ continue;
116358+ }
116359+
116360+ if (n > m - offset)
116361+ break;
116362+
116363+ spin_unlock_irqrestore(&slob_lock, flags);
116364+ return NULL;
116365+ }
116366+
116367+ spin_unlock_irqrestore(&slob_lock, flags);
116368+ return "<slob>";
116369+}
116370+#endif
116371+
116372 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
116373 size_t ksize(const void *block)
116374 {
116375 struct page *sp;
116376 int align;
116377- unsigned int *m;
116378+ slob_t *m;
116379
116380 BUG_ON(!block);
116381 if (unlikely(block == ZERO_SIZE_PTR))
116382 return 0;
116383
116384 sp = virt_to_page(block);
116385- if (unlikely(!PageSlab(sp)))
116386- return PAGE_SIZE << compound_order(sp);
116387+ VM_BUG_ON(!PageSlab(sp));
116388+ if (sp->private)
116389+ return sp->private;
116390
116391 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
116392- m = (unsigned int *)(block - align);
116393- return SLOB_UNITS(*m) * SLOB_UNIT;
116394+ m = (slob_t *)(block - align);
116395+ return SLOB_UNITS(m[0].units) * SLOB_UNIT;
116396 }
116397 EXPORT_SYMBOL(ksize);
116398
116399@@ -534,23 +648,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
116400
116401 static void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
116402 {
116403- void *b;
116404+ void *b = NULL;
116405
116406 flags &= gfp_allowed_mask;
116407
116408 lockdep_trace_alloc(flags);
116409
116410+#ifdef CONFIG_PAX_USERCOPY_SLABS
116411+ b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
116412+#else
116413 if (c->size < PAGE_SIZE) {
116414 b = slob_alloc(c->size, flags, c->align, node);
116415 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
116416 SLOB_UNITS(c->size) * SLOB_UNIT,
116417 flags, node);
116418 } else {
116419- b = slob_new_pages(flags, get_order(c->size), node);
116420+ struct page *sp;
116421+
116422+ sp = slob_new_pages(flags, get_order(c->size), node);
116423+ if (sp) {
116424+ b = page_address(sp);
116425+ sp->private = c->size;
116426+ }
116427 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
116428 PAGE_SIZE << get_order(c->size),
116429 flags, node);
116430 }
116431+#endif
116432
116433 if (b && c->ctor)
116434 c->ctor(b);
116435@@ -566,7 +690,7 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
116436 EXPORT_SYMBOL(kmem_cache_alloc);
116437
116438 #ifdef CONFIG_NUMA
116439-void *__kmalloc_node(size_t size, gfp_t gfp, int node)
116440+void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t gfp, int node)
116441 {
116442 return __do_kmalloc_node(size, gfp, node, _RET_IP_);
116443 }
116444@@ -579,12 +703,16 @@ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t gfp, int node)
116445 EXPORT_SYMBOL(kmem_cache_alloc_node);
116446 #endif
116447
116448-static void __kmem_cache_free(void *b, int size)
116449+static void __kmem_cache_free(struct kmem_cache *c, void *b, int size)
116450 {
116451- if (size < PAGE_SIZE)
116452- slob_free(b, size);
116453+ struct page *sp;
116454+
116455+ sp = virt_to_page(b);
116456+ BUG_ON(!PageSlab(sp));
116457+ if (!sp->private)
116458+ slob_free(c, b, size);
116459 else
116460- slob_free_pages(b, get_order(size));
116461+ slob_free_pages(sp, get_order(size));
116462 }
116463
116464 static void kmem_rcu_free(struct rcu_head *head)
116465@@ -592,22 +720,36 @@ static void kmem_rcu_free(struct rcu_head *head)
116466 struct slob_rcu *slob_rcu = (struct slob_rcu *)head;
116467 void *b = (void *)slob_rcu - (slob_rcu->size - sizeof(struct slob_rcu));
116468
116469- __kmem_cache_free(b, slob_rcu->size);
116470+ __kmem_cache_free(NULL, b, slob_rcu->size);
116471 }
116472
116473 void kmem_cache_free(struct kmem_cache *c, void *b)
116474 {
116475+ int size = c->size;
116476+
116477+#ifdef CONFIG_PAX_USERCOPY_SLABS
116478+ if (size + c->align < PAGE_SIZE) {
116479+ size += c->align;
116480+ b -= c->align;
116481+ }
116482+#endif
116483+
116484 kmemleak_free_recursive(b, c->flags);
116485 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
116486 struct slob_rcu *slob_rcu;
116487- slob_rcu = b + (c->size - sizeof(struct slob_rcu));
116488- slob_rcu->size = c->size;
116489+ slob_rcu = b + (size - sizeof(struct slob_rcu));
116490+ slob_rcu->size = size;
116491 call_rcu(&slob_rcu->head, kmem_rcu_free);
116492 } else {
116493- __kmem_cache_free(b, c->size);
116494+ __kmem_cache_free(c, b, size);
116495 }
116496
116497+#ifdef CONFIG_PAX_USERCOPY_SLABS
116498+ trace_kfree(_RET_IP_, b);
116499+#else
116500 trace_kmem_cache_free(_RET_IP_, b);
116501+#endif
116502+
116503 }
116504 EXPORT_SYMBOL(kmem_cache_free);
116505
116506diff --git a/mm/slub.c b/mm/slub.c
116507index f68c0e5..eb77178 100644
116508--- a/mm/slub.c
116509+++ b/mm/slub.c
116510@@ -34,6 +34,7 @@
116511 #include <linux/stacktrace.h>
116512 #include <linux/prefetch.h>
116513 #include <linux/memcontrol.h>
116514+#include <linux/vmalloc.h>
116515
116516 #include <trace/events/kmem.h>
116517
116518@@ -198,7 +199,7 @@ struct track {
116519
116520 enum track_item { TRACK_ALLOC, TRACK_FREE };
116521
116522-#ifdef CONFIG_SYSFS
116523+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116524 static int sysfs_slab_add(struct kmem_cache *);
116525 static int sysfs_slab_alias(struct kmem_cache *, const char *);
116526 static void memcg_propagate_slab_attrs(struct kmem_cache *s);
116527@@ -556,7 +557,7 @@ static void print_track(const char *s, struct track *t)
116528 if (!t->addr)
116529 return;
116530
116531- pr_err("INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
116532+ pr_err("INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
116533 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
116534 #ifdef CONFIG_STACKTRACE
116535 {
116536@@ -2707,6 +2708,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
116537
116538 slab_free_hook(s, x);
116539
116540+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116541+ if (!(s->flags & SLAB_NO_SANITIZE)) {
116542+ memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
116543+ if (s->ctor)
116544+ s->ctor(x);
116545+ }
116546+#endif
116547+
116548 redo:
116549 /*
116550 * Determine the currently cpus per cpu slab.
116551@@ -3048,6 +3057,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
116552 s->inuse = size;
116553
116554 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
116555+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116556+ (!(flags & SLAB_NO_SANITIZE)) ||
116557+#endif
116558 s->ctor)) {
116559 /*
116560 * Relocate free pointer after the object if it is not
116561@@ -3302,7 +3314,7 @@ static int __init setup_slub_min_objects(char *str)
116562
116563 __setup("slub_min_objects=", setup_slub_min_objects);
116564
116565-void *__kmalloc(size_t size, gfp_t flags)
116566+void * __size_overflow(1) __kmalloc(size_t size, gfp_t flags)
116567 {
116568 struct kmem_cache *s;
116569 void *ret;
116570@@ -3340,7 +3352,7 @@ static void *kmalloc_large_node(size_t size, gfp_t flags, int node)
116571 return ptr;
116572 }
116573
116574-void *__kmalloc_node(size_t size, gfp_t flags, int node)
116575+void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t flags, int node)
116576 {
116577 struct kmem_cache *s;
116578 void *ret;
116579@@ -3388,6 +3400,70 @@ static size_t __ksize(const void *object)
116580 return slab_ksize(page->slab_cache);
116581 }
116582
116583+bool is_usercopy_object(const void *ptr)
116584+{
116585+ struct page *page;
116586+ struct kmem_cache *s;
116587+
116588+ if (ZERO_OR_NULL_PTR(ptr))
116589+ return false;
116590+
116591+ if (!slab_is_available())
116592+ return false;
116593+
116594+ if (is_vmalloc_addr(ptr)
116595+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116596+ && !object_starts_on_stack(ptr)
116597+#endif
116598+ ) {
116599+ struct vm_struct *vm = find_vm_area(ptr);
116600+ if (vm && (vm->flags & VM_USERCOPY))
116601+ return true;
116602+ return false;
116603+ }
116604+
116605+ if (!virt_addr_valid(ptr))
116606+ return false;
116607+
116608+ page = virt_to_head_page(ptr);
116609+
116610+ if (!PageSlab(page))
116611+ return false;
116612+
116613+ s = page->slab_cache;
116614+ return s->flags & SLAB_USERCOPY;
116615+}
116616+
116617+#ifdef CONFIG_PAX_USERCOPY
116618+const char *check_heap_object(const void *ptr, unsigned long n)
116619+{
116620+ struct page *page;
116621+ struct kmem_cache *s;
116622+ unsigned long offset;
116623+
116624+ if (ZERO_OR_NULL_PTR(ptr))
116625+ return "<null>";
116626+
116627+ if (!virt_addr_valid(ptr))
116628+ return NULL;
116629+
116630+ page = virt_to_head_page(ptr);
116631+
116632+ if (!PageSlab(page))
116633+ return NULL;
116634+
116635+ s = page->slab_cache;
116636+ if (!(s->flags & SLAB_USERCOPY))
116637+ return s->name;
116638+
116639+ offset = (ptr - page_address(page)) % s->size;
116640+ if (offset <= s->object_size && n <= s->object_size - offset)
116641+ return NULL;
116642+
116643+ return s->name;
116644+}
116645+#endif
116646+
116647 size_t ksize(const void *object)
116648 {
116649 size_t size = __ksize(object);
116650@@ -3408,6 +3484,7 @@ void kfree(const void *x)
116651 if (unlikely(ZERO_OR_NULL_PTR(x)))
116652 return;
116653
116654+ VM_BUG_ON(!virt_addr_valid(x));
116655 page = virt_to_head_page(x);
116656 if (unlikely(!PageSlab(page))) {
116657 BUG_ON(!PageCompound(page));
116658@@ -3725,7 +3802,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
116659
116660 s = find_mergeable(size, align, flags, name, ctor);
116661 if (s) {
116662- s->refcount++;
116663+ atomic_inc(&s->refcount);
116664
116665 /*
116666 * Adjust the object sizes so that we clear
116667@@ -3741,7 +3818,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
116668 }
116669
116670 if (sysfs_slab_alias(s, name)) {
116671- s->refcount--;
116672+ atomic_dec(&s->refcount);
116673 s = NULL;
116674 }
116675 }
116676@@ -3858,7 +3935,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
116677 }
116678 #endif
116679
116680-#ifdef CONFIG_SYSFS
116681+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116682 static int count_inuse(struct page *page)
116683 {
116684 return page->inuse;
116685@@ -4139,7 +4216,11 @@ static int list_locations(struct kmem_cache *s, char *buf,
116686 len += sprintf(buf + len, "%7ld ", l->count);
116687
116688 if (l->addr)
116689+#ifdef CONFIG_GRKERNSEC_HIDESYM
116690+ len += sprintf(buf + len, "%pS", NULL);
116691+#else
116692 len += sprintf(buf + len, "%pS", (void *)l->addr);
116693+#endif
116694 else
116695 len += sprintf(buf + len, "<not-available>");
116696
116697@@ -4237,12 +4318,12 @@ static void __init resiliency_test(void)
116698 validate_slab_cache(kmalloc_caches[9]);
116699 }
116700 #else
116701-#ifdef CONFIG_SYSFS
116702+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116703 static void resiliency_test(void) {};
116704 #endif
116705 #endif
116706
116707-#ifdef CONFIG_SYSFS
116708+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116709 enum slab_stat_type {
116710 SL_ALL, /* All slabs */
116711 SL_PARTIAL, /* Only partially allocated slabs */
116712@@ -4479,13 +4560,17 @@ static ssize_t ctor_show(struct kmem_cache *s, char *buf)
116713 {
116714 if (!s->ctor)
116715 return 0;
116716+#ifdef CONFIG_GRKERNSEC_HIDESYM
116717+ return sprintf(buf, "%pS\n", NULL);
116718+#else
116719 return sprintf(buf, "%pS\n", s->ctor);
116720+#endif
116721 }
116722 SLAB_ATTR_RO(ctor);
116723
116724 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
116725 {
116726- return sprintf(buf, "%d\n", s->refcount < 0 ? 0 : s->refcount - 1);
116727+ return sprintf(buf, "%d\n", atomic_read(&s->refcount) < 0 ? 0 : atomic_read(&s->refcount) - 1);
116728 }
116729 SLAB_ATTR_RO(aliases);
116730
116731@@ -4573,6 +4658,22 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
116732 SLAB_ATTR_RO(cache_dma);
116733 #endif
116734
116735+#ifdef CONFIG_PAX_USERCOPY_SLABS
116736+static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
116737+{
116738+ return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
116739+}
116740+SLAB_ATTR_RO(usercopy);
116741+#endif
116742+
116743+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116744+static ssize_t sanitize_show(struct kmem_cache *s, char *buf)
116745+{
116746+ return sprintf(buf, "%d\n", !(s->flags & SLAB_NO_SANITIZE));
116747+}
116748+SLAB_ATTR_RO(sanitize);
116749+#endif
116750+
116751 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
116752 {
116753 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
116754@@ -4628,7 +4729,7 @@ static ssize_t trace_store(struct kmem_cache *s, const char *buf,
116755 * as well as cause other issues like converting a mergeable
116756 * cache into an umergeable one.
116757 */
116758- if (s->refcount > 1)
116759+ if (atomic_read(&s->refcount) > 1)
116760 return -EINVAL;
116761
116762 s->flags &= ~SLAB_TRACE;
116763@@ -4748,7 +4849,7 @@ static ssize_t failslab_show(struct kmem_cache *s, char *buf)
116764 static ssize_t failslab_store(struct kmem_cache *s, const char *buf,
116765 size_t length)
116766 {
116767- if (s->refcount > 1)
116768+ if (atomic_read(&s->refcount) > 1)
116769 return -EINVAL;
116770
116771 s->flags &= ~SLAB_FAILSLAB;
116772@@ -4915,6 +5016,12 @@ static struct attribute *slab_attrs[] = {
116773 #ifdef CONFIG_ZONE_DMA
116774 &cache_dma_attr.attr,
116775 #endif
116776+#ifdef CONFIG_PAX_USERCOPY_SLABS
116777+ &usercopy_attr.attr,
116778+#endif
116779+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116780+ &sanitize_attr.attr,
116781+#endif
116782 #ifdef CONFIG_NUMA
116783 &remote_node_defrag_ratio_attr.attr,
116784 #endif
116785@@ -5156,6 +5263,7 @@ static char *create_unique_id(struct kmem_cache *s)
116786 return name;
116787 }
116788
116789+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116790 static int sysfs_slab_add(struct kmem_cache *s)
116791 {
116792 int err;
116793@@ -5229,6 +5337,7 @@ void sysfs_slab_remove(struct kmem_cache *s)
116794 kobject_del(&s->kobj);
116795 kobject_put(&s->kobj);
116796 }
116797+#endif
116798
116799 /*
116800 * Need to buffer aliases during bootup until sysfs becomes
116801@@ -5242,6 +5351,7 @@ struct saved_alias {
116802
116803 static struct saved_alias *alias_list;
116804
116805+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116806 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
116807 {
116808 struct saved_alias *al;
116809@@ -5264,6 +5374,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
116810 alias_list = al;
116811 return 0;
116812 }
116813+#endif
116814
116815 static int __init slab_sysfs_init(void)
116816 {
116817diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
116818index 4cba9c2..b4f9fcc 100644
116819--- a/mm/sparse-vmemmap.c
116820+++ b/mm/sparse-vmemmap.c
116821@@ -131,7 +131,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
116822 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
116823 if (!p)
116824 return NULL;
116825- pud_populate(&init_mm, pud, p);
116826+ pud_populate_kernel(&init_mm, pud, p);
116827 }
116828 return pud;
116829 }
116830@@ -143,7 +143,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
116831 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
116832 if (!p)
116833 return NULL;
116834- pgd_populate(&init_mm, pgd, p);
116835+ pgd_populate_kernel(&init_mm, pgd, p);
116836 }
116837 return pgd;
116838 }
116839diff --git a/mm/sparse.c b/mm/sparse.c
116840index d1b48b6..6e8590e 100644
116841--- a/mm/sparse.c
116842+++ b/mm/sparse.c
116843@@ -750,7 +750,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
116844
116845 for (i = 0; i < PAGES_PER_SECTION; i++) {
116846 if (PageHWPoison(&memmap[i])) {
116847- atomic_long_sub(1, &num_poisoned_pages);
116848+ atomic_long_sub_unchecked(1, &num_poisoned_pages);
116849 ClearPageHWPoison(&memmap[i]);
116850 }
116851 }
116852diff --git a/mm/swap.c b/mm/swap.c
116853index a3a0a2f..915d436 100644
116854--- a/mm/swap.c
116855+++ b/mm/swap.c
116856@@ -85,6 +85,8 @@ static void __put_compound_page(struct page *page)
116857 if (!PageHuge(page))
116858 __page_cache_release(page);
116859 dtor = get_compound_page_dtor(page);
116860+ if (!PageHuge(page))
116861+ BUG_ON(dtor != free_compound_page);
116862 (*dtor)(page);
116863 }
116864
116865diff --git a/mm/swapfile.c b/mm/swapfile.c
116866index 41e4581..6c452c9 100644
116867--- a/mm/swapfile.c
116868+++ b/mm/swapfile.c
116869@@ -84,7 +84,7 @@ static DEFINE_MUTEX(swapon_mutex);
116870
116871 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
116872 /* Activity counter to indicate that a swapon or swapoff has occurred */
116873-static atomic_t proc_poll_event = ATOMIC_INIT(0);
116874+static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
116875
116876 static inline unsigned char swap_count(unsigned char ent)
116877 {
116878@@ -1944,7 +1944,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
116879 spin_unlock(&swap_lock);
116880
116881 err = 0;
116882- atomic_inc(&proc_poll_event);
116883+ atomic_inc_unchecked(&proc_poll_event);
116884 wake_up_interruptible(&proc_poll_wait);
116885
116886 out_dput:
116887@@ -1961,8 +1961,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
116888
116889 poll_wait(file, &proc_poll_wait, wait);
116890
116891- if (seq->poll_event != atomic_read(&proc_poll_event)) {
116892- seq->poll_event = atomic_read(&proc_poll_event);
116893+ if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
116894+ seq->poll_event = atomic_read_unchecked(&proc_poll_event);
116895 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
116896 }
116897
116898@@ -2060,7 +2060,7 @@ static int swaps_open(struct inode *inode, struct file *file)
116899 return ret;
116900
116901 seq = file->private_data;
116902- seq->poll_event = atomic_read(&proc_poll_event);
116903+ seq->poll_event = atomic_read_unchecked(&proc_poll_event);
116904 return 0;
116905 }
116906
116907@@ -2520,7 +2520,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
116908 (frontswap_map) ? "FS" : "");
116909
116910 mutex_unlock(&swapon_mutex);
116911- atomic_inc(&proc_poll_event);
116912+ atomic_inc_unchecked(&proc_poll_event);
116913 wake_up_interruptible(&proc_poll_wait);
116914
116915 if (S_ISREG(inode->i_mode))
116916diff --git a/mm/util.c b/mm/util.c
116917index 68ff8a5..40c7a70 100644
116918--- a/mm/util.c
116919+++ b/mm/util.c
116920@@ -233,6 +233,12 @@ struct task_struct *task_of_stack(struct task_struct *task,
116921 void arch_pick_mmap_layout(struct mm_struct *mm)
116922 {
116923 mm->mmap_base = TASK_UNMAPPED_BASE;
116924+
116925+#ifdef CONFIG_PAX_RANDMMAP
116926+ if (mm->pax_flags & MF_PAX_RANDMMAP)
116927+ mm->mmap_base += mm->delta_mmap;
116928+#endif
116929+
116930 mm->get_unmapped_area = arch_get_unmapped_area;
116931 }
116932 #endif
116933@@ -434,6 +440,9 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen)
116934 if (!mm->arg_end)
116935 goto out_mm; /* Shh! No looking before we're done */
116936
116937+ if (gr_acl_handle_procpidmem(task))
116938+ goto out_mm;
116939+
116940 len = mm->arg_end - mm->arg_start;
116941
116942 if (len > buflen)
116943diff --git a/mm/vmalloc.c b/mm/vmalloc.c
116944index 2faaa29..c816cf4 100644
116945--- a/mm/vmalloc.c
116946+++ b/mm/vmalloc.c
116947@@ -40,20 +40,65 @@ struct vfree_deferred {
116948 struct work_struct wq;
116949 };
116950 static DEFINE_PER_CPU(struct vfree_deferred, vfree_deferred);
116951+static DEFINE_PER_CPU(struct vfree_deferred, vunmap_deferred);
116952+
116953+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116954+struct stack_deferred_llist {
116955+ struct llist_head list;
116956+ void *stack;
116957+ void *lowmem_stack;
116958+};
116959+
116960+struct stack_deferred {
116961+ struct stack_deferred_llist list;
116962+ struct work_struct wq;
116963+};
116964+
116965+static DEFINE_PER_CPU(struct stack_deferred, stack_deferred);
116966+#endif
116967
116968 static void __vunmap(const void *, int);
116969
116970-static void free_work(struct work_struct *w)
116971+static void vfree_work(struct work_struct *w)
116972 {
116973 struct vfree_deferred *p = container_of(w, struct vfree_deferred, wq);
116974 struct llist_node *llnode = llist_del_all(&p->list);
116975 while (llnode) {
116976- void *p = llnode;
116977+ void *x = llnode;
116978 llnode = llist_next(llnode);
116979- __vunmap(p, 1);
116980+ __vunmap(x, 1);
116981 }
116982 }
116983
116984+static void vunmap_work(struct work_struct *w)
116985+{
116986+ struct vfree_deferred *p = container_of(w, struct vfree_deferred, wq);
116987+ struct llist_node *llnode = llist_del_all(&p->list);
116988+ while (llnode) {
116989+ void *x = llnode;
116990+ llnode = llist_next(llnode);
116991+ __vunmap(x, 0);
116992+ }
116993+}
116994+
116995+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116996+static void unmap_work(struct work_struct *w)
116997+{
116998+ struct stack_deferred *p = container_of(w, struct stack_deferred, wq);
116999+ struct llist_node *llnode = llist_del_all(&p->list.list);
117000+ while (llnode) {
117001+ struct stack_deferred_llist *x =
117002+ llist_entry((struct llist_head *)llnode,
117003+ struct stack_deferred_llist, list);
117004+ void *stack = ACCESS_ONCE(x->stack);
117005+ void *lowmem_stack = ACCESS_ONCE(x->lowmem_stack);
117006+ llnode = llist_next(llnode);
117007+ __vunmap(stack, 0);
117008+ free_kmem_pages((unsigned long)lowmem_stack, THREAD_SIZE_ORDER);
117009+ }
117010+}
117011+#endif
117012+
117013 /*** Page table manipulation functions ***/
117014
117015 static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
117016@@ -61,10 +106,23 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
117017 pte_t *pte;
117018
117019 pte = pte_offset_kernel(pmd, addr);
117020+ pax_open_kernel();
117021 do {
117022- pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
117023- WARN_ON(!pte_none(ptent) && !pte_present(ptent));
117024+
117025+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
117026+ if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
117027+ BUG_ON(!pte_exec(*pte));
117028+ set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
117029+ continue;
117030+ }
117031+#endif
117032+
117033+ {
117034+ pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
117035+ WARN_ON(!pte_none(ptent) && !pte_present(ptent));
117036+ }
117037 } while (pte++, addr += PAGE_SIZE, addr != end);
117038+ pax_close_kernel();
117039 }
117040
117041 static void vunmap_pmd_range(pud_t *pud, unsigned long addr, unsigned long end)
117042@@ -127,16 +185,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
117043 pte = pte_alloc_kernel(pmd, addr);
117044 if (!pte)
117045 return -ENOMEM;
117046+
117047+ pax_open_kernel();
117048 do {
117049 struct page *page = pages[*nr];
117050
117051- if (WARN_ON(!pte_none(*pte)))
117052+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
117053+ if (pgprot_val(prot) & _PAGE_NX)
117054+#endif
117055+
117056+ if (!pte_none(*pte)) {
117057+ pax_close_kernel();
117058+ WARN_ON(1);
117059 return -EBUSY;
117060- if (WARN_ON(!page))
117061+ }
117062+ if (!page) {
117063+ pax_close_kernel();
117064+ WARN_ON(1);
117065 return -ENOMEM;
117066+ }
117067 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
117068 (*nr)++;
117069 } while (pte++, addr += PAGE_SIZE, addr != end);
117070+ pax_close_kernel();
117071 return 0;
117072 }
117073
117074@@ -146,7 +217,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
117075 pmd_t *pmd;
117076 unsigned long next;
117077
117078- pmd = pmd_alloc(&init_mm, pud, addr);
117079+ pmd = pmd_alloc_kernel(&init_mm, pud, addr);
117080 if (!pmd)
117081 return -ENOMEM;
117082 do {
117083@@ -163,7 +234,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
117084 pud_t *pud;
117085 unsigned long next;
117086
117087- pud = pud_alloc(&init_mm, pgd, addr);
117088+ pud = pud_alloc_kernel(&init_mm, pgd, addr);
117089 if (!pud)
117090 return -ENOMEM;
117091 do {
117092@@ -223,6 +294,12 @@ int is_vmalloc_or_module_addr(const void *x)
117093 if (addr >= MODULES_VADDR && addr < MODULES_END)
117094 return 1;
117095 #endif
117096+
117097+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
117098+ if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
117099+ return 1;
117100+#endif
117101+
117102 return is_vmalloc_addr(x);
117103 }
117104
117105@@ -243,8 +320,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
117106
117107 if (!pgd_none(*pgd)) {
117108 pud_t *pud = pud_offset(pgd, addr);
117109+#ifdef CONFIG_X86
117110+ if (!pud_large(*pud))
117111+#endif
117112 if (!pud_none(*pud)) {
117113 pmd_t *pmd = pmd_offset(pud, addr);
117114+#ifdef CONFIG_X86
117115+ if (!pmd_large(*pmd))
117116+#endif
117117 if (!pmd_none(*pmd)) {
117118 pte_t *ptep, pte;
117119
117120@@ -346,7 +429,7 @@ static void purge_vmap_area_lazy(void);
117121 * Allocate a region of KVA of the specified size and alignment, within the
117122 * vstart and vend.
117123 */
117124-static struct vmap_area *alloc_vmap_area(unsigned long size,
117125+static struct vmap_area * __size_overflow(1) alloc_vmap_area(unsigned long size,
117126 unsigned long align,
117127 unsigned long vstart, unsigned long vend,
117128 int node, gfp_t gfp_mask)
117129@@ -1202,13 +1285,27 @@ void __init vmalloc_init(void)
117130 for_each_possible_cpu(i) {
117131 struct vmap_block_queue *vbq;
117132 struct vfree_deferred *p;
117133+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117134+ struct stack_deferred *p2;
117135+#endif
117136
117137 vbq = &per_cpu(vmap_block_queue, i);
117138 spin_lock_init(&vbq->lock);
117139 INIT_LIST_HEAD(&vbq->free);
117140+
117141 p = &per_cpu(vfree_deferred, i);
117142 init_llist_head(&p->list);
117143- INIT_WORK(&p->wq, free_work);
117144+ INIT_WORK(&p->wq, vfree_work);
117145+
117146+ p = &per_cpu(vunmap_deferred, i);
117147+ init_llist_head(&p->list);
117148+ INIT_WORK(&p->wq, vunmap_work);
117149+
117150+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117151+ p2 = &per_cpu(stack_deferred, i);
117152+ init_llist_head(&p2->list.list);
117153+ INIT_WORK(&p2->wq, unmap_work);
117154+#endif
117155 }
117156
117157 /* Import existing vmlist entries. */
117158@@ -1333,6 +1430,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
117159 struct vm_struct *area;
117160
117161 BUG_ON(in_interrupt());
117162+
117163+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
117164+ if (flags & VM_KERNEXEC) {
117165+ if (start != VMALLOC_START || end != VMALLOC_END)
117166+ return NULL;
117167+ start = (unsigned long)MODULES_EXEC_VADDR;
117168+ end = (unsigned long)MODULES_EXEC_END;
117169+ }
117170+#endif
117171+
117172 if (flags & VM_IOREMAP)
117173 align = 1ul << clamp_t(int, fls_long(size),
117174 PAGE_SHIFT, IOREMAP_MAX_ORDER);
117175@@ -1531,13 +1638,36 @@ EXPORT_SYMBOL(vfree);
117176 */
117177 void vunmap(const void *addr)
117178 {
117179- BUG_ON(in_interrupt());
117180- might_sleep();
117181- if (addr)
117182+ if (!addr)
117183+ return;
117184+ if (unlikely(in_interrupt())) {
117185+ struct vfree_deferred *p = this_cpu_ptr(&vunmap_deferred);
117186+ if (llist_add((struct llist_node *)addr, &p->list))
117187+ schedule_work(&p->wq);
117188+ } else {
117189+ might_sleep();
117190 __vunmap(addr, 0);
117191+ }
117192 }
117193 EXPORT_SYMBOL(vunmap);
117194
117195+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117196+void unmap_process_stacks(struct task_struct *task)
117197+{
117198+ if (unlikely(in_interrupt())) {
117199+ struct stack_deferred *p = this_cpu_ptr(&stack_deferred);
117200+ struct stack_deferred_llist *list = task->stack;
117201+ list->stack = task->stack;
117202+ list->lowmem_stack = task->lowmem_stack;
117203+ if (llist_add((struct llist_node *)&list->list, &p->list.list))
117204+ schedule_work(&p->wq);
117205+ } else {
117206+ __vunmap(task->stack, 0);
117207+ free_kmem_pages((unsigned long)task->lowmem_stack, THREAD_SIZE_ORDER);
117208+ }
117209+}
117210+#endif
117211+
117212 /**
117213 * vmap - map an array of pages into virtually contiguous space
117214 * @pages: array of page pointers
117215@@ -1558,6 +1688,11 @@ void *vmap(struct page **pages, unsigned int count,
117216 if (count > totalram_pages)
117217 return NULL;
117218
117219+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
117220+ if (!(pgprot_val(prot) & _PAGE_NX))
117221+ flags |= VM_KERNEXEC;
117222+#endif
117223+
117224 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
117225 __builtin_return_address(0));
117226 if (!area)
117227@@ -1662,6 +1797,14 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
117228 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
117229 goto fail;
117230
117231+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
117232+ if (!(pgprot_val(prot) & _PAGE_NX)) {
117233+ vm_flags |= VM_KERNEXEC;
117234+ start = VMALLOC_START;
117235+ end = VMALLOC_END;
117236+ }
117237+#endif
117238+
117239 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED |
117240 vm_flags, start, end, node, gfp_mask, caller);
117241 if (!area)
117242@@ -1715,6 +1858,14 @@ static void *__vmalloc_node(unsigned long size, unsigned long align,
117243 gfp_mask, prot, 0, node, caller);
117244 }
117245
117246+void *vmalloc_usercopy(unsigned long size)
117247+{
117248+ return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
117249+ GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL,
117250+ VM_USERCOPY, NUMA_NO_NODE,
117251+ __builtin_return_address(0));
117252+}
117253+
117254 void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
117255 {
117256 return __vmalloc_node(size, 1, gfp_mask, prot, NUMA_NO_NODE,
117257@@ -1838,10 +1989,9 @@ EXPORT_SYMBOL(vzalloc_node);
117258 * For tight control over page level allocator and protection flags
117259 * use __vmalloc() instead.
117260 */
117261-
117262 void *vmalloc_exec(unsigned long size)
117263 {
117264- return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
117265+ return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
117266 NUMA_NO_NODE, __builtin_return_address(0));
117267 }
117268
117269@@ -2148,6 +2298,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
117270 {
117271 struct vm_struct *area;
117272
117273+ BUG_ON(vma->vm_mirror);
117274+
117275 size = PAGE_ALIGN(size);
117276
117277 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
117278@@ -2630,7 +2782,11 @@ static int s_show(struct seq_file *m, void *p)
117279 v->addr, v->addr + v->size, v->size);
117280
117281 if (v->caller)
117282+#ifdef CONFIG_GRKERNSEC_HIDESYM
117283+ seq_printf(m, " %pK", v->caller);
117284+#else
117285 seq_printf(m, " %pS", v->caller);
117286+#endif
117287
117288 if (v->nr_pages)
117289 seq_printf(m, " pages=%d", v->nr_pages);
117290diff --git a/mm/vmstat.c b/mm/vmstat.c
117291index 4f5cd97..9fb715a 100644
117292--- a/mm/vmstat.c
117293+++ b/mm/vmstat.c
117294@@ -27,6 +27,7 @@
117295 #include <linux/mm_inline.h>
117296 #include <linux/page_ext.h>
117297 #include <linux/page_owner.h>
117298+#include <linux/grsecurity.h>
117299
117300 #include "internal.h"
117301
117302@@ -86,7 +87,7 @@ void vm_events_fold_cpu(int cpu)
117303 *
117304 * vm_stat contains the global counters
117305 */
117306-atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
117307+atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
117308 EXPORT_SYMBOL(vm_stat);
117309
117310 #ifdef CONFIG_SMP
117311@@ -438,7 +439,7 @@ static int fold_diff(int *diff)
117312
117313 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
117314 if (diff[i]) {
117315- atomic_long_add(diff[i], &vm_stat[i]);
117316+ atomic_long_add_unchecked(diff[i], &vm_stat[i]);
117317 changes++;
117318 }
117319 return changes;
117320@@ -476,7 +477,7 @@ static int refresh_cpu_vm_stats(void)
117321 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
117322 if (v) {
117323
117324- atomic_long_add(v, &zone->vm_stat[i]);
117325+ atomic_long_add_unchecked(v, &zone->vm_stat[i]);
117326 global_diff[i] += v;
117327 #ifdef CONFIG_NUMA
117328 /* 3 seconds idle till flush */
117329@@ -540,7 +541,7 @@ void cpu_vm_stats_fold(int cpu)
117330
117331 v = p->vm_stat_diff[i];
117332 p->vm_stat_diff[i] = 0;
117333- atomic_long_add(v, &zone->vm_stat[i]);
117334+ atomic_long_add_unchecked(v, &zone->vm_stat[i]);
117335 global_diff[i] += v;
117336 }
117337 }
117338@@ -560,8 +561,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
117339 if (pset->vm_stat_diff[i]) {
117340 int v = pset->vm_stat_diff[i];
117341 pset->vm_stat_diff[i] = 0;
117342- atomic_long_add(v, &zone->vm_stat[i]);
117343- atomic_long_add(v, &vm_stat[i]);
117344+ atomic_long_add_unchecked(v, &zone->vm_stat[i]);
117345+ atomic_long_add_unchecked(v, &vm_stat[i]);
117346 }
117347 }
117348 #endif
117349@@ -1293,10 +1294,22 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
117350 stat_items_size += sizeof(struct vm_event_state);
117351 #endif
117352
117353- v = kmalloc(stat_items_size, GFP_KERNEL);
117354+ v = kzalloc(stat_items_size, GFP_KERNEL);
117355 m->private = v;
117356 if (!v)
117357 return ERR_PTR(-ENOMEM);
117358+
117359+#ifdef CONFIG_GRKERNSEC_PROC_ADD
117360+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
117361+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
117362+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
117363+ && !in_group_p(grsec_proc_gid)
117364+#endif
117365+ )
117366+ return (unsigned long *)m->private + *pos;
117367+#endif
117368+#endif
117369+
117370 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
117371 v[i] = global_page_state(i);
117372 v += NR_VM_ZONE_STAT_ITEMS;
117373@@ -1528,10 +1541,16 @@ static int __init setup_vmstat(void)
117374 cpu_notifier_register_done();
117375 #endif
117376 #ifdef CONFIG_PROC_FS
117377- proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
117378- proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
117379- proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
117380- proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
117381+ {
117382+ mode_t gr_mode = S_IRUGO;
117383+#ifdef CONFIG_GRKERNSEC_PROC_ADD
117384+ gr_mode = S_IRUSR;
117385+#endif
117386+ proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
117387+ proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
117388+ proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
117389+ proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
117390+ }
117391 #endif
117392 return 0;
117393 }
117394diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
117395index d2cd9de..501c186 100644
117396--- a/net/8021q/vlan.c
117397+++ b/net/8021q/vlan.c
117398@@ -491,7 +491,7 @@ out:
117399 return NOTIFY_DONE;
117400 }
117401
117402-static struct notifier_block vlan_notifier_block __read_mostly = {
117403+static struct notifier_block vlan_notifier_block = {
117404 .notifier_call = vlan_device_event,
117405 };
117406
117407@@ -566,8 +566,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
117408 err = -EPERM;
117409 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
117410 break;
117411- if ((args.u.name_type >= 0) &&
117412- (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
117413+ if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
117414 struct vlan_net *vn;
117415
117416 vn = net_generic(net, vlan_net_id);
117417diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
117418index c92b52f..006c052 100644
117419--- a/net/8021q/vlan_netlink.c
117420+++ b/net/8021q/vlan_netlink.c
117421@@ -245,7 +245,7 @@ static struct net *vlan_get_link_net(const struct net_device *dev)
117422 return dev_net(real_dev);
117423 }
117424
117425-struct rtnl_link_ops vlan_link_ops __read_mostly = {
117426+struct rtnl_link_ops vlan_link_ops = {
117427 .kind = "vlan",
117428 .maxtype = IFLA_VLAN_MAX,
117429 .policy = vlan_policy,
117430diff --git a/net/9p/mod.c b/net/9p/mod.c
117431index 6ab36ae..6f1841b 100644
117432--- a/net/9p/mod.c
117433+++ b/net/9p/mod.c
117434@@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
117435 void v9fs_register_trans(struct p9_trans_module *m)
117436 {
117437 spin_lock(&v9fs_trans_lock);
117438- list_add_tail(&m->list, &v9fs_trans_list);
117439+ pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
117440 spin_unlock(&v9fs_trans_lock);
117441 }
117442 EXPORT_SYMBOL(v9fs_register_trans);
117443@@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
117444 void v9fs_unregister_trans(struct p9_trans_module *m)
117445 {
117446 spin_lock(&v9fs_trans_lock);
117447- list_del_init(&m->list);
117448+ pax_list_del_init((struct list_head *)&m->list);
117449 spin_unlock(&v9fs_trans_lock);
117450 }
117451 EXPORT_SYMBOL(v9fs_unregister_trans);
117452diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
117453index bced8c0..ef253b7 100644
117454--- a/net/9p/trans_fd.c
117455+++ b/net/9p/trans_fd.c
117456@@ -428,7 +428,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
117457 oldfs = get_fs();
117458 set_fs(get_ds());
117459 /* The cast to a user pointer is valid due to the set_fs() */
117460- ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
117461+ ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
117462 set_fs(oldfs);
117463
117464 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
117465diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
117466index af46bc4..f9adfcd 100644
117467--- a/net/appletalk/atalk_proc.c
117468+++ b/net/appletalk/atalk_proc.c
117469@@ -256,7 +256,7 @@ int __init atalk_proc_init(void)
117470 struct proc_dir_entry *p;
117471 int rc = -ENOMEM;
117472
117473- atalk_proc_dir = proc_mkdir("atalk", init_net.proc_net);
117474+ atalk_proc_dir = proc_mkdir_restrict("atalk", init_net.proc_net);
117475 if (!atalk_proc_dir)
117476 goto out;
117477
117478diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
117479index 876fbe8..8bbea9f 100644
117480--- a/net/atm/atm_misc.c
117481+++ b/net/atm/atm_misc.c
117482@@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
117483 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
117484 return 1;
117485 atm_return(vcc, truesize);
117486- atomic_inc(&vcc->stats->rx_drop);
117487+ atomic_inc_unchecked(&vcc->stats->rx_drop);
117488 return 0;
117489 }
117490 EXPORT_SYMBOL(atm_charge);
117491@@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
117492 }
117493 }
117494 atm_return(vcc, guess);
117495- atomic_inc(&vcc->stats->rx_drop);
117496+ atomic_inc_unchecked(&vcc->stats->rx_drop);
117497 return NULL;
117498 }
117499 EXPORT_SYMBOL(atm_alloc_charge);
117500@@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
117501
117502 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
117503 {
117504-#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
117505+#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
117506 __SONET_ITEMS
117507 #undef __HANDLE_ITEM
117508 }
117509@@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
117510
117511 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
117512 {
117513-#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
117514+#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
117515 __SONET_ITEMS
117516 #undef __HANDLE_ITEM
117517 }
117518diff --git a/net/atm/lec.c b/net/atm/lec.c
117519index cd3b379..977a3c9 100644
117520--- a/net/atm/lec.c
117521+++ b/net/atm/lec.c
117522@@ -111,9 +111,9 @@ static inline void lec_arp_put(struct lec_arp_table *entry)
117523 }
117524
117525 static struct lane2_ops lane2_ops = {
117526- lane2_resolve, /* resolve, spec 3.1.3 */
117527- lane2_associate_req, /* associate_req, spec 3.1.4 */
117528- NULL /* associate indicator, spec 3.1.5 */
117529+ .resolve = lane2_resolve,
117530+ .associate_req = lane2_associate_req,
117531+ .associate_indicator = NULL
117532 };
117533
117534 static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
117535diff --git a/net/atm/lec.h b/net/atm/lec.h
117536index 4149db1..f2ab682 100644
117537--- a/net/atm/lec.h
117538+++ b/net/atm/lec.h
117539@@ -48,7 +48,7 @@ struct lane2_ops {
117540 const u8 *tlvs, u32 sizeoftlvs);
117541 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
117542 const u8 *tlvs, u32 sizeoftlvs);
117543-};
117544+} __no_const;
117545
117546 /*
117547 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
117548diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c
117549index d1b2d9a..d549f7f 100644
117550--- a/net/atm/mpoa_caches.c
117551+++ b/net/atm/mpoa_caches.c
117552@@ -535,30 +535,30 @@ static void eg_destroy_cache(struct mpoa_client *mpc)
117553
117554
117555 static struct in_cache_ops ingress_ops = {
117556- in_cache_add_entry, /* add_entry */
117557- in_cache_get, /* get */
117558- in_cache_get_with_mask, /* get_with_mask */
117559- in_cache_get_by_vcc, /* get_by_vcc */
117560- in_cache_put, /* put */
117561- in_cache_remove_entry, /* remove_entry */
117562- cache_hit, /* cache_hit */
117563- clear_count_and_expired, /* clear_count */
117564- check_resolving_entries, /* check_resolving */
117565- refresh_entries, /* refresh */
117566- in_destroy_cache /* destroy_cache */
117567+ .add_entry = in_cache_add_entry,
117568+ .get = in_cache_get,
117569+ .get_with_mask = in_cache_get_with_mask,
117570+ .get_by_vcc = in_cache_get_by_vcc,
117571+ .put = in_cache_put,
117572+ .remove_entry = in_cache_remove_entry,
117573+ .cache_hit = cache_hit,
117574+ .clear_count = clear_count_and_expired,
117575+ .check_resolving = check_resolving_entries,
117576+ .refresh = refresh_entries,
117577+ .destroy_cache = in_destroy_cache
117578 };
117579
117580 static struct eg_cache_ops egress_ops = {
117581- eg_cache_add_entry, /* add_entry */
117582- eg_cache_get_by_cache_id, /* get_by_cache_id */
117583- eg_cache_get_by_tag, /* get_by_tag */
117584- eg_cache_get_by_vcc, /* get_by_vcc */
117585- eg_cache_get_by_src_ip, /* get_by_src_ip */
117586- eg_cache_put, /* put */
117587- eg_cache_remove_entry, /* remove_entry */
117588- update_eg_cache_entry, /* update */
117589- clear_expired, /* clear_expired */
117590- eg_destroy_cache /* destroy_cache */
117591+ .add_entry = eg_cache_add_entry,
117592+ .get_by_cache_id = eg_cache_get_by_cache_id,
117593+ .get_by_tag = eg_cache_get_by_tag,
117594+ .get_by_vcc = eg_cache_get_by_vcc,
117595+ .get_by_src_ip = eg_cache_get_by_src_ip,
117596+ .put = eg_cache_put,
117597+ .remove_entry = eg_cache_remove_entry,
117598+ .update = update_eg_cache_entry,
117599+ .clear_expired = clear_expired,
117600+ .destroy_cache = eg_destroy_cache
117601 };
117602
117603
117604diff --git a/net/atm/proc.c b/net/atm/proc.c
117605index bbb6461..cf04016 100644
117606--- a/net/atm/proc.c
117607+++ b/net/atm/proc.c
117608@@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
117609 const struct k_atm_aal_stats *stats)
117610 {
117611 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
117612- atomic_read(&stats->tx), atomic_read(&stats->tx_err),
117613- atomic_read(&stats->rx), atomic_read(&stats->rx_err),
117614- atomic_read(&stats->rx_drop));
117615+ atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
117616+ atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
117617+ atomic_read_unchecked(&stats->rx_drop));
117618 }
117619
117620 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
117621diff --git a/net/atm/resources.c b/net/atm/resources.c
117622index 0447d5d..3cf4728 100644
117623--- a/net/atm/resources.c
117624+++ b/net/atm/resources.c
117625@@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
117626 static void copy_aal_stats(struct k_atm_aal_stats *from,
117627 struct atm_aal_stats *to)
117628 {
117629-#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
117630+#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
117631 __AAL_STAT_ITEMS
117632 #undef __HANDLE_ITEM
117633 }
117634@@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
117635 static void subtract_aal_stats(struct k_atm_aal_stats *from,
117636 struct atm_aal_stats *to)
117637 {
117638-#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
117639+#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
117640 __AAL_STAT_ITEMS
117641 #undef __HANDLE_ITEM
117642 }
117643diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
117644index 919a5ce..cc6b444 100644
117645--- a/net/ax25/sysctl_net_ax25.c
117646+++ b/net/ax25/sysctl_net_ax25.c
117647@@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
117648 {
117649 char path[sizeof("net/ax25/") + IFNAMSIZ];
117650 int k;
117651- struct ctl_table *table;
117652+ ctl_table_no_const *table;
117653
117654 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
117655 if (!table)
117656diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
117657index 753383c..32d12d9 100644
117658--- a/net/batman-adv/bat_iv_ogm.c
117659+++ b/net/batman-adv/bat_iv_ogm.c
117660@@ -343,7 +343,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
117661
117662 /* randomize initial seqno to avoid collision */
117663 get_random_bytes(&random_seqno, sizeof(random_seqno));
117664- atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
117665+ atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
117666
117667 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
117668 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
117669@@ -947,9 +947,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
117670 batadv_ogm_packet->tvlv_len = htons(tvlv_len);
117671
117672 /* change sequence number to network order */
117673- seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
117674+ seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
117675 batadv_ogm_packet->seqno = htonl(seqno);
117676- atomic_inc(&hard_iface->bat_iv.ogm_seqno);
117677+ atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
117678
117679 batadv_iv_ogm_slide_own_bcast_window(hard_iface);
117680
117681@@ -1626,7 +1626,7 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
117682 return;
117683
117684 /* could be changed by schedule_own_packet() */
117685- if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
117686+ if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
117687
117688 if (ogm_packet->flags & BATADV_DIRECTLINK)
117689 has_directlink_flag = true;
117690diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
117691index c0f0d01..725928a 100644
117692--- a/net/batman-adv/fragmentation.c
117693+++ b/net/batman-adv/fragmentation.c
117694@@ -465,7 +465,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
117695 frag_header.packet_type = BATADV_UNICAST_FRAG;
117696 frag_header.version = BATADV_COMPAT_VERSION;
117697 frag_header.ttl = BATADV_TTL;
117698- frag_header.seqno = htons(atomic_inc_return(&bat_priv->frag_seqno));
117699+ frag_header.seqno = htons(atomic_inc_return_unchecked(&bat_priv->frag_seqno));
117700 frag_header.reserved = 0;
117701 frag_header.no = 0;
117702 frag_header.total_size = htons(skb->len);
117703diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
117704index 51cda3a..a5db59e 100644
117705--- a/net/batman-adv/soft-interface.c
117706+++ b/net/batman-adv/soft-interface.c
117707@@ -330,7 +330,7 @@ send:
117708 primary_if->net_dev->dev_addr);
117709
117710 /* set broadcast sequence number */
117711- seqno = atomic_inc_return(&bat_priv->bcast_seqno);
117712+ seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
117713 bcast_packet->seqno = htonl(seqno);
117714
117715 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
117716@@ -798,7 +798,7 @@ static int batadv_softif_init_late(struct net_device *dev)
117717 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
117718
117719 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
117720- atomic_set(&bat_priv->bcast_seqno, 1);
117721+ atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
117722 atomic_set(&bat_priv->tt.vn, 0);
117723 atomic_set(&bat_priv->tt.local_changes, 0);
117724 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
117725@@ -812,7 +812,7 @@ static int batadv_softif_init_late(struct net_device *dev)
117726
117727 /* randomize initial seqno to avoid collision */
117728 get_random_bytes(&random_seqno, sizeof(random_seqno));
117729- atomic_set(&bat_priv->frag_seqno, random_seqno);
117730+ atomic_set_unchecked(&bat_priv->frag_seqno, random_seqno);
117731
117732 bat_priv->primary_if = NULL;
117733 bat_priv->num_ifaces = 0;
117734@@ -1020,7 +1020,7 @@ int batadv_softif_is_valid(const struct net_device *net_dev)
117735 return 0;
117736 }
117737
117738-struct rtnl_link_ops batadv_link_ops __read_mostly = {
117739+struct rtnl_link_ops batadv_link_ops = {
117740 .kind = "batadv",
117741 .priv_size = sizeof(struct batadv_priv),
117742 .setup = batadv_softif_init_early,
117743diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
117744index 55610a8..aba2ae8 100644
117745--- a/net/batman-adv/types.h
117746+++ b/net/batman-adv/types.h
117747@@ -81,7 +81,7 @@ enum batadv_dhcp_recipient {
117748 struct batadv_hard_iface_bat_iv {
117749 unsigned char *ogm_buff;
117750 int ogm_buff_len;
117751- atomic_t ogm_seqno;
117752+ atomic_unchecked_t ogm_seqno;
117753 };
117754
117755 /**
117756@@ -786,7 +786,7 @@ struct batadv_priv {
117757 atomic_t bonding;
117758 atomic_t fragmentation;
117759 atomic_t packet_size_max;
117760- atomic_t frag_seqno;
117761+ atomic_unchecked_t frag_seqno;
117762 #ifdef CONFIG_BATMAN_ADV_BLA
117763 atomic_t bridge_loop_avoidance;
117764 #endif
117765@@ -805,7 +805,7 @@ struct batadv_priv {
117766 #endif
117767 uint32_t isolation_mark;
117768 uint32_t isolation_mark_mask;
117769- atomic_t bcast_seqno;
117770+ atomic_unchecked_t bcast_seqno;
117771 atomic_t bcast_queue_left;
117772 atomic_t batman_queue_left;
117773 char num_ifaces;
117774diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
117775index f2d30d1..0573933 100644
117776--- a/net/bluetooth/hci_sock.c
117777+++ b/net/bluetooth/hci_sock.c
117778@@ -1253,7 +1253,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
117779 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
117780 }
117781
117782- len = min_t(unsigned int, len, sizeof(uf));
117783+ len = min((size_t)len, sizeof(uf));
117784 if (copy_from_user(&uf, optval, len)) {
117785 err = -EFAULT;
117786 break;
117787diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
117788index 45fffa4..c5ad848 100644
117789--- a/net/bluetooth/l2cap_core.c
117790+++ b/net/bluetooth/l2cap_core.c
117791@@ -3537,8 +3537,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
117792 break;
117793
117794 case L2CAP_CONF_RFC:
117795- if (olen == sizeof(rfc))
117796- memcpy(&rfc, (void *)val, olen);
117797+ if (olen != sizeof(rfc))
117798+ break;
117799+
117800+ memcpy(&rfc, (void *)val, olen);
117801
117802 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
117803 rfc.mode != chan->mode)
117804diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
117805index 2442877..24ddcd1 100644
117806--- a/net/bluetooth/l2cap_sock.c
117807+++ b/net/bluetooth/l2cap_sock.c
117808@@ -633,7 +633,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
117809 struct sock *sk = sock->sk;
117810 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
117811 struct l2cap_options opts;
117812- int len, err = 0;
117813+ int err = 0;
117814+ size_t len = optlen;
117815 u32 opt;
117816
117817 BT_DBG("sk %p", sk);
117818@@ -660,7 +661,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
117819 opts.max_tx = chan->max_tx;
117820 opts.txwin_size = chan->tx_win;
117821
117822- len = min_t(unsigned int, sizeof(opts), optlen);
117823+ len = min(sizeof(opts), len);
117824 if (copy_from_user((char *) &opts, optval, len)) {
117825 err = -EFAULT;
117826 break;
117827@@ -747,7 +748,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
117828 struct bt_security sec;
117829 struct bt_power pwr;
117830 struct l2cap_conn *conn;
117831- int len, err = 0;
117832+ int err = 0;
117833+ size_t len = optlen;
117834 u32 opt;
117835
117836 BT_DBG("sk %p", sk);
117837@@ -771,7 +773,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
117838
117839 sec.level = BT_SECURITY_LOW;
117840
117841- len = min_t(unsigned int, sizeof(sec), optlen);
117842+ len = min(sizeof(sec), len);
117843 if (copy_from_user((char *) &sec, optval, len)) {
117844 err = -EFAULT;
117845 break;
117846@@ -867,7 +869,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
117847
117848 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
117849
117850- len = min_t(unsigned int, sizeof(pwr), optlen);
117851+ len = min(sizeof(pwr), len);
117852 if (copy_from_user((char *) &pwr, optval, len)) {
117853 err = -EFAULT;
117854 break;
117855diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
117856index 7511df7..a670df3 100644
117857--- a/net/bluetooth/rfcomm/sock.c
117858+++ b/net/bluetooth/rfcomm/sock.c
117859@@ -690,7 +690,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
117860 struct sock *sk = sock->sk;
117861 struct bt_security sec;
117862 int err = 0;
117863- size_t len;
117864+ size_t len = optlen;
117865 u32 opt;
117866
117867 BT_DBG("sk %p", sk);
117868@@ -712,7 +712,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
117869
117870 sec.level = BT_SECURITY_LOW;
117871
117872- len = min_t(unsigned int, sizeof(sec), optlen);
117873+ len = min(sizeof(sec), len);
117874 if (copy_from_user((char *) &sec, optval, len)) {
117875 err = -EFAULT;
117876 break;
117877diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
117878index 8e385a0..a5bdd8e 100644
117879--- a/net/bluetooth/rfcomm/tty.c
117880+++ b/net/bluetooth/rfcomm/tty.c
117881@@ -752,7 +752,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
117882 BT_DBG("tty %p id %d", tty, tty->index);
117883
117884 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
117885- dev->channel, dev->port.count);
117886+ dev->channel, atomic_read(&dev->port.count));
117887
117888 err = tty_port_open(&dev->port, tty, filp);
117889 if (err)
117890@@ -775,7 +775,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
117891 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
117892
117893 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
117894- dev->port.count);
117895+ atomic_read(&dev->port.count));
117896
117897 tty_port_close(&dev->port, tty, filp);
117898 }
117899diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
117900index 4d74a06..f37f9c2 100644
117901--- a/net/bridge/br_netlink.c
117902+++ b/net/bridge/br_netlink.c
117903@@ -835,7 +835,7 @@ static struct rtnl_af_ops br_af_ops __read_mostly = {
117904 .get_link_af_size = br_get_link_af_size,
117905 };
117906
117907-struct rtnl_link_ops br_link_ops __read_mostly = {
117908+struct rtnl_link_ops br_link_ops = {
117909 .kind = "bridge",
117910 .priv_size = sizeof(struct net_bridge),
117911 .setup = br_dev_setup,
117912diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
117913index 18ca4b2..7e8d731 100644
117914--- a/net/bridge/netfilter/ebtables.c
117915+++ b/net/bridge/netfilter/ebtables.c
117916@@ -1533,7 +1533,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
117917 tmp.valid_hooks = t->table->valid_hooks;
117918 }
117919 mutex_unlock(&ebt_mutex);
117920- if (copy_to_user(user, &tmp, *len) != 0) {
117921+ if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
117922 BUGPRINT("c2u Didn't work\n");
117923 ret = -EFAULT;
117924 break;
117925@@ -2339,7 +2339,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
117926 goto out;
117927 tmp.valid_hooks = t->valid_hooks;
117928
117929- if (copy_to_user(user, &tmp, *len) != 0) {
117930+ if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
117931 ret = -EFAULT;
117932 break;
117933 }
117934@@ -2350,7 +2350,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
117935 tmp.entries_size = t->table->entries_size;
117936 tmp.valid_hooks = t->table->valid_hooks;
117937
117938- if (copy_to_user(user, &tmp, *len) != 0) {
117939+ if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
117940 ret = -EFAULT;
117941 break;
117942 }
117943diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
117944index f5afda1..dcf770a 100644
117945--- a/net/caif/cfctrl.c
117946+++ b/net/caif/cfctrl.c
117947@@ -10,6 +10,7 @@
117948 #include <linux/spinlock.h>
117949 #include <linux/slab.h>
117950 #include <linux/pkt_sched.h>
117951+#include <linux/sched.h>
117952 #include <net/caif/caif_layer.h>
117953 #include <net/caif/cfpkt.h>
117954 #include <net/caif/cfctrl.h>
117955@@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
117956 memset(&dev_info, 0, sizeof(dev_info));
117957 dev_info.id = 0xff;
117958 cfsrvl_init(&this->serv, 0, &dev_info, false);
117959- atomic_set(&this->req_seq_no, 1);
117960- atomic_set(&this->rsp_seq_no, 1);
117961+ atomic_set_unchecked(&this->req_seq_no, 1);
117962+ atomic_set_unchecked(&this->rsp_seq_no, 1);
117963 this->serv.layer.receive = cfctrl_recv;
117964 sprintf(this->serv.layer.name, "ctrl");
117965 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
117966@@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
117967 struct cfctrl_request_info *req)
117968 {
117969 spin_lock_bh(&ctrl->info_list_lock);
117970- atomic_inc(&ctrl->req_seq_no);
117971- req->sequence_no = atomic_read(&ctrl->req_seq_no);
117972+ atomic_inc_unchecked(&ctrl->req_seq_no);
117973+ req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
117974 list_add_tail(&req->list, &ctrl->list);
117975 spin_unlock_bh(&ctrl->info_list_lock);
117976 }
117977@@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
117978 if (p != first)
117979 pr_warn("Requests are not received in order\n");
117980
117981- atomic_set(&ctrl->rsp_seq_no,
117982+ atomic_set_unchecked(&ctrl->rsp_seq_no,
117983 p->sequence_no);
117984 list_del(&p->list);
117985 goto out;
117986diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
117987index 67a4a36..8d28068 100644
117988--- a/net/caif/chnl_net.c
117989+++ b/net/caif/chnl_net.c
117990@@ -515,7 +515,7 @@ static const struct nla_policy ipcaif_policy[IFLA_CAIF_MAX + 1] = {
117991 };
117992
117993
117994-static struct rtnl_link_ops ipcaif_link_ops __read_mostly = {
117995+static struct rtnl_link_ops ipcaif_link_ops = {
117996 .kind = "caif",
117997 .priv_size = sizeof(struct chnl_net),
117998 .setup = ipcaif_net_setup,
117999diff --git a/net/can/af_can.c b/net/can/af_can.c
118000index 166d436..2920816 100644
118001--- a/net/can/af_can.c
118002+++ b/net/can/af_can.c
118003@@ -890,7 +890,7 @@ static const struct net_proto_family can_family_ops = {
118004 };
118005
118006 /* notifier block for netdevice event */
118007-static struct notifier_block can_netdev_notifier __read_mostly = {
118008+static struct notifier_block can_netdev_notifier = {
118009 .notifier_call = can_notifier,
118010 };
118011
118012diff --git a/net/can/bcm.c b/net/can/bcm.c
118013index a1ba687..aafaec5 100644
118014--- a/net/can/bcm.c
118015+++ b/net/can/bcm.c
118016@@ -1620,7 +1620,7 @@ static int __init bcm_module_init(void)
118017 }
118018
118019 /* create /proc/net/can-bcm directory */
118020- proc_dir = proc_mkdir("can-bcm", init_net.proc_net);
118021+ proc_dir = proc_mkdir_restrict("can-bcm", init_net.proc_net);
118022 return 0;
118023 }
118024
118025diff --git a/net/can/gw.c b/net/can/gw.c
118026index 4551687..4e82e9b 100644
118027--- a/net/can/gw.c
118028+++ b/net/can/gw.c
118029@@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
118030 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
118031
118032 static HLIST_HEAD(cgw_list);
118033-static struct notifier_block notifier;
118034
118035 static struct kmem_cache *cgw_cache __read_mostly;
118036
118037@@ -992,6 +991,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
118038 return err;
118039 }
118040
118041+static struct notifier_block notifier = {
118042+ .notifier_call = cgw_notifier
118043+};
118044+
118045 static __init int cgw_module_init(void)
118046 {
118047 /* sanitize given module parameter */
118048@@ -1007,7 +1010,6 @@ static __init int cgw_module_init(void)
118049 return -ENOMEM;
118050
118051 /* set notifier */
118052- notifier.notifier_call = cgw_notifier;
118053 register_netdevice_notifier(&notifier);
118054
118055 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
118056diff --git a/net/can/proc.c b/net/can/proc.c
118057index 1a19b98..df2b4ec 100644
118058--- a/net/can/proc.c
118059+++ b/net/can/proc.c
118060@@ -514,7 +514,7 @@ static void can_remove_proc_readentry(const char *name)
118061 void can_init_proc(void)
118062 {
118063 /* create /proc/net/can directory */
118064- can_dir = proc_mkdir("can", init_net.proc_net);
118065+ can_dir = proc_mkdir_restrict("can", init_net.proc_net);
118066
118067 if (!can_dir) {
118068 printk(KERN_INFO "can: failed to create /proc/net/can . "
118069diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
118070index e3be1d2..254c555 100644
118071--- a/net/ceph/messenger.c
118072+++ b/net/ceph/messenger.c
118073@@ -189,7 +189,7 @@ static void con_fault(struct ceph_connection *con);
118074 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
118075
118076 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
118077-static atomic_t addr_str_seq = ATOMIC_INIT(0);
118078+static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
118079
118080 static struct page *zero_page; /* used in certain error cases */
118081
118082@@ -200,7 +200,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
118083 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
118084 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
118085
118086- i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
118087+ i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
118088 s = addr_str[i];
118089
118090 switch (ss->ss_family) {
118091diff --git a/net/compat.c b/net/compat.c
118092index 5cfd26a..7e43828 100644
118093--- a/net/compat.c
118094+++ b/net/compat.c
118095@@ -98,20 +98,20 @@ int get_compat_msghdr(struct msghdr *kmsg,
118096
118097 #define CMSG_COMPAT_FIRSTHDR(msg) \
118098 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
118099- (struct compat_cmsghdr __user *)((msg)->msg_control) : \
118100+ (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
118101 (struct compat_cmsghdr __user *)NULL)
118102
118103 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
118104 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
118105 (ucmlen) <= (unsigned long) \
118106 ((mhdr)->msg_controllen - \
118107- ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
118108+ ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
118109
118110 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
118111 struct compat_cmsghdr __user *cmsg, int cmsg_len)
118112 {
118113 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
118114- if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
118115+ if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
118116 msg->msg_controllen)
118117 return NULL;
118118 return (struct compat_cmsghdr __user *)ptr;
118119@@ -201,7 +201,7 @@ Efault:
118120
118121 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
118122 {
118123- struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
118124+ struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
118125 struct compat_cmsghdr cmhdr;
118126 struct compat_timeval ctv;
118127 struct compat_timespec cts[3];
118128@@ -257,7 +257,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
118129
118130 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
118131 {
118132- struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
118133+ struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
118134 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
118135 int fdnum = scm->fp->count;
118136 struct file **fp = scm->fp->fp;
118137@@ -345,7 +345,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
118138 return -EFAULT;
118139 old_fs = get_fs();
118140 set_fs(KERNEL_DS);
118141- err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
118142+ err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
118143 set_fs(old_fs);
118144
118145 return err;
118146@@ -406,7 +406,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
118147 len = sizeof(ktime);
118148 old_fs = get_fs();
118149 set_fs(KERNEL_DS);
118150- err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
118151+ err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
118152 set_fs(old_fs);
118153
118154 if (!err) {
118155@@ -549,7 +549,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
118156 case MCAST_JOIN_GROUP:
118157 case MCAST_LEAVE_GROUP:
118158 {
118159- struct compat_group_req __user *gr32 = (void *)optval;
118160+ struct compat_group_req __user *gr32 = (void __user *)optval;
118161 struct group_req __user *kgr =
118162 compat_alloc_user_space(sizeof(struct group_req));
118163 u32 interface;
118164@@ -570,7 +570,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
118165 case MCAST_BLOCK_SOURCE:
118166 case MCAST_UNBLOCK_SOURCE:
118167 {
118168- struct compat_group_source_req __user *gsr32 = (void *)optval;
118169+ struct compat_group_source_req __user *gsr32 = (void __user *)optval;
118170 struct group_source_req __user *kgsr = compat_alloc_user_space(
118171 sizeof(struct group_source_req));
118172 u32 interface;
118173@@ -591,7 +591,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
118174 }
118175 case MCAST_MSFILTER:
118176 {
118177- struct compat_group_filter __user *gf32 = (void *)optval;
118178+ struct compat_group_filter __user *gf32 = (void __user *)optval;
118179 struct group_filter __user *kgf;
118180 u32 interface, fmode, numsrc;
118181
118182@@ -629,7 +629,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
118183 char __user *optval, int __user *optlen,
118184 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
118185 {
118186- struct compat_group_filter __user *gf32 = (void *)optval;
118187+ struct compat_group_filter __user *gf32 = (void __user *)optval;
118188 struct group_filter __user *kgf;
118189 int __user *koptlen;
118190 u32 interface, fmode, numsrc;
118191@@ -773,7 +773,7 @@ COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args)
118192
118193 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
118194 return -EINVAL;
118195- if (copy_from_user(a, args, nas[call]))
118196+ if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
118197 return -EFAULT;
118198 a0 = a[0];
118199 a1 = a[1];
118200diff --git a/net/core/datagram.c b/net/core/datagram.c
118201index 617088a..0364f4f 100644
118202--- a/net/core/datagram.c
118203+++ b/net/core/datagram.c
118204@@ -338,7 +338,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
118205 }
118206
118207 kfree_skb(skb);
118208- atomic_inc(&sk->sk_drops);
118209+ atomic_inc_unchecked(&sk->sk_drops);
118210 sk_mem_reclaim_partial(sk);
118211
118212 return err;
118213diff --git a/net/core/dev.c b/net/core/dev.c
118214index a8e4dd4..aab06f7 100644
118215--- a/net/core/dev.c
118216+++ b/net/core/dev.c
118217@@ -1721,7 +1721,7 @@ int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
118218 {
118219 if (skb_orphan_frags(skb, GFP_ATOMIC) ||
118220 unlikely(!is_skb_forwardable(dev, skb))) {
118221- atomic_long_inc(&dev->rx_dropped);
118222+ atomic_long_inc_unchecked(&dev->rx_dropped);
118223 kfree_skb(skb);
118224 return NET_RX_DROP;
118225 }
118226@@ -3125,7 +3125,7 @@ recursion_alert:
118227 drop:
118228 rcu_read_unlock_bh();
118229
118230- atomic_long_inc(&dev->tx_dropped);
118231+ atomic_long_inc_unchecked(&dev->tx_dropped);
118232 kfree_skb_list(skb);
118233 return rc;
118234 out:
118235@@ -3477,7 +3477,7 @@ drop:
118236
118237 local_irq_restore(flags);
118238
118239- atomic_long_inc(&skb->dev->rx_dropped);
118240+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
118241 kfree_skb(skb);
118242 return NET_RX_DROP;
118243 }
118244@@ -3554,7 +3554,7 @@ int netif_rx_ni(struct sk_buff *skb)
118245 }
118246 EXPORT_SYMBOL(netif_rx_ni);
118247
118248-static void net_tx_action(struct softirq_action *h)
118249+static __latent_entropy void net_tx_action(void)
118250 {
118251 struct softnet_data *sd = this_cpu_ptr(&softnet_data);
118252
118253@@ -3892,7 +3892,7 @@ ncls:
118254 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
118255 } else {
118256 drop:
118257- atomic_long_inc(&skb->dev->rx_dropped);
118258+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
118259 kfree_skb(skb);
118260 /* Jamal, now you will not able to escape explaining
118261 * me how you were going to use this. :-)
118262@@ -4783,7 +4783,7 @@ out_unlock:
118263 return work;
118264 }
118265
118266-static void net_rx_action(struct softirq_action *h)
118267+static __latent_entropy void net_rx_action(void)
118268 {
118269 struct softnet_data *sd = this_cpu_ptr(&softnet_data);
118270 unsigned long time_limit = jiffies + 2;
118271@@ -6843,8 +6843,8 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
118272 } else {
118273 netdev_stats_to_stats64(storage, &dev->stats);
118274 }
118275- storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
118276- storage->tx_dropped += atomic_long_read(&dev->tx_dropped);
118277+ storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
118278+ storage->tx_dropped += atomic_long_read_unchecked(&dev->tx_dropped);
118279 return storage;
118280 }
118281 EXPORT_SYMBOL(dev_get_stats);
118282diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
118283index b94b1d2..da3ed7c 100644
118284--- a/net/core/dev_ioctl.c
118285+++ b/net/core/dev_ioctl.c
118286@@ -368,8 +368,13 @@ void dev_load(struct net *net, const char *name)
118287 no_module = !dev;
118288 if (no_module && capable(CAP_NET_ADMIN))
118289 no_module = request_module("netdev-%s", name);
118290- if (no_module && capable(CAP_SYS_MODULE))
118291+ if (no_module && capable(CAP_SYS_MODULE)) {
118292+#ifdef CONFIG_GRKERNSEC_MODHARDEN
118293+ ___request_module(true, "grsec_modharden_netdev", "%s", name);
118294+#else
118295 request_module("%s", name);
118296+#endif
118297+ }
118298 }
118299 EXPORT_SYMBOL(dev_load);
118300
118301diff --git a/net/core/ethtool.c b/net/core/ethtool.c
118302index b495ab1..29edf74 100644
118303--- a/net/core/ethtool.c
118304+++ b/net/core/ethtool.c
118305@@ -1284,7 +1284,7 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
118306
118307 gstrings.len = ret;
118308
118309- data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
118310+ data = kcalloc(gstrings.len, ETH_GSTRING_LEN, GFP_USER);
118311 if (!data)
118312 return -ENOMEM;
118313
118314diff --git a/net/core/filter.c b/net/core/filter.c
118315index be3098f..51ee477 100644
118316--- a/net/core/filter.c
118317+++ b/net/core/filter.c
118318@@ -582,7 +582,11 @@ do_pass:
118319
118320 /* Unknown instruction. */
118321 default:
118322- goto err;
118323+ WARN(1, KERN_ALERT "Unknown sock filter code:%u jt:%u tf:%u k:%u\n",
118324+ fp->code, fp->jt, fp->jf, fp->k);
118325+ kfree(addrs);
118326+ BUG();
118327+ return -EINVAL;
118328 }
118329
118330 insn++;
118331@@ -626,7 +630,7 @@ static int check_load_and_stores(const struct sock_filter *filter, int flen)
118332 u16 *masks, memvalid = 0; /* One bit per cell, 16 cells */
118333 int pc, ret = 0;
118334
118335- BUILD_BUG_ON(BPF_MEMWORDS > 16);
118336+ BUILD_BUG_ON(BPF_MEMWORDS != 16);
118337
118338 masks = kmalloc_array(flen, sizeof(*masks), GFP_KERNEL);
118339 if (!masks)
118340@@ -1055,7 +1059,7 @@ int bpf_prog_create(struct bpf_prog **pfp, struct sock_fprog_kern *fprog)
118341 if (!fp)
118342 return -ENOMEM;
118343
118344- memcpy(fp->insns, fprog->filter, fsize);
118345+ memcpy(fp->insns, (void __force_kernel *)fprog->filter, fsize);
118346
118347 fp->len = fprog->len;
118348 /* Since unattached filters are not copied back to user
118349@@ -1701,9 +1705,13 @@ int sk_get_filter(struct sock *sk, struct sock_filter __user *ubuf,
118350 goto out;
118351
118352 /* We're copying the filter that has been originally attached,
118353- * so no conversion/decode needed anymore.
118354+ * so no conversion/decode needed anymore. eBPF programs that
118355+ * have no original program cannot be dumped through this.
118356 */
118357+ ret = -EACCES;
118358 fprog = filter->prog->orig_prog;
118359+ if (!fprog)
118360+ goto out;
118361
118362 ret = fprog->len;
118363 if (!len)
118364diff --git a/net/core/flow.c b/net/core/flow.c
118365index 1033725..340f65d 100644
118366--- a/net/core/flow.c
118367+++ b/net/core/flow.c
118368@@ -65,7 +65,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
118369 static int flow_entry_valid(struct flow_cache_entry *fle,
118370 struct netns_xfrm *xfrm)
118371 {
118372- if (atomic_read(&xfrm->flow_cache_genid) != fle->genid)
118373+ if (atomic_read_unchecked(&xfrm->flow_cache_genid) != fle->genid)
118374 return 0;
118375 if (fle->object && !fle->object->ops->check(fle->object))
118376 return 0;
118377@@ -242,7 +242,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
118378 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
118379 fcp->hash_count++;
118380 }
118381- } else if (likely(fle->genid == atomic_read(&net->xfrm.flow_cache_genid))) {
118382+ } else if (likely(fle->genid == atomic_read_unchecked(&net->xfrm.flow_cache_genid))) {
118383 flo = fle->object;
118384 if (!flo)
118385 goto ret_object;
118386@@ -263,7 +263,7 @@ nocache:
118387 }
118388 flo = resolver(net, key, family, dir, flo, ctx);
118389 if (fle) {
118390- fle->genid = atomic_read(&net->xfrm.flow_cache_genid);
118391+ fle->genid = atomic_read_unchecked(&net->xfrm.flow_cache_genid);
118392 if (!IS_ERR(flo))
118393 fle->object = flo;
118394 else
118395diff --git a/net/core/neighbour.c b/net/core/neighbour.c
118396index 84195da..035c7a7 100644
118397--- a/net/core/neighbour.c
118398+++ b/net/core/neighbour.c
118399@@ -2821,7 +2821,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
118400 void __user *buffer, size_t *lenp, loff_t *ppos)
118401 {
118402 int size, ret;
118403- struct ctl_table tmp = *ctl;
118404+ ctl_table_no_const tmp = *ctl;
118405
118406 tmp.extra1 = &zero;
118407 tmp.extra2 = &unres_qlen_max;
118408@@ -2883,7 +2883,7 @@ static int neigh_proc_dointvec_zero_intmax(struct ctl_table *ctl, int write,
118409 void __user *buffer,
118410 size_t *lenp, loff_t *ppos)
118411 {
118412- struct ctl_table tmp = *ctl;
118413+ ctl_table_no_const tmp = *ctl;
118414 int ret;
118415
118416 tmp.extra1 = &zero;
118417diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
118418index 2bf8329..2eb1423 100644
118419--- a/net/core/net-procfs.c
118420+++ b/net/core/net-procfs.c
118421@@ -79,7 +79,13 @@ static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
118422 struct rtnl_link_stats64 temp;
118423 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
118424
118425- seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
118426+ if (gr_proc_is_restricted())
118427+ seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
118428+ "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
118429+ dev->name, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL,
118430+ 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL);
118431+ else
118432+ seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
118433 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
118434 dev->name, stats->rx_bytes, stats->rx_packets,
118435 stats->rx_errors,
118436@@ -166,7 +172,7 @@ static int softnet_seq_show(struct seq_file *seq, void *v)
118437 return 0;
118438 }
118439
118440-static const struct seq_operations dev_seq_ops = {
118441+const struct seq_operations dev_seq_ops = {
118442 .start = dev_seq_start,
118443 .next = dev_seq_next,
118444 .stop = dev_seq_stop,
118445@@ -196,7 +202,7 @@ static const struct seq_operations softnet_seq_ops = {
118446
118447 static int softnet_seq_open(struct inode *inode, struct file *file)
118448 {
118449- return seq_open(file, &softnet_seq_ops);
118450+ return seq_open_restrict(file, &softnet_seq_ops);
118451 }
118452
118453 static const struct file_operations softnet_seq_fops = {
118454@@ -283,8 +289,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
118455 else
118456 seq_printf(seq, "%04x", ntohs(pt->type));
118457
118458+#ifdef CONFIG_GRKERNSEC_HIDESYM
118459+ seq_printf(seq, " %-8s %pf\n",
118460+ pt->dev ? pt->dev->name : "", NULL);
118461+#else
118462 seq_printf(seq, " %-8s %pf\n",
118463 pt->dev ? pt->dev->name : "", pt->func);
118464+#endif
118465 }
118466
118467 return 0;
118468diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
118469index 18b34d7..faecc1d 100644
118470--- a/net/core/net-sysfs.c
118471+++ b/net/core/net-sysfs.c
118472@@ -288,7 +288,7 @@ static ssize_t carrier_changes_show(struct device *dev,
118473 {
118474 struct net_device *netdev = to_net_dev(dev);
118475 return sprintf(buf, fmt_dec,
118476- atomic_read(&netdev->carrier_changes));
118477+ atomic_read_unchecked(&netdev->carrier_changes));
118478 }
118479 static DEVICE_ATTR_RO(carrier_changes);
118480
118481diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
118482index 2c2eb1b..a53be3e 100644
118483--- a/net/core/net_namespace.c
118484+++ b/net/core/net_namespace.c
118485@@ -775,7 +775,7 @@ static int __register_pernet_operations(struct list_head *list,
118486 int error;
118487 LIST_HEAD(net_exit_list);
118488
118489- list_add_tail(&ops->list, list);
118490+ pax_list_add_tail((struct list_head *)&ops->list, list);
118491 if (ops->init || (ops->id && ops->size)) {
118492 for_each_net(net) {
118493 error = ops_init(ops, net);
118494@@ -788,7 +788,7 @@ static int __register_pernet_operations(struct list_head *list,
118495
118496 out_undo:
118497 /* If I have an error cleanup all namespaces I initialized */
118498- list_del(&ops->list);
118499+ pax_list_del((struct list_head *)&ops->list);
118500 ops_exit_list(ops, &net_exit_list);
118501 ops_free_list(ops, &net_exit_list);
118502 return error;
118503@@ -799,7 +799,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
118504 struct net *net;
118505 LIST_HEAD(net_exit_list);
118506
118507- list_del(&ops->list);
118508+ pax_list_del((struct list_head *)&ops->list);
118509 for_each_net(net)
118510 list_add_tail(&net->exit_list, &net_exit_list);
118511 ops_exit_list(ops, &net_exit_list);
118512@@ -933,7 +933,7 @@ int register_pernet_device(struct pernet_operations *ops)
118513 mutex_lock(&net_mutex);
118514 error = register_pernet_operations(&pernet_list, ops);
118515 if (!error && (first_device == &pernet_list))
118516- first_device = &ops->list;
118517+ first_device = (struct list_head *)&ops->list;
118518 mutex_unlock(&net_mutex);
118519 return error;
118520 }
118521diff --git a/net/core/netpoll.c b/net/core/netpoll.c
118522index c126a87..10ad89d 100644
118523--- a/net/core/netpoll.c
118524+++ b/net/core/netpoll.c
118525@@ -377,7 +377,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
118526 struct udphdr *udph;
118527 struct iphdr *iph;
118528 struct ethhdr *eth;
118529- static atomic_t ip_ident;
118530+ static atomic_unchecked_t ip_ident;
118531 struct ipv6hdr *ip6h;
118532
118533 udp_len = len + sizeof(*udph);
118534@@ -448,7 +448,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
118535 put_unaligned(0x45, (unsigned char *)iph);
118536 iph->tos = 0;
118537 put_unaligned(htons(ip_len), &(iph->tot_len));
118538- iph->id = htons(atomic_inc_return(&ip_ident));
118539+ iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
118540 iph->frag_off = 0;
118541 iph->ttl = 64;
118542 iph->protocol = IPPROTO_UDP;
118543diff --git a/net/core/pktgen.c b/net/core/pktgen.c
118544index 1cbd209..9553598 100644
118545--- a/net/core/pktgen.c
118546+++ b/net/core/pktgen.c
118547@@ -3828,7 +3828,7 @@ static int __net_init pg_net_init(struct net *net)
118548 pn->net = net;
118549 INIT_LIST_HEAD(&pn->pktgen_threads);
118550 pn->pktgen_exiting = false;
118551- pn->proc_dir = proc_mkdir(PG_PROC_DIR, pn->net->proc_net);
118552+ pn->proc_dir = proc_mkdir_restrict(PG_PROC_DIR, pn->net->proc_net);
118553 if (!pn->proc_dir) {
118554 pr_warn("cannot create /proc/net/%s\n", PG_PROC_DIR);
118555 return -ENODEV;
118556diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
118557index 0861018..1fd388b 100644
118558--- a/net/core/rtnetlink.c
118559+++ b/net/core/rtnetlink.c
118560@@ -61,7 +61,7 @@ struct rtnl_link {
118561 rtnl_doit_func doit;
118562 rtnl_dumpit_func dumpit;
118563 rtnl_calcit_func calcit;
118564-};
118565+} __no_const;
118566
118567 static DEFINE_MUTEX(rtnl_mutex);
118568
118569@@ -307,10 +307,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
118570 * to use the ops for creating device. So do not
118571 * fill up dellink as well. That disables rtnl_dellink.
118572 */
118573- if (ops->setup && !ops->dellink)
118574- ops->dellink = unregister_netdevice_queue;
118575+ if (ops->setup && !ops->dellink) {
118576+ pax_open_kernel();
118577+ *(void **)&ops->dellink = unregister_netdevice_queue;
118578+ pax_close_kernel();
118579+ }
118580
118581- list_add_tail(&ops->list, &link_ops);
118582+ pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
118583 return 0;
118584 }
118585 EXPORT_SYMBOL_GPL(__rtnl_link_register);
118586@@ -357,7 +360,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
118587 for_each_net(net) {
118588 __rtnl_kill_links(net, ops);
118589 }
118590- list_del(&ops->list);
118591+ pax_list_del((struct list_head *)&ops->list);
118592 }
118593 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
118594
118595@@ -1082,7 +1085,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
118596 (dev->ifalias &&
118597 nla_put_string(skb, IFLA_IFALIAS, dev->ifalias)) ||
118598 nla_put_u32(skb, IFLA_CARRIER_CHANGES,
118599- atomic_read(&dev->carrier_changes)))
118600+ atomic_read_unchecked(&dev->carrier_changes)))
118601 goto nla_put_failure;
118602
118603 if (1) {
118604diff --git a/net/core/scm.c b/net/core/scm.c
118605index 3b6899b..20d20e7 100644
118606--- a/net/core/scm.c
118607+++ b/net/core/scm.c
118608@@ -209,9 +209,9 @@ EXPORT_SYMBOL(__scm_send);
118609 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
118610 {
118611 struct cmsghdr __user *cm
118612- = (__force struct cmsghdr __user *)msg->msg_control;
118613+ = (struct cmsghdr __force_user *)msg->msg_control;
118614 struct cmsghdr cmhdr;
118615- int cmlen = CMSG_LEN(len);
118616+ size_t cmlen = CMSG_LEN(len);
118617 int err;
118618
118619 if (MSG_CMSG_COMPAT & msg->msg_flags)
118620@@ -232,7 +232,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
118621 err = -EFAULT;
118622 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
118623 goto out;
118624- if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
118625+ if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
118626 goto out;
118627 cmlen = CMSG_SPACE(len);
118628 if (msg->msg_controllen < cmlen)
118629@@ -248,7 +248,7 @@ EXPORT_SYMBOL(put_cmsg);
118630 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118631 {
118632 struct cmsghdr __user *cm
118633- = (__force struct cmsghdr __user*)msg->msg_control;
118634+ = (struct cmsghdr __force_user *)msg->msg_control;
118635
118636 int fdmax = 0;
118637 int fdnum = scm->fp->count;
118638@@ -268,7 +268,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118639 if (fdnum < fdmax)
118640 fdmax = fdnum;
118641
118642- for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
118643+ for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
118644 i++, cmfptr++)
118645 {
118646 struct socket *sock;
118647@@ -297,7 +297,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118648
118649 if (i > 0)
118650 {
118651- int cmlen = CMSG_LEN(i*sizeof(int));
118652+ size_t cmlen = CMSG_LEN(i*sizeof(int));
118653 err = put_user(SOL_SOCKET, &cm->cmsg_level);
118654 if (!err)
118655 err = put_user(SCM_RIGHTS, &cm->cmsg_type);
118656@@ -305,6 +305,8 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118657 err = put_user(cmlen, &cm->cmsg_len);
118658 if (!err) {
118659 cmlen = CMSG_SPACE(i*sizeof(int));
118660+ if (msg->msg_controllen < cmlen)
118661+ cmlen = msg->msg_controllen;
118662 msg->msg_control += cmlen;
118663 msg->msg_controllen -= cmlen;
118664 }
118665diff --git a/net/core/skbuff.c b/net/core/skbuff.c
118666index 7b84330..e0f5a86 100644
118667--- a/net/core/skbuff.c
118668+++ b/net/core/skbuff.c
118669@@ -2103,7 +2103,7 @@ EXPORT_SYMBOL(__skb_checksum);
118670 __wsum skb_checksum(const struct sk_buff *skb, int offset,
118671 int len, __wsum csum)
118672 {
118673- const struct skb_checksum_ops ops = {
118674+ static const struct skb_checksum_ops ops = {
118675 .update = csum_partial_ext,
118676 .combine = csum_block_add_ext,
118677 };
118678@@ -3317,12 +3317,14 @@ void __init skb_init(void)
118679 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
118680 sizeof(struct sk_buff),
118681 0,
118682- SLAB_HWCACHE_ALIGN|SLAB_PANIC,
118683+ SLAB_HWCACHE_ALIGN|SLAB_PANIC|
118684+ SLAB_NO_SANITIZE,
118685 NULL);
118686 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
118687 sizeof(struct sk_buff_fclones),
118688 0,
118689- SLAB_HWCACHE_ALIGN|SLAB_PANIC,
118690+ SLAB_HWCACHE_ALIGN|SLAB_PANIC|
118691+ SLAB_NO_SANITIZE,
118692 NULL);
118693 }
118694
118695diff --git a/net/core/sock.c b/net/core/sock.c
118696index 193901d..33094ab 100644
118697--- a/net/core/sock.c
118698+++ b/net/core/sock.c
118699@@ -441,7 +441,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
118700 struct sk_buff_head *list = &sk->sk_receive_queue;
118701
118702 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
118703- atomic_inc(&sk->sk_drops);
118704+ atomic_inc_unchecked(&sk->sk_drops);
118705 trace_sock_rcvqueue_full(sk, skb);
118706 return -ENOMEM;
118707 }
118708@@ -451,7 +451,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
118709 return err;
118710
118711 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
118712- atomic_inc(&sk->sk_drops);
118713+ atomic_inc_unchecked(&sk->sk_drops);
118714 return -ENOBUFS;
118715 }
118716
118717@@ -484,7 +484,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
118718 skb->dev = NULL;
118719
118720 if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) {
118721- atomic_inc(&sk->sk_drops);
118722+ atomic_inc_unchecked(&sk->sk_drops);
118723 goto discard_and_relse;
118724 }
118725 if (nested)
118726@@ -502,7 +502,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
118727 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
118728 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
118729 bh_unlock_sock(sk);
118730- atomic_inc(&sk->sk_drops);
118731+ atomic_inc_unchecked(&sk->sk_drops);
118732 goto discard_and_relse;
118733 }
118734
118735@@ -908,6 +908,7 @@ set_rcvbuf:
118736 }
118737 break;
118738
118739+#ifndef GRKERNSEC_BPF_HARDEN
118740 case SO_ATTACH_BPF:
118741 ret = -EINVAL;
118742 if (optlen == sizeof(u32)) {
118743@@ -920,7 +921,7 @@ set_rcvbuf:
118744 ret = sk_attach_bpf(ufd, sk);
118745 }
118746 break;
118747-
118748+#endif
118749 case SO_DETACH_FILTER:
118750 ret = sk_detach_filter(sk);
118751 break;
118752@@ -1022,12 +1023,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
118753 struct timeval tm;
118754 } v;
118755
118756- int lv = sizeof(int);
118757- int len;
118758+ unsigned int lv = sizeof(int);
118759+ unsigned int len;
118760
118761 if (get_user(len, optlen))
118762 return -EFAULT;
118763- if (len < 0)
118764+ if (len > INT_MAX)
118765 return -EINVAL;
118766
118767 memset(&v, 0, sizeof(v));
118768@@ -1165,11 +1166,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
118769
118770 case SO_PEERNAME:
118771 {
118772- char address[128];
118773+ char address[_K_SS_MAXSIZE];
118774
118775 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
118776 return -ENOTCONN;
118777- if (lv < len)
118778+ if (lv < len || sizeof address < len)
118779 return -EINVAL;
118780 if (copy_to_user(optval, address, len))
118781 return -EFAULT;
118782@@ -1257,7 +1258,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
118783
118784 if (len > lv)
118785 len = lv;
118786- if (copy_to_user(optval, &v, len))
118787+ if (len > sizeof(v) || copy_to_user(optval, &v, len))
118788 return -EFAULT;
118789 lenout:
118790 if (put_user(len, optlen))
118791@@ -1550,7 +1551,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
118792 newsk->sk_err = 0;
118793 newsk->sk_priority = 0;
118794 newsk->sk_incoming_cpu = raw_smp_processor_id();
118795- atomic64_set(&newsk->sk_cookie, 0);
118796+ atomic64_set_unchecked(&newsk->sk_cookie, 0);
118797 /*
118798 * Before updating sk_refcnt, we must commit prior changes to memory
118799 * (Documentation/RCU/rculist_nulls.txt for details)
118800@@ -2359,7 +2360,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
118801 */
118802 smp_wmb();
118803 atomic_set(&sk->sk_refcnt, 1);
118804- atomic_set(&sk->sk_drops, 0);
118805+ atomic_set_unchecked(&sk->sk_drops, 0);
118806 }
118807 EXPORT_SYMBOL(sock_init_data);
118808
118809@@ -2487,6 +2488,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
118810 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
118811 int level, int type)
118812 {
118813+ struct sock_extended_err ee;
118814 struct sock_exterr_skb *serr;
118815 struct sk_buff *skb;
118816 int copied, err;
118817@@ -2508,7 +2510,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
118818 sock_recv_timestamp(msg, sk, skb);
118819
118820 serr = SKB_EXT_ERR(skb);
118821- put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
118822+ ee = serr->ee;
118823+ put_cmsg(msg, level, type, sizeof ee, &ee);
118824
118825 msg->msg_flags |= MSG_ERRQUEUE;
118826 err = copied;
118827diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
118828index 817622f..2577b26 100644
118829--- a/net/core/sock_diag.c
118830+++ b/net/core/sock_diag.c
118831@@ -12,7 +12,7 @@
118832 #include <linux/inet_diag.h>
118833 #include <linux/sock_diag.h>
118834
118835-static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
118836+static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
118837 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
118838 static DEFINE_MUTEX(sock_diag_table_mutex);
118839 static struct workqueue_struct *broadcast_wq;
118840@@ -20,12 +20,12 @@ static struct workqueue_struct *broadcast_wq;
118841 static u64 sock_gen_cookie(struct sock *sk)
118842 {
118843 while (1) {
118844- u64 res = atomic64_read(&sk->sk_cookie);
118845+ u64 res = atomic64_read_unchecked(&sk->sk_cookie);
118846
118847 if (res)
118848 return res;
118849- res = atomic64_inc_return(&sock_net(sk)->cookie_gen);
118850- atomic64_cmpxchg(&sk->sk_cookie, 0, res);
118851+ res = atomic64_inc_return_unchecked(&sock_net(sk)->cookie_gen);
118852+ atomic64_cmpxchg_unchecked(&sk->sk_cookie, 0, res);
118853 }
118854 }
118855
118856@@ -190,8 +190,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
118857 mutex_lock(&sock_diag_table_mutex);
118858 if (sock_diag_handlers[hndl->family])
118859 err = -EBUSY;
118860- else
118861+ else {
118862+ pax_open_kernel();
118863 sock_diag_handlers[hndl->family] = hndl;
118864+ pax_close_kernel();
118865+ }
118866 mutex_unlock(&sock_diag_table_mutex);
118867
118868 return err;
118869@@ -207,7 +210,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
118870
118871 mutex_lock(&sock_diag_table_mutex);
118872 BUG_ON(sock_diag_handlers[family] != hnld);
118873+ pax_open_kernel();
118874 sock_diag_handlers[family] = NULL;
118875+ pax_close_kernel();
118876 mutex_unlock(&sock_diag_table_mutex);
118877 }
118878 EXPORT_SYMBOL_GPL(sock_diag_unregister);
118879diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
118880index 95b6139..3048623 100644
118881--- a/net/core/sysctl_net_core.c
118882+++ b/net/core/sysctl_net_core.c
118883@@ -35,7 +35,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
118884 {
118885 unsigned int orig_size, size;
118886 int ret, i;
118887- struct ctl_table tmp = {
118888+ ctl_table_no_const tmp = {
118889 .data = &size,
118890 .maxlen = sizeof(size),
118891 .mode = table->mode
118892@@ -203,7 +203,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
118893 void __user *buffer, size_t *lenp, loff_t *ppos)
118894 {
118895 char id[IFNAMSIZ];
118896- struct ctl_table tbl = {
118897+ ctl_table_no_const tbl = {
118898 .data = id,
118899 .maxlen = IFNAMSIZ,
118900 };
118901@@ -221,7 +221,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
118902 static int proc_do_rss_key(struct ctl_table *table, int write,
118903 void __user *buffer, size_t *lenp, loff_t *ppos)
118904 {
118905- struct ctl_table fake_table;
118906+ ctl_table_no_const fake_table;
118907 char buf[NETDEV_RSS_KEY_LEN * 3];
118908
118909 snprintf(buf, sizeof(buf), "%*phC", NETDEV_RSS_KEY_LEN, netdev_rss_key);
118910@@ -285,7 +285,7 @@ static struct ctl_table net_core_table[] = {
118911 .mode = 0444,
118912 .proc_handler = proc_do_rss_key,
118913 },
118914-#ifdef CONFIG_BPF_JIT
118915+#if defined(CONFIG_BPF_JIT) && !defined(CONFIG_GRKERNSEC_BPF_HARDEN)
118916 {
118917 .procname = "bpf_jit_enable",
118918 .data = &bpf_jit_enable,
118919@@ -409,13 +409,12 @@ static struct ctl_table netns_core_table[] = {
118920
118921 static __net_init int sysctl_core_net_init(struct net *net)
118922 {
118923- struct ctl_table *tbl;
118924+ ctl_table_no_const *tbl = NULL;
118925
118926 net->core.sysctl_somaxconn = SOMAXCONN;
118927
118928- tbl = netns_core_table;
118929 if (!net_eq(net, &init_net)) {
118930- tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
118931+ tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
118932 if (tbl == NULL)
118933 goto err_dup;
118934
118935@@ -425,17 +424,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
118936 if (net->user_ns != &init_user_ns) {
118937 tbl[0].procname = NULL;
118938 }
118939- }
118940-
118941- net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
118942+ net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
118943+ } else
118944+ net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
118945 if (net->core.sysctl_hdr == NULL)
118946 goto err_reg;
118947
118948 return 0;
118949
118950 err_reg:
118951- if (tbl != netns_core_table)
118952- kfree(tbl);
118953+ kfree(tbl);
118954 err_dup:
118955 return -ENOMEM;
118956 }
118957@@ -450,7 +448,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
118958 kfree(tbl);
118959 }
118960
118961-static __net_initdata struct pernet_operations sysctl_core_ops = {
118962+static __net_initconst struct pernet_operations sysctl_core_ops = {
118963 .init = sysctl_core_net_init,
118964 .exit = sysctl_core_net_exit,
118965 };
118966diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
118967index 675cf94..9279a75 100644
118968--- a/net/decnet/af_decnet.c
118969+++ b/net/decnet/af_decnet.c
118970@@ -466,6 +466,7 @@ static struct proto dn_proto = {
118971 .sysctl_rmem = sysctl_decnet_rmem,
118972 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
118973 .obj_size = sizeof(struct dn_sock),
118974+ .slab_flags = SLAB_USERCOPY,
118975 };
118976
118977 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp, int kern)
118978diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
118979index b2c26b0..41f803e 100644
118980--- a/net/decnet/dn_dev.c
118981+++ b/net/decnet/dn_dev.c
118982@@ -201,7 +201,7 @@ static struct dn_dev_sysctl_table {
118983 .extra1 = &min_t3,
118984 .extra2 = &max_t3
118985 },
118986- {0}
118987+ { }
118988 },
118989 };
118990
118991diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
118992index 5325b54..a0d4d69 100644
118993--- a/net/decnet/sysctl_net_decnet.c
118994+++ b/net/decnet/sysctl_net_decnet.c
118995@@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
118996
118997 if (len > *lenp) len = *lenp;
118998
118999- if (copy_to_user(buffer, addr, len))
119000+ if (len > sizeof addr || copy_to_user(buffer, addr, len))
119001 return -EFAULT;
119002
119003 *lenp = len;
119004@@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
119005
119006 if (len > *lenp) len = *lenp;
119007
119008- if (copy_to_user(buffer, devname, len))
119009+ if (len > sizeof devname || copy_to_user(buffer, devname, len))
119010 return -EFAULT;
119011
119012 *lenp = len;
119013diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
119014index b445d49..13e8538 100644
119015--- a/net/dsa/dsa.c
119016+++ b/net/dsa/dsa.c
119017@@ -851,7 +851,7 @@ static struct packet_type dsa_pack_type __read_mostly = {
119018 .func = dsa_switch_rcv,
119019 };
119020
119021-static struct notifier_block dsa_netdevice_nb __read_mostly = {
119022+static struct notifier_block dsa_netdevice_nb = {
119023 .notifier_call = dsa_slave_netdevice_event,
119024 };
119025
119026diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c
119027index a2c7e4c..3dc9f67 100644
119028--- a/net/hsr/hsr_netlink.c
119029+++ b/net/hsr/hsr_netlink.c
119030@@ -102,7 +102,7 @@ nla_put_failure:
119031 return -EMSGSIZE;
119032 }
119033
119034-static struct rtnl_link_ops hsr_link_ops __read_mostly = {
119035+static struct rtnl_link_ops hsr_link_ops = {
119036 .kind = "hsr",
119037 .maxtype = IFLA_HSR_MAX,
119038 .policy = hsr_policy,
119039diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
119040index f20a387..2058892 100644
119041--- a/net/ieee802154/6lowpan/core.c
119042+++ b/net/ieee802154/6lowpan/core.c
119043@@ -191,7 +191,7 @@ static void lowpan_dellink(struct net_device *dev, struct list_head *head)
119044 dev_put(real_dev);
119045 }
119046
119047-static struct rtnl_link_ops lowpan_link_ops __read_mostly = {
119048+static struct rtnl_link_ops lowpan_link_ops = {
119049 .kind = "lowpan",
119050 .priv_size = sizeof(struct lowpan_dev_info),
119051 .setup = lowpan_setup,
119052diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
119053index 214d44a..dcb7f86 100644
119054--- a/net/ieee802154/6lowpan/reassembly.c
119055+++ b/net/ieee802154/6lowpan/reassembly.c
119056@@ -435,14 +435,13 @@ static struct ctl_table lowpan_frags_ctl_table[] = {
119057
119058 static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
119059 {
119060- struct ctl_table *table;
119061+ ctl_table_no_const *table = NULL;
119062 struct ctl_table_header *hdr;
119063 struct netns_ieee802154_lowpan *ieee802154_lowpan =
119064 net_ieee802154_lowpan(net);
119065
119066- table = lowpan_frags_ns_ctl_table;
119067 if (!net_eq(net, &init_net)) {
119068- table = kmemdup(table, sizeof(lowpan_frags_ns_ctl_table),
119069+ table = kmemdup(lowpan_frags_ns_ctl_table, sizeof(lowpan_frags_ns_ctl_table),
119070 GFP_KERNEL);
119071 if (table == NULL)
119072 goto err_alloc;
119073@@ -457,9 +456,9 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
119074 /* Don't export sysctls to unprivileged users */
119075 if (net->user_ns != &init_user_ns)
119076 table[0].procname = NULL;
119077- }
119078-
119079- hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
119080+ hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
119081+ } else
119082+ hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", lowpan_frags_ns_ctl_table);
119083 if (hdr == NULL)
119084 goto err_reg;
119085
119086@@ -467,8 +466,7 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
119087 return 0;
119088
119089 err_reg:
119090- if (!net_eq(net, &init_net))
119091- kfree(table);
119092+ kfree(table);
119093 err_alloc:
119094 return -ENOMEM;
119095 }
119096diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
119097index 9532ee8..020410a 100644
119098--- a/net/ipv4/af_inet.c
119099+++ b/net/ipv4/af_inet.c
119100@@ -1392,7 +1392,7 @@ int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)
119101 return ip_recv_error(sk, msg, len, addr_len);
119102 #if IS_ENABLED(CONFIG_IPV6)
119103 if (sk->sk_family == AF_INET6)
119104- return pingv6_ops.ipv6_recv_error(sk, msg, len, addr_len);
119105+ return pingv6_ops->ipv6_recv_error(sk, msg, len, addr_len);
119106 #endif
119107 return -EINVAL;
119108 }
119109diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
119110index 2d9cb17..20ae904 100644
119111--- a/net/ipv4/devinet.c
119112+++ b/net/ipv4/devinet.c
119113@@ -69,7 +69,8 @@
119114
119115 static struct ipv4_devconf ipv4_devconf = {
119116 .data = {
119117- [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 1,
119118+ [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 0,
119119+ [IPV4_DEVCONF_RP_FILTER - 1] = 1,
119120 [IPV4_DEVCONF_SEND_REDIRECTS - 1] = 1,
119121 [IPV4_DEVCONF_SECURE_REDIRECTS - 1] = 1,
119122 [IPV4_DEVCONF_SHARED_MEDIA - 1] = 1,
119123@@ -80,7 +81,8 @@ static struct ipv4_devconf ipv4_devconf = {
119124
119125 static struct ipv4_devconf ipv4_devconf_dflt = {
119126 .data = {
119127- [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 1,
119128+ [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 0,
119129+ [IPV4_DEVCONF_RP_FILTER - 1] = 1,
119130 [IPV4_DEVCONF_SEND_REDIRECTS - 1] = 1,
119131 [IPV4_DEVCONF_SECURE_REDIRECTS - 1] = 1,
119132 [IPV4_DEVCONF_SHARED_MEDIA - 1] = 1,
119133@@ -1579,7 +1581,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
119134 idx = 0;
119135 head = &net->dev_index_head[h];
119136 rcu_read_lock();
119137- cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
119138+ cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
119139 net->dev_base_seq;
119140 hlist_for_each_entry_rcu(dev, head, index_hlist) {
119141 if (idx < s_idx)
119142@@ -1905,7 +1907,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
119143 idx = 0;
119144 head = &net->dev_index_head[h];
119145 rcu_read_lock();
119146- cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
119147+ cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
119148 net->dev_base_seq;
119149 hlist_for_each_entry_rcu(dev, head, index_hlist) {
119150 if (idx < s_idx)
119151@@ -2146,7 +2148,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
119152 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
119153 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
119154
119155-static struct devinet_sysctl_table {
119156+static const struct devinet_sysctl_table {
119157 struct ctl_table_header *sysctl_header;
119158 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
119159 } devinet_sysctl = {
119160@@ -2280,7 +2282,7 @@ static __net_init int devinet_init_net(struct net *net)
119161 int err;
119162 struct ipv4_devconf *all, *dflt;
119163 #ifdef CONFIG_SYSCTL
119164- struct ctl_table *tbl = ctl_forward_entry;
119165+ ctl_table_no_const *tbl = NULL;
119166 struct ctl_table_header *forw_hdr;
119167 #endif
119168
119169@@ -2298,7 +2300,7 @@ static __net_init int devinet_init_net(struct net *net)
119170 goto err_alloc_dflt;
119171
119172 #ifdef CONFIG_SYSCTL
119173- tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
119174+ tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
119175 if (!tbl)
119176 goto err_alloc_ctl;
119177
119178@@ -2318,7 +2320,10 @@ static __net_init int devinet_init_net(struct net *net)
119179 goto err_reg_dflt;
119180
119181 err = -ENOMEM;
119182- forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
119183+ if (!net_eq(net, &init_net))
119184+ forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
119185+ else
119186+ forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
119187 if (!forw_hdr)
119188 goto err_reg_ctl;
119189 net->ipv4.forw_hdr = forw_hdr;
119190@@ -2334,8 +2339,7 @@ err_reg_ctl:
119191 err_reg_dflt:
119192 __devinet_sysctl_unregister(all);
119193 err_reg_all:
119194- if (tbl != ctl_forward_entry)
119195- kfree(tbl);
119196+ kfree(tbl);
119197 err_alloc_ctl:
119198 #endif
119199 if (dflt != &ipv4_devconf_dflt)
119200diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
119201index 6bbc549..28d74951 100644
119202--- a/net/ipv4/fib_frontend.c
119203+++ b/net/ipv4/fib_frontend.c
119204@@ -1083,12 +1083,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
119205 #ifdef CONFIG_IP_ROUTE_MULTIPATH
119206 fib_sync_up(dev, RTNH_F_DEAD);
119207 #endif
119208- atomic_inc(&net->ipv4.dev_addr_genid);
119209+ atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
119210 rt_cache_flush(dev_net(dev));
119211 break;
119212 case NETDEV_DOWN:
119213 fib_del_ifaddr(ifa, NULL);
119214- atomic_inc(&net->ipv4.dev_addr_genid);
119215+ atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
119216 if (!ifa->ifa_dev->ifa_list) {
119217 /* Last address was deleted from this interface.
119218 * Disable IP.
119219@@ -1127,7 +1127,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
119220 #ifdef CONFIG_IP_ROUTE_MULTIPATH
119221 fib_sync_up(dev, RTNH_F_DEAD);
119222 #endif
119223- atomic_inc(&net->ipv4.dev_addr_genid);
119224+ atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
119225 rt_cache_flush(net);
119226 break;
119227 case NETDEV_DOWN:
119228diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
119229index 3a06586..1020c5b 100644
119230--- a/net/ipv4/fib_semantics.c
119231+++ b/net/ipv4/fib_semantics.c
119232@@ -755,7 +755,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
119233 nh->nh_saddr = inet_select_addr(nh->nh_dev,
119234 nh->nh_gw,
119235 nh->nh_parent->fib_scope);
119236- nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
119237+ nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
119238
119239 return nh->nh_saddr;
119240 }
119241diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
119242index 1349571..e136d6e 100644
119243--- a/net/ipv4/inet_connection_sock.c
119244+++ b/net/ipv4/inet_connection_sock.c
119245@@ -728,8 +728,8 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
119246 newsk->sk_write_space = sk_stream_write_space;
119247
119248 newsk->sk_mark = inet_rsk(req)->ir_mark;
119249- atomic64_set(&newsk->sk_cookie,
119250- atomic64_read(&inet_rsk(req)->ir_cookie));
119251+ atomic64_set_unchecked(&newsk->sk_cookie,
119252+ atomic64_read_unchecked(&inet_rsk(req)->ir_cookie));
119253
119254 newicsk->icsk_retransmits = 0;
119255 newicsk->icsk_backoff = 0;
119256diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
119257index 0cb9165..8589720 100644
119258--- a/net/ipv4/inet_hashtables.c
119259+++ b/net/ipv4/inet_hashtables.c
119260@@ -19,6 +19,7 @@
119261 #include <linux/slab.h>
119262 #include <linux/wait.h>
119263 #include <linux/vmalloc.h>
119264+#include <linux/security.h>
119265
119266 #include <net/inet_connection_sock.h>
119267 #include <net/inet_hashtables.h>
119268@@ -54,6 +55,8 @@ u32 sk_ehashfn(const struct sock *sk)
119269 sk->sk_daddr, sk->sk_dport);
119270 }
119271
119272+extern void gr_update_task_in_ip_table(const struct inet_sock *inet);
119273+
119274 /*
119275 * Allocate and initialize a new local port bind bucket.
119276 * The bindhash mutex for snum's hash chain must be held here.
119277@@ -566,6 +569,8 @@ ok:
119278 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
119279 spin_unlock(&head->lock);
119280
119281+ gr_update_task_in_ip_table(inet_sk(sk));
119282+
119283 if (tw) {
119284 inet_twsk_deschedule(tw);
119285 while (twrefcnt) {
119286diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
119287index 2ffbd16..6e94995 100644
119288--- a/net/ipv4/inet_timewait_sock.c
119289+++ b/net/ipv4/inet_timewait_sock.c
119290@@ -214,7 +214,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,
119291 tw->tw_ipv6only = 0;
119292 tw->tw_transparent = inet->transparent;
119293 tw->tw_prot = sk->sk_prot_creator;
119294- atomic64_set(&tw->tw_cookie, atomic64_read(&sk->sk_cookie));
119295+ atomic64_set_unchecked(&tw->tw_cookie, atomic64_read_unchecked(&sk->sk_cookie));
119296 twsk_net_set(tw, sock_net(sk));
119297 setup_timer(&tw->tw_timer, tw_timer_handler, (unsigned long)tw);
119298 /*
119299diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
119300index 241afd7..31b95d5 100644
119301--- a/net/ipv4/inetpeer.c
119302+++ b/net/ipv4/inetpeer.c
119303@@ -461,7 +461,7 @@ relookup:
119304 if (p) {
119305 p->daddr = *daddr;
119306 atomic_set(&p->refcnt, 1);
119307- atomic_set(&p->rid, 0);
119308+ atomic_set_unchecked(&p->rid, 0);
119309 p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW;
119310 p->rate_tokens = 0;
119311 /* 60*HZ is arbitrary, but chosen enough high so that the first
119312diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
119313index 921138f..1e011ff 100644
119314--- a/net/ipv4/ip_fragment.c
119315+++ b/net/ipv4/ip_fragment.c
119316@@ -276,7 +276,7 @@ static int ip_frag_too_far(struct ipq *qp)
119317 return 0;
119318
119319 start = qp->rid;
119320- end = atomic_inc_return(&peer->rid);
119321+ end = atomic_inc_return_unchecked(&peer->rid);
119322 qp->rid = end;
119323
119324 rc = qp->q.fragments && (end - start) > max;
119325@@ -780,12 +780,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
119326
119327 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
119328 {
119329- struct ctl_table *table;
119330+ ctl_table_no_const *table = NULL;
119331 struct ctl_table_header *hdr;
119332
119333- table = ip4_frags_ns_ctl_table;
119334 if (!net_eq(net, &init_net)) {
119335- table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
119336+ table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
119337 if (!table)
119338 goto err_alloc;
119339
119340@@ -799,9 +798,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
119341 /* Don't export sysctls to unprivileged users */
119342 if (net->user_ns != &init_user_ns)
119343 table[0].procname = NULL;
119344- }
119345+ hdr = register_net_sysctl(net, "net/ipv4", table);
119346+ } else
119347+ hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
119348
119349- hdr = register_net_sysctl(net, "net/ipv4", table);
119350 if (!hdr)
119351 goto err_reg;
119352
119353@@ -809,8 +809,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
119354 return 0;
119355
119356 err_reg:
119357- if (!net_eq(net, &init_net))
119358- kfree(table);
119359+ kfree(table);
119360 err_alloc:
119361 return -ENOMEM;
119362 }
119363diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
119364index 5fd7064..d13d75f 100644
119365--- a/net/ipv4/ip_gre.c
119366+++ b/net/ipv4/ip_gre.c
119367@@ -115,7 +115,7 @@ static bool log_ecn_error = true;
119368 module_param(log_ecn_error, bool, 0644);
119369 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
119370
119371-static struct rtnl_link_ops ipgre_link_ops __read_mostly;
119372+static struct rtnl_link_ops ipgre_link_ops;
119373 static int ipgre_tunnel_init(struct net_device *dev);
119374
119375 static int ipgre_net_id __read_mostly;
119376@@ -819,7 +819,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
119377 [IFLA_GRE_ENCAP_DPORT] = { .type = NLA_U16 },
119378 };
119379
119380-static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
119381+static struct rtnl_link_ops ipgre_link_ops = {
119382 .kind = "gre",
119383 .maxtype = IFLA_GRE_MAX,
119384 .policy = ipgre_policy,
119385@@ -834,7 +834,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
119386 .get_link_net = ip_tunnel_get_link_net,
119387 };
119388
119389-static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
119390+static struct rtnl_link_ops ipgre_tap_ops = {
119391 .kind = "gretap",
119392 .maxtype = IFLA_GRE_MAX,
119393 .policy = ipgre_policy,
119394diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
119395index 2db4c87..4db9282 100644
119396--- a/net/ipv4/ip_input.c
119397+++ b/net/ipv4/ip_input.c
119398@@ -147,6 +147,10 @@
119399 #include <linux/mroute.h>
119400 #include <linux/netlink.h>
119401
119402+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119403+extern int grsec_enable_blackhole;
119404+#endif
119405+
119406 /*
119407 * Process Router Attention IP option (RFC 2113)
119408 */
119409@@ -223,6 +227,9 @@ static int ip_local_deliver_finish(struct sock *sk, struct sk_buff *skb)
119410 if (!raw) {
119411 if (xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
119412 IP_INC_STATS_BH(net, IPSTATS_MIB_INUNKNOWNPROTOS);
119413+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119414+ if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
119415+#endif
119416 icmp_send(skb, ICMP_DEST_UNREACH,
119417 ICMP_PROT_UNREACH, 0);
119418 }
119419diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
119420index c3c359a..504edc6 100644
119421--- a/net/ipv4/ip_sockglue.c
119422+++ b/net/ipv4/ip_sockglue.c
119423@@ -1295,7 +1295,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
119424 len = min_t(unsigned int, len, opt->optlen);
119425 if (put_user(len, optlen))
119426 return -EFAULT;
119427- if (copy_to_user(optval, opt->__data, len))
119428+ if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
119429+ copy_to_user(optval, opt->__data, len))
119430 return -EFAULT;
119431 return 0;
119432 }
119433@@ -1432,7 +1433,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
119434 if (sk->sk_type != SOCK_STREAM)
119435 return -ENOPROTOOPT;
119436
119437- msg.msg_control = (__force void *) optval;
119438+ msg.msg_control = (__force_kernel void *) optval;
119439 msg.msg_controllen = len;
119440 msg.msg_flags = flags;
119441
119442diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
119443index 0c15208..a3a76c5 100644
119444--- a/net/ipv4/ip_vti.c
119445+++ b/net/ipv4/ip_vti.c
119446@@ -45,7 +45,7 @@
119447 #include <net/net_namespace.h>
119448 #include <net/netns/generic.h>
119449
119450-static struct rtnl_link_ops vti_link_ops __read_mostly;
119451+static struct rtnl_link_ops vti_link_ops;
119452
119453 static int vti_net_id __read_mostly;
119454 static int vti_tunnel_init(struct net_device *dev);
119455@@ -525,7 +525,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
119456 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
119457 };
119458
119459-static struct rtnl_link_ops vti_link_ops __read_mostly = {
119460+static struct rtnl_link_ops vti_link_ops = {
119461 .kind = "vti",
119462 .maxtype = IFLA_VTI_MAX,
119463 .policy = vti_policy,
119464diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
119465index 8e7328c..9bd7ed3 100644
119466--- a/net/ipv4/ipconfig.c
119467+++ b/net/ipv4/ipconfig.c
119468@@ -333,7 +333,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
119469
119470 mm_segment_t oldfs = get_fs();
119471 set_fs(get_ds());
119472- res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
119473+ res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
119474 set_fs(oldfs);
119475 return res;
119476 }
119477@@ -344,7 +344,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
119478
119479 mm_segment_t oldfs = get_fs();
119480 set_fs(get_ds());
119481- res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
119482+ res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
119483 set_fs(oldfs);
119484 return res;
119485 }
119486@@ -355,7 +355,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
119487
119488 mm_segment_t oldfs = get_fs();
119489 set_fs(get_ds());
119490- res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
119491+ res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
119492 set_fs(oldfs);
119493 return res;
119494 }
119495diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
119496index 254238d..82c19a2 100644
119497--- a/net/ipv4/ipip.c
119498+++ b/net/ipv4/ipip.c
119499@@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
119500 static int ipip_net_id __read_mostly;
119501
119502 static int ipip_tunnel_init(struct net_device *dev);
119503-static struct rtnl_link_ops ipip_link_ops __read_mostly;
119504+static struct rtnl_link_ops ipip_link_ops;
119505
119506 static int ipip_err(struct sk_buff *skb, u32 info)
119507 {
119508@@ -488,7 +488,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
119509 [IFLA_IPTUN_ENCAP_DPORT] = { .type = NLA_U16 },
119510 };
119511
119512-static struct rtnl_link_ops ipip_link_ops __read_mostly = {
119513+static struct rtnl_link_ops ipip_link_ops = {
119514 .kind = "ipip",
119515 .maxtype = IFLA_IPTUN_MAX,
119516 .policy = ipip_policy,
119517diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
119518index 92305a1..0a5b349 100644
119519--- a/net/ipv4/netfilter/arp_tables.c
119520+++ b/net/ipv4/netfilter/arp_tables.c
119521@@ -896,14 +896,14 @@ static int compat_table_info(const struct xt_table_info *info,
119522 #endif
119523
119524 static int get_info(struct net *net, void __user *user,
119525- const int *len, int compat)
119526+ int len, int compat)
119527 {
119528 char name[XT_TABLE_MAXNAMELEN];
119529 struct xt_table *t;
119530 int ret;
119531
119532- if (*len != sizeof(struct arpt_getinfo)) {
119533- duprintf("length %u != %Zu\n", *len,
119534+ if (len != sizeof(struct arpt_getinfo)) {
119535+ duprintf("length %u != %Zu\n", len,
119536 sizeof(struct arpt_getinfo));
119537 return -EINVAL;
119538 }
119539@@ -940,7 +940,7 @@ static int get_info(struct net *net, void __user *user,
119540 info.size = private->size;
119541 strcpy(info.name, name);
119542
119543- if (copy_to_user(user, &info, *len) != 0)
119544+ if (copy_to_user(user, &info, len) != 0)
119545 ret = -EFAULT;
119546 else
119547 ret = 0;
119548@@ -1705,7 +1705,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
119549
119550 switch (cmd) {
119551 case ARPT_SO_GET_INFO:
119552- ret = get_info(sock_net(sk), user, len, 1);
119553+ ret = get_info(sock_net(sk), user, *len, 1);
119554 break;
119555 case ARPT_SO_GET_ENTRIES:
119556 ret = compat_get_entries(sock_net(sk), user, len);
119557@@ -1750,7 +1750,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
119558
119559 switch (cmd) {
119560 case ARPT_SO_GET_INFO:
119561- ret = get_info(sock_net(sk), user, len, 0);
119562+ ret = get_info(sock_net(sk), user, *len, 0);
119563 break;
119564
119565 case ARPT_SO_GET_ENTRIES:
119566diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
119567index 6c72fbb..ce47b05 100644
119568--- a/net/ipv4/netfilter/ip_tables.c
119569+++ b/net/ipv4/netfilter/ip_tables.c
119570@@ -1073,14 +1073,14 @@ static int compat_table_info(const struct xt_table_info *info,
119571 #endif
119572
119573 static int get_info(struct net *net, void __user *user,
119574- const int *len, int compat)
119575+ int len, int compat)
119576 {
119577 char name[XT_TABLE_MAXNAMELEN];
119578 struct xt_table *t;
119579 int ret;
119580
119581- if (*len != sizeof(struct ipt_getinfo)) {
119582- duprintf("length %u != %zu\n", *len,
119583+ if (len != sizeof(struct ipt_getinfo)) {
119584+ duprintf("length %u != %zu\n", len,
119585 sizeof(struct ipt_getinfo));
119586 return -EINVAL;
119587 }
119588@@ -1117,7 +1117,7 @@ static int get_info(struct net *net, void __user *user,
119589 info.size = private->size;
119590 strcpy(info.name, name);
119591
119592- if (copy_to_user(user, &info, *len) != 0)
119593+ if (copy_to_user(user, &info, len) != 0)
119594 ret = -EFAULT;
119595 else
119596 ret = 0;
119597@@ -1968,7 +1968,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
119598
119599 switch (cmd) {
119600 case IPT_SO_GET_INFO:
119601- ret = get_info(sock_net(sk), user, len, 1);
119602+ ret = get_info(sock_net(sk), user, *len, 1);
119603 break;
119604 case IPT_SO_GET_ENTRIES:
119605 ret = compat_get_entries(sock_net(sk), user, len);
119606@@ -2015,7 +2015,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
119607
119608 switch (cmd) {
119609 case IPT_SO_GET_INFO:
119610- ret = get_info(sock_net(sk), user, len, 0);
119611+ ret = get_info(sock_net(sk), user, *len, 0);
119612 break;
119613
119614 case IPT_SO_GET_ENTRIES:
119615diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
119616index 45cb16a..cef4ecd 100644
119617--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
119618+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
119619@@ -730,7 +730,7 @@ static int clusterip_net_init(struct net *net)
119620 spin_lock_init(&cn->lock);
119621
119622 #ifdef CONFIG_PROC_FS
119623- cn->procdir = proc_mkdir("ipt_CLUSTERIP", net->proc_net);
119624+ cn->procdir = proc_mkdir_restrict("ipt_CLUSTERIP", net->proc_net);
119625 if (!cn->procdir) {
119626 pr_err("Unable to proc dir entry\n");
119627 return -ENOMEM;
119628diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
119629index 05ff44b..da00000 100644
119630--- a/net/ipv4/ping.c
119631+++ b/net/ipv4/ping.c
119632@@ -59,7 +59,7 @@ struct ping_table {
119633 };
119634
119635 static struct ping_table ping_table;
119636-struct pingv6_ops pingv6_ops;
119637+struct pingv6_ops *pingv6_ops;
119638 EXPORT_SYMBOL_GPL(pingv6_ops);
119639
119640 static u16 ping_port_rover;
119641@@ -359,7 +359,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
119642 return -ENODEV;
119643 }
119644 }
119645- has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
119646+ has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
119647 scoped);
119648 rcu_read_unlock();
119649
119650@@ -567,7 +567,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
119651 }
119652 #if IS_ENABLED(CONFIG_IPV6)
119653 } else if (skb->protocol == htons(ETH_P_IPV6)) {
119654- harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
119655+ harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
119656 #endif
119657 }
119658
119659@@ -585,7 +585,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
119660 info, (u8 *)icmph);
119661 #if IS_ENABLED(CONFIG_IPV6)
119662 } else if (family == AF_INET6) {
119663- pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
119664+ pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
119665 info, (u8 *)icmph);
119666 #endif
119667 }
119668@@ -918,10 +918,10 @@ int ping_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
119669 }
119670
119671 if (inet6_sk(sk)->rxopt.all)
119672- pingv6_ops.ip6_datagram_recv_common_ctl(sk, msg, skb);
119673+ pingv6_ops->ip6_datagram_recv_common_ctl(sk, msg, skb);
119674 if (skb->protocol == htons(ETH_P_IPV6) &&
119675 inet6_sk(sk)->rxopt.all)
119676- pingv6_ops.ip6_datagram_recv_specific_ctl(sk, msg, skb);
119677+ pingv6_ops->ip6_datagram_recv_specific_ctl(sk, msg, skb);
119678 else if (skb->protocol == htons(ETH_P_IP) && isk->cmsg_flags)
119679 ip_cmsg_recv(msg, skb);
119680 #endif
119681@@ -1116,7 +1116,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
119682 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
119683 0, sock_i_ino(sp),
119684 atomic_read(&sp->sk_refcnt), sp,
119685- atomic_read(&sp->sk_drops));
119686+ atomic_read_unchecked(&sp->sk_drops));
119687 }
119688
119689 static int ping_v4_seq_show(struct seq_file *seq, void *v)
119690diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
119691index 561cd4b..a32a155 100644
119692--- a/net/ipv4/raw.c
119693+++ b/net/ipv4/raw.c
119694@@ -323,7 +323,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
119695 int raw_rcv(struct sock *sk, struct sk_buff *skb)
119696 {
119697 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
119698- atomic_inc(&sk->sk_drops);
119699+ atomic_inc_unchecked(&sk->sk_drops);
119700 kfree_skb(skb);
119701 return NET_RX_DROP;
119702 }
119703@@ -771,16 +771,20 @@ static int raw_init(struct sock *sk)
119704
119705 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
119706 {
119707+ struct icmp_filter filter;
119708+
119709 if (optlen > sizeof(struct icmp_filter))
119710 optlen = sizeof(struct icmp_filter);
119711- if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
119712+ if (copy_from_user(&filter, optval, optlen))
119713 return -EFAULT;
119714+ raw_sk(sk)->filter = filter;
119715 return 0;
119716 }
119717
119718 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
119719 {
119720 int len, ret = -EFAULT;
119721+ struct icmp_filter filter;
119722
119723 if (get_user(len, optlen))
119724 goto out;
119725@@ -790,8 +794,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
119726 if (len > sizeof(struct icmp_filter))
119727 len = sizeof(struct icmp_filter);
119728 ret = -EFAULT;
119729- if (put_user(len, optlen) ||
119730- copy_to_user(optval, &raw_sk(sk)->filter, len))
119731+ filter = raw_sk(sk)->filter;
119732+ if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
119733 goto out;
119734 ret = 0;
119735 out: return ret;
119736@@ -1020,7 +1024,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
119737 0, 0L, 0,
119738 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
119739 0, sock_i_ino(sp),
119740- atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
119741+ atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
119742 }
119743
119744 static int raw_seq_show(struct seq_file *seq, void *v)
119745diff --git a/net/ipv4/route.c b/net/ipv4/route.c
119746index e681b85..8a43a65 100644
119747--- a/net/ipv4/route.c
119748+++ b/net/ipv4/route.c
119749@@ -227,7 +227,7 @@ static const struct seq_operations rt_cache_seq_ops = {
119750
119751 static int rt_cache_seq_open(struct inode *inode, struct file *file)
119752 {
119753- return seq_open(file, &rt_cache_seq_ops);
119754+ return seq_open_restrict(file, &rt_cache_seq_ops);
119755 }
119756
119757 static const struct file_operations rt_cache_seq_fops = {
119758@@ -318,7 +318,7 @@ static const struct seq_operations rt_cpu_seq_ops = {
119759
119760 static int rt_cpu_seq_open(struct inode *inode, struct file *file)
119761 {
119762- return seq_open(file, &rt_cpu_seq_ops);
119763+ return seq_open_restrict(file, &rt_cpu_seq_ops);
119764 }
119765
119766 static const struct file_operations rt_cpu_seq_fops = {
119767@@ -356,7 +356,7 @@ static int rt_acct_proc_show(struct seq_file *m, void *v)
119768
119769 static int rt_acct_proc_open(struct inode *inode, struct file *file)
119770 {
119771- return single_open(file, rt_acct_proc_show, NULL);
119772+ return single_open_restrict(file, rt_acct_proc_show, NULL);
119773 }
119774
119775 static const struct file_operations rt_acct_proc_fops = {
119776@@ -458,7 +458,7 @@ static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst,
119777
119778 #define IP_IDENTS_SZ 2048u
119779
119780-static atomic_t *ip_idents __read_mostly;
119781+static atomic_unchecked_t ip_idents[IP_IDENTS_SZ] __read_mostly;
119782 static u32 *ip_tstamps __read_mostly;
119783
119784 /* In order to protect privacy, we add a perturbation to identifiers
119785@@ -468,7 +468,7 @@ static u32 *ip_tstamps __read_mostly;
119786 u32 ip_idents_reserve(u32 hash, int segs)
119787 {
119788 u32 *p_tstamp = ip_tstamps + hash % IP_IDENTS_SZ;
119789- atomic_t *p_id = ip_idents + hash % IP_IDENTS_SZ;
119790+ atomic_unchecked_t *p_id = ip_idents + hash % IP_IDENTS_SZ;
119791 u32 old = ACCESS_ONCE(*p_tstamp);
119792 u32 now = (u32)jiffies;
119793 u32 delta = 0;
119794@@ -476,7 +476,7 @@ u32 ip_idents_reserve(u32 hash, int segs)
119795 if (old != now && cmpxchg(p_tstamp, old, now) == old)
119796 delta = prandom_u32_max(now - old);
119797
119798- return atomic_add_return(segs + delta, p_id) - segs;
119799+ return atomic_add_return_unchecked(segs + delta, p_id) - segs;
119800 }
119801 EXPORT_SYMBOL(ip_idents_reserve);
119802
119803@@ -2640,34 +2640,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
119804 .maxlen = sizeof(int),
119805 .mode = 0200,
119806 .proc_handler = ipv4_sysctl_rtcache_flush,
119807+ .extra1 = &init_net,
119808 },
119809 { },
119810 };
119811
119812 static __net_init int sysctl_route_net_init(struct net *net)
119813 {
119814- struct ctl_table *tbl;
119815+ ctl_table_no_const *tbl = NULL;
119816
119817- tbl = ipv4_route_flush_table;
119818 if (!net_eq(net, &init_net)) {
119819- tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
119820+ tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
119821 if (!tbl)
119822 goto err_dup;
119823
119824 /* Don't export sysctls to unprivileged users */
119825 if (net->user_ns != &init_user_ns)
119826 tbl[0].procname = NULL;
119827- }
119828- tbl[0].extra1 = net;
119829+ tbl[0].extra1 = net;
119830+ net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
119831+ } else
119832+ net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
119833
119834- net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
119835 if (!net->ipv4.route_hdr)
119836 goto err_reg;
119837 return 0;
119838
119839 err_reg:
119840- if (tbl != ipv4_route_flush_table)
119841- kfree(tbl);
119842+ kfree(tbl);
119843 err_dup:
119844 return -ENOMEM;
119845 }
119846@@ -2690,8 +2690,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
119847
119848 static __net_init int rt_genid_init(struct net *net)
119849 {
119850- atomic_set(&net->ipv4.rt_genid, 0);
119851- atomic_set(&net->fnhe_genid, 0);
119852+ atomic_set_unchecked(&net->ipv4.rt_genid, 0);
119853+ atomic_set_unchecked(&net->fnhe_genid, 0);
119854 get_random_bytes(&net->ipv4.dev_addr_genid,
119855 sizeof(net->ipv4.dev_addr_genid));
119856 return 0;
119857@@ -2735,11 +2735,7 @@ int __init ip_rt_init(void)
119858 int rc = 0;
119859 int cpu;
119860
119861- ip_idents = kmalloc(IP_IDENTS_SZ * sizeof(*ip_idents), GFP_KERNEL);
119862- if (!ip_idents)
119863- panic("IP: failed to allocate ip_idents\n");
119864-
119865- prandom_bytes(ip_idents, IP_IDENTS_SZ * sizeof(*ip_idents));
119866+ prandom_bytes(ip_idents, sizeof(ip_idents));
119867
119868 ip_tstamps = kcalloc(IP_IDENTS_SZ, sizeof(*ip_tstamps), GFP_KERNEL);
119869 if (!ip_tstamps)
119870diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
119871index 0330ab2..4745d2c 100644
119872--- a/net/ipv4/sysctl_net_ipv4.c
119873+++ b/net/ipv4/sysctl_net_ipv4.c
119874@@ -66,7 +66,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
119875 container_of(table->data, struct net, ipv4.ip_local_ports.range);
119876 int ret;
119877 int range[2];
119878- struct ctl_table tmp = {
119879+ ctl_table_no_const tmp = {
119880 .data = &range,
119881 .maxlen = sizeof(range),
119882 .mode = table->mode,
119883@@ -124,7 +124,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
119884 int ret;
119885 gid_t urange[2];
119886 kgid_t low, high;
119887- struct ctl_table tmp = {
119888+ ctl_table_no_const tmp = {
119889 .data = &urange,
119890 .maxlen = sizeof(urange),
119891 .mode = table->mode,
119892@@ -155,7 +155,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
119893 void __user *buffer, size_t *lenp, loff_t *ppos)
119894 {
119895 char val[TCP_CA_NAME_MAX];
119896- struct ctl_table tbl = {
119897+ ctl_table_no_const tbl = {
119898 .data = val,
119899 .maxlen = TCP_CA_NAME_MAX,
119900 };
119901@@ -174,7 +174,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
119902 void __user *buffer, size_t *lenp,
119903 loff_t *ppos)
119904 {
119905- struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
119906+ ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
119907 int ret;
119908
119909 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
119910@@ -191,7 +191,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
119911 void __user *buffer, size_t *lenp,
119912 loff_t *ppos)
119913 {
119914- struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
119915+ ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
119916 int ret;
119917
119918 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
119919@@ -210,7 +210,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
119920 void __user *buffer, size_t *lenp,
119921 loff_t *ppos)
119922 {
119923- struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
119924+ ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
119925 struct tcp_fastopen_context *ctxt;
119926 int ret;
119927 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
119928@@ -915,13 +915,12 @@ static struct ctl_table ipv4_net_table[] = {
119929
119930 static __net_init int ipv4_sysctl_init_net(struct net *net)
119931 {
119932- struct ctl_table *table;
119933+ ctl_table_no_const *table = NULL;
119934
119935- table = ipv4_net_table;
119936 if (!net_eq(net, &init_net)) {
119937 int i;
119938
119939- table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
119940+ table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
119941 if (!table)
119942 goto err_alloc;
119943
119944@@ -930,7 +929,10 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
119945 table[i].data += (void *)net - (void *)&init_net;
119946 }
119947
119948- net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
119949+ if (!net_eq(net, &init_net))
119950+ net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
119951+ else
119952+ net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
119953 if (!net->ipv4.ipv4_hdr)
119954 goto err_reg;
119955
119956diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
119957index 728f5b3..dc51cbe 100644
119958--- a/net/ipv4/tcp_input.c
119959+++ b/net/ipv4/tcp_input.c
119960@@ -767,7 +767,7 @@ static void tcp_update_pacing_rate(struct sock *sk)
119961 * without any lock. We want to make sure compiler wont store
119962 * intermediate values in this location.
119963 */
119964- ACCESS_ONCE(sk->sk_pacing_rate) = min_t(u64, rate,
119965+ ACCESS_ONCE_RW(sk->sk_pacing_rate) = min_t(u64, rate,
119966 sk->sk_max_pacing_rate);
119967 }
119968
119969@@ -4608,7 +4608,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
119970 * simplifies code)
119971 */
119972 static void
119973-tcp_collapse(struct sock *sk, struct sk_buff_head *list,
119974+__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
119975 struct sk_buff *head, struct sk_buff *tail,
119976 u32 start, u32 end)
119977 {
119978@@ -5603,6 +5603,7 @@ discard:
119979 tcp_paws_reject(&tp->rx_opt, 0))
119980 goto discard_and_undo;
119981
119982+#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
119983 if (th->syn) {
119984 /* We see SYN without ACK. It is attempt of
119985 * simultaneous connect with crossed SYNs.
119986@@ -5653,6 +5654,7 @@ discard:
119987 goto discard;
119988 #endif
119989 }
119990+#endif
119991 /* "fifth, if neither of the SYN or RST bits is set then
119992 * drop the segment and return."
119993 */
119994@@ -5699,7 +5701,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
119995 goto discard;
119996
119997 if (th->syn) {
119998- if (th->fin)
119999+ if (th->fin || th->urg || th->psh)
120000 goto discard;
120001 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
120002 return 1;
120003@@ -6026,7 +6028,7 @@ struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops,
120004
120005 kmemcheck_annotate_bitfield(ireq, flags);
120006 ireq->opt = NULL;
120007- atomic64_set(&ireq->ir_cookie, 0);
120008+ atomic64_set_unchecked(&ireq->ir_cookie, 0);
120009 ireq->ireq_state = TCP_NEW_SYN_RECV;
120010 write_pnet(&ireq->ireq_net, sock_net(sk_listener));
120011 ireq->ireq_family = sk_listener->sk_family;
120012diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
120013index 0ea2e1c..a4d1c48 100644
120014--- a/net/ipv4/tcp_ipv4.c
120015+++ b/net/ipv4/tcp_ipv4.c
120016@@ -89,6 +89,10 @@ int sysctl_tcp_tw_reuse __read_mostly;
120017 int sysctl_tcp_low_latency __read_mostly;
120018 EXPORT_SYMBOL(sysctl_tcp_low_latency);
120019
120020+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120021+extern int grsec_enable_blackhole;
120022+#endif
120023+
120024 #ifdef CONFIG_TCP_MD5SIG
120025 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
120026 __be32 daddr, __be32 saddr, const struct tcphdr *th);
120027@@ -1427,6 +1431,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
120028 return 0;
120029
120030 reset:
120031+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120032+ if (!grsec_enable_blackhole)
120033+#endif
120034 tcp_v4_send_reset(rsk, skb);
120035 discard:
120036 kfree_skb(skb);
120037@@ -1591,12 +1598,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
120038 TCP_SKB_CB(skb)->sacked = 0;
120039
120040 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
120041- if (!sk)
120042+ if (!sk) {
120043+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120044+ ret = 1;
120045+#endif
120046 goto no_tcp_socket;
120047-
120048+ }
120049 process:
120050- if (sk->sk_state == TCP_TIME_WAIT)
120051+ if (sk->sk_state == TCP_TIME_WAIT) {
120052+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120053+ ret = 2;
120054+#endif
120055 goto do_time_wait;
120056+ }
120057
120058 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
120059 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
120060@@ -1653,6 +1667,10 @@ csum_error:
120061 bad_packet:
120062 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
120063 } else {
120064+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120065+ if (!grsec_enable_blackhole || (ret == 1 &&
120066+ (skb->dev->flags & IFF_LOOPBACK)))
120067+#endif
120068 tcp_v4_send_reset(NULL, skb);
120069 }
120070
120071diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
120072index 4bc00cb..d024adf 100644
120073--- a/net/ipv4/tcp_minisocks.c
120074+++ b/net/ipv4/tcp_minisocks.c
120075@@ -27,6 +27,10 @@
120076 #include <net/inet_common.h>
120077 #include <net/xfrm.h>
120078
120079+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120080+extern int grsec_enable_blackhole;
120081+#endif
120082+
120083 int sysctl_tcp_syncookies __read_mostly = 1;
120084 EXPORT_SYMBOL(sysctl_tcp_syncookies);
120085
120086@@ -782,7 +786,10 @@ embryonic_reset:
120087 * avoid becoming vulnerable to outside attack aiming at
120088 * resetting legit local connections.
120089 */
120090- req->rsk_ops->send_reset(sk, skb);
120091+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120092+ if (!grsec_enable_blackhole)
120093+#endif
120094+ req->rsk_ops->send_reset(sk, skb);
120095 } else if (fastopen) { /* received a valid RST pkt */
120096 reqsk_fastopen_remove(sk, req, true);
120097 tcp_reset(sk);
120098diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
120099index ebf5ff5..4d1ff32 100644
120100--- a/net/ipv4/tcp_probe.c
120101+++ b/net/ipv4/tcp_probe.c
120102@@ -236,7 +236,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
120103 if (cnt + width >= len)
120104 break;
120105
120106- if (copy_to_user(buf + cnt, tbuf, width))
120107+ if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
120108 return -EFAULT;
120109 cnt += width;
120110 }
120111diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
120112index 5b752f5..9594bb2 100644
120113--- a/net/ipv4/tcp_timer.c
120114+++ b/net/ipv4/tcp_timer.c
120115@@ -22,6 +22,10 @@
120116 #include <linux/gfp.h>
120117 #include <net/tcp.h>
120118
120119+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120120+extern int grsec_lastack_retries;
120121+#endif
120122+
120123 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
120124 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
120125 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
120126@@ -195,6 +199,13 @@ static int tcp_write_timeout(struct sock *sk)
120127 }
120128 }
120129
120130+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120131+ if ((sk->sk_state == TCP_LAST_ACK) &&
120132+ (grsec_lastack_retries > 0) &&
120133+ (grsec_lastack_retries < retry_until))
120134+ retry_until = grsec_lastack_retries;
120135+#endif
120136+
120137 if (retransmits_timed_out(sk, retry_until,
120138 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
120139 /* Has it gone just too far? */
120140diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
120141index 1b8c5ba..e1f0542 100644
120142--- a/net/ipv4/udp.c
120143+++ b/net/ipv4/udp.c
120144@@ -87,6 +87,7 @@
120145 #include <linux/types.h>
120146 #include <linux/fcntl.h>
120147 #include <linux/module.h>
120148+#include <linux/security.h>
120149 #include <linux/socket.h>
120150 #include <linux/sockios.h>
120151 #include <linux/igmp.h>
120152@@ -115,6 +116,10 @@
120153 #include <net/busy_poll.h>
120154 #include "udp_impl.h"
120155
120156+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120157+extern int grsec_enable_blackhole;
120158+#endif
120159+
120160 struct udp_table udp_table __read_mostly;
120161 EXPORT_SYMBOL(udp_table);
120162
120163@@ -608,6 +613,9 @@ static inline bool __udp_is_mcast_sock(struct net *net, struct sock *sk,
120164 return true;
120165 }
120166
120167+extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
120168+extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
120169+
120170 /*
120171 * This routine is called by the ICMP module when it gets some
120172 * sort of error condition. If err < 0 then the socket should
120173@@ -944,9 +952,18 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
120174 dport = usin->sin_port;
120175 if (dport == 0)
120176 return -EINVAL;
120177+
120178+ err = gr_search_udp_sendmsg(sk, usin);
120179+ if (err)
120180+ return err;
120181 } else {
120182 if (sk->sk_state != TCP_ESTABLISHED)
120183 return -EDESTADDRREQ;
120184+
120185+ err = gr_search_udp_sendmsg(sk, NULL);
120186+ if (err)
120187+ return err;
120188+
120189 daddr = inet->inet_daddr;
120190 dport = inet->inet_dport;
120191 /* Open fast path for connected socket.
120192@@ -1193,7 +1210,7 @@ static unsigned int first_packet_length(struct sock *sk)
120193 IS_UDPLITE(sk));
120194 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
120195 IS_UDPLITE(sk));
120196- atomic_inc(&sk->sk_drops);
120197+ atomic_inc_unchecked(&sk->sk_drops);
120198 __skb_unlink(skb, rcvq);
120199 __skb_queue_tail(&list_kill, skb);
120200 }
120201@@ -1273,6 +1290,10 @@ try_again:
120202 if (!skb)
120203 goto out;
120204
120205+ err = gr_search_udp_recvmsg(sk, skb);
120206+ if (err)
120207+ goto out_free;
120208+
120209 ulen = skb->len - sizeof(struct udphdr);
120210 copied = len;
120211 if (copied > ulen)
120212@@ -1305,7 +1326,7 @@ try_again:
120213 if (unlikely(err)) {
120214 trace_kfree_skb(skb, udp_recvmsg);
120215 if (!peeked) {
120216- atomic_inc(&sk->sk_drops);
120217+ atomic_inc_unchecked(&sk->sk_drops);
120218 UDP_INC_STATS_USER(sock_net(sk),
120219 UDP_MIB_INERRORS, is_udplite);
120220 }
120221@@ -1599,7 +1620,7 @@ csum_error:
120222 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
120223 drop:
120224 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
120225- atomic_inc(&sk->sk_drops);
120226+ atomic_inc_unchecked(&sk->sk_drops);
120227 kfree_skb(skb);
120228 return -1;
120229 }
120230@@ -1617,7 +1638,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
120231 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
120232
120233 if (!skb1) {
120234- atomic_inc(&sk->sk_drops);
120235+ atomic_inc_unchecked(&sk->sk_drops);
120236 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
120237 IS_UDPLITE(sk));
120238 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
120239@@ -1823,6 +1844,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
120240 goto csum_error;
120241
120242 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
120243+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120244+ if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
120245+#endif
120246 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
120247
120248 /*
120249@@ -2427,7 +2451,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
120250 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
120251 0, sock_i_ino(sp),
120252 atomic_read(&sp->sk_refcnt), sp,
120253- atomic_read(&sp->sk_drops));
120254+ atomic_read_unchecked(&sp->sk_drops));
120255 }
120256
120257 int udp4_seq_show(struct seq_file *seq, void *v)
120258diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
120259index bff6974..c63736c 100644
120260--- a/net/ipv4/xfrm4_policy.c
120261+++ b/net/ipv4/xfrm4_policy.c
120262@@ -186,11 +186,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
120263 fl4->flowi4_tos = iph->tos;
120264 }
120265
120266-static inline int xfrm4_garbage_collect(struct dst_ops *ops)
120267+static int xfrm4_garbage_collect(struct dst_ops *ops)
120268 {
120269 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
120270
120271- xfrm4_policy_afinfo.garbage_collect(net);
120272+ xfrm_garbage_collect_deferred(net);
120273 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
120274 }
120275
120276@@ -268,19 +268,18 @@ static struct ctl_table xfrm4_policy_table[] = {
120277
120278 static int __net_init xfrm4_net_init(struct net *net)
120279 {
120280- struct ctl_table *table;
120281+ ctl_table_no_const *table = NULL;
120282 struct ctl_table_header *hdr;
120283
120284- table = xfrm4_policy_table;
120285 if (!net_eq(net, &init_net)) {
120286- table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
120287+ table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
120288 if (!table)
120289 goto err_alloc;
120290
120291 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
120292- }
120293-
120294- hdr = register_net_sysctl(net, "net/ipv4", table);
120295+ hdr = register_net_sysctl(net, "net/ipv4", table);
120296+ } else
120297+ hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
120298 if (!hdr)
120299 goto err_reg;
120300
120301@@ -288,8 +287,7 @@ static int __net_init xfrm4_net_init(struct net *net)
120302 return 0;
120303
120304 err_reg:
120305- if (!net_eq(net, &init_net))
120306- kfree(table);
120307+ kfree(table);
120308 err_alloc:
120309 return -ENOMEM;
120310 }
120311diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
120312index 21c2c81..373c1ba 100644
120313--- a/net/ipv6/addrconf.c
120314+++ b/net/ipv6/addrconf.c
120315@@ -178,7 +178,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
120316 .hop_limit = IPV6_DEFAULT_HOPLIMIT,
120317 .mtu6 = IPV6_MIN_MTU,
120318 .accept_ra = 1,
120319- .accept_redirects = 1,
120320+ .accept_redirects = 0,
120321 .autoconf = 1,
120322 .force_mld_version = 0,
120323 .mldv1_unsolicited_report_interval = 10 * HZ,
120324@@ -219,7 +219,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
120325 .hop_limit = IPV6_DEFAULT_HOPLIMIT,
120326 .mtu6 = IPV6_MIN_MTU,
120327 .accept_ra = 1,
120328- .accept_redirects = 1,
120329+ .accept_redirects = 0,
120330 .autoconf = 1,
120331 .force_mld_version = 0,
120332 .mldv1_unsolicited_report_interval = 10 * HZ,
120333@@ -620,7 +620,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
120334 idx = 0;
120335 head = &net->dev_index_head[h];
120336 rcu_read_lock();
120337- cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
120338+ cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
120339 net->dev_base_seq;
120340 hlist_for_each_entry_rcu(dev, head, index_hlist) {
120341 if (idx < s_idx)
120342@@ -2508,7 +2508,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
120343 p.iph.ihl = 5;
120344 p.iph.protocol = IPPROTO_IPV6;
120345 p.iph.ttl = 64;
120346- ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
120347+ ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
120348
120349 if (ops->ndo_do_ioctl) {
120350 mm_segment_t oldfs = get_fs();
120351@@ -3774,16 +3774,23 @@ static const struct file_operations if6_fops = {
120352 .release = seq_release_net,
120353 };
120354
120355+extern void register_ipv6_seq_ops_addr(struct seq_operations *addr);
120356+extern void unregister_ipv6_seq_ops_addr(void);
120357+
120358 static int __net_init if6_proc_net_init(struct net *net)
120359 {
120360- if (!proc_create("if_inet6", S_IRUGO, net->proc_net, &if6_fops))
120361+ register_ipv6_seq_ops_addr(&if6_seq_ops);
120362+ if (!proc_create("if_inet6", S_IRUGO, net->proc_net, &if6_fops)) {
120363+ unregister_ipv6_seq_ops_addr();
120364 return -ENOMEM;
120365+ }
120366 return 0;
120367 }
120368
120369 static void __net_exit if6_proc_net_exit(struct net *net)
120370 {
120371 remove_proc_entry("if_inet6", net->proc_net);
120372+ unregister_ipv6_seq_ops_addr();
120373 }
120374
120375 static struct pernet_operations if6_proc_net_ops = {
120376@@ -4402,7 +4409,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
120377 s_ip_idx = ip_idx = cb->args[2];
120378
120379 rcu_read_lock();
120380- cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
120381+ cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
120382 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
120383 idx = 0;
120384 head = &net->dev_index_head[h];
120385@@ -5059,7 +5066,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
120386 rt_genid_bump_ipv6(net);
120387 break;
120388 }
120389- atomic_inc(&net->ipv6.dev_addr_genid);
120390+ atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
120391 }
120392
120393 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
120394@@ -5079,7 +5086,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
120395 int *valp = ctl->data;
120396 int val = *valp;
120397 loff_t pos = *ppos;
120398- struct ctl_table lctl;
120399+ ctl_table_no_const lctl;
120400 int ret;
120401
120402 /*
120403@@ -5104,7 +5111,7 @@ int addrconf_sysctl_mtu(struct ctl_table *ctl, int write,
120404 {
120405 struct inet6_dev *idev = ctl->extra1;
120406 int min_mtu = IPV6_MIN_MTU;
120407- struct ctl_table lctl;
120408+ ctl_table_no_const lctl;
120409
120410 lctl = *ctl;
120411 lctl.extra1 = &min_mtu;
120412@@ -5179,7 +5186,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
120413 int *valp = ctl->data;
120414 int val = *valp;
120415 loff_t pos = *ppos;
120416- struct ctl_table lctl;
120417+ ctl_table_no_const lctl;
120418 int ret;
120419
120420 /*
120421@@ -5244,7 +5251,7 @@ static int addrconf_sysctl_stable_secret(struct ctl_table *ctl, int write,
120422 int err;
120423 struct in6_addr addr;
120424 char str[IPV6_MAX_STRLEN];
120425- struct ctl_table lctl = *ctl;
120426+ ctl_table_no_const lctl = *ctl;
120427 struct net *net = ctl->extra2;
120428 struct ipv6_stable_secret *secret = ctl->data;
120429
120430diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
120431index 7de52b6..ce7fb94 100644
120432--- a/net/ipv6/af_inet6.c
120433+++ b/net/ipv6/af_inet6.c
120434@@ -770,7 +770,7 @@ static int __net_init inet6_net_init(struct net *net)
120435 net->ipv6.sysctl.idgen_retries = 3;
120436 net->ipv6.sysctl.idgen_delay = 1 * HZ;
120437 net->ipv6.sysctl.flowlabel_state_ranges = 1;
120438- atomic_set(&net->ipv6.fib6_sernum, 1);
120439+ atomic_set_unchecked(&net->ipv6.fib6_sernum, 1);
120440
120441 err = ipv6_init_mibs(net);
120442 if (err)
120443diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
120444index b10a889..e881e1f 100644
120445--- a/net/ipv6/datagram.c
120446+++ b/net/ipv6/datagram.c
120447@@ -977,5 +977,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
120448 0,
120449 sock_i_ino(sp),
120450 atomic_read(&sp->sk_refcnt), sp,
120451- atomic_read(&sp->sk_drops));
120452+ atomic_read_unchecked(&sp->sk_drops));
120453 }
120454diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
120455index 713d743..8eec687 100644
120456--- a/net/ipv6/icmp.c
120457+++ b/net/ipv6/icmp.c
120458@@ -1004,7 +1004,7 @@ static struct ctl_table ipv6_icmp_table_template[] = {
120459
120460 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
120461 {
120462- struct ctl_table *table;
120463+ ctl_table_no_const *table;
120464
120465 table = kmemdup(ipv6_icmp_table_template,
120466 sizeof(ipv6_icmp_table_template),
120467diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
120468index 548c623..bc8ec4f 100644
120469--- a/net/ipv6/ip6_fib.c
120470+++ b/net/ipv6/ip6_fib.c
120471@@ -99,9 +99,9 @@ static int fib6_new_sernum(struct net *net)
120472 int new, old;
120473
120474 do {
120475- old = atomic_read(&net->ipv6.fib6_sernum);
120476+ old = atomic_read_unchecked(&net->ipv6.fib6_sernum);
120477 new = old < INT_MAX ? old + 1 : 1;
120478- } while (atomic_cmpxchg(&net->ipv6.fib6_sernum,
120479+ } while (atomic_cmpxchg_unchecked(&net->ipv6.fib6_sernum,
120480 old, new) != old);
120481 return new;
120482 }
120483diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
120484index 69f4f68..1f97524 100644
120485--- a/net/ipv6/ip6_gre.c
120486+++ b/net/ipv6/ip6_gre.c
120487@@ -71,8 +71,8 @@ struct ip6gre_net {
120488 struct net_device *fb_tunnel_dev;
120489 };
120490
120491-static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
120492-static struct rtnl_link_ops ip6gre_tap_ops __read_mostly;
120493+static struct rtnl_link_ops ip6gre_link_ops;
120494+static struct rtnl_link_ops ip6gre_tap_ops;
120495 static int ip6gre_tunnel_init(struct net_device *dev);
120496 static void ip6gre_tunnel_setup(struct net_device *dev);
120497 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
120498@@ -1281,7 +1281,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
120499 }
120500
120501
120502-static struct inet6_protocol ip6gre_protocol __read_mostly = {
120503+static struct inet6_protocol ip6gre_protocol = {
120504 .handler = ip6gre_rcv,
120505 .err_handler = ip6gre_err,
120506 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
120507@@ -1640,7 +1640,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
120508 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
120509 };
120510
120511-static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
120512+static struct rtnl_link_ops ip6gre_link_ops = {
120513 .kind = "ip6gre",
120514 .maxtype = IFLA_GRE_MAX,
120515 .policy = ip6gre_policy,
120516@@ -1655,7 +1655,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
120517 .get_link_net = ip6_tnl_get_link_net,
120518 };
120519
120520-static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
120521+static struct rtnl_link_ops ip6gre_tap_ops = {
120522 .kind = "ip6gretap",
120523 .maxtype = IFLA_GRE_MAX,
120524 .policy = ip6gre_policy,
120525diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
120526index 2e67b66..b816b34 100644
120527--- a/net/ipv6/ip6_tunnel.c
120528+++ b/net/ipv6/ip6_tunnel.c
120529@@ -80,7 +80,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
120530
120531 static int ip6_tnl_dev_init(struct net_device *dev);
120532 static void ip6_tnl_dev_setup(struct net_device *dev);
120533-static struct rtnl_link_ops ip6_link_ops __read_mostly;
120534+static struct rtnl_link_ops ip6_link_ops;
120535
120536 static int ip6_tnl_net_id __read_mostly;
120537 struct ip6_tnl_net {
120538@@ -1776,7 +1776,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
120539 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
120540 };
120541
120542-static struct rtnl_link_ops ip6_link_ops __read_mostly = {
120543+static struct rtnl_link_ops ip6_link_ops = {
120544 .kind = "ip6tnl",
120545 .maxtype = IFLA_IPTUN_MAX,
120546 .policy = ip6_tnl_policy,
120547diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
120548index 0224c03..c5ec3d9 100644
120549--- a/net/ipv6/ip6_vti.c
120550+++ b/net/ipv6/ip6_vti.c
120551@@ -62,7 +62,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
120552
120553 static int vti6_dev_init(struct net_device *dev);
120554 static void vti6_dev_setup(struct net_device *dev);
120555-static struct rtnl_link_ops vti6_link_ops __read_mostly;
120556+static struct rtnl_link_ops vti6_link_ops;
120557
120558 static int vti6_net_id __read_mostly;
120559 struct vti6_net {
120560@@ -1019,7 +1019,7 @@ static const struct nla_policy vti6_policy[IFLA_VTI_MAX + 1] = {
120561 [IFLA_VTI_OKEY] = { .type = NLA_U32 },
120562 };
120563
120564-static struct rtnl_link_ops vti6_link_ops __read_mostly = {
120565+static struct rtnl_link_ops vti6_link_ops = {
120566 .kind = "vti6",
120567 .maxtype = IFLA_VTI_MAX,
120568 .policy = vti6_policy,
120569diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
120570index 63e6956..ebbbcf6 100644
120571--- a/net/ipv6/ipv6_sockglue.c
120572+++ b/net/ipv6/ipv6_sockglue.c
120573@@ -1015,7 +1015,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
120574 if (sk->sk_type != SOCK_STREAM)
120575 return -ENOPROTOOPT;
120576
120577- msg.msg_control = optval;
120578+ msg.msg_control = (void __force_kernel *)optval;
120579 msg.msg_controllen = len;
120580 msg.msg_flags = flags;
120581
120582diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
120583index 3c35ced..2e6882f 100644
120584--- a/net/ipv6/netfilter/ip6_tables.c
120585+++ b/net/ipv6/netfilter/ip6_tables.c
120586@@ -1086,14 +1086,14 @@ static int compat_table_info(const struct xt_table_info *info,
120587 #endif
120588
120589 static int get_info(struct net *net, void __user *user,
120590- const int *len, int compat)
120591+ int len, int compat)
120592 {
120593 char name[XT_TABLE_MAXNAMELEN];
120594 struct xt_table *t;
120595 int ret;
120596
120597- if (*len != sizeof(struct ip6t_getinfo)) {
120598- duprintf("length %u != %zu\n", *len,
120599+ if (len != sizeof(struct ip6t_getinfo)) {
120600+ duprintf("length %u != %zu\n", len,
120601 sizeof(struct ip6t_getinfo));
120602 return -EINVAL;
120603 }
120604@@ -1130,7 +1130,7 @@ static int get_info(struct net *net, void __user *user,
120605 info.size = private->size;
120606 strcpy(info.name, name);
120607
120608- if (copy_to_user(user, &info, *len) != 0)
120609+ if (copy_to_user(user, &info, len) != 0)
120610 ret = -EFAULT;
120611 else
120612 ret = 0;
120613@@ -1978,7 +1978,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
120614
120615 switch (cmd) {
120616 case IP6T_SO_GET_INFO:
120617- ret = get_info(sock_net(sk), user, len, 1);
120618+ ret = get_info(sock_net(sk), user, *len, 1);
120619 break;
120620 case IP6T_SO_GET_ENTRIES:
120621 ret = compat_get_entries(sock_net(sk), user, len);
120622@@ -2025,7 +2025,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
120623
120624 switch (cmd) {
120625 case IP6T_SO_GET_INFO:
120626- ret = get_info(sock_net(sk), user, len, 0);
120627+ ret = get_info(sock_net(sk), user, *len, 0);
120628 break;
120629
120630 case IP6T_SO_GET_ENTRIES:
120631diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
120632index 6d02498..55e564f 100644
120633--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
120634+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
120635@@ -96,12 +96,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
120636
120637 static int nf_ct_frag6_sysctl_register(struct net *net)
120638 {
120639- struct ctl_table *table;
120640+ ctl_table_no_const *table = NULL;
120641 struct ctl_table_header *hdr;
120642
120643- table = nf_ct_frag6_sysctl_table;
120644 if (!net_eq(net, &init_net)) {
120645- table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
120646+ table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
120647 GFP_KERNEL);
120648 if (table == NULL)
120649 goto err_alloc;
120650@@ -112,9 +111,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
120651 table[2].data = &net->nf_frag.frags.high_thresh;
120652 table[2].extra1 = &net->nf_frag.frags.low_thresh;
120653 table[2].extra2 = &init_net.nf_frag.frags.high_thresh;
120654- }
120655-
120656- hdr = register_net_sysctl(net, "net/netfilter", table);
120657+ hdr = register_net_sysctl(net, "net/netfilter", table);
120658+ } else
120659+ hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
120660 if (hdr == NULL)
120661 goto err_reg;
120662
120663@@ -122,8 +121,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
120664 return 0;
120665
120666 err_reg:
120667- if (!net_eq(net, &init_net))
120668- kfree(table);
120669+ kfree(table);
120670 err_alloc:
120671 return -ENOMEM;
120672 }
120673diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
120674index 263a516..692f738 100644
120675--- a/net/ipv6/ping.c
120676+++ b/net/ipv6/ping.c
120677@@ -240,6 +240,24 @@ static struct pernet_operations ping_v6_net_ops = {
120678 };
120679 #endif
120680
120681+static struct pingv6_ops real_pingv6_ops = {
120682+ .ipv6_recv_error = ipv6_recv_error,
120683+ .ip6_datagram_recv_common_ctl = ip6_datagram_recv_common_ctl,
120684+ .ip6_datagram_recv_specific_ctl = ip6_datagram_recv_specific_ctl,
120685+ .icmpv6_err_convert = icmpv6_err_convert,
120686+ .ipv6_icmp_error = ipv6_icmp_error,
120687+ .ipv6_chk_addr = ipv6_chk_addr,
120688+};
120689+
120690+static struct pingv6_ops dummy_pingv6_ops = {
120691+ .ipv6_recv_error = dummy_ipv6_recv_error,
120692+ .ip6_datagram_recv_common_ctl = dummy_ip6_datagram_recv_ctl,
120693+ .ip6_datagram_recv_specific_ctl = dummy_ip6_datagram_recv_ctl,
120694+ .icmpv6_err_convert = dummy_icmpv6_err_convert,
120695+ .ipv6_icmp_error = dummy_ipv6_icmp_error,
120696+ .ipv6_chk_addr = dummy_ipv6_chk_addr,
120697+};
120698+
120699 int __init pingv6_init(void)
120700 {
120701 #ifdef CONFIG_PROC_FS
120702@@ -247,13 +265,7 @@ int __init pingv6_init(void)
120703 if (ret)
120704 return ret;
120705 #endif
120706- pingv6_ops.ipv6_recv_error = ipv6_recv_error;
120707- pingv6_ops.ip6_datagram_recv_common_ctl = ip6_datagram_recv_common_ctl;
120708- pingv6_ops.ip6_datagram_recv_specific_ctl =
120709- ip6_datagram_recv_specific_ctl;
120710- pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
120711- pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
120712- pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
120713+ pingv6_ops = &real_pingv6_ops;
120714 return inet6_register_protosw(&pingv6_protosw);
120715 }
120716
120717@@ -262,14 +274,9 @@ int __init pingv6_init(void)
120718 */
120719 void pingv6_exit(void)
120720 {
120721- pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
120722- pingv6_ops.ip6_datagram_recv_common_ctl = dummy_ip6_datagram_recv_ctl;
120723- pingv6_ops.ip6_datagram_recv_specific_ctl = dummy_ip6_datagram_recv_ctl;
120724- pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
120725- pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
120726- pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
120727 #ifdef CONFIG_PROC_FS
120728 unregister_pernet_subsys(&ping_v6_net_ops);
120729 #endif
120730+ pingv6_ops = &dummy_pingv6_ops;
120731 inet6_unregister_protosw(&pingv6_protosw);
120732 }
120733diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
120734index 679253d0..70b653c 100644
120735--- a/net/ipv6/proc.c
120736+++ b/net/ipv6/proc.c
120737@@ -310,7 +310,7 @@ static int __net_init ipv6_proc_init_net(struct net *net)
120738 if (!proc_create("snmp6", S_IRUGO, net->proc_net, &snmp6_seq_fops))
120739 goto proc_snmp6_fail;
120740
120741- net->mib.proc_net_devsnmp6 = proc_mkdir("dev_snmp6", net->proc_net);
120742+ net->mib.proc_net_devsnmp6 = proc_mkdir_restrict("dev_snmp6", net->proc_net);
120743 if (!net->mib.proc_net_devsnmp6)
120744 goto proc_dev_snmp6_fail;
120745 return 0;
120746diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
120747index ca4700c..e44c0f9 100644
120748--- a/net/ipv6/raw.c
120749+++ b/net/ipv6/raw.c
120750@@ -388,7 +388,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
120751 {
120752 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
120753 skb_checksum_complete(skb)) {
120754- atomic_inc(&sk->sk_drops);
120755+ atomic_inc_unchecked(&sk->sk_drops);
120756 kfree_skb(skb);
120757 return NET_RX_DROP;
120758 }
120759@@ -416,7 +416,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
120760 struct raw6_sock *rp = raw6_sk(sk);
120761
120762 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
120763- atomic_inc(&sk->sk_drops);
120764+ atomic_inc_unchecked(&sk->sk_drops);
120765 kfree_skb(skb);
120766 return NET_RX_DROP;
120767 }
120768@@ -440,7 +440,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
120769
120770 if (inet->hdrincl) {
120771 if (skb_checksum_complete(skb)) {
120772- atomic_inc(&sk->sk_drops);
120773+ atomic_inc_unchecked(&sk->sk_drops);
120774 kfree_skb(skb);
120775 return NET_RX_DROP;
120776 }
120777@@ -608,7 +608,7 @@ out:
120778 return err;
120779 }
120780
120781-static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
120782+static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, unsigned int length,
120783 struct flowi6 *fl6, struct dst_entry **dstp,
120784 unsigned int flags)
120785 {
120786@@ -916,12 +916,15 @@ do_confirm:
120787 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
120788 char __user *optval, int optlen)
120789 {
120790+ struct icmp6_filter filter;
120791+
120792 switch (optname) {
120793 case ICMPV6_FILTER:
120794 if (optlen > sizeof(struct icmp6_filter))
120795 optlen = sizeof(struct icmp6_filter);
120796- if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
120797+ if (copy_from_user(&filter, optval, optlen))
120798 return -EFAULT;
120799+ raw6_sk(sk)->filter = filter;
120800 return 0;
120801 default:
120802 return -ENOPROTOOPT;
120803@@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
120804 char __user *optval, int __user *optlen)
120805 {
120806 int len;
120807+ struct icmp6_filter filter;
120808
120809 switch (optname) {
120810 case ICMPV6_FILTER:
120811@@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
120812 len = sizeof(struct icmp6_filter);
120813 if (put_user(len, optlen))
120814 return -EFAULT;
120815- if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
120816+ filter = raw6_sk(sk)->filter;
120817+ if (len > sizeof filter || copy_to_user(optval, &filter, len))
120818 return -EFAULT;
120819 return 0;
120820 default:
120821diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
120822index f1159bb..0db5dad 100644
120823--- a/net/ipv6/reassembly.c
120824+++ b/net/ipv6/reassembly.c
120825@@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
120826
120827 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
120828 {
120829- struct ctl_table *table;
120830+ ctl_table_no_const *table = NULL;
120831 struct ctl_table_header *hdr;
120832
120833- table = ip6_frags_ns_ctl_table;
120834 if (!net_eq(net, &init_net)) {
120835- table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
120836+ table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
120837 if (!table)
120838 goto err_alloc;
120839
120840@@ -645,9 +644,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
120841 /* Don't export sysctls to unprivileged users */
120842 if (net->user_ns != &init_user_ns)
120843 table[0].procname = NULL;
120844- }
120845+ hdr = register_net_sysctl(net, "net/ipv6", table);
120846+ } else
120847+ hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
120848
120849- hdr = register_net_sysctl(net, "net/ipv6", table);
120850 if (!hdr)
120851 goto err_reg;
120852
120853@@ -655,8 +655,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
120854 return 0;
120855
120856 err_reg:
120857- if (!net_eq(net, &init_net))
120858- kfree(table);
120859+ kfree(table);
120860 err_alloc:
120861 return -ENOMEM;
120862 }
120863diff --git a/net/ipv6/route.c b/net/ipv6/route.c
120864index 00b64d4..da5099e 100644
120865--- a/net/ipv6/route.c
120866+++ b/net/ipv6/route.c
120867@@ -3430,7 +3430,7 @@ struct ctl_table ipv6_route_table_template[] = {
120868
120869 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
120870 {
120871- struct ctl_table *table;
120872+ ctl_table_no_const *table;
120873
120874 table = kmemdup(ipv6_route_table_template,
120875 sizeof(ipv6_route_table_template),
120876diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
120877index ac35a28..070cc8c 100644
120878--- a/net/ipv6/sit.c
120879+++ b/net/ipv6/sit.c
120880@@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
120881 static void ipip6_dev_free(struct net_device *dev);
120882 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
120883 __be32 *v4dst);
120884-static struct rtnl_link_ops sit_link_ops __read_mostly;
120885+static struct rtnl_link_ops sit_link_ops;
120886
120887 static int sit_net_id __read_mostly;
120888 struct sit_net {
120889@@ -1749,7 +1749,7 @@ static void ipip6_dellink(struct net_device *dev, struct list_head *head)
120890 unregister_netdevice_queue(dev, head);
120891 }
120892
120893-static struct rtnl_link_ops sit_link_ops __read_mostly = {
120894+static struct rtnl_link_ops sit_link_ops = {
120895 .kind = "sit",
120896 .maxtype = IFLA_IPTUN_MAX,
120897 .policy = ipip6_policy,
120898diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
120899index 4e705ad..9ba8db8 100644
120900--- a/net/ipv6/sysctl_net_ipv6.c
120901+++ b/net/ipv6/sysctl_net_ipv6.c
120902@@ -99,7 +99,7 @@ static struct ctl_table ipv6_rotable[] = {
120903
120904 static int __net_init ipv6_sysctl_net_init(struct net *net)
120905 {
120906- struct ctl_table *ipv6_table;
120907+ ctl_table_no_const *ipv6_table;
120908 struct ctl_table *ipv6_route_table;
120909 struct ctl_table *ipv6_icmp_table;
120910 int err;
120911diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
120912index 7a6cea5..1a99e26 100644
120913--- a/net/ipv6/tcp_ipv6.c
120914+++ b/net/ipv6/tcp_ipv6.c
120915@@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
120916 }
120917 }
120918
120919+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120920+extern int grsec_enable_blackhole;
120921+#endif
120922+
120923 static __u32 tcp_v6_init_sequence(const struct sk_buff *skb)
120924 {
120925 return secure_tcpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,
120926@@ -1280,6 +1284,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
120927 return 0;
120928
120929 reset:
120930+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120931+ if (!grsec_enable_blackhole)
120932+#endif
120933 tcp_v6_send_reset(sk, skb);
120934 discard:
120935 if (opt_skb)
120936@@ -1389,12 +1396,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
120937
120938 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest,
120939 inet6_iif(skb));
120940- if (!sk)
120941+ if (!sk) {
120942+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120943+ ret = 1;
120944+#endif
120945 goto no_tcp_socket;
120946+ }
120947
120948 process:
120949- if (sk->sk_state == TCP_TIME_WAIT)
120950+ if (sk->sk_state == TCP_TIME_WAIT) {
120951+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120952+ ret = 2;
120953+#endif
120954 goto do_time_wait;
120955+ }
120956
120957 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
120958 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
120959@@ -1446,6 +1461,10 @@ csum_error:
120960 bad_packet:
120961 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
120962 } else {
120963+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120964+ if (!grsec_enable_blackhole || (ret == 1 &&
120965+ (skb->dev->flags & IFF_LOOPBACK)))
120966+#endif
120967 tcp_v6_send_reset(NULL, skb);
120968 }
120969
120970diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
120971index e51fc3e..8f04229 100644
120972--- a/net/ipv6/udp.c
120973+++ b/net/ipv6/udp.c
120974@@ -76,6 +76,10 @@ static u32 udp6_ehashfn(const struct net *net,
120975 udp_ipv6_hash_secret + net_hash_mix(net));
120976 }
120977
120978+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120979+extern int grsec_enable_blackhole;
120980+#endif
120981+
120982 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
120983 {
120984 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
120985@@ -445,7 +449,7 @@ try_again:
120986 if (unlikely(err)) {
120987 trace_kfree_skb(skb, udpv6_recvmsg);
120988 if (!peeked) {
120989- atomic_inc(&sk->sk_drops);
120990+ atomic_inc_unchecked(&sk->sk_drops);
120991 if (is_udp4)
120992 UDP_INC_STATS_USER(sock_net(sk),
120993 UDP_MIB_INERRORS,
120994@@ -709,7 +713,7 @@ csum_error:
120995 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
120996 drop:
120997 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
120998- atomic_inc(&sk->sk_drops);
120999+ atomic_inc_unchecked(&sk->sk_drops);
121000 kfree_skb(skb);
121001 return -1;
121002 }
121003@@ -750,7 +754,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
121004 if (likely(!skb1))
121005 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
121006 if (!skb1) {
121007- atomic_inc(&sk->sk_drops);
121008+ atomic_inc_unchecked(&sk->sk_drops);
121009 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
121010 IS_UDPLITE(sk));
121011 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
121012@@ -934,6 +938,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
121013 goto csum_error;
121014
121015 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
121016+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121017+ if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
121018+#endif
121019 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
121020
121021 kfree_skb(skb);
121022diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
121023index ed0583c..606962a 100644
121024--- a/net/ipv6/xfrm6_policy.c
121025+++ b/net/ipv6/xfrm6_policy.c
121026@@ -174,7 +174,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
121027 return;
121028
121029 case IPPROTO_ICMPV6:
121030- if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) {
121031+ if (!onlyproto && (nh + offset + 2 < skb->data ||
121032+ pskb_may_pull(skb, nh + offset + 2 - skb->data))) {
121033 u8 *icmp;
121034
121035 nh = skb_network_header(skb);
121036@@ -188,7 +189,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
121037 #if IS_ENABLED(CONFIG_IPV6_MIP6)
121038 case IPPROTO_MH:
121039 offset += ipv6_optlen(exthdr);
121040- if (!onlyproto && pskb_may_pull(skb, nh + offset + 3 - skb->data)) {
121041+ if (!onlyproto && (nh + offset + 3 < skb->data ||
121042+ pskb_may_pull(skb, nh + offset + 3 - skb->data))) {
121043 struct ip6_mh *mh;
121044
121045 nh = skb_network_header(skb);
121046@@ -211,11 +213,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
121047 }
121048 }
121049
121050-static inline int xfrm6_garbage_collect(struct dst_ops *ops)
121051+static int xfrm6_garbage_collect(struct dst_ops *ops)
121052 {
121053 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
121054
121055- xfrm6_policy_afinfo.garbage_collect(net);
121056+ xfrm_garbage_collect_deferred(net);
121057 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
121058 }
121059
121060@@ -322,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
121061
121062 static int __net_init xfrm6_net_init(struct net *net)
121063 {
121064- struct ctl_table *table;
121065+ ctl_table_no_const *table = NULL;
121066 struct ctl_table_header *hdr;
121067
121068- table = xfrm6_policy_table;
121069 if (!net_eq(net, &init_net)) {
121070- table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
121071+ table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
121072 if (!table)
121073 goto err_alloc;
121074
121075 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
121076- }
121077+ hdr = register_net_sysctl(net, "net/ipv6", table);
121078+ } else
121079+ hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
121080
121081- hdr = register_net_sysctl(net, "net/ipv6", table);
121082 if (!hdr)
121083 goto err_reg;
121084
121085@@ -342,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
121086 return 0;
121087
121088 err_reg:
121089- if (!net_eq(net, &init_net))
121090- kfree(table);
121091+ kfree(table);
121092 err_alloc:
121093 return -ENOMEM;
121094 }
121095diff --git a/net/ipx/ipx_proc.c b/net/ipx/ipx_proc.c
121096index c1d247e..9e5949d 100644
121097--- a/net/ipx/ipx_proc.c
121098+++ b/net/ipx/ipx_proc.c
121099@@ -289,7 +289,7 @@ int __init ipx_proc_init(void)
121100 struct proc_dir_entry *p;
121101 int rc = -ENOMEM;
121102
121103- ipx_proc_dir = proc_mkdir("ipx", init_net.proc_net);
121104+ ipx_proc_dir = proc_mkdir_restrict("ipx", init_net.proc_net);
121105
121106 if (!ipx_proc_dir)
121107 goto out;
121108diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
121109index 683346d..cb0e12d 100644
121110--- a/net/irda/ircomm/ircomm_tty.c
121111+++ b/net/irda/ircomm/ircomm_tty.c
121112@@ -310,10 +310,10 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
121113 add_wait_queue(&port->open_wait, &wait);
121114
121115 pr_debug("%s(%d):block_til_ready before block on %s open_count=%d\n",
121116- __FILE__, __LINE__, tty->driver->name, port->count);
121117+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
121118
121119 spin_lock_irqsave(&port->lock, flags);
121120- port->count--;
121121+ atomic_dec(&port->count);
121122 port->blocked_open++;
121123 spin_unlock_irqrestore(&port->lock, flags);
121124
121125@@ -348,7 +348,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
121126 }
121127
121128 pr_debug("%s(%d):block_til_ready blocking on %s open_count=%d\n",
121129- __FILE__, __LINE__, tty->driver->name, port->count);
121130+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
121131
121132 schedule();
121133 }
121134@@ -358,12 +358,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
121135
121136 spin_lock_irqsave(&port->lock, flags);
121137 if (!tty_hung_up_p(filp))
121138- port->count++;
121139+ atomic_inc(&port->count);
121140 port->blocked_open--;
121141 spin_unlock_irqrestore(&port->lock, flags);
121142
121143 pr_debug("%s(%d):block_til_ready after blocking on %s open_count=%d\n",
121144- __FILE__, __LINE__, tty->driver->name, port->count);
121145+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
121146
121147 if (!retval)
121148 port->flags |= ASYNC_NORMAL_ACTIVE;
121149@@ -433,12 +433,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
121150
121151 /* ++ is not atomic, so this should be protected - Jean II */
121152 spin_lock_irqsave(&self->port.lock, flags);
121153- self->port.count++;
121154+ atomic_inc(&self->port.count);
121155 spin_unlock_irqrestore(&self->port.lock, flags);
121156 tty_port_tty_set(&self->port, tty);
121157
121158 pr_debug("%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
121159- self->line, self->port.count);
121160+ self->line, atomic_read(&self->port.count));
121161
121162 /* Not really used by us, but lets do it anyway */
121163 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
121164@@ -961,7 +961,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
121165 tty_kref_put(port->tty);
121166 }
121167 port->tty = NULL;
121168- port->count = 0;
121169+ atomic_set(&port->count, 0);
121170 spin_unlock_irqrestore(&port->lock, flags);
121171
121172 wake_up_interruptible(&port->open_wait);
121173@@ -1308,7 +1308,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
121174 seq_putc(m, '\n');
121175
121176 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
121177- seq_printf(m, "Open count: %d\n", self->port.count);
121178+ seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
121179 seq_printf(m, "Max data size: %d\n", self->max_data_size);
121180 seq_printf(m, "Max header size: %d\n", self->max_header_size);
121181
121182diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
121183index a26c401..4396459 100644
121184--- a/net/irda/irlmp.c
121185+++ b/net/irda/irlmp.c
121186@@ -1839,7 +1839,7 @@ static void *irlmp_seq_hb_idx(struct irlmp_iter_state *iter, loff_t *off)
121187 for (element = hashbin_get_first(iter->hashbin);
121188 element != NULL;
121189 element = hashbin_get_next(iter->hashbin)) {
121190- if (!off || *off-- == 0) {
121191+ if (!off || (*off)-- == 0) {
121192 /* NB: hashbin left locked */
121193 return element;
121194 }
121195diff --git a/net/irda/irproc.c b/net/irda/irproc.c
121196index b9ac598..f88cc56 100644
121197--- a/net/irda/irproc.c
121198+++ b/net/irda/irproc.c
121199@@ -66,7 +66,7 @@ void __init irda_proc_register(void)
121200 {
121201 int i;
121202
121203- proc_irda = proc_mkdir("irda", init_net.proc_net);
121204+ proc_irda = proc_mkdir_restrict("irda", init_net.proc_net);
121205 if (proc_irda == NULL)
121206 return;
121207
121208diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
121209index 918151c..5bbe95a 100644
121210--- a/net/iucv/af_iucv.c
121211+++ b/net/iucv/af_iucv.c
121212@@ -686,10 +686,10 @@ static void __iucv_auto_name(struct iucv_sock *iucv)
121213 {
121214 char name[12];
121215
121216- sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
121217+ sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
121218 while (__iucv_get_sock_by_name(name)) {
121219 sprintf(name, "%08x",
121220- atomic_inc_return(&iucv_sk_list.autobind_name));
121221+ atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
121222 }
121223 memcpy(iucv->src_name, name, 8);
121224 }
121225diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
121226index 2a6a1fd..6c112b0 100644
121227--- a/net/iucv/iucv.c
121228+++ b/net/iucv/iucv.c
121229@@ -702,7 +702,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
121230 return NOTIFY_OK;
121231 }
121232
121233-static struct notifier_block __refdata iucv_cpu_notifier = {
121234+static struct notifier_block iucv_cpu_notifier = {
121235 .notifier_call = iucv_cpu_notify,
121236 };
121237
121238diff --git a/net/key/af_key.c b/net/key/af_key.c
121239index 83a7068..facf2f0 100644
121240--- a/net/key/af_key.c
121241+++ b/net/key/af_key.c
121242@@ -3050,10 +3050,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
121243 static u32 get_acqseq(void)
121244 {
121245 u32 res;
121246- static atomic_t acqseq;
121247+ static atomic_unchecked_t acqseq;
121248
121249 do {
121250- res = atomic_inc_return(&acqseq);
121251+ res = atomic_inc_return_unchecked(&acqseq);
121252 } while (!res);
121253 return res;
121254 }
121255diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
121256index 4b55287..bd247f7 100644
121257--- a/net/l2tp/l2tp_eth.c
121258+++ b/net/l2tp/l2tp_eth.c
121259@@ -42,12 +42,12 @@ struct l2tp_eth {
121260 struct sock *tunnel_sock;
121261 struct l2tp_session *session;
121262 struct list_head list;
121263- atomic_long_t tx_bytes;
121264- atomic_long_t tx_packets;
121265- atomic_long_t tx_dropped;
121266- atomic_long_t rx_bytes;
121267- atomic_long_t rx_packets;
121268- atomic_long_t rx_errors;
121269+ atomic_long_unchecked_t tx_bytes;
121270+ atomic_long_unchecked_t tx_packets;
121271+ atomic_long_unchecked_t tx_dropped;
121272+ atomic_long_unchecked_t rx_bytes;
121273+ atomic_long_unchecked_t rx_packets;
121274+ atomic_long_unchecked_t rx_errors;
121275 };
121276
121277 /* via l2tp_session_priv() */
121278@@ -98,10 +98,10 @@ static int l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev)
121279 int ret = l2tp_xmit_skb(session, skb, session->hdr_len);
121280
121281 if (likely(ret == NET_XMIT_SUCCESS)) {
121282- atomic_long_add(len, &priv->tx_bytes);
121283- atomic_long_inc(&priv->tx_packets);
121284+ atomic_long_add_unchecked(len, &priv->tx_bytes);
121285+ atomic_long_inc_unchecked(&priv->tx_packets);
121286 } else {
121287- atomic_long_inc(&priv->tx_dropped);
121288+ atomic_long_inc_unchecked(&priv->tx_dropped);
121289 }
121290 return NETDEV_TX_OK;
121291 }
121292@@ -111,12 +111,12 @@ static struct rtnl_link_stats64 *l2tp_eth_get_stats64(struct net_device *dev,
121293 {
121294 struct l2tp_eth *priv = netdev_priv(dev);
121295
121296- stats->tx_bytes = atomic_long_read(&priv->tx_bytes);
121297- stats->tx_packets = atomic_long_read(&priv->tx_packets);
121298- stats->tx_dropped = atomic_long_read(&priv->tx_dropped);
121299- stats->rx_bytes = atomic_long_read(&priv->rx_bytes);
121300- stats->rx_packets = atomic_long_read(&priv->rx_packets);
121301- stats->rx_errors = atomic_long_read(&priv->rx_errors);
121302+ stats->tx_bytes = atomic_long_read_unchecked(&priv->tx_bytes);
121303+ stats->tx_packets = atomic_long_read_unchecked(&priv->tx_packets);
121304+ stats->tx_dropped = atomic_long_read_unchecked(&priv->tx_dropped);
121305+ stats->rx_bytes = atomic_long_read_unchecked(&priv->rx_bytes);
121306+ stats->rx_packets = atomic_long_read_unchecked(&priv->rx_packets);
121307+ stats->rx_errors = atomic_long_read_unchecked(&priv->rx_errors);
121308 return stats;
121309 }
121310
121311@@ -167,15 +167,15 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb,
121312 nf_reset(skb);
121313
121314 if (dev_forward_skb(dev, skb) == NET_RX_SUCCESS) {
121315- atomic_long_inc(&priv->rx_packets);
121316- atomic_long_add(data_len, &priv->rx_bytes);
121317+ atomic_long_inc_unchecked(&priv->rx_packets);
121318+ atomic_long_add_unchecked(data_len, &priv->rx_bytes);
121319 } else {
121320- atomic_long_inc(&priv->rx_errors);
121321+ atomic_long_inc_unchecked(&priv->rx_errors);
121322 }
121323 return;
121324
121325 error:
121326- atomic_long_inc(&priv->rx_errors);
121327+ atomic_long_inc_unchecked(&priv->rx_errors);
121328 kfree_skb(skb);
121329 }
121330
121331diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
121332index 7964993..2c48a3a 100644
121333--- a/net/l2tp/l2tp_ip.c
121334+++ b/net/l2tp/l2tp_ip.c
121335@@ -608,7 +608,7 @@ static struct inet_protosw l2tp_ip_protosw = {
121336 .ops = &l2tp_ip_ops,
121337 };
121338
121339-static struct net_protocol l2tp_ip_protocol __read_mostly = {
121340+static const struct net_protocol l2tp_ip_protocol = {
121341 .handler = l2tp_ip_recv,
121342 .netns_ok = 1,
121343 };
121344diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
121345index d1ded37..c0d1e49 100644
121346--- a/net/l2tp/l2tp_ip6.c
121347+++ b/net/l2tp/l2tp_ip6.c
121348@@ -755,7 +755,7 @@ static struct inet_protosw l2tp_ip6_protosw = {
121349 .ops = &l2tp_ip6_ops,
121350 };
121351
121352-static struct inet6_protocol l2tp_ip6_protocol __read_mostly = {
121353+static const struct inet6_protocol l2tp_ip6_protocol = {
121354 .handler = l2tp_ip6_recv,
121355 };
121356
121357diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
121358index 1a3c7e0..80f8b0c 100644
121359--- a/net/llc/llc_proc.c
121360+++ b/net/llc/llc_proc.c
121361@@ -247,7 +247,7 @@ int __init llc_proc_init(void)
121362 int rc = -ENOMEM;
121363 struct proc_dir_entry *p;
121364
121365- llc_proc_dir = proc_mkdir("llc", init_net.proc_net);
121366+ llc_proc_dir = proc_mkdir_restrict("llc", init_net.proc_net);
121367 if (!llc_proc_dir)
121368 goto out;
121369
121370diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
121371index bf7023f..86a5bc6 100644
121372--- a/net/mac80211/cfg.c
121373+++ b/net/mac80211/cfg.c
121374@@ -580,7 +580,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
121375 ret = ieee80211_vif_use_channel(sdata, chandef,
121376 IEEE80211_CHANCTX_EXCLUSIVE);
121377 }
121378- } else if (local->open_count == local->monitors) {
121379+ } else if (local_read(&local->open_count) == local->monitors) {
121380 local->_oper_chandef = *chandef;
121381 ieee80211_hw_config(local, 0);
121382 }
121383@@ -3488,7 +3488,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
121384 else
121385 local->probe_req_reg--;
121386
121387- if (!local->open_count)
121388+ if (!local_read(&local->open_count))
121389 break;
121390
121391 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
121392@@ -3637,8 +3637,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
121393 if (chanctx_conf) {
121394 *chandef = sdata->vif.bss_conf.chandef;
121395 ret = 0;
121396- } else if (local->open_count > 0 &&
121397- local->open_count == local->monitors &&
121398+ } else if (local_read(&local->open_count) > 0 &&
121399+ local_read(&local->open_count) == local->monitors &&
121400 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
121401 if (local->use_chanctx)
121402 *chandef = local->monitor_chandef;
121403diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
121404index b12f615..a264a60 100644
121405--- a/net/mac80211/ieee80211_i.h
121406+++ b/net/mac80211/ieee80211_i.h
121407@@ -30,6 +30,7 @@
121408 #include <net/ieee80211_radiotap.h>
121409 #include <net/cfg80211.h>
121410 #include <net/mac80211.h>
121411+#include <asm/local.h>
121412 #include "key.h"
121413 #include "sta_info.h"
121414 #include "debug.h"
121415@@ -1112,7 +1113,7 @@ struct ieee80211_local {
121416 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
121417 spinlock_t queue_stop_reason_lock;
121418
121419- int open_count;
121420+ local_t open_count;
121421 int monitors, cooked_mntrs;
121422 /* number of interfaces with corresponding FIF_ flags */
121423 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
121424diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
121425index 553ac6d..d2480da 100644
121426--- a/net/mac80211/iface.c
121427+++ b/net/mac80211/iface.c
121428@@ -550,7 +550,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121429 break;
121430 }
121431
121432- if (local->open_count == 0) {
121433+ if (local_read(&local->open_count) == 0) {
121434 res = drv_start(local);
121435 if (res)
121436 goto err_del_bss;
121437@@ -597,7 +597,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121438 res = drv_add_interface(local, sdata);
121439 if (res)
121440 goto err_stop;
121441- } else if (local->monitors == 0 && local->open_count == 0) {
121442+ } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
121443 res = ieee80211_add_virtual_monitor(local);
121444 if (res)
121445 goto err_stop;
121446@@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121447 atomic_inc(&local->iff_allmultis);
121448
121449 if (coming_up)
121450- local->open_count++;
121451+ local_inc(&local->open_count);
121452
121453 if (hw_reconf_flags)
121454 ieee80211_hw_config(local, hw_reconf_flags);
121455@@ -742,7 +742,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121456 err_del_interface:
121457 drv_remove_interface(local, sdata);
121458 err_stop:
121459- if (!local->open_count)
121460+ if (!local_read(&local->open_count))
121461 drv_stop(local);
121462 err_del_bss:
121463 sdata->bss = NULL;
121464@@ -909,7 +909,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121465 }
121466
121467 if (going_down)
121468- local->open_count--;
121469+ local_dec(&local->open_count);
121470
121471 switch (sdata->vif.type) {
121472 case NL80211_IFTYPE_AP_VLAN:
121473@@ -978,7 +978,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121474 atomic_set(&sdata->txqs_len[txqi->txq.ac], 0);
121475 }
121476
121477- if (local->open_count == 0)
121478+ if (local_read(&local->open_count) == 0)
121479 ieee80211_clear_tx_pending(local);
121480
121481 /*
121482@@ -1021,7 +1021,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121483 if (cancel_scan)
121484 flush_delayed_work(&local->scan_work);
121485
121486- if (local->open_count == 0) {
121487+ if (local_read(&local->open_count) == 0) {
121488 ieee80211_stop_device(local);
121489
121490 /* no reconfiguring after stop! */
121491@@ -1032,7 +1032,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121492 ieee80211_configure_filter(local);
121493 ieee80211_hw_config(local, hw_reconf_flags);
121494
121495- if (local->monitors == local->open_count)
121496+ if (local->monitors == local_read(&local->open_count))
121497 ieee80211_add_virtual_monitor(local);
121498 }
121499
121500@@ -1884,8 +1884,8 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local)
121501 */
121502 cfg80211_shutdown_all_interfaces(local->hw.wiphy);
121503
121504- WARN(local->open_count, "%s: open count remains %d\n",
121505- wiphy_name(local->hw.wiphy), local->open_count);
121506+ WARN(local_read(&local->open_count), "%s: open count remains %ld\n",
121507+ wiphy_name(local->hw.wiphy), local_read(&local->open_count));
121508
121509 mutex_lock(&local->iflist_mtx);
121510 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
121511diff --git a/net/mac80211/main.c b/net/mac80211/main.c
121512index 3c63468..b5c285f 100644
121513--- a/net/mac80211/main.c
121514+++ b/net/mac80211/main.c
121515@@ -172,7 +172,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
121516 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
121517 IEEE80211_CONF_CHANGE_POWER);
121518
121519- if (changed && local->open_count) {
121520+ if (changed && local_read(&local->open_count)) {
121521 ret = drv_config(local, changed);
121522 /*
121523 * Goal:
121524diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
121525index b676b9f..395dd95 100644
121526--- a/net/mac80211/pm.c
121527+++ b/net/mac80211/pm.c
121528@@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
121529 struct ieee80211_sub_if_data *sdata;
121530 struct sta_info *sta;
121531
121532- if (!local->open_count)
121533+ if (!local_read(&local->open_count))
121534 goto suspend;
121535
121536 ieee80211_scan_cancel(local);
121537@@ -166,7 +166,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
121538 WARN_ON(!list_empty(&local->chanctx_list));
121539
121540 /* stop hardware - this must stop RX */
121541- if (local->open_count)
121542+ if (local_read(&local->open_count))
121543 ieee80211_stop_device(local);
121544
121545 suspend:
121546diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
121547index fda33f9..0e7d4c0 100644
121548--- a/net/mac80211/rate.c
121549+++ b/net/mac80211/rate.c
121550@@ -730,7 +730,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
121551
121552 ASSERT_RTNL();
121553
121554- if (local->open_count)
121555+ if (local_read(&local->open_count))
121556 return -EBUSY;
121557
121558 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
121559diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
121560index 666ddac..0cad93b 100644
121561--- a/net/mac80211/sta_info.c
121562+++ b/net/mac80211/sta_info.c
121563@@ -341,7 +341,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
121564 int size = sizeof(struct txq_info) +
121565 ALIGN(hw->txq_data_size, sizeof(void *));
121566
121567- txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp);
121568+ txq_data = kcalloc(size, ARRAY_SIZE(sta->sta.txq), gfp);
121569 if (!txq_data)
121570 goto free;
121571
121572diff --git a/net/mac80211/util.c b/net/mac80211/util.c
121573index 43e5aad..d117c3a 100644
121574--- a/net/mac80211/util.c
121575+++ b/net/mac80211/util.c
121576@@ -1761,7 +1761,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121577 bool sched_scan_stopped = false;
121578
121579 /* nothing to do if HW shouldn't run */
121580- if (!local->open_count)
121581+ if (!local_read(&local->open_count))
121582 goto wake_up;
121583
121584 #ifdef CONFIG_PM
121585@@ -2033,7 +2033,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121586 local->in_reconfig = false;
121587 barrier();
121588
121589- if (local->monitors == local->open_count && local->monitors > 0)
121590+ if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
121591 ieee80211_add_virtual_monitor(local);
121592
121593 /*
121594@@ -2088,7 +2088,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121595 * If this is for hw restart things are still running.
121596 * We may want to change that later, however.
121597 */
121598- if (local->open_count && (!local->suspended || reconfig_due_to_wowlan))
121599+ if (local_read(&local->open_count) && (!local->suspended || reconfig_due_to_wowlan))
121600 drv_reconfig_complete(local, IEEE80211_RECONFIG_TYPE_RESTART);
121601
121602 if (!local->suspended)
121603@@ -2112,7 +2112,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121604 flush_delayed_work(&local->scan_work);
121605 }
121606
121607- if (local->open_count && !reconfig_due_to_wowlan)
121608+ if (local_read(&local->open_count) && !reconfig_due_to_wowlan)
121609 drv_reconfig_complete(local, IEEE80211_RECONFIG_TYPE_SUSPEND);
121610
121611 list_for_each_entry(sdata, &local->interfaces, list) {
121612diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
121613index 1f93a59..96faa29 100644
121614--- a/net/mpls/af_mpls.c
121615+++ b/net/mpls/af_mpls.c
121616@@ -456,7 +456,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
121617 struct mpls_dev *mdev)
121618 {
121619 char path[sizeof("net/mpls/conf/") + IFNAMSIZ];
121620- struct ctl_table *table;
121621+ ctl_table_no_const *table;
121622 int i;
121623
121624 table = kmemdup(&mpls_dev_table, sizeof(mpls_dev_table), GFP_KERNEL);
121625@@ -1025,7 +1025,7 @@ static int mpls_platform_labels(struct ctl_table *table, int write,
121626 struct net *net = table->data;
121627 int platform_labels = net->mpls.platform_labels;
121628 int ret;
121629- struct ctl_table tmp = {
121630+ ctl_table_no_const tmp = {
121631 .procname = table->procname,
121632 .data = &platform_labels,
121633 .maxlen = sizeof(int),
121634@@ -1055,7 +1055,7 @@ static const struct ctl_table mpls_table[] = {
121635
121636 static int mpls_net_init(struct net *net)
121637 {
121638- struct ctl_table *table;
121639+ ctl_table_no_const *table;
121640
121641 net->mpls.platform_labels = 0;
121642 net->mpls.platform_label = NULL;
121643diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
121644index 6eae69a..ccccba8 100644
121645--- a/net/netfilter/Kconfig
121646+++ b/net/netfilter/Kconfig
121647@@ -1125,6 +1125,16 @@ config NETFILTER_XT_MATCH_ESP
121648
121649 To compile it as a module, choose M here. If unsure, say N.
121650
121651+config NETFILTER_XT_MATCH_GRADM
121652+ tristate '"gradm" match support'
121653+ depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
121654+ depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
121655+ ---help---
121656+ The gradm match allows to match on grsecurity RBAC being enabled.
121657+ It is useful when iptables rules are applied early on bootup to
121658+ prevent connections to the machine (except from a trusted host)
121659+ while the RBAC system is disabled.
121660+
121661 config NETFILTER_XT_MATCH_HASHLIMIT
121662 tristate '"hashlimit" match support'
121663 depends on IP6_NF_IPTABLES || IP6_NF_IPTABLES=n
121664diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
121665index 70d026d..c400590 100644
121666--- a/net/netfilter/Makefile
121667+++ b/net/netfilter/Makefile
121668@@ -140,6 +140,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
121669 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
121670 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
121671 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
121672+obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
121673 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
121674 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
121675 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
121676diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
121677index 338b404..839dcb0 100644
121678--- a/net/netfilter/ipset/ip_set_core.c
121679+++ b/net/netfilter/ipset/ip_set_core.c
121680@@ -1998,7 +1998,7 @@ done:
121681 return ret;
121682 }
121683
121684-static struct nf_sockopt_ops so_set __read_mostly = {
121685+static struct nf_sockopt_ops so_set = {
121686 .pf = PF_INET,
121687 .get_optmin = SO_IP_SET,
121688 .get_optmax = SO_IP_SET + 1,
121689diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
121690index b0f7b62..0541842 100644
121691--- a/net/netfilter/ipvs/ip_vs_conn.c
121692+++ b/net/netfilter/ipvs/ip_vs_conn.c
121693@@ -572,7 +572,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
121694 /* Increase the refcnt counter of the dest */
121695 ip_vs_dest_hold(dest);
121696
121697- conn_flags = atomic_read(&dest->conn_flags);
121698+ conn_flags = atomic_read_unchecked(&dest->conn_flags);
121699 if (cp->protocol != IPPROTO_UDP)
121700 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
121701 flags = cp->flags;
121702@@ -922,7 +922,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p, int dest_af,
121703
121704 cp->control = NULL;
121705 atomic_set(&cp->n_control, 0);
121706- atomic_set(&cp->in_pkts, 0);
121707+ atomic_set_unchecked(&cp->in_pkts, 0);
121708
121709 cp->packet_xmit = NULL;
121710 cp->app = NULL;
121711@@ -1229,7 +1229,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
121712
121713 /* Don't drop the entry if its number of incoming packets is not
121714 located in [0, 8] */
121715- i = atomic_read(&cp->in_pkts);
121716+ i = atomic_read_unchecked(&cp->in_pkts);
121717 if (i > 8 || i < 0) return 0;
121718
121719 if (!todrop_rate[i]) return 0;
121720diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
121721index 38fbc19..4272cb4 100644
121722--- a/net/netfilter/ipvs/ip_vs_core.c
121723+++ b/net/netfilter/ipvs/ip_vs_core.c
121724@@ -586,7 +586,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
121725 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
121726 /* do not touch skb anymore */
121727
121728- atomic_inc(&cp->in_pkts);
121729+ atomic_inc_unchecked(&cp->in_pkts);
121730 ip_vs_conn_put(cp);
121731 return ret;
121732 }
121733@@ -1762,7 +1762,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
121734 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
121735 pkts = sysctl_sync_threshold(ipvs);
121736 else
121737- pkts = atomic_add_return(1, &cp->in_pkts);
121738+ pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
121739
121740 if (ipvs->sync_state & IP_VS_STATE_MASTER)
121741 ip_vs_sync_conn(net, cp, pkts);
121742diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
121743index 24c5542..e9fd3e5 100644
121744--- a/net/netfilter/ipvs/ip_vs_ctl.c
121745+++ b/net/netfilter/ipvs/ip_vs_ctl.c
121746@@ -814,7 +814,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
121747 */
121748 ip_vs_rs_hash(ipvs, dest);
121749 }
121750- atomic_set(&dest->conn_flags, conn_flags);
121751+ atomic_set_unchecked(&dest->conn_flags, conn_flags);
121752
121753 /* bind the service */
121754 old_svc = rcu_dereference_protected(dest->svc, 1);
121755@@ -1694,7 +1694,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
121756 * align with netns init in ip_vs_control_net_init()
121757 */
121758
121759-static struct ctl_table vs_vars[] = {
121760+static ctl_table_no_const vs_vars[] __read_only = {
121761 {
121762 .procname = "amemthresh",
121763 .maxlen = sizeof(int),
121764@@ -2036,7 +2036,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
121765 " %-7s %-6d %-10d %-10d\n",
121766 &dest->addr.in6,
121767 ntohs(dest->port),
121768- ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
121769+ ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
121770 atomic_read(&dest->weight),
121771 atomic_read(&dest->activeconns),
121772 atomic_read(&dest->inactconns));
121773@@ -2047,7 +2047,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
121774 "%-7s %-6d %-10d %-10d\n",
121775 ntohl(dest->addr.ip),
121776 ntohs(dest->port),
121777- ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
121778+ ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
121779 atomic_read(&dest->weight),
121780 atomic_read(&dest->activeconns),
121781 atomic_read(&dest->inactconns));
121782@@ -2546,7 +2546,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
121783
121784 entry.addr = dest->addr.ip;
121785 entry.port = dest->port;
121786- entry.conn_flags = atomic_read(&dest->conn_flags);
121787+ entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
121788 entry.weight = atomic_read(&dest->weight);
121789 entry.u_threshold = dest->u_threshold;
121790 entry.l_threshold = dest->l_threshold;
121791@@ -3121,7 +3121,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
121792 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
121793 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
121794 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
121795- (atomic_read(&dest->conn_flags) &
121796+ (atomic_read_unchecked(&dest->conn_flags) &
121797 IP_VS_CONN_F_FWD_MASK)) ||
121798 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
121799 atomic_read(&dest->weight)) ||
121800@@ -3759,7 +3759,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
121801 {
121802 int idx;
121803 struct netns_ipvs *ipvs = net_ipvs(net);
121804- struct ctl_table *tbl;
121805+ ctl_table_no_const *tbl;
121806
121807 atomic_set(&ipvs->dropentry, 0);
121808 spin_lock_init(&ipvs->dropentry_lock);
121809diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
121810index 127f140..553d652 100644
121811--- a/net/netfilter/ipvs/ip_vs_lblc.c
121812+++ b/net/netfilter/ipvs/ip_vs_lblc.c
121813@@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
121814 * IPVS LBLC sysctl table
121815 */
121816 #ifdef CONFIG_SYSCTL
121817-static struct ctl_table vs_vars_table[] = {
121818+static ctl_table_no_const vs_vars_table[] __read_only = {
121819 {
121820 .procname = "lblc_expiration",
121821 .data = NULL,
121822diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
121823index 2229d2d..b32b785 100644
121824--- a/net/netfilter/ipvs/ip_vs_lblcr.c
121825+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
121826@@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
121827 * IPVS LBLCR sysctl table
121828 */
121829
121830-static struct ctl_table vs_vars_table[] = {
121831+static ctl_table_no_const vs_vars_table[] __read_only = {
121832 {
121833 .procname = "lblcr_expiration",
121834 .data = NULL,
121835diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
121836index d99ad93..09bd6dc 100644
121837--- a/net/netfilter/ipvs/ip_vs_sync.c
121838+++ b/net/netfilter/ipvs/ip_vs_sync.c
121839@@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
121840 cp = cp->control;
121841 if (cp) {
121842 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
121843- pkts = atomic_add_return(1, &cp->in_pkts);
121844+ pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
121845 else
121846 pkts = sysctl_sync_threshold(ipvs);
121847 ip_vs_sync_conn(net, cp, pkts);
121848@@ -771,7 +771,7 @@ control:
121849 if (!cp)
121850 return;
121851 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
121852- pkts = atomic_add_return(1, &cp->in_pkts);
121853+ pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
121854 else
121855 pkts = sysctl_sync_threshold(ipvs);
121856 goto sloop;
121857@@ -919,7 +919,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
121858
121859 if (opt)
121860 memcpy(&cp->in_seq, opt, sizeof(*opt));
121861- atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
121862+ atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
121863 cp->state = state;
121864 cp->old_state = cp->state;
121865 /*
121866diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
121867index 258a0b0..2082f50 100644
121868--- a/net/netfilter/ipvs/ip_vs_xmit.c
121869+++ b/net/netfilter/ipvs/ip_vs_xmit.c
121870@@ -1259,7 +1259,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
121871 else
121872 rc = NF_ACCEPT;
121873 /* do not touch skb anymore */
121874- atomic_inc(&cp->in_pkts);
121875+ atomic_inc_unchecked(&cp->in_pkts);
121876 goto out;
121877 }
121878
121879@@ -1352,7 +1352,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
121880 else
121881 rc = NF_ACCEPT;
121882 /* do not touch skb anymore */
121883- atomic_inc(&cp->in_pkts);
121884+ atomic_inc_unchecked(&cp->in_pkts);
121885 goto out;
121886 }
121887
121888diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
121889index 45da11a..ef3e5dc 100644
121890--- a/net/netfilter/nf_conntrack_acct.c
121891+++ b/net/netfilter/nf_conntrack_acct.c
121892@@ -64,7 +64,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
121893 #ifdef CONFIG_SYSCTL
121894 static int nf_conntrack_acct_init_sysctl(struct net *net)
121895 {
121896- struct ctl_table *table;
121897+ ctl_table_no_const *table;
121898
121899 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
121900 GFP_KERNEL);
121901diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
121902index 0625a42..b2c15f4 100644
121903--- a/net/netfilter/nf_conntrack_core.c
121904+++ b/net/netfilter/nf_conntrack_core.c
121905@@ -1754,6 +1754,10 @@ void nf_conntrack_init_end(void)
121906 #define DYING_NULLS_VAL ((1<<30)+1)
121907 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
121908
121909+#ifdef CONFIG_GRKERNSEC_HIDESYM
121910+static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
121911+#endif
121912+
121913 int nf_conntrack_init_net(struct net *net)
121914 {
121915 int ret = -ENOMEM;
121916@@ -1778,7 +1782,11 @@ int nf_conntrack_init_net(struct net *net)
121917 if (!net->ct.stat)
121918 goto err_pcpu_lists;
121919
121920+#ifdef CONFIG_GRKERNSEC_HIDESYM
121921+ net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08x", atomic_inc_return_unchecked(&conntrack_cache_id));
121922+#else
121923 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
121924+#endif
121925 if (!net->ct.slabname)
121926 goto err_slabname;
121927
121928diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
121929index 4e78c57..ec8fb74 100644
121930--- a/net/netfilter/nf_conntrack_ecache.c
121931+++ b/net/netfilter/nf_conntrack_ecache.c
121932@@ -264,7 +264,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
121933 #ifdef CONFIG_SYSCTL
121934 static int nf_conntrack_event_init_sysctl(struct net *net)
121935 {
121936- struct ctl_table *table;
121937+ ctl_table_no_const *table;
121938
121939 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
121940 GFP_KERNEL);
121941diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
121942index bd9d315..989947e 100644
121943--- a/net/netfilter/nf_conntrack_helper.c
121944+++ b/net/netfilter/nf_conntrack_helper.c
121945@@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
121946
121947 static int nf_conntrack_helper_init_sysctl(struct net *net)
121948 {
121949- struct ctl_table *table;
121950+ ctl_table_no_const *table;
121951
121952 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
121953 GFP_KERNEL);
121954diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
121955index b65d586..beec902 100644
121956--- a/net/netfilter/nf_conntrack_proto.c
121957+++ b/net/netfilter/nf_conntrack_proto.c
121958@@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
121959
121960 static void
121961 nf_ct_unregister_sysctl(struct ctl_table_header **header,
121962- struct ctl_table **table,
121963+ ctl_table_no_const **table,
121964 unsigned int users)
121965 {
121966 if (users > 0)
121967diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
121968index fc823fa..8311af3 100644
121969--- a/net/netfilter/nf_conntrack_standalone.c
121970+++ b/net/netfilter/nf_conntrack_standalone.c
121971@@ -468,7 +468,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
121972
121973 static int nf_conntrack_standalone_init_sysctl(struct net *net)
121974 {
121975- struct ctl_table *table;
121976+ ctl_table_no_const *table;
121977
121978 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
121979 GFP_KERNEL);
121980diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
121981index 7a394df..bd91a8a 100644
121982--- a/net/netfilter/nf_conntrack_timestamp.c
121983+++ b/net/netfilter/nf_conntrack_timestamp.c
121984@@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
121985 #ifdef CONFIG_SYSCTL
121986 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
121987 {
121988- struct ctl_table *table;
121989+ ctl_table_no_const *table;
121990
121991 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
121992 GFP_KERNEL);
121993diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
121994index a5d41df..1ff49be 100644
121995--- a/net/netfilter/nf_log.c
121996+++ b/net/netfilter/nf_log.c
121997@@ -391,7 +391,7 @@ static const struct file_operations nflog_file_ops = {
121998
121999 #ifdef CONFIG_SYSCTL
122000 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
122001-static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
122002+static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
122003
122004 static int nf_log_proc_dostring(struct ctl_table *table, int write,
122005 void __user *buffer, size_t *lenp, loff_t *ppos)
122006@@ -422,13 +422,15 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
122007 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
122008 mutex_unlock(&nf_log_mutex);
122009 } else {
122010+ ctl_table_no_const nf_log_table = *table;
122011+
122012 mutex_lock(&nf_log_mutex);
122013 logger = nft_log_dereference(net->nf.nf_loggers[tindex]);
122014 if (!logger)
122015- table->data = "NONE";
122016+ nf_log_table.data = "NONE";
122017 else
122018- table->data = logger->name;
122019- r = proc_dostring(table, write, buffer, lenp, ppos);
122020+ nf_log_table.data = logger->name;
122021+ r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
122022 mutex_unlock(&nf_log_mutex);
122023 }
122024
122025diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
122026index c68c1e5..8b5d670 100644
122027--- a/net/netfilter/nf_sockopt.c
122028+++ b/net/netfilter/nf_sockopt.c
122029@@ -43,7 +43,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
122030 }
122031 }
122032
122033- list_add(&reg->list, &nf_sockopts);
122034+ pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
122035 out:
122036 mutex_unlock(&nf_sockopt_mutex);
122037 return ret;
122038@@ -53,7 +53,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
122039 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
122040 {
122041 mutex_lock(&nf_sockopt_mutex);
122042- list_del(&reg->list);
122043+ pax_list_del((struct list_head *)&reg->list);
122044 mutex_unlock(&nf_sockopt_mutex);
122045 }
122046 EXPORT_SYMBOL(nf_unregister_sockopt);
122047diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
122048index 4670821..a6c3c47d 100644
122049--- a/net/netfilter/nfnetlink_log.c
122050+++ b/net/netfilter/nfnetlink_log.c
122051@@ -84,7 +84,7 @@ static int nfnl_log_net_id __read_mostly;
122052 struct nfnl_log_net {
122053 spinlock_t instances_lock;
122054 struct hlist_head instance_table[INSTANCE_BUCKETS];
122055- atomic_t global_seq;
122056+ atomic_unchecked_t global_seq;
122057 };
122058
122059 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
122060@@ -572,7 +572,7 @@ __build_packet_message(struct nfnl_log_net *log,
122061 /* global sequence number */
122062 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
122063 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
122064- htonl(atomic_inc_return(&log->global_seq))))
122065+ htonl(atomic_inc_return_unchecked(&log->global_seq))))
122066 goto nla_put_failure;
122067
122068 if (data_len) {
122069diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
122070index 9c8fab0..5080c7c 100644
122071--- a/net/netfilter/nft_compat.c
122072+++ b/net/netfilter/nft_compat.c
122073@@ -322,14 +322,7 @@ static void nft_match_eval(const struct nft_expr *expr,
122074 return;
122075 }
122076
122077- switch (ret ? 1 : 0) {
122078- case 1:
122079- regs->verdict.code = NFT_CONTINUE;
122080- break;
122081- case 0:
122082- regs->verdict.code = NFT_BREAK;
122083- break;
122084- }
122085+ regs->verdict.code = ret ? NFT_CONTINUE : NFT_BREAK;
122086 }
122087
122088 static const struct nla_policy nft_match_policy[NFTA_MATCH_MAX + 1] = {
122089diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
122090new file mode 100644
122091index 0000000..c566332
122092--- /dev/null
122093+++ b/net/netfilter/xt_gradm.c
122094@@ -0,0 +1,51 @@
122095+/*
122096+ * gradm match for netfilter
122097