]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blame - test/grsecurity-3.1-4.2.5-201510290852.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.1-4.2.5-201510290852.patch
CommitLineData
c3f73f4b
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 96076dc..451272d 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/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
10047index 4082749..fd97781 100644
10048--- a/arch/sparc/include/asm/atomic_64.h
10049+++ b/arch/sparc/include/asm/atomic_64.h
10050@@ -15,18 +15,38 @@
10051 #define ATOMIC64_INIT(i) { (i) }
10052
10053 #define atomic_read(v) ACCESS_ONCE((v)->counter)
10054+static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
10055+{
10056+ return ACCESS_ONCE(v->counter);
10057+}
10058 #define atomic64_read(v) ACCESS_ONCE((v)->counter)
10059+static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
10060+{
10061+ return ACCESS_ONCE(v->counter);
10062+}
10063
10064 #define atomic_set(v, i) (((v)->counter) = i)
10065+static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
10066+{
10067+ v->counter = i;
10068+}
10069 #define atomic64_set(v, i) (((v)->counter) = i)
10070+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
10071+{
10072+ v->counter = i;
10073+}
10074
10075-#define ATOMIC_OP(op) \
10076-void atomic_##op(int, atomic_t *); \
10077-void atomic64_##op(long, atomic64_t *);
10078+#define __ATOMIC_OP(op, suffix) \
10079+void atomic_##op##suffix(int, atomic##suffix##_t *); \
10080+void atomic64_##op##suffix(long, atomic64##suffix##_t *);
10081
10082-#define ATOMIC_OP_RETURN(op) \
10083-int atomic_##op##_return(int, atomic_t *); \
10084-long atomic64_##op##_return(long, atomic64_t *);
10085+#define ATOMIC_OP(op) __ATOMIC_OP(op, ) __ATOMIC_OP(op, _unchecked)
10086+
10087+#define __ATOMIC_OP_RETURN(op, suffix) \
10088+int atomic_##op##_return##suffix(int, atomic##suffix##_t *); \
10089+long atomic64_##op##_return##suffix(long, atomic64##suffix##_t *);
10090+
10091+#define ATOMIC_OP_RETURN(op) __ATOMIC_OP_RETURN(op, ) __ATOMIC_OP_RETURN(op, _unchecked)
10092
10093 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
10094
10095@@ -35,13 +55,23 @@ ATOMIC_OPS(sub)
10096
10097 #undef ATOMIC_OPS
10098 #undef ATOMIC_OP_RETURN
10099+#undef __ATOMIC_OP_RETURN
10100 #undef ATOMIC_OP
10101+#undef __ATOMIC_OP
10102
10103 #define atomic_dec_return(v) atomic_sub_return(1, v)
10104 #define atomic64_dec_return(v) atomic64_sub_return(1, v)
10105
10106 #define atomic_inc_return(v) atomic_add_return(1, v)
10107+static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
10108+{
10109+ return atomic_add_return_unchecked(1, v);
10110+}
10111 #define atomic64_inc_return(v) atomic64_add_return(1, v)
10112+static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
10113+{
10114+ return atomic64_add_return_unchecked(1, v);
10115+}
10116
10117 /*
10118 * atomic_inc_and_test - increment and test
10119@@ -52,6 +82,10 @@ ATOMIC_OPS(sub)
10120 * other cases.
10121 */
10122 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
10123+static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
10124+{
10125+ return atomic_inc_return_unchecked(v) == 0;
10126+}
10127 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
10128
10129 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
10130@@ -61,25 +95,60 @@ ATOMIC_OPS(sub)
10131 #define atomic64_dec_and_test(v) (atomic64_sub_return(1, v) == 0)
10132
10133 #define atomic_inc(v) atomic_add(1, v)
10134+static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
10135+{
10136+ atomic_add_unchecked(1, v);
10137+}
10138 #define atomic64_inc(v) atomic64_add(1, v)
10139+static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
10140+{
10141+ atomic64_add_unchecked(1, v);
10142+}
10143
10144 #define atomic_dec(v) atomic_sub(1, v)
10145+static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
10146+{
10147+ atomic_sub_unchecked(1, v);
10148+}
10149 #define atomic64_dec(v) atomic64_sub(1, v)
10150+static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
10151+{
10152+ atomic64_sub_unchecked(1, v);
10153+}
10154
10155 #define atomic_add_negative(i, v) (atomic_add_return(i, v) < 0)
10156 #define atomic64_add_negative(i, v) (atomic64_add_return(i, v) < 0)
10157
10158 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
10159+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
10160+{
10161+ return cmpxchg(&v->counter, old, new);
10162+}
10163 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
10164+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
10165+{
10166+ return xchg(&v->counter, new);
10167+}
10168
10169 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
10170 {
10171- int c, old;
10172+ int c, old, new;
10173 c = atomic_read(v);
10174 for (;;) {
10175- if (unlikely(c == (u)))
10176+ if (unlikely(c == u))
10177 break;
10178- old = atomic_cmpxchg((v), c, c + (a));
10179+
10180+ asm volatile("addcc %2, %0, %0\n"
10181+
10182+#ifdef CONFIG_PAX_REFCOUNT
10183+ "tvs %%icc, 6\n"
10184+#endif
10185+
10186+ : "=r" (new)
10187+ : "0" (c), "ir" (a)
10188+ : "cc");
10189+
10190+ old = atomic_cmpxchg(v, c, new);
10191 if (likely(old == c))
10192 break;
10193 c = old;
10194@@ -90,20 +159,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
10195 #define atomic64_cmpxchg(v, o, n) \
10196 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
10197 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
10198+static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
10199+{
10200+ return xchg(&v->counter, new);
10201+}
10202
10203 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10204 {
10205- long c, old;
10206+ long c, old, new;
10207 c = atomic64_read(v);
10208 for (;;) {
10209- if (unlikely(c == (u)))
10210+ if (unlikely(c == u))
10211 break;
10212- old = atomic64_cmpxchg((v), c, c + (a));
10213+
10214+ asm volatile("addcc %2, %0, %0\n"
10215+
10216+#ifdef CONFIG_PAX_REFCOUNT
10217+ "tvs %%xcc, 6\n"
10218+#endif
10219+
10220+ : "=r" (new)
10221+ : "0" (c), "ir" (a)
10222+ : "cc");
10223+
10224+ old = atomic64_cmpxchg(v, c, new);
10225 if (likely(old == c))
10226 break;
10227 c = old;
10228 }
10229- return c != (u);
10230+ return c != u;
10231 }
10232
10233 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10234diff --git a/arch/sparc/include/asm/barrier_64.h b/arch/sparc/include/asm/barrier_64.h
10235index 809941e..b443309 100644
10236--- a/arch/sparc/include/asm/barrier_64.h
10237+++ b/arch/sparc/include/asm/barrier_64.h
10238@@ -60,7 +60,7 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
10239 do { \
10240 compiletime_assert_atomic_type(*p); \
10241 barrier(); \
10242- ACCESS_ONCE(*p) = (v); \
10243+ ACCESS_ONCE_RW(*p) = (v); \
10244 } while (0)
10245
10246 #define smp_load_acquire(p) \
10247diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
10248index 5bb6991..5c2132e 100644
10249--- a/arch/sparc/include/asm/cache.h
10250+++ b/arch/sparc/include/asm/cache.h
10251@@ -7,10 +7,12 @@
10252 #ifndef _SPARC_CACHE_H
10253 #define _SPARC_CACHE_H
10254
10255+#include <linux/const.h>
10256+
10257 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
10258
10259 #define L1_CACHE_SHIFT 5
10260-#define L1_CACHE_BYTES 32
10261+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10262
10263 #ifdef CONFIG_SPARC32
10264 #define SMP_CACHE_BYTES_SHIFT 5
10265diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
10266index a24e41f..47677ff 100644
10267--- a/arch/sparc/include/asm/elf_32.h
10268+++ b/arch/sparc/include/asm/elf_32.h
10269@@ -114,6 +114,13 @@ typedef struct {
10270
10271 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
10272
10273+#ifdef CONFIG_PAX_ASLR
10274+#define PAX_ELF_ET_DYN_BASE 0x10000UL
10275+
10276+#define PAX_DELTA_MMAP_LEN 16
10277+#define PAX_DELTA_STACK_LEN 16
10278+#endif
10279+
10280 /* This yields a mask that user programs can use to figure out what
10281 instruction set this cpu supports. This can NOT be done in userspace
10282 on Sparc. */
10283diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
10284index 370ca1e..d4f4a98 100644
10285--- a/arch/sparc/include/asm/elf_64.h
10286+++ b/arch/sparc/include/asm/elf_64.h
10287@@ -189,6 +189,13 @@ typedef struct {
10288 #define ELF_ET_DYN_BASE 0x0000010000000000UL
10289 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
10290
10291+#ifdef CONFIG_PAX_ASLR
10292+#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
10293+
10294+#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
10295+#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
10296+#endif
10297+
10298 extern unsigned long sparc64_elf_hwcap;
10299 #define ELF_HWCAP sparc64_elf_hwcap
10300
10301diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
10302index a3890da..f6a408e 100644
10303--- a/arch/sparc/include/asm/pgalloc_32.h
10304+++ b/arch/sparc/include/asm/pgalloc_32.h
10305@@ -35,6 +35,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
10306 }
10307
10308 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
10309+#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
10310
10311 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
10312 unsigned long address)
10313diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
10314index 5e31871..13469c6 100644
10315--- a/arch/sparc/include/asm/pgalloc_64.h
10316+++ b/arch/sparc/include/asm/pgalloc_64.h
10317@@ -21,6 +21,7 @@ static inline void __pgd_populate(pgd_t *pgd, pud_t *pud)
10318 }
10319
10320 #define pgd_populate(MM, PGD, PUD) __pgd_populate(PGD, PUD)
10321+#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
10322
10323 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
10324 {
10325@@ -38,6 +39,7 @@ static inline void __pud_populate(pud_t *pud, pmd_t *pmd)
10326 }
10327
10328 #define pud_populate(MM, PUD, PMD) __pud_populate(PUD, PMD)
10329+#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
10330
10331 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
10332 {
10333diff --git a/arch/sparc/include/asm/pgtable.h b/arch/sparc/include/asm/pgtable.h
10334index 59ba6f6..4518128 100644
10335--- a/arch/sparc/include/asm/pgtable.h
10336+++ b/arch/sparc/include/asm/pgtable.h
10337@@ -5,4 +5,8 @@
10338 #else
10339 #include <asm/pgtable_32.h>
10340 #endif
10341+
10342+#define ktla_ktva(addr) (addr)
10343+#define ktva_ktla(addr) (addr)
10344+
10345 #endif
10346diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
10347index f06b36a..bca3189 100644
10348--- a/arch/sparc/include/asm/pgtable_32.h
10349+++ b/arch/sparc/include/asm/pgtable_32.h
10350@@ -51,6 +51,9 @@ unsigned long __init bootmem_init(unsigned long *pages_avail);
10351 #define PAGE_SHARED SRMMU_PAGE_SHARED
10352 #define PAGE_COPY SRMMU_PAGE_COPY
10353 #define PAGE_READONLY SRMMU_PAGE_RDONLY
10354+#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
10355+#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
10356+#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
10357 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
10358
10359 /* Top-level page directory - dummy used by init-mm.
10360@@ -63,18 +66,18 @@ extern unsigned long ptr_in_current_pgd;
10361
10362 /* xwr */
10363 #define __P000 PAGE_NONE
10364-#define __P001 PAGE_READONLY
10365-#define __P010 PAGE_COPY
10366-#define __P011 PAGE_COPY
10367+#define __P001 PAGE_READONLY_NOEXEC
10368+#define __P010 PAGE_COPY_NOEXEC
10369+#define __P011 PAGE_COPY_NOEXEC
10370 #define __P100 PAGE_READONLY
10371 #define __P101 PAGE_READONLY
10372 #define __P110 PAGE_COPY
10373 #define __P111 PAGE_COPY
10374
10375 #define __S000 PAGE_NONE
10376-#define __S001 PAGE_READONLY
10377-#define __S010 PAGE_SHARED
10378-#define __S011 PAGE_SHARED
10379+#define __S001 PAGE_READONLY_NOEXEC
10380+#define __S010 PAGE_SHARED_NOEXEC
10381+#define __S011 PAGE_SHARED_NOEXEC
10382 #define __S100 PAGE_READONLY
10383 #define __S101 PAGE_READONLY
10384 #define __S110 PAGE_SHARED
10385diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
10386index ae51a11..eadfd03 100644
10387--- a/arch/sparc/include/asm/pgtsrmmu.h
10388+++ b/arch/sparc/include/asm/pgtsrmmu.h
10389@@ -111,6 +111,11 @@
10390 SRMMU_EXEC | SRMMU_REF)
10391 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
10392 SRMMU_EXEC | SRMMU_REF)
10393+
10394+#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
10395+#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
10396+#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
10397+
10398 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
10399 SRMMU_DIRTY | SRMMU_REF)
10400
10401diff --git a/arch/sparc/include/asm/setup.h b/arch/sparc/include/asm/setup.h
10402index 29d64b1..4272fe8 100644
10403--- a/arch/sparc/include/asm/setup.h
10404+++ b/arch/sparc/include/asm/setup.h
10405@@ -55,8 +55,8 @@ int handle_ldf_stq(u32 insn, struct pt_regs *regs);
10406 void handle_ld_nf(u32 insn, struct pt_regs *regs);
10407
10408 /* init_64.c */
10409-extern atomic_t dcpage_flushes;
10410-extern atomic_t dcpage_flushes_xcall;
10411+extern atomic_unchecked_t dcpage_flushes;
10412+extern atomic_unchecked_t dcpage_flushes_xcall;
10413
10414 extern int sysctl_tsb_ratio;
10415 #endif
10416diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
10417index 9689176..63c18ea 100644
10418--- a/arch/sparc/include/asm/spinlock_64.h
10419+++ b/arch/sparc/include/asm/spinlock_64.h
10420@@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
10421
10422 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
10423
10424-static void inline arch_read_lock(arch_rwlock_t *lock)
10425+static inline void arch_read_lock(arch_rwlock_t *lock)
10426 {
10427 unsigned long tmp1, tmp2;
10428
10429 __asm__ __volatile__ (
10430 "1: ldsw [%2], %0\n"
10431 " brlz,pn %0, 2f\n"
10432-"4: add %0, 1, %1\n"
10433+"4: addcc %0, 1, %1\n"
10434+
10435+#ifdef CONFIG_PAX_REFCOUNT
10436+" tvs %%icc, 6\n"
10437+#endif
10438+
10439 " cas [%2], %0, %1\n"
10440 " cmp %0, %1\n"
10441 " bne,pn %%icc, 1b\n"
10442@@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
10443 " .previous"
10444 : "=&r" (tmp1), "=&r" (tmp2)
10445 : "r" (lock)
10446- : "memory");
10447+ : "memory", "cc");
10448 }
10449
10450-static int inline arch_read_trylock(arch_rwlock_t *lock)
10451+static inline int arch_read_trylock(arch_rwlock_t *lock)
10452 {
10453 int tmp1, tmp2;
10454
10455@@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
10456 "1: ldsw [%2], %0\n"
10457 " brlz,a,pn %0, 2f\n"
10458 " mov 0, %0\n"
10459-" add %0, 1, %1\n"
10460+" addcc %0, 1, %1\n"
10461+
10462+#ifdef CONFIG_PAX_REFCOUNT
10463+" tvs %%icc, 6\n"
10464+#endif
10465+
10466 " cas [%2], %0, %1\n"
10467 " cmp %0, %1\n"
10468 " bne,pn %%icc, 1b\n"
10469@@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
10470 return tmp1;
10471 }
10472
10473-static void inline arch_read_unlock(arch_rwlock_t *lock)
10474+static inline void arch_read_unlock(arch_rwlock_t *lock)
10475 {
10476 unsigned long tmp1, tmp2;
10477
10478 __asm__ __volatile__(
10479 "1: lduw [%2], %0\n"
10480-" sub %0, 1, %1\n"
10481+" subcc %0, 1, %1\n"
10482+
10483+#ifdef CONFIG_PAX_REFCOUNT
10484+" tvs %%icc, 6\n"
10485+#endif
10486+
10487 " cas [%2], %0, %1\n"
10488 " cmp %0, %1\n"
10489 " bne,pn %%xcc, 1b\n"
10490@@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
10491 : "memory");
10492 }
10493
10494-static void inline arch_write_lock(arch_rwlock_t *lock)
10495+static inline void arch_write_lock(arch_rwlock_t *lock)
10496 {
10497 unsigned long mask, tmp1, tmp2;
10498
10499@@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
10500 : "memory");
10501 }
10502
10503-static void inline arch_write_unlock(arch_rwlock_t *lock)
10504+static inline void arch_write_unlock(arch_rwlock_t *lock)
10505 {
10506 __asm__ __volatile__(
10507 " stw %%g0, [%0]"
10508@@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
10509 : "memory");
10510 }
10511
10512-static int inline arch_write_trylock(arch_rwlock_t *lock)
10513+static inline int arch_write_trylock(arch_rwlock_t *lock)
10514 {
10515 unsigned long mask, tmp1, tmp2, result;
10516
10517diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
10518index 229475f..2fca9163 100644
10519--- a/arch/sparc/include/asm/thread_info_32.h
10520+++ b/arch/sparc/include/asm/thread_info_32.h
10521@@ -48,6 +48,7 @@ struct thread_info {
10522 struct reg_window32 reg_window[NSWINS]; /* align for ldd! */
10523 unsigned long rwbuf_stkptrs[NSWINS];
10524 unsigned long w_saved;
10525+ unsigned long lowest_stack;
10526 };
10527
10528 /*
10529diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
10530index bde5982..9cbb56d 100644
10531--- a/arch/sparc/include/asm/thread_info_64.h
10532+++ b/arch/sparc/include/asm/thread_info_64.h
10533@@ -59,6 +59,8 @@ struct thread_info {
10534 struct pt_regs *kern_una_regs;
10535 unsigned int kern_una_insn;
10536
10537+ unsigned long lowest_stack;
10538+
10539 unsigned long fpregs[(7 * 256) / sizeof(unsigned long)]
10540 __attribute__ ((aligned(64)));
10541 };
10542@@ -180,12 +182,13 @@ register struct thread_info *current_thread_info_reg asm("g6");
10543 #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
10544 /* flag bit 4 is available */
10545 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
10546-/* flag bit 6 is available */
10547+#define TIF_GRSEC_SETXID 6 /* update credentials on syscall entry/exit */
10548 #define TIF_32BIT 7 /* 32-bit binary */
10549 #define TIF_NOHZ 8 /* in adaptive nohz mode */
10550 #define TIF_SECCOMP 9 /* secure computing */
10551 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
10552 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
10553+
10554 /* NOTE: Thread flags >= 12 should be ones we have no interest
10555 * in using in assembly, else we can't use the mask as
10556 * an immediate value in instructions such as andcc.
10557@@ -205,12 +208,17 @@ register struct thread_info *current_thread_info_reg asm("g6");
10558 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
10559 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
10560 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
10561+#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
10562
10563 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
10564 _TIF_DO_NOTIFY_RESUME_MASK | \
10565 _TIF_NEED_RESCHED)
10566 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
10567
10568+#define _TIF_WORK_SYSCALL \
10569+ (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
10570+ _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
10571+
10572 #define is_32bit_task() (test_thread_flag(TIF_32BIT))
10573
10574 /*
10575diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
10576index bd56c28..4b63d83 100644
10577--- a/arch/sparc/include/asm/uaccess.h
10578+++ b/arch/sparc/include/asm/uaccess.h
10579@@ -1,5 +1,6 @@
10580 #ifndef ___ASM_SPARC_UACCESS_H
10581 #define ___ASM_SPARC_UACCESS_H
10582+
10583 #if defined(__sparc__) && defined(__arch64__)
10584 #include <asm/uaccess_64.h>
10585 #else
10586diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
10587index 64ee103..388aef0 100644
10588--- a/arch/sparc/include/asm/uaccess_32.h
10589+++ b/arch/sparc/include/asm/uaccess_32.h
10590@@ -47,6 +47,7 @@
10591 #define __user_ok(addr, size) ({ (void)(size); (addr) < STACK_TOP; })
10592 #define __kernel_ok (segment_eq(get_fs(), KERNEL_DS))
10593 #define __access_ok(addr, size) (__user_ok((addr) & get_fs().seg, (size)))
10594+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
10595 #define access_ok(type, addr, size) \
10596 ({ (void)(type); __access_ok((unsigned long)(addr), size); })
10597
10598@@ -313,27 +314,46 @@ unsigned long __copy_user(void __user *to, const void __user *from, unsigned lon
10599
10600 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
10601 {
10602- if (n && __access_ok((unsigned long) to, n))
10603+ if ((long)n < 0)
10604+ return n;
10605+
10606+ if (n && __access_ok((unsigned long) to, n)) {
10607+ if (!__builtin_constant_p(n))
10608+ check_object_size(from, n, true);
10609 return __copy_user(to, (__force void __user *) from, n);
10610- else
10611+ } else
10612 return n;
10613 }
10614
10615 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
10616 {
10617+ if ((long)n < 0)
10618+ return n;
10619+
10620+ if (!__builtin_constant_p(n))
10621+ check_object_size(from, n, true);
10622+
10623 return __copy_user(to, (__force void __user *) from, n);
10624 }
10625
10626 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
10627 {
10628- if (n && __access_ok((unsigned long) from, n))
10629+ if ((long)n < 0)
10630+ return n;
10631+
10632+ if (n && __access_ok((unsigned long) from, n)) {
10633+ if (!__builtin_constant_p(n))
10634+ check_object_size(to, n, false);
10635 return __copy_user((__force void __user *) to, from, n);
10636- else
10637+ } else
10638 return n;
10639 }
10640
10641 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
10642 {
10643+ if ((long)n < 0)
10644+ return n;
10645+
10646 return __copy_user((__force void __user *) to, from, n);
10647 }
10648
10649diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
10650index ea6e9a2..5703598 100644
10651--- a/arch/sparc/include/asm/uaccess_64.h
10652+++ b/arch/sparc/include/asm/uaccess_64.h
10653@@ -10,6 +10,7 @@
10654 #include <linux/compiler.h>
10655 #include <linux/string.h>
10656 #include <linux/thread_info.h>
10657+#include <linux/kernel.h>
10658 #include <asm/asi.h>
10659 #include <asm/spitfire.h>
10660 #include <asm-generic/uaccess-unaligned.h>
10661@@ -76,6 +77,11 @@ static inline int __access_ok(const void __user * addr, unsigned long size)
10662 return 1;
10663 }
10664
10665+static inline int access_ok_noprefault(int type, const void __user * addr, unsigned long size)
10666+{
10667+ return 1;
10668+}
10669+
10670 static inline int access_ok(int type, const void __user * addr, unsigned long size)
10671 {
10672 return 1;
10673@@ -250,8 +256,15 @@ unsigned long copy_from_user_fixup(void *to, const void __user *from,
10674 static inline unsigned long __must_check
10675 copy_from_user(void *to, const void __user *from, unsigned long size)
10676 {
10677- unsigned long ret = ___copy_from_user(to, from, size);
10678+ unsigned long ret;
10679
10680+ if ((long)size < 0 || size > INT_MAX)
10681+ return size;
10682+
10683+ if (!__builtin_constant_p(size))
10684+ check_object_size(to, size, false);
10685+
10686+ ret = ___copy_from_user(to, from, size);
10687 if (unlikely(ret))
10688 ret = copy_from_user_fixup(to, from, size);
10689
10690@@ -267,8 +280,15 @@ unsigned long copy_to_user_fixup(void __user *to, const void *from,
10691 static inline unsigned long __must_check
10692 copy_to_user(void __user *to, const void *from, unsigned long size)
10693 {
10694- unsigned long ret = ___copy_to_user(to, from, size);
10695+ unsigned long ret;
10696
10697+ if ((long)size < 0 || size > INT_MAX)
10698+ return size;
10699+
10700+ if (!__builtin_constant_p(size))
10701+ check_object_size(from, size, true);
10702+
10703+ ret = ___copy_to_user(to, from, size);
10704 if (unlikely(ret))
10705 ret = copy_to_user_fixup(to, from, size);
10706 return ret;
10707diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
10708index 7cf9c6e..6206648 100644
10709--- a/arch/sparc/kernel/Makefile
10710+++ b/arch/sparc/kernel/Makefile
10711@@ -4,7 +4,7 @@
10712 #
10713
10714 asflags-y := -ansi
10715-ccflags-y := -Werror
10716+#ccflags-y := -Werror
10717
10718 extra-y := head_$(BITS).o
10719
10720diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
10721index 50e7b62..79fae35 100644
10722--- a/arch/sparc/kernel/process_32.c
10723+++ b/arch/sparc/kernel/process_32.c
10724@@ -123,14 +123,14 @@ void show_regs(struct pt_regs *r)
10725
10726 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
10727 r->psr, r->pc, r->npc, r->y, print_tainted());
10728- printk("PC: <%pS>\n", (void *) r->pc);
10729+ printk("PC: <%pA>\n", (void *) r->pc);
10730 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10731 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
10732 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
10733 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10734 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
10735 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
10736- printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
10737+ printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
10738
10739 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10740 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
10741@@ -167,7 +167,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10742 rw = (struct reg_window32 *) fp;
10743 pc = rw->ins[7];
10744 printk("[%08lx : ", pc);
10745- printk("%pS ] ", (void *) pc);
10746+ printk("%pA ] ", (void *) pc);
10747 fp = rw->ins[6];
10748 } while (++count < 16);
10749 printk("\n");
10750diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
10751index 46a5964..a35c62c 100644
10752--- a/arch/sparc/kernel/process_64.c
10753+++ b/arch/sparc/kernel/process_64.c
10754@@ -161,7 +161,7 @@ static void show_regwindow(struct pt_regs *regs)
10755 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
10756 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
10757 if (regs->tstate & TSTATE_PRIV)
10758- printk("I7: <%pS>\n", (void *) rwk->ins[7]);
10759+ printk("I7: <%pA>\n", (void *) rwk->ins[7]);
10760 }
10761
10762 void show_regs(struct pt_regs *regs)
10763@@ -170,7 +170,7 @@ void show_regs(struct pt_regs *regs)
10764
10765 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
10766 regs->tpc, regs->tnpc, regs->y, print_tainted());
10767- printk("TPC: <%pS>\n", (void *) regs->tpc);
10768+ printk("TPC: <%pA>\n", (void *) regs->tpc);
10769 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
10770 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
10771 regs->u_regs[3]);
10772@@ -183,7 +183,7 @@ void show_regs(struct pt_regs *regs)
10773 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
10774 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
10775 regs->u_regs[15]);
10776- printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
10777+ printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
10778 show_regwindow(regs);
10779 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
10780 }
10781@@ -278,7 +278,7 @@ void arch_trigger_all_cpu_backtrace(bool include_self)
10782 ((tp && tp->task) ? tp->task->pid : -1));
10783
10784 if (gp->tstate & TSTATE_PRIV) {
10785- printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
10786+ printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
10787 (void *) gp->tpc,
10788 (void *) gp->o7,
10789 (void *) gp->i7,
10790diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
10791index 79cc0d1..ec62734 100644
10792--- a/arch/sparc/kernel/prom_common.c
10793+++ b/arch/sparc/kernel/prom_common.c
10794@@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
10795
10796 unsigned int prom_early_allocated __initdata;
10797
10798-static struct of_pdt_ops prom_sparc_ops __initdata = {
10799+static struct of_pdt_ops prom_sparc_ops __initconst = {
10800 .nextprop = prom_common_nextprop,
10801 .getproplen = prom_getproplen,
10802 .getproperty = prom_getproperty,
10803diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
10804index 9ddc492..27a5619 100644
10805--- a/arch/sparc/kernel/ptrace_64.c
10806+++ b/arch/sparc/kernel/ptrace_64.c
10807@@ -1060,6 +1060,10 @@ long arch_ptrace(struct task_struct *child, long request,
10808 return ret;
10809 }
10810
10811+#ifdef CONFIG_GRKERNSEC_SETXID
10812+extern void gr_delayed_cred_worker(void);
10813+#endif
10814+
10815 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
10816 {
10817 int ret = 0;
10818@@ -1070,6 +1074,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
10819 if (test_thread_flag(TIF_NOHZ))
10820 user_exit();
10821
10822+#ifdef CONFIG_GRKERNSEC_SETXID
10823+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
10824+ gr_delayed_cred_worker();
10825+#endif
10826+
10827 if (test_thread_flag(TIF_SYSCALL_TRACE))
10828 ret = tracehook_report_syscall_entry(regs);
10829
10830@@ -1088,6 +1097,11 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs)
10831 if (test_thread_flag(TIF_NOHZ))
10832 user_exit();
10833
10834+#ifdef CONFIG_GRKERNSEC_SETXID
10835+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
10836+ gr_delayed_cred_worker();
10837+#endif
10838+
10839 audit_syscall_exit(regs);
10840
10841 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
10842diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
10843index 19cd08d..ff21e99 100644
10844--- a/arch/sparc/kernel/smp_64.c
10845+++ b/arch/sparc/kernel/smp_64.c
10846@@ -891,7 +891,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
10847 return;
10848
10849 #ifdef CONFIG_DEBUG_DCFLUSH
10850- atomic_inc(&dcpage_flushes);
10851+ atomic_inc_unchecked(&dcpage_flushes);
10852 #endif
10853
10854 this_cpu = get_cpu();
10855@@ -915,7 +915,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
10856 xcall_deliver(data0, __pa(pg_addr),
10857 (u64) pg_addr, cpumask_of(cpu));
10858 #ifdef CONFIG_DEBUG_DCFLUSH
10859- atomic_inc(&dcpage_flushes_xcall);
10860+ atomic_inc_unchecked(&dcpage_flushes_xcall);
10861 #endif
10862 }
10863 }
10864@@ -934,7 +934,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
10865 preempt_disable();
10866
10867 #ifdef CONFIG_DEBUG_DCFLUSH
10868- atomic_inc(&dcpage_flushes);
10869+ atomic_inc_unchecked(&dcpage_flushes);
10870 #endif
10871 data0 = 0;
10872 pg_addr = page_address(page);
10873@@ -951,7 +951,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
10874 xcall_deliver(data0, __pa(pg_addr),
10875 (u64) pg_addr, cpu_online_mask);
10876 #ifdef CONFIG_DEBUG_DCFLUSH
10877- atomic_inc(&dcpage_flushes_xcall);
10878+ atomic_inc_unchecked(&dcpage_flushes_xcall);
10879 #endif
10880 }
10881 __local_flush_dcache_page(page);
10882diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
10883index 646988d..b88905f 100644
10884--- a/arch/sparc/kernel/sys_sparc_32.c
10885+++ b/arch/sparc/kernel/sys_sparc_32.c
10886@@ -54,7 +54,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10887 if (len > TASK_SIZE - PAGE_SIZE)
10888 return -ENOMEM;
10889 if (!addr)
10890- addr = TASK_UNMAPPED_BASE;
10891+ addr = current->mm->mmap_base;
10892
10893 info.flags = 0;
10894 info.length = len;
10895diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
10896index 30e7ddb..266a3b0 100644
10897--- a/arch/sparc/kernel/sys_sparc_64.c
10898+++ b/arch/sparc/kernel/sys_sparc_64.c
10899@@ -89,13 +89,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10900 struct vm_area_struct * vma;
10901 unsigned long task_size = TASK_SIZE;
10902 int do_color_align;
10903+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
10904 struct vm_unmapped_area_info info;
10905
10906 if (flags & MAP_FIXED) {
10907 /* We do not accept a shared mapping if it would violate
10908 * cache aliasing constraints.
10909 */
10910- if ((flags & MAP_SHARED) &&
10911+ if ((filp || (flags & MAP_SHARED)) &&
10912 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
10913 return -EINVAL;
10914 return addr;
10915@@ -110,6 +111,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10916 if (filp || (flags & MAP_SHARED))
10917 do_color_align = 1;
10918
10919+#ifdef CONFIG_PAX_RANDMMAP
10920+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10921+#endif
10922+
10923 if (addr) {
10924 if (do_color_align)
10925 addr = COLOR_ALIGN(addr, pgoff);
10926@@ -117,22 +122,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10927 addr = PAGE_ALIGN(addr);
10928
10929 vma = find_vma(mm, addr);
10930- if (task_size - len >= addr &&
10931- (!vma || addr + len <= vma->vm_start))
10932+ if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10933 return addr;
10934 }
10935
10936 info.flags = 0;
10937 info.length = len;
10938- info.low_limit = TASK_UNMAPPED_BASE;
10939+ info.low_limit = mm->mmap_base;
10940 info.high_limit = min(task_size, VA_EXCLUDE_START);
10941 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
10942 info.align_offset = pgoff << PAGE_SHIFT;
10943+ info.threadstack_offset = offset;
10944 addr = vm_unmapped_area(&info);
10945
10946 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10947 VM_BUG_ON(addr != -ENOMEM);
10948 info.low_limit = VA_EXCLUDE_END;
10949+
10950+#ifdef CONFIG_PAX_RANDMMAP
10951+ if (mm->pax_flags & MF_PAX_RANDMMAP)
10952+ info.low_limit += mm->delta_mmap;
10953+#endif
10954+
10955 info.high_limit = task_size;
10956 addr = vm_unmapped_area(&info);
10957 }
10958@@ -150,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10959 unsigned long task_size = STACK_TOP32;
10960 unsigned long addr = addr0;
10961 int do_color_align;
10962+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
10963 struct vm_unmapped_area_info info;
10964
10965 /* This should only ever run for 32-bit processes. */
10966@@ -159,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10967 /* We do not accept a shared mapping if it would violate
10968 * cache aliasing constraints.
10969 */
10970- if ((flags & MAP_SHARED) &&
10971+ if ((filp || (flags & MAP_SHARED)) &&
10972 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
10973 return -EINVAL;
10974 return addr;
10975@@ -172,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10976 if (filp || (flags & MAP_SHARED))
10977 do_color_align = 1;
10978
10979+#ifdef CONFIG_PAX_RANDMMAP
10980+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10981+#endif
10982+
10983 /* requesting a specific address */
10984 if (addr) {
10985 if (do_color_align)
10986@@ -180,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10987 addr = PAGE_ALIGN(addr);
10988
10989 vma = find_vma(mm, addr);
10990- if (task_size - len >= addr &&
10991- (!vma || addr + len <= vma->vm_start))
10992+ if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10993 return addr;
10994 }
10995
10996@@ -191,6 +206,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10997 info.high_limit = mm->mmap_base;
10998 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
10999 info.align_offset = pgoff << PAGE_SHIFT;
11000+ info.threadstack_offset = offset;
11001 addr = vm_unmapped_area(&info);
11002
11003 /*
11004@@ -203,6 +219,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11005 VM_BUG_ON(addr != -ENOMEM);
11006 info.flags = 0;
11007 info.low_limit = TASK_UNMAPPED_BASE;
11008+
11009+#ifdef CONFIG_PAX_RANDMMAP
11010+ if (mm->pax_flags & MF_PAX_RANDMMAP)
11011+ info.low_limit += mm->delta_mmap;
11012+#endif
11013+
11014 info.high_limit = STACK_TOP32;
11015 addr = vm_unmapped_area(&info);
11016 }
11017@@ -259,10 +281,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
11018 EXPORT_SYMBOL(get_fb_unmapped_area);
11019
11020 /* Essentially the same as PowerPC. */
11021-static unsigned long mmap_rnd(void)
11022+static unsigned long mmap_rnd(struct mm_struct *mm)
11023 {
11024 unsigned long rnd = 0UL;
11025
11026+#ifdef CONFIG_PAX_RANDMMAP
11027+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11028+#endif
11029+
11030 if (current->flags & PF_RANDOMIZE) {
11031 unsigned long val = get_random_int();
11032 if (test_thread_flag(TIF_32BIT))
11033@@ -275,7 +301,7 @@ static unsigned long mmap_rnd(void)
11034
11035 void arch_pick_mmap_layout(struct mm_struct *mm)
11036 {
11037- unsigned long random_factor = mmap_rnd();
11038+ unsigned long random_factor = mmap_rnd(mm);
11039 unsigned long gap;
11040
11041 /*
11042@@ -288,6 +314,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
11043 gap == RLIM_INFINITY ||
11044 sysctl_legacy_va_layout) {
11045 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
11046+
11047+#ifdef CONFIG_PAX_RANDMMAP
11048+ if (mm->pax_flags & MF_PAX_RANDMMAP)
11049+ mm->mmap_base += mm->delta_mmap;
11050+#endif
11051+
11052 mm->get_unmapped_area = arch_get_unmapped_area;
11053 } else {
11054 /* We know it's 32-bit */
11055@@ -299,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
11056 gap = (task_size / 6 * 5);
11057
11058 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
11059+
11060+#ifdef CONFIG_PAX_RANDMMAP
11061+ if (mm->pax_flags & MF_PAX_RANDMMAP)
11062+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
11063+#endif
11064+
11065 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
11066 }
11067 }
11068diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
11069index bb00089..e0ea580 100644
11070--- a/arch/sparc/kernel/syscalls.S
11071+++ b/arch/sparc/kernel/syscalls.S
11072@@ -62,7 +62,7 @@ sys32_rt_sigreturn:
11073 #endif
11074 .align 32
11075 1: ldx [%g6 + TI_FLAGS], %l5
11076- andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
11077+ andcc %l5, _TIF_WORK_SYSCALL, %g0
11078 be,pt %icc, rtrap
11079 nop
11080 call syscall_trace_leave
11081@@ -194,7 +194,7 @@ linux_sparc_syscall32:
11082
11083 srl %i3, 0, %o3 ! IEU0
11084 srl %i2, 0, %o2 ! IEU0 Group
11085- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
11086+ andcc %l0, _TIF_WORK_SYSCALL, %g0
11087 bne,pn %icc, linux_syscall_trace32 ! CTI
11088 mov %i0, %l5 ! IEU1
11089 5: call %l7 ! CTI Group brk forced
11090@@ -218,7 +218,7 @@ linux_sparc_syscall:
11091
11092 mov %i3, %o3 ! IEU1
11093 mov %i4, %o4 ! IEU0 Group
11094- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
11095+ andcc %l0, _TIF_WORK_SYSCALL, %g0
11096 bne,pn %icc, linux_syscall_trace ! CTI Group
11097 mov %i0, %l5 ! IEU0
11098 2: call %l7 ! CTI Group brk forced
11099@@ -233,7 +233,7 @@ ret_sys_call:
11100
11101 cmp %o0, -ERESTART_RESTARTBLOCK
11102 bgeu,pn %xcc, 1f
11103- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
11104+ andcc %l0, _TIF_WORK_SYSCALL, %g0
11105 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
11106
11107 2:
11108diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
11109index 4f21df7..0a374da 100644
11110--- a/arch/sparc/kernel/traps_32.c
11111+++ b/arch/sparc/kernel/traps_32.c
11112@@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
11113 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
11114 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
11115
11116+extern void gr_handle_kernel_exploit(void);
11117+
11118 void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11119 {
11120 static int die_counter;
11121@@ -76,15 +78,17 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11122 count++ < 30 &&
11123 (((unsigned long) rw) >= PAGE_OFFSET) &&
11124 !(((unsigned long) rw) & 0x7)) {
11125- printk("Caller[%08lx]: %pS\n", rw->ins[7],
11126+ printk("Caller[%08lx]: %pA\n", rw->ins[7],
11127 (void *) rw->ins[7]);
11128 rw = (struct reg_window32 *)rw->ins[6];
11129 }
11130 }
11131 printk("Instruction DUMP:");
11132 instruction_dump ((unsigned long *) regs->pc);
11133- if(regs->psr & PSR_PS)
11134+ if(regs->psr & PSR_PS) {
11135+ gr_handle_kernel_exploit();
11136 do_exit(SIGKILL);
11137+ }
11138 do_exit(SIGSEGV);
11139 }
11140
11141diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
11142index d21cd62..00a4a17 100644
11143--- a/arch/sparc/kernel/traps_64.c
11144+++ b/arch/sparc/kernel/traps_64.c
11145@@ -79,7 +79,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
11146 i + 1,
11147 p->trapstack[i].tstate, p->trapstack[i].tpc,
11148 p->trapstack[i].tnpc, p->trapstack[i].tt);
11149- printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
11150+ printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
11151 }
11152 }
11153
11154@@ -99,6 +99,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
11155
11156 lvl -= 0x100;
11157 if (regs->tstate & TSTATE_PRIV) {
11158+
11159+#ifdef CONFIG_PAX_REFCOUNT
11160+ if (lvl == 6)
11161+ pax_report_refcount_overflow(regs);
11162+#endif
11163+
11164 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
11165 die_if_kernel(buffer, regs);
11166 }
11167@@ -117,11 +123,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
11168 void bad_trap_tl1(struct pt_regs *regs, long lvl)
11169 {
11170 char buffer[32];
11171-
11172+
11173 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
11174 0, lvl, SIGTRAP) == NOTIFY_STOP)
11175 return;
11176
11177+#ifdef CONFIG_PAX_REFCOUNT
11178+ if (lvl == 6)
11179+ pax_report_refcount_overflow(regs);
11180+#endif
11181+
11182 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
11183
11184 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
11185@@ -1151,7 +1162,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
11186 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
11187 printk("%s" "ERROR(%d): ",
11188 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
11189- printk("TPC<%pS>\n", (void *) regs->tpc);
11190+ printk("TPC<%pA>\n", (void *) regs->tpc);
11191 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
11192 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
11193 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
11194@@ -1758,7 +1769,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
11195 smp_processor_id(),
11196 (type & 0x1) ? 'I' : 'D',
11197 regs->tpc);
11198- printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
11199+ printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
11200 panic("Irrecoverable Cheetah+ parity error.");
11201 }
11202
11203@@ -1766,7 +1777,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
11204 smp_processor_id(),
11205 (type & 0x1) ? 'I' : 'D',
11206 regs->tpc);
11207- printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
11208+ printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
11209 }
11210
11211 struct sun4v_error_entry {
11212@@ -1839,8 +1850,8 @@ struct sun4v_error_entry {
11213 /*0x38*/u64 reserved_5;
11214 };
11215
11216-static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
11217-static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
11218+static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
11219+static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
11220
11221 static const char *sun4v_err_type_to_str(u8 type)
11222 {
11223@@ -1932,7 +1943,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
11224 }
11225
11226 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
11227- int cpu, const char *pfx, atomic_t *ocnt)
11228+ int cpu, const char *pfx, atomic_unchecked_t *ocnt)
11229 {
11230 u64 *raw_ptr = (u64 *) ent;
11231 u32 attrs;
11232@@ -1990,8 +2001,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
11233
11234 show_regs(regs);
11235
11236- if ((cnt = atomic_read(ocnt)) != 0) {
11237- atomic_set(ocnt, 0);
11238+ if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
11239+ atomic_set_unchecked(ocnt, 0);
11240 wmb();
11241 printk("%s: Queue overflowed %d times.\n",
11242 pfx, cnt);
11243@@ -2048,7 +2059,7 @@ out:
11244 */
11245 void sun4v_resum_overflow(struct pt_regs *regs)
11246 {
11247- atomic_inc(&sun4v_resum_oflow_cnt);
11248+ atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
11249 }
11250
11251 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
11252@@ -2101,7 +2112,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
11253 /* XXX Actually even this can make not that much sense. Perhaps
11254 * XXX we should just pull the plug and panic directly from here?
11255 */
11256- atomic_inc(&sun4v_nonresum_oflow_cnt);
11257+ atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
11258 }
11259
11260 static void sun4v_tlb_error(struct pt_regs *regs)
11261@@ -2120,9 +2131,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
11262
11263 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
11264 regs->tpc, tl);
11265- printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
11266+ printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
11267 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
11268- printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
11269+ printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
11270 (void *) regs->u_regs[UREG_I7]);
11271 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
11272 "pte[%lx] error[%lx]\n",
11273@@ -2143,9 +2154,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
11274
11275 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
11276 regs->tpc, tl);
11277- printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
11278+ printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
11279 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
11280- printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
11281+ printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
11282 (void *) regs->u_regs[UREG_I7]);
11283 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
11284 "pte[%lx] error[%lx]\n",
11285@@ -2362,13 +2373,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
11286 fp = (unsigned long)sf->fp + STACK_BIAS;
11287 }
11288
11289- printk(" [%016lx] %pS\n", pc, (void *) pc);
11290+ printk(" [%016lx] %pA\n", pc, (void *) pc);
11291 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
11292 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
11293 int index = tsk->curr_ret_stack;
11294 if (tsk->ret_stack && index >= graph) {
11295 pc = tsk->ret_stack[index - graph].ret;
11296- printk(" [%016lx] %pS\n", pc, (void *) pc);
11297+ printk(" [%016lx] %pA\n", pc, (void *) pc);
11298 graph++;
11299 }
11300 }
11301@@ -2386,6 +2397,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
11302 return (struct reg_window *) (fp + STACK_BIAS);
11303 }
11304
11305+extern void gr_handle_kernel_exploit(void);
11306+
11307 void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11308 {
11309 static int die_counter;
11310@@ -2414,7 +2427,7 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11311 while (rw &&
11312 count++ < 30 &&
11313 kstack_valid(tp, (unsigned long) rw)) {
11314- printk("Caller[%016lx]: %pS\n", rw->ins[7],
11315+ printk("Caller[%016lx]: %pA\n", rw->ins[7],
11316 (void *) rw->ins[7]);
11317
11318 rw = kernel_stack_up(rw);
11319@@ -2429,8 +2442,10 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11320 }
11321 if (panic_on_oops)
11322 panic("Fatal exception");
11323- if (regs->tstate & TSTATE_PRIV)
11324+ if (regs->tstate & TSTATE_PRIV) {
11325+ gr_handle_kernel_exploit();
11326 do_exit(SIGKILL);
11327+ }
11328 do_exit(SIGSEGV);
11329 }
11330 EXPORT_SYMBOL(die_if_kernel);
11331diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
11332index 62098a8..547ab2c 100644
11333--- a/arch/sparc/kernel/unaligned_64.c
11334+++ b/arch/sparc/kernel/unaligned_64.c
11335@@ -297,7 +297,7 @@ static void log_unaligned(struct pt_regs *regs)
11336 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
11337
11338 if (__ratelimit(&ratelimit)) {
11339- printk("Kernel unaligned access at TPC[%lx] %pS\n",
11340+ printk("Kernel unaligned access at TPC[%lx] %pA\n",
11341 regs->tpc, (void *) regs->tpc);
11342 }
11343 }
11344diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
11345index 3269b02..64f5231 100644
11346--- a/arch/sparc/lib/Makefile
11347+++ b/arch/sparc/lib/Makefile
11348@@ -2,7 +2,7 @@
11349 #
11350
11351 asflags-y := -ansi -DST_DIV0=0x02
11352-ccflags-y := -Werror
11353+#ccflags-y := -Werror
11354
11355 lib-$(CONFIG_SPARC32) += ashrdi3.o
11356 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
11357diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
11358index 05dac43..76f8ed4 100644
11359--- a/arch/sparc/lib/atomic_64.S
11360+++ b/arch/sparc/lib/atomic_64.S
11361@@ -15,11 +15,22 @@
11362 * a value and does the barriers.
11363 */
11364
11365-#define ATOMIC_OP(op) \
11366-ENTRY(atomic_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11367+#ifdef CONFIG_PAX_REFCOUNT
11368+#define __REFCOUNT_OP(op) op##cc
11369+#define __OVERFLOW_IOP tvs %icc, 6;
11370+#define __OVERFLOW_XOP tvs %xcc, 6;
11371+#else
11372+#define __REFCOUNT_OP(op) op
11373+#define __OVERFLOW_IOP
11374+#define __OVERFLOW_XOP
11375+#endif
11376+
11377+#define __ATOMIC_OP(op, suffix, asm_op, post_op) \
11378+ENTRY(atomic_##op##suffix) /* %o0 = increment, %o1 = atomic_ptr */ \
11379 BACKOFF_SETUP(%o2); \
11380 1: lduw [%o1], %g1; \
11381- op %g1, %o0, %g7; \
11382+ asm_op %g1, %o0, %g7; \
11383+ post_op \
11384 cas [%o1], %g1, %g7; \
11385 cmp %g1, %g7; \
11386 bne,pn %icc, BACKOFF_LABEL(2f, 1b); \
11387@@ -29,11 +40,15 @@ ENTRY(atomic_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11388 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11389 ENDPROC(atomic_##op); \
11390
11391-#define ATOMIC_OP_RETURN(op) \
11392-ENTRY(atomic_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11393+#define ATOMIC_OP(op) __ATOMIC_OP(op, , op, ) \
11394+ __ATOMIC_OP(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_IOP)
11395+
11396+#define __ATOMIC_OP_RETURN(op, suffix, asm_op, post_op) \
11397+ENTRY(atomic_##op##_return##suffix) /* %o0 = increment, %o1 = atomic_ptr */\
11398 BACKOFF_SETUP(%o2); \
11399 1: lduw [%o1], %g1; \
11400- op %g1, %o0, %g7; \
11401+ asm_op %g1, %o0, %g7; \
11402+ post_op \
11403 cas [%o1], %g1, %g7; \
11404 cmp %g1, %g7; \
11405 bne,pn %icc, BACKOFF_LABEL(2f, 1b); \
11406@@ -43,6 +58,9 @@ ENTRY(atomic_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11407 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11408 ENDPROC(atomic_##op##_return);
11409
11410+#define ATOMIC_OP_RETURN(op) __ATOMIC_OP_RETURN(op, , op, ) \
11411+ __ATOMIC_OP_RETURN(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_IOP)
11412+
11413 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
11414
11415 ATOMIC_OPS(add)
11416@@ -50,13 +68,16 @@ ATOMIC_OPS(sub)
11417
11418 #undef ATOMIC_OPS
11419 #undef ATOMIC_OP_RETURN
11420+#undef __ATOMIC_OP_RETURN
11421 #undef ATOMIC_OP
11422+#undef __ATOMIC_OP
11423
11424-#define ATOMIC64_OP(op) \
11425-ENTRY(atomic64_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11426+#define __ATOMIC64_OP(op, suffix, asm_op, post_op) \
11427+ENTRY(atomic64_##op##suffix) /* %o0 = increment, %o1 = atomic_ptr */ \
11428 BACKOFF_SETUP(%o2); \
11429 1: ldx [%o1], %g1; \
11430- op %g1, %o0, %g7; \
11431+ asm_op %g1, %o0, %g7; \
11432+ post_op \
11433 casx [%o1], %g1, %g7; \
11434 cmp %g1, %g7; \
11435 bne,pn %xcc, BACKOFF_LABEL(2f, 1b); \
11436@@ -66,11 +87,15 @@ ENTRY(atomic64_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11437 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11438 ENDPROC(atomic64_##op); \
11439
11440-#define ATOMIC64_OP_RETURN(op) \
11441-ENTRY(atomic64_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11442+#define ATOMIC64_OP(op) __ATOMIC64_OP(op, , op, ) \
11443+ __ATOMIC64_OP(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_XOP)
11444+
11445+#define __ATOMIC64_OP_RETURN(op, suffix, asm_op, post_op) \
11446+ENTRY(atomic64_##op##_return##suffix) /* %o0 = increment, %o1 = atomic_ptr */\
11447 BACKOFF_SETUP(%o2); \
11448 1: ldx [%o1], %g1; \
11449- op %g1, %o0, %g7; \
11450+ asm_op %g1, %o0, %g7; \
11451+ post_op \
11452 casx [%o1], %g1, %g7; \
11453 cmp %g1, %g7; \
11454 bne,pn %xcc, BACKOFF_LABEL(2f, 1b); \
11455@@ -80,6 +105,9 @@ ENTRY(atomic64_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11456 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11457 ENDPROC(atomic64_##op##_return);
11458
11459+#define ATOMIC64_OP_RETURN(op) __ATOMIC64_OP_RETURN(op, , op, ) \
11460+i __ATOMIC64_OP_RETURN(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_XOP)
11461+
11462 #define ATOMIC64_OPS(op) ATOMIC64_OP(op) ATOMIC64_OP_RETURN(op)
11463
11464 ATOMIC64_OPS(add)
11465@@ -87,7 +115,12 @@ ATOMIC64_OPS(sub)
11466
11467 #undef ATOMIC64_OPS
11468 #undef ATOMIC64_OP_RETURN
11469+#undef __ATOMIC64_OP_RETURN
11470 #undef ATOMIC64_OP
11471+#undef __ATOMIC64_OP
11472+#undef __OVERFLOW_XOP
11473+#undef __OVERFLOW_IOP
11474+#undef __REFCOUNT_OP
11475
11476 ENTRY(atomic64_dec_if_positive) /* %o0 = atomic_ptr */
11477 BACKOFF_SETUP(%o2)
11478diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
11479index 8069ce1..c2e23c4 100644
11480--- a/arch/sparc/lib/ksyms.c
11481+++ b/arch/sparc/lib/ksyms.c
11482@@ -101,7 +101,9 @@ EXPORT_SYMBOL(__clear_user);
11483 /* Atomic counter implementation. */
11484 #define ATOMIC_OP(op) \
11485 EXPORT_SYMBOL(atomic_##op); \
11486-EXPORT_SYMBOL(atomic64_##op);
11487+EXPORT_SYMBOL(atomic_##op##_unchecked); \
11488+EXPORT_SYMBOL(atomic64_##op); \
11489+EXPORT_SYMBOL(atomic64_##op##_unchecked);
11490
11491 #define ATOMIC_OP_RETURN(op) \
11492 EXPORT_SYMBOL(atomic_##op##_return); \
11493@@ -110,6 +112,8 @@ EXPORT_SYMBOL(atomic64_##op##_return);
11494 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
11495
11496 ATOMIC_OPS(add)
11497+EXPORT_SYMBOL(atomic_add_ret_unchecked);
11498+EXPORT_SYMBOL(atomic64_add_ret_unchecked);
11499 ATOMIC_OPS(sub)
11500
11501 #undef ATOMIC_OPS
11502diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
11503index 30c3ecc..736f015 100644
11504--- a/arch/sparc/mm/Makefile
11505+++ b/arch/sparc/mm/Makefile
11506@@ -2,7 +2,7 @@
11507 #
11508
11509 asflags-y := -ansi
11510-ccflags-y := -Werror
11511+#ccflags-y := -Werror
11512
11513 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
11514 obj-y += fault_$(BITS).o
11515diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
11516index c399e7b..2387414 100644
11517--- a/arch/sparc/mm/fault_32.c
11518+++ b/arch/sparc/mm/fault_32.c
11519@@ -22,6 +22,9 @@
11520 #include <linux/interrupt.h>
11521 #include <linux/kdebug.h>
11522 #include <linux/uaccess.h>
11523+#include <linux/slab.h>
11524+#include <linux/pagemap.h>
11525+#include <linux/compiler.h>
11526
11527 #include <asm/page.h>
11528 #include <asm/pgtable.h>
11529@@ -156,6 +159,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
11530 return safe_compute_effective_address(regs, insn);
11531 }
11532
11533+#ifdef CONFIG_PAX_PAGEEXEC
11534+#ifdef CONFIG_PAX_DLRESOLVE
11535+static void pax_emuplt_close(struct vm_area_struct *vma)
11536+{
11537+ vma->vm_mm->call_dl_resolve = 0UL;
11538+}
11539+
11540+static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
11541+{
11542+ unsigned int *kaddr;
11543+
11544+ vmf->page = alloc_page(GFP_HIGHUSER);
11545+ if (!vmf->page)
11546+ return VM_FAULT_OOM;
11547+
11548+ kaddr = kmap(vmf->page);
11549+ memset(kaddr, 0, PAGE_SIZE);
11550+ kaddr[0] = 0x9DE3BFA8U; /* save */
11551+ flush_dcache_page(vmf->page);
11552+ kunmap(vmf->page);
11553+ return VM_FAULT_MAJOR;
11554+}
11555+
11556+static const struct vm_operations_struct pax_vm_ops = {
11557+ .close = pax_emuplt_close,
11558+ .fault = pax_emuplt_fault
11559+};
11560+
11561+static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
11562+{
11563+ int ret;
11564+
11565+ INIT_LIST_HEAD(&vma->anon_vma_chain);
11566+ vma->vm_mm = current->mm;
11567+ vma->vm_start = addr;
11568+ vma->vm_end = addr + PAGE_SIZE;
11569+ vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
11570+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
11571+ vma->vm_ops = &pax_vm_ops;
11572+
11573+ ret = insert_vm_struct(current->mm, vma);
11574+ if (ret)
11575+ return ret;
11576+
11577+ ++current->mm->total_vm;
11578+ return 0;
11579+}
11580+#endif
11581+
11582+/*
11583+ * PaX: decide what to do with offenders (regs->pc = fault address)
11584+ *
11585+ * returns 1 when task should be killed
11586+ * 2 when patched PLT trampoline was detected
11587+ * 3 when unpatched PLT trampoline was detected
11588+ */
11589+static int pax_handle_fetch_fault(struct pt_regs *regs)
11590+{
11591+
11592+#ifdef CONFIG_PAX_EMUPLT
11593+ int err;
11594+
11595+ do { /* PaX: patched PLT emulation #1 */
11596+ unsigned int sethi1, sethi2, jmpl;
11597+
11598+ err = get_user(sethi1, (unsigned int *)regs->pc);
11599+ err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
11600+ err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
11601+
11602+ if (err)
11603+ break;
11604+
11605+ if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
11606+ (sethi2 & 0xFFC00000U) == 0x03000000U &&
11607+ (jmpl & 0xFFFFE000U) == 0x81C06000U)
11608+ {
11609+ unsigned int addr;
11610+
11611+ regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
11612+ addr = regs->u_regs[UREG_G1];
11613+ addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11614+ regs->pc = addr;
11615+ regs->npc = addr+4;
11616+ return 2;
11617+ }
11618+ } while (0);
11619+
11620+ do { /* PaX: patched PLT emulation #2 */
11621+ unsigned int ba;
11622+
11623+ err = get_user(ba, (unsigned int *)regs->pc);
11624+
11625+ if (err)
11626+ break;
11627+
11628+ if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
11629+ unsigned int addr;
11630+
11631+ if ((ba & 0xFFC00000U) == 0x30800000U)
11632+ addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
11633+ else
11634+ addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11635+ regs->pc = addr;
11636+ regs->npc = addr+4;
11637+ return 2;
11638+ }
11639+ } while (0);
11640+
11641+ do { /* PaX: patched PLT emulation #3 */
11642+ unsigned int sethi, bajmpl, nop;
11643+
11644+ err = get_user(sethi, (unsigned int *)regs->pc);
11645+ err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
11646+ err |= get_user(nop, (unsigned int *)(regs->pc+8));
11647+
11648+ if (err)
11649+ break;
11650+
11651+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11652+ ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
11653+ nop == 0x01000000U)
11654+ {
11655+ unsigned int addr;
11656+
11657+ addr = (sethi & 0x003FFFFFU) << 10;
11658+ regs->u_regs[UREG_G1] = addr;
11659+ if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
11660+ addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11661+ else
11662+ addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11663+ regs->pc = addr;
11664+ regs->npc = addr+4;
11665+ return 2;
11666+ }
11667+ } while (0);
11668+
11669+ do { /* PaX: unpatched PLT emulation step 1 */
11670+ unsigned int sethi, ba, nop;
11671+
11672+ err = get_user(sethi, (unsigned int *)regs->pc);
11673+ err |= get_user(ba, (unsigned int *)(regs->pc+4));
11674+ err |= get_user(nop, (unsigned int *)(regs->pc+8));
11675+
11676+ if (err)
11677+ break;
11678+
11679+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11680+ ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11681+ nop == 0x01000000U)
11682+ {
11683+ unsigned int addr, save, call;
11684+
11685+ if ((ba & 0xFFC00000U) == 0x30800000U)
11686+ addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
11687+ else
11688+ addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11689+
11690+ err = get_user(save, (unsigned int *)addr);
11691+ err |= get_user(call, (unsigned int *)(addr+4));
11692+ err |= get_user(nop, (unsigned int *)(addr+8));
11693+ if (err)
11694+ break;
11695+
11696+#ifdef CONFIG_PAX_DLRESOLVE
11697+ if (save == 0x9DE3BFA8U &&
11698+ (call & 0xC0000000U) == 0x40000000U &&
11699+ nop == 0x01000000U)
11700+ {
11701+ struct vm_area_struct *vma;
11702+ unsigned long call_dl_resolve;
11703+
11704+ down_read(&current->mm->mmap_sem);
11705+ call_dl_resolve = current->mm->call_dl_resolve;
11706+ up_read(&current->mm->mmap_sem);
11707+ if (likely(call_dl_resolve))
11708+ goto emulate;
11709+
11710+ vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11711+
11712+ down_write(&current->mm->mmap_sem);
11713+ if (current->mm->call_dl_resolve) {
11714+ call_dl_resolve = current->mm->call_dl_resolve;
11715+ up_write(&current->mm->mmap_sem);
11716+ if (vma)
11717+ kmem_cache_free(vm_area_cachep, vma);
11718+ goto emulate;
11719+ }
11720+
11721+ call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11722+ if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11723+ up_write(&current->mm->mmap_sem);
11724+ if (vma)
11725+ kmem_cache_free(vm_area_cachep, vma);
11726+ return 1;
11727+ }
11728+
11729+ if (pax_insert_vma(vma, call_dl_resolve)) {
11730+ up_write(&current->mm->mmap_sem);
11731+ kmem_cache_free(vm_area_cachep, vma);
11732+ return 1;
11733+ }
11734+
11735+ current->mm->call_dl_resolve = call_dl_resolve;
11736+ up_write(&current->mm->mmap_sem);
11737+
11738+emulate:
11739+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11740+ regs->pc = call_dl_resolve;
11741+ regs->npc = addr+4;
11742+ return 3;
11743+ }
11744+#endif
11745+
11746+ /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11747+ if ((save & 0xFFC00000U) == 0x05000000U &&
11748+ (call & 0xFFFFE000U) == 0x85C0A000U &&
11749+ nop == 0x01000000U)
11750+ {
11751+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11752+ regs->u_regs[UREG_G2] = addr + 4;
11753+ addr = (save & 0x003FFFFFU) << 10;
11754+ addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11755+ regs->pc = addr;
11756+ regs->npc = addr+4;
11757+ return 3;
11758+ }
11759+ }
11760+ } while (0);
11761+
11762+ do { /* PaX: unpatched PLT emulation step 2 */
11763+ unsigned int save, call, nop;
11764+
11765+ err = get_user(save, (unsigned int *)(regs->pc-4));
11766+ err |= get_user(call, (unsigned int *)regs->pc);
11767+ err |= get_user(nop, (unsigned int *)(regs->pc+4));
11768+ if (err)
11769+ break;
11770+
11771+ if (save == 0x9DE3BFA8U &&
11772+ (call & 0xC0000000U) == 0x40000000U &&
11773+ nop == 0x01000000U)
11774+ {
11775+ unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
11776+
11777+ regs->u_regs[UREG_RETPC] = regs->pc;
11778+ regs->pc = dl_resolve;
11779+ regs->npc = dl_resolve+4;
11780+ return 3;
11781+ }
11782+ } while (0);
11783+#endif
11784+
11785+ return 1;
11786+}
11787+
11788+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11789+{
11790+ unsigned long i;
11791+
11792+ printk(KERN_ERR "PAX: bytes at PC: ");
11793+ for (i = 0; i < 8; i++) {
11794+ unsigned int c;
11795+ if (get_user(c, (unsigned int *)pc+i))
11796+ printk(KERN_CONT "???????? ");
11797+ else
11798+ printk(KERN_CONT "%08x ", c);
11799+ }
11800+ printk("\n");
11801+}
11802+#endif
11803+
11804 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
11805 int text_fault)
11806 {
11807@@ -226,6 +500,24 @@ good_area:
11808 if (!(vma->vm_flags & VM_WRITE))
11809 goto bad_area;
11810 } else {
11811+
11812+#ifdef CONFIG_PAX_PAGEEXEC
11813+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
11814+ up_read(&mm->mmap_sem);
11815+ switch (pax_handle_fetch_fault(regs)) {
11816+
11817+#ifdef CONFIG_PAX_EMUPLT
11818+ case 2:
11819+ case 3:
11820+ return;
11821+#endif
11822+
11823+ }
11824+ pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
11825+ do_group_exit(SIGKILL);
11826+ }
11827+#endif
11828+
11829 /* Allow reads even for write-only mappings */
11830 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
11831 goto bad_area;
11832diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
11833index dbabe57..d34d315 100644
11834--- a/arch/sparc/mm/fault_64.c
11835+++ b/arch/sparc/mm/fault_64.c
11836@@ -23,6 +23,9 @@
11837 #include <linux/percpu.h>
11838 #include <linux/context_tracking.h>
11839 #include <linux/uaccess.h>
11840+#include <linux/slab.h>
11841+#include <linux/pagemap.h>
11842+#include <linux/compiler.h>
11843
11844 #include <asm/page.h>
11845 #include <asm/pgtable.h>
11846@@ -76,7 +79,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
11847 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
11848 regs->tpc);
11849 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
11850- printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
11851+ printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
11852 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
11853 dump_stack();
11854 unhandled_fault(regs->tpc, current, regs);
11855@@ -279,6 +282,466 @@ static void noinline __kprobes bogus_32bit_fault_tpc(struct pt_regs *regs)
11856 show_regs(regs);
11857 }
11858
11859+#ifdef CONFIG_PAX_PAGEEXEC
11860+#ifdef CONFIG_PAX_DLRESOLVE
11861+static void pax_emuplt_close(struct vm_area_struct *vma)
11862+{
11863+ vma->vm_mm->call_dl_resolve = 0UL;
11864+}
11865+
11866+static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
11867+{
11868+ unsigned int *kaddr;
11869+
11870+ vmf->page = alloc_page(GFP_HIGHUSER);
11871+ if (!vmf->page)
11872+ return VM_FAULT_OOM;
11873+
11874+ kaddr = kmap(vmf->page);
11875+ memset(kaddr, 0, PAGE_SIZE);
11876+ kaddr[0] = 0x9DE3BFA8U; /* save */
11877+ flush_dcache_page(vmf->page);
11878+ kunmap(vmf->page);
11879+ return VM_FAULT_MAJOR;
11880+}
11881+
11882+static const struct vm_operations_struct pax_vm_ops = {
11883+ .close = pax_emuplt_close,
11884+ .fault = pax_emuplt_fault
11885+};
11886+
11887+static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
11888+{
11889+ int ret;
11890+
11891+ INIT_LIST_HEAD(&vma->anon_vma_chain);
11892+ vma->vm_mm = current->mm;
11893+ vma->vm_start = addr;
11894+ vma->vm_end = addr + PAGE_SIZE;
11895+ vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
11896+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
11897+ vma->vm_ops = &pax_vm_ops;
11898+
11899+ ret = insert_vm_struct(current->mm, vma);
11900+ if (ret)
11901+ return ret;
11902+
11903+ ++current->mm->total_vm;
11904+ return 0;
11905+}
11906+#endif
11907+
11908+/*
11909+ * PaX: decide what to do with offenders (regs->tpc = fault address)
11910+ *
11911+ * returns 1 when task should be killed
11912+ * 2 when patched PLT trampoline was detected
11913+ * 3 when unpatched PLT trampoline was detected
11914+ */
11915+static int pax_handle_fetch_fault(struct pt_regs *regs)
11916+{
11917+
11918+#ifdef CONFIG_PAX_EMUPLT
11919+ int err;
11920+
11921+ do { /* PaX: patched PLT emulation #1 */
11922+ unsigned int sethi1, sethi2, jmpl;
11923+
11924+ err = get_user(sethi1, (unsigned int *)regs->tpc);
11925+ err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
11926+ err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
11927+
11928+ if (err)
11929+ break;
11930+
11931+ if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
11932+ (sethi2 & 0xFFC00000U) == 0x03000000U &&
11933+ (jmpl & 0xFFFFE000U) == 0x81C06000U)
11934+ {
11935+ unsigned long addr;
11936+
11937+ regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
11938+ addr = regs->u_regs[UREG_G1];
11939+ addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11940+
11941+ if (test_thread_flag(TIF_32BIT))
11942+ addr &= 0xFFFFFFFFUL;
11943+
11944+ regs->tpc = addr;
11945+ regs->tnpc = addr+4;
11946+ return 2;
11947+ }
11948+ } while (0);
11949+
11950+ do { /* PaX: patched PLT emulation #2 */
11951+ unsigned int ba;
11952+
11953+ err = get_user(ba, (unsigned int *)regs->tpc);
11954+
11955+ if (err)
11956+ break;
11957+
11958+ if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
11959+ unsigned long addr;
11960+
11961+ if ((ba & 0xFFC00000U) == 0x30800000U)
11962+ addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
11963+ else
11964+ addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11965+
11966+ if (test_thread_flag(TIF_32BIT))
11967+ addr &= 0xFFFFFFFFUL;
11968+
11969+ regs->tpc = addr;
11970+ regs->tnpc = addr+4;
11971+ return 2;
11972+ }
11973+ } while (0);
11974+
11975+ do { /* PaX: patched PLT emulation #3 */
11976+ unsigned int sethi, bajmpl, nop;
11977+
11978+ err = get_user(sethi, (unsigned int *)regs->tpc);
11979+ err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
11980+ err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11981+
11982+ if (err)
11983+ break;
11984+
11985+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11986+ ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
11987+ nop == 0x01000000U)
11988+ {
11989+ unsigned long addr;
11990+
11991+ addr = (sethi & 0x003FFFFFU) << 10;
11992+ regs->u_regs[UREG_G1] = addr;
11993+ if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
11994+ addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11995+ else
11996+ addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11997+
11998+ if (test_thread_flag(TIF_32BIT))
11999+ addr &= 0xFFFFFFFFUL;
12000+
12001+ regs->tpc = addr;
12002+ regs->tnpc = addr+4;
12003+ return 2;
12004+ }
12005+ } while (0);
12006+
12007+ do { /* PaX: patched PLT emulation #4 */
12008+ unsigned int sethi, mov1, call, mov2;
12009+
12010+ err = get_user(sethi, (unsigned int *)regs->tpc);
12011+ err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
12012+ err |= get_user(call, (unsigned int *)(regs->tpc+8));
12013+ err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
12014+
12015+ if (err)
12016+ break;
12017+
12018+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12019+ mov1 == 0x8210000FU &&
12020+ (call & 0xC0000000U) == 0x40000000U &&
12021+ mov2 == 0x9E100001U)
12022+ {
12023+ unsigned long addr;
12024+
12025+ regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
12026+ addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
12027+
12028+ if (test_thread_flag(TIF_32BIT))
12029+ addr &= 0xFFFFFFFFUL;
12030+
12031+ regs->tpc = addr;
12032+ regs->tnpc = addr+4;
12033+ return 2;
12034+ }
12035+ } while (0);
12036+
12037+ do { /* PaX: patched PLT emulation #5 */
12038+ unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
12039+
12040+ err = get_user(sethi, (unsigned int *)regs->tpc);
12041+ err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
12042+ err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
12043+ err |= get_user(or1, (unsigned int *)(regs->tpc+12));
12044+ err |= get_user(or2, (unsigned int *)(regs->tpc+16));
12045+ err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
12046+ err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
12047+ err |= get_user(nop, (unsigned int *)(regs->tpc+28));
12048+
12049+ if (err)
12050+ break;
12051+
12052+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12053+ (sethi1 & 0xFFC00000U) == 0x03000000U &&
12054+ (sethi2 & 0xFFC00000U) == 0x0B000000U &&
12055+ (or1 & 0xFFFFE000U) == 0x82106000U &&
12056+ (or2 & 0xFFFFE000U) == 0x8A116000U &&
12057+ sllx == 0x83287020U &&
12058+ jmpl == 0x81C04005U &&
12059+ nop == 0x01000000U)
12060+ {
12061+ unsigned long addr;
12062+
12063+ regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
12064+ regs->u_regs[UREG_G1] <<= 32;
12065+ regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
12066+ addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
12067+ regs->tpc = addr;
12068+ regs->tnpc = addr+4;
12069+ return 2;
12070+ }
12071+ } while (0);
12072+
12073+ do { /* PaX: patched PLT emulation #6 */
12074+ unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
12075+
12076+ err = get_user(sethi, (unsigned int *)regs->tpc);
12077+ err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
12078+ err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
12079+ err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
12080+ err |= get_user(or, (unsigned int *)(regs->tpc+16));
12081+ err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
12082+ err |= get_user(nop, (unsigned int *)(regs->tpc+24));
12083+
12084+ if (err)
12085+ break;
12086+
12087+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12088+ (sethi1 & 0xFFC00000U) == 0x03000000U &&
12089+ (sethi2 & 0xFFC00000U) == 0x0B000000U &&
12090+ sllx == 0x83287020U &&
12091+ (or & 0xFFFFE000U) == 0x8A116000U &&
12092+ jmpl == 0x81C04005U &&
12093+ nop == 0x01000000U)
12094+ {
12095+ unsigned long addr;
12096+
12097+ regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
12098+ regs->u_regs[UREG_G1] <<= 32;
12099+ regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
12100+ addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
12101+ regs->tpc = addr;
12102+ regs->tnpc = addr+4;
12103+ return 2;
12104+ }
12105+ } while (0);
12106+
12107+ do { /* PaX: unpatched PLT emulation step 1 */
12108+ unsigned int sethi, ba, nop;
12109+
12110+ err = get_user(sethi, (unsigned int *)regs->tpc);
12111+ err |= get_user(ba, (unsigned int *)(regs->tpc+4));
12112+ err |= get_user(nop, (unsigned int *)(regs->tpc+8));
12113+
12114+ if (err)
12115+ break;
12116+
12117+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12118+ ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
12119+ nop == 0x01000000U)
12120+ {
12121+ unsigned long addr;
12122+ unsigned int save, call;
12123+ unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
12124+
12125+ if ((ba & 0xFFC00000U) == 0x30800000U)
12126+ addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
12127+ else
12128+ addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
12129+
12130+ if (test_thread_flag(TIF_32BIT))
12131+ addr &= 0xFFFFFFFFUL;
12132+
12133+ err = get_user(save, (unsigned int *)addr);
12134+ err |= get_user(call, (unsigned int *)(addr+4));
12135+ err |= get_user(nop, (unsigned int *)(addr+8));
12136+ if (err)
12137+ break;
12138+
12139+#ifdef CONFIG_PAX_DLRESOLVE
12140+ if (save == 0x9DE3BFA8U &&
12141+ (call & 0xC0000000U) == 0x40000000U &&
12142+ nop == 0x01000000U)
12143+ {
12144+ struct vm_area_struct *vma;
12145+ unsigned long call_dl_resolve;
12146+
12147+ down_read(&current->mm->mmap_sem);
12148+ call_dl_resolve = current->mm->call_dl_resolve;
12149+ up_read(&current->mm->mmap_sem);
12150+ if (likely(call_dl_resolve))
12151+ goto emulate;
12152+
12153+ vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
12154+
12155+ down_write(&current->mm->mmap_sem);
12156+ if (current->mm->call_dl_resolve) {
12157+ call_dl_resolve = current->mm->call_dl_resolve;
12158+ up_write(&current->mm->mmap_sem);
12159+ if (vma)
12160+ kmem_cache_free(vm_area_cachep, vma);
12161+ goto emulate;
12162+ }
12163+
12164+ call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
12165+ if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
12166+ up_write(&current->mm->mmap_sem);
12167+ if (vma)
12168+ kmem_cache_free(vm_area_cachep, vma);
12169+ return 1;
12170+ }
12171+
12172+ if (pax_insert_vma(vma, call_dl_resolve)) {
12173+ up_write(&current->mm->mmap_sem);
12174+ kmem_cache_free(vm_area_cachep, vma);
12175+ return 1;
12176+ }
12177+
12178+ current->mm->call_dl_resolve = call_dl_resolve;
12179+ up_write(&current->mm->mmap_sem);
12180+
12181+emulate:
12182+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
12183+ regs->tpc = call_dl_resolve;
12184+ regs->tnpc = addr+4;
12185+ return 3;
12186+ }
12187+#endif
12188+
12189+ /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
12190+ if ((save & 0xFFC00000U) == 0x05000000U &&
12191+ (call & 0xFFFFE000U) == 0x85C0A000U &&
12192+ nop == 0x01000000U)
12193+ {
12194+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
12195+ regs->u_regs[UREG_G2] = addr + 4;
12196+ addr = (save & 0x003FFFFFU) << 10;
12197+ addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
12198+
12199+ if (test_thread_flag(TIF_32BIT))
12200+ addr &= 0xFFFFFFFFUL;
12201+
12202+ regs->tpc = addr;
12203+ regs->tnpc = addr+4;
12204+ return 3;
12205+ }
12206+
12207+ /* PaX: 64-bit PLT stub */
12208+ err = get_user(sethi1, (unsigned int *)addr);
12209+ err |= get_user(sethi2, (unsigned int *)(addr+4));
12210+ err |= get_user(or1, (unsigned int *)(addr+8));
12211+ err |= get_user(or2, (unsigned int *)(addr+12));
12212+ err |= get_user(sllx, (unsigned int *)(addr+16));
12213+ err |= get_user(add, (unsigned int *)(addr+20));
12214+ err |= get_user(jmpl, (unsigned int *)(addr+24));
12215+ err |= get_user(nop, (unsigned int *)(addr+28));
12216+ if (err)
12217+ break;
12218+
12219+ if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
12220+ (sethi2 & 0xFFC00000U) == 0x0B000000U &&
12221+ (or1 & 0xFFFFE000U) == 0x88112000U &&
12222+ (or2 & 0xFFFFE000U) == 0x8A116000U &&
12223+ sllx == 0x89293020U &&
12224+ add == 0x8A010005U &&
12225+ jmpl == 0x89C14000U &&
12226+ nop == 0x01000000U)
12227+ {
12228+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
12229+ regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
12230+ regs->u_regs[UREG_G4] <<= 32;
12231+ regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
12232+ regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
12233+ regs->u_regs[UREG_G4] = addr + 24;
12234+ addr = regs->u_regs[UREG_G5];
12235+ regs->tpc = addr;
12236+ regs->tnpc = addr+4;
12237+ return 3;
12238+ }
12239+ }
12240+ } while (0);
12241+
12242+#ifdef CONFIG_PAX_DLRESOLVE
12243+ do { /* PaX: unpatched PLT emulation step 2 */
12244+ unsigned int save, call, nop;
12245+
12246+ err = get_user(save, (unsigned int *)(regs->tpc-4));
12247+ err |= get_user(call, (unsigned int *)regs->tpc);
12248+ err |= get_user(nop, (unsigned int *)(regs->tpc+4));
12249+ if (err)
12250+ break;
12251+
12252+ if (save == 0x9DE3BFA8U &&
12253+ (call & 0xC0000000U) == 0x40000000U &&
12254+ nop == 0x01000000U)
12255+ {
12256+ unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
12257+
12258+ if (test_thread_flag(TIF_32BIT))
12259+ dl_resolve &= 0xFFFFFFFFUL;
12260+
12261+ regs->u_regs[UREG_RETPC] = regs->tpc;
12262+ regs->tpc = dl_resolve;
12263+ regs->tnpc = dl_resolve+4;
12264+ return 3;
12265+ }
12266+ } while (0);
12267+#endif
12268+
12269+ do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
12270+ unsigned int sethi, ba, nop;
12271+
12272+ err = get_user(sethi, (unsigned int *)regs->tpc);
12273+ err |= get_user(ba, (unsigned int *)(regs->tpc+4));
12274+ err |= get_user(nop, (unsigned int *)(regs->tpc+8));
12275+
12276+ if (err)
12277+ break;
12278+
12279+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12280+ (ba & 0xFFF00000U) == 0x30600000U &&
12281+ nop == 0x01000000U)
12282+ {
12283+ unsigned long addr;
12284+
12285+ addr = (sethi & 0x003FFFFFU) << 10;
12286+ regs->u_regs[UREG_G1] = addr;
12287+ addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
12288+
12289+ if (test_thread_flag(TIF_32BIT))
12290+ addr &= 0xFFFFFFFFUL;
12291+
12292+ regs->tpc = addr;
12293+ regs->tnpc = addr+4;
12294+ return 2;
12295+ }
12296+ } while (0);
12297+
12298+#endif
12299+
12300+ return 1;
12301+}
12302+
12303+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
12304+{
12305+ unsigned long i;
12306+
12307+ printk(KERN_ERR "PAX: bytes at PC: ");
12308+ for (i = 0; i < 8; i++) {
12309+ unsigned int c;
12310+ if (get_user(c, (unsigned int *)pc+i))
12311+ printk(KERN_CONT "???????? ");
12312+ else
12313+ printk(KERN_CONT "%08x ", c);
12314+ }
12315+ printk("\n");
12316+}
12317+#endif
12318+
12319 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
12320 {
12321 enum ctx_state prev_state = exception_enter();
12322@@ -353,6 +816,29 @@ retry:
12323 if (!vma)
12324 goto bad_area;
12325
12326+#ifdef CONFIG_PAX_PAGEEXEC
12327+ /* PaX: detect ITLB misses on non-exec pages */
12328+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
12329+ !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
12330+ {
12331+ if (address != regs->tpc)
12332+ goto good_area;
12333+
12334+ up_read(&mm->mmap_sem);
12335+ switch (pax_handle_fetch_fault(regs)) {
12336+
12337+#ifdef CONFIG_PAX_EMUPLT
12338+ case 2:
12339+ case 3:
12340+ return;
12341+#endif
12342+
12343+ }
12344+ pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
12345+ do_group_exit(SIGKILL);
12346+ }
12347+#endif
12348+
12349 /* Pure DTLB misses do not tell us whether the fault causing
12350 * load/store/atomic was a write or not, it only says that there
12351 * was no match. So in such a case we (carefully) read the
12352diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
12353index 131eaf4..285ea31 100644
12354--- a/arch/sparc/mm/hugetlbpage.c
12355+++ b/arch/sparc/mm/hugetlbpage.c
12356@@ -25,8 +25,10 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
12357 unsigned long addr,
12358 unsigned long len,
12359 unsigned long pgoff,
12360- unsigned long flags)
12361+ unsigned long flags,
12362+ unsigned long offset)
12363 {
12364+ struct mm_struct *mm = current->mm;
12365 unsigned long task_size = TASK_SIZE;
12366 struct vm_unmapped_area_info info;
12367
12368@@ -35,15 +37,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
12369
12370 info.flags = 0;
12371 info.length = len;
12372- info.low_limit = TASK_UNMAPPED_BASE;
12373+ info.low_limit = mm->mmap_base;
12374 info.high_limit = min(task_size, VA_EXCLUDE_START);
12375 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
12376 info.align_offset = 0;
12377+ info.threadstack_offset = offset;
12378 addr = vm_unmapped_area(&info);
12379
12380 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
12381 VM_BUG_ON(addr != -ENOMEM);
12382 info.low_limit = VA_EXCLUDE_END;
12383+
12384+#ifdef CONFIG_PAX_RANDMMAP
12385+ if (mm->pax_flags & MF_PAX_RANDMMAP)
12386+ info.low_limit += mm->delta_mmap;
12387+#endif
12388+
12389 info.high_limit = task_size;
12390 addr = vm_unmapped_area(&info);
12391 }
12392@@ -55,7 +64,8 @@ static unsigned long
12393 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
12394 const unsigned long len,
12395 const unsigned long pgoff,
12396- const unsigned long flags)
12397+ const unsigned long flags,
12398+ const unsigned long offset)
12399 {
12400 struct mm_struct *mm = current->mm;
12401 unsigned long addr = addr0;
12402@@ -70,6 +80,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
12403 info.high_limit = mm->mmap_base;
12404 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
12405 info.align_offset = 0;
12406+ info.threadstack_offset = offset;
12407 addr = vm_unmapped_area(&info);
12408
12409 /*
12410@@ -82,6 +93,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
12411 VM_BUG_ON(addr != -ENOMEM);
12412 info.flags = 0;
12413 info.low_limit = TASK_UNMAPPED_BASE;
12414+
12415+#ifdef CONFIG_PAX_RANDMMAP
12416+ if (mm->pax_flags & MF_PAX_RANDMMAP)
12417+ info.low_limit += mm->delta_mmap;
12418+#endif
12419+
12420 info.high_limit = STACK_TOP32;
12421 addr = vm_unmapped_area(&info);
12422 }
12423@@ -96,6 +113,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
12424 struct mm_struct *mm = current->mm;
12425 struct vm_area_struct *vma;
12426 unsigned long task_size = TASK_SIZE;
12427+ unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
12428
12429 if (test_thread_flag(TIF_32BIT))
12430 task_size = STACK_TOP32;
12431@@ -111,19 +129,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
12432 return addr;
12433 }
12434
12435+#ifdef CONFIG_PAX_RANDMMAP
12436+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
12437+#endif
12438+
12439 if (addr) {
12440 addr = ALIGN(addr, HPAGE_SIZE);
12441 vma = find_vma(mm, addr);
12442- if (task_size - len >= addr &&
12443- (!vma || addr + len <= vma->vm_start))
12444+ if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
12445 return addr;
12446 }
12447 if (mm->get_unmapped_area == arch_get_unmapped_area)
12448 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
12449- pgoff, flags);
12450+ pgoff, flags, offset);
12451 else
12452 return hugetlb_get_unmapped_area_topdown(file, addr, len,
12453- pgoff, flags);
12454+ pgoff, flags, offset);
12455 }
12456
12457 pte_t *huge_pte_alloc(struct mm_struct *mm,
12458diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
12459index 4ac88b7..bac6cb2 100644
12460--- a/arch/sparc/mm/init_64.c
12461+++ b/arch/sparc/mm/init_64.c
12462@@ -187,9 +187,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
12463 int num_kernel_image_mappings;
12464
12465 #ifdef CONFIG_DEBUG_DCFLUSH
12466-atomic_t dcpage_flushes = ATOMIC_INIT(0);
12467+atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
12468 #ifdef CONFIG_SMP
12469-atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
12470+atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
12471 #endif
12472 #endif
12473
12474@@ -197,7 +197,7 @@ inline void flush_dcache_page_impl(struct page *page)
12475 {
12476 BUG_ON(tlb_type == hypervisor);
12477 #ifdef CONFIG_DEBUG_DCFLUSH
12478- atomic_inc(&dcpage_flushes);
12479+ atomic_inc_unchecked(&dcpage_flushes);
12480 #endif
12481
12482 #ifdef DCACHE_ALIASING_POSSIBLE
12483@@ -469,10 +469,10 @@ void mmu_info(struct seq_file *m)
12484
12485 #ifdef CONFIG_DEBUG_DCFLUSH
12486 seq_printf(m, "DCPageFlushes\t: %d\n",
12487- atomic_read(&dcpage_flushes));
12488+ atomic_read_unchecked(&dcpage_flushes));
12489 #ifdef CONFIG_SMP
12490 seq_printf(m, "DCPageFlushesXC\t: %d\n",
12491- atomic_read(&dcpage_flushes_xcall));
12492+ atomic_read_unchecked(&dcpage_flushes_xcall));
12493 #endif /* CONFIG_SMP */
12494 #endif /* CONFIG_DEBUG_DCFLUSH */
12495 }
12496diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
12497index 9def1f5..cf0cabc 100644
12498--- a/arch/tile/Kconfig
12499+++ b/arch/tile/Kconfig
12500@@ -204,6 +204,7 @@ source "kernel/Kconfig.hz"
12501
12502 config KEXEC
12503 bool "kexec system call"
12504+ depends on !GRKERNSEC_KMEM
12505 ---help---
12506 kexec is a system call that implements the ability to shutdown your
12507 current kernel, and to start another kernel. It is like a reboot
12508diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
12509index 0496970..1a57e5f 100644
12510--- a/arch/tile/include/asm/atomic_64.h
12511+++ b/arch/tile/include/asm/atomic_64.h
12512@@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
12513
12514 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12515
12516+#define atomic64_read_unchecked(v) atomic64_read(v)
12517+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
12518+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
12519+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
12520+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
12521+#define atomic64_inc_unchecked(v) atomic64_inc(v)
12522+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
12523+#define atomic64_dec_unchecked(v) atomic64_dec(v)
12524+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
12525+
12526 #endif /* !__ASSEMBLY__ */
12527
12528 #endif /* _ASM_TILE_ATOMIC_64_H */
12529diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
12530index 6160761..00cac88 100644
12531--- a/arch/tile/include/asm/cache.h
12532+++ b/arch/tile/include/asm/cache.h
12533@@ -15,11 +15,12 @@
12534 #ifndef _ASM_TILE_CACHE_H
12535 #define _ASM_TILE_CACHE_H
12536
12537+#include <linux/const.h>
12538 #include <arch/chip.h>
12539
12540 /* bytes per L1 data cache line */
12541 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
12542-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12543+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12544
12545 /* bytes per L2 cache line */
12546 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
12547diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
12548index 0a9c4265..bfb62d1 100644
12549--- a/arch/tile/include/asm/uaccess.h
12550+++ b/arch/tile/include/asm/uaccess.h
12551@@ -429,9 +429,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
12552 const void __user *from,
12553 unsigned long n)
12554 {
12555- int sz = __compiletime_object_size(to);
12556+ size_t sz = __compiletime_object_size(to);
12557
12558- if (likely(sz == -1 || sz >= n))
12559+ if (likely(sz == (size_t)-1 || sz >= n))
12560 n = _copy_from_user(to, from, n);
12561 else
12562 copy_from_user_overflow();
12563diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
12564index c034dc3..cf1cc96 100644
12565--- a/arch/tile/mm/hugetlbpage.c
12566+++ b/arch/tile/mm/hugetlbpage.c
12567@@ -174,6 +174,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
12568 info.high_limit = TASK_SIZE;
12569 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
12570 info.align_offset = 0;
12571+ info.threadstack_offset = 0;
12572 return vm_unmapped_area(&info);
12573 }
12574
12575@@ -191,6 +192,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
12576 info.high_limit = current->mm->mmap_base;
12577 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
12578 info.align_offset = 0;
12579+ info.threadstack_offset = 0;
12580 addr = vm_unmapped_area(&info);
12581
12582 /*
12583diff --git a/arch/um/Makefile b/arch/um/Makefile
12584index 098ab33..fc54a33 100644
12585--- a/arch/um/Makefile
12586+++ b/arch/um/Makefile
12587@@ -73,6 +73,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
12588 -D_FILE_OFFSET_BITS=64 -idirafter include \
12589 -D__KERNEL__ -D__UM_HOST__
12590
12591+ifdef CONSTIFY_PLUGIN
12592+USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
12593+endif
12594+
12595 #This will adjust *FLAGS accordingly to the platform.
12596 include $(ARCH_DIR)/Makefile-os-$(OS)
12597
12598diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
12599index 19e1bdd..3665b77 100644
12600--- a/arch/um/include/asm/cache.h
12601+++ b/arch/um/include/asm/cache.h
12602@@ -1,6 +1,7 @@
12603 #ifndef __UM_CACHE_H
12604 #define __UM_CACHE_H
12605
12606+#include <linux/const.h>
12607
12608 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
12609 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12610@@ -12,6 +13,6 @@
12611 # define L1_CACHE_SHIFT 5
12612 #endif
12613
12614-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12615+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12616
12617 #endif
12618diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
12619index 2e0a6b1..a64d0f5 100644
12620--- a/arch/um/include/asm/kmap_types.h
12621+++ b/arch/um/include/asm/kmap_types.h
12622@@ -8,6 +8,6 @@
12623
12624 /* No more #include "asm/arch/kmap_types.h" ! */
12625
12626-#define KM_TYPE_NR 14
12627+#define KM_TYPE_NR 15
12628
12629 #endif
12630diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
12631index 71c5d13..4c7b9f1 100644
12632--- a/arch/um/include/asm/page.h
12633+++ b/arch/um/include/asm/page.h
12634@@ -14,6 +14,9 @@
12635 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
12636 #define PAGE_MASK (~(PAGE_SIZE-1))
12637
12638+#define ktla_ktva(addr) (addr)
12639+#define ktva_ktla(addr) (addr)
12640+
12641 #ifndef __ASSEMBLY__
12642
12643 struct page;
12644diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
12645index 2b4274e..754fe06 100644
12646--- a/arch/um/include/asm/pgtable-3level.h
12647+++ b/arch/um/include/asm/pgtable-3level.h
12648@@ -58,6 +58,7 @@
12649 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
12650 #define pud_populate(mm, pud, pmd) \
12651 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
12652+#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
12653
12654 #ifdef CONFIG_64BIT
12655 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
12656diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
12657index 68b9119..f72353c 100644
12658--- a/arch/um/kernel/process.c
12659+++ b/arch/um/kernel/process.c
12660@@ -345,22 +345,6 @@ int singlestepping(void * t)
12661 return 2;
12662 }
12663
12664-/*
12665- * Only x86 and x86_64 have an arch_align_stack().
12666- * All other arches have "#define arch_align_stack(x) (x)"
12667- * in their asm/exec.h
12668- * As this is included in UML from asm-um/system-generic.h,
12669- * we can use it to behave as the subarch does.
12670- */
12671-#ifndef arch_align_stack
12672-unsigned long arch_align_stack(unsigned long sp)
12673-{
12674- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
12675- sp -= get_random_int() % 8192;
12676- return sp & ~0xf;
12677-}
12678-#endif
12679-
12680 unsigned long get_wchan(struct task_struct *p)
12681 {
12682 unsigned long stack_page, sp, ip;
12683diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
12684index ad8f795..2c7eec6 100644
12685--- a/arch/unicore32/include/asm/cache.h
12686+++ b/arch/unicore32/include/asm/cache.h
12687@@ -12,8 +12,10 @@
12688 #ifndef __UNICORE_CACHE_H__
12689 #define __UNICORE_CACHE_H__
12690
12691-#define L1_CACHE_SHIFT (5)
12692-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12693+#include <linux/const.h>
12694+
12695+#define L1_CACHE_SHIFT 5
12696+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12697
12698 /*
12699 * Memory returned by kmalloc() may be used for DMA, so we must make
12700diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
12701index b3a1a5d..8dbc2d6 100644
12702--- a/arch/x86/Kconfig
12703+++ b/arch/x86/Kconfig
12704@@ -35,13 +35,12 @@ config X86
12705 select ARCH_MIGHT_HAVE_PC_SERIO
12706 select ARCH_SUPPORTS_ATOMIC_RMW
12707 select ARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INIT
12708- select ARCH_SUPPORTS_INT128 if X86_64
12709+ select ARCH_SUPPORTS_INT128 if X86_64 && !PAX_SIZE_OVERFLOW
12710 select ARCH_SUPPORTS_NUMA_BALANCING if X86_64
12711 select ARCH_USE_BUILTIN_BSWAP
12712 select ARCH_USE_CMPXCHG_LOCKREF if X86_64
12713 select ARCH_USE_QUEUED_RWLOCKS
12714 select ARCH_USE_QUEUED_SPINLOCKS
12715- select ARCH_WANTS_DYNAMIC_TASK_STRUCT
12716 select ARCH_WANT_FRAME_POINTERS
12717 select ARCH_WANT_IPC_PARSE_VERSION if X86_32
12718 select ARCH_WANT_OPTIONAL_GPIOLIB
12719@@ -85,7 +84,7 @@ config X86
12720 select HAVE_ARCH_TRACEHOOK
12721 select HAVE_ARCH_TRANSPARENT_HUGEPAGE
12722 select HAVE_BPF_JIT if X86_64
12723- select HAVE_CC_STACKPROTECTOR
12724+ select HAVE_CC_STACKPROTECTOR if X86_64 || !PAX_MEMORY_UDEREF
12725 select HAVE_CMPXCHG_DOUBLE
12726 select HAVE_CMPXCHG_LOCAL
12727 select HAVE_CONTEXT_TRACKING if X86_64
12728@@ -274,7 +273,7 @@ config X86_64_SMP
12729
12730 config X86_32_LAZY_GS
12731 def_bool y
12732- depends on X86_32 && !CC_STACKPROTECTOR
12733+ depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
12734
12735 config ARCH_HWEIGHT_CFLAGS
12736 string
12737@@ -646,6 +645,7 @@ config SCHED_OMIT_FRAME_POINTER
12738
12739 menuconfig HYPERVISOR_GUEST
12740 bool "Linux guest support"
12741+ depends on !GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_VIRT_GUEST || (GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_XEN)
12742 ---help---
12743 Say Y here to enable options for running Linux under various hyper-
12744 visors. This option enables basic hypervisor detection and platform
12745@@ -1014,6 +1014,7 @@ config VM86
12746
12747 config X86_16BIT
12748 bool "Enable support for 16-bit segments" if EXPERT
12749+ depends on !GRKERNSEC
12750 default y
12751 ---help---
12752 This option is required by programs like Wine to run 16-bit
12753@@ -1182,6 +1183,7 @@ choice
12754
12755 config NOHIGHMEM
12756 bool "off"
12757+ depends on !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
12758 ---help---
12759 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
12760 However, the address space of 32-bit x86 processors is only 4
12761@@ -1218,6 +1220,7 @@ config NOHIGHMEM
12762
12763 config HIGHMEM4G
12764 bool "4GB"
12765+ depends on !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
12766 ---help---
12767 Select this if you have a 32-bit processor and between 1 and 4
12768 gigabytes of physical RAM.
12769@@ -1270,7 +1273,7 @@ config PAGE_OFFSET
12770 hex
12771 default 0xB0000000 if VMSPLIT_3G_OPT
12772 default 0x80000000 if VMSPLIT_2G
12773- default 0x78000000 if VMSPLIT_2G_OPT
12774+ default 0x70000000 if VMSPLIT_2G_OPT
12775 default 0x40000000 if VMSPLIT_1G
12776 default 0xC0000000
12777 depends on X86_32
12778@@ -1290,7 +1293,6 @@ config X86_PAE
12779
12780 config ARCH_PHYS_ADDR_T_64BIT
12781 def_bool y
12782- depends on X86_64 || X86_PAE
12783
12784 config ARCH_DMA_ADDR_T_64BIT
12785 def_bool y
12786@@ -1724,6 +1726,7 @@ source kernel/Kconfig.hz
12787
12788 config KEXEC
12789 bool "kexec system call"
12790+ depends on !GRKERNSEC_KMEM
12791 ---help---
12792 kexec is a system call that implements the ability to shutdown your
12793 current kernel, and to start another kernel. It is like a reboot
12794@@ -1906,7 +1909,9 @@ config X86_NEED_RELOCS
12795
12796 config PHYSICAL_ALIGN
12797 hex "Alignment value to which kernel should be aligned"
12798- default "0x200000"
12799+ default "0x1000000"
12800+ range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
12801+ range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
12802 range 0x2000 0x1000000 if X86_32
12803 range 0x200000 0x1000000 if X86_64
12804 ---help---
12805@@ -1989,6 +1994,7 @@ config COMPAT_VDSO
12806 def_bool n
12807 prompt "Disable the 32-bit vDSO (needed for glibc 2.3.3)"
12808 depends on X86_32 || IA32_EMULATION
12809+ depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
12810 ---help---
12811 Certain buggy versions of glibc will crash if they are
12812 presented with a 32-bit vDSO that is not mapped at the address
12813@@ -2053,6 +2059,22 @@ config CMDLINE_OVERRIDE
12814 This is used to work around broken boot loaders. This should
12815 be set to 'N' under normal conditions.
12816
12817+config DEFAULT_MODIFY_LDT_SYSCALL
12818+ bool "Allow userspace to modify the LDT by default"
12819+ default y
12820+
12821+ ---help---
12822+ Modifying the LDT (Local Descriptor Table) may be needed to run a
12823+ 16-bit or segmented code such as Dosemu or Wine. This is done via
12824+ a system call which is not needed to run portable applications,
12825+ and which can sometimes be abused to exploit some weaknesses of
12826+ the architecture, opening new vulnerabilities.
12827+
12828+ For this reason this option allows one to enable or disable the
12829+ feature at runtime. It is recommended to say 'N' here to leave
12830+ the system protected, and to enable it at runtime only if needed
12831+ by setting the sys.kernel.modify_ldt sysctl.
12832+
12833 source "kernel/livepatch/Kconfig"
12834
12835 endmenu
12836diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
12837index 6983314..54ad7e8 100644
12838--- a/arch/x86/Kconfig.cpu
12839+++ b/arch/x86/Kconfig.cpu
12840@@ -319,7 +319,7 @@ config X86_PPRO_FENCE
12841
12842 config X86_F00F_BUG
12843 def_bool y
12844- depends on M586MMX || M586TSC || M586 || M486
12845+ depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
12846
12847 config X86_INVD_BUG
12848 def_bool y
12849@@ -327,7 +327,7 @@ config X86_INVD_BUG
12850
12851 config X86_ALIGNMENT_16
12852 def_bool y
12853- depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
12854+ depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
12855
12856 config X86_INTEL_USERCOPY
12857 def_bool y
12858@@ -369,7 +369,7 @@ config X86_CMPXCHG64
12859 # generates cmov.
12860 config X86_CMOV
12861 def_bool y
12862- depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
12863+ depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
12864
12865 config X86_MINIMUM_CPU_FAMILY
12866 int
12867diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
12868index d8c0d32..28e3117 100644
12869--- a/arch/x86/Kconfig.debug
12870+++ b/arch/x86/Kconfig.debug
12871@@ -69,6 +69,7 @@ config X86_PTDUMP
12872 bool "Export kernel pagetable layout to userspace via debugfs"
12873 depends on DEBUG_KERNEL
12874 select DEBUG_FS
12875+ depends on !GRKERNSEC_KMEM
12876 ---help---
12877 Say Y here if you want to show the kernel pagetable layout in a
12878 debugfs file. This information is only useful for kernel developers
12879@@ -89,7 +90,7 @@ config EFI_PGT_DUMP
12880 config DEBUG_RODATA
12881 bool "Write protect kernel read-only data structures"
12882 default y
12883- depends on DEBUG_KERNEL
12884+ depends on DEBUG_KERNEL && BROKEN
12885 ---help---
12886 Mark the kernel read-only data as write-protected in the pagetables,
12887 in order to catch accidental (and incorrect) writes to such const
12888@@ -107,7 +108,7 @@ config DEBUG_RODATA_TEST
12889
12890 config DEBUG_SET_MODULE_RONX
12891 bool "Set loadable kernel module data as NX and text as RO"
12892- depends on MODULES
12893+ depends on MODULES && BROKEN
12894 ---help---
12895 This option helps catch unintended modifications to loadable
12896 kernel module's text and read-only data. It also prevents execution
12897@@ -359,6 +360,7 @@ config X86_DEBUG_FPU
12898 config PUNIT_ATOM_DEBUG
12899 tristate "ATOM Punit debug driver"
12900 select DEBUG_FS
12901+ depends on !GRKERNSEC_KMEM
12902 select IOSF_MBI
12903 ---help---
12904 This is a debug driver, which gets the power states
12905diff --git a/arch/x86/Makefile b/arch/x86/Makefile
12906index 118e6de..e02efff 100644
12907--- a/arch/x86/Makefile
12908+++ b/arch/x86/Makefile
12909@@ -65,9 +65,6 @@ ifeq ($(CONFIG_X86_32),y)
12910 # CPU-specific tuning. Anything which can be shared with UML should go here.
12911 include arch/x86/Makefile_32.cpu
12912 KBUILD_CFLAGS += $(cflags-y)
12913-
12914- # temporary until string.h is fixed
12915- KBUILD_CFLAGS += -ffreestanding
12916 else
12917 BITS := 64
12918 UTS_MACHINE := x86_64
12919@@ -116,6 +113,9 @@ else
12920 KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args)
12921 endif
12922
12923+# temporary until string.h is fixed
12924+KBUILD_CFLAGS += -ffreestanding
12925+
12926 # Make sure compiler does not have buggy stack-protector support.
12927 ifdef CONFIG_CC_STACKPROTECTOR
12928 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
12929@@ -184,6 +184,7 @@ archheaders:
12930 $(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all
12931
12932 archprepare:
12933+ $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
12934 ifeq ($(CONFIG_KEXEC_FILE),y)
12935 $(Q)$(MAKE) $(build)=arch/x86/purgatory arch/x86/purgatory/kexec-purgatory.c
12936 endif
12937@@ -267,3 +268,9 @@ define archhelp
12938 echo ' FDARGS="..." arguments for the booted kernel'
12939 echo ' FDINITRD=file initrd for the booted kernel'
12940 endef
12941+
12942+define OLD_LD
12943+
12944+*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
12945+*** Please upgrade your binutils to 2.18 or newer
12946+endef
12947diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
12948index 57bbf2f..b100fce 100644
12949--- a/arch/x86/boot/Makefile
12950+++ b/arch/x86/boot/Makefile
12951@@ -58,6 +58,9 @@ clean-files += cpustr.h
12952 # ---------------------------------------------------------------------------
12953
12954 KBUILD_CFLAGS := $(USERINCLUDE) $(REALMODE_CFLAGS) -D_SETUP
12955+ifdef CONSTIFY_PLUGIN
12956+KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
12957+endif
12958 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
12959 GCOV_PROFILE := n
12960
12961diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
12962index 878e4b9..20537ab 100644
12963--- a/arch/x86/boot/bitops.h
12964+++ b/arch/x86/boot/bitops.h
12965@@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
12966 u8 v;
12967 const u32 *p = (const u32 *)addr;
12968
12969- asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
12970+ asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
12971 return v;
12972 }
12973
12974@@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
12975
12976 static inline void set_bit(int nr, void *addr)
12977 {
12978- asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
12979+ asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
12980 }
12981
12982 #endif /* BOOT_BITOPS_H */
12983diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
12984index bd49ec6..94c7f58 100644
12985--- a/arch/x86/boot/boot.h
12986+++ b/arch/x86/boot/boot.h
12987@@ -84,7 +84,7 @@ static inline void io_delay(void)
12988 static inline u16 ds(void)
12989 {
12990 u16 seg;
12991- asm("movw %%ds,%0" : "=rm" (seg));
12992+ asm volatile("movw %%ds,%0" : "=rm" (seg));
12993 return seg;
12994 }
12995
12996diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
12997index 0a291cd..9686efc 100644
12998--- a/arch/x86/boot/compressed/Makefile
12999+++ b/arch/x86/boot/compressed/Makefile
13000@@ -30,6 +30,9 @@ KBUILD_CFLAGS += $(cflags-y)
13001 KBUILD_CFLAGS += -mno-mmx -mno-sse
13002 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
13003 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
13004+ifdef CONSTIFY_PLUGIN
13005+KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
13006+endif
13007
13008 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
13009 GCOV_PROFILE := n
13010diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
13011index a53440e..c3dbf1e 100644
13012--- a/arch/x86/boot/compressed/efi_stub_32.S
13013+++ b/arch/x86/boot/compressed/efi_stub_32.S
13014@@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
13015 * parameter 2, ..., param n. To make things easy, we save the return
13016 * address of efi_call_phys in a global variable.
13017 */
13018- popl %ecx
13019- movl %ecx, saved_return_addr(%edx)
13020- /* get the function pointer into ECX*/
13021- popl %ecx
13022- movl %ecx, efi_rt_function_ptr(%edx)
13023+ popl saved_return_addr(%edx)
13024+ popl efi_rt_function_ptr(%edx)
13025
13026 /*
13027 * 3. Call the physical function.
13028 */
13029- call *%ecx
13030+ call *efi_rt_function_ptr(%edx)
13031
13032 /*
13033 * 4. Balance the stack. And because EAX contain the return value,
13034@@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
13035 1: popl %edx
13036 subl $1b, %edx
13037
13038- movl efi_rt_function_ptr(%edx), %ecx
13039- pushl %ecx
13040+ pushl efi_rt_function_ptr(%edx)
13041
13042 /*
13043 * 10. Push the saved return address onto the stack and return.
13044 */
13045- movl saved_return_addr(%edx), %ecx
13046- pushl %ecx
13047- ret
13048+ jmpl *saved_return_addr(%edx)
13049 ENDPROC(efi_call_phys)
13050 .previous
13051
13052diff --git a/arch/x86/boot/compressed/efi_thunk_64.S b/arch/x86/boot/compressed/efi_thunk_64.S
13053index 630384a..278e788 100644
13054--- a/arch/x86/boot/compressed/efi_thunk_64.S
13055+++ b/arch/x86/boot/compressed/efi_thunk_64.S
13056@@ -189,8 +189,8 @@ efi_gdt64:
13057 .long 0 /* Filled out by user */
13058 .word 0
13059 .quad 0x0000000000000000 /* NULL descriptor */
13060- .quad 0x00af9a000000ffff /* __KERNEL_CS */
13061- .quad 0x00cf92000000ffff /* __KERNEL_DS */
13062+ .quad 0x00af9b000000ffff /* __KERNEL_CS */
13063+ .quad 0x00cf93000000ffff /* __KERNEL_DS */
13064 .quad 0x0080890000000000 /* TS descriptor */
13065 .quad 0x0000000000000000 /* TS continued */
13066 efi_gdt64_end:
13067diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
13068index 8ef964d..fcfb8aa 100644
13069--- a/arch/x86/boot/compressed/head_32.S
13070+++ b/arch/x86/boot/compressed/head_32.S
13071@@ -141,10 +141,10 @@ preferred_addr:
13072 addl %eax, %ebx
13073 notl %eax
13074 andl %eax, %ebx
13075- cmpl $LOAD_PHYSICAL_ADDR, %ebx
13076+ cmpl $____LOAD_PHYSICAL_ADDR, %ebx
13077 jge 1f
13078 #endif
13079- movl $LOAD_PHYSICAL_ADDR, %ebx
13080+ movl $____LOAD_PHYSICAL_ADDR, %ebx
13081 1:
13082
13083 /* Target address to relocate to for decompression */
13084diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
13085index b0c0d16..3b44ff8 100644
13086--- a/arch/x86/boot/compressed/head_64.S
13087+++ b/arch/x86/boot/compressed/head_64.S
13088@@ -95,10 +95,10 @@ ENTRY(startup_32)
13089 addl %eax, %ebx
13090 notl %eax
13091 andl %eax, %ebx
13092- cmpl $LOAD_PHYSICAL_ADDR, %ebx
13093+ cmpl $____LOAD_PHYSICAL_ADDR, %ebx
13094 jge 1f
13095 #endif
13096- movl $LOAD_PHYSICAL_ADDR, %ebx
13097+ movl $____LOAD_PHYSICAL_ADDR, %ebx
13098 1:
13099
13100 /* Target address to relocate to for decompression */
13101@@ -323,10 +323,10 @@ preferred_addr:
13102 addq %rax, %rbp
13103 notq %rax
13104 andq %rax, %rbp
13105- cmpq $LOAD_PHYSICAL_ADDR, %rbp
13106+ cmpq $____LOAD_PHYSICAL_ADDR, %rbp
13107 jge 1f
13108 #endif
13109- movq $LOAD_PHYSICAL_ADDR, %rbp
13110+ movq $____LOAD_PHYSICAL_ADDR, %rbp
13111 1:
13112
13113 /* Target address to relocate to for decompression */
13114@@ -435,8 +435,8 @@ gdt:
13115 .long gdt
13116 .word 0
13117 .quad 0x0000000000000000 /* NULL descriptor */
13118- .quad 0x00af9a000000ffff /* __KERNEL_CS */
13119- .quad 0x00cf92000000ffff /* __KERNEL_DS */
13120+ .quad 0x00af9b000000ffff /* __KERNEL_CS */
13121+ .quad 0x00cf93000000ffff /* __KERNEL_DS */
13122 .quad 0x0080890000000000 /* TS descriptor */
13123 .quad 0x0000000000000000 /* TS continued */
13124 gdt_end:
13125diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
13126index e28437e..6a17460 100644
13127--- a/arch/x86/boot/compressed/misc.c
13128+++ b/arch/x86/boot/compressed/misc.c
13129@@ -242,7 +242,7 @@ static void handle_relocations(void *output, unsigned long output_len)
13130 * Calculate the delta between where vmlinux was linked to load
13131 * and where it was actually loaded.
13132 */
13133- delta = min_addr - LOAD_PHYSICAL_ADDR;
13134+ delta = min_addr - ____LOAD_PHYSICAL_ADDR;
13135 if (!delta) {
13136 debug_putstr("No relocation needed... ");
13137 return;
13138@@ -324,7 +324,7 @@ static void parse_elf(void *output)
13139 Elf32_Ehdr ehdr;
13140 Elf32_Phdr *phdrs, *phdr;
13141 #endif
13142- void *dest;
13143+ void *dest, *prev;
13144 int i;
13145
13146 memcpy(&ehdr, output, sizeof(ehdr));
13147@@ -351,13 +351,16 @@ static void parse_elf(void *output)
13148 case PT_LOAD:
13149 #ifdef CONFIG_RELOCATABLE
13150 dest = output;
13151- dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
13152+ dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
13153 #else
13154 dest = (void *)(phdr->p_paddr);
13155 #endif
13156 memcpy(dest,
13157 output + phdr->p_offset,
13158 phdr->p_filesz);
13159+ if (i)
13160+ memset(prev, 0xff, dest - prev);
13161+ prev = dest + phdr->p_filesz;
13162 break;
13163 default: /* Ignore other PT_* */ break;
13164 }
13165@@ -419,7 +422,7 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
13166 error("Destination address too large");
13167 #endif
13168 #ifndef CONFIG_RELOCATABLE
13169- if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
13170+ if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
13171 error("Wrong destination address");
13172 #endif
13173
13174diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
13175index 1fd7d57..0f7d096 100644
13176--- a/arch/x86/boot/cpucheck.c
13177+++ b/arch/x86/boot/cpucheck.c
13178@@ -125,9 +125,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
13179 u32 ecx = MSR_K7_HWCR;
13180 u32 eax, edx;
13181
13182- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13183+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13184 eax &= ~(1 << 15);
13185- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13186+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13187
13188 get_cpuflags(); /* Make sure it really did something */
13189 err = check_cpuflags();
13190@@ -140,9 +140,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
13191 u32 ecx = MSR_VIA_FCR;
13192 u32 eax, edx;
13193
13194- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13195+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13196 eax |= (1<<1)|(1<<7);
13197- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13198+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13199
13200 set_bit(X86_FEATURE_CX8, cpu.flags);
13201 err = check_cpuflags();
13202@@ -153,12 +153,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
13203 u32 eax, edx;
13204 u32 level = 1;
13205
13206- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13207- asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
13208- asm("cpuid"
13209+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13210+ asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
13211+ asm volatile("cpuid"
13212 : "+a" (level), "=d" (cpu.flags[0])
13213 : : "ecx", "ebx");
13214- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13215+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13216
13217 err = check_cpuflags();
13218 } else if (err == 0x01 &&
13219diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
13220index 16ef025..91e033b 100644
13221--- a/arch/x86/boot/header.S
13222+++ b/arch/x86/boot/header.S
13223@@ -438,10 +438,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
13224 # single linked list of
13225 # struct setup_data
13226
13227-pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
13228+pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
13229
13230 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
13231+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
13232+#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
13233+#else
13234 #define VO_INIT_SIZE (VO__end - VO__text)
13235+#endif
13236 #if ZO_INIT_SIZE > VO_INIT_SIZE
13237 #define INIT_SIZE ZO_INIT_SIZE
13238 #else
13239diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
13240index db75d07..8e6d0af 100644
13241--- a/arch/x86/boot/memory.c
13242+++ b/arch/x86/boot/memory.c
13243@@ -19,7 +19,7 @@
13244
13245 static int detect_memory_e820(void)
13246 {
13247- int count = 0;
13248+ unsigned int count = 0;
13249 struct biosregs ireg, oreg;
13250 struct e820entry *desc = boot_params.e820_map;
13251 static struct e820entry buf; /* static so it is zeroed */
13252diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
13253index ba3e100..6501b8f 100644
13254--- a/arch/x86/boot/video-vesa.c
13255+++ b/arch/x86/boot/video-vesa.c
13256@@ -201,6 +201,7 @@ static void vesa_store_pm_info(void)
13257
13258 boot_params.screen_info.vesapm_seg = oreg.es;
13259 boot_params.screen_info.vesapm_off = oreg.di;
13260+ boot_params.screen_info.vesapm_size = oreg.cx;
13261 }
13262
13263 /*
13264diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
13265index 05111bb..a1ae1f0 100644
13266--- a/arch/x86/boot/video.c
13267+++ b/arch/x86/boot/video.c
13268@@ -98,7 +98,7 @@ static void store_mode_params(void)
13269 static unsigned int get_entry(void)
13270 {
13271 char entry_buf[4];
13272- int i, len = 0;
13273+ unsigned int i, len = 0;
13274 int key;
13275 unsigned int v;
13276
13277diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
13278index 9105655..41779c1 100644
13279--- a/arch/x86/crypto/aes-x86_64-asm_64.S
13280+++ b/arch/x86/crypto/aes-x86_64-asm_64.S
13281@@ -8,6 +8,8 @@
13282 * including this sentence is retained in full.
13283 */
13284
13285+#include <asm/alternative-asm.h>
13286+
13287 .extern crypto_ft_tab
13288 .extern crypto_it_tab
13289 .extern crypto_fl_tab
13290@@ -70,6 +72,8 @@
13291 je B192; \
13292 leaq 32(r9),r9;
13293
13294+#define ret pax_force_retaddr; ret
13295+
13296 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
13297 movq r1,r2; \
13298 movq r3,r4; \
13299diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
13300index 6bd2c6c..368c93e 100644
13301--- a/arch/x86/crypto/aesni-intel_asm.S
13302+++ b/arch/x86/crypto/aesni-intel_asm.S
13303@@ -31,6 +31,7 @@
13304
13305 #include <linux/linkage.h>
13306 #include <asm/inst.h>
13307+#include <asm/alternative-asm.h>
13308
13309 /*
13310 * The following macros are used to move an (un)aligned 16 byte value to/from
13311@@ -217,7 +218,7 @@ enc: .octa 0x2
13312 * num_initial_blocks = b mod 4
13313 * encrypt the initial num_initial_blocks blocks and apply ghash on
13314 * the ciphertext
13315-* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13316+* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13317 * are clobbered
13318 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
13319 */
13320@@ -227,8 +228,8 @@ enc: .octa 0x2
13321 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
13322 MOVADQ SHUF_MASK(%rip), %xmm14
13323 mov arg7, %r10 # %r10 = AAD
13324- mov arg8, %r12 # %r12 = aadLen
13325- mov %r12, %r11
13326+ mov arg8, %r15 # %r15 = aadLen
13327+ mov %r15, %r11
13328 pxor %xmm\i, %xmm\i
13329
13330 _get_AAD_loop\num_initial_blocks\operation:
13331@@ -237,17 +238,17 @@ _get_AAD_loop\num_initial_blocks\operation:
13332 psrldq $4, %xmm\i
13333 pxor \TMP1, %xmm\i
13334 add $4, %r10
13335- sub $4, %r12
13336+ sub $4, %r15
13337 jne _get_AAD_loop\num_initial_blocks\operation
13338
13339 cmp $16, %r11
13340 je _get_AAD_loop2_done\num_initial_blocks\operation
13341
13342- mov $16, %r12
13343+ mov $16, %r15
13344 _get_AAD_loop2\num_initial_blocks\operation:
13345 psrldq $4, %xmm\i
13346- sub $4, %r12
13347- cmp %r11, %r12
13348+ sub $4, %r15
13349+ cmp %r11, %r15
13350 jne _get_AAD_loop2\num_initial_blocks\operation
13351
13352 _get_AAD_loop2_done\num_initial_blocks\operation:
13353@@ -442,7 +443,7 @@ _initial_blocks_done\num_initial_blocks\operation:
13354 * num_initial_blocks = b mod 4
13355 * encrypt the initial num_initial_blocks blocks and apply ghash on
13356 * the ciphertext
13357-* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13358+* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13359 * are clobbered
13360 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
13361 */
13362@@ -452,8 +453,8 @@ _initial_blocks_done\num_initial_blocks\operation:
13363 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
13364 MOVADQ SHUF_MASK(%rip), %xmm14
13365 mov arg7, %r10 # %r10 = AAD
13366- mov arg8, %r12 # %r12 = aadLen
13367- mov %r12, %r11
13368+ mov arg8, %r15 # %r15 = aadLen
13369+ mov %r15, %r11
13370 pxor %xmm\i, %xmm\i
13371 _get_AAD_loop\num_initial_blocks\operation:
13372 movd (%r10), \TMP1
13373@@ -461,15 +462,15 @@ _get_AAD_loop\num_initial_blocks\operation:
13374 psrldq $4, %xmm\i
13375 pxor \TMP1, %xmm\i
13376 add $4, %r10
13377- sub $4, %r12
13378+ sub $4, %r15
13379 jne _get_AAD_loop\num_initial_blocks\operation
13380 cmp $16, %r11
13381 je _get_AAD_loop2_done\num_initial_blocks\operation
13382- mov $16, %r12
13383+ mov $16, %r15
13384 _get_AAD_loop2\num_initial_blocks\operation:
13385 psrldq $4, %xmm\i
13386- sub $4, %r12
13387- cmp %r11, %r12
13388+ sub $4, %r15
13389+ cmp %r11, %r15
13390 jne _get_AAD_loop2\num_initial_blocks\operation
13391 _get_AAD_loop2_done\num_initial_blocks\operation:
13392 PSHUFB_XMM %xmm14, %xmm\i # byte-reflect the AAD data
13393@@ -1280,7 +1281,7 @@ _esb_loop_\@:
13394 *
13395 *****************************************************************************/
13396 ENTRY(aesni_gcm_dec)
13397- push %r12
13398+ push %r15
13399 push %r13
13400 push %r14
13401 mov %rsp, %r14
13402@@ -1290,8 +1291,8 @@ ENTRY(aesni_gcm_dec)
13403 */
13404 sub $VARIABLE_OFFSET, %rsp
13405 and $~63, %rsp # align rsp to 64 bytes
13406- mov %arg6, %r12
13407- movdqu (%r12), %xmm13 # %xmm13 = HashKey
13408+ mov %arg6, %r15
13409+ movdqu (%r15), %xmm13 # %xmm13 = HashKey
13410 movdqa SHUF_MASK(%rip), %xmm2
13411 PSHUFB_XMM %xmm2, %xmm13
13412
13413@@ -1319,10 +1320,10 @@ ENTRY(aesni_gcm_dec)
13414 movdqa %xmm13, HashKey(%rsp) # store HashKey<<1 (mod poly)
13415 mov %arg4, %r13 # save the number of bytes of plaintext/ciphertext
13416 and $-16, %r13 # %r13 = %r13 - (%r13 mod 16)
13417- mov %r13, %r12
13418- and $(3<<4), %r12
13419+ mov %r13, %r15
13420+ and $(3<<4), %r15
13421 jz _initial_num_blocks_is_0_decrypt
13422- cmp $(2<<4), %r12
13423+ cmp $(2<<4), %r15
13424 jb _initial_num_blocks_is_1_decrypt
13425 je _initial_num_blocks_is_2_decrypt
13426 _initial_num_blocks_is_3_decrypt:
13427@@ -1372,16 +1373,16 @@ _zero_cipher_left_decrypt:
13428 sub $16, %r11
13429 add %r13, %r11
13430 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte block
13431- lea SHIFT_MASK+16(%rip), %r12
13432- sub %r13, %r12
13433+ lea SHIFT_MASK+16(%rip), %r15
13434+ sub %r13, %r15
13435 # adjust the shuffle mask pointer to be able to shift 16-%r13 bytes
13436 # (%r13 is the number of bytes in plaintext mod 16)
13437- movdqu (%r12), %xmm2 # get the appropriate shuffle mask
13438+ movdqu (%r15), %xmm2 # get the appropriate shuffle mask
13439 PSHUFB_XMM %xmm2, %xmm1 # right shift 16-%r13 butes
13440
13441 movdqa %xmm1, %xmm2
13442 pxor %xmm1, %xmm0 # Ciphertext XOR E(K, Yn)
13443- movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
13444+ movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
13445 # get the appropriate mask to mask out top 16-%r13 bytes of %xmm0
13446 pand %xmm1, %xmm0 # mask out top 16-%r13 bytes of %xmm0
13447 pand %xmm1, %xmm2
13448@@ -1410,9 +1411,9 @@ _less_than_8_bytes_left_decrypt:
13449 sub $1, %r13
13450 jne _less_than_8_bytes_left_decrypt
13451 _multiple_of_16_bytes_decrypt:
13452- mov arg8, %r12 # %r13 = aadLen (number of bytes)
13453- shl $3, %r12 # convert into number of bits
13454- movd %r12d, %xmm15 # len(A) in %xmm15
13455+ mov arg8, %r15 # %r13 = aadLen (number of bytes)
13456+ shl $3, %r15 # convert into number of bits
13457+ movd %r15d, %xmm15 # len(A) in %xmm15
13458 shl $3, %arg4 # len(C) in bits (*128)
13459 MOVQ_R64_XMM %arg4, %xmm1
13460 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
13461@@ -1451,7 +1452,8 @@ _return_T_done_decrypt:
13462 mov %r14, %rsp
13463 pop %r14
13464 pop %r13
13465- pop %r12
13466+ pop %r15
13467+ pax_force_retaddr
13468 ret
13469 ENDPROC(aesni_gcm_dec)
13470
13471@@ -1540,7 +1542,7 @@ ENDPROC(aesni_gcm_dec)
13472 * poly = x^128 + x^127 + x^126 + x^121 + 1
13473 ***************************************************************************/
13474 ENTRY(aesni_gcm_enc)
13475- push %r12
13476+ push %r15
13477 push %r13
13478 push %r14
13479 mov %rsp, %r14
13480@@ -1550,8 +1552,8 @@ ENTRY(aesni_gcm_enc)
13481 #
13482 sub $VARIABLE_OFFSET, %rsp
13483 and $~63, %rsp
13484- mov %arg6, %r12
13485- movdqu (%r12), %xmm13
13486+ mov %arg6, %r15
13487+ movdqu (%r15), %xmm13
13488 movdqa SHUF_MASK(%rip), %xmm2
13489 PSHUFB_XMM %xmm2, %xmm13
13490
13491@@ -1575,13 +1577,13 @@ ENTRY(aesni_gcm_enc)
13492 movdqa %xmm13, HashKey(%rsp)
13493 mov %arg4, %r13 # %xmm13 holds HashKey<<1 (mod poly)
13494 and $-16, %r13
13495- mov %r13, %r12
13496+ mov %r13, %r15
13497
13498 # Encrypt first few blocks
13499
13500- and $(3<<4), %r12
13501+ and $(3<<4), %r15
13502 jz _initial_num_blocks_is_0_encrypt
13503- cmp $(2<<4), %r12
13504+ cmp $(2<<4), %r15
13505 jb _initial_num_blocks_is_1_encrypt
13506 je _initial_num_blocks_is_2_encrypt
13507 _initial_num_blocks_is_3_encrypt:
13508@@ -1634,14 +1636,14 @@ _zero_cipher_left_encrypt:
13509 sub $16, %r11
13510 add %r13, %r11
13511 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte blocks
13512- lea SHIFT_MASK+16(%rip), %r12
13513- sub %r13, %r12
13514+ lea SHIFT_MASK+16(%rip), %r15
13515+ sub %r13, %r15
13516 # adjust the shuffle mask pointer to be able to shift 16-r13 bytes
13517 # (%r13 is the number of bytes in plaintext mod 16)
13518- movdqu (%r12), %xmm2 # get the appropriate shuffle mask
13519+ movdqu (%r15), %xmm2 # get the appropriate shuffle mask
13520 PSHUFB_XMM %xmm2, %xmm1 # shift right 16-r13 byte
13521 pxor %xmm1, %xmm0 # Plaintext XOR Encrypt(K, Yn)
13522- movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
13523+ movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
13524 # get the appropriate mask to mask out top 16-r13 bytes of xmm0
13525 pand %xmm1, %xmm0 # mask out top 16-r13 bytes of xmm0
13526 movdqa SHUF_MASK(%rip), %xmm10
13527@@ -1674,9 +1676,9 @@ _less_than_8_bytes_left_encrypt:
13528 sub $1, %r13
13529 jne _less_than_8_bytes_left_encrypt
13530 _multiple_of_16_bytes_encrypt:
13531- mov arg8, %r12 # %r12 = addLen (number of bytes)
13532- shl $3, %r12
13533- movd %r12d, %xmm15 # len(A) in %xmm15
13534+ mov arg8, %r15 # %r15 = addLen (number of bytes)
13535+ shl $3, %r15
13536+ movd %r15d, %xmm15 # len(A) in %xmm15
13537 shl $3, %arg4 # len(C) in bits (*128)
13538 MOVQ_R64_XMM %arg4, %xmm1
13539 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
13540@@ -1715,7 +1717,8 @@ _return_T_done_encrypt:
13541 mov %r14, %rsp
13542 pop %r14
13543 pop %r13
13544- pop %r12
13545+ pop %r15
13546+ pax_force_retaddr
13547 ret
13548 ENDPROC(aesni_gcm_enc)
13549
13550@@ -1733,6 +1736,7 @@ _key_expansion_256a:
13551 pxor %xmm1, %xmm0
13552 movaps %xmm0, (TKEYP)
13553 add $0x10, TKEYP
13554+ pax_force_retaddr
13555 ret
13556 ENDPROC(_key_expansion_128)
13557 ENDPROC(_key_expansion_256a)
13558@@ -1759,6 +1763,7 @@ _key_expansion_192a:
13559 shufps $0b01001110, %xmm2, %xmm1
13560 movaps %xmm1, 0x10(TKEYP)
13561 add $0x20, TKEYP
13562+ pax_force_retaddr
13563 ret
13564 ENDPROC(_key_expansion_192a)
13565
13566@@ -1779,6 +1784,7 @@ _key_expansion_192b:
13567
13568 movaps %xmm0, (TKEYP)
13569 add $0x10, TKEYP
13570+ pax_force_retaddr
13571 ret
13572 ENDPROC(_key_expansion_192b)
13573
13574@@ -1792,6 +1798,7 @@ _key_expansion_256b:
13575 pxor %xmm1, %xmm2
13576 movaps %xmm2, (TKEYP)
13577 add $0x10, TKEYP
13578+ pax_force_retaddr
13579 ret
13580 ENDPROC(_key_expansion_256b)
13581
13582@@ -1905,6 +1912,7 @@ ENTRY(aesni_set_key)
13583 #ifndef __x86_64__
13584 popl KEYP
13585 #endif
13586+ pax_force_retaddr
13587 ret
13588 ENDPROC(aesni_set_key)
13589
13590@@ -1927,6 +1935,7 @@ ENTRY(aesni_enc)
13591 popl KLEN
13592 popl KEYP
13593 #endif
13594+ pax_force_retaddr
13595 ret
13596 ENDPROC(aesni_enc)
13597
13598@@ -1985,6 +1994,7 @@ _aesni_enc1:
13599 AESENC KEY STATE
13600 movaps 0x70(TKEYP), KEY
13601 AESENCLAST KEY STATE
13602+ pax_force_retaddr
13603 ret
13604 ENDPROC(_aesni_enc1)
13605
13606@@ -2094,6 +2104,7 @@ _aesni_enc4:
13607 AESENCLAST KEY STATE2
13608 AESENCLAST KEY STATE3
13609 AESENCLAST KEY STATE4
13610+ pax_force_retaddr
13611 ret
13612 ENDPROC(_aesni_enc4)
13613
13614@@ -2117,6 +2128,7 @@ ENTRY(aesni_dec)
13615 popl KLEN
13616 popl KEYP
13617 #endif
13618+ pax_force_retaddr
13619 ret
13620 ENDPROC(aesni_dec)
13621
13622@@ -2175,6 +2187,7 @@ _aesni_dec1:
13623 AESDEC KEY STATE
13624 movaps 0x70(TKEYP), KEY
13625 AESDECLAST KEY STATE
13626+ pax_force_retaddr
13627 ret
13628 ENDPROC(_aesni_dec1)
13629
13630@@ -2284,6 +2297,7 @@ _aesni_dec4:
13631 AESDECLAST KEY STATE2
13632 AESDECLAST KEY STATE3
13633 AESDECLAST KEY STATE4
13634+ pax_force_retaddr
13635 ret
13636 ENDPROC(_aesni_dec4)
13637
13638@@ -2342,6 +2356,7 @@ ENTRY(aesni_ecb_enc)
13639 popl KEYP
13640 popl LEN
13641 #endif
13642+ pax_force_retaddr
13643 ret
13644 ENDPROC(aesni_ecb_enc)
13645
13646@@ -2401,6 +2416,7 @@ ENTRY(aesni_ecb_dec)
13647 popl KEYP
13648 popl LEN
13649 #endif
13650+ pax_force_retaddr
13651 ret
13652 ENDPROC(aesni_ecb_dec)
13653
13654@@ -2443,6 +2459,7 @@ ENTRY(aesni_cbc_enc)
13655 popl LEN
13656 popl IVP
13657 #endif
13658+ pax_force_retaddr
13659 ret
13660 ENDPROC(aesni_cbc_enc)
13661
13662@@ -2534,6 +2551,7 @@ ENTRY(aesni_cbc_dec)
13663 popl LEN
13664 popl IVP
13665 #endif
13666+ pax_force_retaddr
13667 ret
13668 ENDPROC(aesni_cbc_dec)
13669
13670@@ -2561,6 +2579,7 @@ _aesni_inc_init:
13671 mov $1, TCTR_LOW
13672 MOVQ_R64_XMM TCTR_LOW INC
13673 MOVQ_R64_XMM CTR TCTR_LOW
13674+ pax_force_retaddr
13675 ret
13676 ENDPROC(_aesni_inc_init)
13677
13678@@ -2590,6 +2609,7 @@ _aesni_inc:
13679 .Linc_low:
13680 movaps CTR, IV
13681 PSHUFB_XMM BSWAP_MASK IV
13682+ pax_force_retaddr
13683 ret
13684 ENDPROC(_aesni_inc)
13685
13686@@ -2651,6 +2671,7 @@ ENTRY(aesni_ctr_enc)
13687 .Lctr_enc_ret:
13688 movups IV, (IVP)
13689 .Lctr_enc_just_ret:
13690+ pax_force_retaddr
13691 ret
13692 ENDPROC(aesni_ctr_enc)
13693
13694@@ -2777,6 +2798,7 @@ ENTRY(aesni_xts_crypt8)
13695 pxor INC, STATE4
13696 movdqu STATE4, 0x70(OUTP)
13697
13698+ pax_force_retaddr
13699 ret
13700 ENDPROC(aesni_xts_crypt8)
13701
13702diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
13703index 246c670..466e2d6 100644
13704--- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
13705+++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
13706@@ -21,6 +21,7 @@
13707 */
13708
13709 #include <linux/linkage.h>
13710+#include <asm/alternative-asm.h>
13711
13712 .file "blowfish-x86_64-asm.S"
13713 .text
13714@@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
13715 jnz .L__enc_xor;
13716
13717 write_block();
13718+ pax_force_retaddr
13719 ret;
13720 .L__enc_xor:
13721 xor_block();
13722+ pax_force_retaddr
13723 ret;
13724 ENDPROC(__blowfish_enc_blk)
13725
13726@@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
13727
13728 movq %r11, %rbp;
13729
13730+ pax_force_retaddr
13731 ret;
13732 ENDPROC(blowfish_dec_blk)
13733
13734@@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
13735
13736 popq %rbx;
13737 popq %rbp;
13738+ pax_force_retaddr
13739 ret;
13740
13741 .L__enc_xor4:
13742@@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
13743
13744 popq %rbx;
13745 popq %rbp;
13746+ pax_force_retaddr
13747 ret;
13748 ENDPROC(__blowfish_enc_blk_4way)
13749
13750@@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
13751 popq %rbx;
13752 popq %rbp;
13753
13754+ pax_force_retaddr
13755 ret;
13756 ENDPROC(blowfish_dec_blk_4way)
13757diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13758index ce71f92..1dce7ec 100644
13759--- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13760+++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13761@@ -16,6 +16,7 @@
13762 */
13763
13764 #include <linux/linkage.h>
13765+#include <asm/alternative-asm.h>
13766
13767 #define CAMELLIA_TABLE_BYTE_LEN 272
13768
13769@@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
13770 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
13771 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
13772 %rcx, (%r9));
13773+ pax_force_retaddr
13774 ret;
13775 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
13776
13777@@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
13778 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
13779 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
13780 %rax, (%r9));
13781+ pax_force_retaddr
13782 ret;
13783 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
13784
13785@@ -780,6 +783,7 @@ __camellia_enc_blk16:
13786 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
13787 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
13788
13789+ pax_force_retaddr
13790 ret;
13791
13792 .align 8
13793@@ -865,6 +869,7 @@ __camellia_dec_blk16:
13794 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
13795 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
13796
13797+ pax_force_retaddr
13798 ret;
13799
13800 .align 8
13801@@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
13802 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13803 %xmm8, %rsi);
13804
13805+ pax_force_retaddr
13806 ret;
13807 ENDPROC(camellia_ecb_enc_16way)
13808
13809@@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
13810 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13811 %xmm8, %rsi);
13812
13813+ pax_force_retaddr
13814 ret;
13815 ENDPROC(camellia_ecb_dec_16way)
13816
13817@@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
13818 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13819 %xmm8, %rsi);
13820
13821+ pax_force_retaddr
13822 ret;
13823 ENDPROC(camellia_cbc_dec_16way)
13824
13825@@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
13826 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13827 %xmm8, %rsi);
13828
13829+ pax_force_retaddr
13830 ret;
13831 ENDPROC(camellia_ctr_16way)
13832
13833@@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
13834 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13835 %xmm8, %rsi);
13836
13837+ pax_force_retaddr
13838 ret;
13839 ENDPROC(camellia_xts_crypt_16way)
13840
13841diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13842index 0e0b886..5a3123c 100644
13843--- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13844+++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13845@@ -11,6 +11,7 @@
13846 */
13847
13848 #include <linux/linkage.h>
13849+#include <asm/alternative-asm.h>
13850
13851 #define CAMELLIA_TABLE_BYTE_LEN 272
13852
13853@@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
13854 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
13855 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
13856 %rcx, (%r9));
13857+ pax_force_retaddr
13858 ret;
13859 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
13860
13861@@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
13862 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
13863 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
13864 %rax, (%r9));
13865+ pax_force_retaddr
13866 ret;
13867 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
13868
13869@@ -820,6 +823,7 @@ __camellia_enc_blk32:
13870 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
13871 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
13872
13873+ pax_force_retaddr
13874 ret;
13875
13876 .align 8
13877@@ -905,6 +909,7 @@ __camellia_dec_blk32:
13878 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
13879 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
13880
13881+ pax_force_retaddr
13882 ret;
13883
13884 .align 8
13885@@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
13886
13887 vzeroupper;
13888
13889+ pax_force_retaddr
13890 ret;
13891 ENDPROC(camellia_ecb_enc_32way)
13892
13893@@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
13894
13895 vzeroupper;
13896
13897+ pax_force_retaddr
13898 ret;
13899 ENDPROC(camellia_ecb_dec_32way)
13900
13901@@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
13902
13903 vzeroupper;
13904
13905+ pax_force_retaddr
13906 ret;
13907 ENDPROC(camellia_cbc_dec_32way)
13908
13909@@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
13910
13911 vzeroupper;
13912
13913+ pax_force_retaddr
13914 ret;
13915 ENDPROC(camellia_ctr_32way)
13916
13917@@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
13918
13919 vzeroupper;
13920
13921+ pax_force_retaddr
13922 ret;
13923 ENDPROC(camellia_xts_crypt_32way)
13924
13925diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
13926index 310319c..db3d7b5 100644
13927--- a/arch/x86/crypto/camellia-x86_64-asm_64.S
13928+++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
13929@@ -21,6 +21,7 @@
13930 */
13931
13932 #include <linux/linkage.h>
13933+#include <asm/alternative-asm.h>
13934
13935 .file "camellia-x86_64-asm_64.S"
13936 .text
13937@@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
13938 enc_outunpack(mov, RT1);
13939
13940 movq RRBP, %rbp;
13941+ pax_force_retaddr
13942 ret;
13943
13944 .L__enc_xor:
13945 enc_outunpack(xor, RT1);
13946
13947 movq RRBP, %rbp;
13948+ pax_force_retaddr
13949 ret;
13950 ENDPROC(__camellia_enc_blk)
13951
13952@@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
13953 dec_outunpack();
13954
13955 movq RRBP, %rbp;
13956+ pax_force_retaddr
13957 ret;
13958 ENDPROC(camellia_dec_blk)
13959
13960@@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
13961
13962 movq RRBP, %rbp;
13963 popq %rbx;
13964+ pax_force_retaddr
13965 ret;
13966
13967 .L__enc2_xor:
13968@@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
13969
13970 movq RRBP, %rbp;
13971 popq %rbx;
13972+ pax_force_retaddr
13973 ret;
13974 ENDPROC(__camellia_enc_blk_2way)
13975
13976@@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
13977
13978 movq RRBP, %rbp;
13979 movq RXOR, %rbx;
13980+ pax_force_retaddr
13981 ret;
13982 ENDPROC(camellia_dec_blk_2way)
13983diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
13984index c35fd5d..2d8c7db 100644
13985--- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
13986+++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
13987@@ -24,6 +24,7 @@
13988 */
13989
13990 #include <linux/linkage.h>
13991+#include <asm/alternative-asm.h>
13992
13993 .file "cast5-avx-x86_64-asm_64.S"
13994
13995@@ -281,6 +282,7 @@ __cast5_enc_blk16:
13996 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
13997 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
13998
13999+ pax_force_retaddr
14000 ret;
14001 ENDPROC(__cast5_enc_blk16)
14002
14003@@ -352,6 +354,7 @@ __cast5_dec_blk16:
14004 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
14005 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
14006
14007+ pax_force_retaddr
14008 ret;
14009
14010 .L__skip_dec:
14011@@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
14012 vmovdqu RR4, (6*4*4)(%r11);
14013 vmovdqu RL4, (7*4*4)(%r11);
14014
14015+ pax_force_retaddr
14016 ret;
14017 ENDPROC(cast5_ecb_enc_16way)
14018
14019@@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
14020 vmovdqu RR4, (6*4*4)(%r11);
14021 vmovdqu RL4, (7*4*4)(%r11);
14022
14023+ pax_force_retaddr
14024 ret;
14025 ENDPROC(cast5_ecb_dec_16way)
14026
14027@@ -430,10 +435,10 @@ ENTRY(cast5_cbc_dec_16way)
14028 * %rdx: src
14029 */
14030
14031- pushq %r12;
14032+ pushq %r14;
14033
14034 movq %rsi, %r11;
14035- movq %rdx, %r12;
14036+ movq %rdx, %r14;
14037
14038 vmovdqu (0*16)(%rdx), RL1;
14039 vmovdqu (1*16)(%rdx), RR1;
14040@@ -447,16 +452,16 @@ ENTRY(cast5_cbc_dec_16way)
14041 call __cast5_dec_blk16;
14042
14043 /* xor with src */
14044- vmovq (%r12), RX;
14045+ vmovq (%r14), RX;
14046 vpshufd $0x4f, RX, RX;
14047 vpxor RX, RR1, RR1;
14048- vpxor 0*16+8(%r12), RL1, RL1;
14049- vpxor 1*16+8(%r12), RR2, RR2;
14050- vpxor 2*16+8(%r12), RL2, RL2;
14051- vpxor 3*16+8(%r12), RR3, RR3;
14052- vpxor 4*16+8(%r12), RL3, RL3;
14053- vpxor 5*16+8(%r12), RR4, RR4;
14054- vpxor 6*16+8(%r12), RL4, RL4;
14055+ vpxor 0*16+8(%r14), RL1, RL1;
14056+ vpxor 1*16+8(%r14), RR2, RR2;
14057+ vpxor 2*16+8(%r14), RL2, RL2;
14058+ vpxor 3*16+8(%r14), RR3, RR3;
14059+ vpxor 4*16+8(%r14), RL3, RL3;
14060+ vpxor 5*16+8(%r14), RR4, RR4;
14061+ vpxor 6*16+8(%r14), RL4, RL4;
14062
14063 vmovdqu RR1, (0*16)(%r11);
14064 vmovdqu RL1, (1*16)(%r11);
14065@@ -467,8 +472,9 @@ ENTRY(cast5_cbc_dec_16way)
14066 vmovdqu RR4, (6*16)(%r11);
14067 vmovdqu RL4, (7*16)(%r11);
14068
14069- popq %r12;
14070+ popq %r14;
14071
14072+ pax_force_retaddr
14073 ret;
14074 ENDPROC(cast5_cbc_dec_16way)
14075
14076@@ -480,10 +486,10 @@ ENTRY(cast5_ctr_16way)
14077 * %rcx: iv (big endian, 64bit)
14078 */
14079
14080- pushq %r12;
14081+ pushq %r14;
14082
14083 movq %rsi, %r11;
14084- movq %rdx, %r12;
14085+ movq %rdx, %r14;
14086
14087 vpcmpeqd RTMP, RTMP, RTMP;
14088 vpsrldq $8, RTMP, RTMP; /* low: -1, high: 0 */
14089@@ -523,14 +529,14 @@ ENTRY(cast5_ctr_16way)
14090 call __cast5_enc_blk16;
14091
14092 /* dst = src ^ iv */
14093- vpxor (0*16)(%r12), RR1, RR1;
14094- vpxor (1*16)(%r12), RL1, RL1;
14095- vpxor (2*16)(%r12), RR2, RR2;
14096- vpxor (3*16)(%r12), RL2, RL2;
14097- vpxor (4*16)(%r12), RR3, RR3;
14098- vpxor (5*16)(%r12), RL3, RL3;
14099- vpxor (6*16)(%r12), RR4, RR4;
14100- vpxor (7*16)(%r12), RL4, RL4;
14101+ vpxor (0*16)(%r14), RR1, RR1;
14102+ vpxor (1*16)(%r14), RL1, RL1;
14103+ vpxor (2*16)(%r14), RR2, RR2;
14104+ vpxor (3*16)(%r14), RL2, RL2;
14105+ vpxor (4*16)(%r14), RR3, RR3;
14106+ vpxor (5*16)(%r14), RL3, RL3;
14107+ vpxor (6*16)(%r14), RR4, RR4;
14108+ vpxor (7*16)(%r14), RL4, RL4;
14109 vmovdqu RR1, (0*16)(%r11);
14110 vmovdqu RL1, (1*16)(%r11);
14111 vmovdqu RR2, (2*16)(%r11);
14112@@ -540,7 +546,8 @@ ENTRY(cast5_ctr_16way)
14113 vmovdqu RR4, (6*16)(%r11);
14114 vmovdqu RL4, (7*16)(%r11);
14115
14116- popq %r12;
14117+ popq %r14;
14118
14119+ pax_force_retaddr
14120 ret;
14121 ENDPROC(cast5_ctr_16way)
14122diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
14123index e3531f8..e123f35 100644
14124--- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
14125+++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
14126@@ -24,6 +24,7 @@
14127 */
14128
14129 #include <linux/linkage.h>
14130+#include <asm/alternative-asm.h>
14131 #include "glue_helper-asm-avx.S"
14132
14133 .file "cast6-avx-x86_64-asm_64.S"
14134@@ -295,6 +296,7 @@ __cast6_enc_blk8:
14135 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
14136 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
14137
14138+ pax_force_retaddr
14139 ret;
14140 ENDPROC(__cast6_enc_blk8)
14141
14142@@ -340,6 +342,7 @@ __cast6_dec_blk8:
14143 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
14144 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
14145
14146+ pax_force_retaddr
14147 ret;
14148 ENDPROC(__cast6_dec_blk8)
14149
14150@@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
14151
14152 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14153
14154+ pax_force_retaddr
14155 ret;
14156 ENDPROC(cast6_ecb_enc_8way)
14157
14158@@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
14159
14160 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14161
14162+ pax_force_retaddr
14163 ret;
14164 ENDPROC(cast6_ecb_dec_8way)
14165
14166@@ -386,19 +391,20 @@ ENTRY(cast6_cbc_dec_8way)
14167 * %rdx: src
14168 */
14169
14170- pushq %r12;
14171+ pushq %r14;
14172
14173 movq %rsi, %r11;
14174- movq %rdx, %r12;
14175+ movq %rdx, %r14;
14176
14177 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14178
14179 call __cast6_dec_blk8;
14180
14181- store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14182+ store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14183
14184- popq %r12;
14185+ popq %r14;
14186
14187+ pax_force_retaddr
14188 ret;
14189 ENDPROC(cast6_cbc_dec_8way)
14190
14191@@ -410,20 +416,21 @@ ENTRY(cast6_ctr_8way)
14192 * %rcx: iv (little endian, 128bit)
14193 */
14194
14195- pushq %r12;
14196+ pushq %r14;
14197
14198 movq %rsi, %r11;
14199- movq %rdx, %r12;
14200+ movq %rdx, %r14;
14201
14202 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
14203 RD2, RX, RKR, RKM);
14204
14205 call __cast6_enc_blk8;
14206
14207- store_ctr_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14208+ store_ctr_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14209
14210- popq %r12;
14211+ popq %r14;
14212
14213+ pax_force_retaddr
14214 ret;
14215 ENDPROC(cast6_ctr_8way)
14216
14217@@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
14218 /* dst <= regs xor IVs(in dst) */
14219 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14220
14221+ pax_force_retaddr
14222 ret;
14223 ENDPROC(cast6_xts_enc_8way)
14224
14225@@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
14226 /* dst <= regs xor IVs(in dst) */
14227 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14228
14229+ pax_force_retaddr
14230 ret;
14231 ENDPROC(cast6_xts_dec_8way)
14232diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
14233index 225be06..2885e731 100644
14234--- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
14235+++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
14236@@ -45,6 +45,7 @@
14237
14238 #include <asm/inst.h>
14239 #include <linux/linkage.h>
14240+#include <asm/alternative-asm.h>
14241
14242 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
14243
14244@@ -309,6 +310,7 @@ do_return:
14245 popq %rsi
14246 popq %rdi
14247 popq %rbx
14248+ pax_force_retaddr
14249 ret
14250
14251 ################################################################
14252@@ -330,7 +332,7 @@ ENDPROC(crc_pcl)
14253 ## PCLMULQDQ tables
14254 ## Table is 128 entries x 2 words (8 bytes) each
14255 ################################################################
14256-.section .rotata, "a", %progbits
14257+.section .rodata, "a", %progbits
14258 .align 8
14259 K_table:
14260 .long 0x493c7d27, 0x00000001
14261diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
14262index 5d1e007..098cb4f 100644
14263--- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
14264+++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
14265@@ -18,6 +18,7 @@
14266
14267 #include <linux/linkage.h>
14268 #include <asm/inst.h>
14269+#include <asm/alternative-asm.h>
14270
14271 .data
14272
14273@@ -89,6 +90,7 @@ __clmul_gf128mul_ble:
14274 psrlq $1, T2
14275 pxor T2, T1
14276 pxor T1, DATA
14277+ pax_force_retaddr
14278 ret
14279 ENDPROC(__clmul_gf128mul_ble)
14280
14281@@ -101,6 +103,7 @@ ENTRY(clmul_ghash_mul)
14282 call __clmul_gf128mul_ble
14283 PSHUFB_XMM BSWAP DATA
14284 movups DATA, (%rdi)
14285+ pax_force_retaddr
14286 ret
14287 ENDPROC(clmul_ghash_mul)
14288
14289@@ -128,5 +131,6 @@ ENTRY(clmul_ghash_update)
14290 PSHUFB_XMM BSWAP DATA
14291 movups DATA, (%rdi)
14292 .Lupdate_just_ret:
14293+ pax_force_retaddr
14294 ret
14295 ENDPROC(clmul_ghash_update)
14296diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
14297index 9279e0b..c4b3d2c 100644
14298--- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
14299+++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
14300@@ -1,4 +1,5 @@
14301 #include <linux/linkage.h>
14302+#include <asm/alternative-asm.h>
14303
14304 # enter salsa20_encrypt_bytes
14305 ENTRY(salsa20_encrypt_bytes)
14306@@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
14307 add %r11,%rsp
14308 mov %rdi,%rax
14309 mov %rsi,%rdx
14310+ pax_force_retaddr
14311 ret
14312 # bytesatleast65:
14313 ._bytesatleast65:
14314@@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
14315 add %r11,%rsp
14316 mov %rdi,%rax
14317 mov %rsi,%rdx
14318+ pax_force_retaddr
14319 ret
14320 ENDPROC(salsa20_keysetup)
14321
14322@@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
14323 add %r11,%rsp
14324 mov %rdi,%rax
14325 mov %rsi,%rdx
14326+ pax_force_retaddr
14327 ret
14328 ENDPROC(salsa20_ivsetup)
14329diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
14330index 2f202f4..d9164d6 100644
14331--- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
14332+++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
14333@@ -24,6 +24,7 @@
14334 */
14335
14336 #include <linux/linkage.h>
14337+#include <asm/alternative-asm.h>
14338 #include "glue_helper-asm-avx.S"
14339
14340 .file "serpent-avx-x86_64-asm_64.S"
14341@@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
14342 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14343 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14344
14345+ pax_force_retaddr
14346 ret;
14347 ENDPROC(__serpent_enc_blk8_avx)
14348
14349@@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
14350 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
14351 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
14352
14353+ pax_force_retaddr
14354 ret;
14355 ENDPROC(__serpent_dec_blk8_avx)
14356
14357@@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
14358
14359 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14360
14361+ pax_force_retaddr
14362 ret;
14363 ENDPROC(serpent_ecb_enc_8way_avx)
14364
14365@@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
14366
14367 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
14368
14369+ pax_force_retaddr
14370 ret;
14371 ENDPROC(serpent_ecb_dec_8way_avx)
14372
14373@@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
14374
14375 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
14376
14377+ pax_force_retaddr
14378 ret;
14379 ENDPROC(serpent_cbc_dec_8way_avx)
14380
14381@@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
14382
14383 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14384
14385+ pax_force_retaddr
14386 ret;
14387 ENDPROC(serpent_ctr_8way_avx)
14388
14389@@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
14390 /* dst <= regs xor IVs(in dst) */
14391 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14392
14393+ pax_force_retaddr
14394 ret;
14395 ENDPROC(serpent_xts_enc_8way_avx)
14396
14397@@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
14398 /* dst <= regs xor IVs(in dst) */
14399 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
14400
14401+ pax_force_retaddr
14402 ret;
14403 ENDPROC(serpent_xts_dec_8way_avx)
14404diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
14405index b222085..abd483c 100644
14406--- a/arch/x86/crypto/serpent-avx2-asm_64.S
14407+++ b/arch/x86/crypto/serpent-avx2-asm_64.S
14408@@ -15,6 +15,7 @@
14409 */
14410
14411 #include <linux/linkage.h>
14412+#include <asm/alternative-asm.h>
14413 #include "glue_helper-asm-avx2.S"
14414
14415 .file "serpent-avx2-asm_64.S"
14416@@ -610,6 +611,7 @@ __serpent_enc_blk16:
14417 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14418 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14419
14420+ pax_force_retaddr
14421 ret;
14422 ENDPROC(__serpent_enc_blk16)
14423
14424@@ -664,6 +666,7 @@ __serpent_dec_blk16:
14425 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
14426 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
14427
14428+ pax_force_retaddr
14429 ret;
14430 ENDPROC(__serpent_dec_blk16)
14431
14432@@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
14433
14434 vzeroupper;
14435
14436+ pax_force_retaddr
14437 ret;
14438 ENDPROC(serpent_ecb_enc_16way)
14439
14440@@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
14441
14442 vzeroupper;
14443
14444+ pax_force_retaddr
14445 ret;
14446 ENDPROC(serpent_ecb_dec_16way)
14447
14448@@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
14449
14450 vzeroupper;
14451
14452+ pax_force_retaddr
14453 ret;
14454 ENDPROC(serpent_cbc_dec_16way)
14455
14456@@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
14457
14458 vzeroupper;
14459
14460+ pax_force_retaddr
14461 ret;
14462 ENDPROC(serpent_ctr_16way)
14463
14464@@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
14465
14466 vzeroupper;
14467
14468+ pax_force_retaddr
14469 ret;
14470 ENDPROC(serpent_xts_enc_16way)
14471
14472@@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
14473
14474 vzeroupper;
14475
14476+ pax_force_retaddr
14477 ret;
14478 ENDPROC(serpent_xts_dec_16way)
14479diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
14480index acc066c..1559cc4 100644
14481--- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
14482+++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
14483@@ -25,6 +25,7 @@
14484 */
14485
14486 #include <linux/linkage.h>
14487+#include <asm/alternative-asm.h>
14488
14489 .file "serpent-sse2-x86_64-asm_64.S"
14490 .text
14491@@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
14492 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14493 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14494
14495+ pax_force_retaddr
14496 ret;
14497
14498 .L__enc_xor8:
14499 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14500 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14501
14502+ pax_force_retaddr
14503 ret;
14504 ENDPROC(__serpent_enc_blk_8way)
14505
14506@@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
14507 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
14508 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
14509
14510+ pax_force_retaddr
14511 ret;
14512 ENDPROC(serpent_dec_blk_8way)
14513diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
14514index a410950..9dfe7ad 100644
14515--- a/arch/x86/crypto/sha1_ssse3_asm.S
14516+++ b/arch/x86/crypto/sha1_ssse3_asm.S
14517@@ -29,6 +29,7 @@
14518 */
14519
14520 #include <linux/linkage.h>
14521+#include <asm/alternative-asm.h>
14522
14523 #define CTX %rdi // arg1
14524 #define BUF %rsi // arg2
14525@@ -75,9 +76,9 @@
14526
14527 push %rbx
14528 push %rbp
14529- push %r12
14530+ push %r14
14531
14532- mov %rsp, %r12
14533+ mov %rsp, %r14
14534 sub $64, %rsp # allocate workspace
14535 and $~15, %rsp # align stack
14536
14537@@ -99,11 +100,12 @@
14538 xor %rax, %rax
14539 rep stosq
14540
14541- mov %r12, %rsp # deallocate workspace
14542+ mov %r14, %rsp # deallocate workspace
14543
14544- pop %r12
14545+ pop %r14
14546 pop %rbp
14547 pop %rbx
14548+ pax_force_retaddr
14549 ret
14550
14551 ENDPROC(\name)
14552diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
14553index 92b3b5d..0dc1dcb 100644
14554--- a/arch/x86/crypto/sha256-avx-asm.S
14555+++ b/arch/x86/crypto/sha256-avx-asm.S
14556@@ -49,6 +49,7 @@
14557
14558 #ifdef CONFIG_AS_AVX
14559 #include <linux/linkage.h>
14560+#include <asm/alternative-asm.h>
14561
14562 ## assume buffers not aligned
14563 #define VMOVDQ vmovdqu
14564@@ -460,6 +461,7 @@ done_hash:
14565 popq %r13
14566 popq %rbp
14567 popq %rbx
14568+ pax_force_retaddr
14569 ret
14570 ENDPROC(sha256_transform_avx)
14571
14572diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
14573index 570ec5e..cf2b625 100644
14574--- a/arch/x86/crypto/sha256-avx2-asm.S
14575+++ b/arch/x86/crypto/sha256-avx2-asm.S
14576@@ -50,6 +50,7 @@
14577
14578 #ifdef CONFIG_AS_AVX2
14579 #include <linux/linkage.h>
14580+#include <asm/alternative-asm.h>
14581
14582 ## assume buffers not aligned
14583 #define VMOVDQ vmovdqu
14584@@ -720,6 +721,7 @@ done_hash:
14585 popq %r12
14586 popq %rbp
14587 popq %rbx
14588+ pax_force_retaddr
14589 ret
14590 ENDPROC(sha256_transform_rorx)
14591
14592diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
14593index 2cedc44..5144899 100644
14594--- a/arch/x86/crypto/sha256-ssse3-asm.S
14595+++ b/arch/x86/crypto/sha256-ssse3-asm.S
14596@@ -47,6 +47,7 @@
14597 ########################################################################
14598
14599 #include <linux/linkage.h>
14600+#include <asm/alternative-asm.h>
14601
14602 ## assume buffers not aligned
14603 #define MOVDQ movdqu
14604@@ -471,6 +472,7 @@ done_hash:
14605 popq %rbp
14606 popq %rbx
14607
14608+ pax_force_retaddr
14609 ret
14610 ENDPROC(sha256_transform_ssse3)
14611
14612diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
14613index 565274d..af6bc08 100644
14614--- a/arch/x86/crypto/sha512-avx-asm.S
14615+++ b/arch/x86/crypto/sha512-avx-asm.S
14616@@ -49,6 +49,7 @@
14617
14618 #ifdef CONFIG_AS_AVX
14619 #include <linux/linkage.h>
14620+#include <asm/alternative-asm.h>
14621
14622 .text
14623
14624@@ -364,6 +365,7 @@ updateblock:
14625 mov frame_RSPSAVE(%rsp), %rsp
14626
14627 nowork:
14628+ pax_force_retaddr
14629 ret
14630 ENDPROC(sha512_transform_avx)
14631
14632diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
14633index 1f20b35..f25c8c1 100644
14634--- a/arch/x86/crypto/sha512-avx2-asm.S
14635+++ b/arch/x86/crypto/sha512-avx2-asm.S
14636@@ -51,6 +51,7 @@
14637
14638 #ifdef CONFIG_AS_AVX2
14639 #include <linux/linkage.h>
14640+#include <asm/alternative-asm.h>
14641
14642 .text
14643
14644@@ -678,6 +679,7 @@ done_hash:
14645
14646 # Restore Stack Pointer
14647 mov frame_RSPSAVE(%rsp), %rsp
14648+ pax_force_retaddr
14649 ret
14650 ENDPROC(sha512_transform_rorx)
14651
14652diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
14653index e610e29..ffcb5ed 100644
14654--- a/arch/x86/crypto/sha512-ssse3-asm.S
14655+++ b/arch/x86/crypto/sha512-ssse3-asm.S
14656@@ -48,6 +48,7 @@
14657 ########################################################################
14658
14659 #include <linux/linkage.h>
14660+#include <asm/alternative-asm.h>
14661
14662 .text
14663
14664@@ -363,6 +364,7 @@ updateblock:
14665 mov frame_RSPSAVE(%rsp), %rsp
14666
14667 nowork:
14668+ pax_force_retaddr
14669 ret
14670 ENDPROC(sha512_transform_ssse3)
14671
14672diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14673index 0505813..b067311 100644
14674--- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14675+++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14676@@ -24,6 +24,7 @@
14677 */
14678
14679 #include <linux/linkage.h>
14680+#include <asm/alternative-asm.h>
14681 #include "glue_helper-asm-avx.S"
14682
14683 .file "twofish-avx-x86_64-asm_64.S"
14684@@ -284,6 +285,7 @@ __twofish_enc_blk8:
14685 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
14686 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
14687
14688+ pax_force_retaddr
14689 ret;
14690 ENDPROC(__twofish_enc_blk8)
14691
14692@@ -324,6 +326,7 @@ __twofish_dec_blk8:
14693 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
14694 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
14695
14696+ pax_force_retaddr
14697 ret;
14698 ENDPROC(__twofish_dec_blk8)
14699
14700@@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
14701
14702 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14703
14704+ pax_force_retaddr
14705 ret;
14706 ENDPROC(twofish_ecb_enc_8way)
14707
14708@@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
14709
14710 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14711
14712+ pax_force_retaddr
14713 ret;
14714 ENDPROC(twofish_ecb_dec_8way)
14715
14716@@ -370,19 +375,20 @@ ENTRY(twofish_cbc_dec_8way)
14717 * %rdx: src
14718 */
14719
14720- pushq %r12;
14721+ pushq %r14;
14722
14723 movq %rsi, %r11;
14724- movq %rdx, %r12;
14725+ movq %rdx, %r14;
14726
14727 load_8way(%rdx, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14728
14729 call __twofish_dec_blk8;
14730
14731- store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14732+ store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14733
14734- popq %r12;
14735+ popq %r14;
14736
14737+ pax_force_retaddr
14738 ret;
14739 ENDPROC(twofish_cbc_dec_8way)
14740
14741@@ -394,20 +400,21 @@ ENTRY(twofish_ctr_8way)
14742 * %rcx: iv (little endian, 128bit)
14743 */
14744
14745- pushq %r12;
14746+ pushq %r14;
14747
14748 movq %rsi, %r11;
14749- movq %rdx, %r12;
14750+ movq %rdx, %r14;
14751
14752 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
14753 RD2, RX0, RX1, RY0);
14754
14755 call __twofish_enc_blk8;
14756
14757- store_ctr_8way(%r12, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14758+ store_ctr_8way(%r14, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14759
14760- popq %r12;
14761+ popq %r14;
14762
14763+ pax_force_retaddr
14764 ret;
14765 ENDPROC(twofish_ctr_8way)
14766
14767@@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
14768 /* dst <= regs xor IVs(in dst) */
14769 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14770
14771+ pax_force_retaddr
14772 ret;
14773 ENDPROC(twofish_xts_enc_8way)
14774
14775@@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
14776 /* dst <= regs xor IVs(in dst) */
14777 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14778
14779+ pax_force_retaddr
14780 ret;
14781 ENDPROC(twofish_xts_dec_8way)
14782diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14783index 1c3b7ce..02f578d 100644
14784--- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14785+++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14786@@ -21,6 +21,7 @@
14787 */
14788
14789 #include <linux/linkage.h>
14790+#include <asm/alternative-asm.h>
14791
14792 .file "twofish-x86_64-asm-3way.S"
14793 .text
14794@@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
14795 popq %r13;
14796 popq %r14;
14797 popq %r15;
14798+ pax_force_retaddr
14799 ret;
14800
14801 .L__enc_xor3:
14802@@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
14803 popq %r13;
14804 popq %r14;
14805 popq %r15;
14806+ pax_force_retaddr
14807 ret;
14808 ENDPROC(__twofish_enc_blk_3way)
14809
14810@@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
14811 popq %r13;
14812 popq %r14;
14813 popq %r15;
14814+ pax_force_retaddr
14815 ret;
14816 ENDPROC(twofish_dec_blk_3way)
14817diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
14818index a350c99..c1bac24 100644
14819--- a/arch/x86/crypto/twofish-x86_64-asm_64.S
14820+++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
14821@@ -22,6 +22,7 @@
14822
14823 #include <linux/linkage.h>
14824 #include <asm/asm-offsets.h>
14825+#include <asm/alternative-asm.h>
14826
14827 #define a_offset 0
14828 #define b_offset 4
14829@@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
14830
14831 popq R1
14832 movl $1,%eax
14833+ pax_force_retaddr
14834 ret
14835 ENDPROC(twofish_enc_blk)
14836
14837@@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
14838
14839 popq R1
14840 movl $1,%eax
14841+ pax_force_retaddr
14842 ret
14843 ENDPROC(twofish_dec_blk)
14844diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h
14845index f4e6308..7ba29a1 100644
14846--- a/arch/x86/entry/calling.h
14847+++ b/arch/x86/entry/calling.h
14848@@ -93,23 +93,26 @@ For 32-bit we have the following conventions - kernel is built with
14849 .endm
14850
14851 .macro SAVE_C_REGS_HELPER offset=0 rax=1 rcx=1 r8910=1 r11=1
14852+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14853+ movq %r12, R12+\offset(%rsp)
14854+#endif
14855 .if \r11
14856- movq %r11, 6*8+\offset(%rsp)
14857+ movq %r11, R11+\offset(%rsp)
14858 .endif
14859 .if \r8910
14860- movq %r10, 7*8+\offset(%rsp)
14861- movq %r9, 8*8+\offset(%rsp)
14862- movq %r8, 9*8+\offset(%rsp)
14863+ movq %r10, R10+\offset(%rsp)
14864+ movq %r9, R9+\offset(%rsp)
14865+ movq %r8, R8+\offset(%rsp)
14866 .endif
14867 .if \rax
14868- movq %rax, 10*8+\offset(%rsp)
14869+ movq %rax, RAX+\offset(%rsp)
14870 .endif
14871 .if \rcx
14872- movq %rcx, 11*8+\offset(%rsp)
14873+ movq %rcx, RCX+\offset(%rsp)
14874 .endif
14875- movq %rdx, 12*8+\offset(%rsp)
14876- movq %rsi, 13*8+\offset(%rsp)
14877- movq %rdi, 14*8+\offset(%rsp)
14878+ movq %rdx, RDX+\offset(%rsp)
14879+ movq %rsi, RSI+\offset(%rsp)
14880+ movq %rdi, RDI+\offset(%rsp)
14881 .endm
14882 .macro SAVE_C_REGS offset=0
14883 SAVE_C_REGS_HELPER \offset, 1, 1, 1, 1
14884@@ -128,76 +131,87 @@ For 32-bit we have the following conventions - kernel is built with
14885 .endm
14886
14887 .macro SAVE_EXTRA_REGS offset=0
14888- movq %r15, 0*8+\offset(%rsp)
14889- movq %r14, 1*8+\offset(%rsp)
14890- movq %r13, 2*8+\offset(%rsp)
14891- movq %r12, 3*8+\offset(%rsp)
14892- movq %rbp, 4*8+\offset(%rsp)
14893- movq %rbx, 5*8+\offset(%rsp)
14894+ movq %r15, R15+\offset(%rsp)
14895+ movq %r14, R14+\offset(%rsp)
14896+ movq %r13, R13+\offset(%rsp)
14897+#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14898+ movq %r12, R12+\offset(%rsp)
14899+#endif
14900+ movq %rbp, RBP+\offset(%rsp)
14901+ movq %rbx, RBX+\offset(%rsp)
14902 .endm
14903 .macro SAVE_EXTRA_REGS_RBP offset=0
14904- movq %rbp, 4*8+\offset(%rsp)
14905+ movq %rbp, RBP+\offset(%rsp)
14906 .endm
14907
14908 .macro RESTORE_EXTRA_REGS offset=0
14909- movq 0*8+\offset(%rsp), %r15
14910- movq 1*8+\offset(%rsp), %r14
14911- movq 2*8+\offset(%rsp), %r13
14912- movq 3*8+\offset(%rsp), %r12
14913- movq 4*8+\offset(%rsp), %rbp
14914- movq 5*8+\offset(%rsp), %rbx
14915+ movq R15+\offset(%rsp), %r15
14916+ movq R14+\offset(%rsp), %r14
14917+ movq R13+\offset(%rsp), %r13
14918+#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14919+ movq R12+\offset(%rsp), %r12
14920+#endif
14921+ movq RBP+\offset(%rsp), %rbp
14922+ movq RBX+\offset(%rsp), %rbx
14923 .endm
14924
14925 .macro ZERO_EXTRA_REGS
14926 xorl %r15d, %r15d
14927 xorl %r14d, %r14d
14928 xorl %r13d, %r13d
14929+#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14930 xorl %r12d, %r12d
14931+#endif
14932 xorl %ebp, %ebp
14933 xorl %ebx, %ebx
14934 .endm
14935
14936- .macro RESTORE_C_REGS_HELPER rstor_rax=1, rstor_rcx=1, rstor_r11=1, rstor_r8910=1, rstor_rdx=1
14937+ .macro RESTORE_C_REGS_HELPER rstor_rax=1, rstor_rcx=1, rstor_r11=1, rstor_r8910=1, rstor_rdx=1, rstor_r12=1
14938+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14939+ .if \rstor_r12
14940+ movq R12(%rsp), %r12
14941+ .endif
14942+#endif
14943 .if \rstor_r11
14944- movq 6*8(%rsp), %r11
14945+ movq R11(%rsp), %r11
14946 .endif
14947 .if \rstor_r8910
14948- movq 7*8(%rsp), %r10
14949- movq 8*8(%rsp), %r9
14950- movq 9*8(%rsp), %r8
14951+ movq R10(%rsp), %r10
14952+ movq R9(%rsp), %r9
14953+ movq R8(%rsp), %r8
14954 .endif
14955 .if \rstor_rax
14956- movq 10*8(%rsp), %rax
14957+ movq RAX(%rsp), %rax
14958 .endif
14959 .if \rstor_rcx
14960- movq 11*8(%rsp), %rcx
14961+ movq RCX(%rsp), %rcx
14962 .endif
14963 .if \rstor_rdx
14964- movq 12*8(%rsp), %rdx
14965+ movq RDX(%rsp), %rdx
14966 .endif
14967- movq 13*8(%rsp), %rsi
14968- movq 14*8(%rsp), %rdi
14969+ movq RSI(%rsp), %rsi
14970+ movq RDI(%rsp), %rdi
14971 .endm
14972 .macro RESTORE_C_REGS
14973- RESTORE_C_REGS_HELPER 1,1,1,1,1
14974+ RESTORE_C_REGS_HELPER 1,1,1,1,1,1
14975 .endm
14976 .macro RESTORE_C_REGS_EXCEPT_RAX
14977- RESTORE_C_REGS_HELPER 0,1,1,1,1
14978+ RESTORE_C_REGS_HELPER 0,1,1,1,1,0
14979 .endm
14980 .macro RESTORE_C_REGS_EXCEPT_RCX
14981- RESTORE_C_REGS_HELPER 1,0,1,1,1
14982+ RESTORE_C_REGS_HELPER 1,0,1,1,1,0
14983 .endm
14984 .macro RESTORE_C_REGS_EXCEPT_R11
14985- RESTORE_C_REGS_HELPER 1,1,0,1,1
14986+ RESTORE_C_REGS_HELPER 1,1,0,1,1,1
14987 .endm
14988 .macro RESTORE_C_REGS_EXCEPT_RCX_R11
14989- RESTORE_C_REGS_HELPER 1,0,0,1,1
14990+ RESTORE_C_REGS_HELPER 1,0,0,1,1,1
14991 .endm
14992 .macro RESTORE_RSI_RDI
14993- RESTORE_C_REGS_HELPER 0,0,0,0,0
14994+ RESTORE_C_REGS_HELPER 0,0,0,0,0,1
14995 .endm
14996 .macro RESTORE_RSI_RDI_RDX
14997- RESTORE_C_REGS_HELPER 0,0,0,0,1
14998+ RESTORE_C_REGS_HELPER 0,0,0,0,1,1
14999 .endm
15000
15001 .macro REMOVE_PT_GPREGS_FROM_STACK addskip=0
15002diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
15003index 21dc60a..844def1 100644
15004--- a/arch/x86/entry/entry_32.S
15005+++ b/arch/x86/entry/entry_32.S
15006@@ -157,13 +157,154 @@
15007 movl \reg, PT_GS(%esp)
15008 .endm
15009 .macro SET_KERNEL_GS reg
15010+
15011+#ifdef CONFIG_CC_STACKPROTECTOR
15012 movl $(__KERNEL_STACK_CANARY), \reg
15013+#elif defined(CONFIG_PAX_MEMORY_UDEREF)
15014+ movl $(__USER_DS), \reg
15015+#else
15016+ xorl \reg, \reg
15017+#endif
15018+
15019 movl \reg, %gs
15020 .endm
15021
15022 #endif /* CONFIG_X86_32_LAZY_GS */
15023
15024-.macro SAVE_ALL
15025+.macro pax_enter_kernel
15026+#ifdef CONFIG_PAX_KERNEXEC
15027+ call pax_enter_kernel
15028+#endif
15029+.endm
15030+
15031+.macro pax_exit_kernel
15032+#ifdef CONFIG_PAX_KERNEXEC
15033+ call pax_exit_kernel
15034+#endif
15035+.endm
15036+
15037+#ifdef CONFIG_PAX_KERNEXEC
15038+ENTRY(pax_enter_kernel)
15039+#ifdef CONFIG_PARAVIRT
15040+ pushl %eax
15041+ pushl %ecx
15042+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
15043+ mov %eax, %esi
15044+#else
15045+ mov %cr0, %esi
15046+#endif
15047+ bts $X86_CR0_WP_BIT, %esi
15048+ jnc 1f
15049+ mov %cs, %esi
15050+ cmp $__KERNEL_CS, %esi
15051+ jz 3f
15052+ ljmp $__KERNEL_CS, $3f
15053+1: ljmp $__KERNEXEC_KERNEL_CS, $2f
15054+2:
15055+#ifdef CONFIG_PARAVIRT
15056+ mov %esi, %eax
15057+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
15058+#else
15059+ mov %esi, %cr0
15060+#endif
15061+3:
15062+#ifdef CONFIG_PARAVIRT
15063+ popl %ecx
15064+ popl %eax
15065+#endif
15066+ ret
15067+ENDPROC(pax_enter_kernel)
15068+
15069+ENTRY(pax_exit_kernel)
15070+#ifdef CONFIG_PARAVIRT
15071+ pushl %eax
15072+ pushl %ecx
15073+#endif
15074+ mov %cs, %esi
15075+ cmp $__KERNEXEC_KERNEL_CS, %esi
15076+ jnz 2f
15077+#ifdef CONFIG_PARAVIRT
15078+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
15079+ mov %eax, %esi
15080+#else
15081+ mov %cr0, %esi
15082+#endif
15083+ btr $X86_CR0_WP_BIT, %esi
15084+ ljmp $__KERNEL_CS, $1f
15085+1:
15086+#ifdef CONFIG_PARAVIRT
15087+ mov %esi, %eax
15088+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
15089+#else
15090+ mov %esi, %cr0
15091+#endif
15092+2:
15093+#ifdef CONFIG_PARAVIRT
15094+ popl %ecx
15095+ popl %eax
15096+#endif
15097+ ret
15098+ENDPROC(pax_exit_kernel)
15099+#endif
15100+
15101+ .macro pax_erase_kstack
15102+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
15103+ call pax_erase_kstack
15104+#endif
15105+ .endm
15106+
15107+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
15108+/*
15109+ * ebp: thread_info
15110+ */
15111+ENTRY(pax_erase_kstack)
15112+ pushl %edi
15113+ pushl %ecx
15114+ pushl %eax
15115+
15116+ mov TI_lowest_stack(%ebp), %edi
15117+ mov $-0xBEEF, %eax
15118+ std
15119+
15120+1: mov %edi, %ecx
15121+ and $THREAD_SIZE_asm - 1, %ecx
15122+ shr $2, %ecx
15123+ repne scasl
15124+ jecxz 2f
15125+
15126+ cmp $2*16, %ecx
15127+ jc 2f
15128+
15129+ mov $2*16, %ecx
15130+ repe scasl
15131+ jecxz 2f
15132+ jne 1b
15133+
15134+2: cld
15135+ or $2*4, %edi
15136+ mov %esp, %ecx
15137+ sub %edi, %ecx
15138+
15139+ cmp $THREAD_SIZE_asm, %ecx
15140+ jb 3f
15141+ ud2
15142+3:
15143+
15144+ shr $2, %ecx
15145+ rep stosl
15146+
15147+ mov TI_task_thread_sp0(%ebp), %edi
15148+ sub $128, %edi
15149+ mov %edi, TI_lowest_stack(%ebp)
15150+
15151+ popl %eax
15152+ popl %ecx
15153+ popl %edi
15154+ ret
15155+ENDPROC(pax_erase_kstack)
15156+#endif
15157+
15158+.macro __SAVE_ALL _DS
15159 cld
15160 PUSH_GS
15161 pushl %fs
15162@@ -176,7 +317,7 @@
15163 pushl %edx
15164 pushl %ecx
15165 pushl %ebx
15166- movl $(__USER_DS), %edx
15167+ movl $\_DS, %edx
15168 movl %edx, %ds
15169 movl %edx, %es
15170 movl $(__KERNEL_PERCPU), %edx
15171@@ -184,6 +325,15 @@
15172 SET_KERNEL_GS %edx
15173 .endm
15174
15175+.macro SAVE_ALL
15176+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15177+ __SAVE_ALL __KERNEL_DS
15178+ pax_enter_kernel
15179+#else
15180+ __SAVE_ALL __USER_DS
15181+#endif
15182+.endm
15183+
15184 .macro RESTORE_INT_REGS
15185 popl %ebx
15186 popl %ecx
15187@@ -222,7 +372,7 @@ ENTRY(ret_from_fork)
15188 pushl $0x0202 # Reset kernel eflags
15189 popfl
15190 jmp syscall_exit
15191-END(ret_from_fork)
15192+ENDPROC(ret_from_fork)
15193
15194 ENTRY(ret_from_kernel_thread)
15195 pushl %eax
15196@@ -262,7 +412,15 @@ ret_from_intr:
15197 andl $SEGMENT_RPL_MASK, %eax
15198 #endif
15199 cmpl $USER_RPL, %eax
15200+
15201+#ifdef CONFIG_PAX_KERNEXEC
15202+ jae resume_userspace
15203+
15204+ pax_exit_kernel
15205+ jmp resume_kernel
15206+#else
15207 jb resume_kernel # not returning to v8086 or userspace
15208+#endif
15209
15210 ENTRY(resume_userspace)
15211 LOCKDEP_SYS_EXIT
15212@@ -274,8 +432,8 @@ ENTRY(resume_userspace)
15213 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
15214 # int/exception return?
15215 jne work_pending
15216- jmp restore_all
15217-END(ret_from_exception)
15218+ jmp restore_all_pax
15219+ENDPROC(ret_from_exception)
15220
15221 #ifdef CONFIG_PREEMPT
15222 ENTRY(resume_kernel)
15223@@ -287,7 +445,7 @@ need_resched:
15224 jz restore_all
15225 call preempt_schedule_irq
15226 jmp need_resched
15227-END(resume_kernel)
15228+ENDPROC(resume_kernel)
15229 #endif
15230
15231 /*
15232@@ -312,32 +470,44 @@ sysenter_past_esp:
15233 pushl $__USER_CS
15234 /*
15235 * Push current_thread_info()->sysenter_return to the stack.
15236- * A tiny bit of offset fixup is necessary: TI_sysenter_return
15237- * is relative to thread_info, which is at the bottom of the
15238- * kernel stack page. 4*4 means the 4 words pushed above;
15239- * TOP_OF_KERNEL_STACK_PADDING takes us to the top of the stack;
15240- * and THREAD_SIZE takes us to the bottom.
15241 */
15242- pushl ((TI_sysenter_return) - THREAD_SIZE + TOP_OF_KERNEL_STACK_PADDING + 4*4)(%esp)
15243+ pushl $0
15244
15245 pushl %eax
15246 SAVE_ALL
15247+ GET_THREAD_INFO(%ebp)
15248+ movl TI_sysenter_return(%ebp), %ebp
15249+ movl %ebp, PT_EIP(%esp)
15250 ENABLE_INTERRUPTS(CLBR_NONE)
15251
15252 /*
15253 * Load the potential sixth argument from user stack.
15254 * Careful about security.
15255 */
15256+ movl PT_OLDESP(%esp),%ebp
15257+
15258+#ifdef CONFIG_PAX_MEMORY_UDEREF
15259+ mov PT_OLDSS(%esp), %ds
15260+1: movl %ds:(%ebp), %ebp
15261+ push %ss
15262+ pop %ds
15263+#else
15264 cmpl $__PAGE_OFFSET-3, %ebp
15265 jae syscall_fault
15266 ASM_STAC
15267 1: movl (%ebp), %ebp
15268 ASM_CLAC
15269+#endif
15270+
15271 movl %ebp, PT_EBP(%esp)
15272 _ASM_EXTABLE(1b, syscall_fault)
15273
15274 GET_THREAD_INFO(%ebp)
15275
15276+#ifdef CONFIG_PAX_RANDKSTACK
15277+ pax_erase_kstack
15278+#endif
15279+
15280 testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%ebp)
15281 jnz sysenter_audit
15282 sysenter_do_call:
15283@@ -353,12 +523,24 @@ sysenter_after_call:
15284 testl $_TIF_ALLWORK_MASK, %ecx
15285 jnz sysexit_audit
15286 sysenter_exit:
15287+
15288+#ifdef CONFIG_PAX_RANDKSTACK
15289+ pushl %eax
15290+ movl %esp, %eax
15291+ call pax_randomize_kstack
15292+ popl %eax
15293+#endif
15294+
15295+ pax_erase_kstack
15296+
15297 /* if something modifies registers it must also disable sysexit */
15298 movl PT_EIP(%esp), %edx
15299 movl PT_OLDESP(%esp), %ecx
15300 xorl %ebp, %ebp
15301 TRACE_IRQS_ON
15302 1: mov PT_FS(%esp), %fs
15303+2: mov PT_DS(%esp), %ds
15304+3: mov PT_ES(%esp), %es
15305 PTGS_TO_GS
15306 ENABLE_INTERRUPTS_SYSEXIT
15307
15308@@ -372,6 +554,9 @@ sysenter_audit:
15309 pushl PT_ESI(%esp) /* a3: 5th arg */
15310 pushl PT_EDX+4(%esp) /* a2: 4th arg */
15311 call __audit_syscall_entry
15312+
15313+ pax_erase_kstack
15314+
15315 popl %ecx /* get that remapped edx off the stack */
15316 popl %ecx /* get that remapped esi off the stack */
15317 movl PT_EAX(%esp), %eax /* reload syscall number */
15318@@ -397,10 +582,16 @@ sysexit_audit:
15319 #endif
15320
15321 .pushsection .fixup, "ax"
15322-2: movl $0, PT_FS(%esp)
15323+4: movl $0, PT_FS(%esp)
15324+ jmp 1b
15325+5: movl $0, PT_DS(%esp)
15326+ jmp 1b
15327+6: movl $0, PT_ES(%esp)
15328 jmp 1b
15329 .popsection
15330- _ASM_EXTABLE(1b, 2b)
15331+ _ASM_EXTABLE(1b, 4b)
15332+ _ASM_EXTABLE(2b, 5b)
15333+ _ASM_EXTABLE(3b, 6b)
15334 PTGS_TO_GS_EX
15335 ENDPROC(entry_SYSENTER_32)
15336
15337@@ -410,6 +601,11 @@ ENTRY(entry_INT80_32)
15338 pushl %eax # save orig_eax
15339 SAVE_ALL
15340 GET_THREAD_INFO(%ebp)
15341+
15342+#ifdef CONFIG_PAX_RANDKSTACK
15343+ pax_erase_kstack
15344+#endif
15345+
15346 # system call tracing in operation / emulation
15347 testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%ebp)
15348 jnz syscall_trace_entry
15349@@ -429,6 +625,15 @@ syscall_exit:
15350 testl $_TIF_ALLWORK_MASK, %ecx # current->work
15351 jnz syscall_exit_work
15352
15353+restore_all_pax:
15354+
15355+#ifdef CONFIG_PAX_RANDKSTACK
15356+ movl %esp, %eax
15357+ call pax_randomize_kstack
15358+#endif
15359+
15360+ pax_erase_kstack
15361+
15362 restore_all:
15363 TRACE_IRQS_IRET
15364 restore_all_notrace:
15365@@ -483,14 +688,34 @@ ldt_ss:
15366 * compensating for the offset by changing to the ESPFIX segment with
15367 * a base address that matches for the difference.
15368 */
15369-#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
15370+#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
15371 mov %esp, %edx /* load kernel esp */
15372 mov PT_OLDESP(%esp), %eax /* load userspace esp */
15373 mov %dx, %ax /* eax: new kernel esp */
15374 sub %eax, %edx /* offset (low word is 0) */
15375+#ifdef CONFIG_SMP
15376+ movl PER_CPU_VAR(cpu_number), %ebx
15377+ shll $PAGE_SHIFT_asm, %ebx
15378+ addl $cpu_gdt_table, %ebx
15379+#else
15380+ movl $cpu_gdt_table, %ebx
15381+#endif
15382 shr $16, %edx
15383- mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
15384- mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
15385+
15386+#ifdef CONFIG_PAX_KERNEXEC
15387+ mov %cr0, %esi
15388+ btr $X86_CR0_WP_BIT, %esi
15389+ mov %esi, %cr0
15390+#endif
15391+
15392+ mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
15393+ mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
15394+
15395+#ifdef CONFIG_PAX_KERNEXEC
15396+ bts $X86_CR0_WP_BIT, %esi
15397+ mov %esi, %cr0
15398+#endif
15399+
15400 pushl $__ESPFIX_SS
15401 pushl %eax /* new kernel esp */
15402 /*
15403@@ -519,20 +744,18 @@ work_resched:
15404 movl TI_flags(%ebp), %ecx
15405 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
15406 # than syscall tracing?
15407- jz restore_all
15408+ jz restore_all_pax
15409 testb $_TIF_NEED_RESCHED, %cl
15410 jnz work_resched
15411
15412 work_notifysig: # deal with pending signals and
15413 # notify-resume requests
15414+ movl %esp, %eax
15415 #ifdef CONFIG_VM86
15416 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
15417- movl %esp, %eax
15418 jnz work_notifysig_v86 # returning to kernel-space or
15419 # vm86-space
15420 1:
15421-#else
15422- movl %esp, %eax
15423 #endif
15424 TRACE_IRQS_ON
15425 ENABLE_INTERRUPTS(CLBR_NONE)
15426@@ -553,7 +776,7 @@ work_notifysig_v86:
15427 movl %eax, %esp
15428 jmp 1b
15429 #endif
15430-END(work_pending)
15431+ENDPROC(work_pending)
15432
15433 # perform syscall exit tracing
15434 ALIGN
15435@@ -561,11 +784,14 @@ syscall_trace_entry:
15436 movl $-ENOSYS, PT_EAX(%esp)
15437 movl %esp, %eax
15438 call syscall_trace_enter
15439+
15440+ pax_erase_kstack
15441+
15442 /* What it returned is what we'll actually use. */
15443 cmpl $(NR_syscalls), %eax
15444 jnae syscall_call
15445 jmp syscall_exit
15446-END(syscall_trace_entry)
15447+ENDPROC(syscall_trace_entry)
15448
15449 # perform syscall exit tracing
15450 ALIGN
15451@@ -578,24 +804,28 @@ syscall_exit_work:
15452 movl %esp, %eax
15453 call syscall_trace_leave
15454 jmp resume_userspace
15455-END(syscall_exit_work)
15456+ENDPROC(syscall_exit_work)
15457
15458 syscall_fault:
15459+#ifdef CONFIG_PAX_MEMORY_UDEREF
15460+ push %ss
15461+ pop %ds
15462+#endif
15463 ASM_CLAC
15464 GET_THREAD_INFO(%ebp)
15465 movl $-EFAULT, PT_EAX(%esp)
15466 jmp resume_userspace
15467-END(syscall_fault)
15468+ENDPROC(syscall_fault)
15469
15470 syscall_badsys:
15471 movl $-ENOSYS, %eax
15472 jmp syscall_after_call
15473-END(syscall_badsys)
15474+ENDPROC(syscall_badsys)
15475
15476 sysenter_badsys:
15477 movl $-ENOSYS, %eax
15478 jmp sysenter_after_call
15479-END(sysenter_badsys)
15480+ENDPROC(sysenter_badsys)
15481
15482 .macro FIXUP_ESPFIX_STACK
15483 /*
15484@@ -607,8 +837,15 @@ END(sysenter_badsys)
15485 */
15486 #ifdef CONFIG_X86_ESPFIX32
15487 /* fixup the stack */
15488- mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
15489- mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
15490+#ifdef CONFIG_SMP
15491+ movl PER_CPU_VAR(cpu_number), %ebx
15492+ shll $PAGE_SHIFT_asm, %ebx
15493+ addl $cpu_gdt_table, %ebx
15494+#else
15495+ movl $cpu_gdt_table, %ebx
15496+#endif
15497+ mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
15498+ mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
15499 shl $16, %eax
15500 addl %esp, %eax /* the adjusted stack pointer */
15501 pushl $__KERNEL_DS
15502@@ -644,7 +881,7 @@ ENTRY(irq_entries_start)
15503 jmp common_interrupt
15504 .align 8
15505 .endr
15506-END(irq_entries_start)
15507+ENDPROC(irq_entries_start)
15508
15509 /*
15510 * the CPU automatically disables interrupts when executing an IRQ vector,
15511@@ -691,7 +928,7 @@ ENTRY(coprocessor_error)
15512 pushl $0
15513 pushl $do_coprocessor_error
15514 jmp error_code
15515-END(coprocessor_error)
15516+ENDPROC(coprocessor_error)
15517
15518 ENTRY(simd_coprocessor_error)
15519 ASM_CLAC
15520@@ -705,25 +942,25 @@ ENTRY(simd_coprocessor_error)
15521 pushl $do_simd_coprocessor_error
15522 #endif
15523 jmp error_code
15524-END(simd_coprocessor_error)
15525+ENDPROC(simd_coprocessor_error)
15526
15527 ENTRY(device_not_available)
15528 ASM_CLAC
15529 pushl $-1 # mark this as an int
15530 pushl $do_device_not_available
15531 jmp error_code
15532-END(device_not_available)
15533+ENDPROC(device_not_available)
15534
15535 #ifdef CONFIG_PARAVIRT
15536 ENTRY(native_iret)
15537 iret
15538 _ASM_EXTABLE(native_iret, iret_exc)
15539-END(native_iret)
15540+ENDPROC(native_iret)
15541
15542 ENTRY(native_irq_enable_sysexit)
15543 sti
15544 sysexit
15545-END(native_irq_enable_sysexit)
15546+ENDPROC(native_irq_enable_sysexit)
15547 #endif
15548
15549 ENTRY(overflow)
15550@@ -731,59 +968,59 @@ ENTRY(overflow)
15551 pushl $0
15552 pushl $do_overflow
15553 jmp error_code
15554-END(overflow)
15555+ENDPROC(overflow)
15556
15557 ENTRY(bounds)
15558 ASM_CLAC
15559 pushl $0
15560 pushl $do_bounds
15561 jmp error_code
15562-END(bounds)
15563+ENDPROC(bounds)
15564
15565 ENTRY(invalid_op)
15566 ASM_CLAC
15567 pushl $0
15568 pushl $do_invalid_op
15569 jmp error_code
15570-END(invalid_op)
15571+ENDPROC(invalid_op)
15572
15573 ENTRY(coprocessor_segment_overrun)
15574 ASM_CLAC
15575 pushl $0
15576 pushl $do_coprocessor_segment_overrun
15577 jmp error_code
15578-END(coprocessor_segment_overrun)
15579+ENDPROC(coprocessor_segment_overrun)
15580
15581 ENTRY(invalid_TSS)
15582 ASM_CLAC
15583 pushl $do_invalid_TSS
15584 jmp error_code
15585-END(invalid_TSS)
15586+ENDPROC(invalid_TSS)
15587
15588 ENTRY(segment_not_present)
15589 ASM_CLAC
15590 pushl $do_segment_not_present
15591 jmp error_code
15592-END(segment_not_present)
15593+ENDPROC(segment_not_present)
15594
15595 ENTRY(stack_segment)
15596 ASM_CLAC
15597 pushl $do_stack_segment
15598 jmp error_code
15599-END(stack_segment)
15600+ENDPROC(stack_segment)
15601
15602 ENTRY(alignment_check)
15603 ASM_CLAC
15604 pushl $do_alignment_check
15605 jmp error_code
15606-END(alignment_check)
15607+ENDPROC(alignment_check)
15608
15609 ENTRY(divide_error)
15610 ASM_CLAC
15611 pushl $0 # no error code
15612 pushl $do_divide_error
15613 jmp error_code
15614-END(divide_error)
15615+ENDPROC(divide_error)
15616
15617 #ifdef CONFIG_X86_MCE
15618 ENTRY(machine_check)
15619@@ -791,7 +1028,7 @@ ENTRY(machine_check)
15620 pushl $0
15621 pushl machine_check_vector
15622 jmp error_code
15623-END(machine_check)
15624+ENDPROC(machine_check)
15625 #endif
15626
15627 ENTRY(spurious_interrupt_bug)
15628@@ -799,7 +1036,7 @@ ENTRY(spurious_interrupt_bug)
15629 pushl $0
15630 pushl $do_spurious_interrupt_bug
15631 jmp error_code
15632-END(spurious_interrupt_bug)
15633+ENDPROC(spurious_interrupt_bug)
15634
15635 #ifdef CONFIG_XEN
15636 /*
15637@@ -906,7 +1143,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
15638
15639 ENTRY(mcount)
15640 ret
15641-END(mcount)
15642+ENDPROC(mcount)
15643
15644 ENTRY(ftrace_caller)
15645 pushl %eax
15646@@ -936,7 +1173,7 @@ ftrace_graph_call:
15647 .globl ftrace_stub
15648 ftrace_stub:
15649 ret
15650-END(ftrace_caller)
15651+ENDPROC(ftrace_caller)
15652
15653 ENTRY(ftrace_regs_caller)
15654 pushf /* push flags before compare (in cs location) */
15655@@ -1034,7 +1271,7 @@ trace:
15656 popl %ecx
15657 popl %eax
15658 jmp ftrace_stub
15659-END(mcount)
15660+ENDPROC(mcount)
15661 #endif /* CONFIG_DYNAMIC_FTRACE */
15662 #endif /* CONFIG_FUNCTION_TRACER */
15663
15664@@ -1052,7 +1289,7 @@ ENTRY(ftrace_graph_caller)
15665 popl %ecx
15666 popl %eax
15667 ret
15668-END(ftrace_graph_caller)
15669+ENDPROC(ftrace_graph_caller)
15670
15671 .globl return_to_handler
15672 return_to_handler:
15673@@ -1100,14 +1337,17 @@ error_code:
15674 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
15675 REG_TO_PTGS %ecx
15676 SET_KERNEL_GS %ecx
15677- movl $(__USER_DS), %ecx
15678+ movl $(__KERNEL_DS), %ecx
15679 movl %ecx, %ds
15680 movl %ecx, %es
15681+
15682+ pax_enter_kernel
15683+
15684 TRACE_IRQS_OFF
15685 movl %esp, %eax # pt_regs pointer
15686 call *%edi
15687 jmp ret_from_exception
15688-END(page_fault)
15689+ENDPROC(page_fault)
15690
15691 /*
15692 * Debug traps and NMI can happen at the one SYSENTER instruction
15693@@ -1145,7 +1385,7 @@ debug_stack_correct:
15694 movl %esp, %eax # pt_regs pointer
15695 call do_debug
15696 jmp ret_from_exception
15697-END(debug)
15698+ENDPROC(debug)
15699
15700 /*
15701 * NMI is doubly nasty. It can happen _while_ we're handling
15702@@ -1184,6 +1424,9 @@ nmi_stack_correct:
15703 xorl %edx, %edx # zero error code
15704 movl %esp, %eax # pt_regs pointer
15705 call do_nmi
15706+
15707+ pax_exit_kernel
15708+
15709 jmp restore_all_notrace
15710
15711 nmi_stack_fixup:
15712@@ -1217,11 +1460,14 @@ nmi_espfix_stack:
15713 FIXUP_ESPFIX_STACK # %eax == %esp
15714 xorl %edx, %edx # zero error code
15715 call do_nmi
15716+
15717+ pax_exit_kernel
15718+
15719 RESTORE_REGS
15720 lss 12+4(%esp), %esp # back to espfix stack
15721 jmp irq_return
15722 #endif
15723-END(nmi)
15724+ENDPROC(nmi)
15725
15726 ENTRY(int3)
15727 ASM_CLAC
15728@@ -1232,17 +1478,17 @@ ENTRY(int3)
15729 movl %esp, %eax # pt_regs pointer
15730 call do_int3
15731 jmp ret_from_exception
15732-END(int3)
15733+ENDPROC(int3)
15734
15735 ENTRY(general_protection)
15736 pushl $do_general_protection
15737 jmp error_code
15738-END(general_protection)
15739+ENDPROC(general_protection)
15740
15741 #ifdef CONFIG_KVM_GUEST
15742 ENTRY(async_page_fault)
15743 ASM_CLAC
15744 pushl $do_async_page_fault
15745 jmp error_code
15746-END(async_page_fault)
15747+ENDPROC(async_page_fault)
15748 #endif
15749diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
15750index d330840..4f1925e 100644
15751--- a/arch/x86/entry/entry_64.S
15752+++ b/arch/x86/entry/entry_64.S
15753@@ -37,6 +37,8 @@
15754 #include <asm/smap.h>
15755 #include <asm/pgtable_types.h>
15756 #include <linux/err.h>
15757+#include <asm/pgtable.h>
15758+#include <asm/alternative-asm.h>
15759
15760 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
15761 #include <linux/elf-em.h>
15762@@ -54,6 +56,402 @@ ENTRY(native_usergs_sysret64)
15763 ENDPROC(native_usergs_sysret64)
15764 #endif /* CONFIG_PARAVIRT */
15765
15766+ .macro ljmpq sel, off
15767+#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
15768+ .byte 0x48; ljmp *1234f(%rip)
15769+ .pushsection .rodata
15770+ .align 16
15771+ 1234: .quad \off; .word \sel
15772+ .popsection
15773+#else
15774+ pushq $\sel
15775+ pushq $\off
15776+ lretq
15777+#endif
15778+ .endm
15779+
15780+ .macro pax_enter_kernel
15781+ pax_set_fptr_mask
15782+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15783+ call pax_enter_kernel
15784+#endif
15785+ .endm
15786+
15787+ .macro pax_exit_kernel
15788+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15789+ call pax_exit_kernel
15790+#endif
15791+ .endm
15792+
15793+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15794+ENTRY(pax_enter_kernel)
15795+ pushq %rdi
15796+
15797+#ifdef CONFIG_PARAVIRT
15798+ PV_SAVE_REGS(CLBR_RDI)
15799+#endif
15800+
15801+#ifdef CONFIG_PAX_KERNEXEC
15802+ GET_CR0_INTO_RDI
15803+ bts $X86_CR0_WP_BIT,%rdi
15804+ jnc 3f
15805+ mov %cs,%edi
15806+ cmp $__KERNEL_CS,%edi
15807+ jnz 2f
15808+1:
15809+#endif
15810+
15811+#ifdef CONFIG_PAX_MEMORY_UDEREF
15812+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
15813+ GET_CR3_INTO_RDI
15814+ cmp $0,%dil
15815+ jnz 112f
15816+ mov $__KERNEL_DS,%edi
15817+ mov %edi,%ss
15818+ jmp 111f
15819+112: cmp $1,%dil
15820+ jz 113f
15821+ ud2
15822+113: sub $4097,%rdi
15823+ bts $63,%rdi
15824+ SET_RDI_INTO_CR3
15825+ mov $__UDEREF_KERNEL_DS,%edi
15826+ mov %edi,%ss
15827+111:
15828+#endif
15829+
15830+#ifdef CONFIG_PARAVIRT
15831+ PV_RESTORE_REGS(CLBR_RDI)
15832+#endif
15833+
15834+ popq %rdi
15835+ pax_force_retaddr
15836+ retq
15837+
15838+#ifdef CONFIG_PAX_KERNEXEC
15839+2: ljmpq __KERNEL_CS,1b
15840+3: ljmpq __KERNEXEC_KERNEL_CS,4f
15841+4: SET_RDI_INTO_CR0
15842+ jmp 1b
15843+#endif
15844+ENDPROC(pax_enter_kernel)
15845+
15846+ENTRY(pax_exit_kernel)
15847+ pushq %rdi
15848+
15849+#ifdef CONFIG_PARAVIRT
15850+ PV_SAVE_REGS(CLBR_RDI)
15851+#endif
15852+
15853+#ifdef CONFIG_PAX_KERNEXEC
15854+ mov %cs,%rdi
15855+ cmp $__KERNEXEC_KERNEL_CS,%edi
15856+ jz 2f
15857+ GET_CR0_INTO_RDI
15858+ bts $X86_CR0_WP_BIT,%rdi
15859+ jnc 4f
15860+1:
15861+#endif
15862+
15863+#ifdef CONFIG_PAX_MEMORY_UDEREF
15864+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
15865+ mov %ss,%edi
15866+ cmp $__UDEREF_KERNEL_DS,%edi
15867+ jnz 111f
15868+ GET_CR3_INTO_RDI
15869+ cmp $0,%dil
15870+ jz 112f
15871+ ud2
15872+112: add $4097,%rdi
15873+ bts $63,%rdi
15874+ SET_RDI_INTO_CR3
15875+ mov $__KERNEL_DS,%edi
15876+ mov %edi,%ss
15877+111:
15878+#endif
15879+
15880+#ifdef CONFIG_PARAVIRT
15881+ PV_RESTORE_REGS(CLBR_RDI);
15882+#endif
15883+
15884+ popq %rdi
15885+ pax_force_retaddr
15886+ retq
15887+
15888+#ifdef CONFIG_PAX_KERNEXEC
15889+2: GET_CR0_INTO_RDI
15890+ btr $X86_CR0_WP_BIT,%rdi
15891+ jnc 4f
15892+ ljmpq __KERNEL_CS,3f
15893+3: SET_RDI_INTO_CR0
15894+ jmp 1b
15895+4: ud2
15896+ jmp 4b
15897+#endif
15898+ENDPROC(pax_exit_kernel)
15899+#endif
15900+
15901+ .macro pax_enter_kernel_user
15902+ pax_set_fptr_mask
15903+#ifdef CONFIG_PAX_MEMORY_UDEREF
15904+ call pax_enter_kernel_user
15905+#endif
15906+ .endm
15907+
15908+ .macro pax_exit_kernel_user
15909+#ifdef CONFIG_PAX_MEMORY_UDEREF
15910+ call pax_exit_kernel_user
15911+#endif
15912+#ifdef CONFIG_PAX_RANDKSTACK
15913+ pushq %rax
15914+ pushq %r11
15915+ call pax_randomize_kstack
15916+ popq %r11
15917+ popq %rax
15918+#endif
15919+ .endm
15920+
15921+#ifdef CONFIG_PAX_MEMORY_UDEREF
15922+ENTRY(pax_enter_kernel_user)
15923+ pushq %rdi
15924+ pushq %rbx
15925+
15926+#ifdef CONFIG_PARAVIRT
15927+ PV_SAVE_REGS(CLBR_RDI)
15928+#endif
15929+
15930+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
15931+ GET_CR3_INTO_RDI
15932+ cmp $1,%dil
15933+ jnz 4f
15934+ sub $4097,%rdi
15935+ bts $63,%rdi
15936+ SET_RDI_INTO_CR3
15937+ jmp 3f
15938+111:
15939+
15940+ GET_CR3_INTO_RDI
15941+ mov %rdi,%rbx
15942+ add $__START_KERNEL_map,%rbx
15943+ sub phys_base(%rip),%rbx
15944+
15945+#ifdef CONFIG_PARAVIRT
15946+ cmpl $0, pv_info+PARAVIRT_enabled
15947+ jz 1f
15948+ pushq %rdi
15949+ i = 0
15950+ .rept USER_PGD_PTRS
15951+ mov i*8(%rbx),%rsi
15952+ mov $0,%sil
15953+ lea i*8(%rbx),%rdi
15954+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
15955+ i = i + 1
15956+ .endr
15957+ popq %rdi
15958+ jmp 2f
15959+1:
15960+#endif
15961+
15962+ i = 0
15963+ .rept USER_PGD_PTRS
15964+ movb $0,i*8(%rbx)
15965+ i = i + 1
15966+ .endr
15967+
15968+2: SET_RDI_INTO_CR3
15969+
15970+#ifdef CONFIG_PAX_KERNEXEC
15971+ GET_CR0_INTO_RDI
15972+ bts $X86_CR0_WP_BIT,%rdi
15973+ SET_RDI_INTO_CR0
15974+#endif
15975+
15976+3:
15977+
15978+#ifdef CONFIG_PARAVIRT
15979+ PV_RESTORE_REGS(CLBR_RDI)
15980+#endif
15981+
15982+ popq %rbx
15983+ popq %rdi
15984+ pax_force_retaddr
15985+ retq
15986+4: ud2
15987+ENDPROC(pax_enter_kernel_user)
15988+
15989+ENTRY(pax_exit_kernel_user)
15990+ pushq %rdi
15991+ pushq %rbx
15992+
15993+#ifdef CONFIG_PARAVIRT
15994+ PV_SAVE_REGS(CLBR_RDI)
15995+#endif
15996+
15997+ GET_CR3_INTO_RDI
15998+ ALTERNATIVE "jmp 1f", "", X86_FEATURE_PCID
15999+ cmp $0,%dil
16000+ jnz 3f
16001+ add $4097,%rdi
16002+ bts $63,%rdi
16003+ SET_RDI_INTO_CR3
16004+ jmp 2f
16005+1:
16006+
16007+ mov %rdi,%rbx
16008+
16009+#ifdef CONFIG_PAX_KERNEXEC
16010+ GET_CR0_INTO_RDI
16011+ btr $X86_CR0_WP_BIT,%rdi
16012+ jnc 3f
16013+ SET_RDI_INTO_CR0
16014+#endif
16015+
16016+ add $__START_KERNEL_map,%rbx
16017+ sub phys_base(%rip),%rbx
16018+
16019+#ifdef CONFIG_PARAVIRT
16020+ cmpl $0, pv_info+PARAVIRT_enabled
16021+ jz 1f
16022+ i = 0
16023+ .rept USER_PGD_PTRS
16024+ mov i*8(%rbx),%rsi
16025+ mov $0x67,%sil
16026+ lea i*8(%rbx),%rdi
16027+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
16028+ i = i + 1
16029+ .endr
16030+ jmp 2f
16031+1:
16032+#endif
16033+
16034+ i = 0
16035+ .rept USER_PGD_PTRS
16036+ movb $0x67,i*8(%rbx)
16037+ i = i + 1
16038+ .endr
16039+2:
16040+
16041+#ifdef CONFIG_PARAVIRT
16042+ PV_RESTORE_REGS(CLBR_RDI)
16043+#endif
16044+
16045+ popq %rbx
16046+ popq %rdi
16047+ pax_force_retaddr
16048+ retq
16049+3: ud2
16050+ENDPROC(pax_exit_kernel_user)
16051+#endif
16052+
16053+ .macro pax_enter_kernel_nmi
16054+ pax_set_fptr_mask
16055+
16056+#ifdef CONFIG_PAX_KERNEXEC
16057+ GET_CR0_INTO_RDI
16058+ bts $X86_CR0_WP_BIT,%rdi
16059+ jc 110f
16060+ SET_RDI_INTO_CR0
16061+ or $2,%ebx
16062+110:
16063+#endif
16064+
16065+#ifdef CONFIG_PAX_MEMORY_UDEREF
16066+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
16067+ GET_CR3_INTO_RDI
16068+ cmp $0,%dil
16069+ jz 111f
16070+ sub $4097,%rdi
16071+ or $4,%ebx
16072+ bts $63,%rdi
16073+ SET_RDI_INTO_CR3
16074+ mov $__UDEREF_KERNEL_DS,%edi
16075+ mov %edi,%ss
16076+111:
16077+#endif
16078+ .endm
16079+
16080+ .macro pax_exit_kernel_nmi
16081+#ifdef CONFIG_PAX_KERNEXEC
16082+ btr $1,%ebx
16083+ jnc 110f
16084+ GET_CR0_INTO_RDI
16085+ btr $X86_CR0_WP_BIT,%rdi
16086+ SET_RDI_INTO_CR0
16087+110:
16088+#endif
16089+
16090+#ifdef CONFIG_PAX_MEMORY_UDEREF
16091+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
16092+ btr $2,%ebx
16093+ jnc 111f
16094+ GET_CR3_INTO_RDI
16095+ add $4097,%rdi
16096+ bts $63,%rdi
16097+ SET_RDI_INTO_CR3
16098+ mov $__KERNEL_DS,%edi
16099+ mov %edi,%ss
16100+111:
16101+#endif
16102+ .endm
16103+
16104+ .macro pax_erase_kstack
16105+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16106+ call pax_erase_kstack
16107+#endif
16108+ .endm
16109+
16110+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16111+ENTRY(pax_erase_kstack)
16112+ pushq %rdi
16113+ pushq %rcx
16114+ pushq %rax
16115+ pushq %r11
16116+
16117+ GET_THREAD_INFO(%r11)
16118+ mov TI_lowest_stack(%r11), %rdi
16119+ mov $-0xBEEF, %rax
16120+ std
16121+
16122+1: mov %edi, %ecx
16123+ and $THREAD_SIZE_asm - 1, %ecx
16124+ shr $3, %ecx
16125+ repne scasq
16126+ jecxz 2f
16127+
16128+ cmp $2*8, %ecx
16129+ jc 2f
16130+
16131+ mov $2*8, %ecx
16132+ repe scasq
16133+ jecxz 2f
16134+ jne 1b
16135+
16136+2: cld
16137+ or $2*8, %rdi
16138+ mov %esp, %ecx
16139+ sub %edi, %ecx
16140+
16141+ cmp $THREAD_SIZE_asm, %rcx
16142+ jb 3f
16143+ ud2
16144+3:
16145+
16146+ shr $3, %ecx
16147+ rep stosq
16148+
16149+ mov TI_task_thread_sp0(%r11), %rdi
16150+ sub $256, %rdi
16151+ mov %rdi, TI_lowest_stack(%r11)
16152+
16153+ popq %r11
16154+ popq %rax
16155+ popq %rcx
16156+ popq %rdi
16157+ pax_force_retaddr
16158+ ret
16159+ENDPROC(pax_erase_kstack)
16160+#endif
16161+
16162 .macro TRACE_IRQS_IRETQ
16163 #ifdef CONFIG_TRACE_IRQFLAGS
16164 bt $9, EFLAGS(%rsp) /* interrupts off? */
16165@@ -89,7 +487,7 @@ ENDPROC(native_usergs_sysret64)
16166 .endm
16167
16168 .macro TRACE_IRQS_IRETQ_DEBUG
16169- bt $9, EFLAGS(%rsp) /* interrupts off? */
16170+ bt $X86_EFLAGS_IF_BIT, EFLAGS(%rsp) /* interrupts off? */
16171 jnc 1f
16172 TRACE_IRQS_ON_DEBUG
16173 1:
16174@@ -149,14 +547,6 @@ GLOBAL(entry_SYSCALL_64_after_swapgs)
16175 /* Construct struct pt_regs on stack */
16176 pushq $__USER_DS /* pt_regs->ss */
16177 pushq PER_CPU_VAR(rsp_scratch) /* pt_regs->sp */
16178- /*
16179- * Re-enable interrupts.
16180- * We use 'rsp_scratch' as a scratch space, hence irq-off block above
16181- * must execute atomically in the face of possible interrupt-driven
16182- * task preemption. We must enable interrupts only after we're done
16183- * with using rsp_scratch:
16184- */
16185- ENABLE_INTERRUPTS(CLBR_NONE)
16186 pushq %r11 /* pt_regs->flags */
16187 pushq $__USER_CS /* pt_regs->cs */
16188 pushq %rcx /* pt_regs->ip */
16189@@ -172,7 +562,27 @@ GLOBAL(entry_SYSCALL_64_after_swapgs)
16190 pushq %r11 /* pt_regs->r11 */
16191 sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */
16192
16193- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16194+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16195+ movq %r12, R12(%rsp)
16196+#endif
16197+
16198+ pax_enter_kernel_user
16199+
16200+#ifdef CONFIG_PAX_RANDKSTACK
16201+ pax_erase_kstack
16202+#endif
16203+
16204+ /*
16205+ * Re-enable interrupts.
16206+ * We use 'rsp_scratch' as a scratch space, hence irq-off block above
16207+ * must execute atomically in the face of possible interrupt-driven
16208+ * task preemption. We must enable interrupts only after we're done
16209+ * with using rsp_scratch:
16210+ */
16211+ ENABLE_INTERRUPTS(CLBR_NONE)
16212+
16213+ GET_THREAD_INFO(%rcx)
16214+ testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%rcx)
16215 jnz tracesys
16216 entry_SYSCALL_64_fastpath:
16217 #if __SYSCALL_MASK == ~0
16218@@ -205,9 +615,13 @@ entry_SYSCALL_64_fastpath:
16219 * flags (TIF_NOTIFY_RESUME, TIF_USER_RETURN_NOTIFY, etc) set is
16220 * very bad.
16221 */
16222- testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16223+ GET_THREAD_INFO(%rcx)
16224+ testl $_TIF_ALLWORK_MASK, TI_flags(%rcx)
16225 jnz int_ret_from_sys_call_irqs_off /* Go to the slow path */
16226
16227+ pax_exit_kernel_user
16228+ pax_erase_kstack
16229+
16230 RESTORE_C_REGS_EXCEPT_RCX_R11
16231 movq RIP(%rsp), %rcx
16232 movq EFLAGS(%rsp), %r11
16233@@ -236,6 +650,9 @@ tracesys:
16234 call syscall_trace_enter_phase1
16235 test %rax, %rax
16236 jnz tracesys_phase2 /* if needed, run the slow path */
16237+
16238+ pax_erase_kstack
16239+
16240 RESTORE_C_REGS_EXCEPT_RAX /* else restore clobbered regs */
16241 movq ORIG_RAX(%rsp), %rax
16242 jmp entry_SYSCALL_64_fastpath /* and return to the fast path */
16243@@ -247,6 +664,8 @@ tracesys_phase2:
16244 movq %rax, %rdx
16245 call syscall_trace_enter_phase2
16246
16247+ pax_erase_kstack
16248+
16249 /*
16250 * Reload registers from stack in case ptrace changed them.
16251 * We don't reload %rax because syscall_trace_entry_phase2() returned
16252@@ -284,6 +703,8 @@ GLOBAL(int_with_check)
16253 andl %edi, %edx
16254 jnz int_careful
16255 andl $~TS_COMPAT, TI_status(%rcx)
16256+ pax_exit_kernel_user
16257+ pax_erase_kstack
16258 jmp syscall_return
16259
16260 /*
16261@@ -407,14 +828,14 @@ syscall_return_via_sysret:
16262 opportunistic_sysret_failed:
16263 SWAPGS
16264 jmp restore_c_regs_and_iret
16265-END(entry_SYSCALL_64)
16266+ENDPROC(entry_SYSCALL_64)
16267
16268
16269 .macro FORK_LIKE func
16270 ENTRY(stub_\func)
16271 SAVE_EXTRA_REGS 8
16272 jmp sys_\func
16273-END(stub_\func)
16274+ENDPROC(stub_\func)
16275 .endm
16276
16277 FORK_LIKE clone
16278@@ -434,7 +855,7 @@ return_from_execve:
16279 ZERO_EXTRA_REGS
16280 movq %rax, RAX(%rsp)
16281 jmp int_ret_from_sys_call
16282-END(stub_execve)
16283+ENDPROC(stub_execve)
16284 /*
16285 * Remaining execve stubs are only 7 bytes long.
16286 * ENTRY() often aligns to 16 bytes, which in this case has no benefits.
16287@@ -443,7 +864,7 @@ END(stub_execve)
16288 GLOBAL(stub_execveat)
16289 call sys_execveat
16290 jmp return_from_execve
16291-END(stub_execveat)
16292+ENDPROC(stub_execveat)
16293
16294 #if defined(CONFIG_X86_X32_ABI) || defined(CONFIG_IA32_EMULATION)
16295 .align 8
16296@@ -451,15 +872,15 @@ GLOBAL(stub_x32_execve)
16297 GLOBAL(stub32_execve)
16298 call compat_sys_execve
16299 jmp return_from_execve
16300-END(stub32_execve)
16301-END(stub_x32_execve)
16302+ENDPROC(stub32_execve)
16303+ENDPROC(stub_x32_execve)
16304 .align 8
16305 GLOBAL(stub_x32_execveat)
16306 GLOBAL(stub32_execveat)
16307 call compat_sys_execveat
16308 jmp return_from_execve
16309-END(stub32_execveat)
16310-END(stub_x32_execveat)
16311+ENDPROC(stub32_execveat)
16312+ENDPROC(stub_x32_execveat)
16313 #endif
16314
16315 /*
16316@@ -488,7 +909,7 @@ ENTRY(stub_x32_rt_sigreturn)
16317 SAVE_EXTRA_REGS 8
16318 call sys32_x32_rt_sigreturn
16319 jmp return_from_stub
16320-END(stub_x32_rt_sigreturn)
16321+ENDPROC(stub_x32_rt_sigreturn)
16322 #endif
16323
16324 /*
16325@@ -527,7 +948,7 @@ ENTRY(ret_from_fork)
16326 movl $0, RAX(%rsp)
16327 RESTORE_EXTRA_REGS
16328 jmp int_ret_from_sys_call
16329-END(ret_from_fork)
16330+ENDPROC(ret_from_fork)
16331
16332 /*
16333 * Build the entry stubs with some assembler magic.
16334@@ -542,7 +963,7 @@ ENTRY(irq_entries_start)
16335 jmp common_interrupt
16336 .align 8
16337 .endr
16338-END(irq_entries_start)
16339+ENDPROC(irq_entries_start)
16340
16341 /*
16342 * Interrupt entry/exit.
16343@@ -555,21 +976,13 @@ END(irq_entries_start)
16344 /* 0(%rsp): ~(interrupt number) */
16345 .macro interrupt func
16346 cld
16347- /*
16348- * Since nothing in interrupt handling code touches r12...r15 members
16349- * of "struct pt_regs", and since interrupts can nest, we can save
16350- * four stack slots and simultaneously provide
16351- * an unwind-friendly stack layout by saving "truncated" pt_regs
16352- * exactly up to rbp slot, without these members.
16353- */
16354- ALLOC_PT_GPREGS_ON_STACK -RBP
16355- SAVE_C_REGS -RBP
16356- /* this goes to 0(%rsp) for unwinder, not for saving the value: */
16357- SAVE_EXTRA_REGS_RBP -RBP
16358+ ALLOC_PT_GPREGS_ON_STACK
16359+ SAVE_C_REGS
16360+ SAVE_EXTRA_REGS
16361
16362- leaq -RBP(%rsp), %rdi /* arg1 for \func (pointer to pt_regs) */
16363+ movq %rsp, %rdi /* arg1 for \func (pointer to pt_regs) */
16364
16365- testb $3, CS-RBP(%rsp)
16366+ testb $3, CS(%rsp)
16367 jz 1f
16368 SWAPGS
16369 1:
16370@@ -584,6 +997,18 @@ END(irq_entries_start)
16371 incl PER_CPU_VAR(irq_count)
16372 cmovzq PER_CPU_VAR(irq_stack_ptr), %rsp
16373 pushq %rsi
16374+
16375+#ifdef CONFIG_PAX_MEMORY_UDEREF
16376+ testb $3, CS(%rdi)
16377+ jnz 1f
16378+ pax_enter_kernel
16379+ jmp 2f
16380+1: pax_enter_kernel_user
16381+2:
16382+#else
16383+ pax_enter_kernel
16384+#endif
16385+
16386 /* We entered an interrupt context - irqs are off: */
16387 TRACE_IRQS_OFF
16388
16389@@ -608,7 +1033,7 @@ ret_from_intr:
16390 /* Restore saved previous stack */
16391 popq %rsi
16392 /* return code expects complete pt_regs - adjust rsp accordingly: */
16393- leaq -RBP(%rsi), %rsp
16394+ movq %rsi, %rsp
16395
16396 testb $3, CS(%rsp)
16397 jz retint_kernel
16398@@ -630,6 +1055,8 @@ retint_swapgs: /* return to user-space */
16399 * The iretq could re-enable interrupts:
16400 */
16401 DISABLE_INTERRUPTS(CLBR_ANY)
16402+ pax_exit_kernel_user
16403+# pax_erase_kstack
16404 TRACE_IRQS_IRETQ
16405
16406 SWAPGS
16407@@ -648,6 +1075,21 @@ retint_kernel:
16408 jmp 0b
16409 1:
16410 #endif
16411+
16412+ pax_exit_kernel
16413+
16414+#if defined(CONFIG_EFI) && defined(CONFIG_PAX_KERNEXEC)
16415+ /* This is a quirk to allow IRQs/NMIs/MCEs during early EFI setup,
16416+ * namely calling EFI runtime services with a phys mapping. We're
16417+ * starting off with NOPs and patch in the real instrumentation
16418+ * (BTS/OR) before starting any userland process; even before starting
16419+ * up the APs.
16420+ */
16421+ ALTERNATIVE "", "pax_force_retaddr 16*8", X86_FEATURE_ALWAYS
16422+#else
16423+ pax_force_retaddr RIP
16424+#endif
16425+
16426 /*
16427 * The iretq could re-enable interrupts:
16428 */
16429@@ -689,15 +1131,15 @@ native_irq_return_ldt:
16430 SWAPGS
16431 movq PER_CPU_VAR(espfix_waddr), %rdi
16432 movq %rax, (0*8)(%rdi) /* RAX */
16433- movq (2*8)(%rsp), %rax /* RIP */
16434+ movq (2*8 + RIP-RIP)(%rsp), %rax /* RIP */
16435 movq %rax, (1*8)(%rdi)
16436- movq (3*8)(%rsp), %rax /* CS */
16437+ movq (2*8 + CS-RIP)(%rsp), %rax /* CS */
16438 movq %rax, (2*8)(%rdi)
16439- movq (4*8)(%rsp), %rax /* RFLAGS */
16440+ movq (2*8 + EFLAGS-RIP)(%rsp), %rax /* RFLAGS */
16441 movq %rax, (3*8)(%rdi)
16442- movq (6*8)(%rsp), %rax /* SS */
16443+ movq (2*8 + SS-RIP)(%rsp), %rax /* SS */
16444 movq %rax, (5*8)(%rdi)
16445- movq (5*8)(%rsp), %rax /* RSP */
16446+ movq (2*8 + RSP-RIP)(%rsp), %rax /* RSP */
16447 movq %rax, (4*8)(%rdi)
16448 andl $0xffff0000, %eax
16449 popq %rdi
16450@@ -738,7 +1180,7 @@ retint_signal:
16451 GET_THREAD_INFO(%rcx)
16452 jmp retint_with_reschedule
16453
16454-END(common_interrupt)
16455+ENDPROC(common_interrupt)
16456
16457 /*
16458 * APIC interrupts.
16459@@ -750,7 +1192,7 @@ ENTRY(\sym)
16460 .Lcommon_\sym:
16461 interrupt \do_sym
16462 jmp ret_from_intr
16463-END(\sym)
16464+ENDPROC(\sym)
16465 .endm
16466
16467 #ifdef CONFIG_TRACING
16468@@ -815,7 +1257,7 @@ apicinterrupt IRQ_WORK_VECTOR irq_work_interrupt smp_irq_work_interrupt
16469 /*
16470 * Exception entry points.
16471 */
16472-#define CPU_TSS_IST(x) PER_CPU_VAR(cpu_tss) + (TSS_ist + ((x) - 1) * 8)
16473+#define CPU_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r13)
16474
16475 .macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1
16476 ENTRY(\sym)
16477@@ -862,6 +1304,12 @@ ENTRY(\sym)
16478 .endif
16479
16480 .if \shift_ist != -1
16481+#ifdef CONFIG_SMP
16482+ imul $TSS_size, PER_CPU_VAR(cpu_number), %r13d
16483+ lea cpu_tss(%r13), %r13
16484+#else
16485+ lea cpu_tss(%rip), %r13
16486+#endif
16487 subq $EXCEPTION_STKSZ, CPU_TSS_IST(\shift_ist)
16488 .endif
16489
16490@@ -905,7 +1353,7 @@ ENTRY(\sym)
16491
16492 jmp error_exit /* %ebx: no swapgs flag */
16493 .endif
16494-END(\sym)
16495+ENDPROC(\sym)
16496 .endm
16497
16498 #ifdef CONFIG_TRACING
16499@@ -947,8 +1395,9 @@ gs_change:
16500 2: mfence /* workaround */
16501 SWAPGS
16502 popfq
16503+ pax_force_retaddr
16504 ret
16505-END(native_load_gs_index)
16506+ENDPROC(native_load_gs_index)
16507
16508 _ASM_EXTABLE(gs_change, bad_gs)
16509 .section .fixup, "ax"
16510@@ -970,8 +1419,9 @@ ENTRY(do_softirq_own_stack)
16511 call __do_softirq
16512 leaveq
16513 decl PER_CPU_VAR(irq_count)
16514+ pax_force_retaddr
16515 ret
16516-END(do_softirq_own_stack)
16517+ENDPROC(do_softirq_own_stack)
16518
16519 #ifdef CONFIG_XEN
16520 idtentry xen_hypervisor_callback xen_do_hypervisor_callback has_error_code=0
16521@@ -1007,7 +1457,7 @@ ENTRY(xen_do_hypervisor_callback) /* do_hypervisor_callback(struct *pt_regs) */
16522 call xen_maybe_preempt_hcall
16523 #endif
16524 jmp error_exit
16525-END(xen_do_hypervisor_callback)
16526+ENDPROC(xen_do_hypervisor_callback)
16527
16528 /*
16529 * Hypervisor uses this for application faults while it executes.
16530@@ -1052,7 +1502,7 @@ ENTRY(xen_failsafe_callback)
16531 SAVE_C_REGS
16532 SAVE_EXTRA_REGS
16533 jmp error_exit
16534-END(xen_failsafe_callback)
16535+ENDPROC(xen_failsafe_callback)
16536
16537 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
16538 xen_hvm_callback_vector xen_evtchn_do_upcall
16539@@ -1101,8 +1551,36 @@ ENTRY(paranoid_entry)
16540 js 1f /* negative -> in kernel */
16541 SWAPGS
16542 xorl %ebx, %ebx
16543-1: ret
16544-END(paranoid_entry)
16545+1:
16546+#ifdef CONFIG_PAX_MEMORY_UDEREF
16547+ testb $3, CS+8(%rsp)
16548+ jnz 1f
16549+ pax_enter_kernel
16550+ jmp 2f
16551+1: pax_enter_kernel_user
16552+2:
16553+#else
16554+ pax_enter_kernel
16555+#endif
16556+ pax_force_retaddr
16557+ ret
16558+ENDPROC(paranoid_entry)
16559+
16560+ENTRY(paranoid_entry_nmi)
16561+ cld
16562+ SAVE_C_REGS 8
16563+ SAVE_EXTRA_REGS 8
16564+ movl $1, %ebx
16565+ movl $MSR_GS_BASE, %ecx
16566+ rdmsr
16567+ testl %edx, %edx
16568+ js 1f /* negative -> in kernel */
16569+ SWAPGS
16570+ xorl %ebx, %ebx
16571+1: pax_enter_kernel_nmi
16572+ pax_force_retaddr
16573+ ret
16574+ENDPROC(paranoid_entry_nmi)
16575
16576 /*
16577 * "Paranoid" exit path from exception stack. This is invoked
16578@@ -1119,19 +1597,26 @@ END(paranoid_entry)
16579 ENTRY(paranoid_exit)
16580 DISABLE_INTERRUPTS(CLBR_NONE)
16581 TRACE_IRQS_OFF_DEBUG
16582- testl %ebx, %ebx /* swapgs needed? */
16583+ testl $1, %ebx /* swapgs needed? */
16584 jnz paranoid_exit_no_swapgs
16585+#ifdef CONFIG_PAX_MEMORY_UDEREF
16586+ pax_exit_kernel_user
16587+#else
16588+ pax_exit_kernel
16589+#endif
16590 TRACE_IRQS_IRETQ
16591 SWAPGS_UNSAFE_STACK
16592 jmp paranoid_exit_restore
16593 paranoid_exit_no_swapgs:
16594+ pax_exit_kernel
16595 TRACE_IRQS_IRETQ_DEBUG
16596 paranoid_exit_restore:
16597 RESTORE_EXTRA_REGS
16598 RESTORE_C_REGS
16599 REMOVE_PT_GPREGS_FROM_STACK 8
16600+ pax_force_retaddr_bts
16601 INTERRUPT_RETURN
16602-END(paranoid_exit)
16603+ENDPROC(paranoid_exit)
16604
16605 /*
16606 * Save all registers in pt_regs, and switch gs if needed.
16607@@ -1149,7 +1634,18 @@ ENTRY(error_entry)
16608 SWAPGS
16609
16610 error_entry_done:
16611+#ifdef CONFIG_PAX_MEMORY_UDEREF
16612+ testb $3, CS+8(%rsp)
16613+ jnz 1f
16614+ pax_enter_kernel
16615+ jmp 2f
16616+1: pax_enter_kernel_user
16617+2:
16618+#else
16619+ pax_enter_kernel
16620+#endif
16621 TRACE_IRQS_OFF
16622+ pax_force_retaddr
16623 ret
16624
16625 /*
16626@@ -1199,7 +1695,7 @@ error_bad_iret:
16627 mov %rax, %rsp
16628 decl %ebx
16629 jmp error_entry_done
16630-END(error_entry)
16631+ENDPROC(error_entry)
16632
16633
16634 /*
16635@@ -1212,10 +1708,10 @@ ENTRY(error_exit)
16636 RESTORE_EXTRA_REGS
16637 DISABLE_INTERRUPTS(CLBR_NONE)
16638 TRACE_IRQS_OFF
16639- testl %eax, %eax
16640+ testl $1, %eax
16641 jnz retint_kernel
16642 jmp retint_user
16643-END(error_exit)
16644+ENDPROC(error_exit)
16645
16646 /* Runs on exception stack */
16647 ENTRY(nmi)
16648@@ -1269,6 +1765,8 @@ ENTRY(nmi)
16649 * other IST entries.
16650 */
16651
16652+ ASM_CLAC
16653+
16654 /* Use %rdx as our temp variable throughout */
16655 pushq %rdx
16656
16657@@ -1312,6 +1810,12 @@ ENTRY(nmi)
16658 pushq %r14 /* pt_regs->r14 */
16659 pushq %r15 /* pt_regs->r15 */
16660
16661+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
16662+ xorl %ebx, %ebx
16663+#endif
16664+
16665+ pax_enter_kernel_nmi
16666+
16667 /*
16668 * At this point we no longer need to worry about stack damage
16669 * due to nesting -- we're on the normal thread stack and we're
16670@@ -1322,12 +1826,19 @@ ENTRY(nmi)
16671 movq $-1, %rsi
16672 call do_nmi
16673
16674+ pax_exit_kernel_nmi
16675+
16676 /*
16677 * Return back to user mode. We must *not* do the normal exit
16678 * work, because we don't want to enable interrupts. Fortunately,
16679 * do_nmi doesn't modify pt_regs.
16680 */
16681 SWAPGS
16682+
16683+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
16684+ movq RBX(%rsp), %rbx
16685+#endif
16686+
16687 jmp restore_c_regs_and_iret
16688
16689 .Lnmi_from_kernel:
16690@@ -1449,6 +1960,7 @@ nested_nmi_out:
16691 popq %rdx
16692
16693 /* We are returning to kernel mode, so this cannot result in a fault. */
16694+# pax_force_retaddr_bts
16695 INTERRUPT_RETURN
16696
16697 first_nmi:
16698@@ -1522,20 +2034,22 @@ end_repeat_nmi:
16699 ALLOC_PT_GPREGS_ON_STACK
16700
16701 /*
16702- * Use paranoid_entry to handle SWAPGS, but no need to use paranoid_exit
16703+ * Use paranoid_entry_nmi to handle SWAPGS, but no need to use paranoid_exit
16704 * as we should not be calling schedule in NMI context.
16705 * Even with normal interrupts enabled. An NMI should not be
16706 * setting NEED_RESCHED or anything that normal interrupts and
16707 * exceptions might do.
16708 */
16709- call paranoid_entry
16710+ call paranoid_entry_nmi
16711
16712 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
16713 movq %rsp, %rdi
16714 movq $-1, %rsi
16715 call do_nmi
16716
16717- testl %ebx, %ebx /* swapgs needed? */
16718+ pax_exit_kernel_nmi
16719+
16720+ testl $1, %ebx /* swapgs needed? */
16721 jnz nmi_restore
16722 nmi_swapgs:
16723 SWAPGS_UNSAFE_STACK
16724@@ -1546,6 +2060,8 @@ nmi_restore:
16725 /* Point RSP at the "iret" frame. */
16726 REMOVE_PT_GPREGS_FROM_STACK 6*8
16727
16728+ pax_force_retaddr_bts
16729+
16730 /*
16731 * Clear "NMI executing". Set DF first so that we can easily
16732 * distinguish the remaining code between here and IRET from
16733@@ -1563,9 +2079,9 @@ nmi_restore:
16734 * mode, so this cannot result in a fault.
16735 */
16736 INTERRUPT_RETURN
16737-END(nmi)
16738+ENDPROC(nmi)
16739
16740 ENTRY(ignore_sysret)
16741 mov $-ENOSYS, %eax
16742 sysret
16743-END(ignore_sysret)
16744+ENDPROC(ignore_sysret)
16745diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
16746index a7e257d..3a6ad23 100644
16747--- a/arch/x86/entry/entry_64_compat.S
16748+++ b/arch/x86/entry/entry_64_compat.S
16749@@ -13,8 +13,10 @@
16750 #include <asm/irqflags.h>
16751 #include <asm/asm.h>
16752 #include <asm/smap.h>
16753+#include <asm/pgtable.h>
16754 #include <linux/linkage.h>
16755 #include <linux/err.h>
16756+#include <asm/alternative-asm.h>
16757
16758 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
16759 #include <linux/elf-em.h>
16760@@ -35,6 +37,32 @@ ENTRY(native_usergs_sysret32)
16761 ENDPROC(native_usergs_sysret32)
16762 #endif
16763
16764+ .macro pax_enter_kernel_user
16765+ pax_set_fptr_mask
16766+#ifdef CONFIG_PAX_MEMORY_UDEREF
16767+ call pax_enter_kernel_user
16768+#endif
16769+ .endm
16770+
16771+ .macro pax_exit_kernel_user
16772+#ifdef CONFIG_PAX_MEMORY_UDEREF
16773+ call pax_exit_kernel_user
16774+#endif
16775+#ifdef CONFIG_PAX_RANDKSTACK
16776+ pushq %rax
16777+ pushq %r11
16778+ call pax_randomize_kstack
16779+ popq %r11
16780+ popq %rax
16781+#endif
16782+ .endm
16783+
16784+ .macro pax_erase_kstack
16785+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16786+ call pax_erase_kstack
16787+#endif
16788+ .endm
16789+
16790 /*
16791 * 32-bit SYSENTER instruction entry.
16792 *
16793@@ -65,20 +93,21 @@ ENTRY(entry_SYSENTER_compat)
16794 */
16795 SWAPGS_UNSAFE_STACK
16796 movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
16797- ENABLE_INTERRUPTS(CLBR_NONE)
16798
16799 /* Zero-extending 32-bit regs, do not remove */
16800 movl %ebp, %ebp
16801 movl %eax, %eax
16802
16803- movl ASM_THREAD_INFO(TI_sysenter_return, %rsp, 0), %r10d
16804+ GET_THREAD_INFO(%r11)
16805+ movl TI_sysenter_return(%r11), %r11d
16806
16807 /* Construct struct pt_regs on stack */
16808 pushq $__USER32_DS /* pt_regs->ss */
16809 pushq %rbp /* pt_regs->sp */
16810 pushfq /* pt_regs->flags */
16811+ orl $X86_EFLAGS_IF,(%rsp)
16812 pushq $__USER32_CS /* pt_regs->cs */
16813- pushq %r10 /* pt_regs->ip = thread_info->sysenter_return */
16814+ pushq %r11 /* pt_regs->ip = thread_info->sysenter_return */
16815 pushq %rax /* pt_regs->orig_ax */
16816 pushq %rdi /* pt_regs->di */
16817 pushq %rsi /* pt_regs->si */
16818@@ -88,15 +117,37 @@ ENTRY(entry_SYSENTER_compat)
16819 cld
16820 sub $(10*8), %rsp /* pt_regs->r8-11, bp, bx, r12-15 not saved */
16821
16822+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16823+ movq %r12, R12(%rsp)
16824+#endif
16825+
16826+ pax_enter_kernel_user
16827+
16828+#ifdef CONFIG_PAX_RANDKSTACK
16829+ pax_erase_kstack
16830+#endif
16831+
16832+ ENABLE_INTERRUPTS(CLBR_NONE)
16833+
16834 /*
16835 * no need to do an access_ok check here because rbp has been
16836 * 32-bit zero extended
16837 */
16838+
16839+#ifdef CONFIG_PAX_MEMORY_UDEREF
16840+ addq pax_user_shadow_base, %rbp
16841+ ASM_PAX_OPEN_USERLAND
16842+#endif
16843+
16844 ASM_STAC
16845 1: movl (%rbp), %ebp
16846 _ASM_EXTABLE(1b, ia32_badarg)
16847 ASM_CLAC
16848
16849+#ifdef CONFIG_PAX_MEMORY_UDEREF
16850+ ASM_PAX_CLOSE_USERLAND
16851+#endif
16852+
16853 /*
16854 * Sysenter doesn't filter flags, so we need to clear NT
16855 * ourselves. To save a few cycles, we can check whether
16856@@ -106,8 +157,9 @@ ENTRY(entry_SYSENTER_compat)
16857 jnz sysenter_fix_flags
16858 sysenter_flags_fixed:
16859
16860- orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
16861- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16862+ GET_THREAD_INFO(%r11)
16863+ orl $TS_COMPAT, TI_status(%r11)
16864+ testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%r11)
16865 jnz sysenter_tracesys
16866
16867 sysenter_do_call:
16868@@ -123,9 +175,10 @@ sysenter_dispatch:
16869 call *ia32_sys_call_table(, %rax, 8)
16870 movq %rax, RAX(%rsp)
16871 1:
16872+ GET_THREAD_INFO(%r11)
16873 DISABLE_INTERRUPTS(CLBR_NONE)
16874 TRACE_IRQS_OFF
16875- testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16876+ testl $_TIF_ALLWORK_MASK, TI_flags(%r11)
16877 jnz sysexit_audit
16878 sysexit_from_sys_call:
16879 /*
16880@@ -138,7 +191,9 @@ sysexit_from_sys_call:
16881 * This code path is still called 'sysexit' because it pairs
16882 * with 'sysenter' and it uses the SYSENTER calling convention.
16883 */
16884- andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
16885+ pax_exit_kernel_user
16886+ pax_erase_kstack
16887+ andl $~TS_COMPAT, TI_status(%r11)
16888 movl RIP(%rsp), %ecx /* User %eip */
16889 movq RAX(%rsp), %rax
16890 RESTORE_RSI_RDI
16891@@ -194,6 +249,8 @@ sysexit_from_sys_call:
16892 movl %eax, %edi /* arg1 (RDI) <= syscall number (EAX) */
16893 call __audit_syscall_entry
16894
16895+ pax_erase_kstack
16896+
16897 /*
16898 * We are going to jump back to the syscall dispatch code.
16899 * Prepare syscall args as required by the 64-bit C ABI.
16900@@ -209,7 +266,7 @@ sysexit_from_sys_call:
16901 .endm
16902
16903 .macro auditsys_exit exit
16904- testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16905+ testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), TI_flags(%r11)
16906 jnz ia32_ret_from_sys_call
16907 TRACE_IRQS_ON
16908 ENABLE_INTERRUPTS(CLBR_NONE)
16909@@ -220,10 +277,11 @@ sysexit_from_sys_call:
16910 1: setbe %al /* 1 if error, 0 if not */
16911 movzbl %al, %edi /* zero-extend that into %edi */
16912 call __audit_syscall_exit
16913+ GET_THREAD_INFO(%r11)
16914 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %edi
16915 DISABLE_INTERRUPTS(CLBR_NONE)
16916 TRACE_IRQS_OFF
16917- testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16918+ testl %edi, TI_flags(%r11)
16919 jz \exit
16920 xorl %eax, %eax /* Do not leak kernel information */
16921 movq %rax, R11(%rsp)
16922@@ -249,7 +307,7 @@ sysenter_fix_flags:
16923
16924 sysenter_tracesys:
16925 #ifdef CONFIG_AUDITSYSCALL
16926- testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16927+ testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), TI_flags(%r11)
16928 jz sysenter_auditsys
16929 #endif
16930 SAVE_EXTRA_REGS
16931@@ -269,6 +327,9 @@ sysenter_tracesys:
16932 movl %eax, %eax /* zero extension */
16933
16934 RESTORE_EXTRA_REGS
16935+
16936+ pax_erase_kstack
16937+
16938 jmp sysenter_do_call
16939 ENDPROC(entry_SYSENTER_compat)
16940
16941@@ -311,7 +372,6 @@ ENTRY(entry_SYSCALL_compat)
16942 SWAPGS_UNSAFE_STACK
16943 movl %esp, %r8d
16944 movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
16945- ENABLE_INTERRUPTS(CLBR_NONE)
16946
16947 /* Zero-extending 32-bit regs, do not remove */
16948 movl %eax, %eax
16949@@ -331,16 +391,41 @@ ENTRY(entry_SYSCALL_compat)
16950 pushq $-ENOSYS /* pt_regs->ax */
16951 sub $(10*8), %rsp /* pt_regs->r8-11, bp, bx, r12-15 not saved */
16952
16953+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16954+ movq %r12, R12(%rsp)
16955+#endif
16956+
16957+ pax_enter_kernel_user
16958+
16959+#ifdef CONFIG_PAX_RANDKSTACK
16960+ pax_erase_kstack
16961+#endif
16962+
16963+ ENABLE_INTERRUPTS(CLBR_NONE)
16964+
16965 /*
16966 * No need to do an access_ok check here because r8 has been
16967 * 32-bit zero extended:
16968 */
16969+
16970+#ifdef CONFIG_PAX_MEMORY_UDEREF
16971+ ASM_PAX_OPEN_USERLAND
16972+ movq pax_user_shadow_base, %r8
16973+ addq RSP(%rsp), %r8
16974+#endif
16975+
16976 ASM_STAC
16977 1: movl (%r8), %r9d
16978 _ASM_EXTABLE(1b, ia32_badarg)
16979 ASM_CLAC
16980- orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
16981- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
16982+
16983+#ifdef CONFIG_PAX_MEMORY_UDEREF
16984+ ASM_PAX_CLOSE_USERLAND
16985+#endif
16986+
16987+ GET_THREAD_INFO(%r11)
16988+ orl $TS_COMPAT,TI_status(%r11)
16989+ testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
16990 jnz cstar_tracesys
16991
16992 cstar_do_call:
16993@@ -358,13 +443,16 @@ cstar_dispatch:
16994 call *ia32_sys_call_table(, %rax, 8)
16995 movq %rax, RAX(%rsp)
16996 1:
16997+ GET_THREAD_INFO(%r11)
16998 DISABLE_INTERRUPTS(CLBR_NONE)
16999 TRACE_IRQS_OFF
17000- testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
17001+ testl $_TIF_ALLWORK_MASK, TI_flags(%r11)
17002 jnz sysretl_audit
17003
17004 sysretl_from_sys_call:
17005- andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
17006+ pax_exit_kernel_user
17007+ pax_erase_kstack
17008+ andl $~TS_COMPAT, TI_status(%r11)
17009 RESTORE_RSI_RDI_RDX
17010 movl RIP(%rsp), %ecx
17011 movl EFLAGS(%rsp), %r11d
17012@@ -403,7 +491,7 @@ sysretl_audit:
17013
17014 cstar_tracesys:
17015 #ifdef CONFIG_AUDITSYSCALL
17016- testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
17017+ testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), TI_flags(%r11)
17018 jz cstar_auditsys
17019 #endif
17020 xchgl %r9d, %ebp
17021@@ -426,11 +514,19 @@ cstar_tracesys:
17022
17023 RESTORE_EXTRA_REGS
17024 xchgl %ebp, %r9d
17025+
17026+ pax_erase_kstack
17027+
17028 jmp cstar_do_call
17029 END(entry_SYSCALL_compat)
17030
17031 ia32_badarg:
17032 ASM_CLAC
17033+
17034+#ifdef CONFIG_PAX_MEMORY_UDEREF
17035+ ASM_PAX_CLOSE_USERLAND
17036+#endif
17037+
17038 movq $-EFAULT, RAX(%rsp)
17039 ia32_ret_from_sys_call:
17040 xorl %eax, %eax /* Do not leak kernel information */
17041@@ -462,14 +558,8 @@ ia32_ret_from_sys_call:
17042 */
17043
17044 ENTRY(entry_INT80_compat)
17045- /*
17046- * Interrupts are off on entry.
17047- * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
17048- * it is too small to ever cause noticeable irq latency.
17049- */
17050 PARAVIRT_ADJUST_EXCEPTION_FRAME
17051 SWAPGS
17052- ENABLE_INTERRUPTS(CLBR_NONE)
17053
17054 /* Zero-extending 32-bit regs, do not remove */
17055 movl %eax, %eax
17056@@ -488,8 +578,26 @@ ENTRY(entry_INT80_compat)
17057 cld
17058 sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */
17059
17060- orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
17061- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
17062+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
17063+ movq %r12, R12(%rsp)
17064+#endif
17065+
17066+ pax_enter_kernel_user
17067+
17068+#ifdef CONFIG_PAX_RANDKSTACK
17069+ pax_erase_kstack
17070+#endif
17071+
17072+ /*
17073+ * Interrupts are off on entry.
17074+ * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
17075+ * it is too small to ever cause noticeable irq latency.
17076+ */
17077+ ENABLE_INTERRUPTS(CLBR_NONE)
17078+
17079+ GET_THREAD_INFO(%r11)
17080+ orl $TS_COMPAT, TI_status(%r11)
17081+ testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%r11)
17082 jnz ia32_tracesys
17083
17084 ia32_do_call:
17085@@ -524,6 +632,9 @@ ia32_tracesys:
17086 movl RDI(%rsp), %edi
17087 movl %eax, %eax /* zero extension */
17088 RESTORE_EXTRA_REGS
17089+
17090+ pax_erase_kstack
17091+
17092 jmp ia32_do_call
17093 END(entry_INT80_compat)
17094
17095diff --git a/arch/x86/entry/thunk_64.S b/arch/x86/entry/thunk_64.S
17096index efb2b93..8a9cb8e 100644
17097--- a/arch/x86/entry/thunk_64.S
17098+++ b/arch/x86/entry/thunk_64.S
17099@@ -8,6 +8,7 @@
17100 #include <linux/linkage.h>
17101 #include "calling.h"
17102 #include <asm/asm.h>
17103+#include <asm/alternative-asm.h>
17104
17105 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
17106 .macro THUNK name, func, put_ret_addr_in_rdi=0
17107@@ -62,6 +63,7 @@ restore:
17108 popq %rdx
17109 popq %rsi
17110 popq %rdi
17111+ pax_force_retaddr
17112 ret
17113 _ASM_NOKPROBE(restore)
17114 #endif
17115diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
17116index e970320..c006fea 100644
17117--- a/arch/x86/entry/vdso/Makefile
17118+++ b/arch/x86/entry/vdso/Makefile
17119@@ -175,7 +175,7 @@ quiet_cmd_vdso = VDSO $@
17120 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
17121 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
17122
17123-VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
17124+VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
17125 $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS)
17126 GCOV_PROFILE := n
17127
17128diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h
17129index 0224987..8deb742 100644
17130--- a/arch/x86/entry/vdso/vdso2c.h
17131+++ b/arch/x86/entry/vdso/vdso2c.h
17132@@ -12,7 +12,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
17133 unsigned long load_size = -1; /* Work around bogus warning */
17134 unsigned long mapping_size;
17135 ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr;
17136- int i;
17137+ unsigned int i;
17138 unsigned long j;
17139 ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
17140 *alt_sec = NULL;
17141@@ -83,7 +83,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
17142 for (i = 0;
17143 i < GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
17144 i++) {
17145- int k;
17146+ unsigned int k;
17147 ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) +
17148 GET_LE(&symtab_hdr->sh_entsize) * i;
17149 const char *name = raw_addr + GET_LE(&strtab_hdr->sh_offset) +
17150diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
17151index 1c9f750..cfddb1a 100644
17152--- a/arch/x86/entry/vdso/vma.c
17153+++ b/arch/x86/entry/vdso/vma.c
17154@@ -19,10 +19,7 @@
17155 #include <asm/page.h>
17156 #include <asm/hpet.h>
17157 #include <asm/desc.h>
17158-
17159-#if defined(CONFIG_X86_64)
17160-unsigned int __read_mostly vdso64_enabled = 1;
17161-#endif
17162+#include <asm/mman.h>
17163
17164 void __init init_vdso_image(const struct vdso_image *image)
17165 {
17166@@ -101,6 +98,11 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
17167 .pages = no_pages,
17168 };
17169
17170+#ifdef CONFIG_PAX_RANDMMAP
17171+ if (mm->pax_flags & MF_PAX_RANDMMAP)
17172+ calculate_addr = false;
17173+#endif
17174+
17175 if (calculate_addr) {
17176 addr = vdso_addr(current->mm->start_stack,
17177 image->size - image->sym_vvar_start);
17178@@ -111,14 +113,14 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
17179 down_write(&mm->mmap_sem);
17180
17181 addr = get_unmapped_area(NULL, addr,
17182- image->size - image->sym_vvar_start, 0, 0);
17183+ image->size - image->sym_vvar_start, 0, MAP_EXECUTABLE);
17184 if (IS_ERR_VALUE(addr)) {
17185 ret = addr;
17186 goto up_fail;
17187 }
17188
17189 text_start = addr - image->sym_vvar_start;
17190- current->mm->context.vdso = (void __user *)text_start;
17191+ mm->context.vdso = text_start;
17192
17193 /*
17194 * MAYWRITE to allow gdb to COW and set breakpoints
17195@@ -163,15 +165,12 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
17196 hpet_address >> PAGE_SHIFT,
17197 PAGE_SIZE,
17198 pgprot_noncached(PAGE_READONLY));
17199-
17200- if (ret)
17201- goto up_fail;
17202 }
17203 #endif
17204
17205 up_fail:
17206 if (ret)
17207- current->mm->context.vdso = NULL;
17208+ current->mm->context.vdso = 0;
17209
17210 up_write(&mm->mmap_sem);
17211 return ret;
17212@@ -191,8 +190,8 @@ static int load_vdso32(void)
17213
17214 if (selected_vdso32->sym_VDSO32_SYSENTER_RETURN)
17215 current_thread_info()->sysenter_return =
17216- current->mm->context.vdso +
17217- selected_vdso32->sym_VDSO32_SYSENTER_RETURN;
17218+ (void __force_user *)(current->mm->context.vdso +
17219+ selected_vdso32->sym_VDSO32_SYSENTER_RETURN);
17220
17221 return 0;
17222 }
17223@@ -201,9 +200,6 @@ static int load_vdso32(void)
17224 #ifdef CONFIG_X86_64
17225 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
17226 {
17227- if (!vdso64_enabled)
17228- return 0;
17229-
17230 return map_vdso(&vdso_image_64, true);
17231 }
17232
17233@@ -212,12 +208,8 @@ int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
17234 int uses_interp)
17235 {
17236 #ifdef CONFIG_X86_X32_ABI
17237- if (test_thread_flag(TIF_X32)) {
17238- if (!vdso64_enabled)
17239- return 0;
17240-
17241+ if (test_thread_flag(TIF_X32))
17242 return map_vdso(&vdso_image_x32, true);
17243- }
17244 #endif
17245
17246 return load_vdso32();
17247@@ -231,15 +223,6 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
17248 #endif
17249
17250 #ifdef CONFIG_X86_64
17251-static __init int vdso_setup(char *s)
17252-{
17253- vdso64_enabled = simple_strtoul(s, NULL, 0);
17254- return 0;
17255-}
17256-__setup("vdso=", vdso_setup);
17257-#endif
17258-
17259-#ifdef CONFIG_X86_64
17260 static void vgetcpu_cpu_init(void *arg)
17261 {
17262 int cpu = smp_processor_id();
17263diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c
17264index 2dcc6ff..082dc7a 100644
17265--- a/arch/x86/entry/vsyscall/vsyscall_64.c
17266+++ b/arch/x86/entry/vsyscall/vsyscall_64.c
17267@@ -38,15 +38,13 @@
17268 #define CREATE_TRACE_POINTS
17269 #include "vsyscall_trace.h"
17270
17271-static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
17272+static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
17273
17274 static int __init vsyscall_setup(char *str)
17275 {
17276 if (str) {
17277 if (!strcmp("emulate", str))
17278 vsyscall_mode = EMULATE;
17279- else if (!strcmp("native", str))
17280- vsyscall_mode = NATIVE;
17281 else if (!strcmp("none", str))
17282 vsyscall_mode = NONE;
17283 else
17284@@ -264,8 +262,7 @@ do_ret:
17285 return true;
17286
17287 sigsegv:
17288- force_sig(SIGSEGV, current);
17289- return true;
17290+ do_group_exit(SIGKILL);
17291 }
17292
17293 /*
17294@@ -283,8 +280,8 @@ static struct vm_operations_struct gate_vma_ops = {
17295 static struct vm_area_struct gate_vma = {
17296 .vm_start = VSYSCALL_ADDR,
17297 .vm_end = VSYSCALL_ADDR + PAGE_SIZE,
17298- .vm_page_prot = PAGE_READONLY_EXEC,
17299- .vm_flags = VM_READ | VM_EXEC,
17300+ .vm_page_prot = PAGE_READONLY,
17301+ .vm_flags = VM_READ,
17302 .vm_ops = &gate_vma_ops,
17303 };
17304
17305@@ -325,10 +322,7 @@ void __init map_vsyscall(void)
17306 unsigned long physaddr_vsyscall = __pa_symbol(&__vsyscall_page);
17307
17308 if (vsyscall_mode != NONE)
17309- __set_fixmap(VSYSCALL_PAGE, physaddr_vsyscall,
17310- vsyscall_mode == NATIVE
17311- ? PAGE_KERNEL_VSYSCALL
17312- : PAGE_KERNEL_VVAR);
17313+ __set_fixmap(VSYSCALL_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
17314
17315 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_PAGE) !=
17316 (unsigned long)VSYSCALL_ADDR);
17317diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
17318index ae6aad1..719d6d9 100644
17319--- a/arch/x86/ia32/ia32_aout.c
17320+++ b/arch/x86/ia32/ia32_aout.c
17321@@ -153,6 +153,8 @@ static int aout_core_dump(struct coredump_params *cprm)
17322 unsigned long dump_start, dump_size;
17323 struct user32 dump;
17324
17325+ memset(&dump, 0, sizeof(dump));
17326+
17327 fs = get_fs();
17328 set_fs(KERNEL_DS);
17329 has_dumped = 1;
17330diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
17331index ae3a29a..cea65e9 100644
17332--- a/arch/x86/ia32/ia32_signal.c
17333+++ b/arch/x86/ia32/ia32_signal.c
17334@@ -216,7 +216,7 @@ asmlinkage long sys32_sigreturn(void)
17335 if (__get_user(set.sig[0], &frame->sc.oldmask)
17336 || (_COMPAT_NSIG_WORDS > 1
17337 && __copy_from_user((((char *) &set.sig) + 4),
17338- &frame->extramask,
17339+ frame->extramask,
17340 sizeof(frame->extramask))))
17341 goto badframe;
17342
17343@@ -336,7 +336,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
17344 sp -= frame_size;
17345 /* Align the stack pointer according to the i386 ABI,
17346 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
17347- sp = ((sp + 4) & -16ul) - 4;
17348+ sp = ((sp - 12) & -16ul) - 4;
17349 return (void __user *) sp;
17350 }
17351
17352@@ -381,10 +381,10 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
17353 } else {
17354 /* Return stub is in 32bit vsyscall page */
17355 if (current->mm->context.vdso)
17356- restorer = current->mm->context.vdso +
17357- selected_vdso32->sym___kernel_sigreturn;
17358+ restorer = (void __force_user *)(current->mm->context.vdso +
17359+ selected_vdso32->sym___kernel_sigreturn);
17360 else
17361- restorer = &frame->retcode;
17362+ restorer = frame->retcode;
17363 }
17364
17365 put_user_try {
17366@@ -394,7 +394,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
17367 * These are actually not used anymore, but left because some
17368 * gdb versions depend on them as a marker.
17369 */
17370- put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
17371+ put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
17372 } put_user_catch(err);
17373
17374 if (err)
17375@@ -436,7 +436,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
17376 0xb8,
17377 __NR_ia32_rt_sigreturn,
17378 0x80cd,
17379- 0,
17380+ 0
17381 };
17382
17383 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
17384@@ -459,16 +459,19 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
17385
17386 if (ksig->ka.sa.sa_flags & SA_RESTORER)
17387 restorer = ksig->ka.sa.sa_restorer;
17388+ else if (current->mm->context.vdso)
17389+ /* Return stub is in 32bit vsyscall page */
17390+ restorer = (void __force_user *)(current->mm->context.vdso +
17391+ selected_vdso32->sym___kernel_rt_sigreturn);
17392 else
17393- restorer = current->mm->context.vdso +
17394- selected_vdso32->sym___kernel_rt_sigreturn;
17395+ restorer = frame->retcode;
17396 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
17397
17398 /*
17399 * Not actually used anymore, but left because some gdb
17400 * versions need it.
17401 */
17402- put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
17403+ put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
17404 } put_user_catch(err);
17405
17406 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
17407diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
17408index 719cd70..72af944 100644
17409--- a/arch/x86/ia32/sys_ia32.c
17410+++ b/arch/x86/ia32/sys_ia32.c
17411@@ -49,18 +49,26 @@
17412
17413 #define AA(__x) ((unsigned long)(__x))
17414
17415+static inline loff_t compose_loff(unsigned int high, unsigned int low)
17416+{
17417+ loff_t retval = low;
17418+
17419+ BUILD_BUG_ON(sizeof retval != sizeof low + sizeof high);
17420+ __builtin_memcpy((unsigned char *)&retval + sizeof low, &high, sizeof high);
17421+ return retval;
17422+}
17423
17424 asmlinkage long sys32_truncate64(const char __user *filename,
17425- unsigned long offset_low,
17426- unsigned long offset_high)
17427+ unsigned int offset_low,
17428+ unsigned int offset_high)
17429 {
17430- return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low);
17431+ return sys_truncate(filename, compose_loff(offset_high, offset_low));
17432 }
17433
17434-asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
17435- unsigned long offset_high)
17436+asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned int offset_low,
17437+ unsigned int offset_high)
17438 {
17439- return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low);
17440+ return sys_ftruncate(fd, ((unsigned long) offset_high << 32) | offset_low);
17441 }
17442
17443 /*
17444@@ -69,8 +77,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
17445 */
17446 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
17447 {
17448- typeof(ubuf->st_uid) uid = 0;
17449- typeof(ubuf->st_gid) gid = 0;
17450+ typeof(((struct stat64 *)0)->st_uid) uid = 0;
17451+ typeof(((struct stat64 *)0)->st_gid) gid = 0;
17452 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
17453 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
17454 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
17455@@ -196,29 +204,29 @@ long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
17456 __u32 len_low, __u32 len_high, int advice)
17457 {
17458 return sys_fadvise64_64(fd,
17459- (((u64)offset_high)<<32) | offset_low,
17460- (((u64)len_high)<<32) | len_low,
17461+ compose_loff(offset_high, offset_low),
17462+ compose_loff(len_high, len_low),
17463 advice);
17464 }
17465
17466 asmlinkage ssize_t sys32_readahead(int fd, unsigned off_lo, unsigned off_hi,
17467 size_t count)
17468 {
17469- return sys_readahead(fd, ((u64)off_hi << 32) | off_lo, count);
17470+ return sys_readahead(fd, compose_loff(off_hi, off_lo), count);
17471 }
17472
17473 asmlinkage long sys32_sync_file_range(int fd, unsigned off_low, unsigned off_hi,
17474 unsigned n_low, unsigned n_hi, int flags)
17475 {
17476 return sys_sync_file_range(fd,
17477- ((u64)off_hi << 32) | off_low,
17478- ((u64)n_hi << 32) | n_low, flags);
17479+ compose_loff(off_hi, off_low),
17480+ compose_loff(n_hi, n_low), flags);
17481 }
17482
17483 asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi,
17484- size_t len, int advice)
17485+ int len, int advice)
17486 {
17487- return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
17488+ return sys_fadvise64_64(fd, compose_loff(offset_hi, offset_lo),
17489 len, advice);
17490 }
17491
17492@@ -226,6 +234,6 @@ asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_lo,
17493 unsigned offset_hi, unsigned len_lo,
17494 unsigned len_hi)
17495 {
17496- return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
17497- ((u64)len_hi << 32) | len_lo);
17498+ return sys_fallocate(fd, mode, compose_loff(offset_hi, offset_lo),
17499+ compose_loff(len_hi, len_lo));
17500 }
17501diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
17502index e7636ba..e1fb78a 100644
17503--- a/arch/x86/include/asm/alternative-asm.h
17504+++ b/arch/x86/include/asm/alternative-asm.h
17505@@ -18,6 +18,45 @@
17506 .endm
17507 #endif
17508
17509+#ifdef KERNEXEC_PLUGIN
17510+ .macro pax_force_retaddr_bts rip=0
17511+ btsq $63,\rip(%rsp)
17512+ .endm
17513+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
17514+ .macro pax_force_retaddr rip=0, reload=0
17515+ btsq $63,\rip(%rsp)
17516+ .endm
17517+ .macro pax_force_fptr ptr
17518+ btsq $63,\ptr
17519+ .endm
17520+ .macro pax_set_fptr_mask
17521+ .endm
17522+#endif
17523+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
17524+ .macro pax_force_retaddr rip=0, reload=0
17525+ .if \reload
17526+ pax_set_fptr_mask
17527+ .endif
17528+ orq %r12,\rip(%rsp)
17529+ .endm
17530+ .macro pax_force_fptr ptr
17531+ orq %r12,\ptr
17532+ .endm
17533+ .macro pax_set_fptr_mask
17534+ movabs $0x8000000000000000,%r12
17535+ .endm
17536+#endif
17537+#else
17538+ .macro pax_force_retaddr rip=0, reload=0
17539+ .endm
17540+ .macro pax_force_fptr ptr
17541+ .endm
17542+ .macro pax_force_retaddr_bts rip=0
17543+ .endm
17544+ .macro pax_set_fptr_mask
17545+ .endm
17546+#endif
17547+
17548 /*
17549 * Issue one struct alt_instr descriptor entry (need to put it into
17550 * the section .altinstructions, see below). This entry contains
17551@@ -50,7 +89,7 @@
17552 altinstruction_entry 140b,143f,\feature,142b-140b,144f-143f,142b-141b
17553 .popsection
17554
17555- .pushsection .altinstr_replacement,"ax"
17556+ .pushsection .altinstr_replacement,"a"
17557 143:
17558 \newinstr
17559 144:
17560@@ -86,7 +125,7 @@
17561 altinstruction_entry 140b,144f,\feature2,142b-140b,145f-144f,142b-141b
17562 .popsection
17563
17564- .pushsection .altinstr_replacement,"ax"
17565+ .pushsection .altinstr_replacement,"a"
17566 143:
17567 \newinstr1
17568 144:
17569diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
17570index 7bfc85b..65d1ec4 100644
17571--- a/arch/x86/include/asm/alternative.h
17572+++ b/arch/x86/include/asm/alternative.h
17573@@ -136,7 +136,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
17574 ".pushsection .altinstructions,\"a\"\n" \
17575 ALTINSTR_ENTRY(feature, 1) \
17576 ".popsection\n" \
17577- ".pushsection .altinstr_replacement, \"ax\"\n" \
17578+ ".pushsection .altinstr_replacement, \"a\"\n" \
17579 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
17580 ".popsection"
17581
17582@@ -146,7 +146,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
17583 ALTINSTR_ENTRY(feature1, 1) \
17584 ALTINSTR_ENTRY(feature2, 2) \
17585 ".popsection\n" \
17586- ".pushsection .altinstr_replacement, \"ax\"\n" \
17587+ ".pushsection .altinstr_replacement, \"a\"\n" \
17588 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
17589 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
17590 ".popsection"
17591diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
17592index c839363..b9a8c43 100644
17593--- a/arch/x86/include/asm/apic.h
17594+++ b/arch/x86/include/asm/apic.h
17595@@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
17596
17597 #ifdef CONFIG_X86_LOCAL_APIC
17598
17599-extern unsigned int apic_verbosity;
17600+extern int apic_verbosity;
17601 extern int local_apic_timer_c2_ok;
17602
17603 extern int disable_apic;
17604diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
17605index 20370c6..a2eb9b0 100644
17606--- a/arch/x86/include/asm/apm.h
17607+++ b/arch/x86/include/asm/apm.h
17608@@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
17609 __asm__ __volatile__(APM_DO_ZERO_SEGS
17610 "pushl %%edi\n\t"
17611 "pushl %%ebp\n\t"
17612- "lcall *%%cs:apm_bios_entry\n\t"
17613+ "lcall *%%ss:apm_bios_entry\n\t"
17614 "setc %%al\n\t"
17615 "popl %%ebp\n\t"
17616 "popl %%edi\n\t"
17617@@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
17618 __asm__ __volatile__(APM_DO_ZERO_SEGS
17619 "pushl %%edi\n\t"
17620 "pushl %%ebp\n\t"
17621- "lcall *%%cs:apm_bios_entry\n\t"
17622+ "lcall *%%ss:apm_bios_entry\n\t"
17623 "setc %%bl\n\t"
17624 "popl %%ebp\n\t"
17625 "popl %%edi\n\t"
17626diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
17627index e916895..42d729d 100644
17628--- a/arch/x86/include/asm/atomic.h
17629+++ b/arch/x86/include/asm/atomic.h
17630@@ -28,6 +28,17 @@ static __always_inline int atomic_read(const atomic_t *v)
17631 }
17632
17633 /**
17634+ * atomic_read_unchecked - read atomic variable
17635+ * @v: pointer of type atomic_unchecked_t
17636+ *
17637+ * Atomically reads the value of @v.
17638+ */
17639+static __always_inline int __intentional_overflow(-1) atomic_read_unchecked(const atomic_unchecked_t *v)
17640+{
17641+ return ACCESS_ONCE((v)->counter);
17642+}
17643+
17644+/**
17645 * atomic_set - set atomic variable
17646 * @v: pointer of type atomic_t
17647 * @i: required value
17648@@ -40,6 +51,18 @@ static __always_inline void atomic_set(atomic_t *v, int i)
17649 }
17650
17651 /**
17652+ * atomic_set_unchecked - set atomic variable
17653+ * @v: pointer of type atomic_unchecked_t
17654+ * @i: required value
17655+ *
17656+ * Atomically sets the value of @v to @i.
17657+ */
17658+static __always_inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
17659+{
17660+ v->counter = i;
17661+}
17662+
17663+/**
17664 * atomic_add - add integer to atomic variable
17665 * @i: integer value to add
17666 * @v: pointer of type atomic_t
17667@@ -48,7 +71,29 @@ static __always_inline void atomic_set(atomic_t *v, int i)
17668 */
17669 static __always_inline void atomic_add(int i, atomic_t *v)
17670 {
17671- asm volatile(LOCK_PREFIX "addl %1,%0"
17672+ asm volatile(LOCK_PREFIX "addl %1,%0\n"
17673+
17674+#ifdef CONFIG_PAX_REFCOUNT
17675+ "jno 0f\n"
17676+ LOCK_PREFIX "subl %1,%0\n"
17677+ "int $4\n0:\n"
17678+ _ASM_EXTABLE(0b, 0b)
17679+#endif
17680+
17681+ : "+m" (v->counter)
17682+ : "ir" (i));
17683+}
17684+
17685+/**
17686+ * atomic_add_unchecked - add integer to atomic variable
17687+ * @i: integer value to add
17688+ * @v: pointer of type atomic_unchecked_t
17689+ *
17690+ * Atomically adds @i to @v.
17691+ */
17692+static __always_inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
17693+{
17694+ asm volatile(LOCK_PREFIX "addl %1,%0\n"
17695 : "+m" (v->counter)
17696 : "ir" (i));
17697 }
17698@@ -62,7 +107,29 @@ static __always_inline void atomic_add(int i, atomic_t *v)
17699 */
17700 static __always_inline void atomic_sub(int i, atomic_t *v)
17701 {
17702- asm volatile(LOCK_PREFIX "subl %1,%0"
17703+ asm volatile(LOCK_PREFIX "subl %1,%0\n"
17704+
17705+#ifdef CONFIG_PAX_REFCOUNT
17706+ "jno 0f\n"
17707+ LOCK_PREFIX "addl %1,%0\n"
17708+ "int $4\n0:\n"
17709+ _ASM_EXTABLE(0b, 0b)
17710+#endif
17711+
17712+ : "+m" (v->counter)
17713+ : "ir" (i));
17714+}
17715+
17716+/**
17717+ * atomic_sub_unchecked - subtract integer from atomic variable
17718+ * @i: integer value to subtract
17719+ * @v: pointer of type atomic_unchecked_t
17720+ *
17721+ * Atomically subtracts @i from @v.
17722+ */
17723+static __always_inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
17724+{
17725+ asm volatile(LOCK_PREFIX "subl %1,%0\n"
17726 : "+m" (v->counter)
17727 : "ir" (i));
17728 }
17729@@ -78,7 +145,7 @@ static __always_inline void atomic_sub(int i, atomic_t *v)
17730 */
17731 static __always_inline int atomic_sub_and_test(int i, atomic_t *v)
17732 {
17733- GEN_BINARY_RMWcc(LOCK_PREFIX "subl", v->counter, "er", i, "%0", "e");
17734+ GEN_BINARY_RMWcc(LOCK_PREFIX "subl", LOCK_PREFIX "addl", v->counter, "er", i, "%0", "e");
17735 }
17736
17737 /**
17738@@ -89,7 +156,27 @@ static __always_inline int atomic_sub_and_test(int i, atomic_t *v)
17739 */
17740 static __always_inline void atomic_inc(atomic_t *v)
17741 {
17742- asm volatile(LOCK_PREFIX "incl %0"
17743+ asm volatile(LOCK_PREFIX "incl %0\n"
17744+
17745+#ifdef CONFIG_PAX_REFCOUNT
17746+ "jno 0f\n"
17747+ LOCK_PREFIX "decl %0\n"
17748+ "int $4\n0:\n"
17749+ _ASM_EXTABLE(0b, 0b)
17750+#endif
17751+
17752+ : "+m" (v->counter));
17753+}
17754+
17755+/**
17756+ * atomic_inc_unchecked - increment atomic variable
17757+ * @v: pointer of type atomic_unchecked_t
17758+ *
17759+ * Atomically increments @v by 1.
17760+ */
17761+static __always_inline void atomic_inc_unchecked(atomic_unchecked_t *v)
17762+{
17763+ asm volatile(LOCK_PREFIX "incl %0\n"
17764 : "+m" (v->counter));
17765 }
17766
17767@@ -101,7 +188,27 @@ static __always_inline void atomic_inc(atomic_t *v)
17768 */
17769 static __always_inline void atomic_dec(atomic_t *v)
17770 {
17771- asm volatile(LOCK_PREFIX "decl %0"
17772+ asm volatile(LOCK_PREFIX "decl %0\n"
17773+
17774+#ifdef CONFIG_PAX_REFCOUNT
17775+ "jno 0f\n"
17776+ LOCK_PREFIX "incl %0\n"
17777+ "int $4\n0:\n"
17778+ _ASM_EXTABLE(0b, 0b)
17779+#endif
17780+
17781+ : "+m" (v->counter));
17782+}
17783+
17784+/**
17785+ * atomic_dec_unchecked - decrement atomic variable
17786+ * @v: pointer of type atomic_unchecked_t
17787+ *
17788+ * Atomically decrements @v by 1.
17789+ */
17790+static __always_inline void atomic_dec_unchecked(atomic_unchecked_t *v)
17791+{
17792+ asm volatile(LOCK_PREFIX "decl %0\n"
17793 : "+m" (v->counter));
17794 }
17795
17796@@ -115,7 +222,7 @@ static __always_inline void atomic_dec(atomic_t *v)
17797 */
17798 static __always_inline int atomic_dec_and_test(atomic_t *v)
17799 {
17800- GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", "e");
17801+ GEN_UNARY_RMWcc(LOCK_PREFIX "decl", LOCK_PREFIX "incl", v->counter, "%0", "e");
17802 }
17803
17804 /**
17805@@ -128,7 +235,20 @@ static __always_inline int atomic_dec_and_test(atomic_t *v)
17806 */
17807 static __always_inline int atomic_inc_and_test(atomic_t *v)
17808 {
17809- GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, "%0", "e");
17810+ GEN_UNARY_RMWcc(LOCK_PREFIX "incl", LOCK_PREFIX "decl", v->counter, "%0", "e");
17811+}
17812+
17813+/**
17814+ * atomic_inc_and_test_unchecked - increment and test
17815+ * @v: pointer of type atomic_unchecked_t
17816+ *
17817+ * Atomically increments @v by 1
17818+ * and returns true if the result is zero, or false for all
17819+ * other cases.
17820+ */
17821+static __always_inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
17822+{
17823+ GEN_UNARY_RMWcc_unchecked(LOCK_PREFIX "incl", v->counter, "%0", "e");
17824 }
17825
17826 /**
17827@@ -142,7 +262,7 @@ static __always_inline int atomic_inc_and_test(atomic_t *v)
17828 */
17829 static __always_inline int atomic_add_negative(int i, atomic_t *v)
17830 {
17831- GEN_BINARY_RMWcc(LOCK_PREFIX "addl", v->counter, "er", i, "%0", "s");
17832+ GEN_BINARY_RMWcc(LOCK_PREFIX "addl", LOCK_PREFIX "subl", v->counter, "er", i, "%0", "s");
17833 }
17834
17835 /**
17836@@ -152,7 +272,19 @@ static __always_inline int atomic_add_negative(int i, atomic_t *v)
17837 *
17838 * Atomically adds @i to @v and returns @i + @v
17839 */
17840-static __always_inline int atomic_add_return(int i, atomic_t *v)
17841+static __always_inline int __intentional_overflow(-1) atomic_add_return(int i, atomic_t *v)
17842+{
17843+ return i + xadd_check_overflow(&v->counter, i);
17844+}
17845+
17846+/**
17847+ * atomic_add_return_unchecked - add integer and return
17848+ * @i: integer value to add
17849+ * @v: pointer of type atomi_uncheckedc_t
17850+ *
17851+ * Atomically adds @i to @v and returns @i + @v
17852+ */
17853+static __always_inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
17854 {
17855 return i + xadd(&v->counter, i);
17856 }
17857@@ -164,15 +296,24 @@ static __always_inline int atomic_add_return(int i, atomic_t *v)
17858 *
17859 * Atomically subtracts @i from @v and returns @v - @i
17860 */
17861-static __always_inline int atomic_sub_return(int i, atomic_t *v)
17862+static __always_inline int __intentional_overflow(-1) atomic_sub_return(int i, atomic_t *v)
17863 {
17864 return atomic_add_return(-i, v);
17865 }
17866
17867 #define atomic_inc_return(v) (atomic_add_return(1, v))
17868+static __always_inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
17869+{
17870+ return atomic_add_return_unchecked(1, v);
17871+}
17872 #define atomic_dec_return(v) (atomic_sub_return(1, v))
17873
17874-static __always_inline int atomic_cmpxchg(atomic_t *v, int old, int new)
17875+static __always_inline int __intentional_overflow(-1) atomic_cmpxchg(atomic_t *v, int old, int new)
17876+{
17877+ return cmpxchg(&v->counter, old, new);
17878+}
17879+
17880+static __always_inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
17881 {
17882 return cmpxchg(&v->counter, old, new);
17883 }
17884@@ -182,6 +323,11 @@ static inline int atomic_xchg(atomic_t *v, int new)
17885 return xchg(&v->counter, new);
17886 }
17887
17888+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
17889+{
17890+ return xchg(&v->counter, new);
17891+}
17892+
17893 /**
17894 * __atomic_add_unless - add unless the number is already a given value
17895 * @v: pointer of type atomic_t
17896@@ -193,12 +339,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
17897 */
17898 static __always_inline int __atomic_add_unless(atomic_t *v, int a, int u)
17899 {
17900- int c, old;
17901+ int c, old, new;
17902 c = atomic_read(v);
17903 for (;;) {
17904- if (unlikely(c == (u)))
17905+ if (unlikely(c == u))
17906 break;
17907- old = atomic_cmpxchg((v), c, c + (a));
17908+
17909+ asm volatile("addl %2,%0\n"
17910+
17911+#ifdef CONFIG_PAX_REFCOUNT
17912+ "jno 0f\n"
17913+ "subl %2,%0\n"
17914+ "int $4\n0:\n"
17915+ _ASM_EXTABLE(0b, 0b)
17916+#endif
17917+
17918+ : "=r" (new)
17919+ : "0" (c), "ir" (a));
17920+
17921+ old = atomic_cmpxchg(v, c, new);
17922 if (likely(old == c))
17923 break;
17924 c = old;
17925@@ -207,6 +366,49 @@ static __always_inline int __atomic_add_unless(atomic_t *v, int a, int u)
17926 }
17927
17928 /**
17929+ * atomic_inc_not_zero_hint - increment if not null
17930+ * @v: pointer of type atomic_t
17931+ * @hint: probable value of the atomic before the increment
17932+ *
17933+ * This version of atomic_inc_not_zero() gives a hint of probable
17934+ * value of the atomic. This helps processor to not read the memory
17935+ * before doing the atomic read/modify/write cycle, lowering
17936+ * number of bus transactions on some arches.
17937+ *
17938+ * Returns: 0 if increment was not done, 1 otherwise.
17939+ */
17940+#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
17941+static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
17942+{
17943+ int val, c = hint, new;
17944+
17945+ /* sanity test, should be removed by compiler if hint is a constant */
17946+ if (!hint)
17947+ return __atomic_add_unless(v, 1, 0);
17948+
17949+ do {
17950+ asm volatile("incl %0\n"
17951+
17952+#ifdef CONFIG_PAX_REFCOUNT
17953+ "jno 0f\n"
17954+ "decl %0\n"
17955+ "int $4\n0:\n"
17956+ _ASM_EXTABLE(0b, 0b)
17957+#endif
17958+
17959+ : "=r" (new)
17960+ : "0" (c));
17961+
17962+ val = atomic_cmpxchg(v, c, new);
17963+ if (val == c)
17964+ return 1;
17965+ c = val;
17966+ } while (c);
17967+
17968+ return 0;
17969+}
17970+
17971+/**
17972 * atomic_inc_short - increment of a short integer
17973 * @v: pointer to type int
17974 *
17975@@ -220,14 +422,37 @@ static __always_inline short int atomic_inc_short(short int *v)
17976 }
17977
17978 /* These are x86-specific, used by some header files */
17979-#define atomic_clear_mask(mask, addr) \
17980- asm volatile(LOCK_PREFIX "andl %0,%1" \
17981- : : "r" (~(mask)), "m" (*(addr)) : "memory")
17982+static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
17983+{
17984+ asm volatile(LOCK_PREFIX "andl %1,%0"
17985+ : "+m" (v->counter)
17986+ : "r" (~(mask))
17987+ : "memory");
17988+}
17989
17990-#define atomic_set_mask(mask, addr) \
17991- asm volatile(LOCK_PREFIX "orl %0,%1" \
17992- : : "r" ((unsigned)(mask)), "m" (*(addr)) \
17993- : "memory")
17994+static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
17995+{
17996+ asm volatile(LOCK_PREFIX "andl %1,%0"
17997+ : "+m" (v->counter)
17998+ : "r" (~(mask))
17999+ : "memory");
18000+}
18001+
18002+static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
18003+{
18004+ asm volatile(LOCK_PREFIX "orl %1,%0"
18005+ : "+m" (v->counter)
18006+ : "r" (mask)
18007+ : "memory");
18008+}
18009+
18010+static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
18011+{
18012+ asm volatile(LOCK_PREFIX "orl %1,%0"
18013+ : "+m" (v->counter)
18014+ : "r" (mask)
18015+ : "memory");
18016+}
18017
18018 #ifdef CONFIG_X86_32
18019 # include <asm/atomic64_32.h>
18020diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
18021index b154de7..3dc335d 100644
18022--- a/arch/x86/include/asm/atomic64_32.h
18023+++ b/arch/x86/include/asm/atomic64_32.h
18024@@ -12,6 +12,14 @@ typedef struct {
18025 u64 __aligned(8) counter;
18026 } atomic64_t;
18027
18028+#ifdef CONFIG_PAX_REFCOUNT
18029+typedef struct {
18030+ u64 __aligned(8) counter;
18031+} atomic64_unchecked_t;
18032+#else
18033+typedef atomic64_t atomic64_unchecked_t;
18034+#endif
18035+
18036 #define ATOMIC64_INIT(val) { (val) }
18037
18038 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
18039@@ -37,21 +45,31 @@ typedef struct {
18040 ATOMIC64_DECL_ONE(sym##_386)
18041
18042 ATOMIC64_DECL_ONE(add_386);
18043+ATOMIC64_DECL_ONE(add_unchecked_386);
18044 ATOMIC64_DECL_ONE(sub_386);
18045+ATOMIC64_DECL_ONE(sub_unchecked_386);
18046 ATOMIC64_DECL_ONE(inc_386);
18047+ATOMIC64_DECL_ONE(inc_unchecked_386);
18048 ATOMIC64_DECL_ONE(dec_386);
18049+ATOMIC64_DECL_ONE(dec_unchecked_386);
18050 #endif
18051
18052 #define alternative_atomic64(f, out, in...) \
18053 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
18054
18055 ATOMIC64_DECL(read);
18056+ATOMIC64_DECL(read_unchecked);
18057 ATOMIC64_DECL(set);
18058+ATOMIC64_DECL(set_unchecked);
18059 ATOMIC64_DECL(xchg);
18060 ATOMIC64_DECL(add_return);
18061+ATOMIC64_DECL(add_return_unchecked);
18062 ATOMIC64_DECL(sub_return);
18063+ATOMIC64_DECL(sub_return_unchecked);
18064 ATOMIC64_DECL(inc_return);
18065+ATOMIC64_DECL(inc_return_unchecked);
18066 ATOMIC64_DECL(dec_return);
18067+ATOMIC64_DECL(dec_return_unchecked);
18068 ATOMIC64_DECL(dec_if_positive);
18069 ATOMIC64_DECL(inc_not_zero);
18070 ATOMIC64_DECL(add_unless);
18071@@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
18072 }
18073
18074 /**
18075+ * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
18076+ * @p: pointer to type atomic64_unchecked_t
18077+ * @o: expected value
18078+ * @n: new value
18079+ *
18080+ * Atomically sets @v to @n if it was equal to @o and returns
18081+ * the old value.
18082+ */
18083+
18084+static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
18085+{
18086+ return cmpxchg64(&v->counter, o, n);
18087+}
18088+
18089+/**
18090 * atomic64_xchg - xchg atomic64 variable
18091 * @v: pointer to type atomic64_t
18092 * @n: value to assign
18093@@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
18094 }
18095
18096 /**
18097+ * atomic64_set_unchecked - set atomic64 variable
18098+ * @v: pointer to type atomic64_unchecked_t
18099+ * @n: value to assign
18100+ *
18101+ * Atomically sets the value of @v to @n.
18102+ */
18103+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
18104+{
18105+ unsigned high = (unsigned)(i >> 32);
18106+ unsigned low = (unsigned)i;
18107+ alternative_atomic64(set, /* no output */,
18108+ "S" (v), "b" (low), "c" (high)
18109+ : "eax", "edx", "memory");
18110+}
18111+
18112+/**
18113 * atomic64_read - read atomic64 variable
18114 * @v: pointer to type atomic64_t
18115 *
18116@@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
18117 }
18118
18119 /**
18120+ * atomic64_read_unchecked - read atomic64 variable
18121+ * @v: pointer to type atomic64_unchecked_t
18122+ *
18123+ * Atomically reads the value of @v and returns it.
18124+ */
18125+static inline long long __intentional_overflow(-1) atomic64_read_unchecked(const atomic64_unchecked_t *v)
18126+{
18127+ long long r;
18128+ alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
18129+ return r;
18130+ }
18131+
18132+/**
18133 * atomic64_add_return - add and return
18134 * @i: integer value to add
18135 * @v: pointer to type atomic64_t
18136@@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
18137 return i;
18138 }
18139
18140+/**
18141+ * atomic64_add_return_unchecked - add and return
18142+ * @i: integer value to add
18143+ * @v: pointer to type atomic64_unchecked_t
18144+ *
18145+ * Atomically adds @i to @v and returns @i + *@v
18146+ */
18147+static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
18148+{
18149+ alternative_atomic64(add_return_unchecked,
18150+ ASM_OUTPUT2("+A" (i), "+c" (v)),
18151+ ASM_NO_INPUT_CLOBBER("memory"));
18152+ return i;
18153+}
18154+
18155 /*
18156 * Other variants with different arithmetic operators:
18157 */
18158@@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
18159 return a;
18160 }
18161
18162+static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
18163+{
18164+ long long a;
18165+ alternative_atomic64(inc_return_unchecked, "=&A" (a),
18166+ "S" (v) : "memory", "ecx");
18167+ return a;
18168+}
18169+
18170 static inline long long atomic64_dec_return(atomic64_t *v)
18171 {
18172 long long a;
18173@@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
18174 }
18175
18176 /**
18177+ * atomic64_add_unchecked - add integer to atomic64 variable
18178+ * @i: integer value to add
18179+ * @v: pointer to type atomic64_unchecked_t
18180+ *
18181+ * Atomically adds @i to @v.
18182+ */
18183+static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
18184+{
18185+ __alternative_atomic64(add_unchecked, add_return_unchecked,
18186+ ASM_OUTPUT2("+A" (i), "+c" (v)),
18187+ ASM_NO_INPUT_CLOBBER("memory"));
18188+ return i;
18189+}
18190+
18191+/**
18192 * atomic64_sub - subtract the atomic64 variable
18193 * @i: integer value to subtract
18194 * @v: pointer to type atomic64_t
18195diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
18196index b965f9e..8e22dd3 100644
18197--- a/arch/x86/include/asm/atomic64_64.h
18198+++ b/arch/x86/include/asm/atomic64_64.h
18199@@ -22,6 +22,18 @@ static inline long atomic64_read(const atomic64_t *v)
18200 }
18201
18202 /**
18203+ * atomic64_read_unchecked - read atomic64 variable
18204+ * @v: pointer of type atomic64_unchecked_t
18205+ *
18206+ * Atomically reads the value of @v.
18207+ * Doesn't imply a read memory barrier.
18208+ */
18209+static inline long __intentional_overflow(-1) atomic64_read_unchecked(const atomic64_unchecked_t *v)
18210+{
18211+ return ACCESS_ONCE((v)->counter);
18212+}
18213+
18214+/**
18215 * atomic64_set - set atomic64 variable
18216 * @v: pointer to type atomic64_t
18217 * @i: required value
18218@@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
18219 }
18220
18221 /**
18222+ * atomic64_set_unchecked - set atomic64 variable
18223+ * @v: pointer to type atomic64_unchecked_t
18224+ * @i: required value
18225+ *
18226+ * Atomically sets the value of @v to @i.
18227+ */
18228+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
18229+{
18230+ v->counter = i;
18231+}
18232+
18233+/**
18234 * atomic64_add - add integer to atomic64 variable
18235 * @i: integer value to add
18236 * @v: pointer to type atomic64_t
18237@@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
18238 */
18239 static __always_inline void atomic64_add(long i, atomic64_t *v)
18240 {
18241+ asm volatile(LOCK_PREFIX "addq %1,%0\n"
18242+
18243+#ifdef CONFIG_PAX_REFCOUNT
18244+ "jno 0f\n"
18245+ LOCK_PREFIX "subq %1,%0\n"
18246+ "int $4\n0:\n"
18247+ _ASM_EXTABLE(0b, 0b)
18248+#endif
18249+
18250+ : "=m" (v->counter)
18251+ : "er" (i), "m" (v->counter));
18252+}
18253+
18254+/**
18255+ * atomic64_add_unchecked - add integer to atomic64 variable
18256+ * @i: integer value to add
18257+ * @v: pointer to type atomic64_unchecked_t
18258+ *
18259+ * Atomically adds @i to @v.
18260+ */
18261+static __always_inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
18262+{
18263 asm volatile(LOCK_PREFIX "addq %1,%0"
18264 : "=m" (v->counter)
18265 : "er" (i), "m" (v->counter));
18266@@ -56,7 +102,29 @@ static __always_inline void atomic64_add(long i, atomic64_t *v)
18267 */
18268 static inline void atomic64_sub(long i, atomic64_t *v)
18269 {
18270- asm volatile(LOCK_PREFIX "subq %1,%0"
18271+ asm volatile(LOCK_PREFIX "subq %1,%0\n"
18272+
18273+#ifdef CONFIG_PAX_REFCOUNT
18274+ "jno 0f\n"
18275+ LOCK_PREFIX "addq %1,%0\n"
18276+ "int $4\n0:\n"
18277+ _ASM_EXTABLE(0b, 0b)
18278+#endif
18279+
18280+ : "=m" (v->counter)
18281+ : "er" (i), "m" (v->counter));
18282+}
18283+
18284+/**
18285+ * atomic64_sub_unchecked - subtract the atomic64 variable
18286+ * @i: integer value to subtract
18287+ * @v: pointer to type atomic64_unchecked_t
18288+ *
18289+ * Atomically subtracts @i from @v.
18290+ */
18291+static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
18292+{
18293+ asm volatile(LOCK_PREFIX "subq %1,%0\n"
18294 : "=m" (v->counter)
18295 : "er" (i), "m" (v->counter));
18296 }
18297@@ -72,7 +140,7 @@ static inline void atomic64_sub(long i, atomic64_t *v)
18298 */
18299 static inline int atomic64_sub_and_test(long i, atomic64_t *v)
18300 {
18301- GEN_BINARY_RMWcc(LOCK_PREFIX "subq", v->counter, "er", i, "%0", "e");
18302+ GEN_BINARY_RMWcc(LOCK_PREFIX "subq", LOCK_PREFIX "addq", v->counter, "er", i, "%0", "e");
18303 }
18304
18305 /**
18306@@ -83,6 +151,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
18307 */
18308 static __always_inline void atomic64_inc(atomic64_t *v)
18309 {
18310+ asm volatile(LOCK_PREFIX "incq %0\n"
18311+
18312+#ifdef CONFIG_PAX_REFCOUNT
18313+ "jno 0f\n"
18314+ LOCK_PREFIX "decq %0\n"
18315+ "int $4\n0:\n"
18316+ _ASM_EXTABLE(0b, 0b)
18317+#endif
18318+
18319+ : "=m" (v->counter)
18320+ : "m" (v->counter));
18321+}
18322+
18323+/**
18324+ * atomic64_inc_unchecked - increment atomic64 variable
18325+ * @v: pointer to type atomic64_unchecked_t
18326+ *
18327+ * Atomically increments @v by 1.
18328+ */
18329+static __always_inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
18330+{
18331 asm volatile(LOCK_PREFIX "incq %0"
18332 : "=m" (v->counter)
18333 : "m" (v->counter));
18334@@ -96,7 +185,28 @@ static __always_inline void atomic64_inc(atomic64_t *v)
18335 */
18336 static __always_inline void atomic64_dec(atomic64_t *v)
18337 {
18338- asm volatile(LOCK_PREFIX "decq %0"
18339+ asm volatile(LOCK_PREFIX "decq %0\n"
18340+
18341+#ifdef CONFIG_PAX_REFCOUNT
18342+ "jno 0f\n"
18343+ LOCK_PREFIX "incq %0\n"
18344+ "int $4\n0:\n"
18345+ _ASM_EXTABLE(0b, 0b)
18346+#endif
18347+
18348+ : "=m" (v->counter)
18349+ : "m" (v->counter));
18350+}
18351+
18352+/**
18353+ * atomic64_dec_unchecked - decrement atomic64 variable
18354+ * @v: pointer to type atomic64_t
18355+ *
18356+ * Atomically decrements @v by 1.
18357+ */
18358+static __always_inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
18359+{
18360+ asm volatile(LOCK_PREFIX "decq %0\n"
18361 : "=m" (v->counter)
18362 : "m" (v->counter));
18363 }
18364@@ -111,7 +221,7 @@ static __always_inline void atomic64_dec(atomic64_t *v)
18365 */
18366 static inline int atomic64_dec_and_test(atomic64_t *v)
18367 {
18368- GEN_UNARY_RMWcc(LOCK_PREFIX "decq", v->counter, "%0", "e");
18369+ GEN_UNARY_RMWcc(LOCK_PREFIX "decq", LOCK_PREFIX "incq", v->counter, "%0", "e");
18370 }
18371
18372 /**
18373@@ -124,7 +234,7 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
18374 */
18375 static inline int atomic64_inc_and_test(atomic64_t *v)
18376 {
18377- GEN_UNARY_RMWcc(LOCK_PREFIX "incq", v->counter, "%0", "e");
18378+ GEN_UNARY_RMWcc(LOCK_PREFIX "incq", LOCK_PREFIX "decq", v->counter, "%0", "e");
18379 }
18380
18381 /**
18382@@ -138,7 +248,7 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
18383 */
18384 static inline int atomic64_add_negative(long i, atomic64_t *v)
18385 {
18386- GEN_BINARY_RMWcc(LOCK_PREFIX "addq", v->counter, "er", i, "%0", "s");
18387+ GEN_BINARY_RMWcc(LOCK_PREFIX "addq", LOCK_PREFIX "subq", v->counter, "er", i, "%0", "s");
18388 }
18389
18390 /**
18391@@ -150,6 +260,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
18392 */
18393 static __always_inline long atomic64_add_return(long i, atomic64_t *v)
18394 {
18395+ return i + xadd_check_overflow(&v->counter, i);
18396+}
18397+
18398+/**
18399+ * atomic64_add_return_unchecked - add and return
18400+ * @i: integer value to add
18401+ * @v: pointer to type atomic64_unchecked_t
18402+ *
18403+ * Atomically adds @i to @v and returns @i + @v
18404+ */
18405+static __always_inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
18406+{
18407 return i + xadd(&v->counter, i);
18408 }
18409
18410@@ -159,6 +281,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
18411 }
18412
18413 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
18414+static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
18415+{
18416+ return atomic64_add_return_unchecked(1, v);
18417+}
18418 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
18419
18420 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
18421@@ -166,6 +292,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
18422 return cmpxchg(&v->counter, old, new);
18423 }
18424
18425+static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
18426+{
18427+ return cmpxchg(&v->counter, old, new);
18428+}
18429+
18430 static inline long atomic64_xchg(atomic64_t *v, long new)
18431 {
18432 return xchg(&v->counter, new);
18433@@ -182,17 +313,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
18434 */
18435 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
18436 {
18437- long c, old;
18438+ long c, old, new;
18439 c = atomic64_read(v);
18440 for (;;) {
18441- if (unlikely(c == (u)))
18442+ if (unlikely(c == u))
18443 break;
18444- old = atomic64_cmpxchg((v), c, c + (a));
18445+
18446+ asm volatile("add %2,%0\n"
18447+
18448+#ifdef CONFIG_PAX_REFCOUNT
18449+ "jno 0f\n"
18450+ "sub %2,%0\n"
18451+ "int $4\n0:\n"
18452+ _ASM_EXTABLE(0b, 0b)
18453+#endif
18454+
18455+ : "=r" (new)
18456+ : "0" (c), "ir" (a));
18457+
18458+ old = atomic64_cmpxchg(v, c, new);
18459 if (likely(old == c))
18460 break;
18461 c = old;
18462 }
18463- return c != (u);
18464+ return c != u;
18465 }
18466
18467 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
18468diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
18469index e51a8f8..ee075df 100644
18470--- a/arch/x86/include/asm/barrier.h
18471+++ b/arch/x86/include/asm/barrier.h
18472@@ -57,7 +57,7 @@
18473 do { \
18474 compiletime_assert_atomic_type(*p); \
18475 smp_mb(); \
18476- ACCESS_ONCE(*p) = (v); \
18477+ ACCESS_ONCE_RW(*p) = (v); \
18478 } while (0)
18479
18480 #define smp_load_acquire(p) \
18481@@ -74,7 +74,7 @@ do { \
18482 do { \
18483 compiletime_assert_atomic_type(*p); \
18484 barrier(); \
18485- ACCESS_ONCE(*p) = (v); \
18486+ ACCESS_ONCE_RW(*p) = (v); \
18487 } while (0)
18488
18489 #define smp_load_acquire(p) \
18490diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
18491index cfe3b95..d01b118 100644
18492--- a/arch/x86/include/asm/bitops.h
18493+++ b/arch/x86/include/asm/bitops.h
18494@@ -50,7 +50,7 @@
18495 * a mask operation on a byte.
18496 */
18497 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
18498-#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
18499+#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
18500 #define CONST_MASK(nr) (1 << ((nr) & 7))
18501
18502 /**
18503@@ -203,7 +203,7 @@ static inline void change_bit(long nr, volatile unsigned long *addr)
18504 */
18505 static inline int test_and_set_bit(long nr, volatile unsigned long *addr)
18506 {
18507- GEN_BINARY_RMWcc(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", "c");
18508+ GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", "c");
18509 }
18510
18511 /**
18512@@ -249,7 +249,7 @@ static inline int __test_and_set_bit(long nr, volatile unsigned long *addr)
18513 */
18514 static inline int test_and_clear_bit(long nr, volatile unsigned long *addr)
18515 {
18516- GEN_BINARY_RMWcc(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", "c");
18517+ GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", "c");
18518 }
18519
18520 /**
18521@@ -302,7 +302,7 @@ static inline int __test_and_change_bit(long nr, volatile unsigned long *addr)
18522 */
18523 static inline int test_and_change_bit(long nr, volatile unsigned long *addr)
18524 {
18525- GEN_BINARY_RMWcc(LOCK_PREFIX "btc", *addr, "Ir", nr, "%0", "c");
18526+ GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "btc", *addr, "Ir", nr, "%0", "c");
18527 }
18528
18529 static __always_inline int constant_test_bit(long nr, const volatile unsigned long *addr)
18530@@ -343,7 +343,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
18531 *
18532 * Undefined if no bit exists, so code should check against 0 first.
18533 */
18534-static inline unsigned long __ffs(unsigned long word)
18535+static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
18536 {
18537 asm("rep; bsf %1,%0"
18538 : "=r" (word)
18539@@ -357,7 +357,7 @@ static inline unsigned long __ffs(unsigned long word)
18540 *
18541 * Undefined if no zero exists, so code should check against ~0UL first.
18542 */
18543-static inline unsigned long ffz(unsigned long word)
18544+static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
18545 {
18546 asm("rep; bsf %1,%0"
18547 : "=r" (word)
18548@@ -371,7 +371,7 @@ static inline unsigned long ffz(unsigned long word)
18549 *
18550 * Undefined if no set bit exists, so code should check against 0 first.
18551 */
18552-static inline unsigned long __fls(unsigned long word)
18553+static inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
18554 {
18555 asm("bsr %1,%0"
18556 : "=r" (word)
18557@@ -434,7 +434,7 @@ static inline int ffs(int x)
18558 * set bit if value is nonzero. The last (most significant) bit is
18559 * at position 32.
18560 */
18561-static inline int fls(int x)
18562+static inline int __intentional_overflow(-1) fls(int x)
18563 {
18564 int r;
18565
18566@@ -476,7 +476,7 @@ static inline int fls(int x)
18567 * at position 64.
18568 */
18569 #ifdef CONFIG_X86_64
18570-static __always_inline int fls64(__u64 x)
18571+static __always_inline __intentional_overflow(-1) int fls64(__u64 x)
18572 {
18573 int bitpos = -1;
18574 /*
18575diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
18576index 4fa687a..4ca636f 100644
18577--- a/arch/x86/include/asm/boot.h
18578+++ b/arch/x86/include/asm/boot.h
18579@@ -6,7 +6,7 @@
18580 #include <uapi/asm/boot.h>
18581
18582 /* Physical address where kernel should be loaded. */
18583-#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
18584+#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
18585 + (CONFIG_PHYSICAL_ALIGN - 1)) \
18586 & ~(CONFIG_PHYSICAL_ALIGN - 1))
18587
18588diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
18589index 48f99f1..d78ebf9 100644
18590--- a/arch/x86/include/asm/cache.h
18591+++ b/arch/x86/include/asm/cache.h
18592@@ -5,12 +5,13 @@
18593
18594 /* L1 cache line size */
18595 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
18596-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
18597+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
18598
18599 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
18600+#define __read_only __attribute__((__section__(".data..read_only")))
18601
18602 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
18603-#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
18604+#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
18605
18606 #ifdef CONFIG_X86_VSMP
18607 #ifdef CONFIG_SMP
18608diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
18609index f50de69..2b0a458 100644
18610--- a/arch/x86/include/asm/checksum_32.h
18611+++ b/arch/x86/include/asm/checksum_32.h
18612@@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
18613 int len, __wsum sum,
18614 int *src_err_ptr, int *dst_err_ptr);
18615
18616+asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
18617+ int len, __wsum sum,
18618+ int *src_err_ptr, int *dst_err_ptr);
18619+
18620+asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
18621+ int len, __wsum sum,
18622+ int *src_err_ptr, int *dst_err_ptr);
18623+
18624 /*
18625 * Note: when you get a NULL pointer exception here this means someone
18626 * passed in an incorrect kernel address to one of these functions.
18627@@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
18628
18629 might_sleep();
18630 stac();
18631- ret = csum_partial_copy_generic((__force void *)src, dst,
18632+ ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
18633 len, sum, err_ptr, NULL);
18634 clac();
18635
18636@@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
18637 might_sleep();
18638 if (access_ok(VERIFY_WRITE, dst, len)) {
18639 stac();
18640- ret = csum_partial_copy_generic(src, (__force void *)dst,
18641+ ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
18642 len, sum, NULL, err_ptr);
18643 clac();
18644 return ret;
18645diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
18646index ad19841..0784041 100644
18647--- a/arch/x86/include/asm/cmpxchg.h
18648+++ b/arch/x86/include/asm/cmpxchg.h
18649@@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
18650 __compiletime_error("Bad argument size for cmpxchg");
18651 extern void __xadd_wrong_size(void)
18652 __compiletime_error("Bad argument size for xadd");
18653+extern void __xadd_check_overflow_wrong_size(void)
18654+ __compiletime_error("Bad argument size for xadd_check_overflow");
18655 extern void __add_wrong_size(void)
18656 __compiletime_error("Bad argument size for add");
18657+extern void __add_check_overflow_wrong_size(void)
18658+ __compiletime_error("Bad argument size for add_check_overflow");
18659
18660 /*
18661 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
18662@@ -67,6 +71,38 @@ extern void __add_wrong_size(void)
18663 __ret; \
18664 })
18665
18666+#ifdef CONFIG_PAX_REFCOUNT
18667+#define __xchg_op_check_overflow(ptr, arg, op, lock) \
18668+ ({ \
18669+ __typeof__ (*(ptr)) __ret = (arg); \
18670+ switch (sizeof(*(ptr))) { \
18671+ case __X86_CASE_L: \
18672+ asm volatile (lock #op "l %0, %1\n" \
18673+ "jno 0f\n" \
18674+ "mov %0,%1\n" \
18675+ "int $4\n0:\n" \
18676+ _ASM_EXTABLE(0b, 0b) \
18677+ : "+r" (__ret), "+m" (*(ptr)) \
18678+ : : "memory", "cc"); \
18679+ break; \
18680+ case __X86_CASE_Q: \
18681+ asm volatile (lock #op "q %q0, %1\n" \
18682+ "jno 0f\n" \
18683+ "mov %0,%1\n" \
18684+ "int $4\n0:\n" \
18685+ _ASM_EXTABLE(0b, 0b) \
18686+ : "+r" (__ret), "+m" (*(ptr)) \
18687+ : : "memory", "cc"); \
18688+ break; \
18689+ default: \
18690+ __ ## op ## _check_overflow_wrong_size(); \
18691+ } \
18692+ __ret; \
18693+ })
18694+#else
18695+#define __xchg_op_check_overflow(ptr, arg, op, lock) __xchg_op(ptr, arg, op, lock)
18696+#endif
18697+
18698 /*
18699 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
18700 * Since this is generally used to protect other memory information, we
18701@@ -165,6 +201,9 @@ extern void __add_wrong_size(void)
18702 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
18703 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
18704
18705+#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
18706+#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
18707+
18708 #define __add(ptr, inc, lock) \
18709 ({ \
18710 __typeof__ (*(ptr)) __ret = (inc); \
18711diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
18712index acdee09..a553db3 100644
18713--- a/arch/x86/include/asm/compat.h
18714+++ b/arch/x86/include/asm/compat.h
18715@@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
18716 typedef u32 compat_uint_t;
18717 typedef u32 compat_ulong_t;
18718 typedef u64 __attribute__((aligned(4))) compat_u64;
18719-typedef u32 compat_uptr_t;
18720+typedef u32 __user compat_uptr_t;
18721
18722 struct compat_timespec {
18723 compat_time_t tv_sec;
18724diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
18725index 3d6606f..300641d 100644
18726--- a/arch/x86/include/asm/cpufeature.h
18727+++ b/arch/x86/include/asm/cpufeature.h
18728@@ -214,7 +214,8 @@
18729 #define X86_FEATURE_PAUSEFILTER ( 8*32+13) /* AMD filtered pause intercept */
18730 #define X86_FEATURE_PFTHRESHOLD ( 8*32+14) /* AMD pause filter threshold */
18731 #define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer vmmcall to vmcall */
18732-
18733+#define X86_FEATURE_PCIDUDEREF ( 8*32+30) /* PaX PCID based UDEREF */
18734+#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
18735
18736 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
18737 #define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
18738@@ -222,7 +223,7 @@
18739 #define X86_FEATURE_BMI1 ( 9*32+ 3) /* 1st group bit manipulation extensions */
18740 #define X86_FEATURE_HLE ( 9*32+ 4) /* Hardware Lock Elision */
18741 #define X86_FEATURE_AVX2 ( 9*32+ 5) /* AVX2 instructions */
18742-#define X86_FEATURE_SMEP ( 9*32+ 7) /* Supervisor Mode Execution Protection */
18743+#define X86_FEATURE_SMEP ( 9*32+ 7) /* Supervisor Mode Execution Prevention */
18744 #define X86_FEATURE_BMI2 ( 9*32+ 8) /* 2nd group bit manipulation extensions */
18745 #define X86_FEATURE_ERMS ( 9*32+ 9) /* Enhanced REP MOVSB/STOSB */
18746 #define X86_FEATURE_INVPCID ( 9*32+10) /* Invalidate Processor Context ID */
18747@@ -401,6 +402,7 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
18748 #define cpu_has_eager_fpu boot_cpu_has(X86_FEATURE_EAGER_FPU)
18749 #define cpu_has_topoext boot_cpu_has(X86_FEATURE_TOPOEXT)
18750 #define cpu_has_bpext boot_cpu_has(X86_FEATURE_BPEXT)
18751+#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
18752
18753 #if __GNUC__ >= 4
18754 extern void warn_pre_alternatives(void);
18755@@ -454,7 +456,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
18756
18757 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
18758 t_warn:
18759- warn_pre_alternatives();
18760+ if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID && bit != X86_FEATURE_PCIDUDEREF)
18761+ warn_pre_alternatives();
18762 return false;
18763 #endif
18764
18765@@ -475,7 +478,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
18766 ".section .discard,\"aw\",@progbits\n"
18767 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
18768 ".previous\n"
18769- ".section .altinstr_replacement,\"ax\"\n"
18770+ ".section .altinstr_replacement,\"a\"\n"
18771 "3: movb $1,%0\n"
18772 "4:\n"
18773 ".previous\n"
18774@@ -510,7 +513,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
18775 " .byte 5f - 4f\n" /* repl len */
18776 " .byte 3b - 2b\n" /* pad len */
18777 ".previous\n"
18778- ".section .altinstr_replacement,\"ax\"\n"
18779+ ".section .altinstr_replacement,\"a\"\n"
18780 "4: jmp %l[t_no]\n"
18781 "5:\n"
18782 ".previous\n"
18783@@ -545,7 +548,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
18784 ".section .discard,\"aw\",@progbits\n"
18785 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
18786 ".previous\n"
18787- ".section .altinstr_replacement,\"ax\"\n"
18788+ ".section .altinstr_replacement,\"a\"\n"
18789 "3: movb $0,%0\n"
18790 "4:\n"
18791 ".previous\n"
18792@@ -560,7 +563,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
18793 ".section .discard,\"aw\",@progbits\n"
18794 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
18795 ".previous\n"
18796- ".section .altinstr_replacement,\"ax\"\n"
18797+ ".section .altinstr_replacement,\"a\"\n"
18798 "5: movb $1,%0\n"
18799 "6:\n"
18800 ".previous\n"
18801diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
18802index 4e10d73..7319a47 100644
18803--- a/arch/x86/include/asm/desc.h
18804+++ b/arch/x86/include/asm/desc.h
18805@@ -4,6 +4,7 @@
18806 #include <asm/desc_defs.h>
18807 #include <asm/ldt.h>
18808 #include <asm/mmu.h>
18809+#include <asm/pgtable.h>
18810
18811 #include <linux/smp.h>
18812 #include <linux/percpu.h>
18813@@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
18814
18815 desc->type = (info->read_exec_only ^ 1) << 1;
18816 desc->type |= info->contents << 2;
18817+ desc->type |= info->seg_not_present ^ 1;
18818
18819 desc->s = 1;
18820 desc->dpl = 0x3;
18821@@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
18822 }
18823
18824 extern struct desc_ptr idt_descr;
18825-extern gate_desc idt_table[];
18826-extern struct desc_ptr debug_idt_descr;
18827-extern gate_desc debug_idt_table[];
18828-
18829-struct gdt_page {
18830- struct desc_struct gdt[GDT_ENTRIES];
18831-} __attribute__((aligned(PAGE_SIZE)));
18832-
18833-DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
18834+extern gate_desc idt_table[IDT_ENTRIES];
18835+extern const struct desc_ptr debug_idt_descr;
18836+extern gate_desc debug_idt_table[IDT_ENTRIES];
18837
18838+extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
18839 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
18840 {
18841- return per_cpu(gdt_page, cpu).gdt;
18842+ return cpu_gdt_table[cpu];
18843 }
18844
18845 #ifdef CONFIG_X86_64
18846@@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
18847 unsigned long base, unsigned dpl, unsigned flags,
18848 unsigned short seg)
18849 {
18850- gate->a = (seg << 16) | (base & 0xffff);
18851- gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
18852+ gate->gate.offset_low = base;
18853+ gate->gate.seg = seg;
18854+ gate->gate.reserved = 0;
18855+ gate->gate.type = type;
18856+ gate->gate.s = 0;
18857+ gate->gate.dpl = dpl;
18858+ gate->gate.p = 1;
18859+ gate->gate.offset_high = base >> 16;
18860 }
18861
18862 #endif
18863@@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
18864
18865 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
18866 {
18867+ pax_open_kernel();
18868 memcpy(&idt[entry], gate, sizeof(*gate));
18869+ pax_close_kernel();
18870 }
18871
18872 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
18873 {
18874+ pax_open_kernel();
18875 memcpy(&ldt[entry], desc, 8);
18876+ pax_close_kernel();
18877 }
18878
18879 static inline void
18880@@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
18881 default: size = sizeof(*gdt); break;
18882 }
18883
18884+ pax_open_kernel();
18885 memcpy(&gdt[entry], desc, size);
18886+ pax_close_kernel();
18887 }
18888
18889 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
18890@@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
18891
18892 static inline void native_load_tr_desc(void)
18893 {
18894+ pax_open_kernel();
18895 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
18896+ pax_close_kernel();
18897 }
18898
18899 static inline void native_load_gdt(const struct desc_ptr *dtr)
18900@@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
18901 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
18902 unsigned int i;
18903
18904+ pax_open_kernel();
18905 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
18906 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
18907+ pax_close_kernel();
18908 }
18909
18910 /* This intentionally ignores lm, since 32-bit apps don't have that field. */
18911@@ -280,7 +293,7 @@ static inline void clear_LDT(void)
18912 set_ldt(NULL, 0);
18913 }
18914
18915-static inline unsigned long get_desc_base(const struct desc_struct *desc)
18916+static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
18917 {
18918 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
18919 }
18920@@ -304,7 +317,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
18921 }
18922
18923 #ifdef CONFIG_X86_64
18924-static inline void set_nmi_gate(int gate, void *addr)
18925+static inline void set_nmi_gate(int gate, const void *addr)
18926 {
18927 gate_desc s;
18928
18929@@ -314,14 +327,14 @@ static inline void set_nmi_gate(int gate, void *addr)
18930 #endif
18931
18932 #ifdef CONFIG_TRACING
18933-extern struct desc_ptr trace_idt_descr;
18934-extern gate_desc trace_idt_table[];
18935+extern const struct desc_ptr trace_idt_descr;
18936+extern gate_desc trace_idt_table[IDT_ENTRIES];
18937 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
18938 {
18939 write_idt_entry(trace_idt_table, entry, gate);
18940 }
18941
18942-static inline void _trace_set_gate(int gate, unsigned type, void *addr,
18943+static inline void _trace_set_gate(int gate, unsigned type, const void *addr,
18944 unsigned dpl, unsigned ist, unsigned seg)
18945 {
18946 gate_desc s;
18947@@ -341,7 +354,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
18948 #define _trace_set_gate(gate, type, addr, dpl, ist, seg)
18949 #endif
18950
18951-static inline void _set_gate(int gate, unsigned type, void *addr,
18952+static inline void _set_gate(int gate, unsigned type, const void *addr,
18953 unsigned dpl, unsigned ist, unsigned seg)
18954 {
18955 gate_desc s;
18956@@ -364,14 +377,14 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
18957 #define set_intr_gate_notrace(n, addr) \
18958 do { \
18959 BUG_ON((unsigned)n > 0xFF); \
18960- _set_gate(n, GATE_INTERRUPT, (void *)addr, 0, 0, \
18961+ _set_gate(n, GATE_INTERRUPT, (const void *)addr, 0, 0, \
18962 __KERNEL_CS); \
18963 } while (0)
18964
18965 #define set_intr_gate(n, addr) \
18966 do { \
18967 set_intr_gate_notrace(n, addr); \
18968- _trace_set_gate(n, GATE_INTERRUPT, (void *)trace_##addr,\
18969+ _trace_set_gate(n, GATE_INTERRUPT, (const void *)trace_##addr,\
18970 0, 0, __KERNEL_CS); \
18971 } while (0)
18972
18973@@ -399,19 +412,19 @@ static inline void alloc_system_vector(int vector)
18974 /*
18975 * This routine sets up an interrupt gate at directory privilege level 3.
18976 */
18977-static inline void set_system_intr_gate(unsigned int n, void *addr)
18978+static inline void set_system_intr_gate(unsigned int n, const void *addr)
18979 {
18980 BUG_ON((unsigned)n > 0xFF);
18981 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
18982 }
18983
18984-static inline void set_system_trap_gate(unsigned int n, void *addr)
18985+static inline void set_system_trap_gate(unsigned int n, const void *addr)
18986 {
18987 BUG_ON((unsigned)n > 0xFF);
18988 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
18989 }
18990
18991-static inline void set_trap_gate(unsigned int n, void *addr)
18992+static inline void set_trap_gate(unsigned int n, const void *addr)
18993 {
18994 BUG_ON((unsigned)n > 0xFF);
18995 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
18996@@ -420,16 +433,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
18997 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
18998 {
18999 BUG_ON((unsigned)n > 0xFF);
19000- _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
19001+ _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
19002 }
19003
19004-static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
19005+static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
19006 {
19007 BUG_ON((unsigned)n > 0xFF);
19008 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
19009 }
19010
19011-static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
19012+static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
19013 {
19014 BUG_ON((unsigned)n > 0xFF);
19015 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
19016@@ -501,4 +514,17 @@ static inline void load_current_idt(void)
19017 else
19018 load_idt((const struct desc_ptr *)&idt_descr);
19019 }
19020+
19021+#ifdef CONFIG_X86_32
19022+static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
19023+{
19024+ struct desc_struct d;
19025+
19026+ if (likely(limit))
19027+ limit = (limit - 1UL) >> PAGE_SHIFT;
19028+ pack_descriptor(&d, base, limit, 0xFB, 0xC);
19029+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
19030+}
19031+#endif
19032+
19033 #endif /* _ASM_X86_DESC_H */
19034diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
19035index 278441f..b95a174 100644
19036--- a/arch/x86/include/asm/desc_defs.h
19037+++ b/arch/x86/include/asm/desc_defs.h
19038@@ -31,6 +31,12 @@ struct desc_struct {
19039 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
19040 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
19041 };
19042+ struct {
19043+ u16 offset_low;
19044+ u16 seg;
19045+ unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
19046+ unsigned offset_high: 16;
19047+ } gate;
19048 };
19049 } __attribute__((packed));
19050
19051diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
19052index ced283a..ffe04cc 100644
19053--- a/arch/x86/include/asm/div64.h
19054+++ b/arch/x86/include/asm/div64.h
19055@@ -39,7 +39,7 @@
19056 __mod; \
19057 })
19058
19059-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
19060+static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
19061 {
19062 union {
19063 u64 v64;
19064diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
19065index f161c18..97d43e8 100644
19066--- a/arch/x86/include/asm/elf.h
19067+++ b/arch/x86/include/asm/elf.h
19068@@ -75,9 +75,6 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
19069
19070 #include <asm/vdso.h>
19071
19072-#ifdef CONFIG_X86_64
19073-extern unsigned int vdso64_enabled;
19074-#endif
19075 #if defined(CONFIG_X86_32) || defined(CONFIG_COMPAT)
19076 extern unsigned int vdso32_enabled;
19077 #endif
19078@@ -250,7 +247,25 @@ extern int force_personality32;
19079 the loader. We need to make sure that it is out of the way of the program
19080 that it will "exec", and that there is sufficient room for the brk. */
19081
19082+#ifdef CONFIG_PAX_SEGMEXEC
19083+#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
19084+#else
19085 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
19086+#endif
19087+
19088+#ifdef CONFIG_PAX_ASLR
19089+#ifdef CONFIG_X86_32
19090+#define PAX_ELF_ET_DYN_BASE 0x10000000UL
19091+
19092+#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
19093+#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
19094+#else
19095+#define PAX_ELF_ET_DYN_BASE 0x400000UL
19096+
19097+#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
19098+#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
19099+#endif
19100+#endif
19101
19102 /* This yields a mask that user programs can use to figure out what
19103 instruction set this CPU supports. This could be done in user space,
19104@@ -299,17 +314,13 @@ do { \
19105
19106 #define ARCH_DLINFO \
19107 do { \
19108- if (vdso64_enabled) \
19109- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
19110- (unsigned long __force)current->mm->context.vdso); \
19111+ NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
19112 } while (0)
19113
19114 /* As a historical oddity, the x32 and x86_64 vDSOs are controlled together. */
19115 #define ARCH_DLINFO_X32 \
19116 do { \
19117- if (vdso64_enabled) \
19118- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
19119- (unsigned long __force)current->mm->context.vdso); \
19120+ NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
19121 } while (0)
19122
19123 #define AT_SYSINFO 32
19124@@ -324,10 +335,10 @@ else \
19125
19126 #endif /* !CONFIG_X86_32 */
19127
19128-#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
19129+#define VDSO_CURRENT_BASE (current->mm->context.vdso)
19130
19131 #define VDSO_ENTRY \
19132- ((unsigned long)current->mm->context.vdso + \
19133+ (current->mm->context.vdso + \
19134 selected_vdso32->sym___kernel_vsyscall)
19135
19136 struct linux_binprm;
19137diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
19138index 77a99ac..39ff7f5 100644
19139--- a/arch/x86/include/asm/emergency-restart.h
19140+++ b/arch/x86/include/asm/emergency-restart.h
19141@@ -1,6 +1,6 @@
19142 #ifndef _ASM_X86_EMERGENCY_RESTART_H
19143 #define _ASM_X86_EMERGENCY_RESTART_H
19144
19145-extern void machine_emergency_restart(void);
19146+extern void machine_emergency_restart(void) __noreturn;
19147
19148 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
19149diff --git a/arch/x86/include/asm/floppy.h b/arch/x86/include/asm/floppy.h
19150index 1c7eefe..d0e4702 100644
19151--- a/arch/x86/include/asm/floppy.h
19152+++ b/arch/x86/include/asm/floppy.h
19153@@ -229,18 +229,18 @@ static struct fd_routine_l {
19154 int (*_dma_setup)(char *addr, unsigned long size, int mode, int io);
19155 } fd_routine[] = {
19156 {
19157- request_dma,
19158- free_dma,
19159- get_dma_residue,
19160- dma_mem_alloc,
19161- hard_dma_setup
19162+ ._request_dma = request_dma,
19163+ ._free_dma = free_dma,
19164+ ._get_dma_residue = get_dma_residue,
19165+ ._dma_mem_alloc = dma_mem_alloc,
19166+ ._dma_setup = hard_dma_setup
19167 },
19168 {
19169- vdma_request_dma,
19170- vdma_nop,
19171- vdma_get_dma_residue,
19172- vdma_mem_alloc,
19173- vdma_dma_setup
19174+ ._request_dma = vdma_request_dma,
19175+ ._free_dma = vdma_nop,
19176+ ._get_dma_residue = vdma_get_dma_residue,
19177+ ._dma_mem_alloc = vdma_mem_alloc,
19178+ ._dma_setup = vdma_dma_setup
19179 }
19180 };
19181
19182diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
19183index 3c3550c..ca9e4c3 100644
19184--- a/arch/x86/include/asm/fpu/internal.h
19185+++ b/arch/x86/include/asm/fpu/internal.h
19186@@ -97,8 +97,11 @@ extern void fpstate_sanitize_xstate(struct fpu *fpu);
19187 #define user_insn(insn, output, input...) \
19188 ({ \
19189 int err; \
19190+ pax_open_userland(); \
19191 asm volatile(ASM_STAC "\n" \
19192- "1:" #insn "\n\t" \
19193+ "1:" \
19194+ __copyuser_seg \
19195+ #insn "\n\t" \
19196 "2: " ASM_CLAC "\n" \
19197 ".section .fixup,\"ax\"\n" \
19198 "3: movl $-1,%[err]\n" \
19199@@ -107,6 +110,7 @@ extern void fpstate_sanitize_xstate(struct fpu *fpu);
19200 _ASM_EXTABLE(1b, 3b) \
19201 : [err] "=r" (err), output \
19202 : "0"(0), input); \
19203+ pax_close_userland(); \
19204 err; \
19205 })
19206
19207@@ -186,9 +190,9 @@ static inline int copy_user_to_fregs(struct fregs_state __user *fx)
19208 static inline void copy_fxregs_to_kernel(struct fpu *fpu)
19209 {
19210 if (config_enabled(CONFIG_X86_32))
19211- asm volatile( "fxsave %[fx]" : [fx] "=m" (fpu->state.fxsave));
19212+ asm volatile( "fxsave %[fx]" : [fx] "=m" (fpu->state->fxsave));
19213 else if (config_enabled(CONFIG_AS_FXSAVEQ))
19214- asm volatile("fxsaveq %[fx]" : [fx] "=m" (fpu->state.fxsave));
19215+ asm volatile("fxsaveq %[fx]" : [fx] "=m" (fpu->state->fxsave));
19216 else {
19217 /* Using "rex64; fxsave %0" is broken because, if the memory
19218 * operand uses any extended registers for addressing, a second
19219@@ -205,15 +209,15 @@ static inline void copy_fxregs_to_kernel(struct fpu *fpu)
19220 * an extended register is needed for addressing (fix submitted
19221 * to mainline 2005-11-21).
19222 *
19223- * asm volatile("rex64/fxsave %0" : "=m" (fpu->state.fxsave));
19224+ * asm volatile("rex64/fxsave %0" : "=m" (fpu->state->fxsave));
19225 *
19226 * This, however, we can work around by forcing the compiler to
19227 * select an addressing mode that doesn't require extended
19228 * registers.
19229 */
19230 asm volatile( "rex64/fxsave (%[fx])"
19231- : "=m" (fpu->state.fxsave)
19232- : [fx] "R" (&fpu->state.fxsave));
19233+ : "=m" (fpu->state->fxsave)
19234+ : [fx] "R" (&fpu->state->fxsave));
19235 }
19236 }
19237
19238@@ -388,12 +392,16 @@ static inline int copy_xregs_to_user(struct xregs_state __user *buf)
19239 if (unlikely(err))
19240 return -EFAULT;
19241
19242+ pax_open_userland();
19243 __asm__ __volatile__(ASM_STAC "\n"
19244- "1:"XSAVE"\n"
19245+ "1:"
19246+ __copyuser_seg
19247+ XSAVE"\n"
19248 "2: " ASM_CLAC "\n"
19249 xstate_fault(err)
19250 : "D" (buf), "a" (-1), "d" (-1), "0" (err)
19251 : "memory");
19252+ pax_close_userland();
19253 return err;
19254 }
19255
19256@@ -402,17 +410,21 @@ static inline int copy_xregs_to_user(struct xregs_state __user *buf)
19257 */
19258 static inline int copy_user_to_xregs(struct xregs_state __user *buf, u64 mask)
19259 {
19260- struct xregs_state *xstate = ((__force struct xregs_state *)buf);
19261+ struct xregs_state *xstate = ((__force_kernel struct xregs_state *)buf);
19262 u32 lmask = mask;
19263 u32 hmask = mask >> 32;
19264 int err = 0;
19265
19266+ pax_open_userland();
19267 __asm__ __volatile__(ASM_STAC "\n"
19268- "1:"XRSTOR"\n"
19269+ "1:"
19270+ __copyuser_seg
19271+ XRSTOR"\n"
19272 "2: " ASM_CLAC "\n"
19273 xstate_fault(err)
19274 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (err)
19275 : "memory"); /* memory required? */
19276+ pax_close_userland();
19277 return err;
19278 }
19279
19280@@ -429,7 +441,7 @@ static inline int copy_user_to_xregs(struct xregs_state __user *buf, u64 mask)
19281 static inline int copy_fpregs_to_fpstate(struct fpu *fpu)
19282 {
19283 if (likely(use_xsave())) {
19284- copy_xregs_to_kernel(&fpu->state.xsave);
19285+ copy_xregs_to_kernel(&fpu->state->xsave);
19286 return 1;
19287 }
19288
19289@@ -442,7 +454,7 @@ static inline int copy_fpregs_to_fpstate(struct fpu *fpu)
19290 * Legacy FPU register saving, FNSAVE always clears FPU registers,
19291 * so we have to mark them inactive:
19292 */
19293- asm volatile("fnsave %[fp]; fwait" : [fp] "=m" (fpu->state.fsave));
19294+ asm volatile("fnsave %[fp]; fwait" : [fp] "=m" (fpu->state->fsave));
19295
19296 return 0;
19297 }
19298@@ -471,7 +483,7 @@ static inline void copy_kernel_to_fpregs(union fpregs_state *fpstate)
19299 "fnclex\n\t"
19300 "emms\n\t"
19301 "fildl %P[addr]" /* set F?P to defined value */
19302- : : [addr] "m" (fpstate));
19303+ : : [addr] "m" (cpu_tss[raw_smp_processor_id()].x86_tss.sp0));
19304 }
19305
19306 __copy_kernel_to_fpregs(fpstate);
19307@@ -611,7 +623,7 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu)
19308 if (fpu.preload) {
19309 new_fpu->counter++;
19310 __fpregs_activate(new_fpu);
19311- prefetch(&new_fpu->state);
19312+ prefetch(new_fpu->state);
19313 } else {
19314 __fpregs_deactivate_hw();
19315 }
19316@@ -623,7 +635,7 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu)
19317 if (fpu_want_lazy_restore(new_fpu, cpu))
19318 fpu.preload = 0;
19319 else
19320- prefetch(&new_fpu->state);
19321+ prefetch(new_fpu->state);
19322 fpregs_activate(new_fpu);
19323 }
19324 }
19325@@ -643,7 +655,7 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu)
19326 static inline void switch_fpu_finish(struct fpu *new_fpu, fpu_switch_t fpu_switch)
19327 {
19328 if (fpu_switch.preload)
19329- copy_kernel_to_fpregs(&new_fpu->state);
19330+ copy_kernel_to_fpregs(new_fpu->state);
19331 }
19332
19333 /*
19334diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h
19335index c49c517..0a6e089 100644
19336--- a/arch/x86/include/asm/fpu/types.h
19337+++ b/arch/x86/include/asm/fpu/types.h
19338@@ -189,7 +189,6 @@ union fpregs_state {
19339 struct fxregs_state fxsave;
19340 struct swregs_state soft;
19341 struct xregs_state xsave;
19342- u8 __padding[PAGE_SIZE];
19343 };
19344
19345 /*
19346@@ -199,6 +198,39 @@ union fpregs_state {
19347 */
19348 struct fpu {
19349 /*
19350+ * @state:
19351+ *
19352+ * In-memory copy of all FPU registers that we save/restore
19353+ * over context switches. If the task is using the FPU then
19354+ * the registers in the FPU are more recent than this state
19355+ * copy. If the task context-switches away then they get
19356+ * saved here and represent the FPU state.
19357+ *
19358+ * After context switches there may be a (short) time period
19359+ * during which the in-FPU hardware registers are unchanged
19360+ * and still perfectly match this state, if the tasks
19361+ * scheduled afterwards are not using the FPU.
19362+ *
19363+ * This is the 'lazy restore' window of optimization, which
19364+ * we track though 'fpu_fpregs_owner_ctx' and 'fpu->last_cpu'.
19365+ *
19366+ * We detect whether a subsequent task uses the FPU via setting
19367+ * CR0::TS to 1, which causes any FPU use to raise a #NM fault.
19368+ *
19369+ * During this window, if the task gets scheduled again, we
19370+ * might be able to skip having to do a restore from this
19371+ * memory buffer to the hardware registers - at the cost of
19372+ * incurring the overhead of #NM fault traps.
19373+ *
19374+ * Note that on modern CPUs that support the XSAVEOPT (or other
19375+ * optimized XSAVE instructions), we don't use #NM traps anymore,
19376+ * as the hardware can track whether FPU registers need saving
19377+ * or not. On such CPUs we activate the non-lazy ('eagerfpu')
19378+ * logic, which unconditionally saves/restores all FPU state
19379+ * across context switches. (if FPU state exists.)
19380+ */
19381+ union fpregs_state *state;
19382+ /*
19383 * @last_cpu:
19384 *
19385 * Records the last CPU on which this context was loaded into
19386@@ -255,43 +287,6 @@ struct fpu {
19387 * deal with bursty apps that only use the FPU for a short time:
19388 */
19389 unsigned char counter;
19390- /*
19391- * @state:
19392- *
19393- * In-memory copy of all FPU registers that we save/restore
19394- * over context switches. If the task is using the FPU then
19395- * the registers in the FPU are more recent than this state
19396- * copy. If the task context-switches away then they get
19397- * saved here and represent the FPU state.
19398- *
19399- * After context switches there may be a (short) time period
19400- * during which the in-FPU hardware registers are unchanged
19401- * and still perfectly match this state, if the tasks
19402- * scheduled afterwards are not using the FPU.
19403- *
19404- * This is the 'lazy restore' window of optimization, which
19405- * we track though 'fpu_fpregs_owner_ctx' and 'fpu->last_cpu'.
19406- *
19407- * We detect whether a subsequent task uses the FPU via setting
19408- * CR0::TS to 1, which causes any FPU use to raise a #NM fault.
19409- *
19410- * During this window, if the task gets scheduled again, we
19411- * might be able to skip having to do a restore from this
19412- * memory buffer to the hardware registers - at the cost of
19413- * incurring the overhead of #NM fault traps.
19414- *
19415- * Note that on modern CPUs that support the XSAVEOPT (or other
19416- * optimized XSAVE instructions), we don't use #NM traps anymore,
19417- * as the hardware can track whether FPU registers need saving
19418- * or not. On such CPUs we activate the non-lazy ('eagerfpu')
19419- * logic, which unconditionally saves/restores all FPU state
19420- * across context switches. (if FPU state exists.)
19421- */
19422- union fpregs_state state;
19423- /*
19424- * WARNING: 'state' is dynamically-sized. Do not put
19425- * anything after it here.
19426- */
19427 };
19428
19429 #endif /* _ASM_X86_FPU_H */
19430diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
19431index b4c1f54..e290c08 100644
19432--- a/arch/x86/include/asm/futex.h
19433+++ b/arch/x86/include/asm/futex.h
19434@@ -12,6 +12,7 @@
19435 #include <asm/smap.h>
19436
19437 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
19438+ typecheck(u32 __user *, uaddr); \
19439 asm volatile("\t" ASM_STAC "\n" \
19440 "1:\t" insn "\n" \
19441 "2:\t" ASM_CLAC "\n" \
19442@@ -20,15 +21,16 @@
19443 "\tjmp\t2b\n" \
19444 "\t.previous\n" \
19445 _ASM_EXTABLE(1b, 3b) \
19446- : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
19447+ : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
19448 : "i" (-EFAULT), "0" (oparg), "1" (0))
19449
19450 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
19451+ typecheck(u32 __user *, uaddr); \
19452 asm volatile("\t" ASM_STAC "\n" \
19453 "1:\tmovl %2, %0\n" \
19454 "\tmovl\t%0, %3\n" \
19455 "\t" insn "\n" \
19456- "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
19457+ "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
19458 "\tjnz\t1b\n" \
19459 "3:\t" ASM_CLAC "\n" \
19460 "\t.section .fixup,\"ax\"\n" \
19461@@ -38,7 +40,7 @@
19462 _ASM_EXTABLE(1b, 4b) \
19463 _ASM_EXTABLE(2b, 4b) \
19464 : "=&a" (oldval), "=&r" (ret), \
19465- "+m" (*uaddr), "=&r" (tem) \
19466+ "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
19467 : "r" (oparg), "i" (-EFAULT), "1" (0))
19468
19469 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
19470@@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
19471
19472 pagefault_disable();
19473
19474+ pax_open_userland();
19475 switch (op) {
19476 case FUTEX_OP_SET:
19477- __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
19478+ __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
19479 break;
19480 case FUTEX_OP_ADD:
19481- __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
19482+ __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
19483 uaddr, oparg);
19484 break;
19485 case FUTEX_OP_OR:
19486@@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
19487 default:
19488 ret = -ENOSYS;
19489 }
19490+ pax_close_userland();
19491
19492 pagefault_enable();
19493
19494diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
19495index 6615032..9c233be 100644
19496--- a/arch/x86/include/asm/hw_irq.h
19497+++ b/arch/x86/include/asm/hw_irq.h
19498@@ -158,8 +158,8 @@ static inline void unlock_vector_lock(void) {}
19499 #endif /* CONFIG_X86_LOCAL_APIC */
19500
19501 /* Statistics */
19502-extern atomic_t irq_err_count;
19503-extern atomic_t irq_mis_count;
19504+extern atomic_unchecked_t irq_err_count;
19505+extern atomic_unchecked_t irq_mis_count;
19506
19507 extern void elcr_set_level_irq(unsigned int irq);
19508
19509diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
19510index ccffa53..3c90c87 100644
19511--- a/arch/x86/include/asm/i8259.h
19512+++ b/arch/x86/include/asm/i8259.h
19513@@ -62,7 +62,7 @@ struct legacy_pic {
19514 void (*init)(int auto_eoi);
19515 int (*irq_pending)(unsigned int irq);
19516 void (*make_irq)(unsigned int irq);
19517-};
19518+} __do_const;
19519
19520 extern struct legacy_pic *legacy_pic;
19521 extern struct legacy_pic null_legacy_pic;
19522diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
19523index cc9c61b..7b17f40 100644
19524--- a/arch/x86/include/asm/io.h
19525+++ b/arch/x86/include/asm/io.h
19526@@ -42,6 +42,7 @@
19527 #include <asm/page.h>
19528 #include <asm/early_ioremap.h>
19529 #include <asm/pgtable_types.h>
19530+#include <asm/processor.h>
19531
19532 #define build_mmio_read(name, size, type, reg, barrier) \
19533 static inline type name(const volatile void __iomem *addr) \
19534@@ -54,12 +55,12 @@ static inline void name(type val, volatile void __iomem *addr) \
19535 "m" (*(volatile type __force *)addr) barrier); }
19536
19537 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
19538-build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
19539-build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
19540+build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
19541+build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
19542
19543 build_mmio_read(__readb, "b", unsigned char, "=q", )
19544-build_mmio_read(__readw, "w", unsigned short, "=r", )
19545-build_mmio_read(__readl, "l", unsigned int, "=r", )
19546+build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
19547+build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
19548
19549 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
19550 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
19551@@ -115,7 +116,7 @@ build_mmio_write(writeq, "q", unsigned long, "r", :"memory")
19552 * this function
19553 */
19554
19555-static inline phys_addr_t virt_to_phys(volatile void *address)
19556+static inline phys_addr_t __intentional_overflow(-1) virt_to_phys(volatile void *address)
19557 {
19558 return __pa(address);
19559 }
19560@@ -192,7 +193,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
19561 return ioremap_nocache(offset, size);
19562 }
19563
19564-extern void iounmap(volatile void __iomem *addr);
19565+extern void iounmap(const volatile void __iomem *addr);
19566
19567 extern void set_iounmap_nonlazy(void);
19568
19569@@ -200,6 +201,17 @@ extern void set_iounmap_nonlazy(void);
19570
19571 #include <asm-generic/iomap.h>
19572
19573+#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
19574+static inline int valid_phys_addr_range(unsigned long addr, size_t count)
19575+{
19576+ return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
19577+}
19578+
19579+static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
19580+{
19581+ return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
19582+}
19583+
19584 /*
19585 * Convert a virtual cached pointer to an uncached pointer
19586 */
19587diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
19588index b77f5ed..a2f791e 100644
19589--- a/arch/x86/include/asm/irqflags.h
19590+++ b/arch/x86/include/asm/irqflags.h
19591@@ -137,6 +137,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
19592 swapgs; \
19593 sysretl
19594
19595+#define GET_CR0_INTO_RDI mov %cr0, %rdi
19596+#define SET_RDI_INTO_CR0 mov %rdi, %cr0
19597+#define GET_CR3_INTO_RDI mov %cr3, %rdi
19598+#define SET_RDI_INTO_CR3 mov %rdi, %cr3
19599+
19600 #else
19601 #define INTERRUPT_RETURN iret
19602 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
19603diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
19604index 4421b5d..8543006 100644
19605--- a/arch/x86/include/asm/kprobes.h
19606+++ b/arch/x86/include/asm/kprobes.h
19607@@ -37,13 +37,8 @@ typedef u8 kprobe_opcode_t;
19608 #define RELATIVEJUMP_SIZE 5
19609 #define RELATIVECALL_OPCODE 0xe8
19610 #define RELATIVE_ADDR_SIZE 4
19611-#define MAX_STACK_SIZE 64
19612-#define MIN_STACK_SIZE(ADDR) \
19613- (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
19614- THREAD_SIZE - (unsigned long)(ADDR))) \
19615- ? (MAX_STACK_SIZE) \
19616- : (((unsigned long)current_thread_info()) + \
19617- THREAD_SIZE - (unsigned long)(ADDR)))
19618+#define MAX_STACK_SIZE 64UL
19619+#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
19620
19621 #define flush_insn_slot(p) do { } while (0)
19622
19623diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
19624index 4ad6560..75c7bdd 100644
19625--- a/arch/x86/include/asm/local.h
19626+++ b/arch/x86/include/asm/local.h
19627@@ -10,33 +10,97 @@ typedef struct {
19628 atomic_long_t a;
19629 } local_t;
19630
19631+typedef struct {
19632+ atomic_long_unchecked_t a;
19633+} local_unchecked_t;
19634+
19635 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
19636
19637 #define local_read(l) atomic_long_read(&(l)->a)
19638+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
19639 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
19640+#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
19641
19642 static inline void local_inc(local_t *l)
19643 {
19644- asm volatile(_ASM_INC "%0"
19645+ asm volatile(_ASM_INC "%0\n"
19646+
19647+#ifdef CONFIG_PAX_REFCOUNT
19648+ "jno 0f\n"
19649+ _ASM_DEC "%0\n"
19650+ "int $4\n0:\n"
19651+ _ASM_EXTABLE(0b, 0b)
19652+#endif
19653+
19654+ : "+m" (l->a.counter));
19655+}
19656+
19657+static inline void local_inc_unchecked(local_unchecked_t *l)
19658+{
19659+ asm volatile(_ASM_INC "%0\n"
19660 : "+m" (l->a.counter));
19661 }
19662
19663 static inline void local_dec(local_t *l)
19664 {
19665- asm volatile(_ASM_DEC "%0"
19666+ asm volatile(_ASM_DEC "%0\n"
19667+
19668+#ifdef CONFIG_PAX_REFCOUNT
19669+ "jno 0f\n"
19670+ _ASM_INC "%0\n"
19671+ "int $4\n0:\n"
19672+ _ASM_EXTABLE(0b, 0b)
19673+#endif
19674+
19675+ : "+m" (l->a.counter));
19676+}
19677+
19678+static inline void local_dec_unchecked(local_unchecked_t *l)
19679+{
19680+ asm volatile(_ASM_DEC "%0\n"
19681 : "+m" (l->a.counter));
19682 }
19683
19684 static inline void local_add(long i, local_t *l)
19685 {
19686- asm volatile(_ASM_ADD "%1,%0"
19687+ asm volatile(_ASM_ADD "%1,%0\n"
19688+
19689+#ifdef CONFIG_PAX_REFCOUNT
19690+ "jno 0f\n"
19691+ _ASM_SUB "%1,%0\n"
19692+ "int $4\n0:\n"
19693+ _ASM_EXTABLE(0b, 0b)
19694+#endif
19695+
19696+ : "+m" (l->a.counter)
19697+ : "ir" (i));
19698+}
19699+
19700+static inline void local_add_unchecked(long i, local_unchecked_t *l)
19701+{
19702+ asm volatile(_ASM_ADD "%1,%0\n"
19703 : "+m" (l->a.counter)
19704 : "ir" (i));
19705 }
19706
19707 static inline void local_sub(long i, local_t *l)
19708 {
19709- asm volatile(_ASM_SUB "%1,%0"
19710+ asm volatile(_ASM_SUB "%1,%0\n"
19711+
19712+#ifdef CONFIG_PAX_REFCOUNT
19713+ "jno 0f\n"
19714+ _ASM_ADD "%1,%0\n"
19715+ "int $4\n0:\n"
19716+ _ASM_EXTABLE(0b, 0b)
19717+#endif
19718+
19719+ : "+m" (l->a.counter)
19720+ : "ir" (i));
19721+}
19722+
19723+static inline void local_sub_unchecked(long i, local_unchecked_t *l)
19724+{
19725+ asm volatile(_ASM_SUB "%1,%0\n"
19726 : "+m" (l->a.counter)
19727 : "ir" (i));
19728 }
19729@@ -52,7 +116,7 @@ static inline void local_sub(long i, local_t *l)
19730 */
19731 static inline int local_sub_and_test(long i, local_t *l)
19732 {
19733- GEN_BINARY_RMWcc(_ASM_SUB, l->a.counter, "er", i, "%0", "e");
19734+ GEN_BINARY_RMWcc(_ASM_SUB, _ASM_ADD, l->a.counter, "er", i, "%0", "e");
19735 }
19736
19737 /**
19738@@ -65,7 +129,7 @@ static inline int local_sub_and_test(long i, local_t *l)
19739 */
19740 static inline int local_dec_and_test(local_t *l)
19741 {
19742- GEN_UNARY_RMWcc(_ASM_DEC, l->a.counter, "%0", "e");
19743+ GEN_UNARY_RMWcc(_ASM_DEC, _ASM_INC, l->a.counter, "%0", "e");
19744 }
19745
19746 /**
19747@@ -78,7 +142,7 @@ static inline int local_dec_and_test(local_t *l)
19748 */
19749 static inline int local_inc_and_test(local_t *l)
19750 {
19751- GEN_UNARY_RMWcc(_ASM_INC, l->a.counter, "%0", "e");
19752+ GEN_UNARY_RMWcc(_ASM_INC, _ASM_DEC, l->a.counter, "%0", "e");
19753 }
19754
19755 /**
19756@@ -92,7 +156,7 @@ static inline int local_inc_and_test(local_t *l)
19757 */
19758 static inline int local_add_negative(long i, local_t *l)
19759 {
19760- GEN_BINARY_RMWcc(_ASM_ADD, l->a.counter, "er", i, "%0", "s");
19761+ GEN_BINARY_RMWcc(_ASM_ADD, _ASM_SUB, l->a.counter, "er", i, "%0", "s");
19762 }
19763
19764 /**
19765@@ -105,6 +169,30 @@ static inline int local_add_negative(long i, local_t *l)
19766 static inline long local_add_return(long i, local_t *l)
19767 {
19768 long __i = i;
19769+ asm volatile(_ASM_XADD "%0, %1\n"
19770+
19771+#ifdef CONFIG_PAX_REFCOUNT
19772+ "jno 0f\n"
19773+ _ASM_MOV "%0,%1\n"
19774+ "int $4\n0:\n"
19775+ _ASM_EXTABLE(0b, 0b)
19776+#endif
19777+
19778+ : "+r" (i), "+m" (l->a.counter)
19779+ : : "memory");
19780+ return i + __i;
19781+}
19782+
19783+/**
19784+ * local_add_return_unchecked - add and return
19785+ * @i: integer value to add
19786+ * @l: pointer to type local_unchecked_t
19787+ *
19788+ * Atomically adds @i to @l and returns @i + @l
19789+ */
19790+static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
19791+{
19792+ long __i = i;
19793 asm volatile(_ASM_XADD "%0, %1;"
19794 : "+r" (i), "+m" (l->a.counter)
19795 : : "memory");
19796@@ -121,6 +209,8 @@ static inline long local_sub_return(long i, local_t *l)
19797
19798 #define local_cmpxchg(l, o, n) \
19799 (cmpxchg_local(&((l)->a.counter), (o), (n)))
19800+#define local_cmpxchg_unchecked(l, o, n) \
19801+ (cmpxchg_local(&((l)->a.counter), (o), (n)))
19802 /* Always has a lock prefix */
19803 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
19804
19805diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
19806new file mode 100644
19807index 0000000..2bfd3ba
19808--- /dev/null
19809+++ b/arch/x86/include/asm/mman.h
19810@@ -0,0 +1,15 @@
19811+#ifndef _X86_MMAN_H
19812+#define _X86_MMAN_H
19813+
19814+#include <uapi/asm/mman.h>
19815+
19816+#ifdef __KERNEL__
19817+#ifndef __ASSEMBLY__
19818+#ifdef CONFIG_X86_32
19819+#define arch_mmap_check i386_mmap_check
19820+int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
19821+#endif
19822+#endif
19823+#endif
19824+
19825+#endif /* X86_MMAN_H */
19826diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
19827index 364d274..e51b4bc 100644
19828--- a/arch/x86/include/asm/mmu.h
19829+++ b/arch/x86/include/asm/mmu.h
19830@@ -17,7 +17,19 @@ typedef struct {
19831 #endif
19832
19833 struct mutex lock;
19834- void __user *vdso;
19835+ unsigned long vdso;
19836+
19837+#ifdef CONFIG_X86_32
19838+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
19839+ unsigned long user_cs_base;
19840+ unsigned long user_cs_limit;
19841+
19842+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
19843+ cpumask_t cpu_user_cs_mask;
19844+#endif
19845+
19846+#endif
19847+#endif
19848
19849 atomic_t perf_rdpmc_allowed; /* nonzero if rdpmc is allowed */
19850 } mm_context_t;
19851diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
19852index 984abfe..9996c62 100644
19853--- a/arch/x86/include/asm/mmu_context.h
19854+++ b/arch/x86/include/asm/mmu_context.h
19855@@ -45,7 +45,7 @@ struct ldt_struct {
19856 * allocations, but it's not worth trying to optimize.
19857 */
19858 struct desc_struct *entries;
19859- int size;
19860+ unsigned int size;
19861 };
19862
19863 static inline void load_mm_ldt(struct mm_struct *mm)
19864@@ -86,26 +86,95 @@ void destroy_context(struct mm_struct *mm);
19865
19866 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
19867 {
19868+
19869+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19870+ if (!(static_cpu_has(X86_FEATURE_PCIDUDEREF))) {
19871+ unsigned int i;
19872+ pgd_t *pgd;
19873+
19874+ pax_open_kernel();
19875+ pgd = get_cpu_pgd(smp_processor_id(), kernel);
19876+ for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
19877+ set_pgd_batched(pgd+i, native_make_pgd(0));
19878+ pax_close_kernel();
19879+ }
19880+#endif
19881+
19882 #ifdef CONFIG_SMP
19883 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
19884 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
19885 #endif
19886 }
19887
19888+static inline void pax_switch_mm(struct mm_struct *next, unsigned int cpu)
19889+{
19890+
19891+#ifdef CONFIG_PAX_PER_CPU_PGD
19892+ pax_open_kernel();
19893+
19894+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19895+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF))
19896+ __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
19897+ else
19898+#endif
19899+
19900+ __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
19901+
19902+ __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
19903+
19904+ pax_close_kernel();
19905+
19906+ 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));
19907+
19908+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19909+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF)) {
19910+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
19911+ u64 descriptor[2];
19912+ descriptor[0] = PCID_USER;
19913+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
19914+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
19915+ descriptor[0] = PCID_KERNEL;
19916+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
19917+ }
19918+ } else {
19919+ write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
19920+ if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
19921+ write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
19922+ else
19923+ write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
19924+ }
19925+ } else
19926+#endif
19927+
19928+ load_cr3(get_cpu_pgd(cpu, kernel));
19929+#endif
19930+
19931+}
19932+
19933 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
19934 struct task_struct *tsk)
19935 {
19936 unsigned cpu = smp_processor_id();
19937+#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
19938+ int tlbstate = TLBSTATE_OK;
19939+#endif
19940
19941 if (likely(prev != next)) {
19942 #ifdef CONFIG_SMP
19943+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
19944+ tlbstate = this_cpu_read(cpu_tlbstate.state);
19945+#endif
19946 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
19947 this_cpu_write(cpu_tlbstate.active_mm, next);
19948 #endif
19949 cpumask_set_cpu(cpu, mm_cpumask(next));
19950
19951 /* Re-load page tables */
19952+#ifdef CONFIG_PAX_PER_CPU_PGD
19953+ pax_switch_mm(next, cpu);
19954+#else
19955 load_cr3(next->pgd);
19956+#endif
19957 trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL);
19958
19959 /* Stop flush ipis for the previous mm */
19960@@ -128,9 +197,31 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
19961 */
19962 if (unlikely(prev->context.ldt != next->context.ldt))
19963 load_mm_ldt(next);
19964+
19965+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
19966+ if (!(__supported_pte_mask & _PAGE_NX)) {
19967+ smp_mb__before_atomic();
19968+ cpumask_clear_cpu(cpu, &prev->context.cpu_user_cs_mask);
19969+ smp_mb__after_atomic();
19970+ cpumask_set_cpu(cpu, &next->context.cpu_user_cs_mask);
19971+ }
19972+#endif
19973+
19974+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
19975+ if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
19976+ prev->context.user_cs_limit != next->context.user_cs_limit))
19977+ set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
19978+#ifdef CONFIG_SMP
19979+ else if (unlikely(tlbstate != TLBSTATE_OK))
19980+ set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
19981+#endif
19982+#endif
19983+
19984 }
19985+ else {
19986+ pax_switch_mm(next, cpu);
19987+
19988 #ifdef CONFIG_SMP
19989- else {
19990 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
19991 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
19992
19993@@ -147,13 +238,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
19994 * tlb flush IPI delivery. We must reload CR3
19995 * to make sure to use no freed page tables.
19996 */
19997+
19998+#ifndef CONFIG_PAX_PER_CPU_PGD
19999 load_cr3(next->pgd);
20000 trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL);
20001+#endif
20002+
20003 load_mm_cr4(next);
20004 load_mm_ldt(next);
20005+
20006+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
20007+ if (!(__supported_pte_mask & _PAGE_NX))
20008+ cpumask_set_cpu(cpu, &next->context.cpu_user_cs_mask);
20009+#endif
20010+
20011+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
20012+#ifdef CONFIG_PAX_PAGEEXEC
20013+ if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
20014+#endif
20015+ set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
20016+#endif
20017+
20018 }
20019+#endif
20020 }
20021-#endif
20022 }
20023
20024 #define activate_mm(prev, next) \
20025diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
20026index e3b7819..b257c64 100644
20027--- a/arch/x86/include/asm/module.h
20028+++ b/arch/x86/include/asm/module.h
20029@@ -5,6 +5,7 @@
20030
20031 #ifdef CONFIG_X86_64
20032 /* X86_64 does not define MODULE_PROC_FAMILY */
20033+#define MODULE_PROC_FAMILY ""
20034 #elif defined CONFIG_M486
20035 #define MODULE_PROC_FAMILY "486 "
20036 #elif defined CONFIG_M586
20037@@ -57,8 +58,20 @@
20038 #error unknown processor family
20039 #endif
20040
20041-#ifdef CONFIG_X86_32
20042-# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
20043+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
20044+#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
20045+#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
20046+#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
20047+#else
20048+#define MODULE_PAX_KERNEXEC ""
20049 #endif
20050
20051+#ifdef CONFIG_PAX_MEMORY_UDEREF
20052+#define MODULE_PAX_UDEREF "UDEREF "
20053+#else
20054+#define MODULE_PAX_UDEREF ""
20055+#endif
20056+
20057+#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
20058+
20059 #endif /* _ASM_X86_MODULE_H */
20060diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
20061index 5f2fc44..106caa6 100644
20062--- a/arch/x86/include/asm/nmi.h
20063+++ b/arch/x86/include/asm/nmi.h
20064@@ -36,26 +36,35 @@ enum {
20065
20066 typedef int (*nmi_handler_t)(unsigned int, struct pt_regs *);
20067
20068+struct nmiaction;
20069+
20070+struct nmiwork {
20071+ const struct nmiaction *action;
20072+ u64 max_duration;
20073+ struct irq_work irq_work;
20074+};
20075+
20076 struct nmiaction {
20077 struct list_head list;
20078 nmi_handler_t handler;
20079- u64 max_duration;
20080- struct irq_work irq_work;
20081 unsigned long flags;
20082 const char *name;
20083-};
20084+ struct nmiwork *work;
20085+} __do_const;
20086
20087 #define register_nmi_handler(t, fn, fg, n, init...) \
20088 ({ \
20089- static struct nmiaction init fn##_na = { \
20090+ static struct nmiwork fn##_nw; \
20091+ static const struct nmiaction init fn##_na = { \
20092 .handler = (fn), \
20093 .name = (n), \
20094 .flags = (fg), \
20095+ .work = &fn##_nw, \
20096 }; \
20097 __register_nmi_handler((t), &fn##_na); \
20098 })
20099
20100-int __register_nmi_handler(unsigned int, struct nmiaction *);
20101+int __register_nmi_handler(unsigned int, const struct nmiaction *);
20102
20103 void unregister_nmi_handler(unsigned int, const char *);
20104
20105diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
20106index 802dde3..9183e68 100644
20107--- a/arch/x86/include/asm/page.h
20108+++ b/arch/x86/include/asm/page.h
20109@@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
20110 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
20111
20112 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
20113+#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
20114
20115 #define __boot_va(x) __va(x)
20116 #define __boot_pa(x) __pa(x)
20117@@ -60,11 +61,21 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
20118 * virt_to_page(kaddr) returns a valid pointer if and only if
20119 * virt_addr_valid(kaddr) returns true.
20120 */
20121-#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
20122 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
20123 extern bool __virt_addr_valid(unsigned long kaddr);
20124 #define virt_addr_valid(kaddr) __virt_addr_valid((unsigned long) (kaddr))
20125
20126+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
20127+#define virt_to_page(kaddr) \
20128+ ({ \
20129+ const void *__kaddr = (const void *)(kaddr); \
20130+ BUG_ON(!virt_addr_valid(__kaddr)); \
20131+ pfn_to_page(__pa(__kaddr) >> PAGE_SHIFT); \
20132+ })
20133+#else
20134+#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
20135+#endif
20136+
20137 #endif /* __ASSEMBLY__ */
20138
20139 #include <asm-generic/memory_model.h>
20140diff --git a/arch/x86/include/asm/page_32.h b/arch/x86/include/asm/page_32.h
20141index 904f528..b4d0d24 100644
20142--- a/arch/x86/include/asm/page_32.h
20143+++ b/arch/x86/include/asm/page_32.h
20144@@ -7,11 +7,17 @@
20145
20146 #define __phys_addr_nodebug(x) ((x) - PAGE_OFFSET)
20147 #ifdef CONFIG_DEBUG_VIRTUAL
20148-extern unsigned long __phys_addr(unsigned long);
20149+extern unsigned long __intentional_overflow(-1) __phys_addr(unsigned long);
20150 #else
20151-#define __phys_addr(x) __phys_addr_nodebug(x)
20152+static inline unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
20153+{
20154+ return __phys_addr_nodebug(x);
20155+}
20156 #endif
20157-#define __phys_addr_symbol(x) __phys_addr(x)
20158+static inline unsigned long __intentional_overflow(-1) __phys_addr_symbol(unsigned long x)
20159+{
20160+ return __phys_addr(x);
20161+}
20162 #define __phys_reloc_hide(x) RELOC_HIDE((x), 0)
20163
20164 #ifdef CONFIG_FLATMEM
20165diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
20166index b3bebf9..cb419e7 100644
20167--- a/arch/x86/include/asm/page_64.h
20168+++ b/arch/x86/include/asm/page_64.h
20169@@ -7,9 +7,9 @@
20170
20171 /* duplicated to the one in bootmem.h */
20172 extern unsigned long max_pfn;
20173-extern unsigned long phys_base;
20174+extern const unsigned long phys_base;
20175
20176-static inline unsigned long __phys_addr_nodebug(unsigned long x)
20177+static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
20178 {
20179 unsigned long y = x - __START_KERNEL_map;
20180
20181@@ -20,12 +20,14 @@ static inline unsigned long __phys_addr_nodebug(unsigned long x)
20182 }
20183
20184 #ifdef CONFIG_DEBUG_VIRTUAL
20185-extern unsigned long __phys_addr(unsigned long);
20186-extern unsigned long __phys_addr_symbol(unsigned long);
20187+extern unsigned long __intentional_overflow(-1) __phys_addr(unsigned long);
20188+extern unsigned long __intentional_overflow(-1) __phys_addr_symbol(unsigned long);
20189 #else
20190 #define __phys_addr(x) __phys_addr_nodebug(x)
20191-#define __phys_addr_symbol(x) \
20192- ((unsigned long)(x) - __START_KERNEL_map + phys_base)
20193+static inline unsigned long __intentional_overflow(-1) __phys_addr_symbol(unsigned long x)
20194+{
20195+ return x - __START_KERNEL_map + phys_base;
20196+}
20197 #endif
20198
20199 #define __phys_reloc_hide(x) (x)
20200diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
20201index d143bfa..30d1f41 100644
20202--- a/arch/x86/include/asm/paravirt.h
20203+++ b/arch/x86/include/asm/paravirt.h
20204@@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
20205 return (pmd_t) { ret };
20206 }
20207
20208-static inline pmdval_t pmd_val(pmd_t pmd)
20209+static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
20210 {
20211 pmdval_t ret;
20212
20213@@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
20214 val);
20215 }
20216
20217+static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
20218+{
20219+ pgdval_t val = native_pgd_val(pgd);
20220+
20221+ if (sizeof(pgdval_t) > sizeof(long))
20222+ PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
20223+ val, (u64)val >> 32);
20224+ else
20225+ PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
20226+ val);
20227+}
20228+
20229 static inline void pgd_clear(pgd_t *pgdp)
20230 {
20231 set_pgd(pgdp, __pgd(0));
20232@@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
20233 pv_mmu_ops.set_fixmap(idx, phys, flags);
20234 }
20235
20236+#ifdef CONFIG_PAX_KERNEXEC
20237+static inline unsigned long pax_open_kernel(void)
20238+{
20239+ return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
20240+}
20241+
20242+static inline unsigned long pax_close_kernel(void)
20243+{
20244+ return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
20245+}
20246+#else
20247+static inline unsigned long pax_open_kernel(void) { return 0; }
20248+static inline unsigned long pax_close_kernel(void) { return 0; }
20249+#endif
20250+
20251 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
20252
20253 #ifdef CONFIG_QUEUED_SPINLOCKS
20254@@ -933,7 +960,7 @@ extern void default_banner(void);
20255
20256 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
20257 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
20258-#define PARA_INDIRECT(addr) *%cs:addr
20259+#define PARA_INDIRECT(addr) *%ss:addr
20260 #endif
20261
20262 #define INTERRUPT_RETURN \
20263@@ -1003,6 +1030,21 @@ extern void default_banner(void);
20264 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_usergs_sysret64), \
20265 CLBR_NONE, \
20266 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_usergs_sysret64))
20267+
20268+#define GET_CR0_INTO_RDI \
20269+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
20270+ mov %rax,%rdi
20271+
20272+#define SET_RDI_INTO_CR0 \
20273+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20274+
20275+#define GET_CR3_INTO_RDI \
20276+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
20277+ mov %rax,%rdi
20278+
20279+#define SET_RDI_INTO_CR3 \
20280+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
20281+
20282 #endif /* CONFIG_X86_32 */
20283
20284 #endif /* __ASSEMBLY__ */
20285diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
20286index a6b8f9f..fd61ef7 100644
20287--- a/arch/x86/include/asm/paravirt_types.h
20288+++ b/arch/x86/include/asm/paravirt_types.h
20289@@ -84,7 +84,7 @@ struct pv_init_ops {
20290 */
20291 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
20292 unsigned long addr, unsigned len);
20293-};
20294+} __no_const __no_randomize_layout;
20295
20296
20297 struct pv_lazy_ops {
20298@@ -92,13 +92,13 @@ struct pv_lazy_ops {
20299 void (*enter)(void);
20300 void (*leave)(void);
20301 void (*flush)(void);
20302-};
20303+} __no_randomize_layout;
20304
20305 struct pv_time_ops {
20306 unsigned long long (*sched_clock)(void);
20307 unsigned long long (*steal_clock)(int cpu);
20308 unsigned long (*get_tsc_khz)(void);
20309-};
20310+} __no_const __no_randomize_layout;
20311
20312 struct pv_cpu_ops {
20313 /* hooks for various privileged instructions */
20314@@ -193,7 +193,7 @@ struct pv_cpu_ops {
20315
20316 void (*start_context_switch)(struct task_struct *prev);
20317 void (*end_context_switch)(struct task_struct *next);
20318-};
20319+} __no_const __no_randomize_layout;
20320
20321 struct pv_irq_ops {
20322 /*
20323@@ -216,7 +216,7 @@ struct pv_irq_ops {
20324 #ifdef CONFIG_X86_64
20325 void (*adjust_exception_frame)(void);
20326 #endif
20327-};
20328+} __no_randomize_layout;
20329
20330 struct pv_apic_ops {
20331 #ifdef CONFIG_X86_LOCAL_APIC
20332@@ -224,7 +224,7 @@ struct pv_apic_ops {
20333 unsigned long start_eip,
20334 unsigned long start_esp);
20335 #endif
20336-};
20337+} __no_const __no_randomize_layout;
20338
20339 struct pv_mmu_ops {
20340 unsigned long (*read_cr2)(void);
20341@@ -314,6 +314,7 @@ struct pv_mmu_ops {
20342 struct paravirt_callee_save make_pud;
20343
20344 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
20345+ void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
20346 #endif /* CONFIG_PGTABLE_LEVELS == 4 */
20347 #endif /* CONFIG_PGTABLE_LEVELS >= 3 */
20348
20349@@ -325,7 +326,13 @@ struct pv_mmu_ops {
20350 an mfn. We can tell which is which from the index. */
20351 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
20352 phys_addr_t phys, pgprot_t flags);
20353-};
20354+
20355+#ifdef CONFIG_PAX_KERNEXEC
20356+ unsigned long (*pax_open_kernel)(void);
20357+ unsigned long (*pax_close_kernel)(void);
20358+#endif
20359+
20360+} __no_randomize_layout;
20361
20362 struct arch_spinlock;
20363 #ifdef CONFIG_SMP
20364@@ -347,11 +354,14 @@ struct pv_lock_ops {
20365 struct paravirt_callee_save lock_spinning;
20366 void (*unlock_kick)(struct arch_spinlock *lock, __ticket_t ticket);
20367 #endif /* !CONFIG_QUEUED_SPINLOCKS */
20368-};
20369+} __no_randomize_layout;
20370
20371 /* This contains all the paravirt structures: we get a convenient
20372 * number for each function using the offset which we use to indicate
20373- * what to patch. */
20374+ * what to patch.
20375+ * shouldn't be randomized due to the "NEAT TRICK" in paravirt.c
20376+ */
20377+
20378 struct paravirt_patch_template {
20379 struct pv_init_ops pv_init_ops;
20380 struct pv_time_ops pv_time_ops;
20381@@ -360,7 +370,7 @@ struct paravirt_patch_template {
20382 struct pv_apic_ops pv_apic_ops;
20383 struct pv_mmu_ops pv_mmu_ops;
20384 struct pv_lock_ops pv_lock_ops;
20385-};
20386+} __no_randomize_layout;
20387
20388 extern struct pv_info pv_info;
20389 extern struct pv_init_ops pv_init_ops;
20390diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
20391index bf7f8b5..ca5799d 100644
20392--- a/arch/x86/include/asm/pgalloc.h
20393+++ b/arch/x86/include/asm/pgalloc.h
20394@@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
20395 pmd_t *pmd, pte_t *pte)
20396 {
20397 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
20398+ set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
20399+}
20400+
20401+static inline void pmd_populate_user(struct mm_struct *mm,
20402+ pmd_t *pmd, pte_t *pte)
20403+{
20404+ paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
20405 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
20406 }
20407
20408@@ -108,12 +115,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
20409
20410 #ifdef CONFIG_X86_PAE
20411 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
20412+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
20413+{
20414+ pud_populate(mm, pudp, pmd);
20415+}
20416 #else /* !CONFIG_X86_PAE */
20417 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
20418 {
20419 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
20420 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
20421 }
20422+
20423+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
20424+{
20425+ paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
20426+ set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
20427+}
20428 #endif /* CONFIG_X86_PAE */
20429
20430 #if CONFIG_PGTABLE_LEVELS > 3
20431@@ -123,6 +140,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
20432 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
20433 }
20434
20435+static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
20436+{
20437+ paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
20438+ set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
20439+}
20440+
20441 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
20442 {
20443 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
20444diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
20445index fd74a11..35fd5af 100644
20446--- a/arch/x86/include/asm/pgtable-2level.h
20447+++ b/arch/x86/include/asm/pgtable-2level.h
20448@@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
20449
20450 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
20451 {
20452+ pax_open_kernel();
20453 *pmdp = pmd;
20454+ pax_close_kernel();
20455 }
20456
20457 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
20458diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
20459index cdaa58c..ae30f0d 100644
20460--- a/arch/x86/include/asm/pgtable-3level.h
20461+++ b/arch/x86/include/asm/pgtable-3level.h
20462@@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
20463
20464 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
20465 {
20466+ pax_open_kernel();
20467 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
20468+ pax_close_kernel();
20469 }
20470
20471 static inline void native_set_pud(pud_t *pudp, pud_t pud)
20472 {
20473+ pax_open_kernel();
20474 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
20475+ pax_close_kernel();
20476 }
20477
20478 /*
20479@@ -116,9 +120,12 @@ static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr,
20480 static inline void native_pmd_clear(pmd_t *pmd)
20481 {
20482 u32 *tmp = (u32 *)pmd;
20483+
20484+ pax_open_kernel();
20485 *tmp = 0;
20486 smp_wmb();
20487 *(tmp + 1) = 0;
20488+ pax_close_kernel();
20489 }
20490
20491 static inline void pud_clear(pud_t *pudp)
20492diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
20493index 867da5b..7ec083d 100644
20494--- a/arch/x86/include/asm/pgtable.h
20495+++ b/arch/x86/include/asm/pgtable.h
20496@@ -47,6 +47,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
20497
20498 #ifndef __PAGETABLE_PUD_FOLDED
20499 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
20500+#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
20501 #define pgd_clear(pgd) native_pgd_clear(pgd)
20502 #endif
20503
20504@@ -84,12 +85,53 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
20505
20506 #define arch_end_context_switch(prev) do {} while(0)
20507
20508+#define pax_open_kernel() native_pax_open_kernel()
20509+#define pax_close_kernel() native_pax_close_kernel()
20510 #endif /* CONFIG_PARAVIRT */
20511
20512+#define __HAVE_ARCH_PAX_OPEN_KERNEL
20513+#define __HAVE_ARCH_PAX_CLOSE_KERNEL
20514+
20515+#ifdef CONFIG_PAX_KERNEXEC
20516+static inline unsigned long native_pax_open_kernel(void)
20517+{
20518+ unsigned long cr0;
20519+
20520+ preempt_disable();
20521+ barrier();
20522+ cr0 = read_cr0() ^ X86_CR0_WP;
20523+ BUG_ON(cr0 & X86_CR0_WP);
20524+ write_cr0(cr0);
20525+ barrier();
20526+ return cr0 ^ X86_CR0_WP;
20527+}
20528+
20529+static inline unsigned long native_pax_close_kernel(void)
20530+{
20531+ unsigned long cr0;
20532+
20533+ barrier();
20534+ cr0 = read_cr0() ^ X86_CR0_WP;
20535+ BUG_ON(!(cr0 & X86_CR0_WP));
20536+ write_cr0(cr0);
20537+ barrier();
20538+ preempt_enable_no_resched();
20539+ return cr0 ^ X86_CR0_WP;
20540+}
20541+#else
20542+static inline unsigned long native_pax_open_kernel(void) { return 0; }
20543+static inline unsigned long native_pax_close_kernel(void) { return 0; }
20544+#endif
20545+
20546 /*
20547 * The following only work if pte_present() is true.
20548 * Undefined behaviour if not..
20549 */
20550+static inline int pte_user(pte_t pte)
20551+{
20552+ return pte_val(pte) & _PAGE_USER;
20553+}
20554+
20555 static inline int pte_dirty(pte_t pte)
20556 {
20557 return pte_flags(pte) & _PAGE_DIRTY;
20558@@ -150,6 +192,11 @@ static inline unsigned long pud_pfn(pud_t pud)
20559 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
20560 }
20561
20562+static inline unsigned long pgd_pfn(pgd_t pgd)
20563+{
20564+ return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
20565+}
20566+
20567 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
20568
20569 static inline int pmd_large(pmd_t pte)
20570@@ -203,9 +250,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
20571 return pte_clear_flags(pte, _PAGE_RW);
20572 }
20573
20574+static inline pte_t pte_mkread(pte_t pte)
20575+{
20576+ return __pte(pte_val(pte) | _PAGE_USER);
20577+}
20578+
20579 static inline pte_t pte_mkexec(pte_t pte)
20580 {
20581- return pte_clear_flags(pte, _PAGE_NX);
20582+#ifdef CONFIG_X86_PAE
20583+ if (__supported_pte_mask & _PAGE_NX)
20584+ return pte_clear_flags(pte, _PAGE_NX);
20585+ else
20586+#endif
20587+ return pte_set_flags(pte, _PAGE_USER);
20588+}
20589+
20590+static inline pte_t pte_exprotect(pte_t pte)
20591+{
20592+#ifdef CONFIG_X86_PAE
20593+ if (__supported_pte_mask & _PAGE_NX)
20594+ return pte_set_flags(pte, _PAGE_NX);
20595+ else
20596+#endif
20597+ return pte_clear_flags(pte, _PAGE_USER);
20598 }
20599
20600 static inline pte_t pte_mkdirty(pte_t pte)
20601@@ -426,6 +493,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
20602 #endif
20603
20604 #ifndef __ASSEMBLY__
20605+
20606+#ifdef CONFIG_PAX_PER_CPU_PGD
20607+extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
20608+enum cpu_pgd_type {kernel = 0, user = 1};
20609+static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
20610+{
20611+ return cpu_pgd[cpu][type];
20612+}
20613+#endif
20614+
20615 #include <linux/mm_types.h>
20616 #include <linux/mmdebug.h>
20617 #include <linux/log2.h>
20618@@ -577,7 +654,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
20619 * Currently stuck as a macro due to indirect forward reference to
20620 * linux/mmzone.h's __section_mem_map_addr() definition:
20621 */
20622-#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
20623+#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
20624
20625 /* Find an entry in the second-level page table.. */
20626 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
20627@@ -617,7 +694,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
20628 * Currently stuck as a macro due to indirect forward reference to
20629 * linux/mmzone.h's __section_mem_map_addr() definition:
20630 */
20631-#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
20632+#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
20633
20634 /* to find an entry in a page-table-directory. */
20635 static inline unsigned long pud_index(unsigned long address)
20636@@ -632,7 +709,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
20637
20638 static inline int pgd_bad(pgd_t pgd)
20639 {
20640- return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
20641+ return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
20642 }
20643
20644 static inline int pgd_none(pgd_t pgd)
20645@@ -655,7 +732,12 @@ static inline int pgd_none(pgd_t pgd)
20646 * pgd_offset() returns a (pgd_t *)
20647 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
20648 */
20649-#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
20650+#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
20651+
20652+#ifdef CONFIG_PAX_PER_CPU_PGD
20653+#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
20654+#endif
20655+
20656 /*
20657 * a shortcut which implies the use of the kernel's pgd, instead
20658 * of a process's
20659@@ -666,6 +748,25 @@ static inline int pgd_none(pgd_t pgd)
20660 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
20661 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
20662
20663+#ifdef CONFIG_X86_32
20664+#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
20665+#else
20666+#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
20667+#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
20668+
20669+#ifdef CONFIG_PAX_MEMORY_UDEREF
20670+#ifdef __ASSEMBLY__
20671+#define pax_user_shadow_base pax_user_shadow_base(%rip)
20672+#else
20673+extern unsigned long pax_user_shadow_base;
20674+extern pgdval_t clone_pgd_mask;
20675+#endif
20676+#else
20677+#define pax_user_shadow_base (0UL)
20678+#endif
20679+
20680+#endif
20681+
20682 #ifndef __ASSEMBLY__
20683
20684 extern int direct_gbpages;
20685@@ -832,11 +933,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
20686 * dst and src can be on the same page, but the range must not overlap,
20687 * and must not cross a page boundary.
20688 */
20689-static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
20690+static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
20691 {
20692- memcpy(dst, src, count * sizeof(pgd_t));
20693+ pax_open_kernel();
20694+ while (count--)
20695+ *dst++ = *src++;
20696+ pax_close_kernel();
20697 }
20698
20699+#ifdef CONFIG_PAX_PER_CPU_PGD
20700+extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
20701+#endif
20702+
20703+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
20704+extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
20705+#else
20706+static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
20707+#endif
20708+
20709 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
20710 static inline int page_level_shift(enum pg_level level)
20711 {
20712diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
20713index b6c0b40..3535d47 100644
20714--- a/arch/x86/include/asm/pgtable_32.h
20715+++ b/arch/x86/include/asm/pgtable_32.h
20716@@ -25,9 +25,6 @@
20717 struct mm_struct;
20718 struct vm_area_struct;
20719
20720-extern pgd_t swapper_pg_dir[1024];
20721-extern pgd_t initial_page_table[1024];
20722-
20723 static inline void pgtable_cache_init(void) { }
20724 static inline void check_pgt_cache(void) { }
20725 void paging_init(void);
20726@@ -45,6 +42,12 @@ void paging_init(void);
20727 # include <asm/pgtable-2level.h>
20728 #endif
20729
20730+extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
20731+extern pgd_t initial_page_table[PTRS_PER_PGD];
20732+#ifdef CONFIG_X86_PAE
20733+extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
20734+#endif
20735+
20736 #if defined(CONFIG_HIGHPTE)
20737 #define pte_offset_map(dir, address) \
20738 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
20739@@ -59,12 +62,17 @@ void paging_init(void);
20740 /* Clear a kernel PTE and flush it from the TLB */
20741 #define kpte_clear_flush(ptep, vaddr) \
20742 do { \
20743+ pax_open_kernel(); \
20744 pte_clear(&init_mm, (vaddr), (ptep)); \
20745+ pax_close_kernel(); \
20746 __flush_tlb_one((vaddr)); \
20747 } while (0)
20748
20749 #endif /* !__ASSEMBLY__ */
20750
20751+#define HAVE_ARCH_UNMAPPED_AREA
20752+#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
20753+
20754 /*
20755 * kern_addr_valid() is (1) for FLATMEM and (0) for
20756 * SPARSEMEM and DISCONTIGMEM
20757diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
20758index 9fb2f2b..8e18c70 100644
20759--- a/arch/x86/include/asm/pgtable_32_types.h
20760+++ b/arch/x86/include/asm/pgtable_32_types.h
20761@@ -8,7 +8,7 @@
20762 */
20763 #ifdef CONFIG_X86_PAE
20764 # include <asm/pgtable-3level_types.h>
20765-# define PMD_SIZE (1UL << PMD_SHIFT)
20766+# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
20767 # define PMD_MASK (~(PMD_SIZE - 1))
20768 #else
20769 # include <asm/pgtable-2level_types.h>
20770@@ -46,6 +46,28 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
20771 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
20772 #endif
20773
20774+#ifdef CONFIG_PAX_KERNEXEC
20775+#ifndef __ASSEMBLY__
20776+extern unsigned char MODULES_EXEC_VADDR[];
20777+extern unsigned char MODULES_EXEC_END[];
20778+
20779+extern unsigned char __LOAD_PHYSICAL_ADDR[];
20780+#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
20781+static inline unsigned long __intentional_overflow(-1) ktla_ktva(unsigned long addr)
20782+{
20783+ return addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET;
20784+
20785+}
20786+static inline unsigned long __intentional_overflow(-1) ktva_ktla(unsigned long addr)
20787+{
20788+ return addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET;
20789+}
20790+#endif
20791+#else
20792+#define ktla_ktva(addr) (addr)
20793+#define ktva_ktla(addr) (addr)
20794+#endif
20795+
20796 #define MODULES_VADDR VMALLOC_START
20797 #define MODULES_END VMALLOC_END
20798 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
20799diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
20800index 2ee7811..afd76c0 100644
20801--- a/arch/x86/include/asm/pgtable_64.h
20802+++ b/arch/x86/include/asm/pgtable_64.h
20803@@ -16,11 +16,17 @@
20804
20805 extern pud_t level3_kernel_pgt[512];
20806 extern pud_t level3_ident_pgt[512];
20807+extern pud_t level3_vmalloc_start_pgt[512];
20808+extern pud_t level3_vmalloc_end_pgt[512];
20809+extern pud_t level3_vmemmap_pgt[512];
20810+extern pud_t level2_vmemmap_pgt[512];
20811 extern pmd_t level2_kernel_pgt[512];
20812 extern pmd_t level2_fixmap_pgt[512];
20813-extern pmd_t level2_ident_pgt[512];
20814-extern pte_t level1_fixmap_pgt[512];
20815-extern pgd_t init_level4_pgt[];
20816+extern pmd_t level2_ident_pgt[2][512];
20817+extern pte_t level1_modules_pgt[4][512];
20818+extern pte_t level1_fixmap_pgt[3][512];
20819+extern pte_t level1_vsyscall_pgt[512];
20820+extern pgd_t init_level4_pgt[512];
20821
20822 #define swapper_pg_dir init_level4_pgt
20823
20824@@ -62,7 +68,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
20825
20826 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
20827 {
20828+ pax_open_kernel();
20829 *pmdp = pmd;
20830+ pax_close_kernel();
20831 }
20832
20833 static inline void native_pmd_clear(pmd_t *pmd)
20834@@ -98,7 +106,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
20835
20836 static inline void native_set_pud(pud_t *pudp, pud_t pud)
20837 {
20838+ pax_open_kernel();
20839 *pudp = pud;
20840+ pax_close_kernel();
20841 }
20842
20843 static inline void native_pud_clear(pud_t *pud)
20844@@ -108,6 +118,13 @@ static inline void native_pud_clear(pud_t *pud)
20845
20846 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
20847 {
20848+ pax_open_kernel();
20849+ *pgdp = pgd;
20850+ pax_close_kernel();
20851+}
20852+
20853+static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
20854+{
20855 *pgdp = pgd;
20856 }
20857
20858diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
20859index e6844df..432b56e 100644
20860--- a/arch/x86/include/asm/pgtable_64_types.h
20861+++ b/arch/x86/include/asm/pgtable_64_types.h
20862@@ -60,11 +60,16 @@ typedef struct { pteval_t pte; } pte_t;
20863 #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
20864 #define MODULES_END _AC(0xffffffffff000000, UL)
20865 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
20866+#define MODULES_EXEC_VADDR MODULES_VADDR
20867+#define MODULES_EXEC_END MODULES_END
20868 #define ESPFIX_PGD_ENTRY _AC(-2, UL)
20869 #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
20870 #define EFI_VA_START ( -4 * (_AC(1, UL) << 30))
20871 #define EFI_VA_END (-68 * (_AC(1, UL) << 30))
20872
20873+#define ktla_ktva(addr) (addr)
20874+#define ktva_ktla(addr) (addr)
20875+
20876 #define EARLY_DYNAMIC_PAGE_TABLES 64
20877
20878 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
20879diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
20880index 13f310b..f0ef42e 100644
20881--- a/arch/x86/include/asm/pgtable_types.h
20882+++ b/arch/x86/include/asm/pgtable_types.h
20883@@ -85,8 +85,10 @@
20884
20885 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
20886 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
20887-#else
20888+#elif defined(CONFIG_KMEMCHECK) || defined(CONFIG_MEM_SOFT_DIRTY)
20889 #define _PAGE_NX (_AT(pteval_t, 0))
20890+#else
20891+#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
20892 #endif
20893
20894 #define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE)
20895@@ -141,6 +143,9 @@ enum page_cache_mode {
20896 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
20897 _PAGE_ACCESSED)
20898
20899+#define PAGE_READONLY_NOEXEC PAGE_READONLY
20900+#define PAGE_SHARED_NOEXEC PAGE_SHARED
20901+
20902 #define __PAGE_KERNEL_EXEC \
20903 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
20904 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
20905@@ -148,7 +153,7 @@ enum page_cache_mode {
20906 #define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW)
20907 #define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW)
20908 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_NOCACHE)
20909-#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
20910+#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
20911 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
20912 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
20913 #define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE)
20914@@ -194,7 +199,7 @@ enum page_cache_mode {
20915 #ifdef CONFIG_X86_64
20916 #define __PAGE_KERNEL_IDENT_LARGE_EXEC __PAGE_KERNEL_LARGE_EXEC
20917 #else
20918-#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
20919+#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
20920 #define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
20921 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
20922 #endif
20923@@ -233,7 +238,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
20924 {
20925 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
20926 }
20927+#endif
20928
20929+#if CONFIG_PGTABLE_LEVELS == 3
20930+#include <asm-generic/pgtable-nopud.h>
20931+#endif
20932+
20933+#if CONFIG_PGTABLE_LEVELS == 2
20934+#include <asm-generic/pgtable-nopmd.h>
20935+#endif
20936+
20937+#ifndef __ASSEMBLY__
20938 #if CONFIG_PGTABLE_LEVELS > 3
20939 typedef struct { pudval_t pud; } pud_t;
20940
20941@@ -247,8 +262,6 @@ static inline pudval_t native_pud_val(pud_t pud)
20942 return pud.pud;
20943 }
20944 #else
20945-#include <asm-generic/pgtable-nopud.h>
20946-
20947 static inline pudval_t native_pud_val(pud_t pud)
20948 {
20949 return native_pgd_val(pud.pgd);
20950@@ -268,8 +281,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
20951 return pmd.pmd;
20952 }
20953 #else
20954-#include <asm-generic/pgtable-nopmd.h>
20955-
20956 static inline pmdval_t native_pmd_val(pmd_t pmd)
20957 {
20958 return native_pgd_val(pmd.pud.pgd);
20959@@ -362,7 +373,6 @@ typedef struct page *pgtable_t;
20960
20961 extern pteval_t __supported_pte_mask;
20962 extern void set_nx(void);
20963-extern int nx_enabled;
20964
20965 #define pgprot_writecombine pgprot_writecombine
20966 extern pgprot_t pgprot_writecombine(pgprot_t prot);
20967diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h
20968index b12f810..aedcc13 100644
20969--- a/arch/x86/include/asm/preempt.h
20970+++ b/arch/x86/include/asm/preempt.h
20971@@ -84,7 +84,7 @@ static __always_inline void __preempt_count_sub(int val)
20972 */
20973 static __always_inline bool __preempt_count_dec_and_test(void)
20974 {
20975- GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), "e");
20976+ GEN_UNARY_RMWcc("decl", "incl", __preempt_count, __percpu_arg(0), "e");
20977 }
20978
20979 /*
20980diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
20981index 944f178..f2269de 100644
20982--- a/arch/x86/include/asm/processor.h
20983+++ b/arch/x86/include/asm/processor.h
20984@@ -136,7 +136,7 @@ struct cpuinfo_x86 {
20985 /* Index into per_cpu list: */
20986 u16 cpu_index;
20987 u32 microcode;
20988-};
20989+} __randomize_layout;
20990
20991 #define X86_VENDOR_INTEL 0
20992 #define X86_VENDOR_CYRIX 1
20993@@ -206,9 +206,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
20994 : "memory");
20995 }
20996
20997+/* invpcid (%rdx),%rax */
20998+#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
20999+
21000+#define INVPCID_SINGLE_ADDRESS 0UL
21001+#define INVPCID_SINGLE_CONTEXT 1UL
21002+#define INVPCID_ALL_GLOBAL 2UL
21003+#define INVPCID_ALL_NONGLOBAL 3UL
21004+
21005+#define PCID_KERNEL 0UL
21006+#define PCID_USER 1UL
21007+#define PCID_NOFLUSH (1UL << 63)
21008+
21009 static inline void load_cr3(pgd_t *pgdir)
21010 {
21011- write_cr3(__pa(pgdir));
21012+ write_cr3(__pa(pgdir) | PCID_KERNEL);
21013 }
21014
21015 #ifdef CONFIG_X86_32
21016@@ -305,11 +317,9 @@ struct tss_struct {
21017
21018 } ____cacheline_aligned;
21019
21020-DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss);
21021+extern struct tss_struct cpu_tss[NR_CPUS];
21022
21023-#ifdef CONFIG_X86_32
21024 DECLARE_PER_CPU(unsigned long, cpu_current_top_of_stack);
21025-#endif
21026
21027 /*
21028 * Save the original ist values for checking stack pointers during debugging
21029@@ -381,6 +391,7 @@ struct thread_struct {
21030 unsigned short ds;
21031 unsigned short fsindex;
21032 unsigned short gsindex;
21033+ unsigned short ss;
21034 #endif
21035 #ifdef CONFIG_X86_32
21036 unsigned long ip;
21037@@ -390,6 +401,9 @@ struct thread_struct {
21038 #endif
21039 unsigned long gs;
21040
21041+ /* Floating point and extended processor state */
21042+ struct fpu fpu;
21043+
21044 /* Save middle states of ptrace breakpoints */
21045 struct perf_event *ptrace_bps[HBP_NUM];
21046 /* Debug status used for traps, single steps, etc... */
21047@@ -415,13 +429,6 @@ struct thread_struct {
21048 unsigned long iopl;
21049 /* Max allowed port in the bitmap, in bytes: */
21050 unsigned io_bitmap_max;
21051-
21052- /* Floating point and extended processor state */
21053- struct fpu fpu;
21054- /*
21055- * WARNING: 'fpu' is dynamically-sized. It *MUST* be at
21056- * the end.
21057- */
21058 };
21059
21060 /*
21061@@ -463,10 +470,10 @@ static inline void native_swapgs(void)
21062 #endif
21063 }
21064
21065-static inline unsigned long current_top_of_stack(void)
21066+static inline unsigned long current_top_of_stack(unsigned int cpu)
21067 {
21068 #ifdef CONFIG_X86_64
21069- return this_cpu_read_stable(cpu_tss.x86_tss.sp0);
21070+ return cpu_tss[cpu].x86_tss.sp0;
21071 #else
21072 /* sp0 on x86_32 is special in and around vm86 mode. */
21073 return this_cpu_read_stable(cpu_current_top_of_stack);
21074@@ -709,20 +716,30 @@ static inline void spin_lock_prefetch(const void *x)
21075 #define TOP_OF_INIT_STACK ((unsigned long)&init_stack + sizeof(init_stack) - \
21076 TOP_OF_KERNEL_STACK_PADDING)
21077
21078+extern union fpregs_state init_fpregs_state;
21079+
21080 #ifdef CONFIG_X86_32
21081 /*
21082 * User space process size: 3GB (default).
21083 */
21084 #define TASK_SIZE PAGE_OFFSET
21085 #define TASK_SIZE_MAX TASK_SIZE
21086+
21087+#ifdef CONFIG_PAX_SEGMEXEC
21088+#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
21089+#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
21090+#else
21091 #define STACK_TOP TASK_SIZE
21092-#define STACK_TOP_MAX STACK_TOP
21093+#endif
21094+
21095+#define STACK_TOP_MAX TASK_SIZE
21096
21097 #define INIT_THREAD { \
21098 .sp0 = TOP_OF_INIT_STACK, \
21099 .vm86_info = NULL, \
21100 .sysenter_cs = __KERNEL_CS, \
21101 .io_bitmap_ptr = NULL, \
21102+ .fpu.state = &init_fpregs_state, \
21103 }
21104
21105 extern unsigned long thread_saved_pc(struct task_struct *tsk);
21106@@ -737,12 +754,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
21107 * "struct pt_regs" is possible, but they may contain the
21108 * completely wrong values.
21109 */
21110-#define task_pt_regs(task) \
21111-({ \
21112- unsigned long __ptr = (unsigned long)task_stack_page(task); \
21113- __ptr += THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING; \
21114- ((struct pt_regs *)__ptr) - 1; \
21115-})
21116+#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)
21117
21118 #define KSTK_ESP(task) (task_pt_regs(task)->sp)
21119
21120@@ -756,13 +768,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
21121 * particular problem by preventing anything from being mapped
21122 * at the maximum canonical address.
21123 */
21124-#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
21125+#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
21126
21127 /* This decides where the kernel will search for a free chunk of vm
21128 * space during mmap's.
21129 */
21130 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
21131- 0xc0000000 : 0xFFFFe000)
21132+ 0xc0000000 : 0xFFFFf000)
21133
21134 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
21135 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
21136@@ -773,7 +785,8 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
21137 #define STACK_TOP_MAX TASK_SIZE_MAX
21138
21139 #define INIT_THREAD { \
21140- .sp0 = TOP_OF_INIT_STACK \
21141+ .sp0 = TOP_OF_INIT_STACK, \
21142+ .fpu.state = &init_fpregs_state, \
21143 }
21144
21145 /*
21146@@ -796,6 +809,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
21147 */
21148 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
21149
21150+#ifdef CONFIG_PAX_SEGMEXEC
21151+#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
21152+#endif
21153+
21154 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
21155
21156 /* Get/set a process' ability to use the timestamp counter instruction */
21157@@ -841,7 +858,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
21158 return 0;
21159 }
21160
21161-extern unsigned long arch_align_stack(unsigned long sp);
21162+#define arch_align_stack(x) ((x) & ~0xfUL)
21163 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
21164
21165 void default_idle(void);
21166@@ -851,6 +868,6 @@ bool xen_set_default_idle(void);
21167 #define xen_set_default_idle 0
21168 #endif
21169
21170-void stop_this_cpu(void *dummy);
21171+void stop_this_cpu(void *dummy) __noreturn;
21172 void df_debug(struct pt_regs *regs, long error_code);
21173 #endif /* _ASM_X86_PROCESSOR_H */
21174diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
21175index 5fabf13..7388158 100644
21176--- a/arch/x86/include/asm/ptrace.h
21177+++ b/arch/x86/include/asm/ptrace.h
21178@@ -125,15 +125,16 @@ static inline int v8086_mode(struct pt_regs *regs)
21179 #ifdef CONFIG_X86_64
21180 static inline bool user_64bit_mode(struct pt_regs *regs)
21181 {
21182+ unsigned long cs = regs->cs & 0xffff;
21183 #ifndef CONFIG_PARAVIRT
21184 /*
21185 * On non-paravirt systems, this is the only long mode CPL 3
21186 * selector. We do not allow long mode selectors in the LDT.
21187 */
21188- return regs->cs == __USER_CS;
21189+ return cs == __USER_CS;
21190 #else
21191 /* Headers are too twisted for this to go in paravirt.h. */
21192- return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
21193+ return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
21194 #endif
21195 }
21196
21197@@ -180,9 +181,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
21198 * Traps from the kernel do not save sp and ss.
21199 * Use the helper function to retrieve sp.
21200 */
21201- if (offset == offsetof(struct pt_regs, sp) &&
21202- regs->cs == __KERNEL_CS)
21203- return kernel_stack_pointer(regs);
21204+ if (offset == offsetof(struct pt_regs, sp)) {
21205+ unsigned long cs = regs->cs & 0xffff;
21206+ if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
21207+ return kernel_stack_pointer(regs);
21208+ }
21209 #endif
21210 return *(unsigned long *)((unsigned long)regs + offset);
21211 }
21212diff --git a/arch/x86/include/asm/qrwlock.h b/arch/x86/include/asm/qrwlock.h
21213index ae0e241..e80b10b 100644
21214--- a/arch/x86/include/asm/qrwlock.h
21215+++ b/arch/x86/include/asm/qrwlock.h
21216@@ -7,8 +7,8 @@
21217 #define queue_write_unlock queue_write_unlock
21218 static inline void queue_write_unlock(struct qrwlock *lock)
21219 {
21220- barrier();
21221- ACCESS_ONCE(*(u8 *)&lock->cnts) = 0;
21222+ barrier();
21223+ ACCESS_ONCE_RW(*(u8 *)&lock->cnts) = 0;
21224 }
21225 #endif
21226
21227diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
21228index 9c6b890..5305f53 100644
21229--- a/arch/x86/include/asm/realmode.h
21230+++ b/arch/x86/include/asm/realmode.h
21231@@ -22,16 +22,14 @@ struct real_mode_header {
21232 #endif
21233 /* APM/BIOS reboot */
21234 u32 machine_real_restart_asm;
21235-#ifdef CONFIG_X86_64
21236 u32 machine_real_restart_seg;
21237-#endif
21238 };
21239
21240 /* This must match data at trampoline_32/64.S */
21241 struct trampoline_header {
21242 #ifdef CONFIG_X86_32
21243 u32 start;
21244- u16 gdt_pad;
21245+ u16 boot_cs;
21246 u16 gdt_limit;
21247 u32 gdt_base;
21248 #else
21249diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
21250index a82c4f1..ac45053 100644
21251--- a/arch/x86/include/asm/reboot.h
21252+++ b/arch/x86/include/asm/reboot.h
21253@@ -6,13 +6,13 @@
21254 struct pt_regs;
21255
21256 struct machine_ops {
21257- void (*restart)(char *cmd);
21258- void (*halt)(void);
21259- void (*power_off)(void);
21260+ void (* __noreturn restart)(char *cmd);
21261+ void (* __noreturn halt)(void);
21262+ void (* __noreturn power_off)(void);
21263 void (*shutdown)(void);
21264 void (*crash_shutdown)(struct pt_regs *);
21265- void (*emergency_restart)(void);
21266-};
21267+ void (* __noreturn emergency_restart)(void);
21268+} __no_const;
21269
21270 extern struct machine_ops machine_ops;
21271
21272diff --git a/arch/x86/include/asm/rmwcc.h b/arch/x86/include/asm/rmwcc.h
21273index 8f7866a..e442f20 100644
21274--- a/arch/x86/include/asm/rmwcc.h
21275+++ b/arch/x86/include/asm/rmwcc.h
21276@@ -3,7 +3,34 @@
21277
21278 #ifdef CC_HAVE_ASM_GOTO
21279
21280-#define __GEN_RMWcc(fullop, var, cc, ...) \
21281+#ifdef CONFIG_PAX_REFCOUNT
21282+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
21283+do { \
21284+ asm_volatile_goto (fullop \
21285+ ";jno 0f\n" \
21286+ fullantiop \
21287+ ";int $4\n0:\n" \
21288+ _ASM_EXTABLE(0b, 0b) \
21289+ ";j" cc " %l[cc_label]" \
21290+ : : "m" (var), ## __VA_ARGS__ \
21291+ : "memory" : cc_label); \
21292+ return 0; \
21293+cc_label: \
21294+ return 1; \
21295+} while (0)
21296+#else
21297+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
21298+do { \
21299+ asm_volatile_goto (fullop ";j" cc " %l[cc_label]" \
21300+ : : "m" (var), ## __VA_ARGS__ \
21301+ : "memory" : cc_label); \
21302+ return 0; \
21303+cc_label: \
21304+ return 1; \
21305+} while (0)
21306+#endif
21307+
21308+#define __GEN_RMWcc_unchecked(fullop, var, cc, ...) \
21309 do { \
21310 asm_volatile_goto (fullop "; j" cc " %l[cc_label]" \
21311 : : "m" (var), ## __VA_ARGS__ \
21312@@ -13,15 +40,46 @@ cc_label: \
21313 return 1; \
21314 } while (0)
21315
21316-#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
21317- __GEN_RMWcc(op " " arg0, var, cc)
21318+#define GEN_UNARY_RMWcc(op, antiop, var, arg0, cc) \
21319+ __GEN_RMWcc(op " " arg0, antiop " " arg0, var, cc)
21320
21321-#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
21322- __GEN_RMWcc(op " %1, " arg0, var, cc, vcon (val))
21323+#define GEN_UNARY_RMWcc_unchecked(op, var, arg0, cc) \
21324+ __GEN_RMWcc_unchecked(op " " arg0, var, cc)
21325+
21326+#define GEN_BINARY_RMWcc(op, antiop, var, vcon, val, arg0, cc) \
21327+ __GEN_RMWcc(op " %1, " arg0, antiop " %1, " arg0, var, cc, vcon (val))
21328+
21329+#define GEN_BINARY_RMWcc_unchecked(op, var, vcon, val, arg0, cc) \
21330+ __GEN_RMWcc_unchecked(op " %1, " arg0, var, cc, vcon (val))
21331
21332 #else /* !CC_HAVE_ASM_GOTO */
21333
21334-#define __GEN_RMWcc(fullop, var, cc, ...) \
21335+#ifdef CONFIG_PAX_REFCOUNT
21336+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
21337+do { \
21338+ char c; \
21339+ asm volatile (fullop \
21340+ ";jno 0f\n" \
21341+ fullantiop \
21342+ ";int $4\n0:\n" \
21343+ _ASM_EXTABLE(0b, 0b) \
21344+ "; set" cc " %1" \
21345+ : "+m" (var), "=qm" (c) \
21346+ : __VA_ARGS__ : "memory"); \
21347+ return c != 0; \
21348+} while (0)
21349+#else
21350+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
21351+do { \
21352+ char c; \
21353+ asm volatile (fullop "; set" cc " %1" \
21354+ : "+m" (var), "=qm" (c) \
21355+ : __VA_ARGS__ : "memory"); \
21356+ return c != 0; \
21357+} while (0)
21358+#endif
21359+
21360+#define __GEN_RMWcc_unchecked(fullop, var, cc, ...) \
21361 do { \
21362 char c; \
21363 asm volatile (fullop "; set" cc " %1" \
21364@@ -30,11 +88,17 @@ do { \
21365 return c != 0; \
21366 } while (0)
21367
21368-#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
21369- __GEN_RMWcc(op " " arg0, var, cc)
21370+#define GEN_UNARY_RMWcc(op, antiop, var, arg0, cc) \
21371+ __GEN_RMWcc(op " " arg0, antiop " " arg0, var, cc)
21372+
21373+#define GEN_UNARY_RMWcc_unchecked(op, var, arg0, cc) \
21374+ __GEN_RMWcc_unchecked(op " " arg0, var, cc)
21375+
21376+#define GEN_BINARY_RMWcc(op, antiop, var, vcon, val, arg0, cc) \
21377+ __GEN_RMWcc(op " %2, " arg0, antiop " %2, " arg0, var, cc, vcon (val))
21378
21379-#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
21380- __GEN_RMWcc(op " %2, " arg0, var, cc, vcon (val))
21381+#define GEN_BINARY_RMWcc_unchecked(op, var, vcon, val, arg0, cc) \
21382+ __GEN_RMWcc_unchecked(op " %2, " arg0, var, cc, vcon (val))
21383
21384 #endif /* CC_HAVE_ASM_GOTO */
21385
21386diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
21387index cad82c9..2e5c5c1 100644
21388--- a/arch/x86/include/asm/rwsem.h
21389+++ b/arch/x86/include/asm/rwsem.h
21390@@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
21391 {
21392 asm volatile("# beginning down_read\n\t"
21393 LOCK_PREFIX _ASM_INC "(%1)\n\t"
21394+
21395+#ifdef CONFIG_PAX_REFCOUNT
21396+ "jno 0f\n"
21397+ LOCK_PREFIX _ASM_DEC "(%1)\n"
21398+ "int $4\n0:\n"
21399+ _ASM_EXTABLE(0b, 0b)
21400+#endif
21401+
21402 /* adds 0x00000001 */
21403 " jns 1f\n"
21404 " call call_rwsem_down_read_failed\n"
21405@@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
21406 "1:\n\t"
21407 " mov %1,%2\n\t"
21408 " add %3,%2\n\t"
21409+
21410+#ifdef CONFIG_PAX_REFCOUNT
21411+ "jno 0f\n"
21412+ "sub %3,%2\n"
21413+ "int $4\n0:\n"
21414+ _ASM_EXTABLE(0b, 0b)
21415+#endif
21416+
21417 " jle 2f\n\t"
21418 LOCK_PREFIX " cmpxchg %2,%0\n\t"
21419 " jnz 1b\n\t"
21420@@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
21421 long tmp;
21422 asm volatile("# beginning down_write\n\t"
21423 LOCK_PREFIX " xadd %1,(%2)\n\t"
21424+
21425+#ifdef CONFIG_PAX_REFCOUNT
21426+ "jno 0f\n"
21427+ "mov %1,(%2)\n"
21428+ "int $4\n0:\n"
21429+ _ASM_EXTABLE(0b, 0b)
21430+#endif
21431+
21432 /* adds 0xffff0001, returns the old value */
21433 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
21434 /* was the active mask 0 before? */
21435@@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
21436 long tmp;
21437 asm volatile("# beginning __up_read\n\t"
21438 LOCK_PREFIX " xadd %1,(%2)\n\t"
21439+
21440+#ifdef CONFIG_PAX_REFCOUNT
21441+ "jno 0f\n"
21442+ "mov %1,(%2)\n"
21443+ "int $4\n0:\n"
21444+ _ASM_EXTABLE(0b, 0b)
21445+#endif
21446+
21447 /* subtracts 1, returns the old value */
21448 " jns 1f\n\t"
21449 " call call_rwsem_wake\n" /* expects old value in %edx */
21450@@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
21451 long tmp;
21452 asm volatile("# beginning __up_write\n\t"
21453 LOCK_PREFIX " xadd %1,(%2)\n\t"
21454+
21455+#ifdef CONFIG_PAX_REFCOUNT
21456+ "jno 0f\n"
21457+ "mov %1,(%2)\n"
21458+ "int $4\n0:\n"
21459+ _ASM_EXTABLE(0b, 0b)
21460+#endif
21461+
21462 /* subtracts 0xffff0001, returns the old value */
21463 " jns 1f\n\t"
21464 " call call_rwsem_wake\n" /* expects old value in %edx */
21465@@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
21466 {
21467 asm volatile("# beginning __downgrade_write\n\t"
21468 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
21469+
21470+#ifdef CONFIG_PAX_REFCOUNT
21471+ "jno 0f\n"
21472+ LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
21473+ "int $4\n0:\n"
21474+ _ASM_EXTABLE(0b, 0b)
21475+#endif
21476+
21477 /*
21478 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
21479 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
21480@@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
21481 */
21482 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
21483 {
21484- asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
21485+ asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
21486+
21487+#ifdef CONFIG_PAX_REFCOUNT
21488+ "jno 0f\n"
21489+ LOCK_PREFIX _ASM_SUB "%1,%0\n"
21490+ "int $4\n0:\n"
21491+ _ASM_EXTABLE(0b, 0b)
21492+#endif
21493+
21494 : "+m" (sem->count)
21495 : "er" (delta));
21496 }
21497@@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
21498 */
21499 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
21500 {
21501- return delta + xadd(&sem->count, delta);
21502+ return delta + xadd_check_overflow(&sem->count, delta);
21503 }
21504
21505 #endif /* __KERNEL__ */
21506diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
21507index 7d5a192..23ef1aa 100644
21508--- a/arch/x86/include/asm/segment.h
21509+++ b/arch/x86/include/asm/segment.h
21510@@ -82,14 +82,20 @@
21511 * 26 - ESPFIX small SS
21512 * 27 - per-cpu [ offset to per-cpu data area ]
21513 * 28 - stack_canary-20 [ for stack protector ] <=== cacheline #8
21514- * 29 - unused
21515- * 30 - unused
21516+ * 29 - PCI BIOS CS
21517+ * 30 - PCI BIOS DS
21518 * 31 - TSS for double fault handler
21519 */
21520+#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
21521+#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
21522+#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
21523+#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
21524+
21525 #define GDT_ENTRY_TLS_MIN 6
21526 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
21527
21528 #define GDT_ENTRY_KERNEL_CS 12
21529+#define GDT_ENTRY_KERNEXEC_KERNEL_CS 4
21530 #define GDT_ENTRY_KERNEL_DS 13
21531 #define GDT_ENTRY_DEFAULT_USER_CS 14
21532 #define GDT_ENTRY_DEFAULT_USER_DS 15
21533@@ -106,6 +112,12 @@
21534 #define GDT_ENTRY_PERCPU 27
21535 #define GDT_ENTRY_STACK_CANARY 28
21536
21537+#define GDT_ENTRY_PCIBIOS_CS 29
21538+#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
21539+
21540+#define GDT_ENTRY_PCIBIOS_DS 30
21541+#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
21542+
21543 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
21544
21545 /*
21546@@ -118,6 +130,7 @@
21547 */
21548
21549 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
21550+#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
21551 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
21552 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3)
21553 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8 + 3)
21554@@ -129,7 +142,7 @@
21555 #define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16*8)
21556
21557 /* "Is this PNP code selector (PNP_CS32 or PNP_CS16)?" */
21558-#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == PNP_CS32)
21559+#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
21560
21561 /* data segment for BIOS: */
21562 #define PNP_DS (GDT_ENTRY_PNPBIOS_DS*8)
21563@@ -176,6 +189,8 @@
21564 #define GDT_ENTRY_DEFAULT_USER_DS 5
21565 #define GDT_ENTRY_DEFAULT_USER_CS 6
21566
21567+#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
21568+
21569 /* Needs two entries */
21570 #define GDT_ENTRY_TSS 8
21571 /* Needs two entries */
21572@@ -187,10 +202,12 @@
21573 /* Abused to load per CPU data from limit */
21574 #define GDT_ENTRY_PER_CPU 15
21575
21576+#define GDT_ENTRY_UDEREF_KERNEL_DS 16
21577+
21578 /*
21579 * Number of entries in the GDT table:
21580 */
21581-#define GDT_ENTRIES 16
21582+#define GDT_ENTRIES 17
21583
21584 /*
21585 * Segment selector values corresponding to the above entries:
21586@@ -200,7 +217,9 @@
21587 */
21588 #define __KERNEL32_CS (GDT_ENTRY_KERNEL32_CS*8)
21589 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
21590+#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
21591 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
21592+#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
21593 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8 + 3)
21594 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3)
21595 #define __USER32_DS __USER_DS
21596diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
21597index ba665eb..0f72938 100644
21598--- a/arch/x86/include/asm/smap.h
21599+++ b/arch/x86/include/asm/smap.h
21600@@ -25,6 +25,18 @@
21601
21602 #include <asm/alternative-asm.h>
21603
21604+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21605+#define ASM_PAX_OPEN_USERLAND \
21606+ ALTERNATIVE "", "call __pax_open_userland", X86_FEATURE_STRONGUDEREF
21607+
21608+#define ASM_PAX_CLOSE_USERLAND \
21609+ ALTERNATIVE "", "call __pax_close_userland", X86_FEATURE_STRONGUDEREF
21610+
21611+#else
21612+#define ASM_PAX_OPEN_USERLAND
21613+#define ASM_PAX_CLOSE_USERLAND
21614+#endif
21615+
21616 #ifdef CONFIG_X86_SMAP
21617
21618 #define ASM_CLAC \
21619@@ -44,6 +56,37 @@
21620
21621 #include <asm/alternative.h>
21622
21623+#define __HAVE_ARCH_PAX_OPEN_USERLAND
21624+#define __HAVE_ARCH_PAX_CLOSE_USERLAND
21625+
21626+extern void __pax_open_userland(void);
21627+static __always_inline unsigned long pax_open_userland(void)
21628+{
21629+
21630+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21631+ asm volatile(ALTERNATIVE("", "call %P[open]", X86_FEATURE_STRONGUDEREF)
21632+ :
21633+ : [open] "i" (__pax_open_userland)
21634+ : "memory", "rax");
21635+#endif
21636+
21637+ return 0;
21638+}
21639+
21640+extern void __pax_close_userland(void);
21641+static __always_inline unsigned long pax_close_userland(void)
21642+{
21643+
21644+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21645+ asm volatile(ALTERNATIVE("", "call %P[close]", X86_FEATURE_STRONGUDEREF)
21646+ :
21647+ : [close] "i" (__pax_close_userland)
21648+ : "memory", "rax");
21649+#endif
21650+
21651+ return 0;
21652+}
21653+
21654 #ifdef CONFIG_X86_SMAP
21655
21656 static __always_inline void clac(void)
21657diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
21658index 222a6a3..839da8d 100644
21659--- a/arch/x86/include/asm/smp.h
21660+++ b/arch/x86/include/asm/smp.h
21661@@ -35,7 +35,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
21662 /* cpus sharing the last level cache: */
21663 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
21664 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
21665-DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
21666+DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
21667
21668 static inline struct cpumask *cpu_llc_shared_mask(int cpu)
21669 {
21670@@ -68,7 +68,7 @@ struct smp_ops {
21671
21672 void (*send_call_func_ipi)(const struct cpumask *mask);
21673 void (*send_call_func_single_ipi)(int cpu);
21674-};
21675+} __no_const;
21676
21677 /* Globals due to paravirt */
21678 extern void set_cpu_sibling_map(int cpu);
21679@@ -182,14 +182,8 @@ extern unsigned disabled_cpus;
21680 extern int safe_smp_processor_id(void);
21681
21682 #elif defined(CONFIG_X86_64_SMP)
21683-#define raw_smp_processor_id() (this_cpu_read(cpu_number))
21684-
21685-#define stack_smp_processor_id() \
21686-({ \
21687- struct thread_info *ti; \
21688- __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
21689- ti->cpu; \
21690-})
21691+#define raw_smp_processor_id() (this_cpu_read(cpu_number))
21692+#define stack_smp_processor_id() raw_smp_processor_id()
21693 #define safe_smp_processor_id() smp_processor_id()
21694
21695 #endif
21696diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
21697index c2e00bb..a10266e 100644
21698--- a/arch/x86/include/asm/stackprotector.h
21699+++ b/arch/x86/include/asm/stackprotector.h
21700@@ -49,7 +49,7 @@
21701 * head_32 for boot CPU and setup_per_cpu_areas() for others.
21702 */
21703 #define GDT_STACK_CANARY_INIT \
21704- [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
21705+ [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
21706
21707 /*
21708 * Initialize the stackprotector canary value.
21709@@ -114,7 +114,7 @@ static inline void setup_stack_canary_segment(int cpu)
21710
21711 static inline void load_stack_canary_segment(void)
21712 {
21713-#ifdef CONFIG_X86_32
21714+#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
21715 asm volatile ("mov %0, %%gs" : : "r" (0));
21716 #endif
21717 }
21718diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
21719index 70bbe39..4ae2bd4 100644
21720--- a/arch/x86/include/asm/stacktrace.h
21721+++ b/arch/x86/include/asm/stacktrace.h
21722@@ -11,28 +11,20 @@
21723
21724 extern int kstack_depth_to_print;
21725
21726-struct thread_info;
21727+struct task_struct;
21728 struct stacktrace_ops;
21729
21730-typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
21731- unsigned long *stack,
21732- unsigned long bp,
21733- const struct stacktrace_ops *ops,
21734- void *data,
21735- unsigned long *end,
21736- int *graph);
21737+typedef unsigned long walk_stack_t(struct task_struct *task,
21738+ void *stack_start,
21739+ unsigned long *stack,
21740+ unsigned long bp,
21741+ const struct stacktrace_ops *ops,
21742+ void *data,
21743+ unsigned long *end,
21744+ int *graph);
21745
21746-extern unsigned long
21747-print_context_stack(struct thread_info *tinfo,
21748- unsigned long *stack, unsigned long bp,
21749- const struct stacktrace_ops *ops, void *data,
21750- unsigned long *end, int *graph);
21751-
21752-extern unsigned long
21753-print_context_stack_bp(struct thread_info *tinfo,
21754- unsigned long *stack, unsigned long bp,
21755- const struct stacktrace_ops *ops, void *data,
21756- unsigned long *end, int *graph);
21757+extern walk_stack_t print_context_stack;
21758+extern walk_stack_t print_context_stack_bp;
21759
21760 /* Generic stack tracer with callbacks */
21761
21762@@ -40,7 +32,7 @@ struct stacktrace_ops {
21763 void (*address)(void *data, unsigned long address, int reliable);
21764 /* On negative return stop dumping */
21765 int (*stack)(void *data, char *name);
21766- walk_stack_t walk_stack;
21767+ walk_stack_t *walk_stack;
21768 };
21769
21770 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
21771diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
21772index d7f3b3b..3cc39f1 100644
21773--- a/arch/x86/include/asm/switch_to.h
21774+++ b/arch/x86/include/asm/switch_to.h
21775@@ -108,7 +108,7 @@ do { \
21776 "call __switch_to\n\t" \
21777 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
21778 __switch_canary \
21779- "movq %P[thread_info](%%rsi),%%r8\n\t" \
21780+ "movq "__percpu_arg([thread_info])",%%r8\n\t" \
21781 "movq %%rax,%%rdi\n\t" \
21782 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
21783 "jnz ret_from_fork\n\t" \
21784@@ -119,7 +119,7 @@ do { \
21785 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
21786 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
21787 [_tif_fork] "i" (_TIF_FORK), \
21788- [thread_info] "i" (offsetof(struct task_struct, stack)), \
21789+ [thread_info] "m" (current_tinfo), \
21790 [current_task] "m" (current_task) \
21791 __switch_canary_iparam \
21792 : "memory", "cc" __EXTRA_CLOBBER)
21793diff --git a/arch/x86/include/asm/sys_ia32.h b/arch/x86/include/asm/sys_ia32.h
21794index 82c34ee..940fa40 100644
21795--- a/arch/x86/include/asm/sys_ia32.h
21796+++ b/arch/x86/include/asm/sys_ia32.h
21797@@ -20,8 +20,8 @@
21798 #include <asm/ia32.h>
21799
21800 /* ia32/sys_ia32.c */
21801-asmlinkage long sys32_truncate64(const char __user *, unsigned long, unsigned long);
21802-asmlinkage long sys32_ftruncate64(unsigned int, unsigned long, unsigned long);
21803+asmlinkage long sys32_truncate64(const char __user *, unsigned int, unsigned int);
21804+asmlinkage long sys32_ftruncate64(unsigned int, unsigned int, unsigned int);
21805
21806 asmlinkage long sys32_stat64(const char __user *, struct stat64 __user *);
21807 asmlinkage long sys32_lstat64(const char __user *, struct stat64 __user *);
21808@@ -42,7 +42,7 @@ long sys32_vm86_warning(void);
21809 asmlinkage ssize_t sys32_readahead(int, unsigned, unsigned, size_t);
21810 asmlinkage long sys32_sync_file_range(int, unsigned, unsigned,
21811 unsigned, unsigned, int);
21812-asmlinkage long sys32_fadvise64(int, unsigned, unsigned, size_t, int);
21813+asmlinkage long sys32_fadvise64(int, unsigned, unsigned, int, int);
21814 asmlinkage long sys32_fallocate(int, int, unsigned,
21815 unsigned, unsigned, unsigned);
21816
21817diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
21818index 225ee54..fae4566 100644
21819--- a/arch/x86/include/asm/thread_info.h
21820+++ b/arch/x86/include/asm/thread_info.h
21821@@ -36,7 +36,7 @@
21822 #ifdef CONFIG_X86_32
21823 # define TOP_OF_KERNEL_STACK_PADDING 8
21824 #else
21825-# define TOP_OF_KERNEL_STACK_PADDING 0
21826+# define TOP_OF_KERNEL_STACK_PADDING 16
21827 #endif
21828
21829 /*
21830@@ -50,27 +50,26 @@ struct task_struct;
21831 #include <linux/atomic.h>
21832
21833 struct thread_info {
21834- struct task_struct *task; /* main task structure */
21835 __u32 flags; /* low level flags */
21836 __u32 status; /* thread synchronous flags */
21837 __u32 cpu; /* current CPU */
21838 int saved_preempt_count;
21839 mm_segment_t addr_limit;
21840 void __user *sysenter_return;
21841+ unsigned long lowest_stack;
21842 unsigned int sig_on_uaccess_error:1;
21843 unsigned int uaccess_err:1; /* uaccess failed */
21844 };
21845
21846-#define INIT_THREAD_INFO(tsk) \
21847+#define INIT_THREAD_INFO \
21848 { \
21849- .task = &tsk, \
21850 .flags = 0, \
21851 .cpu = 0, \
21852 .saved_preempt_count = INIT_PREEMPT_COUNT, \
21853 .addr_limit = KERNEL_DS, \
21854 }
21855
21856-#define init_thread_info (init_thread_union.thread_info)
21857+#define init_thread_info (init_thread_union.stack)
21858 #define init_stack (init_thread_union.stack)
21859
21860 #else /* !__ASSEMBLY__ */
21861@@ -110,6 +109,7 @@ struct thread_info {
21862 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
21863 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
21864 #define TIF_X32 30 /* 32-bit native x86-64 binary */
21865+#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
21866
21867 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
21868 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
21869@@ -133,17 +133,18 @@ struct thread_info {
21870 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
21871 #define _TIF_ADDR32 (1 << TIF_ADDR32)
21872 #define _TIF_X32 (1 << TIF_X32)
21873+#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
21874
21875 /* work to do in syscall_trace_enter() */
21876 #define _TIF_WORK_SYSCALL_ENTRY \
21877 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
21878 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
21879- _TIF_NOHZ)
21880+ _TIF_NOHZ | _TIF_GRSEC_SETXID)
21881
21882 /* work to do in syscall_trace_leave() */
21883 #define _TIF_WORK_SYSCALL_EXIT \
21884 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
21885- _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
21886+ _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
21887
21888 /* work to do on interrupt/exception return */
21889 #define _TIF_WORK_MASK \
21890@@ -154,7 +155,7 @@ struct thread_info {
21891 /* work to do on any return to user space */
21892 #define _TIF_ALLWORK_MASK \
21893 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
21894- _TIF_NOHZ)
21895+ _TIF_NOHZ | _TIF_GRSEC_SETXID)
21896
21897 /* Only used for 64 bit */
21898 #define _TIF_DO_NOTIFY_MASK \
21899@@ -177,9 +178,11 @@ struct thread_info {
21900 */
21901 #ifndef __ASSEMBLY__
21902
21903+DECLARE_PER_CPU(struct thread_info *, current_tinfo);
21904+
21905 static inline struct thread_info *current_thread_info(void)
21906 {
21907- return (struct thread_info *)(current_top_of_stack() - THREAD_SIZE);
21908+ return this_cpu_read_stable(current_tinfo);
21909 }
21910
21911 static inline unsigned long current_stack_pointer(void)
21912@@ -195,14 +198,9 @@ static inline unsigned long current_stack_pointer(void)
21913
21914 #else /* !__ASSEMBLY__ */
21915
21916-#ifdef CONFIG_X86_64
21917-# define cpu_current_top_of_stack (cpu_tss + TSS_sp0)
21918-#endif
21919-
21920 /* Load thread_info address into "reg" */
21921 #define GET_THREAD_INFO(reg) \
21922- _ASM_MOV PER_CPU_VAR(cpu_current_top_of_stack),reg ; \
21923- _ASM_SUB $(THREAD_SIZE),reg ;
21924+ _ASM_MOV PER_CPU_VAR(current_tinfo),reg ;
21925
21926 /*
21927 * ASM operand which evaluates to a 'thread_info' address of
21928@@ -295,5 +293,12 @@ static inline bool is_ia32_task(void)
21929 extern void arch_task_cache_init(void);
21930 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
21931 extern void arch_release_task_struct(struct task_struct *tsk);
21932+
21933+#define __HAVE_THREAD_FUNCTIONS
21934+#define task_thread_info(task) (&(task)->tinfo)
21935+#define task_stack_page(task) ((task)->stack)
21936+#define setup_thread_stack(p, org) do {} while (0)
21937+#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
21938+
21939 #endif
21940 #endif /* _ASM_X86_THREAD_INFO_H */
21941diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
21942index cd79194..6a9956f 100644
21943--- a/arch/x86/include/asm/tlbflush.h
21944+++ b/arch/x86/include/asm/tlbflush.h
21945@@ -86,18 +86,44 @@ static inline void cr4_set_bits_and_update_boot(unsigned long mask)
21946
21947 static inline void __native_flush_tlb(void)
21948 {
21949+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
21950+ u64 descriptor[2];
21951+
21952+ descriptor[0] = PCID_KERNEL;
21953+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_NONGLOBAL) : "memory");
21954+ return;
21955+ }
21956+
21957+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21958+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF)) {
21959+ unsigned int cpu = raw_get_cpu();
21960+
21961+ native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
21962+ native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
21963+ raw_put_cpu_no_resched();
21964+ return;
21965+ }
21966+#endif
21967+
21968 native_write_cr3(native_read_cr3());
21969 }
21970
21971 static inline void __native_flush_tlb_global_irq_disabled(void)
21972 {
21973- unsigned long cr4;
21974+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
21975+ u64 descriptor[2];
21976
21977- cr4 = this_cpu_read(cpu_tlbstate.cr4);
21978- /* clear PGE */
21979- native_write_cr4(cr4 & ~X86_CR4_PGE);
21980- /* write old PGE again and flush TLBs */
21981- native_write_cr4(cr4);
21982+ descriptor[0] = PCID_KERNEL;
21983+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
21984+ } else {
21985+ unsigned long cr4;
21986+
21987+ cr4 = this_cpu_read(cpu_tlbstate.cr4);
21988+ /* clear PGE */
21989+ native_write_cr4(cr4 & ~X86_CR4_PGE);
21990+ /* write old PGE again and flush TLBs */
21991+ native_write_cr4(cr4);
21992+ }
21993 }
21994
21995 static inline void __native_flush_tlb_global(void)
21996@@ -118,6 +144,43 @@ static inline void __native_flush_tlb_global(void)
21997
21998 static inline void __native_flush_tlb_single(unsigned long addr)
21999 {
22000+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
22001+ u64 descriptor[2];
22002+
22003+ descriptor[0] = PCID_KERNEL;
22004+ descriptor[1] = addr;
22005+
22006+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22007+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF)) {
22008+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
22009+ if (addr < TASK_SIZE_MAX)
22010+ descriptor[1] += pax_user_shadow_base;
22011+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
22012+ }
22013+
22014+ descriptor[0] = PCID_USER;
22015+ descriptor[1] = addr;
22016+ }
22017+#endif
22018+
22019+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
22020+ return;
22021+ }
22022+
22023+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22024+ if (static_cpu_has(X86_FEATURE_PCIDUDEREF)) {
22025+ unsigned int cpu = raw_get_cpu();
22026+
22027+ native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
22028+ asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
22029+ native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
22030+ raw_put_cpu_no_resched();
22031+
22032+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
22033+ addr += pax_user_shadow_base;
22034+ }
22035+#endif
22036+
22037 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
22038 }
22039
22040diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
22041index a8df874..ef0e34f 100644
22042--- a/arch/x86/include/asm/uaccess.h
22043+++ b/arch/x86/include/asm/uaccess.h
22044@@ -7,6 +7,7 @@
22045 #include <linux/compiler.h>
22046 #include <linux/thread_info.h>
22047 #include <linux/string.h>
22048+#include <linux/spinlock.h>
22049 #include <asm/asm.h>
22050 #include <asm/page.h>
22051 #include <asm/smap.h>
22052@@ -29,7 +30,12 @@
22053
22054 #define get_ds() (KERNEL_DS)
22055 #define get_fs() (current_thread_info()->addr_limit)
22056+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
22057+void __set_fs(mm_segment_t x);
22058+void set_fs(mm_segment_t x);
22059+#else
22060 #define set_fs(x) (current_thread_info()->addr_limit = (x))
22061+#endif
22062
22063 #define segment_eq(a, b) ((a).seg == (b).seg)
22064
22065@@ -86,8 +92,36 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
22066 * checks that the pointer is in the user space range - after calling
22067 * this function, memory access functions may still return -EFAULT.
22068 */
22069-#define access_ok(type, addr, size) \
22070- likely(!__range_not_ok(addr, size, user_addr_max()))
22071+extern int _cond_resched(void);
22072+#define access_ok_noprefault(type, addr, size) (likely(!__range_not_ok(addr, size, user_addr_max())))
22073+#define access_ok(type, addr, size) \
22074+({ \
22075+ unsigned long __size = size; \
22076+ unsigned long __addr = (unsigned long)addr; \
22077+ bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
22078+ if (__ret_ao && __size) { \
22079+ unsigned long __addr_ao = __addr & PAGE_MASK; \
22080+ unsigned long __end_ao = __addr + __size - 1; \
22081+ if (unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
22082+ while (__addr_ao <= __end_ao) { \
22083+ char __c_ao; \
22084+ __addr_ao += PAGE_SIZE; \
22085+ if (__size > PAGE_SIZE) \
22086+ _cond_resched(); \
22087+ if (__get_user(__c_ao, (char __user *)__addr)) \
22088+ break; \
22089+ if (type != VERIFY_WRITE) { \
22090+ __addr = __addr_ao; \
22091+ continue; \
22092+ } \
22093+ if (__put_user(__c_ao, (char __user *)__addr)) \
22094+ break; \
22095+ __addr = __addr_ao; \
22096+ } \
22097+ } \
22098+ } \
22099+ __ret_ao; \
22100+})
22101
22102 /*
22103 * The exception table consists of pairs of addresses relative to the
22104@@ -135,11 +169,13 @@ extern int __get_user_8(void);
22105 extern int __get_user_bad(void);
22106
22107 /*
22108- * This is a type: either unsigned long, if the argument fits into
22109- * that type, or otherwise unsigned long long.
22110+ * This is a type: either (un)signed int, if the argument fits into
22111+ * that type, or otherwise (un)signed long long.
22112 */
22113 #define __inttype(x) \
22114-__typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
22115+__typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0U), \
22116+ __builtin_choose_expr(__type_is_unsigned(__typeof__(x)), 0ULL, 0LL),\
22117+ __builtin_choose_expr(__type_is_unsigned(__typeof__(x)), 0U, 0)))
22118
22119 /**
22120 * get_user: - Get a simple variable from user space.
22121@@ -178,10 +214,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
22122 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
22123 __chk_user_ptr(ptr); \
22124 might_fault(); \
22125+ pax_open_userland(); \
22126 asm volatile("call __get_user_%P3" \
22127 : "=a" (__ret_gu), "=r" (__val_gu) \
22128 : "0" (ptr), "i" (sizeof(*(ptr)))); \
22129 (x) = (__force __typeof__(*(ptr))) __val_gu; \
22130+ pax_close_userland(); \
22131 __ret_gu; \
22132 })
22133
22134@@ -189,13 +227,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
22135 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
22136 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
22137
22138-
22139+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
22140+#define __copyuser_seg "gs;"
22141+#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
22142+#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
22143+#else
22144+#define __copyuser_seg
22145+#define __COPYUSER_SET_ES
22146+#define __COPYUSER_RESTORE_ES
22147+#endif
22148
22149 #ifdef CONFIG_X86_32
22150 #define __put_user_asm_u64(x, addr, err, errret) \
22151 asm volatile(ASM_STAC "\n" \
22152- "1: movl %%eax,0(%2)\n" \
22153- "2: movl %%edx,4(%2)\n" \
22154+ "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
22155+ "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
22156 "3: " ASM_CLAC "\n" \
22157 ".section .fixup,\"ax\"\n" \
22158 "4: movl %3,%0\n" \
22159@@ -208,8 +254,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
22160
22161 #define __put_user_asm_ex_u64(x, addr) \
22162 asm volatile(ASM_STAC "\n" \
22163- "1: movl %%eax,0(%1)\n" \
22164- "2: movl %%edx,4(%1)\n" \
22165+ "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
22166+ "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
22167 "3: " ASM_CLAC "\n" \
22168 _ASM_EXTABLE_EX(1b, 2b) \
22169 _ASM_EXTABLE_EX(2b, 3b) \
22170@@ -260,7 +306,8 @@ extern void __put_user_8(void);
22171 __typeof__(*(ptr)) __pu_val; \
22172 __chk_user_ptr(ptr); \
22173 might_fault(); \
22174- __pu_val = x; \
22175+ __pu_val = (x); \
22176+ pax_open_userland(); \
22177 switch (sizeof(*(ptr))) { \
22178 case 1: \
22179 __put_user_x(1, __pu_val, ptr, __ret_pu); \
22180@@ -278,6 +325,7 @@ extern void __put_user_8(void);
22181 __put_user_x(X, __pu_val, ptr, __ret_pu); \
22182 break; \
22183 } \
22184+ pax_close_userland(); \
22185 __ret_pu; \
22186 })
22187
22188@@ -358,8 +406,10 @@ do { \
22189 } while (0)
22190
22191 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
22192+do { \
22193+ pax_open_userland(); \
22194 asm volatile(ASM_STAC "\n" \
22195- "1: mov"itype" %2,%"rtype"1\n" \
22196+ "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
22197 "2: " ASM_CLAC "\n" \
22198 ".section .fixup,\"ax\"\n" \
22199 "3: mov %3,%0\n" \
22200@@ -367,8 +417,10 @@ do { \
22201 " jmp 2b\n" \
22202 ".previous\n" \
22203 _ASM_EXTABLE(1b, 3b) \
22204- : "=r" (err), ltype(x) \
22205- : "m" (__m(addr)), "i" (errret), "0" (err))
22206+ : "=r" (err), ltype (x) \
22207+ : "m" (__m(addr)), "i" (errret), "0" (err)); \
22208+ pax_close_userland(); \
22209+} while (0)
22210
22211 #define __get_user_size_ex(x, ptr, size) \
22212 do { \
22213@@ -392,7 +444,7 @@ do { \
22214 } while (0)
22215
22216 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
22217- asm volatile("1: mov"itype" %1,%"rtype"0\n" \
22218+ asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
22219 "2:\n" \
22220 _ASM_EXTABLE_EX(1b, 2b) \
22221 : ltype(x) : "m" (__m(addr)))
22222@@ -409,13 +461,24 @@ do { \
22223 int __gu_err; \
22224 unsigned long __gu_val; \
22225 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
22226- (x) = (__force __typeof__(*(ptr)))__gu_val; \
22227+ (x) = (__typeof__(*(ptr)))__gu_val; \
22228 __gu_err; \
22229 })
22230
22231 /* FIXME: this hack is definitely wrong -AK */
22232 struct __large_struct { unsigned long buf[100]; };
22233-#define __m(x) (*(struct __large_struct __user *)(x))
22234+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22235+#define ____m(x) \
22236+({ \
22237+ unsigned long ____x = (unsigned long)(x); \
22238+ if (____x < pax_user_shadow_base) \
22239+ ____x += pax_user_shadow_base; \
22240+ (typeof(x))____x; \
22241+})
22242+#else
22243+#define ____m(x) (x)
22244+#endif
22245+#define __m(x) (*(struct __large_struct __user *)____m(x))
22246
22247 /*
22248 * Tell gcc we read from memory instead of writing: this is because
22249@@ -423,8 +486,10 @@ struct __large_struct { unsigned long buf[100]; };
22250 * aliasing issues.
22251 */
22252 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
22253+do { \
22254+ pax_open_userland(); \
22255 asm volatile(ASM_STAC "\n" \
22256- "1: mov"itype" %"rtype"1,%2\n" \
22257+ "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
22258 "2: " ASM_CLAC "\n" \
22259 ".section .fixup,\"ax\"\n" \
22260 "3: mov %3,%0\n" \
22261@@ -432,10 +497,12 @@ struct __large_struct { unsigned long buf[100]; };
22262 ".previous\n" \
22263 _ASM_EXTABLE(1b, 3b) \
22264 : "=r"(err) \
22265- : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
22266+ : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
22267+ pax_close_userland(); \
22268+} while (0)
22269
22270 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
22271- asm volatile("1: mov"itype" %"rtype"0,%1\n" \
22272+ asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
22273 "2:\n" \
22274 _ASM_EXTABLE_EX(1b, 2b) \
22275 : : ltype(x), "m" (__m(addr)))
22276@@ -445,11 +512,13 @@ struct __large_struct { unsigned long buf[100]; };
22277 */
22278 #define uaccess_try do { \
22279 current_thread_info()->uaccess_err = 0; \
22280+ pax_open_userland(); \
22281 stac(); \
22282 barrier();
22283
22284 #define uaccess_catch(err) \
22285 clac(); \
22286+ pax_close_userland(); \
22287 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
22288 } while (0)
22289
22290@@ -475,8 +544,12 @@ struct __large_struct { unsigned long buf[100]; };
22291 * On error, the variable @x is set to zero.
22292 */
22293
22294+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22295+#define __get_user(x, ptr) get_user((x), (ptr))
22296+#else
22297 #define __get_user(x, ptr) \
22298 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
22299+#endif
22300
22301 /**
22302 * __put_user: - Write a simple value into user space, with less checking.
22303@@ -499,8 +572,12 @@ struct __large_struct { unsigned long buf[100]; };
22304 * Returns zero on success, or -EFAULT on error.
22305 */
22306
22307+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22308+#define __put_user(x, ptr) put_user((x), (ptr))
22309+#else
22310 #define __put_user(x, ptr) \
22311 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
22312+#endif
22313
22314 #define __get_user_unaligned __get_user
22315 #define __put_user_unaligned __put_user
22316@@ -518,7 +595,7 @@ struct __large_struct { unsigned long buf[100]; };
22317 #define get_user_ex(x, ptr) do { \
22318 unsigned long __gue_val; \
22319 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
22320- (x) = (__force __typeof__(*(ptr)))__gue_val; \
22321+ (x) = (__typeof__(*(ptr)))__gue_val; \
22322 } while (0)
22323
22324 #define put_user_try uaccess_try
22325@@ -536,7 +613,7 @@ extern __must_check long strlen_user(const char __user *str);
22326 extern __must_check long strnlen_user(const char __user *str, long n);
22327
22328 unsigned long __must_check clear_user(void __user *mem, unsigned long len);
22329-unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
22330+unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
22331
22332 extern void __cmpxchg_wrong_size(void)
22333 __compiletime_error("Bad argument size for cmpxchg");
22334@@ -547,18 +624,19 @@ extern void __cmpxchg_wrong_size(void)
22335 __typeof__(ptr) __uval = (uval); \
22336 __typeof__(*(ptr)) __old = (old); \
22337 __typeof__(*(ptr)) __new = (new); \
22338+ pax_open_userland(); \
22339 switch (size) { \
22340 case 1: \
22341 { \
22342 asm volatile("\t" ASM_STAC "\n" \
22343- "1:\t" LOCK_PREFIX "cmpxchgb %4, %2\n" \
22344+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgb %4, %2\n"\
22345 "2:\t" ASM_CLAC "\n" \
22346 "\t.section .fixup, \"ax\"\n" \
22347 "3:\tmov %3, %0\n" \
22348 "\tjmp 2b\n" \
22349 "\t.previous\n" \
22350 _ASM_EXTABLE(1b, 3b) \
22351- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
22352+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
22353 : "i" (-EFAULT), "q" (__new), "1" (__old) \
22354 : "memory" \
22355 ); \
22356@@ -567,14 +645,14 @@ extern void __cmpxchg_wrong_size(void)
22357 case 2: \
22358 { \
22359 asm volatile("\t" ASM_STAC "\n" \
22360- "1:\t" LOCK_PREFIX "cmpxchgw %4, %2\n" \
22361+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgw %4, %2\n"\
22362 "2:\t" ASM_CLAC "\n" \
22363 "\t.section .fixup, \"ax\"\n" \
22364 "3:\tmov %3, %0\n" \
22365 "\tjmp 2b\n" \
22366 "\t.previous\n" \
22367 _ASM_EXTABLE(1b, 3b) \
22368- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
22369+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
22370 : "i" (-EFAULT), "r" (__new), "1" (__old) \
22371 : "memory" \
22372 ); \
22373@@ -583,14 +661,14 @@ extern void __cmpxchg_wrong_size(void)
22374 case 4: \
22375 { \
22376 asm volatile("\t" ASM_STAC "\n" \
22377- "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n" \
22378+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"\
22379 "2:\t" ASM_CLAC "\n" \
22380 "\t.section .fixup, \"ax\"\n" \
22381 "3:\tmov %3, %0\n" \
22382 "\tjmp 2b\n" \
22383 "\t.previous\n" \
22384 _ASM_EXTABLE(1b, 3b) \
22385- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
22386+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
22387 : "i" (-EFAULT), "r" (__new), "1" (__old) \
22388 : "memory" \
22389 ); \
22390@@ -602,14 +680,14 @@ extern void __cmpxchg_wrong_size(void)
22391 __cmpxchg_wrong_size(); \
22392 \
22393 asm volatile("\t" ASM_STAC "\n" \
22394- "1:\t" LOCK_PREFIX "cmpxchgq %4, %2\n" \
22395+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgq %4, %2\n"\
22396 "2:\t" ASM_CLAC "\n" \
22397 "\t.section .fixup, \"ax\"\n" \
22398 "3:\tmov %3, %0\n" \
22399 "\tjmp 2b\n" \
22400 "\t.previous\n" \
22401 _ASM_EXTABLE(1b, 3b) \
22402- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
22403+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
22404 : "i" (-EFAULT), "r" (__new), "1" (__old) \
22405 : "memory" \
22406 ); \
22407@@ -618,6 +696,7 @@ extern void __cmpxchg_wrong_size(void)
22408 default: \
22409 __cmpxchg_wrong_size(); \
22410 } \
22411+ pax_close_userland(); \
22412 *__uval = __old; \
22413 __ret; \
22414 })
22415@@ -641,17 +720,6 @@ extern struct movsl_mask {
22416
22417 #define ARCH_HAS_NOCACHE_UACCESS 1
22418
22419-#ifdef CONFIG_X86_32
22420-# include <asm/uaccess_32.h>
22421-#else
22422-# include <asm/uaccess_64.h>
22423-#endif
22424-
22425-unsigned long __must_check _copy_from_user(void *to, const void __user *from,
22426- unsigned n);
22427-unsigned long __must_check _copy_to_user(void __user *to, const void *from,
22428- unsigned n);
22429-
22430 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
22431 # define copy_user_diag __compiletime_error
22432 #else
22433@@ -661,7 +729,7 @@ unsigned long __must_check _copy_to_user(void __user *to, const void *from,
22434 extern void copy_user_diag("copy_from_user() buffer size is too small")
22435 copy_from_user_overflow(void);
22436 extern void copy_user_diag("copy_to_user() buffer size is too small")
22437-copy_to_user_overflow(void) __asm__("copy_from_user_overflow");
22438+copy_to_user_overflow(void);
22439
22440 #undef copy_user_diag
22441
22442@@ -674,7 +742,7 @@ __copy_from_user_overflow(void) __asm__("copy_from_user_overflow");
22443
22444 extern void
22445 __compiletime_warning("copy_to_user() buffer size is not provably correct")
22446-__copy_to_user_overflow(void) __asm__("copy_from_user_overflow");
22447+__copy_to_user_overflow(void) __asm__("copy_to_user_overflow");
22448 #define __copy_to_user_overflow(size, count) __copy_to_user_overflow()
22449
22450 #else
22451@@ -689,10 +757,16 @@ __copy_from_user_overflow(int size, unsigned long count)
22452
22453 #endif
22454
22455+#ifdef CONFIG_X86_32
22456+# include <asm/uaccess_32.h>
22457+#else
22458+# include <asm/uaccess_64.h>
22459+#endif
22460+
22461 static inline unsigned long __must_check
22462 copy_from_user(void *to, const void __user *from, unsigned long n)
22463 {
22464- int sz = __compiletime_object_size(to);
22465+ size_t sz = __compiletime_object_size(to);
22466
22467 might_fault();
22468
22469@@ -714,12 +788,15 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
22470 * case, and do only runtime checking for non-constant sizes.
22471 */
22472
22473- if (likely(sz < 0 || sz >= n))
22474- n = _copy_from_user(to, from, n);
22475- else if(__builtin_constant_p(n))
22476- copy_from_user_overflow();
22477- else
22478- __copy_from_user_overflow(sz, n);
22479+ if (likely(sz != (size_t)-1 && sz < n)) {
22480+ if(__builtin_constant_p(n))
22481+ copy_from_user_overflow();
22482+ else
22483+ __copy_from_user_overflow(sz, n);
22484+ } else if (access_ok(VERIFY_READ, from, n))
22485+ n = __copy_from_user(to, from, n);
22486+ else if ((long)n > 0)
22487+ memset(to, 0, n);
22488
22489 return n;
22490 }
22491@@ -727,17 +804,18 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
22492 static inline unsigned long __must_check
22493 copy_to_user(void __user *to, const void *from, unsigned long n)
22494 {
22495- int sz = __compiletime_object_size(from);
22496+ size_t sz = __compiletime_object_size(from);
22497
22498 might_fault();
22499
22500 /* See the comment in copy_from_user() above. */
22501- if (likely(sz < 0 || sz >= n))
22502- n = _copy_to_user(to, from, n);
22503- else if(__builtin_constant_p(n))
22504- copy_to_user_overflow();
22505- else
22506- __copy_to_user_overflow(sz, n);
22507+ if (likely(sz != (size_t)-1 && sz < n)) {
22508+ if(__builtin_constant_p(n))
22509+ copy_to_user_overflow();
22510+ else
22511+ __copy_to_user_overflow(sz, n);
22512+ } else if (access_ok(VERIFY_WRITE, to, n))
22513+ n = __copy_to_user(to, from, n);
22514
22515 return n;
22516 }
22517diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
22518index f5dcb52..da2c15b 100644
22519--- a/arch/x86/include/asm/uaccess_32.h
22520+++ b/arch/x86/include/asm/uaccess_32.h
22521@@ -40,9 +40,14 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
22522 * anything, so this is accurate.
22523 */
22524
22525-static __always_inline unsigned long __must_check
22526+static __always_inline __size_overflow(3) unsigned long __must_check
22527 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
22528 {
22529+ if ((long)n < 0)
22530+ return n;
22531+
22532+ check_object_size(from, n, true);
22533+
22534 if (__builtin_constant_p(n)) {
22535 unsigned long ret;
22536
22537@@ -87,12 +92,16 @@ static __always_inline unsigned long __must_check
22538 __copy_to_user(void __user *to, const void *from, unsigned long n)
22539 {
22540 might_fault();
22541+
22542 return __copy_to_user_inatomic(to, from, n);
22543 }
22544
22545-static __always_inline unsigned long
22546+static __always_inline __size_overflow(3) unsigned long
22547 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
22548 {
22549+ if ((long)n < 0)
22550+ return n;
22551+
22552 /* Avoid zeroing the tail if the copy fails..
22553 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
22554 * but as the zeroing behaviour is only significant when n is not
22555@@ -143,6 +152,12 @@ static __always_inline unsigned long
22556 __copy_from_user(void *to, const void __user *from, unsigned long n)
22557 {
22558 might_fault();
22559+
22560+ if ((long)n < 0)
22561+ return n;
22562+
22563+ check_object_size(to, n, false);
22564+
22565 if (__builtin_constant_p(n)) {
22566 unsigned long ret;
22567
22568@@ -165,6 +180,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
22569 const void __user *from, unsigned long n)
22570 {
22571 might_fault();
22572+
22573+ if ((long)n < 0)
22574+ return n;
22575+
22576 if (__builtin_constant_p(n)) {
22577 unsigned long ret;
22578
22579@@ -187,7 +206,10 @@ static __always_inline unsigned long
22580 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
22581 unsigned long n)
22582 {
22583- return __copy_from_user_ll_nocache_nozero(to, from, n);
22584+ if ((long)n < 0)
22585+ return n;
22586+
22587+ return __copy_from_user_ll_nocache_nozero(to, from, n);
22588 }
22589
22590 #endif /* _ASM_X86_UACCESS_32_H */
22591diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
22592index f2f9b39..2ae1bf8 100644
22593--- a/arch/x86/include/asm/uaccess_64.h
22594+++ b/arch/x86/include/asm/uaccess_64.h
22595@@ -10,6 +10,9 @@
22596 #include <asm/alternative.h>
22597 #include <asm/cpufeature.h>
22598 #include <asm/page.h>
22599+#include <asm/pgtable.h>
22600+
22601+#define set_fs(x) (current_thread_info()->addr_limit = (x))
22602
22603 /*
22604 * Copy To/From Userspace
22605@@ -23,8 +26,8 @@ copy_user_generic_string(void *to, const void *from, unsigned len);
22606 __must_check unsigned long
22607 copy_user_generic_unrolled(void *to, const void *from, unsigned len);
22608
22609-static __always_inline __must_check unsigned long
22610-copy_user_generic(void *to, const void *from, unsigned len)
22611+static __always_inline __must_check __size_overflow(3) unsigned long
22612+copy_user_generic(void *to, const void *from, unsigned long len)
22613 {
22614 unsigned ret;
22615
22616@@ -46,121 +49,170 @@ copy_user_generic(void *to, const void *from, unsigned len)
22617 }
22618
22619 __must_check unsigned long
22620-copy_in_user(void __user *to, const void __user *from, unsigned len);
22621+copy_in_user(void __user *to, const void __user *from, unsigned long len);
22622
22623 static __always_inline __must_check
22624-int __copy_from_user_nocheck(void *dst, const void __user *src, unsigned size)
22625+unsigned long __copy_from_user_nocheck(void *dst, const void __user *src, unsigned long size)
22626 {
22627- int ret = 0;
22628+ size_t sz = __compiletime_object_size(dst);
22629+ unsigned ret = 0;
22630+
22631+ if (size > INT_MAX)
22632+ return size;
22633+
22634+ check_object_size(dst, size, false);
22635+
22636+#ifdef CONFIG_PAX_MEMORY_UDEREF
22637+ if (!access_ok_noprefault(VERIFY_READ, src, size))
22638+ return size;
22639+#endif
22640+
22641+ if (unlikely(sz != (size_t)-1 && sz < size)) {
22642+ if(__builtin_constant_p(size))
22643+ copy_from_user_overflow();
22644+ else
22645+ __copy_from_user_overflow(sz, size);
22646+ return size;
22647+ }
22648
22649 if (!__builtin_constant_p(size))
22650- return copy_user_generic(dst, (__force void *)src, size);
22651+ return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
22652 switch (size) {
22653- case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
22654+ case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
22655 ret, "b", "b", "=q", 1);
22656 return ret;
22657- case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
22658+ case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
22659 ret, "w", "w", "=r", 2);
22660 return ret;
22661- case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
22662+ case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
22663 ret, "l", "k", "=r", 4);
22664 return ret;
22665- case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
22666+ case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
22667 ret, "q", "", "=r", 8);
22668 return ret;
22669 case 10:
22670- __get_user_asm(*(u64 *)dst, (u64 __user *)src,
22671+ __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
22672 ret, "q", "", "=r", 10);
22673 if (unlikely(ret))
22674 return ret;
22675 __get_user_asm(*(u16 *)(8 + (char *)dst),
22676- (u16 __user *)(8 + (char __user *)src),
22677+ (const u16 __user *)(8 + (const char __user *)src),
22678 ret, "w", "w", "=r", 2);
22679 return ret;
22680 case 16:
22681- __get_user_asm(*(u64 *)dst, (u64 __user *)src,
22682+ __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
22683 ret, "q", "", "=r", 16);
22684 if (unlikely(ret))
22685 return ret;
22686 __get_user_asm(*(u64 *)(8 + (char *)dst),
22687- (u64 __user *)(8 + (char __user *)src),
22688+ (const u64 __user *)(8 + (const char __user *)src),
22689 ret, "q", "", "=r", 8);
22690 return ret;
22691 default:
22692- return copy_user_generic(dst, (__force void *)src, size);
22693+ return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
22694 }
22695 }
22696
22697 static __always_inline __must_check
22698-int __copy_from_user(void *dst, const void __user *src, unsigned size)
22699+unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
22700 {
22701 might_fault();
22702 return __copy_from_user_nocheck(dst, src, size);
22703 }
22704
22705 static __always_inline __must_check
22706-int __copy_to_user_nocheck(void __user *dst, const void *src, unsigned size)
22707+unsigned long __copy_to_user_nocheck(void __user *dst, const void *src, unsigned long size)
22708 {
22709- int ret = 0;
22710+ size_t sz = __compiletime_object_size(src);
22711+ unsigned ret = 0;
22712+
22713+ if (size > INT_MAX)
22714+ return size;
22715+
22716+ check_object_size(src, size, true);
22717+
22718+#ifdef CONFIG_PAX_MEMORY_UDEREF
22719+ if (!access_ok_noprefault(VERIFY_WRITE, dst, size))
22720+ return size;
22721+#endif
22722+
22723+ if (unlikely(sz != (size_t)-1 && sz < size)) {
22724+ if(__builtin_constant_p(size))
22725+ copy_to_user_overflow();
22726+ else
22727+ __copy_to_user_overflow(sz, size);
22728+ return size;
22729+ }
22730
22731 if (!__builtin_constant_p(size))
22732- return copy_user_generic((__force void *)dst, src, size);
22733+ return copy_user_generic((__force_kernel void *)____m(dst), src, size);
22734 switch (size) {
22735- case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
22736+ case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
22737 ret, "b", "b", "iq", 1);
22738 return ret;
22739- case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
22740+ case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
22741 ret, "w", "w", "ir", 2);
22742 return ret;
22743- case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
22744+ case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
22745 ret, "l", "k", "ir", 4);
22746 return ret;
22747- case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
22748+ case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
22749 ret, "q", "", "er", 8);
22750 return ret;
22751 case 10:
22752- __put_user_asm(*(u64 *)src, (u64 __user *)dst,
22753+ __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
22754 ret, "q", "", "er", 10);
22755 if (unlikely(ret))
22756 return ret;
22757 asm("":::"memory");
22758- __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
22759+ __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
22760 ret, "w", "w", "ir", 2);
22761 return ret;
22762 case 16:
22763- __put_user_asm(*(u64 *)src, (u64 __user *)dst,
22764+ __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
22765 ret, "q", "", "er", 16);
22766 if (unlikely(ret))
22767 return ret;
22768 asm("":::"memory");
22769- __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
22770+ __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
22771 ret, "q", "", "er", 8);
22772 return ret;
22773 default:
22774- return copy_user_generic((__force void *)dst, src, size);
22775+ return copy_user_generic((__force_kernel void *)____m(dst), src, size);
22776 }
22777 }
22778
22779 static __always_inline __must_check
22780-int __copy_to_user(void __user *dst, const void *src, unsigned size)
22781+unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
22782 {
22783 might_fault();
22784 return __copy_to_user_nocheck(dst, src, size);
22785 }
22786
22787 static __always_inline __must_check
22788-int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22789+unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22790 {
22791- int ret = 0;
22792+ unsigned ret = 0;
22793
22794 might_fault();
22795+
22796+ if (size > INT_MAX)
22797+ return size;
22798+
22799+#ifdef CONFIG_PAX_MEMORY_UDEREF
22800+ if (!access_ok_noprefault(VERIFY_READ, src, size))
22801+ return size;
22802+ if (!access_ok_noprefault(VERIFY_WRITE, dst, size))
22803+ return size;
22804+#endif
22805+
22806 if (!__builtin_constant_p(size))
22807- return copy_user_generic((__force void *)dst,
22808- (__force void *)src, size);
22809+ return copy_user_generic((__force_kernel void *)____m(dst),
22810+ (__force_kernel const void *)____m(src), size);
22811 switch (size) {
22812 case 1: {
22813 u8 tmp;
22814- __get_user_asm(tmp, (u8 __user *)src,
22815+ __get_user_asm(tmp, (const u8 __user *)src,
22816 ret, "b", "b", "=q", 1);
22817 if (likely(!ret))
22818 __put_user_asm(tmp, (u8 __user *)dst,
22819@@ -169,7 +221,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22820 }
22821 case 2: {
22822 u16 tmp;
22823- __get_user_asm(tmp, (u16 __user *)src,
22824+ __get_user_asm(tmp, (const u16 __user *)src,
22825 ret, "w", "w", "=r", 2);
22826 if (likely(!ret))
22827 __put_user_asm(tmp, (u16 __user *)dst,
22828@@ -179,7 +231,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22829
22830 case 4: {
22831 u32 tmp;
22832- __get_user_asm(tmp, (u32 __user *)src,
22833+ __get_user_asm(tmp, (const u32 __user *)src,
22834 ret, "l", "k", "=r", 4);
22835 if (likely(!ret))
22836 __put_user_asm(tmp, (u32 __user *)dst,
22837@@ -188,7 +240,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22838 }
22839 case 8: {
22840 u64 tmp;
22841- __get_user_asm(tmp, (u64 __user *)src,
22842+ __get_user_asm(tmp, (const u64 __user *)src,
22843 ret, "q", "", "=r", 8);
22844 if (likely(!ret))
22845 __put_user_asm(tmp, (u64 __user *)dst,
22846@@ -196,41 +248,58 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
22847 return ret;
22848 }
22849 default:
22850- return copy_user_generic((__force void *)dst,
22851- (__force void *)src, size);
22852+ return copy_user_generic((__force_kernel void *)____m(dst),
22853+ (__force_kernel const void *)____m(src), size);
22854 }
22855 }
22856
22857-static __must_check __always_inline int
22858-__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
22859+static __must_check __always_inline unsigned long
22860+__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
22861 {
22862 return __copy_from_user_nocheck(dst, src, size);
22863 }
22864
22865-static __must_check __always_inline int
22866-__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
22867+static __must_check __always_inline unsigned long
22868+__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
22869 {
22870 return __copy_to_user_nocheck(dst, src, size);
22871 }
22872
22873-extern long __copy_user_nocache(void *dst, const void __user *src,
22874- unsigned size, int zerorest);
22875+extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
22876+ unsigned long size, int zerorest);
22877
22878-static inline int
22879-__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
22880+static inline unsigned long
22881+__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
22882 {
22883 might_fault();
22884+
22885+ if (size > INT_MAX)
22886+ return size;
22887+
22888+#ifdef CONFIG_PAX_MEMORY_UDEREF
22889+ if (!access_ok_noprefault(VERIFY_READ, src, size))
22890+ return size;
22891+#endif
22892+
22893 return __copy_user_nocache(dst, src, size, 1);
22894 }
22895
22896-static inline int
22897+static inline unsigned long
22898 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
22899- unsigned size)
22900+ unsigned long size)
22901 {
22902+ if (size > INT_MAX)
22903+ return size;
22904+
22905+#ifdef CONFIG_PAX_MEMORY_UDEREF
22906+ if (!access_ok_noprefault(VERIFY_READ, src, size))
22907+ return size;
22908+#endif
22909+
22910 return __copy_user_nocache(dst, src, size, 0);
22911 }
22912
22913 unsigned long
22914-copy_user_handle_tail(char *to, char *from, unsigned len);
22915+copy_user_handle_tail(char __user *to, char __user *from, unsigned long len) __size_overflow(3);
22916
22917 #endif /* _ASM_X86_UACCESS_64_H */
22918diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
22919index 5b238981..77fdd78 100644
22920--- a/arch/x86/include/asm/word-at-a-time.h
22921+++ b/arch/x86/include/asm/word-at-a-time.h
22922@@ -11,7 +11,7 @@
22923 * and shift, for example.
22924 */
22925 struct word_at_a_time {
22926- const unsigned long one_bits, high_bits;
22927+ unsigned long one_bits, high_bits;
22928 };
22929
22930 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
22931diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
22932index 48d34d2..90671c7 100644
22933--- a/arch/x86/include/asm/x86_init.h
22934+++ b/arch/x86/include/asm/x86_init.h
22935@@ -129,7 +129,7 @@ struct x86_init_ops {
22936 struct x86_init_timers timers;
22937 struct x86_init_iommu iommu;
22938 struct x86_init_pci pci;
22939-};
22940+} __no_const;
22941
22942 /**
22943 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
22944@@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
22945 void (*setup_percpu_clockev)(void);
22946 void (*early_percpu_clock_init)(void);
22947 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
22948-};
22949+} __no_const;
22950
22951 struct timespec;
22952
22953@@ -168,7 +168,7 @@ struct x86_platform_ops {
22954 void (*save_sched_clock_state)(void);
22955 void (*restore_sched_clock_state)(void);
22956 void (*apic_post_init)(void);
22957-};
22958+} __no_const;
22959
22960 struct pci_dev;
22961
22962@@ -177,12 +177,12 @@ struct x86_msi_ops {
22963 void (*teardown_msi_irq)(unsigned int irq);
22964 void (*teardown_msi_irqs)(struct pci_dev *dev);
22965 void (*restore_msi_irqs)(struct pci_dev *dev);
22966-};
22967+} __no_const;
22968
22969 struct x86_io_apic_ops {
22970 unsigned int (*read) (unsigned int apic, unsigned int reg);
22971 void (*disable)(void);
22972-};
22973+} __no_const;
22974
22975 extern struct x86_init_ops x86_init;
22976 extern struct x86_cpuinit_ops x86_cpuinit;
22977diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
22978index c44a5d5..7f83cfc 100644
22979--- a/arch/x86/include/asm/xen/page.h
22980+++ b/arch/x86/include/asm/xen/page.h
22981@@ -82,7 +82,7 @@ static inline int xen_safe_read_ulong(unsigned long *addr, unsigned long *val)
22982 * - get_phys_to_machine() is to be called by __pfn_to_mfn() only in special
22983 * cases needing an extended handling.
22984 */
22985-static inline unsigned long __pfn_to_mfn(unsigned long pfn)
22986+static inline unsigned long __intentional_overflow(-1) __pfn_to_mfn(unsigned long pfn)
22987 {
22988 unsigned long mfn;
22989
22990diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
22991index 0f457e6..5970c0a 100644
22992--- a/arch/x86/include/uapi/asm/e820.h
22993+++ b/arch/x86/include/uapi/asm/e820.h
22994@@ -69,7 +69,7 @@ struct e820map {
22995 #define ISA_START_ADDRESS 0xa0000
22996 #define ISA_END_ADDRESS 0x100000
22997
22998-#define BIOS_BEGIN 0x000a0000
22999+#define BIOS_BEGIN 0x000c0000
23000 #define BIOS_END 0x00100000
23001
23002 #define BIOS_ROM_BASE 0xffe00000
23003diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
23004index 0f15af4..501a76a 100644
23005--- a/arch/x86/kernel/Makefile
23006+++ b/arch/x86/kernel/Makefile
23007@@ -28,7 +28,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
23008 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
23009 obj-$(CONFIG_IRQ_WORK) += irq_work.o
23010 obj-y += probe_roms.o
23011-obj-$(CONFIG_X86_32) += i386_ksyms_32.o
23012+obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
23013 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
23014 obj-$(CONFIG_X86_64) += mcount_64.o
23015 obj-$(CONFIG_X86_ESPFIX64) += espfix_64.o
23016diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
23017index 9393896..adbaa90 100644
23018--- a/arch/x86/kernel/acpi/boot.c
23019+++ b/arch/x86/kernel/acpi/boot.c
23020@@ -1333,7 +1333,7 @@ static void __init acpi_reduced_hw_init(void)
23021 * If your system is blacklisted here, but you find that acpi=force
23022 * works for you, please contact linux-acpi@vger.kernel.org
23023 */
23024-static struct dmi_system_id __initdata acpi_dmi_table[] = {
23025+static const struct dmi_system_id __initconst acpi_dmi_table[] = {
23026 /*
23027 * Boxes that need ACPI disabled
23028 */
23029@@ -1408,7 +1408,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
23030 };
23031
23032 /* second table for DMI checks that should run after early-quirks */
23033-static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
23034+static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
23035 /*
23036 * HP laptops which use a DSDT reporting as HP/SB400/10000,
23037 * which includes some code which overrides all temperature
23038diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
23039index d1daead..acd77e2 100644
23040--- a/arch/x86/kernel/acpi/sleep.c
23041+++ b/arch/x86/kernel/acpi/sleep.c
23042@@ -99,8 +99,12 @@ int x86_acpi_suspend_lowlevel(void)
23043 #else /* CONFIG_64BIT */
23044 #ifdef CONFIG_SMP
23045 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
23046+
23047+ pax_open_kernel();
23048 early_gdt_descr.address =
23049 (unsigned long)get_cpu_gdt_table(smp_processor_id());
23050+ pax_close_kernel();
23051+
23052 initial_gs = per_cpu_offset(smp_processor_id());
23053 #endif
23054 initial_code = (unsigned long)wakeup_long64;
23055diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
23056index 0c26b1b..a766e85 100644
23057--- a/arch/x86/kernel/acpi/wakeup_32.S
23058+++ b/arch/x86/kernel/acpi/wakeup_32.S
23059@@ -31,13 +31,11 @@ wakeup_pmode_return:
23060 # and restore the stack ... but you need gdt for this to work
23061 movl saved_context_esp, %esp
23062
23063- movl %cs:saved_magic, %eax
23064- cmpl $0x12345678, %eax
23065+ cmpl $0x12345678, saved_magic
23066 jne bogus_magic
23067
23068 # jump to place where we left off
23069- movl saved_eip, %eax
23070- jmp *%eax
23071+ jmp *(saved_eip)
23072
23073 bogus_magic:
23074 jmp bogus_magic
23075diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
23076index 25f9093..21d2827 100644
23077--- a/arch/x86/kernel/alternative.c
23078+++ b/arch/x86/kernel/alternative.c
23079@@ -20,6 +20,7 @@
23080 #include <asm/tlbflush.h>
23081 #include <asm/io.h>
23082 #include <asm/fixmap.h>
23083+#include <asm/boot.h>
23084
23085 int __read_mostly alternatives_patched;
23086
23087@@ -261,7 +262,9 @@ static void __init_or_module add_nops(void *insns, unsigned int len)
23088 unsigned int noplen = len;
23089 if (noplen > ASM_NOP_MAX)
23090 noplen = ASM_NOP_MAX;
23091+ pax_open_kernel();
23092 memcpy(insns, ideal_nops[noplen], noplen);
23093+ pax_close_kernel();
23094 insns += noplen;
23095 len -= noplen;
23096 }
23097@@ -289,6 +292,13 @@ recompute_jump(struct alt_instr *a, u8 *orig_insn, u8 *repl_insn, u8 *insnbuf)
23098 if (a->replacementlen != 5)
23099 return;
23100
23101+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23102+ if (orig_insn < (u8 *)_text || (u8 *)_einittext <= orig_insn)
23103+ orig_insn = (u8 *)ktva_ktla((unsigned long)orig_insn);
23104+ else
23105+ orig_insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23106+#endif
23107+
23108 o_dspl = *(s32 *)(insnbuf + 1);
23109
23110 /* next_rip of the replacement JMP */
23111@@ -364,6 +374,7 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
23112 {
23113 struct alt_instr *a;
23114 u8 *instr, *replacement;
23115+ u8 *vinstr, *vreplacement;
23116 u8 insnbuf[MAX_PATCH_LEN];
23117
23118 DPRINTK("alt table %p -> %p", start, end);
23119@@ -379,46 +390,71 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
23120 for (a = start; a < end; a++) {
23121 int insnbuf_sz = 0;
23122
23123- instr = (u8 *)&a->instr_offset + a->instr_offset;
23124- replacement = (u8 *)&a->repl_offset + a->repl_offset;
23125+ vinstr = instr = (u8 *)&a->instr_offset + a->instr_offset;
23126+
23127+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23128+ if ((u8 *)_text - (____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR) <= instr &&
23129+ instr < (u8 *)_einittext - (____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR)) {
23130+ instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23131+ vinstr = (u8 *)ktla_ktva((unsigned long)instr);
23132+ } else if ((u8 *)_text <= instr && instr < (u8 *)_einittext) {
23133+ vinstr = (u8 *)ktla_ktva((unsigned long)instr);
23134+ } else {
23135+ instr = (u8 *)ktva_ktla((unsigned long)instr);
23136+ }
23137+#endif
23138+
23139+ vreplacement = replacement = (u8 *)&a->repl_offset + a->repl_offset;
23140+
23141+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23142+ if ((u8 *)_text - (____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR) <= replacement &&
23143+ replacement < (u8 *)_einittext - (____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR)) {
23144+ replacement += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23145+ vreplacement = (u8 *)ktla_ktva((unsigned long)replacement);
23146+ } else if ((u8 *)_text <= replacement && replacement < (u8 *)_einittext) {
23147+ vreplacement = (u8 *)ktla_ktva((unsigned long)replacement);
23148+ } else
23149+ replacement = (u8 *)ktva_ktla((unsigned long)replacement);
23150+#endif
23151+
23152 BUG_ON(a->instrlen > sizeof(insnbuf));
23153 BUG_ON(a->cpuid >= (NCAPINTS + NBUGINTS) * 32);
23154 if (!boot_cpu_has(a->cpuid)) {
23155 if (a->padlen > 1)
23156- optimize_nops(a, instr);
23157+ optimize_nops(a, vinstr);
23158
23159 continue;
23160 }
23161
23162- DPRINTK("feat: %d*32+%d, old: (%p, len: %d), repl: (%p, len: %d), pad: %d",
23163+ DPRINTK("feat: %d*32+%d, old: (%p/%p, len: %d), repl: (%p, len: %d), pad: %d",
23164 a->cpuid >> 5,
23165 a->cpuid & 0x1f,
23166- instr, a->instrlen,
23167- replacement, a->replacementlen, a->padlen);
23168+ instr, vinstr, a->instrlen,
23169+ vreplacement, a->replacementlen, a->padlen);
23170
23171- DUMP_BYTES(instr, a->instrlen, "%p: old_insn: ", instr);
23172- DUMP_BYTES(replacement, a->replacementlen, "%p: rpl_insn: ", replacement);
23173+ DUMP_BYTES(vinstr, a->instrlen, "%p: old_insn: ", vinstr);
23174+ DUMP_BYTES(vreplacement, a->replacementlen, "%p: rpl_insn: ", vreplacement);
23175
23176- memcpy(insnbuf, replacement, a->replacementlen);
23177+ memcpy(insnbuf, vreplacement, a->replacementlen);
23178 insnbuf_sz = a->replacementlen;
23179
23180 /* 0xe8 is a relative jump; fix the offset. */
23181 if (*insnbuf == 0xe8 && a->replacementlen == 5) {
23182- *(s32 *)(insnbuf + 1) += replacement - instr;
23183+ *(s32 *)(insnbuf + 1) += vreplacement - vinstr;
23184 DPRINTK("Fix CALL offset: 0x%x, CALL 0x%lx",
23185 *(s32 *)(insnbuf + 1),
23186- (unsigned long)instr + *(s32 *)(insnbuf + 1) + 5);
23187+ (unsigned long)vinstr + *(s32 *)(insnbuf + 1) + 5);
23188 }
23189
23190- if (a->replacementlen && is_jmp(replacement[0]))
23191- recompute_jump(a, instr, replacement, insnbuf);
23192+ if (a->replacementlen && is_jmp(vreplacement[0]))
23193+ recompute_jump(a, instr, vreplacement, insnbuf);
23194
23195 if (a->instrlen > a->replacementlen) {
23196 add_nops(insnbuf + a->replacementlen,
23197 a->instrlen - a->replacementlen);
23198 insnbuf_sz += a->instrlen - a->replacementlen;
23199 }
23200- DUMP_BYTES(insnbuf, insnbuf_sz, "%p: final_insn: ", instr);
23201+ DUMP_BYTES(insnbuf, insnbuf_sz, "%p: final_insn: ", vinstr);
23202
23203 text_poke_early(instr, insnbuf, insnbuf_sz);
23204 }
23205@@ -434,10 +470,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
23206 for (poff = start; poff < end; poff++) {
23207 u8 *ptr = (u8 *)poff + *poff;
23208
23209+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23210+ ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23211+ if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
23212+ ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23213+#endif
23214+
23215 if (!*poff || ptr < text || ptr >= text_end)
23216 continue;
23217 /* turn DS segment override prefix into lock prefix */
23218- if (*ptr == 0x3e)
23219+ if (*(u8 *)ktla_ktva((unsigned long)ptr) == 0x3e)
23220 text_poke(ptr, ((unsigned char []){0xf0}), 1);
23221 }
23222 mutex_unlock(&text_mutex);
23223@@ -452,10 +494,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
23224 for (poff = start; poff < end; poff++) {
23225 u8 *ptr = (u8 *)poff + *poff;
23226
23227+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23228+ ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23229+ if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
23230+ ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
23231+#endif
23232+
23233 if (!*poff || ptr < text || ptr >= text_end)
23234 continue;
23235 /* turn lock prefix into DS segment override prefix */
23236- if (*ptr == 0xf0)
23237+ if (*(u8 *)ktla_ktva((unsigned long)ptr) == 0xf0)
23238 text_poke(ptr, ((unsigned char []){0x3E}), 1);
23239 }
23240 mutex_unlock(&text_mutex);
23241@@ -592,7 +640,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
23242
23243 BUG_ON(p->len > MAX_PATCH_LEN);
23244 /* prep the buffer with the original instructions */
23245- memcpy(insnbuf, p->instr, p->len);
23246+ memcpy(insnbuf, (const void *)ktla_ktva((unsigned long)p->instr), p->len);
23247 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
23248 (unsigned long)p->instr, p->len);
23249
23250@@ -639,7 +687,7 @@ void __init alternative_instructions(void)
23251 if (!uniproc_patched || num_possible_cpus() == 1)
23252 free_init_pages("SMP alternatives",
23253 (unsigned long)__smp_locks,
23254- (unsigned long)__smp_locks_end);
23255+ PAGE_ALIGN((unsigned long)__smp_locks_end));
23256 #endif
23257
23258 apply_paravirt(__parainstructions, __parainstructions_end);
23259@@ -660,13 +708,17 @@ void __init alternative_instructions(void)
23260 * instructions. And on the local CPU you need to be protected again NMI or MCE
23261 * handlers seeing an inconsistent instruction while you patch.
23262 */
23263-void *__init_or_module text_poke_early(void *addr, const void *opcode,
23264+void *__kprobes text_poke_early(void *addr, const void *opcode,
23265 size_t len)
23266 {
23267 unsigned long flags;
23268 local_irq_save(flags);
23269- memcpy(addr, opcode, len);
23270+
23271+ pax_open_kernel();
23272+ memcpy((void *)ktla_ktva((unsigned long)addr), opcode, len);
23273 sync_core();
23274+ pax_close_kernel();
23275+
23276 local_irq_restore(flags);
23277 /* Could also do a CLFLUSH here to speed up CPU recovery; but
23278 that causes hangs on some VIA CPUs. */
23279@@ -688,36 +740,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
23280 */
23281 void *text_poke(void *addr, const void *opcode, size_t len)
23282 {
23283- unsigned long flags;
23284- char *vaddr;
23285+ unsigned char *vaddr = (void *)ktla_ktva((unsigned long)addr);
23286 struct page *pages[2];
23287- int i;
23288+ size_t i;
23289
23290 if (!core_kernel_text((unsigned long)addr)) {
23291- pages[0] = vmalloc_to_page(addr);
23292- pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
23293+ pages[0] = vmalloc_to_page(vaddr);
23294+ pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
23295 } else {
23296- pages[0] = virt_to_page(addr);
23297+ pages[0] = virt_to_page(vaddr);
23298 WARN_ON(!PageReserved(pages[0]));
23299- pages[1] = virt_to_page(addr + PAGE_SIZE);
23300+ pages[1] = virt_to_page(vaddr + PAGE_SIZE);
23301 }
23302 BUG_ON(!pages[0]);
23303- local_irq_save(flags);
23304- set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
23305- if (pages[1])
23306- set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
23307- vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
23308- memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
23309- clear_fixmap(FIX_TEXT_POKE0);
23310- if (pages[1])
23311- clear_fixmap(FIX_TEXT_POKE1);
23312- local_flush_tlb();
23313- sync_core();
23314- /* Could also do a CLFLUSH here to speed up CPU recovery; but
23315- that causes hangs on some VIA CPUs. */
23316+ text_poke_early(addr, opcode, len);
23317 for (i = 0; i < len; i++)
23318- BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
23319- local_irq_restore(flags);
23320+ BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
23321 return addr;
23322 }
23323
23324@@ -771,7 +809,7 @@ int poke_int3_handler(struct pt_regs *regs)
23325 */
23326 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
23327 {
23328- unsigned char int3 = 0xcc;
23329+ const unsigned char int3 = 0xcc;
23330
23331 bp_int3_handler = handler;
23332 bp_int3_addr = (u8 *)addr + sizeof(int3);
23333diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
23334index 307a498..783e96a 100644
23335--- a/arch/x86/kernel/apic/apic.c
23336+++ b/arch/x86/kernel/apic/apic.c
23337@@ -171,7 +171,7 @@ int first_system_vector = FIRST_SYSTEM_VECTOR;
23338 /*
23339 * Debug level, exported for io_apic.c
23340 */
23341-unsigned int apic_verbosity;
23342+int apic_verbosity;
23343
23344 int pic_mode;
23345
23346@@ -1864,7 +1864,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
23347 apic_write(APIC_ESR, 0);
23348 v = apic_read(APIC_ESR);
23349 ack_APIC_irq();
23350- atomic_inc(&irq_err_count);
23351+ atomic_inc_unchecked(&irq_err_count);
23352
23353 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x",
23354 smp_processor_id(), v);
23355diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
23356index de918c4..32eed23 100644
23357--- a/arch/x86/kernel/apic/apic_flat_64.c
23358+++ b/arch/x86/kernel/apic/apic_flat_64.c
23359@@ -154,7 +154,7 @@ static int flat_probe(void)
23360 return 1;
23361 }
23362
23363-static struct apic apic_flat = {
23364+static struct apic apic_flat __read_only = {
23365 .name = "flat",
23366 .probe = flat_probe,
23367 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
23368@@ -260,7 +260,7 @@ static int physflat_probe(void)
23369 return 0;
23370 }
23371
23372-static struct apic apic_physflat = {
23373+static struct apic apic_physflat __read_only = {
23374
23375 .name = "physical flat",
23376 .probe = physflat_probe,
23377diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
23378index b205cdb..d8503ff 100644
23379--- a/arch/x86/kernel/apic/apic_noop.c
23380+++ b/arch/x86/kernel/apic/apic_noop.c
23381@@ -108,7 +108,7 @@ static void noop_apic_write(u32 reg, u32 v)
23382 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
23383 }
23384
23385-struct apic apic_noop = {
23386+struct apic apic_noop __read_only = {
23387 .name = "noop",
23388 .probe = noop_probe,
23389 .acpi_madt_oem_check = NULL,
23390diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
23391index c4a8d63..fe893ac 100644
23392--- a/arch/x86/kernel/apic/bigsmp_32.c
23393+++ b/arch/x86/kernel/apic/bigsmp_32.c
23394@@ -147,7 +147,7 @@ static int probe_bigsmp(void)
23395 return dmi_bigsmp;
23396 }
23397
23398-static struct apic apic_bigsmp = {
23399+static struct apic apic_bigsmp __read_only = {
23400
23401 .name = "bigsmp",
23402 .probe = probe_bigsmp,
23403diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
23404index 5880b48..5085f3e 100644
23405--- a/arch/x86/kernel/apic/io_apic.c
23406+++ b/arch/x86/kernel/apic/io_apic.c
23407@@ -1682,7 +1682,7 @@ static unsigned int startup_ioapic_irq(struct irq_data *data)
23408 return was_pending;
23409 }
23410
23411-atomic_t irq_mis_count;
23412+atomic_unchecked_t irq_mis_count;
23413
23414 #ifdef CONFIG_GENERIC_PENDING_IRQ
23415 static bool io_apic_level_ack_pending(struct mp_chip_data *data)
23416@@ -1821,7 +1821,7 @@ static void ioapic_ack_level(struct irq_data *irq_data)
23417 * at the cpu.
23418 */
23419 if (!(v & (1 << (i & 0x1f)))) {
23420- atomic_inc(&irq_mis_count);
23421+ atomic_inc_unchecked(&irq_mis_count);
23422 eoi_ioapic_pin(cfg->vector, irq_data->chip_data);
23423 }
23424
23425@@ -1867,7 +1867,7 @@ static int ioapic_set_affinity(struct irq_data *irq_data,
23426 return ret;
23427 }
23428
23429-static struct irq_chip ioapic_chip __read_mostly = {
23430+static struct irq_chip ioapic_chip = {
23431 .name = "IO-APIC",
23432 .irq_startup = startup_ioapic_irq,
23433 .irq_mask = mask_ioapic_irq,
23434@@ -1936,7 +1936,7 @@ static void ack_lapic_irq(struct irq_data *data)
23435 ack_APIC_irq();
23436 }
23437
23438-static struct irq_chip lapic_chip __read_mostly = {
23439+static struct irq_chip lapic_chip = {
23440 .name = "local-APIC",
23441 .irq_mask = mask_lapic_irq,
23442 .irq_unmask = unmask_lapic_irq,
23443diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c
23444index 1a9d735..c58b5c5 100644
23445--- a/arch/x86/kernel/apic/msi.c
23446+++ b/arch/x86/kernel/apic/msi.c
23447@@ -267,7 +267,7 @@ static void hpet_msi_write_msg(struct irq_data *data, struct msi_msg *msg)
23448 hpet_msi_write(data->handler_data, msg);
23449 }
23450
23451-static struct irq_chip hpet_msi_controller = {
23452+static irq_chip_no_const hpet_msi_controller __read_only = {
23453 .name = "HPET-MSI",
23454 .irq_unmask = hpet_msi_unmask,
23455 .irq_mask = hpet_msi_mask,
23456diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
23457index bda4886..f9c7195 100644
23458--- a/arch/x86/kernel/apic/probe_32.c
23459+++ b/arch/x86/kernel/apic/probe_32.c
23460@@ -72,7 +72,7 @@ static int probe_default(void)
23461 return 1;
23462 }
23463
23464-static struct apic apic_default = {
23465+static struct apic apic_default __read_only = {
23466
23467 .name = "default",
23468 .probe = probe_default,
23469diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
23470index 2683f36..0bdc74c 100644
23471--- a/arch/x86/kernel/apic/vector.c
23472+++ b/arch/x86/kernel/apic/vector.c
23473@@ -36,7 +36,7 @@ static struct irq_chip lapic_controller;
23474 static struct apic_chip_data *legacy_irq_data[NR_IRQS_LEGACY];
23475 #endif
23476
23477-void lock_vector_lock(void)
23478+void lock_vector_lock(void) __acquires(vector_lock)
23479 {
23480 /* Used to the online set of cpus does not change
23481 * during assign_irq_vector.
23482@@ -44,7 +44,7 @@ void lock_vector_lock(void)
23483 raw_spin_lock(&vector_lock);
23484 }
23485
23486-void unlock_vector_lock(void)
23487+void unlock_vector_lock(void) __releases(vector_lock)
23488 {
23489 raw_spin_unlock(&vector_lock);
23490 }
23491diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
23492index ab3219b..e8033eb 100644
23493--- a/arch/x86/kernel/apic/x2apic_cluster.c
23494+++ b/arch/x86/kernel/apic/x2apic_cluster.c
23495@@ -182,7 +182,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
23496 return notifier_from_errno(err);
23497 }
23498
23499-static struct notifier_block __refdata x2apic_cpu_notifier = {
23500+static struct notifier_block x2apic_cpu_notifier = {
23501 .notifier_call = update_clusterinfo,
23502 };
23503
23504@@ -234,7 +234,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
23505 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
23506 }
23507
23508-static struct apic apic_x2apic_cluster = {
23509+static struct apic apic_x2apic_cluster __read_only = {
23510
23511 .name = "cluster x2apic",
23512 .probe = x2apic_cluster_probe,
23513diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
23514index 3ffd925..8c0f5a8 100644
23515--- a/arch/x86/kernel/apic/x2apic_phys.c
23516+++ b/arch/x86/kernel/apic/x2apic_phys.c
23517@@ -90,7 +90,7 @@ static int x2apic_phys_probe(void)
23518 return apic == &apic_x2apic_phys;
23519 }
23520
23521-static struct apic apic_x2apic_phys = {
23522+static struct apic apic_x2apic_phys __read_only = {
23523
23524 .name = "physical x2apic",
23525 .probe = x2apic_phys_probe,
23526diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
23527index c8d9295..9af2d03 100644
23528--- a/arch/x86/kernel/apic/x2apic_uv_x.c
23529+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
23530@@ -375,7 +375,7 @@ static int uv_probe(void)
23531 return apic == &apic_x2apic_uv_x;
23532 }
23533
23534-static struct apic __refdata apic_x2apic_uv_x = {
23535+static struct apic apic_x2apic_uv_x __read_only = {
23536
23537 .name = "UV large system",
23538 .probe = uv_probe,
23539diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
23540index 927ec92..de68f32 100644
23541--- a/arch/x86/kernel/apm_32.c
23542+++ b/arch/x86/kernel/apm_32.c
23543@@ -432,7 +432,7 @@ static DEFINE_MUTEX(apm_mutex);
23544 * This is for buggy BIOS's that refer to (real mode) segment 0x40
23545 * even though they are called in protected mode.
23546 */
23547-static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
23548+static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
23549 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
23550
23551 static const char driver_version[] = "1.16ac"; /* no spaces */
23552@@ -610,7 +610,10 @@ static long __apm_bios_call(void *_call)
23553 BUG_ON(cpu != 0);
23554 gdt = get_cpu_gdt_table(cpu);
23555 save_desc_40 = gdt[0x40 / 8];
23556+
23557+ pax_open_kernel();
23558 gdt[0x40 / 8] = bad_bios_desc;
23559+ pax_close_kernel();
23560
23561 apm_irq_save(flags);
23562 APM_DO_SAVE_SEGS;
23563@@ -619,7 +622,11 @@ static long __apm_bios_call(void *_call)
23564 &call->esi);
23565 APM_DO_RESTORE_SEGS;
23566 apm_irq_restore(flags);
23567+
23568+ pax_open_kernel();
23569 gdt[0x40 / 8] = save_desc_40;
23570+ pax_close_kernel();
23571+
23572 put_cpu();
23573
23574 return call->eax & 0xff;
23575@@ -686,7 +693,10 @@ static long __apm_bios_call_simple(void *_call)
23576 BUG_ON(cpu != 0);
23577 gdt = get_cpu_gdt_table(cpu);
23578 save_desc_40 = gdt[0x40 / 8];
23579+
23580+ pax_open_kernel();
23581 gdt[0x40 / 8] = bad_bios_desc;
23582+ pax_close_kernel();
23583
23584 apm_irq_save(flags);
23585 APM_DO_SAVE_SEGS;
23586@@ -694,7 +704,11 @@ static long __apm_bios_call_simple(void *_call)
23587 &call->eax);
23588 APM_DO_RESTORE_SEGS;
23589 apm_irq_restore(flags);
23590+
23591+ pax_open_kernel();
23592 gdt[0x40 / 8] = save_desc_40;
23593+ pax_close_kernel();
23594+
23595 put_cpu();
23596 return error;
23597 }
23598@@ -2039,7 +2053,7 @@ static int __init swab_apm_power_in_minutes(const struct dmi_system_id *d)
23599 return 0;
23600 }
23601
23602-static struct dmi_system_id __initdata apm_dmi_table[] = {
23603+static const struct dmi_system_id __initconst apm_dmi_table[] = {
23604 {
23605 print_if_true,
23606 KERN_WARNING "IBM T23 - BIOS 1.03b+ and controller firmware 1.02+ may be needed for Linux APM.",
23607@@ -2349,12 +2363,15 @@ static int __init apm_init(void)
23608 * code to that CPU.
23609 */
23610 gdt = get_cpu_gdt_table(0);
23611+
23612+ pax_open_kernel();
23613 set_desc_base(&gdt[APM_CS >> 3],
23614 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
23615 set_desc_base(&gdt[APM_CS_16 >> 3],
23616 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
23617 set_desc_base(&gdt[APM_DS >> 3],
23618 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
23619+ pax_close_kernel();
23620
23621 proc_create("apm", 0, NULL, &apm_file_ops);
23622
23623diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
23624index 8e3d22a1..37118b6 100644
23625--- a/arch/x86/kernel/asm-offsets.c
23626+++ b/arch/x86/kernel/asm-offsets.c
23627@@ -32,6 +32,8 @@ void common(void) {
23628 OFFSET(TI_flags, thread_info, flags);
23629 OFFSET(TI_status, thread_info, status);
23630 OFFSET(TI_addr_limit, thread_info, addr_limit);
23631+ OFFSET(TI_lowest_stack, thread_info, lowest_stack);
23632+ DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
23633
23634 BLANK();
23635 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
23636@@ -73,8 +75,26 @@ void common(void) {
23637 #endif
23638 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
23639 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
23640+
23641+#ifdef CONFIG_PAX_KERNEXEC
23642+ OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
23643 #endif
23644
23645+#ifdef CONFIG_PAX_MEMORY_UDEREF
23646+ OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
23647+ OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
23648+#ifdef CONFIG_X86_64
23649+ OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
23650+#endif
23651+#endif
23652+
23653+#endif
23654+
23655+ BLANK();
23656+ DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
23657+ DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
23658+ DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
23659+
23660 #ifdef CONFIG_XEN
23661 BLANK();
23662 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
23663diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
23664index d8f42f9..a46f1fc 100644
23665--- a/arch/x86/kernel/asm-offsets_64.c
23666+++ b/arch/x86/kernel/asm-offsets_64.c
23667@@ -59,6 +59,7 @@ int main(void)
23668 BLANK();
23669 #undef ENTRY
23670
23671+ DEFINE(TSS_size, sizeof(struct tss_struct));
23672 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
23673 OFFSET(TSS_sp0, tss_struct, x86_tss.sp0);
23674 BLANK();
23675diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
23676index 9bff687..5b899fb 100644
23677--- a/arch/x86/kernel/cpu/Makefile
23678+++ b/arch/x86/kernel/cpu/Makefile
23679@@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
23680 CFLAGS_REMOVE_perf_event.o = -pg
23681 endif
23682
23683-# Make sure load_percpu_segment has no stackprotector
23684-nostackp := $(call cc-option, -fno-stack-protector)
23685-CFLAGS_common.o := $(nostackp)
23686-
23687 obj-y := intel_cacheinfo.o scattered.o topology.o
23688 obj-y += common.o
23689 obj-y += rdrand.o
23690diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
23691index dd3a4ba..06672af 100644
23692--- a/arch/x86/kernel/cpu/amd.c
23693+++ b/arch/x86/kernel/cpu/amd.c
23694@@ -750,7 +750,7 @@ static void init_amd(struct cpuinfo_x86 *c)
23695 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
23696 {
23697 /* AMD errata T13 (order #21922) */
23698- if ((c->x86 == 6)) {
23699+ if (c->x86 == 6) {
23700 /* Duron Rev A0 */
23701 if (c->x86_model == 3 && c->x86_mask == 0)
23702 size = 64;
23703diff --git a/arch/x86/kernel/cpu/bugs_64.c b/arch/x86/kernel/cpu/bugs_64.c
23704index 04f0fe5..3c0598c 100644
23705--- a/arch/x86/kernel/cpu/bugs_64.c
23706+++ b/arch/x86/kernel/cpu/bugs_64.c
23707@@ -10,6 +10,7 @@
23708 #include <asm/processor.h>
23709 #include <asm/mtrr.h>
23710 #include <asm/cacheflush.h>
23711+#include <asm/sections.h>
23712
23713 void __init check_bugs(void)
23714 {
23715@@ -18,6 +19,7 @@ void __init check_bugs(void)
23716 printk(KERN_INFO "CPU: ");
23717 print_cpu_info(&boot_cpu_data);
23718 #endif
23719+ set_memory_nx((unsigned long)_sinitdata, (__START_KERNEL_map + KERNEL_IMAGE_SIZE - (unsigned long)_sinitdata) >> PAGE_SHIFT);
23720 alternative_instructions();
23721
23722 /*
23723diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
23724index cb9e5df..0d25636 100644
23725--- a/arch/x86/kernel/cpu/common.c
23726+++ b/arch/x86/kernel/cpu/common.c
23727@@ -91,60 +91,6 @@ static const struct cpu_dev default_cpu = {
23728
23729 static const struct cpu_dev *this_cpu = &default_cpu;
23730
23731-DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
23732-#ifdef CONFIG_X86_64
23733- /*
23734- * We need valid kernel segments for data and code in long mode too
23735- * IRET will check the segment types kkeil 2000/10/28
23736- * Also sysret mandates a special GDT layout
23737- *
23738- * TLS descriptors are currently at a different place compared to i386.
23739- * Hopefully nobody expects them at a fixed place (Wine?)
23740- */
23741- [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
23742- [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
23743- [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
23744- [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
23745- [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
23746- [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
23747-#else
23748- [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
23749- [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
23750- [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
23751- [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
23752- /*
23753- * Segments used for calling PnP BIOS have byte granularity.
23754- * They code segments and data segments have fixed 64k limits,
23755- * the transfer segment sizes are set at run time.
23756- */
23757- /* 32-bit code */
23758- [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
23759- /* 16-bit code */
23760- [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
23761- /* 16-bit data */
23762- [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
23763- /* 16-bit data */
23764- [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
23765- /* 16-bit data */
23766- [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
23767- /*
23768- * The APM segments have byte granularity and their bases
23769- * are set at run time. All have 64k limits.
23770- */
23771- /* 32-bit code */
23772- [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
23773- /* 16-bit code */
23774- [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
23775- /* data */
23776- [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
23777-
23778- [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
23779- [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
23780- GDT_STACK_CANARY_INIT
23781-#endif
23782-} };
23783-EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
23784-
23785 static int __init x86_mpx_setup(char *s)
23786 {
23787 /* require an exact match without trailing characters */
23788@@ -287,6 +233,109 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
23789 }
23790 }
23791
23792+#ifdef CONFIG_PAX_MEMORY_UDEREF
23793+#ifdef CONFIG_X86_64
23794+static bool uderef_enabled __read_only = true;
23795+unsigned long pax_user_shadow_base __read_only;
23796+EXPORT_SYMBOL(pax_user_shadow_base);
23797+extern char pax_enter_kernel_user[];
23798+extern char pax_exit_kernel_user[];
23799+
23800+static int __init setup_pax_weakuderef(char *str)
23801+{
23802+ if (uderef_enabled)
23803+ pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
23804+ return 1;
23805+}
23806+__setup("pax_weakuderef", setup_pax_weakuderef);
23807+#endif
23808+
23809+static int __init setup_pax_nouderef(char *str)
23810+{
23811+#ifdef CONFIG_X86_32
23812+ unsigned int cpu;
23813+ struct desc_struct *gdt;
23814+
23815+ for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
23816+ gdt = get_cpu_gdt_table(cpu);
23817+ gdt[GDT_ENTRY_KERNEL_DS].type = 3;
23818+ gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
23819+ gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
23820+ gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
23821+ }
23822+ loadsegment(ds, __KERNEL_DS);
23823+ loadsegment(es, __KERNEL_DS);
23824+ loadsegment(ss, __KERNEL_DS);
23825+#else
23826+ memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
23827+ memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
23828+ clone_pgd_mask = ~(pgdval_t)0UL;
23829+ pax_user_shadow_base = 0UL;
23830+ setup_clear_cpu_cap(X86_FEATURE_PCIDUDEREF);
23831+ uderef_enabled = false;
23832+#endif
23833+
23834+ return 0;
23835+}
23836+early_param("pax_nouderef", setup_pax_nouderef);
23837+#endif
23838+
23839+#ifdef CONFIG_X86_64
23840+static __init int setup_disable_pcid(char *arg)
23841+{
23842+ setup_clear_cpu_cap(X86_FEATURE_PCID);
23843+ setup_clear_cpu_cap(X86_FEATURE_INVPCID);
23844+
23845+#ifdef CONFIG_PAX_MEMORY_UDEREF
23846+ if (uderef_enabled)
23847+ pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
23848+#endif
23849+
23850+ return 1;
23851+}
23852+__setup("nopcid", setup_disable_pcid);
23853+
23854+static void setup_pcid(struct cpuinfo_x86 *c)
23855+{
23856+ if (cpu_has(c, X86_FEATURE_PCID)) {
23857+ printk("PAX: PCID detected\n");
23858+ cr4_set_bits(X86_CR4_PCIDE);
23859+ } else
23860+ clear_cpu_cap(c, X86_FEATURE_INVPCID);
23861+
23862+ if (cpu_has(c, X86_FEATURE_INVPCID))
23863+ printk("PAX: INVPCID detected\n");
23864+
23865+#ifdef CONFIG_PAX_MEMORY_UDEREF
23866+ if (!uderef_enabled) {
23867+ printk("PAX: UDEREF disabled\n");
23868+ return;
23869+ }
23870+
23871+ if (!cpu_has(c, X86_FEATURE_PCID)) {
23872+ pax_open_kernel();
23873+ pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
23874+ pax_close_kernel();
23875+ printk("PAX: slow and weak UDEREF enabled\n");
23876+ return;
23877+ }
23878+
23879+ set_cpu_cap(c, X86_FEATURE_PCIDUDEREF);
23880+
23881+ pax_open_kernel();
23882+ clone_pgd_mask = ~(pgdval_t)0UL;
23883+ pax_close_kernel();
23884+ if (pax_user_shadow_base)
23885+ printk("PAX: weak UDEREF enabled\n");
23886+ else {
23887+ set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
23888+ printk("PAX: strong UDEREF enabled\n");
23889+ }
23890+#endif
23891+
23892+}
23893+#endif
23894+
23895 /*
23896 * Some CPU features depend on higher CPUID levels, which may not always
23897 * be available due to CPUID level capping or broken virtualization
23898@@ -387,7 +436,7 @@ void switch_to_new_gdt(int cpu)
23899 {
23900 struct desc_ptr gdt_descr;
23901
23902- gdt_descr.address = (long)get_cpu_gdt_table(cpu);
23903+ gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
23904 gdt_descr.size = GDT_SIZE - 1;
23905 load_gdt(&gdt_descr);
23906 /* Reload the per-cpu base */
23907@@ -918,6 +967,20 @@ static void identify_cpu(struct cpuinfo_x86 *c)
23908 setup_smep(c);
23909 setup_smap(c);
23910
23911+#ifdef CONFIG_X86_32
23912+#ifdef CONFIG_PAX_PAGEEXEC
23913+ if (!(__supported_pte_mask & _PAGE_NX))
23914+ clear_cpu_cap(c, X86_FEATURE_PSE);
23915+#endif
23916+#if defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
23917+ clear_cpu_cap(c, X86_FEATURE_SEP);
23918+#endif
23919+#endif
23920+
23921+#ifdef CONFIG_X86_64
23922+ setup_pcid(c);
23923+#endif
23924+
23925 /*
23926 * The vendor-specific functions might have changed features.
23927 * Now we do "generic changes."
23928@@ -992,7 +1055,7 @@ void enable_sep_cpu(void)
23929 int cpu;
23930
23931 cpu = get_cpu();
23932- tss = &per_cpu(cpu_tss, cpu);
23933+ tss = cpu_tss + cpu;
23934
23935 if (!boot_cpu_has(X86_FEATURE_SEP))
23936 goto out;
23937@@ -1138,10 +1201,12 @@ static __init int setup_disablecpuid(char *arg)
23938 }
23939 __setup("clearcpuid=", setup_disablecpuid);
23940
23941+DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
23942+EXPORT_PER_CPU_SYMBOL(current_tinfo);
23943+
23944 #ifdef CONFIG_X86_64
23945-struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
23946-struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
23947- (unsigned long) debug_idt_table };
23948+struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
23949+const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
23950
23951 DEFINE_PER_CPU_FIRST(union irq_stack_union,
23952 irq_stack_union) __aligned(PAGE_SIZE) __visible;
23953@@ -1253,21 +1318,21 @@ EXPORT_PER_CPU_SYMBOL(current_task);
23954 DEFINE_PER_CPU(int, __preempt_count) = INIT_PREEMPT_COUNT;
23955 EXPORT_PER_CPU_SYMBOL(__preempt_count);
23956
23957+#ifdef CONFIG_CC_STACKPROTECTOR
23958+DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
23959+#endif
23960+
23961+#endif /* CONFIG_X86_64 */
23962+
23963 /*
23964 * On x86_32, vm86 modifies tss.sp0, so sp0 isn't a reliable way to find
23965 * the top of the kernel stack. Use an extra percpu variable to track the
23966 * top of the kernel stack directly.
23967 */
23968 DEFINE_PER_CPU(unsigned long, cpu_current_top_of_stack) =
23969- (unsigned long)&init_thread_union + THREAD_SIZE;
23970+ (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
23971 EXPORT_PER_CPU_SYMBOL(cpu_current_top_of_stack);
23972
23973-#ifdef CONFIG_CC_STACKPROTECTOR
23974-DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
23975-#endif
23976-
23977-#endif /* CONFIG_X86_64 */
23978-
23979 /*
23980 * Clear all 6 debug registers:
23981 */
23982@@ -1343,7 +1408,7 @@ void cpu_init(void)
23983 */
23984 load_ucode_ap();
23985
23986- t = &per_cpu(cpu_tss, cpu);
23987+ t = cpu_tss + cpu;
23988 oist = &per_cpu(orig_ist, cpu);
23989
23990 #ifdef CONFIG_NUMA
23991@@ -1375,7 +1440,6 @@ void cpu_init(void)
23992 wrmsrl(MSR_KERNEL_GS_BASE, 0);
23993 barrier();
23994
23995- x86_configure_nx();
23996 x2apic_setup();
23997
23998 /*
23999@@ -1427,7 +1491,7 @@ void cpu_init(void)
24000 {
24001 int cpu = smp_processor_id();
24002 struct task_struct *curr = current;
24003- struct tss_struct *t = &per_cpu(cpu_tss, cpu);
24004+ struct tss_struct *t = cpu_tss + cpu;
24005 struct thread_struct *thread = &curr->thread;
24006
24007 wait_for_master_cpu(cpu);
24008diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
24009index be4febc..f7af533 100644
24010--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
24011+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
24012@@ -519,25 +519,23 @@ cache_private_attrs_is_visible(struct kobject *kobj,
24013 return 0;
24014 }
24015
24016+static struct attribute *amd_l3_attrs[4];
24017+
24018 static struct attribute_group cache_private_group = {
24019 .is_visible = cache_private_attrs_is_visible,
24020+ .attrs = amd_l3_attrs,
24021 };
24022
24023 static void init_amd_l3_attrs(void)
24024 {
24025 int n = 1;
24026- static struct attribute **amd_l3_attrs;
24027-
24028- if (amd_l3_attrs) /* already initialized */
24029- return;
24030
24031 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
24032 n += 2;
24033 if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
24034 n += 1;
24035
24036- amd_l3_attrs = kcalloc(n, sizeof(*amd_l3_attrs), GFP_KERNEL);
24037- if (!amd_l3_attrs)
24038+ if (n > 1 && amd_l3_attrs[0]) /* already initialized */
24039 return;
24040
24041 n = 0;
24042@@ -547,8 +545,6 @@ static void init_amd_l3_attrs(void)
24043 }
24044 if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
24045 amd_l3_attrs[n++] = &dev_attr_subcaches.attr;
24046-
24047- cache_private_group.attrs = amd_l3_attrs;
24048 }
24049
24050 const struct attribute_group *
24051@@ -559,7 +555,7 @@ cache_get_priv_group(struct cacheinfo *this_leaf)
24052 if (this_leaf->level < 3 || !nb)
24053 return NULL;
24054
24055- if (nb && nb->l3_cache.indices)
24056+ if (nb->l3_cache.indices)
24057 init_amd_l3_attrs();
24058
24059 return &cache_private_group;
24060diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
24061index df919ff..3332bf7 100644
24062--- a/arch/x86/kernel/cpu/mcheck/mce.c
24063+++ b/arch/x86/kernel/cpu/mcheck/mce.c
24064@@ -47,6 +47,7 @@
24065 #include <asm/tlbflush.h>
24066 #include <asm/mce.h>
24067 #include <asm/msr.h>
24068+#include <asm/local.h>
24069
24070 #include "mce-internal.h"
24071
24072@@ -259,7 +260,7 @@ static void print_mce(struct mce *m)
24073 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
24074 m->cs, m->ip);
24075
24076- if (m->cs == __KERNEL_CS)
24077+ if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
24078 print_symbol("{%s}", m->ip);
24079 pr_cont("\n");
24080 }
24081@@ -292,10 +293,10 @@ static void print_mce(struct mce *m)
24082
24083 #define PANIC_TIMEOUT 5 /* 5 seconds */
24084
24085-static atomic_t mce_panicked;
24086+static atomic_unchecked_t mce_panicked;
24087
24088 static int fake_panic;
24089-static atomic_t mce_fake_panicked;
24090+static atomic_unchecked_t mce_fake_panicked;
24091
24092 /* Panic in progress. Enable interrupts and wait for final IPI */
24093 static void wait_for_panic(void)
24094@@ -319,7 +320,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp)
24095 /*
24096 * Make sure only one CPU runs in machine check panic
24097 */
24098- if (atomic_inc_return(&mce_panicked) > 1)
24099+ if (atomic_inc_return_unchecked(&mce_panicked) > 1)
24100 wait_for_panic();
24101 barrier();
24102
24103@@ -327,7 +328,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp)
24104 console_verbose();
24105 } else {
24106 /* Don't log too much for fake panic */
24107- if (atomic_inc_return(&mce_fake_panicked) > 1)
24108+ if (atomic_inc_return_unchecked(&mce_fake_panicked) > 1)
24109 return;
24110 }
24111 /* First print corrected ones that are still unlogged */
24112@@ -366,7 +367,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp)
24113 if (!fake_panic) {
24114 if (panic_timeout == 0)
24115 panic_timeout = mca_cfg.panic_timeout;
24116- panic(msg);
24117+ panic("%s", msg);
24118 } else
24119 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
24120 }
24121@@ -752,7 +753,7 @@ static int mce_timed_out(u64 *t, const char *msg)
24122 * might have been modified by someone else.
24123 */
24124 rmb();
24125- if (atomic_read(&mce_panicked))
24126+ if (atomic_read_unchecked(&mce_panicked))
24127 wait_for_panic();
24128 if (!mca_cfg.monarch_timeout)
24129 goto out;
24130@@ -1708,7 +1709,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
24131 }
24132
24133 /* Call the installed machine check handler for this CPU setup. */
24134-void (*machine_check_vector)(struct pt_regs *, long error_code) =
24135+void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
24136 unexpected_machine_check;
24137
24138 /*
24139@@ -1731,7 +1732,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
24140 return;
24141 }
24142
24143+ pax_open_kernel();
24144 machine_check_vector = do_machine_check;
24145+ pax_close_kernel();
24146
24147 __mcheck_cpu_init_generic();
24148 __mcheck_cpu_init_vendor(c);
24149@@ -1745,7 +1748,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
24150 */
24151
24152 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
24153-static int mce_chrdev_open_count; /* #times opened */
24154+static local_t mce_chrdev_open_count; /* #times opened */
24155 static int mce_chrdev_open_exclu; /* already open exclusive? */
24156
24157 static int mce_chrdev_open(struct inode *inode, struct file *file)
24158@@ -1753,7 +1756,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
24159 spin_lock(&mce_chrdev_state_lock);
24160
24161 if (mce_chrdev_open_exclu ||
24162- (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
24163+ (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
24164 spin_unlock(&mce_chrdev_state_lock);
24165
24166 return -EBUSY;
24167@@ -1761,7 +1764,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
24168
24169 if (file->f_flags & O_EXCL)
24170 mce_chrdev_open_exclu = 1;
24171- mce_chrdev_open_count++;
24172+ local_inc(&mce_chrdev_open_count);
24173
24174 spin_unlock(&mce_chrdev_state_lock);
24175
24176@@ -1772,7 +1775,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
24177 {
24178 spin_lock(&mce_chrdev_state_lock);
24179
24180- mce_chrdev_open_count--;
24181+ local_dec(&mce_chrdev_open_count);
24182 mce_chrdev_open_exclu = 0;
24183
24184 spin_unlock(&mce_chrdev_state_lock);
24185@@ -2448,7 +2451,7 @@ static __init void mce_init_banks(void)
24186
24187 for (i = 0; i < mca_cfg.banks; i++) {
24188 struct mce_bank *b = &mce_banks[i];
24189- struct device_attribute *a = &b->attr;
24190+ device_attribute_no_const *a = &b->attr;
24191
24192 sysfs_attr_init(&a->attr);
24193 a->attr.name = b->attrname;
24194@@ -2555,7 +2558,7 @@ struct dentry *mce_get_debugfs_dir(void)
24195 static void mce_reset(void)
24196 {
24197 cpu_missing = 0;
24198- atomic_set(&mce_fake_panicked, 0);
24199+ atomic_set_unchecked(&mce_fake_panicked, 0);
24200 atomic_set(&mce_executing, 0);
24201 atomic_set(&mce_callin, 0);
24202 atomic_set(&global_nwo, 0);
24203diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
24204index 737b0ad..09ec66e 100644
24205--- a/arch/x86/kernel/cpu/mcheck/p5.c
24206+++ b/arch/x86/kernel/cpu/mcheck/p5.c
24207@@ -12,6 +12,7 @@
24208 #include <asm/tlbflush.h>
24209 #include <asm/mce.h>
24210 #include <asm/msr.h>
24211+#include <asm/pgtable.h>
24212
24213 /* By default disabled */
24214 int mce_p5_enabled __read_mostly;
24215@@ -55,7 +56,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
24216 if (!cpu_has(c, X86_FEATURE_MCE))
24217 return;
24218
24219+ pax_open_kernel();
24220 machine_check_vector = pentium_machine_check;
24221+ pax_close_kernel();
24222 /* Make sure the vector pointer is visible before we enable MCEs: */
24223 wmb();
24224
24225diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
24226index 44f1382..315b292 100644
24227--- a/arch/x86/kernel/cpu/mcheck/winchip.c
24228+++ b/arch/x86/kernel/cpu/mcheck/winchip.c
24229@@ -11,6 +11,7 @@
24230 #include <asm/tlbflush.h>
24231 #include <asm/mce.h>
24232 #include <asm/msr.h>
24233+#include <asm/pgtable.h>
24234
24235 /* Machine check handler for WinChip C6: */
24236 static void winchip_machine_check(struct pt_regs *regs, long error_code)
24237@@ -28,7 +29,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
24238 {
24239 u32 lo, hi;
24240
24241+ pax_open_kernel();
24242 machine_check_vector = winchip_machine_check;
24243+ pax_close_kernel();
24244 /* Make sure the vector pointer is visible before we enable MCEs: */
24245 wmb();
24246
24247diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
24248index 6236a54..532026d 100644
24249--- a/arch/x86/kernel/cpu/microcode/core.c
24250+++ b/arch/x86/kernel/cpu/microcode/core.c
24251@@ -460,7 +460,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24252 return NOTIFY_OK;
24253 }
24254
24255-static struct notifier_block __refdata mc_cpu_notifier = {
24256+static struct notifier_block mc_cpu_notifier = {
24257 .notifier_call = mc_cpu_callback,
24258 };
24259
24260diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
24261index 969dc17..a9c3fdd 100644
24262--- a/arch/x86/kernel/cpu/microcode/intel.c
24263+++ b/arch/x86/kernel/cpu/microcode/intel.c
24264@@ -237,13 +237,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24265
24266 static int get_ucode_user(void *to, const void *from, size_t n)
24267 {
24268- return copy_from_user(to, from, n);
24269+ return copy_from_user(to, (const void __force_user *)from, n);
24270 }
24271
24272 static enum ucode_state
24273 request_microcode_user(int cpu, const void __user *buf, size_t size)
24274 {
24275- return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24276+ return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24277 }
24278
24279 static void microcode_fini_cpu(int cpu)
24280diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
24281index e7ed0d8..57a2ab9 100644
24282--- a/arch/x86/kernel/cpu/mtrr/main.c
24283+++ b/arch/x86/kernel/cpu/mtrr/main.c
24284@@ -72,7 +72,7 @@ static DEFINE_MUTEX(mtrr_mutex);
24285 u64 size_or_mask, size_and_mask;
24286 static bool mtrr_aps_delayed_init;
24287
24288-static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
24289+static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
24290
24291 const struct mtrr_ops *mtrr_if;
24292
24293diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
24294index 951884d..4796b75 100644
24295--- a/arch/x86/kernel/cpu/mtrr/mtrr.h
24296+++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
24297@@ -25,7 +25,7 @@ struct mtrr_ops {
24298 int (*validate_add_page)(unsigned long base, unsigned long size,
24299 unsigned int type);
24300 int (*have_wrcomb)(void);
24301-};
24302+} __do_const;
24303
24304 extern int generic_get_free_region(unsigned long base, unsigned long size,
24305 int replace_reg);
24306diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
24307index 9469dfa..2b026bc 100644
24308--- a/arch/x86/kernel/cpu/perf_event.c
24309+++ b/arch/x86/kernel/cpu/perf_event.c
24310@@ -1518,7 +1518,7 @@ static void __init pmu_check_apic(void)
24311
24312 }
24313
24314-static struct attribute_group x86_pmu_format_group = {
24315+static attribute_group_no_const x86_pmu_format_group = {
24316 .name = "format",
24317 .attrs = NULL,
24318 };
24319@@ -1617,7 +1617,7 @@ static struct attribute *events_attr[] = {
24320 NULL,
24321 };
24322
24323-static struct attribute_group x86_pmu_events_group = {
24324+static attribute_group_no_const x86_pmu_events_group = {
24325 .name = "events",
24326 .attrs = events_attr,
24327 };
24328@@ -2176,7 +2176,7 @@ valid_user_frame(const void __user *fp, unsigned long size)
24329 static unsigned long get_segment_base(unsigned int segment)
24330 {
24331 struct desc_struct *desc;
24332- int idx = segment >> 3;
24333+ unsigned int idx = segment >> 3;
24334
24335 if ((segment & SEGMENT_TI_MASK) == SEGMENT_LDT) {
24336 struct ldt_struct *ldt;
24337@@ -2194,7 +2194,7 @@ static unsigned long get_segment_base(unsigned int segment)
24338 if (idx > GDT_ENTRIES)
24339 return 0;
24340
24341- desc = raw_cpu_ptr(gdt_page.gdt) + idx;
24342+ desc = get_cpu_gdt_table(smp_processor_id()) + idx;
24343 }
24344
24345 return get_desc_base(desc);
24346@@ -2284,7 +2284,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
24347 break;
24348
24349 perf_callchain_store(entry, frame.return_address);
24350- fp = frame.next_frame;
24351+ fp = (const void __force_user *)frame.next_frame;
24352 }
24353 }
24354
24355diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
24356index 97242a9..cf9c30e 100644
24357--- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
24358+++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
24359@@ -402,7 +402,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
24360 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
24361 {
24362 struct attribute **attrs;
24363- struct attribute_group *attr_group;
24364+ attribute_group_no_const *attr_group;
24365 int i = 0, j;
24366
24367 while (amd_iommu_v2_event_descs[i].attr.attr.name)
24368diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
24369index 1b09c42..521004d 100644
24370--- a/arch/x86/kernel/cpu/perf_event_intel.c
24371+++ b/arch/x86/kernel/cpu/perf_event_intel.c
24372@@ -3019,10 +3019,10 @@ __init int intel_pmu_init(void)
24373 x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
24374
24375 if (boot_cpu_has(X86_FEATURE_PDCM)) {
24376- u64 capabilities;
24377+ u64 capabilities = x86_pmu.intel_cap.capabilities;
24378
24379- rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
24380- x86_pmu.intel_cap.capabilities = capabilities;
24381+ if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
24382+ x86_pmu.intel_cap.capabilities = capabilities;
24383 }
24384
24385 intel_ds_init();
24386diff --git a/arch/x86/kernel/cpu/perf_event_intel_bts.c b/arch/x86/kernel/cpu/perf_event_intel_bts.c
24387index 43dd672..78c0562 100644
24388--- a/arch/x86/kernel/cpu/perf_event_intel_bts.c
24389+++ b/arch/x86/kernel/cpu/perf_event_intel_bts.c
24390@@ -252,7 +252,7 @@ static void bts_event_start(struct perf_event *event, int flags)
24391 __bts_event_start(event);
24392
24393 /* PMI handler: this counter is running and likely generating PMIs */
24394- ACCESS_ONCE(bts->started) = 1;
24395+ ACCESS_ONCE_RW(bts->started) = 1;
24396 }
24397
24398 static void __bts_event_stop(struct perf_event *event)
24399@@ -266,7 +266,7 @@ static void __bts_event_stop(struct perf_event *event)
24400 if (event->hw.state & PERF_HES_STOPPED)
24401 return;
24402
24403- ACCESS_ONCE(event->hw.state) |= PERF_HES_STOPPED;
24404+ ACCESS_ONCE_RW(event->hw.state) |= PERF_HES_STOPPED;
24405 }
24406
24407 static void bts_event_stop(struct perf_event *event, int flags)
24408@@ -274,7 +274,7 @@ static void bts_event_stop(struct perf_event *event, int flags)
24409 struct bts_ctx *bts = this_cpu_ptr(&bts_ctx);
24410
24411 /* PMI handler: don't restart this counter */
24412- ACCESS_ONCE(bts->started) = 0;
24413+ ACCESS_ONCE_RW(bts->started) = 0;
24414
24415 __bts_event_stop(event);
24416
24417diff --git a/arch/x86/kernel/cpu/perf_event_intel_cqm.c b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
24418index 377e8f8..2982f48 100644
24419--- a/arch/x86/kernel/cpu/perf_event_intel_cqm.c
24420+++ b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
24421@@ -1364,7 +1364,9 @@ static int __init intel_cqm_init(void)
24422 goto out;
24423 }
24424
24425- event_attr_intel_cqm_llc_scale.event_str = str;
24426+ pax_open_kernel();
24427+ *(const char **)&event_attr_intel_cqm_llc_scale.event_str = str;
24428+ pax_close_kernel();
24429
24430 ret = intel_cqm_setup_rmid_cache();
24431 if (ret)
24432diff --git a/arch/x86/kernel/cpu/perf_event_intel_pt.c b/arch/x86/kernel/cpu/perf_event_intel_pt.c
24433index 183de71..bd34d52 100644
24434--- a/arch/x86/kernel/cpu/perf_event_intel_pt.c
24435+++ b/arch/x86/kernel/cpu/perf_event_intel_pt.c
24436@@ -116,16 +116,12 @@ static const struct attribute_group *pt_attr_groups[] = {
24437
24438 static int __init pt_pmu_hw_init(void)
24439 {
24440- struct dev_ext_attribute *de_attrs;
24441- struct attribute **attrs;
24442- size_t size;
24443- int ret;
24444+ static struct dev_ext_attribute de_attrs[ARRAY_SIZE(pt_caps)];
24445+ static struct attribute *attrs[ARRAY_SIZE(pt_caps)];
24446 long i;
24447
24448- attrs = NULL;
24449- ret = -ENODEV;
24450 if (!test_cpu_cap(&boot_cpu_data, X86_FEATURE_INTEL_PT))
24451- goto fail;
24452+ return -ENODEV;
24453
24454 for (i = 0; i < PT_CPUID_LEAVES; i++) {
24455 cpuid_count(20, i,
24456@@ -135,39 +131,25 @@ static int __init pt_pmu_hw_init(void)
24457 &pt_pmu.caps[CR_EDX + i*4]);
24458 }
24459
24460- ret = -ENOMEM;
24461- size = sizeof(struct attribute *) * (ARRAY_SIZE(pt_caps)+1);
24462- attrs = kzalloc(size, GFP_KERNEL);
24463- if (!attrs)
24464- goto fail;
24465-
24466- size = sizeof(struct dev_ext_attribute) * (ARRAY_SIZE(pt_caps)+1);
24467- de_attrs = kzalloc(size, GFP_KERNEL);
24468- if (!de_attrs)
24469- goto fail;
24470-
24471+ pax_open_kernel();
24472 for (i = 0; i < ARRAY_SIZE(pt_caps); i++) {
24473- struct dev_ext_attribute *de_attr = de_attrs + i;
24474+ struct dev_ext_attribute *de_attr = &de_attrs[i];
24475
24476- de_attr->attr.attr.name = pt_caps[i].name;
24477+ *(const char **)&de_attr->attr.attr.name = pt_caps[i].name;
24478
24479 sysfs_attr_init(&de_attr->attr.attr);
24480
24481- de_attr->attr.attr.mode = S_IRUGO;
24482- de_attr->attr.show = pt_cap_show;
24483- de_attr->var = (void *)i;
24484+ *(umode_t *)&de_attr->attr.attr.mode = S_IRUGO;
24485+ *(void **)&de_attr->attr.show = pt_cap_show;
24486+ *(void **)&de_attr->var = (void *)i;
24487
24488 attrs[i] = &de_attr->attr.attr;
24489 }
24490
24491- pt_cap_group.attrs = attrs;
24492+ *(struct attribute ***)&pt_cap_group.attrs = attrs;
24493+ pax_close_kernel();
24494
24495 return 0;
24496-
24497-fail:
24498- kfree(attrs);
24499-
24500- return ret;
24501 }
24502
24503 #define PT_CONFIG_MASK (RTIT_CTL_TSC_EN | RTIT_CTL_DISRETC)
24504@@ -929,7 +911,7 @@ static void pt_event_start(struct perf_event *event, int mode)
24505 return;
24506 }
24507
24508- ACCESS_ONCE(pt->handle_nmi) = 1;
24509+ ACCESS_ONCE_RW(pt->handle_nmi) = 1;
24510 event->hw.state = 0;
24511
24512 pt_config_buffer(buf->cur->table, buf->cur_idx,
24513@@ -946,7 +928,7 @@ static void pt_event_stop(struct perf_event *event, int mode)
24514 * Protect against the PMI racing with disabling wrmsr,
24515 * see comment in intel_pt_interrupt().
24516 */
24517- ACCESS_ONCE(pt->handle_nmi) = 0;
24518+ ACCESS_ONCE_RW(pt->handle_nmi) = 0;
24519 pt_config_start(false);
24520
24521 if (event->hw.state == PERF_HES_STOPPED)
24522diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
24523index 5cbd4e6..ee9388a 100644
24524--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
24525+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
24526@@ -486,7 +486,7 @@ static struct attribute *rapl_events_hsw_attr[] = {
24527 NULL,
24528 };
24529
24530-static struct attribute_group rapl_pmu_events_group = {
24531+static attribute_group_no_const rapl_pmu_events_group __read_only = {
24532 .name = "events",
24533 .attrs = NULL, /* patched at runtime */
24534 };
24535diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
24536index 21b5e38..84f1f82 100644
24537--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
24538+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
24539@@ -731,7 +731,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
24540 static int __init uncore_type_init(struct intel_uncore_type *type)
24541 {
24542 struct intel_uncore_pmu *pmus;
24543- struct attribute_group *attr_group;
24544+ attribute_group_no_const *attr_group;
24545 struct attribute **attrs;
24546 int i, j;
24547
24548diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
24549index 0f77f0a..d3c6b7d 100644
24550--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
24551+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
24552@@ -115,7 +115,7 @@ struct intel_uncore_box {
24553 struct uncore_event_desc {
24554 struct kobj_attribute attr;
24555 const char *config;
24556-};
24557+} __do_const;
24558
24559 ssize_t uncore_event_show(struct kobject *kobj,
24560 struct kobj_attribute *attr, char *buf);
24561diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
24562index 83741a7..bd3507d 100644
24563--- a/arch/x86/kernel/cpuid.c
24564+++ b/arch/x86/kernel/cpuid.c
24565@@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
24566 return notifier_from_errno(err);
24567 }
24568
24569-static struct notifier_block __refdata cpuid_class_cpu_notifier =
24570+static struct notifier_block cpuid_class_cpu_notifier =
24571 {
24572 .notifier_call = cpuid_class_cpu_callback,
24573 };
24574diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
24575index afa64ad..dce67dd 100644
24576--- a/arch/x86/kernel/crash_dump_64.c
24577+++ b/arch/x86/kernel/crash_dump_64.c
24578@@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
24579 return -ENOMEM;
24580
24581 if (userbuf) {
24582- if (copy_to_user(buf, vaddr + offset, csize)) {
24583+ if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
24584 iounmap(vaddr);
24585 return -EFAULT;
24586 }
24587diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
24588index f6dfd93..892ade4 100644
24589--- a/arch/x86/kernel/doublefault.c
24590+++ b/arch/x86/kernel/doublefault.c
24591@@ -12,7 +12,7 @@
24592
24593 #define DOUBLEFAULT_STACKSIZE (1024)
24594 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
24595-#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
24596+#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
24597
24598 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
24599
24600@@ -22,7 +22,7 @@ static void doublefault_fn(void)
24601 unsigned long gdt, tss;
24602
24603 native_store_gdt(&gdt_desc);
24604- gdt = gdt_desc.address;
24605+ gdt = (unsigned long)gdt_desc.address;
24606
24607 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
24608
24609@@ -59,10 +59,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
24610 /* 0x2 bit is always set */
24611 .flags = X86_EFLAGS_SF | 0x2,
24612 .sp = STACK_START,
24613- .es = __USER_DS,
24614+ .es = __KERNEL_DS,
24615 .cs = __KERNEL_CS,
24616 .ss = __KERNEL_DS,
24617- .ds = __USER_DS,
24618+ .ds = __KERNEL_DS,
24619 .fs = __KERNEL_PERCPU,
24620
24621 .__cr3 = __pa_nodebug(swapper_pg_dir),
24622diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
24623index 9c30acf..8cf2411 100644
24624--- a/arch/x86/kernel/dumpstack.c
24625+++ b/arch/x86/kernel/dumpstack.c
24626@@ -2,6 +2,9 @@
24627 * Copyright (C) 1991, 1992 Linus Torvalds
24628 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
24629 */
24630+#ifdef CONFIG_GRKERNSEC_HIDESYM
24631+#define __INCLUDED_BY_HIDESYM 1
24632+#endif
24633 #include <linux/kallsyms.h>
24634 #include <linux/kprobes.h>
24635 #include <linux/uaccess.h>
24636@@ -35,23 +38,21 @@ static void printk_stack_address(unsigned long address, int reliable,
24637
24638 void printk_address(unsigned long address)
24639 {
24640- pr_cont(" [<%p>] %pS\n", (void *)address, (void *)address);
24641+ pr_cont(" [<%p>] %pA\n", (void *)address, (void *)address);
24642 }
24643
24644 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
24645 static void
24646 print_ftrace_graph_addr(unsigned long addr, void *data,
24647 const struct stacktrace_ops *ops,
24648- struct thread_info *tinfo, int *graph)
24649+ struct task_struct *task, int *graph)
24650 {
24651- struct task_struct *task;
24652 unsigned long ret_addr;
24653 int index;
24654
24655 if (addr != (unsigned long)return_to_handler)
24656 return;
24657
24658- task = tinfo->task;
24659 index = task->curr_ret_stack;
24660
24661 if (!task->ret_stack || index < *graph)
24662@@ -68,7 +69,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
24663 static inline void
24664 print_ftrace_graph_addr(unsigned long addr, void *data,
24665 const struct stacktrace_ops *ops,
24666- struct thread_info *tinfo, int *graph)
24667+ struct task_struct *task, int *graph)
24668 { }
24669 #endif
24670
24671@@ -79,10 +80,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
24672 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
24673 */
24674
24675-static inline int valid_stack_ptr(struct thread_info *tinfo,
24676- void *p, unsigned int size, void *end)
24677+static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
24678 {
24679- void *t = tinfo;
24680 if (end) {
24681 if (p < end && p >= (end-THREAD_SIZE))
24682 return 1;
24683@@ -93,14 +92,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
24684 }
24685
24686 unsigned long
24687-print_context_stack(struct thread_info *tinfo,
24688+print_context_stack(struct task_struct *task, void *stack_start,
24689 unsigned long *stack, unsigned long bp,
24690 const struct stacktrace_ops *ops, void *data,
24691 unsigned long *end, int *graph)
24692 {
24693 struct stack_frame *frame = (struct stack_frame *)bp;
24694
24695- while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
24696+ while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
24697 unsigned long addr;
24698
24699 addr = *stack;
24700@@ -112,7 +111,7 @@ print_context_stack(struct thread_info *tinfo,
24701 } else {
24702 ops->address(data, addr, 0);
24703 }
24704- print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
24705+ print_ftrace_graph_addr(addr, data, ops, task, graph);
24706 }
24707 stack++;
24708 }
24709@@ -121,7 +120,7 @@ print_context_stack(struct thread_info *tinfo,
24710 EXPORT_SYMBOL_GPL(print_context_stack);
24711
24712 unsigned long
24713-print_context_stack_bp(struct thread_info *tinfo,
24714+print_context_stack_bp(struct task_struct *task, void *stack_start,
24715 unsigned long *stack, unsigned long bp,
24716 const struct stacktrace_ops *ops, void *data,
24717 unsigned long *end, int *graph)
24718@@ -129,7 +128,7 @@ print_context_stack_bp(struct thread_info *tinfo,
24719 struct stack_frame *frame = (struct stack_frame *)bp;
24720 unsigned long *ret_addr = &frame->return_address;
24721
24722- while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
24723+ while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
24724 unsigned long addr = *ret_addr;
24725
24726 if (!__kernel_text_address(addr))
24727@@ -138,7 +137,7 @@ print_context_stack_bp(struct thread_info *tinfo,
24728 ops->address(data, addr, 1);
24729 frame = frame->next_frame;
24730 ret_addr = &frame->return_address;
24731- print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
24732+ print_ftrace_graph_addr(addr, data, ops, task, graph);
24733 }
24734
24735 return (unsigned long)frame;
24736@@ -226,6 +225,8 @@ unsigned long oops_begin(void)
24737 EXPORT_SYMBOL_GPL(oops_begin);
24738 NOKPROBE_SYMBOL(oops_begin);
24739
24740+extern void gr_handle_kernel_exploit(void);
24741+
24742 void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
24743 {
24744 if (regs && kexec_should_crash(current))
24745@@ -247,7 +248,10 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
24746 panic("Fatal exception in interrupt");
24747 if (panic_on_oops)
24748 panic("Fatal exception");
24749- do_exit(signr);
24750+
24751+ gr_handle_kernel_exploit();
24752+
24753+ do_group_exit(signr);
24754 }
24755 NOKPROBE_SYMBOL(oops_end);
24756
24757diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
24758index 464ffd6..01f2cda 100644
24759--- a/arch/x86/kernel/dumpstack_32.c
24760+++ b/arch/x86/kernel/dumpstack_32.c
24761@@ -61,15 +61,14 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24762 bp = stack_frame(task, regs);
24763
24764 for (;;) {
24765- struct thread_info *context;
24766+ void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
24767 void *end_stack;
24768
24769 end_stack = is_hardirq_stack(stack, cpu);
24770 if (!end_stack)
24771 end_stack = is_softirq_stack(stack, cpu);
24772
24773- context = task_thread_info(task);
24774- bp = ops->walk_stack(context, stack, bp, ops, data,
24775+ bp = ops->walk_stack(task, stack_start, stack, bp, ops, data,
24776 end_stack, &graph);
24777
24778 /* Stop if not on irq stack */
24779@@ -137,16 +136,17 @@ void show_regs(struct pt_regs *regs)
24780 unsigned int code_len = code_bytes;
24781 unsigned char c;
24782 u8 *ip;
24783+ unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
24784
24785 pr_emerg("Stack:\n");
24786 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
24787
24788 pr_emerg("Code:");
24789
24790- ip = (u8 *)regs->ip - code_prologue;
24791+ ip = (u8 *)regs->ip - code_prologue + cs_base;
24792 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
24793 /* try starting at IP */
24794- ip = (u8 *)regs->ip;
24795+ ip = (u8 *)regs->ip + cs_base;
24796 code_len = code_len - code_prologue + 1;
24797 }
24798 for (i = 0; i < code_len; i++, ip++) {
24799@@ -155,7 +155,7 @@ void show_regs(struct pt_regs *regs)
24800 pr_cont(" Bad EIP value.");
24801 break;
24802 }
24803- if (ip == (u8 *)regs->ip)
24804+ if (ip == (u8 *)regs->ip + cs_base)
24805 pr_cont(" <%02x>", c);
24806 else
24807 pr_cont(" %02x", c);
24808@@ -168,6 +168,7 @@ int is_valid_bugaddr(unsigned long ip)
24809 {
24810 unsigned short ud2;
24811
24812+ ip = ktla_ktva(ip);
24813 if (ip < PAGE_OFFSET)
24814 return 0;
24815 if (probe_kernel_address((unsigned short *)ip, ud2))
24816@@ -175,3 +176,15 @@ int is_valid_bugaddr(unsigned long ip)
24817
24818 return ud2 == 0x0b0f;
24819 }
24820+
24821+#if defined(CONFIG_PAX_MEMORY_STACKLEAK) || defined(CONFIG_PAX_USERCOPY)
24822+void __used pax_check_alloca(unsigned long size)
24823+{
24824+ unsigned long sp = (unsigned long)&sp, stack_left;
24825+
24826+ /* all kernel stacks are of the same size */
24827+ stack_left = sp & (THREAD_SIZE - 1);
24828+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
24829+}
24830+EXPORT_SYMBOL(pax_check_alloca);
24831+#endif
24832diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
24833index 5f1c626..1cba97e 100644
24834--- a/arch/x86/kernel/dumpstack_64.c
24835+++ b/arch/x86/kernel/dumpstack_64.c
24836@@ -153,12 +153,12 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24837 const struct stacktrace_ops *ops, void *data)
24838 {
24839 const unsigned cpu = get_cpu();
24840- struct thread_info *tinfo;
24841 unsigned long *irq_stack = (unsigned long *)per_cpu(irq_stack_ptr, cpu);
24842 unsigned long dummy;
24843 unsigned used = 0;
24844 int graph = 0;
24845 int done = 0;
24846+ void *stack_start;
24847
24848 if (!task)
24849 task = current;
24850@@ -179,7 +179,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24851 * current stack address. If the stacks consist of nested
24852 * exceptions
24853 */
24854- tinfo = task_thread_info(task);
24855 while (!done) {
24856 unsigned long *stack_end;
24857 enum stack_type stype;
24858@@ -202,7 +201,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24859 if (ops->stack(data, id) < 0)
24860 break;
24861
24862- bp = ops->walk_stack(tinfo, stack, bp, ops,
24863+ bp = ops->walk_stack(task, stack_end - EXCEPTION_STKSZ, stack, bp, ops,
24864 data, stack_end, &graph);
24865 ops->stack(data, "<EOE>");
24866 /*
24867@@ -210,6 +209,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24868 * second-to-last pointer (index -2 to end) in the
24869 * exception stack:
24870 */
24871+ if ((u16)stack_end[-1] != __KERNEL_DS)
24872+ goto out;
24873 stack = (unsigned long *) stack_end[-2];
24874 done = 0;
24875 break;
24876@@ -218,7 +219,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24877
24878 if (ops->stack(data, "IRQ") < 0)
24879 break;
24880- bp = ops->walk_stack(tinfo, stack, bp,
24881+ bp = ops->walk_stack(task, irq_stack, stack, bp,
24882 ops, data, stack_end, &graph);
24883 /*
24884 * We link to the next stack (which would be
24885@@ -240,7 +241,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
24886 /*
24887 * This handles the process stack:
24888 */
24889- bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
24890+ stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
24891+ bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
24892+out:
24893 put_cpu();
24894 }
24895 EXPORT_SYMBOL(dump_trace);
24896@@ -347,8 +350,55 @@ int is_valid_bugaddr(unsigned long ip)
24897 {
24898 unsigned short ud2;
24899
24900- if (__copy_from_user(&ud2, (const void __user *) ip, sizeof(ud2)))
24901+ if (probe_kernel_address((unsigned short *)ip, ud2))
24902 return 0;
24903
24904 return ud2 == 0x0b0f;
24905 }
24906+
24907+#if defined(CONFIG_PAX_MEMORY_STACKLEAK) || defined(CONFIG_PAX_USERCOPY)
24908+void __used pax_check_alloca(unsigned long size)
24909+{
24910+ unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
24911+ unsigned cpu, used;
24912+ char *id;
24913+
24914+ /* check the process stack first */
24915+ stack_start = (unsigned long)task_stack_page(current);
24916+ stack_end = stack_start + THREAD_SIZE;
24917+ if (likely(stack_start <= sp && sp < stack_end)) {
24918+ unsigned long stack_left = sp & (THREAD_SIZE - 1);
24919+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
24920+ return;
24921+ }
24922+
24923+ cpu = get_cpu();
24924+
24925+ /* check the irq stacks */
24926+ stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
24927+ stack_start = stack_end - IRQ_STACK_SIZE;
24928+ if (stack_start <= sp && sp < stack_end) {
24929+ unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
24930+ put_cpu();
24931+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
24932+ return;
24933+ }
24934+
24935+ /* check the exception stacks */
24936+ used = 0;
24937+ stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
24938+ stack_start = stack_end - EXCEPTION_STKSZ;
24939+ if (stack_end && stack_start <= sp && sp < stack_end) {
24940+ unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
24941+ put_cpu();
24942+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
24943+ return;
24944+ }
24945+
24946+ put_cpu();
24947+
24948+ /* unknown stack */
24949+ BUG();
24950+}
24951+EXPORT_SYMBOL(pax_check_alloca);
24952+#endif
24953diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
24954index a102564..d1f0b73 100644
24955--- a/arch/x86/kernel/e820.c
24956+++ b/arch/x86/kernel/e820.c
24957@@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
24958
24959 static void early_panic(char *msg)
24960 {
24961- early_printk(msg);
24962- panic(msg);
24963+ early_printk("%s", msg);
24964+ panic("%s", msg);
24965 }
24966
24967 static int userdef __initdata;
24968diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
24969index eec40f5..4fee808 100644
24970--- a/arch/x86/kernel/early_printk.c
24971+++ b/arch/x86/kernel/early_printk.c
24972@@ -7,6 +7,7 @@
24973 #include <linux/pci_regs.h>
24974 #include <linux/pci_ids.h>
24975 #include <linux/errno.h>
24976+#include <linux/sched.h>
24977 #include <asm/io.h>
24978 #include <asm/processor.h>
24979 #include <asm/fcntl.h>
24980diff --git a/arch/x86/kernel/espfix_64.c b/arch/x86/kernel/espfix_64.c
24981index ce95676..af5c012 100644
24982--- a/arch/x86/kernel/espfix_64.c
24983+++ b/arch/x86/kernel/espfix_64.c
24984@@ -41,6 +41,7 @@
24985 #include <asm/pgalloc.h>
24986 #include <asm/setup.h>
24987 #include <asm/espfix.h>
24988+#include <asm/bug.h>
24989
24990 /*
24991 * Note: we only need 6*8 = 48 bytes for the espfix stack, but round
24992@@ -70,8 +71,10 @@ static DEFINE_MUTEX(espfix_init_mutex);
24993 #define ESPFIX_MAX_PAGES DIV_ROUND_UP(CONFIG_NR_CPUS, ESPFIX_STACKS_PER_PAGE)
24994 static void *espfix_pages[ESPFIX_MAX_PAGES];
24995
24996-static __page_aligned_bss pud_t espfix_pud_page[PTRS_PER_PUD]
24997- __aligned(PAGE_SIZE);
24998+static __page_aligned_rodata pud_t espfix_pud_page[PTRS_PER_PUD];
24999+static __page_aligned_rodata pmd_t espfix_pmd_page[PTRS_PER_PMD];
25000+static __page_aligned_rodata pte_t espfix_pte_page[PTRS_PER_PTE];
25001+static __page_aligned_rodata char espfix_stack_page[ESPFIX_MAX_PAGES][PAGE_SIZE];
25002
25003 static unsigned int page_random, slot_random;
25004
25005@@ -122,10 +125,19 @@ static void init_espfix_random(void)
25006 void __init init_espfix_bsp(void)
25007 {
25008 pgd_t *pgd_p;
25009+ pud_t *pud_p;
25010+ unsigned long index = pgd_index(ESPFIX_BASE_ADDR);
25011
25012 /* Install the espfix pud into the kernel page directory */
25013- pgd_p = &init_level4_pgt[pgd_index(ESPFIX_BASE_ADDR)];
25014- pgd_populate(&init_mm, pgd_p, (pud_t *)espfix_pud_page);
25015+ pgd_p = &init_level4_pgt[index];
25016+ pud_p = espfix_pud_page;
25017+ paravirt_alloc_pud(&init_mm, __pa(pud_p) >> PAGE_SHIFT);
25018+ set_pgd(pgd_p, __pgd(PGTABLE_PROT | __pa(pud_p)));
25019+
25020+#ifdef CONFIG_PAX_PER_CPU_PGD
25021+ clone_pgd_range(get_cpu_pgd(0, kernel) + index, swapper_pg_dir + index, 1);
25022+ clone_pgd_range(get_cpu_pgd(0, user) + index, swapper_pg_dir + index, 1);
25023+#endif
25024
25025 /* Randomize the locations */
25026 init_espfix_random();
25027@@ -170,35 +182,39 @@ void init_espfix_ap(int cpu)
25028 pud_p = &espfix_pud_page[pud_index(addr)];
25029 pud = *pud_p;
25030 if (!pud_present(pud)) {
25031- struct page *page = alloc_pages_node(node, PGALLOC_GFP, 0);
25032-
25033- pmd_p = (pmd_t *)page_address(page);
25034+ if (cpu)
25035+ pmd_p = page_address(alloc_pages_node(node, PGALLOC_GFP, 0));
25036+ else
25037+ pmd_p = espfix_pmd_page;
25038 pud = __pud(__pa(pmd_p) | (PGTABLE_PROT & ptemask));
25039 paravirt_alloc_pmd(&init_mm, __pa(pmd_p) >> PAGE_SHIFT);
25040 for (n = 0; n < ESPFIX_PUD_CLONES; n++)
25041 set_pud(&pud_p[n], pud);
25042- }
25043+ } else
25044+ BUG_ON(!cpu);
25045
25046 pmd_p = pmd_offset(&pud, addr);
25047 pmd = *pmd_p;
25048 if (!pmd_present(pmd)) {
25049- struct page *page = alloc_pages_node(node, PGALLOC_GFP, 0);
25050-
25051- pte_p = (pte_t *)page_address(page);
25052+ if (cpu)
25053+ pte_p = page_address(alloc_pages_node(node, PGALLOC_GFP, 0));
25054+ else
25055+ pte_p = espfix_pte_page;
25056 pmd = __pmd(__pa(pte_p) | (PGTABLE_PROT & ptemask));
25057 paravirt_alloc_pte(&init_mm, __pa(pte_p) >> PAGE_SHIFT);
25058 for (n = 0; n < ESPFIX_PMD_CLONES; n++)
25059 set_pmd(&pmd_p[n], pmd);
25060- }
25061+ } else
25062+ BUG_ON(!cpu);
25063
25064 pte_p = pte_offset_kernel(&pmd, addr);
25065- stack_page = page_address(alloc_pages_node(node, GFP_KERNEL, 0));
25066+ stack_page = espfix_stack_page[page];
25067 pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask));
25068 for (n = 0; n < ESPFIX_PTE_CLONES; n++)
25069 set_pte(&pte_p[n*PTE_STRIDE], pte);
25070
25071 /* Job is done for this CPU and any CPU which shares this page */
25072- ACCESS_ONCE(espfix_pages[page]) = stack_page;
25073+ ACCESS_ONCE_RW(espfix_pages[page]) = stack_page;
25074
25075 unlock_done:
25076 mutex_unlock(&espfix_init_mutex);
25077diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
25078index d25097c..e2df353 100644
25079--- a/arch/x86/kernel/fpu/core.c
25080+++ b/arch/x86/kernel/fpu/core.c
25081@@ -127,7 +127,7 @@ void __kernel_fpu_end(void)
25082 struct fpu *fpu = &current->thread.fpu;
25083
25084 if (fpu->fpregs_active)
25085- copy_kernel_to_fpregs(&fpu->state);
25086+ copy_kernel_to_fpregs(fpu->state);
25087 else
25088 __fpregs_deactivate_hw();
25089
25090@@ -238,7 +238,7 @@ static void fpu_copy(struct fpu *dst_fpu, struct fpu *src_fpu)
25091 * leak into the child task:
25092 */
25093 if (use_eager_fpu())
25094- memset(&dst_fpu->state.xsave, 0, xstate_size);
25095+ memset(&dst_fpu->state->xsave, 0, xstate_size);
25096
25097 /*
25098 * Save current FPU registers directly into the child
25099@@ -258,7 +258,7 @@ static void fpu_copy(struct fpu *dst_fpu, struct fpu *src_fpu)
25100 */
25101 preempt_disable();
25102 if (!copy_fpregs_to_fpstate(dst_fpu)) {
25103- memcpy(&src_fpu->state, &dst_fpu->state, xstate_size);
25104+ memcpy(src_fpu->state, dst_fpu->state, xstate_size);
25105 fpregs_deactivate(src_fpu);
25106 }
25107 preempt_enable();
25108@@ -285,7 +285,7 @@ void fpu__activate_curr(struct fpu *fpu)
25109 WARN_ON_FPU(fpu != &current->thread.fpu);
25110
25111 if (!fpu->fpstate_active) {
25112- fpstate_init(&fpu->state);
25113+ fpstate_init(fpu->state);
25114
25115 /* Safe to do for the current task: */
25116 fpu->fpstate_active = 1;
25117@@ -311,7 +311,7 @@ void fpu__activate_fpstate_read(struct fpu *fpu)
25118 fpu__save(fpu);
25119 } else {
25120 if (!fpu->fpstate_active) {
25121- fpstate_init(&fpu->state);
25122+ fpstate_init(fpu->state);
25123
25124 /* Safe to do for current and for stopped child tasks: */
25125 fpu->fpstate_active = 1;
25126@@ -344,7 +344,7 @@ void fpu__activate_fpstate_write(struct fpu *fpu)
25127 /* Invalidate any lazy state: */
25128 fpu->last_cpu = -1;
25129 } else {
25130- fpstate_init(&fpu->state);
25131+ fpstate_init(fpu->state);
25132
25133 /* Safe to do for stopped child tasks: */
25134 fpu->fpstate_active = 1;
25135@@ -368,7 +368,7 @@ void fpu__restore(struct fpu *fpu)
25136 /* Avoid __kernel_fpu_begin() right after fpregs_activate() */
25137 kernel_fpu_disable();
25138 fpregs_activate(fpu);
25139- copy_kernel_to_fpregs(&fpu->state);
25140+ copy_kernel_to_fpregs(fpu->state);
25141 fpu->counter++;
25142 kernel_fpu_enable();
25143 }
25144@@ -442,25 +442,25 @@ void fpu__clear(struct fpu *fpu)
25145 static inline unsigned short get_fpu_cwd(struct fpu *fpu)
25146 {
25147 if (cpu_has_fxsr) {
25148- return fpu->state.fxsave.cwd;
25149+ return fpu->state->fxsave.cwd;
25150 } else {
25151- return (unsigned short)fpu->state.fsave.cwd;
25152+ return (unsigned short)fpu->state->fsave.cwd;
25153 }
25154 }
25155
25156 static inline unsigned short get_fpu_swd(struct fpu *fpu)
25157 {
25158 if (cpu_has_fxsr) {
25159- return fpu->state.fxsave.swd;
25160+ return fpu->state->fxsave.swd;
25161 } else {
25162- return (unsigned short)fpu->state.fsave.swd;
25163+ return (unsigned short)fpu->state->fsave.swd;
25164 }
25165 }
25166
25167 static inline unsigned short get_fpu_mxcsr(struct fpu *fpu)
25168 {
25169 if (cpu_has_xmm) {
25170- return fpu->state.fxsave.mxcsr;
25171+ return fpu->state->fxsave.mxcsr;
25172 } else {
25173 return MXCSR_DEFAULT;
25174 }
25175diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
25176index d14e9ac..f1334f8 100644
25177--- a/arch/x86/kernel/fpu/init.c
25178+++ b/arch/x86/kernel/fpu/init.c
25179@@ -42,7 +42,7 @@ static void fpu__init_cpu_generic(void)
25180 /* Flush out any pending x87 state: */
25181 #ifdef CONFIG_MATH_EMULATION
25182 if (!cpu_has_fpu)
25183- fpstate_init_soft(&current->thread.fpu.state.soft);
25184+ fpstate_init_soft(&current->thread.fpu.state->soft);
25185 else
25186 #endif
25187 asm volatile ("fninit");
25188@@ -143,42 +143,7 @@ static void __init fpu__init_system_generic(void)
25189 unsigned int xstate_size;
25190 EXPORT_SYMBOL_GPL(xstate_size);
25191
25192-/* Enforce that 'MEMBER' is the last field of 'TYPE': */
25193-#define CHECK_MEMBER_AT_END_OF(TYPE, MEMBER) \
25194- BUILD_BUG_ON(sizeof(TYPE) != offsetofend(TYPE, MEMBER))
25195-
25196-/*
25197- * We append the 'struct fpu' to the task_struct:
25198- */
25199-static void __init fpu__init_task_struct_size(void)
25200-{
25201- int task_size = sizeof(struct task_struct);
25202-
25203- /*
25204- * Subtract off the static size of the register state.
25205- * It potentially has a bunch of padding.
25206- */
25207- task_size -= sizeof(((struct task_struct *)0)->thread.fpu.state);
25208-
25209- /*
25210- * Add back the dynamically-calculated register state
25211- * size.
25212- */
25213- task_size += xstate_size;
25214-
25215- /*
25216- * We dynamically size 'struct fpu', so we require that
25217- * it be at the end of 'thread_struct' and that
25218- * 'thread_struct' be at the end of 'task_struct'. If
25219- * you hit a compile error here, check the structure to
25220- * see if something got added to the end.
25221- */
25222- CHECK_MEMBER_AT_END_OF(struct fpu, state);
25223- CHECK_MEMBER_AT_END_OF(struct thread_struct, fpu);
25224- CHECK_MEMBER_AT_END_OF(struct task_struct, thread);
25225-
25226- arch_task_struct_size = task_size;
25227-}
25228+union fpregs_state init_fpregs_state;
25229
25230 /*
25231 * Set up the xstate_size based on the legacy FPU context size.
25232@@ -300,6 +265,9 @@ static void __init fpu__init_system_ctx_switch(void)
25233 }
25234 }
25235
25236+ /* XXX: Temporarily forcing eager FPU mode */
25237+ eagerfpu = ENABLE;
25238+
25239 if (eagerfpu == ENABLE)
25240 setup_force_cpu_cap(X86_FEATURE_EAGER_FPU);
25241
25242@@ -331,7 +299,6 @@ void __init fpu__init_system(struct cpuinfo_x86 *c)
25243 fpu__init_system_generic();
25244 fpu__init_system_xstate_size_legacy();
25245 fpu__init_system_xstate();
25246- fpu__init_task_struct_size();
25247
25248 fpu__init_system_ctx_switch();
25249 }
25250diff --git a/arch/x86/kernel/fpu/regset.c b/arch/x86/kernel/fpu/regset.c
25251index dc60810..6c8a1fa 100644
25252--- a/arch/x86/kernel/fpu/regset.c
25253+++ b/arch/x86/kernel/fpu/regset.c
25254@@ -37,7 +37,7 @@ int xfpregs_get(struct task_struct *target, const struct user_regset *regset,
25255 fpstate_sanitize_xstate(fpu);
25256
25257 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
25258- &fpu->state.fxsave, 0, -1);
25259+ &fpu->state->fxsave, 0, -1);
25260 }
25261
25262 int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
25263@@ -54,19 +54,19 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
25264 fpstate_sanitize_xstate(fpu);
25265
25266 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
25267- &fpu->state.fxsave, 0, -1);
25268+ &fpu->state->fxsave, 0, -1);
25269
25270 /*
25271 * mxcsr reserved bits must be masked to zero for security reasons.
25272 */
25273- fpu->state.fxsave.mxcsr &= mxcsr_feature_mask;
25274+ fpu->state->fxsave.mxcsr &= mxcsr_feature_mask;
25275
25276 /*
25277 * update the header bits in the xsave header, indicating the
25278 * presence of FP and SSE state.
25279 */
25280 if (cpu_has_xsave)
25281- fpu->state.xsave.header.xfeatures |= XSTATE_FPSSE;
25282+ fpu->state->xsave.header.xfeatures |= XSTATE_FPSSE;
25283
25284 return ret;
25285 }
25286@@ -84,7 +84,7 @@ int xstateregs_get(struct task_struct *target, const struct user_regset *regset,
25287
25288 fpu__activate_fpstate_read(fpu);
25289
25290- xsave = &fpu->state.xsave;
25291+ xsave = &fpu->state->xsave;
25292
25293 /*
25294 * Copy the 48bytes defined by the software first into the xstate
25295@@ -113,7 +113,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
25296
25297 fpu__activate_fpstate_write(fpu);
25298
25299- xsave = &fpu->state.xsave;
25300+ xsave = &fpu->state->xsave;
25301
25302 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, xsave, 0, -1);
25303 /*
25304@@ -204,7 +204,7 @@ static inline u32 twd_fxsr_to_i387(struct fxregs_state *fxsave)
25305 void
25306 convert_from_fxsr(struct user_i387_ia32_struct *env, struct task_struct *tsk)
25307 {
25308- struct fxregs_state *fxsave = &tsk->thread.fpu.state.fxsave;
25309+ struct fxregs_state *fxsave = &tsk->thread.fpu.state->fxsave;
25310 struct _fpreg *to = (struct _fpreg *) &env->st_space[0];
25311 struct _fpxreg *from = (struct _fpxreg *) &fxsave->st_space[0];
25312 int i;
25313@@ -242,7 +242,7 @@ void convert_to_fxsr(struct task_struct *tsk,
25314 const struct user_i387_ia32_struct *env)
25315
25316 {
25317- struct fxregs_state *fxsave = &tsk->thread.fpu.state.fxsave;
25318+ struct fxregs_state *fxsave = &tsk->thread.fpu.state->fxsave;
25319 struct _fpreg *from = (struct _fpreg *) &env->st_space[0];
25320 struct _fpxreg *to = (struct _fpxreg *) &fxsave->st_space[0];
25321 int i;
25322@@ -280,7 +280,7 @@ int fpregs_get(struct task_struct *target, const struct user_regset *regset,
25323
25324 if (!cpu_has_fxsr)
25325 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
25326- &fpu->state.fsave, 0,
25327+ &fpu->state->fsave, 0,
25328 -1);
25329
25330 fpstate_sanitize_xstate(fpu);
25331@@ -311,7 +311,7 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,
25332
25333 if (!cpu_has_fxsr)
25334 return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
25335- &fpu->state.fsave, 0,
25336+ &fpu->state->fsave, 0,
25337 -1);
25338
25339 if (pos > 0 || count < sizeof(env))
25340@@ -326,7 +326,7 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,
25341 * presence of FP.
25342 */
25343 if (cpu_has_xsave)
25344- fpu->state.xsave.header.xfeatures |= XSTATE_FP;
25345+ fpu->state->xsave.header.xfeatures |= XSTATE_FP;
25346 return ret;
25347 }
25348
25349diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
25350index 50ec9af..bb871ca 100644
25351--- a/arch/x86/kernel/fpu/signal.c
25352+++ b/arch/x86/kernel/fpu/signal.c
25353@@ -54,7 +54,7 @@ static inline int check_for_xstate(struct fxregs_state __user *buf,
25354 static inline int save_fsave_header(struct task_struct *tsk, void __user *buf)
25355 {
25356 if (use_fxsr()) {
25357- struct xregs_state *xsave = &tsk->thread.fpu.state.xsave;
25358+ struct xregs_state *xsave = &tsk->thread.fpu.state->xsave;
25359 struct user_i387_ia32_struct env;
25360 struct _fpstate_ia32 __user *fp = buf;
25361
25362@@ -83,18 +83,18 @@ static inline int save_xstate_epilog(void __user *buf, int ia32_frame)
25363
25364 /* Setup the bytes not touched by the [f]xsave and reserved for SW. */
25365 sw_bytes = ia32_frame ? &fx_sw_reserved_ia32 : &fx_sw_reserved;
25366- err = __copy_to_user(&x->i387.sw_reserved, sw_bytes, sizeof(*sw_bytes));
25367+ err = __copy_to_user(x->i387.sw_reserved, sw_bytes, sizeof(*sw_bytes));
25368
25369 if (!use_xsave())
25370 return err;
25371
25372- err |= __put_user(FP_XSTATE_MAGIC2, (__u32 *)(buf + xstate_size));
25373+ err |= __put_user(FP_XSTATE_MAGIC2, (__u32 __user *)(buf + xstate_size));
25374
25375 /*
25376 * Read the xfeatures which we copied (directly from the cpu or
25377 * from the state in task struct) to the user buffers.
25378 */
25379- err |= __get_user(xfeatures, (__u32 *)&x->header.xfeatures);
25380+ err |= __get_user(xfeatures, (__u32 __user *)&x->header.xfeatures);
25381
25382 /*
25383 * For legacy compatible, we always set FP/SSE bits in the bit
25384@@ -109,7 +109,7 @@ static inline int save_xstate_epilog(void __user *buf, int ia32_frame)
25385 */
25386 xfeatures |= XSTATE_FPSSE;
25387
25388- err |= __put_user(xfeatures, (__u32 *)&x->header.xfeatures);
25389+ err |= __put_user(xfeatures, (__u32 __user *)&x->header.xfeatures);
25390
25391 return err;
25392 }
25393@@ -118,6 +118,7 @@ static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf)
25394 {
25395 int err;
25396
25397+ buf = (struct xregs_state __user *)____m(buf);
25398 if (use_xsave())
25399 err = copy_xregs_to_user(buf);
25400 else if (use_fxsr())
25401@@ -152,7 +153,7 @@ static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf)
25402 */
25403 int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size)
25404 {
25405- struct xregs_state *xsave = &current->thread.fpu.state.xsave;
25406+ struct xregs_state *xsave = &current->thread.fpu.state->xsave;
25407 struct task_struct *tsk = current;
25408 int ia32_fxstate = (buf != buf_fx);
25409
25410@@ -195,7 +196,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
25411 struct user_i387_ia32_struct *ia32_env,
25412 u64 xfeatures, int fx_only)
25413 {
25414- struct xregs_state *xsave = &tsk->thread.fpu.state.xsave;
25415+ struct xregs_state *xsave = &tsk->thread.fpu.state->xsave;
25416 struct xstate_header *header = &xsave->header;
25417
25418 if (use_xsave()) {
25419@@ -228,6 +229,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
25420 */
25421 static inline int copy_user_to_fpregs_zeroing(void __user *buf, u64 xbv, int fx_only)
25422 {
25423+ buf = (void __user *)____m(buf);
25424 if (use_xsave()) {
25425 if ((unsigned long)buf % 64 || fx_only) {
25426 u64 init_bv = xfeatures_mask & ~XSTATE_FPSSE;
25427@@ -308,9 +310,9 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
25428 */
25429 fpu__drop(fpu);
25430
25431- if (__copy_from_user(&fpu->state.xsave, buf_fx, state_size) ||
25432+ if (__copy_from_user(&fpu->state->xsave, buf_fx, state_size) ||
25433 __copy_from_user(&env, buf, sizeof(env))) {
25434- fpstate_init(&fpu->state);
25435+ fpstate_init(fpu->state);
25436 err = -1;
25437 } else {
25438 sanitize_restored_xstate(tsk, &env, xfeatures, fx_only);
25439diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
25440index 62fc001..5ce38be 100644
25441--- a/arch/x86/kernel/fpu/xstate.c
25442+++ b/arch/x86/kernel/fpu/xstate.c
25443@@ -93,14 +93,14 @@ EXPORT_SYMBOL_GPL(cpu_has_xfeatures);
25444 */
25445 void fpstate_sanitize_xstate(struct fpu *fpu)
25446 {
25447- struct fxregs_state *fx = &fpu->state.fxsave;
25448+ struct fxregs_state *fx = &fpu->state->fxsave;
25449 int feature_bit;
25450 u64 xfeatures;
25451
25452 if (!use_xsaveopt())
25453 return;
25454
25455- xfeatures = fpu->state.xsave.header.xfeatures;
25456+ xfeatures = fpu->state->xsave.header.xfeatures;
25457
25458 /*
25459 * None of the feature bits are in init state. So nothing else
25460@@ -402,7 +402,7 @@ void *get_xsave_addr(struct xregs_state *xsave, int xstate_feature)
25461 if (!boot_cpu_has(X86_FEATURE_XSAVE))
25462 return NULL;
25463
25464- xsave = &current->thread.fpu.state.xsave;
25465+ xsave = &current->thread.fpu.state->xsave;
25466 /*
25467 * We should not ever be requesting features that we
25468 * have not enabled. Remember that pcntxt_mask is
25469@@ -457,5 +457,5 @@ const void *get_xsave_field_ptr(int xsave_state)
25470 */
25471 fpu__save(fpu);
25472
25473- return get_xsave_addr(&fpu->state.xsave, xsave_state);
25474+ return get_xsave_addr(&fpu->state->xsave, xsave_state);
25475 }
25476diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
25477index 8b7b0a5..02219db 100644
25478--- a/arch/x86/kernel/ftrace.c
25479+++ b/arch/x86/kernel/ftrace.c
25480@@ -89,7 +89,7 @@ static unsigned long text_ip_addr(unsigned long ip)
25481 * kernel identity mapping to modify code.
25482 */
25483 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
25484- ip = (unsigned long)__va(__pa_symbol(ip));
25485+ ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
25486
25487 return ip;
25488 }
25489@@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
25490 {
25491 unsigned char replaced[MCOUNT_INSN_SIZE];
25492
25493+ ip = ktla_ktva(ip);
25494+
25495 /*
25496 * Note: Due to modules and __init, code can
25497 * disappear and change, we need to protect against faulting
25498@@ -230,7 +232,7 @@ static int update_ftrace_func(unsigned long ip, void *new)
25499 unsigned char old[MCOUNT_INSN_SIZE];
25500 int ret;
25501
25502- memcpy(old, (void *)ip, MCOUNT_INSN_SIZE);
25503+ memcpy(old, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE);
25504
25505 ftrace_update_func = ip;
25506 /* Make sure the breakpoints see the ftrace_update_func update */
25507@@ -311,7 +313,7 @@ static int add_break(unsigned long ip, const char *old)
25508 unsigned char replaced[MCOUNT_INSN_SIZE];
25509 unsigned char brk = BREAKPOINT_INSTRUCTION;
25510
25511- if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
25512+ if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
25513 return -EFAULT;
25514
25515 /* Make sure it is what we expect it to be */
25516@@ -670,11 +672,11 @@ static unsigned char *ftrace_jmp_replace(unsigned long ip, unsigned long addr)
25517 /* Module allocation simplifies allocating memory for code */
25518 static inline void *alloc_tramp(unsigned long size)
25519 {
25520- return module_alloc(size);
25521+ return module_alloc_exec(size);
25522 }
25523 static inline void tramp_free(void *tramp)
25524 {
25525- module_memfree(tramp);
25526+ module_memfree_exec(tramp);
25527 }
25528 #else
25529 /* Trampolines can only be created if modules are supported */
25530@@ -753,7 +755,9 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
25531 *tramp_size = size + MCOUNT_INSN_SIZE + sizeof(void *);
25532
25533 /* Copy ftrace_caller onto the trampoline memory */
25534+ pax_open_kernel();
25535 ret = probe_kernel_read(trampoline, (void *)start_offset, size);
25536+ pax_close_kernel();
25537 if (WARN_ON(ret < 0)) {
25538 tramp_free(trampoline);
25539 return 0;
25540@@ -763,6 +767,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
25541
25542 /* The trampoline ends with a jmp to ftrace_return */
25543 jmp = ftrace_jmp_replace(ip, (unsigned long)ftrace_return);
25544+ pax_open_kernel();
25545 memcpy(trampoline + size, jmp, MCOUNT_INSN_SIZE);
25546
25547 /*
25548@@ -775,6 +780,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
25549
25550 ptr = (unsigned long *)(trampoline + size + MCOUNT_INSN_SIZE);
25551 *ptr = (unsigned long)ops;
25552+ pax_close_kernel();
25553
25554 op_offset -= start_offset;
25555 memcpy(&op_ptr, trampoline + op_offset, OP_REF_SIZE);
25556@@ -792,7 +798,9 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
25557 op_ptr.offset = offset;
25558
25559 /* put in the new offset to the ftrace_ops */
25560+ pax_open_kernel();
25561 memcpy(trampoline + op_offset, &op_ptr, OP_REF_SIZE);
25562+ pax_close_kernel();
25563
25564 /* ALLOC_TRAMP flags lets us know we created it */
25565 ops->flags |= FTRACE_OPS_FL_ALLOC_TRAMP;
25566diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
25567index f129a9a..af8f6da 100644
25568--- a/arch/x86/kernel/head64.c
25569+++ b/arch/x86/kernel/head64.c
25570@@ -68,12 +68,12 @@ again:
25571 pgd = *pgd_p;
25572
25573 /*
25574- * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
25575- * critical -- __PAGE_OFFSET would point us back into the dynamic
25576+ * The use of __early_va rather than __va here is critical:
25577+ * __va would point us back into the dynamic
25578 * range and we might end up looping forever...
25579 */
25580 if (pgd)
25581- pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
25582+ pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
25583 else {
25584 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
25585 reset_early_page_tables();
25586@@ -83,13 +83,13 @@ again:
25587 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
25588 for (i = 0; i < PTRS_PER_PUD; i++)
25589 pud_p[i] = 0;
25590- *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
25591+ *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
25592 }
25593 pud_p += pud_index(address);
25594 pud = *pud_p;
25595
25596 if (pud)
25597- pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
25598+ pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
25599 else {
25600 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
25601 reset_early_page_tables();
25602@@ -99,7 +99,7 @@ again:
25603 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
25604 for (i = 0; i < PTRS_PER_PMD; i++)
25605 pmd_p[i] = 0;
25606- *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
25607+ *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
25608 }
25609 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
25610 pmd_p[pmd_index(address)] = pmd;
25611@@ -163,8 +163,6 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)
25612
25613 clear_bss();
25614
25615- clear_page(init_level4_pgt);
25616-
25617 kasan_early_init();
25618
25619 for (i = 0; i < NUM_EXCEPTION_VECTORS; i++)
25620diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
25621index 0e2d96f..5889003 100644
25622--- a/arch/x86/kernel/head_32.S
25623+++ b/arch/x86/kernel/head_32.S
25624@@ -27,6 +27,12 @@
25625 /* Physical address */
25626 #define pa(X) ((X) - __PAGE_OFFSET)
25627
25628+#ifdef CONFIG_PAX_KERNEXEC
25629+#define ta(X) (X)
25630+#else
25631+#define ta(X) ((X) - __PAGE_OFFSET)
25632+#endif
25633+
25634 /*
25635 * References to members of the new_cpu_data structure.
25636 */
25637@@ -56,11 +62,7 @@
25638 * and small than max_low_pfn, otherwise will waste some page table entries
25639 */
25640
25641-#if PTRS_PER_PMD > 1
25642-#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
25643-#else
25644-#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
25645-#endif
25646+#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
25647
25648 /*
25649 * Number of possible pages in the lowmem region.
25650@@ -86,6 +88,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
25651 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
25652
25653 /*
25654+ * Real beginning of normal "text" segment
25655+ */
25656+ENTRY(stext)
25657+ENTRY(_stext)
25658+
25659+/*
25660 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
25661 * %esi points to the real-mode code as a 32-bit pointer.
25662 * CS and DS must be 4 GB flat segments, but we don't depend on
25663@@ -93,6 +101,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
25664 * can.
25665 */
25666 __HEAD
25667+
25668+#ifdef CONFIG_PAX_KERNEXEC
25669+ jmp startup_32
25670+/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
25671+.fill PAGE_SIZE-5,1,0xcc
25672+#endif
25673+
25674 ENTRY(startup_32)
25675 movl pa(stack_start),%ecx
25676
25677@@ -114,6 +129,66 @@ ENTRY(startup_32)
25678 2:
25679 leal -__PAGE_OFFSET(%ecx),%esp
25680
25681+#ifdef CONFIG_SMP
25682+ movl $pa(cpu_gdt_table),%edi
25683+ movl $__per_cpu_load,%eax
25684+ movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
25685+ rorl $16,%eax
25686+ movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
25687+ movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
25688+ movl $__per_cpu_end - 1,%eax
25689+ subl $__per_cpu_start,%eax
25690+ cmpl $0x100000,%eax
25691+ jb 1f
25692+ shrl $PAGE_SHIFT,%eax
25693+ orb $0x80,GDT_ENTRY_PERCPU * 8 + 6(%edi)
25694+1:
25695+ movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
25696+ shrl $16,%eax
25697+ orb %al,GDT_ENTRY_PERCPU * 8 + 6(%edi)
25698+#endif
25699+
25700+#ifdef CONFIG_PAX_MEMORY_UDEREF
25701+ movl $NR_CPUS,%ecx
25702+ movl $pa(cpu_gdt_table),%edi
25703+1:
25704+ movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
25705+ movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
25706+ movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
25707+ addl $PAGE_SIZE_asm,%edi
25708+ loop 1b
25709+#endif
25710+
25711+#ifdef CONFIG_PAX_KERNEXEC
25712+ movl $pa(boot_gdt),%edi
25713+ movl $__LOAD_PHYSICAL_ADDR,%eax
25714+ movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
25715+ rorl $16,%eax
25716+ movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
25717+ movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
25718+ rorl $16,%eax
25719+
25720+ ljmp $(__BOOT_CS),$1f
25721+1:
25722+
25723+ movl $NR_CPUS,%ecx
25724+ movl $pa(cpu_gdt_table),%edi
25725+ addl $__PAGE_OFFSET,%eax
25726+1:
25727+ movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
25728+ movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
25729+ movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
25730+ movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
25731+ rorl $16,%eax
25732+ movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
25733+ movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
25734+ movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
25735+ movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
25736+ rorl $16,%eax
25737+ addl $PAGE_SIZE_asm,%edi
25738+ loop 1b
25739+#endif
25740+
25741 /*
25742 * Clear BSS first so that there are no surprises...
25743 */
25744@@ -209,8 +284,11 @@ ENTRY(startup_32)
25745 movl %eax, pa(max_pfn_mapped)
25746
25747 /* Do early initialization of the fixmap area */
25748- movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
25749- movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
25750+#ifdef CONFIG_COMPAT_VDSO
25751+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
25752+#else
25753+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
25754+#endif
25755 #else /* Not PAE */
25756
25757 page_pde_offset = (__PAGE_OFFSET >> 20);
25758@@ -240,8 +318,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
25759 movl %eax, pa(max_pfn_mapped)
25760
25761 /* Do early initialization of the fixmap area */
25762- movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
25763- movl %eax,pa(initial_page_table+0xffc)
25764+#ifdef CONFIG_COMPAT_VDSO
25765+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
25766+#else
25767+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
25768+#endif
25769 #endif
25770
25771 #ifdef CONFIG_PARAVIRT
25772@@ -255,9 +336,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
25773 cmpl $num_subarch_entries, %eax
25774 jae bad_subarch
25775
25776- movl pa(subarch_entries)(,%eax,4), %eax
25777- subl $__PAGE_OFFSET, %eax
25778- jmp *%eax
25779+ jmp *pa(subarch_entries)(,%eax,4)
25780
25781 bad_subarch:
25782 WEAK(lguest_entry)
25783@@ -269,10 +348,10 @@ WEAK(xen_entry)
25784 __INITDATA
25785
25786 subarch_entries:
25787- .long default_entry /* normal x86/PC */
25788- .long lguest_entry /* lguest hypervisor */
25789- .long xen_entry /* Xen hypervisor */
25790- .long default_entry /* Moorestown MID */
25791+ .long ta(default_entry) /* normal x86/PC */
25792+ .long ta(lguest_entry) /* lguest hypervisor */
25793+ .long ta(xen_entry) /* Xen hypervisor */
25794+ .long ta(default_entry) /* Moorestown MID */
25795 num_subarch_entries = (. - subarch_entries) / 4
25796 .previous
25797 #else
25798@@ -362,6 +441,7 @@ default_entry:
25799 movl pa(mmu_cr4_features),%eax
25800 movl %eax,%cr4
25801
25802+#ifdef CONFIG_X86_PAE
25803 testb $X86_CR4_PAE, %al # check if PAE is enabled
25804 jz enable_paging
25805
25806@@ -390,6 +470,9 @@ default_entry:
25807 /* Make changes effective */
25808 wrmsr
25809
25810+ btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
25811+#endif
25812+
25813 enable_paging:
25814
25815 /*
25816@@ -457,14 +540,20 @@ is486:
25817 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
25818 movl %eax,%ss # after changing gdt.
25819
25820- movl $(__USER_DS),%eax # DS/ES contains default USER segment
25821+# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
25822 movl %eax,%ds
25823 movl %eax,%es
25824
25825 movl $(__KERNEL_PERCPU), %eax
25826 movl %eax,%fs # set this cpu's percpu
25827
25828+#ifdef CONFIG_CC_STACKPROTECTOR
25829 movl $(__KERNEL_STACK_CANARY),%eax
25830+#elif defined(CONFIG_PAX_MEMORY_UDEREF)
25831+ movl $(__USER_DS),%eax
25832+#else
25833+ xorl %eax,%eax
25834+#endif
25835 movl %eax,%gs
25836
25837 xorl %eax,%eax # Clear LDT
25838@@ -521,8 +610,11 @@ setup_once:
25839 * relocation. Manually set base address in stack canary
25840 * segment descriptor.
25841 */
25842- movl $gdt_page,%eax
25843+ movl $cpu_gdt_table,%eax
25844 movl $stack_canary,%ecx
25845+#ifdef CONFIG_SMP
25846+ addl $__per_cpu_load,%ecx
25847+#endif
25848 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
25849 shrl $16, %ecx
25850 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
25851@@ -559,7 +651,7 @@ early_idt_handler_common:
25852 cmpl $2,(%esp) # X86_TRAP_NMI
25853 je .Lis_nmi # Ignore NMI
25854
25855- cmpl $2,%ss:early_recursion_flag
25856+ cmpl $1,%ss:early_recursion_flag
25857 je hlt_loop
25858 incl %ss:early_recursion_flag
25859
25860@@ -597,8 +689,8 @@ early_idt_handler_common:
25861 pushl (20+6*4)(%esp) /* trapno */
25862 pushl $fault_msg
25863 call printk
25864-#endif
25865 call dump_stack
25866+#endif
25867 hlt_loop:
25868 hlt
25869 jmp hlt_loop
25870@@ -618,8 +710,11 @@ ENDPROC(early_idt_handler_common)
25871 /* This is the default interrupt "handler" :-) */
25872 ALIGN
25873 ignore_int:
25874- cld
25875 #ifdef CONFIG_PRINTK
25876+ cmpl $2,%ss:early_recursion_flag
25877+ je hlt_loop
25878+ incl %ss:early_recursion_flag
25879+ cld
25880 pushl %eax
25881 pushl %ecx
25882 pushl %edx
25883@@ -628,9 +723,6 @@ ignore_int:
25884 movl $(__KERNEL_DS),%eax
25885 movl %eax,%ds
25886 movl %eax,%es
25887- cmpl $2,early_recursion_flag
25888- je hlt_loop
25889- incl early_recursion_flag
25890 pushl 16(%esp)
25891 pushl 24(%esp)
25892 pushl 32(%esp)
25893@@ -664,29 +756,34 @@ ENTRY(setup_once_ref)
25894 /*
25895 * BSS section
25896 */
25897-__PAGE_ALIGNED_BSS
25898- .align PAGE_SIZE
25899 #ifdef CONFIG_X86_PAE
25900+.section .initial_pg_pmd,"a",@progbits
25901 initial_pg_pmd:
25902 .fill 1024*KPMDS,4,0
25903 #else
25904+.section .initial_page_table,"a",@progbits
25905 ENTRY(initial_page_table)
25906 .fill 1024,4,0
25907 #endif
25908+.section .initial_pg_fixmap,"a",@progbits
25909 initial_pg_fixmap:
25910 .fill 1024,4,0
25911+.section .empty_zero_page,"a",@progbits
25912 ENTRY(empty_zero_page)
25913 .fill 4096,1,0
25914+.section .swapper_pg_dir,"a",@progbits
25915 ENTRY(swapper_pg_dir)
25916+#ifdef CONFIG_X86_PAE
25917+ .fill 4,8,0
25918+#else
25919 .fill 1024,4,0
25920+#endif
25921
25922 /*
25923 * This starts the data section.
25924 */
25925 #ifdef CONFIG_X86_PAE
25926-__PAGE_ALIGNED_DATA
25927- /* Page-aligned for the benefit of paravirt? */
25928- .align PAGE_SIZE
25929+.section .initial_page_table,"a",@progbits
25930 ENTRY(initial_page_table)
25931 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
25932 # if KPMDS == 3
25933@@ -705,12 +802,20 @@ ENTRY(initial_page_table)
25934 # error "Kernel PMDs should be 1, 2 or 3"
25935 # endif
25936 .align PAGE_SIZE /* needs to be page-sized too */
25937+
25938+#ifdef CONFIG_PAX_PER_CPU_PGD
25939+ENTRY(cpu_pgd)
25940+ .rept 2*NR_CPUS
25941+ .fill 4,8,0
25942+ .endr
25943+#endif
25944+
25945 #endif
25946
25947 .data
25948 .balign 4
25949 ENTRY(stack_start)
25950- .long init_thread_union+THREAD_SIZE
25951+ .long init_thread_union+THREAD_SIZE-8
25952
25953 __INITRODATA
25954 int_msg:
25955@@ -738,7 +843,7 @@ fault_msg:
25956 * segment size, and 32-bit linear address value:
25957 */
25958
25959- .data
25960+.section .rodata,"a",@progbits
25961 .globl boot_gdt_descr
25962 .globl idt_descr
25963
25964@@ -747,7 +852,7 @@ fault_msg:
25965 .word 0 # 32 bit align gdt_desc.address
25966 boot_gdt_descr:
25967 .word __BOOT_DS+7
25968- .long boot_gdt - __PAGE_OFFSET
25969+ .long pa(boot_gdt)
25970
25971 .word 0 # 32-bit align idt_desc.address
25972 idt_descr:
25973@@ -758,7 +863,7 @@ idt_descr:
25974 .word 0 # 32 bit align gdt_desc.address
25975 ENTRY(early_gdt_descr)
25976 .word GDT_ENTRIES*8-1
25977- .long gdt_page /* Overwritten for secondary CPUs */
25978+ .long cpu_gdt_table /* Overwritten for secondary CPUs */
25979
25980 /*
25981 * The boot_gdt must mirror the equivalent in setup.S and is
25982@@ -767,5 +872,65 @@ ENTRY(early_gdt_descr)
25983 .align L1_CACHE_BYTES
25984 ENTRY(boot_gdt)
25985 .fill GDT_ENTRY_BOOT_CS,8,0
25986- .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
25987- .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
25988+ .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
25989+ .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
25990+
25991+ .align PAGE_SIZE_asm
25992+ENTRY(cpu_gdt_table)
25993+ .rept NR_CPUS
25994+ .quad 0x0000000000000000 /* NULL descriptor */
25995+ .quad 0x0000000000000000 /* 0x0b reserved */
25996+ .quad 0x0000000000000000 /* 0x13 reserved */
25997+ .quad 0x0000000000000000 /* 0x1b reserved */
25998+
25999+#ifdef CONFIG_PAX_KERNEXEC
26000+ .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
26001+#else
26002+ .quad 0x0000000000000000 /* 0x20 unused */
26003+#endif
26004+
26005+ .quad 0x0000000000000000 /* 0x28 unused */
26006+ .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
26007+ .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
26008+ .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
26009+ .quad 0x0000000000000000 /* 0x4b reserved */
26010+ .quad 0x0000000000000000 /* 0x53 reserved */
26011+ .quad 0x0000000000000000 /* 0x5b reserved */
26012+
26013+ .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
26014+ .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
26015+ .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
26016+ .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
26017+
26018+ .quad 0x0000000000000000 /* 0x80 TSS descriptor */
26019+ .quad 0x0000000000000000 /* 0x88 LDT descriptor */
26020+
26021+ /*
26022+ * Segments used for calling PnP BIOS have byte granularity.
26023+ * The code segments and data segments have fixed 64k limits,
26024+ * the transfer segment sizes are set at run time.
26025+ */
26026+ .quad 0x00409b000000ffff /* 0x90 32-bit code */
26027+ .quad 0x00009b000000ffff /* 0x98 16-bit code */
26028+ .quad 0x000093000000ffff /* 0xa0 16-bit data */
26029+ .quad 0x0000930000000000 /* 0xa8 16-bit data */
26030+ .quad 0x0000930000000000 /* 0xb0 16-bit data */
26031+
26032+ /*
26033+ * The APM segments have byte granularity and their bases
26034+ * are set at run time. All have 64k limits.
26035+ */
26036+ .quad 0x00409b000000ffff /* 0xb8 APM CS code */
26037+ .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
26038+ .quad 0x004093000000ffff /* 0xc8 APM DS data */
26039+
26040+ .quad 0x00c093000000ffff /* 0xd0 - ESPFIX SS */
26041+ .quad 0x0040930000000000 /* 0xd8 - PERCPU */
26042+ .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
26043+ .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
26044+ .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
26045+ .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
26046+
26047+ /* Be sure this is zeroed to avoid false validations in Xen */
26048+ .fill PAGE_SIZE_asm - GDT_SIZE,1,0
26049+ .endr
26050diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
26051index 1d40ca8..4d38dbd 100644
26052--- a/arch/x86/kernel/head_64.S
26053+++ b/arch/x86/kernel/head_64.S
26054@@ -20,6 +20,8 @@
26055 #include <asm/processor-flags.h>
26056 #include <asm/percpu.h>
26057 #include <asm/nops.h>
26058+#include <asm/cpufeature.h>
26059+#include <asm/alternative-asm.h>
26060
26061 #ifdef CONFIG_PARAVIRT
26062 #include <asm/asm-offsets.h>
26063@@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
26064 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
26065 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
26066 L3_START_KERNEL = pud_index(__START_KERNEL_map)
26067+L4_VMALLOC_START = pgd_index(VMALLOC_START)
26068+L3_VMALLOC_START = pud_index(VMALLOC_START)
26069+L4_VMALLOC_END = pgd_index(VMALLOC_END)
26070+L3_VMALLOC_END = pud_index(VMALLOC_END)
26071+L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
26072+L3_VMEMMAP_START = pud_index(VMEMMAP_START)
26073
26074 .text
26075 __HEAD
26076@@ -89,11 +97,33 @@ startup_64:
26077 * Fixup the physical addresses in the page table
26078 */
26079 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
26080+ addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
26081+ addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
26082+ addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
26083+ addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
26084+ addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
26085
26086- addq %rbp, level3_kernel_pgt + (510*8)(%rip)
26087- addq %rbp, level3_kernel_pgt + (511*8)(%rip)
26088+ addq %rbp, level3_ident_pgt + (0*8)(%rip)
26089+#ifndef CONFIG_XEN
26090+ addq %rbp, level3_ident_pgt + (1*8)(%rip)
26091+#endif
26092
26093+ addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
26094+
26095+ addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
26096+ addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
26097+
26098+ addq %rbp, level2_ident_pgt + (0*8)(%rip)
26099+
26100+ addq %rbp, level2_fixmap_pgt + (0*8)(%rip)
26101+ addq %rbp, level2_fixmap_pgt + (1*8)(%rip)
26102+ addq %rbp, level2_fixmap_pgt + (2*8)(%rip)
26103+ addq %rbp, level2_fixmap_pgt + (3*8)(%rip)
26104+
26105+ addq %rbp, level2_fixmap_pgt + (504*8)(%rip)
26106+ addq %rbp, level2_fixmap_pgt + (505*8)(%rip)
26107 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
26108+ addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
26109
26110 /*
26111 * Set up the identity mapping for the switchover. These
26112@@ -174,11 +204,12 @@ ENTRY(secondary_startup_64)
26113 * after the boot processor executes this code.
26114 */
26115
26116+ orq $-1, %rbp
26117 movq $(init_level4_pgt - __START_KERNEL_map), %rax
26118 1:
26119
26120- /* Enable PAE mode and PGE */
26121- movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
26122+ /* Enable PAE mode and PSE/PGE */
26123+ movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
26124 movq %rcx, %cr4
26125
26126 /* Setup early boot stage 4 level pagetables. */
26127@@ -199,10 +230,21 @@ ENTRY(secondary_startup_64)
26128 movl $MSR_EFER, %ecx
26129 rdmsr
26130 btsl $_EFER_SCE, %eax /* Enable System Call */
26131- btl $20,%edi /* No Execute supported? */
26132+ btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
26133 jnc 1f
26134 btsl $_EFER_NX, %eax
26135+ cmpq $-1, %rbp
26136+ je 1f
26137 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
26138+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
26139+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
26140+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
26141+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
26142+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*504(%rip)
26143+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*505(%rip)
26144+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
26145+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
26146+ btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
26147 1: wrmsr /* Make changes effective */
26148
26149 /* Setup cr0 */
26150@@ -282,6 +324,7 @@ ENTRY(secondary_startup_64)
26151 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
26152 * address given in m16:64.
26153 */
26154+ pax_set_fptr_mask
26155 movq initial_code(%rip),%rax
26156 pushq $0 # fake return address to stop unwinder
26157 pushq $__KERNEL_CS # set correct cs
26158@@ -313,7 +356,7 @@ ENDPROC(start_cpu0)
26159 .quad INIT_PER_CPU_VAR(irq_stack_union)
26160
26161 GLOBAL(stack_start)
26162- .quad init_thread_union+THREAD_SIZE-8
26163+ .quad init_thread_union+THREAD_SIZE-16
26164 .word 0
26165 __FINITDATA
26166
26167@@ -393,7 +436,7 @@ early_idt_handler_common:
26168 call dump_stack
26169 #ifdef CONFIG_KALLSYMS
26170 leaq early_idt_ripmsg(%rip),%rdi
26171- movq 40(%rsp),%rsi # %rip again
26172+ movq 88(%rsp),%rsi # %rip again
26173 call __print_symbol
26174 #endif
26175 #endif /* EARLY_PRINTK */
26176@@ -422,6 +465,7 @@ ENDPROC(early_idt_handler_common)
26177 early_recursion_flag:
26178 .long 0
26179
26180+ .section .rodata,"a",@progbits
26181 #ifdef CONFIG_EARLY_PRINTK
26182 early_idt_msg:
26183 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
26184@@ -444,40 +488,67 @@ GLOBAL(name)
26185 __INITDATA
26186 NEXT_PAGE(early_level4_pgt)
26187 .fill 511,8,0
26188- .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
26189+ .quad level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
26190
26191 NEXT_PAGE(early_dynamic_pgts)
26192 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
26193
26194- .data
26195+ .section .rodata,"a",@progbits
26196
26197-#ifndef CONFIG_XEN
26198 NEXT_PAGE(init_level4_pgt)
26199- .fill 512,8,0
26200-#else
26201-NEXT_PAGE(init_level4_pgt)
26202- .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
26203 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
26204 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
26205+ .org init_level4_pgt + L4_VMALLOC_START*8, 0
26206+ .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
26207+ .org init_level4_pgt + L4_VMALLOC_END*8, 0
26208+ .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
26209+ .org init_level4_pgt + L4_VMEMMAP_START*8, 0
26210+ .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
26211 .org init_level4_pgt + L4_START_KERNEL*8, 0
26212 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
26213- .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
26214+ .quad level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
26215+
26216+#ifdef CONFIG_PAX_PER_CPU_PGD
26217+NEXT_PAGE(cpu_pgd)
26218+ .rept 2*NR_CPUS
26219+ .fill 512,8,0
26220+ .endr
26221+#endif
26222
26223 NEXT_PAGE(level3_ident_pgt)
26224 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
26225+#ifdef CONFIG_XEN
26226 .fill 511, 8, 0
26227+#else
26228+ .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
26229+ .fill 510,8,0
26230+#endif
26231+
26232+NEXT_PAGE(level3_vmalloc_start_pgt)
26233+ .fill 512,8,0
26234+
26235+NEXT_PAGE(level3_vmalloc_end_pgt)
26236+ .fill 512,8,0
26237+
26238+NEXT_PAGE(level3_vmemmap_pgt)
26239+ .fill L3_VMEMMAP_START,8,0
26240+ .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
26241+
26242 NEXT_PAGE(level2_ident_pgt)
26243- /* Since I easily can, map the first 1G.
26244+ .quad level1_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
26245+ /* Since I easily can, map the first 2G.
26246 * Don't set NX because code runs from these pages.
26247 */
26248- PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
26249-#endif
26250+ PMDS(PMD_SIZE, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD - 1)
26251
26252 NEXT_PAGE(level3_kernel_pgt)
26253 .fill L3_START_KERNEL,8,0
26254 /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */
26255 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
26256- .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
26257+ .quad level2_fixmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
26258+
26259+NEXT_PAGE(level2_vmemmap_pgt)
26260+ .fill 512,8,0
26261
26262 NEXT_PAGE(level2_kernel_pgt)
26263 /*
26264@@ -494,31 +565,79 @@ NEXT_PAGE(level2_kernel_pgt)
26265 KERNEL_IMAGE_SIZE/PMD_SIZE)
26266
26267 NEXT_PAGE(level2_fixmap_pgt)
26268- .fill 506,8,0
26269- .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
26270- /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
26271- .fill 5,8,0
26272+ .quad level1_modules_pgt - __START_KERNEL_map + 0 * PAGE_SIZE + _KERNPG_TABLE
26273+ .quad level1_modules_pgt - __START_KERNEL_map + 1 * PAGE_SIZE + _KERNPG_TABLE
26274+ .quad level1_modules_pgt - __START_KERNEL_map + 2 * PAGE_SIZE + _KERNPG_TABLE
26275+ .quad level1_modules_pgt - __START_KERNEL_map + 3 * PAGE_SIZE + _KERNPG_TABLE
26276+ .fill 500,8,0
26277+ .quad level1_fixmap_pgt - __START_KERNEL_map + 0 * PAGE_SIZE + _KERNPG_TABLE
26278+ .quad level1_fixmap_pgt - __START_KERNEL_map + 1 * PAGE_SIZE + _KERNPG_TABLE
26279+ .quad level1_fixmap_pgt - __START_KERNEL_map + 2 * PAGE_SIZE + _KERNPG_TABLE
26280+ .quad level1_vsyscall_pgt - __START_KERNEL_map + _KERNPG_TABLE
26281+ /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
26282+ .fill 4,8,0
26283+
26284+NEXT_PAGE(level1_ident_pgt)
26285+ .fill 512,8,0
26286+
26287+NEXT_PAGE(level1_modules_pgt)
26288+ .fill 4*512,8,0
26289
26290 NEXT_PAGE(level1_fixmap_pgt)
26291+ .fill 3*512,8,0
26292+
26293+NEXT_PAGE(level1_vsyscall_pgt)
26294 .fill 512,8,0
26295
26296 #undef PMDS
26297
26298- .data
26299+ .align PAGE_SIZE
26300+ENTRY(cpu_gdt_table)
26301+ .rept NR_CPUS
26302+ .quad 0x0000000000000000 /* NULL descriptor */
26303+ .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
26304+ .quad 0x00af9b000000ffff /* __KERNEL_CS */
26305+ .quad 0x00cf93000000ffff /* __KERNEL_DS */
26306+ .quad 0x00cffb000000ffff /* __USER32_CS */
26307+ .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
26308+ .quad 0x00affb000000ffff /* __USER_CS */
26309+
26310+#ifdef CONFIG_PAX_KERNEXEC
26311+ .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
26312+#else
26313+ .quad 0x0 /* unused */
26314+#endif
26315+
26316+ .quad 0,0 /* TSS */
26317+ .quad 0,0 /* LDT */
26318+ .quad 0,0,0 /* three TLS descriptors */
26319+ .quad 0x0000f40000000000 /* node/CPU stored in limit */
26320+ /* asm/segment.h:GDT_ENTRIES must match this */
26321+
26322+#ifdef CONFIG_PAX_MEMORY_UDEREF
26323+ .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
26324+#else
26325+ .quad 0x0 /* unused */
26326+#endif
26327+
26328+ /* zero the remaining page */
26329+ .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
26330+ .endr
26331+
26332 .align 16
26333 .globl early_gdt_descr
26334 early_gdt_descr:
26335 .word GDT_ENTRIES*8-1
26336 early_gdt_descr_base:
26337- .quad INIT_PER_CPU_VAR(gdt_page)
26338+ .quad cpu_gdt_table
26339
26340 ENTRY(phys_base)
26341 /* This must match the first entry in level2_kernel_pgt */
26342 .quad 0x0000000000000000
26343
26344 #include "../../x86/xen/xen-head.S"
26345-
26346- __PAGE_ALIGNED_BSS
26347+
26348+ .section .rodata,"a",@progbits
26349 NEXT_PAGE(empty_zero_page)
26350 .skip PAGE_SIZE
26351
26352diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
26353index 64341aa..b1e6632 100644
26354--- a/arch/x86/kernel/i386_ksyms_32.c
26355+++ b/arch/x86/kernel/i386_ksyms_32.c
26356@@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
26357 EXPORT_SYMBOL(cmpxchg8b_emu);
26358 #endif
26359
26360+EXPORT_SYMBOL_GPL(cpu_gdt_table);
26361+
26362 /* Networking helper routines. */
26363 EXPORT_SYMBOL(csum_partial_copy_generic);
26364+EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
26365+EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
26366
26367 EXPORT_SYMBOL(__get_user_1);
26368 EXPORT_SYMBOL(__get_user_2);
26369@@ -42,3 +46,11 @@ EXPORT_SYMBOL(empty_zero_page);
26370 EXPORT_SYMBOL(___preempt_schedule);
26371 EXPORT_SYMBOL(___preempt_schedule_notrace);
26372 #endif
26373+
26374+#ifdef CONFIG_PAX_KERNEXEC
26375+EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
26376+#endif
26377+
26378+#ifdef CONFIG_PAX_PER_CPU_PGD
26379+EXPORT_SYMBOL(cpu_pgd);
26380+#endif
26381diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
26382index 16cb827..372334f 100644
26383--- a/arch/x86/kernel/i8259.c
26384+++ b/arch/x86/kernel/i8259.c
26385@@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
26386 static void make_8259A_irq(unsigned int irq)
26387 {
26388 disable_irq_nosync(irq);
26389- io_apic_irqs &= ~(1<<irq);
26390+ io_apic_irqs &= ~(1UL<<irq);
26391 irq_set_chip_and_handler(irq, &i8259A_chip, handle_level_irq);
26392 enable_irq(irq);
26393 }
26394@@ -208,7 +208,7 @@ spurious_8259A_irq:
26395 "spurious 8259A interrupt: IRQ%d.\n", irq);
26396 spurious_irq_mask |= irqmask;
26397 }
26398- atomic_inc(&irq_err_count);
26399+ atomic_inc_unchecked(&irq_err_count);
26400 /*
26401 * Theoretically we do not have to handle this IRQ,
26402 * but in Linux this does not cause problems and is
26403@@ -349,14 +349,16 @@ static void init_8259A(int auto_eoi)
26404 /* (slave's support for AEOI in flat mode is to be investigated) */
26405 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
26406
26407+ pax_open_kernel();
26408 if (auto_eoi)
26409 /*
26410 * In AEOI mode we just have to mask the interrupt
26411 * when acking.
26412 */
26413- i8259A_chip.irq_mask_ack = disable_8259A_irq;
26414+ *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
26415 else
26416- i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
26417+ *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
26418+ pax_close_kernel();
26419
26420 udelay(100); /* wait for 8259A to initialize */
26421
26422diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
26423index a979b5b..1d6db75 100644
26424--- a/arch/x86/kernel/io_delay.c
26425+++ b/arch/x86/kernel/io_delay.c
26426@@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
26427 * Quirk table for systems that misbehave (lock up, etc.) if port
26428 * 0x80 is used:
26429 */
26430-static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
26431+static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
26432 {
26433 .callback = dmi_io_delay_0xed_port,
26434 .ident = "Compaq Presario V6000",
26435diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
26436index 37dae79..620dd84 100644
26437--- a/arch/x86/kernel/ioport.c
26438+++ b/arch/x86/kernel/ioport.c
26439@@ -6,6 +6,7 @@
26440 #include <linux/sched.h>
26441 #include <linux/kernel.h>
26442 #include <linux/capability.h>
26443+#include <linux/security.h>
26444 #include <linux/errno.h>
26445 #include <linux/types.h>
26446 #include <linux/ioport.h>
26447@@ -30,6 +31,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
26448 return -EINVAL;
26449 if (turn_on && !capable(CAP_SYS_RAWIO))
26450 return -EPERM;
26451+#ifdef CONFIG_GRKERNSEC_IO
26452+ if (turn_on && grsec_disable_privio) {
26453+ gr_handle_ioperm();
26454+ return -ENODEV;
26455+ }
26456+#endif
26457
26458 /*
26459 * If it's the first ioperm() call in this thread's lifetime, set the
26460@@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
26461 * because the ->io_bitmap_max value must match the bitmap
26462 * contents:
26463 */
26464- tss = &per_cpu(cpu_tss, get_cpu());
26465+ tss = cpu_tss + get_cpu();
26466
26467 if (turn_on)
26468 bitmap_clear(t->io_bitmap_ptr, from, num);
26469@@ -105,6 +112,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
26470 if (level > old) {
26471 if (!capable(CAP_SYS_RAWIO))
26472 return -EPERM;
26473+#ifdef CONFIG_GRKERNSEC_IO
26474+ if (grsec_disable_privio) {
26475+ gr_handle_iopl();
26476+ return -ENODEV;
26477+ }
26478+#endif
26479 }
26480 regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
26481 t->iopl = level << 12;
26482diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
26483index c7dfe1b..146f63c 100644
26484--- a/arch/x86/kernel/irq.c
26485+++ b/arch/x86/kernel/irq.c
26486@@ -28,7 +28,7 @@ EXPORT_PER_CPU_SYMBOL(irq_stat);
26487 DEFINE_PER_CPU(struct pt_regs *, irq_regs);
26488 EXPORT_PER_CPU_SYMBOL(irq_regs);
26489
26490-atomic_t irq_err_count;
26491+atomic_unchecked_t irq_err_count;
26492
26493 /* Function pointer for generic interrupt vector handling */
26494 void (*x86_platform_ipi_callback)(void) = NULL;
26495@@ -144,9 +144,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
26496 seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count);
26497 seq_puts(p, " Hypervisor callback interrupts\n");
26498 #endif
26499- seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
26500+ seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
26501 #if defined(CONFIG_X86_IO_APIC)
26502- seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
26503+ seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
26504 #endif
26505 #ifdef CONFIG_HAVE_KVM
26506 seq_printf(p, "%*s: ", prec, "PIN");
26507@@ -198,7 +198,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
26508
26509 u64 arch_irq_stat(void)
26510 {
26511- u64 sum = atomic_read(&irq_err_count);
26512+ u64 sum = atomic_read_unchecked(&irq_err_count);
26513 return sum;
26514 }
26515
26516diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
26517index cd74f59..588af0b 100644
26518--- a/arch/x86/kernel/irq_32.c
26519+++ b/arch/x86/kernel/irq_32.c
26520@@ -23,6 +23,8 @@
26521
26522 #ifdef CONFIG_DEBUG_STACKOVERFLOW
26523
26524+extern void gr_handle_kernel_exploit(void);
26525+
26526 int sysctl_panic_on_stackoverflow __read_mostly;
26527
26528 /* Debugging check for stack overflow: is there less than 1KB free? */
26529@@ -33,13 +35,14 @@ static int check_stack_overflow(void)
26530 __asm__ __volatile__("andl %%esp,%0" :
26531 "=r" (sp) : "0" (THREAD_SIZE - 1));
26532
26533- return sp < (sizeof(struct thread_info) + STACK_WARN);
26534+ return sp < STACK_WARN;
26535 }
26536
26537 static void print_stack_overflow(void)
26538 {
26539 printk(KERN_WARNING "low stack detected by irq handler\n");
26540 dump_stack();
26541+ gr_handle_kernel_exploit();
26542 if (sysctl_panic_on_stackoverflow)
26543 panic("low stack detected by irq handler - check messages\n");
26544 }
26545@@ -71,10 +74,9 @@ static inline void *current_stack(void)
26546 static inline int
26547 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
26548 {
26549- struct irq_stack *curstk, *irqstk;
26550+ struct irq_stack *irqstk;
26551 u32 *isp, *prev_esp, arg1, arg2;
26552
26553- curstk = (struct irq_stack *) current_stack();
26554 irqstk = __this_cpu_read(hardirq_stack);
26555
26556 /*
26557@@ -83,15 +85,19 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
26558 * handler) we can't do that and just have to keep using the
26559 * current stack (which is the irq stack already after all)
26560 */
26561- if (unlikely(curstk == irqstk))
26562+ if (unlikely((void *)current_stack_pointer - (void *)irqstk < THREAD_SIZE))
26563 return 0;
26564
26565- isp = (u32 *) ((char *)irqstk + sizeof(*irqstk));
26566+ isp = (u32 *) ((char *)irqstk + sizeof(*irqstk) - 8);
26567
26568 /* Save the next esp at the bottom of the stack */
26569 prev_esp = (u32 *)irqstk;
26570 *prev_esp = current_stack_pointer();
26571
26572+#ifdef CONFIG_PAX_MEMORY_UDEREF
26573+ __set_fs(MAKE_MM_SEG(0));
26574+#endif
26575+
26576 if (unlikely(overflow))
26577 call_on_stack(print_stack_overflow, isp);
26578
26579@@ -102,6 +108,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
26580 : "0" (irq), "1" (desc), "2" (isp),
26581 "D" (desc->handle_irq)
26582 : "memory", "cc", "ecx");
26583+
26584+#ifdef CONFIG_PAX_MEMORY_UDEREF
26585+ __set_fs(current_thread_info()->addr_limit);
26586+#endif
26587+
26588 return 1;
26589 }
26590
26591@@ -110,32 +121,18 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
26592 */
26593 void irq_ctx_init(int cpu)
26594 {
26595- struct irq_stack *irqstk;
26596-
26597 if (per_cpu(hardirq_stack, cpu))
26598 return;
26599
26600- irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
26601- THREADINFO_GFP,
26602- THREAD_SIZE_ORDER));
26603- per_cpu(hardirq_stack, cpu) = irqstk;
26604-
26605- irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
26606- THREADINFO_GFP,
26607- THREAD_SIZE_ORDER));
26608- per_cpu(softirq_stack, cpu) = irqstk;
26609-
26610- printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
26611- cpu, per_cpu(hardirq_stack, cpu), per_cpu(softirq_stack, cpu));
26612+ per_cpu(hardirq_stack, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
26613+ per_cpu(softirq_stack, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
26614 }
26615
26616 void do_softirq_own_stack(void)
26617 {
26618- struct thread_info *curstk;
26619 struct irq_stack *irqstk;
26620 u32 *isp, *prev_esp;
26621
26622- curstk = current_stack();
26623 irqstk = __this_cpu_read(softirq_stack);
26624
26625 /* build the stack frame on the softirq stack */
26626@@ -145,7 +142,16 @@ void do_softirq_own_stack(void)
26627 prev_esp = (u32 *)irqstk;
26628 *prev_esp = current_stack_pointer();
26629
26630+#ifdef CONFIG_PAX_MEMORY_UDEREF
26631+ __set_fs(MAKE_MM_SEG(0));
26632+#endif
26633+
26634 call_on_stack(__do_softirq, isp);
26635+
26636+#ifdef CONFIG_PAX_MEMORY_UDEREF
26637+ __set_fs(current_thread_info()->addr_limit);
26638+#endif
26639+
26640 }
26641
26642 bool handle_irq(unsigned irq, struct pt_regs *regs)
26643diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
26644index bc4604e..0be227d 100644
26645--- a/arch/x86/kernel/irq_64.c
26646+++ b/arch/x86/kernel/irq_64.c
26647@@ -20,6 +20,8 @@
26648 #include <asm/idle.h>
26649 #include <asm/apic.h>
26650
26651+extern void gr_handle_kernel_exploit(void);
26652+
26653 int sysctl_panic_on_stackoverflow;
26654
26655 /*
26656@@ -63,6 +65,8 @@ static inline void stack_overflow_check(struct pt_regs *regs)
26657 irq_stack_top, irq_stack_bottom,
26658 estack_top, estack_bottom);
26659
26660+ gr_handle_kernel_exploit();
26661+
26662 if (sysctl_panic_on_stackoverflow)
26663 panic("low stack detected by irq handler - check messages\n");
26664 #endif
26665diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
26666index 26d5a55..063fef8 100644
26667--- a/arch/x86/kernel/jump_label.c
26668+++ b/arch/x86/kernel/jump_label.c
26669@@ -31,6 +31,8 @@ static void bug_at(unsigned char *ip, int line)
26670 * Something went wrong. Crash the box, as something could be
26671 * corrupting the kernel.
26672 */
26673+ ip = (unsigned char *)ktla_ktva((unsigned long)ip);
26674+ pr_warning("Unexpected op at %pS [%p] %s:%d\n", ip, ip, __FILE__, line);
26675 pr_warning("Unexpected op at %pS [%p] (%02x %02x %02x %02x %02x) %s:%d\n",
26676 ip, ip, ip[0], ip[1], ip[2], ip[3], ip[4], __FILE__, line);
26677 BUG();
26678@@ -51,7 +53,7 @@ static void __jump_label_transform(struct jump_entry *entry,
26679 * Jump label is enabled for the first time.
26680 * So we expect a default_nop...
26681 */
26682- if (unlikely(memcmp((void *)entry->code, default_nop, 5)
26683+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5)
26684 != 0))
26685 bug_at((void *)entry->code, __LINE__);
26686 } else {
26687@@ -59,7 +61,7 @@ static void __jump_label_transform(struct jump_entry *entry,
26688 * ...otherwise expect an ideal_nop. Otherwise
26689 * something went horribly wrong.
26690 */
26691- if (unlikely(memcmp((void *)entry->code, ideal_nop, 5)
26692+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5)
26693 != 0))
26694 bug_at((void *)entry->code, __LINE__);
26695 }
26696@@ -75,13 +77,13 @@ static void __jump_label_transform(struct jump_entry *entry,
26697 * are converting the default nop to the ideal nop.
26698 */
26699 if (init) {
26700- if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
26701+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
26702 bug_at((void *)entry->code, __LINE__);
26703 } else {
26704 code.jump = 0xe9;
26705 code.offset = entry->target -
26706 (entry->code + JUMP_LABEL_NOP_SIZE);
26707- if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
26708+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
26709 bug_at((void *)entry->code, __LINE__);
26710 }
26711 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
26712diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
26713index d6178d9..598681f 100644
26714--- a/arch/x86/kernel/kgdb.c
26715+++ b/arch/x86/kernel/kgdb.c
26716@@ -228,7 +228,10 @@ static void kgdb_correct_hw_break(void)
26717 bp->attr.bp_addr = breakinfo[breakno].addr;
26718 bp->attr.bp_len = breakinfo[breakno].len;
26719 bp->attr.bp_type = breakinfo[breakno].type;
26720- info->address = breakinfo[breakno].addr;
26721+ if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
26722+ info->address = ktla_ktva(breakinfo[breakno].addr);
26723+ else
26724+ info->address = breakinfo[breakno].addr;
26725 info->len = breakinfo[breakno].len;
26726 info->type = breakinfo[breakno].type;
26727 val = arch_install_hw_breakpoint(bp);
26728@@ -475,12 +478,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
26729 case 'k':
26730 /* clear the trace bit */
26731 linux_regs->flags &= ~X86_EFLAGS_TF;
26732- atomic_set(&kgdb_cpu_doing_single_step, -1);
26733+ atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
26734
26735 /* set the trace bit if we're stepping */
26736 if (remcomInBuffer[0] == 's') {
26737 linux_regs->flags |= X86_EFLAGS_TF;
26738- atomic_set(&kgdb_cpu_doing_single_step,
26739+ atomic_set_unchecked(&kgdb_cpu_doing_single_step,
26740 raw_smp_processor_id());
26741 }
26742
26743@@ -545,7 +548,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
26744
26745 switch (cmd) {
26746 case DIE_DEBUG:
26747- if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
26748+ if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
26749 if (user_mode(regs))
26750 return single_step_cont(regs, args);
26751 break;
26752@@ -750,11 +753,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
26753 #endif /* CONFIG_DEBUG_RODATA */
26754
26755 bpt->type = BP_BREAKPOINT;
26756- err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
26757+ err = probe_kernel_read(bpt->saved_instr, (const void *)ktla_ktva(bpt->bpt_addr),
26758 BREAK_INSTR_SIZE);
26759 if (err)
26760 return err;
26761- err = probe_kernel_write((char *)bpt->bpt_addr,
26762+ err = probe_kernel_write((void *)ktla_ktva(bpt->bpt_addr),
26763 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
26764 #ifdef CONFIG_DEBUG_RODATA
26765 if (!err)
26766@@ -767,7 +770,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
26767 return -EBUSY;
26768 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
26769 BREAK_INSTR_SIZE);
26770- err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
26771+ err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
26772 if (err)
26773 return err;
26774 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
26775@@ -792,13 +795,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
26776 if (mutex_is_locked(&text_mutex))
26777 goto knl_write;
26778 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
26779- err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
26780+ err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
26781 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
26782 goto knl_write;
26783 return err;
26784 knl_write:
26785 #endif /* CONFIG_DEBUG_RODATA */
26786- return probe_kernel_write((char *)bpt->bpt_addr,
26787+ return probe_kernel_write((void *)ktla_ktva(bpt->bpt_addr),
26788 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
26789 }
26790
26791diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
26792index 1deffe6..3be342a 100644
26793--- a/arch/x86/kernel/kprobes/core.c
26794+++ b/arch/x86/kernel/kprobes/core.c
26795@@ -120,9 +120,12 @@ __synthesize_relative_insn(void *from, void *to, u8 op)
26796 s32 raddr;
26797 } __packed *insn;
26798
26799- insn = (struct __arch_relative_insn *)from;
26800+ insn = (struct __arch_relative_insn *)ktla_ktva((unsigned long)from);
26801+
26802+ pax_open_kernel();
26803 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
26804 insn->op = op;
26805+ pax_close_kernel();
26806 }
26807
26808 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
26809@@ -168,7 +171,7 @@ int can_boost(kprobe_opcode_t *opcodes)
26810 kprobe_opcode_t opcode;
26811 kprobe_opcode_t *orig_opcodes = opcodes;
26812
26813- if (search_exception_tables((unsigned long)opcodes))
26814+ if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
26815 return 0; /* Page fault may occur on this address. */
26816
26817 retry:
26818@@ -260,12 +263,12 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
26819 * Fortunately, we know that the original code is the ideal 5-byte
26820 * long NOP.
26821 */
26822- memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
26823+ memcpy(buf, (void *)ktla_ktva(addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
26824 if (faddr)
26825 memcpy(buf, ideal_nops[NOP_ATOMIC5], 5);
26826 else
26827 buf[0] = kp->opcode;
26828- return (unsigned long)buf;
26829+ return ktva_ktla((unsigned long)buf);
26830 }
26831
26832 /*
26833@@ -367,7 +370,9 @@ int __copy_instruction(u8 *dest, u8 *src)
26834 /* Another subsystem puts a breakpoint, failed to recover */
26835 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
26836 return 0;
26837+ pax_open_kernel();
26838 memcpy(dest, insn.kaddr, length);
26839+ pax_close_kernel();
26840
26841 #ifdef CONFIG_X86_64
26842 if (insn_rip_relative(&insn)) {
26843@@ -394,7 +399,9 @@ int __copy_instruction(u8 *dest, u8 *src)
26844 return 0;
26845 }
26846 disp = (u8 *) dest + insn_offset_displacement(&insn);
26847+ pax_open_kernel();
26848 *(s32 *) disp = (s32) newdisp;
26849+ pax_close_kernel();
26850 }
26851 #endif
26852 return length;
26853@@ -536,7 +543,7 @@ static void setup_singlestep(struct kprobe *p, struct pt_regs *regs,
26854 * nor set current_kprobe, because it doesn't use single
26855 * stepping.
26856 */
26857- regs->ip = (unsigned long)p->ainsn.insn;
26858+ regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
26859 preempt_enable_no_resched();
26860 return;
26861 }
26862@@ -553,9 +560,9 @@ static void setup_singlestep(struct kprobe *p, struct pt_regs *regs,
26863 regs->flags &= ~X86_EFLAGS_IF;
26864 /* single step inline if the instruction is an int3 */
26865 if (p->opcode == BREAKPOINT_INSTRUCTION)
26866- regs->ip = (unsigned long)p->addr;
26867+ regs->ip = ktla_ktva((unsigned long)p->addr);
26868 else
26869- regs->ip = (unsigned long)p->ainsn.insn;
26870+ regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
26871 }
26872 NOKPROBE_SYMBOL(setup_singlestep);
26873
26874@@ -640,7 +647,7 @@ int kprobe_int3_handler(struct pt_regs *regs)
26875 setup_singlestep(p, regs, kcb, 0);
26876 return 1;
26877 }
26878- } else if (*addr != BREAKPOINT_INSTRUCTION) {
26879+ } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
26880 /*
26881 * The breakpoint instruction was removed right
26882 * after we hit it. Another cpu has removed
26883@@ -687,6 +694,9 @@ static void __used kretprobe_trampoline_holder(void)
26884 " movq %rax, 152(%rsp)\n"
26885 RESTORE_REGS_STRING
26886 " popfq\n"
26887+#ifdef KERNEXEC_PLUGIN
26888+ " btsq $63,(%rsp)\n"
26889+#endif
26890 #else
26891 " pushf\n"
26892 SAVE_REGS_STRING
26893@@ -827,7 +837,7 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs,
26894 struct kprobe_ctlblk *kcb)
26895 {
26896 unsigned long *tos = stack_addr(regs);
26897- unsigned long copy_ip = (unsigned long)p->ainsn.insn;
26898+ unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
26899 unsigned long orig_ip = (unsigned long)p->addr;
26900 kprobe_opcode_t *insn = p->ainsn.insn;
26901
26902diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
26903index 7b3b9d1..e2478b91 100644
26904--- a/arch/x86/kernel/kprobes/opt.c
26905+++ b/arch/x86/kernel/kprobes/opt.c
26906@@ -79,6 +79,7 @@ found:
26907 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
26908 static void synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
26909 {
26910+ pax_open_kernel();
26911 #ifdef CONFIG_X86_64
26912 *addr++ = 0x48;
26913 *addr++ = 0xbf;
26914@@ -86,6 +87,7 @@ static void synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
26915 *addr++ = 0xb8;
26916 #endif
26917 *(unsigned long *)addr = val;
26918+ pax_close_kernel();
26919 }
26920
26921 asm (
26922@@ -342,7 +344,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
26923 * Verify if the address gap is in 2GB range, because this uses
26924 * a relative jump.
26925 */
26926- rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
26927+ rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
26928 if (abs(rel) > 0x7fffffff) {
26929 __arch_remove_optimized_kprobe(op, 0);
26930 return -ERANGE;
26931@@ -359,16 +361,18 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
26932 op->optinsn.size = ret;
26933
26934 /* Copy arch-dep-instance from template */
26935- memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
26936+ pax_open_kernel();
26937+ memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
26938+ pax_close_kernel();
26939
26940 /* Set probe information */
26941 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
26942
26943 /* Set probe function call */
26944- synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
26945+ synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
26946
26947 /* Set returning jmp instruction at the tail of out-of-line buffer */
26948- synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
26949+ synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
26950 (u8 *)op->kp.addr + op->optinsn.size);
26951
26952 flush_icache_range((unsigned long) buf,
26953@@ -393,7 +397,7 @@ void arch_optimize_kprobes(struct list_head *oplist)
26954 WARN_ON(kprobe_disabled(&op->kp));
26955
26956 /* Backup instructions which will be replaced by jump address */
26957- memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
26958+ memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
26959 RELATIVE_ADDR_SIZE);
26960
26961 insn_buf[0] = RELATIVEJUMP_OPCODE;
26962@@ -441,7 +445,7 @@ int setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
26963 /* This kprobe is really able to run optimized path. */
26964 op = container_of(p, struct optimized_kprobe, kp);
26965 /* Detour through copied instructions */
26966- regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
26967+ regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
26968 if (!reenter)
26969 reset_current_kprobe();
26970 preempt_enable_no_resched();
26971diff --git a/arch/x86/kernel/ksysfs.c b/arch/x86/kernel/ksysfs.c
26972index c2bedae..25e7ab60 100644
26973--- a/arch/x86/kernel/ksysfs.c
26974+++ b/arch/x86/kernel/ksysfs.c
26975@@ -184,7 +184,7 @@ out:
26976
26977 static struct kobj_attribute type_attr = __ATTR_RO(type);
26978
26979-static struct bin_attribute data_attr = {
26980+static bin_attribute_no_const data_attr __read_only = {
26981 .attr = {
26982 .name = "data",
26983 .mode = S_IRUGO,
26984diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
26985index 49487b4..a94a0d3 100644
26986--- a/arch/x86/kernel/kvmclock.c
26987+++ b/arch/x86/kernel/kvmclock.c
26988@@ -29,7 +29,7 @@
26989 #include <asm/x86_init.h>
26990 #include <asm/reboot.h>
26991
26992-static int kvmclock = 1;
26993+static int kvmclock __read_only = 1;
26994 static int msr_kvm_system_time = MSR_KVM_SYSTEM_TIME;
26995 static int msr_kvm_wall_clock = MSR_KVM_WALL_CLOCK;
26996
26997@@ -41,7 +41,7 @@ static int parse_no_kvmclock(char *arg)
26998 early_param("no-kvmclock", parse_no_kvmclock);
26999
27000 /* The hypervisor will put information about time periodically here */
27001-static struct pvclock_vsyscall_time_info *hv_clock;
27002+static struct pvclock_vsyscall_time_info hv_clock[NR_CPUS] __page_aligned_bss;
27003 static struct pvclock_wall_clock wall_clock;
27004
27005 /*
27006@@ -132,7 +132,7 @@ bool kvm_check_and_clear_guest_paused(void)
27007 struct pvclock_vcpu_time_info *src;
27008 int cpu = smp_processor_id();
27009
27010- if (!hv_clock)
27011+ if (!kvmclock)
27012 return ret;
27013
27014 src = &hv_clock[cpu].pvti;
27015@@ -159,7 +159,7 @@ int kvm_register_clock(char *txt)
27016 int low, high, ret;
27017 struct pvclock_vcpu_time_info *src;
27018
27019- if (!hv_clock)
27020+ if (!kvmclock)
27021 return 0;
27022
27023 src = &hv_clock[cpu].pvti;
27024@@ -219,7 +219,6 @@ static void kvm_shutdown(void)
27025 void __init kvmclock_init(void)
27026 {
27027 struct pvclock_vcpu_time_info *vcpu_time;
27028- unsigned long mem;
27029 int size, cpu;
27030 u8 flags;
27031
27032@@ -237,15 +236,8 @@ void __init kvmclock_init(void)
27033 printk(KERN_INFO "kvm-clock: Using msrs %x and %x",
27034 msr_kvm_system_time, msr_kvm_wall_clock);
27035
27036- mem = memblock_alloc(size, PAGE_SIZE);
27037- if (!mem)
27038- return;
27039- hv_clock = __va(mem);
27040- memset(hv_clock, 0, size);
27041-
27042 if (kvm_register_clock("primary cpu clock")) {
27043- hv_clock = NULL;
27044- memblock_free(mem, size);
27045+ kvmclock = 0;
27046 return;
27047 }
27048 pv_time_ops.sched_clock = kvm_clock_read;
27049@@ -286,7 +278,7 @@ int __init kvm_setup_vsyscall_timeinfo(void)
27050 struct pvclock_vcpu_time_info *vcpu_time;
27051 unsigned int size;
27052
27053- if (!hv_clock)
27054+ if (!kvmclock)
27055 return 0;
27056
27057 size = PAGE_ALIGN(sizeof(struct pvclock_vsyscall_time_info)*NR_CPUS);
27058diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
27059index 2bcc052..864eb84 100644
27060--- a/arch/x86/kernel/ldt.c
27061+++ b/arch/x86/kernel/ldt.c
27062@@ -11,6 +11,7 @@
27063 #include <linux/sched.h>
27064 #include <linux/string.h>
27065 #include <linux/mm.h>
27066+#include <linux/ratelimit.h>
27067 #include <linux/smp.h>
27068 #include <linux/slab.h>
27069 #include <linux/vmalloc.h>
27070@@ -21,6 +22,14 @@
27071 #include <asm/mmu_context.h>
27072 #include <asm/syscalls.h>
27073
27074+#ifdef CONFIG_GRKERNSEC
27075+int sysctl_modify_ldt __read_only = 0;
27076+#elif defined(CONFIG_DEFAULT_MODIFY_LDT_SYSCALL)
27077+int sysctl_modify_ldt __read_only = 1;
27078+#else
27079+int sysctl_modify_ldt __read_only = 0;
27080+#endif
27081+
27082 /* context.lock is held for us, so we don't need any locking. */
27083 static void flush_ldt(void *current_mm)
27084 {
27085@@ -109,6 +118,23 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
27086 struct mm_struct *old_mm;
27087 int retval = 0;
27088
27089+ if (tsk == current) {
27090+ mm->context.vdso = 0;
27091+
27092+#ifdef CONFIG_X86_32
27093+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27094+ mm->context.user_cs_base = 0UL;
27095+ mm->context.user_cs_limit = ~0UL;
27096+
27097+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
27098+ cpumask_clear(&mm->context.cpu_user_cs_mask);
27099+#endif
27100+
27101+#endif
27102+#endif
27103+
27104+ }
27105+
27106 mutex_init(&mm->context.lock);
27107 old_mm = current->mm;
27108 if (!old_mm) {
27109@@ -235,6 +261,14 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
27110 /* The user wants to clear the entry. */
27111 memset(&ldt, 0, sizeof(ldt));
27112 } else {
27113+
27114+#ifdef CONFIG_PAX_SEGMEXEC
27115+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
27116+ error = -EINVAL;
27117+ goto out;
27118+ }
27119+#endif
27120+
27121 if (!IS_ENABLED(CONFIG_X86_16BIT) && !ldt_info.seg_32bit) {
27122 error = -EINVAL;
27123 goto out;
27124@@ -276,6 +310,15 @@ asmlinkage int sys_modify_ldt(int func, void __user *ptr,
27125 {
27126 int ret = -ENOSYS;
27127
27128+ if (!sysctl_modify_ldt) {
27129+ printk_ratelimited(KERN_INFO
27130+ "Denied a call to modify_ldt() from %s[%d] (uid: %d)."
27131+ " Adjust sysctl if this was not an exploit attempt.\n",
27132+ current->comm, task_pid_nr(current),
27133+ from_kuid_munged(current_user_ns(), current_uid()));
27134+ return ret;
27135+ }
27136+
27137 switch (func) {
27138 case 0:
27139 ret = read_ldt(ptr, bytecount);
27140diff --git a/arch/x86/kernel/livepatch.c b/arch/x86/kernel/livepatch.c
27141index ff3c3101d..d7c0cd8 100644
27142--- a/arch/x86/kernel/livepatch.c
27143+++ b/arch/x86/kernel/livepatch.c
27144@@ -41,9 +41,10 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
27145 int ret, numpages, size = 4;
27146 bool readonly;
27147 unsigned long val;
27148- unsigned long core = (unsigned long)mod->module_core;
27149- unsigned long core_ro_size = mod->core_ro_size;
27150- unsigned long core_size = mod->core_size;
27151+ unsigned long core_rx = (unsigned long)mod->module_core_rx;
27152+ unsigned long core_rw = (unsigned long)mod->module_core_rw;
27153+ unsigned long core_size_rx = mod->core_size_rx;
27154+ unsigned long core_size_rw = mod->core_size_rw;
27155
27156 switch (type) {
27157 case R_X86_64_NONE:
27158@@ -66,11 +67,12 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
27159 return -EINVAL;
27160 }
27161
27162- if (loc < core || loc >= core + core_size)
27163+ if ((loc < core_rx || loc >= core_rx + core_size_rx) &&
27164+ (loc < core_rw || loc >= core_rw + core_size_rw))
27165 /* loc does not point to any symbol inside the module */
27166 return -EINVAL;
27167
27168- if (loc < core + core_ro_size)
27169+ if (loc < core_rx + core_size_rx)
27170 readonly = true;
27171 else
27172 readonly = false;
27173diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
27174index 469b23d..5449cfe 100644
27175--- a/arch/x86/kernel/machine_kexec_32.c
27176+++ b/arch/x86/kernel/machine_kexec_32.c
27177@@ -26,7 +26,7 @@
27178 #include <asm/cacheflush.h>
27179 #include <asm/debugreg.h>
27180
27181-static void set_idt(void *newidt, __u16 limit)
27182+static void set_idt(struct desc_struct *newidt, __u16 limit)
27183 {
27184 struct desc_ptr curidt;
27185
27186@@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
27187 }
27188
27189
27190-static void set_gdt(void *newgdt, __u16 limit)
27191+static void set_gdt(struct desc_struct *newgdt, __u16 limit)
27192 {
27193 struct desc_ptr curgdt;
27194
27195@@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
27196 }
27197
27198 control_page = page_address(image->control_code_page);
27199- memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
27200+ memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
27201
27202 relocate_kernel_ptr = control_page;
27203 page_list[PA_CONTROL_PAGE] = __pa(control_page);
27204diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
27205index 94ea120..4154cea 100644
27206--- a/arch/x86/kernel/mcount_64.S
27207+++ b/arch/x86/kernel/mcount_64.S
27208@@ -7,7 +7,7 @@
27209 #include <linux/linkage.h>
27210 #include <asm/ptrace.h>
27211 #include <asm/ftrace.h>
27212-
27213+#include <asm/alternative-asm.h>
27214
27215 .code64
27216 .section .entry.text, "ax"
27217@@ -148,8 +148,9 @@
27218 #ifdef CONFIG_DYNAMIC_FTRACE
27219
27220 ENTRY(function_hook)
27221+ pax_force_retaddr
27222 retq
27223-END(function_hook)
27224+ENDPROC(function_hook)
27225
27226 ENTRY(ftrace_caller)
27227 /* save_mcount_regs fills in first two parameters */
27228@@ -181,8 +182,9 @@ GLOBAL(ftrace_graph_call)
27229 #endif
27230
27231 GLOBAL(ftrace_stub)
27232+ pax_force_retaddr
27233 retq
27234-END(ftrace_caller)
27235+ENDPROC(ftrace_caller)
27236
27237 ENTRY(ftrace_regs_caller)
27238 /* Save the current flags before any operations that can change them */
27239@@ -253,7 +255,7 @@ GLOBAL(ftrace_regs_caller_end)
27240
27241 jmp ftrace_return
27242
27243-END(ftrace_regs_caller)
27244+ENDPROC(ftrace_regs_caller)
27245
27246
27247 #else /* ! CONFIG_DYNAMIC_FTRACE */
27248@@ -272,18 +274,20 @@ fgraph_trace:
27249 #endif
27250
27251 GLOBAL(ftrace_stub)
27252+ pax_force_retaddr
27253 retq
27254
27255 trace:
27256 /* save_mcount_regs fills in first two parameters */
27257 save_mcount_regs
27258
27259+ pax_force_fptr ftrace_trace_function
27260 call *ftrace_trace_function
27261
27262 restore_mcount_regs
27263
27264 jmp fgraph_trace
27265-END(function_hook)
27266+ENDPROC(function_hook)
27267 #endif /* CONFIG_DYNAMIC_FTRACE */
27268 #endif /* CONFIG_FUNCTION_TRACER */
27269
27270@@ -305,8 +309,9 @@ ENTRY(ftrace_graph_caller)
27271
27272 restore_mcount_regs
27273
27274+ pax_force_retaddr
27275 retq
27276-END(ftrace_graph_caller)
27277+ENDPROC(ftrace_graph_caller)
27278
27279 GLOBAL(return_to_handler)
27280 subq $24, %rsp
27281@@ -322,5 +327,7 @@ GLOBAL(return_to_handler)
27282 movq 8(%rsp), %rdx
27283 movq (%rsp), %rax
27284 addq $24, %rsp
27285+ pax_force_fptr %rdi
27286 jmp *%rdi
27287+ENDPROC(return_to_handler)
27288 #endif
27289diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
27290index 005c03e..7000fe4 100644
27291--- a/arch/x86/kernel/module.c
27292+++ b/arch/x86/kernel/module.c
27293@@ -75,17 +75,17 @@ static unsigned long int get_module_load_offset(void)
27294 }
27295 #endif
27296
27297-void *module_alloc(unsigned long size)
27298+static inline void *__module_alloc(unsigned long size, pgprot_t prot)
27299 {
27300 void *p;
27301
27302- if (PAGE_ALIGN(size) > MODULES_LEN)
27303+ if (!size || PAGE_ALIGN(size) > MODULES_LEN)
27304 return NULL;
27305
27306 p = __vmalloc_node_range(size, MODULE_ALIGN,
27307 MODULES_VADDR + get_module_load_offset(),
27308- MODULES_END, GFP_KERNEL | __GFP_HIGHMEM,
27309- PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
27310+ MODULES_END, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
27311+ prot, 0, NUMA_NO_NODE,
27312 __builtin_return_address(0));
27313 if (p && (kasan_module_alloc(p, size) < 0)) {
27314 vfree(p);
27315@@ -95,6 +95,51 @@ void *module_alloc(unsigned long size)
27316 return p;
27317 }
27318
27319+void *module_alloc(unsigned long size)
27320+{
27321+
27322+#ifdef CONFIG_PAX_KERNEXEC
27323+ return __module_alloc(size, PAGE_KERNEL);
27324+#else
27325+ return __module_alloc(size, PAGE_KERNEL_EXEC);
27326+#endif
27327+
27328+}
27329+
27330+#ifdef CONFIG_PAX_KERNEXEC
27331+#ifdef CONFIG_X86_32
27332+void *module_alloc_exec(unsigned long size)
27333+{
27334+ struct vm_struct *area;
27335+
27336+ if (size == 0)
27337+ return NULL;
27338+
27339+ area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
27340+return area ? area->addr : NULL;
27341+}
27342+EXPORT_SYMBOL(module_alloc_exec);
27343+
27344+void module_memfree_exec(void *module_region)
27345+{
27346+ vunmap(module_region);
27347+}
27348+EXPORT_SYMBOL(module_memfree_exec);
27349+#else
27350+void module_memfree_exec(void *module_region)
27351+{
27352+ module_memfree(module_region);
27353+}
27354+EXPORT_SYMBOL(module_memfree_exec);
27355+
27356+void *module_alloc_exec(unsigned long size)
27357+{
27358+ return __module_alloc(size, PAGE_KERNEL_RX);
27359+}
27360+EXPORT_SYMBOL(module_alloc_exec);
27361+#endif
27362+#endif
27363+
27364 #ifdef CONFIG_X86_32
27365 int apply_relocate(Elf32_Shdr *sechdrs,
27366 const char *strtab,
27367@@ -105,14 +150,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
27368 unsigned int i;
27369 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
27370 Elf32_Sym *sym;
27371- uint32_t *location;
27372+ uint32_t *plocation, location;
27373
27374 DEBUGP("Applying relocate section %u to %u\n",
27375 relsec, sechdrs[relsec].sh_info);
27376 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
27377 /* This is where to make the change */
27378- location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
27379- + rel[i].r_offset;
27380+ plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
27381+ location = (uint32_t)plocation;
27382+ if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
27383+ plocation = (uint32_t *)ktla_ktva((unsigned long)plocation);
27384 /* This is the symbol it is referring to. Note that all
27385 undefined symbols have been resolved. */
27386 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
27387@@ -121,11 +168,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
27388 switch (ELF32_R_TYPE(rel[i].r_info)) {
27389 case R_386_32:
27390 /* We add the value into the location given */
27391- *location += sym->st_value;
27392+ pax_open_kernel();
27393+ *plocation += sym->st_value;
27394+ pax_close_kernel();
27395 break;
27396 case R_386_PC32:
27397 /* Add the value, subtract its position */
27398- *location += sym->st_value - (uint32_t)location;
27399+ pax_open_kernel();
27400+ *plocation += sym->st_value - location;
27401+ pax_close_kernel();
27402 break;
27403 default:
27404 pr_err("%s: Unknown relocation: %u\n",
27405@@ -170,21 +221,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
27406 case R_X86_64_NONE:
27407 break;
27408 case R_X86_64_64:
27409+ pax_open_kernel();
27410 *(u64 *)loc = val;
27411+ pax_close_kernel();
27412 break;
27413 case R_X86_64_32:
27414+ pax_open_kernel();
27415 *(u32 *)loc = val;
27416+ pax_close_kernel();
27417 if (val != *(u32 *)loc)
27418 goto overflow;
27419 break;
27420 case R_X86_64_32S:
27421+ pax_open_kernel();
27422 *(s32 *)loc = val;
27423+ pax_close_kernel();
27424 if ((s64)val != *(s32 *)loc)
27425 goto overflow;
27426 break;
27427 case R_X86_64_PC32:
27428 val -= (u64)loc;
27429+ pax_open_kernel();
27430 *(u32 *)loc = val;
27431+ pax_close_kernel();
27432+
27433 #if 0
27434 if ((s64)val != *(s32 *)loc)
27435 goto overflow;
27436diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
27437index 113e707..0a690e1 100644
27438--- a/arch/x86/kernel/msr.c
27439+++ b/arch/x86/kernel/msr.c
27440@@ -39,6 +39,7 @@
27441 #include <linux/notifier.h>
27442 #include <linux/uaccess.h>
27443 #include <linux/gfp.h>
27444+#include <linux/grsecurity.h>
27445
27446 #include <asm/processor.h>
27447 #include <asm/msr.h>
27448@@ -105,6 +106,11 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
27449 int err = 0;
27450 ssize_t bytes = 0;
27451
27452+#ifdef CONFIG_GRKERNSEC_KMEM
27453+ gr_handle_msr_write();
27454+ return -EPERM;
27455+#endif
27456+
27457 if (count % 8)
27458 return -EINVAL; /* Invalid chunk size */
27459
27460@@ -152,6 +158,10 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
27461 err = -EBADF;
27462 break;
27463 }
27464+#ifdef CONFIG_GRKERNSEC_KMEM
27465+ gr_handle_msr_write();
27466+ return -EPERM;
27467+#endif
27468 if (copy_from_user(&regs, uregs, sizeof regs)) {
27469 err = -EFAULT;
27470 break;
27471@@ -235,7 +245,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
27472 return notifier_from_errno(err);
27473 }
27474
27475-static struct notifier_block __refdata msr_class_cpu_notifier = {
27476+static struct notifier_block msr_class_cpu_notifier = {
27477 .notifier_call = msr_class_cpu_callback,
27478 };
27479
27480diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
27481index d05bd2e..f690edd 100644
27482--- a/arch/x86/kernel/nmi.c
27483+++ b/arch/x86/kernel/nmi.c
27484@@ -98,16 +98,16 @@ fs_initcall(nmi_warning_debugfs);
27485
27486 static void nmi_max_handler(struct irq_work *w)
27487 {
27488- struct nmiaction *a = container_of(w, struct nmiaction, irq_work);
27489+ struct nmiwork *n = container_of(w, struct nmiwork, irq_work);
27490 int remainder_ns, decimal_msecs;
27491- u64 whole_msecs = ACCESS_ONCE(a->max_duration);
27492+ u64 whole_msecs = ACCESS_ONCE(n->max_duration);
27493
27494 remainder_ns = do_div(whole_msecs, (1000 * 1000));
27495 decimal_msecs = remainder_ns / 1000;
27496
27497 printk_ratelimited(KERN_INFO
27498 "INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n",
27499- a->handler, whole_msecs, decimal_msecs);
27500+ n->action->handler, whole_msecs, decimal_msecs);
27501 }
27502
27503 static int nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
27504@@ -134,11 +134,11 @@ static int nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
27505 delta = sched_clock() - delta;
27506 trace_nmi_handler(a->handler, (int)delta, thishandled);
27507
27508- if (delta < nmi_longest_ns || delta < a->max_duration)
27509+ if (delta < nmi_longest_ns || delta < a->work->max_duration)
27510 continue;
27511
27512- a->max_duration = delta;
27513- irq_work_queue(&a->irq_work);
27514+ a->work->max_duration = delta;
27515+ irq_work_queue(&a->work->irq_work);
27516 }
27517
27518 rcu_read_unlock();
27519@@ -148,7 +148,7 @@ static int nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
27520 }
27521 NOKPROBE_SYMBOL(nmi_handle);
27522
27523-int __register_nmi_handler(unsigned int type, struct nmiaction *action)
27524+int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
27525 {
27526 struct nmi_desc *desc = nmi_to_desc(type);
27527 unsigned long flags;
27528@@ -156,7 +156,8 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
27529 if (!action->handler)
27530 return -EINVAL;
27531
27532- init_irq_work(&action->irq_work, nmi_max_handler);
27533+ action->work->action = action;
27534+ init_irq_work(&action->work->irq_work, nmi_max_handler);
27535
27536 spin_lock_irqsave(&desc->lock, flags);
27537
27538@@ -174,9 +175,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
27539 * event confuses some handlers (kdump uses this flag)
27540 */
27541 if (action->flags & NMI_FLAG_FIRST)
27542- list_add_rcu(&action->list, &desc->head);
27543+ pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
27544 else
27545- list_add_tail_rcu(&action->list, &desc->head);
27546+ pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
27547
27548 spin_unlock_irqrestore(&desc->lock, flags);
27549 return 0;
27550@@ -199,7 +200,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
27551 if (!strcmp(n->name, name)) {
27552 WARN(in_nmi(),
27553 "Trying to free NMI (%s) from NMI context!\n", n->name);
27554- list_del_rcu(&n->list);
27555+ pax_list_del_rcu((struct list_head *)&n->list);
27556 break;
27557 }
27558 }
27559@@ -481,6 +482,17 @@ static DEFINE_PER_CPU(int, update_debug_stack);
27560 dotraplinkage notrace void
27561 do_nmi(struct pt_regs *regs, long error_code)
27562 {
27563+
27564+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27565+ if (!user_mode(regs)) {
27566+ unsigned long cs = regs->cs & 0xFFFF;
27567+ unsigned long ip = ktva_ktla(regs->ip);
27568+
27569+ if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
27570+ regs->ip = ip;
27571+ }
27572+#endif
27573+
27574 if (this_cpu_read(nmi_state) != NMI_NOT_RUNNING) {
27575 this_cpu_write(nmi_state, NMI_LATCHED);
27576 return;
27577diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
27578index 6d9582e..f746287 100644
27579--- a/arch/x86/kernel/nmi_selftest.c
27580+++ b/arch/x86/kernel/nmi_selftest.c
27581@@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
27582 {
27583 /* trap all the unknown NMIs we may generate */
27584 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
27585- __initdata);
27586+ __initconst);
27587 }
27588
27589 static void __init cleanup_nmi_testsuite(void)
27590@@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
27591 unsigned long timeout;
27592
27593 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
27594- NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
27595+ NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
27596 nmi_fail = FAILURE;
27597 return;
27598 }
27599diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
27600index 33ee3e0..da3519a 100644
27601--- a/arch/x86/kernel/paravirt-spinlocks.c
27602+++ b/arch/x86/kernel/paravirt-spinlocks.c
27603@@ -23,7 +23,7 @@ bool pv_is_native_spin_unlock(void)
27604 }
27605 #endif
27606
27607-struct pv_lock_ops pv_lock_ops = {
27608+struct pv_lock_ops pv_lock_ops __read_only = {
27609 #ifdef CONFIG_SMP
27610 #ifdef CONFIG_QUEUED_SPINLOCKS
27611 .queued_spin_lock_slowpath = native_queued_spin_lock_slowpath,
27612diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
27613index ebb5657..dde2f45 100644
27614--- a/arch/x86/kernel/paravirt.c
27615+++ b/arch/x86/kernel/paravirt.c
27616@@ -64,6 +64,9 @@ u64 _paravirt_ident_64(u64 x)
27617 {
27618 return x;
27619 }
27620+#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
27621+PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
27622+#endif
27623
27624 void __init default_banner(void)
27625 {
27626@@ -150,16 +153,20 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
27627
27628 if (opfunc == NULL)
27629 /* If there's no function, patch it with a ud2a (BUG) */
27630- ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
27631- else if (opfunc == _paravirt_nop)
27632+ ret = paravirt_patch_insns(insnbuf, len, (const char *)ktva_ktla((unsigned long)ud2a), ud2a+sizeof(ud2a));
27633+ else if (opfunc == (void *)_paravirt_nop)
27634 /* If the operation is a nop, then nop the callsite */
27635 ret = paravirt_patch_nop();
27636
27637 /* identity functions just return their single argument */
27638- else if (opfunc == _paravirt_ident_32)
27639+ else if (opfunc == (void *)_paravirt_ident_32)
27640 ret = paravirt_patch_ident_32(insnbuf, len);
27641- else if (opfunc == _paravirt_ident_64)
27642+ else if (opfunc == (void *)_paravirt_ident_64)
27643 ret = paravirt_patch_ident_64(insnbuf, len);
27644+#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
27645+ else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
27646+ ret = paravirt_patch_ident_64(insnbuf, len);
27647+#endif
27648
27649 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
27650 #ifdef CONFIG_X86_32
27651@@ -186,7 +193,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
27652 if (insn_len > len || start == NULL)
27653 insn_len = len;
27654 else
27655- memcpy(insnbuf, start, insn_len);
27656+ memcpy(insnbuf, (const char *)ktla_ktva((unsigned long)start), insn_len);
27657
27658 return insn_len;
27659 }
27660@@ -310,7 +317,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
27661 return this_cpu_read(paravirt_lazy_mode);
27662 }
27663
27664-struct pv_info pv_info = {
27665+struct pv_info pv_info __read_only = {
27666 .name = "bare hardware",
27667 .paravirt_enabled = 0,
27668 .kernel_rpl = 0,
27669@@ -321,16 +328,16 @@ struct pv_info pv_info = {
27670 #endif
27671 };
27672
27673-struct pv_init_ops pv_init_ops = {
27674+struct pv_init_ops pv_init_ops __read_only = {
27675 .patch = native_patch,
27676 };
27677
27678-struct pv_time_ops pv_time_ops = {
27679+struct pv_time_ops pv_time_ops __read_only = {
27680 .sched_clock = native_sched_clock,
27681 .steal_clock = native_steal_clock,
27682 };
27683
27684-__visible struct pv_irq_ops pv_irq_ops = {
27685+__visible struct pv_irq_ops pv_irq_ops __read_only = {
27686 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
27687 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
27688 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
27689@@ -342,7 +349,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
27690 #endif
27691 };
27692
27693-__visible struct pv_cpu_ops pv_cpu_ops = {
27694+__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
27695 .cpuid = native_cpuid,
27696 .get_debugreg = native_get_debugreg,
27697 .set_debugreg = native_set_debugreg,
27698@@ -405,21 +412,26 @@ NOKPROBE_SYMBOL(native_get_debugreg);
27699 NOKPROBE_SYMBOL(native_set_debugreg);
27700 NOKPROBE_SYMBOL(native_load_idt);
27701
27702-struct pv_apic_ops pv_apic_ops = {
27703+struct pv_apic_ops pv_apic_ops __read_only= {
27704 #ifdef CONFIG_X86_LOCAL_APIC
27705 .startup_ipi_hook = paravirt_nop,
27706 #endif
27707 };
27708
27709-#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
27710+#ifdef CONFIG_X86_32
27711+#ifdef CONFIG_X86_PAE
27712+/* 64-bit pagetable entries */
27713+#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
27714+#else
27715 /* 32-bit pagetable entries */
27716 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
27717+#endif
27718 #else
27719 /* 64-bit pagetable entries */
27720 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
27721 #endif
27722
27723-struct pv_mmu_ops pv_mmu_ops = {
27724+struct pv_mmu_ops pv_mmu_ops __read_only = {
27725
27726 .read_cr2 = native_read_cr2,
27727 .write_cr2 = native_write_cr2,
27728@@ -469,6 +481,7 @@ struct pv_mmu_ops pv_mmu_ops = {
27729 .make_pud = PTE_IDENT,
27730
27731 .set_pgd = native_set_pgd,
27732+ .set_pgd_batched = native_set_pgd_batched,
27733 #endif
27734 #endif /* CONFIG_PGTABLE_LEVELS >= 3 */
27735
27736@@ -489,6 +502,12 @@ struct pv_mmu_ops pv_mmu_ops = {
27737 },
27738
27739 .set_fixmap = native_set_fixmap,
27740+
27741+#ifdef CONFIG_PAX_KERNEXEC
27742+ .pax_open_kernel = native_pax_open_kernel,
27743+ .pax_close_kernel = native_pax_close_kernel,
27744+#endif
27745+
27746 };
27747
27748 EXPORT_SYMBOL_GPL(pv_time_ops);
27749diff --git a/arch/x86/kernel/paravirt_patch_64.c b/arch/x86/kernel/paravirt_patch_64.c
27750index 8aa0558..465512e 100644
27751--- a/arch/x86/kernel/paravirt_patch_64.c
27752+++ b/arch/x86/kernel/paravirt_patch_64.c
27753@@ -9,7 +9,11 @@ DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax");
27754 DEF_NATIVE(pv_mmu_ops, read_cr2, "movq %cr2, %rax");
27755 DEF_NATIVE(pv_mmu_ops, read_cr3, "movq %cr3, %rax");
27756 DEF_NATIVE(pv_mmu_ops, write_cr3, "movq %rdi, %cr3");
27757+
27758+#ifndef CONFIG_PAX_MEMORY_UDEREF
27759 DEF_NATIVE(pv_mmu_ops, flush_tlb_single, "invlpg (%rdi)");
27760+#endif
27761+
27762 DEF_NATIVE(pv_cpu_ops, clts, "clts");
27763 DEF_NATIVE(pv_cpu_ops, wbinvd, "wbinvd");
27764
27765@@ -62,7 +66,11 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
27766 PATCH_SITE(pv_mmu_ops, read_cr3);
27767 PATCH_SITE(pv_mmu_ops, write_cr3);
27768 PATCH_SITE(pv_cpu_ops, clts);
27769+
27770+#ifndef CONFIG_PAX_MEMORY_UDEREF
27771 PATCH_SITE(pv_mmu_ops, flush_tlb_single);
27772+#endif
27773+
27774 PATCH_SITE(pv_cpu_ops, wbinvd);
27775 #if defined(CONFIG_PARAVIRT_SPINLOCKS) && defined(CONFIG_QUEUED_SPINLOCKS)
27776 case PARAVIRT_PATCH(pv_lock_ops.queued_spin_unlock):
27777diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
27778index 0497f71..7186c0d 100644
27779--- a/arch/x86/kernel/pci-calgary_64.c
27780+++ b/arch/x86/kernel/pci-calgary_64.c
27781@@ -1347,7 +1347,7 @@ static void __init get_tce_space_from_tar(void)
27782 tce_space = be64_to_cpu(readq(target));
27783 tce_space = tce_space & TAR_SW_BITS;
27784
27785- tce_space = tce_space & (~specified_table_size);
27786+ tce_space = tce_space & (~(unsigned long)specified_table_size);
27787 info->tce_space = (u64 *)__va(tce_space);
27788 }
27789 }
27790diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
27791index 35ccf75..7a15747 100644
27792--- a/arch/x86/kernel/pci-iommu_table.c
27793+++ b/arch/x86/kernel/pci-iommu_table.c
27794@@ -2,7 +2,7 @@
27795 #include <asm/iommu_table.h>
27796 #include <linux/string.h>
27797 #include <linux/kallsyms.h>
27798-
27799+#include <linux/sched.h>
27800
27801 #define DEBUG 1
27802
27803diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
27804index adf0392..88a7576 100644
27805--- a/arch/x86/kernel/pci-swiotlb.c
27806+++ b/arch/x86/kernel/pci-swiotlb.c
27807@@ -40,7 +40,7 @@ void x86_swiotlb_free_coherent(struct device *dev, size_t size,
27808 struct dma_attrs *attrs)
27809 {
27810 if (is_swiotlb_buffer(dma_to_phys(dev, dma_addr)))
27811- swiotlb_free_coherent(dev, size, vaddr, dma_addr);
27812+ swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
27813 else
27814 dma_generic_free_coherent(dev, size, vaddr, dma_addr, attrs);
27815 }
27816diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
27817index c27cad7..47e3f47 100644
27818--- a/arch/x86/kernel/process.c
27819+++ b/arch/x86/kernel/process.c
27820@@ -15,6 +15,7 @@
27821 #include <linux/dmi.h>
27822 #include <linux/utsname.h>
27823 #include <linux/stackprotector.h>
27824+#include <linux/kthread.h>
27825 #include <linux/tick.h>
27826 #include <linux/cpuidle.h>
27827 #include <trace/events/power.h>
27828@@ -37,7 +38,8 @@
27829 * section. Since TSS's are completely CPU-local, we want them
27830 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
27831 */
27832-__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss) = {
27833+struct tss_struct cpu_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = {
27834+ [0 ... NR_CPUS-1] = {
27835 .x86_tss = {
27836 .sp0 = TOP_OF_INIT_STACK,
27837 #ifdef CONFIG_X86_32
27838@@ -55,6 +57,7 @@ __visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss) = {
27839 */
27840 .io_bitmap = { [0 ... IO_BITMAP_LONGS] = ~0 },
27841 #endif
27842+}
27843 };
27844 EXPORT_PER_CPU_SYMBOL(cpu_tss);
27845
27846@@ -75,17 +78,35 @@ void idle_notifier_unregister(struct notifier_block *n)
27847 EXPORT_SYMBOL_GPL(idle_notifier_unregister);
27848 #endif
27849
27850+struct kmem_cache *fpregs_state_cachep;
27851+EXPORT_SYMBOL(fpregs_state_cachep);
27852+
27853+void __init arch_task_cache_init(void)
27854+{
27855+ /* create a slab on which task_structs can be allocated */
27856+ fpregs_state_cachep =
27857+ kmem_cache_create("fpregs_state", xstate_size,
27858+ ARCH_MIN_TASKALIGN, SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
27859+}
27860+
27861 /*
27862 * this gets called so that we can store lazy state into memory and copy the
27863 * current task into the new thread.
27864 */
27865 int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
27866 {
27867- memcpy(dst, src, arch_task_struct_size);
27868+ *dst = *src;
27869
27870+ dst->thread.fpu.state = kmem_cache_alloc_node(fpregs_state_cachep, GFP_KERNEL, tsk_fork_get_node(src));
27871 return fpu__copy(&dst->thread.fpu, &src->thread.fpu);
27872 }
27873
27874+void arch_release_task_struct(struct task_struct *tsk)
27875+{
27876+ kmem_cache_free(fpregs_state_cachep, tsk->thread.fpu.state);
27877+ tsk->thread.fpu.state = NULL;
27878+}
27879+
27880 /*
27881 * Free current thread data structures etc..
27882 */
27883@@ -97,7 +118,7 @@ void exit_thread(void)
27884 struct fpu *fpu = &t->fpu;
27885
27886 if (bp) {
27887- struct tss_struct *tss = &per_cpu(cpu_tss, get_cpu());
27888+ struct tss_struct *tss = cpu_tss + get_cpu();
27889
27890 t->io_bitmap_ptr = NULL;
27891 clear_thread_flag(TIF_IO_BITMAP);
27892@@ -117,6 +138,9 @@ void flush_thread(void)
27893 {
27894 struct task_struct *tsk = current;
27895
27896+#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
27897+ loadsegment(gs, 0);
27898+#endif
27899 flush_ptrace_hw_breakpoint(tsk);
27900 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
27901
27902@@ -258,7 +282,7 @@ static void __exit_idle(void)
27903 void exit_idle(void)
27904 {
27905 /* idle loop has pid 0 */
27906- if (current->pid)
27907+ if (task_pid_nr(current))
27908 return;
27909 __exit_idle();
27910 }
27911@@ -311,7 +335,7 @@ bool xen_set_default_idle(void)
27912 return ret;
27913 }
27914 #endif
27915-void stop_this_cpu(void *dummy)
27916+__noreturn void stop_this_cpu(void *dummy)
27917 {
27918 local_irq_disable();
27919 /*
27920@@ -488,16 +512,40 @@ static int __init idle_setup(char *str)
27921 }
27922 early_param("idle", idle_setup);
27923
27924-unsigned long arch_align_stack(unsigned long sp)
27925-{
27926- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
27927- sp -= get_random_int() % 8192;
27928- return sp & ~0xf;
27929-}
27930-
27931 unsigned long arch_randomize_brk(struct mm_struct *mm)
27932 {
27933 unsigned long range_end = mm->brk + 0x02000000;
27934 return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
27935 }
27936
27937+#ifdef CONFIG_PAX_RANDKSTACK
27938+void pax_randomize_kstack(struct pt_regs *regs)
27939+{
27940+ struct thread_struct *thread = &current->thread;
27941+ unsigned long time;
27942+
27943+ if (!randomize_va_space)
27944+ return;
27945+
27946+ if (v8086_mode(regs))
27947+ return;
27948+
27949+ rdtscl(time);
27950+
27951+ /* P4 seems to return a 0 LSB, ignore it */
27952+#ifdef CONFIG_MPENTIUM4
27953+ time &= 0x3EUL;
27954+ time <<= 2;
27955+#elif defined(CONFIG_X86_64)
27956+ time &= 0xFUL;
27957+ time <<= 4;
27958+#else
27959+ time &= 0x1FUL;
27960+ time <<= 3;
27961+#endif
27962+
27963+ thread->sp0 ^= time;
27964+ load_sp0(cpu_tss + smp_processor_id(), thread);
27965+ this_cpu_write(cpu_current_top_of_stack, thread->sp0);
27966+}
27967+#endif
27968diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
27969index f73c962..6589332 100644
27970--- a/arch/x86/kernel/process_32.c
27971+++ b/arch/x86/kernel/process_32.c
27972@@ -63,6 +63,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
27973 unsigned long thread_saved_pc(struct task_struct *tsk)
27974 {
27975 return ((unsigned long *)tsk->thread.sp)[3];
27976+//XXX return tsk->thread.eip;
27977 }
27978
27979 void __show_regs(struct pt_regs *regs, int all)
27980@@ -75,16 +76,15 @@ void __show_regs(struct pt_regs *regs, int all)
27981 if (user_mode(regs)) {
27982 sp = regs->sp;
27983 ss = regs->ss & 0xffff;
27984- gs = get_user_gs(regs);
27985 } else {
27986 sp = kernel_stack_pointer(regs);
27987 savesegment(ss, ss);
27988- savesegment(gs, gs);
27989 }
27990+ gs = get_user_gs(regs);
27991
27992 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
27993 (u16)regs->cs, regs->ip, regs->flags,
27994- smp_processor_id());
27995+ raw_smp_processor_id());
27996 print_symbol("EIP is at %s\n", regs->ip);
27997
27998 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
27999@@ -131,21 +131,22 @@ void release_thread(struct task_struct *dead_task)
28000 int copy_thread_tls(unsigned long clone_flags, unsigned long sp,
28001 unsigned long arg, struct task_struct *p, unsigned long tls)
28002 {
28003- struct pt_regs *childregs = task_pt_regs(p);
28004+ struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
28005 struct task_struct *tsk;
28006 int err;
28007
28008 p->thread.sp = (unsigned long) childregs;
28009 p->thread.sp0 = (unsigned long) (childregs+1);
28010+ p->tinfo.lowest_stack = (unsigned long)task_stack_page(p) + 2 * sizeof(unsigned long);
28011 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
28012
28013 if (unlikely(p->flags & PF_KTHREAD)) {
28014 /* kernel thread */
28015 memset(childregs, 0, sizeof(struct pt_regs));
28016 p->thread.ip = (unsigned long) ret_from_kernel_thread;
28017- task_user_gs(p) = __KERNEL_STACK_CANARY;
28018- childregs->ds = __USER_DS;
28019- childregs->es = __USER_DS;
28020+ savesegment(gs, childregs->gs);
28021+ childregs->ds = __KERNEL_DS;
28022+ childregs->es = __KERNEL_DS;
28023 childregs->fs = __KERNEL_PERCPU;
28024 childregs->bx = sp; /* function */
28025 childregs->bp = arg;
28026@@ -245,7 +246,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28027 struct fpu *prev_fpu = &prev->fpu;
28028 struct fpu *next_fpu = &next->fpu;
28029 int cpu = smp_processor_id();
28030- struct tss_struct *tss = &per_cpu(cpu_tss, cpu);
28031+ struct tss_struct *tss = cpu_tss + cpu;
28032 fpu_switch_t fpu_switch;
28033
28034 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
28035@@ -264,6 +265,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28036 */
28037 lazy_save_gs(prev->gs);
28038
28039+#ifdef CONFIG_PAX_MEMORY_UDEREF
28040+ __set_fs(task_thread_info(next_p)->addr_limit);
28041+#endif
28042+
28043 /*
28044 * Load the per-thread Thread-Local Storage descriptor.
28045 */
28046@@ -307,9 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28047 * current_thread_info().
28048 */
28049 load_sp0(tss, next);
28050- this_cpu_write(cpu_current_top_of_stack,
28051- (unsigned long)task_stack_page(next_p) +
28052- THREAD_SIZE);
28053+ this_cpu_write(current_task, next_p);
28054+ this_cpu_write(current_tinfo, &next_p->tinfo);
28055+ this_cpu_write(cpu_current_top_of_stack, next->sp0);
28056
28057 /*
28058 * Restore %gs if needed (which is common)
28059@@ -319,8 +324,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28060
28061 switch_fpu_finish(next_fpu, fpu_switch);
28062
28063- this_cpu_write(current_task, next_p);
28064-
28065 return prev_p;
28066 }
28067
28068@@ -350,4 +353,3 @@ unsigned long get_wchan(struct task_struct *p)
28069 } while (count++ < 16);
28070 return 0;
28071 }
28072-
28073diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
28074index a90ac95..ebac33e 100644
28075--- a/arch/x86/kernel/process_64.c
28076+++ b/arch/x86/kernel/process_64.c
28077@@ -157,9 +157,10 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long sp,
28078 struct pt_regs *childregs;
28079 struct task_struct *me = current;
28080
28081- p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
28082+ p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
28083 childregs = task_pt_regs(p);
28084 p->thread.sp = (unsigned long) childregs;
28085+ p->tinfo.lowest_stack = (unsigned long)task_stack_page(p) + 2 * sizeof(unsigned long);
28086 set_tsk_thread_flag(p, TIF_FORK);
28087 p->thread.io_bitmap_ptr = NULL;
28088
28089@@ -169,6 +170,8 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long sp,
28090 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
28091 savesegment(es, p->thread.es);
28092 savesegment(ds, p->thread.ds);
28093+ savesegment(ss, p->thread.ss);
28094+ BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
28095 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
28096
28097 if (unlikely(p->flags & PF_KTHREAD)) {
28098@@ -276,7 +279,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28099 struct fpu *prev_fpu = &prev->fpu;
28100 struct fpu *next_fpu = &next->fpu;
28101 int cpu = smp_processor_id();
28102- struct tss_struct *tss = &per_cpu(cpu_tss, cpu);
28103+ struct tss_struct *tss = cpu_tss + cpu;
28104 unsigned fsindex, gsindex;
28105 fpu_switch_t fpu_switch;
28106
28107@@ -327,6 +330,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28108 if (unlikely(next->ds | prev->ds))
28109 loadsegment(ds, next->ds);
28110
28111+ savesegment(ss, prev->ss);
28112+ if (unlikely(next->ss != prev->ss))
28113+ loadsegment(ss, next->ss);
28114+
28115 /*
28116 * Switch FS and GS.
28117 *
28118@@ -398,6 +405,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28119 * Switch the PDA and FPU contexts.
28120 */
28121 this_cpu_write(current_task, next_p);
28122+ this_cpu_write(current_tinfo, &next_p->tinfo);
28123
28124 /*
28125 * If it were not for PREEMPT_ACTIVE we could guarantee that the
28126@@ -410,6 +418,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
28127 /* Reload esp0 and ss1. This changes current_thread_info(). */
28128 load_sp0(tss, next);
28129
28130+ this_cpu_write(cpu_current_top_of_stack, next->sp0);
28131+
28132 /*
28133 * Now maybe reload the debug registers and handle I/O bitmaps
28134 */
28135@@ -510,7 +520,6 @@ unsigned long get_wchan(struct task_struct *p)
28136
28137 if (!p || p == current || p->state == TASK_RUNNING)
28138 return 0;
28139-
28140 start = (unsigned long)task_stack_page(p);
28141 if (!start)
28142 return 0;
28143@@ -535,7 +544,10 @@ unsigned long get_wchan(struct task_struct *p)
28144 */
28145 top = start + THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING;
28146 top -= 2 * sizeof(unsigned long);
28147- bottom = start + sizeof(struct thread_info);
28148+ /* not adding sizeof(thread_info) since it's not located on the stack
28149+ with PaX patched in
28150+ */
28151+ bottom = start;
28152
28153 sp = READ_ONCE(p->thread.sp);
28154 if (sp < bottom || sp > top)
28155diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
28156index 9be72bc..f4329c5 100644
28157--- a/arch/x86/kernel/ptrace.c
28158+++ b/arch/x86/kernel/ptrace.c
28159@@ -186,10 +186,10 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
28160 unsigned long sp = (unsigned long)&regs->sp;
28161 u32 *prev_esp;
28162
28163- if (context == (sp & ~(THREAD_SIZE - 1)))
28164+ if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
28165 return sp;
28166
28167- prev_esp = (u32 *)(context);
28168+ prev_esp = *(u32 **)(context);
28169 if (prev_esp)
28170 return (unsigned long)prev_esp;
28171
28172@@ -446,6 +446,20 @@ static int putreg(struct task_struct *child,
28173 if (child->thread.gs != value)
28174 return do_arch_prctl(child, ARCH_SET_GS, value);
28175 return 0;
28176+
28177+ case offsetof(struct user_regs_struct,ip):
28178+ /*
28179+ * Protect against any attempt to set ip to an
28180+ * impossible address. There are dragons lurking if the
28181+ * address is noncanonical. (This explicitly allows
28182+ * setting ip to TASK_SIZE_MAX, because user code can do
28183+ * that all by itself by running off the end of its
28184+ * address space.
28185+ */
28186+ if (value > TASK_SIZE_MAX)
28187+ return -EIO;
28188+ break;
28189+
28190 #endif
28191 }
28192
28193@@ -582,7 +596,7 @@ static void ptrace_triggered(struct perf_event *bp,
28194 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
28195 {
28196 int i;
28197- int dr7 = 0;
28198+ unsigned long dr7 = 0;
28199 struct arch_hw_breakpoint *info;
28200
28201 for (i = 0; i < HBP_NUM; i++) {
28202@@ -816,7 +830,7 @@ long arch_ptrace(struct task_struct *child, long request,
28203 unsigned long addr, unsigned long data)
28204 {
28205 int ret;
28206- unsigned long __user *datap = (unsigned long __user *)data;
28207+ unsigned long __user *datap = (__force unsigned long __user *)data;
28208
28209 switch (request) {
28210 /* read the word at location addr in the USER area. */
28211@@ -901,14 +915,14 @@ long arch_ptrace(struct task_struct *child, long request,
28212 if ((int) addr < 0)
28213 return -EIO;
28214 ret = do_get_thread_area(child, addr,
28215- (struct user_desc __user *)data);
28216+ (__force struct user_desc __user *) data);
28217 break;
28218
28219 case PTRACE_SET_THREAD_AREA:
28220 if ((int) addr < 0)
28221 return -EIO;
28222 ret = do_set_thread_area(child, addr,
28223- (struct user_desc __user *)data, 0);
28224+ (__force struct user_desc __user *) data, 0);
28225 break;
28226 #endif
28227
28228@@ -1286,7 +1300,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
28229
28230 #ifdef CONFIG_X86_64
28231
28232-static struct user_regset x86_64_regsets[] __read_mostly = {
28233+static user_regset_no_const x86_64_regsets[] __read_only = {
28234 [REGSET_GENERAL] = {
28235 .core_note_type = NT_PRSTATUS,
28236 .n = sizeof(struct user_regs_struct) / sizeof(long),
28237@@ -1327,7 +1341,7 @@ static const struct user_regset_view user_x86_64_view = {
28238 #endif /* CONFIG_X86_64 */
28239
28240 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
28241-static struct user_regset x86_32_regsets[] __read_mostly = {
28242+static user_regset_no_const x86_32_regsets[] __read_only = {
28243 [REGSET_GENERAL] = {
28244 .core_note_type = NT_PRSTATUS,
28245 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
28246@@ -1380,7 +1394,7 @@ static const struct user_regset_view user_x86_32_view = {
28247 */
28248 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
28249
28250-void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
28251+void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
28252 {
28253 #ifdef CONFIG_X86_64
28254 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
28255@@ -1415,7 +1429,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
28256 memset(info, 0, sizeof(*info));
28257 info->si_signo = SIGTRAP;
28258 info->si_code = si_code;
28259- info->si_addr = user_mode(regs) ? (void __user *)regs->ip : NULL;
28260+ info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
28261 }
28262
28263 void user_single_step_siginfo(struct task_struct *tsk,
28264@@ -1449,6 +1463,10 @@ static void do_audit_syscall_entry(struct pt_regs *regs, u32 arch)
28265 }
28266 }
28267
28268+#ifdef CONFIG_GRKERNSEC_SETXID
28269+extern void gr_delayed_cred_worker(void);
28270+#endif
28271+
28272 /*
28273 * We can return 0 to resume the syscall or anything else to go to phase
28274 * 2. If we resume the syscall, we need to put something appropriate in
28275@@ -1556,6 +1574,11 @@ long syscall_trace_enter_phase2(struct pt_regs *regs, u32 arch,
28276
28277 BUG_ON(regs != task_pt_regs(current));
28278
28279+#ifdef CONFIG_GRKERNSEC_SETXID
28280+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
28281+ gr_delayed_cred_worker();
28282+#endif
28283+
28284 /*
28285 * If we stepped into a sysenter/syscall insn, it trapped in
28286 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
28287@@ -1614,6 +1637,11 @@ void syscall_trace_leave(struct pt_regs *regs)
28288 */
28289 user_exit();
28290
28291+#ifdef CONFIG_GRKERNSEC_SETXID
28292+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
28293+ gr_delayed_cred_worker();
28294+#endif
28295+
28296 audit_syscall_exit(regs);
28297
28298 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
28299diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
28300index 2f355d2..e75ed0a 100644
28301--- a/arch/x86/kernel/pvclock.c
28302+++ b/arch/x86/kernel/pvclock.c
28303@@ -51,11 +51,11 @@ void pvclock_touch_watchdogs(void)
28304 reset_hung_task_detector();
28305 }
28306
28307-static atomic64_t last_value = ATOMIC64_INIT(0);
28308+static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
28309
28310 void pvclock_resume(void)
28311 {
28312- atomic64_set(&last_value, 0);
28313+ atomic64_set_unchecked(&last_value, 0);
28314 }
28315
28316 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
28317@@ -105,11 +105,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
28318 * updating at the same time, and one of them could be slightly behind,
28319 * making the assumption that last_value always go forward fail to hold.
28320 */
28321- last = atomic64_read(&last_value);
28322+ last = atomic64_read_unchecked(&last_value);
28323 do {
28324 if (ret < last)
28325 return last;
28326- last = atomic64_cmpxchg(&last_value, last, ret);
28327+ last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
28328 } while (unlikely(last != ret));
28329
28330 return ret;
28331diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
28332index 86db4bc..a50a54a 100644
28333--- a/arch/x86/kernel/reboot.c
28334+++ b/arch/x86/kernel/reboot.c
28335@@ -70,6 +70,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
28336
28337 void __noreturn machine_real_restart(unsigned int type)
28338 {
28339+
28340+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
28341+ struct desc_struct *gdt;
28342+#endif
28343+
28344 local_irq_disable();
28345
28346 /*
28347@@ -97,7 +102,29 @@ void __noreturn machine_real_restart(unsigned int type)
28348
28349 /* Jump to the identity-mapped low memory code */
28350 #ifdef CONFIG_X86_32
28351- asm volatile("jmpl *%0" : :
28352+
28353+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
28354+ gdt = get_cpu_gdt_table(smp_processor_id());
28355+ pax_open_kernel();
28356+#ifdef CONFIG_PAX_MEMORY_UDEREF
28357+ gdt[GDT_ENTRY_KERNEL_DS].type = 3;
28358+ gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
28359+ loadsegment(ds, __KERNEL_DS);
28360+ loadsegment(es, __KERNEL_DS);
28361+ loadsegment(ss, __KERNEL_DS);
28362+#endif
28363+#ifdef CONFIG_PAX_KERNEXEC
28364+ gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
28365+ gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
28366+ gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
28367+ gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
28368+ gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
28369+ gdt[GDT_ENTRY_KERNEL_CS].g = 1;
28370+#endif
28371+ pax_close_kernel();
28372+#endif
28373+
28374+ asm volatile("ljmpl *%0" : :
28375 "rm" (real_mode_header->machine_real_restart_asm),
28376 "a" (type));
28377 #else
28378@@ -137,7 +164,7 @@ static int __init set_kbd_reboot(const struct dmi_system_id *d)
28379 /*
28380 * This is a single dmi_table handling all reboot quirks.
28381 */
28382-static struct dmi_system_id __initdata reboot_dmi_table[] = {
28383+static const struct dmi_system_id __initconst reboot_dmi_table[] = {
28384
28385 /* Acer */
28386 { /* Handle reboot issue on Acer Aspire one */
28387@@ -511,7 +538,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
28388 * This means that this function can never return, it can misbehave
28389 * by not rebooting properly and hanging.
28390 */
28391-static void native_machine_emergency_restart(void)
28392+static void __noreturn native_machine_emergency_restart(void)
28393 {
28394 int i;
28395 int attempt = 0;
28396@@ -631,13 +658,13 @@ void native_machine_shutdown(void)
28397 #endif
28398 }
28399
28400-static void __machine_emergency_restart(int emergency)
28401+static void __noreturn __machine_emergency_restart(int emergency)
28402 {
28403 reboot_emergency = emergency;
28404 machine_ops.emergency_restart();
28405 }
28406
28407-static void native_machine_restart(char *__unused)
28408+static void __noreturn native_machine_restart(char *__unused)
28409 {
28410 pr_notice("machine restart\n");
28411
28412@@ -646,7 +673,7 @@ static void native_machine_restart(char *__unused)
28413 __machine_emergency_restart(0);
28414 }
28415
28416-static void native_machine_halt(void)
28417+static void __noreturn native_machine_halt(void)
28418 {
28419 /* Stop other cpus and apics */
28420 machine_shutdown();
28421@@ -656,7 +683,7 @@ static void native_machine_halt(void)
28422 stop_this_cpu(NULL);
28423 }
28424
28425-static void native_machine_power_off(void)
28426+static void __noreturn native_machine_power_off(void)
28427 {
28428 if (pm_power_off) {
28429 if (!reboot_force)
28430@@ -665,9 +692,10 @@ static void native_machine_power_off(void)
28431 }
28432 /* A fallback in case there is no PM info available */
28433 tboot_shutdown(TB_SHUTDOWN_HALT);
28434+ unreachable();
28435 }
28436
28437-struct machine_ops machine_ops = {
28438+struct machine_ops machine_ops __read_only = {
28439 .power_off = native_machine_power_off,
28440 .shutdown = native_machine_shutdown,
28441 .emergency_restart = native_machine_emergency_restart,
28442diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
28443index c8e41e9..64049ef 100644
28444--- a/arch/x86/kernel/reboot_fixups_32.c
28445+++ b/arch/x86/kernel/reboot_fixups_32.c
28446@@ -57,7 +57,7 @@ struct device_fixup {
28447 unsigned int vendor;
28448 unsigned int device;
28449 void (*reboot_fixup)(struct pci_dev *);
28450-};
28451+} __do_const;
28452
28453 /*
28454 * PCI ids solely used for fixups_table go here
28455diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
28456index 98111b3..73ca125 100644
28457--- a/arch/x86/kernel/relocate_kernel_64.S
28458+++ b/arch/x86/kernel/relocate_kernel_64.S
28459@@ -96,8 +96,7 @@ relocate_kernel:
28460
28461 /* jump to identity mapped page */
28462 addq $(identity_mapped - relocate_kernel), %r8
28463- pushq %r8
28464- ret
28465+ jmp *%r8
28466
28467 identity_mapped:
28468 /* set return address to 0 if not preserving context */
28469diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
28470index 80f874b..b3eff67 100644
28471--- a/arch/x86/kernel/setup.c
28472+++ b/arch/x86/kernel/setup.c
28473@@ -111,6 +111,7 @@
28474 #include <asm/mce.h>
28475 #include <asm/alternative.h>
28476 #include <asm/prom.h>
28477+#include <asm/boot.h>
28478
28479 /*
28480 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
28481@@ -206,10 +207,12 @@ EXPORT_SYMBOL(boot_cpu_data);
28482 #endif
28483
28484
28485-#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
28486-__visible unsigned long mmu_cr4_features;
28487+#ifdef CONFIG_X86_64
28488+__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
28489+#elif defined(CONFIG_X86_PAE)
28490+__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
28491 #else
28492-__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
28493+__visible unsigned long mmu_cr4_features __read_only;
28494 #endif
28495
28496 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
28497@@ -772,7 +775,7 @@ static void __init trim_bios_range(void)
28498 * area (640->1Mb) as ram even though it is not.
28499 * take them out.
28500 */
28501- e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
28502+ e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
28503
28504 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
28505 }
28506@@ -780,7 +783,7 @@ static void __init trim_bios_range(void)
28507 /* called before trim_bios_range() to spare extra sanitize */
28508 static void __init e820_add_kernel_range(void)
28509 {
28510- u64 start = __pa_symbol(_text);
28511+ u64 start = __pa_symbol(ktla_ktva((unsigned long)_text));
28512 u64 size = __pa_symbol(_end) - start;
28513
28514 /*
28515@@ -861,8 +864,8 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
28516
28517 void __init setup_arch(char **cmdline_p)
28518 {
28519- memblock_reserve(__pa_symbol(_text),
28520- (unsigned long)__bss_stop - (unsigned long)_text);
28521+ memblock_reserve(__pa_symbol(ktla_ktva((unsigned long)_text)),
28522+ (unsigned long)__bss_stop - ktla_ktva((unsigned long)_text));
28523
28524 early_reserve_initrd();
28525
28526@@ -960,16 +963,16 @@ void __init setup_arch(char **cmdline_p)
28527
28528 if (!boot_params.hdr.root_flags)
28529 root_mountflags &= ~MS_RDONLY;
28530- init_mm.start_code = (unsigned long) _text;
28531- init_mm.end_code = (unsigned long) _etext;
28532- init_mm.end_data = (unsigned long) _edata;
28533+ init_mm.start_code = ktla_ktva((unsigned long)_text);
28534+ init_mm.end_code = ktla_ktva((unsigned long)_etext);
28535+ init_mm.end_data = (unsigned long)_edata;
28536 init_mm.brk = _brk_end;
28537
28538 mpx_mm_init(&init_mm);
28539
28540- code_resource.start = __pa_symbol(_text);
28541- code_resource.end = __pa_symbol(_etext)-1;
28542- data_resource.start = __pa_symbol(_etext);
28543+ code_resource.start = __pa_symbol(ktla_ktva((unsigned long)_text));
28544+ code_resource.end = __pa_symbol(ktla_ktva((unsigned long)_etext))-1;
28545+ data_resource.start = __pa_symbol(_sdata);
28546 data_resource.end = __pa_symbol(_edata)-1;
28547 bss_resource.start = __pa_symbol(__bss_start);
28548 bss_resource.end = __pa_symbol(__bss_stop)-1;
28549diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
28550index e4fcb87..9c06c55 100644
28551--- a/arch/x86/kernel/setup_percpu.c
28552+++ b/arch/x86/kernel/setup_percpu.c
28553@@ -21,19 +21,17 @@
28554 #include <asm/cpu.h>
28555 #include <asm/stackprotector.h>
28556
28557-DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
28558+#ifdef CONFIG_SMP
28559+DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
28560 EXPORT_PER_CPU_SYMBOL(cpu_number);
28561+#endif
28562
28563-#ifdef CONFIG_X86_64
28564 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
28565-#else
28566-#define BOOT_PERCPU_OFFSET 0
28567-#endif
28568
28569 DEFINE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
28570 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
28571
28572-unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
28573+unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
28574 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
28575 };
28576 EXPORT_SYMBOL(__per_cpu_offset);
28577@@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
28578 {
28579 #ifdef CONFIG_NEED_MULTIPLE_NODES
28580 pg_data_t *last = NULL;
28581- unsigned int cpu;
28582+ int cpu;
28583
28584 for_each_possible_cpu(cpu) {
28585 int node = early_cpu_to_node(cpu);
28586@@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
28587 {
28588 #ifdef CONFIG_X86_32
28589 struct desc_struct gdt;
28590+ unsigned long base = per_cpu_offset(cpu);
28591
28592- pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
28593- 0x2 | DESCTYPE_S, 0x8);
28594- gdt.s = 1;
28595+ pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
28596+ 0x83 | DESCTYPE_S, 0xC);
28597 write_gdt_entry(get_cpu_gdt_table(cpu),
28598 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
28599 #endif
28600@@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
28601 /* alrighty, percpu areas up and running */
28602 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
28603 for_each_possible_cpu(cpu) {
28604+#ifdef CONFIG_CC_STACKPROTECTOR
28605+#ifdef CONFIG_X86_32
28606+ unsigned long canary = per_cpu(stack_canary.canary, cpu);
28607+#endif
28608+#endif
28609 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
28610 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
28611 per_cpu(cpu_number, cpu) = cpu;
28612@@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
28613 */
28614 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
28615 #endif
28616+#ifdef CONFIG_CC_STACKPROTECTOR
28617+#ifdef CONFIG_X86_32
28618+ if (!cpu)
28619+ per_cpu(stack_canary.canary, cpu) = canary;
28620+#endif
28621+#endif
28622 /*
28623 * Up to this point, the boot CPU has been using .init.data
28624 * area. Reload any changed state for the boot CPU.
28625diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
28626index 71820c4..ad16f6b 100644
28627--- a/arch/x86/kernel/signal.c
28628+++ b/arch/x86/kernel/signal.c
28629@@ -189,7 +189,7 @@ static unsigned long align_sigframe(unsigned long sp)
28630 * Align the stack pointer according to the i386 ABI,
28631 * i.e. so that on function entry ((sp + 4) & 15) == 0.
28632 */
28633- sp = ((sp + 4) & -16ul) - 4;
28634+ sp = ((sp - 12) & -16ul) - 4;
28635 #else /* !CONFIG_X86_32 */
28636 sp = round_down(sp, 16) - 8;
28637 #endif
28638@@ -298,10 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
28639 }
28640
28641 if (current->mm->context.vdso)
28642- restorer = current->mm->context.vdso +
28643- selected_vdso32->sym___kernel_sigreturn;
28644+ restorer = (void __force_user *)(current->mm->context.vdso + selected_vdso32->sym___kernel_sigreturn);
28645 else
28646- restorer = &frame->retcode;
28647+ restorer = (void __user *)&frame->retcode;
28648 if (ksig->ka.sa.sa_flags & SA_RESTORER)
28649 restorer = ksig->ka.sa.sa_restorer;
28650
28651@@ -315,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
28652 * reasons and because gdb uses it as a signature to notice
28653 * signal handler stack frames.
28654 */
28655- err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
28656+ err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
28657
28658 if (err)
28659 return -EFAULT;
28660@@ -362,8 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
28661 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
28662
28663 /* Set up to return from userspace. */
28664- restorer = current->mm->context.vdso +
28665- selected_vdso32->sym___kernel_rt_sigreturn;
28666+ if (current->mm->context.vdso)
28667+ restorer = (void __force_user *)(current->mm->context.vdso + selected_vdso32->sym___kernel_rt_sigreturn);
28668+ else
28669+ restorer = (void __user *)&frame->retcode;
28670 if (ksig->ka.sa.sa_flags & SA_RESTORER)
28671 restorer = ksig->ka.sa.sa_restorer;
28672 put_user_ex(restorer, &frame->pretcode);
28673@@ -375,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
28674 * reasons and because gdb uses it as a signature to notice
28675 * signal handler stack frames.
28676 */
28677- put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
28678+ put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
28679 } put_user_catch(err);
28680
28681 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
28682@@ -611,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
28683 {
28684 int usig = ksig->sig;
28685 sigset_t *set = sigmask_to_save();
28686- compat_sigset_t *cset = (compat_sigset_t *) set;
28687+ sigset_t sigcopy;
28688+ compat_sigset_t *cset;
28689+
28690+ sigcopy = *set;
28691+
28692+ cset = (compat_sigset_t *) &sigcopy;
28693
28694 /* Set up the stack frame */
28695 if (is_ia32_frame()) {
28696@@ -622,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
28697 } else if (is_x32_frame()) {
28698 return x32_setup_rt_frame(ksig, cset, regs);
28699 } else {
28700- return __setup_rt_frame(ksig->sig, ksig, set, regs);
28701+ return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
28702 }
28703 }
28704
28705diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
28706index 15aaa69..66103af 100644
28707--- a/arch/x86/kernel/smp.c
28708+++ b/arch/x86/kernel/smp.c
28709@@ -334,7 +334,7 @@ static int __init nonmi_ipi_setup(char *str)
28710
28711 __setup("nonmi_ipi", nonmi_ipi_setup);
28712
28713-struct smp_ops smp_ops = {
28714+struct smp_ops smp_ops __read_only = {
28715 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
28716 .smp_prepare_cpus = native_smp_prepare_cpus,
28717 .smp_cpus_done = native_smp_cpus_done,
28718diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
28719index b1f3ed9c..b76221b 100644
28720--- a/arch/x86/kernel/smpboot.c
28721+++ b/arch/x86/kernel/smpboot.c
28722@@ -220,14 +220,17 @@ static void notrace start_secondary(void *unused)
28723
28724 enable_start_cpu0 = 0;
28725
28726-#ifdef CONFIG_X86_32
28727+ /* otherwise gcc will move up smp_processor_id before the cpu_init */
28728+ barrier();
28729+
28730 /* switch away from the initial page table */
28731+#ifdef CONFIG_PAX_PER_CPU_PGD
28732+ load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
28733+#else
28734 load_cr3(swapper_pg_dir);
28735+#endif
28736 __flush_tlb_all();
28737-#endif
28738
28739- /* otherwise gcc will move up smp_processor_id before the cpu_init */
28740- barrier();
28741 /*
28742 * Check TSC synchronization with the BP:
28743 */
28744@@ -808,16 +811,15 @@ void common_cpu_up(unsigned int cpu, struct task_struct *idle)
28745 alternatives_enable_smp();
28746
28747 per_cpu(current_task, cpu) = idle;
28748+ per_cpu(current_tinfo, cpu) = &idle->tinfo;
28749
28750 #ifdef CONFIG_X86_32
28751- /* Stack for startup_32 can be just as for start_secondary onwards */
28752 irq_ctx_init(cpu);
28753- per_cpu(cpu_current_top_of_stack, cpu) =
28754- (unsigned long)task_stack_page(idle) + THREAD_SIZE;
28755 #else
28756 clear_tsk_thread_flag(idle, TIF_FORK);
28757 initial_gs = per_cpu_offset(cpu);
28758 #endif
28759+ per_cpu(cpu_current_top_of_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
28760 }
28761
28762 /*
28763@@ -838,9 +840,11 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
28764 unsigned long timeout;
28765
28766 idle->thread.sp = (unsigned long) (((struct pt_regs *)
28767- (THREAD_SIZE + task_stack_page(idle))) - 1);
28768+ (THREAD_SIZE - 16 + task_stack_page(idle))) - 1);
28769
28770+ pax_open_kernel();
28771 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
28772+ pax_close_kernel();
28773 initial_code = (unsigned long)start_secondary;
28774 stack_start = idle->thread.sp;
28775
28776@@ -992,6 +996,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
28777
28778 common_cpu_up(cpu, tidle);
28779
28780+#ifdef CONFIG_PAX_PER_CPU_PGD
28781+ clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
28782+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28783+ KERNEL_PGD_PTRS);
28784+ clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
28785+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28786+ KERNEL_PGD_PTRS);
28787+#endif
28788+
28789 /*
28790 * We have to walk the irq descriptors to setup the vector
28791 * space for the cpu which comes online. Prevent irq
28792diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
28793index 0ccb53a..fbc4759 100644
28794--- a/arch/x86/kernel/step.c
28795+++ b/arch/x86/kernel/step.c
28796@@ -44,7 +44,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
28797 addr += base;
28798 }
28799 mutex_unlock(&child->mm->context.lock);
28800- }
28801+ } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
28802+ addr = ktla_ktva(addr);
28803
28804 return addr;
28805 }
28806@@ -55,6 +56,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
28807 unsigned char opcode[15];
28808 unsigned long addr = convert_ip_to_linear(child, regs);
28809
28810+ if (addr == -EINVAL)
28811+ return 0;
28812+
28813 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
28814 for (i = 0; i < copied; i++) {
28815 switch (opcode[i]) {
28816diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
28817new file mode 100644
28818index 0000000..5877189
28819--- /dev/null
28820+++ b/arch/x86/kernel/sys_i386_32.c
28821@@ -0,0 +1,189 @@
28822+/*
28823+ * This file contains various random system calls that
28824+ * have a non-standard calling sequence on the Linux/i386
28825+ * platform.
28826+ */
28827+
28828+#include <linux/errno.h>
28829+#include <linux/sched.h>
28830+#include <linux/mm.h>
28831+#include <linux/fs.h>
28832+#include <linux/smp.h>
28833+#include <linux/sem.h>
28834+#include <linux/msg.h>
28835+#include <linux/shm.h>
28836+#include <linux/stat.h>
28837+#include <linux/syscalls.h>
28838+#include <linux/mman.h>
28839+#include <linux/file.h>
28840+#include <linux/utsname.h>
28841+#include <linux/ipc.h>
28842+#include <linux/elf.h>
28843+
28844+#include <linux/uaccess.h>
28845+#include <linux/unistd.h>
28846+
28847+#include <asm/syscalls.h>
28848+
28849+int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
28850+{
28851+ unsigned long pax_task_size = TASK_SIZE;
28852+
28853+#ifdef CONFIG_PAX_SEGMEXEC
28854+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
28855+ pax_task_size = SEGMEXEC_TASK_SIZE;
28856+#endif
28857+
28858+ if (flags & MAP_FIXED)
28859+ if (len > pax_task_size || addr > pax_task_size - len)
28860+ return -EINVAL;
28861+
28862+ return 0;
28863+}
28864+
28865+/*
28866+ * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
28867+ */
28868+static unsigned long get_align_mask(void)
28869+{
28870+ if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
28871+ return 0;
28872+
28873+ if (!(current->flags & PF_RANDOMIZE))
28874+ return 0;
28875+
28876+ return va_align.mask;
28877+}
28878+
28879+unsigned long
28880+arch_get_unmapped_area(struct file *filp, unsigned long addr,
28881+ unsigned long len, unsigned long pgoff, unsigned long flags)
28882+{
28883+ struct mm_struct *mm = current->mm;
28884+ struct vm_area_struct *vma;
28885+ unsigned long pax_task_size = TASK_SIZE;
28886+ struct vm_unmapped_area_info info;
28887+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28888+
28889+#ifdef CONFIG_PAX_SEGMEXEC
28890+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
28891+ pax_task_size = SEGMEXEC_TASK_SIZE;
28892+#endif
28893+
28894+ pax_task_size -= PAGE_SIZE;
28895+
28896+ if (len > pax_task_size)
28897+ return -ENOMEM;
28898+
28899+ if (flags & MAP_FIXED)
28900+ return addr;
28901+
28902+#ifdef CONFIG_PAX_RANDMMAP
28903+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28904+#endif
28905+
28906+ if (addr) {
28907+ addr = PAGE_ALIGN(addr);
28908+ if (pax_task_size - len >= addr) {
28909+ vma = find_vma(mm, addr);
28910+ if (check_heap_stack_gap(vma, addr, len, offset))
28911+ return addr;
28912+ }
28913+ }
28914+
28915+ info.flags = 0;
28916+ info.length = len;
28917+ info.align_mask = filp ? get_align_mask() : 0;
28918+ info.align_offset = pgoff << PAGE_SHIFT;
28919+ info.threadstack_offset = offset;
28920+
28921+#ifdef CONFIG_PAX_PAGEEXEC
28922+ if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
28923+ info.low_limit = 0x00110000UL;
28924+ info.high_limit = mm->start_code;
28925+
28926+#ifdef CONFIG_PAX_RANDMMAP
28927+ if (mm->pax_flags & MF_PAX_RANDMMAP)
28928+ info.low_limit += mm->delta_mmap & 0x03FFF000UL;
28929+#endif
28930+
28931+ if (info.low_limit < info.high_limit) {
28932+ addr = vm_unmapped_area(&info);
28933+ if (!IS_ERR_VALUE(addr))
28934+ return addr;
28935+ }
28936+ } else
28937+#endif
28938+
28939+ info.low_limit = mm->mmap_base;
28940+ info.high_limit = pax_task_size;
28941+
28942+ return vm_unmapped_area(&info);
28943+}
28944+
28945+unsigned long
28946+arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28947+ const unsigned long len, const unsigned long pgoff,
28948+ const unsigned long flags)
28949+{
28950+ struct vm_area_struct *vma;
28951+ struct mm_struct *mm = current->mm;
28952+ unsigned long addr = addr0, pax_task_size = TASK_SIZE;
28953+ struct vm_unmapped_area_info info;
28954+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28955+
28956+#ifdef CONFIG_PAX_SEGMEXEC
28957+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
28958+ pax_task_size = SEGMEXEC_TASK_SIZE;
28959+#endif
28960+
28961+ pax_task_size -= PAGE_SIZE;
28962+
28963+ /* requested length too big for entire address space */
28964+ if (len > pax_task_size)
28965+ return -ENOMEM;
28966+
28967+ if (flags & MAP_FIXED)
28968+ return addr;
28969+
28970+#ifdef CONFIG_PAX_PAGEEXEC
28971+ if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
28972+ goto bottomup;
28973+#endif
28974+
28975+#ifdef CONFIG_PAX_RANDMMAP
28976+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28977+#endif
28978+
28979+ /* requesting a specific address */
28980+ if (addr) {
28981+ addr = PAGE_ALIGN(addr);
28982+ if (pax_task_size - len >= addr) {
28983+ vma = find_vma(mm, addr);
28984+ if (check_heap_stack_gap(vma, addr, len, offset))
28985+ return addr;
28986+ }
28987+ }
28988+
28989+ info.flags = VM_UNMAPPED_AREA_TOPDOWN;
28990+ info.length = len;
28991+ info.low_limit = PAGE_SIZE;
28992+ info.high_limit = mm->mmap_base;
28993+ info.align_mask = filp ? get_align_mask() : 0;
28994+ info.align_offset = pgoff << PAGE_SHIFT;
28995+ info.threadstack_offset = offset;
28996+
28997+ addr = vm_unmapped_area(&info);
28998+ if (!(addr & ~PAGE_MASK))
28999+ return addr;
29000+ VM_BUG_ON(addr != -ENOMEM);
29001+
29002+bottomup:
29003+ /*
29004+ * A failed mmap() very likely causes application failure,
29005+ * so fall back to the bottom-up function here. This scenario
29006+ * can happen with large stack limits and large mmap()
29007+ * allocations.
29008+ */
29009+ return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
29010+}
29011diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
29012index 10e0272..b4bb9a7 100644
29013--- a/arch/x86/kernel/sys_x86_64.c
29014+++ b/arch/x86/kernel/sys_x86_64.c
29015@@ -97,8 +97,8 @@ out:
29016 return error;
29017 }
29018
29019-static void find_start_end(unsigned long flags, unsigned long *begin,
29020- unsigned long *end)
29021+static void find_start_end(struct mm_struct *mm, unsigned long flags,
29022+ unsigned long *begin, unsigned long *end)
29023 {
29024 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
29025 unsigned long new_begin;
29026@@ -117,7 +117,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
29027 *begin = new_begin;
29028 }
29029 } else {
29030- *begin = current->mm->mmap_legacy_base;
29031+ *begin = mm->mmap_legacy_base;
29032 *end = TASK_SIZE;
29033 }
29034 }
29035@@ -130,20 +130,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
29036 struct vm_area_struct *vma;
29037 struct vm_unmapped_area_info info;
29038 unsigned long begin, end;
29039+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
29040
29041 if (flags & MAP_FIXED)
29042 return addr;
29043
29044- find_start_end(flags, &begin, &end);
29045+ find_start_end(mm, flags, &begin, &end);
29046
29047 if (len > end)
29048 return -ENOMEM;
29049
29050+#ifdef CONFIG_PAX_RANDMMAP
29051+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
29052+#endif
29053+
29054 if (addr) {
29055 addr = PAGE_ALIGN(addr);
29056 vma = find_vma(mm, addr);
29057- if (end - len >= addr &&
29058- (!vma || addr + len <= vma->vm_start))
29059+ if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
29060 return addr;
29061 }
29062
29063@@ -157,6 +161,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
29064 info.align_mask = get_align_mask();
29065 info.align_offset += get_align_bits();
29066 }
29067+ info.threadstack_offset = offset;
29068 return vm_unmapped_area(&info);
29069 }
29070
29071@@ -169,6 +174,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
29072 struct mm_struct *mm = current->mm;
29073 unsigned long addr = addr0;
29074 struct vm_unmapped_area_info info;
29075+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
29076
29077 /* requested length too big for entire address space */
29078 if (len > TASK_SIZE)
29079@@ -181,12 +187,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
29080 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
29081 goto bottomup;
29082
29083+#ifdef CONFIG_PAX_RANDMMAP
29084+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
29085+#endif
29086+
29087 /* requesting a specific address */
29088 if (addr) {
29089 addr = PAGE_ALIGN(addr);
29090 vma = find_vma(mm, addr);
29091- if (TASK_SIZE - len >= addr &&
29092- (!vma || addr + len <= vma->vm_start))
29093+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
29094 return addr;
29095 }
29096
29097@@ -200,6 +209,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
29098 info.align_mask = get_align_mask();
29099 info.align_offset += get_align_bits();
29100 }
29101+ info.threadstack_offset = offset;
29102 addr = vm_unmapped_area(&info);
29103 if (!(addr & ~PAGE_MASK))
29104 return addr;
29105diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
29106index 91a4496..42fc304 100644
29107--- a/arch/x86/kernel/tboot.c
29108+++ b/arch/x86/kernel/tboot.c
29109@@ -44,6 +44,7 @@
29110 #include <asm/setup.h>
29111 #include <asm/e820.h>
29112 #include <asm/io.h>
29113+#include <asm/tlbflush.h>
29114
29115 #include "../realmode/rm/wakeup.h"
29116
29117@@ -221,7 +222,7 @@ static int tboot_setup_sleep(void)
29118
29119 void tboot_shutdown(u32 shutdown_type)
29120 {
29121- void (*shutdown)(void);
29122+ void (* __noreturn shutdown)(void);
29123
29124 if (!tboot_enabled())
29125 return;
29126@@ -242,8 +243,9 @@ void tboot_shutdown(u32 shutdown_type)
29127 tboot->shutdown_type = shutdown_type;
29128
29129 switch_to_tboot_pt();
29130+ cr4_clear_bits(X86_CR4_PCIDE);
29131
29132- shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
29133+ shutdown = (void *)(unsigned long)tboot->shutdown_entry;
29134 shutdown();
29135
29136 /* should not reach here */
29137@@ -310,7 +312,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
29138 return -ENODEV;
29139 }
29140
29141-static atomic_t ap_wfs_count;
29142+static atomic_unchecked_t ap_wfs_count;
29143
29144 static int tboot_wait_for_aps(int num_aps)
29145 {
29146@@ -334,9 +336,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
29147 {
29148 switch (action) {
29149 case CPU_DYING:
29150- atomic_inc(&ap_wfs_count);
29151+ atomic_inc_unchecked(&ap_wfs_count);
29152 if (num_online_cpus() == 1)
29153- if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
29154+ if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
29155 return NOTIFY_BAD;
29156 break;
29157 }
29158@@ -422,7 +424,7 @@ static __init int tboot_late_init(void)
29159
29160 tboot_create_trampoline();
29161
29162- atomic_set(&ap_wfs_count, 0);
29163+ atomic_set_unchecked(&ap_wfs_count, 0);
29164 register_hotcpu_notifier(&tboot_cpu_notifier);
29165
29166 #ifdef CONFIG_DEBUG_FS
29167diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
29168index d39c091..1df4349 100644
29169--- a/arch/x86/kernel/time.c
29170+++ b/arch/x86/kernel/time.c
29171@@ -32,7 +32,7 @@ unsigned long profile_pc(struct pt_regs *regs)
29172
29173 if (!user_mode(regs) && in_lock_functions(pc)) {
29174 #ifdef CONFIG_FRAME_POINTER
29175- return *(unsigned long *)(regs->bp + sizeof(long));
29176+ return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
29177 #else
29178 unsigned long *sp =
29179 (unsigned long *)kernel_stack_pointer(regs);
29180@@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
29181 * or above a saved flags. Eflags has bits 22-31 zero,
29182 * kernel addresses don't.
29183 */
29184+
29185+#ifdef CONFIG_PAX_KERNEXEC
29186+ return ktla_ktva(sp[0]);
29187+#else
29188 if (sp[0] >> 22)
29189 return sp[0];
29190 if (sp[1] >> 22)
29191 return sp[1];
29192 #endif
29193+
29194+#endif
29195 }
29196 return pc;
29197 }
29198diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
29199index 7fc5e84..c6e445a 100644
29200--- a/arch/x86/kernel/tls.c
29201+++ b/arch/x86/kernel/tls.c
29202@@ -139,6 +139,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
29203 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
29204 return -EINVAL;
29205
29206+#ifdef CONFIG_PAX_SEGMEXEC
29207+ if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
29208+ return -EINVAL;
29209+#endif
29210+
29211 set_tls_desc(p, idx, &info, 1);
29212
29213 return 0;
29214@@ -256,7 +261,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
29215
29216 if (kbuf)
29217 info = kbuf;
29218- else if (__copy_from_user(infobuf, ubuf, count))
29219+ else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
29220 return -EFAULT;
29221 else
29222 info = infobuf;
29223diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
29224index 1c113db..287b42e 100644
29225--- a/arch/x86/kernel/tracepoint.c
29226+++ b/arch/x86/kernel/tracepoint.c
29227@@ -9,11 +9,11 @@
29228 #include <linux/atomic.h>
29229
29230 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
29231-struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
29232+const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
29233 (unsigned long) trace_idt_table };
29234
29235 /* No need to be aligned, but done to keep all IDTs defined the same way. */
29236-gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
29237+gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
29238
29239 static int trace_irq_vector_refcount;
29240 static DEFINE_MUTEX(irq_vector_mutex);
29241diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
29242index f579192..aed90b8 100644
29243--- a/arch/x86/kernel/traps.c
29244+++ b/arch/x86/kernel/traps.c
29245@@ -69,7 +69,7 @@
29246 #include <asm/proto.h>
29247
29248 /* No need to be aligned, but done to keep all IDTs defined the same way. */
29249-gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
29250+gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
29251 #else
29252 #include <asm/processor-flags.h>
29253 #include <asm/setup.h>
29254@@ -77,7 +77,7 @@ gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
29255 #endif
29256
29257 /* Must be page-aligned because the real IDT is used in a fixmap. */
29258-gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
29259+gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
29260
29261 DECLARE_BITMAP(used_vectors, NR_VECTORS);
29262 EXPORT_SYMBOL_GPL(used_vectors);
29263@@ -174,7 +174,7 @@ void ist_begin_non_atomic(struct pt_regs *regs)
29264 * will catch asm bugs and any attempt to use ist_preempt_enable
29265 * from double_fault.
29266 */
29267- BUG_ON((unsigned long)(current_top_of_stack() -
29268+ BUG_ON((unsigned long)(current_top_of_stack(smp_processor_id()) -
29269 current_stack_pointer()) >= THREAD_SIZE);
29270
29271 preempt_count_sub(HARDIRQ_OFFSET);
29272@@ -191,7 +191,7 @@ void ist_end_non_atomic(void)
29273 }
29274
29275 static nokprobe_inline int
29276-do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
29277+do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
29278 struct pt_regs *regs, long error_code)
29279 {
29280 if (v8086_mode(regs)) {
29281@@ -211,8 +211,20 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
29282 if (!fixup_exception(regs)) {
29283 tsk->thread.error_code = error_code;
29284 tsk->thread.trap_nr = trapnr;
29285+
29286+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29287+ if (trapnr == X86_TRAP_SS && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
29288+ str = "PAX: suspicious stack segment fault";
29289+#endif
29290+
29291 die(str, regs, error_code);
29292 }
29293+
29294+#ifdef CONFIG_PAX_REFCOUNT
29295+ if (trapnr == X86_TRAP_OF)
29296+ pax_report_refcount_overflow(regs);
29297+#endif
29298+
29299 return 0;
29300 }
29301
29302@@ -251,7 +263,7 @@ static siginfo_t *fill_trap_info(struct pt_regs *regs, int signr, int trapnr,
29303 }
29304
29305 static void
29306-do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
29307+do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
29308 long error_code, siginfo_t *info)
29309 {
29310 struct task_struct *tsk = current;
29311@@ -275,7 +287,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
29312 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
29313 printk_ratelimit()) {
29314 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
29315- tsk->comm, tsk->pid, str,
29316+ tsk->comm, task_pid_nr(tsk), str,
29317 regs->ip, regs->sp, error_code);
29318 print_vma_addr(" in ", regs->ip);
29319 pr_cont("\n");
29320@@ -357,6 +369,11 @@ dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
29321 tsk->thread.error_code = error_code;
29322 tsk->thread.trap_nr = X86_TRAP_DF;
29323
29324+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
29325+ if ((unsigned long)tsk->stack - regs->sp <= PAGE_SIZE)
29326+ die("grsec: kernel stack overflow detected", regs, error_code);
29327+#endif
29328+
29329 #ifdef CONFIG_DOUBLEFAULT
29330 df_debug(regs, error_code);
29331 #endif
29332@@ -473,11 +490,35 @@ do_general_protection(struct pt_regs *regs, long error_code)
29333 tsk->thread.error_code = error_code;
29334 tsk->thread.trap_nr = X86_TRAP_GP;
29335 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
29336- X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
29337+ X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
29338+
29339+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29340+ if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
29341+ die("PAX: suspicious general protection fault", regs, error_code);
29342+ else
29343+#endif
29344+
29345 die("general protection fault", regs, error_code);
29346+ }
29347 goto exit;
29348 }
29349
29350+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
29351+ if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
29352+ struct mm_struct *mm = tsk->mm;
29353+ unsigned long limit;
29354+
29355+ down_write(&mm->mmap_sem);
29356+ limit = mm->context.user_cs_limit;
29357+ if (limit < TASK_SIZE) {
29358+ track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
29359+ up_write(&mm->mmap_sem);
29360+ return;
29361+ }
29362+ up_write(&mm->mmap_sem);
29363+ }
29364+#endif
29365+
29366 tsk->thread.error_code = error_code;
29367 tsk->thread.trap_nr = X86_TRAP_GP;
29368
29369@@ -576,6 +617,9 @@ struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s)
29370 container_of(task_pt_regs(current),
29371 struct bad_iret_stack, regs);
29372
29373+ if ((current->thread.sp0 ^ (unsigned long)s) < THREAD_SIZE)
29374+ new_stack = s;
29375+
29376 /* Copy the IRET target to the new stack. */
29377 memmove(&new_stack->regs.ip, (void *)s->regs.sp, 5*8);
29378
29379diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
29380index dc9af7a..1bc625e 100644
29381--- a/arch/x86/kernel/tsc.c
29382+++ b/arch/x86/kernel/tsc.c
29383@@ -151,7 +151,7 @@ static void cyc2ns_write_end(int cpu, struct cyc2ns_data *data)
29384 */
29385 smp_wmb();
29386
29387- ACCESS_ONCE(c2n->head) = data;
29388+ ACCESS_ONCE_RW(c2n->head) = data;
29389 }
29390
29391 /*
29392diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
29393index 6647624..2056791 100644
29394--- a/arch/x86/kernel/uprobes.c
29395+++ b/arch/x86/kernel/uprobes.c
29396@@ -978,7 +978,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
29397
29398 if (nleft != rasize) {
29399 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
29400- "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
29401+ "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
29402
29403 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
29404 }
29405diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
29406index b9242ba..50c5edd 100644
29407--- a/arch/x86/kernel/verify_cpu.S
29408+++ b/arch/x86/kernel/verify_cpu.S
29409@@ -20,6 +20,7 @@
29410 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
29411 * arch/x86/kernel/trampoline_64.S: secondary processor verification
29412 * arch/x86/kernel/head_32.S: processor startup
29413+ * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
29414 *
29415 * verify_cpu, returns the status of longmode and SSE in register %eax.
29416 * 0: Success 1: Failure
29417diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
29418index fc9db6e..2c5865d 100644
29419--- a/arch/x86/kernel/vm86_32.c
29420+++ b/arch/x86/kernel/vm86_32.c
29421@@ -44,6 +44,7 @@
29422 #include <linux/ptrace.h>
29423 #include <linux/audit.h>
29424 #include <linux/stddef.h>
29425+#include <linux/grsecurity.h>
29426
29427 #include <asm/uaccess.h>
29428 #include <asm/io.h>
29429@@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
29430 do_exit(SIGSEGV);
29431 }
29432
29433- tss = &per_cpu(cpu_tss, get_cpu());
29434+ tss = cpu_tss + get_cpu();
29435 current->thread.sp0 = current->thread.saved_sp0;
29436 current->thread.sysenter_cs = __KERNEL_CS;
29437 load_sp0(tss, &current->thread);
29438@@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
29439
29440 if (tsk->thread.saved_sp0)
29441 return -EPERM;
29442+
29443+#ifdef CONFIG_GRKERNSEC_VM86
29444+ if (!capable(CAP_SYS_RAWIO)) {
29445+ gr_handle_vm86();
29446+ return -EPERM;
29447+ }
29448+#endif
29449+
29450 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
29451 offsetof(struct kernel_vm86_struct, vm86plus) -
29452 sizeof(info.regs));
29453@@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
29454 int tmp;
29455 struct vm86plus_struct __user *v86;
29456
29457+#ifdef CONFIG_GRKERNSEC_VM86
29458+ if (!capable(CAP_SYS_RAWIO)) {
29459+ gr_handle_vm86();
29460+ return -EPERM;
29461+ }
29462+#endif
29463+
29464 tsk = current;
29465 switch (cmd) {
29466 case VM86_REQUEST_IRQ:
29467@@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
29468 tsk->thread.saved_fs = info->regs32->fs;
29469 tsk->thread.saved_gs = get_user_gs(info->regs32);
29470
29471- tss = &per_cpu(cpu_tss, get_cpu());
29472+ tss = cpu_tss + get_cpu();
29473 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
29474 if (cpu_has_sep)
29475 tsk->thread.sysenter_cs = 0;
29476@@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
29477 goto cannot_handle;
29478 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
29479 goto cannot_handle;
29480- intr_ptr = (unsigned long __user *) (i << 2);
29481+ intr_ptr = (__force unsigned long __user *) (i << 2);
29482 if (get_user(segoffs, intr_ptr))
29483 goto cannot_handle;
29484 if ((segoffs >> 16) == BIOSSEG)
29485diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
29486index 00bf300..03e1c3b 100644
29487--- a/arch/x86/kernel/vmlinux.lds.S
29488+++ b/arch/x86/kernel/vmlinux.lds.S
29489@@ -26,6 +26,13 @@
29490 #include <asm/page_types.h>
29491 #include <asm/cache.h>
29492 #include <asm/boot.h>
29493+#include <asm/segment.h>
29494+
29495+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29496+#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
29497+#else
29498+#define __KERNEL_TEXT_OFFSET 0
29499+#endif
29500
29501 #undef i386 /* in case the preprocessor is a 32bit one */
29502
29503@@ -69,30 +76,43 @@ jiffies_64 = jiffies;
29504
29505 PHDRS {
29506 text PT_LOAD FLAGS(5); /* R_E */
29507+#ifdef CONFIG_X86_32
29508+ module PT_LOAD FLAGS(5); /* R_E */
29509+#endif
29510+#ifdef CONFIG_XEN
29511+ rodata PT_LOAD FLAGS(5); /* R_E */
29512+#else
29513+ rodata PT_LOAD FLAGS(4); /* R__ */
29514+#endif
29515 data PT_LOAD FLAGS(6); /* RW_ */
29516-#ifdef CONFIG_X86_64
29517+ init.begin PT_LOAD FLAGS(6); /* RW_ */
29518 #ifdef CONFIG_SMP
29519 percpu PT_LOAD FLAGS(6); /* RW_ */
29520 #endif
29521- init PT_LOAD FLAGS(7); /* RWE */
29522-#endif
29523+ text.init PT_LOAD FLAGS(5); /* R_E */
29524+ text.exit PT_LOAD FLAGS(5); /* R_E */
29525+ init PT_LOAD FLAGS(6); /* RW_ */
29526 note PT_NOTE FLAGS(0); /* ___ */
29527 }
29528
29529 SECTIONS
29530 {
29531 #ifdef CONFIG_X86_32
29532- . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
29533- phys_startup_32 = startup_32 - LOAD_OFFSET;
29534+ . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
29535 #else
29536- . = __START_KERNEL;
29537- phys_startup_64 = startup_64 - LOAD_OFFSET;
29538+ . = __START_KERNEL;
29539 #endif
29540
29541 /* Text and read-only data */
29542- .text : AT(ADDR(.text) - LOAD_OFFSET) {
29543- _text = .;
29544+ .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
29545 /* bootstrapping code */
29546+#ifdef CONFIG_X86_32
29547+ phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
29548+#else
29549+ phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
29550+#endif
29551+ __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
29552+ _text = .;
29553 HEAD_TEXT
29554 . = ALIGN(8);
29555 _stext = .;
29556@@ -104,13 +124,47 @@ SECTIONS
29557 IRQENTRY_TEXT
29558 *(.fixup)
29559 *(.gnu.warning)
29560- /* End of text section */
29561- _etext = .;
29562 } :text = 0x9090
29563
29564- NOTES :text :note
29565+ . += __KERNEL_TEXT_OFFSET;
29566
29567- EXCEPTION_TABLE(16) :text = 0x9090
29568+#ifdef CONFIG_X86_32
29569+ . = ALIGN(PAGE_SIZE);
29570+ .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
29571+
29572+#ifdef CONFIG_PAX_KERNEXEC
29573+ MODULES_EXEC_VADDR = .;
29574+ BYTE(0)
29575+ . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
29576+ . = ALIGN(HPAGE_SIZE) - 1;
29577+ MODULES_EXEC_END = .;
29578+#endif
29579+
29580+ } :module
29581+#endif
29582+
29583+ .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
29584+ /* End of text section */
29585+ BYTE(0)
29586+ _etext = . - __KERNEL_TEXT_OFFSET;
29587+ }
29588+
29589+#ifdef CONFIG_X86_32
29590+ . = ALIGN(PAGE_SIZE);
29591+ .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
29592+ . = ALIGN(PAGE_SIZE);
29593+ *(.empty_zero_page)
29594+ *(.initial_pg_fixmap)
29595+ *(.initial_pg_pmd)
29596+ *(.initial_page_table)
29597+ *(.swapper_pg_dir)
29598+ } :rodata
29599+#endif
29600+
29601+ . = ALIGN(PAGE_SIZE);
29602+ NOTES :rodata :note
29603+
29604+ EXCEPTION_TABLE(16) :rodata
29605
29606 #if defined(CONFIG_DEBUG_RODATA)
29607 /* .text should occupy whole number of pages */
29608@@ -122,16 +176,20 @@ SECTIONS
29609
29610 /* Data */
29611 .data : AT(ADDR(.data) - LOAD_OFFSET) {
29612+
29613+#ifdef CONFIG_PAX_KERNEXEC
29614+ . = ALIGN(HPAGE_SIZE);
29615+#else
29616+ . = ALIGN(PAGE_SIZE);
29617+#endif
29618+
29619 /* Start of data section */
29620 _sdata = .;
29621
29622 /* init_task */
29623 INIT_TASK_DATA(THREAD_SIZE)
29624
29625-#ifdef CONFIG_X86_32
29626- /* 32 bit has nosave before _edata */
29627 NOSAVE_DATA
29628-#endif
29629
29630 PAGE_ALIGNED_DATA(PAGE_SIZE)
29631
29632@@ -174,12 +232,19 @@ SECTIONS
29633 . = ALIGN(__vvar_page + PAGE_SIZE, PAGE_SIZE);
29634
29635 /* Init code and data - will be freed after init */
29636- . = ALIGN(PAGE_SIZE);
29637 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
29638+ BYTE(0)
29639+
29640+#ifdef CONFIG_PAX_KERNEXEC
29641+ . = ALIGN(HPAGE_SIZE);
29642+#else
29643+ . = ALIGN(PAGE_SIZE);
29644+#endif
29645+
29646 __init_begin = .; /* paired with __init_end */
29647- }
29648+ } :init.begin
29649
29650-#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
29651+#ifdef CONFIG_SMP
29652 /*
29653 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
29654 * output PHDR, so the next output section - .init.text - should
29655@@ -190,12 +255,33 @@ SECTIONS
29656 "per-CPU data too large - increase CONFIG_PHYSICAL_START")
29657 #endif
29658
29659- INIT_TEXT_SECTION(PAGE_SIZE)
29660-#ifdef CONFIG_X86_64
29661- :init
29662+ . = ALIGN(PAGE_SIZE);
29663+ init_begin = .;
29664+ .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
29665+ VMLINUX_SYMBOL(_sinittext) = .;
29666+ INIT_TEXT
29667+ . = ALIGN(PAGE_SIZE);
29668+ } :text.init
29669+
29670+ /*
29671+ * .exit.text is discard at runtime, not link time, to deal with
29672+ * references from .altinstructions and .eh_frame
29673+ */
29674+ .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
29675+ EXIT_TEXT
29676+ VMLINUX_SYMBOL(_einittext) = .;
29677+
29678+#ifdef CONFIG_PAX_KERNEXEC
29679+ . = ALIGN(HPAGE_SIZE);
29680+#else
29681+ . = ALIGN(16);
29682 #endif
29683
29684- INIT_DATA_SECTION(16)
29685+ } :text.exit
29686+ . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
29687+
29688+ . = ALIGN(PAGE_SIZE);
29689+ INIT_DATA_SECTION(16) :init
29690
29691 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
29692 __x86_cpu_dev_start = .;
29693@@ -266,19 +352,12 @@ SECTIONS
29694 }
29695
29696 . = ALIGN(8);
29697- /*
29698- * .exit.text is discard at runtime, not link time, to deal with
29699- * references from .altinstructions and .eh_frame
29700- */
29701- .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
29702- EXIT_TEXT
29703- }
29704
29705 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
29706 EXIT_DATA
29707 }
29708
29709-#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
29710+#ifndef CONFIG_SMP
29711 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
29712 #endif
29713
29714@@ -297,16 +376,10 @@ SECTIONS
29715 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
29716 __smp_locks = .;
29717 *(.smp_locks)
29718- . = ALIGN(PAGE_SIZE);
29719 __smp_locks_end = .;
29720+ . = ALIGN(PAGE_SIZE);
29721 }
29722
29723-#ifdef CONFIG_X86_64
29724- .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
29725- NOSAVE_DATA
29726- }
29727-#endif
29728-
29729 /* BSS */
29730 . = ALIGN(PAGE_SIZE);
29731 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
29732@@ -322,6 +395,7 @@ SECTIONS
29733 __brk_base = .;
29734 . += 64 * 1024; /* 64k alignment slop space */
29735 *(.brk_reservation) /* areas brk users have reserved */
29736+ . = ALIGN(HPAGE_SIZE);
29737 __brk_limit = .;
29738 }
29739
29740@@ -348,13 +422,12 @@ SECTIONS
29741 * for the boot processor.
29742 */
29743 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
29744-INIT_PER_CPU(gdt_page);
29745 INIT_PER_CPU(irq_stack_union);
29746
29747 /*
29748 * Build-time check on the image size:
29749 */
29750-. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
29751+. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
29752 "kernel image bigger than KERNEL_IMAGE_SIZE");
29753
29754 #ifdef CONFIG_SMP
29755diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
29756index a0695be..33e180c 100644
29757--- a/arch/x86/kernel/x8664_ksyms_64.c
29758+++ b/arch/x86/kernel/x8664_ksyms_64.c
29759@@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
29760 EXPORT_SYMBOL(copy_user_generic_unrolled);
29761 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
29762 EXPORT_SYMBOL(__copy_user_nocache);
29763-EXPORT_SYMBOL(_copy_from_user);
29764-EXPORT_SYMBOL(_copy_to_user);
29765
29766 EXPORT_SYMBOL(copy_page);
29767 EXPORT_SYMBOL(clear_page);
29768@@ -77,3 +75,7 @@ EXPORT_SYMBOL(native_load_gs_index);
29769 EXPORT_SYMBOL(___preempt_schedule);
29770 EXPORT_SYMBOL(___preempt_schedule_notrace);
29771 #endif
29772+
29773+#ifdef CONFIG_PAX_PER_CPU_PGD
29774+EXPORT_SYMBOL(cpu_pgd);
29775+#endif
29776diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
29777index 3839628..2e5b5b35 100644
29778--- a/arch/x86/kernel/x86_init.c
29779+++ b/arch/x86/kernel/x86_init.c
29780@@ -92,7 +92,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
29781 static void default_nmi_init(void) { };
29782 static int default_i8042_detect(void) { return 1; };
29783
29784-struct x86_platform_ops x86_platform = {
29785+struct x86_platform_ops x86_platform __read_only = {
29786 .calibrate_tsc = native_calibrate_tsc,
29787 .get_wallclock = mach_get_cmos_time,
29788 .set_wallclock = mach_set_rtc_mmss,
29789@@ -108,7 +108,7 @@ struct x86_platform_ops x86_platform = {
29790 EXPORT_SYMBOL_GPL(x86_platform);
29791
29792 #if defined(CONFIG_PCI_MSI)
29793-struct x86_msi_ops x86_msi = {
29794+struct x86_msi_ops x86_msi __read_only = {
29795 .setup_msi_irqs = native_setup_msi_irqs,
29796 .teardown_msi_irq = native_teardown_msi_irq,
29797 .teardown_msi_irqs = default_teardown_msi_irqs,
29798@@ -137,7 +137,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev)
29799 }
29800 #endif
29801
29802-struct x86_io_apic_ops x86_io_apic_ops = {
29803+struct x86_io_apic_ops x86_io_apic_ops __read_only = {
29804 .read = native_io_apic_read,
29805 .disable = native_disable_io_apic,
29806 };
29807diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
29808index 2fbea25..9e0f8c7 100644
29809--- a/arch/x86/kvm/cpuid.c
29810+++ b/arch/x86/kvm/cpuid.c
29811@@ -206,15 +206,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
29812 struct kvm_cpuid2 *cpuid,
29813 struct kvm_cpuid_entry2 __user *entries)
29814 {
29815- int r;
29816+ int r, i;
29817
29818 r = -E2BIG;
29819 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
29820 goto out;
29821 r = -EFAULT;
29822- if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
29823- cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
29824+ if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
29825 goto out;
29826+ for (i = 0; i < cpuid->nent; ++i) {
29827+ struct kvm_cpuid_entry2 cpuid_entry;
29828+ if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
29829+ goto out;
29830+ vcpu->arch.cpuid_entries[i] = cpuid_entry;
29831+ }
29832 vcpu->arch.cpuid_nent = cpuid->nent;
29833 kvm_apic_set_version(vcpu);
29834 kvm_x86_ops->cpuid_update(vcpu);
29835@@ -227,15 +232,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
29836 struct kvm_cpuid2 *cpuid,
29837 struct kvm_cpuid_entry2 __user *entries)
29838 {
29839- int r;
29840+ int r, i;
29841
29842 r = -E2BIG;
29843 if (cpuid->nent < vcpu->arch.cpuid_nent)
29844 goto out;
29845 r = -EFAULT;
29846- if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
29847- vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
29848+ if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
29849 goto out;
29850+ for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
29851+ struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
29852+ if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
29853+ goto out;
29854+ }
29855 return 0;
29856
29857 out:
29858diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
29859index 2392541a..2aefc2a 100644
29860--- a/arch/x86/kvm/emulate.c
29861+++ b/arch/x86/kvm/emulate.c
29862@@ -3851,7 +3851,7 @@ static int check_cr_write(struct x86_emulate_ctxt *ctxt)
29863 int cr = ctxt->modrm_reg;
29864 u64 efer = 0;
29865
29866- static u64 cr_reserved_bits[] = {
29867+ static const u64 cr_reserved_bits[] = {
29868 0xffffffff00000000ULL,
29869 0, 0, 0, /* CR3 checked later */
29870 CR4_RESERVED_BITS,
29871diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
29872index 2a5ca97..ce8577a 100644
29873--- a/arch/x86/kvm/lapic.c
29874+++ b/arch/x86/kvm/lapic.c
29875@@ -56,7 +56,7 @@
29876 #define APIC_BUS_CYCLE_NS 1
29877
29878 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
29879-#define apic_debug(fmt, arg...)
29880+#define apic_debug(fmt, arg...) do {} while (0)
29881
29882 #define APIC_LVT_NUM 6
29883 /* 14 is the version for Xeon and Pentium 8.4.8*/
29884diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
29885index 0f67d7e..4b9fa11 100644
29886--- a/arch/x86/kvm/paging_tmpl.h
29887+++ b/arch/x86/kvm/paging_tmpl.h
29888@@ -343,7 +343,7 @@ retry_walk:
29889 if (unlikely(kvm_is_error_hva(host_addr)))
29890 goto error;
29891
29892- ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
29893+ ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
29894 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
29895 goto error;
29896 walker->ptep_user[walker->level - 1] = ptep_user;
29897diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
29898index 2d32b67..2cd298b 100644
29899--- a/arch/x86/kvm/svm.c
29900+++ b/arch/x86/kvm/svm.c
29901@@ -3586,7 +3586,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
29902 int cpu = raw_smp_processor_id();
29903
29904 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
29905+
29906+ pax_open_kernel();
29907 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
29908+ pax_close_kernel();
29909+
29910 load_TR_desc();
29911 }
29912
29913@@ -3982,6 +3986,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
29914 #endif
29915 #endif
29916
29917+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
29918+ __set_fs(current_thread_info()->addr_limit);
29919+#endif
29920+
29921 reload_tss(vcpu);
29922
29923 local_irq_disable();
29924diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
29925index aa9e8229..ab09cc4 100644
29926--- a/arch/x86/kvm/vmx.c
29927+++ b/arch/x86/kvm/vmx.c
29928@@ -1440,12 +1440,12 @@ static void vmcs_write64(unsigned long field, u64 value)
29929 #endif
29930 }
29931
29932-static void vmcs_clear_bits(unsigned long field, u32 mask)
29933+static void vmcs_clear_bits(unsigned long field, unsigned long mask)
29934 {
29935 vmcs_writel(field, vmcs_readl(field) & ~mask);
29936 }
29937
29938-static void vmcs_set_bits(unsigned long field, u32 mask)
29939+static void vmcs_set_bits(unsigned long field, unsigned long mask)
29940 {
29941 vmcs_writel(field, vmcs_readl(field) | mask);
29942 }
29943@@ -1705,7 +1705,11 @@ static void reload_tss(void)
29944 struct desc_struct *descs;
29945
29946 descs = (void *)gdt->address;
29947+
29948+ pax_open_kernel();
29949 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
29950+ pax_close_kernel();
29951+
29952 load_TR_desc();
29953 }
29954
29955@@ -1941,6 +1945,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
29956 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
29957 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
29958
29959+#ifdef CONFIG_PAX_PER_CPU_PGD
29960+ vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
29961+#endif
29962+
29963 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
29964 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
29965 vmx->loaded_vmcs->cpu = cpu;
29966@@ -2232,7 +2240,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
29967 * reads and returns guest's timestamp counter "register"
29968 * guest_tsc = host_tsc + tsc_offset -- 21.3
29969 */
29970-static u64 guest_read_tsc(void)
29971+static u64 __intentional_overflow(-1) guest_read_tsc(void)
29972 {
29973 u64 host_tsc, tsc_offset;
29974
29975@@ -4459,7 +4467,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
29976 unsigned long cr4;
29977
29978 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
29979+
29980+#ifndef CONFIG_PAX_PER_CPU_PGD
29981 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
29982+#endif
29983
29984 /* Save the most likely value for this task's CR4 in the VMCS. */
29985 cr4 = cr4_read_shadow();
29986@@ -4486,7 +4497,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
29987 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
29988 vmx->host_idt_base = dt.address;
29989
29990- vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
29991+ vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
29992
29993 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
29994 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
29995@@ -6097,11 +6108,17 @@ static __init int hardware_setup(void)
29996 * page upon invalidation. No need to do anything if not
29997 * using the APIC_ACCESS_ADDR VMCS field.
29998 */
29999- if (!flexpriority_enabled)
30000- kvm_x86_ops->set_apic_access_page_addr = NULL;
30001+ if (!flexpriority_enabled) {
30002+ pax_open_kernel();
30003+ *(void **)&kvm_x86_ops->set_apic_access_page_addr = NULL;
30004+ pax_close_kernel();
30005+ }
30006
30007- if (!cpu_has_vmx_tpr_shadow())
30008- kvm_x86_ops->update_cr8_intercept = NULL;
30009+ if (!cpu_has_vmx_tpr_shadow()) {
30010+ pax_open_kernel();
30011+ *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
30012+ pax_close_kernel();
30013+ }
30014
30015 if (enable_ept && !cpu_has_vmx_ept_2m_page())
30016 kvm_disable_largepages();
30017@@ -6112,14 +6129,16 @@ static __init int hardware_setup(void)
30018 if (!cpu_has_vmx_apicv())
30019 enable_apicv = 0;
30020
30021+ pax_open_kernel();
30022 if (enable_apicv)
30023- kvm_x86_ops->update_cr8_intercept = NULL;
30024+ *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
30025 else {
30026- kvm_x86_ops->hwapic_irr_update = NULL;
30027- kvm_x86_ops->hwapic_isr_update = NULL;
30028- kvm_x86_ops->deliver_posted_interrupt = NULL;
30029- kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
30030+ *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
30031+ *(void **)&kvm_x86_ops->hwapic_isr_update = NULL;
30032+ *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
30033+ *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
30034 }
30035+ pax_close_kernel();
30036
30037 vmx_disable_intercept_for_msr(MSR_FS_BASE, false);
30038 vmx_disable_intercept_for_msr(MSR_GS_BASE, false);
30039@@ -6174,10 +6193,12 @@ static __init int hardware_setup(void)
30040 enable_pml = 0;
30041
30042 if (!enable_pml) {
30043- kvm_x86_ops->slot_enable_log_dirty = NULL;
30044- kvm_x86_ops->slot_disable_log_dirty = NULL;
30045- kvm_x86_ops->flush_log_dirty = NULL;
30046- kvm_x86_ops->enable_log_dirty_pt_masked = NULL;
30047+ pax_open_kernel();
30048+ *(void **)&kvm_x86_ops->slot_enable_log_dirty = NULL;
30049+ *(void **)&kvm_x86_ops->slot_disable_log_dirty = NULL;
30050+ *(void **)&kvm_x86_ops->flush_log_dirty = NULL;
30051+ *(void **)&kvm_x86_ops->enable_log_dirty_pt_masked = NULL;
30052+ pax_close_kernel();
30053 }
30054
30055 return alloc_kvm_area();
30056@@ -8380,6 +8401,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
30057 "jmp 2f \n\t"
30058 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
30059 "2: "
30060+
30061+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30062+ "ljmp %[cs],$3f\n\t"
30063+ "3: "
30064+#endif
30065+
30066 /* Save guest registers, load host registers, keep flags */
30067 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
30068 "pop %0 \n\t"
30069@@ -8432,6 +8459,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
30070 #endif
30071 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
30072 [wordsize]"i"(sizeof(ulong))
30073+
30074+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30075+ ,[cs]"i"(__KERNEL_CS)
30076+#endif
30077+
30078 : "cc", "memory"
30079 #ifdef CONFIG_X86_64
30080 , "rax", "rbx", "rdi", "rsi"
30081@@ -8445,7 +8477,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
30082 if (debugctlmsr)
30083 update_debugctlmsr(debugctlmsr);
30084
30085-#ifndef CONFIG_X86_64
30086+#ifdef CONFIG_X86_32
30087 /*
30088 * The sysexit path does not restore ds/es, so we must set them to
30089 * a reasonable value ourselves.
30090@@ -8454,8 +8486,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
30091 * may be executed in interrupt context, which saves and restore segments
30092 * around it, nullifying its effect.
30093 */
30094- loadsegment(ds, __USER_DS);
30095- loadsegment(es, __USER_DS);
30096+ loadsegment(ds, __KERNEL_DS);
30097+ loadsegment(es, __KERNEL_DS);
30098+ loadsegment(ss, __KERNEL_DS);
30099+
30100+#ifdef CONFIG_PAX_KERNEXEC
30101+ loadsegment(fs, __KERNEL_PERCPU);
30102+#endif
30103+
30104+#ifdef CONFIG_PAX_MEMORY_UDEREF
30105+ __set_fs(current_thread_info()->addr_limit);
30106+#endif
30107+
30108 #endif
30109
30110 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
30111diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
30112index 373328b7..ebd267f 100644
30113--- a/arch/x86/kvm/x86.c
30114+++ b/arch/x86/kvm/x86.c
30115@@ -1842,8 +1842,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
30116 {
30117 struct kvm *kvm = vcpu->kvm;
30118 int lm = is_long_mode(vcpu);
30119- u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
30120- : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
30121+ u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
30122+ : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
30123 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
30124 : kvm->arch.xen_hvm_config.blob_size_32;
30125 u32 page_num = data & ~PAGE_MASK;
30126@@ -2733,6 +2733,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
30127 if (n < msr_list.nmsrs)
30128 goto out;
30129 r = -EFAULT;
30130+ if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
30131+ goto out;
30132 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
30133 num_msrs_to_save * sizeof(u32)))
30134 goto out;
30135@@ -3093,7 +3095,7 @@ static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu,
30136
30137 static void fill_xsave(u8 *dest, struct kvm_vcpu *vcpu)
30138 {
30139- struct xregs_state *xsave = &vcpu->arch.guest_fpu.state.xsave;
30140+ struct xregs_state *xsave = &vcpu->arch.guest_fpu.state->xsave;
30141 u64 xstate_bv = xsave->header.xfeatures;
30142 u64 valid;
30143
30144@@ -3129,7 +3131,7 @@ static void fill_xsave(u8 *dest, struct kvm_vcpu *vcpu)
30145
30146 static void load_xsave(struct kvm_vcpu *vcpu, u8 *src)
30147 {
30148- struct xregs_state *xsave = &vcpu->arch.guest_fpu.state.xsave;
30149+ struct xregs_state *xsave = &vcpu->arch.guest_fpu.state->xsave;
30150 u64 xstate_bv = *(u64 *)(src + XSAVE_HDR_OFFSET);
30151 u64 valid;
30152
30153@@ -3173,7 +3175,7 @@ static void kvm_vcpu_ioctl_x86_get_xsave(struct kvm_vcpu *vcpu,
30154 fill_xsave((u8 *) guest_xsave->region, vcpu);
30155 } else {
30156 memcpy(guest_xsave->region,
30157- &vcpu->arch.guest_fpu.state.fxsave,
30158+ &vcpu->arch.guest_fpu.state->fxsave,
30159 sizeof(struct fxregs_state));
30160 *(u64 *)&guest_xsave->region[XSAVE_HDR_OFFSET / sizeof(u32)] =
30161 XSTATE_FPSSE;
30162@@ -3198,7 +3200,7 @@ static int kvm_vcpu_ioctl_x86_set_xsave(struct kvm_vcpu *vcpu,
30163 } else {
30164 if (xstate_bv & ~XSTATE_FPSSE)
30165 return -EINVAL;
30166- memcpy(&vcpu->arch.guest_fpu.state.fxsave,
30167+ memcpy(&vcpu->arch.guest_fpu.state->fxsave,
30168 guest_xsave->region, sizeof(struct fxregs_state));
30169 }
30170 return 0;
30171@@ -5788,7 +5790,7 @@ static struct notifier_block pvclock_gtod_notifier = {
30172 };
30173 #endif
30174
30175-int kvm_arch_init(void *opaque)
30176+int kvm_arch_init(const void *opaque)
30177 {
30178 int r;
30179 struct kvm_x86_ops *ops = opaque;
30180@@ -7217,7 +7219,7 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
30181 int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
30182 {
30183 struct fxregs_state *fxsave =
30184- &vcpu->arch.guest_fpu.state.fxsave;
30185+ &vcpu->arch.guest_fpu.state->fxsave;
30186
30187 memcpy(fpu->fpr, fxsave->st_space, 128);
30188 fpu->fcw = fxsave->cwd;
30189@@ -7234,7 +7236,7 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
30190 int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
30191 {
30192 struct fxregs_state *fxsave =
30193- &vcpu->arch.guest_fpu.state.fxsave;
30194+ &vcpu->arch.guest_fpu.state->fxsave;
30195
30196 memcpy(fxsave->st_space, fpu->fpr, 128);
30197 fxsave->cwd = fpu->fcw;
30198@@ -7250,9 +7252,9 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
30199
30200 static void fx_init(struct kvm_vcpu *vcpu)
30201 {
30202- fpstate_init(&vcpu->arch.guest_fpu.state);
30203+ fpstate_init(vcpu->arch.guest_fpu.state);
30204 if (cpu_has_xsaves)
30205- vcpu->arch.guest_fpu.state.xsave.header.xcomp_bv =
30206+ vcpu->arch.guest_fpu.state->xsave.header.xcomp_bv =
30207 host_xcr0 | XSTATE_COMPACTION_ENABLED;
30208
30209 /*
30210@@ -7276,7 +7278,7 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
30211 kvm_put_guest_xcr0(vcpu);
30212 vcpu->guest_fpu_loaded = 1;
30213 __kernel_fpu_begin();
30214- __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu.state);
30215+ __copy_kernel_to_fpregs(vcpu->arch.guest_fpu.state);
30216 trace_kvm_fpu(1);
30217 }
30218
30219@@ -7554,6 +7556,8 @@ bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu)
30220
30221 struct static_key kvm_no_apic_vcpu __read_mostly;
30222
30223+extern struct kmem_cache *fpregs_state_cachep;
30224+
30225 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
30226 {
30227 struct page *page;
30228@@ -7570,11 +7574,14 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
30229 else
30230 vcpu->arch.mp_state = KVM_MP_STATE_UNINITIALIZED;
30231
30232- page = alloc_page(GFP_KERNEL | __GFP_ZERO);
30233- if (!page) {
30234- r = -ENOMEM;
30235+ r = -ENOMEM;
30236+ vcpu->arch.guest_fpu.state = kmem_cache_alloc(fpregs_state_cachep, GFP_KERNEL);
30237+ if (!vcpu->arch.guest_fpu.state)
30238 goto fail;
30239- }
30240+
30241+ page = alloc_page(GFP_KERNEL | __GFP_ZERO);
30242+ if (!page)
30243+ goto fail_free_fpregs;
30244 vcpu->arch.pio_data = page_address(page);
30245
30246 kvm_set_tsc_khz(vcpu, max_tsc_khz);
30247@@ -7628,6 +7635,9 @@ fail_mmu_destroy:
30248 kvm_mmu_destroy(vcpu);
30249 fail_free_pio_data:
30250 free_page((unsigned long)vcpu->arch.pio_data);
30251+fail_free_fpregs:
30252+ kmem_cache_free(fpregs_state_cachep, vcpu->arch.guest_fpu.state);
30253+ vcpu->arch.guest_fpu.state = NULL;
30254 fail:
30255 return r;
30256 }
30257@@ -7645,6 +7655,8 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
30258 free_page((unsigned long)vcpu->arch.pio_data);
30259 if (!irqchip_in_kernel(vcpu->kvm))
30260 static_key_slow_dec(&kvm_no_apic_vcpu);
30261+ kmem_cache_free(fpregs_state_cachep, vcpu->arch.guest_fpu.state);
30262+ vcpu->arch.guest_fpu.state = NULL;
30263 }
30264
30265 void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu)
30266diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
30267index f2dc08c..d85d906 100644
30268--- a/arch/x86/lguest/boot.c
30269+++ b/arch/x86/lguest/boot.c
30270@@ -1341,9 +1341,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
30271 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
30272 * Launcher to reboot us.
30273 */
30274-static void lguest_restart(char *reason)
30275+static __noreturn void lguest_restart(char *reason)
30276 {
30277 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
30278+ BUG();
30279 }
30280
30281 /*G:050
30282diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
30283index 9b0ca8f..bb4af41 100644
30284--- a/arch/x86/lib/atomic64_386_32.S
30285+++ b/arch/x86/lib/atomic64_386_32.S
30286@@ -45,6 +45,10 @@ BEGIN(read)
30287 movl (v), %eax
30288 movl 4(v), %edx
30289 RET_ENDP
30290+BEGIN(read_unchecked)
30291+ movl (v), %eax
30292+ movl 4(v), %edx
30293+RET_ENDP
30294 #undef v
30295
30296 #define v %esi
30297@@ -52,6 +56,10 @@ BEGIN(set)
30298 movl %ebx, (v)
30299 movl %ecx, 4(v)
30300 RET_ENDP
30301+BEGIN(set_unchecked)
30302+ movl %ebx, (v)
30303+ movl %ecx, 4(v)
30304+RET_ENDP
30305 #undef v
30306
30307 #define v %esi
30308@@ -67,6 +75,20 @@ RET_ENDP
30309 BEGIN(add)
30310 addl %eax, (v)
30311 adcl %edx, 4(v)
30312+
30313+#ifdef CONFIG_PAX_REFCOUNT
30314+ jno 0f
30315+ subl %eax, (v)
30316+ sbbl %edx, 4(v)
30317+ int $4
30318+0:
30319+ _ASM_EXTABLE(0b, 0b)
30320+#endif
30321+
30322+RET_ENDP
30323+BEGIN(add_unchecked)
30324+ addl %eax, (v)
30325+ adcl %edx, 4(v)
30326 RET_ENDP
30327 #undef v
30328
30329@@ -74,6 +96,24 @@ RET_ENDP
30330 BEGIN(add_return)
30331 addl (v), %eax
30332 adcl 4(v), %edx
30333+
30334+#ifdef CONFIG_PAX_REFCOUNT
30335+ into
30336+1234:
30337+ _ASM_EXTABLE(1234b, 2f)
30338+#endif
30339+
30340+ movl %eax, (v)
30341+ movl %edx, 4(v)
30342+
30343+#ifdef CONFIG_PAX_REFCOUNT
30344+2:
30345+#endif
30346+
30347+RET_ENDP
30348+BEGIN(add_return_unchecked)
30349+ addl (v), %eax
30350+ adcl 4(v), %edx
30351 movl %eax, (v)
30352 movl %edx, 4(v)
30353 RET_ENDP
30354@@ -83,6 +123,20 @@ RET_ENDP
30355 BEGIN(sub)
30356 subl %eax, (v)
30357 sbbl %edx, 4(v)
30358+
30359+#ifdef CONFIG_PAX_REFCOUNT
30360+ jno 0f
30361+ addl %eax, (v)
30362+ adcl %edx, 4(v)
30363+ int $4
30364+0:
30365+ _ASM_EXTABLE(0b, 0b)
30366+#endif
30367+
30368+RET_ENDP
30369+BEGIN(sub_unchecked)
30370+ subl %eax, (v)
30371+ sbbl %edx, 4(v)
30372 RET_ENDP
30373 #undef v
30374
30375@@ -93,6 +147,27 @@ BEGIN(sub_return)
30376 sbbl $0, %edx
30377 addl (v), %eax
30378 adcl 4(v), %edx
30379+
30380+#ifdef CONFIG_PAX_REFCOUNT
30381+ into
30382+1234:
30383+ _ASM_EXTABLE(1234b, 2f)
30384+#endif
30385+
30386+ movl %eax, (v)
30387+ movl %edx, 4(v)
30388+
30389+#ifdef CONFIG_PAX_REFCOUNT
30390+2:
30391+#endif
30392+
30393+RET_ENDP
30394+BEGIN(sub_return_unchecked)
30395+ negl %edx
30396+ negl %eax
30397+ sbbl $0, %edx
30398+ addl (v), %eax
30399+ adcl 4(v), %edx
30400 movl %eax, (v)
30401 movl %edx, 4(v)
30402 RET_ENDP
30403@@ -102,6 +177,20 @@ RET_ENDP
30404 BEGIN(inc)
30405 addl $1, (v)
30406 adcl $0, 4(v)
30407+
30408+#ifdef CONFIG_PAX_REFCOUNT
30409+ jno 0f
30410+ subl $1, (v)
30411+ sbbl $0, 4(v)
30412+ int $4
30413+0:
30414+ _ASM_EXTABLE(0b, 0b)
30415+#endif
30416+
30417+RET_ENDP
30418+BEGIN(inc_unchecked)
30419+ addl $1, (v)
30420+ adcl $0, 4(v)
30421 RET_ENDP
30422 #undef v
30423
30424@@ -111,6 +200,26 @@ BEGIN(inc_return)
30425 movl 4(v), %edx
30426 addl $1, %eax
30427 adcl $0, %edx
30428+
30429+#ifdef CONFIG_PAX_REFCOUNT
30430+ into
30431+1234:
30432+ _ASM_EXTABLE(1234b, 2f)
30433+#endif
30434+
30435+ movl %eax, (v)
30436+ movl %edx, 4(v)
30437+
30438+#ifdef CONFIG_PAX_REFCOUNT
30439+2:
30440+#endif
30441+
30442+RET_ENDP
30443+BEGIN(inc_return_unchecked)
30444+ movl (v), %eax
30445+ movl 4(v), %edx
30446+ addl $1, %eax
30447+ adcl $0, %edx
30448 movl %eax, (v)
30449 movl %edx, 4(v)
30450 RET_ENDP
30451@@ -120,6 +229,20 @@ RET_ENDP
30452 BEGIN(dec)
30453 subl $1, (v)
30454 sbbl $0, 4(v)
30455+
30456+#ifdef CONFIG_PAX_REFCOUNT
30457+ jno 0f
30458+ addl $1, (v)
30459+ adcl $0, 4(v)
30460+ int $4
30461+0:
30462+ _ASM_EXTABLE(0b, 0b)
30463+#endif
30464+
30465+RET_ENDP
30466+BEGIN(dec_unchecked)
30467+ subl $1, (v)
30468+ sbbl $0, 4(v)
30469 RET_ENDP
30470 #undef v
30471
30472@@ -129,6 +252,26 @@ BEGIN(dec_return)
30473 movl 4(v), %edx
30474 subl $1, %eax
30475 sbbl $0, %edx
30476+
30477+#ifdef CONFIG_PAX_REFCOUNT
30478+ into
30479+1234:
30480+ _ASM_EXTABLE(1234b, 2f)
30481+#endif
30482+
30483+ movl %eax, (v)
30484+ movl %edx, 4(v)
30485+
30486+#ifdef CONFIG_PAX_REFCOUNT
30487+2:
30488+#endif
30489+
30490+RET_ENDP
30491+BEGIN(dec_return_unchecked)
30492+ movl (v), %eax
30493+ movl 4(v), %edx
30494+ subl $1, %eax
30495+ sbbl $0, %edx
30496 movl %eax, (v)
30497 movl %edx, 4(v)
30498 RET_ENDP
30499@@ -140,6 +283,13 @@ BEGIN(add_unless)
30500 adcl %edx, %edi
30501 addl (v), %eax
30502 adcl 4(v), %edx
30503+
30504+#ifdef CONFIG_PAX_REFCOUNT
30505+ into
30506+1234:
30507+ _ASM_EXTABLE(1234b, 2f)
30508+#endif
30509+
30510 cmpl %eax, %ecx
30511 je 3f
30512 1:
30513@@ -165,6 +315,13 @@ BEGIN(inc_not_zero)
30514 1:
30515 addl $1, %eax
30516 adcl $0, %edx
30517+
30518+#ifdef CONFIG_PAX_REFCOUNT
30519+ into
30520+1234:
30521+ _ASM_EXTABLE(1234b, 2f)
30522+#endif
30523+
30524 movl %eax, (v)
30525 movl %edx, 4(v)
30526 movl $1, %eax
30527@@ -183,6 +340,13 @@ BEGIN(dec_if_positive)
30528 movl 4(v), %edx
30529 subl $1, %eax
30530 sbbl $0, %edx
30531+
30532+#ifdef CONFIG_PAX_REFCOUNT
30533+ into
30534+1234:
30535+ _ASM_EXTABLE(1234b, 1f)
30536+#endif
30537+
30538 js 1f
30539 movl %eax, (v)
30540 movl %edx, 4(v)
30541diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
30542index db3ae854..b8ad0de 100644
30543--- a/arch/x86/lib/atomic64_cx8_32.S
30544+++ b/arch/x86/lib/atomic64_cx8_32.S
30545@@ -22,9 +22,16 @@
30546
30547 ENTRY(atomic64_read_cx8)
30548 read64 %ecx
30549+ pax_force_retaddr
30550 ret
30551 ENDPROC(atomic64_read_cx8)
30552
30553+ENTRY(atomic64_read_unchecked_cx8)
30554+ read64 %ecx
30555+ pax_force_retaddr
30556+ ret
30557+ENDPROC(atomic64_read_unchecked_cx8)
30558+
30559 ENTRY(atomic64_set_cx8)
30560 1:
30561 /* we don't need LOCK_PREFIX since aligned 64-bit writes
30562@@ -32,20 +39,33 @@ ENTRY(atomic64_set_cx8)
30563 cmpxchg8b (%esi)
30564 jne 1b
30565
30566+ pax_force_retaddr
30567 ret
30568 ENDPROC(atomic64_set_cx8)
30569
30570+ENTRY(atomic64_set_unchecked_cx8)
30571+1:
30572+/* we don't need LOCK_PREFIX since aligned 64-bit writes
30573+ * are atomic on 586 and newer */
30574+ cmpxchg8b (%esi)
30575+ jne 1b
30576+
30577+ pax_force_retaddr
30578+ ret
30579+ENDPROC(atomic64_set_unchecked_cx8)
30580+
30581 ENTRY(atomic64_xchg_cx8)
30582 1:
30583 LOCK_PREFIX
30584 cmpxchg8b (%esi)
30585 jne 1b
30586
30587+ pax_force_retaddr
30588 ret
30589 ENDPROC(atomic64_xchg_cx8)
30590
30591-.macro addsub_return func ins insc
30592-ENTRY(atomic64_\func\()_return_cx8)
30593+.macro addsub_return func ins insc unchecked=""
30594+ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
30595 pushl %ebp
30596 pushl %ebx
30597 pushl %esi
30598@@ -61,26 +81,43 @@ ENTRY(atomic64_\func\()_return_cx8)
30599 movl %edx, %ecx
30600 \ins\()l %esi, %ebx
30601 \insc\()l %edi, %ecx
30602+
30603+.ifb \unchecked
30604+#ifdef CONFIG_PAX_REFCOUNT
30605+ into
30606+2:
30607+ _ASM_EXTABLE(2b, 3f)
30608+#endif
30609+.endif
30610+
30611 LOCK_PREFIX
30612 cmpxchg8b (%ebp)
30613 jne 1b
30614-
30615-10:
30616 movl %ebx, %eax
30617 movl %ecx, %edx
30618+
30619+.ifb \unchecked
30620+#ifdef CONFIG_PAX_REFCOUNT
30621+3:
30622+#endif
30623+.endif
30624+
30625 popl %edi
30626 popl %esi
30627 popl %ebx
30628 popl %ebp
30629+ pax_force_retaddr
30630 ret
30631-ENDPROC(atomic64_\func\()_return_cx8)
30632+ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
30633 .endm
30634
30635 addsub_return add add adc
30636 addsub_return sub sub sbb
30637+addsub_return add add adc _unchecked
30638+addsub_return sub sub sbb _unchecked
30639
30640-.macro incdec_return func ins insc
30641-ENTRY(atomic64_\func\()_return_cx8)
30642+.macro incdec_return func ins insc unchecked=""
30643+ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
30644 pushl %ebx
30645
30646 read64 %esi
30647@@ -89,20 +126,37 @@ ENTRY(atomic64_\func\()_return_cx8)
30648 movl %edx, %ecx
30649 \ins\()l $1, %ebx
30650 \insc\()l $0, %ecx
30651+
30652+.ifb \unchecked
30653+#ifdef CONFIG_PAX_REFCOUNT
30654+ into
30655+2:
30656+ _ASM_EXTABLE(2b, 3f)
30657+#endif
30658+.endif
30659+
30660 LOCK_PREFIX
30661 cmpxchg8b (%esi)
30662 jne 1b
30663-
30664-10:
30665 movl %ebx, %eax
30666 movl %ecx, %edx
30667+
30668+.ifb \unchecked
30669+#ifdef CONFIG_PAX_REFCOUNT
30670+3:
30671+#endif
30672+.endif
30673+
30674 popl %ebx
30675+ pax_force_retaddr
30676 ret
30677-ENDPROC(atomic64_\func\()_return_cx8)
30678+ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
30679 .endm
30680
30681 incdec_return inc add adc
30682 incdec_return dec sub sbb
30683+incdec_return inc add adc _unchecked
30684+incdec_return dec sub sbb _unchecked
30685
30686 ENTRY(atomic64_dec_if_positive_cx8)
30687 pushl %ebx
30688@@ -113,6 +167,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
30689 movl %edx, %ecx
30690 subl $1, %ebx
30691 sbb $0, %ecx
30692+
30693+#ifdef CONFIG_PAX_REFCOUNT
30694+ into
30695+1234:
30696+ _ASM_EXTABLE(1234b, 2f)
30697+#endif
30698+
30699 js 2f
30700 LOCK_PREFIX
30701 cmpxchg8b (%esi)
30702@@ -122,6 +183,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
30703 movl %ebx, %eax
30704 movl %ecx, %edx
30705 popl %ebx
30706+ pax_force_retaddr
30707 ret
30708 ENDPROC(atomic64_dec_if_positive_cx8)
30709
30710@@ -144,6 +206,13 @@ ENTRY(atomic64_add_unless_cx8)
30711 movl %edx, %ecx
30712 addl %ebp, %ebx
30713 adcl %edi, %ecx
30714+
30715+#ifdef CONFIG_PAX_REFCOUNT
30716+ into
30717+1234:
30718+ _ASM_EXTABLE(1234b, 3f)
30719+#endif
30720+
30721 LOCK_PREFIX
30722 cmpxchg8b (%esi)
30723 jne 1b
30724@@ -153,6 +222,7 @@ ENTRY(atomic64_add_unless_cx8)
30725 addl $8, %esp
30726 popl %ebx
30727 popl %ebp
30728+ pax_force_retaddr
30729 ret
30730 4:
30731 cmpl %edx, 4(%esp)
30732@@ -173,6 +243,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
30733 xorl %ecx, %ecx
30734 addl $1, %ebx
30735 adcl %edx, %ecx
30736+
30737+#ifdef CONFIG_PAX_REFCOUNT
30738+ into
30739+1234:
30740+ _ASM_EXTABLE(1234b, 3f)
30741+#endif
30742+
30743 LOCK_PREFIX
30744 cmpxchg8b (%esi)
30745 jne 1b
30746@@ -180,5 +257,6 @@ ENTRY(atomic64_inc_not_zero_cx8)
30747 movl $1, %eax
30748 3:
30749 popl %ebx
30750+ pax_force_retaddr
30751 ret
30752 ENDPROC(atomic64_inc_not_zero_cx8)
30753diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
30754index c1e6232..ebbeba7 100644
30755--- a/arch/x86/lib/checksum_32.S
30756+++ b/arch/x86/lib/checksum_32.S
30757@@ -28,7 +28,8 @@
30758 #include <linux/linkage.h>
30759 #include <asm/errno.h>
30760 #include <asm/asm.h>
30761-
30762+#include <asm/segment.h>
30763+
30764 /*
30765 * computes a partial checksum, e.g. for TCP/UDP fragments
30766 */
30767@@ -280,7 +281,22 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
30768
30769 #define ARGBASE 16
30770 #define FP 12
30771-
30772+
30773+ENTRY(csum_partial_copy_generic_to_user)
30774+
30775+#ifdef CONFIG_PAX_MEMORY_UDEREF
30776+ pushl %gs
30777+ popl %es
30778+ jmp csum_partial_copy_generic
30779+#endif
30780+
30781+ENTRY(csum_partial_copy_generic_from_user)
30782+
30783+#ifdef CONFIG_PAX_MEMORY_UDEREF
30784+ pushl %gs
30785+ popl %ds
30786+#endif
30787+
30788 ENTRY(csum_partial_copy_generic)
30789 subl $4,%esp
30790 pushl %edi
30791@@ -299,7 +315,7 @@ ENTRY(csum_partial_copy_generic)
30792 jmp 4f
30793 SRC(1: movw (%esi), %bx )
30794 addl $2, %esi
30795-DST( movw %bx, (%edi) )
30796+DST( movw %bx, %es:(%edi) )
30797 addl $2, %edi
30798 addw %bx, %ax
30799 adcl $0, %eax
30800@@ -311,30 +327,30 @@ DST( movw %bx, (%edi) )
30801 SRC(1: movl (%esi), %ebx )
30802 SRC( movl 4(%esi), %edx )
30803 adcl %ebx, %eax
30804-DST( movl %ebx, (%edi) )
30805+DST( movl %ebx, %es:(%edi) )
30806 adcl %edx, %eax
30807-DST( movl %edx, 4(%edi) )
30808+DST( movl %edx, %es:4(%edi) )
30809
30810 SRC( movl 8(%esi), %ebx )
30811 SRC( movl 12(%esi), %edx )
30812 adcl %ebx, %eax
30813-DST( movl %ebx, 8(%edi) )
30814+DST( movl %ebx, %es:8(%edi) )
30815 adcl %edx, %eax
30816-DST( movl %edx, 12(%edi) )
30817+DST( movl %edx, %es:12(%edi) )
30818
30819 SRC( movl 16(%esi), %ebx )
30820 SRC( movl 20(%esi), %edx )
30821 adcl %ebx, %eax
30822-DST( movl %ebx, 16(%edi) )
30823+DST( movl %ebx, %es:16(%edi) )
30824 adcl %edx, %eax
30825-DST( movl %edx, 20(%edi) )
30826+DST( movl %edx, %es:20(%edi) )
30827
30828 SRC( movl 24(%esi), %ebx )
30829 SRC( movl 28(%esi), %edx )
30830 adcl %ebx, %eax
30831-DST( movl %ebx, 24(%edi) )
30832+DST( movl %ebx, %es:24(%edi) )
30833 adcl %edx, %eax
30834-DST( movl %edx, 28(%edi) )
30835+DST( movl %edx, %es:28(%edi) )
30836
30837 lea 32(%esi), %esi
30838 lea 32(%edi), %edi
30839@@ -348,7 +364,7 @@ DST( movl %edx, 28(%edi) )
30840 shrl $2, %edx # This clears CF
30841 SRC(3: movl (%esi), %ebx )
30842 adcl %ebx, %eax
30843-DST( movl %ebx, (%edi) )
30844+DST( movl %ebx, %es:(%edi) )
30845 lea 4(%esi), %esi
30846 lea 4(%edi), %edi
30847 dec %edx
30848@@ -360,12 +376,12 @@ DST( movl %ebx, (%edi) )
30849 jb 5f
30850 SRC( movw (%esi), %cx )
30851 leal 2(%esi), %esi
30852-DST( movw %cx, (%edi) )
30853+DST( movw %cx, %es:(%edi) )
30854 leal 2(%edi), %edi
30855 je 6f
30856 shll $16,%ecx
30857 SRC(5: movb (%esi), %cl )
30858-DST( movb %cl, (%edi) )
30859+DST( movb %cl, %es:(%edi) )
30860 6: addl %ecx, %eax
30861 adcl $0, %eax
30862 7:
30863@@ -376,7 +392,7 @@ DST( movb %cl, (%edi) )
30864
30865 6001:
30866 movl ARGBASE+20(%esp), %ebx # src_err_ptr
30867- movl $-EFAULT, (%ebx)
30868+ movl $-EFAULT, %ss:(%ebx)
30869
30870 # zero the complete destination - computing the rest
30871 # is too much work
30872@@ -389,34 +405,58 @@ DST( movb %cl, (%edi) )
30873
30874 6002:
30875 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
30876- movl $-EFAULT,(%ebx)
30877+ movl $-EFAULT,%ss:(%ebx)
30878 jmp 5000b
30879
30880 .previous
30881
30882+#ifdef CONFIG_PAX_MEMORY_UDEREF
30883+ pushl %ss
30884+ popl %ds
30885+ pushl %ss
30886+ popl %es
30887+#endif
30888+
30889 popl %ebx
30890 popl %esi
30891 popl %edi
30892 popl %ecx # equivalent to addl $4,%esp
30893 ret
30894-ENDPROC(csum_partial_copy_generic)
30895+ENDPROC(csum_partial_copy_generic_to_user)
30896
30897 #else
30898
30899 /* Version for PentiumII/PPro */
30900
30901 #define ROUND1(x) \
30902+ nop; nop; nop; \
30903 SRC(movl x(%esi), %ebx ) ; \
30904 addl %ebx, %eax ; \
30905- DST(movl %ebx, x(%edi) ) ;
30906+ DST(movl %ebx, %es:x(%edi)) ;
30907
30908 #define ROUND(x) \
30909+ nop; nop; nop; \
30910 SRC(movl x(%esi), %ebx ) ; \
30911 adcl %ebx, %eax ; \
30912- DST(movl %ebx, x(%edi) ) ;
30913+ DST(movl %ebx, %es:x(%edi)) ;
30914
30915 #define ARGBASE 12
30916-
30917+
30918+ENTRY(csum_partial_copy_generic_to_user)
30919+
30920+#ifdef CONFIG_PAX_MEMORY_UDEREF
30921+ pushl %gs
30922+ popl %es
30923+ jmp csum_partial_copy_generic
30924+#endif
30925+
30926+ENTRY(csum_partial_copy_generic_from_user)
30927+
30928+#ifdef CONFIG_PAX_MEMORY_UDEREF
30929+ pushl %gs
30930+ popl %ds
30931+#endif
30932+
30933 ENTRY(csum_partial_copy_generic)
30934 pushl %ebx
30935 pushl %edi
30936@@ -435,7 +475,7 @@ ENTRY(csum_partial_copy_generic)
30937 subl %ebx, %edi
30938 lea -1(%esi),%edx
30939 andl $-32,%edx
30940- lea 3f(%ebx,%ebx), %ebx
30941+ lea 3f(%ebx,%ebx,2), %ebx
30942 testl %esi, %esi
30943 jmp *%ebx
30944 1: addl $64,%esi
30945@@ -456,19 +496,19 @@ ENTRY(csum_partial_copy_generic)
30946 jb 5f
30947 SRC( movw (%esi), %dx )
30948 leal 2(%esi), %esi
30949-DST( movw %dx, (%edi) )
30950+DST( movw %dx, %es:(%edi) )
30951 leal 2(%edi), %edi
30952 je 6f
30953 shll $16,%edx
30954 5:
30955 SRC( movb (%esi), %dl )
30956-DST( movb %dl, (%edi) )
30957+DST( movb %dl, %es:(%edi) )
30958 6: addl %edx, %eax
30959 adcl $0, %eax
30960 7:
30961 .section .fixup, "ax"
30962 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
30963- movl $-EFAULT, (%ebx)
30964+ movl $-EFAULT, %ss:(%ebx)
30965 # zero the complete destination (computing the rest is too much work)
30966 movl ARGBASE+8(%esp),%edi # dst
30967 movl ARGBASE+12(%esp),%ecx # len
30968@@ -476,15 +516,22 @@ DST( movb %dl, (%edi) )
30969 rep; stosb
30970 jmp 7b
30971 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
30972- movl $-EFAULT, (%ebx)
30973+ movl $-EFAULT, %ss:(%ebx)
30974 jmp 7b
30975 .previous
30976
30977+#ifdef CONFIG_PAX_MEMORY_UDEREF
30978+ pushl %ss
30979+ popl %ds
30980+ pushl %ss
30981+ popl %es
30982+#endif
30983+
30984 popl %esi
30985 popl %edi
30986 popl %ebx
30987 ret
30988-ENDPROC(csum_partial_copy_generic)
30989+ENDPROC(csum_partial_copy_generic_to_user)
30990
30991 #undef ROUND
30992 #undef ROUND1
30993diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
30994index a2fe51b..507dab0 100644
30995--- a/arch/x86/lib/clear_page_64.S
30996+++ b/arch/x86/lib/clear_page_64.S
30997@@ -21,6 +21,7 @@ ENTRY(clear_page)
30998 movl $4096/8,%ecx
30999 xorl %eax,%eax
31000 rep stosq
31001+ pax_force_retaddr
31002 ret
31003 ENDPROC(clear_page)
31004
31005@@ -43,6 +44,7 @@ ENTRY(clear_page_orig)
31006 leaq 64(%rdi),%rdi
31007 jnz .Lloop
31008 nop
31009+ pax_force_retaddr
31010 ret
31011 ENDPROC(clear_page_orig)
31012
31013@@ -50,5 +52,6 @@ ENTRY(clear_page_c_e)
31014 movl $4096,%ecx
31015 xorl %eax,%eax
31016 rep stosb
31017+ pax_force_retaddr
31018 ret
31019 ENDPROC(clear_page_c_e)
31020diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
31021index 9b33024..e52ee44 100644
31022--- a/arch/x86/lib/cmpxchg16b_emu.S
31023+++ b/arch/x86/lib/cmpxchg16b_emu.S
31024@@ -7,6 +7,7 @@
31025 */
31026 #include <linux/linkage.h>
31027 #include <asm/percpu.h>
31028+#include <asm/alternative-asm.h>
31029
31030 .text
31031
31032@@ -43,11 +44,13 @@ ENTRY(this_cpu_cmpxchg16b_emu)
31033
31034 popfq
31035 mov $1, %al
31036+ pax_force_retaddr
31037 ret
31038
31039 .Lnot_same:
31040 popfq
31041 xor %al,%al
31042+ pax_force_retaddr
31043 ret
31044
31045 ENDPROC(this_cpu_cmpxchg16b_emu)
31046diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
31047index 009f982..9b3db5e 100644
31048--- a/arch/x86/lib/copy_page_64.S
31049+++ b/arch/x86/lib/copy_page_64.S
31050@@ -15,13 +15,14 @@ ENTRY(copy_page)
31051 ALTERNATIVE "jmp copy_page_regs", "", X86_FEATURE_REP_GOOD
31052 movl $4096/8, %ecx
31053 rep movsq
31054+ pax_force_retaddr
31055 ret
31056 ENDPROC(copy_page)
31057
31058 ENTRY(copy_page_regs)
31059 subq $2*8, %rsp
31060 movq %rbx, (%rsp)
31061- movq %r12, 1*8(%rsp)
31062+ movq %r13, 1*8(%rsp)
31063
31064 movl $(4096/64)-5, %ecx
31065 .p2align 4
31066@@ -34,7 +35,7 @@ ENTRY(copy_page_regs)
31067 movq 0x8*4(%rsi), %r9
31068 movq 0x8*5(%rsi), %r10
31069 movq 0x8*6(%rsi), %r11
31070- movq 0x8*7(%rsi), %r12
31071+ movq 0x8*7(%rsi), %r13
31072
31073 prefetcht0 5*64(%rsi)
31074
31075@@ -45,7 +46,7 @@ ENTRY(copy_page_regs)
31076 movq %r9, 0x8*4(%rdi)
31077 movq %r10, 0x8*5(%rdi)
31078 movq %r11, 0x8*6(%rdi)
31079- movq %r12, 0x8*7(%rdi)
31080+ movq %r13, 0x8*7(%rdi)
31081
31082 leaq 64 (%rsi), %rsi
31083 leaq 64 (%rdi), %rdi
31084@@ -64,7 +65,7 @@ ENTRY(copy_page_regs)
31085 movq 0x8*4(%rsi), %r9
31086 movq 0x8*5(%rsi), %r10
31087 movq 0x8*6(%rsi), %r11
31088- movq 0x8*7(%rsi), %r12
31089+ movq 0x8*7(%rsi), %r13
31090
31091 movq %rax, 0x8*0(%rdi)
31092 movq %rbx, 0x8*1(%rdi)
31093@@ -73,14 +74,15 @@ ENTRY(copy_page_regs)
31094 movq %r9, 0x8*4(%rdi)
31095 movq %r10, 0x8*5(%rdi)
31096 movq %r11, 0x8*6(%rdi)
31097- movq %r12, 0x8*7(%rdi)
31098+ movq %r13, 0x8*7(%rdi)
31099
31100 leaq 64(%rdi), %rdi
31101 leaq 64(%rsi), %rsi
31102 jnz .Loop2
31103
31104 movq (%rsp), %rbx
31105- movq 1*8(%rsp), %r12
31106+ movq 1*8(%rsp), %r13
31107 addq $2*8, %rsp
31108+ pax_force_retaddr
31109 ret
31110 ENDPROC(copy_page_regs)
31111diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
31112index 982ce34..8e14731 100644
31113--- a/arch/x86/lib/copy_user_64.S
31114+++ b/arch/x86/lib/copy_user_64.S
31115@@ -14,50 +14,7 @@
31116 #include <asm/alternative-asm.h>
31117 #include <asm/asm.h>
31118 #include <asm/smap.h>
31119-
31120-/* Standard copy_to_user with segment limit checking */
31121-ENTRY(_copy_to_user)
31122- GET_THREAD_INFO(%rax)
31123- movq %rdi,%rcx
31124- addq %rdx,%rcx
31125- jc bad_to_user
31126- cmpq TI_addr_limit(%rax),%rcx
31127- ja bad_to_user
31128- ALTERNATIVE_2 "jmp copy_user_generic_unrolled", \
31129- "jmp copy_user_generic_string", \
31130- X86_FEATURE_REP_GOOD, \
31131- "jmp copy_user_enhanced_fast_string", \
31132- X86_FEATURE_ERMS
31133-ENDPROC(_copy_to_user)
31134-
31135-/* Standard copy_from_user with segment limit checking */
31136-ENTRY(_copy_from_user)
31137- GET_THREAD_INFO(%rax)
31138- movq %rsi,%rcx
31139- addq %rdx,%rcx
31140- jc bad_from_user
31141- cmpq TI_addr_limit(%rax),%rcx
31142- ja bad_from_user
31143- ALTERNATIVE_2 "jmp copy_user_generic_unrolled", \
31144- "jmp copy_user_generic_string", \
31145- X86_FEATURE_REP_GOOD, \
31146- "jmp copy_user_enhanced_fast_string", \
31147- X86_FEATURE_ERMS
31148-ENDPROC(_copy_from_user)
31149-
31150- .section .fixup,"ax"
31151- /* must zero dest */
31152-ENTRY(bad_from_user)
31153-bad_from_user:
31154- movl %edx,%ecx
31155- xorl %eax,%eax
31156- rep
31157- stosb
31158-bad_to_user:
31159- movl %edx,%eax
31160- ret
31161-ENDPROC(bad_from_user)
31162- .previous
31163+#include <asm/pgtable.h>
31164
31165 /*
31166 * copy_user_generic_unrolled - memory copy with exception handling.
31167@@ -73,6 +30,7 @@ ENDPROC(bad_from_user)
31168 * eax uncopied bytes or 0 if successful.
31169 */
31170 ENTRY(copy_user_generic_unrolled)
31171+ ASM_PAX_OPEN_USERLAND
31172 ASM_STAC
31173 cmpl $8,%edx
31174 jb 20f /* less then 8 bytes, go to byte copy loop */
31175@@ -122,6 +80,8 @@ ENTRY(copy_user_generic_unrolled)
31176 jnz 21b
31177 23: xor %eax,%eax
31178 ASM_CLAC
31179+ ASM_PAX_CLOSE_USERLAND
31180+ pax_force_retaddr
31181 ret
31182
31183 .section .fixup,"ax"
31184@@ -175,6 +135,7 @@ ENDPROC(copy_user_generic_unrolled)
31185 * eax uncopied bytes or 0 if successful.
31186 */
31187 ENTRY(copy_user_generic_string)
31188+ ASM_PAX_OPEN_USERLAND
31189 ASM_STAC
31190 cmpl $8,%edx
31191 jb 2f /* less than 8 bytes, go to byte copy loop */
31192@@ -189,6 +150,8 @@ ENTRY(copy_user_generic_string)
31193 movsb
31194 xorl %eax,%eax
31195 ASM_CLAC
31196+ ASM_PAX_CLOSE_USERLAND
31197+ pax_force_retaddr
31198 ret
31199
31200 .section .fixup,"ax"
31201@@ -214,12 +177,15 @@ ENDPROC(copy_user_generic_string)
31202 * eax uncopied bytes or 0 if successful.
31203 */
31204 ENTRY(copy_user_enhanced_fast_string)
31205+ ASM_PAX_OPEN_USERLAND
31206 ASM_STAC
31207 movl %edx,%ecx
31208 1: rep
31209 movsb
31210 xorl %eax,%eax
31211 ASM_CLAC
31212+ ASM_PAX_CLOSE_USERLAND
31213+ pax_force_retaddr
31214 ret
31215
31216 .section .fixup,"ax"
31217@@ -235,6 +201,16 @@ ENDPROC(copy_user_enhanced_fast_string)
31218 * This will force destination/source out of cache for more performance.
31219 */
31220 ENTRY(__copy_user_nocache)
31221+
31222+#ifdef CONFIG_PAX_MEMORY_UDEREF
31223+ mov pax_user_shadow_base,%rcx
31224+ cmp %rcx,%rsi
31225+ jae 1f
31226+ add %rcx,%rsi
31227+1:
31228+#endif
31229+
31230+ ASM_PAX_OPEN_USERLAND
31231 ASM_STAC
31232 cmpl $8,%edx
31233 jb 20f /* less then 8 bytes, go to byte copy loop */
31234@@ -284,7 +260,9 @@ ENTRY(__copy_user_nocache)
31235 jnz 21b
31236 23: xorl %eax,%eax
31237 ASM_CLAC
31238+ ASM_PAX_CLOSE_USERLAND
31239 sfence
31240+ pax_force_retaddr
31241 ret
31242
31243 .section .fixup,"ax"
31244diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
31245index 7e48807..cc966ff 100644
31246--- a/arch/x86/lib/csum-copy_64.S
31247+++ b/arch/x86/lib/csum-copy_64.S
31248@@ -8,6 +8,7 @@
31249 #include <linux/linkage.h>
31250 #include <asm/errno.h>
31251 #include <asm/asm.h>
31252+#include <asm/alternative-asm.h>
31253
31254 /*
31255 * Checksum copy with exception handling.
31256@@ -52,7 +53,7 @@ ENTRY(csum_partial_copy_generic)
31257 .Lignore:
31258 subq $7*8, %rsp
31259 movq %rbx, 2*8(%rsp)
31260- movq %r12, 3*8(%rsp)
31261+ movq %r15, 3*8(%rsp)
31262 movq %r14, 4*8(%rsp)
31263 movq %r13, 5*8(%rsp)
31264 movq %rbp, 6*8(%rsp)
31265@@ -64,16 +65,16 @@ ENTRY(csum_partial_copy_generic)
31266 movl %edx, %ecx
31267
31268 xorl %r9d, %r9d
31269- movq %rcx, %r12
31270+ movq %rcx, %r15
31271
31272- shrq $6, %r12
31273+ shrq $6, %r15
31274 jz .Lhandle_tail /* < 64 */
31275
31276 clc
31277
31278 /* main loop. clear in 64 byte blocks */
31279 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
31280- /* r11: temp3, rdx: temp4, r12 loopcnt */
31281+ /* r11: temp3, rdx: temp4, r15 loopcnt */
31282 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
31283 .p2align 4
31284 .Lloop:
31285@@ -107,7 +108,7 @@ ENTRY(csum_partial_copy_generic)
31286 adcq %r14, %rax
31287 adcq %r13, %rax
31288
31289- decl %r12d
31290+ decl %r15d
31291
31292 dest
31293 movq %rbx, (%rsi)
31294@@ -200,11 +201,12 @@ ENTRY(csum_partial_copy_generic)
31295
31296 .Lende:
31297 movq 2*8(%rsp), %rbx
31298- movq 3*8(%rsp), %r12
31299+ movq 3*8(%rsp), %r15
31300 movq 4*8(%rsp), %r14
31301 movq 5*8(%rsp), %r13
31302 movq 6*8(%rsp), %rbp
31303 addq $7*8, %rsp
31304+ pax_force_retaddr
31305 ret
31306
31307 /* Exception handlers. Very simple, zeroing is done in the wrappers */
31308diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
31309index 1318f75..44c30fd 100644
31310--- a/arch/x86/lib/csum-wrappers_64.c
31311+++ b/arch/x86/lib/csum-wrappers_64.c
31312@@ -52,10 +52,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
31313 len -= 2;
31314 }
31315 }
31316+ pax_open_userland();
31317 stac();
31318- isum = csum_partial_copy_generic((__force const void *)src,
31319+ isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
31320 dst, len, isum, errp, NULL);
31321 clac();
31322+ pax_close_userland();
31323 if (unlikely(*errp))
31324 goto out_err;
31325
31326@@ -109,10 +111,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
31327 }
31328
31329 *errp = 0;
31330+ pax_open_userland();
31331 stac();
31332- ret = csum_partial_copy_generic(src, (void __force *)dst,
31333+ ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
31334 len, isum, NULL, errp);
31335 clac();
31336+ pax_close_userland();
31337 return ret;
31338 }
31339 EXPORT_SYMBOL(csum_partial_copy_to_user);
31340diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
31341index 46668cd..a3bdfb9 100644
31342--- a/arch/x86/lib/getuser.S
31343+++ b/arch/x86/lib/getuser.S
31344@@ -32,42 +32,93 @@
31345 #include <asm/thread_info.h>
31346 #include <asm/asm.h>
31347 #include <asm/smap.h>
31348+#include <asm/segment.h>
31349+#include <asm/pgtable.h>
31350+#include <asm/alternative-asm.h>
31351+
31352+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
31353+#define __copyuser_seg gs;
31354+#else
31355+#define __copyuser_seg
31356+#endif
31357
31358 .text
31359 ENTRY(__get_user_1)
31360+
31361+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31362 GET_THREAD_INFO(%_ASM_DX)
31363 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31364 jae bad_get_user
31365+
31366+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31367+ mov pax_user_shadow_base,%_ASM_DX
31368+ cmp %_ASM_DX,%_ASM_AX
31369+ jae 1234f
31370+ add %_ASM_DX,%_ASM_AX
31371+1234:
31372+#endif
31373+
31374+#endif
31375+
31376 ASM_STAC
31377-1: movzbl (%_ASM_AX),%edx
31378+1: __copyuser_seg movzbl (%_ASM_AX),%edx
31379 xor %eax,%eax
31380 ASM_CLAC
31381+ pax_force_retaddr
31382 ret
31383 ENDPROC(__get_user_1)
31384
31385 ENTRY(__get_user_2)
31386 add $1,%_ASM_AX
31387+
31388+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31389 jc bad_get_user
31390 GET_THREAD_INFO(%_ASM_DX)
31391 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31392 jae bad_get_user
31393+
31394+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31395+ mov pax_user_shadow_base,%_ASM_DX
31396+ cmp %_ASM_DX,%_ASM_AX
31397+ jae 1234f
31398+ add %_ASM_DX,%_ASM_AX
31399+1234:
31400+#endif
31401+
31402+#endif
31403+
31404 ASM_STAC
31405-2: movzwl -1(%_ASM_AX),%edx
31406+2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
31407 xor %eax,%eax
31408 ASM_CLAC
31409+ pax_force_retaddr
31410 ret
31411 ENDPROC(__get_user_2)
31412
31413 ENTRY(__get_user_4)
31414 add $3,%_ASM_AX
31415+
31416+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31417 jc bad_get_user
31418 GET_THREAD_INFO(%_ASM_DX)
31419 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31420 jae bad_get_user
31421+
31422+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31423+ mov pax_user_shadow_base,%_ASM_DX
31424+ cmp %_ASM_DX,%_ASM_AX
31425+ jae 1234f
31426+ add %_ASM_DX,%_ASM_AX
31427+1234:
31428+#endif
31429+
31430+#endif
31431+
31432 ASM_STAC
31433-3: movl -3(%_ASM_AX),%edx
31434+3: __copyuser_seg movl -3(%_ASM_AX),%edx
31435 xor %eax,%eax
31436 ASM_CLAC
31437+ pax_force_retaddr
31438 ret
31439 ENDPROC(__get_user_4)
31440
31441@@ -78,10 +129,20 @@ ENTRY(__get_user_8)
31442 GET_THREAD_INFO(%_ASM_DX)
31443 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31444 jae bad_get_user
31445+
31446+#ifdef CONFIG_PAX_MEMORY_UDEREF
31447+ mov pax_user_shadow_base,%_ASM_DX
31448+ cmp %_ASM_DX,%_ASM_AX
31449+ jae 1234f
31450+ add %_ASM_DX,%_ASM_AX
31451+1234:
31452+#endif
31453+
31454 ASM_STAC
31455 4: movq -7(%_ASM_AX),%rdx
31456 xor %eax,%eax
31457 ASM_CLAC
31458+ pax_force_retaddr
31459 ret
31460 #else
31461 add $7,%_ASM_AX
31462@@ -90,10 +151,11 @@ ENTRY(__get_user_8)
31463 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
31464 jae bad_get_user_8
31465 ASM_STAC
31466-4: movl -7(%_ASM_AX),%edx
31467-5: movl -3(%_ASM_AX),%ecx
31468+4: __copyuser_seg movl -7(%_ASM_AX),%edx
31469+5: __copyuser_seg movl -3(%_ASM_AX),%ecx
31470 xor %eax,%eax
31471 ASM_CLAC
31472+ pax_force_retaddr
31473 ret
31474 #endif
31475 ENDPROC(__get_user_8)
31476@@ -103,6 +165,7 @@ bad_get_user:
31477 xor %edx,%edx
31478 mov $(-EFAULT),%_ASM_AX
31479 ASM_CLAC
31480+ pax_force_retaddr
31481 ret
31482 END(bad_get_user)
31483
31484@@ -112,6 +175,7 @@ bad_get_user_8:
31485 xor %ecx,%ecx
31486 mov $(-EFAULT),%_ASM_AX
31487 ASM_CLAC
31488+ pax_force_retaddr
31489 ret
31490 END(bad_get_user_8)
31491 #endif
31492diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
31493index 8f72b33..4667a46 100644
31494--- a/arch/x86/lib/insn.c
31495+++ b/arch/x86/lib/insn.c
31496@@ -20,8 +20,10 @@
31497
31498 #ifdef __KERNEL__
31499 #include <linux/string.h>
31500+#include <asm/pgtable_types.h>
31501 #else
31502 #include <string.h>
31503+#define ktla_ktva(addr) addr
31504 #endif
31505 #include <asm/inat.h>
31506 #include <asm/insn.h>
31507@@ -60,9 +62,9 @@ void insn_init(struct insn *insn, const void *kaddr, int buf_len, int x86_64)
31508 buf_len = MAX_INSN_SIZE;
31509
31510 memset(insn, 0, sizeof(*insn));
31511- insn->kaddr = kaddr;
31512- insn->end_kaddr = kaddr + buf_len;
31513- insn->next_byte = kaddr;
31514+ insn->kaddr = (void *)ktla_ktva((unsigned long)kaddr);
31515+ insn->end_kaddr = insn->kaddr + buf_len;
31516+ insn->next_byte = insn->kaddr;
31517 insn->x86_64 = x86_64 ? 1 : 0;
31518 insn->opnd_bytes = 4;
31519 if (x86_64)
31520diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
31521index 33147fe..12a8815 100644
31522--- a/arch/x86/lib/iomap_copy_64.S
31523+++ b/arch/x86/lib/iomap_copy_64.S
31524@@ -16,6 +16,7 @@
31525 */
31526
31527 #include <linux/linkage.h>
31528+#include <asm/alternative-asm.h>
31529
31530 /*
31531 * override generic version in lib/iomap_copy.c
31532@@ -23,5 +24,6 @@
31533 ENTRY(__iowrite32_copy)
31534 movl %edx,%ecx
31535 rep movsd
31536+ pax_force_retaddr
31537 ret
31538 ENDPROC(__iowrite32_copy)
31539diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
31540index 16698bb..971d300 100644
31541--- a/arch/x86/lib/memcpy_64.S
31542+++ b/arch/x86/lib/memcpy_64.S
31543@@ -36,6 +36,7 @@ ENTRY(memcpy)
31544 rep movsq
31545 movl %edx, %ecx
31546 rep movsb
31547+ pax_force_retaddr
31548 ret
31549 ENDPROC(memcpy)
31550 ENDPROC(__memcpy)
31551@@ -48,6 +49,7 @@ ENTRY(memcpy_erms)
31552 movq %rdi, %rax
31553 movq %rdx, %rcx
31554 rep movsb
31555+ pax_force_retaddr
31556 ret
31557 ENDPROC(memcpy_erms)
31558
31559@@ -132,6 +134,7 @@ ENTRY(memcpy_orig)
31560 movq %r9, 1*8(%rdi)
31561 movq %r10, -2*8(%rdi, %rdx)
31562 movq %r11, -1*8(%rdi, %rdx)
31563+ pax_force_retaddr
31564 retq
31565 .p2align 4
31566 .Lless_16bytes:
31567@@ -144,6 +147,7 @@ ENTRY(memcpy_orig)
31568 movq -1*8(%rsi, %rdx), %r9
31569 movq %r8, 0*8(%rdi)
31570 movq %r9, -1*8(%rdi, %rdx)
31571+ pax_force_retaddr
31572 retq
31573 .p2align 4
31574 .Lless_8bytes:
31575@@ -157,6 +161,7 @@ ENTRY(memcpy_orig)
31576 movl -4(%rsi, %rdx), %r8d
31577 movl %ecx, (%rdi)
31578 movl %r8d, -4(%rdi, %rdx)
31579+ pax_force_retaddr
31580 retq
31581 .p2align 4
31582 .Lless_3bytes:
31583@@ -175,5 +180,6 @@ ENTRY(memcpy_orig)
31584 movb %cl, (%rdi)
31585
31586 .Lend:
31587+ pax_force_retaddr
31588 retq
31589 ENDPROC(memcpy_orig)
31590diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
31591index ca2afdd..2e474fa 100644
31592--- a/arch/x86/lib/memmove_64.S
31593+++ b/arch/x86/lib/memmove_64.S
31594@@ -41,7 +41,7 @@ ENTRY(__memmove)
31595 jg 2f
31596
31597 .Lmemmove_begin_forward:
31598- ALTERNATIVE "", "movq %rdx, %rcx; rep movsb; retq", X86_FEATURE_ERMS
31599+ ALTERNATIVE "", "movq %rdx, %rcx; rep movsb; pax_force_retaddr; retq", X86_FEATURE_ERMS
31600
31601 /*
31602 * movsq instruction have many startup latency
31603@@ -204,6 +204,7 @@ ENTRY(__memmove)
31604 movb (%rsi), %r11b
31605 movb %r11b, (%rdi)
31606 13:
31607+ pax_force_retaddr
31608 retq
31609 ENDPROC(__memmove)
31610 ENDPROC(memmove)
31611diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
31612index 2661fad..b584d5c 100644
31613--- a/arch/x86/lib/memset_64.S
31614+++ b/arch/x86/lib/memset_64.S
31615@@ -40,6 +40,7 @@ ENTRY(__memset)
31616 movl %edx,%ecx
31617 rep stosb
31618 movq %r9,%rax
31619+ pax_force_retaddr
31620 ret
31621 ENDPROC(memset)
31622 ENDPROC(__memset)
31623@@ -61,6 +62,7 @@ ENTRY(memset_erms)
31624 movq %rdx,%rcx
31625 rep stosb
31626 movq %r9,%rax
31627+ pax_force_retaddr
31628 ret
31629 ENDPROC(memset_erms)
31630
31631@@ -123,6 +125,7 @@ ENTRY(memset_orig)
31632
31633 .Lende:
31634 movq %r10,%rax
31635+ pax_force_retaddr
31636 ret
31637
31638 .Lbad_alignment:
31639diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
31640index e5e3ed8..d7c08c2 100644
31641--- a/arch/x86/lib/mmx_32.c
31642+++ b/arch/x86/lib/mmx_32.c
31643@@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
31644 {
31645 void *p;
31646 int i;
31647+ unsigned long cr0;
31648
31649 if (unlikely(in_interrupt()))
31650 return __memcpy(to, from, len);
31651@@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
31652 kernel_fpu_begin();
31653
31654 __asm__ __volatile__ (
31655- "1: prefetch (%0)\n" /* This set is 28 bytes */
31656- " prefetch 64(%0)\n"
31657- " prefetch 128(%0)\n"
31658- " prefetch 192(%0)\n"
31659- " prefetch 256(%0)\n"
31660+ "1: prefetch (%1)\n" /* This set is 28 bytes */
31661+ " prefetch 64(%1)\n"
31662+ " prefetch 128(%1)\n"
31663+ " prefetch 192(%1)\n"
31664+ " prefetch 256(%1)\n"
31665 "2: \n"
31666 ".section .fixup, \"ax\"\n"
31667- "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31668+ "3: \n"
31669+
31670+#ifdef CONFIG_PAX_KERNEXEC
31671+ " movl %%cr0, %0\n"
31672+ " movl %0, %%eax\n"
31673+ " andl $0xFFFEFFFF, %%eax\n"
31674+ " movl %%eax, %%cr0\n"
31675+#endif
31676+
31677+ " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31678+
31679+#ifdef CONFIG_PAX_KERNEXEC
31680+ " movl %0, %%cr0\n"
31681+#endif
31682+
31683 " jmp 2b\n"
31684 ".previous\n"
31685 _ASM_EXTABLE(1b, 3b)
31686- : : "r" (from));
31687+ : "=&r" (cr0) : "r" (from) : "ax");
31688
31689 for ( ; i > 5; i--) {
31690 __asm__ __volatile__ (
31691- "1: prefetch 320(%0)\n"
31692- "2: movq (%0), %%mm0\n"
31693- " movq 8(%0), %%mm1\n"
31694- " movq 16(%0), %%mm2\n"
31695- " movq 24(%0), %%mm3\n"
31696- " movq %%mm0, (%1)\n"
31697- " movq %%mm1, 8(%1)\n"
31698- " movq %%mm2, 16(%1)\n"
31699- " movq %%mm3, 24(%1)\n"
31700- " movq 32(%0), %%mm0\n"
31701- " movq 40(%0), %%mm1\n"
31702- " movq 48(%0), %%mm2\n"
31703- " movq 56(%0), %%mm3\n"
31704- " movq %%mm0, 32(%1)\n"
31705- " movq %%mm1, 40(%1)\n"
31706- " movq %%mm2, 48(%1)\n"
31707- " movq %%mm3, 56(%1)\n"
31708+ "1: prefetch 320(%1)\n"
31709+ "2: movq (%1), %%mm0\n"
31710+ " movq 8(%1), %%mm1\n"
31711+ " movq 16(%1), %%mm2\n"
31712+ " movq 24(%1), %%mm3\n"
31713+ " movq %%mm0, (%2)\n"
31714+ " movq %%mm1, 8(%2)\n"
31715+ " movq %%mm2, 16(%2)\n"
31716+ " movq %%mm3, 24(%2)\n"
31717+ " movq 32(%1), %%mm0\n"
31718+ " movq 40(%1), %%mm1\n"
31719+ " movq 48(%1), %%mm2\n"
31720+ " movq 56(%1), %%mm3\n"
31721+ " movq %%mm0, 32(%2)\n"
31722+ " movq %%mm1, 40(%2)\n"
31723+ " movq %%mm2, 48(%2)\n"
31724+ " movq %%mm3, 56(%2)\n"
31725 ".section .fixup, \"ax\"\n"
31726- "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31727+ "3:\n"
31728+
31729+#ifdef CONFIG_PAX_KERNEXEC
31730+ " movl %%cr0, %0\n"
31731+ " movl %0, %%eax\n"
31732+ " andl $0xFFFEFFFF, %%eax\n"
31733+ " movl %%eax, %%cr0\n"
31734+#endif
31735+
31736+ " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31737+
31738+#ifdef CONFIG_PAX_KERNEXEC
31739+ " movl %0, %%cr0\n"
31740+#endif
31741+
31742 " jmp 2b\n"
31743 ".previous\n"
31744 _ASM_EXTABLE(1b, 3b)
31745- : : "r" (from), "r" (to) : "memory");
31746+ : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
31747
31748 from += 64;
31749 to += 64;
31750@@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
31751 static void fast_copy_page(void *to, void *from)
31752 {
31753 int i;
31754+ unsigned long cr0;
31755
31756 kernel_fpu_begin();
31757
31758@@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
31759 * but that is for later. -AV
31760 */
31761 __asm__ __volatile__(
31762- "1: prefetch (%0)\n"
31763- " prefetch 64(%0)\n"
31764- " prefetch 128(%0)\n"
31765- " prefetch 192(%0)\n"
31766- " prefetch 256(%0)\n"
31767+ "1: prefetch (%1)\n"
31768+ " prefetch 64(%1)\n"
31769+ " prefetch 128(%1)\n"
31770+ " prefetch 192(%1)\n"
31771+ " prefetch 256(%1)\n"
31772 "2: \n"
31773 ".section .fixup, \"ax\"\n"
31774- "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31775+ "3: \n"
31776+
31777+#ifdef CONFIG_PAX_KERNEXEC
31778+ " movl %%cr0, %0\n"
31779+ " movl %0, %%eax\n"
31780+ " andl $0xFFFEFFFF, %%eax\n"
31781+ " movl %%eax, %%cr0\n"
31782+#endif
31783+
31784+ " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31785+
31786+#ifdef CONFIG_PAX_KERNEXEC
31787+ " movl %0, %%cr0\n"
31788+#endif
31789+
31790 " jmp 2b\n"
31791 ".previous\n"
31792- _ASM_EXTABLE(1b, 3b) : : "r" (from));
31793+ _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
31794
31795 for (i = 0; i < (4096-320)/64; i++) {
31796 __asm__ __volatile__ (
31797- "1: prefetch 320(%0)\n"
31798- "2: movq (%0), %%mm0\n"
31799- " movntq %%mm0, (%1)\n"
31800- " movq 8(%0), %%mm1\n"
31801- " movntq %%mm1, 8(%1)\n"
31802- " movq 16(%0), %%mm2\n"
31803- " movntq %%mm2, 16(%1)\n"
31804- " movq 24(%0), %%mm3\n"
31805- " movntq %%mm3, 24(%1)\n"
31806- " movq 32(%0), %%mm4\n"
31807- " movntq %%mm4, 32(%1)\n"
31808- " movq 40(%0), %%mm5\n"
31809- " movntq %%mm5, 40(%1)\n"
31810- " movq 48(%0), %%mm6\n"
31811- " movntq %%mm6, 48(%1)\n"
31812- " movq 56(%0), %%mm7\n"
31813- " movntq %%mm7, 56(%1)\n"
31814+ "1: prefetch 320(%1)\n"
31815+ "2: movq (%1), %%mm0\n"
31816+ " movntq %%mm0, (%2)\n"
31817+ " movq 8(%1), %%mm1\n"
31818+ " movntq %%mm1, 8(%2)\n"
31819+ " movq 16(%1), %%mm2\n"
31820+ " movntq %%mm2, 16(%2)\n"
31821+ " movq 24(%1), %%mm3\n"
31822+ " movntq %%mm3, 24(%2)\n"
31823+ " movq 32(%1), %%mm4\n"
31824+ " movntq %%mm4, 32(%2)\n"
31825+ " movq 40(%1), %%mm5\n"
31826+ " movntq %%mm5, 40(%2)\n"
31827+ " movq 48(%1), %%mm6\n"
31828+ " movntq %%mm6, 48(%2)\n"
31829+ " movq 56(%1), %%mm7\n"
31830+ " movntq %%mm7, 56(%2)\n"
31831 ".section .fixup, \"ax\"\n"
31832- "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31833+ "3:\n"
31834+
31835+#ifdef CONFIG_PAX_KERNEXEC
31836+ " movl %%cr0, %0\n"
31837+ " movl %0, %%eax\n"
31838+ " andl $0xFFFEFFFF, %%eax\n"
31839+ " movl %%eax, %%cr0\n"
31840+#endif
31841+
31842+ " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31843+
31844+#ifdef CONFIG_PAX_KERNEXEC
31845+ " movl %0, %%cr0\n"
31846+#endif
31847+
31848 " jmp 2b\n"
31849 ".previous\n"
31850- _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
31851+ _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
31852
31853 from += 64;
31854 to += 64;
31855@@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
31856 static void fast_copy_page(void *to, void *from)
31857 {
31858 int i;
31859+ unsigned long cr0;
31860
31861 kernel_fpu_begin();
31862
31863 __asm__ __volatile__ (
31864- "1: prefetch (%0)\n"
31865- " prefetch 64(%0)\n"
31866- " prefetch 128(%0)\n"
31867- " prefetch 192(%0)\n"
31868- " prefetch 256(%0)\n"
31869+ "1: prefetch (%1)\n"
31870+ " prefetch 64(%1)\n"
31871+ " prefetch 128(%1)\n"
31872+ " prefetch 192(%1)\n"
31873+ " prefetch 256(%1)\n"
31874 "2: \n"
31875 ".section .fixup, \"ax\"\n"
31876- "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31877+ "3: \n"
31878+
31879+#ifdef CONFIG_PAX_KERNEXEC
31880+ " movl %%cr0, %0\n"
31881+ " movl %0, %%eax\n"
31882+ " andl $0xFFFEFFFF, %%eax\n"
31883+ " movl %%eax, %%cr0\n"
31884+#endif
31885+
31886+ " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31887+
31888+#ifdef CONFIG_PAX_KERNEXEC
31889+ " movl %0, %%cr0\n"
31890+#endif
31891+
31892 " jmp 2b\n"
31893 ".previous\n"
31894- _ASM_EXTABLE(1b, 3b) : : "r" (from));
31895+ _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
31896
31897 for (i = 0; i < 4096/64; i++) {
31898 __asm__ __volatile__ (
31899- "1: prefetch 320(%0)\n"
31900- "2: movq (%0), %%mm0\n"
31901- " movq 8(%0), %%mm1\n"
31902- " movq 16(%0), %%mm2\n"
31903- " movq 24(%0), %%mm3\n"
31904- " movq %%mm0, (%1)\n"
31905- " movq %%mm1, 8(%1)\n"
31906- " movq %%mm2, 16(%1)\n"
31907- " movq %%mm3, 24(%1)\n"
31908- " movq 32(%0), %%mm0\n"
31909- " movq 40(%0), %%mm1\n"
31910- " movq 48(%0), %%mm2\n"
31911- " movq 56(%0), %%mm3\n"
31912- " movq %%mm0, 32(%1)\n"
31913- " movq %%mm1, 40(%1)\n"
31914- " movq %%mm2, 48(%1)\n"
31915- " movq %%mm3, 56(%1)\n"
31916+ "1: prefetch 320(%1)\n"
31917+ "2: movq (%1), %%mm0\n"
31918+ " movq 8(%1), %%mm1\n"
31919+ " movq 16(%1), %%mm2\n"
31920+ " movq 24(%1), %%mm3\n"
31921+ " movq %%mm0, (%2)\n"
31922+ " movq %%mm1, 8(%2)\n"
31923+ " movq %%mm2, 16(%2)\n"
31924+ " movq %%mm3, 24(%2)\n"
31925+ " movq 32(%1), %%mm0\n"
31926+ " movq 40(%1), %%mm1\n"
31927+ " movq 48(%1), %%mm2\n"
31928+ " movq 56(%1), %%mm3\n"
31929+ " movq %%mm0, 32(%2)\n"
31930+ " movq %%mm1, 40(%2)\n"
31931+ " movq %%mm2, 48(%2)\n"
31932+ " movq %%mm3, 56(%2)\n"
31933 ".section .fixup, \"ax\"\n"
31934- "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31935+ "3:\n"
31936+
31937+#ifdef CONFIG_PAX_KERNEXEC
31938+ " movl %%cr0, %0\n"
31939+ " movl %0, %%eax\n"
31940+ " andl $0xFFFEFFFF, %%eax\n"
31941+ " movl %%eax, %%cr0\n"
31942+#endif
31943+
31944+ " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31945+
31946+#ifdef CONFIG_PAX_KERNEXEC
31947+ " movl %0, %%cr0\n"
31948+#endif
31949+
31950 " jmp 2b\n"
31951 ".previous\n"
31952 _ASM_EXTABLE(1b, 3b)
31953- : : "r" (from), "r" (to) : "memory");
31954+ : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
31955
31956 from += 64;
31957 to += 64;
31958diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
31959index c815564..303dcfa 100644
31960--- a/arch/x86/lib/msr-reg.S
31961+++ b/arch/x86/lib/msr-reg.S
31962@@ -2,6 +2,7 @@
31963 #include <linux/errno.h>
31964 #include <asm/asm.h>
31965 #include <asm/msr.h>
31966+#include <asm/alternative-asm.h>
31967
31968 #ifdef CONFIG_X86_64
31969 /*
31970@@ -34,6 +35,7 @@ ENTRY(\op\()_safe_regs)
31971 movl %edi, 28(%r10)
31972 popq %rbp
31973 popq %rbx
31974+ pax_force_retaddr
31975 ret
31976 3:
31977 movl $-EIO, %r11d
31978diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
31979index e0817a1..bc9cf66 100644
31980--- a/arch/x86/lib/putuser.S
31981+++ b/arch/x86/lib/putuser.S
31982@@ -15,7 +15,9 @@
31983 #include <asm/errno.h>
31984 #include <asm/asm.h>
31985 #include <asm/smap.h>
31986-
31987+#include <asm/segment.h>
31988+#include <asm/pgtable.h>
31989+#include <asm/alternative-asm.h>
31990
31991 /*
31992 * __put_user_X
31993@@ -29,55 +31,124 @@
31994 * as they get called from within inline assembly.
31995 */
31996
31997-#define ENTER GET_THREAD_INFO(%_ASM_BX)
31998-#define EXIT ASM_CLAC ; \
31999+#define ENTER
32000+#define EXIT ASM_CLAC ; \
32001+ pax_force_retaddr ; \
32002 ret
32003
32004+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32005+#define _DEST %_ASM_CX,%_ASM_BX
32006+#else
32007+#define _DEST %_ASM_CX
32008+#endif
32009+
32010+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
32011+#define __copyuser_seg gs;
32012+#else
32013+#define __copyuser_seg
32014+#endif
32015+
32016 .text
32017 ENTRY(__put_user_1)
32018 ENTER
32019+
32020+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
32021+ GET_THREAD_INFO(%_ASM_BX)
32022 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
32023 jae bad_put_user
32024+
32025+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32026+ mov pax_user_shadow_base,%_ASM_BX
32027+ cmp %_ASM_BX,%_ASM_CX
32028+ jb 1234f
32029+ xor %ebx,%ebx
32030+1234:
32031+#endif
32032+
32033+#endif
32034+
32035 ASM_STAC
32036-1: movb %al,(%_ASM_CX)
32037+1: __copyuser_seg movb %al,(_DEST)
32038 xor %eax,%eax
32039 EXIT
32040 ENDPROC(__put_user_1)
32041
32042 ENTRY(__put_user_2)
32043 ENTER
32044+
32045+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
32046+ GET_THREAD_INFO(%_ASM_BX)
32047 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
32048 sub $1,%_ASM_BX
32049 cmp %_ASM_BX,%_ASM_CX
32050 jae bad_put_user
32051+
32052+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32053+ mov pax_user_shadow_base,%_ASM_BX
32054+ cmp %_ASM_BX,%_ASM_CX
32055+ jb 1234f
32056+ xor %ebx,%ebx
32057+1234:
32058+#endif
32059+
32060+#endif
32061+
32062 ASM_STAC
32063-2: movw %ax,(%_ASM_CX)
32064+2: __copyuser_seg movw %ax,(_DEST)
32065 xor %eax,%eax
32066 EXIT
32067 ENDPROC(__put_user_2)
32068
32069 ENTRY(__put_user_4)
32070 ENTER
32071+
32072+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
32073+ GET_THREAD_INFO(%_ASM_BX)
32074 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
32075 sub $3,%_ASM_BX
32076 cmp %_ASM_BX,%_ASM_CX
32077 jae bad_put_user
32078+
32079+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32080+ mov pax_user_shadow_base,%_ASM_BX
32081+ cmp %_ASM_BX,%_ASM_CX
32082+ jb 1234f
32083+ xor %ebx,%ebx
32084+1234:
32085+#endif
32086+
32087+#endif
32088+
32089 ASM_STAC
32090-3: movl %eax,(%_ASM_CX)
32091+3: __copyuser_seg movl %eax,(_DEST)
32092 xor %eax,%eax
32093 EXIT
32094 ENDPROC(__put_user_4)
32095
32096 ENTRY(__put_user_8)
32097 ENTER
32098+
32099+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
32100+ GET_THREAD_INFO(%_ASM_BX)
32101 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
32102 sub $7,%_ASM_BX
32103 cmp %_ASM_BX,%_ASM_CX
32104 jae bad_put_user
32105+
32106+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32107+ mov pax_user_shadow_base,%_ASM_BX
32108+ cmp %_ASM_BX,%_ASM_CX
32109+ jb 1234f
32110+ xor %ebx,%ebx
32111+1234:
32112+#endif
32113+
32114+#endif
32115+
32116 ASM_STAC
32117-4: mov %_ASM_AX,(%_ASM_CX)
32118+4: __copyuser_seg mov %_ASM_AX,(_DEST)
32119 #ifdef CONFIG_X86_32
32120-5: movl %edx,4(%_ASM_CX)
32121+5: __copyuser_seg movl %edx,4(_DEST)
32122 #endif
32123 xor %eax,%eax
32124 EXIT
32125diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
32126index 40027db..37bb69d 100644
32127--- a/arch/x86/lib/rwsem.S
32128+++ b/arch/x86/lib/rwsem.S
32129@@ -90,6 +90,7 @@ ENTRY(call_rwsem_down_read_failed)
32130 call rwsem_down_read_failed
32131 __ASM_SIZE(pop,) %__ASM_REG(dx)
32132 restore_common_regs
32133+ pax_force_retaddr
32134 ret
32135 ENDPROC(call_rwsem_down_read_failed)
32136
32137@@ -98,6 +99,7 @@ ENTRY(call_rwsem_down_write_failed)
32138 movq %rax,%rdi
32139 call rwsem_down_write_failed
32140 restore_common_regs
32141+ pax_force_retaddr
32142 ret
32143 ENDPROC(call_rwsem_down_write_failed)
32144
32145@@ -109,7 +111,8 @@ ENTRY(call_rwsem_wake)
32146 movq %rax,%rdi
32147 call rwsem_wake
32148 restore_common_regs
32149-1: ret
32150+1: pax_force_retaddr
32151+ ret
32152 ENDPROC(call_rwsem_wake)
32153
32154 ENTRY(call_rwsem_downgrade_wake)
32155@@ -119,5 +122,6 @@ ENTRY(call_rwsem_downgrade_wake)
32156 call rwsem_downgrade_wake
32157 __ASM_SIZE(pop,) %__ASM_REG(dx)
32158 restore_common_regs
32159+ pax_force_retaddr
32160 ret
32161 ENDPROC(call_rwsem_downgrade_wake)
32162diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
32163index 91d93b9..4b22130 100644
32164--- a/arch/x86/lib/usercopy_32.c
32165+++ b/arch/x86/lib/usercopy_32.c
32166@@ -42,11 +42,13 @@ do { \
32167 int __d0; \
32168 might_fault(); \
32169 __asm__ __volatile__( \
32170+ __COPYUSER_SET_ES \
32171 ASM_STAC "\n" \
32172 "0: rep; stosl\n" \
32173 " movl %2,%0\n" \
32174 "1: rep; stosb\n" \
32175 "2: " ASM_CLAC "\n" \
32176+ __COPYUSER_RESTORE_ES \
32177 ".section .fixup,\"ax\"\n" \
32178 "3: lea 0(%2,%0,4),%0\n" \
32179 " jmp 2b\n" \
32180@@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
32181
32182 #ifdef CONFIG_X86_INTEL_USERCOPY
32183 static unsigned long
32184-__copy_user_intel(void __user *to, const void *from, unsigned long size)
32185+__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
32186 {
32187 int d0, d1;
32188 __asm__ __volatile__(
32189@@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
32190 " .align 2,0x90\n"
32191 "3: movl 0(%4), %%eax\n"
32192 "4: movl 4(%4), %%edx\n"
32193- "5: movl %%eax, 0(%3)\n"
32194- "6: movl %%edx, 4(%3)\n"
32195+ "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
32196+ "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
32197 "7: movl 8(%4), %%eax\n"
32198 "8: movl 12(%4),%%edx\n"
32199- "9: movl %%eax, 8(%3)\n"
32200- "10: movl %%edx, 12(%3)\n"
32201+ "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
32202+ "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
32203 "11: movl 16(%4), %%eax\n"
32204 "12: movl 20(%4), %%edx\n"
32205- "13: movl %%eax, 16(%3)\n"
32206- "14: movl %%edx, 20(%3)\n"
32207+ "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
32208+ "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
32209 "15: movl 24(%4), %%eax\n"
32210 "16: movl 28(%4), %%edx\n"
32211- "17: movl %%eax, 24(%3)\n"
32212- "18: movl %%edx, 28(%3)\n"
32213+ "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
32214+ "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
32215 "19: movl 32(%4), %%eax\n"
32216 "20: movl 36(%4), %%edx\n"
32217- "21: movl %%eax, 32(%3)\n"
32218- "22: movl %%edx, 36(%3)\n"
32219+ "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
32220+ "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
32221 "23: movl 40(%4), %%eax\n"
32222 "24: movl 44(%4), %%edx\n"
32223- "25: movl %%eax, 40(%3)\n"
32224- "26: movl %%edx, 44(%3)\n"
32225+ "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
32226+ "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
32227 "27: movl 48(%4), %%eax\n"
32228 "28: movl 52(%4), %%edx\n"
32229- "29: movl %%eax, 48(%3)\n"
32230- "30: movl %%edx, 52(%3)\n"
32231+ "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
32232+ "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
32233 "31: movl 56(%4), %%eax\n"
32234 "32: movl 60(%4), %%edx\n"
32235- "33: movl %%eax, 56(%3)\n"
32236- "34: movl %%edx, 60(%3)\n"
32237+ "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
32238+ "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
32239 " addl $-64, %0\n"
32240 " addl $64, %4\n"
32241 " addl $64, %3\n"
32242@@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
32243 " shrl $2, %0\n"
32244 " andl $3, %%eax\n"
32245 " cld\n"
32246+ __COPYUSER_SET_ES
32247 "99: rep; movsl\n"
32248 "36: movl %%eax, %0\n"
32249 "37: rep; movsb\n"
32250 "100:\n"
32251+ __COPYUSER_RESTORE_ES
32252+ ".section .fixup,\"ax\"\n"
32253+ "101: lea 0(%%eax,%0,4),%0\n"
32254+ " jmp 100b\n"
32255+ ".previous\n"
32256+ _ASM_EXTABLE(1b,100b)
32257+ _ASM_EXTABLE(2b,100b)
32258+ _ASM_EXTABLE(3b,100b)
32259+ _ASM_EXTABLE(4b,100b)
32260+ _ASM_EXTABLE(5b,100b)
32261+ _ASM_EXTABLE(6b,100b)
32262+ _ASM_EXTABLE(7b,100b)
32263+ _ASM_EXTABLE(8b,100b)
32264+ _ASM_EXTABLE(9b,100b)
32265+ _ASM_EXTABLE(10b,100b)
32266+ _ASM_EXTABLE(11b,100b)
32267+ _ASM_EXTABLE(12b,100b)
32268+ _ASM_EXTABLE(13b,100b)
32269+ _ASM_EXTABLE(14b,100b)
32270+ _ASM_EXTABLE(15b,100b)
32271+ _ASM_EXTABLE(16b,100b)
32272+ _ASM_EXTABLE(17b,100b)
32273+ _ASM_EXTABLE(18b,100b)
32274+ _ASM_EXTABLE(19b,100b)
32275+ _ASM_EXTABLE(20b,100b)
32276+ _ASM_EXTABLE(21b,100b)
32277+ _ASM_EXTABLE(22b,100b)
32278+ _ASM_EXTABLE(23b,100b)
32279+ _ASM_EXTABLE(24b,100b)
32280+ _ASM_EXTABLE(25b,100b)
32281+ _ASM_EXTABLE(26b,100b)
32282+ _ASM_EXTABLE(27b,100b)
32283+ _ASM_EXTABLE(28b,100b)
32284+ _ASM_EXTABLE(29b,100b)
32285+ _ASM_EXTABLE(30b,100b)
32286+ _ASM_EXTABLE(31b,100b)
32287+ _ASM_EXTABLE(32b,100b)
32288+ _ASM_EXTABLE(33b,100b)
32289+ _ASM_EXTABLE(34b,100b)
32290+ _ASM_EXTABLE(35b,100b)
32291+ _ASM_EXTABLE(36b,100b)
32292+ _ASM_EXTABLE(37b,100b)
32293+ _ASM_EXTABLE(99b,101b)
32294+ : "=&c"(size), "=&D" (d0), "=&S" (d1)
32295+ : "1"(to), "2"(from), "0"(size)
32296+ : "eax", "edx", "memory");
32297+ return size;
32298+}
32299+
32300+static unsigned long
32301+__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
32302+{
32303+ int d0, d1;
32304+ __asm__ __volatile__(
32305+ " .align 2,0x90\n"
32306+ "1: "__copyuser_seg" movl 32(%4), %%eax\n"
32307+ " cmpl $67, %0\n"
32308+ " jbe 3f\n"
32309+ "2: "__copyuser_seg" movl 64(%4), %%eax\n"
32310+ " .align 2,0x90\n"
32311+ "3: "__copyuser_seg" movl 0(%4), %%eax\n"
32312+ "4: "__copyuser_seg" movl 4(%4), %%edx\n"
32313+ "5: movl %%eax, 0(%3)\n"
32314+ "6: movl %%edx, 4(%3)\n"
32315+ "7: "__copyuser_seg" movl 8(%4), %%eax\n"
32316+ "8: "__copyuser_seg" movl 12(%4),%%edx\n"
32317+ "9: movl %%eax, 8(%3)\n"
32318+ "10: movl %%edx, 12(%3)\n"
32319+ "11: "__copyuser_seg" movl 16(%4), %%eax\n"
32320+ "12: "__copyuser_seg" movl 20(%4), %%edx\n"
32321+ "13: movl %%eax, 16(%3)\n"
32322+ "14: movl %%edx, 20(%3)\n"
32323+ "15: "__copyuser_seg" movl 24(%4), %%eax\n"
32324+ "16: "__copyuser_seg" movl 28(%4), %%edx\n"
32325+ "17: movl %%eax, 24(%3)\n"
32326+ "18: movl %%edx, 28(%3)\n"
32327+ "19: "__copyuser_seg" movl 32(%4), %%eax\n"
32328+ "20: "__copyuser_seg" movl 36(%4), %%edx\n"
32329+ "21: movl %%eax, 32(%3)\n"
32330+ "22: movl %%edx, 36(%3)\n"
32331+ "23: "__copyuser_seg" movl 40(%4), %%eax\n"
32332+ "24: "__copyuser_seg" movl 44(%4), %%edx\n"
32333+ "25: movl %%eax, 40(%3)\n"
32334+ "26: movl %%edx, 44(%3)\n"
32335+ "27: "__copyuser_seg" movl 48(%4), %%eax\n"
32336+ "28: "__copyuser_seg" movl 52(%4), %%edx\n"
32337+ "29: movl %%eax, 48(%3)\n"
32338+ "30: movl %%edx, 52(%3)\n"
32339+ "31: "__copyuser_seg" movl 56(%4), %%eax\n"
32340+ "32: "__copyuser_seg" movl 60(%4), %%edx\n"
32341+ "33: movl %%eax, 56(%3)\n"
32342+ "34: movl %%edx, 60(%3)\n"
32343+ " addl $-64, %0\n"
32344+ " addl $64, %4\n"
32345+ " addl $64, %3\n"
32346+ " cmpl $63, %0\n"
32347+ " ja 1b\n"
32348+ "35: movl %0, %%eax\n"
32349+ " shrl $2, %0\n"
32350+ " andl $3, %%eax\n"
32351+ " cld\n"
32352+ "99: rep; "__copyuser_seg" movsl\n"
32353+ "36: movl %%eax, %0\n"
32354+ "37: rep; "__copyuser_seg" movsb\n"
32355+ "100:\n"
32356 ".section .fixup,\"ax\"\n"
32357 "101: lea 0(%%eax,%0,4),%0\n"
32358 " jmp 100b\n"
32359@@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
32360 int d0, d1;
32361 __asm__ __volatile__(
32362 " .align 2,0x90\n"
32363- "0: movl 32(%4), %%eax\n"
32364+ "0: "__copyuser_seg" movl 32(%4), %%eax\n"
32365 " cmpl $67, %0\n"
32366 " jbe 2f\n"
32367- "1: movl 64(%4), %%eax\n"
32368+ "1: "__copyuser_seg" movl 64(%4), %%eax\n"
32369 " .align 2,0x90\n"
32370- "2: movl 0(%4), %%eax\n"
32371- "21: movl 4(%4), %%edx\n"
32372+ "2: "__copyuser_seg" movl 0(%4), %%eax\n"
32373+ "21: "__copyuser_seg" movl 4(%4), %%edx\n"
32374 " movl %%eax, 0(%3)\n"
32375 " movl %%edx, 4(%3)\n"
32376- "3: movl 8(%4), %%eax\n"
32377- "31: movl 12(%4),%%edx\n"
32378+ "3: "__copyuser_seg" movl 8(%4), %%eax\n"
32379+ "31: "__copyuser_seg" movl 12(%4),%%edx\n"
32380 " movl %%eax, 8(%3)\n"
32381 " movl %%edx, 12(%3)\n"
32382- "4: movl 16(%4), %%eax\n"
32383- "41: movl 20(%4), %%edx\n"
32384+ "4: "__copyuser_seg" movl 16(%4), %%eax\n"
32385+ "41: "__copyuser_seg" movl 20(%4), %%edx\n"
32386 " movl %%eax, 16(%3)\n"
32387 " movl %%edx, 20(%3)\n"
32388- "10: movl 24(%4), %%eax\n"
32389- "51: movl 28(%4), %%edx\n"
32390+ "10: "__copyuser_seg" movl 24(%4), %%eax\n"
32391+ "51: "__copyuser_seg" movl 28(%4), %%edx\n"
32392 " movl %%eax, 24(%3)\n"
32393 " movl %%edx, 28(%3)\n"
32394- "11: movl 32(%4), %%eax\n"
32395- "61: movl 36(%4), %%edx\n"
32396+ "11: "__copyuser_seg" movl 32(%4), %%eax\n"
32397+ "61: "__copyuser_seg" movl 36(%4), %%edx\n"
32398 " movl %%eax, 32(%3)\n"
32399 " movl %%edx, 36(%3)\n"
32400- "12: movl 40(%4), %%eax\n"
32401- "71: movl 44(%4), %%edx\n"
32402+ "12: "__copyuser_seg" movl 40(%4), %%eax\n"
32403+ "71: "__copyuser_seg" movl 44(%4), %%edx\n"
32404 " movl %%eax, 40(%3)\n"
32405 " movl %%edx, 44(%3)\n"
32406- "13: movl 48(%4), %%eax\n"
32407- "81: movl 52(%4), %%edx\n"
32408+ "13: "__copyuser_seg" movl 48(%4), %%eax\n"
32409+ "81: "__copyuser_seg" movl 52(%4), %%edx\n"
32410 " movl %%eax, 48(%3)\n"
32411 " movl %%edx, 52(%3)\n"
32412- "14: movl 56(%4), %%eax\n"
32413- "91: movl 60(%4), %%edx\n"
32414+ "14: "__copyuser_seg" movl 56(%4), %%eax\n"
32415+ "91: "__copyuser_seg" movl 60(%4), %%edx\n"
32416 " movl %%eax, 56(%3)\n"
32417 " movl %%edx, 60(%3)\n"
32418 " addl $-64, %0\n"
32419@@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
32420 " shrl $2, %0\n"
32421 " andl $3, %%eax\n"
32422 " cld\n"
32423- "6: rep; movsl\n"
32424+ "6: rep; "__copyuser_seg" movsl\n"
32425 " movl %%eax,%0\n"
32426- "7: rep; movsb\n"
32427+ "7: rep; "__copyuser_seg" movsb\n"
32428 "8:\n"
32429 ".section .fixup,\"ax\"\n"
32430 "9: lea 0(%%eax,%0,4),%0\n"
32431@@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
32432
32433 __asm__ __volatile__(
32434 " .align 2,0x90\n"
32435- "0: movl 32(%4), %%eax\n"
32436+ "0: "__copyuser_seg" movl 32(%4), %%eax\n"
32437 " cmpl $67, %0\n"
32438 " jbe 2f\n"
32439- "1: movl 64(%4), %%eax\n"
32440+ "1: "__copyuser_seg" movl 64(%4), %%eax\n"
32441 " .align 2,0x90\n"
32442- "2: movl 0(%4), %%eax\n"
32443- "21: movl 4(%4), %%edx\n"
32444+ "2: "__copyuser_seg" movl 0(%4), %%eax\n"
32445+ "21: "__copyuser_seg" movl 4(%4), %%edx\n"
32446 " movnti %%eax, 0(%3)\n"
32447 " movnti %%edx, 4(%3)\n"
32448- "3: movl 8(%4), %%eax\n"
32449- "31: movl 12(%4),%%edx\n"
32450+ "3: "__copyuser_seg" movl 8(%4), %%eax\n"
32451+ "31: "__copyuser_seg" movl 12(%4),%%edx\n"
32452 " movnti %%eax, 8(%3)\n"
32453 " movnti %%edx, 12(%3)\n"
32454- "4: movl 16(%4), %%eax\n"
32455- "41: movl 20(%4), %%edx\n"
32456+ "4: "__copyuser_seg" movl 16(%4), %%eax\n"
32457+ "41: "__copyuser_seg" movl 20(%4), %%edx\n"
32458 " movnti %%eax, 16(%3)\n"
32459 " movnti %%edx, 20(%3)\n"
32460- "10: movl 24(%4), %%eax\n"
32461- "51: movl 28(%4), %%edx\n"
32462+ "10: "__copyuser_seg" movl 24(%4), %%eax\n"
32463+ "51: "__copyuser_seg" movl 28(%4), %%edx\n"
32464 " movnti %%eax, 24(%3)\n"
32465 " movnti %%edx, 28(%3)\n"
32466- "11: movl 32(%4), %%eax\n"
32467- "61: movl 36(%4), %%edx\n"
32468+ "11: "__copyuser_seg" movl 32(%4), %%eax\n"
32469+ "61: "__copyuser_seg" movl 36(%4), %%edx\n"
32470 " movnti %%eax, 32(%3)\n"
32471 " movnti %%edx, 36(%3)\n"
32472- "12: movl 40(%4), %%eax\n"
32473- "71: movl 44(%4), %%edx\n"
32474+ "12: "__copyuser_seg" movl 40(%4), %%eax\n"
32475+ "71: "__copyuser_seg" movl 44(%4), %%edx\n"
32476 " movnti %%eax, 40(%3)\n"
32477 " movnti %%edx, 44(%3)\n"
32478- "13: movl 48(%4), %%eax\n"
32479- "81: movl 52(%4), %%edx\n"
32480+ "13: "__copyuser_seg" movl 48(%4), %%eax\n"
32481+ "81: "__copyuser_seg" movl 52(%4), %%edx\n"
32482 " movnti %%eax, 48(%3)\n"
32483 " movnti %%edx, 52(%3)\n"
32484- "14: movl 56(%4), %%eax\n"
32485- "91: movl 60(%4), %%edx\n"
32486+ "14: "__copyuser_seg" movl 56(%4), %%eax\n"
32487+ "91: "__copyuser_seg" movl 60(%4), %%edx\n"
32488 " movnti %%eax, 56(%3)\n"
32489 " movnti %%edx, 60(%3)\n"
32490 " addl $-64, %0\n"
32491@@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
32492 " shrl $2, %0\n"
32493 " andl $3, %%eax\n"
32494 " cld\n"
32495- "6: rep; movsl\n"
32496+ "6: rep; "__copyuser_seg" movsl\n"
32497 " movl %%eax,%0\n"
32498- "7: rep; movsb\n"
32499+ "7: rep; "__copyuser_seg" movsb\n"
32500 "8:\n"
32501 ".section .fixup,\"ax\"\n"
32502 "9: lea 0(%%eax,%0,4),%0\n"
32503@@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
32504
32505 __asm__ __volatile__(
32506 " .align 2,0x90\n"
32507- "0: movl 32(%4), %%eax\n"
32508+ "0: "__copyuser_seg" movl 32(%4), %%eax\n"
32509 " cmpl $67, %0\n"
32510 " jbe 2f\n"
32511- "1: movl 64(%4), %%eax\n"
32512+ "1: "__copyuser_seg" movl 64(%4), %%eax\n"
32513 " .align 2,0x90\n"
32514- "2: movl 0(%4), %%eax\n"
32515- "21: movl 4(%4), %%edx\n"
32516+ "2: "__copyuser_seg" movl 0(%4), %%eax\n"
32517+ "21: "__copyuser_seg" movl 4(%4), %%edx\n"
32518 " movnti %%eax, 0(%3)\n"
32519 " movnti %%edx, 4(%3)\n"
32520- "3: movl 8(%4), %%eax\n"
32521- "31: movl 12(%4),%%edx\n"
32522+ "3: "__copyuser_seg" movl 8(%4), %%eax\n"
32523+ "31: "__copyuser_seg" movl 12(%4),%%edx\n"
32524 " movnti %%eax, 8(%3)\n"
32525 " movnti %%edx, 12(%3)\n"
32526- "4: movl 16(%4), %%eax\n"
32527- "41: movl 20(%4), %%edx\n"
32528+ "4: "__copyuser_seg" movl 16(%4), %%eax\n"
32529+ "41: "__copyuser_seg" movl 20(%4), %%edx\n"
32530 " movnti %%eax, 16(%3)\n"
32531 " movnti %%edx, 20(%3)\n"
32532- "10: movl 24(%4), %%eax\n"
32533- "51: movl 28(%4), %%edx\n"
32534+ "10: "__copyuser_seg" movl 24(%4), %%eax\n"
32535+ "51: "__copyuser_seg" movl 28(%4), %%edx\n"
32536 " movnti %%eax, 24(%3)\n"
32537 " movnti %%edx, 28(%3)\n"
32538- "11: movl 32(%4), %%eax\n"
32539- "61: movl 36(%4), %%edx\n"
32540+ "11: "__copyuser_seg" movl 32(%4), %%eax\n"
32541+ "61: "__copyuser_seg" movl 36(%4), %%edx\n"
32542 " movnti %%eax, 32(%3)\n"
32543 " movnti %%edx, 36(%3)\n"
32544- "12: movl 40(%4), %%eax\n"
32545- "71: movl 44(%4), %%edx\n"
32546+ "12: "__copyuser_seg" movl 40(%4), %%eax\n"
32547+ "71: "__copyuser_seg" movl 44(%4), %%edx\n"
32548 " movnti %%eax, 40(%3)\n"
32549 " movnti %%edx, 44(%3)\n"
32550- "13: movl 48(%4), %%eax\n"
32551- "81: movl 52(%4), %%edx\n"
32552+ "13: "__copyuser_seg" movl 48(%4), %%eax\n"
32553+ "81: "__copyuser_seg" movl 52(%4), %%edx\n"
32554 " movnti %%eax, 48(%3)\n"
32555 " movnti %%edx, 52(%3)\n"
32556- "14: movl 56(%4), %%eax\n"
32557- "91: movl 60(%4), %%edx\n"
32558+ "14: "__copyuser_seg" movl 56(%4), %%eax\n"
32559+ "91: "__copyuser_seg" movl 60(%4), %%edx\n"
32560 " movnti %%eax, 56(%3)\n"
32561 " movnti %%edx, 60(%3)\n"
32562 " addl $-64, %0\n"
32563@@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
32564 " shrl $2, %0\n"
32565 " andl $3, %%eax\n"
32566 " cld\n"
32567- "6: rep; movsl\n"
32568+ "6: rep; "__copyuser_seg" movsl\n"
32569 " movl %%eax,%0\n"
32570- "7: rep; movsb\n"
32571+ "7: rep; "__copyuser_seg" movsb\n"
32572 "8:\n"
32573 ".section .fixup,\"ax\"\n"
32574 "9: lea 0(%%eax,%0,4),%0\n"
32575@@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
32576 */
32577 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
32578 unsigned long size);
32579-unsigned long __copy_user_intel(void __user *to, const void *from,
32580+unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
32581+ unsigned long size);
32582+unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
32583 unsigned long size);
32584 unsigned long __copy_user_zeroing_intel_nocache(void *to,
32585 const void __user *from, unsigned long size);
32586 #endif /* CONFIG_X86_INTEL_USERCOPY */
32587
32588 /* Generic arbitrary sized copy. */
32589-#define __copy_user(to, from, size) \
32590+#define __copy_user(to, from, size, prefix, set, restore) \
32591 do { \
32592 int __d0, __d1, __d2; \
32593 __asm__ __volatile__( \
32594+ set \
32595 " cmp $7,%0\n" \
32596 " jbe 1f\n" \
32597 " movl %1,%0\n" \
32598 " negl %0\n" \
32599 " andl $7,%0\n" \
32600 " subl %0,%3\n" \
32601- "4: rep; movsb\n" \
32602+ "4: rep; "prefix"movsb\n" \
32603 " movl %3,%0\n" \
32604 " shrl $2,%0\n" \
32605 " andl $3,%3\n" \
32606 " .align 2,0x90\n" \
32607- "0: rep; movsl\n" \
32608+ "0: rep; "prefix"movsl\n" \
32609 " movl %3,%0\n" \
32610- "1: rep; movsb\n" \
32611+ "1: rep; "prefix"movsb\n" \
32612 "2:\n" \
32613+ restore \
32614 ".section .fixup,\"ax\"\n" \
32615 "5: addl %3,%0\n" \
32616 " jmp 2b\n" \
32617@@ -538,14 +650,14 @@ do { \
32618 " negl %0\n" \
32619 " andl $7,%0\n" \
32620 " subl %0,%3\n" \
32621- "4: rep; movsb\n" \
32622+ "4: rep; "__copyuser_seg"movsb\n" \
32623 " movl %3,%0\n" \
32624 " shrl $2,%0\n" \
32625 " andl $3,%3\n" \
32626 " .align 2,0x90\n" \
32627- "0: rep; movsl\n" \
32628+ "0: rep; "__copyuser_seg"movsl\n" \
32629 " movl %3,%0\n" \
32630- "1: rep; movsb\n" \
32631+ "1: rep; "__copyuser_seg"movsb\n" \
32632 "2:\n" \
32633 ".section .fixup,\"ax\"\n" \
32634 "5: addl %3,%0\n" \
32635@@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
32636 {
32637 stac();
32638 if (movsl_is_ok(to, from, n))
32639- __copy_user(to, from, n);
32640+ __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
32641 else
32642- n = __copy_user_intel(to, from, n);
32643+ n = __generic_copy_to_user_intel(to, from, n);
32644 clac();
32645 return n;
32646 }
32647@@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
32648 {
32649 stac();
32650 if (movsl_is_ok(to, from, n))
32651- __copy_user(to, from, n);
32652+ __copy_user(to, from, n, __copyuser_seg, "", "");
32653 else
32654- n = __copy_user_intel((void __user *)to,
32655- (const void *)from, n);
32656+ n = __generic_copy_from_user_intel(to, from, n);
32657 clac();
32658 return n;
32659 }
32660@@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
32661 if (n > 64 && cpu_has_xmm2)
32662 n = __copy_user_intel_nocache(to, from, n);
32663 else
32664- __copy_user(to, from, n);
32665+ __copy_user(to, from, n, __copyuser_seg, "", "");
32666 #else
32667- __copy_user(to, from, n);
32668+ __copy_user(to, from, n, __copyuser_seg, "", "");
32669 #endif
32670 clac();
32671 return n;
32672 }
32673 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
32674
32675-/**
32676- * copy_to_user: - Copy a block of data into user space.
32677- * @to: Destination address, in user space.
32678- * @from: Source address, in kernel space.
32679- * @n: Number of bytes to copy.
32680- *
32681- * Context: User context only. This function may sleep if pagefaults are
32682- * enabled.
32683- *
32684- * Copy data from kernel space to user space.
32685- *
32686- * Returns number of bytes that could not be copied.
32687- * On success, this will be zero.
32688- */
32689-unsigned long _copy_to_user(void __user *to, const void *from, unsigned n)
32690+#ifdef CONFIG_PAX_MEMORY_UDEREF
32691+void __set_fs(mm_segment_t x)
32692 {
32693- if (access_ok(VERIFY_WRITE, to, n))
32694- n = __copy_to_user(to, from, n);
32695- return n;
32696+ switch (x.seg) {
32697+ case 0:
32698+ loadsegment(gs, 0);
32699+ break;
32700+ case TASK_SIZE_MAX:
32701+ loadsegment(gs, __USER_DS);
32702+ break;
32703+ case -1UL:
32704+ loadsegment(gs, __KERNEL_DS);
32705+ break;
32706+ default:
32707+ BUG();
32708+ }
32709 }
32710-EXPORT_SYMBOL(_copy_to_user);
32711+EXPORT_SYMBOL(__set_fs);
32712
32713-/**
32714- * copy_from_user: - Copy a block of data from user space.
32715- * @to: Destination address, in kernel space.
32716- * @from: Source address, in user space.
32717- * @n: Number of bytes to copy.
32718- *
32719- * Context: User context only. This function may sleep if pagefaults are
32720- * enabled.
32721- *
32722- * Copy data from user space to kernel space.
32723- *
32724- * Returns number of bytes that could not be copied.
32725- * On success, this will be zero.
32726- *
32727- * If some data could not be copied, this function will pad the copied
32728- * data to the requested size using zero bytes.
32729- */
32730-unsigned long _copy_from_user(void *to, const void __user *from, unsigned n)
32731+void set_fs(mm_segment_t x)
32732 {
32733- if (access_ok(VERIFY_READ, from, n))
32734- n = __copy_from_user(to, from, n);
32735- else
32736- memset(to, 0, n);
32737- return n;
32738+ current_thread_info()->addr_limit = x;
32739+ __set_fs(x);
32740 }
32741-EXPORT_SYMBOL(_copy_from_user);
32742+EXPORT_SYMBOL(set_fs);
32743+#endif
32744diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
32745index 0a42327..7a82465 100644
32746--- a/arch/x86/lib/usercopy_64.c
32747+++ b/arch/x86/lib/usercopy_64.c
32748@@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
32749 might_fault();
32750 /* no memory constraint because it doesn't change any memory gcc knows
32751 about */
32752+ pax_open_userland();
32753 stac();
32754 asm volatile(
32755 " testq %[size8],%[size8]\n"
32756@@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
32757 _ASM_EXTABLE(0b,3b)
32758 _ASM_EXTABLE(1b,2b)
32759 : [size8] "=&c"(size), [dst] "=&D" (__d0)
32760- : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
32761+ : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
32762 [zero] "r" (0UL), [eight] "r" (8UL));
32763 clac();
32764+ pax_close_userland();
32765 return size;
32766 }
32767 EXPORT_SYMBOL(__clear_user);
32768@@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
32769 }
32770 EXPORT_SYMBOL(clear_user);
32771
32772-unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
32773+unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
32774 {
32775- if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
32776- return copy_user_generic((__force void *)to, (__force void *)from, len);
32777- }
32778- return len;
32779+ if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
32780+ return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
32781+ return len;
32782 }
32783 EXPORT_SYMBOL(copy_in_user);
32784
32785@@ -69,8 +70,10 @@ EXPORT_SYMBOL(copy_in_user);
32786 * it is not necessary to optimize tail handling.
32787 */
32788 __visible unsigned long
32789-copy_user_handle_tail(char *to, char *from, unsigned len)
32790+copy_user_handle_tail(char __user *to, char __user *from, unsigned long len)
32791 {
32792+ clac();
32793+ pax_close_userland();
32794 for (; len; --len, to++) {
32795 char c;
32796
32797@@ -79,10 +82,9 @@ copy_user_handle_tail(char *to, char *from, unsigned len)
32798 if (__put_user_nocheck(c, to, sizeof(char)))
32799 break;
32800 }
32801- clac();
32802
32803 /* If the destination is a kernel buffer, we always clear the end */
32804- if (!__addr_ok(to))
32805+ if (!__addr_ok(to) && (unsigned long)to >= TASK_SIZE_MAX + pax_user_shadow_base)
32806 memset(to, 0, len);
32807 return len;
32808 }
32809diff --git a/arch/x86/math-emu/fpu_aux.c b/arch/x86/math-emu/fpu_aux.c
32810index dd76a05..df65688 100644
32811--- a/arch/x86/math-emu/fpu_aux.c
32812+++ b/arch/x86/math-emu/fpu_aux.c
32813@@ -52,7 +52,7 @@ void fpstate_init_soft(struct swregs_state *soft)
32814
32815 void finit(void)
32816 {
32817- fpstate_init_soft(&current->thread.fpu.state.soft);
32818+ fpstate_init_soft(&current->thread.fpu.state->soft);
32819 }
32820
32821 /*
32822diff --git a/arch/x86/math-emu/fpu_entry.c b/arch/x86/math-emu/fpu_entry.c
32823index 3d8f2e4..ef7cf4e 100644
32824--- a/arch/x86/math-emu/fpu_entry.c
32825+++ b/arch/x86/math-emu/fpu_entry.c
32826@@ -677,7 +677,7 @@ int fpregs_soft_set(struct task_struct *target,
32827 unsigned int pos, unsigned int count,
32828 const void *kbuf, const void __user *ubuf)
32829 {
32830- struct swregs_state *s387 = &target->thread.fpu.state.soft;
32831+ struct swregs_state *s387 = &target->thread.fpu.state->soft;
32832 void *space = s387->st_space;
32833 int ret;
32834 int offset, other, i, tags, regnr, tag, newtop;
32835@@ -729,7 +729,7 @@ int fpregs_soft_get(struct task_struct *target,
32836 unsigned int pos, unsigned int count,
32837 void *kbuf, void __user *ubuf)
32838 {
32839- struct swregs_state *s387 = &target->thread.fpu.state.soft;
32840+ struct swregs_state *s387 = &target->thread.fpu.state->soft;
32841 const void *space = s387->st_space;
32842 int ret;
32843 int offset = (S387->ftop & 7) * 10, other = 80 - offset;
32844diff --git a/arch/x86/math-emu/fpu_system.h b/arch/x86/math-emu/fpu_system.h
32845index 5e044d5..d342fce 100644
32846--- a/arch/x86/math-emu/fpu_system.h
32847+++ b/arch/x86/math-emu/fpu_system.h
32848@@ -46,7 +46,7 @@ static inline struct desc_struct FPU_get_ldt_descriptor(unsigned seg)
32849 #define SEG_EXPAND_DOWN(s) (((s).b & ((1 << 11) | (1 << 10))) \
32850 == (1 << 10))
32851
32852-#define I387 (&current->thread.fpu.state)
32853+#define I387 (current->thread.fpu.state)
32854 #define FPU_info (I387->soft.info)
32855
32856 #define FPU_CS (*(unsigned short *) &(FPU_info->regs->cs))
32857diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
32858index a482d10..1a6edb5 100644
32859--- a/arch/x86/mm/Makefile
32860+++ b/arch/x86/mm/Makefile
32861@@ -33,3 +33,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
32862 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
32863
32864 obj-$(CONFIG_X86_INTEL_MPX) += mpx.o
32865+
32866+quote:="
32867+obj-$(CONFIG_X86_64) += uderef_64.o
32868+CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS)) -fcall-saved-rax
32869diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
32870index 903ec1e..41b4708 100644
32871--- a/arch/x86/mm/extable.c
32872+++ b/arch/x86/mm/extable.c
32873@@ -2,16 +2,29 @@
32874 #include <linux/spinlock.h>
32875 #include <linux/sort.h>
32876 #include <asm/uaccess.h>
32877+#include <asm/boot.h>
32878
32879 static inline unsigned long
32880 ex_insn_addr(const struct exception_table_entry *x)
32881 {
32882- return (unsigned long)&x->insn + x->insn;
32883+ unsigned long reloc = 0;
32884+
32885+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
32886+ reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32887+#endif
32888+
32889+ return (unsigned long)&x->insn + x->insn + reloc;
32890 }
32891 static inline unsigned long
32892 ex_fixup_addr(const struct exception_table_entry *x)
32893 {
32894- return (unsigned long)&x->fixup + x->fixup;
32895+ unsigned long reloc = 0;
32896+
32897+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
32898+ reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32899+#endif
32900+
32901+ return (unsigned long)&x->fixup + x->fixup + reloc;
32902 }
32903
32904 int fixup_exception(struct pt_regs *regs)
32905@@ -20,7 +33,7 @@ int fixup_exception(struct pt_regs *regs)
32906 unsigned long new_ip;
32907
32908 #ifdef CONFIG_PNPBIOS
32909- if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
32910+ if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
32911 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
32912 extern u32 pnp_bios_is_utter_crap;
32913 pnp_bios_is_utter_crap = 1;
32914@@ -145,6 +158,13 @@ void sort_extable(struct exception_table_entry *start,
32915 i += 4;
32916 p->fixup -= i;
32917 i += 4;
32918+
32919+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
32920+ BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
32921+ p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32922+ p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32923+#endif
32924+
32925 }
32926 }
32927
32928diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
32929index 9dc9098..938251a 100644
32930--- a/arch/x86/mm/fault.c
32931+++ b/arch/x86/mm/fault.c
32932@@ -14,12 +14,19 @@
32933 #include <linux/prefetch.h> /* prefetchw */
32934 #include <linux/context_tracking.h> /* exception_enter(), ... */
32935 #include <linux/uaccess.h> /* faulthandler_disabled() */
32936+#include <linux/unistd.h>
32937+#include <linux/compiler.h>
32938
32939 #include <asm/traps.h> /* dotraplinkage, ... */
32940 #include <asm/pgalloc.h> /* pgd_*(), ... */
32941 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
32942 #include <asm/fixmap.h> /* VSYSCALL_ADDR */
32943 #include <asm/vsyscall.h> /* emulate_vsyscall */
32944+#include <asm/tlbflush.h>
32945+
32946+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32947+#include <asm/stacktrace.h>
32948+#endif
32949
32950 #define CREATE_TRACE_POINTS
32951 #include <asm/trace/exceptions.h>
32952@@ -121,7 +128,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
32953 return !instr_lo || (instr_lo>>1) == 1;
32954 case 0x00:
32955 /* Prefetch instruction is 0x0F0D or 0x0F18 */
32956- if (probe_kernel_address(instr, opcode))
32957+ if (user_mode(regs)) {
32958+ if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
32959+ return 0;
32960+ } else if (probe_kernel_address(instr, opcode))
32961 return 0;
32962
32963 *prefetch = (instr_lo == 0xF) &&
32964@@ -155,7 +165,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
32965 while (instr < max_instr) {
32966 unsigned char opcode;
32967
32968- if (probe_kernel_address(instr, opcode))
32969+ if (user_mode(regs)) {
32970+ if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
32971+ break;
32972+ } else if (probe_kernel_address(instr, opcode))
32973 break;
32974
32975 instr++;
32976@@ -186,6 +199,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
32977 force_sig_info(si_signo, &info, tsk);
32978 }
32979
32980+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
32981+static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
32982+#endif
32983+
32984+#ifdef CONFIG_PAX_EMUTRAMP
32985+static int pax_handle_fetch_fault(struct pt_regs *regs);
32986+#endif
32987+
32988+#ifdef CONFIG_PAX_PAGEEXEC
32989+static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
32990+{
32991+ pgd_t *pgd;
32992+ pud_t *pud;
32993+ pmd_t *pmd;
32994+
32995+ pgd = pgd_offset(mm, address);
32996+ if (!pgd_present(*pgd))
32997+ return NULL;
32998+ pud = pud_offset(pgd, address);
32999+ if (!pud_present(*pud))
33000+ return NULL;
33001+ pmd = pmd_offset(pud, address);
33002+ if (!pmd_present(*pmd))
33003+ return NULL;
33004+ return pmd;
33005+}
33006+#endif
33007+
33008 DEFINE_SPINLOCK(pgd_lock);
33009 LIST_HEAD(pgd_list);
33010
33011@@ -236,10 +277,27 @@ void vmalloc_sync_all(void)
33012 for (address = VMALLOC_START & PMD_MASK;
33013 address >= TASK_SIZE && address < FIXADDR_TOP;
33014 address += PMD_SIZE) {
33015+
33016+#ifdef CONFIG_PAX_PER_CPU_PGD
33017+ unsigned long cpu;
33018+#else
33019 struct page *page;
33020+#endif
33021
33022 spin_lock(&pgd_lock);
33023+
33024+#ifdef CONFIG_PAX_PER_CPU_PGD
33025+ for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
33026+ pgd_t *pgd = get_cpu_pgd(cpu, user);
33027+ pmd_t *ret;
33028+
33029+ ret = vmalloc_sync_one(pgd, address);
33030+ if (!ret)
33031+ break;
33032+ pgd = get_cpu_pgd(cpu, kernel);
33033+#else
33034 list_for_each_entry(page, &pgd_list, lru) {
33035+ pgd_t *pgd;
33036 spinlock_t *pgt_lock;
33037 pmd_t *ret;
33038
33039@@ -247,8 +305,14 @@ void vmalloc_sync_all(void)
33040 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
33041
33042 spin_lock(pgt_lock);
33043- ret = vmalloc_sync_one(page_address(page), address);
33044+ pgd = page_address(page);
33045+#endif
33046+
33047+ ret = vmalloc_sync_one(pgd, address);
33048+
33049+#ifndef CONFIG_PAX_PER_CPU_PGD
33050 spin_unlock(pgt_lock);
33051+#endif
33052
33053 if (!ret)
33054 break;
33055@@ -282,6 +346,12 @@ static noinline int vmalloc_fault(unsigned long address)
33056 * an interrupt in the middle of a task switch..
33057 */
33058 pgd_paddr = read_cr3();
33059+
33060+#ifdef CONFIG_PAX_PER_CPU_PGD
33061+ BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
33062+ vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
33063+#endif
33064+
33065 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
33066 if (!pmd_k)
33067 return -1;
33068@@ -378,11 +448,25 @@ static noinline int vmalloc_fault(unsigned long address)
33069 * happen within a race in page table update. In the later
33070 * case just flush:
33071 */
33072- pgd = pgd_offset(current->active_mm, address);
33073+
33074 pgd_ref = pgd_offset_k(address);
33075 if (pgd_none(*pgd_ref))
33076 return -1;
33077
33078+#ifdef CONFIG_PAX_PER_CPU_PGD
33079+ BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
33080+ pgd = pgd_offset_cpu(smp_processor_id(), user, address);
33081+ if (pgd_none(*pgd)) {
33082+ set_pgd(pgd, *pgd_ref);
33083+ arch_flush_lazy_mmu_mode();
33084+ } else {
33085+ BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
33086+ }
33087+ pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
33088+#else
33089+ pgd = pgd_offset(current->active_mm, address);
33090+#endif
33091+
33092 if (pgd_none(*pgd)) {
33093 set_pgd(pgd, *pgd_ref);
33094 arch_flush_lazy_mmu_mode();
33095@@ -549,7 +633,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
33096 static int is_errata100(struct pt_regs *regs, unsigned long address)
33097 {
33098 #ifdef CONFIG_X86_64
33099- if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
33100+ if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
33101 return 1;
33102 #endif
33103 return 0;
33104@@ -576,9 +660,9 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
33105 }
33106
33107 static const char nx_warning[] = KERN_CRIT
33108-"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
33109+"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
33110 static const char smep_warning[] = KERN_CRIT
33111-"unable to execute userspace code (SMEP?) (uid: %d)\n";
33112+"unable to execute userspace code (SMEP?) (uid: %d, task: %s, pid: %d)\n";
33113
33114 static void
33115 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
33116@@ -587,7 +671,7 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
33117 if (!oops_may_print())
33118 return;
33119
33120- if (error_code & PF_INSTR) {
33121+ if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
33122 unsigned int level;
33123 pgd_t *pgd;
33124 pte_t *pte;
33125@@ -598,13 +682,25 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
33126 pte = lookup_address_in_pgd(pgd, address, &level);
33127
33128 if (pte && pte_present(*pte) && !pte_exec(*pte))
33129- printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
33130+ printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
33131 if (pte && pte_present(*pte) && pte_exec(*pte) &&
33132 (pgd_flags(*pgd) & _PAGE_USER) &&
33133 (__read_cr4() & X86_CR4_SMEP))
33134- printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
33135+ printk(smep_warning, from_kuid(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
33136 }
33137
33138+#ifdef CONFIG_PAX_KERNEXEC
33139+ if (init_mm.start_code <= address && address < init_mm.end_code) {
33140+ if (current->signal->curr_ip)
33141+ printk(KERN_EMERG "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
33142+ &current->signal->curr_ip, current->comm, task_pid_nr(current),
33143+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
33144+ else
33145+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
33146+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
33147+ }
33148+#endif
33149+
33150 printk(KERN_ALERT "BUG: unable to handle kernel ");
33151 if (address < PAGE_SIZE)
33152 printk(KERN_CONT "NULL pointer dereference");
33153@@ -783,6 +879,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
33154 return;
33155 }
33156 #endif
33157+
33158+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
33159+ if (pax_is_fetch_fault(regs, error_code, address)) {
33160+
33161+#ifdef CONFIG_PAX_EMUTRAMP
33162+ switch (pax_handle_fetch_fault(regs)) {
33163+ case 2:
33164+ return;
33165+ }
33166+#endif
33167+
33168+ pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
33169+ do_group_exit(SIGKILL);
33170+ }
33171+#endif
33172+
33173 /* Kernel addresses are always protection faults: */
33174 if (address >= TASK_SIZE)
33175 error_code |= PF_PROT;
33176@@ -865,7 +977,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
33177 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
33178 printk(KERN_ERR
33179 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
33180- tsk->comm, tsk->pid, address);
33181+ tsk->comm, task_pid_nr(tsk), address);
33182 code = BUS_MCEERR_AR;
33183 }
33184 #endif
33185@@ -917,6 +1029,107 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
33186 return 1;
33187 }
33188
33189+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
33190+static inline unsigned long get_limit(unsigned long segment)
33191+{
33192+ unsigned long __limit;
33193+
33194+ asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
33195+ return __limit + 1;
33196+}
33197+
33198+static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
33199+{
33200+ pte_t *pte;
33201+ pmd_t *pmd;
33202+ spinlock_t *ptl;
33203+ unsigned char pte_mask;
33204+
33205+ if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
33206+ !(mm->pax_flags & MF_PAX_PAGEEXEC))
33207+ return 0;
33208+
33209+ /* PaX: it's our fault, let's handle it if we can */
33210+
33211+ /* PaX: take a look at read faults before acquiring any locks */
33212+ if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
33213+ /* instruction fetch attempt from a protected page in user mode */
33214+ up_read(&mm->mmap_sem);
33215+
33216+#ifdef CONFIG_PAX_EMUTRAMP
33217+ switch (pax_handle_fetch_fault(regs)) {
33218+ case 2:
33219+ return 1;
33220+ }
33221+#endif
33222+
33223+ pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
33224+ do_group_exit(SIGKILL);
33225+ }
33226+
33227+ pmd = pax_get_pmd(mm, address);
33228+ if (unlikely(!pmd))
33229+ return 0;
33230+
33231+ pte = pte_offset_map_lock(mm, pmd, address, &ptl);
33232+ if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
33233+ pte_unmap_unlock(pte, ptl);
33234+ return 0;
33235+ }
33236+
33237+ if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
33238+ /* write attempt to a protected page in user mode */
33239+ pte_unmap_unlock(pte, ptl);
33240+ return 0;
33241+ }
33242+
33243+#ifdef CONFIG_SMP
33244+ if (likely(address > get_limit(regs->cs) && cpumask_test_cpu(smp_processor_id(), &mm->context.cpu_user_cs_mask)))
33245+#else
33246+ if (likely(address > get_limit(regs->cs)))
33247+#endif
33248+ {
33249+ set_pte(pte, pte_mkread(*pte));
33250+ __flush_tlb_one(address);
33251+ pte_unmap_unlock(pte, ptl);
33252+ up_read(&mm->mmap_sem);
33253+ return 1;
33254+ }
33255+
33256+ pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
33257+
33258+ /*
33259+ * PaX: fill DTLB with user rights and retry
33260+ */
33261+ __asm__ __volatile__ (
33262+ "orb %2,(%1)\n"
33263+#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
33264+/*
33265+ * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
33266+ * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
33267+ * page fault when examined during a TLB load attempt. this is true not only
33268+ * for PTEs holding a non-present entry but also present entries that will
33269+ * raise a page fault (such as those set up by PaX, or the copy-on-write
33270+ * mechanism). in effect it means that we do *not* need to flush the TLBs
33271+ * for our target pages since their PTEs are simply not in the TLBs at all.
33272+
33273+ * the best thing in omitting it is that we gain around 15-20% speed in the
33274+ * fast path of the page fault handler and can get rid of tracing since we
33275+ * can no longer flush unintended entries.
33276+ */
33277+ "invlpg (%0)\n"
33278+#endif
33279+ __copyuser_seg"testb $0,(%0)\n"
33280+ "xorb %3,(%1)\n"
33281+ :
33282+ : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
33283+ : "memory", "cc");
33284+ pte_unmap_unlock(pte, ptl);
33285+ up_read(&mm->mmap_sem);
33286+ return 1;
33287+}
33288+#endif
33289+
33290 /*
33291 * Handle a spurious fault caused by a stale TLB entry.
33292 *
33293@@ -1002,6 +1215,9 @@ int show_unhandled_signals = 1;
33294 static inline int
33295 access_error(unsigned long error_code, struct vm_area_struct *vma)
33296 {
33297+ if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
33298+ return 1;
33299+
33300 if (error_code & PF_WRITE) {
33301 /* write, present and write, not present: */
33302 if (unlikely(!(vma->vm_flags & VM_WRITE)))
33303@@ -1064,6 +1280,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
33304 tsk = current;
33305 mm = tsk->mm;
33306
33307+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
33308+ if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
33309+ if (!search_exception_tables(regs->ip)) {
33310+ printk(KERN_EMERG "PAX: please report this to pageexec@freemail.hu\n");
33311+ bad_area_nosemaphore(regs, error_code, address);
33312+ return;
33313+ }
33314+ if (address < pax_user_shadow_base) {
33315+ printk(KERN_EMERG "PAX: please report this to pageexec@freemail.hu\n");
33316+ printk(KERN_EMERG "PAX: faulting IP: %pS\n", (void *)regs->ip);
33317+ show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_EMERG);
33318+ } else
33319+ address -= pax_user_shadow_base;
33320+ }
33321+#endif
33322+
33323 /*
33324 * Detect and handle instructions that would cause a page fault for
33325 * both a tracked kernel page and a userspace page.
33326@@ -1188,6 +1420,11 @@ retry:
33327 might_sleep();
33328 }
33329
33330+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
33331+ if (pax_handle_pageexec_fault(regs, mm, address, error_code))
33332+ return;
33333+#endif
33334+
33335 vma = find_vma(mm, address);
33336 if (unlikely(!vma)) {
33337 bad_area(regs, error_code, address);
33338@@ -1199,18 +1436,24 @@ retry:
33339 bad_area(regs, error_code, address);
33340 return;
33341 }
33342- if (error_code & PF_USER) {
33343- /*
33344- * Accessing the stack below %sp is always a bug.
33345- * The large cushion allows instructions like enter
33346- * and pusha to work. ("enter $65535, $31" pushes
33347- * 32 pointers and then decrements %sp by 65535.)
33348- */
33349- if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
33350- bad_area(regs, error_code, address);
33351- return;
33352- }
33353+ /*
33354+ * Accessing the stack below %sp is always a bug.
33355+ * The large cushion allows instructions like enter
33356+ * and pusha to work. ("enter $65535, $31" pushes
33357+ * 32 pointers and then decrements %sp by 65535.)
33358+ */
33359+ if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
33360+ bad_area(regs, error_code, address);
33361+ return;
33362 }
33363+
33364+#ifdef CONFIG_PAX_SEGMEXEC
33365+ if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
33366+ bad_area(regs, error_code, address);
33367+ return;
33368+ }
33369+#endif
33370+
33371 if (unlikely(expand_stack(vma, address))) {
33372 bad_area(regs, error_code, address);
33373 return;
33374@@ -1330,3 +1573,292 @@ trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
33375 }
33376 NOKPROBE_SYMBOL(trace_do_page_fault);
33377 #endif /* CONFIG_TRACING */
33378+
33379+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
33380+static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
33381+{
33382+ struct mm_struct *mm = current->mm;
33383+ unsigned long ip = regs->ip;
33384+
33385+ if (v8086_mode(regs))
33386+ ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
33387+
33388+#ifdef CONFIG_PAX_PAGEEXEC
33389+ if (mm->pax_flags & MF_PAX_PAGEEXEC) {
33390+ if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
33391+ return true;
33392+ if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
33393+ return true;
33394+ return false;
33395+ }
33396+#endif
33397+
33398+#ifdef CONFIG_PAX_SEGMEXEC
33399+ if (mm->pax_flags & MF_PAX_SEGMEXEC) {
33400+ if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
33401+ return true;
33402+ return false;
33403+ }
33404+#endif
33405+
33406+ return false;
33407+}
33408+#endif
33409+
33410+#ifdef CONFIG_PAX_EMUTRAMP
33411+static int pax_handle_fetch_fault_32(struct pt_regs *regs)
33412+{
33413+ int err;
33414+
33415+ do { /* PaX: libffi trampoline emulation */
33416+ unsigned char mov, jmp;
33417+ unsigned int addr1, addr2;
33418+
33419+#ifdef CONFIG_X86_64
33420+ if ((regs->ip + 9) >> 32)
33421+ break;
33422+#endif
33423+
33424+ err = get_user(mov, (unsigned char __user *)regs->ip);
33425+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
33426+ err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
33427+ err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
33428+
33429+ if (err)
33430+ break;
33431+
33432+ if (mov == 0xB8 && jmp == 0xE9) {
33433+ regs->ax = addr1;
33434+ regs->ip = (unsigned int)(regs->ip + addr2 + 10);
33435+ return 2;
33436+ }
33437+ } while (0);
33438+
33439+ do { /* PaX: gcc trampoline emulation #1 */
33440+ unsigned char mov1, mov2;
33441+ unsigned short jmp;
33442+ unsigned int addr1, addr2;
33443+
33444+#ifdef CONFIG_X86_64
33445+ if ((regs->ip + 11) >> 32)
33446+ break;
33447+#endif
33448+
33449+ err = get_user(mov1, (unsigned char __user *)regs->ip);
33450+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
33451+ err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
33452+ err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
33453+ err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
33454+
33455+ if (err)
33456+ break;
33457+
33458+ if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
33459+ regs->cx = addr1;
33460+ regs->ax = addr2;
33461+ regs->ip = addr2;
33462+ return 2;
33463+ }
33464+ } while (0);
33465+
33466+ do { /* PaX: gcc trampoline emulation #2 */
33467+ unsigned char mov, jmp;
33468+ unsigned int addr1, addr2;
33469+
33470+#ifdef CONFIG_X86_64
33471+ if ((regs->ip + 9) >> 32)
33472+ break;
33473+#endif
33474+
33475+ err = get_user(mov, (unsigned char __user *)regs->ip);
33476+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
33477+ err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
33478+ err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
33479+
33480+ if (err)
33481+ break;
33482+
33483+ if (mov == 0xB9 && jmp == 0xE9) {
33484+ regs->cx = addr1;
33485+ regs->ip = (unsigned int)(regs->ip + addr2 + 10);
33486+ return 2;
33487+ }
33488+ } while (0);
33489+
33490+ return 1; /* PaX in action */
33491+}
33492+
33493+#ifdef CONFIG_X86_64
33494+static int pax_handle_fetch_fault_64(struct pt_regs *regs)
33495+{
33496+ int err;
33497+
33498+ do { /* PaX: libffi trampoline emulation */
33499+ unsigned short mov1, mov2, jmp1;
33500+ unsigned char stcclc, jmp2;
33501+ unsigned long addr1, addr2;
33502+
33503+ err = get_user(mov1, (unsigned short __user *)regs->ip);
33504+ err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
33505+ err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
33506+ err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
33507+ err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
33508+ err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
33509+ err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
33510+
33511+ if (err)
33512+ break;
33513+
33514+ if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
33515+ regs->r11 = addr1;
33516+ regs->r10 = addr2;
33517+ if (stcclc == 0xF8)
33518+ regs->flags &= ~X86_EFLAGS_CF;
33519+ else
33520+ regs->flags |= X86_EFLAGS_CF;
33521+ regs->ip = addr1;
33522+ return 2;
33523+ }
33524+ } while (0);
33525+
33526+ do { /* PaX: gcc trampoline emulation #1 */
33527+ unsigned short mov1, mov2, jmp1;
33528+ unsigned char jmp2;
33529+ unsigned int addr1;
33530+ unsigned long addr2;
33531+
33532+ err = get_user(mov1, (unsigned short __user *)regs->ip);
33533+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
33534+ err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
33535+ err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
33536+ err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
33537+ err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
33538+
33539+ if (err)
33540+ break;
33541+
33542+ if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
33543+ regs->r11 = addr1;
33544+ regs->r10 = addr2;
33545+ regs->ip = addr1;
33546+ return 2;
33547+ }
33548+ } while (0);
33549+
33550+ do { /* PaX: gcc trampoline emulation #2 */
33551+ unsigned short mov1, mov2, jmp1;
33552+ unsigned char jmp2;
33553+ unsigned long addr1, addr2;
33554+
33555+ err = get_user(mov1, (unsigned short __user *)regs->ip);
33556+ err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
33557+ err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
33558+ err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
33559+ err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
33560+ err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
33561+
33562+ if (err)
33563+ break;
33564+
33565+ if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
33566+ regs->r11 = addr1;
33567+ regs->r10 = addr2;
33568+ regs->ip = addr1;
33569+ return 2;
33570+ }
33571+ } while (0);
33572+
33573+ return 1; /* PaX in action */
33574+}
33575+#endif
33576+
33577+/*
33578+ * PaX: decide what to do with offenders (regs->ip = fault address)
33579+ *
33580+ * returns 1 when task should be killed
33581+ * 2 when gcc trampoline was detected
33582+ */
33583+static int pax_handle_fetch_fault(struct pt_regs *regs)
33584+{
33585+ if (v8086_mode(regs))
33586+ return 1;
33587+
33588+ if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
33589+ return 1;
33590+
33591+#ifdef CONFIG_X86_32
33592+ return pax_handle_fetch_fault_32(regs);
33593+#else
33594+ if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
33595+ return pax_handle_fetch_fault_32(regs);
33596+ else
33597+ return pax_handle_fetch_fault_64(regs);
33598+#endif
33599+}
33600+#endif
33601+
33602+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
33603+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
33604+{
33605+ long i;
33606+
33607+ printk(KERN_ERR "PAX: bytes at PC: ");
33608+ for (i = 0; i < 20; i++) {
33609+ unsigned char c;
33610+ if (get_user(c, (unsigned char __force_user *)pc+i))
33611+ printk(KERN_CONT "?? ");
33612+ else
33613+ printk(KERN_CONT "%02x ", c);
33614+ }
33615+ printk("\n");
33616+
33617+ printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
33618+ for (i = -1; i < 80 / (long)sizeof(long); i++) {
33619+ unsigned long c;
33620+ if (get_user(c, (unsigned long __force_user *)sp+i)) {
33621+#ifdef CONFIG_X86_32
33622+ printk(KERN_CONT "???????? ");
33623+#else
33624+ if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
33625+ printk(KERN_CONT "???????? ???????? ");
33626+ else
33627+ printk(KERN_CONT "???????????????? ");
33628+#endif
33629+ } else {
33630+#ifdef CONFIG_X86_64
33631+ if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
33632+ printk(KERN_CONT "%08x ", (unsigned int)c);
33633+ printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
33634+ } else
33635+#endif
33636+ printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
33637+ }
33638+ }
33639+ printk("\n");
33640+}
33641+#endif
33642+
33643+/**
33644+ * probe_kernel_write(): safely attempt to write to a location
33645+ * @dst: address to write to
33646+ * @src: pointer to the data that shall be written
33647+ * @size: size of the data chunk
33648+ *
33649+ * Safely write to address @dst from the buffer at @src. If a kernel fault
33650+ * happens, handle that and return -EFAULT.
33651+ */
33652+long notrace probe_kernel_write(void *dst, const void *src, size_t size)
33653+{
33654+ long ret;
33655+ mm_segment_t old_fs = get_fs();
33656+
33657+ set_fs(KERNEL_DS);
33658+ pagefault_disable();
33659+ pax_open_kernel();
33660+ ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
33661+ pax_close_kernel();
33662+ pagefault_enable();
33663+ set_fs(old_fs);
33664+
33665+ return ret ? -EFAULT : 0;
33666+}
33667diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
33668index 81bf3d2..7ef25c2 100644
33669--- a/arch/x86/mm/gup.c
33670+++ b/arch/x86/mm/gup.c
33671@@ -268,7 +268,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
33672 addr = start;
33673 len = (unsigned long) nr_pages << PAGE_SHIFT;
33674 end = start + len;
33675- if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
33676+ if (unlikely(!access_ok_noprefault(write ? VERIFY_WRITE : VERIFY_READ,
33677 (void __user *)start, len)))
33678 return 0;
33679
33680@@ -344,6 +344,10 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
33681 goto slow_irqon;
33682 #endif
33683
33684+ if (unlikely(!access_ok_noprefault(write ? VERIFY_WRITE : VERIFY_READ,
33685+ (void __user *)start, len)))
33686+ return 0;
33687+
33688 /*
33689 * XXX: batch / limit 'nr', to avoid large irq off latency
33690 * needs some instrumenting to determine the common sizes used by
33691diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
33692index eecb207a..e76b7f4 100644
33693--- a/arch/x86/mm/highmem_32.c
33694+++ b/arch/x86/mm/highmem_32.c
33695@@ -35,6 +35,8 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
33696 unsigned long vaddr;
33697 int idx, type;
33698
33699+ BUG_ON(pgprot_val(prot) & _PAGE_USER);
33700+
33701 preempt_disable();
33702 pagefault_disable();
33703
33704@@ -45,7 +47,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
33705 idx = type + KM_TYPE_NR*smp_processor_id();
33706 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
33707 BUG_ON(!pte_none(*(kmap_pte-idx)));
33708+
33709+ pax_open_kernel();
33710 set_pte(kmap_pte-idx, mk_pte(page, prot));
33711+ pax_close_kernel();
33712+
33713 arch_flush_lazy_mmu_mode();
33714
33715 return (void *)vaddr;
33716diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
33717index 42982b2..7168fc3 100644
33718--- a/arch/x86/mm/hugetlbpage.c
33719+++ b/arch/x86/mm/hugetlbpage.c
33720@@ -74,23 +74,24 @@ int pud_huge(pud_t pud)
33721 #ifdef CONFIG_HUGETLB_PAGE
33722 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
33723 unsigned long addr, unsigned long len,
33724- unsigned long pgoff, unsigned long flags)
33725+ unsigned long pgoff, unsigned long flags, unsigned long offset)
33726 {
33727 struct hstate *h = hstate_file(file);
33728 struct vm_unmapped_area_info info;
33729-
33730+
33731 info.flags = 0;
33732 info.length = len;
33733 info.low_limit = current->mm->mmap_legacy_base;
33734 info.high_limit = TASK_SIZE;
33735 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
33736 info.align_offset = 0;
33737+ info.threadstack_offset = offset;
33738 return vm_unmapped_area(&info);
33739 }
33740
33741 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
33742 unsigned long addr0, unsigned long len,
33743- unsigned long pgoff, unsigned long flags)
33744+ unsigned long pgoff, unsigned long flags, unsigned long offset)
33745 {
33746 struct hstate *h = hstate_file(file);
33747 struct vm_unmapped_area_info info;
33748@@ -102,6 +103,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
33749 info.high_limit = current->mm->mmap_base;
33750 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
33751 info.align_offset = 0;
33752+ info.threadstack_offset = offset;
33753 addr = vm_unmapped_area(&info);
33754
33755 /*
33756@@ -114,6 +116,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
33757 VM_BUG_ON(addr != -ENOMEM);
33758 info.flags = 0;
33759 info.low_limit = TASK_UNMAPPED_BASE;
33760+
33761+#ifdef CONFIG_PAX_RANDMMAP
33762+ if (current->mm->pax_flags & MF_PAX_RANDMMAP)
33763+ info.low_limit += current->mm->delta_mmap;
33764+#endif
33765+
33766 info.high_limit = TASK_SIZE;
33767 addr = vm_unmapped_area(&info);
33768 }
33769@@ -128,10 +136,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
33770 struct hstate *h = hstate_file(file);
33771 struct mm_struct *mm = current->mm;
33772 struct vm_area_struct *vma;
33773+ unsigned long pax_task_size = TASK_SIZE;
33774+ unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
33775
33776 if (len & ~huge_page_mask(h))
33777 return -EINVAL;
33778- if (len > TASK_SIZE)
33779+
33780+#ifdef CONFIG_PAX_SEGMEXEC
33781+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
33782+ pax_task_size = SEGMEXEC_TASK_SIZE;
33783+#endif
33784+
33785+ pax_task_size -= PAGE_SIZE;
33786+
33787+ if (len > pax_task_size)
33788 return -ENOMEM;
33789
33790 if (flags & MAP_FIXED) {
33791@@ -140,19 +158,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
33792 return addr;
33793 }
33794
33795+#ifdef CONFIG_PAX_RANDMMAP
33796+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33797+#endif
33798+
33799 if (addr) {
33800 addr = ALIGN(addr, huge_page_size(h));
33801 vma = find_vma(mm, addr);
33802- if (TASK_SIZE - len >= addr &&
33803- (!vma || addr + len <= vma->vm_start))
33804+ if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
33805 return addr;
33806 }
33807 if (mm->get_unmapped_area == arch_get_unmapped_area)
33808 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
33809- pgoff, flags);
33810+ pgoff, flags, offset);
33811 else
33812 return hugetlb_get_unmapped_area_topdown(file, addr, len,
33813- pgoff, flags);
33814+ pgoff, flags, offset);
33815 }
33816 #endif /* CONFIG_HUGETLB_PAGE */
33817
33818diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
33819index 8533b46..8c83176 100644
33820--- a/arch/x86/mm/init.c
33821+++ b/arch/x86/mm/init.c
33822@@ -4,6 +4,7 @@
33823 #include <linux/swap.h>
33824 #include <linux/memblock.h>
33825 #include <linux/bootmem.h> /* for max_low_pfn */
33826+#include <linux/tboot.h>
33827
33828 #include <asm/cacheflush.h>
33829 #include <asm/e820.h>
33830@@ -17,6 +18,8 @@
33831 #include <asm/proto.h>
33832 #include <asm/dma.h> /* for MAX_DMA_PFN */
33833 #include <asm/microcode.h>
33834+#include <asm/desc.h>
33835+#include <asm/bios_ebda.h>
33836
33837 /*
33838 * We need to define the tracepoints somewhere, and tlb.c
33839@@ -615,7 +618,18 @@ void __init init_mem_mapping(void)
33840 early_ioremap_page_table_range_init();
33841 #endif
33842
33843+#ifdef CONFIG_PAX_PER_CPU_PGD
33844+ clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
33845+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
33846+ KERNEL_PGD_PTRS);
33847+ clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
33848+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
33849+ KERNEL_PGD_PTRS);
33850+ load_cr3(get_cpu_pgd(0, kernel));
33851+#else
33852 load_cr3(swapper_pg_dir);
33853+#endif
33854+
33855 __flush_tlb_all();
33856
33857 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
33858@@ -631,10 +645,40 @@ void __init init_mem_mapping(void)
33859 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
33860 * mmio resources as well as potential bios/acpi data regions.
33861 */
33862+
33863+#ifdef CONFIG_GRKERNSEC_KMEM
33864+static unsigned int ebda_start __read_only;
33865+static unsigned int ebda_end __read_only;
33866+#endif
33867+
33868 int devmem_is_allowed(unsigned long pagenr)
33869 {
33870- if (pagenr < 256)
33871+#ifdef CONFIG_GRKERNSEC_KMEM
33872+ /* allow BDA */
33873+ if (!pagenr)
33874 return 1;
33875+ /* allow EBDA */
33876+ if (pagenr >= ebda_start && pagenr < ebda_end)
33877+ return 1;
33878+ /* if tboot is in use, allow access to its hardcoded serial log range */
33879+ if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
33880+ return 1;
33881+#else
33882+ if (!pagenr)
33883+ return 1;
33884+#ifdef CONFIG_VM86
33885+ if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
33886+ return 1;
33887+#endif
33888+#endif
33889+
33890+ if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
33891+ return 1;
33892+#ifdef CONFIG_GRKERNSEC_KMEM
33893+ /* throw out everything else below 1MB */
33894+ if (pagenr <= 256)
33895+ return 0;
33896+#endif
33897 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
33898 return 0;
33899 if (!page_is_ram(pagenr))
33900@@ -680,8 +724,127 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
33901 #endif
33902 }
33903
33904+#ifdef CONFIG_GRKERNSEC_KMEM
33905+static inline void gr_init_ebda(void)
33906+{
33907+ unsigned int ebda_addr;
33908+ unsigned int ebda_size = 0;
33909+
33910+ ebda_addr = get_bios_ebda();
33911+ if (ebda_addr) {
33912+ ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
33913+ ebda_size <<= 10;
33914+ }
33915+ if (ebda_addr && ebda_size) {
33916+ ebda_start = ebda_addr >> PAGE_SHIFT;
33917+ ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
33918+ } else {
33919+ ebda_start = 0x9f000 >> PAGE_SHIFT;
33920+ ebda_end = 0xa0000 >> PAGE_SHIFT;
33921+ }
33922+}
33923+#else
33924+static inline void gr_init_ebda(void) { }
33925+#endif
33926+
33927 void free_initmem(void)
33928 {
33929+#ifdef CONFIG_PAX_KERNEXEC
33930+#ifdef CONFIG_X86_32
33931+ /* PaX: limit KERNEL_CS to actual size */
33932+ unsigned long addr, limit;
33933+ struct desc_struct d;
33934+ int cpu;
33935+#else
33936+ pgd_t *pgd;
33937+ pud_t *pud;
33938+ pmd_t *pmd;
33939+ unsigned long addr, end;
33940+#endif
33941+#endif
33942+
33943+ gr_init_ebda();
33944+
33945+#ifdef CONFIG_PAX_KERNEXEC
33946+#ifdef CONFIG_X86_32
33947+ limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
33948+ limit = (limit - 1UL) >> PAGE_SHIFT;
33949+
33950+ memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
33951+ for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
33952+ pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
33953+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
33954+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
33955+ }
33956+
33957+ /* PaX: make KERNEL_CS read-only */
33958+ addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
33959+ if (!paravirt_enabled())
33960+ set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
33961+/*
33962+ for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
33963+ pgd = pgd_offset_k(addr);
33964+ pud = pud_offset(pgd, addr);
33965+ pmd = pmd_offset(pud, addr);
33966+ set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
33967+ }
33968+*/
33969+#ifdef CONFIG_X86_PAE
33970+ set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
33971+/*
33972+ for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
33973+ pgd = pgd_offset_k(addr);
33974+ pud = pud_offset(pgd, addr);
33975+ pmd = pmd_offset(pud, addr);
33976+ set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
33977+ }
33978+*/
33979+#endif
33980+
33981+#ifdef CONFIG_MODULES
33982+ set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
33983+#endif
33984+
33985+#else
33986+ /* PaX: make kernel code/rodata read-only, rest non-executable */
33987+ set_memory_ro((unsigned long)_text, ((unsigned long)(_sdata - _text) >> PAGE_SHIFT));
33988+ set_memory_nx((unsigned long)_sdata, (__START_KERNEL_map + KERNEL_IMAGE_SIZE - (unsigned long)_sdata) >> PAGE_SHIFT);
33989+
33990+ for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
33991+ pgd = pgd_offset_k(addr);
33992+ pud = pud_offset(pgd, addr);
33993+ pmd = pmd_offset(pud, addr);
33994+ if (!pmd_present(*pmd))
33995+ continue;
33996+ if (addr >= (unsigned long)_text)
33997+ BUG_ON(!pmd_large(*pmd));
33998+ if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
33999+ BUG_ON(pmd_write(*pmd));
34000+// set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
34001+ else
34002+ BUG_ON(!(pmd_flags(*pmd) & _PAGE_NX));
34003+// set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
34004+ }
34005+
34006+ addr = (unsigned long)__va(__pa(__START_KERNEL_map));
34007+ end = addr + KERNEL_IMAGE_SIZE;
34008+ for (; addr < end; addr += PMD_SIZE) {
34009+ pgd = pgd_offset_k(addr);
34010+ pud = pud_offset(pgd, addr);
34011+ pmd = pmd_offset(pud, addr);
34012+ if (!pmd_present(*pmd))
34013+ continue;
34014+ if (addr >= (unsigned long)_text)
34015+ BUG_ON(!pmd_large(*pmd));
34016+ if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
34017+ BUG_ON(pmd_write(*pmd));
34018+// set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
34019+ }
34020+#endif
34021+
34022+ flush_tlb_all();
34023+#endif
34024+
34025 free_init_pages("unused kernel",
34026 (unsigned long)(&__init_begin),
34027 (unsigned long)(&__init_end));
34028diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
34029index 68aec42..95ad5d3 100644
34030--- a/arch/x86/mm/init_32.c
34031+++ b/arch/x86/mm/init_32.c
34032@@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
34033 bool __read_mostly __vmalloc_start_set = false;
34034
34035 /*
34036- * Creates a middle page table and puts a pointer to it in the
34037- * given global directory entry. This only returns the gd entry
34038- * in non-PAE compilation mode, since the middle layer is folded.
34039- */
34040-static pmd_t * __init one_md_table_init(pgd_t *pgd)
34041-{
34042- pud_t *pud;
34043- pmd_t *pmd_table;
34044-
34045-#ifdef CONFIG_X86_PAE
34046- if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
34047- pmd_table = (pmd_t *)alloc_low_page();
34048- paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
34049- set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
34050- pud = pud_offset(pgd, 0);
34051- BUG_ON(pmd_table != pmd_offset(pud, 0));
34052-
34053- return pmd_table;
34054- }
34055-#endif
34056- pud = pud_offset(pgd, 0);
34057- pmd_table = pmd_offset(pud, 0);
34058-
34059- return pmd_table;
34060-}
34061-
34062-/*
34063 * Create a page table and place a pointer to it in a middle page
34064 * directory entry:
34065 */
34066@@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
34067 pte_t *page_table = (pte_t *)alloc_low_page();
34068
34069 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
34070+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
34071+ set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
34072+#else
34073 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
34074+#endif
34075 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
34076 }
34077
34078 return pte_offset_kernel(pmd, 0);
34079 }
34080
34081+static pmd_t * __init one_md_table_init(pgd_t *pgd)
34082+{
34083+ pud_t *pud;
34084+ pmd_t *pmd_table;
34085+
34086+ pud = pud_offset(pgd, 0);
34087+ pmd_table = pmd_offset(pud, 0);
34088+
34089+ return pmd_table;
34090+}
34091+
34092 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
34093 {
34094 int pgd_idx = pgd_index(vaddr);
34095@@ -209,6 +197,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
34096 int pgd_idx, pmd_idx;
34097 unsigned long vaddr;
34098 pgd_t *pgd;
34099+ pud_t *pud;
34100 pmd_t *pmd;
34101 pte_t *pte = NULL;
34102 unsigned long count = page_table_range_init_count(start, end);
34103@@ -223,8 +212,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
34104 pgd = pgd_base + pgd_idx;
34105
34106 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
34107- pmd = one_md_table_init(pgd);
34108- pmd = pmd + pmd_index(vaddr);
34109+ pud = pud_offset(pgd, vaddr);
34110+ pmd = pmd_offset(pud, vaddr);
34111+
34112+#ifdef CONFIG_X86_PAE
34113+ paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
34114+#endif
34115+
34116 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
34117 pmd++, pmd_idx++) {
34118 pte = page_table_kmap_check(one_page_table_init(pmd),
34119@@ -236,11 +230,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
34120 }
34121 }
34122
34123-static inline int is_kernel_text(unsigned long addr)
34124+static inline int is_kernel_text(unsigned long start, unsigned long end)
34125 {
34126- if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
34127- return 1;
34128- return 0;
34129+ if ((start >= ktla_ktva((unsigned long)_etext) ||
34130+ end <= ktla_ktva((unsigned long)_stext)) &&
34131+ (start >= ktla_ktva((unsigned long)_einittext) ||
34132+ end <= ktla_ktva((unsigned long)_sinittext)) &&
34133+
34134+#ifdef CONFIG_ACPI_SLEEP
34135+ (start >= (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
34136+#endif
34137+
34138+ (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
34139+ return 0;
34140+ return 1;
34141 }
34142
34143 /*
34144@@ -257,9 +260,10 @@ kernel_physical_mapping_init(unsigned long start,
34145 unsigned long last_map_addr = end;
34146 unsigned long start_pfn, end_pfn;
34147 pgd_t *pgd_base = swapper_pg_dir;
34148- int pgd_idx, pmd_idx, pte_ofs;
34149+ unsigned int pgd_idx, pmd_idx, pte_ofs;
34150 unsigned long pfn;
34151 pgd_t *pgd;
34152+ pud_t *pud;
34153 pmd_t *pmd;
34154 pte_t *pte;
34155 unsigned pages_2m, pages_4k;
34156@@ -292,8 +296,13 @@ repeat:
34157 pfn = start_pfn;
34158 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
34159 pgd = pgd_base + pgd_idx;
34160- for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
34161- pmd = one_md_table_init(pgd);
34162+ for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
34163+ pud = pud_offset(pgd, 0);
34164+ pmd = pmd_offset(pud, 0);
34165+
34166+#ifdef CONFIG_X86_PAE
34167+ paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
34168+#endif
34169
34170 if (pfn >= end_pfn)
34171 continue;
34172@@ -305,14 +314,13 @@ repeat:
34173 #endif
34174 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
34175 pmd++, pmd_idx++) {
34176- unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
34177+ unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
34178
34179 /*
34180 * Map with big pages if possible, otherwise
34181 * create normal page tables:
34182 */
34183 if (use_pse) {
34184- unsigned int addr2;
34185 pgprot_t prot = PAGE_KERNEL_LARGE;
34186 /*
34187 * first pass will use the same initial
34188@@ -323,11 +331,7 @@ repeat:
34189 _PAGE_PSE);
34190
34191 pfn &= PMD_MASK >> PAGE_SHIFT;
34192- addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
34193- PAGE_OFFSET + PAGE_SIZE-1;
34194-
34195- if (is_kernel_text(addr) ||
34196- is_kernel_text(addr2))
34197+ if (is_kernel_text(address, address + PMD_SIZE))
34198 prot = PAGE_KERNEL_LARGE_EXEC;
34199
34200 pages_2m++;
34201@@ -344,7 +348,7 @@ repeat:
34202 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
34203 pte += pte_ofs;
34204 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
34205- pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
34206+ pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
34207 pgprot_t prot = PAGE_KERNEL;
34208 /*
34209 * first pass will use the same initial
34210@@ -352,7 +356,7 @@ repeat:
34211 */
34212 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
34213
34214- if (is_kernel_text(addr))
34215+ if (is_kernel_text(address, address + PAGE_SIZE))
34216 prot = PAGE_KERNEL_EXEC;
34217
34218 pages_4k++;
34219@@ -475,7 +479,7 @@ void __init native_pagetable_init(void)
34220
34221 pud = pud_offset(pgd, va);
34222 pmd = pmd_offset(pud, va);
34223- if (!pmd_present(*pmd))
34224+ if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
34225 break;
34226
34227 /* should not be large page here */
34228@@ -533,12 +537,10 @@ void __init early_ioremap_page_table_range_init(void)
34229
34230 static void __init pagetable_init(void)
34231 {
34232- pgd_t *pgd_base = swapper_pg_dir;
34233-
34234- permanent_kmaps_init(pgd_base);
34235+ permanent_kmaps_init(swapper_pg_dir);
34236 }
34237
34238-pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL);
34239+pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL);
34240 EXPORT_SYMBOL_GPL(__supported_pte_mask);
34241
34242 /* user-defined highmem size */
34243@@ -788,10 +790,10 @@ void __init mem_init(void)
34244 ((unsigned long)&__init_end -
34245 (unsigned long)&__init_begin) >> 10,
34246
34247- (unsigned long)&_etext, (unsigned long)&_edata,
34248- ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
34249+ (unsigned long)&_sdata, (unsigned long)&_edata,
34250+ ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
34251
34252- (unsigned long)&_text, (unsigned long)&_etext,
34253+ ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
34254 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
34255
34256 /*
34257@@ -885,6 +887,7 @@ void set_kernel_text_rw(void)
34258 if (!kernel_set_to_readonly)
34259 return;
34260
34261+ start = ktla_ktva(start);
34262 pr_debug("Set kernel text: %lx - %lx for read write\n",
34263 start, start+size);
34264
34265@@ -899,6 +902,7 @@ void set_kernel_text_ro(void)
34266 if (!kernel_set_to_readonly)
34267 return;
34268
34269+ start = ktla_ktva(start);
34270 pr_debug("Set kernel text: %lx - %lx for read only\n",
34271 start, start+size);
34272
34273@@ -927,6 +931,7 @@ void mark_rodata_ro(void)
34274 unsigned long start = PFN_ALIGN(_text);
34275 unsigned long size = PFN_ALIGN(_etext) - start;
34276
34277+ start = ktla_ktva(start);
34278 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
34279 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
34280 size >> 10);
34281diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
34282index f9977a7..21a5082 100644
34283--- a/arch/x86/mm/init_64.c
34284+++ b/arch/x86/mm/init_64.c
34285@@ -136,7 +136,7 @@ int kernel_ident_mapping_init(struct x86_mapping_info *info, pgd_t *pgd_page,
34286 * around without checking the pgd every time.
34287 */
34288
34289-pteval_t __supported_pte_mask __read_mostly = ~0;
34290+pteval_t __supported_pte_mask __read_only = ~_PAGE_NX;
34291 EXPORT_SYMBOL_GPL(__supported_pte_mask);
34292
34293 int force_personality32;
34294@@ -169,7 +169,12 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
34295
34296 for (address = start; address <= end; address += PGDIR_SIZE) {
34297 const pgd_t *pgd_ref = pgd_offset_k(address);
34298+
34299+#ifdef CONFIG_PAX_PER_CPU_PGD
34300+ unsigned long cpu;
34301+#else
34302 struct page *page;
34303+#endif
34304
34305 /*
34306 * When it is called after memory hot remove, pgd_none()
34307@@ -180,6 +185,25 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
34308 continue;
34309
34310 spin_lock(&pgd_lock);
34311+
34312+#ifdef CONFIG_PAX_PER_CPU_PGD
34313+ for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
34314+ pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
34315+
34316+ if (!pgd_none(*pgd_ref) && !pgd_none(*pgd))
34317+ BUG_ON(pgd_page_vaddr(*pgd)
34318+ != pgd_page_vaddr(*pgd_ref));
34319+
34320+ if (removed) {
34321+ if (pgd_none(*pgd_ref) && !pgd_none(*pgd))
34322+ pgd_clear(pgd);
34323+ } else {
34324+ if (pgd_none(*pgd))
34325+ set_pgd(pgd, *pgd_ref);
34326+ }
34327+
34328+ pgd = pgd_offset_cpu(cpu, kernel, address);
34329+#else
34330 list_for_each_entry(page, &pgd_list, lru) {
34331 pgd_t *pgd;
34332 spinlock_t *pgt_lock;
34333@@ -188,6 +212,7 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
34334 /* the pgt_lock only for Xen */
34335 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
34336 spin_lock(pgt_lock);
34337+#endif
34338
34339 if (!pgd_none(*pgd_ref) && !pgd_none(*pgd))
34340 BUG_ON(pgd_page_vaddr(*pgd)
34341@@ -201,7 +226,10 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
34342 set_pgd(pgd, *pgd_ref);
34343 }
34344
34345+#ifndef CONFIG_PAX_PER_CPU_PGD
34346 spin_unlock(pgt_lock);
34347+#endif
34348+
34349 }
34350 spin_unlock(&pgd_lock);
34351 }
34352@@ -234,7 +262,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
34353 {
34354 if (pgd_none(*pgd)) {
34355 pud_t *pud = (pud_t *)spp_getpage();
34356- pgd_populate(&init_mm, pgd, pud);
34357+ pgd_populate_kernel(&init_mm, pgd, pud);
34358 if (pud != pud_offset(pgd, 0))
34359 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
34360 pud, pud_offset(pgd, 0));
34361@@ -246,7 +274,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
34362 {
34363 if (pud_none(*pud)) {
34364 pmd_t *pmd = (pmd_t *) spp_getpage();
34365- pud_populate(&init_mm, pud, pmd);
34366+ pud_populate_kernel(&init_mm, pud, pmd);
34367 if (pmd != pmd_offset(pud, 0))
34368 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
34369 pmd, pmd_offset(pud, 0));
34370@@ -275,7 +303,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
34371 pmd = fill_pmd(pud, vaddr);
34372 pte = fill_pte(pmd, vaddr);
34373
34374+ pax_open_kernel();
34375 set_pte(pte, new_pte);
34376+ pax_close_kernel();
34377
34378 /*
34379 * It's enough to flush this one mapping.
34380@@ -337,14 +367,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
34381 pgd = pgd_offset_k((unsigned long)__va(phys));
34382 if (pgd_none(*pgd)) {
34383 pud = (pud_t *) spp_getpage();
34384- set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
34385- _PAGE_USER));
34386+ set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
34387 }
34388 pud = pud_offset(pgd, (unsigned long)__va(phys));
34389 if (pud_none(*pud)) {
34390 pmd = (pmd_t *) spp_getpage();
34391- set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
34392- _PAGE_USER));
34393+ set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
34394 }
34395 pmd = pmd_offset(pud, phys);
34396 BUG_ON(!pmd_none(*pmd));
34397@@ -585,7 +613,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
34398 prot);
34399
34400 spin_lock(&init_mm.page_table_lock);
34401- pud_populate(&init_mm, pud, pmd);
34402+ pud_populate_kernel(&init_mm, pud, pmd);
34403 spin_unlock(&init_mm.page_table_lock);
34404 }
34405 __flush_tlb_all();
34406@@ -626,7 +654,7 @@ kernel_physical_mapping_init(unsigned long start,
34407 page_size_mask);
34408
34409 spin_lock(&init_mm.page_table_lock);
34410- pgd_populate(&init_mm, pgd, pud);
34411+ pgd_populate_kernel(&init_mm, pgd, pud);
34412 spin_unlock(&init_mm.page_table_lock);
34413 pgd_changed = true;
34414 }
34415diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
34416index 9c0ff04..9020d5f 100644
34417--- a/arch/x86/mm/iomap_32.c
34418+++ b/arch/x86/mm/iomap_32.c
34419@@ -65,7 +65,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
34420 type = kmap_atomic_idx_push();
34421 idx = type + KM_TYPE_NR * smp_processor_id();
34422 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
34423+
34424+ pax_open_kernel();
34425 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
34426+ pax_close_kernel();
34427+
34428 arch_flush_lazy_mmu_mode();
34429
34430 return (void *)vaddr;
34431diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
34432index b9c78f3..9ca7e24 100644
34433--- a/arch/x86/mm/ioremap.c
34434+++ b/arch/x86/mm/ioremap.c
34435@@ -59,8 +59,8 @@ static int __ioremap_check_ram(unsigned long start_pfn, unsigned long nr_pages,
34436 unsigned long i;
34437
34438 for (i = 0; i < nr_pages; ++i)
34439- if (pfn_valid(start_pfn + i) &&
34440- !PageReserved(pfn_to_page(start_pfn + i)))
34441+ if (pfn_valid(start_pfn + i) && (start_pfn + i >= 0x100 ||
34442+ !PageReserved(pfn_to_page(start_pfn + i))))
34443 return 1;
34444
34445 return 0;
34446@@ -332,7 +332,7 @@ EXPORT_SYMBOL(ioremap_prot);
34447 *
34448 * Caller must ensure there is only one unmapping for the same pointer.
34449 */
34450-void iounmap(volatile void __iomem *addr)
34451+void iounmap(const volatile void __iomem *addr)
34452 {
34453 struct vm_struct *p, *o;
34454
34455@@ -395,31 +395,37 @@ int __init arch_ioremap_pmd_supported(void)
34456 */
34457 void *xlate_dev_mem_ptr(phys_addr_t phys)
34458 {
34459- unsigned long start = phys & PAGE_MASK;
34460- unsigned long offset = phys & ~PAGE_MASK;
34461- void *vaddr;
34462+ phys_addr_t pfn = phys >> PAGE_SHIFT;
34463
34464- /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
34465- if (page_is_ram(start >> PAGE_SHIFT))
34466- return __va(phys);
34467+ if (page_is_ram(pfn)) {
34468+#ifdef CONFIG_HIGHMEM
34469+ if (pfn >= max_low_pfn)
34470+ return kmap_high(pfn_to_page(pfn));
34471+ else
34472+#endif
34473+ return __va(phys);
34474+ }
34475
34476- vaddr = ioremap_cache(start, PAGE_SIZE);
34477- /* Only add the offset on success and return NULL if the ioremap() failed: */
34478- if (vaddr)
34479- vaddr += offset;
34480-
34481- return vaddr;
34482+ return (void __force *)ioremap_cache(phys, 1);
34483 }
34484
34485 void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
34486 {
34487- if (page_is_ram(phys >> PAGE_SHIFT))
34488+ phys_addr_t pfn = phys >> PAGE_SHIFT;
34489+
34490+ if (page_is_ram(pfn)) {
34491+#ifdef CONFIG_HIGHMEM
34492+ if (pfn >= max_low_pfn)
34493+ kunmap_high(pfn_to_page(pfn));
34494+#endif
34495 return;
34496+ }
34497
34498- iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
34499+ iounmap((void __iomem __force *)addr);
34500 }
34501
34502-static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
34503+static pte_t __bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
34504+static pte_t *bm_pte __read_only = __bm_pte;
34505
34506 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
34507 {
34508@@ -455,8 +461,14 @@ void __init early_ioremap_init(void)
34509 early_ioremap_setup();
34510
34511 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
34512- memset(bm_pte, 0, sizeof(bm_pte));
34513- pmd_populate_kernel(&init_mm, pmd, bm_pte);
34514+ if (pmd_none(*pmd))
34515+#ifdef CONFIG_COMPAT_VDSO
34516+ pmd_populate_user(&init_mm, pmd, __bm_pte);
34517+#else
34518+ pmd_populate_kernel(&init_mm, pmd, __bm_pte);
34519+#endif
34520+ else
34521+ bm_pte = (pte_t *)pmd_page_vaddr(*pmd);
34522
34523 /*
34524 * The boot-ioremap range spans multiple pmds, for which
34525diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
34526index b4f2e7e..96c9c3e 100644
34527--- a/arch/x86/mm/kmemcheck/kmemcheck.c
34528+++ b/arch/x86/mm/kmemcheck/kmemcheck.c
34529@@ -628,9 +628,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
34530 * memory (e.g. tracked pages)? For now, we need this to avoid
34531 * invoking kmemcheck for PnP BIOS calls.
34532 */
34533- if (regs->flags & X86_VM_MASK)
34534+ if (v8086_mode(regs))
34535 return false;
34536- if (regs->cs != __KERNEL_CS)
34537+ if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
34538 return false;
34539
34540 pte = kmemcheck_pte_lookup(address);
34541diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
34542index 844b06d..f363c86 100644
34543--- a/arch/x86/mm/mmap.c
34544+++ b/arch/x86/mm/mmap.c
34545@@ -52,7 +52,7 @@ static unsigned long stack_maxrandom_size(void)
34546 * Leave an at least ~128 MB hole with possible stack randomization.
34547 */
34548 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
34549-#define MAX_GAP (TASK_SIZE/6*5)
34550+#define MAX_GAP (pax_task_size/6*5)
34551
34552 static int mmap_is_legacy(void)
34553 {
34554@@ -81,27 +81,40 @@ unsigned long arch_mmap_rnd(void)
34555 return rnd << PAGE_SHIFT;
34556 }
34557
34558-static unsigned long mmap_base(unsigned long rnd)
34559+static unsigned long mmap_base(struct mm_struct *mm, unsigned long rnd)
34560 {
34561 unsigned long gap = rlimit(RLIMIT_STACK);
34562+ unsigned long pax_task_size = TASK_SIZE;
34563+
34564+#ifdef CONFIG_PAX_SEGMEXEC
34565+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
34566+ pax_task_size = SEGMEXEC_TASK_SIZE;
34567+#endif
34568
34569 if (gap < MIN_GAP)
34570 gap = MIN_GAP;
34571 else if (gap > MAX_GAP)
34572 gap = MAX_GAP;
34573
34574- return PAGE_ALIGN(TASK_SIZE - gap - rnd);
34575+ return PAGE_ALIGN(pax_task_size - gap - rnd);
34576 }
34577
34578 /*
34579 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
34580 * does, but not when emulating X86_32
34581 */
34582-static unsigned long mmap_legacy_base(unsigned long rnd)
34583+static unsigned long mmap_legacy_base(struct mm_struct *mm, unsigned long rnd)
34584 {
34585- if (mmap_is_ia32())
34586+ if (mmap_is_ia32()) {
34587+
34588+#ifdef CONFIG_PAX_SEGMEXEC
34589+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
34590+ return SEGMEXEC_TASK_UNMAPPED_BASE;
34591+ else
34592+#endif
34593+
34594 return TASK_UNMAPPED_BASE;
34595- else
34596+ } else
34597 return TASK_UNMAPPED_BASE + rnd;
34598 }
34599
34600@@ -113,18 +126,29 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
34601 {
34602 unsigned long random_factor = 0UL;
34603
34604+#ifdef CONFIG_PAX_RANDMMAP
34605+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
34606+#endif
34607 if (current->flags & PF_RANDOMIZE)
34608 random_factor = arch_mmap_rnd();
34609
34610- mm->mmap_legacy_base = mmap_legacy_base(random_factor);
34611+ mm->mmap_legacy_base = mmap_legacy_base(mm, random_factor);
34612
34613 if (mmap_is_legacy()) {
34614 mm->mmap_base = mm->mmap_legacy_base;
34615 mm->get_unmapped_area = arch_get_unmapped_area;
34616 } else {
34617- mm->mmap_base = mmap_base(random_factor);
34618+ mm->mmap_base = mmap_base(mm, random_factor);
34619 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
34620 }
34621+
34622+#ifdef CONFIG_PAX_RANDMMAP
34623+ if (mm->pax_flags & MF_PAX_RANDMMAP) {
34624+ mm->mmap_legacy_base += mm->delta_mmap;
34625+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
34626+ }
34627+#endif
34628+
34629 }
34630
34631 const char *arch_vma_name(struct vm_area_struct *vma)
34632diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
34633index 0057a7a..95c7edd 100644
34634--- a/arch/x86/mm/mmio-mod.c
34635+++ b/arch/x86/mm/mmio-mod.c
34636@@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
34637 break;
34638 default:
34639 {
34640- unsigned char *ip = (unsigned char *)instptr;
34641+ unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
34642 my_trace->opcode = MMIO_UNKNOWN_OP;
34643 my_trace->width = 0;
34644 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
34645@@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
34646 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
34647 void __iomem *addr)
34648 {
34649- static atomic_t next_id;
34650+ static atomic_unchecked_t next_id;
34651 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
34652 /* These are page-unaligned. */
34653 struct mmiotrace_map map = {
34654@@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
34655 .private = trace
34656 },
34657 .phys = offset,
34658- .id = atomic_inc_return(&next_id)
34659+ .id = atomic_inc_return_unchecked(&next_id)
34660 };
34661 map.map_id = trace->id;
34662
34663@@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
34664 ioremap_trace_core(offset, size, addr);
34665 }
34666
34667-static void iounmap_trace_core(volatile void __iomem *addr)
34668+static void iounmap_trace_core(const volatile void __iomem *addr)
34669 {
34670 struct mmiotrace_map map = {
34671 .phys = 0,
34672@@ -328,7 +328,7 @@ not_enabled:
34673 }
34674 }
34675
34676-void mmiotrace_iounmap(volatile void __iomem *addr)
34677+void mmiotrace_iounmap(const volatile void __iomem *addr)
34678 {
34679 might_sleep();
34680 if (is_enabled()) /* recheck and proper locking in *_core() */
34681diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
34682index 4053bb5..b1ad3dc 100644
34683--- a/arch/x86/mm/numa.c
34684+++ b/arch/x86/mm/numa.c
34685@@ -506,7 +506,7 @@ static void __init numa_clear_kernel_node_hotplug(void)
34686 }
34687 }
34688
34689-static int __init numa_register_memblks(struct numa_meminfo *mi)
34690+static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
34691 {
34692 unsigned long uninitialized_var(pfn_align);
34693 int i, nid;
34694diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
34695index 727158c..54dd3ff 100644
34696--- a/arch/x86/mm/pageattr.c
34697+++ b/arch/x86/mm/pageattr.c
34698@@ -260,7 +260,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
34699 */
34700 #ifdef CONFIG_PCI_BIOS
34701 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
34702- pgprot_val(forbidden) |= _PAGE_NX;
34703+ pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
34704 #endif
34705
34706 /*
34707@@ -268,9 +268,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
34708 * Does not cover __inittext since that is gone later on. On
34709 * 64bit we do not enforce !NX on the low mapping
34710 */
34711- if (within(address, (unsigned long)_text, (unsigned long)_etext))
34712- pgprot_val(forbidden) |= _PAGE_NX;
34713+ if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
34714+ pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
34715
34716+#ifdef CONFIG_DEBUG_RODATA
34717 /*
34718 * The .rodata section needs to be read-only. Using the pfn
34719 * catches all aliases.
34720@@ -278,6 +279,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
34721 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
34722 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
34723 pgprot_val(forbidden) |= _PAGE_RW;
34724+#endif
34725
34726 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
34727 /*
34728@@ -316,6 +318,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
34729 }
34730 #endif
34731
34732+#ifdef CONFIG_PAX_KERNEXEC
34733+ if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
34734+ pgprot_val(forbidden) |= _PAGE_RW;
34735+ pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
34736+ }
34737+#endif
34738+
34739 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
34740
34741 return prot;
34742@@ -436,23 +445,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
34743 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
34744 {
34745 /* change init_mm */
34746+ pax_open_kernel();
34747 set_pte_atomic(kpte, pte);
34748+
34749 #ifdef CONFIG_X86_32
34750 if (!SHARED_KERNEL_PMD) {
34751+
34752+#ifdef CONFIG_PAX_PER_CPU_PGD
34753+ unsigned long cpu;
34754+#else
34755 struct page *page;
34756+#endif
34757
34758+#ifdef CONFIG_PAX_PER_CPU_PGD
34759+ for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
34760+ pgd_t *pgd = get_cpu_pgd(cpu, kernel);
34761+#else
34762 list_for_each_entry(page, &pgd_list, lru) {
34763- pgd_t *pgd;
34764+ pgd_t *pgd = (pgd_t *)page_address(page);
34765+#endif
34766+
34767 pud_t *pud;
34768 pmd_t *pmd;
34769
34770- pgd = (pgd_t *)page_address(page) + pgd_index(address);
34771+ pgd += pgd_index(address);
34772 pud = pud_offset(pgd, address);
34773 pmd = pmd_offset(pud, address);
34774 set_pte_atomic((pte_t *)pmd, pte);
34775 }
34776 }
34777 #endif
34778+ pax_close_kernel();
34779 }
34780
34781 static int
34782@@ -505,7 +528,8 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
34783 * up accordingly.
34784 */
34785 old_pte = *kpte;
34786- old_prot = req_prot = pgprot_large_2_4k(pte_pgprot(old_pte));
34787+ old_prot = pte_pgprot(old_pte);
34788+ req_prot = pgprot_large_2_4k(old_prot);
34789
34790 pgprot_val(req_prot) &= ~pgprot_val(cpa->mask_clr);
34791 pgprot_val(req_prot) |= pgprot_val(cpa->mask_set);
34792@@ -1176,7 +1200,9 @@ repeat:
34793 * Do we really change anything ?
34794 */
34795 if (pte_val(old_pte) != pte_val(new_pte)) {
34796+ pax_open_kernel();
34797 set_pte_atomic(kpte, new_pte);
34798+ pax_close_kernel();
34799 cpa->flags |= CPA_FLUSHTLB;
34800 }
34801 cpa->numpages = 1;
34802diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
34803index 188e3e0..5c75446 100644
34804--- a/arch/x86/mm/pat.c
34805+++ b/arch/x86/mm/pat.c
34806@@ -588,7 +588,7 @@ int free_memtype(u64 start, u64 end)
34807
34808 if (!entry) {
34809 pr_info("x86/PAT: %s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
34810- current->comm, current->pid, start, end - 1);
34811+ current->comm, task_pid_nr(current), start, end - 1);
34812 return -EINVAL;
34813 }
34814
34815@@ -711,8 +711,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34816
34817 while (cursor < to) {
34818 if (!devmem_is_allowed(pfn)) {
34819- pr_info("x86/PAT: Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx], PAT prevents it\n",
34820- current->comm, from, to - 1);
34821+ pr_info("x86/PAT: Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx), PAT prevents it\n",
34822+ current->comm, from, to - 1, cursor);
34823 return 0;
34824 }
34825 cursor += PAGE_SIZE;
34826@@ -782,7 +782,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size,
34827
34828 if (ioremap_change_attr((unsigned long)__va(base), id_sz, pcm) < 0) {
34829 pr_info("x86/PAT: %s:%d ioremap_change_attr failed %s for [mem %#010Lx-%#010Lx]\n",
34830- current->comm, current->pid,
34831+ current->comm, task_pid_nr(current),
34832 cattr_name(pcm),
34833 base, (unsigned long long)(base + size-1));
34834 return -EINVAL;
34835@@ -817,7 +817,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
34836 pcm = lookup_memtype(paddr);
34837 if (want_pcm != pcm) {
34838 pr_warn("x86/PAT: %s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
34839- current->comm, current->pid,
34840+ current->comm, task_pid_nr(current),
34841 cattr_name(want_pcm),
34842 (unsigned long long)paddr,
34843 (unsigned long long)(paddr + size - 1),
34844@@ -838,7 +838,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
34845 !is_new_memtype_allowed(paddr, size, want_pcm, pcm)) {
34846 free_memtype(paddr, paddr + size);
34847 pr_err("x86/PAT: %s:%d map pfn expected mapping type %s for [mem %#010Lx-%#010Lx], got %s\n",
34848- current->comm, current->pid,
34849+ current->comm, task_pid_nr(current),
34850 cattr_name(want_pcm),
34851 (unsigned long long)paddr,
34852 (unsigned long long)(paddr + size - 1),
34853diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
34854index 6393108..890adda 100644
34855--- a/arch/x86/mm/pat_rbtree.c
34856+++ b/arch/x86/mm/pat_rbtree.c
34857@@ -161,7 +161,7 @@ success:
34858
34859 failure:
34860 pr_info("x86/PAT: %s:%d conflicting memory types %Lx-%Lx %s<->%s\n",
34861- current->comm, current->pid, start, end,
34862+ current->comm, task_pid_nr(current), start, end,
34863 cattr_name(found_type), cattr_name(match->type));
34864 return -EBUSY;
34865 }
34866diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
34867index 9f0614d..92ae64a 100644
34868--- a/arch/x86/mm/pf_in.c
34869+++ b/arch/x86/mm/pf_in.c
34870@@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
34871 int i;
34872 enum reason_type rv = OTHERS;
34873
34874- p = (unsigned char *)ins_addr;
34875+ p = (unsigned char *)ktla_ktva(ins_addr);
34876 p += skip_prefix(p, &prf);
34877 p += get_opcode(p, &opcode);
34878
34879@@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
34880 struct prefix_bits prf;
34881 int i;
34882
34883- p = (unsigned char *)ins_addr;
34884+ p = (unsigned char *)ktla_ktva(ins_addr);
34885 p += skip_prefix(p, &prf);
34886 p += get_opcode(p, &opcode);
34887
34888@@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
34889 struct prefix_bits prf;
34890 int i;
34891
34892- p = (unsigned char *)ins_addr;
34893+ p = (unsigned char *)ktla_ktva(ins_addr);
34894 p += skip_prefix(p, &prf);
34895 p += get_opcode(p, &opcode);
34896
34897@@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
34898 struct prefix_bits prf;
34899 int i;
34900
34901- p = (unsigned char *)ins_addr;
34902+ p = (unsigned char *)ktla_ktva(ins_addr);
34903 p += skip_prefix(p, &prf);
34904 p += get_opcode(p, &opcode);
34905 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
34906@@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
34907 struct prefix_bits prf;
34908 int i;
34909
34910- p = (unsigned char *)ins_addr;
34911+ p = (unsigned char *)ktla_ktva(ins_addr);
34912 p += skip_prefix(p, &prf);
34913 p += get_opcode(p, &opcode);
34914 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
34915diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
34916index fb0a9dd..5ab49c4 100644
34917--- a/arch/x86/mm/pgtable.c
34918+++ b/arch/x86/mm/pgtable.c
34919@@ -98,10 +98,75 @@ static inline void pgd_list_del(pgd_t *pgd)
34920 list_del(&page->lru);
34921 }
34922
34923-#define UNSHARED_PTRS_PER_PGD \
34924- (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
34925+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
34926+pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
34927
34928+void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
34929+{
34930+ unsigned int count = USER_PGD_PTRS;
34931
34932+ if (!pax_user_shadow_base)
34933+ return;
34934+
34935+ while (count--)
34936+ *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
34937+}
34938+#endif
34939+
34940+#ifdef CONFIG_PAX_PER_CPU_PGD
34941+void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
34942+{
34943+ unsigned int count = USER_PGD_PTRS;
34944+
34945+ while (count--) {
34946+ pgd_t pgd;
34947+
34948+#ifdef CONFIG_X86_64
34949+ pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
34950+#else
34951+ pgd = *src++;
34952+#endif
34953+
34954+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
34955+ pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
34956+#endif
34957+
34958+ *dst++ = pgd;
34959+ }
34960+
34961+}
34962+#endif
34963+
34964+#ifdef CONFIG_X86_64
34965+#define pxd_t pud_t
34966+#define pyd_t pgd_t
34967+#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
34968+#define pgtable_pxd_page_ctor(page) true
34969+#define pgtable_pxd_page_dtor(page) do {} while (0)
34970+#define pxd_free(mm, pud) pud_free((mm), (pud))
34971+#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
34972+#define pyd_offset(mm, address) pgd_offset((mm), (address))
34973+#define PYD_SIZE PGDIR_SIZE
34974+#define mm_inc_nr_pxds(mm) do {} while (0)
34975+#define mm_dec_nr_pxds(mm) do {} while (0)
34976+#else
34977+#define pxd_t pmd_t
34978+#define pyd_t pud_t
34979+#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
34980+#define pgtable_pxd_page_ctor(page) pgtable_pmd_page_ctor(page)
34981+#define pgtable_pxd_page_dtor(page) pgtable_pmd_page_dtor(page)
34982+#define pxd_free(mm, pud) pmd_free((mm), (pud))
34983+#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
34984+#define pyd_offset(mm, address) pud_offset((mm), (address))
34985+#define PYD_SIZE PUD_SIZE
34986+#define mm_inc_nr_pxds(mm) mm_inc_nr_pmds(mm)
34987+#define mm_dec_nr_pxds(mm) mm_dec_nr_pmds(mm)
34988+#endif
34989+
34990+#ifdef CONFIG_PAX_PER_CPU_PGD
34991+static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
34992+static inline void pgd_dtor(pgd_t *pgd) {}
34993+#else
34994 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
34995 {
34996 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
34997@@ -142,6 +207,7 @@ static void pgd_dtor(pgd_t *pgd)
34998 pgd_list_del(pgd);
34999 spin_unlock(&pgd_lock);
35000 }
35001+#endif
35002
35003 /*
35004 * List of all pgd's needed for non-PAE so it can invalidate entries
35005@@ -154,7 +220,7 @@ static void pgd_dtor(pgd_t *pgd)
35006 * -- nyc
35007 */
35008
35009-#ifdef CONFIG_X86_PAE
35010+#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
35011 /*
35012 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
35013 * updating the top-level pagetable entries to guarantee the
35014@@ -166,7 +232,7 @@ static void pgd_dtor(pgd_t *pgd)
35015 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
35016 * and initialize the kernel pmds here.
35017 */
35018-#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
35019+#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
35020
35021 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
35022 {
35023@@ -184,46 +250,48 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
35024 */
35025 flush_tlb_mm(mm);
35026 }
35027+#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
35028+#define PREALLOCATED_PXDS USER_PGD_PTRS
35029 #else /* !CONFIG_X86_PAE */
35030
35031 /* No need to prepopulate any pagetable entries in non-PAE modes. */
35032-#define PREALLOCATED_PMDS 0
35033+#define PREALLOCATED_PXDS 0
35034
35035 #endif /* CONFIG_X86_PAE */
35036
35037-static void free_pmds(struct mm_struct *mm, pmd_t *pmds[])
35038+static void free_pxds(struct mm_struct *mm, pxd_t *pxds[])
35039 {
35040 int i;
35041
35042- for(i = 0; i < PREALLOCATED_PMDS; i++)
35043- if (pmds[i]) {
35044- pgtable_pmd_page_dtor(virt_to_page(pmds[i]));
35045- free_page((unsigned long)pmds[i]);
35046- mm_dec_nr_pmds(mm);
35047+ for(i = 0; i < PREALLOCATED_PXDS; i++)
35048+ if (pxds[i]) {
35049+ pgtable_pxd_page_dtor(virt_to_page(pxds[i]));
35050+ free_page((unsigned long)pxds[i]);
35051+ mm_dec_nr_pxds(mm);
35052 }
35053 }
35054
35055-static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
35056+static int preallocate_pxds(struct mm_struct *mm, pxd_t *pxds[])
35057 {
35058 int i;
35059 bool failed = false;
35060
35061- for(i = 0; i < PREALLOCATED_PMDS; i++) {
35062- pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
35063- if (!pmd)
35064+ for(i = 0; i < PREALLOCATED_PXDS; i++) {
35065+ pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
35066+ if (!pxd)
35067 failed = true;
35068- if (pmd && !pgtable_pmd_page_ctor(virt_to_page(pmd))) {
35069- free_page((unsigned long)pmd);
35070- pmd = NULL;
35071+ if (pxd && !pgtable_pxd_page_ctor(virt_to_page(pxd))) {
35072+ free_page((unsigned long)pxd);
35073+ pxd = NULL;
35074 failed = true;
35075 }
35076- if (pmd)
35077- mm_inc_nr_pmds(mm);
35078- pmds[i] = pmd;
35079+ if (pxd)
35080+ mm_inc_nr_pxds(mm);
35081+ pxds[i] = pxd;
35082 }
35083
35084 if (failed) {
35085- free_pmds(mm, pmds);
35086+ free_pxds(mm, pxds);
35087 return -ENOMEM;
35088 }
35089
35090@@ -236,43 +304,47 @@ static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
35091 * preallocate which never got a corresponding vma will need to be
35092 * freed manually.
35093 */
35094-static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
35095+static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
35096 {
35097 int i;
35098
35099- for(i = 0; i < PREALLOCATED_PMDS; i++) {
35100+ for(i = 0; i < PREALLOCATED_PXDS; i++) {
35101 pgd_t pgd = pgdp[i];
35102
35103 if (pgd_val(pgd) != 0) {
35104- pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
35105+ pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
35106
35107- pgdp[i] = native_make_pgd(0);
35108+ set_pgd(pgdp + i, native_make_pgd(0));
35109
35110- paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
35111- pmd_free(mm, pmd);
35112- mm_dec_nr_pmds(mm);
35113+ paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
35114+ pxd_free(mm, pxd);
35115+ mm_dec_nr_pxds(mm);
35116 }
35117 }
35118 }
35119
35120-static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
35121+static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
35122 {
35123- pud_t *pud;
35124+ pyd_t *pyd;
35125 int i;
35126
35127- if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
35128+ if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
35129 return;
35130
35131- pud = pud_offset(pgd, 0);
35132+#ifdef CONFIG_X86_64
35133+ pyd = pyd_offset(mm, 0L);
35134+#else
35135+ pyd = pyd_offset(pgd, 0L);
35136+#endif
35137
35138- for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
35139- pmd_t *pmd = pmds[i];
35140+ for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
35141+ pxd_t *pxd = pxds[i];
35142
35143 if (i >= KERNEL_PGD_BOUNDARY)
35144- memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
35145- sizeof(pmd_t) * PTRS_PER_PMD);
35146+ memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
35147+ sizeof(pxd_t) * PTRS_PER_PMD);
35148
35149- pud_populate(mm, pud, pmd);
35150+ pyd_populate(mm, pyd, pxd);
35151 }
35152 }
35153
35154@@ -354,7 +426,7 @@ static inline void _pgd_free(pgd_t *pgd)
35155 pgd_t *pgd_alloc(struct mm_struct *mm)
35156 {
35157 pgd_t *pgd;
35158- pmd_t *pmds[PREALLOCATED_PMDS];
35159+ pxd_t *pxds[PREALLOCATED_PXDS];
35160
35161 pgd = _pgd_alloc();
35162
35163@@ -363,11 +435,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
35164
35165 mm->pgd = pgd;
35166
35167- if (preallocate_pmds(mm, pmds) != 0)
35168+ if (preallocate_pxds(mm, pxds) != 0)
35169 goto out_free_pgd;
35170
35171 if (paravirt_pgd_alloc(mm) != 0)
35172- goto out_free_pmds;
35173+ goto out_free_pxds;
35174
35175 /*
35176 * Make sure that pre-populating the pmds is atomic with
35177@@ -377,14 +449,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
35178 spin_lock(&pgd_lock);
35179
35180 pgd_ctor(mm, pgd);
35181- pgd_prepopulate_pmd(mm, pgd, pmds);
35182+ pgd_prepopulate_pxd(mm, pgd, pxds);
35183
35184 spin_unlock(&pgd_lock);
35185
35186 return pgd;
35187
35188-out_free_pmds:
35189- free_pmds(mm, pmds);
35190+out_free_pxds:
35191+ free_pxds(mm, pxds);
35192 out_free_pgd:
35193 _pgd_free(pgd);
35194 out:
35195@@ -393,7 +465,7 @@ out:
35196
35197 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
35198 {
35199- pgd_mop_up_pmds(mm, pgd);
35200+ pgd_mop_up_pxds(mm, pgd);
35201 pgd_dtor(pgd);
35202 paravirt_pgd_free(mm, pgd);
35203 _pgd_free(pgd);
35204@@ -544,6 +616,55 @@ void __init reserve_top_address(unsigned long reserve)
35205
35206 int fixmaps_set;
35207
35208+static void fix_user_fixmap(enum fixed_addresses idx, unsigned long address)
35209+{
35210+#ifdef CONFIG_X86_64
35211+ pgd_t *pgd;
35212+ pud_t *pud;
35213+ pmd_t *pmd;
35214+
35215+ switch (idx) {
35216+ default:
35217+ return;
35218+
35219+#ifdef CONFIG_X86_VSYSCALL_EMULATION
35220+ case VSYSCALL_PAGE:
35221+ break;
35222+#endif
35223+
35224+#ifdef CONFIG_PARAVIRT_CLOCK
35225+ case PVCLOCK_FIXMAP_BEGIN ... PVCLOCK_FIXMAP_END:
35226+ break;
35227+#endif
35228+ }
35229+
35230+ pgd = pgd_offset_k(address);
35231+ if (!(pgd_val(*pgd) & _PAGE_USER)) {
35232+#ifdef CONFIG_PAX_PER_CPU_PGD
35233+ unsigned int cpu;
35234+ pgd_t *pgd_cpu;
35235+
35236+ for_each_possible_cpu(cpu) {
35237+ pgd_cpu = pgd_offset_cpu(cpu, kernel, address);
35238+ set_pgd(pgd_cpu, __pgd(pgd_val(*pgd_cpu) | _PAGE_USER));
35239+
35240+ pgd_cpu = pgd_offset_cpu(cpu, user, address);
35241+ set_pgd(pgd_cpu, __pgd(pgd_val(*pgd_cpu) | _PAGE_USER));
35242+ }
35243+#endif
35244+ set_pgd(pgd, __pgd(pgd_val(*pgd) | _PAGE_USER));
35245+ }
35246+
35247+ pud = pud_offset(pgd, address);
35248+ if (!(pud_val(*pud) & _PAGE_USER))
35249+ set_pud(pud, __pud(pud_val(*pud) | _PAGE_USER));
35250+
35251+ pmd = pmd_offset(pud, address);
35252+ if (!(pmd_val(*pmd) & _PAGE_USER))
35253+ set_pmd(pmd, __pmd(pmd_val(*pmd) | _PAGE_USER));
35254+#endif
35255+}
35256+
35257 void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
35258 {
35259 unsigned long address = __fix_to_virt(idx);
35260@@ -554,6 +675,7 @@ void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
35261 }
35262 set_pte_vaddr(address, pte);
35263 fixmaps_set++;
35264+ fix_user_fixmap(idx, address);
35265 }
35266
35267 void native_set_fixmap(enum fixed_addresses idx, phys_addr_t phys,
35268@@ -620,9 +742,11 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)
35269
35270 prot = pgprot_4k_2_large(prot);
35271
35272+ pax_open_kernel();
35273 set_pte((pte_t *)pmd, pfn_pte(
35274 (u64)addr >> PAGE_SHIFT,
35275 __pgprot(pgprot_val(prot) | _PAGE_PSE)));
35276+ pax_close_kernel();
35277
35278 return 1;
35279 }
35280diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
35281index 75cc097..79a097f 100644
35282--- a/arch/x86/mm/pgtable_32.c
35283+++ b/arch/x86/mm/pgtable_32.c
35284@@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
35285 return;
35286 }
35287 pte = pte_offset_kernel(pmd, vaddr);
35288+
35289+ pax_open_kernel();
35290 if (pte_val(pteval))
35291 set_pte_at(&init_mm, vaddr, pte, pteval);
35292 else
35293 pte_clear(&init_mm, vaddr, pte);
35294+ pax_close_kernel();
35295
35296 /*
35297 * It's enough to flush this one mapping.
35298diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
35299index 90555bf..f5f1828 100644
35300--- a/arch/x86/mm/setup_nx.c
35301+++ b/arch/x86/mm/setup_nx.c
35302@@ -5,8 +5,10 @@
35303 #include <asm/pgtable.h>
35304 #include <asm/proto.h>
35305
35306+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
35307 static int disable_nx;
35308
35309+#ifndef CONFIG_PAX_PAGEEXEC
35310 /*
35311 * noexec = on|off
35312 *
35313@@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
35314 return 0;
35315 }
35316 early_param("noexec", noexec_setup);
35317+#endif
35318+
35319+#endif
35320
35321 void x86_configure_nx(void)
35322 {
35323+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
35324 if (cpu_has_nx && !disable_nx)
35325 __supported_pte_mask |= _PAGE_NX;
35326 else
35327+#endif
35328 __supported_pte_mask &= ~_PAGE_NX;
35329 }
35330
35331diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
35332index 90b924a..4197ac2 100644
35333--- a/arch/x86/mm/tlb.c
35334+++ b/arch/x86/mm/tlb.c
35335@@ -45,7 +45,11 @@ void leave_mm(int cpu)
35336 BUG();
35337 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
35338 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
35339+
35340+#ifndef CONFIG_PAX_PER_CPU_PGD
35341 load_cr3(swapper_pg_dir);
35342+#endif
35343+
35344 /*
35345 * This gets called in the idle path where RCU
35346 * functions differently. Tracing normally
35347diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
35348new file mode 100644
35349index 0000000..3fda3f3
35350--- /dev/null
35351+++ b/arch/x86/mm/uderef_64.c
35352@@ -0,0 +1,37 @@
35353+#include <linux/mm.h>
35354+#include <asm/pgtable.h>
35355+#include <asm/uaccess.h>
35356+
35357+#ifdef CONFIG_PAX_MEMORY_UDEREF
35358+/* PaX: due to the special call convention these functions must
35359+ * - remain leaf functions under all configurations,
35360+ * - never be called directly, only dereferenced from the wrappers.
35361+ */
35362+void __used __pax_open_userland(void)
35363+{
35364+ unsigned int cpu;
35365+
35366+ if (unlikely(!segment_eq(get_fs(), USER_DS)))
35367+ return;
35368+
35369+ cpu = raw_get_cpu();
35370+ BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
35371+ write_cr3(__pa_nodebug(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
35372+ raw_put_cpu_no_resched();
35373+}
35374+EXPORT_SYMBOL(__pax_open_userland);
35375+
35376+void __used __pax_close_userland(void)
35377+{
35378+ unsigned int cpu;
35379+
35380+ if (unlikely(!segment_eq(get_fs(), USER_DS)))
35381+ return;
35382+
35383+ cpu = raw_get_cpu();
35384+ BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
35385+ write_cr3(__pa_nodebug(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
35386+ raw_put_cpu_no_resched();
35387+}
35388+EXPORT_SYMBOL(__pax_close_userland);
35389+#endif
35390diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
35391index 4093216..44b6b83 100644
35392--- a/arch/x86/net/bpf_jit.S
35393+++ b/arch/x86/net/bpf_jit.S
35394@@ -8,6 +8,7 @@
35395 * of the License.
35396 */
35397 #include <linux/linkage.h>
35398+#include <asm/alternative-asm.h>
35399
35400 /*
35401 * Calling convention :
35402@@ -37,6 +38,7 @@ sk_load_word_positive_offset:
35403 jle bpf_slow_path_word
35404 mov (SKBDATA,%rsi),%eax
35405 bswap %eax /* ntohl() */
35406+ pax_force_retaddr
35407 ret
35408
35409 sk_load_half:
35410@@ -54,6 +56,7 @@ sk_load_half_positive_offset:
35411 jle bpf_slow_path_half
35412 movzwl (SKBDATA,%rsi),%eax
35413 rol $8,%ax # ntohs()
35414+ pax_force_retaddr
35415 ret
35416
35417 sk_load_byte:
35418@@ -68,6 +71,7 @@ sk_load_byte_positive_offset:
35419 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
35420 jle bpf_slow_path_byte
35421 movzbl (SKBDATA,%rsi),%eax
35422+ pax_force_retaddr
35423 ret
35424
35425 /* rsi contains offset and can be scratched */
35426@@ -89,6 +93,7 @@ bpf_slow_path_word:
35427 js bpf_error
35428 mov - MAX_BPF_STACK + 32(%rbp),%eax
35429 bswap %eax
35430+ pax_force_retaddr
35431 ret
35432
35433 bpf_slow_path_half:
35434@@ -97,12 +102,14 @@ bpf_slow_path_half:
35435 mov - MAX_BPF_STACK + 32(%rbp),%ax
35436 rol $8,%ax
35437 movzwl %ax,%eax
35438+ pax_force_retaddr
35439 ret
35440
35441 bpf_slow_path_byte:
35442 bpf_slow_path_common(1)
35443 js bpf_error
35444 movzbl - MAX_BPF_STACK + 32(%rbp),%eax
35445+ pax_force_retaddr
35446 ret
35447
35448 #define sk_negative_common(SIZE) \
35449@@ -125,6 +132,7 @@ sk_load_word_negative_offset:
35450 sk_negative_common(4)
35451 mov (%rax), %eax
35452 bswap %eax
35453+ pax_force_retaddr
35454 ret
35455
35456 bpf_slow_path_half_neg:
35457@@ -136,6 +144,7 @@ sk_load_half_negative_offset:
35458 mov (%rax),%ax
35459 rol $8,%ax
35460 movzwl %ax,%eax
35461+ pax_force_retaddr
35462 ret
35463
35464 bpf_slow_path_byte_neg:
35465@@ -145,6 +154,7 @@ sk_load_byte_negative_offset:
35466 .globl sk_load_byte_negative_offset
35467 sk_negative_common(1)
35468 movzbl (%rax), %eax
35469+ pax_force_retaddr
35470 ret
35471
35472 bpf_error:
35473@@ -155,4 +165,5 @@ bpf_error:
35474 mov - MAX_BPF_STACK + 16(%rbp),%r14
35475 mov - MAX_BPF_STACK + 24(%rbp),%r15
35476 leaveq
35477+ pax_force_retaddr
35478 ret
35479diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
35480index be2e7a2..e6960dd 100644
35481--- a/arch/x86/net/bpf_jit_comp.c
35482+++ b/arch/x86/net/bpf_jit_comp.c
35483@@ -14,7 +14,11 @@
35484 #include <asm/cacheflush.h>
35485 #include <linux/bpf.h>
35486
35487+#ifdef CONFIG_GRKERNSEC_BPF_HARDEN
35488+int bpf_jit_enable __read_only;
35489+#else
35490 int bpf_jit_enable __read_mostly;
35491+#endif
35492
35493 /*
35494 * assembly code in arch/x86/net/bpf_jit.S
35495@@ -176,7 +180,9 @@ static u8 add_2reg(u8 byte, u32 dst_reg, u32 src_reg)
35496 static void jit_fill_hole(void *area, unsigned int size)
35497 {
35498 /* fill whole space with int3 instructions */
35499+ pax_open_kernel();
35500 memset(area, 0xcc, size);
35501+ pax_close_kernel();
35502 }
35503
35504 struct jit_context {
35505@@ -1026,7 +1032,9 @@ common_load:
35506 pr_err("bpf_jit_compile fatal error\n");
35507 return -EFAULT;
35508 }
35509+ pax_open_kernel();
35510 memcpy(image + proglen, temp, ilen);
35511+ pax_close_kernel();
35512 }
35513 proglen += ilen;
35514 addrs[i] = proglen;
35515@@ -1103,7 +1111,6 @@ void bpf_int_jit_compile(struct bpf_prog *prog)
35516
35517 if (image) {
35518 bpf_flush_icache(header, image + proglen);
35519- set_memory_ro((unsigned long)header, header->pages);
35520 prog->bpf_func = (void *)image;
35521 prog->jited = true;
35522 }
35523@@ -1116,12 +1123,8 @@ void bpf_jit_free(struct bpf_prog *fp)
35524 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
35525 struct bpf_binary_header *header = (void *)addr;
35526
35527- if (!fp->jited)
35528- goto free_filter;
35529+ if (fp->jited)
35530+ bpf_jit_binary_free(header);
35531
35532- set_memory_rw(addr, header->pages);
35533- bpf_jit_binary_free(header);
35534-
35535-free_filter:
35536 bpf_prog_unlock_free(fp);
35537 }
35538diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
35539index 4e664bd..2beeaa2 100644
35540--- a/arch/x86/oprofile/backtrace.c
35541+++ b/arch/x86/oprofile/backtrace.c
35542@@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
35543 struct stack_frame_ia32 *fp;
35544 unsigned long bytes;
35545
35546- bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
35547+ bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
35548 if (bytes != 0)
35549 return NULL;
35550
35551- fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
35552+ fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
35553
35554 oprofile_add_trace(bufhead[0].return_address);
35555
35556@@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
35557 struct stack_frame bufhead[2];
35558 unsigned long bytes;
35559
35560- bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
35561+ bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
35562 if (bytes != 0)
35563 return NULL;
35564
35565diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
35566index 1d2e639..f6ef82a 100644
35567--- a/arch/x86/oprofile/nmi_int.c
35568+++ b/arch/x86/oprofile/nmi_int.c
35569@@ -23,6 +23,7 @@
35570 #include <asm/nmi.h>
35571 #include <asm/msr.h>
35572 #include <asm/apic.h>
35573+#include <asm/pgtable.h>
35574
35575 #include "op_counter.h"
35576 #include "op_x86_model.h"
35577@@ -785,8 +786,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
35578 if (ret)
35579 return ret;
35580
35581- if (!model->num_virt_counters)
35582- model->num_virt_counters = model->num_counters;
35583+ if (!model->num_virt_counters) {
35584+ pax_open_kernel();
35585+ *(unsigned int *)&model->num_virt_counters = model->num_counters;
35586+ pax_close_kernel();
35587+ }
35588
35589 mux_init(ops);
35590
35591diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
35592index 50d86c0..7985318 100644
35593--- a/arch/x86/oprofile/op_model_amd.c
35594+++ b/arch/x86/oprofile/op_model_amd.c
35595@@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
35596 num_counters = AMD64_NUM_COUNTERS;
35597 }
35598
35599- op_amd_spec.num_counters = num_counters;
35600- op_amd_spec.num_controls = num_counters;
35601- op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
35602+ pax_open_kernel();
35603+ *(unsigned int *)&op_amd_spec.num_counters = num_counters;
35604+ *(unsigned int *)&op_amd_spec.num_controls = num_counters;
35605+ *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
35606+ pax_close_kernel();
35607
35608 return 0;
35609 }
35610diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
35611index d90528e..0127e2b 100644
35612--- a/arch/x86/oprofile/op_model_ppro.c
35613+++ b/arch/x86/oprofile/op_model_ppro.c
35614@@ -19,6 +19,7 @@
35615 #include <asm/msr.h>
35616 #include <asm/apic.h>
35617 #include <asm/nmi.h>
35618+#include <asm/pgtable.h>
35619
35620 #include "op_x86_model.h"
35621 #include "op_counter.h"
35622@@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
35623
35624 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
35625
35626- op_arch_perfmon_spec.num_counters = num_counters;
35627- op_arch_perfmon_spec.num_controls = num_counters;
35628+ pax_open_kernel();
35629+ *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
35630+ *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
35631+ pax_close_kernel();
35632 }
35633
35634 static int arch_perfmon_init(struct oprofile_operations *ignore)
35635diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
35636index 71e8a67..6a313bb 100644
35637--- a/arch/x86/oprofile/op_x86_model.h
35638+++ b/arch/x86/oprofile/op_x86_model.h
35639@@ -52,7 +52,7 @@ struct op_x86_model_spec {
35640 void (*switch_ctrl)(struct op_x86_model_spec const *model,
35641 struct op_msrs const * const msrs);
35642 #endif
35643-};
35644+} __do_const;
35645
35646 struct op_counter_config;
35647
35648diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c
35649index 7553921..d631bd4 100644
35650--- a/arch/x86/pci/intel_mid_pci.c
35651+++ b/arch/x86/pci/intel_mid_pci.c
35652@@ -278,7 +278,7 @@ int __init intel_mid_pci_init(void)
35653 pci_mmcfg_late_init();
35654 pcibios_enable_irq = intel_mid_pci_irq_enable;
35655 pcibios_disable_irq = intel_mid_pci_irq_disable;
35656- pci_root_ops = intel_mid_pci_ops;
35657+ memcpy((void *)&pci_root_ops, &intel_mid_pci_ops, sizeof pci_root_ops);
35658 pci_soc_mode = 1;
35659 /* Continue with standard init */
35660 return 1;
35661diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
35662index 9bd1154..e9d4656 100644
35663--- a/arch/x86/pci/irq.c
35664+++ b/arch/x86/pci/irq.c
35665@@ -51,7 +51,7 @@ struct irq_router {
35666 struct irq_router_handler {
35667 u16 vendor;
35668 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
35669-};
35670+} __do_const;
35671
35672 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
35673 void (*pcibios_disable_irq)(struct pci_dev *dev) = pirq_disable_irq;
35674@@ -792,7 +792,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
35675 return 0;
35676 }
35677
35678-static __initdata struct irq_router_handler pirq_routers[] = {
35679+static __initconst const struct irq_router_handler pirq_routers[] = {
35680 { PCI_VENDOR_ID_INTEL, intel_router_probe },
35681 { PCI_VENDOR_ID_AL, ali_router_probe },
35682 { PCI_VENDOR_ID_ITE, ite_router_probe },
35683@@ -819,7 +819,7 @@ static struct pci_dev *pirq_router_dev;
35684 static void __init pirq_find_router(struct irq_router *r)
35685 {
35686 struct irq_routing_table *rt = pirq_table;
35687- struct irq_router_handler *h;
35688+ const struct irq_router_handler *h;
35689
35690 #ifdef CONFIG_PCI_BIOS
35691 if (!rt->signature) {
35692@@ -1092,7 +1092,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
35693 return 0;
35694 }
35695
35696-static struct dmi_system_id __initdata pciirq_dmi_table[] = {
35697+static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
35698 {
35699 .callback = fix_broken_hp_bios_irq9,
35700 .ident = "HP Pavilion N5400 Series Laptop",
35701diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
35702index 9b83b90..2c256c5 100644
35703--- a/arch/x86/pci/pcbios.c
35704+++ b/arch/x86/pci/pcbios.c
35705@@ -79,7 +79,7 @@ union bios32 {
35706 static struct {
35707 unsigned long address;
35708 unsigned short segment;
35709-} bios32_indirect __initdata = { 0, __KERNEL_CS };
35710+} bios32_indirect __initdata = { 0, __PCIBIOS_CS };
35711
35712 /*
35713 * Returns the entry point for the given service, NULL on error
35714@@ -92,37 +92,80 @@ static unsigned long __init bios32_service(unsigned long service)
35715 unsigned long length; /* %ecx */
35716 unsigned long entry; /* %edx */
35717 unsigned long flags;
35718+ struct desc_struct d, *gdt;
35719
35720 local_irq_save(flags);
35721- __asm__("lcall *(%%edi); cld"
35722+
35723+ gdt = get_cpu_gdt_table(smp_processor_id());
35724+
35725+ pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
35726+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
35727+ pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
35728+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
35729+
35730+ __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
35731 : "=a" (return_code),
35732 "=b" (address),
35733 "=c" (length),
35734 "=d" (entry)
35735 : "0" (service),
35736 "1" (0),
35737- "D" (&bios32_indirect));
35738+ "D" (&bios32_indirect),
35739+ "r"(__PCIBIOS_DS)
35740+ : "memory");
35741+
35742+ pax_open_kernel();
35743+ gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
35744+ gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
35745+ gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
35746+ gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
35747+ pax_close_kernel();
35748+
35749 local_irq_restore(flags);
35750
35751 switch (return_code) {
35752- case 0:
35753- return address + entry;
35754- case 0x80: /* Not present */
35755- printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
35756- return 0;
35757- default: /* Shouldn't happen */
35758- printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
35759- service, return_code);
35760+ case 0: {
35761+ int cpu;
35762+ unsigned char flags;
35763+
35764+ printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
35765+ if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
35766+ printk(KERN_WARNING "bios32_service: not valid\n");
35767 return 0;
35768+ }
35769+ address = address + PAGE_OFFSET;
35770+ length += 16UL; /* some BIOSs underreport this... */
35771+ flags = 4;
35772+ if (length >= 64*1024*1024) {
35773+ length >>= PAGE_SHIFT;
35774+ flags |= 8;
35775+ }
35776+
35777+ for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
35778+ gdt = get_cpu_gdt_table(cpu);
35779+ pack_descriptor(&d, address, length, 0x9b, flags);
35780+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
35781+ pack_descriptor(&d, address, length, 0x93, flags);
35782+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
35783+ }
35784+ return entry;
35785+ }
35786+ case 0x80: /* Not present */
35787+ printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
35788+ return 0;
35789+ default: /* Shouldn't happen */
35790+ printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
35791+ service, return_code);
35792+ return 0;
35793 }
35794 }
35795
35796 static struct {
35797 unsigned long address;
35798 unsigned short segment;
35799-} pci_indirect = { 0, __KERNEL_CS };
35800+} pci_indirect __read_only = { 0, __PCIBIOS_CS };
35801
35802-static int pci_bios_present;
35803+static int pci_bios_present __read_only;
35804
35805 static int __init check_pcibios(void)
35806 {
35807@@ -131,11 +174,13 @@ static int __init check_pcibios(void)
35808 unsigned long flags, pcibios_entry;
35809
35810 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
35811- pci_indirect.address = pcibios_entry + PAGE_OFFSET;
35812+ pci_indirect.address = pcibios_entry;
35813
35814 local_irq_save(flags);
35815- __asm__(
35816- "lcall *(%%edi); cld\n\t"
35817+ __asm__("movw %w6, %%ds\n\t"
35818+ "lcall *%%ss:(%%edi); cld\n\t"
35819+ "push %%ss\n\t"
35820+ "pop %%ds\n\t"
35821 "jc 1f\n\t"
35822 "xor %%ah, %%ah\n"
35823 "1:"
35824@@ -144,7 +189,8 @@ static int __init check_pcibios(void)
35825 "=b" (ebx),
35826 "=c" (ecx)
35827 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
35828- "D" (&pci_indirect)
35829+ "D" (&pci_indirect),
35830+ "r" (__PCIBIOS_DS)
35831 : "memory");
35832 local_irq_restore(flags);
35833
35834@@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35835
35836 switch (len) {
35837 case 1:
35838- __asm__("lcall *(%%esi); cld\n\t"
35839+ __asm__("movw %w6, %%ds\n\t"
35840+ "lcall *%%ss:(%%esi); cld\n\t"
35841+ "push %%ss\n\t"
35842+ "pop %%ds\n\t"
35843 "jc 1f\n\t"
35844 "xor %%ah, %%ah\n"
35845 "1:"
35846@@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35847 : "1" (PCIBIOS_READ_CONFIG_BYTE),
35848 "b" (bx),
35849 "D" ((long)reg),
35850- "S" (&pci_indirect));
35851+ "S" (&pci_indirect),
35852+ "r" (__PCIBIOS_DS));
35853 /*
35854 * Zero-extend the result beyond 8 bits, do not trust the
35855 * BIOS having done it:
35856@@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35857 *value &= 0xff;
35858 break;
35859 case 2:
35860- __asm__("lcall *(%%esi); cld\n\t"
35861+ __asm__("movw %w6, %%ds\n\t"
35862+ "lcall *%%ss:(%%esi); cld\n\t"
35863+ "push %%ss\n\t"
35864+ "pop %%ds\n\t"
35865 "jc 1f\n\t"
35866 "xor %%ah, %%ah\n"
35867 "1:"
35868@@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35869 : "1" (PCIBIOS_READ_CONFIG_WORD),
35870 "b" (bx),
35871 "D" ((long)reg),
35872- "S" (&pci_indirect));
35873+ "S" (&pci_indirect),
35874+ "r" (__PCIBIOS_DS));
35875 /*
35876 * Zero-extend the result beyond 16 bits, do not trust the
35877 * BIOS having done it:
35878@@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35879 *value &= 0xffff;
35880 break;
35881 case 4:
35882- __asm__("lcall *(%%esi); cld\n\t"
35883+ __asm__("movw %w6, %%ds\n\t"
35884+ "lcall *%%ss:(%%esi); cld\n\t"
35885+ "push %%ss\n\t"
35886+ "pop %%ds\n\t"
35887 "jc 1f\n\t"
35888 "xor %%ah, %%ah\n"
35889 "1:"
35890@@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35891 : "1" (PCIBIOS_READ_CONFIG_DWORD),
35892 "b" (bx),
35893 "D" ((long)reg),
35894- "S" (&pci_indirect));
35895+ "S" (&pci_indirect),
35896+ "r" (__PCIBIOS_DS));
35897 break;
35898 }
35899
35900@@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35901
35902 switch (len) {
35903 case 1:
35904- __asm__("lcall *(%%esi); cld\n\t"
35905+ __asm__("movw %w6, %%ds\n\t"
35906+ "lcall *%%ss:(%%esi); cld\n\t"
35907+ "push %%ss\n\t"
35908+ "pop %%ds\n\t"
35909 "jc 1f\n\t"
35910 "xor %%ah, %%ah\n"
35911 "1:"
35912@@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35913 "c" (value),
35914 "b" (bx),
35915 "D" ((long)reg),
35916- "S" (&pci_indirect));
35917+ "S" (&pci_indirect),
35918+ "r" (__PCIBIOS_DS));
35919 break;
35920 case 2:
35921- __asm__("lcall *(%%esi); cld\n\t"
35922+ __asm__("movw %w6, %%ds\n\t"
35923+ "lcall *%%ss:(%%esi); cld\n\t"
35924+ "push %%ss\n\t"
35925+ "pop %%ds\n\t"
35926 "jc 1f\n\t"
35927 "xor %%ah, %%ah\n"
35928 "1:"
35929@@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35930 "c" (value),
35931 "b" (bx),
35932 "D" ((long)reg),
35933- "S" (&pci_indirect));
35934+ "S" (&pci_indirect),
35935+ "r" (__PCIBIOS_DS));
35936 break;
35937 case 4:
35938- __asm__("lcall *(%%esi); cld\n\t"
35939+ __asm__("movw %w6, %%ds\n\t"
35940+ "lcall *%%ss:(%%esi); cld\n\t"
35941+ "push %%ss\n\t"
35942+ "pop %%ds\n\t"
35943 "jc 1f\n\t"
35944 "xor %%ah, %%ah\n"
35945 "1:"
35946@@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35947 "c" (value),
35948 "b" (bx),
35949 "D" ((long)reg),
35950- "S" (&pci_indirect));
35951+ "S" (&pci_indirect),
35952+ "r" (__PCIBIOS_DS));
35953 break;
35954 }
35955
35956@@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
35957
35958 DBG("PCI: Fetching IRQ routing table... ");
35959 __asm__("push %%es\n\t"
35960+ "movw %w8, %%ds\n\t"
35961 "push %%ds\n\t"
35962 "pop %%es\n\t"
35963- "lcall *(%%esi); cld\n\t"
35964+ "lcall *%%ss:(%%esi); cld\n\t"
35965 "pop %%es\n\t"
35966+ "push %%ss\n\t"
35967+ "pop %%ds\n"
35968 "jc 1f\n\t"
35969 "xor %%ah, %%ah\n"
35970 "1:"
35971@@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
35972 "1" (0),
35973 "D" ((long) &opt),
35974 "S" (&pci_indirect),
35975- "m" (opt)
35976+ "m" (opt),
35977+ "r" (__PCIBIOS_DS)
35978 : "memory");
35979 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
35980 if (ret & 0xff00)
35981@@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
35982 {
35983 int ret;
35984
35985- __asm__("lcall *(%%esi); cld\n\t"
35986+ __asm__("movw %w5, %%ds\n\t"
35987+ "lcall *%%ss:(%%esi); cld\n\t"
35988+ "push %%ss\n\t"
35989+ "pop %%ds\n"
35990 "jc 1f\n\t"
35991 "xor %%ah, %%ah\n"
35992 "1:"
35993@@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
35994 : "0" (PCIBIOS_SET_PCI_HW_INT),
35995 "b" ((dev->bus->number << 8) | dev->devfn),
35996 "c" ((irq << 8) | (pin + 10)),
35997- "S" (&pci_indirect));
35998+ "S" (&pci_indirect),
35999+ "r" (__PCIBIOS_DS));
36000 return !(ret & 0xff00);
36001 }
36002 EXPORT_SYMBOL(pcibios_set_irq_routing);
36003diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
36004index ed5b673..24d2d53 100644
36005--- a/arch/x86/platform/efi/efi_32.c
36006+++ b/arch/x86/platform/efi/efi_32.c
36007@@ -61,11 +61,27 @@ pgd_t * __init efi_call_phys_prolog(void)
36008 struct desc_ptr gdt_descr;
36009 pgd_t *save_pgd;
36010
36011+#ifdef CONFIG_PAX_KERNEXEC
36012+ struct desc_struct d;
36013+#endif
36014+
36015 /* Current pgd is swapper_pg_dir, we'll restore it later: */
36016+#ifdef CONFIG_PAX_PER_CPU_PGD
36017+ save_pgd = get_cpu_pgd(smp_processor_id(), kernel);
36018+#else
36019 save_pgd = swapper_pg_dir;
36020+#endif
36021+
36022 load_cr3(initial_page_table);
36023 __flush_tlb_all();
36024
36025+#ifdef CONFIG_PAX_KERNEXEC
36026+ pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
36027+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
36028+ pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
36029+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
36030+#endif
36031+
36032 gdt_descr.address = __pa(get_cpu_gdt_table(0));
36033 gdt_descr.size = GDT_SIZE - 1;
36034 load_gdt(&gdt_descr);
36035@@ -77,6 +93,14 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
36036 {
36037 struct desc_ptr gdt_descr;
36038
36039+#ifdef CONFIG_PAX_KERNEXEC
36040+ struct desc_struct d;
36041+
36042+ memset(&d, 0, sizeof d);
36043+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
36044+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
36045+#endif
36046+
36047 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
36048 gdt_descr.size = GDT_SIZE - 1;
36049 load_gdt(&gdt_descr);
36050diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
36051index a0ac0f9..f41d324 100644
36052--- a/arch/x86/platform/efi/efi_64.c
36053+++ b/arch/x86/platform/efi/efi_64.c
36054@@ -96,6 +96,11 @@ pgd_t * __init efi_call_phys_prolog(void)
36055 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
36056 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
36057 }
36058+
36059+#ifdef CONFIG_PAX_PER_CPU_PGD
36060+ load_cr3(swapper_pg_dir);
36061+#endif
36062+
36063 __flush_tlb_all();
36064
36065 return save_pgd;
36066@@ -119,6 +124,10 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
36067
36068 kfree(save_pgd);
36069
36070+#ifdef CONFIG_PAX_PER_CPU_PGD
36071+ load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
36072+#endif
36073+
36074 __flush_tlb_all();
36075 early_code_mapping_set_exec(0);
36076 }
36077@@ -148,8 +157,23 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
36078 unsigned npages;
36079 pgd_t *pgd;
36080
36081- if (efi_enabled(EFI_OLD_MEMMAP))
36082+ if (efi_enabled(EFI_OLD_MEMMAP)) {
36083+ /* PaX: We need to disable the NX bit in the PGD, otherwise we won't be
36084+ * able to execute the EFI services.
36085+ */
36086+ if (__supported_pte_mask & _PAGE_NX) {
36087+ unsigned long addr = (unsigned long) __va(0);
36088+ pgd_t pe = __pgd(pgd_val(*pgd_offset_k(addr)) & ~_PAGE_NX);
36089+
36090+ pr_alert("PAX: Disabling NX protection for low memory map. Try booting without \"efi=old_map\"\n");
36091+#ifdef CONFIG_PAX_PER_CPU_PGD
36092+ set_pgd(pgd_offset_cpu(0, kernel, addr), pe);
36093+#endif
36094+ set_pgd(pgd_offset_k(addr), pe);
36095+ }
36096+
36097 return 0;
36098+ }
36099
36100 efi_scratch.efi_pgt = (pgd_t *)(unsigned long)real_mode_header->trampoline_pgd;
36101 pgd = __va(efi_scratch.efi_pgt);
36102diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
36103index 040192b..7d3300f 100644
36104--- a/arch/x86/platform/efi/efi_stub_32.S
36105+++ b/arch/x86/platform/efi/efi_stub_32.S
36106@@ -6,7 +6,9 @@
36107 */
36108
36109 #include <linux/linkage.h>
36110+#include <linux/init.h>
36111 #include <asm/page_types.h>
36112+#include <asm/segment.h>
36113
36114 /*
36115 * efi_call_phys(void *, ...) is a function with variable parameters.
36116@@ -20,7 +22,7 @@
36117 * service functions will comply with gcc calling convention, too.
36118 */
36119
36120-.text
36121+__INIT
36122 ENTRY(efi_call_phys)
36123 /*
36124 * 0. The function can only be called in Linux kernel. So CS has been
36125@@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
36126 * The mapping of lower virtual memory has been created in prolog and
36127 * epilog.
36128 */
36129- movl $1f, %edx
36130- subl $__PAGE_OFFSET, %edx
36131- jmp *%edx
36132+#ifdef CONFIG_PAX_KERNEXEC
36133+ movl $(__KERNEXEC_EFI_DS), %edx
36134+ mov %edx, %ds
36135+ mov %edx, %es
36136+ mov %edx, %ss
36137+ addl $2f,(1f)
36138+ ljmp *(1f)
36139+
36140+__INITDATA
36141+1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
36142+.previous
36143+
36144+2:
36145+ subl $2b,(1b)
36146+#else
36147+ jmp 1f-__PAGE_OFFSET
36148 1:
36149+#endif
36150
36151 /*
36152 * 2. Now on the top of stack is the return
36153@@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
36154 * parameter 2, ..., param n. To make things easy, we save the return
36155 * address of efi_call_phys in a global variable.
36156 */
36157- popl %edx
36158- movl %edx, saved_return_addr
36159- /* get the function pointer into ECX*/
36160- popl %ecx
36161- movl %ecx, efi_rt_function_ptr
36162- movl $2f, %edx
36163- subl $__PAGE_OFFSET, %edx
36164- pushl %edx
36165+ popl (saved_return_addr)
36166+ popl (efi_rt_function_ptr)
36167
36168 /*
36169 * 3. Clear PG bit in %CR0.
36170@@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
36171 /*
36172 * 5. Call the physical function.
36173 */
36174- jmp *%ecx
36175+ call *(efi_rt_function_ptr-__PAGE_OFFSET)
36176
36177-2:
36178 /*
36179 * 6. After EFI runtime service returns, control will return to
36180 * following instruction. We'd better readjust stack pointer first.
36181@@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
36182 movl %cr0, %edx
36183 orl $0x80000000, %edx
36184 movl %edx, %cr0
36185- jmp 1f
36186-1:
36187+
36188 /*
36189 * 8. Now restore the virtual mode from flat mode by
36190 * adding EIP with PAGE_OFFSET.
36191 */
36192- movl $1f, %edx
36193- jmp *%edx
36194+#ifdef CONFIG_PAX_KERNEXEC
36195+ movl $(__KERNEL_DS), %edx
36196+ mov %edx, %ds
36197+ mov %edx, %es
36198+ mov %edx, %ss
36199+ ljmp $(__KERNEL_CS),$1f
36200+#else
36201+ jmp 1f+__PAGE_OFFSET
36202+#endif
36203 1:
36204
36205 /*
36206 * 9. Balance the stack. And because EAX contain the return value,
36207 * we'd better not clobber it.
36208 */
36209- leal efi_rt_function_ptr, %edx
36210- movl (%edx), %ecx
36211- pushl %ecx
36212+ pushl (efi_rt_function_ptr)
36213
36214 /*
36215- * 10. Push the saved return address onto the stack and return.
36216+ * 10. Return to the saved return address.
36217 */
36218- leal saved_return_addr, %edx
36219- movl (%edx), %ecx
36220- pushl %ecx
36221- ret
36222+ jmpl *(saved_return_addr)
36223 ENDPROC(efi_call_phys)
36224 .previous
36225
36226-.data
36227+__INITDATA
36228 saved_return_addr:
36229 .long 0
36230 efi_rt_function_ptr:
36231diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
36232index 86d0f9e..6d499f4 100644
36233--- a/arch/x86/platform/efi/efi_stub_64.S
36234+++ b/arch/x86/platform/efi/efi_stub_64.S
36235@@ -11,6 +11,7 @@
36236 #include <asm/msr.h>
36237 #include <asm/processor-flags.h>
36238 #include <asm/page_types.h>
36239+#include <asm/alternative-asm.h>
36240
36241 #define SAVE_XMM \
36242 mov %rsp, %rax; \
36243@@ -88,6 +89,7 @@ ENTRY(efi_call)
36244 RESTORE_PGT
36245 addq $48, %rsp
36246 RESTORE_XMM
36247+ pax_force_retaddr 0, 1
36248 ret
36249 ENDPROC(efi_call)
36250
36251diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c
36252index 01d54ea..ba1d71c 100644
36253--- a/arch/x86/platform/intel-mid/intel-mid.c
36254+++ b/arch/x86/platform/intel-mid/intel-mid.c
36255@@ -63,7 +63,7 @@ enum intel_mid_timer_options intel_mid_timer_options;
36256 /* intel_mid_ops to store sub arch ops */
36257 struct intel_mid_ops *intel_mid_ops;
36258 /* getter function for sub arch ops*/
36259-static void *(*get_intel_mid_ops[])(void) = INTEL_MID_OPS_INIT;
36260+static const void *(*get_intel_mid_ops[])(void) = INTEL_MID_OPS_INIT;
36261 enum intel_mid_cpu_type __intel_mid_cpu_chip;
36262 EXPORT_SYMBOL_GPL(__intel_mid_cpu_chip);
36263
36264@@ -71,9 +71,10 @@ static void intel_mid_power_off(void)
36265 {
36266 };
36267
36268-static void intel_mid_reboot(void)
36269+static void __noreturn intel_mid_reboot(void)
36270 {
36271 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
36272+ BUG();
36273 }
36274
36275 static unsigned long __init intel_mid_calibrate_tsc(void)
36276diff --git a/arch/x86/platform/intel-mid/intel_mid_weak_decls.h b/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
36277index 3c1c386..59a68ed 100644
36278--- a/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
36279+++ b/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
36280@@ -13,6 +13,6 @@
36281 /* For every CPU addition a new get_<cpuname>_ops interface needs
36282 * to be added.
36283 */
36284-extern void *get_penwell_ops(void);
36285-extern void *get_cloverview_ops(void);
36286-extern void *get_tangier_ops(void);
36287+extern const void *get_penwell_ops(void);
36288+extern const void *get_cloverview_ops(void);
36289+extern const void *get_tangier_ops(void);
36290diff --git a/arch/x86/platform/intel-mid/mfld.c b/arch/x86/platform/intel-mid/mfld.c
36291index 23381d2..8ddc10e 100644
36292--- a/arch/x86/platform/intel-mid/mfld.c
36293+++ b/arch/x86/platform/intel-mid/mfld.c
36294@@ -64,12 +64,12 @@ static void __init penwell_arch_setup(void)
36295 pm_power_off = mfld_power_off;
36296 }
36297
36298-void *get_penwell_ops(void)
36299+const void *get_penwell_ops(void)
36300 {
36301 return &penwell_ops;
36302 }
36303
36304-void *get_cloverview_ops(void)
36305+const void *get_cloverview_ops(void)
36306 {
36307 return &penwell_ops;
36308 }
36309diff --git a/arch/x86/platform/intel-mid/mrfl.c b/arch/x86/platform/intel-mid/mrfl.c
36310index aaca917..66eadbc 100644
36311--- a/arch/x86/platform/intel-mid/mrfl.c
36312+++ b/arch/x86/platform/intel-mid/mrfl.c
36313@@ -97,7 +97,7 @@ static struct intel_mid_ops tangier_ops = {
36314 .arch_setup = tangier_arch_setup,
36315 };
36316
36317-void *get_tangier_ops(void)
36318+const void *get_tangier_ops(void)
36319 {
36320 return &tangier_ops;
36321 }
36322diff --git a/arch/x86/platform/intel-quark/imr_selftest.c b/arch/x86/platform/intel-quark/imr_selftest.c
36323index 278e4da..35db1a9 100644
36324--- a/arch/x86/platform/intel-quark/imr_selftest.c
36325+++ b/arch/x86/platform/intel-quark/imr_selftest.c
36326@@ -55,7 +55,7 @@ static void __init imr_self_test_result(int res, const char *fmt, ...)
36327 */
36328 static void __init imr_self_test(void)
36329 {
36330- phys_addr_t base = virt_to_phys(&_text);
36331+ phys_addr_t base = virt_to_phys((void *)ktla_ktva((unsigned long)_text));
36332 size_t size = virt_to_phys(&__end_rodata) - base;
36333 const char *fmt_over = "overlapped IMR @ (0x%08lx - 0x%08lx)\n";
36334 int ret;
36335diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
36336index d6ee929..3637cb5 100644
36337--- a/arch/x86/platform/olpc/olpc_dt.c
36338+++ b/arch/x86/platform/olpc/olpc_dt.c
36339@@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
36340 return res;
36341 }
36342
36343-static struct of_pdt_ops prom_olpc_ops __initdata = {
36344+static struct of_pdt_ops prom_olpc_ops __initconst = {
36345 .nextprop = olpc_dt_nextprop,
36346 .getproplen = olpc_dt_getproplen,
36347 .getproperty = olpc_dt_getproperty,
36348diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
36349index 9ab5279..8ba4611 100644
36350--- a/arch/x86/power/cpu.c
36351+++ b/arch/x86/power/cpu.c
36352@@ -134,11 +134,8 @@ static void do_fpu_end(void)
36353 static void fix_processor_context(void)
36354 {
36355 int cpu = smp_processor_id();
36356- struct tss_struct *t = &per_cpu(cpu_tss, cpu);
36357-#ifdef CONFIG_X86_64
36358- struct desc_struct *desc = get_cpu_gdt_table(cpu);
36359- tss_desc tss;
36360-#endif
36361+ struct tss_struct *t = cpu_tss + cpu;
36362+
36363 set_tss_desc(cpu, t); /*
36364 * This just modifies memory; should not be
36365 * necessary. But... This is necessary, because
36366@@ -147,10 +144,6 @@ static void fix_processor_context(void)
36367 */
36368
36369 #ifdef CONFIG_X86_64
36370- memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
36371- tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
36372- write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
36373-
36374 syscall_init(); /* This sets MSR_*STAR and related */
36375 #endif
36376 load_TR_desc(); /* This does ltr */
36377diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
36378index 0b7a63d..dff2199 100644
36379--- a/arch/x86/realmode/init.c
36380+++ b/arch/x86/realmode/init.c
36381@@ -68,7 +68,13 @@ void __init setup_real_mode(void)
36382 __va(real_mode_header->trampoline_header);
36383
36384 #ifdef CONFIG_X86_32
36385- trampoline_header->start = __pa_symbol(startup_32_smp);
36386+ trampoline_header->start = __pa_symbol(ktla_ktva((unsigned long)startup_32_smp));
36387+
36388+#ifdef CONFIG_PAX_KERNEXEC
36389+ trampoline_header->start -= LOAD_PHYSICAL_ADDR;
36390+#endif
36391+
36392+ trampoline_header->boot_cs = __BOOT_CS;
36393 trampoline_header->gdt_limit = __BOOT_DS + 7;
36394 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
36395 #else
36396@@ -84,7 +90,7 @@ void __init setup_real_mode(void)
36397 *trampoline_cr4_features = __read_cr4();
36398
36399 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
36400- trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
36401+ trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
36402 trampoline_pgd[511] = init_level4_pgt[511].pgd;
36403 #endif
36404 }
36405diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
36406index 2730d77..2e4cd19 100644
36407--- a/arch/x86/realmode/rm/Makefile
36408+++ b/arch/x86/realmode/rm/Makefile
36409@@ -68,5 +68,8 @@ $(obj)/realmode.relocs: $(obj)/realmode.elf FORCE
36410
36411 KBUILD_CFLAGS := $(LINUXINCLUDE) $(REALMODE_CFLAGS) -D_SETUP -D_WAKEUP \
36412 -I$(srctree)/arch/x86/boot
36413+ifdef CONSTIFY_PLUGIN
36414+KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
36415+endif
36416 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
36417 GCOV_PROFILE := n
36418diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
36419index a28221d..93c40f1 100644
36420--- a/arch/x86/realmode/rm/header.S
36421+++ b/arch/x86/realmode/rm/header.S
36422@@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
36423 #endif
36424 /* APM/BIOS reboot */
36425 .long pa_machine_real_restart_asm
36426-#ifdef CONFIG_X86_64
36427+#ifdef CONFIG_X86_32
36428+ .long __KERNEL_CS
36429+#else
36430 .long __KERNEL32_CS
36431 #endif
36432 END(real_mode_header)
36433diff --git a/arch/x86/realmode/rm/reboot.S b/arch/x86/realmode/rm/reboot.S
36434index d66c607..3def845 100644
36435--- a/arch/x86/realmode/rm/reboot.S
36436+++ b/arch/x86/realmode/rm/reboot.S
36437@@ -27,6 +27,10 @@ ENTRY(machine_real_restart_asm)
36438 lgdtl pa_tr_gdt
36439
36440 /* Disable paging to drop us out of long mode */
36441+ movl %cr4, %eax
36442+ andl $~X86_CR4_PCIDE, %eax
36443+ movl %eax, %cr4
36444+
36445 movl %cr0, %eax
36446 andl $~X86_CR0_PG, %eax
36447 movl %eax, %cr0
36448diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
36449index 48ddd76..c26749f 100644
36450--- a/arch/x86/realmode/rm/trampoline_32.S
36451+++ b/arch/x86/realmode/rm/trampoline_32.S
36452@@ -24,6 +24,12 @@
36453 #include <asm/page_types.h>
36454 #include "realmode.h"
36455
36456+#ifdef CONFIG_PAX_KERNEXEC
36457+#define ta(X) (X)
36458+#else
36459+#define ta(X) (pa_ ## X)
36460+#endif
36461+
36462 .text
36463 .code16
36464
36465@@ -38,8 +44,6 @@ ENTRY(trampoline_start)
36466
36467 cli # We should be safe anyway
36468
36469- movl tr_start, %eax # where we need to go
36470-
36471 movl $0xA5A5A5A5, trampoline_status
36472 # write marker for master knows we're running
36473
36474@@ -55,7 +59,7 @@ ENTRY(trampoline_start)
36475 movw $1, %dx # protected mode (PE) bit
36476 lmsw %dx # into protected mode
36477
36478- ljmpl $__BOOT_CS, $pa_startup_32
36479+ ljmpl *(trampoline_header)
36480
36481 .section ".text32","ax"
36482 .code32
36483@@ -66,7 +70,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
36484 .balign 8
36485 GLOBAL(trampoline_header)
36486 tr_start: .space 4
36487- tr_gdt_pad: .space 2
36488+ tr_boot_cs: .space 2
36489 tr_gdt: .space 6
36490 END(trampoline_header)
36491
36492diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
36493index dac7b20..72dbaca 100644
36494--- a/arch/x86/realmode/rm/trampoline_64.S
36495+++ b/arch/x86/realmode/rm/trampoline_64.S
36496@@ -93,6 +93,7 @@ ENTRY(startup_32)
36497 movl %edx, %gs
36498
36499 movl pa_tr_cr4, %eax
36500+ andl $~X86_CR4_PCIDE, %eax
36501 movl %eax, %cr4 # Enable PAE mode
36502
36503 # Setup trampoline 4 level pagetables
36504@@ -106,7 +107,7 @@ ENTRY(startup_32)
36505 wrmsr
36506
36507 # Enable paging and in turn activate Long Mode
36508- movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
36509+ movl $(X86_CR0_PG | X86_CR0_PE), %eax
36510 movl %eax, %cr0
36511
36512 /*
36513diff --git a/arch/x86/realmode/rm/wakeup_asm.S b/arch/x86/realmode/rm/wakeup_asm.S
36514index 9e7e147..25a4158 100644
36515--- a/arch/x86/realmode/rm/wakeup_asm.S
36516+++ b/arch/x86/realmode/rm/wakeup_asm.S
36517@@ -126,11 +126,10 @@ ENTRY(wakeup_start)
36518 lgdtl pmode_gdt
36519
36520 /* This really couldn't... */
36521- movl pmode_entry, %eax
36522 movl pmode_cr0, %ecx
36523 movl %ecx, %cr0
36524- ljmpl $__KERNEL_CS, $pa_startup_32
36525- /* -> jmp *%eax in trampoline_32.S */
36526+
36527+ ljmpl *pmode_entry
36528 #else
36529 jmp trampoline_start
36530 #endif
36531diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
36532index 604a37e..e49702a 100644
36533--- a/arch/x86/tools/Makefile
36534+++ b/arch/x86/tools/Makefile
36535@@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
36536
36537 $(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
36538
36539-HOST_EXTRACFLAGS += -I$(srctree)/tools/include
36540+HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
36541 hostprogs-y += relocs
36542 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
36543 PHONY += relocs
36544diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
36545index 0c2fae8..88d7719 100644
36546--- a/arch/x86/tools/relocs.c
36547+++ b/arch/x86/tools/relocs.c
36548@@ -1,5 +1,7 @@
36549 /* This is included from relocs_32/64.c */
36550
36551+#include "../../../include/generated/autoconf.h"
36552+
36553 #define ElfW(type) _ElfW(ELF_BITS, type)
36554 #define _ElfW(bits, type) __ElfW(bits, type)
36555 #define __ElfW(bits, type) Elf##bits##_##type
36556@@ -11,6 +13,7 @@
36557 #define Elf_Sym ElfW(Sym)
36558
36559 static Elf_Ehdr ehdr;
36560+static Elf_Phdr *phdr;
36561
36562 struct relocs {
36563 uint32_t *offset;
36564@@ -386,9 +389,39 @@ static void read_ehdr(FILE *fp)
36565 }
36566 }
36567
36568+static void read_phdrs(FILE *fp)
36569+{
36570+ unsigned int i;
36571+
36572+ phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
36573+ if (!phdr) {
36574+ die("Unable to allocate %d program headers\n",
36575+ ehdr.e_phnum);
36576+ }
36577+ if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
36578+ die("Seek to %d failed: %s\n",
36579+ ehdr.e_phoff, strerror(errno));
36580+ }
36581+ if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
36582+ die("Cannot read ELF program headers: %s\n",
36583+ strerror(errno));
36584+ }
36585+ for(i = 0; i < ehdr.e_phnum; i++) {
36586+ phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
36587+ phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
36588+ phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
36589+ phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
36590+ phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
36591+ phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
36592+ phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
36593+ phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
36594+ }
36595+
36596+}
36597+
36598 static void read_shdrs(FILE *fp)
36599 {
36600- int i;
36601+ unsigned int i;
36602 Elf_Shdr shdr;
36603
36604 secs = calloc(ehdr.e_shnum, sizeof(struct section));
36605@@ -423,7 +456,7 @@ static void read_shdrs(FILE *fp)
36606
36607 static void read_strtabs(FILE *fp)
36608 {
36609- int i;
36610+ unsigned int i;
36611 for (i = 0; i < ehdr.e_shnum; i++) {
36612 struct section *sec = &secs[i];
36613 if (sec->shdr.sh_type != SHT_STRTAB) {
36614@@ -448,7 +481,7 @@ static void read_strtabs(FILE *fp)
36615
36616 static void read_symtabs(FILE *fp)
36617 {
36618- int i,j;
36619+ unsigned int i,j;
36620 for (i = 0; i < ehdr.e_shnum; i++) {
36621 struct section *sec = &secs[i];
36622 if (sec->shdr.sh_type != SHT_SYMTAB) {
36623@@ -479,9 +512,11 @@ static void read_symtabs(FILE *fp)
36624 }
36625
36626
36627-static void read_relocs(FILE *fp)
36628+static void read_relocs(FILE *fp, int use_real_mode)
36629 {
36630- int i,j;
36631+ unsigned int i,j;
36632+ uint32_t base;
36633+
36634 for (i = 0; i < ehdr.e_shnum; i++) {
36635 struct section *sec = &secs[i];
36636 if (sec->shdr.sh_type != SHT_REL_TYPE) {
36637@@ -501,9 +536,22 @@ static void read_relocs(FILE *fp)
36638 die("Cannot read symbol table: %s\n",
36639 strerror(errno));
36640 }
36641+ base = 0;
36642+
36643+#ifdef CONFIG_X86_32
36644+ for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
36645+ if (phdr[j].p_type != PT_LOAD )
36646+ continue;
36647+ 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)
36648+ continue;
36649+ base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
36650+ break;
36651+ }
36652+#endif
36653+
36654 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
36655 Elf_Rel *rel = &sec->reltab[j];
36656- rel->r_offset = elf_addr_to_cpu(rel->r_offset);
36657+ rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
36658 rel->r_info = elf_xword_to_cpu(rel->r_info);
36659 #if (SHT_REL_TYPE == SHT_RELA)
36660 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
36661@@ -515,7 +563,7 @@ static void read_relocs(FILE *fp)
36662
36663 static void print_absolute_symbols(void)
36664 {
36665- int i;
36666+ unsigned int i;
36667 const char *format;
36668
36669 if (ELF_BITS == 64)
36670@@ -528,7 +576,7 @@ static void print_absolute_symbols(void)
36671 for (i = 0; i < ehdr.e_shnum; i++) {
36672 struct section *sec = &secs[i];
36673 char *sym_strtab;
36674- int j;
36675+ unsigned int j;
36676
36677 if (sec->shdr.sh_type != SHT_SYMTAB) {
36678 continue;
36679@@ -555,7 +603,7 @@ static void print_absolute_symbols(void)
36680
36681 static void print_absolute_relocs(void)
36682 {
36683- int i, printed = 0;
36684+ unsigned int i, printed = 0;
36685 const char *format;
36686
36687 if (ELF_BITS == 64)
36688@@ -568,7 +616,7 @@ static void print_absolute_relocs(void)
36689 struct section *sec_applies, *sec_symtab;
36690 char *sym_strtab;
36691 Elf_Sym *sh_symtab;
36692- int j;
36693+ unsigned int j;
36694 if (sec->shdr.sh_type != SHT_REL_TYPE) {
36695 continue;
36696 }
36697@@ -645,13 +693,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
36698 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
36699 Elf_Sym *sym, const char *symname))
36700 {
36701- int i;
36702+ unsigned int i;
36703 /* Walk through the relocations */
36704 for (i = 0; i < ehdr.e_shnum; i++) {
36705 char *sym_strtab;
36706 Elf_Sym *sh_symtab;
36707 struct section *sec_applies, *sec_symtab;
36708- int j;
36709+ unsigned int j;
36710 struct section *sec = &secs[i];
36711
36712 if (sec->shdr.sh_type != SHT_REL_TYPE) {
36713@@ -697,7 +745,7 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
36714 * kernel data and does not require special treatment.
36715 *
36716 */
36717-static int per_cpu_shndx = -1;
36718+static unsigned int per_cpu_shndx = ~0;
36719 static Elf_Addr per_cpu_load_addr;
36720
36721 static void percpu_init(void)
36722@@ -830,6 +878,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
36723 {
36724 unsigned r_type = ELF32_R_TYPE(rel->r_info);
36725 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
36726+ char *sym_strtab = sec->link->link->strtab;
36727+
36728+ /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
36729+ if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
36730+ return 0;
36731+
36732+#ifdef CONFIG_PAX_KERNEXEC
36733+ /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
36734+ if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
36735+ return 0;
36736+ if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
36737+ return 0;
36738+ if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
36739+ return 0;
36740+ if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
36741+ return 0;
36742+#endif
36743
36744 switch (r_type) {
36745 case R_386_NONE:
36746@@ -968,7 +1033,7 @@ static int write32_as_text(uint32_t v, FILE *f)
36747
36748 static void emit_relocs(int as_text, int use_real_mode)
36749 {
36750- int i;
36751+ unsigned int i;
36752 int (*write_reloc)(uint32_t, FILE *) = write32;
36753 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
36754 const char *symname);
36755@@ -1078,10 +1143,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
36756 {
36757 regex_init(use_real_mode);
36758 read_ehdr(fp);
36759+ read_phdrs(fp);
36760 read_shdrs(fp);
36761 read_strtabs(fp);
36762 read_symtabs(fp);
36763- read_relocs(fp);
36764+ read_relocs(fp, use_real_mode);
36765 if (ELF_BITS == 64)
36766 percpu_init();
36767 if (show_absolute_syms) {
36768diff --git a/arch/x86/um/mem_32.c b/arch/x86/um/mem_32.c
36769index 744afdc..a0b8a0d 100644
36770--- a/arch/x86/um/mem_32.c
36771+++ b/arch/x86/um/mem_32.c
36772@@ -20,7 +20,7 @@ static int __init gate_vma_init(void)
36773 gate_vma.vm_start = FIXADDR_USER_START;
36774 gate_vma.vm_end = FIXADDR_USER_END;
36775 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
36776- gate_vma.vm_page_prot = __P101;
36777+ gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
36778
36779 return 0;
36780 }
36781diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
36782index 48e3858..ab4458c 100644
36783--- a/arch/x86/um/tls_32.c
36784+++ b/arch/x86/um/tls_32.c
36785@@ -261,7 +261,7 @@ out:
36786 if (unlikely(task == current &&
36787 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
36788 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
36789- "without flushed TLS.", current->pid);
36790+ "without flushed TLS.", task_pid_nr(current));
36791 }
36792
36793 return 0;
36794diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
36795index 4841453..d59a203 100644
36796--- a/arch/x86/xen/Kconfig
36797+++ b/arch/x86/xen/Kconfig
36798@@ -9,6 +9,7 @@ config XEN
36799 select XEN_HAVE_PVMMU
36800 depends on X86_64 || (X86_32 && X86_PAE)
36801 depends on X86_LOCAL_APIC && X86_TSC
36802+ depends on !GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_VIRT_XEN
36803 help
36804 This is the Linux Xen port. Enabling this will allow the
36805 kernel to boot in a paravirtualized environment under the
36806diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
36807index 777ad2f..fa43e03 100644
36808--- a/arch/x86/xen/enlighten.c
36809+++ b/arch/x86/xen/enlighten.c
36810@@ -129,8 +129,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
36811
36812 struct shared_info xen_dummy_shared_info;
36813
36814-void *xen_initial_gdt;
36815-
36816 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
36817 __read_mostly int xen_have_vector_callback;
36818 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
36819@@ -588,8 +586,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
36820 {
36821 unsigned long va = dtr->address;
36822 unsigned int size = dtr->size + 1;
36823- unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
36824- unsigned long frames[pages];
36825+ unsigned long frames[65536 / PAGE_SIZE];
36826 int f;
36827
36828 /*
36829@@ -637,8 +634,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
36830 {
36831 unsigned long va = dtr->address;
36832 unsigned int size = dtr->size + 1;
36833- unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
36834- unsigned long frames[pages];
36835+ unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
36836 int f;
36837
36838 /*
36839@@ -646,7 +642,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
36840 * 8-byte entries, or 16 4k pages..
36841 */
36842
36843- BUG_ON(size > 65536);
36844+ BUG_ON(size > GDT_SIZE);
36845 BUG_ON(va & ~PAGE_MASK);
36846
36847 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
36848@@ -1268,30 +1264,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
36849 #endif
36850 };
36851
36852-static void xen_reboot(int reason)
36853+static __noreturn void xen_reboot(int reason)
36854 {
36855 struct sched_shutdown r = { .reason = reason };
36856
36857- if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
36858- BUG();
36859+ HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
36860+ BUG();
36861 }
36862
36863-static void xen_restart(char *msg)
36864+static __noreturn void xen_restart(char *msg)
36865 {
36866 xen_reboot(SHUTDOWN_reboot);
36867 }
36868
36869-static void xen_emergency_restart(void)
36870+static __noreturn void xen_emergency_restart(void)
36871 {
36872 xen_reboot(SHUTDOWN_reboot);
36873 }
36874
36875-static void xen_machine_halt(void)
36876+static __noreturn void xen_machine_halt(void)
36877 {
36878 xen_reboot(SHUTDOWN_poweroff);
36879 }
36880
36881-static void xen_machine_power_off(void)
36882+static __noreturn void xen_machine_power_off(void)
36883 {
36884 if (pm_power_off)
36885 pm_power_off();
36886@@ -1444,8 +1440,11 @@ static void __ref xen_setup_gdt(int cpu)
36887 pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry_boot;
36888 pv_cpu_ops.load_gdt = xen_load_gdt_boot;
36889
36890- setup_stack_canary_segment(0);
36891- switch_to_new_gdt(0);
36892+ setup_stack_canary_segment(cpu);
36893+#ifdef CONFIG_X86_64
36894+ load_percpu_segment(cpu);
36895+#endif
36896+ switch_to_new_gdt(cpu);
36897
36898 pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry;
36899 pv_cpu_ops.load_gdt = xen_load_gdt;
36900@@ -1561,7 +1560,17 @@ asmlinkage __visible void __init xen_start_kernel(void)
36901 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
36902
36903 /* Work out if we support NX */
36904- x86_configure_nx();
36905+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
36906+ if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
36907+ (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
36908+ unsigned l, h;
36909+
36910+ __supported_pte_mask |= _PAGE_NX;
36911+ rdmsr(MSR_EFER, l, h);
36912+ l |= EFER_NX;
36913+ wrmsr(MSR_EFER, l, h);
36914+ }
36915+#endif
36916
36917 /* Get mfn list */
36918 xen_build_dynamic_phys_to_machine();
36919@@ -1589,13 +1598,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
36920
36921 machine_ops = xen_machine_ops;
36922
36923- /*
36924- * The only reliable way to retain the initial address of the
36925- * percpu gdt_page is to remember it here, so we can go and
36926- * mark it RW later, when the initial percpu area is freed.
36927- */
36928- xen_initial_gdt = &per_cpu(gdt_page, 0);
36929-
36930 xen_smp_init();
36931
36932 #ifdef CONFIG_ACPI_NUMA
36933diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
36934index dd151b2..3291e38 100644
36935--- a/arch/x86/xen/mmu.c
36936+++ b/arch/x86/xen/mmu.c
36937@@ -1835,7 +1835,11 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
36938 * L3_k[511] -> level2_fixmap_pgt */
36939 convert_pfn_mfn(level3_kernel_pgt);
36940
36941+ convert_pfn_mfn(level3_vmalloc_start_pgt);
36942+ convert_pfn_mfn(level3_vmalloc_end_pgt);
36943+ convert_pfn_mfn(level3_vmemmap_pgt);
36944 /* L3_k[511][506] -> level1_fixmap_pgt */
36945+ /* L3_k[511][507] -> level1_vsyscall_pgt */
36946 convert_pfn_mfn(level2_fixmap_pgt);
36947 }
36948 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
36949@@ -1860,11 +1864,22 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
36950 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
36951 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
36952 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
36953+ set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
36954+ set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
36955+ set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
36956 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
36957 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
36958+ set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
36959 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
36960 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
36961- set_page_prot(level1_fixmap_pgt, PAGE_KERNEL_RO);
36962+ set_page_prot(level1_modules_pgt[0], PAGE_KERNEL_RO);
36963+ set_page_prot(level1_modules_pgt[1], PAGE_KERNEL_RO);
36964+ set_page_prot(level1_modules_pgt[2], PAGE_KERNEL_RO);
36965+ set_page_prot(level1_modules_pgt[3], PAGE_KERNEL_RO);
36966+ set_page_prot(level1_fixmap_pgt[0], PAGE_KERNEL_RO);
36967+ set_page_prot(level1_fixmap_pgt[1], PAGE_KERNEL_RO);
36968+ set_page_prot(level1_fixmap_pgt[2], PAGE_KERNEL_RO);
36969+ set_page_prot(level1_vsyscall_pgt, PAGE_KERNEL_RO);
36970
36971 /* Pin down new L4 */
36972 pin_pagetable_pfn(MMUEXT_PIN_L4_TABLE,
36973@@ -2048,6 +2063,7 @@ static void __init xen_post_allocator_init(void)
36974 pv_mmu_ops.set_pud = xen_set_pud;
36975 #if CONFIG_PGTABLE_LEVELS == 4
36976 pv_mmu_ops.set_pgd = xen_set_pgd;
36977+ pv_mmu_ops.set_pgd_batched = xen_set_pgd;
36978 #endif
36979
36980 /* This will work as long as patching hasn't happened yet
36981@@ -2126,6 +2142,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
36982 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
36983 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
36984 .set_pgd = xen_set_pgd_hyper,
36985+ .set_pgd_batched = xen_set_pgd_hyper,
36986
36987 .alloc_pud = xen_alloc_pmd_init,
36988 .release_pud = xen_release_pmd_init,
36989diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
36990index 8648438..18bac20 100644
36991--- a/arch/x86/xen/smp.c
36992+++ b/arch/x86/xen/smp.c
36993@@ -284,17 +284,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
36994
36995 if (xen_pv_domain()) {
36996 if (!xen_feature(XENFEAT_writable_page_tables))
36997- /* We've switched to the "real" per-cpu gdt, so make
36998- * sure the old memory can be recycled. */
36999- make_lowmem_page_readwrite(xen_initial_gdt);
37000-
37001 #ifdef CONFIG_X86_32
37002 /*
37003 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
37004 * expects __USER_DS
37005 */
37006- loadsegment(ds, __USER_DS);
37007- loadsegment(es, __USER_DS);
37008+ loadsegment(ds, __KERNEL_DS);
37009+ loadsegment(es, __KERNEL_DS);
37010 #endif
37011
37012 xen_filter_cpu_maps();
37013@@ -375,7 +371,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
37014 #ifdef CONFIG_X86_32
37015 /* Note: PVH is not yet supported on x86_32. */
37016 ctxt->user_regs.fs = __KERNEL_PERCPU;
37017- ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
37018+ savesegment(gs, ctxt->user_regs.gs);
37019 #endif
37020 memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
37021
37022@@ -383,8 +379,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
37023 ctxt->user_regs.eip = (unsigned long)cpu_bringup_and_idle;
37024 ctxt->flags = VGCF_IN_KERNEL;
37025 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
37026- ctxt->user_regs.ds = __USER_DS;
37027- ctxt->user_regs.es = __USER_DS;
37028+ ctxt->user_regs.ds = __KERNEL_DS;
37029+ ctxt->user_regs.es = __KERNEL_DS;
37030 ctxt->user_regs.ss = __KERNEL_DS;
37031
37032 xen_copy_trap_info(ctxt->trap_ctxt);
37033@@ -720,7 +716,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
37034
37035 void __init xen_smp_init(void)
37036 {
37037- smp_ops = xen_smp_ops;
37038+ memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
37039 xen_fill_possible_map();
37040 }
37041
37042diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
37043index fd92a64..1f72641 100644
37044--- a/arch/x86/xen/xen-asm_32.S
37045+++ b/arch/x86/xen/xen-asm_32.S
37046@@ -99,7 +99,7 @@ ENTRY(xen_iret)
37047 pushw %fs
37048 movl $(__KERNEL_PERCPU), %eax
37049 movl %eax, %fs
37050- movl %fs:xen_vcpu, %eax
37051+ mov PER_CPU_VAR(xen_vcpu), %eax
37052 POP_FS
37053 #else
37054 movl %ss:xen_vcpu, %eax
37055diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
37056index 8afdfcc..79239db 100644
37057--- a/arch/x86/xen/xen-head.S
37058+++ b/arch/x86/xen/xen-head.S
37059@@ -41,6 +41,17 @@ ENTRY(startup_xen)
37060 #ifdef CONFIG_X86_32
37061 mov %esi,xen_start_info
37062 mov $init_thread_union+THREAD_SIZE,%esp
37063+#ifdef CONFIG_SMP
37064+ movl $cpu_gdt_table,%edi
37065+ movl $__per_cpu_load,%eax
37066+ movw %ax,__KERNEL_PERCPU + 2(%edi)
37067+ rorl $16,%eax
37068+ movb %al,__KERNEL_PERCPU + 4(%edi)
37069+ movb %ah,__KERNEL_PERCPU + 7(%edi)
37070+ movl $__per_cpu_end - 1,%eax
37071+ subl $__per_cpu_start,%eax
37072+ movw %ax,__KERNEL_PERCPU + 0(%edi)
37073+#endif
37074 #else
37075 mov %rsi,xen_start_info
37076 mov $init_thread_union+THREAD_SIZE,%rsp
37077diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
37078index 2292721..a9bb18e 100644
37079--- a/arch/x86/xen/xen-ops.h
37080+++ b/arch/x86/xen/xen-ops.h
37081@@ -16,8 +16,6 @@ void xen_syscall_target(void);
37082 void xen_syscall32_target(void);
37083 #endif
37084
37085-extern void *xen_initial_gdt;
37086-
37087 struct trap_info;
37088 void xen_copy_trap_info(struct trap_info *traps);
37089
37090diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
37091index 525bd3d..ef888b1 100644
37092--- a/arch/xtensa/variants/dc232b/include/variant/core.h
37093+++ b/arch/xtensa/variants/dc232b/include/variant/core.h
37094@@ -119,9 +119,9 @@
37095 ----------------------------------------------------------------------*/
37096
37097 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
37098-#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
37099 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
37100 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
37101+#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
37102
37103 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
37104 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
37105diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
37106index 2f33760..835e50a 100644
37107--- a/arch/xtensa/variants/fsf/include/variant/core.h
37108+++ b/arch/xtensa/variants/fsf/include/variant/core.h
37109@@ -11,6 +11,7 @@
37110 #ifndef _XTENSA_CORE_H
37111 #define _XTENSA_CORE_H
37112
37113+#include <linux/const.h>
37114
37115 /****************************************************************************
37116 Parameters Useful for Any Code, USER or PRIVILEGED
37117@@ -112,9 +113,9 @@
37118 ----------------------------------------------------------------------*/
37119
37120 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
37121-#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
37122 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
37123 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
37124+#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
37125
37126 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
37127 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
37128diff --git a/block/bio.c b/block/bio.c
37129index d6e5ba3..2bb142c 100644
37130--- a/block/bio.c
37131+++ b/block/bio.c
37132@@ -1187,7 +1187,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
37133 /*
37134 * Overflow, abort
37135 */
37136- if (end < start)
37137+ if (end < start || end - start > INT_MAX - nr_pages)
37138 return ERR_PTR(-EINVAL);
37139
37140 nr_pages += end - start;
37141@@ -1312,7 +1312,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,
37142 /*
37143 * Overflow, abort
37144 */
37145- if (end < start)
37146+ if (end < start || end - start > INT_MAX - nr_pages)
37147 return ERR_PTR(-EINVAL);
37148
37149 nr_pages += end - start;
37150diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
37151index 0736729..2ec3b48 100644
37152--- a/block/blk-iopoll.c
37153+++ b/block/blk-iopoll.c
37154@@ -74,7 +74,7 @@ void blk_iopoll_complete(struct blk_iopoll *iop)
37155 }
37156 EXPORT_SYMBOL(blk_iopoll_complete);
37157
37158-static void blk_iopoll_softirq(struct softirq_action *h)
37159+static __latent_entropy void blk_iopoll_softirq(void)
37160 {
37161 struct list_head *list = this_cpu_ptr(&blk_cpu_iopoll);
37162 int rearm = 0, budget = blk_iopoll_budget;
37163diff --git a/block/blk-map.c b/block/blk-map.c
37164index da310a1..213b5c9 100644
37165--- a/block/blk-map.c
37166+++ b/block/blk-map.c
37167@@ -192,7 +192,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
37168 if (!len || !kbuf)
37169 return -EINVAL;
37170
37171- do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
37172+ do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
37173 if (do_copy)
37174 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
37175 else
37176diff --git a/block/blk-softirq.c b/block/blk-softirq.c
37177index 53b1737..08177d2e 100644
37178--- a/block/blk-softirq.c
37179+++ b/block/blk-softirq.c
37180@@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
37181 * Softirq action handler - move entries to local list and loop over them
37182 * while passing them to the queue registered handler.
37183 */
37184-static void blk_done_softirq(struct softirq_action *h)
37185+static __latent_entropy void blk_done_softirq(void)
37186 {
37187 struct list_head *cpu_list, local_list;
37188
37189diff --git a/block/bsg.c b/block/bsg.c
37190index d214e92..9649863 100644
37191--- a/block/bsg.c
37192+++ b/block/bsg.c
37193@@ -140,16 +140,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
37194 struct sg_io_v4 *hdr, struct bsg_device *bd,
37195 fmode_t has_write_perm)
37196 {
37197+ unsigned char tmpcmd[sizeof(rq->__cmd)];
37198+ unsigned char *cmdptr;
37199+
37200 if (hdr->request_len > BLK_MAX_CDB) {
37201 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
37202 if (!rq->cmd)
37203 return -ENOMEM;
37204- }
37205+ cmdptr = rq->cmd;
37206+ } else
37207+ cmdptr = tmpcmd;
37208
37209- if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
37210+ if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
37211 hdr->request_len))
37212 return -EFAULT;
37213
37214+ if (cmdptr != rq->cmd)
37215+ memcpy(rq->cmd, cmdptr, hdr->request_len);
37216+
37217 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
37218 if (blk_verify_command(rq->cmd, has_write_perm))
37219 return -EPERM;
37220diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
37221index f678c73..f35aa18 100644
37222--- a/block/compat_ioctl.c
37223+++ b/block/compat_ioctl.c
37224@@ -156,7 +156,7 @@ static int compat_cdrom_generic_command(struct block_device *bdev, fmode_t mode,
37225 cgc = compat_alloc_user_space(sizeof(*cgc));
37226 cgc32 = compat_ptr(arg);
37227
37228- if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) ||
37229+ if (copy_in_user(cgc->cmd, cgc32->cmd, sizeof(cgc->cmd)) ||
37230 get_user(data, &cgc32->buffer) ||
37231 put_user(compat_ptr(data), &cgc->buffer) ||
37232 copy_in_user(&cgc->buflen, &cgc32->buflen,
37233@@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
37234 err |= __get_user(f->spec1, &uf->spec1);
37235 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
37236 err |= __get_user(name, &uf->name);
37237- f->name = compat_ptr(name);
37238+ f->name = (void __force_kernel *)compat_ptr(name);
37239 if (err) {
37240 err = -EFAULT;
37241 goto out;
37242diff --git a/block/genhd.c b/block/genhd.c
37243index 59a1395..54ff187 100644
37244--- a/block/genhd.c
37245+++ b/block/genhd.c
37246@@ -470,21 +470,24 @@ static char *bdevt_str(dev_t devt, char *buf)
37247
37248 /*
37249 * Register device numbers dev..(dev+range-1)
37250- * range must be nonzero
37251+ * Noop if @range is zero.
37252 * The hash chain is sorted on range, so that subranges can override.
37253 */
37254 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
37255 struct kobject *(*probe)(dev_t, int *, void *),
37256 int (*lock)(dev_t, void *), void *data)
37257 {
37258- kobj_map(bdev_map, devt, range, module, probe, lock, data);
37259+ if (range)
37260+ kobj_map(bdev_map, devt, range, module, probe, lock, data);
37261 }
37262
37263 EXPORT_SYMBOL(blk_register_region);
37264
37265+/* undo blk_register_region(), noop if @range is zero */
37266 void blk_unregister_region(dev_t devt, unsigned long range)
37267 {
37268- kobj_unmap(bdev_map, devt, range);
37269+ if (range)
37270+ kobj_unmap(bdev_map, devt, range);
37271 }
37272
37273 EXPORT_SYMBOL(blk_unregister_region);
37274diff --git a/block/partitions/efi.c b/block/partitions/efi.c
37275index 26cb624..a49c3a5 100644
37276--- a/block/partitions/efi.c
37277+++ b/block/partitions/efi.c
37278@@ -293,14 +293,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
37279 if (!gpt)
37280 return NULL;
37281
37282+ if (!le32_to_cpu(gpt->num_partition_entries))
37283+ return NULL;
37284+ pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
37285+ if (!pte)
37286+ return NULL;
37287+
37288 count = le32_to_cpu(gpt->num_partition_entries) *
37289 le32_to_cpu(gpt->sizeof_partition_entry);
37290- if (!count)
37291- return NULL;
37292- pte = kmalloc(count, GFP_KERNEL);
37293- if (!pte)
37294- return NULL;
37295-
37296 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
37297 (u8 *) pte, count) < count) {
37298 kfree(pte);
37299diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
37300index dda653c..028a13ee 100644
37301--- a/block/scsi_ioctl.c
37302+++ b/block/scsi_ioctl.c
37303@@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
37304 return put_user(0, p);
37305 }
37306
37307-static int sg_get_timeout(struct request_queue *q)
37308+static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
37309 {
37310 return jiffies_to_clock_t(q->sg_timeout);
37311 }
37312@@ -227,8 +227,20 @@ EXPORT_SYMBOL(blk_verify_command);
37313 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
37314 struct sg_io_hdr *hdr, fmode_t mode)
37315 {
37316- if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
37317+ unsigned char tmpcmd[sizeof(rq->__cmd)];
37318+ unsigned char *cmdptr;
37319+
37320+ if (rq->cmd != rq->__cmd)
37321+ cmdptr = rq->cmd;
37322+ else
37323+ cmdptr = tmpcmd;
37324+
37325+ if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
37326 return -EFAULT;
37327+
37328+ if (cmdptr != rq->cmd)
37329+ memcpy(rq->cmd, cmdptr, hdr->cmd_len);
37330+
37331 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
37332 return -EPERM;
37333
37334@@ -420,6 +432,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
37335 int err;
37336 unsigned int in_len, out_len, bytes, opcode, cmdlen;
37337 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
37338+ unsigned char tmpcmd[sizeof(rq->__cmd)];
37339+ unsigned char *cmdptr;
37340
37341 if (!sic)
37342 return -EINVAL;
37343@@ -458,9 +472,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
37344 */
37345 err = -EFAULT;
37346 rq->cmd_len = cmdlen;
37347- if (copy_from_user(rq->cmd, sic->data, cmdlen))
37348+
37349+ if (rq->cmd != rq->__cmd)
37350+ cmdptr = rq->cmd;
37351+ else
37352+ cmdptr = tmpcmd;
37353+
37354+ if (copy_from_user(cmdptr, sic->data, cmdlen))
37355 goto error;
37356
37357+ if (rq->cmd != cmdptr)
37358+ memcpy(rq->cmd, cmdptr, cmdlen);
37359+
37360 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
37361 goto error;
37362
37363diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
37364index b788f16..b4ffc5b 100644
37365--- a/crypto/ablkcipher.c
37366+++ b/crypto/ablkcipher.c
37367@@ -706,7 +706,7 @@ struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name,
37368 err:
37369 if (err != -EAGAIN)
37370 break;
37371- if (signal_pending(current)) {
37372+ if (fatal_signal_pending(current)) {
37373 err = -EINTR;
37374 break;
37375 }
37376diff --git a/crypto/algapi.c b/crypto/algapi.c
37377index 3c079b7..b603b34 100644
37378--- a/crypto/algapi.c
37379+++ b/crypto/algapi.c
37380@@ -335,7 +335,7 @@ static void crypto_wait_for_test(struct crypto_larval *larval)
37381 crypto_alg_tested(larval->alg.cra_driver_name, 0);
37382 }
37383
37384- err = wait_for_completion_interruptible(&larval->completion);
37385+ err = wait_for_completion_killable(&larval->completion);
37386 WARN_ON(err);
37387
37388 out:
37389diff --git a/crypto/api.c b/crypto/api.c
37390index afe4610..bbc147c 100644
37391--- a/crypto/api.c
37392+++ b/crypto/api.c
37393@@ -172,7 +172,7 @@ static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg)
37394 struct crypto_larval *larval = (void *)alg;
37395 long timeout;
37396
37397- timeout = wait_for_completion_interruptible_timeout(
37398+ timeout = wait_for_completion_killable_timeout(
37399 &larval->completion, 60 * HZ);
37400
37401 alg = larval->adult;
37402@@ -445,7 +445,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
37403 err:
37404 if (err != -EAGAIN)
37405 break;
37406- if (signal_pending(current)) {
37407+ if (fatal_signal_pending(current)) {
37408 err = -EINTR;
37409 break;
37410 }
37411@@ -562,7 +562,7 @@ void *crypto_alloc_tfm(const char *alg_name,
37412 err:
37413 if (err != -EAGAIN)
37414 break;
37415- if (signal_pending(current)) {
37416+ if (fatal_signal_pending(current)) {
37417 err = -EINTR;
37418 break;
37419 }
37420diff --git a/crypto/cryptd.c b/crypto/cryptd.c
37421index 22ba81f..1acac67 100644
37422--- a/crypto/cryptd.c
37423+++ b/crypto/cryptd.c
37424@@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
37425
37426 struct cryptd_blkcipher_request_ctx {
37427 crypto_completion_t complete;
37428-};
37429+} __no_const;
37430
37431 struct cryptd_hash_ctx {
37432 struct crypto_shash *child;
37433@@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
37434
37435 struct cryptd_aead_request_ctx {
37436 crypto_completion_t complete;
37437-};
37438+} __no_const;
37439
37440 static void cryptd_queue_worker(struct work_struct *work);
37441
37442diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
37443index 08ea286..d59fb4e 100644
37444--- a/crypto/crypto_user.c
37445+++ b/crypto/crypto_user.c
37446@@ -376,7 +376,7 @@ static struct crypto_alg *crypto_user_skcipher_alg(const char *name, u32 type,
37447 err = PTR_ERR(alg);
37448 if (err != -EAGAIN)
37449 break;
37450- if (signal_pending(current)) {
37451+ if (fatal_signal_pending(current)) {
37452 err = -EINTR;
37453 break;
37454 }
37455diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
37456index 45e7d51..2967121 100644
37457--- a/crypto/pcrypt.c
37458+++ b/crypto/pcrypt.c
37459@@ -385,7 +385,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
37460 int ret;
37461
37462 pinst->kobj.kset = pcrypt_kset;
37463- ret = kobject_add(&pinst->kobj, NULL, name);
37464+ ret = kobject_add(&pinst->kobj, NULL, "%s", name);
37465 if (!ret)
37466 kobject_uevent(&pinst->kobj, KOBJ_ADD);
37467
37468diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c
37469index ea5815c..5880da6 100644
37470--- a/crypto/scatterwalk.c
37471+++ b/crypto/scatterwalk.c
37472@@ -109,14 +109,20 @@ void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
37473 {
37474 struct scatter_walk walk;
37475 struct scatterlist tmp[2];
37476+ void *realbuf = buf;
37477
37478 if (!nbytes)
37479 return;
37480
37481 sg = scatterwalk_ffwd(tmp, sg, start);
37482
37483- if (sg_page(sg) == virt_to_page(buf) &&
37484- sg->offset == offset_in_page(buf))
37485+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
37486+ if (object_starts_on_stack(buf))
37487+ realbuf = buf - current->stack + current->lowmem_stack;
37488+#endif
37489+
37490+ if (sg_page(sg) == virt_to_page(realbuf) &&
37491+ sg->offset == offset_in_page(realbuf))
37492 return;
37493
37494 scatterwalk_start(&walk, sg);
37495diff --git a/crypto/zlib.c b/crypto/zlib.c
37496index d51a30a..fb1f8af 100644
37497--- a/crypto/zlib.c
37498+++ b/crypto/zlib.c
37499@@ -95,10 +95,10 @@ static int zlib_compress_setup(struct crypto_pcomp *tfm, const void *params,
37500 zlib_comp_exit(ctx);
37501
37502 window_bits = tb[ZLIB_COMP_WINDOWBITS]
37503- ? nla_get_u32(tb[ZLIB_COMP_WINDOWBITS])
37504+ ? nla_get_s32(tb[ZLIB_COMP_WINDOWBITS])
37505 : MAX_WBITS;
37506 mem_level = tb[ZLIB_COMP_MEMLEVEL]
37507- ? nla_get_u32(tb[ZLIB_COMP_MEMLEVEL])
37508+ ? nla_get_s32(tb[ZLIB_COMP_MEMLEVEL])
37509 : DEF_MEM_LEVEL;
37510
37511 workspacesize = zlib_deflate_workspacesize(window_bits, mem_level);
37512diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
37513index 8c2fe2f..fc47c12 100644
37514--- a/drivers/acpi/acpi_video.c
37515+++ b/drivers/acpi/acpi_video.c
37516@@ -398,7 +398,7 @@ static int video_disable_backlight_sysfs_if(
37517 return 0;
37518 }
37519
37520-static struct dmi_system_id video_dmi_table[] = {
37521+static const struct dmi_system_id video_dmi_table[] = {
37522 /*
37523 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121
37524 */
37525diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
37526index 52dfd0d..8386baf 100644
37527--- a/drivers/acpi/acpica/hwxfsleep.c
37528+++ b/drivers/acpi/acpica/hwxfsleep.c
37529@@ -70,11 +70,12 @@ static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id);
37530 /* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */
37531
37532 static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
37533- {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
37534- acpi_hw_extended_sleep},
37535- {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
37536- acpi_hw_extended_wake_prep},
37537- {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake}
37538+ {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
37539+ .extended_function = acpi_hw_extended_sleep},
37540+ {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
37541+ .extended_function = acpi_hw_extended_wake_prep},
37542+ {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake),
37543+ .extended_function = acpi_hw_extended_wake}
37544 };
37545
37546 /*
37547diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
37548index 16129c7..8b675cd 100644
37549--- a/drivers/acpi/apei/apei-internal.h
37550+++ b/drivers/acpi/apei/apei-internal.h
37551@@ -19,7 +19,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
37552 struct apei_exec_ins_type {
37553 u32 flags;
37554 apei_exec_ins_func_t run;
37555-};
37556+} __do_const;
37557
37558 struct apei_exec_context {
37559 u32 ip;
37560diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
37561index 2bfd53c..391e9a4 100644
37562--- a/drivers/acpi/apei/ghes.c
37563+++ b/drivers/acpi/apei/ghes.c
37564@@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
37565 const struct acpi_hest_generic *generic,
37566 const struct acpi_hest_generic_status *estatus)
37567 {
37568- static atomic_t seqno;
37569+ static atomic_unchecked_t seqno;
37570 unsigned int curr_seqno;
37571 char pfx_seq[64];
37572
37573@@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
37574 else
37575 pfx = KERN_ERR;
37576 }
37577- curr_seqno = atomic_inc_return(&seqno);
37578+ curr_seqno = atomic_inc_return_unchecked(&seqno);
37579 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
37580 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
37581 pfx_seq, generic->header.source_id);
37582diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
37583index a83e3c6..c3d617f 100644
37584--- a/drivers/acpi/bgrt.c
37585+++ b/drivers/acpi/bgrt.c
37586@@ -86,8 +86,10 @@ static int __init bgrt_init(void)
37587 if (!bgrt_image)
37588 return -ENODEV;
37589
37590- bin_attr_image.private = bgrt_image;
37591- bin_attr_image.size = bgrt_image_size;
37592+ pax_open_kernel();
37593+ *(void **)&bin_attr_image.private = bgrt_image;
37594+ *(size_t *)&bin_attr_image.size = bgrt_image_size;
37595+ pax_close_kernel();
37596
37597 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
37598 if (!bgrt_kobj)
37599diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
37600index 278dc4b..976433d 100644
37601--- a/drivers/acpi/blacklist.c
37602+++ b/drivers/acpi/blacklist.c
37603@@ -51,7 +51,7 @@ struct acpi_blacklist_item {
37604 u32 is_critical_error;
37605 };
37606
37607-static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
37608+static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
37609
37610 /*
37611 * POLICY: If *anything* doesn't work, put it on the blacklist.
37612@@ -172,7 +172,7 @@ static int __init dmi_enable_rev_override(const struct dmi_system_id *d)
37613 }
37614 #endif
37615
37616-static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
37617+static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
37618 {
37619 .callback = dmi_disable_osi_vista,
37620 .ident = "Fujitsu Siemens",
37621diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
37622index 513e7230e..802015a 100644
37623--- a/drivers/acpi/bus.c
37624+++ b/drivers/acpi/bus.c
37625@@ -67,7 +67,7 @@ static int set_copy_dsdt(const struct dmi_system_id *id)
37626 }
37627 #endif
37628
37629-static struct dmi_system_id dsdt_dmi_table[] __initdata = {
37630+static const struct dmi_system_id dsdt_dmi_table[] __initconst = {
37631 /*
37632 * Invoke DSDT corruption work-around on all Toshiba Satellite.
37633 * https://bugzilla.kernel.org/show_bug.cgi?id=14679
37634@@ -83,7 +83,7 @@ static struct dmi_system_id dsdt_dmi_table[] __initdata = {
37635 {}
37636 };
37637 #else
37638-static struct dmi_system_id dsdt_dmi_table[] __initdata = {
37639+static const struct dmi_system_id dsdt_dmi_table[] __initconst = {
37640 {}
37641 };
37642 #endif
37643diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
37644index c68e724..e863008 100644
37645--- a/drivers/acpi/custom_method.c
37646+++ b/drivers/acpi/custom_method.c
37647@@ -29,6 +29,10 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
37648 struct acpi_table_header table;
37649 acpi_status status;
37650
37651+#ifdef CONFIG_GRKERNSEC_KMEM
37652+ return -EPERM;
37653+#endif
37654+
37655 if (!(*ppos)) {
37656 /* parse the table header to get the table length */
37657 if (count <= sizeof(struct acpi_table_header))
37658diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
37659index 88dbbb1..90714c0 100644
37660--- a/drivers/acpi/device_pm.c
37661+++ b/drivers/acpi/device_pm.c
37662@@ -1045,6 +1045,8 @@ EXPORT_SYMBOL_GPL(acpi_subsys_freeze);
37663
37664 #endif /* CONFIG_PM_SLEEP */
37665
37666+static void acpi_dev_pm_detach(struct device *dev, bool power_off);
37667+
37668 static struct dev_pm_domain acpi_general_pm_domain = {
37669 .ops = {
37670 .runtime_suspend = acpi_subsys_runtime_suspend,
37671@@ -1061,6 +1063,7 @@ static struct dev_pm_domain acpi_general_pm_domain = {
37672 .restore_early = acpi_subsys_resume_early,
37673 #endif
37674 },
37675+ .detach = acpi_dev_pm_detach
37676 };
37677
37678 /**
37679@@ -1130,7 +1133,6 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
37680 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
37681 }
37682
37683- dev->pm_domain->detach = acpi_dev_pm_detach;
37684 return 0;
37685 }
37686 EXPORT_SYMBOL_GPL(acpi_dev_pm_attach);
37687diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
37688index 9d4761d..ece2163 100644
37689--- a/drivers/acpi/ec.c
37690+++ b/drivers/acpi/ec.c
37691@@ -1434,7 +1434,7 @@ static int ec_clear_on_resume(const struct dmi_system_id *id)
37692 return 0;
37693 }
37694
37695-static struct dmi_system_id ec_dmi_table[] __initdata = {
37696+static const struct dmi_system_id ec_dmi_table[] __initconst = {
37697 {
37698 ec_skip_dsdt_scan, "Compal JFL92", {
37699 DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
37700diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
37701index 139d9e4..9a9d799 100644
37702--- a/drivers/acpi/pci_slot.c
37703+++ b/drivers/acpi/pci_slot.c
37704@@ -195,7 +195,7 @@ static int do_sta_before_sun(const struct dmi_system_id *d)
37705 return 0;
37706 }
37707
37708-static struct dmi_system_id acpi_pci_slot_dmi_table[] __initdata = {
37709+static const struct dmi_system_id acpi_pci_slot_dmi_table[] __initconst = {
37710 /*
37711 * Fujitsu Primequest machines will return 1023 to indicate an
37712 * error if the _SUN method is evaluated on SxFy objects that
37713diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
37714index d9f7158..168e742 100644
37715--- a/drivers/acpi/processor_driver.c
37716+++ b/drivers/acpi/processor_driver.c
37717@@ -159,7 +159,7 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
37718 return NOTIFY_OK;
37719 }
37720
37721-static struct notifier_block __refdata acpi_cpu_notifier = {
37722+static struct notifier_block __refconst acpi_cpu_notifier = {
37723 .notifier_call = acpi_cpu_soft_notify,
37724 };
37725
37726diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
37727index d540f42..d5b32ac 100644
37728--- a/drivers/acpi/processor_idle.c
37729+++ b/drivers/acpi/processor_idle.c
37730@@ -910,7 +910,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
37731 {
37732 int i, count = CPUIDLE_DRIVER_STATE_START;
37733 struct acpi_processor_cx *cx;
37734- struct cpuidle_state *state;
37735+ cpuidle_state_no_const *state;
37736 struct cpuidle_driver *drv = &acpi_idle_driver;
37737
37738 if (!pr->flags.power_setup_done)
37739diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
37740index 7cfbda4..74f738c 100644
37741--- a/drivers/acpi/processor_pdc.c
37742+++ b/drivers/acpi/processor_pdc.c
37743@@ -173,7 +173,7 @@ static int __init set_no_mwait(const struct dmi_system_id *id)
37744 return 0;
37745 }
37746
37747-static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
37748+static const struct dmi_system_id processor_idle_dmi_table[] __initconst = {
37749 {
37750 set_no_mwait, "Extensa 5220", {
37751 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
37752diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
37753index 2f0d4db..b9e9b15 100644
37754--- a/drivers/acpi/sleep.c
37755+++ b/drivers/acpi/sleep.c
37756@@ -148,7 +148,7 @@ static int __init init_nvs_nosave(const struct dmi_system_id *d)
37757 return 0;
37758 }
37759
37760-static struct dmi_system_id acpisleep_dmi_table[] __initdata = {
37761+static const struct dmi_system_id acpisleep_dmi_table[] __initconst = {
37762 {
37763 .callback = init_old_suspend_ordering,
37764 .ident = "Abit KN9 (nForce4 variant)",
37765diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
37766index 0876d77b..3ba0127 100644
37767--- a/drivers/acpi/sysfs.c
37768+++ b/drivers/acpi/sysfs.c
37769@@ -423,11 +423,11 @@ static u32 num_counters;
37770 static struct attribute **all_attrs;
37771 static u32 acpi_gpe_count;
37772
37773-static struct attribute_group interrupt_stats_attr_group = {
37774+static attribute_group_no_const interrupt_stats_attr_group = {
37775 .name = "interrupts",
37776 };
37777
37778-static struct kobj_attribute *counter_attrs;
37779+static kobj_attribute_no_const *counter_attrs;
37780
37781 static void delete_gpe_attr_array(void)
37782 {
37783diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
37784index 6d4e44e..44fb839 100644
37785--- a/drivers/acpi/thermal.c
37786+++ b/drivers/acpi/thermal.c
37787@@ -1212,7 +1212,7 @@ static int thermal_psv(const struct dmi_system_id *d) {
37788 return 0;
37789 }
37790
37791-static struct dmi_system_id thermal_dmi_table[] __initdata = {
37792+static const struct dmi_system_id thermal_dmi_table[] __initconst = {
37793 /*
37794 * Award BIOS on this AOpen makes thermal control almost worthless.
37795 * http://bugzilla.kernel.org/show_bug.cgi?id=8842
37796diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
37797index 2922f1f..26b0c03 100644
37798--- a/drivers/acpi/video_detect.c
37799+++ b/drivers/acpi/video_detect.c
37800@@ -41,7 +41,6 @@ ACPI_MODULE_NAME("video");
37801 void acpi_video_unregister_backlight(void);
37802
37803 static bool backlight_notifier_registered;
37804-static struct notifier_block backlight_nb;
37805 static struct work_struct backlight_notify_work;
37806
37807 static enum acpi_backlight_type acpi_backlight_cmdline = acpi_backlight_undef;
37808@@ -284,6 +283,10 @@ static int acpi_video_backlight_notify(struct notifier_block *nb,
37809 return NOTIFY_OK;
37810 }
37811
37812+static const struct notifier_block backlight_nb = {
37813+ .notifier_call = acpi_video_backlight_notify,
37814+};
37815+
37816 /*
37817 * Determine which type of backlight interface to use on this system,
37818 * First check cmdline, then dmi quirks, then do autodetect.
37819@@ -314,8 +317,6 @@ enum acpi_backlight_type acpi_video_get_backlight_type(void)
37820 &video_caps, NULL);
37821 INIT_WORK(&backlight_notify_work,
37822 acpi_video_backlight_notify_work);
37823- backlight_nb.notifier_call = acpi_video_backlight_notify;
37824- backlight_nb.priority = 0;
37825 if (backlight_register_notifier(&backlight_nb) == 0)
37826 backlight_notifier_registered = true;
37827 init_done = true;
37828diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
37829index 790e0de..6bae378 100644
37830--- a/drivers/ata/libata-core.c
37831+++ b/drivers/ata/libata-core.c
37832@@ -102,7 +102,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
37833 static void ata_dev_xfermask(struct ata_device *dev);
37834 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
37835
37836-atomic_t ata_print_id = ATOMIC_INIT(0);
37837+atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
37838
37839 struct ata_force_param {
37840 const char *name;
37841@@ -4800,7 +4800,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
37842 struct ata_port *ap;
37843 unsigned int tag;
37844
37845- WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37846+ BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37847 ap = qc->ap;
37848
37849 qc->flags = 0;
37850@@ -4817,7 +4817,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
37851 struct ata_port *ap;
37852 struct ata_link *link;
37853
37854- WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37855+ BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37856 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
37857 ap = qc->ap;
37858 link = qc->dev->link;
37859@@ -5924,6 +5924,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
37860 return;
37861
37862 spin_lock(&lock);
37863+ pax_open_kernel();
37864
37865 for (cur = ops->inherits; cur; cur = cur->inherits) {
37866 void **inherit = (void **)cur;
37867@@ -5937,8 +5938,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
37868 if (IS_ERR(*pp))
37869 *pp = NULL;
37870
37871- ops->inherits = NULL;
37872+ *(struct ata_port_operations **)&ops->inherits = NULL;
37873
37874+ pax_close_kernel();
37875 spin_unlock(&lock);
37876 }
37877
37878@@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
37879
37880 /* give ports names and add SCSI hosts */
37881 for (i = 0; i < host->n_ports; i++) {
37882- host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
37883+ host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
37884 host->ports[i]->local_port_no = i + 1;
37885 }
37886
37887diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
37888index 0d7f0da..bc20aa6 100644
37889--- a/drivers/ata/libata-scsi.c
37890+++ b/drivers/ata/libata-scsi.c
37891@@ -4193,7 +4193,7 @@ int ata_sas_port_init(struct ata_port *ap)
37892
37893 if (rc)
37894 return rc;
37895- ap->print_id = atomic_inc_return(&ata_print_id);
37896+ ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
37897 return 0;
37898 }
37899 EXPORT_SYMBOL_GPL(ata_sas_port_init);
37900diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
37901index f840ca1..edd6ef3 100644
37902--- a/drivers/ata/libata.h
37903+++ b/drivers/ata/libata.h
37904@@ -53,7 +53,7 @@ enum {
37905 ATA_DNXFER_QUIET = (1 << 31),
37906 };
37907
37908-extern atomic_t ata_print_id;
37909+extern atomic_unchecked_t ata_print_id;
37910 extern int atapi_passthru16;
37911 extern int libata_fua;
37912 extern int libata_noacpi;
37913diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
37914index 5d9ee99..8fa2585 100644
37915--- a/drivers/ata/pata_arasan_cf.c
37916+++ b/drivers/ata/pata_arasan_cf.c
37917@@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
37918 /* Handle platform specific quirks */
37919 if (quirk) {
37920 if (quirk & CF_BROKEN_PIO) {
37921- ap->ops->set_piomode = NULL;
37922+ pax_open_kernel();
37923+ *(void **)&ap->ops->set_piomode = NULL;
37924+ pax_close_kernel();
37925 ap->pio_mask = 0;
37926 }
37927 if (quirk & CF_BROKEN_MWDMA)
37928diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
37929index f9b983a..887b9d8 100644
37930--- a/drivers/atm/adummy.c
37931+++ b/drivers/atm/adummy.c
37932@@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
37933 vcc->pop(vcc, skb);
37934 else
37935 dev_kfree_skb_any(skb);
37936- atomic_inc(&vcc->stats->tx);
37937+ atomic_inc_unchecked(&vcc->stats->tx);
37938
37939 return 0;
37940 }
37941diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
37942index f1a9198..f466a4a 100644
37943--- a/drivers/atm/ambassador.c
37944+++ b/drivers/atm/ambassador.c
37945@@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
37946 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
37947
37948 // VC layer stats
37949- atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
37950+ atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
37951
37952 // free the descriptor
37953 kfree (tx_descr);
37954@@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
37955 dump_skb ("<<<", vc, skb);
37956
37957 // VC layer stats
37958- atomic_inc(&atm_vcc->stats->rx);
37959+ atomic_inc_unchecked(&atm_vcc->stats->rx);
37960 __net_timestamp(skb);
37961 // end of our responsibility
37962 atm_vcc->push (atm_vcc, skb);
37963@@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
37964 } else {
37965 PRINTK (KERN_INFO, "dropped over-size frame");
37966 // should we count this?
37967- atomic_inc(&atm_vcc->stats->rx_drop);
37968+ atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
37969 }
37970
37971 } else {
37972@@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
37973 }
37974
37975 if (check_area (skb->data, skb->len)) {
37976- atomic_inc(&atm_vcc->stats->tx_err);
37977+ atomic_inc_unchecked(&atm_vcc->stats->tx_err);
37978 return -ENOMEM; // ?
37979 }
37980
37981diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
37982index 480fa6f..947067c 100644
37983--- a/drivers/atm/atmtcp.c
37984+++ b/drivers/atm/atmtcp.c
37985@@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
37986 if (vcc->pop) vcc->pop(vcc,skb);
37987 else dev_kfree_skb(skb);
37988 if (dev_data) return 0;
37989- atomic_inc(&vcc->stats->tx_err);
37990+ atomic_inc_unchecked(&vcc->stats->tx_err);
37991 return -ENOLINK;
37992 }
37993 size = skb->len+sizeof(struct atmtcp_hdr);
37994@@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
37995 if (!new_skb) {
37996 if (vcc->pop) vcc->pop(vcc,skb);
37997 else dev_kfree_skb(skb);
37998- atomic_inc(&vcc->stats->tx_err);
37999+ atomic_inc_unchecked(&vcc->stats->tx_err);
38000 return -ENOBUFS;
38001 }
38002 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
38003@@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
38004 if (vcc->pop) vcc->pop(vcc,skb);
38005 else dev_kfree_skb(skb);
38006 out_vcc->push(out_vcc,new_skb);
38007- atomic_inc(&vcc->stats->tx);
38008- atomic_inc(&out_vcc->stats->rx);
38009+ atomic_inc_unchecked(&vcc->stats->tx);
38010+ atomic_inc_unchecked(&out_vcc->stats->rx);
38011 return 0;
38012 }
38013
38014@@ -300,7 +300,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
38015 read_unlock(&vcc_sklist_lock);
38016 if (!out_vcc) {
38017 result = -EUNATCH;
38018- atomic_inc(&vcc->stats->tx_err);
38019+ atomic_inc_unchecked(&vcc->stats->tx_err);
38020 goto done;
38021 }
38022 skb_pull(skb,sizeof(struct atmtcp_hdr));
38023@@ -312,8 +312,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
38024 __net_timestamp(new_skb);
38025 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
38026 out_vcc->push(out_vcc,new_skb);
38027- atomic_inc(&vcc->stats->tx);
38028- atomic_inc(&out_vcc->stats->rx);
38029+ atomic_inc_unchecked(&vcc->stats->tx);
38030+ atomic_inc_unchecked(&out_vcc->stats->rx);
38031 done:
38032 if (vcc->pop) vcc->pop(vcc,skb);
38033 else dev_kfree_skb(skb);
38034diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
38035index 6339efd..2b441d5 100644
38036--- a/drivers/atm/eni.c
38037+++ b/drivers/atm/eni.c
38038@@ -525,7 +525,7 @@ static int rx_aal0(struct atm_vcc *vcc)
38039 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
38040 vcc->dev->number);
38041 length = 0;
38042- atomic_inc(&vcc->stats->rx_err);
38043+ atomic_inc_unchecked(&vcc->stats->rx_err);
38044 }
38045 else {
38046 length = ATM_CELL_SIZE-1; /* no HEC */
38047@@ -580,7 +580,7 @@ static int rx_aal5(struct atm_vcc *vcc)
38048 size);
38049 }
38050 eff = length = 0;
38051- atomic_inc(&vcc->stats->rx_err);
38052+ atomic_inc_unchecked(&vcc->stats->rx_err);
38053 }
38054 else {
38055 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
38056@@ -597,7 +597,7 @@ static int rx_aal5(struct atm_vcc *vcc)
38057 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
38058 vcc->dev->number,vcc->vci,length,size << 2,descr);
38059 length = eff = 0;
38060- atomic_inc(&vcc->stats->rx_err);
38061+ atomic_inc_unchecked(&vcc->stats->rx_err);
38062 }
38063 }
38064 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
38065@@ -770,7 +770,7 @@ rx_dequeued++;
38066 vcc->push(vcc,skb);
38067 pushed++;
38068 }
38069- atomic_inc(&vcc->stats->rx);
38070+ atomic_inc_unchecked(&vcc->stats->rx);
38071 }
38072 wake_up(&eni_dev->rx_wait);
38073 }
38074@@ -1230,7 +1230,7 @@ static void dequeue_tx(struct atm_dev *dev)
38075 DMA_TO_DEVICE);
38076 if (vcc->pop) vcc->pop(vcc,skb);
38077 else dev_kfree_skb_irq(skb);
38078- atomic_inc(&vcc->stats->tx);
38079+ atomic_inc_unchecked(&vcc->stats->tx);
38080 wake_up(&eni_dev->tx_wait);
38081 dma_complete++;
38082 }
38083diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
38084index 82f2ae0..f205c02 100644
38085--- a/drivers/atm/firestream.c
38086+++ b/drivers/atm/firestream.c
38087@@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
38088 }
38089 }
38090
38091- atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
38092+ atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
38093
38094 fs_dprintk (FS_DEBUG_TXMEM, "i");
38095 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
38096@@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
38097 #endif
38098 skb_put (skb, qe->p1 & 0xffff);
38099 ATM_SKB(skb)->vcc = atm_vcc;
38100- atomic_inc(&atm_vcc->stats->rx);
38101+ atomic_inc_unchecked(&atm_vcc->stats->rx);
38102 __net_timestamp(skb);
38103 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
38104 atm_vcc->push (atm_vcc, skb);
38105@@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
38106 kfree (pe);
38107 }
38108 if (atm_vcc)
38109- atomic_inc(&atm_vcc->stats->rx_drop);
38110+ atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
38111 break;
38112 case 0x1f: /* Reassembly abort: no buffers. */
38113 /* Silently increment error counter. */
38114 if (atm_vcc)
38115- atomic_inc(&atm_vcc->stats->rx_drop);
38116+ atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
38117 break;
38118 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
38119 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
38120diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
38121index 75dde90..4309ead 100644
38122--- a/drivers/atm/fore200e.c
38123+++ b/drivers/atm/fore200e.c
38124@@ -932,9 +932,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
38125 #endif
38126 /* check error condition */
38127 if (*entry->status & STATUS_ERROR)
38128- atomic_inc(&vcc->stats->tx_err);
38129+ atomic_inc_unchecked(&vcc->stats->tx_err);
38130 else
38131- atomic_inc(&vcc->stats->tx);
38132+ atomic_inc_unchecked(&vcc->stats->tx);
38133 }
38134 }
38135
38136@@ -1083,7 +1083,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
38137 if (skb == NULL) {
38138 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
38139
38140- atomic_inc(&vcc->stats->rx_drop);
38141+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38142 return -ENOMEM;
38143 }
38144
38145@@ -1126,14 +1126,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
38146
38147 dev_kfree_skb_any(skb);
38148
38149- atomic_inc(&vcc->stats->rx_drop);
38150+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38151 return -ENOMEM;
38152 }
38153
38154 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
38155
38156 vcc->push(vcc, skb);
38157- atomic_inc(&vcc->stats->rx);
38158+ atomic_inc_unchecked(&vcc->stats->rx);
38159
38160 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
38161
38162@@ -1211,7 +1211,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
38163 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
38164 fore200e->atm_dev->number,
38165 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
38166- atomic_inc(&vcc->stats->rx_err);
38167+ atomic_inc_unchecked(&vcc->stats->rx_err);
38168 }
38169 }
38170
38171@@ -1656,7 +1656,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
38172 goto retry_here;
38173 }
38174
38175- atomic_inc(&vcc->stats->tx_err);
38176+ atomic_inc_unchecked(&vcc->stats->tx_err);
38177
38178 fore200e->tx_sat++;
38179 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
38180diff --git a/drivers/atm/he.c b/drivers/atm/he.c
38181index a8da3a5..67cf6c2 100644
38182--- a/drivers/atm/he.c
38183+++ b/drivers/atm/he.c
38184@@ -1692,7 +1692,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
38185
38186 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
38187 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
38188- atomic_inc(&vcc->stats->rx_drop);
38189+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38190 goto return_host_buffers;
38191 }
38192
38193@@ -1719,7 +1719,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
38194 RBRQ_LEN_ERR(he_dev->rbrq_head)
38195 ? "LEN_ERR" : "",
38196 vcc->vpi, vcc->vci);
38197- atomic_inc(&vcc->stats->rx_err);
38198+ atomic_inc_unchecked(&vcc->stats->rx_err);
38199 goto return_host_buffers;
38200 }
38201
38202@@ -1771,7 +1771,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
38203 vcc->push(vcc, skb);
38204 spin_lock(&he_dev->global_lock);
38205
38206- atomic_inc(&vcc->stats->rx);
38207+ atomic_inc_unchecked(&vcc->stats->rx);
38208
38209 return_host_buffers:
38210 ++pdus_assembled;
38211@@ -2097,7 +2097,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
38212 tpd->vcc->pop(tpd->vcc, tpd->skb);
38213 else
38214 dev_kfree_skb_any(tpd->skb);
38215- atomic_inc(&tpd->vcc->stats->tx_err);
38216+ atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
38217 }
38218 dma_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
38219 return;
38220@@ -2509,7 +2509,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38221 vcc->pop(vcc, skb);
38222 else
38223 dev_kfree_skb_any(skb);
38224- atomic_inc(&vcc->stats->tx_err);
38225+ atomic_inc_unchecked(&vcc->stats->tx_err);
38226 return -EINVAL;
38227 }
38228
38229@@ -2520,7 +2520,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38230 vcc->pop(vcc, skb);
38231 else
38232 dev_kfree_skb_any(skb);
38233- atomic_inc(&vcc->stats->tx_err);
38234+ atomic_inc_unchecked(&vcc->stats->tx_err);
38235 return -EINVAL;
38236 }
38237 #endif
38238@@ -2532,7 +2532,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38239 vcc->pop(vcc, skb);
38240 else
38241 dev_kfree_skb_any(skb);
38242- atomic_inc(&vcc->stats->tx_err);
38243+ atomic_inc_unchecked(&vcc->stats->tx_err);
38244 spin_unlock_irqrestore(&he_dev->global_lock, flags);
38245 return -ENOMEM;
38246 }
38247@@ -2574,7 +2574,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38248 vcc->pop(vcc, skb);
38249 else
38250 dev_kfree_skb_any(skb);
38251- atomic_inc(&vcc->stats->tx_err);
38252+ atomic_inc_unchecked(&vcc->stats->tx_err);
38253 spin_unlock_irqrestore(&he_dev->global_lock, flags);
38254 return -ENOMEM;
38255 }
38256@@ -2605,7 +2605,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
38257 __enqueue_tpd(he_dev, tpd, cid);
38258 spin_unlock_irqrestore(&he_dev->global_lock, flags);
38259
38260- atomic_inc(&vcc->stats->tx);
38261+ atomic_inc_unchecked(&vcc->stats->tx);
38262
38263 return 0;
38264 }
38265diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
38266index 527bbd5..96570c8 100644
38267--- a/drivers/atm/horizon.c
38268+++ b/drivers/atm/horizon.c
38269@@ -1018,7 +1018,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
38270 {
38271 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
38272 // VC layer stats
38273- atomic_inc(&vcc->stats->rx);
38274+ atomic_inc_unchecked(&vcc->stats->rx);
38275 __net_timestamp(skb);
38276 // end of our responsibility
38277 vcc->push (vcc, skb);
38278@@ -1170,7 +1170,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
38279 dev->tx_iovec = NULL;
38280
38281 // VC layer stats
38282- atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
38283+ atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
38284
38285 // free the skb
38286 hrz_kfree_skb (skb);
38287diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
38288index 074616b..d6b3d5f 100644
38289--- a/drivers/atm/idt77252.c
38290+++ b/drivers/atm/idt77252.c
38291@@ -811,7 +811,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
38292 else
38293 dev_kfree_skb(skb);
38294
38295- atomic_inc(&vcc->stats->tx);
38296+ atomic_inc_unchecked(&vcc->stats->tx);
38297 }
38298
38299 atomic_dec(&scq->used);
38300@@ -1073,13 +1073,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38301 if ((sb = dev_alloc_skb(64)) == NULL) {
38302 printk("%s: Can't allocate buffers for aal0.\n",
38303 card->name);
38304- atomic_add(i, &vcc->stats->rx_drop);
38305+ atomic_add_unchecked(i, &vcc->stats->rx_drop);
38306 break;
38307 }
38308 if (!atm_charge(vcc, sb->truesize)) {
38309 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
38310 card->name);
38311- atomic_add(i - 1, &vcc->stats->rx_drop);
38312+ atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
38313 dev_kfree_skb(sb);
38314 break;
38315 }
38316@@ -1096,7 +1096,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38317 ATM_SKB(sb)->vcc = vcc;
38318 __net_timestamp(sb);
38319 vcc->push(vcc, sb);
38320- atomic_inc(&vcc->stats->rx);
38321+ atomic_inc_unchecked(&vcc->stats->rx);
38322
38323 cell += ATM_CELL_PAYLOAD;
38324 }
38325@@ -1133,13 +1133,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38326 "(CDC: %08x)\n",
38327 card->name, len, rpp->len, readl(SAR_REG_CDC));
38328 recycle_rx_pool_skb(card, rpp);
38329- atomic_inc(&vcc->stats->rx_err);
38330+ atomic_inc_unchecked(&vcc->stats->rx_err);
38331 return;
38332 }
38333 if (stat & SAR_RSQE_CRC) {
38334 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
38335 recycle_rx_pool_skb(card, rpp);
38336- atomic_inc(&vcc->stats->rx_err);
38337+ atomic_inc_unchecked(&vcc->stats->rx_err);
38338 return;
38339 }
38340 if (skb_queue_len(&rpp->queue) > 1) {
38341@@ -1150,7 +1150,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38342 RXPRINTK("%s: Can't alloc RX skb.\n",
38343 card->name);
38344 recycle_rx_pool_skb(card, rpp);
38345- atomic_inc(&vcc->stats->rx_err);
38346+ atomic_inc_unchecked(&vcc->stats->rx_err);
38347 return;
38348 }
38349 if (!atm_charge(vcc, skb->truesize)) {
38350@@ -1169,7 +1169,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38351 __net_timestamp(skb);
38352
38353 vcc->push(vcc, skb);
38354- atomic_inc(&vcc->stats->rx);
38355+ atomic_inc_unchecked(&vcc->stats->rx);
38356
38357 return;
38358 }
38359@@ -1191,7 +1191,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
38360 __net_timestamp(skb);
38361
38362 vcc->push(vcc, skb);
38363- atomic_inc(&vcc->stats->rx);
38364+ atomic_inc_unchecked(&vcc->stats->rx);
38365
38366 if (skb->truesize > SAR_FB_SIZE_3)
38367 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
38368@@ -1302,14 +1302,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
38369 if (vcc->qos.aal != ATM_AAL0) {
38370 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
38371 card->name, vpi, vci);
38372- atomic_inc(&vcc->stats->rx_drop);
38373+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38374 goto drop;
38375 }
38376
38377 if ((sb = dev_alloc_skb(64)) == NULL) {
38378 printk("%s: Can't allocate buffers for AAL0.\n",
38379 card->name);
38380- atomic_inc(&vcc->stats->rx_err);
38381+ atomic_inc_unchecked(&vcc->stats->rx_err);
38382 goto drop;
38383 }
38384
38385@@ -1328,7 +1328,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
38386 ATM_SKB(sb)->vcc = vcc;
38387 __net_timestamp(sb);
38388 vcc->push(vcc, sb);
38389- atomic_inc(&vcc->stats->rx);
38390+ atomic_inc_unchecked(&vcc->stats->rx);
38391
38392 drop:
38393 skb_pull(queue, 64);
38394@@ -1953,13 +1953,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
38395
38396 if (vc == NULL) {
38397 printk("%s: NULL connection in send().\n", card->name);
38398- atomic_inc(&vcc->stats->tx_err);
38399+ atomic_inc_unchecked(&vcc->stats->tx_err);
38400 dev_kfree_skb(skb);
38401 return -EINVAL;
38402 }
38403 if (!test_bit(VCF_TX, &vc->flags)) {
38404 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
38405- atomic_inc(&vcc->stats->tx_err);
38406+ atomic_inc_unchecked(&vcc->stats->tx_err);
38407 dev_kfree_skb(skb);
38408 return -EINVAL;
38409 }
38410@@ -1971,14 +1971,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
38411 break;
38412 default:
38413 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
38414- atomic_inc(&vcc->stats->tx_err);
38415+ atomic_inc_unchecked(&vcc->stats->tx_err);
38416 dev_kfree_skb(skb);
38417 return -EINVAL;
38418 }
38419
38420 if (skb_shinfo(skb)->nr_frags != 0) {
38421 printk("%s: No scatter-gather yet.\n", card->name);
38422- atomic_inc(&vcc->stats->tx_err);
38423+ atomic_inc_unchecked(&vcc->stats->tx_err);
38424 dev_kfree_skb(skb);
38425 return -EINVAL;
38426 }
38427@@ -1986,7 +1986,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
38428
38429 err = queue_skb(card, vc, skb, oam);
38430 if (err) {
38431- atomic_inc(&vcc->stats->tx_err);
38432+ atomic_inc_unchecked(&vcc->stats->tx_err);
38433 dev_kfree_skb(skb);
38434 return err;
38435 }
38436@@ -2009,7 +2009,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
38437 skb = dev_alloc_skb(64);
38438 if (!skb) {
38439 printk("%s: Out of memory in send_oam().\n", card->name);
38440- atomic_inc(&vcc->stats->tx_err);
38441+ atomic_inc_unchecked(&vcc->stats->tx_err);
38442 return -ENOMEM;
38443 }
38444 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
38445diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
38446index 65e6590..df77d04 100644
38447--- a/drivers/atm/iphase.c
38448+++ b/drivers/atm/iphase.c
38449@@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
38450 status = (u_short) (buf_desc_ptr->desc_mode);
38451 if (status & (RX_CER | RX_PTE | RX_OFL))
38452 {
38453- atomic_inc(&vcc->stats->rx_err);
38454+ atomic_inc_unchecked(&vcc->stats->rx_err);
38455 IF_ERR(printk("IA: bad packet, dropping it");)
38456 if (status & RX_CER) {
38457 IF_ERR(printk(" cause: packet CRC error\n");)
38458@@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
38459 len = dma_addr - buf_addr;
38460 if (len > iadev->rx_buf_sz) {
38461 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
38462- atomic_inc(&vcc->stats->rx_err);
38463+ atomic_inc_unchecked(&vcc->stats->rx_err);
38464 goto out_free_desc;
38465 }
38466
38467@@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
38468 ia_vcc = INPH_IA_VCC(vcc);
38469 if (ia_vcc == NULL)
38470 {
38471- atomic_inc(&vcc->stats->rx_err);
38472+ atomic_inc_unchecked(&vcc->stats->rx_err);
38473 atm_return(vcc, skb->truesize);
38474 dev_kfree_skb_any(skb);
38475 goto INCR_DLE;
38476@@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
38477 if ((length > iadev->rx_buf_sz) || (length >
38478 (skb->len - sizeof(struct cpcs_trailer))))
38479 {
38480- atomic_inc(&vcc->stats->rx_err);
38481+ atomic_inc_unchecked(&vcc->stats->rx_err);
38482 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
38483 length, skb->len);)
38484 atm_return(vcc, skb->truesize);
38485@@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
38486
38487 IF_RX(printk("rx_dle_intr: skb push");)
38488 vcc->push(vcc,skb);
38489- atomic_inc(&vcc->stats->rx);
38490+ atomic_inc_unchecked(&vcc->stats->rx);
38491 iadev->rx_pkt_cnt++;
38492 }
38493 INCR_DLE:
38494@@ -2828,15 +2828,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
38495 {
38496 struct k_sonet_stats *stats;
38497 stats = &PRIV(_ia_dev[board])->sonet_stats;
38498- printk("section_bip: %d\n", atomic_read(&stats->section_bip));
38499- printk("line_bip : %d\n", atomic_read(&stats->line_bip));
38500- printk("path_bip : %d\n", atomic_read(&stats->path_bip));
38501- printk("line_febe : %d\n", atomic_read(&stats->line_febe));
38502- printk("path_febe : %d\n", atomic_read(&stats->path_febe));
38503- printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
38504- printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
38505- printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
38506- printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
38507+ printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
38508+ printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
38509+ printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
38510+ printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
38511+ printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
38512+ printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
38513+ printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
38514+ printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
38515+ printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
38516 }
38517 ia_cmds.status = 0;
38518 break;
38519@@ -2941,7 +2941,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
38520 if ((desc == 0) || (desc > iadev->num_tx_desc))
38521 {
38522 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
38523- atomic_inc(&vcc->stats->tx);
38524+ atomic_inc_unchecked(&vcc->stats->tx);
38525 if (vcc->pop)
38526 vcc->pop(vcc, skb);
38527 else
38528@@ -3046,14 +3046,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
38529 ATM_DESC(skb) = vcc->vci;
38530 skb_queue_tail(&iadev->tx_dma_q, skb);
38531
38532- atomic_inc(&vcc->stats->tx);
38533+ atomic_inc_unchecked(&vcc->stats->tx);
38534 iadev->tx_pkt_cnt++;
38535 /* Increment transaction counter */
38536 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
38537
38538 #if 0
38539 /* add flow control logic */
38540- if (atomic_read(&vcc->stats->tx) % 20 == 0) {
38541+ if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
38542 if (iavcc->vc_desc_cnt > 10) {
38543 vcc->tx_quota = vcc->tx_quota * 3 / 4;
38544 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
38545diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
38546index ce43ae3..969de38 100644
38547--- a/drivers/atm/lanai.c
38548+++ b/drivers/atm/lanai.c
38549@@ -1295,7 +1295,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
38550 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
38551 lanai_endtx(lanai, lvcc);
38552 lanai_free_skb(lvcc->tx.atmvcc, skb);
38553- atomic_inc(&lvcc->tx.atmvcc->stats->tx);
38554+ atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
38555 }
38556
38557 /* Try to fill the buffer - don't call unless there is backlog */
38558@@ -1418,7 +1418,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
38559 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
38560 __net_timestamp(skb);
38561 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
38562- atomic_inc(&lvcc->rx.atmvcc->stats->rx);
38563+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
38564 out:
38565 lvcc->rx.buf.ptr = end;
38566 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
38567@@ -1659,7 +1659,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
38568 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
38569 "vcc %d\n", lanai->number, (unsigned int) s, vci);
38570 lanai->stats.service_rxnotaal5++;
38571- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
38572+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
38573 return 0;
38574 }
38575 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
38576@@ -1671,7 +1671,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
38577 int bytes;
38578 read_unlock(&vcc_sklist_lock);
38579 DPRINTK("got trashed rx pdu on vci %d\n", vci);
38580- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
38581+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
38582 lvcc->stats.x.aal5.service_trash++;
38583 bytes = (SERVICE_GET_END(s) * 16) -
38584 (((unsigned long) lvcc->rx.buf.ptr) -
38585@@ -1683,7 +1683,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
38586 }
38587 if (s & SERVICE_STREAM) {
38588 read_unlock(&vcc_sklist_lock);
38589- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
38590+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
38591 lvcc->stats.x.aal5.service_stream++;
38592 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
38593 "PDU on VCI %d!\n", lanai->number, vci);
38594@@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
38595 return 0;
38596 }
38597 DPRINTK("got rx crc error on vci %d\n", vci);
38598- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
38599+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
38600 lvcc->stats.x.aal5.service_rxcrc++;
38601 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
38602 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
38603diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
38604index ddc4ceb..36e29aa 100644
38605--- a/drivers/atm/nicstar.c
38606+++ b/drivers/atm/nicstar.c
38607@@ -1632,7 +1632,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
38608 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
38609 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
38610 card->index);
38611- atomic_inc(&vcc->stats->tx_err);
38612+ atomic_inc_unchecked(&vcc->stats->tx_err);
38613 dev_kfree_skb_any(skb);
38614 return -EINVAL;
38615 }
38616@@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
38617 if (!vc->tx) {
38618 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
38619 card->index);
38620- atomic_inc(&vcc->stats->tx_err);
38621+ atomic_inc_unchecked(&vcc->stats->tx_err);
38622 dev_kfree_skb_any(skb);
38623 return -EINVAL;
38624 }
38625@@ -1648,14 +1648,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
38626 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
38627 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
38628 card->index);
38629- atomic_inc(&vcc->stats->tx_err);
38630+ atomic_inc_unchecked(&vcc->stats->tx_err);
38631 dev_kfree_skb_any(skb);
38632 return -EINVAL;
38633 }
38634
38635 if (skb_shinfo(skb)->nr_frags != 0) {
38636 printk("nicstar%d: No scatter-gather yet.\n", card->index);
38637- atomic_inc(&vcc->stats->tx_err);
38638+ atomic_inc_unchecked(&vcc->stats->tx_err);
38639 dev_kfree_skb_any(skb);
38640 return -EINVAL;
38641 }
38642@@ -1703,11 +1703,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
38643 }
38644
38645 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
38646- atomic_inc(&vcc->stats->tx_err);
38647+ atomic_inc_unchecked(&vcc->stats->tx_err);
38648 dev_kfree_skb_any(skb);
38649 return -EIO;
38650 }
38651- atomic_inc(&vcc->stats->tx);
38652+ atomic_inc_unchecked(&vcc->stats->tx);
38653
38654 return 0;
38655 }
38656@@ -2024,14 +2024,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38657 printk
38658 ("nicstar%d: Can't allocate buffers for aal0.\n",
38659 card->index);
38660- atomic_add(i, &vcc->stats->rx_drop);
38661+ atomic_add_unchecked(i, &vcc->stats->rx_drop);
38662 break;
38663 }
38664 if (!atm_charge(vcc, sb->truesize)) {
38665 RXPRINTK
38666 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
38667 card->index);
38668- atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
38669+ atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
38670 dev_kfree_skb_any(sb);
38671 break;
38672 }
38673@@ -2046,7 +2046,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38674 ATM_SKB(sb)->vcc = vcc;
38675 __net_timestamp(sb);
38676 vcc->push(vcc, sb);
38677- atomic_inc(&vcc->stats->rx);
38678+ atomic_inc_unchecked(&vcc->stats->rx);
38679 cell += ATM_CELL_PAYLOAD;
38680 }
38681
38682@@ -2063,7 +2063,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38683 if (iovb == NULL) {
38684 printk("nicstar%d: Out of iovec buffers.\n",
38685 card->index);
38686- atomic_inc(&vcc->stats->rx_drop);
38687+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38688 recycle_rx_buf(card, skb);
38689 return;
38690 }
38691@@ -2087,7 +2087,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38692 small or large buffer itself. */
38693 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
38694 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
38695- atomic_inc(&vcc->stats->rx_err);
38696+ atomic_inc_unchecked(&vcc->stats->rx_err);
38697 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
38698 NS_MAX_IOVECS);
38699 NS_PRV_IOVCNT(iovb) = 0;
38700@@ -2107,7 +2107,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38701 ("nicstar%d: Expected a small buffer, and this is not one.\n",
38702 card->index);
38703 which_list(card, skb);
38704- atomic_inc(&vcc->stats->rx_err);
38705+ atomic_inc_unchecked(&vcc->stats->rx_err);
38706 recycle_rx_buf(card, skb);
38707 vc->rx_iov = NULL;
38708 recycle_iov_buf(card, iovb);
38709@@ -2120,7 +2120,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38710 ("nicstar%d: Expected a large buffer, and this is not one.\n",
38711 card->index);
38712 which_list(card, skb);
38713- atomic_inc(&vcc->stats->rx_err);
38714+ atomic_inc_unchecked(&vcc->stats->rx_err);
38715 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
38716 NS_PRV_IOVCNT(iovb));
38717 vc->rx_iov = NULL;
38718@@ -2143,7 +2143,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38719 printk(" - PDU size mismatch.\n");
38720 else
38721 printk(".\n");
38722- atomic_inc(&vcc->stats->rx_err);
38723+ atomic_inc_unchecked(&vcc->stats->rx_err);
38724 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
38725 NS_PRV_IOVCNT(iovb));
38726 vc->rx_iov = NULL;
38727@@ -2157,14 +2157,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38728 /* skb points to a small buffer */
38729 if (!atm_charge(vcc, skb->truesize)) {
38730 push_rxbufs(card, skb);
38731- atomic_inc(&vcc->stats->rx_drop);
38732+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38733 } else {
38734 skb_put(skb, len);
38735 dequeue_sm_buf(card, skb);
38736 ATM_SKB(skb)->vcc = vcc;
38737 __net_timestamp(skb);
38738 vcc->push(vcc, skb);
38739- atomic_inc(&vcc->stats->rx);
38740+ atomic_inc_unchecked(&vcc->stats->rx);
38741 }
38742 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
38743 struct sk_buff *sb;
38744@@ -2175,14 +2175,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38745 if (len <= NS_SMBUFSIZE) {
38746 if (!atm_charge(vcc, sb->truesize)) {
38747 push_rxbufs(card, sb);
38748- atomic_inc(&vcc->stats->rx_drop);
38749+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38750 } else {
38751 skb_put(sb, len);
38752 dequeue_sm_buf(card, sb);
38753 ATM_SKB(sb)->vcc = vcc;
38754 __net_timestamp(sb);
38755 vcc->push(vcc, sb);
38756- atomic_inc(&vcc->stats->rx);
38757+ atomic_inc_unchecked(&vcc->stats->rx);
38758 }
38759
38760 push_rxbufs(card, skb);
38761@@ -2191,7 +2191,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38762
38763 if (!atm_charge(vcc, skb->truesize)) {
38764 push_rxbufs(card, skb);
38765- atomic_inc(&vcc->stats->rx_drop);
38766+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38767 } else {
38768 dequeue_lg_buf(card, skb);
38769 skb_push(skb, NS_SMBUFSIZE);
38770@@ -2201,7 +2201,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38771 ATM_SKB(skb)->vcc = vcc;
38772 __net_timestamp(skb);
38773 vcc->push(vcc, skb);
38774- atomic_inc(&vcc->stats->rx);
38775+ atomic_inc_unchecked(&vcc->stats->rx);
38776 }
38777
38778 push_rxbufs(card, sb);
38779@@ -2222,7 +2222,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38780 printk
38781 ("nicstar%d: Out of huge buffers.\n",
38782 card->index);
38783- atomic_inc(&vcc->stats->rx_drop);
38784+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38785 recycle_iovec_rx_bufs(card,
38786 (struct iovec *)
38787 iovb->data,
38788@@ -2273,7 +2273,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38789 card->hbpool.count++;
38790 } else
38791 dev_kfree_skb_any(hb);
38792- atomic_inc(&vcc->stats->rx_drop);
38793+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38794 } else {
38795 /* Copy the small buffer to the huge buffer */
38796 sb = (struct sk_buff *)iov->iov_base;
38797@@ -2307,7 +2307,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38798 ATM_SKB(hb)->vcc = vcc;
38799 __net_timestamp(hb);
38800 vcc->push(vcc, hb);
38801- atomic_inc(&vcc->stats->rx);
38802+ atomic_inc_unchecked(&vcc->stats->rx);
38803 }
38804 }
38805
38806diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
38807index 74e18b0..f16afa0 100644
38808--- a/drivers/atm/solos-pci.c
38809+++ b/drivers/atm/solos-pci.c
38810@@ -838,7 +838,7 @@ static void solos_bh(unsigned long card_arg)
38811 }
38812 atm_charge(vcc, skb->truesize);
38813 vcc->push(vcc, skb);
38814- atomic_inc(&vcc->stats->rx);
38815+ atomic_inc_unchecked(&vcc->stats->rx);
38816 break;
38817
38818 case PKT_STATUS:
38819@@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
38820 vcc = SKB_CB(oldskb)->vcc;
38821
38822 if (vcc) {
38823- atomic_inc(&vcc->stats->tx);
38824+ atomic_inc_unchecked(&vcc->stats->tx);
38825 solos_pop(vcc, oldskb);
38826 } else {
38827 dev_kfree_skb_irq(oldskb);
38828diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
38829index 0215934..ce9f5b1 100644
38830--- a/drivers/atm/suni.c
38831+++ b/drivers/atm/suni.c
38832@@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
38833
38834
38835 #define ADD_LIMITED(s,v) \
38836- atomic_add((v),&stats->s); \
38837- if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
38838+ atomic_add_unchecked((v),&stats->s); \
38839+ if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
38840
38841
38842 static void suni_hz(unsigned long from_timer)
38843diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
38844index 5120a96..e2572bd 100644
38845--- a/drivers/atm/uPD98402.c
38846+++ b/drivers/atm/uPD98402.c
38847@@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
38848 struct sonet_stats tmp;
38849 int error = 0;
38850
38851- atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
38852+ atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
38853 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
38854 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
38855 if (zero && !error) {
38856@@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
38857
38858
38859 #define ADD_LIMITED(s,v) \
38860- { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
38861- if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
38862- atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
38863+ { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
38864+ if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
38865+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
38866
38867
38868 static void stat_event(struct atm_dev *dev)
38869@@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
38870 if (reason & uPD98402_INT_PFM) stat_event(dev);
38871 if (reason & uPD98402_INT_PCO) {
38872 (void) GET(PCOCR); /* clear interrupt cause */
38873- atomic_add(GET(HECCT),
38874+ atomic_add_unchecked(GET(HECCT),
38875 &PRIV(dev)->sonet_stats.uncorr_hcs);
38876 }
38877 if ((reason & uPD98402_INT_RFO) &&
38878@@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
38879 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
38880 uPD98402_INT_LOS),PIMR); /* enable them */
38881 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
38882- atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
38883- atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
38884- atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
38885+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
38886+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
38887+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
38888 return 0;
38889 }
38890
38891diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
38892index cecfb94..87009ec 100644
38893--- a/drivers/atm/zatm.c
38894+++ b/drivers/atm/zatm.c
38895@@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
38896 }
38897 if (!size) {
38898 dev_kfree_skb_irq(skb);
38899- if (vcc) atomic_inc(&vcc->stats->rx_err);
38900+ if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
38901 continue;
38902 }
38903 if (!atm_charge(vcc,skb->truesize)) {
38904@@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
38905 skb->len = size;
38906 ATM_SKB(skb)->vcc = vcc;
38907 vcc->push(vcc,skb);
38908- atomic_inc(&vcc->stats->rx);
38909+ atomic_inc_unchecked(&vcc->stats->rx);
38910 }
38911 zout(pos & 0xffff,MTA(mbx));
38912 #if 0 /* probably a stupid idea */
38913@@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
38914 skb_queue_head(&zatm_vcc->backlog,skb);
38915 break;
38916 }
38917- atomic_inc(&vcc->stats->tx);
38918+ atomic_inc_unchecked(&vcc->stats->tx);
38919 wake_up(&zatm_vcc->tx_wait);
38920 }
38921
38922diff --git a/drivers/base/bus.c b/drivers/base/bus.c
38923index 5005924..9fc06c4 100644
38924--- a/drivers/base/bus.c
38925+++ b/drivers/base/bus.c
38926@@ -1141,7 +1141,7 @@ int subsys_interface_register(struct subsys_interface *sif)
38927 return -EINVAL;
38928
38929 mutex_lock(&subsys->p->mutex);
38930- list_add_tail(&sif->node, &subsys->p->interfaces);
38931+ pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
38932 if (sif->add_dev) {
38933 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
38934 while ((dev = subsys_dev_iter_next(&iter)))
38935@@ -1166,7 +1166,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
38936 subsys = sif->subsys;
38937
38938 mutex_lock(&subsys->p->mutex);
38939- list_del_init(&sif->node);
38940+ pax_list_del_init((struct list_head *)&sif->node);
38941 if (sif->remove_dev) {
38942 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
38943 while ((dev = subsys_dev_iter_next(&iter)))
38944diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
38945index 68f0314..ca2a609 100644
38946--- a/drivers/base/devtmpfs.c
38947+++ b/drivers/base/devtmpfs.c
38948@@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
38949 if (!thread)
38950 return 0;
38951
38952- err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
38953+ err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
38954 if (err)
38955 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
38956 else
38957@@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
38958 *err = sys_unshare(CLONE_NEWNS);
38959 if (*err)
38960 goto out;
38961- *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
38962+ *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
38963 if (*err)
38964 goto out;
38965- sys_chdir("/.."); /* will traverse into overmounted root */
38966- sys_chroot(".");
38967+ sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
38968+ sys_chroot((char __force_user *)".");
38969 complete(&setup_done);
38970 while (1) {
38971 spin_lock(&req_lock);
38972diff --git a/drivers/base/node.c b/drivers/base/node.c
38973index 560751b..3a4847a 100644
38974--- a/drivers/base/node.c
38975+++ b/drivers/base/node.c
38976@@ -627,7 +627,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
38977 struct node_attr {
38978 struct device_attribute attr;
38979 enum node_states state;
38980-};
38981+} __do_const;
38982
38983 static ssize_t show_node_state(struct device *dev,
38984 struct device_attribute *attr, char *buf)
38985diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
38986index 0ee43c1..369dd62 100644
38987--- a/drivers/base/power/domain.c
38988+++ b/drivers/base/power/domain.c
38989@@ -1738,7 +1738,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
38990 {
38991 struct cpuidle_driver *cpuidle_drv;
38992 struct gpd_cpuidle_data *cpuidle_data;
38993- struct cpuidle_state *idle_state;
38994+ cpuidle_state_no_const *idle_state;
38995 int ret = 0;
38996
38997 if (IS_ERR_OR_NULL(genpd) || state < 0)
38998@@ -1806,7 +1806,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
38999 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
39000 {
39001 struct gpd_cpuidle_data *cpuidle_data;
39002- struct cpuidle_state *idle_state;
39003+ cpuidle_state_no_const *idle_state;
39004 int ret = 0;
39005
39006 if (IS_ERR_OR_NULL(genpd))
39007@@ -2241,8 +2241,11 @@ int genpd_dev_pm_attach(struct device *dev)
39008 return ret;
39009 }
39010
39011- dev->pm_domain->detach = genpd_dev_pm_detach;
39012- dev->pm_domain->sync = genpd_dev_pm_sync;
39013+ pax_open_kernel();
39014+ *(void **)&dev->pm_domain->detach = genpd_dev_pm_detach;
39015+ *(void **)&dev->pm_domain->sync = genpd_dev_pm_sync;
39016+ pax_close_kernel();
39017+
39018 pm_genpd_poweron(pd);
39019
39020 return 0;
39021diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
39022index d2be3f9..0a3167a 100644
39023--- a/drivers/base/power/sysfs.c
39024+++ b/drivers/base/power/sysfs.c
39025@@ -181,7 +181,7 @@ static ssize_t rtpm_status_show(struct device *dev,
39026 return -EIO;
39027 }
39028 }
39029- return sprintf(buf, p);
39030+ return sprintf(buf, "%s", p);
39031 }
39032
39033 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
39034diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
39035index 51f15bc..892a668 100644
39036--- a/drivers/base/power/wakeup.c
39037+++ b/drivers/base/power/wakeup.c
39038@@ -33,14 +33,14 @@ static bool pm_abort_suspend __read_mostly;
39039 * They need to be modified together atomically, so it's better to use one
39040 * atomic variable to hold them both.
39041 */
39042-static atomic_t combined_event_count = ATOMIC_INIT(0);
39043+static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
39044
39045 #define IN_PROGRESS_BITS (sizeof(int) * 4)
39046 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
39047
39048 static void split_counters(unsigned int *cnt, unsigned int *inpr)
39049 {
39050- unsigned int comb = atomic_read(&combined_event_count);
39051+ unsigned int comb = atomic_read_unchecked(&combined_event_count);
39052
39053 *cnt = (comb >> IN_PROGRESS_BITS);
39054 *inpr = comb & MAX_IN_PROGRESS;
39055@@ -537,7 +537,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
39056 ws->start_prevent_time = ws->last_time;
39057
39058 /* Increment the counter of events in progress. */
39059- cec = atomic_inc_return(&combined_event_count);
39060+ cec = atomic_inc_return_unchecked(&combined_event_count);
39061
39062 trace_wakeup_source_activate(ws->name, cec);
39063 }
39064@@ -663,7 +663,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
39065 * Increment the counter of registered wakeup events and decrement the
39066 * couter of wakeup events in progress simultaneously.
39067 */
39068- cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
39069+ cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
39070 trace_wakeup_source_deactivate(ws->name, cec);
39071
39072 split_counters(&cnt, &inpr);
39073diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
39074index c8941f3..f7c7a7e 100644
39075--- a/drivers/base/regmap/regmap-debugfs.c
39076+++ b/drivers/base/regmap/regmap-debugfs.c
39077@@ -30,7 +30,7 @@ static LIST_HEAD(regmap_debugfs_early_list);
39078 static DEFINE_MUTEX(regmap_debugfs_early_lock);
39079
39080 /* Calculate the length of a fixed format */
39081-static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size)
39082+static size_t regmap_calc_reg_len(int max_val)
39083 {
39084 return snprintf(NULL, 0, "%x", max_val);
39085 }
39086@@ -173,8 +173,7 @@ static inline void regmap_calc_tot_len(struct regmap *map,
39087 {
39088 /* Calculate the length of a fixed format */
39089 if (!map->debugfs_tot_len) {
39090- map->debugfs_reg_len = regmap_calc_reg_len(map->max_register,
39091- buf, count);
39092+ map->debugfs_reg_len = regmap_calc_reg_len(map->max_register);
39093 map->debugfs_val_len = 2 * map->format.val_bytes;
39094 map->debugfs_tot_len = map->debugfs_reg_len +
39095 map->debugfs_val_len + 3; /* : \n */
39096@@ -404,7 +403,7 @@ static ssize_t regmap_access_read_file(struct file *file,
39097 char __user *user_buf, size_t count,
39098 loff_t *ppos)
39099 {
39100- int reg_len, tot_len;
39101+ size_t reg_len, tot_len;
39102 size_t buf_pos = 0;
39103 loff_t p = 0;
39104 ssize_t ret;
39105@@ -420,7 +419,7 @@ static ssize_t regmap_access_read_file(struct file *file,
39106 return -ENOMEM;
39107
39108 /* Calculate the length of a fixed format */
39109- reg_len = regmap_calc_reg_len(map->max_register, buf, count);
39110+ reg_len = regmap_calc_reg_len(map->max_register);
39111 tot_len = reg_len + 10; /* ': R W V P\n' */
39112
39113 for (i = 0; i <= map->max_register; i += map->reg_stride) {
39114diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
39115index 8d98a32..61d3165 100644
39116--- a/drivers/base/syscore.c
39117+++ b/drivers/base/syscore.c
39118@@ -22,7 +22,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
39119 void register_syscore_ops(struct syscore_ops *ops)
39120 {
39121 mutex_lock(&syscore_ops_lock);
39122- list_add_tail(&ops->node, &syscore_ops_list);
39123+ pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
39124 mutex_unlock(&syscore_ops_lock);
39125 }
39126 EXPORT_SYMBOL_GPL(register_syscore_ops);
39127@@ -34,7 +34,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
39128 void unregister_syscore_ops(struct syscore_ops *ops)
39129 {
39130 mutex_lock(&syscore_ops_lock);
39131- list_del(&ops->node);
39132+ pax_list_del((struct list_head *)&ops->node);
39133 mutex_unlock(&syscore_ops_lock);
39134 }
39135 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
39136diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
39137index 0422c47..b222c7a 100644
39138--- a/drivers/block/cciss.c
39139+++ b/drivers/block/cciss.c
39140@@ -3024,7 +3024,7 @@ static void start_io(ctlr_info_t *h)
39141 while (!list_empty(&h->reqQ)) {
39142 c = list_entry(h->reqQ.next, CommandList_struct, list);
39143 /* can't do anything if fifo is full */
39144- if ((h->access.fifo_full(h))) {
39145+ if ((h->access->fifo_full(h))) {
39146 dev_warn(&h->pdev->dev, "fifo full\n");
39147 break;
39148 }
39149@@ -3034,7 +3034,7 @@ static void start_io(ctlr_info_t *h)
39150 h->Qdepth--;
39151
39152 /* Tell the controller execute command */
39153- h->access.submit_command(h, c);
39154+ h->access->submit_command(h, c);
39155
39156 /* Put job onto the completed Q */
39157 addQ(&h->cmpQ, c);
39158@@ -3460,17 +3460,17 @@ startio:
39159
39160 static inline unsigned long get_next_completion(ctlr_info_t *h)
39161 {
39162- return h->access.command_completed(h);
39163+ return h->access->command_completed(h);
39164 }
39165
39166 static inline int interrupt_pending(ctlr_info_t *h)
39167 {
39168- return h->access.intr_pending(h);
39169+ return h->access->intr_pending(h);
39170 }
39171
39172 static inline long interrupt_not_for_us(ctlr_info_t *h)
39173 {
39174- return ((h->access.intr_pending(h) == 0) ||
39175+ return ((h->access->intr_pending(h) == 0) ||
39176 (h->interrupts_enabled == 0));
39177 }
39178
39179@@ -3503,7 +3503,7 @@ static inline u32 next_command(ctlr_info_t *h)
39180 u32 a;
39181
39182 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
39183- return h->access.command_completed(h);
39184+ return h->access->command_completed(h);
39185
39186 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
39187 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
39188@@ -4060,7 +4060,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
39189 trans_support & CFGTBL_Trans_use_short_tags);
39190
39191 /* Change the access methods to the performant access methods */
39192- h->access = SA5_performant_access;
39193+ h->access = &SA5_performant_access;
39194 h->transMethod = CFGTBL_Trans_Performant;
39195
39196 return;
39197@@ -4334,7 +4334,7 @@ static int cciss_pci_init(ctlr_info_t *h)
39198 if (prod_index < 0)
39199 return -ENODEV;
39200 h->product_name = products[prod_index].product_name;
39201- h->access = *(products[prod_index].access);
39202+ h->access = products[prod_index].access;
39203
39204 if (cciss_board_disabled(h)) {
39205 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
39206@@ -5065,7 +5065,7 @@ reinit_after_soft_reset:
39207 }
39208
39209 /* make sure the board interrupts are off */
39210- h->access.set_intr_mask(h, CCISS_INTR_OFF);
39211+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
39212 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
39213 if (rc)
39214 goto clean2;
39215@@ -5115,7 +5115,7 @@ reinit_after_soft_reset:
39216 * fake ones to scoop up any residual completions.
39217 */
39218 spin_lock_irqsave(&h->lock, flags);
39219- h->access.set_intr_mask(h, CCISS_INTR_OFF);
39220+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
39221 spin_unlock_irqrestore(&h->lock, flags);
39222 free_irq(h->intr[h->intr_mode], h);
39223 rc = cciss_request_irq(h, cciss_msix_discard_completions,
39224@@ -5135,9 +5135,9 @@ reinit_after_soft_reset:
39225 dev_info(&h->pdev->dev, "Board READY.\n");
39226 dev_info(&h->pdev->dev,
39227 "Waiting for stale completions to drain.\n");
39228- h->access.set_intr_mask(h, CCISS_INTR_ON);
39229+ h->access->set_intr_mask(h, CCISS_INTR_ON);
39230 msleep(10000);
39231- h->access.set_intr_mask(h, CCISS_INTR_OFF);
39232+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
39233
39234 rc = controller_reset_failed(h->cfgtable);
39235 if (rc)
39236@@ -5160,7 +5160,7 @@ reinit_after_soft_reset:
39237 cciss_scsi_setup(h);
39238
39239 /* Turn the interrupts on so we can service requests */
39240- h->access.set_intr_mask(h, CCISS_INTR_ON);
39241+ h->access->set_intr_mask(h, CCISS_INTR_ON);
39242
39243 /* Get the firmware version */
39244 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
39245@@ -5232,7 +5232,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
39246 kfree(flush_buf);
39247 if (return_code != IO_OK)
39248 dev_warn(&h->pdev->dev, "Error flushing cache\n");
39249- h->access.set_intr_mask(h, CCISS_INTR_OFF);
39250+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
39251 free_irq(h->intr[h->intr_mode], h);
39252 }
39253
39254diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
39255index 7fda30e..2f27946 100644
39256--- a/drivers/block/cciss.h
39257+++ b/drivers/block/cciss.h
39258@@ -101,7 +101,7 @@ struct ctlr_info
39259 /* information about each logical volume */
39260 drive_info_struct *drv[CISS_MAX_LUN];
39261
39262- struct access_method access;
39263+ struct access_method *access;
39264
39265 /* queue and queue Info */
39266 struct list_head reqQ;
39267@@ -402,27 +402,27 @@ static bool SA5_performant_intr_pending(ctlr_info_t *h)
39268 }
39269
39270 static struct access_method SA5_access = {
39271- SA5_submit_command,
39272- SA5_intr_mask,
39273- SA5_fifo_full,
39274- SA5_intr_pending,
39275- SA5_completed,
39276+ .submit_command = SA5_submit_command,
39277+ .set_intr_mask = SA5_intr_mask,
39278+ .fifo_full = SA5_fifo_full,
39279+ .intr_pending = SA5_intr_pending,
39280+ .command_completed = SA5_completed,
39281 };
39282
39283 static struct access_method SA5B_access = {
39284- SA5_submit_command,
39285- SA5B_intr_mask,
39286- SA5_fifo_full,
39287- SA5B_intr_pending,
39288- SA5_completed,
39289+ .submit_command = SA5_submit_command,
39290+ .set_intr_mask = SA5B_intr_mask,
39291+ .fifo_full = SA5_fifo_full,
39292+ .intr_pending = SA5B_intr_pending,
39293+ .command_completed = SA5_completed,
39294 };
39295
39296 static struct access_method SA5_performant_access = {
39297- SA5_submit_command,
39298- SA5_performant_intr_mask,
39299- SA5_fifo_full,
39300- SA5_performant_intr_pending,
39301- SA5_performant_completed,
39302+ .submit_command = SA5_submit_command,
39303+ .set_intr_mask = SA5_performant_intr_mask,
39304+ .fifo_full = SA5_fifo_full,
39305+ .intr_pending = SA5_performant_intr_pending,
39306+ .command_completed = SA5_performant_completed,
39307 };
39308
39309 struct board_type {
39310diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
39311index f749df9..5f8b9c4 100644
39312--- a/drivers/block/cpqarray.c
39313+++ b/drivers/block/cpqarray.c
39314@@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
39315 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
39316 goto Enomem4;
39317 }
39318- hba[i]->access.set_intr_mask(hba[i], 0);
39319+ hba[i]->access->set_intr_mask(hba[i], 0);
39320 if (request_irq(hba[i]->intr, do_ida_intr, IRQF_SHARED,
39321 hba[i]->devname, hba[i]))
39322 {
39323@@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
39324 add_timer(&hba[i]->timer);
39325
39326 /* Enable IRQ now that spinlock and rate limit timer are set up */
39327- hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
39328+ hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
39329
39330 for(j=0; j<NWD; j++) {
39331 struct gendisk *disk = ida_gendisk[i][j];
39332@@ -694,7 +694,7 @@ DBGINFO(
39333 for(i=0; i<NR_PRODUCTS; i++) {
39334 if (board_id == products[i].board_id) {
39335 c->product_name = products[i].product_name;
39336- c->access = *(products[i].access);
39337+ c->access = products[i].access;
39338 break;
39339 }
39340 }
39341@@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
39342 hba[ctlr]->intr = intr;
39343 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
39344 hba[ctlr]->product_name = products[j].product_name;
39345- hba[ctlr]->access = *(products[j].access);
39346+ hba[ctlr]->access = products[j].access;
39347 hba[ctlr]->ctlr = ctlr;
39348 hba[ctlr]->board_id = board_id;
39349 hba[ctlr]->pci_dev = NULL; /* not PCI */
39350@@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
39351
39352 while((c = h->reqQ) != NULL) {
39353 /* Can't do anything if we're busy */
39354- if (h->access.fifo_full(h) == 0)
39355+ if (h->access->fifo_full(h) == 0)
39356 return;
39357
39358 /* Get the first entry from the request Q */
39359@@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
39360 h->Qdepth--;
39361
39362 /* Tell the controller to do our bidding */
39363- h->access.submit_command(h, c);
39364+ h->access->submit_command(h, c);
39365
39366 /* Get onto the completion Q */
39367 addQ(&h->cmpQ, c);
39368@@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
39369 unsigned long flags;
39370 __u32 a,a1;
39371
39372- istat = h->access.intr_pending(h);
39373+ istat = h->access->intr_pending(h);
39374 /* Is this interrupt for us? */
39375 if (istat == 0)
39376 return IRQ_NONE;
39377@@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
39378 */
39379 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
39380 if (istat & FIFO_NOT_EMPTY) {
39381- while((a = h->access.command_completed(h))) {
39382+ while((a = h->access->command_completed(h))) {
39383 a1 = a; a &= ~3;
39384 if ((c = h->cmpQ) == NULL)
39385 {
39386@@ -1448,11 +1448,11 @@ static int sendcmd(
39387 /*
39388 * Disable interrupt
39389 */
39390- info_p->access.set_intr_mask(info_p, 0);
39391+ info_p->access->set_intr_mask(info_p, 0);
39392 /* Make sure there is room in the command FIFO */
39393 /* Actually it should be completely empty at this time. */
39394 for (i = 200000; i > 0; i--) {
39395- temp = info_p->access.fifo_full(info_p);
39396+ temp = info_p->access->fifo_full(info_p);
39397 if (temp != 0) {
39398 break;
39399 }
39400@@ -1465,7 +1465,7 @@ DBG(
39401 /*
39402 * Send the cmd
39403 */
39404- info_p->access.submit_command(info_p, c);
39405+ info_p->access->submit_command(info_p, c);
39406 complete = pollcomplete(ctlr);
39407
39408 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
39409@@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
39410 * we check the new geometry. Then turn interrupts back on when
39411 * we're done.
39412 */
39413- host->access.set_intr_mask(host, 0);
39414+ host->access->set_intr_mask(host, 0);
39415 getgeometry(ctlr);
39416- host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
39417+ host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
39418
39419 for(i=0; i<NWD; i++) {
39420 struct gendisk *disk = ida_gendisk[ctlr][i];
39421@@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
39422 /* Wait (up to 2 seconds) for a command to complete */
39423
39424 for (i = 200000; i > 0; i--) {
39425- done = hba[ctlr]->access.command_completed(hba[ctlr]);
39426+ done = hba[ctlr]->access->command_completed(hba[ctlr]);
39427 if (done == 0) {
39428 udelay(10); /* a short fixed delay */
39429 } else
39430diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
39431index be73e9d..7fbf140 100644
39432--- a/drivers/block/cpqarray.h
39433+++ b/drivers/block/cpqarray.h
39434@@ -99,7 +99,7 @@ struct ctlr_info {
39435 drv_info_t drv[NWD];
39436 struct proc_dir_entry *proc;
39437
39438- struct access_method access;
39439+ struct access_method *access;
39440
39441 cmdlist_t *reqQ;
39442 cmdlist_t *cmpQ;
39443diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
39444index 434c77d..6d3219a 100644
39445--- a/drivers/block/drbd/drbd_bitmap.c
39446+++ b/drivers/block/drbd/drbd_bitmap.c
39447@@ -1036,7 +1036,7 @@ static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, int page_nr) __must_ho
39448 submit_bio(rw, bio);
39449 /* this should not count as user activity and cause the
39450 * resync to throttle -- see drbd_rs_should_slow_down(). */
39451- atomic_add(len >> 9, &device->rs_sect_ev);
39452+ atomic_add_unchecked(len >> 9, &device->rs_sect_ev);
39453 }
39454 }
39455
39456diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
39457index efd19c2..6ccfa94 100644
39458--- a/drivers/block/drbd/drbd_int.h
39459+++ b/drivers/block/drbd/drbd_int.h
39460@@ -386,7 +386,7 @@ struct drbd_epoch {
39461 struct drbd_connection *connection;
39462 struct list_head list;
39463 unsigned int barrier_nr;
39464- atomic_t epoch_size; /* increased on every request added. */
39465+ atomic_unchecked_t epoch_size; /* increased on every request added. */
39466 atomic_t active; /* increased on every req. added, and dec on every finished. */
39467 unsigned long flags;
39468 };
39469@@ -947,7 +947,7 @@ struct drbd_device {
39470 unsigned int al_tr_number;
39471 int al_tr_cycle;
39472 wait_queue_head_t seq_wait;
39473- atomic_t packet_seq;
39474+ atomic_unchecked_t packet_seq;
39475 unsigned int peer_seq;
39476 spinlock_t peer_seq_lock;
39477 unsigned long comm_bm_set; /* communicated number of set bits. */
39478@@ -956,8 +956,8 @@ struct drbd_device {
39479 struct mutex own_state_mutex;
39480 struct mutex *state_mutex; /* either own_state_mutex or first_peer_device(device)->connection->cstate_mutex */
39481 char congestion_reason; /* Why we where congested... */
39482- atomic_t rs_sect_in; /* for incoming resync data rate, SyncTarget */
39483- atomic_t rs_sect_ev; /* for submitted resync data rate, both */
39484+ atomic_unchecked_t rs_sect_in; /* for incoming resync data rate, SyncTarget */
39485+ atomic_unchecked_t rs_sect_ev; /* for submitted resync data rate, both */
39486 int rs_last_sect_ev; /* counter to compare with */
39487 int rs_last_events; /* counter of read or write "events" (unit sectors)
39488 * on the lower level device when we last looked. */
39489diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
39490index a151853..b9b5baa 100644
39491--- a/drivers/block/drbd/drbd_main.c
39492+++ b/drivers/block/drbd/drbd_main.c
39493@@ -1328,7 +1328,7 @@ static int _drbd_send_ack(struct drbd_peer_device *peer_device, enum drbd_packet
39494 p->sector = sector;
39495 p->block_id = block_id;
39496 p->blksize = blksize;
39497- p->seq_num = cpu_to_be32(atomic_inc_return(&peer_device->device->packet_seq));
39498+ p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&peer_device->device->packet_seq));
39499 return drbd_send_command(peer_device, sock, cmd, sizeof(*p), NULL, 0);
39500 }
39501
39502@@ -1634,7 +1634,7 @@ int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request *
39503 return -EIO;
39504 p->sector = cpu_to_be64(req->i.sector);
39505 p->block_id = (unsigned long)req;
39506- p->seq_num = cpu_to_be32(atomic_inc_return(&device->packet_seq));
39507+ p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&device->packet_seq));
39508 dp_flags = bio_flags_to_wire(peer_device->connection, req->master_bio->bi_rw);
39509 if (device->state.conn >= C_SYNC_SOURCE &&
39510 device->state.conn <= C_PAUSED_SYNC_T)
39511@@ -1915,8 +1915,8 @@ void drbd_init_set_defaults(struct drbd_device *device)
39512 atomic_set(&device->unacked_cnt, 0);
39513 atomic_set(&device->local_cnt, 0);
39514 atomic_set(&device->pp_in_use_by_net, 0);
39515- atomic_set(&device->rs_sect_in, 0);
39516- atomic_set(&device->rs_sect_ev, 0);
39517+ atomic_set_unchecked(&device->rs_sect_in, 0);
39518+ atomic_set_unchecked(&device->rs_sect_ev, 0);
39519 atomic_set(&device->ap_in_flight, 0);
39520 atomic_set(&device->md_io.in_use, 0);
39521
39522@@ -2683,8 +2683,8 @@ void drbd_destroy_connection(struct kref *kref)
39523 struct drbd_connection *connection = container_of(kref, struct drbd_connection, kref);
39524 struct drbd_resource *resource = connection->resource;
39525
39526- if (atomic_read(&connection->current_epoch->epoch_size) != 0)
39527- drbd_err(connection, "epoch_size:%d\n", atomic_read(&connection->current_epoch->epoch_size));
39528+ if (atomic_read_unchecked(&connection->current_epoch->epoch_size) != 0)
39529+ drbd_err(connection, "epoch_size:%d\n", atomic_read_unchecked(&connection->current_epoch->epoch_size));
39530 kfree(connection->current_epoch);
39531
39532 idr_destroy(&connection->peer_devices);
39533diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
39534index 74df8cf..e41fc24 100644
39535--- a/drivers/block/drbd/drbd_nl.c
39536+++ b/drivers/block/drbd/drbd_nl.c
39537@@ -3637,13 +3637,13 @@ finish:
39538
39539 void drbd_bcast_event(struct drbd_device *device, const struct sib_info *sib)
39540 {
39541- static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
39542+ static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
39543 struct sk_buff *msg;
39544 struct drbd_genlmsghdr *d_out;
39545 unsigned seq;
39546 int err = -ENOMEM;
39547
39548- seq = atomic_inc_return(&drbd_genl_seq);
39549+ seq = atomic_inc_return_unchecked(&drbd_genl_seq);
39550 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
39551 if (!msg)
39552 goto failed;
39553diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
39554index c097909..13688e1 100644
39555--- a/drivers/block/drbd/drbd_receiver.c
39556+++ b/drivers/block/drbd/drbd_receiver.c
39557@@ -870,7 +870,7 @@ int drbd_connected(struct drbd_peer_device *peer_device)
39558 struct drbd_device *device = peer_device->device;
39559 int err;
39560
39561- atomic_set(&device->packet_seq, 0);
39562+ atomic_set_unchecked(&device->packet_seq, 0);
39563 device->peer_seq = 0;
39564
39565 device->state_mutex = peer_device->connection->agreed_pro_version < 100 ?
39566@@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connectio
39567 do {
39568 next_epoch = NULL;
39569
39570- epoch_size = atomic_read(&epoch->epoch_size);
39571+ epoch_size = atomic_read_unchecked(&epoch->epoch_size);
39572
39573 switch (ev & ~EV_CLEANUP) {
39574 case EV_PUT:
39575@@ -1273,7 +1273,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connectio
39576 rv = FE_DESTROYED;
39577 } else {
39578 epoch->flags = 0;
39579- atomic_set(&epoch->epoch_size, 0);
39580+ atomic_set_unchecked(&epoch->epoch_size, 0);
39581 /* atomic_set(&epoch->active, 0); is already zero */
39582 if (rv == FE_STILL_LIVE)
39583 rv = FE_RECYCLED;
39584@@ -1550,7 +1550,7 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
39585 conn_wait_active_ee_empty(connection);
39586 drbd_flush(connection);
39587
39588- if (atomic_read(&connection->current_epoch->epoch_size)) {
39589+ if (atomic_read_unchecked(&connection->current_epoch->epoch_size)) {
39590 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
39591 if (epoch)
39592 break;
39593@@ -1564,11 +1564,11 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
39594 }
39595
39596 epoch->flags = 0;
39597- atomic_set(&epoch->epoch_size, 0);
39598+ atomic_set_unchecked(&epoch->epoch_size, 0);
39599 atomic_set(&epoch->active, 0);
39600
39601 spin_lock(&connection->epoch_lock);
39602- if (atomic_read(&connection->current_epoch->epoch_size)) {
39603+ if (atomic_read_unchecked(&connection->current_epoch->epoch_size)) {
39604 list_add(&epoch->list, &connection->current_epoch->list);
39605 connection->current_epoch = epoch;
39606 connection->epochs++;
39607@@ -1802,7 +1802,7 @@ static int recv_resync_read(struct drbd_peer_device *peer_device, sector_t secto
39608 list_add_tail(&peer_req->w.list, &device->sync_ee);
39609 spin_unlock_irq(&device->resource->req_lock);
39610
39611- atomic_add(pi->size >> 9, &device->rs_sect_ev);
39612+ atomic_add_unchecked(pi->size >> 9, &device->rs_sect_ev);
39613 if (drbd_submit_peer_request(device, peer_req, WRITE, DRBD_FAULT_RS_WR) == 0)
39614 return 0;
39615
39616@@ -1900,7 +1900,7 @@ static int receive_RSDataReply(struct drbd_connection *connection, struct packet
39617 drbd_send_ack_dp(peer_device, P_NEG_ACK, p, pi->size);
39618 }
39619
39620- atomic_add(pi->size >> 9, &device->rs_sect_in);
39621+ atomic_add_unchecked(pi->size >> 9, &device->rs_sect_in);
39622
39623 return err;
39624 }
39625@@ -2290,7 +2290,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *
39626
39627 err = wait_for_and_update_peer_seq(peer_device, peer_seq);
39628 drbd_send_ack_dp(peer_device, P_NEG_ACK, p, pi->size);
39629- atomic_inc(&connection->current_epoch->epoch_size);
39630+ atomic_inc_unchecked(&connection->current_epoch->epoch_size);
39631 err2 = drbd_drain_block(peer_device, pi->size);
39632 if (!err)
39633 err = err2;
39634@@ -2334,7 +2334,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *
39635
39636 spin_lock(&connection->epoch_lock);
39637 peer_req->epoch = connection->current_epoch;
39638- atomic_inc(&peer_req->epoch->epoch_size);
39639+ atomic_inc_unchecked(&peer_req->epoch->epoch_size);
39640 atomic_inc(&peer_req->epoch->active);
39641 spin_unlock(&connection->epoch_lock);
39642
39643@@ -2479,7 +2479,7 @@ bool drbd_rs_c_min_rate_throttle(struct drbd_device *device)
39644
39645 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
39646 (int)part_stat_read(&disk->part0, sectors[1]) -
39647- atomic_read(&device->rs_sect_ev);
39648+ atomic_read_unchecked(&device->rs_sect_ev);
39649
39650 if (atomic_read(&device->ap_actlog_cnt)
39651 || curr_events - device->rs_last_events > 64) {
39652@@ -2618,7 +2618,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet
39653 device->use_csums = true;
39654 } else if (pi->cmd == P_OV_REPLY) {
39655 /* track progress, we may need to throttle */
39656- atomic_add(size >> 9, &device->rs_sect_in);
39657+ atomic_add_unchecked(size >> 9, &device->rs_sect_in);
39658 peer_req->w.cb = w_e_end_ov_reply;
39659 dec_rs_pending(device);
39660 /* drbd_rs_begin_io done when we sent this request,
39661@@ -2691,7 +2691,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet
39662 goto out_free_e;
39663
39664 submit_for_resync:
39665- atomic_add(size >> 9, &device->rs_sect_ev);
39666+ atomic_add_unchecked(size >> 9, &device->rs_sect_ev);
39667
39668 submit:
39669 update_receiver_timing_details(connection, drbd_submit_peer_request);
39670@@ -4564,7 +4564,7 @@ struct data_cmd {
39671 int expect_payload;
39672 size_t pkt_size;
39673 int (*fn)(struct drbd_connection *, struct packet_info *);
39674-};
39675+} __do_const;
39676
39677 static struct data_cmd drbd_cmd_handler[] = {
39678 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
39679@@ -4678,7 +4678,7 @@ static void conn_disconnect(struct drbd_connection *connection)
39680 if (!list_empty(&connection->current_epoch->list))
39681 drbd_err(connection, "ASSERTION FAILED: connection->current_epoch->list not empty\n");
39682 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
39683- atomic_set(&connection->current_epoch->epoch_size, 0);
39684+ atomic_set_unchecked(&connection->current_epoch->epoch_size, 0);
39685 connection->send.seen_any_write_yet = false;
39686
39687 drbd_info(connection, "Connection closed\n");
39688@@ -5182,7 +5182,7 @@ static int got_IsInSync(struct drbd_connection *connection, struct packet_info *
39689 put_ldev(device);
39690 }
39691 dec_rs_pending(device);
39692- atomic_add(blksize >> 9, &device->rs_sect_in);
39693+ atomic_add_unchecked(blksize >> 9, &device->rs_sect_in);
39694
39695 return 0;
39696 }
39697@@ -5470,7 +5470,7 @@ static int connection_finish_peer_reqs(struct drbd_connection *connection)
39698 struct asender_cmd {
39699 size_t pkt_size;
39700 int (*fn)(struct drbd_connection *connection, struct packet_info *);
39701-};
39702+} __do_const;
39703
39704 static struct asender_cmd asender_tbl[] = {
39705 [P_PING] = { 0, got_Ping },
39706diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
39707index d0fae55..4469096 100644
39708--- a/drivers/block/drbd/drbd_worker.c
39709+++ b/drivers/block/drbd/drbd_worker.c
39710@@ -408,7 +408,7 @@ static int read_for_csum(struct drbd_peer_device *peer_device, sector_t sector,
39711 list_add_tail(&peer_req->w.list, &device->read_ee);
39712 spin_unlock_irq(&device->resource->req_lock);
39713
39714- atomic_add(size >> 9, &device->rs_sect_ev);
39715+ atomic_add_unchecked(size >> 9, &device->rs_sect_ev);
39716 if (drbd_submit_peer_request(device, peer_req, READ, DRBD_FAULT_RS_RD) == 0)
39717 return 0;
39718
39719@@ -553,7 +553,7 @@ static int drbd_rs_number_requests(struct drbd_device *device)
39720 unsigned int sect_in; /* Number of sectors that came in since the last turn */
39721 int number, mxb;
39722
39723- sect_in = atomic_xchg(&device->rs_sect_in, 0);
39724+ sect_in = atomic_xchg_unchecked(&device->rs_sect_in, 0);
39725 device->rs_in_flight -= sect_in;
39726
39727 rcu_read_lock();
39728@@ -1595,8 +1595,8 @@ void drbd_rs_controller_reset(struct drbd_device *device)
39729 struct gendisk *disk = device->ldev->backing_bdev->bd_contains->bd_disk;
39730 struct fifo_buffer *plan;
39731
39732- atomic_set(&device->rs_sect_in, 0);
39733- atomic_set(&device->rs_sect_ev, 0);
39734+ atomic_set_unchecked(&device->rs_sect_in, 0);
39735+ atomic_set_unchecked(&device->rs_sect_ev, 0);
39736 device->rs_in_flight = 0;
39737 device->rs_last_events =
39738 (int)part_stat_read(&disk->part0, sectors[0]) +
39739diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
39740index 4c20c22..caef1eb 100644
39741--- a/drivers/block/pktcdvd.c
39742+++ b/drivers/block/pktcdvd.c
39743@@ -109,7 +109,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
39744
39745 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
39746 {
39747- return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
39748+ return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
39749 }
39750
39751 /*
39752@@ -1891,7 +1891,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
39753 return -EROFS;
39754 }
39755 pd->settings.fp = ti.fp;
39756- pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
39757+ pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
39758
39759 if (ti.nwa_v) {
39760 pd->nwa = be32_to_cpu(ti.next_writable);
39761diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
39762index 324bf35..02b54e6 100644
39763--- a/drivers/block/rbd.c
39764+++ b/drivers/block/rbd.c
39765@@ -64,7 +64,7 @@
39766 * If the counter is already at its maximum value returns
39767 * -EINVAL without updating it.
39768 */
39769-static int atomic_inc_return_safe(atomic_t *v)
39770+static int __intentional_overflow(-1) atomic_inc_return_safe(atomic_t *v)
39771 {
39772 unsigned int counter;
39773
39774diff --git a/drivers/block/smart1,2.h b/drivers/block/smart1,2.h
39775index e5565fb..71be10b4 100644
39776--- a/drivers/block/smart1,2.h
39777+++ b/drivers/block/smart1,2.h
39778@@ -108,11 +108,11 @@ static unsigned long smart4_intr_pending(ctlr_info_t *h)
39779 }
39780
39781 static struct access_method smart4_access = {
39782- smart4_submit_command,
39783- smart4_intr_mask,
39784- smart4_fifo_full,
39785- smart4_intr_pending,
39786- smart4_completed,
39787+ .submit_command = smart4_submit_command,
39788+ .set_intr_mask = smart4_intr_mask,
39789+ .fifo_full = smart4_fifo_full,
39790+ .intr_pending = smart4_intr_pending,
39791+ .command_completed = smart4_completed,
39792 };
39793
39794 /*
39795@@ -144,11 +144,11 @@ static unsigned long smart2_intr_pending(ctlr_info_t *h)
39796 }
39797
39798 static struct access_method smart2_access = {
39799- smart2_submit_command,
39800- smart2_intr_mask,
39801- smart2_fifo_full,
39802- smart2_intr_pending,
39803- smart2_completed,
39804+ .submit_command = smart2_submit_command,
39805+ .set_intr_mask = smart2_intr_mask,
39806+ .fifo_full = smart2_fifo_full,
39807+ .intr_pending = smart2_intr_pending,
39808+ .command_completed = smart2_completed,
39809 };
39810
39811 /*
39812@@ -180,11 +180,11 @@ static unsigned long smart2e_intr_pending(ctlr_info_t *h)
39813 }
39814
39815 static struct access_method smart2e_access = {
39816- smart2e_submit_command,
39817- smart2e_intr_mask,
39818- smart2e_fifo_full,
39819- smart2e_intr_pending,
39820- smart2e_completed,
39821+ .submit_command = smart2e_submit_command,
39822+ .set_intr_mask = smart2e_intr_mask,
39823+ .fifo_full = smart2e_fifo_full,
39824+ .intr_pending = smart2e_intr_pending,
39825+ .command_completed = smart2e_completed,
39826 };
39827
39828 /*
39829@@ -270,9 +270,9 @@ static unsigned long smart1_intr_pending(ctlr_info_t *h)
39830 }
39831
39832 static struct access_method smart1_access = {
39833- smart1_submit_command,
39834- smart1_intr_mask,
39835- smart1_fifo_full,
39836- smart1_intr_pending,
39837- smart1_completed,
39838+ .submit_command = smart1_submit_command,
39839+ .set_intr_mask = smart1_intr_mask,
39840+ .fifo_full = smart1_fifo_full,
39841+ .intr_pending = smart1_intr_pending,
39842+ .command_completed = smart1_completed,
39843 };
39844diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
39845index 7a722df..54b76ab 100644
39846--- a/drivers/bluetooth/btwilink.c
39847+++ b/drivers/bluetooth/btwilink.c
39848@@ -288,7 +288,7 @@ static int ti_st_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
39849
39850 static int bt_ti_probe(struct platform_device *pdev)
39851 {
39852- static struct ti_st *hst;
39853+ struct ti_st *hst;
39854 struct hci_dev *hdev;
39855 int err;
39856
39857diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
39858index 5d28a45..a538f90 100644
39859--- a/drivers/cdrom/cdrom.c
39860+++ b/drivers/cdrom/cdrom.c
39861@@ -610,7 +610,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
39862 ENSURE(reset, CDC_RESET);
39863 ENSURE(generic_packet, CDC_GENERIC_PACKET);
39864 cdi->mc_flags = 0;
39865- cdo->n_minors = 0;
39866 cdi->options = CDO_USE_FFLAGS;
39867
39868 if (autoclose == 1 && CDROM_CAN(CDC_CLOSE_TRAY))
39869@@ -630,8 +629,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
39870 else
39871 cdi->cdda_method = CDDA_OLD;
39872
39873- if (!cdo->generic_packet)
39874- cdo->generic_packet = cdrom_dummy_generic_packet;
39875+ if (!cdo->generic_packet) {
39876+ pax_open_kernel();
39877+ *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
39878+ pax_close_kernel();
39879+ }
39880
39881 cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
39882 mutex_lock(&cdrom_mutex);
39883@@ -652,7 +654,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
39884 if (cdi->exit)
39885 cdi->exit(cdi);
39886
39887- cdi->ops->n_minors--;
39888 cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
39889 }
39890
39891@@ -2126,7 +2127,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
39892 */
39893 nr = nframes;
39894 do {
39895- cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
39896+ cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
39897 if (cgc.buffer)
39898 break;
39899
39900@@ -3434,7 +3435,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
39901 struct cdrom_device_info *cdi;
39902 int ret;
39903
39904- ret = scnprintf(info + *pos, max_size - *pos, header);
39905+ ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
39906 if (!ret)
39907 return 1;
39908
39909diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
39910index 584bc31..e64a12c 100644
39911--- a/drivers/cdrom/gdrom.c
39912+++ b/drivers/cdrom/gdrom.c
39913@@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
39914 .audio_ioctl = gdrom_audio_ioctl,
39915 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
39916 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
39917- .n_minors = 1,
39918 };
39919
39920 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
39921diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
39922index a043107..1263e4a 100644
39923--- a/drivers/char/Kconfig
39924+++ b/drivers/char/Kconfig
39925@@ -17,7 +17,8 @@ config DEVMEM
39926
39927 config DEVKMEM
39928 bool "/dev/kmem virtual device support"
39929- default y
39930+ default n
39931+ depends on !GRKERNSEC_KMEM
39932 help
39933 Say Y here if you want to support the /dev/kmem device. The
39934 /dev/kmem device is rarely used, but can be used for certain
39935@@ -586,6 +587,7 @@ config DEVPORT
39936 bool
39937 depends on !M68K
39938 depends on ISA || PCI
39939+ depends on !GRKERNSEC_KMEM
39940 default y
39941
39942 source "drivers/s390/char/Kconfig"
39943diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
39944index a48e05b..6bac831 100644
39945--- a/drivers/char/agp/compat_ioctl.c
39946+++ b/drivers/char/agp/compat_ioctl.c
39947@@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
39948 return -ENOMEM;
39949 }
39950
39951- if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
39952+ if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
39953 sizeof(*usegment) * ureserve.seg_count)) {
39954 kfree(usegment);
39955 kfree(ksegment);
39956diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
39957index 09f17eb..8531d2f 100644
39958--- a/drivers/char/agp/frontend.c
39959+++ b/drivers/char/agp/frontend.c
39960@@ -806,7 +806,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
39961 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
39962 return -EFAULT;
39963
39964- if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
39965+ if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
39966 return -EFAULT;
39967
39968 client = agp_find_client_by_pid(reserve.pid);
39969@@ -836,7 +836,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
39970 if (segment == NULL)
39971 return -ENOMEM;
39972
39973- if (copy_from_user(segment, (void __user *) reserve.seg_list,
39974+ if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
39975 sizeof(struct agp_segment) * reserve.seg_count)) {
39976 kfree(segment);
39977 return -EFAULT;
39978diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
39979index c6dea3f..72ae4b0 100644
39980--- a/drivers/char/agp/intel-gtt.c
39981+++ b/drivers/char/agp/intel-gtt.c
39982@@ -1408,8 +1408,8 @@ int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
39983 }
39984 EXPORT_SYMBOL(intel_gmch_probe);
39985
39986-void intel_gtt_get(size_t *gtt_total, size_t *stolen_size,
39987- phys_addr_t *mappable_base, unsigned long *mappable_end)
39988+void intel_gtt_get(uint64_t *gtt_total, uint64_t *stolen_size,
39989+ uint64_t *mappable_base, uint64_t *mappable_end)
39990 {
39991 *gtt_total = intel_private.gtt_total_entries << PAGE_SHIFT;
39992 *stolen_size = intel_private.stolen_size;
39993diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
39994index 4f94375..413694e 100644
39995--- a/drivers/char/genrtc.c
39996+++ b/drivers/char/genrtc.c
39997@@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
39998 switch (cmd) {
39999
40000 case RTC_PLL_GET:
40001+ memset(&pll, 0, sizeof(pll));
40002 if (get_rtc_pll(&pll))
40003 return -EINVAL;
40004 else
40005diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
40006index 5c0baa9..44011b1 100644
40007--- a/drivers/char/hpet.c
40008+++ b/drivers/char/hpet.c
40009@@ -575,7 +575,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
40010 }
40011
40012 static int
40013-hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
40014+hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
40015 struct hpet_info *info)
40016 {
40017 struct hpet_timer __iomem *timer;
40018diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
40019index bf75f63..359fa10 100644
40020--- a/drivers/char/ipmi/ipmi_msghandler.c
40021+++ b/drivers/char/ipmi/ipmi_msghandler.c
40022@@ -436,7 +436,7 @@ struct ipmi_smi {
40023 struct proc_dir_entry *proc_dir;
40024 char proc_dir_name[10];
40025
40026- atomic_t stats[IPMI_NUM_STATS];
40027+ atomic_unchecked_t stats[IPMI_NUM_STATS];
40028
40029 /*
40030 * run_to_completion duplicate of smb_info, smi_info
40031@@ -468,9 +468,9 @@ static LIST_HEAD(smi_watchers);
40032 static DEFINE_MUTEX(smi_watchers_mutex);
40033
40034 #define ipmi_inc_stat(intf, stat) \
40035- atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
40036+ atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
40037 #define ipmi_get_stat(intf, stat) \
40038- ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
40039+ ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
40040
40041 static char *addr_src_to_str[] = { "invalid", "hotmod", "hardcoded", "SPMI",
40042 "ACPI", "SMBIOS", "PCI",
40043@@ -2828,7 +2828,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
40044 INIT_LIST_HEAD(&intf->cmd_rcvrs);
40045 init_waitqueue_head(&intf->waitq);
40046 for (i = 0; i < IPMI_NUM_STATS; i++)
40047- atomic_set(&intf->stats[i], 0);
40048+ atomic_set_unchecked(&intf->stats[i], 0);
40049
40050 intf->proc_dir = NULL;
40051
40052diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
40053index 8a45e92..e41b1c7 100644
40054--- a/drivers/char/ipmi/ipmi_si_intf.c
40055+++ b/drivers/char/ipmi/ipmi_si_intf.c
40056@@ -289,7 +289,7 @@ struct smi_info {
40057 unsigned char slave_addr;
40058
40059 /* Counters and things for the proc filesystem. */
40060- atomic_t stats[SI_NUM_STATS];
40061+ atomic_unchecked_t stats[SI_NUM_STATS];
40062
40063 struct task_struct *thread;
40064
40065@@ -298,9 +298,9 @@ struct smi_info {
40066 };
40067
40068 #define smi_inc_stat(smi, stat) \
40069- atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
40070+ atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
40071 #define smi_get_stat(smi, stat) \
40072- ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
40073+ ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
40074
40075 #define SI_MAX_PARMS 4
40076
40077@@ -3500,7 +3500,7 @@ static int try_smi_init(struct smi_info *new_smi)
40078 atomic_set(&new_smi->req_events, 0);
40079 new_smi->run_to_completion = false;
40080 for (i = 0; i < SI_NUM_STATS; i++)
40081- atomic_set(&new_smi->stats[i], 0);
40082+ atomic_set_unchecked(&new_smi->stats[i], 0);
40083
40084 new_smi->interrupt_disabled = true;
40085 atomic_set(&new_smi->need_watch, 0);
40086diff --git a/drivers/char/mem.c b/drivers/char/mem.c
40087index 6b1721f..fda9398 100644
40088--- a/drivers/char/mem.c
40089+++ b/drivers/char/mem.c
40090@@ -18,6 +18,7 @@
40091 #include <linux/raw.h>
40092 #include <linux/tty.h>
40093 #include <linux/capability.h>
40094+#include <linux/security.h>
40095 #include <linux/ptrace.h>
40096 #include <linux/device.h>
40097 #include <linux/highmem.h>
40098@@ -36,6 +37,10 @@
40099
40100 #define DEVPORT_MINOR 4
40101
40102+#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
40103+extern const struct file_operations grsec_fops;
40104+#endif
40105+
40106 static inline unsigned long size_inside_page(unsigned long start,
40107 unsigned long size)
40108 {
40109@@ -67,9 +72,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
40110
40111 while (cursor < to) {
40112 if (!devmem_is_allowed(pfn)) {
40113+#ifdef CONFIG_GRKERNSEC_KMEM
40114+ gr_handle_mem_readwrite(from, to);
40115+#else
40116 printk(KERN_INFO
40117 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
40118 current->comm, from, to);
40119+#endif
40120 return 0;
40121 }
40122 cursor += PAGE_SIZE;
40123@@ -77,6 +86,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
40124 }
40125 return 1;
40126 }
40127+#elif defined(CONFIG_GRKERNSEC_KMEM)
40128+static inline int range_is_allowed(unsigned long pfn, unsigned long size)
40129+{
40130+ return 0;
40131+}
40132 #else
40133 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
40134 {
40135@@ -124,7 +138,8 @@ static ssize_t read_mem(struct file *file, char __user *buf,
40136 #endif
40137
40138 while (count > 0) {
40139- unsigned long remaining;
40140+ unsigned long remaining = 0;
40141+ char *temp;
40142
40143 sz = size_inside_page(p, count);
40144
40145@@ -140,7 +155,24 @@ static ssize_t read_mem(struct file *file, char __user *buf,
40146 if (!ptr)
40147 return -EFAULT;
40148
40149- remaining = copy_to_user(buf, ptr, sz);
40150+#ifdef CONFIG_PAX_USERCOPY
40151+ temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
40152+ if (!temp) {
40153+ unxlate_dev_mem_ptr(p, ptr);
40154+ return -ENOMEM;
40155+ }
40156+ remaining = probe_kernel_read(temp, ptr, sz);
40157+#else
40158+ temp = ptr;
40159+#endif
40160+
40161+ if (!remaining)
40162+ remaining = copy_to_user(buf, temp, sz);
40163+
40164+#ifdef CONFIG_PAX_USERCOPY
40165+ kfree(temp);
40166+#endif
40167+
40168 unxlate_dev_mem_ptr(p, ptr);
40169 if (remaining)
40170 return -EFAULT;
40171@@ -380,9 +412,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
40172 size_t count, loff_t *ppos)
40173 {
40174 unsigned long p = *ppos;
40175- ssize_t low_count, read, sz;
40176+ ssize_t low_count, read, sz, err = 0;
40177 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
40178- int err = 0;
40179
40180 read = 0;
40181 if (p < (unsigned long) high_memory) {
40182@@ -404,6 +435,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
40183 }
40184 #endif
40185 while (low_count > 0) {
40186+ char *temp;
40187+
40188 sz = size_inside_page(p, low_count);
40189
40190 /*
40191@@ -413,7 +446,23 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
40192 */
40193 kbuf = xlate_dev_kmem_ptr((void *)p);
40194
40195- if (copy_to_user(buf, kbuf, sz))
40196+#ifdef CONFIG_PAX_USERCOPY
40197+ temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
40198+ if (!temp)
40199+ return -ENOMEM;
40200+ err = probe_kernel_read(temp, kbuf, sz);
40201+#else
40202+ temp = kbuf;
40203+#endif
40204+
40205+ if (!err)
40206+ err = copy_to_user(buf, temp, sz);
40207+
40208+#ifdef CONFIG_PAX_USERCOPY
40209+ kfree(temp);
40210+#endif
40211+
40212+ if (err)
40213 return -EFAULT;
40214 buf += sz;
40215 p += sz;
40216@@ -802,6 +851,9 @@ static const struct memdev {
40217 #ifdef CONFIG_PRINTK
40218 [11] = { "kmsg", 0644, &kmsg_fops, 0 },
40219 #endif
40220+#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
40221+ [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, 0 },
40222+#endif
40223 };
40224
40225 static int memory_open(struct inode *inode, struct file *filp)
40226@@ -863,7 +915,7 @@ static int __init chr_dev_init(void)
40227 continue;
40228
40229 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
40230- NULL, devlist[minor].name);
40231+ NULL, "%s", devlist[minor].name);
40232 }
40233
40234 return tty_init();
40235diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
40236index 9df78e2..01ba9ae 100644
40237--- a/drivers/char/nvram.c
40238+++ b/drivers/char/nvram.c
40239@@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
40240
40241 spin_unlock_irq(&rtc_lock);
40242
40243- if (copy_to_user(buf, contents, tmp - contents))
40244+ if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
40245 return -EFAULT;
40246
40247 *ppos = i;
40248diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
40249index 7680d52..073f799e 100644
40250--- a/drivers/char/pcmcia/synclink_cs.c
40251+++ b/drivers/char/pcmcia/synclink_cs.c
40252@@ -2345,7 +2345,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
40253
40254 if (debug_level >= DEBUG_LEVEL_INFO)
40255 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
40256- __FILE__, __LINE__, info->device_name, port->count);
40257+ __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
40258
40259 if (tty_port_close_start(port, tty, filp) == 0)
40260 goto cleanup;
40261@@ -2363,7 +2363,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
40262 cleanup:
40263 if (debug_level >= DEBUG_LEVEL_INFO)
40264 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
40265- tty->driver->name, port->count);
40266+ tty->driver->name, atomic_read(&port->count));
40267 }
40268
40269 /* Wait until the transmitter is empty.
40270@@ -2505,7 +2505,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
40271
40272 if (debug_level >= DEBUG_LEVEL_INFO)
40273 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
40274- __FILE__, __LINE__, tty->driver->name, port->count);
40275+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
40276
40277 /* If port is closing, signal caller to try again */
40278 if (port->flags & ASYNC_CLOSING){
40279@@ -2525,11 +2525,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
40280 goto cleanup;
40281 }
40282 spin_lock(&port->lock);
40283- port->count++;
40284+ atomic_inc(&port->count);
40285 spin_unlock(&port->lock);
40286 spin_unlock_irqrestore(&info->netlock, flags);
40287
40288- if (port->count == 1) {
40289+ if (atomic_read(&port->count) == 1) {
40290 /* 1st open on this device, init hardware */
40291 retval = startup(info, tty);
40292 if (retval < 0)
40293@@ -3918,7 +3918,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
40294 unsigned short new_crctype;
40295
40296 /* return error if TTY interface open */
40297- if (info->port.count)
40298+ if (atomic_read(&info->port.count))
40299 return -EBUSY;
40300
40301 switch (encoding)
40302@@ -4022,7 +4022,7 @@ static int hdlcdev_open(struct net_device *dev)
40303
40304 /* arbitrate between network and tty opens */
40305 spin_lock_irqsave(&info->netlock, flags);
40306- if (info->port.count != 0 || info->netcount != 0) {
40307+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
40308 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
40309 spin_unlock_irqrestore(&info->netlock, flags);
40310 return -EBUSY;
40311@@ -4112,7 +4112,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40312 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
40313
40314 /* return error if TTY interface open */
40315- if (info->port.count)
40316+ if (atomic_read(&info->port.count))
40317 return -EBUSY;
40318
40319 if (cmd != SIOCWANDEV)
40320diff --git a/drivers/char/random.c b/drivers/char/random.c
40321index d0da5d8..739fd3a 100644
40322--- a/drivers/char/random.c
40323+++ b/drivers/char/random.c
40324@@ -289,9 +289,6 @@
40325 /*
40326 * To allow fractional bits to be tracked, the entropy_count field is
40327 * denominated in units of 1/8th bits.
40328- *
40329- * 2*(ENTROPY_SHIFT + log2(poolbits)) must <= 31, or the multiply in
40330- * credit_entropy_bits() needs to be 64 bits wide.
40331 */
40332 #define ENTROPY_SHIFT 3
40333 #define ENTROPY_BITS(r) ((r)->entropy_count >> ENTROPY_SHIFT)
40334@@ -442,9 +439,9 @@ struct entropy_store {
40335 };
40336
40337 static void push_to_pool(struct work_struct *work);
40338-static __u32 input_pool_data[INPUT_POOL_WORDS];
40339-static __u32 blocking_pool_data[OUTPUT_POOL_WORDS];
40340-static __u32 nonblocking_pool_data[OUTPUT_POOL_WORDS];
40341+static __u32 input_pool_data[INPUT_POOL_WORDS] __latent_entropy;
40342+static __u32 blocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
40343+static __u32 nonblocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
40344
40345 static struct entropy_store input_pool = {
40346 .poolinfo = &poolinfo_table[0],
40347@@ -654,7 +651,7 @@ retry:
40348 /* The +2 corresponds to the /4 in the denominator */
40349
40350 do {
40351- unsigned int anfrac = min(pnfrac, pool_size/2);
40352+ u64 anfrac = min(pnfrac, pool_size/2);
40353 unsigned int add =
40354 ((pool_size - entropy_count)*anfrac*3) >> s;
40355
40356@@ -1227,7 +1224,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
40357
40358 extract_buf(r, tmp);
40359 i = min_t(int, nbytes, EXTRACT_SIZE);
40360- if (copy_to_user(buf, tmp, i)) {
40361+ if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
40362 ret = -EFAULT;
40363 break;
40364 }
40365@@ -1668,7 +1665,7 @@ static char sysctl_bootid[16];
40366 static int proc_do_uuid(struct ctl_table *table, int write,
40367 void __user *buffer, size_t *lenp, loff_t *ppos)
40368 {
40369- struct ctl_table fake_table;
40370+ ctl_table_no_const fake_table;
40371 unsigned char buf[64], tmp_uuid[16], *uuid;
40372
40373 uuid = table->data;
40374@@ -1698,7 +1695,7 @@ static int proc_do_uuid(struct ctl_table *table, int write,
40375 static int proc_do_entropy(struct ctl_table *table, int write,
40376 void __user *buffer, size_t *lenp, loff_t *ppos)
40377 {
40378- struct ctl_table fake_table;
40379+ ctl_table_no_const fake_table;
40380 int entropy_count;
40381
40382 entropy_count = *(int *)table->data >> ENTROPY_SHIFT;
40383diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
40384index e496dae..3db53b6 100644
40385--- a/drivers/char/sonypi.c
40386+++ b/drivers/char/sonypi.c
40387@@ -54,6 +54,7 @@
40388
40389 #include <asm/uaccess.h>
40390 #include <asm/io.h>
40391+#include <asm/local.h>
40392
40393 #include <linux/sonypi.h>
40394
40395@@ -490,7 +491,7 @@ static struct sonypi_device {
40396 spinlock_t fifo_lock;
40397 wait_queue_head_t fifo_proc_list;
40398 struct fasync_struct *fifo_async;
40399- int open_count;
40400+ local_t open_count;
40401 int model;
40402 struct input_dev *input_jog_dev;
40403 struct input_dev *input_key_dev;
40404@@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
40405 static int sonypi_misc_release(struct inode *inode, struct file *file)
40406 {
40407 mutex_lock(&sonypi_device.lock);
40408- sonypi_device.open_count--;
40409+ local_dec(&sonypi_device.open_count);
40410 mutex_unlock(&sonypi_device.lock);
40411 return 0;
40412 }
40413@@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
40414 {
40415 mutex_lock(&sonypi_device.lock);
40416 /* Flush input queue on first open */
40417- if (!sonypi_device.open_count)
40418+ if (!local_read(&sonypi_device.open_count))
40419 kfifo_reset(&sonypi_device.fifo);
40420- sonypi_device.open_count++;
40421+ local_inc(&sonypi_device.open_count);
40422 mutex_unlock(&sonypi_device.lock);
40423
40424 return 0;
40425@@ -1491,7 +1492,7 @@ static struct platform_driver sonypi_driver = {
40426
40427 static struct platform_device *sonypi_platform_device;
40428
40429-static struct dmi_system_id __initdata sonypi_dmi_table[] = {
40430+static const struct dmi_system_id __initconst sonypi_dmi_table[] = {
40431 {
40432 .ident = "Sony Vaio",
40433 .matches = {
40434diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
40435index 565a947..dcdc06e 100644
40436--- a/drivers/char/tpm/tpm_acpi.c
40437+++ b/drivers/char/tpm/tpm_acpi.c
40438@@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
40439 virt = acpi_os_map_iomem(start, len);
40440 if (!virt) {
40441 kfree(log->bios_event_log);
40442+ log->bios_event_log = NULL;
40443 printk("%s: ERROR - Unable to map memory\n", __func__);
40444 return -EIO;
40445 }
40446
40447- memcpy_fromio(log->bios_event_log, virt, len);
40448+ memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
40449
40450 acpi_os_unmap_iomem(virt, len);
40451 return 0;
40452diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
40453index 3a56a13..f8cbd25 100644
40454--- a/drivers/char/tpm/tpm_eventlog.c
40455+++ b/drivers/char/tpm/tpm_eventlog.c
40456@@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
40457 event = addr;
40458
40459 if ((event->event_type == 0 && event->event_size == 0) ||
40460- ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
40461+ (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
40462 return NULL;
40463
40464 return addr;
40465@@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
40466 return NULL;
40467
40468 if ((event->event_type == 0 && event->event_size == 0) ||
40469- ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
40470+ (event->event_size >= limit - v - sizeof(struct tcpa_event)))
40471 return NULL;
40472
40473 (*pos)++;
40474@@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
40475 int i;
40476
40477 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
40478- seq_putc(m, data[i]);
40479+ if (!seq_putc(m, data[i]))
40480+ return -EFAULT;
40481
40482 return 0;
40483 }
40484diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
40485index d2406fe..243951a 100644
40486--- a/drivers/char/virtio_console.c
40487+++ b/drivers/char/virtio_console.c
40488@@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char __user *out_buf,
40489 if (to_user) {
40490 ssize_t ret;
40491
40492- ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
40493+ ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
40494 if (ret)
40495 return -EFAULT;
40496 } else {
40497@@ -789,7 +789,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
40498 if (!port_has_data(port) && !port->host_connected)
40499 return 0;
40500
40501- return fill_readbuf(port, ubuf, count, true);
40502+ return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
40503 }
40504
40505 static int wait_port_writable(struct port *port, bool nonblock)
40506diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
40507index 616f5ae..747bdd0 100644
40508--- a/drivers/clk/clk-composite.c
40509+++ b/drivers/clk/clk-composite.c
40510@@ -197,7 +197,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
40511 struct clk *clk;
40512 struct clk_init_data init;
40513 struct clk_composite *composite;
40514- struct clk_ops *clk_composite_ops;
40515+ clk_ops_no_const *clk_composite_ops;
40516
40517 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
40518 if (!composite)
40519diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h
40520index b775fc2..2d45b64 100644
40521--- a/drivers/clk/samsung/clk.h
40522+++ b/drivers/clk/samsung/clk.h
40523@@ -260,7 +260,7 @@ struct samsung_gate_clock {
40524 #define GATE_DA(_id, dname, cname, pname, o, b, f, gf, a) \
40525 __GATE(_id, dname, cname, pname, o, b, f, gf, a)
40526
40527-#define PNAME(x) static const char *x[] __initdata
40528+#define PNAME(x) static const char * const x[] __initconst
40529
40530 /**
40531 * struct samsung_clk_reg_dump: register dump of clock controller registers.
40532diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
40533index 82449cd..dcfec30 100644
40534--- a/drivers/clk/socfpga/clk-gate.c
40535+++ b/drivers/clk/socfpga/clk-gate.c
40536@@ -22,6 +22,7 @@
40537 #include <linux/mfd/syscon.h>
40538 #include <linux/of.h>
40539 #include <linux/regmap.h>
40540+#include <asm/pgtable.h>
40541
40542 #include "clk.h"
40543
40544@@ -170,7 +171,7 @@ static int socfpga_clk_prepare(struct clk_hw *hwclk)
40545 return 0;
40546 }
40547
40548-static struct clk_ops gateclk_ops = {
40549+static clk_ops_no_const gateclk_ops __read_only = {
40550 .prepare = socfpga_clk_prepare,
40551 .recalc_rate = socfpga_clk_recalc_rate,
40552 .get_parent = socfpga_clk_get_parent,
40553@@ -203,8 +204,10 @@ static void __init __socfpga_gate_init(struct device_node *node,
40554 socfpga_clk->hw.reg = clk_mgr_base_addr + clk_gate[0];
40555 socfpga_clk->hw.bit_idx = clk_gate[1];
40556
40557- gateclk_ops.enable = clk_gate_ops.enable;
40558- gateclk_ops.disable = clk_gate_ops.disable;
40559+ pax_open_kernel();
40560+ *(void **)&gateclk_ops.enable = clk_gate_ops.enable;
40561+ *(void **)&gateclk_ops.disable = clk_gate_ops.disable;
40562+ pax_close_kernel();
40563 }
40564
40565 rc = of_property_read_u32(node, "fixed-divider", &fixed_div);
40566diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
40567index 8f26b52..29f2a3a 100644
40568--- a/drivers/clk/socfpga/clk-pll.c
40569+++ b/drivers/clk/socfpga/clk-pll.c
40570@@ -21,6 +21,7 @@
40571 #include <linux/io.h>
40572 #include <linux/of.h>
40573 #include <linux/of_address.h>
40574+#include <asm/pgtable.h>
40575
40576 #include "clk.h"
40577
40578@@ -76,7 +77,7 @@ static u8 clk_pll_get_parent(struct clk_hw *hwclk)
40579 CLK_MGR_PLL_CLK_SRC_MASK;
40580 }
40581
40582-static struct clk_ops clk_pll_ops = {
40583+static clk_ops_no_const clk_pll_ops __read_only = {
40584 .recalc_rate = clk_pll_recalc_rate,
40585 .get_parent = clk_pll_get_parent,
40586 };
40587@@ -115,8 +116,10 @@ static __init struct clk *__socfpga_pll_init(struct device_node *node,
40588 pll_clk->hw.hw.init = &init;
40589
40590 pll_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
40591- clk_pll_ops.enable = clk_gate_ops.enable;
40592- clk_pll_ops.disable = clk_gate_ops.disable;
40593+ pax_open_kernel();
40594+ *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
40595+ *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
40596+ pax_close_kernel();
40597
40598 clk = clk_register(NULL, &pll_clk->hw.hw);
40599 if (WARN_ON(IS_ERR(clk))) {
40600diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
40601index 7c2a738..0b84bd6 100644
40602--- a/drivers/cpufreq/acpi-cpufreq.c
40603+++ b/drivers/cpufreq/acpi-cpufreq.c
40604@@ -678,8 +678,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
40605 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
40606 per_cpu(acfreq_data, cpu) = data;
40607
40608- if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
40609- acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
40610+ if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
40611+ pax_open_kernel();
40612+ *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
40613+ pax_close_kernel();
40614+ }
40615
40616 result = acpi_processor_register_performance(data->acpi_data, cpu);
40617 if (result)
40618@@ -813,7 +816,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
40619 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
40620 break;
40621 case ACPI_ADR_SPACE_FIXED_HARDWARE:
40622- acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
40623+ pax_open_kernel();
40624+ *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
40625+ pax_close_kernel();
40626 break;
40627 default:
40628 break;
40629@@ -907,8 +912,10 @@ static void __init acpi_cpufreq_boost_init(void)
40630 if (!msrs)
40631 return;
40632
40633- acpi_cpufreq_driver.boost_supported = true;
40634- acpi_cpufreq_driver.boost_enabled = boost_state(0);
40635+ pax_open_kernel();
40636+ *(bool *)&acpi_cpufreq_driver.boost_supported = true;
40637+ *(bool *)&acpi_cpufreq_driver.boost_enabled = boost_state(0);
40638+ pax_close_kernel();
40639
40640 cpu_notifier_register_begin();
40641
40642diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
40643index 99a4065..f97236c 100644
40644--- a/drivers/cpufreq/cpufreq-dt.c
40645+++ b/drivers/cpufreq/cpufreq-dt.c
40646@@ -393,7 +393,9 @@ static int dt_cpufreq_probe(struct platform_device *pdev)
40647 if (!IS_ERR(cpu_reg))
40648 regulator_put(cpu_reg);
40649
40650- dt_cpufreq_driver.driver_data = dev_get_platdata(&pdev->dev);
40651+ pax_open_kernel();
40652+ *(void **)&dt_cpufreq_driver.driver_data = dev_get_platdata(&pdev->dev);
40653+ pax_close_kernel();
40654
40655 ret = cpufreq_register_driver(&dt_cpufreq_driver);
40656 if (ret)
40657diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
40658index 7a3c30c..bac142e 100644
40659--- a/drivers/cpufreq/cpufreq.c
40660+++ b/drivers/cpufreq/cpufreq.c
40661@@ -2197,7 +2197,7 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor)
40662 read_unlock_irqrestore(&cpufreq_driver_lock, flags);
40663
40664 mutex_lock(&cpufreq_governor_mutex);
40665- list_del(&governor->governor_list);
40666+ pax_list_del(&governor->governor_list);
40667 mutex_unlock(&cpufreq_governor_mutex);
40668 return;
40669 }
40670@@ -2412,7 +2412,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
40671 return NOTIFY_OK;
40672 }
40673
40674-static struct notifier_block __refdata cpufreq_cpu_notifier = {
40675+static struct notifier_block cpufreq_cpu_notifier = {
40676 .notifier_call = cpufreq_cpu_callback,
40677 };
40678
40679@@ -2452,13 +2452,17 @@ int cpufreq_boost_trigger_state(int state)
40680 return 0;
40681
40682 write_lock_irqsave(&cpufreq_driver_lock, flags);
40683- cpufreq_driver->boost_enabled = state;
40684+ pax_open_kernel();
40685+ *(bool *)&cpufreq_driver->boost_enabled = state;
40686+ pax_close_kernel();
40687 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
40688
40689 ret = cpufreq_driver->set_boost(state);
40690 if (ret) {
40691 write_lock_irqsave(&cpufreq_driver_lock, flags);
40692- cpufreq_driver->boost_enabled = !state;
40693+ pax_open_kernel();
40694+ *(bool *)&cpufreq_driver->boost_enabled = !state;
40695+ pax_close_kernel();
40696 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
40697
40698 pr_err("%s: Cannot %s BOOST\n",
40699@@ -2523,16 +2527,22 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
40700 cpufreq_driver = driver_data;
40701 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
40702
40703- if (driver_data->setpolicy)
40704- driver_data->flags |= CPUFREQ_CONST_LOOPS;
40705+ if (driver_data->setpolicy) {
40706+ pax_open_kernel();
40707+ *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
40708+ pax_close_kernel();
40709+ }
40710
40711 if (cpufreq_boost_supported()) {
40712 /*
40713 * Check if driver provides function to enable boost -
40714 * if not, use cpufreq_boost_set_sw as default
40715 */
40716- if (!cpufreq_driver->set_boost)
40717- cpufreq_driver->set_boost = cpufreq_boost_set_sw;
40718+ if (!cpufreq_driver->set_boost) {
40719+ pax_open_kernel();
40720+ *(void **)&cpufreq_driver->set_boost = cpufreq_boost_set_sw;
40721+ pax_close_kernel();
40722+ }
40723
40724 ret = cpufreq_sysfs_create_file(&boost.attr);
40725 if (ret) {
40726diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
40727index 57a39f8..feb9c73 100644
40728--- a/drivers/cpufreq/cpufreq_governor.c
40729+++ b/drivers/cpufreq/cpufreq_governor.c
40730@@ -378,7 +378,7 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy,
40731 cs_dbs_info->enable = 1;
40732 cs_dbs_info->requested_freq = policy->cur;
40733 } else {
40734- struct od_ops *od_ops = cdata->gov_ops;
40735+ const struct od_ops *od_ops = cdata->gov_ops;
40736 struct od_cpu_dbs_info_s *od_dbs_info = cdata->get_cpu_dbs_info_s(cpu);
40737
40738 od_dbs_info->rate_mult = 1;
40739diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
40740index 34736f5..da8cf4a 100644
40741--- a/drivers/cpufreq/cpufreq_governor.h
40742+++ b/drivers/cpufreq/cpufreq_governor.h
40743@@ -212,7 +212,7 @@ struct common_dbs_data {
40744 void (*exit)(struct dbs_data *dbs_data, bool notify);
40745
40746 /* Governor specific ops, see below */
40747- void *gov_ops;
40748+ const void *gov_ops;
40749
40750 /*
40751 * Protects governor's data (struct dbs_data and struct common_dbs_data)
40752@@ -234,7 +234,7 @@ struct od_ops {
40753 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
40754 unsigned int freq_next, unsigned int relation);
40755 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
40756-};
40757+} __no_const;
40758
40759 static inline int delay_for_sampling_rate(unsigned int sampling_rate)
40760 {
40761diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
40762index 3c1e10f..02f17af 100644
40763--- a/drivers/cpufreq/cpufreq_ondemand.c
40764+++ b/drivers/cpufreq/cpufreq_ondemand.c
40765@@ -523,7 +523,7 @@ static void od_exit(struct dbs_data *dbs_data, bool notify)
40766
40767 define_get_cpu_dbs_routines(od_cpu_dbs_info);
40768
40769-static struct od_ops od_ops = {
40770+static struct od_ops od_ops __read_only = {
40771 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
40772 .powersave_bias_target = generic_powersave_bias_target,
40773 .freq_increase = dbs_freq_increase,
40774@@ -579,14 +579,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
40775 (struct cpufreq_policy *, unsigned int, unsigned int),
40776 unsigned int powersave_bias)
40777 {
40778- od_ops.powersave_bias_target = f;
40779+ pax_open_kernel();
40780+ *(void **)&od_ops.powersave_bias_target = f;
40781+ pax_close_kernel();
40782 od_set_powersave_bias(powersave_bias);
40783 }
40784 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
40785
40786 void od_unregister_powersave_bias_handler(void)
40787 {
40788- od_ops.powersave_bias_target = generic_powersave_bias_target;
40789+ pax_open_kernel();
40790+ *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
40791+ pax_close_kernel();
40792 od_set_powersave_bias(0);
40793 }
40794 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
40795diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
40796index fcb929e..e628818 100644
40797--- a/drivers/cpufreq/intel_pstate.c
40798+++ b/drivers/cpufreq/intel_pstate.c
40799@@ -137,10 +137,10 @@ struct pstate_funcs {
40800 struct cpu_defaults {
40801 struct pstate_adjust_policy pid_policy;
40802 struct pstate_funcs funcs;
40803-};
40804+} __do_const;
40805
40806 static struct pstate_adjust_policy pid_params;
40807-static struct pstate_funcs pstate_funcs;
40808+static struct pstate_funcs *pstate_funcs;
40809 static int hwp_active;
40810
40811 struct perf_limits {
40812@@ -726,18 +726,18 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate, bool force)
40813
40814 cpu->pstate.current_pstate = pstate;
40815
40816- pstate_funcs.set(cpu, pstate);
40817+ pstate_funcs->set(cpu, pstate);
40818 }
40819
40820 static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
40821 {
40822- cpu->pstate.min_pstate = pstate_funcs.get_min();
40823- cpu->pstate.max_pstate = pstate_funcs.get_max();
40824- cpu->pstate.turbo_pstate = pstate_funcs.get_turbo();
40825- cpu->pstate.scaling = pstate_funcs.get_scaling();
40826+ cpu->pstate.min_pstate = pstate_funcs->get_min();
40827+ cpu->pstate.max_pstate = pstate_funcs->get_max();
40828+ cpu->pstate.turbo_pstate = pstate_funcs->get_turbo();
40829+ cpu->pstate.scaling = pstate_funcs->get_scaling();
40830
40831- if (pstate_funcs.get_vid)
40832- pstate_funcs.get_vid(cpu);
40833+ if (pstate_funcs->get_vid)
40834+ pstate_funcs->get_vid(cpu);
40835 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate, false);
40836 }
40837
40838@@ -1070,15 +1070,15 @@ static unsigned int force_load;
40839
40840 static int intel_pstate_msrs_not_valid(void)
40841 {
40842- if (!pstate_funcs.get_max() ||
40843- !pstate_funcs.get_min() ||
40844- !pstate_funcs.get_turbo())
40845+ if (!pstate_funcs->get_max() ||
40846+ !pstate_funcs->get_min() ||
40847+ !pstate_funcs->get_turbo())
40848 return -ENODEV;
40849
40850 return 0;
40851 }
40852
40853-static void copy_pid_params(struct pstate_adjust_policy *policy)
40854+static void copy_pid_params(const struct pstate_adjust_policy *policy)
40855 {
40856 pid_params.sample_rate_ms = policy->sample_rate_ms;
40857 pid_params.p_gain_pct = policy->p_gain_pct;
40858@@ -1090,12 +1090,7 @@ static void copy_pid_params(struct pstate_adjust_policy *policy)
40859
40860 static void copy_cpu_funcs(struct pstate_funcs *funcs)
40861 {
40862- pstate_funcs.get_max = funcs->get_max;
40863- pstate_funcs.get_min = funcs->get_min;
40864- pstate_funcs.get_turbo = funcs->get_turbo;
40865- pstate_funcs.get_scaling = funcs->get_scaling;
40866- pstate_funcs.set = funcs->set;
40867- pstate_funcs.get_vid = funcs->get_vid;
40868+ pstate_funcs = funcs;
40869 }
40870
40871 #if IS_ENABLED(CONFIG_ACPI)
40872diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
40873index 5dd95da..abc3837 100644
40874--- a/drivers/cpufreq/p4-clockmod.c
40875+++ b/drivers/cpufreq/p4-clockmod.c
40876@@ -134,10 +134,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
40877 case 0x0F: /* Core Duo */
40878 case 0x16: /* Celeron Core */
40879 case 0x1C: /* Atom */
40880- p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40881+ pax_open_kernel();
40882+ *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40883+ pax_close_kernel();
40884 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
40885 case 0x0D: /* Pentium M (Dothan) */
40886- p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40887+ pax_open_kernel();
40888+ *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40889+ pax_close_kernel();
40890 /* fall through */
40891 case 0x09: /* Pentium M (Banias) */
40892 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
40893@@ -149,7 +153,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
40894
40895 /* on P-4s, the TSC runs with constant frequency independent whether
40896 * throttling is active or not. */
40897- p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40898+ pax_open_kernel();
40899+ *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40900+ pax_close_kernel();
40901
40902 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
40903 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
40904diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
40905index 9bb42ba..b01b4a2 100644
40906--- a/drivers/cpufreq/sparc-us3-cpufreq.c
40907+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
40908@@ -18,14 +18,12 @@
40909 #include <asm/head.h>
40910 #include <asm/timer.h>
40911
40912-static struct cpufreq_driver *cpufreq_us3_driver;
40913-
40914 struct us3_freq_percpu_info {
40915 struct cpufreq_frequency_table table[4];
40916 };
40917
40918 /* Indexed by cpu number. */
40919-static struct us3_freq_percpu_info *us3_freq_table;
40920+static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
40921
40922 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
40923 * in the Safari config register.
40924@@ -156,16 +154,27 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
40925
40926 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
40927 {
40928- if (cpufreq_us3_driver)
40929- us3_freq_target(policy, 0);
40930+ us3_freq_target(policy, 0);
40931
40932 return 0;
40933 }
40934
40935+static int __init us3_freq_init(void);
40936+static void __exit us3_freq_exit(void);
40937+
40938+static struct cpufreq_driver cpufreq_us3_driver = {
40939+ .init = us3_freq_cpu_init,
40940+ .verify = cpufreq_generic_frequency_table_verify,
40941+ .target_index = us3_freq_target,
40942+ .get = us3_freq_get,
40943+ .exit = us3_freq_cpu_exit,
40944+ .name = "UltraSPARC-III",
40945+
40946+};
40947+
40948 static int __init us3_freq_init(void)
40949 {
40950 unsigned long manuf, impl, ver;
40951- int ret;
40952
40953 if (tlb_type != cheetah && tlb_type != cheetah_plus)
40954 return -ENODEV;
40955@@ -178,55 +187,15 @@ static int __init us3_freq_init(void)
40956 (impl == CHEETAH_IMPL ||
40957 impl == CHEETAH_PLUS_IMPL ||
40958 impl == JAGUAR_IMPL ||
40959- impl == PANTHER_IMPL)) {
40960- struct cpufreq_driver *driver;
40961-
40962- ret = -ENOMEM;
40963- driver = kzalloc(sizeof(*driver), GFP_KERNEL);
40964- if (!driver)
40965- goto err_out;
40966-
40967- us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
40968- GFP_KERNEL);
40969- if (!us3_freq_table)
40970- goto err_out;
40971-
40972- driver->init = us3_freq_cpu_init;
40973- driver->verify = cpufreq_generic_frequency_table_verify;
40974- driver->target_index = us3_freq_target;
40975- driver->get = us3_freq_get;
40976- driver->exit = us3_freq_cpu_exit;
40977- strcpy(driver->name, "UltraSPARC-III");
40978-
40979- cpufreq_us3_driver = driver;
40980- ret = cpufreq_register_driver(driver);
40981- if (ret)
40982- goto err_out;
40983-
40984- return 0;
40985-
40986-err_out:
40987- if (driver) {
40988- kfree(driver);
40989- cpufreq_us3_driver = NULL;
40990- }
40991- kfree(us3_freq_table);
40992- us3_freq_table = NULL;
40993- return ret;
40994- }
40995+ impl == PANTHER_IMPL))
40996+ return cpufreq_register_driver(&cpufreq_us3_driver);
40997
40998 return -ENODEV;
40999 }
41000
41001 static void __exit us3_freq_exit(void)
41002 {
41003- if (cpufreq_us3_driver) {
41004- cpufreq_unregister_driver(cpufreq_us3_driver);
41005- kfree(cpufreq_us3_driver);
41006- cpufreq_us3_driver = NULL;
41007- kfree(us3_freq_table);
41008- us3_freq_table = NULL;
41009- }
41010+ cpufreq_unregister_driver(&cpufreq_us3_driver);
41011 }
41012
41013 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
41014diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
41015index 7d4a315..21bb886 100644
41016--- a/drivers/cpufreq/speedstep-centrino.c
41017+++ b/drivers/cpufreq/speedstep-centrino.c
41018@@ -351,8 +351,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
41019 !cpu_has(cpu, X86_FEATURE_EST))
41020 return -ENODEV;
41021
41022- if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
41023- centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
41024+ if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
41025+ pax_open_kernel();
41026+ *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
41027+ pax_close_kernel();
41028+ }
41029
41030 if (policy->cpu != 0)
41031 return -ENODEV;
41032diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
41033index 5db1478..e90e25e 100644
41034--- a/drivers/cpuidle/driver.c
41035+++ b/drivers/cpuidle/driver.c
41036@@ -193,7 +193,7 @@ static int poll_idle(struct cpuidle_device *dev,
41037
41038 static void poll_idle_init(struct cpuidle_driver *drv)
41039 {
41040- struct cpuidle_state *state = &drv->states[0];
41041+ cpuidle_state_no_const *state = &drv->states[0];
41042
41043 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
41044 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
41045diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c
41046index a5c111b..1113002 100644
41047--- a/drivers/cpuidle/dt_idle_states.c
41048+++ b/drivers/cpuidle/dt_idle_states.c
41049@@ -21,7 +21,7 @@
41050
41051 #include "dt_idle_states.h"
41052
41053-static int init_state_node(struct cpuidle_state *idle_state,
41054+static int init_state_node(cpuidle_state_no_const *idle_state,
41055 const struct of_device_id *matches,
41056 struct device_node *state_node)
41057 {
41058diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
41059index fb9f511..213e6cc 100644
41060--- a/drivers/cpuidle/governor.c
41061+++ b/drivers/cpuidle/governor.c
41062@@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
41063 mutex_lock(&cpuidle_lock);
41064 if (__cpuidle_find_governor(gov->name) == NULL) {
41065 ret = 0;
41066- list_add_tail(&gov->governor_list, &cpuidle_governors);
41067+ pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
41068 if (!cpuidle_curr_governor ||
41069 cpuidle_curr_governor->rating < gov->rating)
41070 cpuidle_switch_governor(gov);
41071diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
41072index 832a2c3..1794080 100644
41073--- a/drivers/cpuidle/sysfs.c
41074+++ b/drivers/cpuidle/sysfs.c
41075@@ -135,7 +135,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
41076 NULL
41077 };
41078
41079-static struct attribute_group cpuidle_attr_group = {
41080+static attribute_group_no_const cpuidle_attr_group = {
41081 .attrs = cpuidle_default_attrs,
41082 .name = "cpuidle",
41083 };
41084diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
41085index 8d2a772..33826c9 100644
41086--- a/drivers/crypto/hifn_795x.c
41087+++ b/drivers/crypto/hifn_795x.c
41088@@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
41089 MODULE_PARM_DESC(hifn_pll_ref,
41090 "PLL reference clock (pci[freq] or ext[freq], default ext)");
41091
41092-static atomic_t hifn_dev_number;
41093+static atomic_unchecked_t hifn_dev_number;
41094
41095 #define ACRYPTO_OP_DECRYPT 0
41096 #define ACRYPTO_OP_ENCRYPT 1
41097@@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
41098 goto err_out_disable_pci_device;
41099
41100 snprintf(name, sizeof(name), "hifn%d",
41101- atomic_inc_return(&hifn_dev_number)-1);
41102+ atomic_inc_return_unchecked(&hifn_dev_number)-1);
41103
41104 err = pci_request_regions(pdev, name);
41105 if (err)
41106diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
41107index ca1b362..01cae6a 100644
41108--- a/drivers/devfreq/devfreq.c
41109+++ b/drivers/devfreq/devfreq.c
41110@@ -672,7 +672,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
41111 goto err_out;
41112 }
41113
41114- list_add(&governor->node, &devfreq_governor_list);
41115+ pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
41116
41117 list_for_each_entry(devfreq, &devfreq_list, node) {
41118 int ret = 0;
41119@@ -760,7 +760,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
41120 }
41121 }
41122
41123- list_del(&governor->node);
41124+ pax_list_del((struct list_head *)&governor->node);
41125 err_out:
41126 mutex_unlock(&devfreq_list_lock);
41127
41128diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
41129index 10fcaba..326f709 100644
41130--- a/drivers/dma/sh/shdma-base.c
41131+++ b/drivers/dma/sh/shdma-base.c
41132@@ -227,8 +227,8 @@ static int shdma_alloc_chan_resources(struct dma_chan *chan)
41133 schan->slave_id = -EINVAL;
41134 }
41135
41136- schan->desc = kcalloc(NR_DESCS_PER_CHANNEL,
41137- sdev->desc_size, GFP_KERNEL);
41138+ schan->desc = kcalloc(sdev->desc_size,
41139+ NR_DESCS_PER_CHANNEL, GFP_KERNEL);
41140 if (!schan->desc) {
41141 ret = -ENOMEM;
41142 goto edescalloc;
41143diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
41144index 11707df..2ea96f7 100644
41145--- a/drivers/dma/sh/shdmac.c
41146+++ b/drivers/dma/sh/shdmac.c
41147@@ -513,7 +513,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
41148 return ret;
41149 }
41150
41151-static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
41152+static struct notifier_block sh_dmae_nmi_notifier = {
41153 .notifier_call = sh_dmae_nmi_handler,
41154
41155 /* Run before NMI debug handler and KGDB */
41156diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
41157index 592af5f..bb1d583 100644
41158--- a/drivers/edac/edac_device.c
41159+++ b/drivers/edac/edac_device.c
41160@@ -477,9 +477,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
41161 */
41162 int edac_device_alloc_index(void)
41163 {
41164- static atomic_t device_indexes = ATOMIC_INIT(0);
41165+ static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
41166
41167- return atomic_inc_return(&device_indexes) - 1;
41168+ return atomic_inc_return_unchecked(&device_indexes) - 1;
41169 }
41170 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
41171
41172diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
41173index 33df7d9..0794989 100644
41174--- a/drivers/edac/edac_mc_sysfs.c
41175+++ b/drivers/edac/edac_mc_sysfs.c
41176@@ -154,7 +154,7 @@ static const char * const edac_caps[] = {
41177 struct dev_ch_attribute {
41178 struct device_attribute attr;
41179 int channel;
41180-};
41181+} __do_const;
41182
41183 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
41184 static struct dev_ch_attribute dev_attr_legacy_##_name = \
41185diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
41186index 2cf44b4d..6dd2dc7 100644
41187--- a/drivers/edac/edac_pci.c
41188+++ b/drivers/edac/edac_pci.c
41189@@ -29,7 +29,7 @@
41190
41191 static DEFINE_MUTEX(edac_pci_ctls_mutex);
41192 static LIST_HEAD(edac_pci_list);
41193-static atomic_t pci_indexes = ATOMIC_INIT(0);
41194+static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
41195
41196 /*
41197 * edac_pci_alloc_ctl_info
41198@@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
41199 */
41200 int edac_pci_alloc_index(void)
41201 {
41202- return atomic_inc_return(&pci_indexes) - 1;
41203+ return atomic_inc_return_unchecked(&pci_indexes) - 1;
41204 }
41205 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
41206
41207diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
41208index 24d877f..4e30133 100644
41209--- a/drivers/edac/edac_pci_sysfs.c
41210+++ b/drivers/edac/edac_pci_sysfs.c
41211@@ -23,8 +23,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
41212 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
41213 static int edac_pci_poll_msec = 1000; /* one second workq period */
41214
41215-static atomic_t pci_parity_count = ATOMIC_INIT(0);
41216-static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
41217+static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
41218+static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
41219
41220 static struct kobject *edac_pci_top_main_kobj;
41221 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
41222@@ -232,7 +232,7 @@ struct edac_pci_dev_attribute {
41223 void *value;
41224 ssize_t(*show) (void *, char *);
41225 ssize_t(*store) (void *, const char *, size_t);
41226-};
41227+} __do_const;
41228
41229 /* Set of show/store abstract level functions for PCI Parity object */
41230 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
41231@@ -576,7 +576,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41232 edac_printk(KERN_CRIT, EDAC_PCI,
41233 "Signaled System Error on %s\n",
41234 pci_name(dev));
41235- atomic_inc(&pci_nonparity_count);
41236+ atomic_inc_unchecked(&pci_nonparity_count);
41237 }
41238
41239 if (status & (PCI_STATUS_PARITY)) {
41240@@ -584,7 +584,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41241 "Master Data Parity Error on %s\n",
41242 pci_name(dev));
41243
41244- atomic_inc(&pci_parity_count);
41245+ atomic_inc_unchecked(&pci_parity_count);
41246 }
41247
41248 if (status & (PCI_STATUS_DETECTED_PARITY)) {
41249@@ -592,7 +592,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41250 "Detected Parity Error on %s\n",
41251 pci_name(dev));
41252
41253- atomic_inc(&pci_parity_count);
41254+ atomic_inc_unchecked(&pci_parity_count);
41255 }
41256 }
41257
41258@@ -615,7 +615,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41259 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
41260 "Signaled System Error on %s\n",
41261 pci_name(dev));
41262- atomic_inc(&pci_nonparity_count);
41263+ atomic_inc_unchecked(&pci_nonparity_count);
41264 }
41265
41266 if (status & (PCI_STATUS_PARITY)) {
41267@@ -623,7 +623,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41268 "Master Data Parity Error on "
41269 "%s\n", pci_name(dev));
41270
41271- atomic_inc(&pci_parity_count);
41272+ atomic_inc_unchecked(&pci_parity_count);
41273 }
41274
41275 if (status & (PCI_STATUS_DETECTED_PARITY)) {
41276@@ -631,7 +631,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
41277 "Detected Parity Error on %s\n",
41278 pci_name(dev));
41279
41280- atomic_inc(&pci_parity_count);
41281+ atomic_inc_unchecked(&pci_parity_count);
41282 }
41283 }
41284 }
41285@@ -669,7 +669,7 @@ void edac_pci_do_parity_check(void)
41286 if (!check_pci_errors)
41287 return;
41288
41289- before_count = atomic_read(&pci_parity_count);
41290+ before_count = atomic_read_unchecked(&pci_parity_count);
41291
41292 /* scan all PCI devices looking for a Parity Error on devices and
41293 * bridges.
41294@@ -681,7 +681,7 @@ void edac_pci_do_parity_check(void)
41295 /* Only if operator has selected panic on PCI Error */
41296 if (edac_pci_get_panic_on_pe()) {
41297 /* If the count is different 'after' from 'before' */
41298- if (before_count != atomic_read(&pci_parity_count))
41299+ if (before_count != atomic_read_unchecked(&pci_parity_count))
41300 panic("EDAC: PCI Parity Error");
41301 }
41302 }
41303diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
41304index c2359a1..8bd119d 100644
41305--- a/drivers/edac/mce_amd.h
41306+++ b/drivers/edac/mce_amd.h
41307@@ -74,7 +74,7 @@ struct amd_decoder_ops {
41308 bool (*mc0_mce)(u16, u8);
41309 bool (*mc1_mce)(u16, u8);
41310 bool (*mc2_mce)(u16, u8);
41311-};
41312+} __no_const;
41313
41314 void amd_report_gart_errors(bool);
41315 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
41316diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
41317index 57ea7f4..af06b76 100644
41318--- a/drivers/firewire/core-card.c
41319+++ b/drivers/firewire/core-card.c
41320@@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
41321 const struct fw_card_driver *driver,
41322 struct device *device)
41323 {
41324- static atomic_t index = ATOMIC_INIT(-1);
41325+ static atomic_unchecked_t index = ATOMIC_INIT(-1);
41326
41327- card->index = atomic_inc_return(&index);
41328+ card->index = atomic_inc_return_unchecked(&index);
41329 card->driver = driver;
41330 card->device = device;
41331 card->current_tlabel = 0;
41332@@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
41333
41334 void fw_core_remove_card(struct fw_card *card)
41335 {
41336- struct fw_card_driver dummy_driver = dummy_driver_template;
41337+ fw_card_driver_no_const dummy_driver = dummy_driver_template;
41338
41339 card->driver->update_phy_reg(card, 4,
41340 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
41341diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
41342index f9e3aee..269dbdb 100644
41343--- a/drivers/firewire/core-device.c
41344+++ b/drivers/firewire/core-device.c
41345@@ -256,7 +256,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
41346 struct config_rom_attribute {
41347 struct device_attribute attr;
41348 u32 key;
41349-};
41350+} __do_const;
41351
41352 static ssize_t show_immediate(struct device *dev,
41353 struct device_attribute *dattr, char *buf)
41354diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
41355index d6a09b9..18e90dd 100644
41356--- a/drivers/firewire/core-transaction.c
41357+++ b/drivers/firewire/core-transaction.c
41358@@ -38,6 +38,7 @@
41359 #include <linux/timer.h>
41360 #include <linux/types.h>
41361 #include <linux/workqueue.h>
41362+#include <linux/sched.h>
41363
41364 #include <asm/byteorder.h>
41365
41366diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
41367index e1480ff6..1a429bd 100644
41368--- a/drivers/firewire/core.h
41369+++ b/drivers/firewire/core.h
41370@@ -111,6 +111,7 @@ struct fw_card_driver {
41371
41372 int (*stop_iso)(struct fw_iso_context *ctx);
41373 };
41374+typedef struct fw_card_driver __no_const fw_card_driver_no_const;
41375
41376 void fw_card_initialize(struct fw_card *card,
41377 const struct fw_card_driver *driver, struct device *device);
41378diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
41379index f51d376..b118e40 100644
41380--- a/drivers/firewire/ohci.c
41381+++ b/drivers/firewire/ohci.c
41382@@ -2049,10 +2049,12 @@ static void bus_reset_work(struct work_struct *work)
41383 be32_to_cpu(ohci->next_header));
41384 }
41385
41386+#ifndef CONFIG_GRKERNSEC
41387 if (param_remote_dma) {
41388 reg_write(ohci, OHCI1394_PhyReqFilterHiSet, ~0);
41389 reg_write(ohci, OHCI1394_PhyReqFilterLoSet, ~0);
41390 }
41391+#endif
41392
41393 spin_unlock_irq(&ohci->lock);
41394
41395@@ -2584,8 +2586,10 @@ static int ohci_enable_phys_dma(struct fw_card *card,
41396 unsigned long flags;
41397 int n, ret = 0;
41398
41399+#ifndef CONFIG_GRKERNSEC
41400 if (param_remote_dma)
41401 return 0;
41402+#endif
41403
41404 /*
41405 * FIXME: Make sure this bitmask is cleared when we clear the busReset
41406diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
41407index 94a58a0..f5eba42 100644
41408--- a/drivers/firmware/dmi-id.c
41409+++ b/drivers/firmware/dmi-id.c
41410@@ -16,7 +16,7 @@
41411 struct dmi_device_attribute{
41412 struct device_attribute dev_attr;
41413 int field;
41414-};
41415+} __do_const;
41416 #define to_dmi_dev_attr(_dev_attr) \
41417 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
41418
41419diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
41420index ac1ce4a..321745e 100644
41421--- a/drivers/firmware/dmi_scan.c
41422+++ b/drivers/firmware/dmi_scan.c
41423@@ -690,14 +690,18 @@ static int __init dmi_init(void)
41424 if (!dmi_table)
41425 goto err_tables;
41426
41427- bin_attr_smbios_entry_point.size = smbios_entry_point_size;
41428- bin_attr_smbios_entry_point.private = smbios_entry_point;
41429+ pax_open_kernel();
41430+ *(size_t *)&bin_attr_smbios_entry_point.size = smbios_entry_point_size;
41431+ *(void **)&bin_attr_smbios_entry_point.private = smbios_entry_point;
41432+ pax_close_kernel();
41433 ret = sysfs_create_bin_file(tables_kobj, &bin_attr_smbios_entry_point);
41434 if (ret)
41435 goto err_unmap;
41436
41437- bin_attr_DMI.size = dmi_len;
41438- bin_attr_DMI.private = dmi_table;
41439+ pax_open_kernel();
41440+ *(size_t *)&bin_attr_DMI.size = dmi_len;
41441+ *(void **)&bin_attr_DMI.private = dmi_table;
41442+ pax_close_kernel();
41443 ret = sysfs_create_bin_file(tables_kobj, &bin_attr_DMI);
41444 if (!ret)
41445 return 0;
41446diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
41447index d425374..1da1716 100644
41448--- a/drivers/firmware/efi/cper.c
41449+++ b/drivers/firmware/efi/cper.c
41450@@ -44,12 +44,12 @@ static char rcd_decode_str[CPER_REC_LEN];
41451 */
41452 u64 cper_next_record_id(void)
41453 {
41454- static atomic64_t seq;
41455+ static atomic64_unchecked_t seq;
41456
41457- if (!atomic64_read(&seq))
41458- atomic64_set(&seq, ((u64)get_seconds()) << 32);
41459+ if (!atomic64_read_unchecked(&seq))
41460+ atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
41461
41462- return atomic64_inc_return(&seq);
41463+ return atomic64_inc_return_unchecked(&seq);
41464 }
41465 EXPORT_SYMBOL_GPL(cper_next_record_id);
41466
41467diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
41468index d6144e3..23f9686 100644
41469--- a/drivers/firmware/efi/efi.c
41470+++ b/drivers/firmware/efi/efi.c
41471@@ -170,14 +170,16 @@ static struct attribute_group efi_subsys_attr_group = {
41472 };
41473
41474 static struct efivars generic_efivars;
41475-static struct efivar_operations generic_ops;
41476+static efivar_operations_no_const generic_ops __read_only;
41477
41478 static int generic_ops_register(void)
41479 {
41480- generic_ops.get_variable = efi.get_variable;
41481- generic_ops.set_variable = efi.set_variable;
41482- generic_ops.get_next_variable = efi.get_next_variable;
41483- generic_ops.query_variable_store = efi_query_variable_store;
41484+ pax_open_kernel();
41485+ *(void **)&generic_ops.get_variable = efi.get_variable;
41486+ *(void **)&generic_ops.set_variable = efi.set_variable;
41487+ *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
41488+ *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
41489+ pax_close_kernel();
41490
41491 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
41492 }
41493diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
41494index 756eca8..2336d08 100644
41495--- a/drivers/firmware/efi/efivars.c
41496+++ b/drivers/firmware/efi/efivars.c
41497@@ -590,7 +590,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
41498 static int
41499 create_efivars_bin_attributes(void)
41500 {
41501- struct bin_attribute *attr;
41502+ bin_attribute_no_const *attr;
41503 int error;
41504
41505 /* new_var */
41506diff --git a/drivers/firmware/efi/runtime-map.c b/drivers/firmware/efi/runtime-map.c
41507index 5c55227..97f4978 100644
41508--- a/drivers/firmware/efi/runtime-map.c
41509+++ b/drivers/firmware/efi/runtime-map.c
41510@@ -97,7 +97,7 @@ static void map_release(struct kobject *kobj)
41511 kfree(entry);
41512 }
41513
41514-static struct kobj_type __refdata map_ktype = {
41515+static const struct kobj_type __refconst map_ktype = {
41516 .sysfs_ops = &map_attr_ops,
41517 .default_attrs = def_attrs,
41518 .release = map_release,
41519diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
41520index f1ab05e..ab51228 100644
41521--- a/drivers/firmware/google/gsmi.c
41522+++ b/drivers/firmware/google/gsmi.c
41523@@ -709,7 +709,7 @@ static u32 __init hash_oem_table_id(char s[8])
41524 return local_hash_64(input, 32);
41525 }
41526
41527-static struct dmi_system_id gsmi_dmi_table[] __initdata = {
41528+static const struct dmi_system_id gsmi_dmi_table[] __initconst = {
41529 {
41530 .ident = "Google Board",
41531 .matches = {
41532diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
41533index 2f569aa..26e4f39 100644
41534--- a/drivers/firmware/google/memconsole.c
41535+++ b/drivers/firmware/google/memconsole.c
41536@@ -136,7 +136,7 @@ static bool __init found_memconsole(void)
41537 return false;
41538 }
41539
41540-static struct dmi_system_id memconsole_dmi_table[] __initdata = {
41541+static const struct dmi_system_id memconsole_dmi_table[] __initconst = {
41542 {
41543 .ident = "Google Board",
41544 .matches = {
41545@@ -155,7 +155,10 @@ static int __init memconsole_init(void)
41546 if (!found_memconsole())
41547 return -ENODEV;
41548
41549- memconsole_bin_attr.size = memconsole_length;
41550+ pax_open_kernel();
41551+ *(size_t *)&memconsole_bin_attr.size = memconsole_length;
41552+ pax_close_kernel();
41553+
41554 return sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
41555 }
41556
41557diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
41558index 5de3ed2..d839c56 100644
41559--- a/drivers/firmware/memmap.c
41560+++ b/drivers/firmware/memmap.c
41561@@ -124,7 +124,7 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
41562 kfree(entry);
41563 }
41564
41565-static struct kobj_type __refdata memmap_ktype = {
41566+static const struct kobj_type __refconst memmap_ktype = {
41567 .release = release_firmware_map_entry,
41568 .sysfs_ops = &memmap_attr_ops,
41569 .default_attrs = def_attrs,
41570diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
41571index c246ac3..6867ca6 100644
41572--- a/drivers/gpio/gpio-davinci.c
41573+++ b/drivers/gpio/gpio-davinci.c
41574@@ -442,9 +442,9 @@ static struct irq_chip *davinci_gpio_get_irq_chip(unsigned int irq)
41575 return &gpio_unbanked.chip;
41576 };
41577
41578-static struct irq_chip *keystone_gpio_get_irq_chip(unsigned int irq)
41579+static irq_chip_no_const *keystone_gpio_get_irq_chip(unsigned int irq)
41580 {
41581- static struct irq_chip gpio_unbanked;
41582+ static irq_chip_no_const gpio_unbanked;
41583
41584 gpio_unbanked = *irq_get_chip(irq);
41585 return &gpio_unbanked;
41586@@ -474,7 +474,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
41587 struct davinci_gpio_regs __iomem *g;
41588 struct irq_domain *irq_domain = NULL;
41589 const struct of_device_id *match;
41590- struct irq_chip *irq_chip;
41591+ irq_chip_no_const *irq_chip;
41592 gpio_get_irq_chip_cb_t gpio_get_irq_chip;
41593
41594 /*
41595diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c
41596index fbf2873..0a37114 100644
41597--- a/drivers/gpio/gpio-em.c
41598+++ b/drivers/gpio/gpio-em.c
41599@@ -278,7 +278,7 @@ static int em_gio_probe(struct platform_device *pdev)
41600 struct em_gio_priv *p;
41601 struct resource *io[2], *irq[2];
41602 struct gpio_chip *gpio_chip;
41603- struct irq_chip *irq_chip;
41604+ irq_chip_no_const *irq_chip;
41605 const char *name = dev_name(&pdev->dev);
41606 int ret;
41607
41608diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
41609index 4ba7ed5..1536b5d 100644
41610--- a/drivers/gpio/gpio-ich.c
41611+++ b/drivers/gpio/gpio-ich.c
41612@@ -94,7 +94,7 @@ struct ichx_desc {
41613 * this option allows driver caching written output values
41614 */
41615 bool use_outlvl_cache;
41616-};
41617+} __do_const;
41618
41619 static struct {
41620 spinlock_t lock;
41621diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
41622index 61a731f..d5ca6cb 100644
41623--- a/drivers/gpio/gpio-omap.c
41624+++ b/drivers/gpio/gpio-omap.c
41625@@ -1067,7 +1067,7 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
41626 dev_err(bank->dev, "Could not get gpio dbck\n");
41627 }
41628
41629-static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
41630+static int omap_gpio_chip_init(struct gpio_bank *bank, irq_chip_no_const *irqc)
41631 {
41632 static int gpio;
41633 int irq_base = 0;
41634@@ -1150,7 +1150,7 @@ static int omap_gpio_probe(struct platform_device *pdev)
41635 const struct omap_gpio_platform_data *pdata;
41636 struct resource *res;
41637 struct gpio_bank *bank;
41638- struct irq_chip *irqc;
41639+ irq_chip_no_const *irqc;
41640 int ret;
41641
41642 match = of_match_device(of_match_ptr(omap_gpio_match), dev);
41643diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
41644index 1e14a6c..0442450 100644
41645--- a/drivers/gpio/gpio-rcar.c
41646+++ b/drivers/gpio/gpio-rcar.c
41647@@ -379,7 +379,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
41648 struct gpio_rcar_priv *p;
41649 struct resource *io, *irq;
41650 struct gpio_chip *gpio_chip;
41651- struct irq_chip *irq_chip;
41652+ irq_chip_no_const *irq_chip;
41653 struct device *dev = &pdev->dev;
41654 const char *name = dev_name(dev);
41655 int ret;
41656diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
41657index c1caa45..f0f97d2 100644
41658--- a/drivers/gpio/gpio-vr41xx.c
41659+++ b/drivers/gpio/gpio-vr41xx.c
41660@@ -224,7 +224,7 @@ static int giu_get_irq(unsigned int irq)
41661 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
41662 maskl, pendl, maskh, pendh);
41663
41664- atomic_inc(&irq_err_count);
41665+ atomic_inc_unchecked(&irq_err_count);
41666
41667 return -EINVAL;
41668 }
41669diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
41670index bf4bd1d..51154a3 100644
41671--- a/drivers/gpio/gpiolib.c
41672+++ b/drivers/gpio/gpiolib.c
41673@@ -569,8 +569,10 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
41674 }
41675
41676 if (gpiochip->irqchip) {
41677- gpiochip->irqchip->irq_request_resources = NULL;
41678- gpiochip->irqchip->irq_release_resources = NULL;
41679+ pax_open_kernel();
41680+ *(void **)&gpiochip->irqchip->irq_request_resources = NULL;
41681+ *(void **)&gpiochip->irqchip->irq_release_resources = NULL;
41682+ pax_close_kernel();
41683 gpiochip->irqchip = NULL;
41684 }
41685 }
41686@@ -636,8 +638,11 @@ int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
41687 gpiochip->irqchip = NULL;
41688 return -EINVAL;
41689 }
41690- irqchip->irq_request_resources = gpiochip_irq_reqres;
41691- irqchip->irq_release_resources = gpiochip_irq_relres;
41692+
41693+ pax_open_kernel();
41694+ *(void **)&irqchip->irq_request_resources = gpiochip_irq_reqres;
41695+ *(void **)&irqchip->irq_release_resources = gpiochip_irq_relres;
41696+ pax_close_kernel();
41697
41698 /*
41699 * Prepare the mapping since the irqchip shall be orthogonal to
41700diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
41701index 99f158e..20b6c4c 100644
41702--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
41703+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
41704@@ -1071,7 +1071,7 @@ static bool amdgpu_switcheroo_can_switch(struct pci_dev *pdev)
41705 * locking inversion with the driver load path. And the access here is
41706 * completely racy anyway. So don't bother with locking for now.
41707 */
41708- return dev->open_count == 0;
41709+ return local_read(&dev->open_count) == 0;
41710 }
41711
41712 static const struct vga_switcheroo_client_ops amdgpu_switcheroo_ops = {
41713diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
41714index c991973..8eb176b 100644
41715--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
41716+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
41717@@ -419,7 +419,7 @@ static int kfd_ioctl_set_memory_policy(struct file *filep,
41718 (args->alternate_policy == KFD_IOC_CACHE_POLICY_COHERENT)
41719 ? cache_policy_coherent : cache_policy_noncoherent;
41720
41721- if (!dev->dqm->ops.set_cache_memory_policy(dev->dqm,
41722+ if (!dev->dqm->ops->set_cache_memory_policy(dev->dqm,
41723 &pdd->qpd,
41724 default_policy,
41725 alternate_policy,
41726diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
41727index 75312c8..e3684e6 100644
41728--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
41729+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
41730@@ -293,7 +293,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
41731 goto device_queue_manager_error;
41732 }
41733
41734- if (kfd->dqm->ops.start(kfd->dqm) != 0) {
41735+ if (kfd->dqm->ops->start(kfd->dqm) != 0) {
41736 dev_err(kfd_device,
41737 "Error starting queuen manager for device (%x:%x)\n",
41738 kfd->pdev->vendor, kfd->pdev->device);
41739@@ -349,7 +349,7 @@ void kgd2kfd_suspend(struct kfd_dev *kfd)
41740 BUG_ON(kfd == NULL);
41741
41742 if (kfd->init_complete) {
41743- kfd->dqm->ops.stop(kfd->dqm);
41744+ kfd->dqm->ops->stop(kfd->dqm);
41745 amd_iommu_set_invalidate_ctx_cb(kfd->pdev, NULL);
41746 amd_iommu_set_invalid_ppr_cb(kfd->pdev, NULL);
41747 amd_iommu_free_device(kfd->pdev);
41748@@ -372,7 +372,7 @@ int kgd2kfd_resume(struct kfd_dev *kfd)
41749 amd_iommu_set_invalidate_ctx_cb(kfd->pdev,
41750 iommu_pasid_shutdown_callback);
41751 amd_iommu_set_invalid_ppr_cb(kfd->pdev, iommu_invalid_ppr_cb);
41752- kfd->dqm->ops.start(kfd->dqm);
41753+ kfd->dqm->ops->start(kfd->dqm);
41754 }
41755
41756 return 0;
41757diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
41758index 4bb7f42..320fcac 100644
41759--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
41760+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
41761@@ -242,7 +242,7 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm,
41762
41763 BUG_ON(!dqm || !q || !qpd);
41764
41765- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41766+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41767 if (mqd == NULL)
41768 return -ENOMEM;
41769
41770@@ -288,14 +288,14 @@ static int destroy_queue_nocpsch(struct device_queue_manager *dqm,
41771 mutex_lock(&dqm->lock);
41772
41773 if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE) {
41774- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41775+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41776 if (mqd == NULL) {
41777 retval = -ENOMEM;
41778 goto out;
41779 }
41780 deallocate_hqd(dqm, q);
41781 } else if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
41782- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_SDMA);
41783+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_SDMA);
41784 if (mqd == NULL) {
41785 retval = -ENOMEM;
41786 goto out;
41787@@ -347,7 +347,7 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q)
41788 BUG_ON(!dqm || !q || !q->mqd);
41789
41790 mutex_lock(&dqm->lock);
41791- mqd = dqm->ops.get_mqd_manager(dqm,
41792+ mqd = dqm->ops->get_mqd_manager(dqm,
41793 get_mqd_type_from_queue_type(q->properties.type));
41794 if (mqd == NULL) {
41795 mutex_unlock(&dqm->lock);
41796@@ -414,7 +414,7 @@ static int register_process_nocpsch(struct device_queue_manager *dqm,
41797 mutex_lock(&dqm->lock);
41798 list_add(&n->list, &dqm->queues);
41799
41800- retval = dqm->ops_asic_specific.register_process(dqm, qpd);
41801+ retval = dqm->ops_asic_specific->register_process(dqm, qpd);
41802
41803 dqm->processes_count++;
41804
41805@@ -502,7 +502,7 @@ int init_pipelines(struct device_queue_manager *dqm,
41806
41807 memset(hpdptr, 0, CIK_HPD_EOP_BYTES * pipes_num);
41808
41809- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41810+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
41811 if (mqd == NULL) {
41812 kfd_gtt_sa_free(dqm->dev, dqm->pipeline_mem);
41813 return -ENOMEM;
41814@@ -635,7 +635,7 @@ static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
41815 struct mqd_manager *mqd;
41816 int retval;
41817
41818- mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_SDMA);
41819+ mqd = dqm->ops->get_mqd_manager(dqm, KFD_MQD_TYPE_SDMA);
41820 if (!mqd)
41821 return -ENOMEM;
41822
41823@@ -650,7 +650,7 @@ static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
41824 pr_debug(" sdma queue id: %d\n", q->properties.sdma_queue_id);
41825 pr_debug(" sdma engine id: %d\n", q->properties.sdma_engine_id);
41826
41827- dqm->ops_asic_specific.init_sdma_vm(dqm, q, qpd);
41828+ dqm->ops_asic_specific->init_sdma_vm(dqm, q, qpd);
41829 retval = mqd->init_mqd(mqd, &q->mqd, &q->mqd_mem_obj,
41830 &q->gart_mqd_addr, &q->properties);
41831 if (retval != 0) {
41832@@ -712,7 +712,7 @@ static int initialize_cpsch(struct device_queue_manager *dqm)
41833 dqm->queue_count = dqm->processes_count = 0;
41834 dqm->sdma_queue_count = 0;
41835 dqm->active_runlist = false;
41836- retval = dqm->ops_asic_specific.initialize(dqm);
41837+ retval = dqm->ops_asic_specific->initialize(dqm);
41838 if (retval != 0)
41839 goto fail_init_pipelines;
41840
41841@@ -879,7 +879,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
41842 if (q->properties.type == KFD_QUEUE_TYPE_SDMA)
41843 select_sdma_engine_id(q);
41844
41845- mqd = dqm->ops.get_mqd_manager(dqm,
41846+ mqd = dqm->ops->get_mqd_manager(dqm,
41847 get_mqd_type_from_queue_type(q->properties.type));
41848
41849 if (mqd == NULL) {
41850@@ -887,7 +887,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
41851 return -ENOMEM;
41852 }
41853
41854- dqm->ops_asic_specific.init_sdma_vm(dqm, q, qpd);
41855+ dqm->ops_asic_specific->init_sdma_vm(dqm, q, qpd);
41856 retval = mqd->init_mqd(mqd, &q->mqd, &q->mqd_mem_obj,
41857 &q->gart_mqd_addr, &q->properties);
41858 if (retval != 0)
41859@@ -1060,7 +1060,7 @@ static int destroy_queue_cpsch(struct device_queue_manager *dqm,
41860
41861 }
41862
41863- mqd = dqm->ops.get_mqd_manager(dqm,
41864+ mqd = dqm->ops->get_mqd_manager(dqm,
41865 get_mqd_type_from_queue_type(q->properties.type));
41866 if (!mqd) {
41867 retval = -ENOMEM;
41868@@ -1149,7 +1149,7 @@ static bool set_cache_memory_policy(struct device_queue_manager *dqm,
41869 qpd->sh_mem_ape1_limit = limit >> 16;
41870 }
41871
41872- retval = dqm->ops_asic_specific.set_cache_memory_policy(
41873+ retval = dqm->ops_asic_specific->set_cache_memory_policy(
41874 dqm,
41875 qpd,
41876 default_policy,
41877@@ -1172,6 +1172,36 @@ out:
41878 return false;
41879 }
41880
41881+static const struct device_queue_manager_ops cp_dqm_ops = {
41882+ .create_queue = create_queue_cpsch,
41883+ .initialize = initialize_cpsch,
41884+ .start = start_cpsch,
41885+ .stop = stop_cpsch,
41886+ .destroy_queue = destroy_queue_cpsch,
41887+ .update_queue = update_queue,
41888+ .get_mqd_manager = get_mqd_manager_nocpsch,
41889+ .register_process = register_process_nocpsch,
41890+ .unregister_process = unregister_process_nocpsch,
41891+ .uninitialize = uninitialize_nocpsch,
41892+ .create_kernel_queue = create_kernel_queue_cpsch,
41893+ .destroy_kernel_queue = destroy_kernel_queue_cpsch,
41894+ .set_cache_memory_policy = set_cache_memory_policy,
41895+};
41896+
41897+static const struct device_queue_manager_ops no_cp_dqm_ops = {
41898+ .start = start_nocpsch,
41899+ .stop = stop_nocpsch,
41900+ .create_queue = create_queue_nocpsch,
41901+ .destroy_queue = destroy_queue_nocpsch,
41902+ .update_queue = update_queue,
41903+ .get_mqd_manager = get_mqd_manager_nocpsch,
41904+ .register_process = register_process_nocpsch,
41905+ .unregister_process = unregister_process_nocpsch,
41906+ .initialize = initialize_nocpsch,
41907+ .uninitialize = uninitialize_nocpsch,
41908+ .set_cache_memory_policy = set_cache_memory_policy,
41909+};
41910+
41911 struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
41912 {
41913 struct device_queue_manager *dqm;
41914@@ -1189,33 +1219,11 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
41915 case KFD_SCHED_POLICY_HWS:
41916 case KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION:
41917 /* initialize dqm for cp scheduling */
41918- dqm->ops.create_queue = create_queue_cpsch;
41919- dqm->ops.initialize = initialize_cpsch;
41920- dqm->ops.start = start_cpsch;
41921- dqm->ops.stop = stop_cpsch;
41922- dqm->ops.destroy_queue = destroy_queue_cpsch;
41923- dqm->ops.update_queue = update_queue;
41924- dqm->ops.get_mqd_manager = get_mqd_manager_nocpsch;
41925- dqm->ops.register_process = register_process_nocpsch;
41926- dqm->ops.unregister_process = unregister_process_nocpsch;
41927- dqm->ops.uninitialize = uninitialize_nocpsch;
41928- dqm->ops.create_kernel_queue = create_kernel_queue_cpsch;
41929- dqm->ops.destroy_kernel_queue = destroy_kernel_queue_cpsch;
41930- dqm->ops.set_cache_memory_policy = set_cache_memory_policy;
41931+ dqm->ops = &cp_dqm_ops;
41932 break;
41933 case KFD_SCHED_POLICY_NO_HWS:
41934 /* initialize dqm for no cp scheduling */
41935- dqm->ops.start = start_nocpsch;
41936- dqm->ops.stop = stop_nocpsch;
41937- dqm->ops.create_queue = create_queue_nocpsch;
41938- dqm->ops.destroy_queue = destroy_queue_nocpsch;
41939- dqm->ops.update_queue = update_queue;
41940- dqm->ops.get_mqd_manager = get_mqd_manager_nocpsch;
41941- dqm->ops.register_process = register_process_nocpsch;
41942- dqm->ops.unregister_process = unregister_process_nocpsch;
41943- dqm->ops.initialize = initialize_nocpsch;
41944- dqm->ops.uninitialize = uninitialize_nocpsch;
41945- dqm->ops.set_cache_memory_policy = set_cache_memory_policy;
41946+ dqm->ops = &no_cp_dqm_ops;
41947 break;
41948 default:
41949 BUG();
41950@@ -1224,15 +1232,15 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
41951
41952 switch (dev->device_info->asic_family) {
41953 case CHIP_CARRIZO:
41954- device_queue_manager_init_vi(&dqm->ops_asic_specific);
41955+ device_queue_manager_init_vi(dqm);
41956 break;
41957
41958 case CHIP_KAVERI:
41959- device_queue_manager_init_cik(&dqm->ops_asic_specific);
41960+ device_queue_manager_init_cik(dqm);
41961 break;
41962 }
41963
41964- if (dqm->ops.initialize(dqm) != 0) {
41965+ if (dqm->ops->initialize(dqm) != 0) {
41966 kfree(dqm);
41967 return NULL;
41968 }
41969@@ -1244,6 +1252,6 @@ void device_queue_manager_uninit(struct device_queue_manager *dqm)
41970 {
41971 BUG_ON(!dqm);
41972
41973- dqm->ops.uninitialize(dqm);
41974+ dqm->ops->uninitialize(dqm);
41975 kfree(dqm);
41976 }
41977diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
41978index ec4036a..3ef0646 100644
41979--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
41980+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
41981@@ -154,8 +154,8 @@ struct device_queue_manager_asic_ops {
41982 */
41983
41984 struct device_queue_manager {
41985- struct device_queue_manager_ops ops;
41986- struct device_queue_manager_asic_ops ops_asic_specific;
41987+ struct device_queue_manager_ops *ops;
41988+ struct device_queue_manager_asic_ops *ops_asic_specific;
41989
41990 struct mqd_manager *mqds[KFD_MQD_TYPE_MAX];
41991 struct packet_manager packets;
41992@@ -178,8 +178,8 @@ struct device_queue_manager {
41993 bool active_runlist;
41994 };
41995
41996-void device_queue_manager_init_cik(struct device_queue_manager_asic_ops *ops);
41997-void device_queue_manager_init_vi(struct device_queue_manager_asic_ops *ops);
41998+void device_queue_manager_init_cik(struct device_queue_manager *dqm);
41999+void device_queue_manager_init_vi(struct device_queue_manager *dqm);
42000 void program_sh_mem_settings(struct device_queue_manager *dqm,
42001 struct qcm_process_device *qpd);
42002 int init_pipelines(struct device_queue_manager *dqm,
42003diff --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
42004index 9ce8a20..1ca4e22 100644
42005--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c
42006+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c
42007@@ -36,12 +36,16 @@ static int initialize_cpsch_cik(struct device_queue_manager *dqm);
42008 static void init_sdma_vm(struct device_queue_manager *dqm, struct queue *q,
42009 struct qcm_process_device *qpd);
42010
42011-void device_queue_manager_init_cik(struct device_queue_manager_asic_ops *ops)
42012+static const struct device_queue_manager_asic_ops cik_dqm_asic_ops = {
42013+ .set_cache_memory_policy = set_cache_memory_policy_cik,
42014+ .register_process = register_process_cik,
42015+ .initialize = initialize_cpsch_cik,
42016+ .init_sdma_vm = init_sdma_vm,
42017+};
42018+
42019+void device_queue_manager_init_cik(struct device_queue_manager *dqm)
42020 {
42021- ops->set_cache_memory_policy = set_cache_memory_policy_cik;
42022- ops->register_process = register_process_cik;
42023- ops->initialize = initialize_cpsch_cik;
42024- ops->init_sdma_vm = init_sdma_vm;
42025+ dqm->ops_asic_specific = &cik_dqm_asic_ops;
42026 }
42027
42028 static uint32_t compute_sh_mem_bases_64bit(unsigned int top_address_nybble)
42029diff --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
42030index 4c15212..61bfab8 100644
42031--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c
42032+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c
42033@@ -35,14 +35,18 @@ static int initialize_cpsch_vi(struct device_queue_manager *dqm);
42034 static void init_sdma_vm(struct device_queue_manager *dqm, struct queue *q,
42035 struct qcm_process_device *qpd);
42036
42037-void device_queue_manager_init_vi(struct device_queue_manager_asic_ops *ops)
42038+static const struct device_queue_manager_asic_ops vi_dqm_asic_ops = {
42039+ .set_cache_memory_policy = set_cache_memory_policy_vi,
42040+ .register_process = register_process_vi,
42041+ .initialize = initialize_cpsch_vi,
42042+ .init_sdma_vm = init_sdma_vm,
42043+};
42044+
42045+void device_queue_manager_init_vi(struct device_queue_manager *dqm)
42046 {
42047 pr_warn("amdkfd: VI DQM is not currently supported\n");
42048
42049- ops->set_cache_memory_policy = set_cache_memory_policy_vi;
42050- ops->register_process = register_process_vi;
42051- ops->initialize = initialize_cpsch_vi;
42052- ops->init_sdma_vm = init_sdma_vm;
42053+ dqm->ops_asic_specific = &vi_dqm_asic_ops;
42054 }
42055
42056 static bool set_cache_memory_policy_vi(struct device_queue_manager *dqm,
42057diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
42058index 7f134aa..cd34d4a 100644
42059--- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
42060+++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
42061@@ -50,8 +50,8 @@ static void interrupt_wq(struct work_struct *);
42062
42063 int kfd_interrupt_init(struct kfd_dev *kfd)
42064 {
42065- void *interrupt_ring = kmalloc_array(KFD_INTERRUPT_RING_SIZE,
42066- kfd->device_info->ih_ring_entry_size,
42067+ void *interrupt_ring = kmalloc_array(kfd->device_info->ih_ring_entry_size,
42068+ KFD_INTERRUPT_RING_SIZE,
42069 GFP_KERNEL);
42070 if (!interrupt_ring)
42071 return -ENOMEM;
42072diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
42073index 8fa8941..5ae07df 100644
42074--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
42075+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
42076@@ -56,7 +56,7 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
42077 switch (type) {
42078 case KFD_QUEUE_TYPE_DIQ:
42079 case KFD_QUEUE_TYPE_HIQ:
42080- kq->mqd = dev->dqm->ops.get_mqd_manager(dev->dqm,
42081+ kq->mqd = dev->dqm->ops->get_mqd_manager(dev->dqm,
42082 KFD_MQD_TYPE_HIQ);
42083 break;
42084 default:
42085diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
42086index 5940531..a75b0e5 100644
42087--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
42088+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
42089@@ -62,7 +62,7 @@ struct kernel_queue_ops {
42090
42091 void (*submit_packet)(struct kernel_queue *kq);
42092 void (*rollback_packet)(struct kernel_queue *kq);
42093-};
42094+} __no_const;
42095
42096 struct kernel_queue {
42097 struct kernel_queue_ops ops;
42098diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
42099index 7b69070..d7bd78b 100644
42100--- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
42101+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
42102@@ -194,7 +194,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
42103
42104 if (list_empty(&pqm->queues)) {
42105 pdd->qpd.pqm = pqm;
42106- dev->dqm->ops.register_process(dev->dqm, &pdd->qpd);
42107+ dev->dqm->ops->register_process(dev->dqm, &pdd->qpd);
42108 }
42109
42110 pqn = kzalloc(sizeof(struct process_queue_node), GFP_KERNEL);
42111@@ -220,7 +220,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
42112 goto err_create_queue;
42113 pqn->q = q;
42114 pqn->kq = NULL;
42115- retval = dev->dqm->ops.create_queue(dev->dqm, q, &pdd->qpd,
42116+ retval = dev->dqm->ops->create_queue(dev->dqm, q, &pdd->qpd,
42117 &q->properties.vmid);
42118 pr_debug("DQM returned %d for create_queue\n", retval);
42119 print_queue(q);
42120@@ -234,7 +234,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
42121 kq->queue->properties.queue_id = *qid;
42122 pqn->kq = kq;
42123 pqn->q = NULL;
42124- retval = dev->dqm->ops.create_kernel_queue(dev->dqm,
42125+ retval = dev->dqm->ops->create_kernel_queue(dev->dqm,
42126 kq, &pdd->qpd);
42127 break;
42128 default:
42129@@ -265,7 +265,7 @@ err_allocate_pqn:
42130 /* check if queues list is empty unregister process from device */
42131 clear_bit(*qid, pqm->queue_slot_bitmap);
42132 if (list_empty(&pqm->queues))
42133- dev->dqm->ops.unregister_process(dev->dqm, &pdd->qpd);
42134+ dev->dqm->ops->unregister_process(dev->dqm, &pdd->qpd);
42135 return retval;
42136 }
42137
42138@@ -306,13 +306,13 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
42139 if (pqn->kq) {
42140 /* destroy kernel queue (DIQ) */
42141 dqm = pqn->kq->dev->dqm;
42142- dqm->ops.destroy_kernel_queue(dqm, pqn->kq, &pdd->qpd);
42143+ dqm->ops->destroy_kernel_queue(dqm, pqn->kq, &pdd->qpd);
42144 kernel_queue_uninit(pqn->kq);
42145 }
42146
42147 if (pqn->q) {
42148 dqm = pqn->q->device->dqm;
42149- retval = dqm->ops.destroy_queue(dqm, &pdd->qpd, pqn->q);
42150+ retval = dqm->ops->destroy_queue(dqm, &pdd->qpd, pqn->q);
42151 if (retval != 0)
42152 return retval;
42153
42154@@ -324,7 +324,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
42155 clear_bit(qid, pqm->queue_slot_bitmap);
42156
42157 if (list_empty(&pqm->queues))
42158- dqm->ops.unregister_process(dqm, &pdd->qpd);
42159+ dqm->ops->unregister_process(dqm, &pdd->qpd);
42160
42161 return retval;
42162 }
42163@@ -349,7 +349,7 @@ int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid,
42164 pqn->q->properties.queue_percent = p->queue_percent;
42165 pqn->q->properties.priority = p->priority;
42166
42167- retval = pqn->q->device->dqm->ops.update_queue(pqn->q->device->dqm,
42168+ retval = pqn->q->device->dqm->ops->update_queue(pqn->q->device->dqm,
42169 pqn->q);
42170 if (retval != 0)
42171 return retval;
42172diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
42173index 9b23525..65f4110 100644
42174--- a/drivers/gpu/drm/drm_context.c
42175+++ b/drivers/gpu/drm/drm_context.c
42176@@ -53,6 +53,9 @@ struct drm_ctx_list {
42177 */
42178 void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
42179 {
42180+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42181+ return;
42182+
42183 mutex_lock(&dev->struct_mutex);
42184 idr_remove(&dev->ctx_idr, ctx_handle);
42185 mutex_unlock(&dev->struct_mutex);
42186@@ -87,6 +90,9 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
42187 */
42188 int drm_legacy_ctxbitmap_init(struct drm_device * dev)
42189 {
42190+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42191+ return -EINVAL;
42192+
42193 idr_init(&dev->ctx_idr);
42194 return 0;
42195 }
42196@@ -101,6 +107,9 @@ int drm_legacy_ctxbitmap_init(struct drm_device * dev)
42197 */
42198 void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
42199 {
42200+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42201+ return;
42202+
42203 mutex_lock(&dev->struct_mutex);
42204 idr_destroy(&dev->ctx_idr);
42205 mutex_unlock(&dev->struct_mutex);
42206@@ -119,11 +128,14 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
42207 {
42208 struct drm_ctx_list *pos, *tmp;
42209
42210+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42211+ return;
42212+
42213 mutex_lock(&dev->ctxlist_mutex);
42214
42215 list_for_each_entry_safe(pos, tmp, &dev->ctxlist, head) {
42216 if (pos->tag == file &&
42217- pos->handle != DRM_KERNEL_CONTEXT) {
42218+ _DRM_LOCKING_CONTEXT(pos->handle) != DRM_KERNEL_CONTEXT) {
42219 if (dev->driver->context_dtor)
42220 dev->driver->context_dtor(dev, pos->handle);
42221
42222@@ -161,6 +173,9 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
42223 struct drm_local_map *map;
42224 struct drm_map_list *_entry;
42225
42226+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42227+ return -EINVAL;
42228+
42229 mutex_lock(&dev->struct_mutex);
42230
42231 map = idr_find(&dev->ctx_idr, request->ctx_id);
42232@@ -205,6 +220,9 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
42233 struct drm_local_map *map = NULL;
42234 struct drm_map_list *r_list = NULL;
42235
42236+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42237+ return -EINVAL;
42238+
42239 mutex_lock(&dev->struct_mutex);
42240 list_for_each_entry(r_list, &dev->maplist, head) {
42241 if (r_list->map
42242@@ -277,7 +295,13 @@ static int drm_context_switch_complete(struct drm_device *dev,
42243 {
42244 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
42245
42246- if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) {
42247+ if (file_priv->master->lock.hw_lock == NULL) {
42248+ DRM_ERROR(
42249+ "Device has been unregistered. Hard exit. Process %d\n",
42250+ task_pid_nr(current));
42251+ send_sig(SIGTERM, current, 0);
42252+ return -EPERM;
42253+ } else if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) {
42254 DRM_ERROR("Lock isn't held after context switch\n");
42255 }
42256
42257@@ -305,6 +329,9 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
42258 struct drm_ctx ctx;
42259 int i;
42260
42261+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42262+ return -EINVAL;
42263+
42264 if (res->count >= DRM_RESERVED_CONTEXTS) {
42265 memset(&ctx, 0, sizeof(ctx));
42266 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
42267@@ -335,8 +362,11 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
42268 struct drm_ctx_list *ctx_entry;
42269 struct drm_ctx *ctx = data;
42270
42271+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42272+ return -EINVAL;
42273+
42274 ctx->handle = drm_legacy_ctxbitmap_next(dev);
42275- if (ctx->handle == DRM_KERNEL_CONTEXT) {
42276+ if (_DRM_LOCKING_CONTEXT(ctx->handle) == DRM_KERNEL_CONTEXT) {
42277 /* Skip kernel's context and get a new one. */
42278 ctx->handle = drm_legacy_ctxbitmap_next(dev);
42279 }
42280@@ -378,6 +408,9 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
42281 {
42282 struct drm_ctx *ctx = data;
42283
42284+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42285+ return -EINVAL;
42286+
42287 /* This is 0, because we don't handle any context flags */
42288 ctx->flags = 0;
42289
42290@@ -400,6 +433,9 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
42291 {
42292 struct drm_ctx *ctx = data;
42293
42294+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42295+ return -EINVAL;
42296+
42297 DRM_DEBUG("%d\n", ctx->handle);
42298 return drm_context_switch(dev, dev->last_context, ctx->handle);
42299 }
42300@@ -420,6 +456,9 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
42301 {
42302 struct drm_ctx *ctx = data;
42303
42304+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42305+ return -EINVAL;
42306+
42307 DRM_DEBUG("%d\n", ctx->handle);
42308 drm_context_switch_complete(dev, file_priv, ctx->handle);
42309
42310@@ -442,8 +481,11 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
42311 {
42312 struct drm_ctx *ctx = data;
42313
42314+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42315+ return -EINVAL;
42316+
42317 DRM_DEBUG("%d\n", ctx->handle);
42318- if (ctx->handle != DRM_KERNEL_CONTEXT) {
42319+ if (_DRM_LOCKING_CONTEXT(ctx->handle) != DRM_KERNEL_CONTEXT) {
42320 if (dev->driver->context_dtor)
42321 dev->driver->context_dtor(dev, ctx->handle);
42322 drm_legacy_ctxbitmap_free(dev, ctx->handle);
42323diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
42324index fed7483..5bc0335 100644
42325--- a/drivers/gpu/drm/drm_crtc.c
42326+++ b/drivers/gpu/drm/drm_crtc.c
42327@@ -4174,7 +4174,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
42328 goto done;
42329 }
42330
42331- if (copy_to_user(&enum_ptr[copied].name,
42332+ if (copy_to_user(enum_ptr[copied].name,
42333 &prop_enum->name, DRM_PROP_NAME_LEN)) {
42334 ret = -EFAULT;
42335 goto done;
42336diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
42337index b7bf4ce..585cf3b 100644
42338--- a/drivers/gpu/drm/drm_drv.c
42339+++ b/drivers/gpu/drm/drm_drv.c
42340@@ -434,7 +434,7 @@ void drm_unplug_dev(struct drm_device *dev)
42341
42342 drm_device_set_unplugged(dev);
42343
42344- if (dev->open_count == 0) {
42345+ if (local_read(&dev->open_count) == 0) {
42346 drm_put_dev(dev);
42347 }
42348 mutex_unlock(&drm_global_mutex);
42349@@ -582,10 +582,13 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
42350 if (drm_ht_create(&dev->map_hash, 12))
42351 goto err_minors;
42352
42353- ret = drm_legacy_ctxbitmap_init(dev);
42354- if (ret) {
42355- DRM_ERROR("Cannot allocate memory for context bitmap.\n");
42356- goto err_ht;
42357+ if (drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT)) {
42358+ ret = drm_legacy_ctxbitmap_init(dev);
42359+ if (ret) {
42360+ DRM_ERROR(
42361+ "Cannot allocate memory for context bitmap.\n");
42362+ goto err_ht;
42363+ }
42364 }
42365
42366 if (drm_core_check_feature(dev, DRIVER_GEM)) {
42367diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
42368index c59ce4d..056d413 100644
42369--- a/drivers/gpu/drm/drm_fops.c
42370+++ b/drivers/gpu/drm/drm_fops.c
42371@@ -89,7 +89,7 @@ int drm_open(struct inode *inode, struct file *filp)
42372 return PTR_ERR(minor);
42373
42374 dev = minor->dev;
42375- if (!dev->open_count++)
42376+ if (local_inc_return(&dev->open_count) == 1)
42377 need_setup = 1;
42378
42379 /* share address_space across all char-devs of a single device */
42380@@ -106,7 +106,7 @@ int drm_open(struct inode *inode, struct file *filp)
42381 return 0;
42382
42383 err_undo:
42384- dev->open_count--;
42385+ local_dec(&dev->open_count);
42386 drm_minor_release(minor);
42387 return retcode;
42388 }
42389@@ -377,7 +377,7 @@ int drm_release(struct inode *inode, struct file *filp)
42390
42391 mutex_lock(&drm_global_mutex);
42392
42393- DRM_DEBUG("open_count = %d\n", dev->open_count);
42394+ DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
42395
42396 mutex_lock(&dev->struct_mutex);
42397 list_del(&file_priv->lhead);
42398@@ -392,10 +392,10 @@ int drm_release(struct inode *inode, struct file *filp)
42399 * Begin inline drm_release
42400 */
42401
42402- DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
42403+ DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
42404 task_pid_nr(current),
42405 (long)old_encode_dev(file_priv->minor->kdev->devt),
42406- dev->open_count);
42407+ local_read(&dev->open_count));
42408
42409 /* if the master has gone away we can't do anything with the lock */
42410 if (file_priv->minor->master)
42411@@ -465,7 +465,7 @@ int drm_release(struct inode *inode, struct file *filp)
42412 * End inline drm_release
42413 */
42414
42415- if (!--dev->open_count) {
42416+ if (local_dec_and_test(&dev->open_count)) {
42417 retcode = drm_lastclose(dev);
42418 if (drm_device_is_unplugged(dev))
42419 drm_put_dev(dev);
42420diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
42421index 3d2e91c..d31c4c9 100644
42422--- a/drivers/gpu/drm/drm_global.c
42423+++ b/drivers/gpu/drm/drm_global.c
42424@@ -36,7 +36,7 @@
42425 struct drm_global_item {
42426 struct mutex mutex;
42427 void *object;
42428- int refcount;
42429+ atomic_t refcount;
42430 };
42431
42432 static struct drm_global_item glob[DRM_GLOBAL_NUM];
42433@@ -49,7 +49,7 @@ void drm_global_init(void)
42434 struct drm_global_item *item = &glob[i];
42435 mutex_init(&item->mutex);
42436 item->object = NULL;
42437- item->refcount = 0;
42438+ atomic_set(&item->refcount, 0);
42439 }
42440 }
42441
42442@@ -59,7 +59,7 @@ void drm_global_release(void)
42443 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
42444 struct drm_global_item *item = &glob[i];
42445 BUG_ON(item->object != NULL);
42446- BUG_ON(item->refcount != 0);
42447+ BUG_ON(atomic_read(&item->refcount) != 0);
42448 }
42449 }
42450
42451@@ -69,7 +69,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
42452 struct drm_global_item *item = &glob[ref->global_type];
42453
42454 mutex_lock(&item->mutex);
42455- if (item->refcount == 0) {
42456+ if (atomic_read(&item->refcount) == 0) {
42457 item->object = kzalloc(ref->size, GFP_KERNEL);
42458 if (unlikely(item->object == NULL)) {
42459 ret = -ENOMEM;
42460@@ -82,7 +82,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
42461 goto out_err;
42462
42463 }
42464- ++item->refcount;
42465+ atomic_inc(&item->refcount);
42466 ref->object = item->object;
42467 mutex_unlock(&item->mutex);
42468 return 0;
42469@@ -98,9 +98,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
42470 struct drm_global_item *item = &glob[ref->global_type];
42471
42472 mutex_lock(&item->mutex);
42473- BUG_ON(item->refcount == 0);
42474+ BUG_ON(atomic_read(&item->refcount) == 0);
42475 BUG_ON(ref->object != item->object);
42476- if (--item->refcount == 0) {
42477+ if (atomic_dec_and_test(&item->refcount)) {
42478 ref->release(ref);
42479 item->object = NULL;
42480 }
42481diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
42482index cbb4fc0..5c756cb9 100644
42483--- a/drivers/gpu/drm/drm_info.c
42484+++ b/drivers/gpu/drm/drm_info.c
42485@@ -77,10 +77,13 @@ int drm_vm_info(struct seq_file *m, void *data)
42486 struct drm_local_map *map;
42487 struct drm_map_list *r_list;
42488
42489- /* Hardcoded from _DRM_FRAME_BUFFER,
42490- _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
42491- _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
42492- const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
42493+ static const char * const types[] = {
42494+ [_DRM_FRAME_BUFFER] = "FB",
42495+ [_DRM_REGISTERS] = "REG",
42496+ [_DRM_SHM] = "SHM",
42497+ [_DRM_AGP] = "AGP",
42498+ [_DRM_SCATTER_GATHER] = "SG",
42499+ [_DRM_CONSISTENT] = "PCI"};
42500 const char *type;
42501 int i;
42502
42503@@ -91,7 +94,7 @@ int drm_vm_info(struct seq_file *m, void *data)
42504 map = r_list->map;
42505 if (!map)
42506 continue;
42507- if (map->type < 0 || map->type > 5)
42508+ if (map->type >= ARRAY_SIZE(types))
42509 type = "??";
42510 else
42511 type = types[map->type];
42512diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
42513index 9cfcd0a..7142a7f 100644
42514--- a/drivers/gpu/drm/drm_ioc32.c
42515+++ b/drivers/gpu/drm/drm_ioc32.c
42516@@ -459,7 +459,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
42517 request = compat_alloc_user_space(nbytes);
42518 if (!access_ok(VERIFY_WRITE, request, nbytes))
42519 return -EFAULT;
42520- list = (struct drm_buf_desc *) (request + 1);
42521+ list = (struct drm_buf_desc __user *) (request + 1);
42522
42523 if (__put_user(count, &request->count)
42524 || __put_user(list, &request->list))
42525@@ -520,7 +520,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
42526 request = compat_alloc_user_space(nbytes);
42527 if (!access_ok(VERIFY_WRITE, request, nbytes))
42528 return -EFAULT;
42529- list = (struct drm_buf_pub *) (request + 1);
42530+ list = (struct drm_buf_pub __user *) (request + 1);
42531
42532 if (__put_user(count, &request->count)
42533 || __put_user(list, &request->list))
42534@@ -1075,7 +1075,7 @@ static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
42535 return 0;
42536 }
42537
42538-static drm_ioctl_compat_t *drm_compat_ioctls[] = {
42539+static drm_ioctl_compat_t drm_compat_ioctls[] = {
42540 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
42541 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
42542 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
42543@@ -1122,7 +1122,6 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = {
42544 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42545 {
42546 unsigned int nr = DRM_IOCTL_NR(cmd);
42547- drm_ioctl_compat_t *fn;
42548 int ret;
42549
42550 /* Assume that ioctls without an explicit compat routine will just
42551@@ -1132,10 +1131,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42552 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
42553 return drm_ioctl(filp, cmd, arg);
42554
42555- fn = drm_compat_ioctls[nr];
42556-
42557- if (fn != NULL)
42558- ret = (*fn) (filp, cmd, arg);
42559+ if (drm_compat_ioctls[nr] != NULL)
42560+ ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
42561 else
42562 ret = drm_ioctl(filp, cmd, arg);
42563
42564diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
42565index b1d303f..c59012c 100644
42566--- a/drivers/gpu/drm/drm_ioctl.c
42567+++ b/drivers/gpu/drm/drm_ioctl.c
42568@@ -650,7 +650,7 @@ long drm_ioctl(struct file *filp,
42569 struct drm_file *file_priv = filp->private_data;
42570 struct drm_device *dev;
42571 const struct drm_ioctl_desc *ioctl = NULL;
42572- drm_ioctl_t *func;
42573+ drm_ioctl_no_const_t func;
42574 unsigned int nr = DRM_IOCTL_NR(cmd);
42575 int retcode = -EINVAL;
42576 char stack_kdata[128];
42577diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
42578index 4924d381..fd3b5ee 100644
42579--- a/drivers/gpu/drm/drm_lock.c
42580+++ b/drivers/gpu/drm/drm_lock.c
42581@@ -61,12 +61,15 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
42582 struct drm_master *master = file_priv->master;
42583 int ret = 0;
42584
42585+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42586+ return -EINVAL;
42587+
42588 if (drm_core_check_feature(dev, DRIVER_MODESET))
42589 return -EINVAL;
42590
42591 ++file_priv->lock_count;
42592
42593- if (lock->context == DRM_KERNEL_CONTEXT) {
42594+ if (_DRM_LOCKING_CONTEXT(lock->context) == DRM_KERNEL_CONTEXT) {
42595 DRM_ERROR("Process %d using kernel context %d\n",
42596 task_pid_nr(current), lock->context);
42597 return -EINVAL;
42598@@ -156,6 +159,9 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
42599 struct drm_lock *lock = data;
42600 struct drm_master *master = file_priv->master;
42601
42602+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
42603+ return -EINVAL;
42604+
42605 if (drm_core_check_feature(dev, DRIVER_MODESET))
42606 return -EINVAL;
42607
42608@@ -165,6 +171,14 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
42609 return -EINVAL;
42610 }
42611
42612+ if (!master->lock.hw_lock) {
42613+ DRM_ERROR(
42614+ "Device has been unregistered. Hard exit. Process %d\n",
42615+ task_pid_nr(current));
42616+ send_sig(SIGTERM, current, 0);
42617+ return -EPERM;
42618+ }
42619+
42620 if (drm_legacy_lock_free(&master->lock, lock->context)) {
42621 /* FIXME: Should really bail out here. */
42622 }
42623diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
42624index d4813e0..6c1ab4d 100644
42625--- a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
42626+++ b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
42627@@ -825,10 +825,16 @@ void mdfld_dsi_dpi_mode_set(struct drm_encoder *encoder,
42628 u32 pipeconf_reg = PIPEACONF;
42629 u32 dspcntr_reg = DSPACNTR;
42630
42631- u32 pipeconf = dev_priv->pipeconf[pipe];
42632- u32 dspcntr = dev_priv->dspcntr[pipe];
42633+ u32 pipeconf;
42634+ u32 dspcntr;
42635 u32 mipi = MIPI_PORT_EN | PASS_FROM_SPHY_TO_AFE | SEL_FLOPPED_HSTX;
42636
42637+ if (pipe == -1)
42638+ return;
42639+
42640+ pipeconf = dev_priv->pipeconf[pipe];
42641+ dspcntr = dev_priv->dspcntr[pipe];
42642+
42643 if (pipe) {
42644 pipeconf_reg = PIPECCONF;
42645 dspcntr_reg = DSPCCNTR;
42646diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
42647index 93ec5dc..82acbaf 100644
42648--- a/drivers/gpu/drm/i810/i810_drv.h
42649+++ b/drivers/gpu/drm/i810/i810_drv.h
42650@@ -110,8 +110,8 @@ typedef struct drm_i810_private {
42651 int page_flipping;
42652
42653 wait_queue_head_t irq_queue;
42654- atomic_t irq_received;
42655- atomic_t irq_emitted;
42656+ atomic_unchecked_t irq_received;
42657+ atomic_unchecked_t irq_emitted;
42658
42659 int front_offset;
42660 } drm_i810_private_t;
42661diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
42662index 82bbe3f..ce004bf 100644
42663--- a/drivers/gpu/drm/i915/i915_debugfs.c
42664+++ b/drivers/gpu/drm/i915/i915_debugfs.c
42665@@ -480,7 +480,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
42666 seq_printf(m, "%u fault mappable objects, %zu bytes\n",
42667 count, size);
42668
42669- seq_printf(m, "%zu [%lu] gtt total\n",
42670+ seq_printf(m, "%llu [%llu] gtt total\n",
42671 dev_priv->gtt.base.total,
42672 dev_priv->gtt.mappable_end - dev_priv->gtt.base.start);
42673
42674diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
42675index d2df321..f746478 100644
42676--- a/drivers/gpu/drm/i915/i915_dma.c
42677+++ b/drivers/gpu/drm/i915/i915_dma.c
42678@@ -162,6 +162,8 @@ static int i915_getparam(struct drm_device *dev, void *data,
42679 value = INTEL_INFO(dev)->eu_total;
42680 if (!value)
42681 return -ENODEV;
42682+ case I915_PARAM_HAS_LEGACY_CONTEXT:
42683+ value = drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT);
42684 break;
42685 default:
42686 DRM_DEBUG("Unknown parameter %d\n", param->param);
42687@@ -376,7 +378,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
42688 * locking inversion with the driver load path. And the access here is
42689 * completely racy anyway. So don't bother with locking for now.
42690 */
42691- return dev->open_count == 0;
42692+ return local_read(&dev->open_count) == 0;
42693 }
42694
42695 static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {
42696diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
42697index 5e6b4a2..6ba2c85 100644
42698--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
42699+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
42700@@ -935,12 +935,12 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
42701 static int
42702 validate_exec_list(struct drm_device *dev,
42703 struct drm_i915_gem_exec_object2 *exec,
42704- int count)
42705+ unsigned int count)
42706 {
42707 unsigned relocs_total = 0;
42708 unsigned relocs_max = UINT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
42709 unsigned invalid_flags;
42710- int i;
42711+ unsigned int i;
42712
42713 invalid_flags = __EXEC_OBJECT_UNKNOWN_FLAGS;
42714 if (USES_FULL_PPGTT(dev))
42715diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
42716index 31e8269..7055934 100644
42717--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
42718+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
42719@@ -2360,10 +2360,10 @@ static void chv_setup_private_ppat(struct drm_i915_private *dev_priv)
42720 }
42721
42722 static int gen8_gmch_probe(struct drm_device *dev,
42723- size_t *gtt_total,
42724- size_t *stolen,
42725- phys_addr_t *mappable_base,
42726- unsigned long *mappable_end)
42727+ uint64_t *gtt_total,
42728+ uint64_t *stolen,
42729+ uint64_t *mappable_base,
42730+ uint64_t *mappable_end)
42731 {
42732 struct drm_i915_private *dev_priv = dev->dev_private;
42733 unsigned int gtt_size;
42734@@ -2408,10 +2408,10 @@ static int gen8_gmch_probe(struct drm_device *dev,
42735 }
42736
42737 static int gen6_gmch_probe(struct drm_device *dev,
42738- size_t *gtt_total,
42739- size_t *stolen,
42740- phys_addr_t *mappable_base,
42741- unsigned long *mappable_end)
42742+ uint64_t *gtt_total,
42743+ uint64_t *stolen,
42744+ uint64_t *mappable_base,
42745+ uint64_t *mappable_end)
42746 {
42747 struct drm_i915_private *dev_priv = dev->dev_private;
42748 unsigned int gtt_size;
42749@@ -2425,7 +2425,7 @@ static int gen6_gmch_probe(struct drm_device *dev,
42750 * a coarse sanity check.
42751 */
42752 if ((*mappable_end < (64<<20) || (*mappable_end > (512<<20)))) {
42753- DRM_ERROR("Unknown GMADR size (%lx)\n",
42754+ DRM_ERROR("Unknown GMADR size (%llx)\n",
42755 dev_priv->gtt.mappable_end);
42756 return -ENXIO;
42757 }
42758@@ -2459,10 +2459,10 @@ static void gen6_gmch_remove(struct i915_address_space *vm)
42759 }
42760
42761 static int i915_gmch_probe(struct drm_device *dev,
42762- size_t *gtt_total,
42763- size_t *stolen,
42764- phys_addr_t *mappable_base,
42765- unsigned long *mappable_end)
42766+ uint64_t *gtt_total,
42767+ uint64_t *stolen,
42768+ uint64_t *mappable_base,
42769+ uint64_t *mappable_end)
42770 {
42771 struct drm_i915_private *dev_priv = dev->dev_private;
42772 int ret;
42773@@ -2527,10 +2527,10 @@ int i915_gem_gtt_init(struct drm_device *dev)
42774 gtt->base.dev = dev;
42775
42776 /* GMADR is the PCI mmio aperture into the global GTT. */
42777- DRM_INFO("Memory usable by graphics device = %zdM\n",
42778+ DRM_INFO("Memory usable by graphics device = %lldM\n",
42779 gtt->base.total >> 20);
42780- DRM_DEBUG_DRIVER("GMADR size = %ldM\n", gtt->mappable_end >> 20);
42781- DRM_DEBUG_DRIVER("GTT stolen size = %zdM\n", gtt->stolen_size >> 20);
42782+ DRM_DEBUG_DRIVER("GMADR size = %lldM\n", gtt->mappable_end >> 20);
42783+ DRM_DEBUG_DRIVER("GTT stolen size = %lldM\n", gtt->stolen_size >> 20);
42784 #ifdef CONFIG_INTEL_IOMMU
42785 if (intel_iommu_gfx_mapped)
42786 DRM_INFO("VT-d active for gfx access\n");
42787diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
42788index 0d46dd2..1171c00 100644
42789--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
42790+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
42791@@ -233,8 +233,8 @@ struct i915_address_space {
42792 struct drm_mm mm;
42793 struct drm_device *dev;
42794 struct list_head global_link;
42795- unsigned long start; /* Start offset always 0 for dri2 */
42796- size_t total; /* size addr space maps (ex. 2GB for ggtt) */
42797+ uint64_t start; /* Start offset always 0 for dri2 */
42798+ uint64_t total; /* size addr space maps (ex. 2GB for ggtt) */
42799
42800 struct {
42801 dma_addr_t addr;
42802@@ -300,11 +300,11 @@ struct i915_address_space {
42803 */
42804 struct i915_gtt {
42805 struct i915_address_space base;
42806- size_t stolen_size; /* Total size of stolen memory */
42807+ uint64_t stolen_size; /* Total size of stolen memory */
42808
42809- unsigned long mappable_end; /* End offset that we can CPU map */
42810+ uint64_t mappable_end; /* End offset that we can CPU map */
42811 struct io_mapping *mappable; /* Mapping to our CPU mappable region */
42812- phys_addr_t mappable_base; /* PA of our GMADR */
42813+ uint64_t mappable_base; /* PA of our GMADR */
42814
42815 /** "Graphics Stolen Memory" holds the global PTEs */
42816 void __iomem *gsm;
42817@@ -314,9 +314,9 @@ struct i915_gtt {
42818 int mtrr;
42819
42820 /* global gtt ops */
42821- int (*gtt_probe)(struct drm_device *dev, size_t *gtt_total,
42822- size_t *stolen, phys_addr_t *mappable_base,
42823- unsigned long *mappable_end);
42824+ int (*gtt_probe)(struct drm_device *dev, uint64_t *gtt_total,
42825+ uint64_t *stolen, uint64_t *mappable_base,
42826+ uint64_t *mappable_end);
42827 };
42828
42829 struct i915_hw_ppgtt {
42830diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
42831index 8b5b784..78711f6 100644
42832--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
42833+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
42834@@ -310,7 +310,7 @@ int i915_gem_init_stolen(struct drm_device *dev)
42835 if (dev_priv->mm.stolen_base == 0)
42836 return 0;
42837
42838- DRM_DEBUG_KMS("found %zd bytes of stolen memory at %08lx\n",
42839+ DRM_DEBUG_KMS("found %lld bytes of stolen memory at %08lx\n",
42840 dev_priv->gtt.stolen_size, dev_priv->mm.stolen_base);
42841
42842 if (INTEL_INFO(dev)->gen >= 8) {
42843diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
42844index 23aa04c..1d25960 100644
42845--- a/drivers/gpu/drm/i915/i915_ioc32.c
42846+++ b/drivers/gpu/drm/i915/i915_ioc32.c
42847@@ -62,7 +62,7 @@ static int compat_i915_batchbuffer(struct file *file, unsigned int cmd,
42848 || __put_user(batchbuffer32.DR4, &batchbuffer->DR4)
42849 || __put_user(batchbuffer32.num_cliprects,
42850 &batchbuffer->num_cliprects)
42851- || __put_user((int __user *)(unsigned long)batchbuffer32.cliprects,
42852+ || __put_user((struct drm_clip_rect __user *)(unsigned long)batchbuffer32.cliprects,
42853 &batchbuffer->cliprects))
42854 return -EFAULT;
42855
42856@@ -91,13 +91,13 @@ static int compat_i915_cmdbuffer(struct file *file, unsigned int cmd,
42857
42858 cmdbuffer = compat_alloc_user_space(sizeof(*cmdbuffer));
42859 if (!access_ok(VERIFY_WRITE, cmdbuffer, sizeof(*cmdbuffer))
42860- || __put_user((int __user *)(unsigned long)cmdbuffer32.buf,
42861+ || __put_user((char __user *)(unsigned long)cmdbuffer32.buf,
42862 &cmdbuffer->buf)
42863 || __put_user(cmdbuffer32.sz, &cmdbuffer->sz)
42864 || __put_user(cmdbuffer32.DR1, &cmdbuffer->DR1)
42865 || __put_user(cmdbuffer32.DR4, &cmdbuffer->DR4)
42866 || __put_user(cmdbuffer32.num_cliprects, &cmdbuffer->num_cliprects)
42867- || __put_user((int __user *)(unsigned long)cmdbuffer32.cliprects,
42868+ || __put_user((struct drm_clip_rect __user *)(unsigned long)cmdbuffer32.cliprects,
42869 &cmdbuffer->cliprects))
42870 return -EFAULT;
42871
42872@@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
42873 (unsigned long)request);
42874 }
42875
42876-static drm_ioctl_compat_t *i915_compat_ioctls[] = {
42877+static drm_ioctl_compat_t i915_compat_ioctls[] = {
42878 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
42879 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
42880 [DRM_I915_GETPARAM] = compat_i915_getparam,
42881@@ -201,17 +201,13 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
42882 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42883 {
42884 unsigned int nr = DRM_IOCTL_NR(cmd);
42885- drm_ioctl_compat_t *fn = NULL;
42886 int ret;
42887
42888 if (nr < DRM_COMMAND_BASE || nr >= DRM_COMMAND_END)
42889 return drm_compat_ioctl(filp, cmd, arg);
42890
42891- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(i915_compat_ioctls))
42892- fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
42893-
42894- if (fn != NULL)
42895- ret = (*fn) (filp, cmd, arg);
42896+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(i915_compat_ioctls) && i915_compat_ioctls[nr - DRM_COMMAND_BASE])
42897+ ret = (*i915_compat_ioctls[nr - DRM_COMMAND_BASE])(filp, cmd, arg);
42898 else
42899 ret = drm_ioctl(filp, cmd, arg);
42900
42901diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
42902index 107c6c0..e1926b0 100644
42903--- a/drivers/gpu/drm/i915/intel_display.c
42904+++ b/drivers/gpu/drm/i915/intel_display.c
42905@@ -14501,13 +14501,13 @@ struct intel_quirk {
42906 int subsystem_vendor;
42907 int subsystem_device;
42908 void (*hook)(struct drm_device *dev);
42909-};
42910+} __do_const;
42911
42912 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
42913 struct intel_dmi_quirk {
42914 void (*hook)(struct drm_device *dev);
42915 const struct dmi_system_id (*dmi_id_list)[];
42916-};
42917+} __do_const;
42918
42919 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
42920 {
42921@@ -14515,18 +14515,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
42922 return 1;
42923 }
42924
42925-static const struct intel_dmi_quirk intel_dmi_quirks[] = {
42926+static const struct dmi_system_id intel_dmi_quirks_table[] = {
42927 {
42928- .dmi_id_list = &(const struct dmi_system_id[]) {
42929- {
42930- .callback = intel_dmi_reverse_brightness,
42931- .ident = "NCR Corporation",
42932- .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
42933- DMI_MATCH(DMI_PRODUCT_NAME, ""),
42934- },
42935- },
42936- { } /* terminating entry */
42937+ .callback = intel_dmi_reverse_brightness,
42938+ .ident = "NCR Corporation",
42939+ .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
42940+ DMI_MATCH(DMI_PRODUCT_NAME, ""),
42941 },
42942+ },
42943+ { } /* terminating entry */
42944+};
42945+
42946+static const struct intel_dmi_quirk intel_dmi_quirks[] = {
42947+ {
42948+ .dmi_id_list = &intel_dmi_quirks_table,
42949 .hook = quirk_invert_brightness,
42950 },
42951 };
42952diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
42953index 74f505b..21f6914 100644
42954--- a/drivers/gpu/drm/imx/imx-drm-core.c
42955+++ b/drivers/gpu/drm/imx/imx-drm-core.c
42956@@ -355,7 +355,7 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
42957 if (imxdrm->pipes >= MAX_CRTC)
42958 return -EINVAL;
42959
42960- if (imxdrm->drm->open_count)
42961+ if (local_read(&imxdrm->drm->open_count))
42962 return -EBUSY;
42963
42964 imx_drm_crtc = kzalloc(sizeof(*imx_drm_crtc), GFP_KERNEL);
42965diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
42966index b4a20149..219ab78 100644
42967--- a/drivers/gpu/drm/mga/mga_drv.h
42968+++ b/drivers/gpu/drm/mga/mga_drv.h
42969@@ -122,9 +122,9 @@ typedef struct drm_mga_private {
42970 u32 clear_cmd;
42971 u32 maccess;
42972
42973- atomic_t vbl_received; /**< Number of vblanks received. */
42974+ atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
42975 wait_queue_head_t fence_queue;
42976- atomic_t last_fence_retired;
42977+ atomic_unchecked_t last_fence_retired;
42978 u32 next_fence_to_post;
42979
42980 unsigned int fb_cpp;
42981diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
42982index 729bfd5..14bae78 100644
42983--- a/drivers/gpu/drm/mga/mga_ioc32.c
42984+++ b/drivers/gpu/drm/mga/mga_ioc32.c
42985@@ -190,7 +190,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
42986 return 0;
42987 }
42988
42989-drm_ioctl_compat_t *mga_compat_ioctls[] = {
42990+drm_ioctl_compat_t mga_compat_ioctls[] = {
42991 [DRM_MGA_INIT] = compat_mga_init,
42992 [DRM_MGA_GETPARAM] = compat_mga_getparam,
42993 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
42994@@ -208,17 +208,13 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
42995 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42996 {
42997 unsigned int nr = DRM_IOCTL_NR(cmd);
42998- drm_ioctl_compat_t *fn = NULL;
42999 int ret;
43000
43001 if (nr < DRM_COMMAND_BASE)
43002 return drm_compat_ioctl(filp, cmd, arg);
43003
43004- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(mga_compat_ioctls))
43005- fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
43006-
43007- if (fn != NULL)
43008- ret = (*fn) (filp, cmd, arg);
43009+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(mga_compat_ioctls) && mga_compat_ioctls[nr - DRM_COMMAND_BASE])
43010+ ret = (*mga_compat_ioctls[nr - DRM_COMMAND_BASE]) (filp, cmd, arg);
43011 else
43012 ret = drm_ioctl(filp, cmd, arg);
43013
43014diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
43015index 1b071b8..de8601a 100644
43016--- a/drivers/gpu/drm/mga/mga_irq.c
43017+++ b/drivers/gpu/drm/mga/mga_irq.c
43018@@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
43019 if (crtc != 0)
43020 return 0;
43021
43022- return atomic_read(&dev_priv->vbl_received);
43023+ return atomic_read_unchecked(&dev_priv->vbl_received);
43024 }
43025
43026
43027@@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
43028 /* VBLANK interrupt */
43029 if (status & MGA_VLINEPEN) {
43030 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
43031- atomic_inc(&dev_priv->vbl_received);
43032+ atomic_inc_unchecked(&dev_priv->vbl_received);
43033 drm_handle_vblank(dev, 0);
43034 handled = 1;
43035 }
43036@@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
43037 if ((prim_start & ~0x03) != (prim_end & ~0x03))
43038 MGA_WRITE(MGA_PRIMEND, prim_end);
43039
43040- atomic_inc(&dev_priv->last_fence_retired);
43041+ atomic_inc_unchecked(&dev_priv->last_fence_retired);
43042 wake_up(&dev_priv->fence_queue);
43043 handled = 1;
43044 }
43045@@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
43046 * using fences.
43047 */
43048 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * HZ,
43049- (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
43050+ (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
43051 - *sequence) <= (1 << 23)));
43052
43053 *sequence = cur_fence;
43054diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
43055index 0190b69..60c3eaf 100644
43056--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
43057+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
43058@@ -963,7 +963,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
43059 struct bit_table {
43060 const char id;
43061 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
43062-};
43063+} __no_const;
43064
43065 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
43066
43067diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
43068index 477cbb1..109b826 100644
43069--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
43070+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
43071@@ -946,7 +946,8 @@ static struct drm_driver
43072 driver_stub = {
43073 .driver_features =
43074 DRIVER_USE_AGP |
43075- DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER,
43076+ DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER |
43077+ DRIVER_KMS_LEGACY_CONTEXT,
43078
43079 .load = nouveau_drm_load,
43080 .unload = nouveau_drm_unload,
43081diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
43082index dd72652..1fd2368 100644
43083--- a/drivers/gpu/drm/nouveau/nouveau_drm.h
43084+++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
43085@@ -123,7 +123,6 @@ struct nouveau_drm {
43086 struct drm_global_reference mem_global_ref;
43087 struct ttm_bo_global_ref bo_global_ref;
43088 struct ttm_bo_device bdev;
43089- atomic_t validate_sequence;
43090 int (*move)(struct nouveau_channel *,
43091 struct ttm_buffer_object *,
43092 struct ttm_mem_reg *, struct ttm_mem_reg *);
43093diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
43094index 462679a..88e32a7 100644
43095--- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
43096+++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
43097@@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
43098 unsigned long arg)
43099 {
43100 unsigned int nr = DRM_IOCTL_NR(cmd);
43101- drm_ioctl_compat_t *fn = NULL;
43102+ drm_ioctl_compat_t fn = NULL;
43103 int ret;
43104
43105 if (nr < DRM_COMMAND_BASE)
43106diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
43107index 7464aef3..c63ae4f 100644
43108--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
43109+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
43110@@ -130,11 +130,11 @@ nouveau_vram_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
43111 }
43112
43113 const struct ttm_mem_type_manager_func nouveau_vram_manager = {
43114- nouveau_vram_manager_init,
43115- nouveau_vram_manager_fini,
43116- nouveau_vram_manager_new,
43117- nouveau_vram_manager_del,
43118- nouveau_vram_manager_debug
43119+ .init = nouveau_vram_manager_init,
43120+ .takedown = nouveau_vram_manager_fini,
43121+ .get_node = nouveau_vram_manager_new,
43122+ .put_node = nouveau_vram_manager_del,
43123+ .debug = nouveau_vram_manager_debug
43124 };
43125
43126 static int
43127@@ -207,11 +207,11 @@ nouveau_gart_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
43128 }
43129
43130 const struct ttm_mem_type_manager_func nouveau_gart_manager = {
43131- nouveau_gart_manager_init,
43132- nouveau_gart_manager_fini,
43133- nouveau_gart_manager_new,
43134- nouveau_gart_manager_del,
43135- nouveau_gart_manager_debug
43136+ .init = nouveau_gart_manager_init,
43137+ .takedown = nouveau_gart_manager_fini,
43138+ .get_node = nouveau_gart_manager_new,
43139+ .put_node = nouveau_gart_manager_del,
43140+ .debug = nouveau_gart_manager_debug
43141 };
43142
43143 /*XXX*/
43144@@ -280,11 +280,11 @@ nv04_gart_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
43145 }
43146
43147 const struct ttm_mem_type_manager_func nv04_gart_manager = {
43148- nv04_gart_manager_init,
43149- nv04_gart_manager_fini,
43150- nv04_gart_manager_new,
43151- nv04_gart_manager_del,
43152- nv04_gart_manager_debug
43153+ .init = nv04_gart_manager_init,
43154+ .takedown = nv04_gart_manager_fini,
43155+ .get_node = nv04_gart_manager_new,
43156+ .put_node = nv04_gart_manager_del,
43157+ .debug = nv04_gart_manager_debug
43158 };
43159
43160 int
43161diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
43162index c7592ec..dd45ebc 100644
43163--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
43164+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
43165@@ -72,7 +72,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
43166 * locking inversion with the driver load path. And the access here is
43167 * completely racy anyway. So don't bother with locking for now.
43168 */
43169- return dev->open_count == 0;
43170+ return local_read(&dev->open_count) == 0;
43171 }
43172
43173 static const struct vga_switcheroo_client_ops
43174diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
43175index 778372b..4b81cb4 100644
43176--- a/drivers/gpu/drm/omapdrm/Makefile
43177+++ b/drivers/gpu/drm/omapdrm/Makefile
43178@@ -3,7 +3,7 @@
43179 # Direct Rendering Infrastructure (DRI)
43180 #
43181
43182-ccflags-y := -Iinclude/drm -Werror
43183+ccflags-y := -Iinclude/drm
43184 omapdrm-y := omap_drv.o \
43185 omap_irq.o \
43186 omap_debugfs.o \
43187diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
43188index fdc1833..f307630 100644
43189--- a/drivers/gpu/drm/qxl/qxl_cmd.c
43190+++ b/drivers/gpu/drm/qxl/qxl_cmd.c
43191@@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
43192 int ret;
43193
43194 mutex_lock(&qdev->async_io_mutex);
43195- irq_num = atomic_read(&qdev->irq_received_io_cmd);
43196+ irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
43197 if (qdev->last_sent_io_cmd > irq_num) {
43198 if (intr)
43199 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
43200- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43201+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43202 else
43203 ret = wait_event_timeout(qdev->io_cmd_event,
43204- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43205+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43206 /* 0 is timeout, just bail the "hw" has gone away */
43207 if (ret <= 0)
43208 goto out;
43209- irq_num = atomic_read(&qdev->irq_received_io_cmd);
43210+ irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
43211 }
43212 outb(val, addr);
43213 qdev->last_sent_io_cmd = irq_num + 1;
43214 if (intr)
43215 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
43216- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43217+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43218 else
43219 ret = wait_event_timeout(qdev->io_cmd_event,
43220- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43221+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
43222 out:
43223 if (ret > 0)
43224 ret = 0;
43225diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
43226index 6911b8c..89d6867 100644
43227--- a/drivers/gpu/drm/qxl/qxl_debugfs.c
43228+++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
43229@@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
43230 struct drm_info_node *node = (struct drm_info_node *) m->private;
43231 struct qxl_device *qdev = node->minor->dev->dev_private;
43232
43233- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
43234- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
43235- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
43236- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
43237+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
43238+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
43239+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
43240+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
43241 seq_printf(m, "%d\n", qdev->irq_received_error);
43242 return 0;
43243 }
43244diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
43245index 01a8694..584fb48 100644
43246--- a/drivers/gpu/drm/qxl/qxl_drv.h
43247+++ b/drivers/gpu/drm/qxl/qxl_drv.h
43248@@ -290,10 +290,10 @@ struct qxl_device {
43249 unsigned int last_sent_io_cmd;
43250
43251 /* interrupt handling */
43252- atomic_t irq_received;
43253- atomic_t irq_received_display;
43254- atomic_t irq_received_cursor;
43255- atomic_t irq_received_io_cmd;
43256+ atomic_unchecked_t irq_received;
43257+ atomic_unchecked_t irq_received_display;
43258+ atomic_unchecked_t irq_received_cursor;
43259+ atomic_unchecked_t irq_received_io_cmd;
43260 unsigned irq_received_error;
43261 wait_queue_head_t display_event;
43262 wait_queue_head_t cursor_event;
43263diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
43264index bda5c5f..140ac46 100644
43265--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
43266+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
43267@@ -183,7 +183,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
43268
43269 /* TODO copy slow path code from i915 */
43270 fb_cmd = qxl_bo_kmap_atomic_page(qdev, cmd_bo, (release->release_offset & PAGE_SIZE));
43271- 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);
43272+ 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);
43273
43274 {
43275 struct qxl_drawable *draw = fb_cmd;
43276@@ -203,7 +203,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
43277 struct drm_qxl_reloc reloc;
43278
43279 if (copy_from_user(&reloc,
43280- &((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i],
43281+ &((struct drm_qxl_reloc __force_user *)(uintptr_t)cmd->relocs)[i],
43282 sizeof(reloc))) {
43283 ret = -EFAULT;
43284 goto out_free_bos;
43285@@ -282,10 +282,10 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
43286
43287 for (cmd_num = 0; cmd_num < execbuffer->commands_num; ++cmd_num) {
43288
43289- struct drm_qxl_command *commands =
43290- (struct drm_qxl_command *)(uintptr_t)execbuffer->commands;
43291+ struct drm_qxl_command __user *commands =
43292+ (struct drm_qxl_command __user *)(uintptr_t)execbuffer->commands;
43293
43294- if (copy_from_user(&user_cmd, &commands[cmd_num],
43295+ if (copy_from_user(&user_cmd, (struct drm_qxl_command __force_user *)&commands[cmd_num],
43296 sizeof(user_cmd)))
43297 return -EFAULT;
43298
43299diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
43300index 0bf1e20..42a7310 100644
43301--- a/drivers/gpu/drm/qxl/qxl_irq.c
43302+++ b/drivers/gpu/drm/qxl/qxl_irq.c
43303@@ -36,19 +36,19 @@ irqreturn_t qxl_irq_handler(int irq, void *arg)
43304 if (!pending)
43305 return IRQ_NONE;
43306
43307- atomic_inc(&qdev->irq_received);
43308+ atomic_inc_unchecked(&qdev->irq_received);
43309
43310 if (pending & QXL_INTERRUPT_DISPLAY) {
43311- atomic_inc(&qdev->irq_received_display);
43312+ atomic_inc_unchecked(&qdev->irq_received_display);
43313 wake_up_all(&qdev->display_event);
43314 qxl_queue_garbage_collect(qdev, false);
43315 }
43316 if (pending & QXL_INTERRUPT_CURSOR) {
43317- atomic_inc(&qdev->irq_received_cursor);
43318+ atomic_inc_unchecked(&qdev->irq_received_cursor);
43319 wake_up_all(&qdev->cursor_event);
43320 }
43321 if (pending & QXL_INTERRUPT_IO_CMD) {
43322- atomic_inc(&qdev->irq_received_io_cmd);
43323+ atomic_inc_unchecked(&qdev->irq_received_io_cmd);
43324 wake_up_all(&qdev->io_cmd_event);
43325 }
43326 if (pending & QXL_INTERRUPT_ERROR) {
43327@@ -85,10 +85,10 @@ int qxl_irq_init(struct qxl_device *qdev)
43328 init_waitqueue_head(&qdev->io_cmd_event);
43329 INIT_WORK(&qdev->client_monitors_config_work,
43330 qxl_client_monitors_config_work_func);
43331- atomic_set(&qdev->irq_received, 0);
43332- atomic_set(&qdev->irq_received_display, 0);
43333- atomic_set(&qdev->irq_received_cursor, 0);
43334- atomic_set(&qdev->irq_received_io_cmd, 0);
43335+ atomic_set_unchecked(&qdev->irq_received, 0);
43336+ atomic_set_unchecked(&qdev->irq_received_display, 0);
43337+ atomic_set_unchecked(&qdev->irq_received_cursor, 0);
43338+ atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
43339 qdev->irq_received_error = 0;
43340 ret = drm_irq_install(qdev->ddev, qdev->ddev->pdev->irq);
43341 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
43342diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
43343index 0cbc4c9..0e46686 100644
43344--- a/drivers/gpu/drm/qxl/qxl_ttm.c
43345+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
43346@@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
43347 }
43348 }
43349
43350-static struct vm_operations_struct qxl_ttm_vm_ops;
43351+static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
43352 static const struct vm_operations_struct *ttm_vm_ops;
43353
43354 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
43355@@ -145,8 +145,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
43356 return r;
43357 if (unlikely(ttm_vm_ops == NULL)) {
43358 ttm_vm_ops = vma->vm_ops;
43359+ pax_open_kernel();
43360 qxl_ttm_vm_ops = *ttm_vm_ops;
43361 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
43362+ pax_close_kernel();
43363 }
43364 vma->vm_ops = &qxl_ttm_vm_ops;
43365 return 0;
43366@@ -464,25 +466,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
43367 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
43368 {
43369 #if defined(CONFIG_DEBUG_FS)
43370- static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
43371- static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
43372- unsigned i;
43373+ static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
43374+ {
43375+ .name = "qxl_mem_mm",
43376+ .show = &qxl_mm_dump_table,
43377+ },
43378+ {
43379+ .name = "qxl_surf_mm",
43380+ .show = &qxl_mm_dump_table,
43381+ }
43382+ };
43383
43384- for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
43385- if (i == 0)
43386- sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
43387- else
43388- sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
43389- qxl_mem_types_list[i].name = qxl_mem_types_names[i];
43390- qxl_mem_types_list[i].show = &qxl_mm_dump_table;
43391- qxl_mem_types_list[i].driver_features = 0;
43392- if (i == 0)
43393- qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
43394- else
43395- qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
43396+ pax_open_kernel();
43397+ *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
43398+ *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
43399+ pax_close_kernel();
43400
43401- }
43402- return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
43403+ return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
43404 #else
43405 return 0;
43406 #endif
43407diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
43408index 2c45ac9..5d740f8 100644
43409--- a/drivers/gpu/drm/r128/r128_cce.c
43410+++ b/drivers/gpu/drm/r128/r128_cce.c
43411@@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
43412
43413 /* GH: Simple idle check.
43414 */
43415- atomic_set(&dev_priv->idle_count, 0);
43416+ atomic_set_unchecked(&dev_priv->idle_count, 0);
43417
43418 /* We don't support anything other than bus-mastering ring mode,
43419 * but the ring can be in either AGP or PCI space for the ring
43420diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
43421index 723e5d6..102dbaf 100644
43422--- a/drivers/gpu/drm/r128/r128_drv.h
43423+++ b/drivers/gpu/drm/r128/r128_drv.h
43424@@ -93,14 +93,14 @@ typedef struct drm_r128_private {
43425 int is_pci;
43426 unsigned long cce_buffers_offset;
43427
43428- atomic_t idle_count;
43429+ atomic_unchecked_t idle_count;
43430
43431 int page_flipping;
43432 int current_page;
43433 u32 crtc_offset;
43434 u32 crtc_offset_cntl;
43435
43436- atomic_t vbl_received;
43437+ atomic_unchecked_t vbl_received;
43438
43439 u32 color_fmt;
43440 unsigned int front_offset;
43441diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
43442index 663f38c..ec159a1 100644
43443--- a/drivers/gpu/drm/r128/r128_ioc32.c
43444+++ b/drivers/gpu/drm/r128/r128_ioc32.c
43445@@ -178,7 +178,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
43446 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
43447 }
43448
43449-drm_ioctl_compat_t *r128_compat_ioctls[] = {
43450+drm_ioctl_compat_t r128_compat_ioctls[] = {
43451 [DRM_R128_INIT] = compat_r128_init,
43452 [DRM_R128_DEPTH] = compat_r128_depth,
43453 [DRM_R128_STIPPLE] = compat_r128_stipple,
43454@@ -197,17 +197,13 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
43455 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
43456 {
43457 unsigned int nr = DRM_IOCTL_NR(cmd);
43458- drm_ioctl_compat_t *fn = NULL;
43459 int ret;
43460
43461 if (nr < DRM_COMMAND_BASE)
43462 return drm_compat_ioctl(filp, cmd, arg);
43463
43464- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(r128_compat_ioctls))
43465- fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
43466-
43467- if (fn != NULL)
43468- ret = (*fn) (filp, cmd, arg);
43469+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(r128_compat_ioctls) && r128_compat_ioctls[nr - DRM_COMMAND_BASE])
43470+ ret = (*r128_compat_ioctls[nr - DRM_COMMAND_BASE]) (filp, cmd, arg);
43471 else
43472 ret = drm_ioctl(filp, cmd, arg);
43473
43474diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
43475index c2ae496..30b5993 100644
43476--- a/drivers/gpu/drm/r128/r128_irq.c
43477+++ b/drivers/gpu/drm/r128/r128_irq.c
43478@@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
43479 if (crtc != 0)
43480 return 0;
43481
43482- return atomic_read(&dev_priv->vbl_received);
43483+ return atomic_read_unchecked(&dev_priv->vbl_received);
43484 }
43485
43486 irqreturn_t r128_driver_irq_handler(int irq, void *arg)
43487@@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(int irq, void *arg)
43488 /* VBLANK interrupt */
43489 if (status & R128_CRTC_VBLANK_INT) {
43490 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
43491- atomic_inc(&dev_priv->vbl_received);
43492+ atomic_inc_unchecked(&dev_priv->vbl_received);
43493 drm_handle_vblank(dev, 0);
43494 return IRQ_HANDLED;
43495 }
43496diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
43497index 8fd2d9f..18c9660 100644
43498--- a/drivers/gpu/drm/r128/r128_state.c
43499+++ b/drivers/gpu/drm/r128/r128_state.c
43500@@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
43501
43502 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
43503 {
43504- if (atomic_read(&dev_priv->idle_count) == 0)
43505+ if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
43506 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
43507 else
43508- atomic_set(&dev_priv->idle_count, 0);
43509+ atomic_set_unchecked(&dev_priv->idle_count, 0);
43510 }
43511
43512 #endif
43513diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
43514index b928c17..e5d9400 100644
43515--- a/drivers/gpu/drm/radeon/mkregtable.c
43516+++ b/drivers/gpu/drm/radeon/mkregtable.c
43517@@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
43518 regex_t mask_rex;
43519 regmatch_t match[4];
43520 char buf[1024];
43521- size_t end;
43522+ long end;
43523 int len;
43524 int done = 0;
43525 int r;
43526 unsigned o;
43527 struct offset *offset;
43528 char last_reg_s[10];
43529- int last_reg;
43530+ unsigned long last_reg;
43531
43532 if (regcomp
43533 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
43534diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
43535index d8319da..d6e066f 100644
43536--- a/drivers/gpu/drm/radeon/radeon_device.c
43537+++ b/drivers/gpu/drm/radeon/radeon_device.c
43538@@ -1253,7 +1253,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
43539 * locking inversion with the driver load path. And the access here is
43540 * completely racy anyway. So don't bother with locking for now.
43541 */
43542- return dev->open_count == 0;
43543+ return local_read(&dev->open_count) == 0;
43544 }
43545
43546 static const struct vga_switcheroo_client_ops radeon_switcheroo_ops = {
43547diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
43548index 46bd393..6ae4719 100644
43549--- a/drivers/gpu/drm/radeon/radeon_drv.h
43550+++ b/drivers/gpu/drm/radeon/radeon_drv.h
43551@@ -264,7 +264,7 @@ typedef struct drm_radeon_private {
43552
43553 /* SW interrupt */
43554 wait_queue_head_t swi_queue;
43555- atomic_t swi_emitted;
43556+ atomic_unchecked_t swi_emitted;
43557 int vblank_crtc;
43558 uint32_t irq_enable_reg;
43559 uint32_t r500_disp_irq_reg;
43560diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
43561index 0b98ea1..a3c770f 100644
43562--- a/drivers/gpu/drm/radeon/radeon_ioc32.c
43563+++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
43564@@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
43565 request = compat_alloc_user_space(sizeof(*request));
43566 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
43567 || __put_user(req32.param, &request->param)
43568- || __put_user((void __user *)(unsigned long)req32.value,
43569+ || __put_user((unsigned long)req32.value,
43570 &request->value))
43571 return -EFAULT;
43572
43573@@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
43574 #define compat_radeon_cp_setparam NULL
43575 #endif /* X86_64 || IA64 */
43576
43577-static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
43578+static drm_ioctl_compat_t radeon_compat_ioctls[] = {
43579 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
43580 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
43581 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
43582@@ -393,17 +393,13 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
43583 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
43584 {
43585 unsigned int nr = DRM_IOCTL_NR(cmd);
43586- drm_ioctl_compat_t *fn = NULL;
43587 int ret;
43588
43589 if (nr < DRM_COMMAND_BASE)
43590 return drm_compat_ioctl(filp, cmd, arg);
43591
43592- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(radeon_compat_ioctls))
43593- fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
43594-
43595- if (fn != NULL)
43596- ret = (*fn) (filp, cmd, arg);
43597+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(radeon_compat_ioctls) && radeon_compat_ioctls[nr - DRM_COMMAND_BASE])
43598+ ret = (*radeon_compat_ioctls[nr - DRM_COMMAND_BASE]) (filp, cmd, arg);
43599 else
43600 ret = drm_ioctl(filp, cmd, arg);
43601
43602diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
43603index 244b19b..c19226d 100644
43604--- a/drivers/gpu/drm/radeon/radeon_irq.c
43605+++ b/drivers/gpu/drm/radeon/radeon_irq.c
43606@@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
43607 unsigned int ret;
43608 RING_LOCALS;
43609
43610- atomic_inc(&dev_priv->swi_emitted);
43611- ret = atomic_read(&dev_priv->swi_emitted);
43612+ atomic_inc_unchecked(&dev_priv->swi_emitted);
43613+ ret = atomic_read_unchecked(&dev_priv->swi_emitted);
43614
43615 BEGIN_RING(4);
43616 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
43617@@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
43618 drm_radeon_private_t *dev_priv =
43619 (drm_radeon_private_t *) dev->dev_private;
43620
43621- atomic_set(&dev_priv->swi_emitted, 0);
43622+ atomic_set_unchecked(&dev_priv->swi_emitted, 0);
43623 init_waitqueue_head(&dev_priv->swi_queue);
43624
43625 dev->max_vblank_count = 0x001fffff;
43626diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
43627index 15aee72..cda326e 100644
43628--- a/drivers/gpu/drm/radeon/radeon_state.c
43629+++ b/drivers/gpu/drm/radeon/radeon_state.c
43630@@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
43631 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
43632 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
43633
43634- if (copy_from_user(&depth_boxes, clear->depth_boxes,
43635+ if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || copy_from_user(&depth_boxes, clear->depth_boxes,
43636 sarea_priv->nbox * sizeof(depth_boxes[0])))
43637 return -EFAULT;
43638
43639@@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
43640 {
43641 drm_radeon_private_t *dev_priv = dev->dev_private;
43642 drm_radeon_getparam_t *param = data;
43643- int value;
43644+ int value = 0;
43645
43646 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
43647
43648diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
43649index 06ac59fe..57e0681 100644
43650--- a/drivers/gpu/drm/radeon/radeon_ttm.c
43651+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
43652@@ -961,7 +961,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
43653 man->size = size >> PAGE_SHIFT;
43654 }
43655
43656-static struct vm_operations_struct radeon_ttm_vm_ops;
43657+static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
43658 static const struct vm_operations_struct *ttm_vm_ops = NULL;
43659
43660 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
43661@@ -1002,8 +1002,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
43662 }
43663 if (unlikely(ttm_vm_ops == NULL)) {
43664 ttm_vm_ops = vma->vm_ops;
43665+ pax_open_kernel();
43666 radeon_ttm_vm_ops = *ttm_vm_ops;
43667 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
43668+ pax_close_kernel();
43669 }
43670 vma->vm_ops = &radeon_ttm_vm_ops;
43671 return 0;
43672diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
43673index a287e4f..df1d5dd 100644
43674--- a/drivers/gpu/drm/tegra/dc.c
43675+++ b/drivers/gpu/drm/tegra/dc.c
43676@@ -1594,7 +1594,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
43677 }
43678
43679 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
43680- dc->debugfs_files[i].data = dc;
43681+ *(void **)&dc->debugfs_files[i].data = dc;
43682
43683 err = drm_debugfs_create_files(dc->debugfs_files,
43684 ARRAY_SIZE(debugfs_files),
43685diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
43686index ed970f6..4eeea42 100644
43687--- a/drivers/gpu/drm/tegra/dsi.c
43688+++ b/drivers/gpu/drm/tegra/dsi.c
43689@@ -62,7 +62,7 @@ struct tegra_dsi {
43690 struct clk *clk_lp;
43691 struct clk *clk;
43692
43693- struct drm_info_list *debugfs_files;
43694+ drm_info_list_no_const *debugfs_files;
43695 struct drm_minor *minor;
43696 struct dentry *debugfs;
43697
43698diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
43699index 06ab178..b5324e4 100644
43700--- a/drivers/gpu/drm/tegra/hdmi.c
43701+++ b/drivers/gpu/drm/tegra/hdmi.c
43702@@ -64,7 +64,7 @@ struct tegra_hdmi {
43703 bool stereo;
43704 bool dvi;
43705
43706- struct drm_info_list *debugfs_files;
43707+ drm_info_list_no_const *debugfs_files;
43708 struct drm_minor *minor;
43709 struct dentry *debugfs;
43710 };
43711diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
43712index 7591d89..463e2b6 100644
43713--- a/drivers/gpu/drm/tegra/sor.c
43714+++ b/drivers/gpu/drm/tegra/sor.c
43715@@ -826,8 +826,11 @@ static int tegra_sor_debugfs_init(struct tegra_sor *sor,
43716 goto remove;
43717 }
43718
43719- for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
43720- sor->debugfs_files[i].data = sor;
43721+ for (i = 0; i < ARRAY_SIZE(debugfs_files); i++) {
43722+ pax_open_kernel();
43723+ *(void **)&sor->debugfs_files[i].data = sor;
43724+ pax_close_kernel();
43725+ }
43726
43727 err = drm_debugfs_create_files(sor->debugfs_files,
43728 ARRAY_SIZE(debugfs_files),
43729diff --git a/drivers/gpu/drm/tilcdc/Makefile b/drivers/gpu/drm/tilcdc/Makefile
43730index deeca48..54e1b6c 100644
43731--- a/drivers/gpu/drm/tilcdc/Makefile
43732+++ b/drivers/gpu/drm/tilcdc/Makefile
43733@@ -1,7 +1,7 @@
43734 ccflags-y := -Iinclude/drm
43735-ifeq (, $(findstring -W,$(EXTRA_CFLAGS)))
43736- ccflags-y += -Werror
43737-endif
43738+#ifeq (, $(findstring -W,$(EXTRA_CFLAGS)))
43739+# ccflags-y += -Werror
43740+#endif
43741
43742 obj-$(CONFIG_DRM_TILCDC_SLAVE_COMPAT) += tilcdc_slave_compat.o \
43743 tilcdc_slave_compat.dtb.o
43744diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
43745index aa0bd054..aea6a01 100644
43746--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
43747+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
43748@@ -148,10 +148,10 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
43749 }
43750
43751 const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
43752- ttm_bo_man_init,
43753- ttm_bo_man_takedown,
43754- ttm_bo_man_get_node,
43755- ttm_bo_man_put_node,
43756- ttm_bo_man_debug
43757+ .init = ttm_bo_man_init,
43758+ .takedown = ttm_bo_man_takedown,
43759+ .get_node = ttm_bo_man_get_node,
43760+ .put_node = ttm_bo_man_put_node,
43761+ .debug = ttm_bo_man_debug
43762 };
43763 EXPORT_SYMBOL(ttm_bo_manager_func);
43764diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
43765index a1803fb..c53f6b0 100644
43766--- a/drivers/gpu/drm/ttm/ttm_memory.c
43767+++ b/drivers/gpu/drm/ttm/ttm_memory.c
43768@@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
43769 zone->glob = glob;
43770 glob->zone_kernel = zone;
43771 ret = kobject_init_and_add(
43772- &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
43773+ &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
43774 if (unlikely(ret != 0)) {
43775 kobject_put(&zone->kobj);
43776 return ret;
43777@@ -348,7 +348,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
43778 zone->glob = glob;
43779 glob->zone_dma32 = zone;
43780 ret = kobject_init_and_add(
43781- &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
43782+ &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
43783 if (unlikely(ret != 0)) {
43784 kobject_put(&zone->kobj);
43785 return ret;
43786diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
43787index 025c429..314062f 100644
43788--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
43789+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
43790@@ -54,7 +54,7 @@
43791
43792 #define NUM_PAGES_TO_ALLOC (PAGE_SIZE/sizeof(struct page *))
43793 #define SMALL_ALLOCATION 16
43794-#define FREE_ALL_PAGES (~0U)
43795+#define FREE_ALL_PAGES (~0UL)
43796 /* times are in msecs */
43797 #define PAGE_FREE_INTERVAL 1000
43798
43799@@ -299,15 +299,14 @@ static void ttm_pool_update_free_locked(struct ttm_page_pool *pool,
43800 * @free_all: If set to true will free all pages in pool
43801 * @use_static: Safe to use static buffer
43802 **/
43803-static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,
43804+static unsigned long ttm_page_pool_free(struct ttm_page_pool *pool, unsigned long nr_free,
43805 bool use_static)
43806 {
43807 static struct page *static_buf[NUM_PAGES_TO_ALLOC];
43808 unsigned long irq_flags;
43809 struct page *p;
43810 struct page **pages_to_free;
43811- unsigned freed_pages = 0,
43812- npages_to_free = nr_free;
43813+ unsigned long freed_pages = 0, npages_to_free = nr_free;
43814
43815 if (NUM_PAGES_TO_ALLOC < nr_free)
43816 npages_to_free = NUM_PAGES_TO_ALLOC;
43817@@ -371,7 +370,8 @@ restart:
43818 __list_del(&p->lru, &pool->list);
43819
43820 ttm_pool_update_free_locked(pool, freed_pages);
43821- nr_free -= freed_pages;
43822+ if (likely(nr_free != FREE_ALL_PAGES))
43823+ nr_free -= freed_pages;
43824 }
43825
43826 spin_unlock_irqrestore(&pool->lock, irq_flags);
43827@@ -399,7 +399,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43828 unsigned i;
43829 unsigned pool_offset;
43830 struct ttm_page_pool *pool;
43831- int shrink_pages = sc->nr_to_scan;
43832+ unsigned long shrink_pages = sc->nr_to_scan;
43833 unsigned long freed = 0;
43834
43835 if (!mutex_trylock(&lock))
43836@@ -407,7 +407,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43837 pool_offset = ++start_pool % NUM_POOLS;
43838 /* select start pool in round robin fashion */
43839 for (i = 0; i < NUM_POOLS; ++i) {
43840- unsigned nr_free = shrink_pages;
43841+ unsigned long nr_free = shrink_pages;
43842 if (shrink_pages == 0)
43843 break;
43844 pool = &_manager->pools[(i + pool_offset)%NUM_POOLS];
43845@@ -673,7 +673,7 @@ out:
43846 }
43847
43848 /* Put all pages in pages list to correct pool to wait for reuse */
43849-static void ttm_put_pages(struct page **pages, unsigned npages, int flags,
43850+static void ttm_put_pages(struct page **pages, unsigned long npages, int flags,
43851 enum ttm_caching_state cstate)
43852 {
43853 unsigned long irq_flags;
43854@@ -728,7 +728,7 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,
43855 struct list_head plist;
43856 struct page *p = NULL;
43857 gfp_t gfp_flags = GFP_USER;
43858- unsigned count;
43859+ unsigned long count;
43860 int r;
43861
43862 /* set zero flag for page allocation if required */
43863diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
43864index 624d941..106fa1f 100644
43865--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
43866+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
43867@@ -56,7 +56,7 @@
43868
43869 #define NUM_PAGES_TO_ALLOC (PAGE_SIZE/sizeof(struct page *))
43870 #define SMALL_ALLOCATION 4
43871-#define FREE_ALL_PAGES (~0U)
43872+#define FREE_ALL_PAGES (~0UL)
43873 /* times are in msecs */
43874 #define IS_UNDEFINED (0)
43875 #define IS_WC (1<<1)
43876@@ -416,7 +416,7 @@ static void ttm_dma_page_put(struct dma_pool *pool, struct dma_page *d_page)
43877 * @nr_free: If set to true will free all pages in pool
43878 * @use_static: Safe to use static buffer
43879 **/
43880-static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
43881+static unsigned long ttm_dma_page_pool_free(struct dma_pool *pool, unsigned long nr_free,
43882 bool use_static)
43883 {
43884 static struct page *static_buf[NUM_PAGES_TO_ALLOC];
43885@@ -424,8 +424,7 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
43886 struct dma_page *dma_p, *tmp;
43887 struct page **pages_to_free;
43888 struct list_head d_pages;
43889- unsigned freed_pages = 0,
43890- npages_to_free = nr_free;
43891+ unsigned long freed_pages = 0, npages_to_free = nr_free;
43892
43893 if (NUM_PAGES_TO_ALLOC < nr_free)
43894 npages_to_free = NUM_PAGES_TO_ALLOC;
43895@@ -502,7 +501,8 @@ restart:
43896 /* remove range of pages from the pool */
43897 if (freed_pages) {
43898 ttm_pool_update_free_locked(pool, freed_pages);
43899- nr_free -= freed_pages;
43900+ if (likely(nr_free != FREE_ALL_PAGES))
43901+ nr_free -= freed_pages;
43902 }
43903
43904 spin_unlock_irqrestore(&pool->lock, irq_flags);
43905@@ -939,7 +939,7 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)
43906 struct dma_page *d_page, *next;
43907 enum pool_type type;
43908 bool is_cached = false;
43909- unsigned count = 0, i, npages = 0;
43910+ unsigned long count = 0, i, npages = 0;
43911 unsigned long irq_flags;
43912
43913 type = ttm_to_type(ttm->page_flags, ttm->caching_state);
43914@@ -1014,7 +1014,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43915 static unsigned start_pool;
43916 unsigned idx = 0;
43917 unsigned pool_offset;
43918- unsigned shrink_pages = sc->nr_to_scan;
43919+ unsigned long shrink_pages = sc->nr_to_scan;
43920 struct device_pools *p;
43921 unsigned long freed = 0;
43922
43923@@ -1027,7 +1027,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43924 goto out;
43925 pool_offset = ++start_pool % _manager->npools;
43926 list_for_each_entry(p, &_manager->pools, pools) {
43927- unsigned nr_free;
43928+ unsigned long nr_free;
43929
43930 if (!p->dev)
43931 continue;
43932@@ -1041,7 +1041,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
43933 shrink_pages = ttm_dma_page_pool_free(p->pool, nr_free, true);
43934 freed += nr_free - shrink_pages;
43935
43936- pr_debug("%s: (%s:%d) Asked to shrink %d, have %d more to go\n",
43937+ pr_debug("%s: (%s:%d) Asked to shrink %lu, have %lu more to go\n",
43938 p->pool->dev_name, p->pool->name, current->pid,
43939 nr_free, shrink_pages);
43940 }
43941diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
43942index 5fc16ce..1bd84ec 100644
43943--- a/drivers/gpu/drm/udl/udl_fb.c
43944+++ b/drivers/gpu/drm/udl/udl_fb.c
43945@@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
43946 fb_deferred_io_cleanup(info);
43947 kfree(info->fbdefio);
43948 info->fbdefio = NULL;
43949- info->fbops->fb_mmap = udl_fb_mmap;
43950 }
43951
43952 pr_warn("released /dev/fb%d user=%d count=%d\n",
43953diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
43954index ef8c500..01030c8 100644
43955--- a/drivers/gpu/drm/via/via_drv.h
43956+++ b/drivers/gpu/drm/via/via_drv.h
43957@@ -53,7 +53,7 @@ typedef struct drm_via_ring_buffer {
43958 typedef uint32_t maskarray_t[5];
43959
43960 typedef struct drm_via_irq {
43961- atomic_t irq_received;
43962+ atomic_unchecked_t irq_received;
43963 uint32_t pending_mask;
43964 uint32_t enable_mask;
43965 wait_queue_head_t irq_queue;
43966@@ -77,7 +77,7 @@ typedef struct drm_via_private {
43967 struct timeval last_vblank;
43968 int last_vblank_valid;
43969 unsigned usec_per_vblank;
43970- atomic_t vbl_received;
43971+ atomic_unchecked_t vbl_received;
43972 drm_via_state_t hc_state;
43973 char pci_buf[VIA_PCI_BUF_SIZE];
43974 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
43975diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
43976index 1319433..a993b0c 100644
43977--- a/drivers/gpu/drm/via/via_irq.c
43978+++ b/drivers/gpu/drm/via/via_irq.c
43979@@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
43980 if (crtc != 0)
43981 return 0;
43982
43983- return atomic_read(&dev_priv->vbl_received);
43984+ return atomic_read_unchecked(&dev_priv->vbl_received);
43985 }
43986
43987 irqreturn_t via_driver_irq_handler(int irq, void *arg)
43988@@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
43989
43990 status = VIA_READ(VIA_REG_INTERRUPT);
43991 if (status & VIA_IRQ_VBLANK_PENDING) {
43992- atomic_inc(&dev_priv->vbl_received);
43993- if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
43994+ atomic_inc_unchecked(&dev_priv->vbl_received);
43995+ if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
43996 do_gettimeofday(&cur_vblank);
43997 if (dev_priv->last_vblank_valid) {
43998 dev_priv->usec_per_vblank =
43999@@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
44000 dev_priv->last_vblank = cur_vblank;
44001 dev_priv->last_vblank_valid = 1;
44002 }
44003- if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
44004+ if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
44005 DRM_DEBUG("US per vblank is: %u\n",
44006 dev_priv->usec_per_vblank);
44007 }
44008@@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
44009
44010 for (i = 0; i < dev_priv->num_irqs; ++i) {
44011 if (status & cur_irq->pending_mask) {
44012- atomic_inc(&cur_irq->irq_received);
44013+ atomic_inc_unchecked(&cur_irq->irq_received);
44014 wake_up(&cur_irq->irq_queue);
44015 handled = 1;
44016 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
44017@@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
44018 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
44019 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
44020 masks[irq][4]));
44021- cur_irq_sequence = atomic_read(&cur_irq->irq_received);
44022+ cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
44023 } else {
44024 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
44025 (((cur_irq_sequence =
44026- atomic_read(&cur_irq->irq_received)) -
44027+ atomic_read_unchecked(&cur_irq->irq_received)) -
44028 *sequence) <= (1 << 23)));
44029 }
44030 *sequence = cur_irq_sequence;
44031@@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
44032 }
44033
44034 for (i = 0; i < dev_priv->num_irqs; ++i) {
44035- atomic_set(&cur_irq->irq_received, 0);
44036+ atomic_set_unchecked(&cur_irq->irq_received, 0);
44037 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
44038 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
44039 init_waitqueue_head(&cur_irq->irq_queue);
44040@@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
44041 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
44042 case VIA_IRQ_RELATIVE:
44043 irqwait->request.sequence +=
44044- atomic_read(&cur_irq->irq_received);
44045+ atomic_read_unchecked(&cur_irq->irq_received);
44046 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
44047 case VIA_IRQ_ABSOLUTE:
44048 break;
44049diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
44050index db8b491..d87b27c 100644
44051--- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c
44052+++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
44053@@ -34,7 +34,7 @@ virtio_gpu_debugfs_irq_info(struct seq_file *m, void *data)
44054 struct drm_info_node *node = (struct drm_info_node *) m->private;
44055 struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
44056
44057- seq_printf(m, "fence %ld %lld\n",
44058+ seq_printf(m, "fence %lld %lld\n",
44059 atomic64_read(&vgdev->fence_drv.last_seq),
44060 vgdev->fence_drv.sync_seq);
44061 return 0;
44062diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c
44063index 1da6326..98dd385 100644
44064--- a/drivers/gpu/drm/virtio/virtgpu_fence.c
44065+++ b/drivers/gpu/drm/virtio/virtgpu_fence.c
44066@@ -61,7 +61,7 @@ static void virtio_timeline_value_str(struct fence *f, char *str, int size)
44067 {
44068 struct virtio_gpu_fence *fence = to_virtio_fence(f);
44069
44070- snprintf(str, size, "%lu", atomic64_read(&fence->drv->last_seq));
44071+ snprintf(str, size, "%llu", atomic64_read(&fence->drv->last_seq));
44072 }
44073
44074 static const struct fence_ops virtio_fence_ops = {
44075diff --git a/drivers/gpu/drm/virtio/virtgpu_ttm.c b/drivers/gpu/drm/virtio/virtgpu_ttm.c
44076index b092d7b..3bbecd9 100644
44077--- a/drivers/gpu/drm/virtio/virtgpu_ttm.c
44078+++ b/drivers/gpu/drm/virtio/virtgpu_ttm.c
44079@@ -197,11 +197,11 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
44080 }
44081
44082 static const struct ttm_mem_type_manager_func virtio_gpu_bo_manager_func = {
44083- ttm_bo_man_init,
44084- ttm_bo_man_takedown,
44085- ttm_bo_man_get_node,
44086- ttm_bo_man_put_node,
44087- ttm_bo_man_debug
44088+ .init = &ttm_bo_man_init,
44089+ .takedown = &ttm_bo_man_takedown,
44090+ .get_node = &ttm_bo_man_get_node,
44091+ .put_node = &ttm_bo_man_put_node,
44092+ .debug = &ttm_bo_man_debug
44093 };
44094
44095 static int virtio_gpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
44096diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
44097index d26a6da..5fa41ed 100644
44098--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
44099+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
44100@@ -447,7 +447,7 @@ struct vmw_private {
44101 * Fencing and IRQs.
44102 */
44103
44104- atomic_t marker_seq;
44105+ atomic_unchecked_t marker_seq;
44106 wait_queue_head_t fence_queue;
44107 wait_queue_head_t fifo_queue;
44108 spinlock_t waiter_lock;
44109diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
44110index 39f2b03..d1b0a64 100644
44111--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
44112+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
44113@@ -152,7 +152,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
44114 (unsigned int) min,
44115 (unsigned int) fifo->capabilities);
44116
44117- atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
44118+ atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
44119 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
44120 vmw_marker_queue_init(&fifo->marker_queue);
44121 return vmw_fifo_send_fence(dev_priv, &dummy);
44122@@ -372,7 +372,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
44123 if (reserveable)
44124 iowrite32(bytes, fifo_mem +
44125 SVGA_FIFO_RESERVED);
44126- return fifo_mem + (next_cmd >> 2);
44127+ return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
44128 } else {
44129 need_bounce = true;
44130 }
44131@@ -492,7 +492,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
44132
44133 fm = vmw_fifo_reserve(dev_priv, bytes);
44134 if (unlikely(fm == NULL)) {
44135- *seqno = atomic_read(&dev_priv->marker_seq);
44136+ *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
44137 ret = -ENOMEM;
44138 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
44139 false, 3*HZ);
44140@@ -500,7 +500,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
44141 }
44142
44143 do {
44144- *seqno = atomic_add_return(1, &dev_priv->marker_seq);
44145+ *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
44146 } while (*seqno == 0);
44147
44148 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
44149diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
44150index 170b61b..fec7348 100644
44151--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
44152+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
44153@@ -164,9 +164,9 @@ static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man,
44154 }
44155
44156 const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
44157- vmw_gmrid_man_init,
44158- vmw_gmrid_man_takedown,
44159- vmw_gmrid_man_get_node,
44160- vmw_gmrid_man_put_node,
44161- vmw_gmrid_man_debug
44162+ .init = vmw_gmrid_man_init,
44163+ .takedown = vmw_gmrid_man_takedown,
44164+ .get_node = vmw_gmrid_man_get_node,
44165+ .put_node = vmw_gmrid_man_put_node,
44166+ .debug = vmw_gmrid_man_debug
44167 };
44168diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
44169index 69c8ce2..cacb0ab 100644
44170--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
44171+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
44172@@ -235,7 +235,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
44173 int ret;
44174
44175 num_clips = arg->num_clips;
44176- clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
44177+ clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
44178
44179 if (unlikely(num_clips == 0))
44180 return 0;
44181@@ -318,7 +318,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
44182 int ret;
44183
44184 num_clips = arg->num_clips;
44185- clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
44186+ clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
44187
44188 if (unlikely(num_clips == 0))
44189 return 0;
44190diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
44191index 9fe9827..0aa2fc0 100644
44192--- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
44193+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
44194@@ -102,7 +102,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
44195 * emitted. Then the fence is stale and signaled.
44196 */
44197
44198- ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
44199+ ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
44200 > VMW_FENCE_WRAP);
44201
44202 return ret;
44203@@ -133,7 +133,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
44204
44205 if (fifo_idle)
44206 down_read(&fifo_state->rwsem);
44207- signal_seq = atomic_read(&dev_priv->marker_seq);
44208+ signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
44209 ret = 0;
44210
44211 for (;;) {
44212diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
44213index efd1ffd..0ae13ca 100644
44214--- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
44215+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
44216@@ -135,7 +135,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
44217 while (!vmw_lag_lt(queue, us)) {
44218 spin_lock(&queue->lock);
44219 if (list_empty(&queue->head))
44220- seqno = atomic_read(&dev_priv->marker_seq);
44221+ seqno = atomic_read_unchecked(&dev_priv->marker_seq);
44222 else {
44223 marker = list_first_entry(&queue->head,
44224 struct vmw_marker, head);
44225diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
44226index 37ac7b5..d52a5c9 100644
44227--- a/drivers/gpu/vga/vga_switcheroo.c
44228+++ b/drivers/gpu/vga/vga_switcheroo.c
44229@@ -644,7 +644,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
44230
44231 /* this version is for the case where the power switch is separate
44232 to the device being powered down. */
44233-int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
44234+int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
44235 {
44236 /* copy over all the bus versions */
44237 if (dev->bus && dev->bus->pm) {
44238@@ -695,7 +695,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
44239 return ret;
44240 }
44241
44242-int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
44243+int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
44244 {
44245 /* copy over all the bus versions */
44246 if (dev->bus && dev->bus->pm) {
44247diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
44248index e6fce23..85949a0 100644
44249--- a/drivers/hid/hid-core.c
44250+++ b/drivers/hid/hid-core.c
44251@@ -2550,7 +2550,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
44252
44253 int hid_add_device(struct hid_device *hdev)
44254 {
44255- static atomic_t id = ATOMIC_INIT(0);
44256+ static atomic_unchecked_t id = ATOMIC_INIT(0);
44257 int ret;
44258
44259 if (WARN_ON(hdev->status & HID_STAT_ADDED))
44260@@ -2593,7 +2593,7 @@ int hid_add_device(struct hid_device *hdev)
44261 /* XXX hack, any other cleaner solution after the driver core
44262 * is converted to allow more than 20 bytes as the device name? */
44263 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
44264- hdev->vendor, hdev->product, atomic_inc_return(&id));
44265+ hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
44266
44267 hid_debug_register(hdev, dev_name(&hdev->dev));
44268 ret = device_add(&hdev->dev);
44269diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
44270index 5614fee..8a6f5f6 100644
44271--- a/drivers/hid/hid-sensor-custom.c
44272+++ b/drivers/hid/hid-sensor-custom.c
44273@@ -590,7 +590,7 @@ static int hid_sensor_custom_add_attributes(struct hid_sensor_custom
44274 j = 0;
44275 while (j < HID_CUSTOM_TOTAL_ATTRS &&
44276 hid_custom_attrs[j].name) {
44277- struct device_attribute *device_attr;
44278+ device_attribute_no_const *device_attr;
44279
44280 device_attr = &sensor_inst->fields[i].sd_attrs[j];
44281
44282diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
44283index c13fb5b..55a3802 100644
44284--- a/drivers/hid/hid-wiimote-debug.c
44285+++ b/drivers/hid/hid-wiimote-debug.c
44286@@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
44287 else if (size == 0)
44288 return -EIO;
44289
44290- if (copy_to_user(u, buf, size))
44291+ if (size > sizeof(buf) || copy_to_user(u, buf, size))
44292 return -EFAULT;
44293
44294 *off += size;
44295diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
44296index 603ce97..7f27468 100644
44297--- a/drivers/hv/channel.c
44298+++ b/drivers/hv/channel.c
44299@@ -382,7 +382,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
44300 int ret = 0;
44301
44302 next_gpadl_handle =
44303- (atomic_inc_return(&vmbus_connection.next_gpadl_handle) - 1);
44304+ (atomic_inc_return_unchecked(&vmbus_connection.next_gpadl_handle) - 1);
44305
44306 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
44307 if (ret)
44308diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
44309index d3943bc..597fd1e 100644
44310--- a/drivers/hv/hv.c
44311+++ b/drivers/hv/hv.c
44312@@ -118,7 +118,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
44313 u64 output_address = (output) ? virt_to_phys(output) : 0;
44314 u32 output_address_hi = output_address >> 32;
44315 u32 output_address_lo = output_address & 0xFFFFFFFF;
44316- void *hypercall_page = hv_context.hypercall_page;
44317+ void *hypercall_page = (void *)ktva_ktla((unsigned long)hv_context.hypercall_page);
44318
44319 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
44320 "=a"(hv_status_lo) : "d" (control_hi),
44321@@ -164,7 +164,7 @@ int hv_init(void)
44322 /* See if the hypercall page is already set */
44323 rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
44324
44325- virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
44326+ virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_RX);
44327
44328 if (!virtaddr)
44329 goto cleanup;
44330diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
44331index 8a725cd..91abaf0 100644
44332--- a/drivers/hv/hv_balloon.c
44333+++ b/drivers/hv/hv_balloon.c
44334@@ -469,7 +469,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
44335
44336 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
44337 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
44338-static atomic_t trans_id = ATOMIC_INIT(0);
44339+static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
44340
44341 static int dm_ring_size = (5 * PAGE_SIZE);
44342
44343@@ -943,7 +943,7 @@ static void hot_add_req(struct work_struct *dummy)
44344 pr_info("Memory hot add failed\n");
44345
44346 dm->state = DM_INITIALIZED;
44347- resp.hdr.trans_id = atomic_inc_return(&trans_id);
44348+ resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44349 vmbus_sendpacket(dm->dev->channel, &resp,
44350 sizeof(struct dm_hot_add_response),
44351 (unsigned long)NULL,
44352@@ -1024,7 +1024,7 @@ static void post_status(struct hv_dynmem_device *dm)
44353 memset(&status, 0, sizeof(struct dm_status));
44354 status.hdr.type = DM_STATUS_REPORT;
44355 status.hdr.size = sizeof(struct dm_status);
44356- status.hdr.trans_id = atomic_inc_return(&trans_id);
44357+ status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44358
44359 /*
44360 * The host expects the guest to report free and committed memory.
44361@@ -1048,7 +1048,7 @@ static void post_status(struct hv_dynmem_device *dm)
44362 * send the status. This can happen if we were interrupted
44363 * after we picked our transaction ID.
44364 */
44365- if (status.hdr.trans_id != atomic_read(&trans_id))
44366+ if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
44367 return;
44368
44369 /*
44370@@ -1193,7 +1193,7 @@ static void balloon_up(struct work_struct *dummy)
44371 */
44372
44373 do {
44374- bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
44375+ bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44376 ret = vmbus_sendpacket(dm_device.dev->channel,
44377 bl_resp,
44378 bl_resp->hdr.size,
44379@@ -1239,7 +1239,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
44380
44381 memset(&resp, 0, sizeof(struct dm_unballoon_response));
44382 resp.hdr.type = DM_UNBALLOON_RESPONSE;
44383- resp.hdr.trans_id = atomic_inc_return(&trans_id);
44384+ resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44385 resp.hdr.size = sizeof(struct dm_unballoon_response);
44386
44387 vmbus_sendpacket(dm_device.dev->channel, &resp,
44388@@ -1300,7 +1300,7 @@ static void version_resp(struct hv_dynmem_device *dm,
44389 memset(&version_req, 0, sizeof(struct dm_version_request));
44390 version_req.hdr.type = DM_VERSION_REQUEST;
44391 version_req.hdr.size = sizeof(struct dm_version_request);
44392- version_req.hdr.trans_id = atomic_inc_return(&trans_id);
44393+ version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44394 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
44395 version_req.is_last_attempt = 1;
44396
44397@@ -1473,7 +1473,7 @@ static int balloon_probe(struct hv_device *dev,
44398 memset(&version_req, 0, sizeof(struct dm_version_request));
44399 version_req.hdr.type = DM_VERSION_REQUEST;
44400 version_req.hdr.size = sizeof(struct dm_version_request);
44401- version_req.hdr.trans_id = atomic_inc_return(&trans_id);
44402+ version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44403 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
44404 version_req.is_last_attempt = 0;
44405
44406@@ -1504,7 +1504,7 @@ static int balloon_probe(struct hv_device *dev,
44407 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
44408 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
44409 cap_msg.hdr.size = sizeof(struct dm_capabilities);
44410- cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
44411+ cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
44412
44413 cap_msg.caps.cap_bits.balloon = 1;
44414 cap_msg.caps.cap_bits.hot_add = 1;
44415diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
44416index cddc0c9..2eb587d 100644
44417--- a/drivers/hv/hyperv_vmbus.h
44418+++ b/drivers/hv/hyperv_vmbus.h
44419@@ -645,7 +645,7 @@ enum vmbus_connect_state {
44420 struct vmbus_connection {
44421 enum vmbus_connect_state conn_state;
44422
44423- atomic_t next_gpadl_handle;
44424+ atomic_unchecked_t next_gpadl_handle;
44425
44426 struct completion unload_event;
44427 /*
44428diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
44429index 579bdf9..0dac21d5 100644
44430--- a/drivers/hwmon/acpi_power_meter.c
44431+++ b/drivers/hwmon/acpi_power_meter.c
44432@@ -116,7 +116,7 @@ struct sensor_template {
44433 struct device_attribute *devattr,
44434 const char *buf, size_t count);
44435 int index;
44436-};
44437+} __do_const;
44438
44439 /* Averaging interval */
44440 static int update_avg_interval(struct acpi_power_meter_resource *resource)
44441@@ -631,7 +631,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
44442 struct sensor_template *attrs)
44443 {
44444 struct device *dev = &resource->acpi_dev->dev;
44445- struct sensor_device_attribute *sensors =
44446+ sensor_device_attribute_no_const *sensors =
44447 &resource->sensors[resource->num_sensors];
44448 int res = 0;
44449
44450@@ -973,7 +973,7 @@ static int __init enable_cap_knobs(const struct dmi_system_id *d)
44451 return 0;
44452 }
44453
44454-static struct dmi_system_id __initdata pm_dmi_table[] = {
44455+static const struct dmi_system_id __initconst pm_dmi_table[] = {
44456 {
44457 enable_cap_knobs, "IBM Active Energy Manager",
44458 {
44459diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
44460index 0af63da..05a183a 100644
44461--- a/drivers/hwmon/applesmc.c
44462+++ b/drivers/hwmon/applesmc.c
44463@@ -1105,7 +1105,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
44464 {
44465 struct applesmc_node_group *grp;
44466 struct applesmc_dev_attr *node;
44467- struct attribute *attr;
44468+ attribute_no_const *attr;
44469 int ret, i;
44470
44471 for (grp = groups; grp->format; grp++) {
44472diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
44473index cccef87..06ce8ec 100644
44474--- a/drivers/hwmon/asus_atk0110.c
44475+++ b/drivers/hwmon/asus_atk0110.c
44476@@ -147,10 +147,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
44477 struct atk_sensor_data {
44478 struct list_head list;
44479 struct atk_data *data;
44480- struct device_attribute label_attr;
44481- struct device_attribute input_attr;
44482- struct device_attribute limit1_attr;
44483- struct device_attribute limit2_attr;
44484+ device_attribute_no_const label_attr;
44485+ device_attribute_no_const input_attr;
44486+ device_attribute_no_const limit1_attr;
44487+ device_attribute_no_const limit2_attr;
44488 char label_attr_name[ATTR_NAME_SIZE];
44489 char input_attr_name[ATTR_NAME_SIZE];
44490 char limit1_attr_name[ATTR_NAME_SIZE];
44491@@ -270,7 +270,7 @@ static ssize_t atk_name_show(struct device *dev,
44492 static struct device_attribute atk_name_attr =
44493 __ATTR(name, 0444, atk_name_show, NULL);
44494
44495-static void atk_init_attribute(struct device_attribute *attr, char *name,
44496+static void atk_init_attribute(device_attribute_no_const *attr, char *name,
44497 sysfs_show_func show)
44498 {
44499 sysfs_attr_init(&attr->attr);
44500diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
44501index 3e03379..ec521d3 100644
44502--- a/drivers/hwmon/coretemp.c
44503+++ b/drivers/hwmon/coretemp.c
44504@@ -783,7 +783,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
44505 return NOTIFY_OK;
44506 }
44507
44508-static struct notifier_block coretemp_cpu_notifier __refdata = {
44509+static struct notifier_block coretemp_cpu_notifier = {
44510 .notifier_call = coretemp_cpu_callback,
44511 };
44512
44513diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
44514index c848789..e9e9217 100644
44515--- a/drivers/hwmon/dell-smm-hwmon.c
44516+++ b/drivers/hwmon/dell-smm-hwmon.c
44517@@ -819,7 +819,7 @@ static const struct i8k_config_data i8k_config_data[] = {
44518 },
44519 };
44520
44521-static struct dmi_system_id i8k_dmi_table[] __initdata = {
44522+static const struct dmi_system_id i8k_dmi_table[] __initconst = {
44523 {
44524 .ident = "Dell Inspiron",
44525 .matches = {
44526diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
44527index 7a8a6fb..015c1fd 100644
44528--- a/drivers/hwmon/ibmaem.c
44529+++ b/drivers/hwmon/ibmaem.c
44530@@ -924,7 +924,7 @@ static int aem_register_sensors(struct aem_data *data,
44531 struct aem_rw_sensor_template *rw)
44532 {
44533 struct device *dev = &data->pdev->dev;
44534- struct sensor_device_attribute *sensors = data->sensors;
44535+ sensor_device_attribute_no_const *sensors = data->sensors;
44536 int err;
44537
44538 /* Set up read-only sensors */
44539diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
44540index 17ae2eb..21b71dd 100644
44541--- a/drivers/hwmon/iio_hwmon.c
44542+++ b/drivers/hwmon/iio_hwmon.c
44543@@ -61,7 +61,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
44544 {
44545 struct device *dev = &pdev->dev;
44546 struct iio_hwmon_state *st;
44547- struct sensor_device_attribute *a;
44548+ sensor_device_attribute_no_const *a;
44549 int ret, i;
44550 int in_i = 1, temp_i = 1, curr_i = 1, humidity_i = 1;
44551 enum iio_chan_type type;
44552diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
44553index 37f0170..414ec2c 100644
44554--- a/drivers/hwmon/nct6683.c
44555+++ b/drivers/hwmon/nct6683.c
44556@@ -397,11 +397,11 @@ static struct attribute_group *
44557 nct6683_create_attr_group(struct device *dev, struct sensor_template_group *tg,
44558 int repeat)
44559 {
44560- struct sensor_device_attribute_2 *a2;
44561- struct sensor_device_attribute *a;
44562+ sensor_device_attribute_2_no_const *a2;
44563+ sensor_device_attribute_no_const *a;
44564 struct sensor_device_template **t;
44565 struct sensor_device_attr_u *su;
44566- struct attribute_group *group;
44567+ attribute_group_no_const *group;
44568 struct attribute **attrs;
44569 int i, j, count;
44570
44571diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
44572index 2aaedbe..e944f14 100644
44573--- a/drivers/hwmon/nct6775.c
44574+++ b/drivers/hwmon/nct6775.c
44575@@ -957,10 +957,10 @@ static struct attribute_group *
44576 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
44577 int repeat)
44578 {
44579- struct attribute_group *group;
44580+ attribute_group_no_const *group;
44581 struct sensor_device_attr_u *su;
44582- struct sensor_device_attribute *a;
44583- struct sensor_device_attribute_2 *a2;
44584+ sensor_device_attribute_no_const *a;
44585+ sensor_device_attribute_2_no_const *a2;
44586 struct attribute **attrs;
44587 struct sensor_device_template **t;
44588 int i, count;
44589diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
44590index f2e47c7..45d7941 100644
44591--- a/drivers/hwmon/pmbus/pmbus_core.c
44592+++ b/drivers/hwmon/pmbus/pmbus_core.c
44593@@ -816,7 +816,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
44594 return 0;
44595 }
44596
44597-static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
44598+static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
44599 const char *name,
44600 umode_t mode,
44601 ssize_t (*show)(struct device *dev,
44602@@ -833,7 +833,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
44603 dev_attr->store = store;
44604 }
44605
44606-static void pmbus_attr_init(struct sensor_device_attribute *a,
44607+static void pmbus_attr_init(sensor_device_attribute_no_const *a,
44608 const char *name,
44609 umode_t mode,
44610 ssize_t (*show)(struct device *dev,
44611@@ -855,7 +855,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
44612 u16 reg, u8 mask)
44613 {
44614 struct pmbus_boolean *boolean;
44615- struct sensor_device_attribute *a;
44616+ sensor_device_attribute_no_const *a;
44617
44618 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
44619 if (!boolean)
44620@@ -880,7 +880,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
44621 bool update, bool readonly)
44622 {
44623 struct pmbus_sensor *sensor;
44624- struct device_attribute *a;
44625+ device_attribute_no_const *a;
44626
44627 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
44628 if (!sensor)
44629@@ -911,7 +911,7 @@ static int pmbus_add_label(struct pmbus_data *data,
44630 const char *lstring, int index)
44631 {
44632 struct pmbus_label *label;
44633- struct device_attribute *a;
44634+ device_attribute_no_const *a;
44635
44636 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
44637 if (!label)
44638diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
44639index 497a7f8..3fffedf 100644
44640--- a/drivers/hwmon/sht15.c
44641+++ b/drivers/hwmon/sht15.c
44642@@ -169,7 +169,7 @@ struct sht15_data {
44643 int supply_uv;
44644 bool supply_uv_valid;
44645 struct work_struct update_supply_work;
44646- atomic_t interrupt_handled;
44647+ atomic_unchecked_t interrupt_handled;
44648 };
44649
44650 /**
44651@@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
44652 ret = gpio_direction_input(data->pdata->gpio_data);
44653 if (ret)
44654 return ret;
44655- atomic_set(&data->interrupt_handled, 0);
44656+ atomic_set_unchecked(&data->interrupt_handled, 0);
44657
44658 enable_irq(gpio_to_irq(data->pdata->gpio_data));
44659 if (gpio_get_value(data->pdata->gpio_data) == 0) {
44660 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
44661 /* Only relevant if the interrupt hasn't occurred. */
44662- if (!atomic_read(&data->interrupt_handled))
44663+ if (!atomic_read_unchecked(&data->interrupt_handled))
44664 schedule_work(&data->read_work);
44665 }
44666 ret = wait_event_timeout(data->wait_queue,
44667@@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
44668
44669 /* First disable the interrupt */
44670 disable_irq_nosync(irq);
44671- atomic_inc(&data->interrupt_handled);
44672+ atomic_inc_unchecked(&data->interrupt_handled);
44673 /* Then schedule a reading work struct */
44674 if (data->state != SHT15_READING_NOTHING)
44675 schedule_work(&data->read_work);
44676@@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
44677 * If not, then start the interrupt again - care here as could
44678 * have gone low in meantime so verify it hasn't!
44679 */
44680- atomic_set(&data->interrupt_handled, 0);
44681+ atomic_set_unchecked(&data->interrupt_handled, 0);
44682 enable_irq(gpio_to_irq(data->pdata->gpio_data));
44683 /* If still not occurred or another handler was scheduled */
44684 if (gpio_get_value(data->pdata->gpio_data)
44685- || atomic_read(&data->interrupt_handled))
44686+ || atomic_read_unchecked(&data->interrupt_handled))
44687 return;
44688 }
44689
44690diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
44691index ac91c07..8e69663 100644
44692--- a/drivers/hwmon/via-cputemp.c
44693+++ b/drivers/hwmon/via-cputemp.c
44694@@ -295,7 +295,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
44695 return NOTIFY_OK;
44696 }
44697
44698-static struct notifier_block via_cputemp_cpu_notifier __refdata = {
44699+static struct notifier_block via_cputemp_cpu_notifier = {
44700 .notifier_call = via_cputemp_cpu_callback,
44701 };
44702
44703diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
44704index 65e3240..e6c511d 100644
44705--- a/drivers/i2c/busses/i2c-amd756-s4882.c
44706+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
44707@@ -39,7 +39,7 @@
44708 extern struct i2c_adapter amd756_smbus;
44709
44710 static struct i2c_adapter *s4882_adapter;
44711-static struct i2c_algorithm *s4882_algo;
44712+static i2c_algorithm_no_const *s4882_algo;
44713
44714 /* Wrapper access functions for multiplexed SMBus */
44715 static DEFINE_MUTEX(amd756_lock);
44716diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
44717index 88eda09..cf40434 100644
44718--- a/drivers/i2c/busses/i2c-nforce2-s4985.c
44719+++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
44720@@ -37,7 +37,7 @@
44721 extern struct i2c_adapter *nforce2_smbus;
44722
44723 static struct i2c_adapter *s4985_adapter;
44724-static struct i2c_algorithm *s4985_algo;
44725+static i2c_algorithm_no_const *s4985_algo;
44726
44727 /* Wrapper access functions for multiplexed SMBus */
44728 static DEFINE_MUTEX(nforce2_lock);
44729diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
44730index 71c7a39..71dd3e0 100644
44731--- a/drivers/i2c/i2c-dev.c
44732+++ b/drivers/i2c/i2c-dev.c
44733@@ -272,7 +272,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
44734 break;
44735 }
44736
44737- data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
44738+ data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
44739 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
44740 if (IS_ERR(rdwr_pa[i].buf)) {
44741 res = PTR_ERR(rdwr_pa[i].buf);
44742diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
44743index 64a6b82..a524354 100644
44744--- a/drivers/ide/ide-cd.c
44745+++ b/drivers/ide/ide-cd.c
44746@@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
44747 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
44748 if ((unsigned long)buf & alignment
44749 || blk_rq_bytes(rq) & q->dma_pad_mask
44750- || object_is_on_stack(buf))
44751+ || object_starts_on_stack(buf))
44752 drive->dma = 0;
44753 }
44754 }
44755diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
44756index 56b9708..980b63b 100644
44757--- a/drivers/ide/ide-disk.c
44758+++ b/drivers/ide/ide-disk.c
44759@@ -178,7 +178,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
44760 * 1073741822 == 549756 MB or 48bit addressing fake drive
44761 */
44762
44763-static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
44764+static ide_startstop_t __intentional_overflow(-1) ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
44765 sector_t block)
44766 {
44767 ide_hwif_t *hwif = drive->hwif;
44768diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
44769index 3524b0d..8c14520 100644
44770--- a/drivers/iio/industrialio-core.c
44771+++ b/drivers/iio/industrialio-core.c
44772@@ -576,7 +576,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
44773 }
44774
44775 static
44776-int __iio_device_attr_init(struct device_attribute *dev_attr,
44777+int __iio_device_attr_init(device_attribute_no_const *dev_attr,
44778 const char *postfix,
44779 struct iio_chan_spec const *chan,
44780 ssize_t (*readfunc)(struct device *dev,
44781diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
44782index b13936d..65322b2 100644
44783--- a/drivers/iio/magnetometer/ak8975.c
44784+++ b/drivers/iio/magnetometer/ak8975.c
44785@@ -776,7 +776,7 @@ static int ak8975_probe(struct i2c_client *client,
44786 name = id->name;
44787 } else if (ACPI_HANDLE(&client->dev))
44788 name = ak8975_match_acpi_device(&client->dev, &chipset);
44789- else
44790+ if (!name)
44791 return -ENOSYS;
44792
44793 if (chipset >= AK_MAX_TYPE) {
44794diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
44795index 3a972eb..4126183 100644
44796--- a/drivers/infiniband/core/cm.c
44797+++ b/drivers/infiniband/core/cm.c
44798@@ -115,7 +115,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
44799
44800 struct cm_counter_group {
44801 struct kobject obj;
44802- atomic_long_t counter[CM_ATTR_COUNT];
44803+ atomic_long_unchecked_t counter[CM_ATTR_COUNT];
44804 };
44805
44806 struct cm_counter_attribute {
44807@@ -1411,7 +1411,7 @@ static void cm_dup_req_handler(struct cm_work *work,
44808 struct ib_mad_send_buf *msg = NULL;
44809 int ret;
44810
44811- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44812+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44813 counter[CM_REQ_COUNTER]);
44814
44815 /* Quick state check to discard duplicate REQs. */
44816@@ -1798,7 +1798,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
44817 if (!cm_id_priv)
44818 return;
44819
44820- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44821+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44822 counter[CM_REP_COUNTER]);
44823 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
44824 if (ret)
44825@@ -1965,7 +1965,7 @@ static int cm_rtu_handler(struct cm_work *work)
44826 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
44827 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
44828 spin_unlock_irq(&cm_id_priv->lock);
44829- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44830+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44831 counter[CM_RTU_COUNTER]);
44832 goto out;
44833 }
44834@@ -2148,7 +2148,7 @@ static int cm_dreq_handler(struct cm_work *work)
44835 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
44836 dreq_msg->local_comm_id);
44837 if (!cm_id_priv) {
44838- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44839+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44840 counter[CM_DREQ_COUNTER]);
44841 cm_issue_drep(work->port, work->mad_recv_wc);
44842 return -EINVAL;
44843@@ -2173,7 +2173,7 @@ static int cm_dreq_handler(struct cm_work *work)
44844 case IB_CM_MRA_REP_RCVD:
44845 break;
44846 case IB_CM_TIMEWAIT:
44847- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44848+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44849 counter[CM_DREQ_COUNTER]);
44850 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
44851 goto unlock;
44852@@ -2187,7 +2187,7 @@ static int cm_dreq_handler(struct cm_work *work)
44853 cm_free_msg(msg);
44854 goto deref;
44855 case IB_CM_DREQ_RCVD:
44856- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44857+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44858 counter[CM_DREQ_COUNTER]);
44859 goto unlock;
44860 default:
44861@@ -2554,7 +2554,7 @@ static int cm_mra_handler(struct cm_work *work)
44862 ib_modify_mad(cm_id_priv->av.port->mad_agent,
44863 cm_id_priv->msg, timeout)) {
44864 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
44865- atomic_long_inc(&work->port->
44866+ atomic_long_inc_unchecked(&work->port->
44867 counter_group[CM_RECV_DUPLICATES].
44868 counter[CM_MRA_COUNTER]);
44869 goto out;
44870@@ -2563,7 +2563,7 @@ static int cm_mra_handler(struct cm_work *work)
44871 break;
44872 case IB_CM_MRA_REQ_RCVD:
44873 case IB_CM_MRA_REP_RCVD:
44874- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44875+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44876 counter[CM_MRA_COUNTER]);
44877 /* fall through */
44878 default:
44879@@ -2725,7 +2725,7 @@ static int cm_lap_handler(struct cm_work *work)
44880 case IB_CM_LAP_IDLE:
44881 break;
44882 case IB_CM_MRA_LAP_SENT:
44883- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44884+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44885 counter[CM_LAP_COUNTER]);
44886 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
44887 goto unlock;
44888@@ -2741,7 +2741,7 @@ static int cm_lap_handler(struct cm_work *work)
44889 cm_free_msg(msg);
44890 goto deref;
44891 case IB_CM_LAP_RCVD:
44892- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44893+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44894 counter[CM_LAP_COUNTER]);
44895 goto unlock;
44896 default:
44897@@ -3025,7 +3025,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
44898 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
44899 if (cur_cm_id_priv) {
44900 spin_unlock_irq(&cm.lock);
44901- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
44902+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
44903 counter[CM_SIDR_REQ_COUNTER]);
44904 goto out; /* Duplicate message. */
44905 }
44906@@ -3237,10 +3237,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
44907 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
44908 msg->retries = 1;
44909
44910- atomic_long_add(1 + msg->retries,
44911+ atomic_long_add_unchecked(1 + msg->retries,
44912 &port->counter_group[CM_XMIT].counter[attr_index]);
44913 if (msg->retries)
44914- atomic_long_add(msg->retries,
44915+ atomic_long_add_unchecked(msg->retries,
44916 &port->counter_group[CM_XMIT_RETRIES].
44917 counter[attr_index]);
44918
44919@@ -3466,7 +3466,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
44920 }
44921
44922 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
44923- atomic_long_inc(&port->counter_group[CM_RECV].
44924+ atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
44925 counter[attr_id - CM_ATTR_ID_OFFSET]);
44926
44927 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
44928@@ -3709,7 +3709,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
44929 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
44930
44931 return sprintf(buf, "%ld\n",
44932- atomic_long_read(&group->counter[cm_attr->index]));
44933+ atomic_long_read_unchecked(&group->counter[cm_attr->index]));
44934 }
44935
44936 static const struct sysfs_ops cm_counter_ops = {
44937diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
44938index 9f5ad7c..588cd84 100644
44939--- a/drivers/infiniband/core/fmr_pool.c
44940+++ b/drivers/infiniband/core/fmr_pool.c
44941@@ -98,8 +98,8 @@ struct ib_fmr_pool {
44942
44943 struct task_struct *thread;
44944
44945- atomic_t req_ser;
44946- atomic_t flush_ser;
44947+ atomic_unchecked_t req_ser;
44948+ atomic_unchecked_t flush_ser;
44949
44950 wait_queue_head_t force_wait;
44951 };
44952@@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
44953 struct ib_fmr_pool *pool = pool_ptr;
44954
44955 do {
44956- if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
44957+ if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
44958 ib_fmr_batch_release(pool);
44959
44960- atomic_inc(&pool->flush_ser);
44961+ atomic_inc_unchecked(&pool->flush_ser);
44962 wake_up_interruptible(&pool->force_wait);
44963
44964 if (pool->flush_function)
44965@@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
44966 }
44967
44968 set_current_state(TASK_INTERRUPTIBLE);
44969- if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
44970+ if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
44971 !kthread_should_stop())
44972 schedule();
44973 __set_current_state(TASK_RUNNING);
44974@@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
44975 pool->dirty_watermark = params->dirty_watermark;
44976 pool->dirty_len = 0;
44977 spin_lock_init(&pool->pool_lock);
44978- atomic_set(&pool->req_ser, 0);
44979- atomic_set(&pool->flush_ser, 0);
44980+ atomic_set_unchecked(&pool->req_ser, 0);
44981+ atomic_set_unchecked(&pool->flush_ser, 0);
44982 init_waitqueue_head(&pool->force_wait);
44983
44984 pool->thread = kthread_run(ib_fmr_cleanup_thread,
44985@@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
44986 }
44987 spin_unlock_irq(&pool->pool_lock);
44988
44989- serial = atomic_inc_return(&pool->req_ser);
44990+ serial = atomic_inc_return_unchecked(&pool->req_ser);
44991 wake_up_process(pool->thread);
44992
44993 if (wait_event_interruptible(pool->force_wait,
44994- atomic_read(&pool->flush_ser) - serial >= 0))
44995+ atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
44996 return -EINTR;
44997
44998 return 0;
44999@@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
45000 } else {
45001 list_add_tail(&fmr->list, &pool->dirty_list);
45002 if (++pool->dirty_len >= pool->dirty_watermark) {
45003- atomic_inc(&pool->req_ser);
45004+ atomic_inc_unchecked(&pool->req_ser);
45005 wake_up_process(pool->thread);
45006 }
45007 }
45008diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
45009index a6ca83b..bd3a726 100644
45010--- a/drivers/infiniband/core/uverbs_cmd.c
45011+++ b/drivers/infiniband/core/uverbs_cmd.c
45012@@ -951,6 +951,9 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
45013 if (copy_from_user(&cmd, buf, sizeof cmd))
45014 return -EFAULT;
45015
45016+ if (!access_ok_noprefault(VERIFY_READ, cmd.start, cmd.length))
45017+ return -EFAULT;
45018+
45019 INIT_UDATA(&udata, buf + sizeof cmd,
45020 (unsigned long) cmd.response + sizeof resp,
45021 in_len - sizeof cmd, out_len - sizeof resp);
45022diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
45023index cff815b..75576dd 100644
45024--- a/drivers/infiniband/hw/cxgb4/mem.c
45025+++ b/drivers/infiniband/hw/cxgb4/mem.c
45026@@ -256,7 +256,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
45027 int err;
45028 struct fw_ri_tpte tpt;
45029 u32 stag_idx;
45030- static atomic_t key;
45031+ static atomic_unchecked_t key;
45032
45033 if (c4iw_fatal_error(rdev))
45034 return -EIO;
45035@@ -277,7 +277,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
45036 if (rdev->stats.stag.cur > rdev->stats.stag.max)
45037 rdev->stats.stag.max = rdev->stats.stag.cur;
45038 mutex_unlock(&rdev->stats.lock);
45039- *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
45040+ *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
45041 }
45042 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
45043 __func__, stag_state, type, pdid, stag_idx);
45044diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
45045index 79b3dbc..96e5fcc 100644
45046--- a/drivers/infiniband/hw/ipath/ipath_rc.c
45047+++ b/drivers/infiniband/hw/ipath/ipath_rc.c
45048@@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
45049 struct ib_atomic_eth *ateth;
45050 struct ipath_ack_entry *e;
45051 u64 vaddr;
45052- atomic64_t *maddr;
45053+ atomic64_unchecked_t *maddr;
45054 u64 sdata;
45055 u32 rkey;
45056 u8 next;
45057@@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
45058 IB_ACCESS_REMOTE_ATOMIC)))
45059 goto nack_acc_unlck;
45060 /* Perform atomic OP and save result. */
45061- maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
45062+ maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
45063 sdata = be64_to_cpu(ateth->swap_data);
45064 e = &qp->s_ack_queue[qp->r_head_ack_queue];
45065 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
45066- (u64) atomic64_add_return(sdata, maddr) - sdata :
45067+ (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
45068 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
45069 be64_to_cpu(ateth->compare_data),
45070 sdata);
45071diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
45072index 1f95bba..9530f87 100644
45073--- a/drivers/infiniband/hw/ipath/ipath_ruc.c
45074+++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
45075@@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
45076 unsigned long flags;
45077 struct ib_wc wc;
45078 u64 sdata;
45079- atomic64_t *maddr;
45080+ atomic64_unchecked_t *maddr;
45081 enum ib_wc_status send_status;
45082
45083 /*
45084@@ -382,11 +382,11 @@ again:
45085 IB_ACCESS_REMOTE_ATOMIC)))
45086 goto acc_err;
45087 /* Perform atomic OP and save result. */
45088- maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
45089+ maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
45090 sdata = wqe->wr.wr.atomic.compare_add;
45091 *(u64 *) sqp->s_sge.sge.vaddr =
45092 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
45093- (u64) atomic64_add_return(sdata, maddr) - sdata :
45094+ (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
45095 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
45096 sdata, wqe->wr.wr.atomic.swap);
45097 goto send_comp;
45098diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
45099index 68b3dfa..3e0c511 100644
45100--- a/drivers/infiniband/hw/mlx4/mad.c
45101+++ b/drivers/infiniband/hw/mlx4/mad.c
45102@@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
45103
45104 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
45105 {
45106- return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
45107+ return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
45108 cpu_to_be64(0xff00000000000000LL);
45109 }
45110
45111diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
45112index a0559a8..86a2320 100644
45113--- a/drivers/infiniband/hw/mlx4/mcg.c
45114+++ b/drivers/infiniband/hw/mlx4/mcg.c
45115@@ -1042,7 +1042,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
45116 {
45117 char name[20];
45118
45119- atomic_set(&ctx->tid, 0);
45120+ atomic_set_unchecked(&ctx->tid, 0);
45121 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
45122 ctx->mcg_wq = create_singlethread_workqueue(name);
45123 if (!ctx->mcg_wq)
45124diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
45125index 334387f..e640d74 100644
45126--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
45127+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
45128@@ -436,7 +436,7 @@ struct mlx4_ib_demux_ctx {
45129 struct list_head mcg_mgid0_list;
45130 struct workqueue_struct *mcg_wq;
45131 struct mlx4_ib_demux_pv_ctx **tun;
45132- atomic_t tid;
45133+ atomic_unchecked_t tid;
45134 int flushing; /* flushing the work queue */
45135 };
45136
45137diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
45138index c7f49bb..6a021bb 100644
45139--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
45140+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
45141@@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
45142 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
45143 }
45144
45145-int mthca_QUERY_FW(struct mthca_dev *dev)
45146+int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
45147 {
45148 struct mthca_mailbox *mailbox;
45149 u32 *outbox;
45150@@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
45151 CMD_TIME_CLASS_B);
45152 }
45153
45154-int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
45155+int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
45156 int num_mtt)
45157 {
45158 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
45159@@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
45160 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
45161 }
45162
45163-int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
45164+int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
45165 int eq_num)
45166 {
45167 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
45168@@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
45169 CMD_TIME_CLASS_B);
45170 }
45171
45172-int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
45173+int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
45174 int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
45175 const void *in_mad, void *response_mad)
45176 {
45177diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
45178index ded76c1..0cf0a08 100644
45179--- a/drivers/infiniband/hw/mthca/mthca_main.c
45180+++ b/drivers/infiniband/hw/mthca/mthca_main.c
45181@@ -692,7 +692,7 @@ err_close:
45182 return err;
45183 }
45184
45185-static int mthca_setup_hca(struct mthca_dev *dev)
45186+static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
45187 {
45188 int err;
45189
45190diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
45191index ed9a989..6aa5dc2 100644
45192--- a/drivers/infiniband/hw/mthca/mthca_mr.c
45193+++ b/drivers/infiniband/hw/mthca/mthca_mr.c
45194@@ -81,7 +81,7 @@ struct mthca_mpt_entry {
45195 * through the bitmaps)
45196 */
45197
45198-static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
45199+static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
45200 {
45201 int o;
45202 int m;
45203@@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
45204 return key;
45205 }
45206
45207-int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
45208+int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
45209 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
45210 {
45211 struct mthca_mailbox *mailbox;
45212@@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
45213 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
45214 }
45215
45216-int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
45217+int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
45218 u64 *buffer_list, int buffer_size_shift,
45219 int list_len, u64 iova, u64 total_size,
45220 u32 access, struct mthca_mr *mr)
45221diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
45222index 93ae51d..84c4a44 100644
45223--- a/drivers/infiniband/hw/mthca/mthca_provider.c
45224+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
45225@@ -771,7 +771,7 @@ unlock:
45226 return 0;
45227 }
45228
45229-static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
45230+static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
45231 {
45232 struct mthca_dev *dev = to_mdev(ibcq->device);
45233 struct mthca_cq *cq = to_mcq(ibcq);
45234diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
45235index 9f9d5c5..3c19aac 100644
45236--- a/drivers/infiniband/hw/nes/nes.c
45237+++ b/drivers/infiniband/hw/nes/nes.c
45238@@ -97,7 +97,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
45239 LIST_HEAD(nes_adapter_list);
45240 static LIST_HEAD(nes_dev_list);
45241
45242-atomic_t qps_destroyed;
45243+atomic_unchecked_t qps_destroyed;
45244
45245 static unsigned int ee_flsh_adapter;
45246 static unsigned int sysfs_nonidx_addr;
45247@@ -279,7 +279,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
45248 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
45249 struct nes_adapter *nesadapter = nesdev->nesadapter;
45250
45251- atomic_inc(&qps_destroyed);
45252+ atomic_inc_unchecked(&qps_destroyed);
45253
45254 /* Free the control structures */
45255
45256diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
45257index bd9d132..70d84f4 100644
45258--- a/drivers/infiniband/hw/nes/nes.h
45259+++ b/drivers/infiniband/hw/nes/nes.h
45260@@ -180,17 +180,17 @@ extern unsigned int nes_debug_level;
45261 extern unsigned int wqm_quanta;
45262 extern struct list_head nes_adapter_list;
45263
45264-extern atomic_t cm_connects;
45265-extern atomic_t cm_accepts;
45266-extern atomic_t cm_disconnects;
45267-extern atomic_t cm_closes;
45268-extern atomic_t cm_connecteds;
45269-extern atomic_t cm_connect_reqs;
45270-extern atomic_t cm_rejects;
45271-extern atomic_t mod_qp_timouts;
45272-extern atomic_t qps_created;
45273-extern atomic_t qps_destroyed;
45274-extern atomic_t sw_qps_destroyed;
45275+extern atomic_unchecked_t cm_connects;
45276+extern atomic_unchecked_t cm_accepts;
45277+extern atomic_unchecked_t cm_disconnects;
45278+extern atomic_unchecked_t cm_closes;
45279+extern atomic_unchecked_t cm_connecteds;
45280+extern atomic_unchecked_t cm_connect_reqs;
45281+extern atomic_unchecked_t cm_rejects;
45282+extern atomic_unchecked_t mod_qp_timouts;
45283+extern atomic_unchecked_t qps_created;
45284+extern atomic_unchecked_t qps_destroyed;
45285+extern atomic_unchecked_t sw_qps_destroyed;
45286 extern u32 mh_detected;
45287 extern u32 mh_pauses_sent;
45288 extern u32 cm_packets_sent;
45289@@ -199,16 +199,16 @@ extern u32 cm_packets_created;
45290 extern u32 cm_packets_received;
45291 extern u32 cm_packets_dropped;
45292 extern u32 cm_packets_retrans;
45293-extern atomic_t cm_listens_created;
45294-extern atomic_t cm_listens_destroyed;
45295+extern atomic_unchecked_t cm_listens_created;
45296+extern atomic_unchecked_t cm_listens_destroyed;
45297 extern u32 cm_backlog_drops;
45298-extern atomic_t cm_loopbacks;
45299-extern atomic_t cm_nodes_created;
45300-extern atomic_t cm_nodes_destroyed;
45301-extern atomic_t cm_accel_dropped_pkts;
45302-extern atomic_t cm_resets_recvd;
45303-extern atomic_t pau_qps_created;
45304-extern atomic_t pau_qps_destroyed;
45305+extern atomic_unchecked_t cm_loopbacks;
45306+extern atomic_unchecked_t cm_nodes_created;
45307+extern atomic_unchecked_t cm_nodes_destroyed;
45308+extern atomic_unchecked_t cm_accel_dropped_pkts;
45309+extern atomic_unchecked_t cm_resets_recvd;
45310+extern atomic_unchecked_t pau_qps_created;
45311+extern atomic_unchecked_t pau_qps_destroyed;
45312
45313 extern u32 int_mod_timer_init;
45314 extern u32 int_mod_cq_depth_256;
45315diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
45316index 8a3ad17..e1ed4bc 100644
45317--- a/drivers/infiniband/hw/nes/nes_cm.c
45318+++ b/drivers/infiniband/hw/nes/nes_cm.c
45319@@ -69,14 +69,14 @@ u32 cm_packets_dropped;
45320 u32 cm_packets_retrans;
45321 u32 cm_packets_created;
45322 u32 cm_packets_received;
45323-atomic_t cm_listens_created;
45324-atomic_t cm_listens_destroyed;
45325+atomic_unchecked_t cm_listens_created;
45326+atomic_unchecked_t cm_listens_destroyed;
45327 u32 cm_backlog_drops;
45328-atomic_t cm_loopbacks;
45329-atomic_t cm_nodes_created;
45330-atomic_t cm_nodes_destroyed;
45331-atomic_t cm_accel_dropped_pkts;
45332-atomic_t cm_resets_recvd;
45333+atomic_unchecked_t cm_loopbacks;
45334+atomic_unchecked_t cm_nodes_created;
45335+atomic_unchecked_t cm_nodes_destroyed;
45336+atomic_unchecked_t cm_accel_dropped_pkts;
45337+atomic_unchecked_t cm_resets_recvd;
45338
45339 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
45340 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
45341@@ -135,28 +135,28 @@ static void record_ird_ord(struct nes_cm_node *, u16, u16);
45342 /* instance of function pointers for client API */
45343 /* set address of this instance to cm_core->cm_ops at cm_core alloc */
45344 static struct nes_cm_ops nes_cm_api = {
45345- mini_cm_accelerated,
45346- mini_cm_listen,
45347- mini_cm_del_listen,
45348- mini_cm_connect,
45349- mini_cm_close,
45350- mini_cm_accept,
45351- mini_cm_reject,
45352- mini_cm_recv_pkt,
45353- mini_cm_dealloc_core,
45354- mini_cm_get,
45355- mini_cm_set
45356+ .accelerated = mini_cm_accelerated,
45357+ .listen = mini_cm_listen,
45358+ .stop_listener = mini_cm_del_listen,
45359+ .connect = mini_cm_connect,
45360+ .close = mini_cm_close,
45361+ .accept = mini_cm_accept,
45362+ .reject = mini_cm_reject,
45363+ .recv_pkt = mini_cm_recv_pkt,
45364+ .destroy_cm_core = mini_cm_dealloc_core,
45365+ .get = mini_cm_get,
45366+ .set = mini_cm_set
45367 };
45368
45369 static struct nes_cm_core *g_cm_core;
45370
45371-atomic_t cm_connects;
45372-atomic_t cm_accepts;
45373-atomic_t cm_disconnects;
45374-atomic_t cm_closes;
45375-atomic_t cm_connecteds;
45376-atomic_t cm_connect_reqs;
45377-atomic_t cm_rejects;
45378+atomic_unchecked_t cm_connects;
45379+atomic_unchecked_t cm_accepts;
45380+atomic_unchecked_t cm_disconnects;
45381+atomic_unchecked_t cm_closes;
45382+atomic_unchecked_t cm_connecteds;
45383+atomic_unchecked_t cm_connect_reqs;
45384+atomic_unchecked_t cm_rejects;
45385
45386 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
45387 {
45388@@ -1461,7 +1461,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
45389 kfree(listener);
45390 listener = NULL;
45391 ret = 0;
45392- atomic_inc(&cm_listens_destroyed);
45393+ atomic_inc_unchecked(&cm_listens_destroyed);
45394 } else {
45395 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
45396 }
45397@@ -1670,7 +1670,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
45398 cm_node->rem_mac);
45399
45400 add_hte_node(cm_core, cm_node);
45401- atomic_inc(&cm_nodes_created);
45402+ atomic_inc_unchecked(&cm_nodes_created);
45403
45404 return cm_node;
45405 }
45406@@ -1731,7 +1731,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
45407 }
45408
45409 atomic_dec(&cm_core->node_cnt);
45410- atomic_inc(&cm_nodes_destroyed);
45411+ atomic_inc_unchecked(&cm_nodes_destroyed);
45412 nesqp = cm_node->nesqp;
45413 if (nesqp) {
45414 nesqp->cm_node = NULL;
45415@@ -1795,7 +1795,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
45416
45417 static void drop_packet(struct sk_buff *skb)
45418 {
45419- atomic_inc(&cm_accel_dropped_pkts);
45420+ atomic_inc_unchecked(&cm_accel_dropped_pkts);
45421 dev_kfree_skb_any(skb);
45422 }
45423
45424@@ -1858,7 +1858,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
45425 {
45426
45427 int reset = 0; /* whether to send reset in case of err.. */
45428- atomic_inc(&cm_resets_recvd);
45429+ atomic_inc_unchecked(&cm_resets_recvd);
45430 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
45431 " refcnt=%d\n", cm_node, cm_node->state,
45432 atomic_read(&cm_node->ref_count));
45433@@ -2526,7 +2526,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
45434 rem_ref_cm_node(cm_node->cm_core, cm_node);
45435 return NULL;
45436 }
45437- atomic_inc(&cm_loopbacks);
45438+ atomic_inc_unchecked(&cm_loopbacks);
45439 loopbackremotenode->loopbackpartner = cm_node;
45440 loopbackremotenode->tcp_cntxt.rcv_wscale =
45441 NES_CM_DEFAULT_RCV_WND_SCALE;
45442@@ -2807,7 +2807,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
45443 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
45444 else {
45445 rem_ref_cm_node(cm_core, cm_node);
45446- atomic_inc(&cm_accel_dropped_pkts);
45447+ atomic_inc_unchecked(&cm_accel_dropped_pkts);
45448 dev_kfree_skb_any(skb);
45449 }
45450 break;
45451@@ -3118,7 +3118,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
45452
45453 if ((cm_id) && (cm_id->event_handler)) {
45454 if (issue_disconn) {
45455- atomic_inc(&cm_disconnects);
45456+ atomic_inc_unchecked(&cm_disconnects);
45457 cm_event.event = IW_CM_EVENT_DISCONNECT;
45458 cm_event.status = disconn_status;
45459 cm_event.local_addr = cm_id->local_addr;
45460@@ -3140,7 +3140,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
45461 }
45462
45463 if (issue_close) {
45464- atomic_inc(&cm_closes);
45465+ atomic_inc_unchecked(&cm_closes);
45466 nes_disconnect(nesqp, 1);
45467
45468 cm_id->provider_data = nesqp;
45469@@ -3278,7 +3278,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
45470
45471 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
45472 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
45473- atomic_inc(&cm_accepts);
45474+ atomic_inc_unchecked(&cm_accepts);
45475
45476 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
45477 netdev_refcnt_read(nesvnic->netdev));
45478@@ -3476,7 +3476,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
45479 struct nes_cm_core *cm_core;
45480 u8 *start_buff;
45481
45482- atomic_inc(&cm_rejects);
45483+ atomic_inc_unchecked(&cm_rejects);
45484 cm_node = (struct nes_cm_node *)cm_id->provider_data;
45485 loopback = cm_node->loopbackpartner;
45486 cm_core = cm_node->cm_core;
45487@@ -3541,7 +3541,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
45488 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
45489 ntohs(laddr->sin_port));
45490
45491- atomic_inc(&cm_connects);
45492+ atomic_inc_unchecked(&cm_connects);
45493 nesqp->active_conn = 1;
45494
45495 /* cache the cm_id in the qp */
45496@@ -3688,7 +3688,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
45497 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
45498 return err;
45499 }
45500- atomic_inc(&cm_listens_created);
45501+ atomic_inc_unchecked(&cm_listens_created);
45502 }
45503
45504 cm_id->add_ref(cm_id);
45505@@ -3795,7 +3795,7 @@ static void cm_event_connected(struct nes_cm_event *event)
45506
45507 if (nesqp->destroyed)
45508 return;
45509- atomic_inc(&cm_connecteds);
45510+ atomic_inc_unchecked(&cm_connecteds);
45511 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
45512 " local port 0x%04X. jiffies = %lu.\n",
45513 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
45514@@ -3980,7 +3980,7 @@ static void cm_event_reset(struct nes_cm_event *event)
45515
45516 cm_id->add_ref(cm_id);
45517 ret = cm_id->event_handler(cm_id, &cm_event);
45518- atomic_inc(&cm_closes);
45519+ atomic_inc_unchecked(&cm_closes);
45520 cm_event.event = IW_CM_EVENT_CLOSE;
45521 cm_event.status = 0;
45522 cm_event.provider_data = cm_id->provider_data;
45523@@ -4020,7 +4020,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
45524 return;
45525 cm_id = cm_node->cm_id;
45526
45527- atomic_inc(&cm_connect_reqs);
45528+ atomic_inc_unchecked(&cm_connect_reqs);
45529 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
45530 cm_node, cm_id, jiffies);
45531
45532@@ -4069,7 +4069,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
45533 return;
45534 cm_id = cm_node->cm_id;
45535
45536- atomic_inc(&cm_connect_reqs);
45537+ atomic_inc_unchecked(&cm_connect_reqs);
45538 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
45539 cm_node, cm_id, jiffies);
45540
45541diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
45542index 4166452..fc952c3 100644
45543--- a/drivers/infiniband/hw/nes/nes_mgt.c
45544+++ b/drivers/infiniband/hw/nes/nes_mgt.c
45545@@ -40,8 +40,8 @@
45546 #include "nes.h"
45547 #include "nes_mgt.h"
45548
45549-atomic_t pau_qps_created;
45550-atomic_t pau_qps_destroyed;
45551+atomic_unchecked_t pau_qps_created;
45552+atomic_unchecked_t pau_qps_destroyed;
45553
45554 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
45555 {
45556@@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
45557 {
45558 struct sk_buff *skb;
45559 unsigned long flags;
45560- atomic_inc(&pau_qps_destroyed);
45561+ atomic_inc_unchecked(&pau_qps_destroyed);
45562
45563 /* Free packets that have not yet been forwarded */
45564 /* Lock is acquired by skb_dequeue when removing the skb */
45565@@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
45566 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
45567 skb_queue_head_init(&nesqp->pau_list);
45568 spin_lock_init(&nesqp->pau_lock);
45569- atomic_inc(&pau_qps_created);
45570+ atomic_inc_unchecked(&pau_qps_created);
45571 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
45572 }
45573
45574diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
45575index 70acda9..a96de9d 100644
45576--- a/drivers/infiniband/hw/nes/nes_nic.c
45577+++ b/drivers/infiniband/hw/nes/nes_nic.c
45578@@ -1274,39 +1274,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
45579 target_stat_values[++index] = mh_detected;
45580 target_stat_values[++index] = mh_pauses_sent;
45581 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
45582- target_stat_values[++index] = atomic_read(&cm_connects);
45583- target_stat_values[++index] = atomic_read(&cm_accepts);
45584- target_stat_values[++index] = atomic_read(&cm_disconnects);
45585- target_stat_values[++index] = atomic_read(&cm_connecteds);
45586- target_stat_values[++index] = atomic_read(&cm_connect_reqs);
45587- target_stat_values[++index] = atomic_read(&cm_rejects);
45588- target_stat_values[++index] = atomic_read(&mod_qp_timouts);
45589- target_stat_values[++index] = atomic_read(&qps_created);
45590- target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
45591- target_stat_values[++index] = atomic_read(&qps_destroyed);
45592- target_stat_values[++index] = atomic_read(&cm_closes);
45593+ target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
45594+ target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
45595+ target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
45596+ target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
45597+ target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
45598+ target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
45599+ target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
45600+ target_stat_values[++index] = atomic_read_unchecked(&qps_created);
45601+ target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
45602+ target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
45603+ target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
45604 target_stat_values[++index] = cm_packets_sent;
45605 target_stat_values[++index] = cm_packets_bounced;
45606 target_stat_values[++index] = cm_packets_created;
45607 target_stat_values[++index] = cm_packets_received;
45608 target_stat_values[++index] = cm_packets_dropped;
45609 target_stat_values[++index] = cm_packets_retrans;
45610- target_stat_values[++index] = atomic_read(&cm_listens_created);
45611- target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
45612+ target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
45613+ target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
45614 target_stat_values[++index] = cm_backlog_drops;
45615- target_stat_values[++index] = atomic_read(&cm_loopbacks);
45616- target_stat_values[++index] = atomic_read(&cm_nodes_created);
45617- target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
45618- target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
45619- target_stat_values[++index] = atomic_read(&cm_resets_recvd);
45620+ target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
45621+ target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
45622+ target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
45623+ target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
45624+ target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
45625 target_stat_values[++index] = nesadapter->free_4kpbl;
45626 target_stat_values[++index] = nesadapter->free_256pbl;
45627 target_stat_values[++index] = int_mod_timer_init;
45628 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
45629 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
45630 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
45631- target_stat_values[++index] = atomic_read(&pau_qps_created);
45632- target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
45633+ target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
45634+ target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
45635 }
45636
45637 /**
45638diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
45639index fbc43e5..3672792 100644
45640--- a/drivers/infiniband/hw/nes/nes_verbs.c
45641+++ b/drivers/infiniband/hw/nes/nes_verbs.c
45642@@ -46,9 +46,9 @@
45643
45644 #include <rdma/ib_umem.h>
45645
45646-atomic_t mod_qp_timouts;
45647-atomic_t qps_created;
45648-atomic_t sw_qps_destroyed;
45649+atomic_unchecked_t mod_qp_timouts;
45650+atomic_unchecked_t qps_created;
45651+atomic_unchecked_t sw_qps_destroyed;
45652
45653 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
45654
45655@@ -1137,7 +1137,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
45656 if (init_attr->create_flags)
45657 return ERR_PTR(-EINVAL);
45658
45659- atomic_inc(&qps_created);
45660+ atomic_inc_unchecked(&qps_created);
45661 switch (init_attr->qp_type) {
45662 case IB_QPT_RC:
45663 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
45664@@ -1471,7 +1471,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
45665 struct iw_cm_event cm_event;
45666 int ret = 0;
45667
45668- atomic_inc(&sw_qps_destroyed);
45669+ atomic_inc_unchecked(&sw_qps_destroyed);
45670 nesqp->destroyed = 1;
45671
45672 /* Blow away the connection if it exists. */
45673diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
45674index 7df16f7..7e1b21e 100644
45675--- a/drivers/infiniband/hw/qib/qib.h
45676+++ b/drivers/infiniband/hw/qib/qib.h
45677@@ -52,6 +52,7 @@
45678 #include <linux/kref.h>
45679 #include <linux/sched.h>
45680 #include <linux/kthread.h>
45681+#include <linux/slab.h>
45682
45683 #include "qib_common.h"
45684 #include "qib_verbs.h"
45685diff --git a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
45686index cdc7df4..a2fdfdb 100644
45687--- a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
45688+++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
45689@@ -156,7 +156,7 @@ static size_t ipoib_get_size(const struct net_device *dev)
45690 nla_total_size(2); /* IFLA_IPOIB_UMCAST */
45691 }
45692
45693-static struct rtnl_link_ops ipoib_link_ops __read_mostly = {
45694+static struct rtnl_link_ops ipoib_link_ops = {
45695 .kind = "ipoib",
45696 .maxtype = IFLA_IPOIB_MAX,
45697 .policy = ipoib_policy,
45698diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
45699index e853a21..56fc5a8 100644
45700--- a/drivers/input/gameport/gameport.c
45701+++ b/drivers/input/gameport/gameport.c
45702@@ -527,14 +527,14 @@ EXPORT_SYMBOL(gameport_set_phys);
45703 */
45704 static void gameport_init_port(struct gameport *gameport)
45705 {
45706- static atomic_t gameport_no = ATOMIC_INIT(-1);
45707+ static atomic_unchecked_t gameport_no = ATOMIC_INIT(-1);
45708
45709 __module_get(THIS_MODULE);
45710
45711 mutex_init(&gameport->drv_mutex);
45712 device_initialize(&gameport->dev);
45713 dev_set_name(&gameport->dev, "gameport%lu",
45714- (unsigned long)atomic_inc_return(&gameport_no));
45715+ (unsigned long)atomic_inc_return_unchecked(&gameport_no));
45716 gameport->dev.bus = &gameport_bus;
45717 gameport->dev.release = gameport_release_port;
45718 if (gameport->parent)
45719diff --git a/drivers/input/input.c b/drivers/input/input.c
45720index 78d2499..1f0318e 100644
45721--- a/drivers/input/input.c
45722+++ b/drivers/input/input.c
45723@@ -1775,7 +1775,7 @@ EXPORT_SYMBOL_GPL(input_class);
45724 */
45725 struct input_dev *input_allocate_device(void)
45726 {
45727- static atomic_t input_no = ATOMIC_INIT(-1);
45728+ static atomic_unchecked_t input_no = ATOMIC_INIT(-1);
45729 struct input_dev *dev;
45730
45731 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
45732@@ -1790,7 +1790,7 @@ struct input_dev *input_allocate_device(void)
45733 INIT_LIST_HEAD(&dev->node);
45734
45735 dev_set_name(&dev->dev, "input%lu",
45736- (unsigned long)atomic_inc_return(&input_no));
45737+ (unsigned long)atomic_inc_return_unchecked(&input_no));
45738
45739 __module_get(THIS_MODULE);
45740 }
45741diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
45742index 4a95b22..874c182 100644
45743--- a/drivers/input/joystick/sidewinder.c
45744+++ b/drivers/input/joystick/sidewinder.c
45745@@ -30,6 +30,7 @@
45746 #include <linux/kernel.h>
45747 #include <linux/module.h>
45748 #include <linux/slab.h>
45749+#include <linux/sched.h>
45750 #include <linux/input.h>
45751 #include <linux/gameport.h>
45752 #include <linux/jiffies.h>
45753diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
45754index f8850f9..9708a2d 100644
45755--- a/drivers/input/joystick/xpad.c
45756+++ b/drivers/input/joystick/xpad.c
45757@@ -959,7 +959,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
45758
45759 static int xpad_led_probe(struct usb_xpad *xpad)
45760 {
45761- static atomic_t led_seq = ATOMIC_INIT(-1);
45762+ static atomic_unchecked_t led_seq = ATOMIC_INIT(-1);
45763 struct xpad_led *led;
45764 struct led_classdev *led_cdev;
45765 int error;
45766@@ -971,7 +971,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
45767 if (!led)
45768 return -ENOMEM;
45769
45770- xpad->led_no = atomic_inc_return(&led_seq);
45771+ xpad->led_no = atomic_inc_return_unchecked(&led_seq);
45772
45773 snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->led_no);
45774 led->xpad = xpad;
45775diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
45776index ac1fa5f..5f7502c 100644
45777--- a/drivers/input/misc/ims-pcu.c
45778+++ b/drivers/input/misc/ims-pcu.c
45779@@ -1851,7 +1851,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
45780
45781 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
45782 {
45783- static atomic_t device_no = ATOMIC_INIT(-1);
45784+ static atomic_unchecked_t device_no = ATOMIC_INIT(-1);
45785
45786 const struct ims_pcu_device_info *info;
45787 int error;
45788@@ -1882,7 +1882,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
45789 }
45790
45791 /* Device appears to be operable, complete initialization */
45792- pcu->device_no = atomic_inc_return(&device_no);
45793+ pcu->device_no = atomic_inc_return_unchecked(&device_no);
45794
45795 /*
45796 * PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor
45797diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
45798index ad5a5a1..5eac214 100644
45799--- a/drivers/input/mouse/psmouse.h
45800+++ b/drivers/input/mouse/psmouse.h
45801@@ -125,7 +125,7 @@ struct psmouse_attribute {
45802 ssize_t (*set)(struct psmouse *psmouse, void *data,
45803 const char *buf, size_t count);
45804 bool protect;
45805-};
45806+} __do_const;
45807 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
45808
45809 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
45810diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
45811index b604564..3f14ae4 100644
45812--- a/drivers/input/mousedev.c
45813+++ b/drivers/input/mousedev.c
45814@@ -744,7 +744,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
45815
45816 spin_unlock_irq(&client->packet_lock);
45817
45818- if (copy_to_user(buffer, data, count))
45819+ if (count > sizeof(data) || copy_to_user(buffer, data, count))
45820 return -EFAULT;
45821
45822 return count;
45823diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
45824index a05a517..323a2fd 100644
45825--- a/drivers/input/serio/serio.c
45826+++ b/drivers/input/serio/serio.c
45827@@ -514,7 +514,7 @@ static void serio_release_port(struct device *dev)
45828 */
45829 static void serio_init_port(struct serio *serio)
45830 {
45831- static atomic_t serio_no = ATOMIC_INIT(-1);
45832+ static atomic_unchecked_t serio_no = ATOMIC_INIT(-1);
45833
45834 __module_get(THIS_MODULE);
45835
45836@@ -525,7 +525,7 @@ static void serio_init_port(struct serio *serio)
45837 mutex_init(&serio->drv_mutex);
45838 device_initialize(&serio->dev);
45839 dev_set_name(&serio->dev, "serio%lu",
45840- (unsigned long)atomic_inc_return(&serio_no));
45841+ (unsigned long)atomic_inc_return_unchecked(&serio_no));
45842 serio->dev.bus = &serio_bus;
45843 serio->dev.release = serio_release_port;
45844 serio->dev.groups = serio_device_attr_groups;
45845diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
45846index 71ef5d6..93380a9 100644
45847--- a/drivers/input/serio/serio_raw.c
45848+++ b/drivers/input/serio/serio_raw.c
45849@@ -292,7 +292,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
45850
45851 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
45852 {
45853- static atomic_t serio_raw_no = ATOMIC_INIT(-1);
45854+ static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(-1);
45855 struct serio_raw *serio_raw;
45856 int err;
45857
45858@@ -303,7 +303,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
45859 }
45860
45861 snprintf(serio_raw->name, sizeof(serio_raw->name),
45862- "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no));
45863+ "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no));
45864 kref_init(&serio_raw->kref);
45865 INIT_LIST_HEAD(&serio_raw->client_list);
45866 init_waitqueue_head(&serio_raw->wait);
45867diff --git a/drivers/input/touchscreen/htcpen.c b/drivers/input/touchscreen/htcpen.c
45868index 92e2243..8fd9092 100644
45869--- a/drivers/input/touchscreen/htcpen.c
45870+++ b/drivers/input/touchscreen/htcpen.c
45871@@ -219,7 +219,7 @@ static struct isa_driver htcpen_isa_driver = {
45872 }
45873 };
45874
45875-static struct dmi_system_id htcshift_dmi_table[] __initdata = {
45876+static const struct dmi_system_id htcshift_dmi_table[] __initconst = {
45877 {
45878 .ident = "Shift",
45879 .matches = {
45880diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
45881index f1fb1d3..82257cc 100644
45882--- a/drivers/iommu/Kconfig
45883+++ b/drivers/iommu/Kconfig
45884@@ -102,6 +102,7 @@ config AMD_IOMMU_STATS
45885 bool "Export AMD IOMMU statistics to debugfs"
45886 depends on AMD_IOMMU
45887 select DEBUG_FS
45888+ depends on !GRKERNSEC_KMEM
45889 ---help---
45890 This option enables code in the AMD IOMMU driver to collect various
45891 statistics about whats happening in the driver and exports that
45892diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
45893index 658ee39..6fde5be 100644
45894--- a/drivers/iommu/amd_iommu.c
45895+++ b/drivers/iommu/amd_iommu.c
45896@@ -794,11 +794,21 @@ static void copy_cmd_to_buffer(struct amd_iommu *iommu,
45897
45898 static void build_completion_wait(struct iommu_cmd *cmd, u64 address)
45899 {
45900+ phys_addr_t physaddr;
45901 WARN_ON(address & 0x7ULL);
45902
45903 memset(cmd, 0, sizeof(*cmd));
45904- cmd->data[0] = lower_32_bits(__pa(address)) | CMD_COMPL_WAIT_STORE_MASK;
45905- cmd->data[1] = upper_32_bits(__pa(address));
45906+
45907+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
45908+ if (object_starts_on_stack((void *)address)) {
45909+ void *adjbuf = (void *)address - current->stack + current->lowmem_stack;
45910+ physaddr = __pa((u64)adjbuf);
45911+ } else
45912+#endif
45913+ physaddr = __pa(address);
45914+
45915+ cmd->data[0] = lower_32_bits(physaddr) | CMD_COMPL_WAIT_STORE_MASK;
45916+ cmd->data[1] = upper_32_bits(physaddr);
45917 cmd->data[2] = 1;
45918 CMD_SET_TYPE(cmd, CMD_COMPL_WAIT);
45919 }
45920diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
45921index 4cd0c29..afd3cbe 100644
45922--- a/drivers/iommu/arm-smmu.c
45923+++ b/drivers/iommu/arm-smmu.c
45924@@ -330,7 +330,7 @@ enum arm_smmu_domain_stage {
45925
45926 struct arm_smmu_domain {
45927 struct arm_smmu_device *smmu;
45928- struct io_pgtable_ops *pgtbl_ops;
45929+ struct io_pgtable *pgtbl;
45930 spinlock_t pgtbl_lock;
45931 struct arm_smmu_cfg cfg;
45932 enum arm_smmu_domain_stage stage;
45933@@ -816,7 +816,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
45934 {
45935 int irq, start, ret = 0;
45936 unsigned long ias, oas;
45937- struct io_pgtable_ops *pgtbl_ops;
45938+ struct io_pgtable *pgtbl;
45939 struct io_pgtable_cfg pgtbl_cfg;
45940 enum io_pgtable_fmt fmt;
45941 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
45942@@ -901,14 +901,16 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
45943 };
45944
45945 smmu_domain->smmu = smmu;
45946- pgtbl_ops = alloc_io_pgtable_ops(fmt, &pgtbl_cfg, smmu_domain);
45947- if (!pgtbl_ops) {
45948+ pgtbl = alloc_io_pgtable(fmt, &pgtbl_cfg, smmu_domain);
45949+ if (!pgtbl) {
45950 ret = -ENOMEM;
45951 goto out_clear_smmu;
45952 }
45953
45954 /* Update our support page sizes to reflect the page table format */
45955- arm_smmu_ops.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
45956+ pax_open_kernel();
45957+ *(unsigned long *)&arm_smmu_ops.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
45958+ pax_close_kernel();
45959
45960 /* Initialise the context bank with our page table cfg */
45961 arm_smmu_init_context_bank(smmu_domain, &pgtbl_cfg);
45962@@ -929,7 +931,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
45963 mutex_unlock(&smmu_domain->init_mutex);
45964
45965 /* Publish page table ops for map/unmap */
45966- smmu_domain->pgtbl_ops = pgtbl_ops;
45967+ smmu_domain->pgtbl = pgtbl;
45968 return 0;
45969
45970 out_clear_smmu:
45971@@ -962,8 +964,7 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain)
45972 free_irq(irq, domain);
45973 }
45974
45975- if (smmu_domain->pgtbl_ops)
45976- free_io_pgtable_ops(smmu_domain->pgtbl_ops);
45977+ free_io_pgtable(smmu_domain->pgtbl);
45978
45979 __arm_smmu_free_bitmap(smmu->context_map, cfg->cbndx);
45980 }
45981@@ -1189,13 +1190,13 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova,
45982 int ret;
45983 unsigned long flags;
45984 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
45985- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
45986+ struct io_pgtable *iop = smmu_domain->pgtbl;
45987
45988- if (!ops)
45989+ if (!iop)
45990 return -ENODEV;
45991
45992 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
45993- ret = ops->map(ops, iova, paddr, size, prot);
45994+ ret = iop->ops->map(iop, iova, paddr, size, prot);
45995 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
45996 return ret;
45997 }
45998@@ -1206,13 +1207,13 @@ static size_t arm_smmu_unmap(struct iommu_domain *domain, unsigned long iova,
45999 size_t ret;
46000 unsigned long flags;
46001 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
46002- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
46003+ struct io_pgtable *iop = smmu_domain->pgtbl;
46004
46005- if (!ops)
46006+ if (!iop)
46007 return 0;
46008
46009 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
46010- ret = ops->unmap(ops, iova, size);
46011+ ret = iop->ops->unmap(iop, iova, size);
46012 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
46013 return ret;
46014 }
46015@@ -1223,7 +1224,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
46016 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
46017 struct arm_smmu_device *smmu = smmu_domain->smmu;
46018 struct arm_smmu_cfg *cfg = &smmu_domain->cfg;
46019- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
46020+ struct io_pgtable *iop = smmu_domain->pgtbl;
46021 struct device *dev = smmu->dev;
46022 void __iomem *cb_base;
46023 u32 tmp;
46024@@ -1246,7 +1247,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
46025 dev_err(dev,
46026 "iova to phys timed out on 0x%pad. Falling back to software table walk.\n",
46027 &iova);
46028- return ops->iova_to_phys(ops, iova);
46029+ return iop->ops->iova_to_phys(iop, iova);
46030 }
46031
46032 phys = readl_relaxed(cb_base + ARM_SMMU_CB_PAR_LO);
46033@@ -1267,9 +1268,9 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
46034 phys_addr_t ret;
46035 unsigned long flags;
46036 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
46037- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
46038+ struct io_pgtable *iop = smmu_domain->pgtbl;
46039
46040- if (!ops)
46041+ if (!iop)
46042 return 0;
46043
46044 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
46045@@ -1277,7 +1278,7 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
46046 smmu_domain->stage == ARM_SMMU_DOMAIN_S1) {
46047 ret = arm_smmu_iova_to_phys_hard(domain, iova);
46048 } else {
46049- ret = ops->iova_to_phys(ops, iova);
46050+ ret = iop->ops->iova_to_phys(iop, iova);
46051 }
46052
46053 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
46054@@ -1667,7 +1668,9 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
46055 size |= SZ_64K | SZ_512M;
46056 }
46057
46058- arm_smmu_ops.pgsize_bitmap &= size;
46059+ pax_open_kernel();
46060+ *(unsigned long *)&arm_smmu_ops.pgsize_bitmap &= size;
46061+ pax_close_kernel();
46062 dev_notice(smmu->dev, "\tSupported page sizes: 0x%08lx\n", size);
46063
46064 if (smmu->features & ARM_SMMU_FEAT_TRANS_S1)
46065diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
46066index e29d5d7..e5eeb3e 100644
46067--- a/drivers/iommu/io-pgtable-arm.c
46068+++ b/drivers/iommu/io-pgtable-arm.c
46069@@ -36,12 +36,6 @@
46070 #define io_pgtable_to_data(x) \
46071 container_of((x), struct arm_lpae_io_pgtable, iop)
46072
46073-#define io_pgtable_ops_to_pgtable(x) \
46074- container_of((x), struct io_pgtable, ops)
46075-
46076-#define io_pgtable_ops_to_data(x) \
46077- io_pgtable_to_data(io_pgtable_ops_to_pgtable(x))
46078-
46079 /*
46080 * For consistency with the architecture, we always consider
46081 * ARM_LPAE_MAX_LEVELS levels, with the walk starting at level n >=0
46082@@ -319,10 +313,10 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data,
46083 return pte;
46084 }
46085
46086-static int arm_lpae_map(struct io_pgtable_ops *ops, unsigned long iova,
46087+static int arm_lpae_map(struct io_pgtable *iop, unsigned long iova,
46088 phys_addr_t paddr, size_t size, int iommu_prot)
46089 {
46090- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
46091+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
46092 arm_lpae_iopte *ptep = data->pgd;
46093 int lvl = ARM_LPAE_START_LVL(data);
46094 arm_lpae_iopte prot;
46095@@ -462,12 +456,11 @@ static int __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,
46096 return __arm_lpae_unmap(data, iova, size, lvl + 1, ptep);
46097 }
46098
46099-static int arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova,
46100+static int arm_lpae_unmap(struct io_pgtable *iop, unsigned long iova,
46101 size_t size)
46102 {
46103 size_t unmapped;
46104- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
46105- struct io_pgtable *iop = &data->iop;
46106+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
46107 arm_lpae_iopte *ptep = data->pgd;
46108 int lvl = ARM_LPAE_START_LVL(data);
46109
46110@@ -478,10 +471,10 @@ static int arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova,
46111 return unmapped;
46112 }
46113
46114-static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable_ops *ops,
46115+static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable *iop,
46116 unsigned long iova)
46117 {
46118- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
46119+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
46120 arm_lpae_iopte pte, *ptep = data->pgd;
46121 int lvl = ARM_LPAE_START_LVL(data);
46122
46123@@ -548,6 +541,12 @@ static void arm_lpae_restrict_pgsizes(struct io_pgtable_cfg *cfg)
46124 }
46125 }
46126
46127+static struct io_pgtable_ops arm_lpae_io_pgtable_ops = {
46128+ .map = arm_lpae_map,
46129+ .unmap = arm_lpae_unmap,
46130+ .iova_to_phys = arm_lpae_iova_to_phys,
46131+};
46132+
46133 static struct arm_lpae_io_pgtable *
46134 arm_lpae_alloc_pgtable(struct io_pgtable_cfg *cfg)
46135 {
46136@@ -579,11 +578,7 @@ arm_lpae_alloc_pgtable(struct io_pgtable_cfg *cfg)
46137 pgd_bits = va_bits - (data->bits_per_level * (data->levels - 1));
46138 data->pgd_size = 1UL << (pgd_bits + ilog2(sizeof(arm_lpae_iopte)));
46139
46140- data->iop.ops = (struct io_pgtable_ops) {
46141- .map = arm_lpae_map,
46142- .unmap = arm_lpae_unmap,
46143- .iova_to_phys = arm_lpae_iova_to_phys,
46144- };
46145+ data->iop.ops = &arm_lpae_io_pgtable_ops;
46146
46147 return data;
46148 }
46149@@ -845,9 +840,9 @@ static struct iommu_gather_ops dummy_tlb_ops __initdata = {
46150 .flush_pgtable = dummy_flush_pgtable,
46151 };
46152
46153-static void __init arm_lpae_dump_ops(struct io_pgtable_ops *ops)
46154+static void __init arm_lpae_dump_ops(struct io_pgtable *iop)
46155 {
46156- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
46157+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
46158 struct io_pgtable_cfg *cfg = &data->iop.cfg;
46159
46160 pr_err("cfg: pgsize_bitmap 0x%lx, ias %u-bit\n",
46161@@ -857,9 +852,9 @@ static void __init arm_lpae_dump_ops(struct io_pgtable_ops *ops)
46162 data->bits_per_level, data->pgd);
46163 }
46164
46165-#define __FAIL(ops, i) ({ \
46166+#define __FAIL(iop, i) ({ \
46167 WARN(1, "selftest: test failed for fmt idx %d\n", (i)); \
46168- arm_lpae_dump_ops(ops); \
46169+ arm_lpae_dump_ops(iop); \
46170 selftest_running = false; \
46171 -EFAULT; \
46172 })
46173@@ -874,30 +869,32 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
46174 int i, j;
46175 unsigned long iova;
46176 size_t size;
46177- struct io_pgtable_ops *ops;
46178+ struct io_pgtable *iop;
46179+ const struct io_pgtable_ops *ops;
46180
46181 selftest_running = true;
46182
46183 for (i = 0; i < ARRAY_SIZE(fmts); ++i) {
46184 cfg_cookie = cfg;
46185- ops = alloc_io_pgtable_ops(fmts[i], cfg, cfg);
46186- if (!ops) {
46187+ iop = alloc_io_pgtable(fmts[i], cfg, cfg);
46188+ if (!iop) {
46189 pr_err("selftest: failed to allocate io pgtable ops\n");
46190 return -ENOMEM;
46191 }
46192+ ops = iop->ops;
46193
46194 /*
46195 * Initial sanity checks.
46196 * Empty page tables shouldn't provide any translations.
46197 */
46198- if (ops->iova_to_phys(ops, 42))
46199- return __FAIL(ops, i);
46200+ if (ops->iova_to_phys(iop, 42))
46201+ return __FAIL(iop, i);
46202
46203- if (ops->iova_to_phys(ops, SZ_1G + 42))
46204- return __FAIL(ops, i);
46205+ if (ops->iova_to_phys(iop, SZ_1G + 42))
46206+ return __FAIL(iop, i);
46207
46208- if (ops->iova_to_phys(ops, SZ_2G + 42))
46209- return __FAIL(ops, i);
46210+ if (ops->iova_to_phys(iop, SZ_2G + 42))
46211+ return __FAIL(iop, i);
46212
46213 /*
46214 * Distinct mappings of different granule sizes.
46215@@ -907,19 +904,19 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
46216 while (j != BITS_PER_LONG) {
46217 size = 1UL << j;
46218
46219- if (ops->map(ops, iova, iova, size, IOMMU_READ |
46220+ if (ops->map(iop, iova, iova, size, IOMMU_READ |
46221 IOMMU_WRITE |
46222 IOMMU_NOEXEC |
46223 IOMMU_CACHE))
46224- return __FAIL(ops, i);
46225+ return __FAIL(iop, i);
46226
46227 /* Overlapping mappings */
46228- if (!ops->map(ops, iova, iova + size, size,
46229+ if (!ops->map(iop, iova, iova + size, size,
46230 IOMMU_READ | IOMMU_NOEXEC))
46231- return __FAIL(ops, i);
46232+ return __FAIL(iop, i);
46233
46234- if (ops->iova_to_phys(ops, iova + 42) != (iova + 42))
46235- return __FAIL(ops, i);
46236+ if (ops->iova_to_phys(iop, iova + 42) != (iova + 42))
46237+ return __FAIL(iop, i);
46238
46239 iova += SZ_1G;
46240 j++;
46241@@ -928,15 +925,15 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
46242
46243 /* Partial unmap */
46244 size = 1UL << __ffs(cfg->pgsize_bitmap);
46245- if (ops->unmap(ops, SZ_1G + size, size) != size)
46246- return __FAIL(ops, i);
46247+ if (ops->unmap(iop, SZ_1G + size, size) != size)
46248+ return __FAIL(iop, i);
46249
46250 /* Remap of partial unmap */
46251- if (ops->map(ops, SZ_1G + size, size, size, IOMMU_READ))
46252- return __FAIL(ops, i);
46253+ if (ops->map(iop, SZ_1G + size, size, size, IOMMU_READ))
46254+ return __FAIL(iop, i);
46255
46256- if (ops->iova_to_phys(ops, SZ_1G + size + 42) != (size + 42))
46257- return __FAIL(ops, i);
46258+ if (ops->iova_to_phys(iop, SZ_1G + size + 42) != (size + 42))
46259+ return __FAIL(iop, i);
46260
46261 /* Full unmap */
46262 iova = 0;
46263@@ -944,25 +941,25 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
46264 while (j != BITS_PER_LONG) {
46265 size = 1UL << j;
46266
46267- if (ops->unmap(ops, iova, size) != size)
46268- return __FAIL(ops, i);
46269+ if (ops->unmap(iop, iova, size) != size)
46270+ return __FAIL(iop, i);
46271
46272- if (ops->iova_to_phys(ops, iova + 42))
46273- return __FAIL(ops, i);
46274+ if (ops->iova_to_phys(iop, iova + 42))
46275+ return __FAIL(iop, i);
46276
46277 /* Remap full block */
46278- if (ops->map(ops, iova, iova, size, IOMMU_WRITE))
46279- return __FAIL(ops, i);
46280+ if (ops->map(iop, iova, iova, size, IOMMU_WRITE))
46281+ return __FAIL(iop, i);
46282
46283- if (ops->iova_to_phys(ops, iova + 42) != (iova + 42))
46284- return __FAIL(ops, i);
46285+ if (ops->iova_to_phys(iop, iova + 42) != (iova + 42))
46286+ return __FAIL(iop, i);
46287
46288 iova += SZ_1G;
46289 j++;
46290 j = find_next_bit(&cfg->pgsize_bitmap, BITS_PER_LONG, j);
46291 }
46292
46293- free_io_pgtable_ops(ops);
46294+ free_io_pgtable(iop);
46295 }
46296
46297 selftest_running = false;
46298diff --git a/drivers/iommu/io-pgtable.c b/drivers/iommu/io-pgtable.c
46299index 6436fe2..088c965 100644
46300--- a/drivers/iommu/io-pgtable.c
46301+++ b/drivers/iommu/io-pgtable.c
46302@@ -40,7 +40,7 @@ io_pgtable_init_table[IO_PGTABLE_NUM_FMTS] =
46303 #endif
46304 };
46305
46306-struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
46307+struct io_pgtable *alloc_io_pgtable(enum io_pgtable_fmt fmt,
46308 struct io_pgtable_cfg *cfg,
46309 void *cookie)
46310 {
46311@@ -62,21 +62,18 @@ struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
46312 iop->cookie = cookie;
46313 iop->cfg = *cfg;
46314
46315- return &iop->ops;
46316+ return iop;
46317 }
46318
46319 /*
46320 * It is the IOMMU driver's responsibility to ensure that the page table
46321 * is no longer accessible to the walker by this point.
46322 */
46323-void free_io_pgtable_ops(struct io_pgtable_ops *ops)
46324+void free_io_pgtable(struct io_pgtable *iop)
46325 {
46326- struct io_pgtable *iop;
46327-
46328- if (!ops)
46329+ if (!iop)
46330 return;
46331
46332- iop = container_of(ops, struct io_pgtable, ops);
46333 iop->cfg.tlb->tlb_flush_all(iop->cookie);
46334 io_pgtable_init_table[iop->fmt]->free(iop);
46335 }
46336diff --git a/drivers/iommu/io-pgtable.h b/drivers/iommu/io-pgtable.h
46337index 10e32f6..0b276c8 100644
46338--- a/drivers/iommu/io-pgtable.h
46339+++ b/drivers/iommu/io-pgtable.h
46340@@ -75,17 +75,18 @@ struct io_pgtable_cfg {
46341 * These functions map directly onto the iommu_ops member functions with
46342 * the same names.
46343 */
46344+struct io_pgtable;
46345 struct io_pgtable_ops {
46346- int (*map)(struct io_pgtable_ops *ops, unsigned long iova,
46347+ int (*map)(struct io_pgtable *iop, unsigned long iova,
46348 phys_addr_t paddr, size_t size, int prot);
46349- int (*unmap)(struct io_pgtable_ops *ops, unsigned long iova,
46350+ int (*unmap)(struct io_pgtable *iop, unsigned long iova,
46351 size_t size);
46352- phys_addr_t (*iova_to_phys)(struct io_pgtable_ops *ops,
46353+ phys_addr_t (*iova_to_phys)(struct io_pgtable *iop,
46354 unsigned long iova);
46355 };
46356
46357 /**
46358- * alloc_io_pgtable_ops() - Allocate a page table allocator for use by an IOMMU.
46359+ * alloc_io_pgtable() - Allocate a page table allocator for use by an IOMMU.
46360 *
46361 * @fmt: The page table format.
46362 * @cfg: The page table configuration. This will be modified to represent
46363@@ -94,9 +95,9 @@ struct io_pgtable_ops {
46364 * @cookie: An opaque token provided by the IOMMU driver and passed back to
46365 * the callback routines in cfg->tlb.
46366 */
46367-struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
46368- struct io_pgtable_cfg *cfg,
46369- void *cookie);
46370+struct io_pgtable *alloc_io_pgtable(enum io_pgtable_fmt fmt,
46371+ struct io_pgtable_cfg *cfg,
46372+ void *cookie);
46373
46374 /**
46375 * free_io_pgtable_ops() - Free an io_pgtable_ops structure. The caller
46376@@ -105,7 +106,7 @@ struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
46377 *
46378 * @ops: The ops returned from alloc_io_pgtable_ops.
46379 */
46380-void free_io_pgtable_ops(struct io_pgtable_ops *ops);
46381+void free_io_pgtable(struct io_pgtable *iop);
46382
46383
46384 /*
46385@@ -125,7 +126,7 @@ struct io_pgtable {
46386 enum io_pgtable_fmt fmt;
46387 void *cookie;
46388 struct io_pgtable_cfg cfg;
46389- struct io_pgtable_ops ops;
46390+ const struct io_pgtable_ops *ops;
46391 };
46392
46393 /**
46394diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
46395index f286090..bac3e7e 100644
46396--- a/drivers/iommu/iommu.c
46397+++ b/drivers/iommu/iommu.c
46398@@ -934,7 +934,7 @@ static int iommu_bus_notifier(struct notifier_block *nb,
46399 static int iommu_bus_init(struct bus_type *bus, const struct iommu_ops *ops)
46400 {
46401 int err;
46402- struct notifier_block *nb;
46403+ notifier_block_no_const *nb;
46404 struct iommu_callback_data cb = {
46405 .ops = ops,
46406 };
46407diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
46408index 1a67c53..23181d8 100644
46409--- a/drivers/iommu/ipmmu-vmsa.c
46410+++ b/drivers/iommu/ipmmu-vmsa.c
46411@@ -41,7 +41,7 @@ struct ipmmu_vmsa_domain {
46412 struct iommu_domain io_domain;
46413
46414 struct io_pgtable_cfg cfg;
46415- struct io_pgtable_ops *iop;
46416+ struct io_pgtable *iop;
46417
46418 unsigned int context_id;
46419 spinlock_t lock; /* Protects mappings */
46420@@ -328,8 +328,7 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
46421 domain->cfg.oas = 40;
46422 domain->cfg.tlb = &ipmmu_gather_ops;
46423
46424- domain->iop = alloc_io_pgtable_ops(ARM_32_LPAE_S1, &domain->cfg,
46425- domain);
46426+ domain->iop = alloc_io_pgtable(ARM_32_LPAE_S1, &domain->cfg, domain);
46427 if (!domain->iop)
46428 return -EINVAL;
46429
46430@@ -487,7 +486,7 @@ static void ipmmu_domain_free(struct iommu_domain *io_domain)
46431 * been detached.
46432 */
46433 ipmmu_domain_destroy_context(domain);
46434- free_io_pgtable_ops(domain->iop);
46435+ free_io_pgtable(domain->iop);
46436 kfree(domain);
46437 }
46438
46439@@ -556,7 +555,7 @@ static int ipmmu_map(struct iommu_domain *io_domain, unsigned long iova,
46440 if (!domain)
46441 return -ENODEV;
46442
46443- return domain->iop->map(domain->iop, iova, paddr, size, prot);
46444+ return domain->iop->ops->map(domain->iop, iova, paddr, size, prot);
46445 }
46446
46447 static size_t ipmmu_unmap(struct iommu_domain *io_domain, unsigned long iova,
46448@@ -564,7 +563,7 @@ static size_t ipmmu_unmap(struct iommu_domain *io_domain, unsigned long iova,
46449 {
46450 struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
46451
46452- return domain->iop->unmap(domain->iop, iova, size);
46453+ return domain->iop->ops->unmap(domain->iop, iova, size);
46454 }
46455
46456 static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,
46457@@ -574,7 +573,7 @@ static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,
46458
46459 /* TODO: Is locking needed ? */
46460
46461- return domain->iop->iova_to_phys(domain->iop, iova);
46462+ return domain->iop->ops->iova_to_phys(domain->iop, iova);
46463 }
46464
46465 static int ipmmu_find_utlbs(struct ipmmu_vmsa_device *mmu, struct device *dev,
46466diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
46467index 2d99930..b8b358c 100644
46468--- a/drivers/iommu/irq_remapping.c
46469+++ b/drivers/iommu/irq_remapping.c
46470@@ -149,7 +149,7 @@ int __init irq_remap_enable_fault_handling(void)
46471 void panic_if_irq_remap(const char *msg)
46472 {
46473 if (irq_remapping_enabled)
46474- panic(msg);
46475+ panic("%s", msg);
46476 }
46477
46478 void ir_ack_apic_edge(struct irq_data *data)
46479diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c
46480index f3d20a2..5dcb85e 100644
46481--- a/drivers/iommu/omap-iommu-debug.c
46482+++ b/drivers/iommu/omap-iommu-debug.c
46483@@ -55,34 +55,22 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
46484 return bytes;
46485 }
46486
46487-static ssize_t debug_read_tlb(struct file *file, char __user *userbuf,
46488- size_t count, loff_t *ppos)
46489+static int debug_read_tlb(struct seq_file *s, void *data)
46490 {
46491- struct omap_iommu *obj = file->private_data;
46492- char *p, *buf;
46493- ssize_t bytes, rest;
46494+ struct omap_iommu *obj = s->private;
46495
46496 if (is_omap_iommu_detached(obj))
46497 return -EPERM;
46498
46499- buf = kmalloc(count, GFP_KERNEL);
46500- if (!buf)
46501- return -ENOMEM;
46502- p = buf;
46503-
46504 mutex_lock(&iommu_debug_lock);
46505
46506- p += sprintf(p, "%8s %8s\n", "cam:", "ram:");
46507- p += sprintf(p, "-----------------------------------------\n");
46508- rest = count - (p - buf);
46509- p += omap_dump_tlb_entries(obj, p, rest);
46510-
46511- bytes = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
46512+ seq_printf(s, "%8s %8s\n", "cam:", "ram:");
46513+ seq_puts(s, "-----------------------------------------\n");
46514+ omap_dump_tlb_entries(obj, s);
46515
46516 mutex_unlock(&iommu_debug_lock);
46517- kfree(buf);
46518
46519- return bytes;
46520+ return 0;
46521 }
46522
46523 static void dump_ioptable(struct seq_file *s)
46524@@ -157,7 +145,7 @@ static int debug_read_pagetable(struct seq_file *s, void *data)
46525 };
46526
46527 DEBUG_FOPS_RO(regs);
46528-DEBUG_FOPS_RO(tlb);
46529+DEBUG_SEQ_FOPS_RO(tlb);
46530 DEBUG_SEQ_FOPS_RO(pagetable);
46531
46532 #define __DEBUG_ADD_FILE(attr, mode) \
46533diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
46534index a22c33d..2247075e2 100644
46535--- a/drivers/iommu/omap-iommu.c
46536+++ b/drivers/iommu/omap-iommu.c
46537@@ -546,36 +546,30 @@ __dump_tlb_entries(struct omap_iommu *obj, struct cr_regs *crs, int num)
46538 }
46539
46540 /**
46541- * iotlb_dump_cr - Dump an iommu tlb entry into buf
46542+ * iotlb_dump_cr - Dump an iommu tlb entry into seq_file
46543 * @obj: target iommu
46544 * @cr: contents of cam and ram register
46545- * @buf: output buffer
46546+ * @s: output seq_file
46547 **/
46548 static ssize_t iotlb_dump_cr(struct omap_iommu *obj, struct cr_regs *cr,
46549- char *buf)
46550+ struct seq_file *s)
46551 {
46552- char *p = buf;
46553-
46554 /* FIXME: Need more detail analysis of cam/ram */
46555- p += sprintf(p, "%08x %08x %01x\n", cr->cam, cr->ram,
46556- (cr->cam & MMU_CAM_P) ? 1 : 0);
46557-
46558- return p - buf;
46559+ return seq_printf(s, "%08x %08x %01x\n", cr->cam, cr->ram,
46560+ (cr->cam & MMU_CAM_P) ? 1 : 0);
46561 }
46562
46563 /**
46564- * omap_dump_tlb_entries - dump cr arrays to given buffer
46565+ * omap_dump_tlb_entries - dump cr arrays to given seq_file
46566 * @obj: target iommu
46567- * @buf: output buffer
46568+ * @s: output seq_file
46569 **/
46570-size_t omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t bytes)
46571+size_t omap_dump_tlb_entries(struct omap_iommu *obj, struct seq_file *s)
46572 {
46573 int i, num;
46574 struct cr_regs *cr;
46575- char *p = buf;
46576
46577- num = bytes / sizeof(*cr);
46578- num = min(obj->nr_tlb_entries, num);
46579+ num = obj->nr_tlb_entries;
46580
46581 cr = kcalloc(num, sizeof(*cr), GFP_KERNEL);
46582 if (!cr)
46583@@ -583,10 +577,10 @@ size_t omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t bytes)
46584
46585 num = __dump_tlb_entries(obj, cr, num);
46586 for (i = 0; i < num; i++)
46587- p += iotlb_dump_cr(obj, cr + i, p);
46588+ iotlb_dump_cr(obj, cr + i, s);
46589 kfree(cr);
46590
46591- return p - buf;
46592+ return 0;
46593 }
46594
46595 #endif /* CONFIG_OMAP_IOMMU_DEBUG */
46596diff --git a/drivers/iommu/omap-iommu.h b/drivers/iommu/omap-iommu.h
46597index d736630..5df9755 100644
46598--- a/drivers/iommu/omap-iommu.h
46599+++ b/drivers/iommu/omap-iommu.h
46600@@ -193,8 +193,7 @@ static inline struct omap_iommu *dev_to_omap_iommu(struct device *dev)
46601 #ifdef CONFIG_OMAP_IOMMU_DEBUG
46602 extern ssize_t
46603 omap_iommu_dump_ctx(struct omap_iommu *obj, char *buf, ssize_t len);
46604-extern size_t
46605-omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t len);
46606+extern size_t omap_dump_tlb_entries(struct omap_iommu *obj, struct seq_file *s);
46607
46608 void omap_iommu_debugfs_init(void);
46609 void omap_iommu_debugfs_exit(void);
46610diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
46611index 4dd8826..1f33400 100644
46612--- a/drivers/irqchip/irq-gic.c
46613+++ b/drivers/irqchip/irq-gic.c
46614@@ -313,7 +313,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
46615 chained_irq_exit(chip, desc);
46616 }
46617
46618-static struct irq_chip gic_chip = {
46619+static irq_chip_no_const gic_chip __read_only = {
46620 .name = "GIC",
46621 .irq_mask = gic_mask_irq,
46622 .irq_unmask = gic_unmask_irq,
46623diff --git a/drivers/irqchip/irq-renesas-intc-irqpin.c b/drivers/irqchip/irq-renesas-intc-irqpin.c
46624index 0670ab4..1094651 100644
46625--- a/drivers/irqchip/irq-renesas-intc-irqpin.c
46626+++ b/drivers/irqchip/irq-renesas-intc-irqpin.c
46627@@ -373,7 +373,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
46628 struct intc_irqpin_iomem *i;
46629 struct resource *io[INTC_IRQPIN_REG_NR];
46630 struct resource *irq;
46631- struct irq_chip *irq_chip;
46632+ irq_chip_no_const *irq_chip;
46633 void (*enable_fn)(struct irq_data *d);
46634 void (*disable_fn)(struct irq_data *d);
46635 const char *name = dev_name(dev);
46636diff --git a/drivers/irqchip/irq-renesas-irqc.c b/drivers/irqchip/irq-renesas-irqc.c
46637index 778bd07..0397152 100644
46638--- a/drivers/irqchip/irq-renesas-irqc.c
46639+++ b/drivers/irqchip/irq-renesas-irqc.c
46640@@ -176,7 +176,7 @@ static int irqc_probe(struct platform_device *pdev)
46641 struct irqc_priv *p;
46642 struct resource *io;
46643 struct resource *irq;
46644- struct irq_chip *irq_chip;
46645+ irq_chip_no_const *irq_chip;
46646 const char *name = dev_name(&pdev->dev);
46647 int ret;
46648 int k;
46649diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
46650index 6a2df32..dc962f1 100644
46651--- a/drivers/isdn/capi/capi.c
46652+++ b/drivers/isdn/capi/capi.c
46653@@ -81,8 +81,8 @@ struct capiminor {
46654
46655 struct capi20_appl *ap;
46656 u32 ncci;
46657- atomic_t datahandle;
46658- atomic_t msgid;
46659+ atomic_unchecked_t datahandle;
46660+ atomic_unchecked_t msgid;
46661
46662 struct tty_port port;
46663 int ttyinstop;
46664@@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
46665 capimsg_setu16(s, 2, mp->ap->applid);
46666 capimsg_setu8 (s, 4, CAPI_DATA_B3);
46667 capimsg_setu8 (s, 5, CAPI_RESP);
46668- capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
46669+ capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
46670 capimsg_setu32(s, 8, mp->ncci);
46671 capimsg_setu16(s, 12, datahandle);
46672 }
46673@@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
46674 mp->outbytes -= len;
46675 spin_unlock_bh(&mp->outlock);
46676
46677- datahandle = atomic_inc_return(&mp->datahandle);
46678+ datahandle = atomic_inc_return_unchecked(&mp->datahandle);
46679 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
46680 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
46681 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
46682 capimsg_setu16(skb->data, 2, mp->ap->applid);
46683 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
46684 capimsg_setu8 (skb->data, 5, CAPI_REQ);
46685- capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
46686+ capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
46687 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
46688 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
46689 capimsg_setu16(skb->data, 16, len); /* Data length */
46690diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
46691index aecec6d..11e13c5 100644
46692--- a/drivers/isdn/gigaset/bas-gigaset.c
46693+++ b/drivers/isdn/gigaset/bas-gigaset.c
46694@@ -2565,22 +2565,22 @@ static int gigaset_post_reset(struct usb_interface *intf)
46695
46696
46697 static const struct gigaset_ops gigops = {
46698- gigaset_write_cmd,
46699- gigaset_write_room,
46700- gigaset_chars_in_buffer,
46701- gigaset_brkchars,
46702- gigaset_init_bchannel,
46703- gigaset_close_bchannel,
46704- gigaset_initbcshw,
46705- gigaset_freebcshw,
46706- gigaset_reinitbcshw,
46707- gigaset_initcshw,
46708- gigaset_freecshw,
46709- gigaset_set_modem_ctrl,
46710- gigaset_baud_rate,
46711- gigaset_set_line_ctrl,
46712- gigaset_isoc_send_skb,
46713- gigaset_isoc_input,
46714+ .write_cmd = gigaset_write_cmd,
46715+ .write_room = gigaset_write_room,
46716+ .chars_in_buffer = gigaset_chars_in_buffer,
46717+ .brkchars = gigaset_brkchars,
46718+ .init_bchannel = gigaset_init_bchannel,
46719+ .close_bchannel = gigaset_close_bchannel,
46720+ .initbcshw = gigaset_initbcshw,
46721+ .freebcshw = gigaset_freebcshw,
46722+ .reinitbcshw = gigaset_reinitbcshw,
46723+ .initcshw = gigaset_initcshw,
46724+ .freecshw = gigaset_freecshw,
46725+ .set_modem_ctrl = gigaset_set_modem_ctrl,
46726+ .baud_rate = gigaset_baud_rate,
46727+ .set_line_ctrl = gigaset_set_line_ctrl,
46728+ .send_skb = gigaset_isoc_send_skb,
46729+ .handle_input = gigaset_isoc_input,
46730 };
46731
46732 /* bas_gigaset_init
46733diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
46734index 600c79b..3752bab 100644
46735--- a/drivers/isdn/gigaset/interface.c
46736+++ b/drivers/isdn/gigaset/interface.c
46737@@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
46738 }
46739 tty->driver_data = cs;
46740
46741- ++cs->port.count;
46742+ atomic_inc(&cs->port.count);
46743
46744- if (cs->port.count == 1) {
46745+ if (atomic_read(&cs->port.count) == 1) {
46746 tty_port_tty_set(&cs->port, tty);
46747 cs->port.low_latency = 1;
46748 }
46749@@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
46750
46751 if (!cs->connected)
46752 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
46753- else if (!cs->port.count)
46754+ else if (!atomic_read(&cs->port.count))
46755 dev_warn(cs->dev, "%s: device not opened\n", __func__);
46756- else if (!--cs->port.count)
46757+ else if (!atomic_dec_return(&cs->port.count))
46758 tty_port_tty_set(&cs->port, NULL);
46759
46760 mutex_unlock(&cs->mutex);
46761diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
46762index 375be50..675293c 100644
46763--- a/drivers/isdn/gigaset/ser-gigaset.c
46764+++ b/drivers/isdn/gigaset/ser-gigaset.c
46765@@ -453,22 +453,22 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
46766 }
46767
46768 static const struct gigaset_ops ops = {
46769- gigaset_write_cmd,
46770- gigaset_write_room,
46771- gigaset_chars_in_buffer,
46772- gigaset_brkchars,
46773- gigaset_init_bchannel,
46774- gigaset_close_bchannel,
46775- gigaset_initbcshw,
46776- gigaset_freebcshw,
46777- gigaset_reinitbcshw,
46778- gigaset_initcshw,
46779- gigaset_freecshw,
46780- gigaset_set_modem_ctrl,
46781- gigaset_baud_rate,
46782- gigaset_set_line_ctrl,
46783- gigaset_m10x_send_skb, /* asyncdata.c */
46784- gigaset_m10x_input, /* asyncdata.c */
46785+ .write_cmd = gigaset_write_cmd,
46786+ .write_room = gigaset_write_room,
46787+ .chars_in_buffer = gigaset_chars_in_buffer,
46788+ .brkchars = gigaset_brkchars,
46789+ .init_bchannel = gigaset_init_bchannel,
46790+ .close_bchannel = gigaset_close_bchannel,
46791+ .initbcshw = gigaset_initbcshw,
46792+ .freebcshw = gigaset_freebcshw,
46793+ .reinitbcshw = gigaset_reinitbcshw,
46794+ .initcshw = gigaset_initcshw,
46795+ .freecshw = gigaset_freecshw,
46796+ .set_modem_ctrl = gigaset_set_modem_ctrl,
46797+ .baud_rate = gigaset_baud_rate,
46798+ .set_line_ctrl = gigaset_set_line_ctrl,
46799+ .send_skb = gigaset_m10x_send_skb, /* asyncdata.c */
46800+ .handle_input = gigaset_m10x_input, /* asyncdata.c */
46801 };
46802
46803
46804diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
46805index 5f306e2..5342f88 100644
46806--- a/drivers/isdn/gigaset/usb-gigaset.c
46807+++ b/drivers/isdn/gigaset/usb-gigaset.c
46808@@ -543,7 +543,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
46809 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
46810 memcpy(cs->hw.usb->bchars, buf, 6);
46811 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
46812- 0, 0, &buf, 6, 2000);
46813+ 0, 0, buf, 6, 2000);
46814 }
46815
46816 static void gigaset_freebcshw(struct bc_state *bcs)
46817@@ -862,22 +862,22 @@ static int gigaset_pre_reset(struct usb_interface *intf)
46818 }
46819
46820 static const struct gigaset_ops ops = {
46821- gigaset_write_cmd,
46822- gigaset_write_room,
46823- gigaset_chars_in_buffer,
46824- gigaset_brkchars,
46825- gigaset_init_bchannel,
46826- gigaset_close_bchannel,
46827- gigaset_initbcshw,
46828- gigaset_freebcshw,
46829- gigaset_reinitbcshw,
46830- gigaset_initcshw,
46831- gigaset_freecshw,
46832- gigaset_set_modem_ctrl,
46833- gigaset_baud_rate,
46834- gigaset_set_line_ctrl,
46835- gigaset_m10x_send_skb,
46836- gigaset_m10x_input,
46837+ .write_cmd = gigaset_write_cmd,
46838+ .write_room = gigaset_write_room,
46839+ .chars_in_buffer = gigaset_chars_in_buffer,
46840+ .brkchars = gigaset_brkchars,
46841+ .init_bchannel = gigaset_init_bchannel,
46842+ .close_bchannel = gigaset_close_bchannel,
46843+ .initbcshw = gigaset_initbcshw,
46844+ .freebcshw = gigaset_freebcshw,
46845+ .reinitbcshw = gigaset_reinitbcshw,
46846+ .initcshw = gigaset_initcshw,
46847+ .freecshw = gigaset_freecshw,
46848+ .set_modem_ctrl = gigaset_set_modem_ctrl,
46849+ .baud_rate = gigaset_baud_rate,
46850+ .set_line_ctrl = gigaset_set_line_ctrl,
46851+ .send_skb = gigaset_m10x_send_skb,
46852+ .handle_input = gigaset_m10x_input,
46853 };
46854
46855 /*
46856diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
46857index 4d9b195..455075c 100644
46858--- a/drivers/isdn/hardware/avm/b1.c
46859+++ b/drivers/isdn/hardware/avm/b1.c
46860@@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
46861 }
46862 if (left) {
46863 if (t4file->user) {
46864- if (copy_from_user(buf, dp, left))
46865+ if (left > sizeof buf || copy_from_user(buf, dp, left))
46866 return -EFAULT;
46867 } else {
46868 memcpy(buf, dp, left);
46869@@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
46870 }
46871 if (left) {
46872 if (config->user) {
46873- if (copy_from_user(buf, dp, left))
46874+ if (left > sizeof buf || copy_from_user(buf, dp, left))
46875 return -EFAULT;
46876 } else {
46877 memcpy(buf, dp, left);
46878diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
46879index 9b856e1..fa03c92 100644
46880--- a/drivers/isdn/i4l/isdn_common.c
46881+++ b/drivers/isdn/i4l/isdn_common.c
46882@@ -1654,6 +1654,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
46883 } else
46884 return -EINVAL;
46885 case IIOCDBGVAR:
46886+ if (!capable(CAP_SYS_RAWIO))
46887+ return -EPERM;
46888 if (arg) {
46889 if (copy_to_user(argp, &dev, sizeof(ulong)))
46890 return -EFAULT;
46891diff --git a/drivers/isdn/i4l/isdn_concap.c b/drivers/isdn/i4l/isdn_concap.c
46892index 91d5730..336523e 100644
46893--- a/drivers/isdn/i4l/isdn_concap.c
46894+++ b/drivers/isdn/i4l/isdn_concap.c
46895@@ -80,9 +80,9 @@ static int isdn_concap_dl_disconn_req(struct concap_proto *concap)
46896 }
46897
46898 struct concap_device_ops isdn_concap_reliable_dl_dops = {
46899- &isdn_concap_dl_data_req,
46900- &isdn_concap_dl_connect_req,
46901- &isdn_concap_dl_disconn_req
46902+ .data_req = &isdn_concap_dl_data_req,
46903+ .connect_req = &isdn_concap_dl_connect_req,
46904+ .disconn_req = &isdn_concap_dl_disconn_req
46905 };
46906
46907 /* The following should better go into a dedicated source file such that
46908diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
46909index bc91261..2ef7e36 100644
46910--- a/drivers/isdn/i4l/isdn_tty.c
46911+++ b/drivers/isdn/i4l/isdn_tty.c
46912@@ -1503,9 +1503,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
46913
46914 #ifdef ISDN_DEBUG_MODEM_OPEN
46915 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
46916- port->count);
46917+ atomic_read(&port->count));
46918 #endif
46919- port->count++;
46920+ atomic_inc(&port->count);
46921 port->tty = tty;
46922 /*
46923 * Start up serial port
46924@@ -1549,7 +1549,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
46925 #endif
46926 return;
46927 }
46928- if ((tty->count == 1) && (port->count != 1)) {
46929+ if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
46930 /*
46931 * Uh, oh. tty->count is 1, which means that the tty
46932 * structure will be freed. Info->count should always
46933@@ -1558,15 +1558,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
46934 * serial port won't be shutdown.
46935 */
46936 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
46937- "info->count is %d\n", port->count);
46938- port->count = 1;
46939+ "info->count is %d\n", atomic_read(&port->count));
46940+ atomic_set(&port->count, 1);
46941 }
46942- if (--port->count < 0) {
46943+ if (atomic_dec_return(&port->count) < 0) {
46944 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
46945- info->line, port->count);
46946- port->count = 0;
46947+ info->line, atomic_read(&port->count));
46948+ atomic_set(&port->count, 0);
46949 }
46950- if (port->count) {
46951+ if (atomic_read(&port->count)) {
46952 #ifdef ISDN_DEBUG_MODEM_OPEN
46953 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
46954 #endif
46955@@ -1620,7 +1620,7 @@ isdn_tty_hangup(struct tty_struct *tty)
46956 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
46957 return;
46958 isdn_tty_shutdown(info);
46959- port->count = 0;
46960+ atomic_set(&port->count, 0);
46961 port->flags &= ~ASYNC_NORMAL_ACTIVE;
46962 port->tty = NULL;
46963 wake_up_interruptible(&port->open_wait);
46964@@ -1965,7 +1965,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
46965 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
46966 modem_info *info = &dev->mdm.info[i];
46967
46968- if (info->port.count == 0)
46969+ if (atomic_read(&info->port.count) == 0)
46970 continue;
46971 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
46972 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
46973diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c
46974index e2d4e58..40cd045 100644
46975--- a/drivers/isdn/i4l/isdn_x25iface.c
46976+++ b/drivers/isdn/i4l/isdn_x25iface.c
46977@@ -53,14 +53,14 @@ static int isdn_x25iface_disconn_ind(struct concap_proto *);
46978
46979
46980 static struct concap_proto_ops ix25_pops = {
46981- &isdn_x25iface_proto_new,
46982- &isdn_x25iface_proto_del,
46983- &isdn_x25iface_proto_restart,
46984- &isdn_x25iface_proto_close,
46985- &isdn_x25iface_xmit,
46986- &isdn_x25iface_receive,
46987- &isdn_x25iface_connect_ind,
46988- &isdn_x25iface_disconn_ind
46989+ .proto_new = &isdn_x25iface_proto_new,
46990+ .proto_del = &isdn_x25iface_proto_del,
46991+ .restart = &isdn_x25iface_proto_restart,
46992+ .close = &isdn_x25iface_proto_close,
46993+ .encap_and_xmit = &isdn_x25iface_xmit,
46994+ .data_ind = &isdn_x25iface_receive,
46995+ .connect_ind = &isdn_x25iface_connect_ind,
46996+ .disconn_ind = &isdn_x25iface_disconn_ind
46997 };
46998
46999 /* error message helper function */
47000diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
47001index 358a574..b4987ea 100644
47002--- a/drivers/isdn/icn/icn.c
47003+++ b/drivers/isdn/icn/icn.c
47004@@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
47005 if (count > len)
47006 count = len;
47007 if (user) {
47008- if (copy_from_user(msg, buf, count))
47009+ if (count > sizeof msg || copy_from_user(msg, buf, count))
47010 return -EFAULT;
47011 } else
47012 memcpy(msg, buf, count);
47013diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
47014index 52c4382..09e0c7c 100644
47015--- a/drivers/isdn/mISDN/dsp_cmx.c
47016+++ b/drivers/isdn/mISDN/dsp_cmx.c
47017@@ -1625,7 +1625,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
47018 static u16 dsp_count; /* last sample count */
47019 static int dsp_count_valid; /* if we have last sample count */
47020
47021-void
47022+void __intentional_overflow(-1)
47023 dsp_cmx_send(void *arg)
47024 {
47025 struct dsp_conf *conf;
47026diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
47027index 312ffd3..9263d05 100644
47028--- a/drivers/lguest/core.c
47029+++ b/drivers/lguest/core.c
47030@@ -96,9 +96,17 @@ static __init int map_switcher(void)
47031 * The end address needs +1 because __get_vm_area allocates an
47032 * extra guard page, so we need space for that.
47033 */
47034+
47035+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
47036+ switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
47037+ VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
47038+ + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
47039+#else
47040 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
47041 VM_ALLOC, switcher_addr, switcher_addr
47042 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
47043+#endif
47044+
47045 if (!switcher_vma) {
47046 err = -ENOMEM;
47047 printk("lguest: could not map switcher pages high\n");
47048@@ -121,7 +129,7 @@ static __init int map_switcher(void)
47049 * Now the Switcher is mapped at the right address, we can't fail!
47050 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
47051 */
47052- memcpy(switcher_vma->addr, start_switcher_text,
47053+ memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
47054 end_switcher_text - start_switcher_text);
47055
47056 printk(KERN_INFO "lguest: mapped switcher at %p\n",
47057diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
47058index e3abebc9..6a35328 100644
47059--- a/drivers/lguest/page_tables.c
47060+++ b/drivers/lguest/page_tables.c
47061@@ -585,7 +585,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
47062 /*:*/
47063
47064 #ifdef CONFIG_X86_PAE
47065-static void release_pmd(pmd_t *spmd)
47066+static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
47067 {
47068 /* If the entry's not present, there's nothing to release. */
47069 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
47070diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
47071index 6a4cd77..c9e2d9f 100644
47072--- a/drivers/lguest/x86/core.c
47073+++ b/drivers/lguest/x86/core.c
47074@@ -60,7 +60,7 @@ static struct {
47075 /* Offset from where switcher.S was compiled to where we've copied it */
47076 static unsigned long switcher_offset(void)
47077 {
47078- return switcher_addr - (unsigned long)start_switcher_text;
47079+ return switcher_addr - ktla_ktva((unsigned long)start_switcher_text);
47080 }
47081
47082 /* This cpu's struct lguest_pages (after the Switcher text page) */
47083@@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
47084 * These copies are pretty cheap, so we do them unconditionally: */
47085 /* Save the current Host top-level page directory.
47086 */
47087+
47088+#ifdef CONFIG_PAX_PER_CPU_PGD
47089+ pages->state.host_cr3 = read_cr3();
47090+#else
47091 pages->state.host_cr3 = __pa(current->mm->pgd);
47092+#endif
47093+
47094 /*
47095 * Set up the Guest's page tables to see this CPU's pages (and no
47096 * other CPU's pages).
47097@@ -494,7 +500,7 @@ void __init lguest_arch_host_init(void)
47098 * compiled-in switcher code and the high-mapped copy we just made.
47099 */
47100 for (i = 0; i < IDT_ENTRIES; i++)
47101- default_idt_entries[i] += switcher_offset();
47102+ default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
47103
47104 /*
47105 * Set up the Switcher's per-cpu areas.
47106@@ -577,7 +583,7 @@ void __init lguest_arch_host_init(void)
47107 * it will be undisturbed when we switch. To change %cs and jump we
47108 * need this structure to feed to Intel's "lcall" instruction.
47109 */
47110- lguest_entry.offset = (long)switch_to_guest + switcher_offset();
47111+ lguest_entry.offset = ktla_ktva((unsigned long)switch_to_guest) + switcher_offset();
47112 lguest_entry.segment = LGUEST_CS;
47113
47114 /*
47115diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
47116index 40634b0..4f5855e 100644
47117--- a/drivers/lguest/x86/switcher_32.S
47118+++ b/drivers/lguest/x86/switcher_32.S
47119@@ -87,6 +87,7 @@
47120 #include <asm/page.h>
47121 #include <asm/segment.h>
47122 #include <asm/lguest.h>
47123+#include <asm/processor-flags.h>
47124
47125 // We mark the start of the code to copy
47126 // It's placed in .text tho it's never run here
47127@@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
47128 // Changes type when we load it: damn Intel!
47129 // For after we switch over our page tables
47130 // That entry will be read-only: we'd crash.
47131+
47132+#ifdef CONFIG_PAX_KERNEXEC
47133+ mov %cr0, %edx
47134+ xor $X86_CR0_WP, %edx
47135+ mov %edx, %cr0
47136+#endif
47137+
47138 movl $(GDT_ENTRY_TSS*8), %edx
47139 ltr %dx
47140
47141@@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
47142 // Let's clear it again for our return.
47143 // The GDT descriptor of the Host
47144 // Points to the table after two "size" bytes
47145- movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
47146+ movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
47147 // Clear "used" from type field (byte 5, bit 2)
47148- andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
47149+ andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
47150+
47151+#ifdef CONFIG_PAX_KERNEXEC
47152+ mov %cr0, %eax
47153+ xor $X86_CR0_WP, %eax
47154+ mov %eax, %cr0
47155+#endif
47156
47157 // Once our page table's switched, the Guest is live!
47158 // The Host fades as we run this final step.
47159@@ -295,13 +309,12 @@ deliver_to_host:
47160 // I consulted gcc, and it gave
47161 // These instructions, which I gladly credit:
47162 leal (%edx,%ebx,8), %eax
47163- movzwl (%eax),%edx
47164- movl 4(%eax), %eax
47165- xorw %ax, %ax
47166- orl %eax, %edx
47167+ movl 4(%eax), %edx
47168+ movw (%eax), %dx
47169 // Now the address of the handler's in %edx
47170 // We call it now: its "iret" drops us home.
47171- jmp *%edx
47172+ ljmp $__KERNEL_CS, $1f
47173+1: jmp *%edx
47174
47175 // Every interrupt can come to us here
47176 // But we must truly tell each apart.
47177diff --git a/drivers/md/bcache/Kconfig b/drivers/md/bcache/Kconfig
47178index 4d20088..de60cb2 100644
47179--- a/drivers/md/bcache/Kconfig
47180+++ b/drivers/md/bcache/Kconfig
47181@@ -20,6 +20,7 @@ config BCACHE_CLOSURES_DEBUG
47182 bool "Debug closures"
47183 depends on BCACHE
47184 select DEBUG_FS
47185+ depends on !GRKERNSEC_KMEM
47186 ---help---
47187 Keeps all active closures in a linked list and provides a debugfs
47188 interface to list them, which makes it possible to see asynchronous
47189diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
47190index 79a6d63..47acff6 100644
47191--- a/drivers/md/bcache/closure.h
47192+++ b/drivers/md/bcache/closure.h
47193@@ -238,7 +238,7 @@ static inline void closure_set_stopped(struct closure *cl)
47194 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
47195 struct workqueue_struct *wq)
47196 {
47197- BUG_ON(object_is_on_stack(cl));
47198+ BUG_ON(object_starts_on_stack(cl));
47199 closure_set_ip(cl);
47200 cl->fn = fn;
47201 cl->wq = wq;
47202diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
47203index 48b5890..b0af0ca 100644
47204--- a/drivers/md/bitmap.c
47205+++ b/drivers/md/bitmap.c
47206@@ -1933,7 +1933,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
47207 chunk_kb ? "KB" : "B");
47208 if (bitmap->storage.file) {
47209 seq_printf(seq, ", file: ");
47210- seq_file_path(seq, bitmap->storage.file, " \t\n");
47211+ seq_file_path(seq, bitmap->storage.file, " \t\n\\");
47212 }
47213
47214 seq_printf(seq, "\n");
47215diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
47216index 720ceeb..030f1d4 100644
47217--- a/drivers/md/dm-ioctl.c
47218+++ b/drivers/md/dm-ioctl.c
47219@@ -1773,7 +1773,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
47220 cmd == DM_LIST_VERSIONS_CMD)
47221 return 0;
47222
47223- if ((cmd == DM_DEV_CREATE_CMD)) {
47224+ if (cmd == DM_DEV_CREATE_CMD) {
47225 if (!*param->name) {
47226 DMWARN("name not supplied when creating device");
47227 return -EINVAL;
47228diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
47229index d83696b..44f22f7 100644
47230--- a/drivers/md/dm-raid1.c
47231+++ b/drivers/md/dm-raid1.c
47232@@ -42,7 +42,7 @@ enum dm_raid1_error {
47233
47234 struct mirror {
47235 struct mirror_set *ms;
47236- atomic_t error_count;
47237+ atomic_unchecked_t error_count;
47238 unsigned long error_type;
47239 struct dm_dev *dev;
47240 sector_t offset;
47241@@ -188,7 +188,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
47242 struct mirror *m;
47243
47244 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
47245- if (!atomic_read(&m->error_count))
47246+ if (!atomic_read_unchecked(&m->error_count))
47247 return m;
47248
47249 return NULL;
47250@@ -220,7 +220,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
47251 * simple way to tell if a device has encountered
47252 * errors.
47253 */
47254- atomic_inc(&m->error_count);
47255+ atomic_inc_unchecked(&m->error_count);
47256
47257 if (test_and_set_bit(error_type, &m->error_type))
47258 return;
47259@@ -378,7 +378,7 @@ static void reset_ms_flags(struct mirror_set *ms)
47260
47261 ms->leg_failure = 0;
47262 for (m = 0; m < ms->nr_mirrors; m++) {
47263- atomic_set(&(ms->mirror[m].error_count), 0);
47264+ atomic_set_unchecked(&(ms->mirror[m].error_count), 0);
47265 ms->mirror[m].error_type = 0;
47266 }
47267 }
47268@@ -423,7 +423,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
47269 struct mirror *m = get_default_mirror(ms);
47270
47271 do {
47272- if (likely(!atomic_read(&m->error_count)))
47273+ if (likely(!atomic_read_unchecked(&m->error_count)))
47274 return m;
47275
47276 if (m-- == ms->mirror)
47277@@ -437,7 +437,7 @@ static int default_ok(struct mirror *m)
47278 {
47279 struct mirror *default_mirror = get_default_mirror(m->ms);
47280
47281- return !atomic_read(&default_mirror->error_count);
47282+ return !atomic_read_unchecked(&default_mirror->error_count);
47283 }
47284
47285 static int mirror_available(struct mirror_set *ms, struct bio *bio)
47286@@ -574,7 +574,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
47287 */
47288 if (likely(region_in_sync(ms, region, 1)))
47289 m = choose_mirror(ms, bio->bi_iter.bi_sector);
47290- else if (m && atomic_read(&m->error_count))
47291+ else if (m && atomic_read_unchecked(&m->error_count))
47292 m = NULL;
47293
47294 if (likely(m))
47295@@ -956,7 +956,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
47296 }
47297
47298 ms->mirror[mirror].ms = ms;
47299- atomic_set(&(ms->mirror[mirror].error_count), 0);
47300+ atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
47301 ms->mirror[mirror].error_type = 0;
47302 ms->mirror[mirror].offset = offset;
47303
47304@@ -1380,7 +1380,7 @@ static void mirror_resume(struct dm_target *ti)
47305 */
47306 static char device_status_char(struct mirror *m)
47307 {
47308- if (!atomic_read(&(m->error_count)))
47309+ if (!atomic_read_unchecked(&(m->error_count)))
47310 return 'A';
47311
47312 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
47313diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
47314index 8289804..12db118 100644
47315--- a/drivers/md/dm-stats.c
47316+++ b/drivers/md/dm-stats.c
47317@@ -435,7 +435,7 @@ do_sync_free:
47318 synchronize_rcu_expedited();
47319 dm_stat_free(&s->rcu_head);
47320 } else {
47321- ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
47322+ ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
47323 call_rcu(&s->rcu_head, dm_stat_free);
47324 }
47325 return 0;
47326@@ -648,8 +648,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
47327 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
47328 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
47329 ));
47330- ACCESS_ONCE(last->last_sector) = end_sector;
47331- ACCESS_ONCE(last->last_rw) = bi_rw;
47332+ ACCESS_ONCE_RW(last->last_sector) = end_sector;
47333+ ACCESS_ONCE_RW(last->last_rw) = bi_rw;
47334 }
47335
47336 rcu_read_lock();
47337diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
47338index a672a15..dc85e99 100644
47339--- a/drivers/md/dm-stripe.c
47340+++ b/drivers/md/dm-stripe.c
47341@@ -21,7 +21,7 @@ struct stripe {
47342 struct dm_dev *dev;
47343 sector_t physical_start;
47344
47345- atomic_t error_count;
47346+ atomic_unchecked_t error_count;
47347 };
47348
47349 struct stripe_c {
47350@@ -188,7 +188,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
47351 kfree(sc);
47352 return r;
47353 }
47354- atomic_set(&(sc->stripe[i].error_count), 0);
47355+ atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
47356 }
47357
47358 ti->private = sc;
47359@@ -332,7 +332,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
47360 DMEMIT("%d ", sc->stripes);
47361 for (i = 0; i < sc->stripes; i++) {
47362 DMEMIT("%s ", sc->stripe[i].dev->name);
47363- buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
47364+ buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
47365 'D' : 'A';
47366 }
47367 buffer[i] = '\0';
47368@@ -377,8 +377,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
47369 */
47370 for (i = 0; i < sc->stripes; i++)
47371 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
47372- atomic_inc(&(sc->stripe[i].error_count));
47373- if (atomic_read(&(sc->stripe[i].error_count)) <
47374+ atomic_inc_unchecked(&(sc->stripe[i].error_count));
47375+ if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
47376 DM_IO_ERROR_THRESHOLD)
47377 schedule_work(&sc->trigger_event);
47378 }
47379diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
47380index 16ba55a..31af906 100644
47381--- a/drivers/md/dm-table.c
47382+++ b/drivers/md/dm-table.c
47383@@ -305,7 +305,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
47384 if (!dev_size)
47385 return 0;
47386
47387- if ((start >= dev_size) || (start + len > dev_size)) {
47388+ if ((start >= dev_size) || (len > dev_size - start)) {
47389 DMWARN("%s: %s too small for target: "
47390 "start=%llu, len=%llu, dev_size=%llu",
47391 dm_device_name(ti->table->md), bdevname(bdev, b),
47392diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
47393index 6ba47cf..a870ba2 100644
47394--- a/drivers/md/dm-thin-metadata.c
47395+++ b/drivers/md/dm-thin-metadata.c
47396@@ -403,7 +403,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
47397 {
47398 pmd->info.tm = pmd->tm;
47399 pmd->info.levels = 2;
47400- pmd->info.value_type.context = pmd->data_sm;
47401+ pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
47402 pmd->info.value_type.size = sizeof(__le64);
47403 pmd->info.value_type.inc = data_block_inc;
47404 pmd->info.value_type.dec = data_block_dec;
47405@@ -422,7 +422,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
47406
47407 pmd->bl_info.tm = pmd->tm;
47408 pmd->bl_info.levels = 1;
47409- pmd->bl_info.value_type.context = pmd->data_sm;
47410+ pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
47411 pmd->bl_info.value_type.size = sizeof(__le64);
47412 pmd->bl_info.value_type.inc = data_block_inc;
47413 pmd->bl_info.value_type.dec = data_block_dec;
47414diff --git a/drivers/md/dm.c b/drivers/md/dm.c
47415index 3e32f4e..01e0a7f 100644
47416--- a/drivers/md/dm.c
47417+++ b/drivers/md/dm.c
47418@@ -194,9 +194,9 @@ struct mapped_device {
47419 /*
47420 * Event handling.
47421 */
47422- atomic_t event_nr;
47423+ atomic_unchecked_t event_nr;
47424 wait_queue_head_t eventq;
47425- atomic_t uevent_seq;
47426+ atomic_unchecked_t uevent_seq;
47427 struct list_head uevent_list;
47428 spinlock_t uevent_lock; /* Protect access to uevent_list */
47429
47430@@ -2339,8 +2339,8 @@ static struct mapped_device *alloc_dev(int minor)
47431 spin_lock_init(&md->deferred_lock);
47432 atomic_set(&md->holders, 1);
47433 atomic_set(&md->open_count, 0);
47434- atomic_set(&md->event_nr, 0);
47435- atomic_set(&md->uevent_seq, 0);
47436+ atomic_set_unchecked(&md->event_nr, 0);
47437+ atomic_set_unchecked(&md->uevent_seq, 0);
47438 INIT_LIST_HEAD(&md->uevent_list);
47439 INIT_LIST_HEAD(&md->table_devices);
47440 spin_lock_init(&md->uevent_lock);
47441@@ -2481,7 +2481,7 @@ static void event_callback(void *context)
47442
47443 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
47444
47445- atomic_inc(&md->event_nr);
47446+ atomic_inc_unchecked(&md->event_nr);
47447 wake_up(&md->eventq);
47448 }
47449
47450@@ -3479,18 +3479,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
47451
47452 uint32_t dm_next_uevent_seq(struct mapped_device *md)
47453 {
47454- return atomic_add_return(1, &md->uevent_seq);
47455+ return atomic_add_return_unchecked(1, &md->uevent_seq);
47456 }
47457
47458 uint32_t dm_get_event_nr(struct mapped_device *md)
47459 {
47460- return atomic_read(&md->event_nr);
47461+ return atomic_read_unchecked(&md->event_nr);
47462 }
47463
47464 int dm_wait_event(struct mapped_device *md, int event_nr)
47465 {
47466 return wait_event_interruptible(md->eventq,
47467- (event_nr != atomic_read(&md->event_nr)));
47468+ (event_nr != atomic_read_unchecked(&md->event_nr)));
47469 }
47470
47471 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
47472diff --git a/drivers/md/md.c b/drivers/md/md.c
47473index e25f00f..12caa60 100644
47474--- a/drivers/md/md.c
47475+++ b/drivers/md/md.c
47476@@ -197,10 +197,10 @@ EXPORT_SYMBOL_GPL(bio_clone_mddev);
47477 * start build, activate spare
47478 */
47479 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
47480-static atomic_t md_event_count;
47481+static atomic_unchecked_t md_event_count;
47482 void md_new_event(struct mddev *mddev)
47483 {
47484- atomic_inc(&md_event_count);
47485+ atomic_inc_unchecked(&md_event_count);
47486 wake_up(&md_event_waiters);
47487 }
47488 EXPORT_SYMBOL_GPL(md_new_event);
47489@@ -210,7 +210,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
47490 */
47491 static void md_new_event_inintr(struct mddev *mddev)
47492 {
47493- atomic_inc(&md_event_count);
47494+ atomic_inc_unchecked(&md_event_count);
47495 wake_up(&md_event_waiters);
47496 }
47497
47498@@ -1449,7 +1449,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
47499 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
47500 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
47501 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
47502- atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
47503+ atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
47504
47505 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
47506 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
47507@@ -1700,7 +1700,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
47508 else
47509 sb->resync_offset = cpu_to_le64(0);
47510
47511- sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
47512+ sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
47513
47514 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
47515 sb->size = cpu_to_le64(mddev->dev_sectors);
47516@@ -2622,7 +2622,7 @@ __ATTR_PREALLOC(state, S_IRUGO|S_IWUSR, state_show, state_store);
47517 static ssize_t
47518 errors_show(struct md_rdev *rdev, char *page)
47519 {
47520- return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
47521+ return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
47522 }
47523
47524 static ssize_t
47525@@ -2634,7 +2634,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
47526 rv = kstrtouint(buf, 10, &n);
47527 if (rv < 0)
47528 return rv;
47529- atomic_set(&rdev->corrected_errors, n);
47530+ atomic_set_unchecked(&rdev->corrected_errors, n);
47531 return len;
47532 }
47533 static struct rdev_sysfs_entry rdev_errors =
47534@@ -3071,8 +3071,8 @@ int md_rdev_init(struct md_rdev *rdev)
47535 rdev->sb_loaded = 0;
47536 rdev->bb_page = NULL;
47537 atomic_set(&rdev->nr_pending, 0);
47538- atomic_set(&rdev->read_errors, 0);
47539- atomic_set(&rdev->corrected_errors, 0);
47540+ atomic_set_unchecked(&rdev->read_errors, 0);
47541+ atomic_set_unchecked(&rdev->corrected_errors, 0);
47542
47543 INIT_LIST_HEAD(&rdev->same_set);
47544 init_waitqueue_head(&rdev->blocked_wait);
47545@@ -7256,7 +7256,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
47546
47547 spin_unlock(&pers_lock);
47548 seq_printf(seq, "\n");
47549- seq->poll_event = atomic_read(&md_event_count);
47550+ seq->poll_event = atomic_read_unchecked(&md_event_count);
47551 return 0;
47552 }
47553 if (v == (void*)2) {
47554@@ -7359,7 +7359,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
47555 return error;
47556
47557 seq = file->private_data;
47558- seq->poll_event = atomic_read(&md_event_count);
47559+ seq->poll_event = atomic_read_unchecked(&md_event_count);
47560 return error;
47561 }
47562
47563@@ -7376,7 +7376,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
47564 /* always allow read */
47565 mask = POLLIN | POLLRDNORM;
47566
47567- if (seq->poll_event != atomic_read(&md_event_count))
47568+ if (seq->poll_event != atomic_read_unchecked(&md_event_count))
47569 mask |= POLLERR | POLLPRI;
47570 return mask;
47571 }
47572@@ -7472,7 +7472,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
47573 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
47574 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
47575 (int)part_stat_read(&disk->part0, sectors[1]) -
47576- atomic_read(&disk->sync_io);
47577+ atomic_read_unchecked(&disk->sync_io);
47578 /* sync IO will cause sync_io to increase before the disk_stats
47579 * as sync_io is counted when a request starts, and
47580 * disk_stats is counted when it completes.
47581diff --git a/drivers/md/md.h b/drivers/md/md.h
47582index 7da6e9c..f0c1f10 100644
47583--- a/drivers/md/md.h
47584+++ b/drivers/md/md.h
47585@@ -96,13 +96,13 @@ struct md_rdev {
47586 * only maintained for arrays that
47587 * support hot removal
47588 */
47589- atomic_t read_errors; /* number of consecutive read errors that
47590+ atomic_unchecked_t read_errors; /* number of consecutive read errors that
47591 * we have tried to ignore.
47592 */
47593 struct timespec last_read_error; /* monotonic time since our
47594 * last read error
47595 */
47596- atomic_t corrected_errors; /* number of corrected read errors,
47597+ atomic_unchecked_t corrected_errors; /* number of corrected read errors,
47598 * for reporting to userspace and storing
47599 * in superblock.
47600 */
47601@@ -487,7 +487,7 @@ extern void mddev_unlock(struct mddev *mddev);
47602
47603 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
47604 {
47605- atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
47606+ atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
47607 }
47608
47609 struct md_personality
47610diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
47611index 5309129..7fb096e 100644
47612--- a/drivers/md/persistent-data/dm-space-map-metadata.c
47613+++ b/drivers/md/persistent-data/dm-space-map-metadata.c
47614@@ -691,7 +691,7 @@ static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
47615 * Flick into a mode where all blocks get allocated in the new area.
47616 */
47617 smm->begin = old_len;
47618- memcpy(sm, &bootstrap_ops, sizeof(*sm));
47619+ memcpy((void *)sm, &bootstrap_ops, sizeof(*sm));
47620
47621 /*
47622 * Extend.
47623@@ -728,7 +728,7 @@ out:
47624 /*
47625 * Switch back to normal behaviour.
47626 */
47627- memcpy(sm, &ops, sizeof(*sm));
47628+ memcpy((void *)sm, &ops, sizeof(*sm));
47629 return r;
47630 }
47631
47632diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
47633index 3e6d115..ffecdeb 100644
47634--- a/drivers/md/persistent-data/dm-space-map.h
47635+++ b/drivers/md/persistent-data/dm-space-map.h
47636@@ -71,6 +71,7 @@ struct dm_space_map {
47637 dm_sm_threshold_fn fn,
47638 void *context);
47639 };
47640+typedef struct dm_space_map __no_const dm_space_map_no_const;
47641
47642 /*----------------------------------------------------------------*/
47643
47644diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
47645index 967a4ed..002d339 100644
47646--- a/drivers/md/raid1.c
47647+++ b/drivers/md/raid1.c
47648@@ -1937,7 +1937,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
47649 if (r1_sync_page_io(rdev, sect, s,
47650 bio->bi_io_vec[idx].bv_page,
47651 READ) != 0)
47652- atomic_add(s, &rdev->corrected_errors);
47653+ atomic_add_unchecked(s, &rdev->corrected_errors);
47654 }
47655 sectors -= s;
47656 sect += s;
47657@@ -2170,7 +2170,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
47658 !test_bit(Faulty, &rdev->flags)) {
47659 if (r1_sync_page_io(rdev, sect, s,
47660 conf->tmppage, READ)) {
47661- atomic_add(s, &rdev->corrected_errors);
47662+ atomic_add_unchecked(s, &rdev->corrected_errors);
47663 printk(KERN_INFO
47664 "md/raid1:%s: read error corrected "
47665 "(%d sectors at %llu on %s)\n",
47666diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
47667index 38c58e1..89c3e0f 100644
47668--- a/drivers/md/raid10.c
47669+++ b/drivers/md/raid10.c
47670@@ -1934,7 +1934,7 @@ static void end_sync_read(struct bio *bio, int error)
47671 /* The write handler will notice the lack of
47672 * R10BIO_Uptodate and record any errors etc
47673 */
47674- atomic_add(r10_bio->sectors,
47675+ atomic_add_unchecked(r10_bio->sectors,
47676 &conf->mirrors[d].rdev->corrected_errors);
47677
47678 /* for reconstruct, we always reschedule after a read.
47679@@ -2281,7 +2281,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
47680 {
47681 struct timespec cur_time_mon;
47682 unsigned long hours_since_last;
47683- unsigned int read_errors = atomic_read(&rdev->read_errors);
47684+ unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
47685
47686 ktime_get_ts(&cur_time_mon);
47687
47688@@ -2303,9 +2303,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
47689 * overflowing the shift of read_errors by hours_since_last.
47690 */
47691 if (hours_since_last >= 8 * sizeof(read_errors))
47692- atomic_set(&rdev->read_errors, 0);
47693+ atomic_set_unchecked(&rdev->read_errors, 0);
47694 else
47695- atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
47696+ atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
47697 }
47698
47699 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
47700@@ -2359,8 +2359,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
47701 return;
47702
47703 check_decay_read_errors(mddev, rdev);
47704- atomic_inc(&rdev->read_errors);
47705- if (atomic_read(&rdev->read_errors) > max_read_errors) {
47706+ atomic_inc_unchecked(&rdev->read_errors);
47707+ if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
47708 char b[BDEVNAME_SIZE];
47709 bdevname(rdev->bdev, b);
47710
47711@@ -2368,7 +2368,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
47712 "md/raid10:%s: %s: Raid device exceeded "
47713 "read_error threshold [cur %d:max %d]\n",
47714 mdname(mddev), b,
47715- atomic_read(&rdev->read_errors), max_read_errors);
47716+ atomic_read_unchecked(&rdev->read_errors), max_read_errors);
47717 printk(KERN_NOTICE
47718 "md/raid10:%s: %s: Failing raid device\n",
47719 mdname(mddev), b);
47720@@ -2523,7 +2523,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
47721 sect +
47722 choose_data_offset(r10_bio, rdev)),
47723 bdevname(rdev->bdev, b));
47724- atomic_add(s, &rdev->corrected_errors);
47725+ atomic_add_unchecked(s, &rdev->corrected_errors);
47726 }
47727
47728 rdev_dec_pending(rdev, mddev);
47729diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
47730index f757023..f958632 100644
47731--- a/drivers/md/raid5.c
47732+++ b/drivers/md/raid5.c
47733@@ -1119,23 +1119,23 @@ async_copy_data(int frombio, struct bio *bio, struct page **page,
47734 struct bio_vec bvl;
47735 struct bvec_iter iter;
47736 struct page *bio_page;
47737- int page_offset;
47738+ s64 page_offset;
47739 struct async_submit_ctl submit;
47740 enum async_tx_flags flags = 0;
47741
47742 if (bio->bi_iter.bi_sector >= sector)
47743- page_offset = (signed)(bio->bi_iter.bi_sector - sector) * 512;
47744+ page_offset = (s64)(bio->bi_iter.bi_sector - sector) * 512;
47745 else
47746- page_offset = (signed)(sector - bio->bi_iter.bi_sector) * -512;
47747+ page_offset = (s64)(sector - bio->bi_iter.bi_sector) * -512;
47748
47749 if (frombio)
47750 flags |= ASYNC_TX_FENCE;
47751 init_async_submit(&submit, flags, tx, NULL, NULL, NULL);
47752
47753 bio_for_each_segment(bvl, bio, iter) {
47754- int len = bvl.bv_len;
47755- int clen;
47756- int b_offset = 0;
47757+ s64 len = bvl.bv_len;
47758+ s64 clen;
47759+ s64 b_offset = 0;
47760
47761 if (page_offset < 0) {
47762 b_offset = -page_offset;
47763@@ -2028,6 +2028,10 @@ static int grow_one_stripe(struct r5conf *conf, gfp_t gfp)
47764 return 1;
47765 }
47766
47767+#ifdef CONFIG_GRKERNSEC_HIDESYM
47768+static atomic_unchecked_t raid5_cache_id = ATOMIC_INIT(0);
47769+#endif
47770+
47771 static int grow_stripes(struct r5conf *conf, int num)
47772 {
47773 struct kmem_cache *sc;
47774@@ -2038,7 +2042,11 @@ static int grow_stripes(struct r5conf *conf, int num)
47775 "raid%d-%s", conf->level, mdname(conf->mddev));
47776 else
47777 sprintf(conf->cache_name[0],
47778+#ifdef CONFIG_GRKERNSEC_HIDESYM
47779+ "raid%d-%08lx", conf->level, atomic_inc_return_unchecked(&raid5_cache_id));
47780+#else
47781 "raid%d-%p", conf->level, conf->mddev);
47782+#endif
47783 sprintf(conf->cache_name[1], "%s-alt", conf->cache_name[0]);
47784
47785 conf->active_name = 0;
47786@@ -2331,21 +2339,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
47787 mdname(conf->mddev), STRIPE_SECTORS,
47788 (unsigned long long)s,
47789 bdevname(rdev->bdev, b));
47790- atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
47791+ atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
47792 clear_bit(R5_ReadError, &sh->dev[i].flags);
47793 clear_bit(R5_ReWrite, &sh->dev[i].flags);
47794 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
47795 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
47796
47797- if (atomic_read(&rdev->read_errors))
47798- atomic_set(&rdev->read_errors, 0);
47799+ if (atomic_read_unchecked(&rdev->read_errors))
47800+ atomic_set_unchecked(&rdev->read_errors, 0);
47801 } else {
47802 const char *bdn = bdevname(rdev->bdev, b);
47803 int retry = 0;
47804 int set_bad = 0;
47805
47806 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
47807- atomic_inc(&rdev->read_errors);
47808+ atomic_inc_unchecked(&rdev->read_errors);
47809 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
47810 printk_ratelimited(
47811 KERN_WARNING
47812@@ -2373,7 +2381,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
47813 mdname(conf->mddev),
47814 (unsigned long long)s,
47815 bdn);
47816- } else if (atomic_read(&rdev->read_errors)
47817+ } else if (atomic_read_unchecked(&rdev->read_errors)
47818 > conf->max_nr_stripes)
47819 printk(KERN_WARNING
47820 "md/raid:%s: Too many read errors, failing device %s.\n",
47821diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
47822index 13bb57f..0ca21b2 100644
47823--- a/drivers/media/dvb-core/dvbdev.c
47824+++ b/drivers/media/dvb-core/dvbdev.c
47825@@ -272,7 +272,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
47826 const struct dvb_device *template, void *priv, int type)
47827 {
47828 struct dvb_device *dvbdev;
47829- struct file_operations *dvbdevfops;
47830+ file_operations_no_const *dvbdevfops;
47831 struct device *clsdev;
47832 int minor;
47833 int id;
47834diff --git a/drivers/media/dvb-frontends/af9033.h b/drivers/media/dvb-frontends/af9033.h
47835index 6ad22b6..6e90e2a 100644
47836--- a/drivers/media/dvb-frontends/af9033.h
47837+++ b/drivers/media/dvb-frontends/af9033.h
47838@@ -96,6 +96,6 @@ struct af9033_ops {
47839 int (*pid_filter_ctrl)(struct dvb_frontend *fe, int onoff);
47840 int (*pid_filter)(struct dvb_frontend *fe, int index, u16 pid,
47841 int onoff);
47842-};
47843+} __no_const;
47844
47845 #endif /* AF9033_H */
47846diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
47847index 6ae9899..07d8543 100644
47848--- a/drivers/media/dvb-frontends/dib3000.h
47849+++ b/drivers/media/dvb-frontends/dib3000.h
47850@@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
47851 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
47852 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
47853 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
47854-};
47855+} __no_const;
47856
47857 #if IS_REACHABLE(CONFIG_DVB_DIB3000MB)
47858 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
47859diff --git a/drivers/media/dvb-frontends/dib7000p.h b/drivers/media/dvb-frontends/dib7000p.h
47860index baa2789..c8de7fe 100644
47861--- a/drivers/media/dvb-frontends/dib7000p.h
47862+++ b/drivers/media/dvb-frontends/dib7000p.h
47863@@ -64,7 +64,7 @@ struct dib7000p_ops {
47864 int (*get_adc_power)(struct dvb_frontend *fe);
47865 int (*slave_reset)(struct dvb_frontend *fe);
47866 struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000p_config *cfg);
47867-};
47868+} __no_const;
47869
47870 #if IS_REACHABLE(CONFIG_DVB_DIB7000P)
47871 void *dib7000p_attach(struct dib7000p_ops *ops);
47872diff --git a/drivers/media/dvb-frontends/dib8000.h b/drivers/media/dvb-frontends/dib8000.h
47873index 2b8b4b1..8cef451 100644
47874--- a/drivers/media/dvb-frontends/dib8000.h
47875+++ b/drivers/media/dvb-frontends/dib8000.h
47876@@ -61,7 +61,7 @@ struct dib8000_ops {
47877 int (*pid_filter_ctrl)(struct dvb_frontend *fe, u8 onoff);
47878 int (*pid_filter)(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff);
47879 struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg);
47880-};
47881+} __no_const;
47882
47883 #if IS_REACHABLE(CONFIG_DVB_DIB8000)
47884 void *dib8000_attach(struct dib8000_ops *ops);
47885diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
47886index 400e5ca..f69f748 100644
47887--- a/drivers/media/pci/cx88/cx88-video.c
47888+++ b/drivers/media/pci/cx88/cx88-video.c
47889@@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
47890
47891 /* ------------------------------------------------------------------ */
47892
47893-static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47894-static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47895-static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47896+static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47897+static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47898+static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
47899
47900 module_param_array(video_nr, int, NULL, 0444);
47901 module_param_array(vbi_nr, int, NULL, 0444);
47902diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
47903index 8616fa8..e16eeaf 100644
47904--- a/drivers/media/pci/ivtv/ivtv-driver.c
47905+++ b/drivers/media/pci/ivtv/ivtv-driver.c
47906@@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
47907 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
47908
47909 /* ivtv instance counter */
47910-static atomic_t ivtv_instance = ATOMIC_INIT(0);
47911+static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
47912
47913 /* Parameter declarations */
47914 static int cardtype[IVTV_MAX_CARDS];
47915diff --git a/drivers/media/pci/solo6x10/solo6x10-core.c b/drivers/media/pci/solo6x10/solo6x10-core.c
47916index 570d119..ed25830 100644
47917--- a/drivers/media/pci/solo6x10/solo6x10-core.c
47918+++ b/drivers/media/pci/solo6x10/solo6x10-core.c
47919@@ -424,7 +424,7 @@ static void solo_device_release(struct device *dev)
47920
47921 static int solo_sysfs_init(struct solo_dev *solo_dev)
47922 {
47923- struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47924+ bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47925 struct device *dev = &solo_dev->dev;
47926 const char *driver;
47927 int i;
47928diff --git a/drivers/media/pci/solo6x10/solo6x10-g723.c b/drivers/media/pci/solo6x10/solo6x10-g723.c
47929index 7ddc767..1c24361 100644
47930--- a/drivers/media/pci/solo6x10/solo6x10-g723.c
47931+++ b/drivers/media/pci/solo6x10/solo6x10-g723.c
47932@@ -351,7 +351,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
47933
47934 int solo_g723_init(struct solo_dev *solo_dev)
47935 {
47936- static struct snd_device_ops ops = { NULL };
47937+ static struct snd_device_ops ops = { };
47938 struct snd_card *card;
47939 struct snd_kcontrol_new kctl;
47940 char name[32];
47941diff --git a/drivers/media/pci/solo6x10/solo6x10-p2m.c b/drivers/media/pci/solo6x10/solo6x10-p2m.c
47942index 8c84846..27b4f83 100644
47943--- a/drivers/media/pci/solo6x10/solo6x10-p2m.c
47944+++ b/drivers/media/pci/solo6x10/solo6x10-p2m.c
47945@@ -73,7 +73,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47946
47947 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47948 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47949- p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47950+ p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47951 if (p2m_id < 0)
47952 p2m_id = -p2m_id;
47953 }
47954diff --git a/drivers/media/pci/solo6x10/solo6x10.h b/drivers/media/pci/solo6x10/solo6x10.h
47955index 1ca54b0..7d7cb9a 100644
47956--- a/drivers/media/pci/solo6x10/solo6x10.h
47957+++ b/drivers/media/pci/solo6x10/solo6x10.h
47958@@ -218,7 +218,7 @@ struct solo_dev {
47959
47960 /* P2M DMA Engine */
47961 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47962- atomic_t p2m_count;
47963+ atomic_unchecked_t p2m_count;
47964 int p2m_jiffies;
47965 unsigned int p2m_timeouts;
47966
47967diff --git a/drivers/media/pci/tw68/tw68-core.c b/drivers/media/pci/tw68/tw68-core.c
47968index c135165..dc69499 100644
47969--- a/drivers/media/pci/tw68/tw68-core.c
47970+++ b/drivers/media/pci/tw68/tw68-core.c
47971@@ -60,7 +60,7 @@ static unsigned int card[] = {[0 ... (TW68_MAXBOARDS - 1)] = UNSET };
47972 module_param_array(card, int, NULL, 0444);
47973 MODULE_PARM_DESC(card, "card type");
47974
47975-static atomic_t tw68_instance = ATOMIC_INIT(0);
47976+static atomic_unchecked_t tw68_instance = ATOMIC_INIT(0);
47977
47978 /* ------------------------------------------------------------------ */
47979
47980diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
47981index f09c5f1..38f6d65 100644
47982--- a/drivers/media/platform/omap/omap_vout.c
47983+++ b/drivers/media/platform/omap/omap_vout.c
47984@@ -63,7 +63,6 @@ enum omap_vout_channels {
47985 OMAP_VIDEO2,
47986 };
47987
47988-static struct videobuf_queue_ops video_vbq_ops;
47989 /* Variables configurable through module params*/
47990 static u32 video1_numbuffers = 3;
47991 static u32 video2_numbuffers = 3;
47992@@ -1008,6 +1007,12 @@ static int omap_vout_open(struct file *file)
47993 {
47994 struct videobuf_queue *q;
47995 struct omap_vout_device *vout = NULL;
47996+ static struct videobuf_queue_ops video_vbq_ops = {
47997+ .buf_setup = omap_vout_buffer_setup,
47998+ .buf_prepare = omap_vout_buffer_prepare,
47999+ .buf_release = omap_vout_buffer_release,
48000+ .buf_queue = omap_vout_buffer_queue,
48001+ };
48002
48003 vout = video_drvdata(file);
48004 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
48005@@ -1025,10 +1030,6 @@ static int omap_vout_open(struct file *file)
48006 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
48007
48008 q = &vout->vbq;
48009- video_vbq_ops.buf_setup = omap_vout_buffer_setup;
48010- video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
48011- video_vbq_ops.buf_release = omap_vout_buffer_release;
48012- video_vbq_ops.buf_queue = omap_vout_buffer_queue;
48013 spin_lock_init(&vout->vbq_lock);
48014
48015 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
48016diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
48017index fb2acc5..a2fcbdc4 100644
48018--- a/drivers/media/platform/s5p-tv/mixer.h
48019+++ b/drivers/media/platform/s5p-tv/mixer.h
48020@@ -156,7 +156,7 @@ struct mxr_layer {
48021 /** layer index (unique identifier) */
48022 int idx;
48023 /** callbacks for layer methods */
48024- struct mxr_layer_ops ops;
48025+ struct mxr_layer_ops *ops;
48026 /** format array */
48027 const struct mxr_format **fmt_array;
48028 /** size of format array */
48029diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
48030index 74344c7..a39e70e 100644
48031--- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
48032+++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
48033@@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
48034 {
48035 struct mxr_layer *layer;
48036 int ret;
48037- struct mxr_layer_ops ops = {
48038+ static struct mxr_layer_ops ops = {
48039 .release = mxr_graph_layer_release,
48040 .buffer_set = mxr_graph_buffer_set,
48041 .stream_set = mxr_graph_stream_set,
48042diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
48043index b713403..53cb5ad 100644
48044--- a/drivers/media/platform/s5p-tv/mixer_reg.c
48045+++ b/drivers/media/platform/s5p-tv/mixer_reg.c
48046@@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
48047 layer->update_buf = next;
48048 }
48049
48050- layer->ops.buffer_set(layer, layer->update_buf);
48051+ layer->ops->buffer_set(layer, layer->update_buf);
48052
48053 if (done && done != layer->shadow_buf)
48054 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
48055diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
48056index 751f3b6..d829203 100644
48057--- a/drivers/media/platform/s5p-tv/mixer_video.c
48058+++ b/drivers/media/platform/s5p-tv/mixer_video.c
48059@@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
48060 layer->geo.src.height = layer->geo.src.full_height;
48061
48062 mxr_geometry_dump(mdev, &layer->geo);
48063- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
48064+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
48065 mxr_geometry_dump(mdev, &layer->geo);
48066 }
48067
48068@@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
48069 layer->geo.dst.full_width = mbus_fmt.width;
48070 layer->geo.dst.full_height = mbus_fmt.height;
48071 layer->geo.dst.field = mbus_fmt.field;
48072- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
48073+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
48074
48075 mxr_geometry_dump(mdev, &layer->geo);
48076 }
48077@@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
48078 /* set source size to highest accepted value */
48079 geo->src.full_width = max(geo->dst.full_width, pix->width);
48080 geo->src.full_height = max(geo->dst.full_height, pix->height);
48081- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
48082+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
48083 mxr_geometry_dump(mdev, &layer->geo);
48084 /* set cropping to total visible screen */
48085 geo->src.width = pix->width;
48086@@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
48087 geo->src.x_offset = 0;
48088 geo->src.y_offset = 0;
48089 /* assure consistency of geometry */
48090- layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
48091+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
48092 mxr_geometry_dump(mdev, &layer->geo);
48093 /* set full size to lowest possible value */
48094 geo->src.full_width = 0;
48095 geo->src.full_height = 0;
48096- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
48097+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
48098 mxr_geometry_dump(mdev, &layer->geo);
48099
48100 /* returning results */
48101@@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
48102 target->width = s->r.width;
48103 target->height = s->r.height;
48104
48105- layer->ops.fix_geometry(layer, stage, s->flags);
48106+ layer->ops->fix_geometry(layer, stage, s->flags);
48107
48108 /* retrieve update selection rectangle */
48109 res.left = target->x_offset;
48110@@ -938,13 +938,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
48111 mxr_output_get(mdev);
48112
48113 mxr_layer_update_output(layer);
48114- layer->ops.format_set(layer);
48115+ layer->ops->format_set(layer);
48116 /* enabling layer in hardware */
48117 spin_lock_irqsave(&layer->enq_slock, flags);
48118 layer->state = MXR_LAYER_STREAMING;
48119 spin_unlock_irqrestore(&layer->enq_slock, flags);
48120
48121- layer->ops.stream_set(layer, MXR_ENABLE);
48122+ layer->ops->stream_set(layer, MXR_ENABLE);
48123 mxr_streamer_get(mdev);
48124
48125 return 0;
48126@@ -1014,7 +1014,7 @@ static void stop_streaming(struct vb2_queue *vq)
48127 spin_unlock_irqrestore(&layer->enq_slock, flags);
48128
48129 /* disabling layer in hardware */
48130- layer->ops.stream_set(layer, MXR_DISABLE);
48131+ layer->ops->stream_set(layer, MXR_DISABLE);
48132 /* remove one streamer */
48133 mxr_streamer_put(mdev);
48134 /* allow changes in output configuration */
48135@@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
48136
48137 void mxr_layer_release(struct mxr_layer *layer)
48138 {
48139- if (layer->ops.release)
48140- layer->ops.release(layer);
48141+ if (layer->ops->release)
48142+ layer->ops->release(layer);
48143 }
48144
48145 void mxr_base_layer_release(struct mxr_layer *layer)
48146@@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
48147
48148 layer->mdev = mdev;
48149 layer->idx = idx;
48150- layer->ops = *ops;
48151+ layer->ops = ops;
48152
48153 spin_lock_init(&layer->enq_slock);
48154 INIT_LIST_HEAD(&layer->enq_list);
48155diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
48156index c9388c4..ce71ece 100644
48157--- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
48158+++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
48159@@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
48160 {
48161 struct mxr_layer *layer;
48162 int ret;
48163- struct mxr_layer_ops ops = {
48164+ static struct mxr_layer_ops ops = {
48165 .release = mxr_vp_layer_release,
48166 .buffer_set = mxr_vp_buffer_set,
48167 .stream_set = mxr_vp_stream_set,
48168diff --git a/drivers/media/platform/vivid/vivid-osd.c b/drivers/media/platform/vivid/vivid-osd.c
48169index 084d346..e15eef6 100644
48170--- a/drivers/media/platform/vivid/vivid-osd.c
48171+++ b/drivers/media/platform/vivid/vivid-osd.c
48172@@ -85,6 +85,7 @@ static int vivid_fb_ioctl(struct fb_info *info, unsigned cmd, unsigned long arg)
48173 case FBIOGET_VBLANK: {
48174 struct fb_vblank vblank;
48175
48176+ memset(&vblank, 0, sizeof(vblank));
48177 vblank.flags = FB_VBLANK_HAVE_COUNT | FB_VBLANK_HAVE_VCOUNT |
48178 FB_VBLANK_HAVE_VSYNC;
48179 vblank.count = 0;
48180diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
48181index 82affae..42833ec 100644
48182--- a/drivers/media/radio/radio-cadet.c
48183+++ b/drivers/media/radio/radio-cadet.c
48184@@ -333,6 +333,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
48185 unsigned char readbuf[RDS_BUFFER];
48186 int i = 0;
48187
48188+ if (count > RDS_BUFFER)
48189+ return -EFAULT;
48190 mutex_lock(&dev->lock);
48191 if (dev->rdsstat == 0)
48192 cadet_start_rds(dev);
48193@@ -349,8 +351,9 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
48194 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
48195 mutex_unlock(&dev->lock);
48196
48197- if (i && copy_to_user(data, readbuf, i))
48198- return -EFAULT;
48199+ if (i > sizeof(readbuf) || (i && copy_to_user(data, readbuf, i)))
48200+ i = -EFAULT;
48201+
48202 return i;
48203 }
48204
48205diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
48206index 5236035..c622c74 100644
48207--- a/drivers/media/radio/radio-maxiradio.c
48208+++ b/drivers/media/radio/radio-maxiradio.c
48209@@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
48210 /* TEA5757 pin mappings */
48211 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
48212
48213-static atomic_t maxiradio_instance = ATOMIC_INIT(0);
48214+static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
48215
48216 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
48217 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
48218diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
48219index 050b3bb..79f62b9 100644
48220--- a/drivers/media/radio/radio-shark.c
48221+++ b/drivers/media/radio/radio-shark.c
48222@@ -79,7 +79,7 @@ struct shark_device {
48223 u32 last_val;
48224 };
48225
48226-static atomic_t shark_instance = ATOMIC_INIT(0);
48227+static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
48228
48229 static void shark_write_val(struct snd_tea575x *tea, u32 val)
48230 {
48231diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
48232index 8654e0d..0608a64 100644
48233--- a/drivers/media/radio/radio-shark2.c
48234+++ b/drivers/media/radio/radio-shark2.c
48235@@ -74,7 +74,7 @@ struct shark_device {
48236 u8 *transfer_buffer;
48237 };
48238
48239-static atomic_t shark_instance = ATOMIC_INIT(0);
48240+static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
48241
48242 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
48243 {
48244diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
48245index 9cbb8cd..2bf2ff3 100644
48246--- a/drivers/media/radio/radio-si476x.c
48247+++ b/drivers/media/radio/radio-si476x.c
48248@@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
48249 struct si476x_radio *radio;
48250 struct v4l2_ctrl *ctrl;
48251
48252- static atomic_t instance = ATOMIC_INIT(0);
48253+ static atomic_unchecked_t instance = ATOMIC_INIT(0);
48254
48255 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
48256 if (!radio)
48257diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
48258index 704397f..4d05977 100644
48259--- a/drivers/media/radio/wl128x/fmdrv_common.c
48260+++ b/drivers/media/radio/wl128x/fmdrv_common.c
48261@@ -71,7 +71,7 @@ module_param(default_rds_buf, uint, 0444);
48262 MODULE_PARM_DESC(rds_buf, "RDS buffer entries");
48263
48264 /* Radio Nr */
48265-static u32 radio_nr = -1;
48266+static int radio_nr = -1;
48267 module_param(radio_nr, int, 0444);
48268 MODULE_PARM_DESC(radio_nr, "Radio Nr");
48269
48270diff --git a/drivers/media/usb/dvb-usb/cinergyT2-core.c b/drivers/media/usb/dvb-usb/cinergyT2-core.c
48271index 9fd1527..8927230 100644
48272--- a/drivers/media/usb/dvb-usb/cinergyT2-core.c
48273+++ b/drivers/media/usb/dvb-usb/cinergyT2-core.c
48274@@ -50,29 +50,73 @@ static struct dvb_usb_device_properties cinergyt2_properties;
48275
48276 static int cinergyt2_streaming_ctrl(struct dvb_usb_adapter *adap, int enable)
48277 {
48278- char buf[] = { CINERGYT2_EP1_CONTROL_STREAM_TRANSFER, enable ? 1 : 0 };
48279- char result[64];
48280- return dvb_usb_generic_rw(adap->dev, buf, sizeof(buf), result,
48281- sizeof(result), 0);
48282+ char *buf;
48283+ char *result;
48284+ int retval;
48285+
48286+ buf = kmalloc(2, GFP_KERNEL);
48287+ if (buf == NULL)
48288+ return -ENOMEM;
48289+ result = kmalloc(64, GFP_KERNEL);
48290+ if (result == NULL) {
48291+ kfree(buf);
48292+ return -ENOMEM;
48293+ }
48294+
48295+ buf[0] = CINERGYT2_EP1_CONTROL_STREAM_TRANSFER;
48296+ buf[1] = enable ? 1 : 0;
48297+
48298+ retval = dvb_usb_generic_rw(adap->dev, buf, 2, result, 64, 0);
48299+
48300+ kfree(buf);
48301+ kfree(result);
48302+ return retval;
48303 }
48304
48305 static int cinergyt2_power_ctrl(struct dvb_usb_device *d, int enable)
48306 {
48307- char buf[] = { CINERGYT2_EP1_SLEEP_MODE, enable ? 0 : 1 };
48308- char state[3];
48309- return dvb_usb_generic_rw(d, buf, sizeof(buf), state, sizeof(state), 0);
48310+ char *buf;
48311+ char *state;
48312+ int retval;
48313+
48314+ buf = kmalloc(2, GFP_KERNEL);
48315+ if (buf == NULL)
48316+ return -ENOMEM;
48317+ state = kmalloc(3, GFP_KERNEL);
48318+ if (state == NULL) {
48319+ kfree(buf);
48320+ return -ENOMEM;
48321+ }
48322+
48323+ buf[0] = CINERGYT2_EP1_SLEEP_MODE;
48324+ buf[1] = enable ? 1 : 0;
48325+
48326+ retval = dvb_usb_generic_rw(d, buf, 2, state, 3, 0);
48327+
48328+ kfree(buf);
48329+ kfree(state);
48330+ return retval;
48331 }
48332
48333 static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
48334 {
48335- char query[] = { CINERGYT2_EP1_GET_FIRMWARE_VERSION };
48336- char state[3];
48337+ char *query;
48338+ char *state;
48339 int ret;
48340+ query = kmalloc(1, GFP_KERNEL);
48341+ if (query == NULL)
48342+ return -ENOMEM;
48343+ state = kmalloc(3, GFP_KERNEL);
48344+ if (state == NULL) {
48345+ kfree(query);
48346+ return -ENOMEM;
48347+ }
48348+
48349+ query[0] = CINERGYT2_EP1_GET_FIRMWARE_VERSION;
48350
48351 adap->fe_adap[0].fe = cinergyt2_fe_attach(adap->dev);
48352
48353- ret = dvb_usb_generic_rw(adap->dev, query, sizeof(query), state,
48354- sizeof(state), 0);
48355+ ret = dvb_usb_generic_rw(adap->dev, query, 1, state, 3, 0);
48356 if (ret < 0) {
48357 deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep "
48358 "state info\n");
48359@@ -80,7 +124,8 @@ static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
48360
48361 /* Copy this pointer as we are gonna need it in the release phase */
48362 cinergyt2_usb_device = adap->dev;
48363-
48364+ kfree(query);
48365+ kfree(state);
48366 return 0;
48367 }
48368
48369@@ -141,12 +186,23 @@ static int repeatable_keys[] = {
48370 static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
48371 {
48372 struct cinergyt2_state *st = d->priv;
48373- u8 key[5] = {0, 0, 0, 0, 0}, cmd = CINERGYT2_EP1_GET_RC_EVENTS;
48374+ u8 *key, *cmd;
48375 int i;
48376
48377+ cmd = kmalloc(1, GFP_KERNEL);
48378+ if (cmd == NULL)
48379+ return -EINVAL;
48380+ key = kzalloc(5, GFP_KERNEL);
48381+ if (key == NULL) {
48382+ kfree(cmd);
48383+ return -EINVAL;
48384+ }
48385+
48386+ cmd[0] = CINERGYT2_EP1_GET_RC_EVENTS;
48387+
48388 *state = REMOTE_NO_KEY_PRESSED;
48389
48390- dvb_usb_generic_rw(d, &cmd, 1, key, sizeof(key), 0);
48391+ dvb_usb_generic_rw(d, cmd, 1, key, 5, 0);
48392 if (key[4] == 0xff) {
48393 /* key repeat */
48394 st->rc_counter++;
48395@@ -157,12 +213,12 @@ static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
48396 *event = d->last_event;
48397 deb_rc("repeat key, event %x\n",
48398 *event);
48399- return 0;
48400+ goto out;
48401 }
48402 }
48403 deb_rc("repeated key (non repeatable)\n");
48404 }
48405- return 0;
48406+ goto out;
48407 }
48408
48409 /* hack to pass checksum on the custom field */
48410@@ -174,6 +230,9 @@ static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
48411
48412 deb_rc("key: %*ph\n", 5, key);
48413 }
48414+out:
48415+ kfree(cmd);
48416+ kfree(key);
48417 return 0;
48418 }
48419
48420diff --git a/drivers/media/usb/dvb-usb/cinergyT2-fe.c b/drivers/media/usb/dvb-usb/cinergyT2-fe.c
48421index b3ec743..9c0e418 100644
48422--- a/drivers/media/usb/dvb-usb/cinergyT2-fe.c
48423+++ b/drivers/media/usb/dvb-usb/cinergyT2-fe.c
48424@@ -145,103 +145,176 @@ static int cinergyt2_fe_read_status(struct dvb_frontend *fe,
48425 enum fe_status *status)
48426 {
48427 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48428- struct dvbt_get_status_msg result;
48429- u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48430+ struct dvbt_get_status_msg *result;
48431+ u8 *cmd;
48432 int ret;
48433
48434- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&result,
48435- sizeof(result), 0);
48436+ cmd = kmalloc(1, GFP_KERNEL);
48437+ if (cmd == NULL)
48438+ return -ENOMEM;
48439+ result = kmalloc(sizeof(*result), GFP_KERNEL);
48440+ if (result == NULL) {
48441+ kfree(cmd);
48442+ return -ENOMEM;
48443+ }
48444+
48445+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48446+
48447+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (u8 *)result,
48448+ sizeof(*result), 0);
48449 if (ret < 0)
48450- return ret;
48451+ goto out;
48452
48453 *status = 0;
48454
48455- if (0xffff - le16_to_cpu(result.gain) > 30)
48456+ if (0xffff - le16_to_cpu(result->gain) > 30)
48457 *status |= FE_HAS_SIGNAL;
48458- if (result.lock_bits & (1 << 6))
48459+ if (result->lock_bits & (1 << 6))
48460 *status |= FE_HAS_LOCK;
48461- if (result.lock_bits & (1 << 5))
48462+ if (result->lock_bits & (1 << 5))
48463 *status |= FE_HAS_SYNC;
48464- if (result.lock_bits & (1 << 4))
48465+ if (result->lock_bits & (1 << 4))
48466 *status |= FE_HAS_CARRIER;
48467- if (result.lock_bits & (1 << 1))
48468+ if (result->lock_bits & (1 << 1))
48469 *status |= FE_HAS_VITERBI;
48470
48471 if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
48472 (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
48473 *status &= ~FE_HAS_LOCK;
48474
48475- return 0;
48476+out:
48477+ kfree(cmd);
48478+ kfree(result);
48479+ return ret;
48480 }
48481
48482 static int cinergyt2_fe_read_ber(struct dvb_frontend *fe, u32 *ber)
48483 {
48484 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48485- struct dvbt_get_status_msg status;
48486- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48487+ struct dvbt_get_status_msg *status;
48488+ char *cmd;
48489 int ret;
48490
48491- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
48492- sizeof(status), 0);
48493+ cmd = kmalloc(1, GFP_KERNEL);
48494+ if (cmd == NULL)
48495+ return -ENOMEM;
48496+ status = kmalloc(sizeof(*status), GFP_KERNEL);
48497+ if (status == NULL) {
48498+ kfree(cmd);
48499+ return -ENOMEM;
48500+ }
48501+
48502+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48503+
48504+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status,
48505+ sizeof(*status), 0);
48506 if (ret < 0)
48507- return ret;
48508+ goto out;
48509
48510- *ber = le32_to_cpu(status.viterbi_error_rate);
48511+ *ber = le32_to_cpu(status->viterbi_error_rate);
48512+out:
48513+ kfree(cmd);
48514+ kfree(status);
48515 return 0;
48516 }
48517
48518 static int cinergyt2_fe_read_unc_blocks(struct dvb_frontend *fe, u32 *unc)
48519 {
48520 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48521- struct dvbt_get_status_msg status;
48522- u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48523+ struct dvbt_get_status_msg *status;
48524+ u8 *cmd;
48525 int ret;
48526
48527- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&status,
48528- sizeof(status), 0);
48529+ cmd = kmalloc(1, GFP_KERNEL);
48530+ if (cmd == NULL)
48531+ return -ENOMEM;
48532+ status = kmalloc(sizeof(*status), GFP_KERNEL);
48533+ if (status == NULL) {
48534+ kfree(cmd);
48535+ return -ENOMEM;
48536+ }
48537+
48538+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48539+
48540+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (u8 *)status,
48541+ sizeof(*status), 0);
48542 if (ret < 0) {
48543 err("cinergyt2_fe_read_unc_blocks() Failed! (Error=%d)\n",
48544 ret);
48545- return ret;
48546+ goto out;
48547 }
48548- *unc = le32_to_cpu(status.uncorrected_block_count);
48549- return 0;
48550+ *unc = le32_to_cpu(status->uncorrected_block_count);
48551+
48552+out:
48553+ kfree(cmd);
48554+ kfree(status);
48555+ return ret;
48556 }
48557
48558 static int cinergyt2_fe_read_signal_strength(struct dvb_frontend *fe,
48559 u16 *strength)
48560 {
48561 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48562- struct dvbt_get_status_msg status;
48563- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48564+ struct dvbt_get_status_msg *status;
48565+ char *cmd;
48566 int ret;
48567
48568- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
48569- sizeof(status), 0);
48570+ cmd = kmalloc(1, GFP_KERNEL);
48571+ if (cmd == NULL)
48572+ return -ENOMEM;
48573+ status = kmalloc(sizeof(*status), GFP_KERNEL);
48574+ if (status == NULL) {
48575+ kfree(cmd);
48576+ return -ENOMEM;
48577+ }
48578+
48579+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48580+
48581+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status,
48582+ sizeof(*status), 0);
48583 if (ret < 0) {
48584 err("cinergyt2_fe_read_signal_strength() Failed!"
48585 " (Error=%d)\n", ret);
48586- return ret;
48587+ goto out;
48588 }
48589- *strength = (0xffff - le16_to_cpu(status.gain));
48590+ *strength = (0xffff - le16_to_cpu(status->gain));
48591+
48592+out:
48593+ kfree(cmd);
48594+ kfree(status);
48595 return 0;
48596 }
48597
48598 static int cinergyt2_fe_read_snr(struct dvb_frontend *fe, u16 *snr)
48599 {
48600 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48601- struct dvbt_get_status_msg status;
48602- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
48603+ struct dvbt_get_status_msg *status;
48604+ char *cmd;
48605 int ret;
48606
48607- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
48608- sizeof(status), 0);
48609+ cmd = kmalloc(1, GFP_KERNEL);
48610+ if (cmd == NULL)
48611+ return -ENOMEM;
48612+ status = kmalloc(sizeof(*status), GFP_KERNEL);
48613+ if (status == NULL) {
48614+ kfree(cmd);
48615+ return -ENOMEM;
48616+ }
48617+
48618+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
48619+
48620+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status,
48621+ sizeof(*status), 0);
48622 if (ret < 0) {
48623 err("cinergyt2_fe_read_snr() Failed! (Error=%d)\n", ret);
48624- return ret;
48625+ goto out;
48626 }
48627- *snr = (status.snr << 8) | status.snr;
48628- return 0;
48629+ *snr = (status->snr << 8) | status->snr;
48630+
48631+out:
48632+ kfree(cmd);
48633+ kfree(status);
48634+ return ret;
48635 }
48636
48637 static int cinergyt2_fe_init(struct dvb_frontend *fe)
48638@@ -266,35 +339,46 @@ static int cinergyt2_fe_set_frontend(struct dvb_frontend *fe)
48639 {
48640 struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
48641 struct cinergyt2_fe_state *state = fe->demodulator_priv;
48642- struct dvbt_set_parameters_msg param;
48643- char result[2];
48644+ struct dvbt_set_parameters_msg *param;
48645+ char *result;
48646 int err;
48647
48648- param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
48649- param.tps = cpu_to_le16(compute_tps(fep));
48650- param.freq = cpu_to_le32(fep->frequency / 1000);
48651- param.flags = 0;
48652+ result = kmalloc(2, GFP_KERNEL);
48653+ if (result == NULL)
48654+ return -ENOMEM;
48655+ param = kmalloc(sizeof(*param), GFP_KERNEL);
48656+ if (param == NULL) {
48657+ kfree(result);
48658+ return -ENOMEM;
48659+ }
48660+
48661+ param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
48662+ param->tps = cpu_to_le16(compute_tps(fep));
48663+ param->freq = cpu_to_le32(fep->frequency / 1000);
48664+ param->flags = 0;
48665
48666 switch (fep->bandwidth_hz) {
48667 default:
48668 case 8000000:
48669- param.bandwidth = 8;
48670+ param->bandwidth = 8;
48671 break;
48672 case 7000000:
48673- param.bandwidth = 7;
48674+ param->bandwidth = 7;
48675 break;
48676 case 6000000:
48677- param.bandwidth = 6;
48678+ param->bandwidth = 6;
48679 break;
48680 }
48681
48682 err = dvb_usb_generic_rw(state->d,
48683- (char *)&param, sizeof(param),
48684- result, sizeof(result), 0);
48685+ (char *)param, sizeof(*param),
48686+ result, 2, 0);
48687 if (err < 0)
48688 err("cinergyt2_fe_set_frontend() Failed! err=%d\n", err);
48689
48690- return (err < 0) ? err : 0;
48691+ kfree(result);
48692+ kfree(param);
48693+ return err;
48694 }
48695
48696 static void cinergyt2_fe_release(struct dvb_frontend *fe)
48697diff --git a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
48698index 733a7ff..f8b52e3 100644
48699--- a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
48700+++ b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
48701@@ -35,42 +35,57 @@ static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 le
48702
48703 int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)
48704 {
48705- struct hexline hx;
48706- u8 reset;
48707+ struct hexline *hx;
48708+ u8 *reset;
48709 int ret,pos=0;
48710
48711+ reset = kmalloc(1, GFP_KERNEL);
48712+ if (reset == NULL)
48713+ return -ENOMEM;
48714+
48715+ hx = kmalloc(sizeof(struct hexline), GFP_KERNEL);
48716+ if (hx == NULL) {
48717+ kfree(reset);
48718+ return -ENOMEM;
48719+ }
48720+
48721 /* stop the CPU */
48722- reset = 1;
48723- if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1)
48724+ reset[0] = 1;
48725+ if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,reset,1)) != 1)
48726 err("could not stop the USB controller CPU.");
48727
48728- while ((ret = dvb_usb_get_hexline(fw,&hx,&pos)) > 0) {
48729- deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk);
48730- ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len);
48731+ while ((ret = dvb_usb_get_hexline(fw,hx,&pos)) > 0) {
48732+ deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx->addr,hx->len,hx->chk);
48733+ ret = usb_cypress_writemem(udev,hx->addr,hx->data,hx->len);
48734
48735- if (ret != hx.len) {
48736+ if (ret != hx->len) {
48737 err("error while transferring firmware "
48738 "(transferred size: %d, block size: %d)",
48739- ret,hx.len);
48740+ ret,hx->len);
48741 ret = -EINVAL;
48742 break;
48743 }
48744 }
48745 if (ret < 0) {
48746 err("firmware download failed at %d with %d",pos,ret);
48747+ kfree(reset);
48748+ kfree(hx);
48749 return ret;
48750 }
48751
48752 if (ret == 0) {
48753 /* restart the CPU */
48754- reset = 0;
48755- if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) {
48756+ reset[0] = 0;
48757+ if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,reset,1) != 1) {
48758 err("could not restart the USB controller CPU.");
48759 ret = -EINVAL;
48760 }
48761 } else
48762 ret = -EIO;
48763
48764+ kfree(reset);
48765+ kfree(hx);
48766+
48767 return ret;
48768 }
48769 EXPORT_SYMBOL(usb_cypress_load_firmware);
48770diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
48771index 03f334d..0986492 100644
48772--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
48773+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
48774@@ -87,8 +87,11 @@ struct technisat_usb2_state {
48775 static int technisat_usb2_i2c_access(struct usb_device *udev,
48776 u8 device_addr, u8 *tx, u8 txlen, u8 *rx, u8 rxlen)
48777 {
48778- u8 b[64];
48779- int ret, actual_length;
48780+ u8 *b = kmalloc(64, GFP_KERNEL);
48781+ int ret, actual_length, error = 0;
48782+
48783+ if (b == NULL)
48784+ return -ENOMEM;
48785
48786 deb_i2c("i2c-access: %02x, tx: ", device_addr);
48787 debug_dump(tx, txlen, deb_i2c);
48788@@ -121,7 +124,8 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
48789
48790 if (ret < 0) {
48791 err("i2c-error: out failed %02x = %d", device_addr, ret);
48792- return -ENODEV;
48793+ error = -ENODEV;
48794+ goto out;
48795 }
48796
48797 ret = usb_bulk_msg(udev,
48798@@ -129,7 +133,8 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
48799 b, 64, &actual_length, 1000);
48800 if (ret < 0) {
48801 err("i2c-error: in failed %02x = %d", device_addr, ret);
48802- return -ENODEV;
48803+ error = -ENODEV;
48804+ goto out;
48805 }
48806
48807 if (b[0] != I2C_STATUS_OK) {
48808@@ -137,8 +142,10 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
48809 /* handle tuner-i2c-nak */
48810 if (!(b[0] == I2C_STATUS_NAK &&
48811 device_addr == 0x60
48812- /* && device_is_technisat_usb2 */))
48813- return -ENODEV;
48814+ /* && device_is_technisat_usb2 */)) {
48815+ error = -ENODEV;
48816+ goto out;
48817+ }
48818 }
48819
48820 deb_i2c("status: %d, ", b[0]);
48821@@ -152,7 +159,9 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
48822
48823 deb_i2c("\n");
48824
48825- return 0;
48826+out:
48827+ kfree(b);
48828+ return error;
48829 }
48830
48831 static int technisat_usb2_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
48832@@ -224,14 +233,16 @@ static int technisat_usb2_set_led(struct dvb_usb_device *d, int red, enum techni
48833 {
48834 int ret;
48835
48836- u8 led[8] = {
48837- red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST,
48838- 0
48839- };
48840+ u8 *led = kzalloc(8, GFP_KERNEL);
48841+
48842+ if (led == NULL)
48843+ return -ENOMEM;
48844
48845 if (disable_led_control && state != TECH_LED_OFF)
48846 return 0;
48847
48848+ led[0] = red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST;
48849+
48850 switch (state) {
48851 case TECH_LED_ON:
48852 led[1] = 0x82;
48853@@ -263,16 +274,22 @@ static int technisat_usb2_set_led(struct dvb_usb_device *d, int red, enum techni
48854 red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST,
48855 USB_TYPE_VENDOR | USB_DIR_OUT,
48856 0, 0,
48857- led, sizeof(led), 500);
48858+ led, 8, 500);
48859
48860 mutex_unlock(&d->i2c_mutex);
48861+
48862+ kfree(led);
48863+
48864 return ret;
48865 }
48866
48867 static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 green)
48868 {
48869 int ret;
48870- u8 b = 0;
48871+ u8 *b = kzalloc(1, GFP_KERNEL);
48872+
48873+ if (b == NULL)
48874+ return -ENOMEM;
48875
48876 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
48877 return -EAGAIN;
48878@@ -281,10 +298,12 @@ static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 gre
48879 SET_LED_TIMER_DIVIDER_VENDOR_REQUEST,
48880 USB_TYPE_VENDOR | USB_DIR_OUT,
48881 (red << 8) | green, 0,
48882- &b, 1, 500);
48883+ b, 1, 500);
48884
48885 mutex_unlock(&d->i2c_mutex);
48886
48887+ kfree(b);
48888+
48889 return ret;
48890 }
48891
48892@@ -328,7 +347,7 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
48893 struct dvb_usb_device_description **desc, int *cold)
48894 {
48895 int ret;
48896- u8 version[3];
48897+ u8 *version = kmalloc(3, GFP_KERNEL);
48898
48899 /* first select the interface */
48900 if (usb_set_interface(udev, 0, 1) != 0)
48901@@ -338,11 +357,14 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
48902
48903 *cold = 0; /* by default do not download a firmware - just in case something is wrong */
48904
48905+ if (version == NULL)
48906+ return 0;
48907+
48908 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
48909 GET_VERSION_INFO_VENDOR_REQUEST,
48910 USB_TYPE_VENDOR | USB_DIR_IN,
48911 0, 0,
48912- version, sizeof(version), 500);
48913+ version, 3, 500);
48914
48915 if (ret < 0)
48916 *cold = 1;
48917@@ -351,6 +373,8 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
48918 *cold = 0;
48919 }
48920
48921+ kfree(version);
48922+
48923 return 0;
48924 }
48925
48926@@ -594,10 +618,15 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
48927
48928 static int technisat_usb2_get_ir(struct dvb_usb_device *d)
48929 {
48930- u8 buf[62], *b;
48931+ u8 *buf, *b;
48932 int ret;
48933 struct ir_raw_event ev;
48934
48935+ buf = kmalloc(62, GFP_KERNEL);
48936+
48937+ if (buf == NULL)
48938+ return -ENOMEM;
48939+
48940 buf[0] = GET_IR_DATA_VENDOR_REQUEST;
48941 buf[1] = 0x08;
48942 buf[2] = 0x8f;
48943@@ -620,16 +649,20 @@ static int technisat_usb2_get_ir(struct dvb_usb_device *d)
48944 GET_IR_DATA_VENDOR_REQUEST,
48945 USB_TYPE_VENDOR | USB_DIR_IN,
48946 0x8080, 0,
48947- buf, sizeof(buf), 500);
48948+ buf, 62, 500);
48949
48950 unlock:
48951 mutex_unlock(&d->i2c_mutex);
48952
48953- if (ret < 0)
48954+ if (ret < 0) {
48955+ kfree(buf);
48956 return ret;
48957+ }
48958
48959- if (ret == 1)
48960+ if (ret == 1) {
48961+ kfree(buf);
48962 return 0; /* no key pressed */
48963+ }
48964
48965 /* decoding */
48966 b = buf+1;
48967@@ -656,6 +689,8 @@ unlock:
48968
48969 ir_raw_event_handle(d->rc_dev);
48970
48971+ kfree(buf);
48972+
48973 return 1;
48974 }
48975
48976diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
48977index af63543..0436f20 100644
48978--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
48979+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
48980@@ -429,7 +429,7 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
48981 * by passing a very big num_planes value */
48982 uplane = compat_alloc_user_space(num_planes *
48983 sizeof(struct v4l2_plane));
48984- kp->m.planes = (__force struct v4l2_plane *)uplane;
48985+ kp->m.planes = (__force_kernel struct v4l2_plane *)uplane;
48986
48987 while (--num_planes >= 0) {
48988 ret = get_v4l2_plane32(uplane, uplane32, kp->memory);
48989@@ -500,7 +500,7 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
48990 if (num_planes == 0)
48991 return 0;
48992
48993- uplane = (__force struct v4l2_plane __user *)kp->m.planes;
48994+ uplane = (struct v4l2_plane __force_user *)kp->m.planes;
48995 if (get_user(p, &up->m.planes))
48996 return -EFAULT;
48997 uplane32 = compat_ptr(p);
48998@@ -564,7 +564,7 @@ static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_frame
48999 get_user(kp->flags, &up->flags) ||
49000 copy_from_user(&kp->fmt, &up->fmt, sizeof(up->fmt)))
49001 return -EFAULT;
49002- kp->base = (__force void *)compat_ptr(tmp);
49003+ kp->base = (__force_kernel void *)compat_ptr(tmp);
49004 return 0;
49005 }
49006
49007@@ -669,7 +669,7 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
49008 n * sizeof(struct v4l2_ext_control32)))
49009 return -EFAULT;
49010 kcontrols = compat_alloc_user_space(n * sizeof(struct v4l2_ext_control));
49011- kp->controls = (__force struct v4l2_ext_control *)kcontrols;
49012+ kp->controls = (__force_kernel struct v4l2_ext_control *)kcontrols;
49013 while (--n >= 0) {
49014 u32 id;
49015
49016@@ -696,7 +696,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
49017 {
49018 struct v4l2_ext_control32 __user *ucontrols;
49019 struct v4l2_ext_control __user *kcontrols =
49020- (__force struct v4l2_ext_control __user *)kp->controls;
49021+ (struct v4l2_ext_control __force_user *)kp->controls;
49022 int n = kp->count;
49023 compat_caddr_t p;
49024
49025@@ -780,7 +780,7 @@ static int get_v4l2_edid32(struct v4l2_edid *kp, struct v4l2_edid32 __user *up)
49026 get_user(tmp, &up->edid) ||
49027 copy_from_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
49028 return -EFAULT;
49029- kp->edid = (__force u8 *)compat_ptr(tmp);
49030+ kp->edid = (__force_kernel u8 *)compat_ptr(tmp);
49031 return 0;
49032 }
49033
49034diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
49035index 5b0a30b..1974b38 100644
49036--- a/drivers/media/v4l2-core/v4l2-device.c
49037+++ b/drivers/media/v4l2-core/v4l2-device.c
49038@@ -74,9 +74,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
49039 EXPORT_SYMBOL_GPL(v4l2_device_put);
49040
49041 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
49042- atomic_t *instance)
49043+ atomic_unchecked_t *instance)
49044 {
49045- int num = atomic_inc_return(instance) - 1;
49046+ int num = atomic_inc_return_unchecked(instance) - 1;
49047 int len = strlen(basename);
49048
49049 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
49050diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
49051index 85de455..4987854 100644
49052--- a/drivers/media/v4l2-core/v4l2-ioctl.c
49053+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
49054@@ -2341,7 +2341,8 @@ struct v4l2_ioctl_info {
49055 struct file *file, void *fh, void *p);
49056 } u;
49057 void (*debug)(const void *arg, bool write_only);
49058-};
49059+} __do_const;
49060+typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
49061
49062 /* This control needs a priority check */
49063 #define INFO_FL_PRIO (1 << 0)
49064@@ -2525,7 +2526,7 @@ static long __video_do_ioctl(struct file *file,
49065 struct video_device *vfd = video_devdata(file);
49066 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
49067 bool write_only = false;
49068- struct v4l2_ioctl_info default_info;
49069+ v4l2_ioctl_info_no_const default_info;
49070 const struct v4l2_ioctl_info *info;
49071 void *fh = file->private_data;
49072 struct v4l2_fh *vfh = NULL;
49073@@ -2616,7 +2617,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
49074 ret = -EINVAL;
49075 break;
49076 }
49077- *user_ptr = (void __user *)buf->m.planes;
49078+ *user_ptr = (void __force_user *)buf->m.planes;
49079 *kernel_ptr = (void **)&buf->m.planes;
49080 *array_size = sizeof(struct v4l2_plane) * buf->length;
49081 ret = 1;
49082@@ -2633,7 +2634,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
49083 ret = -EINVAL;
49084 break;
49085 }
49086- *user_ptr = (void __user *)edid->edid;
49087+ *user_ptr = (void __force_user *)edid->edid;
49088 *kernel_ptr = (void **)&edid->edid;
49089 *array_size = edid->blocks * 128;
49090 ret = 1;
49091@@ -2651,7 +2652,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
49092 ret = -EINVAL;
49093 break;
49094 }
49095- *user_ptr = (void __user *)ctrls->controls;
49096+ *user_ptr = (void __force_user *)ctrls->controls;
49097 *kernel_ptr = (void **)&ctrls->controls;
49098 *array_size = sizeof(struct v4l2_ext_control)
49099 * ctrls->count;
49100@@ -2752,7 +2753,7 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
49101 }
49102
49103 if (has_array_args) {
49104- *kernel_ptr = (void __force *)user_ptr;
49105+ *kernel_ptr = (void __force_kernel *)user_ptr;
49106 if (copy_to_user(user_ptr, mbuf, array_size))
49107 err = -EFAULT;
49108 goto out_array_args;
49109diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
49110index 9426276..9abd11e 100644
49111--- a/drivers/memory/omap-gpmc.c
49112+++ b/drivers/memory/omap-gpmc.c
49113@@ -232,7 +232,6 @@ struct omap3_gpmc_regs {
49114 };
49115
49116 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
49117-static struct irq_chip gpmc_irq_chip;
49118 static int gpmc_irq_start;
49119
49120 static struct resource gpmc_mem_root;
49121@@ -1146,6 +1145,17 @@ static void gpmc_irq_noop(struct irq_data *data) { }
49122
49123 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
49124
49125+static struct irq_chip gpmc_irq_chip = {
49126+ .name = "gpmc",
49127+ .irq_startup = gpmc_irq_noop_ret,
49128+ .irq_enable = gpmc_irq_enable,
49129+ .irq_disable = gpmc_irq_disable,
49130+ .irq_shutdown = gpmc_irq_noop,
49131+ .irq_ack = gpmc_irq_noop,
49132+ .irq_mask = gpmc_irq_noop,
49133+ .irq_unmask = gpmc_irq_noop,
49134+};
49135+
49136 static int gpmc_setup_irq(void)
49137 {
49138 int i;
49139@@ -1160,15 +1170,6 @@ static int gpmc_setup_irq(void)
49140 return gpmc_irq_start;
49141 }
49142
49143- gpmc_irq_chip.name = "gpmc";
49144- gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
49145- gpmc_irq_chip.irq_enable = gpmc_irq_enable;
49146- gpmc_irq_chip.irq_disable = gpmc_irq_disable;
49147- gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
49148- gpmc_irq_chip.irq_ack = gpmc_irq_noop;
49149- gpmc_irq_chip.irq_mask = gpmc_irq_noop;
49150- gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
49151-
49152 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
49153 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
49154
49155diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
49156index 5dcc031..e08ecd2 100644
49157--- a/drivers/message/fusion/mptbase.c
49158+++ b/drivers/message/fusion/mptbase.c
49159@@ -6722,8 +6722,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
49160 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
49161 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
49162
49163+#ifdef CONFIG_GRKERNSEC_HIDESYM
49164+ seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
49165+#else
49166 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
49167 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
49168+#endif
49169+
49170 /*
49171 * Rounding UP to nearest 4-kB boundary here...
49172 */
49173@@ -6736,7 +6741,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
49174 ioc->facts.GlobalCredits);
49175
49176 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
49177+#ifdef CONFIG_GRKERNSEC_HIDESYM
49178+ NULL, NULL);
49179+#else
49180 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
49181+#endif
49182 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
49183 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
49184 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
49185diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
49186index 005a88b..5a90fbb 100644
49187--- a/drivers/message/fusion/mptsas.c
49188+++ b/drivers/message/fusion/mptsas.c
49189@@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
49190 return 0;
49191 }
49192
49193+static inline void
49194+mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
49195+{
49196+ if (phy_info->port_details) {
49197+ phy_info->port_details->rphy = rphy;
49198+ dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
49199+ ioc->name, rphy));
49200+ }
49201+
49202+ if (rphy) {
49203+ dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
49204+ &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
49205+ dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
49206+ ioc->name, rphy, rphy->dev.release));
49207+ }
49208+}
49209+
49210 /* no mutex */
49211 static void
49212 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
49213@@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
49214 return NULL;
49215 }
49216
49217-static inline void
49218-mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
49219-{
49220- if (phy_info->port_details) {
49221- phy_info->port_details->rphy = rphy;
49222- dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
49223- ioc->name, rphy));
49224- }
49225-
49226- if (rphy) {
49227- dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
49228- &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
49229- dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
49230- ioc->name, rphy, rphy->dev.release));
49231- }
49232-}
49233-
49234 static inline struct sas_port *
49235 mptsas_get_port(struct mptsas_phyinfo *phy_info)
49236 {
49237diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
49238index 0236cd7..53b10d7 100644
49239--- a/drivers/mfd/ab8500-debugfs.c
49240+++ b/drivers/mfd/ab8500-debugfs.c
49241@@ -100,7 +100,7 @@ static int irq_last;
49242 static u32 *irq_count;
49243 static int num_irqs;
49244
49245-static struct device_attribute **dev_attr;
49246+static device_attribute_no_const **dev_attr;
49247 static char **event_name;
49248
49249 static u8 avg_sample = SAMPLE_16;
49250diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
49251index 8057849..0550fdf 100644
49252--- a/drivers/mfd/kempld-core.c
49253+++ b/drivers/mfd/kempld-core.c
49254@@ -499,7 +499,7 @@ static struct platform_driver kempld_driver = {
49255 .remove = kempld_remove,
49256 };
49257
49258-static struct dmi_system_id kempld_dmi_table[] __initdata = {
49259+static const struct dmi_system_id kempld_dmi_table[] __initconst = {
49260 {
49261 .ident = "BHL6",
49262 .matches = {
49263diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
49264index c880c89..45a7c68 100644
49265--- a/drivers/mfd/max8925-i2c.c
49266+++ b/drivers/mfd/max8925-i2c.c
49267@@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
49268 const struct i2c_device_id *id)
49269 {
49270 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
49271- static struct max8925_chip *chip;
49272+ struct max8925_chip *chip;
49273 struct device_node *node = client->dev.of_node;
49274
49275 if (node && !pdata) {
49276diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
49277index 7612d89..70549c2 100644
49278--- a/drivers/mfd/tps65910.c
49279+++ b/drivers/mfd/tps65910.c
49280@@ -230,7 +230,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
49281 struct tps65910_platform_data *pdata)
49282 {
49283 int ret = 0;
49284- static struct regmap_irq_chip *tps6591x_irqs_chip;
49285+ struct regmap_irq_chip *tps6591x_irqs_chip;
49286
49287 if (!irq) {
49288 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
49289diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
49290index a3fa7f4..eac02ef 100644
49291--- a/drivers/mfd/twl4030-irq.c
49292+++ b/drivers/mfd/twl4030-irq.c
49293@@ -34,6 +34,7 @@
49294 #include <linux/of.h>
49295 #include <linux/irqdomain.h>
49296 #include <linux/i2c/twl.h>
49297+#include <asm/pgtable.h>
49298
49299 #include "twl-core.h"
49300
49301@@ -729,10 +730,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
49302 * Install an irq handler for each of the SIH modules;
49303 * clone dummy irq_chip since PIH can't *do* anything
49304 */
49305- twl4030_irq_chip = dummy_irq_chip;
49306- twl4030_irq_chip.name = "twl4030";
49307+ pax_open_kernel();
49308+ memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
49309+ *(const char **)&twl4030_irq_chip.name = "twl4030";
49310
49311- twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
49312+ *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
49313+ pax_close_kernel();
49314
49315 for (i = irq_base; i < irq_end; i++) {
49316 irq_set_chip_and_handler(i, &twl4030_irq_chip,
49317diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
49318index 464419b..64bae8d 100644
49319--- a/drivers/misc/c2port/core.c
49320+++ b/drivers/misc/c2port/core.c
49321@@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
49322 goto error_idr_alloc;
49323 c2dev->id = ret;
49324
49325- bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
49326+ pax_open_kernel();
49327+ *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
49328+ pax_close_kernel();
49329
49330 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
49331 "c2port%d", c2dev->id);
49332diff --git a/drivers/misc/eeprom/sunxi_sid.c b/drivers/misc/eeprom/sunxi_sid.c
49333index 8385177..2f54635 100644
49334--- a/drivers/misc/eeprom/sunxi_sid.c
49335+++ b/drivers/misc/eeprom/sunxi_sid.c
49336@@ -126,7 +126,9 @@ static int sunxi_sid_probe(struct platform_device *pdev)
49337
49338 platform_set_drvdata(pdev, sid_data);
49339
49340- sid_bin_attr.size = sid_data->keysize;
49341+ pax_open_kernel();
49342+ *(size_t *)&sid_bin_attr.size = sid_data->keysize;
49343+ pax_close_kernel();
49344 if (device_create_bin_file(&pdev->dev, &sid_bin_attr))
49345 return -ENODEV;
49346
49347diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
49348index 9a60bd4..cee2069 100644
49349--- a/drivers/misc/kgdbts.c
49350+++ b/drivers/misc/kgdbts.c
49351@@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
49352 char before[BREAK_INSTR_SIZE];
49353 char after[BREAK_INSTR_SIZE];
49354
49355- probe_kernel_read(before, (char *)kgdbts_break_test,
49356+ probe_kernel_read(before, (void *)ktla_ktva((unsigned long)kgdbts_break_test),
49357 BREAK_INSTR_SIZE);
49358 init_simple_test();
49359 ts.tst = plant_and_detach_test;
49360@@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
49361 /* Activate test with initial breakpoint */
49362 if (!is_early)
49363 kgdb_breakpoint();
49364- probe_kernel_read(after, (char *)kgdbts_break_test,
49365+ probe_kernel_read(after, (void *)ktla_ktva((unsigned long)kgdbts_break_test),
49366 BREAK_INSTR_SIZE);
49367 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
49368 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
49369diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
49370index fb8705f..dc2f679 100644
49371--- a/drivers/misc/lis3lv02d/lis3lv02d.c
49372+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
49373@@ -497,7 +497,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
49374 * the lid is closed. This leads to interrupts as soon as a little move
49375 * is done.
49376 */
49377- atomic_inc(&lis3->count);
49378+ atomic_inc_unchecked(&lis3->count);
49379
49380 wake_up_interruptible(&lis3->misc_wait);
49381 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
49382@@ -583,7 +583,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
49383 if (lis3->pm_dev)
49384 pm_runtime_get_sync(lis3->pm_dev);
49385
49386- atomic_set(&lis3->count, 0);
49387+ atomic_set_unchecked(&lis3->count, 0);
49388 return 0;
49389 }
49390
49391@@ -615,7 +615,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
49392 add_wait_queue(&lis3->misc_wait, &wait);
49393 while (true) {
49394 set_current_state(TASK_INTERRUPTIBLE);
49395- data = atomic_xchg(&lis3->count, 0);
49396+ data = atomic_xchg_unchecked(&lis3->count, 0);
49397 if (data)
49398 break;
49399
49400@@ -656,7 +656,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
49401 struct lis3lv02d, miscdev);
49402
49403 poll_wait(file, &lis3->misc_wait, wait);
49404- if (atomic_read(&lis3->count))
49405+ if (atomic_read_unchecked(&lis3->count))
49406 return POLLIN | POLLRDNORM;
49407 return 0;
49408 }
49409diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
49410index c439c82..1f20f57 100644
49411--- a/drivers/misc/lis3lv02d/lis3lv02d.h
49412+++ b/drivers/misc/lis3lv02d/lis3lv02d.h
49413@@ -297,7 +297,7 @@ struct lis3lv02d {
49414 struct input_polled_dev *idev; /* input device */
49415 struct platform_device *pdev; /* platform device */
49416 struct regulator_bulk_data regulators[2];
49417- atomic_t count; /* interrupt count after last read */
49418+ atomic_unchecked_t count; /* interrupt count after last read */
49419 union axis_conversion ac; /* hw -> logical axis */
49420 int mapped_btns[3];
49421
49422diff --git a/drivers/misc/mic/scif/scif_rb.c b/drivers/misc/mic/scif/scif_rb.c
49423index 637cc46..4fb1267 100644
49424--- a/drivers/misc/mic/scif/scif_rb.c
49425+++ b/drivers/misc/mic/scif/scif_rb.c
49426@@ -138,7 +138,7 @@ void scif_rb_commit(struct scif_rb *rb)
49427 * the read barrier in scif_rb_count(..)
49428 */
49429 wmb();
49430- ACCESS_ONCE(*rb->write_ptr) = rb->current_write_offset;
49431+ ACCESS_ONCE_RW(*rb->write_ptr) = rb->current_write_offset;
49432 #ifdef CONFIG_INTEL_MIC_CARD
49433 /*
49434 * X100 Si bug: For the case where a Core is performing an EXT_WR
49435@@ -147,7 +147,7 @@ void scif_rb_commit(struct scif_rb *rb)
49436 * This way, if ordering is violated for the Interrupt Message, it will
49437 * fall just behind the first Posted associated with the first EXT_WR.
49438 */
49439- ACCESS_ONCE(*rb->write_ptr) = rb->current_write_offset;
49440+ ACCESS_ONCE_RW(*rb->write_ptr) = rb->current_write_offset;
49441 #endif
49442 }
49443
49444@@ -210,7 +210,7 @@ void scif_rb_update_read_ptr(struct scif_rb *rb)
49445 * scif_rb_space(..)
49446 */
49447 mb();
49448- ACCESS_ONCE(*rb->read_ptr) = new_offset;
49449+ ACCESS_ONCE_RW(*rb->read_ptr) = new_offset;
49450 #ifdef CONFIG_INTEL_MIC_CARD
49451 /*
49452 * X100 Si Bug: For the case where a Core is performing an EXT_WR
49453@@ -219,7 +219,7 @@ void scif_rb_update_read_ptr(struct scif_rb *rb)
49454 * This way, if ordering is violated for the Interrupt Message, it will
49455 * fall just behind the first Posted associated with the first EXT_WR.
49456 */
49457- ACCESS_ONCE(*rb->read_ptr) = new_offset;
49458+ ACCESS_ONCE_RW(*rb->read_ptr) = new_offset;
49459 #endif
49460 }
49461
49462diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
49463index 2f30bad..c4c13d0 100644
49464--- a/drivers/misc/sgi-gru/gruhandles.c
49465+++ b/drivers/misc/sgi-gru/gruhandles.c
49466@@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
49467 unsigned long nsec;
49468
49469 nsec = CLKS2NSEC(clks);
49470- atomic_long_inc(&mcs_op_statistics[op].count);
49471- atomic_long_add(nsec, &mcs_op_statistics[op].total);
49472+ atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
49473+ atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
49474 if (mcs_op_statistics[op].max < nsec)
49475 mcs_op_statistics[op].max = nsec;
49476 }
49477diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
49478index 4f76359..cdfcb2e 100644
49479--- a/drivers/misc/sgi-gru/gruprocfs.c
49480+++ b/drivers/misc/sgi-gru/gruprocfs.c
49481@@ -32,9 +32,9 @@
49482
49483 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
49484
49485-static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
49486+static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
49487 {
49488- unsigned long val = atomic_long_read(v);
49489+ unsigned long val = atomic_long_read_unchecked(v);
49490
49491 seq_printf(s, "%16lu %s\n", val, id);
49492 }
49493@@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
49494
49495 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
49496 for (op = 0; op < mcsop_last; op++) {
49497- count = atomic_long_read(&mcs_op_statistics[op].count);
49498- total = atomic_long_read(&mcs_op_statistics[op].total);
49499+ count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
49500+ total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
49501 max = mcs_op_statistics[op].max;
49502 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
49503 count ? total / count : 0, max);
49504diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
49505index 5c3ce24..4915ccb 100644
49506--- a/drivers/misc/sgi-gru/grutables.h
49507+++ b/drivers/misc/sgi-gru/grutables.h
49508@@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
49509 * GRU statistics.
49510 */
49511 struct gru_stats_s {
49512- atomic_long_t vdata_alloc;
49513- atomic_long_t vdata_free;
49514- atomic_long_t gts_alloc;
49515- atomic_long_t gts_free;
49516- atomic_long_t gms_alloc;
49517- atomic_long_t gms_free;
49518- atomic_long_t gts_double_allocate;
49519- atomic_long_t assign_context;
49520- atomic_long_t assign_context_failed;
49521- atomic_long_t free_context;
49522- atomic_long_t load_user_context;
49523- atomic_long_t load_kernel_context;
49524- atomic_long_t lock_kernel_context;
49525- atomic_long_t unlock_kernel_context;
49526- atomic_long_t steal_user_context;
49527- atomic_long_t steal_kernel_context;
49528- atomic_long_t steal_context_failed;
49529- atomic_long_t nopfn;
49530- atomic_long_t asid_new;
49531- atomic_long_t asid_next;
49532- atomic_long_t asid_wrap;
49533- atomic_long_t asid_reuse;
49534- atomic_long_t intr;
49535- atomic_long_t intr_cbr;
49536- atomic_long_t intr_tfh;
49537- atomic_long_t intr_spurious;
49538- atomic_long_t intr_mm_lock_failed;
49539- atomic_long_t call_os;
49540- atomic_long_t call_os_wait_queue;
49541- atomic_long_t user_flush_tlb;
49542- atomic_long_t user_unload_context;
49543- atomic_long_t user_exception;
49544- atomic_long_t set_context_option;
49545- atomic_long_t check_context_retarget_intr;
49546- atomic_long_t check_context_unload;
49547- atomic_long_t tlb_dropin;
49548- atomic_long_t tlb_preload_page;
49549- atomic_long_t tlb_dropin_fail_no_asid;
49550- atomic_long_t tlb_dropin_fail_upm;
49551- atomic_long_t tlb_dropin_fail_invalid;
49552- atomic_long_t tlb_dropin_fail_range_active;
49553- atomic_long_t tlb_dropin_fail_idle;
49554- atomic_long_t tlb_dropin_fail_fmm;
49555- atomic_long_t tlb_dropin_fail_no_exception;
49556- atomic_long_t tfh_stale_on_fault;
49557- atomic_long_t mmu_invalidate_range;
49558- atomic_long_t mmu_invalidate_page;
49559- atomic_long_t flush_tlb;
49560- atomic_long_t flush_tlb_gru;
49561- atomic_long_t flush_tlb_gru_tgh;
49562- atomic_long_t flush_tlb_gru_zero_asid;
49563+ atomic_long_unchecked_t vdata_alloc;
49564+ atomic_long_unchecked_t vdata_free;
49565+ atomic_long_unchecked_t gts_alloc;
49566+ atomic_long_unchecked_t gts_free;
49567+ atomic_long_unchecked_t gms_alloc;
49568+ atomic_long_unchecked_t gms_free;
49569+ atomic_long_unchecked_t gts_double_allocate;
49570+ atomic_long_unchecked_t assign_context;
49571+ atomic_long_unchecked_t assign_context_failed;
49572+ atomic_long_unchecked_t free_context;
49573+ atomic_long_unchecked_t load_user_context;
49574+ atomic_long_unchecked_t load_kernel_context;
49575+ atomic_long_unchecked_t lock_kernel_context;
49576+ atomic_long_unchecked_t unlock_kernel_context;
49577+ atomic_long_unchecked_t steal_user_context;
49578+ atomic_long_unchecked_t steal_kernel_context;
49579+ atomic_long_unchecked_t steal_context_failed;
49580+ atomic_long_unchecked_t nopfn;
49581+ atomic_long_unchecked_t asid_new;
49582+ atomic_long_unchecked_t asid_next;
49583+ atomic_long_unchecked_t asid_wrap;
49584+ atomic_long_unchecked_t asid_reuse;
49585+ atomic_long_unchecked_t intr;
49586+ atomic_long_unchecked_t intr_cbr;
49587+ atomic_long_unchecked_t intr_tfh;
49588+ atomic_long_unchecked_t intr_spurious;
49589+ atomic_long_unchecked_t intr_mm_lock_failed;
49590+ atomic_long_unchecked_t call_os;
49591+ atomic_long_unchecked_t call_os_wait_queue;
49592+ atomic_long_unchecked_t user_flush_tlb;
49593+ atomic_long_unchecked_t user_unload_context;
49594+ atomic_long_unchecked_t user_exception;
49595+ atomic_long_unchecked_t set_context_option;
49596+ atomic_long_unchecked_t check_context_retarget_intr;
49597+ atomic_long_unchecked_t check_context_unload;
49598+ atomic_long_unchecked_t tlb_dropin;
49599+ atomic_long_unchecked_t tlb_preload_page;
49600+ atomic_long_unchecked_t tlb_dropin_fail_no_asid;
49601+ atomic_long_unchecked_t tlb_dropin_fail_upm;
49602+ atomic_long_unchecked_t tlb_dropin_fail_invalid;
49603+ atomic_long_unchecked_t tlb_dropin_fail_range_active;
49604+ atomic_long_unchecked_t tlb_dropin_fail_idle;
49605+ atomic_long_unchecked_t tlb_dropin_fail_fmm;
49606+ atomic_long_unchecked_t tlb_dropin_fail_no_exception;
49607+ atomic_long_unchecked_t tfh_stale_on_fault;
49608+ atomic_long_unchecked_t mmu_invalidate_range;
49609+ atomic_long_unchecked_t mmu_invalidate_page;
49610+ atomic_long_unchecked_t flush_tlb;
49611+ atomic_long_unchecked_t flush_tlb_gru;
49612+ atomic_long_unchecked_t flush_tlb_gru_tgh;
49613+ atomic_long_unchecked_t flush_tlb_gru_zero_asid;
49614
49615- atomic_long_t copy_gpa;
49616- atomic_long_t read_gpa;
49617+ atomic_long_unchecked_t copy_gpa;
49618+ atomic_long_unchecked_t read_gpa;
49619
49620- atomic_long_t mesq_receive;
49621- atomic_long_t mesq_receive_none;
49622- atomic_long_t mesq_send;
49623- atomic_long_t mesq_send_failed;
49624- atomic_long_t mesq_noop;
49625- atomic_long_t mesq_send_unexpected_error;
49626- atomic_long_t mesq_send_lb_overflow;
49627- atomic_long_t mesq_send_qlimit_reached;
49628- atomic_long_t mesq_send_amo_nacked;
49629- atomic_long_t mesq_send_put_nacked;
49630- atomic_long_t mesq_page_overflow;
49631- atomic_long_t mesq_qf_locked;
49632- atomic_long_t mesq_qf_noop_not_full;
49633- atomic_long_t mesq_qf_switch_head_failed;
49634- atomic_long_t mesq_qf_unexpected_error;
49635- atomic_long_t mesq_noop_unexpected_error;
49636- atomic_long_t mesq_noop_lb_overflow;
49637- atomic_long_t mesq_noop_qlimit_reached;
49638- atomic_long_t mesq_noop_amo_nacked;
49639- atomic_long_t mesq_noop_put_nacked;
49640- atomic_long_t mesq_noop_page_overflow;
49641+ atomic_long_unchecked_t mesq_receive;
49642+ atomic_long_unchecked_t mesq_receive_none;
49643+ atomic_long_unchecked_t mesq_send;
49644+ atomic_long_unchecked_t mesq_send_failed;
49645+ atomic_long_unchecked_t mesq_noop;
49646+ atomic_long_unchecked_t mesq_send_unexpected_error;
49647+ atomic_long_unchecked_t mesq_send_lb_overflow;
49648+ atomic_long_unchecked_t mesq_send_qlimit_reached;
49649+ atomic_long_unchecked_t mesq_send_amo_nacked;
49650+ atomic_long_unchecked_t mesq_send_put_nacked;
49651+ atomic_long_unchecked_t mesq_page_overflow;
49652+ atomic_long_unchecked_t mesq_qf_locked;
49653+ atomic_long_unchecked_t mesq_qf_noop_not_full;
49654+ atomic_long_unchecked_t mesq_qf_switch_head_failed;
49655+ atomic_long_unchecked_t mesq_qf_unexpected_error;
49656+ atomic_long_unchecked_t mesq_noop_unexpected_error;
49657+ atomic_long_unchecked_t mesq_noop_lb_overflow;
49658+ atomic_long_unchecked_t mesq_noop_qlimit_reached;
49659+ atomic_long_unchecked_t mesq_noop_amo_nacked;
49660+ atomic_long_unchecked_t mesq_noop_put_nacked;
49661+ atomic_long_unchecked_t mesq_noop_page_overflow;
49662
49663 };
49664
49665@@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
49666 tghop_invalidate, mcsop_last};
49667
49668 struct mcs_op_statistic {
49669- atomic_long_t count;
49670- atomic_long_t total;
49671+ atomic_long_unchecked_t count;
49672+ atomic_long_unchecked_t total;
49673 unsigned long max;
49674 };
49675
49676@@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
49677
49678 #define STAT(id) do { \
49679 if (gru_options & OPT_STATS) \
49680- atomic_long_inc(&gru_stats.id); \
49681+ atomic_long_inc_unchecked(&gru_stats.id); \
49682 } while (0)
49683
49684 #ifdef CONFIG_SGI_GRU_DEBUG
49685diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
49686index c862cd4..0d176fe 100644
49687--- a/drivers/misc/sgi-xp/xp.h
49688+++ b/drivers/misc/sgi-xp/xp.h
49689@@ -288,7 +288,7 @@ struct xpc_interface {
49690 xpc_notify_func, void *);
49691 void (*received) (short, int, void *);
49692 enum xp_retval (*partid_to_nasids) (short, void *);
49693-};
49694+} __no_const;
49695
49696 extern struct xpc_interface xpc_interface;
49697
49698diff --git a/drivers/misc/sgi-xp/xp_main.c b/drivers/misc/sgi-xp/xp_main.c
49699index 01be66d..e3a0c7e 100644
49700--- a/drivers/misc/sgi-xp/xp_main.c
49701+++ b/drivers/misc/sgi-xp/xp_main.c
49702@@ -78,13 +78,13 @@ xpc_notloaded(void)
49703 }
49704
49705 struct xpc_interface xpc_interface = {
49706- (void (*)(int))xpc_notloaded,
49707- (void (*)(int))xpc_notloaded,
49708- (enum xp_retval(*)(short, int, u32, void *, u16))xpc_notloaded,
49709- (enum xp_retval(*)(short, int, u32, void *, u16, xpc_notify_func,
49710+ .connect = (void (*)(int))xpc_notloaded,
49711+ .disconnect = (void (*)(int))xpc_notloaded,
49712+ .send = (enum xp_retval(*)(short, int, u32, void *, u16))xpc_notloaded,
49713+ .send_notify = (enum xp_retval(*)(short, int, u32, void *, u16, xpc_notify_func,
49714 void *))xpc_notloaded,
49715- (void (*)(short, int, void *))xpc_notloaded,
49716- (enum xp_retval(*)(short, void *))xpc_notloaded
49717+ .received = (void (*)(short, int, void *))xpc_notloaded,
49718+ .partid_to_nasids = (enum xp_retval(*)(short, void *))xpc_notloaded
49719 };
49720 EXPORT_SYMBOL_GPL(xpc_interface);
49721
49722diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
49723index b94d5f7..7f494c5 100644
49724--- a/drivers/misc/sgi-xp/xpc.h
49725+++ b/drivers/misc/sgi-xp/xpc.h
49726@@ -835,6 +835,7 @@ struct xpc_arch_operations {
49727 void (*received_payload) (struct xpc_channel *, void *);
49728 void (*notify_senders_of_disconnect) (struct xpc_channel *);
49729 };
49730+typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
49731
49732 /* struct xpc_partition act_state values (for XPC HB) */
49733
49734@@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
49735 /* found in xpc_main.c */
49736 extern struct device *xpc_part;
49737 extern struct device *xpc_chan;
49738-extern struct xpc_arch_operations xpc_arch_ops;
49739+extern xpc_arch_operations_no_const xpc_arch_ops;
49740 extern int xpc_disengage_timelimit;
49741 extern int xpc_disengage_timedout;
49742 extern int xpc_activate_IRQ_rcvd;
49743diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
49744index 7f32712..8539ab2 100644
49745--- a/drivers/misc/sgi-xp/xpc_main.c
49746+++ b/drivers/misc/sgi-xp/xpc_main.c
49747@@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
49748 .notifier_call = xpc_system_die,
49749 };
49750
49751-struct xpc_arch_operations xpc_arch_ops;
49752+xpc_arch_operations_no_const xpc_arch_ops;
49753
49754 /*
49755 * Timer function to enforce the timelimit on the partition disengage.
49756diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
49757index a1b820f..e299c58 100644
49758--- a/drivers/mmc/card/block.c
49759+++ b/drivers/mmc/card/block.c
49760@@ -579,7 +579,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
49761 if (idata->ic.postsleep_min_us)
49762 usleep_range(idata->ic.postsleep_min_us, idata->ic.postsleep_max_us);
49763
49764- if (copy_to_user(&(ic_ptr->response), cmd.resp, sizeof(cmd.resp))) {
49765+ if (copy_to_user(ic_ptr->response, cmd.resp, sizeof(cmd.resp))) {
49766 err = -EFAULT;
49767 goto cmd_rel_host;
49768 }
49769diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
49770index 8ce4674..a23c858 100644
49771--- a/drivers/mmc/host/dw_mmc.h
49772+++ b/drivers/mmc/host/dw_mmc.h
49773@@ -286,5 +286,5 @@ struct dw_mci_drv_data {
49774 struct mmc_ios *ios);
49775 int (*switch_voltage)(struct mmc_host *mmc,
49776 struct mmc_ios *ios);
49777-};
49778+} __do_const;
49779 #endif /* _DW_MMC_H_ */
49780diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
49781index fb26674..3172c2b 100644
49782--- a/drivers/mmc/host/mmci.c
49783+++ b/drivers/mmc/host/mmci.c
49784@@ -1633,7 +1633,9 @@ static int mmci_probe(struct amba_device *dev,
49785 mmc->caps |= MMC_CAP_CMD23;
49786
49787 if (variant->busy_detect) {
49788- mmci_ops.card_busy = mmci_card_busy;
49789+ pax_open_kernel();
49790+ *(void **)&mmci_ops.card_busy = mmci_card_busy;
49791+ pax_close_kernel();
49792 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
49793 mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
49794 mmc->max_busy_timeout = 0;
49795diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
49796index 4d12032..2b0eb6d 100644
49797--- a/drivers/mmc/host/omap_hsmmc.c
49798+++ b/drivers/mmc/host/omap_hsmmc.c
49799@@ -1984,7 +1984,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
49800
49801 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) {
49802 dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n");
49803- omap_hsmmc_ops.multi_io_quirk = omap_hsmmc_multi_io_quirk;
49804+ pax_open_kernel();
49805+ *(void **)&omap_hsmmc_ops.multi_io_quirk = omap_hsmmc_multi_io_quirk;
49806+ pax_close_kernel();
49807 }
49808
49809 device_init_wakeup(&pdev->dev, true);
49810diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
49811index c6b9f64..00e656c 100644
49812--- a/drivers/mmc/host/sdhci-esdhc-imx.c
49813+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
49814@@ -1088,9 +1088,12 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
49815 host->ioaddr + 0x6c);
49816 }
49817
49818- if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING)
49819- sdhci_esdhc_ops.platform_execute_tuning =
49820+ if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
49821+ pax_open_kernel();
49822+ *(void **)&sdhci_esdhc_ops.platform_execute_tuning =
49823 esdhc_executing_tuning;
49824+ pax_close_kernel();
49825+ }
49826
49827 if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING)
49828 writel(readl(host->ioaddr + ESDHC_TUNING_CTRL) |
49829diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
49830index 70c724b..308aafc 100644
49831--- a/drivers/mmc/host/sdhci-s3c.c
49832+++ b/drivers/mmc/host/sdhci-s3c.c
49833@@ -598,9 +598,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
49834 * we can use overriding functions instead of default.
49835 */
49836 if (sc->no_divider) {
49837- sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
49838- sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
49839- sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
49840+ pax_open_kernel();
49841+ *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
49842+ *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
49843+ *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
49844+ pax_close_kernel();
49845 }
49846
49847 /* It supports additional host capabilities if needed */
49848diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
49849index 9a1a6ff..b8f1a57 100644
49850--- a/drivers/mtd/chips/cfi_cmdset_0020.c
49851+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
49852@@ -666,7 +666,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
49853 size_t totlen = 0, thislen;
49854 int ret = 0;
49855 size_t buflen = 0;
49856- static char *buffer;
49857+ char *buffer;
49858
49859 if (!ECCBUF_SIZE) {
49860 /* We should fall back to a general writev implementation.
49861diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
49862index 870c7fc..c7d6440 100644
49863--- a/drivers/mtd/nand/denali.c
49864+++ b/drivers/mtd/nand/denali.c
49865@@ -24,6 +24,7 @@
49866 #include <linux/slab.h>
49867 #include <linux/mtd/mtd.h>
49868 #include <linux/module.h>
49869+#include <linux/slab.h>
49870
49871 #include "denali.h"
49872
49873diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
49874index 1b8f350..990f2e9 100644
49875--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
49876+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
49877@@ -386,7 +386,7 @@ void prepare_data_dma(struct gpmi_nand_data *this, enum dma_data_direction dr)
49878
49879 /* first try to map the upper buffer directly */
49880 if (virt_addr_valid(this->upper_buf) &&
49881- !object_is_on_stack(this->upper_buf)) {
49882+ !object_starts_on_stack(this->upper_buf)) {
49883 sg_init_one(sgl, this->upper_buf, this->upper_len);
49884 ret = dma_map_sg(this->dev, sgl, 1, dr);
49885 if (ret == 0)
49886diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
49887index a5dfbfb..8042ab4 100644
49888--- a/drivers/mtd/nftlmount.c
49889+++ b/drivers/mtd/nftlmount.c
49890@@ -24,6 +24,7 @@
49891 #include <asm/errno.h>
49892 #include <linux/delay.h>
49893 #include <linux/slab.h>
49894+#include <linux/sched.h>
49895 #include <linux/mtd/mtd.h>
49896 #include <linux/mtd/nand.h>
49897 #include <linux/mtd/nftl.h>
49898diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
49899index c23184a..4115c41 100644
49900--- a/drivers/mtd/sm_ftl.c
49901+++ b/drivers/mtd/sm_ftl.c
49902@@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
49903 #define SM_CIS_VENDOR_OFFSET 0x59
49904 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
49905 {
49906- struct attribute_group *attr_group;
49907+ attribute_group_no_const *attr_group;
49908 struct attribute **attributes;
49909 struct sm_sysfs_attribute *vendor_attribute;
49910 char *vendor;
49911diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
49912index 1bda292..3f4af40 100644
49913--- a/drivers/net/bonding/bond_netlink.c
49914+++ b/drivers/net/bonding/bond_netlink.c
49915@@ -649,7 +649,7 @@ nla_put_failure:
49916 return -EMSGSIZE;
49917 }
49918
49919-struct rtnl_link_ops bond_link_ops __read_mostly = {
49920+struct rtnl_link_ops bond_link_ops = {
49921 .kind = "bond",
49922 .priv_size = sizeof(struct bonding),
49923 .setup = bond_setup,
49924diff --git a/drivers/net/caif/caif_hsi.c b/drivers/net/caif/caif_hsi.c
49925index b3b922a..80bba38 100644
49926--- a/drivers/net/caif/caif_hsi.c
49927+++ b/drivers/net/caif/caif_hsi.c
49928@@ -1444,7 +1444,7 @@ err:
49929 return -ENODEV;
49930 }
49931
49932-static struct rtnl_link_ops caif_hsi_link_ops __read_mostly = {
49933+static struct rtnl_link_ops caif_hsi_link_ops = {
49934 .kind = "cfhsi",
49935 .priv_size = sizeof(struct cfhsi),
49936 .setup = cfhsi_setup,
49937diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
49938index e8c96b8..516a96c 100644
49939--- a/drivers/net/can/Kconfig
49940+++ b/drivers/net/can/Kconfig
49941@@ -98,7 +98,7 @@ config CAN_JANZ_ICAN3
49942
49943 config CAN_FLEXCAN
49944 tristate "Support for Freescale FLEXCAN based chips"
49945- depends on ARM || PPC
49946+ depends on (ARM && CPU_LITTLE_ENDIAN) || PPC
49947 ---help---
49948 Say Y here if you want to support for Freescale FlexCAN.
49949
49950diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
49951index aede704..b516b4d 100644
49952--- a/drivers/net/can/dev.c
49953+++ b/drivers/net/can/dev.c
49954@@ -961,7 +961,7 @@ static int can_newlink(struct net *src_net, struct net_device *dev,
49955 return -EOPNOTSUPP;
49956 }
49957
49958-static struct rtnl_link_ops can_link_ops __read_mostly = {
49959+static struct rtnl_link_ops can_link_ops = {
49960 .kind = "can",
49961 .maxtype = IFLA_CAN_MAX,
49962 .policy = can_policy,
49963diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
49964index 674f367..ec3a31f 100644
49965--- a/drivers/net/can/vcan.c
49966+++ b/drivers/net/can/vcan.c
49967@@ -163,7 +163,7 @@ static void vcan_setup(struct net_device *dev)
49968 dev->destructor = free_netdev;
49969 }
49970
49971-static struct rtnl_link_ops vcan_link_ops __read_mostly = {
49972+static struct rtnl_link_ops vcan_link_ops = {
49973 .kind = "vcan",
49974 .setup = vcan_setup,
49975 };
49976diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
49977index 49adbf1..fff7ff8 100644
49978--- a/drivers/net/dummy.c
49979+++ b/drivers/net/dummy.c
49980@@ -164,7 +164,7 @@ static int dummy_validate(struct nlattr *tb[], struct nlattr *data[])
49981 return 0;
49982 }
49983
49984-static struct rtnl_link_ops dummy_link_ops __read_mostly = {
49985+static struct rtnl_link_ops dummy_link_ops = {
49986 .kind = DRV_NAME,
49987 .setup = dummy_setup,
49988 .validate = dummy_validate,
49989diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
49990index 0443654..4f0aa18 100644
49991--- a/drivers/net/ethernet/8390/ax88796.c
49992+++ b/drivers/net/ethernet/8390/ax88796.c
49993@@ -889,9 +889,11 @@ static int ax_probe(struct platform_device *pdev)
49994 if (ax->plat->reg_offsets)
49995 ei_local->reg_offset = ax->plat->reg_offsets;
49996 else {
49997+ resource_size_t _mem_size = mem_size;
49998+ do_div(_mem_size, 0x18);
49999 ei_local->reg_offset = ax->reg_offsets;
50000 for (ret = 0; ret < 0x18; ret++)
50001- ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
50002+ ax->reg_offsets[ret] = _mem_size * ret;
50003 }
50004
50005 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
50006diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
50007index 8207877..ce13e99 100644
50008--- a/drivers/net/ethernet/altera/altera_tse_main.c
50009+++ b/drivers/net/ethernet/altera/altera_tse_main.c
50010@@ -1255,7 +1255,7 @@ static int tse_shutdown(struct net_device *dev)
50011 return 0;
50012 }
50013
50014-static struct net_device_ops altera_tse_netdev_ops = {
50015+static net_device_ops_no_const altera_tse_netdev_ops __read_only = {
50016 .ndo_open = tse_open,
50017 .ndo_stop = tse_shutdown,
50018 .ndo_start_xmit = tse_start_xmit,
50019@@ -1492,11 +1492,13 @@ static int altera_tse_probe(struct platform_device *pdev)
50020 ndev->netdev_ops = &altera_tse_netdev_ops;
50021 altera_tse_set_ethtool_ops(ndev);
50022
50023+ pax_open_kernel();
50024 altera_tse_netdev_ops.ndo_set_rx_mode = tse_set_rx_mode;
50025
50026 if (priv->hash_filter)
50027 altera_tse_netdev_ops.ndo_set_rx_mode =
50028 tse_set_rx_mode_hashfilter;
50029+ pax_close_kernel();
50030
50031 /* Scatter/gather IO is not supported,
50032 * so it is turned off
50033diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-common.h b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
50034index b6fa891..31ef157 100644
50035--- a/drivers/net/ethernet/amd/xgbe/xgbe-common.h
50036+++ b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
50037@@ -1279,14 +1279,14 @@ do { \
50038 * operations, everything works on mask values.
50039 */
50040 #define XMDIO_READ(_pdata, _mmd, _reg) \
50041- ((_pdata)->hw_if.read_mmd_regs((_pdata), 0, \
50042+ ((_pdata)->hw_if->read_mmd_regs((_pdata), 0, \
50043 MII_ADDR_C45 | (_mmd << 16) | ((_reg) & 0xffff)))
50044
50045 #define XMDIO_READ_BITS(_pdata, _mmd, _reg, _mask) \
50046 (XMDIO_READ((_pdata), _mmd, _reg) & _mask)
50047
50048 #define XMDIO_WRITE(_pdata, _mmd, _reg, _val) \
50049- ((_pdata)->hw_if.write_mmd_regs((_pdata), 0, \
50050+ ((_pdata)->hw_if->write_mmd_regs((_pdata), 0, \
50051 MII_ADDR_C45 | (_mmd << 16) | ((_reg) & 0xffff), (_val)))
50052
50053 #define XMDIO_WRITE_BITS(_pdata, _mmd, _reg, _mask, _val) \
50054diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
50055index a6b9899..2e5e972 100644
50056--- a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
50057+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
50058@@ -190,7 +190,7 @@ static int xgbe_dcb_ieee_setets(struct net_device *netdev,
50059
50060 memcpy(pdata->ets, ets, sizeof(*pdata->ets));
50061
50062- pdata->hw_if.config_dcb_tc(pdata);
50063+ pdata->hw_if->config_dcb_tc(pdata);
50064
50065 return 0;
50066 }
50067@@ -230,7 +230,7 @@ static int xgbe_dcb_ieee_setpfc(struct net_device *netdev,
50068
50069 memcpy(pdata->pfc, pfc, sizeof(*pdata->pfc));
50070
50071- pdata->hw_if.config_dcb_pfc(pdata);
50072+ pdata->hw_if->config_dcb_pfc(pdata);
50073
50074 return 0;
50075 }
50076diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
50077index b3bc87f..5bdfdd3 100644
50078--- a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
50079+++ b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
50080@@ -353,7 +353,7 @@ static int xgbe_map_rx_buffer(struct xgbe_prv_data *pdata,
50081
50082 static void xgbe_wrapper_tx_descriptor_init(struct xgbe_prv_data *pdata)
50083 {
50084- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50085+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50086 struct xgbe_channel *channel;
50087 struct xgbe_ring *ring;
50088 struct xgbe_ring_data *rdata;
50089@@ -394,7 +394,7 @@ static void xgbe_wrapper_tx_descriptor_init(struct xgbe_prv_data *pdata)
50090
50091 static void xgbe_wrapper_rx_descriptor_init(struct xgbe_prv_data *pdata)
50092 {
50093- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50094+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50095 struct xgbe_channel *channel;
50096 struct xgbe_ring *ring;
50097 struct xgbe_ring_desc *rdesc;
50098@@ -628,17 +628,12 @@ err_out:
50099 return 0;
50100 }
50101
50102-void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *desc_if)
50103-{
50104- DBGPR("-->xgbe_init_function_ptrs_desc\n");
50105-
50106- desc_if->alloc_ring_resources = xgbe_alloc_ring_resources;
50107- desc_if->free_ring_resources = xgbe_free_ring_resources;
50108- desc_if->map_tx_skb = xgbe_map_tx_skb;
50109- desc_if->map_rx_buffer = xgbe_map_rx_buffer;
50110- desc_if->unmap_rdata = xgbe_unmap_rdata;
50111- desc_if->wrapper_tx_desc_init = xgbe_wrapper_tx_descriptor_init;
50112- desc_if->wrapper_rx_desc_init = xgbe_wrapper_rx_descriptor_init;
50113-
50114- DBGPR("<--xgbe_init_function_ptrs_desc\n");
50115-}
50116+const struct xgbe_desc_if default_xgbe_desc_if = {
50117+ .alloc_ring_resources = xgbe_alloc_ring_resources,
50118+ .free_ring_resources = xgbe_free_ring_resources,
50119+ .map_tx_skb = xgbe_map_tx_skb,
50120+ .map_rx_buffer = xgbe_map_rx_buffer,
50121+ .unmap_rdata = xgbe_unmap_rdata,
50122+ .wrapper_tx_desc_init = xgbe_wrapper_tx_descriptor_init,
50123+ .wrapper_rx_desc_init = xgbe_wrapper_rx_descriptor_init,
50124+};
50125diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
50126index a4473d8..039a2ab 100644
50127--- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
50128+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
50129@@ -2776,7 +2776,7 @@ static void xgbe_powerdown_rx(struct xgbe_prv_data *pdata)
50130
50131 static int xgbe_init(struct xgbe_prv_data *pdata)
50132 {
50133- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50134+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50135 int ret;
50136
50137 DBGPR("-->xgbe_init\n");
50138@@ -2842,106 +2842,101 @@ static int xgbe_init(struct xgbe_prv_data *pdata)
50139 return 0;
50140 }
50141
50142-void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *hw_if)
50143-{
50144- DBGPR("-->xgbe_init_function_ptrs\n");
50145-
50146- hw_if->tx_complete = xgbe_tx_complete;
50147-
50148- hw_if->set_mac_address = xgbe_set_mac_address;
50149- hw_if->config_rx_mode = xgbe_config_rx_mode;
50150-
50151- hw_if->enable_rx_csum = xgbe_enable_rx_csum;
50152- hw_if->disable_rx_csum = xgbe_disable_rx_csum;
50153-
50154- hw_if->enable_rx_vlan_stripping = xgbe_enable_rx_vlan_stripping;
50155- hw_if->disable_rx_vlan_stripping = xgbe_disable_rx_vlan_stripping;
50156- hw_if->enable_rx_vlan_filtering = xgbe_enable_rx_vlan_filtering;
50157- hw_if->disable_rx_vlan_filtering = xgbe_disable_rx_vlan_filtering;
50158- hw_if->update_vlan_hash_table = xgbe_update_vlan_hash_table;
50159-
50160- hw_if->read_mmd_regs = xgbe_read_mmd_regs;
50161- hw_if->write_mmd_regs = xgbe_write_mmd_regs;
50162-
50163- hw_if->set_gmii_speed = xgbe_set_gmii_speed;
50164- hw_if->set_gmii_2500_speed = xgbe_set_gmii_2500_speed;
50165- hw_if->set_xgmii_speed = xgbe_set_xgmii_speed;
50166-
50167- hw_if->enable_tx = xgbe_enable_tx;
50168- hw_if->disable_tx = xgbe_disable_tx;
50169- hw_if->enable_rx = xgbe_enable_rx;
50170- hw_if->disable_rx = xgbe_disable_rx;
50171-
50172- hw_if->powerup_tx = xgbe_powerup_tx;
50173- hw_if->powerdown_tx = xgbe_powerdown_tx;
50174- hw_if->powerup_rx = xgbe_powerup_rx;
50175- hw_if->powerdown_rx = xgbe_powerdown_rx;
50176-
50177- hw_if->dev_xmit = xgbe_dev_xmit;
50178- hw_if->dev_read = xgbe_dev_read;
50179- hw_if->enable_int = xgbe_enable_int;
50180- hw_if->disable_int = xgbe_disable_int;
50181- hw_if->init = xgbe_init;
50182- hw_if->exit = xgbe_exit;
50183+const struct xgbe_hw_if default_xgbe_hw_if = {
50184+ .tx_complete = xgbe_tx_complete,
50185+
50186+ .set_mac_address = xgbe_set_mac_address,
50187+ .config_rx_mode = xgbe_config_rx_mode,
50188+
50189+ .enable_rx_csum = xgbe_enable_rx_csum,
50190+ .disable_rx_csum = xgbe_disable_rx_csum,
50191+
50192+ .enable_rx_vlan_stripping = xgbe_enable_rx_vlan_stripping,
50193+ .disable_rx_vlan_stripping = xgbe_disable_rx_vlan_stripping,
50194+ .enable_rx_vlan_filtering = xgbe_enable_rx_vlan_filtering,
50195+ .disable_rx_vlan_filtering = xgbe_disable_rx_vlan_filtering,
50196+ .update_vlan_hash_table = xgbe_update_vlan_hash_table,
50197+
50198+ .read_mmd_regs = xgbe_read_mmd_regs,
50199+ .write_mmd_regs = xgbe_write_mmd_regs,
50200+
50201+ .set_gmii_speed = xgbe_set_gmii_speed,
50202+ .set_gmii_2500_speed = xgbe_set_gmii_2500_speed,
50203+ .set_xgmii_speed = xgbe_set_xgmii_speed,
50204+
50205+ .enable_tx = xgbe_enable_tx,
50206+ .disable_tx = xgbe_disable_tx,
50207+ .enable_rx = xgbe_enable_rx,
50208+ .disable_rx = xgbe_disable_rx,
50209+
50210+ .powerup_tx = xgbe_powerup_tx,
50211+ .powerdown_tx = xgbe_powerdown_tx,
50212+ .powerup_rx = xgbe_powerup_rx,
50213+ .powerdown_rx = xgbe_powerdown_rx,
50214+
50215+ .dev_xmit = xgbe_dev_xmit,
50216+ .dev_read = xgbe_dev_read,
50217+ .enable_int = xgbe_enable_int,
50218+ .disable_int = xgbe_disable_int,
50219+ .init = xgbe_init,
50220+ .exit = xgbe_exit,
50221
50222 /* Descriptor related Sequences have to be initialized here */
50223- hw_if->tx_desc_init = xgbe_tx_desc_init;
50224- hw_if->rx_desc_init = xgbe_rx_desc_init;
50225- hw_if->tx_desc_reset = xgbe_tx_desc_reset;
50226- hw_if->rx_desc_reset = xgbe_rx_desc_reset;
50227- hw_if->is_last_desc = xgbe_is_last_desc;
50228- hw_if->is_context_desc = xgbe_is_context_desc;
50229- hw_if->tx_start_xmit = xgbe_tx_start_xmit;
50230+ .tx_desc_init = xgbe_tx_desc_init,
50231+ .rx_desc_init = xgbe_rx_desc_init,
50232+ .tx_desc_reset = xgbe_tx_desc_reset,
50233+ .rx_desc_reset = xgbe_rx_desc_reset,
50234+ .is_last_desc = xgbe_is_last_desc,
50235+ .is_context_desc = xgbe_is_context_desc,
50236+ .tx_start_xmit = xgbe_tx_start_xmit,
50237
50238 /* For FLOW ctrl */
50239- hw_if->config_tx_flow_control = xgbe_config_tx_flow_control;
50240- hw_if->config_rx_flow_control = xgbe_config_rx_flow_control;
50241+ .config_tx_flow_control = xgbe_config_tx_flow_control,
50242+ .config_rx_flow_control = xgbe_config_rx_flow_control,
50243
50244 /* For RX coalescing */
50245- hw_if->config_rx_coalesce = xgbe_config_rx_coalesce;
50246- hw_if->config_tx_coalesce = xgbe_config_tx_coalesce;
50247- hw_if->usec_to_riwt = xgbe_usec_to_riwt;
50248- hw_if->riwt_to_usec = xgbe_riwt_to_usec;
50249+ .config_rx_coalesce = xgbe_config_rx_coalesce,
50250+ .config_tx_coalesce = xgbe_config_tx_coalesce,
50251+ .usec_to_riwt = xgbe_usec_to_riwt,
50252+ .riwt_to_usec = xgbe_riwt_to_usec,
50253
50254 /* For RX and TX threshold config */
50255- hw_if->config_rx_threshold = xgbe_config_rx_threshold;
50256- hw_if->config_tx_threshold = xgbe_config_tx_threshold;
50257+ .config_rx_threshold = xgbe_config_rx_threshold,
50258+ .config_tx_threshold = xgbe_config_tx_threshold,
50259
50260 /* For RX and TX Store and Forward Mode config */
50261- hw_if->config_rsf_mode = xgbe_config_rsf_mode;
50262- hw_if->config_tsf_mode = xgbe_config_tsf_mode;
50263+ .config_rsf_mode = xgbe_config_rsf_mode,
50264+ .config_tsf_mode = xgbe_config_tsf_mode,
50265
50266 /* For TX DMA Operating on Second Frame config */
50267- hw_if->config_osp_mode = xgbe_config_osp_mode;
50268+ .config_osp_mode = xgbe_config_osp_mode,
50269
50270 /* For RX and TX PBL config */
50271- hw_if->config_rx_pbl_val = xgbe_config_rx_pbl_val;
50272- hw_if->get_rx_pbl_val = xgbe_get_rx_pbl_val;
50273- hw_if->config_tx_pbl_val = xgbe_config_tx_pbl_val;
50274- hw_if->get_tx_pbl_val = xgbe_get_tx_pbl_val;
50275- hw_if->config_pblx8 = xgbe_config_pblx8;
50276+ .config_rx_pbl_val = xgbe_config_rx_pbl_val,
50277+ .get_rx_pbl_val = xgbe_get_rx_pbl_val,
50278+ .config_tx_pbl_val = xgbe_config_tx_pbl_val,
50279+ .get_tx_pbl_val = xgbe_get_tx_pbl_val,
50280+ .config_pblx8 = xgbe_config_pblx8,
50281
50282 /* For MMC statistics support */
50283- hw_if->tx_mmc_int = xgbe_tx_mmc_int;
50284- hw_if->rx_mmc_int = xgbe_rx_mmc_int;
50285- hw_if->read_mmc_stats = xgbe_read_mmc_stats;
50286+ .tx_mmc_int = xgbe_tx_mmc_int,
50287+ .rx_mmc_int = xgbe_rx_mmc_int,
50288+ .read_mmc_stats = xgbe_read_mmc_stats,
50289
50290 /* For PTP config */
50291- hw_if->config_tstamp = xgbe_config_tstamp;
50292- hw_if->update_tstamp_addend = xgbe_update_tstamp_addend;
50293- hw_if->set_tstamp_time = xgbe_set_tstamp_time;
50294- hw_if->get_tstamp_time = xgbe_get_tstamp_time;
50295- hw_if->get_tx_tstamp = xgbe_get_tx_tstamp;
50296+ .config_tstamp = xgbe_config_tstamp,
50297+ .update_tstamp_addend = xgbe_update_tstamp_addend,
50298+ .set_tstamp_time = xgbe_set_tstamp_time,
50299+ .get_tstamp_time = xgbe_get_tstamp_time,
50300+ .get_tx_tstamp = xgbe_get_tx_tstamp,
50301
50302 /* For Data Center Bridging config */
50303- hw_if->config_dcb_tc = xgbe_config_dcb_tc;
50304- hw_if->config_dcb_pfc = xgbe_config_dcb_pfc;
50305+ .config_dcb_tc = xgbe_config_dcb_tc,
50306+ .config_dcb_pfc = xgbe_config_dcb_pfc,
50307
50308 /* For Receive Side Scaling */
50309- hw_if->enable_rss = xgbe_enable_rss;
50310- hw_if->disable_rss = xgbe_disable_rss;
50311- hw_if->set_rss_hash_key = xgbe_set_rss_hash_key;
50312- hw_if->set_rss_lookup_table = xgbe_set_rss_lookup_table;
50313-
50314- DBGPR("<--xgbe_init_function_ptrs\n");
50315-}
50316+ .enable_rss = xgbe_enable_rss,
50317+ .disable_rss = xgbe_disable_rss,
50318+ .set_rss_hash_key = xgbe_set_rss_hash_key,
50319+ .set_rss_lookup_table = xgbe_set_rss_lookup_table,
50320+};
50321diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
50322index aae9d5e..29ce58d 100644
50323--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
50324+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
50325@@ -245,7 +245,7 @@ static int xgbe_maybe_stop_tx_queue(struct xgbe_channel *channel,
50326 * support, tell it now
50327 */
50328 if (ring->tx.xmit_more)
50329- pdata->hw_if.tx_start_xmit(channel, ring);
50330+ pdata->hw_if->tx_start_xmit(channel, ring);
50331
50332 return NETDEV_TX_BUSY;
50333 }
50334@@ -273,7 +273,7 @@ static int xgbe_calc_rx_buf_size(struct net_device *netdev, unsigned int mtu)
50335
50336 static void xgbe_enable_rx_tx_ints(struct xgbe_prv_data *pdata)
50337 {
50338- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50339+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50340 struct xgbe_channel *channel;
50341 enum xgbe_int int_id;
50342 unsigned int i;
50343@@ -295,7 +295,7 @@ static void xgbe_enable_rx_tx_ints(struct xgbe_prv_data *pdata)
50344
50345 static void xgbe_disable_rx_tx_ints(struct xgbe_prv_data *pdata)
50346 {
50347- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50348+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50349 struct xgbe_channel *channel;
50350 enum xgbe_int int_id;
50351 unsigned int i;
50352@@ -318,7 +318,7 @@ static void xgbe_disable_rx_tx_ints(struct xgbe_prv_data *pdata)
50353 static irqreturn_t xgbe_isr(int irq, void *data)
50354 {
50355 struct xgbe_prv_data *pdata = data;
50356- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50357+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50358 struct xgbe_channel *channel;
50359 unsigned int dma_isr, dma_ch_isr;
50360 unsigned int mac_isr, mac_tssr;
50361@@ -443,7 +443,7 @@ static void xgbe_service(struct work_struct *work)
50362 struct xgbe_prv_data,
50363 service_work);
50364
50365- pdata->phy_if.phy_status(pdata);
50366+ pdata->phy_if->phy_status(pdata);
50367 }
50368
50369 static void xgbe_service_timer(unsigned long data)
50370@@ -702,7 +702,7 @@ static void xgbe_free_irqs(struct xgbe_prv_data *pdata)
50371
50372 void xgbe_init_tx_coalesce(struct xgbe_prv_data *pdata)
50373 {
50374- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50375+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50376
50377 DBGPR("-->xgbe_init_tx_coalesce\n");
50378
50379@@ -716,7 +716,7 @@ void xgbe_init_tx_coalesce(struct xgbe_prv_data *pdata)
50380
50381 void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata)
50382 {
50383- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50384+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50385
50386 DBGPR("-->xgbe_init_rx_coalesce\n");
50387
50388@@ -731,7 +731,7 @@ void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata)
50389
50390 static void xgbe_free_tx_data(struct xgbe_prv_data *pdata)
50391 {
50392- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50393+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50394 struct xgbe_channel *channel;
50395 struct xgbe_ring *ring;
50396 struct xgbe_ring_data *rdata;
50397@@ -756,7 +756,7 @@ static void xgbe_free_tx_data(struct xgbe_prv_data *pdata)
50398
50399 static void xgbe_free_rx_data(struct xgbe_prv_data *pdata)
50400 {
50401- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50402+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50403 struct xgbe_channel *channel;
50404 struct xgbe_ring *ring;
50405 struct xgbe_ring_data *rdata;
50406@@ -784,13 +784,13 @@ static int xgbe_phy_init(struct xgbe_prv_data *pdata)
50407 pdata->phy_link = -1;
50408 pdata->phy_speed = SPEED_UNKNOWN;
50409
50410- return pdata->phy_if.phy_reset(pdata);
50411+ return pdata->phy_if->phy_reset(pdata);
50412 }
50413
50414 int xgbe_powerdown(struct net_device *netdev, unsigned int caller)
50415 {
50416 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50417- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50418+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50419 unsigned long flags;
50420
50421 DBGPR("-->xgbe_powerdown\n");
50422@@ -829,7 +829,7 @@ int xgbe_powerdown(struct net_device *netdev, unsigned int caller)
50423 int xgbe_powerup(struct net_device *netdev, unsigned int caller)
50424 {
50425 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50426- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50427+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50428 unsigned long flags;
50429
50430 DBGPR("-->xgbe_powerup\n");
50431@@ -866,8 +866,8 @@ int xgbe_powerup(struct net_device *netdev, unsigned int caller)
50432
50433 static int xgbe_start(struct xgbe_prv_data *pdata)
50434 {
50435- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50436- struct xgbe_phy_if *phy_if = &pdata->phy_if;
50437+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50438+ struct xgbe_phy_if *phy_if = pdata->phy_if;
50439 struct net_device *netdev = pdata->netdev;
50440 int ret;
50441
50442@@ -910,8 +910,8 @@ err_phy:
50443
50444 static void xgbe_stop(struct xgbe_prv_data *pdata)
50445 {
50446- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50447- struct xgbe_phy_if *phy_if = &pdata->phy_if;
50448+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50449+ struct xgbe_phy_if *phy_if = pdata->phy_if;
50450 struct xgbe_channel *channel;
50451 struct net_device *netdev = pdata->netdev;
50452 struct netdev_queue *txq;
50453@@ -1139,7 +1139,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
50454 return -ERANGE;
50455 }
50456
50457- pdata->hw_if.config_tstamp(pdata, mac_tscr);
50458+ pdata->hw_if->config_tstamp(pdata, mac_tscr);
50459
50460 memcpy(&pdata->tstamp_config, &config, sizeof(config));
50461
50462@@ -1288,7 +1288,7 @@ static void xgbe_packet_info(struct xgbe_prv_data *pdata,
50463 static int xgbe_open(struct net_device *netdev)
50464 {
50465 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50466- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50467+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50468 int ret;
50469
50470 DBGPR("-->xgbe_open\n");
50471@@ -1360,7 +1360,7 @@ err_sysclk:
50472 static int xgbe_close(struct net_device *netdev)
50473 {
50474 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50475- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50476+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50477
50478 DBGPR("-->xgbe_close\n");
50479
50480@@ -1387,8 +1387,8 @@ static int xgbe_close(struct net_device *netdev)
50481 static int xgbe_xmit(struct sk_buff *skb, struct net_device *netdev)
50482 {
50483 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50484- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50485- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50486+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50487+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50488 struct xgbe_channel *channel;
50489 struct xgbe_ring *ring;
50490 struct xgbe_packet_data *packet;
50491@@ -1457,7 +1457,7 @@ tx_netdev_return:
50492 static void xgbe_set_rx_mode(struct net_device *netdev)
50493 {
50494 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50495- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50496+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50497
50498 DBGPR("-->xgbe_set_rx_mode\n");
50499
50500@@ -1469,7 +1469,7 @@ static void xgbe_set_rx_mode(struct net_device *netdev)
50501 static int xgbe_set_mac_address(struct net_device *netdev, void *addr)
50502 {
50503 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50504- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50505+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50506 struct sockaddr *saddr = addr;
50507
50508 DBGPR("-->xgbe_set_mac_address\n");
50509@@ -1544,7 +1544,7 @@ static struct rtnl_link_stats64 *xgbe_get_stats64(struct net_device *netdev,
50510
50511 DBGPR("-->%s\n", __func__);
50512
50513- pdata->hw_if.read_mmc_stats(pdata);
50514+ pdata->hw_if->read_mmc_stats(pdata);
50515
50516 s->rx_packets = pstats->rxframecount_gb;
50517 s->rx_bytes = pstats->rxoctetcount_gb;
50518@@ -1571,7 +1571,7 @@ static int xgbe_vlan_rx_add_vid(struct net_device *netdev, __be16 proto,
50519 u16 vid)
50520 {
50521 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50522- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50523+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50524
50525 DBGPR("-->%s\n", __func__);
50526
50527@@ -1587,7 +1587,7 @@ static int xgbe_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto,
50528 u16 vid)
50529 {
50530 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50531- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50532+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50533
50534 DBGPR("-->%s\n", __func__);
50535
50536@@ -1654,7 +1654,7 @@ static int xgbe_set_features(struct net_device *netdev,
50537 netdev_features_t features)
50538 {
50539 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50540- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50541+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50542 netdev_features_t rxhash, rxcsum, rxvlan, rxvlan_filter;
50543 int ret = 0;
50544
50545@@ -1720,8 +1720,8 @@ struct net_device_ops *xgbe_get_netdev_ops(void)
50546 static void xgbe_rx_refresh(struct xgbe_channel *channel)
50547 {
50548 struct xgbe_prv_data *pdata = channel->pdata;
50549- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50550- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50551+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50552+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50553 struct xgbe_ring *ring = channel->rx_ring;
50554 struct xgbe_ring_data *rdata;
50555
50556@@ -1798,8 +1798,8 @@ static struct sk_buff *xgbe_create_skb(struct xgbe_prv_data *pdata,
50557 static int xgbe_tx_poll(struct xgbe_channel *channel)
50558 {
50559 struct xgbe_prv_data *pdata = channel->pdata;
50560- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50561- struct xgbe_desc_if *desc_if = &pdata->desc_if;
50562+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50563+ struct xgbe_desc_if *desc_if = pdata->desc_if;
50564 struct xgbe_ring *ring = channel->tx_ring;
50565 struct xgbe_ring_data *rdata;
50566 struct xgbe_ring_desc *rdesc;
50567@@ -1863,7 +1863,7 @@ static int xgbe_tx_poll(struct xgbe_channel *channel)
50568 static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
50569 {
50570 struct xgbe_prv_data *pdata = channel->pdata;
50571- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50572+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50573 struct xgbe_ring *ring = channel->rx_ring;
50574 struct xgbe_ring_data *rdata;
50575 struct xgbe_packet_data *packet;
50576diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
50577index 59e090e..90bc0b4 100644
50578--- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
50579+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
50580@@ -211,7 +211,7 @@ static void xgbe_get_ethtool_stats(struct net_device *netdev,
50581
50582 DBGPR("-->%s\n", __func__);
50583
50584- pdata->hw_if.read_mmc_stats(pdata);
50585+ pdata->hw_if->read_mmc_stats(pdata);
50586 for (i = 0; i < XGBE_STATS_COUNT; i++) {
50587 stat = (u8 *)pdata + xgbe_gstring_stats[i].stat_offset;
50588 *data++ = *(u64 *)stat;
50589@@ -284,7 +284,7 @@ static int xgbe_set_pauseparam(struct net_device *netdev,
50590 pdata->phy.advertising ^= ADVERTISED_Asym_Pause;
50591
50592 if (netif_running(netdev))
50593- ret = pdata->phy_if.phy_config_aneg(pdata);
50594+ ret = pdata->phy_if->phy_config_aneg(pdata);
50595
50596 DBGPR("<--xgbe_set_pauseparam\n");
50597
50598@@ -364,7 +364,7 @@ static int xgbe_set_settings(struct net_device *netdev,
50599 pdata->phy.advertising &= ~ADVERTISED_Autoneg;
50600
50601 if (netif_running(netdev))
50602- ret = pdata->phy_if.phy_config_aneg(pdata);
50603+ ret = pdata->phy_if->phy_config_aneg(pdata);
50604
50605 DBGPR("<--xgbe_set_settings\n");
50606
50607@@ -411,7 +411,7 @@ static int xgbe_set_coalesce(struct net_device *netdev,
50608 struct ethtool_coalesce *ec)
50609 {
50610 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50611- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50612+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50613 unsigned int rx_frames, rx_riwt, rx_usecs;
50614 unsigned int tx_frames;
50615
50616@@ -536,7 +536,7 @@ static int xgbe_set_rxfh(struct net_device *netdev, const u32 *indir,
50617 const u8 *key, const u8 hfunc)
50618 {
50619 struct xgbe_prv_data *pdata = netdev_priv(netdev);
50620- struct xgbe_hw_if *hw_if = &pdata->hw_if;
50621+ struct xgbe_hw_if *hw_if = pdata->hw_if;
50622 unsigned int ret;
50623
50624 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
50625diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
50626index e83bd76..f2d5d56 100644
50627--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
50628+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
50629@@ -202,13 +202,6 @@ static void xgbe_default_config(struct xgbe_prv_data *pdata)
50630 DBGPR("<--xgbe_default_config\n");
50631 }
50632
50633-static void xgbe_init_all_fptrs(struct xgbe_prv_data *pdata)
50634-{
50635- xgbe_init_function_ptrs_dev(&pdata->hw_if);
50636- xgbe_init_function_ptrs_phy(&pdata->phy_if);
50637- xgbe_init_function_ptrs_desc(&pdata->desc_if);
50638-}
50639-
50640 #ifdef CONFIG_ACPI
50641 static int xgbe_acpi_support(struct xgbe_prv_data *pdata)
50642 {
50643@@ -641,10 +634,12 @@ static int xgbe_probe(struct platform_device *pdev)
50644 memcpy(netdev->dev_addr, pdata->mac_addr, netdev->addr_len);
50645
50646 /* Set all the function pointers */
50647- xgbe_init_all_fptrs(pdata);
50648+ pdata->hw_if = &default_xgbe_hw_if;
50649+ pdata->phy_if = &default_xgbe_phy_if;
50650+ pdata->desc_if = &default_xgbe_desc_if;
50651
50652 /* Issue software reset to device */
50653- pdata->hw_if.exit(pdata);
50654+ pdata->hw_if->exit(pdata);
50655
50656 /* Populate the hardware features */
50657 xgbe_get_all_hw_features(pdata);
50658@@ -698,7 +693,7 @@ static int xgbe_probe(struct platform_device *pdev)
50659 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, UDP4TE, 1);
50660
50661 /* Call MDIO/PHY initialization routine */
50662- pdata->phy_if.phy_init(pdata);
50663+ pdata->phy_if->phy_init(pdata);
50664
50665 /* Set device operations */
50666 netdev->netdev_ops = xgbe_get_netdev_ops();
50667diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
50668index 9088c3a..2ffe7c4 100644
50669--- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
50670+++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
50671@@ -202,7 +202,7 @@ static void xgbe_xgmii_mode(struct xgbe_prv_data *pdata)
50672 xgbe_an_enable_kr_training(pdata);
50673
50674 /* Set MAC to 10G speed */
50675- pdata->hw_if.set_xgmii_speed(pdata);
50676+ pdata->hw_if->set_xgmii_speed(pdata);
50677
50678 /* Set PCS to KR/10G speed */
50679 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL2);
50680@@ -250,7 +250,7 @@ static void xgbe_gmii_2500_mode(struct xgbe_prv_data *pdata)
50681 xgbe_an_disable_kr_training(pdata);
50682
50683 /* Set MAC to 2.5G speed */
50684- pdata->hw_if.set_gmii_2500_speed(pdata);
50685+ pdata->hw_if->set_gmii_2500_speed(pdata);
50686
50687 /* Set PCS to KX/1G speed */
50688 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL2);
50689@@ -298,7 +298,7 @@ static void xgbe_gmii_mode(struct xgbe_prv_data *pdata)
50690 xgbe_an_disable_kr_training(pdata);
50691
50692 /* Set MAC to 1G speed */
50693- pdata->hw_if.set_gmii_speed(pdata);
50694+ pdata->hw_if->set_gmii_speed(pdata);
50695
50696 /* Set PCS to KX/1G speed */
50697 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL2);
50698@@ -872,13 +872,13 @@ static void xgbe_phy_adjust_link(struct xgbe_prv_data *pdata)
50699
50700 if (pdata->tx_pause != pdata->phy.tx_pause) {
50701 new_state = 1;
50702- pdata->hw_if.config_tx_flow_control(pdata);
50703+ pdata->hw_if->config_tx_flow_control(pdata);
50704 pdata->tx_pause = pdata->phy.tx_pause;
50705 }
50706
50707 if (pdata->rx_pause != pdata->phy.rx_pause) {
50708 new_state = 1;
50709- pdata->hw_if.config_rx_flow_control(pdata);
50710+ pdata->hw_if->config_rx_flow_control(pdata);
50711 pdata->rx_pause = pdata->phy.rx_pause;
50712 }
50713
50714@@ -1351,14 +1351,13 @@ static void xgbe_phy_init(struct xgbe_prv_data *pdata)
50715 xgbe_dump_phy_registers(pdata);
50716 }
50717
50718-void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *phy_if)
50719-{
50720- phy_if->phy_init = xgbe_phy_init;
50721+const struct xgbe_phy_if default_xgbe_phy_if = {
50722+ .phy_init = xgbe_phy_init,
50723
50724- phy_if->phy_reset = xgbe_phy_reset;
50725- phy_if->phy_start = xgbe_phy_start;
50726- phy_if->phy_stop = xgbe_phy_stop;
50727+ .phy_reset = xgbe_phy_reset,
50728+ .phy_start = xgbe_phy_start,
50729+ .phy_stop = xgbe_phy_stop,
50730
50731- phy_if->phy_status = xgbe_phy_status;
50732- phy_if->phy_config_aneg = xgbe_phy_config_aneg;
50733-}
50734+ .phy_status = xgbe_phy_status,
50735+ .phy_config_aneg = xgbe_phy_config_aneg,
50736+};
50737diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
50738index b03e4f5..78e4cc4 100644
50739--- a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
50740+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
50741@@ -129,7 +129,7 @@ static cycle_t xgbe_cc_read(const struct cyclecounter *cc)
50742 tstamp_cc);
50743 u64 nsec;
50744
50745- nsec = pdata->hw_if.get_tstamp_time(pdata);
50746+ nsec = pdata->hw_if->get_tstamp_time(pdata);
50747
50748 return nsec;
50749 }
50750@@ -158,7 +158,7 @@ static int xgbe_adjfreq(struct ptp_clock_info *info, s32 delta)
50751
50752 spin_lock_irqsave(&pdata->tstamp_lock, flags);
50753
50754- pdata->hw_if.update_tstamp_addend(pdata, addend);
50755+ pdata->hw_if->update_tstamp_addend(pdata, addend);
50756
50757 spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
50758
50759diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
50760index 717ce21..aacd1f3 100644
50761--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
50762+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
50763@@ -801,9 +801,9 @@ struct xgbe_prv_data {
50764 int dev_irq;
50765 unsigned int per_channel_irq;
50766
50767- struct xgbe_hw_if hw_if;
50768- struct xgbe_phy_if phy_if;
50769- struct xgbe_desc_if desc_if;
50770+ struct xgbe_hw_if *hw_if;
50771+ struct xgbe_phy_if *phy_if;
50772+ struct xgbe_desc_if *desc_if;
50773
50774 /* AXI DMA settings */
50775 unsigned int coherent;
50776@@ -964,6 +964,10 @@ struct xgbe_prv_data {
50777 #endif
50778 };
50779
50780+extern const struct xgbe_hw_if default_xgbe_hw_if;
50781+extern const struct xgbe_phy_if default_xgbe_phy_if;
50782+extern const struct xgbe_desc_if default_xgbe_desc_if;
50783+
50784 /* Function prototypes*/
50785
50786 void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *);
50787diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
50788index 03b7404..01ff3b3 100644
50789--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
50790+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
50791@@ -1082,7 +1082,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
50792 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
50793 {
50794 /* RX_MODE controlling object */
50795- bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
50796+ bnx2x_init_rx_mode_obj(bp);
50797
50798 /* multicast configuration controlling object */
50799 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
50800diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
50801index 4ad415a..8e0a040 100644
50802--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
50803+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
50804@@ -2329,15 +2329,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
50805 return rc;
50806 }
50807
50808-void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
50809- struct bnx2x_rx_mode_obj *o)
50810+void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
50811 {
50812 if (CHIP_IS_E1x(bp)) {
50813- o->wait_comp = bnx2x_empty_rx_mode_wait;
50814- o->config_rx_mode = bnx2x_set_rx_mode_e1x;
50815+ bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
50816+ bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
50817 } else {
50818- o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
50819- o->config_rx_mode = bnx2x_set_rx_mode_e2;
50820+ bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
50821+ bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
50822 }
50823 }
50824
50825diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
50826index 86baecb..ff3bb46 100644
50827--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
50828+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
50829@@ -1411,8 +1411,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
50830
50831 /********************* RX MODE ****************/
50832
50833-void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
50834- struct bnx2x_rx_mode_obj *o);
50835+void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
50836
50837 /**
50838 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
50839diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
50840index 31c9f82..e65e986 100644
50841--- a/drivers/net/ethernet/broadcom/tg3.h
50842+++ b/drivers/net/ethernet/broadcom/tg3.h
50843@@ -150,6 +150,7 @@
50844 #define CHIPREV_ID_5750_A0 0x4000
50845 #define CHIPREV_ID_5750_A1 0x4001
50846 #define CHIPREV_ID_5750_A3 0x4003
50847+#define CHIPREV_ID_5750_C1 0x4201
50848 #define CHIPREV_ID_5750_C2 0x4202
50849 #define CHIPREV_ID_5752_A0_HW 0x5000
50850 #define CHIPREV_ID_5752_A0 0x6000
50851diff --git a/drivers/net/ethernet/brocade/bna/bna_enet.c b/drivers/net/ethernet/brocade/bna/bna_enet.c
50852index 4e5c387..bba8173 100644
50853--- a/drivers/net/ethernet/brocade/bna/bna_enet.c
50854+++ b/drivers/net/ethernet/brocade/bna/bna_enet.c
50855@@ -1676,10 +1676,10 @@ bna_cb_ioceth_reset(void *arg)
50856 }
50857
50858 static struct bfa_ioc_cbfn bna_ioceth_cbfn = {
50859- bna_cb_ioceth_enable,
50860- bna_cb_ioceth_disable,
50861- bna_cb_ioceth_hbfail,
50862- bna_cb_ioceth_reset
50863+ .enable_cbfn = bna_cb_ioceth_enable,
50864+ .disable_cbfn = bna_cb_ioceth_disable,
50865+ .hbfail_cbfn = bna_cb_ioceth_hbfail,
50866+ .reset_cbfn = bna_cb_ioceth_reset
50867 };
50868
50869 static void bna_attr_init(struct bna_ioceth *ioceth)
50870diff --git a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
50871index 29f3308..b594c38 100644
50872--- a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
50873+++ b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
50874@@ -265,9 +265,9 @@ static void octnet_mdio_resp_callback(struct octeon_device *oct,
50875 if (status) {
50876 dev_err(&oct->pci_dev->dev, "MIDO instruction failed. Status: %llx\n",
50877 CVM_CAST64(status));
50878- ACCESS_ONCE(mdio_cmd_ctx->cond) = -1;
50879+ ACCESS_ONCE_RW(mdio_cmd_ctx->cond) = -1;
50880 } else {
50881- ACCESS_ONCE(mdio_cmd_ctx->cond) = 1;
50882+ ACCESS_ONCE_RW(mdio_cmd_ctx->cond) = 1;
50883 }
50884 wake_up_interruptible(&mdio_cmd_ctx->wc);
50885 }
50886@@ -298,7 +298,7 @@ octnet_mdio45_access(struct lio *lio, int op, int loc, int *value)
50887 mdio_cmd_rsp = (struct oct_mdio_cmd_resp *)sc->virtrptr;
50888 mdio_cmd = (struct oct_mdio_cmd *)sc->virtdptr;
50889
50890- ACCESS_ONCE(mdio_cmd_ctx->cond) = 0;
50891+ ACCESS_ONCE_RW(mdio_cmd_ctx->cond) = 0;
50892 mdio_cmd_ctx->octeon_id = lio_get_device_id(oct_dev);
50893 mdio_cmd->op = op;
50894 mdio_cmd->mdio_addr = loc;
50895diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
50896index 0660dee..e07895e 100644
50897--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
50898+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
50899@@ -1727,7 +1727,7 @@ static void if_cfg_callback(struct octeon_device *oct,
50900 if (resp->status)
50901 dev_err(&oct->pci_dev->dev, "nic if cfg instruction failed. Status: %llx\n",
50902 CVM_CAST64(resp->status));
50903- ACCESS_ONCE(ctx->cond) = 1;
50904+ ACCESS_ONCE_RW(ctx->cond) = 1;
50905
50906 /* This barrier is required to be sure that the response has been
50907 * written fully before waking up the handler
50908@@ -3177,7 +3177,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
50909 dev_dbg(&octeon_dev->pci_dev->dev,
50910 "requesting config for interface %d, iqs %d, oqs %d\n",
50911 i, num_iqueues, num_oqueues);
50912- ACCESS_ONCE(ctx->cond) = 0;
50913+ ACCESS_ONCE_RW(ctx->cond) = 0;
50914 ctx->octeon_id = lio_get_device_id(octeon_dev);
50915 init_waitqueue_head(&ctx->wc);
50916
50917@@ -3240,8 +3240,11 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
50918 props = &octeon_dev->props[i];
50919 props->netdev = netdev;
50920
50921- if (num_iqueues > 1)
50922- lionetdevops.ndo_select_queue = select_q;
50923+ if (num_iqueues > 1) {
50924+ pax_open_kernel();
50925+ *(void **)&lionetdevops.ndo_select_queue = select_q;
50926+ pax_close_kernel();
50927+ }
50928
50929 /* Associate the routines that will handle different
50930 * netdev tasks.
50931diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
50932index 8cffcdf..aadf043 100644
50933--- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
50934+++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
50935@@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
50936 */
50937 struct l2t_skb_cb {
50938 arp_failure_handler_func arp_failure_handler;
50939-};
50940+} __no_const;
50941
50942 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
50943
50944diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
50945index 8966f31..e15a101 100644
50946--- a/drivers/net/ethernet/dec/tulip/de4x5.c
50947+++ b/drivers/net/ethernet/dec/tulip/de4x5.c
50948@@ -5373,7 +5373,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
50949 for (i=0; i<ETH_ALEN; i++) {
50950 tmp.addr[i] = dev->dev_addr[i];
50951 }
50952- if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
50953+ if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
50954 break;
50955
50956 case DE4X5_SET_HWADDR: /* Set the hardware address */
50957@@ -5413,7 +5413,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
50958 spin_lock_irqsave(&lp->lock, flags);
50959 memcpy(&statbuf, &lp->pktStats, ioc->len);
50960 spin_unlock_irqrestore(&lp->lock, flags);
50961- if (copy_to_user(ioc->data, &statbuf, ioc->len))
50962+ if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
50963 return -EFAULT;
50964 break;
50965 }
50966diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
50967index 6ca693b..fa18c3f 100644
50968--- a/drivers/net/ethernet/emulex/benet/be_main.c
50969+++ b/drivers/net/ethernet/emulex/benet/be_main.c
50970@@ -551,7 +551,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
50971
50972 if (wrapped)
50973 newacc += 65536;
50974- ACCESS_ONCE(*acc) = newacc;
50975+ ACCESS_ONCE_RW(*acc) = newacc;
50976 }
50977
50978 static void populate_erx_stats(struct be_adapter *adapter,
50979diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
50980index 6d0c5d5..55be363 100644
50981--- a/drivers/net/ethernet/faraday/ftgmac100.c
50982+++ b/drivers/net/ethernet/faraday/ftgmac100.c
50983@@ -30,6 +30,8 @@
50984 #include <linux/netdevice.h>
50985 #include <linux/phy.h>
50986 #include <linux/platform_device.h>
50987+#include <linux/interrupt.h>
50988+#include <linux/irqreturn.h>
50989 #include <net/ip.h>
50990
50991 #include "ftgmac100.h"
50992diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
50993index dce5f7b..2433466 100644
50994--- a/drivers/net/ethernet/faraday/ftmac100.c
50995+++ b/drivers/net/ethernet/faraday/ftmac100.c
50996@@ -31,6 +31,8 @@
50997 #include <linux/module.h>
50998 #include <linux/netdevice.h>
50999 #include <linux/platform_device.h>
51000+#include <linux/interrupt.h>
51001+#include <linux/irqreturn.h>
51002
51003 #include "ftmac100.h"
51004
51005diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
51006index a92b772..250fe69 100644
51007--- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
51008+++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
51009@@ -419,7 +419,7 @@ void i40e_ptp_set_increment(struct i40e_pf *pf)
51010 wr32(hw, I40E_PRTTSYN_INC_H, incval >> 32);
51011
51012 /* Update the base adjustement value. */
51013- ACCESS_ONCE(pf->ptp_base_adj) = incval;
51014+ ACCESS_ONCE_RW(pf->ptp_base_adj) = incval;
51015 smp_mb(); /* Force the above update. */
51016 }
51017
51018diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
51019index e5ba040..d47531c 100644
51020--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
51021+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
51022@@ -782,7 +782,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
51023 }
51024
51025 /* update the base incval used to calculate frequency adjustment */
51026- ACCESS_ONCE(adapter->base_incval) = incval;
51027+ ACCESS_ONCE_RW(adapter->base_incval) = incval;
51028 smp_mb();
51029
51030 /* need lock to prevent incorrect read while modifying cyclecounter */
51031diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
51032index c10d98f..72914c6 100644
51033--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
51034+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
51035@@ -475,8 +475,8 @@ static bool mlx4_en_process_tx_cq(struct net_device *dev,
51036 wmb();
51037
51038 /* we want to dirty this cache line once */
51039- ACCESS_ONCE(ring->last_nr_txbb) = last_nr_txbb;
51040- ACCESS_ONCE(ring->cons) = ring_cons + txbbs_skipped;
51041+ ACCESS_ONCE_RW(ring->last_nr_txbb) = last_nr_txbb;
51042+ ACCESS_ONCE_RW(ring->cons) = ring_cons + txbbs_skipped;
51043
51044 netdev_tx_completed_queue(ring->tx_queue, packets, bytes);
51045
51046diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
51047index 40206da..9d94643 100644
51048--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
51049+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
51050@@ -1734,7 +1734,9 @@ static void mlx5e_build_netdev(struct net_device *netdev)
51051 SET_NETDEV_DEV(netdev, &mdev->pdev->dev);
51052
51053 if (priv->num_tc > 1) {
51054- mlx5e_netdev_ops.ndo_select_queue = mlx5e_select_queue;
51055+ pax_open_kernel();
51056+ *(void **)&mlx5e_netdev_ops.ndo_select_queue = mlx5e_select_queue;
51057+ pax_close_kernel();
51058 }
51059
51060 netdev->netdev_ops = &mlx5e_netdev_ops;
51061diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
51062index 6223930..975033d 100644
51063--- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
51064+++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
51065@@ -3457,7 +3457,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
51066 struct __vxge_hw_fifo *fifo;
51067 struct vxge_hw_fifo_config *config;
51068 u32 txdl_size, txdl_per_memblock;
51069- struct vxge_hw_mempool_cbs fifo_mp_callback;
51070+ static struct vxge_hw_mempool_cbs fifo_mp_callback = {
51071+ .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
51072+ };
51073+
51074 struct __vxge_hw_virtualpath *vpath;
51075
51076 if ((vp == NULL) || (attr == NULL)) {
51077@@ -3540,8 +3543,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
51078 goto exit;
51079 }
51080
51081- fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
51082-
51083 fifo->mempool =
51084 __vxge_hw_mempool_create(vpath->hldev,
51085 fifo->config->memblock_size,
51086diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
51087index 753ea8b..674c39a 100644
51088--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
51089+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
51090@@ -2324,7 +2324,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
51091 max_tx_rings = QLCNIC_MAX_VNIC_TX_RINGS;
51092 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
51093 ahw->nic_mode = QLCNIC_DEFAULT_MODE;
51094- adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
51095+ pax_open_kernel();
51096+ *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
51097+ pax_close_kernel();
51098 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
51099 max_sds_rings = QLCNIC_MAX_SDS_RINGS;
51100 max_tx_rings = QLCNIC_MAX_TX_RINGS;
51101diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
51102index be7d7a6..a8983f8 100644
51103--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
51104+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
51105@@ -207,17 +207,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
51106 case QLCNIC_NON_PRIV_FUNC:
51107 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
51108 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
51109- nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
51110+ pax_open_kernel();
51111+ *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
51112+ pax_close_kernel();
51113 break;
51114 case QLCNIC_PRIV_FUNC:
51115 ahw->op_mode = QLCNIC_PRIV_FUNC;
51116 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
51117- nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
51118+ pax_open_kernel();
51119+ *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
51120+ pax_close_kernel();
51121 break;
51122 case QLCNIC_MGMT_FUNC:
51123 ahw->op_mode = QLCNIC_MGMT_FUNC;
51124 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
51125- nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
51126+ pax_open_kernel();
51127+ *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
51128+ pax_close_kernel();
51129 break;
51130 default:
51131 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
51132diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
51133index 332bb8a..e6adcd1 100644
51134--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
51135+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
51136@@ -1285,7 +1285,7 @@ flash_temp:
51137 int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
51138 {
51139 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
51140- static const struct qlcnic_dump_operations *fw_dump_ops;
51141+ const struct qlcnic_dump_operations *fw_dump_ops;
51142 struct qlcnic_83xx_dump_template_hdr *hdr_83xx;
51143 u32 entry_offset, dump, no_entries, buf_offset = 0;
51144 int i, k, ops_cnt, ops_index, dump_size = 0;
51145diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
51146index f790f61..f1faafe 100644
51147--- a/drivers/net/ethernet/realtek/r8169.c
51148+++ b/drivers/net/ethernet/realtek/r8169.c
51149@@ -788,22 +788,22 @@ struct rtl8169_private {
51150 struct mdio_ops {
51151 void (*write)(struct rtl8169_private *, int, int);
51152 int (*read)(struct rtl8169_private *, int);
51153- } mdio_ops;
51154+ } __no_const mdio_ops;
51155
51156 struct pll_power_ops {
51157 void (*down)(struct rtl8169_private *);
51158 void (*up)(struct rtl8169_private *);
51159- } pll_power_ops;
51160+ } __no_const pll_power_ops;
51161
51162 struct jumbo_ops {
51163 void (*enable)(struct rtl8169_private *);
51164 void (*disable)(struct rtl8169_private *);
51165- } jumbo_ops;
51166+ } __no_const jumbo_ops;
51167
51168 struct csi_ops {
51169 void (*write)(struct rtl8169_private *, int, int);
51170 u32 (*read)(struct rtl8169_private *, int);
51171- } csi_ops;
51172+ } __no_const csi_ops;
51173
51174 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
51175 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
51176diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
51177index ad62615..a4c124d 100644
51178--- a/drivers/net/ethernet/sfc/ptp.c
51179+++ b/drivers/net/ethernet/sfc/ptp.c
51180@@ -832,7 +832,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
51181 ptp->start.dma_addr);
51182
51183 /* Clear flag that signals MC ready */
51184- ACCESS_ONCE(*start) = 0;
51185+ ACCESS_ONCE_RW(*start) = 0;
51186 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
51187 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
51188 EFX_BUG_ON_PARANOID(rc);
51189diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
51190index 3f20bb1..59add41 100644
51191--- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
51192+++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
51193@@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
51194
51195 writel(value, ioaddr + MMC_CNTRL);
51196
51197- pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
51198- MMC_CNTRL, value);
51199+// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
51200+// MMC_CNTRL, value);
51201 }
51202
51203 /* To mask all all interrupts.*/
51204diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
51205index a832637..092da0a 100644
51206--- a/drivers/net/ethernet/via/via-rhine.c
51207+++ b/drivers/net/ethernet/via/via-rhine.c
51208@@ -2599,7 +2599,7 @@ static struct platform_driver rhine_driver_platform = {
51209 }
51210 };
51211
51212-static struct dmi_system_id rhine_dmi_table[] __initdata = {
51213+static const struct dmi_system_id rhine_dmi_table[] __initconst = {
51214 {
51215 .ident = "EPIA-M",
51216 .matches = {
51217diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
51218index dd45440..c5f3cae 100644
51219--- a/drivers/net/hyperv/hyperv_net.h
51220+++ b/drivers/net/hyperv/hyperv_net.h
51221@@ -177,7 +177,7 @@ struct rndis_device {
51222 enum rndis_device_state state;
51223 bool link_state;
51224 bool link_change;
51225- atomic_t new_req_id;
51226+ atomic_unchecked_t new_req_id;
51227
51228 spinlock_t request_lock;
51229 struct list_head req_list;
51230diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
51231index 236aeb7..fd695e2 100644
51232--- a/drivers/net/hyperv/rndis_filter.c
51233+++ b/drivers/net/hyperv/rndis_filter.c
51234@@ -101,7 +101,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
51235 * template
51236 */
51237 set = &rndis_msg->msg.set_req;
51238- set->req_id = atomic_inc_return(&dev->new_req_id);
51239+ set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
51240
51241 /* Add to the request list */
51242 spin_lock_irqsave(&dev->request_lock, flags);
51243@@ -924,7 +924,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
51244
51245 /* Setup the rndis set */
51246 halt = &request->request_msg.msg.halt_req;
51247- halt->req_id = atomic_inc_return(&dev->new_req_id);
51248+ halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
51249
51250 /* Ignore return since this msg is optional. */
51251 rndis_filter_send_request(dev, request);
51252diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
51253index 94570aa..1a798e1 100644
51254--- a/drivers/net/ifb.c
51255+++ b/drivers/net/ifb.c
51256@@ -253,7 +253,7 @@ static int ifb_validate(struct nlattr *tb[], struct nlattr *data[])
51257 return 0;
51258 }
51259
51260-static struct rtnl_link_ops ifb_link_ops __read_mostly = {
51261+static struct rtnl_link_ops ifb_link_ops = {
51262 .kind = "ifb",
51263 .priv_size = sizeof(struct ifb_private),
51264 .setup = ifb_setup,
51265diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
51266index 207f62e..af3f5e5 100644
51267--- a/drivers/net/ipvlan/ipvlan_core.c
51268+++ b/drivers/net/ipvlan/ipvlan_core.c
51269@@ -466,7 +466,7 @@ static void ipvlan_multicast_enqueue(struct ipvl_port *port,
51270 schedule_work(&port->wq);
51271 } else {
51272 spin_unlock(&port->backlog.lock);
51273- atomic_long_inc(&skb->dev->rx_dropped);
51274+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
51275 kfree_skb(skb);
51276 }
51277 }
51278diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
51279index 9f59f17..52cb38f 100644
51280--- a/drivers/net/macvlan.c
51281+++ b/drivers/net/macvlan.c
51282@@ -335,7 +335,7 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
51283 free_nskb:
51284 kfree_skb(nskb);
51285 err:
51286- atomic_long_inc(&skb->dev->rx_dropped);
51287+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
51288 }
51289
51290 static void macvlan_flush_sources(struct macvlan_port *port,
51291@@ -1480,13 +1480,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
51292 int macvlan_link_register(struct rtnl_link_ops *ops)
51293 {
51294 /* common fields */
51295- ops->priv_size = sizeof(struct macvlan_dev);
51296- ops->validate = macvlan_validate;
51297- ops->maxtype = IFLA_MACVLAN_MAX;
51298- ops->policy = macvlan_policy;
51299- ops->changelink = macvlan_changelink;
51300- ops->get_size = macvlan_get_size;
51301- ops->fill_info = macvlan_fill_info;
51302+ pax_open_kernel();
51303+ *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
51304+ *(void **)&ops->validate = macvlan_validate;
51305+ *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
51306+ *(const void **)&ops->policy = macvlan_policy;
51307+ *(void **)&ops->changelink = macvlan_changelink;
51308+ *(void **)&ops->get_size = macvlan_get_size;
51309+ *(void **)&ops->fill_info = macvlan_fill_info;
51310+ pax_close_kernel();
51311
51312 return rtnl_link_register(ops);
51313 };
51314@@ -1572,7 +1574,7 @@ static int macvlan_device_event(struct notifier_block *unused,
51315 return NOTIFY_DONE;
51316 }
51317
51318-static struct notifier_block macvlan_notifier_block __read_mostly = {
51319+static struct notifier_block macvlan_notifier_block = {
51320 .notifier_call = macvlan_device_event,
51321 };
51322
51323diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
51324index 248478c..05e8467 100644
51325--- a/drivers/net/macvtap.c
51326+++ b/drivers/net/macvtap.c
51327@@ -485,7 +485,7 @@ static void macvtap_setup(struct net_device *dev)
51328 dev->tx_queue_len = TUN_READQ_SIZE;
51329 }
51330
51331-static struct rtnl_link_ops macvtap_link_ops __read_mostly = {
51332+static struct rtnl_link_ops macvtap_link_ops = {
51333 .kind = "macvtap",
51334 .setup = macvtap_setup,
51335 .newlink = macvtap_newlink,
51336@@ -1090,7 +1090,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
51337
51338 ret = 0;
51339 u = q->flags;
51340- if (copy_to_user(&ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
51341+ if (copy_to_user(ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
51342 put_user(u, &ifr->ifr_flags))
51343 ret = -EFAULT;
51344 macvtap_put_vlan(vlan);
51345@@ -1308,7 +1308,7 @@ static int macvtap_device_event(struct notifier_block *unused,
51346 return NOTIFY_DONE;
51347 }
51348
51349-static struct notifier_block macvtap_notifier_block __read_mostly = {
51350+static struct notifier_block macvtap_notifier_block = {
51351 .notifier_call = macvtap_device_event,
51352 };
51353
51354diff --git a/drivers/net/nlmon.c b/drivers/net/nlmon.c
51355index 34924df..a747360 100644
51356--- a/drivers/net/nlmon.c
51357+++ b/drivers/net/nlmon.c
51358@@ -154,7 +154,7 @@ static int nlmon_validate(struct nlattr *tb[], struct nlattr *data[])
51359 return 0;
51360 }
51361
51362-static struct rtnl_link_ops nlmon_link_ops __read_mostly = {
51363+static struct rtnl_link_ops nlmon_link_ops = {
51364 .kind = "nlmon",
51365 .priv_size = sizeof(struct nlmon),
51366 .setup = nlmon_setup,
51367diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
51368index 55f0178..6220e93 100644
51369--- a/drivers/net/phy/phy_device.c
51370+++ b/drivers/net/phy/phy_device.c
51371@@ -218,7 +218,7 @@ EXPORT_SYMBOL(phy_device_create);
51372 * zero on success.
51373 *
51374 */
51375-static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
51376+static int get_phy_c45_ids(struct mii_bus *bus, int addr, int *phy_id,
51377 struct phy_c45_device_ids *c45_ids) {
51378 int phy_reg;
51379 int i, reg_addr;
51380@@ -296,7 +296,7 @@ retry: reg_addr = MII_ADDR_C45 | i << 16 | MDIO_DEVS2;
51381 * its return value is in turn returned.
51382 *
51383 */
51384-static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
51385+static int get_phy_id(struct mii_bus *bus, int addr, int *phy_id,
51386 bool is_c45, struct phy_c45_device_ids *c45_ids)
51387 {
51388 int phy_reg;
51389@@ -334,7 +334,7 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
51390 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
51391 {
51392 struct phy_c45_device_ids c45_ids = {0};
51393- u32 phy_id = 0;
51394+ int phy_id = 0;
51395 int r;
51396
51397 r = get_phy_id(bus, addr, &phy_id, is_c45, &c45_ids);
51398diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
51399index 487be20..f4c87bc 100644
51400--- a/drivers/net/ppp/ppp_generic.c
51401+++ b/drivers/net/ppp/ppp_generic.c
51402@@ -1035,7 +1035,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
51403 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
51404 struct ppp_stats stats;
51405 struct ppp_comp_stats cstats;
51406- char *vers;
51407
51408 switch (cmd) {
51409 case SIOCGPPPSTATS:
51410@@ -1057,8 +1056,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
51411 break;
51412
51413 case SIOCGPPPVER:
51414- vers = PPP_VERSION;
51415- if (copy_to_user(addr, vers, strlen(vers) + 1))
51416+ if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
51417 break;
51418 err = 0;
51419 break;
51420diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
51421index 079f7ad..7e59810 100644
51422--- a/drivers/net/slip/slhc.c
51423+++ b/drivers/net/slip/slhc.c
51424@@ -94,6 +94,9 @@ slhc_init(int rslots, int tslots)
51425 register struct cstate *ts;
51426 struct slcompress *comp;
51427
51428+ if (rslots <= 0 || tslots <= 0 || rslots >= 256 || tslots >= 256)
51429+ goto out_fail;
51430+
51431 comp = kzalloc(sizeof(struct slcompress), GFP_KERNEL);
51432 if (! comp)
51433 goto out_fail;
51434@@ -487,7 +490,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
51435 register struct tcphdr *thp;
51436 register struct iphdr *ip;
51437 register struct cstate *cs;
51438- int len, hdrlen;
51439+ long len, hdrlen;
51440 unsigned char *cp = icp;
51441
51442 /* We've got a compressed packet; read the change byte */
51443diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
51444index daa054b..07d6b98 100644
51445--- a/drivers/net/team/team.c
51446+++ b/drivers/net/team/team.c
51447@@ -2107,7 +2107,7 @@ static unsigned int team_get_num_rx_queues(void)
51448 return TEAM_DEFAULT_NUM_RX_QUEUES;
51449 }
51450
51451-static struct rtnl_link_ops team_link_ops __read_mostly = {
51452+static struct rtnl_link_ops team_link_ops = {
51453 .kind = DRV_NAME,
51454 .priv_size = sizeof(struct team),
51455 .setup = team_setup,
51456@@ -2897,7 +2897,7 @@ static int team_device_event(struct notifier_block *unused,
51457 return NOTIFY_DONE;
51458 }
51459
51460-static struct notifier_block team_notifier_block __read_mostly = {
51461+static struct notifier_block team_notifier_block = {
51462 .notifier_call = team_device_event,
51463 };
51464
51465diff --git a/drivers/net/tun.c b/drivers/net/tun.c
51466index 06a0394..1756d18 100644
51467--- a/drivers/net/tun.c
51468+++ b/drivers/net/tun.c
51469@@ -1472,7 +1472,7 @@ static int tun_validate(struct nlattr *tb[], struct nlattr *data[])
51470 return -EINVAL;
51471 }
51472
51473-static struct rtnl_link_ops tun_link_ops __read_mostly = {
51474+static struct rtnl_link_ops tun_link_ops = {
51475 .kind = DRV_NAME,
51476 .priv_size = sizeof(struct tun_struct),
51477 .setup = tun_setup,
51478@@ -1871,7 +1871,7 @@ unlock:
51479 }
51480
51481 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
51482- unsigned long arg, int ifreq_len)
51483+ unsigned long arg, size_t ifreq_len)
51484 {
51485 struct tun_file *tfile = file->private_data;
51486 struct tun_struct *tun;
51487@@ -1885,6 +1885,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
51488 int le;
51489 int ret;
51490
51491+ if (ifreq_len > sizeof ifr)
51492+ return -EFAULT;
51493+
51494 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
51495 if (copy_from_user(&ifr, argp, ifreq_len))
51496 return -EFAULT;
51497diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
51498index 111d907..1ee643e 100644
51499--- a/drivers/net/usb/hso.c
51500+++ b/drivers/net/usb/hso.c
51501@@ -70,7 +70,7 @@
51502 #include <asm/byteorder.h>
51503 #include <linux/serial_core.h>
51504 #include <linux/serial.h>
51505-
51506+#include <asm/local.h>
51507
51508 #define MOD_AUTHOR "Option Wireless"
51509 #define MOD_DESCRIPTION "USB High Speed Option driver"
51510@@ -1183,7 +1183,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
51511 struct urb *urb;
51512
51513 urb = serial->rx_urb[0];
51514- if (serial->port.count > 0) {
51515+ if (atomic_read(&serial->port.count) > 0) {
51516 count = put_rxbuf_data(urb, serial);
51517 if (count == -1)
51518 return;
51519@@ -1221,7 +1221,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
51520 DUMP1(urb->transfer_buffer, urb->actual_length);
51521
51522 /* Anyone listening? */
51523- if (serial->port.count == 0)
51524+ if (atomic_read(&serial->port.count) == 0)
51525 return;
51526
51527 if (serial->parent->port_spec & HSO_INFO_CRC_BUG)
51528@@ -1282,8 +1282,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
51529 tty_port_tty_set(&serial->port, tty);
51530
51531 /* check for port already opened, if not set the termios */
51532- serial->port.count++;
51533- if (serial->port.count == 1) {
51534+ if (atomic_inc_return(&serial->port.count) == 1) {
51535 serial->rx_state = RX_IDLE;
51536 /* Force default termio settings */
51537 _hso_serial_set_termios(tty, NULL);
51538@@ -1293,7 +1292,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
51539 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
51540 if (result) {
51541 hso_stop_serial_device(serial->parent);
51542- serial->port.count--;
51543+ atomic_dec(&serial->port.count);
51544 } else {
51545 kref_get(&serial->parent->ref);
51546 }
51547@@ -1331,10 +1330,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
51548
51549 /* reset the rts and dtr */
51550 /* do the actual close */
51551- serial->port.count--;
51552+ atomic_dec(&serial->port.count);
51553
51554- if (serial->port.count <= 0) {
51555- serial->port.count = 0;
51556+ if (atomic_read(&serial->port.count) <= 0) {
51557+ atomic_set(&serial->port.count, 0);
51558 tty_port_tty_set(&serial->port, NULL);
51559 if (!usb_gone)
51560 hso_stop_serial_device(serial->parent);
51561@@ -1417,7 +1416,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
51562
51563 /* the actual setup */
51564 spin_lock_irqsave(&serial->serial_lock, flags);
51565- if (serial->port.count)
51566+ if (atomic_read(&serial->port.count))
51567 _hso_serial_set_termios(tty, old);
51568 else
51569 tty->termios = *old;
51570@@ -1891,7 +1890,7 @@ static void intr_callback(struct urb *urb)
51571 D1("Pending read interrupt on port %d\n", i);
51572 spin_lock(&serial->serial_lock);
51573 if (serial->rx_state == RX_IDLE &&
51574- serial->port.count > 0) {
51575+ atomic_read(&serial->port.count) > 0) {
51576 /* Setup and send a ctrl req read on
51577 * port i */
51578 if (!serial->rx_urb_filled[0]) {
51579@@ -3058,7 +3057,7 @@ static int hso_resume(struct usb_interface *iface)
51580 /* Start all serial ports */
51581 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
51582 if (serial_table[i] && (serial_table[i]->interface == iface)) {
51583- if (dev2ser(serial_table[i])->port.count) {
51584+ if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
51585 result =
51586 hso_start_serial_device(serial_table[i], GFP_NOIO);
51587 hso_kick_transmit(dev2ser(serial_table[i]));
51588diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
51589index ad8cbc6..de80b09 100644
51590--- a/drivers/net/usb/r8152.c
51591+++ b/drivers/net/usb/r8152.c
51592@@ -603,7 +603,7 @@ struct r8152 {
51593 void (*unload)(struct r8152 *);
51594 int (*eee_get)(struct r8152 *, struct ethtool_eee *);
51595 int (*eee_set)(struct r8152 *, struct ethtool_eee *);
51596- } rtl_ops;
51597+ } __no_const rtl_ops;
51598
51599 int intr_interval;
51600 u32 saved_wolopts;
51601diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
51602index a2515887..6d13233 100644
51603--- a/drivers/net/usb/sierra_net.c
51604+++ b/drivers/net/usb/sierra_net.c
51605@@ -51,7 +51,7 @@ static const char driver_name[] = "sierra_net";
51606 /* atomic counter partially included in MAC address to make sure 2 devices
51607 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
51608 */
51609-static atomic_t iface_counter = ATOMIC_INIT(0);
51610+static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
51611
51612 /*
51613 * SYNC Timer Delay definition used to set the expiry time
51614@@ -697,7 +697,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
51615 dev->net->netdev_ops = &sierra_net_device_ops;
51616
51617 /* change MAC addr to include, ifacenum, and to be unique */
51618- dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
51619+ dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
51620 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
51621
51622 /* we will have to manufacture ethernet headers, prepare template */
51623diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
51624index 237f8e5..8dccb91 100644
51625--- a/drivers/net/virtio_net.c
51626+++ b/drivers/net/virtio_net.c
51627@@ -48,7 +48,7 @@ module_param(gso, bool, 0444);
51628 #define RECEIVE_AVG_WEIGHT 64
51629
51630 /* Minimum alignment for mergeable packet buffers. */
51631-#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, 256)
51632+#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, 256UL)
51633
51634 #define VIRTNET_DRIVER_VERSION "1.0.0"
51635
51636diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
51637index 5bc4b1e..d5769f5 100644
51638--- a/drivers/net/vxlan.c
51639+++ b/drivers/net/vxlan.c
51640@@ -2884,7 +2884,7 @@ static struct net *vxlan_get_link_net(const struct net_device *dev)
51641 return vxlan->net;
51642 }
51643
51644-static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
51645+static struct rtnl_link_ops vxlan_link_ops = {
51646 .kind = "vxlan",
51647 .maxtype = IFLA_VXLAN_MAX,
51648 .policy = vxlan_policy,
51649@@ -2932,7 +2932,7 @@ static int vxlan_lowerdev_event(struct notifier_block *unused,
51650 return NOTIFY_DONE;
51651 }
51652
51653-static struct notifier_block vxlan_notifier_block __read_mostly = {
51654+static struct notifier_block vxlan_notifier_block = {
51655 .notifier_call = vxlan_lowerdev_event,
51656 };
51657
51658diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
51659index 5920c99..ff2e4a5 100644
51660--- a/drivers/net/wan/lmc/lmc_media.c
51661+++ b/drivers/net/wan/lmc/lmc_media.c
51662@@ -95,62 +95,63 @@ static inline void write_av9110_bit (lmc_softc_t *, int);
51663 static void write_av9110(lmc_softc_t *, u32, u32, u32, u32, u32);
51664
51665 lmc_media_t lmc_ds3_media = {
51666- lmc_ds3_init, /* special media init stuff */
51667- lmc_ds3_default, /* reset to default state */
51668- lmc_ds3_set_status, /* reset status to state provided */
51669- lmc_dummy_set_1, /* set clock source */
51670- lmc_dummy_set2_1, /* set line speed */
51671- lmc_ds3_set_100ft, /* set cable length */
51672- lmc_ds3_set_scram, /* set scrambler */
51673- lmc_ds3_get_link_status, /* get link status */
51674- lmc_dummy_set_1, /* set link status */
51675- lmc_ds3_set_crc_length, /* set CRC length */
51676- lmc_dummy_set_1, /* set T1 or E1 circuit type */
51677- lmc_ds3_watchdog
51678+ .init = lmc_ds3_init, /* special media init stuff */
51679+ .defaults = lmc_ds3_default, /* reset to default state */
51680+ .set_status = lmc_ds3_set_status, /* reset status to state provided */
51681+ .set_clock_source = lmc_dummy_set_1, /* set clock source */
51682+ .set_speed = lmc_dummy_set2_1, /* set line speed */
51683+ .set_cable_length = lmc_ds3_set_100ft, /* set cable length */
51684+ .set_scrambler = lmc_ds3_set_scram, /* set scrambler */
51685+ .get_link_status = lmc_ds3_get_link_status, /* get link status */
51686+ .set_link_status = lmc_dummy_set_1, /* set link status */
51687+ .set_crc_length = lmc_ds3_set_crc_length, /* set CRC length */
51688+ .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
51689+ .watchdog = lmc_ds3_watchdog
51690 };
51691
51692 lmc_media_t lmc_hssi_media = {
51693- lmc_hssi_init, /* special media init stuff */
51694- lmc_hssi_default, /* reset to default state */
51695- lmc_hssi_set_status, /* reset status to state provided */
51696- lmc_hssi_set_clock, /* set clock source */
51697- lmc_dummy_set2_1, /* set line speed */
51698- lmc_dummy_set_1, /* set cable length */
51699- lmc_dummy_set_1, /* set scrambler */
51700- lmc_hssi_get_link_status, /* get link status */
51701- lmc_hssi_set_link_status, /* set link status */
51702- lmc_hssi_set_crc_length, /* set CRC length */
51703- lmc_dummy_set_1, /* set T1 or E1 circuit type */
51704- lmc_hssi_watchdog
51705+ .init = lmc_hssi_init, /* special media init stuff */
51706+ .defaults = lmc_hssi_default, /* reset to default state */
51707+ .set_status = lmc_hssi_set_status, /* reset status to state provided */
51708+ .set_clock_source = lmc_hssi_set_clock, /* set clock source */
51709+ .set_speed = lmc_dummy_set2_1, /* set line speed */
51710+ .set_cable_length = lmc_dummy_set_1, /* set cable length */
51711+ .set_scrambler = lmc_dummy_set_1, /* set scrambler */
51712+ .get_link_status = lmc_hssi_get_link_status, /* get link status */
51713+ .set_link_status = lmc_hssi_set_link_status, /* set link status */
51714+ .set_crc_length = lmc_hssi_set_crc_length, /* set CRC length */
51715+ .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
51716+ .watchdog = lmc_hssi_watchdog
51717 };
51718
51719-lmc_media_t lmc_ssi_media = { lmc_ssi_init, /* special media init stuff */
51720- lmc_ssi_default, /* reset to default state */
51721- lmc_ssi_set_status, /* reset status to state provided */
51722- lmc_ssi_set_clock, /* set clock source */
51723- lmc_ssi_set_speed, /* set line speed */
51724- lmc_dummy_set_1, /* set cable length */
51725- lmc_dummy_set_1, /* set scrambler */
51726- lmc_ssi_get_link_status, /* get link status */
51727- lmc_ssi_set_link_status, /* set link status */
51728- lmc_ssi_set_crc_length, /* set CRC length */
51729- lmc_dummy_set_1, /* set T1 or E1 circuit type */
51730- lmc_ssi_watchdog
51731+lmc_media_t lmc_ssi_media = {
51732+ .init = lmc_ssi_init, /* special media init stuff */
51733+ .defaults = lmc_ssi_default, /* reset to default state */
51734+ .set_status = lmc_ssi_set_status, /* reset status to state provided */
51735+ .set_clock_source = lmc_ssi_set_clock, /* set clock source */
51736+ .set_speed = lmc_ssi_set_speed, /* set line speed */
51737+ .set_cable_length = lmc_dummy_set_1, /* set cable length */
51738+ .set_scrambler = lmc_dummy_set_1, /* set scrambler */
51739+ .get_link_status = lmc_ssi_get_link_status, /* get link status */
51740+ .set_link_status = lmc_ssi_set_link_status, /* set link status */
51741+ .set_crc_length = lmc_ssi_set_crc_length, /* set CRC length */
51742+ .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
51743+ .watchdog = lmc_ssi_watchdog
51744 };
51745
51746 lmc_media_t lmc_t1_media = {
51747- lmc_t1_init, /* special media init stuff */
51748- lmc_t1_default, /* reset to default state */
51749- lmc_t1_set_status, /* reset status to state provided */
51750- lmc_t1_set_clock, /* set clock source */
51751- lmc_dummy_set2_1, /* set line speed */
51752- lmc_dummy_set_1, /* set cable length */
51753- lmc_dummy_set_1, /* set scrambler */
51754- lmc_t1_get_link_status, /* get link status */
51755- lmc_dummy_set_1, /* set link status */
51756- lmc_t1_set_crc_length, /* set CRC length */
51757- lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */
51758- lmc_t1_watchdog
51759+ .init = lmc_t1_init, /* special media init stuff */
51760+ .defaults = lmc_t1_default, /* reset to default state */
51761+ .set_status = lmc_t1_set_status, /* reset status to state provided */
51762+ .set_clock_source = lmc_t1_set_clock, /* set clock source */
51763+ .set_speed = lmc_dummy_set2_1, /* set line speed */
51764+ .set_cable_length = lmc_dummy_set_1, /* set cable length */
51765+ .set_scrambler = lmc_dummy_set_1, /* set scrambler */
51766+ .get_link_status = lmc_t1_get_link_status, /* get link status */
51767+ .set_link_status = lmc_dummy_set_1, /* set link status */
51768+ .set_crc_length = lmc_t1_set_crc_length, /* set CRC length */
51769+ .set_circuit_type = lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */
51770+ .watchdog = lmc_t1_watchdog
51771 };
51772
51773 static void
51774diff --git a/drivers/net/wan/z85230.c b/drivers/net/wan/z85230.c
51775index 2f0bd69..e46ed7b 100644
51776--- a/drivers/net/wan/z85230.c
51777+++ b/drivers/net/wan/z85230.c
51778@@ -485,9 +485,9 @@ static void z8530_status(struct z8530_channel *chan)
51779
51780 struct z8530_irqhandler z8530_sync =
51781 {
51782- z8530_rx,
51783- z8530_tx,
51784- z8530_status
51785+ .rx = z8530_rx,
51786+ .tx = z8530_tx,
51787+ .status = z8530_status
51788 };
51789
51790 EXPORT_SYMBOL(z8530_sync);
51791@@ -605,15 +605,15 @@ static void z8530_dma_status(struct z8530_channel *chan)
51792 }
51793
51794 static struct z8530_irqhandler z8530_dma_sync = {
51795- z8530_dma_rx,
51796- z8530_dma_tx,
51797- z8530_dma_status
51798+ .rx = z8530_dma_rx,
51799+ .tx = z8530_dma_tx,
51800+ .status = z8530_dma_status
51801 };
51802
51803 static struct z8530_irqhandler z8530_txdma_sync = {
51804- z8530_rx,
51805- z8530_dma_tx,
51806- z8530_dma_status
51807+ .rx = z8530_rx,
51808+ .tx = z8530_dma_tx,
51809+ .status = z8530_dma_status
51810 };
51811
51812 /**
51813@@ -680,9 +680,9 @@ static void z8530_status_clear(struct z8530_channel *chan)
51814
51815 struct z8530_irqhandler z8530_nop=
51816 {
51817- z8530_rx_clear,
51818- z8530_tx_clear,
51819- z8530_status_clear
51820+ .rx = z8530_rx_clear,
51821+ .tx = z8530_tx_clear,
51822+ .status = z8530_status_clear
51823 };
51824
51825
51826diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
51827index 0b60295..b8bfa5b 100644
51828--- a/drivers/net/wimax/i2400m/rx.c
51829+++ b/drivers/net/wimax/i2400m/rx.c
51830@@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
51831 if (i2400m->rx_roq == NULL)
51832 goto error_roq_alloc;
51833
51834- rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
51835+ rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
51836 GFP_KERNEL);
51837 if (rd == NULL) {
51838 result = -ENOMEM;
51839diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
51840index d0c97c2..108f59b 100644
51841--- a/drivers/net/wireless/airo.c
51842+++ b/drivers/net/wireless/airo.c
51843@@ -7846,7 +7846,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
51844 struct airo_info *ai = dev->ml_priv;
51845 int ridcode;
51846 int enabled;
51847- static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
51848+ int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
51849 unsigned char *iobuf;
51850
51851 /* Only super-user can write RIDs */
51852diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
51853index dab2513..4c4b65d 100644
51854--- a/drivers/net/wireless/at76c50x-usb.c
51855+++ b/drivers/net/wireless/at76c50x-usb.c
51856@@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
51857 }
51858
51859 /* Convert timeout from the DFU status to jiffies */
51860-static inline unsigned long at76_get_timeout(struct dfu_status *s)
51861+static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
51862 {
51863 return msecs_to_jiffies((s->poll_timeout[2] << 16)
51864 | (s->poll_timeout[1] << 8)
51865diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c
51866index e508c65..fb0dbae 100644
51867--- a/drivers/net/wireless/ath/ath10k/ce.c
51868+++ b/drivers/net/wireless/ath/ath10k/ce.c
51869@@ -896,7 +896,7 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar,
51870 return 0;
51871 }
51872
51873-static struct ath10k_ce_ring *
51874+static struct ath10k_ce_ring * __intentional_overflow(-1)
51875 ath10k_ce_alloc_src_ring(struct ath10k *ar, unsigned int ce_id,
51876 const struct ce_attr *attr)
51877 {
51878diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
51879index 32d9ff1..0952b33 100644
51880--- a/drivers/net/wireless/ath/ath10k/htc.c
51881+++ b/drivers/net/wireless/ath/ath10k/htc.c
51882@@ -841,7 +841,10 @@ int ath10k_htc_start(struct ath10k_htc *htc)
51883 /* registered target arrival callback from the HIF layer */
51884 int ath10k_htc_init(struct ath10k *ar)
51885 {
51886- struct ath10k_hif_cb htc_callbacks;
51887+ static struct ath10k_hif_cb htc_callbacks = {
51888+ .rx_completion = ath10k_htc_rx_completion_handler,
51889+ .tx_completion = ath10k_htc_tx_completion_handler,
51890+ };
51891 struct ath10k_htc_ep *ep = NULL;
51892 struct ath10k_htc *htc = &ar->htc;
51893
51894@@ -850,8 +853,6 @@ int ath10k_htc_init(struct ath10k *ar)
51895 ath10k_htc_reset_endpoint_states(htc);
51896
51897 /* setup HIF layer callbacks */
51898- htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
51899- htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
51900 htc->ar = ar;
51901
51902 /* Get HIF default pipe for HTC message exchange */
51903diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
51904index 527179c..a890150 100644
51905--- a/drivers/net/wireless/ath/ath10k/htc.h
51906+++ b/drivers/net/wireless/ath/ath10k/htc.h
51907@@ -270,13 +270,13 @@ enum ath10k_htc_ep_id {
51908
51909 struct ath10k_htc_ops {
51910 void (*target_send_suspend_complete)(struct ath10k *ar);
51911-};
51912+} __no_const;
51913
51914 struct ath10k_htc_ep_ops {
51915 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
51916 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
51917 void (*ep_tx_credits)(struct ath10k *);
51918-};
51919+} __no_const;
51920
51921 /* service connection information */
51922 struct ath10k_htc_svc_conn_req {
51923diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
51924index fee0cad..a7a3b63 100644
51925--- a/drivers/net/wireless/ath/ath9k/Kconfig
51926+++ b/drivers/net/wireless/ath/ath9k/Kconfig
51927@@ -3,7 +3,6 @@ config ATH9K_HW
51928 config ATH9K_COMMON
51929 tristate
51930 select ATH_COMMON
51931- select DEBUG_FS
51932 select RELAY
51933 config ATH9K_DFS_DEBUGFS
51934 def_bool y
51935diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
51936index f816909..e56cd8b 100644
51937--- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
51938+++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
51939@@ -220,8 +220,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51940 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
51941 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
51942
51943- ACCESS_ONCE(ads->ds_link) = i->link;
51944- ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
51945+ ACCESS_ONCE_RW(ads->ds_link) = i->link;
51946+ ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
51947
51948 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
51949 ctl6 = SM(i->keytype, AR_EncrType);
51950@@ -235,26 +235,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51951
51952 if ((i->is_first || i->is_last) &&
51953 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
51954- ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
51955+ ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
51956 | set11nTries(i->rates, 1)
51957 | set11nTries(i->rates, 2)
51958 | set11nTries(i->rates, 3)
51959 | (i->dur_update ? AR_DurUpdateEna : 0)
51960 | SM(0, AR_BurstDur);
51961
51962- ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
51963+ ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
51964 | set11nRate(i->rates, 1)
51965 | set11nRate(i->rates, 2)
51966 | set11nRate(i->rates, 3);
51967 } else {
51968- ACCESS_ONCE(ads->ds_ctl2) = 0;
51969- ACCESS_ONCE(ads->ds_ctl3) = 0;
51970+ ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
51971+ ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
51972 }
51973
51974 if (!i->is_first) {
51975- ACCESS_ONCE(ads->ds_ctl0) = 0;
51976- ACCESS_ONCE(ads->ds_ctl1) = ctl1;
51977- ACCESS_ONCE(ads->ds_ctl6) = ctl6;
51978+ ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
51979+ ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
51980+ ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
51981 return;
51982 }
51983
51984@@ -279,7 +279,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51985 break;
51986 }
51987
51988- ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
51989+ ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
51990 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
51991 | SM(i->txpower[0], AR_XmitPower0)
51992 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
51993@@ -289,27 +289,27 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
51994 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
51995 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
51996
51997- ACCESS_ONCE(ads->ds_ctl1) = ctl1;
51998- ACCESS_ONCE(ads->ds_ctl6) = ctl6;
51999+ ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
52000+ ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
52001
52002 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
52003 return;
52004
52005- ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
52006+ ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
52007 | set11nPktDurRTSCTS(i->rates, 1);
52008
52009- ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
52010+ ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
52011 | set11nPktDurRTSCTS(i->rates, 3);
52012
52013- ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
52014+ ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
52015 | set11nRateFlags(i->rates, 1)
52016 | set11nRateFlags(i->rates, 2)
52017 | set11nRateFlags(i->rates, 3)
52018 | SM(i->rtscts_rate, AR_RTSCTSRate);
52019
52020- ACCESS_ONCE(ads->ds_ctl9) = SM(i->txpower[1], AR_XmitPower1);
52021- ACCESS_ONCE(ads->ds_ctl10) = SM(i->txpower[2], AR_XmitPower2);
52022- ACCESS_ONCE(ads->ds_ctl11) = SM(i->txpower[3], AR_XmitPower3);
52023+ ACCESS_ONCE_RW(ads->ds_ctl9) = SM(i->txpower[1], AR_XmitPower1);
52024+ ACCESS_ONCE_RW(ads->ds_ctl10) = SM(i->txpower[2], AR_XmitPower2);
52025+ ACCESS_ONCE_RW(ads->ds_ctl11) = SM(i->txpower[3], AR_XmitPower3);
52026 }
52027
52028 static int ar9002_hw_proc_txdesc(struct ath_hw *ah, void *ds,
52029diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
52030index da84b70..83e4978 100644
52031--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
52032+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
52033@@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
52034 (i->qcu << AR_TxQcuNum_S) | desc_len;
52035
52036 checksum += val;
52037- ACCESS_ONCE(ads->info) = val;
52038+ ACCESS_ONCE_RW(ads->info) = val;
52039
52040 checksum += i->link;
52041- ACCESS_ONCE(ads->link) = i->link;
52042+ ACCESS_ONCE_RW(ads->link) = i->link;
52043
52044 checksum += i->buf_addr[0];
52045- ACCESS_ONCE(ads->data0) = i->buf_addr[0];
52046+ ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
52047 checksum += i->buf_addr[1];
52048- ACCESS_ONCE(ads->data1) = i->buf_addr[1];
52049+ ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
52050 checksum += i->buf_addr[2];
52051- ACCESS_ONCE(ads->data2) = i->buf_addr[2];
52052+ ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
52053 checksum += i->buf_addr[3];
52054- ACCESS_ONCE(ads->data3) = i->buf_addr[3];
52055+ ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
52056
52057 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
52058- ACCESS_ONCE(ads->ctl3) = val;
52059+ ACCESS_ONCE_RW(ads->ctl3) = val;
52060 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
52061- ACCESS_ONCE(ads->ctl5) = val;
52062+ ACCESS_ONCE_RW(ads->ctl5) = val;
52063 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
52064- ACCESS_ONCE(ads->ctl7) = val;
52065+ ACCESS_ONCE_RW(ads->ctl7) = val;
52066 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
52067- ACCESS_ONCE(ads->ctl9) = val;
52068+ ACCESS_ONCE_RW(ads->ctl9) = val;
52069
52070 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
52071- ACCESS_ONCE(ads->ctl10) = checksum;
52072+ ACCESS_ONCE_RW(ads->ctl10) = checksum;
52073
52074 if (i->is_first || i->is_last) {
52075- ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
52076+ ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
52077 | set11nTries(i->rates, 1)
52078 | set11nTries(i->rates, 2)
52079 | set11nTries(i->rates, 3)
52080 | (i->dur_update ? AR_DurUpdateEna : 0)
52081 | SM(0, AR_BurstDur);
52082
52083- ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
52084+ ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
52085 | set11nRate(i->rates, 1)
52086 | set11nRate(i->rates, 2)
52087 | set11nRate(i->rates, 3);
52088 } else {
52089- ACCESS_ONCE(ads->ctl13) = 0;
52090- ACCESS_ONCE(ads->ctl14) = 0;
52091+ ACCESS_ONCE_RW(ads->ctl13) = 0;
52092+ ACCESS_ONCE_RW(ads->ctl14) = 0;
52093 }
52094
52095 ads->ctl20 = 0;
52096@@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
52097
52098 ctl17 = SM(i->keytype, AR_EncrType);
52099 if (!i->is_first) {
52100- ACCESS_ONCE(ads->ctl11) = 0;
52101- ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
52102- ACCESS_ONCE(ads->ctl15) = 0;
52103- ACCESS_ONCE(ads->ctl16) = 0;
52104- ACCESS_ONCE(ads->ctl17) = ctl17;
52105- ACCESS_ONCE(ads->ctl18) = 0;
52106- ACCESS_ONCE(ads->ctl19) = 0;
52107+ ACCESS_ONCE_RW(ads->ctl11) = 0;
52108+ ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
52109+ ACCESS_ONCE_RW(ads->ctl15) = 0;
52110+ ACCESS_ONCE_RW(ads->ctl16) = 0;
52111+ ACCESS_ONCE_RW(ads->ctl17) = ctl17;
52112+ ACCESS_ONCE_RW(ads->ctl18) = 0;
52113+ ACCESS_ONCE_RW(ads->ctl19) = 0;
52114 return;
52115 }
52116
52117- ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
52118+ ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
52119 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
52120 | SM(i->txpower[0], AR_XmitPower0)
52121 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
52122@@ -135,26 +135,26 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
52123 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
52124 ctl12 |= SM(val, AR_PAPRDChainMask);
52125
52126- ACCESS_ONCE(ads->ctl12) = ctl12;
52127- ACCESS_ONCE(ads->ctl17) = ctl17;
52128+ ACCESS_ONCE_RW(ads->ctl12) = ctl12;
52129+ ACCESS_ONCE_RW(ads->ctl17) = ctl17;
52130
52131- ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
52132+ ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
52133 | set11nPktDurRTSCTS(i->rates, 1);
52134
52135- ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
52136+ ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
52137 | set11nPktDurRTSCTS(i->rates, 3);
52138
52139- ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
52140+ ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
52141 | set11nRateFlags(i->rates, 1)
52142 | set11nRateFlags(i->rates, 2)
52143 | set11nRateFlags(i->rates, 3)
52144 | SM(i->rtscts_rate, AR_RTSCTSRate);
52145
52146- ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
52147+ ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
52148
52149- ACCESS_ONCE(ads->ctl20) = SM(i->txpower[1], AR_XmitPower1);
52150- ACCESS_ONCE(ads->ctl21) = SM(i->txpower[2], AR_XmitPower2);
52151- ACCESS_ONCE(ads->ctl22) = SM(i->txpower[3], AR_XmitPower3);
52152+ ACCESS_ONCE_RW(ads->ctl20) = SM(i->txpower[1], AR_XmitPower1);
52153+ ACCESS_ONCE_RW(ads->ctl21) = SM(i->txpower[2], AR_XmitPower2);
52154+ ACCESS_ONCE_RW(ads->ctl22) = SM(i->txpower[3], AR_XmitPower3);
52155 }
52156
52157 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
52158diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
52159index e8454db..c7b26fe 100644
52160--- a/drivers/net/wireless/ath/ath9k/hw.h
52161+++ b/drivers/net/wireless/ath/ath9k/hw.h
52162@@ -671,7 +671,7 @@ struct ath_hw_private_ops {
52163 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
52164 bool (*is_aic_enabled)(struct ath_hw *ah);
52165 #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
52166-};
52167+} __no_const;
52168
52169 /**
52170 * struct ath_spec_scan - parameters for Atheros spectral scan
52171@@ -747,7 +747,7 @@ struct ath_hw_ops {
52172 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
52173 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
52174 #endif
52175-};
52176+} __no_const;
52177
52178 struct ath_nf_limits {
52179 s16 max;
52180diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
52181index cfd45cb..6de2be6 100644
52182--- a/drivers/net/wireless/ath/ath9k/main.c
52183+++ b/drivers/net/wireless/ath/ath9k/main.c
52184@@ -2574,16 +2574,18 @@ void ath9k_fill_chanctx_ops(void)
52185 if (!ath9k_is_chanctx_enabled())
52186 return;
52187
52188- ath9k_ops.hw_scan = ath9k_hw_scan;
52189- ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan;
52190- ath9k_ops.remain_on_channel = ath9k_remain_on_channel;
52191- ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel;
52192- ath9k_ops.add_chanctx = ath9k_add_chanctx;
52193- ath9k_ops.remove_chanctx = ath9k_remove_chanctx;
52194- ath9k_ops.change_chanctx = ath9k_change_chanctx;
52195- ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx;
52196- ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx;
52197- ath9k_ops.mgd_prepare_tx = ath9k_mgd_prepare_tx;
52198+ pax_open_kernel();
52199+ *(void **)&ath9k_ops.hw_scan = ath9k_hw_scan;
52200+ *(void **)&ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan;
52201+ *(void **)&ath9k_ops.remain_on_channel = ath9k_remain_on_channel;
52202+ *(void **)&ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel;
52203+ *(void **)&ath9k_ops.add_chanctx = ath9k_add_chanctx;
52204+ *(void **)&ath9k_ops.remove_chanctx = ath9k_remove_chanctx;
52205+ *(void **)&ath9k_ops.change_chanctx = ath9k_change_chanctx;
52206+ *(void **)&ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx;
52207+ *(void **)&ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx;
52208+ *(void **)&ath9k_ops.mgd_prepare_tx = ath9k_mgd_prepare_tx;
52209+ pax_close_kernel();
52210 }
52211
52212 #endif
52213diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
52214index 058a9f2..d5cb1ba 100644
52215--- a/drivers/net/wireless/b43/phy_lp.c
52216+++ b/drivers/net/wireless/b43/phy_lp.c
52217@@ -2502,7 +2502,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
52218 {
52219 struct ssb_bus *bus = dev->dev->sdev->bus;
52220
52221- static const struct b206x_channel *chandata = NULL;
52222+ const struct b206x_channel *chandata = NULL;
52223 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
52224 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
52225 u16 old_comm15, scale;
52226diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
52227index 7f4cb69..16c0825 100644
52228--- a/drivers/net/wireless/iwlegacy/3945-mac.c
52229+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
52230@@ -3633,7 +3633,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
52231 */
52232 if (il3945_mod_params.disable_hw_scan) {
52233 D_INFO("Disabling hw_scan\n");
52234- il3945_mac_ops.hw_scan = NULL;
52235+ pax_open_kernel();
52236+ *(void **)&il3945_mac_ops.hw_scan = NULL;
52237+ pax_close_kernel();
52238 }
52239
52240 D_INFO("*** LOAD DRIVER ***\n");
52241diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
52242index 0ffb6ff..c0b7f0e 100644
52243--- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
52244+++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
52245@@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
52246 {
52247 struct iwl_priv *priv = file->private_data;
52248 char buf[64];
52249- int buf_size;
52250+ size_t buf_size;
52251 u32 offset, len;
52252
52253 memset(buf, 0, sizeof(buf));
52254@@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
52255 struct iwl_priv *priv = file->private_data;
52256
52257 char buf[8];
52258- int buf_size;
52259+ size_t buf_size;
52260 u32 reset_flag;
52261
52262 memset(buf, 0, sizeof(buf));
52263@@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
52264 {
52265 struct iwl_priv *priv = file->private_data;
52266 char buf[8];
52267- int buf_size;
52268+ size_t buf_size;
52269 int ht40;
52270
52271 memset(buf, 0, sizeof(buf));
52272@@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
52273 {
52274 struct iwl_priv *priv = file->private_data;
52275 char buf[8];
52276- int buf_size;
52277+ size_t buf_size;
52278 int value;
52279
52280 memset(buf, 0, sizeof(buf));
52281@@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
52282 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
52283 DEBUGFS_READ_FILE_OPS(current_sleep_command);
52284
52285-static const char *fmt_value = " %-30s %10u\n";
52286-static const char *fmt_hex = " %-30s 0x%02X\n";
52287-static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
52288-static const char *fmt_header =
52289+static const char fmt_value[] = " %-30s %10u\n";
52290+static const char fmt_hex[] = " %-30s 0x%02X\n";
52291+static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
52292+static const char fmt_header[] =
52293 "%-32s current cumulative delta max\n";
52294
52295 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
52296@@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
52297 {
52298 struct iwl_priv *priv = file->private_data;
52299 char buf[8];
52300- int buf_size;
52301+ size_t buf_size;
52302 int clear;
52303
52304 memset(buf, 0, sizeof(buf));
52305@@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
52306 {
52307 struct iwl_priv *priv = file->private_data;
52308 char buf[8];
52309- int buf_size;
52310+ size_t buf_size;
52311 int trace;
52312
52313 memset(buf, 0, sizeof(buf));
52314@@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
52315 {
52316 struct iwl_priv *priv = file->private_data;
52317 char buf[8];
52318- int buf_size;
52319+ size_t buf_size;
52320 int missed;
52321
52322 memset(buf, 0, sizeof(buf));
52323@@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
52324
52325 struct iwl_priv *priv = file->private_data;
52326 char buf[8];
52327- int buf_size;
52328+ size_t buf_size;
52329 int plcp;
52330
52331 memset(buf, 0, sizeof(buf));
52332@@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
52333
52334 struct iwl_priv *priv = file->private_data;
52335 char buf[8];
52336- int buf_size;
52337+ size_t buf_size;
52338 int flush;
52339
52340 memset(buf, 0, sizeof(buf));
52341@@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
52342
52343 struct iwl_priv *priv = file->private_data;
52344 char buf[8];
52345- int buf_size;
52346+ size_t buf_size;
52347 int rts;
52348
52349 if (!priv->cfg->ht_params)
52350@@ -2204,7 +2204,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
52351 {
52352 struct iwl_priv *priv = file->private_data;
52353 char buf[8];
52354- int buf_size;
52355+ size_t buf_size;
52356
52357 memset(buf, 0, sizeof(buf));
52358 buf_size = min(count, sizeof(buf) - 1);
52359@@ -2238,7 +2238,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
52360 struct iwl_priv *priv = file->private_data;
52361 u32 event_log_flag;
52362 char buf[8];
52363- int buf_size;
52364+ size_t buf_size;
52365
52366 /* check that the interface is up */
52367 if (!iwl_is_ready(priv))
52368@@ -2292,7 +2292,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
52369 struct iwl_priv *priv = file->private_data;
52370 char buf[8];
52371 u32 calib_disabled;
52372- int buf_size;
52373+ size_t buf_size;
52374
52375 memset(buf, 0, sizeof(buf));
52376 buf_size = min(count, sizeof(buf) - 1);
52377diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
52378index 9e144e7..2f5511a 100644
52379--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
52380+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
52381@@ -1950,7 +1950,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
52382 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
52383
52384 char buf[8];
52385- int buf_size;
52386+ size_t buf_size;
52387 u32 reset_flag;
52388
52389 memset(buf, 0, sizeof(buf));
52390@@ -1971,7 +1971,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
52391 {
52392 struct iwl_trans *trans = file->private_data;
52393 char buf[8];
52394- int buf_size;
52395+ size_t buf_size;
52396 int csr;
52397
52398 memset(buf, 0, sizeof(buf));
52399diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
52400index 99e873d..0d9aab2 100644
52401--- a/drivers/net/wireless/mac80211_hwsim.c
52402+++ b/drivers/net/wireless/mac80211_hwsim.c
52403@@ -3148,20 +3148,20 @@ static int __init init_mac80211_hwsim(void)
52404 if (channels < 1)
52405 return -EINVAL;
52406
52407- mac80211_hwsim_mchan_ops = mac80211_hwsim_ops;
52408- mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan;
52409- mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
52410- mac80211_hwsim_mchan_ops.sw_scan_start = NULL;
52411- mac80211_hwsim_mchan_ops.sw_scan_complete = NULL;
52412- mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc;
52413- mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
52414- mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx;
52415- mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
52416- mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx;
52417- mac80211_hwsim_mchan_ops.assign_vif_chanctx =
52418- mac80211_hwsim_assign_vif_chanctx;
52419- mac80211_hwsim_mchan_ops.unassign_vif_chanctx =
52420- mac80211_hwsim_unassign_vif_chanctx;
52421+ pax_open_kernel();
52422+ memcpy((void *)&mac80211_hwsim_mchan_ops, &mac80211_hwsim_ops, sizeof mac80211_hwsim_mchan_ops);
52423+ *(void **)&mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan;
52424+ *(void **)&mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
52425+ *(void **)&mac80211_hwsim_mchan_ops.sw_scan_start = NULL;
52426+ *(void **)&mac80211_hwsim_mchan_ops.sw_scan_complete = NULL;
52427+ *(void **)&mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc;
52428+ *(void **)&mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
52429+ *(void **)&mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx;
52430+ *(void **)&mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
52431+ *(void **)&mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx;
52432+ *(void **)&mac80211_hwsim_mchan_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
52433+ *(void **)&mac80211_hwsim_mchan_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
52434+ pax_close_kernel();
52435
52436 spin_lock_init(&hwsim_radio_lock);
52437 INIT_LIST_HEAD(&hwsim_radios);
52438diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
52439index 71a825c..ce7d6c3 100644
52440--- a/drivers/net/wireless/rndis_wlan.c
52441+++ b/drivers/net/wireless/rndis_wlan.c
52442@@ -1236,7 +1236,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
52443
52444 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
52445
52446- if (rts_threshold < 0 || rts_threshold > 2347)
52447+ if (rts_threshold > 2347)
52448 rts_threshold = 2347;
52449
52450 tmp = cpu_to_le32(rts_threshold);
52451diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
52452index 9bb398b..b0cc047 100644
52453--- a/drivers/net/wireless/rt2x00/rt2x00.h
52454+++ b/drivers/net/wireless/rt2x00/rt2x00.h
52455@@ -375,7 +375,7 @@ struct rt2x00_intf {
52456 * for hardware which doesn't support hardware
52457 * sequence counting.
52458 */
52459- atomic_t seqno;
52460+ atomic_unchecked_t seqno;
52461 };
52462
52463 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
52464diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
52465index 68b620b..92ecd9e 100644
52466--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
52467+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
52468@@ -224,9 +224,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
52469 * sequence counter given by mac80211.
52470 */
52471 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
52472- seqno = atomic_add_return(0x10, &intf->seqno);
52473+ seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
52474 else
52475- seqno = atomic_read(&intf->seqno);
52476+ seqno = atomic_read_unchecked(&intf->seqno);
52477
52478 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
52479 hdr->seq_ctrl |= cpu_to_le16(seqno);
52480diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
52481index b661f896..ddf7d2b 100644
52482--- a/drivers/net/wireless/ti/wl1251/sdio.c
52483+++ b/drivers/net/wireless/ti/wl1251/sdio.c
52484@@ -282,13 +282,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
52485
52486 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
52487
52488- wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
52489- wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
52490+ pax_open_kernel();
52491+ *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
52492+ *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
52493+ pax_close_kernel();
52494
52495 wl1251_info("using dedicated interrupt line");
52496 } else {
52497- wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
52498- wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
52499+ pax_open_kernel();
52500+ *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
52501+ *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
52502+ pax_close_kernel();
52503
52504 wl1251_info("using SDIO interrupt");
52505 }
52506diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
52507index af0fe2e..d04986b 100644
52508--- a/drivers/net/wireless/ti/wl12xx/main.c
52509+++ b/drivers/net/wireless/ti/wl12xx/main.c
52510@@ -655,7 +655,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
52511 sizeof(wl->conf.mem));
52512
52513 /* read data preparation is only needed by wl127x */
52514- wl->ops->prepare_read = wl127x_prepare_read;
52515+ pax_open_kernel();
52516+ *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
52517+ pax_close_kernel();
52518
52519 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
52520 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
52521@@ -680,7 +682,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
52522 sizeof(wl->conf.mem));
52523
52524 /* read data preparation is only needed by wl127x */
52525- wl->ops->prepare_read = wl127x_prepare_read;
52526+ pax_open_kernel();
52527+ *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
52528+ pax_close_kernel();
52529
52530 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
52531 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
52532diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
52533index 49aca2c..3b9c10c 100644
52534--- a/drivers/net/wireless/ti/wl18xx/main.c
52535+++ b/drivers/net/wireless/ti/wl18xx/main.c
52536@@ -1952,8 +1952,10 @@ static int wl18xx_setup(struct wl1271 *wl)
52537 }
52538
52539 if (!checksum_param) {
52540- wl18xx_ops.set_rx_csum = NULL;
52541- wl18xx_ops.init_vif = NULL;
52542+ pax_open_kernel();
52543+ *(void **)&wl18xx_ops.set_rx_csum = NULL;
52544+ *(void **)&wl18xx_ops.init_vif = NULL;
52545+ pax_close_kernel();
52546 }
52547
52548 /* Enable 11a Band only if we have 5G antennas */
52549diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
52550index a912dc0..a8225ba 100644
52551--- a/drivers/net/wireless/zd1211rw/zd_usb.c
52552+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
52553@@ -385,7 +385,7 @@ static inline void handle_regs_int(struct urb *urb)
52554 {
52555 struct zd_usb *usb = urb->context;
52556 struct zd_usb_interrupt *intr = &usb->intr;
52557- int len;
52558+ unsigned int len;
52559 u16 int_num;
52560
52561 ZD_ASSERT(in_interrupt());
52562diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
52563index ce2e2cf..f81e500 100644
52564--- a/drivers/nfc/nfcwilink.c
52565+++ b/drivers/nfc/nfcwilink.c
52566@@ -497,7 +497,7 @@ static struct nci_ops nfcwilink_ops = {
52567
52568 static int nfcwilink_probe(struct platform_device *pdev)
52569 {
52570- static struct nfcwilink *drv;
52571+ struct nfcwilink *drv;
52572 int rc;
52573 __u32 protocols;
52574
52575diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
52576index 6e82bc42..ab4145c 100644
52577--- a/drivers/of/fdt.c
52578+++ b/drivers/of/fdt.c
52579@@ -1161,7 +1161,9 @@ static int __init of_fdt_raw_init(void)
52580 pr_warn("fdt: not creating '/sys/firmware/fdt': CRC check failed\n");
52581 return 0;
52582 }
52583- of_fdt_raw_attr.size = fdt_totalsize(initial_boot_params);
52584+ pax_open_kernel();
52585+ *(size_t *)&of_fdt_raw_attr.size = fdt_totalsize(initial_boot_params);
52586+ pax_close_kernel();
52587 return sysfs_create_bin_file(firmware_kobj, &of_fdt_raw_attr);
52588 }
52589 late_initcall(of_fdt_raw_init);
52590diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
52591index 82f7000..d6d0447 100644
52592--- a/drivers/oprofile/buffer_sync.c
52593+++ b/drivers/oprofile/buffer_sync.c
52594@@ -345,7 +345,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
52595 if (cookie == NO_COOKIE)
52596 offset = pc;
52597 if (cookie == INVALID_COOKIE) {
52598- atomic_inc(&oprofile_stats.sample_lost_no_mapping);
52599+ atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
52600 offset = pc;
52601 }
52602 if (cookie != last_cookie) {
52603@@ -389,14 +389,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
52604 /* add userspace sample */
52605
52606 if (!mm) {
52607- atomic_inc(&oprofile_stats.sample_lost_no_mm);
52608+ atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
52609 return 0;
52610 }
52611
52612 cookie = lookup_dcookie(mm, s->eip, &offset);
52613
52614 if (cookie == INVALID_COOKIE) {
52615- atomic_inc(&oprofile_stats.sample_lost_no_mapping);
52616+ atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
52617 return 0;
52618 }
52619
52620@@ -554,7 +554,7 @@ void sync_buffer(int cpu)
52621 /* ignore backtraces if failed to add a sample */
52622 if (state == sb_bt_start) {
52623 state = sb_bt_ignore;
52624- atomic_inc(&oprofile_stats.bt_lost_no_mapping);
52625+ atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
52626 }
52627 }
52628 release_mm(mm);
52629diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
52630index c0cc4e7..44d4e54 100644
52631--- a/drivers/oprofile/event_buffer.c
52632+++ b/drivers/oprofile/event_buffer.c
52633@@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
52634 }
52635
52636 if (buffer_pos == buffer_size) {
52637- atomic_inc(&oprofile_stats.event_lost_overflow);
52638+ atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
52639 return;
52640 }
52641
52642diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
52643index ed2c3ec..deda85a 100644
52644--- a/drivers/oprofile/oprof.c
52645+++ b/drivers/oprofile/oprof.c
52646@@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
52647 if (oprofile_ops.switch_events())
52648 return;
52649
52650- atomic_inc(&oprofile_stats.multiplex_counter);
52651+ atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
52652 start_switch_worker();
52653 }
52654
52655diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
52656index 59659ce..6c860a0 100644
52657--- a/drivers/oprofile/oprofile_stats.c
52658+++ b/drivers/oprofile/oprofile_stats.c
52659@@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
52660 cpu_buf->sample_invalid_eip = 0;
52661 }
52662
52663- atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
52664- atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
52665- atomic_set(&oprofile_stats.event_lost_overflow, 0);
52666- atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
52667- atomic_set(&oprofile_stats.multiplex_counter, 0);
52668+ atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
52669+ atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
52670+ atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
52671+ atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
52672+ atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
52673 }
52674
52675
52676diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
52677index 1fc622b..8c48fc3 100644
52678--- a/drivers/oprofile/oprofile_stats.h
52679+++ b/drivers/oprofile/oprofile_stats.h
52680@@ -13,11 +13,11 @@
52681 #include <linux/atomic.h>
52682
52683 struct oprofile_stat_struct {
52684- atomic_t sample_lost_no_mm;
52685- atomic_t sample_lost_no_mapping;
52686- atomic_t bt_lost_no_mapping;
52687- atomic_t event_lost_overflow;
52688- atomic_t multiplex_counter;
52689+ atomic_unchecked_t sample_lost_no_mm;
52690+ atomic_unchecked_t sample_lost_no_mapping;
52691+ atomic_unchecked_t bt_lost_no_mapping;
52692+ atomic_unchecked_t event_lost_overflow;
52693+ atomic_unchecked_t multiplex_counter;
52694 };
52695
52696 extern struct oprofile_stat_struct oprofile_stats;
52697diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
52698index dd92c5e..dfc04b5 100644
52699--- a/drivers/oprofile/oprofilefs.c
52700+++ b/drivers/oprofile/oprofilefs.c
52701@@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
52702
52703 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
52704 {
52705- atomic_t *val = file->private_data;
52706- return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
52707+ atomic_unchecked_t *val = file->private_data;
52708+ return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
52709 }
52710
52711
52712@@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
52713
52714
52715 int oprofilefs_create_ro_atomic(struct dentry *root,
52716- char const *name, atomic_t *val)
52717+ char const *name, atomic_unchecked_t *val)
52718 {
52719 return __oprofilefs_create_file(root, name,
52720 &atomic_ro_fops, 0444, val);
52721diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
52722index bdef916..88c7dee 100644
52723--- a/drivers/oprofile/timer_int.c
52724+++ b/drivers/oprofile/timer_int.c
52725@@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
52726 return NOTIFY_OK;
52727 }
52728
52729-static struct notifier_block __refdata oprofile_cpu_notifier = {
52730+static struct notifier_block oprofile_cpu_notifier = {
52731 .notifier_call = oprofile_cpu_notify,
52732 };
52733
52734diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
52735index c776333..aa6b325 100644
52736--- a/drivers/parport/procfs.c
52737+++ b/drivers/parport/procfs.c
52738@@ -65,7 +65,7 @@ static int do_active_device(struct ctl_table *table, int write,
52739
52740 *ppos += len;
52741
52742- return copy_to_user(result, buffer, len) ? -EFAULT : 0;
52743+ return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
52744 }
52745
52746 #ifdef CONFIG_PARPORT_1284
52747@@ -107,7 +107,7 @@ static int do_autoprobe(struct ctl_table *table, int write,
52748
52749 *ppos += len;
52750
52751- return copy_to_user (result, buffer, len) ? -EFAULT : 0;
52752+ return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
52753 }
52754 #endif /* IEEE1284.3 support. */
52755
52756diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
52757index ba46e58..90cfc24 100644
52758--- a/drivers/pci/host/pci-host-generic.c
52759+++ b/drivers/pci/host/pci-host-generic.c
52760@@ -26,9 +26,9 @@
52761 #include <linux/platform_device.h>
52762
52763 struct gen_pci_cfg_bus_ops {
52764+ struct pci_ops ops;
52765 u32 bus_shift;
52766- void __iomem *(*map_bus)(struct pci_bus *, unsigned int, int);
52767-};
52768+} __do_const;
52769
52770 struct gen_pci_cfg_windows {
52771 struct resource res;
52772@@ -56,8 +56,12 @@ static void __iomem *gen_pci_map_cfg_bus_cam(struct pci_bus *bus,
52773 }
52774
52775 static struct gen_pci_cfg_bus_ops gen_pci_cfg_cam_bus_ops = {
52776+ .ops = {
52777+ .map_bus = gen_pci_map_cfg_bus_cam,
52778+ .read = pci_generic_config_read,
52779+ .write = pci_generic_config_write,
52780+ },
52781 .bus_shift = 16,
52782- .map_bus = gen_pci_map_cfg_bus_cam,
52783 };
52784
52785 static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus,
52786@@ -72,13 +76,12 @@ static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus,
52787 }
52788
52789 static struct gen_pci_cfg_bus_ops gen_pci_cfg_ecam_bus_ops = {
52790+ .ops = {
52791+ .map_bus = gen_pci_map_cfg_bus_ecam,
52792+ .read = pci_generic_config_read,
52793+ .write = pci_generic_config_write,
52794+ },
52795 .bus_shift = 20,
52796- .map_bus = gen_pci_map_cfg_bus_ecam,
52797-};
52798-
52799-static struct pci_ops gen_pci_ops = {
52800- .read = pci_generic_config_read,
52801- .write = pci_generic_config_write,
52802 };
52803
52804 static const struct of_device_id gen_pci_of_match[] = {
52805@@ -219,7 +222,6 @@ static int gen_pci_probe(struct platform_device *pdev)
52806 .private_data = (void **)&pci,
52807 .setup = gen_pci_setup,
52808 .map_irq = of_irq_parse_and_map_pci,
52809- .ops = &gen_pci_ops,
52810 };
52811
52812 if (!pci)
52813@@ -241,7 +243,7 @@ static int gen_pci_probe(struct platform_device *pdev)
52814
52815 of_id = of_match_node(gen_pci_of_match, np);
52816 pci->cfg.ops = of_id->data;
52817- gen_pci_ops.map_bus = pci->cfg.ops->map_bus;
52818+ hw.ops = &pci->cfg.ops->ops;
52819 pci->host.dev.parent = dev;
52820 INIT_LIST_HEAD(&pci->host.windows);
52821 INIT_LIST_HEAD(&pci->resources);
52822diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
52823index 6ca2399..68d866b 100644
52824--- a/drivers/pci/hotplug/acpiphp_ibm.c
52825+++ b/drivers/pci/hotplug/acpiphp_ibm.c
52826@@ -452,7 +452,9 @@ static int __init ibm_acpiphp_init(void)
52827 goto init_cleanup;
52828 }
52829
52830- ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
52831+ pax_open_kernel();
52832+ *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
52833+ pax_close_kernel();
52834 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
52835
52836 return retval;
52837diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
52838index 66b7bbe..26bee78 100644
52839--- a/drivers/pci/hotplug/cpcihp_generic.c
52840+++ b/drivers/pci/hotplug/cpcihp_generic.c
52841@@ -73,7 +73,6 @@ static u16 port;
52842 static unsigned int enum_bit;
52843 static u8 enum_mask;
52844
52845-static struct cpci_hp_controller_ops generic_hpc_ops;
52846 static struct cpci_hp_controller generic_hpc;
52847
52848 static int __init validate_parameters(void)
52849@@ -139,6 +138,10 @@ static int query_enum(void)
52850 return ((value & enum_mask) == enum_mask);
52851 }
52852
52853+static struct cpci_hp_controller_ops generic_hpc_ops = {
52854+ .query_enum = query_enum,
52855+};
52856+
52857 static int __init cpcihp_generic_init(void)
52858 {
52859 int status;
52860@@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
52861 pci_dev_put(dev);
52862
52863 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
52864- generic_hpc_ops.query_enum = query_enum;
52865 generic_hpc.ops = &generic_hpc_ops;
52866
52867 status = cpci_hp_register_controller(&generic_hpc);
52868diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
52869index 7ecf34e..effed62 100644
52870--- a/drivers/pci/hotplug/cpcihp_zt5550.c
52871+++ b/drivers/pci/hotplug/cpcihp_zt5550.c
52872@@ -59,7 +59,6 @@
52873 /* local variables */
52874 static bool debug;
52875 static bool poll;
52876-static struct cpci_hp_controller_ops zt5550_hpc_ops;
52877 static struct cpci_hp_controller zt5550_hpc;
52878
52879 /* Primary cPCI bus bridge device */
52880@@ -204,6 +203,10 @@ static int zt5550_hc_disable_irq(void)
52881 return 0;
52882 }
52883
52884+static struct cpci_hp_controller_ops zt5550_hpc_ops = {
52885+ .query_enum = zt5550_hc_query_enum,
52886+};
52887+
52888 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
52889 {
52890 int status;
52891@@ -215,16 +218,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
52892 dbg("returned from zt5550_hc_config");
52893
52894 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
52895- zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
52896 zt5550_hpc.ops = &zt5550_hpc_ops;
52897 if (!poll) {
52898 zt5550_hpc.irq = hc_dev->irq;
52899 zt5550_hpc.irq_flags = IRQF_SHARED;
52900 zt5550_hpc.dev_id = hc_dev;
52901
52902- zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
52903- zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
52904- zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
52905+ pax_open_kernel();
52906+ *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
52907+ *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
52908+ *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
52909+ pax_open_kernel();
52910 } else {
52911 info("using ENUM# polling mode");
52912 }
52913diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
52914index 1e08ff8c..3cd145f 100644
52915--- a/drivers/pci/hotplug/cpqphp_nvram.c
52916+++ b/drivers/pci/hotplug/cpqphp_nvram.c
52917@@ -425,8 +425,10 @@ static u32 store_HRT (void __iomem *rom_start)
52918
52919 void compaq_nvram_init (void __iomem *rom_start)
52920 {
52921+#ifndef CONFIG_PAX_KERNEXEC
52922 if (rom_start)
52923 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
52924+#endif
52925
52926 dbg("int15 entry = %p\n", compaq_int15_entry_point);
52927
52928diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
52929index 56d8486..f26113f 100644
52930--- a/drivers/pci/hotplug/pci_hotplug_core.c
52931+++ b/drivers/pci/hotplug/pci_hotplug_core.c
52932@@ -436,8 +436,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
52933 return -EINVAL;
52934 }
52935
52936- slot->ops->owner = owner;
52937- slot->ops->mod_name = mod_name;
52938+ pax_open_kernel();
52939+ *(struct module **)&slot->ops->owner = owner;
52940+ *(const char **)&slot->ops->mod_name = mod_name;
52941+ pax_close_kernel();
52942
52943 mutex_lock(&pci_hp_mutex);
52944 /*
52945diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
52946index 612b21a..9494a5e 100644
52947--- a/drivers/pci/hotplug/pciehp_core.c
52948+++ b/drivers/pci/hotplug/pciehp_core.c
52949@@ -87,7 +87,7 @@ static int init_slot(struct controller *ctrl)
52950 struct slot *slot = ctrl->slot;
52951 struct hotplug_slot *hotplug = NULL;
52952 struct hotplug_slot_info *info = NULL;
52953- struct hotplug_slot_ops *ops = NULL;
52954+ hotplug_slot_ops_no_const *ops = NULL;
52955 char name[SLOT_NAME_SIZE];
52956 int retval = -ENOMEM;
52957
52958diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
52959index f66be86..6cbcabb 100644
52960--- a/drivers/pci/msi.c
52961+++ b/drivers/pci/msi.c
52962@@ -492,8 +492,8 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
52963 {
52964 struct attribute **msi_attrs;
52965 struct attribute *msi_attr;
52966- struct device_attribute *msi_dev_attr;
52967- struct attribute_group *msi_irq_group;
52968+ device_attribute_no_const *msi_dev_attr;
52969+ attribute_group_no_const *msi_irq_group;
52970 const struct attribute_group **msi_irq_groups;
52971 struct msi_desc *entry;
52972 int ret = -ENOMEM;
52973@@ -552,7 +552,7 @@ error_attrs:
52974 count = 0;
52975 msi_attr = msi_attrs[count];
52976 while (msi_attr) {
52977- msi_dev_attr = container_of(msi_attr, struct device_attribute, attr);
52978+ msi_dev_attr = container_of(msi_attr, device_attribute_no_const, attr);
52979 kfree(msi_attr->name);
52980 kfree(msi_dev_attr);
52981 ++count;
52982@@ -1236,12 +1236,14 @@ static void pci_msi_domain_update_dom_ops(struct msi_domain_info *info)
52983 if (ops == NULL) {
52984 info->ops = &pci_msi_domain_ops_default;
52985 } else {
52986+ pax_open_kernel();
52987 if (ops->set_desc == NULL)
52988- ops->set_desc = pci_msi_domain_set_desc;
52989+ *(void **)&ops->set_desc = pci_msi_domain_set_desc;
52990 if (ops->msi_check == NULL)
52991- ops->msi_check = pci_msi_domain_check_cap;
52992+ *(void **)&ops->msi_check = pci_msi_domain_check_cap;
52993 if (ops->handle_error == NULL)
52994- ops->handle_error = pci_msi_domain_handle_error;
52995+ *(void **)&ops->handle_error = pci_msi_domain_handle_error;
52996+ pax_close_kernel();
52997 }
52998 }
52999
53000@@ -1250,8 +1252,11 @@ static void pci_msi_domain_update_chip_ops(struct msi_domain_info *info)
53001 struct irq_chip *chip = info->chip;
53002
53003 BUG_ON(!chip);
53004- if (!chip->irq_write_msi_msg)
53005- chip->irq_write_msi_msg = pci_msi_domain_write_msg;
53006+ if (!chip->irq_write_msi_msg) {
53007+ pax_open_kernel();
53008+ *(void **)&chip->irq_write_msi_msg = pci_msi_domain_write_msg;
53009+ pax_close_kernel();
53010+ }
53011 }
53012
53013 /**
53014diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
53015index 312f23a..d21181c 100644
53016--- a/drivers/pci/pci-sysfs.c
53017+++ b/drivers/pci/pci-sysfs.c
53018@@ -1140,7 +1140,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
53019 {
53020 /* allocate attribute structure, piggyback attribute name */
53021 int name_len = write_combine ? 13 : 10;
53022- struct bin_attribute *res_attr;
53023+ bin_attribute_no_const *res_attr;
53024 int retval;
53025
53026 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
53027@@ -1317,7 +1317,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
53028 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
53029 {
53030 int retval;
53031- struct bin_attribute *attr;
53032+ bin_attribute_no_const *attr;
53033
53034 /* If the device has VPD, try to expose it in sysfs. */
53035 if (dev->vpd) {
53036@@ -1364,7 +1364,7 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
53037 {
53038 int retval;
53039 int rom_size = 0;
53040- struct bin_attribute *attr;
53041+ bin_attribute_no_const *attr;
53042
53043 if (!sysfs_initialized)
53044 return -EACCES;
53045diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
53046index 4ff0ff1..e309fb0 100644
53047--- a/drivers/pci/pci.h
53048+++ b/drivers/pci/pci.h
53049@@ -99,7 +99,7 @@ struct pci_vpd_ops {
53050 struct pci_vpd {
53051 unsigned int len;
53052 const struct pci_vpd_ops *ops;
53053- struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
53054+ bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
53055 };
53056
53057 int pci_vpd_pci22_init(struct pci_dev *dev);
53058diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
53059index 317e355..21f7b91 100644
53060--- a/drivers/pci/pcie/aspm.c
53061+++ b/drivers/pci/pcie/aspm.c
53062@@ -27,9 +27,9 @@
53063 #define MODULE_PARAM_PREFIX "pcie_aspm."
53064
53065 /* Note: those are not register definitions */
53066-#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
53067-#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
53068-#define ASPM_STATE_L1 (4) /* L1 state */
53069+#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
53070+#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
53071+#define ASPM_STATE_L1 (4U) /* L1 state */
53072 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
53073 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
53074
53075diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
53076index be35da2..ec16cdb 100644
53077--- a/drivers/pci/pcie/portdrv_pci.c
53078+++ b/drivers/pci/pcie/portdrv_pci.c
53079@@ -324,7 +324,7 @@ static int __init dmi_pcie_pme_disable_msi(const struct dmi_system_id *d)
53080 return 0;
53081 }
53082
53083-static struct dmi_system_id __initdata pcie_portdrv_dmi_table[] = {
53084+static const struct dmi_system_id __initconst pcie_portdrv_dmi_table[] = {
53085 /*
53086 * Boxes that should not use MSI for PCIe PME signaling.
53087 */
53088diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
53089index f6ae0d0..af897bc 100644
53090--- a/drivers/pci/probe.c
53091+++ b/drivers/pci/probe.c
53092@@ -176,7 +176,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
53093 u16 orig_cmd;
53094 struct pci_bus_region region, inverted_region;
53095
53096- mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
53097+ mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
53098
53099 /* No printks while decoding is disabled! */
53100 if (!dev->mmio_always_on) {
53101diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
53102index 3f155e7..0f4b1f0 100644
53103--- a/drivers/pci/proc.c
53104+++ b/drivers/pci/proc.c
53105@@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
53106 static int __init pci_proc_init(void)
53107 {
53108 struct pci_dev *dev = NULL;
53109+
53110+#ifdef CONFIG_GRKERNSEC_PROC_ADD
53111+#ifdef CONFIG_GRKERNSEC_PROC_USER
53112+ proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
53113+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
53114+ proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
53115+#endif
53116+#else
53117 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
53118+#endif
53119 proc_create("devices", 0, proc_bus_pci_dir,
53120 &proc_bus_pci_dev_operations);
53121 proc_initialized = 1;
53122diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
53123index 2deb130..8194e13 100644
53124--- a/drivers/pinctrl/pinctrl-at91.c
53125+++ b/drivers/pinctrl/pinctrl-at91.c
53126@@ -24,6 +24,7 @@
53127 #include <linux/pinctrl/pinmux.h>
53128 /* Since we request GPIOs from ourself */
53129 #include <linux/pinctrl/consumer.h>
53130+#include <asm/pgtable.h>
53131
53132 #include "pinctrl-at91.h"
53133 #include "core.h"
53134@@ -1656,7 +1657,9 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev,
53135 at91_gpio->pioc_hwirq = irqd_to_hwirq(d);
53136
53137 /* Setup proper .irq_set_type function */
53138- gpio_irqchip.irq_set_type = at91_gpio->ops->irq_type;
53139+ pax_open_kernel();
53140+ *(void **)&gpio_irqchip.irq_set_type = at91_gpio->ops->irq_type;
53141+ pax_close_kernel();
53142
53143 /* Disable irqs of this PIO controller */
53144 writel_relaxed(~0, at91_gpio->regbase + PIO_IDR);
53145diff --git a/drivers/platform/chrome/chromeos_pstore.c b/drivers/platform/chrome/chromeos_pstore.c
53146index 3474920..acc9581 100644
53147--- a/drivers/platform/chrome/chromeos_pstore.c
53148+++ b/drivers/platform/chrome/chromeos_pstore.c
53149@@ -13,7 +13,7 @@
53150 #include <linux/platform_device.h>
53151 #include <linux/pstore_ram.h>
53152
53153-static struct dmi_system_id chromeos_pstore_dmi_table[] __initdata = {
53154+static const struct dmi_system_id chromeos_pstore_dmi_table[] __initconst = {
53155 {
53156 /*
53157 * Today all Chromebooks/boxes ship with Google_* as version and
53158diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c
53159index 1e1e594..8fe59c5 100644
53160--- a/drivers/platform/x86/alienware-wmi.c
53161+++ b/drivers/platform/x86/alienware-wmi.c
53162@@ -150,7 +150,7 @@ struct wmax_led_args {
53163 } __packed;
53164
53165 static struct platform_device *platform_device;
53166-static struct device_attribute *zone_dev_attrs;
53167+static device_attribute_no_const *zone_dev_attrs;
53168 static struct attribute **zone_attrs;
53169 static struct platform_zone *zone_data;
53170
53171@@ -160,7 +160,7 @@ static struct platform_driver platform_driver = {
53172 }
53173 };
53174
53175-static struct attribute_group zone_attribute_group = {
53176+static attribute_group_no_const zone_attribute_group = {
53177 .name = "rgb_zones",
53178 };
53179
53180diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
53181index efbc3f0..18ae682 100644
53182--- a/drivers/platform/x86/asus-wmi.c
53183+++ b/drivers/platform/x86/asus-wmi.c
53184@@ -1868,6 +1868,10 @@ static int show_dsts(struct seq_file *m, void *data)
53185 int err;
53186 u32 retval = -1;
53187
53188+#ifdef CONFIG_GRKERNSEC_KMEM
53189+ return -EPERM;
53190+#endif
53191+
53192 err = asus_wmi_get_devstate(asus, asus->debug.dev_id, &retval);
53193
53194 if (err < 0)
53195@@ -1884,6 +1888,10 @@ static int show_devs(struct seq_file *m, void *data)
53196 int err;
53197 u32 retval = -1;
53198
53199+#ifdef CONFIG_GRKERNSEC_KMEM
53200+ return -EPERM;
53201+#endif
53202+
53203 err = asus_wmi_set_devstate(asus->debug.dev_id, asus->debug.ctrl_param,
53204 &retval);
53205
53206@@ -1908,6 +1916,10 @@ static int show_call(struct seq_file *m, void *data)
53207 union acpi_object *obj;
53208 acpi_status status;
53209
53210+#ifdef CONFIG_GRKERNSEC_KMEM
53211+ return -EPERM;
53212+#endif
53213+
53214 status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID,
53215 1, asus->debug.method_id,
53216 &input, &output);
53217diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c
53218index f2706d2..850edfa4 100644
53219--- a/drivers/platform/x86/compal-laptop.c
53220+++ b/drivers/platform/x86/compal-laptop.c
53221@@ -765,7 +765,7 @@ static int dmi_check_cb_extra(const struct dmi_system_id *id)
53222 return 1;
53223 }
53224
53225-static struct dmi_system_id __initdata compal_dmi_table[] = {
53226+static const struct dmi_system_id __initconst compal_dmi_table[] = {
53227 {
53228 .ident = "FL90/IFL90",
53229 .matches = {
53230diff --git a/drivers/platform/x86/hdaps.c b/drivers/platform/x86/hdaps.c
53231index 458e6c9..089aee7 100644
53232--- a/drivers/platform/x86/hdaps.c
53233+++ b/drivers/platform/x86/hdaps.c
53234@@ -514,7 +514,7 @@ static int __init hdaps_dmi_match_invert(const struct dmi_system_id *id)
53235 "ThinkPad T42p", so the order of the entries matters.
53236 If your ThinkPad is not recognized, please update to latest
53237 BIOS. This is especially the case for some R52 ThinkPads. */
53238-static struct dmi_system_id __initdata hdaps_whitelist[] = {
53239+static const struct dmi_system_id __initconst hdaps_whitelist[] = {
53240 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad R50p", HDAPS_BOTH_AXES),
53241 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R50"),
53242 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R51"),
53243diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c
53244index 97c2be1..2ee50ce 100644
53245--- a/drivers/platform/x86/ibm_rtl.c
53246+++ b/drivers/platform/x86/ibm_rtl.c
53247@@ -227,7 +227,7 @@ static void rtl_teardown_sysfs(void) {
53248 }
53249
53250
53251-static struct dmi_system_id __initdata ibm_rtl_dmi_table[] = {
53252+static const struct dmi_system_id __initconst ibm_rtl_dmi_table[] = {
53253 { \
53254 .matches = { \
53255 DMI_MATCH(DMI_SYS_VENDOR, "IBM"), \
53256diff --git a/drivers/platform/x86/intel_oaktrail.c b/drivers/platform/x86/intel_oaktrail.c
53257index 6aa33c4..cfb5425 100644
53258--- a/drivers/platform/x86/intel_oaktrail.c
53259+++ b/drivers/platform/x86/intel_oaktrail.c
53260@@ -299,7 +299,7 @@ static int dmi_check_cb(const struct dmi_system_id *id)
53261 return 0;
53262 }
53263
53264-static struct dmi_system_id __initdata oaktrail_dmi_table[] = {
53265+static const struct dmi_system_id __initconst oaktrail_dmi_table[] = {
53266 {
53267 .ident = "OakTrail platform",
53268 .matches = {
53269diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
53270index 4231770..10a6caf 100644
53271--- a/drivers/platform/x86/msi-laptop.c
53272+++ b/drivers/platform/x86/msi-laptop.c
53273@@ -605,7 +605,7 @@ static int dmi_check_cb(const struct dmi_system_id *dmi)
53274 return 1;
53275 }
53276
53277-static struct dmi_system_id __initdata msi_dmi_table[] = {
53278+static const struct dmi_system_id __initconst msi_dmi_table[] = {
53279 {
53280 .ident = "MSI S270",
53281 .matches = {
53282@@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
53283
53284 if (!quirks->ec_read_only) {
53285 /* allow userland write sysfs file */
53286- dev_attr_bluetooth.store = store_bluetooth;
53287- dev_attr_wlan.store = store_wlan;
53288- dev_attr_threeg.store = store_threeg;
53289- dev_attr_bluetooth.attr.mode |= S_IWUSR;
53290- dev_attr_wlan.attr.mode |= S_IWUSR;
53291- dev_attr_threeg.attr.mode |= S_IWUSR;
53292+ pax_open_kernel();
53293+ *(void **)&dev_attr_bluetooth.store = store_bluetooth;
53294+ *(void **)&dev_attr_wlan.store = store_wlan;
53295+ *(void **)&dev_attr_threeg.store = store_threeg;
53296+ *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
53297+ *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
53298+ *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
53299+ pax_close_kernel();
53300 }
53301
53302 /* disable hardware control by fn key */
53303diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
53304index 978e6d6..1f0b37d 100644
53305--- a/drivers/platform/x86/msi-wmi.c
53306+++ b/drivers/platform/x86/msi-wmi.c
53307@@ -184,7 +184,7 @@ static const struct backlight_ops msi_backlight_ops = {
53308 static void msi_wmi_notify(u32 value, void *context)
53309 {
53310 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
53311- static struct key_entry *key;
53312+ struct key_entry *key;
53313 union acpi_object *obj;
53314 acpi_status status;
53315
53316diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
53317index 8c146e2..356c62e 100644
53318--- a/drivers/platform/x86/samsung-laptop.c
53319+++ b/drivers/platform/x86/samsung-laptop.c
53320@@ -1567,7 +1567,7 @@ static int __init samsung_dmi_matched(const struct dmi_system_id *d)
53321 return 0;
53322 }
53323
53324-static struct dmi_system_id __initdata samsung_dmi_table[] = {
53325+static const struct dmi_system_id __initconst samsung_dmi_table[] = {
53326 {
53327 .matches = {
53328 DMI_MATCH(DMI_SYS_VENDOR,
53329diff --git a/drivers/platform/x86/samsung-q10.c b/drivers/platform/x86/samsung-q10.c
53330index e6aac72..e11ff24 100644
53331--- a/drivers/platform/x86/samsung-q10.c
53332+++ b/drivers/platform/x86/samsung-q10.c
53333@@ -95,7 +95,7 @@ static int __init dmi_check_callback(const struct dmi_system_id *id)
53334 return 1;
53335 }
53336
53337-static struct dmi_system_id __initdata samsungq10_dmi_table[] = {
53338+static const struct dmi_system_id __initconst samsungq10_dmi_table[] = {
53339 {
53340 .ident = "Samsung Q10",
53341 .matches = {
53342diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
53343index aeb80d1..3eb376b 100644
53344--- a/drivers/platform/x86/sony-laptop.c
53345+++ b/drivers/platform/x86/sony-laptop.c
53346@@ -2527,7 +2527,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
53347 }
53348
53349 /* High speed charging function */
53350-static struct device_attribute *hsc_handle;
53351+static device_attribute_no_const *hsc_handle;
53352
53353 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
53354 struct device_attribute *attr,
53355@@ -2601,7 +2601,7 @@ static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd)
53356 }
53357
53358 /* low battery function */
53359-static struct device_attribute *lowbatt_handle;
53360+static device_attribute_no_const *lowbatt_handle;
53361
53362 static ssize_t sony_nc_lowbatt_store(struct device *dev,
53363 struct device_attribute *attr,
53364@@ -2667,7 +2667,7 @@ static void sony_nc_lowbatt_cleanup(struct platform_device *pd)
53365 }
53366
53367 /* fan speed function */
53368-static struct device_attribute *fan_handle, *hsf_handle;
53369+static device_attribute_no_const *fan_handle, *hsf_handle;
53370
53371 static ssize_t sony_nc_hsfan_store(struct device *dev,
53372 struct device_attribute *attr,
53373@@ -2774,7 +2774,7 @@ static void sony_nc_fanspeed_cleanup(struct platform_device *pd)
53374 }
53375
53376 /* USB charge function */
53377-static struct device_attribute *uc_handle;
53378+static device_attribute_no_const *uc_handle;
53379
53380 static ssize_t sony_nc_usb_charge_store(struct device *dev,
53381 struct device_attribute *attr,
53382@@ -2848,7 +2848,7 @@ static void sony_nc_usb_charge_cleanup(struct platform_device *pd)
53383 }
53384
53385 /* Panel ID function */
53386-static struct device_attribute *panel_handle;
53387+static device_attribute_no_const *panel_handle;
53388
53389 static ssize_t sony_nc_panelid_show(struct device *dev,
53390 struct device_attribute *attr, char *buffer)
53391@@ -2895,7 +2895,7 @@ static void sony_nc_panelid_cleanup(struct platform_device *pd)
53392 }
53393
53394 /* smart connect function */
53395-static struct device_attribute *sc_handle;
53396+static device_attribute_no_const *sc_handle;
53397
53398 static ssize_t sony_nc_smart_conn_store(struct device *dev,
53399 struct device_attribute *attr,
53400@@ -4851,7 +4851,7 @@ static struct acpi_driver sony_pic_driver = {
53401 .drv.pm = &sony_pic_pm,
53402 };
53403
53404-static struct dmi_system_id __initdata sonypi_dmi_table[] = {
53405+static const struct dmi_system_id __initconst sonypi_dmi_table[] = {
53406 {
53407 .ident = "Sony Vaio",
53408 .matches = {
53409diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
53410index 33e488c..417aaea 100644
53411--- a/drivers/platform/x86/thinkpad_acpi.c
53412+++ b/drivers/platform/x86/thinkpad_acpi.c
53413@@ -2460,10 +2460,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
53414 && !tp_features.bright_unkfw)
53415 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
53416 }
53417+}
53418
53419 #undef TPACPI_COMPARE_KEY
53420 #undef TPACPI_MAY_SEND_KEY
53421-}
53422
53423 /*
53424 * Polling driver
53425diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
53426index 438d4c7..ca8a2fb 100644
53427--- a/drivers/pnp/pnpbios/bioscalls.c
53428+++ b/drivers/pnp/pnpbios/bioscalls.c
53429@@ -59,7 +59,7 @@ do { \
53430 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
53431 } while(0)
53432
53433-static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
53434+static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
53435 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
53436
53437 /*
53438@@ -96,7 +96,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
53439
53440 cpu = get_cpu();
53441 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
53442+
53443+ pax_open_kernel();
53444 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
53445+ pax_close_kernel();
53446
53447 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
53448 spin_lock_irqsave(&pnp_bios_lock, flags);
53449@@ -134,7 +137,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
53450 :"memory");
53451 spin_unlock_irqrestore(&pnp_bios_lock, flags);
53452
53453+ pax_open_kernel();
53454 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
53455+ pax_close_kernel();
53456+
53457 put_cpu();
53458
53459 /* If we get here and this is set then the PnP BIOS faulted on us. */
53460@@ -468,7 +474,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
53461 return status;
53462 }
53463
53464-void pnpbios_calls_init(union pnp_bios_install_struct *header)
53465+void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
53466 {
53467 int i;
53468
53469@@ -476,6 +482,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
53470 pnp_bios_callpoint.offset = header->fields.pm16offset;
53471 pnp_bios_callpoint.segment = PNP_CS16;
53472
53473+ pax_open_kernel();
53474+
53475 for_each_possible_cpu(i) {
53476 struct desc_struct *gdt = get_cpu_gdt_table(i);
53477 if (!gdt)
53478@@ -487,4 +495,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
53479 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
53480 (unsigned long)__va(header->fields.pm16dseg));
53481 }
53482+
53483+ pax_close_kernel();
53484 }
53485diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
53486index facd43b..b291260 100644
53487--- a/drivers/pnp/pnpbios/core.c
53488+++ b/drivers/pnp/pnpbios/core.c
53489@@ -494,7 +494,7 @@ static int __init exploding_pnp_bios(const struct dmi_system_id *d)
53490 return 0;
53491 }
53492
53493-static struct dmi_system_id pnpbios_dmi_table[] __initdata = {
53494+static const struct dmi_system_id pnpbios_dmi_table[] __initconst = {
53495 { /* PnPBIOS GPF on boot */
53496 .callback = exploding_pnp_bios,
53497 .ident = "Higraded P14H",
53498diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
53499index dfe1ee8..67e820c 100644
53500--- a/drivers/power/pda_power.c
53501+++ b/drivers/power/pda_power.c
53502@@ -38,7 +38,11 @@ static struct power_supply *pda_psy_ac, *pda_psy_usb;
53503
53504 #if IS_ENABLED(CONFIG_USB_PHY)
53505 static struct usb_phy *transceiver;
53506-static struct notifier_block otg_nb;
53507+static int otg_handle_notification(struct notifier_block *nb,
53508+ unsigned long event, void *unused);
53509+static struct notifier_block otg_nb = {
53510+ .notifier_call = otg_handle_notification
53511+};
53512 #endif
53513
53514 static struct regulator *ac_draw;
53515@@ -373,7 +377,6 @@ static int pda_power_probe(struct platform_device *pdev)
53516
53517 #if IS_ENABLED(CONFIG_USB_PHY)
53518 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
53519- otg_nb.notifier_call = otg_handle_notification;
53520 ret = usb_register_notifier(transceiver, &otg_nb);
53521 if (ret) {
53522 dev_err(dev, "failure to register otg notifier\n");
53523diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
53524index cc439fd..8fa30df 100644
53525--- a/drivers/power/power_supply.h
53526+++ b/drivers/power/power_supply.h
53527@@ -16,12 +16,12 @@ struct power_supply;
53528
53529 #ifdef CONFIG_SYSFS
53530
53531-extern void power_supply_init_attrs(struct device_type *dev_type);
53532+extern void power_supply_init_attrs(void);
53533 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
53534
53535 #else
53536
53537-static inline void power_supply_init_attrs(struct device_type *dev_type) {}
53538+static inline void power_supply_init_attrs(void) {}
53539 #define power_supply_uevent NULL
53540
53541 #endif /* CONFIG_SYSFS */
53542diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
53543index 869284c..38a812b 100644
53544--- a/drivers/power/power_supply_core.c
53545+++ b/drivers/power/power_supply_core.c
53546@@ -28,7 +28,10 @@ EXPORT_SYMBOL_GPL(power_supply_class);
53547 ATOMIC_NOTIFIER_HEAD(power_supply_notifier);
53548 EXPORT_SYMBOL_GPL(power_supply_notifier);
53549
53550-static struct device_type power_supply_dev_type;
53551+extern const struct attribute_group *power_supply_attr_groups[];
53552+static struct device_type power_supply_dev_type = {
53553+ .groups = power_supply_attr_groups,
53554+};
53555
53556 #define POWER_SUPPLY_DEFERRED_REGISTER_TIME msecs_to_jiffies(10)
53557
53558@@ -960,7 +963,7 @@ static int __init power_supply_class_init(void)
53559 return PTR_ERR(power_supply_class);
53560
53561 power_supply_class->dev_uevent = power_supply_uevent;
53562- power_supply_init_attrs(&power_supply_dev_type);
53563+ power_supply_init_attrs();
53564
53565 return 0;
53566 }
53567diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
53568index ed2d7fd..266b28f 100644
53569--- a/drivers/power/power_supply_sysfs.c
53570+++ b/drivers/power/power_supply_sysfs.c
53571@@ -238,17 +238,15 @@ static struct attribute_group power_supply_attr_group = {
53572 .is_visible = power_supply_attr_is_visible,
53573 };
53574
53575-static const struct attribute_group *power_supply_attr_groups[] = {
53576+const struct attribute_group *power_supply_attr_groups[] = {
53577 &power_supply_attr_group,
53578 NULL,
53579 };
53580
53581-void power_supply_init_attrs(struct device_type *dev_type)
53582+void power_supply_init_attrs(void)
53583 {
53584 int i;
53585
53586- dev_type->groups = power_supply_attr_groups;
53587-
53588 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
53589 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
53590 }
53591diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
53592index 36dc52f..e2e8a4b 100644
53593--- a/drivers/power/reset/at91-reset.c
53594+++ b/drivers/power/reset/at91-reset.c
53595@@ -16,6 +16,7 @@
53596 #include <linux/of_address.h>
53597 #include <linux/platform_device.h>
53598 #include <linux/reboot.h>
53599+#include <asm/pgtable.h>
53600
53601 #include <soc/at91/at91sam9_ddrsdr.h>
53602 #include <soc/at91/at91sam9_sdramc.h>
53603@@ -191,7 +192,9 @@ static int at91_reset_of_probe(struct platform_device *pdev)
53604 }
53605
53606 match = of_match_node(at91_reset_of_match, pdev->dev.of_node);
53607- at91_restart_nb.notifier_call = match->data;
53608+ pax_open_kernel();
53609+ *(void **)&at91_restart_nb.notifier_call = match->data;
53610+ pax_close_kernel();
53611 return register_restart_handler(&at91_restart_nb);
53612 }
53613
53614@@ -219,9 +222,11 @@ static int at91_reset_platform_probe(struct platform_device *pdev)
53615 }
53616
53617 match = platform_get_device_id(pdev);
53618- at91_restart_nb.notifier_call =
53619+ pax_open_kernel();
53620+ *(void **)&at91_restart_nb.notifier_call =
53621 (int (*)(struct notifier_block *,
53622 unsigned long, void *)) match->driver_data;
53623+ pax_close_kernel();
53624
53625 return register_restart_handler(&at91_restart_nb);
53626 }
53627diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c
53628index 84419af..268ede8 100644
53629--- a/drivers/powercap/powercap_sys.c
53630+++ b/drivers/powercap/powercap_sys.c
53631@@ -154,8 +154,77 @@ struct powercap_constraint_attr {
53632 struct device_attribute name_attr;
53633 };
53634
53635+static ssize_t show_constraint_name(struct device *dev,
53636+ struct device_attribute *dev_attr,
53637+ char *buf);
53638+
53639 static struct powercap_constraint_attr
53640- constraint_attrs[MAX_CONSTRAINTS_PER_ZONE];
53641+ constraint_attrs[MAX_CONSTRAINTS_PER_ZONE] = {
53642+ [0 ... MAX_CONSTRAINTS_PER_ZONE - 1] = {
53643+ .power_limit_attr = {
53644+ .attr = {
53645+ .name = NULL,
53646+ .mode = S_IWUSR | S_IRUGO
53647+ },
53648+ .show = show_constraint_power_limit_uw,
53649+ .store = store_constraint_power_limit_uw
53650+ },
53651+
53652+ .time_window_attr = {
53653+ .attr = {
53654+ .name = NULL,
53655+ .mode = S_IWUSR | S_IRUGO
53656+ },
53657+ .show = show_constraint_time_window_us,
53658+ .store = store_constraint_time_window_us
53659+ },
53660+
53661+ .max_power_attr = {
53662+ .attr = {
53663+ .name = NULL,
53664+ .mode = S_IRUGO
53665+ },
53666+ .show = show_constraint_max_power_uw,
53667+ .store = NULL
53668+ },
53669+
53670+ .min_power_attr = {
53671+ .attr = {
53672+ .name = NULL,
53673+ .mode = S_IRUGO
53674+ },
53675+ .show = show_constraint_min_power_uw,
53676+ .store = NULL
53677+ },
53678+
53679+ .max_time_window_attr = {
53680+ .attr = {
53681+ .name = NULL,
53682+ .mode = S_IRUGO
53683+ },
53684+ .show = show_constraint_max_time_window_us,
53685+ .store = NULL
53686+ },
53687+
53688+ .min_time_window_attr = {
53689+ .attr = {
53690+ .name = NULL,
53691+ .mode = S_IRUGO
53692+ },
53693+ .show = show_constraint_min_time_window_us,
53694+ .store = NULL
53695+ },
53696+
53697+ .name_attr = {
53698+ .attr = {
53699+ .name = NULL,
53700+ .mode = S_IRUGO
53701+ },
53702+ .show = show_constraint_name,
53703+ .store = NULL
53704+ }
53705+ }
53706+};
53707
53708 /* A list of powercap control_types */
53709 static LIST_HEAD(powercap_cntrl_list);
53710@@ -193,23 +262,16 @@ static ssize_t show_constraint_name(struct device *dev,
53711 }
53712
53713 static int create_constraint_attribute(int id, const char *name,
53714- int mode,
53715- struct device_attribute *dev_attr,
53716- ssize_t (*show)(struct device *,
53717- struct device_attribute *, char *),
53718- ssize_t (*store)(struct device *,
53719- struct device_attribute *,
53720- const char *, size_t)
53721- )
53722+ struct device_attribute *dev_attr)
53723 {
53724+ name = kasprintf(GFP_KERNEL, "constraint_%d_%s", id, name);
53725
53726- dev_attr->attr.name = kasprintf(GFP_KERNEL, "constraint_%d_%s",
53727- id, name);
53728- if (!dev_attr->attr.name)
53729+ if (!name)
53730 return -ENOMEM;
53731- dev_attr->attr.mode = mode;
53732- dev_attr->show = show;
53733- dev_attr->store = store;
53734+
53735+ pax_open_kernel();
53736+ *(const char **)&dev_attr->attr.name = name;
53737+ pax_close_kernel();
53738
53739 return 0;
53740 }
53741@@ -236,49 +298,31 @@ static int seed_constraint_attributes(void)
53742
53743 for (i = 0; i < MAX_CONSTRAINTS_PER_ZONE; ++i) {
53744 ret = create_constraint_attribute(i, "power_limit_uw",
53745- S_IWUSR | S_IRUGO,
53746- &constraint_attrs[i].power_limit_attr,
53747- show_constraint_power_limit_uw,
53748- store_constraint_power_limit_uw);
53749+ &constraint_attrs[i].power_limit_attr);
53750 if (ret)
53751 goto err_alloc;
53752 ret = create_constraint_attribute(i, "time_window_us",
53753- S_IWUSR | S_IRUGO,
53754- &constraint_attrs[i].time_window_attr,
53755- show_constraint_time_window_us,
53756- store_constraint_time_window_us);
53757+ &constraint_attrs[i].time_window_attr);
53758 if (ret)
53759 goto err_alloc;
53760- ret = create_constraint_attribute(i, "name", S_IRUGO,
53761- &constraint_attrs[i].name_attr,
53762- show_constraint_name,
53763- NULL);
53764+ ret = create_constraint_attribute(i, "name",
53765+ &constraint_attrs[i].name_attr);
53766 if (ret)
53767 goto err_alloc;
53768- ret = create_constraint_attribute(i, "max_power_uw", S_IRUGO,
53769- &constraint_attrs[i].max_power_attr,
53770- show_constraint_max_power_uw,
53771- NULL);
53772+ ret = create_constraint_attribute(i, "max_power_uw",
53773+ &constraint_attrs[i].max_power_attr);
53774 if (ret)
53775 goto err_alloc;
53776- ret = create_constraint_attribute(i, "min_power_uw", S_IRUGO,
53777- &constraint_attrs[i].min_power_attr,
53778- show_constraint_min_power_uw,
53779- NULL);
53780+ ret = create_constraint_attribute(i, "min_power_uw",
53781+ &constraint_attrs[i].min_power_attr);
53782 if (ret)
53783 goto err_alloc;
53784 ret = create_constraint_attribute(i, "max_time_window_us",
53785- S_IRUGO,
53786- &constraint_attrs[i].max_time_window_attr,
53787- show_constraint_max_time_window_us,
53788- NULL);
53789+ &constraint_attrs[i].max_time_window_attr);
53790 if (ret)
53791 goto err_alloc;
53792 ret = create_constraint_attribute(i, "min_time_window_us",
53793- S_IRUGO,
53794- &constraint_attrs[i].min_time_window_attr,
53795- show_constraint_min_time_window_us,
53796- NULL);
53797+ &constraint_attrs[i].min_time_window_attr);
53798 if (ret)
53799 goto err_alloc;
53800
53801@@ -378,10 +422,12 @@ static void create_power_zone_common_attributes(
53802 power_zone->zone_dev_attrs[count++] =
53803 &dev_attr_max_energy_range_uj.attr;
53804 if (power_zone->ops->get_energy_uj) {
53805+ pax_open_kernel();
53806 if (power_zone->ops->reset_energy_uj)
53807- dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
53808+ *(umode_t *)&dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
53809 else
53810- dev_attr_energy_uj.attr.mode = S_IRUGO;
53811+ *(umode_t *)&dev_attr_energy_uj.attr.mode = S_IRUGO;
53812+ pax_close_kernel();
53813 power_zone->zone_dev_attrs[count++] =
53814 &dev_attr_energy_uj.attr;
53815 }
53816diff --git a/drivers/ptp/ptp_private.h b/drivers/ptp/ptp_private.h
53817index 9c5d414..c7900ce 100644
53818--- a/drivers/ptp/ptp_private.h
53819+++ b/drivers/ptp/ptp_private.h
53820@@ -51,7 +51,7 @@ struct ptp_clock {
53821 struct mutex pincfg_mux; /* protect concurrent info->pin_config access */
53822 wait_queue_head_t tsev_wq;
53823 int defunct; /* tells readers to go away when clock is being removed */
53824- struct device_attribute *pin_dev_attr;
53825+ device_attribute_no_const *pin_dev_attr;
53826 struct attribute **pin_attr;
53827 struct attribute_group pin_attr_group;
53828 };
53829diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
53830index 302e626..12579af 100644
53831--- a/drivers/ptp/ptp_sysfs.c
53832+++ b/drivers/ptp/ptp_sysfs.c
53833@@ -280,7 +280,7 @@ static int ptp_populate_pins(struct ptp_clock *ptp)
53834 goto no_pin_attr;
53835
53836 for (i = 0; i < n_pins; i++) {
53837- struct device_attribute *da = &ptp->pin_dev_attr[i];
53838+ device_attribute_no_const *da = &ptp->pin_dev_attr[i];
53839 sysfs_attr_init(&da->attr);
53840 da->attr.name = info->pin_config[i].name;
53841 da->attr.mode = 0644;
53842diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
53843index 5081533..794deb2 100644
53844--- a/drivers/regulator/core.c
53845+++ b/drivers/regulator/core.c
53846@@ -3650,7 +3650,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
53847 const struct regulation_constraints *constraints = NULL;
53848 const struct regulator_init_data *init_data;
53849 struct regulator_config *config = NULL;
53850- static atomic_t regulator_no = ATOMIC_INIT(-1);
53851+ static atomic_unchecked_t regulator_no = ATOMIC_INIT(-1);
53852 struct regulator_dev *rdev;
53853 struct device *dev;
53854 int ret, i;
53855@@ -3733,7 +3733,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
53856 rdev->dev.class = &regulator_class;
53857 rdev->dev.parent = dev;
53858 dev_set_name(&rdev->dev, "regulator.%lu",
53859- (unsigned long) atomic_inc_return(&regulator_no));
53860+ (unsigned long) atomic_inc_return_unchecked(&regulator_no));
53861 ret = device_register(&rdev->dev);
53862 if (ret != 0) {
53863 put_device(&rdev->dev);
53864diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
53865index 4071d74..260b15a 100644
53866--- a/drivers/regulator/max8660.c
53867+++ b/drivers/regulator/max8660.c
53868@@ -423,8 +423,10 @@ static int max8660_probe(struct i2c_client *client,
53869 max8660->shadow_regs[MAX8660_OVER1] = 5;
53870 } else {
53871 /* Otherwise devices can be toggled via software */
53872- max8660_dcdc_ops.enable = max8660_dcdc_enable;
53873- max8660_dcdc_ops.disable = max8660_dcdc_disable;
53874+ pax_open_kernel();
53875+ *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
53876+ *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
53877+ pax_close_kernel();
53878 }
53879
53880 /*
53881diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
53882index e94ddcf..bad33ad 100644
53883--- a/drivers/regulator/max8973-regulator.c
53884+++ b/drivers/regulator/max8973-regulator.c
53885@@ -580,9 +580,11 @@ static int max8973_probe(struct i2c_client *client,
53886 if (!pdata->enable_ext_control) {
53887 max->desc.enable_reg = MAX8973_VOUT;
53888 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
53889- max->ops.enable = regulator_enable_regmap;
53890- max->ops.disable = regulator_disable_regmap;
53891- max->ops.is_enabled = regulator_is_enabled_regmap;
53892+ pax_open_kernel();
53893+ *(void **)&max->ops.enable = regulator_enable_regmap;
53894+ *(void **)&max->ops.disable = regulator_disable_regmap;
53895+ *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
53896+ pax_close_kernel();
53897 break;
53898 }
53899
53900@@ -610,9 +612,11 @@ static int max8973_probe(struct i2c_client *client,
53901
53902 max->desc.enable_reg = MAX8973_VOUT;
53903 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
53904- max->ops.enable = regulator_enable_regmap;
53905- max->ops.disable = regulator_disable_regmap;
53906- max->ops.is_enabled = regulator_is_enabled_regmap;
53907+ pax_open_kernel();
53908+ *(void **)&max->ops.enable = regulator_enable_regmap;
53909+ *(void **)&max->ops.disable = regulator_disable_regmap;
53910+ *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
53911+ pax_close_kernel();
53912 break;
53913 default:
53914 break;
53915diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
53916index 0d17c92..a29f627 100644
53917--- a/drivers/regulator/mc13892-regulator.c
53918+++ b/drivers/regulator/mc13892-regulator.c
53919@@ -584,10 +584,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
53920 mc13xxx_unlock(mc13892);
53921
53922 /* update mc13892_vcam ops */
53923- memcpy(&mc13892_vcam_ops, mc13892_regulators[MC13892_VCAM].desc.ops,
53924+ pax_open_kernel();
53925+ memcpy((void *)&mc13892_vcam_ops, mc13892_regulators[MC13892_VCAM].desc.ops,
53926 sizeof(struct regulator_ops));
53927- mc13892_vcam_ops.set_mode = mc13892_vcam_set_mode,
53928- mc13892_vcam_ops.get_mode = mc13892_vcam_get_mode,
53929+ *(void **)&mc13892_vcam_ops.set_mode = mc13892_vcam_set_mode,
53930+ *(void **)&mc13892_vcam_ops.get_mode = mc13892_vcam_get_mode,
53931+ pax_close_kernel();
53932 mc13892_regulators[MC13892_VCAM].desc.ops = &mc13892_vcam_ops;
53933
53934 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
53935diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c
53936index 2b08cac..8942201 100644
53937--- a/drivers/rtc/rtc-armada38x.c
53938+++ b/drivers/rtc/rtc-armada38x.c
53939@@ -18,6 +18,7 @@
53940 #include <linux/of.h>
53941 #include <linux/platform_device.h>
53942 #include <linux/rtc.h>
53943+#include <asm/pgtable.h>
53944
53945 #define RTC_STATUS 0x0
53946 #define RTC_STATUS_ALARM1 BIT(0)
53947@@ -254,8 +255,10 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
53948 * If there is no interrupt available then we can't
53949 * use the alarm
53950 */
53951- armada38x_rtc_ops.set_alarm = NULL;
53952- armada38x_rtc_ops.alarm_irq_enable = NULL;
53953+ pax_open_kernel();
53954+ *(void **)&armada38x_rtc_ops.set_alarm = NULL;
53955+ *(void **)&armada38x_rtc_ops.alarm_irq_enable = NULL;
53956+ pax_close_kernel();
53957 }
53958 platform_set_drvdata(pdev, rtc);
53959 if (rtc->irq != -1)
53960diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
53961index a82556a0..e842923 100644
53962--- a/drivers/rtc/rtc-cmos.c
53963+++ b/drivers/rtc/rtc-cmos.c
53964@@ -793,7 +793,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
53965 hpet_rtc_timer_init();
53966
53967 /* export at least the first block of NVRAM */
53968- nvram.size = address_space - NVRAM_OFFSET;
53969+ pax_open_kernel();
53970+ *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
53971+ pax_close_kernel();
53972 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
53973 if (retval < 0) {
53974 dev_dbg(dev, "can't create nvram file? %d\n", retval);
53975diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
53976index 799c34b..8e9786a 100644
53977--- a/drivers/rtc/rtc-dev.c
53978+++ b/drivers/rtc/rtc-dev.c
53979@@ -16,6 +16,7 @@
53980 #include <linux/module.h>
53981 #include <linux/rtc.h>
53982 #include <linux/sched.h>
53983+#include <linux/grsecurity.h>
53984 #include "rtc-core.h"
53985
53986 static dev_t rtc_devt;
53987@@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
53988 if (copy_from_user(&tm, uarg, sizeof(tm)))
53989 return -EFAULT;
53990
53991+ gr_log_timechange();
53992+
53993 return rtc_set_time(rtc, &tm);
53994
53995 case RTC_PIE_ON:
53996diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
53997index 6e76de1..d38a1e0 100644
53998--- a/drivers/rtc/rtc-ds1307.c
53999+++ b/drivers/rtc/rtc-ds1307.c
54000@@ -107,7 +107,7 @@ struct ds1307 {
54001 u8 offset; /* register's offset */
54002 u8 regs[11];
54003 u16 nvram_offset;
54004- struct bin_attribute *nvram;
54005+ bin_attribute_no_const *nvram;
54006 enum ds_type type;
54007 unsigned long flags;
54008 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
54009diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
54010index 90abb5b..e0bf6dd 100644
54011--- a/drivers/rtc/rtc-m48t59.c
54012+++ b/drivers/rtc/rtc-m48t59.c
54013@@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
54014 if (IS_ERR(m48t59->rtc))
54015 return PTR_ERR(m48t59->rtc);
54016
54017- m48t59_nvram_attr.size = pdata->offset;
54018+ pax_open_kernel();
54019+ *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
54020+ pax_close_kernel();
54021
54022 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
54023 if (ret)
54024diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
54025index 3a2da4c..e88493c 100644
54026--- a/drivers/rtc/rtc-test.c
54027+++ b/drivers/rtc/rtc-test.c
54028@@ -112,8 +112,10 @@ static int test_probe(struct platform_device *plat_dev)
54029 struct rtc_device *rtc;
54030
54031 if (test_mmss64) {
54032- test_rtc_ops.set_mmss64 = test_rtc_set_mmss64;
54033- test_rtc_ops.set_mmss = NULL;
54034+ pax_open_kernel();
54035+ *(void **)&test_rtc_ops.set_mmss64 = test_rtc_set_mmss64;
54036+ *(void **)&test_rtc_ops.set_mmss = NULL;
54037+ pax_close_kernel();
54038 }
54039
54040 rtc = devm_rtc_device_register(&plat_dev->dev, "test",
54041diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
54042index 7a6dbfb..5cdcd29 100644
54043--- a/drivers/scsi/be2iscsi/be_main.c
54044+++ b/drivers/scsi/be2iscsi/be_main.c
54045@@ -3184,7 +3184,7 @@ be_sgl_create_contiguous(void *virtual_address,
54046 {
54047 WARN_ON(!virtual_address);
54048 WARN_ON(!physical_address);
54049- WARN_ON(!length > 0);
54050+ WARN_ON(!length);
54051 WARN_ON(!sgl);
54052
54053 sgl->va = virtual_address;
54054diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
54055index e693af6..2e525b6 100644
54056--- a/drivers/scsi/bfa/bfa_fcpim.h
54057+++ b/drivers/scsi/bfa/bfa_fcpim.h
54058@@ -36,7 +36,7 @@ struct bfa_iotag_s {
54059
54060 struct bfa_itn_s {
54061 bfa_isr_func_t isr;
54062-};
54063+} __no_const;
54064
54065 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
54066 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
54067diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c
54068index 0f19455..ef7adb5 100644
54069--- a/drivers/scsi/bfa/bfa_fcs.c
54070+++ b/drivers/scsi/bfa/bfa_fcs.c
54071@@ -38,10 +38,21 @@ struct bfa_fcs_mod_s {
54072 #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit }
54073
54074 static struct bfa_fcs_mod_s fcs_modules[] = {
54075- { bfa_fcs_port_attach, NULL, NULL },
54076- { bfa_fcs_uf_attach, NULL, NULL },
54077- { bfa_fcs_fabric_attach, bfa_fcs_fabric_modinit,
54078- bfa_fcs_fabric_modexit },
54079+ {
54080+ .attach = bfa_fcs_port_attach,
54081+ .modinit = NULL,
54082+ .modexit = NULL
54083+ },
54084+ {
54085+ .attach = bfa_fcs_uf_attach,
54086+ .modinit = NULL,
54087+ .modexit = NULL
54088+ },
54089+ {
54090+ .attach = bfa_fcs_fabric_attach,
54091+ .modinit = bfa_fcs_fabric_modinit,
54092+ .modexit = bfa_fcs_fabric_modexit
54093+ },
54094 };
54095
54096 /*
54097diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
54098index ff75ef8..2dfe00a 100644
54099--- a/drivers/scsi/bfa/bfa_fcs_lport.c
54100+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
54101@@ -89,15 +89,26 @@ static struct {
54102 void (*offline) (struct bfa_fcs_lport_s *port);
54103 } __port_action[] = {
54104 {
54105- bfa_fcs_lport_unknown_init, bfa_fcs_lport_unknown_online,
54106- bfa_fcs_lport_unknown_offline}, {
54107- bfa_fcs_lport_fab_init, bfa_fcs_lport_fab_online,
54108- bfa_fcs_lport_fab_offline}, {
54109- bfa_fcs_lport_n2n_init, bfa_fcs_lport_n2n_online,
54110- bfa_fcs_lport_n2n_offline}, {
54111- bfa_fcs_lport_loop_init, bfa_fcs_lport_loop_online,
54112- bfa_fcs_lport_loop_offline},
54113- };
54114+ .init = bfa_fcs_lport_unknown_init,
54115+ .online = bfa_fcs_lport_unknown_online,
54116+ .offline = bfa_fcs_lport_unknown_offline
54117+ },
54118+ {
54119+ .init = bfa_fcs_lport_fab_init,
54120+ .online = bfa_fcs_lport_fab_online,
54121+ .offline = bfa_fcs_lport_fab_offline
54122+ },
54123+ {
54124+ .init = bfa_fcs_lport_n2n_init,
54125+ .online = bfa_fcs_lport_n2n_online,
54126+ .offline = bfa_fcs_lport_n2n_offline
54127+ },
54128+ {
54129+ .init = bfa_fcs_lport_loop_init,
54130+ .online = bfa_fcs_lport_loop_online,
54131+ .offline = bfa_fcs_lport_loop_offline
54132+ },
54133+};
54134
54135 /*
54136 * fcs_port_sm FCS logical port state machine
54137diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
54138index a38aafa0..fe8f03b 100644
54139--- a/drivers/scsi/bfa/bfa_ioc.h
54140+++ b/drivers/scsi/bfa/bfa_ioc.h
54141@@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
54142 bfa_ioc_disable_cbfn_t disable_cbfn;
54143 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
54144 bfa_ioc_reset_cbfn_t reset_cbfn;
54145-};
54146+} __no_const;
54147
54148 /*
54149 * IOC event notification mechanism.
54150@@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
54151 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
54152 enum bfi_ioc_state fwstate);
54153 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
54154-};
54155+} __no_const;
54156
54157 /*
54158 * Queue element to wait for room in request queue. FIFO order is
54159diff --git a/drivers/scsi/bfa/bfa_modules.h b/drivers/scsi/bfa/bfa_modules.h
54160index a14c784..6de6790 100644
54161--- a/drivers/scsi/bfa/bfa_modules.h
54162+++ b/drivers/scsi/bfa/bfa_modules.h
54163@@ -78,12 +78,12 @@ enum {
54164 \
54165 extern struct bfa_module_s hal_mod_ ## __mod; \
54166 struct bfa_module_s hal_mod_ ## __mod = { \
54167- bfa_ ## __mod ## _meminfo, \
54168- bfa_ ## __mod ## _attach, \
54169- bfa_ ## __mod ## _detach, \
54170- bfa_ ## __mod ## _start, \
54171- bfa_ ## __mod ## _stop, \
54172- bfa_ ## __mod ## _iocdisable, \
54173+ .meminfo = bfa_ ## __mod ## _meminfo, \
54174+ .attach = bfa_ ## __mod ## _attach, \
54175+ .detach = bfa_ ## __mod ## _detach, \
54176+ .start = bfa_ ## __mod ## _start, \
54177+ .stop = bfa_ ## __mod ## _stop, \
54178+ .iocdisable = bfa_ ## __mod ## _iocdisable, \
54179 }
54180
54181 #define BFA_CACHELINE_SZ (256)
54182diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
54183index 045c4e1..13de803 100644
54184--- a/drivers/scsi/fcoe/fcoe_sysfs.c
54185+++ b/drivers/scsi/fcoe/fcoe_sysfs.c
54186@@ -33,8 +33,8 @@
54187 */
54188 #include "libfcoe.h"
54189
54190-static atomic_t ctlr_num;
54191-static atomic_t fcf_num;
54192+static atomic_unchecked_t ctlr_num;
54193+static atomic_unchecked_t fcf_num;
54194
54195 /*
54196 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
54197@@ -685,7 +685,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
54198 if (!ctlr)
54199 goto out;
54200
54201- ctlr->id = atomic_inc_return(&ctlr_num) - 1;
54202+ ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
54203 ctlr->f = f;
54204 ctlr->mode = FIP_CONN_TYPE_FABRIC;
54205 INIT_LIST_HEAD(&ctlr->fcfs);
54206@@ -902,7 +902,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
54207 fcf->dev.parent = &ctlr->dev;
54208 fcf->dev.bus = &fcoe_bus_type;
54209 fcf->dev.type = &fcoe_fcf_device_type;
54210- fcf->id = atomic_inc_return(&fcf_num) - 1;
54211+ fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
54212 fcf->state = FCOE_FCF_STATE_UNKNOWN;
54213
54214 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
54215@@ -938,8 +938,8 @@ int __init fcoe_sysfs_setup(void)
54216 {
54217 int error;
54218
54219- atomic_set(&ctlr_num, 0);
54220- atomic_set(&fcf_num, 0);
54221+ atomic_set_unchecked(&ctlr_num, 0);
54222+ atomic_set_unchecked(&fcf_num, 0);
54223
54224 error = bus_register(&fcoe_bus_type);
54225 if (error)
54226diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
54227index 8bb173e..20236b4 100644
54228--- a/drivers/scsi/hosts.c
54229+++ b/drivers/scsi/hosts.c
54230@@ -42,7 +42,7 @@
54231 #include "scsi_logging.h"
54232
54233
54234-static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
54235+static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
54236
54237
54238 static void scsi_host_cls_release(struct device *dev)
54239@@ -392,7 +392,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
54240 * subtract one because we increment first then return, but we need to
54241 * know what the next host number was before increment
54242 */
54243- shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
54244+ shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
54245 shost->dma_channel = 0xff;
54246
54247 /* These three are default values which can be overridden */
54248diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
54249index cab4e98..31323f6 100644
54250--- a/drivers/scsi/hpsa.c
54251+++ b/drivers/scsi/hpsa.c
54252@@ -793,10 +793,10 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
54253 struct reply_queue_buffer *rq = &h->reply_queue[q];
54254
54255 if (h->transMethod & CFGTBL_Trans_io_accel1)
54256- return h->access.command_completed(h, q);
54257+ return h->access->command_completed(h, q);
54258
54259 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
54260- return h->access.command_completed(h, q);
54261+ return h->access->command_completed(h, q);
54262
54263 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
54264 a = rq->head[rq->current_entry];
54265@@ -978,7 +978,7 @@ static void __enqueue_cmd_and_start_io(struct ctlr_info *h,
54266 break;
54267 default:
54268 set_performant_mode(h, c, reply_queue);
54269- h->access.submit_command(h, c);
54270+ h->access->submit_command(h, c);
54271 }
54272 }
54273
54274@@ -6343,17 +6343,17 @@ static void __iomem *remap_pci_mem(ulong base, ulong size)
54275
54276 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
54277 {
54278- return h->access.command_completed(h, q);
54279+ return h->access->command_completed(h, q);
54280 }
54281
54282 static inline bool interrupt_pending(struct ctlr_info *h)
54283 {
54284- return h->access.intr_pending(h);
54285+ return h->access->intr_pending(h);
54286 }
54287
54288 static inline long interrupt_not_for_us(struct ctlr_info *h)
54289 {
54290- return (h->access.intr_pending(h) == 0) ||
54291+ return (h->access->intr_pending(h) == 0) ||
54292 (h->interrupts_enabled == 0);
54293 }
54294
54295@@ -7291,7 +7291,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
54296 if (prod_index < 0)
54297 return prod_index;
54298 h->product_name = products[prod_index].product_name;
54299- h->access = *(products[prod_index].access);
54300+ h->access = products[prod_index].access;
54301
54302 h->needs_abort_tags_swizzled =
54303 ctlr_needs_abort_tags_swizzled(h->board_id);
54304@@ -7690,7 +7690,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
54305 unsigned long flags;
54306 u32 lockup_detected;
54307
54308- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54309+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54310 spin_lock_irqsave(&h->lock, flags);
54311 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
54312 if (!lockup_detected) {
54313@@ -7973,7 +7973,7 @@ reinit_after_soft_reset:
54314 }
54315
54316 /* make sure the board interrupts are off */
54317- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54318+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54319
54320 rc = hpsa_request_irqs(h, do_hpsa_intr_msi, do_hpsa_intr_intx);
54321 if (rc)
54322@@ -8032,7 +8032,7 @@ reinit_after_soft_reset:
54323 * fake ones to scoop up any residual completions.
54324 */
54325 spin_lock_irqsave(&h->lock, flags);
54326- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54327+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54328 spin_unlock_irqrestore(&h->lock, flags);
54329 hpsa_free_irqs(h);
54330 rc = hpsa_request_irqs(h, hpsa_msix_discard_completions,
54331@@ -8062,9 +8062,9 @@ reinit_after_soft_reset:
54332 dev_info(&h->pdev->dev, "Board READY.\n");
54333 dev_info(&h->pdev->dev,
54334 "Waiting for stale completions to drain.\n");
54335- h->access.set_intr_mask(h, HPSA_INTR_ON);
54336+ h->access->set_intr_mask(h, HPSA_INTR_ON);
54337 msleep(10000);
54338- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54339+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54340
54341 rc = controller_reset_failed(h->cfgtable);
54342 if (rc)
54343@@ -8089,7 +8089,7 @@ reinit_after_soft_reset:
54344
54345
54346 /* Turn the interrupts on so we can service requests */
54347- h->access.set_intr_mask(h, HPSA_INTR_ON);
54348+ h->access->set_intr_mask(h, HPSA_INTR_ON);
54349
54350 hpsa_hba_inquiry(h);
54351
54352@@ -8107,7 +8107,7 @@ clean9: /* wq, sh, perf, sg, cmd, irq, shost, pci, lu, aer/h */
54353 kfree(h->hba_inquiry_data);
54354 clean7: /* perf, sg, cmd, irq, shost, pci, lu, aer/h */
54355 hpsa_free_performant_mode(h);
54356- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54357+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54358 clean6: /* sg, cmd, irq, pci, lockup, wq/aer/h */
54359 hpsa_free_sg_chain_blocks(h);
54360 clean5: /* cmd, irq, shost, pci, lu, aer/h */
54361@@ -8177,7 +8177,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
54362 * To write all data in the battery backed cache to disks
54363 */
54364 hpsa_flush_cache(h);
54365- h->access.set_intr_mask(h, HPSA_INTR_OFF);
54366+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
54367 hpsa_free_irqs(h); /* init_one 4 */
54368 hpsa_disable_interrupt_mode(h); /* pci_init 2 */
54369 }
54370@@ -8309,7 +8309,7 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
54371 CFGTBL_Trans_enable_directed_msix |
54372 (trans_support & (CFGTBL_Trans_io_accel1 |
54373 CFGTBL_Trans_io_accel2));
54374- struct access_method access = SA5_performant_access;
54375+ struct access_method *access = &SA5_performant_access;
54376
54377 /* This is a bit complicated. There are 8 registers on
54378 * the controller which we write to to tell it 8 different
54379@@ -8351,7 +8351,7 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
54380 * perform the superfluous readl() after each command submission.
54381 */
54382 if (trans_support & (CFGTBL_Trans_io_accel1 | CFGTBL_Trans_io_accel2))
54383- access = SA5_performant_access_no_read;
54384+ access = &SA5_performant_access_no_read;
54385
54386 /* Controller spec: zero out this buffer. */
54387 for (i = 0; i < h->nreply_queues; i++)
54388@@ -8381,12 +8381,12 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
54389 * enable outbound interrupt coalescing in accelerator mode;
54390 */
54391 if (trans_support & CFGTBL_Trans_io_accel1) {
54392- access = SA5_ioaccel_mode1_access;
54393+ access = &SA5_ioaccel_mode1_access;
54394 writel(10, &h->cfgtable->HostWrite.CoalIntDelay);
54395 writel(4, &h->cfgtable->HostWrite.CoalIntCount);
54396 } else {
54397 if (trans_support & CFGTBL_Trans_io_accel2) {
54398- access = SA5_ioaccel_mode2_access;
54399+ access = &SA5_ioaccel_mode2_access;
54400 writel(10, &h->cfgtable->HostWrite.CoalIntDelay);
54401 writel(4, &h->cfgtable->HostWrite.CoalIntCount);
54402 }
54403diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
54404index 6ee4da6..dfafb48 100644
54405--- a/drivers/scsi/hpsa.h
54406+++ b/drivers/scsi/hpsa.h
54407@@ -152,7 +152,7 @@ struct ctlr_info {
54408 unsigned int msix_vector;
54409 unsigned int msi_vector;
54410 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
54411- struct access_method access;
54412+ struct access_method *access;
54413 char hba_mode_enabled;
54414
54415 /* queue and queue Info */
54416@@ -542,38 +542,38 @@ static unsigned long SA5_ioaccel_mode1_completed(struct ctlr_info *h, u8 q)
54417 }
54418
54419 static struct access_method SA5_access = {
54420- SA5_submit_command,
54421- SA5_intr_mask,
54422- SA5_intr_pending,
54423- SA5_completed,
54424+ .submit_command = SA5_submit_command,
54425+ .set_intr_mask = SA5_intr_mask,
54426+ .intr_pending = SA5_intr_pending,
54427+ .command_completed = SA5_completed,
54428 };
54429
54430 static struct access_method SA5_ioaccel_mode1_access = {
54431- SA5_submit_command,
54432- SA5_performant_intr_mask,
54433- SA5_ioaccel_mode1_intr_pending,
54434- SA5_ioaccel_mode1_completed,
54435+ .submit_command = SA5_submit_command,
54436+ .set_intr_mask = SA5_performant_intr_mask,
54437+ .intr_pending = SA5_ioaccel_mode1_intr_pending,
54438+ .command_completed = SA5_ioaccel_mode1_completed,
54439 };
54440
54441 static struct access_method SA5_ioaccel_mode2_access = {
54442- SA5_submit_command_ioaccel2,
54443- SA5_performant_intr_mask,
54444- SA5_performant_intr_pending,
54445- SA5_performant_completed,
54446+ .submit_command = SA5_submit_command_ioaccel2,
54447+ .set_intr_mask = SA5_performant_intr_mask,
54448+ .intr_pending = SA5_performant_intr_pending,
54449+ .command_completed = SA5_performant_completed,
54450 };
54451
54452 static struct access_method SA5_performant_access = {
54453- SA5_submit_command,
54454- SA5_performant_intr_mask,
54455- SA5_performant_intr_pending,
54456- SA5_performant_completed,
54457+ .submit_command = SA5_submit_command,
54458+ .set_intr_mask = SA5_performant_intr_mask,
54459+ .intr_pending = SA5_performant_intr_pending,
54460+ .command_completed = SA5_performant_completed,
54461 };
54462
54463 static struct access_method SA5_performant_access_no_read = {
54464- SA5_submit_command_no_read,
54465- SA5_performant_intr_mask,
54466- SA5_performant_intr_pending,
54467- SA5_performant_completed,
54468+ .submit_command = SA5_submit_command_no_read,
54469+ .set_intr_mask = SA5_performant_intr_mask,
54470+ .intr_pending = SA5_performant_intr_pending,
54471+ .command_completed = SA5_performant_completed,
54472 };
54473
54474 struct board_type {
54475diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
54476index 30f9ef0..a1e29ac 100644
54477--- a/drivers/scsi/libfc/fc_exch.c
54478+++ b/drivers/scsi/libfc/fc_exch.c
54479@@ -101,12 +101,12 @@ struct fc_exch_mgr {
54480 u16 pool_max_index;
54481
54482 struct {
54483- atomic_t no_free_exch;
54484- atomic_t no_free_exch_xid;
54485- atomic_t xid_not_found;
54486- atomic_t xid_busy;
54487- atomic_t seq_not_found;
54488- atomic_t non_bls_resp;
54489+ atomic_unchecked_t no_free_exch;
54490+ atomic_unchecked_t no_free_exch_xid;
54491+ atomic_unchecked_t xid_not_found;
54492+ atomic_unchecked_t xid_busy;
54493+ atomic_unchecked_t seq_not_found;
54494+ atomic_unchecked_t non_bls_resp;
54495 } stats;
54496 };
54497
54498@@ -809,7 +809,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
54499 /* allocate memory for exchange */
54500 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
54501 if (!ep) {
54502- atomic_inc(&mp->stats.no_free_exch);
54503+ atomic_inc_unchecked(&mp->stats.no_free_exch);
54504 goto out;
54505 }
54506 memset(ep, 0, sizeof(*ep));
54507@@ -872,7 +872,7 @@ out:
54508 return ep;
54509 err:
54510 spin_unlock_bh(&pool->lock);
54511- atomic_inc(&mp->stats.no_free_exch_xid);
54512+ atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
54513 mempool_free(ep, mp->ep_pool);
54514 return NULL;
54515 }
54516@@ -1021,7 +1021,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
54517 xid = ntohs(fh->fh_ox_id); /* we originated exch */
54518 ep = fc_exch_find(mp, xid);
54519 if (!ep) {
54520- atomic_inc(&mp->stats.xid_not_found);
54521+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54522 reject = FC_RJT_OX_ID;
54523 goto out;
54524 }
54525@@ -1051,7 +1051,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
54526 ep = fc_exch_find(mp, xid);
54527 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
54528 if (ep) {
54529- atomic_inc(&mp->stats.xid_busy);
54530+ atomic_inc_unchecked(&mp->stats.xid_busy);
54531 reject = FC_RJT_RX_ID;
54532 goto rel;
54533 }
54534@@ -1062,7 +1062,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
54535 }
54536 xid = ep->xid; /* get our XID */
54537 } else if (!ep) {
54538- atomic_inc(&mp->stats.xid_not_found);
54539+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54540 reject = FC_RJT_RX_ID; /* XID not found */
54541 goto out;
54542 }
54543@@ -1080,7 +1080,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
54544 } else {
54545 sp = &ep->seq;
54546 if (sp->id != fh->fh_seq_id) {
54547- atomic_inc(&mp->stats.seq_not_found);
54548+ atomic_inc_unchecked(&mp->stats.seq_not_found);
54549 if (f_ctl & FC_FC_END_SEQ) {
54550 /*
54551 * Update sequence_id based on incoming last
54552@@ -1531,22 +1531,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
54553
54554 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
54555 if (!ep) {
54556- atomic_inc(&mp->stats.xid_not_found);
54557+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54558 goto out;
54559 }
54560 if (ep->esb_stat & ESB_ST_COMPLETE) {
54561- atomic_inc(&mp->stats.xid_not_found);
54562+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54563 goto rel;
54564 }
54565 if (ep->rxid == FC_XID_UNKNOWN)
54566 ep->rxid = ntohs(fh->fh_rx_id);
54567 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
54568- atomic_inc(&mp->stats.xid_not_found);
54569+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54570 goto rel;
54571 }
54572 if (ep->did != ntoh24(fh->fh_s_id) &&
54573 ep->did != FC_FID_FLOGI) {
54574- atomic_inc(&mp->stats.xid_not_found);
54575+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54576 goto rel;
54577 }
54578 sof = fr_sof(fp);
54579@@ -1555,7 +1555,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
54580 sp->ssb_stat |= SSB_ST_RESP;
54581 sp->id = fh->fh_seq_id;
54582 } else if (sp->id != fh->fh_seq_id) {
54583- atomic_inc(&mp->stats.seq_not_found);
54584+ atomic_inc_unchecked(&mp->stats.seq_not_found);
54585 goto rel;
54586 }
54587
54588@@ -1618,9 +1618,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
54589 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
54590
54591 if (!sp)
54592- atomic_inc(&mp->stats.xid_not_found);
54593+ atomic_inc_unchecked(&mp->stats.xid_not_found);
54594 else
54595- atomic_inc(&mp->stats.non_bls_resp);
54596+ atomic_inc_unchecked(&mp->stats.non_bls_resp);
54597
54598 fc_frame_free(fp);
54599 }
54600@@ -2261,13 +2261,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
54601
54602 list_for_each_entry(ema, &lport->ema_list, ema_list) {
54603 mp = ema->mp;
54604- st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
54605+ st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
54606 st->fc_no_free_exch_xid +=
54607- atomic_read(&mp->stats.no_free_exch_xid);
54608- st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
54609- st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
54610- st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
54611- st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
54612+ atomic_read_unchecked(&mp->stats.no_free_exch_xid);
54613+ st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
54614+ st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
54615+ st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
54616+ st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
54617 }
54618 }
54619 EXPORT_SYMBOL(fc_exch_update_stats);
54620diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
54621index 9c706d8..d3e3ed2 100644
54622--- a/drivers/scsi/libsas/sas_ata.c
54623+++ b/drivers/scsi/libsas/sas_ata.c
54624@@ -535,7 +535,7 @@ static struct ata_port_operations sas_sata_ops = {
54625 .postreset = ata_std_postreset,
54626 .error_handler = ata_std_error_handler,
54627 .post_internal_cmd = sas_ata_post_internal,
54628- .qc_defer = ata_std_qc_defer,
54629+ .qc_defer = ata_std_qc_defer,
54630 .qc_prep = ata_noop_qc_prep,
54631 .qc_issue = sas_ata_qc_issue,
54632 .qc_fill_rtf = sas_ata_qc_fill_rtf,
54633diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
54634index a5a56fa..43499fd 100644
54635--- a/drivers/scsi/lpfc/lpfc.h
54636+++ b/drivers/scsi/lpfc/lpfc.h
54637@@ -435,7 +435,7 @@ struct lpfc_vport {
54638 struct dentry *debug_nodelist;
54639 struct dentry *vport_debugfs_root;
54640 struct lpfc_debugfs_trc *disc_trc;
54641- atomic_t disc_trc_cnt;
54642+ atomic_unchecked_t disc_trc_cnt;
54643 #endif
54644 uint8_t stat_data_enabled;
54645 uint8_t stat_data_blocked;
54646@@ -885,8 +885,8 @@ struct lpfc_hba {
54647 struct timer_list fabric_block_timer;
54648 unsigned long bit_flags;
54649 #define FABRIC_COMANDS_BLOCKED 0
54650- atomic_t num_rsrc_err;
54651- atomic_t num_cmd_success;
54652+ atomic_unchecked_t num_rsrc_err;
54653+ atomic_unchecked_t num_cmd_success;
54654 unsigned long last_rsrc_error_time;
54655 unsigned long last_ramp_down_time;
54656 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
54657@@ -921,7 +921,7 @@ struct lpfc_hba {
54658
54659 struct dentry *debug_slow_ring_trc;
54660 struct lpfc_debugfs_trc *slow_ring_trc;
54661- atomic_t slow_ring_trc_cnt;
54662+ atomic_unchecked_t slow_ring_trc_cnt;
54663 /* iDiag debugfs sub-directory */
54664 struct dentry *idiag_root;
54665 struct dentry *idiag_pci_cfg;
54666diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
54667index 25aa9b9..d700a65 100644
54668--- a/drivers/scsi/lpfc/lpfc_debugfs.c
54669+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
54670@@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
54671
54672 #include <linux/debugfs.h>
54673
54674-static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
54675+static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
54676 static unsigned long lpfc_debugfs_start_time = 0L;
54677
54678 /* iDiag */
54679@@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
54680 lpfc_debugfs_enable = 0;
54681
54682 len = 0;
54683- index = (atomic_read(&vport->disc_trc_cnt) + 1) &
54684+ index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
54685 (lpfc_debugfs_max_disc_trc - 1);
54686 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
54687 dtp = vport->disc_trc + i;
54688@@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
54689 lpfc_debugfs_enable = 0;
54690
54691 len = 0;
54692- index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
54693+ index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
54694 (lpfc_debugfs_max_slow_ring_trc - 1);
54695 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
54696 dtp = phba->slow_ring_trc + i;
54697@@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
54698 !vport || !vport->disc_trc)
54699 return;
54700
54701- index = atomic_inc_return(&vport->disc_trc_cnt) &
54702+ index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
54703 (lpfc_debugfs_max_disc_trc - 1);
54704 dtp = vport->disc_trc + index;
54705 dtp->fmt = fmt;
54706 dtp->data1 = data1;
54707 dtp->data2 = data2;
54708 dtp->data3 = data3;
54709- dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
54710+ dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
54711 dtp->jif = jiffies;
54712 #endif
54713 return;
54714@@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
54715 !phba || !phba->slow_ring_trc)
54716 return;
54717
54718- index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
54719+ index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
54720 (lpfc_debugfs_max_slow_ring_trc - 1);
54721 dtp = phba->slow_ring_trc + index;
54722 dtp->fmt = fmt;
54723 dtp->data1 = data1;
54724 dtp->data2 = data2;
54725 dtp->data3 = data3;
54726- dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
54727+ dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
54728 dtp->jif = jiffies;
54729 #endif
54730 return;
54731@@ -4268,7 +4268,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
54732 "slow_ring buffer\n");
54733 goto debug_failed;
54734 }
54735- atomic_set(&phba->slow_ring_trc_cnt, 0);
54736+ atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
54737 memset(phba->slow_ring_trc, 0,
54738 (sizeof(struct lpfc_debugfs_trc) *
54739 lpfc_debugfs_max_slow_ring_trc));
54740@@ -4314,7 +4314,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
54741 "buffer\n");
54742 goto debug_failed;
54743 }
54744- atomic_set(&vport->disc_trc_cnt, 0);
54745+ atomic_set_unchecked(&vport->disc_trc_cnt, 0);
54746
54747 snprintf(name, sizeof(name), "discovery_trace");
54748 vport->debug_disc_trc =
54749diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
54750index f962118..6706983 100644
54751--- a/drivers/scsi/lpfc/lpfc_init.c
54752+++ b/drivers/scsi/lpfc/lpfc_init.c
54753@@ -11416,8 +11416,10 @@ lpfc_init(void)
54754 "misc_register returned with status %d", error);
54755
54756 if (lpfc_enable_npiv) {
54757- lpfc_transport_functions.vport_create = lpfc_vport_create;
54758- lpfc_transport_functions.vport_delete = lpfc_vport_delete;
54759+ pax_open_kernel();
54760+ *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
54761+ *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
54762+ pax_close_kernel();
54763 }
54764 lpfc_transport_template =
54765 fc_attach_transport(&lpfc_transport_functions);
54766diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
54767index e5eb40d..056dcd4 100644
54768--- a/drivers/scsi/lpfc/lpfc_scsi.c
54769+++ b/drivers/scsi/lpfc/lpfc_scsi.c
54770@@ -261,7 +261,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
54771 unsigned long expires;
54772
54773 spin_lock_irqsave(&phba->hbalock, flags);
54774- atomic_inc(&phba->num_rsrc_err);
54775+ atomic_inc_unchecked(&phba->num_rsrc_err);
54776 phba->last_rsrc_error_time = jiffies;
54777
54778 expires = phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL;
54779@@ -303,8 +303,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
54780 unsigned long num_rsrc_err, num_cmd_success;
54781 int i;
54782
54783- num_rsrc_err = atomic_read(&phba->num_rsrc_err);
54784- num_cmd_success = atomic_read(&phba->num_cmd_success);
54785+ num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
54786+ num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
54787
54788 /*
54789 * The error and success command counters are global per
54790@@ -331,8 +331,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
54791 }
54792 }
54793 lpfc_destroy_vport_work_array(phba, vports);
54794- atomic_set(&phba->num_rsrc_err, 0);
54795- atomic_set(&phba->num_cmd_success, 0);
54796+ atomic_set_unchecked(&phba->num_rsrc_err, 0);
54797+ atomic_set_unchecked(&phba->num_cmd_success, 0);
54798 }
54799
54800 /**
54801diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
54802index 20c3754..1b05e727 100644
54803--- a/drivers/scsi/megaraid/megaraid_sas.h
54804+++ b/drivers/scsi/megaraid/megaraid_sas.h
54805@@ -1700,7 +1700,7 @@ struct megasas_instance {
54806 s8 init_id;
54807
54808 u16 max_num_sge;
54809- u16 max_fw_cmds;
54810+ u16 max_fw_cmds __intentional_overflow(-1);
54811 u16 max_mfi_cmds;
54812 u16 max_scsi_cmds;
54813 u32 max_sectors_per_req;
54814diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
54815index 3f26147..ee8efd1 100644
54816--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
54817+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
54818@@ -1509,7 +1509,7 @@ _scsih_get_resync(struct device *dev)
54819 {
54820 struct scsi_device *sdev = to_scsi_device(dev);
54821 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
54822- static struct _raid_device *raid_device;
54823+ struct _raid_device *raid_device;
54824 unsigned long flags;
54825 Mpi2RaidVolPage0_t vol_pg0;
54826 Mpi2ConfigReply_t mpi_reply;
54827@@ -1561,7 +1561,7 @@ _scsih_get_state(struct device *dev)
54828 {
54829 struct scsi_device *sdev = to_scsi_device(dev);
54830 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
54831- static struct _raid_device *raid_device;
54832+ struct _raid_device *raid_device;
54833 unsigned long flags;
54834 Mpi2RaidVolPage0_t vol_pg0;
54835 Mpi2ConfigReply_t mpi_reply;
54836@@ -6641,7 +6641,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
54837 Mpi2EventDataIrOperationStatus_t *event_data =
54838 (Mpi2EventDataIrOperationStatus_t *)
54839 fw_event->event_data;
54840- static struct _raid_device *raid_device;
54841+ struct _raid_device *raid_device;
54842 unsigned long flags;
54843 u16 handle;
54844
54845@@ -7112,7 +7112,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
54846 u64 sas_address;
54847 struct _sas_device *sas_device;
54848 struct _sas_node *expander_device;
54849- static struct _raid_device *raid_device;
54850+ struct _raid_device *raid_device;
54851 u8 retry_count;
54852 unsigned long flags;
54853
54854diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
54855index ed31d8c..ab856b3 100644
54856--- a/drivers/scsi/pmcraid.c
54857+++ b/drivers/scsi/pmcraid.c
54858@@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
54859 res->scsi_dev = scsi_dev;
54860 scsi_dev->hostdata = res;
54861 res->change_detected = 0;
54862- atomic_set(&res->read_failures, 0);
54863- atomic_set(&res->write_failures, 0);
54864+ atomic_set_unchecked(&res->read_failures, 0);
54865+ atomic_set_unchecked(&res->write_failures, 0);
54866 rc = 0;
54867 }
54868 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
54869@@ -2640,9 +2640,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
54870
54871 /* If this was a SCSI read/write command keep count of errors */
54872 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
54873- atomic_inc(&res->read_failures);
54874+ atomic_inc_unchecked(&res->read_failures);
54875 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
54876- atomic_inc(&res->write_failures);
54877+ atomic_inc_unchecked(&res->write_failures);
54878
54879 if (!RES_IS_GSCSI(res->cfg_entry) &&
54880 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
54881@@ -3468,7 +3468,7 @@ static int pmcraid_queuecommand_lck(
54882 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
54883 * hrrq_id assigned here in queuecommand
54884 */
54885- ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
54886+ ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
54887 pinstance->num_hrrq;
54888 cmd->cmd_done = pmcraid_io_done;
54889
54890@@ -3782,7 +3782,7 @@ static long pmcraid_ioctl_passthrough(
54891 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
54892 * hrrq_id assigned here in queuecommand
54893 */
54894- ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
54895+ ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
54896 pinstance->num_hrrq;
54897
54898 if (request_size) {
54899@@ -4420,7 +4420,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
54900
54901 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
54902 /* add resources only after host is added into system */
54903- if (!atomic_read(&pinstance->expose_resources))
54904+ if (!atomic_read_unchecked(&pinstance->expose_resources))
54905 return;
54906
54907 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
54908@@ -5237,8 +5237,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
54909 init_waitqueue_head(&pinstance->reset_wait_q);
54910
54911 atomic_set(&pinstance->outstanding_cmds, 0);
54912- atomic_set(&pinstance->last_message_id, 0);
54913- atomic_set(&pinstance->expose_resources, 0);
54914+ atomic_set_unchecked(&pinstance->last_message_id, 0);
54915+ atomic_set_unchecked(&pinstance->expose_resources, 0);
54916
54917 INIT_LIST_HEAD(&pinstance->free_res_q);
54918 INIT_LIST_HEAD(&pinstance->used_res_q);
54919@@ -5951,7 +5951,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
54920 /* Schedule worker thread to handle CCN and take care of adding and
54921 * removing devices to OS
54922 */
54923- atomic_set(&pinstance->expose_resources, 1);
54924+ atomic_set_unchecked(&pinstance->expose_resources, 1);
54925 schedule_work(&pinstance->worker_q);
54926 return rc;
54927
54928diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
54929index e1d150f..6c6df44 100644
54930--- a/drivers/scsi/pmcraid.h
54931+++ b/drivers/scsi/pmcraid.h
54932@@ -748,7 +748,7 @@ struct pmcraid_instance {
54933 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
54934
54935 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
54936- atomic_t last_message_id;
54937+ atomic_unchecked_t last_message_id;
54938
54939 /* configuration table */
54940 struct pmcraid_config_table *cfg_table;
54941@@ -777,7 +777,7 @@ struct pmcraid_instance {
54942 atomic_t outstanding_cmds;
54943
54944 /* should add/delete resources to mid-layer now ?*/
54945- atomic_t expose_resources;
54946+ atomic_unchecked_t expose_resources;
54947
54948
54949
54950@@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
54951 struct pmcraid_config_table_entry_ext cfg_entry_ext;
54952 };
54953 struct scsi_device *scsi_dev; /* Link scsi_device structure */
54954- atomic_t read_failures; /* count of failed READ commands */
54955- atomic_t write_failures; /* count of failed WRITE commands */
54956+ atomic_unchecked_t read_failures; /* count of failed READ commands */
54957+ atomic_unchecked_t write_failures; /* count of failed WRITE commands */
54958
54959 /* To indicate add/delete/modify during CCN */
54960 u8 change_detected;
54961diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
54962index 437254e..a66eb82 100644
54963--- a/drivers/scsi/qla2xxx/qla_attr.c
54964+++ b/drivers/scsi/qla2xxx/qla_attr.c
54965@@ -2192,7 +2192,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
54966 return 0;
54967 }
54968
54969-struct fc_function_template qla2xxx_transport_functions = {
54970+fc_function_template_no_const qla2xxx_transport_functions = {
54971
54972 .show_host_node_name = 1,
54973 .show_host_port_name = 1,
54974@@ -2240,7 +2240,7 @@ struct fc_function_template qla2xxx_transport_functions = {
54975 .bsg_timeout = qla24xx_bsg_timeout,
54976 };
54977
54978-struct fc_function_template qla2xxx_transport_vport_functions = {
54979+fc_function_template_no_const qla2xxx_transport_vport_functions = {
54980
54981 .show_host_node_name = 1,
54982 .show_host_port_name = 1,
54983diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
54984index 7686bfe..4710893 100644
54985--- a/drivers/scsi/qla2xxx/qla_gbl.h
54986+++ b/drivers/scsi/qla2xxx/qla_gbl.h
54987@@ -571,8 +571,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *, size_t);
54988 struct device_attribute;
54989 extern struct device_attribute *qla2x00_host_attrs[];
54990 struct fc_function_template;
54991-extern struct fc_function_template qla2xxx_transport_functions;
54992-extern struct fc_function_template qla2xxx_transport_vport_functions;
54993+extern fc_function_template_no_const qla2xxx_transport_functions;
54994+extern fc_function_template_no_const qla2xxx_transport_vport_functions;
54995 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
54996 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *, bool);
54997 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
54998diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
54999index 8a5cac8..4eba6ab 100644
55000--- a/drivers/scsi/qla2xxx/qla_os.c
55001+++ b/drivers/scsi/qla2xxx/qla_os.c
55002@@ -1435,8 +1435,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
55003 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
55004 /* Ok, a 64bit DMA mask is applicable. */
55005 ha->flags.enable_64bit_addressing = 1;
55006- ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
55007- ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
55008+ pax_open_kernel();
55009+ *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
55010+ *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
55011+ pax_close_kernel();
55012 return;
55013 }
55014 }
55015diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
55016index a7cfc27..151f483 100644
55017--- a/drivers/scsi/qla4xxx/ql4_def.h
55018+++ b/drivers/scsi/qla4xxx/ql4_def.h
55019@@ -306,7 +306,7 @@ struct ddb_entry {
55020 * (4000 only) */
55021 atomic_t relogin_timer; /* Max Time to wait for
55022 * relogin to complete */
55023- atomic_t relogin_retry_count; /* Num of times relogin has been
55024+ atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
55025 * retried */
55026 uint32_t default_time2wait; /* Default Min time between
55027 * relogins (+aens) */
55028diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
55029index 6d25879..3031a9f 100644
55030--- a/drivers/scsi/qla4xxx/ql4_os.c
55031+++ b/drivers/scsi/qla4xxx/ql4_os.c
55032@@ -4491,12 +4491,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
55033 */
55034 if (!iscsi_is_session_online(cls_sess)) {
55035 /* Reset retry relogin timer */
55036- atomic_inc(&ddb_entry->relogin_retry_count);
55037+ atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
55038 DEBUG2(ql4_printk(KERN_INFO, ha,
55039 "%s: index[%d] relogin timed out-retrying"
55040 " relogin (%d), retry (%d)\n", __func__,
55041 ddb_entry->fw_ddb_index,
55042- atomic_read(&ddb_entry->relogin_retry_count),
55043+ atomic_read_unchecked(&ddb_entry->relogin_retry_count),
55044 ddb_entry->default_time2wait + 4));
55045 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
55046 atomic_set(&ddb_entry->retry_relogin_timer,
55047@@ -6604,7 +6604,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
55048
55049 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
55050 atomic_set(&ddb_entry->relogin_timer, 0);
55051- atomic_set(&ddb_entry->relogin_retry_count, 0);
55052+ atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
55053 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
55054 ddb_entry->default_relogin_timeout =
55055 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
55056diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
55057index 207d6a7..bf155b5 100644
55058--- a/drivers/scsi/scsi.c
55059+++ b/drivers/scsi/scsi.c
55060@@ -591,7 +591,7 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
55061
55062 good_bytes = scsi_bufflen(cmd);
55063 if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) {
55064- int old_good_bytes = good_bytes;
55065+ unsigned int old_good_bytes = good_bytes;
55066 drv = scsi_cmd_to_driver(cmd);
55067 if (drv->done)
55068 good_bytes = drv->done(cmd);
55069diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
55070index 448ebda..9bd345f 100644
55071--- a/drivers/scsi/scsi_lib.c
55072+++ b/drivers/scsi/scsi_lib.c
55073@@ -1597,7 +1597,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
55074 shost = sdev->host;
55075 scsi_init_cmd_errh(cmd);
55076 cmd->result = DID_NO_CONNECT << 16;
55077- atomic_inc(&cmd->device->iorequest_cnt);
55078+ atomic_inc_unchecked(&cmd->device->iorequest_cnt);
55079
55080 /*
55081 * SCSI request completion path will do scsi_device_unbusy(),
55082@@ -1620,9 +1620,9 @@ static void scsi_softirq_done(struct request *rq)
55083
55084 INIT_LIST_HEAD(&cmd->eh_entry);
55085
55086- atomic_inc(&cmd->device->iodone_cnt);
55087+ atomic_inc_unchecked(&cmd->device->iodone_cnt);
55088 if (cmd->result)
55089- atomic_inc(&cmd->device->ioerr_cnt);
55090+ atomic_inc_unchecked(&cmd->device->ioerr_cnt);
55091
55092 disposition = scsi_decide_disposition(cmd);
55093 if (disposition != SUCCESS &&
55094@@ -1663,7 +1663,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
55095 struct Scsi_Host *host = cmd->device->host;
55096 int rtn = 0;
55097
55098- atomic_inc(&cmd->device->iorequest_cnt);
55099+ atomic_inc_unchecked(&cmd->device->iorequest_cnt);
55100
55101 /* check if the device is still usable */
55102 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
55103diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
55104index 9ad4116..4e736fc 100644
55105--- a/drivers/scsi/scsi_sysfs.c
55106+++ b/drivers/scsi/scsi_sysfs.c
55107@@ -788,7 +788,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
55108 char *buf) \
55109 { \
55110 struct scsi_device *sdev = to_scsi_device(dev); \
55111- unsigned long long count = atomic_read(&sdev->field); \
55112+ unsigned long long count = atomic_read_unchecked(&sdev->field); \
55113 return snprintf(buf, 20, "0x%llx\n", count); \
55114 } \
55115 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
55116diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
55117index 24eaaf6..de30ec9 100644
55118--- a/drivers/scsi/scsi_transport_fc.c
55119+++ b/drivers/scsi/scsi_transport_fc.c
55120@@ -502,7 +502,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
55121 * Netlink Infrastructure
55122 */
55123
55124-static atomic_t fc_event_seq;
55125+static atomic_unchecked_t fc_event_seq;
55126
55127 /**
55128 * fc_get_event_number - Obtain the next sequential FC event number
55129@@ -515,7 +515,7 @@ static atomic_t fc_event_seq;
55130 u32
55131 fc_get_event_number(void)
55132 {
55133- return atomic_add_return(1, &fc_event_seq);
55134+ return atomic_add_return_unchecked(1, &fc_event_seq);
55135 }
55136 EXPORT_SYMBOL(fc_get_event_number);
55137
55138@@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
55139 {
55140 int error;
55141
55142- atomic_set(&fc_event_seq, 0);
55143+ atomic_set_unchecked(&fc_event_seq, 0);
55144
55145 error = transport_class_register(&fc_host_class);
55146 if (error)
55147@@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
55148 char *cp;
55149
55150 *val = simple_strtoul(buf, &cp, 0);
55151- if ((*cp && (*cp != '\n')) || (*val < 0))
55152+ if (*cp && (*cp != '\n'))
55153 return -EINVAL;
55154 /*
55155 * Check for overflow; dev_loss_tmo is u32
55156diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
55157index 55647aa..b647d05 100644
55158--- a/drivers/scsi/scsi_transport_iscsi.c
55159+++ b/drivers/scsi/scsi_transport_iscsi.c
55160@@ -79,7 +79,7 @@ struct iscsi_internal {
55161 struct transport_container session_cont;
55162 };
55163
55164-static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
55165+static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
55166 static struct workqueue_struct *iscsi_eh_timer_workq;
55167
55168 static DEFINE_IDA(iscsi_sess_ida);
55169@@ -2073,7 +2073,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
55170 int err;
55171
55172 ihost = shost->shost_data;
55173- session->sid = atomic_add_return(1, &iscsi_session_nr);
55174+ session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
55175
55176 if (target_id == ISCSI_MAX_TARGET) {
55177 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
55178@@ -4517,7 +4517,7 @@ static __init int iscsi_transport_init(void)
55179 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
55180 ISCSI_TRANSPORT_VERSION);
55181
55182- atomic_set(&iscsi_session_nr, 0);
55183+ atomic_set_unchecked(&iscsi_session_nr, 0);
55184
55185 err = class_register(&iscsi_transport_class);
55186 if (err)
55187diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
55188index e3cd3ec..00560ec 100644
55189--- a/drivers/scsi/scsi_transport_srp.c
55190+++ b/drivers/scsi/scsi_transport_srp.c
55191@@ -35,7 +35,7 @@
55192 #include "scsi_priv.h"
55193
55194 struct srp_host_attrs {
55195- atomic_t next_port_id;
55196+ atomic_unchecked_t next_port_id;
55197 };
55198 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
55199
55200@@ -105,7 +105,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
55201 struct Scsi_Host *shost = dev_to_shost(dev);
55202 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
55203
55204- atomic_set(&srp_host->next_port_id, 0);
55205+ atomic_set_unchecked(&srp_host->next_port_id, 0);
55206 return 0;
55207 }
55208
55209@@ -752,7 +752,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
55210 rport_fast_io_fail_timedout);
55211 INIT_DELAYED_WORK(&rport->dev_loss_work, rport_dev_loss_timedout);
55212
55213- id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
55214+ id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
55215 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
55216
55217 transport_setup_device(&rport->dev);
55218diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
55219index a20da8c..7f47bac 100644
55220--- a/drivers/scsi/sd.c
55221+++ b/drivers/scsi/sd.c
55222@@ -111,7 +111,7 @@ static int sd_resume(struct device *);
55223 static void sd_rescan(struct device *);
55224 static int sd_init_command(struct scsi_cmnd *SCpnt);
55225 static void sd_uninit_command(struct scsi_cmnd *SCpnt);
55226-static int sd_done(struct scsi_cmnd *);
55227+static unsigned int sd_done(struct scsi_cmnd *);
55228 static int sd_eh_action(struct scsi_cmnd *, int);
55229 static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
55230 static void scsi_disk_release(struct device *cdev);
55231@@ -1646,7 +1646,7 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
55232 *
55233 * Note: potentially run from within an ISR. Must not block.
55234 **/
55235-static int sd_done(struct scsi_cmnd *SCpnt)
55236+static unsigned int sd_done(struct scsi_cmnd *SCpnt)
55237 {
55238 int result = SCpnt->result;
55239 unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt);
55240@@ -2973,7 +2973,7 @@ static int sd_probe(struct device *dev)
55241 sdkp->disk = gd;
55242 sdkp->index = index;
55243 atomic_set(&sdkp->openers, 0);
55244- atomic_set(&sdkp->device->ioerr_cnt, 0);
55245+ atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
55246
55247 if (!sdp->request_queue->rq_timeout) {
55248 if (sdp->type != TYPE_MOD)
55249diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
55250index 9d7b7db..33ecc51 100644
55251--- a/drivers/scsi/sg.c
55252+++ b/drivers/scsi/sg.c
55253@@ -1083,7 +1083,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
55254 sdp->disk->disk_name,
55255 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
55256 NULL,
55257- (char *)arg);
55258+ (char __user *)arg);
55259 case BLKTRACESTART:
55260 return blk_trace_startstop(sdp->device->request_queue, 1);
55261 case BLKTRACESTOP:
55262diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
55263index 8bd54a6..58fa0d6 100644
55264--- a/drivers/scsi/sr.c
55265+++ b/drivers/scsi/sr.c
55266@@ -80,7 +80,7 @@ static DEFINE_MUTEX(sr_mutex);
55267 static int sr_probe(struct device *);
55268 static int sr_remove(struct device *);
55269 static int sr_init_command(struct scsi_cmnd *SCpnt);
55270-static int sr_done(struct scsi_cmnd *);
55271+static unsigned int sr_done(struct scsi_cmnd *);
55272 static int sr_runtime_suspend(struct device *dev);
55273
55274 static struct dev_pm_ops sr_pm_ops = {
55275@@ -312,13 +312,13 @@ do_tur:
55276 * It will be notified on the end of a SCSI read / write, and will take one
55277 * of several actions based on success or failure.
55278 */
55279-static int sr_done(struct scsi_cmnd *SCpnt)
55280+static unsigned int sr_done(struct scsi_cmnd *SCpnt)
55281 {
55282 int result = SCpnt->result;
55283- int this_count = scsi_bufflen(SCpnt);
55284- int good_bytes = (result == 0 ? this_count : 0);
55285- int block_sectors = 0;
55286- long error_sector;
55287+ unsigned int this_count = scsi_bufflen(SCpnt);
55288+ unsigned int good_bytes = (result == 0 ? this_count : 0);
55289+ unsigned int block_sectors = 0;
55290+ sector_t error_sector;
55291 struct scsi_cd *cd = scsi_cd(SCpnt->request->rq_disk);
55292
55293 #ifdef DEBUG
55294@@ -351,9 +351,12 @@ static int sr_done(struct scsi_cmnd *SCpnt)
55295 if (cd->device->sector_size == 2048)
55296 error_sector <<= 2;
55297 error_sector &= ~(block_sectors - 1);
55298- good_bytes = (error_sector -
55299- blk_rq_pos(SCpnt->request)) << 9;
55300- if (good_bytes < 0 || good_bytes >= this_count)
55301+ if (error_sector >= blk_rq_pos(SCpnt->request)) {
55302+ good_bytes = (error_sector -
55303+ blk_rq_pos(SCpnt->request)) << 9;
55304+ if (good_bytes >= this_count)
55305+ good_bytes = 0;
55306+ } else
55307 good_bytes = 0;
55308 /*
55309 * The SCSI specification allows for the value
55310diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
55311index c0d660f..24a5854 100644
55312--- a/drivers/soc/tegra/fuse/fuse-tegra.c
55313+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
55314@@ -71,7 +71,7 @@ static ssize_t fuse_read(struct file *fd, struct kobject *kobj,
55315 return i;
55316 }
55317
55318-static struct bin_attribute fuse_bin_attr = {
55319+static bin_attribute_no_const fuse_bin_attr = {
55320 .attr = { .name = "fuse", .mode = S_IRUGO, },
55321 .read = fuse_read,
55322 };
55323diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
55324index 9ce2f15..1ff9b36 100644
55325--- a/drivers/spi/spi.c
55326+++ b/drivers/spi/spi.c
55327@@ -2215,7 +2215,7 @@ int spi_bus_unlock(struct spi_master *master)
55328 EXPORT_SYMBOL_GPL(spi_bus_unlock);
55329
55330 /* portable code must never pass more than 32 bytes */
55331-#define SPI_BUFSIZ max(32, SMP_CACHE_BYTES)
55332+#define SPI_BUFSIZ max(32UL, SMP_CACHE_BYTES)
55333
55334 static u8 *buf;
55335
55336diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
55337index b41429f..2de5373 100644
55338--- a/drivers/staging/android/timed_output.c
55339+++ b/drivers/staging/android/timed_output.c
55340@@ -25,7 +25,7 @@
55341 #include "timed_output.h"
55342
55343 static struct class *timed_output_class;
55344-static atomic_t device_count;
55345+static atomic_unchecked_t device_count;
55346
55347 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
55348 char *buf)
55349@@ -65,7 +65,7 @@ static int create_timed_output_class(void)
55350 timed_output_class = class_create(THIS_MODULE, "timed_output");
55351 if (IS_ERR(timed_output_class))
55352 return PTR_ERR(timed_output_class);
55353- atomic_set(&device_count, 0);
55354+ atomic_set_unchecked(&device_count, 0);
55355 timed_output_class->dev_groups = timed_output_groups;
55356 }
55357
55358@@ -83,7 +83,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
55359 if (ret < 0)
55360 return ret;
55361
55362- tdev->index = atomic_inc_return(&device_count);
55363+ tdev->index = atomic_inc_return_unchecked(&device_count);
55364 tdev->dev = device_create(timed_output_class, NULL,
55365 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
55366 if (IS_ERR(tdev->dev))
55367diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
55368index 985d94b..49c59fb 100644
55369--- a/drivers/staging/comedi/comedi_fops.c
55370+++ b/drivers/staging/comedi/comedi_fops.c
55371@@ -314,8 +314,8 @@ static void comedi_file_reset(struct file *file)
55372 }
55373 cfp->last_attached = dev->attached;
55374 cfp->last_detach_count = dev->detach_count;
55375- ACCESS_ONCE(cfp->read_subdev) = read_s;
55376- ACCESS_ONCE(cfp->write_subdev) = write_s;
55377+ ACCESS_ONCE_RW(cfp->read_subdev) = read_s;
55378+ ACCESS_ONCE_RW(cfp->write_subdev) = write_s;
55379 }
55380
55381 static void comedi_file_check(struct file *file)
55382@@ -1983,7 +1983,7 @@ static int do_setrsubd_ioctl(struct comedi_device *dev, unsigned long arg,
55383 !(s_old->async->cmd.flags & CMDF_WRITE))
55384 return -EBUSY;
55385
55386- ACCESS_ONCE(cfp->read_subdev) = s_new;
55387+ ACCESS_ONCE_RW(cfp->read_subdev) = s_new;
55388 return 0;
55389 }
55390
55391@@ -2025,7 +2025,7 @@ static int do_setwsubd_ioctl(struct comedi_device *dev, unsigned long arg,
55392 (s_old->async->cmd.flags & CMDF_WRITE))
55393 return -EBUSY;
55394
55395- ACCESS_ONCE(cfp->write_subdev) = s_new;
55396+ ACCESS_ONCE_RW(cfp->write_subdev) = s_new;
55397 return 0;
55398 }
55399
55400diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
55401index b13318a..883e2a8 100644
55402--- a/drivers/staging/dgnc/dgnc_mgmt.c
55403+++ b/drivers/staging/dgnc/dgnc_mgmt.c
55404@@ -115,6 +115,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
55405
55406 spin_lock_irqsave(&dgnc_global_lock, flags);
55407
55408+ memset(&ddi, 0, sizeof(ddi));
55409 ddi.dinfo_nboards = dgnc_NumBoards;
55410 sprintf(ddi.dinfo_version, "%s", DG_PART);
55411
55412diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
55413index 9cc8141..ffd5039 100644
55414--- a/drivers/staging/fbtft/fbtft-core.c
55415+++ b/drivers/staging/fbtft/fbtft-core.c
55416@@ -681,7 +681,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
55417 {
55418 struct fb_info *info;
55419 struct fbtft_par *par;
55420- struct fb_ops *fbops = NULL;
55421+ fb_ops_no_const *fbops = NULL;
55422 struct fb_deferred_io *fbdefio = NULL;
55423 struct fbtft_platform_data *pdata = dev->platform_data;
55424 u8 *vmem = NULL;
55425diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h
55426index 7d817eb..d22e49e 100644
55427--- a/drivers/staging/fbtft/fbtft.h
55428+++ b/drivers/staging/fbtft/fbtft.h
55429@@ -106,7 +106,7 @@ struct fbtft_ops {
55430
55431 int (*set_var)(struct fbtft_par *par);
55432 int (*set_gamma)(struct fbtft_par *par, unsigned long *curves);
55433-};
55434+} __no_const;
55435
55436 /**
55437 * struct fbtft_display - Describes the display properties
55438diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
55439index 001348c..cfaac8a 100644
55440--- a/drivers/staging/gdm724x/gdm_tty.c
55441+++ b/drivers/staging/gdm724x/gdm_tty.c
55442@@ -44,7 +44,7 @@
55443 #define gdm_tty_send_control(n, r, v, d, l) (\
55444 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
55445
55446-#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
55447+#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
55448
55449 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
55450 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
55451diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
55452index b892f2c..9b4898a 100644
55453--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
55454+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
55455@@ -118,7 +118,7 @@ static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev,
55456 int scan_count = bitmap_weight(indio_dev->active_scan_mask,
55457 indio_dev->masklength);
55458
55459- rx_array = kcalloc(4, scan_count, GFP_KERNEL);
55460+ rx_array = kcalloc(scan_count, 4, GFP_KERNEL);
55461 if (!rx_array)
55462 return -ENOMEM;
55463 ret = lis3l02dq_read_all(indio_dev, rx_array);
55464diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
55465index d98e229..9c59bc2 100644
55466--- a/drivers/staging/iio/adc/ad7280a.c
55467+++ b/drivers/staging/iio/adc/ad7280a.c
55468@@ -547,8 +547,8 @@ static int ad7280_attr_init(struct ad7280_state *st)
55469 {
55470 int dev, ch, cnt;
55471
55472- st->iio_attr = kcalloc(2, sizeof(*st->iio_attr) *
55473- (st->slave_num + 1) * AD7280A_CELLS_PER_DEV,
55474+ st->iio_attr = kcalloc(sizeof(*st->iio_attr) *
55475+ (st->slave_num + 1) * AD7280A_CELLS_PER_DEV, 2,
55476 GFP_KERNEL);
55477 if (st->iio_attr == NULL)
55478 return -ENOMEM;
55479diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
55480index de11f1b..f7181cf 100644
55481--- a/drivers/staging/lustre/lnet/selftest/brw_test.c
55482+++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
55483@@ -487,13 +487,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
55484 return 0;
55485 }
55486
55487-sfw_test_client_ops_t brw_test_client;
55488-void brw_init_test_client(void)
55489-{
55490- brw_test_client.tso_init = brw_client_init;
55491- brw_test_client.tso_fini = brw_client_fini;
55492- brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
55493- brw_test_client.tso_done_rpc = brw_client_done_rpc;
55494+sfw_test_client_ops_t brw_test_client = {
55495+ .tso_init = brw_client_init,
55496+ .tso_fini = brw_client_fini,
55497+ .tso_prep_rpc = brw_client_prep_rpc,
55498+ .tso_done_rpc = brw_client_done_rpc,
55499 };
55500
55501 srpc_service_t brw_test_service;
55502diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
55503index 7c5185a..51c2ae7 100644
55504--- a/drivers/staging/lustre/lnet/selftest/framework.c
55505+++ b/drivers/staging/lustre/lnet/selftest/framework.c
55506@@ -1628,12 +1628,10 @@ static srpc_service_t sfw_services[] = {
55507
55508 extern sfw_test_client_ops_t ping_test_client;
55509 extern srpc_service_t ping_test_service;
55510-extern void ping_init_test_client(void);
55511 extern void ping_init_test_service(void);
55512
55513 extern sfw_test_client_ops_t brw_test_client;
55514 extern srpc_service_t brw_test_service;
55515-extern void brw_init_test_client(void);
55516 extern void brw_init_test_service(void);
55517
55518
55519@@ -1675,12 +1673,10 @@ sfw_startup(void)
55520 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
55521 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
55522
55523- brw_init_test_client();
55524 brw_init_test_service();
55525 rc = sfw_register_test(&brw_test_service, &brw_test_client);
55526 LASSERT(rc == 0);
55527
55528- ping_init_test_client();
55529 ping_init_test_service();
55530 rc = sfw_register_test(&ping_test_service, &ping_test_client);
55531 LASSERT(rc == 0);
55532diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
55533index 1dab998..edfe0ac 100644
55534--- a/drivers/staging/lustre/lnet/selftest/ping_test.c
55535+++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
55536@@ -211,14 +211,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
55537 return 0;
55538 }
55539
55540-sfw_test_client_ops_t ping_test_client;
55541-void ping_init_test_client(void)
55542-{
55543- ping_test_client.tso_init = ping_client_init;
55544- ping_test_client.tso_fini = ping_client_fini;
55545- ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
55546- ping_test_client.tso_done_rpc = ping_client_done_rpc;
55547-}
55548+sfw_test_client_ops_t ping_test_client = {
55549+ .tso_init = ping_client_init,
55550+ .tso_fini = ping_client_fini,
55551+ .tso_prep_rpc = ping_client_prep_rpc,
55552+ .tso_done_rpc = ping_client_done_rpc,
55553+};
55554
55555 srpc_service_t ping_test_service;
55556 void ping_init_test_service(void)
55557diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
55558index f6f4c03..cdc3556 100644
55559--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
55560+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
55561@@ -1107,7 +1107,7 @@ struct ldlm_callback_suite {
55562 ldlm_completion_callback lcs_completion;
55563 ldlm_blocking_callback lcs_blocking;
55564 ldlm_glimpse_callback lcs_glimpse;
55565-};
55566+} __no_const;
55567
55568 /* ldlm_lockd.c */
55569 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
55570diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
55571index 55452e5..43b0f2f 100644
55572--- a/drivers/staging/lustre/lustre/include/obd.h
55573+++ b/drivers/staging/lustre/lustre/include/obd.h
55574@@ -1364,7 +1364,7 @@ struct md_ops {
55575 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
55576 * wrapper function in include/linux/obd_class.h.
55577 */
55578-};
55579+} __no_const;
55580
55581 struct lsm_operations {
55582 void (*lsm_free)(struct lov_stripe_md *);
55583diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
55584index a4c252f..b21acac 100644
55585--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
55586+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
55587@@ -258,7 +258,7 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq,
55588 int added = (mode == LCK_NL);
55589 int overlaps = 0;
55590 int splitted = 0;
55591- const struct ldlm_callback_suite null_cbs = { NULL };
55592+ const struct ldlm_callback_suite null_cbs = { };
55593
55594 CDEBUG(D_DLMTRACE,
55595 "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n",
55596diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
55597index e60b2e9..ad9ceb3 100644
55598--- a/drivers/staging/lustre/lustre/libcfs/module.c
55599+++ b/drivers/staging/lustre/lustre/libcfs/module.c
55600@@ -377,11 +377,11 @@ out:
55601
55602
55603 struct cfs_psdev_ops libcfs_psdev_ops = {
55604- libcfs_psdev_open,
55605- libcfs_psdev_release,
55606- NULL,
55607- NULL,
55608- libcfs_ioctl
55609+ .p_open = libcfs_psdev_open,
55610+ .p_close = libcfs_psdev_release,
55611+ .p_read = NULL,
55612+ .p_write = NULL,
55613+ .p_ioctl = libcfs_ioctl
55614 };
55615
55616 static int init_libcfs_module(void)
55617@@ -623,7 +623,7 @@ static int proc_console_max_delay_cs(struct ctl_table *table, int write,
55618 loff_t *ppos)
55619 {
55620 int rc, max_delay_cs;
55621- struct ctl_table dummy = *table;
55622+ ctl_table_no_const dummy = *table;
55623 long d;
55624
55625 dummy.data = &max_delay_cs;
55626@@ -656,7 +656,7 @@ static int proc_console_min_delay_cs(struct ctl_table *table, int write,
55627 loff_t *ppos)
55628 {
55629 int rc, min_delay_cs;
55630- struct ctl_table dummy = *table;
55631+ ctl_table_no_const dummy = *table;
55632 long d;
55633
55634 dummy.data = &min_delay_cs;
55635@@ -688,7 +688,7 @@ static int proc_console_backoff(struct ctl_table *table, int write,
55636 void __user *buffer, size_t *lenp, loff_t *ppos)
55637 {
55638 int rc, backoff;
55639- struct ctl_table dummy = *table;
55640+ ctl_table_no_const dummy = *table;
55641
55642 dummy.data = &backoff;
55643 dummy.proc_handler = &proc_dointvec;
55644diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
55645index 22853d3..cfa3c49 100644
55646--- a/drivers/staging/octeon/ethernet-rx.c
55647+++ b/drivers/staging/octeon/ethernet-rx.c
55648@@ -335,14 +335,14 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
55649 /* Increment RX stats for virtual ports */
55650 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
55651 #ifdef CONFIG_64BIT
55652- atomic64_add(1,
55653+ atomic64_add_unchecked(1,
55654 (atomic64_t *)&priv->stats.rx_packets);
55655- atomic64_add(skb->len,
55656+ atomic64_add_unchecked(skb->len,
55657 (atomic64_t *)&priv->stats.rx_bytes);
55658 #else
55659- atomic_add(1,
55660+ atomic_add_unchecked(1,
55661 (atomic_t *)&priv->stats.rx_packets);
55662- atomic_add(skb->len,
55663+ atomic_add_unchecked(skb->len,
55664 (atomic_t *)&priv->stats.rx_bytes);
55665 #endif
55666 }
55667@@ -354,10 +354,10 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
55668 dev->name);
55669 */
55670 #ifdef CONFIG_64BIT
55671- atomic64_add(1,
55672+ atomic64_add_unchecked(1,
55673 (atomic64_t *)&priv->stats.rx_dropped);
55674 #else
55675- atomic_add(1,
55676+ atomic_add_unchecked(1,
55677 (atomic_t *)&priv->stats.rx_dropped);
55678 #endif
55679 dev_kfree_skb_irq(skb);
55680diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
55681index f9dba23..7bc0ef3 100644
55682--- a/drivers/staging/octeon/ethernet.c
55683+++ b/drivers/staging/octeon/ethernet.c
55684@@ -231,11 +231,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
55685 * since the RX tasklet also increments it.
55686 */
55687 #ifdef CONFIG_64BIT
55688- atomic64_add(rx_status.dropped_packets,
55689- (atomic64_t *)&priv->stats.rx_dropped);
55690+ atomic64_add_unchecked(rx_status.dropped_packets,
55691+ (atomic64_unchecked_t *)&priv->stats.rx_dropped);
55692 #else
55693- atomic_add(rx_status.dropped_packets,
55694- (atomic_t *)&priv->stats.rx_dropped);
55695+ atomic_add_unchecked(rx_status.dropped_packets,
55696+ (atomic_unchecked_t *)&priv->stats.rx_dropped);
55697 #endif
55698 }
55699
55700diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
55701index 3b476d8..f522d68 100644
55702--- a/drivers/staging/rtl8188eu/include/hal_intf.h
55703+++ b/drivers/staging/rtl8188eu/include/hal_intf.h
55704@@ -225,7 +225,7 @@ struct hal_ops {
55705
55706 void (*hal_notch_filter)(struct adapter *adapter, bool enable);
55707 void (*hal_reset_security_engine)(struct adapter *adapter);
55708-};
55709+} __no_const;
55710
55711 enum rt_eeprom_type {
55712 EEPROM_93C46,
55713diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
55714index 070cc03..6806e37 100644
55715--- a/drivers/staging/rtl8712/rtl871x_io.h
55716+++ b/drivers/staging/rtl8712/rtl871x_io.h
55717@@ -108,7 +108,7 @@ struct _io_ops {
55718 u8 *pmem);
55719 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
55720 u8 *pmem);
55721-};
55722+} __no_const;
55723
55724 struct io_req {
55725 struct list_head list;
55726diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
55727index 8e201f1..bf2a28d 100644
55728--- a/drivers/staging/sm750fb/sm750.c
55729+++ b/drivers/staging/sm750fb/sm750.c
55730@@ -775,6 +775,7 @@ static struct fb_ops lynxfb_ops = {
55731 .fb_set_par = lynxfb_ops_set_par,
55732 .fb_setcolreg = lynxfb_ops_setcolreg,
55733 .fb_blank = lynxfb_ops_blank,
55734+ .fb_pan_display = lynxfb_ops_pan_display,
55735 .fb_fillrect = cfb_fillrect,
55736 .fb_imageblit = cfb_imageblit,
55737 .fb_copyarea = cfb_copyarea,
55738@@ -822,8 +823,10 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
55739 par->index = index;
55740 output->channel = &crtc->channel;
55741 sm750fb_set_drv(par);
55742- lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;
55743
55744+ pax_open_kernel();
55745+ *(void **)&lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;
55746+ pax_close_kernel();
55747
55748 /* set current cursor variable and proc pointer,
55749 * must be set after crtc member initialized */
55750@@ -845,7 +848,9 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
55751 crtc->cursor.share = share;
55752 memset_io(crtc->cursor.vstart, 0, crtc->cursor.size);
55753 if (!g_hwcursor) {
55754- lynxfb_ops.fb_cursor = NULL;
55755+ pax_open_kernel();
55756+ *(void **)&lynxfb_ops.fb_cursor = NULL;
55757+ pax_close_kernel();
55758 crtc->cursor.disable(&crtc->cursor);
55759 }
55760
55761@@ -853,9 +858,11 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
55762 /* set info->fbops, must be set before fb_find_mode */
55763 if (!share->accel_off) {
55764 /* use 2d acceleration */
55765- lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
55766- lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
55767- lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit;
55768+ pax_open_kernel();
55769+ *(void **)&lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
55770+ *(void **)&lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
55771+ *(void **)&lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit;
55772+ pax_close_kernel();
55773 }
55774 info->fbops = &lynxfb_ops;
55775
55776diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
55777index 2f12483..6e1b50a 100644
55778--- a/drivers/staging/unisys/visorbus/visorbus_private.h
55779+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
55780@@ -35,7 +35,7 @@ struct visorchipset_busdev_notifiers {
55781 void (*device_destroy)(struct visor_device *bus_info);
55782 void (*device_pause)(struct visor_device *bus_info);
55783 void (*device_resume)(struct visor_device *bus_info);
55784-};
55785+} __no_const;
55786
55787 /* These functions live inside visorchipset, and will be called to indicate
55788 * responses to specific events (by code outside of visorchipset).
55789@@ -50,7 +50,7 @@ struct visorchipset_busdev_responders {
55790 void (*device_destroy)(struct visor_device *p, int response);
55791 void (*device_pause)(struct visor_device *p, int response);
55792 void (*device_resume)(struct visor_device *p, int response);
55793-};
55794+} __no_const;
55795
55796 /** Register functions (in the bus driver) to get called by visorchipset
55797 * whenever a bus or device appears for which this guest is to be the
55798diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
55799index 0edf320..49afe95 100644
55800--- a/drivers/target/sbp/sbp_target.c
55801+++ b/drivers/target/sbp/sbp_target.c
55802@@ -60,7 +60,7 @@ static const u32 sbp_unit_directory_template[] = {
55803
55804 #define SESSION_MAINTENANCE_INTERVAL HZ
55805
55806-static atomic_t login_id = ATOMIC_INIT(0);
55807+static atomic_unchecked_t login_id = ATOMIC_INIT(0);
55808
55809 static void session_maintenance_work(struct work_struct *);
55810 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
55811@@ -441,7 +441,7 @@ static void sbp_management_request_login(
55812 login->login_lun = unpacked_lun;
55813 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
55814 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
55815- login->login_id = atomic_inc_return(&login_id);
55816+ login->login_id = atomic_inc_return_unchecked(&login_id);
55817
55818 login->tgt_agt = sbp_target_agent_register(login);
55819 if (IS_ERR(login->tgt_agt)) {
55820diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
55821index 8f1cd19..ba7a8f1 100644
55822--- a/drivers/target/target_core_device.c
55823+++ b/drivers/target/target_core_device.c
55824@@ -772,7 +772,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
55825 spin_lock_init(&dev->se_tmr_lock);
55826 spin_lock_init(&dev->qf_cmd_lock);
55827 sema_init(&dev->caw_sem, 1);
55828- atomic_set(&dev->dev_ordered_id, 0);
55829+ atomic_set_unchecked(&dev->dev_ordered_id, 0);
55830 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
55831 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
55832 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
55833diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
55834index ce8574b..98d6199 100644
55835--- a/drivers/target/target_core_transport.c
55836+++ b/drivers/target/target_core_transport.c
55837@@ -1181,7 +1181,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
55838 * Used to determine when ORDERED commands should go from
55839 * Dormant to Active status.
55840 */
55841- cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
55842+ cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
55843 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
55844 cmd->se_ordered_id, cmd->sam_task_attr,
55845 dev->transport->name);
55846diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
55847index 42c6f71..1c64309 100644
55848--- a/drivers/thermal/cpu_cooling.c
55849+++ b/drivers/thermal/cpu_cooling.c
55850@@ -838,10 +838,11 @@ __cpufreq_cooling_register(struct device_node *np,
55851 cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus);
55852
55853 if (capacitance) {
55854- cpufreq_cooling_ops.get_requested_power =
55855- cpufreq_get_requested_power;
55856- cpufreq_cooling_ops.state2power = cpufreq_state2power;
55857- cpufreq_cooling_ops.power2state = cpufreq_power2state;
55858+ pax_open_kernel();
55859+ *(void **)&cpufreq_cooling_ops.get_requested_power = cpufreq_get_requested_power;
55860+ *(void **)&cpufreq_cooling_ops.state2power = cpufreq_state2power;
55861+ *(void **)&cpufreq_cooling_ops.power2state = cpufreq_power2state;
55862+ pax_close_kernel();
55863 cpufreq_dev->plat_get_static_power = plat_static_func;
55864
55865 ret = build_dyn_power_table(cpufreq_dev, capacitance);
55866diff --git a/drivers/thermal/int340x_thermal/int3400_thermal.c b/drivers/thermal/int340x_thermal/int3400_thermal.c
55867index 031018e..90981a1 100644
55868--- a/drivers/thermal/int340x_thermal/int3400_thermal.c
55869+++ b/drivers/thermal/int340x_thermal/int3400_thermal.c
55870@@ -272,8 +272,10 @@ static int int3400_thermal_probe(struct platform_device *pdev)
55871 platform_set_drvdata(pdev, priv);
55872
55873 if (priv->uuid_bitmap & 1 << INT3400_THERMAL_PASSIVE_1) {
55874- int3400_thermal_ops.get_mode = int3400_thermal_get_mode;
55875- int3400_thermal_ops.set_mode = int3400_thermal_set_mode;
55876+ pax_open_kernel();
55877+ *(void **)&int3400_thermal_ops.get_mode = int3400_thermal_get_mode;
55878+ *(void **)&int3400_thermal_ops.set_mode = int3400_thermal_set_mode;
55879+ pax_close_kernel();
55880 }
55881 priv->thermal = thermal_zone_device_register("INT3400 Thermal", 0, 0,
55882 priv, &int3400_thermal_ops,
55883diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
55884index b295b2b..f7e2a30 100644
55885--- a/drivers/thermal/of-thermal.c
55886+++ b/drivers/thermal/of-thermal.c
55887@@ -31,6 +31,7 @@
55888 #include <linux/export.h>
55889 #include <linux/string.h>
55890 #include <linux/thermal.h>
55891+#include <linux/mm.h>
55892
55893 #include "thermal_core.h"
55894
55895@@ -417,9 +418,11 @@ thermal_zone_of_add_sensor(struct device_node *zone,
55896 tz->ops = ops;
55897 tz->sensor_data = data;
55898
55899- tzd->ops->get_temp = of_thermal_get_temp;
55900- tzd->ops->get_trend = of_thermal_get_trend;
55901- tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
55902+ pax_open_kernel();
55903+ *(void **)&tzd->ops->get_temp = of_thermal_get_temp;
55904+ *(void **)&tzd->ops->get_trend = of_thermal_get_trend;
55905+ *(void **)&tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
55906+ pax_close_kernel();
55907 mutex_unlock(&tzd->lock);
55908
55909 return tzd;
55910@@ -549,9 +552,11 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
55911 return;
55912
55913 mutex_lock(&tzd->lock);
55914- tzd->ops->get_temp = NULL;
55915- tzd->ops->get_trend = NULL;
55916- tzd->ops->set_emul_temp = NULL;
55917+ pax_open_kernel();
55918+ *(void **)&tzd->ops->get_temp = NULL;
55919+ *(void **)&tzd->ops->get_trend = NULL;
55920+ *(void **)&tzd->ops->set_emul_temp = NULL;
55921+ pax_close_kernel();
55922
55923 tz->ops = NULL;
55924 tz->sensor_data = NULL;
55925diff --git a/drivers/thermal/x86_pkg_temp_thermal.c b/drivers/thermal/x86_pkg_temp_thermal.c
55926index 50d1d2c..39c5ce0 100644
55927--- a/drivers/thermal/x86_pkg_temp_thermal.c
55928+++ b/drivers/thermal/x86_pkg_temp_thermal.c
55929@@ -567,7 +567,7 @@ static int pkg_temp_thermal_cpu_callback(struct notifier_block *nfb,
55930 return NOTIFY_OK;
55931 }
55932
55933-static struct notifier_block pkg_temp_thermal_notifier __refdata = {
55934+static struct notifier_block pkg_temp_thermal_notifier __refconst = {
55935 .notifier_call = pkg_temp_thermal_cpu_callback,
55936 };
55937
55938diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
55939index 87f6578..905c8f8 100644
55940--- a/drivers/tty/cyclades.c
55941+++ b/drivers/tty/cyclades.c
55942@@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
55943 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
55944 info->port.count);
55945 #endif
55946- info->port.count++;
55947+ atomic_inc(&info->port.count);
55948 #ifdef CY_DEBUG_COUNT
55949 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
55950- current->pid, info->port.count);
55951+ current->pid, atomic_read(&info->port.count));
55952 #endif
55953
55954 /*
55955@@ -3970,7 +3970,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
55956 for (j = 0; j < cy_card[i].nports; j++) {
55957 info = &cy_card[i].ports[j];
55958
55959- if (info->port.count) {
55960+ if (atomic_read(&info->port.count)) {
55961 /* XXX is the ldisc num worth this? */
55962 struct tty_struct *tty;
55963 struct tty_ldisc *ld;
55964diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
55965index 4e9c4cc..2199d8f 100644
55966--- a/drivers/tty/hvc/hvc_console.c
55967+++ b/drivers/tty/hvc/hvc_console.c
55968@@ -343,7 +343,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
55969
55970 spin_lock_irqsave(&hp->port.lock, flags);
55971 /* Check and then increment for fast path open. */
55972- if (hp->port.count++ > 0) {
55973+ if (atomic_inc_return(&hp->port.count) > 1) {
55974 spin_unlock_irqrestore(&hp->port.lock, flags);
55975 hvc_kick();
55976 return 0;
55977@@ -398,7 +398,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
55978
55979 spin_lock_irqsave(&hp->port.lock, flags);
55980
55981- if (--hp->port.count == 0) {
55982+ if (atomic_dec_return(&hp->port.count) == 0) {
55983 spin_unlock_irqrestore(&hp->port.lock, flags);
55984 /* We are done with the tty pointer now. */
55985 tty_port_tty_set(&hp->port, NULL);
55986@@ -420,9 +420,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
55987 */
55988 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
55989 } else {
55990- if (hp->port.count < 0)
55991+ if (atomic_read(&hp->port.count) < 0)
55992 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
55993- hp->vtermno, hp->port.count);
55994+ hp->vtermno, atomic_read(&hp->port.count));
55995 spin_unlock_irqrestore(&hp->port.lock, flags);
55996 }
55997 }
55998@@ -452,12 +452,12 @@ static void hvc_hangup(struct tty_struct *tty)
55999 * open->hangup case this can be called after the final close so prevent
56000 * that from happening for now.
56001 */
56002- if (hp->port.count <= 0) {
56003+ if (atomic_read(&hp->port.count) <= 0) {
56004 spin_unlock_irqrestore(&hp->port.lock, flags);
56005 return;
56006 }
56007
56008- hp->port.count = 0;
56009+ atomic_set(&hp->port.count, 0);
56010 spin_unlock_irqrestore(&hp->port.lock, flags);
56011 tty_port_tty_set(&hp->port, NULL);
56012
56013@@ -505,7 +505,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
56014 return -EPIPE;
56015
56016 /* FIXME what's this (unprotected) check for? */
56017- if (hp->port.count <= 0)
56018+ if (atomic_read(&hp->port.count) <= 0)
56019 return -EIO;
56020
56021 spin_lock_irqsave(&hp->lock, flags);
56022diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
56023index f7ff97c..0c0ebbf 100644
56024--- a/drivers/tty/hvc/hvcs.c
56025+++ b/drivers/tty/hvc/hvcs.c
56026@@ -83,6 +83,7 @@
56027 #include <asm/hvcserver.h>
56028 #include <asm/uaccess.h>
56029 #include <asm/vio.h>
56030+#include <asm/local.h>
56031
56032 /*
56033 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
56034@@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
56035
56036 spin_lock_irqsave(&hvcsd->lock, flags);
56037
56038- if (hvcsd->port.count > 0) {
56039+ if (atomic_read(&hvcsd->port.count) > 0) {
56040 spin_unlock_irqrestore(&hvcsd->lock, flags);
56041 printk(KERN_INFO "HVCS: vterm state unchanged. "
56042 "The hvcs device node is still in use.\n");
56043@@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
56044 }
56045 }
56046
56047- hvcsd->port.count = 0;
56048+ atomic_set(&hvcsd->port.count, 0);
56049 hvcsd->port.tty = tty;
56050 tty->driver_data = hvcsd;
56051
56052@@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
56053 unsigned long flags;
56054
56055 spin_lock_irqsave(&hvcsd->lock, flags);
56056- hvcsd->port.count++;
56057+ atomic_inc(&hvcsd->port.count);
56058 hvcsd->todo_mask |= HVCS_SCHED_READ;
56059 spin_unlock_irqrestore(&hvcsd->lock, flags);
56060
56061@@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
56062 hvcsd = tty->driver_data;
56063
56064 spin_lock_irqsave(&hvcsd->lock, flags);
56065- if (--hvcsd->port.count == 0) {
56066+ if (atomic_dec_and_test(&hvcsd->port.count)) {
56067
56068 vio_disable_interrupts(hvcsd->vdev);
56069
56070@@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
56071
56072 free_irq(irq, hvcsd);
56073 return;
56074- } else if (hvcsd->port.count < 0) {
56075+ } else if (atomic_read(&hvcsd->port.count) < 0) {
56076 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
56077 " is missmanaged.\n",
56078- hvcsd->vdev->unit_address, hvcsd->port.count);
56079+ hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
56080 }
56081
56082 spin_unlock_irqrestore(&hvcsd->lock, flags);
56083@@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
56084
56085 spin_lock_irqsave(&hvcsd->lock, flags);
56086 /* Preserve this so that we know how many kref refs to put */
56087- temp_open_count = hvcsd->port.count;
56088+ temp_open_count = atomic_read(&hvcsd->port.count);
56089
56090 /*
56091 * Don't kref put inside the spinlock because the destruction
56092@@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
56093 tty->driver_data = NULL;
56094 hvcsd->port.tty = NULL;
56095
56096- hvcsd->port.count = 0;
56097+ atomic_set(&hvcsd->port.count, 0);
56098
56099 /* This will drop any buffered data on the floor which is OK in a hangup
56100 * scenario. */
56101@@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
56102 * the middle of a write operation? This is a crummy place to do this
56103 * but we want to keep it all in the spinlock.
56104 */
56105- if (hvcsd->port.count <= 0) {
56106+ if (atomic_read(&hvcsd->port.count) <= 0) {
56107 spin_unlock_irqrestore(&hvcsd->lock, flags);
56108 return -ENODEV;
56109 }
56110@@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
56111 {
56112 struct hvcs_struct *hvcsd = tty->driver_data;
56113
56114- if (!hvcsd || hvcsd->port.count <= 0)
56115+ if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
56116 return 0;
56117
56118 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
56119diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
56120index 4190199..06d5bfa 100644
56121--- a/drivers/tty/hvc/hvsi.c
56122+++ b/drivers/tty/hvc/hvsi.c
56123@@ -85,7 +85,7 @@ struct hvsi_struct {
56124 int n_outbuf;
56125 uint32_t vtermno;
56126 uint32_t virq;
56127- atomic_t seqno; /* HVSI packet sequence number */
56128+ atomic_unchecked_t seqno; /* HVSI packet sequence number */
56129 uint16_t mctrl;
56130 uint8_t state; /* HVSI protocol state */
56131 uint8_t flags;
56132@@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
56133
56134 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
56135 packet.hdr.len = sizeof(struct hvsi_query_response);
56136- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
56137+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
56138 packet.verb = VSV_SEND_VERSION_NUMBER;
56139 packet.u.version = HVSI_VERSION;
56140 packet.query_seqno = query_seqno+1;
56141@@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
56142
56143 packet.hdr.type = VS_QUERY_PACKET_HEADER;
56144 packet.hdr.len = sizeof(struct hvsi_query);
56145- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
56146+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
56147 packet.verb = verb;
56148
56149 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
56150@@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
56151 int wrote;
56152
56153 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
56154- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
56155+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
56156 packet.hdr.len = sizeof(struct hvsi_control);
56157 packet.verb = VSV_SET_MODEM_CTL;
56158 packet.mask = HVSI_TSDTR;
56159@@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
56160 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
56161
56162 packet.hdr.type = VS_DATA_PACKET_HEADER;
56163- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
56164+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
56165 packet.hdr.len = count + sizeof(struct hvsi_header);
56166 memcpy(&packet.data, buf, count);
56167
56168@@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
56169 struct hvsi_control packet __ALIGNED__;
56170
56171 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
56172- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
56173+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
56174 packet.hdr.len = 6;
56175 packet.verb = VSV_CLOSE_PROTOCOL;
56176
56177@@ -725,7 +725,7 @@ static int hvsi_open(struct tty_struct *tty, struct file *filp)
56178
56179 tty_port_tty_set(&hp->port, tty);
56180 spin_lock_irqsave(&hp->lock, flags);
56181- hp->port.count++;
56182+ atomic_inc(&hp->port.count);
56183 atomic_set(&hp->seqno, 0);
56184 h_vio_signal(hp->vtermno, VIO_IRQ_ENABLE);
56185 spin_unlock_irqrestore(&hp->lock, flags);
56186@@ -782,7 +782,7 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp)
56187
56188 spin_lock_irqsave(&hp->lock, flags);
56189
56190- if (--hp->port.count == 0) {
56191+ if (atomic_dec_return(&hp->port.count) == 0) {
56192 tty_port_tty_set(&hp->port, NULL);
56193 hp->inbuf_end = hp->inbuf; /* discard remaining partial packets */
56194
56195@@ -815,9 +815,9 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp)
56196
56197 spin_lock_irqsave(&hp->lock, flags);
56198 }
56199- } else if (hp->port.count < 0)
56200+ } else if (atomic_read(&hp->port.count) < 0)
56201 printk(KERN_ERR "hvsi_close %lu: oops, count is %d\n",
56202- hp - hvsi_ports, hp->port.count);
56203+ hp - hvsi_ports, atomic_read(&hp->port.count));
56204
56205 spin_unlock_irqrestore(&hp->lock, flags);
56206 }
56207@@ -832,7 +832,7 @@ static void hvsi_hangup(struct tty_struct *tty)
56208 tty_port_tty_set(&hp->port, NULL);
56209
56210 spin_lock_irqsave(&hp->lock, flags);
56211- hp->port.count = 0;
56212+ atomic_set(&hp->port.count, 0);
56213 hp->n_outbuf = 0;
56214 spin_unlock_irqrestore(&hp->lock, flags);
56215 }
56216diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
56217index a270f04..7c77b5d 100644
56218--- a/drivers/tty/hvc/hvsi_lib.c
56219+++ b/drivers/tty/hvc/hvsi_lib.c
56220@@ -8,7 +8,7 @@
56221
56222 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
56223 {
56224- packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno));
56225+ packet->seqno = cpu_to_be16(atomic_inc_return_unchecked(&pv->seqno));
56226
56227 /* Assumes that always succeeds, works in practice */
56228 return pv->put_chars(pv->termno, (char *)packet, packet->len);
56229@@ -20,7 +20,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
56230
56231 /* Reset state */
56232 pv->established = 0;
56233- atomic_set(&pv->seqno, 0);
56234+ atomic_set_unchecked(&pv->seqno, 0);
56235
56236 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
56237
56238diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
56239index 345cebb..d5a1e9e 100644
56240--- a/drivers/tty/ipwireless/tty.c
56241+++ b/drivers/tty/ipwireless/tty.c
56242@@ -28,6 +28,7 @@
56243 #include <linux/tty_driver.h>
56244 #include <linux/tty_flip.h>
56245 #include <linux/uaccess.h>
56246+#include <asm/local.h>
56247
56248 #include "tty.h"
56249 #include "network.h"
56250@@ -93,10 +94,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
56251 return -ENODEV;
56252
56253 mutex_lock(&tty->ipw_tty_mutex);
56254- if (tty->port.count == 0)
56255+ if (atomic_read(&tty->port.count) == 0)
56256 tty->tx_bytes_queued = 0;
56257
56258- tty->port.count++;
56259+ atomic_inc(&tty->port.count);
56260
56261 tty->port.tty = linux_tty;
56262 linux_tty->driver_data = tty;
56263@@ -112,9 +113,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
56264
56265 static void do_ipw_close(struct ipw_tty *tty)
56266 {
56267- tty->port.count--;
56268-
56269- if (tty->port.count == 0) {
56270+ if (atomic_dec_return(&tty->port.count) == 0) {
56271 struct tty_struct *linux_tty = tty->port.tty;
56272
56273 if (linux_tty != NULL) {
56274@@ -135,7 +134,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
56275 return;
56276
56277 mutex_lock(&tty->ipw_tty_mutex);
56278- if (tty->port.count == 0) {
56279+ if (atomic_read(&tty->port.count) == 0) {
56280 mutex_unlock(&tty->ipw_tty_mutex);
56281 return;
56282 }
56283@@ -158,7 +157,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
56284
56285 mutex_lock(&tty->ipw_tty_mutex);
56286
56287- if (!tty->port.count) {
56288+ if (!atomic_read(&tty->port.count)) {
56289 mutex_unlock(&tty->ipw_tty_mutex);
56290 return;
56291 }
56292@@ -197,7 +196,7 @@ static int ipw_write(struct tty_struct *linux_tty,
56293 return -ENODEV;
56294
56295 mutex_lock(&tty->ipw_tty_mutex);
56296- if (!tty->port.count) {
56297+ if (!atomic_read(&tty->port.count)) {
56298 mutex_unlock(&tty->ipw_tty_mutex);
56299 return -EINVAL;
56300 }
56301@@ -237,7 +236,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
56302 if (!tty)
56303 return -ENODEV;
56304
56305- if (!tty->port.count)
56306+ if (!atomic_read(&tty->port.count))
56307 return -EINVAL;
56308
56309 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
56310@@ -279,7 +278,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
56311 if (!tty)
56312 return 0;
56313
56314- if (!tty->port.count)
56315+ if (!atomic_read(&tty->port.count))
56316 return 0;
56317
56318 return tty->tx_bytes_queued;
56319@@ -360,7 +359,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
56320 if (!tty)
56321 return -ENODEV;
56322
56323- if (!tty->port.count)
56324+ if (!atomic_read(&tty->port.count))
56325 return -EINVAL;
56326
56327 return get_control_lines(tty);
56328@@ -376,7 +375,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
56329 if (!tty)
56330 return -ENODEV;
56331
56332- if (!tty->port.count)
56333+ if (!atomic_read(&tty->port.count))
56334 return -EINVAL;
56335
56336 return set_control_lines(tty, set, clear);
56337@@ -390,7 +389,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
56338 if (!tty)
56339 return -ENODEV;
56340
56341- if (!tty->port.count)
56342+ if (!atomic_read(&tty->port.count))
56343 return -EINVAL;
56344
56345 /* FIXME: Exactly how is the tty object locked here .. */
56346@@ -546,7 +545,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
56347 * are gone */
56348 mutex_lock(&ttyj->ipw_tty_mutex);
56349 }
56350- while (ttyj->port.count)
56351+ while (atomic_read(&ttyj->port.count))
56352 do_ipw_close(ttyj);
56353 ipwireless_disassociate_network_ttys(network,
56354 ttyj->channel_idx);
56355diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
56356index 14c54e0..1efd4f2 100644
56357--- a/drivers/tty/moxa.c
56358+++ b/drivers/tty/moxa.c
56359@@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
56360 }
56361
56362 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
56363- ch->port.count++;
56364+ atomic_inc(&ch->port.count);
56365 tty->driver_data = ch;
56366 tty_port_tty_set(&ch->port, tty);
56367 mutex_lock(&ch->port.mutex);
56368diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
56369index 382d3fc..b16d625 100644
56370--- a/drivers/tty/n_gsm.c
56371+++ b/drivers/tty/n_gsm.c
56372@@ -1644,7 +1644,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
56373 spin_lock_init(&dlci->lock);
56374 mutex_init(&dlci->mutex);
56375 dlci->fifo = &dlci->_fifo;
56376- if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
56377+ if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
56378 kfree(dlci);
56379 return NULL;
56380 }
56381@@ -2957,7 +2957,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
56382 struct gsm_dlci *dlci = tty->driver_data;
56383 struct tty_port *port = &dlci->port;
56384
56385- port->count++;
56386+ atomic_inc(&port->count);
56387 tty_port_tty_set(port, tty);
56388
56389 dlci->modem_rx = 0;
56390diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
56391index afc1879..b605d4b 100644
56392--- a/drivers/tty/n_tty.c
56393+++ b/drivers/tty/n_tty.c
56394@@ -2574,6 +2574,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
56395 {
56396 *ops = tty_ldisc_N_TTY;
56397 ops->owner = NULL;
56398- ops->refcount = ops->flags = 0;
56399+ atomic_set(&ops->refcount, 0);
56400+ ops->flags = 0;
56401 }
56402 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
56403diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
56404index 4d5e840..a2340a6 100644
56405--- a/drivers/tty/pty.c
56406+++ b/drivers/tty/pty.c
56407@@ -849,8 +849,10 @@ static void __init unix98_pty_init(void)
56408 panic("Couldn't register Unix98 pts driver");
56409
56410 /* Now create the /dev/ptmx special device */
56411+ pax_open_kernel();
56412 tty_default_fops(&ptmx_fops);
56413- ptmx_fops.open = ptmx_open;
56414+ *(void **)&ptmx_fops.open = ptmx_open;
56415+ pax_close_kernel();
56416
56417 cdev_init(&ptmx_cdev, &ptmx_fops);
56418 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
56419diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
56420index c8dd8dc..dca6cfd 100644
56421--- a/drivers/tty/rocket.c
56422+++ b/drivers/tty/rocket.c
56423@@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
56424 tty->driver_data = info;
56425 tty_port_tty_set(port, tty);
56426
56427- if (port->count++ == 0) {
56428+ if (atomic_inc_return(&port->count) == 1) {
56429 atomic_inc(&rp_num_ports_open);
56430
56431 #ifdef ROCKET_DEBUG_OPEN
56432@@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
56433 #endif
56434 }
56435 #ifdef ROCKET_DEBUG_OPEN
56436- printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
56437+ printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
56438 #endif
56439
56440 /*
56441@@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
56442 spin_unlock_irqrestore(&info->port.lock, flags);
56443 return;
56444 }
56445- if (info->port.count)
56446+ if (atomic_read(&info->port.count))
56447 atomic_dec(&rp_num_ports_open);
56448 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
56449 spin_unlock_irqrestore(&info->port.lock, flags);
56450diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
56451index c35d96e..f05d689 100644
56452--- a/drivers/tty/serial/8250/8250_core.c
56453+++ b/drivers/tty/serial/8250/8250_core.c
56454@@ -3237,9 +3237,9 @@ static void univ8250_release_port(struct uart_port *port)
56455
56456 static void univ8250_rsa_support(struct uart_ops *ops)
56457 {
56458- ops->config_port = univ8250_config_port;
56459- ops->request_port = univ8250_request_port;
56460- ops->release_port = univ8250_release_port;
56461+ *(void **)&ops->config_port = univ8250_config_port;
56462+ *(void **)&ops->request_port = univ8250_request_port;
56463+ *(void **)&ops->release_port = univ8250_release_port;
56464 }
56465
56466 #else
56467@@ -3282,8 +3282,10 @@ static void __init serial8250_isa_init_ports(void)
56468 }
56469
56470 /* chain base port ops to support Remote Supervisor Adapter */
56471- univ8250_port_ops = *base_ops;
56472+ pax_open_kernel();
56473+ memcpy((void *)&univ8250_port_ops, base_ops, sizeof univ8250_port_ops);
56474 univ8250_rsa_support(&univ8250_port_ops);
56475+ pax_close_kernel();
56476
56477 if (share_irqs)
56478 irqflag = IRQF_SHARED;
56479diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
56480index 536a33b..1b98f43 100644
56481--- a/drivers/tty/serial/ifx6x60.c
56482+++ b/drivers/tty/serial/ifx6x60.c
56483@@ -649,7 +649,7 @@ static void ifx_spi_complete(void *ctx)
56484 struct ifx_spi_device *ifx_dev = ctx;
56485 int length;
56486 int actual_length;
56487- unsigned char more;
56488+ unsigned char more = 0;
56489 unsigned char cts;
56490 int local_write_pending = 0;
56491 int queue_length;
56492diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
56493index e5c42fe..f091b02 100644
56494--- a/drivers/tty/serial/ioc4_serial.c
56495+++ b/drivers/tty/serial/ioc4_serial.c
56496@@ -437,7 +437,7 @@ struct ioc4_soft {
56497 } is_intr_info[MAX_IOC4_INTR_ENTS];
56498
56499 /* Number of entries active in the above array */
56500- atomic_t is_num_intrs;
56501+ atomic_unchecked_t is_num_intrs;
56502 } is_intr_type[IOC4_NUM_INTR_TYPES];
56503
56504 /* is_ir_lock must be held while
56505@@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
56506 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
56507 || (type == IOC4_OTHER_INTR_TYPE)));
56508
56509- i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
56510+ i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
56511 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
56512
56513 /* Save off the lower level interrupt handler */
56514@@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
56515
56516 soft = arg;
56517 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
56518- num_intrs = (int)atomic_read(
56519+ num_intrs = (int)atomic_read_unchecked(
56520 &soft->is_intr_type[intr_type].is_num_intrs);
56521
56522 this_mir = this_ir = pending_intrs(soft, intr_type);
56523diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
56524index 117df15..2f7dfcf 100644
56525--- a/drivers/tty/serial/kgdb_nmi.c
56526+++ b/drivers/tty/serial/kgdb_nmi.c
56527@@ -53,7 +53,9 @@ static int kgdb_nmi_console_setup(struct console *co, char *options)
56528 * I/O utilities that messages sent to the console will automatically
56529 * be displayed on the dbg_io.
56530 */
56531- dbg_io_ops->is_console = true;
56532+ pax_open_kernel();
56533+ *(int *)&dbg_io_ops->is_console = true;
56534+ pax_close_kernel();
56535
56536 return 0;
56537 }
56538diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
56539index a260cde..6b2b5ce 100644
56540--- a/drivers/tty/serial/kgdboc.c
56541+++ b/drivers/tty/serial/kgdboc.c
56542@@ -24,8 +24,9 @@
56543 #define MAX_CONFIG_LEN 40
56544
56545 static struct kgdb_io kgdboc_io_ops;
56546+static struct kgdb_io kgdboc_io_ops_console;
56547
56548-/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
56549+/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
56550 static int configured = -1;
56551
56552 static char config[MAX_CONFIG_LEN];
56553@@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
56554 kgdboc_unregister_kbd();
56555 if (configured == 1)
56556 kgdb_unregister_io_module(&kgdboc_io_ops);
56557+ else if (configured == 2)
56558+ kgdb_unregister_io_module(&kgdboc_io_ops_console);
56559 }
56560
56561 static int configure_kgdboc(void)
56562@@ -160,13 +163,13 @@ static int configure_kgdboc(void)
56563 int err;
56564 char *cptr = config;
56565 struct console *cons;
56566+ int is_console = 0;
56567
56568 err = kgdboc_option_setup(config);
56569 if (err || !strlen(config) || isspace(config[0]))
56570 goto noconfig;
56571
56572 err = -ENODEV;
56573- kgdboc_io_ops.is_console = 0;
56574 kgdb_tty_driver = NULL;
56575
56576 kgdboc_use_kms = 0;
56577@@ -187,7 +190,7 @@ static int configure_kgdboc(void)
56578 int idx;
56579 if (cons->device && cons->device(cons, &idx) == p &&
56580 idx == tty_line) {
56581- kgdboc_io_ops.is_console = 1;
56582+ is_console = 1;
56583 break;
56584 }
56585 cons = cons->next;
56586@@ -197,7 +200,13 @@ static int configure_kgdboc(void)
56587 kgdb_tty_line = tty_line;
56588
56589 do_register:
56590- err = kgdb_register_io_module(&kgdboc_io_ops);
56591+ if (is_console) {
56592+ err = kgdb_register_io_module(&kgdboc_io_ops_console);
56593+ configured = 2;
56594+ } else {
56595+ err = kgdb_register_io_module(&kgdboc_io_ops);
56596+ configured = 1;
56597+ }
56598 if (err)
56599 goto noconfig;
56600
56601@@ -205,8 +214,6 @@ do_register:
56602 if (err)
56603 goto nmi_con_failed;
56604
56605- configured = 1;
56606-
56607 return 0;
56608
56609 nmi_con_failed:
56610@@ -223,7 +230,7 @@ noconfig:
56611 static int __init init_kgdboc(void)
56612 {
56613 /* Already configured? */
56614- if (configured == 1)
56615+ if (configured >= 1)
56616 return 0;
56617
56618 return configure_kgdboc();
56619@@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
56620 if (config[len - 1] == '\n')
56621 config[len - 1] = '\0';
56622
56623- if (configured == 1)
56624+ if (configured >= 1)
56625 cleanup_kgdboc();
56626
56627 /* Go and configure with the new params. */
56628@@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
56629 .post_exception = kgdboc_post_exp_handler,
56630 };
56631
56632+static struct kgdb_io kgdboc_io_ops_console = {
56633+ .name = "kgdboc",
56634+ .read_char = kgdboc_get_char,
56635+ .write_char = kgdboc_put_char,
56636+ .pre_exception = kgdboc_pre_exp_handler,
56637+ .post_exception = kgdboc_post_exp_handler,
56638+ .is_console = 1
56639+};
56640+
56641 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
56642 /* This is only available if kgdboc is a built in for early debugging */
56643 static int __init kgdboc_early_init(char *opt)
56644diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
56645index b73889c..9f74f0a 100644
56646--- a/drivers/tty/serial/msm_serial.c
56647+++ b/drivers/tty/serial/msm_serial.c
56648@@ -1012,7 +1012,7 @@ static struct uart_driver msm_uart_driver = {
56649 .cons = MSM_CONSOLE,
56650 };
56651
56652-static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
56653+static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
56654
56655 static const struct of_device_id msm_uartdm_table[] = {
56656 { .compatible = "qcom,msm-uartdm-v1.1", .data = (void *)UARTDM_1P1 },
56657@@ -1036,7 +1036,7 @@ static int msm_serial_probe(struct platform_device *pdev)
56658 line = pdev->id;
56659
56660 if (line < 0)
56661- line = atomic_inc_return(&msm_uart_next_id) - 1;
56662+ line = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
56663
56664 if (unlikely(line < 0 || line >= UART_NR))
56665 return -ENXIO;
56666diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
56667index 5916311..1e32415 100644
56668--- a/drivers/tty/serial/samsung.c
56669+++ b/drivers/tty/serial/samsung.c
56670@@ -995,11 +995,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
56671 ourport->tx_in_progress = 0;
56672 }
56673
56674+static int s3c64xx_serial_startup(struct uart_port *port);
56675 static int s3c24xx_serial_startup(struct uart_port *port)
56676 {
56677 struct s3c24xx_uart_port *ourport = to_ourport(port);
56678 int ret;
56679
56680+ /* Startup sequence is different for s3c64xx and higher SoC's */
56681+ if (s3c24xx_serial_has_interrupt_mask(port))
56682+ return s3c64xx_serial_startup(port);
56683+
56684 dbg("s3c24xx_serial_startup: port=%p (%08llx,%p)\n",
56685 port, (unsigned long long)port->mapbase, port->membase);
56686
56687@@ -1706,10 +1711,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
56688 /* setup info for port */
56689 port->dev = &platdev->dev;
56690
56691- /* Startup sequence is different for s3c64xx and higher SoC's */
56692- if (s3c24xx_serial_has_interrupt_mask(port))
56693- s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
56694-
56695 port->uartclk = 1;
56696
56697 if (cfg->uart_flags & UPF_CONS_FLOW) {
56698diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
56699index f368520..c7a703a 100644
56700--- a/drivers/tty/serial/serial_core.c
56701+++ b/drivers/tty/serial/serial_core.c
56702@@ -1385,7 +1385,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
56703 state = drv->state + tty->index;
56704 port = &state->port;
56705 spin_lock_irq(&port->lock);
56706- --port->count;
56707+ atomic_dec(&port->count);
56708 spin_unlock_irq(&port->lock);
56709 return;
56710 }
56711@@ -1395,7 +1395,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
56712
56713 pr_debug("uart_close(%d) called\n", uport ? uport->line : -1);
56714
56715- if (!port->count || tty_port_close_start(port, tty, filp) == 0)
56716+ if (!atomic_read(&port->count) || tty_port_close_start(port, tty, filp) == 0)
56717 return;
56718
56719 /*
56720@@ -1520,7 +1520,7 @@ static void uart_hangup(struct tty_struct *tty)
56721 uart_flush_buffer(tty);
56722 uart_shutdown(tty, state);
56723 spin_lock_irqsave(&port->lock, flags);
56724- port->count = 0;
56725+ atomic_set(&port->count, 0);
56726 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
56727 spin_unlock_irqrestore(&port->lock, flags);
56728 tty_port_tty_set(port, NULL);
56729@@ -1607,7 +1607,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
56730 pr_debug("uart_open(%d) called\n", line);
56731
56732 spin_lock_irq(&port->lock);
56733- ++port->count;
56734+ atomic_inc(&port->count);
56735 spin_unlock_irq(&port->lock);
56736
56737 /*
56738diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
56739index b1c6bd3..5f038e2 100644
56740--- a/drivers/tty/serial/uartlite.c
56741+++ b/drivers/tty/serial/uartlite.c
56742@@ -341,13 +341,13 @@ static int ulite_request_port(struct uart_port *port)
56743 return -EBUSY;
56744 }
56745
56746- port->private_data = &uartlite_be;
56747+ port->private_data = (void *)&uartlite_be;
56748 ret = uart_in32(ULITE_CONTROL, port);
56749 uart_out32(ULITE_CONTROL_RST_TX, ULITE_CONTROL, port);
56750 ret = uart_in32(ULITE_STATUS, port);
56751 /* Endianess detection */
56752 if ((ret & ULITE_STATUS_TXEMPTY) != ULITE_STATUS_TXEMPTY)
56753- port->private_data = &uartlite_le;
56754+ port->private_data = (void *)&uartlite_le;
56755
56756 return 0;
56757 }
56758diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
56759index 2fac712..fcd5268 100644
56760--- a/drivers/tty/synclink.c
56761+++ b/drivers/tty/synclink.c
56762@@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
56763
56764 if (debug_level >= DEBUG_LEVEL_INFO)
56765 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
56766- __FILE__,__LINE__, info->device_name, info->port.count);
56767+ __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
56768
56769 if (tty_port_close_start(&info->port, tty, filp) == 0)
56770 goto cleanup;
56771@@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
56772 cleanup:
56773 if (debug_level >= DEBUG_LEVEL_INFO)
56774 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
56775- tty->driver->name, info->port.count);
56776+ tty->driver->name, atomic_read(&info->port.count));
56777
56778 } /* end of mgsl_close() */
56779
56780@@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
56781
56782 mgsl_flush_buffer(tty);
56783 shutdown(info);
56784-
56785- info->port.count = 0;
56786+
56787+ atomic_set(&info->port.count, 0);
56788 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
56789 info->port.tty = NULL;
56790
56791@@ -3296,10 +3296,10 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
56792
56793 if (debug_level >= DEBUG_LEVEL_INFO)
56794 printk("%s(%d):block_til_ready before block on %s count=%d\n",
56795- __FILE__,__LINE__, tty->driver->name, port->count );
56796+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56797
56798 spin_lock_irqsave(&info->irq_spinlock, flags);
56799- port->count--;
56800+ atomic_dec(&port->count);
56801 spin_unlock_irqrestore(&info->irq_spinlock, flags);
56802 port->blocked_open++;
56803
56804@@ -3327,7 +3327,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
56805
56806 if (debug_level >= DEBUG_LEVEL_INFO)
56807 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
56808- __FILE__,__LINE__, tty->driver->name, port->count );
56809+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56810
56811 tty_unlock(tty);
56812 schedule();
56813@@ -3339,12 +3339,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
56814
56815 /* FIXME: Racy on hangup during close wait */
56816 if (!tty_hung_up_p(filp))
56817- port->count++;
56818+ atomic_inc(&port->count);
56819 port->blocked_open--;
56820
56821 if (debug_level >= DEBUG_LEVEL_INFO)
56822 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
56823- __FILE__,__LINE__, tty->driver->name, port->count );
56824+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
56825
56826 if (!retval)
56827 port->flags |= ASYNC_NORMAL_ACTIVE;
56828@@ -3396,7 +3396,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
56829
56830 if (debug_level >= DEBUG_LEVEL_INFO)
56831 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
56832- __FILE__,__LINE__,tty->driver->name, info->port.count);
56833+ __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
56834
56835 /* If port is closing, signal caller to try again */
56836 if (info->port.flags & ASYNC_CLOSING){
56837@@ -3415,10 +3415,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
56838 spin_unlock_irqrestore(&info->netlock, flags);
56839 goto cleanup;
56840 }
56841- info->port.count++;
56842+ atomic_inc(&info->port.count);
56843 spin_unlock_irqrestore(&info->netlock, flags);
56844
56845- if (info->port.count == 1) {
56846+ if (atomic_read(&info->port.count) == 1) {
56847 /* 1st open on this device, init hardware */
56848 retval = startup(info);
56849 if (retval < 0)
56850@@ -3442,8 +3442,8 @@ cleanup:
56851 if (retval) {
56852 if (tty->count == 1)
56853 info->port.tty = NULL; /* tty layer will release tty struct */
56854- if(info->port.count)
56855- info->port.count--;
56856+ if (atomic_read(&info->port.count))
56857+ atomic_dec(&info->port.count);
56858 }
56859
56860 return retval;
56861@@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
56862 unsigned short new_crctype;
56863
56864 /* return error if TTY interface open */
56865- if (info->port.count)
56866+ if (atomic_read(&info->port.count))
56867 return -EBUSY;
56868
56869 switch (encoding)
56870@@ -7758,7 +7758,7 @@ static int hdlcdev_open(struct net_device *dev)
56871
56872 /* arbitrate between network and tty opens */
56873 spin_lock_irqsave(&info->netlock, flags);
56874- if (info->port.count != 0 || info->netcount != 0) {
56875+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
56876 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
56877 spin_unlock_irqrestore(&info->netlock, flags);
56878 return -EBUSY;
56879@@ -7844,7 +7844,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
56880 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
56881
56882 /* return error if TTY interface open */
56883- if (info->port.count)
56884+ if (atomic_read(&info->port.count))
56885 return -EBUSY;
56886
56887 if (cmd != SIOCWANDEV)
56888diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
56889index 0ea8eee..b3f1b8f 100644
56890--- a/drivers/tty/synclink_gt.c
56891+++ b/drivers/tty/synclink_gt.c
56892@@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
56893 tty->driver_data = info;
56894 info->port.tty = tty;
56895
56896- DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
56897+ DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
56898
56899 /* If port is closing, signal caller to try again */
56900 if (info->port.flags & ASYNC_CLOSING){
56901@@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
56902 mutex_unlock(&info->port.mutex);
56903 goto cleanup;
56904 }
56905- info->port.count++;
56906+ atomic_inc(&info->port.count);
56907 spin_unlock_irqrestore(&info->netlock, flags);
56908
56909- if (info->port.count == 1) {
56910+ if (atomic_read(&info->port.count) == 1) {
56911 /* 1st open on this device, init hardware */
56912 retval = startup(info);
56913 if (retval < 0) {
56914@@ -715,8 +715,8 @@ cleanup:
56915 if (retval) {
56916 if (tty->count == 1)
56917 info->port.tty = NULL; /* tty layer will release tty struct */
56918- if(info->port.count)
56919- info->port.count--;
56920+ if(atomic_read(&info->port.count))
56921+ atomic_dec(&info->port.count);
56922 }
56923
56924 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
56925@@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
56926
56927 if (sanity_check(info, tty->name, "close"))
56928 return;
56929- DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
56930+ DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
56931
56932 if (tty_port_close_start(&info->port, tty, filp) == 0)
56933 goto cleanup;
56934@@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
56935 tty_port_close_end(&info->port, tty);
56936 info->port.tty = NULL;
56937 cleanup:
56938- DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
56939+ DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
56940 }
56941
56942 static void hangup(struct tty_struct *tty)
56943@@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
56944 shutdown(info);
56945
56946 spin_lock_irqsave(&info->port.lock, flags);
56947- info->port.count = 0;
56948+ atomic_set(&info->port.count, 0);
56949 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
56950 info->port.tty = NULL;
56951 spin_unlock_irqrestore(&info->port.lock, flags);
56952@@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
56953 unsigned short new_crctype;
56954
56955 /* return error if TTY interface open */
56956- if (info->port.count)
56957+ if (atomic_read(&info->port.count))
56958 return -EBUSY;
56959
56960 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
56961@@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
56962
56963 /* arbitrate between network and tty opens */
56964 spin_lock_irqsave(&info->netlock, flags);
56965- if (info->port.count != 0 || info->netcount != 0) {
56966+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
56967 DBGINFO(("%s hdlc_open busy\n", dev->name));
56968 spin_unlock_irqrestore(&info->netlock, flags);
56969 return -EBUSY;
56970@@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
56971 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
56972
56973 /* return error if TTY interface open */
56974- if (info->port.count)
56975+ if (atomic_read(&info->port.count))
56976 return -EBUSY;
56977
56978 if (cmd != SIOCWANDEV)
56979@@ -2417,7 +2417,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
56980 if (port == NULL)
56981 continue;
56982 spin_lock(&port->lock);
56983- if ((port->port.count || port->netcount) &&
56984+ if ((atomic_read(&port->port.count) || port->netcount) &&
56985 port->pending_bh && !port->bh_running &&
56986 !port->bh_requested) {
56987 DBGISR(("%s bh queued\n", port->device_name));
56988@@ -3303,7 +3303,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
56989 add_wait_queue(&port->open_wait, &wait);
56990
56991 spin_lock_irqsave(&info->lock, flags);
56992- port->count--;
56993+ atomic_dec(&port->count);
56994 spin_unlock_irqrestore(&info->lock, flags);
56995 port->blocked_open++;
56996
56997@@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
56998 remove_wait_queue(&port->open_wait, &wait);
56999
57000 if (!tty_hung_up_p(filp))
57001- port->count++;
57002+ atomic_inc(&port->count);
57003 port->blocked_open--;
57004
57005 if (!retval)
57006diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
57007index 08633a8..3d56e14 100644
57008--- a/drivers/tty/synclinkmp.c
57009+++ b/drivers/tty/synclinkmp.c
57010@@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
57011
57012 if (debug_level >= DEBUG_LEVEL_INFO)
57013 printk("%s(%d):%s open(), old ref count = %d\n",
57014- __FILE__,__LINE__,tty->driver->name, info->port.count);
57015+ __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
57016
57017 /* If port is closing, signal caller to try again */
57018 if (info->port.flags & ASYNC_CLOSING){
57019@@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
57020 spin_unlock_irqrestore(&info->netlock, flags);
57021 goto cleanup;
57022 }
57023- info->port.count++;
57024+ atomic_inc(&info->port.count);
57025 spin_unlock_irqrestore(&info->netlock, flags);
57026
57027- if (info->port.count == 1) {
57028+ if (atomic_read(&info->port.count) == 1) {
57029 /* 1st open on this device, init hardware */
57030 retval = startup(info);
57031 if (retval < 0)
57032@@ -796,8 +796,8 @@ cleanup:
57033 if (retval) {
57034 if (tty->count == 1)
57035 info->port.tty = NULL; /* tty layer will release tty struct */
57036- if(info->port.count)
57037- info->port.count--;
57038+ if(atomic_read(&info->port.count))
57039+ atomic_dec(&info->port.count);
57040 }
57041
57042 return retval;
57043@@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
57044
57045 if (debug_level >= DEBUG_LEVEL_INFO)
57046 printk("%s(%d):%s close() entry, count=%d\n",
57047- __FILE__,__LINE__, info->device_name, info->port.count);
57048+ __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
57049
57050 if (tty_port_close_start(&info->port, tty, filp) == 0)
57051 goto cleanup;
57052@@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
57053 cleanup:
57054 if (debug_level >= DEBUG_LEVEL_INFO)
57055 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
57056- tty->driver->name, info->port.count);
57057+ tty->driver->name, atomic_read(&info->port.count));
57058 }
57059
57060 /* Called by tty_hangup() when a hangup is signaled.
57061@@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
57062 shutdown(info);
57063
57064 spin_lock_irqsave(&info->port.lock, flags);
57065- info->port.count = 0;
57066+ atomic_set(&info->port.count, 0);
57067 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
57068 info->port.tty = NULL;
57069 spin_unlock_irqrestore(&info->port.lock, flags);
57070@@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
57071 unsigned short new_crctype;
57072
57073 /* return error if TTY interface open */
57074- if (info->port.count)
57075+ if (atomic_read(&info->port.count))
57076 return -EBUSY;
57077
57078 switch (encoding)
57079@@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
57080
57081 /* arbitrate between network and tty opens */
57082 spin_lock_irqsave(&info->netlock, flags);
57083- if (info->port.count != 0 || info->netcount != 0) {
57084+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
57085 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
57086 spin_unlock_irqrestore(&info->netlock, flags);
57087 return -EBUSY;
57088@@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
57089 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
57090
57091 /* return error if TTY interface open */
57092- if (info->port.count)
57093+ if (atomic_read(&info->port.count))
57094 return -EBUSY;
57095
57096 if (cmd != SIOCWANDEV)
57097@@ -2624,7 +2624,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
57098 * do not request bottom half processing if the
57099 * device is not open in a normal mode.
57100 */
57101- if ( port && (port->port.count || port->netcount) &&
57102+ if ( port && (atomic_read(&port->port.count) || port->netcount) &&
57103 port->pending_bh && !port->bh_running &&
57104 !port->bh_requested ) {
57105 if ( debug_level >= DEBUG_LEVEL_ISR )
57106@@ -3321,10 +3321,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
57107
57108 if (debug_level >= DEBUG_LEVEL_INFO)
57109 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
57110- __FILE__,__LINE__, tty->driver->name, port->count );
57111+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
57112
57113 spin_lock_irqsave(&info->lock, flags);
57114- port->count--;
57115+ atomic_dec(&port->count);
57116 spin_unlock_irqrestore(&info->lock, flags);
57117 port->blocked_open++;
57118
57119@@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
57120
57121 if (debug_level >= DEBUG_LEVEL_INFO)
57122 printk("%s(%d):%s block_til_ready() count=%d\n",
57123- __FILE__,__LINE__, tty->driver->name, port->count );
57124+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
57125
57126 tty_unlock(tty);
57127 schedule();
57128@@ -3362,12 +3362,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
57129 set_current_state(TASK_RUNNING);
57130 remove_wait_queue(&port->open_wait, &wait);
57131 if (!tty_hung_up_p(filp))
57132- port->count++;
57133+ atomic_inc(&port->count);
57134 port->blocked_open--;
57135
57136 if (debug_level >= DEBUG_LEVEL_INFO)
57137 printk("%s(%d):%s block_til_ready() after, count=%d\n",
57138- __FILE__,__LINE__, tty->driver->name, port->count );
57139+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
57140
57141 if (!retval)
57142 port->flags |= ASYNC_NORMAL_ACTIVE;
57143diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
57144index b5b4278..bb9c7b0 100644
57145--- a/drivers/tty/sysrq.c
57146+++ b/drivers/tty/sysrq.c
57147@@ -1072,7 +1072,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
57148 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
57149 size_t count, loff_t *ppos)
57150 {
57151- if (count) {
57152+ if (count && capable(CAP_SYS_ADMIN)) {
57153 char c;
57154
57155 if (get_user(c, buf))
57156diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
57157index 4cf263d..fd011fa 100644
57158--- a/drivers/tty/tty_buffer.c
57159+++ b/drivers/tty/tty_buffer.c
57160@@ -242,7 +242,10 @@ void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld)
57161 atomic_inc(&buf->priority);
57162
57163 mutex_lock(&buf->lock);
57164- while ((next = buf->head->next) != NULL) {
57165+ /* paired w/ release in __tty_buffer_request_room; ensures there are
57166+ * no pending memory accesses to the freed buffer
57167+ */
57168+ while ((next = smp_load_acquire(&buf->head->next)) != NULL) {
57169 tty_buffer_free(port, buf->head);
57170 buf->head = next;
57171 }
57172@@ -290,13 +293,15 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size,
57173 if (n != NULL) {
57174 n->flags = flags;
57175 buf->tail = n;
57176- b->commit = b->used;
57177- /* paired w/ barrier in flush_to_ldisc(); ensures the
57178+ /* paired w/ acquire in flush_to_ldisc(); ensures
57179+ * flush_to_ldisc() sees buffer data.
57180+ */
57181+ smp_store_release(&b->commit, b->used);
57182+ /* paired w/ acquire in flush_to_ldisc(); ensures the
57183 * latest commit value can be read before the head is
57184 * advanced to the next buffer
57185 */
57186- smp_wmb();
57187- b->next = n;
57188+ smp_store_release(&b->next, n);
57189 } else if (change)
57190 size = 0;
57191 else
57192@@ -394,7 +399,10 @@ void tty_schedule_flip(struct tty_port *port)
57193 {
57194 struct tty_bufhead *buf = &port->buf;
57195
57196- buf->tail->commit = buf->tail->used;
57197+ /* paired w/ acquire in flush_to_ldisc(); ensures
57198+ * flush_to_ldisc() sees buffer data.
57199+ */
57200+ smp_store_release(&buf->tail->commit, buf->tail->used);
57201 schedule_work(&buf->work);
57202 }
57203 EXPORT_SYMBOL(tty_schedule_flip);
57204@@ -469,7 +477,7 @@ static void flush_to_ldisc(struct work_struct *work)
57205 struct tty_struct *tty;
57206 struct tty_ldisc *disc;
57207
57208- tty = port->itty;
57209+ tty = READ_ONCE(port->itty);
57210 if (tty == NULL)
57211 return;
57212
57213@@ -488,13 +496,15 @@ static void flush_to_ldisc(struct work_struct *work)
57214 if (atomic_read(&buf->priority))
57215 break;
57216
57217- next = head->next;
57218- /* paired w/ barrier in __tty_buffer_request_room();
57219+ /* paired w/ release in __tty_buffer_request_room();
57220 * ensures commit value read is not stale if the head
57221 * is advancing to the next buffer
57222 */
57223- smp_rmb();
57224- count = head->commit - head->read;
57225+ next = smp_load_acquire(&head->next);
57226+ /* paired w/ release in __tty_buffer_request_room() or in
57227+ * tty_buffer_flush(); ensures we see the committed buffer data
57228+ */
57229+ count = smp_load_acquire(&head->commit) - head->read;
57230 if (!count) {
57231 if (next == NULL) {
57232 check_other_closed(tty);
57233diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
57234index 774df35..62fa290 100644
57235--- a/drivers/tty/tty_io.c
57236+++ b/drivers/tty/tty_io.c
57237@@ -3524,7 +3524,7 @@ EXPORT_SYMBOL(tty_devnum);
57238
57239 void tty_default_fops(struct file_operations *fops)
57240 {
57241- *fops = tty_fops;
57242+ memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
57243 }
57244
57245 /*
57246diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
57247index c07fb5d..942acf7 100644
57248--- a/drivers/tty/tty_ldisc.c
57249+++ b/drivers/tty/tty_ldisc.c
57250@@ -70,7 +70,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
57251 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
57252 tty_ldiscs[disc] = new_ldisc;
57253 new_ldisc->num = disc;
57254- new_ldisc->refcount = 0;
57255+ atomic_set(&new_ldisc->refcount, 0);
57256 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
57257
57258 return ret;
57259@@ -98,7 +98,7 @@ int tty_unregister_ldisc(int disc)
57260 return -EINVAL;
57261
57262 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
57263- if (tty_ldiscs[disc]->refcount)
57264+ if (atomic_read(&tty_ldiscs[disc]->refcount))
57265 ret = -EBUSY;
57266 else
57267 tty_ldiscs[disc] = NULL;
57268@@ -119,7 +119,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
57269 if (ldops) {
57270 ret = ERR_PTR(-EAGAIN);
57271 if (try_module_get(ldops->owner)) {
57272- ldops->refcount++;
57273+ atomic_inc(&ldops->refcount);
57274 ret = ldops;
57275 }
57276 }
57277@@ -132,7 +132,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
57278 unsigned long flags;
57279
57280 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
57281- ldops->refcount--;
57282+ atomic_dec(&ldops->refcount);
57283 module_put(ldops->owner);
57284 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
57285 }
57286diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
57287index 40b31835..94d92ae 100644
57288--- a/drivers/tty/tty_port.c
57289+++ b/drivers/tty/tty_port.c
57290@@ -236,7 +236,7 @@ void tty_port_hangup(struct tty_port *port)
57291 unsigned long flags;
57292
57293 spin_lock_irqsave(&port->lock, flags);
57294- port->count = 0;
57295+ atomic_set(&port->count, 0);
57296 port->flags &= ~ASYNC_NORMAL_ACTIVE;
57297 tty = port->tty;
57298 if (tty)
57299@@ -398,7 +398,7 @@ int tty_port_block_til_ready(struct tty_port *port,
57300
57301 /* The port lock protects the port counts */
57302 spin_lock_irqsave(&port->lock, flags);
57303- port->count--;
57304+ atomic_dec(&port->count);
57305 port->blocked_open++;
57306 spin_unlock_irqrestore(&port->lock, flags);
57307
57308@@ -440,7 +440,7 @@ int tty_port_block_til_ready(struct tty_port *port,
57309 we must not mess that up further */
57310 spin_lock_irqsave(&port->lock, flags);
57311 if (!tty_hung_up_p(filp))
57312- port->count++;
57313+ atomic_inc(&port->count);
57314 port->blocked_open--;
57315 if (retval == 0)
57316 port->flags |= ASYNC_NORMAL_ACTIVE;
57317@@ -476,19 +476,19 @@ int tty_port_close_start(struct tty_port *port,
57318 return 0;
57319
57320 spin_lock_irqsave(&port->lock, flags);
57321- if (tty->count == 1 && port->count != 1) {
57322+ if (tty->count == 1 && atomic_read(&port->count) != 1) {
57323 printk(KERN_WARNING
57324 "tty_port_close_start: tty->count = 1 port count = %d.\n",
57325- port->count);
57326- port->count = 1;
57327+ atomic_read(&port->count));
57328+ atomic_set(&port->count, 1);
57329 }
57330- if (--port->count < 0) {
57331+ if (atomic_dec_return(&port->count) < 0) {
57332 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
57333- port->count);
57334- port->count = 0;
57335+ atomic_read(&port->count));
57336+ atomic_set(&port->count, 0);
57337 }
57338
57339- if (port->count) {
57340+ if (atomic_read(&port->count)) {
57341 spin_unlock_irqrestore(&port->lock, flags);
57342 return 0;
57343 }
57344@@ -590,7 +590,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
57345 struct file *filp)
57346 {
57347 spin_lock_irq(&port->lock);
57348- ++port->count;
57349+ atomic_inc(&port->count);
57350 spin_unlock_irq(&port->lock);
57351 tty_port_tty_set(port, tty);
57352
57353diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
57354index 6f0336f..5818bc1 100644
57355--- a/drivers/tty/vt/keyboard.c
57356+++ b/drivers/tty/vt/keyboard.c
57357@@ -642,6 +642,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
57358 kbd->kbdmode == VC_OFF) &&
57359 value != KVAL(K_SAK))
57360 return; /* SAK is allowed even in raw mode */
57361+
57362+#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
57363+ {
57364+ void *func = fn_handler[value];
57365+ if (func == fn_show_state || func == fn_show_ptregs ||
57366+ func == fn_show_mem)
57367+ return;
57368+ }
57369+#endif
57370+
57371 fn_handler[value](vc);
57372 }
57373
57374@@ -1880,9 +1890,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
57375 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
57376 return -EFAULT;
57377
57378- if (!capable(CAP_SYS_TTY_CONFIG))
57379- perm = 0;
57380-
57381 switch (cmd) {
57382 case KDGKBENT:
57383 /* Ensure another thread doesn't free it under us */
57384@@ -1897,6 +1904,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
57385 spin_unlock_irqrestore(&kbd_event_lock, flags);
57386 return put_user(val, &user_kbe->kb_value);
57387 case KDSKBENT:
57388+ if (!capable(CAP_SYS_TTY_CONFIG))
57389+ perm = 0;
57390+
57391 if (!perm)
57392 return -EPERM;
57393 if (!i && v == K_NOSUCHMAP) {
57394@@ -1987,9 +1997,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
57395 int i, j, k;
57396 int ret;
57397
57398- if (!capable(CAP_SYS_TTY_CONFIG))
57399- perm = 0;
57400-
57401 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
57402 if (!kbs) {
57403 ret = -ENOMEM;
57404@@ -2023,6 +2030,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
57405 kfree(kbs);
57406 return ((p && *p) ? -EOVERFLOW : 0);
57407 case KDSKBSENT:
57408+ if (!capable(CAP_SYS_TTY_CONFIG))
57409+ perm = 0;
57410+
57411 if (!perm) {
57412 ret = -EPERM;
57413 goto reterr;
57414diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
57415index 3257d42..b430b06 100644
57416--- a/drivers/uio/uio.c
57417+++ b/drivers/uio/uio.c
57418@@ -25,6 +25,7 @@
57419 #include <linux/kobject.h>
57420 #include <linux/cdev.h>
57421 #include <linux/uio_driver.h>
57422+#include <asm/local.h>
57423
57424 #define UIO_MAX_DEVICES (1U << MINORBITS)
57425
57426@@ -231,7 +232,7 @@ static ssize_t event_show(struct device *dev,
57427 struct device_attribute *attr, char *buf)
57428 {
57429 struct uio_device *idev = dev_get_drvdata(dev);
57430- return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
57431+ return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
57432 }
57433 static DEVICE_ATTR_RO(event);
57434
57435@@ -393,7 +394,7 @@ void uio_event_notify(struct uio_info *info)
57436 {
57437 struct uio_device *idev = info->uio_dev;
57438
57439- atomic_inc(&idev->event);
57440+ atomic_inc_unchecked(&idev->event);
57441 wake_up_interruptible(&idev->wait);
57442 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
57443 }
57444@@ -446,7 +447,7 @@ static int uio_open(struct inode *inode, struct file *filep)
57445 }
57446
57447 listener->dev = idev;
57448- listener->event_count = atomic_read(&idev->event);
57449+ listener->event_count = atomic_read_unchecked(&idev->event);
57450 filep->private_data = listener;
57451
57452 if (idev->info->open) {
57453@@ -497,7 +498,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
57454 return -EIO;
57455
57456 poll_wait(filep, &idev->wait, wait);
57457- if (listener->event_count != atomic_read(&idev->event))
57458+ if (listener->event_count != atomic_read_unchecked(&idev->event))
57459 return POLLIN | POLLRDNORM;
57460 return 0;
57461 }
57462@@ -522,7 +523,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
57463 do {
57464 set_current_state(TASK_INTERRUPTIBLE);
57465
57466- event_count = atomic_read(&idev->event);
57467+ event_count = atomic_read_unchecked(&idev->event);
57468 if (event_count != listener->event_count) {
57469 if (copy_to_user(buf, &event_count, count))
57470 retval = -EFAULT;
57471@@ -579,9 +580,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
57472 static int uio_find_mem_index(struct vm_area_struct *vma)
57473 {
57474 struct uio_device *idev = vma->vm_private_data;
57475+ unsigned long size;
57476
57477 if (vma->vm_pgoff < MAX_UIO_MAPS) {
57478- if (idev->info->mem[vma->vm_pgoff].size == 0)
57479+ size = idev->info->mem[vma->vm_pgoff].size;
57480+ if (size == 0)
57481+ return -1;
57482+ if (vma->vm_end - vma->vm_start > size)
57483 return -1;
57484 return (int)vma->vm_pgoff;
57485 }
57486@@ -813,7 +818,7 @@ int __uio_register_device(struct module *owner,
57487 idev->owner = owner;
57488 idev->info = info;
57489 init_waitqueue_head(&idev->wait);
57490- atomic_set(&idev->event, 0);
57491+ atomic_set_unchecked(&idev->event, 0);
57492
57493 ret = uio_get_minor(idev);
57494 if (ret)
57495diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
57496index 813d4d3..a71934f 100644
57497--- a/drivers/usb/atm/cxacru.c
57498+++ b/drivers/usb/atm/cxacru.c
57499@@ -472,7 +472,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
57500 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
57501 if (ret < 2)
57502 return -EINVAL;
57503- if (index < 0 || index > 0x7f)
57504+ if (index > 0x7f)
57505 return -EINVAL;
57506 pos += tmp;
57507
57508diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
57509index db322d9..f0f4bc1 100644
57510--- a/drivers/usb/atm/usbatm.c
57511+++ b/drivers/usb/atm/usbatm.c
57512@@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57513 if (printk_ratelimit())
57514 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
57515 __func__, vpi, vci);
57516- atomic_inc(&vcc->stats->rx_err);
57517+ atomic_inc_unchecked(&vcc->stats->rx_err);
57518 return;
57519 }
57520
57521@@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57522 if (length > ATM_MAX_AAL5_PDU) {
57523 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
57524 __func__, length, vcc);
57525- atomic_inc(&vcc->stats->rx_err);
57526+ atomic_inc_unchecked(&vcc->stats->rx_err);
57527 goto out;
57528 }
57529
57530@@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57531 if (sarb->len < pdu_length) {
57532 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
57533 __func__, pdu_length, sarb->len, vcc);
57534- atomic_inc(&vcc->stats->rx_err);
57535+ atomic_inc_unchecked(&vcc->stats->rx_err);
57536 goto out;
57537 }
57538
57539 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
57540 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
57541 __func__, vcc);
57542- atomic_inc(&vcc->stats->rx_err);
57543+ atomic_inc_unchecked(&vcc->stats->rx_err);
57544 goto out;
57545 }
57546
57547@@ -387,7 +387,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57548 if (printk_ratelimit())
57549 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
57550 __func__, length);
57551- atomic_inc(&vcc->stats->rx_drop);
57552+ atomic_inc_unchecked(&vcc->stats->rx_drop);
57553 goto out;
57554 }
57555
57556@@ -415,7 +415,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
57557
57558 vcc->push(vcc, skb);
57559
57560- atomic_inc(&vcc->stats->rx);
57561+ atomic_inc_unchecked(&vcc->stats->rx);
57562 out:
57563 skb_trim(sarb, 0);
57564 }
57565@@ -613,7 +613,7 @@ static void usbatm_tx_process(unsigned long data)
57566 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
57567
57568 usbatm_pop(vcc, skb);
57569- atomic_inc(&vcc->stats->tx);
57570+ atomic_inc_unchecked(&vcc->stats->tx);
57571
57572 skb = skb_dequeue(&instance->sndqueue);
57573 }
57574@@ -757,11 +757,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t *pos, char *page
57575 if (!left--)
57576 return sprintf(page,
57577 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
57578- atomic_read(&atm_dev->stats.aal5.tx),
57579- atomic_read(&atm_dev->stats.aal5.tx_err),
57580- atomic_read(&atm_dev->stats.aal5.rx),
57581- atomic_read(&atm_dev->stats.aal5.rx_err),
57582- atomic_read(&atm_dev->stats.aal5.rx_drop));
57583+ atomic_read_unchecked(&atm_dev->stats.aal5.tx),
57584+ atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
57585+ atomic_read_unchecked(&atm_dev->stats.aal5.rx),
57586+ atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
57587+ atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
57588
57589 if (!left--) {
57590 if (instance->disconnected)
57591diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
57592index dd9af38..75b53e3 100644
57593--- a/drivers/usb/class/cdc-acm.h
57594+++ b/drivers/usb/class/cdc-acm.h
57595@@ -95,7 +95,7 @@ struct acm {
57596 struct urb *read_urbs[ACM_NR];
57597 struct acm_rb read_buffers[ACM_NR];
57598 int rx_buflimit;
57599- int rx_endpoint;
57600+ unsigned int rx_endpoint;
57601 spinlock_t read_lock;
57602 int write_used; /* number of non-empty write buffers */
57603 int transmitting;
57604diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
57605index 2a3bbdf..91d72cf 100644
57606--- a/drivers/usb/core/devices.c
57607+++ b/drivers/usb/core/devices.c
57608@@ -126,7 +126,7 @@ static const char format_endpt[] =
57609 * time it gets called.
57610 */
57611 static struct device_connect_event {
57612- atomic_t count;
57613+ atomic_unchecked_t count;
57614 wait_queue_head_t wait;
57615 } device_event = {
57616 .count = ATOMIC_INIT(1),
57617@@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
57618
57619 void usbfs_conn_disc_event(void)
57620 {
57621- atomic_add(2, &device_event.count);
57622+ atomic_add_unchecked(2, &device_event.count);
57623 wake_up(&device_event.wait);
57624 }
57625
57626@@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
57627
57628 poll_wait(file, &device_event.wait, wait);
57629
57630- event_count = atomic_read(&device_event.count);
57631+ event_count = atomic_read_unchecked(&device_event.count);
57632 if (file->f_version != event_count) {
57633 file->f_version = event_count;
57634 return POLLIN | POLLRDNORM;
57635diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
57636index 986abde..2af59b11 100644
57637--- a/drivers/usb/core/devio.c
57638+++ b/drivers/usb/core/devio.c
57639@@ -187,7 +187,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
57640 struct usb_dev_state *ps = file->private_data;
57641 struct usb_device *dev = ps->dev;
57642 ssize_t ret = 0;
57643- unsigned len;
57644+ size_t len;
57645 loff_t pos;
57646 int i;
57647
57648@@ -229,22 +229,22 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
57649 for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
57650 struct usb_config_descriptor *config =
57651 (struct usb_config_descriptor *)dev->rawdescriptors[i];
57652- unsigned int length = le16_to_cpu(config->wTotalLength);
57653+ size_t length = le16_to_cpu(config->wTotalLength);
57654
57655 if (*ppos < pos + length) {
57656
57657 /* The descriptor may claim to be longer than it
57658 * really is. Here is the actual allocated length. */
57659- unsigned alloclen =
57660+ size_t alloclen =
57661 le16_to_cpu(dev->config[i].desc.wTotalLength);
57662
57663- len = length - (*ppos - pos);
57664+ len = length + pos - *ppos;
57665 if (len > nbytes)
57666 len = nbytes;
57667
57668 /* Simply don't write (skip over) unallocated parts */
57669 if (alloclen > (*ppos - pos)) {
57670- alloclen -= (*ppos - pos);
57671+ alloclen = alloclen + pos - *ppos;
57672 if (copy_to_user(buf,
57673 dev->rawdescriptors[i] + (*ppos - pos),
57674 min(len, alloclen))) {
57675@@ -1499,7 +1499,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
57676 }
57677 }
57678 as->urb->dev = ps->dev;
57679- as->urb->pipe = (uurb->type << 30) |
57680+ as->urb->pipe = ((unsigned int)uurb->type << 30) |
57681 __create_pipe(ps->dev, uurb->endpoint & 0xf) |
57682 (uurb->endpoint & USB_DIR_IN);
57683
57684diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
57685index cbcd092..e783f87 100644
57686--- a/drivers/usb/core/hcd.c
57687+++ b/drivers/usb/core/hcd.c
57688@@ -1554,7 +1554,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
57689 */
57690 usb_get_urb(urb);
57691 atomic_inc(&urb->use_count);
57692- atomic_inc(&urb->dev->urbnum);
57693+ atomic_inc_unchecked(&urb->dev->urbnum);
57694 usbmon_urb_submit(&hcd->self, urb);
57695
57696 /* NOTE requirements on root-hub callers (usbfs and the hub
57697@@ -1581,7 +1581,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
57698 urb->hcpriv = NULL;
57699 INIT_LIST_HEAD(&urb->urb_list);
57700 atomic_dec(&urb->use_count);
57701- atomic_dec(&urb->dev->urbnum);
57702+ atomic_dec_unchecked(&urb->dev->urbnum);
57703 if (atomic_read(&urb->reject))
57704 wake_up(&usb_kill_urb_queue);
57705 usb_put_urb(urb);
57706diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
57707index 73dfa19..c22f1e43 100644
57708--- a/drivers/usb/core/hub.c
57709+++ b/drivers/usb/core/hub.c
57710@@ -26,6 +26,7 @@
57711 #include <linux/mutex.h>
57712 #include <linux/random.h>
57713 #include <linux/pm_qos.h>
57714+#include <linux/grsecurity.h>
57715
57716 #include <asm/uaccess.h>
57717 #include <asm/byteorder.h>
57718@@ -4655,6 +4656,10 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
57719 goto done;
57720 return;
57721 }
57722+
57723+ if (gr_handle_new_usb())
57724+ goto done;
57725+
57726 if (hub_is_superspeed(hub->hdev))
57727 unit_load = 150;
57728 else
57729diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
57730index d269738..7340cd7 100644
57731--- a/drivers/usb/core/sysfs.c
57732+++ b/drivers/usb/core/sysfs.c
57733@@ -244,7 +244,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
57734 struct usb_device *udev;
57735
57736 udev = to_usb_device(dev);
57737- return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
57738+ return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
57739 }
57740 static DEVICE_ATTR_RO(urbnum);
57741
57742diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
57743index 8d5b2f4..3896940 100644
57744--- a/drivers/usb/core/usb.c
57745+++ b/drivers/usb/core/usb.c
57746@@ -447,7 +447,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
57747 set_dev_node(&dev->dev, dev_to_node(bus->controller));
57748 dev->state = USB_STATE_ATTACHED;
57749 dev->lpm_disable_count = 1;
57750- atomic_set(&dev->urbnum, 0);
57751+ atomic_set_unchecked(&dev->urbnum, 0);
57752
57753 INIT_LIST_HEAD(&dev->ep0.urb_list);
57754 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
57755diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
57756index 8cfc319..4868255 100644
57757--- a/drivers/usb/early/ehci-dbgp.c
57758+++ b/drivers/usb/early/ehci-dbgp.c
57759@@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
57760
57761 #ifdef CONFIG_KGDB
57762 static struct kgdb_io kgdbdbgp_io_ops;
57763-#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
57764+static struct kgdb_io kgdbdbgp_io_ops_console;
57765+#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
57766 #else
57767 #define dbgp_kgdb_mode (0)
57768 #endif
57769@@ -1043,6 +1044,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
57770 .write_char = kgdbdbgp_write_char,
57771 };
57772
57773+static struct kgdb_io kgdbdbgp_io_ops_console = {
57774+ .name = "kgdbdbgp",
57775+ .read_char = kgdbdbgp_read_char,
57776+ .write_char = kgdbdbgp_write_char,
57777+ .is_console = 1
57778+};
57779+
57780 static int kgdbdbgp_wait_time;
57781
57782 static int __init kgdbdbgp_parse_config(char *str)
57783@@ -1058,8 +1066,10 @@ static int __init kgdbdbgp_parse_config(char *str)
57784 ptr++;
57785 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
57786 }
57787- kgdb_register_io_module(&kgdbdbgp_io_ops);
57788- kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
57789+ if (early_dbgp_console.index != -1)
57790+ kgdb_register_io_module(&kgdbdbgp_io_ops_console);
57791+ else
57792+ kgdb_register_io_module(&kgdbdbgp_io_ops);
57793
57794 return 0;
57795 }
57796diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c
57797index 7856b33..8b7fe09 100644
57798--- a/drivers/usb/gadget/function/f_uac1.c
57799+++ b/drivers/usb/gadget/function/f_uac1.c
57800@@ -14,6 +14,7 @@
57801 #include <linux/module.h>
57802 #include <linux/device.h>
57803 #include <linux/atomic.h>
57804+#include <linux/module.h>
57805
57806 #include "u_uac1.h"
57807
57808diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
57809index 7ee05793..2e31e99 100644
57810--- a/drivers/usb/gadget/function/u_serial.c
57811+++ b/drivers/usb/gadget/function/u_serial.c
57812@@ -732,9 +732,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
57813 spin_lock_irq(&port->port_lock);
57814
57815 /* already open? Great. */
57816- if (port->port.count) {
57817+ if (atomic_read(&port->port.count)) {
57818 status = 0;
57819- port->port.count++;
57820+ atomic_inc(&port->port.count);
57821
57822 /* currently opening/closing? wait ... */
57823 } else if (port->openclose) {
57824@@ -793,7 +793,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
57825 tty->driver_data = port;
57826 port->port.tty = tty;
57827
57828- port->port.count = 1;
57829+ atomic_set(&port->port.count, 1);
57830 port->openclose = false;
57831
57832 /* if connected, start the I/O stream */
57833@@ -835,11 +835,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
57834
57835 spin_lock_irq(&port->port_lock);
57836
57837- if (port->port.count != 1) {
57838- if (port->port.count == 0)
57839+ if (atomic_read(&port->port.count) != 1) {
57840+ if (atomic_read(&port->port.count) == 0)
57841 WARN_ON(1);
57842 else
57843- --port->port.count;
57844+ atomic_dec(&port->port.count);
57845 goto exit;
57846 }
57847
57848@@ -849,7 +849,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
57849 * and sleep if necessary
57850 */
57851 port->openclose = true;
57852- port->port.count = 0;
57853+ atomic_set(&port->port.count, 0);
57854
57855 gser = port->port_usb;
57856 if (gser && gser->disconnect)
57857@@ -1065,7 +1065,7 @@ static int gs_closed(struct gs_port *port)
57858 int cond;
57859
57860 spin_lock_irq(&port->port_lock);
57861- cond = (port->port.count == 0) && !port->openclose;
57862+ cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
57863 spin_unlock_irq(&port->port_lock);
57864 return cond;
57865 }
57866@@ -1208,7 +1208,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
57867 /* if it's already open, start I/O ... and notify the serial
57868 * protocol about open/close status (connect/disconnect).
57869 */
57870- if (port->port.count) {
57871+ if (atomic_read(&port->port.count)) {
57872 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
57873 gs_start_io(port);
57874 if (gser->connect)
57875@@ -1255,7 +1255,7 @@ void gserial_disconnect(struct gserial *gser)
57876
57877 port->port_usb = NULL;
57878 gser->ioport = NULL;
57879- if (port->port.count > 0 || port->openclose) {
57880+ if (atomic_read(&port->port.count) > 0 || port->openclose) {
57881 wake_up_interruptible(&port->drain_wait);
57882 if (port->port.tty)
57883 tty_hangup(port->port.tty);
57884@@ -1271,7 +1271,7 @@ void gserial_disconnect(struct gserial *gser)
57885
57886 /* finally, free any unused/unusable I/O buffers */
57887 spin_lock_irqsave(&port->port_lock, flags);
57888- if (port->port.count == 0 && !port->openclose)
57889+ if (atomic_read(&port->port.count) == 0 && !port->openclose)
57890 gs_buf_free(&port->port_write_buf);
57891 gs_free_requests(gser->out, &port->read_pool, NULL);
57892 gs_free_requests(gser->out, &port->read_queue, NULL);
57893diff --git a/drivers/usb/gadget/function/u_uac1.c b/drivers/usb/gadget/function/u_uac1.c
57894index c78c841..48fd281 100644
57895--- a/drivers/usb/gadget/function/u_uac1.c
57896+++ b/drivers/usb/gadget/function/u_uac1.c
57897@@ -17,6 +17,7 @@
57898 #include <linux/ctype.h>
57899 #include <linux/random.h>
57900 #include <linux/syscalls.h>
57901+#include <linux/module.h>
57902
57903 #include "u_uac1.h"
57904
57905diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
57906index 181112c..036bcab 100644
57907--- a/drivers/usb/gadget/udc/dummy_hcd.c
57908+++ b/drivers/usb/gadget/udc/dummy_hcd.c
57909@@ -2384,7 +2384,7 @@ static int dummy_setup(struct usb_hcd *hcd)
57910 struct dummy *dum;
57911
57912 dum = *((void **)dev_get_platdata(hcd->self.controller));
57913- hcd->self.sg_tablesize = ~0;
57914+ hcd->self.sg_tablesize = SG_ALL;
57915 if (usb_hcd_is_primary_hcd(hcd)) {
57916 dum->hs_hcd = hcd_to_dummy_hcd(hcd);
57917 dum->hs_hcd->dum = dum;
57918diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
57919index c63d82c..a7e8665 100644
57920--- a/drivers/usb/host/ehci-hcd.c
57921+++ b/drivers/usb/host/ehci-hcd.c
57922@@ -564,7 +564,7 @@ static int ehci_init(struct usb_hcd *hcd)
57923
57924 /* Accept arbitrarily long scatter-gather lists */
57925 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
57926- hcd->self.sg_tablesize = ~0;
57927+ hcd->self.sg_tablesize = SG_ALL;
57928 return 0;
57929 }
57930
57931diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
57932index 22abb68..50b7b84 100644
57933--- a/drivers/usb/host/ehci-hub.c
57934+++ b/drivers/usb/host/ehci-hub.c
57935@@ -773,7 +773,7 @@ static struct urb *request_single_step_set_feature_urb(
57936 urb->transfer_flags = URB_DIR_IN;
57937 usb_get_urb(urb);
57938 atomic_inc(&urb->use_count);
57939- atomic_inc(&urb->dev->urbnum);
57940+ atomic_inc_unchecked(&urb->dev->urbnum);
57941 urb->setup_dma = dma_map_single(
57942 hcd->self.controller,
57943 urb->setup_packet,
57944@@ -840,7 +840,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
57945 urb->status = -EINPROGRESS;
57946 usb_get_urb(urb);
57947 atomic_inc(&urb->use_count);
57948- atomic_inc(&urb->dev->urbnum);
57949+ atomic_inc_unchecked(&urb->dev->urbnum);
57950 retval = submit_single_step_set_feature(hcd, urb, 0);
57951 if (!retval && !wait_for_completion_timeout(&done,
57952 msecs_to_jiffies(2000))) {
57953diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
57954index 54f5332..8b8335c 100644
57955--- a/drivers/usb/host/ehci-q.c
57956+++ b/drivers/usb/host/ehci-q.c
57957@@ -44,9 +44,9 @@
57958
57959 static int
57960 qtd_fill(struct ehci_hcd *ehci, struct ehci_qtd *qtd, dma_addr_t buf,
57961- size_t len, int token, int maxpacket)
57962+ size_t len, u32 token, int maxpacket)
57963 {
57964- int i, count;
57965+ u32 i, count;
57966 u64 addr = buf;
57967
57968 /* one buffer entry per 4K ... first might be short or unaligned */
57969diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
57970index 000ed80..2701154 100644
57971--- a/drivers/usb/host/fotg210-hcd.c
57972+++ b/drivers/usb/host/fotg210-hcd.c
57973@@ -5231,7 +5231,7 @@ static int hcd_fotg210_init(struct usb_hcd *hcd)
57974
57975 /* Accept arbitrarily long scatter-gather lists */
57976 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
57977- hcd->self.sg_tablesize = ~0;
57978+ hcd->self.sg_tablesize = SG_ALL;
57979 return 0;
57980 }
57981
57982diff --git a/drivers/usb/host/fusbh200-hcd.c b/drivers/usb/host/fusbh200-hcd.c
57983index 1fd8718..c7ff47c 100644
57984--- a/drivers/usb/host/fusbh200-hcd.c
57985+++ b/drivers/usb/host/fusbh200-hcd.c
57986@@ -5156,7 +5156,7 @@ static int hcd_fusbh200_init(struct usb_hcd *hcd)
57987
57988 /* Accept arbitrarily long scatter-gather lists */
57989 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
57990- hcd->self.sg_tablesize = ~0;
57991+ hcd->self.sg_tablesize = SG_ALL;
57992 return 0;
57993 }
57994
57995diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
57996index 1db0626..2e9f5ea 100644
57997--- a/drivers/usb/host/hwa-hc.c
57998+++ b/drivers/usb/host/hwa-hc.c
57999@@ -337,7 +337,10 @@ static int __hwahc_op_bwa_set(struct wusbhc *wusbhc, s8 stream_index,
58000 struct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc);
58001 struct wahc *wa = &hwahc->wa;
58002 struct device *dev = &wa->usb_iface->dev;
58003- u8 mas_le[UWB_NUM_MAS/8];
58004+ u8 *mas_le = kmalloc(UWB_NUM_MAS/8, GFP_KERNEL);
58005+
58006+ if (mas_le == NULL)
58007+ return -ENOMEM;
58008
58009 /* Set the stream index */
58010 result = usb_control_msg(wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0),
58011@@ -356,10 +359,12 @@ static int __hwahc_op_bwa_set(struct wusbhc *wusbhc, s8 stream_index,
58012 WUSB_REQ_SET_WUSB_MAS,
58013 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
58014 0, wa->usb_iface->cur_altsetting->desc.bInterfaceNumber,
58015- mas_le, 32, USB_CTRL_SET_TIMEOUT);
58016+ mas_le, UWB_NUM_MAS/8, USB_CTRL_SET_TIMEOUT);
58017 if (result < 0)
58018 dev_err(dev, "Cannot set WUSB MAS allocation: %d\n", result);
58019 out:
58020+ kfree(mas_le);
58021+
58022 return result;
58023 }
58024
58025@@ -812,7 +817,7 @@ static int hwahc_probe(struct usb_interface *usb_iface,
58026 goto error_alloc;
58027 }
58028 usb_hcd->wireless = 1;
58029- usb_hcd->self.sg_tablesize = ~0;
58030+ usb_hcd->self.sg_tablesize = SG_ALL;
58031 wusbhc = usb_hcd_to_wusbhc(usb_hcd);
58032 hwahc = container_of(wusbhc, struct hwahc, wusbhc);
58033 hwahc_init(hwahc);
58034diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
58035index 760cb57..fc7f8ad 100644
58036--- a/drivers/usb/host/ohci-hcd.c
58037+++ b/drivers/usb/host/ohci-hcd.c
58038@@ -444,7 +444,7 @@ static int ohci_init (struct ohci_hcd *ohci)
58039 struct usb_hcd *hcd = ohci_to_hcd(ohci);
58040
58041 /* Accept arbitrarily long scatter-gather lists */
58042- hcd->self.sg_tablesize = ~0;
58043+ hcd->self.sg_tablesize = SG_ALL;
58044
58045 if (distrust_firmware)
58046 ohci->flags |= OHCI_QUIRK_HUB_POWER;
58047diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h
58048index 672cea3..31a730db 100644
58049--- a/drivers/usb/host/r8a66597.h
58050+++ b/drivers/usb/host/r8a66597.h
58051@@ -125,7 +125,7 @@ struct r8a66597 {
58052 unsigned short interval_map;
58053 unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE];
58054 unsigned char dma_map;
58055- unsigned int max_root_hub;
58056+ unsigned char max_root_hub;
58057
58058 struct list_head child_device;
58059 unsigned long child_connect_map[4];
58060diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
58061index a7de8e8..e1ef134 100644
58062--- a/drivers/usb/host/uhci-hcd.c
58063+++ b/drivers/usb/host/uhci-hcd.c
58064@@ -570,7 +570,7 @@ static int uhci_start(struct usb_hcd *hcd)
58065 hcd->uses_new_polling = 1;
58066 /* Accept arbitrarily long scatter-gather lists */
58067 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
58068- hcd->self.sg_tablesize = ~0;
58069+ hcd->self.sg_tablesize = SG_ALL;
58070
58071 spin_lock_init(&uhci->lock);
58072 setup_timer(&uhci->fsbr_timer, uhci_fsbr_timeout,
58073diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
58074index c79d336..8fe41af 100644
58075--- a/drivers/usb/host/xhci-pci.c
58076+++ b/drivers/usb/host/xhci-pci.c
58077@@ -30,7 +30,7 @@
58078
58079 #define PORT2_SSIC_CONFIG_REG2 0x883c
58080 #define PROG_DONE (1 << 30)
58081-#define SSIC_PORT_UNUSED (1 << 31)
58082+#define SSIC_PORT_UNUSED (1U << 31)
58083
58084 /* Device for a quirk */
58085 #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73
58086diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
58087index d7b9f484..8208965 100644
58088--- a/drivers/usb/host/xhci.c
58089+++ b/drivers/usb/host/xhci.c
58090@@ -4837,7 +4837,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
58091 int retval;
58092
58093 /* Accept arbitrarily long scatter-gather lists */
58094- hcd->self.sg_tablesize = ~0;
58095+ hcd->self.sg_tablesize = SG_ALL;
58096
58097 /* support to build packet from discontinuous buffers */
58098 hcd->self.no_sg_constraint = 1;
58099diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
58100index a0a3827..d7ec10b 100644
58101--- a/drivers/usb/misc/appledisplay.c
58102+++ b/drivers/usb/misc/appledisplay.c
58103@@ -84,7 +84,7 @@ struct appledisplay {
58104 struct mutex sysfslock; /* concurrent read and write */
58105 };
58106
58107-static atomic_t count_displays = ATOMIC_INIT(0);
58108+static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
58109 static struct workqueue_struct *wq;
58110
58111 static void appledisplay_complete(struct urb *urb)
58112@@ -288,7 +288,7 @@ static int appledisplay_probe(struct usb_interface *iface,
58113
58114 /* Register backlight device */
58115 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
58116- atomic_inc_return(&count_displays) - 1);
58117+ atomic_inc_return_unchecked(&count_displays) - 1);
58118 memset(&props, 0, sizeof(struct backlight_properties));
58119 props.type = BACKLIGHT_RAW;
58120 props.max_brightness = 0xff;
58121diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
58122index 3806e70..55c508b 100644
58123--- a/drivers/usb/serial/console.c
58124+++ b/drivers/usb/serial/console.c
58125@@ -126,7 +126,7 @@ static int usb_console_setup(struct console *co, char *options)
58126
58127 info->port = port;
58128
58129- ++port->port.count;
58130+ atomic_inc(&port->port.count);
58131 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
58132 if (serial->type->set_termios) {
58133 /*
58134@@ -175,7 +175,7 @@ static int usb_console_setup(struct console *co, char *options)
58135 }
58136 /* Now that any required fake tty operations are completed restore
58137 * the tty port count */
58138- --port->port.count;
58139+ atomic_dec(&port->port.count);
58140 /* The console is special in terms of closing the device so
58141 * indicate this port is now acting as a system console. */
58142 port->port.console = 1;
58143@@ -188,7 +188,7 @@ static int usb_console_setup(struct console *co, char *options)
58144 put_tty:
58145 tty_kref_put(tty);
58146 reset_open_count:
58147- port->port.count = 0;
58148+ atomic_set(&port->port.count, 0);
58149 usb_autopm_put_interface(serial->interface);
58150 error_get_interface:
58151 usb_serial_put(serial);
58152@@ -199,7 +199,7 @@ static int usb_console_setup(struct console *co, char *options)
58153 static void usb_console_write(struct console *co,
58154 const char *buf, unsigned count)
58155 {
58156- static struct usbcons_info *info = &usbcons_info;
58157+ struct usbcons_info *info = &usbcons_info;
58158 struct usb_serial_port *port = info->port;
58159 struct usb_serial *serial;
58160 int retval = -ENODEV;
58161diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
58162index 540add2..2a2c7da 100644
58163--- a/drivers/usb/storage/transport.c
58164+++ b/drivers/usb/storage/transport.c
58165@@ -689,7 +689,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
58166 if (need_auto_sense) {
58167 int temp_result;
58168 struct scsi_eh_save ses;
58169- int sense_size = US_SENSE_SIZE;
58170+ unsigned int sense_size = US_SENSE_SIZE;
58171 struct scsi_sense_hdr sshdr;
58172 const u8 *scdd;
58173 u8 fm_ili;
58174diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
58175index 43576ed..583589d 100644
58176--- a/drivers/usb/storage/usb.c
58177+++ b/drivers/usb/storage/usb.c
58178@@ -912,7 +912,7 @@ static void usb_stor_scan_dwork(struct work_struct *work)
58179 clear_bit(US_FLIDX_SCAN_PENDING, &us->dflags);
58180 }
58181
58182-static unsigned int usb_stor_sg_tablesize(struct usb_interface *intf)
58183+static unsigned short usb_stor_sg_tablesize(struct usb_interface *intf)
58184 {
58185 struct usb_device *usb_dev = interface_to_usbdev(intf);
58186
58187diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
58188index da0ad32..50b5bbe 100644
58189--- a/drivers/usb/storage/usb.h
58190+++ b/drivers/usb/storage/usb.h
58191@@ -63,7 +63,7 @@ struct us_unusual_dev {
58192 __u8 useProtocol;
58193 __u8 useTransport;
58194 int (*initFunction)(struct us_data *);
58195-};
58196+} __do_const;
58197
58198
58199 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
58200diff --git a/drivers/usb/usbip/vhci.h b/drivers/usb/usbip/vhci.h
58201index a863a98..d272795 100644
58202--- a/drivers/usb/usbip/vhci.h
58203+++ b/drivers/usb/usbip/vhci.h
58204@@ -83,7 +83,7 @@ struct vhci_hcd {
58205 unsigned resuming:1;
58206 unsigned long re_timeout;
58207
58208- atomic_t seqnum;
58209+ atomic_unchecked_t seqnum;
58210
58211 /*
58212 * NOTE:
58213diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
58214index e9ef1ec..c3a0b04 100644
58215--- a/drivers/usb/usbip/vhci_hcd.c
58216+++ b/drivers/usb/usbip/vhci_hcd.c
58217@@ -440,7 +440,7 @@ static void vhci_tx_urb(struct urb *urb)
58218
58219 spin_lock(&vdev->priv_lock);
58220
58221- priv->seqnum = atomic_inc_return(&the_controller->seqnum);
58222+ priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
58223 if (priv->seqnum == 0xffff)
58224 dev_info(&urb->dev->dev, "seqnum max\n");
58225
58226@@ -685,7 +685,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
58227 return -ENOMEM;
58228 }
58229
58230- unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
58231+ unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
58232 if (unlink->seqnum == 0xffff)
58233 pr_info("seqnum max\n");
58234
58235@@ -889,7 +889,7 @@ static int vhci_start(struct usb_hcd *hcd)
58236 vdev->rhport = rhport;
58237 }
58238
58239- atomic_set(&vhci->seqnum, 0);
58240+ atomic_set_unchecked(&vhci->seqnum, 0);
58241 spin_lock_init(&vhci->lock);
58242
58243 hcd->power_budget = 0; /* no limit */
58244diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
58245index 00e4a54..d676f85 100644
58246--- a/drivers/usb/usbip/vhci_rx.c
58247+++ b/drivers/usb/usbip/vhci_rx.c
58248@@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
58249 if (!urb) {
58250 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
58251 pr_info("max seqnum %d\n",
58252- atomic_read(&the_controller->seqnum));
58253+ atomic_read_unchecked(&the_controller->seqnum));
58254 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
58255 return;
58256 }
58257diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
58258index 211f43f..6c22ae1 100644
58259--- a/drivers/usb/usbip/vhci_sysfs.c
58260+++ b/drivers/usb/usbip/vhci_sysfs.c
58261@@ -59,7 +59,7 @@ static ssize_t status_show(struct device *dev, struct device_attribute *attr,
58262 if (vdev->ud.status == VDEV_ST_USED) {
58263 out += sprintf(out, "%03u %08x ",
58264 vdev->speed, vdev->devid);
58265- out += sprintf(out, "%16p ", vdev->ud.tcp_socket);
58266+ out += sprintf(out, "%16pK ", vdev->ud.tcp_socket);
58267 out += sprintf(out, "%s", dev_name(&vdev->udev->dev));
58268
58269 } else {
58270diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
58271index edc7267..9f65ce2 100644
58272--- a/drivers/usb/wusbcore/wa-hc.h
58273+++ b/drivers/usb/wusbcore/wa-hc.h
58274@@ -240,7 +240,7 @@ struct wahc {
58275 spinlock_t xfer_list_lock;
58276 struct work_struct xfer_enqueue_work;
58277 struct work_struct xfer_error_work;
58278- atomic_t xfer_id_count;
58279+ atomic_unchecked_t xfer_id_count;
58280
58281 kernel_ulong_t quirks;
58282 };
58283@@ -305,7 +305,7 @@ static inline void wa_init(struct wahc *wa)
58284 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
58285 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
58286 wa->dto_in_use = 0;
58287- atomic_set(&wa->xfer_id_count, 1);
58288+ atomic_set_unchecked(&wa->xfer_id_count, 1);
58289 /* init the buf in URBs */
58290 for (index = 0; index < WA_MAX_BUF_IN_URBS; ++index)
58291 usb_init_urb(&(wa->buf_in_urbs[index]));
58292diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
58293index 69af4fd..da390d7 100644
58294--- a/drivers/usb/wusbcore/wa-xfer.c
58295+++ b/drivers/usb/wusbcore/wa-xfer.c
58296@@ -314,7 +314,7 @@ static void wa_xfer_completion(struct wa_xfer *xfer)
58297 */
58298 static void wa_xfer_id_init(struct wa_xfer *xfer)
58299 {
58300- xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
58301+ xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
58302 }
58303
58304 /* Return the xfer's ID. */
58305diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
58306index 563c510..1fcc957 100644
58307--- a/drivers/vfio/vfio.c
58308+++ b/drivers/vfio/vfio.c
58309@@ -517,7 +517,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
58310 return 0;
58311
58312 /* TODO Prevent device auto probing */
58313- WARN("Device %s added to live group %d!\n", dev_name(dev),
58314+ WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
58315 iommu_group_id(group->iommu_group));
58316
58317 return 0;
58318diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
58319index 3bb02c6..a01ff38 100644
58320--- a/drivers/vhost/vringh.c
58321+++ b/drivers/vhost/vringh.c
58322@@ -551,7 +551,7 @@ static inline void __vringh_notify_disable(struct vringh *vrh,
58323 static inline int getu16_user(const struct vringh *vrh, u16 *val, const __virtio16 *p)
58324 {
58325 __virtio16 v = 0;
58326- int rc = get_user(v, (__force __virtio16 __user *)p);
58327+ int rc = get_user(v, (__force_user __virtio16 *)p);
58328 *val = vringh16_to_cpu(vrh, v);
58329 return rc;
58330 }
58331@@ -559,12 +559,12 @@ static inline int getu16_user(const struct vringh *vrh, u16 *val, const __virtio
58332 static inline int putu16_user(const struct vringh *vrh, __virtio16 *p, u16 val)
58333 {
58334 __virtio16 v = cpu_to_vringh16(vrh, val);
58335- return put_user(v, (__force __virtio16 __user *)p);
58336+ return put_user(v, (__force_user __virtio16 *)p);
58337 }
58338
58339 static inline int copydesc_user(void *dst, const void *src, size_t len)
58340 {
58341- return copy_from_user(dst, (__force void __user *)src, len) ?
58342+ return copy_from_user(dst, (void __force_user *)src, len) ?
58343 -EFAULT : 0;
58344 }
58345
58346@@ -572,19 +572,19 @@ static inline int putused_user(struct vring_used_elem *dst,
58347 const struct vring_used_elem *src,
58348 unsigned int num)
58349 {
58350- return copy_to_user((__force void __user *)dst, src,
58351+ return copy_to_user((void __force_user *)dst, src,
58352 sizeof(*dst) * num) ? -EFAULT : 0;
58353 }
58354
58355 static inline int xfer_from_user(void *src, void *dst, size_t len)
58356 {
58357- return copy_from_user(dst, (__force void __user *)src, len) ?
58358+ return copy_from_user(dst, (void __force_user *)src, len) ?
58359 -EFAULT : 0;
58360 }
58361
58362 static inline int xfer_to_user(void *dst, void *src, size_t len)
58363 {
58364- return copy_to_user((__force void __user *)dst, src, len) ?
58365+ return copy_to_user((void __force_user *)dst, src, len) ?
58366 -EFAULT : 0;
58367 }
58368
58369@@ -621,9 +621,9 @@ int vringh_init_user(struct vringh *vrh, u64 features,
58370 vrh->last_used_idx = 0;
58371 vrh->vring.num = num;
58372 /* vring expects kernel addresses, but only used via accessors. */
58373- vrh->vring.desc = (__force struct vring_desc *)desc;
58374- vrh->vring.avail = (__force struct vring_avail *)avail;
58375- vrh->vring.used = (__force struct vring_used *)used;
58376+ vrh->vring.desc = (__force_kernel struct vring_desc *)desc;
58377+ vrh->vring.avail = (__force_kernel struct vring_avail *)avail;
58378+ vrh->vring.used = (__force_kernel struct vring_used *)used;
58379 return 0;
58380 }
58381 EXPORT_SYMBOL(vringh_init_user);
58382@@ -826,7 +826,7 @@ static inline int getu16_kern(const struct vringh *vrh,
58383
58384 static inline int putu16_kern(const struct vringh *vrh, __virtio16 *p, u16 val)
58385 {
58386- ACCESS_ONCE(*p) = cpu_to_vringh16(vrh, val);
58387+ ACCESS_ONCE_RW(*p) = cpu_to_vringh16(vrh, val);
58388 return 0;
58389 }
58390
58391diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
58392index 84a110a..96312c3 100644
58393--- a/drivers/video/backlight/kb3886_bl.c
58394+++ b/drivers/video/backlight/kb3886_bl.c
58395@@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
58396 static unsigned long kb3886bl_flags;
58397 #define KB3886BL_SUSPENDED 0x01
58398
58399-static struct dmi_system_id kb3886bl_device_table[] __initdata = {
58400+static const struct dmi_system_id kb3886bl_device_table[] __initconst = {
58401 {
58402 .ident = "Sahara Touch-iT",
58403 .matches = {
58404diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
58405index 1aaf893..da2885a 100644
58406--- a/drivers/video/console/fbcon.c
58407+++ b/drivers/video/console/fbcon.c
58408@@ -106,7 +106,7 @@ static int fbcon_softback_size = 32768;
58409 static unsigned long softback_buf, softback_curr;
58410 static unsigned long softback_in;
58411 static unsigned long softback_top, softback_end;
58412-static int softback_lines;
58413+static long softback_lines;
58414 /* console mappings */
58415 static int first_fb_vc;
58416 static int last_fb_vc = MAX_NR_CONSOLES - 1;
58417diff --git a/drivers/video/fbdev/arcfb.c b/drivers/video/fbdev/arcfb.c
58418index 1b0b233..6f34c2c 100644
58419--- a/drivers/video/fbdev/arcfb.c
58420+++ b/drivers/video/fbdev/arcfb.c
58421@@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
58422 return -ENOSPC;
58423
58424 err = 0;
58425- if ((count + p) > fbmemlength) {
58426+ if (count > (fbmemlength - p)) {
58427 count = fbmemlength - p;
58428 err = -ENOSPC;
58429 }
58430diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c
58431index c42ce2f..4c8bc59 100644
58432--- a/drivers/video/fbdev/aty/aty128fb.c
58433+++ b/drivers/video/fbdev/aty/aty128fb.c
58434@@ -145,7 +145,7 @@ enum {
58435 };
58436
58437 /* Must match above enum */
58438-static char * const r128_family[] = {
58439+static const char * const r128_family[] = {
58440 "AGP",
58441 "PCI",
58442 "PRO AGP",
58443diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c
58444index 8789e48..698fe4c 100644
58445--- a/drivers/video/fbdev/aty/atyfb_base.c
58446+++ b/drivers/video/fbdev/aty/atyfb_base.c
58447@@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
58448 par->accel_flags = var->accel_flags; /* hack */
58449
58450 if (var->accel_flags) {
58451- info->fbops->fb_sync = atyfb_sync;
58452+ pax_open_kernel();
58453+ *(void **)&info->fbops->fb_sync = atyfb_sync;
58454+ pax_close_kernel();
58455 info->flags &= ~FBINFO_HWACCEL_DISABLED;
58456 } else {
58457- info->fbops->fb_sync = NULL;
58458+ pax_open_kernel();
58459+ *(void **)&info->fbops->fb_sync = NULL;
58460+ pax_close_kernel();
58461 info->flags |= FBINFO_HWACCEL_DISABLED;
58462 }
58463
58464diff --git a/drivers/video/fbdev/aty/mach64_cursor.c b/drivers/video/fbdev/aty/mach64_cursor.c
58465index 2fa0317..4983f2a 100644
58466--- a/drivers/video/fbdev/aty/mach64_cursor.c
58467+++ b/drivers/video/fbdev/aty/mach64_cursor.c
58468@@ -8,6 +8,7 @@
58469 #include "../core/fb_draw.h"
58470
58471 #include <asm/io.h>
58472+#include <asm/pgtable.h>
58473
58474 #ifdef __sparc__
58475 #include <asm/fbio.h>
58476@@ -218,7 +219,9 @@ int aty_init_cursor(struct fb_info *info)
58477 info->sprite.buf_align = 16; /* and 64 lines tall. */
58478 info->sprite.flags = FB_PIXMAP_IO;
58479
58480- info->fbops->fb_cursor = atyfb_cursor;
58481+ pax_open_kernel();
58482+ *(void **)&info->fbops->fb_cursor = atyfb_cursor;
58483+ pax_close_kernel();
58484
58485 return 0;
58486 }
58487diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
58488index 3fc63c2..eec5e49 100644
58489--- a/drivers/video/fbdev/core/fb_defio.c
58490+++ b/drivers/video/fbdev/core/fb_defio.c
58491@@ -207,7 +207,9 @@ void fb_deferred_io_init(struct fb_info *info)
58492
58493 BUG_ON(!fbdefio);
58494 mutex_init(&fbdefio->lock);
58495- info->fbops->fb_mmap = fb_deferred_io_mmap;
58496+ pax_open_kernel();
58497+ *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
58498+ pax_close_kernel();
58499 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
58500 INIT_LIST_HEAD(&fbdefio->pagelist);
58501 if (fbdefio->delay == 0) /* set a default of 1 s */
58502@@ -238,7 +240,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
58503 page->mapping = NULL;
58504 }
58505
58506- info->fbops->fb_mmap = NULL;
58507+ *(void **)&info->fbops->fb_mmap = NULL;
58508 mutex_destroy(&fbdefio->lock);
58509 }
58510 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
58511diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
58512index 0705d88..d9429bf 100644
58513--- a/drivers/video/fbdev/core/fbmem.c
58514+++ b/drivers/video/fbdev/core/fbmem.c
58515@@ -1301,7 +1301,7 @@ static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix,
58516 __u32 data;
58517 int err;
58518
58519- err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id));
58520+ err = copy_to_user(fix32->id, &fix->id, sizeof(fix32->id));
58521
58522 data = (__u32) (unsigned long) fix->smem_start;
58523 err |= put_user(data, &fix32->smem_start);
58524diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c
58525index 807ee22..7814cd6 100644
58526--- a/drivers/video/fbdev/hyperv_fb.c
58527+++ b/drivers/video/fbdev/hyperv_fb.c
58528@@ -240,7 +240,7 @@ static uint screen_fb_size;
58529 static inline int synthvid_send(struct hv_device *hdev,
58530 struct synthvid_msg *msg)
58531 {
58532- static atomic64_t request_id = ATOMIC64_INIT(0);
58533+ static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
58534 int ret;
58535
58536 msg->pipe_hdr.type = PIPE_MSG_DATA;
58537@@ -248,7 +248,7 @@ static inline int synthvid_send(struct hv_device *hdev,
58538
58539 ret = vmbus_sendpacket(hdev->channel, msg,
58540 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
58541- atomic64_inc_return(&request_id),
58542+ atomic64_inc_return_unchecked(&request_id),
58543 VM_PKT_DATA_INBAND, 0);
58544
58545 if (ret)
58546diff --git a/drivers/video/fbdev/i810/i810_accel.c b/drivers/video/fbdev/i810/i810_accel.c
58547index 7672d2e..b56437f 100644
58548--- a/drivers/video/fbdev/i810/i810_accel.c
58549+++ b/drivers/video/fbdev/i810/i810_accel.c
58550@@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
58551 }
58552 }
58553 printk("ringbuffer lockup!!!\n");
58554+ printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
58555 i810_report_error(mmio);
58556 par->dev_flags |= LOCKUP;
58557 info->pixmap.scan_align = 1;
58558diff --git a/drivers/video/fbdev/matrox/matroxfb_DAC1064.c b/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
58559index a01147f..5d896f8 100644
58560--- a/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
58561+++ b/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
58562@@ -1088,14 +1088,20 @@ static void MGAG100_restore(struct matrox_fb_info *minfo)
58563
58564 #ifdef CONFIG_FB_MATROX_MYSTIQUE
58565 struct matrox_switch matrox_mystique = {
58566- MGA1064_preinit, MGA1064_reset, MGA1064_init, MGA1064_restore,
58567+ .preinit = MGA1064_preinit,
58568+ .reset = MGA1064_reset,
58569+ .init = MGA1064_init,
58570+ .restore = MGA1064_restore,
58571 };
58572 EXPORT_SYMBOL(matrox_mystique);
58573 #endif
58574
58575 #ifdef CONFIG_FB_MATROX_G
58576 struct matrox_switch matrox_G100 = {
58577- MGAG100_preinit, MGAG100_reset, MGAG100_init, MGAG100_restore,
58578+ .preinit = MGAG100_preinit,
58579+ .reset = MGAG100_reset,
58580+ .init = MGAG100_init,
58581+ .restore = MGAG100_restore,
58582 };
58583 EXPORT_SYMBOL(matrox_G100);
58584 #endif
58585diff --git a/drivers/video/fbdev/matrox/matroxfb_Ti3026.c b/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
58586index 195ad7c..09743fc 100644
58587--- a/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
58588+++ b/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
58589@@ -738,7 +738,10 @@ static int Ti3026_preinit(struct matrox_fb_info *minfo)
58590 }
58591
58592 struct matrox_switch matrox_millennium = {
58593- Ti3026_preinit, Ti3026_reset, Ti3026_init, Ti3026_restore
58594+ .preinit = Ti3026_preinit,
58595+ .reset = Ti3026_reset,
58596+ .init = Ti3026_init,
58597+ .restore = Ti3026_restore
58598 };
58599 EXPORT_SYMBOL(matrox_millennium);
58600 #endif
58601diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c b/drivers/video/fbdev/matrox/matroxfb_base.c
58602index 11eb094..622ee31 100644
58603--- a/drivers/video/fbdev/matrox/matroxfb_base.c
58604+++ b/drivers/video/fbdev/matrox/matroxfb_base.c
58605@@ -2176,7 +2176,7 @@ static struct pci_driver matroxfb_driver = {
58606 #define RS1056x480 14 /* 132 x 60 text */
58607 #define RSNoxNo 15
58608 /* 10-FF */
58609-static struct { int xres, yres, left, right, upper, lower, hslen, vslen, vfreq; } timmings[] __initdata = {
58610+static struct { unsigned int xres, yres, left, right, upper, lower, hslen, vslen, vfreq; } timmings[] __initdata = {
58611 { 640, 400, 48, 16, 39, 8, 96, 2, 70 },
58612 { 640, 480, 48, 16, 33, 10, 96, 2, 60 },
58613 { 800, 600, 144, 24, 28, 8, 112, 6, 60 },
58614diff --git a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
58615index fe92eed..106e085 100644
58616--- a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
58617+++ b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
58618@@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
58619 struct mb862xxfb_par *par = info->par;
58620
58621 if (info->var.bits_per_pixel == 32) {
58622- info->fbops->fb_fillrect = cfb_fillrect;
58623- info->fbops->fb_copyarea = cfb_copyarea;
58624- info->fbops->fb_imageblit = cfb_imageblit;
58625+ pax_open_kernel();
58626+ *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
58627+ *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
58628+ *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
58629+ pax_close_kernel();
58630 } else {
58631 outreg(disp, GC_L0EM, 3);
58632- info->fbops->fb_fillrect = mb86290fb_fillrect;
58633- info->fbops->fb_copyarea = mb86290fb_copyarea;
58634- info->fbops->fb_imageblit = mb86290fb_imageblit;
58635+ pax_open_kernel();
58636+ *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
58637+ *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
58638+ *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
58639+ pax_close_kernel();
58640 }
58641 outreg(draw, GDC_REG_DRAW_BASE, 0);
58642 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
58643diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c
58644index ce7dab7..a87baf8 100644
58645--- a/drivers/video/fbdev/nvidia/nvidia.c
58646+++ b/drivers/video/fbdev/nvidia/nvidia.c
58647@@ -660,19 +660,23 @@ static int nvidiafb_set_par(struct fb_info *info)
58648 info->fix.line_length = (info->var.xres_virtual *
58649 info->var.bits_per_pixel) >> 3;
58650 if (info->var.accel_flags) {
58651- info->fbops->fb_imageblit = nvidiafb_imageblit;
58652- info->fbops->fb_fillrect = nvidiafb_fillrect;
58653- info->fbops->fb_copyarea = nvidiafb_copyarea;
58654- info->fbops->fb_sync = nvidiafb_sync;
58655+ pax_open_kernel();
58656+ *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
58657+ *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
58658+ *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
58659+ *(void **)&info->fbops->fb_sync = nvidiafb_sync;
58660+ pax_close_kernel();
58661 info->pixmap.scan_align = 4;
58662 info->flags &= ~FBINFO_HWACCEL_DISABLED;
58663 info->flags |= FBINFO_READS_FAST;
58664 NVResetGraphics(info);
58665 } else {
58666- info->fbops->fb_imageblit = cfb_imageblit;
58667- info->fbops->fb_fillrect = cfb_fillrect;
58668- info->fbops->fb_copyarea = cfb_copyarea;
58669- info->fbops->fb_sync = NULL;
58670+ pax_open_kernel();
58671+ *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
58672+ *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
58673+ *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
58674+ *(void **)&info->fbops->fb_sync = NULL;
58675+ pax_close_kernel();
58676 info->pixmap.scan_align = 1;
58677 info->flags |= FBINFO_HWACCEL_DISABLED;
58678 info->flags &= ~FBINFO_READS_FAST;
58679@@ -1164,8 +1168,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
58680 info->pixmap.size = 8 * 1024;
58681 info->pixmap.flags = FB_PIXMAP_SYSTEM;
58682
58683- if (!hwcur)
58684- info->fbops->fb_cursor = NULL;
58685+ if (!hwcur) {
58686+ pax_open_kernel();
58687+ *(void **)&info->fbops->fb_cursor = NULL;
58688+ pax_close_kernel();
58689+ }
58690
58691 info->var.accel_flags = (!noaccel);
58692
58693diff --git a/drivers/video/fbdev/omap2/dss/display.c b/drivers/video/fbdev/omap2/dss/display.c
58694index ef5b902..47cf7f5 100644
58695--- a/drivers/video/fbdev/omap2/dss/display.c
58696+++ b/drivers/video/fbdev/omap2/dss/display.c
58697@@ -161,12 +161,14 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
58698 if (dssdev->name == NULL)
58699 dssdev->name = dssdev->alias;
58700
58701+ pax_open_kernel();
58702 if (drv && drv->get_resolution == NULL)
58703- drv->get_resolution = omapdss_default_get_resolution;
58704+ *(void **)&drv->get_resolution = omapdss_default_get_resolution;
58705 if (drv && drv->get_recommended_bpp == NULL)
58706- drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
58707+ *(void **)&drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
58708 if (drv && drv->get_timings == NULL)
58709- drv->get_timings = omapdss_default_get_timings;
58710+ *(void **)&drv->get_timings = omapdss_default_get_timings;
58711+ pax_close_kernel();
58712
58713 mutex_lock(&panel_list_mutex);
58714 list_add_tail(&dssdev->panel_list, &panel_list);
58715diff --git a/drivers/video/fbdev/s1d13xxxfb.c b/drivers/video/fbdev/s1d13xxxfb.c
58716index 83433cb..71e9b98 100644
58717--- a/drivers/video/fbdev/s1d13xxxfb.c
58718+++ b/drivers/video/fbdev/s1d13xxxfb.c
58719@@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
58720
58721 switch(prod_id) {
58722 case S1D13506_PROD_ID: /* activate acceleration */
58723- s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
58724- s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
58725+ pax_open_kernel();
58726+ *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
58727+ *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
58728+ pax_close_kernel();
58729 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
58730 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
58731 break;
58732diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
58733index 82c0a8c..42499a1 100644
58734--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
58735+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
58736@@ -439,9 +439,9 @@ static unsigned long lcdc_sys_read_data(void *handle)
58737 }
58738
58739 static struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = {
58740- lcdc_sys_write_index,
58741- lcdc_sys_write_data,
58742- lcdc_sys_read_data,
58743+ .write_index = lcdc_sys_write_index,
58744+ .write_data = lcdc_sys_write_data,
58745+ .read_data = lcdc_sys_read_data,
58746 };
58747
58748 static int sh_mobile_lcdc_sginit(struct fb_info *info,
58749diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
58750index 9279e5f..d5f5276 100644
58751--- a/drivers/video/fbdev/smscufx.c
58752+++ b/drivers/video/fbdev/smscufx.c
58753@@ -1174,7 +1174,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
58754 fb_deferred_io_cleanup(info);
58755 kfree(info->fbdefio);
58756 info->fbdefio = NULL;
58757- info->fbops->fb_mmap = ufx_ops_mmap;
58758+ pax_open_kernel();
58759+ *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
58760+ pax_close_kernel();
58761 }
58762
58763 pr_debug("released /dev/fb%d user=%d count=%d",
58764diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
58765index ff2b873..626a8d5 100644
58766--- a/drivers/video/fbdev/udlfb.c
58767+++ b/drivers/video/fbdev/udlfb.c
58768@@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
58769 dlfb_urb_completion(urb);
58770
58771 error:
58772- atomic_add(bytes_sent, &dev->bytes_sent);
58773- atomic_add(bytes_identical, &dev->bytes_identical);
58774- atomic_add(width*height*2, &dev->bytes_rendered);
58775+ atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
58776+ atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
58777+ atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
58778 end_cycles = get_cycles();
58779- atomic_add(((unsigned int) ((end_cycles - start_cycles)
58780+ atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
58781 >> 10)), /* Kcycles */
58782 &dev->cpu_kcycles_used);
58783
58784@@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
58785 dlfb_urb_completion(urb);
58786
58787 error:
58788- atomic_add(bytes_sent, &dev->bytes_sent);
58789- atomic_add(bytes_identical, &dev->bytes_identical);
58790- atomic_add(bytes_rendered, &dev->bytes_rendered);
58791+ atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
58792+ atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
58793+ atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
58794 end_cycles = get_cycles();
58795- atomic_add(((unsigned int) ((end_cycles - start_cycles)
58796+ atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
58797 >> 10)), /* Kcycles */
58798 &dev->cpu_kcycles_used);
58799 }
58800@@ -991,7 +991,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
58801 fb_deferred_io_cleanup(info);
58802 kfree(info->fbdefio);
58803 info->fbdefio = NULL;
58804- info->fbops->fb_mmap = dlfb_ops_mmap;
58805+ pax_open_kernel();
58806+ *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
58807+ pax_close_kernel();
58808 }
58809
58810 pr_warn("released /dev/fb%d user=%d count=%d\n",
58811@@ -1373,7 +1375,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
58812 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58813 struct dlfb_data *dev = fb_info->par;
58814 return snprintf(buf, PAGE_SIZE, "%u\n",
58815- atomic_read(&dev->bytes_rendered));
58816+ atomic_read_unchecked(&dev->bytes_rendered));
58817 }
58818
58819 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
58820@@ -1381,7 +1383,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
58821 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58822 struct dlfb_data *dev = fb_info->par;
58823 return snprintf(buf, PAGE_SIZE, "%u\n",
58824- atomic_read(&dev->bytes_identical));
58825+ atomic_read_unchecked(&dev->bytes_identical));
58826 }
58827
58828 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
58829@@ -1389,7 +1391,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
58830 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58831 struct dlfb_data *dev = fb_info->par;
58832 return snprintf(buf, PAGE_SIZE, "%u\n",
58833- atomic_read(&dev->bytes_sent));
58834+ atomic_read_unchecked(&dev->bytes_sent));
58835 }
58836
58837 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
58838@@ -1397,7 +1399,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
58839 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58840 struct dlfb_data *dev = fb_info->par;
58841 return snprintf(buf, PAGE_SIZE, "%u\n",
58842- atomic_read(&dev->cpu_kcycles_used));
58843+ atomic_read_unchecked(&dev->cpu_kcycles_used));
58844 }
58845
58846 static ssize_t edid_show(
58847@@ -1457,10 +1459,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
58848 struct fb_info *fb_info = dev_get_drvdata(fbdev);
58849 struct dlfb_data *dev = fb_info->par;
58850
58851- atomic_set(&dev->bytes_rendered, 0);
58852- atomic_set(&dev->bytes_identical, 0);
58853- atomic_set(&dev->bytes_sent, 0);
58854- atomic_set(&dev->cpu_kcycles_used, 0);
58855+ atomic_set_unchecked(&dev->bytes_rendered, 0);
58856+ atomic_set_unchecked(&dev->bytes_identical, 0);
58857+ atomic_set_unchecked(&dev->bytes_sent, 0);
58858+ atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
58859
58860 return count;
58861 }
58862diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
58863index 178ae93..624b2eb 100644
58864--- a/drivers/video/fbdev/uvesafb.c
58865+++ b/drivers/video/fbdev/uvesafb.c
58866@@ -19,6 +19,7 @@
58867 #include <linux/io.h>
58868 #include <linux/mutex.h>
58869 #include <linux/slab.h>
58870+#include <linux/moduleloader.h>
58871 #include <video/edid.h>
58872 #include <video/uvesafb.h>
58873 #ifdef CONFIG_X86
58874@@ -565,10 +566,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
58875 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
58876 par->pmi_setpal = par->ypan = 0;
58877 } else {
58878+
58879+#ifdef CONFIG_PAX_KERNEXEC
58880+#ifdef CONFIG_MODULES
58881+ par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
58882+#endif
58883+ if (!par->pmi_code) {
58884+ par->pmi_setpal = par->ypan = 0;
58885+ return 0;
58886+ }
58887+#endif
58888+
58889 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
58890 + task->t.regs.edi);
58891+
58892+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58893+ pax_open_kernel();
58894+ memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
58895+ pax_close_kernel();
58896+
58897+ par->pmi_start = (void *)ktva_ktla((unsigned long)(par->pmi_code + par->pmi_base[1]));
58898+ par->pmi_pal = (void *)ktva_ktla((unsigned long)(par->pmi_code + par->pmi_base[2]));
58899+#else
58900 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
58901 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
58902+#endif
58903+
58904 printk(KERN_INFO "uvesafb: protected mode interface info at "
58905 "%04x:%04x\n",
58906 (u16)task->t.regs.es, (u16)task->t.regs.edi);
58907@@ -813,13 +836,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
58908 par->ypan = ypan;
58909
58910 if (par->pmi_setpal || par->ypan) {
58911+#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
58912 if (__supported_pte_mask & _PAGE_NX) {
58913 par->pmi_setpal = par->ypan = 0;
58914 printk(KERN_WARNING "uvesafb: NX protection is active, "
58915 "better not use the PMI.\n");
58916- } else {
58917+ } else
58918+#endif
58919 uvesafb_vbe_getpmi(task, par);
58920- }
58921 }
58922 #else
58923 /* The protected mode interface is not available on non-x86. */
58924@@ -1452,8 +1476,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
58925 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
58926
58927 /* Disable blanking if the user requested so. */
58928- if (!blank)
58929- info->fbops->fb_blank = NULL;
58930+ if (!blank) {
58931+ pax_open_kernel();
58932+ *(void **)&info->fbops->fb_blank = NULL;
58933+ pax_close_kernel();
58934+ }
58935
58936 /*
58937 * Find out how much IO memory is required for the mode with
58938@@ -1524,8 +1551,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
58939 info->flags = FBINFO_FLAG_DEFAULT |
58940 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
58941
58942- if (!par->ypan)
58943- info->fbops->fb_pan_display = NULL;
58944+ if (!par->ypan) {
58945+ pax_open_kernel();
58946+ *(void **)&info->fbops->fb_pan_display = NULL;
58947+ pax_close_kernel();
58948+ }
58949 }
58950
58951 static void uvesafb_init_mtrr(struct fb_info *info)
58952@@ -1786,6 +1816,11 @@ out_mode:
58953 out:
58954 kfree(par->vbe_modes);
58955
58956+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58957+ if (par->pmi_code)
58958+ module_memfree_exec(par->pmi_code);
58959+#endif
58960+
58961 framebuffer_release(info);
58962 return err;
58963 }
58964@@ -1810,6 +1845,11 @@ static int uvesafb_remove(struct platform_device *dev)
58965 kfree(par->vbe_state_orig);
58966 kfree(par->vbe_state_saved);
58967
58968+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
58969+ if (par->pmi_code)
58970+ module_memfree_exec(par->pmi_code);
58971+#endif
58972+
58973 framebuffer_release(info);
58974 }
58975 return 0;
58976diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c
58977index 528fe91..6fd29fe 100644
58978--- a/drivers/video/fbdev/vesafb.c
58979+++ b/drivers/video/fbdev/vesafb.c
58980@@ -9,6 +9,7 @@
58981 */
58982
58983 #include <linux/module.h>
58984+#include <linux/moduleloader.h>
58985 #include <linux/kernel.h>
58986 #include <linux/errno.h>
58987 #include <linux/string.h>
58988@@ -56,8 +57,8 @@ static int vram_remap; /* Set amount of memory to be used */
58989 static int vram_total; /* Set total amount of memory */
58990 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
58991 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
58992-static void (*pmi_start)(void) __read_mostly;
58993-static void (*pmi_pal) (void) __read_mostly;
58994+static void (*pmi_start)(void) __read_only;
58995+static void (*pmi_pal) (void) __read_only;
58996 static int depth __read_mostly;
58997 static int vga_compat __read_mostly;
58998 /* --------------------------------------------------------------------- */
58999@@ -241,6 +242,7 @@ static int vesafb_probe(struct platform_device *dev)
59000 unsigned int size_remap;
59001 unsigned int size_total;
59002 char *option = NULL;
59003+ void *pmi_code = NULL;
59004
59005 /* ignore error return of fb_get_options */
59006 fb_get_options("vesafb", &option);
59007@@ -287,10 +289,6 @@ static int vesafb_probe(struct platform_device *dev)
59008 size_remap = size_total;
59009 vesafb_fix.smem_len = size_remap;
59010
59011-#ifndef __i386__
59012- screen_info.vesapm_seg = 0;
59013-#endif
59014-
59015 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
59016 printk(KERN_WARNING
59017 "vesafb: cannot reserve video memory at 0x%lx\n",
59018@@ -320,9 +318,21 @@ static int vesafb_probe(struct platform_device *dev)
59019 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
59020 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
59021
59022+#ifdef __i386__
59023+
59024+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
59025+ pmi_code = module_alloc_exec(screen_info.vesapm_size);
59026+ if (!pmi_code)
59027+#elif !defined(CONFIG_PAX_KERNEXEC)
59028+ if (0)
59029+#endif
59030+
59031+#endif
59032+ screen_info.vesapm_seg = 0;
59033+
59034 if (screen_info.vesapm_seg) {
59035- printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
59036- screen_info.vesapm_seg,screen_info.vesapm_off);
59037+ printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
59038+ screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
59039 }
59040
59041 if (screen_info.vesapm_seg < 0xc000)
59042@@ -330,9 +340,25 @@ static int vesafb_probe(struct platform_device *dev)
59043
59044 if (ypan || pmi_setpal) {
59045 unsigned short *pmi_base;
59046+
59047 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
59048- pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
59049- pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
59050+
59051+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
59052+ pax_open_kernel();
59053+ memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
59054+#else
59055+ pmi_code = pmi_base;
59056+#endif
59057+
59058+ pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
59059+ pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
59060+
59061+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
59062+ pmi_start = (void *)ktva_ktla((unsigned long)pmi_start);
59063+ pmi_pal = (void *)ktva_ktla((unsigned long)pmi_pal);
59064+ pax_close_kernel();
59065+#endif
59066+
59067 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
59068 if (pmi_base[3]) {
59069 printk(KERN_INFO "vesafb: pmi: ports = ");
59070@@ -452,8 +478,11 @@ static int vesafb_probe(struct platform_device *dev)
59071 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
59072 (ypan ? FBINFO_HWACCEL_YPAN : 0);
59073
59074- if (!ypan)
59075- info->fbops->fb_pan_display = NULL;
59076+ if (!ypan) {
59077+ pax_open_kernel();
59078+ *(void **)&info->fbops->fb_pan_display = NULL;
59079+ pax_close_kernel();
59080+ }
59081
59082 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
59083 err = -ENOMEM;
59084@@ -467,6 +496,11 @@ static int vesafb_probe(struct platform_device *dev)
59085 fb_info(info, "%s frame buffer device\n", info->fix.id);
59086 return 0;
59087 err:
59088+
59089+#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
59090+ module_memfree_exec(pmi_code);
59091+#endif
59092+
59093 arch_phys_wc_del(par->wc_cookie);
59094 if (info->screen_base)
59095 iounmap(info->screen_base);
59096diff --git a/drivers/video/fbdev/via/via_clock.h b/drivers/video/fbdev/via/via_clock.h
59097index 88714ae..16c2e11 100644
59098--- a/drivers/video/fbdev/via/via_clock.h
59099+++ b/drivers/video/fbdev/via/via_clock.h
59100@@ -56,7 +56,7 @@ struct via_clock {
59101
59102 void (*set_engine_pll_state)(u8 state);
59103 void (*set_engine_pll)(struct via_pll_config config);
59104-};
59105+} __no_const;
59106
59107
59108 static inline u32 get_pll_internal_frequency(u32 ref_freq,
59109diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
59110index 3c14e43..2630570 100644
59111--- a/drivers/video/logo/logo_linux_clut224.ppm
59112+++ b/drivers/video/logo/logo_linux_clut224.ppm
59113@@ -2,1603 +2,1123 @@ P3
59114 # Standard 224-color Linux logo
59115 80 80
59116 255
59117- 0 0 0 0 0 0 0 0 0 0 0 0
59118- 0 0 0 0 0 0 0 0 0 0 0 0
59119- 0 0 0 0 0 0 0 0 0 0 0 0
59120- 0 0 0 0 0 0 0 0 0 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- 6 6 6 6 6 6 10 10 10 10 10 10
59127- 10 10 10 6 6 6 6 6 6 6 6 6
59128- 0 0 0 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 0 0 0
59134- 0 0 0 0 0 0 0 0 0 0 0 0
59135- 0 0 0 0 0 0 0 0 0 0 0 0
59136- 0 0 0 0 0 0 0 0 0 0 0 0
59137- 0 0 0 0 0 0 0 0 0 0 0 0
59138- 0 0 0 0 0 0 0 0 0 0 0 0
59139- 0 0 0 0 0 0 0 0 0 0 0 0
59140- 0 0 0 0 0 0 0 0 0 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 6 6 6 10 10 10 14 14 14
59146- 22 22 22 26 26 26 30 30 30 34 34 34
59147- 30 30 30 30 30 30 26 26 26 18 18 18
59148- 14 14 14 10 10 10 6 6 6 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 0 0 0
59154- 0 0 0 0 0 0 0 0 0 0 0 0
59155- 0 0 0 0 0 0 0 0 0 0 0 0
59156- 0 0 0 0 0 0 0 0 0 0 0 0
59157- 0 0 0 0 0 0 0 0 0 0 0 0
59158- 0 0 0 0 0 1 0 0 1 0 0 0
59159- 0 0 0 0 0 0 0 0 0 0 0 0
59160- 0 0 0 0 0 0 0 0 0 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- 6 6 6 14 14 14 26 26 26 42 42 42
59166- 54 54 54 66 66 66 78 78 78 78 78 78
59167- 78 78 78 74 74 74 66 66 66 54 54 54
59168- 42 42 42 26 26 26 18 18 18 10 10 10
59169- 6 6 6 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 0 0 0
59174- 0 0 0 0 0 0 0 0 0 0 0 0
59175- 0 0 0 0 0 0 0 0 0 0 0 0
59176- 0 0 0 0 0 0 0 0 0 0 0 0
59177- 0 0 0 0 0 0 0 0 0 0 0 0
59178- 0 0 1 0 0 0 0 0 0 0 0 0
59179- 0 0 0 0 0 0 0 0 0 0 0 0
59180- 0 0 0 0 0 0 0 0 0 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 10 10 10
59185- 22 22 22 42 42 42 66 66 66 86 86 86
59186- 66 66 66 38 38 38 38 38 38 22 22 22
59187- 26 26 26 34 34 34 54 54 54 66 66 66
59188- 86 86 86 70 70 70 46 46 46 26 26 26
59189- 14 14 14 6 6 6 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 0 0 0
59194- 0 0 0 0 0 0 0 0 0 0 0 0
59195- 0 0 0 0 0 0 0 0 0 0 0 0
59196- 0 0 0 0 0 0 0 0 0 0 0 0
59197- 0 0 0 0 0 0 0 0 0 0 0 0
59198- 0 0 1 0 0 1 0 0 1 0 0 0
59199- 0 0 0 0 0 0 0 0 0 0 0 0
59200- 0 0 0 0 0 0 0 0 0 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 10 10 10 26 26 26
59205- 50 50 50 82 82 82 58 58 58 6 6 6
59206- 2 2 6 2 2 6 2 2 6 2 2 6
59207- 2 2 6 2 2 6 2 2 6 2 2 6
59208- 6 6 6 54 54 54 86 86 86 66 66 66
59209- 38 38 38 18 18 18 6 6 6 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 0 0 0
59214- 0 0 0 0 0 0 0 0 0 0 0 0
59215- 0 0 0 0 0 0 0 0 0 0 0 0
59216- 0 0 0 0 0 0 0 0 0 0 0 0
59217- 0 0 0 0 0 0 0 0 0 0 0 0
59218- 0 0 0 0 0 0 0 0 0 0 0 0
59219- 0 0 0 0 0 0 0 0 0 0 0 0
59220- 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6 22 22 22 50 50 50
59225- 78 78 78 34 34 34 2 2 6 2 2 6
59226- 2 2 6 2 2 6 2 2 6 2 2 6
59227- 2 2 6 2 2 6 2 2 6 2 2 6
59228- 2 2 6 2 2 6 6 6 6 70 70 70
59229- 78 78 78 46 46 46 22 22 22 6 6 6
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 0 0 0
59234- 0 0 0 0 0 0 0 0 0 0 0 0
59235- 0 0 0 0 0 0 0 0 0 0 0 0
59236- 0 0 0 0 0 0 0 0 0 0 0 0
59237- 0 0 0 0 0 0 0 0 0 0 0 0
59238- 0 0 1 0 0 1 0 0 1 0 0 0
59239- 0 0 0 0 0 0 0 0 0 0 0 0
59240- 0 0 0 0 0 0 0 0 0 0 0 0
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- 6 6 6 18 18 18 42 42 42 82 82 82
59245- 26 26 26 2 2 6 2 2 6 2 2 6
59246- 2 2 6 2 2 6 2 2 6 2 2 6
59247- 2 2 6 2 2 6 2 2 6 14 14 14
59248- 46 46 46 34 34 34 6 6 6 2 2 6
59249- 42 42 42 78 78 78 42 42 42 18 18 18
59250- 6 6 6 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 0 0 0
59254- 0 0 0 0 0 0 0 0 0 0 0 0
59255- 0 0 0 0 0 0 0 0 0 0 0 0
59256- 0 0 0 0 0 0 0 0 0 0 0 0
59257- 0 0 0 0 0 0 0 0 0 0 0 0
59258- 0 0 1 0 0 0 0 0 1 0 0 0
59259- 0 0 0 0 0 0 0 0 0 0 0 0
59260- 0 0 0 0 0 0 0 0 0 0 0 0
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- 10 10 10 30 30 30 66 66 66 58 58 58
59265- 2 2 6 2 2 6 2 2 6 2 2 6
59266- 2 2 6 2 2 6 2 2 6 2 2 6
59267- 2 2 6 2 2 6 2 2 6 26 26 26
59268- 86 86 86 101 101 101 46 46 46 10 10 10
59269- 2 2 6 58 58 58 70 70 70 34 34 34
59270- 10 10 10 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 0 0 0
59274- 0 0 0 0 0 0 0 0 0 0 0 0
59275- 0 0 0 0 0 0 0 0 0 0 0 0
59276- 0 0 0 0 0 0 0 0 0 0 0 0
59277- 0 0 0 0 0 0 0 0 0 0 0 0
59278- 0 0 1 0 0 1 0 0 1 0 0 0
59279- 0 0 0 0 0 0 0 0 0 0 0 0
59280- 0 0 0 0 0 0 0 0 0 0 0 0
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- 14 14 14 42 42 42 86 86 86 10 10 10
59285- 2 2 6 2 2 6 2 2 6 2 2 6
59286- 2 2 6 2 2 6 2 2 6 2 2 6
59287- 2 2 6 2 2 6 2 2 6 30 30 30
59288- 94 94 94 94 94 94 58 58 58 26 26 26
59289- 2 2 6 6 6 6 78 78 78 54 54 54
59290- 22 22 22 6 6 6 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 0 0 0
59294- 0 0 0 0 0 0 0 0 0 0 0 0
59295- 0 0 0 0 0 0 0 0 0 0 0 0
59296- 0 0 0 0 0 0 0 0 0 0 0 0
59297- 0 0 0 0 0 0 0 0 0 0 0 0
59298- 0 0 0 0 0 0 0 0 0 0 0 0
59299- 0 0 0 0 0 0 0 0 0 0 0 0
59300- 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6
59304- 22 22 22 62 62 62 62 62 62 2 2 6
59305- 2 2 6 2 2 6 2 2 6 2 2 6
59306- 2 2 6 2 2 6 2 2 6 2 2 6
59307- 2 2 6 2 2 6 2 2 6 26 26 26
59308- 54 54 54 38 38 38 18 18 18 10 10 10
59309- 2 2 6 2 2 6 34 34 34 82 82 82
59310- 38 38 38 14 14 14 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 0 0 0
59314- 0 0 0 0 0 0 0 0 0 0 0 0
59315- 0 0 0 0 0 0 0 0 0 0 0 0
59316- 0 0 0 0 0 0 0 0 0 0 0 0
59317- 0 0 0 0 0 0 0 0 0 0 0 0
59318- 0 0 0 0 0 1 0 0 1 0 0 0
59319- 0 0 0 0 0 0 0 0 0 0 0 0
59320- 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6
59324- 30 30 30 78 78 78 30 30 30 2 2 6
59325- 2 2 6 2 2 6 2 2 6 2 2 6
59326- 2 2 6 2 2 6 2 2 6 2 2 6
59327- 2 2 6 2 2 6 2 2 6 10 10 10
59328- 10 10 10 2 2 6 2 2 6 2 2 6
59329- 2 2 6 2 2 6 2 2 6 78 78 78
59330- 50 50 50 18 18 18 6 6 6 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 0 0 0
59334- 0 0 0 0 0 0 0 0 0 0 0 0
59335- 0 0 0 0 0 0 0 0 0 0 0 0
59336- 0 0 0 0 0 0 0 0 0 0 0 0
59337- 0 0 0 0 0 0 0 0 0 0 0 0
59338- 0 0 1 0 0 0 0 0 0 0 0 0
59339- 0 0 0 0 0 0 0 0 0 0 0 0
59340- 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
59344- 38 38 38 86 86 86 14 14 14 2 2 6
59345- 2 2 6 2 2 6 2 2 6 2 2 6
59346- 2 2 6 2 2 6 2 2 6 2 2 6
59347- 2 2 6 2 2 6 2 2 6 2 2 6
59348- 2 2 6 2 2 6 2 2 6 2 2 6
59349- 2 2 6 2 2 6 2 2 6 54 54 54
59350- 66 66 66 26 26 26 6 6 6 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 0 0 0
59354- 0 0 0 0 0 0 0 0 0 0 0 0
59355- 0 0 0 0 0 0 0 0 0 0 0 0
59356- 0 0 0 0 0 0 0 0 0 0 0 0
59357- 0 0 0 0 0 0 0 0 0 0 0 0
59358- 0 0 0 0 0 1 0 0 1 0 0 0
59359- 0 0 0 0 0 0 0 0 0 0 0 0
59360- 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
59364- 42 42 42 82 82 82 2 2 6 2 2 6
59365- 2 2 6 6 6 6 10 10 10 2 2 6
59366- 2 2 6 2 2 6 2 2 6 2 2 6
59367- 2 2 6 2 2 6 2 2 6 6 6 6
59368- 14 14 14 10 10 10 2 2 6 2 2 6
59369- 2 2 6 2 2 6 2 2 6 18 18 18
59370- 82 82 82 34 34 34 10 10 10 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 0 0 0
59374- 0 0 0 0 0 0 0 0 0 0 0 0
59375- 0 0 0 0 0 0 0 0 0 0 0 0
59376- 0 0 0 0 0 0 0 0 0 0 0 0
59377- 0 0 0 0 0 0 0 0 0 0 0 0
59378- 0 0 1 0 0 0 0 0 0 0 0 0
59379- 0 0 0 0 0 0 0 0 0 0 0 0
59380- 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
59384- 46 46 46 86 86 86 2 2 6 2 2 6
59385- 6 6 6 6 6 6 22 22 22 34 34 34
59386- 6 6 6 2 2 6 2 2 6 2 2 6
59387- 2 2 6 2 2 6 18 18 18 34 34 34
59388- 10 10 10 50 50 50 22 22 22 2 2 6
59389- 2 2 6 2 2 6 2 2 6 10 10 10
59390- 86 86 86 42 42 42 14 14 14 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 0 0 0
59394- 0 0 0 0 0 0 0 0 0 0 0 0
59395- 0 0 0 0 0 0 0 0 0 0 0 0
59396- 0 0 0 0 0 0 0 0 0 0 0 0
59397- 0 0 0 0 0 0 0 0 0 0 0 0
59398- 0 0 1 0 0 1 0 0 1 0 0 0
59399- 0 0 0 0 0 0 0 0 0 0 0 0
59400- 0 0 0 0 0 0 0 0 0 0 0 0
59401- 0 0 0 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 14 14 14
59404- 46 46 46 86 86 86 2 2 6 2 2 6
59405- 38 38 38 116 116 116 94 94 94 22 22 22
59406- 22 22 22 2 2 6 2 2 6 2 2 6
59407- 14 14 14 86 86 86 138 138 138 162 162 162
59408-154 154 154 38 38 38 26 26 26 6 6 6
59409- 2 2 6 2 2 6 2 2 6 2 2 6
59410- 86 86 86 46 46 46 14 14 14 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 0 0 0
59414- 0 0 0 0 0 0 0 0 0 0 0 0
59415- 0 0 0 0 0 0 0 0 0 0 0 0
59416- 0 0 0 0 0 0 0 0 0 0 0 0
59417- 0 0 0 0 0 0 0 0 0 0 0 0
59418- 0 0 0 0 0 0 0 0 0 0 0 0
59419- 0 0 0 0 0 0 0 0 0 0 0 0
59420- 0 0 0 0 0 0 0 0 0 0 0 0
59421- 0 0 0 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 14 14 14
59424- 46 46 46 86 86 86 2 2 6 14 14 14
59425-134 134 134 198 198 198 195 195 195 116 116 116
59426- 10 10 10 2 2 6 2 2 6 6 6 6
59427-101 98 89 187 187 187 210 210 210 218 218 218
59428-214 214 214 134 134 134 14 14 14 6 6 6
59429- 2 2 6 2 2 6 2 2 6 2 2 6
59430- 86 86 86 50 50 50 18 18 18 6 6 6
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 0 0 0
59434- 0 0 0 0 0 0 0 0 0 0 0 0
59435- 0 0 0 0 0 0 0 0 0 0 0 0
59436- 0 0 0 0 0 0 0 0 0 0 0 0
59437- 0 0 0 0 0 0 0 0 1 0 0 0
59438- 0 0 1 0 0 1 0 0 1 0 0 0
59439- 0 0 0 0 0 0 0 0 0 0 0 0
59440- 0 0 0 0 0 0 0 0 0 0 0 0
59441- 0 0 0 0 0 0 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 14 14 14
59444- 46 46 46 86 86 86 2 2 6 54 54 54
59445-218 218 218 195 195 195 226 226 226 246 246 246
59446- 58 58 58 2 2 6 2 2 6 30 30 30
59447-210 210 210 253 253 253 174 174 174 123 123 123
59448-221 221 221 234 234 234 74 74 74 2 2 6
59449- 2 2 6 2 2 6 2 2 6 2 2 6
59450- 70 70 70 58 58 58 22 22 22 6 6 6
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 0 0 0
59454- 0 0 0 0 0 0 0 0 0 0 0 0
59455- 0 0 0 0 0 0 0 0 0 0 0 0
59456- 0 0 0 0 0 0 0 0 0 0 0 0
59457- 0 0 0 0 0 0 0 0 0 0 0 0
59458- 0 0 0 0 0 0 0 0 0 0 0 0
59459- 0 0 0 0 0 0 0 0 0 0 0 0
59460- 0 0 0 0 0 0 0 0 0 0 0 0
59461- 0 0 0 0 0 0 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 14 14 14
59464- 46 46 46 82 82 82 2 2 6 106 106 106
59465-170 170 170 26 26 26 86 86 86 226 226 226
59466-123 123 123 10 10 10 14 14 14 46 46 46
59467-231 231 231 190 190 190 6 6 6 70 70 70
59468- 90 90 90 238 238 238 158 158 158 2 2 6
59469- 2 2 6 2 2 6 2 2 6 2 2 6
59470- 70 70 70 58 58 58 22 22 22 6 6 6
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 0 0 0 0 0 0
59474- 0 0 0 0 0 0 0 0 0 0 0 0
59475- 0 0 0 0 0 0 0 0 0 0 0 0
59476- 0 0 0 0 0 0 0 0 0 0 0 0
59477- 0 0 0 0 0 0 0 0 1 0 0 0
59478- 0 0 1 0 0 1 0 0 1 0 0 0
59479- 0 0 0 0 0 0 0 0 0 0 0 0
59480- 0 0 0 0 0 0 0 0 0 0 0 0
59481- 0 0 0 0 0 0 0 0 0 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 14 14 14
59484- 42 42 42 86 86 86 6 6 6 116 116 116
59485-106 106 106 6 6 6 70 70 70 149 149 149
59486-128 128 128 18 18 18 38 38 38 54 54 54
59487-221 221 221 106 106 106 2 2 6 14 14 14
59488- 46 46 46 190 190 190 198 198 198 2 2 6
59489- 2 2 6 2 2 6 2 2 6 2 2 6
59490- 74 74 74 62 62 62 22 22 22 6 6 6
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 0 0 0 0 0 0
59494- 0 0 0 0 0 0 0 0 0 0 0 0
59495- 0 0 0 0 0 0 0 0 0 0 0 0
59496- 0 0 0 0 0 0 0 0 0 0 0 0
59497- 0 0 0 0 0 0 0 0 1 0 0 0
59498- 0 0 1 0 0 0 0 0 1 0 0 0
59499- 0 0 0 0 0 0 0 0 0 0 0 0
59500- 0 0 0 0 0 0 0 0 0 0 0 0
59501- 0 0 0 0 0 0 0 0 0 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 14 14 14
59504- 42 42 42 94 94 94 14 14 14 101 101 101
59505-128 128 128 2 2 6 18 18 18 116 116 116
59506-118 98 46 121 92 8 121 92 8 98 78 10
59507-162 162 162 106 106 106 2 2 6 2 2 6
59508- 2 2 6 195 195 195 195 195 195 6 6 6
59509- 2 2 6 2 2 6 2 2 6 2 2 6
59510- 74 74 74 62 62 62 22 22 22 6 6 6
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 0 0 0 0 0 0 0 0 0
59514- 0 0 0 0 0 0 0 0 0 0 0 0
59515- 0 0 0 0 0 0 0 0 0 0 0 0
59516- 0 0 0 0 0 0 0 0 0 0 0 0
59517- 0 0 0 0 0 0 0 0 1 0 0 1
59518- 0 0 1 0 0 0 0 0 1 0 0 0
59519- 0 0 0 0 0 0 0 0 0 0 0 0
59520- 0 0 0 0 0 0 0 0 0 0 0 0
59521- 0 0 0 0 0 0 0 0 0 0 0 0
59522- 0 0 0 0 0 0 0 0 0 0 0 0
59523- 0 0 0 0 0 0 0 0 0 10 10 10
59524- 38 38 38 90 90 90 14 14 14 58 58 58
59525-210 210 210 26 26 26 54 38 6 154 114 10
59526-226 170 11 236 186 11 225 175 15 184 144 12
59527-215 174 15 175 146 61 37 26 9 2 2 6
59528- 70 70 70 246 246 246 138 138 138 2 2 6
59529- 2 2 6 2 2 6 2 2 6 2 2 6
59530- 70 70 70 66 66 66 26 26 26 6 6 6
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- 0 0 0 0 0 0 0 0 0 0 0 0
59534- 0 0 0 0 0 0 0 0 0 0 0 0
59535- 0 0 0 0 0 0 0 0 0 0 0 0
59536- 0 0 0 0 0 0 0 0 0 0 0 0
59537- 0 0 0 0 0 0 0 0 0 0 0 0
59538- 0 0 0 0 0 0 0 0 0 0 0 0
59539- 0 0 0 0 0 0 0 0 0 0 0 0
59540- 0 0 0 0 0 0 0 0 0 0 0 0
59541- 0 0 0 0 0 0 0 0 0 0 0 0
59542- 0 0 0 0 0 0 0 0 0 0 0 0
59543- 0 0 0 0 0 0 0 0 0 10 10 10
59544- 38 38 38 86 86 86 14 14 14 10 10 10
59545-195 195 195 188 164 115 192 133 9 225 175 15
59546-239 182 13 234 190 10 232 195 16 232 200 30
59547-245 207 45 241 208 19 232 195 16 184 144 12
59548-218 194 134 211 206 186 42 42 42 2 2 6
59549- 2 2 6 2 2 6 2 2 6 2 2 6
59550- 50 50 50 74 74 74 30 30 30 6 6 6
59551- 0 0 0 0 0 0 0 0 0 0 0 0
59552- 0 0 0 0 0 0 0 0 0 0 0 0
59553- 0 0 0 0 0 0 0 0 0 0 0 0
59554- 0 0 0 0 0 0 0 0 0 0 0 0
59555- 0 0 0 0 0 0 0 0 0 0 0 0
59556- 0 0 0 0 0 0 0 0 0 0 0 0
59557- 0 0 0 0 0 0 0 0 0 0 0 0
59558- 0 0 0 0 0 0 0 0 0 0 0 0
59559- 0 0 0 0 0 0 0 0 0 0 0 0
59560- 0 0 0 0 0 0 0 0 0 0 0 0
59561- 0 0 0 0 0 0 0 0 0 0 0 0
59562- 0 0 0 0 0 0 0 0 0 0 0 0
59563- 0 0 0 0 0 0 0 0 0 10 10 10
59564- 34 34 34 86 86 86 14 14 14 2 2 6
59565-121 87 25 192 133 9 219 162 10 239 182 13
59566-236 186 11 232 195 16 241 208 19 244 214 54
59567-246 218 60 246 218 38 246 215 20 241 208 19
59568-241 208 19 226 184 13 121 87 25 2 2 6
59569- 2 2 6 2 2 6 2 2 6 2 2 6
59570- 50 50 50 82 82 82 34 34 34 10 10 10
59571- 0 0 0 0 0 0 0 0 0 0 0 0
59572- 0 0 0 0 0 0 0 0 0 0 0 0
59573- 0 0 0 0 0 0 0 0 0 0 0 0
59574- 0 0 0 0 0 0 0 0 0 0 0 0
59575- 0 0 0 0 0 0 0 0 0 0 0 0
59576- 0 0 0 0 0 0 0 0 0 0 0 0
59577- 0 0 0 0 0 0 0 0 0 0 0 0
59578- 0 0 0 0 0 0 0 0 0 0 0 0
59579- 0 0 0 0 0 0 0 0 0 0 0 0
59580- 0 0 0 0 0 0 0 0 0 0 0 0
59581- 0 0 0 0 0 0 0 0 0 0 0 0
59582- 0 0 0 0 0 0 0 0 0 0 0 0
59583- 0 0 0 0 0 0 0 0 0 10 10 10
59584- 34 34 34 82 82 82 30 30 30 61 42 6
59585-180 123 7 206 145 10 230 174 11 239 182 13
59586-234 190 10 238 202 15 241 208 19 246 218 74
59587-246 218 38 246 215 20 246 215 20 246 215 20
59588-226 184 13 215 174 15 184 144 12 6 6 6
59589- 2 2 6 2 2 6 2 2 6 2 2 6
59590- 26 26 26 94 94 94 42 42 42 14 14 14
59591- 0 0 0 0 0 0 0 0 0 0 0 0
59592- 0 0 0 0 0 0 0 0 0 0 0 0
59593- 0 0 0 0 0 0 0 0 0 0 0 0
59594- 0 0 0 0 0 0 0 0 0 0 0 0
59595- 0 0 0 0 0 0 0 0 0 0 0 0
59596- 0 0 0 0 0 0 0 0 0 0 0 0
59597- 0 0 0 0 0 0 0 0 0 0 0 0
59598- 0 0 0 0 0 0 0 0 0 0 0 0
59599- 0 0 0 0 0 0 0 0 0 0 0 0
59600- 0 0 0 0 0 0 0 0 0 0 0 0
59601- 0 0 0 0 0 0 0 0 0 0 0 0
59602- 0 0 0 0 0 0 0 0 0 0 0 0
59603- 0 0 0 0 0 0 0 0 0 10 10 10
59604- 30 30 30 78 78 78 50 50 50 104 69 6
59605-192 133 9 216 158 10 236 178 12 236 186 11
59606-232 195 16 241 208 19 244 214 54 245 215 43
59607-246 215 20 246 215 20 241 208 19 198 155 10
59608-200 144 11 216 158 10 156 118 10 2 2 6
59609- 2 2 6 2 2 6 2 2 6 2 2 6
59610- 6 6 6 90 90 90 54 54 54 18 18 18
59611- 6 6 6 0 0 0 0 0 0 0 0 0
59612- 0 0 0 0 0 0 0 0 0 0 0 0
59613- 0 0 0 0 0 0 0 0 0 0 0 0
59614- 0 0 0 0 0 0 0 0 0 0 0 0
59615- 0 0 0 0 0 0 0 0 0 0 0 0
59616- 0 0 0 0 0 0 0 0 0 0 0 0
59617- 0 0 0 0 0 0 0 0 0 0 0 0
59618- 0 0 0 0 0 0 0 0 0 0 0 0
59619- 0 0 0 0 0 0 0 0 0 0 0 0
59620- 0 0 0 0 0 0 0 0 0 0 0 0
59621- 0 0 0 0 0 0 0 0 0 0 0 0
59622- 0 0 0 0 0 0 0 0 0 0 0 0
59623- 0 0 0 0 0 0 0 0 0 10 10 10
59624- 30 30 30 78 78 78 46 46 46 22 22 22
59625-137 92 6 210 162 10 239 182 13 238 190 10
59626-238 202 15 241 208 19 246 215 20 246 215 20
59627-241 208 19 203 166 17 185 133 11 210 150 10
59628-216 158 10 210 150 10 102 78 10 2 2 6
59629- 6 6 6 54 54 54 14 14 14 2 2 6
59630- 2 2 6 62 62 62 74 74 74 30 30 30
59631- 10 10 10 0 0 0 0 0 0 0 0 0
59632- 0 0 0 0 0 0 0 0 0 0 0 0
59633- 0 0 0 0 0 0 0 0 0 0 0 0
59634- 0 0 0 0 0 0 0 0 0 0 0 0
59635- 0 0 0 0 0 0 0 0 0 0 0 0
59636- 0 0 0 0 0 0 0 0 0 0 0 0
59637- 0 0 0 0 0 0 0 0 0 0 0 0
59638- 0 0 0 0 0 0 0 0 0 0 0 0
59639- 0 0 0 0 0 0 0 0 0 0 0 0
59640- 0 0 0 0 0 0 0 0 0 0 0 0
59641- 0 0 0 0 0 0 0 0 0 0 0 0
59642- 0 0 0 0 0 0 0 0 0 0 0 0
59643- 0 0 0 0 0 0 0 0 0 10 10 10
59644- 34 34 34 78 78 78 50 50 50 6 6 6
59645- 94 70 30 139 102 15 190 146 13 226 184 13
59646-232 200 30 232 195 16 215 174 15 190 146 13
59647-168 122 10 192 133 9 210 150 10 213 154 11
59648-202 150 34 182 157 106 101 98 89 2 2 6
59649- 2 2 6 78 78 78 116 116 116 58 58 58
59650- 2 2 6 22 22 22 90 90 90 46 46 46
59651- 18 18 18 6 6 6 0 0 0 0 0 0
59652- 0 0 0 0 0 0 0 0 0 0 0 0
59653- 0 0 0 0 0 0 0 0 0 0 0 0
59654- 0 0 0 0 0 0 0 0 0 0 0 0
59655- 0 0 0 0 0 0 0 0 0 0 0 0
59656- 0 0 0 0 0 0 0 0 0 0 0 0
59657- 0 0 0 0 0 0 0 0 0 0 0 0
59658- 0 0 0 0 0 0 0 0 0 0 0 0
59659- 0 0 0 0 0 0 0 0 0 0 0 0
59660- 0 0 0 0 0 0 0 0 0 0 0 0
59661- 0 0 0 0 0 0 0 0 0 0 0 0
59662- 0 0 0 0 0 0 0 0 0 0 0 0
59663- 0 0 0 0 0 0 0 0 0 10 10 10
59664- 38 38 38 86 86 86 50 50 50 6 6 6
59665-128 128 128 174 154 114 156 107 11 168 122 10
59666-198 155 10 184 144 12 197 138 11 200 144 11
59667-206 145 10 206 145 10 197 138 11 188 164 115
59668-195 195 195 198 198 198 174 174 174 14 14 14
59669- 2 2 6 22 22 22 116 116 116 116 116 116
59670- 22 22 22 2 2 6 74 74 74 70 70 70
59671- 30 30 30 10 10 10 0 0 0 0 0 0
59672- 0 0 0 0 0 0 0 0 0 0 0 0
59673- 0 0 0 0 0 0 0 0 0 0 0 0
59674- 0 0 0 0 0 0 0 0 0 0 0 0
59675- 0 0 0 0 0 0 0 0 0 0 0 0
59676- 0 0 0 0 0 0 0 0 0 0 0 0
59677- 0 0 0 0 0 0 0 0 0 0 0 0
59678- 0 0 0 0 0 0 0 0 0 0 0 0
59679- 0 0 0 0 0 0 0 0 0 0 0 0
59680- 0 0 0 0 0 0 0 0 0 0 0 0
59681- 0 0 0 0 0 0 0 0 0 0 0 0
59682- 0 0 0 0 0 0 0 0 0 0 0 0
59683- 0 0 0 0 0 0 6 6 6 18 18 18
59684- 50 50 50 101 101 101 26 26 26 10 10 10
59685-138 138 138 190 190 190 174 154 114 156 107 11
59686-197 138 11 200 144 11 197 138 11 192 133 9
59687-180 123 7 190 142 34 190 178 144 187 187 187
59688-202 202 202 221 221 221 214 214 214 66 66 66
59689- 2 2 6 2 2 6 50 50 50 62 62 62
59690- 6 6 6 2 2 6 10 10 10 90 90 90
59691- 50 50 50 18 18 18 6 6 6 0 0 0
59692- 0 0 0 0 0 0 0 0 0 0 0 0
59693- 0 0 0 0 0 0 0 0 0 0 0 0
59694- 0 0 0 0 0 0 0 0 0 0 0 0
59695- 0 0 0 0 0 0 0 0 0 0 0 0
59696- 0 0 0 0 0 0 0 0 0 0 0 0
59697- 0 0 0 0 0 0 0 0 0 0 0 0
59698- 0 0 0 0 0 0 0 0 0 0 0 0
59699- 0 0 0 0 0 0 0 0 0 0 0 0
59700- 0 0 0 0 0 0 0 0 0 0 0 0
59701- 0 0 0 0 0 0 0 0 0 0 0 0
59702- 0 0 0 0 0 0 0 0 0 0 0 0
59703- 0 0 0 0 0 0 10 10 10 34 34 34
59704- 74 74 74 74 74 74 2 2 6 6 6 6
59705-144 144 144 198 198 198 190 190 190 178 166 146
59706-154 121 60 156 107 11 156 107 11 168 124 44
59707-174 154 114 187 187 187 190 190 190 210 210 210
59708-246 246 246 253 253 253 253 253 253 182 182 182
59709- 6 6 6 2 2 6 2 2 6 2 2 6
59710- 2 2 6 2 2 6 2 2 6 62 62 62
59711- 74 74 74 34 34 34 14 14 14 0 0 0
59712- 0 0 0 0 0 0 0 0 0 0 0 0
59713- 0 0 0 0 0 0 0 0 0 0 0 0
59714- 0 0 0 0 0 0 0 0 0 0 0 0
59715- 0 0 0 0 0 0 0 0 0 0 0 0
59716- 0 0 0 0 0 0 0 0 0 0 0 0
59717- 0 0 0 0 0 0 0 0 0 0 0 0
59718- 0 0 0 0 0 0 0 0 0 0 0 0
59719- 0 0 0 0 0 0 0 0 0 0 0 0
59720- 0 0 0 0 0 0 0 0 0 0 0 0
59721- 0 0 0 0 0 0 0 0 0 0 0 0
59722- 0 0 0 0 0 0 0 0 0 0 0 0
59723- 0 0 0 10 10 10 22 22 22 54 54 54
59724- 94 94 94 18 18 18 2 2 6 46 46 46
59725-234 234 234 221 221 221 190 190 190 190 190 190
59726-190 190 190 187 187 187 187 187 187 190 190 190
59727-190 190 190 195 195 195 214 214 214 242 242 242
59728-253 253 253 253 253 253 253 253 253 253 253 253
59729- 82 82 82 2 2 6 2 2 6 2 2 6
59730- 2 2 6 2 2 6 2 2 6 14 14 14
59731- 86 86 86 54 54 54 22 22 22 6 6 6
59732- 0 0 0 0 0 0 0 0 0 0 0 0
59733- 0 0 0 0 0 0 0 0 0 0 0 0
59734- 0 0 0 0 0 0 0 0 0 0 0 0
59735- 0 0 0 0 0 0 0 0 0 0 0 0
59736- 0 0 0 0 0 0 0 0 0 0 0 0
59737- 0 0 0 0 0 0 0 0 0 0 0 0
59738- 0 0 0 0 0 0 0 0 0 0 0 0
59739- 0 0 0 0 0 0 0 0 0 0 0 0
59740- 0 0 0 0 0 0 0 0 0 0 0 0
59741- 0 0 0 0 0 0 0 0 0 0 0 0
59742- 0 0 0 0 0 0 0 0 0 0 0 0
59743- 6 6 6 18 18 18 46 46 46 90 90 90
59744- 46 46 46 18 18 18 6 6 6 182 182 182
59745-253 253 253 246 246 246 206 206 206 190 190 190
59746-190 190 190 190 190 190 190 190 190 190 190 190
59747-206 206 206 231 231 231 250 250 250 253 253 253
59748-253 253 253 253 253 253 253 253 253 253 253 253
59749-202 202 202 14 14 14 2 2 6 2 2 6
59750- 2 2 6 2 2 6 2 2 6 2 2 6
59751- 42 42 42 86 86 86 42 42 42 18 18 18
59752- 6 6 6 0 0 0 0 0 0 0 0 0
59753- 0 0 0 0 0 0 0 0 0 0 0 0
59754- 0 0 0 0 0 0 0 0 0 0 0 0
59755- 0 0 0 0 0 0 0 0 0 0 0 0
59756- 0 0 0 0 0 0 0 0 0 0 0 0
59757- 0 0 0 0 0 0 0 0 0 0 0 0
59758- 0 0 0 0 0 0 0 0 0 0 0 0
59759- 0 0 0 0 0 0 0 0 0 0 0 0
59760- 0 0 0 0 0 0 0 0 0 0 0 0
59761- 0 0 0 0 0 0 0 0 0 0 0 0
59762- 0 0 0 0 0 0 0 0 0 6 6 6
59763- 14 14 14 38 38 38 74 74 74 66 66 66
59764- 2 2 6 6 6 6 90 90 90 250 250 250
59765-253 253 253 253 253 253 238 238 238 198 198 198
59766-190 190 190 190 190 190 195 195 195 221 221 221
59767-246 246 246 253 253 253 253 253 253 253 253 253
59768-253 253 253 253 253 253 253 253 253 253 253 253
59769-253 253 253 82 82 82 2 2 6 2 2 6
59770- 2 2 6 2 2 6 2 2 6 2 2 6
59771- 2 2 6 78 78 78 70 70 70 34 34 34
59772- 14 14 14 6 6 6 0 0 0 0 0 0
59773- 0 0 0 0 0 0 0 0 0 0 0 0
59774- 0 0 0 0 0 0 0 0 0 0 0 0
59775- 0 0 0 0 0 0 0 0 0 0 0 0
59776- 0 0 0 0 0 0 0 0 0 0 0 0
59777- 0 0 0 0 0 0 0 0 0 0 0 0
59778- 0 0 0 0 0 0 0 0 0 0 0 0
59779- 0 0 0 0 0 0 0 0 0 0 0 0
59780- 0 0 0 0 0 0 0 0 0 0 0 0
59781- 0 0 0 0 0 0 0 0 0 0 0 0
59782- 0 0 0 0 0 0 0 0 0 14 14 14
59783- 34 34 34 66 66 66 78 78 78 6 6 6
59784- 2 2 6 18 18 18 218 218 218 253 253 253
59785-253 253 253 253 253 253 253 253 253 246 246 246
59786-226 226 226 231 231 231 246 246 246 253 253 253
59787-253 253 253 253 253 253 253 253 253 253 253 253
59788-253 253 253 253 253 253 253 253 253 253 253 253
59789-253 253 253 178 178 178 2 2 6 2 2 6
59790- 2 2 6 2 2 6 2 2 6 2 2 6
59791- 2 2 6 18 18 18 90 90 90 62 62 62
59792- 30 30 30 10 10 10 0 0 0 0 0 0
59793- 0 0 0 0 0 0 0 0 0 0 0 0
59794- 0 0 0 0 0 0 0 0 0 0 0 0
59795- 0 0 0 0 0 0 0 0 0 0 0 0
59796- 0 0 0 0 0 0 0 0 0 0 0 0
59797- 0 0 0 0 0 0 0 0 0 0 0 0
59798- 0 0 0 0 0 0 0 0 0 0 0 0
59799- 0 0 0 0 0 0 0 0 0 0 0 0
59800- 0 0 0 0 0 0 0 0 0 0 0 0
59801- 0 0 0 0 0 0 0 0 0 0 0 0
59802- 0 0 0 0 0 0 10 10 10 26 26 26
59803- 58 58 58 90 90 90 18 18 18 2 2 6
59804- 2 2 6 110 110 110 253 253 253 253 253 253
59805-253 253 253 253 253 253 253 253 253 253 253 253
59806-250 250 250 253 253 253 253 253 253 253 253 253
59807-253 253 253 253 253 253 253 253 253 253 253 253
59808-253 253 253 253 253 253 253 253 253 253 253 253
59809-253 253 253 231 231 231 18 18 18 2 2 6
59810- 2 2 6 2 2 6 2 2 6 2 2 6
59811- 2 2 6 2 2 6 18 18 18 94 94 94
59812- 54 54 54 26 26 26 10 10 10 0 0 0
59813- 0 0 0 0 0 0 0 0 0 0 0 0
59814- 0 0 0 0 0 0 0 0 0 0 0 0
59815- 0 0 0 0 0 0 0 0 0 0 0 0
59816- 0 0 0 0 0 0 0 0 0 0 0 0
59817- 0 0 0 0 0 0 0 0 0 0 0 0
59818- 0 0 0 0 0 0 0 0 0 0 0 0
59819- 0 0 0 0 0 0 0 0 0 0 0 0
59820- 0 0 0 0 0 0 0 0 0 0 0 0
59821- 0 0 0 0 0 0 0 0 0 0 0 0
59822- 0 0 0 6 6 6 22 22 22 50 50 50
59823- 90 90 90 26 26 26 2 2 6 2 2 6
59824- 14 14 14 195 195 195 250 250 250 253 253 253
59825-253 253 253 253 253 253 253 253 253 253 253 253
59826-253 253 253 253 253 253 253 253 253 253 253 253
59827-253 253 253 253 253 253 253 253 253 253 253 253
59828-253 253 253 253 253 253 253 253 253 253 253 253
59829-250 250 250 242 242 242 54 54 54 2 2 6
59830- 2 2 6 2 2 6 2 2 6 2 2 6
59831- 2 2 6 2 2 6 2 2 6 38 38 38
59832- 86 86 86 50 50 50 22 22 22 6 6 6
59833- 0 0 0 0 0 0 0 0 0 0 0 0
59834- 0 0 0 0 0 0 0 0 0 0 0 0
59835- 0 0 0 0 0 0 0 0 0 0 0 0
59836- 0 0 0 0 0 0 0 0 0 0 0 0
59837- 0 0 0 0 0 0 0 0 0 0 0 0
59838- 0 0 0 0 0 0 0 0 0 0 0 0
59839- 0 0 0 0 0 0 0 0 0 0 0 0
59840- 0 0 0 0 0 0 0 0 0 0 0 0
59841- 0 0 0 0 0 0 0 0 0 0 0 0
59842- 6 6 6 14 14 14 38 38 38 82 82 82
59843- 34 34 34 2 2 6 2 2 6 2 2 6
59844- 42 42 42 195 195 195 246 246 246 253 253 253
59845-253 253 253 253 253 253 253 253 253 250 250 250
59846-242 242 242 242 242 242 250 250 250 253 253 253
59847-253 253 253 253 253 253 253 253 253 253 253 253
59848-253 253 253 250 250 250 246 246 246 238 238 238
59849-226 226 226 231 231 231 101 101 101 6 6 6
59850- 2 2 6 2 2 6 2 2 6 2 2 6
59851- 2 2 6 2 2 6 2 2 6 2 2 6
59852- 38 38 38 82 82 82 42 42 42 14 14 14
59853- 6 6 6 0 0 0 0 0 0 0 0 0
59854- 0 0 0 0 0 0 0 0 0 0 0 0
59855- 0 0 0 0 0 0 0 0 0 0 0 0
59856- 0 0 0 0 0 0 0 0 0 0 0 0
59857- 0 0 0 0 0 0 0 0 0 0 0 0
59858- 0 0 0 0 0 0 0 0 0 0 0 0
59859- 0 0 0 0 0 0 0 0 0 0 0 0
59860- 0 0 0 0 0 0 0 0 0 0 0 0
59861- 0 0 0 0 0 0 0 0 0 0 0 0
59862- 10 10 10 26 26 26 62 62 62 66 66 66
59863- 2 2 6 2 2 6 2 2 6 6 6 6
59864- 70 70 70 170 170 170 206 206 206 234 234 234
59865-246 246 246 250 250 250 250 250 250 238 238 238
59866-226 226 226 231 231 231 238 238 238 250 250 250
59867-250 250 250 250 250 250 246 246 246 231 231 231
59868-214 214 214 206 206 206 202 202 202 202 202 202
59869-198 198 198 202 202 202 182 182 182 18 18 18
59870- 2 2 6 2 2 6 2 2 6 2 2 6
59871- 2 2 6 2 2 6 2 2 6 2 2 6
59872- 2 2 6 62 62 62 66 66 66 30 30 30
59873- 10 10 10 0 0 0 0 0 0 0 0 0
59874- 0 0 0 0 0 0 0 0 0 0 0 0
59875- 0 0 0 0 0 0 0 0 0 0 0 0
59876- 0 0 0 0 0 0 0 0 0 0 0 0
59877- 0 0 0 0 0 0 0 0 0 0 0 0
59878- 0 0 0 0 0 0 0 0 0 0 0 0
59879- 0 0 0 0 0 0 0 0 0 0 0 0
59880- 0 0 0 0 0 0 0 0 0 0 0 0
59881- 0 0 0 0 0 0 0 0 0 0 0 0
59882- 14 14 14 42 42 42 82 82 82 18 18 18
59883- 2 2 6 2 2 6 2 2 6 10 10 10
59884- 94 94 94 182 182 182 218 218 218 242 242 242
59885-250 250 250 253 253 253 253 253 253 250 250 250
59886-234 234 234 253 253 253 253 253 253 253 253 253
59887-253 253 253 253 253 253 253 253 253 246 246 246
59888-238 238 238 226 226 226 210 210 210 202 202 202
59889-195 195 195 195 195 195 210 210 210 158 158 158
59890- 6 6 6 14 14 14 50 50 50 14 14 14
59891- 2 2 6 2 2 6 2 2 6 2 2 6
59892- 2 2 6 6 6 6 86 86 86 46 46 46
59893- 18 18 18 6 6 6 0 0 0 0 0 0
59894- 0 0 0 0 0 0 0 0 0 0 0 0
59895- 0 0 0 0 0 0 0 0 0 0 0 0
59896- 0 0 0 0 0 0 0 0 0 0 0 0
59897- 0 0 0 0 0 0 0 0 0 0 0 0
59898- 0 0 0 0 0 0 0 0 0 0 0 0
59899- 0 0 0 0 0 0 0 0 0 0 0 0
59900- 0 0 0 0 0 0 0 0 0 0 0 0
59901- 0 0 0 0 0 0 0 0 0 6 6 6
59902- 22 22 22 54 54 54 70 70 70 2 2 6
59903- 2 2 6 10 10 10 2 2 6 22 22 22
59904-166 166 166 231 231 231 250 250 250 253 253 253
59905-253 253 253 253 253 253 253 253 253 250 250 250
59906-242 242 242 253 253 253 253 253 253 253 253 253
59907-253 253 253 253 253 253 253 253 253 253 253 253
59908-253 253 253 253 253 253 253 253 253 246 246 246
59909-231 231 231 206 206 206 198 198 198 226 226 226
59910- 94 94 94 2 2 6 6 6 6 38 38 38
59911- 30 30 30 2 2 6 2 2 6 2 2 6
59912- 2 2 6 2 2 6 62 62 62 66 66 66
59913- 26 26 26 10 10 10 0 0 0 0 0 0
59914- 0 0 0 0 0 0 0 0 0 0 0 0
59915- 0 0 0 0 0 0 0 0 0 0 0 0
59916- 0 0 0 0 0 0 0 0 0 0 0 0
59917- 0 0 0 0 0 0 0 0 0 0 0 0
59918- 0 0 0 0 0 0 0 0 0 0 0 0
59919- 0 0 0 0 0 0 0 0 0 0 0 0
59920- 0 0 0 0 0 0 0 0 0 0 0 0
59921- 0 0 0 0 0 0 0 0 0 10 10 10
59922- 30 30 30 74 74 74 50 50 50 2 2 6
59923- 26 26 26 26 26 26 2 2 6 106 106 106
59924-238 238 238 253 253 253 253 253 253 253 253 253
59925-253 253 253 253 253 253 253 253 253 253 253 253
59926-253 253 253 253 253 253 253 253 253 253 253 253
59927-253 253 253 253 253 253 253 253 253 253 253 253
59928-253 253 253 253 253 253 253 253 253 253 253 253
59929-253 253 253 246 246 246 218 218 218 202 202 202
59930-210 210 210 14 14 14 2 2 6 2 2 6
59931- 30 30 30 22 22 22 2 2 6 2 2 6
59932- 2 2 6 2 2 6 18 18 18 86 86 86
59933- 42 42 42 14 14 14 0 0 0 0 0 0
59934- 0 0 0 0 0 0 0 0 0 0 0 0
59935- 0 0 0 0 0 0 0 0 0 0 0 0
59936- 0 0 0 0 0 0 0 0 0 0 0 0
59937- 0 0 0 0 0 0 0 0 0 0 0 0
59938- 0 0 0 0 0 0 0 0 0 0 0 0
59939- 0 0 0 0 0 0 0 0 0 0 0 0
59940- 0 0 0 0 0 0 0 0 0 0 0 0
59941- 0 0 0 0 0 0 0 0 0 14 14 14
59942- 42 42 42 90 90 90 22 22 22 2 2 6
59943- 42 42 42 2 2 6 18 18 18 218 218 218
59944-253 253 253 253 253 253 253 253 253 253 253 253
59945-253 253 253 253 253 253 253 253 253 253 253 253
59946-253 253 253 253 253 253 253 253 253 253 253 253
59947-253 253 253 253 253 253 253 253 253 253 253 253
59948-253 253 253 253 253 253 253 253 253 253 253 253
59949-253 253 253 253 253 253 250 250 250 221 221 221
59950-218 218 218 101 101 101 2 2 6 14 14 14
59951- 18 18 18 38 38 38 10 10 10 2 2 6
59952- 2 2 6 2 2 6 2 2 6 78 78 78
59953- 58 58 58 22 22 22 6 6 6 0 0 0
59954- 0 0 0 0 0 0 0 0 0 0 0 0
59955- 0 0 0 0 0 0 0 0 0 0 0 0
59956- 0 0 0 0 0 0 0 0 0 0 0 0
59957- 0 0 0 0 0 0 0 0 0 0 0 0
59958- 0 0 0 0 0 0 0 0 0 0 0 0
59959- 0 0 0 0 0 0 0 0 0 0 0 0
59960- 0 0 0 0 0 0 0 0 0 0 0 0
59961- 0 0 0 0 0 0 6 6 6 18 18 18
59962- 54 54 54 82 82 82 2 2 6 26 26 26
59963- 22 22 22 2 2 6 123 123 123 253 253 253
59964-253 253 253 253 253 253 253 253 253 253 253 253
59965-253 253 253 253 253 253 253 253 253 253 253 253
59966-253 253 253 253 253 253 253 253 253 253 253 253
59967-253 253 253 253 253 253 253 253 253 253 253 253
59968-253 253 253 253 253 253 253 253 253 253 253 253
59969-253 253 253 253 253 253 253 253 253 250 250 250
59970-238 238 238 198 198 198 6 6 6 38 38 38
59971- 58 58 58 26 26 26 38 38 38 2 2 6
59972- 2 2 6 2 2 6 2 2 6 46 46 46
59973- 78 78 78 30 30 30 10 10 10 0 0 0
59974- 0 0 0 0 0 0 0 0 0 0 0 0
59975- 0 0 0 0 0 0 0 0 0 0 0 0
59976- 0 0 0 0 0 0 0 0 0 0 0 0
59977- 0 0 0 0 0 0 0 0 0 0 0 0
59978- 0 0 0 0 0 0 0 0 0 0 0 0
59979- 0 0 0 0 0 0 0 0 0 0 0 0
59980- 0 0 0 0 0 0 0 0 0 0 0 0
59981- 0 0 0 0 0 0 10 10 10 30 30 30
59982- 74 74 74 58 58 58 2 2 6 42 42 42
59983- 2 2 6 22 22 22 231 231 231 253 253 253
59984-253 253 253 253 253 253 253 253 253 253 253 253
59985-253 253 253 253 253 253 253 253 253 250 250 250
59986-253 253 253 253 253 253 253 253 253 253 253 253
59987-253 253 253 253 253 253 253 253 253 253 253 253
59988-253 253 253 253 253 253 253 253 253 253 253 253
59989-253 253 253 253 253 253 253 253 253 253 253 253
59990-253 253 253 246 246 246 46 46 46 38 38 38
59991- 42 42 42 14 14 14 38 38 38 14 14 14
59992- 2 2 6 2 2 6 2 2 6 6 6 6
59993- 86 86 86 46 46 46 14 14 14 0 0 0
59994- 0 0 0 0 0 0 0 0 0 0 0 0
59995- 0 0 0 0 0 0 0 0 0 0 0 0
59996- 0 0 0 0 0 0 0 0 0 0 0 0
59997- 0 0 0 0 0 0 0 0 0 0 0 0
59998- 0 0 0 0 0 0 0 0 0 0 0 0
59999- 0 0 0 0 0 0 0 0 0 0 0 0
60000- 0 0 0 0 0 0 0 0 0 0 0 0
60001- 0 0 0 6 6 6 14 14 14 42 42 42
60002- 90 90 90 18 18 18 18 18 18 26 26 26
60003- 2 2 6 116 116 116 253 253 253 253 253 253
60004-253 253 253 253 253 253 253 253 253 253 253 253
60005-253 253 253 253 253 253 250 250 250 238 238 238
60006-253 253 253 253 253 253 253 253 253 253 253 253
60007-253 253 253 253 253 253 253 253 253 253 253 253
60008-253 253 253 253 253 253 253 253 253 253 253 253
60009-253 253 253 253 253 253 253 253 253 253 253 253
60010-253 253 253 253 253 253 94 94 94 6 6 6
60011- 2 2 6 2 2 6 10 10 10 34 34 34
60012- 2 2 6 2 2 6 2 2 6 2 2 6
60013- 74 74 74 58 58 58 22 22 22 6 6 6
60014- 0 0 0 0 0 0 0 0 0 0 0 0
60015- 0 0 0 0 0 0 0 0 0 0 0 0
60016- 0 0 0 0 0 0 0 0 0 0 0 0
60017- 0 0 0 0 0 0 0 0 0 0 0 0
60018- 0 0 0 0 0 0 0 0 0 0 0 0
60019- 0 0 0 0 0 0 0 0 0 0 0 0
60020- 0 0 0 0 0 0 0 0 0 0 0 0
60021- 0 0 0 10 10 10 26 26 26 66 66 66
60022- 82 82 82 2 2 6 38 38 38 6 6 6
60023- 14 14 14 210 210 210 253 253 253 253 253 253
60024-253 253 253 253 253 253 253 253 253 253 253 253
60025-253 253 253 253 253 253 246 246 246 242 242 242
60026-253 253 253 253 253 253 253 253 253 253 253 253
60027-253 253 253 253 253 253 253 253 253 253 253 253
60028-253 253 253 253 253 253 253 253 253 253 253 253
60029-253 253 253 253 253 253 253 253 253 253 253 253
60030-253 253 253 253 253 253 144 144 144 2 2 6
60031- 2 2 6 2 2 6 2 2 6 46 46 46
60032- 2 2 6 2 2 6 2 2 6 2 2 6
60033- 42 42 42 74 74 74 30 30 30 10 10 10
60034- 0 0 0 0 0 0 0 0 0 0 0 0
60035- 0 0 0 0 0 0 0 0 0 0 0 0
60036- 0 0 0 0 0 0 0 0 0 0 0 0
60037- 0 0 0 0 0 0 0 0 0 0 0 0
60038- 0 0 0 0 0 0 0 0 0 0 0 0
60039- 0 0 0 0 0 0 0 0 0 0 0 0
60040- 0 0 0 0 0 0 0 0 0 0 0 0
60041- 6 6 6 14 14 14 42 42 42 90 90 90
60042- 26 26 26 6 6 6 42 42 42 2 2 6
60043- 74 74 74 250 250 250 253 253 253 253 253 253
60044-253 253 253 253 253 253 253 253 253 253 253 253
60045-253 253 253 253 253 253 242 242 242 242 242 242
60046-253 253 253 253 253 253 253 253 253 253 253 253
60047-253 253 253 253 253 253 253 253 253 253 253 253
60048-253 253 253 253 253 253 253 253 253 253 253 253
60049-253 253 253 253 253 253 253 253 253 253 253 253
60050-253 253 253 253 253 253 182 182 182 2 2 6
60051- 2 2 6 2 2 6 2 2 6 46 46 46
60052- 2 2 6 2 2 6 2 2 6 2 2 6
60053- 10 10 10 86 86 86 38 38 38 10 10 10
60054- 0 0 0 0 0 0 0 0 0 0 0 0
60055- 0 0 0 0 0 0 0 0 0 0 0 0
60056- 0 0 0 0 0 0 0 0 0 0 0 0
60057- 0 0 0 0 0 0 0 0 0 0 0 0
60058- 0 0 0 0 0 0 0 0 0 0 0 0
60059- 0 0 0 0 0 0 0 0 0 0 0 0
60060- 0 0 0 0 0 0 0 0 0 0 0 0
60061- 10 10 10 26 26 26 66 66 66 82 82 82
60062- 2 2 6 22 22 22 18 18 18 2 2 6
60063-149 149 149 253 253 253 253 253 253 253 253 253
60064-253 253 253 253 253 253 253 253 253 253 253 253
60065-253 253 253 253 253 253 234 234 234 242 242 242
60066-253 253 253 253 253 253 253 253 253 253 253 253
60067-253 253 253 253 253 253 253 253 253 253 253 253
60068-253 253 253 253 253 253 253 253 253 253 253 253
60069-253 253 253 253 253 253 253 253 253 253 253 253
60070-253 253 253 253 253 253 206 206 206 2 2 6
60071- 2 2 6 2 2 6 2 2 6 38 38 38
60072- 2 2 6 2 2 6 2 2 6 2 2 6
60073- 6 6 6 86 86 86 46 46 46 14 14 14
60074- 0 0 0 0 0 0 0 0 0 0 0 0
60075- 0 0 0 0 0 0 0 0 0 0 0 0
60076- 0 0 0 0 0 0 0 0 0 0 0 0
60077- 0 0 0 0 0 0 0 0 0 0 0 0
60078- 0 0 0 0 0 0 0 0 0 0 0 0
60079- 0 0 0 0 0 0 0 0 0 0 0 0
60080- 0 0 0 0 0 0 0 0 0 6 6 6
60081- 18 18 18 46 46 46 86 86 86 18 18 18
60082- 2 2 6 34 34 34 10 10 10 6 6 6
60083-210 210 210 253 253 253 253 253 253 253 253 253
60084-253 253 253 253 253 253 253 253 253 253 253 253
60085-253 253 253 253 253 253 234 234 234 242 242 242
60086-253 253 253 253 253 253 253 253 253 253 253 253
60087-253 253 253 253 253 253 253 253 253 253 253 253
60088-253 253 253 253 253 253 253 253 253 253 253 253
60089-253 253 253 253 253 253 253 253 253 253 253 253
60090-253 253 253 253 253 253 221 221 221 6 6 6
60091- 2 2 6 2 2 6 6 6 6 30 30 30
60092- 2 2 6 2 2 6 2 2 6 2 2 6
60093- 2 2 6 82 82 82 54 54 54 18 18 18
60094- 6 6 6 0 0 0 0 0 0 0 0 0
60095- 0 0 0 0 0 0 0 0 0 0 0 0
60096- 0 0 0 0 0 0 0 0 0 0 0 0
60097- 0 0 0 0 0 0 0 0 0 0 0 0
60098- 0 0 0 0 0 0 0 0 0 0 0 0
60099- 0 0 0 0 0 0 0 0 0 0 0 0
60100- 0 0 0 0 0 0 0 0 0 10 10 10
60101- 26 26 26 66 66 66 62 62 62 2 2 6
60102- 2 2 6 38 38 38 10 10 10 26 26 26
60103-238 238 238 253 253 253 253 253 253 253 253 253
60104-253 253 253 253 253 253 253 253 253 253 253 253
60105-253 253 253 253 253 253 231 231 231 238 238 238
60106-253 253 253 253 253 253 253 253 253 253 253 253
60107-253 253 253 253 253 253 253 253 253 253 253 253
60108-253 253 253 253 253 253 253 253 253 253 253 253
60109-253 253 253 253 253 253 253 253 253 253 253 253
60110-253 253 253 253 253 253 231 231 231 6 6 6
60111- 2 2 6 2 2 6 10 10 10 30 30 30
60112- 2 2 6 2 2 6 2 2 6 2 2 6
60113- 2 2 6 66 66 66 58 58 58 22 22 22
60114- 6 6 6 0 0 0 0 0 0 0 0 0
60115- 0 0 0 0 0 0 0 0 0 0 0 0
60116- 0 0 0 0 0 0 0 0 0 0 0 0
60117- 0 0 0 0 0 0 0 0 0 0 0 0
60118- 0 0 0 0 0 0 0 0 0 0 0 0
60119- 0 0 0 0 0 0 0 0 0 0 0 0
60120- 0 0 0 0 0 0 0 0 0 10 10 10
60121- 38 38 38 78 78 78 6 6 6 2 2 6
60122- 2 2 6 46 46 46 14 14 14 42 42 42
60123-246 246 246 253 253 253 253 253 253 253 253 253
60124-253 253 253 253 253 253 253 253 253 253 253 253
60125-253 253 253 253 253 253 231 231 231 242 242 242
60126-253 253 253 253 253 253 253 253 253 253 253 253
60127-253 253 253 253 253 253 253 253 253 253 253 253
60128-253 253 253 253 253 253 253 253 253 253 253 253
60129-253 253 253 253 253 253 253 253 253 253 253 253
60130-253 253 253 253 253 253 234 234 234 10 10 10
60131- 2 2 6 2 2 6 22 22 22 14 14 14
60132- 2 2 6 2 2 6 2 2 6 2 2 6
60133- 2 2 6 66 66 66 62 62 62 22 22 22
60134- 6 6 6 0 0 0 0 0 0 0 0 0
60135- 0 0 0 0 0 0 0 0 0 0 0 0
60136- 0 0 0 0 0 0 0 0 0 0 0 0
60137- 0 0 0 0 0 0 0 0 0 0 0 0
60138- 0 0 0 0 0 0 0 0 0 0 0 0
60139- 0 0 0 0 0 0 0 0 0 0 0 0
60140- 0 0 0 0 0 0 6 6 6 18 18 18
60141- 50 50 50 74 74 74 2 2 6 2 2 6
60142- 14 14 14 70 70 70 34 34 34 62 62 62
60143-250 250 250 253 253 253 253 253 253 253 253 253
60144-253 253 253 253 253 253 253 253 253 253 253 253
60145-253 253 253 253 253 253 231 231 231 246 246 246
60146-253 253 253 253 253 253 253 253 253 253 253 253
60147-253 253 253 253 253 253 253 253 253 253 253 253
60148-253 253 253 253 253 253 253 253 253 253 253 253
60149-253 253 253 253 253 253 253 253 253 253 253 253
60150-253 253 253 253 253 253 234 234 234 14 14 14
60151- 2 2 6 2 2 6 30 30 30 2 2 6
60152- 2 2 6 2 2 6 2 2 6 2 2 6
60153- 2 2 6 66 66 66 62 62 62 22 22 22
60154- 6 6 6 0 0 0 0 0 0 0 0 0
60155- 0 0 0 0 0 0 0 0 0 0 0 0
60156- 0 0 0 0 0 0 0 0 0 0 0 0
60157- 0 0 0 0 0 0 0 0 0 0 0 0
60158- 0 0 0 0 0 0 0 0 0 0 0 0
60159- 0 0 0 0 0 0 0 0 0 0 0 0
60160- 0 0 0 0 0 0 6 6 6 18 18 18
60161- 54 54 54 62 62 62 2 2 6 2 2 6
60162- 2 2 6 30 30 30 46 46 46 70 70 70
60163-250 250 250 253 253 253 253 253 253 253 253 253
60164-253 253 253 253 253 253 253 253 253 253 253 253
60165-253 253 253 253 253 253 231 231 231 246 246 246
60166-253 253 253 253 253 253 253 253 253 253 253 253
60167-253 253 253 253 253 253 253 253 253 253 253 253
60168-253 253 253 253 253 253 253 253 253 253 253 253
60169-253 253 253 253 253 253 253 253 253 253 253 253
60170-253 253 253 253 253 253 226 226 226 10 10 10
60171- 2 2 6 6 6 6 30 30 30 2 2 6
60172- 2 2 6 2 2 6 2 2 6 2 2 6
60173- 2 2 6 66 66 66 58 58 58 22 22 22
60174- 6 6 6 0 0 0 0 0 0 0 0 0
60175- 0 0 0 0 0 0 0 0 0 0 0 0
60176- 0 0 0 0 0 0 0 0 0 0 0 0
60177- 0 0 0 0 0 0 0 0 0 0 0 0
60178- 0 0 0 0 0 0 0 0 0 0 0 0
60179- 0 0 0 0 0 0 0 0 0 0 0 0
60180- 0 0 0 0 0 0 6 6 6 22 22 22
60181- 58 58 58 62 62 62 2 2 6 2 2 6
60182- 2 2 6 2 2 6 30 30 30 78 78 78
60183-250 250 250 253 253 253 253 253 253 253 253 253
60184-253 253 253 253 253 253 253 253 253 253 253 253
60185-253 253 253 253 253 253 231 231 231 246 246 246
60186-253 253 253 253 253 253 253 253 253 253 253 253
60187-253 253 253 253 253 253 253 253 253 253 253 253
60188-253 253 253 253 253 253 253 253 253 253 253 253
60189-253 253 253 253 253 253 253 253 253 253 253 253
60190-253 253 253 253 253 253 206 206 206 2 2 6
60191- 22 22 22 34 34 34 18 14 6 22 22 22
60192- 26 26 26 18 18 18 6 6 6 2 2 6
60193- 2 2 6 82 82 82 54 54 54 18 18 18
60194- 6 6 6 0 0 0 0 0 0 0 0 0
60195- 0 0 0 0 0 0 0 0 0 0 0 0
60196- 0 0 0 0 0 0 0 0 0 0 0 0
60197- 0 0 0 0 0 0 0 0 0 0 0 0
60198- 0 0 0 0 0 0 0 0 0 0 0 0
60199- 0 0 0 0 0 0 0 0 0 0 0 0
60200- 0 0 0 0 0 0 6 6 6 26 26 26
60201- 62 62 62 106 106 106 74 54 14 185 133 11
60202-210 162 10 121 92 8 6 6 6 62 62 62
60203-238 238 238 253 253 253 253 253 253 253 253 253
60204-253 253 253 253 253 253 253 253 253 253 253 253
60205-253 253 253 253 253 253 231 231 231 246 246 246
60206-253 253 253 253 253 253 253 253 253 253 253 253
60207-253 253 253 253 253 253 253 253 253 253 253 253
60208-253 253 253 253 253 253 253 253 253 253 253 253
60209-253 253 253 253 253 253 253 253 253 253 253 253
60210-253 253 253 253 253 253 158 158 158 18 18 18
60211- 14 14 14 2 2 6 2 2 6 2 2 6
60212- 6 6 6 18 18 18 66 66 66 38 38 38
60213- 6 6 6 94 94 94 50 50 50 18 18 18
60214- 6 6 6 0 0 0 0 0 0 0 0 0
60215- 0 0 0 0 0 0 0 0 0 0 0 0
60216- 0 0 0 0 0 0 0 0 0 0 0 0
60217- 0 0 0 0 0 0 0 0 0 0 0 0
60218- 0 0 0 0 0 0 0 0 0 0 0 0
60219- 0 0 0 0 0 0 0 0 0 6 6 6
60220- 10 10 10 10 10 10 18 18 18 38 38 38
60221- 78 78 78 142 134 106 216 158 10 242 186 14
60222-246 190 14 246 190 14 156 118 10 10 10 10
60223- 90 90 90 238 238 238 253 253 253 253 253 253
60224-253 253 253 253 253 253 253 253 253 253 253 253
60225-253 253 253 253 253 253 231 231 231 250 250 250
60226-253 253 253 253 253 253 253 253 253 253 253 253
60227-253 253 253 253 253 253 253 253 253 253 253 253
60228-253 253 253 253 253 253 253 253 253 253 253 253
60229-253 253 253 253 253 253 253 253 253 246 230 190
60230-238 204 91 238 204 91 181 142 44 37 26 9
60231- 2 2 6 2 2 6 2 2 6 2 2 6
60232- 2 2 6 2 2 6 38 38 38 46 46 46
60233- 26 26 26 106 106 106 54 54 54 18 18 18
60234- 6 6 6 0 0 0 0 0 0 0 0 0
60235- 0 0 0 0 0 0 0 0 0 0 0 0
60236- 0 0 0 0 0 0 0 0 0 0 0 0
60237- 0 0 0 0 0 0 0 0 0 0 0 0
60238- 0 0 0 0 0 0 0 0 0 0 0 0
60239- 0 0 0 6 6 6 14 14 14 22 22 22
60240- 30 30 30 38 38 38 50 50 50 70 70 70
60241-106 106 106 190 142 34 226 170 11 242 186 14
60242-246 190 14 246 190 14 246 190 14 154 114 10
60243- 6 6 6 74 74 74 226 226 226 253 253 253
60244-253 253 253 253 253 253 253 253 253 253 253 253
60245-253 253 253 253 253 253 231 231 231 250 250 250
60246-253 253 253 253 253 253 253 253 253 253 253 253
60247-253 253 253 253 253 253 253 253 253 253 253 253
60248-253 253 253 253 253 253 253 253 253 253 253 253
60249-253 253 253 253 253 253 253 253 253 228 184 62
60250-241 196 14 241 208 19 232 195 16 38 30 10
60251- 2 2 6 2 2 6 2 2 6 2 2 6
60252- 2 2 6 6 6 6 30 30 30 26 26 26
60253-203 166 17 154 142 90 66 66 66 26 26 26
60254- 6 6 6 0 0 0 0 0 0 0 0 0
60255- 0 0 0 0 0 0 0 0 0 0 0 0
60256- 0 0 0 0 0 0 0 0 0 0 0 0
60257- 0 0 0 0 0 0 0 0 0 0 0 0
60258- 0 0 0 0 0 0 0 0 0 0 0 0
60259- 6 6 6 18 18 18 38 38 38 58 58 58
60260- 78 78 78 86 86 86 101 101 101 123 123 123
60261-175 146 61 210 150 10 234 174 13 246 186 14
60262-246 190 14 246 190 14 246 190 14 238 190 10
60263-102 78 10 2 2 6 46 46 46 198 198 198
60264-253 253 253 253 253 253 253 253 253 253 253 253
60265-253 253 253 253 253 253 234 234 234 242 242 242
60266-253 253 253 253 253 253 253 253 253 253 253 253
60267-253 253 253 253 253 253 253 253 253 253 253 253
60268-253 253 253 253 253 253 253 253 253 253 253 253
60269-253 253 253 253 253 253 253 253 253 224 178 62
60270-242 186 14 241 196 14 210 166 10 22 18 6
60271- 2 2 6 2 2 6 2 2 6 2 2 6
60272- 2 2 6 2 2 6 6 6 6 121 92 8
60273-238 202 15 232 195 16 82 82 82 34 34 34
60274- 10 10 10 0 0 0 0 0 0 0 0 0
60275- 0 0 0 0 0 0 0 0 0 0 0 0
60276- 0 0 0 0 0 0 0 0 0 0 0 0
60277- 0 0 0 0 0 0 0 0 0 0 0 0
60278- 0 0 0 0 0 0 0 0 0 0 0 0
60279- 14 14 14 38 38 38 70 70 70 154 122 46
60280-190 142 34 200 144 11 197 138 11 197 138 11
60281-213 154 11 226 170 11 242 186 14 246 190 14
60282-246 190 14 246 190 14 246 190 14 246 190 14
60283-225 175 15 46 32 6 2 2 6 22 22 22
60284-158 158 158 250 250 250 253 253 253 253 253 253
60285-253 253 253 253 253 253 253 253 253 253 253 253
60286-253 253 253 253 253 253 253 253 253 253 253 253
60287-253 253 253 253 253 253 253 253 253 253 253 253
60288-253 253 253 253 253 253 253 253 253 253 253 253
60289-253 253 253 250 250 250 242 242 242 224 178 62
60290-239 182 13 236 186 11 213 154 11 46 32 6
60291- 2 2 6 2 2 6 2 2 6 2 2 6
60292- 2 2 6 2 2 6 61 42 6 225 175 15
60293-238 190 10 236 186 11 112 100 78 42 42 42
60294- 14 14 14 0 0 0 0 0 0 0 0 0
60295- 0 0 0 0 0 0 0 0 0 0 0 0
60296- 0 0 0 0 0 0 0 0 0 0 0 0
60297- 0 0 0 0 0 0 0 0 0 0 0 0
60298- 0 0 0 0 0 0 0 0 0 6 6 6
60299- 22 22 22 54 54 54 154 122 46 213 154 11
60300-226 170 11 230 174 11 226 170 11 226 170 11
60301-236 178 12 242 186 14 246 190 14 246 190 14
60302-246 190 14 246 190 14 246 190 14 246 190 14
60303-241 196 14 184 144 12 10 10 10 2 2 6
60304- 6 6 6 116 116 116 242 242 242 253 253 253
60305-253 253 253 253 253 253 253 253 253 253 253 253
60306-253 253 253 253 253 253 253 253 253 253 253 253
60307-253 253 253 253 253 253 253 253 253 253 253 253
60308-253 253 253 253 253 253 253 253 253 253 253 253
60309-253 253 253 231 231 231 198 198 198 214 170 54
60310-236 178 12 236 178 12 210 150 10 137 92 6
60311- 18 14 6 2 2 6 2 2 6 2 2 6
60312- 6 6 6 70 47 6 200 144 11 236 178 12
60313-239 182 13 239 182 13 124 112 88 58 58 58
60314- 22 22 22 6 6 6 0 0 0 0 0 0
60315- 0 0 0 0 0 0 0 0 0 0 0 0
60316- 0 0 0 0 0 0 0 0 0 0 0 0
60317- 0 0 0 0 0 0 0 0 0 0 0 0
60318- 0 0 0 0 0 0 0 0 0 10 10 10
60319- 30 30 30 70 70 70 180 133 36 226 170 11
60320-239 182 13 242 186 14 242 186 14 246 186 14
60321-246 190 14 246 190 14 246 190 14 246 190 14
60322-246 190 14 246 190 14 246 190 14 246 190 14
60323-246 190 14 232 195 16 98 70 6 2 2 6
60324- 2 2 6 2 2 6 66 66 66 221 221 221
60325-253 253 253 253 253 253 253 253 253 253 253 253
60326-253 253 253 253 253 253 253 253 253 253 253 253
60327-253 253 253 253 253 253 253 253 253 253 253 253
60328-253 253 253 253 253 253 253 253 253 253 253 253
60329-253 253 253 206 206 206 198 198 198 214 166 58
60330-230 174 11 230 174 11 216 158 10 192 133 9
60331-163 110 8 116 81 8 102 78 10 116 81 8
60332-167 114 7 197 138 11 226 170 11 239 182 13
60333-242 186 14 242 186 14 162 146 94 78 78 78
60334- 34 34 34 14 14 14 6 6 6 0 0 0
60335- 0 0 0 0 0 0 0 0 0 0 0 0
60336- 0 0 0 0 0 0 0 0 0 0 0 0
60337- 0 0 0 0 0 0 0 0 0 0 0 0
60338- 0 0 0 0 0 0 0 0 0 6 6 6
60339- 30 30 30 78 78 78 190 142 34 226 170 11
60340-239 182 13 246 190 14 246 190 14 246 190 14
60341-246 190 14 246 190 14 246 190 14 246 190 14
60342-246 190 14 246 190 14 246 190 14 246 190 14
60343-246 190 14 241 196 14 203 166 17 22 18 6
60344- 2 2 6 2 2 6 2 2 6 38 38 38
60345-218 218 218 253 253 253 253 253 253 253 253 253
60346-253 253 253 253 253 253 253 253 253 253 253 253
60347-253 253 253 253 253 253 253 253 253 253 253 253
60348-253 253 253 253 253 253 253 253 253 253 253 253
60349-250 250 250 206 206 206 198 198 198 202 162 69
60350-226 170 11 236 178 12 224 166 10 210 150 10
60351-200 144 11 197 138 11 192 133 9 197 138 11
60352-210 150 10 226 170 11 242 186 14 246 190 14
60353-246 190 14 246 186 14 225 175 15 124 112 88
60354- 62 62 62 30 30 30 14 14 14 6 6 6
60355- 0 0 0 0 0 0 0 0 0 0 0 0
60356- 0 0 0 0 0 0 0 0 0 0 0 0
60357- 0 0 0 0 0 0 0 0 0 0 0 0
60358- 0 0 0 0 0 0 0 0 0 10 10 10
60359- 30 30 30 78 78 78 174 135 50 224 166 10
60360-239 182 13 246 190 14 246 190 14 246 190 14
60361-246 190 14 246 190 14 246 190 14 246 190 14
60362-246 190 14 246 190 14 246 190 14 246 190 14
60363-246 190 14 246 190 14 241 196 14 139 102 15
60364- 2 2 6 2 2 6 2 2 6 2 2 6
60365- 78 78 78 250 250 250 253 253 253 253 253 253
60366-253 253 253 253 253 253 253 253 253 253 253 253
60367-253 253 253 253 253 253 253 253 253 253 253 253
60368-253 253 253 253 253 253 253 253 253 253 253 253
60369-250 250 250 214 214 214 198 198 198 190 150 46
60370-219 162 10 236 178 12 234 174 13 224 166 10
60371-216 158 10 213 154 11 213 154 11 216 158 10
60372-226 170 11 239 182 13 246 190 14 246 190 14
60373-246 190 14 246 190 14 242 186 14 206 162 42
60374-101 101 101 58 58 58 30 30 30 14 14 14
60375- 6 6 6 0 0 0 0 0 0 0 0 0
60376- 0 0 0 0 0 0 0 0 0 0 0 0
60377- 0 0 0 0 0 0 0 0 0 0 0 0
60378- 0 0 0 0 0 0 0 0 0 10 10 10
60379- 30 30 30 74 74 74 174 135 50 216 158 10
60380-236 178 12 246 190 14 246 190 14 246 190 14
60381-246 190 14 246 190 14 246 190 14 246 190 14
60382-246 190 14 246 190 14 246 190 14 246 190 14
60383-246 190 14 246 190 14 241 196 14 226 184 13
60384- 61 42 6 2 2 6 2 2 6 2 2 6
60385- 22 22 22 238 238 238 253 253 253 253 253 253
60386-253 253 253 253 253 253 253 253 253 253 253 253
60387-253 253 253 253 253 253 253 253 253 253 253 253
60388-253 253 253 253 253 253 253 253 253 253 253 253
60389-253 253 253 226 226 226 187 187 187 180 133 36
60390-216 158 10 236 178 12 239 182 13 236 178 12
60391-230 174 11 226 170 11 226 170 11 230 174 11
60392-236 178 12 242 186 14 246 190 14 246 190 14
60393-246 190 14 246 190 14 246 186 14 239 182 13
60394-206 162 42 106 106 106 66 66 66 34 34 34
60395- 14 14 14 6 6 6 0 0 0 0 0 0
60396- 0 0 0 0 0 0 0 0 0 0 0 0
60397- 0 0 0 0 0 0 0 0 0 0 0 0
60398- 0 0 0 0 0 0 0 0 0 6 6 6
60399- 26 26 26 70 70 70 163 133 67 213 154 11
60400-236 178 12 246 190 14 246 190 14 246 190 14
60401-246 190 14 246 190 14 246 190 14 246 190 14
60402-246 190 14 246 190 14 246 190 14 246 190 14
60403-246 190 14 246 190 14 246 190 14 241 196 14
60404-190 146 13 18 14 6 2 2 6 2 2 6
60405- 46 46 46 246 246 246 253 253 253 253 253 253
60406-253 253 253 253 253 253 253 253 253 253 253 253
60407-253 253 253 253 253 253 253 253 253 253 253 253
60408-253 253 253 253 253 253 253 253 253 253 253 253
60409-253 253 253 221 221 221 86 86 86 156 107 11
60410-216 158 10 236 178 12 242 186 14 246 186 14
60411-242 186 14 239 182 13 239 182 13 242 186 14
60412-242 186 14 246 186 14 246 190 14 246 190 14
60413-246 190 14 246 190 14 246 190 14 246 190 14
60414-242 186 14 225 175 15 142 122 72 66 66 66
60415- 30 30 30 10 10 10 0 0 0 0 0 0
60416- 0 0 0 0 0 0 0 0 0 0 0 0
60417- 0 0 0 0 0 0 0 0 0 0 0 0
60418- 0 0 0 0 0 0 0 0 0 6 6 6
60419- 26 26 26 70 70 70 163 133 67 210 150 10
60420-236 178 12 246 190 14 246 190 14 246 190 14
60421-246 190 14 246 190 14 246 190 14 246 190 14
60422-246 190 14 246 190 14 246 190 14 246 190 14
60423-246 190 14 246 190 14 246 190 14 246 190 14
60424-232 195 16 121 92 8 34 34 34 106 106 106
60425-221 221 221 253 253 253 253 253 253 253 253 253
60426-253 253 253 253 253 253 253 253 253 253 253 253
60427-253 253 253 253 253 253 253 253 253 253 253 253
60428-253 253 253 253 253 253 253 253 253 253 253 253
60429-242 242 242 82 82 82 18 14 6 163 110 8
60430-216 158 10 236 178 12 242 186 14 246 190 14
60431-246 190 14 246 190 14 246 190 14 246 190 14
60432-246 190 14 246 190 14 246 190 14 246 190 14
60433-246 190 14 246 190 14 246 190 14 246 190 14
60434-246 190 14 246 190 14 242 186 14 163 133 67
60435- 46 46 46 18 18 18 6 6 6 0 0 0
60436- 0 0 0 0 0 0 0 0 0 0 0 0
60437- 0 0 0 0 0 0 0 0 0 0 0 0
60438- 0 0 0 0 0 0 0 0 0 10 10 10
60439- 30 30 30 78 78 78 163 133 67 210 150 10
60440-236 178 12 246 186 14 246 190 14 246 190 14
60441-246 190 14 246 190 14 246 190 14 246 190 14
60442-246 190 14 246 190 14 246 190 14 246 190 14
60443-246 190 14 246 190 14 246 190 14 246 190 14
60444-241 196 14 215 174 15 190 178 144 253 253 253
60445-253 253 253 253 253 253 253 253 253 253 253 253
60446-253 253 253 253 253 253 253 253 253 253 253 253
60447-253 253 253 253 253 253 253 253 253 253 253 253
60448-253 253 253 253 253 253 253 253 253 218 218 218
60449- 58 58 58 2 2 6 22 18 6 167 114 7
60450-216 158 10 236 178 12 246 186 14 246 190 14
60451-246 190 14 246 190 14 246 190 14 246 190 14
60452-246 190 14 246 190 14 246 190 14 246 190 14
60453-246 190 14 246 190 14 246 190 14 246 190 14
60454-246 190 14 246 186 14 242 186 14 190 150 46
60455- 54 54 54 22 22 22 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 14 14 14
60459- 38 38 38 86 86 86 180 133 36 213 154 11
60460-236 178 12 246 186 14 246 190 14 246 190 14
60461-246 190 14 246 190 14 246 190 14 246 190 14
60462-246 190 14 246 190 14 246 190 14 246 190 14
60463-246 190 14 246 190 14 246 190 14 246 190 14
60464-246 190 14 232 195 16 190 146 13 214 214 214
60465-253 253 253 253 253 253 253 253 253 253 253 253
60466-253 253 253 253 253 253 253 253 253 253 253 253
60467-253 253 253 253 253 253 253 253 253 253 253 253
60468-253 253 253 250 250 250 170 170 170 26 26 26
60469- 2 2 6 2 2 6 37 26 9 163 110 8
60470-219 162 10 239 182 13 246 186 14 246 190 14
60471-246 190 14 246 190 14 246 190 14 246 190 14
60472-246 190 14 246 190 14 246 190 14 246 190 14
60473-246 190 14 246 190 14 246 190 14 246 190 14
60474-246 186 14 236 178 12 224 166 10 142 122 72
60475- 46 46 46 18 18 18 6 6 6 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 6 6 6 18 18 18
60479- 50 50 50 109 106 95 192 133 9 224 166 10
60480-242 186 14 246 190 14 246 190 14 246 190 14
60481-246 190 14 246 190 14 246 190 14 246 190 14
60482-246 190 14 246 190 14 246 190 14 246 190 14
60483-246 190 14 246 190 14 246 190 14 246 190 14
60484-242 186 14 226 184 13 210 162 10 142 110 46
60485-226 226 226 253 253 253 253 253 253 253 253 253
60486-253 253 253 253 253 253 253 253 253 253 253 253
60487-253 253 253 253 253 253 253 253 253 253 253 253
60488-198 198 198 66 66 66 2 2 6 2 2 6
60489- 2 2 6 2 2 6 50 34 6 156 107 11
60490-219 162 10 239 182 13 246 186 14 246 190 14
60491-246 190 14 246 190 14 246 190 14 246 190 14
60492-246 190 14 246 190 14 246 190 14 246 190 14
60493-246 190 14 246 190 14 246 190 14 242 186 14
60494-234 174 13 213 154 11 154 122 46 66 66 66
60495- 30 30 30 10 10 10 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 6 6 6 22 22 22
60499- 58 58 58 154 121 60 206 145 10 234 174 13
60500-242 186 14 246 186 14 246 190 14 246 190 14
60501-246 190 14 246 190 14 246 190 14 246 190 14
60502-246 190 14 246 190 14 246 190 14 246 190 14
60503-246 190 14 246 190 14 246 190 14 246 190 14
60504-246 186 14 236 178 12 210 162 10 163 110 8
60505- 61 42 6 138 138 138 218 218 218 250 250 250
60506-253 253 253 253 253 253 253 253 253 250 250 250
60507-242 242 242 210 210 210 144 144 144 66 66 66
60508- 6 6 6 2 2 6 2 2 6 2 2 6
60509- 2 2 6 2 2 6 61 42 6 163 110 8
60510-216 158 10 236 178 12 246 190 14 246 190 14
60511-246 190 14 246 190 14 246 190 14 246 190 14
60512-246 190 14 246 190 14 246 190 14 246 190 14
60513-246 190 14 239 182 13 230 174 11 216 158 10
60514-190 142 34 124 112 88 70 70 70 38 38 38
60515- 18 18 18 6 6 6 0 0 0 0 0 0
60516- 0 0 0 0 0 0 0 0 0 0 0 0
60517- 0 0 0 0 0 0 0 0 0 0 0 0
60518- 0 0 0 0 0 0 6 6 6 22 22 22
60519- 62 62 62 168 124 44 206 145 10 224 166 10
60520-236 178 12 239 182 13 242 186 14 242 186 14
60521-246 186 14 246 190 14 246 190 14 246 190 14
60522-246 190 14 246 190 14 246 190 14 246 190 14
60523-246 190 14 246 190 14 246 190 14 246 190 14
60524-246 190 14 236 178 12 216 158 10 175 118 6
60525- 80 54 7 2 2 6 6 6 6 30 30 30
60526- 54 54 54 62 62 62 50 50 50 38 38 38
60527- 14 14 14 2 2 6 2 2 6 2 2 6
60528- 2 2 6 2 2 6 2 2 6 2 2 6
60529- 2 2 6 6 6 6 80 54 7 167 114 7
60530-213 154 11 236 178 12 246 190 14 246 190 14
60531-246 190 14 246 190 14 246 190 14 246 190 14
60532-246 190 14 242 186 14 239 182 13 239 182 13
60533-230 174 11 210 150 10 174 135 50 124 112 88
60534- 82 82 82 54 54 54 34 34 34 18 18 18
60535- 6 6 6 0 0 0 0 0 0 0 0 0
60536- 0 0 0 0 0 0 0 0 0 0 0 0
60537- 0 0 0 0 0 0 0 0 0 0 0 0
60538- 0 0 0 0 0 0 6 6 6 18 18 18
60539- 50 50 50 158 118 36 192 133 9 200 144 11
60540-216 158 10 219 162 10 224 166 10 226 170 11
60541-230 174 11 236 178 12 239 182 13 239 182 13
60542-242 186 14 246 186 14 246 190 14 246 190 14
60543-246 190 14 246 190 14 246 190 14 246 190 14
60544-246 186 14 230 174 11 210 150 10 163 110 8
60545-104 69 6 10 10 10 2 2 6 2 2 6
60546- 2 2 6 2 2 6 2 2 6 2 2 6
60547- 2 2 6 2 2 6 2 2 6 2 2 6
60548- 2 2 6 2 2 6 2 2 6 2 2 6
60549- 2 2 6 6 6 6 91 60 6 167 114 7
60550-206 145 10 230 174 11 242 186 14 246 190 14
60551-246 190 14 246 190 14 246 186 14 242 186 14
60552-239 182 13 230 174 11 224 166 10 213 154 11
60553-180 133 36 124 112 88 86 86 86 58 58 58
60554- 38 38 38 22 22 22 10 10 10 6 6 6
60555- 0 0 0 0 0 0 0 0 0 0 0 0
60556- 0 0 0 0 0 0 0 0 0 0 0 0
60557- 0 0 0 0 0 0 0 0 0 0 0 0
60558- 0 0 0 0 0 0 0 0 0 14 14 14
60559- 34 34 34 70 70 70 138 110 50 158 118 36
60560-167 114 7 180 123 7 192 133 9 197 138 11
60561-200 144 11 206 145 10 213 154 11 219 162 10
60562-224 166 10 230 174 11 239 182 13 242 186 14
60563-246 186 14 246 186 14 246 186 14 246 186 14
60564-239 182 13 216 158 10 185 133 11 152 99 6
60565-104 69 6 18 14 6 2 2 6 2 2 6
60566- 2 2 6 2 2 6 2 2 6 2 2 6
60567- 2 2 6 2 2 6 2 2 6 2 2 6
60568- 2 2 6 2 2 6 2 2 6 2 2 6
60569- 2 2 6 6 6 6 80 54 7 152 99 6
60570-192 133 9 219 162 10 236 178 12 239 182 13
60571-246 186 14 242 186 14 239 182 13 236 178 12
60572-224 166 10 206 145 10 192 133 9 154 121 60
60573- 94 94 94 62 62 62 42 42 42 22 22 22
60574- 14 14 14 6 6 6 0 0 0 0 0 0
60575- 0 0 0 0 0 0 0 0 0 0 0 0
60576- 0 0 0 0 0 0 0 0 0 0 0 0
60577- 0 0 0 0 0 0 0 0 0 0 0 0
60578- 0 0 0 0 0 0 0 0 0 6 6 6
60579- 18 18 18 34 34 34 58 58 58 78 78 78
60580-101 98 89 124 112 88 142 110 46 156 107 11
60581-163 110 8 167 114 7 175 118 6 180 123 7
60582-185 133 11 197 138 11 210 150 10 219 162 10
60583-226 170 11 236 178 12 236 178 12 234 174 13
60584-219 162 10 197 138 11 163 110 8 130 83 6
60585- 91 60 6 10 10 10 2 2 6 2 2 6
60586- 18 18 18 38 38 38 38 38 38 38 38 38
60587- 38 38 38 38 38 38 38 38 38 38 38 38
60588- 38 38 38 38 38 38 26 26 26 2 2 6
60589- 2 2 6 6 6 6 70 47 6 137 92 6
60590-175 118 6 200 144 11 219 162 10 230 174 11
60591-234 174 13 230 174 11 219 162 10 210 150 10
60592-192 133 9 163 110 8 124 112 88 82 82 82
60593- 50 50 50 30 30 30 14 14 14 6 6 6
60594- 0 0 0 0 0 0 0 0 0 0 0 0
60595- 0 0 0 0 0 0 0 0 0 0 0 0
60596- 0 0 0 0 0 0 0 0 0 0 0 0
60597- 0 0 0 0 0 0 0 0 0 0 0 0
60598- 0 0 0 0 0 0 0 0 0 0 0 0
60599- 6 6 6 14 14 14 22 22 22 34 34 34
60600- 42 42 42 58 58 58 74 74 74 86 86 86
60601-101 98 89 122 102 70 130 98 46 121 87 25
60602-137 92 6 152 99 6 163 110 8 180 123 7
60603-185 133 11 197 138 11 206 145 10 200 144 11
60604-180 123 7 156 107 11 130 83 6 104 69 6
60605- 50 34 6 54 54 54 110 110 110 101 98 89
60606- 86 86 86 82 82 82 78 78 78 78 78 78
60607- 78 78 78 78 78 78 78 78 78 78 78 78
60608- 78 78 78 82 82 82 86 86 86 94 94 94
60609-106 106 106 101 101 101 86 66 34 124 80 6
60610-156 107 11 180 123 7 192 133 9 200 144 11
60611-206 145 10 200 144 11 192 133 9 175 118 6
60612-139 102 15 109 106 95 70 70 70 42 42 42
60613- 22 22 22 10 10 10 0 0 0 0 0 0
60614- 0 0 0 0 0 0 0 0 0 0 0 0
60615- 0 0 0 0 0 0 0 0 0 0 0 0
60616- 0 0 0 0 0 0 0 0 0 0 0 0
60617- 0 0 0 0 0 0 0 0 0 0 0 0
60618- 0 0 0 0 0 0 0 0 0 0 0 0
60619- 0 0 0 0 0 0 6 6 6 10 10 10
60620- 14 14 14 22 22 22 30 30 30 38 38 38
60621- 50 50 50 62 62 62 74 74 74 90 90 90
60622-101 98 89 112 100 78 121 87 25 124 80 6
60623-137 92 6 152 99 6 152 99 6 152 99 6
60624-138 86 6 124 80 6 98 70 6 86 66 30
60625-101 98 89 82 82 82 58 58 58 46 46 46
60626- 38 38 38 34 34 34 34 34 34 34 34 34
60627- 34 34 34 34 34 34 34 34 34 34 34 34
60628- 34 34 34 34 34 34 38 38 38 42 42 42
60629- 54 54 54 82 82 82 94 86 76 91 60 6
60630-134 86 6 156 107 11 167 114 7 175 118 6
60631-175 118 6 167 114 7 152 99 6 121 87 25
60632-101 98 89 62 62 62 34 34 34 18 18 18
60633- 6 6 6 0 0 0 0 0 0 0 0 0
60634- 0 0 0 0 0 0 0 0 0 0 0 0
60635- 0 0 0 0 0 0 0 0 0 0 0 0
60636- 0 0 0 0 0 0 0 0 0 0 0 0
60637- 0 0 0 0 0 0 0 0 0 0 0 0
60638- 0 0 0 0 0 0 0 0 0 0 0 0
60639- 0 0 0 0 0 0 0 0 0 0 0 0
60640- 0 0 0 6 6 6 6 6 6 10 10 10
60641- 18 18 18 22 22 22 30 30 30 42 42 42
60642- 50 50 50 66 66 66 86 86 86 101 98 89
60643-106 86 58 98 70 6 104 69 6 104 69 6
60644-104 69 6 91 60 6 82 62 34 90 90 90
60645- 62 62 62 38 38 38 22 22 22 14 14 14
60646- 10 10 10 10 10 10 10 10 10 10 10 10
60647- 10 10 10 10 10 10 6 6 6 10 10 10
60648- 10 10 10 10 10 10 10 10 10 14 14 14
60649- 22 22 22 42 42 42 70 70 70 89 81 66
60650- 80 54 7 104 69 6 124 80 6 137 92 6
60651-134 86 6 116 81 8 100 82 52 86 86 86
60652- 58 58 58 30 30 30 14 14 14 6 6 6
60653- 0 0 0 0 0 0 0 0 0 0 0 0
60654- 0 0 0 0 0 0 0 0 0 0 0 0
60655- 0 0 0 0 0 0 0 0 0 0 0 0
60656- 0 0 0 0 0 0 0 0 0 0 0 0
60657- 0 0 0 0 0 0 0 0 0 0 0 0
60658- 0 0 0 0 0 0 0 0 0 0 0 0
60659- 0 0 0 0 0 0 0 0 0 0 0 0
60660- 0 0 0 0 0 0 0 0 0 0 0 0
60661- 0 0 0 6 6 6 10 10 10 14 14 14
60662- 18 18 18 26 26 26 38 38 38 54 54 54
60663- 70 70 70 86 86 86 94 86 76 89 81 66
60664- 89 81 66 86 86 86 74 74 74 50 50 50
60665- 30 30 30 14 14 14 6 6 6 0 0 0
60666- 0 0 0 0 0 0 0 0 0 0 0 0
60667- 0 0 0 0 0 0 0 0 0 0 0 0
60668- 0 0 0 0 0 0 0 0 0 0 0 0
60669- 6 6 6 18 18 18 34 34 34 58 58 58
60670- 82 82 82 89 81 66 89 81 66 89 81 66
60671- 94 86 66 94 86 76 74 74 74 50 50 50
60672- 26 26 26 14 14 14 6 6 6 0 0 0
60673- 0 0 0 0 0 0 0 0 0 0 0 0
60674- 0 0 0 0 0 0 0 0 0 0 0 0
60675- 0 0 0 0 0 0 0 0 0 0 0 0
60676- 0 0 0 0 0 0 0 0 0 0 0 0
60677- 0 0 0 0 0 0 0 0 0 0 0 0
60678- 0 0 0 0 0 0 0 0 0 0 0 0
60679- 0 0 0 0 0 0 0 0 0 0 0 0
60680- 0 0 0 0 0 0 0 0 0 0 0 0
60681- 0 0 0 0 0 0 0 0 0 0 0 0
60682- 6 6 6 6 6 6 14 14 14 18 18 18
60683- 30 30 30 38 38 38 46 46 46 54 54 54
60684- 50 50 50 42 42 42 30 30 30 18 18 18
60685- 10 10 10 0 0 0 0 0 0 0 0 0
60686- 0 0 0 0 0 0 0 0 0 0 0 0
60687- 0 0 0 0 0 0 0 0 0 0 0 0
60688- 0 0 0 0 0 0 0 0 0 0 0 0
60689- 0 0 0 6 6 6 14 14 14 26 26 26
60690- 38 38 38 50 50 50 58 58 58 58 58 58
60691- 54 54 54 42 42 42 30 30 30 18 18 18
60692- 10 10 10 0 0 0 0 0 0 0 0 0
60693- 0 0 0 0 0 0 0 0 0 0 0 0
60694- 0 0 0 0 0 0 0 0 0 0 0 0
60695- 0 0 0 0 0 0 0 0 0 0 0 0
60696- 0 0 0 0 0 0 0 0 0 0 0 0
60697- 0 0 0 0 0 0 0 0 0 0 0 0
60698- 0 0 0 0 0 0 0 0 0 0 0 0
60699- 0 0 0 0 0 0 0 0 0 0 0 0
60700- 0 0 0 0 0 0 0 0 0 0 0 0
60701- 0 0 0 0 0 0 0 0 0 0 0 0
60702- 0 0 0 0 0 0 0 0 0 6 6 6
60703- 6 6 6 10 10 10 14 14 14 18 18 18
60704- 18 18 18 14 14 14 10 10 10 6 6 6
60705- 0 0 0 0 0 0 0 0 0 0 0 0
60706- 0 0 0 0 0 0 0 0 0 0 0 0
60707- 0 0 0 0 0 0 0 0 0 0 0 0
60708- 0 0 0 0 0 0 0 0 0 0 0 0
60709- 0 0 0 0 0 0 0 0 0 6 6 6
60710- 14 14 14 18 18 18 22 22 22 22 22 22
60711- 18 18 18 14 14 14 10 10 10 6 6 6
60712- 0 0 0 0 0 0 0 0 0 0 0 0
60713- 0 0 0 0 0 0 0 0 0 0 0 0
60714- 0 0 0 0 0 0 0 0 0 0 0 0
60715- 0 0 0 0 0 0 0 0 0 0 0 0
60716- 0 0 0 0 0 0 0 0 0 0 0 0
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+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60720+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60721+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60722+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60723+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60724+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60725+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60726+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60727+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60728+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60729+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4
60733+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60734+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60735+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60736+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60737+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60738+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60739+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60740+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60741+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60742+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60743+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60747+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60748+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60749+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60750+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60751+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60752+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60753+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60754+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60755+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60756+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60757+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60758+4 4 4 4 4 4
60759+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60760+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60761+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60762+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60763+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60764+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60765+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60766+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60767+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60768+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60769+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60770+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60771+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60772+4 4 4 4 4 4
60773+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60774+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60775+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60776+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60777+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60778+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60779+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60780+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60781+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60782+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60783+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60784+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60785+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60786+4 4 4 4 4 4
60787+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60788+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60789+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60790+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60791+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60792+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60793+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60794+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60795+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60796+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60797+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60798+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60799+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60800+4 4 4 4 4 4
60801+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60802+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60803+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60804+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60805+4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
60806+0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
60807+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60808+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60809+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60810+4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
60811+0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
60812+4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
60813+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60814+4 4 4 4 4 4
60815+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60816+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60817+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60818+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60819+4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
60820+37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
60821+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60822+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60823+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60824+4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
60825+2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
60826+4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
60827+1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60828+4 4 4 4 4 4
60829+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60830+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60831+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60832+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60833+2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
60834+153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
60835+0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
60836+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60837+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60838+4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
60839+60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
60840+4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
60841+2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
60842+4 4 4 4 4 4
60843+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60844+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60845+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60846+4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
60847+4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
60848+165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
60849+1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
60850+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60851+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
60852+3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
60853+163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
60854+0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
60855+37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
60856+4 4 4 4 4 4
60857+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60858+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60859+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60860+4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
60861+37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
60862+156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
60863+125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
60864+5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
60865+4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
60866+0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
60867+174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
60868+0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
60869+64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
60870+4 4 4 4 4 4
60871+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60872+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60873+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
60874+5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
60875+156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
60876+156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
60877+174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
60878+1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
60879+4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
60880+13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
60881+174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
60882+22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
60883+90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
60884+4 4 4 4 4 4
60885+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60886+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60887+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
60888+0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
60889+174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
60890+156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
60891+163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
60892+4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
60893+5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
60894+131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
60895+190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
60896+90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
60897+31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
60898+4 4 4 4 4 4
60899+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60900+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60901+4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
60902+4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
60903+155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
60904+167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
60905+153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
60906+41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
60907+1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
60908+177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
60909+125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
60910+136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
60911+7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
60912+4 4 4 4 4 4
60913+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60914+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60915+4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
60916+125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
60917+156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
60918+137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
60919+156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
60920+167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
60921+0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
60922+166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
60923+6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
60924+90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
60925+1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
60926+4 4 4 4 4 4
60927+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60928+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60929+1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
60930+167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
60931+157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
60932+26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
60933+158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
60934+165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
60935+60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
60936+137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
60937+52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
60938+13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
60939+4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
60940+4 4 4 4 4 4
60941+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60942+4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
60943+0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
60944+158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
60945+167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
60946+4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
60947+174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
60948+155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
60949+137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
60950+16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
60951+136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
60952+2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
60953+4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
60954+4 4 4 4 4 4
60955+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60956+4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
60957+37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
60958+157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
60959+153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
60960+4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
60961+125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
60962+156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
60963+174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
60964+4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
60965+136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
60966+1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
60967+2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
60968+0 0 0 4 4 4
60969+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
60970+4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
60971+158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
60972+153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
60973+37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
60974+4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
60975+4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
60976+154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
60977+174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
60978+32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
60979+28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
60980+50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
60981+0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
60982+2 0 0 0 0 0
60983+4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
60984+0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
60985+174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
60986+165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
60987+4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
60988+4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
60989+4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
60990+174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
60991+60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
60992+136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
60993+22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
60994+136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
60995+26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
60996+37 38 37 0 0 0
60997+4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
60998+13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
60999+153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
61000+177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
61001+4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
61002+5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
61003+6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
61004+166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
61005+4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
61006+146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
61007+71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
61008+90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
61009+125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
61010+85 115 134 4 0 0
61011+4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
61012+125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
61013+155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
61014+125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
61015+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
61016+0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
61017+5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
61018+37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
61019+4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
61020+90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
61021+2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
61022+13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
61023+166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
61024+60 73 81 4 0 0
61025+4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
61026+174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
61027+156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
61028+4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
61029+4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
61030+10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
61031+4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
61032+4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
61033+80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
61034+28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
61035+50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
61036+1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
61037+167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
61038+16 19 21 4 0 0
61039+4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
61040+158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
61041+167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
61042+4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
61043+4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
61044+80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
61045+4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
61046+3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
61047+146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
61048+68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
61049+136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
61050+24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
61051+163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
61052+4 0 0 4 3 3
61053+3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
61054+156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
61055+155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
61056+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
61057+2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
61058+136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
61059+0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
61060+0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
61061+136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
61062+28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
61063+22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
61064+137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
61065+60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
61066+3 2 2 4 4 4
61067+3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
61068+157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
61069+37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
61070+4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
61071+0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
61072+101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
61073+14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
61074+22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
61075+136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
61076+17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
61077+2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
61078+166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
61079+13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
61080+4 4 4 4 4 4
61081+1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
61082+163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
61083+4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
61084+4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
61085+40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
61086+101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
61087+101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
61088+136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
61089+136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
61090+136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
61091+3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
61092+174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
61093+4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
61094+4 4 4 4 4 4
61095+4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
61096+155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
61097+4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
61098+4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
61099+101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
61100+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
61101+136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
61102+136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
61103+136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
61104+90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
61105+85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
61106+167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
61107+6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
61108+5 5 5 5 5 5
61109+1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
61110+131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
61111+6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
61112+0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
61113+101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
61114+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
61115+101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
61116+136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
61117+101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
61118+7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
61119+174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
61120+24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
61121+4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
61122+5 5 5 4 4 4
61123+4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
61124+131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
61125+6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
61126+13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
61127+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
61128+101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
61129+101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
61130+136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
61131+136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
61132+2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
61133+174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
61134+4 0 0 4 0 0 5 5 5 5 5 5 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+1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
61138+137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
61139+4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
61140+64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
61141+90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
61142+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
61143+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
61144+136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
61145+101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
61146+37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
61147+167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
61148+3 3 3 5 5 5 6 6 6 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 41 54 63 137 136 137 153 152 153 137 136 137
61152+153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
61153+4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
61154+90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
61155+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
61156+90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
61157+101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
61158+101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
61159+35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
61160+154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
61161+60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 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+1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
61166+153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
61167+4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
61168+64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
61169+64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
61170+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
61171+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
61172+136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
61173+13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
61174+174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
61175+6 6 6 4 0 0 4 0 0 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 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
61180+156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
61181+4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
61182+90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
61183+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
61184+90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
61185+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
61186+101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
61187+2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
61188+174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
61189+4 0 0 4 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+3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
61194+158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
61195+4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
61196+37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
61197+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
61198+90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
61199+101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
61200+90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
61201+5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
61202+167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
61203+6 6 6 4 0 0 6 6 6 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 41 54 63 163 162 163 166 165 166 154 154 154
61208+163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
61209+4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
61210+18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
61211+64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
61212+90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
61213+101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
61214+13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
61215+3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
61216+174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
61217+4 0 0 3 2 2 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+1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
61222+167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
61223+4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
61224+18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
61225+26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
61226+90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
61227+101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
61228+7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
61229+4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
61230+174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
61231+4 0 0 4 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 167 166 167 174 174 174 163 162 163
61236+174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
61237+5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
61238+18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
61239+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61240+90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
61241+101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
61242+2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
61243+3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
61244+153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
61245+4 0 0 4 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+1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
61250+174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
61251+5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
61252+18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
61253+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61254+26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
61255+35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
61256+2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
61257+3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
61258+131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
61259+4 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+3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
61264+174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
61265+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
61266+18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
61267+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61268+26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
61269+7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
61270+4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
61271+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
61272+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
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+1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
61278+174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
61279+5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
61280+18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
61281+18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
61282+26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
61283+28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
61284+3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
61285+4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61286+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61287+0 0 0 3 3 3 5 5 5 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+4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
61292+174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
61293+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
61294+10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
61295+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61296+18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
61297+90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
61298+3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
61299+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
61300+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61301+0 0 0 3 3 3 5 5 5 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+1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
61306+177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
61307+5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
61308+10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
61309+26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
61310+6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
61311+10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
61312+2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
61313+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61314+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61315+0 0 0 3 3 3 5 5 5 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+4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
61320+177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
61321+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
61322+10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
61323+26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
61324+7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
61325+3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
61326+21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
61327+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
61328+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61329+0 0 0 3 3 3 5 5 5 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+3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
61334+190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
61335+5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
61336+10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
61337+24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
61338+18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
61339+28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
61340+26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
61341+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61342+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61343+0 0 0 3 3 3 5 5 5 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+4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
61348+190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
61349+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
61350+10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
61351+0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
61352+26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
61353+37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
61354+90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
61355+4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
61356+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61357+0 0 0 3 3 3 5 5 5 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+4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
61362+193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
61363+5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
61364+10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
61365+1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
61366+26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
61367+22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
61368+26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
61369+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61370+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61371+0 0 0 3 3 3 5 5 5 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 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
61376+190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
61377+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
61378+10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
61379+2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
61380+26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
61381+10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
61382+26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
61383+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
61384+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61385+0 0 0 3 3 3 5 5 5 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+4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
61390+193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
61391+5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
61392+10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
61393+13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
61394+10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
61395+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61396+26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
61397+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
61398+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61399+0 0 0 3 3 3 5 5 5 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 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
61404+190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
61405+5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
61406+28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
61407+10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
61408+28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
61409+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
61410+26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
61411+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
61412+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61413+0 0 0 3 3 3 5 5 5 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 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
61418+193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
61419+5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
61420+4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
61421+10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
61422+10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
61423+18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
61424+22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
61425+4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
61426+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61427+0 0 0 3 3 3 5 5 5 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 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
61432+190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
61433+6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
61434+1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
61435+18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
61436+10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
61437+26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
61438+1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
61439+5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
61440+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61441+0 0 0 3 3 3 5 5 5 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 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
61446+193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
61447+2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
61448+4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
61449+10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
61450+10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
61451+26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
61452+2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
61453+3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
61454+131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61455+0 0 0 3 3 3 5 5 5 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 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
61460+193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
61461+0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
61462+4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
61463+13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
61464+10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
61465+28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
61466+4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
61467+0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
61468+125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
61469+0 0 0 3 3 3 5 5 5 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 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
61474+193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
61475+120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
61476+4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
61477+4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
61478+10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
61479+4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
61480+4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
61481+24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
61482+125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
61483+0 0 0 3 3 3 5 5 5 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 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
61488+174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
61489+220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
61490+3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
61491+4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
61492+10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
61493+1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
61494+5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
61495+137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
61496+125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
61497+0 0 0 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+5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
61502+193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
61503+220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
61504+4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
61505+4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
61506+22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
61507+4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61508+1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
61509+166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
61510+125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
61511+4 3 3 5 5 5 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 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
61516+220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
61517+205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
61518+24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
61519+4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
61520+4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
61521+4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
61522+2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
61523+156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
61524+137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
61525+5 5 5 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+5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
61530+125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
61531+205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
61532+193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
61533+5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
61534+1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
61535+5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
61536+60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
61537+153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
61538+125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
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 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
61544+6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
61545+193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
61546+244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
61547+0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
61548+4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
61549+3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
61550+220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
61551+153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
61552+13 16 17 4 0 0 4 0 0 4 3 3 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+5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
61558+6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
61559+244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
61560+220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
61561+3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
61562+4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
61563+0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
61564+177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
61565+158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
61566+4 0 0 4 0 0 5 5 5 5 5 5 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+5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
61572+6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
61573+177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
61574+220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
61575+125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
61576+4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
61577+37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
61578+174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
61579+158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
61580+4 3 3 5 5 5 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 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
61586+4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
61587+26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
61588+205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
61589+244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
61590+0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
61591+177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
61592+174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
61593+60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
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+5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
61600+6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
61601+6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
61602+220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
61603+220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
61604+0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
61605+220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
61606+174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
61607+4 0 0 4 0 0 4 0 0 6 6 6 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 5 5 5 4 3 3 5 5 5 6 6 6
61614+6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
61615+4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
61616+220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
61617+205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
61618+60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
61619+177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
61620+190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
61621+4 0 0 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
61627+4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
61628+4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
61629+6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
61630+125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
61631+205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
61632+193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
61633+190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
61634+153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
61635+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61636+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61637+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61638+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61639+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61640+4 4 4 4 4 4
61641+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
61642+6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
61643+4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
61644+4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
61645+205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
61646+220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
61647+174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
61648+6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
61649+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61650+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61651+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61652+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61653+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61654+4 4 4 4 4 4
61655+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
61656+5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
61657+6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
61658+4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
61659+220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
61660+190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
61661+193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
61662+4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
61663+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61664+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61665+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61666+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61667+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61668+4 4 4 4 4 4
61669+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61670+4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
61671+4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
61672+6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
61673+174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
61674+193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
61675+193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
61676+6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
61677+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61678+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61679+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61680+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61681+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61682+4 4 4 4 4 4
61683+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61684+4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
61685+5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
61686+5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
61687+6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
61688+193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
61689+60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
61690+5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
61691+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61692+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61693+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61694+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61695+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61696+4 4 4 4 4 4
61697+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61698+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61699+4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
61700+5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
61701+4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
61702+193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
61703+6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
61704+4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
61705+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61706+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61707+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61708+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61709+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61710+4 4 4 4 4 4
61711+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61712+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61713+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
61714+4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
61715+6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
61716+153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
61717+6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
61718+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61719+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61720+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61721+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61722+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61723+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61724+4 4 4 4 4 4
61725+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61726+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61727+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61728+4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
61729+6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
61730+24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
61731+6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
61732+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61733+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61734+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61735+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61736+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61737+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61738+4 4 4 4 4 4
61739+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61740+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61741+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61742+4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
61743+4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
61744+6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
61745+4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
61746+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61747+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61748+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61749+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61750+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61751+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61752+4 4 4 4 4 4
61753+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61754+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61755+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61756+4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
61757+5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
61758+6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
61759+6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
61760+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61761+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61762+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61763+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61764+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61765+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61766+4 4 4 4 4 4
61767+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61768+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61769+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61770+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
61771+4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
61772+4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
61773+6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
61774+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61775+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61776+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61777+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61778+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61779+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61780+4 4 4 4 4 4
61781+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61782+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61783+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61784+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61785+4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
61786+6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
61787+4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
61788+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61789+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61790+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61791+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61792+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61793+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61794+4 4 4 4 4 4
61795+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61796+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61797+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61798+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61799+4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
61800+4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
61801+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61802+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61803+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61804+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61805+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61806+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61807+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61808+4 4 4 4 4 4
61809+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61810+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61811+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61812+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61813+4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
61814+5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
61815+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61816+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61817+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61818+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61819+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61820+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61821+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61822+4 4 4 4 4 4
61823+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61824+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61825+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61826+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61827+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
61828+5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
61829+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61830+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61831+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61832+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61833+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61834+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61835+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
61836+4 4 4 4 4 4
61837diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
61838index 96093ae..b9eed29 100644
61839--- a/drivers/xen/events/events_base.c
61840+++ b/drivers/xen/events/events_base.c
61841@@ -1568,7 +1568,7 @@ void xen_irq_resume(void)
61842 restore_pirqs();
61843 }
61844
61845-static struct irq_chip xen_dynamic_chip __read_mostly = {
61846+static struct irq_chip xen_dynamic_chip = {
61847 .name = "xen-dyn",
61848
61849 .irq_disable = disable_dynirq,
61850@@ -1582,7 +1582,7 @@ static struct irq_chip xen_dynamic_chip __read_mostly = {
61851 .irq_retrigger = retrigger_dynirq,
61852 };
61853
61854-static struct irq_chip xen_pirq_chip __read_mostly = {
61855+static struct irq_chip xen_pirq_chip = {
61856 .name = "xen-pirq",
61857
61858 .irq_startup = startup_pirq,
61859@@ -1602,7 +1602,7 @@ static struct irq_chip xen_pirq_chip __read_mostly = {
61860 .irq_retrigger = retrigger_dynirq,
61861 };
61862
61863-static struct irq_chip xen_percpu_chip __read_mostly = {
61864+static struct irq_chip xen_percpu_chip = {
61865 .name = "xen-percpu",
61866
61867 .irq_disable = disable_dynirq,
61868diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
61869index 00f40f0..e3c0b15 100644
61870--- a/drivers/xen/evtchn.c
61871+++ b/drivers/xen/evtchn.c
61872@@ -201,8 +201,8 @@ static ssize_t evtchn_read(struct file *file, char __user *buf,
61873
61874 /* Byte lengths of two chunks. Chunk split (if any) is at ring wrap. */
61875 if (((c ^ p) & EVTCHN_RING_SIZE) != 0) {
61876- bytes1 = (EVTCHN_RING_SIZE - EVTCHN_RING_MASK(c)) *
61877- sizeof(evtchn_port_t);
61878+ bytes1 = EVTCHN_RING_SIZE - EVTCHN_RING_MASK(c);
61879+ bytes1 *= sizeof(evtchn_port_t);
61880 bytes2 = EVTCHN_RING_MASK(p) * sizeof(evtchn_port_t);
61881 } else {
61882 bytes1 = (p - c) * sizeof(evtchn_port_t);
61883diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
61884index fef20db..d28b1ab 100644
61885--- a/drivers/xen/xenfs/xenstored.c
61886+++ b/drivers/xen/xenfs/xenstored.c
61887@@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
61888 static int xsd_kva_open(struct inode *inode, struct file *file)
61889 {
61890 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
61891+#ifdef CONFIG_GRKERNSEC_HIDESYM
61892+ NULL);
61893+#else
61894 xen_store_interface);
61895+#endif
61896+
61897 if (!file->private_data)
61898 return -ENOMEM;
61899 return 0;
61900diff --git a/firmware/Makefile b/firmware/Makefile
61901index e297e1b..aeb0982 100644
61902--- a/firmware/Makefile
61903+++ b/firmware/Makefile
61904@@ -35,9 +35,11 @@ fw-shipped-$(CONFIG_BNX2X) += bnx2x/bnx2x-e1-6.2.9.0.fw \
61905 bnx2x/bnx2x-e1h-6.2.9.0.fw \
61906 bnx2x/bnx2x-e2-6.2.9.0.fw
61907 fw-shipped-$(CONFIG_BNX2) += bnx2/bnx2-mips-09-6.2.1a.fw \
61908+ bnx2/bnx2-mips-09-6.2.1b.fw \
61909 bnx2/bnx2-rv2p-09-6.0.17.fw \
61910 bnx2/bnx2-rv2p-09ax-6.0.17.fw \
61911 bnx2/bnx2-mips-06-6.2.1.fw \
61912+ bnx2/bnx2-mips-06-6.2.3.fw \
61913 bnx2/bnx2-rv2p-06-6.0.15.fw
61914 fw-shipped-$(CONFIG_CASSINI) += sun/cassini.bin
61915 fw-shipped-$(CONFIG_CHELSIO_T3) += cxgb3/t3b_psram-1.1.0.bin \
61916diff --git a/firmware/WHENCE b/firmware/WHENCE
61917index 0c4d96d..b17700f 100644
61918--- a/firmware/WHENCE
61919+++ b/firmware/WHENCE
61920@@ -653,21 +653,23 @@ Found in hex form in kernel source.
61921 Driver: BNX2 - Broadcom NetXtremeII
61922
61923 File: bnx2/bnx2-mips-06-6.2.1.fw
61924+File: bnx2/bnx2-mips-06-6.2.3.fw
61925 File: bnx2/bnx2-rv2p-06-6.0.15.fw
61926 File: bnx2/bnx2-mips-09-6.2.1a.fw
61927+File: bnx2/bnx2-mips-09-6.2.1b.fw
61928 File: bnx2/bnx2-rv2p-09-6.0.17.fw
61929 File: bnx2/bnx2-rv2p-09ax-6.0.17.fw
61930
61931 Licence:
61932-
61933- This file contains firmware data derived from proprietary unpublished
61934- source code, Copyright (c) 2004 - 2010 Broadcom Corporation.
61935-
61936- Permission is hereby granted for the distribution of this firmware data
61937- in hexadecimal or equivalent format, provided this copyright notice is
61938- accompanying it.
61939-
61940-Found in hex form in kernel source.
61941+
61942+ This file contains firmware data derived from proprietary unpublished
61943+ source code, Copyright (c) 2004 - 2010 Broadcom Corporation.
61944+
61945+ Permission is hereby granted for the distribution of this firmware data
61946+ in hexadecimal or equivalent format, provided this copyright notice is
61947+ accompanying it.
61948+
61949+Found in hex form in kernel source.
61950
61951 --------------------------------------------------------------------------
61952
61953diff --git a/firmware/bnx2/bnx2-mips-06-6.2.3.fw.ihex b/firmware/bnx2/bnx2-mips-06-6.2.3.fw.ihex
61954new file mode 100644
61955index 0000000..da72bf1
61956--- /dev/null
61957+++ b/firmware/bnx2/bnx2-mips-06-6.2.3.fw.ihex
61958@@ -0,0 +1,5804 @@
61959+:10000000080001180800000000004A68000000C84D
61960+:1000100000000000000000000000000008004A6826
61961+:100020000000001400004B30080000A00800000091
61962+:100030000000569400004B44080058200000008443
61963+:100040000000A1D808005694000001580000A25CEE
61964+:100050000800321008000000000072F00000A3B495
61965+:10006000000000000000000000000000080072F026
61966+:1000700000000024000116A40800049008000400F9
61967+:10008000000017D4000116C80000000000000000A6
61968+:100090000000000000000000000000000000000060
61969+:1000A000080000A80800000000003BFC00012E9C96
61970+:1000B0000000000000000000000000000000000040
61971+:1000C00000000000000000000A00004600000000E0
61972+:1000D000000000000000000D636F6D362E322E33DD
61973+:1000E0000000000006020302000000000000000300
61974+:1000F000000000C800000032000000030000000003
61975+:1001000000000000000000000000000000000000EF
61976+:1001100000000010000001360000EA600000000549
61977+:1001200000000000000000000000000000000008C7
61978+:1001300000000000000000000000000000000000BF
61979+:1001400000000000000000000000000000000000AF
61980+:10015000000000000000000000000000000000009F
61981+:10016000000000020000000000000000000000008D
61982+:10017000000000000000000000000000000000007F
61983+:10018000000000000000000000000010000000005F
61984+:10019000000000000000000000000000000000005F
61985+:1001A000000000000000000000000000000000004F
61986+:1001B000000000000000000000000000000000003F
61987+:1001C000000000000000000000000000000000002F
61988+:1001D000000000000000000000000000000000001F
61989+:1001E0000000000010000003000000000000000DEF
61990+:1001F0000000000D3C02080024424AA03C03080015
61991+:1002000024634B9CAC4000000043202B1480FFFD76
61992+:10021000244200043C1D080037BD7FFC03A0F021F0
61993+:100220003C100800261001183C1C0800279C4AA01E
61994+:100230000E000168000000000000000D27470100CB
61995+:1002400090E3000B2402001A94E5000814620028D1
61996+:10025000000020218CE200003C0308008C63004475
61997+:1002600094E60014000211C20002104030A4000203
61998+:10027000005A10212463000130A50004A446008028
61999+:100280003C010800AC23004410A000190004202BFE
62000+:100290008F4202B804410008240400013C02080017
62001+:1002A0008C420060244200013C010800AC22006046
62002+:1002B00003E00008008010218CE2002094E3001687
62003+:1002C00000002021AF4202808CE20004A743028498
62004+:1002D000AF4202883C021000AF4202B83C02080064
62005+:1002E0008C42005C244200013C010800AC22005C0E
62006+:1002F00003E00008008010212747010090E3000B75
62007+:100300002402000394E50008146200280000202164
62008+:100310008CE200003C0308008C63004494E6001467
62009+:10032000000211C20002104030A40002005A102145
62010+:100330002463000130A50004A44600803C010800AD
62011+:10034000AC23004410A000190004202B8F4202B8F7
62012+:1003500004410008240400013C0208008C420060B3
62013+:10036000244200013C010800AC22006003E00008C8
62014+:10037000008010218CE2002094E300160000202170
62015+:10038000AF4202808CE20004A7430284AF4202889D
62016+:100390003C021000AF4202B83C0208008C42005CF4
62017+:1003A000244200013C010800AC22005C03E000088C
62018+:1003B000008010218F4301002402010050620003DD
62019+:1003C000000311C20000000D000311C20002104022
62020+:1003D000005A1021A440008003E000080000102112
62021+:1003E0009362000003E00008AF80000003E0000813
62022+:1003F0000000102103E00008000010212402010089
62023+:1004000014820008000000003C0208008C4200FC3E
62024+:10041000244200013C010800AC2200FC0A0000DD7F
62025+:1004200030A200203C0208008C42008424420001DB
62026+:100430003C010800AC22008430A2002010400008DB
62027+:1004400030A300103C0208008C4201082442000145
62028+:100450003C010800AC22010803E000080000000095
62029+:1004600010600008000000003C0208008C420104FB
62030+:10047000244200013C010800AC22010403E0000812
62031+:10048000000000003C0208008C42010024420001F0
62032+:100490003C010800AC22010003E00008000000005D
62033+:1004A00027BDFFE8AFBF0010274401009483000878
62034+:1004B000306200041040001B306600028F4202B818
62035+:1004C00004410008240500013C0208008C42006041
62036+:1004D000244200013C010800AC2200600A0001290E
62037+:1004E0008FBF00108C82002094830016000028210A
62038+:1004F000AF4202808C820004A7430284AF4202888C
62039+:100500003C021000AF4202B83C0208008C42005C82
62040+:10051000244200013C010800AC22005C0A000129D1
62041+:100520008FBF001010C00006006028218F4401001A
62042+:100530000E0000CD000000000A0001282405000183
62043+:100540008F8200088F4301045043000700002821D8
62044+:100550008F4401000E0000CD000000008F42010416
62045+:10056000AF820008000028218FBF001000A01021DA
62046+:1005700003E0000827BD001827BDFFE8AFBF001447
62047+:10058000AFB00010974201083043700024022000F1
62048+:100590001062000B286220011440002F000010217F
62049+:1005A00024024000106200250000000024026000C8
62050+:1005B00010620026000010210A0001658FBF0014A0
62051+:1005C00027500100920200091040001A2403000184
62052+:1005D0003C0208008C420020104000160000182148
62053+:1005E0000E00049300000000960300083C0608007B
62054+:1005F00094C64B5E8E0400188F8200209605000C76
62055+:1006000000031C0000661825AC440000AC45000443
62056+:1006100024040001AC400008AC40000CAC400010C9
62057+:10062000AC400014AC4000180E0004B8AC43001CF1
62058+:10063000000018210A000164006010210E0003254B
62059+:10064000000000000A000164000010210E000EE905
62060+:1006500000000000000010218FBF00148FB00010B8
62061+:1006600003E0000827BD001827BDFFE0AFB2001867
62062+:100670003C036010AFBF001CAFB10014AFB000105E
62063+:100680008C6450002402FF7F3C1A800000822024EA
62064+:100690003484380C24020037AC6450003C1208004B
62065+:1006A00026524AD8AF42000824020C80AF420024F0
62066+:1006B0003C1B80083C06080024C60324024010218D
62067+:1006C0002404001D2484FFFFAC4600000481FFFDCC
62068+:1006D000244200043C020800244204B03C0108000B
62069+:1006E000AC224AE03C020800244202303C010800EF
62070+:1006F000AC224AE43C020800244201743C03080096
62071+:100700002463032C3C040800248403D83C0508001F
62072+:1007100024A538F03C010800AC224B403C02080004
62073+:10072000244202EC3C010800AC264B243C010800AA
62074+:10073000AC254B343C010800AC234B3C3C01080089
62075+:10074000AC244B443C010800AC224B483C0108005F
62076+:10075000AC234ADC3C010800AC204AE83C0108001C
62077+:10076000AC204AEC3C010800AC204AF03C010800F7
62078+:10077000AC204AF43C010800AC204AF83C010800D7
62079+:10078000AC204AFC3C010800AC204B003C010800B6
62080+:10079000AC244B043C010800AC204B083C01080091
62081+:1007A000AC204B0C3C010800AC204B103C01080075
62082+:1007B000AC204B143C010800AC204B183C01080055
62083+:1007C000AC264B1C3C010800AC264B203C01080029
62084+:1007D000AC254B303C010800AC234B380E000623FF
62085+:1007E000000000003C028000344200708C42000097
62086+:1007F000AF8200143C0308008C6300208F82000449
62087+:10080000104300043C0280000E00045BAF83000430
62088+:100810003C028000344600703C0308008C6300A05A
62089+:100820003C0208008C4200A4104300048F84001492
62090+:100830003C010800AC2300A4A743009E8CCA000022
62091+:100840003C0308008C6300BC3C0208008C4200B8EA
62092+:100850000144202300641821000040210064202B63
62093+:1008600000481021004410213C010800AC2300BCCA
62094+:100870003C010800AC2200B88F5100003222000772
62095+:100880001040FFDCAF8A00148CC600003C05080055
62096+:100890008CA500BC3C0408008C8400B800CA30233E
62097+:1008A00000A628210000102100A6302B0082202164
62098+:1008B00000862021322700013C010800AC2500BC45
62099+:1008C0003C010800AC2400B810E0001F32220002F6
62100+:1008D0008F420100AF4200208F420104AF4200A8C6
62101+:1008E0009342010B0E0000C6305000FF2E02001E86
62102+:1008F00054400004001010800E0000C90A000213CA
62103+:1009000000000000005210218C4200000040F80955
62104+:1009100000000000104000053C0240008F4301042D
62105+:100920003C026020AC4300143C024000AF4201385E
62106+:100930003C0208008C420034244200013C010800C3
62107+:10094000AC220034322200021040000E3222000499
62108+:100950008F4201400E0000C6AF4200200E000295FB
62109+:10096000000000003C024000AF4201783C02080059
62110+:100970008C420038244200013C010800AC220038BF
62111+:10098000322200041040FF983C0280008F42018018
62112+:100990000E0000C6AF4200208F43018024020F00EA
62113+:1009A00014620005000000008F420188A742009CED
62114+:1009B0000A0002483C0240009362000024030050F9
62115+:1009C000304200FF144300083C0240000E00027B4E
62116+:1009D00000000000544000043C0240000E000D7571
62117+:1009E000000000003C024000AF4201B83C02080099
62118+:1009F0008C42003C244200013C010800AC22003C37
62119+:100A00000A0001C83C0280003C0290003442000110
62120+:100A100000822025AF4400208F4200200440FFFECA
62121+:100A20000000000003E00008000000003C0280001D
62122+:100A3000344200010082202503E00008AF4400207A
62123+:100A400027BDFFE0AFB10014AFB0001000808821D7
62124+:100A5000AFBF00180E00025030B000FF9362007D5F
62125+:100A60000220202102028025A370007D8F70007477
62126+:100A70003C0280000E000259020280241600000988
62127+:100A80008FBF00188F4201F80440FFFE24020002CD
62128+:100A9000AF5101C0A34201C43C021000AF4201F8B3
62129+:100AA0008FBF00188FB100148FB0001003E0000852
62130+:100AB00027BD002027BDFFE8AFBF0010974201848B
62131+:100AC0008F440188304202001040000500002821B8
62132+:100AD0000E000FAA000000000A00028D240500018C
62133+:100AE0003C02FF0004800005008218243C02040040
62134+:100AF000506200019362003E240500018FBF001088
62135+:100B000000A0102103E0000827BD0018A360002208
62136+:100B10008F4401400A00025E2405000127BDFFE862
62137+:100B2000AFBF0014AFB0001093620000304400FF6C
62138+:100B300038830020388200300003182B0002102B6D
62139+:100B40000062182410600003240200501482008008
62140+:100B50008FBF001493620005304200011040007CFA
62141+:100B60008FBF0014934201482443FFFF2C6200050D
62142+:100B7000104000788FB00010000310803C03080084
62143+:100B800024634A68004310218C42000000400008A2
62144+:100B9000000000000E0002508F4401408F70000CD6
62145+:100BA0008F4201441602000224020001AF62000CD1
62146+:100BB0000E0002598F4401408F420144145000043A
62147+:100BC0008FBF00148FB000100A000F2027BD00183F
62148+:100BD0008F62000C0A0003040000000097620010FE
62149+:100BE0008F4301443042FFFF1462001A00000000EE
62150+:100BF00024020001A76200108F4202380443001053
62151+:100C00008F4201403C02003F3446F0003C0560004A
62152+:100C10003C04FFC08CA22BBC0044182400461024C6
62153+:100C20000002130200031D82106200390000000060
62154+:100C30008F4202380440FFF7000000008F4201405D
62155+:100C4000AF4202003C021000AF4202380A00032209
62156+:100C50008FBF0014976200100A0003040000000018
62157+:100C60000E0002508F440140976200128F430144EE
62158+:100C70003050FFFF1603000224020001A762001299
62159+:100C80000E0002598F4401408F42014416020004B5
62160+:100C90008FBF00148FB000100A00029127BD00180A
62161+:100CA000976200120A00030400000000976200141B
62162+:100CB0008F4301443042FFFF14620006240200010A
62163+:100CC0008FBF00148FB00010A76200140A00124AF0
62164+:100CD00027BD0018976200141440001D8FBF001438
62165+:100CE0000A00031C00000000976200168F430144B5
62166+:100CF0003042FFFF1462000B240200018FBF00147A
62167+:100D00008FB00010A76200160A000B1227BD001852
62168+:100D10009742007824420004A76200100A000322D0
62169+:100D20008FBF001497620016240300013042FFFFBA
62170+:100D3000144300078FBF00143C0208008C4200706F
62171+:100D4000244200013C010800AC2200708FBF001457
62172+:100D50008FB0001003E0000827BD001827BDFFE892
62173+:100D6000AFBF0014AFB000108F50010093620000BD
62174+:100D700093430109304400FF2402001F106200A5C4
62175+:100D80002862002010400018240200382862000A5F
62176+:100D90001040000C2402000B286200081040002CB8
62177+:100DA00000000000046000E52862000214400028F2
62178+:100DB00024020006106200268FBF00140A00041FE0
62179+:100DC0008FB000101062005E2862000B144000DC3F
62180+:100DD0008FBF00142402000E106200738FB0001049
62181+:100DE0000A00041F00000000106200C028620039E1
62182+:100DF0001040000A2402008024020036106200CA5B
62183+:100E000028620037104000B424020035106200C18F
62184+:100E10008FBF00140A00041F8FB000101062002B57
62185+:100E20002862008110400006240200C82402003914
62186+:100E3000106200B48FBF00140A00041F8FB00010AE
62187+:100E4000106200998FBF00140A00041F8FB00010B9
62188+:100E50003C0208008C420020104000B98FBF0014F3
62189+:100E60000E000493000000008F4201008F830020D9
62190+:100E70009745010C97460108AC6200008F420104BF
62191+:100E80003C04080094844B5E00052C00AC62000416
62192+:100E90008F4201180006340000C43025AC620008FF
62193+:100EA0008F42011C24040001AC62000C9342010A31
62194+:100EB00000A22825AC650010AC600014AC600018DE
62195+:100EC000AC66001C0A0003F58FBF00143C0208004A
62196+:100ED0008C4200201040009A8FBF00140E00049333
62197+:100EE00000000000974401083C03080094634B5E37
62198+:100EF0009745010C000422029746010E8F820020C4
62199+:100F0000000426000083202500052C003C030080FF
62200+:100F100000A6282500832025AC400000AC4000043A
62201+:100F2000AC400008AC40000CAC450010AC400014D4
62202+:100F3000AC400018AC44001C0A0003F42404000177
62203+:100F40009742010C14400015000000009362000558
62204+:100F50003042001014400011000000000E0002504A
62205+:100F6000020020219362000502002021344200107B
62206+:100F70000E000259A36200059362000024030020C2
62207+:100F8000304200FF1043006D020020218FBF00148B
62208+:100F90008FB000100A000FC027BD00180000000D20
62209+:100FA0000A00041E8FBF00143C0208008C4200207F
62210+:100FB000104000638FBF00140E0004930000000077
62211+:100FC0008F4201048F8300209744010C3C050800E8
62212+:100FD00094A54B5EAC6200009762002C00042400D4
62213+:100FE0003042FFFF008220253C02400E00A228254F
62214+:100FF000AC640004AC600008AC60000CAC60001095
62215+:10100000AC600014AC600018AC65001C0A0003F46E
62216+:10101000240400010E00025002002021A7600008F5
62217+:101020000E00025902002021020020210E00025E63
62218+:10103000240500013C0208008C42002010400040C2
62219+:101040008FBF00140E000493000000009742010CB3
62220+:101050008F8300203C05080094A54B5E000214001D
62221+:10106000AC700000AC620004AC6000088F64004CFF
62222+:101070003C02401F00A22825AC64000C8F62005087
62223+:1010800024040001AC6200108F620054AC620014B2
62224+:10109000AC600018AC65001C8FBF00148FB000104E
62225+:1010A0000A0004B827BD0018240200205082002541
62226+:1010B0008FB000100E000F0A020020211040002007
62227+:1010C0008FBF0014020020218FB0001000002821E3
62228+:1010D0000A00025E27BD0018020020218FBF001405
62229+:1010E0008FB000100A00058027BD00189745010C3D
62230+:1010F000020020218FBF00148FB000100A0005A04D
62231+:1011000027BD0018020020218FB000100A0005C57D
62232+:1011100027BD00189345010D020020218FB000105B
62233+:101120000A00060F27BD0018020020218FBF0014FF
62234+:101130008FB000100A0005EB27BD00188FBF001408
62235+:101140008FB0001003E0000827BD00188F4202781E
62236+:101150000440FFFE2402000234840080AF440240B9
62237+:10116000A34202443C02100003E00008AF420278B0
62238+:101170003C04080094844B6A3C0208008C424B7487
62239+:101180003083FFFF000318C000431021AF42003C32
62240+:101190003C0208008C424B70AF4200383C020050C9
62241+:1011A00034420008AF4200300000000000000000A0
62242+:1011B000000000008F420000304200201040FFFD80
62243+:1011C000000000008F4204003C010800AC224B608C
62244+:1011D0008F4204043C010800AC224B643C02002016
62245+:1011E000AF420030000000003C02080094424B680F
62246+:1011F0003C03080094634B6C3C05080094A54B6EBF
62247+:1012000024840001004310213083FFFF3C010800CB
62248+:10121000A4224B683C010800A4244B6A1465000317
62249+:10122000000000003C010800A4204B6A03E0000815
62250+:10123000000000003C05000A27BDFFE80345282107
62251+:101240003C04080024844B50AFBF00100E00051D65
62252+:101250002406000A3C02080094424B523C0308005A
62253+:1012600094634B6E3042000F244200030043180485
62254+:1012700024027FFF0043102B10400002AF83001CAC
62255+:101280000000000D0E00042A000000003C020800CF
62256+:1012900094424B5A8FBF001027BD001803E000088E
62257+:1012A000A74200A23C02000A034210219443000618
62258+:1012B0003C02080094424B5A3C010800A4234B56C0
62259+:1012C000004310238F83001C00021400000214034B
62260+:1012D0000043102B03E000083842000127BDFFE85F
62261+:1012E000AFBF00103C02000A0342102194420006E6
62262+:1012F0003C010800A4224B560E00047700000000B9
62263+:101300005440FFF93C02000A8FBF001003E00008C0
62264+:1013100027BD001827BDFFE8AFBF00100E000477FF
62265+:101320000000000010400003000000000E000485D3
62266+:10133000000000003C0208008C424B608FBF001090
62267+:1013400027430400AF4200383C0208008C424B6443
62268+:1013500027BD0018AF830020AF42003C3C020005CF
62269+:10136000AF42003003E00008AF8000188F82001801
62270+:101370003C0300060002114000431025AF4200303C
62271+:101380000000000000000000000000008F4200008C
62272+:10139000304200101040FFFD27420400AF820020C1
62273+:1013A00003E00008AF8000183C0608008CC64B64C0
62274+:1013B0008F8500188F8300203C02080094424B5A0E
62275+:1013C00027BDFFE024A50001246300202442000182
62276+:1013D00024C70020AFB10014AFB00010AFBF001899
62277+:1013E000AF850018AF8300203C010800A4224B5AAF
62278+:1013F000309000FF3C010800AC274B6404C100089A
62279+:101400000000882104E00006000000003C02080003
62280+:101410008C424B60244200013C010800AC224B602E
62281+:101420003C02080094424B5A3C03080094634B680A
62282+:101430000010202B004310262C42000100441025F0
62283+:10144000144000048F830018240200101462000F5F
62284+:10145000000000000E0004A9241100013C03080054
62285+:1014600094634B5A3C02080094424B681462000398
62286+:10147000000000000E00042A000000001600000317
62287+:10148000000000000E000493000000003C03080070
62288+:1014900094634B5E3C02080094424B5C2463000161
62289+:1014A0003064FFFF3C010800A4234B5E148200035C
62290+:1014B000000000003C010800A4204B5E1200000662
62291+:1014C000000000003C02080094424B5AA74200A2D0
62292+:1014D0000A00050B022010210E0004770000000016
62293+:1014E00010400004022010210E00048500000000BE
62294+:1014F000022010218FBF00188FB100148FB0001090
62295+:1015000003E0000827BD00203084FFFF30A5FFFF67
62296+:101510000000182110800007000000003082000148
62297+:101520001040000200042042006518210A00051343
62298+:101530000005284003E000080060102110C00006EC
62299+:1015400024C6FFFF8CA2000024A50004AC8200008A
62300+:101550000A00051D2484000403E0000800000000C8
62301+:1015600010A0000824A3FFFFAC86000000000000CC
62302+:10157000000000002402FFFF2463FFFF1462FFFA53
62303+:101580002484000403E0000800000000240200019D
62304+:10159000AF62000CA7620010A7620012A7620014DD
62305+:1015A00003E00008A76200163082007F034210218A
62306+:1015B0003C08000E004818213C0208008C42002024
62307+:1015C00027BDFFD82407FF80AFB3001CAFB20018BF
62308+:1015D000AFB10014AFB00010AFBF00200080802179
62309+:1015E00030B100FF0087202430D200FF1040002FD0
62310+:1015F00000009821AF44002C9062000024030050AA
62311+:10160000304200FF1443000E000000003C020800BE
62312+:101610008C4200E00202102100471024AF42002C4F
62313+:101620003C0208008C4200E0020210213042007FA0
62314+:101630000342102100481021944200D43053FFFF90
62315+:101640000E000493000000003C02080094424B5E30
62316+:101650008F8300200011340000C2302500122C00BE
62317+:101660003C02400000C2302534A50001AC700000EF
62318+:101670008FBF0020AC6000048FB20018AC7300086C
62319+:101680008FB10014AC60000C8FB3001CAC6500106F
62320+:101690008FB00010AC60001424040001AC6000188E
62321+:1016A00027BD00280A0004B8AC66001C8FBF0020CC
62322+:1016B0008FB3001C8FB200188FB100148FB00010D0
62323+:1016C00003E0000827BD00289343010F2402001007
62324+:1016D0001062000E2865001110A0000724020012FD
62325+:1016E000240200082405003A1062000600003021A0
62326+:1016F00003E0000800000000240500351462FFFC30
62327+:10170000000030210A000538000000008F420074FC
62328+:1017100024420FA003E00008AF62000C27BDFFE8E1
62329+:10172000AFBF00100E00025E240500018FBF001045
62330+:1017300024020001A762001227BD00182402000144
62331+:1017400003E00008A360002227BDFFE0AFB1001452
62332+:10175000AFB00010AFBF001830B1FFFF0E00025055
62333+:10176000008080219362003F24030004304200FF88
62334+:101770001443000C02002021122000082402000A59
62335+:101780000E00053100000000936200052403FFFEF7
62336+:1017900000431024A362000524020012A362003F4C
62337+:1017A000020020210E000259A360008116200003D0
62338+:1017B000020020210E0005950000000002002021FB
62339+:1017C000322600FF8FBF00188FB100148FB00010B9
62340+:1017D000240500380A00053827BD002027BDFFE09A
62341+:1017E000AFBF001CAFB20018AFB10014AFB0001013
62342+:1017F0000E000250008080210E0005310000000024
62343+:101800009362003F24120018305100FF123200038F
62344+:101810000200202124020012A362003F936200050F
62345+:101820002403FFFE004310240E000259A3620005AA
62346+:10183000020020212405002016320007000030217C
62347+:101840008FBF001C8FB200188FB100148FB0001032
62348+:101850000A00025E27BD00208FBF001C8FB2001857
62349+:101860008FB100148FB00010240500390A0005382C
62350+:1018700027BD002027BDFFE8AFB00010AFBF0014A8
62351+:101880009742010C2405003600808021144000108E
62352+:10189000304600FF0E00025000000000240200123B
62353+:1018A000A362003F93620005344200100E00053130
62354+:1018B000A36200050E00025902002021020020212F
62355+:1018C0000E00025E240500200A000604000000004D
62356+:1018D0000E000538000000000E000250020020211A
62357+:1018E000936200232403FF9F020020210043102461
62358+:1018F0008FBF00148FB00010A36200230A000259AA
62359+:1019000027BD001827BDFFE0AFBF0018AFB100141E
62360+:10191000AFB0001030B100FF0E00025000808021F7
62361+:10192000240200120E000531A362003F0E0002598E
62362+:101930000200202102002021022030218FBF001848
62363+:101940008FB100148FB00010240500350A0005384F
62364+:1019500027BD0020A380002C03E00008A380002DF9
62365+:101960008F4202780440FFFE8F820034AF42024073
62366+:1019700024020002A34202443C02100003E00008DB
62367+:10198000AF4202783C0360008C6254003042000891
62368+:101990001440FFFD000000008C625408AF82000C70
62369+:1019A00024020052AC605408AC645430AC6254342D
62370+:1019B0002402000803E00008AC6254003C0260000E
62371+:1019C0008C42540030420008104000053C03600087
62372+:1019D0008C625400304200081440FFFD00000000FB
62373+:1019E0008F83000C3C02600003E00008AC43540805
62374+:1019F00090A3000024020005008040213063003FD6
62375+:101A000000004821146200050000502190A2001C33
62376+:101A100094A3001E304900FF306AFFFFAD00000CA8
62377+:101A2000AD000010AD000024950200148D05001CCF
62378+:101A30008D0400183042FFFF0049102300021100FE
62379+:101A4000000237C3004038210086202300A2102B5B
62380+:101A50000082202300A72823AD05001CAD04001838
62381+:101A6000A5090014A5090020A50A001603E0000836
62382+:101A7000A50A00228F4201F80440FFFE2402000262
62383+:101A8000AF4401C0A34201C43C02100003E00008BF
62384+:101A9000AF4201F83C0208008C4200B427BDFFE8C9
62385+:101AA000AFBF001424420001AFB000103C01080099
62386+:101AB000AC2200B48F4300243C02001F30AA00FF78
62387+:101AC0003442FF8030D800FF006280240080F8217B
62388+:101AD00030EF00FF1158003B01405821240CFF80DB
62389+:101AE0003C19000A3163007F000310C00003194055
62390+:101AF000006218213C0208008C4200DC25680001CD
62391+:101B0000310D007F03E21021004310213043007F9C
62392+:101B100003431821004C102400794821AF420024CF
62393+:101B20008D220024016C1824006C7026AD22000C5C
62394+:101B30008D220024310800FFAD22001095220014F0
62395+:101B4000952300208D27001C3042FFFF3063FFFFEC
62396+:101B50008D2600180043102300021100000227C345
62397+:101B60000040282100C4302300E2102B00C23023A3
62398+:101B700000E53823AD27001CAD2600189522002073
62399+:101B8000A522001495220022154B000AA52200165A
62400+:101B90008D2300248D220008254600013145008058
62401+:101BA0001462000430C4007F108F000238AA008045
62402+:101BB00000C0502151AF000131C800FF1518FFC906
62403+:101BC000010058218F8400343082007F03421821A5
62404+:101BD0003C02000A006218212402FF8000822024B7
62405+:101BE000AF440024A06A0079A06A00838C62005090
62406+:101BF0008F840034AC6200708C6500743C027FFFFF
62407+:101C00003442FFFF00A228240E00066BAC6500746E
62408+:101C1000AF5000248FBF00148FB0001003E0000805
62409+:101C200027BD001827BDFFC0AFBE0038AFB70034D6
62410+:101C3000AFB5002CAFB20020AFB1001CAFB00018A0
62411+:101C4000AFBF003CAFB60030AFB40028AFB3002444
62412+:101C50008F4500248F4600288F43002C3C02001F34
62413+:101C60003442FF800062182400C230240080A82182
62414+:101C7000AFA3001400A2F0240E00062FAFA60010A0
62415+:101C80003C0208008C4200E02410FF8003608821A1
62416+:101C900002A2102100501024AF4200243C02080090
62417+:101CA0008C4200E002A210213042007F0342182142
62418+:101CB0003C02000A00629021924200D293630084A9
62419+:101CC000305700FF306300FF24020001106200342F
62420+:101CD000036020212402000214620036000000008C
62421+:101CE0000E001216024028219223008392220083C4
62422+:101CF0003063007F3042007F000210C000031940B3
62423+:101D0000006218213C0208008C4200DC02A2102173
62424+:101D10000043382100F01024AF42002892250078BB
62425+:101D20009224008330E2007F034218213C02000C21
62426+:101D300014850007006280212402FFFFA24200F107
62427+:101D40002402FFFFA64200F20A0007272402FFFF39
62428+:101D500096020020A24200F196020022A64200F262
62429+:101D60008E020024AE4200F492220083A24200F0D0
62430+:101D70008E4200C8AE4200FC8E4200C4AE4200F863
62431+:101D80008E220050AE4201008E4200CCAE420104D1
62432+:101D9000922200853042003F0A0007823442004010
62433+:101DA0000E00123902402821922200850A00078283
62434+:101DB0003042003F936200852403FFDF3042003F42
62435+:101DC000A36200859362008500431024A36200850E
62436+:101DD0009363008393620078307400FF304200FF09
62437+:101DE00010540036240AFF803C0C000C3283007F24
62438+:101DF000000310C000031940006218213C020800D3
62439+:101E00008C4200DC268800013109007F02A21021EB
62440+:101E10000043382130E2007F0342182100EA1024F9
62441+:101E2000AF420028006C80218E020024028A182410
62442+:101E3000006A5826AE02000C8E020024310800FF12
62443+:101E4000AE02001096020014960300208E07001CBC
62444+:101E50003042FFFF3063FFFF8E060018004310235F
62445+:101E600000021100000227C30040282100C43023D3
62446+:101E700000E2102B00C2302300E53823AE07001C1F
62447+:101E8000AE06001896020020A60200149602002258
62448+:101E9000A602001692220079304200FF105400077B
62449+:101EA0000000000051370001316800FF92220078E5
62450+:101EB000304200FF1448FFCD0100A0219222008390
62451+:101EC000A22200798E2200500A0007E2AE220070A2
62452+:101ED000A22200858E22004C2405FF80AE42010C18
62453+:101EE0009222008534420020A2220085924200D135
62454+:101EF0003C0308008C6300DC305400FF3C02080007
62455+:101F00008C4200E400143140001420C002A31821C8
62456+:101F100000C4202102A210210064382100461021B3
62457+:101F20000045182400E52824AF450028AF43002CC5
62458+:101F30003042007F924400D030E3007F03422821EA
62459+:101F4000034318213C02000C006280213C02000E79
62460+:101F5000309600FF00A298211296002A000000008F
62461+:101F60008E02000C02002021026028211040002572
62462+:101F7000261000280E00064A000000009262000DA4
62463+:101F800026830001307400FF3042007FA262000D02
62464+:101F90002404FF801697FFF0267300203C020800FF
62465+:101FA0008C4200DC0000A02102A210210044102479
62466+:101FB000AF4200283C0208008C4200E43C030800C9
62467+:101FC0008C6300DC02A2102100441024AF42002CDC
62468+:101FD0003C0208008C4200E402A318213063007F19
62469+:101FE00002A210213042007F034220210343182126
62470+:101FF0003C02000C006280213C02000E0A0007A493
62471+:10200000008298218E4200D8AE2200508E4200D825
62472+:10201000AE22007092250083924600D19223008365
62473+:10202000924400D12402FF8000A228243063007F64
62474+:10203000308400FF00A628250064182A10600002E2
62475+:1020400030A500FF38A50080A2250083A2250079D5
62476+:102050000E00063D000000009222007E02A020211A
62477+:10206000A222007A8E2300743C027FFF3442FFFFDD
62478+:10207000006218240E00066BAE2300748FA20010BD
62479+:10208000AF5E00248FBF003CAF4200288FBE0038F7
62480+:102090008FA200148FB700348FB600308FB5002C9C
62481+:1020A0008FB400288FB300248FB200208FB1001CA2
62482+:1020B0008FB0001827BD004003E00008AF42002C9D
62483+:1020C00090A2000024420001A0A200003C030800EE
62484+:1020D0008C6300F4304200FF1443000F0080302175
62485+:1020E000A0A000003C0208008C4200E48F84003471
62486+:1020F000008220213082007F034218213C02000C24
62487+:10210000006218212402FF8000822024ACC300005A
62488+:1021100003E00008AF4400288C8200002442002025
62489+:1021200003E00008AC82000094C200003C080800F4
62490+:10213000950800CA30E7FFFF008048210102102106
62491+:10214000A4C2000094C200003042FFFF00E2102B46
62492+:1021500054400001A4C7000094A200003C03080002
62493+:102160008C6300CC24420001A4A2000094A20000D1
62494+:102170003042FFFF544300078F8600280107102BD1
62495+:10218000A4A000005440000101003821A4C70000B1
62496+:102190008F8600288CC4001CAF44003C94A2000031
62497+:1021A0008F43003C3042FFFF000210C00062182144
62498+:1021B000AF43003C8F42003C008220231880000483
62499+:1021C000000000008CC200180A00084324420001ED
62500+:1021D0008CC20018AF4200383C020050344200105C
62501+:1021E000AF420030000000000000000000000000CE
62502+:1021F0008F420000304200201040FFFD0000000030
62503+:102200008F420404AD2200048F420400AD2200007E
62504+:102210003C020020AF42003003E000080000000054
62505+:1022200027BDFFE0AFB20018AFB10014AFB000108F
62506+:10223000AFBF001C94C2000000C080213C12080007
62507+:10224000965200C624420001A60200009603000038
62508+:1022500094E2000000E03021144300058FB100300B
62509+:102260000E000818024038210A000875000000001E
62510+:102270008C8300048C820004244200400461000727
62511+:10228000AC8200048C8200040440000400000000C2
62512+:102290008C82000024420001AC8200009602000003
62513+:1022A0003042FFFF50520001A600000096220000BD
62514+:1022B00024420001A62200008F82002896230000FD
62515+:1022C00094420016144300048FBF001C2402000136
62516+:1022D000A62200008FBF001C8FB200188FB100141F
62517+:1022E0008FB0001003E0000827BD00208F89002870
62518+:1022F00027BDFFE0AFBF00188D220028274804004B
62519+:1023000030E700FFAF4200388D22002CAF8800304C
62520+:10231000AF42003C3C020005AF420030000000002C
62521+:1023200000000000000000000000000000000000AD
62522+:10233000000000008C82000C8C82000CAD020000BA
62523+:102340008C820010AD0200048C820018AD020008DF
62524+:102350008C82001CAD02000C8CA20014AD02001097
62525+:102360008C820020AD02001490820005304200FFF4
62526+:1023700000021200AD0200188CA20018AD02001C71
62527+:102380008CA2000CAD0200208CA20010AD02002433
62528+:102390008CA2001CAD0200288CA20020AD02002CF3
62529+:1023A000AD060030AD000034978300263402FFFFF5
62530+:1023B00014620002006020213404FFFF10E00011CD
62531+:1023C000AD04003895230036952400362402000120
62532+:1023D0003063FFFF000318C20069182190650040B8
62533+:1023E000308400070082100400451025A0620040E0
62534+:1023F0008F820028944200563042FFFF0A0008DC1A
62535+:10240000AD02003C952300369524003624020001DD
62536+:102410003063FFFF000318C2006918219065004077
62537+:1024200030840007008210040002102700451024A9
62538+:10243000A0620040AD00003C000000000000000071
62539+:10244000000000003C02000634420040AF42003071
62540+:102450000000000000000000000000008F420000AB
62541+:10246000304200101040FFFD8F860028AF880030FA
62542+:1024700024C2005624C7003C24C4002824C50032CE
62543+:1024800024C600360E000856AFA200108FBF0018F9
62544+:1024900003E0000827BD00208F8300243C060800CD
62545+:1024A0008CC600E88F82003430633FFF0003198040
62546+:1024B00000461021004310212403FF803046007F96
62547+:1024C00000431024AF420028034618213C02000CB0
62548+:1024D0000062302190C2000D30A500FF00003821BD
62549+:1024E00034420010A0C2000D8F8900288F8A00247A
62550+:1024F00095230036000A13823048000324020001AD
62551+:10250000A4C3000E1102000B2902000210400005B6
62552+:10251000240200021100000C240300010A0009201B
62553+:102520000000182111020006000000000A00092026
62554+:10253000000018218CC2002C0A000920244300014D
62555+:102540008CC20014244300018CC200180043102BDD
62556+:1025500050400009240700012402002714A20003B0
62557+:10256000000000000A00092C240700019522003E0B
62558+:1025700024420001A522003E000A138230430003DA
62559+:102580002C62000210400009008028211460000421
62560+:102590000000000094C200360A00093C3046FFFFEC
62561+:1025A0008CC600380A00093C008028210000302138
62562+:1025B0003C04080024844B780A00088900000000CD
62563+:1025C000274901008D22000C9523000601202021BF
62564+:1025D000000216023046003F3063FFFF240200274E
62565+:1025E00000C0282128C7002810C2000EAF83002495
62566+:1025F00010E00008240200312402002110C200096A
62567+:102600002402002510C200079382002D0A00095BF6
62568+:102610000000000010C200059382002D0A00095B33
62569+:10262000000000000A0008F4000000000A0006266E
62570+:102630000000000095230006912400058D25000C64
62571+:102640008D2600108D2700188D28001C8D29002054
62572+:10265000244200013C010800A4234B7E3C010800F9
62573+:10266000A0244B7D3C010800AC254B843C010800B4
62574+:10267000AC264B883C010800AC274B903C0108007D
62575+:10268000AC284B943C010800AC294B9803E00008AF
62576+:10269000A382002D8F87002827BDFFC0AFB3003471
62577+:1026A000AFB20030AFB1002CAFB00028AFBF0038E0
62578+:1026B0003C0208008C4200D094E3003030B0FFFFB1
62579+:1026C000005010073045FFFF3063FFFF00C0982126
62580+:1026D000A7A200103C110800963100C614A3000602
62581+:1026E0003092FFFF8CE2002424420030AF42003CD5
62582+:1026F0000A0009948CE2002094E200323042FFFF8D
62583+:1027000054A2000827A400188CE2002C24420030B8
62584+:10271000AF42003C8CE20028AF4200380A0009A218
62585+:102720008F84002827A5001027A60020022038212A
62586+:102730000E000818A7A000208FA200182442003025
62587+:10274000AF4200388FA2001CAF42003C8F840028AB
62588+:102750003C020005AF42003094820034274304005D
62589+:102760003042FFFF0202102B14400007AF830030FD
62590+:1027700094820054948300340202102100431023F9
62591+:102780000A0009B63043FFFF94830054948200345A
62592+:102790000223182100501023006218233063FFFF2A
62593+:1027A000948200163042FFFF144300030000000033
62594+:1027B0000A0009C424030001948200163042FFFF7E
62595+:1027C0000043102B104000058F82003094820016C9
62596+:1027D000006210233043FFFF8F820030AC530000B3
62597+:1027E000AC400004AC520008AC43000C3C020006B4
62598+:1027F00034420010AF420030000000000000000032
62599+:10280000000000008F420000304200101040FFFD29
62600+:10281000001018C2006418219065004032040007BF
62601+:10282000240200018FBF00388FB300348FB2003014
62602+:102830008FB1002C8FB000280082100400451025B5
62603+:1028400027BD004003E00008A062004027BDFFA8AC
62604+:10285000AFB60050AFB5004CAFB40048AFB30044C2
62605+:10286000AFB1003CAFBF0054AFB20040AFB00038D2
62606+:102870008C9000003C0208008C4200E88F860034F7
62607+:10288000960300022413FF8000C2302130633FFF13
62608+:102890000003198000C3382100F3102490B2000017
62609+:1028A000AF42002C9203000230E2007F034230214D
62610+:1028B0003C02000E00C28821306300C024020040A8
62611+:1028C0000080A82100A0B021146200260000A021F1
62612+:1028D0008E3400388E2200181440000224020001B9
62613+:1028E000AE2200189202000D304200201440001564
62614+:1028F0008F8200343C0308008C6300DC001238C077
62615+:10290000001231400043102100C730210046382119
62616+:1029100030E300073C02008030E6007800C230253A
62617+:102920000343182100F31024AF4208002463090078
62618+:10293000AF4608108E2200188C6300080043102157
62619+:10294000AE2200188E22002C8E2300182442000193
62620+:102950000062182B1060003D000000000A000A7899
62621+:1029600000000000920300022402FFC00043102474
62622+:10297000304200FF1440000524020001AE2200187E
62623+:10298000962200360A000A613054FFFF8E2200149E
62624+:1029900024420001AE22001892020000000216003C
62625+:1029A0000002160304410029000000009602000204
62626+:1029B00027A4001000802821A7A20016960200027A
62627+:1029C00024070001000030213042FFFFAF820024C5
62628+:1029D0000E000889AFA0001C960300023C0408000A
62629+:1029E0008C8400E88F82003430633FFF000319803D
62630+:1029F00000441021004310213043007F3C05000CAF
62631+:102A00000053102403431821AF4200280065182109
62632+:102A10009062000D001221403042007FA062000D44
62633+:102A20003C0308008C6300E48F82003400431021D3
62634+:102A30000044382130E2007F03421021004510217C
62635+:102A400000F31824AF430028AEA200009222000D2C
62636+:102A5000304200101040001302A020218F83002874
62637+:102A60008EA40000028030219462003E2442FFFFC9
62638+:102A7000A462003E948400029625000E3084FFFF7D
62639+:102A80000E00097330A5FFFF8F82002894430034A5
62640+:102A90009622000E1443000302A02021240200010C
62641+:102AA000A382002C02C028210E0007FE00000000B7
62642+:102AB0008FBF00548FB600508FB5004C8FB40048C4
62643+:102AC0008FB300448FB200408FB1003C8FB000380C
62644+:102AD00003E0000827BD00588F82002827BDFFD0E3
62645+:102AE000AFB40028AFB20020AFBF002CAFB30024BA
62646+:102AF000AFB1001CAFB00018904400D0904300D19B
62647+:102B00000000A021309200FFA3A30010306300FF5B
62648+:102B10008C5100D88C5300DC1072002B2402000171
62649+:102B20003C0308008C6300E493A400108F820034FF
62650+:102B30002406FF800004214000431021004410219E
62651+:102B40003043007F00461024AF4200280343182181
62652+:102B50003C02000C006218218C62000427A40014BF
62653+:102B600027A50010022280210270102304400015C6
62654+:102B7000AFA300149062000D00C21024304200FF89
62655+:102B800014400007020088219062000D344200408A
62656+:102B90000E0007FEA062000D0A000ABD93A20010FD
62657+:102BA0000E0009E1241400018F830028AC7000D8C6
62658+:102BB00093A20010A06200D193A200101452FFD87B
62659+:102BC0000000000024020001168200048FBF002CC8
62660+:102BD0000E000626000000008FBF002C8FB40028D6
62661+:102BE0008FB300248FB200208FB1001C8FB000186B
62662+:102BF00003E0000827BD003027BDFFD8AFB3001C9D
62663+:102C0000AFB20018AFB10014AFB00010AFBF0020DA
62664+:102C10000080982100E0802130B1FFFF0E00049376
62665+:102C200030D200FF000000000000000000000000A3
62666+:102C30008F820020AC510000AC520004AC5300085D
62667+:102C4000AC40000CAC400010AC400014AC4000188C
62668+:102C50003C03080094634B5E02038025AC50001CCB
62669+:102C6000000000000000000000000000240400013B
62670+:102C70008FBF00208FB3001C8FB200188FB10014DB
62671+:102C80008FB000100A0004B827BD002827BDFFE858
62672+:102C9000AFB00010AFBF001430A5FFFF30C600FF7B
62673+:102CA0000080802124020C80AF420024000000003C
62674+:102CB0000000000000000000000000000000000014
62675+:102CC0000E000ACC000000003C040800248400E050
62676+:102CD0008C8200002403FF808FBF001402021021A9
62677+:102CE00000431024AF4200248C8200003C03000A01
62678+:102CF000020280213210007F035010218FB000109B
62679+:102D00000043102127BD001803E00008AF8200280F
62680+:102D100027BDFFE8AFBF00108F4401403C0308000F
62681+:102D20008C6300E02402FF80AF840034008318210C
62682+:102D300000621024AF4200243C02000803424021FC
62683+:102D4000950500023063007F3C02000A034318210E
62684+:102D50000062182130A5FFFF3402FFFF0000302180
62685+:102D60003C07602010A20006AF8300282402FFFF6A
62686+:102D7000A5020002946500D40E000AF130A5FFFF01
62687+:102D80008FBF001024020C8027BD001803E000084C
62688+:102D9000AF4200243C020008034240219502000299
62689+:102DA0003C0A0800954A00C63046FFFF14C00007E1
62690+:102DB0003402FFFF8F8200288F8400343C0760209C
62691+:102DC000944500D40A000B5A30A5FFFF10C200241E
62692+:102DD0008F87002894E2005494E400163045FFFFEA
62693+:102DE00000A6102300A6182B3089FFFF10600004F6
62694+:102DF0003044FFFF00C51023012210233044FFFFA1
62695+:102E0000008A102B1040000C012A1023240200011C
62696+:102E1000A50200162402FFFFA502000294E500D4DB
62697+:102E20008F8400340000302130A5FFFF3C07602074
62698+:102E30000A000AF1000000000044102A10400008B7
62699+:102E4000000000009502001630420001104000040E
62700+:102E5000000000009742007E24420014A5020016E4
62701+:102E600003E00008000000008F84002827BDFFE079
62702+:102E7000AFBF0018948200349483003E1060001AA3
62703+:102E80003048FFFF9383002C2402000114620027C6
62704+:102E90008FBF00188F820028000818C23108000771
62705+:102EA000006218212447003A244900542444002099
62706+:102EB000244500302446003490620040304200FF38
62707+:102EC0000102100730420001104000168FBF0018A9
62708+:102ED0000E000856AFA900108F82002894420034DB
62709+:102EE0000A000B733048FFFF94830036948200344D
62710+:102EF0001043000E8FBF001894820036A482003465
62711+:102F000094820056A48200548C82002CAC8200244F
62712+:102F100094820032A48200309482003CA482003A61
62713+:102F20008FBF00180A000B3327BD002003E0000804
62714+:102F300027BD002027BDFFE8AFBF00108F4A01006A
62715+:102F40003C0508008CA500E03C02080090424B8440
62716+:102F50003C0C0800958C4B7E01452821304B003FEE
62717+:102F600030A2007F03424021396900323C02000A4E
62718+:102F70003963003F2C630001010240212D2900012B
62719+:102F80002402FF8000A2282401234825AF8A0034B0
62720+:102F900000801821AF450024000030210080282146
62721+:102FA00024070001AF8800283C04080024844B78E3
62722+:102FB000AF8C002415200007A380002D24020020E0
62723+:102FC0005562000F006020213402FFFF5582000C83
62724+:102FD000006020212402002015620005000000008E
62725+:102FE0008C6300142402FFFF106200070000000041
62726+:102FF0000E000889000000000A000BD0000000004D
62727+:103000000E0008F4016028210E000B68000000008B
62728+:103010008FBF001024020C8027BD001803E00008B9
62729+:10302000AF4200243C0208008C4200E027BDFFA014
62730+:10303000AFB1003C008210212411FF80AFBE0058C8
62731+:10304000AFB70054AFB20040AFB00038AFBF005CC4
62732+:10305000AFB60050AFB5004CAFB40048AFB30044BA
62733+:10306000005110248F4800248F4900288F470028E2
62734+:10307000AF4200243C0208008C4200E00080902116
62735+:1030800024060006008210213042007F03421821EE
62736+:103090003C02000A006280213C02001F3442FF8093
62737+:1030A00000E2382427A40010260500F00122F024B5
62738+:1030B0000102B8240E00051DAFA700308FA2001832
62739+:1030C000AE0200C48FA2001CAE0200C88FA2002472
62740+:1030D000AE0200CC93A40010920300D12402FF8022
62741+:1030E0000082102400431025304900FF3083007F08
62742+:1030F0003122007F0062102A10400004000310C03B
62743+:1031000001311026304900FF000310C000031940B0
62744+:10311000006218213C0208008C4200DC920400D2BC
62745+:10312000024210210043102100511024AF42002818
62746+:1031300093A300103063007F000310C00003194008
62747+:10314000006218213C0208008C4200DC024210217F
62748+:10315000004310213042007F034218213C02000C42
62749+:10316000006240218FA300142402FFFF1062003090
62750+:10317000309500FF93A2001195030014304400FF26
62751+:103180003063FFFF0064182B1060000D000000008A
62752+:10319000950400148D07001C8D0600183084FFFF75
62753+:1031A00000442023000421000000102100E4382105
62754+:1031B00000E4202B00C230210A000C4A00C4302158
62755+:1031C000950400148D07001C8D0600183084FFFF45
62756+:1031D000008220230004210000001021008018211B
62757+:1031E00000C2302300E4202B00C4302300E3382346
62758+:1031F000AD07001CAD06001893A20011A502001433
62759+:1032000097A20012A50200168FA20014AD020010B2
62760+:103210008FA20014AD02000C93A20011A5020020A1
62761+:1032200097A20012A50200228FA20014AD02002472
62762+:103230002406FF80024610243256007FAF4200244D
62763+:10324000035618213C02000A006280218E02004CC5
62764+:103250008FA200203124007F000428C0AE0200505D
62765+:103260008FA200200004214000852821AE020070BA
62766+:1032700093A2001001208821A202008393A20010D3
62767+:10328000A2020079920200853042003FA20200852E
62768+:103290003C0208008C4200DC024210210045102153
62769+:1032A00000461024AF42002C3C0208008C4200E48F
62770+:1032B0003C0308008C6300DC024210210044102112
62771+:1032C00000461024AF4200283C0208008C4200E473
62772+:1032D00002431821006518210242102100441021E8
62773+:1032E0003042007F3063007F93A50010034220210D
62774+:1032F000034318213C02000E006240213C02000CF6
62775+:1033000010B1008C008248213233007F1660001912
62776+:103310002404FF803C0208008C4200DC02421021A1
62777+:1033200000441024AF42002C3C0208008C4200E410
62778+:103330003C0308008C6300DC02421021004410248E
62779+:10334000AF4200283C0208008C4200E402431821EE
62780+:103350003063007F024210213042007F034220216F
62781+:10336000034318213C02000E006240213C02000C85
62782+:10337000008248219124000D2414FF8000001021B8
62783+:1033800000942025A124000D950400029505001449
62784+:103390008D07001C3084FFFF30A5FFFF8D0600184D
62785+:1033A000008520230004210000E4382100C23021E0
62786+:1033B00000E4202B00C43021AD07001CAD0600182E
62787+:1033C00095020002A5020014A50000168D02000857
62788+:1033D000AD0200108D020008AD02000C9502000243
62789+:1033E000A5020020A50000228D020008AD020024E5
62790+:1033F0009122000D30420040104000422622000180
62791+:103400003C0208008C4200E0A3B300283C10000AF4
62792+:103410000242102100541024AF4200243C02080054
62793+:103420008C4200E0A380002C27A4002C0242102133
62794+:103430003042007F03421821007018218C6200D8AE
62795+:103440008D26000427A50028AFA9002C00461021D6
62796+:10345000AC6200D80E0009E1AF83002893A30028D6
62797+:103460008F8200280E000626A04300D10E000B68B4
62798+:103470000000000002541024AF4200243C02080067
62799+:103480008C4200DC00132940001320C000A420213E
62800+:10349000024210210044102100541024AF42002C9D
62801+:1034A0003C0208008C4200E43C0308008C6300DC12
62802+:1034B00003563021024210210045102100541024EF
62803+:1034C000AF4200283C0208008C4200E4024318216D
62804+:1034D0000064182102421021004510213042007F73
62805+:1034E0003063007F03422021034318213C02000E79
62806+:1034F000006240213C02000C00D080210082482163
62807+:10350000262200013043007F14750005304400FF7F
62808+:103510002403FF800223102400431026304400FFC0
62809+:1035200093A2001000808821250800281444FF760B
62810+:103530002529002093A400108FA300142402FFFF6C
62811+:103540001062000A308900FF2482000124830001F8
62812+:103550003042007F14550005306900FF2403FF80CE
62813+:103560000083102400431026304900FF92020078A7
62814+:10357000305300FF11330032012088213C02080043
62815+:103580008C4200DC3225007F000520C00005294068
62816+:1035900000A42021024210212406FF8000441021B3
62817+:1035A00000461024AF42002C3C0308008C6300DC72
62818+:1035B0003C0208008C4200E4024318210242102120
62819+:1035C0000045102100641821004610243063007F5C
62820+:1035D000AF420028034318213C02000E0062402144
62821+:1035E0003C0208008C4200E48D06000C0100202102
62822+:1035F00002421021004510213042007F0342182171
62823+:103600003C02000C0062482110C0000D012028215E
62824+:103610000E00064A000000002402FF800222182447
62825+:1036200026240001006228263082007F1455000203
62826+:10363000308300FF30A300FF1473FFD000608821A7
62827+:103640008E0300743C027FFF3442FFFF00621824A7
62828+:10365000AE0300740E00066B02402021AF57002419
62829+:103660008FA20030AF5E00288FBF005C8FBE005875
62830+:103670008FB700548FB600508FB5004C8FB4004800
62831+:103680008FB300448FB200408FB1003C8FB0003840
62832+:1036900027BD006003E00008AF42002C27BDFFD823
62833+:1036A000AFB1001CAFBF0020AFB000182751018898
62834+:1036B000922200032408FF803C03000A3047007F69
62835+:1036C000A3A700108F4601803C0208008C4200E056
62836+:1036D000AF86003400C2282100A81024AF42002485
62837+:1036E0009224000030A2007F0342102100431021E9
62838+:1036F000AF8200283084007F24020002148200255B
62839+:10370000000719403C0208008C4200E400C210216E
62840+:103710000043282130A2007F0342182100A8102472
62841+:10372000AF4200283C02000C006218219062000D9C
62842+:10373000AFA3001400481025A062000D8FA3001451
62843+:103740009062000D304200405040006A8FBF002060
62844+:103750008F860028A380002C27A400148CC200D8D8
62845+:103760008C63000427A50010004310210E0009E11E
62846+:10377000ACC200D893A300108F8200280E0006264A
62847+:10378000A04300D10E000B68000000000A000E0BE1
62848+:103790008FBF00200E00062F00C020210E00063D26
62849+:1037A000000000003C020008034280219223000137
62850+:1037B0009202007B1443004F8FBF00209222000032
62851+:1037C0003044007F24020004108200172882000584
62852+:1037D00010400006240200052402000310820007A6
62853+:1037E0008FB1001C0A000E0C0000000010820012B5
62854+:1037F0008FBF00200A000E0C8FB1001C92050083C1
62855+:10380000920600788E0700748F84003430A500FF84
62856+:1038100000073E0230C600FF0E00067330E7007F4F
62857+:103820000A000E0B8FBF00200E000BD78F840034D0
62858+:103830000A000E0B8FBF002024020C80AF42002430
62859+:103840009202003E30420040104000200000000084
62860+:103850009202003E00021600000216030441000618
62861+:10386000000000008F8400340E0005A024050093A2
62862+:103870000A000E0B8FBF00209202003F24030018A5
62863+:10388000304200FF1443000C8F84003424050039BB
62864+:103890000E000538000030210E0002508F840034E5
62865+:1038A00024020012A202003F0E0002598F8400344D
62866+:1038B0000A000E0B8FBF0020240500360E000538CD
62867+:1038C000000030210A000E0B8FBF00200E000250B6
62868+:1038D0008F8400349202000534420020A2020005C9
62869+:1038E0000E0002598F8400340E000FC08F84003404
62870+:1038F0008FBF00208FB1001C8FB0001824020C80F5
62871+:1039000027BD002803E00008AF42002427BDFFE8E0
62872+:10391000AFB00010AFBF001427430100946200084D
62873+:103920000002140000021403044100020000802180
62874+:103930002410000194620008304200801040001AF8
62875+:10394000020010219462000830422000104000164E
62876+:10395000020010218C6300183C021C2D344219ED2A
62877+:10396000240600061062000F3C0760213C0208009C
62878+:103970008C4200D4104000078F8200288F830028DB
62879+:10398000906200623042000F34420040A062006248
62880+:103990008F8200288F840034944500D40E000AF1F1
62881+:1039A00030A5FFFF020010218FBF00148FB0001060
62882+:1039B00003E0000827BD001827BDFFE0AFB10014E9
62883+:1039C000AFB00010A380002CAFBF00188F450100DE
62884+:1039D0003C0308008C6300E02402FF80AF850034C4
62885+:1039E00000A318213064007F0344202100621824C2
62886+:1039F0003C02000A00822021AF430024275001002E
62887+:103A00008E0200148C8300DCAF8400280043102356
62888+:103A100018400004000088218E0200140E000A8461
62889+:103A2000AC8200DC9202000B24030002304200FF53
62890+:103A30001443002F0000000096020008304300FFEE
62891+:103A40002402008214620005240200840E00093E54
62892+:103A5000000000000A000E97000000001462000938
62893+:103A6000240200818F8200288F8400343C0760216B
62894+:103A7000944500D49206000530A5FFFF0A000E868B
62895+:103A800030C600FF14620027000000009202000A06
62896+:103A9000304300FF306200201040000430620040DC
62897+:103AA0008F8400340A000E82240600401040000477
62898+:103AB000000316008F8400340A000E8224060041A1
62899+:103AC00000021603044100178F84003424060042CC
62900+:103AD0008F8200283C076019944500D430A5FFFF71
62901+:103AE0000E000AF1000000000A000E97000000001E
62902+:103AF0009202000B24030016304200FF1043000620
62903+:103B0000000000009202000B24030017304200FF67
62904+:103B100014430004000000000E000E11000000001D
62905+:103B2000004088210E000B68000000009202000A8D
62906+:103B3000304200081040000624020C808F850028C7
62907+:103B40003C0400080E0011EE0344202124020C80E6
62908+:103B5000AF4200248FBF0018022010218FB0001048
62909+:103B60008FB1001403E0000827BD002027BDFFE847
62910+:103B7000AFBF0014AFB000108F5000243C0308000A
62911+:103B80008C6300E08F4501002402FF8000A3182110
62912+:103B90003064007F03442021006218243C02000AA4
62913+:103BA00000822021AF850034AF4300249082006260
62914+:103BB000AF8400283042000F34420050A0820062DF
62915+:103BC0003C02001F3442FF800E00062602028024C1
62916+:103BD000AF5000248FBF00148FB0001003E0000826
62917+:103BE00027BD00183C0208008C4200201040001D38
62918+:103BF0002745010090A300093C0200080342202150
62919+:103C000024020018546200033C0200080A000ED887
62920+:103C10002402000803422021240200161462000539
62921+:103C20002402001724020012A082003F0A000EE2C4
62922+:103C300094A700085462000694A700089362000548
62923+:103C40002403FFFE00431024A362000594A700088C
62924+:103C500090A6001B8CA4000094A500060A000ACCC4
62925+:103C600000073C0003E000080000000027440100BA
62926+:103C700094820008304500FF38A3008238A20084F7
62927+:103C80002C6300012C420001006218251060000620
62928+:103C9000240200839382002D1040000D00000000DC
62929+:103CA0000A000B9B0000000014A2000524A2FF8064
62930+:103CB0008F4301043C02602003E00008AC43001481
62931+:103CC000304200FF2C420002104000032402002278
62932+:103CD0000A000E3C0000000014A2000300000000D7
62933+:103CE0000A000EA9000000000A000EC70000000034
62934+:103CF0009363007E9362007A144300090000202140
62935+:103D00009362000024030050304200FF144300047B
62936+:103D1000240400019362007E24420001A362007E1D
62937+:103D200003E00008008010218F4201F80440FFFEEC
62938+:103D300024020002AF4401C0A34201C43C021000AF
62939+:103D400003E00008AF4201F827BDFFE8AFBF001055
62940+:103D50009362003F2403000A304200FF14430046F0
62941+:103D6000000000008F6300548F62004C1062007DE1
62942+:103D7000036030219362000024030050304200FFB2
62943+:103D80001443002F000000008F4401403C02080053
62944+:103D90008C4200E02403FF800082102100431024A5
62945+:103DA000AF4200243C0208008C4200E08F650054C2
62946+:103DB0003C03000A008220213084007F034410214C
62947+:103DC00000431021AC4501089762003C8F63004C12
62948+:103DD0003042FFFF0002104000621821AF63005C18
62949+:103DE0008F6300548F64004C9762003C006418237A
62950+:103DF0003042FFFF00031843000210400043102A26
62951+:103E000010400006000000008F6200548F63004CD9
62952+:103E1000004310230A000F58000210439762003C31
62953+:103E20003042FFFF00021040ACC2006424020001D7
62954+:103E3000A0C0007CA0C2008424020C80AF420024F9
62955+:103E40000E000F0A8F440140104000478FBF001042
62956+:103E50008F4301408F4201F80440FFFE240200021C
62957+:103E6000AF4301C0A34201C43C021000AF4201F8BD
62958+:103E70000A000FA88FBF00109362003F24030010B8
62959+:103E8000304200FF14430004000000008F44014052
62960+:103E90000A000F94000028219362003F24030016BB
62961+:103EA000304200FF1443000424020014A362003FC8
62962+:103EB0000A000FA2000000008F62004C8F630050C8
62963+:103EC00000431023044100288FBF0010936200813B
62964+:103ED00024420001A3620081936200812C4200040D
62965+:103EE00014400010000000009362003F240300040F
62966+:103EF000304200FF14430006000000008F440140E0
62967+:103F00008FBF0010240500930A0005A027BD0018EC
62968+:103F10008F440140240500938FBF00100A00060F54
62969+:103F200027BD00188F4401400E0002500000000021
62970+:103F30008F6200542442FFFFAF6200548F62005032
62971+:103F40002442FFFFAF6200500E0002598F4401402F
62972+:103F50008F4401408FBF0010240500040A00025E58
62973+:103F600027BD00188FBF001003E0000827BD001810
62974+:103F70008F4201889363007E00021402304400FFE8
62975+:103F8000306300FF1464000D0000000093620080A5
62976+:103F9000304200FF1044000900000000A3640080CC
62977+:103FA0009362000024030050304200FF14430004D9
62978+:103FB000000000000A0006D78F440180A36400803F
62979+:103FC00003E000080000000027BDFFE8AFB00010CC
62980+:103FD000AFBF00149362000524030030304200306C
62981+:103FE00014430089008080213C0208008C4200209C
62982+:103FF00010400080020020210E0004930000000009
62983+:104000008F850020ACB000009362003E9363003FB8
62984+:10401000304200FF00021200306300FF0043102511
62985+:10402000ACA2000493620082000216000002160394
62986+:1040300004410005000000003C0308008C630048B8
62987+:104040000A000FE6000000009362003E304200408C
62988+:10405000144000030000182193620081304300FFE8
62989+:104060009362008200031E00304200FF0002140031
62990+:1040700000621825ACA300088F620040ACA2000CBF
62991+:104080008F620048ACA200108F62004CACA20014FA
62992+:104090008F6200508F63004C0043102304410003E3
62993+:1040A000000000000A000FFA8F62004C8F6200507F
62994+:1040B000ACA200183C02080094424B5E3C03C00BCB
62995+:1040C00000002021004310250E0004B8ACA2001C03
62996+:1040D0008F6200548F840020AC8200008F620058F1
62997+:1040E000AC8200048F62005CAC8200088F620060CA
62998+:1040F0008F43007400431021AC82000C8F62006477
62999+:10410000AC820010976300689762006A00031C008D
63000+:104110003042FFFF00621825AC83001493620082D6
63001+:1041200024030080304200FF14430003000000001D
63002+:104130000A00102EAC8000188F63000C24020001CE
63003+:104140001062000E2402FFFF9362003E30420040E6
63004+:104150001440000A2402FFFF8F63000C8F4200749A
63005+:10416000006218233C020800006210241440000280
63006+:10417000000028210060282100051043AC820018AF
63007+:104180003C02080094424B5E3C03C00C000020211E
63008+:10419000004310258F8300200E0004B8AC62001C81
63009+:1041A0008F6200188F8300203C05080094A54B5EA9
63010+:1041B00024040001AC620000AC6000048F66006C57
63011+:1041C0003C02400D00A22825AC6600088F6200DC8E
63012+:1041D000AC62000CAC600010936200050002160097
63013+:1041E000AC620014AC6000180E0004B8AC65001C92
63014+:1041F000020020218FBF00148FB00010A3600005C3
63015+:104200000A00042127BD00188FBF00148FB00010D2
63016+:1042100003E0000827BD00189742007C30C600FF6D
63017+:10422000A08600843047FFFF2402000514C2000B63
63018+:1042300024E3465090A201122C42000710400007D0
63019+:1042400024E30A0090A30112240200140062100467
63020+:1042500000E210210A0010663047FFFF3067FFFFC1
63021+:1042600003E00008A4870014AC87004C8CA201086E
63022+:104270000080402100A0482100E2102330C600FF4A
63023+:104280001840000393AA001324E2FFFCACA201082B
63024+:1042900030C2000110400008000000008D020050F4
63025+:1042A00000E2102304410013240600058D0200548F
63026+:1042B00010E20010000000008D02005414E2001A09
63027+:1042C000000000003C0208008C4200D83042002070
63028+:1042D0001040000A2402000191030078910200833B
63029+:1042E000144300062402000101002021012028219E
63030+:1042F000240600040A00105400000000A1000084FD
63031+:1043000011400009A50200148F4301008F4201F8FB
63032+:104310000440FFFE24020002AF4301C0A34201C4D7
63033+:104320003C021000AF4201F803E00008000000006A
63034+:1043300027BDFFE88FA90028AFBF001000804021F3
63035+:1043400000E918231860007330C600FFA080007CCD
63036+:10435000A08000818CA2010800E210230440004DDF
63037+:10436000000000008C8200509483003C8C84006428
63038+:10437000004748233063FFFF012318210083202BCF
63039+:1043800010800004000000008D0200640A0010B7D5
63040+:1043900000E210219502003C3042FFFF0122102173
63041+:1043A00000E21021AD02005C9502003C8D03005C30
63042+:1043B0003042FFFF0002104000E210210043102BAA
63043+:1043C00010400003000000000A0010C68D02005CCF
63044+:1043D0009502003C3042FFFF0002104000E2102135
63045+:1043E000AD02005CA1000084AD07004C8CA2010866
63046+:1043F00000E210231840000224E2FFFCACA20108F6
63047+:1044000030C200011040000A000000008D02005080
63048+:1044100000E2102304410004010020218D02005419
63049+:1044200014E20003000000000A0010E82406000562
63050+:104430008D02005414E200478FBF00103C020800B8
63051+:104440008C4200D8304200201040000A24020001B3
63052+:1044500091030078910200831443000624020001B6
63053+:1044600001002021240600048FBF00100A00105410
63054+:1044700027BD0018A1000084A50200148F4301008D
63055+:104480008F4201F80440FFFE240200020A00110DD1
63056+:10449000000000008C82005C004910230043102BB8
63057+:1044A00054400001AC87005C9502003C3042FFFFA5
63058+:1044B0000062102B14400007240200029502003C09
63059+:1044C0008D03005C3042FFFF00621821AD03005CE9
63060+:1044D00024020002AD07004CA10200840E000F0A66
63061+:1044E0008F4401001040001B8FBF00108F4301005C
63062+:1044F0008F4201F80440FFFE24020002AF4301C0D6
63063+:10450000A34201C43C021000AF4201F80A0011238B
63064+:104510008FBF001030C200101040000E8FBF00107F
63065+:104520008C83005C9482003C006918233042FFFFBA
63066+:10453000006218213C023FFF3444FFFF0083102B30
63067+:10454000544000010080182101231021AD02005CBD
63068+:104550008FBF001003E0000827BD001827BDFFE84B
63069+:104560008FAA0028AFBF00100080402100EA482336
63070+:104570001920002130C600FF8C83005C8C8200640F
63071+:10458000006A18230043102B5040001000691821C6
63072+:1045900094A2011001221021A4A2011094A20110E2
63073+:1045A0003042FFFF0043102B1440000A3C023FFF43
63074+:1045B00094A2011000431023A4A201109482003C95
63075+:1045C0003042FFFF0A00114200621821A4A001102E
63076+:1045D0003C023FFF3444FFFF0083102B5440000196
63077+:1045E0000080182100671021AD02005CA100007C52
63078+:1045F0000A00118AA100008130C200101040003C66
63079+:10460000000000008C820050004A1023184000383F
63080+:10461000000000009082007C24420001A082007C07
63081+:104620009082007C3C0308008C630024304200FF31
63082+:104630000043102B1440005C8FBF00108CA20108B7
63083+:1046400000E2102318400058000000008C83005442
63084+:104650009482003C006A18233042FFFF0003184395
63085+:10466000000210400043102A104000050000000026
63086+:104670008C820054004A10230A001171000210437A
63087+:104680009482003C3042FFFF00021040AD02006403
63088+:104690009502003C8D0400649503003C3042FFFF0E
63089+:1046A00000021040008220213063FFFF00831821A8
63090+:1046B00001431021AD02005C8D020054ACA2010840
63091+:1046C00024020002A10200840E000F0A8F440100A0
63092+:1046D000104000358FBF00108F4301008F4201F85A
63093+:1046E0000440FFFE240200020A0011B30000000093
63094+:1046F000AD07004C8CA2010800E210231840000214
63095+:1047000024E2FFFCACA2010830C200011040000A04
63096+:10471000000000008D02005000E21023044100045C
63097+:10472000010020218D02005414E20003000000006B
63098+:104730000A0011AA240600058D02005414E2001A92
63099+:104740008FBF00103C0208008C4200D8304200208D
63100+:104750001040000A240200019103007891020083B6
63101+:104760001443000624020001010020212406000455
63102+:104770008FBF00100A00105427BD0018A10000844C
63103+:10478000A50200148F4301008F4201F80440FFFE90
63104+:1047900024020002AF4301C0A34201C43C02100046
63105+:1047A000AF4201F88FBF001003E0000827BD0018DA
63106+:1047B0008FAA00108C8200500080402130C600FF7C
63107+:1047C000004A102300A048211840000700E01821EB
63108+:1047D00024020001A0800084A0A00112A482001481
63109+:1047E0000A001125AFAA0010A0800081AD07004C7F
63110+:1047F0008CA2010800E210231840000224E2FFFC12
63111+:10480000ACA2010830C20001104000080000000006
63112+:104810008D0200500062102304410013240600059D
63113+:104820008D02005410620010000000008D02005440
63114+:1048300014620011000000003C0208008C4200D805
63115+:10484000304200201040000A240200019103007849
63116+:10485000910200831443000624020001010020217C
63117+:1048600001202821240600040A0010540000000042
63118+:10487000A1000084A502001403E00008000000006D
63119+:1048800027BDFFE0AFBF0018274201009046000A95
63120+:104890008C4800148C8B004C9082008430C900FF3F
63121+:1048A00001681823304A00FF1C60001A2D460006DC
63122+:1048B000240200010142100410C00016304300031E
63123+:1048C000012030210100382114600007304C000C19
63124+:1048D00015800009304200301440000B8FBF0018D3
63125+:1048E0000A001214000000000E001125AFAB0010EA
63126+:1048F0000A0012148FBF00180E00109AAFAB001000
63127+:104900000A0012148FBF0018AFAB00100E0011BACE
63128+:10491000AFAA00148FBF001803E0000827BD0020D5
63129+:1049200024020003A08200848C82005403E000086B
63130+:10493000ACA201083C0200080342182190620081E9
63131+:10494000240600433C07601924420001A062008154
63132+:10495000906300813C0208008C4200C0306300FF7D
63133+:10496000146200102403FF803C0208008C4200E027
63134+:104970000082102100431024AF4200243C020800B2
63135+:104980008C4200E03C03000A008210213042007F8C
63136+:104990000342102100431021944500D40A000AF17B
63137+:1049A00030A5FFFF03E000080000000027BDFFE086
63138+:1049B000AFBF0018AFB10014AFB000108F4201803C
63139+:1049C0000080802100A088210E00121B00402021C1
63140+:1049D000A20000848E0200548FBF00188FB0001018
63141+:1049E000AE2201088FB1001403E0000827BD0020AB
63142+:1049F00027BDFFE03C020008AFB00010AFBF0018B9
63143+:104A0000AFB10014034280218F5101409203008412
63144+:104A10008E0400508E02004C14820040306600FF6D
63145+:104A20003C0208008C4200E02403FF800222102197
63146+:104A300000431024AF4200243C0208008C4200E0F6
63147+:104A40009744007C92050081022210213042007FB1
63148+:104A5000034218213C02000A0062182114A0000B36
63149+:104A60003084FFFF2402000554C20014248205DCB8
63150+:104A70009062011224420001A062011224020C8003
63151+:104A8000AF4200240A00127324020005A060011244
63152+:104A90002402000514C20009248205DC9202008170
63153+:104AA0002C4200075040000524820A009203008136
63154+:104AB0002402001400621004008210213044FFFF21
63155+:104AC000A60400140E00121B022020219602003CB6
63156+:104AD0008E03004C022020213042FFFF00021040D4
63157+:104AE000006218210E000250AE03005C9202007DAD
63158+:104AF00002202021344200400E000259A202007D13
63159+:104B00008F4201F80440FFFE24020002AF5101C0B1
63160+:104B1000A34201C43C021000AF4201F88FBF00184D
63161+:104B20008FB100148FB0001003E0000827BD0020F3
63162+:104B300008000ACC08000B1408000B9808000BE4CE
63163+:104B400008000C200A0000280000000000000000FF
63164+:104B50000000000D6370362E322E3300000000007E
63165+:104B60000602030400000000000000000000000036
63166+:104B70000000000000000000000000000000000035
63167+:104B80000000000000000000000000000000002005
63168+:104B90000000000000000000000000000000000015
63169+:104BA0000000000000000000000000000000000005
63170+:104BB00000000000000000000000000000000001F4
63171+:104BC0000000002B000000000000000400030D4066
63172+:104BD00000000000000000000000000000000000D5
63173+:104BE00000000000000000001000000300000000B2
63174+:104BF0000000000D0000000D3C020800244258A4F3
63175+:104C00003C03080024635F70AC4000000043202B8D
63176+:104C10001480FFFD244200043C1D080037BD7FFCCA
63177+:104C200003A0F0213C100800261000A03C1C080046
63178+:104C3000279C58A40E0001AC000000000000000DED
63179+:104C400027BDFFE83C096018AFBF00108D2C500055
63180+:104C5000240DFF7F24080031018D5824356A380C5B
63181+:104C600024070C003C1A8000AD2A50003C04800A46
63182+:104C7000AF4800083C1B8008AF4700240E00091510
63183+:104C8000AF8400100E0008D8000000000E000825B8
63184+:104C9000000000000E001252000000003C046016EC
63185+:104CA0008C8500003C06FFFF3C02535300A61824ED
63186+:104CB0001062004734867C0094C201F2A780002C69
63187+:104CC00010400003A78000CC38581E1EA798002C67
63188+:104CD00094C201F810400004978300CC38591E1E7E
63189+:104CE000A79900CC978300CC2C7F006753E000018C
63190+:104CF000240300669784002C2C82040114400002D7
63191+:104D000000602821240404003C0760008CE904387A
63192+:104D10002403103C3128FFFF1103001F30B9FFFFAF
63193+:104D200057200010A38000CE24020050A38200CEA2
63194+:104D3000939F00CE53E0000FA78500CCA78000CC46
63195+:104D4000978500CC8FBF0010A780002CA78000346F
63196+:104D5000A78000E63C010800AC25008003E00008C5
63197+:104D600027BD0018939F00CE57E0FFF5A78000CC29
63198+:104D7000A78500CC978500CC8FBF0010A784002C9E
63199+:104D8000A7800034A78000E63C010800AC25008025
63200+:104D900003E0000827BD0018A38000CE8CCB003CA8
63201+:104DA000316A00011140000E0000000030A7FFFF33
63202+:104DB00010E0FFDE240200508CCC00C831860001D8
63203+:104DC00014C0FFDC939F00CE0A00007A2402005139
63204+:104DD0008C8F00043C0E60000A00005D01EE302163
63205+:104DE0008CEF0808240D5708000F740211CD000441
63206+:104DF00030B8FFFF240500660A00007B240404008D
63207+:104E00001700FFCC939F00CE0A00007A24020050C6
63208+:104E10008F8600103089FFFF000939408CC30010D5
63209+:104E20003C08005000E82025AF4300388CC5001432
63210+:104E300027420400AF82001CAF45003CAF44003065
63211+:104E40000000000000000000000000000000000062
63212+:104E50000000000000000000000000000000000052
63213+:104E60008F4B0000316A00201140FFFD0000000060
63214+:104E700003E00008000000008F840010948A001AEC
63215+:104E80008C8700243149FFFF000940C000E8302131
63216+:104E9000AF46003C8C8500248F43003C00A31023C8
63217+:104EA00018400029000000008C8B002025620001C2
63218+:104EB0003C0D005035AC0008AF420038AF4C00301C
63219+:104EC00000000000000000000000000000000000E2
63220+:104ED00000000000000000000000000000000000D2
63221+:104EE0008F4F000031EE002011C0FFFD00000000D8
63222+:104EF0008F4A04003C080020AC8A00108F4904044B
63223+:104F0000AC890014AF4800300000000094860018FF
63224+:104F10009487001C00C71821A48300189485001AE8
63225+:104F200024A20001A482001A9498001A9499001EE9
63226+:104F3000133800030000000003E000080000000038
63227+:104F400003E00008A480001A8C8200200A0000DC24
63228+:104F50003C0D00500A0000CD000000003C0308009A
63229+:104F60008C6300208F82001827BDFFE810620008C4
63230+:104F7000AFBF00100E000104AF8300183C0308000F
63231+:104F80008C63002024040001106400048F89001049
63232+:104F90008FBF001003E0000827BD00188FBF00106E
63233+:104FA0003C076012A520000A9528000A34E500108D
63234+:104FB00027BD00183106FFFF03E00008ACA60090F3
63235+:104FC0003C0208008C42002027BDFFC8AFBF003460
63236+:104FD000AFBE0030AFB7002CAFB60028AFB500248D
63237+:104FE000AFB40020AFB3001CAFB20018AFB10014D3
63238+:104FF00010400050AFB000108F840010948600065F
63239+:105000009483000A00C3282330B6FFFF12C0004A71
63240+:105010008FBF003494890018948A000A012A402323
63241+:105020003102FFFF02C2382B14E0000202C020212F
63242+:10503000004020212C8C0005158000020080A0215A
63243+:10504000241400040E0000B3028020218F8700107A
63244+:1050500002809821AF80001494ED000A028088211C
63245+:105060001280004E31B2FFFF3C1770003C1540002B
63246+:105070003C1E60008F8F001C8DEE000001D71824AD
63247+:10508000507500500220202102A3802B160000350D
63248+:105090003C182000507800470220202124100001F5
63249+:1050A0008F83001414600039029158230230F823D2
63250+:1050B0000250C82133F1FFFF1620FFEE3332FFFF0D
63251+:1050C0008F8700103C110020AF510030000000001D
63252+:1050D00094E6000A3C1E601237D5001002662821B3
63253+:1050E000A4E5000A94E2000A94F2000A94F400187D
63254+:1050F0003057FFFF1292003BAEB700908CED0014CA
63255+:105100008CE400100013714001AE4021000E5FC31B
63256+:10511000010E502B008B4821012A1821ACE8001405
63257+:10512000ACE3001002D3382330F6FFFF16C0FFB9FE
63258+:105130008F8400108FBF00348FBE00308FB7002CDB
63259+:105140008FB600288FB500248FB400208FB3001CC9
63260+:105150008FB200188FB100148FB0001003E0000868
63261+:1051600027BD0038107E001B000000001477FFCC24
63262+:10517000241000010E00159B000000008F83001416
63263+:105180001060FFCB0230F823029158238F87001064
63264+:10519000017020210A0001973093FFFF8F830014D4
63265+:1051A0001460FFCB3C110020AF5100300A000163B6
63266+:1051B000000000000E00077D024028210A00015770
63267+:1051C000004080210E00033A024028210A000157C6
63268+:1051D000004080210E001463022020210A000157A4
63269+:1051E000004080210E0000CD000000000A0001797F
63270+:1051F00002D3382327BDFFE8AFB00010AFBF0014C3
63271+:105200000E00003F000000003C028000345000709F
63272+:105210000A0001BA8E0600008F4F000039EE00012F
63273+:1052200031C20001104000248F8600A88E070000C4
63274+:105230003C0C08008D8C003C3C0908008D2900388E
63275+:1052400000E66823018D28210000502100AD302B9D
63276+:10525000012A4021010620213C010800AC25003C28
63277+:10526000AF8700A83C010800AC2400380E000106FE
63278+:10527000000000003C0308008C6300701060FFE633
63279+:10528000006020213C0508008CA500683C06080051
63280+:105290008CC6006C0E00152A000000003C010800BE
63281+:1052A000AC2000708F4F000039EE000131C20001C8
63282+:1052B0001440FFDE8F8600A88E0A00008F8B00A8A6
63283+:1052C0003C0508008CA5003C3C0408008C84003898
63284+:1052D000014B482300A938210082182100E9402B06
63285+:1052E000006810213C010800AC27003C3C0108008C
63286+:1052F000AC2200388F5F01002419FF0024180C0035
63287+:1053000003F9202410980012AF840000AF4400205D
63288+:10531000936D0000240C002031A600FF10CC001279
63289+:10532000240E005010CE00043C194000AF59013843
63290+:105330000A0001B3000000000E0011C800000000C8
63291+:105340003C194000AF5901380A0001B300000000C9
63292+:105350000E00011F000000003C194000AF59013849
63293+:105360000A0001B3000000008F58010000802821CE
63294+:10537000330F00FF01E020210E0002F1AF8F000487
63295+:105380003C194000AF5901380A0001B30000000089
63296+:1053900000A4102B2403000110400009000030215C
63297+:1053A0000005284000A4102B04A0000300031840AF
63298+:1053B0005440FFFC000528405060000A0004182BF0
63299+:1053C0000085382B54E000040003184200C3302548
63300+:1053D00000852023000318421460FFF900052842CD
63301+:1053E0000004182B03E0000800C310218F4201B80D
63302+:1053F0000440FFFE00000000AF4401803C031000A9
63303+:1054000024040040AF450184A3440188A3460189D8
63304+:10541000A747018A03E00008AF4301B83084FFFFCB
63305+:105420000080382130A5FFFF000020210A00022A59
63306+:10543000240600803087FFFF8CA40000240600387B
63307+:105440000A00022A000028218F8300388F8600304E
63308+:105450001066000B008040213C07080024E75A1822
63309+:10546000000328C000A710218C4400002463000121
63310+:10547000108800053063000F5466FFFA000328C04F
63311+:1054800003E00008000010213C07080024E75A1C34
63312+:1054900000A7302103E000088CC200003C0390000C
63313+:1054A0003462000100822025AF4400208F45002097
63314+:1054B00004A0FFFE0000000003E000080000000060
63315+:1054C0003C038000346200010082202503E00008D4
63316+:1054D000AF44002027BDFFE0AFB100143091FFFFC3
63317+:1054E000AFB00010AFBF00181220001300A0802141
63318+:1054F0008CA2000024040002240601401040000F8A
63319+:10550000004028210E000C5C00000000000010216B
63320+:10551000AE000000022038218FBF00188FB10014A8
63321+:105520008FB0001000402021000028210000302111
63322+:105530000A00022A27BD00208CA200000220382188
63323+:105540008FBF00188FB100148FB0001000402021D1
63324+:1055500000002821000030210A00022A27BD002077
63325+:1055600000A010213087FFFF8CA500048C440000B0
63326+:105570000A00022A2406000627BDFFE0AFB0001093
63327+:10558000AFBF0018AFB100149363003E00808021CC
63328+:105590000080282130620040000020211040000FD0
63329+:1055A0008E1100000E000851022020219367000098
63330+:1055B0002404005030E500FF50A400128E0F0000BC
63331+:1055C000022020218FBF00188FB100148FB000106F
63332+:1055D000A762013C0A00091127BD00200E000287C6
63333+:1055E000000000000E0008510220202193670000F7
63334+:1055F0002404005030E500FF14A4FFF20220202113
63335+:105600008E0F00003C1008008E1000503C0D000C66
63336+:10561000240BFF8001F05021314E007F01DA602120
63337+:10562000018D4021014B4824AF4900280220202150
63338+:105630008FBF00188FB100148FB00010A50200D6E4
63339+:1056400027BD00200A000911AF8800D027BDFFE068
63340+:10565000AFBF0018AFB10014AFB0001093660001E7
63341+:10566000008080210E00025630D1000493640005B2
63342+:10567000001029C2A765000034830040A363000521
63343+:105680000E00025F020020210E00091302002021FB
63344+:1056900024020001AF62000C02002821A762001062
63345+:1056A00024040002A762001224060140A76200142D
63346+:1056B0000E000C5CA76200161620000F8FBF0018AA
63347+:1056C000978C00343C0B08008D6B00782588FFFF19
63348+:1056D0003109FFFF256A0001012A382B10E000067E
63349+:1056E000A78800343C0F6006240E001635ED00102C
63350+:1056F000ADAE00508FBF00188FB100148FB00010F6
63351+:1057000003E0000827BD002027BDFFE0AFB1001473
63352+:10571000AFBF0018AFB0001000A088211080000AB1
63353+:105720003C03600024020080108200120000000090
63354+:105730000000000D8FBF00188FB100148FB0001053
63355+:1057400003E0000827BD00208C682BF80500FFFE51
63356+:1057500000000000AC712BC08FBF00188FB1001487
63357+:105760008FB000103C09100027BD002003E00008A6
63358+:10577000AC692BF80E00025600A0202193650005AD
63359+:10578000022020210E00025F30B000FF2403003E03
63360+:105790001603FFE7000000008F4401780480FFFE3D
63361+:1057A000240700073C061000AF51014002202021D1
63362+:1057B000A34701448FBF00188FB100148FB00010B1
63363+:1057C000AF4601780A0002C227BD002027BDFFE8CE
63364+:1057D000AFBF0014AFB000108F50002000000000D9
63365+:1057E0000E000913AF440020AF5000208FBF0014FB
63366+:1057F0008FB0001003E0000827BD00183084FFFFC1
63367+:10580000008038212406003500A020210A00022A49
63368+:10581000000028213084FFFF008038212406003654
63369+:1058200000A020210A00022A0000282127BDFFD065
63370+:10583000AFB3001C3093FFFFAFB50024AFB2001828
63371+:10584000AFBF0028AFB40020AFB10014AFB000105C
63372+:1058500030B5FFFF12600027000090218F90001CE0
63373+:105860008E0300003C0680002402004000033E023C
63374+:1058700000032C0230E4007F006688241482001D9F
63375+:1058800030A500FF8F8300282C68000A510000100B
63376+:105890008F910014000358803C0C0800258C56940E
63377+:1058A000016C50218D49000001200008000000001B
63378+:1058B00002B210213045FFFF0E000236240400849E
63379+:1058C000162000028F90001CAF8000288F910014DA
63380+:1058D000260C002026430001018080213072FFFF4A
63381+:1058E00016200004AF8C001C0253502B1540FFDC27
63382+:1058F00000000000024010218FBF00288FB5002457
63383+:105900008FB400208FB3001C8FB200188FB1001429
63384+:105910008FB0001003E0000827BD0030240E0034D3
63385+:1059200014AE00F9000000009203000E241F168040
63386+:105930003C07000CA36300219202000D0347C8211D
63387+:105940003C066000A3620020961100123C0A7FFF13
63388+:10595000354CFFFFA771003C960B00102403000597
63389+:105960003168FFFFAF6800848E05001CAF5F002820
63390+:105970008F3800008CC4444803057826008F3021FE
63391+:10598000AF66004C8F69004C24CE00013C057F00BF
63392+:10599000AF6900508F740050AF740054AF66007050
63393+:1059A000AF6E00588F6D005824140050AF6D005C2E
63394+:1059B000A3600023AF6C0064A36300378E02001461
63395+:1059C000AF6200488F710048AF7100248E0B001841
63396+:1059D000AF6B006C9208000CA3680036937F003E0A
63397+:1059E00037F90020A379003E8F78007403058024E6
63398+:1059F000360F4000AF6F007493640000308900FFE1
63399+:105A0000513402452404FF803C04080024845A9841
63400+:105A10000E00028D000000003C1008008E105A9805
63401+:105A20000E00025602002021240600042407000173
63402+:105A3000A366007D020020210E00025FA36700051F
63403+:105A40008F5F017807E0FFFE240B0002AF5001409A
63404+:105A5000A34B01448F90001C3C081000AF48017814
63405+:105A60000A000362AF8000282CAD003751A0FF98D8
63406+:105A70008F9100140005A0803C180800271856BC20
63407+:105A8000029878218DEE000001C00008000000009F
63408+:105A90002418000614B80011000000003C0808009B
63409+:105AA0008D085A9824040005AF4800208E1F001866
63410+:105AB000AF7F00188F79004CAF79001C8F650050C4
63411+:105AC000122000C0AF6500700A000362AF84002896
63412+:105AD0002406000710A60083240300063C050800E6
63413+:105AE00024A55A980E000264240400818F90001CA3
63414+:105AF0000011102B0A000362AF8200282407000463
63415+:105B000014A7FFF6240500503C1808008F185A9877
63416+:105B1000AF5800208E0F0008AF6F00408E090008BC
63417+:105B2000AF6900448E14000CAF7400488E0E001054
63418+:105B3000AF6E004C8E0D0010AF6D00848E0A001405
63419+:105B4000AF6A00508E0C0018AF6C00548E04001C1D
63420+:105B5000AF64005893630000306B00FF116501D8FB
63421+:105B6000000000008F7400488F6900400289702394
63422+:105B700005C000042404008C1620FFDE240200036C
63423+:105B8000240400823C05080024A55A980E000287D0
63424+:105B9000000000008F90001C000010210A0003622A
63425+:105BA000AF820028240F000514AFFFCC240520008D
63426+:105BB0003C0708008CE75A98AF4700208E06000487
63427+:105BC000AF66005C9208000824100008A36800215A
63428+:105BD0008F9F001C93F90009A37900208F86001C79
63429+:105BE00090D8000A330400FF10900011000000005C
63430+:105BF0002885000914A0006924020002240A00205C
63431+:105C0000108A000B34058000288D002115A00008A3
63432+:105C100024054000240E0040108E00053C050001C4
63433+:105C200024140080109400023C050002240540006A
63434+:105C30008F7800743C19FF00031980240205782531
63435+:105C4000AF6F007490C4000BA36400818F84001CAC
63436+:105C50009489000C11200192000000009490000C27
63437+:105C60002406FFBF24050004A770003C908F000E9F
63438+:105C7000A36F003E8F84001C9089000FA369003F32
63439+:105C80008F8B001C8D6E00108F54007401D468231C
63440+:105C9000AF6D00608D6A0014AF6A0064956C0018E7
63441+:105CA000A76C00689563001AA763006A8D62001CE8
63442+:105CB000AF62006C9167000EA367003E9368003EE0
63443+:105CC0000106F8241220014BA37F003E8F90001C98
63444+:105CD0000A000362AF8500282407002214A7FF7F73
63445+:105CE000240300073C0B08008D6B5A981220000C0F
63446+:105CF000AF4B00200A000362AF830028240C00335E
63447+:105D000010AC0014240A00283C05080024A55A9869
63448+:105D10000E00023C240400810A0003EB8F90001C5B
63449+:105D20003C04080024845A980E00028D00000000F4
63450+:105D30009363000024110050306200FF10510135C0
63451+:105D4000000000008F90001C000018210A00036270
63452+:105D5000AF8300283C0D08008DAD5A9824040081C3
63453+:105D6000AF4D00203C05080024A55A980E00023CC7
63454+:105D7000A36A00348F90001C240200090A00036209
63455+:105D8000AF82002802B288213225FFFF0E000236C2
63456+:105D9000240400840A0003628F90001C1082FFA478
63457+:105DA00024050400288B000311600170240C0004FA
63458+:105DB000240300015483FF9E240540000A00043B95
63459+:105DC000240501003C04080024845A988F62004C8A
63460+:105DD0000E00028D8F6300508F90001C0000202168
63461+:105DE0000A000362AF8400288E1000042404008A95
63462+:105DF000AF50002093790005333800021700015F8F
63463+:105E0000020028219368002302002821311F00206E
63464+:105E100017E0015A2404008D9367003F2406001206
63465+:105E200030E200FF10460155240400810E000256A6
63466+:105E30000200202193630023240500040200202196
63467+:105E4000346B0042A36B00230E00025FA365007D4C
63468+:105E50008F4401780480FFFE240A0002AF50014005
63469+:105E6000A34A01448F90001C3C0C1000AF4C0178F9
63470+:105E70000A0003EC0011102B8E1000042404008A89
63471+:105E8000AF500020936E000531CD000215A0001622
63472+:105E900002002821936F003F2414000402002821EF
63473+:105EA00031E900FF11340010240400810E00025675
63474+:105EB000020020219362002324080012241FFFFE09
63475+:105EC00034460020A3660023A368003F93790005B1
63476+:105ED00002002021033FC0240E00025FA3780005CA
63477+:105EE00002002821000020210E00033400000000E1
63478+:105EF0000A0003EB8F90001C8E1000043C03000886
63479+:105F00000343A021AF500020928B000024050050D5
63480+:105F1000316400FF10850161240700880200202100
63481+:105F2000000028210E00022A2406000E928D000097
63482+:105F3000240EFF800200282101AE8025A2900000DF
63483+:105F4000240400040E000C5C240600300A0003EB5D
63484+:105F50008F90001C8E0800043C14080026945A9868
63485+:105F60003C010800AC285A98AF480020921F00035B
63486+:105F700033F9000413200002240200122402000658
63487+:105F8000A362003F920B001B2404FFC03165003F59
63488+:105F900000A43825A367003E9206000330C200012A
63489+:105FA00014400132000000008E020008AE8200089A
63490+:105FB0003C0208008C425AA010400131000249C244
63491+:105FC000A76900088E14000C240C0001240300149F
63492+:105FD000AF74002C8E0E0010AF6E0030960D0016C0
63493+:105FE000A76D0038960A0014A76A003AAF6C000C3F
63494+:105FF000A76C0010A76C0012A76C0014A76C001609
63495+:1060000012200136A3630034920F000331F0000226
63496+:106010002E1100018F90001C262200080A00036246
63497+:10602000AF8200288E0400043C0E0008034E30218D
63498+:10603000AF4400208E05000890CD0000240C0050D5
63499+:1060400031AA00FF114C00862407008824060009AD
63500+:106050000E00022A000000000A0003EB8F90001CD3
63501+:106060008E04001C0E00024100000000104000F4ED
63502+:10607000004050218F89001C240700890140202105
63503+:106080008D25001C240600010E00022A00000000DD
63504+:106090000A0003EB8F90001C960D00023C140800D0
63505+:1060A00026945A9831AA0004514000B83C10600070
63506+:1060B0008E0E001C3C010800AC2E5A98AF4E0020FA
63507+:1060C000920700102408001430E200FF144800D6A4
63508+:1060D00000000000960B00023163000114600165AE
63509+:1060E000000000008E020004AE8200083C1408008C
63510+:1060F0008E945AA01280015B000000008F7400741F
63511+:106100003C0380002404000102835825AF6B007417
63512+:10611000A3600005AF64000C3C0708008CE75AA0A0
63513+:106120008F86001CA7640010000711C2A76400122C
63514+:10613000A7640014A7640016A76200088CC80008B2
63515+:1061400024040002AF68002C8CC5000CAF65003041
63516+:1061500090DF0010A37F00348F99001C9330001152
63517+:10616000A37000358F98001C930F0012A36F0036A8
63518+:106170008F89001C912E0013A36E00378F90001C96
63519+:10618000960D0014A76D0038960A0016A76A003A0B
63520+:106190008E0C0018AF6C00245620FDCCAF84002874
63521+:1061A0003C05080024A55A980E0002640000202136
63522+:1061B0008F90001C0A0004A7000020218E1000040C
63523+:1061C00024070081AF500020936900233134001070
63524+:1061D000128000170000000002002021000028218A
63525+:1061E0002406001F0E00022A000000000A0003EB34
63526+:1061F0008F90001C3C05080024A55A980E000287C9
63527+:10620000240400828F90001C000028210A000362F1
63528+:10621000AF8500283C0408008C845A980E0014E8CE
63529+:10622000000000008F90001C0A000482000018216A
63530+:106230000E00025602002021937800230200202144
63531+:10624000370F00100E00025FA36F002300003821FB
63532+:1062500002002021000028210A0005A82406001FB2
63533+:10626000920F000C31E90001112000030000000032
63534+:106270009618000EA4D8002C921F000C33F90002CF
63535+:1062800013200005000038218E0200149608001229
63536+:10629000ACC2001CA4C8001A0A0005432406000969
63537+:1062A0003C05080024A55A980E0002872404008BA0
63538+:1062B0008F90001C0011282B0A000362AF85002874
63539+:1062C000AF6000843C0A08008D4A5A983C0D0800D3
63540+:1062D0008DAD0050240CFF803C02000C014D1821B4
63541+:1062E000006C2024AF4400288E070014306B007F20
63542+:1062F000017A282100A2C821AF2700D88E060014F9
63543+:10630000AF9900D0AF2600DC8E080010251FFFFEDD
63544+:106310000A000408AF3F01083C0508008CA55A9804
63545+:106320003C1908008F39005024CCFFFE00B9C02171
63546+:1063300003047824AF4F00283C1408008E945A9828
63547+:106340003C0908008D2900500289702131CD007F61
63548+:1063500001BA502101478021AE0600D8AF9000D08D
63549+:10636000AE0000DC0A0003B1AE0C0108548CFE3014
63550+:10637000240540000A00043B240510000E00032EF3
63551+:10638000000000000A0003EB8F90001C8E0F442CCD
63552+:106390003C186C62370979703C010800AC205A98AF
63553+:1063A00015E9000824050140979F00349786002CCA
63554+:1063B0000280282103E6C82B132000112404009238
63555+:1063C000240501400E000C7A240400023C01080060
63556+:1063D000AC225A98AF4200203C0508008CA55A9880
63557+:1063E00010A00005240400830E00084500000000F2
63558+:1063F00010400009240400833C05080024A55A9895
63559+:106400000E000264000000008F90001C0011202B81
63560+:106410000A000362AF8400280E0008490000000053
63561+:106420000A00055F8F90001C0E00084D0000000060
63562+:106430003C05080024A55A980A00062F2404008B66
63563+:10644000240400040E000C7A240500301440002AB5
63564+:10645000004050218F89001C240700830140202127
63565+:106460008D25001C0A000551240600018E04000839
63566+:106470000E000241000000000A00051BAE82000869
63567+:106480003C05080024A55A980E00023C240400870D
63568+:106490008F90001C0A0005360011102B8F830038E6
63569+:1064A0008F8600301066FE9D000038213C070800F2
63570+:1064B00024E75A1C000320C0008728218CAC000070
63571+:1064C00011900061246A00013143000F5466FFFA05
63572+:1064D000000320C00A0004F6000038213C05080033
63573+:1064E00024A55A980E000287240400828F90001C75
63574+:1064F0000A000536000010213C0B0008034B202148
63575+:106500002403005024070001AF420020A0830000B4
63576+:10651000A08700018F82001C90480004A08800180A
63577+:106520008F85001C90A60005A08600198F9F001C77
63578+:1065300093F90006A099001A8F90001C921800078A
63579+:10654000A098001B8F94001C928F0008A08F001C45
63580+:106550008F89001C912E0009A08E001D8F8D001CBC
63581+:1065600091AC000AA08C001E8F8B001C3C0C080014
63582+:10657000258C5A1C9163000B3C0B0800256B5A18A4
63583+:10658000A083001F8F87001C90E8000CA0880020CB
63584+:106590008F82001C9045000D24024646A0850021F4
63585+:1065A0008F86001C90DF000EA09F00228F99001C98
63586+:1065B0009330000FA09000238F98001C93140010BC
63587+:1065C000A09400248F8F001C91E90011A089002560
63588+:1065D0008F89001C8F8E00308F900038952D00140D
63589+:1065E000000E18C025C80001A48D002895270016AC
63590+:1065F000006C3021006BC821A487002A9525001863
63591+:106600003108000FA485002CA482002E8D3F001CB1
63592+:10661000ACCA0000AF88003011100006AF3F000088
63593+:10662000000038218D25001C014020210A00055161
63594+:1066300024060001250C00013184000F00003821E0
63595+:106640000A0006B8AF8400383C07080024E75A184F
63596+:106650000087302100003821ACA000000A0004F6B9
63597+:10666000ACC000003C05080024A55A980A00062F7B
63598+:10667000240400878E0400040E0002410000000084
63599+:106680000A00056AAE8200083084FFFF30C600FFB2
63600+:106690008F4201B80440FFFE00064400010430258B
63601+:1066A0003C07200000C720253C031000AF400180BC
63602+:1066B000AF450184AF44018803E00008AF4301B84F
63603+:1066C00027BDFFE8AFB00010AFBF00143C0760006B
63604+:1066D000240600021080000600A080210010102B6C
63605+:1066E0008FBF00148FB0001003E0000827BD001812
63606+:1066F0003C09600EAD2000348CE5201C8F82001C0C
63607+:106700002408FFFC00A81824ACE3201C0E0006D1CE
63608+:106710008C45000C0010102B8FBF00148FB00010A0
63609+:1067200003E0000827BD00183C02600E344701005A
63610+:1067300024090018274A040000000000000000009F
63611+:10674000000000003C06005034C30200AF44003893
63612+:10675000AF45003CAF430030014018218F4B000093
63613+:10676000316800201100FFFD2406007F2408FFFF90
63614+:106770008C6C000024C6FFFF24630004ACEC000016
63615+:1067800014C8FFFB24E70004000000000000000024
63616+:10679000000000003C0F0020AF4F00300000000060
63617+:1067A00024AD020001A5702B2529FFFF008E2021BA
63618+:1067B0001520FFE101A0282103E0000800000000EF
63619+:1067C00027BDFFE0AFB10014AFBF0018AFB000109D
63620+:1067D0003C05600E8CA20034008088211440000625
63621+:1067E0003C0460008C87201C2408FFFC00E8302457
63622+:1067F00034C30001AC83201C8F8B001C24090001D2
63623+:10680000ACA90034956900028D6500148D70000CF0
63624+:106810002D2400818D6700048D660008108000071C
63625+:106820008D6A00102D2C00041580000E30CE00075C
63626+:10683000312D000311A0000B000000002404008B88
63627+:10684000020028210E0006D1240600030011102B9F
63628+:106850008FBF00188FB100148FB0001003E0000844
63629+:1068600027BD002015C0FFF62404008B3C03002048
63630+:10687000AF4300300000000024020001AF8200148A
63631+:106880000000000000000000000000003C1F01505C
63632+:10689000013FC825253800033C0F600EAF47003884
63633+:1068A00000181882AF46003C35E8003CAF59003074
63634+:1068B000274704008F4400003086002010C0FFFDF1
63635+:1068C00000000000106000082466FFFF2403FFFFA3
63636+:1068D0008CEB000024C6FFFF24E70004AD0B000092
63637+:1068E00014C3FFFB250800043C08600EAD09003806
63638+:1068F0000000000000000000000000003C07002035
63639+:10690000AF470030000000000E0006F901402021D2
63640+:1069100002002821000020210E0006D124060003D9
63641+:106920000011102B8FBF00188FB100148FB0001012
63642+:1069300003E0000827BD002027BDFFE0AFB200182C
63643+:106940003092FFFFAFB10014AFBF001CAFB000101A
63644+:106950001640000D000088210A0007AA022010211D
63645+:1069600024050001508500278CE5000C0000000D77
63646+:10697000262300013071FFFF24E200200232382B71
63647+:1069800010E00019AF82001C8F8200141440001622
63648+:106990008F87001C3C0670003C0320008CE5000043
63649+:1069A00000A62024148300108F84003C00054402BC
63650+:1069B0003C09800000A980241480FFE9310600FF13
63651+:1069C0002CCA00095140FFEB262300010006688015
63652+:1069D0003C0E080025CE579801AE60218D8B00003B
63653+:1069E0000160000800000000022010218FBF001C81
63654+:1069F0008FB200188FB100148FB0001003E00008B0
63655+:106A000027BD00200E0006D1240400841600FFD804
63656+:106A10008F87001C0A00078BAF80003C90EF0002BC
63657+:106A200000002021240600090E0006D1000F2E00D0
63658+:106A30008F87001C0010102B0A00078BAF82003CD0
63659+:106A4000020028210E0006DF240400018F87001CAD
63660+:106A50000A00078BAF82003C020028210E0006DFEF
63661+:106A6000000020210A0007C38F87001C0E00071FAB
63662+:106A7000020020210A0007C38F87001C30B0FFFFEF
63663+:106A8000001019C08F5801B80700FFFE3C1F2004FA
63664+:106A90003C191000AF430180AF400184AF5F018813
63665+:106AA000AF5901B80A00078C262300013082FFFF8E
63666+:106AB00014400003000018210004240224030010E5
63667+:106AC000308500FF14A000053087000F2466000801
63668+:106AD0000004220230C300FF3087000F14E00005DD
63669+:106AE000308900032468000400042102310300FF00
63670+:106AF0003089000315200005388B0001246A00024C
63671+:106B000000042082314300FF388B00013164000112
63672+:106B100010800002246C0001318300FF03E00008B4
63673+:106B200000601021308BFFFF000B394230E600FF80
63674+:106B30003C09080025295998000640800109602178
63675+:106B40008D8700003164001F240A0001008A1804A8
63676+:106B500030A500FF00E3202514A000020003102749
63677+:106B600000E22024240F000100CF700401096821F5
63678+:106B7000000E282714800005ADA400008F86000CAD
63679+:106B800000A6102403E00008AF82000C8F88000CE0
63680+:106B900001C8102503E00008AF82000C3C06001F6E
63681+:106BA0003C0360003084FFFF34C5FF8024020020D6
63682+:106BB000AC602008AC60200CAC602010AC652014E8
63683+:106BC000AC642018AC62200000000000000000004F
63684+:106BD00003E000080000000027BDFFE82402FFFFDB
63685+:106BE000AFBF0010AF82000C000020213C0608005F
63686+:106BF00024C659982405FFFF248900010004408021
63687+:106C00003124FFFF010618212C87002014E0FFFA31
63688+:106C1000AC6500000E0008160000202124020001CF
63689+:106C20003C04600024050020AC822018AC852000C4
63690+:106C3000000000000000000000000000244A0001E5
63691+:106C40003142FFFF2C46040014C0FFF78FBF001035
63692+:106C500003E0000827BD00188F8300082C620400A1
63693+:106C600003E00008384200018F830008246200011D
63694+:106C700003E00008AF8200088F8300082462FFFF52
63695+:106C800003E00008AF82000827BDFFE0AFB10014A9
63696+:106C9000AFBF0018AFB000108F6B00303C06600033
63697+:106CA00000808821ACCB20088F6A002C3C02800039
63698+:106CB00024030008ACCA200C9769003A9768003892
63699+:106CC00000092C003107FFFF00A72025ACC42010CD
63700+:106CD000ACC22014ACC32000000000000000000083
63701+:106CE000000000003C0360008C6D200031AC000807
63702+:106CF0001580FFF9000000008C6E201405C00020F4
63703+:106D0000000000000E0007DA8F84000C00024080B3
63704+:106D10003C09080025295998010938218CE4000014
63705+:106D20000E0007DA00028140020220213090FFFFAE
63706+:106D3000020020210E0007F8000028213C0C8000F2
63707+:106D4000022C58253210FFFF3C116000240A00205D
63708+:106D5000AE2B2014AE302018AE2A20000000000018
63709+:106D60000000000000000000020010218FBF00188A
63710+:106D70008FB100148FB0001003E0000827BD002081
63711+:106D80008C6620143C02001F3443FF803C1FFFE848
63712+:106D900000C3C02437F9080003198021001079C20C
63713+:106DA0003C0C8000022C582531F0FFFF3C116000A4
63714+:106DB000240A0020AE2B2014AE302018AE2A20006A
63715+:106DC0000000000000000000000000000200102190
63716+:106DD0008FBF00188FB100148FB0001003E00008BF
63717+:106DE00027BD002027BDFFE8AFB000103402FFFF31
63718+:106DF0003090FFFFAFBF00141202000602002021F6
63719+:106E00000E00081600000000020020210E0007F806
63720+:106E1000240500018F8400088FBF00148FB000107C
63721+:106E20002483FFFF27BD001803E00008AF8300089C
63722+:106E3000000439C230E6003F00043B42000718401E
63723+:106E4000240210002CC4002024C8FFE0AF42002C14
63724+:106E5000246300011480000330A900FF00071840DC
63725+:106E6000310600FF0003608024080001019A5821C8
63726+:106E70003C0A000E00C82804016A382111200005D0
63727+:106E8000000530278CE900000125302503E00008CB
63728+:106E9000ACE600008CEE000001C6682403E00008A8
63729+:106EA000ACED000027BDFFE8AFBF0014AFB000108D
63730+:106EB0003C0460008C8508083403F00030A2F00028
63731+:106EC00050430006240200018C8708083404E000C7
63732+:106ED00030E6F00010C4001E24020002AF82004021
63733+:106EE0003C1060003C0A0200AE0A0814240910009D
63734+:106EF0003C08000E8E03440003482021AF49002CBB
63735+:106F0000240501200E000CC0000030218F830040BA
63736+:106F1000106000043C021691240B0001106B000E5F
63737+:106F20003C023D2C344F0090AE0F44088FBF00143C
63738+:106F30008FB000103C0C6000240E10003C0D0200CD
63739+:106F400027BD0018AD8E442003E00008AD8D081069
63740+:106F50000A0008E7AF8000403C0218DA344F009086
63741+:106F6000AE0F44088FBF00148FB000103C0C6000BF
63742+:106F7000240E10003C0D020027BD0018AD8E4420E9
63743+:106F800003E00008AD8D08100A0008BB24050001CD
63744+:106F90000A0008BB000028213C08080025085DA461
63745+:106FA0002404FFFF010018212402001E2442FFFFD9
63746+:106FB000AC6400000441FFFD246300043C070800AA
63747+:106FC00024E75E208CE5FFFC2404001C240600015D
63748+:106FD000308A001F0146480424840001000910275C
63749+:106FE0002C8300201460FFFA00A22824ACE5FFFCEB
63750+:106FF0003C05666634A4616E3C06080024C65EE06B
63751+:10700000AF840058AF88009C2404FFFF00C0182103
63752+:107010002402001F2442FFFFAC6400000441FFFD76
63753+:10702000246300043C0766663C05080024A55EA0B6
63754+:10703000AF86004834E6616EAF8600982404FFFFF7
63755+:1070400000A018212402000F2442FFFFAC640000BE
63756+:107050000441FFFD246300043C0B66663C06080007
63757+:1070600024C65E203568616EAF8500A4AF880070CD
63758+:107070002404FFFF00C018212402001F2442FFFF48
63759+:10708000AC6400000441FFFD246300043C0D66660F
63760+:107090003C0A0800254A5F6035AC616EAF860090FF
63761+:1070A000AF8C005C2404FFFF014018212402000380
63762+:1070B0002442FFFFAC6400000441FFFD2463000490
63763+:1070C0003C09080025295F708D27FFFC2404000679
63764+:1070D000240500013099001F0325C0042484000109
63765+:1070E000001878272C8E002015C0FFFA00EF3824F6
63766+:1070F000AD27FFFC3C09666624030400240403DC7E
63767+:1071000024050200240600663522616E3C08080052
63768+:1071100025085AA4AF820074AF830044AF83006C8B
63769+:10712000AF830050AF830084AF8A008CAF840064CB
63770+:10713000AF85004CAF860054AF840078AF85006007
63771+:10714000AF86008001001821240200022442FFFFC4
63772+:10715000AC6000000441FFFD24630004240400032C
63773+:107160002403000C3C0A0800254A5AB0AF8A006884
63774+:107170000A00098E2405FFFF000418802484000102
63775+:10718000006858212C8700C014E0FFFBAD650000AB
63776+:107190003C0E666635CD616E240C17A024081800DD
63777+:1071A000AF8D0088AF8C009403E00008AF88007CAE
63778+:1071B0002484007F000421C200004021000030210F
63779+:1071C00000003821000028210A0009A5AF8400A092
63780+:1071D0001060000624E7000100C4302124A500014E
63781+:1071E0002CC20BF51440FFFA2CA300663C090800E2
63782+:1071F00025295F6001201821240200032442FFFF9B
63783+:10720000AC6000000441FFFD2463000410E0001A9C
63784+:1072100024E3FFFF0003294210A0000A0000202100
63785+:107220002406FFFF3C03080024635F602484000100
63786+:107230000085502BAC660000250800011540FFFBBF
63787+:107240002463000430E2001F10400008000868803A
63788+:10725000240C0001004C38040008588001692821E2
63789+:1072600024E6FFFF03E00008ACA6000001A94021CE
63790+:107270002409FFFFAD09000003E000080000000042
63791+:10728000AF4400283C04000C034420210005288260
63792+:107290000A000CC000003021000421803C03600083
63793+:1072A000AC6410080000000000052980AC65100CDB
63794+:1072B0000000000003E000088C62100C27BDFFE80E
63795+:1072C0000080282124040038AFBF00140E0009D527
63796+:1072D000AFB0001024040E00AF4400283C10000C96
63797+:1072E00003502021240500100E000CC000003021A6
63798+:1072F00003501021AC400000AC40000424040038CE
63799+:107300008FBF00148FB0001024053FFF27BD001869
63800+:107310000A0009D58C430000000421803C03600072
63801+:10732000AC641008000000008C62100C03E0000840
63802+:107330000002118227BDFFC8AFB400208F940068FF
63803+:10734000AFBE0030AFB7002CAFB600280000B821A8
63804+:107350000080B021241E00C0AFBF0034AFB50024B0
63805+:10736000AFB3001CAFB20018AFB10014AFB0001043
63806+:107370000A000A12AFA5003C504000018F9400683B
63807+:1073800027DEFFFF13C00028269400048E92000021
63808+:107390003C03080024635DA01240FFF70283102B1A
63809+:1073A0003C04080024845AA4028410230002A8C0CC
63810+:1073B000000098210A000A212411000100118840D0
63811+:1073C000122000260000000002B380210251282470
63812+:1073D0000200202110A0FFF9267300010E0009DE33
63813+:1073E000000000000016684032EC000101AC2021D2
63814+:1073F0000E0009D5020028218F89009426F700018C
63815+:107400008FA6003C3AEB0001316A00012528FFFFFE
63816+:107410000011382702CAB021AF88009416E6FFE7B2
63817+:1074200002479024AE92000002E010218FBF00348A
63818+:107430008FBE00308FB7002C8FB600288FB5002488
63819+:107440008FB400208FB3001C8FB200188FB10014CE
63820+:107450008FB0001003E0000827BD00383C0E080084
63821+:1074600025CE5DA0028E102B0A000A0DAE92000000
63822+:1074700027BDFFD8AFB10014AFB00010AFBF0020E0
63823+:10748000AFB3001CAFB2001800A0882110A0001FED
63824+:10749000000480403C13080026735AA40A000A5ACC
63825+:1074A0002412000112200019261000010E0009F517
63826+:1074B00002002021000231422444FFA0000618806F
63827+:1074C0003045001F2C8217A1007318212631FFFFC1
63828+:1074D0001040FFF400B230048C690000020020214B
63829+:1074E00024053FFF012640241500FFEE0126382524
63830+:1074F0000E0009D5AC6700008F8A009426100001A9
63831+:10750000254700011620FFE9AF8700948FBF0020B8
63832+:107510008FB3001C8FB200188FB100148FB0001011
63833+:1075200003E0000827BD00288F85009C00805821BB
63834+:107530000000402100004821240A001F3C0C0800E4
63835+:10754000258C5E1C3C0D080025AD5DA48CA60000BA
63836+:1075500050C000140000402100AD1023000238C0CC
63837+:10756000240300010A000A930000202115000003F3
63838+:1075700000E410212448202400004821252900018E
63839+:10758000512B00132506DFDC106000062484000167
63840+:1075900000C3702415C0FFF5000318400A000A91CB
63841+:1075A0000000402110AC002624A300040060282124
63842+:1075B000254AFFFF1540FFE5AF85009C512B0004D5
63843+:1075C0002506DFDC0000402103E000080100102157
63844+:1075D0000006614230C5001F000C50803C070800C7
63845+:1075E00024E75DA424040001014730211120000F8D
63846+:1075F00000A420043C05080024A55E20148000059A
63847+:107600002529FFFF24C6000410C50011000000005A
63848+:10761000240400018CCF00000004C0270004204097
63849+:1076200001F868241520FFF5ACCD00008F99007893
63850+:1076300001001021032B482303E00008AF890078E4
63851+:107640003C05080024A55DA40A000A9B0000402117
63852+:107650003C06080024C65DA40A000AB42404000104
63853+:10766000308800FF240200021102000A24030003F4
63854+:107670001103005C8F8900A4240400041104005F3E
63855+:1076800024050005110500670000182103E000082B
63856+:10769000006010218F8900483C0C0800258C5EE0BA
63857+:1076A0003C04080024845F60240300201060000F65
63858+:1076B00000005821240D0002240E00033C0F080096
63859+:1076C00025EF5EE08D27000014E0000B30F9FFFF8E
63860+:1076D000252900040124C02B53000001018048210A
63861+:1076E0002463FFFF5460FFF88D270000016018211C
63862+:1076F00003E0000800601021132000323C0500FF69
63863+:1077000030E200FF004030211040004200005021D4
63864+:1077100024050001000020210005C84000A6C02467
63865+:1077200017000003332500FF14A0FFFB2484000191
63866+:10773000012CC023001828C000AA6021008C502111
63867+:107740003144001F240C0001008C18040003102792
63868+:1077500000E23024110D0041AD260000110E004C56
63869+:10776000000A1840110D00368F87006C510E00562C
63870+:107770008F8C0060240D0004110D005A8F8E008440
63871+:10778000240E0005150EFFDA01601821240B1430B9
63872+:1077900011400006000018218F8400A0246300011E
63873+:1077A000006A402B1500FFFD016458218F8A00807C
63874+:1077B000AF89008C016018212549FFFF0A000AEB00
63875+:1077C000AF89008000E52024000736021080FFD03A
63876+:1077D000240A001800075402314600FF0A000AF389
63877+:1077E000240A00103C0C0800258C5EA03C04080014
63878+:1077F00024845EE00A000ADA240300103C0C08002E
63879+:10780000258C5E203C04080024845EA00A000AD96E
63880+:107810008F89009000071A02306600FF0A000AF301
63881+:10782000240A00088F89008C3C0C0800258C5F60BE
63882+:107830003C04080024845F700A000ADA2403000470
63883+:10784000000A4080250B003024E6FFFF016018216C
63884+:10785000AF8900480A000AEBAF86006C000AC982B3
63885+:10786000001978803C07080024E75EA001E720218A
63886+:10787000000A18428C8F00003079001F032C380456
63887+:107880000007C02701F860240A000B08AC8C000038
63888+:10789000000331420006288000AF28213062001F1B
63889+:1078A0008CB8000024630001004CC804000321428E
63890+:1078B000001938270004108003073024004F2021CE
63891+:1078C0000A000B4CACA60000000A68C025AB0032D1
63892+:1078D000258AFFFF01601821AF8900A40A000AEB86
63893+:1078E000AF8A0060254B1030AF89009001601821ED
63894+:1078F00025C9FFFF0A000AEBAF8900843086000724
63895+:107900002CC2000610400014000000000006408059
63896+:107910003C030800246357BC010338218CE40000B9
63897+:1079200000800008000000002409000310A9000ED8
63898+:1079300000000000240A000510AA000B000000004F
63899+:10794000240B000110AB0008000000008F8C00A089
63900+:1079500010AC00050000000003E00008000010214A
63901+:107960000A000A7900A020210A000AC700C02021CD
63902+:1079700027BDFFE8308400FF240300021083000BC2
63903+:10798000AFBF0010240600031086003A240800044C
63904+:1079900010880068240E0005108E007F2CAF143074
63905+:1079A0008FBF001003E0000827BD00182CA2003094
63906+:1079B0001440FFFC8FBF001024A5FFD0000531C28A
63907+:1079C000000668803C07080024E75EE001A730213C
63908+:1079D0008CC900000005288230AC001F240B000178
63909+:1079E000018B50048F840048012A4025ACC8000058
63910+:1079F0008C83000050600001AF8600488F98006CB7
63911+:107A000030AE000124A6FFFF270F000115C00002C1
63912+:107A1000AF8F006C24A600010006414200082080C0
63913+:107A2000008718218C79000030C2001F2406000155
63914+:107A30000046F804033F382410E0FFDA8FBF00103F
63915+:107A40000005C182001870803C0F080025EF5EA081
63916+:107A500001CF48218D2B00000005684231A5001F91
63917+:107A600000A66004016C502527BD001803E0000843
63918+:107A7000AD2A00002CA7003014E0FFCA8FBF001011
63919+:107A800030B900071723FFC724A8FFCE00086A02F9
63920+:107A9000000D60803C0B0800256B5EA0018B30213F
63921+:107AA0008CC40000000828C230AA001F240800016E
63922+:107AB000014848048F8200A400891825ACC3000047
63923+:107AC0008C5F000053E00001AF8600A40005704009
63924+:107AD000000E7942000F28803C04080024845EE0F8
63925+:107AE00000A418218C6B000025DF000131CD001FA0
63926+:107AF000001F514201A86004016C4825000A108053
63927+:107B0000AC690000004428218CA600008F9800601A
63928+:107B100033F9001F8FBF00100328380400C77825F1
63929+:107B2000270E000127BD0018ACAF000003E00008DD
63930+:107B3000AF8E006024A5EFD02CB804001300FF998D
63931+:107B40008FBF001000053142000658803C0A080033
63932+:107B5000254A5E20016A30218CC4000030A3001F3A
63933+:107B600024090001006910048F9900900082F82513
63934+:107B7000ACDF00008F27000050E00001AF860090CE
63935+:107B80008F8D00848FBF001027BD001825AC000129
63936+:107B900003E00008AF8C008415E0FF828FBF001067
63937+:107BA0008F8600A0000610400046F821001F21002B
63938+:107BB00003E4C8210019384024F8143000B8402BE1
63939+:107BC0001100FF788FBF001024A4EBD00E00021329
63940+:107BD00000C0282100027942000F70803C0D08008F
63941+:107BE00025AD5F6001CD20218C8B0000304C001F43
63942+:107BF00024060001018618048F89008C016350253A
63943+:107C0000AC8A00008D25000050A00001AF84008CDC
63944+:107C10008F9800808FBF001027BD00182708000133
63945+:107C200003E00008AF88008030A5000724030003AC
63946+:107C300010A3001028A2000414400008240700022A
63947+:107C40002403000410A300152408000510A8000F49
63948+:107C50008F8500A003E000080000000014A7FFFDCE
63949+:107C60000080282114C3FFFB240400020A000B8BB0
63950+:107C700000000000240900050080282110C9FFFB36
63951+:107C80002404000303E000080000000014C5FFF115
63952+:107C9000008028210A000B8B24040005240A00011F
63953+:107CA0000080282110CAFFF12404000403E000082A
63954+:107CB0000000000027BDFFE0AFB00010000581C24A
63955+:107CC0002603FFD024C5003F2C6223D024C6007FAA
63956+:107CD000AFB20018AFB10014AFBF001C309100FF6D
63957+:107CE000000691C2000529820200202110400008F0
63958+:107CF0002403FFFF0E000A4B0000000002002021B9
63959+:107D0000022028210E000C390240302100001821E9
63960+:107D10008FBF001C8FB200188FB100148FB00010FD
63961+:107D20000060102103E0000827BD002027BDFFD818
63962+:107D300024A2007FAFB3001CAFB20018000299C2AA
63963+:107D4000309200FF24A3003F02402021026028213E
63964+:107D5000AFB10014AFB00010AFBF00200E000B6E2B
63965+:107D60000003898200408021004020210220282138
63966+:107D700014400009000018218FBF00208FB3001CA1
63967+:107D80008FB200188FB100148FB000100060102166
63968+:107D900003E0000827BD00280E0009FC00000000D9
63969+:107DA00000402821020020211051FFF3001019C0CB
63970+:107DB0000E000A4B00000000020020210240282192
63971+:107DC0000E000C39026030218FBF00208FB3001CE1
63972+:107DD0008FB200188FB100148FB00010000018216E
63973+:107DE0000060102103E0000827BD00283084FFFF59
63974+:107DF00030A5FFFF1080000700001821308200012D
63975+:107E00001040000200042042006518211480FFFB8E
63976+:107E10000005284003E000080060102110C00007A2
63977+:107E2000000000008CA2000024C6FFFF24A500046F
63978+:107E3000AC82000014C0FFFB2484000403E00008AF
63979+:107E40000000000010A0000824A3FFFFAC86000083
63980+:107E500000000000000000002402FFFF2463FFFF79
63981+:107E60001462FFFA2484000403E00008000000000C
63982+:107E700030A5FFFF8F4201B80440FFFE3C076015AC
63983+:107E800000A730253C031000AF440180AF400184BF
63984+:107E9000AF46018803E00008AF4301B88F8500D0EA
63985+:107EA0002C864000008018218CA700840087102BAE
63986+:107EB00014400010000000008CA800842D06400033
63987+:107EC00050C0000F240340008CAA0084008A482B75
63988+:107ED000512000018CA3008400035A42000B208033
63989+:107EE0003C05080024A558200085182103E000085F
63990+:107EF0008C62000014C0FFF4000000002403400066
63991+:107F000000035A42000B20803C05080024A558209D
63992+:107F10000085182103E000088C6200008F8300D0E8
63993+:107F2000906600D024C50001A06500D08F8500D0E8
63994+:107F3000906400D090A200D210440017000000000E
63995+:107F4000936C00788F8B00BC318A00FFA16A000C13
63996+:107F500025490001938700C4312200FF3048007F8B
63997+:107F60001107000B00026827A36200788F4E01788A
63998+:107F700005C0FFFE8F9900B0241800023C0F1000CE
63999+:107F8000AF590140A358014403E00008AF4F017806
64000+:107F90000A000D0931A20080A0A000D00A000CFF49
64001+:107FA000000000008F8700D027BDFFC8AFBF0030A2
64002+:107FB000AFB7002CAFB60028AFB50024AFB4002097
64003+:107FC000AFB3001CAFB20018AFB10014AFB00010D7
64004+:107FD00094E300E094E200E2104300D72405FFFFA1
64005+:107FE0003C047FFF3497FFFF2415FF800A000DF04B
64006+:107FF0003C16000E108A00D18FBF00308F9100B068
64007+:108000003C1808008F18005C001230C0001291402C
64008+:108010000311702101D57824AF4F002C94EC00E2BD
64009+:1080200031CD007F01BA5821318A7FFF0176482186
64010+:10803000000A804002091021945300003C08080007
64011+:108040008D0800580246C02132733FFF001319808B
64012+:10805000010320210224282130BF007F03FAC82118
64013+:1080600000B5A024AF54002C0336A0218E87001049
64014+:108070008E8F003003785821256D008800EF702323
64015+:10808000240C0002AE8E0010AF8D00ACA16C0088F5
64016+:10809000976A003C8E8400308F9100AC0E000CD6A5
64017+:1080A0003150FFFF00024B80020940253C02420094
64018+:1080B00001022025AE2400048E8300048F8D00ACC5
64019+:1080C0008E860000240E0008ADA3001CADA600188B
64020+:1080D000ADA0000CADA00010929F000A33F900FF84
64021+:1080E000A5B90014968500083C1F000CA5A5001634
64022+:1080F0009298000A331100FFA5B100209690000865
64023+:1081000024180005A5B00022ADA00024928F000B1A
64024+:108110002410C00031E700FFA5A70002A1AE0001B6
64025+:108120008E8C00308F8B00AC8F8400B0AD6C00085B
64026+:108130003C0A08008D4A005401444821013540247E
64027+:10814000AF4800283C0208008C4200540044302113
64028+:1081500030C3007F007AC821033F282102458821CF
64029+:10816000AF9100BCAF8500C0A23800008F8A00BC70
64030+:108170002403FFBF2418FFDF954F000201F03824CD
64031+:1081800000F37025A54E0002914D000231AC003F76
64032+:10819000358B0040A14B00028F8600BC8F8900D038
64033+:1081A000ACC000048D28007C3C098000ACC80008ED
64034+:1081B00090C4000D3082007FA0C2000D8F8500BCEE
64035+:1081C00090BF000D03E3C824A0B9000D8F9100BC3F
64036+:1081D0009233000D02789024A232000D8E9000346C
64037+:1081E0008F8B00BCAD7000108E87002C8E8F0030FE
64038+:1081F00000EF7023AD6E0014916D001831AC007F5C
64039+:10820000A16C00188F9F00BC8E8A00308FE8001888
64040+:10821000015720240109302400C41025AFE20018C2
64041+:108220009283000AA3E3001C969900088F8500BC86
64042+:108230008F9800D0A4B9001E8E9000308E8400303C
64043+:108240000E0002138F0500848F8500D0000291403C
64044+:108250000002990090AF00BC0253882100403021F9
64045+:1082600031E7000210E0000302118021000290803B
64046+:108270000212802190B900BC3327000410E00002F4
64047+:108280000006F880021F80218E9800308F8B00BC82
64048+:1082900024068000330F0003000F702331CD00034C
64049+:1082A000020D6021AD6C000494A400E294AA00E2E7
64050+:1082B00094B000E231497FFF2522000130537FFF57
64051+:1082C0000206182400734025A4A800E294A400E24A
64052+:1082D0003C1408008E94006030917FFF123400221D
64053+:1082E000000000000E000CF6000000008F8700D098
64054+:1082F0000000282194F300E094F000E21213000F34
64055+:108300008FBF003090E900D090E800D1313200FFFB
64056+:10831000310400FF0244302B14C0FF36264A00010E
64057+:1083200090EE00D2264B000131CD00FF008D602180
64058+:10833000158BFF338F9100B08FBF00308FB7002CAB
64059+:108340008FB600288FB500248FB400208FB3001C97
64060+:108350008FB200188FB100148FB0001000A0102150
64061+:1083600003E0000827BD003894A300E20066402423
64062+:10837000A4A800E290A400E290B900E2309100FFCE
64063+:108380000011A1C20014F827001F39C03332007F4A
64064+:10839000024730250A000DE8A0A600E23084FFFF66
64065+:1083A00030A5FFFFAF440018AF45001C03E00008F4
64066+:1083B0008F42001427BDFFB8AFB000208F9000D0CF
64067+:1083C0003084FFFFAFA40010AFBF0044AFBE004039
64068+:1083D000AFB7003CAFB60038AFB50034AFB4003033
64069+:1083E000AFB3002CAFB20028AFB10024A7A0001893
64070+:1083F000920600D1920500D030C400FF30A300FFE8
64071+:108400000064102B10400122AFA00014920900D08C
64072+:108410008FB50010312800FF0088382324F4FFFFB7
64073+:108420000014882B0015982B02339024524001260B
64074+:108430008FB40014961E0012961F00108FB7001004
64075+:1084400003DFC823001714000019C400000224032E
64076+:108450000018140302E2B02A52C00001004020219B
64077+:108460000284282B10A0000200801821028018210D
64078+:1084700000033C0000071C033064FFFF2C8600094A
64079+:1084800014C000020060B821241700088E0A0008FA
64080+:10849000001769808E09000C31ABFFFF3C0C001007
64081+:1084A000016C402527520400AF4A0038AF9200B853
64082+:1084B000AF49003CAF480030000000000000000061
64083+:1084C00000000000000000000000000000000000AC
64084+:1084D00000000000000000008F4F000031EE00207F
64085+:1084E00011C0FFFD0017982A027110240A000E83A4
64086+:1084F0000000B02155E001019258000131130080C5
64087+:10850000126001CF012020219655001232A5FFFFF5
64088+:108510000E000CCBA7B500188F9000D00291A023BD
64089+:1085200026CD00018F9100B8000DB4000016B403F1
64090+:108530002638004002D7582A0014882B2405000151
64091+:108540000300902101711024AF9800B8AFA500146A
64092+:10855000104001BC8F8900B03C0C08008D8C005489
64093+:10856000240BFF80921E00D001895021014B28244A
64094+:10857000921900D0AF4500288E4700103C08080033
64095+:108580008D0800583C1808008F18005430E33FFF56
64096+:108590000003218001043021012658212402FF809C
64097+:1085A0000162F824920C00D0AF5F002C92480000CA
64098+:1085B00033D100FF333500FF0309982100117140CA
64099+:1085C000001578C0326D007F01CF382101BA282113
64100+:1085D000318300FF3164007F3C0A000C00AA88212F
64101+:1085E0000367F02100033140009A10213108003F59
64102+:1085F0003C1F000E00D1C021005F982127D90088C0
64103+:108600002D150008AF9100C0AF9900ACAF9800BC29
64104+:10861000AF9300B412A0018A00008821240E00014B
64105+:10862000010E4004310D005D11A0FFB2310F0002B8
64106+:108630008E4A00283C0300803C04FFEFAE6A000035
64107+:108640008E450024A260000A3488FFFFAE65000456
64108+:108650009247002C3C1FFF9F37FEFFFFA267000CD4
64109+:108660008E62000C3C180040A267000B00433025CE
64110+:1086700000C8C824033E88240238A825AE75000C23
64111+:108680008E490004AE6000183C0F00FFAE69001474
64112+:108690008E4D002C35EEFFFF8F8B00B001AE6024B5
64113+:1086A000AE6C00108E470008A660000896450012C8
64114+:1086B000AE6700208E42000C30B03FFF00105180AA
64115+:1086C000AE6200248E5E0014014B182130A400011C
64116+:1086D000AE7E00288E590018000331C2000443808A
64117+:1086E000AE79002C8E51001C00C8F821A67F001C1A
64118+:1086F000AE710030965800028E550020A678001EFC
64119+:10870000AE75003492490033313000045600000544
64120+:10871000925000008F8C00D08D8B007CAE6B0030AF
64121+:10872000925000008F8F00BCA1F00000924E0033E9
64122+:1087300031CD000251A00007925E00018F8900BC7C
64123+:108740002418FF80913100000311A825A1350000F5
64124+:10875000925E00018F9900BC2409FFBF240BFFDF4C
64125+:10876000A33E00018F9500BC92B8000D3311007F2D
64126+:10877000A2B1000D8F8E00BC91D0000D02097824AB
64127+:10878000A1CF000D8F8800BC8E6D0014910A000DE2
64128+:108790002DAC0001000C2940014B382400E51825C0
64129+:1087A000A103000D964200128F8800BC8F8700D075
64130+:1087B000A50200028E45000490FF00BC30A4000317
64131+:1087C0000004302330DE000300BE102133F9000224
64132+:1087D00017200002244400342444003090E200BCFE
64133+:1087E00000A2302430DF000417E0000224830004DC
64134+:1087F000008018218F8F00AC24090002AD03000413
64135+:10880000A1E90000924E003F8F8D00ACA1AE0001A7
64136+:108810008F9500AC924C003F8E440004A6AC000241
64137+:10882000976B003C0E000CD63170FFFF00025380A6
64138+:10883000020A38253C05420000E51825AEA30004D5
64139+:108840008F8600AC8E480038ACC800188E440034C7
64140+:10885000ACC4001CACC0000CACC00010A4C0001420
64141+:10886000A4C00016A4C00020A4C00022ACC00024F4
64142+:108870008E6400145080000124040001ACC4000880
64143+:108880000E000CF6241100010A000E768F9000D025
64144+:10889000920F00D2920E00D08FB5001031EB00FF86
64145+:1088A00031CD00FF008D6023016C50212554FFFF66
64146+:1088B0000014882B0015982B023390241640FEDDFF
64147+:1088C000000000008FB400148FBF00448FBE004032
64148+:1088D0003A8200018FB7003C8FB600388FB5003464
64149+:1088E0008FB400308FB3002C8FB200288FB10024DA
64150+:1088F0008FB0002003E0000827BD0048331100209E
64151+:10890000122000EF24150001921E00BC241F00015C
64152+:108910000000A82133D900011320000DAFBF001CB7
64153+:108920008E4400148E0800840088102B144000022E
64154+:10893000008030218E0600848E03006400C3A82BC3
64155+:1089400016A0000200C020218E0400640080A8212F
64156+:108950008E4700148E05006400E5302B14C0000221
64157+:1089600000E020218E0400640095F02313C0000471
64158+:108970008FAC001C240A0002AFAA001C8FAC001CA4
64159+:10898000028C582B156000A8000018218E4F00386B
64160+:108990008E6D000C3C0E0080AE6F00008E4A0034DD
64161+:1089A0003C10FF9F01AE5825AE6A00049246003F7E
64162+:1089B000360CFFFF016C38243C0500203C03FFEF20
64163+:1089C000A266000B00E510253468FFFF8F8700B812
64164+:1089D0000048F8243C04000803E4C825AE79000CE4
64165+:1089E0008CF80014AE60001802BE7821AE78001436
64166+:1089F0008CF10018AE71001C8CE90008AE690024EF
64167+:108A00008CEE000CAE6F002CAE600028AE6E002025
64168+:108A1000A6600038A660003A8CED001401B58023F2
64169+:108A2000021E902312400011AE72001090EA003D29
64170+:108A30008E6500048E640000000A310000A6C82183
64171+:108A4000000010210326402B0082F82103E8C021FA
64172+:108A5000AE790004AE78000090F1003DA271000AEA
64173+:108A60008F8900B895320006A67200088F9800AC76
64174+:108A70002419000202A02021A31900009769003CDC
64175+:108A80008F9200AC0E000CD63131FFFF00027B80CC
64176+:108A90008F8500B8022F68253C0E420001AE80256C
64177+:108AA000AE5000048F8400AC8CAC0038AC8C001845
64178+:108AB0008CAB0034AC8B001CAC80000CAC80001084
64179+:108AC000A4800014A4800016A4800020A4800022AA
64180+:108AD000AC80002490A7003FA487000212A00135BB
64181+:108AE0002403000153C0000290A2003D90A2003E6A
64182+:108AF00024480001A08800018F9F00ACAFF500085A
64183+:108B00008F8300D024070034906600BC30C500027B
64184+:108B100050A00001240700308F9200B88F8A00BC5B
64185+:108B2000906D00BC924B00002412C00032A50003DF
64186+:108B3000A14B00008F8600B88F8800BC240200047F
64187+:108B400090C400010045182330790003A1040001FE
64188+:108B50008F8A00BC8F9F00B800F53821955800021D
64189+:108B600097E9001200F9382103128824312F3FFFC2
64190+:108B7000022F7025A54E00029150000231A800047A
64191+:108B8000320C003F358B0040A14B000212A00002C6
64192+:108B90008F8500BC00E838218F8E00D0ACA7000480
64193+:108BA000240BFFBF8DCD007C2EA400012403FFDF2A
64194+:108BB000ACAD000890B0000D00044140320C007FC5
64195+:108BC000A0AC000D8F8600BC90CA000D014B102494
64196+:108BD000A0C2000D8F8700BC90E5000D00A3F82413
64197+:108BE00003E8C825A0F9000D8F9100B88F8D00BC57
64198+:108BF0008E380020ADB800108E290024ADA90014D5
64199+:108C00008E2F0028ADAF00188E2E002C0E000CF613
64200+:108C1000ADAE001C8FB0001C240C0002120C00EE44
64201+:108C20008F9000D08FA3001C006088211460000288
64202+:108C30000060A8210000A02156A0FE390291A023C7
64203+:108C40000014882B8FA90010960700103C1E0020EE
64204+:108C50000136402302C750213112FFFFA60A00103F
64205+:108C6000AFB20010AF5E0030000000009617001099
64206+:108C7000961300121277008F000000008E05000C82
64207+:108C80008E0B00080016698000AD7021000DC7C36F
64208+:108C900001CDA82B0178782101F56021AE0E000CE2
64209+:108CA000AE0C00088FB300100013B82B02378024DD
64210+:108CB0001200FF048F9000D00A000E3C000000005C
64211+:108CC0008E4D0038A6600008240B0003AE6D000036
64212+:108CD0008E500034A260000A8F9800B8AE70000475
64213+:108CE0003C0500809311003FA26B000C8E6F000CBE
64214+:108CF0003C0EFF9FA271000B01E5102535CCFFFF54
64215+:108D00003C03FFEF8F9200B8004C30243464FFFF27
64216+:108D100000C4F824AE7F000C8E590014964800124F
64217+:108D20008F8A00B0AE7900108E490014AE60001832
64218+:108D3000AE600020AE690014AE6000248E470018BB
64219+:108D400031093FFF0009F180AE6700288E4D000811
64220+:108D500003CA802131180001AE6D00308E4F000C27
64221+:108D60008F8C00AC001089C200185B80022B282178
64222+:108D7000240E0002A665001CA6600036AE6F002C13
64223+:108D8000A18E00009763003C8F8A00AC3C04420037
64224+:108D90003062FFFF00443025AD4600048F9F00B8CD
64225+:108DA000240700012411C0008FF30038240600348A
64226+:108DB000AD5300188FF90034AD59001CAD40000CC4
64227+:108DC000AD400010A5400014A5400016A5400020AD
64228+:108DD000A5400022AD400024A5550002A147000196
64229+:108DE0008F9E00AC8F8800B88F9200BCAFD5000872
64230+:108DF000910D0000A24D00008F9000B88F8B00BC39
64231+:108E000092180001A17800018F8400BC94850002B3
64232+:108E100000B1782401E97025A48E0002908C000234
64233+:108E20003183003FA08300028F8300D08F8400BC79
64234+:108E3000906200BC305300025260000124060030F2
64235+:108E4000AC8600048C6F007C2403FFBF02A0882145
64236+:108E5000AC8F0008908E000D31CC007FA08C000DEF
64237+:108E60008F8600BC90C2000D00432024A0C4000DDA
64238+:108E70008F8900BC913F000D37F90020A139000D0A
64239+:108E80008F8800B88F9300BC8D070020AE6700105C
64240+:108E90008D0A0024AE6A00148D1E0028AE7E0018D4
64241+:108EA0008D12002C0E000CF6AE72001C0A00103D54
64242+:108EB0008F9000D0960E00148E03000431CCFFFF7B
64243+:108EC000000C10C000622021AF44003C8E1F000443
64244+:108ED0008F46003C03E6C8231B20003C0000000036
64245+:108EE0008E0F000025E200013C05001034B500089B
64246+:108EF000AF420038AF550030000000000000000015
64247+:108F00000000000000000000000000000000000061
64248+:108F100000000000000000008F580000330B00200C
64249+:108F20001160FFFD000000008F5304003C0D002085
64250+:108F3000AE1300088F570404AE17000CAF4D00307D
64251+:108F4000000000003C0608008CC600442416000106
64252+:108F500010D600BD00000000961F00123C0508005E
64253+:108F60008CA5004000BFC821A61900129609001464
64254+:108F700025270001A6070014960A00143144FFFFBC
64255+:108F80005486FF498FB30010A60000140E000E1681
64256+:108F900030A5FFFF3C0408008C84002496030012D7
64257+:108FA0000044102300623023A60600120A00105964
64258+:108FB0008FB30010A08300018F8200AC2404000155
64259+:108FC000AC4400080A000FF08F8300D08E0200002E
64260+:108FD0000A0010EA3C0500108F8200C08FA7001C19
64261+:108FE000921800D0920B00D0920E00D0331100FFE7
64262+:108FF000316900FF00117940000928C001E56021B6
64263+:1090000031C300FF036C50210003314000C2C8216E
64264+:10901000255F0088AF9F00ACAF9900BCA1470088D6
64265+:109020009768003C03C020218F9100AC0E000CD645
64266+:109030003110FFFF00026B80020DC0253C0442008E
64267+:109040008F8D00B803045825AE2B00048DA900387D
64268+:109050008F8B00AC0000882100118100AD690018E1
64269+:109060008DAF00343C087FFF3504FFFFAD6F001C5F
64270+:1090700091AC003E8D65001C8D660018000C190037
64271+:10908000000C770200A33821020E102500E3F82B14
64272+:1090900000C2C821033F5021AD67001CAD6A001813
64273+:1090A000AD60000CAD60001091B8003E24050005D5
64274+:1090B00003C45024A578001495A9000403C02021FE
64275+:1090C000A569001691AF003EA56F002095B1000480
64276+:1090D000A5710022AD60002491AE003FA56E000294
64277+:1090E00091B0003E91AC003D01901023244300015B
64278+:1090F000A16300018F8600AC8F9F00BCACDE00082E
64279+:10910000A3E500008F9000BC8F9900B82405FFBF35
64280+:1091100096070002973800120247782433093FFF70
64281+:1091200001E98825A6110002921200022418FFDF2F
64282+:10913000324E003F35CD0040A20D00028F8600BCAC
64283+:109140008F8C00D02412FFFFACC000048D8B007CFC
64284+:109150003C0C8000ACCB000890C2000D3043007F77
64285+:10916000A0C3000D8F8700BC90FF000D03E5C8244D
64286+:10917000A0F9000D8F9100BC9229000D01387824D0
64287+:10918000A22F000D8F9000BCAE120010AE1500147F
64288+:10919000920E00182415FF8002AE6825A20D00185B
64289+:1091A0008F8500BC8F8300B88CAB0018016C102435
64290+:1091B000004A3025ACA600189068003EA0A8001C0C
64291+:1091C0008F9F00B88F8700BC8F9800D097F900045C
64292+:1091D000A4F9001E0E0002138F0500848F8600D0B4
64293+:1091E000000279400002490090D200BC01E98821C8
64294+:1091F000004028213255000212A0000303D1202193
64295+:109200000002A8800095202190CD00BC31B200045E
64296+:109210001240000333DF0003000540800088202156
64297+:10922000240600048F9E00BC00DFC8233327000300
64298+:1092300000875021AFCA00040E000CF6A665003866
64299+:109240000A0010388F9000D0961E00123C080800CB
64300+:109250008D080024011E9021A61200120A00105948
64301+:109260008FB3001027BDFFE03C1808008F18005096
64302+:10927000AFB00010AFBF0018AFB10014AF8400B0A2
64303+:1092800093710074030478212410FF8031EE007F75
64304+:109290003225007F01F0582401DA68213C0C000AD5
64305+:1092A000A38500C401AC2821AF4B002494A9001071
64306+:1092B0009768000690A600620080382124020030E2
64307+:1092C0000109202330C300F0AF8500D010620019DF
64308+:1092D0003090FFFF90AE0062240DFFF0240A005092
64309+:1092E00001AE6024318B00FF116A002F00000000E6
64310+:1092F00016000007241F0C00AF5F00248FB100147C
64311+:109300008FBF00188FB0001003E0000827BD0020B9
64312+:109310000E000E1C02002021241F0C00AF5F002451
64313+:109320008FB100148FBF00188FB0001003E0000849
64314+:1093300027BD002094A200E094A400E290BF011396
64315+:10934000008218263079FFFF33E700C014E00009DF
64316+:109350002F31000116000038000000005620FFE603
64317+:10936000241F0C000E000D18000000000A0011ED73
64318+:10937000241F0C001620FFDE000000000E000D1858
64319+:10938000000000001440FFDC241F0C001600002227
64320+:109390008F8300D0906901133122003FA062011336
64321+:1093A0000A0011ED241F0C0094AF00D48F8600D466
64322+:1093B00000E02821240400050E000C5C31F0FFFFC2
64323+:1093C0001440000524030003979100E600001821D3
64324+:1093D0002625FFFFA78500E68F5801B80700FFFE8E
64325+:1093E0003C196013AF400180241F0C00AF50018472
64326+:1093F000007938253C101000AF4701888FB1001468
64327+:10940000AF5001B8AF5F00248FB000108FBF0018BD
64328+:1094100003E0000827BD00200E000E1C02002021E2
64329+:109420005040FFB5241F0C008F8300D090690113BA
64330+:109430000A0012163122003F0E000E1C02002021ED
64331+:109440001440FFAD241F0C00122000078F8300D0B2
64332+:10945000906801133106003F34C20040A06201133E
64333+:109460000A0011ED241F0C000E000D180000000072
64334+:109470005040FFA1241F0C008F8300D0906801137F
64335+:109480003106003F0A00124634C20040AF9B00C8BC
64336+:1094900003E00008AF8000EC3089FFFF0009404284
64337+:1094A0002D020041000921801440000200095040B3
64338+:1094B00024080040000830C0000811400046582130
64339+:1094C000256701A800E2C821272F007F2418FF800C
64340+:1094D00001F818240064302100CA702125CC00FF57
64341+:1094E000240DFF00018D202425650088240A0088B2
64342+:1094F0003C010800AC2A004C3C010800AC2500509F
64343+:10950000AF8400D43C010800AC2900603C01080095
64344+:10951000AC2800643C010800AC2700543C01080062
64345+:10952000AC2300583C010800AC26005C03E00008B6
64346+:1095300000000000308300FF30C6FFFF30E400FF72
64347+:109540008F4201B80440FFFE00034C00012438257F
64348+:109550003C08600000E820253C031000AF45018076
64349+:10956000AF460184AF44018803E00008AF4301B86F
64350+:109570008F86001C3C096012352700108CCB00043C
64351+:109580003C0C600E35850010316A00062D48000144
64352+:10959000ACE800C48CC40004ACA431808CC20008C8
64353+:1095A00094C30002ACA2318403E00008A78300E466
64354+:1095B0003C0308008C6300508F8400E88F86001CF9
64355+:1095C0002402FF800064C0210302C824AF59002890
64356+:1095D0008CCD00043305007F00BA78213C0E000CCE
64357+:1095E00001EE2821ACAD00588CC80008AF8500D032
64358+:1095F0003C076012ACA8005C8CCC001034E8001072
64359+:10960000ACAC000C8CCB000CACAB000894AA0014E2
64360+:109610003C0208008C42004425490001A4A9001422
64361+:1096200094A400143083FFFF106200178F8400D0D1
64362+:109630003C0A08008D4A0040A4AA00128CCE0018F3
64363+:10964000AC8E00248CCD0014AC8D00208CC700188B
64364+:10965000AC87002C8CCC001424060001AC8C0028B4
64365+:109660008D0B00BC5166001A8D0200B48D0200B84B
64366+:10967000A482003A948F003AA48F003C948800D4CE
64367+:1096800003E000083102FFFF3C0908008D29002497
64368+:10969000A4A000148F8400D0A4A900128CCE0018BE
64369+:1096A000AC8E00248CCD0014AC8D00208CC700182B
64370+:1096B000AC87002C8CCC001424060001AC8C002854
64371+:1096C0008D0B00BC5566FFEA8D0200B88D0200B418
64372+:1096D000A482003A948F003AA48F003C948800D46E
64373+:1096E00003E000083102FFFF8F86001C3C0C0800DD
64374+:1096F0008D8C0050240BFF808CCD00083C03000CA7
64375+:10970000000D51C0018A4021010B4824AF8A00E8B6
64376+:10971000AF49002890C700073105007F00BA10212B
64377+:109720000043282130E4000410800039AF8500D0C8
64378+:1097300090CF000731EE000811C000380000000093
64379+:109740008CD9000C8CC400140324C02B13000030EF
64380+:10975000000000008CC2000CACA200648CCD00188C
64381+:109760002402FFF8ACAD00688CCC0010ACAC0080DB
64382+:109770008CCB000CACAB00848CCA001CACAA007C67
64383+:1097800090A900BC01224024A0A800BC90C30007FF
64384+:109790003067000810E000048F8500D090AF00BC57
64385+:1097A00035EE0001A0AE00BC90D9000733380001AF
64386+:1097B000130000088F8300D08F8700D0240400346A
64387+:1097C00090E800BC35030002A0E300BC8F8300D00A
64388+:1097D000AC6400C090C900073126000210C000052B
64389+:1097E00000000000906A00BC35420004A06200BC8A
64390+:1097F0008F8300D09065011330AD003FA06D011341
64391+:109800008F8C00D0958B00D403E000083162FFFFFD
64392+:109810008CC200140A001305000000000A001306A1
64393+:10982000ACA0006427BDFFD8AFB000108F90001C23
64394+:10983000AFBF0024AFB40020AFB20018AFB1001426
64395+:10984000AFB3001C9613000E3C07600A3C14600680
64396+:109850003264FFFF369300100E00125534F40410EA
64397+:109860008F8400D43C11600E0E00099B363100102D
64398+:10987000920E00153C0708008CE700603C12601255
64399+:1098800031CD000FA38D00F08E0E00048E0D000868
64400+:1098900096080012961F00109619001A9618001EBE
64401+:1098A000960F001C310CFFFF33EBFFFF332AFFFF45
64402+:1098B0003309FFFF31E6FFFF3C010800AC2B0040FD
64403+:1098C0003C010800AC2C00243C010800AC2A0044F8
64404+:1098D000AE293178AE26317C92020015960300162F
64405+:1098E00036520010304400FF3065FFFF3C06080090
64406+:1098F0008CC60064AE243188AE4500B492080014D2
64407+:1099000096190018241F0001011FC004332FFFFF08
64408+:109910003C0508008CA50058AE5800B8AE4F00BCFE
64409+:10992000920C0014AF8E00D8AF8D00DC318B00FF9D
64410+:10993000AE4B00C0920A0015AE670048AE66004C00
64411+:10994000314900FFAE4900C8AE65007C3C03080009
64412+:109950008C6300503C0408008C84004C3C080800D8
64413+:109960008D0800543C0208008C42005C8FBF00242C
64414+:10997000AE6300808FB00010AE8300748FB3001C04
64415+:10998000AE22319CAE4200DCAE2731A0AE2631A41F
64416+:10999000AE24318CAE233190AE283194AE2531986F
64417+:1099A000AE870050AE860054AE8500708FB10014B3
64418+:1099B000AE4700E0AE4600E4AE4400CCAE4300D07B
64419+:1099C000AE4800D4AE4500D88FB400208FB2001846
64420+:1099D00003E0000827BD002827BDFFE0AFB1001459
64421+:1099E000AFBF0018241100010E000845AFB00010F1
64422+:1099F00010510005978400E6978300CC0083102B5C
64423+:109A0000144000088F8500D4240700028FBF00187F
64424+:109A10008FB100148FB0001000E0102103E00008A7
64425+:109A200027BD00200E000C7A24040005AF8200E858
64426+:109A30001040FFF6240700020E0008498F90001C1A
64427+:109A4000979F00E68F9900E88F8D00C827EF0001EF
64428+:109A5000240E0050AF590020A78F00E6A1AE0000F1
64429+:109A60003C0C08008D8C00648F8600C8240A80009E
64430+:109A7000000C5E00ACCB0074A4C0000694C9000AC0
64431+:109A8000241FFF803C0D000C012AC024A4D8000A2A
64432+:109A900090C8000A24182000011F1825A0C3000A3E
64433+:109AA0008F8700C8A0E000788F8500C800003821AB
64434+:109AB000A0A000833C0208008C4200508F8400E884
64435+:109AC0000044782101FFC824AF590028960B0002FA
64436+:109AD00031EE007F01DA6021018D3021A4CB00D46A
64437+:109AE000960A0002AF8600D03C0E000425492401EE
64438+:109AF000A4C900E68E080004ACC800048E03000868
64439+:109B0000ACC30000A4C00010A4C00014A0C000D0CA
64440+:109B10008F8500D02403FFBFA0A000D13C04080023
64441+:109B20008C8400648F8200D0A04400D28E1F000C71
64442+:109B30008F8A00D0978F00E4AD5F001C8E19001053
64443+:109B400024100030AD590018A5400030A551005434
64444+:109B5000A5510056A54F0016AD4E0068AD580080C7
64445+:109B6000AD580084914D006231AC000F358B001070
64446+:109B7000A14B00628F8600D090C900633128007F1E
64447+:109B8000A0C800638F8400D02406FFFF9085006387
64448+:109B900000A31024A08200638F9100D000E0102168
64449+:109BA000923F00BC37F90001A23900BC8F8A00D077
64450+:109BB000938F00F0AD580064AD5000C0914E00D3BB
64451+:109BC000000F690031CC000F018D5825A14B00D347
64452+:109BD0008F8500D08F8900DCACA900E88F8800D881
64453+:109BE0008FBF00188FB100148FB0001027BD002068
64454+:109BF000ACA800ECA4A600D6A4A000E0A4A000E2BB
64455+:109C000003E000080000000027BDFFE0AFB0001037
64456+:109C10008F90001CAFB10014AFBF00188E19000464
64457+:109C20003C1808008F180050240FFF80001989C0CD
64458+:109C30000238702131CD007F01CF602401BA50215C
64459+:109C40003C0B000CAF4C0028014B4021950900D47F
64460+:109C5000950400D68E0700043131FFFFAF8800D095
64461+:109C60000E000913000721C08E0600048F8300C870
64462+:109C7000000629C0AF4500209064003E30820040BD
64463+:109C8000144000068F8400D0341FFFFF948300D659
64464+:109C90003062FFFF145F000400000000948400D6CF
64465+:109CA0000E0008A83084FFFF8E050004022030213A
64466+:109CB0008FBF00188FB100148FB000102404002251
64467+:109CC00000003821000529C00A00127C27BD0020B1
64468+:109CD00027BDFFE0AFB100143091FFFFAFB000101F
64469+:109CE000AFBF00181220001D000080218F86001CCD
64470+:109CF0008CC500002403000600053F020005140285
64471+:109D000030E4000714830015304500FF2CA800063E
64472+:109D10001100004D000558803C0C0800258C57D4DC
64473+:109D2000016C50218D490000012000080000000056
64474+:109D30008F8E00EC240D000111CD005900000000B1
64475+:109D4000260B00013170FFFF24CA00200211202BD6
64476+:109D5000014030211480FFE6AF8A001C0200102170
64477+:109D60008FBF00188FB100148FB0001003E00008FF
64478+:109D700027BD0020938700CE14E00038240400148F
64479+:109D80000E001338000000008F86001C2402000122
64480+:109D90000A00147FAF8200EC8F8900EC24080002D7
64481+:109DA0001128003B2404001300002821000030216A
64482+:109DB000240700010E00127C000000000A00147F3E
64483+:109DC0008F86001C8F8700EC2405000214E5FFF647
64484+:109DD000240400120E0012E9000000008F8500E844
64485+:109DE00000403021240400120E00127C00003821B3
64486+:109DF0000A00147F8F86001C8F8300EC241F000351
64487+:109E0000147FFFD0260B00010E00129B0000000003
64488+:109E10008F8500E800403021240200022404001055
64489+:109E200000003821AF8200EC0E00127C0000000020
64490+:109E30000A00147F8F86001C8F8F00EC240600021E
64491+:109E400011E6000B0000000024040010000028218F
64492+:109E5000000030210A00149C240700010000282182
64493+:109E60000E00127C000030210A00147F8F86001C37
64494+:109E70000E0013A500000000144000128F99001C72
64495+:109E80008F86001C240200030A00147FAF8200ECBE
64496+:109E90000E001431000000000A00147F8F86001CA1
64497+:109EA0000E00128B000000002402000224040014A3
64498+:109EB0000000282100003021000038210A0014B9D8
64499+:109EC000AF8200EC004038212404001097380002D3
64500+:109ED000000028210E00127C3306FFFF0A00147FC9
64501+:109EE0008F86001C8F8400C83C077FFF34E6FFFF8D
64502+:109EF0008C8500742402000100A61824AC83007431
64503+:109F000003E00008A082000510A000362CA200800B
64504+:109F1000274A04003C0B000524090080104000077C
64505+:109F20002408008030A6000F00C540212D030081C9
64506+:109F30001460000200A0482124080080AF4B0030CC
64507+:109F400000000000000000000000000011000009F7
64508+:109F500000003821014030218C8D000024E70004EE
64509+:109F600000E8602BACCD0000248400041580FFFACB
64510+:109F700024C60004000000000000000000000000F3
64511+:109F80003C0E0006010E3825AF47003000000000EF
64512+:109F900000000000000000008F4F000031E80010BA
64513+:109FA0001100FFFD000000008F42003C8F43003C89
64514+:109FB0000049C8210323C02B130000040000000047
64515+:109FC0008F4C003825860001AF4600388F47003C93
64516+:109FD00000A9282300E96821AF4D003C14A0FFCE62
64517+:109FE0002CA2008003E000080000000027BDFFD085
64518+:109FF0003C020002AFB100143C11000CAF45003828
64519+:10A00000AFB3001CAF46003C00809821AF42003047
64520+:10A0100024050088AF44002803512021AFBF002849
64521+:10A02000AFB50024AFB40020AFB200180E0014F199
64522+:10A03000AFB000103C1F08008FFF004C3C18080018
64523+:10A040008F1800642410FF8003F3A82132B9007F29
64524+:10A0500002B078240018A0C0033A70210018914083
64525+:10A0600001D12021AF4F00280E0014F10254282105
64526+:10A070003C0D08008DAD00502405012001B358218E
64527+:10A08000316C007F01705024019A48210131202158
64528+:10A090000E0014F1AF4A00283C0808008D08005457
64529+:10A0A0003C0508008CA500640113382130E6007FD0
64530+:10A0B00000F0182400DA202100912021AF4300286D
64531+:10A0C0000E0014F1000529403C0208008C420058A3
64532+:10A0D0003C1008008E1000601200001C0053882104
64533+:10A0E0002415FF800A0015743C14000C3226007FF2
64534+:10A0F0000235182400DA202102402821AF4300282D
64535+:10A10000009420210E0014F12610FFC01200000F51
64536+:10A11000023288212E05004110A0FFF42412100005
64537+:10A120003226007F001091800235182400DA2021A9
64538+:10A1300002402821AF430028009420210E0014F192
64539+:10A14000000080211600FFF3023288213C0B08003A
64540+:10A150008D6B005C240AFF802405000201734021FE
64541+:10A16000010A4824AF4900283C0408009484006296
64542+:10A170003110007F021A88213C07000C0E000CAA47
64543+:10A180000227982100402821026020218FBF00284B
64544+:10A190008FB500248FB400208FB3001C8FB200183D
64545+:10A1A0008FB100148FB000100A0014F127BD0030E9
64546+:10A1B0008F83001C8C62000410400003000000002C
64547+:10A1C00003E00008000000008C6400108C650008AB
64548+:10A1D0000A00152A8C66000C000000000000001B1D
64549+:10A1E0000000000F0000000A000000080000000648
64550+:10A1F000000000050000000500000004000000044D
64551+:10A200000000000300000003000000030000000342
64552+:10A210000000000300000002000000020000000235
64553+:10A220000000000200000002000000020000000226
64554+:10A230000000000200000002000000020000000216
64555+:10A240000000000200000002000000020000000206
64556+:10A2500000000001000000010000000108000F24C0
64557+:10A2600008000D6C08000FB80800106008000F4CC3
64558+:10A2700008000F8C0800119408000D88080011B820
64559+:10A2800008000DD8080015540800151C08000D889A
64560+:10A2900008000D8808000D880800124008001240D0
64561+:10A2A00008000D8808000D88080014E008000D88DB
64562+:10A2B00008000D8808000D8808000D88080013B4F8
64563+:10A2C00008000D8808000D8808000D8808000D881A
64564+:10A2D00008000D8808000D8808000D8808000D880A
64565+:10A2E00008000D8808000D8808000D8808000D88FA
64566+:10A2F00008000D8808000D8808000FAC08000D88C4
64567+:10A3000008000D880800167808000D8808000D88E0
64568+:10A3100008000D8808000D8808000D8808000D88C9
64569+:10A3200008000D8808000D8808000D8808000D88B9
64570+:10A3300008000D8808000D8808000D8808000D88A9
64571+:10A3400008000D8808000D8808000D88080014100A
64572+:10A3500008000D8808000D8808001334080012A4B6
64573+:10A3600008001E2C08001EFC08001F1408001F28EF
64574+:10A3700008001F3808001E2C08001E2C08001E2C88
64575+:10A3800008001ED808002E1408002E1C08002DE41A
64576+:10A3900008002DF008002DFC08002E08080052F4DB
64577+:10A3A000080052B40800528008005254080052308D
64578+:10A3B000080051EC0A000C840000000000000000BE
64579+:10A3C0000000000D727870362E322E33000000002F
64580+:10A3D000060203030000000000000001000000006E
64581+:10A3E000000000000000000000000000000000006D
64582+:10A3F000000000000000000000000000000000005D
64583+:10A40000000000000000000000000000000000004C
64584+:10A41000000000000000000000000000000000003C
64585+:10A42000000000000000000000000000000000002C
64586+:10A43000000000000000000000000000000000001C
64587+:10A44000000000000000000000000000000000000C
64588+:10A4500000000000000000000000000000000000FC
64589+:10A4600000000000000000000000000000000000EC
64590+:10A4700000000000000000000000000000000000DC
64591+:10A4800000000000000000000000000000000000CC
64592+:10A4900000000000000000000000000000000000BC
64593+:10A4A00000000000000000000000000000000000AC
64594+:10A4B000000000000000000000000000000000009C
64595+:10A4C000000000000000000000000000000000008C
64596+:10A4D000000000000000000000000000000000007C
64597+:10A4E000000000000000000000000000000000006C
64598+:10A4F000000000000000000000000000000000005C
64599+:10A50000000000000000000000000000000000004B
64600+:10A51000000000000000000000000000000000003B
64601+:10A52000000000000000000000000000000000002B
64602+:10A53000000000000000000000000000000000001B
64603+:10A54000000000000000000000000000000000000B
64604+:10A5500000000000000000000000000000000000FB
64605+:10A5600000000000000000000000000000000000EB
64606+:10A5700000000000000000000000000000000000DB
64607+:10A5800000000000000000000000000000000000CB
64608+:10A5900000000000000000000000000000000000BB
64609+:10A5A00000000000000000000000000000000000AB
64610+:10A5B000000000000000000000000000000000009B
64611+:10A5C000000000000000000000000000000000008B
64612+:10A5D000000000000000000000000000000000007B
64613+:10A5E000000000000000000000000000000000006B
64614+:10A5F000000000000000000000000000000000005B
64615+:10A60000000000000000000000000000000000004A
64616+:10A61000000000000000000000000000000000003A
64617+:10A62000000000000000000000000000000000002A
64618+:10A63000000000000000000000000000000000001A
64619+:10A64000000000000000000000000000000000000A
64620+:10A6500000000000000000000000000000000000FA
64621+:10A6600000000000000000000000000000000000EA
64622+:10A6700000000000000000000000000000000000DA
64623+:10A6800000000000000000000000000000000000CA
64624+:10A6900000000000000000000000000000000000BA
64625+:10A6A00000000000000000000000000000000000AA
64626+:10A6B000000000000000000000000000000000009A
64627+:10A6C000000000000000000000000000000000008A
64628+:10A6D000000000000000000000000000000000007A
64629+:10A6E000000000000000000000000000000000006A
64630+:10A6F000000000000000000000000000000000005A
64631+:10A700000000000000000000000000000000000049
64632+:10A710000000000000000000000000000000000039
64633+:10A720000000000000000000000000000000000029
64634+:10A730000000000000000000000000000000000019
64635+:10A740000000000000000000000000000000000009
64636+:10A7500000000000000000000000000000000000F9
64637+:10A7600000000000000000000000000000000000E9
64638+:10A7700000000000000000000000000000000000D9
64639+:10A7800000000000000000000000000000000000C9
64640+:10A7900000000000000000000000000000000000B9
64641+:10A7A00000000000000000000000000000000000A9
64642+:10A7B0000000000000000000000000000000000099
64643+:10A7C0000000000000000000000000000000000089
64644+:10A7D0000000000000000000000000000000000079
64645+:10A7E0000000000000000000000000000000000069
64646+:10A7F0000000000000000000000000000000000059
64647+:10A800000000000000000000000000000000000048
64648+:10A810000000000000000000000000000000000038
64649+:10A820000000000000000000000000000000000028
64650+:10A830000000000000000000000000000000000018
64651+:10A840000000000000000000000000000000000008
64652+:10A8500000000000000000000000000000000000F8
64653+:10A8600000000000000000000000000000000000E8
64654+:10A8700000000000000000000000000000000000D8
64655+:10A8800000000000000000000000000000000000C8
64656+:10A8900000000000000000000000000000000000B8
64657+:10A8A00000000000000000000000000000000000A8
64658+:10A8B0000000000000000000000000000000000098
64659+:10A8C0000000000000000000000000000000000088
64660+:10A8D0000000000000000000000000000000000078
64661+:10A8E0000000000000000000000000000000000068
64662+:10A8F0000000000000000000000000000000000058
64663+:10A900000000000000000000000000000000000047
64664+:10A910000000000000000000000000000000000037
64665+:10A920000000000000000000000000000000000027
64666+:10A930000000000000000000000000000000000017
64667+:10A940000000000000000000000000000000000007
64668+:10A9500000000000000000000000000000000000F7
64669+:10A9600000000000000000000000000000000000E7
64670+:10A9700000000000000000000000000000000000D7
64671+:10A9800000000000000000000000000000000000C7
64672+:10A9900000000000000000000000000000000000B7
64673+:10A9A00000000000000000000000000000000000A7
64674+:10A9B0000000000000000000000000000000000097
64675+:10A9C0000000000000000000000000000000000087
64676+:10A9D0000000000000000000000000000000000077
64677+:10A9E0000000000000000000000000000000000067
64678+:10A9F0000000000000000000000000000000000057
64679+:10AA00000000000000000000000000000000000046
64680+:10AA10000000000000000000000000000000000036
64681+:10AA20000000000000000000000000000000000026
64682+:10AA30000000000000000000000000000000000016
64683+:10AA40000000000000000000000000000000000006
64684+:10AA500000000000000000000000000000000000F6
64685+:10AA600000000000000000000000000000000000E6
64686+:10AA700000000000000000000000000000000000D6
64687+:10AA800000000000000000000000000000000000C6
64688+:10AA900000000000000000000000000000000000B6
64689+:10AAA00000000000000000000000000000000000A6
64690+:10AAB0000000000000000000000000000000000096
64691+:10AAC0000000000000000000000000000000000086
64692+:10AAD0000000000000000000000000000000000076
64693+:10AAE0000000000000000000000000000000000066
64694+:10AAF0000000000000000000000000000000000056
64695+:10AB00000000000000000000000000000000000045
64696+:10AB10000000000000000000000000000000000035
64697+:10AB20000000000000000000000000000000000025
64698+:10AB30000000000000000000000000000000000015
64699+:10AB40000000000000000000000000000000000005
64700+:10AB500000000000000000000000000000000000F5
64701+:10AB600000000000000000000000000000000000E5
64702+:10AB700000000000000000000000000000000000D5
64703+:10AB800000000000000000000000000000000000C5
64704+:10AB900000000000000000000000000000000000B5
64705+:10ABA00000000000000000000000000000000000A5
64706+:10ABB0000000000000000000000000000000000095
64707+:10ABC0000000000000000000000000000000000085
64708+:10ABD0000000000000000000000000000000000075
64709+:10ABE0000000000000000000000000000000000065
64710+:10ABF0000000000000000000000000000000000055
64711+:10AC00000000000000000000000000000000000044
64712+:10AC10000000000000000000000000000000000034
64713+:10AC20000000000000000000000000000000000024
64714+:10AC30000000000000000000000000000000000014
64715+:10AC40000000000000000000000000000000000004
64716+:10AC500000000000000000000000000000000000F4
64717+:10AC600000000000000000000000000000000000E4
64718+:10AC700000000000000000000000000000000000D4
64719+:10AC800000000000000000000000000000000000C4
64720+:10AC900000000000000000000000000000000000B4
64721+:10ACA00000000000000000000000000000000000A4
64722+:10ACB0000000000000000000000000000000000094
64723+:10ACC0000000000000000000000000000000000084
64724+:10ACD0000000000000000000000000000000000074
64725+:10ACE0000000000000000000000000000000000064
64726+:10ACF0000000000000000000000000000000000054
64727+:10AD00000000000000000000000000000000000043
64728+:10AD10000000000000000000000000000000000033
64729+:10AD20000000000000000000000000000000000023
64730+:10AD30000000000000000000000000000000000013
64731+:10AD40000000000000000000000000000000000003
64732+:10AD500000000000000000000000000000000000F3
64733+:10AD600000000000000000000000000000000000E3
64734+:10AD700000000000000000000000000000000000D3
64735+:10AD800000000000000000000000000000000000C3
64736+:10AD900000000000000000000000000000000000B3
64737+:10ADA00000000000000000000000000000000000A3
64738+:10ADB0000000000000000000000000000000000093
64739+:10ADC0000000000000000000000000000000000083
64740+:10ADD0000000000000000000000000000000000073
64741+:10ADE0000000000000000000000000000000000063
64742+:10ADF0000000000000000000000000000000000053
64743+:10AE00000000000000000000000000000000000042
64744+:10AE10000000000000000000000000000000000032
64745+:10AE20000000000000000000000000000000000022
64746+:10AE30000000000000000000000000000000000012
64747+:10AE40000000000000000000000000000000000002
64748+:10AE500000000000000000000000000000000000F2
64749+:10AE600000000000000000000000000000000000E2
64750+:10AE700000000000000000000000000000000000D2
64751+:10AE800000000000000000000000000000000000C2
64752+:10AE900000000000000000000000000000000000B2
64753+:10AEA00000000000000000000000000000000000A2
64754+:10AEB0000000000000000000000000000000000092
64755+:10AEC0000000000000000000000000000000000082
64756+:10AED0000000000000000000000000000000000072
64757+:10AEE0000000000000000000000000000000000062
64758+:10AEF0000000000000000000000000000000000052
64759+:10AF00000000000000000000000000000000000041
64760+:10AF10000000000000000000000000000000000031
64761+:10AF20000000000000000000000000000000000021
64762+:10AF30000000000000000000000000000000000011
64763+:10AF40000000000000000000000000000000000001
64764+:10AF500000000000000000000000000000000000F1
64765+:10AF600000000000000000000000000000000000E1
64766+:10AF700000000000000000000000000000000000D1
64767+:10AF800000000000000000000000000000000000C1
64768+:10AF900000000000000000000000000000000000B1
64769+:10AFA00000000000000000000000000000000000A1
64770+:10AFB0000000000000000000000000000000000091
64771+:10AFC0000000000000000000000000000000000081
64772+:10AFD0000000000000000000000000000000000071
64773+:10AFE0000000000000000000000000000000000061
64774+:10AFF0000000000000000000000000000000000051
64775+:10B000000000000000000000000000000000000040
64776+:10B010000000000000000000000000000000000030
64777+:10B020000000000000000000000000000000000020
64778+:10B030000000000000000000000000000000000010
64779+:10B040000000000000000000000000000000000000
64780+:10B0500000000000000000000000000000000000F0
64781+:10B0600000000000000000000000000000000000E0
64782+:10B0700000000000000000000000000000000000D0
64783+:10B0800000000000000000000000000000000000C0
64784+:10B0900000000000000000000000000000000000B0
64785+:10B0A00000000000000000000000000000000000A0
64786+:10B0B0000000000000000000000000000000000090
64787+:10B0C0000000000000000000000000000000000080
64788+:10B0D0000000000000000000000000000000000070
64789+:10B0E0000000000000000000000000000000000060
64790+:10B0F0000000000000000000000000000000000050
64791+:10B10000000000000000000000000000000000003F
64792+:10B11000000000000000000000000000000000002F
64793+:10B12000000000000000000000000000000000001F
64794+:10B13000000000000000000000000000000000000F
64795+:10B1400000000000000000000000000000000000FF
64796+:10B1500000000000000000000000000000000000EF
64797+:10B1600000000000000000000000000000000000DF
64798+:10B1700000000000000000000000000000000000CF
64799+:10B1800000000000000000000000000000000000BF
64800+:10B1900000000000000000000000000000000000AF
64801+:10B1A000000000000000000000000000000000009F
64802+:10B1B000000000000000000000000000000000008F
64803+:10B1C000000000000000000000000000000000007F
64804+:10B1D000000000000000000000000000000000006F
64805+:10B1E000000000000000000000000000000000005F
64806+:10B1F000000000000000000000000000000000004F
64807+:10B20000000000000000000000000000000000003E
64808+:10B21000000000000000000000000000000000002E
64809+:10B22000000000000000000000000000000000001E
64810+:10B23000000000000000000000000000000000000E
64811+:10B2400000000000000000000000000000000000FE
64812+:10B2500000000000000000000000000000000000EE
64813+:10B2600000000000000000000000000000000000DE
64814+:10B2700000000000000000000000000000000000CE
64815+:10B2800000000000000000000000000000000000BE
64816+:10B2900000000000000000000000000000000000AE
64817+:10B2A000000000000000000000000000000000009E
64818+:10B2B000000000000000000000000000000000008E
64819+:10B2C000000000000000000000000000000000007E
64820+:10B2D000000000000000000000000000000000006E
64821+:10B2E000000000000000000000000000000000005E
64822+:10B2F000000000000000000000000000000000004E
64823+:10B30000000000000000000000000000000000003D
64824+:10B31000000000000000000000000000000000002D
64825+:10B32000000000000000000000000000000000001D
64826+:10B33000000000000000000000000000000000000D
64827+:10B3400000000000000000000000000000000000FD
64828+:10B3500000000000000000000000000000000000ED
64829+:10B3600000000000000000000000000000000000DD
64830+:10B3700000000000000000000000000000000000CD
64831+:10B3800000000000000000000000000000000000BD
64832+:10B3900000000000000000000000000000000000AD
64833+:10B3A000000000000000000000000000000000009D
64834+:10B3B000000000000000000000000000000000008D
64835+:10B3C000000000000000000000000000000000007D
64836+:10B3D000000000000000000000000000000000006D
64837+:10B3E000000000000000000000000000000000005D
64838+:10B3F000000000000000000000000000000000004D
64839+:10B40000000000000000000000000000000000003C
64840+:10B41000000000000000000000000000000000002C
64841+:10B42000000000000000000000000000000000001C
64842+:10B43000000000000000000000000000000000000C
64843+:10B4400000000000000000000000000000000000FC
64844+:10B4500000000000000000000000000000000000EC
64845+:10B4600000000000000000000000000000000000DC
64846+:10B4700000000000000000000000000000000000CC
64847+:10B4800000000000000000000000000000000000BC
64848+:10B4900000000000000000000000000000000000AC
64849+:10B4A000000000000000000000000000000000009C
64850+:10B4B000000000000000000000000000000000008C
64851+:10B4C000000000000000000000000000000000007C
64852+:10B4D000000000000000000000000000000000006C
64853+:10B4E000000000000000000000000000000000005C
64854+:10B4F000000000000000000000000000000000004C
64855+:10B50000000000000000000000000000000000003B
64856+:10B51000000000000000000000000000000000002B
64857+:10B52000000000000000000000000000000000001B
64858+:10B53000000000000000000000000000000000000B
64859+:10B5400000000000000000000000000000000000FB
64860+:10B5500000000000000000000000000000000000EB
64861+:10B5600000000000000000000000000000000000DB
64862+:10B5700000000000000000000000000000000000CB
64863+:10B5800000000000000000000000000000000000BB
64864+:10B5900000000000000000000000000000000000AB
64865+:10B5A000000000000000000000000000000000009B
64866+:10B5B000000000000000000000000000000000008B
64867+:10B5C000000000000000000000000000000000007B
64868+:10B5D000000000000000000000000000000000006B
64869+:10B5E000000000000000000000000000000000005B
64870+:10B5F000000000000000000000000000000000004B
64871+:10B60000000000000000000000000000000000003A
64872+:10B61000000000000000000000000000000000002A
64873+:10B62000000000000000000000000000000000001A
64874+:10B63000000000000000000000000000000000000A
64875+:10B6400000000000000000000000000000000000FA
64876+:10B6500000000000000000000000000000000000EA
64877+:10B6600000000000000000000000000000000000DA
64878+:10B6700000000000000000000000000000000000CA
64879+:10B6800000000000000000000000000000000000BA
64880+:10B6900000000000000000000000000000000000AA
64881+:10B6A000000000000000000000000000000000009A
64882+:10B6B000000000000000000000000000000000008A
64883+:10B6C000000000000000000000000000000000007A
64884+:10B6D000000000000000000000000000000000006A
64885+:10B6E000000000000000000000000000000000005A
64886+:10B6F000000000000000000000000000000000004A
64887+:10B700000000000000000000000000000000000039
64888+:10B710000000000000000000000000000000000029
64889+:10B720000000000000000000000000000000000019
64890+:10B730000000000000000000000000000000000009
64891+:10B7400000000000000000000000000000000000F9
64892+:10B7500000000000000000000000000000000000E9
64893+:10B7600000000000000000000000000000000000D9
64894+:10B7700000000000000000000000000000000000C9
64895+:10B7800000000000000000000000000000000000B9
64896+:10B7900000000000000000000000000000000000A9
64897+:10B7A0000000000000000000000000000000000099
64898+:10B7B0000000000000000000000000000000000089
64899+:10B7C0000000000000000000000000000000000079
64900+:10B7D0000000000000000000000000000000000069
64901+:10B7E0000000000000000000000000000000000059
64902+:10B7F0000000000000000000000000000000000049
64903+:10B800000000000000000000000000000000000038
64904+:10B810000000000000000000000000000000000028
64905+:10B820000000000000000000000000000000000018
64906+:10B830000000000000000000000000000000000008
64907+:10B8400000000000000000000000000000000000F8
64908+:10B8500000000000000000000000000000000000E8
64909+:10B8600000000000000000000000000000000000D8
64910+:10B8700000000000000000000000000000000000C8
64911+:10B8800000000000000000000000000000000000B8
64912+:10B8900000000000000000000000000000000000A8
64913+:10B8A0000000000000000000000000000000000098
64914+:10B8B0000000000000000000000000000000000088
64915+:10B8C0000000000000000000000000000000000078
64916+:10B8D0000000000000000000000000000000000068
64917+:10B8E0000000000000000000000000000000000058
64918+:10B8F0000000000000000000000000000000000048
64919+:10B900000000000000000000000000000000000037
64920+:10B910000000000000000000000000000000000027
64921+:10B920000000000000000000000000000000000017
64922+:10B930000000000000000000000000000000000007
64923+:10B9400000000000000000000000000000000000F7
64924+:10B9500000000000000000000000000000000000E7
64925+:10B9600000000000000000000000000000000000D7
64926+:10B9700000000000000000000000000000000000C7
64927+:10B9800000000000000000000000000000000000B7
64928+:10B9900000000000000000000000000000000000A7
64929+:10B9A0000000000000000000000000000000000097
64930+:10B9B0000000000000000000000000000000000087
64931+:10B9C0000000000000000000000000000000000077
64932+:10B9D0000000000000000000000000000000000067
64933+:10B9E0000000000000000000000000000000000057
64934+:10B9F0000000000000000000000000000000000047
64935+:10BA00000000000000000000000000000000000036
64936+:10BA10000000000000000000000000000000000026
64937+:10BA20000000000000000000000000000000000016
64938+:10BA30000000000000000000000000000000000006
64939+:10BA400000000000000000000000000000000000F6
64940+:10BA500000000000000000000000000000000000E6
64941+:10BA600000000000000000000000000000000000D6
64942+:10BA700000000000000000000000000000000000C6
64943+:10BA800000000000000000000000000000000000B6
64944+:10BA900000000000000000000000000000000000A6
64945+:10BAA0000000000000000000000000000000000096
64946+:10BAB0000000000000000000000000000000000086
64947+:10BAC0000000000000000000000000000000000076
64948+:10BAD0000000000000000000000000000000000066
64949+:10BAE0000000000000000000000000000000000056
64950+:10BAF0000000000000000000000000000000000046
64951+:10BB00000000000000000000000000000000000035
64952+:10BB10000000000000000000000000000000000025
64953+:10BB20000000000000000000000000000000000015
64954+:10BB30000000000000000000000000000000000005
64955+:10BB400000000000000000000000000000000000F5
64956+:10BB500000000000000000000000000000000000E5
64957+:10BB600000000000000000000000000000000000D5
64958+:10BB700000000000000000000000000000000000C5
64959+:10BB800000000000000000000000000000000000B5
64960+:10BB900000000000000000000000000000000000A5
64961+:10BBA0000000000000000000000000000000000095
64962+:10BBB0000000000000000000000000000000000085
64963+:10BBC0000000000000000000000000000000000075
64964+:10BBD0000000000000000000000000000000000065
64965+:10BBE0000000000000000000000000000000000055
64966+:10BBF0000000000000000000000000000000000045
64967+:10BC00000000000000000000000000000000000034
64968+:10BC10000000000000000000000000000000000024
64969+:10BC20000000000000000000000000000000000014
64970+:10BC30000000000000000000000000000000000004
64971+:10BC400000000000000000000000000000000000F4
64972+:10BC500000000000000000000000000000000000E4
64973+:10BC600000000000000000000000000000000000D4
64974+:10BC700000000000000000000000000000000000C4
64975+:10BC800000000000000000000000000000000000B4
64976+:10BC900000000000000000000000000000000000A4
64977+:10BCA0000000000000000000000000000000000094
64978+:10BCB0000000000000000000000000000000000084
64979+:10BCC0000000000000000000000000000000000074
64980+:10BCD0000000000000000000000000000000000064
64981+:10BCE0000000000000000000000000000000000054
64982+:10BCF0000000000000000000000000000000000044
64983+:10BD00000000000000000000000000000000000033
64984+:10BD10000000000000000000000000000000000023
64985+:10BD20000000000000000000000000000000000013
64986+:10BD30000000000000000000000000000000000003
64987+:10BD400000000000000000000000000000000000F3
64988+:10BD500000000000000000000000000000000000E3
64989+:10BD600000000000000000000000000000000000D3
64990+:10BD700000000000000000000000000000000000C3
64991+:10BD800000000000000000000000000000000000B3
64992+:10BD900000000000000000000000000000000000A3
64993+:10BDA0000000000000000000000000000000000093
64994+:10BDB0000000000000000000000000000000000083
64995+:10BDC0000000000000000000000000000000000073
64996+:10BDD0000000000000000000000000000000000063
64997+:10BDE0000000000000000000000000000000000053
64998+:10BDF0000000000000000000000000000000000043
64999+:10BE00000000000000000000000000000000000032
65000+:10BE10000000000000000000000000000000000022
65001+:10BE20000000000000000000000000000000000012
65002+:10BE30000000000000000000000000000000000002
65003+:10BE400000000000000000000000000000000000F2
65004+:10BE500000000000000000000000000000000000E2
65005+:10BE600000000000000000000000000000000000D2
65006+:10BE700000000000000000000000000000000000C2
65007+:10BE800000000000000000000000000000000000B2
65008+:10BE900000000000000000000000000000000000A2
65009+:10BEA0000000000000000000000000000000000092
65010+:10BEB0000000000000000000000000000000000082
65011+:10BEC0000000000000000000000000000000000072
65012+:10BED0000000000000000000000000000000000062
65013+:10BEE0000000000000000000000000000000000052
65014+:10BEF0000000000000000000000000000000000042
65015+:10BF00000000000000000000000000000000000031
65016+:10BF10000000000000000000000000000000000021
65017+:10BF20000000000000000000000000000000000011
65018+:10BF30000000000000000000000000000000000001
65019+:10BF400000000000000000000000000000000000F1
65020+:10BF500000000000000000000000000000000000E1
65021+:10BF600000000000000000000000000000000000D1
65022+:10BF700000000000000000000000000000000000C1
65023+:10BF800000000000000000000000000000000000B1
65024+:10BF900000000000000000000000000000000000A1
65025+:10BFA0000000000000000000000000000000000091
65026+:10BFB0000000000000000000000000000000000081
65027+:10BFC0000000000000000000000000000000000071
65028+:10BFD0000000000000000000000000000000000061
65029+:10BFE0000000000000000000000000000000000051
65030+:10BFF0000000000000000000000000000000000041
65031+:10C000000000000000000000000000000000000030
65032+:10C010000000000000000000000000000000000020
65033+:10C020000000000000000000000000000000000010
65034+:10C030000000000000000000000000000000000000
65035+:10C0400000000000000000000000000000000000F0
65036+:10C0500000000000000000000000000000000000E0
65037+:10C0600000000000000000000000000000000000D0
65038+:10C0700000000000000000000000000000000000C0
65039+:10C0800000000000000000000000000000000000B0
65040+:10C0900000000000000000000000000000000000A0
65041+:10C0A0000000000000000000000000000000000090
65042+:10C0B0000000000000000000000000000000000080
65043+:10C0C0000000000000000000000000000000000070
65044+:10C0D0000000000000000000000000000000000060
65045+:10C0E0000000000000000000000000000000000050
65046+:10C0F0000000000000000000000000000000000040
65047+:10C10000000000000000000000000000000000002F
65048+:10C11000000000000000000000000000000000001F
65049+:10C12000000000000000000000000000000000000F
65050+:10C1300000000000000000000000000000000000FF
65051+:10C1400000000000000000000000000000000000EF
65052+:10C1500000000000000000000000000000000000DF
65053+:10C1600000000000000000000000000000000000CF
65054+:10C1700000000000000000000000000000000000BF
65055+:10C1800000000000000000000000000000000000AF
65056+:10C19000000000000000000000000000000000009F
65057+:10C1A000000000000000000000000000000000008F
65058+:10C1B000000000000000000000000000000000007F
65059+:10C1C000000000000000000000000000000000006F
65060+:10C1D000000000000000000000000000000000005F
65061+:10C1E000000000000000000000000000000000004F
65062+:10C1F000000000000000000000000000000000003F
65063+:10C20000000000000000000000000000000000002E
65064+:10C21000000000000000000000000000000000001E
65065+:10C22000000000000000000000000000000000000E
65066+:10C2300000000000000000000000000000000000FE
65067+:10C2400000000000000000000000000000000000EE
65068+:10C2500000000000000000000000000000000000DE
65069+:10C2600000000000000000000000000000000000CE
65070+:10C2700000000000000000000000000000000000BE
65071+:10C2800000000000000000000000000000000000AE
65072+:10C29000000000000000000000000000000000009E
65073+:10C2A000000000000000000000000000000000008E
65074+:10C2B000000000000000000000000000000000007E
65075+:10C2C000000000000000000000000000000000006E
65076+:10C2D000000000000000000000000000000000005E
65077+:10C2E000000000000000000000000000000000004E
65078+:10C2F000000000000000000000000000000000003E
65079+:10C30000000000000000000000000000000000002D
65080+:10C31000000000000000000000000000000000001D
65081+:10C32000000000000000000000000000000000000D
65082+:10C3300000000000000000000000000000000000FD
65083+:10C3400000000000000000000000000000000000ED
65084+:10C3500000000000000000000000000000000000DD
65085+:10C3600000000000000000000000000000000000CD
65086+:10C3700000000000000000000000000000000000BD
65087+:10C3800000000000000000000000000000000000AD
65088+:10C39000000000000000000000000000000000009D
65089+:10C3A000000000000000000000000000000000008D
65090+:10C3B000000000000000000000000000000000007D
65091+:10C3C000000000000000000000000000000000006D
65092+:10C3D000000000000000000000000000000000005D
65093+:10C3E000000000000000000000000000000000004D
65094+:10C3F000000000000000000000000000000000003D
65095+:10C40000000000000000000000000000000000002C
65096+:10C41000000000000000000000000000000000001C
65097+:10C42000000000000000000000000000000000000C
65098+:10C4300000000000000000000000000000000000FC
65099+:10C4400000000000000000000000000000000000EC
65100+:10C4500000000000000000000000000000000000DC
65101+:10C4600000000000000000000000000000000000CC
65102+:10C4700000000000000000000000000000000000BC
65103+:10C4800000000000000000000000000000000000AC
65104+:10C49000000000000000000000000000000000009C
65105+:10C4A000000000000000000000000000000000008C
65106+:10C4B000000000000000000000000000000000007C
65107+:10C4C000000000000000000000000000000000006C
65108+:10C4D000000000000000000000000000000000005C
65109+:10C4E000000000000000000000000000000000004C
65110+:10C4F000000000000000000000000000000000003C
65111+:10C50000000000000000000000000000000000002B
65112+:10C51000000000000000000000000000000000001B
65113+:10C52000000000000000000000000000000000000B
65114+:10C5300000000000000000000000000000000000FB
65115+:10C5400000000000000000000000000000000000EB
65116+:10C5500000000000000000000000000000000000DB
65117+:10C5600000000000000000000000000000000000CB
65118+:10C5700000000000000000000000000000000000BB
65119+:10C5800000000000000000000000000000000000AB
65120+:10C59000000000000000000000000000000000009B
65121+:10C5A000000000000000000000000000000000008B
65122+:10C5B000000000000000000000000000000000007B
65123+:10C5C000000000000000000000000000000000006B
65124+:10C5D000000000000000000000000000000000005B
65125+:10C5E000000000000000000000000000000000004B
65126+:10C5F000000000000000000000000000000000003B
65127+:10C60000000000000000000000000000000000002A
65128+:10C61000000000000000000000000000000000001A
65129+:10C62000000000000000000000000000000000000A
65130+:10C6300000000000000000000000000000000000FA
65131+:10C6400000000000000000000000000000000000EA
65132+:10C6500000000000000000000000000000000000DA
65133+:10C6600000000000000000000000000000000000CA
65134+:10C6700000000000000000000000000000000000BA
65135+:10C6800000000000000000000000000000000000AA
65136+:10C69000000000000000000000000000000000009A
65137+:10C6A000000000000000000000000000000000008A
65138+:10C6B000000000000000000000000000000000007A
65139+:10C6C000000000000000000000000000000000006A
65140+:10C6D000000000000000000000000000000000005A
65141+:10C6E000000000000000000000000000000000004A
65142+:10C6F000000000000000000000000000000000003A
65143+:10C700000000000000000000000000000000000029
65144+:10C710000000000000000000000000000000000019
65145+:10C720000000000000000000000000000000000009
65146+:10C7300000000000000000000000000000000000F9
65147+:10C7400000000000000000000000000000000000E9
65148+:10C7500000000000000000000000000000000000D9
65149+:10C7600000000000000000000000000000000000C9
65150+:10C7700000000000000000000000000000000000B9
65151+:10C7800000000000000000000000000000000000A9
65152+:10C790000000000000000000000000000000000099
65153+:10C7A0000000000000000000000000000000000089
65154+:10C7B0000000000000000000000000000000000079
65155+:10C7C0000000000000000000000000000000000069
65156+:10C7D0000000000000000000000000000000000059
65157+:10C7E0000000000000000000000000000000000049
65158+:10C7F0000000000000000000000000000000000039
65159+:10C800000000000000000000000000000000000028
65160+:10C810000000000000000000000000000000000018
65161+:10C820000000000000000000000000000000000008
65162+:10C8300000000000000000000000000000000000F8
65163+:10C8400000000000000000000000000000000000E8
65164+:10C8500000000000000000000000000000000000D8
65165+:10C8600000000000000000000000000000000000C8
65166+:10C8700000000000000000000000000000000000B8
65167+:10C8800000000000000000000000000000000000A8
65168+:10C890000000000000000000000000000000000098
65169+:10C8A0000000000000000000000000000000000088
65170+:10C8B0000000000000000000000000000000000078
65171+:10C8C0000000000000000000000000000000000068
65172+:10C8D0000000000000000000000000000000000058
65173+:10C8E0000000000000000000000000000000000048
65174+:10C8F0000000000000000000000000000000000038
65175+:10C900000000000000000000000000000000000027
65176+:10C910000000000000000000000000000000000017
65177+:10C920000000000000000000000000000000000007
65178+:10C9300000000000000000000000000000000000F7
65179+:10C9400000000000000000000000000000000000E7
65180+:10C9500000000000000000000000000000000000D7
65181+:10C9600000000000000000000000000000000000C7
65182+:10C9700000000000000000000000000000000000B7
65183+:10C9800000000000000000000000000000000000A7
65184+:10C990000000000000000000000000000000000097
65185+:10C9A0000000000000000000000000000000000087
65186+:10C9B0000000000000000000000000000000000077
65187+:10C9C0000000000000000000000000000000000067
65188+:10C9D0000000000000000000000000000000000057
65189+:10C9E0000000000000000000000000000000000047
65190+:10C9F0000000000000000000000000000000000037
65191+:10CA00000000000000000000000000000000000026
65192+:10CA10000000000000000000000000000000000016
65193+:10CA20000000000000000000000000000000000006
65194+:10CA300000000000000000000000000000000000F6
65195+:10CA400000000000000000000000000000000000E6
65196+:10CA500000000000000000000000000000000000D6
65197+:10CA600000000000000000000000000000000000C6
65198+:10CA700000000000000000000000000000000000B6
65199+:10CA800000000000000000000000000000000000A6
65200+:10CA90000000000000000000000000000000000096
65201+:10CAA0000000000000000000000000000000000086
65202+:10CAB0000000000000000000000000000000000076
65203+:10CAC0000000000000000000000000000000000066
65204+:10CAD0000000000000000000000000000000000056
65205+:10CAE0000000000000000000000000000000000046
65206+:10CAF0000000000000000000000000000000000036
65207+:10CB00000000000000000000000000000000000025
65208+:10CB10000000000000000000000000000000000015
65209+:10CB20000000000000000000000000000000000005
65210+:10CB300000000000000000000000000000000000F5
65211+:10CB400000000000000000000000000000000000E5
65212+:10CB500000000000000000000000000000000000D5
65213+:10CB600000000000000000000000000000000000C5
65214+:10CB700000000000000000000000000000000000B5
65215+:10CB800000000000000000000000000000000000A5
65216+:10CB90000000000000000000000000000000000095
65217+:10CBA0000000000000000000000000000000000085
65218+:10CBB0000000000000000000000000000000000075
65219+:10CBC0000000000000000000000000000000000065
65220+:10CBD0000000000000000000000000000000000055
65221+:10CBE0000000000000000000000000000000000045
65222+:10CBF0000000000000000000000000000000000035
65223+:10CC00000000000000000000000000000000000024
65224+:10CC10000000000000000000000000000000000014
65225+:10CC20000000000000000000000000000000000004
65226+:10CC300000000000000000000000000000000000F4
65227+:10CC400000000000000000000000000000000000E4
65228+:10CC500000000000000000000000000000000000D4
65229+:10CC600000000000000000000000000000000000C4
65230+:10CC700000000000000000000000000000000000B4
65231+:10CC800000000000000000000000000000000000A4
65232+:10CC90000000000000000000000000000000000094
65233+:10CCA0000000000000000000000000000000000084
65234+:10CCB0000000000000000000000000000000000074
65235+:10CCC0000000000000000000000000000000000064
65236+:10CCD0000000000000000000000000000000000054
65237+:10CCE0000000000000000000000000000000000044
65238+:10CCF0000000000000000000000000000000000034
65239+:10CD00000000000000000000000000000000000023
65240+:10CD10000000000000000000000000000000000013
65241+:10CD20000000000000000000000000000000000003
65242+:10CD300000000000000000000000000000000000F3
65243+:10CD400000000000000000000000000000000000E3
65244+:10CD500000000000000000000000000000000000D3
65245+:10CD600000000000000000000000000000000000C3
65246+:10CD700000000000000000000000000000000000B3
65247+:10CD800000000000000000000000000000000000A3
65248+:10CD90000000000000000000000000000000000093
65249+:10CDA0000000000000000000000000000000000083
65250+:10CDB0000000000000000000000000000000000073
65251+:10CDC0000000000000000000000000000000000063
65252+:10CDD0000000000000000000000000000000000053
65253+:10CDE0000000000000000000000000000000000043
65254+:10CDF0000000000000000000000000000000000033
65255+:10CE00000000000000000000000000000000000022
65256+:10CE10000000000000000000000000000000000012
65257+:10CE20000000000000000000000000000000000002
65258+:10CE300000000000000000000000000000000000F2
65259+:10CE400000000000000000000000000000000000E2
65260+:10CE500000000000000000000000000000000000D2
65261+:10CE600000000000000000000000000000000000C2
65262+:10CE700000000000000000000000000000000000B2
65263+:10CE800000000000000000000000000000000000A2
65264+:10CE90000000000000000000000000000000000092
65265+:10CEA0000000000000000000000000000000000082
65266+:10CEB0000000000000000000000000000000000072
65267+:10CEC0000000000000000000000000000000000062
65268+:10CED0000000000000000000000000000000000052
65269+:10CEE0000000000000000000000000000000000042
65270+:10CEF0000000000000000000000000000000000032
65271+:10CF00000000000000000000000000000000000021
65272+:10CF10000000000000000000000000000000000011
65273+:10CF20000000000000000000000000000000000001
65274+:10CF300000000000000000000000000000000000F1
65275+:10CF400000000000000000000000000000000000E1
65276+:10CF500000000000000000000000000000000000D1
65277+:10CF600000000000000000000000000000000000C1
65278+:10CF700000000000000000000000000000000000B1
65279+:10CF800000000000000000000000000000000000A1
65280+:10CF90000000000000000000000000000000000091
65281+:10CFA0000000000000000000000000000000000081
65282+:10CFB0000000000000000000000000000000000071
65283+:10CFC0000000000000000000000000000000000061
65284+:10CFD0000000000000000000000000000000000051
65285+:10CFE0000000000000000000000000000000000041
65286+:10CFF0000000000000000000000000000000000031
65287+:10D000000000000000000000000000000000000020
65288+:10D010000000000000000000000000000000000010
65289+:10D020000000000000000000000000000000000000
65290+:10D0300000000000000000000000000000000000F0
65291+:10D0400000000000000000000000000000000000E0
65292+:10D0500000000000000000000000000000000000D0
65293+:10D0600000000000000000000000000000000000C0
65294+:10D0700000000000000000000000000000000000B0
65295+:10D0800000000000000000000000000000000000A0
65296+:10D090000000000000000000000000000000000090
65297+:10D0A0000000000000000000000000000000000080
65298+:10D0B0000000000000000000000000000000000070
65299+:10D0C0000000000000000000000000000000000060
65300+:10D0D0000000000000000000000000000000000050
65301+:10D0E0000000000000000000000000000000000040
65302+:10D0F0000000000000000000000000000000000030
65303+:10D10000000000000000000000000000000000001F
65304+:10D11000000000000000000000000000000000000F
65305+:10D1200000000000000000000000000000000000FF
65306+:10D1300000000000000000000000000000000000EF
65307+:10D1400000000000000000000000000000000000DF
65308+:10D1500000000000000000000000000000000000CF
65309+:10D1600000000000000000000000000000000000BF
65310+:10D1700000000000000000000000000000000000AF
65311+:10D18000000000000000000000000000000000009F
65312+:10D19000000000000000000000000000000000008F
65313+:10D1A000000000000000000000000000000000007F
65314+:10D1B000000000000000000000000000000000006F
65315+:10D1C000000000000000000000000000000000005F
65316+:10D1D000000000000000000000000000000000004F
65317+:10D1E000000000000000000000000000000000003F
65318+:10D1F000000000000000000000000000000000002F
65319+:10D20000000000000000000000000000000000001E
65320+:10D21000000000000000000000000000000000000E
65321+:10D2200000000000000000000000000000000000FE
65322+:10D2300000000000000000000000000000000000EE
65323+:10D2400000000000000000000000000000000000DE
65324+:10D2500000000000000000000000000000000000CE
65325+:10D2600000000000000000000000000000000000BE
65326+:10D2700000000000000000000000000000000000AE
65327+:10D28000000000000000000000000000000000009E
65328+:10D29000000000000000000000000000000000008E
65329+:10D2A000000000000000000000000000000000007E
65330+:10D2B000000000000000000000000000000000006E
65331+:10D2C000000000000000000000000000000000005E
65332+:10D2D000000000000000000000000000000000004E
65333+:10D2E000000000000000000000000000000000003E
65334+:10D2F000000000000000000000000000000000002E
65335+:10D30000000000000000000000000000000000001D
65336+:10D31000000000000000000000000000000000000D
65337+:10D3200000000000000000000000000000000000FD
65338+:10D3300000000000000000000000000000000000ED
65339+:10D3400000000000000000000000000000000000DD
65340+:10D3500000000000000000000000000000000000CD
65341+:10D3600000000000000000000000000000000000BD
65342+:10D3700000000000000000000000000000000000AD
65343+:10D38000000000000000000000000000000000009D
65344+:10D39000000000000000000000000000000000008D
65345+:10D3A000000000000000000000000000000000007D
65346+:10D3B000000000000000000000000000000000006D
65347+:10D3C000000000000000000000000000000000005D
65348+:10D3D000000000000000000000000000000000004D
65349+:10D3E000000000000000000000000000000000003D
65350+:10D3F000000000000000000000000000000000002D
65351+:10D40000000000000000000000000000000000001C
65352+:10D41000000000000000000000000000000000000C
65353+:10D4200000000000000000000000000000000000FC
65354+:10D4300000000000000000000000000000000000EC
65355+:10D4400000000000000000000000000000000000DC
65356+:10D4500000000000000000000000000000000000CC
65357+:10D4600000000000000000000000000000000000BC
65358+:10D4700000000000000000000000000000000000AC
65359+:10D48000000000000000000000000000000000009C
65360+:10D49000000000000000000000000000000000008C
65361+:10D4A000000000000000000000000000000000007C
65362+:10D4B000000000000000000000000000000000006C
65363+:10D4C000000000000000000000000000000000005C
65364+:10D4D000000000000000000000000000000000004C
65365+:10D4E000000000000000000000000000000000003C
65366+:10D4F000000000000000000000000000000000002C
65367+:10D50000000000000000000000000000000000001B
65368+:10D51000000000000000000000000000000000000B
65369+:10D5200000000000000000000000000000000000FB
65370+:10D5300000000000000000000000000000000000EB
65371+:10D5400000000000000000000000000000000000DB
65372+:10D5500000000000000000000000000000000000CB
65373+:10D5600000000000000000000000000000000000BB
65374+:10D5700000000000000000000000000000000000AB
65375+:10D58000000000000000000000000000000000009B
65376+:10D59000000000000000008000000000000000000B
65377+:10D5A000000000000000000000000000000000007B
65378+:10D5B00000000000000000000000000A0000000061
65379+:10D5C0000000000000000000100000030000000048
65380+:10D5D0000000000D0000000D3C02080024427340D2
65381+:10D5E0003C030800246377CCAC4000000043202BB0
65382+:10D5F0001480FFFD244200043C1D080037BD7FFC61
65383+:10D6000003A0F0213C100800261032103C1C08003A
65384+:10D61000279C73400E0010FE000000000000000D6B
65385+:10D6200030A5FFFF30C600FF274301808F4201B8BD
65386+:10D630000440FFFE24020002AC640000A465000860
65387+:10D64000A066000AA062000B3C021000AC67001844
65388+:10D6500003E00008AF4201B83C0360008C624FF861
65389+:10D660000440FFFE3C020200AC644FC0AC624FC4F9
65390+:10D670003C02100003E00008AC624FF89482000CFA
65391+:10D680002486001400A0382100021302000210803A
65392+:10D690000082402100C8102B1040005700000000FD
65393+:10D6A00090C300002C6200095040005190C200015C
65394+:10D6B000000310803C030800246372F00043102133
65395+:10D6C0008C420000004000080000000090C30001F0
65396+:10D6D0002402000A1462003A000000000106102330
65397+:10D6E0002C42000A1440003624C600028CE20000DE
65398+:10D6F00034420100ACE2000090C2000090C300017F
65399+:10D7000090C4000290C5000300031C000002160034
65400+:10D710000043102500042200004410250045102578
65401+:10D7200024C60004ACE2000490C2000090C30001D3
65402+:10D7300090C4000290C500030002160000031C0004
65403+:10D740000043102500042200004410250045102548
65404+:10D7500024C600040A000CB8ACE2000890C3000123
65405+:10D76000240200041462001624C6000290C20000C5
65406+:10D7700090C400018CE30000000212000044102558
65407+:10D780003463000424C60002ACE2000C0A000CB8AA
65408+:10D79000ACE3000090C300012402000314620008FF
65409+:10D7A00024C600028CE2000090C3000024C60001E1
65410+:10D7B00034420008A0E300100A000CB8ACE20000FC
65411+:10D7C00003E000082402000190C3000124020002CB
65412+:10D7D0001062000224C40002010020210A000CB8DB
65413+:10D7E000008030210A000CB824C6000190C200015C
65414+:10D7F0000A000CB800C2302103E00008000010212C
65415+:10D8000027BDFFE8AFBF0014AFB000100E00130239
65416+:10D8100000808021936200052403FFFE0200202186
65417+:10D82000004310248FBF00148FB00010A3620005C6
65418+:10D830000A00130B27BD001827BDFFE8AFB000108A
65419+:10D84000AFBF00140E000F3C0080802193620000E7
65420+:10D8500024030050304200FF14430004240201005E
65421+:10D86000AF4201800A000D3002002021AF4001804C
65422+:10D87000020020218FBF00148FB000100A000FE7B4
65423+:10D8800027BD001827BDFF80AFBE0078AFB700747A
65424+:10D89000AFB20060AFBF007CAFB60070AFB5006C38
65425+:10D8A000AFB40068AFB30064AFB1005CAFB0005874
65426+:10D8B0008F5001283C0208008C4231A02403FF80D5
65427+:10D8C0009365003F0202102100431024AF42002460
65428+:10D8D0003C0208008C4231A09364000530B200FF86
65429+:10D8E000020210213042007F034218210004202749
65430+:10D8F0003C02000A0062182130840001AF8300144A
65431+:10D900000000F0210000B82114800053AFA00050A7
65432+:10D9100093430116934401128F450104306300FFC5
65433+:10D920003C020001308400FF00A2282403431021A0
65434+:10D9300003441821245640002467400014A001CD60
65435+:10D940002402000193620000304300FF2402002003
65436+:10D950001062000524020050106200060000000062
65437+:10D960000A000D74000000000000000D0A000D7D8B
65438+:10D97000AFA000303C1E080027DE738C0A000D7D2E
65439+:10D98000AFA000303C0208008C4200DC24420001C1
65440+:10D990003C010800AC2200DC0E00139F00000000D8
65441+:10D9A0000A000F318FBF007C8F4201043C0300202E
65442+:10D9B00092D3000D004310240002202B00042140CC
65443+:10D9C000AFA400308F4301043C02004000621824E1
65444+:10D9D000146000023485004000802821326200205B
65445+:10D9E000AFA500301440000234A6008000A0302112
65446+:10D9F00010C0000BAFA6003093C500088F67004C25
65447+:10DA00000200202100052B0034A5008130A5F08103
65448+:10DA10000E000C9B30C600FF0A000F2E0000000015
65449+:10DA20009362003E304200401040000F2402000488
65450+:10DA300056420007240200120200202100E02821A3
65451+:10DA40000E0013F702C030210A000F318FBF007C97
65452+:10DA500016420005000000000E000D2100002021EC
65453+:10DA60000A000F318FBF007C9743011A96C4000E45
65454+:10DA700093620035326500043075FFFF00442004D6
65455+:10DA8000AFA400548ED1000410A000158ED400085D
65456+:10DA90009362003E3042004010400007000000004A
65457+:10DAA0000E0013E0022020211040000D00000000B5
65458+:10DAB0000A000F2E000000008F6200440222102393
65459+:10DAC0000440016A000000008F6200480222102317
65460+:10DAD00004410166240400160A000E218FC20004CE
65461+:10DAE0008F6200480222102304400008000000005A
65462+:10DAF0003C0208008C423100244200013C01080035
65463+:10DB0000AC2231000A000F23000000008F620040A9
65464+:10DB100002221023184000128F8400143C020800D7
65465+:10DB20008C423100327300FC0000A8212442000125
65466+:10DB30003C010800AC2231008F6300409482011C3C
65467+:10DB4000022318233042FFFF0043102A50400010E8
65468+:10DB50002402000C8F6200400A000DF20222102302
65469+:10DB60009483011C9762003C0043102B1040000678
65470+:10DB7000000000009482011C00551023A482011CA7
65471+:10DB80000A000DF72402000CA480011C2402000CE2
65472+:10DB9000AFA200308F620040005120231880000D9A
65473+:10DBA00002A4102A1440012600000000149500066B
65474+:10DBB00002A410233A620001304200011440012007
65475+:10DBC0000000000002A41023022488210A000E098C
65476+:10DBD0003055FFFF00002021326200021040001A81
65477+:10DBE000326200109362003E30420040504000110B
65478+:10DBF0008FC200040E00130202002021240200182C
65479+:10DC0000A362003F936200052403FFFE020020216F
65480+:10DC1000004310240E00130BA362000524040039F6
65481+:10DC2000000028210E0013C9240600180A000F3036
65482+:10DC300024020001240400170040F809000000003D
65483+:10DC40000A000F302402000110400108000000000B
65484+:10DC50008F63004C8F620054028210231C4001032A
65485+:10DC600002831023044200010060A021AFA4001829
65486+:10DC7000AFB10010AFB50014934201208F65004092
65487+:10DC80009763003C304200FF034210210044102102
65488+:10DC90008FA400543063FFFF244240000083182B00
65489+:10DCA0008FA40030AFA20020AFA50028008320255C
65490+:10DCB000AFA40030AFA50024AFA0002CAFB4003457
65491+:10DCC0009362003E30420008504000118FC20000B5
65492+:10DCD00002C0202127A500380E000CB2AFA00038EA
65493+:10DCE0005440000B8FC200008FA200383042010068
65494+:10DCF000504000078FC200008FA3003C8F6200607D
65495+:10DD00000062102304430001AF6300608FC2000073
65496+:10DD10000040F80927A400108FA200303042000212
65497+:10DD200054400001327300FE9362003E30420040D6
65498+:10DD3000104000378FA200248F6200541682001A10
65499+:10DD40003262000124020014124200102A4200151F
65500+:10DD500010400006240200162402000C12420007A4
65501+:10DD6000326200010A000E7D000000001242000530
65502+:10DD7000326200010A000E7D000000000A000E78E9
65503+:10DD80002417000E0A000E78241700100A000E7CDB
65504+:10DD900024170012936200232403FFBD00431024C4
65505+:10DDA000A362002332620001104000198FA20024F8
65506+:10DDB0002402000C1242000E2A42000D1040000600
65507+:10DDC0002402000E2402000A124200078FA200243F
65508+:10DDD0000A000E9524420001124200088FA200247E
65509+:10DDE0000A000E95244200010A000E932417000831
65510+:10DDF0002402000E16E20002241700162417001059
65511+:10DE00008FA2002424420001AFA200248FA200248C
65512+:10DE10008FA300148F76004000431021AF620040B2
65513+:10DE20008F8200149442011C104000090000000081
65514+:10DE30008F6200488F6400409763003C00441023C9
65515+:10DE40003063FFFF0043102A104000088FA20054E7
65516+:10DE5000936400368F6300403402FFFC008210049C
65517+:10DE600000621821AF6300488FA200548FA60030D3
65518+:10DE70000282902130C200081040000E0000000015
65519+:10DE80008F6200581642000430C600FF9742011A04
65520+:10DE90005040000134C6001093C500088FA700341D
65521+:10DEA0000200202100052B0034A500800E000C9BF1
65522+:10DEB00030A5F0808F620040005610231840001BF0
65523+:10DEC0008FA200183C0208008C42319830420010AA
65524+:10DED0001040000D24020001976200681440000AFF
65525+:10DEE000240200018F8200149442011C1440000699
65526+:10DEF00024020001A76200689742007A244200646D
65527+:10DF00000A000EE9A7620012A76200120E001302B7
65528+:10DF1000020020219362007D2403000102002021E1
65529+:10DF2000344200010A000EE7AFA300501840000A77
65530+:10DF3000000000000E001302020020219362007D09
65531+:10DF40002403000102002021AFA30050344200044A
65532+:10DF50000E00130BA362007D9362003E304200402E
65533+:10DF60001440000C326200011040000A0000000062
65534+:10DF70008F6300408FC20004240400182463000152
65535+:10DF80000040F809AF6300408FA200300A000F3054
65536+:10DF9000304200048F620058105200100000000050
65537+:10DFA0008F620018022210231C4000082404000184
65538+:10DFB0008F62001816220009000000008F62001C0A
65539+:10DFC000028210230440000500000000AF720058D8
65540+:10DFD000AFA40050AF710018AF74001C12E0000B2A
65541+:10DFE0008FA200500E00130202002021A377003FF1
65542+:10DFF0000E00130B0200202102E030212404003720
65543+:10E000000E0013C9000028218FA200501040000309
65544+:10E01000000000000E000CA90200202112A0000543
65545+:10E02000000018218FA2003030420004504000113F
65546+:10E0300000601021240300010A000F30006010214D
65547+:10E040000E001302020020219362007D02002021B5
65548+:10E05000344200040E00130BA362007D0E000CA9D5
65549+:10E06000020020210A000F3024020001AF400044CA
65550+:10E07000240200018FBF007C8FBE00788FB7007430
65551+:10E080008FB600708FB5006C8FB400688FB30064DA
65552+:10E090008FB200608FB1005C8FB0005803E00008C1
65553+:10E0A00027BD00808F4201B80440FFFE2402080013
65554+:10E0B000AF4201B803E00008000000003C02000885
65555+:10E0C00003421021944200483084FFFF2484001250
65556+:10E0D0003045FFFF10A0001700A4102B10400016C1
65557+:10E0E00024020003934201202403001AA343018B5E
65558+:10E0F000304200FF2446FFFE8F82000000A6182B4E
65559+:10E100003863000100021382004310241040000510
65560+:10E110008F84000434820001A746019403E00008C4
65561+:10E12000AF8200042402FFFE0082102403E00008F6
65562+:10E13000AF8200042402000303E00008A342018B25
65563+:10E1400027BDFFE0AFB10014AFB00010AFBF0018A3
65564+:10E1500030B0FFFF30D1FFFF8F4201B80440FFFE17
65565+:10E1600000000000AF440180AF4400200E000F42C9
65566+:10E17000020020218F8300008F840004A750019AA1
65567+:10E18000A750018EA74301908F8300083082800042
65568+:10E19000AF4301A8A75101881040000E8F820004F0
65569+:10E1A00093420116304200FC24420004005A102120
65570+:10E1B0008C4240003042FFFF144000068F82000472
65571+:10E1C0003C02FFFF34427FFF00821024AF82000434
65572+:10E1D0008F8200042403BFFF00431024A74201A63E
65573+:10E1E0009743010C8F42010400031C003042FFFFE3
65574+:10E1F00000621825AF4301AC3C021000AF4201B8E9
65575+:10E200008FBF00188FB100148FB0001003E000081A
65576+:10E2100027BD00208F470070934201128F830000BA
65577+:10E2200027BDFFF0304200FF00022882306201006B
65578+:10E23000000030211040004324A40003306240005D
65579+:10E24000104000103062200000041080005A10219D
65580+:10E250008C43400024A4000400041080AFA30000FD
65581+:10E26000005A10218C424000AFA2000493420116D4
65582+:10E27000304200FC005A10218C4240000A000FC0BE
65583+:10E28000AFA200081040002F0000302100041080D1
65584+:10E29000005A10218C43400024A400040004108084
65585+:10E2A000AFA30000005A10218C424000AFA000082C
65586+:10E2B000AFA200048FA80008000030210000202138
65587+:10E2C000240A00083C0908002529010003A41021A4
65588+:10E2D000148A000300042A001100000A0000000054
65589+:10E2E00090420000248400012C83000C00A2102125
65590+:10E2F00000021080004910218C4200001460FFF3DE
65591+:10E3000000C230263C0408008C8431048F42007027
65592+:10E310002C83002010600009004738233C030800CC
65593+:10E32000246331080004108000431021248300017D
65594+:10E33000AC4700003C010800AC233104AF86000864
65595+:10E340002406000100C0102103E0000827BD0010D2
65596+:10E350003C0208008C42003827BDFFD0AFB5002436
65597+:10E36000AFB40020AFB10014AFBF0028AFB3001CA2
65598+:10E37000AFB20018AFB00010000088213C150800B3
65599+:10E3800026B50038144000022454FFFF0000A021ED
65600+:10E390009742010E8F8400003042FFFF308340001F
65601+:10E3A0001060000A245200043C0200200082102465
65602+:10E3B00050400007308280008F8200042403BFFF9A
65603+:10E3C000008318240A0010103442100030828000AC
65604+:10E3D0001040000A3C020020008210241040000778
65605+:10E3E0008F8200043C03FFFF34637FFF0083182407
65606+:10E3F00034428000AF820004AF8300000E000F980B
65607+:10E400000000000014400007000000009743011EB8
65608+:10E410009742011C3063FFFF0002140000621825C0
65609+:10E42000AF8300089742010C8F4340003045FFFF47
65610+:10E430003402FFFF14620003000000000A001028ED
65611+:10E44000241100208F42400030420100544000015E
65612+:10E45000241100108F8400003082100050400014FE
65613+:10E4600036310001308200201440000B3C021000C5
65614+:10E47000008210245040000E363100013C030E0093
65615+:10E480003C020DFF008318243442FFFF0043102B91
65616+:10E4900050400007363100013C0208008C42002C3D
65617+:10E4A000244200013C010800AC22002C363100055A
65618+:10E4B0003C0608008CC6003454C000238F85000041
65619+:10E4C0008F820004304240005440001F8F850000BE
65620+:10E4D0003C021F01008210243C0310005443001A28
65621+:10E4E0008F85000030A20200144000178F850000C5
65622+:10E4F0003250FFFF363100028F4201B80440FFFE68
65623+:10E5000000000000AF400180020020210E000F42F9
65624+:10E51000AF4000208F8300042402BFFFA750019A60
65625+:10E52000006218248F820000A750018EA751018835
65626+:10E53000A74301A6A74201903C021000AF4201B8D8
65627+:10E540000A0010F5000010213C02100000A2102467
65628+:10E550001040003A0000000010C0000F0000000052
65629+:10E5600030A201001040000C3C0302003C020F00EE
65630+:10E5700000A2102410430008000000008F82000851
65631+:10E58000005410240055102190420004244200043D
65632+:10E590000A00109F000221C00000000000051602C2
65633+:10E5A0003050000F3A0300022E4203EF38420001C0
65634+:10E5B0002C6300010062182414600073240200011F
65635+:10E5C0003C0308008C6300D02E06000C386200016A
65636+:10E5D0002C4200010046102414400015001021C0F8
65637+:10E5E0002602FFFC2C4200045440001100002021B0
65638+:10E5F000386200022C420001004610241040000343
65639+:10E60000000512420A00109F000020210010182B64
65640+:10E610000043102450400006001021C000002021BB
65641+:10E620003245FFFF0E000F633226FFFB001021C0B2
65642+:10E630003245FFFF0A0010F2362600028F424000EA
65643+:10E640003C0308008C630024304201001040004667
65644+:10E6500030620001322200043070000D14400002CC
65645+:10E660002413000424130002000512C238420001E2
65646+:10E670002E4303EF304200013863000100431025B0
65647+:10E68000104000033231FFFB2402FFFB0202802412
65648+:10E6900010C000183202000130A201001040001525
65649+:10E6A000320200013C020F0000A210243C030200D1
65650+:10E6B0001043000F8F8200082403FFFE0203802412
65651+:10E6C00000541024005510219042000402333025DC
65652+:10E6D0002442000412000002000221C03226FFFF83
65653+:10E6E0000E000F633245FFFF1200002700001021CB
65654+:10E6F000320200011040000D320200042402000129
65655+:10E7000012020002023330253226FFFF00002021D2
65656+:10E710000E000F633245FFFF2402FFFE0202802439
65657+:10E7200012000019000010213202000410400016EF
65658+:10E7300024020001240200041202000202333025E8
65659+:10E740003226FFFF3245FFFF0E000F632404010055
65660+:10E750002402FFFB020280241200000B00001021A3
65661+:10E760000A0010F5240200011040000700001021EB
65662+:10E770003245FFFF36260002000020210E000F6305
65663+:10E7800000000000000010218FBF00288FB500247A
65664+:10E790008FB400208FB3001C8FB200188FB100140B
65665+:10E7A0008FB0001003E0000827BD003027BDFFD068
65666+:10E7B000AFB000103C04600CAFBF002CAFB6002817
65667+:10E7C000AFB50024AFB40020AFB3001CAFB2001847
65668+:10E7D000AFB100148C8250002403FF7F3C1A8000EC
65669+:10E7E000004310243442380CAC8250002402000351
65670+:10E7F0003C106000AF4200088E0208083C1B8008F5
65671+:10E800003C010800AC2000203042FFF038420010EC
65672+:10E810002C4200010E001B8DAF8200183C04FFFF4C
65673+:10E820003C020400348308063442000CAE0219484E
65674+:10E83000AE03194C3C0560168E0219808CA30000B3
65675+:10E840003442020000641824AE0219803C02535383
65676+:10E850001462000334A47C008CA200040050202128
65677+:10E860008C82007C8C830078AF820010AF83000C18
65678+:10E870008F55000032A200031040FFFD32A20001BC
65679+:10E880001040013D32A200028F420128AF42002019
65680+:10E890008F4201048F430100AF8200000E000F3C45
65681+:10E8A000AF8300043C0208008C4200C01040000806
65682+:10E8B0008F8400003C0208008C4200C42442000106
65683+:10E8C0003C010800AC2200C40A00126900000000EC
65684+:10E8D0003C020010008210241440010C8F830004BD
65685+:10E8E0003C0208008C4200203C0308008C63003886
65686+:10E8F00000008821244200013C010800AC220020D5
65687+:10E900003C16080026D60038146000022474FFFF6D
65688+:10E910000000A0219742010E308340003042FFFFEB
65689+:10E920001060000A245200043C02002000821024DF
65690+:10E9300050400007308280008F8200042403BFFF14
65691+:10E94000008318240A0011703442100030828000C5
65692+:10E950001040000A3C0200200082102410400007F2
65693+:10E960008F8200043C03FFFF34637FFF0083182481
65694+:10E9700034428000AF820004AF8300000E000F9885
65695+:10E980000000000014400007000000009743011E33
65696+:10E990009742011C3063FFFF00021400006218253B
65697+:10E9A000AF8300089742010C8F4340003045FFFFC2
65698+:10E9B0003402FFFF14620003000000000A00118807
65699+:10E9C000241100208F4240003042010054400001D9
65700+:10E9D000241100108F840000308210005040001479
65701+:10E9E00036310001308200201440000B3C02100040
65702+:10E9F000008210245040000E363100013C030E000E
65703+:10EA00003C020DFF008318243442FFFF0043102B0B
65704+:10EA100050400007363100013C0208008C42002CB7
65705+:10EA2000244200013C010800AC22002C36310005D4
65706+:10EA30003C0608008CC6003454C000238F850000BB
65707+:10EA40008F820004304240005440001F8F85000038
65708+:10EA50003C021F01008210243C0310005443001AA2
65709+:10EA60008F85000030A20200144000178F8500003F
65710+:10EA70003250FFFF363100028F4201B80440FFFEE2
65711+:10EA800000000000AF400180020020210E000F4274
65712+:10EA9000AF4000208F8300042402BFFFA750019ADB
65713+:10EAA000006218248F820000A750018EA7510188B0
65714+:10EAB000A74301A6A74201903C021000AF4201B853
65715+:10EAC0000A001267000010213C02100000A210246E
65716+:10EAD0001040003A0000000010C0000F00000000CD
65717+:10EAE00030A201001040000C3C0302003C020F0069
65718+:10EAF00000A2102410430008000000008F820008CC
65719+:10EB000000541024005610219042000424420004B6
65720+:10EB10000A0011FF000221C00000000000051602DB
65721+:10EB20003050000F3A0300022E4203EF384200013A
65722+:10EB30002C63000100621824146000852402000187
65723+:10EB40003C0308008C6300D02E06000C38620001E4
65724+:10EB50002C4200010046102414400015001021C072
65725+:10EB60002602FFFC2C42000454400011000020212A
65726+:10EB7000386200022C42000100461024504000037D
65727+:10EB8000000512420A0011FF000020210010182B7E
65728+:10EB90000043102450400006001021C00000202136
65729+:10EBA0003245FFFF0E000F633226FFFB001021C02D
65730+:10EBB0003245FFFF0A001252362600028F42400003
65731+:10EBC0003C0308008C6300243042010010400046E2
65732+:10EBD00030620001322200043070000D1440000247
65733+:10EBE0002413000424130002000512C2384200015D
65734+:10EBF0002E4303EF3042000138630001004310252B
65735+:10EC0000104000033231FFFB2402FFFB020280248C
65736+:10EC100010C000183202000130A20100104000159F
65737+:10EC2000320200013C020F0000A210243C0302004B
65738+:10EC30001043000F8F8200082403FFFE020380248C
65739+:10EC40000054102400561021904200040233302555
65740+:10EC50002442000412000002000221C03226FFFFFD
65741+:10EC60000E000F633245FFFF120000390000102133
65742+:10EC7000320200011040000D3202000424020001A3
65743+:10EC800012020002023330253226FFFF000020214D
65744+:10EC90000E000F633245FFFF2402FFFE02028024B4
65745+:10ECA0001200002B00001021320200041040002846
65746+:10ECB0002402000124020004120200020233302563
65747+:10ECC0003226FFFF3245FFFF0E000F6324040100D0
65748+:10ECD0002402FFFB020280241200001D000010210C
65749+:10ECE0000A001267240200015040001900001021A0
65750+:10ECF0003245FFFF36260002000020210E000F6380
65751+:10ED0000000000000A001267000010212402BFFF6B
65752+:10ED1000006210241040000800000000240287FF59
65753+:10ED200000621024144000083C020060008210249D
65754+:10ED300010400005000000000E000D34000000002F
65755+:10ED40000A001267000000000E0012C70000000059
65756+:10ED5000104000063C0240008F4301243C0260202A
65757+:10ED6000AC430014000000003C024000AF420138F8
65758+:10ED70000000000032A200021040FEBD00000000B2
65759+:10ED80008F4201403C044000AF4200208F430148C5
65760+:10ED90003C02700000621824106400420000000071
65761+:10EDA0000083102B144000063C0260003C0220004F
65762+:10EDB000106200073C0240000A0012C3000000007D
65763+:10EDC0001062003C3C0240000A0012C30000000038
65764+:10EDD0008F4501408F4601448F42014800021402D2
65765+:10EDE000304300FF240200041462000A274401801B
65766+:10EDF0008F4201B80440FFFE2402001CAC850000D5
65767+:10EE0000A082000B3C021000AF4201B80A0012C3FE
65768+:10EE10003C0240002402000914620012000616029F
65769+:10EE2000000229C0AF4500208F4201B80440FFFE18
65770+:10EE30002402000124030003AF450180A343018B9A
65771+:10EE4000A740018EA740019AA7400190AF4001A8BA
65772+:10EE5000A7420188A74201A6AF4001AC3C021000C6
65773+:10EE6000AF4201B88F4201B80440FFFE000000002D
65774+:10EE7000AC8500008F42014800021402A482000801
65775+:10EE800024020002A082000B8F420148A4820010DD
65776+:10EE90003C021000AC860024AF4201B80A0012C345
65777+:10EEA0003C0240000E001310000000000A0012C3D4
65778+:10EEB0003C0240000E001BC2000000003C0240006B
65779+:10EEC000AF420178000000000A00112F000000008E
65780+:10EED0008F4201003042003E144000112402000124
65781+:10EEE000AF4000488F420100304207C0104000058B
65782+:10EEF00000000000AF40004CAF40005003E00008AD
65783+:10EF000024020001AF400054AF4000408F42010096
65784+:10EF10003042380054400001AF4000442402000158
65785+:10EF200003E00008000000008F4201B80440FFFE2B
65786+:10EF300024020001AF440180AF400184A74501884D
65787+:10EF4000A342018A24020002A342018B9742014A94
65788+:10EF500014C00004A7420190AF4001A40A0012EFC0
65789+:10EF60003C0210008F420144AF4201A43C02100059
65790+:10EF7000AF4001A803E00008AF4201B88F4201B8DA
65791+:10EF80000440FFFE24020002AF440180AF4401842C
65792+:10EF9000A7450188A342018AA342018B9742014AF7
65793+:10EFA000A7420190AF4001A48F420144AF4201A8A3
65794+:10EFB0003C02100003E00008AF4201B83C029000A0
65795+:10EFC0003442000100822025AF4400208F420020FF
65796+:10EFD0000440FFFE0000000003E000080000000005
65797+:10EFE0003C028000344200010082202503E000083A
65798+:10EFF000AF44002027BDFFE8AFBF0014AFB0001042
65799+:10F000008F50014093430149934201489344014882
65800+:10F01000306300FF304200FF00021200006228252A
65801+:10F020002402001910620076308400802862001AE1
65802+:10F030001040001C24020020240200081062007707
65803+:10F04000286200091040000E2402000B2402000177
65804+:10F0500010620034286200025040000524020006BD
65805+:10F0600050600034020020210A00139A00000000C2
65806+:10F0700010620030020020210A00139A00000000F4
65807+:10F080001062003B2862000C504000022402000E77
65808+:10F090002402000910620056020020210A00139A7F
65809+:10F0A0000000000010620056286200211040000F8E
65810+:10F0B000240200382402001C106200582862001D3F
65811+:10F0C000104000062402001F2402001B1062004CA6
65812+:10F0D000000000000A00139A000000001062004ABD
65813+:10F0E000020020210A00139A00000000106200456F
65814+:10F0F0002862003910400007240200802462FFCB00
65815+:10F100002C42000210400045020020210A00139604
65816+:10F110000000302110620009000000000A00139A6C
65817+:10F12000000000001480003D020020210A0013901E
65818+:10F130008FBF00140A001396240600018F4201B805
65819+:10F140000440FFFE24020002A342018BA745018870
65820+:10F150009742014AA74201908F420144A74201927F
65821+:10F160003C021000AF4201B80A00139C8FBF00148C
65822+:10F170009742014A144000290000000093620005F4
65823+:10F180003042000414400025000000000E0013026D
65824+:10F190000200202193620005020020213442000475
65825+:10F1A0000E00130BA36200059362000530420004B9
65826+:10F1B00014400002000000000000000D93620000F7
65827+:10F1C00024030020304200FF14430014000000001C
65828+:10F1D0008F4201B80440FFFE24020005AF500180B9
65829+:10F1E000A342018B3C0210000A00139AAF4201B8FF
65830+:10F1F0008FBF00148FB000100A0012F227BD001854
65831+:10F200000000000D02002021000030218FBF0014FB
65832+:10F210008FB000100A0012DD27BD00180000000D9D
65833+:10F220008FBF00148FB0001003E0000827BD001846
65834+:10F2300027BDFFE8AFBF00100E000F3C000000002C
65835+:10F24000AF4001808FBF0010000020210A000FE7AF
65836+:10F2500027BD00183084FFFF30A5FFFF00001821F4
65837+:10F260001080000700000000308200011040000202
65838+:10F2700000042042006518210A0013AB0005284055
65839+:10F2800003E000080060102110C0000624C6FFFF44
65840+:10F290008CA2000024A50004AC8200000A0013B573
65841+:10F2A0002484000403E000080000000010A000080F
65842+:10F2B00024A3FFFFAC860000000000000000000057
65843+:10F2C0002402FFFF2463FFFF1462FFFA248400047A
65844+:10F2D00003E0000800000000308300FF30A500FFBD
65845+:10F2E00030C600FF274701808F4201B80440FFFE6F
65846+:10F2F000000000008F42012834634000ACE20000AF
65847+:10F3000024020001ACE00004A4E30008A0E2000A2B
65848+:10F3100024020002A0E2000B3C021000A4E5001051
65849+:10F32000ACE00024ACE00028A4E6001203E00008F2
65850+:10F33000AF4201B827BDFFE8AFBF00109362003FA6
65851+:10F3400024030012304200FF1043000D00803021E2
65852+:10F350008F620044008210230440000A8FBF001017
65853+:10F360008F620048240400390000282100C21023C5
65854+:10F3700004410004240600120E0013C9000000001E
65855+:10F380008FBF00102402000103E0000827BD001811
65856+:10F3900027BDFFC8AFB20030AFB1002CAFBF003403
65857+:10F3A000AFB0002890C5000D0080902130A400105F
65858+:10F3B0001080000B00C088218CC300088F620054AD
65859+:10F3C0001062000730A20005144000B524040001BB
65860+:10F3D0000E000D21000020210A0014BB0040202156
65861+:10F3E00030A200051040000930A30012108000ACCC
65862+:10F3F000240400018E2300088F620054146200A9C7
65863+:10F400008FBF00340A00142C240400382402001298
65864+:10F41000146200A3240400010220202127A500106B
65865+:10F420000E000CB2AFA000101040001102402021CD
65866+:10F430008E220008AF620084AF6000400E0013020D
65867+:10F44000000000009362007D024020213442002031
65868+:10F450000E00130BA362007D0E000CA902402021B8
65869+:10F46000240400382405008D0A0014B82406001274
65870+:10F470009362003E304200081040000F8FA200103F
65871+:10F4800030420100104000078FA300148F6200601B
65872+:10F490000062102304430008AF6300600A001441B7
65873+:10F4A00000000000AF6000609362003E2403FFF79D
65874+:10F4B00000431024A362003E9362003E30420008E5
65875+:10F4C000144000022406000300003021936200343F
65876+:10F4D000936300378F640084304200FF306300FF85
65877+:10F4E00000661821000318800043282100A4202B67
65878+:10F4F0001080000B000000009763003C8F620084C6
65879+:10F500003063FFFF004510230062182B14600004D5
65880+:10F51000000000008F6200840A00145D0045802313
65881+:10F520009762003C3050FFFF8FA300103062000450
65882+:10F5300010400004000628808FA2001C0A001465F9
65883+:10F540000202102B2E02021850400003240202185F
65884+:10F550000A00146E020510233063000410600003DB
65885+:10F56000004510238FA2001C00451023004080217D
65886+:10F570002C42008054400001241000800E00130231
65887+:10F580000240202124020001AF62000C9362003E81
65888+:10F59000001020403042007FA362003E8E22000413
65889+:10F5A00024420001AF620040A770003C8F6200500F
65890+:10F5B0009623000E00431021AF6200588F62005066
65891+:10F5C00000441021AF62005C8E220004AF6200187C
65892+:10F5D0008E220008AF62001C8FA20010304200088B
65893+:10F5E0005440000A93A20020A360003693620036C4
65894+:10F5F0002403FFDFA36200359362003E0043102422
65895+:10F60000A362003E0A0014988E220008A36200350F
65896+:10F610008E220008AF62004C8F6200248F6300408E
65897+:10F6200000431021AF6200489362000024030050A1
65898+:10F63000304200FF144300122403FF803C02080004
65899+:10F640008C4231A00242102100431024AF42002816
65900+:10F650003C0208008C4231A08E2400083C03000CC0
65901+:10F66000024210213042007F03421021004310214A
65902+:10F67000AC4400D88E230008AF820014AC4300DCF9
65903+:10F680000E00130B02402021240400380000282122
65904+:10F690002406000A0E0013C9000000002404000123
65905+:10F6A0008FBF00348FB200308FB1002C8FB0002894
65906+:10F6B0000080102103E0000827BD003827BDFFF8B7
65907+:10F6C00027420180AFA20000308A00FF8F4201B8BC
65908+:10F6D0000440FFFE000000008F4601283C020800A5
65909+:10F6E0008C4231A02403FF80AF86004800C2102165
65910+:10F6F00000431024AF4200243C0208008C4231A099
65911+:10F700008FA900008FA8000000C210213042007FA6
65912+:10F71000034218213C02000A00621821946400D4BC
65913+:10F720008FA700008FA5000024020002AF83001401
65914+:10F73000A0A2000B8FA30000354260003084FFFFC1
65915+:10F74000A4E200083C021000AD260000AD04000455
65916+:10F75000AC60002427BD0008AF4201B803E00008F8
65917+:10F76000240200018F88003C938200288F830014BC
65918+:10F770003C07080024E7779800481023304200FF38
65919+:10F78000304900FC246500888F860040304A000321
65920+:10F790001120000900002021248200048CA3000015
65921+:10F7A000304400FF0089102AACE3000024A50004C7
65922+:10F7B0001440FFF924E70004114000090000202153
65923+:10F7C0002482000190A30000304400FF008A102B27
65924+:10F7D000A0E3000024A500011440FFF924E7000184
65925+:10F7E00030C20003144000048F85003C3102000346
65926+:10F7F0001040000D0000000010A0000900002021B2
65927+:10F800002482000190C30000304400FF0085102BCB
65928+:10F81000A0E3000024C600011440FFF924E7000122
65929+:10F8200003E00008000000001100FFFD000020219F
65930+:10F83000248200048CC30000304400FF0088102B99
65931+:10F84000ACE3000024C600041440FFF924E70004E0
65932+:10F8500003E00008000000008F83003C9382002832
65933+:10F8600030C600FF30A500FF00431023304300FFE7
65934+:10F870008F820014008038210043102114C0000240
65935+:10F88000244800880083382130E20003144000053A
65936+:10F8900030A2000314400003306200031040000D4A
65937+:10F8A0000000000010A000090000202124820001B7
65938+:10F8B00090E30000304400FF0085102BA1030000FE
65939+:10F8C00024E700011440FFF92508000103E00008C7
65940+:10F8D0000000000010A0FFFD000020212482000491
65941+:10F8E0008CE30000304400FF0085102BAD030000C6
65942+:10F8F00024E700041440FFF92508000403E0000891
65943+:10F90000000000000080482130AAFFFF30C600FF41
65944+:10F9100030E7FFFF274801808F4201B80440FFFE17
65945+:10F920008F820048AD0200008F420124AD02000426
65946+:10F930008D220020A5070008A102000A240200165B
65947+:10F94000A102000B934301208D2200088D240004A6
65948+:10F95000306300FF004310219783003A00441021D8
65949+:10F960008D250024004310233C0308008C6331A044
65950+:10F970008F840014A502000C246300E82402FFFF1A
65951+:10F98000A50A000EA5030010A5060012AD0500187B
65952+:10F99000AD020024948201142403FFF73042FFFFDC
65953+:10F9A000AD0200288C820118AD02002C3C02100030
65954+:10F9B000AD000030AF4201B88D220020004310247A
65955+:10F9C00003E00008AD2200208F82001430E7FFFF23
65956+:10F9D00000804821904200D330A5FFFF30C600FFD1
65957+:10F9E0000002110030420F0000E238252748018054
65958+:10F9F0008F4201B80440FFFE8F820048AD02000034
65959+:10FA00008F420124AD0200048D220020A5070008CA
65960+:10FA1000A102000A24020017A102000B9343012057
65961+:10FA20008D2200088D240004306300FF0043102164
65962+:10FA30009783003A004410218F8400140043102360
65963+:10FA40003C0308008C6331A0A502000CA505000E44
65964+:10FA5000246300E8A5030010A5060012AD00001401
65965+:10FA60008D220024AD0200188C82005CAD02001CC7
65966+:10FA70008C820058AD0200202402FFFFAD0200245A
65967+:10FA8000948200E63042FFFFAD02002894820060BD
65968+:10FA9000948300BE30427FFF3063FFFF00021200FC
65969+:10FAA00000431021AD02002C3C021000AD000030DC
65970+:10FAB000AF4201B8948200BE2403FFF700A21021D8
65971+:10FAC000A48200BE8D2200200043102403E0000821
65972+:10FAD000AD220020274301808F4201B80440FFFE81
65973+:10FAE0008F8200249442001C3042FFFF000211C0AC
65974+:10FAF000AC62000024020019A062000B3C0210005E
65975+:10FB0000AC60003003E00008AF4201B88F87002CE2
65976+:10FB100030C300FF8F4201B80440FFFE8F820048CF
65977+:10FB200034636000ACA2000093820044A0A20005F0
65978+:10FB30008CE20010A4A20006A4A300088C8200207E
65979+:10FB40002403FFF7A0A2000A24020002A0A2000BD7
65980+:10FB50008CE20000ACA200108CE20004ACA2001405
65981+:10FB60008CE2001CACA200248CE20020ACA2002895
65982+:10FB70008CE2002CACA2002C8C820024ACA20018D9
65983+:10FB80003C021000AF4201B88C82002000431024D8
65984+:10FB900003E00008AC8200208F86001427BDFFE838
65985+:10FBA000AFBF0014AFB0001090C20063304200201D
65986+:10FBB0001040000830A500FF8CC2007C2403FFDF4A
65987+:10FBC00024420001ACC2007C90C2006300431024B8
65988+:10FBD000A0C2006310A000238F830014275001806F
65989+:10FBE000020028210E0015D6240600828F82001400
65990+:10FBF000904200633042004050400019A38000440E
65991+:10FC00008F83002C8F4201B80440FFFE8F82004892
65992+:10FC1000AE02000024026082A60200082402000254
65993+:10FC2000A202000B8C620008AE0200108C62000C75
65994+:10FC3000AE0200148C620014AE0200188C62001830
65995+:10FC4000AE0200248C620024AE0200288C620028E0
65996+:10FC5000AE02002C3C021000AF4201B8A380004469
65997+:10FC60008F8300148FBF00148FB000109062006368
65998+:10FC700027BD00183042007FA06200639782003ADF
65999+:10FC80008F86003C8F850014938300280046102344
66000+:10FC9000A782003AA4A000E490A400638F820040F1
66001+:10FCA000AF83003C2403FFBF0046102100832024C3
66002+:10FCB000AF820040A0A400638F820014A04000BD6A
66003+:10FCC0008F82001403E00008A44000BE8F8A001455
66004+:10FCD00027BDFFE0AFB10014AFB000108F88003C2B
66005+:10FCE000AFBF00189389001C954200E430D100FF9B
66006+:10FCF0000109182B0080802130AC00FF3047FFFF46
66007+:10FD00000000582114600003310600FF012030215B
66008+:10FD1000010958239783003A0068102B1440003CD7
66009+:10FD20000000000014680007240200018E02002079
66010+:10FD30002403FFFB34E7800000431024AE020020C0
66011+:10FD40002402000134E70880158200053165FFFFB9
66012+:10FD50000E001554020020210A00169102002021F5
66013+:10FD60000E001585020020218F8400482743018062
66014+:10FD70008F4201B80440FFFE24020018AC6400006A
66015+:10FD8000A062000B8F840014948200E6A46200102D
66016+:10FD90003C021000AC600030AF4201B894820060B9
66017+:10FDA00024420001A4820060948200603C030800A9
66018+:10FDB0008C63318830427FFF5443000F02002021C2
66019+:10FDC000948200602403800000431024A482006019
66020+:10FDD0009082006090830060304200FF000211C2F8
66021+:10FDE00000021027000211C03063007F0062182556
66022+:10FDF000A083006002002021022028218FBF00186C
66023+:10FE00008FB100148FB000100A0015F927BD002033
66024+:10FE1000914200632403FF8000431025A142006348
66025+:10FE20009782003A3048FFFF110000209383001CA6
66026+:10FE30008F840014004B1023304600FF948300E4AD
66027+:10FE40002402EFFF0168282B00621824A48300E439
66028+:10FE500014A000038E020020010058210000302170
66029+:10FE60002403FFFB34E7800000431024AE0200208F
66030+:10FE700024020001158200053165FFFF0E001554B4
66031+:10FE8000020020210A0016B99783003A0E0015855A
66032+:10FE9000020020219783003A8F82003CA780003A1D
66033+:10FEA00000431023AF82003C9383001C8F82001418
66034+:10FEB0008FBF00188FB100148FB0001027BD002035
66035+:10FEC00003E00008A04300BD938200442403000126
66036+:10FED00027BDFFE8004330042C420020AFB00010E3
66037+:10FEE000AFBF00142410FFFE10400005274501801D
66038+:10FEF0003C0208008C4231900A0016D600461024BD
66039+:10FF00003C0208008C423194004610241440000743
66040+:10FF1000240600848F8300142410FFFF9062006287
66041+:10FF20003042000F34420040A06200620E0015D63D
66042+:10FF300000000000020010218FBF00148FB00010DD
66043+:10FF400003E0000827BD00188F83002427BDFFE0D1
66044+:10FF5000AFB20018AFB10014AFB00010AFBF001CBB
66045+:10FF60009062000D00A0902130D100FF3042007F50
66046+:10FF7000A062000D8F8500148E4300180080802140
66047+:10FF80008CA2007C146200052402000E90A2006383
66048+:10FF9000344200200A0016FFA0A200630E0016C51E
66049+:10FFA000A38200442403FFFF104300472404FFFF03
66050+:10FFB00052200045000020218E4300003C0200102A
66051+:10FFC00000621024504000043C020008020020217E
66052+:10FFD0000A00170E24020015006210245040000988
66053+:10FFE0008E45000002002021240200140E0016C5D8
66054+:10FFF000A38200442403FFFF104300332404FFFFC7
66055+:020000021000EC
66056+:100000008E4500003C02000200A2102410400016A1
66057+:100010003C0200048F8600248CC200148CC30010A4
66058+:100020008CC40014004310230044102B50400005E2
66059+:10003000020020218E43002C8CC2001010620003AD
66060+:10004000020020210A00173F240200123C02000493
66061+:1000500000A210245040001C00002021020020219A
66062+:100060000A00173F2402001300A2102410400006CB
66063+:100070008F8300248C620010504000130000202168
66064+:100080000A001739020020218C6200105040000441
66065+:100090008E42002C020020210A00173F240200118A
66066+:1000A00050400009000020210200202124020017F6
66067+:1000B0000E0016C5A38200442403FFFF1043000274
66068+:1000C0002404FFFF000020218FBF001C8FB2001806
66069+:1000D0008FB100148FB000100080102103E00008E1
66070+:1000E00027BD00208F83001427BDFFD8AFB40020A8
66071+:1000F000AFB3001CAFB20018AFB10014AFB0001026
66072+:10010000AFBF0024906200638F91002C2412FFFF88
66073+:100110003442004092250000A06200638E2200104D
66074+:100120000080982130B0003F105200060360A021EB
66075+:100130002402000D0E0016C5A38200441052005484
66076+:100140002404FFFF8F8300148E2200188C63007C30
66077+:1001500010430007026020212402000E0E0016C585
66078+:10016000A38200442403FFFF104300492404FFFF3F
66079+:1001700024040020120400048F83001490620063A2
66080+:1001800034420020A06200638F85003410A000205C
66081+:1001900000000000560400048F8200140260202139
66082+:1001A0000A0017902402000A9683000A9442006015
66083+:1001B0003042FFFF144300048F8200202404FFFD1F
66084+:1001C0000A0017B7AF82003C3C0208008C42318C19
66085+:1001D0000045102B14400006026020210000282159
66086+:1001E0000E001646240600010A0017B70000202161
66087+:1001F0002402002D0E0016C5A38200442403FFFF35
66088+:10020000104300232404FFFF0A0017B70000202139
66089+:10021000160400058F8400148E2300142402FFFFAF
66090+:100220005062001802602021948200602442000184
66091+:10023000A4820060948200603C0308008C633188D3
66092+:1002400030427FFF5443000F0260202194820060FF
66093+:100250002403800000431024A48200609082006088
66094+:1002600090830060304200FF000211C2000210279C
66095+:10027000000211C03063007F00621825A083006077
66096+:10028000026020210E0015F9240500010000202144
66097+:100290008FBF00248FB400208FB3001C8FB20018D2
66098+:1002A0008FB100148FB000100080102103E000080F
66099+:1002B00027BD00288F83001427BDFFE8AFB00010D2
66100+:1002C000AFBF0014906200638F87002C00808021F4
66101+:1002D000344200408CE60010A06200633C0308003A
66102+:1002E0008C6331B030C23FFF0043102B1040004EF2
66103+:1002F0008F8500302402FF8090A3000D004310245E
66104+:10030000304200FF504000490200202100061382C5
66105+:10031000304800032402000255020044020020215C
66106+:1003200094A2001C8F85001424030023A4A20114AE
66107+:100330008CE60000000616023042003F1043001019
66108+:100340003C0300838CE300188CA2007C1062000642
66109+:100350002402000E0E0016C5A38200442403FFFFF2
66110+:10036000104300382404FFFF8F8300149062006361
66111+:1003700034420020A06200630A0017FC8F8300242F
66112+:1003800000C31024144300078F83002490A200624E
66113+:100390003042000F34420020A0A20062A38800383F
66114+:1003A0008F8300249062000D3042007FA062000D18
66115+:1003B0008F83003410600018020020218F840030E9
66116+:1003C0008C8200100043102B1040000924020018FA
66117+:1003D000020020210E0016C5A38200442403FFFF63
66118+:1003E000104300182404FFFF0A00182400002021F5
66119+:1003F0008C820010240500010200202100431023FC
66120+:100400008F830024240600010E001646AC62001003
66121+:100410000A001824000020210E0015F9240500010F
66122+:100420000A00182400002021020020212402000DCF
66123+:100430008FBF00148FB0001027BD00180A0016C52A
66124+:10044000A38200448FBF00148FB0001000801021E1
66125+:1004500003E0000827BD001827BDFFC8AFB2002089
66126+:10046000AFBF0034AFB60030AFB5002CAFB400283A
66127+:10047000AFB30024AFB1001CAFB000188F46012805
66128+:100480003C0308008C6331A02402FF80AF86004843
66129+:1004900000C318213065007F03452821006218241D
66130+:1004A0003C02000AAF43002400A2282190A200626F
66131+:1004B00000809021AF850014304200FF000211023D
66132+:1004C000A382003890A200BC304200021440000217
66133+:1004D00024030034240300308F820014A3830028F7
66134+:1004E000938300388C4200C0A3800044AF82003C5C
66135+:1004F000240200041062031C8F84003C8E4400041C
66136+:10050000508003198F84003C8E4200103083FFFF1F
66137+:10051000A784003A106002FFAF8200408F8400146D
66138+:100520002403FF809082006300621024304200FFA9
66139+:10053000144002CF9785003A9383003824020002CA
66140+:1005400030B6FFFF14620005000088219382002866
66141+:100550002403FFFD0A001B19AF82003C8F82003C80
66142+:1005600002C2102B144002A18F8400400E0014EC34
66143+:1005700000000000938300283C040800248477983E
66144+:10058000240200341462002EAF84002C3C0A0800C0
66145+:100590008D4A77C82402FFFFAFA2001000803821E7
66146+:1005A0002405002F3C09080025297398240800FF22
66147+:1005B0002406FFFF90E2000024A3FFFF00062202B2
66148+:1005C00000C21026304200FF0002108000491021B6
66149+:1005D0008C420000306500FF24E7000114A8FFF5FD
66150+:1005E0000082302600061027AFA20014AFA2001030
66151+:1005F0000000282127A7001027A6001400C51023FB
66152+:100600009044000324A2000100A71821304500FFF8
66153+:100610002CA200041440FFF9A06400008FA2001077
66154+:100620001142000724020005024020210E0016C5D9
66155+:10063000A38200442403FFFF104300642404FFFF4F
66156+:100640003C0208009042779C104000098F82001401
66157+:10065000024020212402000C0E0016C5A382004493
66158+:100660002403FFFF104300592404FFFF8F8200146E
66159+:10067000A380001C3C0308008C63779C8C440080A2
66160+:100680003C0200FF3442FFFF006218240083202B4D
66161+:1006900010800008AF83003402402021240200199A
66162+:1006A0000E0016C5A38200442403FFFF1043004739
66163+:1006B0002404FFFF8F87003C9782003A8F85003427
66164+:1006C000AF8700200047202310A0003BA784003AFA
66165+:1006D0008F86001430A200030002102390C300BCD8
66166+:1006E0003050000300B0282100031882307300014D
66167+:1006F0000013108000A228213C0308008C6331A065
66168+:100700008F8200483084FFFF0085202B004310219A
66169+:1007100010800011244200888F84002C1082000E6B
66170+:100720003C033F013C0208008C42779800431024B0
66171+:100730003C0325001443000630E500FF8C820000D6
66172+:10074000ACC200888C8200100A0018E9ACC2009884
66173+:100750000E001529000030219382001C8F850014A3
66174+:100760008F830040020238218F82003CA387001C47
66175+:1007700094A400E4006218218F82003434841000B5
66176+:10078000AF83004000503021A4A400E41260000EAA
66177+:10079000AF86003C24E20004A382001C94A200E483
66178+:1007A00024C30004AF83003C34422000A4A200E430
66179+:1007B0000A001906000020218F820040AF80003C13
66180+:1007C00000471021AF820040000020212414FFFFC9
66181+:1007D000109402112403FFFF3C0808008D0877A83D
66182+:1007E0003C0208008C4231B03C03080090637798CB
66183+:1007F00031043FFF0082102B1040001B3067003F88
66184+:100800003C0208008C4231A88F83004800042180FC
66185+:1008100000621821006418213062007F0342282101
66186+:100820003C02000C00A228213C020080344200015E
66187+:100830003066007800C230252402FF800062102458
66188+:10084000AF42002830640007AF4208048F820014D2
66189+:100850000344202124840940AF460814AF850024B6
66190+:10086000AF840030AC4301189383003824020003A6
66191+:10087000146201CF240200012402002610E201D1FB
66192+:1008800028E2002710400013240200322402002234
66193+:1008900010E201CC28E200231040000824020024CA
66194+:1008A0002402002010E201B82402002110E20147D6
66195+:1008B000024020210A001AFB2402000B10E201C1B1
66196+:1008C0002402002510E20010024020210A001AFB39
66197+:1008D0002402000B10E201AE28E2003310400006B3
66198+:1008E0002402003F2402003110E2009A024020213D
66199+:1008F0000A001AFB2402000B10E201A5024020218D
66200+:100900000A001AFB2402000B8F90002C3C03080005
66201+:100910008C6331B08F8500308E0400100000A82158
66202+:100920008CB3001430823FFF0043102B8CB10020A9
66203+:100930005040018F0240202190A3000D2402FF802F
66204+:1009400000431024304200FF504001890240202122
66205+:10095000000413823042000314400185024020212C
66206+:1009600094A3001C8F8200148E040028A443011459
66207+:100970008CA20010026218231064000302402021A0
66208+:100980000A00197C2402001F8F82003400621021AB
66209+:100990000262102B104000088F83002402402021A7
66210+:1009A000240200180E0016C5A382004410540174DE
66211+:1009B0002404FFFF8F8300248F8400348C62001096
66212+:1009C0000224882100441023AC6200108F8200149E
66213+:1009D000AC7100208C4200680051102B10400009BF
66214+:1009E0008F830030024020212402001D0E0016C516
66215+:1009F000A38200442403FFFF104301612404FFFF8E
66216+:100A00008F8300308E0200248C6300241043000783
66217+:100A1000024020212402001C0E0016C5A3820044BF
66218+:100A20002403FFFF104301562404FFFF8F8400249A
66219+:100A30008C82002424420001AC8200241233000482
66220+:100A40008F8200148C4200685622000E8E02000035
66221+:100A50008E0200003C030080004310241440000D6F
66222+:100A60002402001A024020210E0016C5A382004471
66223+:100A70002403FFFF104301422404FFFF0A0019BAB8
66224+:100A80008E0200143C0300800043102450400003F9
66225+:100A90008E020014AC8000208E0200142411FFFF8F
66226+:100AA0001051000E3C0308003C0208008C423190BB
66227+:100AB000004310242403001B14400007A3830044B8
66228+:100AC0000E0016C5024020211051012D2404FFFF05
66229+:100AD0000A0019CB8E030000A38000448E0300009F
66230+:100AE0003C02000100621024104000123C02008011
66231+:100AF0000062102414400008024020212402001A41
66232+:100B00000E0016C5A38200442403FFFF1043011CFE
66233+:100B10002404FFFF02402021020028210E0016E5D8
66234+:100B2000240600012403FFFF104301152404FFFFE6
66235+:100B3000241500018F83002402A0302102402021CF
66236+:100B40009462003624050001244200010A001ADFE5
66237+:100B5000A46200368F90002C3C0308008C6331B0F7
66238+:100B60008E13001032623FFF0043102B10400089AB
66239+:100B70008F8400302402FF809083000D00431024F6
66240+:100B8000304200FF104000842402000D0013138245
66241+:100B900030420003240300011443007F2402000DAF
66242+:100BA0009082000D30420008544000048F820034CF
66243+:100BB000024020210A001A102402002450400004A0
66244+:100BC0008E03000C024020210A001A102402002784
66245+:100BD0008C82002054620006024020218E0300080F
66246+:100BE0008C820024506200098E02001402402021F1
66247+:100BF000240200200E0016C5A38200441054007188
66248+:100C00002403FFFF0A001A458F8400242411FFFFEC
66249+:100C1000145100048F860014024020210A001A405B
66250+:100C2000240200258E0300188CC2007C1062000391
66251+:100C30002402000E0A001A40024020218E030024E4
66252+:100C40008C82002810620003240200210A001A404E
66253+:100C5000024020218E0500288C82002C10A2000367
66254+:100C60002402001F0A001A40024020218E03002C9B
66255+:100C700014600003240200230A001A4002402021CD
66256+:100C80008CC200680043102B104000032402002691
66257+:100C90000A001A40024020218C82001400651821AD
66258+:100CA0000043102B104000088F84002402402021B4
66259+:100CB000240200220E0016C5A382004410510041F8
66260+:100CC0002403FFFF8F8400242403FFF79082000D8C
66261+:100CD00000431024A082000D8F8600143C030800FE
66262+:100CE0008C6331AC8F82004894C400E08F8500246F
66263+:100CF0000043102130847FFF000420400044102175
66264+:100D00003043007F034320213C03000E0083202159
66265+:100D10002403FF8000431024AF42002CA493000062
66266+:100D20008CA2002824420001ACA200288CA2002C36
66267+:100D30008E03002C00431021ACA2002C8E02002C4C
66268+:100D4000ACA200308E020014ACA2003494A2003A8F
66269+:100D500024420001A4A2003A94C600E03C0208002C
66270+:100D60008C4231B024C4000130837FFF1462000F35
66271+:100D700000803021240280000082302430C2FFFF36
66272+:100D8000000213C2304200FF000210270A001A7E40
66273+:100D9000000233C02402000D024020210E0016C5BF
66274+:100DA000A38200440A001A84004018218F82001494
66275+:100DB00002402021240500010E0015F9A44600E0A0
66276+:100DC000000018210A001B16006088218F90002C5B
66277+:100DD0003C0308008C6331B08E05001030A23FFF49
66278+:100DE0000043102B104000612402FF808F840030EC
66279+:100DF0009083000D00431024304200FF5040005CFF
66280+:100E0000024020218F8200341040000B0005138225
66281+:100E10008F8200149763000A944200603042FFFF03
66282+:100E200014430005000513828F8200202404FFFD77
66283+:100E30000A001AF3AF82003C304200031440000E57
66284+:100E40000000000092020002104000058E03002402
66285+:100E500050600015920300030A001AAF02402021DF
66286+:100E60008C82002450620010920300030240202173
66287+:100E70000A001AB72402000F9082000D30420008C9
66288+:100E80005440000992030003024020212402001074
66289+:100E90000E0016C5A38200442403FFFF1043003850
66290+:100EA0002404FFFF92030003240200025462000C9A
66291+:100EB000920200038F820034544000099202000322
66292+:100EC000024020212402002C0E0016C5A3820044FB
66293+:100ED0002403FFFF1043002A2404FFFF92020003B3
66294+:100EE0000200282102402021384600102CC60001B3
66295+:100EF0002C4200010E0016E5004630252410FFFFAD
66296+:100F00001050001F2404FFFF8F8300341060001373
66297+:100F1000024020213C0208008C42318C0043102BFF
66298+:100F200014400007000000000000282124060001F2
66299+:100F30000E001646000000000A001AF300002021EF
66300+:100F40002402002D0E0016C5A38200441050000C90
66301+:100F50002404FFFF0A001AF3000020210E0015F9F7
66302+:100F6000240500010A001AF300002021024020217C
66303+:100F70002402000D0E0016C5A3820044004020216B
66304+:100F80000A001B16008088211514000E00000000C6
66305+:100F90000E00174C024020210A001B160040882139
66306+:100FA0000E0016C5A38200440A001B1600408821CB
66307+:100FB00014620017022018212402002314E2000505
66308+:100FC0002402000B0E0017C0024020210A001B164D
66309+:100FD0000040882102402021A38200440E0016C553
66310+:100FE0002411FFFF0A001B170220182130A500FF63
66311+:100FF0000E001529240600019783003A8F82003CD9
66312+:10100000A780003A00431023AF82003C0220182141
66313+:101010001220003E9782003A2402FFFD5462003EF7
66314+:101020008E4300208E4200048F830014005610234C
66315+:10103000AE420004906200633042007FA062006311
66316+:101040008E4200208F840014A780003A34420002B0
66317+:10105000AE420020A48000E4908200632403FFBF1E
66318+:1010600000431024A08200630A001B598E43002015
66319+:101070009082006300621024304200FF1040002381
66320+:101080009782003A90820088908300BD2485008872
66321+:101090003042003F2444FFE02C820020A383001C48
66322+:1010A00010400019AF85002C2402000100821804B2
66323+:1010B000306200191440000C3C02800034420002EF
66324+:1010C000006210241440000B306200201040000F1A
66325+:1010D0009782003A90A600010240202124050001D9
66326+:1010E0000A001B5330C60001024020210A001B5297
66327+:1010F00024050001024020210000282124060001CF
66328+:101100000E001646000000009782003A1440FD04CD
66329+:101110008F8400148E4300203062000410400012BF
66330+:101120008F84003C2402FFFB00621024AE420020AA
66331+:10113000274301808F4201B80440FFFE8F820048A0
66332+:10114000AC6200008F420124AC6200042402608380
66333+:10115000A462000824020002A062000B3C021000FE
66334+:10116000AF4201B88F84003C8F8300148FBF0034DE
66335+:101170008FB600308FB5002C8FB400288FB30024B9
66336+:101180008FB200208FB1001C8FB000182402000124
66337+:1011900027BD003803E00008AC6400C030A500FFA4
66338+:1011A0002403000124A900010069102B1040000C49
66339+:1011B00000004021240A000100A31023004A380443
66340+:1011C00024630001308200010069302B10400002CE
66341+:1011D000000420420107402554C0FFF800A310235B
66342+:1011E00003E00008010010213C020800244260A432
66343+:1011F0003C010800AC22738C3C02080024425308D6
66344+:101200003C010800AC2273902402000627BDFFE0D9
66345+:101210003C010800A02273943C021EDCAFB200180F
66346+:10122000AFB10014AFBF001CAFB0001034526F411B
66347+:1012300000008821240500080E001B7A02202021CE
66348+:10124000001180803C07080024E773980002160014
66349+:1012500002071821AC6200000000282124A200012E
66350+:101260003045FFFF8C6200002CA6000804410002FC
66351+:10127000000220400092202614C0FFF8AC64000059
66352+:10128000020780218E0400000E001B7A2405002036
66353+:10129000262300013071FFFF2E2301001460FFE5BB
66354+:1012A000AE0200008FBF001C8FB200188FB1001477
66355+:1012B0008FB0001003E0000827BD002027BDFFD835
66356+:1012C000AFB3001CAFB20018AFBF0020AFB1001425
66357+:1012D000AFB000108F5101408F48014800089402C0
66358+:1012E000324300FF311300FF8F4201B80440FFFE7C
66359+:1012F00027500180AE1100008F420144AE0200046D
66360+:1013000024020002A6120008A202000B240200140C
66361+:10131000AE1300241062002528620015104000085A
66362+:101320002402001524020010106200302402001272
66363+:10133000106200098FBF00200A001CB58FB3001C8B
66364+:101340001062007024020022106200378FBF00205C
66365+:101350000A001CB58FB3001C3C0208008C4231A06F
66366+:101360002403FF800222102100431024AF420024F6
66367+:101370003C0208008C4231A0022210213042007F42
66368+:10138000034218213C02000A00621821166000BCCA
66369+:10139000AF830014906200623042000F344200308C
66370+:1013A000A06200620A001CB48FBF00203C046000F1
66371+:1013B0008C832C083C02F0033442FFFF00621824A7
66372+:1013C000AC832C083C0208008C4231A08C832C0892
66373+:1013D000244200740002108200021480006218256A
66374+:1013E000AC832C080A001CB48FBF00203C0208000C
66375+:1013F0008C4231A02403FF800222102100431024DC
66376+:10140000AF4200243C0208008C4231A03C03000A99
66377+:10141000022210213042007F03421021004310219C
66378+:101420000A001CB3AF8200143C0208008C4231A0B9
66379+:101430002405FF800222102100451024AF42002421
66380+:101440003C0208008C4231A0022210213042007F71
66381+:10145000034218213C02000A0062182190620063D6
66382+:1014600000A21024304200FF10400085AF8300141A
66383+:1014700024620088944300123C0208008C4231A888
66384+:1014800030633FFF00031980022210210043102126
66385+:101490003043007F03432021004510243C03000C0F
66386+:1014A00000832021AF4200289082000D00A210246A
66387+:1014B000304200FF10400072AF8400249082000D83
66388+:1014C000304200101440006F8FBF00200E0015C87E
66389+:1014D000000000008F4201B80440FFFE0000000041
66390+:1014E000AE1100008F420144AE020004240200024B
66391+:1014F000A6120008A202000BAE1300240A001CB4BE
66392+:101500008FBF00202406FF8002261024AF42002057
66393+:101510003C0208008C4231A031043FFF00042180CE
66394+:101520000222102100461024AF4200243C03080090
66395+:101530008C6331A83C0208008C4231A03227007F26
66396+:101540000223182102221021006418213042007F5A
66397+:101550003064007F034228213C02000A0066182400
66398+:1015600000A22821034420213C02000C00822021FB
66399+:10157000AF4300283C020008034718210062902175
66400+:10158000AF850014AF8400240E0015C8010080212F
66401+:101590008F4201B80440FFFE8F8200248F84001424
66402+:1015A000274501809042000DACB10000A4B00006B8
66403+:1015B000000216000002160300021027000237C2C4
66404+:1015C00014C00016248200889442001232033FFFA8
66405+:1015D00030423FFF14430012240260829083006374
66406+:1015E0002402FF8000431024304200FF5040000CD2
66407+:1015F00024026082908200623042000F3442004038
66408+:10160000A082006224026084A4A200082402000DCB
66409+:10161000A0A200050A001C9E3C0227002402608252
66410+:10162000A4A20008A0A000053C02270000061C00A0
66411+:101630000062182524020002A0A2000BACA3001037
66412+:10164000ACA00014ACA00024ACA00028ACA0002CDE
66413+:101650008E42004C8F840024ACA200189083000DB1
66414+:101660002402FF8000431024304200FF1040000598
66415+:101670008FBF00209082000D3042007FA082000DBD
66416+:101680008FBF00208FB3001C8FB200188FB10014E1
66417+:101690008FB000103C02100027BD002803E00008B6
66418+:1016A000AF4201B80800343008003430080033A8D5
66419+:1016B000080033E0080034140800343808003438D7
66420+:1016C00008003438080033180A0001240000000024
66421+:1016D000000000000000000D747061362E322E33C1
66422+:1016E00000000000060203010000000000000000EE
66423+:1016F00000000000000000000000000000000000EA
66424+:1017000000000000000000000000000000000000D9
66425+:1017100000000000000000000000000000000000C9
66426+:1017200000000000000000000000000000000000B9
66427+:1017300000000000000000000000000000000000A9
66428+:101740000000000000000000000000000000000099
66429+:101750000000000000000000000000001000000376
66430+:10176000000000000000000D0000000D3C02080019
66431+:1017700024421C003C03080024632094AC40000079
66432+:101780000043202B1480FFFD244200043C1D080070
66433+:1017900037BD2FFC03A0F0213C1008002610049058
66434+:1017A0003C1C0800279C1C000E00015C000000008F
66435+:1017B0000000000D3084FFFF308200078F85001885
66436+:1017C00010400002248300073064FFF800853021B8
66437+:1017D00030C41FFF03441821247B4000AF85001C48
66438+:1017E000AF84001803E00008AF4400843084FFFF9A
66439+:1017F000308200078F8500208F860028104000026D
66440+:10180000248300073064FFF8008520210086182B10
66441+:1018100014600002AF8500240086202303442821A1
66442+:1018200034068000AF840020AF44008000A6202151
66443+:1018300003E00008AF84003827BDFFD8AFB3001C19
66444+:10184000AFB20018AFB00010AFBF0024AFB400209B
66445+:10185000AFB100143C0860088D1450002418FF7FBD
66446+:101860003C1A8000029898243672380CAD12500051
66447+:101870008F5100083C07601C3C08600036300001B6
66448+:10188000AF500008AF800018AF400080AF40008428
66449+:101890008CE600088D0F08083C0760168CEC0000F1
66450+:1018A00031EEFFF039CA00103C0DFFFF340B800011
66451+:1018B0003C030080034B48212D440001018D282466
66452+:1018C0003C0253533C010800AC230420AF8900388C
66453+:1018D000AF860028AF840010275B400014A20003ED
66454+:1018E00034E37C008CF90004032818218C7F007CF1
66455+:1018F0008C6500783C0280003C0B08008D6B048CEA
66456+:101900003C0A08008D4A048834520070AF85003CC0
66457+:10191000AF9F00403C13080026731C440240A021E6
66458+:101920008E4800008F46000038C30001306400017B
66459+:1019300010800017AF880034028048218D2F0000EE
66460+:101940003C0508008CA5045C3C1808008F1804585E
66461+:1019500001E8102300A280210000C8210202402BD0
66462+:1019600003198821022838213C010800AC30045CAE
66463+:101970003C010800AC2704588F4E000039CD00010F
66464+:1019800031AC00011580FFED01E04021AF8F003444
66465+:101990008E5100003C0708008CE7045C3C0D0800F9
66466+:1019A0008DAD04580228802300F0602100007021D2
66467+:1019B0000190302B01AE1821006620213C01080067
66468+:1019C000AC2C045C3C010800AC2404588F46010890
66469+:1019D0008F47010030C92000AF860000AF87000CA0
66470+:1019E0001120000A00C040213C1808008F18042C68
66471+:1019F000270800013C010800AC28042C3C184000DA
66472+:101A0000AF5801380A000196000000009749010410
66473+:101A100000002821014550213122FFFF0162582199
66474+:101A20000162F82B015F502130D902003C0108000F
66475+:101A3000AC2B048C3C010800AC2A0488172000154C
66476+:101A400024040F0010E400130000000024080D001F
66477+:101A500010E8023B30CD000611A0FFE93C18400021
66478+:101A6000936E00002409001031C400F01089027147
66479+:101A700024020070108202E58F880014250F0001F7
66480+:101A8000AF8F00143C184000AF5801380A0001968F
66481+:101A900000000000974C01041180FFD93C18400061
66482+:101AA00030C34000146000A1000000008F460178A0
66483+:101AB00004C0FFFE8F87003824100800240F0008A0
66484+:101AC0008CE30008AF500178A74F0140A7400142C6
66485+:101AD000974E01048F86000031C9FFFF30CD000111
66486+:101AE00011A002E1012040212531FFFE241800024F
66487+:101AF000A75801463228FFFFA75101483C190800AA
66488+:101B00008F39043C172002D08F8C000C30DF00206E
66489+:101B100017E00002240400092404000130C20C0074
66490+:101B2000240504005045000134840004A744014A00
66491+:101B30003C1108008E3104203C1800483C10000184
66492+:101B40000238182530CF00020070282511E000046B
66493+:101B5000000018213C19010000B9282524030001C8
66494+:101B600030DF000453E00005AF8300083C0600109E
66495+:101B700000A6282524030001AF830008AF4510000C
66496+:101B80000000000000000000000000000000000055
66497+:101B90008F83000810600023000000008F451000B4
66498+:101BA00004A1FFFE000000001060001E0000000005
66499+:101BB0008F4410003C0C0020008C102410400019B1
66500+:101BC0008F8E000031CD000211A000160000000031
66501+:101BD000974F101415E000130000000097591008EB
66502+:101BE0003338FFFF271100060011188200033080F0
66503+:101BF00000C7282132300001322300031200032CD9
66504+:101C00008CA200000000000D00C7F821AFE2000028
66505+:101C10003C0508008CA5043024A600013C01080006
66506+:101C2000AC2604308F6D00003402FFFFAF8D00043E
66507+:101C30008CEC0000118202A6000020218CED000037
66508+:101C400031AC01001180028A000000003C02080053
66509+:101C50008C4204743C0308008C63044C3C1F080055
66510+:101C60008FFF04703C1808008F1804480048382182
66511+:101C70000068802100E8282B03E430210208402B73
66512+:101C80000304882100C57021022878213C01080046
66513+:101C9000AC30044C3C010800AC2F04483C01080067
66514+:101CA000AC2704743C010800AC2E04708F8400182B
66515+:101CB0000120302131290007249F000833F91FFF3C
66516+:101CC00003594021AF84001CAF990018251B400028
66517+:101CD000AF590084112000038F83002024C2000725
66518+:101CE0003046FFF88F84002800C3282100A4302B41
66519+:101CF00014C00002AF83002400A428230345602100
66520+:101D0000340D8000018D10213C0F1000AF850020A4
66521+:101D1000AF820038AF450080AF4F01788F88001444
66522+:101D2000250F00010A0001EFAF8F00148F62000839
66523+:101D30008F670000240500300007760231C300F0F1
66524+:101D4000106500A7240F0040546FFF4C8F880014CB
66525+:101D50008F4B01780560FFFE0000000030CA0200D2
66526+:101D600015400003000612820000000D00061282DA
66527+:101D7000304D0003000D4900012D18210003808023
66528+:101D8000020D402100086080019380218E1F000019
66529+:101D900017E00002000000000000000D8F6E00043C
66530+:101DA00005C202BD92070006920E000592020004D1
66531+:101DB0003C090001000E18800070F8218FED00181A
66532+:101DC000277100082448000501A96021000830821D
66533+:101DD000AFEC0018022020210E00059E26050014FD
66534+:101DE000920A00068F7900043C0B7FFF000A2080D6
66535+:101DF000009178218DF800043566FFFF0326282422
66536+:101E000003053821ADE70004920E0005920D000491
66537+:101E1000960C0008000E10800051C8218F2300008E
66538+:101E2000974901043C07FFFF006758243128FFFF52
66539+:101E3000010DF82103EC50233144FFFF01643025EC
66540+:101E4000AF260000920300072418000110780275E5
66541+:101E5000240F0003106F0285000000008E050010A3
66542+:101E60002419000AA7590140A7450142921800040D
66543+:101E70008F860000240F0001A7580144A7400146A7
66544+:101E80009747010430D100023C050041A7470148B3
66545+:101E900000001821A74F014A1220000330CB000494
66546+:101EA0003C0501412403000151600005AF83000897
66547+:101EB0003C06001000A6282524030001AF8300087B
66548+:101EC000AF4510000000000000000000000000000E
66549+:101ED000000000008F8A000811400004000000008C
66550+:101EE0008F4410000481FFFE000000008F6B000093
66551+:101EF000920800043C1108008E310444AF8B0004AA
66552+:101F000097590104311800FF3C0E08008DCE0440A3
66553+:101F10003325FFFF0305382102276021000010212F
66554+:101F2000250F000A31E8FFFF0187482B01C2682115
66555+:101F300001A9F821311000073C010800AC2C044431
66556+:101F40003C010800AC3F0440120000038F8C0018D5
66557+:101F50002506000730C8FFF8010C682131BF1FFFBC
66558+:101F6000AF8C001CAF9F0018AF5F00849744010442
66559+:101F7000035F80213084FFFF308A00071140000397
66560+:101F8000261B4000248900073124FFF88F8200209F
66561+:101F90008F850028008220210085702B15C000024B
66562+:101FA000AF820024008520233C0B08008D6B048C3D
66563+:101FB0003C0A08008D4A04880344882134038000C9
66564+:101FC000022310213C0F1000AF840020AF820038A4
66565+:101FD000AF440080AF4F01780A0002968F8800144A
66566+:101FE0008F5001780600FFFE30D10200162000035A
66567+:101FF000000612820000000D00061282305F00030E
66568+:10200000001F1900007F302100062080009FC8219A
66569+:1020100000194880013380218E180000130000024F
66570+:10202000000000000000000D8F6C000C058001FB1B
66571+:102030008F870038240E0001AE0E00008CE30008EC
66572+:10204000A20000078F65000400055402314D00FF17
66573+:1020500025A80005000830822CCB00411560000245
66574+:10206000A20A00040000000D8F7800043C03FFFF6B
66575+:1020700000E02821330BFFFF256C000B000C1082C1
66576+:1020800000022080008748218D3F000026040014B4
66577+:10209000A618000803E3C8240E00059EAD39000011
66578+:1020A0008F4F01083C11100001F1382410E001AB02
66579+:1020B00000000000974D01049208000725AAFFECDC
66580+:1020C000350600023144FFFFA2060007960600080D
66581+:1020D0002CC7001354E0000592030007921100077B
66582+:1020E000362F0001A20F00079203000724180001F9
66583+:1020F000107801C224090003106901D58F880038C7
66584+:1021000030CBFFFF257100020011788331E400FF1E
66585+:1021100000042880A20F000500A848218D2D000092
66586+:10212000974A01043C0EFFFF01AEF8243143FFFF44
66587+:10213000006B1023244CFFFE03ECC825AD390000D2
66588+:10214000920600053C03FFF63462FFFF30D800FF23
66589+:102150000018388000F08821922F00143C04FF7F83
66590+:102160003487FFFF31EE000F01C65821316500FFB3
66591+:1021700000055080015068218DAC00200148F821F5
66592+:10218000A20B00060182C824AE0C000CAFF9000CB3
66593+:10219000920900068E11000C032778240009C080E4
66594+:1021A0000310702195C60026030828210227202449
66595+:1021B000AE04000CADCF0020ADC60024ACA60010CC
66596+:1021C0008F8800003C0B08008D6B048C3C0A0800D3
66597+:1021D0008D4A0488241F001024190002A75F0140C3
66598+:1021E000A7400142A7400144A7590146974901046D
66599+:1021F00024070001310600022538FFFEA7580148D8
66600+:102200003C050009A747014A10C00003000018213F
66601+:102210003C05010924030001310C00045180000534
66602+:10222000AF8300083C08001000A828252403000103
66603+:10223000AF830008AF451000000000000000000060
66604+:1022400000000000000000009205000424AE00021F
66605+:1022500031CD0007000D182330620007AE020010D8
66606+:102260008F90000812000004000000008F4F100043
66607+:1022700005E1FFFE000000008F7100008F8E001846
66608+:102280003C0308008C630444AF91000497450104AB
66609+:1022900025CF001031E61FFF30A2FFFFAF8E001CDC
66610+:1022A000AF860018AF4600842449FFFE3C0C0800AE
66611+:1022B0008D8C0440974D010401208021000947C303
66612+:1022C0000070C02131A9FFFF0310F82B0188C8213D
66613+:1022D000033F202103463821313100073C0108002B
66614+:1022E000AC3804443C010800AC2404401220000334
66615+:1022F00024FB40002527000730E9FFF88F860020E7
66616+:102300008F8400280126382100E4C02B170000022A
66617+:10231000AF86002400E438230347202134198000CD
66618+:10232000009910213C0F1000AF870020AF820038C9
66619+:10233000AF470080AF4F01780A0002968F880014E3
66620+:102340009747010410E0FDAE3C1840008F5801781B
66621+:102350000700FFFE30C5400010A000033C1F00082E
66622+:102360000000000D3C1F0008AF5F01402410080072
66623+:102370008F860000AF5001789744010430D90001E6
66624+:10238000132000ED3086FFFF24CCFFFE240D000259
66625+:10239000A74D0146A74C01488F9100182408000D55
66626+:1023A000A748014A8F630000262F000831E21FFF73
66627+:1023B0000342702130C90007AF830004AF91001CB5
66628+:1023C000AF82001800C03821AF4200841120000302
66629+:1023D00025DB400024D800073307FFF88F85002055
66630+:1023E0008F84002800E5302100C4382B14E000025F
66631+:1023F000AF85002400C430238F8400140346F821E5
66632+:10240000340C8000AF86002003EC8021AF460080B2
66633+:10241000249900013C0610003C184000AF460178AA
66634+:10242000AF900038AF990014AF5801380A000196F8
66635+:10243000000000008F630000975101043067FFFF28
66636+:102440003228FFFF8F4F017805E0FFFE30EC0007D8
66637+:10245000000CF82333F0000724F9FFFE2404000ADF
66638+:10246000A7440140A7500142A7590144A740014693
66639+:10247000A74801488F45010830B800201700000226
66640+:10248000240300092403000130CD0002A743014AC0
66641+:102490003C04004111A00003000018213C0401414C
66642+:1024A0002403000130C9000451200005AF83000857
66643+:1024B0003C0600100086202524030001AF8300089D
66644+:1024C000AF44100000000000000000000000000009
66645+:1024D000000000008F8E000811C000040000000002
66646+:1024E0008F4210000441FFFE000000008F7F0000BB
66647+:1024F000276400088F91003CAF9F0004948500087A
66648+:102500009490000A9499000C30AFFFFF0010C400B3
66649+:102510003323FFFF11F100A6030320253C0E080022
66650+:102520008DCE04443C0C08008D8C044000E88821CA
66651+:102530002626FFFE01C628210000682100A6F82BF0
66652+:10254000018D2021009F80213C010800AC2504441E
66653+:102550003C010800AC30044024E200083042FFFF98
66654+:102560003047000710E000038F830018244F000756
66655+:1025700031E2FFF83106FFFF30C800070043802139
66656+:1025800032191FFF0359C021AF83001CAF990018F7
66657+:10259000271B4000AF590084110000038F8C0020DE
66658+:1025A00024C5000730A6FFF88F84002800CC28211E
66659+:1025B00000A4F82B17E00002AF8C002400A428230D
66660+:1025C000AF850020AF4500803C0408008C840434B3
66661+:1025D00003454821340E8000012E6821108000053B
66662+:1025E000AF8D0038939100172406000E12260011BB
66663+:1025F0002407043F3C021000AF4201788F8800148A
66664+:10260000250F00010A0001EFAF8F00140E0005C472
66665+:1026100000E020218F8800143C0B08008D6B048C97
66666+:102620003C0A08008D4A0488250F00010A0001EFCA
66667+:10263000AF8F00143C021000A7470148AF42017859
66668+:102640000A0004CE8F88001424040F001184003D7A
66669+:1026500030CE002015C0000224030009240300012D
66670+:102660000A00021AA743014A0A00020DA7400146C8
66671+:1026700094EF000894F1000A94F0000C8F8C003C59
66672+:10268000001174003207FFFF31EDFFFF11AC00377E
66673+:1026900001C720253C1808008F1804443C0F08008F
66674+:1026A0008DEF0440000080210308682101A8382B29
66675+:1026B00001F0702101C760213C010800AC2D0444E9
66676+:1026C0003C010800AC2C04400A00027A8F840018F8
66677+:1026D0003C0208008C42047C3C0308008C630454D8
66678+:1026E0003C1F08008FFF04783C1808008F18045026
66679+:1026F000004838210068802100E8282B03E43021BD
66680+:102700000208402B0304882100C57021022878218B
66681+:102710003C010800AC3004543C010800AC2F0450CC
66682+:102720003C010800AC27047C3C010800AC2E047876
66683+:102730000A00027A8F840018A74001460A00043577
66684+:102740008F91001830CD002015A0FFC52403000D87
66685+:10275000240300050A00021AA743014A974E010408
66686+:1027600025C5FFF00A00038130A4FFFF8F980040C9
66687+:102770001498FFC8000010213C0508008CA5046CCB
66688+:102780003C1F08008FFF046800A8C8210328302BD5
66689+:1027900003E22021008640213C010800AC39046C92
66690+:1027A0003C010800AC2804680A00027A8F840018F3
66691+:1027B0008F8C0040148CFF5900E8C8213C18080099
66692+:1027C0008F18046C3C1108008E3104682723FFFE2B
66693+:1027D00003034821000010210123302B0222702125
66694+:1027E00001C668213C010800AC29046C3C010800CA
66695+:1027F000AC2D04680A0004A524E200088F88003884
66696+:102800003C03FFFF8D02000C0043F82403E4C825BD
66697+:10281000AD19000C0A00038F30CBFFFF0A0003C381
66698+:10282000AE000000974A0104920400048E26000CBA
66699+:10283000014458212579FFF200C7C0243325FFFF4A
66700+:1028400003053825AE27000C0A0002E68E050010AD
66701+:102850003C0DFFFF8D0A0010014D582401646025D6
66702+:10286000AD0C00100A00038F30CBFFFF974301042B
66703+:10287000920E00048E290010006E1021244DFFEEF0
66704+:102880000127602431A8FFFF0188F825AE3F001022
66705+:102890000A0002E68E0500108E0F000CAE0000004C
66706+:1028A00000078880023028210A0002B8ACAF00205F
66707+:1028B0001460000D3058FFFF3C04FFFF0044682403
66708+:1028C00001A47026000E602B000D102B004CF82484
66709+:1028D00013E00002000000000000000D8CAF0000BB
66710+:1028E0000A00025001E410253B03FFFF0003882B80
66711+:1028F0000018802B0211202410800002000000002C
66712+:102900000000000D8CB900000A0002503722FFFFC2
66713+:102910003084FFFF30A5FFFF108000070000182162
66714+:10292000308200011040000200042042006518219E
66715+:102930001480FFFB0005284003E000080060102120
66716+:1029400010C00007000000008CA2000024C6FFFF9A
66717+:1029500024A50004AC82000014C0FFFB2484000402
66718+:1029600003E000080000000010A0000824A3FFFFFF
66719+:10297000AC86000000000000000000002402FFFF01
66720+:102980002463FFFF1462FFFA2484000403E00008BC
66721+:1029900000000000308EFFFF30D8FFFF00057C00F4
66722+:1029A00001F8602539CDFFFF01AC5021014C582BB7
66723+:1029B000014B4821000944023127FFFF00E8302184
66724+:1029C0000006240230C5FFFF00A418213862FFFF73
66725+:1029D00003E000083042FFFF3C0C08008D8C0484AB
66726+:1029E000240BFF8027BDFFD001845021014B4824D8
66727+:1029F000AF4900203C0808008D080484AFB20020D5
66728+:102A0000AFB00018AFBF0028AFB30024AFB1001CB7
66729+:102A1000936600040104382130E4007F009A1021FD
66730+:102A20003C0300080043902130C500200360802152
66731+:102A30003C080111277B000814A000022646007004
66732+:102A40002646006C9213000497510104920F000473
66733+:102A50003267000F322EFFFF31ED004001C72823FF
66734+:102A600011A0000500004821925900BC3338000431
66735+:102A70001700009000000000924300BC307F00046B
66736+:102A800013E0000F0000000010A0000D0000000087
66737+:102A9000960E0002240AFF8000A7602125CDFFFECC
66738+:102AA000A74D1016920B0004014B2024308200FF2A
66739+:102AB00010400085010C40253C0F0400010F40250B
66740+:102AC0008F5301780660FFFE2404000AA7440140EA
66741+:102AD000960D00022404000931AC0007000C5823B5
66742+:102AE000316A0007A74A0142960200022443FFFE12
66743+:102AF000A7430144A7400146975F0104A75F01482F
66744+:102B00008F590108333800205300000124040001CC
66745+:102B1000920F000431EE001015C000023483001043
66746+:102B200000801821A743014A0000000000000000B7
66747+:102B30000000000000000000AF481000000000008E
66748+:102B40000000000000000000000000008F51100095
66749+:102B50000621FFFE3113FFFF12600003000000009A
66750+:102B60008F481018ACC8000096030006307FFFFFA6
66751+:102B700027F900020019988200138880023B302157
66752+:102B80008CD800001520005700183402920300046E
66753+:102B90002405FF8000A3F82433F100FF1220002C4D
66754+:102BA00000000000924700BC30F2000212400028F2
66755+:102BB00000000000974B100C2562FFFEA742101684
66756+:102BC000000000003C0A040035490030AF49100005
66757+:102BD00000000000000000000000000000000000F5
66758+:102BE0008F4C10000581FFFE000000009749100C7B
66759+:102BF0008F51101C00C020213127FFFF24F200302C
66760+:102C0000001218820003288000BBF8213226FFFF43
66761+:102C1000AFF100000E0005B300112C020013C880B4
66762+:102C2000033B98218E78000000027400AFB80010BA
66763+:102C30008FA80010310FFFFFAFAF00108FA400105E
66764+:102C400001C46825AFAD00108FA60010AE6600006D
66765+:102C500097730008976D000A9766000C8F8A003CF6
66766+:102C6000000D5C0030CCFFFF3262FFFF104A0036DF
66767+:102C7000016C2025960600023C10100024D30008A9
66768+:102C80000E00013B3264FFFF974C01040E00014926
66769+:102C90003184FFFFAF5001788FBF00288FB300242D
66770+:102CA0008FB200208FB1001C8FB0001803E0000825
66771+:102CB00027BD003010A0FF700000000024A5FFFC1D
66772+:102CC0000A0005EC240900048CD10000AF51101853
66773+:102CD0008F5301780660FF7A2404000A0A00060177
66774+:102CE0000000000000A7C8218F8800388F4E101CFC
66775+:102CF0000019C0820018788001E82021AC8E000005
66776+:102D0000000E2C0200C020210E0005B331C6FFFFCB
66777+:102D1000023B28218CAD000000025400004030210D
66778+:102D2000AFAD00108FAC0010318BFFFFAFAB0010C8
66779+:102D30008FA2001001424825AFA900108FA70010F4
66780+:102D40000A000631ACA700008F8F0040148FFFC926
66781+:102D50000000000097420104960B00023C050800A9
66782+:102D60008CA5046C3049FFFF316AFFFF3C1108005D
66783+:102D70008E310468012A382124F2FFFE00B240217E
66784+:102D80000012FFC30112C82B023FC02103192021EA
66785+:102D90003C010800AC28046C3C010800AC24046829
66786+:102DA0000A00066B0000000000A4102B1040000970
66787+:102DB000240300010005284000A4102B04A00003F8
66788+:102DC000000318405440FFFC000528401060000735
66789+:102DD000000000000085302B14C0000200031842E0
66790+:102DE000008520231460FFFB0005284203E0000853
66791+:102DF000008010218F85002C27BDFFE800053027BB
66792+:102E00002CC300012CA400020083102510400003F5
66793+:102E1000AFBF00102405007FAF85002C00052827D8
66794+:102E200030A5FFFF0E000592240426F58F830030A5
66795+:102E3000240402BD004030210083382B10E000093B
66796+:102E400024050001000420400083102B04800003AF
66797+:102E5000000528405440FFFC0004204010A000085A
66798+:102E600000C350210064402B1500000200052842D9
66799+:102E70000064182314A0FFFB0004204200C350216B
66800+:102E80008FBF0010000A4C02312200FF27BD00183E
66801+:102E9000AF8A002C03E00008AF8900300A00002A46
66802+:102EA00000000000000000000000000D7478703683
66803+:102EB0002E322E3300000000060203000000000046
66804+:102EC000000001360000EA60000000000000000081
66805+:102ED00000000000000000000000000000000000F2
66806+:102EE00000000000000000000000000000000000E2
66807+:102EF00000000000000000000000000000000016BC
66808+:102F000000000000000000000000000000000000C1
66809+:102F100000000000000000000000000000000000B1
66810+:102F200000000000000000000000000000000000A1
66811+:102F3000000000000000138800000000000005DC15
66812+:102F4000000000000000000010000003000000006E
66813+:102F50000000000D0000000D3C02080024423C204F
66814+:102F60003C03080024633DD4AC4000000043202B08
66815+:102F70001480FFFD244200043C1D080037BD7FFC87
66816+:102F800003A0F0213C100800261000A83C1C0800FB
66817+:102F9000279C3C200E0002BA000000000000000D3B
66818+:102FA0008F8300383C088000350700708CE50000F6
66819+:102FB000008330253C02900000C22025AF85003000
66820+:102FC000AF4400208F4900200520FFFE3C03800015
66821+:102FD000346200708C4500008F8600303C19080078
66822+:102FE0008F39007C3C0E08008DCE007800A620238F
66823+:102FF00003245821000078210164682B01CF60214F
66824+:10300000018D50213C010800AC2B007C3C010800E4
66825+:10301000AC2A007803E00008000000000A0000412C
66826+:10302000240400018F8400383C05800034A2000194
66827+:103030000082182503E00008AF43002003E00008E9
66828+:10304000000010213084FFFF30A5FFFF1080000733
66829+:1030500000001821308200011040000200042042CC
66830+:10306000006518211480FFFB0005284003E00008DC
66831+:103070000060102110C00007000000008CA20000BA
66832+:1030800024C6FFFF24A50004AC82000014C0FFFB8F
66833+:103090002484000403E000080000000010A00008E1
66834+:1030A00024A3FFFFAC860000000000000000000029
66835+:1030B0002402FFFF2463FFFF1462FFFA248400044C
66836+:1030C00003E0000800000000308AFFFF93A800130F
66837+:1030D000A74A014497490E1630C600FF3C02100073
66838+:1030E000A7490146AF450148A3460152A748015AE6
66839+:1030F000AF4701608FA400188FA30014A7440158A4
66840+:10310000AF43015403E00008AF42017803E0000838
66841+:10311000000000003C038000346200708C49000015
66842+:103120008F8800002484000727BDFFF83084FFF853
66843+:10313000AF890030974D008A31ACFFFFAFAC000083
66844+:103140008FAB0000016850232547FFFF30E61FFFCB
66845+:1031500000C4282B14A0FFF73C0C8000358B0070B6
66846+:103160008D6A00003C0708008CE700843C060800DC
66847+:103170008CC6008000081082014918230002788064
66848+:1031800000E370210000202101C3C82B00C4C0212E
66849+:1031900001FA4021031948212502400027BD0008FB
66850+:1031A0003C010800AC2E00843C010800AC290080E2
66851+:1031B00003E00008000000008F8200002486000762
66852+:1031C00030C5FFF800A2182130641FFF03E000089B
66853+:1031D000AF8400008F8700388F8A004027BDFFB87A
66854+:1031E0008F860044AFB60040AFBF0044AFB5003C8F
66855+:1031F000AFB40038AFB30034AFB20030AFB1002C81
66856+:10320000AFB000288F4501048D4900ACAF47008066
66857+:103210008CC8002000A938230000B021AF480E1050
66858+:103220008F440E1000004821AF440E148CC20024BD
66859+:10323000AF420E188F430E18AF430E1C10E001254D
66860+:103240002D230001936B0008116000D400000000E2
66861+:10325000976E001031CDFFFF00ED602B158000CF81
66862+:103260000000000097700010320FFFFFAF4F0E00FC
66863+:103270008F520000325100081220FFFD00000000B4
66864+:1032800097540E088F460E043285FFFF30B30001BD
66865+:1032900012600132000000000000000D30B8A040B4
66866+:1032A00024150040131500C030A9A0001120012DE5
66867+:1032B00000000000937F000813E0000800000000F9
66868+:1032C00097630010306BFFFF00CB402B1100000311
66869+:1032D00030AC00401180012300000000A785003CB5
66870+:1032E000AF8600349366000800E02821AFA70020D5
66871+:1032F00014C0012427B30020AF60000C9782003C6B
66872+:103300003047400014E00002240300162403000E9E
66873+:1033100024194007A363000AAF790014938A003E82
66874+:103320008F740014315800070018AA4002959025A8
66875+:10333000AF7200149784003C8F700014309100101D
66876+:1033400002117825AF6F0014978E003C31CD000834
66877+:1033500011A00147000028218F6700143C021000D3
66878+:103360003C0C810000E22825AF65001497460E0A48
66879+:103370002408000E3405FFFC30C3FFFF006C582505
66880+:10338000AF6B0004A3680002937F000A27E90004E2
66881+:10339000A369000A9786003C9363000A30CC1F00A3
66882+:1033A000000C598301634021251F0028A37F0009D9
66883+:1033B00097490E0CA769001093790009272A00028B
66884+:1033C000315800070018A82332B10007A371000B81
66885+:1033D00093740009976400108F910034978F003C1C
66886+:1033E000329200FF024480210205702131ED00403D
66887+:1033F00011A0000531C4FFFF0091282B3C12800072
66888+:1034000010A000140000A0210224382B14E0011B9E
66889+:103410008FA500208F4D0E14AF4D0E108F420E1C45
66890+:10342000AF420E18AF440E008F4F000031EE00087F
66891+:1034300011C0FFFD0000000097540E080080882195
66892+:1034400000009021A794003C8F500E04241400012A
66893+:10345000AF900034976400103095FFFF8E68000035
66894+:103460000111F82317E00009AE7F00008F650014FA
66895+:103470008F8B004434A60040AF6600148F4C0E10B2
66896+:10348000AD6C00208F430E18AD63002493670008D5
66897+:1034900014E000D2000000000E00009E2404001082
66898+:1034A0008F8900483C08320000402821312600FF67
66899+:1034B0000006FC0003E8502525390001AF990048BB
66900+:1034C000AC4A0000937800099370000A330400FFAF
66901+:1034D00000047400320F00FF01CF6825AC4D0004DA
66902+:1034E0008F820048064000EAACA20008ACA0000CA5
66903+:1034F0009783003C306B0008156000022628000608
66904+:1035000026280002974E0E148F450E1C8F6700046C
66905+:10351000936D000231C4FFFF31A200FFAFA2001083
66906+:103520008F6C0014AFA800180E00008BAFAC001415
66907+:10353000240400100E0000C7000000008E7200007E
66908+:1035400016400005000000008F6400142405FFBF32
66909+:1035500000859824AF7300148F79000C033538214F
66910+:10356000AF67000C9375000816A00008000000006B
66911+:1035700012800006000000008F7F00143C0BEFFF5C
66912+:103580003568FFFE03E84824AF690014A3740008FF
66913+:103590008FA500200A00024602202021AF470E001E
66914+:1035A0000A0000F5000000008F5901780720FFFE97
66915+:1035B000241F08008F840000AF5F0178974B008ABA
66916+:1035C000316AFFFF014448232528FFFF31021FFF16
66917+:1035D0002C4300081460FFF9000000008F8E0048A3
66918+:1035E0008F8D003800C048210344202125C60001EA
66919+:1035F000240C0F00AF86004800E9382324864000E1
66920+:1036000031CA00FF11AC0005240800019391003E6F
66921+:103610003230000700107A4035E80001000AAC00A3
66922+:103620003C18010002B8A025AC9440008F930048DC
66923+:1036300030B2003630A40008ACD3000410800097EC
66924+:1036400001123025974E0E0A8F8D00003C0281003A
66925+:1036500031CCFFFF25AB0008018240253C03100060
66926+:1036600031651FFF25390006241F000EAF48016099
66927+:1036700000C33025A75F015AAF850000A759015844
66928+:1036800014E0000A8F93003824120F0052720002D7
66929+:103690002416000134C600408F580E108F94004449
66930+:1036A000AE9800208F550E18AE9500248F450E144D
66931+:1036B000AF4501448F590E1CAF590148A34A01522E
66932+:1036C0003C0A1000AF460154AF4A017814E0FEDD19
66933+:1036D0002D2300010076A025128000178FBF004423
66934+:1036E0008F84003824160F0010960084000000001C
66935+:1036F0008F45017804A0FFFE24150F001095006E81
66936+:10370000000000008F470E14240202403C1F1000EE
66937+:10371000AF4701448F440E1CAF440148A3400152FF
66938+:10372000A740015AAF400160A7400158AF42015481
66939+:10373000AF5F01788FBF00448FB600408FB5003C6B
66940+:103740008FB400388FB300348FB200308FB1002CAB
66941+:103750008FB0002803E0000827BD004814C0FED049
66942+:1037600030B8A0408F420E148F84004400004821DE
66943+:10377000AC8200208F510E1CAC9100240A00020E76
66944+:103780002D2300018F910034978A003C3C12800069
66945+:103790000220A821315800401700FF300000A0216E
66946+:1037A000976900108F9200343139FFFF13320035D2
66947+:1037B00000002021008048211480FEA000A03821B4
66948+:1037C0008F420E148F840044AC8200208F510E1C57
66949+:1037D000AC9100240A00020E2D230001936A000917
66950+:1037E0009378000B315000FF330F00FF020F702160
66951+:1037F00025C2000A3050FFFF0E00009E020020216B
66952+:103800008F8600483C1F410024CD0001AF8D004849
66953+:10381000936C000930C600FF00064400318300FFAE
66954+:10382000246B0002010B4825013FC825AC5900005C
66955+:103830008F67000C97440E1400F22825AC45000455
66956+:103840008F450E1C8F670004936A00023084FFFFCF
66957+:10385000315800FFAFB800108F6F0014AFB10018DF
66958+:103860000E00008BAFAF00140A0001A60200202159
66959+:10387000AF6000040A00013EA36000020A00024695
66960+:1038800000002021000090210A0001702414000192
66961+:103890003C1280000A000195ACB2000C8F91000030
66962+:1038A00025240002A744015826300008320F1FFFCC
66963+:1038B0000A0001F9AF8F0000AF40014C1120002C2D
66964+:1038C000000000008F590E10AF5901448F430E18AD
66965+:1038D000240200403C1F1000AF430148A3400152A6
66966+:1038E000A740015AAF400160A7400158AF420154C0
66967+:1038F000AF5F01780A0002278FBF00441120000645
66968+:103900000000000097460E0830CC004015800002F1
66969+:10391000000000000000000D8F4D017805A0FFFEA3
66970+:103920000000000097530E103C120500240E2000EA
66971+:10393000326AFFFF0152C025AF58014C8F4F0E1461
66972+:103940003C021000AF4F01448F500E1CAF50014895
66973+:10395000A34001528F840038A740015AAF40016054
66974+:10396000A7400158AF4E01540A000215AF4201783A
66975+:103970008F490E14AF4901448F430E1C0A00028E7A
66976+:10398000240200403C0E20FF27BDFFE03C1A8000CF
66977+:103990003C0F800835CDFFFDAFBF001CAFB2001853
66978+:1039A000AFB10014AFB00010AF8F0040AF4D0E00AC
66979+:1039B0000000000000000000000000000000000007
66980+:1039C000000000003C0C00FF358BFFFDAF4B0E00EC
66981+:1039D0003C0660048CC95000240AFF7F3C11600043
66982+:1039E000012A40243507380CACC750008E24043817
66983+:1039F00024050009AF4500083083FFFF38622F71AE
66984+:103A00002450C0B3AF8000480E000068AF800000B3
66985+:103A100052000001AE20442C0E0004353C11800001
66986+:103A20000E000ED9363000708F8A00403C1208001C
66987+:103A300026523C88020088218E0800008F5F00001B
66988+:103A40003BF900013338000113000017AF88003044
66989+:103A5000022048218D2700003C0F08008DEF006CEC
66990+:103A60003C0C08008D8C006800E8C02301F8282178
66991+:103A70000000682100B8302B018D582101664021DB
66992+:103A80003C010800AC25006C3C010800AC28006833
66993+:103A90008F44000038830001306200011440FFEDC4
66994+:103AA00000E04021AF8700308E0C00003C0508008C
66995+:103AB0008CA5006C3C0408008C84006801883023CD
66996+:103AC00000A638210000102100E6402B00821821BA
66997+:103AD0000068F8213C010800AC27006C3C0108009C
66998+:103AE000AC3F00688F49010025590088AF99004418
66999+:103AF000AF890038AF4900208E070000AF87003043
67000+:103B00008F4D017805A0FFFE000000008E0600002A
67001+:103B10003C0B08008D6B00743C0408008C84007022
67002+:103B200000C728230165F8210000102103E5402B80
67003+:103B30000082382100E8C821240908003C0108005F
67004+:103B4000AC3F00743C010800AC390070AF4901780B
67005+:103B500093580108A398003E938F003E31EE000178
67006+:103B600015C000158F830038240E0D00106E00194B
67007+:103B7000240F0F00106F001D00000000915900007D
67008+:103B800024180050332900FF113800043C1F400066
67009+:103B9000AF5F01380A0002E7000000000E00090EC6
67010+:103BA000000000008F8A00403C1F4000AF5F0138DA
67011+:103BB0000A0002E700000000938D003E31AC0006D1
67012+:103BC000000C51000E0000CE0152D8210A00034320
67013+:103BD0008F8A00403C1B0800277B3D080E0000CE6A
67014+:103BE000000000000A0003438F8A00403C1B0800CD
67015+:103BF000277B3D280E0000CE000000000A00034392
67016+:103C00008F8A004090AA00018FAB00108CAC00108E
67017+:103C10003C0300FF8D680004AD6C00208CAD0014E7
67018+:103C200000E060213462FFFFAD6D00248CA7001816
67019+:103C30003C09FF000109C024AD6700288CAE001CC0
67020+:103C40000182C82403197825AD6F0004AD6E002CE5
67021+:103C50008CAD0008314A00FFAD6D001C94A9000234
67022+:103C60003128FFFFAD68001090A70000A56000029A
67023+:103C7000A1600004A167000090A30002306200FF71
67024+:103C80000002198210600005240500011065000E75
67025+:103C90000000000003E00008A16A00018CD80028A1
67026+:103CA000354A0080AD7800188CCF0014AD6F001439
67027+:103CB0008CCE0030AD6E00088CC4002CA16A0001CF
67028+:103CC00003E00008AD64000C8CCD001CAD6D001845
67029+:103CD0008CC90014AD6900148CC80024AD680008BC
67030+:103CE0008CC70020AD67000C8CC200148C8300646C
67031+:103CF0000043C82B13200007000000008CC20014F2
67032+:103D0000144CFFE400000000354A008003E0000886
67033+:103D1000A16A00018C8200640A000399000000007F
67034+:103D200090AA000027BDFFF88FA9001CA3AA0000DD
67035+:103D30008FAE00003C0FFF808FA8001835E2FFFF18
67036+:103D40008CCD002C01C26024AFAC0000A120000487
67037+:103D500000E06021A7A000028FB800008D270004BA
67038+:103D60000188182100A0582100C05021006D28268C
67039+:103D70003C06FF7F3C0F00FF2CAD000135EEFFFF3E
67040+:103D800034D9FFFF3C02FF0003193024000D1DC091
67041+:103D9000010EC82400E2C02400C370250319782551
67042+:103DA000AD2E0000AD2F00048D450024AFAE000005
67043+:103DB000AD2500088D4D00202405FFFFAD2D000C22
67044+:103DC000956800023107FFFFAD27001091660018CB
67045+:103DD00030C200FF000219C2506000018D4500345E
67046+:103DE000AD2500148D67000827BD0008AD27001C15
67047+:103DF0008C8B00CCAD2C0028AD20002CAD2B0024EA
67048+:103E0000AD20001803E00008AD20002027BDFFE032
67049+:103E1000AFB20018AFB10014AFB00010AFBF001CBC
67050+:103E20009098000000C088213C0D00FF330F007FF8
67051+:103E3000A0CF0000908E000135ACFFFF3C0AFF00D0
67052+:103E4000A0CE000194A6001EA22000048CAB00149A
67053+:103E50008E29000400A08021016C2824012A40241E
67054+:103E60000080902101052025A6260002AE24000432
67055+:103E700026050020262400080E00007624060002F5
67056+:103E800092470000260500282624001400071E0083
67057+:103E90000003160324060004044000032403FFFF6C
67058+:103EA000965900023323FFFF0E000076AE23001068
67059+:103EB000262400248FBF001C8FB200188FB100147D
67060+:103EC0008FB0001024050003000030210A0000809C
67061+:103ED00027BD002027BDFFD8AFB1001CAFB0001830
67062+:103EE000AFBF002090A80000240200018FB0003C6A
67063+:103EF0003103003F00808821106200148FAA00382F
67064+:103F0000240B0005506B0016AFAA001000A0202162
67065+:103F100000C028210E0003DC02003021922400BCE6
67066+:103F2000308300021060000326060030ACC00000A1
67067+:103F300024C600048FBF00208FB1001C8FB0001872
67068+:103F400000C0102103E0000827BD002801403821EF
67069+:103F50000E00035AAFB000100A0004200000000059
67070+:103F60000E0003A1AFB000140A00042000000000FE
67071+:103F70003C02000A034218213C04080024843D6CE2
67072+:103F80002405001A000030210A000080AF8300548D
67073+:103F90003C038000346200708C48000000A058216F
67074+:103FA00000C04821308A00FFAF8800308F4401787C
67075+:103FB0000480FFFE3C0C8000358600708CC500003C
67076+:103FC0003C0308008C6300743C1808008F180070D4
67077+:103FD00000A82023006468210000C82101A4782BD8
67078+:103FE0000319702101CF60213C010800AC2D007441
67079+:103FF0003C010800AC2C00708F480E14AF480144FF
67080+:10400000AF47014CA34A0152A74B01589346010800
67081+:1040100030C5000854A0000135291000934B090059
67082+:1040200024070050316A00FF11470007000000001C
67083+:104030008F450E1CAF450148AF4901543C091000A3
67084+:1040400003E00008AF490178934D010831A800084A
67085+:104050001100001000000000934F010831EE001025
67086+:1040600051C00001352900083C04080090843DD06F
67087+:10407000A34401508F4309A4AF4301488F4209A0D4
67088+:10408000AF420144AF4901543C09100003E000086D
67089+:10409000AF4901783C1908008F393D8C333800084E
67090+:1040A0005700FFF1352900080A00047300000000E2
67091+:1040B00024070040AF470814AF4008108F4209445E
67092+:1040C0008F4309508F4409548F45095C8F46094C32
67093+:1040D000AF820064AF830050AF84004CAF85005CBA
67094+:1040E00003E00008AF8600609346010930C5007FF9
67095+:1040F000000518C0000521400083102103E00008DE
67096+:10410000244200883C09080091293D9124A800021E
67097+:104110003C05110000093C0000E8302500C51825C9
67098+:1041200024820008AC83000003E00008AC80000497
67099+:104130009347010B8F4A002C974F09083C18000E3B
67100+:104140000358482131EEFFFF000E41C0AF48002C5C
67101+:1041500097430908952C001A008040212403000190
67102+:10416000318BFFFFAC8B00008D2D001C00A058216F
67103+:1041700000C06021AC8D00048D24002030E7004099
67104+:10418000AD04000891220019304400031083004858
67105+:104190002885000214A00062240600021086005642
67106+:1041A00024190003109900660000000010E0003A96
67107+:1041B000000000003C07080094E73D8624E200016F
67108+:1041C000934F0934934709219525002A31EE00FFCA
67109+:1041D000000E488230ED00FF978700580009360036
67110+:1041E000000D1C003044FFFF00C310250044C02513
67111+:1041F00000A778213C19400003197025000F4C00DE
67112+:10420000AD090004AD0E0000934D09203C030006EB
67113+:1042100025090014000D360000C32025AD04000858
67114+:104220008F59092C24E5000130A27FFFAD19000C45
67115+:104230008F580930A782005825020028AD180010B9
67116+:104240008F4F0938AD0F0014AD2B00048F4E09407D
67117+:10425000AD2E0008934D09373C05080090A53D9010
67118+:104260008F4409488F46094031A700FF00EC182110
67119+:10427000008678230003C7000005CC0003196025E1
67120+:1042800031E8FFFC01885825AD2B000CAD20001053
67121+:1042900003E00008AF4A002C3C0D080095AD3D86B8
67122+:1042A0003C0E080095CE3D800A0004C901AE1021E5
67123+:1042B0003C05080094A53D8A3C06080094C63D8054
67124+:1042C0003C18080097183D7C952E002400A6782104
67125+:1042D00001F86823000E240025A2FFF200821825B1
67126+:1042E00024190800AD03000CAD190014AD00001036
67127+:1042F0000A0004C4250800189526002495250028E6
67128+:104300000006C40000057C00370E810035ED080072
67129+:10431000AD0E000CAD0D00100A0004C425080014F9
67130+:104320001480FFA200000000952400240004140063
67131+:1043300034430800AD03000C0A0004C42508001033
67132+:104340003C03080094633D8A3C05080094A53D8029
67133+:104350003C06080094C63D7C953900249538002819
67134+:10436000006520210086782300196C000018740075
67135+:1043700025E2FFEE01C2202535A3810024190800A3
67136+:10438000AD03000CAD040010AD190018AD00001411
67137+:104390000A0004C42508001C03E00008240201F4FC
67138+:1043A00027BDFFE8AFB00010AFBF00140E000060E3
67139+:1043B0000080802124050040AF4508148F83005001
67140+:1043C0008F84004C8F85005C0070182100641023DE
67141+:1043D00018400004AF830050AF6300548F66005450
67142+:1043E000AF86004C1200000C000000008F440074E7
67143+:1043F000936800813409FA002D07000710E00005DA
67144+:1044000000891021936C0081240B01F4018B50046E
67145+:1044100001441021AF62000C8F4E095C01C5682376
67146+:1044200019A000048FBF00148F4F095CAF8F005C90
67147+:104430008FBF00148FB000100A00006227BD001863
67148+:104440008F8400648F8300508F82004CAF640044DF
67149+:10445000AF63005003E00008AF6200543C038000EB
67150+:10446000346200708C43000027BDFFF8308700FFE6
67151+:1044700030A900FF30C800FFAF8300308F440178BF
67152+:104480000480FFFE3C028000345900708F38000029
67153+:10449000A3A700033C0708008CE700748FAC000062
67154+:1044A0003C0608008CC60070030378233C0E7FFF97
67155+:1044B00000EFC82135CDFFFF00005021018D2824D9
67156+:1044C00000CA1821000847C0032F202B00A8102580
67157+:1044D0000064C021AFA200003C010800AC390074A8
67158+:1044E0003C010800AC380070934F010AA3A0000201
67159+:1044F0003C0E80FFA3AF00018FAC0000312B007F8A
67160+:1045000035CDFFFF018D4824000B5600012A4025C0
67161+:10451000240730002406FF803C05100027BD00085A
67162+:10452000AF48014CAF470154A7400158A346015280
67163+:1045300003E00008AF45017827BDFFE8AFBF0014D6
67164+:10454000AFB000108F6500743C068000309000FF13
67165+:1045500000A620250E000060AF6400749363000580
67166+:10456000346200080E000062A362000502002021F0
67167+:104570008FBF00148FB00010240500052406000131
67168+:104580000A00057027BD001827BDFFE03C0380002E
67169+:10459000AFB00010AFBF0018AFB1001434620070AC
67170+:1045A0008C470000309000FF30A800FFAF8700303C
67171+:1045B0008F4401780480FFFE3C18800037110070A2
67172+:1045C0008E2F00003C0D08008DAD00743C0A0800E1
67173+:1045D0008D4A007001E7702301AE282100005821A8
67174+:1045E00000AE302B014B4821012638213C01080048
67175+:1045F000AC250074000088213C010800AC27007045
67176+:104600001100000F000000008F6200742619FFFFE8
67177+:104610003208007F0002FE0233E5007F150000062D
67178+:10462000332200FF2407FF800207202624A3FFFF78
67179+:1046300000838025320200FF0040802124111008F1
67180+:104640000E000060000000008F49081831250004AA
67181+:1046500014A0FFFD3218007F001878C000187140C8
67182+:1046600001CF682125AC0088AF4C0818274A098083
67183+:104670008D4B0020AF4B01448D460024AF460148CE
67184+:10468000A35001500E000062A740015802201021E3
67185+:104690008FBF00188FB100148FB0001003E0000826
67186+:1046A00027BD002027BDFFE8308400FFAFBF00100A
67187+:1046B0000E0005BB30A500FF8F8300508FBF001098
67188+:1046C000344500402404FF903C02100027BD001830
67189+:1046D000AF43014CA3440152AF45015403E000082D
67190+:1046E000AF4201789343093E306200081040000D4C
67191+:1046F0003C0901013528080AAC8800008F47007486
67192+:10470000AC8700043C06080090C63D9030C5001000
67193+:1047100050A00006AC8000088F6A0060AC8A0008D8
67194+:104720002484000C03E00008008010210A00062207
67195+:104730002484000C27BDFFE8AFBF0014AFB0001009
67196+:104740009346093F00A050210005288000853823AA
67197+:1047500030C200FF240300063C09080095293D866D
67198+:1047600024E8FFD824050004104300372406000283
67199+:104770009750093C3C0F020400063400320EFFFF44
67200+:1047800001CF6825AC8D0000934C093E318B002091
67201+:104790001160000800000000934309363C02010349
67202+:1047A000345F0300307900FF033FC0252405000873
67203+:1047B000AC98000493430934935909210005F88209
67204+:1047C000306200FF0002C082332F00FF00186E002D
67205+:1047D000000F740001AE6025018920253C094000CE
67206+:1047E00000898025ACF0FFD8934309378F4F0948E3
67207+:1047F0008F580940306200FF004AC821033F7021F2
67208+:1048000001F86023000E6F0001A650253185FFFCE2
67209+:10481000001F58800145482501683821AD09002056
67210+:104820000E00006024F00028240400040E00006242
67211+:10483000A364003F020010218FBF00148FB000104E
67212+:1048400003E0000827BD00180A0006352406001200
67213+:1048500027BDFFD024090010AFB60028AFB5002453
67214+:10486000AFB40020AFB10014AFB000103C0108009D
67215+:10487000A0293D90AFBF002CAFB3001CAFB2001811
67216+:1048800097480908309400FF3C02000E3107FFFFF3
67217+:10489000000731C0AF46002C974409089344010B30
67218+:1048A00030B500FF03428021308300300000B0218A
67219+:1048B0001060012500008821240C00043C01080040
67220+:1048C000A02C3D90934B093E000B5600000A2E038E
67221+:1048D00004A0016000000000AF400048934F010BAE
67222+:1048E00031EE002011C00006000000009358093E80
67223+:1048F00000189E0000139603064001890000000086
67224+:104900009344010B30830040106000038F930050EC
67225+:104910008F8200502453FFFF9347093E30E6000882
67226+:1049200014C0000224120003000090219619002CEC
67227+:1049300093580934934F0937A7990058330C00FF57
67228+:1049400031EE00FF024E6821000D5880016C5021AD
67229+:10495000015140213C010800A4283D869205001821
67230+:1049600030A900FF010918213C010800A4233D885B
67231+:104970009211001816200002000000000000000D37
67232+:104980003C010800A4233D8A3C010800A4203D808E
67233+:104990003C010800A4203D7C935F010B3063FFFFC6
67234+:1049A00033F00040120000022464000A2464000B6B
67235+:1049B0003091FFFF0E00009E022020219358010B32
67236+:1049C0003C08080095083D8A0040202100185982C3
67237+:1049D000316700010E00049A01072821934C010B56
67238+:1049E0008F4B002C974E09083C0F000E034F4021BF
67239+:1049F00031CDFFFF000D51C0AF4A002C974309088D
67240+:104A00009505001A004038212404000130A9FFFF59
67241+:104A1000AC4900008D06001C00404821318A00404E
67242+:104A2000AC4600048D020020ACE20008910300199E
67243+:104A300030630003106400EC28790002172001188D
67244+:104A4000241000021070010C241F0003107F011EAF
67245+:104A500000000000114000DE000000003C090800DA
67246+:104A600095293D8625220001935F0934934E092143
67247+:104A70009504002A33F900FF0019C08231CF00FFEE
67248+:104A8000978E005800184600000F6C00010D80251D
67249+:104A90003045FFFF02051025008E50213C034000E9
67250+:104AA00000433025000A6400ACEC0004ACE60000D2
67251+:104AB000935F09203C19000624EC0014001FC60077
67252+:104AC00003197825ACEF00088F48092C25CD00018B
67253+:104AD00031A57FFFACE8000C8F500930A785005846
67254+:104AE00024E80028ACF000108F4409380100802130
67255+:104AF000ACE40014AD9300048F530940AD9300085B
67256+:104B0000934A09373C19080093393D908F4309486F
67257+:104B10008F460940314200FF0052F82100667023A1
67258+:104B2000001F7F000019C40001F8282531CDFFFCCB
67259+:104B300000AD2025AD84000CAD800010AF4B002CE3
67260+:104B4000934B093E317300081260000D3C060101D1
67261+:104B500034CC080AACEC00288F530074AD13000469
67262+:104B60003C0B0800916B3D903167001050E0000352
67263+:104B7000AD0000088F6A0060AD0A00082510000C27
67264+:104B800012C0003D000000009343093F24160006B8
67265+:104B900024060004306200FF105600C924070002FA
67266+:104BA0009758093C3C0F0204330DFFFF01AF40252D
67267+:104BB000AE0800009345093E30A400201080000894
67268+:104BC00000000000935309363C0B0103357F0300BE
67269+:104BD000327900FF033F7025AE0E00042406000862
67270+:104BE000934F093493480921312AFFFF31ED00FF2B
67271+:104BF000000D1082310300FF0002B60000032C00FC
67272+:104C000002C56025018A9825001220803C094000D9
67273+:104C10000204502302695825AD4BFFD8935F093732
67274+:104C20008F4F09488F58094033F900FF0332702134
67275+:104C30000006B08201D668210007440001F828234D
67276+:104C4000000D1F000068302530A2FFFC2547FFD86B
67277+:104C500000C260250016808002074821ACEC0020CD
67278+:104C6000253000280E00006024120004A372003FCB
67279+:104C70000E000062000000009347010B30F200407C
67280+:104C8000124000053C1900FF8E180000372EFFFF70
67281+:104C9000030E3024AE0600000E0000C702202021C3
67282+:104CA0003C10080092103D90321100031220000FBA
67283+:104CB00002A028218F89005025330001AF930050B6
67284+:104CC000AF7300508F6B00540173F8231BE0000298
67285+:104CD000026020218F640054AF6400548F4C007434
67286+:104CE000258401F4AF64000C02A028210280202159
67287+:104CF000A76000680E0005BB3C1410008F850050B3
67288+:104D000034550006AF45014C8F8A00488FBF002CF8
67289+:104D10008FB3001C25560001AF9600488FB20018D3
67290+:104D2000A34A01528FB60028AF5501548FB1001429
67291+:104D3000AF5401788FB500248FB400208FB00010DD
67292+:104D400003E0000827BD00309358093E00189E007C
67293+:104D500000139603064200362411000293440923EF
67294+:104D6000308300021060FEDD8F8600608F8200506D
67295+:104D700014C2FEDA000000000E0000600000000017
67296+:104D80009369003F24070016312800FF1107000C2B
67297+:104D9000240500083C0C0800918C3D90358B0001E7
67298+:104DA0003C010800A02B3D90936A003F314300FF77
67299+:104DB00010650065240D000A106D005E2402000CD1
67300+:104DC0000E000062000000000A00069000000000D3
67301+:104DD0003C09080095293D863C0A0800954A3D801B
67302+:104DE0000A0006F3012A10213C09080095293D8A92
67303+:104DF0003C04080094843D803C06080094C63D7C39
67304+:104E000095030024012410210046F8230003CC0060
67305+:104E100027F0FFF20330C025240F0800ACF8000C87
67306+:104E2000ACEF0014ACE000100A0006EE24E7001816
67307+:104E30003C010800A0313D90935F093E241600011B
67308+:104E400033F900201720FEA5241100080A0006905F
67309+:104E5000241100048F6E00848F4D094011A0FE9E26
67310+:104E6000AF8E0050240F00143C010800A02F3D908D
67311+:104E70000A00068F00000000950E0024950D002802
67312+:104E8000000E6400000D2C003589810034A6080056
67313+:104E9000ACE9000CACE600100A0006EE24E70014B2
67314+:104EA0001460FEEC000000009502002400021C00CB
67315+:104EB00034640800ACE4000C0A0006EE24E700109D
67316+:104EC0000A000741240700123C02080094423D8A70
67317+:104ED0003C06080094C63D803C03080094633D7C7A
67318+:104EE00095100024951900280046F82103E3C023FB
67319+:104EF00000106C0000197400270FFFEE01CF282569
67320+:104F000035AC8100ACEC000CACE5001024070800C7
67321+:104F1000AD2700182527001C0A0006EEAD2000145E
67322+:104F20008F7F004CAF7F00548F7900540A000699A0
67323+:104F3000AF790050A362003F0E0000620000000045
67324+:104F40000A00069000000000240200140A0008274E
67325+:104F5000A362003F27BDFFE8308400FFAFBF001011
67326+:104F60000E0005BB30A500FF9378007E9379007F8B
67327+:104F7000936E00809368007A332F00FF001866005C
67328+:104F8000000F6C0031CB00FF018D4825000B520053
67329+:104F90008FBF0010012A3825310600FF344470000D
67330+:104FA00000E628252402FF813C03100027BD0018DD
67331+:104FB000AF45014CAF440154A342015203E0000845
67332+:104FC000AF43017827BDFFD8AFB20018AFB10014CE
67333+:104FD000AFB00010AFBF0020AFB3001C9342010977
67334+:104FE000308600FF30B000FF000618C23204000215
67335+:104FF0003071000114800005305200FF93670005F6
67336+:1050000030E5000810A0000D30C80010024020213B
67337+:105010000E0005A702202821240400018FBF0020D4
67338+:105020008FB3001C8FB200188FB100148FB0001026
67339+:105030000080102103E0000827BD00281500003281
67340+:105040000000000093430109000028213062007F26
67341+:10505000000220C00002F94003E49821267900886C
67342+:10506000033B98218E7800248E6F0008130F0046B2
67343+:10507000000000008F640084241800020004FD82F8
67344+:1050800033F900031338007C0000000093660083AE
67345+:10509000934A0109514600043205007C10A00060CB
67346+:1050A000000000003205007C14A0005302402021C3
67347+:1050B00016200006320400018E7F00248F5901045F
67348+:1050C00017F9FFD600002021320400011080000AE9
67349+:1050D000024020218F4209408F9300641053000644
67350+:1050E000000000000E00066D022028218F430940B9
67351+:1050F000AF630044024020210E0006020220282156
67352+:105100000A000860240400013C0908008D2900649D
67353+:10511000252600013C010800AC26006416000012A0
67354+:10512000000000008F6D00843C0E00C001AE6024C2
67355+:1051300015800005024020210E00082E02202821A3
67356+:105140000A00086024040001240500040E00057014
67357+:1051500024060001024020210E00082E02202821F2
67358+:105160000A000860240400010E000041240400012C
67359+:10517000936B007D020B50250E000062A36A007D38
67360+:105180000A0008A38F6D00848F6600748F480104A5
67361+:105190008E67002400064E021507FFB63126007FF9
67362+:1051A000936B008326440001308A007F1146004340
67363+:1051B000316300FF5464FFB08F6400842645000112
67364+:1051C00030B1007F30A200FF122600042405000148
67365+:1051D000004090210A00087624110001240FFF806E
67366+:1051E000024F702401CF9026324200FF00409021F0
67367+:1051F0000A000876241100010E00066D0220282105
67368+:10520000321800301300FFAA321000820240202121
67369+:105210000E0005A7022028210A00086024040001CE
67370+:105220008F6E00743C0F80002405000301CF902591
67371+:10523000AF72007493710083240600010E000570A4
67372+:10524000322400FF0E00004124040001936D007D14
67373+:10525000020D60250E000062A36C007D3C0B08006F
67374+:105260008D6B0054257000013C010800AC300054E7
67375+:105270000A000860240400018F6800743C09800063
67376+:105280002405000401093825AF6700749363008387
67377+:10529000240600010E000570306400FF0E0000417E
67378+:1052A000240400019362007D020298250E00006232
67379+:1052B000A373007D0A00086024040001324D0080C1
67380+:1052C00039AC0080546CFF6C8F6400840A0008C9FC
67381+:1052D0002645000127BDFFC83C0A0008AFBF0030CB
67382+:1052E000AFB5002CAFB40028AFB30024AFB200209C
67383+:1052F000AFB1001CAFB00018034AD8212409004008
67384+:10530000AF490814AF4008108F4209448F43095039
67385+:105310008F4609548F47095C8F48094C9344010814
67386+:105320009345010BAF820064308400FF30A500FF7D
67387+:10533000AF830050AF86004CAF87005C0E00084A78
67388+:10534000AF8800601440017D8FBF0030A760006807
67389+:10535000934D0900240B00503C15080026B53D482C
67390+:1053600031AC00FF3C12080026523D58118B00035F
67391+:10537000000000000000A8210000902193510109C5
67392+:105380008F9F005024040010322E007F000E68C052
67393+:10539000000E6140018D282124B40088AF54081804
67394+:1053A0008F4901048F4A09A43C0B000E034BC02116
67395+:1053B000012A10233C010800AC223D6C8F430958A0
67396+:1053C0003C010800A0243D9097470908007F302346
67397+:1053D0003C010800AC263D7030E8FFFF0008C9C062
67398+:1053E0003C010800AC3F3D94AF59002C974209089E
67399+:1053F0009710002C8EB10000930F001803749821B1
67400+:10540000A7900058AF9300440220F80931F000FF44
67401+:10541000304E000215C001B2304F000111E0014FC3
67402+:10542000000000009343093E3066000814C00002EB
67403+:10543000241400030000A0218F5809A424130001A4
67404+:105440003C010800AC383D98934F0934935109371B
67405+:1054500031EC00FF322E00FF028E6821000D288003
67406+:1054600000AC5021015058213C010800A42B3D887C
67407+:105470003C010800A42A3D8693490934312200FFEB
67408+:1054800002022021249000103C010800A4303D8439
67409+:10549000240700068F9F00503C010800AC273D8C7C
67410+:1054A0008F88005C8F59095800008021011F282334
67411+:1054B00004A00149033F20230480014700A4302BAE
67412+:1054C00010C00149000000003C010800AC253D70FF
67413+:1054D0008E4200000040F809000000003043000246
67414+:1054E000146000F80040882130440001548000100E
67415+:1054F0008E4200043C0908008D293D743C0AC0001E
67416+:10550000012A8025AF500E008F45000030AB000807
67417+:105510001160FFFD00000000974D0E0824100001EF
67418+:10552000A78D003C8F4C0E04AF8C00348E420004DB
67419+:105530000040F8090000000002228825322E0002F7
67420+:1055400015C00180000000003C09080095293D7C41
67421+:105550003C06080094C63D883C0A0800954A3D7EFA
67422+:105560003C1908008F393D74012660213C18080061
67423+:105570008F183D983C03080094633D92018A2021D6
67424+:105580008F4E09400329F821248F000203E32821CC
67425+:10559000031968213C010800A42C3D8AAF8E0064E9
67426+:1055A0003C010800AC2D3D983C010800A4253D803D
67427+:1055B0000E00009E31E4FFFF8F870048004020214D
67428+:1055C0003C010800A0273D918E42000824E800011C
67429+:1055D000AF8800480040F809000000009344010B28
67430+:1055E0008F4C002C974A09083C0B000E034B4021BE
67431+:1055F0003149FFFF000919C08F8B0050AF43002CC9
67432+:10560000974309089506001A00403821308A004067
67433+:1056100030DFFFFFAC5F00008D19001C0040482107
67434+:10562000AC5900048D180020AC580008910F0019E7
67435+:1056300031E30003107300F0000000002862000254
67436+:105640001440010924050002106500FD240D00032B
67437+:10565000106D010D00000000114000D90000000095
67438+:105660003C0A0800954A3D8625420001934D0934C5
67439+:1056700093580921950E002A31A300FF00032082D0
67440+:10568000331F00FF9798005800047E00001FCC00D5
67441+:1056900001F940253049FFFF0109102501D83021CB
67442+:1056A0003C0540000045502500066C00ACED0004B0
67443+:1056B000ACEA0000934309203C04000624ED0014EA
67444+:1056C0000003FE0003E4C825ACF900088F49092C4B
67445+:1056D000270F000131EE7FFFACE9000C8F48093045
67446+:1056E000A78E005824E90028ACE800108F4509383F
67447+:1056F00001204021ACE50014ADAB00048F4209400D
67448+:10570000ADA20008934B09373C1F080093FF3D9062
67449+:105710008F4309488F4A0940316600FF00D4202199
67450+:10572000006A78230004C700001FCC000319282555
67451+:1057300031EEFFFC00AE1025ADA2000CADA00010B4
67452+:10574000AF4C002C934C093E318B00085160000F88
67453+:105750008E58000C3C06010134CA080AACEA002845
67454+:105760008F4B0074AD2B00043C0C0800918C3D90D5
67455+:105770003187001050E00003AD2000088F62006008
67456+:10578000AD2200082528000C8E58000C0300F809F3
67457+:10579000010020213C19080097393D8A3C1F080070
67458+:1057A00097FF3D7E033F782125E900020E0000C7E8
67459+:1057B0003124FFFF3C0E08008DCE3D6C3C080800F4
67460+:1057C0008D083D7401C828233C010800AC253D6CC0
67461+:1057D00014A00006000000003C0308008C633D8C10
67462+:1057E000346400403C010800AC243D8C1200007081
67463+:1057F0008F8C00448F470E108F900044AE0700201E
67464+:105800008F4D0E18AE0D00243C10080096103D8000
67465+:105810000E0000600000000024020040AF420814A7
67466+:105820008F8600508F8A004C00D01821006A5823C0
67467+:1058300019600004AF830050AF6300548F650054BB
67468+:10584000AF85004C1200000C000000008F44007473
67469+:10585000936800813409FA002D0E000711C000057D
67470+:1058600000891821937F0081241901F403F9780439
67471+:1058700001E41821AF63000C8F44095C8F83005C46
67472+:105880000083C0231B000003000000008F50095C50
67473+:10589000AF90005C0E000062000000008F8C005092
67474+:1058A0008E4700103C010800AC2C3D9400E0F80944
67475+:1058B000000000003C0D08008DAD3D6C55A0FEF5CC
67476+:1058C000240700068F450024975909088F8B006430
67477+:1058D0008F9400503C0F001F978200588F86005411
67478+:1058E0008F93004C3328FFFF35E9FF8000A9502437
67479+:1058F000000871C032320100AF4E0024A4C2002C57
67480+:10590000AF4A0024AF6B0044AF740050AF73005433
67481+:105910001640008032380010570000868EA4000424
67482+:10592000322300405460001B8EB100088EB0000C82
67483+:105930000200F809000000008FBF00308FB5002C76
67484+:105940008FB400288FB300248FB200208FB1001CC9
67485+:105950008FB0001803E0000827BD00389347010905
67486+:105960008F8800380007FE0003E8C825AF59008083
67487+:105970008F5809A08F5309A4AFB80010AF580E1468
67488+:105980008FB40010AF540E10AF530E1C0A00096202
67489+:10599000AF530E180220F809000000008EB0000C72
67490+:1059A0000200F809000000000A000AA88FBF0030BA
67491+:1059B000A5800020A59300220A000A5BAD93002475
67492+:1059C0003C09080095293D863C06080094C63D80A8
67493+:1059D0000A0009F4012610213C010800AC203D70AA
67494+:1059E0000A00098E8E4200003C010800AC243D7084
67495+:1059F0000A00098E8E4200003C03080094633D8A31
67496+:105A00003C04080094843D803C1F080097FF3D7CC7
67497+:105A1000951800240064C821033F782300186C0007
67498+:105A200025EEFFF201AE2825AC45000C240208004B
67499+:105A3000ACE20014ACE000100A0009EF24E7001803
67500+:105A400095060024950900280006240000091C0082
67501+:105A5000349F810034790800ACFF000CACF90010D1
67502+:105A60000A0009EF24E700141460FEFB00000000A8
67503+:105A70009518002400187C0035EE0800ACEE000CF0
67504+:105A80000A0009EF24E700103C07080094E73D8076
67505+:105A90003C04080094843D8A3C03080094633D7CE8
67506+:105AA00095190024951800280087F82103E378232E
67507+:105AB0002407080000192C0000186C0025EEFFEEEA
67508+:105AC00001AE302534A28100AD2700182527001C27
67509+:105AD000AD22000CAD2600100A0009EFAD20001425
67510+:105AE00093520109000028210E000602324400FFF3
67511+:105AF0008FBF00308FB5002C8FB400288FB30024E7
67512+:105B00008FB200208FB1001C8FB0001803E0000896
67513+:105B100027BD0038935F010933E400FF0E00066DD6
67514+:105B200000002821323800105300FF7E322300404D
67515+:105B30008EA400040080F809000000000A000AA2F8
67516+:105B4000322300401200FF5F000000008F540E144B
67517+:105B50008F920044AE5400208F530E1C0A000A8A14
67518+:105B6000AE5300248F82001C008040213C040100C1
67519+:105B70009047008530E3002010600009000000001D
67520+:105B80003C0708008CE73D948F83001800E3202336
67521+:105B9000048000089389000414E30003010020211D
67522+:105BA00003E00008008010213C04010003E000082D
67523+:105BB000008010211120000B006738238F8C0020FB
67524+:105BC00024090034918B00BC316A0002514000016D
67525+:105BD0002409003000E9682B15A0FFF10100202105
67526+:105BE00000E938232419FFFC00B9C02400F9782407
67527+:105BF00000F8702B15C0FFEA01E8202130C2000335
67528+:105C00000002182314C00012306900030000302184
67529+:105C100000A9702101C6682100ED602B1180FFE012
67530+:105C20003C0401002D2F00010006482B01053821FE
67531+:105C300001E9302414C0FFDA24E4FFFC2419FFFC3E
67532+:105C400000B9C0240308202103E0000800801021CF
67533+:105C50008F8B002024060004916A00BC31440004AC
67534+:105C60001480FFEC00A970210A000B5E00003021B7
67535+:105C700027BDFFE8AFBF00108F460100934A01091E
67536+:105C80003C1F08008FFF00902407FF80314F00FF6A
67537+:105C900031E8007F0008614003E6C821032CC021E1
67538+:105CA00027090120012770243C010800A02F3DD0C6
67539+:105CB000AF4E080C3C0D08008DAD00903C040080F8
67540+:105CC0003482000301A65821016C182124650120AB
67541+:105CD00030AA007801424025AF48081C3C1F08004C
67542+:105CE0008FFF00908F88004003E6C0213319000722
67543+:105CF00003074824033A7821AF49002825E909C061
67544+:105D0000952E00023C0D08008DAD008C3C0A080069
67545+:105D10008D4A009031CC3FFF01A61821000C59801C
67546+:105D2000006B282100A72024AF44002C95220002FC
67547+:105D30003C1F08008FFF008C9107008530593FFF02
67548+:105D400003E678210019C1800146702101F868211D
67549+:105D500031CC007F31AB007F019A2821017A50219C
67550+:105D60003C03000C3C04000E00A328210144102138
67551+:105D700030E6002027470980AF82002CAF88001C46
67552+:105D8000AF890024AF85002010C00006AF8700282F
67553+:105D90008D0200508CA4010C0044302318C0007701
67554+:105DA00000000000910C0085240DFFDF018D3824D8
67555+:105DB000A10700858F8B001C8F8900248F87002806
67556+:105DC0008D65004CAF850018912F000D31EE00203D
67557+:105DD00011C000170000000024090001A38900047D
67558+:105DE000AF80000C8CE400248F85000C240A00088E
67559+:105DF000AF800008AF8000103C010800A42A3D7E5F
67560+:105E00003C010800A4203D920E000B32000030211E
67561+:105E10008F8500248FBF0010AF82001490A8000D62
67562+:105E200027BD00180008394203E0000830E20001F5
67563+:105E3000913F00022418000133F900FF001921826C
67564+:105E400010980039240800021088005B8F86002C0F
67565+:105E50008CE5002414A0001B8F9F002091220000DD
67566+:105E6000240A00053046003F10CA00472404000100
67567+:105E70008F860008A3840004AF860010AF86000C54
67568+:105E80008CE400248F85000C240A00083C010800E3
67569+:105E9000A42A3D7E3C010800A4203D920E000B3256
67570+:105EA000000000008F8500248FBF0010AF82001417
67571+:105EB00090A8000D27BD00180008394203E0000833
67572+:105EC00030E200018CF800088CF900248FEE00C449
67573+:105ED000A38000048CE40024AF8E000C8F85000C9E
67574+:105EE0008F86000803197823240A0008AF8F00105A
67575+:105EF0003C010800A42A3D7E3C010800A4203D92FC
67576+:105F00000E000B32000000008F8500248FBF0010B0
67577+:105F1000AF82001490A8000D27BD00180008394278
67578+:105F200003E0000830E20001912300003062003FEE
67579+:105F3000104400278F8500208CE400241480002169
67580+:105F4000000000008D2E00183C187FFF8F85002078
67581+:105F5000370FFFFF01CF1824AF8300088F9F000881
67582+:105F60008CA8008403E8C82B1720000203E020213E
67583+:105F70008CA400840A000BEDAF8400088CA3010CF4
67584+:105F80000A000BCBAF8300188D2C00188F860008F9
67585+:105F90003C0D7FFF8F89002035A3FFFF018358242C
67586+:105FA00024040001AF8B0010AD2000CCA3840004BA
67587+:105FB0000A000BF9AF86000C8CCA00140A000BED26
67588+:105FC000AF8A00088CA300C80A000C30AF83000819
67589+:105FD0008F84002C8CAC00648C8D0014018D582BA8
67590+:105FE00011600004000000008CA200640A000C3064
67591+:105FF000AF8200088C8200140A000C30AF820008C7
67592+:106000008F85000C27BDFFE0AFBF0018AFB10014B3
67593+:1060100014A00007AFB000108F86002424020005F2
67594+:1060200090C400003083003F106200B68F840020CF
67595+:106030008F91000800A080218F8C00283C0508006B
67596+:106040008CA53D708D8B000431663FFF00C5502B41
67597+:106050005540000100C02821938D000411A0007359
67598+:1060600000B0F82B8F98002024040034930F00BC5C
67599+:1060700031EE000251C000012404003000A4C82BFE
67600+:10608000172000D10000000000A4282300B0F82B46
67601+:106090003C010800A4243D7C17E000680200202198
67602+:1060A0003C0308008C633D6C0083102B54400001BE
67603+:1060B000008018218F8800243C010800AC233D7427
67604+:1060C000000048219104000D308300205060000141
67605+:1060D0008F490E188F8300140123382B10E00059CC
67606+:1060E000000000003C0408008C843D7400895821A5
67607+:1060F000006B502B114000560090602B006930233C
67608+:1061000000C020213C010800AC263D7412000003B1
67609+:10611000241FFFFC1090008A32270003009FC82430
67610+:106120003C010800AC393D743C010800A4203D92BC
67611+:106130008F84000C120400078F830020AF910008A9
67612+:10614000020020218C7100CCAF90000C26300001A1
67613+:10615000AC7000CC3C0208008C423D748F8A001069
67614+:10616000240700180082202301422823AF84000C5A
67615+:1061700010800002AF850010240700108F86001CDD
67616+:106180003C010800A0273D902407004090CC0085EA
67617+:10619000318B00C0116700408F8D001414A00015D2
67618+:1061A00000002021934A01098F420974314500FF04
67619+:1061B0000002260224A300013090007F3071007F8E
67620+:1061C0001230007A2407FF80A0C300833C09080036
67621+:1061D0008D293D8C8F880024240D0002352C000869
67622+:1061E0003C010800A02D3DD13C010800AC2C3D8CA9
67623+:1061F00024040010910E000D31C6002010C00005CF
67624+:1062000000801821240800013C010800AC283D74DE
67625+:10621000348300018FBF00188FB100148FB00010BD
67626+:106220000060102103E0000827BD00203C010800A9
67627+:10623000A4203D7C13E0FF9A020020210A000C817B
67628+:1062400000A020213C0408008C843D740090602B49
67629+:106250001180FFAE000000003C0F080095EF3D7C70
67630+:1062600001E4702101C6682B11A000072C820004F4
67631+:106270003C1F60008FF954043338003F1700FFE5DE
67632+:10628000240300422C8200041040FFA0240300429B
67633+:106290000A000CDF8FBF0018152DFFC000000000A2
67634+:1062A0008CDF00743C0380002405FF8003E3C825D5
67635+:1062B000ACD9007490D80085240E0004240400108A
67636+:1062C000330F003F01E54025A0C800858F880024DA
67637+:1062D0003C010800A02E3DD1240300019106000DD1
67638+:1062E00030C9002015200003000000003C03080016
67639+:1062F0008C633D743C010800AC233D6C0A000CD655
67640+:10630000000000008F8700108C88008400E8282B94
67641+:1063100014A0000200E088218C910084240900016F
67642+:10632000A38900048F440E18022028210E000B328E
67643+:1063300002203021022080210A000C67AF82001465
67644+:1063400000071823306600033C010800A4263D9294
67645+:10635000122000058F8C0020918B00BC316A000454
67646+:106360001540001524CD00043C0F080095EF3D9228
67647+:1063700001E4702100AE302B50C0FF6E8F84000C02
67648+:106380002C85000514A0FFA32403004230980003CD
67649+:1063900017000002009818232483FFFC3C0108002A
67650+:1063A000AC233D740A000CA30000000000A7582491
67651+:1063B0000A000CCB016718263C010800A42D3D9271
67652+:1063C0000A000D33000000003C010800AC203D74C1
67653+:1063D0000A000CDE240300428F83001014600007C3
67654+:1063E000000010218F88002424050005910600007C
67655+:1063F00030C400FF108500030000000003E0000827
67656+:1064000000000000910A0018314900FF000939C25C
67657+:1064100014E0FFFA8F85001C3C04080094843D7C46
67658+:106420003C0308008C633D943C1908008F393D748F
67659+:106430003C0F080095EF3D920064C0218CAD0054E4
67660+:106440000319702101CF6021018D58231960001DAF
67661+:1064500000000000910E001C8F8C002C974B0E103A
67662+:1064600031CD00FF8D850004016D30238D88000043
67663+:1064700030CEFFFF000E510000AAC82100003821D5
67664+:1064800001072021032A182B0083C021AD990004A5
67665+:10649000AD980000918F000A01CF6821A18D000AFC
67666+:1064A0008F88002C974B0E12A50B0008950A003818
67667+:1064B00025490001A50900389107000D34E60008C0
67668+:1064C000A106000D03E000080000000027BDFFE06A
67669+:1064D000938700048F8F00248FAD00143C0E7FFF44
67670+:1064E0008F89000C35C8FFFFAFBF001CAFB000188C
67671+:1064F00001A8182491EA000D000717C03C1FBFFF38
67672+:10650000006258252D2E00018F90001837F9FFFFEB
67673+:106510003C1808008F183D943C0F080095EF3D8A09
67674+:1065200001796824000E47803C07EFFF3C05F0FF2F
67675+:1065300001A818253149002034E2FFFF34ACFFFFE9
67676+:106540000310582327A500102406000225EA0002A4
67677+:1065500000621824008080211520000200004021E4
67678+:106560008F480E1CA7AA0012056000372407000000
67679+:1065700030FF00FF001FCF008F8B001C00793825F3
67680+:10658000AFA70014916F00853C08080091083D9169
67681+:106590003C18DFFF31EE00C0370AFFFF000E182B5A
67682+:1065A0003C1F080097FF3D8400EA6824A3A800115F
67683+:1065B0000003174001A248258FB90010AFA90014AD
67684+:1065C0003C0A0800914A3D93A7BF00168FA800140B
67685+:1065D000032CC0243C0B01003C0F0FFF030B1825BC
67686+:1065E0003147000335EEFFFF010C68240007160059
67687+:1065F000006EF8243C09700001A2C82503E9582563
67688+:10660000AFB90014AFAB00100E000076A3A00015C8
67689+:106610008F8C0024260200089186000D30C40020D3
67690+:10662000108000068FBF001C3C05080094A53D802B
67691+:1066300024B0FFFF3C010800A4303D808FB000185B
67692+:1066400003E0000827BD00208F9800140118502B8C
67693+:106650005540FFC7240700010A000DB630FF00FFB8
67694+:106660009382000427BDFFE0AFBF00181040000F69
67695+:10667000008050218F880024240B00058F8900089A
67696+:10668000910700008F8400200100282130E3003FA3
67697+:106690008F86002C106B000800003821AFA9001075
67698+:1066A0000E00040EAFAA0014A38000048FBF0018D0
67699+:1066B00003E0000827BD00208D1900183C0F0800DA
67700+:1066C0008DEF3D748F9800103C027FFF8D08001401
67701+:1066D000345FFFFF033F682401F8702101AE60239F
67702+:1066E00001883821AFA900100E00040EAFAA0014D3
67703+:1066F0000A000E04A38000048F8700243C050800D4
67704+:1067000094A53D923C0208008C423D8C90E6000D21
67705+:106710000005240030C300201060002C00444025F8
67706+:106720008F85001C00006021240B000190A30085D0
67707+:1067300000004821240A00013C0F800035EE007063
67708+:106740008DC70000AF8700308F5801780700FFFE2B
67709+:106750003C038000347900708F3800003C0508004D
67710+:106760008CA500743C0D08008DAD007003077823E4
67711+:1067700000AF38210000102100EF302B01A22021B2
67712+:10678000008618213C010800AC2700743C01080079
67713+:10679000AC230070AF4B01483C1908008F393D9481
67714+:1067A000A7490144A74A0146AF59014C3C0B0800D8
67715+:1067B000916B3D91A34B0152AF4801543C0810002E
67716+:1067C000A74C015803E00008AF4801788F4B0E1C1E
67717+:1067D0003C0A08008D4A3D7497490E16974D0E14D9
67718+:1067E00001456021312AFFFF0A000E2731A9FFFF72
67719+:1067F0008F8300249064000D308200201040002917
67720+:10680000000000000000482100005021000040214D
67721+:106810003C07800034EB00708D670000AF870030CC
67722+:106820008F4C01780580FFFE3C0D800035AC007078
67723+:106830008D8B00003C0508008CA500743C0408000A
67724+:106840008C8400700167302300A67821000010219D
67725+:1068500001E6C82B0082C021031970213C01080009
67726+:10686000AC2F00743C010800AC2E0070AF49014809
67727+:106870003C0D08008DAD3D94A7480144240900401B
67728+:10688000A74A01463C081000240AFF91AF4D014C75
67729+:10689000A34A0152AF490154A740015803E0000840
67730+:1068A000AF4801788F490E1897460E1297450E1083
67731+:1068B00030CAFFFF0A000E5D30A8FFFF8F8300245F
67732+:1068C00027BDFFF89064000D308200201040003A90
67733+:1068D00000000000240B000100004821240A0001F0
67734+:1068E0003C088000350700708CE30000AF83003067
67735+:1068F0008F4C01780580FFFE3C0E80003C040800B0
67736+:1069000090843DD035C700708CEC00003C05080039
67737+:106910008CA50074A3A400033C1908008F390070F3
67738+:106920008FAD00000183302300A638210000102124
67739+:106930000322782100E6C02B01F8602101AE40253A
67740+:10694000AFA800003C010800AC2700743C0108001F
67741+:10695000AC2C00709346010A3C04080090843DD1A1
67742+:10696000A3A00002A3A600018FA300003C0580FFA6
67743+:106970003099007F34A2FFFF006278240019C6001E
67744+:1069800001F87025240D3000AF4E014C27BD0008E2
67745+:10699000AF4D0154A7400158AF4B0148A7490144EE
67746+:1069A000A74A01463C091000240AFF80A34A01526D
67747+:1069B00003E00008AF4901788F4B0E1897460E127E
67748+:1069C00097450E1030CAFFFF0A000E9130A9FFFF55
67749+:1069D0008F85001C2402008090A40085308300C0B5
67750+:1069E000106200058F8600208F8800088F87000CBA
67751+:1069F000ACC800C8ACC700C403E000080000000039
67752+:106A00003C0A0800254A39543C09080025293A2047
67753+:106A10003C08080025082DD43C07080024E73B3437
67754+:106A20003C06080024C637C43C05080024A5353CB4
67755+:106A30003C040800248431643C0308002463385C6F
67756+:106A40003C020800244236303C010800AC2A3D508C
67757+:106A50003C010800AC293D4C3C010800AC283D48F5
67758+:106A60003C010800AC273D543C010800AC263D64C5
67759+:106A70003C010800AC253D5C3C010800AC243D58BD
67760+:106A80003C010800AC233D683C010800AC223D609D
67761+:086A900003E000080000000013
67762+:00000001FF
67763diff --git a/firmware/bnx2/bnx2-mips-09-6.2.1b.fw.ihex b/firmware/bnx2/bnx2-mips-09-6.2.1b.fw.ihex
67764new file mode 100644
67765index 0000000..43d7c4f
67766--- /dev/null
67767+++ b/firmware/bnx2/bnx2-mips-09-6.2.1b.fw.ihex
67768@@ -0,0 +1,6496 @@
67769+:10000000080001180800000000005594000000C816
67770+:1000100000000000000000000000000008005594EF
67771+:10002000000000380000565C080000A00800000036
67772+:100030000000574400005694080059200000008436
67773+:100040000000ADD808005744000001C00000AE5CBD
67774+:100050000800321008000000000092580000B01C98
67775+:10006000000000000000000000000000080092589E
67776+:100070000000033C000142740800049008000400E2
67777+:10008000000012FC000145B000000000000000006C
67778+:1000900000000000080016FC00000004000158AC3D
67779+:1000A000080000A80800000000003D00000158B052
67780+:1000B00000000000000000000000000008003D00FB
67781+:1000C00000000030000195B00A000046000000006A
67782+:1000D000000000000000000D636F6D362E322E31DF
67783+:1000E00062000000060201020000000000000003A0
67784+:1000F000000000C800000032000000030000000003
67785+:1001000000000000000000000000000000000000EF
67786+:1001100000000010000001360000EA600000000549
67787+:1001200000000000000000000000000000000008C7
67788+:1001300000000000000000000000000000000000BF
67789+:1001400000000000000000000000000000000000AF
67790+:10015000000000000000000000000000000000009F
67791+:10016000000000020000000000000000000000008D
67792+:10017000000000000000000000000000000000007F
67793+:10018000000000000000000000000010000000005F
67794+:10019000000000000000000000000000000000005F
67795+:1001A000000000000000000000000000000000004F
67796+:1001B000000000000000000000000000000000003F
67797+:1001C000000000000000000000000000000000002F
67798+:1001D000000000000000000000000000000000001F
67799+:1001E0000000000010000003000000000000000DEF
67800+:1001F0000000000D3C020800244256083C030800A1
67801+:1002000024635754AC4000000043202B1480FFFDB2
67802+:10021000244200043C1D080037BD9FFC03A0F021D0
67803+:100220003C100800261001183C1C0800279C5608AA
67804+:100230000E000256000000000000000D27BDFFB4B4
67805+:10024000AFA10000AFA20004AFA30008AFA4000C50
67806+:10025000AFA50010AFA60014AFA70018AFA8001CF0
67807+:10026000AFA90020AFAA0024AFAB0028AFAC002C90
67808+:10027000AFAD0030AFAE0034AFAF0038AFB8003C28
67809+:10028000AFB90040AFBC0044AFBF00480E001544FA
67810+:10029000000000008FBF00488FBC00448FB90040B1
67811+:1002A0008FB8003C8FAF00388FAE00348FAD003078
67812+:1002B0008FAC002C8FAB00288FAA00248FA90020C0
67813+:1002C0008FA8001C8FA700188FA600148FA5001000
67814+:1002D0008FA4000C8FA300088FA200048FA1000040
67815+:1002E00027BD004C3C1B60108F7A5030377B502864
67816+:1002F00003400008AF7A00008F82002427BDFFE092
67817+:10030000AFB00010AFBF0018AFB100148C42000CAA
67818+:100310003C1080008E110100104000348FBF001887
67819+:100320000E000D84000000008F85002024047FFF54
67820+:100330000091202BACB100008E030104960201084D
67821+:1003400000031C003042FFFF00621825ACA300042C
67822+:100350009202010A96030114304200FF3063FFFF4E
67823+:100360000002140000431025ACA200089603010C03
67824+:100370009602010E00031C003042FFFF00621825A8
67825+:10038000ACA3000C960301109602011200031C009E
67826+:100390003042FFFF00621825ACA300108E02011846
67827+:1003A000ACA200148E02011CACA20018148000083C
67828+:1003B0008F820024978200003C0420050044182509
67829+:1003C00024420001ACA3001C0A0000C6A782000062
67830+:1003D0003C0340189442001E00431025ACA2001CB0
67831+:1003E0000E000DB8240400018FBF00188FB1001457
67832+:1003F0008FB000100000102103E0000827BD00208E
67833+:100400003C0780008CE202B834E50100044100089A
67834+:10041000240300013C0208008C42006024420001D9
67835+:100420003C010800AC22006003E0000800601021DD
67836+:100430003C0208008C42005C8CA4002094A30016AF
67837+:100440008CA6000494A5000E24420001ACE40280B6
67838+:100450002463FFFC3C010800AC22005C3C0210005D
67839+:10046000A4E30284A4E5028600001821ACE6028819
67840+:10047000ACE202B803E000080060102127BDFFE0F5
67841+:100480003C028000AFB0001034420100AFBF001C3E
67842+:10049000AFB20018AFB100148C43000094450008BF
67843+:1004A0002462FE002C42038110400003000381C23D
67844+:1004B0000A00010226100004240201001462000553
67845+:1004C0003C1180003C02800890420004305000FF44
67846+:1004D0003C11800036320100964300143202000FB6
67847+:1004E00000021500004310253C0308008C63004403
67848+:1004F00030A40004AE220080246300013C01080007
67849+:10050000AC2300441080000730A200028FBF001C03
67850+:100510008FB200188FB100148FB000100A0000CE07
67851+:1005200027BD00201040002D0000182130A20080BF
67852+:1005300010400005362200708E44001C0E000C672F
67853+:10054000240500A0362200708C4400008F82000C2D
67854+:10055000008210232C43012C10600004AF82001095
67855+:10056000240300010A000145AF84000C8E42000400
67856+:100570003C036020AF84000CAC6200143C02080015
67857+:100580008C42005850400015000018218C62000475
67858+:10059000240301FE304203FF144300100000182121
67859+:1005A0002E020004104000032E0200080A00014041
67860+:1005B0000000802114400003000000000A000140F8
67861+:1005C0002610FFF90000000D2402000202021004B0
67862+:1005D0003C036000AC626914000018218FBF001C4E
67863+:1005E0008FB200188FB100148FB00010006010217E
67864+:1005F00003E0000827BD00203C0480008C8301003C
67865+:1006000024020100506200033C0280080000000D3B
67866+:100610003C02800890430004000010213063000F6A
67867+:1006200000031D0003E00008AC8300800004188074
67868+:100630002782FF9C00621821000410C00044102390
67869+:100640008C640000000210C03C030800246356E4E0
67870+:10065000004310213C038000AC64009003E00008DC
67871+:10066000AF8200243C0208008C42011410400019A3
67872+:100670003084400030A2007F000231C03C02020002
67873+:100680001080001400A218253C026020AC43001426
67874+:100690003C0408008C8456B83C0308008C630110AD
67875+:1006A0003C02800024050900AC4500200086202182
67876+:1006B000246300013C028008AC4400643C01080053
67877+:1006C000AC2301103C010800AC2456B803E000083C
67878+:1006D000000000003C02602003E00008AC4500146C
67879+:1006E00003E000080000102103E0000800001021D2
67880+:1006F00030A2000810400008240201003C0208005B
67881+:100700008C42010C244200013C010800AC22010C87
67882+:1007100003E0000800000000148200080000000050
67883+:100720003C0208008C4200FC244200013C0108000D
67884+:10073000AC2200FC0A0001A330A200203C02080009
67885+:100740008C420084244200013C010800AC22008459
67886+:1007500030A200201040000830A200103C02080027
67887+:100760008C420108244200013C010800AC2201082F
67888+:1007700003E0000800000000104000080000000036
67889+:100780003C0208008C420104244200013C010800A4
67890+:10079000AC22010403E00008000000003C02080055
67891+:1007A0008C420100244200013C010800AC220100FF
67892+:1007B00003E000080000000027BDFFE0AFB1001417
67893+:1007C0003C118000AFB20018AFBF001CAFB00010EA
67894+:1007D0003632010096500008320200041040000733
67895+:1007E000320300028FBF001C8FB200188FB10014BB
67896+:1007F0008FB000100A0000CE27BD00201060000B53
67897+:10080000020028218E2401000E00018A0000000051
67898+:100810003202008010400003240500A10E000C6786
67899+:100820008E44001C0A0001E3240200018E2301040F
67900+:100830008F82000810430006020028218E24010048
67901+:100840000E00018A000000008E220104AF82000821
67902+:10085000000010218FBF001C8FB200188FB1001450
67903+:100860008FB0001003E0000827BD00202C82000498
67904+:1008700014400002000018212483FFFD240200021E
67905+:10088000006210043C03600003E00008AC626914DD
67906+:1008900027BDFFE0AFBF001CAFB20018AFB100141E
67907+:1008A000AFB000103C048000948201083043700017
67908+:1008B000240220001062000A2862200154400052E5
67909+:1008C0008FBF001C24024000106200482402600018
67910+:1008D0001062004A8FBF001C0A0002518FB200183C
67911+:1008E00034820100904300098C5000189451000C90
67912+:1008F000240200091062001C0000902128620009F7
67913+:10090000144000218F8200242402000A5062001249
67914+:10091000323100FF2402000B1062000F00000000C3
67915+:100920002402000C146200188F8200243C0208008C
67916+:100930008C4256B824030900AC83002000501021DB
67917+:100940003C038008AC6200643C010800AC2256B84D
67918+:100950000A0002508FBF001C0E0001E900102602A1
67919+:100960000A0002308F8200240E0001E900102602E6
67920+:100970003C0380089462001A8C72000C3042FFFF26
67921+:10098000020280258F8200248C42000C5040001E01
67922+:100990008FBF001C0E000D84000000003C02800090
67923+:1009A00034420100944300088F82002400031C009D
67924+:1009B0009444001E8F82002000641825AC50000073
67925+:1009C00024040001AC510004AC520008AC40000CFF
67926+:1009D000AC400010AC400014AC4000180E000DB844
67927+:1009E000AC43001C0A0002508FBF001C0E000440E4
67928+:1009F000000000000A0002508FBF001C0E000C9F78
67929+:100A0000000000008FBF001C8FB200188FB10014CF
67930+:100A10008FB000100000102103E0000827BD002067
67931+:100A200027BDFFD8AFB400203C036010AFBF002447
67932+:100A3000AFB3001CAFB20018AFB10014AFB00010DC
67933+:100A40008C6450002402FF7F3C1408002694563822
67934+:100A5000008220243484380CAC6450003C028000B6
67935+:100A6000240300370E0014B0AC4300083C07080014
67936+:100A700024E70618028010212404001D2484FFFFAF
67937+:100A8000AC4700000481FFFD244200043C02080042
67938+:100A9000244207C83C010800AC2256403C02080032
67939+:100AA000244202303C030800246306203C04080072
67940+:100AB000248403B43C05080024A506F03C06080085
67941+:100AC00024C62C9C3C010800AC2256803C02080045
67942+:100AD000244205303C010800AC2756843C01080044
67943+:100AE000AC2656943C010800AC23569C3C010800FF
67944+:100AF000AC2456A03C010800AC2556A43C010800DB
67945+:100B0000AC2256A83C010800AC23563C3C0108002E
67946+:100B1000AC2456443C010800AC2056603C0108005F
67947+:100B2000AC2556643C010800AC2056703C0108001E
67948+:100B3000AC27567C3C010800AC2656903C010800CE
67949+:100B4000AC2356980E00056E00000000AF80000C2C
67950+:100B50003C0280008C5300008F8300043C0208009C
67951+:100B60008C420020106200213262000700008821C0
67952+:100B70002792FF9C3C100800261056E43C02080017
67953+:100B80008C42002024050001022518040043202483
67954+:100B90008F820004004310245044000C26310001D1
67955+:100BA00010800008AF9000248E4300003C028000BB
67956+:100BB000AC4300900E000D4BAE05000C0A0002C1C4
67957+:100BC00026310001AE00000C263100012E22000269
67958+:100BD000261000381440FFE9265200043C020800A9
67959+:100BE0008C420020AF820004326200071040FFD91F
67960+:100BF0003C028000326200011040002D326200028F
67961+:100C00003C0580008CA2010000002021ACA2002045
67962+:100C10008CA301042C42078110400008ACA300A85B
67963+:100C200094A2010824032000304270001443000302
67964+:100C30003C02800890420005304400FF0E0001593C
67965+:100C4000000000003C0280009042010B304300FF96
67966+:100C50002C62001E54400004000310800E00018628
67967+:100C60000A0002EC00000000005410218C42000039
67968+:100C70000040F80900000000104000043C02800021
67969+:100C80008C4301043C026020AC4300143C02080089
67970+:100C90008C4200343C0440003C03800024420001AC
67971+:100CA000AC6401383C010800AC220034326200021E
67972+:100CB00010400010326200043C1080008E0201409F
67973+:100CC000000020210E000159AE0200200E00038317
67974+:100CD000000000003C024000AE0201783C02080027
67975+:100CE0008C420038244200013C010800AC2200384C
67976+:100CF000326200041040FF973C0280003C108000EC
67977+:100D00008E020180000020210E000159AE02002059
67978+:100D10008E03018024020F00546200073C02800809
67979+:100D20008E0201883C0300E03042FFFF00431025A3
67980+:100D30000A000328AE020080344200809042000086
67981+:100D400024030050304200FF14430007000000005D
67982+:100D50000E000362000000001440000300000000C9
67983+:100D60000E000971000000003C0208008C42003CAB
67984+:100D70003C0440003C03800024420001AC6401B804
67985+:100D80003C010800AC22003C0A0002A33C028000A7
67986+:100D90003C02900034420001008220253C02800089
67987+:100DA000AC4400203C0380008C6200200440FFFE25
67988+:100DB0000000000003E00008000000003C0280008A
67989+:100DC000344300010083202503E00008AC440020E8
67990+:100DD00027BDFFE0AFB10014AFB000100080882144
67991+:100DE000AFBF00180E00033230B000FF8F83FF94B6
67992+:100DF000022020219062002502028025A07000259B
67993+:100E00008C7000183C0280000E00033D020280241A
67994+:100E10001600000B8FBF00183C0480008C8201F884
67995+:100E20000440FFFE348201C024030002AC510000E4
67996+:100E3000A04300043C021000AC8201F88FBF0018F0
67997+:100E40008FB100148FB0001003E0000827BD002010
67998+:100E500027BDFFE83C028000AFBF00103442018094
67999+:100E6000944300048C4400083063020010600005C5
68000+:100E7000000028210E00100C000000000A0003787A
68001+:100E8000240500013C02FF000480000700821824B2
68002+:100E90003C02040014620004240500018F82FF94C8
68003+:100EA00090420008240500018FBF001000A010210F
68004+:100EB00003E0000827BD00188F82FF982405000179
68005+:100EC000A040001A3C028000344201400A00034264
68006+:100ED0008C4400008F85FF9427BDFFE0AFBF001C4E
68007+:100EE000AFB20018AFB10014AFB0001090A2000074
68008+:100EF000304400FF38830020388200300003182B74
68009+:100F00000002102B0062182410600003240200501D
68010+:100F1000148200A88FBF001C90A20005304200017F
68011+:100F2000104000A48FBF001C3C02800034420140EE
68012+:100F3000904200082443FFFF2C6200051040009EF1
68013+:100F40008FB20018000310803C030800246355ACE6
68014+:100F5000004310218C420000004000080000000007
68015+:100F60003C028000345101400E0003328E24000008
68016+:100F70008F92FF948E2200048E50000C1602000205
68017+:100F800024020001AE42000C0E00033D8E2400003E
68018+:100F90008E220004145000068FBF001C8FB2001870
68019+:100FA0008FB100148FB000100A000F7827BD002009
68020+:100FB0008E42000C0A000419000000003C0480006E
68021+:100FC0003482014094A300108C4200043063FFFF80
68022+:100FD0001443001C0000000024020001A4A2001021
68023+:100FE0008C8202380441000F3C0380003C02003F29
68024+:100FF0003448F0003C0760003C06FFC08CE22BBC8C
68025+:1010000000461824004810240002130200031D8229
68026+:10101000106200583C0280008C8202380440FFF7C6
68027+:101020003C038000346201408C44000034620200C2
68028+:10103000AC4400003C021000AC6202380A00043BE1
68029+:101040008FBF001C94A200100A00041900000000C9
68030+:10105000240200201482000F3C0280003C03800028
68031+:1010600094A20012346301408C6300043042FFFFFD
68032+:10107000146200050000000024020001A4A2001276
68033+:101080000A0004028FBF001C94A200120A00041977
68034+:1010900000000000345101400E0003328E24000095
68035+:1010A0008F92FF948E230004964200123050FFFF6F
68036+:1010B0001603000224020001A64200120E00033DA6
68037+:1010C0008E2400008E220004160200068FBF001C32
68038+:1010D0008FB200188FB100148FB000100A00037C8B
68039+:1010E00027BD0020964200120A00041900000000EB
68040+:1010F0003C03800094A20014346301408C6300041C
68041+:101100003042FFFF14620008240200018FBF001C60
68042+:101110008FB200188FB100148FB00010A4A2001479
68043+:101120000A00146327BD002094A20014144000217B
68044+:101130008FBF001C0A000435000000003C03800043
68045+:1011400094A20016346301408C6300043042FFFF18
68046+:101150001462000D240200018FBF001C8FB2001822
68047+:101160008FB100148FB00010A4A200160A000B1457
68048+:1011700027BD00209442007824420004A4A200105D
68049+:101180000A00043B8FBF001C94A200162403000138
68050+:101190003042FFFF144300078FBF001C3C020800D1
68051+:1011A0008C420070244200013C010800AC22007017
68052+:1011B0008FBF001C8FB200188FB100148FB00010C9
68053+:1011C00003E0000827BD002027BDFFD8AFB20018FC
68054+:1011D0008F92FF94AFB10014AFBF0020AFB3001CDB
68055+:1011E000AFB000103C028000345101008C5001006F
68056+:1011F0009242000092230009304400FF2402001FA5
68057+:10120000106200AB28620020104000192402003850
68058+:101210002862000A1040000D2402000B286200081A
68059+:101220001040002E8F820024046001042862000216
68060+:101230001440002A8F820024240200061062002637
68061+:101240008FBF00200A00055F8FB3001C1062006092
68062+:101250002862000B144000FA8FBF00202402000E09
68063+:10126000106200788F8200240A00055F8FB3001C93
68064+:10127000106200D2286200391040000A2402008067
68065+:1012800024020036106200E528620037104000C3D7
68066+:1012900024020035106200D98FBF00200A00055FCC
68067+:1012A0008FB3001C1062002D2862008110400006E0
68068+:1012B000240200C824020039106200C98FBF002038
68069+:1012C0000A00055F8FB3001C106200A28FBF0020D0
68070+:1012D0000A00055F8FB3001C8F8200248C42000C33
68071+:1012E000104000D78FBF00200E000D8400000000CA
68072+:1012F0003C038000346301008C6200008F85002075
68073+:10130000946700089466000CACA200008C64000492
68074+:101310008F82002400063400ACA400049448001E10
68075+:101320008C62001800073C0000E83825ACA20008D9
68076+:101330008C62001C24040001ACA2000C9062000A24
68077+:1013400000C23025ACA60010ACA00014ACA0001860
68078+:10135000ACA7001C0A00051D8FBF00208F8200244F
68079+:101360008C42000C104000B68FBF00200E000D8490
68080+:10137000000000008F820024962400089625000CAF
68081+:101380009443001E000422029626000E8F82002045
68082+:10139000000426000083202500052C003C0300806B
68083+:1013A00000A6282500832025AC400000AC400004A6
68084+:1013B000AC400008AC40000CAC450010AC40001440
68085+:1013C000AC400018AC44001C0A00051C24040001B9
68086+:1013D0009622000C14400018000000009242000504
68087+:1013E0003042001014400014000000000E000332D0
68088+:1013F0000200202192420005020020213442001008
68089+:101400000E00033DA242000592420000240300208A
68090+:10141000304200FF10430089020020218FBF0020CE
68091+:101420008FB3001C8FB200188FB100148FB0001062
68092+:101430000A00107527BD00280000000D0A00055E97
68093+:101440008FBF00208C42000C1040007D8FBF002019
68094+:101450000E000D84000000008E2200048F84002006
68095+:101460009623000CAC8200003C0280089445002CBE
68096+:101470008F82002400031C0030A5FFFF9446001E4D
68097+:101480003C02400E0065182500C23025AC830004E4
68098+:10149000AC800008AC80000CAC800010AC80001464
68099+:1014A000AC800018AC86001C0A00051C2404000156
68100+:1014B0000E000332020020218F93FF9802002021AA
68101+:1014C0000E00033DA660000C020020210E00034226
68102+:1014D000240500018F8200248C42000C104000582B
68103+:1014E0008FBF00200E000D84000000009622000C2B
68104+:1014F0008F83002000021400AC700000AC62000476
68105+:10150000AC6000088E4400388F820024AC64000C6C
68106+:101510008E46003C9445001E3C02401FAC66001005
68107+:1015200000A228258E62000424040001AC6200148D
68108+:10153000AC600018AC65001C8FBF00208FB3001C8E
68109+:101540008FB200188FB100148FB000100A000DB8D0
68110+:1015500027BD0028240200201082003A8FB3001C0F
68111+:101560000E000F5E00000000104000358FBF00200D
68112+:101570003C0480008C8201F80440FFFE348201C0EC
68113+:1015800024030002AC500000A04300043C02100001
68114+:10159000AC8201F80A00055E8FBF00200200202106
68115+:1015A0008FBF00208FB3001C8FB200188FB10014C2
68116+:1015B0008FB000100A000EA727BD00289625000C4A
68117+:1015C000020020218FBF00208FB3001C8FB20018B3
68118+:1015D0008FB100148FB000100A000ECC27BD002878
68119+:1015E000020020218FB3001C8FB200188FB10014AD
68120+:1015F0008FB000100A000EF727BD00289225000DBD
68121+:10160000020020218FB3001C8FB200188FB100148C
68122+:101610008FB000100A000F4827BD002802002021CB
68123+:101620008FBF00208FB3001C8FB200188FB1001441
68124+:101630008FB000100A000F1F27BD00288FBF0020A9
68125+:101640008FB3001C8FB200188FB100148FB0001040
68126+:1016500003E0000827BD00283C0580008CA202782A
68127+:101660000440FFFE34A2024024030002AC44000008
68128+:10167000A04300043C02100003E00008ACA2027882
68129+:10168000A380001803E00008A38000193C03800039
68130+:101690008C6202780440FFFE8F82001CAC62024024
68131+:1016A00024020002A06202443C02100003E0000891
68132+:1016B000AC6202783C02600003E000088C425404F3
68133+:1016C0009083003024020005008040213063003FF9
68134+:1016D0000000482114620005000050219082004C57
68135+:1016E0009483004E304900FF306AFFFFAD00000CCC
68136+:1016F000AD000010AD000024950200148D05001C03
68137+:101700008D0400183042FFFF004910230002110031
68138+:10171000000237C3004038210086202300A2102B8E
68139+:101720000082202300A72823AD05001CAD0400186B
68140+:10173000A5090014A5090020A50A001603E0000869
68141+:10174000A50A002203E000080000000027BDFFD822
68142+:10175000AFB200183C128008AFB40020AFB3001C39
68143+:10176000AFB10014AFBF0024AFB00010365101007C
68144+:101770003C0260008C4254049222000C3C1408008D
68145+:10178000929400F7304300FF2402000110620032FF
68146+:101790000080982124020002146200353650008037
68147+:1017A0000E00143D000000009202004C2403FF8054
68148+:1017B0003C0480003042007F000211C024420240FD
68149+:1017C0000262102100431824AC8300949245000863
68150+:1017D0009204004C3042007F3C03800614850007D1
68151+:1017E000004380212402FFFFA22200112402FFFFF8
68152+:1017F000A62200120A0005D22402FFFF9602002052
68153+:10180000A222001196020022A62200128E020024BB
68154+:101810003C048008AE2200143485008090A2004C65
68155+:1018200034830100A06200108CA2003CAC6200185E
68156+:101830008C820068AC6200F48C820064AC6200F0C0
68157+:101840008C82006CAC6200F824020001A0A2006847
68158+:101850000A0005EE3C0480080E001456000000004B
68159+:1018600036420080A04000680A0005EE3C04800873
68160+:10187000A2000068A20000690A0006293C02800854
68161+:10188000348300808C62003834850100AC62006CC7
68162+:1018900024020001A062006990A200D59083000894
68163+:1018A000305100FF3072007F12320019001111C058
68164+:1018B00024420240026210212403FF8000431824C6
68165+:1018C0003C048000AC8300943042007F3C038006DF
68166+:1018D000004380218E02000C1040000D02002021E8
68167+:1018E0000E00057E0000000026220001305100FF9E
68168+:1018F0009203003C023410260002102B0002102339
68169+:101900003063007F022288240A0005F8A203003C0D
68170+:101910003C088008350401008C8200E03507008017
68171+:10192000ACE2003C8C8200E0AD02000090E5004C8F
68172+:10193000908600D590E3004C908400D52402FF806F
68173+:1019400000A228243063007F308400FF00A62825F1
68174+:101950000064182A1060000230A500FF38A500803E
68175+:10196000A0E5004CA10500093C0280089043000E50
68176+:10197000344400803C058000A043000A8C8300189A
68177+:101980003C027FFF3442FFFF00621824AC83001842
68178+:101990008CA201F80440FFFE00000000ACB301C0BF
68179+:1019A0008FBF00248FB400208FB3001C8FB20018AB
68180+:1019B0008FB100148FB0001024020002A0A201C455
68181+:1019C00027BD00283C02100003E00008ACA201F88B
68182+:1019D00090A2000024420001A0A200003C030800E5
68183+:1019E0008C6300F4304200FF144300020080302179
68184+:1019F000A0A0000090A200008F84001C000211C073
68185+:101A00002442024024830040008220212402FF80DF
68186+:101A1000008220243063007F3C02800A006218218B
68187+:101A20003C028000AC44002403E00008ACC300008A
68188+:101A300094820006908300058C85000C8C86001033
68189+:101A40008C8700188C88001C8C8400203C010800C6
68190+:101A5000A42256C63C010800A02356C53C0108003C
68191+:101A6000AC2556CC3C010800AC2656D03C01080001
68192+:101A7000AC2756D83C010800AC2856DC3C010800D5
68193+:101A8000AC2456E003E00008000000003C0280089F
68194+:101A9000344201008C4400343C038000346504006F
68195+:101AA000AC6400388C420038AF850028AC62003C42
68196+:101AB0003C020005AC6200300000000000000000A5
68197+:101AC00003E00008000000003C020006308400FF34
68198+:101AD000008220253C028000AC4400300000000061
68199+:101AE00000000000000000003C0380008C62000049
68200+:101AF000304200101040FFFD3462040003E0000893
68201+:101B0000AF82002894C200003C080800950800CA73
68202+:101B100030E7FFFF0080482101021021A4C200002D
68203+:101B200094C200003042FFFF00E2102B544000013D
68204+:101B3000A4C7000094A200003C0308008C6300CC02
68205+:101B400024420001A4A2000094A200003042FFFF42
68206+:101B5000144300073C0280080107102BA4A00000DA
68207+:101B60005440000101003821A4C700003C02800855
68208+:101B7000344601008CC3002894A200003C0480007D
68209+:101B80003042FFFE000210C000621021AC82003C17
68210+:101B90008C82003C006218231860000400000000E2
68211+:101BA0008CC200240A0006BA244200018CC2002420
68212+:101BB000AC8200383C020050344200103C038000EC
68213+:101BC000AC620030000000000000000000000000D7
68214+:101BD0008C620000304200201040FFFD0000000039
68215+:101BE00094A200003C04800030420001000210C0BA
68216+:101BF000004410218C430400AD2300008C420404F7
68217+:101C0000AD2200043C02002003E00008AC8200305A
68218+:101C100027BDFFE0AFB20018AFB10014AFB00010A5
68219+:101C2000AFBF001C94C2000000C080213C1208001D
68220+:101C3000965200C624420001A6020000960300004E
68221+:101C400094E2000000E03021144300058FB1003021
68222+:101C50000E00068F024038210A0006F10000000045
68223+:101C60008C8300048C82000424420040046100073D
68224+:101C7000AC8200048C8200040440000400000000D8
68225+:101C80008C82000024420001AC8200009602000019
68226+:101C90003042FFFF50520001A600000096220000D3
68227+:101CA00024420001A62200003C02800834420100C8
68228+:101CB000962300009442003C144300048FBF001C94
68229+:101CC00024020001A62200008FBF001C8FB2001862
68230+:101CD0008FB100148FB0001003E0000827BD002072
68231+:101CE00027BDFFE03C028008AFBF0018344201006E
68232+:101CF0008C4800343C03800034690400AC68003830
68233+:101D00008C42003830E700FFAF890028AC62003C0D
68234+:101D10003C020005AC620030000000000000000042
68235+:101D200000000000000000000000000000000000B3
68236+:101D30008C82000C8C82000C97830016AD22000070
68237+:101D40008C82001000604021AD2200048C820018BB
68238+:101D5000AD2200088C82001CAD22000C8CA2001465
68239+:101D6000AD2200108C820020AD220014908200056C
68240+:101D7000304200FF00021200AD2200188CA20018B1
68241+:101D8000AD22001C8CA2000CAD2200208CA2001001
68242+:101D9000AD2200248CA2001CAD2200288CA20020C1
68243+:101DA000AD22002C3402FFFFAD260030AD20003400
68244+:101DB000506200013408FFFFAD28003850E00011E8
68245+:101DC0003C0280083C048008348401009482005066
68246+:101DD0003042FFFFAD22003C9483004494850044D0
68247+:101DE000240200013063FFFF000318C200641821C1
68248+:101DF0009064006430A5000700A210040A00075C8C
68249+:101E00000044102534420100AD20003C94430044BE
68250+:101E1000944400443063FFFF000318C2006218219D
68251+:101E200030840007906500642402000100821004E1
68252+:101E30000002102700451024A0620064000000008A
68253+:101E400000000000000000003C0200063442004098
68254+:101E50003C038000AC620030000000000000000085
68255+:101E6000000000008C620000304200101040FFFDB6
68256+:101E70003C06800834C201503463040034C7014A70
68257+:101E800034C4013434C5014034C60144AFA200104B
68258+:101E90000E0006D2AF8300288FBF001803E00008B1
68259+:101EA00027BD00208F8300143C0608008CC600E884
68260+:101EB0008F82001C30633FFF000319800046102111
68261+:101EC000004310212403FF80004318243C068000B7
68262+:101ED000ACC300283042007F3C03800C004330211B
68263+:101EE00090C2000D30A500FF0000382134420010E0
68264+:101EF000A0C2000D8F8900143C028008344201000A
68265+:101F00009443004400091382304800032402000176
68266+:101F1000A4C3000E1102000B2902000210400005AC
68267+:101F2000240200021100000C240300010A0007A48F
68268+:101F30000000182111020006000000000A0007A49A
68269+:101F4000000018218CC2002C0A0007A424430001C1
68270+:101F50008CC20014244300018CC200180043102BD3
68271+:101F60005040000A240700012402002714A20003A5
68272+:101F70003C0380080A0007B1240700013463010014
68273+:101F80009462004C24420001A462004C00091382B8
68274+:101F9000304300032C620002104000090080282119
68275+:101FA000146000040000000094C200340A0007C15D
68276+:101FB0003046FFFF8CC600380A0007C10080282188
68277+:101FC000000030213C040800248456C00A000706A3
68278+:101FD0000000000027BDFF90AFB60068AFB50064F9
68279+:101FE000AFB40060AFB3005CAFB20058AFB1005403
68280+:101FF000AFBF006CAFB000508C9000000080B021EB
68281+:102000003C0208008C4200E8960400328F83001CDA
68282+:102010002414FF8030843FFF0062182100042180D7
68283+:1020200000641821007410243C13800000A090214B
68284+:1020300090A50000AE620028920400323C02800CA1
68285+:102040003063007F00628821308400C02402004099
68286+:10205000148200320000A8218E3500388E2200182C
68287+:102060001440000224020001AE2200189202003C3B
68288+:10207000304200201440000E8F83001C000511C068
68289+:102080002442024000621821306400783C02008043
68290+:102090000082202500741824AE630800AE64081086
68291+:1020A0008E2200188E03000800431021AE22001873
68292+:1020B0008E22002C8E230018244200010062182B6F
68293+:1020C0001060004300000000924200002442000122
68294+:1020D000A24200003C0308008C6300F4304200FF81
68295+:1020E00050430001A2400000924200008F84001C77
68296+:1020F000000211C024420240248300403063007F6C
68297+:10210000008220213C02800A0094202400621821D1
68298+:10211000AE6400240A0008D2AEC30000920300326D
68299+:102120002402FFC000431024304200FF1440000589
68300+:1021300024020001AE220018962200340A00084250
68301+:102140003055FFFF8E22001424420001AE220018F9
68302+:102150009202003000021600000216030441001C27
68303+:10216000000000009602003227A400100080282101
68304+:10217000A7A20016960200320000302124070001B9
68305+:102180003042FFFFAF8200140E000706AFA0001C14
68306+:10219000960200328F83001C3C0408008C8400E807
68307+:1021A00030423FFF000211800064182100621821B4
68308+:1021B00000741024AE62002C3063007F3C02800E5D
68309+:1021C000006218219062000D3042007FA062000D75
68310+:1021D0009222000D304200105040007892420000E0
68311+:1021E0003C028008344401009482004C8EC30000FD
68312+:1021F0003C130800967300C62442FFFFA482004CE3
68313+:10220000946200329623000E3054FFFF3070FFFFBF
68314+:102210003C0308008C6300D000701807A7A30038A7
68315+:102220009482003E3063FFFF3042FFFF14620007DC
68316+:10223000000000008C8200303C038000244200300B
68317+:10224000AC62003C0A00086A8C82002C9482004038
68318+:102250003042FFFF5462000927A400408C820038FE
68319+:102260003C03800024420030AC62003C8C8200348D
68320+:10227000AC6200380A0008793C03800027A50038CA
68321+:1022800027A60048026038210E00068FA7A000484C
68322+:102290008FA300403C02800024630030AC43003830
68323+:1022A0008FA30044AC43003C3C0380003C0200058B
68324+:1022B000AC6200303C028008344401009482004249
68325+:1022C000346304003042FFFF0202102B1440000769
68326+:1022D000AF8300289482004E9483004202021021B2
68327+:1022E000004310230A00088F3043FFFF9483004E01
68328+:1022F00094820042026318210050102300621823C8
68329+:102300003063FFFF3C028008344401009482003CAB
68330+:102310003042FFFF14430003000000000A00089F42
68331+:10232000240300019482003C3042FFFF0062102B26
68332+:10233000144000058F8200289482003C0062102324
68333+:102340003043FFFF8F820028AC550000AC400004F2
68334+:10235000AC540008AC43000C3C02000634420010B0
68335+:102360003C038000AC620030000000000000000070
68336+:10237000000000008C620000304200101040FFFDA1
68337+:102380003C04800834840100001018C20064182145
68338+:102390009065006432020007240600010046100424
68339+:1023A00000451025A0620064948300429622000E2E
68340+:1023B00050430001A386001892420000244200010D
68341+:1023C000A24200003C0308008C6300F4304200FF8E
68342+:1023D00050430001A2400000924200008F84001C84
68343+:1023E000000211C0244202402483004000822021C8
68344+:1023F0002402FF80008220243063007F3C02800A98
68345+:10240000006218213C028000AC440024AEC30000EE
68346+:102410008FBF006C8FB600688FB500648FB400600A
68347+:102420008FB3005C8FB200588FB100548FB0005052
68348+:1024300003E0000827BD007027BDFFD8AFB3001C24
68349+:10244000AFB20018AFB10014AFB00010AFBF0020A2
68350+:102450000080982100E0802130B1FFFF0E000D8444
68351+:1024600030D200FF0000000000000000000000006B
68352+:102470008F8200208F830024AC510000AC520004F6
68353+:10248000AC530008AC40000CAC400010AC40001451
68354+:10249000AC4000189463001E02038025AC50001C61
68355+:1024A0000000000000000000000000002404000103
68356+:1024B0008FBF00208FB3001C8FB200188FB10014A3
68357+:1024C0008FB000100A000DB827BD002830A5FFFF0F
68358+:1024D0000A0008DC30C600FF3C02800834430100DB
68359+:1024E0009462000E3C080800950800C63046FFFFC5
68360+:1024F00014C000043402FFFF946500EA0A000929B1
68361+:102500008F84001C10C20027000000009462004E5F
68362+:102510009464003C3045FFFF00A6102300A6182B52
68363+:102520003087FFFF106000043044FFFF00C5102318
68364+:1025300000E210233044FFFF0088102B1040000EF3
68365+:1025400000E810233C028008344401002403000109
68366+:1025500034420080A44300162402FFFFA482000E30
68367+:10256000948500EA8F84001C0000302130A5FFFF15
68368+:102570000A0009013C0760200044102A10400009AD
68369+:102580003C0280083443008094620016304200010F
68370+:10259000104000043C0280009442007E244200145B
68371+:1025A000A462001603E000080000000027BDFFE061
68372+:1025B0003C028008AFBF001CAFB0001834420100DD
68373+:1025C000944300429442004C104000193068FFFFD1
68374+:1025D0009383001824020001146200298FBF001C9D
68375+:1025E0003C06800834D00100000810C200501021C1
68376+:1025F000904200643103000734C70148304200FFB5
68377+:10260000006210073042000134C9014E34C4012C6D
68378+:1026100034C5013E1040001634C601420E0006D2F9
68379+:10262000AFA90010960200420A0009463048FFFF99
68380+:102630003C028008344401009483004494820042A8
68381+:102640001043000F8FBF001C94820044A4820042FC
68382+:1026500094820050A482004E8C820038AC820030FC
68383+:1026600094820040A482003E9482004AA4820048E2
68384+:102670008FBF001C8FB000180A00090427BD00207E
68385+:102680008FB0001803E0000827BD002027BDFFA081
68386+:10269000AFB1004C3C118000AFBF0058AFB3005445
68387+:1026A000AFB20050AFB000483626018890C2000398
68388+:1026B0003044007FA3A400108E32018090C200003D
68389+:1026C0003043007F240200031062003BAF92001CE5
68390+:1026D00028620004104000062402000424020002C4
68391+:1026E000106200098FBF00580A000B0F8FB300540F
68392+:1026F0001062004D240200051062014E8FBF005889
68393+:102700000A000B0F8FB30054000411C002421021C5
68394+:102710002404FF8024420240004410242643004049
68395+:10272000AE2200243063007F3C02800A0062182140
68396+:102730009062003CAFA3003C00441025A062003C26
68397+:102740008FA3003C9062003C304200401040016C7E
68398+:102750008FBF00583C108008A3800018361001007D
68399+:102760008E0200E08C63003427A4003C27A50010F3
68400+:10277000004310210E0007C3AE0200E093A2001038
68401+:102780003C038000A20200D58C6202780440FFFE68
68402+:102790008F82001CAC62024024020002A06202444C
68403+:1027A0003C021000AC6202780E0009390000000003
68404+:1027B0000A000B0E8FBF00583C05800890C3000133
68405+:1027C00090A2000B1443014E8FBF005834A4008028
68406+:1027D0008C8200189082004C90A200083C0260009D
68407+:1027E0008C4254048C8300183C027FFF3442FFFF6C
68408+:1027F000006218243C0208008C4200B4AC8300182C
68409+:102800003C038000244200013C010800AC2200B4DB
68410+:102810008C6201F80440FFFE8F82001CAC6201C094
68411+:102820000A000AD6240200023C10800890C300016E
68412+:102830009202000B144301328FBF005827A40018E6
68413+:1028400036050110240600033C0260008C4254044B
68414+:102850000E000E470000000027A40028360501F0F6
68415+:102860000E000E47240600038FA200283603010045
68416+:10287000AE0200648FA2002CAE0200688FA200306E
68417+:10288000AE02006C93A40018906300D52402FF8070
68418+:102890000082102400431025304900FF3084007F5F
68419+:1028A0003122007F0082102A544000013929008023
68420+:1028B000000411C0244202402403FF800242102180
68421+:1028C00000431024AE220094264200403042007F94
68422+:1028D0003C038006004340218FA3001C2402FFFF1D
68423+:1028E000AFA800403C130800927300F71062003359
68424+:1028F00093A2001995030014304400FF3063FFFFDA
68425+:102900000064182B106000100000000095040014F3
68426+:102910008D07001C8D0600183084FFFF0044202323
68427+:102920000004210000E438210000102100E4202BE5
68428+:1029300000C2302100C43021AD07001CAD060018D4
68429+:102940000A000A2F93A20019950400148D07001C99
68430+:102950008D0600183084FFFF008220230004210030
68431+:10296000000010210080182100C2302300E4202B39
68432+:1029700000C4302300E33823AD07001CAD06001867
68433+:1029800093A200198FA30040A462001497A2001A1A
68434+:10299000A46200168FA2001CAC6200108FA2001C63
68435+:1029A000AC62000C93A20019A462002097A2001A46
68436+:1029B000A46200228FA2001CAC6200243C048008A8
68437+:1029C000348300808C6200388FA20020012088218F
68438+:1029D000AC62003C8FA20020AC82000093A20018E1
68439+:1029E000A062004C93A20018A0820009A0600068B9
68440+:1029F00093A20018105100512407FF803229007F54
68441+:102A0000000911C024420240024210213046007FDA
68442+:102A10003C03800000471024AC6200943C02800616
68443+:102A200000C2302190C2003CAFA60040000020212F
68444+:102A300000471025A0C2003C8FA80040950200026C
68445+:102A4000950300148D07001C3042FFFF3063FFFF29
68446+:102A50008D060018004310230002110000E2382107
68447+:102A600000E2102B00C4302100C23021AD07001C51
68448+:102A7000AD06001895020002A5020014A50000167C
68449+:102A80008D020008AD0200108D020008AD02000C9E
68450+:102A900095020002A5020020A50000228D02000878
68451+:102AA000AD0200249102003C304200401040001A68
68452+:102AB000262200013C108008A3A90038A38000183A
68453+:102AC000361001008E0200E08D03003427A4004080
68454+:102AD00027A50038004310210E0007C3AE0200E016
68455+:102AE00093A200383C038000A20200D58C620278D9
68456+:102AF0000440FFFE8F82001CAC62024024020002F0
68457+:102B0000A06202443C021000AC6202780E00093957
68458+:102B100000000000262200013043007F14730004EF
68459+:102B2000004020212403FF8002231024004320269C
68460+:102B300093A200180A000A4B309100FF93A40018DA
68461+:102B40008FA3001C2402FFFF1062000A308900FFDF
68462+:102B500024820001248300013042007F14530005C9
68463+:102B6000306900FF2403FF800083102400431026F7
68464+:102B7000304900FF3C028008904200080120882173
68465+:102B8000305000FF123000193222007F000211C0C5
68466+:102B900002421021244202402403FF8000431824F3
68467+:102BA0003C048000AC8300943042007F3C038006EC
68468+:102BB000004310218C43000C004020211060000BCA
68469+:102BC000AFA200400E00057E000000002623000199
68470+:102BD0002405FF803062007F145300020225202468
68471+:102BE000008518260A000AAF307100FF3C048008F7
68472+:102BF000348400808C8300183C027FFF3442FFFF46
68473+:102C000000621824AC8300183C0380008C6201F839
68474+:102C10000440FFFE00000000AC7201C0240200026C
68475+:102C2000A06201C43C021000AC6201F80A000B0E65
68476+:102C30008FBF00583C04800890C300019082000BB5
68477+:102C40001443002F8FBF0058349000809202000878
68478+:102C500030420040104000200000000092020008B6
68479+:102C60000002160000021603044100050240202164
68480+:102C70000E000ECC240500930A000B0E8FBF0058E7
68481+:102C80009202000924030018304200FF1443000D93
68482+:102C900002402021240500390E000E64000030217E
68483+:102CA0000E0003328F84001C8F82FF9424030012D5
68484+:102CB000A04300090E00033D8F84001C0A000B0E88
68485+:102CC0008FBF0058240500360E000E64000030212E
68486+:102CD0000A000B0E8FBF00580E0003320240202165
68487+:102CE000920200058F84001C344200200E00033D38
68488+:102CF000A20200050E0010758F84001C8FBF0058C3
68489+:102D00008FB300548FB200508FB1004C8FB0004889
68490+:102D100003E0000827BD00603C0280083445010044
68491+:102D20003C0280008C42014094A3000E0000302140
68492+:102D300000402021AF82001C3063FFFF3402FFFF00
68493+:102D4000106200063C0760202402FFFFA4A2000ED0
68494+:102D500094A500EA0A00090130A5FFFF03E000087E
68495+:102D60000000000027BDFFC83C0280003C06800830
68496+:102D7000AFB5002CAFB1001CAFBF0030AFB400281E
68497+:102D8000AFB30024AFB20020AFB00018345101003F
68498+:102D900034C501008C4301008E2200148CA400E491
68499+:102DA0000000A821AF83001C0044102318400052EB
68500+:102DB000A38000188E22001400005021ACA200E471
68501+:102DC00090C3000890A200D53073007FA3A200102A
68502+:102DD0008CB200E08CB400E4304200FF1053003BA2
68503+:102DE00093A200108F83001C2407FF80000211C0F3
68504+:102DF0000062102124420240246300400047102456
68505+:102E00003063007F3C0980003C08800A006818217C
68506+:102E1000AD2200248C62003427A4001427A50010E2
68507+:102E2000024280210290102304400028AFA3001426
68508+:102E30009062003C00E21024304200FF1440001970
68509+:102E4000020090219062003C34420040A062003CAD
68510+:102E50008F86001C93A3001024C200403042007FE4
68511+:102E6000004828213C0208008C4200F42463000141
68512+:102E7000306400FF14820002A3A30010A3A000107E
68513+:102E800093A20010AFA50014000211C0244202401A
68514+:102E900000C2102100471024AD2200240A000B4577
68515+:102EA00093A200100E0007C3000000003C0280083F
68516+:102EB00034420100AC5000E093A30010240A00014A
68517+:102EC000A04300D50A000B4593A200102402000184
68518+:102ED000154200093C0380008C6202780440FFFE2A
68519+:102EE0008F82001CAC62024024020002A0620244F5
68520+:102EF0003C021000AC6202789222000B2403000214
68521+:102F0000304200FF144300720000000096220008C7
68522+:102F1000304300FF24020082146200402402008437
68523+:102F20003C028000344901008D22000C95230006EC
68524+:102F3000000216023063FFFF3045003F24020027E5
68525+:102F400010A2000FAF83001428A200281040000830
68526+:102F5000240200312402002110A2000924020025CD
68527+:102F600010A20007938200190A000BBD00000000A8
68528+:102F700010A20007938200190A000BBD0000000098
68529+:102F80000E000777012020210A000C3D0000000000
68530+:102F90003C0380008C6202780440FFFE8F82001C9C
68531+:102FA000AC62024024020002A06202443C02100013
68532+:102FB000AC6202780A000C3D000000009523000678
68533+:102FC000912400058D25000C8D2600108D270018FA
68534+:102FD0008D28001C8D290020244200013C0108009E
68535+:102FE000A42356C63C010800A02456C53C01080095
68536+:102FF000AC2556CC3C010800AC2656D03C0108005C
68537+:10300000AC2756D83C010800AC2856DC3C0108002F
68538+:10301000AC2956E00A000C3DA38200191462000A94
68539+:10302000240200813C02800834420100944500EAF9
68540+:10303000922600058F84001C30A5FFFF30C600FFDC
68541+:103040000A000BFE3C0760211462005C00000000D7
68542+:103050009222000A304300FF306200201040000737
68543+:10306000306200403C02800834420100944500EA8E
68544+:103070008F84001C0A000BFC24060040104000074F
68545+:10308000000316003C02800834420100944500EA27
68546+:103090008F84001C0A000BFC24060041000216036A
68547+:1030A000044100463C02800834420100944500EA95
68548+:1030B0008F84001C2406004230A5FFFF3C076019E6
68549+:1030C0000E000901000000000A000C3D0000000095
68550+:1030D0009222000B24040016304200FF1044000628
68551+:1030E0003C0680009222000B24030017304200FFB0
68552+:1030F000144300320000000034C5010090A2000B10
68553+:10310000304200FF1444000B000080218CA20020FC
68554+:103110008CA400202403FF800043102400021140EF
68555+:103120003084007F004410253C032000004310251C
68556+:10313000ACC2083094A2000800021400000214037C
68557+:10314000044200012410000194A2000830420080D3
68558+:103150005040001A0200A82194A20008304220002A
68559+:10316000504000160200A8218CA300183C021C2D20
68560+:10317000344219ED106200110200A8213C0208003F
68561+:103180008C4200D4104000053C0280082403000457
68562+:1031900034420100A04300FC3C028008344201009C
68563+:1031A000944500EA8F84001C2406000630A5FFFF2A
68564+:1031B0000E0009013C0760210200A8210E00093918
68565+:1031C000000000009222000A304200081040000473
68566+:1031D00002A010210E0013790000000002A01021AF
68567+:1031E0008FBF00308FB5002C8FB400288FB3002420
68568+:1031F0008FB200208FB1001C8FB0001803E00008D0
68569+:1032000027BD00382402FF80008220243C02900069
68570+:1032100034420007008220253C028000AC4400209C
68571+:103220003C0380008C6200200440FFFE0000000090
68572+:1032300003E00008000000003C0380002402FF803F
68573+:10324000008220243462000700822025AC64002024
68574+:103250008C6200200440FFFE0000000003E0000834
68575+:103260000000000027BDFFD8AFB3001CAFB10014B1
68576+:10327000AFB00010AFBF0020AFB200183C1180000B
68577+:103280003C0280088E32002034530100AE2400201E
68578+:10329000966300EA000514003C074000004738250B
68579+:1032A00000A08021000030210E0009013065FFFFE1
68580+:1032B000240200A1160200022402FFFFA2620009FC
68581+:1032C000AE3200208FBF00208FB3001C8FB20018D9
68582+:1032D0008FB100148FB0001003E0000827BD002854
68583+:1032E0003C0280082403000527BDFFE834420100AA
68584+:1032F000A04300FCAFBF00103C0280008C420100E4
68585+:10330000240500A1004020210E000C67AF82001CA4
68586+:103310003C0380008C6202780440FFFE8F82001C18
68587+:103320008FBF001027BD0018AC62024024020002CB
68588+:10333000A06202443C021000AC62027803E0000884
68589+:103340000000000027BDFFE83C068000AFBF001072
68590+:1033500034C7010094E20008304400FF3883008243
68591+:10336000388200842C6300012C4200010062182581
68592+:103370001060002D24020083938200195040003B0E
68593+:103380008FBF00103C020800904256CC8CC4010054
68594+:103390003C06080094C656C63045003F38A30032AC
68595+:1033A00038A2003F2C6300012C4200010062182566
68596+:1033B000AF84001CAF860014A380001914600007BE
68597+:1033C00000E020212402002014A2001200000000CE
68598+:1033D0003402FFFF14C2000F00000000240200208E
68599+:1033E00014A2000500E028218CE300142402FFFF52
68600+:1033F0005062000B8FBF00103C040800248456C0AC
68601+:10340000000030210E000706240700010A000CD638
68602+:103410008FBF00100E000777000000008FBF001064
68603+:103420000A00093927BD001814820004240200850F
68604+:103430008CC501040A000CE1000020211482000662
68605+:103440002482FF808CC50104240440008FBF00103B
68606+:103450000A00016727BD0018304200FF2C4200021D
68607+:1034600010400004240200228FBF00100A000B2726
68608+:1034700027BD0018148200048F8200248FBF001023
68609+:103480000A000C8627BD00188C42000C1040001E5C
68610+:1034900000E0282190E300092402001814620003D0
68611+:1034A000240200160A000CFC240300081462000722
68612+:1034B00024020017240300123C02800834420080DA
68613+:1034C000A04300090A000D0994A7000854620007F0
68614+:1034D00094A700088F82FF942404FFFE9043000508
68615+:1034E00000641824A043000594A7000890A6001BC0
68616+:1034F0008CA4000094A500068FBF001000073C00BC
68617+:103500000A0008DC27BD00188FBF001003E0000888
68618+:1035100027BD00188F8500243C04800094A2002A57
68619+:103520008CA30034000230C02402FFF000C210243B
68620+:1035300000621821AC83003C8CA200303C03800068
68621+:10354000AC8200383C02005034420010AC620030C3
68622+:103550000000000000000000000000008C6200007D
68623+:10356000304200201040FFFD30C20008104000062D
68624+:103570003C0280008C620408ACA200208C62040C27
68625+:103580000A000D34ACA200248C430400ACA300203C
68626+:103590008C420404ACA200243C0300203C028000C6
68627+:1035A000AC4300303C0480008C8200300043102487
68628+:1035B0001440FFFD8F8600243C020040AC820030A6
68629+:1035C00094C3002A94C2002894C4002C94C5002EF1
68630+:1035D00024630001004410213064FFFFA4C20028CE
68631+:1035E00014850002A4C3002AA4C0002A03E0000836
68632+:1035F000000000008F84002427BDFFE83C05800404
68633+:1036000024840010AFBF00100E000E472406000AED
68634+:103610008F840024948200129483002E3042000F85
68635+:10362000244200030043180424027FFF0043102BB0
68636+:1036300010400002AC8300000000000D0E000D13CE
68637+:10364000000000008F8300248FBF001027BD0018EA
68638+:10365000946200149463001A3042000F00021500B7
68639+:10366000006218253C02800003E00008AC4300A083
68640+:103670008F8300243C028004944400069462001A64
68641+:103680008C650000A4640016004410233042FFFF44
68642+:103690000045102B03E00008384200018F8400240D
68643+:1036A0003C0780049486001A8C85000094E2000692
68644+:1036B000A482001694E3000600C310233042FFFFEB
68645+:1036C0000045102B384200011440FFF8A483001677
68646+:1036D00003E00008000000008F8400243C02800406
68647+:1036E000944200069483001A8C850000A482001680
68648+:1036F000006210233042FFFF0045102B38420001CA
68649+:103700005040000D8F850024006030213C0780046C
68650+:1037100094E20006A482001694E3000600C310237E
68651+:103720003042FFFF0045102B384200011440FFF8E3
68652+:10373000A48300168F8500243C03800034620400BB
68653+:103740008CA40020AF820020AC6400388CA200243E
68654+:10375000AC62003C3C020005AC62003003E00008B3
68655+:10376000ACA000048F8400243C0300068C8200047B
68656+:1037700000021140004310253C038000AC62003081
68657+:103780000000000000000000000000008C6200004B
68658+:10379000304200101040FFFD34620400AC80000491
68659+:1037A00003E00008AF8200208F86002427BDFFE0E1
68660+:1037B000AFB10014AFB00010AFBF00188CC300044D
68661+:1037C0008CC500248F820020309000FF94C4001A22
68662+:1037D00024630001244200202484000124A7002047
68663+:1037E000ACC30004AF820020A4C4001AACC70024FC
68664+:1037F00004A100060000882104E2000594C2001A1A
68665+:103800008CC2002024420001ACC2002094C2001AE5
68666+:1038100094C300282E040001004310262C4200010E
68667+:10382000004410245040000594C2001A24020001F4
68668+:10383000ACC2000894C2001A94C300280010202BC8
68669+:10384000004310262C4200010044102514400007BC
68670+:10385000000000008CC20008144000042402001084
68671+:103860008CC300041462000F8F8500240E000DA786
68672+:10387000241100018F820024944300289442001AEE
68673+:1038800014430003000000000E000D1300000000B0
68674+:10389000160000048F8500240E000D840000000037
68675+:1038A0008F85002494A2001E94A4001C24420001D1
68676+:1038B0003043FFFF14640002A4A2001EA4A0001E57
68677+:1038C0001200000A3C02800494A2001494A3001A7F
68678+:1038D0003042000F00021500006218253C028000F3
68679+:1038E000AC4300A00A000E1EACA0000894420006E3
68680+:1038F00094A3001A8CA40000A4A200160062102356
68681+:103900003042FFFF0044102B384200011040000DF0
68682+:1039100002201021006030213C07800494E2000660
68683+:10392000A4A2001694E3000600C310233042FFFF58
68684+:103930000044102B384200011440FFF8A4A30016E5
68685+:10394000022010218FBF00188FB100148FB000101B
68686+:1039500003E0000827BD002003E00008000000008D
68687+:103960008F82002C3C03000600021140004310250A
68688+:103970003C038000AC62003000000000000000004A
68689+:10398000000000008C620000304200101040FFFD7B
68690+:1039900034620400AF82002803E00008AF80002CEE
68691+:1039A00003E000080000102103E000080000000010
68692+:1039B0003084FFFF30A5FFFF0000182110800007B2
68693+:1039C000000000003082000110400002000420428C
68694+:1039D000006518210A000E3D0005284003E000089C
68695+:1039E0000060102110C0000624C6FFFF8CA200005A
68696+:1039F00024A50004AC8200000A000E4724840004C1
68697+:103A000003E000080000000010A0000824A3FFFF4E
68698+:103A1000AC86000000000000000000002402FFFF50
68699+:103A20002463FFFF1462FFFA2484000403E000080B
68700+:103A3000000000003C0280083442008024030001A2
68701+:103A4000AC43000CA4430010A4430012A443001490
68702+:103A500003E00008A44300168F82002427BDFFD88E
68703+:103A6000AFB3001CAFB20018AFB10014AFB000107C
68704+:103A7000AFBF00208C47000C248200802409FF8007
68705+:103A80003C08800E3043007F008080213C0A80008B
68706+:103A9000004920240068182130B100FF30D200FF17
68707+:103AA00010E000290000982126020100AD44002CFE
68708+:103AB000004928243042007F004820219062000005
68709+:103AC00024030050304200FF1443000400000000B3
68710+:103AD000AD45002C948200EA3053FFFF0E000D84A8
68711+:103AE000000000008F8200248F83002000112C0032
68712+:103AF0009442001E001224003484000100A22825F4
68713+:103B00003C02400000A22825AC7000008FBF0020BE
68714+:103B1000AC6000048FB20018AC7300088FB10014C1
68715+:103B2000AC60000C8FB3001CAC6400108FB00010B0
68716+:103B3000AC60001424040001AC60001827BD00280C
68717+:103B40000A000DB8AC65001C8FBF00208FB3001CAD
68718+:103B50008FB200188FB100148FB0001003E000087E
68719+:103B600027BD00283C06800034C201009043000FAE
68720+:103B7000240200101062000E2865001110A000073A
68721+:103B800024020012240200082405003A10620006F4
68722+:103B90000000302103E0000800000000240500358B
68723+:103BA0001462FFFC000030210A000E6400000000D7
68724+:103BB0008CC200748F83FF9424420FA003E000089E
68725+:103BC000AC62000C27BDFFE8AFBF00100E0003423F
68726+:103BD000240500013C0480088FBF0010240200016E
68727+:103BE00034830080A462001227BD00182402000163
68728+:103BF00003E00008A080001A27BDFFE0AFB2001864
68729+:103C0000AFB10014AFB00010AFBF001C30B2FFFF67
68730+:103C10000E000332008088213C028008345000806E
68731+:103C20009202000924030004304200FF1443000CF8
68732+:103C30003C028008124000082402000A0E000E5BBD
68733+:103C400000000000920200052403FFFE0043102440
68734+:103C5000A202000524020012A20200093C02800810
68735+:103C600034420080022020210E00033DA0400027A6
68736+:103C700016400003022020210E000EBF00000000AD
68737+:103C800002202021324600FF8FBF001C8FB2001897
68738+:103C90008FB100148FB00010240500380A000E64A4
68739+:103CA00027BD002027BDFFE0AFBF001CAFB200184A
68740+:103CB000AFB10014AFB000100E00033200808021BD
68741+:103CC0000E000E5B000000003C02800834450080BE
68742+:103CD00090A2000924120018305100FF1232000394
68743+:103CE0000200202124020012A0A2000990A20005D7
68744+:103CF0002403FFFE004310240E00033DA0A2000594
68745+:103D00000200202124050020163200070000302187
68746+:103D10008FBF001C8FB200188FB100148FB000103D
68747+:103D20000A00034227BD00208FBF001C8FB200187D
68748+:103D30008FB100148FB00010240500390A000E6402
68749+:103D400027BD002027BDFFE83C028000AFB0001077
68750+:103D5000AFBF0014344201009442000C2405003629
68751+:103D60000080802114400012304600FF0E00033214
68752+:103D7000000000003C02800834420080240300124E
68753+:103D8000A043000990430005346300100E000E5B51
68754+:103D9000A04300050E00033D020020210200202167
68755+:103DA0000E000342240500200A000F3C0000000022
68756+:103DB0000E000E64000000000E00033202002021FD
68757+:103DC0003C0280089043001B2405FF9F0200202135
68758+:103DD000006518248FBF00148FB00010A043001B93
68759+:103DE0000A00033D27BD001827BDFFE0AFBF001844
68760+:103DF000AFB10014AFB0001030B100FF0E000332BD
68761+:103E0000008080213C02800824030012344200809C
68762+:103E10000E000E5BA04300090E00033D02002021AE
68763+:103E200002002021022030218FBF00188FB1001422
68764+:103E30008FB00010240500350A000E6427BD002055
68765+:103E40003C0480089083000E9082000A1443000B0B
68766+:103E5000000028218F82FF942403005024050001D4
68767+:103E600090420000304200FF1443000400000000B4
68768+:103E70009082000E24420001A082000E03E00008A0
68769+:103E800000A010213C0380008C6201F80440FFFE7A
68770+:103E900024020002AC6401C0A06201C43C02100014
68771+:103EA00003E00008AC6201F827BDFFE0AFB20018E4
68772+:103EB0003C128008AFB10014AFBF001CAFB00010BF
68773+:103EC00036510080922200092403000A304200FF8C
68774+:103ED0001443003E000000008E4300048E22003890
68775+:103EE000506200808FBF001C92220000240300500B
68776+:103EF000304200FF144300253C0280008C42014008
68777+:103F00008E4300043642010002202821AC43001CED
68778+:103F10009622005C8E2300383042FFFF00021040E2
68779+:103F200000621821AE23001C8E4300048E2400384A
68780+:103F30009622005C006418233042FFFF0003184300
68781+:103F4000000210400043102A10400006000000004C
68782+:103F50008E4200048E230038004310230A000FAA6B
68783+:103F6000000220439622005C3042FFFF0002204006
68784+:103F70003C0280083443010034420080ACA4002C91
68785+:103F8000A040002424020001A062000C0E000F5E7D
68786+:103F900000000000104000538FBF001C3C02800056
68787+:103FA0008C4401403C0380008C6201F80440FFFE19
68788+:103FB00024020002AC6401C0A06201C43C021000F3
68789+:103FC000AC6201F80A0010078FBF001C92220009A2
68790+:103FD00024030010304200FF144300043C02800020
68791+:103FE0008C4401400A000FEE0000282192220009B3
68792+:103FF00024030016304200FF14430006240200147C
68793+:10400000A22200093C0280008C4401400A001001F9
68794+:104010008FBF001C8E2200388E23003C00431023EB
68795+:10402000044100308FBF001C92220027244200016F
68796+:10403000A2220027922200272C42000414400016DE
68797+:104040003C1080009222000924030004304200FF4B
68798+:10405000144300093C0280008C4401408FBF001CC7
68799+:104060008FB200188FB100148FB000102405009398
68800+:104070000A000ECC27BD00208C440140240500938B
68801+:104080008FBF001C8FB200188FB100148FB00010CA
68802+:104090000A000F4827BD00208E0401400E000332A5
68803+:1040A000000000008E4200042442FFFFAE420004E4
68804+:1040B0008E22003C2442FFFFAE22003C0E00033D56
68805+:1040C0008E0401408E0401408FBF001C8FB2001887
68806+:1040D0008FB100148FB00010240500040A000342C1
68807+:1040E00027BD00208FB200188FB100148FB00010D0
68808+:1040F00003E0000827BD00203C0680008CC2018838
68809+:104100003C038008346500809063000E00021402B6
68810+:10411000304400FF306300FF1464000E3C0280084E
68811+:1041200090A20026304200FF104400098F82FF94C5
68812+:10413000A0A400262403005090420000304200FF5B
68813+:1041400014430006000000000A0005A18CC4018091
68814+:104150003C02800834420080A044002603E00008AE
68815+:104160000000000027BDFFE030E700FFAFB20018FD
68816+:10417000AFBF001CAFB10014AFB0001000809021A1
68817+:1041800014E0000630C600FF000000000000000D33
68818+:10419000000000000A001060240001163C038008A3
68819+:1041A0009062000E304200FF14460023346200800B
68820+:1041B00090420026304200FF1446001F000000001D
68821+:1041C0009062000F304200FF1446001B0000000008
68822+:1041D0009062000A304200FF144600038F90FF9463
68823+:1041E0000000000D8F90FF948F82FF983C1180009B
68824+:1041F000AE05003CAC450000A066000A0E0003328C
68825+:104200008E240100A20000240E00033D8E24010034
68826+:104210003C0380008C6201F80440FFFE240200028F
68827+:10422000AC7201C0A06201C43C021000AC6201F893
68828+:104230000A0010618FBF001C000000000000000D8C
68829+:10424000000000002400013F8FBF001C8FB2001847
68830+:104250008FB100148FB0001003E0000827BD0020CC
68831+:104260008F83FF943C0280008C44010034420100A3
68832+:104270008C65003C9046001B0A00102724070001B3
68833+:104280003C0280089043000E9042000A0043102632
68834+:10429000304200FF03E000080002102B27BDFFE0C2
68835+:1042A0003C028008AFB10014AFB00010AFBF0018DF
68836+:1042B0003450008092020005240300303042003068
68837+:1042C00014430085008088218F8200248C42000CDA
68838+:1042D000104000828FBF00180E000D840000000007
68839+:1042E0008F860020ACD100009202000892030009E2
68840+:1042F000304200FF00021200306300FF004310252F
68841+:10430000ACC200049202004D000216000002160327
68842+:1043100004410005000000003C0308008C630048D5
68843+:104320000A00109F3C1080089202000830420040B2
68844+:10433000144000030000182192020027304300FFC0
68845+:104340003C108008361100809222004D00031E00B0
68846+:10435000304200FF0002140000621825ACC30008C0
68847+:104360008E2400308F820024ACC4000C8E250034D3
68848+:104370009443001E3C02C00BACC50010006218251F
68849+:104380008E22003800002021ACC200148E22003C96
68850+:10439000ACC200180E000DB8ACC3001C8E020004A5
68851+:1043A0008F8400203C058000AC8200008E2200201B
68852+:1043B000AC8200048E22001CAC8200088E220058C1
68853+:1043C0008CA3007400431021AC82000C8E22002CC0
68854+:1043D000AC8200108E2200408E23004400021400A4
68855+:1043E00000431025AC8200149222004D240300806B
68856+:1043F000304200FF1443000400000000AC800018AD
68857+:104400000A0010E38F8200248E23000C2402000196
68858+:104410001062000E2402FFFF92220008304200408A
68859+:104420001440000A2402FFFF8E23000C8CA20074AB
68860+:10443000006218233C0208000062102414400002AD
68861+:10444000000028210060282100051043AC820018DC
68862+:104450008F820024000020219443001E3C02C00CE7
68863+:10446000006218258F8200200E000DB8AC43001C9E
68864+:104470003C038008346201008C4200008F850020DC
68865+:10448000346300808FBF0018ACA20000ACA0000411
68866+:104490008C6400488F8200248FB10014ACA4000803
68867+:1044A000ACA0000CACA00010906300059446001E68
68868+:1044B0003C02400D00031E0000C23025ACA30014D6
68869+:1044C0008FB00010ACA0001824040001ACA6001CA2
68870+:1044D0000A000DB827BD00208FBF00188FB100144F
68871+:1044E0008FB0001003E0000827BD00203C028000D0
68872+:1044F0009443007C3C02800834460100308400FF75
68873+:104500003065FFFF2402000524A34650A0C4000C20
68874+:104510005482000C3065FFFF90C2000D2C42000752
68875+:104520001040000724A30A0090C3000D24020014C9
68876+:104530000062100400A210210A00111F3045FFFF85
68877+:104540003065FFFF3C0280083442008003E0000831
68878+:10455000A44500143C03800834680080AD05003891
68879+:10456000346701008CE2001C308400FF00A210239D
68880+:104570001840000330C600FF24A2FFFCACE2001C80
68881+:1045800030820001504000083C0380088D02003C4E
68882+:1045900000A2102304410012240400058C620004D0
68883+:1045A00010A2000F3C0380088C62000414A2001EBD
68884+:1045B000000000003C0208008C4200D8304200207D
68885+:1045C000104000093C0280083462008090630008BB
68886+:1045D0009042004C144300043C0280082404000470
68887+:1045E0000A00110900000000344300803442010039
68888+:1045F000A040000C24020001A462001410C0000AB4
68889+:104600003C0280008C4401003C0380008C6201F875
68890+:104610000440FFFE24020002AC6401C0A06201C499
68891+:104620003C021000AC6201F803E00008000000004A
68892+:1046300027BDFFE800A61823AFBF00101860008058
68893+:10464000308800FF3C02800834470080A0E000244E
68894+:1046500034440100A0E000278C82001C00A210233B
68895+:1046600004400056000000008CE2003C94E3005C33
68896+:104670008CE4002C004530233063FFFF00C3182179
68897+:104680000083202B1080000400E018218CE2002C15
68898+:104690000A00117800A2102194E2005C3042FFFF72
68899+:1046A00000C2102100A21021AC62001C3C02800854
68900+:1046B000344400809482005C8C83001C3042FFFFF5
68901+:1046C0000002104000A210210043102B10400004F3
68902+:1046D000000000008C82001C0A00118B3C06800840
68903+:1046E0009482005C3042FFFF0002104000A21021C3
68904+:1046F0003C06800834C3010034C70080AC82001C33
68905+:10470000A060000CACE500388C62001C00A21023F5
68906+:104710001840000224A2FFFCAC62001C3102000120
68907+:10472000104000083C0380088CE2003C00A21023EB
68908+:1047300004410012240400058CC2000410A20010E1
68909+:104740008FBF00108C62000414A2004F8FBF0010B6
68910+:104750003C0208008C4200D8304200201040000A81
68911+:104760003C02800834620080906300089042004C54
68912+:10477000144300053C028008240400048FBF00108D
68913+:104780000A00110927BD001834430080344201009B
68914+:10479000A040000C24020001A46200143C0280002E
68915+:1047A0008C4401003C0380008C6201F80440FFFE51
68916+:1047B000240200020A0011D8000000008CE2001C54
68917+:1047C000004610230043102B54400001ACE5001CB0
68918+:1047D00094E2005C3042FFFF0062102B144000079F
68919+:1047E0002402000294E2005C8CE3001C3042FFFFD4
68920+:1047F00000621821ACE3001C24020002ACE5003882
68921+:104800000E000F5EA082000C1040001F8FBF001032
68922+:104810003C0280008C4401003C0380008C6201F863
68923+:104820000440FFFE24020002AC6401C0A06201C487
68924+:104830003C021000AC6201F80A0011F08FBF0010BA
68925+:1048400031020010104000108FBF00103C028008A1
68926+:10485000344500808CA3001C94A2005C00661823E1
68927+:104860003042FFFF006218213C023FFF3444FFFF4B
68928+:104870000083102B544000010080182100C3102138
68929+:10488000ACA2001C8FBF001003E0000827BD001879
68930+:1048900027BDFFE800C0402100A63023AFBF0010B5
68931+:1048A00018C00026308A00FF3C028008344900808E
68932+:1048B0008D24001C8D23002C008820230064182BDD
68933+:1048C0001060000F344701008CE2002000461021E8
68934+:1048D000ACE200208CE200200044102B1440000BBE
68935+:1048E0003C023FFF8CE2002000441023ACE2002099
68936+:1048F0009522005C3042FFFF0A0012100082202146
68937+:10490000ACE00020008620213C023FFF3443FFFF43
68938+:104910000064102B54400001006020213C028008FC
68939+:104920003442008000851821AC43001CA0400024C4
68940+:10493000A04000270A0012623C03800831420010A8
68941+:10494000104000433C0380083C06800834C40080CB
68942+:104950008C82003C004810235840003E34660080A2
68943+:104960009082002424420001A0820024908200242E
68944+:104970003C0308008C630024304200FF0043102BEE
68945+:10498000144000688FBF001034C201008C42001C2C
68946+:1049900000A2102318400063000000008CC3000434
68947+:1049A0009482005C006818233042FFFF0003184324
68948+:1049B000000210400043102A1040000500000000D3
68949+:1049C0008CC20004004810230A0012450002104364
68950+:1049D0009482005C3042FFFF000210403C068008D9
68951+:1049E000AC82002C34C5008094A2005C8CA4002C06
68952+:1049F00094A3005C3042FFFF00021040008220219F
68953+:104A00003063FFFF0083202101041021ACA2001CB1
68954+:104A10008CC2000434C60100ACC2001C2402000297
68955+:104A20000E000F5EA0C2000C1040003E8FBF0010B1
68956+:104A30003C0280008C4401003C0380008C6201F841
68957+:104A40000440FFFE240200020A001292000000004F
68958+:104A500034660080ACC50038346401008C82001CD0
68959+:104A600000A210231840000224A2FFFCAC82001C0C
68960+:104A7000314200015040000A3C0380088CC2003CD7
68961+:104A800000A2102304430014240400058C620004D7
68962+:104A900014A200033C0380080A00128424040005C9
68963+:104AA0008C62000414A2001F8FBF00103C0208009B
68964+:104AB0008C4200D8304200201040000A3C0280089E
68965+:104AC00034620080906300089042004C144300055B
68966+:104AD0003C028008240400048FBF00100A00110962
68967+:104AE00027BD00183443008034420100A040000C70
68968+:104AF00024020001A46200143C0280008C440100E6
68969+:104B00003C0380008C6201F80440FFFE2402000296
68970+:104B1000AC6401C0A06201C43C021000AC6201F8A8
68971+:104B20008FBF001003E0000827BD001827BDFFE875
68972+:104B30003C0A8008AFBF0010354900808D22003C40
68973+:104B400000C04021308400FF004610231840009D23
68974+:104B500030E700FF354701002402000100A63023A2
68975+:104B6000A0E0000CA0E0000DA522001418C0002455
68976+:104B7000308200108D23001C8D22002C0068182329
68977+:104B80000043102B1040000F000000008CE20020BA
68978+:104B900000461021ACE200208CE200200043102BE4
68979+:104BA0001440000B3C023FFF8CE200200043102326
68980+:104BB000ACE200209522005C3042FFFF0A0012C1E7
68981+:104BC00000621821ACE00020006618213C023FFF83
68982+:104BD0003446FFFF00C3102B5440000100C01821D1
68983+:104BE0003C0280083442008000651821AC43001C60
68984+:104BF000A0400024A04000270A00130F3C038008B7
68985+:104C0000104000403C0380088D22003C00481023E7
68986+:104C10005840003D34670080912200242442000166
68987+:104C2000A1220024912200243C0308008C6300246C
68988+:104C3000304200FF0043102B1440009A8FBF001039
68989+:104C40008CE2001C00A21023184000960000000017
68990+:104C50008D4300049522005C006818233042FFFF5A
68991+:104C600000031843000210400043102A10400005C2
68992+:104C7000012020218D420004004810230A0012F276
68993+:104C8000000210439522005C3042FFFF00021040FA
68994+:104C90003C068008AC82002C34C5008094A2005CE5
68995+:104CA0008CA4002C94A3005C3042FFFF0002104053
68996+:104CB000008220213063FFFF0083182101031021AF
68997+:104CC000ACA2001C8CC2000434C60100ACC2001CA3
68998+:104CD000240200020E000F5EA0C2000C1040007102
68999+:104CE0008FBF00103C0280008C4401003C03800018
69000+:104CF0008C6201F80440FFFE240200020A0013390E
69001+:104D00000000000034670080ACE500383466010024
69002+:104D10008CC2001C00A210231840000224A2FFFC39
69003+:104D2000ACC2001C30820001504000083C038008E7
69004+:104D30008CE2003C00A2102304430051240400052F
69005+:104D40008C62000410A2003E3C0380088C620004C8
69006+:104D500054A200548FBF00103C0208008C4200D8BF
69007+:104D600030420020104000063C028008346200807F
69008+:104D7000906300089042004C104300403C028008C1
69009+:104D80003443008034420100A040000C24020001A2
69010+:104D9000A46200143C0280008C4401003C038000AB
69011+:104DA0008C6201F80440FFFE24020002AC6401C0E2
69012+:104DB000A06201C43C021000AC6201F80A00137743
69013+:104DC0008FBF001024020005A120002714E2000A72
69014+:104DD0003C038008354301009062000D2C42000620
69015+:104DE000504000053C0380089062000D2442000101
69016+:104DF000A062000D3C03800834670080ACE50038F9
69017+:104E0000346601008CC2001C00A21023184000026E
69018+:104E100024A2FFFCACC2001C308200015040000AFA
69019+:104E20003C0380088CE2003C00A2102304410014E3
69020+:104E3000240400058C62000414A200033C038008D3
69021+:104E40000A00136E240400058C62000414A20015ED
69022+:104E50008FBF00103C0208008C4200D83042002076
69023+:104E60001040000A3C028008346200809063000811
69024+:104E70009042004C144300053C02800824040004C6
69025+:104E80008FBF00100A00110927BD001834430080AD
69026+:104E900034420100A040000C24020001A46200146E
69027+:104EA0008FBF001003E0000827BD00183C0B8008EE
69028+:104EB00027BDFFE83C028000AFBF00103442010074
69029+:104EC000356A00809044000A356901008C45001461
69030+:104ED0008D4800389123000C308400FF0105102319
69031+:104EE0001C4000B3306700FF2CE20006504000B1C8
69032+:104EF0008FBF00102402000100E2300430C2000322
69033+:104F00005440000800A8302330C2000C144000A117
69034+:104F100030C20030144000A38FBF00100A00143BC1
69035+:104F20000000000018C00024308200108D43001CD7
69036+:104F30008D42002C006818230043102B1040000FF6
69037+:104F4000000000008D22002000461021AD2200202C
69038+:104F50008D2200200043102B1440000B3C023FFF29
69039+:104F60008D22002000431023AD2200209542005CDA
69040+:104F70003042FFFF0A0013AF00621821AD2000206D
69041+:104F8000006618213C023FFF3446FFFF00C3102B90
69042+:104F90005440000100C018213C02800834420080C7
69043+:104FA00000651821AC43001CA0400024A04000274D
69044+:104FB0000A0013FD3C038008104000403C038008B9
69045+:104FC0008D42003C004810231840003D34670080AB
69046+:104FD0009142002424420001A14200249142002475
69047+:104FE0003C0308008C630024304200FF0043102B78
69048+:104FF000144000708FBF00108D22001C00A21023EF
69049+:105000001840006C000000008D6300049542005CB5
69050+:10501000006818233042FFFF0003184300021040CD
69051+:105020000043102A10400005014020218D62000439
69052+:10503000004810230A0013E0000210439542005C70
69053+:105040003042FFFF000210403C068008AC82002C7A
69054+:1050500034C5008094A2005C8CA4002C94A3005C56
69055+:105060003042FFFF00021040008220213063FFFF2A
69056+:105070000083182101031021ACA2001C8CC2000483
69057+:1050800034C60100ACC2001C240200020E000F5EF8
69058+:10509000A0C2000C104000478FBF00103C028000EF
69059+:1050A0008C4401003C0380008C6201F80440FFFE48
69060+:1050B000240200020A00142D000000003467008062
69061+:1050C000ACE50038346601008CC2001C00A210233D
69062+:1050D0001840000224A2FFFCACC2001C3082000178
69063+:1050E0005040000A3C0380088CE2003C00A21023E0
69064+:1050F00004430014240400058C62000414A200037D
69065+:105100003C0380080A00141F240400058C6200047C
69066+:1051100014A200288FBF00103C0208008C4200D867
69067+:10512000304200201040000A3C02800834620080B7
69068+:10513000906300089042004C144300053C02800834
69069+:10514000240400048FBF00100A00110927BD0018B5
69070+:105150003443008034420100A040000C24020001CE
69071+:10516000A46200143C0280008C4401003C038000D7
69072+:105170008C6201F80440FFFE24020002AC6401C00E
69073+:10518000A06201C43C021000AC6201F80A00143BAA
69074+:105190008FBF00108FBF0010010030210A00115A8C
69075+:1051A00027BD0018010030210A00129927BD001800
69076+:1051B0008FBF001003E0000827BD00183C038008E3
69077+:1051C0003464010024020003A082000C8C620004FD
69078+:1051D00003E00008AC82001C3C05800834A300807A
69079+:1051E0009062002734A501002406004324420001F8
69080+:1051F000A0620027906300273C0208008C42004810
69081+:10520000306300FF146200043C07602194A500EAAB
69082+:105210000A00090130A5FFFF03E0000800000000BC
69083+:1052200027BDFFE8AFBF00103C0280000E00144411
69084+:105230008C4401803C02800834430100A060000CD3
69085+:105240008C4200048FBF001027BD001803E0000847
69086+:10525000AC62001C27BDFFE03C028008AFBF001815
69087+:10526000AFB10014AFB000103445008034460100E7
69088+:105270003C0880008D09014090C3000C8CA4003CC8
69089+:105280008CA200381482003B306700FF9502007C3E
69090+:1052900090A30027146000093045FFFF2402000599
69091+:1052A00054E200083C04800890C2000D2442000132
69092+:1052B000A0C2000D0A00147F3C048008A0C0000DAD
69093+:1052C0003C048008348201009042000C2403000555
69094+:1052D000304200FF1443000A24A205DC348300801E
69095+:1052E000906200272C4200075040000524A20A00CB
69096+:1052F00090630027240200140062100400A2102111
69097+:105300003C108008361000803045FFFF012020212E
69098+:105310000E001444A60500149602005C8E030038AB
69099+:105320003C1180003042FFFF000210400062182153
69100+:10533000AE03001C0E0003328E24014092020025B1
69101+:1053400034420040A20200250E00033D8E2401409D
69102+:105350008E2401403C0380008C6201F80440FFFE73
69103+:1053600024020002AC6401C0A06201C43C0210002F
69104+:10537000AC6201F88FBF00188FB100148FB000101D
69105+:1053800003E0000827BD00203C0360103C02080039
69106+:1053900024420174AC62502C8C6250003C048000AA
69107+:1053A00034420080AC6250003C0208002442547C2D
69108+:1053B0003C010800AC2256003C020800244254384C
69109+:1053C0003C010800AC2256043C020002AC840008F8
69110+:1053D000AC82000C03E000082402000100A0302190
69111+:1053E0003C1C0800279C56083C0200023C050400B7
69112+:1053F00000852826008220260004102B2CA5000101
69113+:105400002C840001000210803C0308002463560035
69114+:105410000085202500431821108000030000102182
69115+:10542000AC6600002402000103E000080000000058
69116+:105430003C1C0800279C56083C0200023C05040066
69117+:1054400000852826008220260004102B2CA50001B0
69118+:105450002C840001000210803C03080024635600E5
69119+:105460000085202500431821108000050000102130
69120+:105470003C02080024425438AC62000024020001BF
69121+:1054800003E00008000000003C0200023C030400AE
69122+:1054900000821026008318262C4200012C63000194
69123+:1054A000004310251040000B000028213C1C080080
69124+:1054B000279C56083C0380008C62000824050001EC
69125+:1054C00000431025AC6200088C62000C00441025DB
69126+:1054D000AC62000C03E0000800A010213C1C080096
69127+:1054E000279C56083C0580008CA3000C0004202754
69128+:1054F000240200010064182403E00008ACA3000C9F
69129+:105500003C020002148200063C0560008CA208D018
69130+:105510002403FFFE0043102403E00008ACA208D0DF
69131+:105520003C02040014820005000000008CA208D098
69132+:105530002403FFFD00431024ACA208D003E00008C0
69133+:10554000000000003C02601A344200108C430080CE
69134+:1055500027BDFFF88C440084AFA3000093A3000094
69135+:10556000240200041462001AAFA4000493A20001F4
69136+:105570001040000797A300023062FFFC3C0380004C
69137+:10558000004310218C4200000A001536AFA200042F
69138+:105590003062FFFC3C03800000431021AC4400005B
69139+:1055A000A3A000003C0560008CA208D02403FFFEED
69140+:1055B0003C04601A00431024ACA208D08FA300045E
69141+:1055C0008FA2000034840010AC830084AC82008081
69142+:1055D00003E0000827BD000827BDFFE8AFBF0010AB
69143+:1055E0003C1C0800279C56083C0280008C43000CA1
69144+:1055F0008C420004004318243C0200021060001496
69145+:10560000006228243C0204003C04000210A00005B3
69146+:10561000006210243C0208008C4256000A00155B10
69147+:1056200000000000104000073C0404003C02080099
69148+:105630008C4256040040F809000000000A00156082
69149+:10564000000000000000000D3C1C0800279C5608CC
69150+:105650008FBF001003E0000827BD0018800802403B
69151+:1056600080080100800800808008000000000C8095
69152+:105670000000320008000E9808000EF408000F88A1
69153+:1056800008001028080010748008010080080080BD
69154+:10569000800800000A000028000000000000000050
69155+:1056A0000000000D6370362E322E316200000000C3
69156+:1056B00006020104000000000000000000000000DD
69157+:1056C000000000000000000038003C000000000066
69158+:1056D00000000000000000000000000000000020AA
69159+:1056E00000000000000000000000000000000000BA
69160+:1056F00000000000000000000000000000000000AA
69161+:10570000000000000000000021003800000000013F
69162+:105710000000002B000000000000000400030D400A
69163+:105720000000000000000000000000000000000079
69164+:105730000000000000000000100000030000000056
69165+:105740000000000D0000000D3C020800244259AC8E
69166+:105750003C03080024635BF4AC4000000043202BB2
69167+:105760001480FFFD244200043C1D080037BD9FFC4F
69168+:1057700003A0F0213C100800261000A03C1C0800EB
69169+:10578000279C59AC0E0002F6000000000000000D3E
69170+:1057900027BDFFB4AFA10000AFA20004AFA3000873
69171+:1057A000AFA4000CAFA50010AFA60014AFA700185F
69172+:1057B000AFA8001CAFA90020AFAA0024AFAB0028FF
69173+:1057C000AFAC002CAFAD0030AFAE0034AFAF00389F
69174+:1057D000AFB8003CAFB90040AFBC0044AFBF004819
69175+:1057E0000E000820000000008FBF00488FBC00445E
69176+:1057F0008FB900408FB8003C8FAF00388FAE0034B7
69177+:105800008FAD00308FAC002C8FAB00288FAA002406
69178+:105810008FA900208FA8001C8FA700188FA6001446
69179+:105820008FA500108FA4000C8FA300088FA2000486
69180+:105830008FA1000027BD004C3C1B60188F7A5030B0
69181+:10584000377B502803400008AF7A000000A01821E1
69182+:1058500000801021008028213C0460003C0760008B
69183+:105860002406000810600006348420788C42000072
69184+:10587000ACE220088C63000003E00008ACE3200CDD
69185+:105880000A000F8100000000240300403C02600079
69186+:1058900003E00008AC4320003C0760008F86000452
69187+:1058A0008CE520740086102100A2182B14600007DC
69188+:1058B000000028218F8AFDA024050001A1440013C7
69189+:1058C0008F89000401244021AF88000403E0000810
69190+:1058D00000A010218F84FDA08F8500049086001306
69191+:1058E00030C300FF00A31023AF82000403E00008D0
69192+:1058F000A08000138F84FDA027BDFFE8AFB000108B
69193+:10590000AFBF001490890011908700112402002875
69194+:10591000312800FF3906002830E300FF2485002CE1
69195+:105920002CD00001106200162484001C0E00006EB2
69196+:10593000000000008F8FFDA03C05600024020204DF
69197+:1059400095EE003E95ED003C000E5C0031ACFFFF93
69198+:10595000016C5025ACAA2010520000012402000462
69199+:10596000ACA22000000000000000000000000000C9
69200+:105970008FBF00148FB0001003E0000827BD00188F
69201+:105980000A0000A6000028218F85FDA027BDFFD8B2
69202+:10599000AFBF0020AFB3001CAFB20018AFB100140E
69203+:1059A000AFB000100080982190A4001124B0001C1A
69204+:1059B00024B1002C308300FF386200280E000090D4
69205+:1059C0002C5200010E00009800000000020020216F
69206+:1059D0001240000202202821000028210E00006E43
69207+:1059E000000000008F8DFDA03C0880003C05600099
69208+:1059F00095AC003E95AB003C02683025000C4C0095
69209+:105A0000316AFFFF012A3825ACA7201024020202C8
69210+:105A1000ACA6201452400001240200028FBF0020D7
69211+:105A20008FB3001C8FB200188FB100148FB000101C
69212+:105A300027BD002803E00008ACA2200027BDFFE03E
69213+:105A4000AFB20018AFB10014AFB00010AFBF001C70
69214+:105A50003C1160008E2320748F82000430D0FFFF41
69215+:105A600030F2FFFF1062000C2406008F0E00006E63
69216+:105A7000000000003C06801F0010440034C5FF00F9
69217+:105A80000112382524040002AE2720100000302126
69218+:105A9000AE252014AE2420008FBF001C8FB200184A
69219+:105AA0008FB100148FB0001000C0102103E0000877
69220+:105AB00027BD002027BDFFE0AFB0001030D0FFFFB2
69221+:105AC000AFBF0018AFB100140E00006E30F1FFFF41
69222+:105AD00000102400009180253C036000AC70201071
69223+:105AE0008FBF00188FB100148FB000102402000483
69224+:105AF000AC62200027BD002003E000080000102158
69225+:105B000027BDFFE03C046018AFBF0018AFB1001420
69226+:105B1000AFB000108C8850002403FF7F34028071E6
69227+:105B20000103382434E5380C241F00313C1980006F
69228+:105B3000AC8550003C11800AAC8253BCAF3F0008DA
69229+:105B40000E00054CAF9100400E00050A3C116000AC
69230+:105B50000E00007D000000008E3008083C0F570941
69231+:105B60002418FFF00218602435EEE00035EDF00057
69232+:105B7000018E5026018D58262D4600012D69000109
69233+:105B8000AF86004C0E000D09AF8900503C06601630
69234+:105B90008CC700003C0860148D0500A03C03FFFF8B
69235+:105BA00000E320243C02535300052FC2108200550D
69236+:105BB00034D07C00960201F2A780006C10400003F4
69237+:105BC000A780007C384B1E1EA78B006C960201F844
69238+:105BD000104000048F8D0050384C1E1EA78C007C96
69239+:105BE0008F8D005011A000058F83004C240E0020E3
69240+:105BF000A78E007CA78E006C8F83004C1060000580
69241+:105C00009785007C240F0020A78F007CA78F006C55
69242+:105C10009785007C2CB8008153000001240500808A
69243+:105C20009784006C2C91040152200001240404008C
69244+:105C30001060000B3C0260008FBF00188FB1001491
69245+:105C40008FB0001027BD0020A784006CA785007CC2
69246+:105C5000A380007EA780007403E00008A780009264
69247+:105C60008C4704382419103C30FFFFFF13F9000360
69248+:105C700030A8FFFF1100004624030050A380007EDF
69249+:105C80009386007E50C00024A785007CA780007CFE
69250+:105C90009798007CA780006CA7800074A780009272
69251+:105CA0003C010800AC3800800E00078700000000AF
69252+:105CB0003C0F60008DED0808240EFFF03C0B600ED9
69253+:105CC000260C0388356A00100000482100002821B6
69254+:105CD00001AE20243C105709AF8C0010AF8A004859
69255+:105CE000AF89001810900023AF8500148FBF0018F3
69256+:105CF0008FB100148FB0001027BD002003E0000812
69257+:105D0000AF80005400055080014648218D260004D4
69258+:105D10000A00014800D180219798007CA784006C7C
69259+:105D2000A7800074A78000923C010800AC38008076
69260+:105D30000E000787000000003C0F60008DED080892
69261+:105D4000240EFFF03C0B600E260C0388356A001011
69262+:105D5000000048210000282101AE20243C105709F2
69263+:105D6000AF8C0010AF8A0048AF8900181490FFDF95
69264+:105D7000AF85001424110001AF9100548FBF0018AB
69265+:105D80008FB100148FB0001003E0000827BD002081
69266+:105D90000A00017BA383007E3083FFFF8F880040D1
69267+:105DA0008F87003C000321403C0580003C020050EE
69268+:105DB000008248253C0660003C0A010034AC040027
69269+:105DC0008CCD08E001AA58241160000500000000F5
69270+:105DD0008CCF08E024E7000101EA7025ACCE08E092
69271+:105DE0008D19001001805821ACB900388D180014AD
69272+:105DF000ACB8003CACA9003000000000000000007E
69273+:105E00000000000000000000000000000000000092
69274+:105E100000000000000000003C0380008C640000D3
69275+:105E2000308200201040FFFD3C0F60008DED08E047
69276+:105E30003C0E010001AE18241460FFE100000000D8
69277+:105E4000AF87003C03E00008AF8B00588F8500400F
69278+:105E5000240BFFF03C06800094A7001A8CA90024B4
69279+:105E600030ECFFFF000C38C000EB5024012A402129
69280+:105E7000ACC8003C8CA400248CC3003C00831023DD
69281+:105E800018400033000000008CAD002025A2000166
69282+:105E90003C0F0050ACC2003835EE00103C068000CC
69283+:105EA000ACCE003000000000000000000000000048
69284+:105EB00000000000000000000000000000000000E2
69285+:105EC000000000003C0480008C9900003338002062
69286+:105ED0001300FFFD30E20008104000173C0980006D
69287+:105EE0008C880408ACA800108C83040CACA30014AC
69288+:105EF0003C1900203C188000AF19003094AE001807
69289+:105F000094AF001C01CF3021A4A6001894AD001A54
69290+:105F100025A70001A4A7001A94AB001A94AC001E98
69291+:105F2000118B00030000000003E0000800000000E7
69292+:105F300003E00008A4A0001A8D2A0400ACAA0010F7
69293+:105F40008D240404ACA400140A0002183C1900209B
69294+:105F50008CA200200A0002003C0F00500A0001EE53
69295+:105F60000000000027BDFFE8AFBF00100E000232A6
69296+:105F7000000000008F8900408FBF00103C038000AC
69297+:105F8000A520000A9528000A9527000427BD0018BF
69298+:105F90003105FFFF30E6000F0006150000A22025A6
69299+:105FA00003E00008AC6400803C0508008CA50020DC
69300+:105FB0008F83000C27BDFFE8AFB00010AFBF001407
69301+:105FC00010A300100000802124040001020430040A
69302+:105FD00000A6202400C3102450440006261000010F
69303+:105FE000001018802787FDA41480000A006718217C
69304+:105FF000261000012E0900025520FFF38F83000CAC
69305+:10600000AF85000C8FBF00148FB0001003E00008B4
69306+:1060100027BD00188C6800003C058000ACA8002457
69307+:106020000E000234261000013C0508008CA500205B
69308+:106030000A0002592E0900022405000100851804F7
69309+:106040003C0408008C84002027BDFFC8AFBF00348B
69310+:1060500000831024AFBE0030AFB7002CAFB60028CD
69311+:10606000AFB50024AFB40020AFB3001CAFB200182E
69312+:10607000AFB1001410400051AFB000108F84004049
69313+:10608000948700069488000A00E8302330D5FFFF8B
69314+:1060900012A0004B8FBF0034948B0018948C000A20
69315+:1060A000016C50233142FFFF02A2482B1520000251
69316+:1060B00002A02021004020212C8F000515E00002C5
69317+:1060C00000809821241300040E0001C102602021E9
69318+:1060D0008F87004002609021AF80004494F4000A52
69319+:1060E000026080211260004E3291FFFF3C1670006A
69320+:1060F0003C1440003C1E20003C1760008F99005863
69321+:106100008F380000031618241074004F0283F82BF8
69322+:1061100017E0003600000000107E00478F86004424
69323+:1061200014C0003A2403000102031023022320219B
69324+:106130003050FFFF1600FFF13091FFFF8F870040C6
69325+:106140003C1100203C108000AE11003094EB000A9E
69326+:106150003C178000024B5021A4EA000A94E9000A8F
69327+:1061600094E800043123FFFF3106000F00062D00E4
69328+:106170000065F025AEFE008094F3000A94F6001846
69329+:1061800012D30036001221408CFF00148CF4001052
69330+:1061900003E468210000C02101A4782B029870213B
69331+:1061A00001CF6021ACED0014ACEC001002B238233A
69332+:1061B00030F5FFFF16A0FFB88F8400408FBF00347A
69333+:1061C0008FBE00308FB7002C8FB600288FB500240B
69334+:1061D0008FB400208FB3001C8FB200188FB1001451
69335+:1061E0008FB0001003E0000827BD00381477FFCC03
69336+:1061F0008F8600440E000EE202002021004018218C
69337+:106200008F86004410C0FFC9020310230270702360
69338+:106210008F87004001C368210A0002E431B2FFFF0A
69339+:106220008F86004414C0FFC93C1100203C10800040
69340+:106230000A0002AEAE1100300E00046602002021FA
69341+:106240000A0002DB00401821020020210E0009395B
69342+:10625000022028210A0002DB004018210E0001EE76
69343+:10626000000000000A0002C702B2382327BDFFC8A1
69344+:10627000AFB7002CAFB60028AFB50024AFB40020F4
69345+:10628000AFB3001CAFB20018AFB10014AFB0001034
69346+:10629000AFBF00300E00011B241300013C047FFF40
69347+:1062A0003C0380083C0220003C010800AC20007048
69348+:1062B0003496FFFF34770080345200033C1512C03F
69349+:1062C000241400013C1080002411FF800E000245C0
69350+:1062D000000000008F8700488F8B00188F89001402
69351+:1062E0008CEA00EC8CE800E8014B302B01092823F4
69352+:1062F00000A6102314400006014B18231440000E82
69353+:106300003C05800002A3602B1180000B0000000000
69354+:106310003C0560008CEE00EC8CED00E88CA4180CC1
69355+:10632000AF8E001804800053AF8D00148F8F0010C3
69356+:10633000ADF400003C0580008CBF00003BF900017B
69357+:10634000333800011700FFE13C0380008C6201003C
69358+:1063500024060C0010460009000000008C680100B3
69359+:106360002D043080548000103C0480008C690100B2
69360+:106370002D2331811060000C3C0480008CAA0100A8
69361+:1063800011460004000020218CA6010024C5FF81D5
69362+:1063900030A400FF8E0B01000E000269AE0B00243A
69363+:1063A0000A00034F3C0480008C8D01002DAC3300AB
69364+:1063B00011800022000000003C0708008CE70098D4
69365+:1063C00024EE00013C010800AC2E00983C04800043
69366+:1063D0008C8201001440000300000000566000148D
69367+:1063E0003C0440008C9F01008C9801000000982123
69368+:1063F00003F1C82400193940330F007F00EF7025E6
69369+:1064000001D26825AC8D08308C8C01008C85010090
69370+:10641000258B0100017130240006514030A3007F1C
69371+:106420000143482501324025AC8808303C04400037
69372+:10643000AE0401380A00030E000000008C99010030
69373+:10644000240F0020AC99002092F80000330300FFD5
69374+:10645000106F000C241F0050547FFFDD3C048000AF
69375+:106460008C8401000E00154E000000000A00034F4E
69376+:106470003C04800000963824ACA7180C0A000327BF
69377+:106480008F8F00108C8501000E0008F72404008017
69378+:106490000A00034F3C04800000A4102B24030001D9
69379+:1064A00010400009000030210005284000A4102BF6
69380+:1064B00004A00003000318405440FFFC00052840DE
69381+:1064C0005060000A0004182B0085382B54E00004AB
69382+:1064D0000003184200C33025008520230003184222
69383+:1064E0001460FFF9000528420004182B03E000089F
69384+:1064F00000C310213084FFFF30C600FF3C0780003E
69385+:106500008CE201B80440FFFE00064C000124302557
69386+:106510003C08200000C820253C031000ACE00180AE
69387+:10652000ACE50184ACE4018803E00008ACE301B809
69388+:106530003C0660008CC5201C2402FFF03083020062
69389+:10654000308601001060000E00A2282434A500014E
69390+:106550003087300010E0000530830C0034A50004C3
69391+:106560003C04600003E00008AC85201C1060FFFDC7
69392+:106570003C04600034A5000803E00008AC85201C42
69393+:1065800054C0FFF334A500020A0003B03087300086
69394+:1065900027BDFFE8AFB00010AFBF00143C0760009C
69395+:1065A000240600021080001100A080218F83005873
69396+:1065B0000E0003A78C6400188F8200580000202171
69397+:1065C000240600018C45000C0E000398000000001A
69398+:1065D0001600000224020003000010218FBF0014E7
69399+:1065E0008FB0001003E0000827BD00188CE8201CC5
69400+:1065F0002409FFF001092824ACE5201C8F870058EE
69401+:106600000A0003CD8CE5000C3C02600E00804021A6
69402+:1066100034460100240900180000000000000000BA
69403+:10662000000000003C0A00503C0380003547020097
69404+:10663000AC68003834640400AC65003CAC670030E2
69405+:106640008C6C0000318B00201160FFFD2407FFFFE0
69406+:106650002403007F8C8D00002463FFFF248400044A
69407+:10666000ACCD00001467FFFB24C60004000000004E
69408+:10667000000000000000000024A402000085282B78
69409+:106680003C0300203C0E80002529FFFF010540212E
69410+:10669000ADC300301520FFE00080282103E0000892
69411+:1066A000000000008F82005827BDFFD8AFB3001C48
69412+:1066B000AFBF0020AFB20018AFB10014AFB00010F0
69413+:1066C00094460002008098218C5200182CC300814F
69414+:1066D0008C4800048C4700088C51000C8C49001039
69415+:1066E000106000078C4A00142CC4000414800013AE
69416+:1066F00030EB000730C5000310A0001000000000C0
69417+:106700002410008B02002021022028210E00039873
69418+:10671000240600031660000224020003000010217A
69419+:106720008FBF00208FB3001C8FB200188FB10014F0
69420+:106730008FB0001003E0000827BD00281560FFF1AE
69421+:106740002410008B3C0C80003C030020241F00011F
69422+:10675000AD830030AF9F0044000000000000000047
69423+:10676000000000002419FFF024D8000F031978243A
69424+:106770003C1000D0AD88003801F0702524CD000316
69425+:106780003C08600EAD87003C35850400AD8E0030BE
69426+:10679000000D38823504003C3C0380008C6B000007
69427+:1067A000316200201040FFFD0000000010E00008F2
69428+:1067B00024E3FFFF2407FFFF8CA800002463FFFFF2
69429+:1067C00024A50004AC8800001467FFFB24840004A7
69430+:1067D0003C05600EACA60038000000000000000080
69431+:1067E000000000008F8600543C0400203C0780001D
69432+:1067F000ACE4003054C000060120202102402021DA
69433+:106800000E0003A7000080210A00041D02002021C1
69434+:106810000E0003DD01402821024020210E0003A7C5
69435+:10682000000080210A00041D0200202127BDFFE096
69436+:10683000AFB200183092FFFFAFB10014AFBF001C21
69437+:10684000AFB000101640000D000088210A0004932C
69438+:106850000220102124050003508500278CE5000C40
69439+:106860000000000D262800013111FFFF24E2002066
69440+:106870000232802B12000019AF8200588F82004430
69441+:10688000144000168F8700583C0670003C0320001F
69442+:106890008CE5000000A62024148300108F84006083
69443+:1068A000000544023C09800000A980241480FFE90F
69444+:1068B000310600FF2CCA000B5140FFEB26280001D7
69445+:1068C000000668803C0E080025CE575801AE6021B6
69446+:1068D0008D8B0000016000080000000002201021E4
69447+:1068E0008FBF001C8FB200188FB100148FB0001042
69448+:1068F00003E0000827BD00200E0003982404008454
69449+:106900001600FFD88F8700580A000474AF8000601B
69450+:10691000020028210E0003BF240400018F870058C5
69451+:106920000A000474AF820060020028210E0003BF39
69452+:10693000000020210A0004A38F8700580E000404E1
69453+:10694000020020218F8700580A000474AF82006083
69454+:1069500030AFFFFF000F19C03C0480008C9001B8DD
69455+:106960000600FFFE3C1920043C181000AC83018097
69456+:10697000AC800184AC990188AC9801B80A00047518
69457+:106980002628000190E2000390E30002000020218D
69458+:106990000002FE0000033A0000FF2825240600083C
69459+:1069A0000E000398000000001600FFDC2402000324
69460+:1069B0008F870058000010210A000474AF82006025
69461+:1069C00090E8000200002021240600090A0004C308
69462+:1069D00000082E0090E4000C240900FF308500FF21
69463+:1069E00010A900150000302190F9000290F8000372
69464+:1069F000308F00FF94EB000400196E000018740043
69465+:106A0000000F62000186202501AE5025014B28258C
69466+:106A10003084FF8B0A0004C32406000A90E30002BE
69467+:106A200090FF0004000020210003360000DF28252D
69468+:106A30000A0004C32406000B0A0004D52406008BB8
69469+:106A4000000449C23127003F000443423C02800059
69470+:106A500000082040240316802CE60020AC43002CC4
69471+:106A600024EAFFE02482000114C0000330A900FFE3
69472+:106A700000801021314700FF000260803C0D800043
69473+:106A8000240A0001018D20213C0B000E00EA28049D
69474+:106A9000008B302111200005000538278CCE000026
69475+:106AA00001C5382503E00008ACC700008CD8000001
69476+:106AB0000307782403E00008ACCF000027BDFFE007
69477+:106AC000AFB10014AFB00010AFBF00183C076000BA
69478+:106AD0008CE408083402F0003C1160003083F000C0
69479+:106AE000240501C03C04800E000030211062000625
69480+:106AF000241000018CEA08083149F0003928E00030
69481+:106B00000008382B000780403C0D0200AE2D081411
69482+:106B1000240C16803C0B80008E2744000E000F8B47
69483+:106B2000AD6C002C120000043C02169124050001FB
69484+:106B3000120500103C023D2C345800E0AE384408E9
69485+:106B40003C1108008E31007C8FBF00183C066000AD
69486+:106B500000118540360F16808FB100148FB00010E1
69487+:106B60003C0E020027BD0020ACCF442003E000080B
69488+:106B7000ACCE08103C0218DA345800E0AE384408B5
69489+:106B80003C1108008E31007C8FBF00183C0660006D
69490+:106B900000118540360F16808FB100148FB00010A1
69491+:106BA0003C0E020027BD0020ACCF442003E00008CB
69492+:106BB000ACCE08100A0004EB240500010A0004EB27
69493+:106BC0000000282124020400A7820024A780001CC2
69494+:106BD000000020213C06080024C65A582405FFFF67
69495+:106BE00024890001000440803124FFFF01061821A0
69496+:106BF0002C87002014E0FFFAAC6500002404040098
69497+:106C0000A7840026A780001E000020213C06080063
69498+:106C100024C65AD82405FFFF248D0001000460809B
69499+:106C200031A4FFFF018658212C8A00201540FFFA6D
69500+:106C3000AD650000A7800028A7800020A780002263
69501+:106C4000000020213C06080024C65B582405FFFFF5
69502+:106C5000249900010004C0803324FFFF030678213B
69503+:106C60002C8E000415C0FFFAADE500003C05600065
69504+:106C70008CA73D002403E08F00E31024344601403C
69505+:106C800003E00008ACA63D002487007F000731C266
69506+:106C900024C5FFFF000518C2246400013082FFFFF5
69507+:106CA000000238C0A78400303C010800AC27003047
69508+:106CB000AF80002C0000282100002021000030219E
69509+:106CC0002489000100A728213124FFFF2CA81701E7
69510+:106CD000110000032C8300801460FFF924C600011A
69511+:106CE00000C02821AF86002C10C0001DA786002AF6
69512+:106CF00024CAFFFF000A11423C08080025085B581F
69513+:106D00001040000A00002021004030212407FFFF2E
69514+:106D1000248E00010004688031C4FFFF01A86021B7
69515+:106D20000086582B1560FFFAAD87000030A2001FC7
69516+:106D30005040000800043080240300010043C804D0
69517+:106D400000041080004878212738FFFF03E0000886
69518+:106D5000ADF8000000C820212405FFFFAC8500002D
69519+:106D600003E000080000000030A5FFFF30C6FFFF71
69520+:106D700030A8001F0080602130E700FF0005294295
69521+:106D80000000502110C0001D24090001240B000147
69522+:106D900025180001010B2004330800FF0126782686
69523+:106DA000390E00202DED00012DC2000101A2182591
69524+:106DB0001060000D014450250005C880032C4021BF
69525+:106DC0000100182110E0000F000A20278D040000A8
69526+:106DD000008A1825AD03000024AD00010000402109
69527+:106DE0000000502131A5FFFF252E000131C9FFFF12
69528+:106DF00000C9102B1040FFE72518000103E0000830
69529+:106E0000000000008D0A0000014440240A0005D162
69530+:106E1000AC68000027BDFFE830A5FFFF30C6FFFFCC
69531+:106E2000AFB00010AFBF001430E7FFFF00005021EB
69532+:106E30003410FFFF0000602124AF001F00C0482174
69533+:106E4000241800012419002005E0001601E010219B
69534+:106E50000002F943019F682A0009702B01AE40240B
69535+:106E600011000017000C18800064102110E00005CC
69536+:106E70008C4B000000F840040008382301675824B8
69537+:106E800000003821154000410000402155600016E7
69538+:106E90003169FFFF258B0001316CFFFF05E1FFEC3D
69539+:106EA00001E0102124A2003E0002F943019F682A5C
69540+:106EB0000009702B01AE40241500FFEB000C188078
69541+:106EC000154600053402FFFF020028210E0005B51B
69542+:106ED00000003821020010218FBF00148FB0001075
69543+:106EE00003E0000827BD00181520000301601821E9
69544+:106EF000000B1C0224080010306A00FF154000053A
69545+:106F0000306E000F250D000800031A0231A800FFA3
69546+:106F1000306E000F15C00005307F000325100004FF
69547+:106F200000031902320800FF307F000317E000055C
69548+:106F3000386900012502000200031882304800FF72
69549+:106F4000386900013123000110600004310300FFA3
69550+:106F5000250A0001314800FF310300FF000C6940A1
69551+:106F600001A34021240A000110CAFFD53110FFFF00
69552+:106F7000246E000131C800FF1119FFC638C9000195
69553+:106F80002D1F002053E0001C258B0001240D000163
69554+:106F90000A000648240E002051460017258B0001E8
69555+:106FA00025090001312800FF2D0900205120001281
69556+:106FB000258B000125430001010D5004014B1024D5
69557+:106FC000250900011440FFF4306AFFFF3127FFFF5D
69558+:106FD00010EE000C2582FFFF304CFFFF0000502117
69559+:106FE0003410FFFF312800FF2D0900205520FFF24B
69560+:106FF00025430001258B0001014648260A000602B0
69561+:10700000316CFFFF00003821000050210A000654B7
69562+:107010003410FFFF27BDFFD8AFB0001030F0FFFFE6
69563+:10702000AFB10014001039423211FFE000071080A8
69564+:10703000AFB3001C00B1282330D3FFFFAFB200185C
69565+:1070400030A5FFFF00809021026030210044202104
69566+:10705000AFBF00200E0005E03207001F022288218A
69567+:107060003403FFFF0240202102002821026030216A
69568+:1070700000003821104300093231FFFF02201021A7
69569+:107080008FBF00208FB3001C8FB200188FB1001487
69570+:107090008FB0001003E0000827BD00280E0005E0B7
69571+:1070A0000000000000408821022010218FBF002036
69572+:1070B0008FB3001C8FB200188FB100148FB0001076
69573+:1070C00003E0000827BD0028000424003C03600002
69574+:1070D000AC603D0810A00002348210063482101605
69575+:1070E00003E00008AC623D0427BDFFE0AFB0001034
69576+:1070F000309000FF2E020006AFBF001810400008BD
69577+:10710000AFB10014001030803C03080024635784A2
69578+:1071100000C328218CA400000080000800000000AB
69579+:10712000000020218FBF00188FB100148FB0001015
69580+:107130000080102103E0000827BD00209791002A5D
69581+:1071400016200051000020213C020800904200332C
69582+:107150000A0006BB00000000978D002615A0003134
69583+:10716000000020210A0006BB2402000897870024A3
69584+:1071700014E0001A00001821006020212402000100
69585+:107180001080FFE98FBF0018000429C2004530219C
69586+:1071900000A6582B1160FFE43C0880003C0720004B
69587+:1071A000000569C001A76025AD0C00203C038008E4
69588+:1071B0002402001F2442FFFFAC6000000441FFFDD9
69589+:1071C0002463000424A5000100A6702B15C0FFF560
69590+:1071D000000569C00A0006A58FBF00189787001C2C
69591+:1071E0003C04080024845A58240504000E0006605C
69592+:1071F00024060001978B002424440001308AFFFFFD
69593+:107200002569FFFF2D48040000402821150000409B
69594+:10721000A789002424AC3800000C19C00A0006B964
69595+:10722000A780001C9787001E3C04080024845AD8BD
69596+:10723000240504000E00066024060001979900262C
69597+:10724000244400013098FFFF272FFFFF2F0E04007A
69598+:107250000040882115C0002CA78F0026A780001EA3
69599+:107260003A020003262401003084FFFF0E00068D41
69600+:107270002C4500010011F8C027F00100001021C0CA
69601+:107280000A0006BB240200089785002E978700227B
69602+:107290003C04080024845B580E00066024060001AC
69603+:1072A0009787002A8F89002C2445000130A8FFFF12
69604+:1072B00024E3FFFF0109302B0040802114C0001897
69605+:1072C000A783002AA7800022978500300E000F7543
69606+:1072D00002002021244A05003144FFFF0E00068DE4
69607+:1072E000240500013C05080094A500320E000F752E
69608+:1072F00002002021244521003C0208009042003376
69609+:107300000A0006BB000521C00A0006F3A784001E80
69610+:1073100024AC3800000C19C00A0006B9A784001C70
69611+:107320000A00070DA7850022308400FF27BDFFE873
69612+:107330002C820006AFBF0014AFB000101040001543
69613+:1073400000A03821000440803C0308002463579CBF
69614+:10735000010328218CA40000008000080000000028
69615+:1073600024CC007F000751C2000C59C23170FFFFCE
69616+:107370002547C40030E5FFFF2784001C02003021B0
69617+:107380000E0005B52407000197860028020620217B
69618+:10739000A78400288FBF00148FB0001003E00008FE
69619+:1073A00027BD00183C0508008CA50030000779C2F5
69620+:1073B0000E00038125E4DF003045FFFF3C04080098
69621+:1073C00024845B58240600010E0005B52407000143
69622+:1073D000978E002A8FBF00148FB0001025CD0001BA
69623+:1073E00027BD001803E00008A78D002A0007C9C2C6
69624+:1073F0002738FF00001878C231F0FFFF3C04080076
69625+:1074000024845AD802002821240600010E0005B564
69626+:1074100024070001978D0026260E0100000E84002F
69627+:1074200025AC00013C0B6000A78C0026AD603D0838
69628+:1074300036040006000030213C0760008CE23D0469
69629+:10744000305F000617E0FFFD24C9000100061B00A5
69630+:10745000312600FF006440252CC50004ACE83D0443
69631+:1074600014A0FFF68FBF00148FB0001003E00008D7
69632+:1074700027BD0018000751C22549C8002406000195
69633+:10748000240700013C04080024845A580E0005B566
69634+:107490003125FFFF978700248FBF00148FB00010A5
69635+:1074A00024E6000127BD001803E00008A786002499
69636+:1074B0003C0660183C090800252900FCACC9502C8A
69637+:1074C0008CC850003C0580003C020002350700805B
69638+:1074D000ACC750003C04080024841FE03C030800B3
69639+:1074E00024631F98ACA50008ACA2000C3C01080066
69640+:1074F000AC2459A43C010800AC2359A803E00008BF
69641+:107500002402000100A030213C1C0800279C59AC3B
69642+:107510003C0C04003C0B0002008B3826008C4026FB
69643+:107520002CE200010007502B2D050001000A4880C5
69644+:107530003C030800246359A4004520250123182199
69645+:107540001080000300001021AC660000240200013E
69646+:1075500003E00008000000003C1C0800279C59AC18
69647+:107560003C0B04003C0A0002008A3026008B3826BF
69648+:107570002CC200010006482B2CE5000100094080C8
69649+:107580003C030800246359A4004520250103182169
69650+:1075900010800005000010213C0C0800258C1F986D
69651+:1075A000AC6C00002402000103E0000800000000B1
69652+:1075B0003C0900023C080400008830260089382677
69653+:1075C0002CC30001008028212CE400010083102539
69654+:1075D0001040000B000030213C1C0800279C59ACD7
69655+:1075E0003C0A80008D4E00082406000101CA68256F
69656+:1075F000AD4D00088D4C000C01855825AD4B000C9D
69657+:1076000003E0000800C010213C1C0800279C59AC76
69658+:107610003C0580008CA6000C0004202724020001F9
69659+:1076200000C4182403E00008ACA3000C3C020002D4
69660+:107630001082000B3C0560003C070400108700032B
69661+:107640000000000003E00008000000008CA908D042
69662+:10765000240AFFFD012A402403E00008ACA808D05A
69663+:107660008CA408D02406FFFE0086182403E000083E
69664+:10767000ACA308D03C05601A34A600108CC300806F
69665+:1076800027BDFFF88CC50084AFA3000093A40000C1
69666+:107690002402001010820003AFA5000403E00008DC
69667+:1076A00027BD000893A7000114E0001497AC000266
69668+:1076B00097B800023C0F8000330EFFFC01CF682119
69669+:1076C000ADA50000A3A000003C0660008CC708D058
69670+:1076D0002408FFFE3C04601A00E82824ACC508D04A
69671+:1076E0008FA300048FA200003499001027BD00086A
69672+:1076F000AF22008003E00008AF2300843C0B800031
69673+:10770000318AFFFC014B48218D2800000A00080C3B
69674+:10771000AFA8000427BDFFE8AFBF00103C1C080065
69675+:10772000279C59AC3C0580008CA4000C8CA2000462
69676+:107730003C0300020044282410A0000A00A31824DF
69677+:107740003C0604003C0400021460000900A610245A
69678+:107750001440000F3C0404000000000D3C1C080015
69679+:10776000279C59AC8FBF001003E0000827BD00180C
69680+:107770003C0208008C4259A40040F80900000000B7
69681+:107780003C1C0800279C59AC0A0008358FBF00102C
69682+:107790003C0208008C4259A80040F8090000000093
69683+:1077A0000A00083B000000003C0880008D0201B880
69684+:1077B0000440FFFE35090180AD2400003C031000A9
69685+:1077C00024040040AD250004A1240008A1260009DE
69686+:1077D000A527000A03E00008AD0301B83084FFFFCD
69687+:1077E0000080382130A5FFFF000020210A00084555
69688+:1077F000240600803087FFFF8CA400002406003898
69689+:107800000A000845000028218F8300788F860070C9
69690+:107810001066000B008040213C07080024E75B68ED
69691+:10782000000328C000A710218C440000246300013D
69692+:10783000108800053063000F5466FFFA000328C06B
69693+:1078400003E00008000010213C07080024E75B6CFF
69694+:1078500000A7302103E000088CC200003C03900028
69695+:1078600034620001008220253C038000AC640020CB
69696+:107870008C65002004A0FFFE0000000003E000086B
69697+:10788000000000003C0280003443000100832025FA
69698+:1078900003E00008AC44002027BDFFE0AFB10014B6
69699+:1078A0003091FFFFAFB00010AFBF001812200013DF
69700+:1078B00000A080218CA20000240400022406020003
69701+:1078C0001040000F004028210E0007250000000096
69702+:1078D00000001021AE000000022038218FBF0018E8
69703+:1078E0008FB100148FB0001000402021000028212B
69704+:1078F000000030210A00084527BD00208CA20000AE
69705+:10790000022038218FBF00188FB100148FB00010F3
69706+:107910000040202100002821000030210A000845F5
69707+:1079200027BD002000A010213087FFFF8CA5000498
69708+:107930008C4400000A000845240600068F83FD9C45
69709+:1079400027BDFFE8AFBF0014AFB00010906700087C
69710+:10795000008010210080282130E600400000202116
69711+:1079600010C000088C5000000E0000BD0200202155
69712+:10797000020020218FBF00148FB000100A000548BC
69713+:1079800027BD00180E0008A4000000000E0000BD76
69714+:1079900002002021020020218FBF00148FB00010B0
69715+:1079A0000A00054827BD001827BDFFE0AFB0001052
69716+:1079B0008F90FD9CAFBF001CAFB20018AFB1001498
69717+:1079C00092060001008088210E00087230D2000467
69718+:1079D00092040005001129C2A6050000348300406E
69719+:1079E000A20300050E00087C022020210E00054A9B
69720+:1079F0000220202124020001AE02000C02202821D6
69721+:107A0000A602001024040002A602001224060200AE
69722+:107A1000A60200140E000725A60200161640000F4D
69723+:107A20008FBF001C978C00743C0B08008D6B007896
69724+:107A30002588FFFF3109FFFF256A0001012A382B45
69725+:107A400010E00006A78800743C0F6006240E0016A4
69726+:107A500035ED0010ADAE00508FBF001C8FB2001886
69727+:107A60008FB100148FB0001003E0000827BD002084
69728+:107A700027BDFFE0AFB10014AFBF0018AFB00010DA
69729+:107A80001080000400A088212402008010820007DA
69730+:107A9000000000000000000D8FBF00188FB100141F
69731+:107AA0008FB0001003E0000827BD00200E00087210
69732+:107AB00000A020218F86FD9C0220202190C500057A
69733+:107AC0000E00087C30B000FF2403003E1603FFF1D7
69734+:107AD0003C0680008CC401780480FFFE34C801405D
69735+:107AE000240900073C071000AD11000002202021EE
69736+:107AF000A10900048FBF00188FB100148FB00010CF
69737+:107B0000ACC701780A0008C527BD002027BDFFE0EB
69738+:107B1000AFB00010AFBF0018AFB100143C10800030
69739+:107B20008E110020000000000E00054AAE04002067
69740+:107B3000AE1100208FBF00188FB100148FB000105D
69741+:107B400003E0000827BD00203084FFFF00803821BB
69742+:107B50002406003500A020210A0008450000282145
69743+:107B60003084FFFF008038212406003600A0202149
69744+:107B70000A0008450000282127BDFFD0AFB500242A
69745+:107B80003095FFFFAFB60028AFB40020AFBF002C88
69746+:107B9000AFB3001CAFB20018AFB10014AFB000100B
69747+:107BA00030B6FFFF12A000270000A0218F920058DE
69748+:107BB0008E4300003C0680002402004000033E0289
69749+:107BC00000032C0230E4007F006698241482001D1C
69750+:107BD00030A500FF8F8300682C68000A1100001098
69751+:107BE0008F8D0044000358803C0C0800258C57B84A
69752+:107BF000016C50218D4900000120000800000000A8
69753+:107C000002D4302130C5FFFF0E0008522404008446
69754+:107C1000166000028F920058AF8000688F8D00447C
69755+:107C20002659002026980001032090213314FFFFDD
69756+:107C300015A00004AF9900580295202B1480FFDC9A
69757+:107C400000000000028010218FBF002C8FB600289A
69758+:107C50008FB500248FB400208FB3001C8FB20018A2
69759+:107C60008FB100148FB0001003E0000827BD003072
69760+:107C70002407003414A70149000000009247000EB9
69761+:107C80008F9FFDA08F90FD9C24181600A3E700197C
69762+:107C90009242000D3C0880003C07800CA3E20018D3
69763+:107CA000964A00123C0D60003C117FFFA60A005C62
69764+:107CB000964400103623FFFF240200053099FFFF91
69765+:107CC000AE1900548E46001CAD1800288CEF000041
69766+:107CD0008DAE444801E6482601C93021AE06003881
69767+:107CE0008E05003824CB00013C0E7F00AE05003C21
69768+:107CF0008E0C003CAFEC0004AE0B00208E13002075
69769+:107D0000AE13001CA3E0001BAE03002CA3E2001284
69770+:107D10008E4A001424130050AE0A00348E0400343E
69771+:107D2000AFE400148E590018AE1900489258000CA8
69772+:107D3000A218004E920D000835AF0020A20F0008D7
69773+:107D40008E090018012E282434AC4000AE0C001817
69774+:107D5000920B0000317200FF1253027F2403FF8058
69775+:107D60003C04080024845BE80E0008AA0000000020
69776+:107D70003C1108008E315BE80E00087202202021C1
69777+:107D80002405000424080001A2050025022020216A
69778+:107D90000E00087CA20800053C0580008CB001782C
69779+:107DA0000600FFFE8F92005834AE0140240F0002FF
69780+:107DB0003C091000ADD10000A1CF0004ACA90178AE
69781+:107DC0000A000962AF8000682CAD003751A0FF9413
69782+:107DD0008F8D0044000580803C110800263157E05B
69783+:107DE000021178218DEE000001C0000800000000A3
69784+:107DF0002411000414B1008C3C0780003C080800EA
69785+:107E00008D085BE88F86FD9CACE800208E4500085D
69786+:107E10008F99FDA0240D0050ACC500308E4C000899
69787+:107E2000ACCC00508E4B000CACCB00348E43001019
69788+:107E3000ACC300388E4A0010ACCA00548E42001405
69789+:107E4000ACC2003C8E5F0018AF3F00048E50001C97
69790+:107E5000ACD0002090C40000309800FF130D024AFF
69791+:107E6000000000008CC400348CD00030009030231F
69792+:107E700004C000F12404008C126000EE2402000310
69793+:107E80000A000962AF8200682419000514B900666F
69794+:107E90003C0580003C0808008D085BE88F86FD9C4F
69795+:107EA000ACA800208E4C00048F8AFDA0240720007F
69796+:107EB000ACCC001C924B000824120008A14B001906
69797+:107EC0008F82005890430009A14300188F85005805
69798+:107ED00090BF000A33E400FF1092001028890009C7
69799+:107EE000152000BA240E0002240D0020108D000B76
69800+:107EF000340780002898002117000008240740005C
69801+:107F000024100040109000053C0700012419008057
69802+:107F1000109900023C070002240740008CC20018A0
69803+:107F20003C03FF00004350240147F825ACDF001854
69804+:107F300090B2000BA0D200278F8300589464000CED
69805+:107F4000108001FE000000009467000C3C1F8000C0
69806+:107F50002405FFBFA4C7005C9063000E2407000443
69807+:107F6000A0C300088F820058904A000FA0CA0009E1
69808+:107F70008F8900588D3200108FE400740244C823AA
69809+:107F8000ACD900588D300014ACD0002C95380018B6
69810+:107F9000330DFFFFACCD00409531001A322FFFFFAB
69811+:107FA000ACCF00448D2E001CACCE00489128000EB2
69812+:107FB000A0C8000890CC000801855824126001B6C2
69813+:107FC000A0CB00088F9200580A000962AF870068B2
69814+:107FD0002406000614A600143C0E80003C0F080086
69815+:107FE0008DEF5BE88F85FD98ADCF00208E4900189E
69816+:107FF0008F86FD9C8F8BFDA0ACA900008CC800383B
69817+:1080000024040005ACA800048CCC003C1260008164
69818+:10801000AD6C00000A000962AF84006824110007FB
69819+:1080200010B1004B240400063C05080024A55BE8C1
69820+:108030000E000881240400818F9200580013102B39
69821+:108040000A000962AF820068241F002314BFFFF6F4
69822+:108050003C0C80003C0508008CA55BE88F8BFDA0E4
69823+:10806000AD8500208F91FD9C8E4600042564002084
69824+:1080700026450014AE260028240600030E000F81BA
69825+:10808000257000308F87005802002021240600034D
69826+:108090000E000F8124E500083C04080024845BE8FE
69827+:1080A0000E0008AA0000000092230000240A0050DD
69828+:1080B000306200FF544AFFE18F9200580E000F6CAF
69829+:1080C000000000000A000A6A8F920058240800335A
69830+:1080D00014A800323C0380003C1108008E315BE89C
69831+:1080E0008F8FFDA0AC7100208E420008240D002867
69832+:1080F0008F89FD9CADE200308E4A000C24060009F9
69833+:10810000ADEA00348E5F0010ADFF00388E440014DD
69834+:10811000ADE400208E590018ADF900248E58001CE3
69835+:10812000ADF80028A1ED00118E4E00041260003160
69836+:10813000AD2E00288F9200580A000962AF860068B1
69837+:10814000240D002214ADFFB8000000002404000735
69838+:108150003C1008008E105BE83C188000AF10002037
69839+:108160005660FEAEAF8400683C04080024845BE8DF
69840+:108170000E0008AA241300508F84FD9C90920000EA
69841+:10818000325900FF1333014B000000008F9200585A
69842+:10819000000020210A000962AF8400683C05080045
69843+:1081A00024A55BE80E000858240400810A000A6A2E
69844+:1081B0008F92005802D498213265FFFF0E000852BA
69845+:1081C000240400840A0009628F920058108EFF5325
69846+:1081D000240704002887000310E00179241100041B
69847+:1081E000240F0001548FFF4D240740000A000A228B
69848+:1081F000240701003C05080024A55BE80E0008A444
69849+:10820000240400828F920058000030210A00096285
69850+:10821000AF8600683C04080024845BE88CC2003808
69851+:108220000E0008AA8CC3003C8F9200580A000AC0B6
69852+:1082300000002021240400823C05080024A55BE8FE
69853+:108240000E0008A4000000008F92005800001021CA
69854+:108250000A000962AF8200688E5000048F91FD9C75
69855+:108260003C078000ACF00020922C00050200282181
69856+:10827000318B0002156001562404008A8F92FDA004
69857+:108280002404008D9245001B30A6002014C001502C
69858+:1082900002002821922E00092408001231C900FF93
69859+:1082A0001128014B240400810E00087202002021D5
69860+:1082B0009258001B240F000402002021370D0042B9
69861+:1082C000A24D001B0E00087CA22F00253C0580005B
69862+:1082D0008CA401780480FFFE34B90140241F000201
69863+:1082E000AF300000A33F00048F9200583C101000F4
69864+:1082F000ACB001780A000A6B0013102B8E500004FA
69865+:108300008F91FD9C3C038000AC700020922A0005F8
69866+:108310000200282131420002144000172404008A80
69867+:10832000922C00092412000402002821318B00FF46
69868+:1083300011720011240400810E0008720200202135
69869+:108340008F89FDA0240800122405FFFE912F001B39
69870+:108350000200202135EE0020A12E001BA2280009DA
69871+:108360009226000500C538240E00087CA2270005CF
69872+:1083700002002821000020210E0009330000000027
69873+:108380000A000A6A8F9200588E4C00043C07800055
69874+:108390003C10080026105BE8ACEC00203C01080013
69875+:1083A000AC2C5BE8924B0003317100041220013BBE
69876+:1083B0008F84FD9C24020006A0820009924F001BBE
69877+:1083C000240EFFC031E9003F012E4025A08800089F
69878+:1083D0009245000330A6000114C0013200000000E5
69879+:1083E0008E420008AE0200083C0208008C425BF09E
69880+:1083F000104001318F90FDA0000219C28F8DFD9CAD
69881+:10840000A603000C8E4A000C24180001240400145A
69882+:10841000AE0A002C8E420010AE02001C965F0016C1
69883+:10842000A61F003C96590014A619003EADB8000CDA
69884+:10843000A5B80010A5B80012A5B80014A5B800167C
69885+:1084400012600144A2040011925100033232000272
69886+:108450002E5300018F920058266200080A0009621C
69887+:10846000AF8200688E4400043C1980003C068008FE
69888+:10847000AF2400208E45000890D80000240D005045
69889+:10848000331100FF122D009C2407008824060009E8
69890+:108490000E000845000000000A000A6A8F9200588A
69891+:1084A0008E5000043C0980003C118008AD30002053
69892+:1084B0009228000024050050310400FF10850110AF
69893+:1084C0002407008802002021000028210E00084512
69894+:1084D0002406000E922D00002418FF80020028219F
69895+:1084E00001B8802524040004240600300E0007256E
69896+:1084F000A23000000A000A6A8F9200588E500004D1
69897+:108500008F91FDA03C028000AC500020923F001BE8
69898+:1085100033F900101320006C240700810200202191
69899+:10852000000028212406001F0E000845000000005E
69900+:108530000A000A6A8F9200588E44001C0E00085DE3
69901+:1085400000000000104000E3004048218F880058E0
69902+:1085500024070089012020218D05001C240600012C
69903+:108560000E000845000000000A000A6A8F920058B9
69904+:10857000964900023C10080026105BE831280004F0
69905+:10858000110000973C0460008E4E001C3C0F8000E0
69906+:10859000ADEE00203C010800AC2E5BE896470002DF
69907+:1085A00030E40001148000E6000000008E42000468
69908+:1085B000AE0200083C1008008E105BF0120000ECC8
69909+:1085C0003C0F80008F92FD9C241000018E4E0018FD
69910+:1085D0008F8DFDA08F9FFD9801CF4825AE490018D3
69911+:1085E000A2400005AE50000C3C0808008D085BF06E
69912+:1085F0008F840058A6500010000839C2A6500012FF
69913+:10860000A6500014A6500016A5A7000C8C8C0008DC
69914+:108610008F8B00588F8A0058ADAC002C8D63000CF6
69915+:1086200024070002ADA3001C91460010A1A6001172
69916+:108630008F82005890450011A3E500088F990058DB
69917+:1086400093380012A258004E8F910058922F0013B9
69918+:10865000A1AF00128F920058964E0014A5AE003CB8
69919+:1086600096490016A5A9003E8E480018ADA8001432
69920+:108670005660FD6AAF8700683C05080024A55BE8EA
69921+:108680000E000881000020218F9200580000382140
69922+:108690000A000962AF8700683C05080024A55BE872
69923+:1086A0000E0008A4240400828F9200580A000A4D8C
69924+:1086B000000038210E000F6C000000008F9200585F
69925+:1086C0000A000AC0000020210E00087202002021CA
69926+:1086D0009223001B02002021346A00100E00087C47
69927+:1086E000A22A001B000038210200202100002821BE
69928+:1086F0000A000BA52406001F9242000C305F000107
69929+:1087000013E0000300000000964A000EA4CA002CEB
69930+:10871000924B000C316300025060000600003821CB
69931+:108720008E470014964C0012ACC7001CA4CC001A53
69932+:10873000000038210A000B7F240600093C050800D0
69933+:1087400024A55BE80E0008A42404008B8F92005837
69934+:108750000A000A4D0013382B3C0C08008D8C5BE896
69935+:1087600024DFFFFE25930100326B007F016790211B
69936+:1087700002638824AD110028AE4600E0AE4000E45C
69937+:108780000A0009B3AE5F001CACC000543C0D0800E9
69938+:108790008DAD5BE83C18800C37090100ACED00287A
69939+:1087A0008E510014AD3100E08E4F0014AD2F00E467
69940+:1087B0008E4E001025C7FFFE0A0009F4AD27001CED
69941+:1087C0005491FDD6240740000A000A222407100015
69942+:1087D0000E00092D000000000A000A6A8F9200585E
69943+:1087E0008C83442C3C12DEAD3651BEEF3C010800B8
69944+:1087F000AC205BE810710062000000003C196C6264
69945+:1088000037387970147800082404000297850074C2
69946+:108810009782006C2404009200A2F82B13E0001948
69947+:1088200002002821240400020E00069524050200FF
69948+:108830003C068000ACC200203C010800AC225BE892
69949+:108840001040000D8F8C0058240A002824040003D7
69950+:10885000918B0010316300FF546A00012404000171
69951+:108860000E0000810000000010400004240400837A
69952+:108870000A000BC28F920058240400833C050800B4
69953+:1088800024A55BE80E000881000000008F920058CC
69954+:108890000013382B0A000962AF8700680A000B49F1
69955+:1088A000240200128E4400080E00085D0000000043
69956+:1088B0000A000B55AE0200083C05080024A55BE841
69957+:1088C0000E000858240400878F9200580A000B728B
69958+:1088D0000013102B240400040E000695240500301C
69959+:1088E0001440002A004048218F8800582407008344
69960+:1088F000012020218D05001C0A000BB32406000175
69961+:108900008F8300788F8600701066FEEE000038219D
69962+:108910003C07080024E75B6C000320C00087282187
69963+:108920008CAE000011D0005D246F000131E3000F18
69964+:108930005466FFFA000320C00A000B8C00003821A7
69965+:108940008E4400040E00085D000000000A000BC801
69966+:10895000AE0200083C05080024A55BE80E0008A450
69967+:10896000240400828F9200580A000B72000010212C
69968+:108970003C05080024A55BE80A000C7C2404008761
69969+:108980008C83442C0A000C5B3C196C628F88005865
69970+:108990003C0780083C0C8000240B0050240A000196
69971+:1089A000AD820020A0EB0000A0EA000191030004CA
69972+:1089B000A0E3001891040005A0E400199106000648
69973+:1089C0003C04080024845B6CA0E6001A91020007B6
69974+:1089D0003C06080024C65B68A0E2001B9105000865
69975+:1089E000A0E5001C911F0009A0FF001D9119000ABD
69976+:1089F000A0F9001E9118000BA0F8001F9112000CA6
69977+:108A0000A0F200209111000DA0F100219110000EA4
69978+:108A1000A0F00022910F000FA0EF0023910E001094
69979+:108A2000A0EE0024910D0011A0ED0025950C00147E
69980+:108A3000A4EC0028950B00168F8A00708F920078A6
69981+:108A4000A4EB002A95030018000A10C02545000178
69982+:108A5000A4E3002C8D1F001C0044C0210046C82147
69983+:108A600030A5000FAF3F0000AF09000010B20006B4
69984+:108A7000AF850070000038218D05001C01202021E9
69985+:108A80000A000BB32406000124AD000131A7000F3A
69986+:108A9000AF8700780A000CF9000038213C06080076
69987+:108AA00024C65B680086902100003821ACA000003D
69988+:108AB0000A000B8CAE4000003C0482013C036000C5
69989+:108AC00034820E02AC603D68AF80009803E000087D
69990+:108AD000AC623D6C27BDFFE8AFB000103090FFFFE7
69991+:108AE000001018422C620041AFBF00141440000275
69992+:108AF00024040080240300403C010800AC300060E6
69993+:108B00003C010800AC2300640E000F7500602821B2
69994+:108B1000244802BF2409FF8001092824001039805D
69995+:108B2000001030408FBF00148FB0001000A720212C
69996+:108B300000861821AF8300803C010800AC25005856
69997+:108B40003C010800AC24005C03E0000827BD0018CD
69998+:108B5000308300FF30C6FFFF30E400FF3C08800098
69999+:108B60008D0201B80440FFFE000354000144382583
70000+:108B70003C09600000E920253C031000AD050180A0
70001+:108B8000AD060184AD04018803E00008AD0301B81F
70002+:108B90008F8500583C0A6012354800108CAC0004E8
70003+:108BA0003C0D600E35A60010318B00062D690001CA
70004+:108BB000AD0900C48CA70004ACC731808CA20008AA
70005+:108BC00094A40002ACC231848CA3001C0460000396
70006+:108BD000A784009003E00008000000008CAF00189C
70007+:108BE000ACCF31D08CAE001C03E00008ACCE31D449
70008+:108BF0008F8500588F87FF288F86FF308CAE00044A
70009+:108C00003C0F601235E80010ACEE00788CAD000827
70010+:108C1000ACED007C8CAC0010ACCC004C8CAB000CF0
70011+:108C2000ACCB004894CA00543C0208008C4200447B
70012+:108C300025490001A4C9005494C400543083FFFFA7
70013+:108C400010620017000000003C0208008C42004047
70014+:108C5000A4C200528CA30018ACE300308CA2001414
70015+:108C6000ACE2002C8CB90018ACF900388CB80014B8
70016+:108C700024050001ACF800348D0600BC50C5001975
70017+:108C80008D0200B48D0200B8A4E2004894E40048CC
70018+:108C9000A4E4004A94E800EA03E000083102FFFF80
70019+:108CA0003C0208008C420024A4C00054A4C200521C
70020+:108CB0008CA30018ACE300308CA20014ACE2002CB2
70021+:108CC0008CB90018ACF900388CB8001424050001E8
70022+:108CD000ACF800348D0600BC54C5FFEB8D0200B823
70023+:108CE0008D0200B4A4E2004894E40048A4E4004AE1
70024+:108CF00094E800EA03E000083102FFFF8F86005885
70025+:108D00003C0480008CC900088CC80008000929C0F8
70026+:108D1000000839C0AC87002090C30007306200040F
70027+:108D20001040003EAF85009490CB0007316A0008E8
70028+:108D30001140003D8F87FF2C8CCD000C8CCE001491
70029+:108D400001AE602B11800036000000008CC2000CC8
70030+:108D5000ACE200708CCB00188F85FF288F88FF3025
70031+:108D6000ACEB00748CCA00102402FFF8ACAA00D847
70032+:108D70008CC9000CAD0900608CC4001CACA400D0F0
70033+:108D800090E3007C0062C824A0F9007C90D8000722
70034+:108D9000330F000811E000040000000090ED007C9B
70035+:108DA00035AC0001A0EC007C90CF000731EE000153
70036+:108DB00011C000060000000090E3007C241800347D
70037+:108DC00034790002A0F9007CACB800DC90C2000746
70038+:108DD0003046000210C000040000000090E8007C53
70039+:108DE00035040004A0E4007C90ED007D3C0B600E97
70040+:108DF000356A001031AC003FA0EC007D8D4931D4C4
70041+:108E00003127000110E00002240E0001A0AE00098D
70042+:108E100094AF00EA03E0000831E2FFFF8F87FF2CE8
70043+:108E20000A000DAF8CC200140A000DB0ACE0007057
70044+:108E30008F8C005827BDFFD8AFB3001CAFB200180D
70045+:108E4000AFB00010AFBF0020AFB10014918F00157C
70046+:108E50003C13600E3673001031EB000FA38B009CA7
70047+:108E60008D8F00048D8B0008959F0012959900103E
70048+:108E70009584001A9598001E958E001C33EDFFFF17
70049+:108E8000332AFFFF3089FFFF3308FFFF31C7FFFFA1
70050+:108E90003C010800AC2D00243C010800AC29004432
70051+:108EA0003C010800AC2A0040AE683178AE67317CE6
70052+:108EB00091850015959100163C12601236520010F3
70053+:108EC00030A200FF3230FFFFAE623188AE5000B4F6
70054+:108ED00091830014959F0018240600010066C804C1
70055+:108EE00033F8FFFFAE5900B8AE5800BC918E0014A5
70056+:108EF000AF8F00843C08600631CD00FFAE4D00C04E
70057+:108F0000918A00159584000E3C07600A314900FFE4
70058+:108F1000AF8B00883084FFFFAE4900C835110010C8
70059+:108F20000E000D1034F004103C0208008C4200606A
70060+:108F30003C0308008C6300643C0608008CC60058A3
70061+:108F40003C0508008CA5005C8F8400808FBF00204A
70062+:108F5000AE23004CAE65319CAE030054AE4500DC40
70063+:108F6000AE6231A0AE6331A4AE663198AE22004845
70064+:108F70008FB3001CAE0200508FB10014AE4200E06F
70065+:108F8000AE4300E4AE4600D88FB000108FB2001898
70066+:108F90000A00057D27BD0028978500929783007CF5
70067+:108FA00027BDFFE8AFB0001000A3102BAFBF001427
70068+:108FB000240400058F900058104000552409000239
70069+:108FC0000E0006958F850080AF8200942404000374
70070+:108FD0001040004F240900023C0680000E00008172
70071+:108FE000ACC2002024070001240820001040004DDE
70072+:108FF00024040005978E00928F8AFF2C24090050CC
70073+:1090000025C50001A7850092A14900003C0D08007C
70074+:109010008DAD0064240380008F84FF28000D66005E
70075+:10902000AD4C0018A5400006954B000A8F85FF3017
70076+:109030002402FF8001633024A546000A915F000AE4
70077+:109040000000482103E2C825A159000AA0A0000899
70078+:10905000A140004CA08000D5961800029783009094
70079+:109060003C020004A49800EA960F00022418FFBFF7
70080+:1090700025EE2401A48E00BE8E0D0004ACAD00448C
70081+:109080008E0C0008ACAC0040A4A00050A4A000547A
70082+:109090008E0B000C240C0030AC8B00288E060010C8
70083+:1090A000AC860024A480003EA487004EA487005014
70084+:1090B000A483003CAD420074AC8800D8ACA800602A
70085+:1090C000A08700FC909F00D433F9007FA09900D4C2
70086+:1090D000909000D402187824A08F00D4914E007C88
70087+:1090E00035CD0001A14D007C938B009CAD480070F4
70088+:1090F000AC8C00DCA08B00D68F8800888F87008422
70089+:10910000AC8800C4AC8700C8A5400078A540007AB0
70090+:109110008FBF00148FB000100120102103E0000861
70091+:1091200027BD00188F8500940E0007258F860080CC
70092+:109130000A000E9F2409000227BDFFE0AFB0001017
70093+:109140008F900058AFB10014AFBF00188E09000413
70094+:109150000E00054A000921C08E0800048F84FF28F4
70095+:109160008F82FF30000839C03C068000ACC7002069
70096+:10917000948500EA904300131460001C30B1FFFF97
70097+:109180008F8CFF2C918B0008316A00401540000B3A
70098+:10919000000000008E0D0004022030218FBF001857
70099+:1091A0008FB100148FB00010240400220000382179
70100+:1091B000000D29C00A000D2F27BD00200E000098C9
70101+:1091C000000000008E0D0004022030218FBF001827
70102+:1091D0008FB100148FB00010240400220000382149
70103+:1091E000000D29C00A000D2F27BD00200E000090A1
70104+:1091F000000000008E0D0004022030218FBF0018F7
70105+:109200008FB100148FB00010240400220000382118
70106+:10921000000D29C00A000D2F27BD002027BDFFE04B
70107+:10922000AFB200183092FFFFAFB00010AFBF001C0C
70108+:10923000AFB100141240001E000080218F8600583C
70109+:109240008CC500002403000600053F02000514023F
70110+:1092500030E4000714830016304500FF2CA80006F8
70111+:1092600011000040000558803C0C0800258C58BCBB
70112+:10927000016C50218D490000012000080000000011
70113+:109280008F8E0098240D000111CD005024020002A1
70114+:10929000AF820098260900013130FFFF24C800206A
70115+:1092A0000212202B010030211480FFE5AF88005806
70116+:1092B000020010218FBF001C8FB200188FB1001464
70117+:1092C0008FB0001003E0000827BD00209387007EC8
70118+:1092D00054E00034000030210E000DE700000000D3
70119+:1092E0008F8600580A000EFF240200018F87009825
70120+:1092F0002405000210E50031240400130000282199
70121+:1093000000003021240700010E000D2F0000000096
70122+:109310000A000F008F8600588F83009824020002F5
70123+:109320001462FFF6240400120E000D9A00000000E3
70124+:109330008F85009400403021240400120E000D2F70
70125+:10934000000038210A000F008F8600588F83009894
70126+:109350002411000310710029241F0002107FFFCE8A
70127+:1093600026090001240400100000282100003021FB
70128+:109370000A000F1D240700018F91009824060002A7
70129+:109380001626FFF9240400100E000E410000000014
70130+:10939000144000238F9800588F8600580A000EFF53
70131+:1093A00024020003240400140E000D2F00002821C5
70132+:1093B0008F8600580A000EFF240200020E000EA93C
70133+:1093C000000000000A000F008F8600580E000D3FBD
70134+:1093D00000000000241900022404001400002821C9
70135+:1093E0000000302100003821AF9900980E000D2FA9
70136+:1093F000000000000A000F008F8600580E000D5775
70137+:10940000000000008F8500942419000200403021E4
70138+:1094100024040010000038210A000F56AF9900986C
70139+:109420000040382124040010970F0002000028217A
70140+:109430000E000D2F31E6FFFF8F8600580A000F0047
70141+:10944000AF9100988F84FF2C3C077FFF34E6FFFF2D
70142+:109450008C8500182402000100A61824AC83001893
70143+:1094600003E00008A08200053084FFFF30A5FFFF65
70144+:109470001080000700001821308200011040000217
70145+:1094800000042042006518211480FFFB00052840DD
70146+:1094900003E000080060102110C000070000000079
70147+:1094A0008CA2000024C6FFFF24A50004AC820000AB
70148+:1094B00014C0FFFB2484000403E000080000000047
70149+:1094C00010A0000824A3FFFFAC86000000000000ED
70150+:1094D000000000002402FFFF2463FFFF1462FFFA74
70151+:1094E0002484000403E0000800000000000411C010
70152+:1094F00003E000082442024027BDFFE8AFB000109F
70153+:1095000000808021AFBF00140E000F9600A0202124
70154+:1095100000504821240AFF808FBF00148FB0001034
70155+:10952000012A30243127007F3C08800A3C042100B6
70156+:1095300000E8102100C428253C03800027BD001846
70157+:10954000AC650024AF820038AC400000AC6500245C
70158+:1095500003E00008AC4000403C0D08008DAD005811
70159+:1095600000056180240AFF8001A45821016C482174
70160+:10957000012A30243127007F3C08800C3C04210064
70161+:1095800000E8102100C428253C038000AC650028B9
70162+:10959000AF82003403E00008AC40002430A5FFFF98
70163+:1095A0003C0680008CC201B80440FFFE3C086015F8
70164+:1095B00000A838253C031000ACC40180ACC0018475
70165+:1095C000ACC7018803E00008ACC301B83C0D08003B
70166+:1095D0008DAD005800056180240AFF8001A4582148
70167+:1095E000016C4021010A4824000931403107007F05
70168+:1095F00000C728253C04200000A418253C02800058
70169+:10960000AC43083003E00008AF80003427BDFFE81A
70170+:10961000AFB0001000808021AFBF00140E000F9685
70171+:1096200000A0202100504821240BFF80012B502452
70172+:10963000000A39403128007F3C0620008FBF00140B
70173+:109640008FB0001000E8282534C2000100A21825C0
70174+:109650003C04800027BD0018AC83083003E00008FC
70175+:10966000AF8000383C0580088CA700603C0680086D
70176+:109670000087102B144000112C8340008CA8006040
70177+:109680002D0340001060000F240340008CC90060CF
70178+:109690000089282B14A00002008018218CC30060D0
70179+:1096A00000035A42000B30803C0A0800254A59202A
70180+:1096B00000CA202103E000088C8200001460FFF340
70181+:1096C0002403400000035A42000B30803C0A08008B
70182+:1096D000254A592000CA202103E000088C8200009E
70183+:1096E0003C05800890A60008938400AB24C20001CA
70184+:1096F000304200FF3043007F1064000C0002382726
70185+:10970000A0A200083C0480008C85017804A0FFFE24
70186+:109710008F8A00A0240900023C081000AC8A014096
70187+:10972000A089014403E00008AC8801780A00101BFE
70188+:1097300030E2008027BDFFD8AFB200188F9200A49E
70189+:10974000AFBF0020AFB3001CAFB00010AFB100142A
70190+:109750008F9300348E5900283C1000803C0EFFEFA0
70191+:10976000AE7900008E580024A260000A35CDFFFFBC
70192+:10977000AE7800049251002C3C0BFF9F356AFFFF2E
70193+:10978000A271000C8E6F000C3C080040A271000B0F
70194+:1097900001F06025018D4824012A382400E8302595
70195+:1097A000AE66000C8E450004AE6000183C0400FF5D
70196+:1097B000AE6500148E43002C3482FFFFA6600008C3
70197+:1097C0000062F824AE7F00108E5900088F9000A030
70198+:1097D000964E0012AE7900208E51000C31D83FFF1A
70199+:1097E00000187980AE7100248E4D001401F06021C4
70200+:1097F00031CB0001AE6D00288E4A0018000C41C22A
70201+:10980000000B4B80AE6A002C8E46001C01093821EB
70202+:10981000A667001CAE660030964500028E4400200C
70203+:10982000A665001EAE64003492430033306200042B
70204+:1098300054400006924700003C0280083443010077
70205+:109840008C7F00D0AE7F0030924700008F860038BA
70206+:10985000A0C700309245003330A4000250800007BA
70207+:10986000925100018F880038240BFF80910A00304C
70208+:10987000014B4825A1090030925100018F9000381A
70209+:10988000240CFFBF2404FFDFA21100318F8D0038AC
70210+:109890003C1880083711008091AF003C31EE007F0A
70211+:1098A000A1AE003C8F890038912B003C016C502404
70212+:1098B000A12A003C8F9F00388E68001493E6003C7C
70213+:1098C0002D0700010007114000C4282400A218251C
70214+:1098D000A3E3003C8F87003896590012A4F90032A8
70215+:1098E0008E450004922E007C30B0000300107823D7
70216+:1098F00031ED000300AD102131CC000215800002D3
70217+:1099000024460034244600303C0280083443008062
70218+:10991000907F007C00BFC824333800041700000289
70219+:1099200024C2000400C010218F98003824190002BE
70220+:10993000ACE20034A3190000924F003F8F8E003834
70221+:109940003C0C8008358B0080A1CF00018F9100383E
70222+:10995000924D003F8E440004A62D0002956A005CE3
70223+:109960000E000FF43150FFFF00024B800209382532
70224+:109970003C08420000E82825AE2500048E4400384B
70225+:109980008F850038ACA400188E460034ACA6001CAD
70226+:10999000ACA0000CACA00010A4A00014A4A0001661
70227+:1099A000A4A00020A4A00022ACA000248E62001479
70228+:1099B00050400001240200018FBF00208FB3001C23
70229+:1099C0008FB200188FB100148FB00010ACA2000845
70230+:1099D0000A00101327BD002827BDFFC83C058008DA
70231+:1099E00034A40080AFBF0034AFBE0030AFB7002C4E
70232+:1099F000AFB60028AFB50024AFB40020AFB3001C51
70233+:109A0000AFB20018AFB10014AFB00010948300786B
70234+:109A10009482007A104300512405FFFF0080F0215A
70235+:109A20000A0011230080B821108B004D8FBF003435
70236+:109A30008F8600A03C1808008F18005C2411FF805E
70237+:109A40003C1680000306782101F18024AED0002C62
70238+:109A500096EE007A31EC007F3C0D800E31CB7FFF1B
70239+:109A6000018D5021000B4840012AA82196A4000036
70240+:109A70003C0808008D0800582405FF8030953FFF02
70241+:109A800001061821001539800067C8210325F82434
70242+:109A90003C02010003E290253338007F3C11800C2A
70243+:109AA000AED20028031190219250000D320F000415
70244+:109AB00011E0003702E0982196E3007A96E8007AF8
70245+:109AC00096E5007A2404800031077FFF24E300013B
70246+:109AD00030627FFF00A4F82403E2C825A6F9007ACB
70247+:109AE00096E6007A3C1408008E94006030D67FFF22
70248+:109AF00012D400C1000000008E5800188F8400A00E
70249+:109B000002A028212713FFFF0E000FCEAE53002C1A
70250+:109B100097D5007897D4007A12950010000028217C
70251+:109B20003C098008352401003C0A8008914800085F
70252+:109B3000908700D53114007F30E400FF0284302B81
70253+:109B400014C0FFB9268B0001938E00AB268C000158
70254+:109B5000008E682115ACFFB78F8600A08FBF003440
70255+:109B60008FBE00308FB7002C8FB600288FB5002431
70256+:109B70008FB400208FB3001C8FB200188FB1001477
70257+:109B80008FB0001000A0102103E0000827BD0038AE
70258+:109B900000C020210E000F99028028218E4B00105A
70259+:109BA0008E4C00308F84003824090002016C502351
70260+:109BB000AE4A0010A089000096E3005C8E4400309D
70261+:109BC0008F9100380E000FF43070FFFF00024380C9
70262+:109BD000020838253C02420000E22825AE25000498
70263+:109BE0008E5F00048F8A00388E590000240B000815
70264+:109BF000AD5F001CAD590018AD40000CAD40001029
70265+:109C00009246000A240400052408C00030D000FF5A
70266+:109C1000A550001496580008A55800169251000A45
70267+:109C20003C188008322F00FFA54F0020964E0008F8
70268+:109C300037110100A54E0022AD400024924D000BCB
70269+:109C400031AC00FFA54C0002A14B00018E49003051
70270+:109C50008F830038240BFFBFAC690008A06400307C
70271+:109C60008F9000382403FFDF9607003200E8282495
70272+:109C700000B51025A6020032921F003233F9003FD2
70273+:109C800037260040A20600328F8C0038AD800034A9
70274+:109C90008E2F00D0AD8F0038918E003C3C0F7FFF9F
70275+:109CA00031CD007FA18D003C8F84003835EEFFFF61
70276+:109CB000908A003C014B4824A089003C8F850038E5
70277+:109CC00090A8003C01033824A0A7003C8E42003439
70278+:109CD0008F9100383C038008AE2200408E59002C42
70279+:109CE0008E5F0030033F3023AE26004492300048A0
70280+:109CF0003218007FA23800488F8800388E4D00301F
70281+:109D00008D0C004801AE582401965024014B482583
70282+:109D1000AD0900489244000AA104004C964700088F
70283+:109D20008F850038A4A7004E8E5000308E4400303E
70284+:109D30000E0003818C65006092F9007C0002F940FE
70285+:109D4000004028210002110003E2302133360002D6
70286+:109D500012C00003020680210005B0800216802197
70287+:109D6000926D007C31B30004126000020005708027
70288+:109D7000020E80218E4B00308F8800382405800031
70289+:109D8000316A0003000A4823312400030204182129
70290+:109D9000AD03003496E4007A96F0007A96F1007AEA
70291+:109DA00032027FFF2447000130FF7FFF0225C824D5
70292+:109DB000033F3025A6E6007A96F8007A3C120800A8
70293+:109DC0008E520060330F7FFF11F200180000000078
70294+:109DD0008F8400A00E000FCE02A028218F8400A047
70295+:109DE0000E000FDE028028210E001013000000007C
70296+:109DF0000A00111F0000000096F1007A022480245E
70297+:109E0000A6F0007A92EF007A92EB007A31EE00FF32
70298+:109E1000000E69C2000D6027000C51C03169007F3F
70299+:109E2000012A20250A001119A2E4007A96E6007A98
70300+:109E300000C5C024A6F8007A92EF007A92F3007A67
70301+:109E400031F200FF001271C2000E6827000DB1C090
70302+:109E5000326C007F01962825A2E5007A0A0011D015
70303+:109E60008F8400A03C0380003084FFFF30A5FFFFFB
70304+:109E7000AC640018AC65001C03E000088C620014A0
70305+:109E800027BDFFA03C068008AFBF005CAFBE0058F6
70306+:109E9000AFB70054AFB60050AFB5004CAFB40048F8
70307+:109EA000AFB30044AFB20040AFB1003CAFB0003838
70308+:109EB00034C80100910500D590C700083084FFFF29
70309+:109EC00030A500FF30E2007F0045182AAFA4001043
70310+:109ED000A7A00018A7A0002610600055AFA000148E
70311+:109EE00090CA00083149007F00A9302324D3FFFF26
70312+:109EF0000013802B8FB400100014902B02128824C2
70313+:109F0000522000888FB300143C03800894790052DB
70314+:109F1000947E00508FB60010033EC0230018BC0092
70315+:109F2000001714030016FC0002C2A82A16A00002A3
70316+:109F3000001F2C030040282100133C0000072403CD
70317+:109F400000A4102A5440000100A020212885000907
70318+:109F500014A000020080A021241400083C0C8008FA
70319+:109F60008D860048001459808D88004C3C03800089
70320+:109F70003169FFFF3C0A0010012A202534710400DA
70321+:109F8000AC660038AF9100A4AC68003CAC64003013
70322+:109F900000000000000000000000000000000000C1
70323+:109FA00000000000000000000000000000000000B1
70324+:109FB0008C6E000031CD002011A0FFFD0014782A26
70325+:109FC00001F01024104000390000A8213C16800840
70326+:109FD00092D700083C1280008E44010032F6007FC8
70327+:109FE0000E000F9902C028218E3900108E44010006
70328+:109FF0000000902133373FFF0E000FB102E028210F
70329+:10A00000923800003302003F2C500008520000102C
70330+:10A0100000008821000210803C030800246358E4FB
70331+:10A020000043F8218FFE000003C00008000000007C
70332+:10A0300090CF0008938C00AB31EE007F00AE682318
70333+:10A04000018D58210A0012172573FFFF0000882197
70334+:10A050003C1E80008FC401000E000FCE02E02821BC
70335+:10A060008FC401000E000FDE02C028211220000F55
70336+:10A070000013802B8F8B00A426A400010004AC00E9
70337+:10A08000027298230015AC032578004002B4B02A70
70338+:10A090000013802B241700010300882102D0102414
70339+:10A0A000AF9800A41440FFC9AFB700143C07800864
70340+:10A0B00094E200508FAE00103C05800002A288217F
70341+:10A0C0003C060020A4F10050ACA6003094F40050EF
70342+:10A0D00094EF005201D51823306CFFFF11F4001EDD
70343+:10A0E000AFAC00108CEF004C001561808CF500487F
70344+:10A0F00001EC28210000202100AC582B02A4C02133
70345+:10A10000030BB021ACE5004CACF600488FB4001056
70346+:10A110000014902B021288241620FF7C3C03800838
70347+:10A120008FB300148FBF005C8FBE00583A620001ED
70348+:10A130008FB700548FB600508FB5004C8FB40048D5
70349+:10A140008FB300448FB200408FB1003C8FB0003815
70350+:10A1500003E0000827BD006094FE00548CF2004428
70351+:10A1600033C9FFFE0009C8C00259F821ACBF003C4A
70352+:10A170008CE800448CAD003C010D50231940003B9D
70353+:10A18000000000008CF7004026E20001ACA200387D
70354+:10A190003C05005034A700103C038000AC67003041
70355+:10A1A00000000000000000000000000000000000AF
70356+:10A1B000000000000000000000000000000000009F
70357+:10A1C0008C7800003316002012C0FFFD3C1180087F
70358+:10A1D000962200543C1580003C068008304E000159
70359+:10A1E000000E18C0007578218DEC04003C070800B3
70360+:10A1F0008CE700443C040020ACCC00488DF40404FF
70361+:10A20000240B0001ACD4004C10EB0260AEA4003073
70362+:10A21000963900523C0508008CA5004000B99021F9
70363+:10A22000A6320052963F005427ED0001A62D00549F
70364+:10A230009626005430C4FFFF5487FF2F8FB40010C0
70365+:10A2400030A5FFFF0E0011F4A62000543C070800C3
70366+:10A250008CE70024963E00520047B82303D74823DA
70367+:10A26000A62900520A0012198FB400108CE2004097
70368+:10A270000A0012BE00000000922400012407000121
70369+:10A280003085007F14A7001C97AD00268E2B00148C
70370+:10A29000240CC000316A3FFF01AC48243C06080092
70371+:10A2A0008CC60060012A402531043FFF0086882BC0
70372+:10A2B00012200011A7A800263C0508008CA5005814
70373+:10A2C0008F9100A0000439802402FF8000B1182182
70374+:10A2D0000067F82103E2F02433F8007F3C1280008D
70375+:10A2E0003C19800EAE5E002C0319702191D0000D38
70376+:10A2F000360F0004A1CF000D0E001028241200011B
70377+:10A30000241100013C1E80008FC401000E000FCEFE
70378+:10A3100002E028218FC401000E000FDE02C02821B8
70379+:10A320001620FF558F8B00A40A0012860013802B85
70380+:10A330008F8600A490C80001310400201080019194
70381+:10A34000241000013C048008348B0080916A007C5A
70382+:10A350008F9E0034AFA0002C314900011120000F66
70383+:10A36000AFB000288CCD00148C8E006001AE602B45
70384+:10A370001580000201A038218C8700603C188008FD
70385+:10A38000370300808C70007000F0782B15E000021D
70386+:10A3900000E020218C640070AFA4002C3C028008F7
70387+:10A3A000344500808CD200148CBF0070025FC82B33
70388+:10A3B00017200002024020218CA400708FA7002CDF
70389+:10A3C0000087182310600003AFA3003024050002AB
70390+:10A3D000AFA500288FA400280264882B162000BA9D
70391+:10A3E000000018218CD000388FCE000C3C0F00806C
70392+:10A3F000AFD000008CCD00343C0CFF9F01CF58251E
70393+:10A40000AFCD000490CA003F3586FFFF01662024CF
70394+:10A410003C0900203C08FFEFA3CA000B0089382547
70395+:10A420003511FFFF00F118243C0500088F8700A4B8
70396+:10A430000065C825AFD9000C8CE20014AFC000182D
70397+:10A440008FA60030AFC200148CF800188FB0002C1B
70398+:10A450003C1FFFFBAFD8001C8CEF000837F2FFFF5A
70399+:10A4600003326824AFCF00248CEC000C020670216C
70400+:10A47000AFCD000CA7C00038A7C0003AAFCE002C6B
70401+:10A48000AFCC0020AFC000288CEA00148FAB002CAA
70402+:10A49000014B48230126402311000011AFC80010D2
70403+:10A4A00090EB003D8FC900048FC80000000B5100E5
70404+:10A4B000012A28210000102100AA882B010218215E
70405+:10A4C0000071F821AFC50004AFDF000090F2003D3D
70406+:10A4D000A3D2000A8F9900A497380006A7D80008D5
70407+:10A4E0008F910038240800023C038008A228000055
70408+:10A4F0003465008094BF005C8FA4002C33F0FFFF14
70409+:10A500000E000FF48F9200380002CB808F8500A4DC
70410+:10A51000021978253C18420001F87025AE4E00045F
70411+:10A520008F8400388CAD0038AC8D00188CAC0034B2
70412+:10A53000AC8C001CAC80000CAC800010A48000141B
70413+:10A54000A4800016A4800020A4800022AC800024F7
70414+:10A5500090A6003F8FA7002CA486000250E0019235
70415+:10A56000240700018FA200305040000290A2003D5D
70416+:10A5700090A2003E244A0001A08A00018F84003886
70417+:10A580008FA9002CAC8900083C128008364D008051
70418+:10A5900091AC007C3186000214C000022407003414
70419+:10A5A000240700308F8500A43C198008373F0080C5
70420+:10A5B00090B0000093F9007C240E0004A0900030BD
70421+:10A5C0008F8F00A48FB8002C8F8D003891F200017E
70422+:10A5D0003304000301C46023A1B200318F8E003820
70423+:10A5E0008F8600A42402C00095CA003294C90012CC
70424+:10A5F0008FAB002C0142402431233FFF010388250B
70425+:10A60000A5D1003291D000323185000300EBF82152
70426+:10A610003218003F370F0040A1CF00328FA4002C2A
70427+:10A6200003E5382133280004108000028F850038AC
70428+:10A6300000E838213C0A8008ACA700343549010005
70429+:10A640008D2800D08FA3002C2419FFBFACA80038A0
70430+:10A6500090B1003C2C640001240FFFDF3227007F03
70431+:10A66000A0A7003C8F98003800049140931F003C45
70432+:10A6700003F98024A310003C8F8C0038918E003C9D
70433+:10A6800001CF682401B23025A186003C8F8900A447
70434+:10A690008F8800388D2B0020AD0B00408D220024C8
70435+:10A6A000AD0200448D2A0028AD0A00488D23002CFD
70436+:10A6B0000E001013AD03004C8FB1002824070002D8
70437+:10A6C000122700118FA300280003282B00058023E8
70438+:10A6D0000270982400608021006090210A00126FAF
70439+:10A6E0000010882B962900128F8400A00000902172
70440+:10A6F0003125FFFFA7A900180E000FC22411000189
70441+:10A700000A00131D3C1E80003C0B80003C12800898
70442+:10A710008D640100924900088F92FF340E000F995A
70443+:10A720003125007F8F9900388FA700288FA4003033
70444+:10A73000A3270000965F005C33F0FFFF0E000FF4CC
70445+:10A740008F91003800026B80020D80253C0842008A
70446+:10A750008F8D00A402085025AE2A00048DA5003874
70447+:10A760008F8A003800007821000F1100AD450018D5
70448+:10A770008DB800343C047FFF3488FFFFAD58001CC7
70449+:10A7800091A6003E8D4C001C8D4900180006190052
70450+:10A79000000677020183C821004E58250323882B29
70451+:10A7A000012B382100F1F821AD59001CAD5F0018D4
70452+:10A7B000AD40000CAD40001091B0003E8FA40030C1
70453+:10A7C00024090005A550001495A500042419C00013
70454+:10A7D00000884024A545001691B8003EA5580020E9
70455+:10A7E00095AF0004A54F0022AD40002491AE003F7C
70456+:10A7F000A54E000291A6003E91AC003D01861023BB
70457+:10A80000244B0001A14B00018F9100388FA3003031
70458+:10A810003C028008344B0100AE230008A22900301E
70459+:10A820008F8C00388F8700A4959F003294F000121F
70460+:10A830002407FFBF033FC02432053FFF03057825EF
70461+:10A84000A58F0032918E00322418FFDF31CD003FFA
70462+:10A8500035A60040A18600328F910038240DFFFFFD
70463+:10A86000240CFF80AE2000348D6A00D0AE2A003860
70464+:10A870009223003C3069007FA229003C8F90003871
70465+:10A880003C0380009219003C0327F824A21F003CDF
70466+:10A890008F8E003891C5003C00B87824A1CF003CD1
70467+:10A8A0008F8A00383C0E8008AD4D00408FA6002CEA
70468+:10A8B000AD46004491420048004C5825A14B004849
70469+:10A8C0008F9000388F9900A48E09004801238824B6
70470+:10A8D00002283825AE070048933F003EA21F004CD7
70471+:10A8E0008F9800A48F8F003897050004A5E5004ECF
70472+:10A8F0000E0003818DC500609246007C8FAC003055
70473+:10A9000000026940000291000040282130CB000283
70474+:10A9100001B21021156000AA018230213C0E80088E
70475+:10A9200035C20080904C007C31830004106000032D
70476+:10A930008FB900300005788000CF3021241F00043B
70477+:10A940008F910038332D000303ED8023320800037C
70478+:10A9500000C85021AE2A00343C188000A7C500383A
70479+:10A960003C0680088F04010090DE00080E000FDE18
70480+:10A9700033C5007F0E001013000000000A00140D04
70481+:10A980008FA300288F9800348CC90038241F00033F
70482+:10A99000A7000008AF0900008CC50034A300000A1E
70483+:10A9A0008F9900A4AF0500043C080080932D003F60
70484+:10A9B000A31F000C8F0A000C3C02FF9FA30D000B8D
70485+:10A9C0000148F0253451FFFF3C12FFEF8F9900A49E
70486+:10A9D00003D170243646FFFF01C61824AF03000CD4
70487+:10A9E0008F2C0014972900128F8400A0AF0C001048
70488+:10A9F0008F2F0014AF000018AF000020AF0F00141D
70489+:10AA0000AF0000248F270018312F3FFF000F59801F
70490+:10AA1000AF0700288F2500080164F821312D0001BF
70491+:10AA2000AF0500308F31000C8F920038001F51C2EB
70492+:10AA3000000D438001481021241E00023C068008BE
70493+:10AA4000A702001CA7000034AF11002CA25E00007A
70494+:10AA500034D20080964E005C8F9900383C0342004F
70495+:10AA600031CCFFFF01833825AF2700048F8B00A472
70496+:10AA7000240500012402C0008D640038240700343E
70497+:10AA8000AF2400188D690034AF29001CAF20000CE2
70498+:10AA9000AF200010A7200014A7200016A720002038
70499+:10AAA000A7200022AF200024A7300002A325000128
70500+:10AAB0008F8800388F9F00A4AD10000893ED000030
70501+:10AAC000A10D00308F8A00A48F98003891510001A9
70502+:10AAD000A31100318F8B0038957E003203C27024A1
70503+:10AAE00001CF6025A56C0032916300323064003FD5
70504+:10AAF000A16400329249007C3125000214A00002BA
70505+:10AB00008F840038240700303C198008AC8700345B
70506+:10AB1000373201008E5F00D0240AFFBF020090216F
70507+:10AB2000AC9F0038908D003C31A8007FA088003C8D
70508+:10AB30008F9E003893C2003C004A8824A3D1003C79
70509+:10AB40008F8300380010882B9066003C34CE0020A4
70510+:10AB5000A06E003C8F8400A48F9800388C8C00205D
70511+:10AB6000AF0C00408C8F0024AF0F00448C8700286E
70512+:10AB7000AF0700488C8B002CAF0B004C0E0010135D
70513+:10AB80003C1E80000A0012700000000094C80052B1
70514+:10AB90003C0A08008D4A002401488821A4D10052B3
70515+:10ABA0000A0012198FB40010A08700018F840038AA
70516+:10ABB000240B0001AC8B00080A0013BE3C12800875
70517+:10ABC000000520800A0014A200C4302127BDFFE048
70518+:10ABD0003C0D8008AFB20018AFB00010AFBF001C32
70519+:10ABE000AFB1001435B200808E4C001835A80100BA
70520+:10ABF000964B000695A70050910900FC000C5602E8
70521+:10AC0000016728233143007F312600FF240200031F
70522+:10AC1000AF8300A8AF8400A010C2001B30B0FFFFBC
70523+:10AC2000910600FC2412000530C200FF10520033D0
70524+:10AC300000000000160000098FBF001C8FB2001832
70525+:10AC40008FB100148FB00010240D0C003C0C80005C
70526+:10AC500027BD002003E00008AD8D00240E0011FB8D
70527+:10AC6000020020218FBF001C8FB200188FB100148A
70528+:10AC70008FB00010240D0C003C0C800027BD00207C
70529+:10AC800003E00008AD8D0024965800789651007AB4
70530+:10AC9000924E007D0238782631E8FFFF31C400C0B3
70531+:10ACA000148000092D11000116000037000000007B
70532+:10ACB0005620FFE28FBF001C0E0010D100000000E4
70533+:10ACC0000A00156A8FBF001C1620FFDA0000000082
70534+:10ACD0000E0010D1000000001440FFD88FBF001CF0
70535+:10ACE0001600002200000000925F007D33E2003F6A
70536+:10ACF000A242007D0A00156A8FBF001C950900EA78
70537+:10AD00008F86008000802821240400050E0007257E
70538+:10AD10003130FFFF978300923C0480002465FFFFE1
70539+:10AD2000A78500928C8A01B80540FFFE0000000054
70540+:10AD3000AC8001808FBF001CAC9001848FB20018E2
70541+:10AD40008FB100148FB000103C0760133C0B100053
70542+:10AD5000240D0C003C0C800027BD0020AC8701882E
70543+:10AD6000AC8B01B803E00008AD8D00240E0011FB90
70544+:10AD7000020020215040FFB18FBF001C925F007D78
70545+:10AD80000A00159733E2003F0E0011FB020020215C
70546+:10AD90001440FFAA8FBF001C122000070000000013
70547+:10ADA0009259007D3330003F36020040A242007DC0
70548+:10ADB0000A00156A8FBF001C0E0010D100000000B1
70549+:10ADC0005040FF9E8FBF001C9259007D3330003FE2
70550+:10ADD0000A0015C636020040000000000000001BFB
70551+:10ADE0000000000F0000000A00000008000000063C
70552+:10ADF0000000000500000005000000040000000441
70553+:10AE00000000000300000003000000030000000336
70554+:10AE10000000000300000002000000020000000229
70555+:10AE2000000000020000000200000002000000021A
70556+:10AE3000000000020000000200000002000000020A
70557+:10AE400000000002000000020000000200000002FA
70558+:10AE50000000000100000001000000018008010066
70559+:10AE6000800800808008000000000C000000308096
70560+:10AE7000080011D00800127C08001294080012A8E3
70561+:10AE8000080012BC080011D0080011D0080012F010
70562+:10AE90000800132C080013400800138808001A8CBF
70563+:10AEA00008001A8C08001AC408001AC408001AD82E
70564+:10AEB00008001AA808001D0008001CCC08001D5836
70565+:10AEC00008001D5808001DE008001D108008024001
70566+:10AED000080027340800256C0800275C080027F4C8
70567+:10AEE0000800293C0800298808002AAC080029B479
70568+:10AEF00008002A38080025DC08002EDC08002EA4F3
70569+:10AF000008002588080025880800258808002B20CF
70570+:10AF100008002B20080025880800258808002DD06F
70571+:10AF2000080025880800258808002588080025884D
70572+:10AF300008002E0C080025880800258808002588B0
70573+:10AF4000080025880800258808002588080025882D
70574+:10AF5000080025880800258808002588080025881D
70575+:10AF6000080025880800258808002588080029A8E9
70576+:10AF7000080025880800258808002E680800258814
70577+:10AF800008002588080025880800258808002588ED
70578+:10AF900008002588080025880800258808002588DD
70579+:10AFA00008002588080025880800258808002588CD
70580+:10AFB00008002588080025880800258808002588BD
70581+:10AFC00008002CF4080025880800258808002C6853
70582+:10AFD00008002BC408003CE408003CB808003C848E
70583+:10AFE00008003C5808003C3808003BEC8008010091
70584+:10AFF00080080080800800008008008008004C6401
70585+:10B0000008004C9C08004BE408004C6408004C64A9
70586+:10B01000080049B808004C64080050500A000C842D
70587+:10B0200000000000000000000000000D7278703683
70588+:10B030002E322E31620000000602010300000000E3
70589+:10B0400000000001000000000000000000000000FF
70590+:10B0500000000000000000000000000000000000F0
70591+:10B0600000000000000000000000000000000000E0
70592+:10B0700000000000000000000000000000000000D0
70593+:10B0800000000000000000000000000000000000C0
70594+:10B0900000000000000000000000000000000000B0
70595+:10B0A00000000000000000000000000000000000A0
70596+:10B0B0000000000000000000000000000000000090
70597+:10B0C0000000000000000000000000000000000080
70598+:10B0D0000000000000000000000000000000000070
70599+:10B0E0000000000000000000000000000000000060
70600+:10B0F0000000000000000000000000000000000050
70601+:10B10000000000000000000000000000000000003F
70602+:10B11000000000000000000000000000000000002F
70603+:10B12000000000000000000000000000000000001F
70604+:10B13000000000000000000000000000000000000F
70605+:10B1400000000000000000000000000000000000FF
70606+:10B1500000000000000000000000000000000000EF
70607+:10B1600000000000000000000000000000000000DF
70608+:10B1700000000000000000000000000000000000CF
70609+:10B1800000000000000000000000000000000000BF
70610+:10B1900000000000000000000000000000000000AF
70611+:10B1A000000000000000000000000000000000009F
70612+:10B1B000000000000000000000000000000000008F
70613+:10B1C000000000000000000000000000000000007F
70614+:10B1D000000000000000000000000000000000006F
70615+:10B1E000000000000000000000000000000000005F
70616+:10B1F000000000000000000000000000000000004F
70617+:10B20000000000000000000000000000000000003E
70618+:10B21000000000000000000000000000000000002E
70619+:10B22000000000000000000000000000000000001E
70620+:10B23000000000000000000000000000000000000E
70621+:10B2400000000000000000000000000000000000FE
70622+:10B2500000000000000000000000000000000000EE
70623+:10B2600000000000000000000000000000000000DE
70624+:10B2700000000000000000000000000000000000CE
70625+:10B2800000000000000000000000000000000000BE
70626+:10B2900000000000000000000000000000000000AE
70627+:10B2A000000000000000000000000000000000009E
70628+:10B2B000000000000000000000000000000000008E
70629+:10B2C000000000000000000000000000000000007E
70630+:10B2D000000000000000000000000000000000006E
70631+:10B2E000000000000000000000000000000000005E
70632+:10B2F000000000000000000000000000000000004E
70633+:10B30000000000000000000000000000000000003D
70634+:10B31000000000000000000000000000000000002D
70635+:10B32000000000000000000000000000000000001D
70636+:10B33000000000000000000000000000000000000D
70637+:10B3400000000000000000000000000000000000FD
70638+:10B3500000000000000000000000000000000000ED
70639+:10B3600000000000000000000000000000000000DD
70640+:10B3700000000000000000000000000000000000CD
70641+:10B3800000000000000000000000000000000000BD
70642+:10B3900000000000000000000000000000000000AD
70643+:10B3A000000000000000000000000000000000009D
70644+:10B3B000000000000000000000000000000000008D
70645+:10B3C000000000000000000000000000000000007D
70646+:10B3D000000000000000000000000000000000006D
70647+:10B3E000000000000000000000000000000000005D
70648+:10B3F000000000000000000000000000000000004D
70649+:10B40000000000000000000000000000000000003C
70650+:10B41000000000000000000000000000000000002C
70651+:10B42000000000000000000000000000000000001C
70652+:10B43000000000000000000000000000000000000C
70653+:10B4400000000000000000000000000000000000FC
70654+:10B4500000000000000000000000000000000000EC
70655+:10B4600000000000000000000000000000000000DC
70656+:10B4700000000000000000000000000000000000CC
70657+:10B4800000000000000000000000000000000000BC
70658+:10B4900000000000000000000000000000000000AC
70659+:10B4A000000000000000000000000000000000009C
70660+:10B4B000000000000000000000000000000000008C
70661+:10B4C000000000000000000000000000000000007C
70662+:10B4D000000000000000000000000000000000006C
70663+:10B4E000000000000000000000000000000000005C
70664+:10B4F000000000000000000000000000000000004C
70665+:10B50000000000000000000000000000000000003B
70666+:10B51000000000000000000000000000000000002B
70667+:10B52000000000000000000000000000000000001B
70668+:10B53000000000000000000000000000000000000B
70669+:10B5400000000000000000000000000000000000FB
70670+:10B5500000000000000000000000000000000000EB
70671+:10B5600000000000000000000000000000000000DB
70672+:10B5700000000000000000000000000000000000CB
70673+:10B5800000000000000000000000000000000000BB
70674+:10B5900000000000000000000000000000000000AB
70675+:10B5A000000000000000000000000000000000009B
70676+:10B5B000000000000000000000000000000000008B
70677+:10B5C000000000000000000000000000000000007B
70678+:10B5D000000000000000000000000000000000006B
70679+:10B5E000000000000000000000000000000000005B
70680+:10B5F000000000000000000000000000000000004B
70681+:10B60000000000000000000000000000000000003A
70682+:10B61000000000000000000000000000000000002A
70683+:10B62000000000000000000000000000000000001A
70684+:10B63000000000000000000000000000000000000A
70685+:10B6400000000000000000000000000000000000FA
70686+:10B6500000000000000000000000000000000000EA
70687+:10B6600000000000000000000000000000000000DA
70688+:10B6700000000000000000000000000000000000CA
70689+:10B6800000000000000000000000000000000000BA
70690+:10B6900000000000000000000000000000000000AA
70691+:10B6A000000000000000000000000000000000009A
70692+:10B6B000000000000000000000000000000000008A
70693+:10B6C000000000000000000000000000000000007A
70694+:10B6D000000000000000000000000000000000006A
70695+:10B6E000000000000000000000000000000000005A
70696+:10B6F000000000000000000000000000000000004A
70697+:10B700000000000000000000000000000000000039
70698+:10B710000000000000000000000000000000000029
70699+:10B720000000000000000000000000000000000019
70700+:10B730000000000000000000000000000000000009
70701+:10B7400000000000000000000000000000000000F9
70702+:10B7500000000000000000000000000000000000E9
70703+:10B7600000000000000000000000000000000000D9
70704+:10B7700000000000000000000000000000000000C9
70705+:10B7800000000000000000000000000000000000B9
70706+:10B7900000000000000000000000000000000000A9
70707+:10B7A0000000000000000000000000000000000099
70708+:10B7B0000000000000000000000000000000000089
70709+:10B7C0000000000000000000000000000000000079
70710+:10B7D0000000000000000000000000000000000069
70711+:10B7E0000000000000000000000000000000000059
70712+:10B7F0000000000000000000000000000000000049
70713+:10B800000000000000000000000000000000000038
70714+:10B810000000000000000000000000000000000028
70715+:10B820000000000000000000000000000000000018
70716+:10B830000000000000000000000000000000000008
70717+:10B8400000000000000000000000000000000000F8
70718+:10B8500000000000000000000000000000000000E8
70719+:10B8600000000000000000000000000000000000D8
70720+:10B8700000000000000000000000000000000000C8
70721+:10B8800000000000000000000000000000000000B8
70722+:10B8900000000000000000000000000000000000A8
70723+:10B8A0000000000000000000000000000000000098
70724+:10B8B0000000000000000000000000000000000088
70725+:10B8C0000000000000000000000000000000000078
70726+:10B8D0000000000000000000000000000000000068
70727+:10B8E0000000000000000000000000000000000058
70728+:10B8F0000000000000000000000000000000000048
70729+:10B900000000000000000000000000000000000037
70730+:10B910000000000000000000000000000000000027
70731+:10B920000000000000000000000000000000000017
70732+:10B930000000000000000000000000000000000007
70733+:10B9400000000000000000000000000000000000F7
70734+:10B9500000000000000000000000000000000000E7
70735+:10B9600000000000000000000000000000000000D7
70736+:10B9700000000000000000000000000000000000C7
70737+:10B9800000000000000000000000000000000000B7
70738+:10B9900000000000000000000000000000000000A7
70739+:10B9A0000000000000000000000000000000000097
70740+:10B9B0000000000000000000000000000000000087
70741+:10B9C0000000000000000000000000000000000077
70742+:10B9D0000000000000000000000000000000000067
70743+:10B9E0000000000000000000000000000000000057
70744+:10B9F0000000000000000000000000000000000047
70745+:10BA00000000000000000000000000000000000036
70746+:10BA10000000000000000000000000000000000026
70747+:10BA20000000000000000000000000000000000016
70748+:10BA30000000000000000000000000000000000006
70749+:10BA400000000000000000000000000000000000F6
70750+:10BA500000000000000000000000000000000000E6
70751+:10BA600000000000000000000000000000000000D6
70752+:10BA700000000000000000000000000000000000C6
70753+:10BA800000000000000000000000000000000000B6
70754+:10BA900000000000000000000000000000000000A6
70755+:10BAA0000000000000000000000000000000000096
70756+:10BAB0000000000000000000000000000000000086
70757+:10BAC0000000000000000000000000000000000076
70758+:10BAD0000000000000000000000000000000000066
70759+:10BAE0000000000000000000000000000000000056
70760+:10BAF0000000000000000000000000000000000046
70761+:10BB00000000000000000000000000000000000035
70762+:10BB10000000000000000000000000000000000025
70763+:10BB20000000000000000000000000000000000015
70764+:10BB30000000000000000000000000000000000005
70765+:10BB400000000000000000000000000000000000F5
70766+:10BB500000000000000000000000000000000000E5
70767+:10BB600000000000000000000000000000000000D5
70768+:10BB700000000000000000000000000000000000C5
70769+:10BB800000000000000000000000000000000000B5
70770+:10BB900000000000000000000000000000000000A5
70771+:10BBA0000000000000000000000000000000000095
70772+:10BBB0000000000000000000000000000000000085
70773+:10BBC0000000000000000000000000000000000075
70774+:10BBD0000000000000000000000000000000000065
70775+:10BBE0000000000000000000000000000000000055
70776+:10BBF0000000000000000000000000000000000045
70777+:10BC00000000000000000000000000000000000034
70778+:10BC10000000000000000000000000000000000024
70779+:10BC20000000000000000000000000000000000014
70780+:10BC30000000000000000000000000000000000004
70781+:10BC400000000000000000000000000000000000F4
70782+:10BC500000000000000000000000000000000000E4
70783+:10BC600000000000000000000000000000000000D4
70784+:10BC700000000000000000000000000000000000C4
70785+:10BC800000000000000000000000000000000000B4
70786+:10BC900000000000000000000000000000000000A4
70787+:10BCA0000000000000000000000000000000000094
70788+:10BCB0000000000000000000000000000000000084
70789+:10BCC0000000000000000000000000000000000074
70790+:10BCD0000000000000000000000000000000000064
70791+:10BCE0000000000000000000000000000000000054
70792+:10BCF0000000000000000000000000000000000044
70793+:10BD00000000000000000000000000000000000033
70794+:10BD10000000000000000000000000000000000023
70795+:10BD20000000000000000000000000000000000013
70796+:10BD30000000000000000000000000000000000003
70797+:10BD400000000000000000000000000000000000F3
70798+:10BD500000000000000000000000000000000000E3
70799+:10BD600000000000000000000000000000000000D3
70800+:10BD700000000000000000000000000000000000C3
70801+:10BD800000000000000000000000000000000000B3
70802+:10BD900000000000000000000000000000000000A3
70803+:10BDA0000000000000000000000000000000000093
70804+:10BDB0000000000000000000000000000000000083
70805+:10BDC0000000000000000000000000000000000073
70806+:10BDD0000000000000000000000000000000000063
70807+:10BDE0000000000000000000000000000000000053
70808+:10BDF0000000000000000000000000000000000043
70809+:10BE00000000000000000000000000000000000032
70810+:10BE10000000000000000000000000000000000022
70811+:10BE20000000000000000000000000000000000012
70812+:10BE30000000000000000000000000000000000002
70813+:10BE400000000000000000000000000000000000F2
70814+:10BE500000000000000000000000000000000000E2
70815+:10BE600000000000000000000000000000000000D2
70816+:10BE700000000000000000000000000000000000C2
70817+:10BE800000000000000000000000000000000000B2
70818+:10BE900000000000000000000000000000000000A2
70819+:10BEA0000000000000000000000000000000000092
70820+:10BEB0000000000000000000000000000000000082
70821+:10BEC0000000000000000000000000000000000072
70822+:10BED0000000000000000000000000000000000062
70823+:10BEE0000000000000000000000000000000000052
70824+:10BEF0000000000000000000000000000000000042
70825+:10BF00000000000000000000000000000000000031
70826+:10BF10000000000000000000000000000000000021
70827+:10BF20000000000000000000000000000000000011
70828+:10BF30000000000000000000000000000000000001
70829+:10BF400000000000000000000000000000000000F1
70830+:10BF500000000000000000000000000000000000E1
70831+:10BF600000000000000000000000000000000000D1
70832+:10BF700000000000000000000000000000000000C1
70833+:10BF800000000000000000000000000000000000B1
70834+:10BF900000000000000000000000000000000000A1
70835+:10BFA0000000000000000000000000000000000091
70836+:10BFB0000000000000000000000000000000000081
70837+:10BFC0000000000000000000000000000000000071
70838+:10BFD0000000000000000000000000000000000061
70839+:10BFE0000000000000000000000000000000000051
70840+:10BFF0000000000000000000000000000000000041
70841+:10C000000000000000000000000000000000000030
70842+:10C010000000000000000000000000000000000020
70843+:10C020000000000000000000000000000000000010
70844+:10C030000000000000000000000000000000000000
70845+:10C0400000000000000000000000000000000000F0
70846+:10C0500000000000000000000000000000000000E0
70847+:10C0600000000000000000000000000000000000D0
70848+:10C0700000000000000000000000000000000000C0
70849+:10C0800000000000000000000000000000000000B0
70850+:10C0900000000000000000000000000000000000A0
70851+:10C0A0000000000000000000000000000000000090
70852+:10C0B0000000000000000000000000000000000080
70853+:10C0C0000000000000000000000000000000000070
70854+:10C0D0000000000000000000000000000000000060
70855+:10C0E0000000000000000000000000000000000050
70856+:10C0F0000000000000000000000000000000000040
70857+:10C10000000000000000000000000000000000002F
70858+:10C11000000000000000000000000000000000001F
70859+:10C12000000000000000000000000000000000000F
70860+:10C1300000000000000000000000000000000000FF
70861+:10C1400000000000000000000000000000000000EF
70862+:10C1500000000000000000000000000000000000DF
70863+:10C1600000000000000000000000000000000000CF
70864+:10C1700000000000000000000000000000000000BF
70865+:10C1800000000000000000000000000000000000AF
70866+:10C19000000000000000000000000000000000009F
70867+:10C1A000000000000000000000000000000000008F
70868+:10C1B000000000000000000000000000000000007F
70869+:10C1C000000000000000000000000000000000006F
70870+:10C1D000000000000000000000000000000000005F
70871+:10C1E000000000000000000000000000000000004F
70872+:10C1F000000000000000000000000000000000003F
70873+:10C20000000000000000000000000000000000002E
70874+:10C21000000000000000000000000000000000001E
70875+:10C22000000000000000000000000000000000000E
70876+:10C2300000000000000000000000000000000000FE
70877+:10C2400000000000000000000000000000000000EE
70878+:10C2500000000000000000000000000000000000DE
70879+:10C2600000000000000000000000000000000000CE
70880+:10C2700000000000000000000000000000000000BE
70881+:10C2800000000000000000000000000000000000AE
70882+:10C29000000000000000000000000000000000009E
70883+:10C2A000000000000000000000000000000000008E
70884+:10C2B000000000000000000000000000000000007E
70885+:10C2C000000000000000000000000000000000006E
70886+:10C2D000000000000000000000000000000000005E
70887+:10C2E000000000000000000000000000000000004E
70888+:10C2F000000000000000000000000000000000003E
70889+:10C30000000000000000000000000000000000002D
70890+:10C31000000000000000000000000000000000001D
70891+:10C32000000000000000000000000000000000000D
70892+:10C3300000000000000000000000000000000000FD
70893+:10C3400000000000000000000000000000000000ED
70894+:10C3500000000000000000000000000000000000DD
70895+:10C3600000000000000000000000000000000000CD
70896+:10C3700000000000000000000000000000000000BD
70897+:10C3800000000000000000000000000000000000AD
70898+:10C39000000000000000000000000000000000009D
70899+:10C3A000000000000000000000000000000000008D
70900+:10C3B000000000000000000000000000000000007D
70901+:10C3C000000000000000000000000000000000006D
70902+:10C3D000000000000000000000000000000000005D
70903+:10C3E000000000000000000000000000000000004D
70904+:10C3F000000000000000000000000000000000003D
70905+:10C40000000000000000000000000000000000002C
70906+:10C41000000000000000000000000000000000001C
70907+:10C42000000000000000000000000000000000000C
70908+:10C4300000000000000000000000000000000000FC
70909+:10C4400000000000000000000000000000000000EC
70910+:10C4500000000000000000000000000000000000DC
70911+:10C4600000000000000000000000000000000000CC
70912+:10C4700000000000000000000000000000000000BC
70913+:10C4800000000000000000000000000000000000AC
70914+:10C49000000000000000000000000000000000009C
70915+:10C4A000000000000000000000000000000000008C
70916+:10C4B000000000000000000000000000000000007C
70917+:10C4C000000000000000000000000000000000006C
70918+:10C4D000000000000000000000000000000000005C
70919+:10C4E000000000000000000000000000000000004C
70920+:10C4F000000000000000000000000000000000003C
70921+:10C50000000000000000000000000000000000002B
70922+:10C51000000000000000000000000000000000001B
70923+:10C52000000000000000000000000000000000000B
70924+:10C5300000000000000000000000000000000000FB
70925+:10C5400000000000000000000000000000000000EB
70926+:10C5500000000000000000000000000000000000DB
70927+:10C5600000000000000000000000000000000000CB
70928+:10C5700000000000000000000000000000000000BB
70929+:10C5800000000000000000000000000000000000AB
70930+:10C59000000000000000000000000000000000009B
70931+:10C5A000000000000000000000000000000000008B
70932+:10C5B000000000000000000000000000000000007B
70933+:10C5C000000000000000000000000000000000006B
70934+:10C5D000000000000000000000000000000000005B
70935+:10C5E000000000000000000000000000000000004B
70936+:10C5F000000000000000000000000000000000003B
70937+:10C60000000000000000000000000000000000002A
70938+:10C61000000000000000000000000000000000001A
70939+:10C62000000000000000000000000000000000000A
70940+:10C6300000000000000000000000000000000000FA
70941+:10C6400000000000000000000000000000000000EA
70942+:10C6500000000000000000000000000000000000DA
70943+:10C6600000000000000000000000000000000000CA
70944+:10C6700000000000000000000000000000000000BA
70945+:10C6800000000000000000000000000000000000AA
70946+:10C69000000000000000000000000000000000009A
70947+:10C6A000000000000000000000000000000000008A
70948+:10C6B000000000000000000000000000000000007A
70949+:10C6C000000000000000000000000000000000006A
70950+:10C6D000000000000000000000000000000000005A
70951+:10C6E000000000000000000000000000000000004A
70952+:10C6F000000000000000000000000000000000003A
70953+:10C700000000000000000000000000000000000029
70954+:10C710000000000000000000000000000000000019
70955+:10C720000000000000000000000000000000000009
70956+:10C7300000000000000000000000000000000000F9
70957+:10C7400000000000000000000000000000000000E9
70958+:10C7500000000000000000000000000000000000D9
70959+:10C7600000000000000000000000000000000000C9
70960+:10C7700000000000000000000000000000000000B9
70961+:10C7800000000000000000000000000000000000A9
70962+:10C790000000000000000000000000000000000099
70963+:10C7A0000000000000000000000000000000000089
70964+:10C7B0000000000000000000000000000000000079
70965+:10C7C0000000000000000000000000000000000069
70966+:10C7D0000000000000000000000000000000000059
70967+:10C7E0000000000000000000000000000000000049
70968+:10C7F0000000000000000000000000000000000039
70969+:10C800000000000000000000000000000000000028
70970+:10C810000000000000000000000000000000000018
70971+:10C820000000000000000000000000000000000008
70972+:10C8300000000000000000000000000000000000F8
70973+:10C8400000000000000000000000000000000000E8
70974+:10C8500000000000000000000000000000000000D8
70975+:10C8600000000000000000000000000000000000C8
70976+:10C8700000000000000000000000000000000000B8
70977+:10C8800000000000000000000000000000000000A8
70978+:10C890000000000000000000000000000000000098
70979+:10C8A0000000000000000000000000000000000088
70980+:10C8B0000000000000000000000000000000000078
70981+:10C8C0000000000000000000000000000000000068
70982+:10C8D0000000000000000000000000000000000058
70983+:10C8E0000000000000000000000000000000000048
70984+:10C8F0000000000000000000000000000000000038
70985+:10C900000000000000000000000000000000000027
70986+:10C910000000000000000000000000000000000017
70987+:10C920000000000000000000000000000000000007
70988+:10C9300000000000000000000000000000000000F7
70989+:10C9400000000000000000000000000000000000E7
70990+:10C9500000000000000000000000000000000000D7
70991+:10C9600000000000000000000000000000000000C7
70992+:10C9700000000000000000000000000000000000B7
70993+:10C9800000000000000000000000000000000000A7
70994+:10C990000000000000000000000000000000000097
70995+:10C9A0000000000000000000000000000000000087
70996+:10C9B0000000000000000000000000000000000077
70997+:10C9C0000000000000000000000000000000000067
70998+:10C9D0000000000000000000000000000000000057
70999+:10C9E0000000000000000000000000000000000047
71000+:10C9F0000000000000000000000000000000000037
71001+:10CA00000000000000000000000000000000000026
71002+:10CA10000000000000000000000000000000000016
71003+:10CA20000000000000000000000000000000000006
71004+:10CA300000000000000000000000000000000000F6
71005+:10CA400000000000000000000000000000000000E6
71006+:10CA500000000000000000000000000000000000D6
71007+:10CA600000000000000000000000000000000000C6
71008+:10CA700000000000000000000000000000000000B6
71009+:10CA800000000000000000000000000000000000A6
71010+:10CA90000000000000000000000000000000000096
71011+:10CAA0000000000000000000000000000000000086
71012+:10CAB0000000000000000000000000000000000076
71013+:10CAC0000000000000000000000000000000000066
71014+:10CAD0000000000000000000000000000000000056
71015+:10CAE0000000000000000000000000000000000046
71016+:10CAF0000000000000000000000000000000000036
71017+:10CB00000000000000000000000000000000000025
71018+:10CB10000000000000000000000000000000000015
71019+:10CB20000000000000000000000000000000000005
71020+:10CB300000000000000000000000000000000000F5
71021+:10CB400000000000000000000000000000000000E5
71022+:10CB500000000000000000000000000000000000D5
71023+:10CB600000000000000000000000000000000000C5
71024+:10CB700000000000000000000000000000000000B5
71025+:10CB800000000000000000000000000000000000A5
71026+:10CB90000000000000000000000000000000000095
71027+:10CBA0000000000000000000000000000000000085
71028+:10CBB0000000000000000000000000000000000075
71029+:10CBC0000000000000000000000000000000000065
71030+:10CBD0000000000000000000000000000000000055
71031+:10CBE0000000000000000000000000000000000045
71032+:10CBF0000000000000000000000000000000000035
71033+:10CC00000000000000000000000000000000000024
71034+:10CC10000000000000000000000000000000000014
71035+:10CC20000000000000000000000000000000000004
71036+:10CC300000000000000000000000000000000000F4
71037+:10CC400000000000000000000000000000000000E4
71038+:10CC500000000000000000000000000000000000D4
71039+:10CC600000000000000000000000000000000000C4
71040+:10CC700000000000000000000000000000000000B4
71041+:10CC800000000000000000000000000000000000A4
71042+:10CC90000000000000000000000000000000000094
71043+:10CCA0000000000000000000000000000000000084
71044+:10CCB0000000000000000000000000000000000074
71045+:10CCC0000000000000000000000000000000000064
71046+:10CCD0000000000000000000000000000000000054
71047+:10CCE0000000000000000000000000000000000044
71048+:10CCF0000000000000000000000000000000000034
71049+:10CD00000000000000000000000000000000000023
71050+:10CD10000000000000000000000000000000000013
71051+:10CD20000000000000000000000000000000000003
71052+:10CD300000000000000000000000000000000000F3
71053+:10CD400000000000000000000000000000000000E3
71054+:10CD500000000000000000000000000000000000D3
71055+:10CD600000000000000000000000000000000000C3
71056+:10CD700000000000000000000000000000000000B3
71057+:10CD800000000000000000000000000000000000A3
71058+:10CD90000000000000000000000000000000000093
71059+:10CDA0000000000000000000000000000000000083
71060+:10CDB0000000000000000000000000000000000073
71061+:10CDC0000000000000000000000000000000000063
71062+:10CDD0000000000000000000000000000000000053
71063+:10CDE0000000000000000000000000000000000043
71064+:10CDF0000000000000000000000000000000000033
71065+:10CE00000000000000000000000000000000000022
71066+:10CE10000000000000000000000000000000000012
71067+:10CE20000000000000000000000000000000000002
71068+:10CE300000000000000000000000000000000000F2
71069+:10CE400000000000000000000000000000000000E2
71070+:10CE500000000000000000000000000000000000D2
71071+:10CE600000000000000000000000000000000000C2
71072+:10CE700000000000000000000000000000000000B2
71073+:10CE800000000000000000000000000000000000A2
71074+:10CE90000000000000000000000000000000000092
71075+:10CEA0000000000000000000000000000000000082
71076+:10CEB0000000000000000000000000000000000072
71077+:10CEC0000000000000000000000000000000000062
71078+:10CED0000000000000000000000000000000000052
71079+:10CEE0000000000000000000000000000000000042
71080+:10CEF0000000000000000000000000000000000032
71081+:10CF00000000000000000000000000000000000021
71082+:10CF10000000000000000000000000000000000011
71083+:10CF20000000000000000000000000000000000001
71084+:10CF300000000000000000000000000000000000F1
71085+:10CF400000000000000000000000000000000000E1
71086+:10CF500000000000000000000000000000000000D1
71087+:10CF600000000000000000000000000000000000C1
71088+:10CF700000000000000000000000000000000000B1
71089+:10CF800000000000000000000000000000000000A1
71090+:10CF90000000000000000000000000000000000091
71091+:10CFA0000000000000000000000000000000000081
71092+:10CFB0000000000000000000000000000000000071
71093+:10CFC0000000000000000000000000000000000061
71094+:10CFD0000000000000000000000000000000000051
71095+:10CFE0000000000000000000000000000000000041
71096+:10CFF0000000000000000000000000000000000031
71097+:10D000000000000000000000000000000000000020
71098+:10D010000000000000000000000000000000000010
71099+:10D020000000000000000000000000000000000000
71100+:10D0300000000000000000000000000000000000F0
71101+:10D0400000000000000000000000000000000000E0
71102+:10D0500000000000000000000000000000000000D0
71103+:10D0600000000000000000000000000000000000C0
71104+:10D0700000000000000000000000000000000000B0
71105+:10D0800000000000000000000000000000000000A0
71106+:10D090000000000000000000000000000000000090
71107+:10D0A0000000000000000000000000000000000080
71108+:10D0B0000000000000000000000000000000000070
71109+:10D0C0000000000000000000000000000000000060
71110+:10D0D0000000000000000000000000000000000050
71111+:10D0E0000000000000000000000000000000000040
71112+:10D0F0000000000000000000000000000000000030
71113+:10D10000000000000000000000000000000000001F
71114+:10D11000000000000000000000000000000000000F
71115+:10D1200000000000000000000000000000000000FF
71116+:10D1300000000000000000000000000000000000EF
71117+:10D1400000000000000000000000000000000000DF
71118+:10D1500000000000000000000000000000000000CF
71119+:10D1600000000000000000000000000000000000BF
71120+:10D1700000000000000000000000000000000000AF
71121+:10D18000000000000000000000000000000000009F
71122+:10D19000000000000000000000000000000000008F
71123+:10D1A000000000000000000000000000000000007F
71124+:10D1B000000000000000000000000000000000006F
71125+:10D1C000000000000000000000000000000000005F
71126+:10D1D000000000000000000000000000000000004F
71127+:10D1E000000000000000000000000000000000003F
71128+:10D1F000000000000000000000000000000000002F
71129+:10D20000000000000000000000000000000000001E
71130+:10D21000000000000000000000000000000000000E
71131+:10D2200000000000000000000000000000000000FE
71132+:10D2300000000000000000000000000000000000EE
71133+:10D2400000000000000000000000000000000000DE
71134+:10D2500000000000000000000000000000000000CE
71135+:10D2600000000000000000000000000000000000BE
71136+:10D2700000000000000000000000000000000000AE
71137+:10D28000000000000000000000000000000000009E
71138+:10D29000000000000000000000000000000000008E
71139+:10D2A000000000000000000000000000000000007E
71140+:10D2B000000000000000000000000000000000006E
71141+:10D2C000000000000000000000000000000000005E
71142+:10D2D000000000000000000000000000000000004E
71143+:10D2E000000000000000000000000000000000003E
71144+:10D2F000000000000000000000000000000000002E
71145+:10D30000000000000000000000000000000000001D
71146+:10D31000000000000000000000000000000000000D
71147+:10D3200000000000000000000000000000000000FD
71148+:10D3300000000000000000000000000000000000ED
71149+:10D3400000000000000000000000000000000000DD
71150+:10D3500000000000000000000000000000000000CD
71151+:10D3600000000000000000000000000000000000BD
71152+:10D3700000000000000000000000000000000000AD
71153+:10D38000000000000000000000000000000000009D
71154+:10D39000000000000000000000000000000000008D
71155+:10D3A000000000000000000000000000000000007D
71156+:10D3B000000000000000000000000000000000006D
71157+:10D3C000000000000000000000000000000000005D
71158+:10D3D000000000000000000000000000000000004D
71159+:10D3E000000000000000000000000000000000003D
71160+:10D3F000000000000000000000000000000000002D
71161+:10D40000000000000000000000000000000000001C
71162+:10D41000000000000000000000000000000000000C
71163+:10D4200000000000000000000000000000000000FC
71164+:10D4300000000000000000000000000000000000EC
71165+:10D4400000000000000000000000000000000000DC
71166+:10D4500000000000000000000000000000000000CC
71167+:10D4600000000000000000000000000000000000BC
71168+:10D4700000000000000000000000000000000000AC
71169+:10D48000000000000000000000000000000000009C
71170+:10D49000000000000000000000000000000000008C
71171+:10D4A000000000000000000000000000000000007C
71172+:10D4B000000000000000000000000000000000006C
71173+:10D4C000000000000000000000000000000000005C
71174+:10D4D000000000000000000000000000000000004C
71175+:10D4E000000000000000000000000000000000003C
71176+:10D4F000000000000000000000000000000000002C
71177+:10D50000000000000000000000000000000000001B
71178+:10D51000000000000000000000000000000000000B
71179+:10D5200000000000000000000000000000000000FB
71180+:10D5300000000000000000000000000000000000EB
71181+:10D5400000000000000000000000000000000000DB
71182+:10D5500000000000000000000000000000000000CB
71183+:10D5600000000000000000000000000000000000BB
71184+:10D5700000000000000000000000000000000000AB
71185+:10D58000000000000000000000000000000000009B
71186+:10D59000000000000000000000000000000000008B
71187+:10D5A000000000000000000000000000000000007B
71188+:10D5B000000000000000000000000000000000006B
71189+:10D5C000000000000000000000000000000000005B
71190+:10D5D000000000000000000000000000000000004B
71191+:10D5E000000000000000000000000000000000003B
71192+:10D5F000000000000000000000000000000000002B
71193+:10D60000000000000000000000000000000000001A
71194+:10D61000000000000000000000000000000000000A
71195+:10D6200000000000000000000000000000000000FA
71196+:10D6300000000000000000000000000000000000EA
71197+:10D6400000000000000000000000000000000000DA
71198+:10D6500000000000000000000000000000000000CA
71199+:10D6600000000000000000000000000000000000BA
71200+:10D6700000000000000000000000000000000000AA
71201+:10D68000000000000000000000000000000000009A
71202+:10D69000000000000000000000000000000000008A
71203+:10D6A000000000000000000000000000000000007A
71204+:10D6B000000000000000000000000000000000006A
71205+:10D6C000000000000000000000000000000000005A
71206+:10D6D000000000000000000000000000000000004A
71207+:10D6E000000000000000000000000000000000003A
71208+:10D6F000000000000000000000000000000000002A
71209+:10D700000000000000000000000000000000000019
71210+:10D710000000000000000000000000000000000009
71211+:10D7200000000000000000000000000000000000F9
71212+:10D7300000000000000000000000000000000000E9
71213+:10D7400000000000000000000000000000000000D9
71214+:10D7500000000000000000000000000000000000C9
71215+:10D7600000000000000000000000000000000000B9
71216+:10D7700000000000000000000000000000000000A9
71217+:10D780000000000000000000000000000000000099
71218+:10D790000000000000000000000000000000000089
71219+:10D7A0000000000000000000000000000000000079
71220+:10D7B0000000000000000000000000000000000069
71221+:10D7C0000000000000000000000000000000000059
71222+:10D7D0000000000000000000000000000000000049
71223+:10D7E0000000000000000000000000000000000039
71224+:10D7F0000000000000000000000000000000000029
71225+:10D800000000000000000000000000000000000018
71226+:10D810000000000000000000000000000000000008
71227+:10D8200000000000000000000000000000000000F8
71228+:10D8300000000000000000000000000000000000E8
71229+:10D8400000000000000000000000000000000000D8
71230+:10D8500000000000000000000000000000000000C8
71231+:10D8600000000000000000000000000000000000B8
71232+:10D8700000000000000000000000000000000000A8
71233+:10D880000000000000000000000000000000000098
71234+:10D890000000000000000000000000000000000088
71235+:10D8A0000000000000000000000000000000000078
71236+:10D8B0000000000000000000000000000000000068
71237+:10D8C0000000000000000000000000000000000058
71238+:10D8D0000000000000000000000000000000000048
71239+:10D8E0000000000000000000000000000000000038
71240+:10D8F0000000000000000000000000000000000028
71241+:10D900000000000000000000000000000000000017
71242+:10D910000000000000000000000000000000000007
71243+:10D9200000000000000000000000000000000000F7
71244+:10D9300000000000000000000000000000000000E7
71245+:10D9400000000000000000000000000000000000D7
71246+:10D9500000000000000000000000000000000000C7
71247+:10D9600000000000000000000000000000000000B7
71248+:10D9700000000000000000000000000000000000A7
71249+:10D980000000000000000000000000000000000097
71250+:10D990000000000000000000000000000000000087
71251+:10D9A0000000000000000000000000000000000077
71252+:10D9B0000000000000000000000000000000000067
71253+:10D9C0000000000000000000000000000000000057
71254+:10D9D0000000000000000000000000000000000047
71255+:10D9E0000000000000000000000000000000000037
71256+:10D9F0000000000000000000000000000000000027
71257+:10DA00000000000000000000000000000000000016
71258+:10DA10000000000000000000000000000000000006
71259+:10DA200000000000000000000000000000000000F6
71260+:10DA300000000000000000000000000000000000E6
71261+:10DA400000000000000000000000000000000000D6
71262+:10DA500000000000000000000000000000000000C6
71263+:10DA600000000000000000000000000000000000B6
71264+:10DA700000000000000000000000000000000000A6
71265+:10DA80000000000000000000000000000000000096
71266+:10DA90000000000000000000000000000000000086
71267+:10DAA0000000000000000000000000000000000076
71268+:10DAB0000000000000000000000000000000000066
71269+:10DAC0000000000000000000000000000000000056
71270+:10DAD0000000000000000000000000000000000046
71271+:10DAE0000000000000000000000000000000000036
71272+:10DAF0000000000000000000000000000000000026
71273+:10DB00000000000000000000000000000000000015
71274+:10DB10000000000000000000000000000000000005
71275+:10DB200000000000000000000000000000000000F5
71276+:10DB300000000000000000000000000000000000E5
71277+:10DB400000000000000000000000000000000000D5
71278+:10DB500000000000000000000000000000000000C5
71279+:10DB600000000000000000000000000000000000B5
71280+:10DB700000000000000000000000000000000000A5
71281+:10DB80000000000000000000000000000000000095
71282+:10DB90000000000000000000000000000000000085
71283+:10DBA0000000000000000000000000000000000075
71284+:10DBB0000000000000000000000000000000000065
71285+:10DBC0000000000000000000000000000000000055
71286+:10DBD0000000000000000000000000000000000045
71287+:10DBE0000000000000000000000000000000000035
71288+:10DBF0000000000000000000000000000000000025
71289+:10DC00000000000000000000000000000000000014
71290+:10DC10000000000000000000000000000000000004
71291+:10DC200000000000000000000000000000000000F4
71292+:10DC300000000000000000000000000000000000E4
71293+:10DC400000000000000000000000000000000000D4
71294+:10DC500000000000000000000000000000000000C4
71295+:10DC600000000000000000000000000000000000B4
71296+:10DC700000000000000000000000000000000000A4
71297+:10DC80000000000000000000000000000000000094
71298+:10DC90000000000000000000000000000000000084
71299+:10DCA0000000000000000000000000000000000074
71300+:10DCB0000000000000000000000000000000000064
71301+:10DCC0000000000000000000000000000000000054
71302+:10DCD0000000000000000000000000000000000044
71303+:10DCE0000000000000000000000000000000000034
71304+:10DCF0000000000000000000000000000000000024
71305+:10DD00000000000000000000000000000000000013
71306+:10DD10000000000000000000000000000000000003
71307+:10DD200000000000000000000000000000000000F3
71308+:10DD300000000000000000000000000000000000E3
71309+:10DD400000000000000000000000000000000000D3
71310+:10DD500000000000000000000000000000000000C3
71311+:10DD600000000000000000000000000000000000B3
71312+:10DD700000000000000000000000000000000000A3
71313+:10DD80000000000000000000000000000000000093
71314+:10DD90000000000000000000000000000000000083
71315+:10DDA0000000000000000000000000000000000073
71316+:10DDB0000000000000000000000000000000000063
71317+:10DDC0000000000000000000000000000000000053
71318+:10DDD0000000000000000000000000000000000043
71319+:10DDE0000000000000000000000000000000000033
71320+:10DDF0000000000000000000000000000000000023
71321+:10DE00000000000000000000000000000000000012
71322+:10DE10000000000000000000000000000000000002
71323+:10DE200000000000000000000000000000000000F2
71324+:10DE300000000000000000000000000000000000E2
71325+:10DE400000000000000000000000000000000000D2
71326+:10DE500000000000000000000000000000000000C2
71327+:10DE600000000000000000000000000000000000B2
71328+:10DE700000000000000000000000000000000000A2
71329+:10DE80000000000000000000000000000000000092
71330+:10DE90000000000000000000000000000000000082
71331+:10DEA0000000000000000000000000000000000072
71332+:10DEB0000000000000000000000000000000000062
71333+:10DEC0000000000000000000000000000000000052
71334+:10DED0000000000000000000000000000000000042
71335+:10DEE0000000000000000000000000000000000032
71336+:10DEF0000000000000000000000000000000000022
71337+:10DF00000000000000000000000000000000000011
71338+:10DF10000000000000000000000000000000000001
71339+:10DF200000000000000000000000000000000000F1
71340+:10DF300000000000000000000000000000000000E1
71341+:10DF400000000000000000000000000000000000D1
71342+:10DF500000000000000000000000000000000000C1
71343+:10DF600000000000000000000000000000000000B1
71344+:10DF700000000000000000000000000000000000A1
71345+:10DF80000000000000000000000000000000000091
71346+:10DF90000000000000000000000000000000000081
71347+:10DFA0000000000000000000000000000000000071
71348+:10DFB0000000000000000000000000000000000061
71349+:10DFC0000000000000000000000000000000000051
71350+:10DFD0000000000000000000000000000000000041
71351+:10DFE0000000000000000000000000000000000031
71352+:10DFF0000000000000000000000000000000000021
71353+:10E000000000000000000000000000000000000010
71354+:10E010000000000000000000000000000000000000
71355+:10E0200000000000000000000000000000000000F0
71356+:10E0300000000000000000000000000000000000E0
71357+:10E0400000000000000000000000000000000000D0
71358+:10E0500000000000000000000000000000000000C0
71359+:10E0600000000000000000000000000000000000B0
71360+:10E0700000000000000000000000000000000000A0
71361+:10E080000000000000000000000000000000000090
71362+:10E090000000000000000000000000000000000080
71363+:10E0A0000000000000000000000000000000000070
71364+:10E0B0000000000000000000000000000000000060
71365+:10E0C0000000000000000000000000000000000050
71366+:10E0D0000000000000000000000000000000000040
71367+:10E0E0000000000000000000000000000000000030
71368+:10E0F0000000000000000000000000000000000020
71369+:10E10000000000000000000000000000000000000F
71370+:10E1100000000000000000000000000000000000FF
71371+:10E1200000000000000000000000000000000000EF
71372+:10E1300000000000000000000000000000000000DF
71373+:10E1400000000000000000000000000000000000CF
71374+:10E1500000000000000000000000000000000000BF
71375+:10E1600000000000000000000000000000000000AF
71376+:10E17000000000000000000000000000000000009F
71377+:10E18000000000000000000000000000000000008F
71378+:10E19000000000000000000000000000000000007F
71379+:10E1A000000000000000000000000000000000006F
71380+:10E1B000000000000000000000000000000000005F
71381+:10E1C000000000000000000000000000000000004F
71382+:10E1D000000000000000000000000000000000003F
71383+:10E1E000000000000000000000000000000000002F
71384+:10E1F000000000000000000000000000000000809F
71385+:10E20000000000000000000000000000000000000E
71386+:10E2100000000000000000000000000000000000FE
71387+:10E220000000000A000000000000000000000000E4
71388+:10E2300010000003000000000000000D0000000DB1
71389+:10E240003C020801244295C03C030801246397FC6A
71390+:10E25000AC4000000043202B1480FFFD244200044A
71391+:10E260003C1D080037BD9FFC03A0F0213C100800B6
71392+:10E27000261032103C1C0801279C95C00E0012BECF
71393+:10E28000000000000000000D3C02800030A5FFFFF0
71394+:10E2900030C600FF344301803C0880008D0901B87E
71395+:10E2A0000520FFFE00000000AC6400002404000212
71396+:10E2B000A4650008A066000AA064000BAC67001803
71397+:10E2C0003C03100003E00008AD0301B83C0560000A
71398+:10E2D0008CA24FF80440FFFE00000000ACA44FC029
71399+:10E2E0003C0310003C040200ACA44FC403E000084F
71400+:10E2F000ACA34FF89486000C00A050212488001491
71401+:10E3000000062B0200051080004448210109182B4B
71402+:10E310001060001100000000910300002C6400094F
71403+:10E320005080000991190001000360803C0D080134
71404+:10E3300025AD9258018D58218D67000000E000083E
71405+:10E340000000000091190001011940210109302B42
71406+:10E3500054C0FFF29103000003E000080000102108
71407+:10E360000A000CCC25080001910F0001240E000AC0
71408+:10E3700015EE00400128C8232F38000A1700003D81
71409+:10E38000250D00028D580000250F0006370E0100F4
71410+:10E39000AD4E0000910C000291AB000191A400026F
71411+:10E3A00091A60003000C2E00000B3C0000A71025D6
71412+:10E3B00000041A000043C8250326C025AD580004F8
71413+:10E3C000910E000691ED000191E7000291E5000336
71414+:10E3D000000E5E00000D6400016C30250007220075
71415+:10E3E00000C41025004518252508000A0A000CCC99
71416+:10E3F000AD430008910F000125040002240800022B
71417+:10E4000055E80001012020210A000CCC00804021A9
71418+:10E41000910C0001240B0003158B00160000000076
71419+:10E420008D580000910E000225080003370D0008EA
71420+:10E43000A14E00100A000CCCAD4D00009119000156
71421+:10E44000240F0004172F000B0000000091070002AA
71422+:10E45000910400038D43000000072A0000A410254A
71423+:10E460003466000425080004AD42000C0A000CCC00
71424+:10E47000AD46000003E000082402000127BDFFE8CC
71425+:10E48000AFBF0014AFB000100E00164E0080802108
71426+:10E490003C0480083485008090A600052403FFFE1C
71427+:10E4A0000200202100C310248FBF00148FB0001081
71428+:10E4B000A0A200050A00165827BD001827BDFFE8D6
71429+:10E4C000AFB00010AFBF00140E000FD40080802149
71430+:10E4D0003C06800834C5008090A40000240200504F
71431+:10E4E000308300FF106200073C09800002002021F9
71432+:10E4F0008FBF00148FB00010AD2001800A00108F74
71433+:10E5000027BD0018240801003C07800002002021DC
71434+:10E510008FBF00148FB00010ACE801800A00108F8C
71435+:10E5200027BD001827BDFF783C058008AFBE0080DE
71436+:10E53000AFB7007CAFB3006CAFB10064AFBF008475
71437+:10E54000AFB60078AFB50074AFB40070AFB200687A
71438+:10E55000AFB0006034A600803C0580008CB201287A
71439+:10E5600090C400098CA701043C020001309100FF17
71440+:10E5700000E218240000B8210000F021106000071C
71441+:10E58000000098213C0908008D2931F02413000176
71442+:10E59000252800013C010800AC2831F0ACA0008423
71443+:10E5A00090CC0005000C5827316A0001154000721C
71444+:10E5B000AFA0005090CD00002406002031A400FF41
71445+:10E5C00010860018240E0050108E009300000000EA
71446+:10E5D0003C1008008E1000DC260F00013C010800F2
71447+:10E5E000AC2F00DC0E0016C7000000000040182110
71448+:10E5F0008FBF00848FBE00808FB7007C8FB60078FD
71449+:10E600008FB500748FB400708FB3006C8FB2006848
71450+:10E610008FB100648FB000600060102103E000083B
71451+:10E6200027BD00880000000D3C1F8000AFA0003017
71452+:10E6300097E501168FE201043C04002030B9FFFF8A
71453+:10E64000004438240007182B00033140AFA60030E7
71454+:10E650008FF5010437F80C003C1600400338802188
71455+:10E6600002B6A02434C40040128000479215000D69
71456+:10E6700032A800201500000234860080008030217E
71457+:10E6800014C0009FAFA600303C0D800835A6008066
71458+:10E6900090CC0008318B0040516000063C06800899
71459+:10E6A000240E0004122E00A8240F0012122F003294
71460+:10E6B0003C06800834C401003C0280009447011AE3
71461+:10E6C0009619000E909F00088E18000830E3FFFF97
71462+:10E6D00003F9B00432B40004AFB6005CAFA3005835
71463+:10E6E0008E1600041280002EAFB8005434C3008090
71464+:10E6F000906800083105004014A0002500000000CB
71465+:10E700008C70005002D090230640000500000000ED
71466+:10E710008C71003402D1A82306A201678EE20008A2
71467+:10E72000126000063C1280003C1508008EB531F4E2
71468+:10E7300026B600013C010800AC3631F4AE4000447E
71469+:10E74000240300018FBF00848FBE00808FB7007C40
71470+:10E750008FB600788FB500748FB400708FB3006CE3
71471+:10E760008FB200688FB100648FB00060006010212C
71472+:10E7700003E0000827BD00880E000D2800002021BE
71473+:10E780000A000D75004018210A000D9500C02021D7
71474+:10E790000E00171702C020211440FFE10000000006
71475+:10E7A0003C0B8008356400808C8A003402CA482300
71476+:10E7B0000520001D000000003C1E08008FDE310017
71477+:10E7C00027D700013C010800AC3731001260000679
71478+:10E7D000024020213C1408008E9431F42690000160
71479+:10E7E0003C010800AC3031F40E00164E3C1E80088F
71480+:10E7F00037CD008091B700250240202136EE00047D
71481+:10E800000E001658A1AE00250E000CAC02402021CF
71482+:10E810000A000DCA240300013C17080126F796C020
71483+:10E820000A000D843C1F80008C86003002C66023E5
71484+:10E830001980000C2419000C908F004F3C14080024
71485+:10E840008E94310032B500FC35ED0001268E0001BA
71486+:10E850003C010800AC2E3100A08D004FAFA0005845
71487+:10E860002419000CAFB900308C9800300316A02397
71488+:10E870001A80010B8FA300580074F82A17E0FFD309
71489+:10E88000000000001074002A8FA5005802D4B021A7
71490+:10E8900000B410233044FFFFAFA4005832A8000298
71491+:10E8A0001100002E32AB00103C15800836B00080FD
71492+:10E8B0009216000832D30040526000FB8EE200083E
71493+:10E8C0000E00164E02402021240A0018A20A000958
71494+:10E8D000921100052409FFFE024020210229902404
71495+:10E8E0000E001658A2120005240400390000282149
71496+:10E8F0000E0016F2240600180A000DCA24030001B7
71497+:10E9000092FE000C3C0A800835490080001EBB00C6
71498+:10E910008D27003836F10081024020213225F08118
71499+:10E920000E000C9B30C600FF0A000DC10000000065
71500+:10E930003AA7000130E300011460FFA402D4B02123
71501+:10E940000A000E1D00000000024020210E001734B6
71502+:10E95000020028210A000D75004018211160FF7087
71503+:10E960003C0F80083C0D800835EE00808DC40038D7
71504+:10E970008FA300548DA60004006660231D80FF68ED
71505+:10E98000000000000064C02307020001AFA400548F
71506+:10E990003C1F08008FFF31E433F9000113200015FC
71507+:10E9A0008FAC00583C07800094E3011A10600012FD
71508+:10E9B0003C0680080E00216A024020213C03080129
71509+:10E9C000906396F13064000214800145000000005D
71510+:10E9D000306C0004118000078FAC0058306600FBDB
71511+:10E9E0003C010801A02696F132B500FCAFA000580A
71512+:10E9F0008FAC00583C06800834D30080AFB40018B8
71513+:10EA0000AFB60010AFAC00143C088000950B01209D
71514+:10EA10008E6F0030966A005C8FA3005C8FBF003061
71515+:10EA20003169FFFF3144FFFF8FAE005401341021E4
71516+:10EA3000350540000064382B0045C82103E7C02598
71517+:10EA4000AFB90020AFAF0028AFB80030AFAF00249F
71518+:10EA5000AFA0002CAFAE0034926D000831B40008B6
71519+:10EA6000168000BB020020218EE200040040F8095D
71520+:10EA700027A400108FAF003031F300025660000170
71521+:10EA800032B500FE3C048008349F008093F90008F2
71522+:10EA900033380040530000138FA400248C850004F9
71523+:10EAA0008FA7005410A700D52404001432B0000131
71524+:10EAB0001200000C8FA400242414000C1234011A3C
71525+:10EAC0002A2D000D11A001022413000E240E000AAD
71526+:10EAD000522E0001241E00088FAF002425E40001FF
71527+:10EAE000AFA400248FAA00143C0B80083565008079
71528+:10EAF000008A48218CB10030ACA9003090A4004EAF
71529+:10EB00008CA700303408FFFF0088180400E3F821C8
71530+:10EB1000ACBF00348FA600308FB900548FB8005CB2
71531+:10EB200030C200081040000B033898218CAC002044
71532+:10EB3000119300D330C600FF92EE000C8FA7003473
71533+:10EB400002402021000E6B0035B400800E000C9BAB
71534+:10EB50003285F0803C028008345000808E0F0030F7
71535+:10EB600001F1302318C00097264800803C070800B8
71536+:10EB70008CE731E42404FF80010418243118007F5D
71537+:10EB80003C1F80003C19800430F10001AFE300908D
71538+:10EB900012200006031928213C030801906396F116
71539+:10EBA00030690008152000C6306A00F73C10800864
71540+:10EBB00036040080908C004F318B000115600042BC
71541+:10EBC000000000003C0608008CC6319830CE0010D2
71542+:10EBD00051C0004230F9000190AF006B55E0003F9A
71543+:10EBE00030F9000124180001A0B8006B3C1180002E
71544+:10EBF0009622007A24470064A48700123C0D800806
71545+:10EC000035A5008090B40008329000401600000442
71546+:10EC10003C03800832AE000115C0008B00000000EC
71547+:10EC2000346400808C86002010D3000A3463010015
71548+:10EC30008C67000002C7782319E000978FBF00544B
71549+:10EC4000AC93002024130001AC760000AFB3005059
71550+:10EC5000AC7F000417C0004E000000008FA90050D8
71551+:10EC60001520000B000000003C030801906396F1A2
71552+:10EC7000306A00011140002E8FAB0058306400FE56
71553+:10EC80003C010801A02496F10A000D75000018212E
71554+:10EC90000E000CAC024020210A000F1300000000FF
71555+:10ECA0000A000E200000A0210040F80924040017EB
71556+:10ECB0000A000DCA240300010040F80924040016CC
71557+:10ECC0000A000DCA240300019094004F240DFFFE9A
71558+:10ECD000028D2824A085004F30F900011320000682
71559+:10ECE0003C0480083C030801906396F1307F0010DB
71560+:10ECF00017E00051306800EF34900080240A0001D2
71561+:10ED0000024020210E00164EA60A00129203002592
71562+:10ED100024090001AFA90050346200010240202103
71563+:10ED20000E001658A20200250A000EF93C0D8008BC
71564+:10ED30001160FE83000018218FA5003030AC000464
71565+:10ED40001180FE2C8FBF00840A000DCB240300012C
71566+:10ED500027A500380E000CB6AFA000385440FF4382
71567+:10ED60008EE200048FB40038329001005200FF3F61
71568+:10ED70008EE200048FA3003C8E6E0058006E682364
71569+:10ED800005A3FF39AE6300580A000E948EE200041A
71570+:10ED90000E00164E024020213C038008346800809B
71571+:10EDA000024020210E001658A11E000903C0302188
71572+:10EDB000240400370E0016F2000028210A000F116B
71573+:10EDC0008FA900508FAB00185960FF8D3C0D800853
71574+:10EDD0000E00164E02402021920C00252405000151
71575+:10EDE000AFA5005035820004024020210E001658C5
71576+:10EDF000A20200250A000EF93C0D800812240059D9
71577+:10EE00002A2300151060004D240900162408000C68
71578+:10EE10005628FF2732B000013C0A8008914C001BA5
71579+:10EE20002406FFBD241E000E01865824A14B001BA2
71580+:10EE30000A000EA532B000013C010801A02896F19D
71581+:10EE40000A000EF93C0D80088CB500308EFE0008DB
71582+:10EE50002404001826B6000103C0F809ACB600303F
71583+:10EE60003C030801906396F13077000116E0FF81C2
71584+:10EE7000306A00018FB200300A000D753243000481
71585+:10EE80003C1080009605011A50A0FF2B34C60010DC
71586+:10EE90000A000EC892EE000C8C6200001456FF6D42
71587+:10EEA000000000008C7800048FB9005403388823D8
71588+:10EEB0000621FF638FBF00540A000F0E0000000000
71589+:10EEC0003C010801A02A96F10A000F3030F9000138
71590+:10EED0001633FF028FAF00240A000EB0241E00106C
71591+:10EEE0000E00164E024020213C0B80083568008041
71592+:10EEF00091090025240A0001AFAA0050353300040F
71593+:10EF0000024020210E001658A11300253C050801DF
71594+:10EF100090A596F130A200FD3C010801A02296F1D7
71595+:10EF20000A000E6D004018212411000E53D1FEEA94
71596+:10EF3000241E00100A000EAF241E00165629FEDC07
71597+:10EF400032B000013C0A8008914C001B2406FFBD32
71598+:10EF5000241E001001865824A14B001B0A000EA598
71599+:10EF600032B000010A000EA4241E00123C038000EF
71600+:10EF70008C6201B80440FFFE24040800AC6401B8B0
71601+:10EF800003E000080000000030A5FFFF30C6FFFFCF
71602+:10EF90003C0780008CE201B80440FFFE34EA0180A7
71603+:10EFA000AD440000ACE400203C0480089483004899
71604+:10EFB0003068FFFF11000016AF88000824AB001274
71605+:10EFC000010B482B512000133C04800034EF01005A
71606+:10EFD00095EE00208F890000240D001A31CCFFFF30
71607+:10EFE00031274000A14D000B10E000362583FFFEC5
71608+:10EFF0000103C02B170000348F9900048F88000490
71609+:10F00000A5430014350700010A001003AF87000470
71610+:10F010003C04800024030003348201808F890000B7
71611+:10F020008F870004A043000B3C088000350C018052
71612+:10F03000A585000EA585001A8F85000C30EB800099
71613+:10F04000A5890010AD850028A58600081160000F75
71614+:10F050008F85001435190100972A00163158FFFCDE
71615+:10F06000270F000401E870218DCD400031A6FFFF7D
71616+:10F0700014C000072403BFFF3C02FFFF34487FFF9A
71617+:10F0800000E83824AF8700048F8500142403BFFFF5
71618+:10F090003C04800000E3582434830180A46B0026E4
71619+:10F0A000AC69002C10A0000300054C02A465001000
71620+:10F0B000A46900263C071000AC8701B803E00008F3
71621+:10F0C000000000008F990004240AFFFE032A382460
71622+:10F0D0000A001003AF87000427BDFFE88FA20028B5
71623+:10F0E00030A5FFFF30C6FFFFAFBF0010AF87000C99
71624+:10F0F000AF820014AF8000040E000FDBAF80000071
71625+:10F100008FBF001027BD001803E00008AF80001477
71626+:10F110003C06800034C4007034C701008C8A0000B3
71627+:10F1200090E500128F84000027BDFFF030A300FFA0
71628+:10F13000000318823082400010400037246500032D
71629+:10F140000005C8800326C0218F0E4000246F0004F4
71630+:10F15000000F6880AFAE000001A660218D8B4000DB
71631+:10F16000AFAB000494E900163128FFFC01063821FA
71632+:10F170008CE64000AFA600088FA9000800003021EF
71633+:10F18000000028213C07080024E701000A0010675E
71634+:10F19000240800089059000024A500012CAC000CA4
71635+:10F1A0000079C0210018788001E770218DCD000022
71636+:10F1B0001180000600CD302603A5102114A8FFF50C
71637+:10F1C00000051A005520FFF4905900003C0480000F
71638+:10F1D000348700703C0508008CA531048CE30000E6
71639+:10F1E0002CA2002010400009006A38230005488046
71640+:10F1F0003C0B0800256B3108012B402124AA00019B
71641+:10F20000AD0700003C010800AC2A310400C0102109
71642+:10F2100003E0000827BD0010308220001040000BE2
71643+:10F2200000055880016648218D24400024680004B0
71644+:10F2300000083880AFA4000000E618218C6540006B
71645+:10F24000AFA000080A001057AFA500040000000D91
71646+:10F250000A0010588FA9000827BDFFE03C07800076
71647+:10F2600034E60100AFBF001CAFB20018AFB100140C
71648+:10F27000AFB0001094C5000E8F87000030A4FFFFD0
71649+:10F280002483000430E2400010400010AF830028C7
71650+:10F290003C09002000E940241100000D30EC800002
71651+:10F2A0008F8A0004240BBFFF00EB38243543100085
71652+:10F2B000AF87000030F220001640000B3C1900041C
71653+:10F2C000241FFFBF0A0010B7007F102430EC80001D
71654+:10F2D000158000423C0E002030F220001240FFF862
71655+:10F2E0008F8300043C19000400F9C0241300FFF5CB
71656+:10F2F000241FFFBF34620040AF82000430E20100EF
71657+:10F300001040001130F010008F83002C10600006B8
71658+:10F310003C0F80003C05002000E52024148000C044
71659+:10F320003C0800043C0F800035EE010095CD001E26
71660+:10F3300095CC001C31AAFFFF000C5C00014B482556
71661+:10F34000AF89000C30F010001200000824110001F9
71662+:10F3500030F100201620008B3C18100000F890249B
71663+:10F36000164000823C040C002411000130E801002A
71664+:10F370001500000B3C0900018F85000430A94000F6
71665+:10F38000152000073C0900013C0C1F0100EC58242B
71666+:10F390003C0A1000116A01183C1080003C09000171
71667+:10F3A00000E9302410C000173C0B10003C18080086
71668+:10F3B0008F1800243307000214E0014024030001E9
71669+:10F3C0008FBF001C8FB200188FB100148FB00010D7
71670+:10F3D0000060102103E0000827BD002000EE682433
71671+:10F3E00011A0FFBE30F220008F8F00043C11FFFF00
71672+:10F3F00036307FFF00F0382435E380000A0010A685
71673+:10F40000AF87000000EB102450400065AF8000245F
71674+:10F410008F8C002C3C0D0F0000ED18241580008807
71675+:10F42000AF83001030E8010011000086938F0010B8
71676+:10F430003C0A0200106A00833C1280003650010032
71677+:10F44000920500139789002A3626000230AF00FF8C
71678+:10F4500025EE0004000E19C03C0480008C9801B811
71679+:10F460000700FFFE34880180AD0300003C198008CE
71680+:10F47000AC830020973100483225FFFF10A0015CCB
71681+:10F48000AF8500082523001200A3F82B53E0015993
71682+:10F490008F850004348D010095AC00202402001AF1
71683+:10F4A00030E44000318BFFFFA102000B108001927D
71684+:10F4B0002563FFFE00A3502B154001908F8F0004A1
71685+:10F4C000A50300148F88000435050001AF850004F2
71686+:10F4D0003C08800035190180A729000EA729001AD1
71687+:10F4E0008F89000C30B18000A7270010AF290028B9
71688+:10F4F000A72600081220000E3C04800035020100FF
71689+:10F50000944C0016318BFFFC256400040088182100
71690+:10F510008C7F400033E6FFFF14C000053C048000F0
71691+:10F520003C0AFFFF354D7FFF00AD2824AF85000466
71692+:10F53000240EBFFF00AE402434850180A4A800261D
71693+:10F54000ACA7002C3C071000AC8701B800001821C4
71694+:10F550008FBF001C8FB200188FB100148FB0001045
71695+:10F560000060102103E0000827BD00203C020BFFD3
71696+:10F5700000E41824345FFFFF03E3C82B5320FF7B14
71697+:10F58000241100013C0608008CC6002C24C5000193
71698+:10F590003C010800AC25002C0A0010D42411000501
71699+:10F5A0008F85002410A0002FAF80001090A30000D2
71700+:10F5B000146000792419000310A0002A30E601002D
71701+:10F5C00010C000CC8F860010241F000210DF00C97D
71702+:10F5D0008F8B000C3C0708008CE7003824E4FFFF09
71703+:10F5E00014E0000201641824000018213C0D0800FA
71704+:10F5F00025AD0038006D1021904C00048F85002847
71705+:10F6000025830004000321C030A5FFFF3626000239
71706+:10F610000E000FDB000000000A00114D0000182151
71707+:10F6200000E8302414C0FF403C0F80000E00103D65
71708+:10F63000000000008F8700000A0010CAAF82000C93
71709+:10F64000938F00103C18080127189640000F90C0B7
71710+:10F6500002588021AF9000248F85002414A0FFD38E
71711+:10F66000AF8F00103C0480008C86400030C5010044
71712+:10F6700010A000BC322300043C0C08008D8C002438
71713+:10F6800024120004106000C23190000D3C04800080
71714+:10F690008C8D40003402FFFF11A201003231FFFBCC
71715+:10F6A0008C884000310A01005540000124110010EF
71716+:10F6B00030EE080011C000BE2419FFFB8F9800280F
71717+:10F6C0002F0F03EF51E000010219802430E90100FF
71718+:10F6D00011200014320800018F87002C14E000FB79
71719+:10F6E0008F8C000C3C05800034AB0100917F00132F
71720+:10F6F00033E300FF246A00042403FFFE0203802496
71721+:10F70000000A21C012000002023230253226FFFF1B
71722+:10F710000E000FDB9785002A1200FF290000182138
71723+:10F72000320800011100000D32180004240E0001FF
71724+:10F73000120E0002023230253226FFFF9785002A82
71725+:10F740000E000FDB00002021240FFFFE020F80249B
71726+:10F750001200FF1B00001821321800045300FF188C
71727+:10F760002403000102323025241200045612000145
71728+:10F770003226FFFF9785002A0E000FDB24040100CC
71729+:10F780002419FFFB021988241220FF0D0000182104
71730+:10F790000A0010E9240300011079009C00003021C8
71731+:10F7A00090AD00012402000211A200BE30EA004028
71732+:10F7B00090B90001241800011338007F30E900409F
71733+:10F7C0008CA600049785002A00C020210E000FDBC4
71734+:10F7D0003626000200004021010018218FBF001CC6
71735+:10F7E0008FB200188FB100148FB00010006010218C
71736+:10F7F00003E0000827BD0020360F010095EE000C45
71737+:10F8000031CD020015A0FEE63C0900013C1880083D
71738+:10F81000971200489789002A362600023248FFFFD7
71739+:10F82000AF8800083C0380008C7101B80620FFFE01
71740+:10F83000346A0180AD4000001100008E3C0F800052
71741+:10F84000253F0012011FC82B1320008B240E00033C
71742+:10F85000346C0100958B00202402001A30E4400033
71743+:10F860003163FFFFA142000B108000A72463FFFE5D
71744+:10F870000103682B15A000A52408FFFE34A5000194
71745+:10F88000A5430014AF8500043C0480002412BFFF90
71746+:10F8900000B2802434850180A4A9000EA4A9001A16
71747+:10F8A000A4A60008A4B00026A4A700103C071000DE
71748+:10F8B000AC8701B80A00114D000018213C038000FC
71749+:10F8C00034640100949F000E3C1908008F3900D861
71750+:10F8D0002404008033E5FFFF273100013C010800CC
71751+:10F8E000AC3100D80E000FDB240600030A00114DD6
71752+:10F8F00000001821240A000210CA00598F85002830
71753+:10F900003C0308008C6300D0240E0001106E005EE2
71754+:10F910002CCF000C24D2FFFC2E5000041600002136
71755+:10F9200000002021241800021078001B2CD9000CA4
71756+:10F9300024DFFFF82FE900041520FF330000202109
71757+:10F9400030EB020051600004000621C054C00022C8
71758+:10F9500030A5FFFF000621C030A5FFFF0A00117D82
71759+:10F96000362600023C0908008D29002431300001B0
71760+:10F970005200FEF7000018219785002A3626000263
71761+:10F980000E000FDB000020210A00114D000018219D
71762+:10F990000A00119C241200021320FFE624DFFFF866
71763+:10F9A0000000202130A5FFFF0A00117D362600024D
71764+:10F9B0000A0011AC021980245120FF828CA6000499
71765+:10F9C0003C05080190A5964110A0FF7E2408000187
71766+:10F9D0000A0011F0010018210E000FDB3226000191
71767+:10F9E0008F8600108F8500280A00124F000621C064
71768+:10F9F0008F8500043C18800024120003371001801A
71769+:10FA0000A212000B0A00112E3C08800090A30001F6
71770+:10FA1000241100011071FF70240800012409000264
71771+:10FA20005069000430E60040240800010A0011F08B
71772+:10FA30000100182150C0FFFD240800013C0C80008B
71773+:10FA4000358B01009563001094A40002307FFFFF06
71774+:10FA5000509FFF62010018210A001284240800014F
71775+:10FA60002CA803EF1100FE56240300010A001239EE
71776+:10FA700000000000240E000335EA0180A14E000BB7
71777+:10FA80000A00121C3C04800011E0FFA2000621C005
71778+:10FA900030A5FFFF0A00117D362600020A0011A5DD
71779+:10FAA000241100201140FFC63C1280003650010096
71780+:10FAB000960F001094AE000231E80FFF15C8FFC08A
71781+:10FAC000000000000A0011E690B900013C060800A1
71782+:10FAD0008CC6003824C4FFFF14C00002018418241F
71783+:10FAE000000018213C0D080025AD0038006D1021E4
71784+:10FAF0000A0011B6904300048F8F0004240EFFFE0D
71785+:10FB00000A00112C01EE28242408FFFE0A00121A14
71786+:10FB100000A8282427BDFFC8AFB00010AFBF003435
71787+:10FB20003C10600CAFBE0030AFB7002CAFB6002861
71788+:10FB3000AFB50024AFB40020AFB3001CAFB20018C3
71789+:10FB4000AFB100148E0E5000240FFF7F3C068000E2
71790+:10FB500001CF682435AC380C240B0003AE0C5000E8
71791+:10FB6000ACCB00083C010800AC2000200E001819A6
71792+:10FB7000000000003C0A0010354980513C06601628
71793+:10FB8000AE09537C8CC700003C0860148D0500A0B2
71794+:10FB90003C03FFFF00E320243C02535300051FC237
71795+:10FBA0001482000634C57C000003A08002869821E0
71796+:10FBB0008E7200043C116000025128218CBF007C31
71797+:10FBC0008CA200783C1E600037C420203C05080150
71798+:10FBD00024A59288AF820018AF9F001C0E0016DD8E
71799+:10FBE0002406000A3C190001273996403C01080010
71800+:10FBF000AC3931DC0E0020DDAF8000148FD708084F
71801+:10FC00002418FFF03C15570902F8B02412D502F56C
71802+:10FC100024040001AF80002C3C1480003697018042
71803+:10FC20003C1E080127DE9644369301008E900000AA
71804+:10FC30003205000310A0FFFD3207000110E000882C
71805+:10FC4000320600028E7100283C048000AE91002034
71806+:10FC50008E6500048E66000000A0382100C040219F
71807+:10FC60008C8301B80460FFFE3C0B0010240A0800DE
71808+:10FC700000AB4824AC8A01B8552000E0240BBFFF3C
71809+:10FC80009675000E3C1208008E52002030AC4000E9
71810+:10FC900032AFFFFF264E000125ED00043C010800B5
71811+:10FCA000AC2E0020118000E8AF8D00283C18002009
71812+:10FCB00000B8B02412C000E530B980002408BFFFAE
71813+:10FCC00000A8382434C81000AF87000030E62000B8
71814+:10FCD00010C000E92409FFBF3C03000400E328240E
71815+:10FCE00010A00002010910243502004030EA010092
71816+:10FCF00011400010AF8200048F8B002C11600007B0
71817+:10FD00003C0D002000ED6024118000043C0F000435
71818+:10FD100000EF702411C00239000000009668001E38
71819+:10FD20009678001C3115FFFF0018B40002B690252C
71820+:10FD3000AF92000C30F910001320001324150001BD
71821+:10FD400030FF002017E0000A3C04100000E41024FB
71822+:10FD50001040000D3C0A0C003C090BFF00EA18247F
71823+:10FD60003525FFFF00A3302B10C0000830ED010047
71824+:10FD70003C0C08008D8C002C24150005258B0001FF
71825+:10FD80003C010800AC2B002C30ED010015A0000B4D
71826+:10FD90003C0500018F85000430AE400055C00007CF
71827+:10FDA0003C0500013C161F0100F690243C0F10009A
71828+:10FDB000124F01CE000000003C05000100E5302498
71829+:10FDC00010C000AF3C0C10003C1F08008FFF002447
71830+:10FDD00033E90002152000712403000100601021A6
71831+:10FDE000104000083C0680003C08800035180100E7
71832+:10FDF0008F0F00243C056020ACAF00140000000011
71833+:10FE00003C0680003C194000ACD9013800000000DD
71834+:10FE10005220001332060002262B0140262C0080BF
71835+:10FE2000240EFF80016E2024018E6824000D1940ED
71836+:10FE3000318A007F0004A9403172007F3C16200007
71837+:10FE400036C20002006A482502B2382500E2882541
71838+:10FE50000122F825ACDF0830ACD1083032060002B0
71839+:10FE600010C0FF723C188000370501408CA80000CC
71840+:10FE700024100040AF08002090AF000831E300706C
71841+:10FE8000107000D428790041532000082405006038
71842+:10FE9000241100201071000E3C0A40003C09800033
71843+:10FEA000AD2A01780A001304000000001465FFFB6E
71844+:10FEB0003C0A40000E001FFA000000003C0A40000F
71845+:10FEC0003C098000AD2A01780A00130400000000FC
71846+:10FED00090A90009241F00048CA70000312800FF0E
71847+:10FEE000111F01B22503FFFA2C7200061240001404
71848+:10FEF0003C0680008CA9000494A4000A310500FF90
71849+:10FF000000095E022D6A00083086FFFF15400002DE
71850+:10FF10002567000424070003240C000910AC01FA33
71851+:10FF200028AD000A11A001DE2410000A240E0008EA
71852+:10FF300010AE0028000731C000C038213C06800008
71853+:10FF40008CD501B806A0FFFE34D20180AE47000078
71854+:10FF500034CB0140916E0008240300023C0A4000AB
71855+:10FF600031C400FF00046A0001A86025A64C000807
71856+:10FF7000A243000B9562000A3C0810003C09800077
71857+:10FF8000A64200108D670004AE470024ACC801B83B
71858+:10FF9000AD2A01780A001304000000003C0A80002A
71859+:10FFA000354401009483000E3C0208008C4200D8C6
71860+:10FFB000240400803065FFFF245500013C01080047
71861+:10FFC000AC3500D80E000FDB240600030A001370C6
71862+:10FFD000000018210009320230D900FF2418000166
71863+:10FFE0001738FFD5000731C08F910020262200016D
71864+:10FFF000AF8200200A0013C800C0382100CB2024A3
71865+:020000021000EC
71866+:10000000AF85000010800008AF860004240D87FF34
71867+:1000100000CD6024158000083C0E006000AE302446
71868+:1000200010C00005000000000E000D42000000009E
71869+:100030000A001371000000000E0016050000000009
71870+:100040000A0013710000000030B980005320FF1F28
71871+:10005000AF8500003C02002000A2F82453E0FF1B03
71872+:10006000AF8500003C07FFFF34E47FFF00A4382485
71873+:100070000A00132B34C880000A001334010910242D
71874+:1000800000EC58245160005AAF8000248F8D002C62
71875+:100090003C0E0F0000EE182415A00075AF83001071
71876+:1000A00030EF010011E00073939800103C12020041
71877+:1000B000107200703C06800034D9010093280013B0
71878+:1000C0009789002A36A60002311800FF271600047F
71879+:1000D000001619C03C0480008C8501B804A0FFFE06
71880+:1000E00034880180AD0300003C158008AC830020FB
71881+:1000F00096BF004833E5FFFF10A001BCAF850008A4
71882+:100100002523001200A3102B504001B98F85000455
71883+:10011000348D010095AC0020240B001A30E440001F
71884+:10012000318AFFFFA10B000B108001BA2543FFFEAF
71885+:1001300000A3702B15C001B88F9600048F8F0004A8
71886+:10014000A503001435E50001AF8500043C088000DC
71887+:1001500035150180A6A9000EA6A9001A8F89000CEA
71888+:1001600030BF8000A6A70010AEA90028A6A60008F0
71889+:1001700013E0000F3C0F8000350C0100958B00163A
71890+:10018000316AFFFC25440004008818218C6240007D
71891+:100190003046FFFF14C000072416BFFF3C0EFFFFD0
71892+:1001A00035CD7FFF00AD2824AF8500043C0F8000D3
71893+:1001B0002416BFFF00B6902435E50180A4B20026C6
71894+:1001C000ACA7002C3C071000ADE701B80A00137083
71895+:1001D000000018210E00165D000000003C0A4000DF
71896+:1001E0003C098000AD2A01780A00130400000000D9
71897+:1001F0008F85002410A00027AF80001090A300007E
71898+:10020000106000742409000310690101000030210E
71899+:1002100090AE0001240D000211CD014230EF0040EC
71900+:1002200090A90001241F0001113F000930E20040A5
71901+:100230008CA600049785002A00C020210E000FDB49
71902+:1002400036A60002000040210A00137001001821A8
71903+:100250005040FFF88CA600043C07080190E7964147
71904+:1002600010E0FFF4240800010A00137001001821B7
71905+:10027000939800103C1F080127FF96400018C8C043
71906+:10028000033F4021AF8800248F85002414A0FFDBAA
71907+:10029000AF9800103C0480008C86400030C50100FF
71908+:1002A00010A0008732AB00043C0C08008D8C0024A9
71909+:1002B00024160004156000033192000D241600027C
71910+:1002C0003C0480008C8E4000340DFFFF11CD0113E3
71911+:1002D00032B5FFFB8C984000330F010055E0000160
71912+:1002E0002415001030E80800110000382409FFFB35
71913+:1002F0008F9F00282FF903EF53200001024990241B
71914+:1003000030E2010010400014325F00018F87002CA2
71915+:1003100014E0010E8F8C000C3C0480003486010038
71916+:1003200090C5001330AA00FF25430004000321C03C
71917+:100330002419FFFE025990241240000202B6302513
71918+:1003400032A6FFFF0E000FDB9785002A1240FEA3A6
71919+:1003500000001821325F000113E0000D3247000455
71920+:10036000240900011249000202B6302532A6FFFF1F
71921+:100370009785002A0E000FDB000020212402FFFEDB
71922+:10038000024290241240FE950000182132470004DA
71923+:1003900050E0FE922403000102B63025241600042A
71924+:1003A0005656000132A6FFFF9785002A0E000FDB8C
71925+:1003B000240401002403FFFB0243A82412A0FE87AB
71926+:1003C000000018210A001370240300010A0014B968
71927+:1003D0000249902410A0FFAF30E5010010A00017E3
71928+:1003E0008F8600102403000210C300148F84000CB9
71929+:1003F0003C0608008CC6003824CAFFFF14C0000267
71930+:10040000008A1024000010213C0E080025CE003880
71931+:10041000004E682191AC00048F850028258B0004D4
71932+:10042000000B21C030A5FFFF36A600020E000FDB37
71933+:10043000000000000A00137000001821240F0002C1
71934+:1004400010CF0088241600013C0308008C6300D004
71935+:100450001076008D8F85002824D9FFFC2F280004FA
71936+:100460001500006300002021241F0002107F005DA2
71937+:100470002CC9000C24C3FFF82C6200041440FFE9CF
71938+:100480000000202130EA020051400004000621C093
71939+:1004900054C0000530A5FFFF000621C030A5FFFFB6
71940+:1004A0000A00150436A600020E000FDB32A600017A
71941+:1004B0008F8600108F8500280A001520000621C0B5
71942+:1004C0003C0A08008D4A0024315200015240FE438C
71943+:1004D000000018219785002A36A600020E000FDBC7
71944+:1004E000000020210A001370000018219668000CFB
71945+:1004F000311802005700FE313C0500013C1F800806
71946+:1005000097F900489789002A36A600023328FFFF92
71947+:10051000AF8800083C0380008C7501B806A0FFFE80
71948+:100520003C04800034820180AC400000110000B621
71949+:1005300024180003252A0012010A182B106000B2AB
71950+:1005400000000000966F00203C0E8000240D001A71
71951+:1005500031ECFFFF35CA018030EB4000A14D000BAC
71952+:10056000116000B02583FFFE0103902B164000AE02
71953+:100570002416FFFE34A50001A5430014AF85000436
71954+:100580002419BFFF00B94024A6E9000EA6E9001A0D
71955+:10059000A6E60008A6E80026A6E700103C07100023
71956+:1005A000AE8701B80A001370000018213C048000D7
71957+:1005B0008C8201B80440FFFE349601802415001C93
71958+:1005C000AEC70000A2D5000B3C071000AC8701B8F5
71959+:1005D0003C0A40003C098000AD2A01780A0013045F
71960+:1005E000000000005120FFA424C3FFF800002021D8
71961+:1005F00030A5FFFF0A00150436A600020E00103DCC
71962+:10060000000000008F8700000A001346AF82000C34
71963+:1006100090A30001241500011075FF0B24080001B0
71964+:10062000240600021066000430E2004024080001A5
71965+:100630000A001370010018215040FFFD240800013A
71966+:100640003C0C8000358B0100956A001094A40002D8
71967+:100650003143FFFF5083FDE1010018210A00158599
71968+:10066000240800018F8500282CB203EF1240FDDB27
71969+:10067000240300013C0308008C6300D02416000111
71970+:100680001476FF7624D9FFFC2CD8000C1300FF72DF
71971+:10069000000621C030A5FFFF0A00150436A600029F
71972+:1006A00010B00037240F000B14AFFE23000731C039
71973+:1006B000312600FF00065600000A4E0305220047BF
71974+:1006C00030C6007F0006F8C03C16080126D69640CA
71975+:1006D00003F68021A2000001A20000003C0F600090
71976+:1006E0008DF918202405000100C588040011302769
71977+:1006F0000326C024000731C000C03821ADF81820FF
71978+:100700000A0013C8A60000028F850020000731C030
71979+:1007100024A2FFFF0A0013F6AF8200200A0014B2E1
71980+:100720002415002011E0FECC3C1980003728010080
71981+:100730009518001094B6000233120FFF16D2FEC6B1
71982+:10074000000000000A00148290A900013C0B080080
71983+:100750008D6B0038256DFFFF15600002018D1024A0
71984+:10076000000010213C080800250800380048C0217E
71985+:10077000930F000425EE00040A0014C5000E21C0EA
71986+:1007800000065202241F00FF115FFDEB000731C07D
71987+:10079000000A20C03C0E080125CE9640008EA821FC
71988+:1007A000009E602100095C02240D00013C076000EE
71989+:1007B000A2AD0000AD860000A2AB00018CF21820B3
71990+:1007C00024030001014310040242B025ACF61820B6
71991+:1007D00000C038210A0013C8A6A900020A0015AA01
71992+:1007E000AF8000200A0012FFAF84002C8F85000428
71993+:1007F0003C1980002408000337380180A308000B4F
71994+:100800000A00144D3C088000A2F8000B0A00155A9B
71995+:100810002419BFFF8F9600042412FFFE0A00144B18
71996+:1008200002D228242416FFFE0A00155800B62824F8
71997+:100830003C038000346401008C85000030A2003E3F
71998+:100840001440000800000000AC6000488C870000E5
71999+:1008500030E607C010C0000500000000AC60004C8E
72000+:10086000AC60005003E0000824020001AC600054BA
72001+:10087000AC6000408C880000310438001080FFF923
72002+:10088000000000002402000103E00008AC60004406
72003+:100890003C0380008C6201B80440FFFE3467018095
72004+:1008A000ACE4000024080001ACE00004A4E500086A
72005+:1008B00024050002A0E8000A34640140A0E5000B12
72006+:1008C0009483000A14C00008A4E30010ACE00024E4
72007+:1008D0003C07800034E901803C041000AD20002872
72008+:1008E00003E00008ACE401B88C8600043C0410006E
72009+:1008F000ACE600243C07800034E90180AD200028EC
72010+:1009000003E00008ACE401B83C0680008CC201B8EA
72011+:100910000440FFFE34C7018024090002ACE400005B
72012+:10092000ACE40004A4E50008A0E9000A34C50140D5
72013+:10093000A0E9000B94A8000A3C041000A4E80010F1
72014+:10094000ACE000248CA30004ACE3002803E0000822
72015+:10095000ACC401B83C039000346200010082202541
72016+:100960003C038000AC6400208C65002004A0FFFEE6
72017+:100970000000000003E00008000000003C028000CE
72018+:10098000344300010083202503E00008AC4400202C
72019+:1009900027BDFFE03C098000AFBF0018AFB10014D5
72020+:1009A000AFB00010352801408D10000091040009FF
72021+:1009B0009107000891050008308400FF30E600FF31
72022+:1009C00000061A002C820081008330251040002A86
72023+:1009D00030A50080000460803C0D080125AD92B078
72024+:1009E000018D58218D6A00000140000800000000C0
72025+:1009F0003C038000346201409445000A14A0001EAC
72026+:100A00008F91FCC09227000530E6000414C0001A44
72027+:100A1000000000000E00164E02002021922A000560
72028+:100A200002002021354900040E001658A2290005B5
72029+:100A30009228000531040004148000020000000028
72030+:100A40000000000D922D0000240B002031AC00FFAF
72031+:100A5000158B00093C0580008CAE01B805C0FFFE77
72032+:100A600034B10180AE3000003C0F100024100005AE
72033+:100A7000A230000BACAF01B80000000D8FBF001812
72034+:100A80008FB100148FB0001003E0000827BD0020D4
72035+:100A90000200202100C028218FBF00188FB1001450
72036+:100AA0008FB00010240600010A00161D27BD00208B
72037+:100AB0000000000D0200202100C028218FBF001877
72038+:100AC0008FB100148FB00010000030210A00161DF5
72039+:100AD00027BD002014A0FFE8000000000200202134
72040+:100AE0008FBF00188FB100148FB0001000C02821F4
72041+:100AF0000A00163B27BD00203C0780008CEE01B8A1
72042+:100B000005C0FFFE34F00180241F0002A21F000B6D
72043+:100B100034F80140A60600089719000A3C0F10009F
72044+:100B2000A61900108F110004A6110012ACEF01B835
72045+:100B30000A0016998FBF001827BDFFE8AFBF00104D
72046+:100B40000E000FD4000000003C0280008FBF001098
72047+:100B500000002021AC4001800A00108F27BD001842
72048+:100B60003084FFFF30A5FFFF108000070000182130
72049+:100B7000308200011040000200042042006518216C
72050+:100B80001480FFFB0005284003E0000800601021EE
72051+:100B900010C00007000000008CA2000024C6FFFF68
72052+:100BA00024A50004AC82000014C0FFFB24840004D0
72053+:100BB00003E000080000000010A0000824A3FFFFCD
72054+:100BC000AC86000000000000000000002402FFFFCF
72055+:100BD0002463FFFF1462FFFA2484000403E000088A
72056+:100BE000000000003C03800027BDFFF83462018054
72057+:100BF000AFA20000308C00FF30AD00FF30CE00FF10
72058+:100C00003C0B80008D6401B80480FFFE00000000F2
72059+:100C10008FA900008D6801288FAA00008FA700000F
72060+:100C20008FA400002405000124020002A085000A10
72061+:100C30008FA30000359940003C051000A062000B16
72062+:100C40008FB800008FAC00008FA600008FAF0000AF
72063+:100C500027BD0008AD280000AD400004AD80002491
72064+:100C6000ACC00028A4F90008A70D0010A5EE0012E2
72065+:100C700003E00008AD6501B83C06800827BDFFE829
72066+:100C800034C50080AFBF001090A7000924020012F5
72067+:100C900030E300FF1062000B008030218CA8005070
72068+:100CA00000882023048000088FBF00108CAA003425
72069+:100CB000240400390000282100CA4823052000052B
72070+:100CC000240600128FBF00102402000103E0000878
72071+:100CD00027BD00180E0016F2000000008FBF0010A4
72072+:100CE0002402000103E0000827BD001827BDFFC84B
72073+:100CF000AFB20030AFB00028AFBF0034AFB1002CAE
72074+:100D000000A0802190A5000D30A6001010C000109A
72075+:100D1000008090213C0280088C4400048E0300086F
72076+:100D20001064000C30A7000530A6000510C0009329
72077+:100D3000240400018FBF00348FB200308FB1002C2B
72078+:100D40008FB000280080102103E0000827BD003884
72079+:100D500030A7000510E0000F30AB001210C00006F5
72080+:100D6000240400013C0980088E0800088D25000439
72081+:100D70005105009C240400388FBF00348FB200302E
72082+:100D80008FB1002C8FB000280080102103E00008F4
72083+:100D900027BD0038240A0012156AFFE6240400016A
72084+:100DA0000200202127A500100E000CB6AFA00010F5
72085+:100DB0001440007C3C19800837240080909800087B
72086+:100DC000331100081220000A8FA7001030FF010025
72087+:100DD00013E000A48FA300148C8600580066102333
72088+:100DE000044000043C0A8008AC8300588FA7001020
72089+:100DF0003C0A800835480080910900083124000829
72090+:100E00001480000224080003000040213C1F8008D9
72091+:100E100093F1001193F9001237E600808CCC005456
72092+:100E2000333800FF03087821322D00FF000F708057
72093+:100E300001AE282100AC582B1160006F00000000AB
72094+:100E400094CA005C8CC900543144FFFF0125102373
72095+:100E50000082182B14600068000000008CCB005446
72096+:100E60000165182330EC00041180006C000830800C
72097+:100E70008FA8001C0068102B1040006230ED0004A9
72098+:100E8000006610232C46008010C00002004088211C
72099+:100E9000241100800E00164E024020213C0D8008D7
72100+:100EA00035A6008024070001ACC7000C90C80008DC
72101+:100EB0000011484035A70100310C007FA0CC00088C
72102+:100EC0008E05000424AB0001ACCB0030A4D1005C43
72103+:100ED0008CCA003C9602000E01422021ACC40020C6
72104+:100EE0008CC3003C0069F821ACDF001C8E190004A3
72105+:100EF000ACF900008E180008ACF800048FB10010A7
72106+:100F0000322F000855E0004793A60020A0C0004EF5
72107+:100F100090D8004E2411FFDFA0F8000890CF000801
72108+:100F200001F17024A0CE00088E0500083C0B80085B
72109+:100F300035690080AD2500388D6A00148D2200309F
72110+:100F40002419005001422021AD24003491230000D7
72111+:100F5000307F00FF13F90036264F01000E001658AF
72112+:100F60000240202124040038000028210E0016F23F
72113+:100F70002406000A0A001757240400010E000D2859
72114+:100F8000000020218FBF00348FB200308FB1002CC1
72115+:100F90008FB00028004020210080102103E00008CD
72116+:100FA00027BD00388E0E00083C0F800835F0008009
72117+:100FB000AE0E005402402021AE0000300E00164E4E
72118+:100FC00000000000920D00250240202135AC0020D9
72119+:100FD0000E001658A20C00250E000CAC0240202179
72120+:100FE000240400382405008D0E0016F22406001299
72121+:100FF0000A0017572404000194C5005C0A001792E8
72122+:1010000030A3FFFF2407021811A0FF9E00E6102363
72123+:101010008FAE001C0A00179A01C610230A0017970A
72124+:101020002C620218A0E600080A0017C48E0500080A
72125+:101030002406FF8001E6C0243C118000AE38002861
72126+:101040008E0D000831E7007F3C0E800C00EE602121
72127+:10105000AD8D00E08E080008AF8C00380A0017D074
72128+:10106000AD8800E4AC800058908500082403FFF7A9
72129+:1010700000A33824A08700080A0017758FA7001066
72130+:101080003C05080024A560A83C04080024846FF4F3
72131+:101090003C020800244260B0240300063C01080121
72132+:1010A000AC2596C03C010801AC2496C43C01080163
72133+:1010B000AC2296C83C010801A02396CC03E00008AE
72134+:1010C0000000000003E00008240200013C02800050
72135+:1010D000308800FF344701803C0680008CC301B893
72136+:1010E0000460FFFE000000008CC501282418FF806A
72137+:1010F0003C0D800A24AF010001F8702431EC007F20
72138+:10110000ACCE0024018D2021ACE50000948B00EAD8
72139+:101110003509600024080002316AFFFFACEA0004D0
72140+:1011200024020001A4E90008A0E8000BACE00024C0
72141+:101130003C071000ACC701B8AF84003803E00008DA
72142+:10114000AF85006C938800488F8900608F820038DB
72143+:1011500030C600FF0109382330E900FF01221821C1
72144+:1011600030A500FF2468008810C000020124382147
72145+:101170000080382130E400031480000330AA00030B
72146+:101180001140000D312B000310A0000900001021B8
72147+:1011900090ED0000244E000131C200FF0045602B9D
72148+:1011A000A10D000024E700011580FFF925080001CA
72149+:1011B00003E00008000000001560FFF300000000DD
72150+:1011C00010A0FFFB000010218CF80000245900043F
72151+:1011D000332200FF0045782BAD18000024E70004FF
72152+:1011E00015E0FFF92508000403E0000800000000F6
72153+:1011F00093850048938800588F8700600004320070
72154+:101200003103007F00E5102B30C47F001040000F39
72155+:10121000006428258F8400383C0980008C8A00EC0B
72156+:10122000AD2A00A43C03800000A35825AC6B00A0AD
72157+:101230008C6C00A00580FFFE000000008C6D00ACEF
72158+:10124000AC8D00EC03E000088C6200A80A00188254
72159+:101250008F840038938800593C0280000080502120
72160+:10126000310300FEA383005930ABFFFF30CC00FFF9
72161+:1012700030E7FFFF344801803C0980008D2401B82D
72162+:101280000480FFFE8F8D006C24180016AD0D000049
72163+:101290008D2201248F8D0038AD0200048D5900206D
72164+:1012A000A5070008240201C4A119000AA118000B17
72165+:1012B000952F01208D4E00088D4700049783005C18
72166+:1012C0008D59002401CF302100C7282100A32023FD
72167+:1012D0002418FFFFA504000CA50B000EA5020010AA
72168+:1012E000A50C0012AD190018AD18002495AF00E848
72169+:1012F0003C0B10002407FFF731EEFFFFAD0E002876
72170+:101300008DAC0084AD0C002CAD2B01B88D460020B7
72171+:1013100000C7282403E00008AD4500208F8800386E
72172+:101320000080582130E7FFFF910900D63C02800081
72173+:1013300030A5FFFF312400FF00041A00006750258C
72174+:1013400030C600FF344701803C0980008D2C01B875
72175+:101350000580FFFE8F82006C240F0017ACE20000B6
72176+:101360008D390124ACF900048D780020A4EA00082E
72177+:10137000241901C4A0F8000AA0EF000B9523012056
72178+:101380008D6E00088D6D00049784005C01C35021B0
72179+:10139000014D602101841023A4E2000CA4E5000E9D
72180+:1013A000A4F90010A4E60012ACE000148D7800242B
72181+:1013B000240DFFFFACF800188D0F007CACEF001C73
72182+:1013C0008D0E00783C0F1000ACEE0020ACED002438
72183+:1013D000950A00BE240DFFF73146FFFFACE600285A
72184+:1013E000950C00809504008231837FFF0003CA00C2
72185+:1013F0003082FFFF0322C021ACF8002CAD2F01B8D2
72186+:10140000950E00828D6A002000AE3021014D282407
72187+:10141000A506008203E00008AD6500203C028000C4
72188+:10142000344501803C0480008C8301B80460FFFED9
72189+:101430008F8A0044240600199549001C3128FFFFBB
72190+:10144000000839C0ACA70000A0A6000B3C051000A6
72191+:1014500003E00008AC8501B88F87004C0080402174
72192+:1014600030C400FF3C0680008CC201B80440FFFE7F
72193+:101470008F89006C9383006834996000ACA90000E8
72194+:10148000A0A300058CE20010240F00022403FFF744
72195+:10149000A4A20006A4B900088D180020A0B8000A74
72196+:1014A000A0AF000B8CEE0000ACAE00108CED000481
72197+:1014B000ACAD00148CEC001CACAC00248CEB002018
72198+:1014C000ACAB00288CEA002C3C071000ACAA002C26
72199+:1014D0008D090024ACA90018ACC701B88D05002007
72200+:1014E00000A3202403E00008AD0400208F8600380C
72201+:1014F00027BDFFE0AFB10014AFBF0018AFB00010C0
72202+:1015000090C300D430A500FF3062002010400008D6
72203+:10151000008088218CCB00D02409FFDF256A0001E0
72204+:10152000ACCA00D090C800D401093824A0C700D4A8
72205+:1015300014A000403C0C80008F840038908700D4B9
72206+:101540002418FFBF2406FFEF30E3007FA08300D400
72207+:10155000979F005C8F8200608F8D003803E2C82364
72208+:10156000A799005CA5A000BC91AF00D401F870243D
72209+:10157000A1AE00D48F8C0038A18000D78F8A0038AC
72210+:10158000A5400082AD4000EC914500D400A658244F
72211+:10159000A14B00D48F9000348F8400609786005C4C
72212+:1015A0000204282110C0000FAF850034A38000582A
72213+:1015B0003C0780008E2C000894ED01208E2B000447
72214+:1015C000018D5021014B8021020620233086FFFF30
72215+:1015D00030C8000F3909000131310001162000091F
72216+:1015E000A3880058938600488FBF00188FB100145D
72217+:1015F0008FB0001027BD0020AF85006403E0000815
72218+:10160000AF86006000C870238FBF00189386004823
72219+:101610008FB100148FB0001034EF0C00010F28219F
72220+:1016200027BD0020ACEE0084AF85006403E0000815
72221+:10163000AF86006035900180020028210E00190F4E
72222+:10164000240600828F840038908600D430C5004084
72223+:1016500050A0FFBAA38000688F85004C3C06800034
72224+:101660008CCD01B805A0FFFE8F89006C2408608234
72225+:1016700024070002AE090000A6080008A207000B1C
72226+:101680008CA300083C0E1000AE0300108CA2000CCE
72227+:10169000AE0200148CBF0014AE1F00188CB90018E5
72228+:1016A000AE1900248CB80024AE1800288CAF002896
72229+:1016B000AE0F002CACCE01B80A001948A380006818
72230+:1016C0008F8A003827BDFFE0AFB10014AFB0001023
72231+:1016D0008F880060AFBF00189389003C954200BC22
72232+:1016E00030D100FF0109182B0080802130AC00FFB1
72233+:1016F0003047FFFF0000582114600003310600FF4F
72234+:1017000001203021010958239783005C0068202BB9
72235+:101710001480002700000000106800562419000102
72236+:101720001199006334E708803165FFFF0E0018C08F
72237+:10173000020020218F83006C3C07800034E601808A
72238+:101740003C0580008CAB01B80560FFFE240A001840
72239+:101750008F840038ACC30000A0CA000B948900BE7F
72240+:101760003C081000A4C90010ACC00030ACA801B8FF
72241+:101770009482008024430001A4830080949F008011
72242+:101780003C0608008CC6318833EC7FFF1186005E72
72243+:101790000000000002002021022028218FBF001835
72244+:1017A0008FB100148FB000100A00193427BD00203B
72245+:1017B000914400D42403FF8000838825A15100D4E4
72246+:1017C0009784005C3088FFFF51000023938C003C1D
72247+:1017D0008F8500382402EFFF008B782394AE00BC85
72248+:1017E0000168502B31E900FF01C26824A4AD00BCA0
72249+:1017F00051400039010058213C1F800037E60100AC
72250+:101800008CD800043C190001031940245500000144
72251+:1018100034E740008E0A00202403FFFB241100015E
72252+:1018200001432024AE0400201191002D34E78000F4
72253+:1018300002002021012030210E0018C03165FFFF79
72254+:101840009787005C8F890060A780005C0127802358
72255+:10185000AF900060938C003C8F8B00388FBF0018D6
72256+:101860008FB100148FB0001027BD002003E00008E6
72257+:10187000A16C00D73C0D800035AA01008D48000402
72258+:101880003C0900010109282454A0000134E740006C
72259+:101890008E0F00202418FFFB34E7800001F870242D
72260+:1018A00024190001AE0E00201599FF9F34E708802F
72261+:1018B000020020210E00188E3165FFFF020020215A
72262+:1018C000022028218FBF00188FB100148FB00010A4
72263+:1018D0000A00193427BD00200A0019F7000048212A
72264+:1018E00002002021012030210E00188E3165FFFFFB
72265+:1018F0009787005C8F890060A780005C01278023A8
72266+:101900000A001A0EAF900060948C0080241F8000A3
72267+:10191000019F3024A4860080908B0080908F0080EF
72268+:10192000316700FF0007C9C20019C027001871C045
72269+:1019300031ED007F01AE2825A08500800A0019DF67
72270+:1019400002002021938500682403000127BDFFE8E1
72271+:1019500000A330042CA20020AFB00010AFBF0014D1
72272+:1019600000C01821104000132410FFFE3C0708009F
72273+:101970008CE7319000E610243C088000350501809A
72274+:1019800014400005240600848F890038240A0004CE
72275+:101990002410FFFFA12A00FC0E00190F0000000018
72276+:1019A000020010218FBF00148FB0001003E0000868
72277+:1019B00027BD00183C0608008CC631940A001A574F
72278+:1019C00000C310248F87004427BDFFE0AFB200188A
72279+:1019D000AFB10014AFB00010AFBF001C30D000FF9B
72280+:1019E00090E6000D00A088210080902130C5007F86
72281+:1019F000A0E5000D8F8500388E2300188CA200D042
72282+:101A00001062002E240A000E0E001A4AA38A0068F3
72283+:101A10002409FFFF104900222404FFFF5200002088
72284+:101A2000000020218E2600003C0C001000CC582421
72285+:101A3000156000393C0E000800CE682455A0003F18
72286+:101A4000024020213C18000200D880241200001F10
72287+:101A50003C0A00048F8700448CE200148CE30010E1
72288+:101A60008CE500140043F82303E5C82B1320000580
72289+:101A7000024020218E24002C8CF1001010910031A6
72290+:101A80000240202124020012A38200680E001A4A9C
72291+:101A90002412FFFF105200022404FFFF0000202147
72292+:101AA0008FBF001C8FB200188FB100148FB00010D0
72293+:101AB0000080102103E0000827BD002090A800D47A
72294+:101AC000350400200A001A80A0A400D400CA4824CB
72295+:101AD0001520000B8F8B00448F8D00448DAC0010BF
72296+:101AE0001580000B024020218E2E002C51C0FFECEF
72297+:101AF00000002021024020210A001A9B2402001726
72298+:101B00008D66001050C0FFE6000020210240202119
72299+:101B10000A001A9B24020011024020212402001511
72300+:101B20000E001A4AA3820068240FFFFF104FFFDC4B
72301+:101B30002404FFFF0A001A8A8E2600000A001AC138
72302+:101B4000240200143C08000400C8382450E0FFD4EC
72303+:101B500000002021024020210A001A9B24020013C9
72304+:101B60008F85003827BDFFD8AFB3001CAFB2001877
72305+:101B7000AFB10014AFB00010AFBF002090A700D4E9
72306+:101B80008F90004C2412FFFF34E2004092060000C8
72307+:101B9000A0A200D48E0300100080982110720006CD
72308+:101BA00030D1003F2408000D0E001A4AA3880068B7
72309+:101BB000105200252404FFFF8F8A00388E09001878
72310+:101BC0008D4400D01124000702602021240C000E57
72311+:101BD0000E001A4AA38C0068240BFFFF104B001A5A
72312+:101BE0002404FFFF24040020122400048F8D0038F9
72313+:101BF00091AF00D435EE0020A1AE00D48F85005403
72314+:101C000010A00019000000001224004A8F9800382C
72315+:101C10008F92FCC0971000809651000A5230004805
72316+:101C20008F9300403C1F08008FFF318C03E5C82BC9
72317+:101C30001720001E02602021000028210E0019A993
72318+:101C400024060001000020218FBF00208FB3001C5C
72319+:101C50008FB200188FB100148FB0001000801021D7
72320+:101C600003E0000827BD00285224002A8E05001436
72321+:101C70008F840038948A008025490001A48900805F
72322+:101C8000948800803C0208008C42318831077FFF35
72323+:101C900010E2000E00000000026020210E00193446
72324+:101CA000240500010A001B0B000020212402002D46
72325+:101CB0000E001A4AA38200682403FFFF1443FFE1C9
72326+:101CC0002404FFFF0A001B0C8FBF002094990080A2
72327+:101CD000241F800024050001033FC024A498008035
72328+:101CE00090920080908E0080325100FF001181C2DE
72329+:101CF00000107827000F69C031CC007F018D582576
72330+:101D0000A08B00800E001934026020210A001B0BFA
72331+:101D1000000020212406FFFF54A6FFD68F84003840
72332+:101D2000026020210E001934240500010A001B0B5B
72333+:101D300000002021026020210A001B252402000A45
72334+:101D40002404FFFD0A001B0BAF9300608F8800384E
72335+:101D500027BDFFE8AFB00010AFBF0014910A00D458
72336+:101D60008F87004C00808021354900408CE60010B0
72337+:101D7000A10900D43C0208008C4231B030C53FFFBD
72338+:101D800000A2182B106000078F850050240DFF80E3
72339+:101D900090AE000D01AE6024318B00FF156000088D
72340+:101DA0000006C382020020212403000D8FBF00140F
72341+:101DB0008FB0001027BD00180A001A4AA3830068DC
72342+:101DC00033060003240F000254CFFFF70200202146
72343+:101DD00094A2001C8F85003824190023A4A200E8D7
72344+:101DE0008CE8000000081E02307F003F13F9003528
72345+:101DF0003C0A00838CE800188CA600D0110600086D
72346+:101E0000000000002405000E0E001A4AA385006899
72347+:101E10002407FFFF104700182404FFFF8F850038B8
72348+:101E200090A900D435240020A0A400D48F8C0044B5
72349+:101E3000918E000D31CD007FA18D000D8F83005458
72350+:101E40001060001C020020218F8400508C9800102C
72351+:101E50000303782B11E0000D241900180200202143
72352+:101E6000A39900680E001A4A2410FFFF10500002C8
72353+:101E70002404FFFF000020218FBF00148FB000104A
72354+:101E80000080102103E0000827BD00188C86001098
72355+:101E90008F9F00440200202100C31023AFE20010F6
72356+:101EA000240500010E0019A9240600010A001B9751
72357+:101EB000000020210E001934240500010A001B97A0
72358+:101EC00000002021010A5824156AFFD98F8C004494
72359+:101ED000A0A600FC0A001B84A386005A30A500FFC0
72360+:101EE0002406000124A9000100C9102B1040000C99
72361+:101EF00000004021240A000100A61823308B0001B5
72362+:101F000024C60001006A3804000420421160000267
72363+:101F100000C9182B010740251460FFF800A61823FC
72364+:101F200003E000080100102127BDFFD8AFB0001862
72365+:101F30008F90004CAFB1001CAFBF00202403FFFF07
72366+:101F40002411002FAFA30010920600002405000802
72367+:101F500026100001006620260E001BB0308400FF12
72368+:101F600000021E003C021EDC34466F410A001BD8F2
72369+:101F70000000102110A00009008018212445000154
72370+:101F800030A2FFFF2C4500080461FFFA0003204047
72371+:101F90000086202614A0FFF9008018210E001BB037
72372+:101FA000240500208FA300102629FFFF313100FFF8
72373+:101FB00000034202240700FF1627FFE20102182651
72374+:101FC00000035027AFAA0014AFAA00100000302170
72375+:101FD00027A8001027A7001400E6782391ED00033E
72376+:101FE00024CE000100C8602131C600FF2CCB0004C4
72377+:101FF0001560FFF9A18D00008FA200108FBF002097
72378+:102000008FB1001C8FB0001803E0000827BD002826
72379+:1020100027BDFFD0AFB3001CAFB00010AFBF00288A
72380+:10202000AFB50024AFB40020AFB20018AFB10014B8
72381+:102030003C0C80008D880128240FFF803C06800A1C
72382+:1020400025100100250B0080020F68243205007F57
72383+:10205000016F7024AD8E009000A62821AD8D002464
72384+:1020600090A600FC3169007F3C0A8004012A1821F7
72385+:10207000A386005A9067007C00809821AF830030CF
72386+:1020800030E20002AF88006CAF85003800A0182154
72387+:10209000144000022404003424040030A3840048C7
72388+:1020A0008C7200DC30D100FF24040004AF92006089
72389+:1020B00012240004A38000688E7400041680001EA1
72390+:1020C0003C0880009386005930C7000110E0000FE3
72391+:1020D0008F9300608CB000848CA800842404FF805F
72392+:1020E000020410240002F940310A007F03EA482567
72393+:1020F0003C0C2000012C902530CD00FE3C038000DC
72394+:10210000AC720830A38D00598F9300608FBF0028F8
72395+:102110008FB50024ACB300DC8FB400208FB3001C5B
72396+:102120008FB200188FB100148FB00010240200018C
72397+:1021300003E0000827BD00308E7F000895020120D3
72398+:102140008E67001003E2C8213326FFFF30D8000F4E
72399+:1021500033150001AF87003416A00058A39800582B
72400+:1021600035090C000309382100D81823AD03008479
72401+:10217000AF8700648E6A00043148FFFF1100007EC3
72402+:10218000A78A005C90AC00D42407FF8000EC3024C8
72403+:1021900030CB00FF1560004B9786005C938E005A91
72404+:1021A000240D000230D5FFFF11CD02A20000A021B6
72405+:1021B0008F85006002A5802B160000BC9388004824
72406+:1021C0003C11800096240120310400FF1485008812
72407+:1021D0008F8400648F9800343312000356400085CA
72408+:1021E00030A500FF8F900064310C00FF24060034FE
72409+:1021F00011860095AF90004C9204000414800118E1
72410+:102200008F8E0038A380003C8E0D00048DC800D84E
72411+:102210003C0600FF34CCFFFF01AC30240106182B34
72412+:1022200014600120AF8600548F8700609798005C8F
72413+:10223000AF8700400307402310C000C7A788005C99
72414+:102240008F91003030C3000300035823922A007C92
72415+:102250003171000302261021000A20823092000111
72416+:102260000012488000492821311FFFFF03E5C82BD9
72417+:10227000132001208F8800388F8500348F880064F8
72418+:102280001105025A3C0E3F018E0600003C0C250051
72419+:1022900000CE682411AC01638F84004C30E500FF50
72420+:1022A0000E00184A000030218F8800388F870060A8
72421+:1022B0008F8500340A001DB78F8600540A001C5613
72422+:1022C000AF87006490A400D400E48024320200FFB1
72423+:1022D000104000169386005990A6008890AE00D753
72424+:1022E00024A8008830D4003F2686FFE02CD10020AF
72425+:1022F000A38E003C1220000CAF88004C240B000180
72426+:1023000000CB20043095001916A0012B3C0680005C
72427+:1023100034CF0002008FC0241700022E3099002015
72428+:1023200017200234000000009386005930CB0001D2
72429+:102330001160000F9788005C8CBF00848CA900841A
72430+:10234000240AFF8003EA6024000C19403132007F28
72431+:10235000007238253C0D200000EDC82530D800FE65
72432+:102360003C0F8000ADF90830A39800599788005CB5
72433+:102370001500FF84000000008E630020306200041E
72434+:102380001040FF51938600592404FFFB0064802411
72435+:102390003C038000AE700020346601808C7301B86D
72436+:1023A0000660FFFE8F98006C347501003C1400013C
72437+:1023B000ACD800008C6B012424076085ACCB0004F2
72438+:1023C0008EAE000401D488245220000124076083CB
72439+:1023D00024190002A4C700083C0F1000A0D9000B6C
72440+:1023E0003C068000ACCF01B80A001C2B9386005934
72441+:1023F00030A500FF0E00184A240600018F88006CEB
72442+:102400003C05800034A90900250201889388004812
72443+:10241000304A0007304B00783C0340802407FF809F
72444+:102420000163C825014980210047F824310C00FFD1
72445+:1024300024060034ACBF0800AF90004CACB90810C3
72446+:102440005586FF6E920400048F8400388E11003090
72447+:10245000908E00D431CD001015A000108F83006045
72448+:102460002C6F000515E000E400000000909800D4F7
72449+:102470002465FFFC331200101640000830A400FF52
72450+:102480008F9F00648F99003413F90004388700018E
72451+:1024900030E20001144001C8000000000E001BC320
72452+:1024A000000000000A001DF8000000008F84006496
72453+:1024B00030C500FF0E00184A24060001939800481A
72454+:1024C000240B0034130B00A08F8500388F8600602A
72455+:1024D0009783005C306EFFFF00CE8823AF910060D1
72456+:1024E000A780005C1280FF90028018212414FFFD59
72457+:1024F0005474FFA28E6300208E6A00042403FFBF81
72458+:102500002408FFEF0155F823AE7F000490AC00D4FF
72459+:102510003189007FA0A900D48E7200208F8F0038EF
72460+:10252000A780005C364D0002AE6D0020A5E000BC27
72461+:1025300091E500D400A3C824A1F900D48F950038F8
72462+:10254000AEA000EC92B800D403085824A2AB00D48B
72463+:102550000A001CD78F8500388F910034AF8000604F
72464+:1025600002275821AF8B0034000020212403FFFFF5
72465+:10257000108301B48F8500388E0C00103C0D0800CC
72466+:102580008DAD31B09208000031843FFF008D802B6B
72467+:1025900012000023310D003F3C1908008F3931A88B
72468+:1025A0008F9F006C000479802408FF80033F202166
72469+:1025B000008FC821938500590328F8243C06008029
72470+:1025C0003C0F800034D80001001F91403331007F60
72471+:1025D0008F8600380251502535EE0940332B0078A4
72472+:1025E000333000073C0310003C02800C017890253A
72473+:1025F000020E48210143C0250222382134AE0001D9
72474+:10260000ADFF0804AF890050ADF20814AF87004455
72475+:10261000ADFF0028ACD90084ADF80830A38E005976
72476+:102620009383005A24070003106700272407000142
72477+:102630001467FFAC8F8500382411002311B1008589
72478+:1026400000000000240E000B026020210E001A4A38
72479+:10265000A38E00680040A0210A001D328F8500383B
72480+:1026600002602021240B000C0E001A4AA38B006884
72481+:10267000240AFFFF104AFFBD2404FFFF8F8E00389D
72482+:10268000A380003C8E0D00048DC800D83C0600FFDE
72483+:1026900034CCFFFF01AC30240106182B1060FEE2A1
72484+:1026A000AF86005402602021241200190E001A4A3D
72485+:1026B000A3920068240FFFFF104FFFAC2404FFFF1C
72486+:1026C0000A001C838F86005425A3FFE02C74002091
72487+:1026D0001280FFDD240E000B000328803C1108014E
72488+:1026E000263194B400B148218D2D000001A00008CE
72489+:1026F000000000008F85003400A710219385003C66
72490+:10270000AF82003402251821A383003C951F00BC32
72491+:102710000226282137F91000A51900BC5240FF926B
72492+:10272000AF850060246A0004A38A003C950900BCC0
72493+:1027300024A40004AF84006035322000A51200BC40
72494+:102740000A001D54000020218F8600602CC800055F
72495+:102750001500FF609783005C3065FFFF00C5C8234C
72496+:102760002F2F000511E00003306400FF24CDFFFC93
72497+:1027700031A400FF8F8900648F920034113200046D
72498+:10278000389F000133EC0001158001380000000083
72499+:102790008F840038908700D434E60010A08600D4DF
72500+:1027A0008F8500388F8600609783005CACA000ECBA
72501+:1027B0000A001D2F306EFFFF8CB500848CB400849E
72502+:1027C0003C04100002A7302400068940328E007FAE
72503+:1027D000022E8025020410253C08800024050001FB
72504+:1027E00002602021240600010E0019A9AD02083064
72505+:1027F0000A001CC38F8500388C8200EC1222FE7EFA
72506+:102800000260202124090005A38900680E001A4AED
72507+:102810002411FFFF1451FE782404FFFF0A001D5508
72508+:102820002403FFFF8F8F004C8F8800388DF8000045
72509+:10283000AD1800888DE70010AD0700988F87006005
72510+:102840000A001DB78F8600542406FFFF118600057D
72511+:10285000000000000E001B4C026020210A001D8FAA
72512+:102860000040A0210E001AD1026020210A001D8F15
72513+:102870000040A0218F90004C3C0208008C4231B0F7
72514+:102880008E110010322C3FFF0182282B10A0000C6B
72515+:10289000240BFF808F85005090A3000D01637024EE
72516+:1028A00031CA00FF1140000702602021001143825D
72517+:1028B000310600032418000110D8010600000000B2
72518+:1028C000026020212403000D0E001A4AA383006831
72519+:1028D000004020218F8500380A001D320080A02191
72520+:1028E0008F90004C3C0A08008D4A31B08F85005013
72521+:1028F0008E0400100000A0218CB1001430823FFF34
72522+:10290000004A602B8CB200205180FFEE0260202133
72523+:1029100090B8000D240BFF800178702431C300FFB4
72524+:102920005060FFE80260202100044382310600036A
72525+:1029300014C0FFE40260202194BF001C8F9900386E
72526+:102940008E060028A73F00E88CAF0010022F20233E
72527+:1029500014C4013A026020218F83005400C368210F
72528+:10296000022D382B14E00136240200188F8A00440F
72529+:102970008F820030024390218D4B00100163702341
72530+:10298000AD4E0010AD5200208C4C00740192282BEB
72531+:1029900014A0015F026020218F8400508E08002463
72532+:1029A0008C86002411060007026020212419001CD7
72533+:1029B0000E001A4AA3990068240FFFFF104FFFC5AD
72534+:1029C0002404FFFF8F8400448C87002424FF00012F
72535+:1029D000AC9F00241251012F8F8D00308DB10074F7
72536+:1029E0001232012C3C0B00808E0E000001CB5024D3
72537+:1029F00015400075000000008E0300142411FFFF35
72538+:102A0000107100073C0808003C0608008CC6319095
72539+:102A100000C8C0241300015202602021A380006876
72540+:102A20008E0300003C19000100792024108000135F
72541+:102A30003C1F0080007FA02416800009020028218E
72542+:102A4000026020212411001A0E001A4AA391006886
72543+:102A50002407FFFF1047FF9F2404FFFF02002821E7
72544+:102A6000026020210E001A6A240600012410FFFFD4
72545+:102A70001050FF982404FFFF241400018F8D0044A0
72546+:102A8000026020210280302195A900342405000134
72547+:102A9000253200010E0019A9A5B200340000202142
72548+:102AA0008F8500380A001D320080A0218F90004CD5
72549+:102AB0003C1408008E9431B08E07001030E53FFFC3
72550+:102AC00000B4C82B132000618F8600502412FF80B1
72551+:102AD00090C9000D0249682431A400FF5080005CB9
72552+:102AE000026020218F8C00541180000700078B8228
72553+:102AF0008F8500388F82FCC094BF0080944A000A02
72554+:102B0000515F00F78F8600403227000314E0006415
72555+:102B100000000000920E000211C000D8000000006A
72556+:102B20008E0B0024156000D902602021920400035E
72557+:102B300024190002308500FF14B90005308900FF18
72558+:102B40008F940054128000EA240D002C308900FF7D
72559+:102B5000392C00102D8400012D3200010244302553
72560+:102B6000020028210E001A6A026020212410FFFFB3
72561+:102B7000105000BF8F8500388F830054106000D341
72562+:102B8000240500013C0A08008D4A318C0143F82BD2
72563+:102B900017E000B22402002D02602021000028214D
72564+:102BA0000E0019A9240600018F85003800001821A5
72565+:102BB0000A001D320060A0210E0018750000000000
72566+:102BC0000A001DF800000000AC8000200A001E78FA
72567+:102BD0008E03001400002821026020210E0019A994
72568+:102BE000240600010A001CC38F8500380A001DB7A7
72569+:102BF0008F8800388CAA00848CAC00843C031000C1
72570+:102C00000147F824001F91403189007F024968255F
72571+:102C100001A32825ACC50830910700012405000157
72572+:102C2000026020210E0019A930E600010A001CC331
72573+:102C30008F850038938F00482403FFFD0A001D3460
72574+:102C4000AF8F00600A001D342403FFFF02602021C3
72575+:102C50002410000D0E001A4AA390006800401821AD
72576+:102C60008F8500380A001D320060A0210E00187503
72577+:102C7000000000009783005C8F86006000402021E8
72578+:102C80003070FFFF00D010232C4A00051140FE11C8
72579+:102C90008F850038ACA400EC0A001D2F306EFFFFBA
72580+:102CA00090CF000D31E300085460FFA192040003AF
72581+:102CB00002602021240200100E001A4AA38200683C
72582+:102CC0002403FFFF5443FF9A920400030A001F12DB
72583+:102CD0008F85003890A4000D308F000811E000951A
72584+:102CE0008F990054572000A6026020218E1F000CEF
72585+:102CF0008CB4002057F40005026020218E0D0008DE
72586+:102D00008CA7002411A7003A026020212402002091
72587+:102D1000A38200680E001A4A2412FFFF1052FEED33
72588+:102D20002404FFFF8F9F00442402FFF73C14800E11
72589+:102D300093EA000D2419FF803C03800001423824EF
72590+:102D4000A3E7000D8F9F00303C0908008D2931ACAE
72591+:102D50008F8C006C97F200788F870044012C302113
72592+:102D6000324D7FFF000D204000C4782131E5007F07
72593+:102D700000B4C02101F94024AC68002CA711000068
72594+:102D80008CEB0028256E0001ACEE00288CEA002CAC
72595+:102D90008E02002C01426021ACEC002C8E09002C2C
72596+:102DA000ACE900308E120014ACF2003494ED003A1D
72597+:102DB00025A40001A4E4003A97E600783C1108003D
72598+:102DC0008E3131B024C3000130707FFF1211005CDE
72599+:102DD000006030218F8F0030026020212405000127
72600+:102DE0000E001934A5E600780A001EA1000020217B
72601+:102DF0008E0900142412FFFF1132006B8F8A0038F5
72602+:102E00008E0200188D4C00D0144C00650260202109
72603+:102E10008E0B00248CAE0028116E005B2402002172
72604+:102E20000E001A4AA38200681452FFBE2404FFFF5A
72605+:102E30008F8500380A001D320080A0212402001F67
72606+:102E40000E001A4AA38200682409FFFF1049FEA160
72607+:102E50002404FFFF0A001E548F83005402602021C7
72608+:102E60000E001A4AA38200681450FF508F85003864
72609+:102E70002403FFFF0A001D320060A0218CD800242B
72610+:102E80008E0800241118FF29026020210A001F2744
72611+:102E90002402000F8E0900003C05008001259024CB
72612+:102EA0001640FF492402001A026020210E001A4A2F
72613+:102EB000A3820068240CFFFF144CFECF2404FFFF04
72614+:102EC0008F8500380A001D320080A0210E001934C1
72615+:102ED000026020218F8500380A001EE500001821BD
72616+:102EE0002403FFFD0060A0210A001D32AF860060B0
72617+:102EF000026020210E001A4AA38D00682403FFFF00
72618+:102F00001043FF588F8500380A001ECC920400033E
72619+:102F10002418001D0E001A4AA39800682403FFFF1E
72620+:102F20001443FE9D2404FFFF8F8500380A001D32E4
72621+:102F30000080A021026020210A001F3D24020024FD
72622+:102F4000240880000068C024330BFFFF000B73C20D
72623+:102F500031D000FF001088270A001F6E001133C017
72624+:102F6000240F001B0E001A4AA38F00681451FEACF8
72625+:102F70002404FFFF8F8500380A001D320080A02145
72626+:102F80000A001F3D240200278E0600288CA3002C77
72627+:102F900010C30008026020210A001F812402001FC4
72628+:102FA0000A001F812402000E026020210A001F81F6
72629+:102FB000240200258E04002C1080000D8F8F00301D
72630+:102FC0008DE800740104C02B5700000C0260202122
72631+:102FD0008CB900140086A0210334282B10A0FF52C6
72632+:102FE0008F9F0044026020210A001F8124020022DA
72633+:102FF000026020210A001F81240200230A001F8191
72634+:103000002402002627BDFFD8AFB3001CAFB10014C7
72635+:10301000AFBF0020AFB20018AFB000103C0280007C
72636+:103020008C5201408C4B01483C048000000B8C0208
72637+:10303000322300FF317300FF8C8501B804A0FFFE2E
72638+:1030400034900180AE1200008C8701442464FFF0AC
72639+:10305000240600022C830013AE070004A61100080A
72640+:10306000A206000BAE1300241060004F8FBF00209B
72641+:10307000000448803C0A0801254A9534012A402171
72642+:103080008D04000000800008000000003C030800E0
72643+:103090008C6331A831693FFF00099980007280215B
72644+:1030A000021370212405FF80264D0100264C00806C
72645+:1030B0003C02800031B1007F3198007F31CA007F2F
72646+:1030C0003C1F800A3C1980043C0F800C01C5202461
72647+:1030D00001A5302401853824014F1821AC46002475
72648+:1030E000023F402103194821AC470090AC4400281E
72649+:1030F000AF830044AF880038AF8900300E0019005C
72650+:10310000016080213C0380008C6B01B80560FFFEEC
72651+:103110008F8700448F8600383465018090E8000D69
72652+:10312000ACB20000A4B0000600082600000416039C
72653+:1031300000029027001227C21080008124C200885C
72654+:10314000241F6082A4BF0008A0A000052402000282
72655+:10315000A0A2000B8F8B0030000424003C08270045
72656+:1031600000889025ACB20010ACA00014ACA00024E4
72657+:10317000ACA00028ACA0002C8D6900382413FF807F
72658+:10318000ACA9001890E3000D02638024320500FF13
72659+:1031900010A000058FBF002090ED000D31AC007F26
72660+:1031A000A0EC000D8FBF00208FB3001C8FB2001861
72661+:1031B0008FB100148FB000103C0A10003C0E80004C
72662+:1031C00027BD002803E00008ADCA01B8265F010052
72663+:1031D0002405FF8033F8007F3C06800003E5782457
72664+:1031E0003C19800A03192021ACCF0024908E00D412
72665+:1031F00000AE682431AC00FF11800024AF84003899
72666+:10320000248E008895CD00123C0C08008D8C31A8CE
72667+:1032100031AB3FFF01924821000B5180012A402130
72668+:1032200001052024ACC400283107007F3C06800C37
72669+:1032300000E620219083000D00A31024304500FFFC
72670+:1032400010A0FFD8AF8400449098000D330F0010F9
72671+:1032500015E0FFD58FBF00200E0019000000000010
72672+:103260003C0380008C7901B80720FFFE00000000BD
72673+:10327000AE1200008C7F0144AE1F0004A6110008AE
72674+:1032800024110002A211000BAE1300243C1308010C
72675+:10329000927396F0327000015200FFC38FBF00207E
72676+:1032A0000E002146024020210A0020638FBF00202B
72677+:1032B0003C1260008E452C083C03F0033462FFFF93
72678+:1032C00000A2F824AE5F2C088E582C083C1901C0CF
72679+:1032D00003199825AE532C080A0020638FBF0020E5
72680+:1032E000264D010031AF007F3C10800A240EFF8084
72681+:1032F00001F0282101AE60243C0B8000AD6C00245D
72682+:103300001660FFA8AF85003824110003A0B100FCAF
72683+:103310000A0020638FBF002026480100310A007F89
72684+:103320003C0B800A2409FF80014B30210109202435
72685+:103330003C078000ACE400240A002062AF8600381D
72686+:10334000944E0012320C3FFF31CD3FFF15ACFF7D94
72687+:10335000241F608290D900D42418FF800319782498
72688+:1033600031EA00FF1140FF7700000000240700044D
72689+:10337000A0C700FC8F870044241160842406000D40
72690+:10338000A4B10008A0A600050A00204D24020002F6
72691+:103390003C040001248496DC24030014240200FE73
72692+:1033A0003C010800AC2431EC3C010800AC2331E8BE
72693+:1033B0003C010801A42296F83C040801248496F8F4
72694+:1033C0000000182100643021A0C300042463000120
72695+:1033D0002C6500FF54A0FFFC006430213C0708006E
72696+:1033E00024E7010003E00008AF87007800A058211F
72697+:1033F000008048210000102114A00012000050217C
72698+:103400000A002142000000003C010801A42096F8B7
72699+:103410003C05080194A596F88F8200783C0C0801C1
72700+:10342000258C96F800E2182100AC2021014B302BAE
72701+:10343000A089000400001021A460000810C0003919
72702+:10344000010048218F8600780009384000E94021BA
72703+:103450000008388000E6282190A8000B90B9000AE7
72704+:103460000008204000881021000218800066C0215A
72705+:10347000A319000A8F85007800E5782191EE000AF3
72706+:1034800091E6000B000E684001AE6021000C208028
72707+:1034900000851021A046000B3C030801906396F2C2
72708+:1034A000106000222462FFFF8F8300383C01080176
72709+:1034B000A02296F2906C00FF118000040000000032
72710+:1034C000906E00FF25CDFFFFA06D00FF3C190801A5
72711+:1034D000973996F8272300013078FFFF2F0F00FF60
72712+:1034E00011E0FFC9254A00013C010801A42396F818
72713+:1034F0003C05080194A596F88F8200783C0C0801E1
72714+:10350000258C96F800E2182100AC2021014B302BCD
72715+:10351000A089000400001021A460000814C0FFC9A5
72716+:103520000100482103E000080000000003E000085B
72717+:103530002402000227BDFFE0248501002407FF804C
72718+:10354000AFB00010AFBF0018AFB1001400A718242F
72719+:103550003C10800030A4007F3C06800A00862821B1
72720+:103560008E110024AE03002490A200FF1440000836
72721+:10357000AF850038A0A000098FBF0018AE1100244D
72722+:103580008FB100148FB0001003E0000827BD0020A9
72723+:1035900090A900FD90A800FF312400FF0E0020F448
72724+:1035A000310500FF8F8500388FBF0018A0A00009EB
72725+:1035B000AE1100248FB100148FB0001003E000089A
72726+:1035C00027BD002027BDFFD0AFB20020AFB1001C47
72727+:1035D000AFB00018AFBF002CAFB40028AFB30024C9
72728+:1035E0003C0980009533011635320C00952F011AE5
72729+:1035F0003271FFFF023280218E08000431EEFFFF9E
72730+:10360000248B0100010E6821240CFF8025A5FFFFFB
72731+:10361000016C50243166007F3C07800AAD2A0024EB
72732+:1036200000C73021AF850074AF8800703C010801ED
72733+:10363000A02096F190C300090200D02100809821BB
72734+:10364000306300FF2862000510400048AF86003854
72735+:10365000286400021480008E24140001240D00054B
72736+:103660003C010801A02D96D590CC00FD3C0108013D
72737+:10367000A02096D63C010801A02096D790CB000A46
72738+:10368000240AFF80318500FF014B4824312700FFC9
72739+:1036900010E0000C000058213C12800836510080D8
72740+:1036A0008E2F00308CD0005C01F0702305C0018E9D
72741+:1036B0008F87007090D4000A3284007FA0C4000A73
72742+:1036C0008F8600383C118008363000808E0F003025
72743+:1036D0008F87007000EF702319C000EE000000001B
72744+:1036E00090D4000924120002328400FF1092024795
72745+:1036F000000000008CC2005800E2F82327F9FFFF09
72746+:103700001B2001300000000090C5000924080004BF
72747+:1037100030A300FF10680057240A00013C01080193
72748+:10372000A02A96D590C900FF252700013C01080179
72749+:10373000A02796D43C030801906396D52406000583
72750+:103740001066006A2C780005130000C40000902168
72751+:103750000003F8803C0408012484958003E4C82118
72752+:103760008F25000000A0000800000000241800FFC2
72753+:103770001078005C0000000090CC000A90CA00099C
72754+:103780003C080801910896F13187008000EA48253D
72755+:103790003C010801A02996DC90C500FD3C140801FD
72756+:1037A000929496F2311100013C010801A02596DDAA
72757+:1037B00090DF00FE3C010801A03F96DE90D200FFA2
72758+:1037C0003C010801A03296DF8CD900543C0108016D
72759+:1037D000AC3996E08CD000583C010801AC3096E43E
72760+:1037E0008CC3005C3C010801AC3496EC3C01080140
72761+:1037F000AC2396E8162000088FBF002C8FB4002859
72762+:103800008FB300248FB200208FB1001C8FB000183E
72763+:1038100003E0000827BD00303C1180009624010E13
72764+:103820000E000FD43094FFFF3C0B08018D6B96F413
72765+:103830000260382102802821AE2B01803C13080150
72766+:103840008E7396D401602021240600830E00102F71
72767+:10385000AFB300108FBF002C8FB400288FB30024AB
72768+:103860008FB200208FB1001C8FB0001803E0000859
72769+:1038700027BD00303C1808008F1831FC270F0001CD
72770+:103880003C010800AC2F31FC0A0021D700000000E9
72771+:103890001474FFB900000000A0C000FF3C05080040
72772+:1038A0008CA531E43C0308008C6331E03C02080045
72773+:1038B0008C4232048F99003834A80001241F000282
72774+:1038C0003C010801AC2396F43C010801A02896F0C5
72775+:1038D0003C010801A02296F3A33F00090A002190B1
72776+:1038E0008F8600380E002146000000000A0021D714
72777+:1038F0008F8600383C1F080193FF96D424190001DD
72778+:1039000013F902298F8700703C100801921096D895
72779+:103910003C06080190C696D610C000050200A02102
72780+:103920003C040801908496D9109001E48F870078B8
72781+:10393000001088408F9F0078023048210009C8801D
72782+:10394000033F702195D80008270F0001A5CF00087C
72783+:103950003C040801908496D93C05080190A596D6B0
72784+:103960000E0020F4000000008F8700780230202134
72785+:103970000004308000C720218C8500048F820074F1
72786+:1039800000A2402305020006AC8200048C8A0000DD
72787+:103990008F830070014310235C400001AC83000062
72788+:1039A0008F86003890CB00FF2D6C00025580002DD3
72789+:1039B000241400010230F821001F40800107282153
72790+:1039C00090B9000B8CAE00040019C0400319782197
72791+:1039D000000F1880006710218C4D000001AE882375
72792+:1039E0002630FFFF5E00001F241400018C440004F9
72793+:1039F0008CAA0000008A482319200019240E000414
72794+:103A00003C010801A02E96D590AD000B8CAB0004B4
72795+:103A1000000D8840022D80210010108000471021E9
72796+:103A20008C44000401646023058202009443000872
72797+:103A300090DF00FE90B9000B33E500FF54B900049D
72798+:103A40000107A021A0D400FE8F8700780107A021E4
72799+:103A50009284000B0E0020F4240500018F860038AC
72800+:103A600024140001125400962E500001160000424A
72801+:103A70003C08FFFF241900021659FF3F0000000018
72802+:103A8000A0C000FF8F860038A0D200090A0021D70D
72803+:103A90008F86003890C700092404000230E300FF3D
72804+:103AA0001064016F24090004106901528F880074AA
72805+:103AB0008CCE0054010E682325B10001062001754B
72806+:103AC000241800043C010801A03896D53C010801E7
72807+:103AD000A02096D490D400FD90D200FF2E4F00027B
72808+:103AE00015E0FF14328400FF000438408F8900780D
72809+:103AF00090DF00FF00E41021000220800089C8212F
72810+:103B00002FE500029324000B14A0FF0A24070002F3
72811+:103B100000041840006480210010588001692821A9
72812+:103B20008CAC0004010C50230540FF020000000093
72813+:103B30003C030801906396D614600005246F0001D1
72814+:103B40003C010801A02496D93C010801A02796D782
72815+:103B50003C010801A02F96D690CE00FF24E700017B
72816+:103B600031CD00FF01A7882B1220FFE990A4000BA4
72817+:103B70000A0021C6000000003C0508018CA596D46F
72818+:103B80003C12000400A8F82413F2000624020005E9
72819+:103B90003C090801912996D5152000022402000352
72820+:103BA000240200053C010801A02296F190C700FF05
72821+:103BB00014E0012024020002A0C200090A0021D75B
72822+:103BC0008F86003890CC00FF1180FEDA240A0001B5
72823+:103BD0008F8C00748F890078240F00030180682186
72824+:103BE0001160001E240E0002000540400105A021C6
72825+:103BF00000142080008990218E51000401918023BF
72826+:103C00000600FECC000000003C020801904296D65F
72827+:103C100014400005245800013C010801A02A96D751
72828+:103C20003C010801A02596D93C010801A03896D690
72829+:103C300090DF00FF010510210002C88033E500FF7E
72830+:103C4000254A00010329202100AA402B1500FEB9B6
72831+:103C50009085000B1560FFE50005404000054040E1
72832+:103C600001051821000310803C010801A02A96D408
72833+:103C70003C010801A02596D8004918218C64000455
72834+:103C800000E4F82327F9FFFF1F20FFE900000000F0
72835+:103C90008C63000000E358230560013A01A38823E8
72836+:103CA00010E301170184C0231B00FEA200000000E6
72837+:103CB0003C010801A02E96D50A002305240B000123
72838+:103CC000240E0004A0CE00093C0D08008DAD31F893
72839+:103CD0008F86003825A200013C010800AC2231F893
72840+:103CE0000A0021D7000000008CD9005C00F9C02335
72841+:103CF0001F00FE7B000000008CDF005C10FFFF65F2
72842+:103D00008F8400748CC3005C008340232502000173
72843+:103D10001C40FF60000000008CC9005C248700018B
72844+:103D200000E9282B10A0FE943C0D80008DAB01040F
72845+:103D30003C0C0001016C50241140FE8F2402001045
72846+:103D40003C010801A02296F10A0021D700000000E2
72847+:103D50008F9100748F86003826220001ACC2005C6F
72848+:103D60000A002292241400018F8700382404FF8067
72849+:103D70000000882190E9000A241400010124302564
72850+:103D8000A0E6000A3C05080190A596D63C0408016F
72851+:103D9000908496D90E0020F4000000008F86003831
72852+:103DA0008F85007890C800FD310700FF0007404074
72853+:103DB0000107F821001FC0800305C8219323000BD1
72854+:103DC000A0C300FD8F8500788F8600380305602131
72855+:103DD000918F000B000F704001CF6821000D808093
72856+:103DE000020510218C4B0000ACCB00548D840004E4
72857+:103DF0008F83007400645023194000022482000164
72858+:103E00002462000101074821ACC2005C0009308037
72859+:103E100000C5402100E02021240500010E0020F40F
72860+:103E20009110000B8F86003890C500FF10A0FF0C8A
72861+:103E3000001070408F85007801D06821000D10803F
72862+:103E4000004558218D6400008F8C0074018450233C
72863+:103E50002547000104E0FF02263100013C03080170
72864+:103E6000906396D62E2F0002247800013C010801B1
72865+:103E7000A03896D63C010801A03496D711E0FEF890
72866+:103E8000020038210A002365000740408F84003873
72867+:103E90008F8300748C85005800A340230502FE9A8E
72868+:103EA000AC8300580A00223B000000003C070801D8
72869+:103EB00090E796F2240200FF10E200BE8F860038E1
72870+:103EC0003C110801963196FA3C030801246396F8E8
72871+:103ED000262500013230FFFF30ABFFFF02036021D7
72872+:103EE0002D6A00FF1540008D918700043C010801F8
72873+:103EF000A42096FA8F88003800074840012728211F
72874+:103F0000911800FF000530802405000127140001EE
72875+:103F1000A11400FF3C120801925296F28F8800789B
72876+:103F20008F8E0070264F000100C820213C0108013F
72877+:103F3000A02F96F2AC8E00008F8D0074A48500082F
72878+:103F4000AC8D00043C030801906396D414600077A4
72879+:103F5000000090213C010801A02596D4A087000B09
72880+:103F60008F8C007800CC5021A147000A8F82003846
72881+:103F7000A04700FD8F840038A08700FE8F860038A0
72882+:103F80008F9F0070ACDF00548F990074ACD900583B
72883+:103F90008F8D00780127C02100185880016DA02165
72884+:103FA000928F000A000F704001CF18210003888013
72885+:103FB000022D8021A207000B8F8600780166602108
72886+:103FC000918A000B000A1040004A2021000428803A
72887+:103FD00000A64021A107000A3C07800834E90080C0
72888+:103FE0008D2200308F860038ACC2005C0A0022921D
72889+:103FF0002414000190CA00FF1540FEAD8F880074A4
72890+:10400000A0C400090A0021D78F860038A0C000FD97
72891+:104010008F98003824060001A30000FE3C0108012F
72892+:10402000A02696D53C010801A02096D40A0021C6FE
72893+:104030000000000090CB00FF3C040801908496F340
72894+:10404000316C00FF0184502B1540000F2402000347
72895+:1040500024020004A0C200090A0021D78F8600387C
72896+:1040600090C3000A2410FF8002035824316C00FF23
72897+:104070001180FDC1000000003C010801A02096D580
72898+:104080000A0021C600000000A0C200090A0021D7D2
72899+:104090008F86003890D4000A2412FF8002544824EE
72900+:1040A000312800FF1500FFF4240200083C0108013C
72901+:1040B000A02296F10A0021D70000000000108840DD
72902+:1040C0008F8B0070023018210003688001A7202127
72903+:1040D000AC8B00008F8A0074240C0001A48C0008B3
72904+:1040E000AC8A00043C05080190A596D62402000184
72905+:1040F00010A2FE1E24A5FFFF0A0022519084000B8F
72906+:104100000184A0231A80FD8B000000003C010801FF
72907+:10411000A02E96D50A002305240B00013C010801BE
72908+:10412000A42596FA0A0023B78F880038240B0001D3
72909+:10413000106B00228F9800388F85003890BF00FFE9
72910+:1041400033F900FF1079002B000000003C1F08012C
72911+:1041500093FF96D8001FC840033FC0210018A080DD
72912+:104160000288782191EE000AA08E000A8F8D0078D7
72913+:104170003C030801906396D800CD88210A0023DD16
72914+:10418000A223000B263000010600003101A4902379
72915+:104190000640002B240200033C010801A02F96D505
72916+:1041A0000A002305240B00018F8900380A00223BF6
72917+:1041B000AD2700540A00229124120001931400FD3F
72918+:1041C000A094000B8F8800388F8F0078910E00FE2E
72919+:1041D00000CF6821A1AE000A8F910038A22700FD10
72920+:1041E0008F8300708F900038AE0300540A0023DEE6
72921+:1041F0008F8D007890B000FEA090000A8F8B003861
72922+:104200008F8C0078916A00FD00CC1021A04A000B31
72923+:104210008F840038A08700FE8F8600748F85003859
72924+:10422000ACA600580A0023DE8F8D007894B80008F1
72925+:10423000ACA40004030378210A002285A4AF00087F
72926+:104240003C010801A02296D50A0021C6000000000A
72927+:1042500090CF0009240D000431EE00FF11CDFD8543
72928+:10426000240200013C010801A02296D50A0021C6C3
72929+:1042700000000000080033440800334408003420E4
72930+:10428000080033F4080033D8080033280800332826
72931+:10429000080033280800334C8008010080080080A3
72932+:1042A000800800005F865437E4AC62CC50103A4579
72933+:1042B00036621985BF14C0E81BC27A1E84F4B55655
72934+:1042C000094EA6FE7DDA01E7C04D748108005A74DC
72935+:1042D00008005AB808005A5C08005A5C08005A5C8A
72936+:1042E00008005A5C08005A7408005A5C08005A5CBE
72937+:1042F00008005AC008005A5C080059D408005A5CEB
72938+:1043000008005A5C08005AC008005A5C08005A5C51
72939+:1043100008005A5C08005A5C08005A5C08005A5CA5
72940+:1043200008005A5C08005A5C08005A5C08005A5C95
72941+:1043300008005A9408005A5C08005A9408005A5C15
72942+:1043400008005A5C08005A5C08005A9808005A9401
72943+:1043500008005A5C08005A5C08005A5C08005A5C65
72944+:1043600008005A5C08005A5C08005A5C08005A5C55
72945+:1043700008005A5C08005A5C08005A5C08005A5C45
72946+:1043800008005A5C08005A5C08005A5C08005A5C35
72947+:1043900008005A5C08005A5C08005A5C08005A5C25
72948+:1043A00008005A9808005A9808005A5C08005A9861
72949+:1043B00008005A5C08005A5C08005A5C08005A5C05
72950+:1043C00008005A5C08005A5C08005A5C08005A5CF5
72951+:1043D00008005A5C08005A5C08005A5C08005A5CE5
72952+:1043E00008005A5C08005A5C08005A5C08005A5CD5
72953+:1043F00008005A5C08005A5C08005A5C08005A5CC5
72954+:1044000008005A5C08005A5C08005A5C08005A5CB4
72955+:1044100008005A5C08005A5C08005A5C08005A5CA4
72956+:1044200008005A5C08005A5C08005A5C08005A5C94
72957+:1044300008005A5C08005A5C08005A5C08005A5C84
72958+:1044400008005A5C08005A5C08005A5C08005A5C74
72959+:1044500008005A5C08005A5C08005A5C08005A5C64
72960+:1044600008005A5C08005A5C08005A5C08005A5C54
72961+:1044700008005A5C08005A5C08005A5C08005A5C44
72962+:1044800008005A5C08005A5C08005A5C08005A5C34
72963+:1044900008005A5C08005A5C08005A5C08005A5C24
72964+:1044A00008005A5C08005A5C08005A5C08005A5C14
72965+:1044B00008005A5C08005A5C08005A5C08005A5C04
72966+:1044C00008005A5C08005A5C08005A5C08005ADC74
72967+:1044D0000800782C08007A900800783808007628C0
72968+:1044E00008007838080078C4080078380800762872
72969+:1044F0000800762808007628080076280800762824
72970+:104500000800762808007628080076280800762813
72971+:1045100008007628080078580800784808007628AF
72972+:1045200008007628080076280800762808007628F3
72973+:1045300008007628080076280800762808007628E3
72974+:1045400008007628080076280800762808007848B1
72975+:10455000080082FC08008188080082C40800818865
72976+:104560000800829408008070080081880800818813
72977+:1045700008008188080081880800818808008188F7
72978+:1045800008008188080081880800818808008188E7
72979+:104590000800818808008188080081B008008D34F7
72980+:1045A00008008E9008008E70080088D808008D4C96
72981+:1045B0000A00012400000000000000000000000DBF
72982+:1045C000747061362E322E31620000000602010145
72983+:1045D00000000000000000000000000000000000DB
72984+:1045E00000000000000000000000000000000000CB
72985+:1045F00000000000000000000000000000000000BB
72986+:1046000000000000000000000000000000000000AA
72987+:10461000000000000000000000000000000000009A
72988+:10462000000000000000000000000000000000008A
72989+:10463000000000000000000000000000000000007A
72990+:104640000000000010000003000000000000000D4A
72991+:104650000000000D3C020800244217203C03080023
72992+:1046600024632A10AC4000000043202B1480FFFD7F
72993+:10467000244200043C1D080037BD2FFC03A0F0219C
72994+:104680003C100800261004903C1C0800279C1720B2
72995+:104690000E000262000000000000000D2402FF80F6
72996+:1046A00027BDFFE000821024AFB00010AF42002011
72997+:1046B000AFBF0018AFB10014936500043084007FD1
72998+:1046C000034418213C0200080062182130A5002094
72999+:1046D000036080213C080111277B000814A0000220
73000+:1046E0002466005C2466005892020004974301048B
73001+:1046F000920400043047000F3063FFFF3084004015
73002+:10470000006728231080000900004821920200055C
73003+:1047100030420004104000050000000010A000031B
73004+:104720000000000024A5FFFC2409000492020005FB
73005+:1047300030420004104000120000000010A00010E1
73006+:10474000000000009602000200A72021010440257D
73007+:104750002442FFFEA7421016920300042402FF80A9
73008+:1047600000431024304200FF104000033C020400CC
73009+:104770000A000174010240258CC20000AF421018EB
73010+:104780008F4201780440FFFE2402000AA742014044
73011+:1047900096020002240400093042000700021023A0
73012+:1047A00030420007A7420142960200022442FFFE67
73013+:1047B000A7420144A740014697420104A74201488D
73014+:1047C0008F420108304200205040000124040001C3
73015+:1047D00092020004304200101440000234830010A2
73016+:1047E00000801821A743014A0000000000000000DB
73017+:1047F0000000000000000000AF48100000000000B2
73018+:104800000000000000000000000000008F421000C7
73019+:104810000441FFFE3102FFFF1040000700000000CE
73020+:1048200092020004304200401440000300000000E7
73021+:104830008F421018ACC20000960200063042FFFF03
73022+:10484000244200020002104300021040036288214B
73023+:10485000962200001120000D3044FFFF00A7102118
73024+:104860008F8300388F45101C0002108200021080D8
73025+:1048700000431021AC45000030A6FFFF0E00058D5F
73026+:1048800000052C0200402021A62200009203000413
73027+:104890002402FF8000431024304200FF1040001F1C
73028+:1048A0000000000092020005304200021040001B90
73029+:1048B000000000009742100C2442FFFEA742101691
73030+:1048C000000000003C02040034420030AF421000FF
73031+:1048D00000000000000000000000000000000000D8
73032+:1048E0008F4210000441FFFE000000009742100CB0
73033+:1048F0008F45101C3042FFFF24420030000210821E
73034+:1049000000021080005B1021AC45000030A6FFFFC4
73035+:104910000E00058D00052C02A62200009604000260
73036+:10492000248400080E0001E93084FFFF974401044D
73037+:104930000E0001F73084FFFF8FBF00188FB1001405
73038+:104940008FB000103C02100027BD002003E00008DB
73039+:10495000AF4201783084FFFF308200078F8500244A
73040+:1049600010400002248300073064FFF800A41021E7
73041+:1049700030421FFF03421821247B4000AF850028EE
73042+:10498000AF82002403E00008AF4200843084FFFFC0
73043+:104990003082000F8F85002C8F860034104000027B
73044+:1049A0002483000F3064FFF000A410210046182B70
73045+:1049B000AF8500300046202314600002AF82002C37
73046+:1049C000AF84002C8F82002C340480000342182115
73047+:1049D00000641821AF83003803E00008AF42008074
73048+:1049E0008F820014104000088F8200048F82FFDC49
73049+:1049F000144000058F8200043C02FFBF3442FFFFD9
73050+:104A0000008220248F82000430430006240200022A
73051+:104A10001062000F3C0201012C62000350400005AF
73052+:104A2000240200041060000F3C0200010A00023062
73053+:104A30000000000010620005240200061462000C51
73054+:104A40003C0201110A000229008210253C020011DB
73055+:104A500000821025AF421000240200010A0002303B
73056+:104A6000AF82000C00821025AF421000AF80000C16
73057+:104A700000000000000000000000000003E000084B
73058+:104A8000000000008F82000C1040000400000000B5
73059+:104A90008F4210000441FFFE0000000003E0000808
73060+:104AA000000000008F8200102443F800000231C291
73061+:104AB00024C2FFF02C6303011060000300021042C7
73062+:104AC0000A000257AC8200008F85001800C5102B29
73063+:104AD0001440000B0000182100C5102324470001DA
73064+:104AE0008F82001C00A210212442FFFF0046102BE1
73065+:104AF000544000042402FFFF0A000257AC87000064
73066+:104B00002402FFFF0A000260AC8200008C820000D9
73067+:104B10000002194000621821000318800062182169
73068+:104B2000000318803C0208002442175C0062182130
73069+:104B300003E000080060102127BDFFD8AFBF0020B0
73070+:104B4000AFB1001CAFB000183C0460088C8250006C
73071+:104B50002403FF7F3C066000004310243442380CDD
73072+:104B6000AC8250008CC24C1C3C1A80000002160221
73073+:104B70003042000F10400007AF82001C8CC34C1C59
73074+:104B80003C02001F3442FC0000621824000319C2DA
73075+:104B9000AF8300188F420008275B400034420001B9
73076+:104BA000AF420008AF8000243C02601CAF40008090
73077+:104BB000AF4000848C4500088CC308083402800094
73078+:104BC000034220212402FFF0006218243C020080EE
73079+:104BD0003C010800AC2204203C025709AF84003895
73080+:104BE00014620004AF850034240200010A0002921E
73081+:104BF000AF820014AF8000148F42000038420001E1
73082+:104C0000304200011440FFFC8F8200141040001657
73083+:104C10000000000097420104104000058F8300004F
73084+:104C2000146000072462FFFF0A0002A72C62000A3A
73085+:104C30002C620010504000048F83000024620001A9
73086+:104C4000AF8200008F8300002C62000A1440000332
73087+:104C50002C6200070A0002AEAF80FFDC10400002A9
73088+:104C600024020001AF82FFDC8F4301088F44010062
73089+:104C700030622000AF83000410400008AF840010B1
73090+:104C80003C0208008C42042C244200013C01080034
73091+:104C9000AC22042C0A00058A3C0240003065020068
73092+:104CA00014A0000324020F001482026024020D00ED
73093+:104CB00097420104104002C83C02400030624000AC
73094+:104CC000144000AD8F8200388C4400088F42017878
73095+:104CD0000440FFFE24020800AF42017824020008CD
73096+:104CE000A7420140A7400142974201048F8400047B
73097+:104CF0003051FFFF30820001104000070220802168
73098+:104D00002623FFFE240200023070FFFFA742014667
73099+:104D10000A0002DBA7430148A74001463C02080005
73100+:104D20008C42043C1440000D8F8300103082002020
73101+:104D30001440000224030009240300010060202124
73102+:104D40008F830010240209005062000134840004A3
73103+:104D5000A744014A0A0002F60000000024020F00E6
73104+:104D60001462000530820020144000062403000D68
73105+:104D70000A0002F524030005144000022403000980
73106+:104D800024030001A743014A3C0208008C4204208E
73107+:104D90003C0400480E00020C004420250E000235A1
73108+:104DA000000000008F82000C1040003E0000000058
73109+:104DB0008F4210003C0300200043102410400039B3
73110+:104DC0008F820004304200021040003600000000D4
73111+:104DD000974210141440003300000000974210085E
73112+:104DE0008F8800383042FFFF2442000600021882FC
73113+:104DF0000003388000E83021304300018CC40000FB
73114+:104E000010600004304200030000000D0A00033768
73115+:104E100000E81021544000103084FFFF3C05FFFFE4
73116+:104E200000852024008518260003182B0004102B71
73117+:104E300000431024104000050000000000000000A6
73118+:104E40000000000D00000000240002228CC20000BF
73119+:104E50000A000336004520253883FFFF0003182B86
73120+:104E60000004102B00431024104000050000000037
73121+:104E7000000000000000000D000000002400022BD4
73122+:104E80008CC200003444FFFF00E81021AC44000055
73123+:104E90003C0208008C420430244200013C0108001E
73124+:104EA000AC2204308F6200008F840038AF8200088B
73125+:104EB0008C8300003402FFFF1462000F00001021F9
73126+:104EC0003C0508008CA504543C0408008C84045064
73127+:104ED00000B0282100B0302B008220210086202144
73128+:104EE0003C010800AC2504543C010800AC240450EB
73129+:104EF0000A000580240400088C8200003042010072
73130+:104F00001040000F000010213C0508008CA5044C47
73131+:104F10003C0408008C84044800B0282100B0302BE9
73132+:104F200000822021008620213C010800AC25044C91
73133+:104F30003C010800AC2404480A0005802404000851
73134+:104F40003C0508008CA504443C0408008C84044003
73135+:104F500000B0282100B0302B0082202100862021C3
73136+:104F60003C010800AC2504443C010800AC2404408A
73137+:104F70000A000580240400088F6200088F62000088
73138+:104F800000021602304300F02402003010620005D7
73139+:104F900024020040106200E08F8200200A00058891
73140+:104FA0002442000114A000050000000000000000E1
73141+:104FB0000000000D00000000240002568F4201781E
73142+:104FC0000440FFFE000000000E00023D27A4001078
73143+:104FD0001440000500408021000000000000000D8A
73144+:104FE000000000002400025D8E0200001040000559
73145+:104FF00000000000000000000000000D00000000A4
73146+:10500000240002608F62000C0443000324020001AC
73147+:105010000A00042EAE000000AE0200008F820038AD
73148+:105020008C480008A20000078F65000C8F64000404
73149+:1050300030A3FFFF0004240200852023308200FFFC
73150+:105040000043102124420005000230832CC200815D
73151+:10505000A605000A14400005A20400040000000098
73152+:105060000000000D00000000240002788F85003849
73153+:105070000E0005AB260400148F6200048F43010864
73154+:10508000A60200083C02100000621824106000080C
73155+:105090000000000097420104920300072442FFEC45
73156+:1050A000346300023045FFFF0A0003C3A203000778
73157+:1050B000974201042442FFF03045FFFF96060008A6
73158+:1050C0002CC200135440000592030007920200070F
73159+:1050D00034420001A20200079203000724020001EB
73160+:1050E00010620005240200031062000B8F8200385A
73161+:1050F0000A0003E030C6FFFF8F8200383C04FFFF48
73162+:105100008C43000C0064182400651825AC43000C87
73163+:105110000A0003E030C6FFFF3C04FFFF8C43001091
73164+:105120000064182400651825AC43001030C6FFFF4A
73165+:1051300024C2000200021083A20200058F830038FF
73166+:10514000304200FF00021080004328218CA800009C
73167+:105150008CA2000024030004000217021443001272
73168+:1051600000000000974201043C03FFFF01031824E4
73169+:105170003042FFFF004610232442FFFE006240251C
73170+:10518000ACA8000092030005306200FF000210800E
73171+:1051900000501021904200143042000F00431021B3
73172+:1051A0000A000415A20200068CA400049742010420
73173+:1051B0009603000A3088FFFF3042FFFF00461023AD
73174+:1051C0002442FFD60002140001024025ACA80004CE
73175+:1051D000920200079204000524630028000318834C
73176+:1051E0000064182134420004A2030006A202000752
73177+:1051F0008F8200042403FFFB34420002004310248A
73178+:10520000AF820004920300068F87003800031880E5
73179+:10521000007010218C4400203C02FFF63442FFFF56
73180+:105220000082402400671821AE04000CAC68000C1A
73181+:10523000920500063C03FF7F8E02000C00052880CB
73182+:1052400000B020213463FFFF01033024948800263E
73183+:1052500000A7282100431024AE02000CAC860020D9
73184+:10526000AC880024ACA8001024020010A742014022
73185+:1052700024020002A7400142A7400144A742014680
73186+:10528000974201043C0400082442FFFEA742014863
73187+:10529000240200010E00020CA742014A9603000AF4
73188+:1052A0009202000400431021244200023042000711
73189+:1052B00000021023304200070E000235AE0200103B
73190+:1052C0008F6200003C0308008C6304442404001037
73191+:1052D000AF820008974201043042FFFF2442FFFEE4
73192+:1052E00000403821000237C33C0208008C420440D1
73193+:1052F000006718210067282B004610210045102167
73194+:105300003C010800AC2304443C010800AC220440EA
73195+:105310000A0005150000000014A0000500000000B0
73196+:10532000000000000000000D000000002400030A3F
73197+:105330008F4201780440FFFE000000000E00023D95
73198+:1053400027A4001414400005004080210000000044
73199+:105350000000000D00000000240003118E02000078
73200+:105360005440000692020007000000000000000DFB
73201+:10537000000000002400031C9202000730420004D9
73202+:10538000104000058F8200042403FFFB344200021A
73203+:1053900000431024AF8200048F620004044300081D
73204+:1053A00092020007920200068E03000CAE0000007D
73205+:1053B0000002108000501021AC4300209202000730
73206+:1053C00030420004544000099602000A920200058F
73207+:1053D0003C03000100021080005010218C46001890
73208+:1053E00000C33021AC4600189602000A9206000461
73209+:1053F000277100080220202100C2302124C60005A8
73210+:10540000260500140E0005AB00063082920400064B
73211+:105410008F6500043C027FFF000420800091202162
73212+:105420008C8300043442FFFF00A228240065182169
73213+:10543000AC8300049202000792040005920300046A
73214+:10544000304200041040001496070008308400FF2A
73215+:1054500000042080009120218C86000497420104E2
73216+:105460009605000A306300FF3042FFFF0043102121
73217+:105470000045102130E3FFFF004310232442FFD8F2
73218+:1054800030C6FFFF0002140000C23025AC860004C5
73219+:105490000A0004C992030007308500FF0005288038
73220+:1054A00000B128218CA4000097420104306300FF62
73221+:1054B0003042FFFF00431021004710233C03FFFF51
73222+:1054C000008320243042FFFF00822025ACA400008E
73223+:1054D0009203000724020001106200060000000091
73224+:1054E0002402000310620011000000000A0004EC16
73225+:1054F0008E03001097420104920300049605000AEF
73226+:105500008E24000C00431021004510212442FFF29C
73227+:105510003C03FFFF008320243042FFFF0082202550
73228+:10552000AE24000C0A0004EC8E0300109742010424
73229+:10553000920300049605000A8E24001000431021F7
73230+:10554000004510212442FFEE3C03FFFF008320248E
73231+:105550003042FFFF00822025AE2400108E03001091
73232+:105560002402000AA7420140A74301429603000A11
73233+:10557000920200043C04004000431021A742014471
73234+:10558000A740014697420104A742014824020001B6
73235+:105590000E00020CA742014A0E0002350000000076
73236+:1055A0008F6200009203000400002021AF820008F7
73237+:1055B000974201049606000A3042FFFF006218215C
73238+:1055C000006028213C0308008C6304443C0208006E
73239+:1055D0008C42044000651821004410210065382BDE
73240+:1055E000004710213C010800AC2304443C010800A2
73241+:1055F000AC22044092040004008620212484000A86
73242+:105600003084FFFF0E0001E9000000009744010410
73243+:105610003084FFFF0E0001F7000000003C02100084
73244+:10562000AF4201780A0005878F820020148200278C
73245+:105630003062000697420104104000673C024000BF
73246+:105640003062400010400005000000000000000033
73247+:105650000000000D00000000240004208F420178AB
73248+:105660000440FFFE24020800AF4201782402000833
73249+:10567000A7420140A74001428F82000497430104E2
73250+:1056800030420001104000073070FFFF2603FFFE8C
73251+:1056900024020002A7420146A74301480A00053F31
73252+:1056A0002402000DA74001462402000DA742014A32
73253+:1056B0008F62000024040008AF8200080E0001E998
73254+:1056C000000000000A0005190200202110400042DD
73255+:1056D0003C02400093620000304300F024020010BE
73256+:1056E0001062000524020070106200358F820020D5
73257+:1056F0000A000588244200018F62000097430104DC
73258+:105700003050FFFF3071FFFF8F4201780440FFFEF1
73259+:105710003202000700021023304200072403000A6F
73260+:105720002604FFFEA7430140A7420142A7440144CB
73261+:10573000A7400146A75101488F420108304200208E
73262+:10574000144000022403000924030001A743014A76
73263+:105750000E00020C3C0400400E0002350000000068
73264+:105760003C0708008CE70444021110212442FFFE8C
73265+:105770003C0608008CC604400040182100E3382194
73266+:10578000000010218F65000000E3402B00C2302193
73267+:105790002604000800C830213084FFFFAF850008D0
73268+:1057A0003C010800AC2704443C010800AC2604403E
73269+:1057B0000E0001E9000000000A0005190220202166
73270+:1057C0000E00013B000000008F82002024420001F7
73271+:1057D000AF8200203C024000AF4201380A00029232
73272+:1057E000000000003084FFFF30C6FFFF00052C00E2
73273+:1057F00000A628253882FFFF004510210045282BF0
73274+:105800000045102100021C023042FFFF004310211E
73275+:1058100000021C023042FFFF004310213842FFFF0C
73276+:1058200003E000083042FFFF3084FFFF30A5FFFF98
73277+:1058300000001821108000070000000030820001E5
73278+:105840001040000200042042006518210A0005A152
73279+:105850000005284003E000080060102110C0000689
73280+:1058600024C6FFFF8CA2000024A50004AC82000027
73281+:105870000A0005AB2484000403E0000800000000D7
73282+:1058800010A0000824A3FFFFAC8600000000000069
73283+:10589000000000002402FFFF2463FFFF1462FFFAF0
73284+:1058A0002484000403E00008000000000000000160
73285+:1058B0000A00002A00000000000000000000000DA7
73286+:1058C000747870362E322E3162000000060201001C
73287+:1058D00000000000000001360000EA600000000047
73288+:1058E00000000000000000000000000000000000B8
73289+:1058F00000000000000000000000000000000000A8
73290+:105900000000000000000000000000000000000097
73291+:105910000000001600000000000000000000000071
73292+:105920000000000000000000000000000000000077
73293+:105930000000000000000000000000000000000067
73294+:1059400000000000000000000000138800000000BC
73295+:10595000000005DC00000000000000001000000353
73296+:10596000000000000000000D0000000D3C020800D7
73297+:1059700024423D683C0308002463401CAC40000006
73298+:105980000043202B1480FFFD244200043C1D08002E
73299+:1059900037BD7FFC03A0F0213C100800261000A8B2
73300+:1059A0003C1C0800279C3D680E00044E00000000CF
73301+:1059B0000000000D27BDFFB4AFA10000AFA200049E
73302+:1059C000AFA30008AFA4000CAFA50010AFA6001451
73303+:1059D000AFA70018AFA8001CAFA90020AFAA0024F1
73304+:1059E000AFAB0028AFAC002CAFAD0030AFAE003491
73305+:1059F000AFAF0038AFB8003CAFB90040AFBC004417
73306+:105A0000AFBF00480E000591000000008FBF0048A6
73307+:105A10008FBC00448FB900408FB8003C8FAF003876
73308+:105A20008FAE00348FAD00308FAC002C8FAB0028D0
73309+:105A30008FAA00248FA900208FA8001C8FA7001810
73310+:105A40008FA600148FA500108FA4000C8FA3000850
73311+:105A50008FA200048FA1000027BD004C3C1B6004F6
73312+:105A60008F7A5030377B502803400008AF7A00000F
73313+:105A70008F86003C3C0390003C0280000086282575
73314+:105A800000A32025AC4400203C0380008C6700204C
73315+:105A900004E0FFFE0000000003E00008000000003A
73316+:105AA0000A000070240400018F85003C3C04800043
73317+:105AB0003483000100A3102503E00008AC8200201D
73318+:105AC00003E00008000010213084FFFF30A5FFFF35
73319+:105AD00010800007000018213082000110400002F1
73320+:105AE00000042042006518211480FFFB00052840B7
73321+:105AF00003E000080060102110C000070000000053
73322+:105B00008CA2000024C6FFFF24A50004AC82000084
73323+:105B100014C0FFFB2484000403E000080000000020
73324+:105B200010A0000824A3FFFFAC86000000000000C6
73325+:105B3000000000002402FFFF2463FFFF1462FFFA4D
73326+:105B40002484000403E000080000000090AA003153
73327+:105B50008FAB00108CAC00403C0300FF8D6800044C
73328+:105B6000AD6C00208CAD004400E060213462FFFF8A
73329+:105B7000AD6D00248CA700483C09FF000109C0243A
73330+:105B8000AD6700288CAE004C0182C824031978252B
73331+:105B9000AD6F0004AD6E002C8CAD0038314A00FFB3
73332+:105BA000AD6D001C94A900323128FFFFAD680010D4
73333+:105BB00090A70030A5600002A1600004A16700006A
73334+:105BC00090A30032306200FF0002198210600005CD
73335+:105BD000240500011065000E0000000003E000082D
73336+:105BE000A16A00018CD80028354A0080AD780018E1
73337+:105BF0008CCF0014AD6F00148CCE0030AD6E000859
73338+:105C00008CC4002CA16A000103E00008AD64000C04
73339+:105C10008CCD001CAD6D00188CC90014AD6900144A
73340+:105C20008CC80024AD6800088CC70020AD67000C4C
73341+:105C30008CC200148C8300700043C82B1320000713
73342+:105C4000000000008CC20014144CFFE400000000AF
73343+:105C5000354A008003E00008A16A00018C820070D0
73344+:105C60000A0000E6000000009089003027BDFFF820
73345+:105C70008FA8001CA3A900008FA300003C0DFF808B
73346+:105C800035A2FFFF8CAC002C00625824AFAB0000A3
73347+:105C9000A100000400C05821A7A000028D06000446
73348+:105CA00000A048210167C8218FA500000080502175
73349+:105CB0003C18FF7F032C20263C0E00FF2C8C00019B
73350+:105CC000370FFFFF35CDFFFF3C02FF0000AFC824B8
73351+:105CD00000EDC02400C27824000C1DC003236825F9
73352+:105CE00001F87025AD0D0000AD0E00048D240024D8
73353+:105CF000AFAD0000AD0400088D2C00202404FFFF90
73354+:105D0000AD0C000C9547003230E6FFFFAD060010E9
73355+:105D10009145004830A200FF000219C25060000106
73356+:105D20008D240034AD0400148D4700388FAA00186C
73357+:105D300027BD0008AD0B0028AD0A0024AD07001CEC
73358+:105D4000AD00002CAD00001803E00008AD000020FD
73359+:105D500027BDFFE0AFB20018AFB10014AFB0001024
73360+:105D6000AFBF001C9098003000C088213C0D00FFA0
73361+:105D7000330F007FA0CF0000908E003135ACFFFFC5
73362+:105D80003C0AFF00A0CE000194A6001EA220000441
73363+:105D90008CAB00148E29000400A08021016C282403
73364+:105DA000012A40240080902101052025A62600021A
73365+:105DB000AE24000426050020262400080E000092D0
73366+:105DC00024060002924700302605002826240014ED
73367+:105DD00000071E000003160324060004044000030D
73368+:105DE0002403FFFF965900323323FFFF0E00009279
73369+:105DF000AE230010262400248FBF001C8FB2001891
73370+:105E00008FB100148FB00010240500030000302172
73371+:105E10000A00009C27BD002027BDFFD8AFB1001CA1
73372+:105E2000AFB00018AFBF002090A9003024020001DD
73373+:105E300000E050213123003F00A040218FB00040FE
73374+:105E40000080882100C04821106200148FA700380C
73375+:105E5000240B000500A0202100C02821106B001396
73376+:105E6000020030210E000128000000009225007C75
73377+:105E700030A400021080000326030030AE00003082
73378+:105E8000260300348FBF00208FB1001C8FB0001894
73379+:105E90000060102103E0000827BD00280E0000A7C5
73380+:105EA000AFB000100A00016F000000008FA3003C9B
73381+:105EB000010020210120282101403021AFA3001042
73382+:105EC0000E0000EEAFB000140A00016F00000000E9
73383+:105ED0003C06800034C20E008C4400108F850044C4
73384+:105EE000ACA400208C43001803E00008ACA30024FD
73385+:105EF0003C06800034C20E008C4400148F850044A0
73386+:105F0000ACA400208C43001C03E00008ACA30024D8
73387+:105F10009382000C1040001B2483000F2404FFF028
73388+:105F20000064382410E00019978B00109784000E4D
73389+:105F30009389000D3C0A601C0A0001AC01644023F7
73390+:105F400001037021006428231126000231C2FFFFE3
73391+:105F500030A2FFFF0047302B50C0000E00E4482164
73392+:105F60008D4D000C31A3FFFF00036400000C2C03D7
73393+:105F700004A1FFF30000302130637FFF0A0001A479
73394+:105F80002406000103E00008000000009784000ED2
73395+:105F900000E448213123FFFF3168FFFF0068382B00
73396+:105FA00054E0FFF8A783000E938A000D114000050E
73397+:105FB000240F0001006BC023A380000D03E0000844
73398+:105FC000A798000E006BC023A38F000D03E000080C
73399+:105FD000A798000E03E000080000000027BDFFE8BE
73400+:105FE000AFB000103C10800036030140308BFFFF43
73401+:105FF00093AA002BAFBF0014A46B000436040E005C
73402+:106000009488001630C600FF8FA90030A4680006EF
73403+:10601000AC650008A0660012A46A001AAC670020F4
73404+:106020008FA5002CA4690018012020210E000198E2
73405+:10603000AC6500143C021000AE0201788FBF001462
73406+:106040008FB0001003E0000827BD00188F85000006
73407+:106050002484000727BDFFF83084FFF83C06800049
73408+:1060600094CB008A316AFFFFAFAA00008FA900001D
73409+:10607000012540232507FFFF30E31FFF0064102B9D
73410+:106080001440FFF700056882000D288034CC4000E2
73411+:1060900000AC102103E0000827BD00088F8200003B
73412+:1060A0002486000730C5FFF800A2182130641FFFC6
73413+:1060B00003E00008AF8400008F87003C8F84004419
73414+:1060C00027BDFFB0AFB70044AFB40038AFB1002C6C
73415+:1060D000AFBF0048AFB60040AFB5003CAFB300342F
73416+:1060E000AFB20030AFB000283C0B80008C8600249B
73417+:1060F000AD6700808C8A002035670E00356901008D
73418+:10610000ACEA00108C8800248D2500040000B82122
73419+:10611000ACE800188CE3001000A688230000A02142
73420+:10612000ACE300148CE20018ACE2001C122000FE6C
73421+:1061300000E0B021936C0008118000F40000000022
73422+:10614000976F001031EEFFFF022E682B15A000EFB5
73423+:1061500000000000977200103250FFFFAED0000028
73424+:106160003C0380008C740000329300081260FFFD35
73425+:106170000000000096D800088EC700043305FFFF1A
73426+:1061800030B5000112A000E4000000000000000D86
73427+:1061900030BFA0402419004013F9011B30B4A00007
73428+:1061A000128000DF000000009373000812600008F6
73429+:1061B00000000000976D001031ACFFFF00EC202BB9
73430+:1061C0001080000330AE004011C000D50000000078
73431+:1061D000A7850040AF87003893630008022028217C
73432+:1061E000AFB10020146000F527B40020AF60000CB0
73433+:1061F000978F004031F14000162000022403001662
73434+:106200002403000E24054007A363000AAF650014B1
73435+:10621000938A00428F70001431550001001512401E
73436+:1062200002024825AF690014979F00408F78001440
73437+:1062300033F9001003194025AF680014979200400D
73438+:106240003247000810E0016E000000008F67001464
73439+:106250003C1210003C11800000F27825AF6F001452
73440+:1062600036230E00946E000A3C0D81002406000EB9
73441+:1062700031CCFFFF018D2025AF640004A36600022E
73442+:106280009373000A3406FFFC266B0004A36B000A1C
73443+:1062900097980040330820001100015F00000000C3
73444+:1062A0003C05800034A90E00979900409538000CF9
73445+:1062B00097870040001940423312C00031030003A9
73446+:1062C00000127B0330F11000006F6825001172038B
73447+:1062D00001AE6025000C20C0A76400129793004017
73448+:1062E000936A000A001359823175003C02AA1021FA
73449+:1062F0002450003CA3700009953F000C33F93FFF88
73450+:10630000A779001097700012936900090130F821F5
73451+:1063100027E5000230B900070019C0233308000741
73452+:10632000A368000B9371000997720012976F001019
73453+:10633000322700FF8F910038978D004000F218211E
73454+:10634000006F702101C6602131A6004010C0000519
73455+:106350003185FFFF00B1102B3C1280001040001768
73456+:10636000000098210225A82B56A0013E8FA50020F1
73457+:106370003C048000348A0E008D5300143C068000DB
73458+:10638000AD5300108D4B001CAD4B0018AD45000007
73459+:106390008CCD000031AC00081180FFFD34CE0E0022
73460+:1063A00095C3000800A0882100009021A783004029
73461+:1063B0008DC6000424130001AF860038976F0010CB
73462+:1063C00031F5FFFF8E9F000003F1282310A0011F6D
73463+:1063D000AE85000093620008144000DD000000005C
73464+:1063E0000E0001E7240400108F900048004028218F
73465+:1063F0003C023200320600FF000654000142F8253C
73466+:1064000026090001AF890048ACBF0000937900095C
73467+:1064100097780012936F000A332800FF3303FFFFC1
73468+:106420000103382100076C0031EE00FF01AE60254A
73469+:10643000ACAC00048F840048978B0040316A200088
73470+:106440001140010AACA4000897640012308BFFFFD2
73471+:1064500006400108ACAB000C978E004031C5000827
73472+:1064600014A0000226280006262800023C1F8000F7
73473+:1064700037E70E0094F900148CE5001C8F670004C8
73474+:10648000937800023324FFFF330300FFAFA3001013
73475+:106490008F6F0014AFA800180E0001CBAFAF00142F
73476+:1064A000240400100E0001FB000000008E9200008A
73477+:1064B00016400005000000008F7800142403FFBF81
73478+:1064C0000303A024AF7400148F67000C00F5C821EB
73479+:1064D000AF79000C9375000816A0000800000000BA
73480+:1064E00012600006000000008F6800143C0AEFFFF5
73481+:1064F0003549FFFE0109F824AF7F0014A37300089B
73482+:106500008FA500200A00034F02202021AED10000F9
73483+:106510000A00022D3C03800014E0FF1E30BFA040A3
73484+:106520000E0001900000A0212E9100010237B0253D
73485+:1065300012C000188FBF00488F87003C24170F003F
73486+:1065400010F700D43C0680008CD901780720FFFEAC
73487+:10655000241F0F0010FF00F634CA0E008D560014E1
73488+:1065600034C7014024080240ACF600048D49001CE9
73489+:106570003C141000ACE90008A0E00012A4E0001AEE
73490+:10658000ACE00020A4E00018ACE80014ACD4017822
73491+:106590008FBF00488FB700448FB600408FB5003CD6
73492+:1065A0008FB400388FB300348FB200308FB1002C1D
73493+:1065B0008FB0002803E0000827BD00508F910038FD
73494+:1065C000978800403C1280000220A821310700403B
73495+:1065D00014E0FF7C00009821977900108F9200381A
73496+:1065E0003338FFFF131200A8000020210080A021F3
73497+:1065F000108000F300A088211620FECE00000000CD
73498+:106600000A00031F2E9100013C0380008C62017878
73499+:106610000440FFFE240808008F860000AC68017863
73500+:106620003C038000946D008A31ACFFFF0186582343
73501+:10663000256AFFFF31441FFF2C8900081520FFF950
73502+:10664000000000008F8F0048347040008F83003CB2
73503+:1066500000E0A021240E0F0025E70001AF870048CD
73504+:1066600000D03021023488233C08800031F500FF3F
73505+:10667000106E0005240700019398004233130001B7
73506+:106680000013924036470001001524003C0A010027
73507+:10669000008A4825ACC900008F82004830BF003610
73508+:1066A00030B90008ACC200041320009900FF9825FF
73509+:1066B00035120E009650000A8F8700003C0F8100B3
73510+:1066C0003203FFFF24ED000835060140006F60250E
73511+:1066D0003C0E100031AB1FFF269200062405000E71
73512+:1066E000ACCC0020026E9825A4C5001AAF8B000028
73513+:1066F000A4D20018162000083C1080008F89003CAE
73514+:1067000024020F00512200022417000136730040BA
73515+:106710000E0001883C10800036060E008CCB001461
73516+:10672000360A014002402021AD4B00048CC5001CFC
73517+:10673000AD450008A1550012AD5300140E0001989C
73518+:106740003C151000AE1501780A000352000000004D
73519+:10675000936F0009976E0012936D000B31E500FFF7
73520+:1067600000AE202131AC00FF008C80212602000AFF
73521+:106770003050FFFF0E0001E7020020218F86004805
73522+:106780003C0341003C05800024CB0001AF8B004856
73523+:10679000936A00099769001230C600FF315F00FF5D
73524+:1067A0003128FFFF03E8382124F900020006C40065
73525+:1067B0000319782501E37025AC4E00008F6D000CA5
73526+:1067C00034A40E00948B001401B26025AC4C00047C
73527+:1067D0008C85001C8F670004936A00023164FFFF00
73528+:1067E000314900FFAFA900108F680014AFB1001845
73529+:1067F0000E0001CBAFA800140A0002FD0200202108
73530+:10680000AF600004A36000029798004033082000A6
73531+:106810001500FEA300003021A760001297840040FD
73532+:10682000936B000A3C10800030931F0000135183CB
73533+:10683000014BA82126A20028A362000936090E00F8
73534+:10684000953F000C0A000295A77F00108F7000147E
73535+:10685000360900400E000188AF6900140A0002C921
73536+:10686000000000000A00034F000020210641FEFA4C
73537+:10687000ACA0000C8CAC000C3C0D8000018D902570
73538+:106880000A0002EAACB2000C000090210A0002C526
73539+:1068900024130001128000073C028000344B0E00DC
73540+:1068A0009566000830D300401260004900000000E7
73541+:1068B0003C0680008CD001780600FFFE34C50E0037
73542+:1068C00094B500103C03050034CC014032B8FFFF02
73543+:1068D00003039025AD92000C8CAF0014240D200012
73544+:1068E0003C041000AD8F00048CAE001CAD8E00087F
73545+:1068F000A1800012A580001AAD800020A58000189C
73546+:10690000AD8D0014ACC401780A0003263C0680005B
73547+:106910008F9F0000351801402692000227F90008D9
73548+:1069200033281FFFA71200180A000391AF88000048
73549+:106930003C02800034450140ACA0000C1280001BDA
73550+:1069400034530E0034510E008E370010ACB70004E3
73551+:106950008E2400183C0B8000ACA400083570014068
73552+:1069600024040040A20000128FBF0048A600001AB5
73553+:106970008FB70044AE0000208FB60040A60000187C
73554+:106980008FB5003CAE0400148FB400388FB30034D0
73555+:106990008FB200308FB1002C8FB000283C02100065
73556+:1069A00027BD005003E00008AD6201788E66001438
73557+:1069B000ACA600048E64001C0A00042A3C0B800074
73558+:1069C0000E0001902E9100010A0003200237B0252D
73559+:1069D000000000000000000D00000000240003691A
73560+:1069E0000A0004013C06800027BDFFD8AFBF00208D
73561+:1069F0003C0980003C1F20FFAFB200183C0760003C
73562+:106A000035320E002402001037F9FFFDACE23008E9
73563+:106A1000AFB3001CAFB10014AFB00010AE5900000E
73564+:106A20000000000000000000000000000000000066
73565+:106A3000000000003C1800FF3713FFFDAE530000BC
73566+:106A40003C0B60048D7050002411FF7F3C0E00024F
73567+:106A50000211782435EC380C35CD0109ACED4C1819
73568+:106A6000240A0009AD6C50008CE80438AD2A0008F7
73569+:106A7000AD2000148CE54C1C3106FFFF38C42F718B
73570+:106A800000051E023062000F2486C0B310400007CC
73571+:106A9000AF8200088CE54C1C3C09001F3528FC0027
73572+:106AA00000A81824000321C2AF8400048CF1080858
73573+:106AB0003C0F57092412F0000232702435F0001008
73574+:106AC00001D0602601CF68262DAA00012D8B000180
73575+:106AD000014B382550E00009A380000C3C1F601CCE
73576+:106AE0008FF8000824190001A399000C33137C00CF
73577+:106AF000A7930010A780000EA380000DAF80004870
73578+:106B000014C00003AF8000003C066000ACC0442C01
73579+:106B10000E0005B93C1080000E000F1A361101005E
73580+:106B20003C12080026523DD03C13080026733E500C
73581+:106B30008E03000038640001308200011440FFFC25
73582+:106B40003C0B800A8E2600002407FF8024C90240E7
73583+:106B5000312A007F014B402101272824AE06002066
73584+:106B6000AF880044AE0500243C048000AF86003CA2
73585+:106B70008C8C01780580FFFE24180800922F0008F5
73586+:106B8000AC980178A38F0042938E004231CD000172
73587+:106B900011A0000F24050D0024DFF8002FF90301D8
73588+:106BA0001320001C000629C224A4FFF00004104298
73589+:106BB000000231400E00020200D2D8213C02400007
73590+:106BC0003C068000ACC201380A0004A000000000AE
73591+:106BD00010C50023240D0F0010CD00273C1F800896
73592+:106BE00037F9008093380000240E0050330F00FF67
73593+:106BF00015EEFFF33C0240000E000A3600000000D4
73594+:106C00003C0240003C068000ACC201380A0004A0EF
73595+:106C1000000000008F83000400A3402B1500000B30
73596+:106C20008F8B0008006B50212547FFFF00E5482BA4
73597+:106C30001520000600A36023000C19400E0002027C
73598+:106C40000073D8210A0004C43C0240000000000D7B
73599+:106C50000E000202000000000A0004C43C024000D2
73600+:106C60003C1B0800277B3F500E0002020000000082
73601+:106C70000A0004C43C0240003C1B0800277B3F7014
73602+:106C80000E000202000000000A0004C43C024000A2
73603+:106C90003C0660043C09080025290104ACC9502CBD
73604+:106CA0008CC850003C0580003C0200023507008083
73605+:106CB000ACC750003C040800248415A43C03080021
73606+:106CC0002463155CACA50008ACA2000C3C010800D4
73607+:106CD000AC243D603C010800AC233D6403E00008A7
73608+:106CE0002402000100A030213C1C0800279C3D68C4
73609+:106CF0003C0C04003C0B0002008B3826008C402624
73610+:106D00002CE200010007502B2D050001000A4880ED
73611+:106D10003C03080024633D60004520250123182121
73612+:106D20001080000300001021AC6600002402000166
73613+:106D300003E00008000000003C1C0800279C3D68A0
73614+:106D40003C0B04003C0A0002008A3026008B3826E7
73615+:106D50002CC200010006482B2CE5000100094080F0
73616+:106D60003C03080024633D600045202501031821F1
73617+:106D700010800005000010213C0C0800258C155CDB
73618+:106D8000AC6C00002402000103E0000800000000D9
73619+:106D90003C0900023C08040000883026008938269F
73620+:106DA0002CC30001008028212CE400010083102561
73621+:106DB0001040000B000030213C1C0800279C3D685F
73622+:106DC0003C0A80008D4E00082406000101CA682597
73623+:106DD000AD4D00088D4C000C01855825AD4B000CC5
73624+:106DE00003E0000800C010213C1C0800279C3D68FF
73625+:106DF0003C0580008CA6000C000420272402000122
73626+:106E000000C4182403E00008ACA3000C3C020002FC
73627+:106E10001082000B3C0560003C0704001087000353
73628+:106E20000000000003E00008000000008CA908D06A
73629+:106E3000240AFFFD012A402403E00008ACA808D082
73630+:106E40008CA408D02406FFFE0086182403E0000866
73631+:106E5000ACA308D03C05601A34A600108CC3008097
73632+:106E600027BDFFF88CC50084AFA3000093A40000E9
73633+:106E70002402000110820003AFA5000403E0000813
73634+:106E800027BD000893A7000114E0001497AC00028E
73635+:106E900097B800023C0F8000330EFFFC01CF682141
73636+:106EA000ADA50000A3A000003C0660008CC708D080
73637+:106EB0002408FFFE3C04601A00E82824ACC508D072
73638+:106EC0008FA300048FA200003499001027BD000892
73639+:106ED000AF22008003E00008AF2300843C0B800059
73640+:106EE000318AFFFC014B48218D2800000A00057DF6
73641+:106EF000AFA8000427BDFFE8AFBF00103C1C08008E
73642+:106F0000279C3D683C0580008CA4000C8CA20004EA
73643+:106F10003C0300020044282410A0000A00A3182407
73644+:106F20003C0604003C0400021460000900A6102482
73645+:106F30001440000F3C0404000000000D3C1C08003D
73646+:106F4000279C3D688FBF001003E0000827BD001894
73647+:106F50003C0208008C423D600040F809000000003F
73648+:106F60003C1C0800279C3D680A0005A68FBF001046
73649+:106F70003C0208008C423D640040F809000000001B
73650+:106F80000A0005AC00000000000411C003E0000886
73651+:106F9000244202403C04080024843FB42405001A23
73652+:106FA0000A00009C0000302127BDFFE0AFB00010B8
73653+:106FB0003C108000AFBF0018AFB1001436110100C3
73654+:106FC000922200090E0005B63044007F8E3F00007B
73655+:106FD0008F89003C3C0F008003E26021258800403F
73656+:106FE0000049F821240DFF80310E00783198007897
73657+:106FF00035F9000135F100020319382501D1482582
73658+:10700000010D302403ED5824018D2824240A00406A
73659+:1070100024040080240300C0AE0B0024AE0008103E
73660+:10702000AE0A0814AE040818AE03081CAE05080426
73661+:10703000AE070820AE060808AE0908243609090084
73662+:107040009539000C3605098033ED007F3338FFFF9A
73663+:10705000001889C0AE110800AE0F0828952C000C4E
73664+:107060008FBF00188FB10014318BFFFF000B51C090
73665+:10707000AE0A002C8CA400508FB000108CA3003CF2
73666+:107080008D2700048CA8001C8CA600383C0E800ABA
73667+:1070900001AE102127BD0020AF820044AF84005014
73668+:1070A000AF830054AF87004CAF88005C03E000085A
73669+:1070B000AF8600603C09080091293FD924A800024E
73670+:1070C0003C05110000093C0000E8302500C51825EA
73671+:1070D00024820008AC83000003E00008AC800004B8
73672+:1070E0003C098000352309009128010B906A0011AA
73673+:1070F0002402002800804821314700FF00A07021B1
73674+:1071000000C068213108004010E20002340C86DD26
73675+:10711000240C08003C0A800035420A9A944700007B
73676+:10712000354B0A9C35460AA030F9FFFFAD39000007
73677+:107130008D780000354B0A8024040001AD3800042E
73678+:107140008CCF0000AD2F00089165001930A300031B
73679+:107150001064009028640002148000AF240500022F
73680+:107160001065009E240F0003106F00B435450AA47B
73681+:10717000240A0800118A0048000000005100003D68
73682+:107180003C0B80003C0480003483090090670012AF
73683+:1071900030E200FF004D7821000FC8802724000155
73684+:1071A0003C0A8000354F090091E50019354C0980F3
73685+:1071B0008D87002830A300FF0003150000475825E5
73686+:1071C0000004C4003C19600001793025370806FF2F
73687+:1071D000AD260000AD2800048DEA002C25280028EB
73688+:1071E000AD2A00088DEC0030AD2C000C8DE500348C
73689+:1071F000AD2500108DE400383C05800034AC093C1E
73690+:10720000AD2400148DE3001CAD2300188DE7002091
73691+:10721000AD27001C8DE20024AD2200208DF900284E
73692+:1072200034A20100AD3900248D830000AD0E0004AE
73693+:1072300034B90900AD0300008C47000C250200148E
73694+:10724000AD070008932B00123C04080090843FD83F
73695+:10725000AD000010317800FF030D302100064F0013
73696+:1072600000047C00012F702535CDFFFC03E00008F1
73697+:10727000AD0D000C35780900930600123C0508009E
73698+:1072800094A53FC830C800FF010D5021000A60805E
73699+:107290000A00063C018520211500005B000000006B
73700+:1072A0003C08080095083FCE3C06080094C63FC83D
73701+:1072B000010610213C0B800035790900933800113C
73702+:1072C000932A001935660A80330800FF94CF002AFC
73703+:1072D00000086082314500FF978A0058000C1E00AC
73704+:1072E000000524003047FFFF006410250047C0253B
73705+:1072F00001EA30213C0B4000030B402500066400EE
73706+:10730000AD280000AD2C0004932500183C030006B6
73707+:107310002528001400053E0000E31025AD220008DA
73708+:107320008F24002C3C05800034AC093CAD24000CBB
73709+:107330008F38001C34A20100254F0001AD38001029
73710+:107340008D830000AD0E000431EB7FFFAD03000024
73711+:107350008C47000C34B90900A78B0058AD07000812
73712+:10736000932B00123C04080090843FD8250200149F
73713+:10737000317800FF030D302100064F0000047C002F
73714+:10738000012F702535CDFFFCAD00001003E0000893
73715+:10739000AD0D000C3C02080094423FD23C050800B1
73716+:1073A00094A53FC835440AA43C07080094E73FC4AD
73717+:1073B000948B00000045C8210327C023000B1C004C
73718+:1073C0002706FFF200665025AD2A000CAD20001004
73719+:1073D000AD2C00140A00063025290018354F0AA4E8
73720+:1073E00095E50000956400280005140000043C00A9
73721+:1073F0003459810000EC5825AD39000CAD2B00103C
73722+:107400000A000630252900143C0C0800958C3FCE5C
73723+:107410000A000681258200015460FF56240A0800F4
73724+:1074200035580AA49706000000061C00006C502581
73725+:10743000AD2A000C0A000630252900103C03080084
73726+:1074400094633FD23C07080094E73FC83C0F080014
73727+:1074500095EF3FC494A4000095790028006710219F
73728+:10746000004F582300041C00001934002578FFEE5B
73729+:1074700000D87825346A8100AD2A000CAD2F0010A9
73730+:10748000AD200014AD2C00180A0006302529001C80
73731+:1074900003E00008240207D027BDFFE0AFB20018C8
73732+:1074A000AFB10014AFB00010AFBF001C0E00007CE5
73733+:1074B000008088218F8800548F87004C3C0580080D
73734+:1074C00034B20080011128213C1080002402008089
73735+:1074D000240300C000A72023AE0208183C06800841
73736+:1074E000AE03081C18800004AF850054ACC500042E
73737+:1074F0008CC90004AF89004C1220000936040980B1
73738+:107500000E0006F800000000924C00278E0B00745D
73739+:1075100001825004014B3021AE46000C3604098034
73740+:107520008C8E001C8F8F005C01CF682319A0000493
73741+:107530008FBF001C8C90001CAF90005C8FBF001CA4
73742+:107540008FB200188FB100148FB000100A00007EB7
73743+:1075500027BD00208F8600508F8300548F82004CFF
73744+:107560003C05800834A40080AC860050AC83003C0D
73745+:1075700003E00008ACA200043C0308008C63005444
73746+:1075800027BDFFF8308400FF2462000130A500FF12
73747+:107590003C010800AC22005430C600FF3C078000CC
73748+:1075A0008CE801780500FFFE3C0C7FFFA3A40003DC
73749+:1075B0008FAA0000358BFFFF014B4824000627C02F
73750+:1075C00001244025AFA8000034E201009043000AE6
73751+:1075D000A3A000023C1980FFA3A300018FAF00000D
73752+:1075E00030AE007F3738FFFF01F86024000E6E00D8
73753+:1075F0003C0A002034E50140018D58253549200022
73754+:107600002406FF803C04100027BD0008ACAB000C32
73755+:10761000ACA90014A4A00018A0A6001203E0000862
73756+:10762000ACE40178308800FF30A700FF3C03800005
73757+:107630008C6201780440FFFE3C0C8000358A0A0011
73758+:107640008D4B00203584014035850980AC8B0004CA
73759+:107650008D4900240007302B00061540AC89000836
73760+:10766000A088001090A3004CA083002D03E0000828
73761+:10767000A480001827BDFFE8308400FFAFBF0010D2
73762+:107680000E00075D30A500FF8F8300548FBF0010F0
73763+:107690003C06800034C50140344700402404FF907C
73764+:1076A0003C02100027BD0018ACA3000CA0A40012DF
73765+:1076B000ACA7001403E00008ACC2017827BDFFE0CE
73766+:1076C0003C088008AFBF001CAFB20018AFB1001477
73767+:1076D000AFB00010351000808E0600183C07800007
73768+:1076E000309200FF00C72025AE0400180E00007C79
73769+:1076F00030B100FF92030005346200080E00007EE6
73770+:10770000A2020005024020210E000771022028215C
73771+:10771000024020218FBF001C8FB200188FB10014CF
73772+:107720008FB0001024050005240600010A0007326E
73773+:1077300027BD00203C05800034A309809066000826
73774+:1077400030C200081040000F3C0A01013549080A08
73775+:10775000AC8900008CA80074AC8800043C070800C9
73776+:1077600090E73FD830E5001050A00008AC8000083A
73777+:107770003C0D800835AC00808D8B0058AC8B000828
73778+:107780002484000C03E00008008010210A0007B5E3
73779+:107790002484000C27BDFFE83C098000AFB0001036
73780+:1077A000AFBF00143526098090C8000924020006E6
73781+:1077B00000A05821310300FF3527090000808021F7
73782+:1077C000240500041062007B2408000294CF005CB2
73783+:1077D0003C0E020431EDFFFF01AE6025AE0C00004F
73784+:1077E00090CA00083144002010800008000000000A
73785+:1077F00090C2004E3C1F010337F90300305800FFD0
73786+:107800000319302524050008AE06000490F9001184
73787+:1078100090E6001290E40011333800FF00187082E7
73788+:1078200030CF00FF01CF5021014B6821308900FF8C
73789+:1078300031AAFFFF39230028000A60801460002C61
73790+:10784000020C482390E400123C198000372F0100FD
73791+:10785000308C00FF018B1821000310800045F821B7
73792+:10786000001F8400360706FFAD270004373F0900DC
73793+:1078700093EC001193EE0012372609800005C082B8
73794+:107880008DE4000C8CC5003431CD00FF01AB10211C
73795+:107890000058182100A4F8230008840000033F00CA
73796+:1078A00000F0302533F9FFFF318F00FC00D970253F
73797+:1078B0000158202101E9682100045080ADAE000C80
73798+:1078C0000E00007C012A80213C088008240B000463
73799+:1078D000350500800E00007EA0AB000902001021DB
73800+:1078E0008FBF00148FB0001003E0000827BD001800
73801+:1078F00090EC001190E300193C18080097183FCE57
73802+:10790000318200FF0002F882307000FF001FCE00BD
73803+:1079100000103C000327302500D870253C0F4000A4
73804+:1079200001CF68253C198000AD2D0000373F0900CC
73805+:1079300093EC001193EE0012372F010037260980D7
73806+:107940000005C0828DE4000C8CC5003431CD00FFF1
73807+:1079500001AB10210058182100A4F823000884006E
73808+:1079600000033F0000F0302533F9FFFF318F00FCAA
73809+:1079700000D970250158202101E9682100045080B8
73810+:10798000ADAE000C0E00007C012A80213C0880086E
73811+:10799000240B0004350500800E00007EA0AB00091A
73812+:1079A000020010218FBF00148FB0001003E0000808
73813+:1079B00027BD00180A0007C72408001227BDFFD002
73814+:1079C0003C038000AFB60028AFB50024AFB4002060
73815+:1079D000AFB10014AFBF002CAFB3001CAFB20018A2
73816+:1079E000AFB000103467010090E6000B309400FF48
73817+:1079F00030B500FF30C200300000B02110400099C7
73818+:107A000000008821346409809088000800082E0056
73819+:107A100000051E03046000C0240400048F86005487
73820+:107A20003C010800A0243FD83C0C8000AD800048F9
73821+:107A30003C048000348E010091CD000B31A5002064
73822+:107A400010A000073C078000349309809272000860
73823+:107A50000012860000107E0305E000C43C1F800871
73824+:107A600034EC0100918A000B34EB09809169000825
73825+:107A7000314400400004402B3123000800C8982303
73826+:107A80001460000224120003000090213C108000CA
73827+:107A900036180A8036040900970E002C90830011D6
73828+:107AA0009089001293050018307F00FF312800FFF5
73829+:107AB000024810210002C880930D0018033F78216E
73830+:107AC00001F1302130B100FF00D11821A78E0058FC
73831+:107AD0003C010800A4263FCE3C010800A4233FD06F
73832+:107AE00015A00002000000000000000D920B010B29
73833+:107AF0003065FFFF3C010800A4233FD2316A0040FB
73834+:107B00003C010800A4203FC83C010800A4203FC459
73835+:107B10001140000224A4000A24A4000B3091FFFFAE
73836+:107B20000E0001E7022020219206010B3C0C080008
73837+:107B3000958C3FD2004020210006698231A70001C8
73838+:107B40000E00060101872821004020210260282123
73839+:107B50000E00060C024030210E0007A1004020213B
73840+:107B600016C00069004020219212010B32560040DD
73841+:107B700012C000053C0500FF8C93000034AEFFFFEF
73842+:107B8000026E8024AC9000000E0001FB0220202138
73843+:107B90003C0F080091EF3FD831F10003122000168E
73844+:107BA0003C1380088F8200543C09800835280080EF
73845+:107BB000245F0001AD1F003C3C0580088CB9000427
73846+:107BC00003E02021033FC0231B000002AF9F0054AD
73847+:107BD0008CA400040E0006F8ACA400043C0780004E
73848+:107BE0008CEB00743C04800834830080004B5021EF
73849+:107BF000AC6A000C3C1380083670008002802021A3
73850+:107C000002A02821A200006B0E00075D3C1480003A
73851+:107C10008F920054368C0140AD92000C8F86004844
73852+:107C20003C151000344D000624D60001AF960048E4
73853+:107C30008FBF002CA18600128FB60028AD8D0014D6
73854+:107C40008FB3001CAE9501788FB200188FB5002459
73855+:107C50008FB400208FB100148FB0001003E0000833
73856+:107C600027BD003034640980908F0008000F760033
73857+:107C7000000E6E0305A00033347F090093F8001B4B
73858+:107C8000241900103C010800A0393FD8331300022A
73859+:107C90001260FF678F8600548F8200601446FF6574
73860+:107CA0003C0480000E00007C000000003C048008C2
73861+:107CB0003485008090A8000924060016310300FFD7
73862+:107CC0001066000D0000000090AB00093C070800A2
73863+:107CD00090E73FD824090008316400FF34EA00012E
73864+:107CE0003C010800A02A3FD81089002F240C000A6C
73865+:107CF000108C00282402000C0E00007E0000000002
73866+:107D00000A0008608F8600540E0007B9024028213F
73867+:107D10000A0008AE004020213C0B8008356A008034
73868+:107D20008D4600548CE9000C1120FF3DAF860054B5
73869+:107D3000240700143C010800A0273FD80A00085F70
73870+:107D40003C0C800090910008241200023C010800C5
73871+:107D5000A0323FD8323000201200000B2416000160
73872+:107D60008F8600540A0008602411000837F800804C
73873+:107D70008F020038AFE200048FF90004AF19003C15
73874+:107D80000A00086C3C0780008F8600540A000860D7
73875+:107D900024110004A0A200090E00007E00000000D3
73876+:107DA0000A0008608F860054240200140A00093A71
73877+:107DB000A0A2000927BDFFE8AFB000103C10800072
73878+:107DC000AFBF001436020100904400090E00075DA9
73879+:107DD000240500013C0480089099000E3483008043
73880+:107DE000909F000F906F00269089000A33F800FFE3
73881+:107DF00000196E000018740031EC00FF01AE502530
73882+:107E0000000C5A00014B3825312800FF3603014091
73883+:107E10003445600000E830252402FF813C04100056
73884+:107E2000AC66000C8FBF0014AC650014A062001299
73885+:107E3000AE0401788FB0001003E0000827BD0018E1
73886+:107E400027BDFFE8308400FFAFBF00100E00075DC4
73887+:107E500030A500FF3C05800034A4014034470040B9
73888+:107E60002406FF92AC870014A08600128F83005472
73889+:107E70008FBF00103C02100027BD0018AC83000C1F
73890+:107E800003E00008ACA2017827BDFFD8AFB0001016
73891+:107E9000308400FF30B000FF3C058000AFB100141B
73892+:107EA000AFBF0020AFB3001CAFB20018000410C277
73893+:107EB00034A60100320300023051000114600007B3
73894+:107EC00090D200093C098008353300809268000593
73895+:107ED0003107000810E0000C308A00100240202119
73896+:107EE0000E00078302202821240200018FBF0020FA
73897+:107EF0008FB3001C8FB200188FB100148FB0001028
73898+:107F000003E0000827BD00281540003434A50A000E
73899+:107F10008CB800248CAF0008130F004B00003821F0
73900+:107F20003C0D800835B30080926C00682406000286
73901+:107F3000318B00FF116600843C06800034C20100D2
73902+:107F40009263004C90590009307F00FF53F9000400
73903+:107F50003213007C10E00069000000003213007C46
73904+:107F60005660005C0240202116200009320D0001FD
73905+:107F70003C0C800035840100358B0A008D6500249F
73906+:107F80008C86000414A6FFD900001021320D0001D8
73907+:107F900011A0000E024020213C1880003710010083
73908+:107FA0008E0F000C8F8E005011EE000800000000B4
73909+:107FB0000E000843022028218E19000C3C1F800867
73910+:107FC00037F00080AE190050024020210E000771EA
73911+:107FD000022028210A00098F240200013C05080024
73912+:107FE0008CA5006424A400013C010800AC240064BA
73913+:107FF0001600000D00000000022028210E0007716D
73914+:1080000002402021926E0068240C000231CD00FF56
73915+:1080100011AC0022024020210E00094100000000A6
73916+:108020000A00098F240200010E00007024040001E0
73917+:10803000926B0025020B30250E00007EA266002503
73918+:108040000A0009D3022028218E6200188CDF000468
73919+:108050008CB9002400021E0217F9FFB13065007FC1
73920+:108060009268004C264400013093007F1265004066
73921+:10807000310300FF1464FFAB3C0D8008264700016C
73922+:1080800030F1007F30E200FF1225000B24070001D1
73923+:10809000004090210A00099C2411000124050004DD
73924+:1080A0000E000732240600010E0009410000000006
73925+:1080B0000A00098F240200012405FF8002452024C4
73926+:1080C00000859026324200FF004090210A00099C62
73927+:1080D000241100010E00084302202821320700303D
73928+:1080E00010E0FFA132100082024020210E00078321
73929+:1080F000022028210A00098F240200018E6900183D
73930+:108100000240202102202821012640250E0009647A
73931+:10811000AE6800189264004C240500032406000198
73932+:108120000E000732308400FF0E00007024040001AE
73933+:1081300092710025021150250E00007EA26A0025D2
73934+:108140000A00098F240200018E6F00183C1880007D
73935+:108150000240202101F87025022028210E0007711D
73936+:10816000AE6E00189264004C0A000A1B240500043D
73937+:10817000324A0080394900801469FF6A3C0D80084A
73938+:108180000A0009F42647000127BDFFC0AFB0001860
73939+:108190003C108000AFBF0038AFB70034AFB600303E
73940+:1081A000AFB5002CAFB40028AFB30024AFB20020AD
73941+:1081B0000E0005BEAFB1001C360201009045000B59
73942+:1081C0000E00097690440008144000E78FBF003885
73943+:1081D0003C08800835070080A0E0006B3606098067
73944+:1081E00090C50000240300503C17080026F73F907C
73945+:1081F00030A400FF3C13080026733FA01083000347
73946+:108200003C1080000000B82100009821241F0010BD
73947+:108210003611010036120A00361509808E580024E6
73948+:108220008E3400048EAF00208F8C00543C01080077
73949+:10823000A03F3FD836190A80972B002C8EF60000FD
73950+:10824000932A00180298702301EC68233C0108006F
73951+:10825000AC2E3FB43C010800AC2D3FB83C010800F7
73952+:10826000AC2C3FDCA78B005802C0F809315400FF4A
73953+:1082700030490002152000E930420001504000C49E
73954+:108280009227000992A90008312800081500000271
73955+:10829000241500030000A8213C0A80003543090092
73956+:1082A00035440A008C8D00249072001190700012E9
73957+:1082B000907F0011325900FF321100FF02B11021EE
73958+:1082C0000002C08033EF00FF0319B021028F70213C
73959+:1082D00002D4602125CB00103C010800A4363FCE1B
73960+:1082E0003C010800AC2D3FE03C010800A42C3FD02D
73961+:1082F0003C010800A42B3FCC3556010035540980C1
73962+:1083000035510E008F8700548F89005C8E850020C8
73963+:1083100024080006012730233C010800AC283FD484
73964+:1083200000A7282304C000B50000902104A000B3DA
73965+:1083300000C5502B114000B5000000003C010800B2
73966+:10834000AC263FB88E6200000040F8090000000033
73967+:108350003046000214C0007400408021304B000100
73968+:10836000556000118E6200043C0D08008DAD3FBCCD
73969+:108370003C0EC0003C04800001AE6025AE2C000025
73970+:108380008C980000330F000811E0FFFD0000000092
73971+:10839000963F000824120001A79F00408E39000478
73972+:1083A000AF9900388E6200040040F8090000000018
73973+:1083B0000202802532030002146000B300000000B6
73974+:1083C0003C09080095293FC43C06080094C63FD0EC
73975+:1083D0003C0A0800954A3FC63C0708008CE73FBCB2
73976+:1083E000012670213C0308008C633FE03C08080034
73977+:1083F00095083FDA01CA20218ED9000C00E9282116
73978+:10840000249F000200A878210067C02133E4FFFF09
73979+:10841000AF9900503C010800AC383FE03C01080037
73980+:10842000A42F3FC83C010800A42E3FD20E0001E754
73981+:10843000000000008F8D0048004020213C01080012
73982+:10844000A02D3FD98E62000825AC0001AF8C0048FA
73983+:108450000040F809000000008F85005402A0302180
73984+:108460000E00060C004020210E0007A10040202134
73985+:108470008E6B000C0160F809004020213C0A0800C6
73986+:10848000954A3FD23C06080094C63FC601464821A3
73987+:10849000252800020E0001FB3104FFFF3C05080007
73988+:1084A0008CA53FB43C0708008CE73FBC00A7202305
73989+:1084B0003C010800AC243FB414800006000000001A
73990+:1084C0003C0208008C423FD4344B00403C01080081
73991+:1084D000AC2B3FD4124000438F8E00448E2D0010F1
73992+:1084E0008F920044AE4D00208E2C0018AE4C00241C
73993+:1084F0003C04080094843FC80E0006FA0000000007
73994+:108500008F9F00548E6700103C010800AC3F3FDC99
73995+:1085100000E0F809000000003C1908008F393FB462
73996+:108520001720FF798F870054979300583C11800ED5
73997+:10853000321601000E000729A633002C16C0004594
73998+:10854000320300105460004C8EE5000432080040F5
73999+:108550005500001D8EF000088EE4000C0080F80924
74000+:10856000000000008FBF00388FB700348FB6003096
74001+:108570008FB5002C8FB400288FB300248FB2002059
74002+:108580008FB1001C8FB0001803E0000827BD004029
74003+:108590008F86003C36110E0000072E0000A6202515
74004+:1085A000AE0400808E4300208E500024AFA3001044
74005+:1085B000AE2300148FB20010AE320010AE30001C9B
74006+:1085C0000A000A75AE3000180200F8090000000029
74007+:1085D0008EE4000C0080F809000000000A000B2E59
74008+:1085E0008FBF003824180001240F0001A5C000200F
74009+:1085F000A5D800220A000B10ADCF00243C010800D2
74010+:10860000AC203FB80A000AA68E6200003C010800B8
74011+:10861000AC253FB80A000AA68E6200009224000929
74012+:108620000E000771000028218FBF00388FB700347B
74013+:108630008FB600308FB5002C8FB400288FB3002484
74014+:108640008FB200208FB1001C8FB0001803E000082B
74015+:1086500027BD00403C1480009295010900002821AC
74016+:108660000E00084332A400FF320300105060FFB830
74017+:10867000320800408EE5000400A0F8090000000068
74018+:108680000A000B28320800405240FFA89793005878
74019+:108690008E3400148F930044AE7400208E35001C7D
74020+:1086A000AE7500240A000B1F979300588F820014A8
74021+:1086B0000004218003E00008008210213C078008AC
74022+:1086C00034E200809043006900804021106000097E
74023+:1086D0003C0401003C0708008CE73FDC8F8300303E
74024+:1086E00000E32023048000089389001C14E30003A6
74025+:1086F0000100202103E00008008010213C0401005B
74026+:1087000003E00008008010211120000B00673823CF
74027+:108710003C0D800035AC0980918B007C316A0002F1
74028+:10872000114000202409003400E9702B15C0FFF12E
74029+:108730000100202100E938232403FFFC00A3C82402
74030+:1087400000E3C02400F9782B15E0FFEA030820219C
74031+:1087500030C400030004102314C000143049000387
74032+:108760000000302100A9782101E6702100EE682B7D
74033+:1087700011A0FFE03C0401002D3800010006C82BC9
74034+:10878000010548210319382414E0FFDA2524FFFCF1
74035+:108790002402FFFC00A218240068202103E0000846
74036+:1087A000008010210A000B9E240900303C0C800040
74037+:1087B0003586098090CB007C316A00041540FFE9C2
74038+:1087C000240600040A000BAD000030213C03080021
74039+:1087D0008C63005C8F82001827BDFFE0AFBF0018DC
74040+:1087E000AFB1001410620005AFB00010000329C043
74041+:1087F00024A40280AF840014AF8300183C108000D2
74042+:1088000036020A0094450032361101000E000B7F3B
74043+:1088100030A43FFF8E240000241FFF803C11008005
74044+:108820000082C021031F60243309007F000CC9406F
74045+:1088300003294025330E0078362F00033C0D10002D
74046+:10884000010D502501CF5825AE0C002836080980AF
74047+:10885000AE0C080CAE0B082CAE0A08309103006970
74048+:108860003C06800C0126382110600006AF870034DA
74049+:108870008D09003C8D03006C0123382318E0008231
74050+:10888000000000003C0B8008356A00803C1080002E
74051+:10889000A1400069360609808CC200383C06800081
74052+:1088A00034C50A0090A8003C310C00201180001A49
74053+:1088B000AF820030240D00013C0E800035D10A004B
74054+:1088C000A38D001CAF8000248E2400248F850024FB
74055+:1088D000240D0008AF800020AF8000283C01080074
74056+:1088E000A42D3FC63C010800A4203FDA0E000B83F4
74057+:1088F000000030219228003C8FBF00188FB1001477
74058+:108900008FB0001000086142AF82002C27BD00200C
74059+:1089100003E000083182000190B80032240E00010B
74060+:10892000330F00FF000F2182108E00412419000236
74061+:108930001099006434C40AC03C03800034640A0007
74062+:108940008C8F002415E0001E34660900909F0030D3
74063+:108950002418000533F9003F1338004E24030001AA
74064+:108960008F860020A383001CAF860028AF860024DA
74065+:108970003C0E800035D10A008E2400248F8500240F
74066+:10898000240D00083C010800A42D3FC63C0108004E
74067+:10899000A4203FDA0E000B83000000009228003C68
74068+:1089A0008FBF00188FB100148FB000100008614213
74069+:1089B000AF82002C27BD002003E0000831820001B7
74070+:1089C0008C8A00088C8B00248CD000643C0E8000C4
74071+:1089D00035D10A00014B2823AF900024A380001C4E
74072+:1089E000AF8500288E2400248F8600208F850024E8
74073+:1089F000240D00083C010800A42D3FC63C010800DE
74074+:108A0000A4203FDA0E000B83000000009228003CF7
74075+:108A10008FBF00188FB100148FB0001000086142A2
74076+:108A2000AF82002C27BD002003E000083182000146
74077+:108A300090A200303051003F5224002834C50AC0B3
74078+:108A40008CB000241600002234CB09008CA600480C
74079+:108A50003C0A7FFF3545FFFF00C510243C0E800017
74080+:108A6000AF82002035C509008F8800208CAD0060E2
74081+:108A7000010D602B15800002010020218CA40060F4
74082+:108A80000A000C22AF8400208D02006C0A000BFC4F
74083+:108A90003C0680008C8200488F8600203C097FFFC6
74084+:108AA0003527FFFF004788243C0480082403000189
74085+:108AB000AF910028AC80006CA383001C0A000C302E
74086+:108AC000AF8600248C9F00140A000C22AF9F002068
74087+:108AD0008D6200680A000C6C3C0E800034C4098072
74088+:108AE0008C8900708CA300140123382B10E0000443
74089+:108AF000000000008C8200700A000C6C3C0E8000AC
74090+:108B00008CA200140A000C6C3C0E80008F8500249F
74091+:108B100027BDFFE0AFBF0018AFB1001414A00008DC
74092+:108B2000AFB000103C04800034870A0090E60030AB
74093+:108B30002402000530C3003F106200B934840900EC
74094+:108B40008F91002000A080213C048000348E0A0018
74095+:108B50008DCD00043C0608008CC63FB831A73FFF0E
74096+:108B600000E6602B5580000100E03021938F001C4F
74097+:108B700011E0007800D0282B349F098093F9007C05
74098+:108B800033380002130000792403003400C3102B93
74099+:108B9000144000D90000000000C3302300D0282B6F
74100+:108BA0003C010800A4233FC414A0006E0200182159
74101+:108BB0003C0408008C843FB40064402B5500000145
74102+:108BC000006020213C05800034A90A00912A003C65
74103+:108BD0003C010800AC243FBC31430020146000037A
74104+:108BE0000000482134AB0E008D6900188F88002CDE
74105+:108BF0000128202B1080005F000000003C050800C9
74106+:108C00008CA53FBC00A96821010D602B1180005C80
74107+:108C100000B0702B0109382300E028213C01080036
74108+:108C2000AC273FBC12000003240AFFFC10B0008DEB
74109+:108C30003224000300AA18243C010800A4203FDAD3
74110+:108C40003C010800AC233FBC006028218F84002435
74111+:108C5000120400063C0B80088D6C006C0200202181
74112+:108C6000AF91002025900001AD70006C8F8D002821
74113+:108C700000858823AF91002401A52023AF8400281C
74114+:108C80001220000224070018240700103C18800856
74115+:108C90003706008090CF00683C010800A0273FD82D
74116+:108CA0002407000131EE00FF11C70047000000005B
74117+:108CB00014800018000028213C06800034D109806F
74118+:108CC00034CD010091A600098E2C001824C40001A7
74119+:108CD000000C86023205007F308B007F1165007F1B
74120+:108CE0002407FF803C19800837290080A124004C0C
74121+:108CF0003C0808008D083FD4241800023C010800FD
74122+:108D0000A0384019350F00083C010800AC2F3FD4B3
74123+:108D1000240500103C02800034440A009083003C8B
74124+:108D2000307F002013E0000500A02021240A00016C
74125+:108D30003C010800AC2A3FBC34A400018FBF0018DE
74126+:108D40008FB100148FB000100080102103E00008E4
74127+:108D500027BD00203C010800A4203FC410A0FF94C0
74128+:108D6000020018210A000CC000C018210A000CB72C
74129+:108D7000240300303C0508008CA53FBC00B0702BDC
74130+:108D800011C0FFA8000000003C19080097393FC43B
74131+:108D90000325C0210307782B11E000072CAA00044B
74132+:108DA0003C0360008C625404305F003F17E0FFE337
74133+:108DB000240400422CAA00041140FF9A240400421B
74134+:108DC0000A000D248FBF00181528FFB9000000000D
74135+:108DD0008CCA00183C1F800024020002015F182585
74136+:108DE000ACC3001837F90A00A0C200689329003C00
74137+:108DF0002404000400A01021312800203C010800B8
74138+:108E0000A0244019110000022405001024020001D2
74139+:108E10003C010800AC223FB40A000D1A3C0280005D
74140+:108E20008F8800288C8900600109282B14A000027B
74141+:108E3000010088218C9100603C048000348B0E007E
74142+:108E40008D640018240A000102202821022030210C
74143+:108E5000A38A001C0E000B83022080210A000CA6AE
74144+:108E6000AF82002C00045823122000073164000355
74145+:108E70003C0E800035C7098090ED007C31AC0004C9
74146+:108E800015800019248F00043C010800A4243FDA57
74147+:108E90003C1F080097FF3FDA03E5C82100D9C02B2B
74148+:108EA0001300FF6B8F8400242CA6000514C0FFA3C1
74149+:108EB0002404004230A200031440000200A2182340
74150+:108EC00024A3FFFC3C010800AC233FBC3C0108008C
74151+:108ED000A4203FDA0A000CE70060282100C77024B4
74152+:108EE0000A000D0D01C720263C010800A42F3FDA1F
74153+:108EF0000A000D78000000003C010800AC203FBCD7
74154+:108F00000A000D23240400428F8300283C058000C2
74155+:108F100034AA0A00146000060000102191470030B6
74156+:108F20002406000530E400FF108600030000000066
74157+:108F300003E0000800000000914B0048316900FF89
74158+:108F4000000941C21500FFFA3C0680083C040800F5
74159+:108F500094843FC43C0308008C633FDC3C19080048
74160+:108F60008F393FBC3C0F080095EF3FDA0064C02109
74161+:108F70008CCD00040319702101CF602134AB0E00A9
74162+:108F8000018D282318A0001D00000000914F004C07
74163+:108F90008F8C0034956D001031EE00FF8D89000438
74164+:108FA00001AE30238D8A000030CEFFFF000E290075
74165+:108FB0000125C82100003821014720210325182B55
74166+:108FC0000083C021AD990004AD980000918F000A84
74167+:108FD00001CF6821A18D000A956500128F8A0034A7
74168+:108FE000A5450008954B003825690001A5490038C2
74169+:108FF0009148000D35070008A147000D03E0000867
74170+:109000000000000027BDFFD8AFB000189388001CF7
74171+:109010008FB000143C0A80003C197FFF8F8700242A
74172+:109020003738FFFFAFBF0020AFB1001C355F0A002B
74173+:109030000218182493EB003C00087FC03C02BFFFDD
74174+:10904000006F60252CF000013449FFFF3C1F080031
74175+:109050008FFF3FDC8F9900303C18080097183FD2F3
74176+:1090600001897824001047803C07EFFF3C05F0FFA2
74177+:1090700001E818253C1180003169002034E2FFFF2F
74178+:1090800034ADFFFF362E098027A50010240600020C
74179+:1090900003F96023270B0002354A0E0000621824F2
74180+:1090A0000080802115200002000040218D48001C16
74181+:1090B000A7AB0012058000392407000030E800FF4C
74182+:1090C00000083F00006758253C028008AFAB001441
74183+:1090D000344F008091EA00683C08080091083FD9AD
74184+:1090E0003C09DFFF352CFFFF000AF82B3C0208008B
74185+:1090F00094423FCCA3A80011016CC024001FCF40B4
74186+:10910000031918258FA70010AFA300143C0C08000A
74187+:10911000918C3FDBA7A200168FAB001400ED482412
74188+:109120003C0F01003C0A0FFF012FC82531980003B6
74189+:10913000355FFFFF016D40243C027000033F38247F
74190+:1091400000181E0000E2482501037825AFAF001487
74191+:10915000AFA9001091CC007C0E000092A3AC0015CA
74192+:10916000362D0A0091A6003C30C400201080000675
74193+:10917000260200083C11080096313FC8262EFFFF4A
74194+:109180003C010800A42E3FC88FBF00208FB1001CF7
74195+:109190008FB0001803E0000827BD00288F8B002C3B
74196+:1091A000010B502B5540FFC5240700010A000E0497
74197+:1091B00030E800FF9383001C3C02800027BDFFD8ED
74198+:1091C00034480A0000805021AFBF002034460AC056
74199+:1091D000010028211060000E3444098091070030FE
74200+:1091E000240B00058F89002030EC003F118B000B11
74201+:1091F00000003821AFA900103C0B80088D69006C7D
74202+:10920000AFAA00180E00015AAFA90014A380001CD9
74203+:109210008FBF002003E0000827BD00288D1F0048F5
74204+:109220003C1808008F183FBC8F9900283C027FFF34
74205+:109230008D0800443443FFFFAFA900103C0B8008A9
74206+:109240008D69006C03E370240319782101CF682332
74207+:1092500001A83821AFAA00180E00015AAFA90014C6
74208+:109260000A000E58A380001C3C05800034A60A00AA
74209+:1092700090C7003C3C06080094C63FDA3C02080058
74210+:109280008C423FD430E30020000624001060001E12
74211+:10929000004438253C0880083505008090A300680C
74212+:1092A00000004821240800010000282124040001B6
74213+:1092B0003C0680008CCD017805A0FFFE34CF014034
74214+:1092C000ADE800083C0208008C423FDCA5E5000444
74215+:1092D000A5E40006ADE2000C3C04080090843FD9F0
74216+:1092E0003C03800834790080A1E40012ADE700144B
74217+:1092F000A5E900189338004C3C0E1000A1F8002D91
74218+:1093000003E00008ACCE017834A90E008D28001CC3
74219+:109310003C0C08008D8C3FBC952B0016952A001440
74220+:10932000018648213164FFFF0A000E803145FFFFAE
74221+:109330003C04800034830A009065003C30A2002089
74222+:109340001040001934870E00000040210000382131
74223+:10935000000020213C0680008CC901780520FFFE1A
74224+:1093600034CA014034CF010091EB0009AD48000838
74225+:109370003C0E08008DCE3FDC240DFF91240C0040F4
74226+:109380003C081000A5440004A5470006AD4E000CA3
74227+:10939000A14D0012AD4C0014A5400018A14B002DAA
74228+:1093A00003E00008ACC801788CE8001894E60012CD
74229+:1093B00094E4001030C7FFFF0A000EA93084FFFFBD
74230+:1093C0003C04800034830A009065003C30A20020F9
74231+:1093D0001040002727BDFFF82409000100003821B4
74232+:1093E000240800013C0680008CCA01780540FFFE7D
74233+:1093F0003C0280FF34C40100908D00093C0C080041
74234+:10940000918C4019A3AD00038FAB00003185007F24
74235+:109410003459FFFF01665025AFAA00009083000A6F
74236+:10942000A3A0000200057E00A3A300018FB80000E6
74237+:1094300034CB0140240C30000319702401CF68257F
74238+:10944000AD6D000C27BD0008AD6C0014A5600018C0
74239+:10945000AD690008A56700042409FF80A56800061F
74240+:109460003C081000A169001203E00008ACC80178B4
74241+:1094700034870E008CE9001894E6001294E4001082
74242+:1094800030C8FFFF0A000ECD3087FFFF27BDFFE089
74243+:10949000AFB100143C118000AFB00010AFBF001896
74244+:1094A00036380A00970F0032363001000E000B7F6D
74245+:1094B00031E43FFF8E0E0000240DFF803C042000AD
74246+:1094C00001C25821016D6024000C4940316A007FBF
74247+:1094D000012A4025010438253C048008AE270830C5
74248+:1094E0003486008090C500682403000230A200FF8B
74249+:1094F000104300048F9F00208F990024AC9F0068C8
74250+:10950000AC9900648FBF00188FB100148FB00010A9
74251+:1095100003E0000827BD00203C0A0800254A3A80E5
74252+:109520003C09080025293B103C08080025082F1C91
74253+:109530003C07080024E73BDC3C06080024C639044D
74254+:109540003C05080024A536583C0408002484325CFD
74255+:109550003C030800246339B83C0208002442375415
74256+:109560003C010800AC2A3F983C010800AC293F941C
74257+:109570003C010800AC283F903C010800AC273F9C10
74258+:109580003C010800AC263FAC3C010800AC253FA4E0
74259+:109590003C010800AC243FA03C010800AC233FB0D4
74260+:1095A0003C010800AC223FA803E0000800000000D6
74261+:1095B00080000940800009008008010080080080C8
74262+:1095C00080080000800E00008008008080080000F5
74263+:1095D00080000A8080000A00800009808000090065
74264+:00000001FF
74265diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
74266index 2d0cbbd..a6d6149 100644
74267--- a/fs/Kconfig.binfmt
74268+++ b/fs/Kconfig.binfmt
74269@@ -103,7 +103,7 @@ config HAVE_AOUT
74270
74271 config BINFMT_AOUT
74272 tristate "Kernel support for a.out and ECOFF binaries"
74273- depends on HAVE_AOUT
74274+ depends on HAVE_AOUT && BROKEN
74275 ---help---
74276 A.out (Assembler.OUTput) is a set of formats for libraries and
74277 executables used in the earliest versions of UNIX. Linux used
74278diff --git a/fs/afs/inode.c b/fs/afs/inode.c
74279index e06f5a2..81d07ac 100644
74280--- a/fs/afs/inode.c
74281+++ b/fs/afs/inode.c
74282@@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
74283 struct afs_vnode *vnode;
74284 struct super_block *sb;
74285 struct inode *inode;
74286- static atomic_t afs_autocell_ino;
74287+ static atomic_unchecked_t afs_autocell_ino;
74288
74289 _enter("{%x:%u},%*.*s,",
74290 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
74291@@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
74292 data.fid.unique = 0;
74293 data.fid.vnode = 0;
74294
74295- inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
74296+ inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
74297 afs_iget5_autocell_test, afs_iget5_set,
74298 &data);
74299 if (!inode) {
74300diff --git a/fs/aio.c b/fs/aio.c
74301index 480440f..623fd88 100644
74302--- a/fs/aio.c
74303+++ b/fs/aio.c
74304@@ -441,7 +441,7 @@ static int aio_setup_ring(struct kioctx *ctx)
74305 size += sizeof(struct io_event) * nr_events;
74306
74307 nr_pages = PFN_UP(size);
74308- if (nr_pages < 0)
74309+ if (nr_pages <= 0)
74310 return -EINVAL;
74311
74312 file = aio_private_file(ctx, nr_pages);
74313diff --git a/fs/attr.c b/fs/attr.c
74314index 6530ced..4a827e2 100644
74315--- a/fs/attr.c
74316+++ b/fs/attr.c
74317@@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
74318 unsigned long limit;
74319
74320 limit = rlimit(RLIMIT_FSIZE);
74321+ gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
74322 if (limit != RLIM_INFINITY && offset > limit)
74323 goto out_sig;
74324 if (offset > inode->i_sb->s_maxbytes)
74325diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
74326index 35b755e..f4b9e0a 100644
74327--- a/fs/autofs4/waitq.c
74328+++ b/fs/autofs4/waitq.c
74329@@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
74330 {
74331 unsigned long sigpipe, flags;
74332 mm_segment_t fs;
74333- const char *data = (const char *)addr;
74334+ const char __user *data = (const char __force_user *)addr;
74335 ssize_t wr = 0;
74336
74337 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
74338@@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
74339 return 1;
74340 }
74341
74342+#ifdef CONFIG_GRKERNSEC_HIDESYM
74343+static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
74344+#endif
74345+
74346 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
74347 enum autofs_notify notify)
74348 {
74349@@ -385,7 +389,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
74350
74351 /* If this is a direct mount request create a dummy name */
74352 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
74353+#ifdef CONFIG_GRKERNSEC_HIDESYM
74354+ /* this name does get written to userland via autofs4_write() */
74355+ qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
74356+#else
74357 qstr.len = sprintf(name, "%p", dentry);
74358+#endif
74359 else {
74360 qstr.len = autofs4_getpath(sbi, dentry, &name);
74361 if (!qstr.len) {
74362diff --git a/fs/befs/endian.h b/fs/befs/endian.h
74363index 2722387..56059b5 100644
74364--- a/fs/befs/endian.h
74365+++ b/fs/befs/endian.h
74366@@ -11,7 +11,7 @@
74367
74368 #include <asm/byteorder.h>
74369
74370-static inline u64
74371+static inline u64 __intentional_overflow(-1)
74372 fs64_to_cpu(const struct super_block *sb, fs64 n)
74373 {
74374 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
74375@@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
74376 return (__force fs64)cpu_to_be64(n);
74377 }
74378
74379-static inline u32
74380+static inline u32 __intentional_overflow(-1)
74381 fs32_to_cpu(const struct super_block *sb, fs32 n)
74382 {
74383 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
74384@@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
74385 return (__force fs32)cpu_to_be32(n);
74386 }
74387
74388-static inline u16
74389+static inline u16 __intentional_overflow(-1)
74390 fs16_to_cpu(const struct super_block *sb, fs16 n)
74391 {
74392 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
74393diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
74394index 4c55668..eeae150 100644
74395--- a/fs/binfmt_aout.c
74396+++ b/fs/binfmt_aout.c
74397@@ -16,6 +16,7 @@
74398 #include <linux/string.h>
74399 #include <linux/fs.h>
74400 #include <linux/file.h>
74401+#include <linux/security.h>
74402 #include <linux/stat.h>
74403 #include <linux/fcntl.h>
74404 #include <linux/ptrace.h>
74405@@ -58,6 +59,8 @@ static int aout_core_dump(struct coredump_params *cprm)
74406 #endif
74407 # define START_STACK(u) ((void __user *)u.start_stack)
74408
74409+ memset(&dump, 0, sizeof(dump));
74410+
74411 fs = get_fs();
74412 set_fs(KERNEL_DS);
74413 has_dumped = 1;
74414@@ -68,10 +71,12 @@ static int aout_core_dump(struct coredump_params *cprm)
74415
74416 /* If the size of the dump file exceeds the rlimit, then see what would happen
74417 if we wrote the stack, but not the data area. */
74418+ gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
74419 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
74420 dump.u_dsize = 0;
74421
74422 /* Make sure we have enough room to write the stack and data areas. */
74423+ gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
74424 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
74425 dump.u_ssize = 0;
74426
74427@@ -232,6 +237,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
74428 rlim = rlimit(RLIMIT_DATA);
74429 if (rlim >= RLIM_INFINITY)
74430 rlim = ~0;
74431+
74432+ gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
74433 if (ex.a_data + ex.a_bss > rlim)
74434 return -ENOMEM;
74435
74436@@ -261,6 +268,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
74437
74438 install_exec_creds(bprm);
74439
74440+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74441+ current->mm->pax_flags = 0UL;
74442+#endif
74443+
74444+#ifdef CONFIG_PAX_PAGEEXEC
74445+ if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
74446+ current->mm->pax_flags |= MF_PAX_PAGEEXEC;
74447+
74448+#ifdef CONFIG_PAX_EMUTRAMP
74449+ if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
74450+ current->mm->pax_flags |= MF_PAX_EMUTRAMP;
74451+#endif
74452+
74453+#ifdef CONFIG_PAX_MPROTECT
74454+ if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
74455+ current->mm->pax_flags |= MF_PAX_MPROTECT;
74456+#endif
74457+
74458+ }
74459+#endif
74460+
74461 if (N_MAGIC(ex) == OMAGIC) {
74462 unsigned long text_addr, map_size;
74463 loff_t pos;
74464@@ -312,7 +340,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
74465 return error;
74466
74467 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
74468- PROT_READ | PROT_WRITE | PROT_EXEC,
74469+ PROT_READ | PROT_WRITE,
74470 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
74471 fd_offset + ex.a_text);
74472 if (error != N_DATADDR(ex))
74473diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
74474index 6b65996..17bd3c4 100644
74475--- a/fs/binfmt_elf.c
74476+++ b/fs/binfmt_elf.c
74477@@ -35,6 +35,7 @@
74478 #include <linux/utsname.h>
74479 #include <linux/coredump.h>
74480 #include <linux/sched.h>
74481+#include <linux/xattr.h>
74482 #include <asm/uaccess.h>
74483 #include <asm/param.h>
74484 #include <asm/page.h>
74485@@ -66,6 +67,14 @@ static int elf_core_dump(struct coredump_params *cprm);
74486 #define elf_core_dump NULL
74487 #endif
74488
74489+#ifdef CONFIG_PAX_MPROTECT
74490+static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
74491+#endif
74492+
74493+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
74494+static void elf_handle_mmap(struct file *file);
74495+#endif
74496+
74497 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
74498 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
74499 #else
74500@@ -85,6 +94,15 @@ static struct linux_binfmt elf_format = {
74501 .load_binary = load_elf_binary,
74502 .load_shlib = load_elf_library,
74503 .core_dump = elf_core_dump,
74504+
74505+#ifdef CONFIG_PAX_MPROTECT
74506+ .handle_mprotect= elf_handle_mprotect,
74507+#endif
74508+
74509+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
74510+ .handle_mmap = elf_handle_mmap,
74511+#endif
74512+
74513 .min_coredump = ELF_EXEC_PAGESIZE,
74514 };
74515
74516@@ -92,6 +110,8 @@ static struct linux_binfmt elf_format = {
74517
74518 static int set_brk(unsigned long start, unsigned long end)
74519 {
74520+ unsigned long e = end;
74521+
74522 start = ELF_PAGEALIGN(start);
74523 end = ELF_PAGEALIGN(end);
74524 if (end > start) {
74525@@ -100,7 +120,7 @@ static int set_brk(unsigned long start, unsigned long end)
74526 if (BAD_ADDR(addr))
74527 return addr;
74528 }
74529- current->mm->start_brk = current->mm->brk = end;
74530+ current->mm->start_brk = current->mm->brk = e;
74531 return 0;
74532 }
74533
74534@@ -161,12 +181,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
74535 elf_addr_t __user *u_rand_bytes;
74536 const char *k_platform = ELF_PLATFORM;
74537 const char *k_base_platform = ELF_BASE_PLATFORM;
74538- unsigned char k_rand_bytes[16];
74539+ u32 k_rand_bytes[4];
74540 int items;
74541 elf_addr_t *elf_info;
74542 int ei_index = 0;
74543 const struct cred *cred = current_cred();
74544 struct vm_area_struct *vma;
74545+ unsigned long saved_auxv[AT_VECTOR_SIZE];
74546
74547 /*
74548 * In some cases (e.g. Hyper-Threading), we want to avoid L1
74549@@ -208,8 +229,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
74550 * Generate 16 random bytes for userspace PRNG seeding.
74551 */
74552 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
74553- u_rand_bytes = (elf_addr_t __user *)
74554- STACK_ALLOC(p, sizeof(k_rand_bytes));
74555+ prandom_seed(k_rand_bytes[0] ^ prandom_u32());
74556+ prandom_seed(k_rand_bytes[1] ^ prandom_u32());
74557+ prandom_seed(k_rand_bytes[2] ^ prandom_u32());
74558+ prandom_seed(k_rand_bytes[3] ^ prandom_u32());
74559+ p = STACK_ROUND(p, sizeof(k_rand_bytes));
74560+ u_rand_bytes = (elf_addr_t __user *) p;
74561 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
74562 return -EFAULT;
74563
74564@@ -324,9 +349,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
74565 return -EFAULT;
74566 current->mm->env_end = p;
74567
74568+ memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
74569+
74570 /* Put the elf_info on the stack in the right place. */
74571 sp = (elf_addr_t __user *)envp + 1;
74572- if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
74573+ if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
74574 return -EFAULT;
74575 return 0;
74576 }
74577@@ -515,14 +542,14 @@ static inline int arch_check_elf(struct elfhdr *ehdr, bool has_interp,
74578 an ELF header */
74579
74580 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74581- struct file *interpreter, unsigned long *interp_map_addr,
74582+ struct file *interpreter,
74583 unsigned long no_base, struct elf_phdr *interp_elf_phdata)
74584 {
74585 struct elf_phdr *eppnt;
74586- unsigned long load_addr = 0;
74587+ unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
74588 int load_addr_set = 0;
74589 unsigned long last_bss = 0, elf_bss = 0;
74590- unsigned long error = ~0UL;
74591+ unsigned long error = -EINVAL;
74592 unsigned long total_size;
74593 int i;
74594
74595@@ -542,6 +569,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74596 goto out;
74597 }
74598
74599+#ifdef CONFIG_PAX_SEGMEXEC
74600+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
74601+ pax_task_size = SEGMEXEC_TASK_SIZE;
74602+#endif
74603+
74604 eppnt = interp_elf_phdata;
74605 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
74606 if (eppnt->p_type == PT_LOAD) {
74607@@ -565,8 +597,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74608 map_addr = elf_map(interpreter, load_addr + vaddr,
74609 eppnt, elf_prot, elf_type, total_size);
74610 total_size = 0;
74611- if (!*interp_map_addr)
74612- *interp_map_addr = map_addr;
74613 error = map_addr;
74614 if (BAD_ADDR(map_addr))
74615 goto out;
74616@@ -585,8 +615,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74617 k = load_addr + eppnt->p_vaddr;
74618 if (BAD_ADDR(k) ||
74619 eppnt->p_filesz > eppnt->p_memsz ||
74620- eppnt->p_memsz > TASK_SIZE ||
74621- TASK_SIZE - eppnt->p_memsz < k) {
74622+ eppnt->p_memsz > pax_task_size ||
74623+ pax_task_size - eppnt->p_memsz < k) {
74624 error = -ENOMEM;
74625 goto out;
74626 }
74627@@ -625,9 +655,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
74628 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
74629
74630 /* Map the last of the bss segment */
74631- error = vm_brk(elf_bss, last_bss - elf_bss);
74632- if (BAD_ADDR(error))
74633- goto out;
74634+ if (last_bss > elf_bss) {
74635+ error = vm_brk(elf_bss, last_bss - elf_bss);
74636+ if (BAD_ADDR(error))
74637+ goto out;
74638+ }
74639 }
74640
74641 error = load_addr;
74642@@ -635,6 +667,336 @@ out:
74643 return error;
74644 }
74645
74646+#ifdef CONFIG_PAX_PT_PAX_FLAGS
74647+#ifdef CONFIG_PAX_SOFTMODE
74648+static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
74649+{
74650+ unsigned long pax_flags = 0UL;
74651+
74652+#ifdef CONFIG_PAX_PAGEEXEC
74653+ if (elf_phdata->p_flags & PF_PAGEEXEC)
74654+ pax_flags |= MF_PAX_PAGEEXEC;
74655+#endif
74656+
74657+#ifdef CONFIG_PAX_SEGMEXEC
74658+ if (elf_phdata->p_flags & PF_SEGMEXEC)
74659+ pax_flags |= MF_PAX_SEGMEXEC;
74660+#endif
74661+
74662+#ifdef CONFIG_PAX_EMUTRAMP
74663+ if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
74664+ pax_flags |= MF_PAX_EMUTRAMP;
74665+#endif
74666+
74667+#ifdef CONFIG_PAX_MPROTECT
74668+ if (elf_phdata->p_flags & PF_MPROTECT)
74669+ pax_flags |= MF_PAX_MPROTECT;
74670+#endif
74671+
74672+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
74673+ if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
74674+ pax_flags |= MF_PAX_RANDMMAP;
74675+#endif
74676+
74677+ return pax_flags;
74678+}
74679+#endif
74680+
74681+static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
74682+{
74683+ unsigned long pax_flags = 0UL;
74684+
74685+#ifdef CONFIG_PAX_PAGEEXEC
74686+ if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
74687+ pax_flags |= MF_PAX_PAGEEXEC;
74688+#endif
74689+
74690+#ifdef CONFIG_PAX_SEGMEXEC
74691+ if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
74692+ pax_flags |= MF_PAX_SEGMEXEC;
74693+#endif
74694+
74695+#ifdef CONFIG_PAX_EMUTRAMP
74696+ if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
74697+ pax_flags |= MF_PAX_EMUTRAMP;
74698+#endif
74699+
74700+#ifdef CONFIG_PAX_MPROTECT
74701+ if (!(elf_phdata->p_flags & PF_NOMPROTECT))
74702+ pax_flags |= MF_PAX_MPROTECT;
74703+#endif
74704+
74705+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
74706+ if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
74707+ pax_flags |= MF_PAX_RANDMMAP;
74708+#endif
74709+
74710+ return pax_flags;
74711+}
74712+#endif
74713+
74714+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
74715+#ifdef CONFIG_PAX_SOFTMODE
74716+static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
74717+{
74718+ unsigned long pax_flags = 0UL;
74719+
74720+#ifdef CONFIG_PAX_PAGEEXEC
74721+ if (pax_flags_softmode & MF_PAX_PAGEEXEC)
74722+ pax_flags |= MF_PAX_PAGEEXEC;
74723+#endif
74724+
74725+#ifdef CONFIG_PAX_SEGMEXEC
74726+ if (pax_flags_softmode & MF_PAX_SEGMEXEC)
74727+ pax_flags |= MF_PAX_SEGMEXEC;
74728+#endif
74729+
74730+#ifdef CONFIG_PAX_EMUTRAMP
74731+ if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
74732+ pax_flags |= MF_PAX_EMUTRAMP;
74733+#endif
74734+
74735+#ifdef CONFIG_PAX_MPROTECT
74736+ if (pax_flags_softmode & MF_PAX_MPROTECT)
74737+ pax_flags |= MF_PAX_MPROTECT;
74738+#endif
74739+
74740+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
74741+ if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
74742+ pax_flags |= MF_PAX_RANDMMAP;
74743+#endif
74744+
74745+ return pax_flags;
74746+}
74747+#endif
74748+
74749+static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
74750+{
74751+ unsigned long pax_flags = 0UL;
74752+
74753+#ifdef CONFIG_PAX_PAGEEXEC
74754+ if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
74755+ pax_flags |= MF_PAX_PAGEEXEC;
74756+#endif
74757+
74758+#ifdef CONFIG_PAX_SEGMEXEC
74759+ if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
74760+ pax_flags |= MF_PAX_SEGMEXEC;
74761+#endif
74762+
74763+#ifdef CONFIG_PAX_EMUTRAMP
74764+ if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
74765+ pax_flags |= MF_PAX_EMUTRAMP;
74766+#endif
74767+
74768+#ifdef CONFIG_PAX_MPROTECT
74769+ if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
74770+ pax_flags |= MF_PAX_MPROTECT;
74771+#endif
74772+
74773+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
74774+ if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
74775+ pax_flags |= MF_PAX_RANDMMAP;
74776+#endif
74777+
74778+ return pax_flags;
74779+}
74780+#endif
74781+
74782+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74783+static unsigned long pax_parse_defaults(void)
74784+{
74785+ unsigned long pax_flags = 0UL;
74786+
74787+#ifdef CONFIG_PAX_SOFTMODE
74788+ if (pax_softmode)
74789+ return pax_flags;
74790+#endif
74791+
74792+#ifdef CONFIG_PAX_PAGEEXEC
74793+ pax_flags |= MF_PAX_PAGEEXEC;
74794+#endif
74795+
74796+#ifdef CONFIG_PAX_SEGMEXEC
74797+ pax_flags |= MF_PAX_SEGMEXEC;
74798+#endif
74799+
74800+#ifdef CONFIG_PAX_MPROTECT
74801+ pax_flags |= MF_PAX_MPROTECT;
74802+#endif
74803+
74804+#ifdef CONFIG_PAX_RANDMMAP
74805+ if (randomize_va_space)
74806+ pax_flags |= MF_PAX_RANDMMAP;
74807+#endif
74808+
74809+ return pax_flags;
74810+}
74811+
74812+static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
74813+{
74814+ unsigned long pax_flags = PAX_PARSE_FLAGS_FALLBACK;
74815+
74816+#ifdef CONFIG_PAX_EI_PAX
74817+
74818+#ifdef CONFIG_PAX_SOFTMODE
74819+ if (pax_softmode)
74820+ return pax_flags;
74821+#endif
74822+
74823+ pax_flags = 0UL;
74824+
74825+#ifdef CONFIG_PAX_PAGEEXEC
74826+ if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
74827+ pax_flags |= MF_PAX_PAGEEXEC;
74828+#endif
74829+
74830+#ifdef CONFIG_PAX_SEGMEXEC
74831+ if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
74832+ pax_flags |= MF_PAX_SEGMEXEC;
74833+#endif
74834+
74835+#ifdef CONFIG_PAX_EMUTRAMP
74836+ if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
74837+ pax_flags |= MF_PAX_EMUTRAMP;
74838+#endif
74839+
74840+#ifdef CONFIG_PAX_MPROTECT
74841+ if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
74842+ pax_flags |= MF_PAX_MPROTECT;
74843+#endif
74844+
74845+#ifdef CONFIG_PAX_ASLR
74846+ if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
74847+ pax_flags |= MF_PAX_RANDMMAP;
74848+#endif
74849+
74850+#endif
74851+
74852+ return pax_flags;
74853+
74854+}
74855+
74856+static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
74857+{
74858+
74859+#ifdef CONFIG_PAX_PT_PAX_FLAGS
74860+ unsigned long i;
74861+
74862+ for (i = 0UL; i < elf_ex->e_phnum; i++)
74863+ if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
74864+ if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
74865+ ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
74866+ ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
74867+ ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
74868+ ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
74869+ return PAX_PARSE_FLAGS_FALLBACK;
74870+
74871+#ifdef CONFIG_PAX_SOFTMODE
74872+ if (pax_softmode)
74873+ return pax_parse_pt_pax_softmode(&elf_phdata[i]);
74874+ else
74875+#endif
74876+
74877+ return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
74878+ break;
74879+ }
74880+#endif
74881+
74882+ return PAX_PARSE_FLAGS_FALLBACK;
74883+}
74884+
74885+static unsigned long pax_parse_xattr_pax(struct file * const file)
74886+{
74887+
74888+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
74889+ ssize_t xattr_size, i;
74890+ unsigned char xattr_value[sizeof("pemrs") - 1];
74891+ unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
74892+
74893+ xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
74894+ if (xattr_size < 0 || xattr_size > sizeof xattr_value)
74895+ return PAX_PARSE_FLAGS_FALLBACK;
74896+
74897+ for (i = 0; i < xattr_size; i++)
74898+ switch (xattr_value[i]) {
74899+ default:
74900+ return PAX_PARSE_FLAGS_FALLBACK;
74901+
74902+#define parse_flag(option1, option2, flag) \
74903+ case option1: \
74904+ if (pax_flags_hardmode & MF_PAX_##flag) \
74905+ return PAX_PARSE_FLAGS_FALLBACK;\
74906+ pax_flags_hardmode |= MF_PAX_##flag; \
74907+ break; \
74908+ case option2: \
74909+ if (pax_flags_softmode & MF_PAX_##flag) \
74910+ return PAX_PARSE_FLAGS_FALLBACK;\
74911+ pax_flags_softmode |= MF_PAX_##flag; \
74912+ break;
74913+
74914+ parse_flag('p', 'P', PAGEEXEC);
74915+ parse_flag('e', 'E', EMUTRAMP);
74916+ parse_flag('m', 'M', MPROTECT);
74917+ parse_flag('r', 'R', RANDMMAP);
74918+ parse_flag('s', 'S', SEGMEXEC);
74919+
74920+#undef parse_flag
74921+ }
74922+
74923+ if (pax_flags_hardmode & pax_flags_softmode)
74924+ return PAX_PARSE_FLAGS_FALLBACK;
74925+
74926+#ifdef CONFIG_PAX_SOFTMODE
74927+ if (pax_softmode)
74928+ return pax_parse_xattr_pax_softmode(pax_flags_softmode);
74929+ else
74930+#endif
74931+
74932+ return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
74933+#else
74934+ return PAX_PARSE_FLAGS_FALLBACK;
74935+#endif
74936+
74937+}
74938+
74939+static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
74940+{
74941+ unsigned long pax_flags, ei_pax_flags, pt_pax_flags, xattr_pax_flags;
74942+
74943+ pax_flags = pax_parse_defaults();
74944+ ei_pax_flags = pax_parse_ei_pax(elf_ex);
74945+ pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
74946+ xattr_pax_flags = pax_parse_xattr_pax(file);
74947+
74948+ if (pt_pax_flags != PAX_PARSE_FLAGS_FALLBACK &&
74949+ xattr_pax_flags != PAX_PARSE_FLAGS_FALLBACK &&
74950+ pt_pax_flags != xattr_pax_flags)
74951+ return -EINVAL;
74952+ if (xattr_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
74953+ pax_flags = xattr_pax_flags;
74954+ else if (pt_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
74955+ pax_flags = pt_pax_flags;
74956+ else if (ei_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
74957+ pax_flags = ei_pax_flags;
74958+
74959+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
74960+ if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
74961+ if ((__supported_pte_mask & _PAGE_NX))
74962+ pax_flags &= ~MF_PAX_SEGMEXEC;
74963+ else
74964+ pax_flags &= ~MF_PAX_PAGEEXEC;
74965+ }
74966+#endif
74967+
74968+ if (0 > pax_check_flags(&pax_flags))
74969+ return -EINVAL;
74970+
74971+ current->mm->pax_flags = pax_flags;
74972+ return 0;
74973+}
74974+#endif
74975+
74976 /*
74977 * These are the functions used to load ELF style executables and shared
74978 * libraries. There is no binary dependent code anywhere else.
74979@@ -648,6 +1010,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
74980 {
74981 unsigned long random_variable = 0;
74982
74983+#ifdef CONFIG_PAX_RANDUSTACK
74984+ if (current->mm->pax_flags & MF_PAX_RANDMMAP)
74985+ return stack_top - current->mm->delta_stack;
74986+#endif
74987+
74988 if ((current->flags & PF_RANDOMIZE) &&
74989 !(current->personality & ADDR_NO_RANDOMIZE)) {
74990 random_variable = (unsigned long) get_random_int();
74991@@ -667,7 +1034,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
74992 unsigned long load_addr = 0, load_bias = 0;
74993 int load_addr_set = 0;
74994 char * elf_interpreter = NULL;
74995- unsigned long error;
74996+ unsigned long error = 0;
74997 struct elf_phdr *elf_ppnt, *elf_phdata, *interp_elf_phdata = NULL;
74998 unsigned long elf_bss, elf_brk;
74999 int retval, i;
75000@@ -682,6 +1049,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
75001 struct elfhdr interp_elf_ex;
75002 } *loc;
75003 struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE;
75004+ unsigned long pax_task_size;
75005
75006 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
75007 if (!loc) {
75008@@ -840,6 +1208,77 @@ static int load_elf_binary(struct linux_binprm *bprm)
75009 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
75010 may depend on the personality. */
75011 SET_PERSONALITY2(loc->elf_ex, &arch_state);
75012+
75013+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
75014+ current->mm->pax_flags = 0UL;
75015+#endif
75016+
75017+#ifdef CONFIG_PAX_DLRESOLVE
75018+ current->mm->call_dl_resolve = 0UL;
75019+#endif
75020+
75021+#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
75022+ current->mm->call_syscall = 0UL;
75023+#endif
75024+
75025+#ifdef CONFIG_PAX_ASLR
75026+ current->mm->delta_mmap = 0UL;
75027+ current->mm->delta_stack = 0UL;
75028+#endif
75029+
75030+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
75031+ if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
75032+ retval = -EINVAL;
75033+ goto out_free_dentry;
75034+ }
75035+#endif
75036+
75037+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
75038+ pax_set_initial_flags(bprm);
75039+#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
75040+ if (pax_set_initial_flags_func)
75041+ (pax_set_initial_flags_func)(bprm);
75042+#endif
75043+
75044+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
75045+ if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
75046+ current->mm->context.user_cs_limit = PAGE_SIZE;
75047+ current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
75048+ }
75049+#endif
75050+
75051+#ifdef CONFIG_PAX_SEGMEXEC
75052+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
75053+ current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
75054+ current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
75055+ pax_task_size = SEGMEXEC_TASK_SIZE;
75056+ current->mm->def_flags |= VM_NOHUGEPAGE;
75057+ } else
75058+#endif
75059+
75060+ pax_task_size = TASK_SIZE;
75061+
75062+#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
75063+ if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
75064+ set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
75065+ put_cpu();
75066+ }
75067+#endif
75068+
75069+#ifdef CONFIG_PAX_ASLR
75070+ if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
75071+ current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
75072+ current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
75073+ }
75074+#endif
75075+
75076+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
75077+ if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
75078+ executable_stack = EXSTACK_DISABLE_X;
75079+ current->personality &= ~READ_IMPLIES_EXEC;
75080+ } else
75081+#endif
75082+
75083 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
75084 current->personality |= READ_IMPLIES_EXEC;
75085
75086@@ -915,8 +1354,21 @@ static int load_elf_binary(struct linux_binprm *bprm)
75087 if (current->flags & PF_RANDOMIZE)
75088 load_bias += arch_mmap_rnd();
75089 load_bias = ELF_PAGESTART(load_bias);
75090- total_size = total_mapping_size(elf_phdata,
75091- loc->elf_ex.e_phnum);
75092+
75093+#ifdef CONFIG_PAX_RANDMMAP
75094+ /* PaX: randomize base address at the default exe base if requested */
75095+ if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
75096+#ifdef CONFIG_SPARC64
75097+ load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
75098+#else
75099+ load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
75100+#endif
75101+ load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
75102+ elf_flags |= MAP_FIXED;
75103+ }
75104+#endif
75105+
75106+ total_size = total_mapping_size(elf_phdata, loc->elf_ex.e_phnum);
75107 if (!total_size) {
75108 retval = -EINVAL;
75109 goto out_free_dentry;
75110@@ -952,9 +1404,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
75111 * allowed task size. Note that p_filesz must always be
75112 * <= p_memsz so it is only necessary to check p_memsz.
75113 */
75114- if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
75115- elf_ppnt->p_memsz > TASK_SIZE ||
75116- TASK_SIZE - elf_ppnt->p_memsz < k) {
75117+ if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
75118+ elf_ppnt->p_memsz > pax_task_size ||
75119+ pax_task_size - elf_ppnt->p_memsz < k) {
75120 /* set_brk can never work. Avoid overflows. */
75121 retval = -EINVAL;
75122 goto out_free_dentry;
75123@@ -990,16 +1442,43 @@ static int load_elf_binary(struct linux_binprm *bprm)
75124 if (retval)
75125 goto out_free_dentry;
75126 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
75127- retval = -EFAULT; /* Nobody gets to see this, but.. */
75128- goto out_free_dentry;
75129+ /*
75130+ * This bss-zeroing can fail if the ELF
75131+ * file specifies odd protections. So
75132+ * we don't check the return value
75133+ */
75134 }
75135
75136+#ifdef CONFIG_PAX_RANDMMAP
75137+ if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
75138+ unsigned long start, size, flags;
75139+ vm_flags_t vm_flags;
75140+
75141+ start = ELF_PAGEALIGN(elf_brk);
75142+ size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
75143+ flags = MAP_FIXED | MAP_PRIVATE;
75144+ vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
75145+
75146+ down_write(&current->mm->mmap_sem);
75147+ start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
75148+ retval = -ENOMEM;
75149+ if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
75150+// if (current->personality & ADDR_NO_RANDOMIZE)
75151+// vm_flags |= VM_READ | VM_MAYREAD;
75152+ start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
75153+ retval = IS_ERR_VALUE(start) ? start : 0;
75154+ }
75155+ up_write(&current->mm->mmap_sem);
75156+ if (retval == 0)
75157+ retval = set_brk(start + size, start + size + PAGE_SIZE);
75158+ if (retval < 0)
75159+ goto out_free_dentry;
75160+ }
75161+#endif
75162+
75163 if (elf_interpreter) {
75164- unsigned long interp_map_addr = 0;
75165-
75166 elf_entry = load_elf_interp(&loc->interp_elf_ex,
75167 interpreter,
75168- &interp_map_addr,
75169 load_bias, interp_elf_phdata);
75170 if (!IS_ERR((void *)elf_entry)) {
75171 /*
75172@@ -1050,6 +1529,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
75173 current->mm->end_data = end_data;
75174 current->mm->start_stack = bprm->p;
75175
75176+#ifndef CONFIG_PAX_RANDMMAP
75177 if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1)) {
75178 current->mm->brk = current->mm->start_brk =
75179 arch_randomize_brk(current->mm);
75180@@ -1057,6 +1537,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
75181 current->brk_randomized = 1;
75182 #endif
75183 }
75184+#endif
75185
75186 if (current->personality & MMAP_PAGE_ZERO) {
75187 /* Why this, you ask??? Well SVr4 maps page 0 as read-only,
75188@@ -1225,7 +1706,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
75189 * Decide what to dump of a segment, part, all or none.
75190 */
75191 static unsigned long vma_dump_size(struct vm_area_struct *vma,
75192- unsigned long mm_flags)
75193+ unsigned long mm_flags, long signr)
75194 {
75195 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
75196
75197@@ -1263,7 +1744,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
75198 if (vma->vm_file == NULL)
75199 return 0;
75200
75201- if (FILTER(MAPPED_PRIVATE))
75202+ if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
75203 goto whole;
75204
75205 /*
75206@@ -1363,7 +1844,7 @@ static void fill_elf_header(struct elfhdr *elf, int segs,
75207 return;
75208 }
75209
75210-static void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, loff_t offset)
75211+static void fill_elf_note_phdr(struct elf_phdr *phdr, size_t sz, loff_t offset)
75212 {
75213 phdr->p_type = PT_NOTE;
75214 phdr->p_offset = offset;
75215@@ -1470,9 +1951,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
75216 {
75217 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
75218 int i = 0;
75219- do
75220+ do {
75221 i += 2;
75222- while (auxv[i - 2] != AT_NULL);
75223+ } while (auxv[i - 2] != AT_NULL);
75224 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
75225 }
75226
75227@@ -1481,7 +1962,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
75228 {
75229 mm_segment_t old_fs = get_fs();
75230 set_fs(KERNEL_DS);
75231- copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
75232+ copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
75233 set_fs(old_fs);
75234 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
75235 }
75236@@ -2201,7 +2682,7 @@ static int elf_core_dump(struct coredump_params *cprm)
75237 vma = next_vma(vma, gate_vma)) {
75238 unsigned long dump_size;
75239
75240- dump_size = vma_dump_size(vma, cprm->mm_flags);
75241+ dump_size = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
75242 vma_filesz[i++] = dump_size;
75243 vma_data_size += dump_size;
75244 }
75245@@ -2309,6 +2790,167 @@ out:
75246
75247 #endif /* CONFIG_ELF_CORE */
75248
75249+#ifdef CONFIG_PAX_MPROTECT
75250+/* PaX: non-PIC ELF libraries need relocations on their executable segments
75251+ * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
75252+ * we'll remove VM_MAYWRITE for good on RELRO segments.
75253+ *
75254+ * The checks favour ld-linux.so behaviour which operates on a per ELF segment
75255+ * basis because we want to allow the common case and not the special ones.
75256+ */
75257+static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
75258+{
75259+ struct elfhdr elf_h;
75260+ struct elf_phdr elf_p;
75261+ unsigned long i;
75262+ unsigned long oldflags;
75263+ bool is_textrel_rw, is_textrel_rx, is_relro;
75264+
75265+ if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
75266+ return;
75267+
75268+ oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
75269+ newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
75270+
75271+#ifdef CONFIG_PAX_ELFRELOCS
75272+ /* possible TEXTREL */
75273+ is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
75274+ is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
75275+#else
75276+ is_textrel_rw = false;
75277+ is_textrel_rx = false;
75278+#endif
75279+
75280+ /* possible RELRO */
75281+ is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
75282+
75283+ if (!is_textrel_rw && !is_textrel_rx && !is_relro)
75284+ return;
75285+
75286+ if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
75287+ memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
75288+
75289+#ifdef CONFIG_PAX_ETEXECRELOCS
75290+ ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
75291+#else
75292+ ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
75293+#endif
75294+
75295+ (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
75296+ !elf_check_arch(&elf_h) ||
75297+ elf_h.e_phentsize != sizeof(struct elf_phdr) ||
75298+ elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
75299+ return;
75300+
75301+ for (i = 0UL; i < elf_h.e_phnum; i++) {
75302+ if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
75303+ return;
75304+ switch (elf_p.p_type) {
75305+ case PT_DYNAMIC:
75306+ if (!is_textrel_rw && !is_textrel_rx)
75307+ continue;
75308+ i = 0UL;
75309+ while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
75310+ elf_dyn dyn;
75311+
75312+ if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
75313+ break;
75314+ if (dyn.d_tag == DT_NULL)
75315+ break;
75316+ if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
75317+ gr_log_textrel(vma, is_textrel_rw);
75318+ if (is_textrel_rw)
75319+ vma->vm_flags |= VM_MAYWRITE;
75320+ else
75321+ /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
75322+ vma->vm_flags &= ~VM_MAYWRITE;
75323+ break;
75324+ }
75325+ i++;
75326+ }
75327+ is_textrel_rw = false;
75328+ is_textrel_rx = false;
75329+ continue;
75330+
75331+ case PT_GNU_RELRO:
75332+ if (!is_relro)
75333+ continue;
75334+ if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
75335+ vma->vm_flags &= ~VM_MAYWRITE;
75336+ is_relro = false;
75337+ continue;
75338+
75339+#ifdef CONFIG_PAX_PT_PAX_FLAGS
75340+ case PT_PAX_FLAGS: {
75341+ const char *msg_mprotect = "", *msg_emutramp = "";
75342+ char *buffer_lib, *buffer_exe;
75343+
75344+ if (elf_p.p_flags & PF_NOMPROTECT)
75345+ msg_mprotect = "MPROTECT disabled";
75346+
75347+#ifdef CONFIG_PAX_EMUTRAMP
75348+ if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
75349+ msg_emutramp = "EMUTRAMP enabled";
75350+#endif
75351+
75352+ if (!msg_mprotect[0] && !msg_emutramp[0])
75353+ continue;
75354+
75355+ if (!printk_ratelimit())
75356+ continue;
75357+
75358+ buffer_lib = (char *)__get_free_page(GFP_KERNEL);
75359+ buffer_exe = (char *)__get_free_page(GFP_KERNEL);
75360+ if (buffer_lib && buffer_exe) {
75361+ char *path_lib, *path_exe;
75362+
75363+ path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
75364+ path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
75365+
75366+ pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
75367+ (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
75368+
75369+ }
75370+ free_page((unsigned long)buffer_exe);
75371+ free_page((unsigned long)buffer_lib);
75372+ continue;
75373+ }
75374+#endif
75375+
75376+ }
75377+ }
75378+}
75379+#endif
75380+
75381+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
75382+
75383+extern int grsec_enable_log_rwxmaps;
75384+
75385+static void elf_handle_mmap(struct file *file)
75386+{
75387+ struct elfhdr elf_h;
75388+ struct elf_phdr elf_p;
75389+ unsigned long i;
75390+
75391+ if (!grsec_enable_log_rwxmaps)
75392+ return;
75393+
75394+ if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
75395+ memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
75396+ (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
75397+ elf_h.e_phentsize != sizeof(struct elf_phdr) ||
75398+ elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
75399+ return;
75400+
75401+ for (i = 0UL; i < elf_h.e_phnum; i++) {
75402+ if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
75403+ return;
75404+ if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
75405+ gr_log_ptgnustack(file);
75406+ }
75407+}
75408+#endif
75409+
75410 static int __init init_elf_binfmt(void)
75411 {
75412 register_binfmt(&elf_format);
75413diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
75414index d3634bf..10fc244 100644
75415--- a/fs/binfmt_elf_fdpic.c
75416+++ b/fs/binfmt_elf_fdpic.c
75417@@ -1296,7 +1296,7 @@ static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs)
75418 return;
75419 }
75420
75421-static inline void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, loff_t offset)
75422+static inline void fill_elf_note_phdr(struct elf_phdr *phdr, size_t sz, loff_t offset)
75423 {
75424 phdr->p_type = PT_NOTE;
75425 phdr->p_offset = offset;
75426@@ -1667,7 +1667,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
75427
75428 /* Write notes phdr entry */
75429 {
75430- int sz = 0;
75431+ size_t sz = 0;
75432
75433 for (i = 0; i < numnote; i++)
75434 sz += notesize(notes + i);
75435diff --git a/fs/block_dev.c b/fs/block_dev.c
75436index 1170f8c..2a8acc1 100644
75437--- a/fs/block_dev.c
75438+++ b/fs/block_dev.c
75439@@ -738,7 +738,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
75440 else if (bdev->bd_contains == bdev)
75441 return true; /* is a whole device which isn't held */
75442
75443- else if (whole->bd_holder == bd_may_claim)
75444+ else if (whole->bd_holder == (void *)bd_may_claim)
75445 return true; /* is a partition of a device that is being partitioned */
75446 else if (whole->bd_holder != NULL)
75447 return false; /* is a partition of a held device */
75448diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
75449index 54114b4..580cfc9 100644
75450--- a/fs/btrfs/ctree.c
75451+++ b/fs/btrfs/ctree.c
75452@@ -1180,9 +1180,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
75453 free_extent_buffer(buf);
75454 add_root_to_dirty_list(root);
75455 } else {
75456- if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
75457- parent_start = parent->start;
75458- else
75459+ if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
75460+ if (parent)
75461+ parent_start = parent->start;
75462+ else
75463+ parent_start = 0;
75464+ } else
75465 parent_start = 0;
75466
75467 WARN_ON(trans->transid != btrfs_header_generation(parent));
75468diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
75469index a2ae427..53c2e98 100644
75470--- a/fs/btrfs/delayed-inode.c
75471+++ b/fs/btrfs/delayed-inode.c
75472@@ -462,7 +462,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
75473
75474 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
75475 {
75476- int seq = atomic_inc_return(&delayed_root->items_seq);
75477+ int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
75478 if ((atomic_dec_return(&delayed_root->items) <
75479 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
75480 waitqueue_active(&delayed_root->wait))
75481@@ -1412,7 +1412,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
75482
75483 static int could_end_wait(struct btrfs_delayed_root *delayed_root, int seq)
75484 {
75485- int val = atomic_read(&delayed_root->items_seq);
75486+ int val = atomic_read_unchecked(&delayed_root->items_seq);
75487
75488 if (val < seq || val >= seq + BTRFS_DELAYED_BATCH)
75489 return 1;
75490@@ -1437,7 +1437,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
75491 int seq;
75492 int ret;
75493
75494- seq = atomic_read(&delayed_root->items_seq);
75495+ seq = atomic_read_unchecked(&delayed_root->items_seq);
75496
75497 ret = btrfs_wq_run_delayed_node(delayed_root, fs_info, 0);
75498 if (ret)
75499diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
75500index f70119f..ab5894d 100644
75501--- a/fs/btrfs/delayed-inode.h
75502+++ b/fs/btrfs/delayed-inode.h
75503@@ -43,7 +43,7 @@ struct btrfs_delayed_root {
75504 */
75505 struct list_head prepare_list;
75506 atomic_t items; /* for delayed items */
75507- atomic_t items_seq; /* for delayed items */
75508+ atomic_unchecked_t items_seq; /* for delayed items */
75509 int nodes; /* for delayed nodes */
75510 wait_queue_head_t wait;
75511 };
75512@@ -90,7 +90,7 @@ static inline void btrfs_init_delayed_root(
75513 struct btrfs_delayed_root *delayed_root)
75514 {
75515 atomic_set(&delayed_root->items, 0);
75516- atomic_set(&delayed_root->items_seq, 0);
75517+ atomic_set_unchecked(&delayed_root->items_seq, 0);
75518 delayed_root->nodes = 0;
75519 spin_lock_init(&delayed_root->lock);
75520 init_waitqueue_head(&delayed_root->wait);
75521diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
75522index cd7ef34..1e31ae3 100644
75523--- a/fs/btrfs/super.c
75524+++ b/fs/btrfs/super.c
75525@@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
75526 function, line, errstr);
75527 return;
75528 }
75529- ACCESS_ONCE(trans->transaction->aborted) = errno;
75530+ ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
75531 /* Wake up anybody who may be waiting on this transaction */
75532 wake_up(&root->fs_info->transaction_wait);
75533 wake_up(&root->fs_info->transaction_blocked_wait);
75534diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
75535index 603b0cc..8e3f600 100644
75536--- a/fs/btrfs/sysfs.c
75537+++ b/fs/btrfs/sysfs.c
75538@@ -481,7 +481,7 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
75539 for (set = 0; set < FEAT_MAX; set++) {
75540 int i;
75541 struct attribute *attrs[2];
75542- struct attribute_group agroup = {
75543+ attribute_group_no_const agroup = {
75544 .name = "features",
75545 .attrs = attrs,
75546 };
75547diff --git a/fs/btrfs/tests/free-space-tests.c b/fs/btrfs/tests/free-space-tests.c
75548index 2299bfd..4098e72 100644
75549--- a/fs/btrfs/tests/free-space-tests.c
75550+++ b/fs/btrfs/tests/free-space-tests.c
75551@@ -463,7 +463,9 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache)
75552 * extent entry.
75553 */
75554 use_bitmap_op = cache->free_space_ctl->op->use_bitmap;
75555- cache->free_space_ctl->op->use_bitmap = test_use_bitmap;
75556+ pax_open_kernel();
75557+ *(void **)&cache->free_space_ctl->op->use_bitmap = test_use_bitmap;
75558+ pax_close_kernel();
75559
75560 /*
75561 * Extent entry covering free space range [128Mb - 256Kb, 128Mb - 128Kb[
75562@@ -870,7 +872,9 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache)
75563 if (ret)
75564 return ret;
75565
75566- cache->free_space_ctl->op->use_bitmap = use_bitmap_op;
75567+ pax_open_kernel();
75568+ *(void **)&cache->free_space_ctl->op->use_bitmap = use_bitmap_op;
75569+ pax_close_kernel();
75570 __btrfs_remove_free_space_cache(cache->free_space_ctl);
75571
75572 return 0;
75573diff --git a/fs/btrfs/tree-log.h b/fs/btrfs/tree-log.h
75574index 6916a78..4598936 100644
75575--- a/fs/btrfs/tree-log.h
75576+++ b/fs/btrfs/tree-log.h
75577@@ -45,7 +45,7 @@ static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx)
75578 static inline void btrfs_set_log_full_commit(struct btrfs_fs_info *fs_info,
75579 struct btrfs_trans_handle *trans)
75580 {
75581- ACCESS_ONCE(fs_info->last_trans_log_full_commit) = trans->transid;
75582+ ACCESS_ONCE_RW(fs_info->last_trans_log_full_commit) = trans->transid;
75583 }
75584
75585 static inline int btrfs_need_log_full_commit(struct btrfs_fs_info *fs_info,
75586diff --git a/fs/buffer.c b/fs/buffer.c
75587index 1cf7a53..b49f8c0 100644
75588--- a/fs/buffer.c
75589+++ b/fs/buffer.c
75590@@ -3440,7 +3440,7 @@ void __init buffer_init(void)
75591 bh_cachep = kmem_cache_create("buffer_head",
75592 sizeof(struct buffer_head), 0,
75593 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
75594- SLAB_MEM_SPREAD),
75595+ SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
75596 NULL);
75597
75598 /*
75599diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
75600index 6af790f..ec4c1e6 100644
75601--- a/fs/cachefiles/bind.c
75602+++ b/fs/cachefiles/bind.c
75603@@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
75604 args);
75605
75606 /* start by checking things over */
75607- ASSERT(cache->fstop_percent >= 0 &&
75608- cache->fstop_percent < cache->fcull_percent &&
75609+ ASSERT(cache->fstop_percent < cache->fcull_percent &&
75610 cache->fcull_percent < cache->frun_percent &&
75611 cache->frun_percent < 100);
75612
75613- ASSERT(cache->bstop_percent >= 0 &&
75614- cache->bstop_percent < cache->bcull_percent &&
75615+ ASSERT(cache->bstop_percent < cache->bcull_percent &&
75616 cache->bcull_percent < cache->brun_percent &&
75617 cache->brun_percent < 100);
75618
75619diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
75620index f601def..b2cf704 100644
75621--- a/fs/cachefiles/daemon.c
75622+++ b/fs/cachefiles/daemon.c
75623@@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
75624 if (n > buflen)
75625 return -EMSGSIZE;
75626
75627- if (copy_to_user(_buffer, buffer, n) != 0)
75628+ if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
75629 return -EFAULT;
75630
75631 return n;
75632@@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
75633 if (test_bit(CACHEFILES_DEAD, &cache->flags))
75634 return -EIO;
75635
75636- if (datalen < 0 || datalen > PAGE_SIZE - 1)
75637+ if (datalen > PAGE_SIZE - 1)
75638 return -EOPNOTSUPP;
75639
75640 /* drag the command string into the kernel so we can parse it */
75641@@ -385,7 +385,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
75642 if (args[0] != '%' || args[1] != '\0')
75643 return -EINVAL;
75644
75645- if (fstop < 0 || fstop >= cache->fcull_percent)
75646+ if (fstop >= cache->fcull_percent)
75647 return cachefiles_daemon_range_error(cache, args);
75648
75649 cache->fstop_percent = fstop;
75650@@ -457,7 +457,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
75651 if (args[0] != '%' || args[1] != '\0')
75652 return -EINVAL;
75653
75654- if (bstop < 0 || bstop >= cache->bcull_percent)
75655+ if (bstop >= cache->bcull_percent)
75656 return cachefiles_daemon_range_error(cache, args);
75657
75658 cache->bstop_percent = bstop;
75659diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
75660index aecd085..3584e2f 100644
75661--- a/fs/cachefiles/internal.h
75662+++ b/fs/cachefiles/internal.h
75663@@ -65,7 +65,7 @@ struct cachefiles_cache {
75664 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
75665 struct rb_root active_nodes; /* active nodes (can't be culled) */
75666 rwlock_t active_lock; /* lock for active_nodes */
75667- atomic_t gravecounter; /* graveyard uniquifier */
75668+ atomic_unchecked_t gravecounter; /* graveyard uniquifier */
75669 unsigned frun_percent; /* when to stop culling (% files) */
75670 unsigned fcull_percent; /* when to start culling (% files) */
75671 unsigned fstop_percent; /* when to stop allocating (% files) */
75672@@ -177,19 +177,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
75673 * proc.c
75674 */
75675 #ifdef CONFIG_CACHEFILES_HISTOGRAM
75676-extern atomic_t cachefiles_lookup_histogram[HZ];
75677-extern atomic_t cachefiles_mkdir_histogram[HZ];
75678-extern atomic_t cachefiles_create_histogram[HZ];
75679+extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
75680+extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
75681+extern atomic_unchecked_t cachefiles_create_histogram[HZ];
75682
75683 extern int __init cachefiles_proc_init(void);
75684 extern void cachefiles_proc_cleanup(void);
75685 static inline
75686-void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
75687+void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
75688 {
75689 unsigned long jif = jiffies - start_jif;
75690 if (jif >= HZ)
75691 jif = HZ - 1;
75692- atomic_inc(&histogram[jif]);
75693+ atomic_inc_unchecked(&histogram[jif]);
75694 }
75695
75696 #else
75697diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
75698index fc1056f..501a546 100644
75699--- a/fs/cachefiles/namei.c
75700+++ b/fs/cachefiles/namei.c
75701@@ -312,7 +312,7 @@ try_again:
75702 /* first step is to make up a grave dentry in the graveyard */
75703 sprintf(nbuffer, "%08x%08x",
75704 (uint32_t) get_seconds(),
75705- (uint32_t) atomic_inc_return(&cache->gravecounter));
75706+ (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
75707
75708 /* do the multiway lock magic */
75709 trap = lock_rename(cache->graveyard, dir);
75710diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
75711index eccd339..4c1d995 100644
75712--- a/fs/cachefiles/proc.c
75713+++ b/fs/cachefiles/proc.c
75714@@ -14,9 +14,9 @@
75715 #include <linux/seq_file.h>
75716 #include "internal.h"
75717
75718-atomic_t cachefiles_lookup_histogram[HZ];
75719-atomic_t cachefiles_mkdir_histogram[HZ];
75720-atomic_t cachefiles_create_histogram[HZ];
75721+atomic_unchecked_t cachefiles_lookup_histogram[HZ];
75722+atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
75723+atomic_unchecked_t cachefiles_create_histogram[HZ];
75724
75725 /*
75726 * display the latency histogram
75727@@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
75728 return 0;
75729 default:
75730 index = (unsigned long) v - 3;
75731- x = atomic_read(&cachefiles_lookup_histogram[index]);
75732- y = atomic_read(&cachefiles_mkdir_histogram[index]);
75733- z = atomic_read(&cachefiles_create_histogram[index]);
75734+ x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
75735+ y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
75736+ z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
75737 if (x == 0 && y == 0 && z == 0)
75738 return 0;
75739
75740diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
75741index 9314b4e..4a1f602 100644
75742--- a/fs/ceph/dir.c
75743+++ b/fs/ceph/dir.c
75744@@ -214,10 +214,18 @@ static int __dcache_readdir(struct file *file, struct dir_context *ctx,
75745 spin_unlock(&dentry->d_lock);
75746
75747 if (emit_dentry) {
75748+ char d_name[DNAME_INLINE_LEN];
75749+ const unsigned char *name;
75750+
75751 dout(" %llu (%llu) dentry %p %pd %p\n", di->offset, ctx->pos,
75752 dentry, dentry, d_inode(dentry));
75753 ctx->pos = di->offset;
75754- if (!dir_emit(ctx, dentry->d_name.name,
75755+ name = dentry->d_name.name;
75756+ if (name == dentry->d_iname) {
75757+ memcpy(d_name, name, dentry->d_name.len);
75758+ name = d_name;
75759+ }
75760+ if (!dir_emit(ctx, name,
75761 dentry->d_name.len,
75762 ceph_translate_ino(dentry->d_sb,
75763 d_inode(dentry)->i_ino),
75764@@ -259,7 +267,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
75765 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
75766 struct ceph_mds_client *mdsc = fsc->mdsc;
75767 unsigned frag = fpos_frag(ctx->pos);
75768- int off = fpos_off(ctx->pos);
75769+ unsigned int off = fpos_off(ctx->pos);
75770 int err;
75771 u32 ftype;
75772 struct ceph_mds_reply_info_parsed *rinfo;
75773diff --git a/fs/ceph/super.c b/fs/ceph/super.c
75774index 7b6bfcb..f8d5416 100644
75775--- a/fs/ceph/super.c
75776+++ b/fs/ceph/super.c
75777@@ -906,7 +906,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
75778 /*
75779 * construct our own bdi so we can control readahead, etc.
75780 */
75781-static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
75782+static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
75783
75784 static int ceph_register_bdi(struct super_block *sb,
75785 struct ceph_fs_client *fsc)
75786@@ -923,7 +923,7 @@ static int ceph_register_bdi(struct super_block *sb,
75787 VM_MAX_READAHEAD * 1024 / PAGE_CACHE_SIZE;
75788
75789 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
75790- atomic_long_inc_return(&bdi_seq));
75791+ atomic_long_inc_return_unchecked(&bdi_seq));
75792 if (!err)
75793 sb->s_bdi = &fsc->backing_dev_info;
75794 return err;
75795diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
75796index 7febcf2..62a5721 100644
75797--- a/fs/cifs/cifs_debug.c
75798+++ b/fs/cifs/cifs_debug.c
75799@@ -269,8 +269,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
75800
75801 if (strtobool(&c, &bv) == 0) {
75802 #ifdef CONFIG_CIFS_STATS2
75803- atomic_set(&totBufAllocCount, 0);
75804- atomic_set(&totSmBufAllocCount, 0);
75805+ atomic_set_unchecked(&totBufAllocCount, 0);
75806+ atomic_set_unchecked(&totSmBufAllocCount, 0);
75807 #endif /* CONFIG_CIFS_STATS2 */
75808 spin_lock(&cifs_tcp_ses_lock);
75809 list_for_each(tmp1, &cifs_tcp_ses_list) {
75810@@ -283,7 +283,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
75811 tcon = list_entry(tmp3,
75812 struct cifs_tcon,
75813 tcon_list);
75814- atomic_set(&tcon->num_smbs_sent, 0);
75815+ atomic_set_unchecked(&tcon->num_smbs_sent, 0);
75816 if (server->ops->clear_stats)
75817 server->ops->clear_stats(tcon);
75818 }
75819@@ -315,8 +315,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
75820 smBufAllocCount.counter, cifs_min_small);
75821 #ifdef CONFIG_CIFS_STATS2
75822 seq_printf(m, "Total Large %d Small %d Allocations\n",
75823- atomic_read(&totBufAllocCount),
75824- atomic_read(&totSmBufAllocCount));
75825+ atomic_read_unchecked(&totBufAllocCount),
75826+ atomic_read_unchecked(&totSmBufAllocCount));
75827 #endif /* CONFIG_CIFS_STATS2 */
75828
75829 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
75830@@ -345,7 +345,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
75831 if (tcon->need_reconnect)
75832 seq_puts(m, "\tDISCONNECTED ");
75833 seq_printf(m, "\nSMBs: %d",
75834- atomic_read(&tcon->num_smbs_sent));
75835+ atomic_read_unchecked(&tcon->num_smbs_sent));
75836 if (server->ops->print_stats)
75837 server->ops->print_stats(m, tcon);
75838 }
75839diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
75840index 6a1119e..b2f2160 100644
75841--- a/fs/cifs/cifsfs.c
75842+++ b/fs/cifs/cifsfs.c
75843@@ -1082,7 +1082,7 @@ cifs_init_request_bufs(void)
75844 */
75845 cifs_req_cachep = kmem_cache_create("cifs_request",
75846 CIFSMaxBufSize + max_hdr_size, 0,
75847- SLAB_HWCACHE_ALIGN, NULL);
75848+ SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
75849 if (cifs_req_cachep == NULL)
75850 return -ENOMEM;
75851
75852@@ -1109,7 +1109,7 @@ cifs_init_request_bufs(void)
75853 efficient to alloc 1 per page off the slab compared to 17K (5page)
75854 alloc of large cifs buffers even when page debugging is on */
75855 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
75856- MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
75857+ MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
75858 NULL);
75859 if (cifs_sm_req_cachep == NULL) {
75860 mempool_destroy(cifs_req_poolp);
75861@@ -1194,8 +1194,8 @@ init_cifs(void)
75862 atomic_set(&bufAllocCount, 0);
75863 atomic_set(&smBufAllocCount, 0);
75864 #ifdef CONFIG_CIFS_STATS2
75865- atomic_set(&totBufAllocCount, 0);
75866- atomic_set(&totSmBufAllocCount, 0);
75867+ atomic_set_unchecked(&totBufAllocCount, 0);
75868+ atomic_set_unchecked(&totSmBufAllocCount, 0);
75869 #endif /* CONFIG_CIFS_STATS2 */
75870
75871 atomic_set(&midCount, 0);
75872diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
75873index b406a32..243eb1c 100644
75874--- a/fs/cifs/cifsglob.h
75875+++ b/fs/cifs/cifsglob.h
75876@@ -832,35 +832,35 @@ struct cifs_tcon {
75877 __u16 Flags; /* optional support bits */
75878 enum statusEnum tidStatus;
75879 #ifdef CONFIG_CIFS_STATS
75880- atomic_t num_smbs_sent;
75881+ atomic_unchecked_t num_smbs_sent;
75882 union {
75883 struct {
75884- atomic_t num_writes;
75885- atomic_t num_reads;
75886- atomic_t num_flushes;
75887- atomic_t num_oplock_brks;
75888- atomic_t num_opens;
75889- atomic_t num_closes;
75890- atomic_t num_deletes;
75891- atomic_t num_mkdirs;
75892- atomic_t num_posixopens;
75893- atomic_t num_posixmkdirs;
75894- atomic_t num_rmdirs;
75895- atomic_t num_renames;
75896- atomic_t num_t2renames;
75897- atomic_t num_ffirst;
75898- atomic_t num_fnext;
75899- atomic_t num_fclose;
75900- atomic_t num_hardlinks;
75901- atomic_t num_symlinks;
75902- atomic_t num_locks;
75903- atomic_t num_acl_get;
75904- atomic_t num_acl_set;
75905+ atomic_unchecked_t num_writes;
75906+ atomic_unchecked_t num_reads;
75907+ atomic_unchecked_t num_flushes;
75908+ atomic_unchecked_t num_oplock_brks;
75909+ atomic_unchecked_t num_opens;
75910+ atomic_unchecked_t num_closes;
75911+ atomic_unchecked_t num_deletes;
75912+ atomic_unchecked_t num_mkdirs;
75913+ atomic_unchecked_t num_posixopens;
75914+ atomic_unchecked_t num_posixmkdirs;
75915+ atomic_unchecked_t num_rmdirs;
75916+ atomic_unchecked_t num_renames;
75917+ atomic_unchecked_t num_t2renames;
75918+ atomic_unchecked_t num_ffirst;
75919+ atomic_unchecked_t num_fnext;
75920+ atomic_unchecked_t num_fclose;
75921+ atomic_unchecked_t num_hardlinks;
75922+ atomic_unchecked_t num_symlinks;
75923+ atomic_unchecked_t num_locks;
75924+ atomic_unchecked_t num_acl_get;
75925+ atomic_unchecked_t num_acl_set;
75926 } cifs_stats;
75927 #ifdef CONFIG_CIFS_SMB2
75928 struct {
75929- atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
75930- atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
75931+ atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
75932+ atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
75933 } smb2_stats;
75934 #endif /* CONFIG_CIFS_SMB2 */
75935 } stats;
75936@@ -1207,7 +1207,7 @@ convert_delimiter(char *path, char delim)
75937 }
75938
75939 #ifdef CONFIG_CIFS_STATS
75940-#define cifs_stats_inc atomic_inc
75941+#define cifs_stats_inc atomic_inc_unchecked
75942
75943 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
75944 unsigned int bytes)
75945@@ -1574,8 +1574,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
75946 /* Various Debug counters */
75947 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
75948 #ifdef CONFIG_CIFS_STATS2
75949-GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
75950-GLOBAL_EXTERN atomic_t totSmBufAllocCount;
75951+GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
75952+GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
75953 #endif
75954 GLOBAL_EXTERN atomic_t smBufAllocCount;
75955 GLOBAL_EXTERN atomic_t midCount;
75956diff --git a/fs/cifs/file.c b/fs/cifs/file.c
75957index 3f50cee..7741620 100644
75958--- a/fs/cifs/file.c
75959+++ b/fs/cifs/file.c
75960@@ -2054,10 +2054,14 @@ static int cifs_writepages(struct address_space *mapping,
75961 index = mapping->writeback_index; /* Start from prev offset */
75962 end = -1;
75963 } else {
75964- index = wbc->range_start >> PAGE_CACHE_SHIFT;
75965- end = wbc->range_end >> PAGE_CACHE_SHIFT;
75966- if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
75967+ if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) {
75968 range_whole = true;
75969+ index = 0;
75970+ end = ULONG_MAX;
75971+ } else {
75972+ index = wbc->range_start >> PAGE_CACHE_SHIFT;
75973+ end = wbc->range_end >> PAGE_CACHE_SHIFT;
75974+ }
75975 scanned = true;
75976 }
75977 server = cifs_sb_master_tcon(cifs_sb)->ses->server;
75978diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
75979index 8442b8b..ea6986f 100644
75980--- a/fs/cifs/misc.c
75981+++ b/fs/cifs/misc.c
75982@@ -170,7 +170,7 @@ cifs_buf_get(void)
75983 memset(ret_buf, 0, buf_size + 3);
75984 atomic_inc(&bufAllocCount);
75985 #ifdef CONFIG_CIFS_STATS2
75986- atomic_inc(&totBufAllocCount);
75987+ atomic_inc_unchecked(&totBufAllocCount);
75988 #endif /* CONFIG_CIFS_STATS2 */
75989 }
75990
75991@@ -205,7 +205,7 @@ cifs_small_buf_get(void)
75992 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
75993 atomic_inc(&smBufAllocCount);
75994 #ifdef CONFIG_CIFS_STATS2
75995- atomic_inc(&totSmBufAllocCount);
75996+ atomic_inc_unchecked(&totSmBufAllocCount);
75997 #endif /* CONFIG_CIFS_STATS2 */
75998
75999 }
76000diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
76001index fc537c2..47d654c 100644
76002--- a/fs/cifs/smb1ops.c
76003+++ b/fs/cifs/smb1ops.c
76004@@ -622,27 +622,27 @@ static void
76005 cifs_clear_stats(struct cifs_tcon *tcon)
76006 {
76007 #ifdef CONFIG_CIFS_STATS
76008- atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
76009- atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
76010- atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
76011- atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
76012- atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
76013- atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
76014- atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
76015- atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
76016- atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
76017- atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
76018- atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
76019- atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
76020- atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
76021- atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
76022- atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
76023- atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
76024- atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
76025- atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
76026- atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
76027- atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
76028- atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
76029+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
76030+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
76031+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
76032+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
76033+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
76034+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
76035+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
76036+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
76037+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
76038+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
76039+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
76040+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
76041+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
76042+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
76043+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
76044+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
76045+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
76046+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
76047+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
76048+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
76049+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
76050 #endif
76051 }
76052
76053@@ -651,36 +651,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
76054 {
76055 #ifdef CONFIG_CIFS_STATS
76056 seq_printf(m, " Oplocks breaks: %d",
76057- atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
76058+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
76059 seq_printf(m, "\nReads: %d Bytes: %llu",
76060- atomic_read(&tcon->stats.cifs_stats.num_reads),
76061+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
76062 (long long)(tcon->bytes_read));
76063 seq_printf(m, "\nWrites: %d Bytes: %llu",
76064- atomic_read(&tcon->stats.cifs_stats.num_writes),
76065+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
76066 (long long)(tcon->bytes_written));
76067 seq_printf(m, "\nFlushes: %d",
76068- atomic_read(&tcon->stats.cifs_stats.num_flushes));
76069+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
76070 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
76071- atomic_read(&tcon->stats.cifs_stats.num_locks),
76072- atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
76073- atomic_read(&tcon->stats.cifs_stats.num_symlinks));
76074+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
76075+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
76076+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
76077 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
76078- atomic_read(&tcon->stats.cifs_stats.num_opens),
76079- atomic_read(&tcon->stats.cifs_stats.num_closes),
76080- atomic_read(&tcon->stats.cifs_stats.num_deletes));
76081+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
76082+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
76083+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
76084 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
76085- atomic_read(&tcon->stats.cifs_stats.num_posixopens),
76086- atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
76087+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
76088+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
76089 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
76090- atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
76091- atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
76092+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
76093+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
76094 seq_printf(m, "\nRenames: %d T2 Renames %d",
76095- atomic_read(&tcon->stats.cifs_stats.num_renames),
76096- atomic_read(&tcon->stats.cifs_stats.num_t2renames));
76097+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
76098+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
76099 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
76100- atomic_read(&tcon->stats.cifs_stats.num_ffirst),
76101- atomic_read(&tcon->stats.cifs_stats.num_fnext),
76102- atomic_read(&tcon->stats.cifs_stats.num_fclose));
76103+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
76104+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
76105+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
76106 #endif
76107 }
76108
76109diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
76110index 18da19f..38a3a79 100644
76111--- a/fs/cifs/smb2ops.c
76112+++ b/fs/cifs/smb2ops.c
76113@@ -422,8 +422,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
76114 #ifdef CONFIG_CIFS_STATS
76115 int i;
76116 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
76117- atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
76118- atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
76119+ atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
76120+ atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
76121 }
76122 #endif
76123 }
76124@@ -463,65 +463,65 @@ static void
76125 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
76126 {
76127 #ifdef CONFIG_CIFS_STATS
76128- atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
76129- atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
76130+ atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
76131+ atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
76132 seq_printf(m, "\nNegotiates: %d sent %d failed",
76133- atomic_read(&sent[SMB2_NEGOTIATE_HE]),
76134- atomic_read(&failed[SMB2_NEGOTIATE_HE]));
76135+ atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
76136+ atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
76137 seq_printf(m, "\nSessionSetups: %d sent %d failed",
76138- atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
76139- atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
76140+ atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
76141+ atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
76142 seq_printf(m, "\nLogoffs: %d sent %d failed",
76143- atomic_read(&sent[SMB2_LOGOFF_HE]),
76144- atomic_read(&failed[SMB2_LOGOFF_HE]));
76145+ atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
76146+ atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
76147 seq_printf(m, "\nTreeConnects: %d sent %d failed",
76148- atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
76149- atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
76150+ atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
76151+ atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
76152 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
76153- atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
76154- atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
76155+ atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
76156+ atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
76157 seq_printf(m, "\nCreates: %d sent %d failed",
76158- atomic_read(&sent[SMB2_CREATE_HE]),
76159- atomic_read(&failed[SMB2_CREATE_HE]));
76160+ atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
76161+ atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
76162 seq_printf(m, "\nCloses: %d sent %d failed",
76163- atomic_read(&sent[SMB2_CLOSE_HE]),
76164- atomic_read(&failed[SMB2_CLOSE_HE]));
76165+ atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
76166+ atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
76167 seq_printf(m, "\nFlushes: %d sent %d failed",
76168- atomic_read(&sent[SMB2_FLUSH_HE]),
76169- atomic_read(&failed[SMB2_FLUSH_HE]));
76170+ atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
76171+ atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
76172 seq_printf(m, "\nReads: %d sent %d failed",
76173- atomic_read(&sent[SMB2_READ_HE]),
76174- atomic_read(&failed[SMB2_READ_HE]));
76175+ atomic_read_unchecked(&sent[SMB2_READ_HE]),
76176+ atomic_read_unchecked(&failed[SMB2_READ_HE]));
76177 seq_printf(m, "\nWrites: %d sent %d failed",
76178- atomic_read(&sent[SMB2_WRITE_HE]),
76179- atomic_read(&failed[SMB2_WRITE_HE]));
76180+ atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
76181+ atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
76182 seq_printf(m, "\nLocks: %d sent %d failed",
76183- atomic_read(&sent[SMB2_LOCK_HE]),
76184- atomic_read(&failed[SMB2_LOCK_HE]));
76185+ atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
76186+ atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
76187 seq_printf(m, "\nIOCTLs: %d sent %d failed",
76188- atomic_read(&sent[SMB2_IOCTL_HE]),
76189- atomic_read(&failed[SMB2_IOCTL_HE]));
76190+ atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
76191+ atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
76192 seq_printf(m, "\nCancels: %d sent %d failed",
76193- atomic_read(&sent[SMB2_CANCEL_HE]),
76194- atomic_read(&failed[SMB2_CANCEL_HE]));
76195+ atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
76196+ atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
76197 seq_printf(m, "\nEchos: %d sent %d failed",
76198- atomic_read(&sent[SMB2_ECHO_HE]),
76199- atomic_read(&failed[SMB2_ECHO_HE]));
76200+ atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
76201+ atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
76202 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
76203- atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
76204- atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
76205+ atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
76206+ atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
76207 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
76208- atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
76209- atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
76210+ atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
76211+ atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
76212 seq_printf(m, "\nQueryInfos: %d sent %d failed",
76213- atomic_read(&sent[SMB2_QUERY_INFO_HE]),
76214- atomic_read(&failed[SMB2_QUERY_INFO_HE]));
76215+ atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
76216+ atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
76217 seq_printf(m, "\nSetInfos: %d sent %d failed",
76218- atomic_read(&sent[SMB2_SET_INFO_HE]),
76219- atomic_read(&failed[SMB2_SET_INFO_HE]));
76220+ atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
76221+ atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
76222 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
76223- atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
76224- atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
76225+ atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
76226+ atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
76227 #endif
76228 }
76229
76230diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
76231index 60dd831..42f911c 100644
76232--- a/fs/cifs/smb2pdu.c
76233+++ b/fs/cifs/smb2pdu.c
76234@@ -2252,8 +2252,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
76235 default:
76236 cifs_dbg(VFS, "info level %u isn't supported\n",
76237 srch_inf->info_level);
76238- rc = -EINVAL;
76239- goto qdir_exit;
76240+ return -EINVAL;
76241 }
76242
76243 req->FileIndex = cpu_to_le32(index);
76244diff --git a/fs/coda/cache.c b/fs/coda/cache.c
76245index 5bb630a..043dc70 100644
76246--- a/fs/coda/cache.c
76247+++ b/fs/coda/cache.c
76248@@ -24,7 +24,7 @@
76249 #include "coda_linux.h"
76250 #include "coda_cache.h"
76251
76252-static atomic_t permission_epoch = ATOMIC_INIT(0);
76253+static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
76254
76255 /* replace or extend an acl cache hit */
76256 void coda_cache_enter(struct inode *inode, int mask)
76257@@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
76258 struct coda_inode_info *cii = ITOC(inode);
76259
76260 spin_lock(&cii->c_lock);
76261- cii->c_cached_epoch = atomic_read(&permission_epoch);
76262+ cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
76263 if (!uid_eq(cii->c_uid, current_fsuid())) {
76264 cii->c_uid = current_fsuid();
76265 cii->c_cached_perm = mask;
76266@@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
76267 {
76268 struct coda_inode_info *cii = ITOC(inode);
76269 spin_lock(&cii->c_lock);
76270- cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
76271+ cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
76272 spin_unlock(&cii->c_lock);
76273 }
76274
76275 /* remove all acl caches */
76276 void coda_cache_clear_all(struct super_block *sb)
76277 {
76278- atomic_inc(&permission_epoch);
76279+ atomic_inc_unchecked(&permission_epoch);
76280 }
76281
76282
76283@@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
76284 spin_lock(&cii->c_lock);
76285 hit = (mask & cii->c_cached_perm) == mask &&
76286 uid_eq(cii->c_uid, current_fsuid()) &&
76287- cii->c_cached_epoch == atomic_read(&permission_epoch);
76288+ cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
76289 spin_unlock(&cii->c_lock);
76290
76291 return hit;
76292diff --git a/fs/compat.c b/fs/compat.c
76293index 6fd272d..dd34ba2 100644
76294--- a/fs/compat.c
76295+++ b/fs/compat.c
76296@@ -54,7 +54,7 @@
76297 #include <asm/ioctls.h>
76298 #include "internal.h"
76299
76300-int compat_log = 1;
76301+int compat_log = 0;
76302
76303 int compat_printk(const char *fmt, ...)
76304 {
76305@@ -512,7 +512,7 @@ COMPAT_SYSCALL_DEFINE2(io_setup, unsigned, nr_reqs, u32 __user *, ctx32p)
76306
76307 set_fs(KERNEL_DS);
76308 /* The __user pointer cast is valid because of the set_fs() */
76309- ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
76310+ ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
76311 set_fs(oldfs);
76312 /* truncating is ok because it's a user address */
76313 if (!ret)
76314@@ -562,7 +562,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
76315 goto out;
76316
76317 ret = -EINVAL;
76318- if (nr_segs > UIO_MAXIOV || nr_segs < 0)
76319+ if (nr_segs > UIO_MAXIOV)
76320 goto out;
76321 if (nr_segs > fast_segs) {
76322 ret = -ENOMEM;
76323@@ -844,6 +844,7 @@ struct compat_old_linux_dirent {
76324 struct compat_readdir_callback {
76325 struct dir_context ctx;
76326 struct compat_old_linux_dirent __user *dirent;
76327+ struct file * file;
76328 int result;
76329 };
76330
76331@@ -863,6 +864,10 @@ static int compat_fillonedir(struct dir_context *ctx, const char *name,
76332 buf->result = -EOVERFLOW;
76333 return -EOVERFLOW;
76334 }
76335+
76336+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
76337+ return 0;
76338+
76339 buf->result++;
76340 dirent = buf->dirent;
76341 if (!access_ok(VERIFY_WRITE, dirent,
76342@@ -894,6 +899,7 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
76343 if (!f.file)
76344 return -EBADF;
76345
76346+ buf.file = f.file;
76347 error = iterate_dir(f.file, &buf.ctx);
76348 if (buf.result)
76349 error = buf.result;
76350@@ -913,6 +919,7 @@ struct compat_getdents_callback {
76351 struct dir_context ctx;
76352 struct compat_linux_dirent __user *current_dir;
76353 struct compat_linux_dirent __user *previous;
76354+ struct file * file;
76355 int count;
76356 int error;
76357 };
76358@@ -935,6 +942,10 @@ static int compat_filldir(struct dir_context *ctx, const char *name, int namlen,
76359 buf->error = -EOVERFLOW;
76360 return -EOVERFLOW;
76361 }
76362+
76363+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
76364+ return 0;
76365+
76366 dirent = buf->previous;
76367 if (dirent) {
76368 if (__put_user(offset, &dirent->d_off))
76369@@ -980,6 +991,7 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd,
76370 if (!f.file)
76371 return -EBADF;
76372
76373+ buf.file = f.file;
76374 error = iterate_dir(f.file, &buf.ctx);
76375 if (error >= 0)
76376 error = buf.error;
76377@@ -1000,6 +1012,7 @@ struct compat_getdents_callback64 {
76378 struct dir_context ctx;
76379 struct linux_dirent64 __user *current_dir;
76380 struct linux_dirent64 __user *previous;
76381+ struct file * file;
76382 int count;
76383 int error;
76384 };
76385@@ -1018,6 +1031,10 @@ static int compat_filldir64(struct dir_context *ctx, const char *name,
76386 buf->error = -EINVAL; /* only used if we fail.. */
76387 if (reclen > buf->count)
76388 return -EINVAL;
76389+
76390+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
76391+ return 0;
76392+
76393 dirent = buf->previous;
76394
76395 if (dirent) {
76396@@ -1067,6 +1084,7 @@ COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd,
76397 if (!f.file)
76398 return -EBADF;
76399
76400+ buf.file = f.file;
76401 error = iterate_dir(f.file, &buf.ctx);
76402 if (error >= 0)
76403 error = buf.error;
76404diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
76405index 4d24d17..4f8c09e 100644
76406--- a/fs/compat_binfmt_elf.c
76407+++ b/fs/compat_binfmt_elf.c
76408@@ -30,11 +30,13 @@
76409 #undef elf_phdr
76410 #undef elf_shdr
76411 #undef elf_note
76412+#undef elf_dyn
76413 #undef elf_addr_t
76414 #define elfhdr elf32_hdr
76415 #define elf_phdr elf32_phdr
76416 #define elf_shdr elf32_shdr
76417 #define elf_note elf32_note
76418+#define elf_dyn Elf32_Dyn
76419 #define elf_addr_t Elf32_Addr
76420
76421 /*
76422diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
76423index 48851f6..6c79d32 100644
76424--- a/fs/compat_ioctl.c
76425+++ b/fs/compat_ioctl.c
76426@@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
76427 return -EFAULT;
76428 if (__get_user(udata, &ss32->iomem_base))
76429 return -EFAULT;
76430- ss.iomem_base = compat_ptr(udata);
76431+ ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
76432 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
76433 __get_user(ss.port_high, &ss32->port_high))
76434 return -EFAULT;
76435@@ -704,8 +704,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
76436 for (i = 0; i < nmsgs; i++) {
76437 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
76438 return -EFAULT;
76439- if (get_user(datap, &umsgs[i].buf) ||
76440- put_user(compat_ptr(datap), &tmsgs[i].buf))
76441+ if (get_user(datap, (compat_caddr_t __user *)&umsgs[i].buf) ||
76442+ put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
76443 return -EFAULT;
76444 }
76445 return sys_ioctl(fd, cmd, (unsigned long)tdata);
76446@@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
76447 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
76448 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
76449 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
76450- copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
76451+ copy_in_user(p->l_pad, p32->l_pad, 4*sizeof(u32)))
76452 return -EFAULT;
76453
76454 return ioctl_preallocate(file, p);
76455@@ -1621,8 +1621,8 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
76456 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
76457 {
76458 unsigned int a, b;
76459- a = *(unsigned int *)p;
76460- b = *(unsigned int *)q;
76461+ a = *(const unsigned int *)p;
76462+ b = *(const unsigned int *)q;
76463 if (a > b)
76464 return 1;
76465 if (a < b)
76466diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
76467index c81ce7f..f3de5fd 100644
76468--- a/fs/configfs/dir.c
76469+++ b/fs/configfs/dir.c
76470@@ -1540,7 +1540,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
76471 }
76472 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
76473 struct configfs_dirent *next;
76474- const char *name;
76475+ const unsigned char * name;
76476+ char d_name[sizeof(next->s_dentry->d_iname)];
76477 int len;
76478 struct inode *inode = NULL;
76479
76480@@ -1549,7 +1550,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
76481 continue;
76482
76483 name = configfs_get_name(next);
76484- len = strlen(name);
76485+ if (next->s_dentry && name == next->s_dentry->d_iname) {
76486+ len = next->s_dentry->d_name.len;
76487+ memcpy(d_name, name, len);
76488+ name = d_name;
76489+ } else
76490+ len = strlen(name);
76491
76492 /*
76493 * We'll have a dentry and an inode for
76494diff --git a/fs/coredump.c b/fs/coredump.c
76495index a8f7564..3dde349 100644
76496--- a/fs/coredump.c
76497+++ b/fs/coredump.c
76498@@ -457,8 +457,8 @@ static void wait_for_dump_helpers(struct file *file)
76499 struct pipe_inode_info *pipe = file->private_data;
76500
76501 pipe_lock(pipe);
76502- pipe->readers++;
76503- pipe->writers--;
76504+ atomic_inc(&pipe->readers);
76505+ atomic_dec(&pipe->writers);
76506 wake_up_interruptible_sync(&pipe->wait);
76507 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
76508 pipe_unlock(pipe);
76509@@ -467,11 +467,11 @@ static void wait_for_dump_helpers(struct file *file)
76510 * We actually want wait_event_freezable() but then we need
76511 * to clear TIF_SIGPENDING and improve dump_interrupted().
76512 */
76513- wait_event_interruptible(pipe->wait, pipe->readers == 1);
76514+ wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
76515
76516 pipe_lock(pipe);
76517- pipe->readers--;
76518- pipe->writers++;
76519+ atomic_dec(&pipe->readers);
76520+ atomic_inc(&pipe->writers);
76521 pipe_unlock(pipe);
76522 }
76523
76524@@ -518,7 +518,9 @@ void do_coredump(const siginfo_t *siginfo)
76525 /* require nonrelative corefile path and be extra careful */
76526 bool need_suid_safe = false;
76527 bool core_dumped = false;
76528- static atomic_t core_dump_count = ATOMIC_INIT(0);
76529+ static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
76530+ long signr = siginfo->si_signo;
76531+ int dumpable;
76532 struct coredump_params cprm = {
76533 .siginfo = siginfo,
76534 .regs = signal_pt_regs(),
76535@@ -531,12 +533,17 @@ void do_coredump(const siginfo_t *siginfo)
76536 .mm_flags = mm->flags,
76537 };
76538
76539- audit_core_dumps(siginfo->si_signo);
76540+ audit_core_dumps(signr);
76541+
76542+ dumpable = __get_dumpable(cprm.mm_flags);
76543+
76544+ if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
76545+ gr_handle_brute_attach(dumpable);
76546
76547 binfmt = mm->binfmt;
76548 if (!binfmt || !binfmt->core_dump)
76549 goto fail;
76550- if (!__get_dumpable(cprm.mm_flags))
76551+ if (!dumpable)
76552 goto fail;
76553
76554 cred = prepare_creds();
76555@@ -554,7 +561,7 @@ void do_coredump(const siginfo_t *siginfo)
76556 need_suid_safe = true;
76557 }
76558
76559- retval = coredump_wait(siginfo->si_signo, &core_state);
76560+ retval = coredump_wait(signr, &core_state);
76561 if (retval < 0)
76562 goto fail_creds;
76563
76564@@ -597,7 +604,7 @@ void do_coredump(const siginfo_t *siginfo)
76565 }
76566 cprm.limit = RLIM_INFINITY;
76567
76568- dump_count = atomic_inc_return(&core_dump_count);
76569+ dump_count = atomic_inc_return_unchecked(&core_dump_count);
76570 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
76571 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
76572 task_tgid_vnr(current), current->comm);
76573@@ -629,6 +636,8 @@ void do_coredump(const siginfo_t *siginfo)
76574 } else {
76575 struct inode *inode;
76576
76577+ gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
76578+
76579 if (cprm.limit < binfmt->min_coredump)
76580 goto fail_unlock;
76581
76582@@ -718,7 +727,7 @@ close_fail:
76583 filp_close(cprm.file, NULL);
76584 fail_dropcount:
76585 if (ispipe)
76586- atomic_dec(&core_dump_count);
76587+ atomic_dec_unchecked(&core_dump_count);
76588 fail_unlock:
76589 kfree(cn.corename);
76590 coredump_finish(mm, core_dumped);
76591@@ -739,6 +748,8 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
76592 struct file *file = cprm->file;
76593 loff_t pos = file->f_pos;
76594 ssize_t n;
76595+
76596+ gr_learn_resource(current, RLIMIT_CORE, cprm->written + nr, 1);
76597 if (cprm->written + nr > cprm->limit)
76598 return 0;
76599 while (nr) {
76600diff --git a/fs/dcache.c b/fs/dcache.c
76601index e3b44ca..e0d94f1 100644
76602--- a/fs/dcache.c
76603+++ b/fs/dcache.c
76604@@ -545,7 +545,7 @@ static void __dentry_kill(struct dentry *dentry)
76605 * dentry_iput drops the locks, at which point nobody (except
76606 * transient RCU lookups) can reach this dentry.
76607 */
76608- BUG_ON(dentry->d_lockref.count > 0);
76609+ BUG_ON(__lockref_read(&dentry->d_lockref) > 0);
76610 this_cpu_dec(nr_dentry);
76611 if (dentry->d_op && dentry->d_op->d_release)
76612 dentry->d_op->d_release(dentry);
76613@@ -598,7 +598,7 @@ static inline struct dentry *lock_parent(struct dentry *dentry)
76614 struct dentry *parent = dentry->d_parent;
76615 if (IS_ROOT(dentry))
76616 return NULL;
76617- if (unlikely(dentry->d_lockref.count < 0))
76618+ if (unlikely(__lockref_read(&dentry->d_lockref) < 0))
76619 return NULL;
76620 if (likely(spin_trylock(&parent->d_lock)))
76621 return parent;
76622@@ -660,8 +660,8 @@ static inline bool fast_dput(struct dentry *dentry)
76623 */
76624 if (unlikely(ret < 0)) {
76625 spin_lock(&dentry->d_lock);
76626- if (dentry->d_lockref.count > 1) {
76627- dentry->d_lockref.count--;
76628+ if (__lockref_read(&dentry->d_lockref) > 1) {
76629+ __lockref_dec(&dentry->d_lockref);
76630 spin_unlock(&dentry->d_lock);
76631 return 1;
76632 }
76633@@ -716,7 +716,7 @@ static inline bool fast_dput(struct dentry *dentry)
76634 * else could have killed it and marked it dead. Either way, we
76635 * don't need to do anything else.
76636 */
76637- if (dentry->d_lockref.count) {
76638+ if (__lockref_read(&dentry->d_lockref)) {
76639 spin_unlock(&dentry->d_lock);
76640 return 1;
76641 }
76642@@ -726,7 +726,7 @@ static inline bool fast_dput(struct dentry *dentry)
76643 * lock, and we just tested that it was zero, so we can just
76644 * set it to 1.
76645 */
76646- dentry->d_lockref.count = 1;
76647+ __lockref_set(&dentry->d_lockref, 1);
76648 return 0;
76649 }
76650
76651@@ -788,7 +788,7 @@ repeat:
76652 dentry->d_flags |= DCACHE_REFERENCED;
76653 dentry_lru_add(dentry);
76654
76655- dentry->d_lockref.count--;
76656+ __lockref_dec(&dentry->d_lockref);
76657 spin_unlock(&dentry->d_lock);
76658 return;
76659
76660@@ -803,7 +803,7 @@ EXPORT_SYMBOL(dput);
76661 /* This must be called with d_lock held */
76662 static inline void __dget_dlock(struct dentry *dentry)
76663 {
76664- dentry->d_lockref.count++;
76665+ __lockref_inc(&dentry->d_lockref);
76666 }
76667
76668 static inline void __dget(struct dentry *dentry)
76669@@ -844,8 +844,8 @@ repeat:
76670 goto repeat;
76671 }
76672 rcu_read_unlock();
76673- BUG_ON(!ret->d_lockref.count);
76674- ret->d_lockref.count++;
76675+ BUG_ON(!__lockref_read(&ret->d_lockref));
76676+ __lockref_inc(&ret->d_lockref);
76677 spin_unlock(&ret->d_lock);
76678 return ret;
76679 }
76680@@ -923,9 +923,9 @@ restart:
76681 spin_lock(&inode->i_lock);
76682 hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
76683 spin_lock(&dentry->d_lock);
76684- if (!dentry->d_lockref.count) {
76685+ if (!__lockref_read(&dentry->d_lockref)) {
76686 struct dentry *parent = lock_parent(dentry);
76687- if (likely(!dentry->d_lockref.count)) {
76688+ if (likely(!__lockref_read(&dentry->d_lockref))) {
76689 __dentry_kill(dentry);
76690 dput(parent);
76691 goto restart;
76692@@ -960,7 +960,7 @@ static void shrink_dentry_list(struct list_head *list)
76693 * We found an inuse dentry which was not removed from
76694 * the LRU because of laziness during lookup. Do not free it.
76695 */
76696- if (dentry->d_lockref.count > 0) {
76697+ if (__lockref_read(&dentry->d_lockref) > 0) {
76698 spin_unlock(&dentry->d_lock);
76699 if (parent)
76700 spin_unlock(&parent->d_lock);
76701@@ -998,8 +998,8 @@ static void shrink_dentry_list(struct list_head *list)
76702 dentry = parent;
76703 while (dentry && !lockref_put_or_lock(&dentry->d_lockref)) {
76704 parent = lock_parent(dentry);
76705- if (dentry->d_lockref.count != 1) {
76706- dentry->d_lockref.count--;
76707+ if (__lockref_read(&dentry->d_lockref) != 1) {
76708+ __lockref_inc(&dentry->d_lockref);
76709 spin_unlock(&dentry->d_lock);
76710 if (parent)
76711 spin_unlock(&parent->d_lock);
76712@@ -1039,7 +1039,7 @@ static enum lru_status dentry_lru_isolate(struct list_head *item,
76713 * counts, just remove them from the LRU. Otherwise give them
76714 * another pass through the LRU.
76715 */
76716- if (dentry->d_lockref.count) {
76717+ if (__lockref_read(&dentry->d_lockref)) {
76718 d_lru_isolate(lru, dentry);
76719 spin_unlock(&dentry->d_lock);
76720 return LRU_REMOVED;
76721@@ -1373,7 +1373,7 @@ static enum d_walk_ret select_collect(void *_data, struct dentry *dentry)
76722 } else {
76723 if (dentry->d_flags & DCACHE_LRU_LIST)
76724 d_lru_del(dentry);
76725- if (!dentry->d_lockref.count) {
76726+ if (!__lockref_read(&dentry->d_lockref)) {
76727 d_shrink_add(dentry, &data->dispose);
76728 data->found++;
76729 }
76730@@ -1421,7 +1421,7 @@ static enum d_walk_ret umount_check(void *_data, struct dentry *dentry)
76731 return D_WALK_CONTINUE;
76732
76733 /* root with refcount 1 is fine */
76734- if (dentry == _data && dentry->d_lockref.count == 1)
76735+ if (dentry == _data && __lockref_read(&dentry->d_lockref) == 1)
76736 return D_WALK_CONTINUE;
76737
76738 printk(KERN_ERR "BUG: Dentry %p{i=%lx,n=%pd} "
76739@@ -1430,7 +1430,7 @@ static enum d_walk_ret umount_check(void *_data, struct dentry *dentry)
76740 dentry->d_inode ?
76741 dentry->d_inode->i_ino : 0UL,
76742 dentry,
76743- dentry->d_lockref.count,
76744+ __lockref_read(&dentry->d_lockref),
76745 dentry->d_sb->s_type->name,
76746 dentry->d_sb->s_id);
76747 WARN_ON(1);
76748@@ -1571,7 +1571,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
76749 dentry->d_iname[DNAME_INLINE_LEN-1] = 0;
76750 if (name->len > DNAME_INLINE_LEN-1) {
76751 size_t size = offsetof(struct external_name, name[1]);
76752- struct external_name *p = kmalloc(size + name->len, GFP_KERNEL);
76753+ struct external_name *p = kmalloc(round_up(size + name->len, sizeof(unsigned long)), GFP_KERNEL);
76754 if (!p) {
76755 kmem_cache_free(dentry_cache, dentry);
76756 return NULL;
76757@@ -1594,7 +1594,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
76758 smp_wmb();
76759 dentry->d_name.name = dname;
76760
76761- dentry->d_lockref.count = 1;
76762+ __lockref_set(&dentry->d_lockref, 1);
76763 dentry->d_flags = 0;
76764 spin_lock_init(&dentry->d_lock);
76765 seqcount_init(&dentry->d_seq);
76766@@ -1603,6 +1603,9 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
76767 dentry->d_sb = sb;
76768 dentry->d_op = NULL;
76769 dentry->d_fsdata = NULL;
76770+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
76771+ atomic_set(&dentry->chroot_refcnt, 0);
76772+#endif
76773 INIT_HLIST_BL_NODE(&dentry->d_hash);
76774 INIT_LIST_HEAD(&dentry->d_lru);
76775 INIT_LIST_HEAD(&dentry->d_subdirs);
76776@@ -2327,7 +2330,7 @@ struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name)
76777 goto next;
76778 }
76779
76780- dentry->d_lockref.count++;
76781+ __lockref_inc(&dentry->d_lockref);
76782 found = dentry;
76783 spin_unlock(&dentry->d_lock);
76784 break;
76785@@ -2395,7 +2398,7 @@ again:
76786 spin_lock(&dentry->d_lock);
76787 inode = dentry->d_inode;
76788 isdir = S_ISDIR(inode->i_mode);
76789- if (dentry->d_lockref.count == 1) {
76790+ if (__lockref_read(&dentry->d_lockref) == 1) {
76791 if (!spin_trylock(&inode->i_lock)) {
76792 spin_unlock(&dentry->d_lock);
76793 cpu_relax();
76794@@ -3344,7 +3347,7 @@ static enum d_walk_ret d_genocide_kill(void *data, struct dentry *dentry)
76795
76796 if (!(dentry->d_flags & DCACHE_GENOCIDE)) {
76797 dentry->d_flags |= DCACHE_GENOCIDE;
76798- dentry->d_lockref.count--;
76799+ __lockref_dec(&dentry->d_lockref);
76800 }
76801 }
76802 return D_WALK_CONTINUE;
76803@@ -3452,7 +3455,8 @@ void __init vfs_caches_init_early(void)
76804 void __init vfs_caches_init(void)
76805 {
76806 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
76807- SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
76808+ SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
76809+ SLAB_NO_SANITIZE, NULL);
76810
76811 dcache_init();
76812 inode_init();
76813diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
76814index c711be8..23b8df9 100644
76815--- a/fs/debugfs/inode.c
76816+++ b/fs/debugfs/inode.c
76817@@ -402,6 +402,10 @@ EXPORT_SYMBOL_GPL(debugfs_create_file_size);
76818 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
76819 * returned.
76820 */
76821+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
76822+extern int grsec_enable_sysfs_restrict;
76823+#endif
76824+
76825 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
76826 {
76827 struct dentry *dentry = start_creating(name, parent);
76828@@ -414,7 +418,12 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
76829 if (unlikely(!inode))
76830 return failed_creating(dentry);
76831
76832- inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
76833+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
76834+ if (grsec_enable_sysfs_restrict)
76835+ inode->i_mode = S_IFDIR | S_IRWXU;
76836+ else
76837+#endif
76838+ inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
76839 inode->i_op = &simple_dir_inode_operations;
76840 inode->i_fop = &simple_dir_operations;
76841
76842diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
76843index 754fd6c..ed6acbe 100644
76844--- a/fs/dlm/lowcomms.c
76845+++ b/fs/dlm/lowcomms.c
76846@@ -538,7 +538,7 @@ static void close_connection(struct connection *con, bool and_other)
76847 /* We only send shutdown messages to nodes that are not part of the cluster */
76848 static void sctp_send_shutdown(sctp_assoc_t associd)
76849 {
76850- static char outcmsg[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
76851+ char outcmsg[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
76852 struct msghdr outmessage;
76853 struct cmsghdr *cmsg;
76854 struct sctp_sndrcvinfo *sinfo;
76855diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
76856index 3c4db11..a43976f 100644
76857--- a/fs/ecryptfs/inode.c
76858+++ b/fs/ecryptfs/inode.c
76859@@ -662,7 +662,7 @@ static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
76860 old_fs = get_fs();
76861 set_fs(get_ds());
76862 rc = d_inode(lower_dentry)->i_op->readlink(lower_dentry,
76863- (char __user *)lower_buf,
76864+ (char __force_user *)lower_buf,
76865 PATH_MAX);
76866 set_fs(old_fs);
76867 if (rc < 0)
76868diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
76869index e4141f2..d8263e8 100644
76870--- a/fs/ecryptfs/miscdev.c
76871+++ b/fs/ecryptfs/miscdev.c
76872@@ -304,7 +304,7 @@ check_list:
76873 goto out_unlock_msg_ctx;
76874 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
76875 if (msg_ctx->msg) {
76876- if (copy_to_user(&buf[i], packet_length, packet_length_size))
76877+ if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
76878 goto out_unlock_msg_ctx;
76879 i += packet_length_size;
76880 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
76881diff --git a/fs/exec.c b/fs/exec.c
76882index 1977c2a..b6b953a 100644
76883--- a/fs/exec.c
76884+++ b/fs/exec.c
76885@@ -56,8 +56,20 @@
76886 #include <linux/pipe_fs_i.h>
76887 #include <linux/oom.h>
76888 #include <linux/compat.h>
76889+#include <linux/random.h>
76890+#include <linux/seq_file.h>
76891+#include <linux/coredump.h>
76892+#include <linux/mman.h>
76893+
76894+#ifdef CONFIG_PAX_REFCOUNT
76895+#include <linux/kallsyms.h>
76896+#include <linux/kdebug.h>
76897+#endif
76898+
76899+#include <trace/events/fs.h>
76900
76901 #include <asm/uaccess.h>
76902+#include <asm/sections.h>
76903 #include <asm/mmu_context.h>
76904 #include <asm/tlb.h>
76905
76906@@ -66,19 +78,34 @@
76907
76908 #include <trace/events/sched.h>
76909
76910+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76911+void __weak pax_set_initial_flags(struct linux_binprm *bprm)
76912+{
76913+ 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");
76914+}
76915+#endif
76916+
76917+#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
76918+void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76919+EXPORT_SYMBOL(pax_set_initial_flags_func);
76920+#endif
76921+
76922 int suid_dumpable = 0;
76923
76924 static LIST_HEAD(formats);
76925 static DEFINE_RWLOCK(binfmt_lock);
76926
76927+extern int gr_process_kernel_exec_ban(void);
76928+extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
76929+
76930 void __register_binfmt(struct linux_binfmt * fmt, int insert)
76931 {
76932 BUG_ON(!fmt);
76933 if (WARN_ON(!fmt->load_binary))
76934 return;
76935 write_lock(&binfmt_lock);
76936- insert ? list_add(&fmt->lh, &formats) :
76937- list_add_tail(&fmt->lh, &formats);
76938+ insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
76939+ pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
76940 write_unlock(&binfmt_lock);
76941 }
76942
76943@@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
76944 void unregister_binfmt(struct linux_binfmt * fmt)
76945 {
76946 write_lock(&binfmt_lock);
76947- list_del(&fmt->lh);
76948+ pax_list_del((struct list_head *)&fmt->lh);
76949 write_unlock(&binfmt_lock);
76950 }
76951
76952@@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
76953 int write)
76954 {
76955 struct page *page;
76956- int ret;
76957
76958-#ifdef CONFIG_STACK_GROWSUP
76959- if (write) {
76960- ret = expand_downwards(bprm->vma, pos);
76961- if (ret < 0)
76962- return NULL;
76963- }
76964-#endif
76965- ret = get_user_pages(current, bprm->mm, pos,
76966- 1, write, 1, &page, NULL);
76967- if (ret <= 0)
76968+ if (0 > expand_downwards(bprm->vma, pos))
76969+ return NULL;
76970+ if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
76971 return NULL;
76972
76973 if (write) {
76974@@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
76975 if (size <= ARG_MAX)
76976 return page;
76977
76978+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76979+ // only allow 512KB for argv+env on suid/sgid binaries
76980+ // to prevent easy ASLR exhaustion
76981+ if (((!uid_eq(bprm->cred->euid, current_euid())) ||
76982+ (!gid_eq(bprm->cred->egid, current_egid()))) &&
76983+ (size > (512 * 1024))) {
76984+ put_page(page);
76985+ return NULL;
76986+ }
76987+#endif
76988+
76989 /*
76990 * Limit to 1/4-th the stack size for the argv+env strings.
76991 * This ensures that:
76992@@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
76993 vma->vm_end = STACK_TOP_MAX;
76994 vma->vm_start = vma->vm_end - PAGE_SIZE;
76995 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
76996+
76997+#ifdef CONFIG_PAX_SEGMEXEC
76998+ vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
76999+#endif
77000+
77001 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
77002 INIT_LIST_HEAD(&vma->anon_vma_chain);
77003
77004@@ -280,6 +315,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
77005 arch_bprm_mm_init(mm, vma);
77006 up_write(&mm->mmap_sem);
77007 bprm->p = vma->vm_end - sizeof(void *);
77008+
77009+#ifdef CONFIG_PAX_RANDUSTACK
77010+ if (randomize_va_space)
77011+ bprm->p ^= prandom_u32() & ~PAGE_MASK;
77012+#endif
77013+
77014 return 0;
77015 err:
77016 up_write(&mm->mmap_sem);
77017@@ -396,7 +437,7 @@ struct user_arg_ptr {
77018 } ptr;
77019 };
77020
77021-static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
77022+const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
77023 {
77024 const char __user *native;
77025
77026@@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
77027 compat_uptr_t compat;
77028
77029 if (get_user(compat, argv.ptr.compat + nr))
77030- return ERR_PTR(-EFAULT);
77031+ return (const char __force_user *)ERR_PTR(-EFAULT);
77032
77033 return compat_ptr(compat);
77034 }
77035 #endif
77036
77037 if (get_user(native, argv.ptr.native + nr))
77038- return ERR_PTR(-EFAULT);
77039+ return (const char __force_user *)ERR_PTR(-EFAULT);
77040
77041 return native;
77042 }
77043@@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
77044 if (!p)
77045 break;
77046
77047- if (IS_ERR(p))
77048+ if (IS_ERR((const char __force_kernel *)p))
77049 return -EFAULT;
77050
77051 if (i >= max)
77052@@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
77053
77054 ret = -EFAULT;
77055 str = get_user_arg_ptr(argv, argc);
77056- if (IS_ERR(str))
77057+ if (IS_ERR((const char __force_kernel *)str))
77058 goto out;
77059
77060 len = strnlen_user(str, MAX_ARG_STRLEN);
77061@@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
77062 int r;
77063 mm_segment_t oldfs = get_fs();
77064 struct user_arg_ptr argv = {
77065- .ptr.native = (const char __user *const __user *)__argv,
77066+ .ptr.native = (const char __user * const __force_user *)__argv,
77067 };
77068
77069 set_fs(KERNEL_DS);
77070@@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
77071 unsigned long new_end = old_end - shift;
77072 struct mmu_gather tlb;
77073
77074- BUG_ON(new_start > new_end);
77075+ if (new_start >= new_end || new_start < mmap_min_addr)
77076+ return -ENOMEM;
77077
77078 /*
77079 * ensure there are no vmas between where we want to go
77080@@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
77081 if (vma != find_vma(mm, new_start))
77082 return -EFAULT;
77083
77084+#ifdef CONFIG_PAX_SEGMEXEC
77085+ BUG_ON(pax_find_mirror_vma(vma));
77086+#endif
77087+
77088 /*
77089 * cover the whole range: [new_start, old_end)
77090 */
77091@@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
77092 stack_top = arch_align_stack(stack_top);
77093 stack_top = PAGE_ALIGN(stack_top);
77094
77095- if (unlikely(stack_top < mmap_min_addr) ||
77096- unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
77097- return -ENOMEM;
77098-
77099 stack_shift = vma->vm_end - stack_top;
77100
77101 bprm->p -= stack_shift;
77102@@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
77103 bprm->exec -= stack_shift;
77104
77105 down_write(&mm->mmap_sem);
77106+
77107+ /* Move stack pages down in memory. */
77108+ if (stack_shift) {
77109+ ret = shift_arg_pages(vma, stack_shift);
77110+ if (ret)
77111+ goto out_unlock;
77112+ }
77113+
77114 vm_flags = VM_STACK_FLAGS;
77115
77116+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
77117+ if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
77118+ vm_flags &= ~VM_EXEC;
77119+
77120+#ifdef CONFIG_PAX_MPROTECT
77121+ if (mm->pax_flags & MF_PAX_MPROTECT)
77122+ vm_flags &= ~VM_MAYEXEC;
77123+#endif
77124+
77125+ }
77126+#endif
77127+
77128 /*
77129 * Adjust stack execute permissions; explicitly enable for
77130 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
77131@@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
77132 goto out_unlock;
77133 BUG_ON(prev != vma);
77134
77135- /* Move stack pages down in memory. */
77136- if (stack_shift) {
77137- ret = shift_arg_pages(vma, stack_shift);
77138- if (ret)
77139- goto out_unlock;
77140- }
77141-
77142 /* mprotect_fixup is overkill to remove the temporary stack flags */
77143 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
77144
77145@@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
77146 #endif
77147 current->mm->start_stack = bprm->p;
77148 ret = expand_stack(vma, stack_base);
77149+
77150+#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
77151+ if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
77152+ unsigned long size;
77153+ vm_flags_t vm_flags;
77154+
77155+ size = STACK_TOP - vma->vm_end;
77156+ vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
77157+
77158+ ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
77159+
77160+#ifdef CONFIG_X86
77161+ if (!ret) {
77162+ size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
77163+ ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
77164+ }
77165+#endif
77166+
77167+ }
77168+#endif
77169+
77170 if (ret)
77171 ret = -EFAULT;
77172
77173@@ -784,8 +860,10 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
77174 if (err)
77175 goto exit;
77176
77177- if (name->name[0] != '\0')
77178+ if (name->name[0] != '\0') {
77179 fsnotify_open(file);
77180+ trace_open_exec(name->name);
77181+ }
77182
77183 out:
77184 return file;
77185@@ -818,7 +896,7 @@ int kernel_read(struct file *file, loff_t offset,
77186 old_fs = get_fs();
77187 set_fs(get_ds());
77188 /* The cast to a user pointer is valid due to the set_fs() */
77189- result = vfs_read(file, (void __user *)addr, count, &pos);
77190+ result = vfs_read(file, (void __force_user *)addr, count, &pos);
77191 set_fs(old_fs);
77192 return result;
77193 }
77194@@ -863,6 +941,7 @@ static int exec_mmap(struct mm_struct *mm)
77195 tsk->mm = mm;
77196 tsk->active_mm = mm;
77197 activate_mm(active_mm, mm);
77198+ populate_stack();
77199 tsk->mm->vmacache_seqnum = 0;
77200 vmacache_flush(tsk);
77201 task_unlock(tsk);
77202@@ -1271,7 +1350,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm)
77203 }
77204 rcu_read_unlock();
77205
77206- if (p->fs->users > n_fs)
77207+ if (atomic_read(&p->fs->users) > n_fs)
77208 bprm->unsafe |= LSM_UNSAFE_SHARE;
77209 else
77210 p->fs->in_exec = 1;
77211@@ -1472,6 +1551,31 @@ static int exec_binprm(struct linux_binprm *bprm)
77212 return ret;
77213 }
77214
77215+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77216+static DEFINE_PER_CPU(u64, exec_counter);
77217+static int __init init_exec_counters(void)
77218+{
77219+ unsigned int cpu;
77220+
77221+ for_each_possible_cpu(cpu) {
77222+ per_cpu(exec_counter, cpu) = (u64)cpu;
77223+ }
77224+
77225+ return 0;
77226+}
77227+early_initcall(init_exec_counters);
77228+static inline void increment_exec_counter(void)
77229+{
77230+ BUILD_BUG_ON(NR_CPUS > (1 << 16));
77231+ current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
77232+}
77233+#else
77234+static inline void increment_exec_counter(void) {}
77235+#endif
77236+
77237+extern void gr_handle_exec_args(struct linux_binprm *bprm,
77238+ struct user_arg_ptr argv);
77239+
77240 /*
77241 * sys_execve() executes a new program.
77242 */
77243@@ -1480,6 +1584,11 @@ static int do_execveat_common(int fd, struct filename *filename,
77244 struct user_arg_ptr envp,
77245 int flags)
77246 {
77247+#ifdef CONFIG_GRKERNSEC
77248+ struct file *old_exec_file;
77249+ struct acl_subject_label *old_acl;
77250+ struct rlimit old_rlim[RLIM_NLIMITS];
77251+#endif
77252 char *pathbuf = NULL;
77253 struct linux_binprm *bprm;
77254 struct file *file;
77255@@ -1489,6 +1598,8 @@ static int do_execveat_common(int fd, struct filename *filename,
77256 if (IS_ERR(filename))
77257 return PTR_ERR(filename);
77258
77259+ gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
77260+
77261 /*
77262 * We move the actual failure in case of RLIMIT_NPROC excess from
77263 * set*uid() to execve() because too many poorly written programs
77264@@ -1526,6 +1637,11 @@ static int do_execveat_common(int fd, struct filename *filename,
77265 if (IS_ERR(file))
77266 goto out_unmark;
77267
77268+ if (gr_ptrace_readexec(file, bprm->unsafe)) {
77269+ retval = -EPERM;
77270+ goto out_unmark;
77271+ }
77272+
77273 sched_exec();
77274
77275 bprm->file = file;
77276@@ -1552,6 +1668,11 @@ static int do_execveat_common(int fd, struct filename *filename,
77277 }
77278 bprm->interp = bprm->filename;
77279
77280+ if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
77281+ retval = -EACCES;
77282+ goto out_unmark;
77283+ }
77284+
77285 retval = bprm_mm_init(bprm);
77286 if (retval)
77287 goto out_unmark;
77288@@ -1568,24 +1689,70 @@ static int do_execveat_common(int fd, struct filename *filename,
77289 if (retval < 0)
77290 goto out;
77291
77292+#ifdef CONFIG_GRKERNSEC
77293+ old_acl = current->acl;
77294+ memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
77295+ old_exec_file = current->exec_file;
77296+ get_file(file);
77297+ current->exec_file = file;
77298+#endif
77299+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77300+ /* limit suid stack to 8MB
77301+ * we saved the old limits above and will restore them if this exec fails
77302+ */
77303+ if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
77304+ (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
77305+ current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
77306+#endif
77307+
77308+ if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
77309+ retval = -EPERM;
77310+ goto out_fail;
77311+ }
77312+
77313+ if (!gr_tpe_allow(file)) {
77314+ retval = -EACCES;
77315+ goto out_fail;
77316+ }
77317+
77318+ if (gr_check_crash_exec(file)) {
77319+ retval = -EACCES;
77320+ goto out_fail;
77321+ }
77322+
77323+ retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
77324+ bprm->unsafe);
77325+ if (retval < 0)
77326+ goto out_fail;
77327+
77328 retval = copy_strings_kernel(1, &bprm->filename, bprm);
77329 if (retval < 0)
77330- goto out;
77331+ goto out_fail;
77332
77333 bprm->exec = bprm->p;
77334 retval = copy_strings(bprm->envc, envp, bprm);
77335 if (retval < 0)
77336- goto out;
77337+ goto out_fail;
77338
77339 retval = copy_strings(bprm->argc, argv, bprm);
77340 if (retval < 0)
77341- goto out;
77342+ goto out_fail;
77343+
77344+ gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
77345+
77346+ gr_handle_exec_args(bprm, argv);
77347
77348 retval = exec_binprm(bprm);
77349 if (retval < 0)
77350- goto out;
77351+ goto out_fail;
77352+#ifdef CONFIG_GRKERNSEC
77353+ if (old_exec_file)
77354+ fput(old_exec_file);
77355+#endif
77356
77357 /* execve succeeded */
77358+
77359+ increment_exec_counter();
77360 current->fs->in_exec = 0;
77361 current->in_execve = 0;
77362 acct_update_integrals(current);
77363@@ -1597,6 +1764,14 @@ static int do_execveat_common(int fd, struct filename *filename,
77364 put_files_struct(displaced);
77365 return retval;
77366
77367+out_fail:
77368+#ifdef CONFIG_GRKERNSEC
77369+ current->acl = old_acl;
77370+ memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
77371+ fput(current->exec_file);
77372+ current->exec_file = old_exec_file;
77373+#endif
77374+
77375 out:
77376 if (bprm->mm) {
77377 acct_arg_size(bprm, 0);
77378@@ -1743,3 +1918,324 @@ COMPAT_SYSCALL_DEFINE5(execveat, int, fd,
77379 argv, envp, flags);
77380 }
77381 #endif
77382+
77383+int pax_check_flags(unsigned long *flags)
77384+{
77385+ int retval = 0;
77386+
77387+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
77388+ if (*flags & MF_PAX_SEGMEXEC)
77389+ {
77390+ *flags &= ~MF_PAX_SEGMEXEC;
77391+ retval = -EINVAL;
77392+ }
77393+#endif
77394+
77395+ if ((*flags & MF_PAX_PAGEEXEC)
77396+
77397+#ifdef CONFIG_PAX_PAGEEXEC
77398+ && (*flags & MF_PAX_SEGMEXEC)
77399+#endif
77400+
77401+ )
77402+ {
77403+ *flags &= ~MF_PAX_PAGEEXEC;
77404+ retval = -EINVAL;
77405+ }
77406+
77407+ if ((*flags & MF_PAX_MPROTECT)
77408+
77409+#ifdef CONFIG_PAX_MPROTECT
77410+ && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
77411+#endif
77412+
77413+ )
77414+ {
77415+ *flags &= ~MF_PAX_MPROTECT;
77416+ retval = -EINVAL;
77417+ }
77418+
77419+ if ((*flags & MF_PAX_EMUTRAMP)
77420+
77421+#ifdef CONFIG_PAX_EMUTRAMP
77422+ && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
77423+#endif
77424+
77425+ )
77426+ {
77427+ *flags &= ~MF_PAX_EMUTRAMP;
77428+ retval = -EINVAL;
77429+ }
77430+
77431+ return retval;
77432+}
77433+
77434+EXPORT_SYMBOL(pax_check_flags);
77435+
77436+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
77437+char *pax_get_path(const struct path *path, char *buf, int buflen)
77438+{
77439+ char *pathname = d_path(path, buf, buflen);
77440+
77441+ if (IS_ERR(pathname))
77442+ goto toolong;
77443+
77444+ pathname = mangle_path(buf, pathname, "\t\n\\");
77445+ if (!pathname)
77446+ goto toolong;
77447+
77448+ *pathname = 0;
77449+ return buf;
77450+
77451+toolong:
77452+ return "<path too long>";
77453+}
77454+EXPORT_SYMBOL(pax_get_path);
77455+
77456+void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
77457+{
77458+ struct task_struct *tsk = current;
77459+ struct mm_struct *mm = current->mm;
77460+ char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
77461+ char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
77462+ char *path_exec = NULL;
77463+ char *path_fault = NULL;
77464+ unsigned long start = 0UL, end = 0UL, offset = 0UL;
77465+ siginfo_t info = { };
77466+
77467+ if (buffer_exec && buffer_fault) {
77468+ struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
77469+
77470+ down_read(&mm->mmap_sem);
77471+ vma = mm->mmap;
77472+ while (vma && (!vma_exec || !vma_fault)) {
77473+ if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
77474+ vma_exec = vma;
77475+ if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
77476+ vma_fault = vma;
77477+ vma = vma->vm_next;
77478+ }
77479+ if (vma_exec)
77480+ path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
77481+ if (vma_fault) {
77482+ start = vma_fault->vm_start;
77483+ end = vma_fault->vm_end;
77484+ offset = vma_fault->vm_pgoff << PAGE_SHIFT;
77485+ if (vma_fault->vm_file)
77486+ path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
77487+ else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
77488+ path_fault = "<heap>";
77489+ else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
77490+ path_fault = "<stack>";
77491+ else
77492+ path_fault = "<anonymous mapping>";
77493+ }
77494+ up_read(&mm->mmap_sem);
77495+ }
77496+ if (tsk->signal->curr_ip)
77497+ printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
77498+ else
77499+ printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
77500+ 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),
77501+ from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
77502+ free_page((unsigned long)buffer_exec);
77503+ free_page((unsigned long)buffer_fault);
77504+ pax_report_insns(regs, pc, sp);
77505+ info.si_signo = SIGKILL;
77506+ info.si_errno = 0;
77507+ info.si_code = SI_KERNEL;
77508+ info.si_pid = 0;
77509+ info.si_uid = 0;
77510+ do_coredump(&info);
77511+}
77512+#endif
77513+
77514+#ifdef CONFIG_PAX_REFCOUNT
77515+void pax_report_refcount_overflow(struct pt_regs *regs)
77516+{
77517+ if (current->signal->curr_ip)
77518+ printk(KERN_EMERG "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
77519+ &current->signal->curr_ip, current->comm, task_pid_nr(current),
77520+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
77521+ else
77522+ printk(KERN_EMERG "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
77523+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
77524+ print_symbol(KERN_EMERG "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
77525+ preempt_disable();
77526+ show_regs(regs);
77527+ preempt_enable();
77528+ force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
77529+}
77530+#endif
77531+
77532+#ifdef CONFIG_PAX_USERCOPY
77533+/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
77534+static noinline int check_stack_object(const void *obj, unsigned long len)
77535+{
77536+ const void * const stack = task_stack_page(current);
77537+ const void * const stackend = stack + THREAD_SIZE;
77538+
77539+#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
77540+ const void *frame = NULL;
77541+ const void *oldframe;
77542+#endif
77543+
77544+ if (obj + len < obj)
77545+ return -1;
77546+
77547+ if (obj + len <= stack || stackend <= obj)
77548+ return 0;
77549+
77550+ if (obj < stack || stackend < obj + len)
77551+ return -1;
77552+
77553+#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
77554+ oldframe = __builtin_frame_address(1);
77555+ if (oldframe)
77556+ frame = __builtin_frame_address(2);
77557+ /*
77558+ low ----------------------------------------------> high
77559+ [saved bp][saved ip][args][local vars][saved bp][saved ip]
77560+ ^----------------^
77561+ allow copies only within here
77562+ */
77563+ while (stack <= frame && frame < stackend) {
77564+ /* if obj + len extends past the last frame, this
77565+ check won't pass and the next frame will be 0,
77566+ causing us to bail out and correctly report
77567+ the copy as invalid
77568+ */
77569+ if (obj + len <= frame)
77570+ return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
77571+ oldframe = frame;
77572+ frame = *(const void * const *)frame;
77573+ }
77574+ return -1;
77575+#else
77576+ return 1;
77577+#endif
77578+}
77579+
77580+static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
77581+{
77582+ if (current->signal->curr_ip)
77583+ printk(KERN_EMERG "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
77584+ &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
77585+ else
77586+ printk(KERN_EMERG "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
77587+ to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
77588+ dump_stack();
77589+ gr_handle_kernel_exploit();
77590+ do_group_exit(SIGKILL);
77591+}
77592+#endif
77593+
77594+#ifdef CONFIG_PAX_USERCOPY
77595+
77596+static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
77597+{
77598+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
77599+ unsigned long textlow = ktla_ktva((unsigned long)_stext);
77600+#ifdef CONFIG_MODULES
77601+ unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
77602+#else
77603+ unsigned long texthigh = ktla_ktva((unsigned long)_etext);
77604+#endif
77605+
77606+#else
77607+ unsigned long textlow = (unsigned long)_stext;
77608+ unsigned long texthigh = (unsigned long)_etext;
77609+
77610+#ifdef CONFIG_X86_64
77611+ /* check against linear mapping as well */
77612+ if (high > (unsigned long)__va(__pa(textlow)) &&
77613+ low < (unsigned long)__va(__pa(texthigh)))
77614+ return true;
77615+#endif
77616+
77617+#endif
77618+
77619+ if (high <= textlow || low >= texthigh)
77620+ return false;
77621+ else
77622+ return true;
77623+}
77624+#endif
77625+
77626+void __check_object_size(const void *ptr, unsigned long n, bool to_user, bool const_size)
77627+{
77628+#ifdef CONFIG_PAX_USERCOPY
77629+ const char *type;
77630+#endif
77631+
77632+#if !defined(CONFIG_STACK_GROWSUP) && !defined(CONFIG_X86_64)
77633+ unsigned long stackstart = (unsigned long)task_stack_page(current);
77634+ unsigned long currentsp = (unsigned long)&stackstart;
77635+ if (unlikely((currentsp < stackstart + 512 ||
77636+ currentsp >= stackstart + THREAD_SIZE) && !in_interrupt()))
77637+ BUG();
77638+#endif
77639+
77640+#ifndef CONFIG_PAX_USERCOPY_DEBUG
77641+ if (const_size)
77642+ return;
77643+#endif
77644+
77645+#ifdef CONFIG_PAX_USERCOPY
77646+ if (!n)
77647+ return;
77648+
77649+ type = check_heap_object(ptr, n);
77650+ if (!type) {
77651+ int ret = check_stack_object(ptr, n);
77652+ if (ret == 1 || ret == 2)
77653+ return;
77654+ if (ret == 0) {
77655+ if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
77656+ type = "<kernel text>";
77657+ else
77658+ return;
77659+ } else
77660+ type = "<process stack>";
77661+ }
77662+
77663+ pax_report_usercopy(ptr, n, to_user, type);
77664+#endif
77665+
77666+}
77667+EXPORT_SYMBOL(__check_object_size);
77668+
77669+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
77670+void __used pax_track_stack(void)
77671+{
77672+ unsigned long sp = (unsigned long)&sp;
77673+ if (sp < current_thread_info()->lowest_stack &&
77674+ sp >= (unsigned long)task_stack_page(current) + 2 * sizeof(unsigned long))
77675+ current_thread_info()->lowest_stack = sp;
77676+ if (unlikely((sp & ~(THREAD_SIZE - 1)) < (THREAD_SIZE/16)))
77677+ BUG();
77678+}
77679+EXPORT_SYMBOL(pax_track_stack);
77680+#endif
77681+
77682+#ifdef CONFIG_PAX_SIZE_OVERFLOW
77683+
77684+#ifdef CONFIG_PAX_SIZE_OVERFLOW_DISABLE_KILL
77685+static DEFINE_RATELIMIT_STATE(size_overflow_ratelimit, 15 * HZ, 3);
77686+#endif
77687+
77688+void __nocapture(1, 3, 4) __used report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
77689+{
77690+#ifdef CONFIG_PAX_SIZE_OVERFLOW_DISABLE_KILL
77691+ if (__ratelimit(&size_overflow_ratelimit)) {
77692+ printk(KERN_EMERG "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
77693+ dump_stack();
77694+ }
77695+#else
77696+ printk(KERN_EMERG "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
77697+ dump_stack();
77698+ do_group_exit(SIGKILL);
77699+#endif
77700+}
77701+EXPORT_SYMBOL(report_size_overflow);
77702+#endif
77703diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
77704index 9f9992b..8b59411 100644
77705--- a/fs/ext2/balloc.c
77706+++ b/fs/ext2/balloc.c
77707@@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
77708
77709 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
77710 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
77711- if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
77712+ if (free_blocks < root_blocks + 1 &&
77713 !uid_eq(sbi->s_resuid, current_fsuid()) &&
77714 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
77715- !in_group_p (sbi->s_resgid))) {
77716+ !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
77717 return 0;
77718 }
77719 return 1;
77720diff --git a/fs/ext2/super.c b/fs/ext2/super.c
77721index 900e19c..f7dc2b8 100644
77722--- a/fs/ext2/super.c
77723+++ b/fs/ext2/super.c
77724@@ -267,10 +267,8 @@ static int ext2_show_options(struct seq_file *seq, struct dentry *root)
77725 #ifdef CONFIG_EXT2_FS_XATTR
77726 if (test_opt(sb, XATTR_USER))
77727 seq_puts(seq, ",user_xattr");
77728- if (!test_opt(sb, XATTR_USER) &&
77729- (def_mount_opts & EXT2_DEFM_XATTR_USER)) {
77730+ if (!test_opt(sb, XATTR_USER))
77731 seq_puts(seq, ",nouser_xattr");
77732- }
77733 #endif
77734
77735 #ifdef CONFIG_EXT2_FS_POSIX_ACL
77736@@ -856,8 +854,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
77737 if (def_mount_opts & EXT2_DEFM_UID16)
77738 set_opt(sbi->s_mount_opt, NO_UID32);
77739 #ifdef CONFIG_EXT2_FS_XATTR
77740- if (def_mount_opts & EXT2_DEFM_XATTR_USER)
77741- set_opt(sbi->s_mount_opt, XATTR_USER);
77742+ /* always enable user xattrs */
77743+ set_opt(sbi->s_mount_opt, XATTR_USER);
77744 #endif
77745 #ifdef CONFIG_EXT2_FS_POSIX_ACL
77746 if (def_mount_opts & EXT2_DEFM_ACL)
77747diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
77748index 0b6bfd3..93a2964 100644
77749--- a/fs/ext2/xattr.c
77750+++ b/fs/ext2/xattr.c
77751@@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
77752 struct buffer_head *bh = NULL;
77753 struct ext2_xattr_entry *entry;
77754 char *end;
77755- size_t rest = buffer_size;
77756+ size_t rest = buffer_size, total_size = 0;
77757 int error;
77758
77759 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
77760@@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
77761 buffer += size;
77762 }
77763 rest -= size;
77764+ total_size += size;
77765 }
77766 }
77767- error = buffer_size - rest; /* total size */
77768+ error = total_size;
77769
77770 cleanup:
77771 brelse(bh);
77772diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
77773index 158b5d4..2432610 100644
77774--- a/fs/ext3/balloc.c
77775+++ b/fs/ext3/balloc.c
77776@@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
77777
77778 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
77779 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
77780- if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
77781+ if (free_blocks < root_blocks + 1 &&
77782 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
77783 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
77784- !in_group_p (sbi->s_resgid))) {
77785+ !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
77786 return 0;
77787 }
77788 return 1;
77789diff --git a/fs/ext3/super.c b/fs/ext3/super.c
77790index 5ed0044..656e3d2 100644
77791--- a/fs/ext3/super.c
77792+++ b/fs/ext3/super.c
77793@@ -655,10 +655,8 @@ static int ext3_show_options(struct seq_file *seq, struct dentry *root)
77794 #ifdef CONFIG_EXT3_FS_XATTR
77795 if (test_opt(sb, XATTR_USER))
77796 seq_puts(seq, ",user_xattr");
77797- if (!test_opt(sb, XATTR_USER) &&
77798- (def_mount_opts & EXT3_DEFM_XATTR_USER)) {
77799+ if (!test_opt(sb, XATTR_USER))
77800 seq_puts(seq, ",nouser_xattr");
77801- }
77802 #endif
77803 #ifdef CONFIG_EXT3_FS_POSIX_ACL
77804 if (test_opt(sb, POSIX_ACL))
77805@@ -1760,8 +1758,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
77806 if (def_mount_opts & EXT3_DEFM_UID16)
77807 set_opt(sbi->s_mount_opt, NO_UID32);
77808 #ifdef CONFIG_EXT3_FS_XATTR
77809- if (def_mount_opts & EXT3_DEFM_XATTR_USER)
77810- set_opt(sbi->s_mount_opt, XATTR_USER);
77811+ /* always enable user xattrs */
77812+ set_opt(sbi->s_mount_opt, XATTR_USER);
77813 #endif
77814 #ifdef CONFIG_EXT3_FS_POSIX_ACL
77815 if (def_mount_opts & EXT3_DEFM_ACL)
77816diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
77817index 7cf3650..e3f4a51 100644
77818--- a/fs/ext3/xattr.c
77819+++ b/fs/ext3/xattr.c
77820@@ -330,7 +330,7 @@ static int
77821 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
77822 char *buffer, size_t buffer_size)
77823 {
77824- size_t rest = buffer_size;
77825+ size_t rest = buffer_size, total_size = 0;
77826
77827 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
77828 const struct xattr_handler *handler =
77829@@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
77830 buffer += size;
77831 }
77832 rest -= size;
77833+ total_size += size;
77834 }
77835 }
77836- return buffer_size - rest;
77837+ return total_size;
77838 }
77839
77840 static int
77841diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
77842index cd6ea29..1cd2a97 100644
77843--- a/fs/ext4/balloc.c
77844+++ b/fs/ext4/balloc.c
77845@@ -556,8 +556,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
77846 /* Hm, nope. Are (enough) root reserved clusters available? */
77847 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
77848 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
77849- capable(CAP_SYS_RESOURCE) ||
77850- (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
77851+ (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
77852+ capable_nolog(CAP_SYS_RESOURCE)) {
77853
77854 if (free_clusters >= (nclusters + dirty_clusters +
77855 resv_clusters))
77856diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
77857index f5e9f04..91296b9 100644
77858--- a/fs/ext4/ext4.h
77859+++ b/fs/ext4/ext4.h
77860@@ -1305,19 +1305,19 @@ struct ext4_sb_info {
77861 unsigned long s_mb_last_start;
77862
77863 /* stats for buddy allocator */
77864- atomic_t s_bal_reqs; /* number of reqs with len > 1 */
77865- atomic_t s_bal_success; /* we found long enough chunks */
77866- atomic_t s_bal_allocated; /* in blocks */
77867- atomic_t s_bal_ex_scanned; /* total extents scanned */
77868- atomic_t s_bal_goals; /* goal hits */
77869- atomic_t s_bal_breaks; /* too long searches */
77870- atomic_t s_bal_2orders; /* 2^order hits */
77871+ atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
77872+ atomic_unchecked_t s_bal_success; /* we found long enough chunks */
77873+ atomic_unchecked_t s_bal_allocated; /* in blocks */
77874+ atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
77875+ atomic_unchecked_t s_bal_goals; /* goal hits */
77876+ atomic_unchecked_t s_bal_breaks; /* too long searches */
77877+ atomic_unchecked_t s_bal_2orders; /* 2^order hits */
77878 spinlock_t s_bal_lock;
77879 unsigned long s_mb_buddies_generated;
77880 unsigned long long s_mb_generation_time;
77881- atomic_t s_mb_lost_chunks;
77882- atomic_t s_mb_preallocated;
77883- atomic_t s_mb_discarded;
77884+ atomic_unchecked_t s_mb_lost_chunks;
77885+ atomic_unchecked_t s_mb_preallocated;
77886+ atomic_unchecked_t s_mb_discarded;
77887 atomic_t s_lock_busy;
77888
77889 /* locality groups */
77890diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
77891index 34b610e..ecc47cb 100644
77892--- a/fs/ext4/mballoc.c
77893+++ b/fs/ext4/mballoc.c
77894@@ -1905,7 +1905,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
77895 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
77896
77897 if (EXT4_SB(sb)->s_mb_stats)
77898- atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
77899+ atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
77900
77901 break;
77902 }
77903@@ -2228,7 +2228,7 @@ repeat:
77904 ac->ac_status = AC_STATUS_CONTINUE;
77905 ac->ac_flags |= EXT4_MB_HINT_FIRST;
77906 cr = 3;
77907- atomic_inc(&sbi->s_mb_lost_chunks);
77908+ atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
77909 goto repeat;
77910 }
77911 }
77912@@ -2732,25 +2732,25 @@ int ext4_mb_release(struct super_block *sb)
77913 if (sbi->s_mb_stats) {
77914 ext4_msg(sb, KERN_INFO,
77915 "mballoc: %u blocks %u reqs (%u success)",
77916- atomic_read(&sbi->s_bal_allocated),
77917- atomic_read(&sbi->s_bal_reqs),
77918- atomic_read(&sbi->s_bal_success));
77919+ atomic_read_unchecked(&sbi->s_bal_allocated),
77920+ atomic_read_unchecked(&sbi->s_bal_reqs),
77921+ atomic_read_unchecked(&sbi->s_bal_success));
77922 ext4_msg(sb, KERN_INFO,
77923 "mballoc: %u extents scanned, %u goal hits, "
77924 "%u 2^N hits, %u breaks, %u lost",
77925- atomic_read(&sbi->s_bal_ex_scanned),
77926- atomic_read(&sbi->s_bal_goals),
77927- atomic_read(&sbi->s_bal_2orders),
77928- atomic_read(&sbi->s_bal_breaks),
77929- atomic_read(&sbi->s_mb_lost_chunks));
77930+ atomic_read_unchecked(&sbi->s_bal_ex_scanned),
77931+ atomic_read_unchecked(&sbi->s_bal_goals),
77932+ atomic_read_unchecked(&sbi->s_bal_2orders),
77933+ atomic_read_unchecked(&sbi->s_bal_breaks),
77934+ atomic_read_unchecked(&sbi->s_mb_lost_chunks));
77935 ext4_msg(sb, KERN_INFO,
77936 "mballoc: %lu generated and it took %Lu",
77937 sbi->s_mb_buddies_generated,
77938 sbi->s_mb_generation_time);
77939 ext4_msg(sb, KERN_INFO,
77940 "mballoc: %u preallocated, %u discarded",
77941- atomic_read(&sbi->s_mb_preallocated),
77942- atomic_read(&sbi->s_mb_discarded));
77943+ atomic_read_unchecked(&sbi->s_mb_preallocated),
77944+ atomic_read_unchecked(&sbi->s_mb_discarded));
77945 }
77946
77947 free_percpu(sbi->s_locality_groups);
77948@@ -3206,16 +3206,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
77949 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
77950
77951 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
77952- atomic_inc(&sbi->s_bal_reqs);
77953- atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
77954+ atomic_inc_unchecked(&sbi->s_bal_reqs);
77955+ atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
77956 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
77957- atomic_inc(&sbi->s_bal_success);
77958- atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
77959+ atomic_inc_unchecked(&sbi->s_bal_success);
77960+ atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
77961 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
77962 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
77963- atomic_inc(&sbi->s_bal_goals);
77964+ atomic_inc_unchecked(&sbi->s_bal_goals);
77965 if (ac->ac_found > sbi->s_mb_max_to_scan)
77966- atomic_inc(&sbi->s_bal_breaks);
77967+ atomic_inc_unchecked(&sbi->s_bal_breaks);
77968 }
77969
77970 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
77971@@ -3642,7 +3642,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
77972 trace_ext4_mb_new_inode_pa(ac, pa);
77973
77974 ext4_mb_use_inode_pa(ac, pa);
77975- atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
77976+ atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
77977
77978 ei = EXT4_I(ac->ac_inode);
77979 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
77980@@ -3702,7 +3702,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
77981 trace_ext4_mb_new_group_pa(ac, pa);
77982
77983 ext4_mb_use_group_pa(ac, pa);
77984- atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
77985+ atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
77986
77987 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
77988 lg = ac->ac_lg;
77989@@ -3791,7 +3791,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
77990 * from the bitmap and continue.
77991 */
77992 }
77993- atomic_add(free, &sbi->s_mb_discarded);
77994+ atomic_add_unchecked(free, &sbi->s_mb_discarded);
77995
77996 return err;
77997 }
77998@@ -3809,7 +3809,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
77999 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
78000 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
78001 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
78002- atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
78003+ atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
78004 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
78005
78006 return 0;
78007diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
78008index 8313ca3..8a37d08 100644
78009--- a/fs/ext4/mmp.c
78010+++ b/fs/ext4/mmp.c
78011@@ -111,7 +111,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
78012 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
78013 const char *function, unsigned int line, const char *msg)
78014 {
78015- __ext4_warning(sb, function, line, msg);
78016+ __ext4_warning(sb, function, line, "%s", msg);
78017 __ext4_warning(sb, function, line,
78018 "MMP failure info: last update time: %llu, last update "
78019 "node: %s, last update device: %s\n",
78020diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
78021index cf0c472..ddf284d 100644
78022--- a/fs/ext4/resize.c
78023+++ b/fs/ext4/resize.c
78024@@ -413,7 +413,7 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
78025
78026 ext4_debug("mark blocks [%llu/%u] used\n", block, count);
78027 for (count2 = count; count > 0; count -= count2, block += count2) {
78028- ext4_fsblk_t start;
78029+ ext4_fsblk_t start, diff;
78030 struct buffer_head *bh;
78031 ext4_group_t group;
78032 int err;
78033@@ -422,10 +422,6 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
78034 start = ext4_group_first_block_no(sb, group);
78035 group -= flex_gd->groups[0].group;
78036
78037- count2 = EXT4_BLOCKS_PER_GROUP(sb) - (block - start);
78038- if (count2 > count)
78039- count2 = count;
78040-
78041 if (flex_gd->bg_flags[group] & EXT4_BG_BLOCK_UNINIT) {
78042 BUG_ON(flex_gd->count > 1);
78043 continue;
78044@@ -443,9 +439,15 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
78045 err = ext4_journal_get_write_access(handle, bh);
78046 if (err)
78047 return err;
78048+
78049+ diff = block - start;
78050+ count2 = EXT4_BLOCKS_PER_GROUP(sb) - diff;
78051+ if (count2 > count)
78052+ count2 = count;
78053+
78054 ext4_debug("mark block bitmap %#04llx (+%llu/%u)\n", block,
78055- block - start, count2);
78056- ext4_set_bits(bh->b_data, block - start, count2);
78057+ diff, count2);
78058+ ext4_set_bits(bh->b_data, diff, count2);
78059
78060 err = ext4_handle_dirty_metadata(handle, NULL, bh);
78061 if (unlikely(err))
78062diff --git a/fs/ext4/super.c b/fs/ext4/super.c
78063index a5e8c74..a7711a8 100644
78064--- a/fs/ext4/super.c
78065+++ b/fs/ext4/super.c
78066@@ -1274,7 +1274,7 @@ static ext4_fsblk_t get_sb_block(void **data)
78067 }
78068
78069 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
78070-static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
78071+static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
78072 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
78073
78074 #ifdef CONFIG_QUOTA
78075@@ -2484,7 +2484,7 @@ struct ext4_attr {
78076 int offset;
78077 int deprecated_val;
78078 } u;
78079-};
78080+} __do_const;
78081
78082 static int parse_strtoull(const char *buf,
78083 unsigned long long max, unsigned long long *value)
78084diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
78085index 16e28c0..728c282 100644
78086--- a/fs/ext4/xattr.c
78087+++ b/fs/ext4/xattr.c
78088@@ -398,7 +398,7 @@ static int
78089 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
78090 char *buffer, size_t buffer_size)
78091 {
78092- size_t rest = buffer_size;
78093+ size_t rest = buffer_size, total_size = 0;
78094
78095 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
78096 const struct xattr_handler *handler =
78097@@ -415,9 +415,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
78098 buffer += size;
78099 }
78100 rest -= size;
78101+ total_size += size;
78102 }
78103 }
78104- return buffer_size - rest;
78105+ return total_size;
78106 }
78107
78108 static int
78109diff --git a/fs/fcntl.c b/fs/fcntl.c
78110index ee85cd4..9dd0d20 100644
78111--- a/fs/fcntl.c
78112+++ b/fs/fcntl.c
78113@@ -102,6 +102,10 @@ void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
78114 int force)
78115 {
78116 security_file_set_fowner(filp);
78117+ if (gr_handle_chroot_fowner(pid, type))
78118+ return;
78119+ if (gr_check_protected_task_fowner(pid, type))
78120+ return;
78121 f_modown(filp, pid, type, force);
78122 }
78123 EXPORT_SYMBOL(__f_setown);
78124diff --git a/fs/fhandle.c b/fs/fhandle.c
78125index d59712d..2281df9 100644
78126--- a/fs/fhandle.c
78127+++ b/fs/fhandle.c
78128@@ -8,6 +8,7 @@
78129 #include <linux/fs_struct.h>
78130 #include <linux/fsnotify.h>
78131 #include <linux/personality.h>
78132+#include <linux/grsecurity.h>
78133 #include <asm/uaccess.h>
78134 #include "internal.h"
78135 #include "mount.h"
78136@@ -67,8 +68,7 @@ static long do_sys_name_to_handle(struct path *path,
78137 } else
78138 retval = 0;
78139 /* copy the mount id */
78140- if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
78141- sizeof(*mnt_id)) ||
78142+ if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
78143 copy_to_user(ufh, handle,
78144 sizeof(struct file_handle) + handle_bytes))
78145 retval = -EFAULT;
78146@@ -175,7 +175,7 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh,
78147 * the directory. Ideally we would like CAP_DAC_SEARCH.
78148 * But we don't have that
78149 */
78150- if (!capable(CAP_DAC_READ_SEARCH)) {
78151+ if (!capable(CAP_DAC_READ_SEARCH) || !gr_chroot_fhandle()) {
78152 retval = -EPERM;
78153 goto out_err;
78154 }
78155diff --git a/fs/file.c b/fs/file.c
78156index 6c672ad..bf787b0 100644
78157--- a/fs/file.c
78158+++ b/fs/file.c
78159@@ -16,6 +16,7 @@
78160 #include <linux/slab.h>
78161 #include <linux/vmalloc.h>
78162 #include <linux/file.h>
78163+#include <linux/security.h>
78164 #include <linux/fdtable.h>
78165 #include <linux/bitops.h>
78166 #include <linux/interrupt.h>
78167@@ -139,7 +140,7 @@ out:
78168 * Return <0 error code on error; 1 on successful completion.
78169 * The files->file_lock should be held on entry, and will be held on exit.
78170 */
78171-static int expand_fdtable(struct files_struct *files, int nr)
78172+static int expand_fdtable(struct files_struct *files, unsigned int nr)
78173 __releases(files->file_lock)
78174 __acquires(files->file_lock)
78175 {
78176@@ -184,7 +185,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
78177 * expanded and execution may have blocked.
78178 * The files->file_lock should be held on entry, and will be held on exit.
78179 */
78180-static int expand_files(struct files_struct *files, int nr)
78181+static int expand_files(struct files_struct *files, unsigned int nr)
78182 __releases(files->file_lock)
78183 __acquires(files->file_lock)
78184 {
78185@@ -834,6 +835,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
78186 if (!file)
78187 return __close_fd(files, fd);
78188
78189+ gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
78190 if (fd >= rlimit(RLIMIT_NOFILE))
78191 return -EBADF;
78192
78193@@ -860,6 +862,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
78194 if (unlikely(oldfd == newfd))
78195 return -EINVAL;
78196
78197+ gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
78198 if (newfd >= rlimit(RLIMIT_NOFILE))
78199 return -EBADF;
78200
78201@@ -915,6 +918,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
78202 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
78203 {
78204 int err;
78205+ gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
78206 if (from >= rlimit(RLIMIT_NOFILE))
78207 return -EINVAL;
78208 err = alloc_fd(from, flags);
78209diff --git a/fs/filesystems.c b/fs/filesystems.c
78210index 5797d45..7d7d79a 100644
78211--- a/fs/filesystems.c
78212+++ b/fs/filesystems.c
78213@@ -275,7 +275,11 @@ struct file_system_type *get_fs_type(const char *name)
78214 int len = dot ? dot - name : strlen(name);
78215
78216 fs = __get_fs_type(name, len);
78217+#ifdef CONFIG_GRKERNSEC_MODHARDEN
78218+ if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
78219+#else
78220 if (!fs && (request_module("fs-%.*s", len, name) == 0))
78221+#endif
78222 fs = __get_fs_type(name, len);
78223
78224 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
78225diff --git a/fs/fs_struct.c b/fs/fs_struct.c
78226index 7dca743..1ff87ae 100644
78227--- a/fs/fs_struct.c
78228+++ b/fs/fs_struct.c
78229@@ -4,6 +4,7 @@
78230 #include <linux/path.h>
78231 #include <linux/slab.h>
78232 #include <linux/fs_struct.h>
78233+#include <linux/grsecurity.h>
78234 #include "internal.h"
78235
78236 /*
78237@@ -15,14 +16,18 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
78238 struct path old_root;
78239
78240 path_get(path);
78241+ gr_inc_chroot_refcnts(path->dentry, path->mnt);
78242 spin_lock(&fs->lock);
78243 write_seqcount_begin(&fs->seq);
78244 old_root = fs->root;
78245 fs->root = *path;
78246+ gr_set_chroot_entries(current, path);
78247 write_seqcount_end(&fs->seq);
78248 spin_unlock(&fs->lock);
78249- if (old_root.dentry)
78250+ if (old_root.dentry) {
78251+ gr_dec_chroot_refcnts(old_root.dentry, old_root.mnt);
78252 path_put(&old_root);
78253+ }
78254 }
78255
78256 /*
78257@@ -67,6 +72,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
78258 int hits = 0;
78259 spin_lock(&fs->lock);
78260 write_seqcount_begin(&fs->seq);
78261+ /* this root replacement is only done by pivot_root,
78262+ leave grsec's chroot tagging alone for this task
78263+ so that a pivoted root isn't treated as a chroot
78264+ */
78265 hits += replace_path(&fs->root, old_root, new_root);
78266 hits += replace_path(&fs->pwd, old_root, new_root);
78267 write_seqcount_end(&fs->seq);
78268@@ -85,6 +94,7 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
78269
78270 void free_fs_struct(struct fs_struct *fs)
78271 {
78272+ gr_dec_chroot_refcnts(fs->root.dentry, fs->root.mnt);
78273 path_put(&fs->root);
78274 path_put(&fs->pwd);
78275 kmem_cache_free(fs_cachep, fs);
78276@@ -99,7 +109,8 @@ void exit_fs(struct task_struct *tsk)
78277 task_lock(tsk);
78278 spin_lock(&fs->lock);
78279 tsk->fs = NULL;
78280- kill = !--fs->users;
78281+ gr_clear_chroot_entries(tsk);
78282+ kill = !atomic_dec_return(&fs->users);
78283 spin_unlock(&fs->lock);
78284 task_unlock(tsk);
78285 if (kill)
78286@@ -112,7 +123,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
78287 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
78288 /* We don't need to lock fs - think why ;-) */
78289 if (fs) {
78290- fs->users = 1;
78291+ atomic_set(&fs->users, 1);
78292 fs->in_exec = 0;
78293 spin_lock_init(&fs->lock);
78294 seqcount_init(&fs->seq);
78295@@ -121,9 +132,13 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
78296 spin_lock(&old->lock);
78297 fs->root = old->root;
78298 path_get(&fs->root);
78299+ /* instead of calling gr_set_chroot_entries here,
78300+ we call it from every caller of this function
78301+ */
78302 fs->pwd = old->pwd;
78303 path_get(&fs->pwd);
78304 spin_unlock(&old->lock);
78305+ gr_inc_chroot_refcnts(fs->root.dentry, fs->root.mnt);
78306 }
78307 return fs;
78308 }
78309@@ -139,8 +154,9 @@ int unshare_fs_struct(void)
78310
78311 task_lock(current);
78312 spin_lock(&fs->lock);
78313- kill = !--fs->users;
78314+ kill = !atomic_dec_return(&fs->users);
78315 current->fs = new_fs;
78316+ gr_set_chroot_entries(current, &new_fs->root);
78317 spin_unlock(&fs->lock);
78318 task_unlock(current);
78319
78320@@ -153,13 +169,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
78321
78322 int current_umask(void)
78323 {
78324- return current->fs->umask;
78325+ return current->fs->umask | gr_acl_umask();
78326 }
78327 EXPORT_SYMBOL(current_umask);
78328
78329 /* to be mentioned only in INIT_TASK */
78330 struct fs_struct init_fs = {
78331- .users = 1,
78332+ .users = ATOMIC_INIT(1),
78333 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
78334 .seq = SEQCNT_ZERO(init_fs.seq),
78335 .umask = 0022,
78336diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
78337index d403c69..30be0a9 100644
78338--- a/fs/fscache/cookie.c
78339+++ b/fs/fscache/cookie.c
78340@@ -19,7 +19,7 @@
78341
78342 struct kmem_cache *fscache_cookie_jar;
78343
78344-static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
78345+static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
78346
78347 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
78348 static int fscache_alloc_object(struct fscache_cache *cache,
78349@@ -69,11 +69,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
78350 parent ? (char *) parent->def->name : "<no-parent>",
78351 def->name, netfs_data, enable);
78352
78353- fscache_stat(&fscache_n_acquires);
78354+ fscache_stat_unchecked(&fscache_n_acquires);
78355
78356 /* if there's no parent cookie, then we don't create one here either */
78357 if (!parent) {
78358- fscache_stat(&fscache_n_acquires_null);
78359+ fscache_stat_unchecked(&fscache_n_acquires_null);
78360 _leave(" [no parent]");
78361 return NULL;
78362 }
78363@@ -88,7 +88,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
78364 /* allocate and initialise a cookie */
78365 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
78366 if (!cookie) {
78367- fscache_stat(&fscache_n_acquires_oom);
78368+ fscache_stat_unchecked(&fscache_n_acquires_oom);
78369 _leave(" [ENOMEM]");
78370 return NULL;
78371 }
78372@@ -115,13 +115,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
78373
78374 switch (cookie->def->type) {
78375 case FSCACHE_COOKIE_TYPE_INDEX:
78376- fscache_stat(&fscache_n_cookie_index);
78377+ fscache_stat_unchecked(&fscache_n_cookie_index);
78378 break;
78379 case FSCACHE_COOKIE_TYPE_DATAFILE:
78380- fscache_stat(&fscache_n_cookie_data);
78381+ fscache_stat_unchecked(&fscache_n_cookie_data);
78382 break;
78383 default:
78384- fscache_stat(&fscache_n_cookie_special);
78385+ fscache_stat_unchecked(&fscache_n_cookie_special);
78386 break;
78387 }
78388
78389@@ -135,7 +135,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
78390 } else {
78391 atomic_dec(&parent->n_children);
78392 __fscache_cookie_put(cookie);
78393- fscache_stat(&fscache_n_acquires_nobufs);
78394+ fscache_stat_unchecked(&fscache_n_acquires_nobufs);
78395 _leave(" = NULL");
78396 return NULL;
78397 }
78398@@ -144,7 +144,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
78399 }
78400 }
78401
78402- fscache_stat(&fscache_n_acquires_ok);
78403+ fscache_stat_unchecked(&fscache_n_acquires_ok);
78404 _leave(" = %p", cookie);
78405 return cookie;
78406 }
78407@@ -213,7 +213,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
78408 cache = fscache_select_cache_for_object(cookie->parent);
78409 if (!cache) {
78410 up_read(&fscache_addremove_sem);
78411- fscache_stat(&fscache_n_acquires_no_cache);
78412+ fscache_stat_unchecked(&fscache_n_acquires_no_cache);
78413 _leave(" = -ENOMEDIUM [no cache]");
78414 return -ENOMEDIUM;
78415 }
78416@@ -297,14 +297,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
78417 object = cache->ops->alloc_object(cache, cookie);
78418 fscache_stat_d(&fscache_n_cop_alloc_object);
78419 if (IS_ERR(object)) {
78420- fscache_stat(&fscache_n_object_no_alloc);
78421+ fscache_stat_unchecked(&fscache_n_object_no_alloc);
78422 ret = PTR_ERR(object);
78423 goto error;
78424 }
78425
78426- fscache_stat(&fscache_n_object_alloc);
78427+ fscache_stat_unchecked(&fscache_n_object_alloc);
78428
78429- object->debug_id = atomic_inc_return(&fscache_object_debug_id);
78430+ object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
78431
78432 _debug("ALLOC OBJ%x: %s {%lx}",
78433 object->debug_id, cookie->def->name, object->events);
78434@@ -419,7 +419,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
78435
78436 _enter("{%s}", cookie->def->name);
78437
78438- fscache_stat(&fscache_n_invalidates);
78439+ fscache_stat_unchecked(&fscache_n_invalidates);
78440
78441 /* Only permit invalidation of data files. Invalidating an index will
78442 * require the caller to release all its attachments to the tree rooted
78443@@ -477,10 +477,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
78444 {
78445 struct fscache_object *object;
78446
78447- fscache_stat(&fscache_n_updates);
78448+ fscache_stat_unchecked(&fscache_n_updates);
78449
78450 if (!cookie) {
78451- fscache_stat(&fscache_n_updates_null);
78452+ fscache_stat_unchecked(&fscache_n_updates_null);
78453 _leave(" [no cookie]");
78454 return;
78455 }
78456@@ -581,12 +581,12 @@ EXPORT_SYMBOL(__fscache_disable_cookie);
78457 */
78458 void __fscache_relinquish_cookie(struct fscache_cookie *cookie, bool retire)
78459 {
78460- fscache_stat(&fscache_n_relinquishes);
78461+ fscache_stat_unchecked(&fscache_n_relinquishes);
78462 if (retire)
78463- fscache_stat(&fscache_n_relinquishes_retire);
78464+ fscache_stat_unchecked(&fscache_n_relinquishes_retire);
78465
78466 if (!cookie) {
78467- fscache_stat(&fscache_n_relinquishes_null);
78468+ fscache_stat_unchecked(&fscache_n_relinquishes_null);
78469 _leave(" [no cookie]");
78470 return;
78471 }
78472@@ -687,7 +687,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
78473 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
78474 goto inconsistent;
78475
78476- op->debug_id = atomic_inc_return(&fscache_op_debug_id);
78477+ op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
78478
78479 __fscache_use_cookie(cookie);
78480 if (fscache_submit_op(object, op) < 0)
78481diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
78482index 97ec451..f722cee 100644
78483--- a/fs/fscache/internal.h
78484+++ b/fs/fscache/internal.h
78485@@ -136,8 +136,8 @@ extern void fscache_operation_gc(struct work_struct *);
78486 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
78487 extern int fscache_wait_for_operation_activation(struct fscache_object *,
78488 struct fscache_operation *,
78489- atomic_t *,
78490- atomic_t *);
78491+ atomic_unchecked_t *,
78492+ atomic_unchecked_t *);
78493 extern void fscache_invalidate_writes(struct fscache_cookie *);
78494
78495 /*
78496@@ -155,102 +155,102 @@ extern void fscache_proc_cleanup(void);
78497 * stats.c
78498 */
78499 #ifdef CONFIG_FSCACHE_STATS
78500-extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
78501-extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
78502+extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
78503+extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
78504
78505-extern atomic_t fscache_n_op_pend;
78506-extern atomic_t fscache_n_op_run;
78507-extern atomic_t fscache_n_op_enqueue;
78508-extern atomic_t fscache_n_op_deferred_release;
78509-extern atomic_t fscache_n_op_initialised;
78510-extern atomic_t fscache_n_op_release;
78511-extern atomic_t fscache_n_op_gc;
78512-extern atomic_t fscache_n_op_cancelled;
78513-extern atomic_t fscache_n_op_rejected;
78514+extern atomic_unchecked_t fscache_n_op_pend;
78515+extern atomic_unchecked_t fscache_n_op_run;
78516+extern atomic_unchecked_t fscache_n_op_enqueue;
78517+extern atomic_unchecked_t fscache_n_op_deferred_release;
78518+extern atomic_unchecked_t fscache_n_op_initialised;
78519+extern atomic_unchecked_t fscache_n_op_release;
78520+extern atomic_unchecked_t fscache_n_op_gc;
78521+extern atomic_unchecked_t fscache_n_op_cancelled;
78522+extern atomic_unchecked_t fscache_n_op_rejected;
78523
78524-extern atomic_t fscache_n_attr_changed;
78525-extern atomic_t fscache_n_attr_changed_ok;
78526-extern atomic_t fscache_n_attr_changed_nobufs;
78527-extern atomic_t fscache_n_attr_changed_nomem;
78528-extern atomic_t fscache_n_attr_changed_calls;
78529+extern atomic_unchecked_t fscache_n_attr_changed;
78530+extern atomic_unchecked_t fscache_n_attr_changed_ok;
78531+extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
78532+extern atomic_unchecked_t fscache_n_attr_changed_nomem;
78533+extern atomic_unchecked_t fscache_n_attr_changed_calls;
78534
78535-extern atomic_t fscache_n_allocs;
78536-extern atomic_t fscache_n_allocs_ok;
78537-extern atomic_t fscache_n_allocs_wait;
78538-extern atomic_t fscache_n_allocs_nobufs;
78539-extern atomic_t fscache_n_allocs_intr;
78540-extern atomic_t fscache_n_allocs_object_dead;
78541-extern atomic_t fscache_n_alloc_ops;
78542-extern atomic_t fscache_n_alloc_op_waits;
78543+extern atomic_unchecked_t fscache_n_allocs;
78544+extern atomic_unchecked_t fscache_n_allocs_ok;
78545+extern atomic_unchecked_t fscache_n_allocs_wait;
78546+extern atomic_unchecked_t fscache_n_allocs_nobufs;
78547+extern atomic_unchecked_t fscache_n_allocs_intr;
78548+extern atomic_unchecked_t fscache_n_allocs_object_dead;
78549+extern atomic_unchecked_t fscache_n_alloc_ops;
78550+extern atomic_unchecked_t fscache_n_alloc_op_waits;
78551
78552-extern atomic_t fscache_n_retrievals;
78553-extern atomic_t fscache_n_retrievals_ok;
78554-extern atomic_t fscache_n_retrievals_wait;
78555-extern atomic_t fscache_n_retrievals_nodata;
78556-extern atomic_t fscache_n_retrievals_nobufs;
78557-extern atomic_t fscache_n_retrievals_intr;
78558-extern atomic_t fscache_n_retrievals_nomem;
78559-extern atomic_t fscache_n_retrievals_object_dead;
78560-extern atomic_t fscache_n_retrieval_ops;
78561-extern atomic_t fscache_n_retrieval_op_waits;
78562+extern atomic_unchecked_t fscache_n_retrievals;
78563+extern atomic_unchecked_t fscache_n_retrievals_ok;
78564+extern atomic_unchecked_t fscache_n_retrievals_wait;
78565+extern atomic_unchecked_t fscache_n_retrievals_nodata;
78566+extern atomic_unchecked_t fscache_n_retrievals_nobufs;
78567+extern atomic_unchecked_t fscache_n_retrievals_intr;
78568+extern atomic_unchecked_t fscache_n_retrievals_nomem;
78569+extern atomic_unchecked_t fscache_n_retrievals_object_dead;
78570+extern atomic_unchecked_t fscache_n_retrieval_ops;
78571+extern atomic_unchecked_t fscache_n_retrieval_op_waits;
78572
78573-extern atomic_t fscache_n_stores;
78574-extern atomic_t fscache_n_stores_ok;
78575-extern atomic_t fscache_n_stores_again;
78576-extern atomic_t fscache_n_stores_nobufs;
78577-extern atomic_t fscache_n_stores_oom;
78578-extern atomic_t fscache_n_store_ops;
78579-extern atomic_t fscache_n_store_calls;
78580-extern atomic_t fscache_n_store_pages;
78581-extern atomic_t fscache_n_store_radix_deletes;
78582-extern atomic_t fscache_n_store_pages_over_limit;
78583+extern atomic_unchecked_t fscache_n_stores;
78584+extern atomic_unchecked_t fscache_n_stores_ok;
78585+extern atomic_unchecked_t fscache_n_stores_again;
78586+extern atomic_unchecked_t fscache_n_stores_nobufs;
78587+extern atomic_unchecked_t fscache_n_stores_oom;
78588+extern atomic_unchecked_t fscache_n_store_ops;
78589+extern atomic_unchecked_t fscache_n_store_calls;
78590+extern atomic_unchecked_t fscache_n_store_pages;
78591+extern atomic_unchecked_t fscache_n_store_radix_deletes;
78592+extern atomic_unchecked_t fscache_n_store_pages_over_limit;
78593
78594-extern atomic_t fscache_n_store_vmscan_not_storing;
78595-extern atomic_t fscache_n_store_vmscan_gone;
78596-extern atomic_t fscache_n_store_vmscan_busy;
78597-extern atomic_t fscache_n_store_vmscan_cancelled;
78598-extern atomic_t fscache_n_store_vmscan_wait;
78599+extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
78600+extern atomic_unchecked_t fscache_n_store_vmscan_gone;
78601+extern atomic_unchecked_t fscache_n_store_vmscan_busy;
78602+extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
78603+extern atomic_unchecked_t fscache_n_store_vmscan_wait;
78604
78605-extern atomic_t fscache_n_marks;
78606-extern atomic_t fscache_n_uncaches;
78607+extern atomic_unchecked_t fscache_n_marks;
78608+extern atomic_unchecked_t fscache_n_uncaches;
78609
78610-extern atomic_t fscache_n_acquires;
78611-extern atomic_t fscache_n_acquires_null;
78612-extern atomic_t fscache_n_acquires_no_cache;
78613-extern atomic_t fscache_n_acquires_ok;
78614-extern atomic_t fscache_n_acquires_nobufs;
78615-extern atomic_t fscache_n_acquires_oom;
78616+extern atomic_unchecked_t fscache_n_acquires;
78617+extern atomic_unchecked_t fscache_n_acquires_null;
78618+extern atomic_unchecked_t fscache_n_acquires_no_cache;
78619+extern atomic_unchecked_t fscache_n_acquires_ok;
78620+extern atomic_unchecked_t fscache_n_acquires_nobufs;
78621+extern atomic_unchecked_t fscache_n_acquires_oom;
78622
78623-extern atomic_t fscache_n_invalidates;
78624-extern atomic_t fscache_n_invalidates_run;
78625+extern atomic_unchecked_t fscache_n_invalidates;
78626+extern atomic_unchecked_t fscache_n_invalidates_run;
78627
78628-extern atomic_t fscache_n_updates;
78629-extern atomic_t fscache_n_updates_null;
78630-extern atomic_t fscache_n_updates_run;
78631+extern atomic_unchecked_t fscache_n_updates;
78632+extern atomic_unchecked_t fscache_n_updates_null;
78633+extern atomic_unchecked_t fscache_n_updates_run;
78634
78635-extern atomic_t fscache_n_relinquishes;
78636-extern atomic_t fscache_n_relinquishes_null;
78637-extern atomic_t fscache_n_relinquishes_waitcrt;
78638-extern atomic_t fscache_n_relinquishes_retire;
78639+extern atomic_unchecked_t fscache_n_relinquishes;
78640+extern atomic_unchecked_t fscache_n_relinquishes_null;
78641+extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
78642+extern atomic_unchecked_t fscache_n_relinquishes_retire;
78643
78644-extern atomic_t fscache_n_cookie_index;
78645-extern atomic_t fscache_n_cookie_data;
78646-extern atomic_t fscache_n_cookie_special;
78647+extern atomic_unchecked_t fscache_n_cookie_index;
78648+extern atomic_unchecked_t fscache_n_cookie_data;
78649+extern atomic_unchecked_t fscache_n_cookie_special;
78650
78651-extern atomic_t fscache_n_object_alloc;
78652-extern atomic_t fscache_n_object_no_alloc;
78653-extern atomic_t fscache_n_object_lookups;
78654-extern atomic_t fscache_n_object_lookups_negative;
78655-extern atomic_t fscache_n_object_lookups_positive;
78656-extern atomic_t fscache_n_object_lookups_timed_out;
78657-extern atomic_t fscache_n_object_created;
78658-extern atomic_t fscache_n_object_avail;
78659-extern atomic_t fscache_n_object_dead;
78660+extern atomic_unchecked_t fscache_n_object_alloc;
78661+extern atomic_unchecked_t fscache_n_object_no_alloc;
78662+extern atomic_unchecked_t fscache_n_object_lookups;
78663+extern atomic_unchecked_t fscache_n_object_lookups_negative;
78664+extern atomic_unchecked_t fscache_n_object_lookups_positive;
78665+extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
78666+extern atomic_unchecked_t fscache_n_object_created;
78667+extern atomic_unchecked_t fscache_n_object_avail;
78668+extern atomic_unchecked_t fscache_n_object_dead;
78669
78670-extern atomic_t fscache_n_checkaux_none;
78671-extern atomic_t fscache_n_checkaux_okay;
78672-extern atomic_t fscache_n_checkaux_update;
78673-extern atomic_t fscache_n_checkaux_obsolete;
78674+extern atomic_unchecked_t fscache_n_checkaux_none;
78675+extern atomic_unchecked_t fscache_n_checkaux_okay;
78676+extern atomic_unchecked_t fscache_n_checkaux_update;
78677+extern atomic_unchecked_t fscache_n_checkaux_obsolete;
78678
78679 extern atomic_t fscache_n_cop_alloc_object;
78680 extern atomic_t fscache_n_cop_lookup_object;
78681@@ -280,6 +280,11 @@ static inline void fscache_stat(atomic_t *stat)
78682 atomic_inc(stat);
78683 }
78684
78685+static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
78686+{
78687+ atomic_inc_unchecked(stat);
78688+}
78689+
78690 static inline void fscache_stat_d(atomic_t *stat)
78691 {
78692 atomic_dec(stat);
78693@@ -292,6 +297,7 @@ extern const struct file_operations fscache_stats_fops;
78694
78695 #define __fscache_stat(stat) (NULL)
78696 #define fscache_stat(stat) do {} while (0)
78697+#define fscache_stat_unchecked(stat) do {} while (0)
78698 #define fscache_stat_d(stat) do {} while (0)
78699 #endif
78700
78701diff --git a/fs/fscache/object.c b/fs/fscache/object.c
78702index 9e792e3..6b2affb 100644
78703--- a/fs/fscache/object.c
78704+++ b/fs/fscache/object.c
78705@@ -465,7 +465,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
78706 _debug("LOOKUP \"%s\" in \"%s\"",
78707 cookie->def->name, object->cache->tag->name);
78708
78709- fscache_stat(&fscache_n_object_lookups);
78710+ fscache_stat_unchecked(&fscache_n_object_lookups);
78711 fscache_stat(&fscache_n_cop_lookup_object);
78712 ret = object->cache->ops->lookup_object(object);
78713 fscache_stat_d(&fscache_n_cop_lookup_object);
78714@@ -475,7 +475,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
78715 if (ret == -ETIMEDOUT) {
78716 /* probably stuck behind another object, so move this one to
78717 * the back of the queue */
78718- fscache_stat(&fscache_n_object_lookups_timed_out);
78719+ fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
78720 _leave(" [timeout]");
78721 return NO_TRANSIT;
78722 }
78723@@ -503,7 +503,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
78724 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
78725
78726 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
78727- fscache_stat(&fscache_n_object_lookups_negative);
78728+ fscache_stat_unchecked(&fscache_n_object_lookups_negative);
78729
78730 /* Allow write requests to begin stacking up and read requests to begin
78731 * returning ENODATA.
78732@@ -538,7 +538,7 @@ void fscache_obtained_object(struct fscache_object *object)
78733 /* if we were still looking up, then we must have a positive lookup
78734 * result, in which case there may be data available */
78735 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
78736- fscache_stat(&fscache_n_object_lookups_positive);
78737+ fscache_stat_unchecked(&fscache_n_object_lookups_positive);
78738
78739 /* We do (presumably) have data */
78740 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
78741@@ -550,7 +550,7 @@ void fscache_obtained_object(struct fscache_object *object)
78742 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
78743 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
78744 } else {
78745- fscache_stat(&fscache_n_object_created);
78746+ fscache_stat_unchecked(&fscache_n_object_created);
78747 }
78748
78749 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
78750@@ -586,7 +586,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
78751 fscache_stat_d(&fscache_n_cop_lookup_complete);
78752
78753 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
78754- fscache_stat(&fscache_n_object_avail);
78755+ fscache_stat_unchecked(&fscache_n_object_avail);
78756
78757 _leave("");
78758 return transit_to(JUMPSTART_DEPS);
78759@@ -735,7 +735,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
78760
78761 /* this just shifts the object release to the work processor */
78762 fscache_put_object(object);
78763- fscache_stat(&fscache_n_object_dead);
78764+ fscache_stat_unchecked(&fscache_n_object_dead);
78765
78766 _leave("");
78767 return transit_to(OBJECT_DEAD);
78768@@ -900,7 +900,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
78769 enum fscache_checkaux result;
78770
78771 if (!object->cookie->def->check_aux) {
78772- fscache_stat(&fscache_n_checkaux_none);
78773+ fscache_stat_unchecked(&fscache_n_checkaux_none);
78774 return FSCACHE_CHECKAUX_OKAY;
78775 }
78776
78777@@ -909,17 +909,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
78778 switch (result) {
78779 /* entry okay as is */
78780 case FSCACHE_CHECKAUX_OKAY:
78781- fscache_stat(&fscache_n_checkaux_okay);
78782+ fscache_stat_unchecked(&fscache_n_checkaux_okay);
78783 break;
78784
78785 /* entry requires update */
78786 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
78787- fscache_stat(&fscache_n_checkaux_update);
78788+ fscache_stat_unchecked(&fscache_n_checkaux_update);
78789 break;
78790
78791 /* entry requires deletion */
78792 case FSCACHE_CHECKAUX_OBSOLETE:
78793- fscache_stat(&fscache_n_checkaux_obsolete);
78794+ fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
78795 break;
78796
78797 default:
78798@@ -1007,7 +1007,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
78799 {
78800 const struct fscache_state *s;
78801
78802- fscache_stat(&fscache_n_invalidates_run);
78803+ fscache_stat_unchecked(&fscache_n_invalidates_run);
78804 fscache_stat(&fscache_n_cop_invalidate_object);
78805 s = _fscache_invalidate_object(object, event);
78806 fscache_stat_d(&fscache_n_cop_invalidate_object);
78807@@ -1022,7 +1022,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
78808 {
78809 _enter("{OBJ%x},%d", object->debug_id, event);
78810
78811- fscache_stat(&fscache_n_updates_run);
78812+ fscache_stat_unchecked(&fscache_n_updates_run);
78813 fscache_stat(&fscache_n_cop_update_object);
78814 object->cache->ops->update_object(object);
78815 fscache_stat_d(&fscache_n_cop_update_object);
78816diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
78817index de67745..6a3a9b6 100644
78818--- a/fs/fscache/operation.c
78819+++ b/fs/fscache/operation.c
78820@@ -17,7 +17,7 @@
78821 #include <linux/slab.h>
78822 #include "internal.h"
78823
78824-atomic_t fscache_op_debug_id;
78825+atomic_unchecked_t fscache_op_debug_id;
78826 EXPORT_SYMBOL(fscache_op_debug_id);
78827
78828 static void fscache_operation_dummy_cancel(struct fscache_operation *op)
78829@@ -40,12 +40,12 @@ void fscache_operation_init(struct fscache_operation *op,
78830 INIT_WORK(&op->work, fscache_op_work_func);
78831 atomic_set(&op->usage, 1);
78832 op->state = FSCACHE_OP_ST_INITIALISED;
78833- op->debug_id = atomic_inc_return(&fscache_op_debug_id);
78834+ op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
78835 op->processor = processor;
78836 op->cancel = cancel ?: fscache_operation_dummy_cancel;
78837 op->release = release;
78838 INIT_LIST_HEAD(&op->pend_link);
78839- fscache_stat(&fscache_n_op_initialised);
78840+ fscache_stat_unchecked(&fscache_n_op_initialised);
78841 }
78842 EXPORT_SYMBOL(fscache_operation_init);
78843
78844@@ -68,7 +68,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
78845 ASSERTCMP(atomic_read(&op->usage), >, 0);
78846 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
78847
78848- fscache_stat(&fscache_n_op_enqueue);
78849+ fscache_stat_unchecked(&fscache_n_op_enqueue);
78850 switch (op->flags & FSCACHE_OP_TYPE) {
78851 case FSCACHE_OP_ASYNC:
78852 _debug("queue async");
78853@@ -101,7 +101,7 @@ static void fscache_run_op(struct fscache_object *object,
78854 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
78855 if (op->processor)
78856 fscache_enqueue_operation(op);
78857- fscache_stat(&fscache_n_op_run);
78858+ fscache_stat_unchecked(&fscache_n_op_run);
78859 }
78860
78861 /*
78862@@ -169,7 +169,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
78863 op->state = FSCACHE_OP_ST_PENDING;
78864 flags = READ_ONCE(object->flags);
78865 if (unlikely(!(flags & BIT(FSCACHE_OBJECT_IS_LIVE)))) {
78866- fscache_stat(&fscache_n_op_rejected);
78867+ fscache_stat_unchecked(&fscache_n_op_rejected);
78868 op->cancel(op);
78869 op->state = FSCACHE_OP_ST_CANCELLED;
78870 ret = -ENOBUFS;
78871@@ -185,11 +185,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
78872 if (object->n_in_progress > 0) {
78873 atomic_inc(&op->usage);
78874 list_add_tail(&op->pend_link, &object->pending_ops);
78875- fscache_stat(&fscache_n_op_pend);
78876+ fscache_stat_unchecked(&fscache_n_op_pend);
78877 } else if (!list_empty(&object->pending_ops)) {
78878 atomic_inc(&op->usage);
78879 list_add_tail(&op->pend_link, &object->pending_ops);
78880- fscache_stat(&fscache_n_op_pend);
78881+ fscache_stat_unchecked(&fscache_n_op_pend);
78882 fscache_start_operations(object);
78883 } else {
78884 ASSERTCMP(object->n_in_progress, ==, 0);
78885@@ -205,7 +205,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
78886 object->n_exclusive++; /* reads and writes must wait */
78887 atomic_inc(&op->usage);
78888 list_add_tail(&op->pend_link, &object->pending_ops);
78889- fscache_stat(&fscache_n_op_pend);
78890+ fscache_stat_unchecked(&fscache_n_op_pend);
78891 ret = 0;
78892 } else if (flags & BIT(FSCACHE_OBJECT_KILLED_BY_CACHE)) {
78893 op->cancel(op);
78894@@ -254,7 +254,7 @@ int fscache_submit_op(struct fscache_object *object,
78895 op->state = FSCACHE_OP_ST_PENDING;
78896 flags = READ_ONCE(object->flags);
78897 if (unlikely(!(flags & BIT(FSCACHE_OBJECT_IS_LIVE)))) {
78898- fscache_stat(&fscache_n_op_rejected);
78899+ fscache_stat_unchecked(&fscache_n_op_rejected);
78900 op->cancel(op);
78901 op->state = FSCACHE_OP_ST_CANCELLED;
78902 ret = -ENOBUFS;
78903@@ -269,11 +269,11 @@ int fscache_submit_op(struct fscache_object *object,
78904 if (object->n_exclusive > 0) {
78905 atomic_inc(&op->usage);
78906 list_add_tail(&op->pend_link, &object->pending_ops);
78907- fscache_stat(&fscache_n_op_pend);
78908+ fscache_stat_unchecked(&fscache_n_op_pend);
78909 } else if (!list_empty(&object->pending_ops)) {
78910 atomic_inc(&op->usage);
78911 list_add_tail(&op->pend_link, &object->pending_ops);
78912- fscache_stat(&fscache_n_op_pend);
78913+ fscache_stat_unchecked(&fscache_n_op_pend);
78914 fscache_start_operations(object);
78915 } else {
78916 ASSERTCMP(object->n_exclusive, ==, 0);
78917@@ -285,7 +285,7 @@ int fscache_submit_op(struct fscache_object *object,
78918 object->n_ops++;
78919 atomic_inc(&op->usage);
78920 list_add_tail(&op->pend_link, &object->pending_ops);
78921- fscache_stat(&fscache_n_op_pend);
78922+ fscache_stat_unchecked(&fscache_n_op_pend);
78923 ret = 0;
78924 } else if (flags & BIT(FSCACHE_OBJECT_KILLED_BY_CACHE)) {
78925 op->cancel(op);
78926@@ -369,7 +369,7 @@ int fscache_cancel_op(struct fscache_operation *op,
78927 list_del_init(&op->pend_link);
78928 put = true;
78929
78930- fscache_stat(&fscache_n_op_cancelled);
78931+ fscache_stat_unchecked(&fscache_n_op_cancelled);
78932 op->cancel(op);
78933 op->state = FSCACHE_OP_ST_CANCELLED;
78934 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
78935@@ -385,7 +385,7 @@ int fscache_cancel_op(struct fscache_operation *op,
78936 if (object->n_in_progress == 0)
78937 fscache_start_operations(object);
78938
78939- fscache_stat(&fscache_n_op_cancelled);
78940+ fscache_stat_unchecked(&fscache_n_op_cancelled);
78941 op->cancel(op);
78942 op->state = FSCACHE_OP_ST_CANCELLED;
78943 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
78944@@ -416,7 +416,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
78945 while (!list_empty(&object->pending_ops)) {
78946 op = list_entry(object->pending_ops.next,
78947 struct fscache_operation, pend_link);
78948- fscache_stat(&fscache_n_op_cancelled);
78949+ fscache_stat_unchecked(&fscache_n_op_cancelled);
78950 list_del_init(&op->pend_link);
78951
78952 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
78953@@ -493,7 +493,7 @@ void fscache_put_operation(struct fscache_operation *op)
78954 op->state != FSCACHE_OP_ST_COMPLETE,
78955 op->state, ==, FSCACHE_OP_ST_CANCELLED);
78956
78957- fscache_stat(&fscache_n_op_release);
78958+ fscache_stat_unchecked(&fscache_n_op_release);
78959
78960 if (op->release) {
78961 op->release(op);
78962@@ -513,7 +513,7 @@ void fscache_put_operation(struct fscache_operation *op)
78963 * lock, and defer it otherwise */
78964 if (!spin_trylock(&object->lock)) {
78965 _debug("defer put");
78966- fscache_stat(&fscache_n_op_deferred_release);
78967+ fscache_stat_unchecked(&fscache_n_op_deferred_release);
78968
78969 cache = object->cache;
78970 spin_lock(&cache->op_gc_list_lock);
78971@@ -567,7 +567,7 @@ void fscache_operation_gc(struct work_struct *work)
78972
78973 _debug("GC DEFERRED REL OBJ%x OP%x",
78974 object->debug_id, op->debug_id);
78975- fscache_stat(&fscache_n_op_gc);
78976+ fscache_stat_unchecked(&fscache_n_op_gc);
78977
78978 ASSERTCMP(atomic_read(&op->usage), ==, 0);
78979 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
78980diff --git a/fs/fscache/page.c b/fs/fscache/page.c
78981index 483bbc6..ba36737 100644
78982--- a/fs/fscache/page.c
78983+++ b/fs/fscache/page.c
78984@@ -74,7 +74,7 @@ try_again:
78985 val = radix_tree_lookup(&cookie->stores, page->index);
78986 if (!val) {
78987 rcu_read_unlock();
78988- fscache_stat(&fscache_n_store_vmscan_not_storing);
78989+ fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
78990 __fscache_uncache_page(cookie, page);
78991 return true;
78992 }
78993@@ -104,11 +104,11 @@ try_again:
78994 spin_unlock(&cookie->stores_lock);
78995
78996 if (xpage) {
78997- fscache_stat(&fscache_n_store_vmscan_cancelled);
78998- fscache_stat(&fscache_n_store_radix_deletes);
78999+ fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
79000+ fscache_stat_unchecked(&fscache_n_store_radix_deletes);
79001 ASSERTCMP(xpage, ==, page);
79002 } else {
79003- fscache_stat(&fscache_n_store_vmscan_gone);
79004+ fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
79005 }
79006
79007 wake_up_bit(&cookie->flags, 0);
79008@@ -123,11 +123,11 @@ page_busy:
79009 * sleeping on memory allocation, so we may need to impose a timeout
79010 * too. */
79011 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
79012- fscache_stat(&fscache_n_store_vmscan_busy);
79013+ fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
79014 return false;
79015 }
79016
79017- fscache_stat(&fscache_n_store_vmscan_wait);
79018+ fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
79019 if (!release_page_wait_timeout(cookie, page))
79020 _debug("fscache writeout timeout page: %p{%lx}",
79021 page, page->index);
79022@@ -156,7 +156,7 @@ static void fscache_end_page_write(struct fscache_object *object,
79023 FSCACHE_COOKIE_STORING_TAG);
79024 if (!radix_tree_tag_get(&cookie->stores, page->index,
79025 FSCACHE_COOKIE_PENDING_TAG)) {
79026- fscache_stat(&fscache_n_store_radix_deletes);
79027+ fscache_stat_unchecked(&fscache_n_store_radix_deletes);
79028 xpage = radix_tree_delete(&cookie->stores, page->index);
79029 }
79030 spin_unlock(&cookie->stores_lock);
79031@@ -177,7 +177,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
79032
79033 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
79034
79035- fscache_stat(&fscache_n_attr_changed_calls);
79036+ fscache_stat_unchecked(&fscache_n_attr_changed_calls);
79037
79038 if (fscache_object_is_active(object)) {
79039 fscache_stat(&fscache_n_cop_attr_changed);
79040@@ -204,11 +204,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
79041
79042 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
79043
79044- fscache_stat(&fscache_n_attr_changed);
79045+ fscache_stat_unchecked(&fscache_n_attr_changed);
79046
79047 op = kzalloc(sizeof(*op), GFP_KERNEL);
79048 if (!op) {
79049- fscache_stat(&fscache_n_attr_changed_nomem);
79050+ fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
79051 _leave(" = -ENOMEM");
79052 return -ENOMEM;
79053 }
79054@@ -230,7 +230,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
79055 if (fscache_submit_exclusive_op(object, op) < 0)
79056 goto nobufs_dec;
79057 spin_unlock(&cookie->lock);
79058- fscache_stat(&fscache_n_attr_changed_ok);
79059+ fscache_stat_unchecked(&fscache_n_attr_changed_ok);
79060 fscache_put_operation(op);
79061 _leave(" = 0");
79062 return 0;
79063@@ -242,7 +242,7 @@ nobufs:
79064 fscache_put_operation(op);
79065 if (wake_cookie)
79066 __fscache_wake_unused_cookie(cookie);
79067- fscache_stat(&fscache_n_attr_changed_nobufs);
79068+ fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
79069 _leave(" = %d", -ENOBUFS);
79070 return -ENOBUFS;
79071 }
79072@@ -293,7 +293,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
79073 /* allocate a retrieval operation and attempt to submit it */
79074 op = kzalloc(sizeof(*op), GFP_NOIO);
79075 if (!op) {
79076- fscache_stat(&fscache_n_retrievals_nomem);
79077+ fscache_stat_unchecked(&fscache_n_retrievals_nomem);
79078 return NULL;
79079 }
79080
79081@@ -332,12 +332,12 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
79082 return 0;
79083 }
79084
79085- fscache_stat(&fscache_n_retrievals_wait);
79086+ fscache_stat_unchecked(&fscache_n_retrievals_wait);
79087
79088 jif = jiffies;
79089 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
79090 TASK_INTERRUPTIBLE) != 0) {
79091- fscache_stat(&fscache_n_retrievals_intr);
79092+ fscache_stat_unchecked(&fscache_n_retrievals_intr);
79093 _leave(" = -ERESTARTSYS");
79094 return -ERESTARTSYS;
79095 }
79096@@ -355,8 +355,8 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
79097 */
79098 int fscache_wait_for_operation_activation(struct fscache_object *object,
79099 struct fscache_operation *op,
79100- atomic_t *stat_op_waits,
79101- atomic_t *stat_object_dead)
79102+ atomic_unchecked_t *stat_op_waits,
79103+ atomic_unchecked_t *stat_object_dead)
79104 {
79105 int ret;
79106
79107@@ -365,7 +365,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
79108
79109 _debug(">>> WT");
79110 if (stat_op_waits)
79111- fscache_stat(stat_op_waits);
79112+ fscache_stat_unchecked(stat_op_waits);
79113 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
79114 TASK_INTERRUPTIBLE) != 0) {
79115 ret = fscache_cancel_op(op, false);
79116@@ -382,7 +382,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
79117 check_if_dead:
79118 if (op->state == FSCACHE_OP_ST_CANCELLED) {
79119 if (stat_object_dead)
79120- fscache_stat(stat_object_dead);
79121+ fscache_stat_unchecked(stat_object_dead);
79122 _leave(" = -ENOBUFS [cancelled]");
79123 return -ENOBUFS;
79124 }
79125@@ -391,7 +391,7 @@ check_if_dead:
79126 enum fscache_operation_state state = op->state;
79127 fscache_cancel_op(op, true);
79128 if (stat_object_dead)
79129- fscache_stat(stat_object_dead);
79130+ fscache_stat_unchecked(stat_object_dead);
79131 _leave(" = -ENOBUFS [obj dead %d]", state);
79132 return -ENOBUFS;
79133 }
79134@@ -420,7 +420,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
79135
79136 _enter("%p,%p,,,", cookie, page);
79137
79138- fscache_stat(&fscache_n_retrievals);
79139+ fscache_stat_unchecked(&fscache_n_retrievals);
79140
79141 if (hlist_empty(&cookie->backing_objects))
79142 goto nobufs;
79143@@ -462,7 +462,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
79144 goto nobufs_unlock_dec;
79145 spin_unlock(&cookie->lock);
79146
79147- fscache_stat(&fscache_n_retrieval_ops);
79148+ fscache_stat_unchecked(&fscache_n_retrieval_ops);
79149
79150 /* we wait for the operation to become active, and then process it
79151 * *here*, in this thread, and not in the thread pool */
79152@@ -488,15 +488,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
79153
79154 error:
79155 if (ret == -ENOMEM)
79156- fscache_stat(&fscache_n_retrievals_nomem);
79157+ fscache_stat_unchecked(&fscache_n_retrievals_nomem);
79158 else if (ret == -ERESTARTSYS)
79159- fscache_stat(&fscache_n_retrievals_intr);
79160+ fscache_stat_unchecked(&fscache_n_retrievals_intr);
79161 else if (ret == -ENODATA)
79162- fscache_stat(&fscache_n_retrievals_nodata);
79163+ fscache_stat_unchecked(&fscache_n_retrievals_nodata);
79164 else if (ret < 0)
79165- fscache_stat(&fscache_n_retrievals_nobufs);
79166+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
79167 else
79168- fscache_stat(&fscache_n_retrievals_ok);
79169+ fscache_stat_unchecked(&fscache_n_retrievals_ok);
79170
79171 fscache_put_retrieval(op);
79172 _leave(" = %d", ret);
79173@@ -511,7 +511,7 @@ nobufs_unlock:
79174 __fscache_wake_unused_cookie(cookie);
79175 fscache_put_retrieval(op);
79176 nobufs:
79177- fscache_stat(&fscache_n_retrievals_nobufs);
79178+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
79179 _leave(" = -ENOBUFS");
79180 return -ENOBUFS;
79181 }
79182@@ -550,7 +550,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
79183
79184 _enter("%p,,%d,,,", cookie, *nr_pages);
79185
79186- fscache_stat(&fscache_n_retrievals);
79187+ fscache_stat_unchecked(&fscache_n_retrievals);
79188
79189 if (hlist_empty(&cookie->backing_objects))
79190 goto nobufs;
79191@@ -588,7 +588,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
79192 goto nobufs_unlock_dec;
79193 spin_unlock(&cookie->lock);
79194
79195- fscache_stat(&fscache_n_retrieval_ops);
79196+ fscache_stat_unchecked(&fscache_n_retrieval_ops);
79197
79198 /* we wait for the operation to become active, and then process it
79199 * *here*, in this thread, and not in the thread pool */
79200@@ -614,15 +614,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
79201
79202 error:
79203 if (ret == -ENOMEM)
79204- fscache_stat(&fscache_n_retrievals_nomem);
79205+ fscache_stat_unchecked(&fscache_n_retrievals_nomem);
79206 else if (ret == -ERESTARTSYS)
79207- fscache_stat(&fscache_n_retrievals_intr);
79208+ fscache_stat_unchecked(&fscache_n_retrievals_intr);
79209 else if (ret == -ENODATA)
79210- fscache_stat(&fscache_n_retrievals_nodata);
79211+ fscache_stat_unchecked(&fscache_n_retrievals_nodata);
79212 else if (ret < 0)
79213- fscache_stat(&fscache_n_retrievals_nobufs);
79214+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
79215 else
79216- fscache_stat(&fscache_n_retrievals_ok);
79217+ fscache_stat_unchecked(&fscache_n_retrievals_ok);
79218
79219 fscache_put_retrieval(op);
79220 _leave(" = %d", ret);
79221@@ -637,7 +637,7 @@ nobufs_unlock:
79222 if (wake_cookie)
79223 __fscache_wake_unused_cookie(cookie);
79224 nobufs:
79225- fscache_stat(&fscache_n_retrievals_nobufs);
79226+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
79227 _leave(" = -ENOBUFS");
79228 return -ENOBUFS;
79229 }
79230@@ -662,7 +662,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
79231
79232 _enter("%p,%p,,,", cookie, page);
79233
79234- fscache_stat(&fscache_n_allocs);
79235+ fscache_stat_unchecked(&fscache_n_allocs);
79236
79237 if (hlist_empty(&cookie->backing_objects))
79238 goto nobufs;
79239@@ -696,7 +696,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
79240 goto nobufs_unlock_dec;
79241 spin_unlock(&cookie->lock);
79242
79243- fscache_stat(&fscache_n_alloc_ops);
79244+ fscache_stat_unchecked(&fscache_n_alloc_ops);
79245
79246 ret = fscache_wait_for_operation_activation(
79247 object, &op->op,
79248@@ -712,11 +712,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
79249
79250 error:
79251 if (ret == -ERESTARTSYS)
79252- fscache_stat(&fscache_n_allocs_intr);
79253+ fscache_stat_unchecked(&fscache_n_allocs_intr);
79254 else if (ret < 0)
79255- fscache_stat(&fscache_n_allocs_nobufs);
79256+ fscache_stat_unchecked(&fscache_n_allocs_nobufs);
79257 else
79258- fscache_stat(&fscache_n_allocs_ok);
79259+ fscache_stat_unchecked(&fscache_n_allocs_ok);
79260
79261 fscache_put_retrieval(op);
79262 _leave(" = %d", ret);
79263@@ -730,7 +730,7 @@ nobufs_unlock:
79264 if (wake_cookie)
79265 __fscache_wake_unused_cookie(cookie);
79266 nobufs:
79267- fscache_stat(&fscache_n_allocs_nobufs);
79268+ fscache_stat_unchecked(&fscache_n_allocs_nobufs);
79269 _leave(" = -ENOBUFS");
79270 return -ENOBUFS;
79271 }
79272@@ -806,7 +806,7 @@ static void fscache_write_op(struct fscache_operation *_op)
79273
79274 spin_lock(&cookie->stores_lock);
79275
79276- fscache_stat(&fscache_n_store_calls);
79277+ fscache_stat_unchecked(&fscache_n_store_calls);
79278
79279 /* find a page to store */
79280 page = NULL;
79281@@ -817,7 +817,7 @@ static void fscache_write_op(struct fscache_operation *_op)
79282 page = results[0];
79283 _debug("gang %d [%lx]", n, page->index);
79284 if (page->index > op->store_limit) {
79285- fscache_stat(&fscache_n_store_pages_over_limit);
79286+ fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
79287 goto superseded;
79288 }
79289
79290@@ -829,7 +829,7 @@ static void fscache_write_op(struct fscache_operation *_op)
79291 spin_unlock(&cookie->stores_lock);
79292 spin_unlock(&object->lock);
79293
79294- fscache_stat(&fscache_n_store_pages);
79295+ fscache_stat_unchecked(&fscache_n_store_pages);
79296 fscache_stat(&fscache_n_cop_write_page);
79297 ret = object->cache->ops->write_page(op, page);
79298 fscache_stat_d(&fscache_n_cop_write_page);
79299@@ -933,7 +933,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
79300 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
79301 ASSERT(PageFsCache(page));
79302
79303- fscache_stat(&fscache_n_stores);
79304+ fscache_stat_unchecked(&fscache_n_stores);
79305
79306 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
79307 _leave(" = -ENOBUFS [invalidating]");
79308@@ -992,7 +992,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
79309 spin_unlock(&cookie->stores_lock);
79310 spin_unlock(&object->lock);
79311
79312- op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
79313+ op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
79314 op->store_limit = object->store_limit;
79315
79316 __fscache_use_cookie(cookie);
79317@@ -1001,8 +1001,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
79318
79319 spin_unlock(&cookie->lock);
79320 radix_tree_preload_end();
79321- fscache_stat(&fscache_n_store_ops);
79322- fscache_stat(&fscache_n_stores_ok);
79323+ fscache_stat_unchecked(&fscache_n_store_ops);
79324+ fscache_stat_unchecked(&fscache_n_stores_ok);
79325
79326 /* the work queue now carries its own ref on the object */
79327 fscache_put_operation(&op->op);
79328@@ -1010,14 +1010,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
79329 return 0;
79330
79331 already_queued:
79332- fscache_stat(&fscache_n_stores_again);
79333+ fscache_stat_unchecked(&fscache_n_stores_again);
79334 already_pending:
79335 spin_unlock(&cookie->stores_lock);
79336 spin_unlock(&object->lock);
79337 spin_unlock(&cookie->lock);
79338 radix_tree_preload_end();
79339 fscache_put_operation(&op->op);
79340- fscache_stat(&fscache_n_stores_ok);
79341+ fscache_stat_unchecked(&fscache_n_stores_ok);
79342 _leave(" = 0");
79343 return 0;
79344
79345@@ -1039,14 +1039,14 @@ nobufs:
79346 fscache_put_operation(&op->op);
79347 if (wake_cookie)
79348 __fscache_wake_unused_cookie(cookie);
79349- fscache_stat(&fscache_n_stores_nobufs);
79350+ fscache_stat_unchecked(&fscache_n_stores_nobufs);
79351 _leave(" = -ENOBUFS");
79352 return -ENOBUFS;
79353
79354 nomem_free:
79355 fscache_put_operation(&op->op);
79356 nomem:
79357- fscache_stat(&fscache_n_stores_oom);
79358+ fscache_stat_unchecked(&fscache_n_stores_oom);
79359 _leave(" = -ENOMEM");
79360 return -ENOMEM;
79361 }
79362@@ -1064,7 +1064,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
79363 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
79364 ASSERTCMP(page, !=, NULL);
79365
79366- fscache_stat(&fscache_n_uncaches);
79367+ fscache_stat_unchecked(&fscache_n_uncaches);
79368
79369 /* cache withdrawal may beat us to it */
79370 if (!PageFsCache(page))
79371@@ -1115,7 +1115,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
79372 struct fscache_cookie *cookie = op->op.object->cookie;
79373
79374 #ifdef CONFIG_FSCACHE_STATS
79375- atomic_inc(&fscache_n_marks);
79376+ atomic_inc_unchecked(&fscache_n_marks);
79377 #endif
79378
79379 _debug("- mark %p{%lx}", page, page->index);
79380diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
79381index 7cfa0aa..d5ef97b7 100644
79382--- a/fs/fscache/stats.c
79383+++ b/fs/fscache/stats.c
79384@@ -18,100 +18,100 @@
79385 /*
79386 * operation counters
79387 */
79388-atomic_t fscache_n_op_pend;
79389-atomic_t fscache_n_op_run;
79390-atomic_t fscache_n_op_enqueue;
79391-atomic_t fscache_n_op_requeue;
79392-atomic_t fscache_n_op_deferred_release;
79393-atomic_t fscache_n_op_initialised;
79394-atomic_t fscache_n_op_release;
79395-atomic_t fscache_n_op_gc;
79396-atomic_t fscache_n_op_cancelled;
79397-atomic_t fscache_n_op_rejected;
79398+atomic_unchecked_t fscache_n_op_pend;
79399+atomic_unchecked_t fscache_n_op_run;
79400+atomic_unchecked_t fscache_n_op_enqueue;
79401+atomic_unchecked_t fscache_n_op_requeue;
79402+atomic_unchecked_t fscache_n_op_deferred_release;
79403+atomic_unchecked_t fscache_n_op_initialised;
79404+atomic_unchecked_t fscache_n_op_release;
79405+atomic_unchecked_t fscache_n_op_gc;
79406+atomic_unchecked_t fscache_n_op_cancelled;
79407+atomic_unchecked_t fscache_n_op_rejected;
79408
79409-atomic_t fscache_n_attr_changed;
79410-atomic_t fscache_n_attr_changed_ok;
79411-atomic_t fscache_n_attr_changed_nobufs;
79412-atomic_t fscache_n_attr_changed_nomem;
79413-atomic_t fscache_n_attr_changed_calls;
79414+atomic_unchecked_t fscache_n_attr_changed;
79415+atomic_unchecked_t fscache_n_attr_changed_ok;
79416+atomic_unchecked_t fscache_n_attr_changed_nobufs;
79417+atomic_unchecked_t fscache_n_attr_changed_nomem;
79418+atomic_unchecked_t fscache_n_attr_changed_calls;
79419
79420-atomic_t fscache_n_allocs;
79421-atomic_t fscache_n_allocs_ok;
79422-atomic_t fscache_n_allocs_wait;
79423-atomic_t fscache_n_allocs_nobufs;
79424-atomic_t fscache_n_allocs_intr;
79425-atomic_t fscache_n_allocs_object_dead;
79426-atomic_t fscache_n_alloc_ops;
79427-atomic_t fscache_n_alloc_op_waits;
79428+atomic_unchecked_t fscache_n_allocs;
79429+atomic_unchecked_t fscache_n_allocs_ok;
79430+atomic_unchecked_t fscache_n_allocs_wait;
79431+atomic_unchecked_t fscache_n_allocs_nobufs;
79432+atomic_unchecked_t fscache_n_allocs_intr;
79433+atomic_unchecked_t fscache_n_allocs_object_dead;
79434+atomic_unchecked_t fscache_n_alloc_ops;
79435+atomic_unchecked_t fscache_n_alloc_op_waits;
79436
79437-atomic_t fscache_n_retrievals;
79438-atomic_t fscache_n_retrievals_ok;
79439-atomic_t fscache_n_retrievals_wait;
79440-atomic_t fscache_n_retrievals_nodata;
79441-atomic_t fscache_n_retrievals_nobufs;
79442-atomic_t fscache_n_retrievals_intr;
79443-atomic_t fscache_n_retrievals_nomem;
79444-atomic_t fscache_n_retrievals_object_dead;
79445-atomic_t fscache_n_retrieval_ops;
79446-atomic_t fscache_n_retrieval_op_waits;
79447+atomic_unchecked_t fscache_n_retrievals;
79448+atomic_unchecked_t fscache_n_retrievals_ok;
79449+atomic_unchecked_t fscache_n_retrievals_wait;
79450+atomic_unchecked_t fscache_n_retrievals_nodata;
79451+atomic_unchecked_t fscache_n_retrievals_nobufs;
79452+atomic_unchecked_t fscache_n_retrievals_intr;
79453+atomic_unchecked_t fscache_n_retrievals_nomem;
79454+atomic_unchecked_t fscache_n_retrievals_object_dead;
79455+atomic_unchecked_t fscache_n_retrieval_ops;
79456+atomic_unchecked_t fscache_n_retrieval_op_waits;
79457
79458-atomic_t fscache_n_stores;
79459-atomic_t fscache_n_stores_ok;
79460-atomic_t fscache_n_stores_again;
79461-atomic_t fscache_n_stores_nobufs;
79462-atomic_t fscache_n_stores_oom;
79463-atomic_t fscache_n_store_ops;
79464-atomic_t fscache_n_store_calls;
79465-atomic_t fscache_n_store_pages;
79466-atomic_t fscache_n_store_radix_deletes;
79467-atomic_t fscache_n_store_pages_over_limit;
79468+atomic_unchecked_t fscache_n_stores;
79469+atomic_unchecked_t fscache_n_stores_ok;
79470+atomic_unchecked_t fscache_n_stores_again;
79471+atomic_unchecked_t fscache_n_stores_nobufs;
79472+atomic_unchecked_t fscache_n_stores_oom;
79473+atomic_unchecked_t fscache_n_store_ops;
79474+atomic_unchecked_t fscache_n_store_calls;
79475+atomic_unchecked_t fscache_n_store_pages;
79476+atomic_unchecked_t fscache_n_store_radix_deletes;
79477+atomic_unchecked_t fscache_n_store_pages_over_limit;
79478
79479-atomic_t fscache_n_store_vmscan_not_storing;
79480-atomic_t fscache_n_store_vmscan_gone;
79481-atomic_t fscache_n_store_vmscan_busy;
79482-atomic_t fscache_n_store_vmscan_cancelled;
79483-atomic_t fscache_n_store_vmscan_wait;
79484+atomic_unchecked_t fscache_n_store_vmscan_not_storing;
79485+atomic_unchecked_t fscache_n_store_vmscan_gone;
79486+atomic_unchecked_t fscache_n_store_vmscan_busy;
79487+atomic_unchecked_t fscache_n_store_vmscan_cancelled;
79488+atomic_unchecked_t fscache_n_store_vmscan_wait;
79489
79490-atomic_t fscache_n_marks;
79491-atomic_t fscache_n_uncaches;
79492+atomic_unchecked_t fscache_n_marks;
79493+atomic_unchecked_t fscache_n_uncaches;
79494
79495-atomic_t fscache_n_acquires;
79496-atomic_t fscache_n_acquires_null;
79497-atomic_t fscache_n_acquires_no_cache;
79498-atomic_t fscache_n_acquires_ok;
79499-atomic_t fscache_n_acquires_nobufs;
79500-atomic_t fscache_n_acquires_oom;
79501+atomic_unchecked_t fscache_n_acquires;
79502+atomic_unchecked_t fscache_n_acquires_null;
79503+atomic_unchecked_t fscache_n_acquires_no_cache;
79504+atomic_unchecked_t fscache_n_acquires_ok;
79505+atomic_unchecked_t fscache_n_acquires_nobufs;
79506+atomic_unchecked_t fscache_n_acquires_oom;
79507
79508-atomic_t fscache_n_invalidates;
79509-atomic_t fscache_n_invalidates_run;
79510+atomic_unchecked_t fscache_n_invalidates;
79511+atomic_unchecked_t fscache_n_invalidates_run;
79512
79513-atomic_t fscache_n_updates;
79514-atomic_t fscache_n_updates_null;
79515-atomic_t fscache_n_updates_run;
79516+atomic_unchecked_t fscache_n_updates;
79517+atomic_unchecked_t fscache_n_updates_null;
79518+atomic_unchecked_t fscache_n_updates_run;
79519
79520-atomic_t fscache_n_relinquishes;
79521-atomic_t fscache_n_relinquishes_null;
79522-atomic_t fscache_n_relinquishes_waitcrt;
79523-atomic_t fscache_n_relinquishes_retire;
79524+atomic_unchecked_t fscache_n_relinquishes;
79525+atomic_unchecked_t fscache_n_relinquishes_null;
79526+atomic_unchecked_t fscache_n_relinquishes_waitcrt;
79527+atomic_unchecked_t fscache_n_relinquishes_retire;
79528
79529-atomic_t fscache_n_cookie_index;
79530-atomic_t fscache_n_cookie_data;
79531-atomic_t fscache_n_cookie_special;
79532+atomic_unchecked_t fscache_n_cookie_index;
79533+atomic_unchecked_t fscache_n_cookie_data;
79534+atomic_unchecked_t fscache_n_cookie_special;
79535
79536-atomic_t fscache_n_object_alloc;
79537-atomic_t fscache_n_object_no_alloc;
79538-atomic_t fscache_n_object_lookups;
79539-atomic_t fscache_n_object_lookups_negative;
79540-atomic_t fscache_n_object_lookups_positive;
79541-atomic_t fscache_n_object_lookups_timed_out;
79542-atomic_t fscache_n_object_created;
79543-atomic_t fscache_n_object_avail;
79544-atomic_t fscache_n_object_dead;
79545+atomic_unchecked_t fscache_n_object_alloc;
79546+atomic_unchecked_t fscache_n_object_no_alloc;
79547+atomic_unchecked_t fscache_n_object_lookups;
79548+atomic_unchecked_t fscache_n_object_lookups_negative;
79549+atomic_unchecked_t fscache_n_object_lookups_positive;
79550+atomic_unchecked_t fscache_n_object_lookups_timed_out;
79551+atomic_unchecked_t fscache_n_object_created;
79552+atomic_unchecked_t fscache_n_object_avail;
79553+atomic_unchecked_t fscache_n_object_dead;
79554
79555-atomic_t fscache_n_checkaux_none;
79556-atomic_t fscache_n_checkaux_okay;
79557-atomic_t fscache_n_checkaux_update;
79558-atomic_t fscache_n_checkaux_obsolete;
79559+atomic_unchecked_t fscache_n_checkaux_none;
79560+atomic_unchecked_t fscache_n_checkaux_okay;
79561+atomic_unchecked_t fscache_n_checkaux_update;
79562+atomic_unchecked_t fscache_n_checkaux_obsolete;
79563
79564 atomic_t fscache_n_cop_alloc_object;
79565 atomic_t fscache_n_cop_lookup_object;
79566@@ -144,119 +144,119 @@ static int fscache_stats_show(struct seq_file *m, void *v)
79567 seq_puts(m, "FS-Cache statistics\n");
79568
79569 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
79570- atomic_read(&fscache_n_cookie_index),
79571- atomic_read(&fscache_n_cookie_data),
79572- atomic_read(&fscache_n_cookie_special));
79573+ atomic_read_unchecked(&fscache_n_cookie_index),
79574+ atomic_read_unchecked(&fscache_n_cookie_data),
79575+ atomic_read_unchecked(&fscache_n_cookie_special));
79576
79577 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
79578- atomic_read(&fscache_n_object_alloc),
79579- atomic_read(&fscache_n_object_no_alloc),
79580- atomic_read(&fscache_n_object_avail),
79581- atomic_read(&fscache_n_object_dead));
79582+ atomic_read_unchecked(&fscache_n_object_alloc),
79583+ atomic_read_unchecked(&fscache_n_object_no_alloc),
79584+ atomic_read_unchecked(&fscache_n_object_avail),
79585+ atomic_read_unchecked(&fscache_n_object_dead));
79586 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
79587- atomic_read(&fscache_n_checkaux_none),
79588- atomic_read(&fscache_n_checkaux_okay),
79589- atomic_read(&fscache_n_checkaux_update),
79590- atomic_read(&fscache_n_checkaux_obsolete));
79591+ atomic_read_unchecked(&fscache_n_checkaux_none),
79592+ atomic_read_unchecked(&fscache_n_checkaux_okay),
79593+ atomic_read_unchecked(&fscache_n_checkaux_update),
79594+ atomic_read_unchecked(&fscache_n_checkaux_obsolete));
79595
79596 seq_printf(m, "Pages : mrk=%u unc=%u\n",
79597- atomic_read(&fscache_n_marks),
79598- atomic_read(&fscache_n_uncaches));
79599+ atomic_read_unchecked(&fscache_n_marks),
79600+ atomic_read_unchecked(&fscache_n_uncaches));
79601
79602 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
79603 " oom=%u\n",
79604- atomic_read(&fscache_n_acquires),
79605- atomic_read(&fscache_n_acquires_null),
79606- atomic_read(&fscache_n_acquires_no_cache),
79607- atomic_read(&fscache_n_acquires_ok),
79608- atomic_read(&fscache_n_acquires_nobufs),
79609- atomic_read(&fscache_n_acquires_oom));
79610+ atomic_read_unchecked(&fscache_n_acquires),
79611+ atomic_read_unchecked(&fscache_n_acquires_null),
79612+ atomic_read_unchecked(&fscache_n_acquires_no_cache),
79613+ atomic_read_unchecked(&fscache_n_acquires_ok),
79614+ atomic_read_unchecked(&fscache_n_acquires_nobufs),
79615+ atomic_read_unchecked(&fscache_n_acquires_oom));
79616
79617 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
79618- atomic_read(&fscache_n_object_lookups),
79619- atomic_read(&fscache_n_object_lookups_negative),
79620- atomic_read(&fscache_n_object_lookups_positive),
79621- atomic_read(&fscache_n_object_created),
79622- atomic_read(&fscache_n_object_lookups_timed_out));
79623+ atomic_read_unchecked(&fscache_n_object_lookups),
79624+ atomic_read_unchecked(&fscache_n_object_lookups_negative),
79625+ atomic_read_unchecked(&fscache_n_object_lookups_positive),
79626+ atomic_read_unchecked(&fscache_n_object_created),
79627+ atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
79628
79629 seq_printf(m, "Invals : n=%u run=%u\n",
79630- atomic_read(&fscache_n_invalidates),
79631- atomic_read(&fscache_n_invalidates_run));
79632+ atomic_read_unchecked(&fscache_n_invalidates),
79633+ atomic_read_unchecked(&fscache_n_invalidates_run));
79634
79635 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
79636- atomic_read(&fscache_n_updates),
79637- atomic_read(&fscache_n_updates_null),
79638- atomic_read(&fscache_n_updates_run));
79639+ atomic_read_unchecked(&fscache_n_updates),
79640+ atomic_read_unchecked(&fscache_n_updates_null),
79641+ atomic_read_unchecked(&fscache_n_updates_run));
79642
79643 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
79644- atomic_read(&fscache_n_relinquishes),
79645- atomic_read(&fscache_n_relinquishes_null),
79646- atomic_read(&fscache_n_relinquishes_waitcrt),
79647- atomic_read(&fscache_n_relinquishes_retire));
79648+ atomic_read_unchecked(&fscache_n_relinquishes),
79649+ atomic_read_unchecked(&fscache_n_relinquishes_null),
79650+ atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
79651+ atomic_read_unchecked(&fscache_n_relinquishes_retire));
79652
79653 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
79654- atomic_read(&fscache_n_attr_changed),
79655- atomic_read(&fscache_n_attr_changed_ok),
79656- atomic_read(&fscache_n_attr_changed_nobufs),
79657- atomic_read(&fscache_n_attr_changed_nomem),
79658- atomic_read(&fscache_n_attr_changed_calls));
79659+ atomic_read_unchecked(&fscache_n_attr_changed),
79660+ atomic_read_unchecked(&fscache_n_attr_changed_ok),
79661+ atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
79662+ atomic_read_unchecked(&fscache_n_attr_changed_nomem),
79663+ atomic_read_unchecked(&fscache_n_attr_changed_calls));
79664
79665 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
79666- atomic_read(&fscache_n_allocs),
79667- atomic_read(&fscache_n_allocs_ok),
79668- atomic_read(&fscache_n_allocs_wait),
79669- atomic_read(&fscache_n_allocs_nobufs),
79670- atomic_read(&fscache_n_allocs_intr));
79671+ atomic_read_unchecked(&fscache_n_allocs),
79672+ atomic_read_unchecked(&fscache_n_allocs_ok),
79673+ atomic_read_unchecked(&fscache_n_allocs_wait),
79674+ atomic_read_unchecked(&fscache_n_allocs_nobufs),
79675+ atomic_read_unchecked(&fscache_n_allocs_intr));
79676 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
79677- atomic_read(&fscache_n_alloc_ops),
79678- atomic_read(&fscache_n_alloc_op_waits),
79679- atomic_read(&fscache_n_allocs_object_dead));
79680+ atomic_read_unchecked(&fscache_n_alloc_ops),
79681+ atomic_read_unchecked(&fscache_n_alloc_op_waits),
79682+ atomic_read_unchecked(&fscache_n_allocs_object_dead));
79683
79684 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
79685 " int=%u oom=%u\n",
79686- atomic_read(&fscache_n_retrievals),
79687- atomic_read(&fscache_n_retrievals_ok),
79688- atomic_read(&fscache_n_retrievals_wait),
79689- atomic_read(&fscache_n_retrievals_nodata),
79690- atomic_read(&fscache_n_retrievals_nobufs),
79691- atomic_read(&fscache_n_retrievals_intr),
79692- atomic_read(&fscache_n_retrievals_nomem));
79693+ atomic_read_unchecked(&fscache_n_retrievals),
79694+ atomic_read_unchecked(&fscache_n_retrievals_ok),
79695+ atomic_read_unchecked(&fscache_n_retrievals_wait),
79696+ atomic_read_unchecked(&fscache_n_retrievals_nodata),
79697+ atomic_read_unchecked(&fscache_n_retrievals_nobufs),
79698+ atomic_read_unchecked(&fscache_n_retrievals_intr),
79699+ atomic_read_unchecked(&fscache_n_retrievals_nomem));
79700 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
79701- atomic_read(&fscache_n_retrieval_ops),
79702- atomic_read(&fscache_n_retrieval_op_waits),
79703- atomic_read(&fscache_n_retrievals_object_dead));
79704+ atomic_read_unchecked(&fscache_n_retrieval_ops),
79705+ atomic_read_unchecked(&fscache_n_retrieval_op_waits),
79706+ atomic_read_unchecked(&fscache_n_retrievals_object_dead));
79707
79708 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
79709- atomic_read(&fscache_n_stores),
79710- atomic_read(&fscache_n_stores_ok),
79711- atomic_read(&fscache_n_stores_again),
79712- atomic_read(&fscache_n_stores_nobufs),
79713- atomic_read(&fscache_n_stores_oom));
79714+ atomic_read_unchecked(&fscache_n_stores),
79715+ atomic_read_unchecked(&fscache_n_stores_ok),
79716+ atomic_read_unchecked(&fscache_n_stores_again),
79717+ atomic_read_unchecked(&fscache_n_stores_nobufs),
79718+ atomic_read_unchecked(&fscache_n_stores_oom));
79719 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
79720- atomic_read(&fscache_n_store_ops),
79721- atomic_read(&fscache_n_store_calls),
79722- atomic_read(&fscache_n_store_pages),
79723- atomic_read(&fscache_n_store_radix_deletes),
79724- atomic_read(&fscache_n_store_pages_over_limit));
79725+ atomic_read_unchecked(&fscache_n_store_ops),
79726+ atomic_read_unchecked(&fscache_n_store_calls),
79727+ atomic_read_unchecked(&fscache_n_store_pages),
79728+ atomic_read_unchecked(&fscache_n_store_radix_deletes),
79729+ atomic_read_unchecked(&fscache_n_store_pages_over_limit));
79730
79731 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
79732- atomic_read(&fscache_n_store_vmscan_not_storing),
79733- atomic_read(&fscache_n_store_vmscan_gone),
79734- atomic_read(&fscache_n_store_vmscan_busy),
79735- atomic_read(&fscache_n_store_vmscan_cancelled),
79736- atomic_read(&fscache_n_store_vmscan_wait));
79737+ atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
79738+ atomic_read_unchecked(&fscache_n_store_vmscan_gone),
79739+ atomic_read_unchecked(&fscache_n_store_vmscan_busy),
79740+ atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
79741+ atomic_read_unchecked(&fscache_n_store_vmscan_wait));
79742
79743 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
79744- atomic_read(&fscache_n_op_pend),
79745- atomic_read(&fscache_n_op_run),
79746- atomic_read(&fscache_n_op_enqueue),
79747- atomic_read(&fscache_n_op_cancelled),
79748- atomic_read(&fscache_n_op_rejected));
79749+ atomic_read_unchecked(&fscache_n_op_pend),
79750+ atomic_read_unchecked(&fscache_n_op_run),
79751+ atomic_read_unchecked(&fscache_n_op_enqueue),
79752+ atomic_read_unchecked(&fscache_n_op_cancelled),
79753+ atomic_read_unchecked(&fscache_n_op_rejected));
79754 seq_printf(m, "Ops : ini=%u dfr=%u rel=%u gc=%u\n",
79755- atomic_read(&fscache_n_op_initialised),
79756- atomic_read(&fscache_n_op_deferred_release),
79757- atomic_read(&fscache_n_op_release),
79758- atomic_read(&fscache_n_op_gc));
79759+ atomic_read_unchecked(&fscache_n_op_initialised),
79760+ atomic_read_unchecked(&fscache_n_op_deferred_release),
79761+ atomic_read_unchecked(&fscache_n_op_release),
79762+ atomic_read_unchecked(&fscache_n_op_gc));
79763
79764 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
79765 atomic_read(&fscache_n_cop_alloc_object),
79766diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
79767index eae2c11..b277a45 100644
79768--- a/fs/fuse/cuse.c
79769+++ b/fs/fuse/cuse.c
79770@@ -609,10 +609,12 @@ static int __init cuse_init(void)
79771 INIT_LIST_HEAD(&cuse_conntbl[i]);
79772
79773 /* inherit and extend fuse_dev_operations */
79774- cuse_channel_fops = fuse_dev_operations;
79775- cuse_channel_fops.owner = THIS_MODULE;
79776- cuse_channel_fops.open = cuse_channel_open;
79777- cuse_channel_fops.release = cuse_channel_release;
79778+ pax_open_kernel();
79779+ memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
79780+ *(void **)&cuse_channel_fops.owner = THIS_MODULE;
79781+ *(void **)&cuse_channel_fops.open = cuse_channel_open;
79782+ *(void **)&cuse_channel_fops.release = cuse_channel_release;
79783+ pax_close_kernel();
79784
79785 cuse_class = class_create(THIS_MODULE, "cuse");
79786 if (IS_ERR(cuse_class))
79787diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
79788index ebb5e37..beae05b 100644
79789--- a/fs/fuse/dev.c
79790+++ b/fs/fuse/dev.c
79791@@ -1390,7 +1390,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
79792 ret = 0;
79793 pipe_lock(pipe);
79794
79795- if (!pipe->readers) {
79796+ if (!atomic_read(&pipe->readers)) {
79797 send_sig(SIGPIPE, current, 0);
79798 if (!ret)
79799 ret = -EPIPE;
79800@@ -1419,7 +1419,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
79801 page_nr++;
79802 ret += buf->len;
79803
79804- if (pipe->files)
79805+ if (atomic_read(&pipe->files))
79806 do_wakeup = 1;
79807 }
79808
79809diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
79810index a38e38f..6dbdcf6 100644
79811--- a/fs/gfs2/glock.c
79812+++ b/fs/gfs2/glock.c
79813@@ -385,9 +385,9 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state)
79814 if (held1 != held2) {
79815 GLOCK_BUG_ON(gl, __lockref_is_dead(&gl->gl_lockref));
79816 if (held2)
79817- gl->gl_lockref.count++;
79818+ __lockref_inc(&gl->gl_lockref);
79819 else
79820- gl->gl_lockref.count--;
79821+ __lockref_dec(&gl->gl_lockref);
79822 }
79823 if (held1 && held2 && list_empty(&gl->gl_holders))
79824 clear_bit(GLF_QUEUED, &gl->gl_flags);
79825@@ -614,9 +614,9 @@ out:
79826 out_sched:
79827 clear_bit(GLF_LOCK, &gl->gl_flags);
79828 smp_mb__after_atomic();
79829- gl->gl_lockref.count++;
79830+ __lockref_inc(&gl->gl_lockref);
79831 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
79832- gl->gl_lockref.count--;
79833+ __lockref_dec(&gl->gl_lockref);
79834 return;
79835
79836 out_unlock:
79837@@ -742,7 +742,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
79838 gl->gl_sbd = sdp;
79839 gl->gl_flags = 0;
79840 gl->gl_name = name;
79841- gl->gl_lockref.count = 1;
79842+ __lockref_set(&gl->gl_lockref, 1);
79843 gl->gl_state = LM_ST_UNLOCKED;
79844 gl->gl_target = LM_ST_UNLOCKED;
79845 gl->gl_demote_state = LM_ST_EXCLUSIVE;
79846@@ -1020,9 +1020,9 @@ int gfs2_glock_nq(struct gfs2_holder *gh)
79847 if (unlikely((LM_FLAG_NOEXP & gh->gh_flags) &&
79848 test_and_clear_bit(GLF_FROZEN, &gl->gl_flags))) {
79849 set_bit(GLF_REPLY_PENDING, &gl->gl_flags);
79850- gl->gl_lockref.count++;
79851+ __lockref_inc(&gl->gl_lockref);
79852 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
79853- gl->gl_lockref.count--;
79854+ __lockref_dec(&gl->gl_lockref);
79855 }
79856 run_queue(gl, 1);
79857 spin_unlock(&gl->gl_spin);
79858@@ -1326,7 +1326,7 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret)
79859 }
79860 }
79861
79862- gl->gl_lockref.count++;
79863+ __lockref_inc(&gl->gl_lockref);
79864 set_bit(GLF_REPLY_PENDING, &gl->gl_flags);
79865 spin_unlock(&gl->gl_spin);
79866
79867@@ -1385,12 +1385,12 @@ add_back_to_lru:
79868 goto add_back_to_lru;
79869 }
79870 clear_bit(GLF_LRU, &gl->gl_flags);
79871- gl->gl_lockref.count++;
79872+ __lockref_inc(&gl->gl_lockref);
79873 if (demote_ok(gl))
79874 handle_callback(gl, LM_ST_UNLOCKED, 0, false);
79875 WARN_ON(!test_and_clear_bit(GLF_LOCK, &gl->gl_flags));
79876 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
79877- gl->gl_lockref.count--;
79878+ __lockref_dec(&gl->gl_lockref);
79879 spin_unlock(&gl->gl_spin);
79880 cond_resched_lock(&lru_lock);
79881 }
79882@@ -1720,7 +1720,7 @@ void gfs2_dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
79883 state2str(gl->gl_demote_state), dtime,
79884 atomic_read(&gl->gl_ail_count),
79885 atomic_read(&gl->gl_revokes),
79886- (int)gl->gl_lockref.count, gl->gl_hold_time);
79887+ __lockref_read(&gl->gl_lockref), gl->gl_hold_time);
79888
79889 list_for_each_entry(gh, &gl->gl_holders, gh_list)
79890 dump_holder(seq, gh);
79891diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
79892index fa3fa5e..9fe2272 100644
79893--- a/fs/gfs2/glops.c
79894+++ b/fs/gfs2/glops.c
79895@@ -552,9 +552,9 @@ static void iopen_go_callback(struct gfs2_glock *gl, bool remote)
79896
79897 if (gl->gl_demote_state == LM_ST_UNLOCKED &&
79898 gl->gl_state == LM_ST_SHARED && ip) {
79899- gl->gl_lockref.count++;
79900+ __lockref_inc(&gl->gl_lockref);
79901 if (queue_work(gfs2_delete_workqueue, &gl->gl_delete) == 0)
79902- gl->gl_lockref.count--;
79903+ __lockref_dec(&gl->gl_lockref);
79904 }
79905 }
79906
79907diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
79908index 9b61f92..ab84778 100644
79909--- a/fs/gfs2/quota.c
79910+++ b/fs/gfs2/quota.c
79911@@ -154,7 +154,7 @@ static enum lru_status gfs2_qd_isolate(struct list_head *item,
79912 if (!spin_trylock(&qd->qd_lockref.lock))
79913 return LRU_SKIP;
79914
79915- if (qd->qd_lockref.count == 0) {
79916+ if (__lockref_read(&qd->qd_lockref) == 0) {
79917 lockref_mark_dead(&qd->qd_lockref);
79918 list_lru_isolate_move(lru, &qd->qd_lru, dispose);
79919 }
79920@@ -221,7 +221,7 @@ static struct gfs2_quota_data *qd_alloc(unsigned hash, struct gfs2_sbd *sdp, str
79921 return NULL;
79922
79923 qd->qd_sbd = sdp;
79924- qd->qd_lockref.count = 1;
79925+ __lockref_set(&qd->qd_lockref, 1);
79926 spin_lock_init(&qd->qd_lockref.lock);
79927 qd->qd_id = qid;
79928 qd->qd_slot = -1;
79929@@ -312,7 +312,7 @@ static void qd_put(struct gfs2_quota_data *qd)
79930 if (lockref_put_or_lock(&qd->qd_lockref))
79931 return;
79932
79933- qd->qd_lockref.count = 0;
79934+ __lockref_set(&qd->qd_lockref, 0);
79935 list_lru_add(&gfs2_qd_lru, &qd->qd_lru);
79936 spin_unlock(&qd->qd_lockref.lock);
79937
79938diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
79939index 973c24c..a3cbeb3 100644
79940--- a/fs/hugetlbfs/inode.c
79941+++ b/fs/hugetlbfs/inode.c
79942@@ -150,6 +150,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
79943 struct mm_struct *mm = current->mm;
79944 struct vm_area_struct *vma;
79945 struct hstate *h = hstate_file(file);
79946+ unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
79947 struct vm_unmapped_area_info info;
79948
79949 if (len & ~huge_page_mask(h))
79950@@ -163,17 +164,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
79951 return addr;
79952 }
79953
79954+#ifdef CONFIG_PAX_RANDMMAP
79955+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
79956+#endif
79957+
79958 if (addr) {
79959 addr = ALIGN(addr, huge_page_size(h));
79960 vma = find_vma(mm, addr);
79961- if (TASK_SIZE - len >= addr &&
79962- (!vma || addr + len <= vma->vm_start))
79963+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
79964 return addr;
79965 }
79966
79967 info.flags = 0;
79968 info.length = len;
79969 info.low_limit = TASK_UNMAPPED_BASE;
79970+
79971+#ifdef CONFIG_PAX_RANDMMAP
79972+ if (mm->pax_flags & MF_PAX_RANDMMAP)
79973+ info.low_limit += mm->delta_mmap;
79974+#endif
79975+
79976 info.high_limit = TASK_SIZE;
79977 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
79978 info.align_offset = 0;
79979@@ -938,7 +948,7 @@ static struct file_system_type hugetlbfs_fs_type = {
79980 };
79981 MODULE_ALIAS_FS("hugetlbfs");
79982
79983-static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
79984+struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
79985
79986 static int can_do_hugetlb_shm(void)
79987 {
79988diff --git a/fs/inode.c b/fs/inode.c
79989index d30640f..9d909a7 100644
79990--- a/fs/inode.c
79991+++ b/fs/inode.c
79992@@ -832,19 +832,19 @@ unsigned int get_next_ino(void)
79993 unsigned int *p = &get_cpu_var(last_ino);
79994 unsigned int res = *p;
79995
79996+start:
79997+
79998 #ifdef CONFIG_SMP
79999 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
80000- static atomic_t shared_last_ino;
80001- int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
80002+ static atomic_unchecked_t shared_last_ino;
80003+ int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
80004
80005 res = next - LAST_INO_BATCH;
80006 }
80007 #endif
80008
80009- res++;
80010- /* get_next_ino should not provide a 0 inode number */
80011- if (unlikely(!res))
80012- res++;
80013+ if (unlikely(!++res))
80014+ goto start; /* never zero */
80015 *p = res;
80016 put_cpu_var(last_ino);
80017 return res;
80018diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
80019index 4a6cf28..d3a29d3 100644
80020--- a/fs/jffs2/erase.c
80021+++ b/fs/jffs2/erase.c
80022@@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
80023 struct jffs2_unknown_node marker = {
80024 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
80025 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
80026- .totlen = cpu_to_je32(c->cleanmarker_size)
80027+ .totlen = cpu_to_je32(c->cleanmarker_size),
80028+ .hdr_crc = cpu_to_je32(0)
80029 };
80030
80031 jffs2_prealloc_raw_node_refs(c, jeb, 1);
80032diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
80033index 09ed551..45684f8 100644
80034--- a/fs/jffs2/wbuf.c
80035+++ b/fs/jffs2/wbuf.c
80036@@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
80037 {
80038 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
80039 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
80040- .totlen = constant_cpu_to_je32(8)
80041+ .totlen = constant_cpu_to_je32(8),
80042+ .hdr_crc = constant_cpu_to_je32(0)
80043 };
80044
80045 /*
80046diff --git a/fs/jfs/super.c b/fs/jfs/super.c
80047index 4cd9798..8dfe86a 100644
80048--- a/fs/jfs/super.c
80049+++ b/fs/jfs/super.c
80050@@ -901,7 +901,7 @@ static int __init init_jfs_fs(void)
80051
80052 jfs_inode_cachep =
80053 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
80054- SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
80055+ SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
80056 init_once);
80057 if (jfs_inode_cachep == NULL)
80058 return -ENOMEM;
80059diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
80060index 2d48d28..82eddad 100644
80061--- a/fs/kernfs/dir.c
80062+++ b/fs/kernfs/dir.c
80063@@ -182,7 +182,7 @@ struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn)
80064 *
80065 * Returns 31 bit hash of ns + name (so it fits in an off_t )
80066 */
80067-static unsigned int kernfs_name_hash(const char *name, const void *ns)
80068+static unsigned int kernfs_name_hash(const unsigned char *name, const void *ns)
80069 {
80070 unsigned long hash = init_name_hash();
80071 unsigned int len = strlen(name);
80072@@ -873,6 +873,12 @@ static int kernfs_iop_mkdir(struct inode *dir, struct dentry *dentry,
80073 ret = scops->mkdir(parent, dentry->d_name.name, mode);
80074
80075 kernfs_put_active(parent);
80076+
80077+ if (!ret) {
80078+ struct dentry *dentry_ret = kernfs_iop_lookup(dir, dentry, 0);
80079+ ret = PTR_ERR_OR_ZERO(dentry_ret);
80080+ }
80081+
80082 return ret;
80083 }
80084
80085diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
80086index 7247252..c73808e 100644
80087--- a/fs/kernfs/file.c
80088+++ b/fs/kernfs/file.c
80089@@ -34,7 +34,7 @@ static DEFINE_MUTEX(kernfs_open_file_mutex);
80090
80091 struct kernfs_open_node {
80092 atomic_t refcnt;
80093- atomic_t event;
80094+ atomic_unchecked_t event;
80095 wait_queue_head_t poll;
80096 struct list_head files; /* goes through kernfs_open_file.list */
80097 };
80098@@ -163,7 +163,7 @@ static int kernfs_seq_show(struct seq_file *sf, void *v)
80099 {
80100 struct kernfs_open_file *of = sf->private;
80101
80102- of->event = atomic_read(&of->kn->attr.open->event);
80103+ of->event = atomic_read_unchecked(&of->kn->attr.open->event);
80104
80105 return of->kn->attr.ops->seq_show(sf, v);
80106 }
80107@@ -207,7 +207,7 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
80108 goto out_free;
80109 }
80110
80111- of->event = atomic_read(&of->kn->attr.open->event);
80112+ of->event = atomic_read_unchecked(&of->kn->attr.open->event);
80113 ops = kernfs_ops(of->kn);
80114 if (ops->read)
80115 len = ops->read(of, buf, len, *ppos);
80116@@ -272,7 +272,7 @@ static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf,
80117 {
80118 struct kernfs_open_file *of = kernfs_of(file);
80119 const struct kernfs_ops *ops;
80120- size_t len;
80121+ ssize_t len;
80122 char *buf;
80123
80124 if (of->atomic_write_len) {
80125@@ -385,12 +385,12 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma,
80126 return ret;
80127 }
80128
80129-static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
80130- void *buf, int len, int write)
80131+static ssize_t kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
80132+ void *buf, size_t len, int write)
80133 {
80134 struct file *file = vma->vm_file;
80135 struct kernfs_open_file *of = kernfs_of(file);
80136- int ret;
80137+ ssize_t ret;
80138
80139 if (!of->vm_ops)
80140 return -EINVAL;
80141@@ -569,7 +569,7 @@ static int kernfs_get_open_node(struct kernfs_node *kn,
80142 return -ENOMEM;
80143
80144 atomic_set(&new_on->refcnt, 0);
80145- atomic_set(&new_on->event, 1);
80146+ atomic_set_unchecked(&new_on->event, 1);
80147 init_waitqueue_head(&new_on->poll);
80148 INIT_LIST_HEAD(&new_on->files);
80149 goto retry;
80150@@ -792,7 +792,7 @@ static unsigned int kernfs_fop_poll(struct file *filp, poll_table *wait)
80151
80152 kernfs_put_active(kn);
80153
80154- if (of->event != atomic_read(&on->event))
80155+ if (of->event != atomic_read_unchecked(&on->event))
80156 goto trigger;
80157
80158 return DEFAULT_POLLMASK;
80159@@ -823,7 +823,7 @@ repeat:
80160
80161 on = kn->attr.open;
80162 if (on) {
80163- atomic_inc(&on->event);
80164+ atomic_inc_unchecked(&on->event);
80165 wake_up_interruptible(&on->poll);
80166 }
80167
80168diff --git a/fs/libfs.c b/fs/libfs.c
80169index c7cbfb0..fc3636d4 100644
80170--- a/fs/libfs.c
80171+++ b/fs/libfs.c
80172@@ -155,6 +155,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
80173
80174 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
80175 struct dentry *next = list_entry(p, struct dentry, d_child);
80176+ char d_name[sizeof(next->d_iname)];
80177+ const unsigned char *name;
80178+
80179 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
80180 if (!simple_positive(next)) {
80181 spin_unlock(&next->d_lock);
80182@@ -163,7 +166,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
80183
80184 spin_unlock(&next->d_lock);
80185 spin_unlock(&dentry->d_lock);
80186- if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
80187+ name = next->d_name.name;
80188+ if (name == next->d_iname) {
80189+ memcpy(d_name, name, next->d_name.len);
80190+ name = d_name;
80191+ }
80192+ if (!dir_emit(ctx, name, next->d_name.len,
80193 d_inode(next)->i_ino, dt_type(d_inode(next))))
80194 return 0;
80195 spin_lock(&dentry->d_lock);
80196diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
80197index acd3947..1f896e2 100644
80198--- a/fs/lockd/clntproc.c
80199+++ b/fs/lockd/clntproc.c
80200@@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
80201 /*
80202 * Cookie counter for NLM requests
80203 */
80204-static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
80205+static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
80206
80207 void nlmclnt_next_cookie(struct nlm_cookie *c)
80208 {
80209- u32 cookie = atomic_inc_return(&nlm_cookie);
80210+ u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
80211
80212 memcpy(c->data, &cookie, 4);
80213 c->len=4;
80214diff --git a/fs/mount.h b/fs/mount.h
80215index 14db05d..687f6d8 100644
80216--- a/fs/mount.h
80217+++ b/fs/mount.h
80218@@ -13,7 +13,7 @@ struct mnt_namespace {
80219 u64 seq; /* Sequence number to prevent loops */
80220 wait_queue_head_t poll;
80221 u64 event;
80222-};
80223+} __randomize_layout;
80224
80225 struct mnt_pcp {
80226 int mnt_count;
80227@@ -65,7 +65,7 @@ struct mount {
80228 struct hlist_head mnt_pins;
80229 struct fs_pin mnt_umount;
80230 struct dentry *mnt_ex_mountpoint;
80231-};
80232+} __randomize_layout;
80233
80234 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
80235
80236diff --git a/fs/namei.c b/fs/namei.c
80237index 36df481..c3045fd 100644
80238--- a/fs/namei.c
80239+++ b/fs/namei.c
80240@@ -336,17 +336,32 @@ int generic_permission(struct inode *inode, int mask)
80241 if (ret != -EACCES)
80242 return ret;
80243
80244+#ifdef CONFIG_GRKERNSEC
80245+ /* we'll block if we have to log due to a denied capability use */
80246+ if (mask & MAY_NOT_BLOCK)
80247+ return -ECHILD;
80248+#endif
80249+
80250 if (S_ISDIR(inode->i_mode)) {
80251 /* DACs are overridable for directories */
80252- if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
80253- return 0;
80254 if (!(mask & MAY_WRITE))
80255- if (capable_wrt_inode_uidgid(inode,
80256- CAP_DAC_READ_SEARCH))
80257+ if (capable_wrt_inode_uidgid_nolog(inode, CAP_DAC_OVERRIDE) ||
80258+ capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
80259 return 0;
80260+ if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
80261+ return 0;
80262 return -EACCES;
80263 }
80264 /*
80265+ * Searching includes executable on directories, else just read.
80266+ */
80267+ mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
80268+ if (mask == MAY_READ)
80269+ if (capable_wrt_inode_uidgid_nolog(inode, CAP_DAC_OVERRIDE) ||
80270+ capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
80271+ return 0;
80272+
80273+ /*
80274 * Read/write DACs are always overridable.
80275 * Executable DACs are overridable when there is
80276 * at least one exec bit set.
80277@@ -355,14 +370,6 @@ int generic_permission(struct inode *inode, int mask)
80278 if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
80279 return 0;
80280
80281- /*
80282- * Searching includes executable on directories, else just read.
80283- */
80284- mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
80285- if (mask == MAY_READ)
80286- if (capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
80287- return 0;
80288-
80289 return -EACCES;
80290 }
80291 EXPORT_SYMBOL(generic_permission);
80292@@ -514,12 +521,35 @@ struct nameidata {
80293 struct nameidata *saved;
80294 unsigned root_seq;
80295 int dfd;
80296-};
80297+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80298+ struct path *symlinkown_stack;
80299+ struct path symlinkown_internal[EMBEDDED_LEVELS];
80300+ unsigned symlinkown_depth;
80301+ int symlinkown_enabled;
80302+#endif
80303+} __randomize_layout;
80304+
80305+static int gr_handle_nameidata_symlinkowner(const struct nameidata *nd, const struct inode *target)
80306+{
80307+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80308+ int i;
80309+
80310+ for (i = 0; i < nd->symlinkown_depth; i++) {
80311+ if (gr_handle_symlink_owner(&nd->symlinkown_stack[i], target))
80312+ return -EACCES;
80313+ }
80314+#endif
80315+ return 0;
80316+}
80317
80318 static void set_nameidata(struct nameidata *p, int dfd, struct filename *name)
80319 {
80320 struct nameidata *old = current->nameidata;
80321 p->stack = p->internal;
80322+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80323+ p->symlinkown_stack = p->symlinkown_internal;
80324+ p->symlinkown_enabled = -1;
80325+#endif
80326 p->dfd = dfd;
80327 p->name = name;
80328 p->total_link_count = old ? old->total_link_count : 0;
80329@@ -538,6 +568,12 @@ static void restore_nameidata(void)
80330 kfree(now->stack);
80331 now->stack = now->internal;
80332 }
80333+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80334+ if (now->symlinkown_stack != now->symlinkown_internal) {
80335+ kfree(now->symlinkown_stack);
80336+ now->symlinkown_stack = now->symlinkown_internal;
80337+ }
80338+#endif
80339 }
80340
80341 static int __nd_alloc_stack(struct nameidata *nd)
80342@@ -557,9 +593,29 @@ static int __nd_alloc_stack(struct nameidata *nd)
80343 }
80344 memcpy(p, nd->internal, sizeof(nd->internal));
80345 nd->stack = p;
80346+
80347 return 0;
80348 }
80349
80350+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80351+static int nd_alloc_symlinkown_stack(struct nameidata *nd)
80352+{
80353+ struct path *p;
80354+
80355+ if (likely(nd->symlinkown_depth != EMBEDDED_LEVELS))
80356+ return 0;
80357+ if (nd->symlinkown_stack != nd->symlinkown_internal)
80358+ return 0;
80359+
80360+ p = kmalloc(MAXSYMLINKS * sizeof(struct path), GFP_KERNEL);
80361+ if (unlikely(!p))
80362+ return -ENOMEM;
80363+ memcpy(p, nd->symlinkown_internal, sizeof(nd->symlinkown_internal));
80364+ nd->symlinkown_stack = p;
80365+ return 0;
80366+}
80367+#endif
80368+
80369 /**
80370 * path_connected - Verify that a path->dentry is below path->mnt.mnt_root
80371 * @path: nameidate to verify
80372@@ -580,6 +636,11 @@ static bool path_connected(const struct path *path)
80373
80374 static inline int nd_alloc_stack(struct nameidata *nd)
80375 {
80376+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80377+ if (nd->flags & LOOKUP_RCU)
80378+ return -ECHILD;
80379+#endif
80380+
80381 if (likely(nd->depth != EMBEDDED_LEVELS))
80382 return 0;
80383 if (likely(nd->stack != nd->internal))
80384@@ -608,6 +669,14 @@ static void terminate_walk(struct nameidata *nd)
80385 path_put(&nd->path);
80386 for (i = 0; i < nd->depth; i++)
80387 path_put(&nd->stack[i].link);
80388+
80389+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80390+ /* we'll only ever set our values in ref-walk mode */
80391+ for (i = 0; i < nd->symlinkown_depth; i++)
80392+ path_put(&nd->symlinkown_stack[i]);
80393+ nd->symlinkown_depth = 0;
80394+#endif
80395+
80396 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) {
80397 path_put(&nd->root);
80398 nd->root.mnt = NULL;
80399@@ -1004,6 +1073,9 @@ const char *get_link(struct nameidata *nd)
80400 if (unlikely(error))
80401 return ERR_PTR(error);
80402
80403+ if (gr_handle_follow_link(dentry, last->link.mnt))
80404+ return ERR_PTR(-EACCES);
80405+
80406 nd->last_type = LAST_BIND;
80407 res = inode->i_link;
80408 if (!res) {
80409@@ -1692,6 +1764,23 @@ static int pick_link(struct nameidata *nd, struct path *link,
80410 }
80411 }
80412
80413+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80414+ if (unlikely(nd->symlinkown_enabled == -1))
80415+ nd->symlinkown_enabled = gr_get_symlinkown_enabled();
80416+ if (nd->symlinkown_enabled && gr_is_global_nonroot(inode->i_uid)) {
80417+ struct path *symlinkownlast;
80418+ error = nd_alloc_symlinkown_stack(nd);
80419+ if (unlikely(error)) {
80420+ path_put(link);
80421+ return error;
80422+ }
80423+ symlinkownlast = nd->symlinkown_stack + nd->symlinkown_depth++;
80424+ symlinkownlast->dentry = link->dentry;
80425+ symlinkownlast->mnt = link->mnt;
80426+ path_get(symlinkownlast);
80427+ }
80428+#endif
80429+
80430 last = nd->stack + nd->depth++;
80431 last->link = *link;
80432 last->cookie = NULL;
80433@@ -1831,7 +1920,7 @@ EXPORT_SYMBOL(full_name_hash);
80434 static inline u64 hash_name(const char *name)
80435 {
80436 unsigned long a, b, adata, bdata, mask, hash, len;
80437- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80438+ static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80439
80440 hash = a = 0;
80441 len = -sizeof(unsigned long);
80442@@ -2000,6 +2089,9 @@ static const char *path_init(struct nameidata *nd, unsigned flags)
80443 nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT;
80444 nd->depth = 0;
80445 nd->total_link_count = 0;
80446+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
80447+ nd->symlinkown_depth = 0;
80448+#endif
80449 if (flags & LOOKUP_ROOT) {
80450 struct dentry *root = nd->root.dentry;
80451 struct inode *inode = root->d_inode;
80452@@ -2137,6 +2229,11 @@ static int path_lookupat(struct nameidata *nd, unsigned flags, struct path *path
80453 if (!err)
80454 err = complete_walk(nd);
80455
80456+ if (!err && !(nd->flags & LOOKUP_PARENT)) {
80457+ if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt))
80458+ err = -ENOENT;
80459+ }
80460+
80461 if (!err && nd->flags & LOOKUP_DIRECTORY)
80462 if (!d_can_lookup(nd->path.dentry))
80463 err = -ENOTDIR;
80464@@ -2185,6 +2282,10 @@ static int path_parentat(struct nameidata *nd, unsigned flags,
80465 err = link_path_walk(s, nd);
80466 if (!err)
80467 err = complete_walk(nd);
80468+
80469+ if (!err && gr_handle_nameidata_symlinkowner(nd, nd->inode))
80470+ err = -EACCES;
80471+
80472 if (!err) {
80473 *parent = nd->path;
80474 nd->path.mnt = NULL;
80475@@ -2716,6 +2817,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
80476 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
80477 return -EPERM;
80478
80479+ if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
80480+ return -EPERM;
80481+ if (gr_handle_rawio(inode))
80482+ return -EPERM;
80483+ if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
80484+ return -EACCES;
80485+
80486 return 0;
80487 }
80488
80489@@ -2982,6 +3090,18 @@ static int lookup_open(struct nameidata *nd, struct path *path,
80490 /* Negative dentry, just create the file */
80491 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
80492 umode_t mode = op->mode;
80493+
80494+
80495+ if (gr_handle_nameidata_symlinkowner(nd, dir_inode)) {
80496+ error = -EACCES;
80497+ goto out_dput;
80498+ }
80499+
80500+ if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
80501+ error = -EACCES;
80502+ goto out_dput;
80503+ }
80504+
80505 if (!IS_POSIXACL(dir->d_inode))
80506 mode &= ~current_umask();
80507 /*
80508@@ -3003,6 +3123,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
80509 nd->flags & LOOKUP_EXCL);
80510 if (error)
80511 goto out_dput;
80512+ else
80513+ gr_handle_create(dentry, nd->path.mnt);
80514 }
80515 out_no_open:
80516 path->dentry = dentry;
80517@@ -3066,6 +3188,9 @@ static int do_last(struct nameidata *nd,
80518 if (error)
80519 return error;
80520
80521+ if (!gr_acl_handle_hidden_file(dir, nd->path.mnt))
80522+ return -ENOENT;
80523+
80524 audit_inode(nd->name, dir, LOOKUP_PARENT);
80525 /* trailing slashes? */
80526 if (unlikely(nd->last.name[nd->last.len]))
80527@@ -3108,11 +3233,24 @@ retry_lookup:
80528 goto finish_open_created;
80529 }
80530
80531+ if (!gr_acl_handle_hidden_file(path.dentry, nd->path.mnt)) {
80532+ path_to_nameidata(&path, nd);
80533+ return -ENOENT;
80534+ }
80535+
80536 /*
80537 * create/update audit record if it already exists.
80538 */
80539- if (d_is_positive(path.dentry))
80540+ if (d_is_positive(path.dentry)) {
80541+ /* only check if O_CREAT is specified, all other checks need to go
80542+ into may_open */
80543+ if (gr_handle_fifo(path.dentry, path.mnt, dir, open_flag, acc_mode)) {
80544+ path_to_nameidata(&path, nd);
80545+ return -EACCES;
80546+ }
80547+
80548 audit_inode(nd->name, path.dentry, 0);
80549+ }
80550
80551 /*
80552 * If atomic_open() acquired write access it is dropped now due to
80553@@ -3148,6 +3286,11 @@ finish_lookup:
80554 if (unlikely(error))
80555 return error;
80556
80557+ if (gr_handle_nameidata_symlinkowner(nd, inode)) {
80558+ path_to_nameidata(&path, nd);
80559+ return -EACCES;
80560+ }
80561+
80562 if (unlikely(d_is_symlink(path.dentry)) && !(open_flag & O_PATH)) {
80563 path_to_nameidata(&path, nd);
80564 return -ELOOP;
80565@@ -3170,6 +3313,12 @@ finish_open:
80566 path_put(&save_parent);
80567 return error;
80568 }
80569+
80570+ if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
80571+ error = -ENOENT;
80572+ goto out;
80573+ }
80574+
80575 audit_inode(nd->name, nd->path.dentry, 0);
80576 error = -EISDIR;
80577 if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry))
80578@@ -3436,9 +3585,11 @@ static struct dentry *filename_create(int dfd, struct filename *name,
80579 goto unlock;
80580
80581 error = -EEXIST;
80582- if (d_is_positive(dentry))
80583+ if (d_is_positive(dentry)) {
80584+ if (!gr_acl_handle_hidden_file(dentry, path->mnt))
80585+ error = -ENOENT;
80586 goto fail;
80587-
80588+ }
80589 /*
80590 * Special case - lookup gave negative, but... we had foo/bar/
80591 * From the vfs_mknod() POV we just have a negative dentry -
80592@@ -3492,6 +3643,20 @@ inline struct dentry *user_path_create(int dfd, const char __user *pathname,
80593 }
80594 EXPORT_SYMBOL(user_path_create);
80595
80596+static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
80597+{
80598+ struct filename *tmp = getname(pathname);
80599+ struct dentry *res;
80600+ if (IS_ERR(tmp))
80601+ return ERR_CAST(tmp);
80602+ res = kern_path_create(dfd, tmp->name, path, lookup_flags);
80603+ if (IS_ERR(res))
80604+ putname(tmp);
80605+ else
80606+ *to = tmp;
80607+ return res;
80608+}
80609+
80610 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
80611 {
80612 int error = may_create(dir, dentry);
80613@@ -3555,6 +3720,17 @@ retry:
80614
80615 if (!IS_POSIXACL(path.dentry->d_inode))
80616 mode &= ~current_umask();
80617+
80618+ if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
80619+ error = -EPERM;
80620+ goto out;
80621+ }
80622+
80623+ if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
80624+ error = -EACCES;
80625+ goto out;
80626+ }
80627+
80628 error = security_path_mknod(&path, dentry, mode, dev);
80629 if (error)
80630 goto out;
80631@@ -3570,6 +3746,8 @@ retry:
80632 error = vfs_mknod(path.dentry->d_inode,dentry,mode,0);
80633 break;
80634 }
80635+ if (!error)
80636+ gr_handle_create(dentry, path.mnt);
80637 out:
80638 done_path_create(&path, dentry);
80639 if (retry_estale(error, lookup_flags)) {
80640@@ -3624,9 +3802,16 @@ retry:
80641
80642 if (!IS_POSIXACL(path.dentry->d_inode))
80643 mode &= ~current_umask();
80644+ if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
80645+ error = -EACCES;
80646+ goto out;
80647+ }
80648 error = security_path_mkdir(&path, dentry, mode);
80649 if (!error)
80650 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
80651+ if (!error)
80652+ gr_handle_create(dentry, path.mnt);
80653+out:
80654 done_path_create(&path, dentry);
80655 if (retry_estale(error, lookup_flags)) {
80656 lookup_flags |= LOOKUP_REVAL;
80657@@ -3659,7 +3844,7 @@ void dentry_unhash(struct dentry *dentry)
80658 {
80659 shrink_dcache_parent(dentry);
80660 spin_lock(&dentry->d_lock);
80661- if (dentry->d_lockref.count == 1)
80662+ if (__lockref_read(&dentry->d_lockref) == 1)
80663 __d_drop(dentry);
80664 spin_unlock(&dentry->d_lock);
80665 }
80666@@ -3712,6 +3897,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
80667 struct path path;
80668 struct qstr last;
80669 int type;
80670+ u64 saved_ino = 0;
80671+ dev_t saved_dev = 0;
80672 unsigned int lookup_flags = 0;
80673 retry:
80674 name = user_path_parent(dfd, pathname,
80675@@ -3744,10 +3931,20 @@ retry:
80676 error = -ENOENT;
80677 goto exit3;
80678 }
80679+ saved_ino = gr_get_ino_from_dentry(dentry);
80680+ saved_dev = gr_get_dev_from_dentry(dentry);
80681+
80682+ if (!gr_acl_handle_rmdir(dentry, path.mnt)) {
80683+ error = -EACCES;
80684+ goto exit3;
80685+ }
80686+
80687 error = security_path_rmdir(&path, dentry);
80688 if (error)
80689 goto exit3;
80690 error = vfs_rmdir(path.dentry->d_inode, dentry);
80691+ if (!error && (saved_dev || saved_ino))
80692+ gr_handle_delete(saved_ino, saved_dev);
80693 exit3:
80694 dput(dentry);
80695 exit2:
80696@@ -3842,6 +4039,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
80697 int type;
80698 struct inode *inode = NULL;
80699 struct inode *delegated_inode = NULL;
80700+ u64 saved_ino = 0;
80701+ dev_t saved_dev = 0;
80702 unsigned int lookup_flags = 0;
80703 retry:
80704 name = user_path_parent(dfd, pathname,
80705@@ -3868,10 +4067,21 @@ retry_deleg:
80706 if (d_is_negative(dentry))
80707 goto slashes;
80708 ihold(inode);
80709+ if (inode->i_nlink <= 1) {
80710+ saved_ino = gr_get_ino_from_dentry(dentry);
80711+ saved_dev = gr_get_dev_from_dentry(dentry);
80712+ }
80713+ if (!gr_acl_handle_unlink(dentry, path.mnt)) {
80714+ error = -EACCES;
80715+ goto exit2;
80716+ }
80717+
80718 error = security_path_unlink(&path, dentry);
80719 if (error)
80720 goto exit2;
80721 error = vfs_unlink(path.dentry->d_inode, dentry, &delegated_inode);
80722+ if (!error && (saved_ino || saved_dev))
80723+ gr_handle_delete(saved_ino, saved_dev);
80724 exit2:
80725 dput(dentry);
80726 }
80727@@ -3960,9 +4170,17 @@ retry:
80728 if (IS_ERR(dentry))
80729 goto out_putname;
80730
80731+ if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
80732+ error = -EACCES;
80733+ goto out;
80734+ }
80735+
80736 error = security_path_symlink(&path, dentry, from->name);
80737 if (!error)
80738 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
80739+ if (!error)
80740+ gr_handle_create(dentry, path.mnt);
80741+out:
80742 done_path_create(&path, dentry);
80743 if (retry_estale(error, lookup_flags)) {
80744 lookup_flags |= LOOKUP_REVAL;
80745@@ -4066,6 +4284,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
80746 struct dentry *new_dentry;
80747 struct path old_path, new_path;
80748 struct inode *delegated_inode = NULL;
80749+ struct filename *to = NULL;
80750 int how = 0;
80751 int error;
80752
80753@@ -4089,7 +4308,7 @@ retry:
80754 if (error)
80755 return error;
80756
80757- new_dentry = user_path_create(newdfd, newname, &new_path,
80758+ new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
80759 (how & LOOKUP_REVAL));
80760 error = PTR_ERR(new_dentry);
80761 if (IS_ERR(new_dentry))
80762@@ -4101,11 +4320,26 @@ retry:
80763 error = may_linkat(&old_path);
80764 if (unlikely(error))
80765 goto out_dput;
80766+
80767+ if (gr_handle_hardlink(old_path.dentry, old_path.mnt, to)) {
80768+ error = -EACCES;
80769+ goto out_dput;
80770+ }
80771+
80772+ if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
80773+ old_path.dentry, old_path.mnt, to)) {
80774+ error = -EACCES;
80775+ goto out_dput;
80776+ }
80777+
80778 error = security_path_link(old_path.dentry, &new_path, new_dentry);
80779 if (error)
80780 goto out_dput;
80781 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry, &delegated_inode);
80782+ if (!error)
80783+ gr_handle_create(new_dentry, new_path.mnt);
80784 out_dput:
80785+ putname(to);
80786 done_path_create(&new_path, new_dentry);
80787 if (delegated_inode) {
80788 error = break_deleg_wait(&delegated_inode);
80789@@ -4420,6 +4654,20 @@ retry_deleg:
80790 if (new_dentry == trap)
80791 goto exit5;
80792
80793+ if (gr_bad_chroot_rename(old_dentry, old_path.mnt, new_dentry, new_path.mnt)) {
80794+ /* use EXDEV error to cause 'mv' to switch to an alternative
80795+ * method for usability
80796+ */
80797+ error = -EXDEV;
80798+ goto exit5;
80799+ }
80800+
80801+ error = gr_acl_handle_rename(new_dentry, new_path.dentry, new_path.mnt,
80802+ old_dentry, d_backing_inode(old_path.dentry), old_path.mnt,
80803+ to, flags);
80804+ if (error)
80805+ goto exit5;
80806+
80807 error = security_path_rename(&old_path, old_dentry,
80808 &new_path, new_dentry, flags);
80809 if (error)
80810@@ -4427,6 +4675,9 @@ retry_deleg:
80811 error = vfs_rename(old_path.dentry->d_inode, old_dentry,
80812 new_path.dentry->d_inode, new_dentry,
80813 &delegated_inode, flags);
80814+ if (!error)
80815+ gr_handle_rename(d_backing_inode(old_path.dentry), d_backing_inode(new_path.dentry), old_dentry,
80816+ new_dentry, old_path.mnt, d_is_positive(new_dentry) ? 1 : 0, flags);
80817 exit5:
80818 dput(new_dentry);
80819 exit4:
80820@@ -4483,14 +4734,24 @@ EXPORT_SYMBOL(vfs_whiteout);
80821
80822 int readlink_copy(char __user *buffer, int buflen, const char *link)
80823 {
80824+ char tmpbuf[64];
80825+ const char *newlink;
80826 int len = PTR_ERR(link);
80827+
80828 if (IS_ERR(link))
80829 goto out;
80830
80831 len = strlen(link);
80832 if (len > (unsigned) buflen)
80833 len = buflen;
80834- if (copy_to_user(buffer, link, len))
80835+
80836+ if (len < sizeof(tmpbuf)) {
80837+ memcpy(tmpbuf, link, len);
80838+ newlink = tmpbuf;
80839+ } else
80840+ newlink = link;
80841+
80842+ if (copy_to_user(buffer, newlink, len))
80843 len = -EFAULT;
80844 out:
80845 return len;
80846diff --git a/fs/namespace.c b/fs/namespace.c
80847index 2b8aa15..3230081 100644
80848--- a/fs/namespace.c
80849+++ b/fs/namespace.c
80850@@ -1516,6 +1516,9 @@ static int do_umount(struct mount *mnt, int flags)
80851 if (!(sb->s_flags & MS_RDONLY))
80852 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
80853 up_write(&sb->s_umount);
80854+
80855+ gr_log_remount(mnt->mnt_devname, retval);
80856+
80857 return retval;
80858 }
80859
80860@@ -1538,6 +1541,9 @@ static int do_umount(struct mount *mnt, int flags)
80861 }
80862 unlock_mount_hash();
80863 namespace_unlock();
80864+
80865+ gr_log_unmount(mnt->mnt_devname, retval);
80866+
80867 return retval;
80868 }
80869
80870@@ -1592,7 +1598,7 @@ static inline bool may_mount(void)
80871 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
80872 */
80873
80874-SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
80875+SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
80876 {
80877 struct path path;
80878 struct mount *mnt;
80879@@ -1637,7 +1643,7 @@ out:
80880 /*
80881 * The 2.0 compatible umount. No flags.
80882 */
80883-SYSCALL_DEFINE1(oldumount, char __user *, name)
80884+SYSCALL_DEFINE1(oldumount, const char __user *, name)
80885 {
80886 return sys_umount(name, 0);
80887 }
80888@@ -2712,6 +2718,16 @@ long do_mount(const char *dev_name, const char __user *dir_name,
80889 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
80890 MS_STRICTATIME);
80891
80892+ if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
80893+ retval = -EPERM;
80894+ goto dput_out;
80895+ }
80896+
80897+ if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
80898+ retval = -EPERM;
80899+ goto dput_out;
80900+ }
80901+
80902 if (flags & MS_REMOUNT)
80903 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
80904 data_page);
80905@@ -2725,7 +2741,10 @@ long do_mount(const char *dev_name, const char __user *dir_name,
80906 retval = do_new_mount(&path, type_page, flags, mnt_flags,
80907 dev_name, data_page);
80908 dput_out:
80909+ gr_log_mount(dev_name, &path, retval);
80910+
80911 path_put(&path);
80912+
80913 return retval;
80914 }
80915
80916@@ -2743,7 +2762,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
80917 * number incrementing at 10Ghz will take 12,427 years to wrap which
80918 * is effectively never, so we can ignore the possibility.
80919 */
80920-static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
80921+static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
80922
80923 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
80924 {
80925@@ -2759,7 +2778,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
80926 return ERR_PTR(ret);
80927 }
80928 new_ns->ns.ops = &mntns_operations;
80929- new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
80930+ new_ns->seq = atomic64_add_return_unchecked(1, &mnt_ns_seq);
80931 atomic_set(&new_ns->count, 1);
80932 new_ns->root = NULL;
80933 INIT_LIST_HEAD(&new_ns->list);
80934@@ -2769,7 +2788,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
80935 return new_ns;
80936 }
80937
80938-struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
80939+__latent_entropy struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
80940 struct user_namespace *user_ns, struct fs_struct *new_fs)
80941 {
80942 struct mnt_namespace *new_ns;
80943@@ -2890,8 +2909,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
80944 }
80945 EXPORT_SYMBOL(mount_subtree);
80946
80947-SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
80948- char __user *, type, unsigned long, flags, void __user *, data)
80949+SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
80950+ const char __user *, type, unsigned long, flags, void __user *, data)
80951 {
80952 int ret;
80953 char *kernel_type;
80954@@ -2997,6 +3016,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
80955 if (error)
80956 goto out2;
80957
80958+ if (gr_handle_chroot_pivot()) {
80959+ error = -EPERM;
80960+ goto out2;
80961+ }
80962+
80963 get_fs_root(current->fs, &root);
80964 old_mp = lock_mount(&old);
80965 error = PTR_ERR(old_mp);
80966@@ -3298,7 +3322,7 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
80967 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
80968 return -EPERM;
80969
80970- if (fs->users != 1)
80971+ if (atomic_read(&fs->users) != 1)
80972 return -EINVAL;
80973
80974 get_mnt_ns(mnt_ns);
80975diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
80976index 6b1697a..6d5787c 100644
80977--- a/fs/nfs/callback_xdr.c
80978+++ b/fs/nfs/callback_xdr.c
80979@@ -51,7 +51,7 @@ struct callback_op {
80980 callback_decode_arg_t decode_args;
80981 callback_encode_res_t encode_res;
80982 long res_maxsize;
80983-};
80984+} __do_const;
80985
80986 static struct callback_op callback_ops[];
80987
80988diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
80989index 4afbe13..a6a26ce 100644
80990--- a/fs/nfs/inode.c
80991+++ b/fs/nfs/inode.c
80992@@ -1273,16 +1273,16 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
80993 return 0;
80994 }
80995
80996-static atomic_long_t nfs_attr_generation_counter;
80997+static atomic_long_unchecked_t nfs_attr_generation_counter;
80998
80999 static unsigned long nfs_read_attr_generation_counter(void)
81000 {
81001- return atomic_long_read(&nfs_attr_generation_counter);
81002+ return atomic_long_read_unchecked(&nfs_attr_generation_counter);
81003 }
81004
81005 unsigned long nfs_inc_attr_generation_counter(void)
81006 {
81007- return atomic_long_inc_return(&nfs_attr_generation_counter);
81008+ return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
81009 }
81010 EXPORT_SYMBOL_GPL(nfs_inc_attr_generation_counter);
81011
81012diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
81013index 90cfda7..e4b50df 100644
81014--- a/fs/nfsd/nfs4proc.c
81015+++ b/fs/nfsd/nfs4proc.c
81016@@ -1487,7 +1487,7 @@ struct nfsd4_operation {
81017 nfsd4op_rsize op_rsize_bop;
81018 stateid_getter op_get_currentstateid;
81019 stateid_setter op_set_currentstateid;
81020-};
81021+} __do_const;
81022
81023 static struct nfsd4_operation nfsd4_ops[];
81024
81025diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
81026index b81f725..8e36601 100644
81027--- a/fs/nfsd/nfs4xdr.c
81028+++ b/fs/nfsd/nfs4xdr.c
81029@@ -1704,7 +1704,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
81030
81031 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
81032
81033-static nfsd4_dec nfsd4_dec_ops[] = {
81034+static const nfsd4_dec nfsd4_dec_ops[] = {
81035 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
81036 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
81037 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
81038diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
81039index 46ec934..f384e41 100644
81040--- a/fs/nfsd/nfscache.c
81041+++ b/fs/nfsd/nfscache.c
81042@@ -541,7 +541,7 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
81043 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
81044 u32 hash;
81045 struct nfsd_drc_bucket *b;
81046- int len;
81047+ long len;
81048 size_t bufsize = 0;
81049
81050 if (!rp)
81051@@ -550,11 +550,14 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
81052 hash = nfsd_cache_hash(rp->c_xid);
81053 b = &drc_hashtbl[hash];
81054
81055- len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
81056- len >>= 2;
81057+ if (statp) {
81058+ len = (char*)statp - (char*)resv->iov_base;
81059+ len = resv->iov_len - len;
81060+ len >>= 2;
81061+ }
81062
81063 /* Don't cache excessive amounts of data and XDR failures */
81064- if (!statp || len > (256 >> 2)) {
81065+ if (!statp || len > (256 >> 2) || len < 0) {
81066 nfsd_reply_cache_free(b, rp);
81067 return;
81068 }
81069@@ -562,7 +565,7 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
81070 switch (cachetype) {
81071 case RC_REPLSTAT:
81072 if (len != 1)
81073- printk("nfsd: RC_REPLSTAT/reply len %d!\n",len);
81074+ printk("nfsd: RC_REPLSTAT/reply len %ld!\n",len);
81075 rp->c_replstat = *statp;
81076 break;
81077 case RC_REPLBUFF:
81078diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
81079index b5e077a..50cf549 100644
81080--- a/fs/nfsd/vfs.c
81081+++ b/fs/nfsd/vfs.c
81082@@ -855,7 +855,7 @@ __be32 nfsd_readv(struct file *file, loff_t offset, struct kvec *vec, int vlen,
81083
81084 oldfs = get_fs();
81085 set_fs(KERNEL_DS);
81086- host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
81087+ host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
81088 set_fs(oldfs);
81089 return nfsd_finish_read(file, count, host_err);
81090 }
81091@@ -942,7 +942,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
81092
81093 /* Write the data. */
81094 oldfs = get_fs(); set_fs(KERNEL_DS);
81095- host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
81096+ host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
81097 set_fs(oldfs);
81098 if (host_err < 0)
81099 goto out_nfserr;
81100@@ -1455,7 +1455,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
81101 */
81102
81103 oldfs = get_fs(); set_fs(KERNEL_DS);
81104- host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
81105+ host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
81106 set_fs(oldfs);
81107
81108 if (host_err < 0)
81109diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
81110index 52ccd34..7a6b202 100644
81111--- a/fs/nls/nls_base.c
81112+++ b/fs/nls/nls_base.c
81113@@ -234,21 +234,25 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
81114
81115 int __register_nls(struct nls_table *nls, struct module *owner)
81116 {
81117- struct nls_table ** tmp = &tables;
81118+ struct nls_table *tmp = tables;
81119
81120 if (nls->next)
81121 return -EBUSY;
81122
81123- nls->owner = owner;
81124+ pax_open_kernel();
81125+ *(void **)&nls->owner = owner;
81126+ pax_close_kernel();
81127 spin_lock(&nls_lock);
81128- while (*tmp) {
81129- if (nls == *tmp) {
81130+ while (tmp) {
81131+ if (nls == tmp) {
81132 spin_unlock(&nls_lock);
81133 return -EBUSY;
81134 }
81135- tmp = &(*tmp)->next;
81136+ tmp = tmp->next;
81137 }
81138- nls->next = tables;
81139+ pax_open_kernel();
81140+ *(struct nls_table **)&nls->next = tables;
81141+ pax_close_kernel();
81142 tables = nls;
81143 spin_unlock(&nls_lock);
81144 return 0;
81145@@ -257,12 +261,14 @@ EXPORT_SYMBOL(__register_nls);
81146
81147 int unregister_nls(struct nls_table * nls)
81148 {
81149- struct nls_table ** tmp = &tables;
81150+ struct nls_table * const * tmp = &tables;
81151
81152 spin_lock(&nls_lock);
81153 while (*tmp) {
81154 if (nls == *tmp) {
81155- *tmp = nls->next;
81156+ pax_open_kernel();
81157+ *(struct nls_table **)tmp = nls->next;
81158+ pax_close_kernel();
81159 spin_unlock(&nls_lock);
81160 return 0;
81161 }
81162@@ -272,7 +278,7 @@ int unregister_nls(struct nls_table * nls)
81163 return -EINVAL;
81164 }
81165
81166-static struct nls_table *find_nls(char *charset)
81167+static struct nls_table *find_nls(const char *charset)
81168 {
81169 struct nls_table *nls;
81170 spin_lock(&nls_lock);
81171@@ -288,7 +294,7 @@ static struct nls_table *find_nls(char *charset)
81172 return nls;
81173 }
81174
81175-struct nls_table *load_nls(char *charset)
81176+struct nls_table *load_nls(const char *charset)
81177 {
81178 return try_then_request_module(find_nls(charset), "nls_%s", charset);
81179 }
81180diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
81181index 162b3f1..6076a7c 100644
81182--- a/fs/nls/nls_euc-jp.c
81183+++ b/fs/nls/nls_euc-jp.c
81184@@ -560,8 +560,10 @@ static int __init init_nls_euc_jp(void)
81185 p_nls = load_nls("cp932");
81186
81187 if (p_nls) {
81188- table.charset2upper = p_nls->charset2upper;
81189- table.charset2lower = p_nls->charset2lower;
81190+ pax_open_kernel();
81191+ *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
81192+ *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
81193+ pax_close_kernel();
81194 return register_nls(&table);
81195 }
81196
81197diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
81198index a80a741..7b96e1b 100644
81199--- a/fs/nls/nls_koi8-ru.c
81200+++ b/fs/nls/nls_koi8-ru.c
81201@@ -62,8 +62,10 @@ static int __init init_nls_koi8_ru(void)
81202 p_nls = load_nls("koi8-u");
81203
81204 if (p_nls) {
81205- table.charset2upper = p_nls->charset2upper;
81206- table.charset2lower = p_nls->charset2lower;
81207+ pax_open_kernel();
81208+ *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
81209+ *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
81210+ pax_close_kernel();
81211 return register_nls(&table);
81212 }
81213
81214diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
81215index cf27550..6c70f29d 100644
81216--- a/fs/notify/fanotify/fanotify_user.c
81217+++ b/fs/notify/fanotify/fanotify_user.c
81218@@ -216,8 +216,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
81219
81220 fd = fanotify_event_metadata.fd;
81221 ret = -EFAULT;
81222- if (copy_to_user(buf, &fanotify_event_metadata,
81223- fanotify_event_metadata.event_len))
81224+ if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
81225+ copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
81226 goto out_close_fd;
81227
81228 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
81229diff --git a/fs/notify/notification.c b/fs/notify/notification.c
81230index a95d8e0..a91a5fd 100644
81231--- a/fs/notify/notification.c
81232+++ b/fs/notify/notification.c
81233@@ -48,7 +48,7 @@
81234 #include <linux/fsnotify_backend.h>
81235 #include "fsnotify.h"
81236
81237-static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
81238+static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
81239
81240 /**
81241 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
81242@@ -56,7 +56,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
81243 */
81244 u32 fsnotify_get_cookie(void)
81245 {
81246- return atomic_inc_return(&fsnotify_sync_cookie);
81247+ return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
81248 }
81249 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
81250
81251diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
81252index 9e38daf..5727cae 100644
81253--- a/fs/ntfs/dir.c
81254+++ b/fs/ntfs/dir.c
81255@@ -1310,7 +1310,7 @@ find_next_index_buffer:
81256 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
81257 ~(s64)(ndir->itype.index.block_size - 1)));
81258 /* Bounds checks. */
81259- if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
81260+ if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
81261 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
81262 "inode 0x%lx or driver bug.", vdir->i_ino);
81263 goto err_out;
81264diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
81265index 9e1e112..241a52a 100644
81266--- a/fs/ntfs/super.c
81267+++ b/fs/ntfs/super.c
81268@@ -688,7 +688,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
81269 if (!silent)
81270 ntfs_error(sb, "Primary boot sector is invalid.");
81271 } else if (!silent)
81272- ntfs_error(sb, read_err_str, "primary");
81273+ ntfs_error(sb, read_err_str, "%s", "primary");
81274 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
81275 if (bh_primary)
81276 brelse(bh_primary);
81277@@ -704,7 +704,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
81278 goto hotfix_primary_boot_sector;
81279 brelse(bh_backup);
81280 } else if (!silent)
81281- ntfs_error(sb, read_err_str, "backup");
81282+ ntfs_error(sb, read_err_str, "%s", "backup");
81283 /* Try to read NT3.51- backup boot sector. */
81284 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
81285 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
81286@@ -715,7 +715,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
81287 "sector.");
81288 brelse(bh_backup);
81289 } else if (!silent)
81290- ntfs_error(sb, read_err_str, "backup");
81291+ ntfs_error(sb, read_err_str, "%s", "backup");
81292 /* We failed. Cleanup and return. */
81293 if (bh_primary)
81294 brelse(bh_primary);
81295diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
81296index 857bbbc..3c47d15 100644
81297--- a/fs/ocfs2/localalloc.c
81298+++ b/fs/ocfs2/localalloc.c
81299@@ -1320,7 +1320,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
81300 goto bail;
81301 }
81302
81303- atomic_inc(&osb->alloc_stats.moves);
81304+ atomic_inc_unchecked(&osb->alloc_stats.moves);
81305
81306 bail:
81307 if (handle)
81308diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
81309index 690ddc6..f2d4c4d 100644
81310--- a/fs/ocfs2/ocfs2.h
81311+++ b/fs/ocfs2/ocfs2.h
81312@@ -247,11 +247,11 @@ enum ocfs2_vol_state
81313
81314 struct ocfs2_alloc_stats
81315 {
81316- atomic_t moves;
81317- atomic_t local_data;
81318- atomic_t bitmap_data;
81319- atomic_t bg_allocs;
81320- atomic_t bg_extends;
81321+ atomic_unchecked_t moves;
81322+ atomic_unchecked_t local_data;
81323+ atomic_unchecked_t bitmap_data;
81324+ atomic_unchecked_t bg_allocs;
81325+ atomic_unchecked_t bg_extends;
81326 };
81327
81328 enum ocfs2_local_alloc_state
81329diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
81330index 4479029..5de740b 100644
81331--- a/fs/ocfs2/suballoc.c
81332+++ b/fs/ocfs2/suballoc.c
81333@@ -867,7 +867,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
81334 mlog_errno(status);
81335 goto bail;
81336 }
81337- atomic_inc(&osb->alloc_stats.bg_extends);
81338+ atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
81339
81340 /* You should never ask for this much metadata */
81341 BUG_ON(bits_wanted >
81342@@ -2014,7 +2014,7 @@ int ocfs2_claim_metadata(handle_t *handle,
81343 mlog_errno(status);
81344 goto bail;
81345 }
81346- atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81347+ atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81348
81349 *suballoc_loc = res.sr_bg_blkno;
81350 *suballoc_bit_start = res.sr_bit_offset;
81351@@ -2180,7 +2180,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
81352 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
81353 res->sr_bits);
81354
81355- atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81356+ atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81357
81358 BUG_ON(res->sr_bits != 1);
81359
81360@@ -2222,7 +2222,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
81361 mlog_errno(status);
81362 goto bail;
81363 }
81364- atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81365+ atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
81366
81367 BUG_ON(res.sr_bits != 1);
81368
81369@@ -2326,7 +2326,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
81370 cluster_start,
81371 num_clusters);
81372 if (!status)
81373- atomic_inc(&osb->alloc_stats.local_data);
81374+ atomic_inc_unchecked(&osb->alloc_stats.local_data);
81375 } else {
81376 if (min_clusters > (osb->bitmap_cpg - 1)) {
81377 /* The only paths asking for contiguousness
81378@@ -2352,7 +2352,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
81379 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
81380 res.sr_bg_blkno,
81381 res.sr_bit_offset);
81382- atomic_inc(&osb->alloc_stats.bitmap_data);
81383+ atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
81384 *num_clusters = res.sr_bits;
81385 }
81386 }
81387diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
81388index a482e31..81b251d 100644
81389--- a/fs/ocfs2/super.c
81390+++ b/fs/ocfs2/super.c
81391@@ -308,11 +308,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
81392 "%10s => GlobalAllocs: %d LocalAllocs: %d "
81393 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
81394 "Stats",
81395- atomic_read(&osb->alloc_stats.bitmap_data),
81396- atomic_read(&osb->alloc_stats.local_data),
81397- atomic_read(&osb->alloc_stats.bg_allocs),
81398- atomic_read(&osb->alloc_stats.moves),
81399- atomic_read(&osb->alloc_stats.bg_extends));
81400+ atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
81401+ atomic_read_unchecked(&osb->alloc_stats.local_data),
81402+ atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
81403+ atomic_read_unchecked(&osb->alloc_stats.moves),
81404+ atomic_read_unchecked(&osb->alloc_stats.bg_extends));
81405
81406 out += snprintf(buf + out, len - out,
81407 "%10s => State: %u Descriptor: %llu Size: %u bits "
81408@@ -2095,11 +2095,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
81409
81410 mutex_init(&osb->system_file_mutex);
81411
81412- atomic_set(&osb->alloc_stats.moves, 0);
81413- atomic_set(&osb->alloc_stats.local_data, 0);
81414- atomic_set(&osb->alloc_stats.bitmap_data, 0);
81415- atomic_set(&osb->alloc_stats.bg_allocs, 0);
81416- atomic_set(&osb->alloc_stats.bg_extends, 0);
81417+ atomic_set_unchecked(&osb->alloc_stats.moves, 0);
81418+ atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
81419+ atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
81420+ atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
81421+ atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
81422
81423 /* Copy the blockcheck stats from the superblock probe */
81424 osb->osb_ecc_stats = *stats;
81425diff --git a/fs/open.c b/fs/open.c
81426index e33dab2..cdbdad9 100644
81427--- a/fs/open.c
81428+++ b/fs/open.c
81429@@ -32,6 +32,8 @@
81430 #include <linux/dnotify.h>
81431 #include <linux/compat.h>
81432
81433+#define CREATE_TRACE_POINTS
81434+#include <trace/events/fs.h>
81435 #include "internal.h"
81436
81437 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
81438@@ -105,6 +107,8 @@ long vfs_truncate(struct path *path, loff_t length)
81439 error = locks_verify_truncate(inode, NULL, length);
81440 if (!error)
81441 error = security_path_truncate(path);
81442+ if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
81443+ error = -EACCES;
81444 if (!error)
81445 error = do_truncate(path->dentry, length, 0, NULL);
81446
81447@@ -189,6 +193,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
81448 error = locks_verify_truncate(inode, f.file, length);
81449 if (!error)
81450 error = security_path_truncate(&f.file->f_path);
81451+ if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
81452+ error = -EACCES;
81453 if (!error)
81454 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
81455 sb_end_write(inode->i_sb);
81456@@ -398,6 +404,9 @@ retry:
81457 if (__mnt_is_readonly(path.mnt))
81458 res = -EROFS;
81459
81460+ if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
81461+ res = -EACCES;
81462+
81463 out_path_release:
81464 path_put(&path);
81465 if (retry_estale(res, lookup_flags)) {
81466@@ -429,6 +438,8 @@ retry:
81467 if (error)
81468 goto dput_and_out;
81469
81470+ gr_log_chdir(path.dentry, path.mnt);
81471+
81472 set_fs_pwd(current->fs, &path);
81473
81474 dput_and_out:
81475@@ -458,6 +469,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
81476 goto out_putf;
81477
81478 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
81479+
81480+ if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
81481+ error = -EPERM;
81482+
81483+ if (!error)
81484+ gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
81485+
81486 if (!error)
81487 set_fs_pwd(current->fs, &f.file->f_path);
81488 out_putf:
81489@@ -487,7 +505,13 @@ retry:
81490 if (error)
81491 goto dput_and_out;
81492
81493+ if (gr_handle_chroot_chroot(path.dentry, path.mnt))
81494+ goto dput_and_out;
81495+
81496 set_fs_root(current->fs, &path);
81497+
81498+ gr_handle_chroot_chdir(&path);
81499+
81500 error = 0;
81501 dput_and_out:
81502 path_put(&path);
81503@@ -511,6 +535,16 @@ static int chmod_common(struct path *path, umode_t mode)
81504 return error;
81505 retry_deleg:
81506 mutex_lock(&inode->i_mutex);
81507+
81508+ if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
81509+ error = -EACCES;
81510+ goto out_unlock;
81511+ }
81512+ if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
81513+ error = -EACCES;
81514+ goto out_unlock;
81515+ }
81516+
81517 error = security_path_chmod(path, mode);
81518 if (error)
81519 goto out_unlock;
81520@@ -576,6 +610,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
81521 uid = make_kuid(current_user_ns(), user);
81522 gid = make_kgid(current_user_ns(), group);
81523
81524+ if (!gr_acl_handle_chown(path->dentry, path->mnt))
81525+ return -EACCES;
81526+
81527 retry_deleg:
81528 newattrs.ia_valid = ATTR_CTIME;
81529 if (user != (uid_t) -1) {
81530@@ -1029,6 +1066,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
81531 } else {
81532 fsnotify_open(f);
81533 fd_install(fd, f);
81534+ trace_do_sys_open(tmp->name, flags, mode);
81535 }
81536 }
81537 putname(tmp);
81538diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
81539index d9da5a4..7ced3c7 100644
81540--- a/fs/overlayfs/inode.c
81541+++ b/fs/overlayfs/inode.c
81542@@ -346,6 +346,9 @@ struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags)
81543 if (d_is_dir(dentry))
81544 return d_backing_inode(dentry);
81545
81546+ if (d_is_dir(dentry))
81547+ return d_backing_inode(dentry);
81548+
81549 type = ovl_path_real(dentry, &realpath);
81550 if (ovl_open_need_copy_up(file_flags, type, realpath.dentry)) {
81551 err = ovl_want_write(dentry);
81552diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
81553index 79073d6..0eb5c27 100644
81554--- a/fs/overlayfs/super.c
81555+++ b/fs/overlayfs/super.c
81556@@ -172,7 +172,7 @@ void ovl_path_lower(struct dentry *dentry, struct path *path)
81557 {
81558 struct ovl_entry *oe = dentry->d_fsdata;
81559
81560- *path = oe->numlower ? oe->lowerstack[0] : (struct path) { NULL, NULL };
81561+ *path = oe->numlower ? oe->lowerstack[0] : (struct path) { .dentry = NULL, .mnt = NULL };
81562 }
81563
81564 int ovl_want_write(struct dentry *dentry)
81565@@ -879,8 +879,8 @@ static unsigned int ovl_split_lowerdirs(char *str)
81566
81567 static int ovl_fill_super(struct super_block *sb, void *data, int silent)
81568 {
81569- struct path upperpath = { NULL, NULL };
81570- struct path workpath = { NULL, NULL };
81571+ struct path upperpath = { .dentry = NULL, .mnt = NULL };
81572+ struct path workpath = { .dentry = NULL, .mnt = NULL };
81573 struct dentry *root_dentry;
81574 struct ovl_entry *oe;
81575 struct ovl_fs *ufs;
81576diff --git a/fs/pipe.c b/fs/pipe.c
81577index 8865f79..bd2c79b 100644
81578--- a/fs/pipe.c
81579+++ b/fs/pipe.c
81580@@ -36,7 +36,7 @@ unsigned int pipe_max_size = 1048576;
81581 /*
81582 * Minimum pipe size, as required by POSIX
81583 */
81584-unsigned int pipe_min_size = PAGE_SIZE;
81585+unsigned int pipe_min_size __read_only = PAGE_SIZE;
81586
81587 /*
81588 * We use a start+len construction, which provides full use of the
81589@@ -55,7 +55,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
81590
81591 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
81592 {
81593- if (pipe->files)
81594+ if (atomic_read(&pipe->files))
81595 mutex_lock_nested(&pipe->mutex, subclass);
81596 }
81597
81598@@ -70,7 +70,7 @@ EXPORT_SYMBOL(pipe_lock);
81599
81600 void pipe_unlock(struct pipe_inode_info *pipe)
81601 {
81602- if (pipe->files)
81603+ if (atomic_read(&pipe->files))
81604 mutex_unlock(&pipe->mutex);
81605 }
81606 EXPORT_SYMBOL(pipe_unlock);
81607@@ -291,9 +291,9 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)
81608 }
81609 if (bufs) /* More to do? */
81610 continue;
81611- if (!pipe->writers)
81612+ if (!atomic_read(&pipe->writers))
81613 break;
81614- if (!pipe->waiting_writers) {
81615+ if (!atomic_read(&pipe->waiting_writers)) {
81616 /* syscall merging: Usually we must not sleep
81617 * if O_NONBLOCK is set, or if we got some data.
81618 * But if a writer sleeps in kernel space, then
81619@@ -350,7 +350,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
81620
81621 __pipe_lock(pipe);
81622
81623- if (!pipe->readers) {
81624+ if (!atomic_read(&pipe->readers)) {
81625 send_sig(SIGPIPE, current, 0);
81626 ret = -EPIPE;
81627 goto out;
81628@@ -386,7 +386,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
81629 for (;;) {
81630 int bufs;
81631
81632- if (!pipe->readers) {
81633+ if (!atomic_read(&pipe->readers)) {
81634 send_sig(SIGPIPE, current, 0);
81635 if (!ret)
81636 ret = -EPIPE;
81637@@ -454,9 +454,9 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
81638 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
81639 do_wakeup = 0;
81640 }
81641- pipe->waiting_writers++;
81642+ atomic_inc(&pipe->waiting_writers);
81643 pipe_wait(pipe);
81644- pipe->waiting_writers--;
81645+ atomic_dec(&pipe->waiting_writers);
81646 }
81647 out:
81648 __pipe_unlock(pipe);
81649@@ -511,7 +511,7 @@ pipe_poll(struct file *filp, poll_table *wait)
81650 mask = 0;
81651 if (filp->f_mode & FMODE_READ) {
81652 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
81653- if (!pipe->writers && filp->f_version != pipe->w_counter)
81654+ if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
81655 mask |= POLLHUP;
81656 }
81657
81658@@ -521,7 +521,7 @@ pipe_poll(struct file *filp, poll_table *wait)
81659 * Most Unices do not set POLLERR for FIFOs but on Linux they
81660 * behave exactly like pipes for poll().
81661 */
81662- if (!pipe->readers)
81663+ if (!atomic_read(&pipe->readers))
81664 mask |= POLLERR;
81665 }
81666
81667@@ -533,7 +533,7 @@ static void put_pipe_info(struct inode *inode, struct pipe_inode_info *pipe)
81668 int kill = 0;
81669
81670 spin_lock(&inode->i_lock);
81671- if (!--pipe->files) {
81672+ if (atomic_dec_and_test(&pipe->files)) {
81673 inode->i_pipe = NULL;
81674 kill = 1;
81675 }
81676@@ -550,11 +550,11 @@ pipe_release(struct inode *inode, struct file *file)
81677
81678 __pipe_lock(pipe);
81679 if (file->f_mode & FMODE_READ)
81680- pipe->readers--;
81681+ atomic_dec(&pipe->readers);
81682 if (file->f_mode & FMODE_WRITE)
81683- pipe->writers--;
81684+ atomic_dec(&pipe->writers);
81685
81686- if (pipe->readers || pipe->writers) {
81687+ if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
81688 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
81689 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
81690 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
81691@@ -619,7 +619,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
81692 kfree(pipe);
81693 }
81694
81695-static struct vfsmount *pipe_mnt __read_mostly;
81696+struct vfsmount *pipe_mnt __read_mostly;
81697
81698 /*
81699 * pipefs_dname() is called from d_path().
81700@@ -649,8 +649,9 @@ static struct inode * get_pipe_inode(void)
81701 goto fail_iput;
81702
81703 inode->i_pipe = pipe;
81704- pipe->files = 2;
81705- pipe->readers = pipe->writers = 1;
81706+ atomic_set(&pipe->files, 2);
81707+ atomic_set(&pipe->readers, 1);
81708+ atomic_set(&pipe->writers, 1);
81709 inode->i_fop = &pipefifo_fops;
81710
81711 /*
81712@@ -829,17 +830,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
81713 spin_lock(&inode->i_lock);
81714 if (inode->i_pipe) {
81715 pipe = inode->i_pipe;
81716- pipe->files++;
81717+ atomic_inc(&pipe->files);
81718 spin_unlock(&inode->i_lock);
81719 } else {
81720 spin_unlock(&inode->i_lock);
81721 pipe = alloc_pipe_info();
81722 if (!pipe)
81723 return -ENOMEM;
81724- pipe->files = 1;
81725+ atomic_set(&pipe->files, 1);
81726 spin_lock(&inode->i_lock);
81727 if (unlikely(inode->i_pipe)) {
81728- inode->i_pipe->files++;
81729+ atomic_inc(&inode->i_pipe->files);
81730 spin_unlock(&inode->i_lock);
81731 free_pipe_info(pipe);
81732 pipe = inode->i_pipe;
81733@@ -864,10 +865,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
81734 * opened, even when there is no process writing the FIFO.
81735 */
81736 pipe->r_counter++;
81737- if (pipe->readers++ == 0)
81738+ if (atomic_inc_return(&pipe->readers) == 1)
81739 wake_up_partner(pipe);
81740
81741- if (!is_pipe && !pipe->writers) {
81742+ if (!is_pipe && !atomic_read(&pipe->writers)) {
81743 if ((filp->f_flags & O_NONBLOCK)) {
81744 /* suppress POLLHUP until we have
81745 * seen a writer */
81746@@ -886,14 +887,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
81747 * errno=ENXIO when there is no process reading the FIFO.
81748 */
81749 ret = -ENXIO;
81750- if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
81751+ if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
81752 goto err;
81753
81754 pipe->w_counter++;
81755- if (!pipe->writers++)
81756+ if (atomic_inc_return(&pipe->writers) == 1)
81757 wake_up_partner(pipe);
81758
81759- if (!is_pipe && !pipe->readers) {
81760+ if (!is_pipe && !atomic_read(&pipe->readers)) {
81761 if (wait_for_partner(pipe, &pipe->r_counter))
81762 goto err_wr;
81763 }
81764@@ -907,11 +908,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
81765 * the process can at least talk to itself.
81766 */
81767
81768- pipe->readers++;
81769- pipe->writers++;
81770+ atomic_inc(&pipe->readers);
81771+ atomic_inc(&pipe->writers);
81772 pipe->r_counter++;
81773 pipe->w_counter++;
81774- if (pipe->readers == 1 || pipe->writers == 1)
81775+ if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
81776 wake_up_partner(pipe);
81777 break;
81778
81779@@ -925,13 +926,13 @@ static int fifo_open(struct inode *inode, struct file *filp)
81780 return 0;
81781
81782 err_rd:
81783- if (!--pipe->readers)
81784+ if (atomic_dec_and_test(&pipe->readers))
81785 wake_up_interruptible(&pipe->wait);
81786 ret = -ERESTARTSYS;
81787 goto err;
81788
81789 err_wr:
81790- if (!--pipe->writers)
81791+ if (atomic_dec_and_test(&pipe->writers))
81792 wake_up_interruptible(&pipe->wait);
81793 ret = -ERESTARTSYS;
81794 goto err;
81795@@ -1007,7 +1008,7 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long nr_pages)
81796 * Currently we rely on the pipe array holding a power-of-2 number
81797 * of pages.
81798 */
81799-static inline unsigned int round_pipe_size(unsigned int size)
81800+static inline unsigned long round_pipe_size(unsigned long size)
81801 {
81802 unsigned long nr_pages;
81803
81804@@ -1055,13 +1056,16 @@ long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
81805
81806 switch (cmd) {
81807 case F_SETPIPE_SZ: {
81808- unsigned int size, nr_pages;
81809+ unsigned long size, nr_pages;
81810+
81811+ ret = -EINVAL;
81812+ if (arg < pipe_min_size)
81813+ goto out;
81814
81815 size = round_pipe_size(arg);
81816 nr_pages = size >> PAGE_SHIFT;
81817
81818- ret = -EINVAL;
81819- if (!nr_pages)
81820+ if (size < pipe_min_size)
81821 goto out;
81822
81823 if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) {
81824diff --git a/fs/posix_acl.c b/fs/posix_acl.c
81825index 4fb17de..13d8c0f 100644
81826--- a/fs/posix_acl.c
81827+++ b/fs/posix_acl.c
81828@@ -20,6 +20,7 @@
81829 #include <linux/xattr.h>
81830 #include <linux/export.h>
81831 #include <linux/user_namespace.h>
81832+#include <linux/grsecurity.h>
81833
81834 struct posix_acl **acl_by_type(struct inode *inode, int type)
81835 {
81836@@ -277,7 +278,7 @@ posix_acl_equiv_mode(const struct posix_acl *acl, umode_t *mode_p)
81837 }
81838 }
81839 if (mode_p)
81840- *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
81841+ *mode_p = ((*mode_p & ~S_IRWXUGO) | mode) & ~gr_acl_umask();
81842 return not_equiv;
81843 }
81844 EXPORT_SYMBOL(posix_acl_equiv_mode);
81845@@ -427,7 +428,7 @@ static int posix_acl_create_masq(struct posix_acl *acl, umode_t *mode_p)
81846 mode &= (group_obj->e_perm << 3) | ~S_IRWXG;
81847 }
81848
81849- *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
81850+ *mode_p = ((*mode_p & ~S_IRWXUGO) | mode) & ~gr_acl_umask();
81851 return not_equiv;
81852 }
81853
81854@@ -485,6 +486,8 @@ __posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p)
81855 struct posix_acl *clone = posix_acl_clone(*acl, gfp);
81856 int err = -ENOMEM;
81857 if (clone) {
81858+ *mode_p &= ~gr_acl_umask();
81859+
81860 err = posix_acl_create_masq(clone, mode_p);
81861 if (err < 0) {
81862 posix_acl_release(clone);
81863@@ -657,11 +660,12 @@ struct posix_acl *
81864 posix_acl_from_xattr(struct user_namespace *user_ns,
81865 const void *value, size_t size)
81866 {
81867- posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
81868- posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
81869+ const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
81870+ const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
81871 int count;
81872 struct posix_acl *acl;
81873 struct posix_acl_entry *acl_e;
81874+ umode_t umask = gr_acl_umask();
81875
81876 if (!value)
81877 return NULL;
81878@@ -687,12 +691,18 @@ posix_acl_from_xattr(struct user_namespace *user_ns,
81879
81880 switch(acl_e->e_tag) {
81881 case ACL_USER_OBJ:
81882+ acl_e->e_perm &= ~((umask & S_IRWXU) >> 6);
81883+ break;
81884 case ACL_GROUP_OBJ:
81885 case ACL_MASK:
81886+ acl_e->e_perm &= ~((umask & S_IRWXG) >> 3);
81887+ break;
81888 case ACL_OTHER:
81889+ acl_e->e_perm &= ~(umask & S_IRWXO);
81890 break;
81891
81892 case ACL_USER:
81893+ acl_e->e_perm &= ~((umask & S_IRWXU) >> 6);
81894 acl_e->e_uid =
81895 make_kuid(user_ns,
81896 le32_to_cpu(entry->e_id));
81897@@ -700,6 +710,7 @@ posix_acl_from_xattr(struct user_namespace *user_ns,
81898 goto fail;
81899 break;
81900 case ACL_GROUP:
81901+ acl_e->e_perm &= ~((umask & S_IRWXG) >> 3);
81902 acl_e->e_gid =
81903 make_kgid(user_ns,
81904 le32_to_cpu(entry->e_id));
81905diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
81906index 1ade120..a86f1a2 100644
81907--- a/fs/proc/Kconfig
81908+++ b/fs/proc/Kconfig
81909@@ -30,7 +30,7 @@ config PROC_FS
81910
81911 config PROC_KCORE
81912 bool "/proc/kcore support" if !ARM
81913- depends on PROC_FS && MMU
81914+ depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
81915 help
81916 Provides a virtual ELF core file of the live kernel. This can
81917 be read with gdb and other ELF tools. No modifications can be
81918@@ -38,8 +38,8 @@ config PROC_KCORE
81919
81920 config PROC_VMCORE
81921 bool "/proc/vmcore support"
81922- depends on PROC_FS && CRASH_DUMP
81923- default y
81924+ depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
81925+ default n
81926 help
81927 Exports the dump image of crashed kernel in ELF format.
81928
81929@@ -63,8 +63,8 @@ config PROC_SYSCTL
81930 limited in memory.
81931
81932 config PROC_PAGE_MONITOR
81933- default y
81934- depends on PROC_FS && MMU
81935+ default n
81936+ depends on PROC_FS && MMU && !GRKERNSEC
81937 bool "Enable /proc page monitoring" if EXPERT
81938 help
81939 Various /proc files exist to monitor process memory utilization:
81940diff --git a/fs/proc/array.c b/fs/proc/array.c
81941index ce065cf..8974fed 100644
81942--- a/fs/proc/array.c
81943+++ b/fs/proc/array.c
81944@@ -60,6 +60,7 @@
81945 #include <linux/tty.h>
81946 #include <linux/string.h>
81947 #include <linux/mman.h>
81948+#include <linux/grsecurity.h>
81949 #include <linux/proc_fs.h>
81950 #include <linux/ioport.h>
81951 #include <linux/uaccess.h>
81952@@ -348,6 +349,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
81953 cpumask_pr_args(&task->cpus_allowed));
81954 }
81955
81956+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
81957+static inline void task_pax(struct seq_file *m, struct task_struct *p)
81958+{
81959+ if (p->mm)
81960+ seq_printf(m, "PaX:\t%c%c%c%c%c\n",
81961+ p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
81962+ p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
81963+ p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
81964+ p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
81965+ p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
81966+ else
81967+ seq_printf(m, "PaX:\t-----\n");
81968+}
81969+#endif
81970+
81971 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
81972 struct pid *pid, struct task_struct *task)
81973 {
81974@@ -366,9 +382,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
81975 task_cpus_allowed(m, task);
81976 cpuset_task_status_allowed(m, task);
81977 task_context_switch_counts(m, task);
81978+
81979+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
81980+ task_pax(m, task);
81981+#endif
81982+
81983+#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
81984+ task_grsec_rbac(m, task);
81985+#endif
81986+
81987 return 0;
81988 }
81989
81990+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81991+#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
81992+ (_mm->pax_flags & MF_PAX_RANDMMAP || \
81993+ _mm->pax_flags & MF_PAX_SEGMEXEC))
81994+#endif
81995+
81996 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
81997 struct pid *pid, struct task_struct *task, int whole)
81998 {
81999@@ -390,6 +421,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
82000 char tcomm[sizeof(task->comm)];
82001 unsigned long flags;
82002
82003+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82004+ if (current->exec_id != m->exec_id) {
82005+ gr_log_badprocpid("stat");
82006+ return 0;
82007+ }
82008+#endif
82009+
82010 state = *get_task_state(task);
82011 vsize = eip = esp = 0;
82012 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
82013@@ -460,6 +498,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
82014 gtime = task_gtime(task);
82015 }
82016
82017+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82018+ if (PAX_RAND_FLAGS(mm)) {
82019+ eip = 0;
82020+ esp = 0;
82021+ wchan = 0;
82022+ }
82023+#endif
82024+#ifdef CONFIG_GRKERNSEC_HIDESYM
82025+ wchan = 0;
82026+ eip =0;
82027+ esp =0;
82028+#endif
82029+
82030 /* scale priority and nice values from timeslices to -20..20 */
82031 /* to make it look like a "normal" Unix priority/nice value */
82032 priority = task_prio(task);
82033@@ -491,9 +542,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
82034 seq_put_decimal_ull(m, ' ', vsize);
82035 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
82036 seq_put_decimal_ull(m, ' ', rsslim);
82037+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82038+ seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
82039+ seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
82040+ seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
82041+#else
82042 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
82043 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
82044 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
82045+#endif
82046 seq_put_decimal_ull(m, ' ', esp);
82047 seq_put_decimal_ull(m, ' ', eip);
82048 /* The signal information here is obsolete.
82049@@ -515,7 +572,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
82050 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
82051 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
82052
82053- if (mm && permitted) {
82054+ if (mm && permitted
82055+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82056+ && !PAX_RAND_FLAGS(mm)
82057+#endif
82058+ ) {
82059 seq_put_decimal_ull(m, ' ', mm->start_data);
82060 seq_put_decimal_ull(m, ' ', mm->end_data);
82061 seq_put_decimal_ull(m, ' ', mm->start_brk);
82062@@ -553,8 +614,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
82063 struct pid *pid, struct task_struct *task)
82064 {
82065 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
82066- struct mm_struct *mm = get_task_mm(task);
82067+ struct mm_struct *mm;
82068
82069+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82070+ if (current->exec_id != m->exec_id) {
82071+ gr_log_badprocpid("statm");
82072+ return 0;
82073+ }
82074+#endif
82075+ mm = get_task_mm(task);
82076 if (mm) {
82077 size = task_statm(mm, &shared, &text, &data, &resident);
82078 mmput(mm);
82079@@ -577,6 +645,20 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
82080 return 0;
82081 }
82082
82083+#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
82084+int proc_pid_ipaddr(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task)
82085+{
82086+ unsigned long flags;
82087+ u32 curr_ip = 0;
82088+
82089+ if (lock_task_sighand(task, &flags)) {
82090+ curr_ip = task->signal->curr_ip;
82091+ unlock_task_sighand(task, &flags);
82092+ }
82093+ return seq_printf(m, "%pI4\n", &curr_ip);
82094+}
82095+#endif
82096+
82097 #ifdef CONFIG_PROC_CHILDREN
82098 static struct pid *
82099 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
82100diff --git a/fs/proc/base.c b/fs/proc/base.c
82101index aa50d1a..7a62b7a 100644
82102--- a/fs/proc/base.c
82103+++ b/fs/proc/base.c
82104@@ -113,6 +113,14 @@ struct pid_entry {
82105 union proc_op op;
82106 };
82107
82108+struct getdents_callback {
82109+ struct linux_dirent __user * current_dir;
82110+ struct linux_dirent __user * previous;
82111+ struct file * file;
82112+ int count;
82113+ int error;
82114+};
82115+
82116 #define NOD(NAME, MODE, IOP, FOP, OP) { \
82117 .name = (NAME), \
82118 .len = sizeof(NAME) - 1, \
82119@@ -224,6 +232,11 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
82120 goto out_mmput;
82121 }
82122
82123+ if (gr_acl_handle_procpidmem(tsk)) {
82124+ rv = 0;
82125+ goto out_mmput;
82126+ }
82127+
82128 page = (char *)__get_free_page(GFP_TEMPORARY);
82129 if (!page) {
82130 rv = -ENOMEM;
82131@@ -400,12 +413,28 @@ static const struct file_operations proc_pid_cmdline_ops = {
82132 .llseek = generic_file_llseek,
82133 };
82134
82135+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82136+#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
82137+ (_mm->pax_flags & MF_PAX_RANDMMAP || \
82138+ _mm->pax_flags & MF_PAX_SEGMEXEC))
82139+#endif
82140+
82141 static int proc_pid_auxv(struct seq_file *m, struct pid_namespace *ns,
82142 struct pid *pid, struct task_struct *task)
82143 {
82144 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
82145 if (mm && !IS_ERR(mm)) {
82146 unsigned int nwords = 0;
82147+
82148+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82149+ /* allow if we're currently ptracing this task */
82150+ if (PAX_RAND_FLAGS(mm) &&
82151+ (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
82152+ mmput(mm);
82153+ return 0;
82154+ }
82155+#endif
82156+
82157 do {
82158 nwords += 2;
82159 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
82160@@ -417,7 +446,7 @@ static int proc_pid_auxv(struct seq_file *m, struct pid_namespace *ns,
82161 }
82162
82163
82164-#ifdef CONFIG_KALLSYMS
82165+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82166 /*
82167 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
82168 * Returns the resolved symbol. If that fails, simply return the address.
82169@@ -459,7 +488,7 @@ static void unlock_trace(struct task_struct *task)
82170 mutex_unlock(&task->signal->cred_guard_mutex);
82171 }
82172
82173-#ifdef CONFIG_STACKTRACE
82174+#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82175
82176 #define MAX_STACK_TRACE_DEPTH 64
82177
82178@@ -657,7 +686,7 @@ static int proc_pid_limits(struct seq_file *m, struct pid_namespace *ns,
82179 return 0;
82180 }
82181
82182-#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
82183+#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
82184 static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
82185 struct pid *pid, struct task_struct *task)
82186 {
82187@@ -690,7 +719,7 @@ static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
82188 /************************************************************************/
82189
82190 /* permission checks */
82191-static int proc_fd_access_allowed(struct inode *inode)
82192+static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
82193 {
82194 struct task_struct *task;
82195 int allowed = 0;
82196@@ -700,7 +729,10 @@ static int proc_fd_access_allowed(struct inode *inode)
82197 */
82198 task = get_proc_task(inode);
82199 if (task) {
82200- allowed = ptrace_may_access(task, PTRACE_MODE_READ);
82201+ if (log)
82202+ allowed = ptrace_may_access(task, PTRACE_MODE_READ);
82203+ else
82204+ allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
82205 put_task_struct(task);
82206 }
82207 return allowed;
82208@@ -731,10 +763,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
82209 struct task_struct *task,
82210 int hide_pid_min)
82211 {
82212+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
82213+ return false;
82214+
82215+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82216+ rcu_read_lock();
82217+ {
82218+ const struct cred *tmpcred = current_cred();
82219+ const struct cred *cred = __task_cred(task);
82220+
82221+ if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
82222+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82223+ || in_group_p(grsec_proc_gid)
82224+#endif
82225+ ) {
82226+ rcu_read_unlock();
82227+ return true;
82228+ }
82229+ }
82230+ rcu_read_unlock();
82231+
82232+ if (!pid->hide_pid)
82233+ return false;
82234+#endif
82235+
82236 if (pid->hide_pid < hide_pid_min)
82237 return true;
82238 if (in_group_p(pid->pid_gid))
82239 return true;
82240+
82241 return ptrace_may_access(task, PTRACE_MODE_READ);
82242 }
82243
82244@@ -752,7 +809,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
82245 put_task_struct(task);
82246
82247 if (!has_perms) {
82248+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82249+ {
82250+#else
82251 if (pid->hide_pid == 2) {
82252+#endif
82253 /*
82254 * Let's make getdents(), stat(), and open()
82255 * consistent with each other. If a process
82256@@ -813,6 +874,10 @@ struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode)
82257
82258 if (task) {
82259 mm = mm_access(task, mode);
82260+ if (!IS_ERR_OR_NULL(mm) && gr_acl_handle_procpidmem(task)) {
82261+ mmput(mm);
82262+ mm = ERR_PTR(-EPERM);
82263+ }
82264 put_task_struct(task);
82265
82266 if (!IS_ERR_OR_NULL(mm)) {
82267@@ -834,6 +899,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
82268 return PTR_ERR(mm);
82269
82270 file->private_data = mm;
82271+
82272+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82273+ file->f_version = current->exec_id;
82274+#endif
82275+
82276 return 0;
82277 }
82278
82279@@ -855,6 +925,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
82280 ssize_t copied;
82281 char *page;
82282
82283+#ifdef CONFIG_GRKERNSEC
82284+ if (write)
82285+ return -EPERM;
82286+#endif
82287+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82288+ if (file->f_version != current->exec_id) {
82289+ gr_log_badprocpid("mem");
82290+ return 0;
82291+ }
82292+#endif
82293+
82294 if (!mm)
82295 return 0;
82296
82297@@ -867,7 +948,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
82298 goto free;
82299
82300 while (count > 0) {
82301- int this_len = min_t(int, count, PAGE_SIZE);
82302+ ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
82303
82304 if (write && copy_from_user(page, buf, this_len)) {
82305 copied = -EFAULT;
82306@@ -959,6 +1040,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
82307 if (!mm)
82308 return 0;
82309
82310+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82311+ if (file->f_version != current->exec_id) {
82312+ gr_log_badprocpid("environ");
82313+ return 0;
82314+ }
82315+#endif
82316+
82317 page = (char *)__get_free_page(GFP_TEMPORARY);
82318 if (!page)
82319 return -ENOMEM;
82320@@ -968,7 +1056,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
82321 goto free;
82322 while (count > 0) {
82323 size_t this_len, max_len;
82324- int retval;
82325+ ssize_t retval;
82326
82327 if (src >= (mm->env_end - mm->env_start))
82328 break;
82329@@ -1582,7 +1670,7 @@ static const char *proc_pid_follow_link(struct dentry *dentry, void **cookie)
82330 int error = -EACCES;
82331
82332 /* Are we allowed to snoop on the tasks file descriptors? */
82333- if (!proc_fd_access_allowed(inode))
82334+ if (!proc_fd_access_allowed(inode, 0))
82335 goto out;
82336
82337 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
82338@@ -1626,8 +1714,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
82339 struct path path;
82340
82341 /* Are we allowed to snoop on the tasks file descriptors? */
82342- if (!proc_fd_access_allowed(inode))
82343- goto out;
82344+ /* logging this is needed for learning on chromium to work properly,
82345+ but we don't want to flood the logs from 'ps' which does a readlink
82346+ on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
82347+ CAP_SYS_PTRACE as it's not necessary for its basic functionality
82348+ */
82349+ if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
82350+ if (!proc_fd_access_allowed(inode,0))
82351+ goto out;
82352+ } else {
82353+ if (!proc_fd_access_allowed(inode,1))
82354+ goto out;
82355+ }
82356
82357 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
82358 if (error)
82359@@ -1677,7 +1775,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
82360 rcu_read_lock();
82361 cred = __task_cred(task);
82362 inode->i_uid = cred->euid;
82363+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82364+ inode->i_gid = grsec_proc_gid;
82365+#else
82366 inode->i_gid = cred->egid;
82367+#endif
82368 rcu_read_unlock();
82369 }
82370 security_task_to_inode(task, inode);
82371@@ -1713,10 +1815,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
82372 return -ENOENT;
82373 }
82374 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
82375+#ifdef CONFIG_GRKERNSEC_PROC_USER
82376+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
82377+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82378+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
82379+#endif
82380 task_dumpable(task)) {
82381 cred = __task_cred(task);
82382 stat->uid = cred->euid;
82383+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82384+ stat->gid = grsec_proc_gid;
82385+#else
82386 stat->gid = cred->egid;
82387+#endif
82388 }
82389 }
82390 rcu_read_unlock();
82391@@ -1754,11 +1865,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
82392
82393 if (task) {
82394 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
82395+#ifdef CONFIG_GRKERNSEC_PROC_USER
82396+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
82397+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82398+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
82399+#endif
82400 task_dumpable(task)) {
82401 rcu_read_lock();
82402 cred = __task_cred(task);
82403 inode->i_uid = cred->euid;
82404+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82405+ inode->i_gid = grsec_proc_gid;
82406+#else
82407 inode->i_gid = cred->egid;
82408+#endif
82409 rcu_read_unlock();
82410 } else {
82411 inode->i_uid = GLOBAL_ROOT_UID;
82412@@ -2290,6 +2410,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
82413 if (!task)
82414 goto out_no_task;
82415
82416+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
82417+ goto out;
82418+
82419 /*
82420 * Yes, it does not scale. And it should not. Don't add
82421 * new entries into /proc/<tgid>/ without very good reasons.
82422@@ -2320,6 +2443,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
82423 if (!task)
82424 return -ENOENT;
82425
82426+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
82427+ goto out;
82428+
82429 if (!dir_emit_dots(file, ctx))
82430 goto out;
82431
82432@@ -2764,7 +2890,7 @@ static const struct pid_entry tgid_base_stuff[] = {
82433 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
82434 #endif
82435 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
82436-#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
82437+#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
82438 ONE("syscall", S_IRUSR, proc_pid_syscall),
82439 #endif
82440 REG("cmdline", S_IRUGO, proc_pid_cmdline_ops),
82441@@ -2789,10 +2915,10 @@ static const struct pid_entry tgid_base_stuff[] = {
82442 #ifdef CONFIG_SECURITY
82443 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
82444 #endif
82445-#ifdef CONFIG_KALLSYMS
82446+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82447 ONE("wchan", S_IRUGO, proc_pid_wchan),
82448 #endif
82449-#ifdef CONFIG_STACKTRACE
82450+#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82451 ONE("stack", S_IRUSR, proc_pid_stack),
82452 #endif
82453 #ifdef CONFIG_SCHED_INFO
82454@@ -2826,6 +2952,9 @@ static const struct pid_entry tgid_base_stuff[] = {
82455 #ifdef CONFIG_HARDWALL
82456 ONE("hardwall", S_IRUGO, proc_pid_hardwall),
82457 #endif
82458+#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
82459+ ONE("ipaddr", S_IRUSR, proc_pid_ipaddr),
82460+#endif
82461 #ifdef CONFIG_USER_NS
82462 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
82463 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
82464@@ -2958,7 +3087,14 @@ static int proc_pid_instantiate(struct inode *dir,
82465 if (!inode)
82466 goto out;
82467
82468+#ifdef CONFIG_GRKERNSEC_PROC_USER
82469+ inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
82470+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82471+ inode->i_gid = grsec_proc_gid;
82472+ inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
82473+#else
82474 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
82475+#endif
82476 inode->i_op = &proc_tgid_base_inode_operations;
82477 inode->i_fop = &proc_tgid_base_operations;
82478 inode->i_flags|=S_IMMUTABLE;
82479@@ -2996,7 +3132,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
82480 if (!task)
82481 goto out;
82482
82483+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
82484+ goto out_put_task;
82485+
82486 result = proc_pid_instantiate(dir, dentry, task, NULL);
82487+out_put_task:
82488 put_task_struct(task);
82489 out:
82490 return ERR_PTR(result);
82491@@ -3110,7 +3250,7 @@ static const struct pid_entry tid_base_stuff[] = {
82492 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
82493 #endif
82494 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
82495-#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
82496+#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
82497 ONE("syscall", S_IRUSR, proc_pid_syscall),
82498 #endif
82499 REG("cmdline", S_IRUGO, proc_pid_cmdline_ops),
82500@@ -3137,10 +3277,10 @@ static const struct pid_entry tid_base_stuff[] = {
82501 #ifdef CONFIG_SECURITY
82502 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
82503 #endif
82504-#ifdef CONFIG_KALLSYMS
82505+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82506 ONE("wchan", S_IRUGO, proc_pid_wchan),
82507 #endif
82508-#ifdef CONFIG_STACKTRACE
82509+#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82510 ONE("stack", S_IRUSR, proc_pid_stack),
82511 #endif
82512 #ifdef CONFIG_SCHED_INFO
82513diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
82514index cbd82df..c0407d2 100644
82515--- a/fs/proc/cmdline.c
82516+++ b/fs/proc/cmdline.c
82517@@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
82518
82519 static int __init proc_cmdline_init(void)
82520 {
82521+#ifdef CONFIG_GRKERNSEC_PROC_ADD
82522+ proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
82523+#else
82524 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
82525+#endif
82526 return 0;
82527 }
82528 fs_initcall(proc_cmdline_init);
82529diff --git a/fs/proc/devices.c b/fs/proc/devices.c
82530index 50493ed..248166b 100644
82531--- a/fs/proc/devices.c
82532+++ b/fs/proc/devices.c
82533@@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
82534
82535 static int __init proc_devices_init(void)
82536 {
82537+#ifdef CONFIG_GRKERNSEC_PROC_ADD
82538+ proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
82539+#else
82540 proc_create("devices", 0, NULL, &proc_devinfo_operations);
82541+#endif
82542 return 0;
82543 }
82544 fs_initcall(proc_devices_init);
82545diff --git a/fs/proc/fd.c b/fs/proc/fd.c
82546index 6e5fcd0..06ea074 100644
82547--- a/fs/proc/fd.c
82548+++ b/fs/proc/fd.c
82549@@ -27,7 +27,8 @@ static int seq_show(struct seq_file *m, void *v)
82550 if (!task)
82551 return -ENOENT;
82552
82553- files = get_files_struct(task);
82554+ if (!gr_acl_handle_procpidmem(task))
82555+ files = get_files_struct(task);
82556 put_task_struct(task);
82557
82558 if (files) {
82559@@ -291,11 +292,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
82560 */
82561 int proc_fd_permission(struct inode *inode, int mask)
82562 {
82563+ struct task_struct *task;
82564 int rv = generic_permission(inode, mask);
82565- if (rv == 0)
82566- return 0;
82567+
82568 if (task_tgid(current) == proc_pid(inode))
82569 rv = 0;
82570+
82571+ task = get_proc_task(inode);
82572+ if (task == NULL)
82573+ return rv;
82574+
82575+ if (gr_acl_handle_procpidmem(task))
82576+ rv = -EACCES;
82577+
82578+ put_task_struct(task);
82579+
82580 return rv;
82581 }
82582
82583diff --git a/fs/proc/generic.c b/fs/proc/generic.c
82584index e5dee5c..dafe21b 100644
82585--- a/fs/proc/generic.c
82586+++ b/fs/proc/generic.c
82587@@ -22,6 +22,7 @@
82588 #include <linux/bitops.h>
82589 #include <linux/spinlock.h>
82590 #include <linux/completion.h>
82591+#include <linux/grsecurity.h>
82592 #include <asm/uaccess.h>
82593
82594 #include "internal.h"
82595@@ -253,6 +254,15 @@ struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
82596 return proc_lookup_de(PDE(dir), dir, dentry);
82597 }
82598
82599+struct dentry *proc_lookup_restrict(struct inode *dir, struct dentry *dentry,
82600+ unsigned int flags)
82601+{
82602+ if (gr_proc_is_restricted())
82603+ return ERR_PTR(-EACCES);
82604+
82605+ return proc_lookup_de(PDE(dir), dir, dentry);
82606+}
82607+
82608 /*
82609 * This returns non-zero if at EOF, so that the /proc
82610 * root directory can use this and check if it should
82611@@ -310,6 +320,16 @@ int proc_readdir(struct file *file, struct dir_context *ctx)
82612 return proc_readdir_de(PDE(inode), file, ctx);
82613 }
82614
82615+int proc_readdir_restrict(struct file *file, struct dir_context *ctx)
82616+{
82617+ struct inode *inode = file_inode(file);
82618+
82619+ if (gr_proc_is_restricted())
82620+ return -EACCES;
82621+
82622+ return proc_readdir_de(PDE(inode), file, ctx);
82623+}
82624+
82625 /*
82626 * These are the generic /proc directory operations. They
82627 * use the in-memory "struct proc_dir_entry" tree to parse
82628@@ -321,6 +341,12 @@ static const struct file_operations proc_dir_operations = {
82629 .iterate = proc_readdir,
82630 };
82631
82632+static const struct file_operations proc_dir_restricted_operations = {
82633+ .llseek = generic_file_llseek,
82634+ .read = generic_read_dir,
82635+ .iterate = proc_readdir_restrict,
82636+};
82637+
82638 /*
82639 * proc directories can do almost nothing..
82640 */
82641@@ -330,6 +356,12 @@ static const struct inode_operations proc_dir_inode_operations = {
82642 .setattr = proc_notify_change,
82643 };
82644
82645+static const struct inode_operations proc_dir_restricted_inode_operations = {
82646+ .lookup = proc_lookup_restrict,
82647+ .getattr = proc_getattr,
82648+ .setattr = proc_notify_change,
82649+};
82650+
82651 static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp)
82652 {
82653 int ret;
82654@@ -445,6 +477,31 @@ struct proc_dir_entry *proc_mkdir_data(const char *name, umode_t mode,
82655 }
82656 EXPORT_SYMBOL_GPL(proc_mkdir_data);
82657
82658+struct proc_dir_entry *proc_mkdir_data_restrict(const char *name, umode_t mode,
82659+ struct proc_dir_entry *parent, void *data)
82660+{
82661+ struct proc_dir_entry *ent;
82662+
82663+ if (mode == 0)
82664+ mode = S_IRUGO | S_IXUGO;
82665+
82666+ ent = __proc_create(&parent, name, S_IFDIR | mode, 2);
82667+ if (ent) {
82668+ ent->data = data;
82669+ ent->restricted = 1;
82670+ ent->proc_fops = &proc_dir_restricted_operations;
82671+ ent->proc_iops = &proc_dir_restricted_inode_operations;
82672+ parent->nlink++;
82673+ if (proc_register(parent, ent) < 0) {
82674+ kfree(ent);
82675+ parent->nlink--;
82676+ ent = NULL;
82677+ }
82678+ }
82679+ return ent;
82680+}
82681+EXPORT_SYMBOL_GPL(proc_mkdir_data_restrict);
82682+
82683 struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
82684 struct proc_dir_entry *parent)
82685 {
82686@@ -459,6 +516,13 @@ struct proc_dir_entry *proc_mkdir(const char *name,
82687 }
82688 EXPORT_SYMBOL(proc_mkdir);
82689
82690+struct proc_dir_entry *proc_mkdir_restrict(const char *name,
82691+ struct proc_dir_entry *parent)
82692+{
82693+ return proc_mkdir_data_restrict(name, 0, parent, NULL);
82694+}
82695+EXPORT_SYMBOL(proc_mkdir_restrict);
82696+
82697 struct proc_dir_entry *proc_create_mount_point(const char *name)
82698 {
82699 umode_t mode = S_IFDIR | S_IRUGO | S_IXUGO;
82700diff --git a/fs/proc/inode.c b/fs/proc/inode.c
82701index bd95b9f..a64a773 100644
82702--- a/fs/proc/inode.c
82703+++ b/fs/proc/inode.c
82704@@ -23,11 +23,17 @@
82705 #include <linux/slab.h>
82706 #include <linux/mount.h>
82707 #include <linux/magic.h>
82708+#include <linux/grsecurity.h>
82709
82710 #include <asm/uaccess.h>
82711
82712 #include "internal.h"
82713
82714+#ifdef CONFIG_PROC_SYSCTL
82715+extern const struct inode_operations proc_sys_inode_operations;
82716+extern const struct inode_operations proc_sys_dir_operations;
82717+#endif
82718+
82719 static void proc_evict_inode(struct inode *inode)
82720 {
82721 struct proc_dir_entry *de;
82722@@ -48,6 +54,13 @@ static void proc_evict_inode(struct inode *inode)
82723 RCU_INIT_POINTER(PROC_I(inode)->sysctl, NULL);
82724 sysctl_head_put(head);
82725 }
82726+
82727+#ifdef CONFIG_PROC_SYSCTL
82728+ if (inode->i_op == &proc_sys_inode_operations ||
82729+ inode->i_op == &proc_sys_dir_operations)
82730+ gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
82731+#endif
82732+
82733 }
82734
82735 static struct kmem_cache * proc_inode_cachep;
82736@@ -429,7 +442,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
82737 if (de->mode) {
82738 inode->i_mode = de->mode;
82739 inode->i_uid = de->uid;
82740+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
82741+ inode->i_gid = grsec_proc_gid;
82742+#else
82743 inode->i_gid = de->gid;
82744+#endif
82745 }
82746 if (de->size)
82747 inode->i_size = de->size;
82748diff --git a/fs/proc/internal.h b/fs/proc/internal.h
82749index aa27810..9f2d3b2 100644
82750--- a/fs/proc/internal.h
82751+++ b/fs/proc/internal.h
82752@@ -47,9 +47,10 @@ struct proc_dir_entry {
82753 struct completion *pde_unload_completion;
82754 struct list_head pde_openers; /* who did ->open, but not ->release */
82755 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
82756+ u8 restricted; /* a directory in /proc/net that should be restricted via GRKERNSEC_PROC */
82757 u8 namelen;
82758 char name[];
82759-};
82760+} __randomize_layout;
82761
82762 union proc_op {
82763 int (*proc_get_link)(struct dentry *, struct path *);
82764@@ -67,7 +68,7 @@ struct proc_inode {
82765 struct ctl_table *sysctl_entry;
82766 const struct proc_ns_operations *ns_ops;
82767 struct inode vfs_inode;
82768-};
82769+} __randomize_layout;
82770
82771 /*
82772 * General functions
82773@@ -155,6 +156,10 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
82774 struct pid *, struct task_struct *);
82775 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
82776 struct pid *, struct task_struct *);
82777+#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
82778+extern int proc_pid_ipaddr(struct seq_file *, struct pid_namespace *,
82779+ struct pid *, struct task_struct *);
82780+#endif
82781
82782 /*
82783 * base.c
82784@@ -179,9 +184,11 @@ extern bool proc_fill_cache(struct file *, struct dir_context *, const char *, i
82785 * generic.c
82786 */
82787 extern struct dentry *proc_lookup(struct inode *, struct dentry *, unsigned int);
82788+extern struct dentry *proc_lookup_restrict(struct inode *, struct dentry *, unsigned int);
82789 extern struct dentry *proc_lookup_de(struct proc_dir_entry *, struct inode *,
82790 struct dentry *);
82791 extern int proc_readdir(struct file *, struct dir_context *);
82792+extern int proc_readdir_restrict(struct file *, struct dir_context *);
82793 extern int proc_readdir_de(struct proc_dir_entry *, struct file *, struct dir_context *);
82794
82795 static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde)
82796diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
82797index a352d57..cb94a5c 100644
82798--- a/fs/proc/interrupts.c
82799+++ b/fs/proc/interrupts.c
82800@@ -47,7 +47,11 @@ static const struct file_operations proc_interrupts_operations = {
82801
82802 static int __init proc_interrupts_init(void)
82803 {
82804+#ifdef CONFIG_GRKERNSEC_PROC_ADD
82805+ proc_create_grsec("interrupts", 0, NULL, &proc_interrupts_operations);
82806+#else
82807 proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
82808+#endif
82809 return 0;
82810 }
82811 fs_initcall(proc_interrupts_init);
82812diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
82813index 92e6726..a600d4fa 100644
82814--- a/fs/proc/kcore.c
82815+++ b/fs/proc/kcore.c
82816@@ -483,9 +483,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
82817 * the addresses in the elf_phdr on our list.
82818 */
82819 start = kc_offset_to_vaddr(*fpos - elf_buflen);
82820- if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
82821+ tsz = PAGE_SIZE - (start & ~PAGE_MASK);
82822+ if (tsz > buflen)
82823 tsz = buflen;
82824-
82825+
82826 while (buflen) {
82827 struct kcore_list *m;
82828
82829@@ -515,19 +516,20 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
82830 } else {
82831 if (kern_addr_valid(start)) {
82832 unsigned long n;
82833+ char *elf_buf;
82834+ mm_segment_t oldfs;
82835
82836- n = copy_to_user(buffer, (char *)start, tsz);
82837- /*
82838- * We cannot distinguish between fault on source
82839- * and fault on destination. When this happens
82840- * we clear too and hope it will trigger the
82841- * EFAULT again.
82842- */
82843- if (n) {
82844- if (clear_user(buffer + tsz - n,
82845- n))
82846- return -EFAULT;
82847- }
82848+ elf_buf = kzalloc(tsz, GFP_KERNEL);
82849+ if (!elf_buf)
82850+ return -ENOMEM;
82851+ oldfs = get_fs();
82852+ set_fs(KERNEL_DS);
82853+ n = __copy_from_user(elf_buf, (const void __user *)start, tsz);
82854+ set_fs(oldfs);
82855+ n = copy_to_user(buffer, elf_buf, tsz);
82856+ kfree(elf_buf);
82857+ if (n)
82858+ return -EFAULT;
82859 } else {
82860 if (clear_user(buffer, tsz))
82861 return -EFAULT;
82862@@ -547,6 +549,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
82863
82864 static int open_kcore(struct inode *inode, struct file *filp)
82865 {
82866+#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
82867+ return -EPERM;
82868+#endif
82869 if (!capable(CAP_SYS_RAWIO))
82870 return -EPERM;
82871 if (kcore_need_update)
82872@@ -580,7 +585,7 @@ static int __meminit kcore_callback(struct notifier_block *self,
82873 return NOTIFY_OK;
82874 }
82875
82876-static struct notifier_block kcore_callback_nb __meminitdata = {
82877+static struct notifier_block kcore_callback_nb __meminitconst = {
82878 .notifier_call = kcore_callback,
82879 .priority = 0,
82880 };
82881diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
82882index d3ebf2e..6ad42d1 100644
82883--- a/fs/proc/meminfo.c
82884+++ b/fs/proc/meminfo.c
82885@@ -194,7 +194,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
82886 vmi.used >> 10,
82887 vmi.largest_chunk >> 10
82888 #ifdef CONFIG_MEMORY_FAILURE
82889- , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
82890+ , atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
82891 #endif
82892 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
82893 , K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
82894diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
82895index f8595e8..e0d13cbd 100644
82896--- a/fs/proc/nommu.c
82897+++ b/fs/proc/nommu.c
82898@@ -64,7 +64,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
82899
82900 if (file) {
82901 seq_pad(m, ' ');
82902- seq_file_path(m, file, "");
82903+ seq_file_path(m, file, "\n\\");
82904 }
82905
82906 seq_putc(m, '\n');
82907diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
82908index 350984a..0fb02a9 100644
82909--- a/fs/proc/proc_net.c
82910+++ b/fs/proc/proc_net.c
82911@@ -23,9 +23,27 @@
82912 #include <linux/nsproxy.h>
82913 #include <net/net_namespace.h>
82914 #include <linux/seq_file.h>
82915+#include <linux/grsecurity.h>
82916
82917 #include "internal.h"
82918
82919+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
82920+static struct seq_operations *ipv6_seq_ops_addr;
82921+
82922+void register_ipv6_seq_ops_addr(struct seq_operations *addr)
82923+{
82924+ ipv6_seq_ops_addr = addr;
82925+}
82926+
82927+void unregister_ipv6_seq_ops_addr(void)
82928+{
82929+ ipv6_seq_ops_addr = NULL;
82930+}
82931+
82932+EXPORT_SYMBOL_GPL(register_ipv6_seq_ops_addr);
82933+EXPORT_SYMBOL_GPL(unregister_ipv6_seq_ops_addr);
82934+#endif
82935+
82936 static inline struct net *PDE_NET(struct proc_dir_entry *pde)
82937 {
82938 return pde->parent->data;
82939@@ -36,6 +54,8 @@ static struct net *get_proc_net(const struct inode *inode)
82940 return maybe_get_net(PDE_NET(PDE(inode)));
82941 }
82942
82943+extern const struct seq_operations dev_seq_ops;
82944+
82945 int seq_open_net(struct inode *ino, struct file *f,
82946 const struct seq_operations *ops, int size)
82947 {
82948@@ -44,6 +64,14 @@ int seq_open_net(struct inode *ino, struct file *f,
82949
82950 BUG_ON(size < sizeof(*p));
82951
82952+ /* only permit access to /proc/net/dev */
82953+ if (
82954+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
82955+ ops != ipv6_seq_ops_addr &&
82956+#endif
82957+ ops != &dev_seq_ops && gr_proc_is_restricted())
82958+ return -EACCES;
82959+
82960 net = get_proc_net(ino);
82961 if (net == NULL)
82962 return -ENXIO;
82963@@ -66,6 +94,9 @@ int single_open_net(struct inode *inode, struct file *file,
82964 int err;
82965 struct net *net;
82966
82967+ if (gr_proc_is_restricted())
82968+ return -EACCES;
82969+
82970 err = -ENXIO;
82971 net = get_proc_net(inode);
82972 if (net == NULL)
82973diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
82974index fdda62e..cd7c75f 100644
82975--- a/fs/proc/proc_sysctl.c
82976+++ b/fs/proc/proc_sysctl.c
82977@@ -11,13 +11,21 @@
82978 #include <linux/namei.h>
82979 #include <linux/mm.h>
82980 #include <linux/module.h>
82981+#include <linux/nsproxy.h>
82982+#ifdef CONFIG_GRKERNSEC
82983+#include <net/net_namespace.h>
82984+#endif
82985 #include "internal.h"
82986
82987+extern int gr_handle_chroot_sysctl(const int op);
82988+extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
82989+ const int op);
82990+
82991 static const struct dentry_operations proc_sys_dentry_operations;
82992 static const struct file_operations proc_sys_file_operations;
82993-static const struct inode_operations proc_sys_inode_operations;
82994+const struct inode_operations proc_sys_inode_operations;
82995 static const struct file_operations proc_sys_dir_file_operations;
82996-static const struct inode_operations proc_sys_dir_operations;
82997+const struct inode_operations proc_sys_dir_operations;
82998
82999 /* Support for permanently empty directories */
83000
83001@@ -32,13 +40,17 @@ static bool is_empty_dir(struct ctl_table_header *head)
83002
83003 static void set_empty_dir(struct ctl_dir *dir)
83004 {
83005- dir->header.ctl_table[0].child = sysctl_mount_point;
83006+ pax_open_kernel();
83007+ *(const void **)&dir->header.ctl_table[0].child = sysctl_mount_point;
83008+ pax_close_kernel();
83009 }
83010
83011 static void clear_empty_dir(struct ctl_dir *dir)
83012
83013 {
83014- dir->header.ctl_table[0].child = NULL;
83015+ pax_open_kernel();
83016+ *(void **)&dir->header.ctl_table[0].child = NULL;
83017+ pax_close_kernel();
83018 }
83019
83020 void proc_sys_poll_notify(struct ctl_table_poll *poll)
83021@@ -504,6 +516,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
83022
83023 err = NULL;
83024 d_set_d_op(dentry, &proc_sys_dentry_operations);
83025+
83026+ gr_handle_proc_create(dentry, inode);
83027+
83028 d_add(dentry, inode);
83029
83030 out:
83031@@ -519,6 +534,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
83032 struct inode *inode = file_inode(filp);
83033 struct ctl_table_header *head = grab_header(inode);
83034 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
83035+ int op = write ? MAY_WRITE : MAY_READ;
83036 ssize_t error;
83037 size_t res;
83038
83039@@ -530,7 +546,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
83040 * and won't be until we finish.
83041 */
83042 error = -EPERM;
83043- if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
83044+ if (sysctl_perm(head, table, op))
83045 goto out;
83046
83047 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
83048@@ -538,6 +554,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
83049 if (!table->proc_handler)
83050 goto out;
83051
83052+#ifdef CONFIG_GRKERNSEC
83053+ error = -EPERM;
83054+ if (gr_handle_chroot_sysctl(op))
83055+ goto out;
83056+ dget(filp->f_path.dentry);
83057+ if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
83058+ dput(filp->f_path.dentry);
83059+ goto out;
83060+ }
83061+ dput(filp->f_path.dentry);
83062+ if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
83063+ goto out;
83064+ if (write) {
83065+ if (current->nsproxy->net_ns != table->extra2) {
83066+ if (!capable(CAP_SYS_ADMIN))
83067+ goto out;
83068+ } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
83069+ goto out;
83070+ }
83071+#endif
83072+
83073 /* careful: calling conventions are nasty here */
83074 res = count;
83075 error = table->proc_handler(table, write, buf, &res, ppos);
83076@@ -635,6 +672,9 @@ static bool proc_sys_fill_cache(struct file *file,
83077 return false;
83078 } else {
83079 d_set_d_op(child, &proc_sys_dentry_operations);
83080+
83081+ gr_handle_proc_create(child, inode);
83082+
83083 d_add(child, inode);
83084 }
83085 } else {
83086@@ -678,6 +718,9 @@ static int scan(struct ctl_table_header *head, struct ctl_table *table,
83087 if ((*pos)++ < ctx->pos)
83088 return true;
83089
83090+ if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
83091+ return 0;
83092+
83093 if (unlikely(S_ISLNK(table->mode)))
83094 res = proc_sys_link_fill_cache(file, ctx, head, table);
83095 else
83096@@ -771,6 +814,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
83097 if (IS_ERR(head))
83098 return PTR_ERR(head);
83099
83100+ if (table && !gr_acl_handle_hidden_file(dentry, mnt))
83101+ return -ENOENT;
83102+
83103 generic_fillattr(inode, stat);
83104 if (table)
83105 stat->mode = (stat->mode & S_IFMT) | table->mode;
83106@@ -793,13 +839,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
83107 .llseek = generic_file_llseek,
83108 };
83109
83110-static const struct inode_operations proc_sys_inode_operations = {
83111+const struct inode_operations proc_sys_inode_operations = {
83112 .permission = proc_sys_permission,
83113 .setattr = proc_sys_setattr,
83114 .getattr = proc_sys_getattr,
83115 };
83116
83117-static const struct inode_operations proc_sys_dir_operations = {
83118+const struct inode_operations proc_sys_dir_operations = {
83119 .lookup = proc_sys_lookup,
83120 .permission = proc_sys_permission,
83121 .setattr = proc_sys_setattr,
83122@@ -876,7 +922,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
83123 static struct ctl_dir *new_dir(struct ctl_table_set *set,
83124 const char *name, int namelen)
83125 {
83126- struct ctl_table *table;
83127+ ctl_table_no_const *table;
83128 struct ctl_dir *new;
83129 struct ctl_node *node;
83130 char *new_name;
83131@@ -888,7 +934,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
83132 return NULL;
83133
83134 node = (struct ctl_node *)(new + 1);
83135- table = (struct ctl_table *)(node + 1);
83136+ table = (ctl_table_no_const *)(node + 1);
83137 new_name = (char *)(table + 2);
83138 memcpy(new_name, name, namelen);
83139 new_name[namelen] = '\0';
83140@@ -1057,7 +1103,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
83141 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
83142 struct ctl_table_root *link_root)
83143 {
83144- struct ctl_table *link_table, *entry, *link;
83145+ ctl_table_no_const *link_table, *link;
83146+ struct ctl_table *entry;
83147 struct ctl_table_header *links;
83148 struct ctl_node *node;
83149 char *link_name;
83150@@ -1080,7 +1127,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
83151 return NULL;
83152
83153 node = (struct ctl_node *)(links + 1);
83154- link_table = (struct ctl_table *)(node + nr_entries);
83155+ link_table = (ctl_table_no_const *)(node + nr_entries);
83156 link_name = (char *)&link_table[nr_entries + 1];
83157
83158 for (link = link_table, entry = table; entry->procname; link++, entry++) {
83159@@ -1328,8 +1375,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
83160 struct ctl_table_header ***subheader, struct ctl_table_set *set,
83161 struct ctl_table *table)
83162 {
83163- struct ctl_table *ctl_table_arg = NULL;
83164- struct ctl_table *entry, *files;
83165+ ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
83166+ struct ctl_table *entry;
83167 int nr_files = 0;
83168 int nr_dirs = 0;
83169 int err = -ENOMEM;
83170@@ -1341,10 +1388,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
83171 nr_files++;
83172 }
83173
83174- files = table;
83175 /* If there are mixed files and directories we need a new table */
83176 if (nr_dirs && nr_files) {
83177- struct ctl_table *new;
83178+ ctl_table_no_const *new;
83179 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
83180 GFP_KERNEL);
83181 if (!files)
83182@@ -1362,7 +1408,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
83183 /* Register everything except a directory full of subdirectories */
83184 if (nr_files || !nr_dirs) {
83185 struct ctl_table_header *header;
83186- header = __register_sysctl_table(set, path, files);
83187+ header = __register_sysctl_table(set, path, files ? files : table);
83188 if (!header) {
83189 kfree(ctl_table_arg);
83190 goto out;
83191diff --git a/fs/proc/root.c b/fs/proc/root.c
83192index 68feb0f..2c04780 100644
83193--- a/fs/proc/root.c
83194+++ b/fs/proc/root.c
83195@@ -185,7 +185,15 @@ void __init proc_root_init(void)
83196 proc_create_mount_point("openprom");
83197 #endif
83198 proc_tty_init();
83199+#ifdef CONFIG_GRKERNSEC_PROC_ADD
83200+#ifdef CONFIG_GRKERNSEC_PROC_USER
83201+ proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
83202+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83203+ proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
83204+#endif
83205+#else
83206 proc_mkdir("bus", NULL);
83207+#endif
83208 proc_sys_init();
83209 }
83210
83211diff --git a/fs/proc/stat.c b/fs/proc/stat.c
83212index 510413eb..34d9a8c 100644
83213--- a/fs/proc/stat.c
83214+++ b/fs/proc/stat.c
83215@@ -11,6 +11,7 @@
83216 #include <linux/irqnr.h>
83217 #include <linux/cputime.h>
83218 #include <linux/tick.h>
83219+#include <linux/grsecurity.h>
83220
83221 #ifndef arch_irq_stat_cpu
83222 #define arch_irq_stat_cpu(cpu) 0
83223@@ -87,6 +88,18 @@ static int show_stat(struct seq_file *p, void *v)
83224 u64 sum_softirq = 0;
83225 unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
83226 struct timespec boottime;
83227+ int unrestricted = 1;
83228+
83229+#ifdef CONFIG_GRKERNSEC_PROC_ADD
83230+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83231+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
83232+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
83233+ && !in_group_p(grsec_proc_gid)
83234+#endif
83235+ )
83236+ unrestricted = 0;
83237+#endif
83238+#endif
83239
83240 user = nice = system = idle = iowait =
83241 irq = softirq = steal = 0;
83242@@ -99,23 +112,25 @@ static int show_stat(struct seq_file *p, void *v)
83243 nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE];
83244 system += kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
83245 idle += get_idle_time(i);
83246- iowait += get_iowait_time(i);
83247- irq += kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
83248- softirq += kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
83249- steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
83250- guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
83251- guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
83252- sum += kstat_cpu_irqs_sum(i);
83253- sum += arch_irq_stat_cpu(i);
83254+ if (unrestricted) {
83255+ iowait += get_iowait_time(i);
83256+ irq += kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
83257+ softirq += kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
83258+ steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
83259+ guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
83260+ guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
83261+ sum += kstat_cpu_irqs_sum(i);
83262+ sum += arch_irq_stat_cpu(i);
83263+ for (j = 0; j < NR_SOFTIRQS; j++) {
83264+ unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
83265
83266- for (j = 0; j < NR_SOFTIRQS; j++) {
83267- unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
83268-
83269- per_softirq_sums[j] += softirq_stat;
83270- sum_softirq += softirq_stat;
83271+ per_softirq_sums[j] += softirq_stat;
83272+ sum_softirq += softirq_stat;
83273+ }
83274 }
83275 }
83276- sum += arch_irq_stat();
83277+ if (unrestricted)
83278+ sum += arch_irq_stat();
83279
83280 seq_puts(p, "cpu ");
83281 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
83282@@ -136,12 +151,14 @@ static int show_stat(struct seq_file *p, void *v)
83283 nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE];
83284 system = kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
83285 idle = get_idle_time(i);
83286- iowait = get_iowait_time(i);
83287- irq = kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
83288- softirq = kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
83289- steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
83290- guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
83291- guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
83292+ if (unrestricted) {
83293+ iowait = get_iowait_time(i);
83294+ irq = kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
83295+ softirq = kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
83296+ steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
83297+ guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
83298+ guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
83299+ }
83300 seq_printf(p, "cpu%d", i);
83301 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
83302 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(nice));
83303@@ -159,7 +176,7 @@ static int show_stat(struct seq_file *p, void *v)
83304
83305 /* sum again ? it could be updated? */
83306 for_each_irq_nr(j)
83307- seq_put_decimal_ull(p, ' ', kstat_irqs_usr(j));
83308+ seq_put_decimal_ull(p, ' ', unrestricted ? kstat_irqs_usr(j) : 0ULL);
83309
83310 seq_printf(p,
83311 "\nctxt %llu\n"
83312@@ -167,11 +184,11 @@ static int show_stat(struct seq_file *p, void *v)
83313 "processes %lu\n"
83314 "procs_running %lu\n"
83315 "procs_blocked %lu\n",
83316- nr_context_switches(),
83317+ unrestricted ? nr_context_switches() : 0ULL,
83318 (unsigned long)jif,
83319- total_forks,
83320- nr_running(),
83321- nr_iowait());
83322+ unrestricted ? total_forks : 0UL,
83323+ unrestricted ? nr_running() : 0UL,
83324+ unrestricted ? nr_iowait() : 0UL);
83325
83326 seq_printf(p, "softirq %llu", (unsigned long long)sum_softirq);
83327
83328diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
83329index ca1e091..a048795 100644
83330--- a/fs/proc/task_mmu.c
83331+++ b/fs/proc/task_mmu.c
83332@@ -13,12 +13,19 @@
83333 #include <linux/swap.h>
83334 #include <linux/swapops.h>
83335 #include <linux/mmu_notifier.h>
83336+#include <linux/grsecurity.h>
83337
83338 #include <asm/elf.h>
83339 #include <asm/uaccess.h>
83340 #include <asm/tlbflush.h>
83341 #include "internal.h"
83342
83343+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83344+#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
83345+ (_mm->pax_flags & MF_PAX_RANDMMAP || \
83346+ _mm->pax_flags & MF_PAX_SEGMEXEC))
83347+#endif
83348+
83349 void task_mem(struct seq_file *m, struct mm_struct *mm)
83350 {
83351 unsigned long data, text, lib, swap, ptes, pmds;
83352@@ -57,8 +64,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
83353 "VmLib:\t%8lu kB\n"
83354 "VmPTE:\t%8lu kB\n"
83355 "VmPMD:\t%8lu kB\n"
83356- "VmSwap:\t%8lu kB\n",
83357- hiwater_vm << (PAGE_SHIFT-10),
83358+ "VmSwap:\t%8lu kB\n"
83359+
83360+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83361+ "CsBase:\t%8lx\nCsLim:\t%8lx\n"
83362+#endif
83363+
83364+ ,hiwater_vm << (PAGE_SHIFT-10),
83365 total_vm << (PAGE_SHIFT-10),
83366 mm->locked_vm << (PAGE_SHIFT-10),
83367 mm->pinned_vm << (PAGE_SHIFT-10),
83368@@ -68,7 +80,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
83369 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
83370 ptes >> 10,
83371 pmds >> 10,
83372- swap << (PAGE_SHIFT-10));
83373+ swap << (PAGE_SHIFT-10)
83374+
83375+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83376+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83377+ , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
83378+ , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
83379+#else
83380+ , mm->context.user_cs_base
83381+ , mm->context.user_cs_limit
83382+#endif
83383+#endif
83384+
83385+ );
83386 }
83387
83388 unsigned long task_vsize(struct mm_struct *mm)
83389@@ -285,13 +309,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
83390 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
83391 }
83392
83393- /* We don't show the stack guard page in /proc/maps */
83394+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83395+ start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
83396+ end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
83397+#else
83398 start = vma->vm_start;
83399- if (stack_guard_page_start(vma, start))
83400- start += PAGE_SIZE;
83401 end = vma->vm_end;
83402- if (stack_guard_page_end(vma, end))
83403- end -= PAGE_SIZE;
83404+#endif
83405
83406 seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
83407 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
83408@@ -301,7 +325,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
83409 flags & VM_WRITE ? 'w' : '-',
83410 flags & VM_EXEC ? 'x' : '-',
83411 flags & VM_MAYSHARE ? 's' : 'p',
83412+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83413+ PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
83414+#else
83415 pgoff,
83416+#endif
83417 MAJOR(dev), MINOR(dev), ino);
83418
83419 /*
83420@@ -310,7 +338,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
83421 */
83422 if (file) {
83423 seq_pad(m, ' ');
83424- seq_file_path(m, file, "\n");
83425+ seq_file_path(m, file, "\n\\");
83426 goto done;
83427 }
83428
83429@@ -341,8 +369,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
83430 * Thread stack in /proc/PID/task/TID/maps or
83431 * the main process stack.
83432 */
83433- if (!is_pid || (vma->vm_start <= mm->start_stack &&
83434- vma->vm_end >= mm->start_stack)) {
83435+ if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
83436+ (vma->vm_start <= mm->start_stack &&
83437+ vma->vm_end >= mm->start_stack)) {
83438 name = "[stack]";
83439 } else {
83440 /* Thread stack in /proc/PID/maps */
83441@@ -362,6 +391,12 @@ done:
83442
83443 static int show_map(struct seq_file *m, void *v, int is_pid)
83444 {
83445+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83446+ if (current->exec_id != m->exec_id) {
83447+ gr_log_badprocpid("maps");
83448+ return 0;
83449+ }
83450+#endif
83451 show_map_vma(m, v, is_pid);
83452 m_cache_vma(m, v);
83453 return 0;
83454@@ -620,9 +655,18 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
83455 .private = &mss,
83456 };
83457
83458+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83459+ if (current->exec_id != m->exec_id) {
83460+ gr_log_badprocpid("smaps");
83461+ return 0;
83462+ }
83463+#endif
83464 memset(&mss, 0, sizeof mss);
83465- /* mmap_sem is held in m_start */
83466- walk_page_vma(vma, &smaps_walk);
83467+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83468+ if (!PAX_RAND_FLAGS(vma->vm_mm))
83469+#endif
83470+ /* mmap_sem is held in m_start */
83471+ walk_page_vma(vma, &smaps_walk);
83472
83473 show_map_vma(m, vma, is_pid);
83474
83475@@ -641,7 +685,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
83476 "KernelPageSize: %8lu kB\n"
83477 "MMUPageSize: %8lu kB\n"
83478 "Locked: %8lu kB\n",
83479+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83480+ PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
83481+#else
83482 (vma->vm_end - vma->vm_start) >> 10,
83483+#endif
83484 mss.resident >> 10,
83485 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
83486 mss.shared_clean >> 10,
83487@@ -1491,6 +1539,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
83488 char buffer[64];
83489 int nid;
83490
83491+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83492+ if (current->exec_id != m->exec_id) {
83493+ gr_log_badprocpid("numa_maps");
83494+ return 0;
83495+ }
83496+#endif
83497+
83498 if (!mm)
83499 return 0;
83500
83501@@ -1505,11 +1560,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
83502 mpol_to_str(buffer, sizeof(buffer), proc_priv->task_mempolicy);
83503 }
83504
83505+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83506+ seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
83507+#else
83508 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
83509+#endif
83510
83511 if (file) {
83512 seq_puts(m, " file=");
83513- seq_file_path(m, file, "\n\t= ");
83514+ seq_file_path(m, file, "\n\t\\= ");
83515 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
83516 seq_puts(m, " heap");
83517 } else {
83518diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
83519index e0d64c9..c44c96e 100644
83520--- a/fs/proc/task_nommu.c
83521+++ b/fs/proc/task_nommu.c
83522@@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
83523 else
83524 bytes += kobjsize(mm);
83525
83526- if (current->fs && current->fs->users > 1)
83527+ if (current->fs && atomic_read(&current->fs->users) > 1)
83528 sbytes += kobjsize(current->fs);
83529 else
83530 bytes += kobjsize(current->fs);
83531@@ -180,7 +180,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
83532
83533 if (file) {
83534 seq_pad(m, ' ');
83535- seq_file_path(m, file, "");
83536+ seq_file_path(m, file, "\n\\");
83537 } else if (mm) {
83538 pid_t tid = pid_of_stack(priv, vma, is_pid);
83539
83540diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
83541index 4e61388..1a2523d 100644
83542--- a/fs/proc/vmcore.c
83543+++ b/fs/proc/vmcore.c
83544@@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
83545 nr_bytes = count;
83546
83547 /* If pfn is not ram, return zeros for sparse dump files */
83548- if (pfn_is_ram(pfn) == 0)
83549- memset(buf, 0, nr_bytes);
83550- else {
83551+ if (pfn_is_ram(pfn) == 0) {
83552+ if (userbuf) {
83553+ if (clear_user((char __force_user *)buf, nr_bytes))
83554+ return -EFAULT;
83555+ } else
83556+ memset(buf, 0, nr_bytes);
83557+ } else {
83558 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
83559 offset, userbuf);
83560 if (tmp < 0)
83561@@ -170,7 +174,7 @@ int __weak remap_oldmem_pfn_range(struct vm_area_struct *vma,
83562 static int copy_to(void *target, void *src, size_t size, int userbuf)
83563 {
83564 if (userbuf) {
83565- if (copy_to_user((char __user *) target, src, size))
83566+ if (copy_to_user((char __force_user *) target, src, size))
83567 return -EFAULT;
83568 } else {
83569 memcpy(target, src, size);
83570@@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
83571 if (*fpos < m->offset + m->size) {
83572 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
83573 start = m->paddr + *fpos - m->offset;
83574- tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
83575+ tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
83576 if (tmp < 0)
83577 return tmp;
83578 buflen -= tsz;
83579@@ -253,7 +257,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
83580 static ssize_t read_vmcore(struct file *file, char __user *buffer,
83581 size_t buflen, loff_t *fpos)
83582 {
83583- return __read_vmcore((__force char *) buffer, buflen, fpos, 1);
83584+ return __read_vmcore((__force_kernel char *) buffer, buflen, fpos, 1);
83585 }
83586
83587 /*
83588diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
83589index d3fb2b6..43a8140 100644
83590--- a/fs/qnx6/qnx6.h
83591+++ b/fs/qnx6/qnx6.h
83592@@ -74,7 +74,7 @@ enum {
83593 BYTESEX_BE,
83594 };
83595
83596-static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
83597+static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
83598 {
83599 if (sbi->s_bytesex == BYTESEX_LE)
83600 return le64_to_cpu((__force __le64)n);
83601@@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
83602 return (__force __fs64)cpu_to_be64(n);
83603 }
83604
83605-static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
83606+static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
83607 {
83608 if (sbi->s_bytesex == BYTESEX_LE)
83609 return le32_to_cpu((__force __le32)n);
83610diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
83611index bb2869f..d34ada8 100644
83612--- a/fs/quota/netlink.c
83613+++ b/fs/quota/netlink.c
83614@@ -44,7 +44,7 @@ static struct genl_family quota_genl_family = {
83615 void quota_send_warning(struct kqid qid, dev_t dev,
83616 const char warntype)
83617 {
83618- static atomic_t seq;
83619+ static atomic_unchecked_t seq;
83620 struct sk_buff *skb;
83621 void *msg_head;
83622 int ret;
83623@@ -60,7 +60,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
83624 "VFS: Not enough memory to send quota warning.\n");
83625 return;
83626 }
83627- msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
83628+ msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
83629 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
83630 if (!msg_head) {
83631 printk(KERN_ERR
83632diff --git a/fs/read_write.c b/fs/read_write.c
83633index 819ef3f..f07222d 100644
83634--- a/fs/read_write.c
83635+++ b/fs/read_write.c
83636@@ -505,7 +505,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
83637
83638 old_fs = get_fs();
83639 set_fs(get_ds());
83640- p = (__force const char __user *)buf;
83641+ p = (const char __force_user *)buf;
83642 if (count > MAX_RW_COUNT)
83643 count = MAX_RW_COUNT;
83644 ret = __vfs_write(file, p, count, pos);
83645diff --git a/fs/readdir.c b/fs/readdir.c
83646index ced6791..936687b 100644
83647--- a/fs/readdir.c
83648+++ b/fs/readdir.c
83649@@ -18,6 +18,7 @@
83650 #include <linux/security.h>
83651 #include <linux/syscalls.h>
83652 #include <linux/unistd.h>
83653+#include <linux/namei.h>
83654
83655 #include <asm/uaccess.h>
83656
83657@@ -71,6 +72,7 @@ struct old_linux_dirent {
83658 struct readdir_callback {
83659 struct dir_context ctx;
83660 struct old_linux_dirent __user * dirent;
83661+ struct file * file;
83662 int result;
83663 };
83664
83665@@ -89,6 +91,10 @@ static int fillonedir(struct dir_context *ctx, const char *name, int namlen,
83666 buf->result = -EOVERFLOW;
83667 return -EOVERFLOW;
83668 }
83669+
83670+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
83671+ return 0;
83672+
83673 buf->result++;
83674 dirent = buf->dirent;
83675 if (!access_ok(VERIFY_WRITE, dirent,
83676@@ -120,6 +126,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
83677 if (!f.file)
83678 return -EBADF;
83679
83680+ buf.file = f.file;
83681 error = iterate_dir(f.file, &buf.ctx);
83682 if (buf.result)
83683 error = buf.result;
83684@@ -145,6 +152,7 @@ struct getdents_callback {
83685 struct dir_context ctx;
83686 struct linux_dirent __user * current_dir;
83687 struct linux_dirent __user * previous;
83688+ struct file * file;
83689 int count;
83690 int error;
83691 };
83692@@ -167,6 +175,10 @@ static int filldir(struct dir_context *ctx, const char *name, int namlen,
83693 buf->error = -EOVERFLOW;
83694 return -EOVERFLOW;
83695 }
83696+
83697+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
83698+ return 0;
83699+
83700 dirent = buf->previous;
83701 if (dirent) {
83702 if (__put_user(offset, &dirent->d_off))
83703@@ -212,6 +224,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
83704 if (!f.file)
83705 return -EBADF;
83706
83707+ buf.file = f.file;
83708 error = iterate_dir(f.file, &buf.ctx);
83709 if (error >= 0)
83710 error = buf.error;
83711@@ -230,6 +243,7 @@ struct getdents_callback64 {
83712 struct dir_context ctx;
83713 struct linux_dirent64 __user * current_dir;
83714 struct linux_dirent64 __user * previous;
83715+ struct file *file;
83716 int count;
83717 int error;
83718 };
83719@@ -246,6 +260,10 @@ static int filldir64(struct dir_context *ctx, const char *name, int namlen,
83720 buf->error = -EINVAL; /* only used if we fail.. */
83721 if (reclen > buf->count)
83722 return -EINVAL;
83723+
83724+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
83725+ return 0;
83726+
83727 dirent = buf->previous;
83728 if (dirent) {
83729 if (__put_user(offset, &dirent->d_off))
83730@@ -293,6 +311,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
83731 if (!f.file)
83732 return -EBADF;
83733
83734+ buf.file = f.file;
83735 error = iterate_dir(f.file, &buf.ctx);
83736 if (error >= 0)
83737 error = buf.error;
83738diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
83739index 9c02d96..6562c10 100644
83740--- a/fs/reiserfs/do_balan.c
83741+++ b/fs/reiserfs/do_balan.c
83742@@ -1887,7 +1887,7 @@ void do_balance(struct tree_balance *tb, struct item_head *ih,
83743 return;
83744 }
83745
83746- atomic_inc(&fs_generation(tb->tb_sb));
83747+ atomic_inc_unchecked(&fs_generation(tb->tb_sb));
83748 do_balance_starts(tb);
83749
83750 /*
83751diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
83752index aca73dd..e3c558d 100644
83753--- a/fs/reiserfs/item_ops.c
83754+++ b/fs/reiserfs/item_ops.c
83755@@ -724,18 +724,18 @@ static void errcatch_print_vi(struct virtual_item *vi)
83756 }
83757
83758 static struct item_operations errcatch_ops = {
83759- errcatch_bytes_number,
83760- errcatch_decrement_key,
83761- errcatch_is_left_mergeable,
83762- errcatch_print_item,
83763- errcatch_check_item,
83764+ .bytes_number = errcatch_bytes_number,
83765+ .decrement_key = errcatch_decrement_key,
83766+ .is_left_mergeable = errcatch_is_left_mergeable,
83767+ .print_item = errcatch_print_item,
83768+ .check_item = errcatch_check_item,
83769
83770- errcatch_create_vi,
83771- errcatch_check_left,
83772- errcatch_check_right,
83773- errcatch_part_size,
83774- errcatch_unit_num,
83775- errcatch_print_vi
83776+ .create_vi = errcatch_create_vi,
83777+ .check_left = errcatch_check_left,
83778+ .check_right = errcatch_check_right,
83779+ .part_size = errcatch_part_size,
83780+ .unit_num = errcatch_unit_num,
83781+ .print_vi = errcatch_print_vi
83782 };
83783
83784 #if ! (TYPE_STAT_DATA == 0 && TYPE_INDIRECT == 1 && TYPE_DIRECT == 2 && TYPE_DIRENTRY == 3)
83785diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
83786index 621b9f3..af527fd 100644
83787--- a/fs/reiserfs/procfs.c
83788+++ b/fs/reiserfs/procfs.c
83789@@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
83790 "SMALL_TAILS " : "NO_TAILS ",
83791 replay_only(sb) ? "REPLAY_ONLY " : "",
83792 convert_reiserfs(sb) ? "CONV " : "",
83793- atomic_read(&r->s_generation_counter),
83794+ atomic_read_unchecked(&r->s_generation_counter),
83795 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
83796 SF(s_do_balance), SF(s_unneeded_left_neighbor),
83797 SF(s_good_search_by_key_reada), SF(s_bmaps),
83798diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
83799index 2adcde1..7d27bc8 100644
83800--- a/fs/reiserfs/reiserfs.h
83801+++ b/fs/reiserfs/reiserfs.h
83802@@ -580,7 +580,7 @@ struct reiserfs_sb_info {
83803 /* Comment? -Hans */
83804 wait_queue_head_t s_wait;
83805 /* increased by one every time the tree gets re-balanced */
83806- atomic_t s_generation_counter;
83807+ atomic_unchecked_t s_generation_counter;
83808
83809 /* File system properties. Currently holds on-disk FS format */
83810 unsigned long s_properties;
83811@@ -2300,7 +2300,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
83812 #define REISERFS_USER_MEM 1 /* user memory mode */
83813
83814 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
83815-#define get_generation(s) atomic_read (&fs_generation(s))
83816+#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
83817 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
83818 #define __fs_changed(gen,s) (gen != get_generation (s))
83819 #define fs_changed(gen,s) \
83820diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
83821index 4a62fe8..5dc2f5f 100644
83822--- a/fs/reiserfs/super.c
83823+++ b/fs/reiserfs/super.c
83824@@ -1870,6 +1870,10 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
83825 sbi->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
83826 sbi->s_mount_opt |= (1 << REISERFS_ERROR_RO);
83827 sbi->s_mount_opt |= (1 << REISERFS_BARRIER_FLUSH);
83828+#ifdef CONFIG_REISERFS_FS_XATTR
83829+ /* turn on user xattrs by default */
83830+ sbi->s_mount_opt |= (1 << REISERFS_XATTRS_USER);
83831+#endif
83832 /* no preallocation minimum, be smart in reiserfs_file_write instead */
83833 sbi->s_alloc_options.preallocmin = 0;
83834 /* Preallocate by 16 blocks (17-1) at once */
83835diff --git a/fs/select.c b/fs/select.c
83836index 0155473..29d751f 100644
83837--- a/fs/select.c
83838+++ b/fs/select.c
83839@@ -20,6 +20,7 @@
83840 #include <linux/export.h>
83841 #include <linux/slab.h>
83842 #include <linux/poll.h>
83843+#include <linux/security.h>
83844 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
83845 #include <linux/file.h>
83846 #include <linux/fdtable.h>
83847@@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
83848 struct poll_list *walk = head;
83849 unsigned long todo = nfds;
83850
83851+ gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
83852 if (nfds > rlimit(RLIMIT_NOFILE))
83853 return -EINVAL;
83854
83855diff --git a/fs/seq_file.c b/fs/seq_file.c
83856index ce9e39f..5c5a436 100644
83857--- a/fs/seq_file.c
83858+++ b/fs/seq_file.c
83859@@ -12,6 +12,8 @@
83860 #include <linux/slab.h>
83861 #include <linux/cred.h>
83862 #include <linux/mm.h>
83863+#include <linux/sched.h>
83864+#include <linux/grsecurity.h>
83865
83866 #include <asm/uaccess.h>
83867 #include <asm/page.h>
83868@@ -29,9 +31,9 @@ static void *seq_buf_alloc(unsigned long size)
83869 * __GFP_NORETRY to avoid oom-killings with high-order allocations -
83870 * it's better to fall back to vmalloc() than to kill things.
83871 */
83872- buf = kmalloc(size, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
83873+ buf = kmalloc(size, GFP_KERNEL | GFP_USERCOPY | __GFP_NORETRY | __GFP_NOWARN);
83874 if (!buf && size > PAGE_SIZE)
83875- buf = vmalloc(size);
83876+ buf = vmalloc_usercopy(size);
83877 return buf;
83878 }
83879
83880@@ -68,6 +70,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
83881 #ifdef CONFIG_USER_NS
83882 p->user_ns = file->f_cred->user_ns;
83883 #endif
83884+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83885+ p->exec_id = current->exec_id;
83886+#endif
83887
83888 /*
83889 * Wrappers around seq_open(e.g. swaps_open) need to be
83890@@ -90,6 +95,16 @@ int seq_open(struct file *file, const struct seq_operations *op)
83891 }
83892 EXPORT_SYMBOL(seq_open);
83893
83894+
83895+int seq_open_restrict(struct file *file, const struct seq_operations *op)
83896+{
83897+ if (gr_proc_is_restricted())
83898+ return -EACCES;
83899+
83900+ return seq_open(file, op);
83901+}
83902+EXPORT_SYMBOL(seq_open_restrict);
83903+
83904 static int traverse(struct seq_file *m, loff_t offset)
83905 {
83906 loff_t pos = 0, index;
83907@@ -161,7 +176,7 @@ Eoverflow:
83908 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
83909 {
83910 struct seq_file *m = file->private_data;
83911- size_t copied = 0;
83912+ ssize_t copied = 0;
83913 loff_t pos;
83914 size_t n;
83915 void *p;
83916@@ -575,7 +590,7 @@ static void single_stop(struct seq_file *p, void *v)
83917 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
83918 void *data)
83919 {
83920- struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
83921+ seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
83922 int res = -ENOMEM;
83923
83924 if (op) {
83925@@ -611,6 +626,17 @@ int single_open_size(struct file *file, int (*show)(struct seq_file *, void *),
83926 }
83927 EXPORT_SYMBOL(single_open_size);
83928
83929+int single_open_restrict(struct file *file, int (*show)(struct seq_file *, void *),
83930+ void *data)
83931+{
83932+ if (gr_proc_is_restricted())
83933+ return -EACCES;
83934+
83935+ return single_open(file, show, data);
83936+}
83937+EXPORT_SYMBOL(single_open_restrict);
83938+
83939+
83940 int single_release(struct inode *inode, struct file *file)
83941 {
83942 const struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
83943diff --git a/fs/splice.c b/fs/splice.c
83944index 5fc1e50..6ae8957 100644
83945--- a/fs/splice.c
83946+++ b/fs/splice.c
83947@@ -192,7 +192,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
83948 pipe_lock(pipe);
83949
83950 for (;;) {
83951- if (!pipe->readers) {
83952+ if (!atomic_read(&pipe->readers)) {
83953 send_sig(SIGPIPE, current, 0);
83954 if (!ret)
83955 ret = -EPIPE;
83956@@ -215,7 +215,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
83957 page_nr++;
83958 ret += buf->len;
83959
83960- if (pipe->files)
83961+ if (atomic_read(&pipe->files))
83962 do_wakeup = 1;
83963
83964 if (!--spd->nr_pages)
83965@@ -246,9 +246,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
83966 do_wakeup = 0;
83967 }
83968
83969- pipe->waiting_writers++;
83970+ atomic_inc(&pipe->waiting_writers);
83971 pipe_wait(pipe);
83972- pipe->waiting_writers--;
83973+ atomic_dec(&pipe->waiting_writers);
83974 }
83975
83976 pipe_unlock(pipe);
83977@@ -579,7 +579,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
83978 old_fs = get_fs();
83979 set_fs(get_ds());
83980 /* The cast to a user pointer is valid due to the set_fs() */
83981- res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
83982+ res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
83983 set_fs(old_fs);
83984
83985 return res;
83986@@ -594,7 +594,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
83987 old_fs = get_fs();
83988 set_fs(get_ds());
83989 /* The cast to a user pointer is valid due to the set_fs() */
83990- res = vfs_write(file, (__force const char __user *)buf, count, &pos);
83991+ res = vfs_write(file, (const char __force_user *)buf, count, &pos);
83992 set_fs(old_fs);
83993
83994 return res;
83995@@ -647,7 +647,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
83996 goto err;
83997
83998 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
83999- vec[i].iov_base = (void __user *) page_address(page);
84000+ vec[i].iov_base = (void __force_user *) page_address(page);
84001 vec[i].iov_len = this_len;
84002 spd.pages[i] = page;
84003 spd.nr_pages++;
84004@@ -786,7 +786,7 @@ static int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_des
84005 ops->release(pipe, buf);
84006 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
84007 pipe->nrbufs--;
84008- if (pipe->files)
84009+ if (atomic_read(&pipe->files))
84010 sd->need_wakeup = true;
84011 }
84012
84013@@ -810,10 +810,10 @@ static int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_des
84014 static int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
84015 {
84016 while (!pipe->nrbufs) {
84017- if (!pipe->writers)
84018+ if (!atomic_read(&pipe->writers))
84019 return 0;
84020
84021- if (!pipe->waiting_writers && sd->num_spliced)
84022+ if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
84023 return 0;
84024
84025 if (sd->flags & SPLICE_F_NONBLOCK)
84026@@ -1028,7 +1028,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
84027 ops->release(pipe, buf);
84028 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
84029 pipe->nrbufs--;
84030- if (pipe->files)
84031+ if (atomic_read(&pipe->files))
84032 sd.need_wakeup = true;
84033 } else {
84034 buf->offset += ret;
84035@@ -1188,7 +1188,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
84036 * out of the pipe right after the splice_to_pipe(). So set
84037 * PIPE_READERS appropriately.
84038 */
84039- pipe->readers = 1;
84040+ atomic_set(&pipe->readers, 1);
84041
84042 current->splice_pipe = pipe;
84043 }
84044@@ -1495,6 +1495,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
84045
84046 partial[buffers].offset = off;
84047 partial[buffers].len = plen;
84048+ partial[buffers].private = 0;
84049
84050 off = 0;
84051 len -= plen;
84052@@ -1726,9 +1727,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
84053 ret = -ERESTARTSYS;
84054 break;
84055 }
84056- if (!pipe->writers)
84057+ if (!atomic_read(&pipe->writers))
84058 break;
84059- if (!pipe->waiting_writers) {
84060+ if (!atomic_read(&pipe->waiting_writers)) {
84061 if (flags & SPLICE_F_NONBLOCK) {
84062 ret = -EAGAIN;
84063 break;
84064@@ -1760,7 +1761,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
84065 pipe_lock(pipe);
84066
84067 while (pipe->nrbufs >= pipe->buffers) {
84068- if (!pipe->readers) {
84069+ if (!atomic_read(&pipe->readers)) {
84070 send_sig(SIGPIPE, current, 0);
84071 ret = -EPIPE;
84072 break;
84073@@ -1773,9 +1774,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
84074 ret = -ERESTARTSYS;
84075 break;
84076 }
84077- pipe->waiting_writers++;
84078+ atomic_inc(&pipe->waiting_writers);
84079 pipe_wait(pipe);
84080- pipe->waiting_writers--;
84081+ atomic_dec(&pipe->waiting_writers);
84082 }
84083
84084 pipe_unlock(pipe);
84085@@ -1811,14 +1812,14 @@ retry:
84086 pipe_double_lock(ipipe, opipe);
84087
84088 do {
84089- if (!opipe->readers) {
84090+ if (!atomic_read(&opipe->readers)) {
84091 send_sig(SIGPIPE, current, 0);
84092 if (!ret)
84093 ret = -EPIPE;
84094 break;
84095 }
84096
84097- if (!ipipe->nrbufs && !ipipe->writers)
84098+ if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
84099 break;
84100
84101 /*
84102@@ -1915,7 +1916,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
84103 pipe_double_lock(ipipe, opipe);
84104
84105 do {
84106- if (!opipe->readers) {
84107+ if (!atomic_read(&opipe->readers)) {
84108 send_sig(SIGPIPE, current, 0);
84109 if (!ret)
84110 ret = -EPIPE;
84111@@ -1960,7 +1961,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
84112 * return EAGAIN if we have the potential of some data in the
84113 * future, otherwise just return 0
84114 */
84115- if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
84116+ if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
84117 ret = -EAGAIN;
84118
84119 pipe_unlock(ipipe);
84120diff --git a/fs/squashfs/xattr.c b/fs/squashfs/xattr.c
84121index e5e0ddf..09598c4 100644
84122--- a/fs/squashfs/xattr.c
84123+++ b/fs/squashfs/xattr.c
84124@@ -46,8 +46,8 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
84125 + msblk->xattr_table;
84126 int offset = SQUASHFS_XATTR_OFFSET(squashfs_i(inode)->xattr);
84127 int count = squashfs_i(inode)->xattr_count;
84128- size_t rest = buffer_size;
84129- int err;
84130+ size_t used = 0;
84131+ ssize_t err;
84132
84133 /* check that the file system has xattrs */
84134 if (msblk->xattr_id_table == NULL)
84135@@ -68,11 +68,11 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
84136 name_size = le16_to_cpu(entry.size);
84137 handler = squashfs_xattr_handler(le16_to_cpu(entry.type));
84138 if (handler)
84139- prefix_size = handler->list(d, buffer, rest, NULL,
84140+ prefix_size = handler->list(d, buffer, buffer ? buffer_size - used : 0, NULL,
84141 name_size, handler->flags);
84142 if (prefix_size) {
84143 if (buffer) {
84144- if (prefix_size + name_size + 1 > rest) {
84145+ if (prefix_size + name_size + 1 > buffer_size - used) {
84146 err = -ERANGE;
84147 goto failed;
84148 }
84149@@ -86,7 +86,7 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
84150 buffer[name_size] = '\0';
84151 buffer += name_size + 1;
84152 }
84153- rest -= prefix_size + name_size + 1;
84154+ used += prefix_size + name_size + 1;
84155 } else {
84156 /* no handler or insuffficient privileges, so skip */
84157 err = squashfs_read_metadata(sb, NULL, &start,
84158@@ -107,7 +107,7 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
84159 if (err < 0)
84160 goto failed;
84161 }
84162- err = buffer_size - rest;
84163+ err = used;
84164
84165 failed:
84166 return err;
84167diff --git a/fs/stat.c b/fs/stat.c
84168index cccc1aa..7fe8951 100644
84169--- a/fs/stat.c
84170+++ b/fs/stat.c
84171@@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
84172 stat->gid = inode->i_gid;
84173 stat->rdev = inode->i_rdev;
84174 stat->size = i_size_read(inode);
84175- stat->atime = inode->i_atime;
84176- stat->mtime = inode->i_mtime;
84177+ if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
84178+ stat->atime = inode->i_ctime;
84179+ stat->mtime = inode->i_ctime;
84180+ } else {
84181+ stat->atime = inode->i_atime;
84182+ stat->mtime = inode->i_mtime;
84183+ }
84184 stat->ctime = inode->i_ctime;
84185 stat->blksize = (1 << inode->i_blkbits);
84186 stat->blocks = inode->i_blocks;
84187@@ -52,9 +57,16 @@ EXPORT_SYMBOL(generic_fillattr);
84188 int vfs_getattr_nosec(struct path *path, struct kstat *stat)
84189 {
84190 struct inode *inode = d_backing_inode(path->dentry);
84191+ int retval;
84192
84193- if (inode->i_op->getattr)
84194- return inode->i_op->getattr(path->mnt, path->dentry, stat);
84195+ if (inode->i_op->getattr) {
84196+ retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
84197+ if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
84198+ stat->atime = stat->ctime;
84199+ stat->mtime = stat->ctime;
84200+ }
84201+ return retval;
84202+ }
84203
84204 generic_fillattr(inode, stat);
84205 return 0;
84206diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
84207index 94374e4..b5da3a1 100644
84208--- a/fs/sysfs/dir.c
84209+++ b/fs/sysfs/dir.c
84210@@ -33,6 +33,10 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
84211 kfree(buf);
84212 }
84213
84214+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
84215+extern int grsec_enable_sysfs_restrict;
84216+#endif
84217+
84218 /**
84219 * sysfs_create_dir_ns - create a directory for an object with a namespace tag
84220 * @kobj: object we're creating directory for
84221@@ -41,9 +45,16 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
84222 int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
84223 {
84224 struct kernfs_node *parent, *kn;
84225+ const char *name;
84226+ umode_t mode = S_IRWXU | S_IRUGO | S_IXUGO;
84227+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
84228+ const char *parent_name;
84229+#endif
84230
84231 BUG_ON(!kobj);
84232
84233+ name = kobject_name(kobj);
84234+
84235 if (kobj->parent)
84236 parent = kobj->parent->sd;
84237 else
84238@@ -52,11 +63,24 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
84239 if (!parent)
84240 return -ENOENT;
84241
84242- kn = kernfs_create_dir_ns(parent, kobject_name(kobj),
84243- S_IRWXU | S_IRUGO | S_IXUGO, kobj, ns);
84244+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
84245+ parent_name = parent->name;
84246+ mode = S_IRWXU;
84247+
84248+ if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
84249+ (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
84250+ (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
84251+ (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
84252+ mode = S_IRWXU | S_IRUGO | S_IXUGO;
84253+ if (!grsec_enable_sysfs_restrict)
84254+ mode = S_IRWXU | S_IRUGO | S_IXUGO;
84255+#endif
84256+
84257+ kn = kernfs_create_dir_ns(parent, name,
84258+ mode, kobj, ns);
84259 if (IS_ERR(kn)) {
84260 if (PTR_ERR(kn) == -EEXIST)
84261- sysfs_warn_dup(parent, kobject_name(kobj));
84262+ sysfs_warn_dup(parent, name);
84263 return PTR_ERR(kn);
84264 }
84265
84266diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
84267index 6c21228..9afd5fe 100644
84268--- a/fs/sysv/sysv.h
84269+++ b/fs/sysv/sysv.h
84270@@ -187,7 +187,7 @@ static inline u32 PDP_swab(u32 x)
84271 #endif
84272 }
84273
84274-static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
84275+static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
84276 {
84277 if (sbi->s_bytesex == BYTESEX_PDP)
84278 return PDP_swab((__force __u32)n);
84279diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
84280index cbc8d5d..56d2600 100644
84281--- a/fs/tracefs/inode.c
84282+++ b/fs/tracefs/inode.c
84283@@ -53,7 +53,7 @@ static const struct file_operations tracefs_file_operations = {
84284 static struct tracefs_dir_ops {
84285 int (*mkdir)(const char *name);
84286 int (*rmdir)(const char *name);
84287-} tracefs_ops;
84288+} __no_const tracefs_ops __read_only;
84289
84290 static char *get_dname(struct dentry *dentry)
84291 {
84292@@ -490,8 +490,10 @@ struct dentry *tracefs_create_instance_dir(const char *name, struct dentry *pare
84293 if (!dentry)
84294 return NULL;
84295
84296- tracefs_ops.mkdir = mkdir;
84297- tracefs_ops.rmdir = rmdir;
84298+ pax_open_kernel();
84299+ *(void **)&tracefs_ops.mkdir = mkdir;
84300+ *(void **)&tracefs_ops.rmdir = rmdir;
84301+ pax_close_kernel();
84302
84303 return dentry;
84304 }
84305diff --git a/fs/udf/misc.c b/fs/udf/misc.c
84306index 71d1c25..084e2ad 100644
84307--- a/fs/udf/misc.c
84308+++ b/fs/udf/misc.c
84309@@ -288,7 +288,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
84310
84311 u8 udf_tag_checksum(const struct tag *t)
84312 {
84313- u8 *data = (u8 *)t;
84314+ const u8 *data = (const u8 *)t;
84315 u8 checksum = 0;
84316 int i;
84317 for (i = 0; i < sizeof(struct tag); ++i)
84318diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
84319index 8d974c4..b82f6ec 100644
84320--- a/fs/ufs/swab.h
84321+++ b/fs/ufs/swab.h
84322@@ -22,7 +22,7 @@ enum {
84323 BYTESEX_BE
84324 };
84325
84326-static inline u64
84327+static inline u64 __intentional_overflow(-1)
84328 fs64_to_cpu(struct super_block *sbp, __fs64 n)
84329 {
84330 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
84331@@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
84332 return (__force __fs64)cpu_to_be64(n);
84333 }
84334
84335-static inline u32
84336+static inline u32 __intentional_overflow(-1)
84337 fs32_to_cpu(struct super_block *sbp, __fs32 n)
84338 {
84339 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
84340diff --git a/fs/utimes.c b/fs/utimes.c
84341index aa138d6..5f3a811 100644
84342--- a/fs/utimes.c
84343+++ b/fs/utimes.c
84344@@ -1,6 +1,7 @@
84345 #include <linux/compiler.h>
84346 #include <linux/file.h>
84347 #include <linux/fs.h>
84348+#include <linux/security.h>
84349 #include <linux/linkage.h>
84350 #include <linux/mount.h>
84351 #include <linux/namei.h>
84352@@ -103,6 +104,12 @@ static int utimes_common(struct path *path, struct timespec *times)
84353 }
84354 }
84355 retry_deleg:
84356+
84357+ if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
84358+ error = -EACCES;
84359+ goto mnt_drop_write_and_out;
84360+ }
84361+
84362 mutex_lock(&inode->i_mutex);
84363 error = notify_change(path->dentry, &newattrs, &delegated_inode);
84364 mutex_unlock(&inode->i_mutex);
84365diff --git a/fs/xattr.c b/fs/xattr.c
84366index 072fee1..9e497b0 100644
84367--- a/fs/xattr.c
84368+++ b/fs/xattr.c
84369@@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
84370 return rc;
84371 }
84372
84373+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84374+ssize_t
84375+pax_getxattr(struct dentry *dentry, void *value, size_t size)
84376+{
84377+ struct inode *inode = dentry->d_inode;
84378+ ssize_t error;
84379+
84380+ error = inode_permission(inode, MAY_EXEC);
84381+ if (error)
84382+ return error;
84383+
84384+ if (inode->i_op->getxattr)
84385+ error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
84386+ else
84387+ error = -EOPNOTSUPP;
84388+
84389+ return error;
84390+}
84391+EXPORT_SYMBOL(pax_getxattr);
84392+#endif
84393+
84394 ssize_t
84395 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
84396 {
84397@@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
84398 * Extended attribute SET operations
84399 */
84400 static long
84401-setxattr(struct dentry *d, const char __user *name, const void __user *value,
84402+setxattr(struct path *path, const char __user *name, const void __user *value,
84403 size_t size, int flags)
84404 {
84405 int error;
84406@@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
84407 posix_acl_fix_xattr_from_user(kvalue, size);
84408 }
84409
84410- error = vfs_setxattr(d, kname, kvalue, size, flags);
84411+ if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
84412+ error = -EACCES;
84413+ goto out;
84414+ }
84415+
84416+ error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
84417 out:
84418 if (vvalue)
84419 vfree(vvalue);
84420@@ -376,7 +402,7 @@ retry:
84421 return error;
84422 error = mnt_want_write(path.mnt);
84423 if (!error) {
84424- error = setxattr(path.dentry, name, value, size, flags);
84425+ error = setxattr(&path, name, value, size, flags);
84426 mnt_drop_write(path.mnt);
84427 }
84428 path_put(&path);
84429@@ -412,7 +438,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
84430 audit_file(f.file);
84431 error = mnt_want_write_file(f.file);
84432 if (!error) {
84433- error = setxattr(f.file->f_path.dentry, name, value, size, flags);
84434+ error = setxattr(&f.file->f_path, name, value, size, flags);
84435 mnt_drop_write_file(f.file);
84436 }
84437 fdput(f);
84438@@ -598,7 +624,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
84439 * Extended attribute REMOVE operations
84440 */
84441 static long
84442-removexattr(struct dentry *d, const char __user *name)
84443+removexattr(struct path *path, const char __user *name)
84444 {
84445 int error;
84446 char kname[XATTR_NAME_MAX + 1];
84447@@ -609,7 +635,10 @@ removexattr(struct dentry *d, const char __user *name)
84448 if (error < 0)
84449 return error;
84450
84451- return vfs_removexattr(d, kname);
84452+ if (!gr_acl_handle_removexattr(path->dentry, path->mnt))
84453+ return -EACCES;
84454+
84455+ return vfs_removexattr(path->dentry, kname);
84456 }
84457
84458 static int path_removexattr(const char __user *pathname,
84459@@ -623,7 +652,7 @@ retry:
84460 return error;
84461 error = mnt_want_write(path.mnt);
84462 if (!error) {
84463- error = removexattr(path.dentry, name);
84464+ error = removexattr(&path, name);
84465 mnt_drop_write(path.mnt);
84466 }
84467 path_put(&path);
84468@@ -649,14 +678,16 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
84469 SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
84470 {
84471 struct fd f = fdget(fd);
84472+ struct path *path;
84473 int error = -EBADF;
84474
84475 if (!f.file)
84476 return error;
84477+ path = &f.file->f_path;
84478 audit_file(f.file);
84479 error = mnt_want_write_file(f.file);
84480 if (!error) {
84481- error = removexattr(f.file->f_path.dentry, name);
84482+ error = removexattr(path, name);
84483 mnt_drop_write_file(f.file);
84484 }
84485 fdput(f);
84486diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
84487index 63e05b6..249b043 100644
84488--- a/fs/xfs/libxfs/xfs_bmap.c
84489+++ b/fs/xfs/libxfs/xfs_bmap.c
84490@@ -554,7 +554,7 @@ xfs_bmap_validate_ret(
84491
84492 #else
84493 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
84494-#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
84495+#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
84496 #endif /* DEBUG */
84497
84498 /*
84499diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
84500index 098cd78..724d3f8 100644
84501--- a/fs/xfs/xfs_dir2_readdir.c
84502+++ b/fs/xfs/xfs_dir2_readdir.c
84503@@ -140,7 +140,12 @@ xfs_dir2_sf_getdents(
84504 ino = dp->d_ops->sf_get_ino(sfp, sfep);
84505 filetype = dp->d_ops->sf_get_ftype(sfep);
84506 ctx->pos = off & 0x7fffffff;
84507- if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
84508+ if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
84509+ char name[sfep->namelen];
84510+ memcpy(name, sfep->name, sfep->namelen);
84511+ if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(dp->i_mount, filetype)))
84512+ return 0;
84513+ } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
84514 xfs_dir3_get_dtype(dp->i_mount, filetype)))
84515 return 0;
84516 sfep = dp->d_ops->sf_nextentry(sfp, sfep);
84517diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
84518index ea7d85a..6d4b24b 100644
84519--- a/fs/xfs/xfs_ioctl.c
84520+++ b/fs/xfs/xfs_ioctl.c
84521@@ -120,7 +120,7 @@ xfs_find_handle(
84522 }
84523
84524 error = -EFAULT;
84525- if (copy_to_user(hreq->ohandle, &handle, hsize) ||
84526+ if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
84527 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
84528 goto out_put;
84529
84530diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
84531index 85f883d..db6eecc 100644
84532--- a/fs/xfs/xfs_linux.h
84533+++ b/fs/xfs/xfs_linux.h
84534@@ -211,7 +211,7 @@ static inline kgid_t xfs_gid_to_kgid(__uint32_t gid)
84535 * of the compiler which do not like us using do_div in the middle
84536 * of large functions.
84537 */
84538-static inline __u32 xfs_do_div(void *a, __u32 b, int n)
84539+static inline __u32 __intentional_overflow(-1) xfs_do_div(void *a, __u32 b, int n)
84540 {
84541 __u32 mod;
84542
84543@@ -267,7 +267,7 @@ static inline __u32 xfs_do_mod(void *a, __u32 b, int n)
84544 return 0;
84545 }
84546 #else
84547-static inline __u32 xfs_do_div(void *a, __u32 b, int n)
84548+static inline __u32 __intentional_overflow(-1) xfs_do_div(void *a, __u32 b, int n)
84549 {
84550 __u32 mod;
84551
84552diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
84553new file mode 100644
84554index 0000000..31f8fe4
84555--- /dev/null
84556+++ b/grsecurity/Kconfig
84557@@ -0,0 +1,1182 @@
84558+#
84559+# grecurity configuration
84560+#
84561+menu "Memory Protections"
84562+depends on GRKERNSEC
84563+
84564+config GRKERNSEC_KMEM
84565+ bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
84566+ default y if GRKERNSEC_CONFIG_AUTO
84567+ select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
84568+ help
84569+ If you say Y here, /dev/kmem and /dev/mem won't be allowed to
84570+ be written to or read from to modify or leak the contents of the running
84571+ kernel. /dev/port will also not be allowed to be opened, writing to
84572+ /dev/cpu/*/msr will be prevented, and support for kexec will be removed.
84573+ If you have module support disabled, enabling this will close up several
84574+ ways that are currently used to insert malicious code into the running
84575+ kernel.
84576+
84577+ Even with this feature enabled, we still highly recommend that
84578+ you use the RBAC system, as it is still possible for an attacker to
84579+ modify the running kernel through other more obscure methods.
84580+
84581+ It is highly recommended that you say Y here if you meet all the
84582+ conditions above.
84583+
84584+config GRKERNSEC_VM86
84585+ bool "Restrict VM86 mode"
84586+ default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
84587+ depends on X86_32
84588+
84589+ help
84590+ If you say Y here, only processes with CAP_SYS_RAWIO will be able to
84591+ make use of a special execution mode on 32bit x86 processors called
84592+ Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
84593+ video cards and will still work with this option enabled. The purpose
84594+ of the option is to prevent exploitation of emulation errors in
84595+ virtualization of vm86 mode like the one discovered in VMWare in 2009.
84596+ Nearly all users should be able to enable this option.
84597+
84598+config GRKERNSEC_IO
84599+ bool "Disable privileged I/O"
84600+ default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
84601+ depends on X86
84602+ select RTC_CLASS
84603+ select RTC_INTF_DEV
84604+ select RTC_DRV_CMOS
84605+
84606+ help
84607+ If you say Y here, all ioperm and iopl calls will return an error.
84608+ Ioperm and iopl can be used to modify the running kernel.
84609+ Unfortunately, some programs need this access to operate properly,
84610+ the most notable of which are XFree86 and hwclock. hwclock can be
84611+ remedied by having RTC support in the kernel, so real-time
84612+ clock support is enabled if this option is enabled, to ensure
84613+ that hwclock operates correctly. If hwclock still does not work,
84614+ either update udev or symlink /dev/rtc to /dev/rtc0.
84615+
84616+ If you're using XFree86 or a version of Xorg from 2012 or earlier,
84617+ you may not be able to boot into a graphical environment with this
84618+ option enabled. In this case, you should use the RBAC system instead.
84619+
84620+config GRKERNSEC_BPF_HARDEN
84621+ bool "Harden BPF interpreter"
84622+ default y if GRKERNSEC_CONFIG_AUTO
84623+ help
84624+ Unlike previous versions of grsecurity that hardened both the BPF
84625+ interpreted code against corruption at rest as well as the JIT code
84626+ against JIT-spray attacks and attacker-controlled immediate values
84627+ for ROP, this feature will enforce disabling of the new eBPF JIT engine
84628+ and will ensure the interpreted code is read-only at rest. This feature
84629+ may be removed at a later time when eBPF stabilizes to entirely revert
84630+ back to the more secure pre-3.16 BPF interpreter/JIT.
84631+
84632+ If you're using KERNEXEC, it's recommended that you enable this option
84633+ to supplement the hardening of the kernel.
84634+
84635+config GRKERNSEC_PERF_HARDEN
84636+ bool "Disable unprivileged PERF_EVENTS usage by default"
84637+ default y if GRKERNSEC_CONFIG_AUTO
84638+ depends on PERF_EVENTS
84639+ help
84640+ If you say Y here, the range of acceptable values for the
84641+ /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
84642+ default to a new value: 3. When the sysctl is set to this value, no
84643+ unprivileged use of the PERF_EVENTS syscall interface will be permitted.
84644+
84645+ Though PERF_EVENTS can be used legitimately for performance monitoring
84646+ and low-level application profiling, it is forced on regardless of
84647+ configuration, has been at fault for several vulnerabilities, and
84648+ creates new opportunities for side channels and other information leaks.
84649+
84650+ This feature puts PERF_EVENTS into a secure default state and permits
84651+ the administrator to change out of it temporarily if unprivileged
84652+ application profiling is needed.
84653+
84654+config GRKERNSEC_RAND_THREADSTACK
84655+ bool "Insert random gaps between thread stacks"
84656+ default y if GRKERNSEC_CONFIG_AUTO
84657+ depends on PAX_RANDMMAP && !PPC
84658+ help
84659+ If you say Y here, a random-sized gap will be enforced between allocated
84660+ thread stacks. Glibc's NPTL and other threading libraries that
84661+ pass MAP_STACK to the kernel for thread stack allocation are supported.
84662+ The implementation currently provides 8 bits of entropy for the gap.
84663+
84664+ Many distributions do not compile threaded remote services with the
84665+ -fstack-check argument to GCC, causing the variable-sized stack-based
84666+ allocator, alloca(), to not probe the stack on allocation. This
84667+ permits an unbounded alloca() to skip over any guard page and potentially
84668+ modify another thread's stack reliably. An enforced random gap
84669+ reduces the reliability of such an attack and increases the chance
84670+ that such a read/write to another thread's stack instead lands in
84671+ an unmapped area, causing a crash and triggering grsecurity's
84672+ anti-bruteforcing logic.
84673+
84674+config GRKERNSEC_PROC_MEMMAP
84675+ bool "Harden ASLR against information leaks and entropy reduction"
84676+ default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
84677+ depends on PAX_NOEXEC || PAX_ASLR
84678+ help
84679+ If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
84680+ give no information about the addresses of its mappings if
84681+ PaX features that rely on random addresses are enabled on the task.
84682+ In addition to sanitizing this information and disabling other
84683+ dangerous sources of information, this option causes reads of sensitive
84684+ /proc/<pid> entries where the file descriptor was opened in a different
84685+ task than the one performing the read. Such attempts are logged.
84686+ This option also limits argv/env strings for suid/sgid binaries
84687+ to 512KB to prevent a complete exhaustion of the stack entropy provided
84688+ by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
84689+ binaries to prevent alternative mmap layouts from being abused.
84690+
84691+ If you use PaX it is essential that you say Y here as it closes up
84692+ several holes that make full ASLR useless locally.
84693+
84694+
84695+config GRKERNSEC_KSTACKOVERFLOW
84696+ bool "Prevent kernel stack overflows"
84697+ default y if GRKERNSEC_CONFIG_AUTO
84698+ depends on !IA64 && 64BIT
84699+ help
84700+ If you say Y here, the kernel's process stacks will be allocated
84701+ with vmalloc instead of the kernel's default allocator. This
84702+ introduces guard pages that in combination with the alloca checking
84703+ of the STACKLEAK feature prevents all forms of kernel process stack
84704+ overflow abuse. Note that this is different from kernel stack
84705+ buffer overflows.
84706+
84707+config GRKERNSEC_BRUTE
84708+ bool "Deter exploit bruteforcing"
84709+ default y if GRKERNSEC_CONFIG_AUTO
84710+ help
84711+ If you say Y here, attempts to bruteforce exploits against forking
84712+ daemons such as apache or sshd, as well as against suid/sgid binaries
84713+ will be deterred. When a child of a forking daemon is killed by PaX
84714+ or crashes due to an illegal instruction or other suspicious signal,
84715+ the parent process will be delayed 30 seconds upon every subsequent
84716+ fork until the administrator is able to assess the situation and
84717+ restart the daemon.
84718+ In the suid/sgid case, the attempt is logged, the user has all their
84719+ existing instances of the suid/sgid binary terminated and will
84720+ be unable to execute any suid/sgid binaries for 15 minutes.
84721+
84722+ It is recommended that you also enable signal logging in the auditing
84723+ section so that logs are generated when a process triggers a suspicious
84724+ signal.
84725+ If the sysctl option is enabled, a sysctl option with name
84726+ "deter_bruteforce" is created.
84727+
84728+config GRKERNSEC_MODHARDEN
84729+ bool "Harden module auto-loading"
84730+ default y if GRKERNSEC_CONFIG_AUTO
84731+ depends on MODULES
84732+ help
84733+ If you say Y here, module auto-loading in response to use of some
84734+ feature implemented by an unloaded module will be restricted to
84735+ root users. Enabling this option helps defend against attacks
84736+ by unprivileged users who abuse the auto-loading behavior to
84737+ cause a vulnerable module to load that is then exploited.
84738+
84739+ If this option prevents a legitimate use of auto-loading for a
84740+ non-root user, the administrator can execute modprobe manually
84741+ with the exact name of the module mentioned in the alert log.
84742+ Alternatively, the administrator can add the module to the list
84743+ of modules loaded at boot by modifying init scripts.
84744+
84745+ Modification of init scripts will most likely be needed on
84746+ Ubuntu servers with encrypted home directory support enabled,
84747+ as the first non-root user logging in will cause the ecb(aes),
84748+ ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
84749+
84750+config GRKERNSEC_HIDESYM
84751+ bool "Hide kernel symbols"
84752+ default y if GRKERNSEC_CONFIG_AUTO
84753+ select PAX_USERCOPY_SLABS
84754+ help
84755+ If you say Y here, getting information on loaded modules, and
84756+ displaying all kernel symbols through a syscall will be restricted
84757+ to users with CAP_SYS_MODULE. For software compatibility reasons,
84758+ /proc/kallsyms will be restricted to the root user. The RBAC
84759+ system can hide that entry even from root.
84760+
84761+ This option also prevents leaking of kernel addresses through
84762+ several /proc entries.
84763+
84764+ Note that this option is only effective provided the following
84765+ conditions are met:
84766+ 1) The kernel using grsecurity is not precompiled by some distribution
84767+ 2) You have also enabled GRKERNSEC_DMESG
84768+ 3) You are using the RBAC system and hiding other files such as your
84769+ kernel image and System.map. Alternatively, enabling this option
84770+ causes the permissions on /boot, /lib/modules, and the kernel
84771+ source directory to change at compile time to prevent
84772+ reading by non-root users.
84773+ If the above conditions are met, this option will aid in providing a
84774+ useful protection against local kernel exploitation of overflows
84775+ and arbitrary read/write vulnerabilities.
84776+
84777+ It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
84778+ in addition to this feature.
84779+
84780+config GRKERNSEC_RANDSTRUCT
84781+ bool "Randomize layout of sensitive kernel structures"
84782+ default y if GRKERNSEC_CONFIG_AUTO
84783+ select GRKERNSEC_HIDESYM
84784+ select MODVERSIONS if MODULES
84785+ help
84786+ If you say Y here, the layouts of a number of sensitive kernel
84787+ structures (task, fs, cred, etc) and all structures composed entirely
84788+ of function pointers (aka "ops" structs) will be randomized at compile-time.
84789+ This can introduce the requirement of an additional infoleak
84790+ vulnerability for exploits targeting these structure types.
84791+
84792+ Enabling this feature will introduce some performance impact, slightly
84793+ increase memory usage, and prevent the use of forensic tools like
84794+ Volatility against the system (unless the kernel source tree isn't
84795+ cleaned after kernel installation).
84796+
84797+ The seed used for compilation is located at tools/gcc/randomize_layout_seed.h.
84798+ It remains after a make clean to allow for external modules to be compiled
84799+ with the existing seed and will be removed by a make mrproper or
84800+ make distclean.
84801+
84802+ Note that the implementation requires gcc 4.6.4. or newer. You may need
84803+ to install the supporting headers explicitly in addition to the normal
84804+ gcc package.
84805+
84806+config GRKERNSEC_RANDSTRUCT_PERFORMANCE
84807+ bool "Use cacheline-aware structure randomization"
84808+ depends on GRKERNSEC_RANDSTRUCT
84809+ default y if GRKERNSEC_CONFIG_PRIORITY_PERF
84810+ help
84811+ If you say Y here, the RANDSTRUCT randomization will make a best effort
84812+ at restricting randomization to cacheline-sized groups of elements. It
84813+ will further not randomize bitfields in structures. This reduces the
84814+ performance hit of RANDSTRUCT at the cost of weakened randomization.
84815+
84816+config GRKERNSEC_KERN_LOCKOUT
84817+ bool "Active kernel exploit response"
84818+ default y if GRKERNSEC_CONFIG_AUTO
84819+ depends on X86 || ARM || PPC || SPARC
84820+ help
84821+ If you say Y here, when a PaX alert is triggered due to suspicious
84822+ activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
84823+ or an OOPS occurs due to bad memory accesses, instead of just
84824+ terminating the offending process (and potentially allowing
84825+ a subsequent exploit from the same user), we will take one of two
84826+ actions:
84827+ If the user was root, we will panic the system
84828+ If the user was non-root, we will log the attempt, terminate
84829+ all processes owned by the user, then prevent them from creating
84830+ any new processes until the system is restarted
84831+ This deters repeated kernel exploitation/bruteforcing attempts
84832+ and is useful for later forensics.
84833+
84834+config GRKERNSEC_OLD_ARM_USERLAND
84835+ bool "Old ARM userland compatibility"
84836+ depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
84837+ help
84838+ If you say Y here, stubs of executable code to perform such operations
84839+ as "compare-exchange" will be placed at fixed locations in the ARM vector
84840+ table. This is unfortunately needed for old ARM userland meant to run
84841+ across a wide range of processors. Without this option enabled,
84842+ the get_tls and data memory barrier stubs will be emulated by the kernel,
84843+ which is enough for Linaro userlands or other userlands designed for v6
84844+ and newer ARM CPUs. It's recommended that you try without this option enabled
84845+ first, and only enable it if your userland does not boot (it will likely fail
84846+ at init time).
84847+
84848+endmenu
84849+menu "Role Based Access Control Options"
84850+depends on GRKERNSEC
84851+
84852+config GRKERNSEC_RBAC_DEBUG
84853+ bool
84854+
84855+config GRKERNSEC_NO_RBAC
84856+ bool "Disable RBAC system"
84857+ help
84858+ If you say Y here, the /dev/grsec device will be removed from the kernel,
84859+ preventing the RBAC system from being enabled. You should only say Y
84860+ here if you have no intention of using the RBAC system, so as to prevent
84861+ an attacker with root access from misusing the RBAC system to hide files
84862+ and processes when loadable module support and /dev/[k]mem have been
84863+ locked down.
84864+
84865+config GRKERNSEC_ACL_HIDEKERN
84866+ bool "Hide kernel processes"
84867+ help
84868+ If you say Y here, all kernel threads will be hidden to all
84869+ processes but those whose subject has the "view hidden processes"
84870+ flag.
84871+
84872+config GRKERNSEC_ACL_MAXTRIES
84873+ int "Maximum tries before password lockout"
84874+ default 3
84875+ help
84876+ This option enforces the maximum number of times a user can attempt
84877+ to authorize themselves with the grsecurity RBAC system before being
84878+ denied the ability to attempt authorization again for a specified time.
84879+ The lower the number, the harder it will be to brute-force a password.
84880+
84881+config GRKERNSEC_ACL_TIMEOUT
84882+ int "Time to wait after max password tries, in seconds"
84883+ default 30
84884+ help
84885+ This option specifies the time the user must wait after attempting to
84886+ authorize to the RBAC system with the maximum number of invalid
84887+ passwords. The higher the number, the harder it will be to brute-force
84888+ a password.
84889+
84890+endmenu
84891+menu "Filesystem Protections"
84892+depends on GRKERNSEC
84893+
84894+config GRKERNSEC_PROC
84895+ bool "Proc restrictions"
84896+ default y if GRKERNSEC_CONFIG_AUTO
84897+ help
84898+ If you say Y here, the permissions of the /proc filesystem
84899+ will be altered to enhance system security and privacy. You MUST
84900+ choose either a user only restriction or a user and group restriction.
84901+ Depending upon the option you choose, you can either restrict users to
84902+ see only the processes they themselves run, or choose a group that can
84903+ view all processes and files normally restricted to root if you choose
84904+ the "restrict to user only" option. NOTE: If you're running identd or
84905+ ntpd as a non-root user, you will have to run it as the group you
84906+ specify here.
84907+
84908+config GRKERNSEC_PROC_USER
84909+ bool "Restrict /proc to user only"
84910+ depends on GRKERNSEC_PROC
84911+ help
84912+ If you say Y here, non-root users will only be able to view their own
84913+ processes, and restricts them from viewing network-related information,
84914+ and viewing kernel symbol and module information.
84915+
84916+config GRKERNSEC_PROC_USERGROUP
84917+ bool "Allow special group"
84918+ default y if GRKERNSEC_CONFIG_AUTO
84919+ depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
84920+ help
84921+ If you say Y here, you will be able to select a group that will be
84922+ able to view all processes and network-related information. If you've
84923+ enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
84924+ remain hidden. This option is useful if you want to run identd as
84925+ a non-root user. The group you select may also be chosen at boot time
84926+ via "grsec_proc_gid=" on the kernel commandline.
84927+
84928+config GRKERNSEC_PROC_GID
84929+ int "GID for special group"
84930+ depends on GRKERNSEC_PROC_USERGROUP
84931+ default 1001
84932+
84933+config GRKERNSEC_PROC_ADD
84934+ bool "Additional restrictions"
84935+ default y if GRKERNSEC_CONFIG_AUTO
84936+ depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
84937+ help
84938+ If you say Y here, additional restrictions will be placed on
84939+ /proc that keep normal users from viewing device information and
84940+ slabinfo information that could be useful for exploits.
84941+
84942+config GRKERNSEC_LINK
84943+ bool "Linking restrictions"
84944+ default y if GRKERNSEC_CONFIG_AUTO
84945+ help
84946+ If you say Y here, /tmp race exploits will be prevented, since users
84947+ will no longer be able to follow symlinks owned by other users in
84948+ world-writable +t directories (e.g. /tmp), unless the owner of the
84949+ symlink is the owner of the directory. users will also not be
84950+ able to hardlink to files they do not own. If the sysctl option is
84951+ enabled, a sysctl option with name "linking_restrictions" is created.
84952+
84953+config GRKERNSEC_SYMLINKOWN
84954+ bool "Kernel-enforced SymlinksIfOwnerMatch"
84955+ default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
84956+ help
84957+ Apache's SymlinksIfOwnerMatch option has an inherent race condition
84958+ that prevents it from being used as a security feature. As Apache
84959+ verifies the symlink by performing a stat() against the target of
84960+ the symlink before it is followed, an attacker can setup a symlink
84961+ to point to a same-owned file, then replace the symlink with one
84962+ that targets another user's file just after Apache "validates" the
84963+ symlink -- a classic TOCTOU race. If you say Y here, a complete,
84964+ race-free replacement for Apache's "SymlinksIfOwnerMatch" option
84965+ will be in place for the group you specify. If the sysctl option
84966+ is enabled, a sysctl option with name "enforce_symlinksifowner" is
84967+ created.
84968+
84969+config GRKERNSEC_SYMLINKOWN_GID
84970+ int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
84971+ depends on GRKERNSEC_SYMLINKOWN
84972+ default 1006
84973+ help
84974+ Setting this GID determines what group kernel-enforced
84975+ SymlinksIfOwnerMatch will be enabled for. If the sysctl option
84976+ is enabled, a sysctl option with name "symlinkown_gid" is created.
84977+
84978+config GRKERNSEC_FIFO
84979+ bool "FIFO restrictions"
84980+ default y if GRKERNSEC_CONFIG_AUTO
84981+ help
84982+ If you say Y here, users will not be able to write to FIFOs they don't
84983+ own in world-writable +t directories (e.g. /tmp), unless the owner of
84984+ the FIFO is the same owner of the directory it's held in. If the sysctl
84985+ option is enabled, a sysctl option with name "fifo_restrictions" is
84986+ created.
84987+
84988+config GRKERNSEC_SYSFS_RESTRICT
84989+ bool "Sysfs/debugfs restriction"
84990+ default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
84991+ depends on SYSFS
84992+ help
84993+ If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
84994+ any filesystem normally mounted under it (e.g. debugfs) will be
84995+ mostly accessible only by root. These filesystems generally provide access
84996+ to hardware and debug information that isn't appropriate for unprivileged
84997+ users of the system. Sysfs and debugfs have also become a large source
84998+ of new vulnerabilities, ranging from infoleaks to local compromise.
84999+ There has been very little oversight with an eye toward security involved
85000+ in adding new exporters of information to these filesystems, so their
85001+ use is discouraged.
85002+ For reasons of compatibility, a few directories have been whitelisted
85003+ for access by non-root users:
85004+ /sys/fs/selinux
85005+ /sys/fs/fuse
85006+ /sys/devices/system/cpu
85007+
85008+config GRKERNSEC_ROFS
85009+ bool "Runtime read-only mount protection"
85010+ depends on SYSCTL
85011+ help
85012+ If you say Y here, a sysctl option with name "romount_protect" will
85013+ be created. By setting this option to 1 at runtime, filesystems
85014+ will be protected in the following ways:
85015+ * No new writable mounts will be allowed
85016+ * Existing read-only mounts won't be able to be remounted read/write
85017+ * Write operations will be denied on all block devices
85018+ This option acts independently of grsec_lock: once it is set to 1,
85019+ it cannot be turned off. Therefore, please be mindful of the resulting
85020+ behavior if this option is enabled in an init script on a read-only
85021+ filesystem.
85022+ Also be aware that as with other root-focused features, GRKERNSEC_KMEM
85023+ and GRKERNSEC_IO should be enabled and module loading disabled via
85024+ config or at runtime.
85025+ This feature is mainly intended for secure embedded systems.
85026+
85027+
85028+config GRKERNSEC_DEVICE_SIDECHANNEL
85029+ bool "Eliminate stat/notify-based device sidechannels"
85030+ default y if GRKERNSEC_CONFIG_AUTO
85031+ help
85032+ If you say Y here, timing analyses on block or character
85033+ devices like /dev/ptmx using stat or inotify/dnotify/fanotify
85034+ will be thwarted for unprivileged users. If a process without
85035+ CAP_MKNOD stats such a device, the last access and last modify times
85036+ will match the device's create time. No access or modify events
85037+ will be triggered through inotify/dnotify/fanotify for such devices.
85038+ This feature will prevent attacks that may at a minimum
85039+ allow an attacker to determine the administrator's password length.
85040+
85041+config GRKERNSEC_CHROOT
85042+ bool "Chroot jail restrictions"
85043+ default y if GRKERNSEC_CONFIG_AUTO
85044+ help
85045+ If you say Y here, you will be able to choose several options that will
85046+ make breaking out of a chrooted jail much more difficult. If you
85047+ encounter no software incompatibilities with the following options, it
85048+ is recommended that you enable each one.
85049+
85050+ Note that the chroot restrictions are not intended to apply to "chroots"
85051+ to directories that are simple bind mounts of the global root filesystem.
85052+ For several other reasons, a user shouldn't expect any significant
85053+ security by performing such a chroot.
85054+
85055+config GRKERNSEC_CHROOT_MOUNT
85056+ bool "Deny mounts"
85057+ default y if GRKERNSEC_CONFIG_AUTO
85058+ depends on GRKERNSEC_CHROOT
85059+ help
85060+ If you say Y here, processes inside a chroot will not be able to
85061+ mount or remount filesystems. If the sysctl option is enabled, a
85062+ sysctl option with name "chroot_deny_mount" is created.
85063+
85064+config GRKERNSEC_CHROOT_DOUBLE
85065+ bool "Deny double-chroots"
85066+ default y if GRKERNSEC_CONFIG_AUTO
85067+ depends on GRKERNSEC_CHROOT
85068+ help
85069+ If you say Y here, processes inside a chroot will not be able to chroot
85070+ again outside the chroot. This is a widely used method of breaking
85071+ out of a chroot jail and should not be allowed. If the sysctl
85072+ option is enabled, a sysctl option with name
85073+ "chroot_deny_chroot" is created.
85074+
85075+config GRKERNSEC_CHROOT_PIVOT
85076+ bool "Deny pivot_root in chroot"
85077+ default y if GRKERNSEC_CONFIG_AUTO
85078+ depends on GRKERNSEC_CHROOT
85079+ help
85080+ If you say Y here, processes inside a chroot will not be able to use
85081+ a function called pivot_root() that was introduced in Linux 2.3.41. It
85082+ works similar to chroot in that it changes the root filesystem. This
85083+ function could be misused in a chrooted process to attempt to break out
85084+ of the chroot, and therefore should not be allowed. If the sysctl
85085+ option is enabled, a sysctl option with name "chroot_deny_pivot" is
85086+ created.
85087+
85088+config GRKERNSEC_CHROOT_CHDIR
85089+ bool "Enforce chdir(\"/\") on all chroots"
85090+ default y if GRKERNSEC_CONFIG_AUTO
85091+ depends on GRKERNSEC_CHROOT
85092+ help
85093+ If you say Y here, the current working directory of all newly-chrooted
85094+ applications will be set to the the root directory of the chroot.
85095+ The man page on chroot(2) states:
85096+ Note that this call does not change the current working
85097+ directory, so that `.' can be outside the tree rooted at
85098+ `/'. In particular, the super-user can escape from a
85099+ `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
85100+
85101+ It is recommended that you say Y here, since it's not known to break
85102+ any software. If the sysctl option is enabled, a sysctl option with
85103+ name "chroot_enforce_chdir" is created.
85104+
85105+config GRKERNSEC_CHROOT_CHMOD
85106+ bool "Deny (f)chmod +s"
85107+ default y if GRKERNSEC_CONFIG_AUTO
85108+ depends on GRKERNSEC_CHROOT
85109+ help
85110+ If you say Y here, processes inside a chroot will not be able to chmod
85111+ or fchmod files to make them have suid or sgid bits. This protects
85112+ against another published method of breaking a chroot. If the sysctl
85113+ option is enabled, a sysctl option with name "chroot_deny_chmod" is
85114+ created.
85115+
85116+config GRKERNSEC_CHROOT_FCHDIR
85117+ bool "Deny fchdir and fhandle out of chroot"
85118+ default y if GRKERNSEC_CONFIG_AUTO
85119+ depends on GRKERNSEC_CHROOT
85120+ help
85121+ If you say Y here, a well-known method of breaking chroots by fchdir'ing
85122+ to a file descriptor of the chrooting process that points to a directory
85123+ outside the filesystem will be stopped. Additionally, this option prevents
85124+ use of the recently-created syscall for opening files by a guessable "file
85125+ handle" inside a chroot. If the sysctl option is enabled, a sysctl option
85126+ with name "chroot_deny_fchdir" is created.
85127+
85128+config GRKERNSEC_CHROOT_MKNOD
85129+ bool "Deny mknod"
85130+ default y if GRKERNSEC_CONFIG_AUTO
85131+ depends on GRKERNSEC_CHROOT
85132+ help
85133+ If you say Y here, processes inside a chroot will not be allowed to
85134+ mknod. The problem with using mknod inside a chroot is that it
85135+ would allow an attacker to create a device entry that is the same
85136+ as one on the physical root of your system, which could range from
85137+ anything from the console device to a device for your harddrive (which
85138+ they could then use to wipe the drive or steal data). It is recommended
85139+ that you say Y here, unless you run into software incompatibilities.
85140+ If the sysctl option is enabled, a sysctl option with name
85141+ "chroot_deny_mknod" is created.
85142+
85143+config GRKERNSEC_CHROOT_SHMAT
85144+ bool "Deny shmat() out of chroot"
85145+ default y if GRKERNSEC_CONFIG_AUTO
85146+ depends on GRKERNSEC_CHROOT
85147+ help
85148+ If you say Y here, processes inside a chroot will not be able to attach
85149+ to shared memory segments that were created outside of the chroot jail.
85150+ It is recommended that you say Y here. If the sysctl option is enabled,
85151+ a sysctl option with name "chroot_deny_shmat" is created.
85152+
85153+config GRKERNSEC_CHROOT_UNIX
85154+ bool "Deny access to abstract AF_UNIX sockets out of chroot"
85155+ default y if GRKERNSEC_CONFIG_AUTO
85156+ depends on GRKERNSEC_CHROOT
85157+ help
85158+ If you say Y here, processes inside a chroot will not be able to
85159+ connect to abstract (meaning not belonging to a filesystem) Unix
85160+ domain sockets that were bound outside of a chroot. It is recommended
85161+ that you say Y here. If the sysctl option is enabled, a sysctl option
85162+ with name "chroot_deny_unix" is created.
85163+
85164+config GRKERNSEC_CHROOT_FINDTASK
85165+ bool "Protect outside processes"
85166+ default y if GRKERNSEC_CONFIG_AUTO
85167+ depends on GRKERNSEC_CHROOT
85168+ help
85169+ If you say Y here, processes inside a chroot will not be able to
85170+ kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
85171+ getsid, or view any process outside of the chroot. If the sysctl
85172+ option is enabled, a sysctl option with name "chroot_findtask" is
85173+ created.
85174+
85175+config GRKERNSEC_CHROOT_NICE
85176+ bool "Restrict priority changes"
85177+ default y if GRKERNSEC_CONFIG_AUTO
85178+ depends on GRKERNSEC_CHROOT
85179+ help
85180+ If you say Y here, processes inside a chroot will not be able to raise
85181+ the priority of processes in the chroot, or alter the priority of
85182+ processes outside the chroot. This provides more security than simply
85183+ removing CAP_SYS_NICE from the process' capability set. If the
85184+ sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
85185+ is created.
85186+
85187+config GRKERNSEC_CHROOT_SYSCTL
85188+ bool "Deny sysctl writes"
85189+ default y if GRKERNSEC_CONFIG_AUTO
85190+ depends on GRKERNSEC_CHROOT
85191+ help
85192+ If you say Y here, an attacker in a chroot will not be able to
85193+ write to sysctl entries, either by sysctl(2) or through a /proc
85194+ interface. It is strongly recommended that you say Y here. If the
85195+ sysctl option is enabled, a sysctl option with name
85196+ "chroot_deny_sysctl" is created.
85197+
85198+config GRKERNSEC_CHROOT_RENAME
85199+ bool "Deny bad renames"
85200+ default y if GRKERNSEC_CONFIG_AUTO
85201+ depends on GRKERNSEC_CHROOT
85202+ help
85203+ If you say Y here, an attacker in a chroot will not be able to
85204+ abuse the ability to create double chroots to break out of the
85205+ chroot by exploiting a race condition between a rename of a directory
85206+ within a chroot against an open of a symlink with relative path
85207+ components. This feature will likewise prevent an accomplice outside
85208+ a chroot from enabling a user inside the chroot to break out and make
85209+ use of their credentials on the global filesystem. Enabling this
85210+ feature is essential to prevent root users from breaking out of a
85211+ chroot. If the sysctl option is enabled, a sysctl option with name
85212+ "chroot_deny_bad_rename" is created.
85213+
85214+config GRKERNSEC_CHROOT_CAPS
85215+ bool "Capability restrictions"
85216+ default y if GRKERNSEC_CONFIG_AUTO
85217+ depends on GRKERNSEC_CHROOT
85218+ help
85219+ If you say Y here, the capabilities on all processes within a
85220+ chroot jail will be lowered to stop module insertion, raw i/o,
85221+ system and net admin tasks, rebooting the system, modifying immutable
85222+ files, modifying IPC owned by another, and changing the system time.
85223+ This is left an option because it can break some apps. Disable this
85224+ if your chrooted apps are having problems performing those kinds of
85225+ tasks. If the sysctl option is enabled, a sysctl option with
85226+ name "chroot_caps" is created.
85227+
85228+config GRKERNSEC_CHROOT_INITRD
85229+ bool "Exempt initrd tasks from restrictions"
85230+ default y if GRKERNSEC_CONFIG_AUTO
85231+ depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
85232+ help
85233+ If you say Y here, tasks started prior to init will be exempted from
85234+ grsecurity's chroot restrictions. This option is mainly meant to
85235+ resolve Plymouth's performing privileged operations unnecessarily
85236+ in a chroot.
85237+
85238+endmenu
85239+menu "Kernel Auditing"
85240+depends on GRKERNSEC
85241+
85242+config GRKERNSEC_AUDIT_GROUP
85243+ bool "Single group for auditing"
85244+ help
85245+ If you say Y here, the exec and chdir logging features will only operate
85246+ on a group you specify. This option is recommended if you only want to
85247+ watch certain users instead of having a large amount of logs from the
85248+ entire system. If the sysctl option is enabled, a sysctl option with
85249+ name "audit_group" is created.
85250+
85251+config GRKERNSEC_AUDIT_GID
85252+ int "GID for auditing"
85253+ depends on GRKERNSEC_AUDIT_GROUP
85254+ default 1007
85255+
85256+config GRKERNSEC_EXECLOG
85257+ bool "Exec logging"
85258+ help
85259+ If you say Y here, all execve() calls will be logged (since the
85260+ other exec*() calls are frontends to execve(), all execution
85261+ will be logged). Useful for shell-servers that like to keep track
85262+ of their users. If the sysctl option is enabled, a sysctl option with
85263+ name "exec_logging" is created.
85264+ WARNING: This option when enabled will produce a LOT of logs, especially
85265+ on an active system.
85266+
85267+config GRKERNSEC_RESLOG
85268+ bool "Resource logging"
85269+ default y if GRKERNSEC_CONFIG_AUTO
85270+ help
85271+ If you say Y here, all attempts to overstep resource limits will
85272+ be logged with the resource name, the requested size, and the current
85273+ limit. It is highly recommended that you say Y here. If the sysctl
85274+ option is enabled, a sysctl option with name "resource_logging" is
85275+ created. If the RBAC system is enabled, the sysctl value is ignored.
85276+
85277+config GRKERNSEC_CHROOT_EXECLOG
85278+ bool "Log execs within chroot"
85279+ help
85280+ If you say Y here, all executions inside a chroot jail will be logged
85281+ to syslog. This can cause a large amount of logs if certain
85282+ applications (eg. djb's daemontools) are installed on the system, and
85283+ is therefore left as an option. If the sysctl option is enabled, a
85284+ sysctl option with name "chroot_execlog" is created.
85285+
85286+config GRKERNSEC_AUDIT_PTRACE
85287+ bool "Ptrace logging"
85288+ help
85289+ If you say Y here, all attempts to attach to a process via ptrace
85290+ will be logged. If the sysctl option is enabled, a sysctl option
85291+ with name "audit_ptrace" is created.
85292+
85293+config GRKERNSEC_AUDIT_CHDIR
85294+ bool "Chdir logging"
85295+ help
85296+ If you say Y here, all chdir() calls will be logged. If the sysctl
85297+ option is enabled, a sysctl option with name "audit_chdir" is created.
85298+
85299+config GRKERNSEC_AUDIT_MOUNT
85300+ bool "(Un)Mount logging"
85301+ help
85302+ If you say Y here, all mounts and unmounts will be logged. If the
85303+ sysctl option is enabled, a sysctl option with name "audit_mount" is
85304+ created.
85305+
85306+config GRKERNSEC_SIGNAL
85307+ bool "Signal logging"
85308+ default y if GRKERNSEC_CONFIG_AUTO
85309+ help
85310+ If you say Y here, certain important signals will be logged, such as
85311+ SIGSEGV, which will as a result inform you of when a error in a program
85312+ occurred, which in some cases could mean a possible exploit attempt.
85313+ If the sysctl option is enabled, a sysctl option with name
85314+ "signal_logging" is created.
85315+
85316+config GRKERNSEC_FORKFAIL
85317+ bool "Fork failure logging"
85318+ help
85319+ If you say Y here, all failed fork() attempts will be logged.
85320+ This could suggest a fork bomb, or someone attempting to overstep
85321+ their process limit. If the sysctl option is enabled, a sysctl option
85322+ with name "forkfail_logging" is created.
85323+
85324+config GRKERNSEC_TIME
85325+ bool "Time change logging"
85326+ default y if GRKERNSEC_CONFIG_AUTO
85327+ help
85328+ If you say Y here, any changes of the system clock will be logged.
85329+ If the sysctl option is enabled, a sysctl option with name
85330+ "timechange_logging" is created.
85331+
85332+config GRKERNSEC_PROC_IPADDR
85333+ bool "/proc/<pid>/ipaddr support"
85334+ default y if GRKERNSEC_CONFIG_AUTO
85335+ help
85336+ If you say Y here, a new entry will be added to each /proc/<pid>
85337+ directory that contains the IP address of the person using the task.
85338+ The IP is carried across local TCP and AF_UNIX stream sockets.
85339+ This information can be useful for IDS/IPSes to perform remote response
85340+ to a local attack. The entry is readable by only the owner of the
85341+ process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
85342+ the RBAC system), and thus does not create privacy concerns.
85343+
85344+config GRKERNSEC_RWXMAP_LOG
85345+ bool 'Denied RWX mmap/mprotect logging'
85346+ default y if GRKERNSEC_CONFIG_AUTO
85347+ depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
85348+ help
85349+ If you say Y here, calls to mmap() and mprotect() with explicit
85350+ usage of PROT_WRITE and PROT_EXEC together will be logged when
85351+ denied by the PAX_MPROTECT feature. This feature will also
85352+ log other problematic scenarios that can occur when PAX_MPROTECT
85353+ is enabled on a binary, like textrels and PT_GNU_STACK. If the
85354+ sysctl option is enabled, a sysctl option with name "rwxmap_logging"
85355+ is created.
85356+
85357+endmenu
85358+
85359+menu "Executable Protections"
85360+depends on GRKERNSEC
85361+
85362+config GRKERNSEC_DMESG
85363+ bool "Dmesg(8) restriction"
85364+ default y if GRKERNSEC_CONFIG_AUTO
85365+ help
85366+ If you say Y here, non-root users will not be able to use dmesg(8)
85367+ to view the contents of the kernel's circular log buffer.
85368+ The kernel's log buffer often contains kernel addresses and other
85369+ identifying information useful to an attacker in fingerprinting a
85370+ system for a targeted exploit.
85371+ If the sysctl option is enabled, a sysctl option with name "dmesg" is
85372+ created.
85373+
85374+config GRKERNSEC_HARDEN_PTRACE
85375+ bool "Deter ptrace-based process snooping"
85376+ default y if GRKERNSEC_CONFIG_AUTO
85377+ help
85378+ If you say Y here, TTY sniffers and other malicious monitoring
85379+ programs implemented through ptrace will be defeated. If you
85380+ have been using the RBAC system, this option has already been
85381+ enabled for several years for all users, with the ability to make
85382+ fine-grained exceptions.
85383+
85384+ This option only affects the ability of non-root users to ptrace
85385+ processes that are not a descendent of the ptracing process.
85386+ This means that strace ./binary and gdb ./binary will still work,
85387+ but attaching to arbitrary processes will not. If the sysctl
85388+ option is enabled, a sysctl option with name "harden_ptrace" is
85389+ created.
85390+
85391+config GRKERNSEC_PTRACE_READEXEC
85392+ bool "Require read access to ptrace sensitive binaries"
85393+ default y if GRKERNSEC_CONFIG_AUTO
85394+ help
85395+ If you say Y here, unprivileged users will not be able to ptrace unreadable
85396+ binaries. This option is useful in environments that
85397+ remove the read bits (e.g. file mode 4711) from suid binaries to
85398+ prevent infoleaking of their contents. This option adds
85399+ consistency to the use of that file mode, as the binary could normally
85400+ be read out when run without privileges while ptracing.
85401+
85402+ If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
85403+ is created.
85404+
85405+config GRKERNSEC_SETXID
85406+ bool "Enforce consistent multithreaded privileges"
85407+ default y if GRKERNSEC_CONFIG_AUTO
85408+ depends on (X86 || SPARC64 || PPC || ARM || MIPS)
85409+ help
85410+ If you say Y here, a change from a root uid to a non-root uid
85411+ in a multithreaded application will cause the resulting uids,
85412+ gids, supplementary groups, and capabilities in that thread
85413+ to be propagated to the other threads of the process. In most
85414+ cases this is unnecessary, as glibc will emulate this behavior
85415+ on behalf of the application. Other libcs do not act in the
85416+ same way, allowing the other threads of the process to continue
85417+ running with root privileges. If the sysctl option is enabled,
85418+ a sysctl option with name "consistent_setxid" is created.
85419+
85420+config GRKERNSEC_HARDEN_IPC
85421+ bool "Disallow access to overly-permissive IPC objects"
85422+ default y if GRKERNSEC_CONFIG_AUTO
85423+ depends on SYSVIPC
85424+ help
85425+ If you say Y here, access to overly-permissive IPC objects (shared
85426+ memory, message queues, and semaphores) will be denied for processes
85427+ given the following criteria beyond normal permission checks:
85428+ 1) If the IPC object is world-accessible and the euid doesn't match
85429+ that of the creator or current uid for the IPC object
85430+ 2) If the IPC object is group-accessible and the egid doesn't
85431+ match that of the creator or current gid for the IPC object
85432+ It's a common error to grant too much permission to these objects,
85433+ with impact ranging from denial of service and information leaking to
85434+ privilege escalation. This feature was developed in response to
85435+ research by Tim Brown:
85436+ http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
85437+ who found hundreds of such insecure usages. Processes with
85438+ CAP_IPC_OWNER are still permitted to access these IPC objects.
85439+ If the sysctl option is enabled, a sysctl option with name
85440+ "harden_ipc" is created.
85441+
85442+config GRKERNSEC_TPE
85443+ bool "Trusted Path Execution (TPE)"
85444+ default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
85445+ help
85446+ If you say Y here, you will be able to choose a gid to add to the
85447+ supplementary groups of users you want to mark as "untrusted."
85448+ These users will not be able to execute any files that are not in
85449+ root-owned directories writable only by root. If the sysctl option
85450+ is enabled, a sysctl option with name "tpe" is created.
85451+
85452+config GRKERNSEC_TPE_ALL
85453+ bool "Partially restrict all non-root users"
85454+ depends on GRKERNSEC_TPE
85455+ help
85456+ If you say Y here, all non-root users will be covered under
85457+ a weaker TPE restriction. This is separate from, and in addition to,
85458+ the main TPE options that you have selected elsewhere. Thus, if a
85459+ "trusted" GID is chosen, this restriction applies to even that GID.
85460+ Under this restriction, all non-root users will only be allowed to
85461+ execute files in directories they own that are not group or
85462+ world-writable, or in directories owned by root and writable only by
85463+ root. If the sysctl option is enabled, a sysctl option with name
85464+ "tpe_restrict_all" is created.
85465+
85466+config GRKERNSEC_TPE_INVERT
85467+ bool "Invert GID option"
85468+ depends on GRKERNSEC_TPE
85469+ help
85470+ If you say Y here, the group you specify in the TPE configuration will
85471+ decide what group TPE restrictions will be *disabled* for. This
85472+ option is useful if you want TPE restrictions to be applied to most
85473+ users on the system. If the sysctl option is enabled, a sysctl option
85474+ with name "tpe_invert" is created. Unlike other sysctl options, this
85475+ entry will default to on for backward-compatibility.
85476+
85477+config GRKERNSEC_TPE_GID
85478+ int
85479+ default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
85480+ default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
85481+
85482+config GRKERNSEC_TPE_UNTRUSTED_GID
85483+ int "GID for TPE-untrusted users"
85484+ depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
85485+ default 1005
85486+ help
85487+ Setting this GID determines what group TPE restrictions will be
85488+ *enabled* for. If the sysctl option is enabled, a sysctl option
85489+ with name "tpe_gid" is created.
85490+
85491+config GRKERNSEC_TPE_TRUSTED_GID
85492+ int "GID for TPE-trusted users"
85493+ depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
85494+ default 1005
85495+ help
85496+ Setting this GID determines what group TPE restrictions will be
85497+ *disabled* for. If the sysctl option is enabled, a sysctl option
85498+ with name "tpe_gid" is created.
85499+
85500+endmenu
85501+menu "Network Protections"
85502+depends on GRKERNSEC
85503+
85504+config GRKERNSEC_BLACKHOLE
85505+ bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
85506+ default y if GRKERNSEC_CONFIG_AUTO
85507+ depends on NET
85508+ help
85509+ If you say Y here, neither TCP resets nor ICMP
85510+ destination-unreachable packets will be sent in response to packets
85511+ sent to ports for which no associated listening process exists.
85512+ It will also prevent the sending of ICMP protocol unreachable packets
85513+ in response to packets with unknown protocols.
85514+ This feature supports both IPV4 and IPV6 and exempts the
85515+ loopback interface from blackholing. Enabling this feature
85516+ makes a host more resilient to DoS attacks and reduces network
85517+ visibility against scanners.
85518+
85519+ The blackhole feature as-implemented is equivalent to the FreeBSD
85520+ blackhole feature, as it prevents RST responses to all packets, not
85521+ just SYNs. Under most application behavior this causes no
85522+ problems, but applications (like haproxy) may not close certain
85523+ connections in a way that cleanly terminates them on the remote
85524+ end, leaving the remote host in LAST_ACK state. Because of this
85525+ side-effect and to prevent intentional LAST_ACK DoSes, this
85526+ feature also adds automatic mitigation against such attacks.
85527+ The mitigation drastically reduces the amount of time a socket
85528+ can spend in LAST_ACK state. If you're using haproxy and not
85529+ all servers it connects to have this option enabled, consider
85530+ disabling this feature on the haproxy host.
85531+
85532+ If the sysctl option is enabled, two sysctl options with names
85533+ "ip_blackhole" and "lastack_retries" will be created.
85534+ While "ip_blackhole" takes the standard zero/non-zero on/off
85535+ toggle, "lastack_retries" uses the same kinds of values as
85536+ "tcp_retries1" and "tcp_retries2". The default value of 4
85537+ prevents a socket from lasting more than 45 seconds in LAST_ACK
85538+ state.
85539+
85540+config GRKERNSEC_NO_SIMULT_CONNECT
85541+ bool "Disable TCP Simultaneous Connect"
85542+ default y if GRKERNSEC_CONFIG_AUTO
85543+ depends on NET
85544+ help
85545+ If you say Y here, a feature by Willy Tarreau will be enabled that
85546+ removes a weakness in Linux's strict implementation of TCP that
85547+ allows two clients to connect to each other without either entering
85548+ a listening state. The weakness allows an attacker to easily prevent
85549+ a client from connecting to a known server provided the source port
85550+ for the connection is guessed correctly.
85551+
85552+ As the weakness could be used to prevent an antivirus or IPS from
85553+ fetching updates, or prevent an SSL gateway from fetching a CRL,
85554+ it should be eliminated by enabling this option. Though Linux is
85555+ one of few operating systems supporting simultaneous connect, it
85556+ has no legitimate use in practice and is rarely supported by firewalls.
85557+
85558+config GRKERNSEC_SOCKET
85559+ bool "Socket restrictions"
85560+ depends on NET
85561+ help
85562+ If you say Y here, you will be able to choose from several options.
85563+ If you assign a GID on your system and add it to the supplementary
85564+ groups of users you want to restrict socket access to, this patch
85565+ will perform up to three things, based on the option(s) you choose.
85566+
85567+config GRKERNSEC_SOCKET_ALL
85568+ bool "Deny any sockets to group"
85569+ depends on GRKERNSEC_SOCKET
85570+ help
85571+ If you say Y here, you will be able to choose a GID of whose users will
85572+ be unable to connect to other hosts from your machine or run server
85573+ applications from your machine. If the sysctl option is enabled, a
85574+ sysctl option with name "socket_all" is created.
85575+
85576+config GRKERNSEC_SOCKET_ALL_GID
85577+ int "GID to deny all sockets for"
85578+ depends on GRKERNSEC_SOCKET_ALL
85579+ default 1004
85580+ help
85581+ Here you can choose the GID to disable socket access for. Remember to
85582+ add the users you want socket access disabled for to the GID
85583+ specified here. If the sysctl option is enabled, a sysctl option
85584+ with name "socket_all_gid" is created.
85585+
85586+config GRKERNSEC_SOCKET_CLIENT
85587+ bool "Deny client sockets to group"
85588+ depends on GRKERNSEC_SOCKET
85589+ help
85590+ If you say Y here, you will be able to choose a GID of whose users will
85591+ be unable to connect to other hosts from your machine, but will be
85592+ able to run servers. If this option is enabled, all users in the group
85593+ you specify will have to use passive mode when initiating ftp transfers
85594+ from the shell on your machine. If the sysctl option is enabled, a
85595+ sysctl option with name "socket_client" is created.
85596+
85597+config GRKERNSEC_SOCKET_CLIENT_GID
85598+ int "GID to deny client sockets for"
85599+ depends on GRKERNSEC_SOCKET_CLIENT
85600+ default 1003
85601+ help
85602+ Here you can choose the GID to disable client socket access for.
85603+ Remember to add the users you want client socket access disabled for to
85604+ the GID specified here. If the sysctl option is enabled, a sysctl
85605+ option with name "socket_client_gid" is created.
85606+
85607+config GRKERNSEC_SOCKET_SERVER
85608+ bool "Deny server sockets to group"
85609+ depends on GRKERNSEC_SOCKET
85610+ help
85611+ If you say Y here, you will be able to choose a GID of whose users will
85612+ be unable to run server applications from your machine. If the sysctl
85613+ option is enabled, a sysctl option with name "socket_server" is created.
85614+
85615+config GRKERNSEC_SOCKET_SERVER_GID
85616+ int "GID to deny server sockets for"
85617+ depends on GRKERNSEC_SOCKET_SERVER
85618+ default 1002
85619+ help
85620+ Here you can choose the GID to disable server socket access for.
85621+ Remember to add the users you want server socket access disabled for to
85622+ the GID specified here. If the sysctl option is enabled, a sysctl
85623+ option with name "socket_server_gid" is created.
85624+
85625+endmenu
85626+
85627+menu "Physical Protections"
85628+depends on GRKERNSEC
85629+
85630+config GRKERNSEC_DENYUSB
85631+ bool "Deny new USB connections after toggle"
85632+ default y if GRKERNSEC_CONFIG_AUTO
85633+ depends on SYSCTL && USB_SUPPORT
85634+ help
85635+ If you say Y here, a new sysctl option with name "deny_new_usb"
85636+ will be created. Setting its value to 1 will prevent any new
85637+ USB devices from being recognized by the OS. Any attempted USB
85638+ device insertion will be logged. This option is intended to be
85639+ used against custom USB devices designed to exploit vulnerabilities
85640+ in various USB device drivers.
85641+
85642+ For greatest effectiveness, this sysctl should be set after any
85643+ relevant init scripts. This option is safe to enable in distros
85644+ as each user can choose whether or not to toggle the sysctl.
85645+
85646+config GRKERNSEC_DENYUSB_FORCE
85647+ bool "Reject all USB devices not connected at boot"
85648+ select USB
85649+ depends on GRKERNSEC_DENYUSB
85650+ help
85651+ If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
85652+ that doesn't involve a sysctl entry. This option should only be
85653+ enabled if you're sure you want to deny all new USB connections
85654+ at runtime and don't want to modify init scripts. This should not
85655+ be enabled by distros. It forces the core USB code to be built
85656+ into the kernel image so that all devices connected at boot time
85657+ can be recognized and new USB device connections can be prevented
85658+ prior to init running.
85659+
85660+endmenu
85661+
85662+menu "Sysctl Support"
85663+depends on GRKERNSEC && SYSCTL
85664+
85665+config GRKERNSEC_SYSCTL
85666+ bool "Sysctl support"
85667+ default y if GRKERNSEC_CONFIG_AUTO
85668+ help
85669+ If you say Y here, you will be able to change the options that
85670+ grsecurity runs with at bootup, without having to recompile your
85671+ kernel. You can echo values to files in /proc/sys/kernel/grsecurity
85672+ to enable (1) or disable (0) various features. All the sysctl entries
85673+ are mutable until the "grsec_lock" entry is set to a non-zero value.
85674+ All features enabled in the kernel configuration are disabled at boot
85675+ if you do not say Y to the "Turn on features by default" option.
85676+ All options should be set at startup, and the grsec_lock entry should
85677+ be set to a non-zero value after all the options are set.
85678+ *THIS IS EXTREMELY IMPORTANT*
85679+
85680+config GRKERNSEC_SYSCTL_DISTRO
85681+ bool "Extra sysctl support for distro makers (READ HELP)"
85682+ depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
85683+ help
85684+ If you say Y here, additional sysctl options will be created
85685+ for features that affect processes running as root. Therefore,
85686+ it is critical when using this option that the grsec_lock entry be
85687+ enabled after boot. Only distros with prebuilt kernel packages
85688+ with this option enabled that can ensure grsec_lock is enabled
85689+ after boot should use this option.
85690+ *Failure to set grsec_lock after boot makes all grsec features
85691+ this option covers useless*
85692+
85693+ Currently this option creates the following sysctl entries:
85694+ "Disable Privileged I/O": "disable_priv_io"
85695+
85696+config GRKERNSEC_SYSCTL_ON
85697+ bool "Turn on features by default"
85698+ default y if GRKERNSEC_CONFIG_AUTO
85699+ depends on GRKERNSEC_SYSCTL
85700+ help
85701+ If you say Y here, instead of having all features enabled in the
85702+ kernel configuration disabled at boot time, the features will be
85703+ enabled at boot time. It is recommended you say Y here unless
85704+ there is some reason you would want all sysctl-tunable features to
85705+ be disabled by default. As mentioned elsewhere, it is important
85706+ to enable the grsec_lock entry once you have finished modifying
85707+ the sysctl entries.
85708+
85709+endmenu
85710+menu "Logging Options"
85711+depends on GRKERNSEC
85712+
85713+config GRKERNSEC_FLOODTIME
85714+ int "Seconds in between log messages (minimum)"
85715+ default 10
85716+ help
85717+ This option allows you to enforce the number of seconds between
85718+ grsecurity log messages. The default should be suitable for most
85719+ people, however, if you choose to change it, choose a value small enough
85720+ to allow informative logs to be produced, but large enough to
85721+ prevent flooding.
85722+
85723+ Setting both this value and GRKERNSEC_FLOODBURST to 0 will disable
85724+ any rate limiting on grsecurity log messages.
85725+
85726+config GRKERNSEC_FLOODBURST
85727+ int "Number of messages in a burst (maximum)"
85728+ default 6
85729+ help
85730+ This option allows you to choose the maximum number of messages allowed
85731+ within the flood time interval you chose in a separate option. The
85732+ default should be suitable for most people, however if you find that
85733+ many of your logs are being interpreted as flooding, you may want to
85734+ raise this value.
85735+
85736+ Setting both this value and GRKERNSEC_FLOODTIME to 0 will disable
85737+ any rate limiting on grsecurity log messages.
85738+
85739+endmenu
85740diff --git a/grsecurity/Makefile b/grsecurity/Makefile
85741new file mode 100644
85742index 0000000..30ababb
85743--- /dev/null
85744+++ b/grsecurity/Makefile
85745@@ -0,0 +1,54 @@
85746+# grsecurity – access control and security hardening for Linux
85747+# All code in this directory and various hooks located throughout the Linux kernel are
85748+# Copyright (C) 2001-2014 Bradley Spengler, Open Source Security, Inc.
85749+# http://www.grsecurity.net spender@grsecurity.net
85750+#
85751+# This program is free software; you can redistribute it and/or
85752+# modify it under the terms of the GNU General Public License version 2
85753+# as published by the Free Software Foundation.
85754+#
85755+# This program is distributed in the hope that it will be useful,
85756+# but WITHOUT ANY WARRANTY; without even the implied warranty of
85757+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
85758+# GNU General Public License for more details.
85759+#
85760+# You should have received a copy of the GNU General Public License
85761+# along with this program; if not, write to the Free Software
85762+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
85763+
85764+KBUILD_CFLAGS += -Werror
85765+
85766+obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
85767+ grsec_mount.o grsec_sig.o grsec_sysctl.o \
85768+ grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
85769+ grsec_usb.o grsec_ipc.o grsec_proc.o
85770+
85771+obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
85772+ gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
85773+ gracl_learn.o grsec_log.o gracl_policy.o
85774+ifdef CONFIG_COMPAT
85775+obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
85776+endif
85777+
85778+obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
85779+
85780+ifdef CONFIG_NET
85781+obj-y += grsec_sock.o
85782+obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
85783+endif
85784+
85785+ifndef CONFIG_GRKERNSEC
85786+obj-y += grsec_disabled.o
85787+endif
85788+
85789+ifdef CONFIG_GRKERNSEC_HIDESYM
85790+extra-y := grsec_hidesym.o
85791+$(obj)/grsec_hidesym.o:
85792+ @-chmod -f 500 /boot
85793+ @-chmod -f 500 /lib/modules
85794+ @-chmod -f 500 /lib64/modules
85795+ @-chmod -f 500 /lib32/modules
85796+ @-chmod -f 700 .
85797+ @-chmod -f 700 $(objtree)
85798+ @echo ' grsec: protected kernel image paths'
85799+endif
85800diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
85801new file mode 100644
85802index 0000000..7ad630a
85803--- /dev/null
85804+++ b/grsecurity/gracl.c
85805@@ -0,0 +1,2757 @@
85806+#include <linux/kernel.h>
85807+#include <linux/module.h>
85808+#include <linux/sched.h>
85809+#include <linux/mm.h>
85810+#include <linux/file.h>
85811+#include <linux/fs.h>
85812+#include <linux/namei.h>
85813+#include <linux/mount.h>
85814+#include <linux/tty.h>
85815+#include <linux/proc_fs.h>
85816+#include <linux/lglock.h>
85817+#include <linux/slab.h>
85818+#include <linux/vmalloc.h>
85819+#include <linux/types.h>
85820+#include <linux/sysctl.h>
85821+#include <linux/netdevice.h>
85822+#include <linux/ptrace.h>
85823+#include <linux/gracl.h>
85824+#include <linux/gralloc.h>
85825+#include <linux/security.h>
85826+#include <linux/grinternal.h>
85827+#include <linux/pid_namespace.h>
85828+#include <linux/stop_machine.h>
85829+#include <linux/fdtable.h>
85830+#include <linux/percpu.h>
85831+#include <linux/lglock.h>
85832+#include <linux/hugetlb.h>
85833+#include <linux/posix-timers.h>
85834+#include <linux/prefetch.h>
85835+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
85836+#include <linux/magic.h>
85837+#include <linux/pagemap.h>
85838+#include "../fs/btrfs/async-thread.h"
85839+#include "../fs/btrfs/ctree.h"
85840+#include "../fs/btrfs/btrfs_inode.h"
85841+#endif
85842+#include "../fs/mount.h"
85843+
85844+#include <asm/uaccess.h>
85845+#include <asm/errno.h>
85846+#include <asm/mman.h>
85847+
85848+#define FOR_EACH_ROLE_START(role) \
85849+ role = running_polstate.role_list; \
85850+ while (role) {
85851+
85852+#define FOR_EACH_ROLE_END(role) \
85853+ role = role->prev; \
85854+ }
85855+
85856+extern struct path gr_real_root;
85857+
85858+static struct gr_policy_state running_polstate;
85859+struct gr_policy_state *polstate = &running_polstate;
85860+extern struct gr_alloc_state *current_alloc_state;
85861+
85862+extern char *gr_shared_page[4];
85863+DEFINE_RWLOCK(gr_inode_lock);
85864+
85865+static unsigned int gr_status __read_only = GR_STATUS_INIT;
85866+
85867+#ifdef CONFIG_NET
85868+extern struct vfsmount *sock_mnt;
85869+#endif
85870+
85871+extern struct vfsmount *pipe_mnt;
85872+extern struct vfsmount *shm_mnt;
85873+
85874+#ifdef CONFIG_HUGETLBFS
85875+extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
85876+#endif
85877+
85878+extern u16 acl_sp_role_value;
85879+extern struct acl_object_label *fakefs_obj_rw;
85880+extern struct acl_object_label *fakefs_obj_rwx;
85881+
85882+int gr_acl_is_enabled(void)
85883+{
85884+ return (gr_status & GR_READY);
85885+}
85886+
85887+void gr_enable_rbac_system(void)
85888+{
85889+ pax_open_kernel();
85890+ gr_status |= GR_READY;
85891+ pax_close_kernel();
85892+}
85893+
85894+int gr_rbac_disable(void *unused)
85895+{
85896+ pax_open_kernel();
85897+ gr_status &= ~GR_READY;
85898+ pax_close_kernel();
85899+
85900+ return 0;
85901+}
85902+
85903+static inline dev_t __get_dev(const struct dentry *dentry)
85904+{
85905+ struct dentry *ldentry = d_backing_dentry((struct dentry *)dentry);
85906+
85907+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
85908+ if (ldentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
85909+ return BTRFS_I(d_inode(ldentry))->root->anon_dev;
85910+ else
85911+#endif
85912+ return d_inode(ldentry)->i_sb->s_dev;
85913+}
85914+
85915+static inline u64 __get_ino(const struct dentry *dentry)
85916+{
85917+ struct dentry *ldentry = d_backing_dentry((struct dentry *)dentry);
85918+
85919+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
85920+ if (ldentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
85921+ return btrfs_ino(d_inode(dentry));
85922+ else
85923+#endif
85924+ return d_inode(ldentry)->i_ino;
85925+}
85926+
85927+dev_t gr_get_dev_from_dentry(struct dentry *dentry)
85928+{
85929+ return __get_dev(dentry);
85930+}
85931+
85932+u64 gr_get_ino_from_dentry(struct dentry *dentry)
85933+{
85934+ return __get_ino(dentry);
85935+}
85936+
85937+static char gr_task_roletype_to_char(struct task_struct *task)
85938+{
85939+ switch (task->role->roletype &
85940+ (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
85941+ GR_ROLE_SPECIAL)) {
85942+ case GR_ROLE_DEFAULT:
85943+ return 'D';
85944+ case GR_ROLE_USER:
85945+ return 'U';
85946+ case GR_ROLE_GROUP:
85947+ return 'G';
85948+ case GR_ROLE_SPECIAL:
85949+ return 'S';
85950+ }
85951+
85952+ return 'X';
85953+}
85954+
85955+char gr_roletype_to_char(void)
85956+{
85957+ return gr_task_roletype_to_char(current);
85958+}
85959+
85960+int
85961+gr_acl_tpe_check(void)
85962+{
85963+ if (unlikely(!(gr_status & GR_READY)))
85964+ return 0;
85965+ if (current->role->roletype & GR_ROLE_TPE)
85966+ return 1;
85967+ else
85968+ return 0;
85969+}
85970+
85971+int
85972+gr_handle_rawio(const struct inode *inode)
85973+{
85974+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
85975+ if (inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR)) &&
85976+ grsec_enable_chroot_caps && proc_is_chrooted(current) &&
85977+ !capable(CAP_SYS_RAWIO))
85978+ return 1;
85979+#endif
85980+ return 0;
85981+}
85982+
85983+int
85984+gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
85985+{
85986+ if (likely(lena != lenb))
85987+ return 0;
85988+
85989+ return !memcmp(a, b, lena);
85990+}
85991+
85992+static int prepend(char **buffer, int *buflen, const char *str, int namelen)
85993+{
85994+ *buflen -= namelen;
85995+ if (*buflen < 0)
85996+ return -ENAMETOOLONG;
85997+ *buffer -= namelen;
85998+ memcpy(*buffer, str, namelen);
85999+ return 0;
86000+}
86001+
86002+static int prepend_name(char **buffer, int *buflen, struct qstr *name)
86003+{
86004+ return prepend(buffer, buflen, name->name, name->len);
86005+}
86006+
86007+static int prepend_path(const struct path *path, struct path *root,
86008+ char **buffer, int *buflen)
86009+{
86010+ struct dentry *dentry = path->dentry;
86011+ struct vfsmount *vfsmnt = path->mnt;
86012+ struct mount *mnt = real_mount(vfsmnt);
86013+ bool slash = false;
86014+ int error = 0;
86015+
86016+ while (dentry != root->dentry || vfsmnt != root->mnt) {
86017+ struct dentry * parent;
86018+
86019+ if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
86020+ /* Global root? */
86021+ if (!mnt_has_parent(mnt)) {
86022+ goto out;
86023+ }
86024+ dentry = mnt->mnt_mountpoint;
86025+ mnt = mnt->mnt_parent;
86026+ vfsmnt = &mnt->mnt;
86027+ continue;
86028+ }
86029+ parent = dentry->d_parent;
86030+ prefetch(parent);
86031+ spin_lock(&dentry->d_lock);
86032+ error = prepend_name(buffer, buflen, &dentry->d_name);
86033+ spin_unlock(&dentry->d_lock);
86034+ if (!error)
86035+ error = prepend(buffer, buflen, "/", 1);
86036+ if (error)
86037+ break;
86038+
86039+ slash = true;
86040+ dentry = parent;
86041+ }
86042+
86043+out:
86044+ if (!error && !slash)
86045+ error = prepend(buffer, buflen, "/", 1);
86046+
86047+ return error;
86048+}
86049+
86050+/* this must be called with mount_lock and rename_lock held */
86051+
86052+static char *__our_d_path(const struct path *path, struct path *root,
86053+ char *buf, int buflen)
86054+{
86055+ char *res = buf + buflen;
86056+ int error;
86057+
86058+ prepend(&res, &buflen, "\0", 1);
86059+ error = prepend_path(path, root, &res, &buflen);
86060+ if (error)
86061+ return ERR_PTR(error);
86062+
86063+ return res;
86064+}
86065+
86066+static char *
86067+gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
86068+{
86069+ char *retval;
86070+
86071+ retval = __our_d_path(path, root, buf, buflen);
86072+ if (unlikely(IS_ERR(retval)))
86073+ retval = strcpy(buf, "<path too long>");
86074+ else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
86075+ retval[1] = '\0';
86076+
86077+ return retval;
86078+}
86079+
86080+static char *
86081+__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
86082+ char *buf, int buflen)
86083+{
86084+ struct path path;
86085+ char *res;
86086+
86087+ path.dentry = (struct dentry *)dentry;
86088+ path.mnt = (struct vfsmount *)vfsmnt;
86089+
86090+ /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
86091+ by the RBAC system */
86092+ res = gen_full_path(&path, &gr_real_root, buf, buflen);
86093+
86094+ return res;
86095+}
86096+
86097+static char *
86098+d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
86099+ char *buf, int buflen)
86100+{
86101+ char *res;
86102+ struct path path;
86103+ struct path root;
86104+ struct task_struct *reaper = init_pid_ns.child_reaper;
86105+
86106+ path.dentry = (struct dentry *)dentry;
86107+ path.mnt = (struct vfsmount *)vfsmnt;
86108+
86109+ /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
86110+ get_fs_root(reaper->fs, &root);
86111+
86112+ read_seqlock_excl(&mount_lock);
86113+ write_seqlock(&rename_lock);
86114+ res = gen_full_path(&path, &root, buf, buflen);
86115+ write_sequnlock(&rename_lock);
86116+ read_sequnlock_excl(&mount_lock);
86117+
86118+ path_put(&root);
86119+ return res;
86120+}
86121+
86122+char *
86123+gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
86124+{
86125+ char *ret;
86126+ read_seqlock_excl(&mount_lock);
86127+ write_seqlock(&rename_lock);
86128+ ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
86129+ PAGE_SIZE);
86130+ write_sequnlock(&rename_lock);
86131+ read_sequnlock_excl(&mount_lock);
86132+ return ret;
86133+}
86134+
86135+static char *
86136+gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
86137+{
86138+ char *ret;
86139+ char *buf;
86140+ int buflen;
86141+
86142+ read_seqlock_excl(&mount_lock);
86143+ write_seqlock(&rename_lock);
86144+ buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
86145+ ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
86146+ buflen = (int)(ret - buf);
86147+ if (buflen >= 5)
86148+ prepend(&ret, &buflen, "/proc", 5);
86149+ else
86150+ ret = strcpy(buf, "<path too long>");
86151+ write_sequnlock(&rename_lock);
86152+ read_sequnlock_excl(&mount_lock);
86153+ return ret;
86154+}
86155+
86156+char *
86157+gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
86158+{
86159+ return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
86160+ PAGE_SIZE);
86161+}
86162+
86163+char *
86164+gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
86165+{
86166+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
86167+ PAGE_SIZE);
86168+}
86169+
86170+char *
86171+gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
86172+{
86173+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
86174+ PAGE_SIZE);
86175+}
86176+
86177+char *
86178+gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
86179+{
86180+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
86181+ PAGE_SIZE);
86182+}
86183+
86184+char *
86185+gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
86186+{
86187+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
86188+ PAGE_SIZE);
86189+}
86190+
86191+__u32
86192+to_gr_audit(const __u32 reqmode)
86193+{
86194+ /* masks off auditable permission flags, then shifts them to create
86195+ auditing flags, and adds the special case of append auditing if
86196+ we're requesting write */
86197+ return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
86198+}
86199+
86200+struct acl_role_label *
86201+__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
86202+ const gid_t gid)
86203+{
86204+ unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
86205+ struct acl_role_label *match;
86206+ struct role_allowed_ip *ipp;
86207+ unsigned int x;
86208+ u32 curr_ip = task->signal->saved_ip;
86209+
86210+ match = state->acl_role_set.r_hash[index];
86211+
86212+ while (match) {
86213+ if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
86214+ for (x = 0; x < match->domain_child_num; x++) {
86215+ if (match->domain_children[x] == uid)
86216+ goto found;
86217+ }
86218+ } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
86219+ break;
86220+ match = match->next;
86221+ }
86222+found:
86223+ if (match == NULL) {
86224+ try_group:
86225+ index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
86226+ match = state->acl_role_set.r_hash[index];
86227+
86228+ while (match) {
86229+ if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
86230+ for (x = 0; x < match->domain_child_num; x++) {
86231+ if (match->domain_children[x] == gid)
86232+ goto found2;
86233+ }
86234+ } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
86235+ break;
86236+ match = match->next;
86237+ }
86238+found2:
86239+ if (match == NULL)
86240+ match = state->default_role;
86241+ if (match->allowed_ips == NULL)
86242+ return match;
86243+ else {
86244+ for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
86245+ if (likely
86246+ ((ntohl(curr_ip) & ipp->netmask) ==
86247+ (ntohl(ipp->addr) & ipp->netmask)))
86248+ return match;
86249+ }
86250+ match = state->default_role;
86251+ }
86252+ } else if (match->allowed_ips == NULL) {
86253+ return match;
86254+ } else {
86255+ for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
86256+ if (likely
86257+ ((ntohl(curr_ip) & ipp->netmask) ==
86258+ (ntohl(ipp->addr) & ipp->netmask)))
86259+ return match;
86260+ }
86261+ goto try_group;
86262+ }
86263+
86264+ return match;
86265+}
86266+
86267+static struct acl_role_label *
86268+lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
86269+ const gid_t gid)
86270+{
86271+ return __lookup_acl_role_label(&running_polstate, task, uid, gid);
86272+}
86273+
86274+struct acl_subject_label *
86275+lookup_acl_subj_label(const u64 ino, const dev_t dev,
86276+ const struct acl_role_label *role)
86277+{
86278+ unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
86279+ struct acl_subject_label *match;
86280+
86281+ match = role->subj_hash[index];
86282+
86283+ while (match && (match->inode != ino || match->device != dev ||
86284+ (match->mode & GR_DELETED))) {
86285+ match = match->next;
86286+ }
86287+
86288+ if (match && !(match->mode & GR_DELETED))
86289+ return match;
86290+ else
86291+ return NULL;
86292+}
86293+
86294+struct acl_subject_label *
86295+lookup_acl_subj_label_deleted(const u64 ino, const dev_t dev,
86296+ const struct acl_role_label *role)
86297+{
86298+ unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
86299+ struct acl_subject_label *match;
86300+
86301+ match = role->subj_hash[index];
86302+
86303+ while (match && (match->inode != ino || match->device != dev ||
86304+ !(match->mode & GR_DELETED))) {
86305+ match = match->next;
86306+ }
86307+
86308+ if (match && (match->mode & GR_DELETED))
86309+ return match;
86310+ else
86311+ return NULL;
86312+}
86313+
86314+static struct acl_object_label *
86315+lookup_acl_obj_label(const u64 ino, const dev_t dev,
86316+ const struct acl_subject_label *subj)
86317+{
86318+ unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
86319+ struct acl_object_label *match;
86320+
86321+ match = subj->obj_hash[index];
86322+
86323+ while (match && (match->inode != ino || match->device != dev ||
86324+ (match->mode & GR_DELETED))) {
86325+ match = match->next;
86326+ }
86327+
86328+ if (match && !(match->mode & GR_DELETED))
86329+ return match;
86330+ else
86331+ return NULL;
86332+}
86333+
86334+static struct acl_object_label *
86335+lookup_acl_obj_label_create(const u64 ino, const dev_t dev,
86336+ const struct acl_subject_label *subj)
86337+{
86338+ unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
86339+ struct acl_object_label *match;
86340+
86341+ match = subj->obj_hash[index];
86342+
86343+ while (match && (match->inode != ino || match->device != dev ||
86344+ !(match->mode & GR_DELETED))) {
86345+ match = match->next;
86346+ }
86347+
86348+ if (match && (match->mode & GR_DELETED))
86349+ return match;
86350+
86351+ match = subj->obj_hash[index];
86352+
86353+ while (match && (match->inode != ino || match->device != dev ||
86354+ (match->mode & GR_DELETED))) {
86355+ match = match->next;
86356+ }
86357+
86358+ if (match && !(match->mode & GR_DELETED))
86359+ return match;
86360+ else
86361+ return NULL;
86362+}
86363+
86364+struct name_entry *
86365+__lookup_name_entry(const struct gr_policy_state *state, const char *name)
86366+{
86367+ unsigned int len = strlen(name);
86368+ unsigned int key = full_name_hash(name, len);
86369+ unsigned int index = key % state->name_set.n_size;
86370+ struct name_entry *match;
86371+
86372+ match = state->name_set.n_hash[index];
86373+
86374+ while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
86375+ match = match->next;
86376+
86377+ return match;
86378+}
86379+
86380+static struct name_entry *
86381+lookup_name_entry(const char *name)
86382+{
86383+ return __lookup_name_entry(&running_polstate, name);
86384+}
86385+
86386+static struct name_entry *
86387+lookup_name_entry_create(const char *name)
86388+{
86389+ unsigned int len = strlen(name);
86390+ unsigned int key = full_name_hash(name, len);
86391+ unsigned int index = key % running_polstate.name_set.n_size;
86392+ struct name_entry *match;
86393+
86394+ match = running_polstate.name_set.n_hash[index];
86395+
86396+ while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
86397+ !match->deleted))
86398+ match = match->next;
86399+
86400+ if (match && match->deleted)
86401+ return match;
86402+
86403+ match = running_polstate.name_set.n_hash[index];
86404+
86405+ while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
86406+ match->deleted))
86407+ match = match->next;
86408+
86409+ if (match && !match->deleted)
86410+ return match;
86411+ else
86412+ return NULL;
86413+}
86414+
86415+static struct inodev_entry *
86416+lookup_inodev_entry(const u64 ino, const dev_t dev)
86417+{
86418+ unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
86419+ struct inodev_entry *match;
86420+
86421+ match = running_polstate.inodev_set.i_hash[index];
86422+
86423+ while (match && (match->nentry->inode != ino || match->nentry->device != dev))
86424+ match = match->next;
86425+
86426+ return match;
86427+}
86428+
86429+void
86430+__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
86431+{
86432+ unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
86433+ state->inodev_set.i_size);
86434+ struct inodev_entry **curr;
86435+
86436+ entry->prev = NULL;
86437+
86438+ curr = &state->inodev_set.i_hash[index];
86439+ if (*curr != NULL)
86440+ (*curr)->prev = entry;
86441+
86442+ entry->next = *curr;
86443+ *curr = entry;
86444+
86445+ return;
86446+}
86447+
86448+static void
86449+insert_inodev_entry(struct inodev_entry *entry)
86450+{
86451+ __insert_inodev_entry(&running_polstate, entry);
86452+}
86453+
86454+void
86455+insert_acl_obj_label(struct acl_object_label *obj,
86456+ struct acl_subject_label *subj)
86457+{
86458+ unsigned int index =
86459+ gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
86460+ struct acl_object_label **curr;
86461+
86462+ obj->prev = NULL;
86463+
86464+ curr = &subj->obj_hash[index];
86465+ if (*curr != NULL)
86466+ (*curr)->prev = obj;
86467+
86468+ obj->next = *curr;
86469+ *curr = obj;
86470+
86471+ return;
86472+}
86473+
86474+void
86475+insert_acl_subj_label(struct acl_subject_label *obj,
86476+ struct acl_role_label *role)
86477+{
86478+ unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
86479+ struct acl_subject_label **curr;
86480+
86481+ obj->prev = NULL;
86482+
86483+ curr = &role->subj_hash[index];
86484+ if (*curr != NULL)
86485+ (*curr)->prev = obj;
86486+
86487+ obj->next = *curr;
86488+ *curr = obj;
86489+
86490+ return;
86491+}
86492+
86493+/* derived from glibc fnmatch() 0: match, 1: no match*/
86494+
86495+static int
86496+glob_match(const char *p, const char *n)
86497+{
86498+ char c;
86499+
86500+ while ((c = *p++) != '\0') {
86501+ switch (c) {
86502+ case '?':
86503+ if (*n == '\0')
86504+ return 1;
86505+ else if (*n == '/')
86506+ return 1;
86507+ break;
86508+ case '\\':
86509+ if (*n != c)
86510+ return 1;
86511+ break;
86512+ case '*':
86513+ for (c = *p++; c == '?' || c == '*'; c = *p++) {
86514+ if (*n == '/')
86515+ return 1;
86516+ else if (c == '?') {
86517+ if (*n == '\0')
86518+ return 1;
86519+ else
86520+ ++n;
86521+ }
86522+ }
86523+ if (c == '\0') {
86524+ return 0;
86525+ } else {
86526+ const char *endp;
86527+
86528+ if ((endp = strchr(n, '/')) == NULL)
86529+ endp = n + strlen(n);
86530+
86531+ if (c == '[') {
86532+ for (--p; n < endp; ++n)
86533+ if (!glob_match(p, n))
86534+ return 0;
86535+ } else if (c == '/') {
86536+ while (*n != '\0' && *n != '/')
86537+ ++n;
86538+ if (*n == '/' && !glob_match(p, n + 1))
86539+ return 0;
86540+ } else {
86541+ for (--p; n < endp; ++n)
86542+ if (*n == c && !glob_match(p, n))
86543+ return 0;
86544+ }
86545+
86546+ return 1;
86547+ }
86548+ case '[':
86549+ {
86550+ int not;
86551+ char cold;
86552+
86553+ if (*n == '\0' || *n == '/')
86554+ return 1;
86555+
86556+ not = (*p == '!' || *p == '^');
86557+ if (not)
86558+ ++p;
86559+
86560+ c = *p++;
86561+ for (;;) {
86562+ unsigned char fn = (unsigned char)*n;
86563+
86564+ if (c == '\0')
86565+ return 1;
86566+ else {
86567+ if (c == fn)
86568+ goto matched;
86569+ cold = c;
86570+ c = *p++;
86571+
86572+ if (c == '-' && *p != ']') {
86573+ unsigned char cend = *p++;
86574+
86575+ if (cend == '\0')
86576+ return 1;
86577+
86578+ if (cold <= fn && fn <= cend)
86579+ goto matched;
86580+
86581+ c = *p++;
86582+ }
86583+ }
86584+
86585+ if (c == ']')
86586+ break;
86587+ }
86588+ if (!not)
86589+ return 1;
86590+ break;
86591+ matched:
86592+ while (c != ']') {
86593+ if (c == '\0')
86594+ return 1;
86595+
86596+ c = *p++;
86597+ }
86598+ if (not)
86599+ return 1;
86600+ }
86601+ break;
86602+ default:
86603+ if (c != *n)
86604+ return 1;
86605+ }
86606+
86607+ ++n;
86608+ }
86609+
86610+ if (*n == '\0')
86611+ return 0;
86612+
86613+ if (*n == '/')
86614+ return 0;
86615+
86616+ return 1;
86617+}
86618+
86619+static struct acl_object_label *
86620+chk_glob_label(struct acl_object_label *globbed,
86621+ const struct dentry *dentry, const struct vfsmount *mnt, char **path)
86622+{
86623+ struct acl_object_label *tmp;
86624+
86625+ if (*path == NULL)
86626+ *path = gr_to_filename_nolock(dentry, mnt);
86627+
86628+ tmp = globbed;
86629+
86630+ while (tmp) {
86631+ if (!glob_match(tmp->filename, *path))
86632+ return tmp;
86633+ tmp = tmp->next;
86634+ }
86635+
86636+ return NULL;
86637+}
86638+
86639+static struct acl_object_label *
86640+__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
86641+ const u64 curr_ino, const dev_t curr_dev,
86642+ const struct acl_subject_label *subj, char **path, const int checkglob)
86643+{
86644+ struct acl_subject_label *tmpsubj;
86645+ struct acl_object_label *retval;
86646+ struct acl_object_label *retval2;
86647+
86648+ tmpsubj = (struct acl_subject_label *) subj;
86649+ read_lock(&gr_inode_lock);
86650+ do {
86651+ retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
86652+ if (retval) {
86653+ if (checkglob && retval->globbed) {
86654+ retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
86655+ if (retval2)
86656+ retval = retval2;
86657+ }
86658+ break;
86659+ }
86660+ } while ((tmpsubj = tmpsubj->parent_subject));
86661+ read_unlock(&gr_inode_lock);
86662+
86663+ return retval;
86664+}
86665+
86666+static struct acl_object_label *
86667+full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
86668+ struct dentry *curr_dentry,
86669+ const struct acl_subject_label *subj, char **path, const int checkglob)
86670+{
86671+ int newglob = checkglob;
86672+ u64 inode;
86673+ dev_t device;
86674+
86675+ /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
86676+ as we don't want a / * rule to match instead of the / object
86677+ don't do this for create lookups that call this function though, since they're looking up
86678+ on the parent and thus need globbing checks on all paths
86679+ */
86680+ if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
86681+ newglob = GR_NO_GLOB;
86682+
86683+ spin_lock(&curr_dentry->d_lock);
86684+ inode = __get_ino(curr_dentry);
86685+ device = __get_dev(curr_dentry);
86686+ spin_unlock(&curr_dentry->d_lock);
86687+
86688+ return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
86689+}
86690+
86691+#ifdef CONFIG_HUGETLBFS
86692+static inline bool
86693+is_hugetlbfs_mnt(const struct vfsmount *mnt)
86694+{
86695+ int i;
86696+ for (i = 0; i < HUGE_MAX_HSTATE; i++) {
86697+ if (unlikely(hugetlbfs_vfsmount[i] == mnt))
86698+ return true;
86699+ }
86700+
86701+ return false;
86702+}
86703+#endif
86704+
86705+static struct acl_object_label *
86706+__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86707+ const struct acl_subject_label *subj, char *path, const int checkglob)
86708+{
86709+ struct dentry *dentry = (struct dentry *) l_dentry;
86710+ struct vfsmount *mnt = (struct vfsmount *) l_mnt;
86711+ struct inode * inode = d_backing_inode(dentry);
86712+ struct mount *real_mnt = real_mount(mnt);
86713+ struct acl_object_label *retval;
86714+ struct dentry *parent;
86715+
86716+ read_seqlock_excl(&mount_lock);
86717+ write_seqlock(&rename_lock);
86718+
86719+ if (unlikely((mnt == shm_mnt && inode->i_nlink == 0) || mnt == pipe_mnt ||
86720+#ifdef CONFIG_NET
86721+ mnt == sock_mnt ||
86722+#endif
86723+#ifdef CONFIG_HUGETLBFS
86724+ (is_hugetlbfs_mnt(mnt) && inode->i_nlink == 0) ||
86725+#endif
86726+ /* ignore Eric Biederman */
86727+ IS_PRIVATE(inode))) {
86728+ retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
86729+ goto out;
86730+ }
86731+
86732+ for (;;) {
86733+ if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
86734+ break;
86735+
86736+ if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
86737+ if (!mnt_has_parent(real_mnt))
86738+ break;
86739+
86740+ retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
86741+ if (retval != NULL)
86742+ goto out;
86743+
86744+ dentry = real_mnt->mnt_mountpoint;
86745+ real_mnt = real_mnt->mnt_parent;
86746+ mnt = &real_mnt->mnt;
86747+ continue;
86748+ }
86749+
86750+ parent = dentry->d_parent;
86751+ retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
86752+ if (retval != NULL)
86753+ goto out;
86754+
86755+ dentry = parent;
86756+ }
86757+
86758+ retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
86759+
86760+ /* gr_real_root is pinned so we don't have to hold a reference */
86761+ if (retval == NULL)
86762+ retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
86763+out:
86764+ write_sequnlock(&rename_lock);
86765+ read_sequnlock_excl(&mount_lock);
86766+
86767+ BUG_ON(retval == NULL);
86768+
86769+ return retval;
86770+}
86771+
86772+static struct acl_object_label *
86773+chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86774+ const struct acl_subject_label *subj)
86775+{
86776+ char *path = NULL;
86777+ return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
86778+}
86779+
86780+static struct acl_object_label *
86781+chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86782+ const struct acl_subject_label *subj)
86783+{
86784+ char *path = NULL;
86785+ return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
86786+}
86787+
86788+static struct acl_object_label *
86789+chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86790+ const struct acl_subject_label *subj, char *path)
86791+{
86792+ return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
86793+}
86794+
86795+struct acl_subject_label *
86796+chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
86797+ const struct acl_role_label *role)
86798+{
86799+ struct dentry *dentry = (struct dentry *) l_dentry;
86800+ struct vfsmount *mnt = (struct vfsmount *) l_mnt;
86801+ struct mount *real_mnt = real_mount(mnt);
86802+ struct acl_subject_label *retval;
86803+ struct dentry *parent;
86804+
86805+ read_seqlock_excl(&mount_lock);
86806+ write_seqlock(&rename_lock);
86807+
86808+ for (;;) {
86809+ if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
86810+ break;
86811+ if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
86812+ if (!mnt_has_parent(real_mnt))
86813+ break;
86814+
86815+ spin_lock(&dentry->d_lock);
86816+ read_lock(&gr_inode_lock);
86817+ retval =
86818+ lookup_acl_subj_label(__get_ino(dentry),
86819+ __get_dev(dentry), role);
86820+ read_unlock(&gr_inode_lock);
86821+ spin_unlock(&dentry->d_lock);
86822+ if (retval != NULL)
86823+ goto out;
86824+
86825+ dentry = real_mnt->mnt_mountpoint;
86826+ real_mnt = real_mnt->mnt_parent;
86827+ mnt = &real_mnt->mnt;
86828+ continue;
86829+ }
86830+
86831+ spin_lock(&dentry->d_lock);
86832+ read_lock(&gr_inode_lock);
86833+ retval = lookup_acl_subj_label(__get_ino(dentry),
86834+ __get_dev(dentry), role);
86835+ read_unlock(&gr_inode_lock);
86836+ parent = dentry->d_parent;
86837+ spin_unlock(&dentry->d_lock);
86838+
86839+ if (retval != NULL)
86840+ goto out;
86841+
86842+ dentry = parent;
86843+ }
86844+
86845+ spin_lock(&dentry->d_lock);
86846+ read_lock(&gr_inode_lock);
86847+ retval = lookup_acl_subj_label(__get_ino(dentry),
86848+ __get_dev(dentry), role);
86849+ read_unlock(&gr_inode_lock);
86850+ spin_unlock(&dentry->d_lock);
86851+
86852+ if (unlikely(retval == NULL)) {
86853+ /* gr_real_root is pinned, we don't need to hold a reference */
86854+ read_lock(&gr_inode_lock);
86855+ retval = lookup_acl_subj_label(__get_ino(gr_real_root.dentry),
86856+ __get_dev(gr_real_root.dentry), role);
86857+ read_unlock(&gr_inode_lock);
86858+ }
86859+out:
86860+ write_sequnlock(&rename_lock);
86861+ read_sequnlock_excl(&mount_lock);
86862+
86863+ BUG_ON(retval == NULL);
86864+
86865+ return retval;
86866+}
86867+
86868+void
86869+assign_special_role(const char *rolename)
86870+{
86871+ struct acl_object_label *obj;
86872+ struct acl_role_label *r;
86873+ struct acl_role_label *assigned = NULL;
86874+ struct task_struct *tsk;
86875+ struct file *filp;
86876+
86877+ FOR_EACH_ROLE_START(r)
86878+ if (!strcmp(rolename, r->rolename) &&
86879+ (r->roletype & GR_ROLE_SPECIAL)) {
86880+ assigned = r;
86881+ break;
86882+ }
86883+ FOR_EACH_ROLE_END(r)
86884+
86885+ if (!assigned)
86886+ return;
86887+
86888+ read_lock(&tasklist_lock);
86889+ read_lock(&grsec_exec_file_lock);
86890+
86891+ tsk = current->real_parent;
86892+ if (tsk == NULL)
86893+ goto out_unlock;
86894+
86895+ filp = tsk->exec_file;
86896+ if (filp == NULL)
86897+ goto out_unlock;
86898+
86899+ tsk->is_writable = 0;
86900+ tsk->inherited = 0;
86901+
86902+ tsk->acl_sp_role = 1;
86903+ tsk->acl_role_id = ++acl_sp_role_value;
86904+ tsk->role = assigned;
86905+ tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
86906+
86907+ /* ignore additional mmap checks for processes that are writable
86908+ by the default ACL */
86909+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
86910+ if (unlikely(obj->mode & GR_WRITE))
86911+ tsk->is_writable = 1;
86912+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
86913+ if (unlikely(obj->mode & GR_WRITE))
86914+ tsk->is_writable = 1;
86915+
86916+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
86917+ printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
86918+ tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
86919+#endif
86920+
86921+out_unlock:
86922+ read_unlock(&grsec_exec_file_lock);
86923+ read_unlock(&tasklist_lock);
86924+ return;
86925+}
86926+
86927+
86928+static void
86929+gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
86930+{
86931+ struct task_struct *task = current;
86932+ const struct cred *cred = current_cred();
86933+
86934+ security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
86935+ GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
86936+ task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
86937+ 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
86938+
86939+ return;
86940+}
86941+
86942+static void
86943+gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
86944+{
86945+ struct task_struct *task = current;
86946+ const struct cred *cred = current_cred();
86947+
86948+ security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
86949+ GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
86950+ task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
86951+ 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
86952+
86953+ return;
86954+}
86955+
86956+static void
86957+gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
86958+{
86959+ struct task_struct *task = current;
86960+ const struct cred *cred = current_cred();
86961+
86962+ security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
86963+ GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
86964+ task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
86965+ 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
86966+
86967+ return;
86968+}
86969+
86970+static void
86971+gr_set_proc_res(struct task_struct *task)
86972+{
86973+ struct acl_subject_label *proc;
86974+ unsigned short i;
86975+
86976+ proc = task->acl;
86977+
86978+ if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
86979+ return;
86980+
86981+ for (i = 0; i < RLIM_NLIMITS; i++) {
86982+ unsigned long rlim_cur, rlim_max;
86983+
86984+ if (!(proc->resmask & (1U << i)))
86985+ continue;
86986+
86987+ rlim_cur = proc->res[i].rlim_cur;
86988+ rlim_max = proc->res[i].rlim_max;
86989+
86990+ if (i == RLIMIT_NOFILE) {
86991+ unsigned long saved_sysctl_nr_open = sysctl_nr_open;
86992+ if (rlim_cur > saved_sysctl_nr_open)
86993+ rlim_cur = saved_sysctl_nr_open;
86994+ if (rlim_max > saved_sysctl_nr_open)
86995+ rlim_max = saved_sysctl_nr_open;
86996+ }
86997+
86998+ task->signal->rlim[i].rlim_cur = rlim_cur;
86999+ task->signal->rlim[i].rlim_max = rlim_max;
87000+
87001+ if (i == RLIMIT_CPU)
87002+ update_rlimit_cpu(task, rlim_cur);
87003+ }
87004+
87005+ return;
87006+}
87007+
87008+/* both of the below must be called with
87009+ rcu_read_lock();
87010+ read_lock(&tasklist_lock);
87011+ read_lock(&grsec_exec_file_lock);
87012+ except in the case of gr_set_role_label() (for __gr_get_subject_for_task)
87013+*/
87014+
87015+struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename, int fallback)
87016+{
87017+ char *tmpname;
87018+ struct acl_subject_label *tmpsubj;
87019+ struct file *filp;
87020+ struct name_entry *nmatch;
87021+
87022+ filp = task->exec_file;
87023+ if (filp == NULL)
87024+ return NULL;
87025+
87026+ /* the following is to apply the correct subject
87027+ on binaries running when the RBAC system
87028+ is enabled, when the binaries have been
87029+ replaced or deleted since their execution
87030+ -----
87031+ when the RBAC system starts, the inode/dev
87032+ from exec_file will be one the RBAC system
87033+ is unaware of. It only knows the inode/dev
87034+ of the present file on disk, or the absence
87035+ of it.
87036+ */
87037+
87038+ if (filename)
87039+ nmatch = __lookup_name_entry(state, filename);
87040+ else {
87041+ preempt_disable();
87042+ tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
87043+
87044+ nmatch = __lookup_name_entry(state, tmpname);
87045+ preempt_enable();
87046+ }
87047+ tmpsubj = NULL;
87048+ if (nmatch) {
87049+ if (nmatch->deleted)
87050+ tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
87051+ else
87052+ tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
87053+ }
87054+ /* this also works for the reload case -- if we don't match a potentially inherited subject
87055+ then we fall back to a normal lookup based on the binary's ino/dev
87056+ */
87057+ if (tmpsubj == NULL && fallback)
87058+ tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, task->role);
87059+
87060+ return tmpsubj;
87061+}
87062+
87063+static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename, int fallback)
87064+{
87065+ return __gr_get_subject_for_task(&running_polstate, task, filename, fallback);
87066+}
87067+
87068+void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
87069+{
87070+ struct acl_object_label *obj;
87071+ struct file *filp;
87072+
87073+ filp = task->exec_file;
87074+
87075+ task->acl = subj;
87076+ task->is_writable = 0;
87077+ /* ignore additional mmap checks for processes that are writable
87078+ by the default ACL */
87079+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
87080+ if (unlikely(obj->mode & GR_WRITE))
87081+ task->is_writable = 1;
87082+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
87083+ if (unlikely(obj->mode & GR_WRITE))
87084+ task->is_writable = 1;
87085+
87086+ gr_set_proc_res(task);
87087+
87088+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
87089+ 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);
87090+#endif
87091+}
87092+
87093+static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
87094+{
87095+ __gr_apply_subject_to_task(&running_polstate, task, subj);
87096+}
87097+
87098+__u32
87099+gr_search_file(const struct dentry * dentry, const __u32 mode,
87100+ const struct vfsmount * mnt)
87101+{
87102+ __u32 retval = mode;
87103+ struct acl_subject_label *curracl;
87104+ struct acl_object_label *currobj;
87105+
87106+ if (unlikely(!(gr_status & GR_READY)))
87107+ return (mode & ~GR_AUDITS);
87108+
87109+ curracl = current->acl;
87110+
87111+ currobj = chk_obj_label(dentry, mnt, curracl);
87112+ retval = currobj->mode & mode;
87113+
87114+ /* if we're opening a specified transfer file for writing
87115+ (e.g. /dev/initctl), then transfer our role to init
87116+ */
87117+ if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
87118+ current->role->roletype & GR_ROLE_PERSIST)) {
87119+ struct task_struct *task = init_pid_ns.child_reaper;
87120+
87121+ if (task->role != current->role) {
87122+ struct acl_subject_label *subj;
87123+
87124+ task->acl_sp_role = 0;
87125+ task->acl_role_id = current->acl_role_id;
87126+ task->role = current->role;
87127+ rcu_read_lock();
87128+ read_lock(&grsec_exec_file_lock);
87129+ subj = gr_get_subject_for_task(task, NULL, 1);
87130+ gr_apply_subject_to_task(task, subj);
87131+ read_unlock(&grsec_exec_file_lock);
87132+ rcu_read_unlock();
87133+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
87134+ }
87135+ }
87136+
87137+ if (unlikely
87138+ ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
87139+ && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
87140+ __u32 new_mode = mode;
87141+
87142+ new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
87143+
87144+ retval = new_mode;
87145+
87146+ if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
87147+ new_mode |= GR_INHERIT;
87148+
87149+ if (!(mode & GR_NOLEARN))
87150+ gr_log_learn(dentry, mnt, new_mode);
87151+ }
87152+
87153+ return retval;
87154+}
87155+
87156+struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
87157+ const struct dentry *parent,
87158+ const struct vfsmount *mnt)
87159+{
87160+ struct name_entry *match;
87161+ struct acl_object_label *matchpo;
87162+ struct acl_subject_label *curracl;
87163+ char *path;
87164+
87165+ if (unlikely(!(gr_status & GR_READY)))
87166+ return NULL;
87167+
87168+ preempt_disable();
87169+ path = gr_to_filename_rbac(new_dentry, mnt);
87170+ match = lookup_name_entry_create(path);
87171+
87172+ curracl = current->acl;
87173+
87174+ if (match) {
87175+ read_lock(&gr_inode_lock);
87176+ matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
87177+ read_unlock(&gr_inode_lock);
87178+
87179+ if (matchpo) {
87180+ preempt_enable();
87181+ return matchpo;
87182+ }
87183+ }
87184+
87185+ // lookup parent
87186+
87187+ matchpo = chk_obj_create_label(parent, mnt, curracl, path);
87188+
87189+ preempt_enable();
87190+ return matchpo;
87191+}
87192+
87193+__u32
87194+gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
87195+ const struct vfsmount * mnt, const __u32 mode)
87196+{
87197+ struct acl_object_label *matchpo;
87198+ __u32 retval;
87199+
87200+ if (unlikely(!(gr_status & GR_READY)))
87201+ return (mode & ~GR_AUDITS);
87202+
87203+ matchpo = gr_get_create_object(new_dentry, parent, mnt);
87204+
87205+ retval = matchpo->mode & mode;
87206+
87207+ if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
87208+ && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
87209+ __u32 new_mode = mode;
87210+
87211+ new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
87212+
87213+ gr_log_learn(new_dentry, mnt, new_mode);
87214+ return new_mode;
87215+ }
87216+
87217+ return retval;
87218+}
87219+
87220+__u32
87221+gr_check_link(const struct dentry * new_dentry,
87222+ const struct dentry * parent_dentry,
87223+ const struct vfsmount * parent_mnt,
87224+ const struct dentry * old_dentry, const struct vfsmount * old_mnt)
87225+{
87226+ struct acl_object_label *obj;
87227+ __u32 oldmode, newmode;
87228+ __u32 needmode;
87229+ __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
87230+ GR_DELETE | GR_INHERIT;
87231+
87232+ if (unlikely(!(gr_status & GR_READY)))
87233+ return (GR_CREATE | GR_LINK);
87234+
87235+ obj = chk_obj_label(old_dentry, old_mnt, current->acl);
87236+ oldmode = obj->mode;
87237+
87238+ obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
87239+ newmode = obj->mode;
87240+
87241+ needmode = newmode & checkmodes;
87242+
87243+ // old name for hardlink must have at least the permissions of the new name
87244+ if ((oldmode & needmode) != needmode)
87245+ goto bad;
87246+
87247+ // if old name had restrictions/auditing, make sure the new name does as well
87248+ needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
87249+
87250+ // don't allow hardlinking of suid/sgid/fcapped files without permission
87251+ if (is_privileged_binary(old_dentry))
87252+ needmode |= GR_SETID;
87253+
87254+ if ((newmode & needmode) != needmode)
87255+ goto bad;
87256+
87257+ // enforce minimum permissions
87258+ if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
87259+ return newmode;
87260+bad:
87261+ needmode = oldmode;
87262+ if (is_privileged_binary(old_dentry))
87263+ needmode |= GR_SETID;
87264+
87265+ if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
87266+ gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
87267+ return (GR_CREATE | GR_LINK);
87268+ } else if (newmode & GR_SUPPRESS)
87269+ return GR_SUPPRESS;
87270+ else
87271+ return 0;
87272+}
87273+
87274+int
87275+gr_check_hidden_task(const struct task_struct *task)
87276+{
87277+ if (unlikely(!(gr_status & GR_READY)))
87278+ return 0;
87279+
87280+ if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
87281+ return 1;
87282+
87283+ return 0;
87284+}
87285+
87286+int
87287+gr_check_protected_task(const struct task_struct *task)
87288+{
87289+ if (unlikely(!(gr_status & GR_READY) || !task))
87290+ return 0;
87291+
87292+ if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
87293+ task->acl != current->acl)
87294+ return 1;
87295+
87296+ return 0;
87297+}
87298+
87299+int
87300+gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
87301+{
87302+ struct task_struct *p;
87303+ int ret = 0;
87304+
87305+ if (unlikely(!(gr_status & GR_READY) || !pid))
87306+ return ret;
87307+
87308+ read_lock(&tasklist_lock);
87309+ do_each_pid_task(pid, type, p) {
87310+ if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
87311+ p->acl != current->acl) {
87312+ ret = 1;
87313+ goto out;
87314+ }
87315+ } while_each_pid_task(pid, type, p);
87316+out:
87317+ read_unlock(&tasklist_lock);
87318+
87319+ return ret;
87320+}
87321+
87322+void
87323+gr_copy_label(struct task_struct *tsk)
87324+{
87325+ struct task_struct *p = current;
87326+
87327+ tsk->inherited = p->inherited;
87328+ tsk->acl_sp_role = 0;
87329+ tsk->acl_role_id = p->acl_role_id;
87330+ tsk->acl = p->acl;
87331+ tsk->role = p->role;
87332+ tsk->signal->used_accept = 0;
87333+ tsk->signal->curr_ip = p->signal->curr_ip;
87334+ tsk->signal->saved_ip = p->signal->saved_ip;
87335+ if (p->exec_file)
87336+ get_file(p->exec_file);
87337+ tsk->exec_file = p->exec_file;
87338+ tsk->is_writable = p->is_writable;
87339+ if (unlikely(p->signal->used_accept)) {
87340+ p->signal->curr_ip = 0;
87341+ p->signal->saved_ip = 0;
87342+ }
87343+
87344+ return;
87345+}
87346+
87347+extern int gr_process_kernel_setuid_ban(struct user_struct *user);
87348+
87349+int
87350+gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
87351+{
87352+ unsigned int i;
87353+ __u16 num;
87354+ uid_t *uidlist;
87355+ uid_t curuid;
87356+ int realok = 0;
87357+ int effectiveok = 0;
87358+ int fsok = 0;
87359+ uid_t globalreal, globaleffective, globalfs;
87360+
87361+#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
87362+ struct user_struct *user;
87363+
87364+ if (!uid_valid(real))
87365+ goto skipit;
87366+
87367+ /* find user based on global namespace */
87368+
87369+ globalreal = GR_GLOBAL_UID(real);
87370+
87371+ user = find_user(make_kuid(&init_user_ns, globalreal));
87372+ if (user == NULL)
87373+ goto skipit;
87374+
87375+ if (gr_process_kernel_setuid_ban(user)) {
87376+ /* for find_user */
87377+ free_uid(user);
87378+ return 1;
87379+ }
87380+
87381+ /* for find_user */
87382+ free_uid(user);
87383+
87384+skipit:
87385+#endif
87386+
87387+ if (unlikely(!(gr_status & GR_READY)))
87388+ return 0;
87389+
87390+ if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
87391+ gr_log_learn_uid_change(real, effective, fs);
87392+
87393+ num = current->acl->user_trans_num;
87394+ uidlist = current->acl->user_transitions;
87395+
87396+ if (uidlist == NULL)
87397+ return 0;
87398+
87399+ if (!uid_valid(real)) {
87400+ realok = 1;
87401+ globalreal = (uid_t)-1;
87402+ } else {
87403+ globalreal = GR_GLOBAL_UID(real);
87404+ }
87405+ if (!uid_valid(effective)) {
87406+ effectiveok = 1;
87407+ globaleffective = (uid_t)-1;
87408+ } else {
87409+ globaleffective = GR_GLOBAL_UID(effective);
87410+ }
87411+ if (!uid_valid(fs)) {
87412+ fsok = 1;
87413+ globalfs = (uid_t)-1;
87414+ } else {
87415+ globalfs = GR_GLOBAL_UID(fs);
87416+ }
87417+
87418+ if (current->acl->user_trans_type & GR_ID_ALLOW) {
87419+ for (i = 0; i < num; i++) {
87420+ curuid = uidlist[i];
87421+ if (globalreal == curuid)
87422+ realok = 1;
87423+ if (globaleffective == curuid)
87424+ effectiveok = 1;
87425+ if (globalfs == curuid)
87426+ fsok = 1;
87427+ }
87428+ } else if (current->acl->user_trans_type & GR_ID_DENY) {
87429+ for (i = 0; i < num; i++) {
87430+ curuid = uidlist[i];
87431+ if (globalreal == curuid)
87432+ break;
87433+ if (globaleffective == curuid)
87434+ break;
87435+ if (globalfs == curuid)
87436+ break;
87437+ }
87438+ /* not in deny list */
87439+ if (i == num) {
87440+ realok = 1;
87441+ effectiveok = 1;
87442+ fsok = 1;
87443+ }
87444+ }
87445+
87446+ if (realok && effectiveok && fsok)
87447+ return 0;
87448+ else {
87449+ gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
87450+ return 1;
87451+ }
87452+}
87453+
87454+int
87455+gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
87456+{
87457+ unsigned int i;
87458+ __u16 num;
87459+ gid_t *gidlist;
87460+ gid_t curgid;
87461+ int realok = 0;
87462+ int effectiveok = 0;
87463+ int fsok = 0;
87464+ gid_t globalreal, globaleffective, globalfs;
87465+
87466+ if (unlikely(!(gr_status & GR_READY)))
87467+ return 0;
87468+
87469+ if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
87470+ gr_log_learn_gid_change(real, effective, fs);
87471+
87472+ num = current->acl->group_trans_num;
87473+ gidlist = current->acl->group_transitions;
87474+
87475+ if (gidlist == NULL)
87476+ return 0;
87477+
87478+ if (!gid_valid(real)) {
87479+ realok = 1;
87480+ globalreal = (gid_t)-1;
87481+ } else {
87482+ globalreal = GR_GLOBAL_GID(real);
87483+ }
87484+ if (!gid_valid(effective)) {
87485+ effectiveok = 1;
87486+ globaleffective = (gid_t)-1;
87487+ } else {
87488+ globaleffective = GR_GLOBAL_GID(effective);
87489+ }
87490+ if (!gid_valid(fs)) {
87491+ fsok = 1;
87492+ globalfs = (gid_t)-1;
87493+ } else {
87494+ globalfs = GR_GLOBAL_GID(fs);
87495+ }
87496+
87497+ if (current->acl->group_trans_type & GR_ID_ALLOW) {
87498+ for (i = 0; i < num; i++) {
87499+ curgid = gidlist[i];
87500+ if (globalreal == curgid)
87501+ realok = 1;
87502+ if (globaleffective == curgid)
87503+ effectiveok = 1;
87504+ if (globalfs == curgid)
87505+ fsok = 1;
87506+ }
87507+ } else if (current->acl->group_trans_type & GR_ID_DENY) {
87508+ for (i = 0; i < num; i++) {
87509+ curgid = gidlist[i];
87510+ if (globalreal == curgid)
87511+ break;
87512+ if (globaleffective == curgid)
87513+ break;
87514+ if (globalfs == curgid)
87515+ break;
87516+ }
87517+ /* not in deny list */
87518+ if (i == num) {
87519+ realok = 1;
87520+ effectiveok = 1;
87521+ fsok = 1;
87522+ }
87523+ }
87524+
87525+ if (realok && effectiveok && fsok)
87526+ return 0;
87527+ else {
87528+ gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
87529+ return 1;
87530+ }
87531+}
87532+
87533+extern int gr_acl_is_capable(const int cap);
87534+
87535+void
87536+gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
87537+{
87538+ struct acl_role_label *role = task->role;
87539+ struct acl_role_label *origrole = role;
87540+ struct acl_subject_label *subj = NULL;
87541+ struct acl_object_label *obj;
87542+ struct file *filp;
87543+ uid_t uid;
87544+ gid_t gid;
87545+
87546+ if (unlikely(!(gr_status & GR_READY)))
87547+ return;
87548+
87549+ uid = GR_GLOBAL_UID(kuid);
87550+ gid = GR_GLOBAL_GID(kgid);
87551+
87552+ filp = task->exec_file;
87553+
87554+ /* kernel process, we'll give them the kernel role */
87555+ if (unlikely(!filp)) {
87556+ task->role = running_polstate.kernel_role;
87557+ task->acl = running_polstate.kernel_role->root_label;
87558+ return;
87559+ } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
87560+ /* save the current ip at time of role lookup so that the proper
87561+ IP will be learned for role_allowed_ip */
87562+ task->signal->saved_ip = task->signal->curr_ip;
87563+ role = lookup_acl_role_label(task, uid, gid);
87564+ }
87565+
87566+ /* don't change the role if we're not a privileged process */
87567+ if (role && task->role != role &&
87568+ (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
87569+ ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
87570+ return;
87571+
87572+ task->role = role;
87573+
87574+ if (task->inherited) {
87575+ /* if we reached our subject through inheritance, then first see
87576+ if there's a subject of the same name in the new role that has
87577+ an object that would result in the same inherited subject
87578+ */
87579+ subj = gr_get_subject_for_task(task, task->acl->filename, 0);
87580+ if (subj) {
87581+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, subj);
87582+ if (!(obj->mode & GR_INHERIT))
87583+ subj = NULL;
87584+ }
87585+
87586+ }
87587+ if (subj == NULL) {
87588+ /* otherwise:
87589+ perform subject lookup in possibly new role
87590+ we can use this result below in the case where role == task->role
87591+ */
87592+ subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
87593+ }
87594+
87595+ /* if we changed uid/gid, but result in the same role
87596+ and are using inheritance, don't lose the inherited subject
87597+ if current subject is other than what normal lookup
87598+ would result in, we arrived via inheritance, don't
87599+ lose subject
87600+ */
87601+ if (role != origrole || (!(task->acl->mode & GR_INHERITLEARN) &&
87602+ (subj == task->acl)))
87603+ task->acl = subj;
87604+
87605+ /* leave task->inherited unaffected */
87606+
87607+ task->is_writable = 0;
87608+
87609+ /* ignore additional mmap checks for processes that are writable
87610+ by the default ACL */
87611+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
87612+ if (unlikely(obj->mode & GR_WRITE))
87613+ task->is_writable = 1;
87614+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
87615+ if (unlikely(obj->mode & GR_WRITE))
87616+ task->is_writable = 1;
87617+
87618+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
87619+ 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);
87620+#endif
87621+
87622+ gr_set_proc_res(task);
87623+
87624+ return;
87625+}
87626+
87627+int
87628+gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
87629+ const int unsafe_flags)
87630+{
87631+ struct task_struct *task = current;
87632+ struct acl_subject_label *newacl;
87633+ struct acl_object_label *obj;
87634+ __u32 retmode;
87635+
87636+ if (unlikely(!(gr_status & GR_READY)))
87637+ return 0;
87638+
87639+ newacl = chk_subj_label(dentry, mnt, task->role);
87640+
87641+ /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
87642+ did an exec
87643+ */
87644+ rcu_read_lock();
87645+ read_lock(&tasklist_lock);
87646+ if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
87647+ (task->parent->acl->mode & GR_POVERRIDE))) {
87648+ read_unlock(&tasklist_lock);
87649+ rcu_read_unlock();
87650+ goto skip_check;
87651+ }
87652+ read_unlock(&tasklist_lock);
87653+ rcu_read_unlock();
87654+
87655+ if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
87656+ !(task->role->roletype & GR_ROLE_GOD) &&
87657+ !gr_search_file(dentry, GR_PTRACERD, mnt) &&
87658+ !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
87659+ if (unsafe_flags & LSM_UNSAFE_SHARE)
87660+ gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
87661+ else
87662+ gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
87663+ return -EACCES;
87664+ }
87665+
87666+skip_check:
87667+
87668+ obj = chk_obj_label(dentry, mnt, task->acl);
87669+ retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
87670+
87671+ if (!(task->acl->mode & GR_INHERITLEARN) &&
87672+ ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
87673+ if (obj->nested)
87674+ task->acl = obj->nested;
87675+ else
87676+ task->acl = newacl;
87677+ task->inherited = 0;
87678+ } else {
87679+ task->inherited = 1;
87680+ if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
87681+ gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
87682+ }
87683+
87684+ task->is_writable = 0;
87685+
87686+ /* ignore additional mmap checks for processes that are writable
87687+ by the default ACL */
87688+ obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
87689+ if (unlikely(obj->mode & GR_WRITE))
87690+ task->is_writable = 1;
87691+ obj = chk_obj_label(dentry, mnt, task->role->root_label);
87692+ if (unlikely(obj->mode & GR_WRITE))
87693+ task->is_writable = 1;
87694+
87695+ gr_set_proc_res(task);
87696+
87697+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
87698+ 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);
87699+#endif
87700+ return 0;
87701+}
87702+
87703+/* always called with valid inodev ptr */
87704+static void
87705+do_handle_delete(struct inodev_entry *inodev, const u64 ino, const dev_t dev)
87706+{
87707+ struct acl_object_label *matchpo;
87708+ struct acl_subject_label *matchps;
87709+ struct acl_subject_label *subj;
87710+ struct acl_role_label *role;
87711+ unsigned int x;
87712+
87713+ FOR_EACH_ROLE_START(role)
87714+ FOR_EACH_SUBJECT_START(role, subj, x)
87715+ if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
87716+ matchpo->mode |= GR_DELETED;
87717+ FOR_EACH_SUBJECT_END(subj,x)
87718+ FOR_EACH_NESTED_SUBJECT_START(role, subj)
87719+ /* nested subjects aren't in the role's subj_hash table */
87720+ if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
87721+ matchpo->mode |= GR_DELETED;
87722+ FOR_EACH_NESTED_SUBJECT_END(subj)
87723+ if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
87724+ matchps->mode |= GR_DELETED;
87725+ FOR_EACH_ROLE_END(role)
87726+
87727+ inodev->nentry->deleted = 1;
87728+
87729+ return;
87730+}
87731+
87732+void
87733+gr_handle_delete(const u64 ino, const dev_t dev)
87734+{
87735+ struct inodev_entry *inodev;
87736+
87737+ if (unlikely(!(gr_status & GR_READY)))
87738+ return;
87739+
87740+ write_lock(&gr_inode_lock);
87741+ inodev = lookup_inodev_entry(ino, dev);
87742+ if (inodev != NULL)
87743+ do_handle_delete(inodev, ino, dev);
87744+ write_unlock(&gr_inode_lock);
87745+
87746+ return;
87747+}
87748+
87749+static void
87750+update_acl_obj_label(const u64 oldinode, const dev_t olddevice,
87751+ const u64 newinode, const dev_t newdevice,
87752+ struct acl_subject_label *subj)
87753+{
87754+ unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
87755+ struct acl_object_label *match;
87756+
87757+ match = subj->obj_hash[index];
87758+
87759+ while (match && (match->inode != oldinode ||
87760+ match->device != olddevice ||
87761+ !(match->mode & GR_DELETED)))
87762+ match = match->next;
87763+
87764+ if (match && (match->inode == oldinode)
87765+ && (match->device == olddevice)
87766+ && (match->mode & GR_DELETED)) {
87767+ if (match->prev == NULL) {
87768+ subj->obj_hash[index] = match->next;
87769+ if (match->next != NULL)
87770+ match->next->prev = NULL;
87771+ } else {
87772+ match->prev->next = match->next;
87773+ if (match->next != NULL)
87774+ match->next->prev = match->prev;
87775+ }
87776+ match->prev = NULL;
87777+ match->next = NULL;
87778+ match->inode = newinode;
87779+ match->device = newdevice;
87780+ match->mode &= ~GR_DELETED;
87781+
87782+ insert_acl_obj_label(match, subj);
87783+ }
87784+
87785+ return;
87786+}
87787+
87788+static void
87789+update_acl_subj_label(const u64 oldinode, const dev_t olddevice,
87790+ const u64 newinode, const dev_t newdevice,
87791+ struct acl_role_label *role)
87792+{
87793+ unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
87794+ struct acl_subject_label *match;
87795+
87796+ match = role->subj_hash[index];
87797+
87798+ while (match && (match->inode != oldinode ||
87799+ match->device != olddevice ||
87800+ !(match->mode & GR_DELETED)))
87801+ match = match->next;
87802+
87803+ if (match && (match->inode == oldinode)
87804+ && (match->device == olddevice)
87805+ && (match->mode & GR_DELETED)) {
87806+ if (match->prev == NULL) {
87807+ role->subj_hash[index] = match->next;
87808+ if (match->next != NULL)
87809+ match->next->prev = NULL;
87810+ } else {
87811+ match->prev->next = match->next;
87812+ if (match->next != NULL)
87813+ match->next->prev = match->prev;
87814+ }
87815+ match->prev = NULL;
87816+ match->next = NULL;
87817+ match->inode = newinode;
87818+ match->device = newdevice;
87819+ match->mode &= ~GR_DELETED;
87820+
87821+ insert_acl_subj_label(match, role);
87822+ }
87823+
87824+ return;
87825+}
87826+
87827+static void
87828+update_inodev_entry(const u64 oldinode, const dev_t olddevice,
87829+ const u64 newinode, const dev_t newdevice)
87830+{
87831+ unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
87832+ struct inodev_entry *match;
87833+
87834+ match = running_polstate.inodev_set.i_hash[index];
87835+
87836+ while (match && (match->nentry->inode != oldinode ||
87837+ match->nentry->device != olddevice || !match->nentry->deleted))
87838+ match = match->next;
87839+
87840+ if (match && (match->nentry->inode == oldinode)
87841+ && (match->nentry->device == olddevice) &&
87842+ match->nentry->deleted) {
87843+ if (match->prev == NULL) {
87844+ running_polstate.inodev_set.i_hash[index] = match->next;
87845+ if (match->next != NULL)
87846+ match->next->prev = NULL;
87847+ } else {
87848+ match->prev->next = match->next;
87849+ if (match->next != NULL)
87850+ match->next->prev = match->prev;
87851+ }
87852+ match->prev = NULL;
87853+ match->next = NULL;
87854+ match->nentry->inode = newinode;
87855+ match->nentry->device = newdevice;
87856+ match->nentry->deleted = 0;
87857+
87858+ insert_inodev_entry(match);
87859+ }
87860+
87861+ return;
87862+}
87863+
87864+static void
87865+__do_handle_create(const struct name_entry *matchn, u64 ino, dev_t dev)
87866+{
87867+ struct acl_subject_label *subj;
87868+ struct acl_role_label *role;
87869+ unsigned int x;
87870+
87871+ FOR_EACH_ROLE_START(role)
87872+ update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
87873+
87874+ FOR_EACH_NESTED_SUBJECT_START(role, subj)
87875+ if ((subj->inode == ino) && (subj->device == dev)) {
87876+ subj->inode = ino;
87877+ subj->device = dev;
87878+ }
87879+ /* nested subjects aren't in the role's subj_hash table */
87880+ update_acl_obj_label(matchn->inode, matchn->device,
87881+ ino, dev, subj);
87882+ FOR_EACH_NESTED_SUBJECT_END(subj)
87883+ FOR_EACH_SUBJECT_START(role, subj, x)
87884+ update_acl_obj_label(matchn->inode, matchn->device,
87885+ ino, dev, subj);
87886+ FOR_EACH_SUBJECT_END(subj,x)
87887+ FOR_EACH_ROLE_END(role)
87888+
87889+ update_inodev_entry(matchn->inode, matchn->device, ino, dev);
87890+
87891+ return;
87892+}
87893+
87894+static void
87895+do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
87896+ const struct vfsmount *mnt)
87897+{
87898+ u64 ino = __get_ino(dentry);
87899+ dev_t dev = __get_dev(dentry);
87900+
87901+ __do_handle_create(matchn, ino, dev);
87902+
87903+ return;
87904+}
87905+
87906+void
87907+gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
87908+{
87909+ struct name_entry *matchn;
87910+
87911+ if (unlikely(!(gr_status & GR_READY)))
87912+ return;
87913+
87914+ preempt_disable();
87915+ matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
87916+
87917+ if (unlikely((unsigned long)matchn)) {
87918+ write_lock(&gr_inode_lock);
87919+ do_handle_create(matchn, dentry, mnt);
87920+ write_unlock(&gr_inode_lock);
87921+ }
87922+ preempt_enable();
87923+
87924+ return;
87925+}
87926+
87927+void
87928+gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
87929+{
87930+ struct name_entry *matchn;
87931+
87932+ if (unlikely(!(gr_status & GR_READY)))
87933+ return;
87934+
87935+ preempt_disable();
87936+ matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
87937+
87938+ if (unlikely((unsigned long)matchn)) {
87939+ write_lock(&gr_inode_lock);
87940+ __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
87941+ write_unlock(&gr_inode_lock);
87942+ }
87943+ preempt_enable();
87944+
87945+ return;
87946+}
87947+
87948+void
87949+gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
87950+ struct dentry *old_dentry,
87951+ struct dentry *new_dentry,
87952+ struct vfsmount *mnt, const __u8 replace, unsigned int flags)
87953+{
87954+ struct name_entry *matchn;
87955+ struct name_entry *matchn2 = NULL;
87956+ struct inodev_entry *inodev;
87957+ struct inode *inode = d_backing_inode(new_dentry);
87958+ struct inode *old_inode = d_backing_inode(old_dentry);
87959+ u64 old_ino = __get_ino(old_dentry);
87960+ dev_t old_dev = __get_dev(old_dentry);
87961+ unsigned int exchange = flags & RENAME_EXCHANGE;
87962+
87963+ /* vfs_rename swaps the name and parent link for old_dentry and
87964+ new_dentry
87965+ at this point, old_dentry has the new name, parent link, and inode
87966+ for the renamed file
87967+ if a file is being replaced by a rename, new_dentry has the inode
87968+ and name for the replaced file
87969+ */
87970+
87971+ if (unlikely(!(gr_status & GR_READY)))
87972+ return;
87973+
87974+ preempt_disable();
87975+ matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
87976+
87977+ /* exchange cases:
87978+ a filename exists for the source, but not dest
87979+ do a recreate on source
87980+ a filename exists for the dest, but not source
87981+ do a recreate on dest
87982+ a filename exists for both source and dest
87983+ delete source and dest, then create source and dest
87984+ a filename exists for neither source nor dest
87985+ no updates needed
87986+
87987+ the name entry lookups get us the old inode/dev associated with
87988+ each name, so do the deletes first (if possible) so that when
87989+ we do the create, we pick up on the right entries
87990+ */
87991+
87992+ if (exchange)
87993+ matchn2 = lookup_name_entry(gr_to_filename_rbac(new_dentry, mnt));
87994+
87995+ /* we wouldn't have to check d_inode if it weren't for
87996+ NFS silly-renaming
87997+ */
87998+
87999+ write_lock(&gr_inode_lock);
88000+ if (unlikely((replace || exchange) && inode)) {
88001+ u64 new_ino = __get_ino(new_dentry);
88002+ dev_t new_dev = __get_dev(new_dentry);
88003+
88004+ inodev = lookup_inodev_entry(new_ino, new_dev);
88005+ if (inodev != NULL && ((inode->i_nlink <= 1) || d_is_dir(new_dentry)))
88006+ do_handle_delete(inodev, new_ino, new_dev);
88007+ }
88008+
88009+ inodev = lookup_inodev_entry(old_ino, old_dev);
88010+ if (inodev != NULL && ((old_inode->i_nlink <= 1) || d_is_dir(old_dentry)))
88011+ do_handle_delete(inodev, old_ino, old_dev);
88012+
88013+ if (unlikely(matchn != NULL))
88014+ do_handle_create(matchn, old_dentry, mnt);
88015+
88016+ if (unlikely(matchn2 != NULL))
88017+ do_handle_create(matchn2, new_dentry, mnt);
88018+
88019+ write_unlock(&gr_inode_lock);
88020+ preempt_enable();
88021+
88022+ return;
88023+}
88024+
88025+#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
88026+static const unsigned long res_learn_bumps[GR_NLIMITS] = {
88027+ [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
88028+ [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
88029+ [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
88030+ [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
88031+ [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
88032+ [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
88033+ [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
88034+ [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
88035+ [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
88036+ [RLIMIT_AS] = GR_RLIM_AS_BUMP,
88037+ [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
88038+ [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
88039+ [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
88040+ [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
88041+ [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
88042+ [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
88043+};
88044+
88045+void
88046+gr_learn_resource(const struct task_struct *task,
88047+ const int res, const unsigned long wanted, const int gt)
88048+{
88049+ struct acl_subject_label *acl;
88050+ const struct cred *cred;
88051+
88052+ if (unlikely((gr_status & GR_READY) &&
88053+ task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
88054+ goto skip_reslog;
88055+
88056+ gr_log_resource(task, res, wanted, gt);
88057+skip_reslog:
88058+
88059+ if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
88060+ return;
88061+
88062+ acl = task->acl;
88063+
88064+ if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
88065+ !(acl->resmask & (1U << (unsigned short) res))))
88066+ return;
88067+
88068+ if (wanted >= acl->res[res].rlim_cur) {
88069+ unsigned long res_add;
88070+
88071+ res_add = wanted + res_learn_bumps[res];
88072+
88073+ acl->res[res].rlim_cur = res_add;
88074+
88075+ if (wanted > acl->res[res].rlim_max)
88076+ acl->res[res].rlim_max = res_add;
88077+
88078+ /* only log the subject filename, since resource logging is supported for
88079+ single-subject learning only */
88080+ rcu_read_lock();
88081+ cred = __task_cred(task);
88082+ security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
88083+ task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
88084+ acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
88085+ "", (unsigned long) res, &task->signal->saved_ip);
88086+ rcu_read_unlock();
88087+ }
88088+
88089+ return;
88090+}
88091+EXPORT_SYMBOL_GPL(gr_learn_resource);
88092+#endif
88093+
88094+#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
88095+void
88096+pax_set_initial_flags(struct linux_binprm *bprm)
88097+{
88098+ struct task_struct *task = current;
88099+ struct acl_subject_label *proc;
88100+ unsigned long flags;
88101+
88102+ if (unlikely(!(gr_status & GR_READY)))
88103+ return;
88104+
88105+ flags = pax_get_flags(task);
88106+
88107+ proc = task->acl;
88108+
88109+ if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
88110+ flags &= ~MF_PAX_PAGEEXEC;
88111+ if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
88112+ flags &= ~MF_PAX_SEGMEXEC;
88113+ if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
88114+ flags &= ~MF_PAX_RANDMMAP;
88115+ if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
88116+ flags &= ~MF_PAX_EMUTRAMP;
88117+ if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
88118+ flags &= ~MF_PAX_MPROTECT;
88119+
88120+ if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
88121+ flags |= MF_PAX_PAGEEXEC;
88122+ if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
88123+ flags |= MF_PAX_SEGMEXEC;
88124+ if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
88125+ flags |= MF_PAX_RANDMMAP;
88126+ if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
88127+ flags |= MF_PAX_EMUTRAMP;
88128+ if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
88129+ flags |= MF_PAX_MPROTECT;
88130+
88131+ pax_set_flags(task, flags);
88132+
88133+ return;
88134+}
88135+#endif
88136+
88137+int
88138+gr_handle_proc_ptrace(struct task_struct *task)
88139+{
88140+ struct file *filp;
88141+ struct task_struct *tmp = task;
88142+ struct task_struct *curtemp = current;
88143+ __u32 retmode;
88144+
88145+#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
88146+ if (unlikely(!(gr_status & GR_READY)))
88147+ return 0;
88148+#endif
88149+
88150+ read_lock(&tasklist_lock);
88151+ read_lock(&grsec_exec_file_lock);
88152+ filp = task->exec_file;
88153+
88154+ while (task_pid_nr(tmp) > 0) {
88155+ if (tmp == curtemp)
88156+ break;
88157+ tmp = tmp->real_parent;
88158+ }
88159+
88160+ if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
88161+ ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
88162+ read_unlock(&grsec_exec_file_lock);
88163+ read_unlock(&tasklist_lock);
88164+ return 1;
88165+ }
88166+
88167+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
88168+ if (!(gr_status & GR_READY)) {
88169+ read_unlock(&grsec_exec_file_lock);
88170+ read_unlock(&tasklist_lock);
88171+ return 0;
88172+ }
88173+#endif
88174+
88175+ retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
88176+ read_unlock(&grsec_exec_file_lock);
88177+ read_unlock(&tasklist_lock);
88178+
88179+ if (retmode & GR_NOPTRACE)
88180+ return 1;
88181+
88182+ if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
88183+ && (current->acl != task->acl || (current->acl != current->role->root_label
88184+ && task_pid_nr(current) != task_pid_nr(task))))
88185+ return 1;
88186+
88187+ return 0;
88188+}
88189+
88190+void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
88191+{
88192+ if (unlikely(!(gr_status & GR_READY)))
88193+ return;
88194+
88195+ if (!(current->role->roletype & GR_ROLE_GOD))
88196+ return;
88197+
88198+ seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
88199+ p->role->rolename, gr_task_roletype_to_char(p),
88200+ p->acl->filename);
88201+}
88202+
88203+int
88204+gr_handle_ptrace(struct task_struct *task, const long request)
88205+{
88206+ struct task_struct *tmp = task;
88207+ struct task_struct *curtemp = current;
88208+ __u32 retmode;
88209+
88210+#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
88211+ if (unlikely(!(gr_status & GR_READY)))
88212+ return 0;
88213+#endif
88214+ if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
88215+ read_lock(&tasklist_lock);
88216+ while (task_pid_nr(tmp) > 0) {
88217+ if (tmp == curtemp)
88218+ break;
88219+ tmp = tmp->real_parent;
88220+ }
88221+
88222+ if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
88223+ ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
88224+ read_unlock(&tasklist_lock);
88225+ gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
88226+ return 1;
88227+ }
88228+ read_unlock(&tasklist_lock);
88229+ }
88230+
88231+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
88232+ if (!(gr_status & GR_READY))
88233+ return 0;
88234+#endif
88235+
88236+ read_lock(&grsec_exec_file_lock);
88237+ if (unlikely(!task->exec_file)) {
88238+ read_unlock(&grsec_exec_file_lock);
88239+ return 0;
88240+ }
88241+
88242+ retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
88243+ read_unlock(&grsec_exec_file_lock);
88244+
88245+ if (retmode & GR_NOPTRACE) {
88246+ gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
88247+ return 1;
88248+ }
88249+
88250+ if (retmode & GR_PTRACERD) {
88251+ switch (request) {
88252+ case PTRACE_SEIZE:
88253+ case PTRACE_POKETEXT:
88254+ case PTRACE_POKEDATA:
88255+ case PTRACE_POKEUSR:
88256+#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
88257+ case PTRACE_SETREGS:
88258+ case PTRACE_SETFPREGS:
88259+#endif
88260+#ifdef CONFIG_X86
88261+ case PTRACE_SETFPXREGS:
88262+#endif
88263+#ifdef CONFIG_ALTIVEC
88264+ case PTRACE_SETVRREGS:
88265+#endif
88266+ return 1;
88267+ default:
88268+ return 0;
88269+ }
88270+ } else if (!(current->acl->mode & GR_POVERRIDE) &&
88271+ !(current->role->roletype & GR_ROLE_GOD) &&
88272+ (current->acl != task->acl)) {
88273+ gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
88274+ return 1;
88275+ }
88276+
88277+ return 0;
88278+}
88279+
88280+static int is_writable_mmap(const struct file *filp)
88281+{
88282+ struct task_struct *task = current;
88283+ struct acl_object_label *obj, *obj2;
88284+ struct dentry *dentry = filp->f_path.dentry;
88285+ struct vfsmount *mnt = filp->f_path.mnt;
88286+ struct inode *inode = d_backing_inode(dentry);
88287+
88288+ if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
88289+ !task->is_writable && d_is_reg(dentry) && (mnt != shm_mnt || (inode->i_nlink > 0))) {
88290+ obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
88291+ obj2 = chk_obj_label(dentry, mnt, task->role->root_label);
88292+ if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
88293+ gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, dentry, mnt);
88294+ return 1;
88295+ }
88296+ }
88297+ return 0;
88298+}
88299+
88300+int
88301+gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
88302+{
88303+ __u32 mode;
88304+
88305+ if (unlikely(!file || !(prot & PROT_EXEC)))
88306+ return 1;
88307+
88308+ if (is_writable_mmap(file))
88309+ return 0;
88310+
88311+ mode =
88312+ gr_search_file(file->f_path.dentry,
88313+ GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
88314+ file->f_path.mnt);
88315+
88316+ if (!gr_tpe_allow(file))
88317+ return 0;
88318+
88319+ if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
88320+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
88321+ return 0;
88322+ } else if (unlikely(!(mode & GR_EXEC))) {
88323+ return 0;
88324+ } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
88325+ gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
88326+ return 1;
88327+ }
88328+
88329+ return 1;
88330+}
88331+
88332+int
88333+gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
88334+{
88335+ __u32 mode;
88336+
88337+ if (unlikely(!file || !(prot & PROT_EXEC)))
88338+ return 1;
88339+
88340+ if (is_writable_mmap(file))
88341+ return 0;
88342+
88343+ mode =
88344+ gr_search_file(file->f_path.dentry,
88345+ GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
88346+ file->f_path.mnt);
88347+
88348+ if (!gr_tpe_allow(file))
88349+ return 0;
88350+
88351+ if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
88352+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
88353+ return 0;
88354+ } else if (unlikely(!(mode & GR_EXEC))) {
88355+ return 0;
88356+ } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
88357+ gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
88358+ return 1;
88359+ }
88360+
88361+ return 1;
88362+}
88363+
88364+void
88365+gr_acl_handle_psacct(struct task_struct *task, const long code)
88366+{
88367+ unsigned long runtime, cputime;
88368+ cputime_t utime, stime;
88369+ unsigned int wday, cday;
88370+ __u8 whr, chr;
88371+ __u8 wmin, cmin;
88372+ __u8 wsec, csec;
88373+ struct timespec curtime, starttime;
88374+
88375+ if (unlikely(!(gr_status & GR_READY) || !task->acl ||
88376+ !(task->acl->mode & GR_PROCACCT)))
88377+ return;
88378+
88379+ curtime = ns_to_timespec(ktime_get_ns());
88380+ starttime = ns_to_timespec(task->start_time);
88381+ runtime = curtime.tv_sec - starttime.tv_sec;
88382+ wday = runtime / (60 * 60 * 24);
88383+ runtime -= wday * (60 * 60 * 24);
88384+ whr = runtime / (60 * 60);
88385+ runtime -= whr * (60 * 60);
88386+ wmin = runtime / 60;
88387+ runtime -= wmin * 60;
88388+ wsec = runtime;
88389+
88390+ task_cputime(task, &utime, &stime);
88391+ cputime = cputime_to_secs(utime + stime);
88392+ cday = cputime / (60 * 60 * 24);
88393+ cputime -= cday * (60 * 60 * 24);
88394+ chr = cputime / (60 * 60);
88395+ cputime -= chr * (60 * 60);
88396+ cmin = cputime / 60;
88397+ cputime -= cmin * 60;
88398+ csec = cputime;
88399+
88400+ gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
88401+
88402+ return;
88403+}
88404+
88405+#ifdef CONFIG_TASKSTATS
88406+int gr_is_taskstats_denied(int pid)
88407+{
88408+ struct task_struct *task;
88409+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
88410+ const struct cred *cred;
88411+#endif
88412+ int ret = 0;
88413+
88414+ /* restrict taskstats viewing to un-chrooted root users
88415+ who have the 'view' subject flag if the RBAC system is enabled
88416+ */
88417+
88418+ rcu_read_lock();
88419+ read_lock(&tasklist_lock);
88420+ task = find_task_by_vpid(pid);
88421+ if (task) {
88422+#ifdef CONFIG_GRKERNSEC_CHROOT
88423+ if (proc_is_chrooted(task))
88424+ ret = -EACCES;
88425+#endif
88426+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
88427+ cred = __task_cred(task);
88428+#ifdef CONFIG_GRKERNSEC_PROC_USER
88429+ if (gr_is_global_nonroot(cred->uid))
88430+ ret = -EACCES;
88431+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
88432+ if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
88433+ ret = -EACCES;
88434+#endif
88435+#endif
88436+ if (gr_status & GR_READY) {
88437+ if (!(task->acl->mode & GR_VIEW))
88438+ ret = -EACCES;
88439+ }
88440+ } else
88441+ ret = -ENOENT;
88442+
88443+ read_unlock(&tasklist_lock);
88444+ rcu_read_unlock();
88445+
88446+ return ret;
88447+}
88448+#endif
88449+
88450+/* AUXV entries are filled via a descendant of search_binary_handler
88451+ after we've already applied the subject for the target
88452+*/
88453+int gr_acl_enable_at_secure(void)
88454+{
88455+ if (unlikely(!(gr_status & GR_READY)))
88456+ return 0;
88457+
88458+ if (current->acl->mode & GR_ATSECURE)
88459+ return 1;
88460+
88461+ return 0;
88462+}
88463+
88464+int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const u64 ino)
88465+{
88466+ struct task_struct *task = current;
88467+ struct dentry *dentry = file->f_path.dentry;
88468+ struct vfsmount *mnt = file->f_path.mnt;
88469+ struct acl_object_label *obj, *tmp;
88470+ struct acl_subject_label *subj;
88471+ unsigned int bufsize;
88472+ int is_not_root;
88473+ char *path;
88474+ dev_t dev = __get_dev(dentry);
88475+
88476+ if (unlikely(!(gr_status & GR_READY)))
88477+ return 1;
88478+
88479+ if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
88480+ return 1;
88481+
88482+ /* ignore Eric Biederman */
88483+ if (IS_PRIVATE(d_backing_inode(dentry)))
88484+ return 1;
88485+
88486+ subj = task->acl;
88487+ read_lock(&gr_inode_lock);
88488+ do {
88489+ obj = lookup_acl_obj_label(ino, dev, subj);
88490+ if (obj != NULL) {
88491+ read_unlock(&gr_inode_lock);
88492+ return (obj->mode & GR_FIND) ? 1 : 0;
88493+ }
88494+ } while ((subj = subj->parent_subject));
88495+ read_unlock(&gr_inode_lock);
88496+
88497+ /* this is purely an optimization since we're looking for an object
88498+ for the directory we're doing a readdir on
88499+ if it's possible for any globbed object to match the entry we're
88500+ filling into the directory, then the object we find here will be
88501+ an anchor point with attached globbed objects
88502+ */
88503+ obj = chk_obj_label_noglob(dentry, mnt, task->acl);
88504+ if (obj->globbed == NULL)
88505+ return (obj->mode & GR_FIND) ? 1 : 0;
88506+
88507+ is_not_root = ((obj->filename[0] == '/') &&
88508+ (obj->filename[1] == '\0')) ? 0 : 1;
88509+ bufsize = PAGE_SIZE - namelen - is_not_root;
88510+
88511+ /* check bufsize > PAGE_SIZE || bufsize == 0 */
88512+ if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
88513+ return 1;
88514+
88515+ preempt_disable();
88516+ path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
88517+ bufsize);
88518+
88519+ bufsize = strlen(path);
88520+
88521+ /* if base is "/", don't append an additional slash */
88522+ if (is_not_root)
88523+ *(path + bufsize) = '/';
88524+ memcpy(path + bufsize + is_not_root, name, namelen);
88525+ *(path + bufsize + namelen + is_not_root) = '\0';
88526+
88527+ tmp = obj->globbed;
88528+ while (tmp) {
88529+ if (!glob_match(tmp->filename, path)) {
88530+ preempt_enable();
88531+ return (tmp->mode & GR_FIND) ? 1 : 0;
88532+ }
88533+ tmp = tmp->next;
88534+ }
88535+ preempt_enable();
88536+ return (obj->mode & GR_FIND) ? 1 : 0;
88537+}
88538+
88539+void gr_put_exec_file(struct task_struct *task)
88540+{
88541+ struct file *filp;
88542+
88543+ write_lock(&grsec_exec_file_lock);
88544+ filp = task->exec_file;
88545+ task->exec_file = NULL;
88546+ write_unlock(&grsec_exec_file_lock);
88547+
88548+ if (filp)
88549+ fput(filp);
88550+
88551+ return;
88552+}
88553+
88554+
88555+#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
88556+EXPORT_SYMBOL_GPL(gr_acl_is_enabled);
88557+#endif
88558+#ifdef CONFIG_SECURITY
88559+EXPORT_SYMBOL_GPL(gr_check_user_change);
88560+EXPORT_SYMBOL_GPL(gr_check_group_change);
88561+#endif
88562+
88563diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
88564new file mode 100644
88565index 0000000..9adc75c
88566--- /dev/null
88567+++ b/grsecurity/gracl_alloc.c
88568@@ -0,0 +1,105 @@
88569+#include <linux/kernel.h>
88570+#include <linux/mm.h>
88571+#include <linux/slab.h>
88572+#include <linux/vmalloc.h>
88573+#include <linux/gracl.h>
88574+#include <linux/grsecurity.h>
88575+
88576+static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
88577+struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
88578+
88579+static int
88580+alloc_pop(void)
88581+{
88582+ if (current_alloc_state->alloc_stack_next == 1)
88583+ return 0;
88584+
88585+ kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
88586+
88587+ current_alloc_state->alloc_stack_next--;
88588+
88589+ return 1;
88590+}
88591+
88592+static int
88593+alloc_push(void *buf)
88594+{
88595+ if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
88596+ return 1;
88597+
88598+ current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
88599+
88600+ current_alloc_state->alloc_stack_next++;
88601+
88602+ return 0;
88603+}
88604+
88605+void *
88606+acl_alloc(unsigned long len)
88607+{
88608+ void *ret = NULL;
88609+
88610+ if (!len || len > PAGE_SIZE)
88611+ goto out;
88612+
88613+ ret = kmalloc(len, GFP_KERNEL);
88614+
88615+ if (ret) {
88616+ if (alloc_push(ret)) {
88617+ kfree(ret);
88618+ ret = NULL;
88619+ }
88620+ }
88621+
88622+out:
88623+ return ret;
88624+}
88625+
88626+void *
88627+acl_alloc_num(unsigned long num, unsigned long len)
88628+{
88629+ if (!len || (num > (PAGE_SIZE / len)))
88630+ return NULL;
88631+
88632+ return acl_alloc(num * len);
88633+}
88634+
88635+void
88636+acl_free_all(void)
88637+{
88638+ if (!current_alloc_state->alloc_stack)
88639+ return;
88640+
88641+ while (alloc_pop()) ;
88642+
88643+ if (current_alloc_state->alloc_stack) {
88644+ if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
88645+ kfree(current_alloc_state->alloc_stack);
88646+ else
88647+ vfree(current_alloc_state->alloc_stack);
88648+ }
88649+
88650+ current_alloc_state->alloc_stack = NULL;
88651+ current_alloc_state->alloc_stack_size = 1;
88652+ current_alloc_state->alloc_stack_next = 1;
88653+
88654+ return;
88655+}
88656+
88657+int
88658+acl_alloc_stack_init(unsigned long size)
88659+{
88660+ if ((size * sizeof (void *)) <= PAGE_SIZE)
88661+ current_alloc_state->alloc_stack =
88662+ (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
88663+ else
88664+ current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
88665+
88666+ current_alloc_state->alloc_stack_size = size;
88667+ current_alloc_state->alloc_stack_next = 1;
88668+
88669+ if (!current_alloc_state->alloc_stack)
88670+ return 0;
88671+ else
88672+ return 1;
88673+}
88674diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
88675new file mode 100644
88676index 0000000..1a94c11
88677--- /dev/null
88678+++ b/grsecurity/gracl_cap.c
88679@@ -0,0 +1,127 @@
88680+#include <linux/kernel.h>
88681+#include <linux/module.h>
88682+#include <linux/sched.h>
88683+#include <linux/gracl.h>
88684+#include <linux/grsecurity.h>
88685+#include <linux/grinternal.h>
88686+
88687+extern const char *captab_log[];
88688+extern int captab_log_entries;
88689+
88690+int gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap)
88691+{
88692+ struct acl_subject_label *curracl;
88693+
88694+ if (!gr_acl_is_enabled())
88695+ return 1;
88696+
88697+ curracl = task->acl;
88698+
88699+ if (curracl->mode & (GR_LEARN | GR_INHERITLEARN)) {
88700+ security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
88701+ task->role->roletype, GR_GLOBAL_UID(cred->uid),
88702+ GR_GLOBAL_GID(cred->gid), task->exec_file ?
88703+ gr_to_filename(task->exec_file->f_path.dentry,
88704+ task->exec_file->f_path.mnt) : curracl->filename,
88705+ curracl->filename, 0UL,
88706+ 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
88707+ return 1;
88708+ }
88709+
88710+ return 0;
88711+}
88712+
88713+int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
88714+{
88715+ struct acl_subject_label *curracl;
88716+ kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
88717+ kernel_cap_t cap_audit = __cap_empty_set;
88718+
88719+ if (!gr_acl_is_enabled())
88720+ return 1;
88721+
88722+ curracl = task->acl;
88723+
88724+ cap_drop = curracl->cap_lower;
88725+ cap_mask = curracl->cap_mask;
88726+ cap_audit = curracl->cap_invert_audit;
88727+
88728+ while ((curracl = curracl->parent_subject)) {
88729+ /* if the cap isn't specified in the current computed mask but is specified in the
88730+ current level subject, and is lowered in the current level subject, then add
88731+ it to the set of dropped capabilities
88732+ otherwise, add the current level subject's mask to the current computed mask
88733+ */
88734+ if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
88735+ cap_raise(cap_mask, cap);
88736+ if (cap_raised(curracl->cap_lower, cap))
88737+ cap_raise(cap_drop, cap);
88738+ if (cap_raised(curracl->cap_invert_audit, cap))
88739+ cap_raise(cap_audit, cap);
88740+ }
88741+ }
88742+
88743+ if (!cap_raised(cap_drop, cap)) {
88744+ if (cap_raised(cap_audit, cap))
88745+ gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
88746+ return 1;
88747+ }
88748+
88749+ /* only learn the capability use if the process has the capability in the
88750+ general case, the two uses in sys.c of gr_learn_cap are an exception
88751+ to this rule to ensure any role transition involves what the full-learned
88752+ policy believes in a privileged process
88753+ */
88754+ if (cap_raised(cred->cap_effective, cap) && gr_learn_cap(task, cred, cap))
88755+ return 1;
88756+
88757+ if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
88758+ gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
88759+
88760+ return 0;
88761+}
88762+
88763+int
88764+gr_acl_is_capable(const int cap)
88765+{
88766+ return gr_task_acl_is_capable(current, current_cred(), cap);
88767+}
88768+
88769+int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
88770+{
88771+ struct acl_subject_label *curracl;
88772+ kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
88773+
88774+ if (!gr_acl_is_enabled())
88775+ return 1;
88776+
88777+ curracl = task->acl;
88778+
88779+ cap_drop = curracl->cap_lower;
88780+ cap_mask = curracl->cap_mask;
88781+
88782+ while ((curracl = curracl->parent_subject)) {
88783+ /* if the cap isn't specified in the current computed mask but is specified in the
88784+ current level subject, and is lowered in the current level subject, then add
88785+ it to the set of dropped capabilities
88786+ otherwise, add the current level subject's mask to the current computed mask
88787+ */
88788+ if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
88789+ cap_raise(cap_mask, cap);
88790+ if (cap_raised(curracl->cap_lower, cap))
88791+ cap_raise(cap_drop, cap);
88792+ }
88793+ }
88794+
88795+ if (!cap_raised(cap_drop, cap))
88796+ return 1;
88797+
88798+ return 0;
88799+}
88800+
88801+int
88802+gr_acl_is_capable_nolog(const int cap)
88803+{
88804+ return gr_task_acl_is_capable_nolog(current, cap);
88805+}
88806+
88807diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
88808new file mode 100644
88809index 0000000..a43dd06
88810--- /dev/null
88811+++ b/grsecurity/gracl_compat.c
88812@@ -0,0 +1,269 @@
88813+#include <linux/kernel.h>
88814+#include <linux/gracl.h>
88815+#include <linux/compat.h>
88816+#include <linux/gracl_compat.h>
88817+
88818+#include <asm/uaccess.h>
88819+
88820+int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
88821+{
88822+ struct gr_arg_wrapper_compat uwrapcompat;
88823+
88824+ if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
88825+ return -EFAULT;
88826+
88827+ if ((uwrapcompat.version != GRSECURITY_VERSION) ||
88828+ (uwrapcompat.size != sizeof(struct gr_arg_compat)))
88829+ return -EINVAL;
88830+
88831+ uwrap->arg = compat_ptr(uwrapcompat.arg);
88832+ uwrap->version = uwrapcompat.version;
88833+ uwrap->size = sizeof(struct gr_arg);
88834+
88835+ return 0;
88836+}
88837+
88838+int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
88839+{
88840+ struct gr_arg_compat argcompat;
88841+
88842+ if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
88843+ return -EFAULT;
88844+
88845+ arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
88846+ arg->role_db.num_pointers = argcompat.role_db.num_pointers;
88847+ arg->role_db.num_roles = argcompat.role_db.num_roles;
88848+ arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
88849+ arg->role_db.num_subjects = argcompat.role_db.num_subjects;
88850+ arg->role_db.num_objects = argcompat.role_db.num_objects;
88851+
88852+ memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
88853+ memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
88854+ memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
88855+ memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
88856+ arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
88857+ arg->segv_device = argcompat.segv_device;
88858+ arg->segv_inode = argcompat.segv_inode;
88859+ arg->segv_uid = argcompat.segv_uid;
88860+ arg->num_sprole_pws = argcompat.num_sprole_pws;
88861+ arg->mode = argcompat.mode;
88862+
88863+ return 0;
88864+}
88865+
88866+int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
88867+{
88868+ struct acl_object_label_compat objcompat;
88869+
88870+ if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
88871+ return -EFAULT;
88872+
88873+ obj->filename = compat_ptr(objcompat.filename);
88874+ obj->inode = objcompat.inode;
88875+ obj->device = objcompat.device;
88876+ obj->mode = objcompat.mode;
88877+
88878+ obj->nested = compat_ptr(objcompat.nested);
88879+ obj->globbed = compat_ptr(objcompat.globbed);
88880+
88881+ obj->prev = compat_ptr(objcompat.prev);
88882+ obj->next = compat_ptr(objcompat.next);
88883+
88884+ return 0;
88885+}
88886+
88887+int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
88888+{
88889+ unsigned int i;
88890+ struct acl_subject_label_compat subjcompat;
88891+
88892+ if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
88893+ return -EFAULT;
88894+
88895+ subj->filename = compat_ptr(subjcompat.filename);
88896+ subj->inode = subjcompat.inode;
88897+ subj->device = subjcompat.device;
88898+ subj->mode = subjcompat.mode;
88899+ subj->cap_mask = subjcompat.cap_mask;
88900+ subj->cap_lower = subjcompat.cap_lower;
88901+ subj->cap_invert_audit = subjcompat.cap_invert_audit;
88902+
88903+ for (i = 0; i < GR_NLIMITS; i++) {
88904+ if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
88905+ subj->res[i].rlim_cur = RLIM_INFINITY;
88906+ else
88907+ subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
88908+ if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
88909+ subj->res[i].rlim_max = RLIM_INFINITY;
88910+ else
88911+ subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
88912+ }
88913+ subj->resmask = subjcompat.resmask;
88914+
88915+ subj->user_trans_type = subjcompat.user_trans_type;
88916+ subj->group_trans_type = subjcompat.group_trans_type;
88917+ subj->user_transitions = compat_ptr(subjcompat.user_transitions);
88918+ subj->group_transitions = compat_ptr(subjcompat.group_transitions);
88919+ subj->user_trans_num = subjcompat.user_trans_num;
88920+ subj->group_trans_num = subjcompat.group_trans_num;
88921+
88922+ memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
88923+ memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
88924+ subj->ip_type = subjcompat.ip_type;
88925+ subj->ips = compat_ptr(subjcompat.ips);
88926+ subj->ip_num = subjcompat.ip_num;
88927+ subj->inaddr_any_override = subjcompat.inaddr_any_override;
88928+
88929+ subj->crashes = subjcompat.crashes;
88930+ subj->expires = subjcompat.expires;
88931+
88932+ subj->parent_subject = compat_ptr(subjcompat.parent_subject);
88933+ subj->hash = compat_ptr(subjcompat.hash);
88934+ subj->prev = compat_ptr(subjcompat.prev);
88935+ subj->next = compat_ptr(subjcompat.next);
88936+
88937+ subj->obj_hash = compat_ptr(subjcompat.obj_hash);
88938+ subj->obj_hash_size = subjcompat.obj_hash_size;
88939+ subj->pax_flags = subjcompat.pax_flags;
88940+
88941+ return 0;
88942+}
88943+
88944+int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
88945+{
88946+ struct acl_role_label_compat rolecompat;
88947+
88948+ if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
88949+ return -EFAULT;
88950+
88951+ role->rolename = compat_ptr(rolecompat.rolename);
88952+ role->uidgid = rolecompat.uidgid;
88953+ role->roletype = rolecompat.roletype;
88954+
88955+ role->auth_attempts = rolecompat.auth_attempts;
88956+ role->expires = rolecompat.expires;
88957+
88958+ role->root_label = compat_ptr(rolecompat.root_label);
88959+ role->hash = compat_ptr(rolecompat.hash);
88960+
88961+ role->prev = compat_ptr(rolecompat.prev);
88962+ role->next = compat_ptr(rolecompat.next);
88963+
88964+ role->transitions = compat_ptr(rolecompat.transitions);
88965+ role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
88966+ role->domain_children = compat_ptr(rolecompat.domain_children);
88967+ role->domain_child_num = rolecompat.domain_child_num;
88968+
88969+ role->umask = rolecompat.umask;
88970+
88971+ role->subj_hash = compat_ptr(rolecompat.subj_hash);
88972+ role->subj_hash_size = rolecompat.subj_hash_size;
88973+
88974+ return 0;
88975+}
88976+
88977+int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
88978+{
88979+ struct role_allowed_ip_compat roleip_compat;
88980+
88981+ if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
88982+ return -EFAULT;
88983+
88984+ roleip->addr = roleip_compat.addr;
88985+ roleip->netmask = roleip_compat.netmask;
88986+
88987+ roleip->prev = compat_ptr(roleip_compat.prev);
88988+ roleip->next = compat_ptr(roleip_compat.next);
88989+
88990+ return 0;
88991+}
88992+
88993+int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
88994+{
88995+ struct role_transition_compat trans_compat;
88996+
88997+ if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
88998+ return -EFAULT;
88999+
89000+ trans->rolename = compat_ptr(trans_compat.rolename);
89001+
89002+ trans->prev = compat_ptr(trans_compat.prev);
89003+ trans->next = compat_ptr(trans_compat.next);
89004+
89005+ return 0;
89006+
89007+}
89008+
89009+int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
89010+{
89011+ struct gr_hash_struct_compat hash_compat;
89012+
89013+ if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
89014+ return -EFAULT;
89015+
89016+ hash->table = compat_ptr(hash_compat.table);
89017+ hash->nametable = compat_ptr(hash_compat.nametable);
89018+ hash->first = compat_ptr(hash_compat.first);
89019+
89020+ hash->table_size = hash_compat.table_size;
89021+ hash->used_size = hash_compat.used_size;
89022+
89023+ hash->type = hash_compat.type;
89024+
89025+ return 0;
89026+}
89027+
89028+int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
89029+{
89030+ compat_uptr_t ptrcompat;
89031+
89032+ if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
89033+ return -EFAULT;
89034+
89035+ *(void **)ptr = compat_ptr(ptrcompat);
89036+
89037+ return 0;
89038+}
89039+
89040+int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
89041+{
89042+ struct acl_ip_label_compat ip_compat;
89043+
89044+ if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
89045+ return -EFAULT;
89046+
89047+ ip->iface = compat_ptr(ip_compat.iface);
89048+ ip->addr = ip_compat.addr;
89049+ ip->netmask = ip_compat.netmask;
89050+ ip->low = ip_compat.low;
89051+ ip->high = ip_compat.high;
89052+ ip->mode = ip_compat.mode;
89053+ ip->type = ip_compat.type;
89054+
89055+ memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
89056+
89057+ ip->prev = compat_ptr(ip_compat.prev);
89058+ ip->next = compat_ptr(ip_compat.next);
89059+
89060+ return 0;
89061+}
89062+
89063+int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
89064+{
89065+ struct sprole_pw_compat pw_compat;
89066+
89067+ if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
89068+ return -EFAULT;
89069+
89070+ pw->rolename = compat_ptr(pw_compat.rolename);
89071+ memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
89072+ memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
89073+
89074+ return 0;
89075+}
89076+
89077+size_t get_gr_arg_wrapper_size_compat(void)
89078+{
89079+ return sizeof(struct gr_arg_wrapper_compat);
89080+}
89081+
89082diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
89083new file mode 100644
89084index 0000000..fce7f71
89085--- /dev/null
89086+++ b/grsecurity/gracl_fs.c
89087@@ -0,0 +1,448 @@
89088+#include <linux/kernel.h>
89089+#include <linux/sched.h>
89090+#include <linux/types.h>
89091+#include <linux/fs.h>
89092+#include <linux/file.h>
89093+#include <linux/stat.h>
89094+#include <linux/grsecurity.h>
89095+#include <linux/grinternal.h>
89096+#include <linux/gracl.h>
89097+
89098+umode_t
89099+gr_acl_umask(void)
89100+{
89101+ if (unlikely(!gr_acl_is_enabled()))
89102+ return 0;
89103+
89104+ return current->role->umask;
89105+}
89106+
89107+__u32
89108+gr_acl_handle_hidden_file(const struct dentry * dentry,
89109+ const struct vfsmount * mnt)
89110+{
89111+ __u32 mode;
89112+
89113+ if (unlikely(d_is_negative(dentry)))
89114+ return GR_FIND;
89115+
89116+ mode =
89117+ gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
89118+
89119+ if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
89120+ gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
89121+ return mode;
89122+ } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
89123+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
89124+ return 0;
89125+ } else if (unlikely(!(mode & GR_FIND)))
89126+ return 0;
89127+
89128+ return GR_FIND;
89129+}
89130+
89131+__u32
89132+gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
89133+ int acc_mode)
89134+{
89135+ __u32 reqmode = GR_FIND;
89136+ __u32 mode;
89137+
89138+ if (unlikely(d_is_negative(dentry)))
89139+ return reqmode;
89140+
89141+ if (acc_mode & MAY_APPEND)
89142+ reqmode |= GR_APPEND;
89143+ else if (acc_mode & MAY_WRITE)
89144+ reqmode |= GR_WRITE;
89145+ if ((acc_mode & MAY_READ) && !d_is_dir(dentry))
89146+ reqmode |= GR_READ;
89147+
89148+ mode =
89149+ gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
89150+ mnt);
89151+
89152+ if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
89153+ gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
89154+ reqmode & GR_READ ? " reading" : "",
89155+ reqmode & GR_WRITE ? " writing" : reqmode &
89156+ GR_APPEND ? " appending" : "");
89157+ return reqmode;
89158+ } else
89159+ if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
89160+ {
89161+ gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
89162+ reqmode & GR_READ ? " reading" : "",
89163+ reqmode & GR_WRITE ? " writing" : reqmode &
89164+ GR_APPEND ? " appending" : "");
89165+ return 0;
89166+ } else if (unlikely((mode & reqmode) != reqmode))
89167+ return 0;
89168+
89169+ return reqmode;
89170+}
89171+
89172+__u32
89173+gr_acl_handle_creat(const struct dentry * dentry,
89174+ const struct dentry * p_dentry,
89175+ const struct vfsmount * p_mnt, int open_flags, int acc_mode,
89176+ const int imode)
89177+{
89178+ __u32 reqmode = GR_WRITE | GR_CREATE;
89179+ __u32 mode;
89180+
89181+ if (acc_mode & MAY_APPEND)
89182+ reqmode |= GR_APPEND;
89183+ // if a directory was required or the directory already exists, then
89184+ // don't count this open as a read
89185+ if ((acc_mode & MAY_READ) &&
89186+ !((open_flags & O_DIRECTORY) || d_is_dir(dentry)))
89187+ reqmode |= GR_READ;
89188+ if ((open_flags & O_CREAT) &&
89189+ ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
89190+ reqmode |= GR_SETID;
89191+
89192+ mode =
89193+ gr_check_create(dentry, p_dentry, p_mnt,
89194+ reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
89195+
89196+ if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
89197+ gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
89198+ reqmode & GR_READ ? " reading" : "",
89199+ reqmode & GR_WRITE ? " writing" : reqmode &
89200+ GR_APPEND ? " appending" : "");
89201+ return reqmode;
89202+ } else
89203+ if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
89204+ {
89205+ gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
89206+ reqmode & GR_READ ? " reading" : "",
89207+ reqmode & GR_WRITE ? " writing" : reqmode &
89208+ GR_APPEND ? " appending" : "");
89209+ return 0;
89210+ } else if (unlikely((mode & reqmode) != reqmode))
89211+ return 0;
89212+
89213+ return reqmode;
89214+}
89215+
89216+__u32
89217+gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
89218+ const int fmode)
89219+{
89220+ __u32 mode, reqmode = GR_FIND;
89221+
89222+ if ((fmode & S_IXOTH) && !d_is_dir(dentry))
89223+ reqmode |= GR_EXEC;
89224+ if (fmode & S_IWOTH)
89225+ reqmode |= GR_WRITE;
89226+ if (fmode & S_IROTH)
89227+ reqmode |= GR_READ;
89228+
89229+ mode =
89230+ gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
89231+ mnt);
89232+
89233+ if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
89234+ gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
89235+ reqmode & GR_READ ? " reading" : "",
89236+ reqmode & GR_WRITE ? " writing" : "",
89237+ reqmode & GR_EXEC ? " executing" : "");
89238+ return reqmode;
89239+ } else
89240+ if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
89241+ {
89242+ gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
89243+ reqmode & GR_READ ? " reading" : "",
89244+ reqmode & GR_WRITE ? " writing" : "",
89245+ reqmode & GR_EXEC ? " executing" : "");
89246+ return 0;
89247+ } else if (unlikely((mode & reqmode) != reqmode))
89248+ return 0;
89249+
89250+ return reqmode;
89251+}
89252+
89253+static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
89254+{
89255+ __u32 mode;
89256+
89257+ mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
89258+
89259+ if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
89260+ gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
89261+ return mode;
89262+ } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
89263+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
89264+ return 0;
89265+ } else if (unlikely((mode & (reqmode)) != (reqmode)))
89266+ return 0;
89267+
89268+ return (reqmode);
89269+}
89270+
89271+__u32
89272+gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
89273+{
89274+ return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
89275+}
89276+
89277+__u32
89278+gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
89279+{
89280+ return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
89281+}
89282+
89283+__u32
89284+gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
89285+{
89286+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
89287+}
89288+
89289+__u32
89290+gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
89291+{
89292+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
89293+}
89294+
89295+__u32
89296+gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
89297+ umode_t *modeptr)
89298+{
89299+ umode_t mode;
89300+ struct inode *inode = d_backing_inode(dentry);
89301+
89302+ *modeptr &= ~gr_acl_umask();
89303+ mode = *modeptr;
89304+
89305+ if (unlikely(inode && S_ISSOCK(inode->i_mode)))
89306+ return 1;
89307+
89308+ if (unlikely(!d_is_dir(dentry) &&
89309+ ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
89310+ return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
89311+ GR_CHMOD_ACL_MSG);
89312+ } else {
89313+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
89314+ }
89315+}
89316+
89317+__u32
89318+gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
89319+{
89320+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
89321+}
89322+
89323+__u32
89324+gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
89325+{
89326+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
89327+}
89328+
89329+__u32
89330+gr_acl_handle_removexattr(const struct dentry *dentry, const struct vfsmount *mnt)
89331+{
89332+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_REMOVEXATTR_ACL_MSG);
89333+}
89334+
89335+__u32
89336+gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
89337+{
89338+ return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
89339+}
89340+
89341+__u32
89342+gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
89343+{
89344+ return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
89345+ GR_UNIXCONNECT_ACL_MSG);
89346+}
89347+
89348+/* hardlinks require at minimum create and link permission,
89349+ any additional privilege required is based on the
89350+ privilege of the file being linked to
89351+*/
89352+__u32
89353+gr_acl_handle_link(const struct dentry * new_dentry,
89354+ const struct dentry * parent_dentry,
89355+ const struct vfsmount * parent_mnt,
89356+ const struct dentry * old_dentry,
89357+ const struct vfsmount * old_mnt, const struct filename *to)
89358+{
89359+ __u32 mode;
89360+ __u32 needmode = GR_CREATE | GR_LINK;
89361+ __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
89362+
89363+ mode =
89364+ gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
89365+ old_mnt);
89366+
89367+ if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
89368+ gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
89369+ return mode;
89370+ } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
89371+ gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
89372+ return 0;
89373+ } else if (unlikely((mode & needmode) != needmode))
89374+ return 0;
89375+
89376+ return 1;
89377+}
89378+
89379+__u32
89380+gr_acl_handle_symlink(const struct dentry * new_dentry,
89381+ const struct dentry * parent_dentry,
89382+ const struct vfsmount * parent_mnt, const struct filename *from)
89383+{
89384+ __u32 needmode = GR_WRITE | GR_CREATE;
89385+ __u32 mode;
89386+
89387+ mode =
89388+ gr_check_create(new_dentry, parent_dentry, parent_mnt,
89389+ GR_CREATE | GR_AUDIT_CREATE |
89390+ GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
89391+
89392+ if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
89393+ gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
89394+ return mode;
89395+ } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
89396+ gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
89397+ return 0;
89398+ } else if (unlikely((mode & needmode) != needmode))
89399+ return 0;
89400+
89401+ return (GR_WRITE | GR_CREATE);
89402+}
89403+
89404+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)
89405+{
89406+ __u32 mode;
89407+
89408+ mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
89409+
89410+ if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
89411+ gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
89412+ return mode;
89413+ } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
89414+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
89415+ return 0;
89416+ } else if (unlikely((mode & (reqmode)) != (reqmode)))
89417+ return 0;
89418+
89419+ return (reqmode);
89420+}
89421+
89422+__u32
89423+gr_acl_handle_mknod(const struct dentry * new_dentry,
89424+ const struct dentry * parent_dentry,
89425+ const struct vfsmount * parent_mnt,
89426+ const int mode)
89427+{
89428+ __u32 reqmode = GR_WRITE | GR_CREATE;
89429+ if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
89430+ reqmode |= GR_SETID;
89431+
89432+ return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
89433+ reqmode, GR_MKNOD_ACL_MSG);
89434+}
89435+
89436+__u32
89437+gr_acl_handle_mkdir(const struct dentry *new_dentry,
89438+ const struct dentry *parent_dentry,
89439+ const struct vfsmount *parent_mnt)
89440+{
89441+ return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
89442+ GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
89443+}
89444+
89445+#define RENAME_CHECK_SUCCESS(old, new) \
89446+ (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
89447+ ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
89448+
89449+int
89450+gr_acl_handle_rename(struct dentry *new_dentry,
89451+ struct dentry *parent_dentry,
89452+ const struct vfsmount *parent_mnt,
89453+ struct dentry *old_dentry,
89454+ struct inode *old_parent_inode,
89455+ struct vfsmount *old_mnt, const struct filename *newname, unsigned int flags)
89456+{
89457+ __u32 comp1, comp2;
89458+ int error = 0;
89459+
89460+ if (unlikely(!gr_acl_is_enabled()))
89461+ return 0;
89462+
89463+ if (flags & RENAME_EXCHANGE) {
89464+ comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
89465+ GR_AUDIT_READ | GR_AUDIT_WRITE |
89466+ GR_SUPPRESS, parent_mnt);
89467+ comp2 =
89468+ gr_search_file(old_dentry,
89469+ GR_READ | GR_WRITE | GR_AUDIT_READ |
89470+ GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
89471+ } else if (d_is_negative(new_dentry)) {
89472+ comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
89473+ GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
89474+ GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
89475+ comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
89476+ GR_DELETE | GR_AUDIT_DELETE |
89477+ GR_AUDIT_READ | GR_AUDIT_WRITE |
89478+ GR_SUPPRESS, old_mnt);
89479+ } else {
89480+ comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
89481+ GR_CREATE | GR_DELETE |
89482+ GR_AUDIT_CREATE | GR_AUDIT_DELETE |
89483+ GR_AUDIT_READ | GR_AUDIT_WRITE |
89484+ GR_SUPPRESS, parent_mnt);
89485+ comp2 =
89486+ gr_search_file(old_dentry,
89487+ GR_READ | GR_WRITE | GR_AUDIT_READ |
89488+ GR_DELETE | GR_AUDIT_DELETE |
89489+ GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
89490+ }
89491+
89492+ if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
89493+ ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
89494+ gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
89495+ else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
89496+ && !(comp2 & GR_SUPPRESS)) {
89497+ gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
89498+ error = -EACCES;
89499+ } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
89500+ error = -EACCES;
89501+
89502+ return error;
89503+}
89504+
89505+void
89506+gr_acl_handle_exit(void)
89507+{
89508+ u16 id;
89509+ char *rolename;
89510+
89511+ if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
89512+ !(current->role->roletype & GR_ROLE_PERSIST))) {
89513+ id = current->acl_role_id;
89514+ rolename = current->role->rolename;
89515+ gr_set_acls(1);
89516+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
89517+ }
89518+
89519+ gr_put_exec_file(current);
89520+ return;
89521+}
89522+
89523+int
89524+gr_acl_handle_procpidmem(const struct task_struct *task)
89525+{
89526+ if (unlikely(!gr_acl_is_enabled()))
89527+ return 0;
89528+
89529+ if (task != current && (task->acl->mode & GR_PROTPROCFD) &&
89530+ !(current->acl->mode & GR_POVERRIDE) &&
89531+ !(current->role->roletype & GR_ROLE_GOD))
89532+ return -EACCES;
89533+
89534+ return 0;
89535+}
89536diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
89537new file mode 100644
89538index 0000000..ed6ee43
89539--- /dev/null
89540+++ b/grsecurity/gracl_ip.c
89541@@ -0,0 +1,386 @@
89542+#include <linux/kernel.h>
89543+#include <asm/uaccess.h>
89544+#include <asm/errno.h>
89545+#include <net/sock.h>
89546+#include <linux/file.h>
89547+#include <linux/fs.h>
89548+#include <linux/net.h>
89549+#include <linux/in.h>
89550+#include <linux/skbuff.h>
89551+#include <linux/ip.h>
89552+#include <linux/udp.h>
89553+#include <linux/types.h>
89554+#include <linux/sched.h>
89555+#include <linux/netdevice.h>
89556+#include <linux/inetdevice.h>
89557+#include <linux/gracl.h>
89558+#include <linux/grsecurity.h>
89559+#include <linux/grinternal.h>
89560+
89561+#define GR_BIND 0x01
89562+#define GR_CONNECT 0x02
89563+#define GR_INVERT 0x04
89564+#define GR_BINDOVERRIDE 0x08
89565+#define GR_CONNECTOVERRIDE 0x10
89566+#define GR_SOCK_FAMILY 0x20
89567+
89568+static const char * gr_protocols[IPPROTO_MAX] = {
89569+ "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
89570+ "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
89571+ "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
89572+ "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
89573+ "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
89574+ "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
89575+ "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
89576+ "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
89577+ "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
89578+ "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
89579+ "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
89580+ "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
89581+ "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
89582+ "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
89583+ "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
89584+ "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
89585+ "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
89586+ "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
89587+ "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
89588+ "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
89589+ "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
89590+ "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
89591+ "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
89592+ "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
89593+ "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
89594+ "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
89595+ "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
89596+ "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
89597+ "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
89598+ "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
89599+ "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
89600+ "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
89601+ };
89602+
89603+static const char * gr_socktypes[SOCK_MAX] = {
89604+ "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
89605+ "unknown:7", "unknown:8", "unknown:9", "packet"
89606+ };
89607+
89608+static const char * gr_sockfamilies[AF_MAX+1] = {
89609+ "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
89610+ "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
89611+ "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
89612+ "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf", "alg", "nfc", "vsock"
89613+ };
89614+
89615+const char *
89616+gr_proto_to_name(unsigned char proto)
89617+{
89618+ return gr_protocols[proto];
89619+}
89620+
89621+const char *
89622+gr_socktype_to_name(unsigned char type)
89623+{
89624+ return gr_socktypes[type];
89625+}
89626+
89627+const char *
89628+gr_sockfamily_to_name(unsigned char family)
89629+{
89630+ return gr_sockfamilies[family];
89631+}
89632+
89633+extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
89634+
89635+int
89636+gr_search_socket(const int domain, const int type, const int protocol)
89637+{
89638+ struct acl_subject_label *curr;
89639+ const struct cred *cred = current_cred();
89640+
89641+ if (unlikely(!gr_acl_is_enabled()))
89642+ goto exit;
89643+
89644+ if ((domain < 0) || (type < 0) || (protocol < 0) ||
89645+ (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
89646+ goto exit; // let the kernel handle it
89647+
89648+ curr = current->acl;
89649+
89650+ if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
89651+ /* the family is allowed, if this is PF_INET allow it only if
89652+ the extra sock type/protocol checks pass */
89653+ if (domain == PF_INET)
89654+ goto inet_check;
89655+ goto exit;
89656+ } else {
89657+ if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
89658+ __u32 fakeip = 0;
89659+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
89660+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
89661+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
89662+ gr_to_filename(current->exec_file->f_path.dentry,
89663+ current->exec_file->f_path.mnt) :
89664+ curr->filename, curr->filename,
89665+ &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
89666+ &current->signal->saved_ip);
89667+ goto exit;
89668+ }
89669+ goto exit_fail;
89670+ }
89671+
89672+inet_check:
89673+ /* the rest of this checking is for IPv4 only */
89674+ if (!curr->ips)
89675+ goto exit;
89676+
89677+ if ((curr->ip_type & (1U << type)) &&
89678+ (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
89679+ goto exit;
89680+
89681+ if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
89682+ /* we don't place acls on raw sockets , and sometimes
89683+ dgram/ip sockets are opened for ioctl and not
89684+ bind/connect, so we'll fake a bind learn log */
89685+ if (type == SOCK_RAW || type == SOCK_PACKET) {
89686+ __u32 fakeip = 0;
89687+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
89688+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
89689+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
89690+ gr_to_filename(current->exec_file->f_path.dentry,
89691+ current->exec_file->f_path.mnt) :
89692+ curr->filename, curr->filename,
89693+ &fakeip, 0, type,
89694+ protocol, GR_CONNECT, &current->signal->saved_ip);
89695+ } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
89696+ __u32 fakeip = 0;
89697+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
89698+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
89699+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
89700+ gr_to_filename(current->exec_file->f_path.dentry,
89701+ current->exec_file->f_path.mnt) :
89702+ curr->filename, curr->filename,
89703+ &fakeip, 0, type,
89704+ protocol, GR_BIND, &current->signal->saved_ip);
89705+ }
89706+ /* we'll log when they use connect or bind */
89707+ goto exit;
89708+ }
89709+
89710+exit_fail:
89711+ if (domain == PF_INET)
89712+ gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
89713+ gr_socktype_to_name(type), gr_proto_to_name(protocol));
89714+ else if (rcu_access_pointer(net_families[domain]) != NULL)
89715+ gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
89716+ gr_socktype_to_name(type), protocol);
89717+
89718+ return 0;
89719+exit:
89720+ return 1;
89721+}
89722+
89723+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)
89724+{
89725+ if ((ip->mode & mode) &&
89726+ (ip_port >= ip->low) &&
89727+ (ip_port <= ip->high) &&
89728+ ((ntohl(ip_addr) & our_netmask) ==
89729+ (ntohl(our_addr) & our_netmask))
89730+ && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
89731+ && (ip->type & (1U << type))) {
89732+ if (ip->mode & GR_INVERT)
89733+ return 2; // specifically denied
89734+ else
89735+ return 1; // allowed
89736+ }
89737+
89738+ return 0; // not specifically allowed, may continue parsing
89739+}
89740+
89741+static int
89742+gr_search_connectbind(const int full_mode, struct sock *sk,
89743+ struct sockaddr_in *addr, const int type)
89744+{
89745+ char iface[IFNAMSIZ] = {0};
89746+ struct acl_subject_label *curr;
89747+ struct acl_ip_label *ip;
89748+ struct inet_sock *isk;
89749+ struct net_device *dev;
89750+ struct in_device *idev;
89751+ unsigned long i;
89752+ int ret;
89753+ int mode = full_mode & (GR_BIND | GR_CONNECT);
89754+ __u32 ip_addr = 0;
89755+ __u32 our_addr;
89756+ __u32 our_netmask;
89757+ char *p;
89758+ __u16 ip_port = 0;
89759+ const struct cred *cred = current_cred();
89760+
89761+ if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
89762+ return 0;
89763+
89764+ curr = current->acl;
89765+ isk = inet_sk(sk);
89766+
89767+ /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
89768+ if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
89769+ addr->sin_addr.s_addr = curr->inaddr_any_override;
89770+ if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
89771+ struct sockaddr_in saddr;
89772+ int err;
89773+
89774+ saddr.sin_family = AF_INET;
89775+ saddr.sin_addr.s_addr = curr->inaddr_any_override;
89776+ saddr.sin_port = isk->inet_sport;
89777+
89778+ err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
89779+ if (err)
89780+ return err;
89781+
89782+ err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
89783+ if (err)
89784+ return err;
89785+ }
89786+
89787+ if (!curr->ips)
89788+ return 0;
89789+
89790+ ip_addr = addr->sin_addr.s_addr;
89791+ ip_port = ntohs(addr->sin_port);
89792+
89793+ if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
89794+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
89795+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
89796+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
89797+ gr_to_filename(current->exec_file->f_path.dentry,
89798+ current->exec_file->f_path.mnt) :
89799+ curr->filename, curr->filename,
89800+ &ip_addr, ip_port, type,
89801+ sk->sk_protocol, mode, &current->signal->saved_ip);
89802+ return 0;
89803+ }
89804+
89805+ for (i = 0; i < curr->ip_num; i++) {
89806+ ip = *(curr->ips + i);
89807+ if (ip->iface != NULL) {
89808+ strncpy(iface, ip->iface, IFNAMSIZ - 1);
89809+ p = strchr(iface, ':');
89810+ if (p != NULL)
89811+ *p = '\0';
89812+ dev = dev_get_by_name(sock_net(sk), iface);
89813+ if (dev == NULL)
89814+ continue;
89815+ idev = in_dev_get(dev);
89816+ if (idev == NULL) {
89817+ dev_put(dev);
89818+ continue;
89819+ }
89820+ rcu_read_lock();
89821+ for_ifa(idev) {
89822+ if (!strcmp(ip->iface, ifa->ifa_label)) {
89823+ our_addr = ifa->ifa_address;
89824+ our_netmask = 0xffffffff;
89825+ ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
89826+ if (ret == 1) {
89827+ rcu_read_unlock();
89828+ in_dev_put(idev);
89829+ dev_put(dev);
89830+ return 0;
89831+ } else if (ret == 2) {
89832+ rcu_read_unlock();
89833+ in_dev_put(idev);
89834+ dev_put(dev);
89835+ goto denied;
89836+ }
89837+ }
89838+ } endfor_ifa(idev);
89839+ rcu_read_unlock();
89840+ in_dev_put(idev);
89841+ dev_put(dev);
89842+ } else {
89843+ our_addr = ip->addr;
89844+ our_netmask = ip->netmask;
89845+ ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
89846+ if (ret == 1)
89847+ return 0;
89848+ else if (ret == 2)
89849+ goto denied;
89850+ }
89851+ }
89852+
89853+denied:
89854+ if (mode == GR_BIND)
89855+ 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));
89856+ else if (mode == GR_CONNECT)
89857+ 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));
89858+
89859+ return -EACCES;
89860+}
89861+
89862+int
89863+gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
89864+{
89865+ /* always allow disconnection of dgram sockets with connect */
89866+ if (addr->sin_family == AF_UNSPEC)
89867+ return 0;
89868+ return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
89869+}
89870+
89871+int
89872+gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
89873+{
89874+ return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
89875+}
89876+
89877+int gr_search_listen(struct socket *sock)
89878+{
89879+ struct sock *sk = sock->sk;
89880+ struct sockaddr_in addr;
89881+
89882+ addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
89883+ addr.sin_port = inet_sk(sk)->inet_sport;
89884+
89885+ return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
89886+}
89887+
89888+int gr_search_accept(struct socket *sock)
89889+{
89890+ struct sock *sk = sock->sk;
89891+ struct sockaddr_in addr;
89892+
89893+ addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
89894+ addr.sin_port = inet_sk(sk)->inet_sport;
89895+
89896+ return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
89897+}
89898+
89899+int
89900+gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
89901+{
89902+ if (addr)
89903+ return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
89904+ else {
89905+ struct sockaddr_in sin;
89906+ const struct inet_sock *inet = inet_sk(sk);
89907+
89908+ sin.sin_addr.s_addr = inet->inet_daddr;
89909+ sin.sin_port = inet->inet_dport;
89910+
89911+ return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
89912+ }
89913+}
89914+
89915+int
89916+gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
89917+{
89918+ struct sockaddr_in sin;
89919+
89920+ if (unlikely(skb->len < sizeof (struct udphdr)))
89921+ return 0; // skip this packet
89922+
89923+ sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
89924+ sin.sin_port = udp_hdr(skb)->source;
89925+
89926+ return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
89927+}
89928diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
89929new file mode 100644
89930index 0000000..25f54ef
89931--- /dev/null
89932+++ b/grsecurity/gracl_learn.c
89933@@ -0,0 +1,207 @@
89934+#include <linux/kernel.h>
89935+#include <linux/mm.h>
89936+#include <linux/sched.h>
89937+#include <linux/poll.h>
89938+#include <linux/string.h>
89939+#include <linux/file.h>
89940+#include <linux/types.h>
89941+#include <linux/vmalloc.h>
89942+#include <linux/grinternal.h>
89943+
89944+extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
89945+ size_t count, loff_t *ppos);
89946+extern int gr_acl_is_enabled(void);
89947+
89948+static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
89949+static int gr_learn_attached;
89950+
89951+/* use a 512k buffer */
89952+#define LEARN_BUFFER_SIZE (512 * 1024)
89953+
89954+static DEFINE_SPINLOCK(gr_learn_lock);
89955+static DEFINE_MUTEX(gr_learn_user_mutex);
89956+
89957+/* we need to maintain two buffers, so that the kernel context of grlearn
89958+ uses a semaphore around the userspace copying, and the other kernel contexts
89959+ use a spinlock when copying into the buffer, since they cannot sleep
89960+*/
89961+static char *learn_buffer;
89962+static char *learn_buffer_user;
89963+static int learn_buffer_len;
89964+static int learn_buffer_user_len;
89965+
89966+static ssize_t
89967+read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
89968+{
89969+ DECLARE_WAITQUEUE(wait, current);
89970+ ssize_t retval = 0;
89971+
89972+ add_wait_queue(&learn_wait, &wait);
89973+ set_current_state(TASK_INTERRUPTIBLE);
89974+ do {
89975+ mutex_lock(&gr_learn_user_mutex);
89976+ spin_lock(&gr_learn_lock);
89977+ if (learn_buffer_len)
89978+ break;
89979+ spin_unlock(&gr_learn_lock);
89980+ mutex_unlock(&gr_learn_user_mutex);
89981+ if (file->f_flags & O_NONBLOCK) {
89982+ retval = -EAGAIN;
89983+ goto out;
89984+ }
89985+ if (signal_pending(current)) {
89986+ retval = -ERESTARTSYS;
89987+ goto out;
89988+ }
89989+
89990+ schedule();
89991+ } while (1);
89992+
89993+ memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
89994+ learn_buffer_user_len = learn_buffer_len;
89995+ retval = learn_buffer_len;
89996+ learn_buffer_len = 0;
89997+
89998+ spin_unlock(&gr_learn_lock);
89999+
90000+ if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
90001+ retval = -EFAULT;
90002+
90003+ mutex_unlock(&gr_learn_user_mutex);
90004+out:
90005+ set_current_state(TASK_RUNNING);
90006+ remove_wait_queue(&learn_wait, &wait);
90007+ return retval;
90008+}
90009+
90010+static unsigned int
90011+poll_learn(struct file * file, poll_table * wait)
90012+{
90013+ poll_wait(file, &learn_wait, wait);
90014+
90015+ if (learn_buffer_len)
90016+ return (POLLIN | POLLRDNORM);
90017+
90018+ return 0;
90019+}
90020+
90021+void
90022+gr_clear_learn_entries(void)
90023+{
90024+ char *tmp;
90025+
90026+ mutex_lock(&gr_learn_user_mutex);
90027+ spin_lock(&gr_learn_lock);
90028+ tmp = learn_buffer;
90029+ learn_buffer = NULL;
90030+ spin_unlock(&gr_learn_lock);
90031+ if (tmp)
90032+ vfree(tmp);
90033+ if (learn_buffer_user != NULL) {
90034+ vfree(learn_buffer_user);
90035+ learn_buffer_user = NULL;
90036+ }
90037+ learn_buffer_len = 0;
90038+ mutex_unlock(&gr_learn_user_mutex);
90039+
90040+ return;
90041+}
90042+
90043+void
90044+gr_add_learn_entry(const char *fmt, ...)
90045+{
90046+ va_list args;
90047+ unsigned int len;
90048+
90049+ if (!gr_learn_attached)
90050+ return;
90051+
90052+ spin_lock(&gr_learn_lock);
90053+
90054+ /* leave a gap at the end so we know when it's "full" but don't have to
90055+ compute the exact length of the string we're trying to append
90056+ */
90057+ if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
90058+ spin_unlock(&gr_learn_lock);
90059+ wake_up_interruptible(&learn_wait);
90060+ return;
90061+ }
90062+ if (learn_buffer == NULL) {
90063+ spin_unlock(&gr_learn_lock);
90064+ return;
90065+ }
90066+
90067+ va_start(args, fmt);
90068+ len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
90069+ va_end(args);
90070+
90071+ learn_buffer_len += len + 1;
90072+
90073+ spin_unlock(&gr_learn_lock);
90074+ wake_up_interruptible(&learn_wait);
90075+
90076+ return;
90077+}
90078+
90079+static int
90080+open_learn(struct inode *inode, struct file *file)
90081+{
90082+ if (file->f_mode & FMODE_READ && gr_learn_attached)
90083+ return -EBUSY;
90084+ if (file->f_mode & FMODE_READ) {
90085+ int retval = 0;
90086+ mutex_lock(&gr_learn_user_mutex);
90087+ if (learn_buffer == NULL)
90088+ learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
90089+ if (learn_buffer_user == NULL)
90090+ learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
90091+ if (learn_buffer == NULL) {
90092+ retval = -ENOMEM;
90093+ goto out_error;
90094+ }
90095+ if (learn_buffer_user == NULL) {
90096+ retval = -ENOMEM;
90097+ goto out_error;
90098+ }
90099+ learn_buffer_len = 0;
90100+ learn_buffer_user_len = 0;
90101+ gr_learn_attached = 1;
90102+out_error:
90103+ mutex_unlock(&gr_learn_user_mutex);
90104+ return retval;
90105+ }
90106+ return 0;
90107+}
90108+
90109+static int
90110+close_learn(struct inode *inode, struct file *file)
90111+{
90112+ if (file->f_mode & FMODE_READ) {
90113+ char *tmp = NULL;
90114+ mutex_lock(&gr_learn_user_mutex);
90115+ spin_lock(&gr_learn_lock);
90116+ tmp = learn_buffer;
90117+ learn_buffer = NULL;
90118+ spin_unlock(&gr_learn_lock);
90119+ if (tmp)
90120+ vfree(tmp);
90121+ if (learn_buffer_user != NULL) {
90122+ vfree(learn_buffer_user);
90123+ learn_buffer_user = NULL;
90124+ }
90125+ learn_buffer_len = 0;
90126+ learn_buffer_user_len = 0;
90127+ gr_learn_attached = 0;
90128+ mutex_unlock(&gr_learn_user_mutex);
90129+ }
90130+
90131+ return 0;
90132+}
90133+
90134+const struct file_operations grsec_fops = {
90135+ .read = read_learn,
90136+ .write = write_grsec_handler,
90137+ .open = open_learn,
90138+ .release = close_learn,
90139+ .poll = poll_learn,
90140+};
90141diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
90142new file mode 100644
90143index 0000000..0773423
90144--- /dev/null
90145+++ b/grsecurity/gracl_policy.c
90146@@ -0,0 +1,1786 @@
90147+#include <linux/kernel.h>
90148+#include <linux/module.h>
90149+#include <linux/sched.h>
90150+#include <linux/mm.h>
90151+#include <linux/file.h>
90152+#include <linux/fs.h>
90153+#include <linux/namei.h>
90154+#include <linux/mount.h>
90155+#include <linux/tty.h>
90156+#include <linux/proc_fs.h>
90157+#include <linux/lglock.h>
90158+#include <linux/slab.h>
90159+#include <linux/vmalloc.h>
90160+#include <linux/types.h>
90161+#include <linux/sysctl.h>
90162+#include <linux/netdevice.h>
90163+#include <linux/ptrace.h>
90164+#include <linux/gracl.h>
90165+#include <linux/gralloc.h>
90166+#include <linux/security.h>
90167+#include <linux/grinternal.h>
90168+#include <linux/pid_namespace.h>
90169+#include <linux/stop_machine.h>
90170+#include <linux/fdtable.h>
90171+#include <linux/percpu.h>
90172+#include <linux/lglock.h>
90173+#include <linux/hugetlb.h>
90174+#include <linux/posix-timers.h>
90175+#include "../fs/mount.h"
90176+
90177+#include <asm/uaccess.h>
90178+#include <asm/errno.h>
90179+#include <asm/mman.h>
90180+
90181+extern struct gr_policy_state *polstate;
90182+
90183+#define FOR_EACH_ROLE_START(role) \
90184+ role = polstate->role_list; \
90185+ while (role) {
90186+
90187+#define FOR_EACH_ROLE_END(role) \
90188+ role = role->prev; \
90189+ }
90190+
90191+struct path gr_real_root;
90192+
90193+extern struct gr_alloc_state *current_alloc_state;
90194+
90195+u16 acl_sp_role_value;
90196+
90197+static DEFINE_MUTEX(gr_dev_mutex);
90198+
90199+extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
90200+extern void gr_clear_learn_entries(void);
90201+
90202+struct gr_arg *gr_usermode __read_only;
90203+unsigned char *gr_system_salt __read_only;
90204+unsigned char *gr_system_sum __read_only;
90205+
90206+static unsigned int gr_auth_attempts = 0;
90207+static unsigned long gr_auth_expires = 0UL;
90208+
90209+struct acl_object_label *fakefs_obj_rw;
90210+struct acl_object_label *fakefs_obj_rwx;
90211+
90212+extern int gr_init_uidset(void);
90213+extern void gr_free_uidset(void);
90214+extern void gr_remove_uid(uid_t uid);
90215+extern int gr_find_uid(uid_t uid);
90216+
90217+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);
90218+extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
90219+extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
90220+extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
90221+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);
90222+extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
90223+extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
90224+extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
90225+extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
90226+extern struct acl_subject_label *lookup_acl_subj_label(const u64 ino, const dev_t dev, const struct acl_role_label *role);
90227+extern struct acl_subject_label *lookup_acl_subj_label_deleted(const u64 ino, const dev_t dev, const struct acl_role_label *role);
90228+extern void assign_special_role(const char *rolename);
90229+extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
90230+extern int gr_rbac_disable(void *unused);
90231+extern void gr_enable_rbac_system(void);
90232+
90233+static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
90234+{
90235+ if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
90236+ return -EFAULT;
90237+
90238+ return 0;
90239+}
90240+
90241+static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
90242+{
90243+ if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
90244+ return -EFAULT;
90245+
90246+ return 0;
90247+}
90248+
90249+static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
90250+{
90251+ if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
90252+ return -EFAULT;
90253+
90254+ return 0;
90255+}
90256+
90257+static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
90258+{
90259+ if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
90260+ return -EFAULT;
90261+
90262+ return 0;
90263+}
90264+
90265+static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
90266+{
90267+ if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
90268+ return -EFAULT;
90269+
90270+ return 0;
90271+}
90272+
90273+static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
90274+{
90275+ if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
90276+ return -EFAULT;
90277+
90278+ return 0;
90279+}
90280+
90281+static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
90282+{
90283+ if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
90284+ return -EFAULT;
90285+
90286+ return 0;
90287+}
90288+
90289+static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
90290+{
90291+ if (copy_from_user(trans, userp, sizeof(struct role_transition)))
90292+ return -EFAULT;
90293+
90294+ return 0;
90295+}
90296+
90297+int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
90298+{
90299+ if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
90300+ return -EFAULT;
90301+
90302+ return 0;
90303+}
90304+
90305+static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
90306+{
90307+ if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
90308+ return -EFAULT;
90309+
90310+ if ((uwrap->version != GRSECURITY_VERSION) ||
90311+ (uwrap->size != sizeof(struct gr_arg)))
90312+ return -EINVAL;
90313+
90314+ return 0;
90315+}
90316+
90317+static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
90318+{
90319+ if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
90320+ return -EFAULT;
90321+
90322+ return 0;
90323+}
90324+
90325+static size_t get_gr_arg_wrapper_size_normal(void)
90326+{
90327+ return sizeof(struct gr_arg_wrapper);
90328+}
90329+
90330+#ifdef CONFIG_COMPAT
90331+extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
90332+extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
90333+extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
90334+extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
90335+extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
90336+extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
90337+extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
90338+extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
90339+extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
90340+extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
90341+extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
90342+extern size_t get_gr_arg_wrapper_size_compat(void);
90343+
90344+int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
90345+int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
90346+int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
90347+int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
90348+int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
90349+int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
90350+int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
90351+int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
90352+int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
90353+int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
90354+int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
90355+size_t (* get_gr_arg_wrapper_size)(void) __read_only;
90356+
90357+#else
90358+#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
90359+#define copy_gr_arg copy_gr_arg_normal
90360+#define copy_gr_hash_struct copy_gr_hash_struct_normal
90361+#define copy_acl_object_label copy_acl_object_label_normal
90362+#define copy_acl_subject_label copy_acl_subject_label_normal
90363+#define copy_acl_role_label copy_acl_role_label_normal
90364+#define copy_acl_ip_label copy_acl_ip_label_normal
90365+#define copy_pointer_from_array copy_pointer_from_array_normal
90366+#define copy_sprole_pw copy_sprole_pw_normal
90367+#define copy_role_transition copy_role_transition_normal
90368+#define copy_role_allowed_ip copy_role_allowed_ip_normal
90369+#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
90370+#endif
90371+
90372+static struct acl_subject_label *
90373+lookup_subject_map(const struct acl_subject_label *userp)
90374+{
90375+ unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
90376+ struct subject_map *match;
90377+
90378+ match = polstate->subj_map_set.s_hash[index];
90379+
90380+ while (match && match->user != userp)
90381+ match = match->next;
90382+
90383+ if (match != NULL)
90384+ return match->kernel;
90385+ else
90386+ return NULL;
90387+}
90388+
90389+static void
90390+insert_subj_map_entry(struct subject_map *subjmap)
90391+{
90392+ unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
90393+ struct subject_map **curr;
90394+
90395+ subjmap->prev = NULL;
90396+
90397+ curr = &polstate->subj_map_set.s_hash[index];
90398+ if (*curr != NULL)
90399+ (*curr)->prev = subjmap;
90400+
90401+ subjmap->next = *curr;
90402+ *curr = subjmap;
90403+
90404+ return;
90405+}
90406+
90407+static void
90408+__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
90409+{
90410+ unsigned int index =
90411+ gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
90412+ struct acl_role_label **curr;
90413+ struct acl_role_label *tmp, *tmp2;
90414+
90415+ curr = &polstate->acl_role_set.r_hash[index];
90416+
90417+ /* simple case, slot is empty, just set it to our role */
90418+ if (*curr == NULL) {
90419+ *curr = role;
90420+ } else {
90421+ /* example:
90422+ 1 -> 2 -> 3 (adding 2 -> 3 to here)
90423+ 2 -> 3
90424+ */
90425+ /* first check to see if we can already be reached via this slot */
90426+ tmp = *curr;
90427+ while (tmp && tmp != role)
90428+ tmp = tmp->next;
90429+ if (tmp == role) {
90430+ /* we don't need to add ourselves to this slot's chain */
90431+ return;
90432+ }
90433+ /* we need to add ourselves to this chain, two cases */
90434+ if (role->next == NULL) {
90435+ /* simple case, append the current chain to our role */
90436+ role->next = *curr;
90437+ *curr = role;
90438+ } else {
90439+ /* 1 -> 2 -> 3 -> 4
90440+ 2 -> 3 -> 4
90441+ 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
90442+ */
90443+ /* trickier case: walk our role's chain until we find
90444+ the role for the start of the current slot's chain */
90445+ tmp = role;
90446+ tmp2 = *curr;
90447+ while (tmp->next && tmp->next != tmp2)
90448+ tmp = tmp->next;
90449+ if (tmp->next == tmp2) {
90450+ /* from example above, we found 3, so just
90451+ replace this slot's chain with ours */
90452+ *curr = role;
90453+ } else {
90454+ /* we didn't find a subset of our role's chain
90455+ in the current slot's chain, so append their
90456+ chain to ours, and set us as the first role in
90457+ the slot's chain
90458+
90459+ we could fold this case with the case above,
90460+ but making it explicit for clarity
90461+ */
90462+ tmp->next = tmp2;
90463+ *curr = role;
90464+ }
90465+ }
90466+ }
90467+
90468+ return;
90469+}
90470+
90471+static void
90472+insert_acl_role_label(struct acl_role_label *role)
90473+{
90474+ int i;
90475+
90476+ if (polstate->role_list == NULL) {
90477+ polstate->role_list = role;
90478+ role->prev = NULL;
90479+ } else {
90480+ role->prev = polstate->role_list;
90481+ polstate->role_list = role;
90482+ }
90483+
90484+ /* used for hash chains */
90485+ role->next = NULL;
90486+
90487+ if (role->roletype & GR_ROLE_DOMAIN) {
90488+ for (i = 0; i < role->domain_child_num; i++)
90489+ __insert_acl_role_label(role, role->domain_children[i]);
90490+ } else
90491+ __insert_acl_role_label(role, role->uidgid);
90492+}
90493+
90494+static int
90495+insert_name_entry(char *name, const u64 inode, const dev_t device, __u8 deleted)
90496+{
90497+ struct name_entry **curr, *nentry;
90498+ struct inodev_entry *ientry;
90499+ unsigned int len = strlen(name);
90500+ unsigned int key = full_name_hash(name, len);
90501+ unsigned int index = key % polstate->name_set.n_size;
90502+
90503+ curr = &polstate->name_set.n_hash[index];
90504+
90505+ while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
90506+ curr = &((*curr)->next);
90507+
90508+ if (*curr != NULL)
90509+ return 1;
90510+
90511+ nentry = acl_alloc(sizeof (struct name_entry));
90512+ if (nentry == NULL)
90513+ return 0;
90514+ ientry = acl_alloc(sizeof (struct inodev_entry));
90515+ if (ientry == NULL)
90516+ return 0;
90517+ ientry->nentry = nentry;
90518+
90519+ nentry->key = key;
90520+ nentry->name = name;
90521+ nentry->inode = inode;
90522+ nentry->device = device;
90523+ nentry->len = len;
90524+ nentry->deleted = deleted;
90525+
90526+ nentry->prev = NULL;
90527+ curr = &polstate->name_set.n_hash[index];
90528+ if (*curr != NULL)
90529+ (*curr)->prev = nentry;
90530+ nentry->next = *curr;
90531+ *curr = nentry;
90532+
90533+ /* insert us into the table searchable by inode/dev */
90534+ __insert_inodev_entry(polstate, ientry);
90535+
90536+ return 1;
90537+}
90538+
90539+/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
90540+
90541+static void *
90542+create_table(__u32 * len, int elementsize)
90543+{
90544+ unsigned int table_sizes[] = {
90545+ 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
90546+ 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
90547+ 4194301, 8388593, 16777213, 33554393, 67108859
90548+ };
90549+ void *newtable = NULL;
90550+ unsigned int pwr = 0;
90551+
90552+ while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
90553+ table_sizes[pwr] <= *len)
90554+ pwr++;
90555+
90556+ if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
90557+ return newtable;
90558+
90559+ if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
90560+ newtable =
90561+ kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
90562+ else
90563+ newtable = vmalloc(table_sizes[pwr] * elementsize);
90564+
90565+ *len = table_sizes[pwr];
90566+
90567+ return newtable;
90568+}
90569+
90570+static int
90571+init_variables(const struct gr_arg *arg, bool reload)
90572+{
90573+ struct task_struct *reaper = init_pid_ns.child_reaper;
90574+ unsigned int stacksize;
90575+
90576+ polstate->subj_map_set.s_size = arg->role_db.num_subjects;
90577+ polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
90578+ polstate->name_set.n_size = arg->role_db.num_objects;
90579+ polstate->inodev_set.i_size = arg->role_db.num_objects;
90580+
90581+ if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
90582+ !polstate->name_set.n_size || !polstate->inodev_set.i_size)
90583+ return 1;
90584+
90585+ if (!reload) {
90586+ if (!gr_init_uidset())
90587+ return 1;
90588+ }
90589+
90590+ /* set up the stack that holds allocation info */
90591+
90592+ stacksize = arg->role_db.num_pointers + 5;
90593+
90594+ if (!acl_alloc_stack_init(stacksize))
90595+ return 1;
90596+
90597+ if (!reload) {
90598+ /* grab reference for the real root dentry and vfsmount */
90599+ get_fs_root(reaper->fs, &gr_real_root);
90600+
90601+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
90602+ 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));
90603+#endif
90604+
90605+ fakefs_obj_rw = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
90606+ if (fakefs_obj_rw == NULL)
90607+ return 1;
90608+ fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
90609+
90610+ fakefs_obj_rwx = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
90611+ if (fakefs_obj_rwx == NULL)
90612+ return 1;
90613+ fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
90614+ }
90615+
90616+ polstate->subj_map_set.s_hash =
90617+ (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
90618+ polstate->acl_role_set.r_hash =
90619+ (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
90620+ polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
90621+ polstate->inodev_set.i_hash =
90622+ (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
90623+
90624+ if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
90625+ !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
90626+ return 1;
90627+
90628+ memset(polstate->subj_map_set.s_hash, 0,
90629+ sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
90630+ memset(polstate->acl_role_set.r_hash, 0,
90631+ sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
90632+ memset(polstate->name_set.n_hash, 0,
90633+ sizeof (struct name_entry *) * polstate->name_set.n_size);
90634+ memset(polstate->inodev_set.i_hash, 0,
90635+ sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
90636+
90637+ return 0;
90638+}
90639+
90640+/* free information not needed after startup
90641+ currently contains user->kernel pointer mappings for subjects
90642+*/
90643+
90644+static void
90645+free_init_variables(void)
90646+{
90647+ __u32 i;
90648+
90649+ if (polstate->subj_map_set.s_hash) {
90650+ for (i = 0; i < polstate->subj_map_set.s_size; i++) {
90651+ if (polstate->subj_map_set.s_hash[i]) {
90652+ kfree(polstate->subj_map_set.s_hash[i]);
90653+ polstate->subj_map_set.s_hash[i] = NULL;
90654+ }
90655+ }
90656+
90657+ if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
90658+ PAGE_SIZE)
90659+ kfree(polstate->subj_map_set.s_hash);
90660+ else
90661+ vfree(polstate->subj_map_set.s_hash);
90662+ }
90663+
90664+ return;
90665+}
90666+
90667+static void
90668+free_variables(bool reload)
90669+{
90670+ struct acl_subject_label *s;
90671+ struct acl_role_label *r;
90672+ struct task_struct *task, *task2;
90673+ unsigned int x;
90674+
90675+ if (!reload) {
90676+ gr_clear_learn_entries();
90677+
90678+ read_lock(&tasklist_lock);
90679+ do_each_thread(task2, task) {
90680+ task->acl_sp_role = 0;
90681+ task->acl_role_id = 0;
90682+ task->inherited = 0;
90683+ task->acl = NULL;
90684+ task->role = NULL;
90685+ } while_each_thread(task2, task);
90686+ read_unlock(&tasklist_lock);
90687+
90688+ kfree(fakefs_obj_rw);
90689+ fakefs_obj_rw = NULL;
90690+ kfree(fakefs_obj_rwx);
90691+ fakefs_obj_rwx = NULL;
90692+
90693+ /* release the reference to the real root dentry and vfsmount */
90694+ path_put(&gr_real_root);
90695+ memset(&gr_real_root, 0, sizeof(gr_real_root));
90696+ }
90697+
90698+ /* free all object hash tables */
90699+
90700+ FOR_EACH_ROLE_START(r)
90701+ if (r->subj_hash == NULL)
90702+ goto next_role;
90703+ FOR_EACH_SUBJECT_START(r, s, x)
90704+ if (s->obj_hash == NULL)
90705+ break;
90706+ if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
90707+ kfree(s->obj_hash);
90708+ else
90709+ vfree(s->obj_hash);
90710+ FOR_EACH_SUBJECT_END(s, x)
90711+ FOR_EACH_NESTED_SUBJECT_START(r, s)
90712+ if (s->obj_hash == NULL)
90713+ break;
90714+ if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
90715+ kfree(s->obj_hash);
90716+ else
90717+ vfree(s->obj_hash);
90718+ FOR_EACH_NESTED_SUBJECT_END(s)
90719+ if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
90720+ kfree(r->subj_hash);
90721+ else
90722+ vfree(r->subj_hash);
90723+ r->subj_hash = NULL;
90724+next_role:
90725+ FOR_EACH_ROLE_END(r)
90726+
90727+ acl_free_all();
90728+
90729+ if (polstate->acl_role_set.r_hash) {
90730+ if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
90731+ PAGE_SIZE)
90732+ kfree(polstate->acl_role_set.r_hash);
90733+ else
90734+ vfree(polstate->acl_role_set.r_hash);
90735+ }
90736+ if (polstate->name_set.n_hash) {
90737+ if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
90738+ PAGE_SIZE)
90739+ kfree(polstate->name_set.n_hash);
90740+ else
90741+ vfree(polstate->name_set.n_hash);
90742+ }
90743+
90744+ if (polstate->inodev_set.i_hash) {
90745+ if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
90746+ PAGE_SIZE)
90747+ kfree(polstate->inodev_set.i_hash);
90748+ else
90749+ vfree(polstate->inodev_set.i_hash);
90750+ }
90751+
90752+ if (!reload)
90753+ gr_free_uidset();
90754+
90755+ memset(&polstate->name_set, 0, sizeof (struct name_db));
90756+ memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
90757+ memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
90758+ memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
90759+
90760+ polstate->default_role = NULL;
90761+ polstate->kernel_role = NULL;
90762+ polstate->role_list = NULL;
90763+
90764+ return;
90765+}
90766+
90767+static struct acl_subject_label *
90768+do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
90769+
90770+static int alloc_and_copy_string(char **name, unsigned int maxlen)
90771+{
90772+ unsigned int len = strnlen_user(*name, maxlen);
90773+ char *tmp;
90774+
90775+ if (!len || len >= maxlen)
90776+ return -EINVAL;
90777+
90778+ if ((tmp = (char *) acl_alloc(len)) == NULL)
90779+ return -ENOMEM;
90780+
90781+ if (copy_from_user(tmp, *name, len))
90782+ return -EFAULT;
90783+
90784+ tmp[len-1] = '\0';
90785+ *name = tmp;
90786+
90787+ return 0;
90788+}
90789+
90790+static int
90791+copy_user_glob(struct acl_object_label *obj)
90792+{
90793+ struct acl_object_label *g_tmp, **guser;
90794+ int error;
90795+
90796+ if (obj->globbed == NULL)
90797+ return 0;
90798+
90799+ guser = &obj->globbed;
90800+ while (*guser) {
90801+ g_tmp = (struct acl_object_label *)
90802+ acl_alloc(sizeof (struct acl_object_label));
90803+ if (g_tmp == NULL)
90804+ return -ENOMEM;
90805+
90806+ if (copy_acl_object_label(g_tmp, *guser))
90807+ return -EFAULT;
90808+
90809+ error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
90810+ if (error)
90811+ return error;
90812+
90813+ *guser = g_tmp;
90814+ guser = &(g_tmp->next);
90815+ }
90816+
90817+ return 0;
90818+}
90819+
90820+static int
90821+copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
90822+ struct acl_role_label *role)
90823+{
90824+ struct acl_object_label *o_tmp;
90825+ int ret;
90826+
90827+ while (userp) {
90828+ if ((o_tmp = (struct acl_object_label *)
90829+ acl_alloc(sizeof (struct acl_object_label))) == NULL)
90830+ return -ENOMEM;
90831+
90832+ if (copy_acl_object_label(o_tmp, userp))
90833+ return -EFAULT;
90834+
90835+ userp = o_tmp->prev;
90836+
90837+ ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
90838+ if (ret)
90839+ return ret;
90840+
90841+ insert_acl_obj_label(o_tmp, subj);
90842+ if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
90843+ o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
90844+ return -ENOMEM;
90845+
90846+ ret = copy_user_glob(o_tmp);
90847+ if (ret)
90848+ return ret;
90849+
90850+ if (o_tmp->nested) {
90851+ int already_copied;
90852+
90853+ o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
90854+ if (IS_ERR(o_tmp->nested))
90855+ return PTR_ERR(o_tmp->nested);
90856+
90857+ /* insert into nested subject list if we haven't copied this one yet
90858+ to prevent duplicate entries */
90859+ if (!already_copied) {
90860+ o_tmp->nested->next = role->hash->first;
90861+ role->hash->first = o_tmp->nested;
90862+ }
90863+ }
90864+ }
90865+
90866+ return 0;
90867+}
90868+
90869+static __u32
90870+count_user_subjs(struct acl_subject_label *userp)
90871+{
90872+ struct acl_subject_label s_tmp;
90873+ __u32 num = 0;
90874+
90875+ while (userp) {
90876+ if (copy_acl_subject_label(&s_tmp, userp))
90877+ break;
90878+
90879+ userp = s_tmp.prev;
90880+ }
90881+
90882+ return num;
90883+}
90884+
90885+static int
90886+copy_user_allowedips(struct acl_role_label *rolep)
90887+{
90888+ struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
90889+
90890+ ruserip = rolep->allowed_ips;
90891+
90892+ while (ruserip) {
90893+ rlast = rtmp;
90894+
90895+ if ((rtmp = (struct role_allowed_ip *)
90896+ acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
90897+ return -ENOMEM;
90898+
90899+ if (copy_role_allowed_ip(rtmp, ruserip))
90900+ return -EFAULT;
90901+
90902+ ruserip = rtmp->prev;
90903+
90904+ if (!rlast) {
90905+ rtmp->prev = NULL;
90906+ rolep->allowed_ips = rtmp;
90907+ } else {
90908+ rlast->next = rtmp;
90909+ rtmp->prev = rlast;
90910+ }
90911+
90912+ if (!ruserip)
90913+ rtmp->next = NULL;
90914+ }
90915+
90916+ return 0;
90917+}
90918+
90919+static int
90920+copy_user_transitions(struct acl_role_label *rolep)
90921+{
90922+ struct role_transition *rusertp, *rtmp = NULL, *rlast;
90923+ int error;
90924+
90925+ rusertp = rolep->transitions;
90926+
90927+ while (rusertp) {
90928+ rlast = rtmp;
90929+
90930+ if ((rtmp = (struct role_transition *)
90931+ acl_alloc(sizeof (struct role_transition))) == NULL)
90932+ return -ENOMEM;
90933+
90934+ if (copy_role_transition(rtmp, rusertp))
90935+ return -EFAULT;
90936+
90937+ rusertp = rtmp->prev;
90938+
90939+ error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
90940+ if (error)
90941+ return error;
90942+
90943+ if (!rlast) {
90944+ rtmp->prev = NULL;
90945+ rolep->transitions = rtmp;
90946+ } else {
90947+ rlast->next = rtmp;
90948+ rtmp->prev = rlast;
90949+ }
90950+
90951+ if (!rusertp)
90952+ rtmp->next = NULL;
90953+ }
90954+
90955+ return 0;
90956+}
90957+
90958+static __u32 count_user_objs(const struct acl_object_label __user *userp)
90959+{
90960+ struct acl_object_label o_tmp;
90961+ __u32 num = 0;
90962+
90963+ while (userp) {
90964+ if (copy_acl_object_label(&o_tmp, userp))
90965+ break;
90966+
90967+ userp = o_tmp.prev;
90968+ num++;
90969+ }
90970+
90971+ return num;
90972+}
90973+
90974+static struct acl_subject_label *
90975+do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
90976+{
90977+ struct acl_subject_label *s_tmp = NULL, *s_tmp2;
90978+ __u32 num_objs;
90979+ struct acl_ip_label **i_tmp, *i_utmp2;
90980+ struct gr_hash_struct ghash;
90981+ struct subject_map *subjmap;
90982+ unsigned int i_num;
90983+ int err;
90984+
90985+ if (already_copied != NULL)
90986+ *already_copied = 0;
90987+
90988+ s_tmp = lookup_subject_map(userp);
90989+
90990+ /* we've already copied this subject into the kernel, just return
90991+ the reference to it, and don't copy it over again
90992+ */
90993+ if (s_tmp) {
90994+ if (already_copied != NULL)
90995+ *already_copied = 1;
90996+ return(s_tmp);
90997+ }
90998+
90999+ if ((s_tmp = (struct acl_subject_label *)
91000+ acl_alloc(sizeof (struct acl_subject_label))) == NULL)
91001+ return ERR_PTR(-ENOMEM);
91002+
91003+ subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
91004+ if (subjmap == NULL)
91005+ return ERR_PTR(-ENOMEM);
91006+
91007+ subjmap->user = userp;
91008+ subjmap->kernel = s_tmp;
91009+ insert_subj_map_entry(subjmap);
91010+
91011+ if (copy_acl_subject_label(s_tmp, userp))
91012+ return ERR_PTR(-EFAULT);
91013+
91014+ err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
91015+ if (err)
91016+ return ERR_PTR(err);
91017+
91018+ if (!strcmp(s_tmp->filename, "/"))
91019+ role->root_label = s_tmp;
91020+
91021+ if (copy_gr_hash_struct(&ghash, s_tmp->hash))
91022+ return ERR_PTR(-EFAULT);
91023+
91024+ /* copy user and group transition tables */
91025+
91026+ if (s_tmp->user_trans_num) {
91027+ uid_t *uidlist;
91028+
91029+ uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
91030+ if (uidlist == NULL)
91031+ return ERR_PTR(-ENOMEM);
91032+ if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
91033+ return ERR_PTR(-EFAULT);
91034+
91035+ s_tmp->user_transitions = uidlist;
91036+ }
91037+
91038+ if (s_tmp->group_trans_num) {
91039+ gid_t *gidlist;
91040+
91041+ gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
91042+ if (gidlist == NULL)
91043+ return ERR_PTR(-ENOMEM);
91044+ if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
91045+ return ERR_PTR(-EFAULT);
91046+
91047+ s_tmp->group_transitions = gidlist;
91048+ }
91049+
91050+ /* set up object hash table */
91051+ num_objs = count_user_objs(ghash.first);
91052+
91053+ s_tmp->obj_hash_size = num_objs;
91054+ s_tmp->obj_hash =
91055+ (struct acl_object_label **)
91056+ create_table(&(s_tmp->obj_hash_size), sizeof(void *));
91057+
91058+ if (!s_tmp->obj_hash)
91059+ return ERR_PTR(-ENOMEM);
91060+
91061+ memset(s_tmp->obj_hash, 0,
91062+ s_tmp->obj_hash_size *
91063+ sizeof (struct acl_object_label *));
91064+
91065+ /* add in objects */
91066+ err = copy_user_objs(ghash.first, s_tmp, role);
91067+
91068+ if (err)
91069+ return ERR_PTR(err);
91070+
91071+ /* set pointer for parent subject */
91072+ if (s_tmp->parent_subject) {
91073+ s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
91074+
91075+ if (IS_ERR(s_tmp2))
91076+ return s_tmp2;
91077+
91078+ s_tmp->parent_subject = s_tmp2;
91079+ }
91080+
91081+ /* add in ip acls */
91082+
91083+ if (!s_tmp->ip_num) {
91084+ s_tmp->ips = NULL;
91085+ goto insert;
91086+ }
91087+
91088+ i_tmp =
91089+ (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
91090+ sizeof (struct acl_ip_label *));
91091+
91092+ if (!i_tmp)
91093+ return ERR_PTR(-ENOMEM);
91094+
91095+ for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
91096+ *(i_tmp + i_num) =
91097+ (struct acl_ip_label *)
91098+ acl_alloc(sizeof (struct acl_ip_label));
91099+ if (!*(i_tmp + i_num))
91100+ return ERR_PTR(-ENOMEM);
91101+
91102+ if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
91103+ return ERR_PTR(-EFAULT);
91104+
91105+ if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
91106+ return ERR_PTR(-EFAULT);
91107+
91108+ if ((*(i_tmp + i_num))->iface == NULL)
91109+ continue;
91110+
91111+ err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
91112+ if (err)
91113+ return ERR_PTR(err);
91114+ }
91115+
91116+ s_tmp->ips = i_tmp;
91117+
91118+insert:
91119+ if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
91120+ s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
91121+ return ERR_PTR(-ENOMEM);
91122+
91123+ return s_tmp;
91124+}
91125+
91126+static int
91127+copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
91128+{
91129+ struct acl_subject_label s_pre;
91130+ struct acl_subject_label * ret;
91131+ int err;
91132+
91133+ while (userp) {
91134+ if (copy_acl_subject_label(&s_pre, userp))
91135+ return -EFAULT;
91136+
91137+ ret = do_copy_user_subj(userp, role, NULL);
91138+
91139+ err = PTR_ERR(ret);
91140+ if (IS_ERR(ret))
91141+ return err;
91142+
91143+ insert_acl_subj_label(ret, role);
91144+
91145+ userp = s_pre.prev;
91146+ }
91147+
91148+ return 0;
91149+}
91150+
91151+static int
91152+copy_user_acl(struct gr_arg *arg)
91153+{
91154+ struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
91155+ struct acl_subject_label *subj_list;
91156+ struct sprole_pw *sptmp;
91157+ struct gr_hash_struct *ghash;
91158+ uid_t *domainlist;
91159+ unsigned int r_num;
91160+ int err = 0;
91161+ __u16 i;
91162+ __u32 num_subjs;
91163+
91164+ /* we need a default and kernel role */
91165+ if (arg->role_db.num_roles < 2)
91166+ return -EINVAL;
91167+
91168+ /* copy special role authentication info from userspace */
91169+
91170+ polstate->num_sprole_pws = arg->num_sprole_pws;
91171+ polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
91172+
91173+ if (!polstate->acl_special_roles && polstate->num_sprole_pws)
91174+ return -ENOMEM;
91175+
91176+ for (i = 0; i < polstate->num_sprole_pws; i++) {
91177+ sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
91178+ if (!sptmp)
91179+ return -ENOMEM;
91180+ if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
91181+ return -EFAULT;
91182+
91183+ err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
91184+ if (err)
91185+ return err;
91186+
91187+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
91188+ printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
91189+#endif
91190+
91191+ polstate->acl_special_roles[i] = sptmp;
91192+ }
91193+
91194+ r_utmp = (struct acl_role_label **) arg->role_db.r_table;
91195+
91196+ for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
91197+ r_tmp = acl_alloc(sizeof (struct acl_role_label));
91198+
91199+ if (!r_tmp)
91200+ return -ENOMEM;
91201+
91202+ if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
91203+ return -EFAULT;
91204+
91205+ if (copy_acl_role_label(r_tmp, r_utmp2))
91206+ return -EFAULT;
91207+
91208+ err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
91209+ if (err)
91210+ return err;
91211+
91212+ if (!strcmp(r_tmp->rolename, "default")
91213+ && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
91214+ polstate->default_role = r_tmp;
91215+ } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
91216+ polstate->kernel_role = r_tmp;
91217+ }
91218+
91219+ if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
91220+ return -ENOMEM;
91221+
91222+ if (copy_gr_hash_struct(ghash, r_tmp->hash))
91223+ return -EFAULT;
91224+
91225+ r_tmp->hash = ghash;
91226+
91227+ num_subjs = count_user_subjs(r_tmp->hash->first);
91228+
91229+ r_tmp->subj_hash_size = num_subjs;
91230+ r_tmp->subj_hash =
91231+ (struct acl_subject_label **)
91232+ create_table(&(r_tmp->subj_hash_size), sizeof(void *));
91233+
91234+ if (!r_tmp->subj_hash)
91235+ return -ENOMEM;
91236+
91237+ err = copy_user_allowedips(r_tmp);
91238+ if (err)
91239+ return err;
91240+
91241+ /* copy domain info */
91242+ if (r_tmp->domain_children != NULL) {
91243+ domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
91244+ if (domainlist == NULL)
91245+ return -ENOMEM;
91246+
91247+ if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
91248+ return -EFAULT;
91249+
91250+ r_tmp->domain_children = domainlist;
91251+ }
91252+
91253+ err = copy_user_transitions(r_tmp);
91254+ if (err)
91255+ return err;
91256+
91257+ memset(r_tmp->subj_hash, 0,
91258+ r_tmp->subj_hash_size *
91259+ sizeof (struct acl_subject_label *));
91260+
91261+ /* acquire the list of subjects, then NULL out
91262+ the list prior to parsing the subjects for this role,
91263+ as during this parsing the list is replaced with a list
91264+ of *nested* subjects for the role
91265+ */
91266+ subj_list = r_tmp->hash->first;
91267+
91268+ /* set nested subject list to null */
91269+ r_tmp->hash->first = NULL;
91270+
91271+ err = copy_user_subjs(subj_list, r_tmp);
91272+
91273+ if (err)
91274+ return err;
91275+
91276+ insert_acl_role_label(r_tmp);
91277+ }
91278+
91279+ if (polstate->default_role == NULL || polstate->kernel_role == NULL)
91280+ return -EINVAL;
91281+
91282+ return err;
91283+}
91284+
91285+static int gracl_reload_apply_policies(void *reload)
91286+{
91287+ struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
91288+ struct task_struct *task, *task2;
91289+ struct acl_role_label *role, *rtmp;
91290+ struct acl_subject_label *subj;
91291+ const struct cred *cred;
91292+ int role_applied;
91293+ int ret = 0;
91294+
91295+ memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_policy_state));
91296+ memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
91297+
91298+ /* first make sure we'll be able to apply the new policy cleanly */
91299+ do_each_thread(task2, task) {
91300+ if (task->exec_file == NULL)
91301+ continue;
91302+ role_applied = 0;
91303+ if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
91304+ /* preserve special roles */
91305+ FOR_EACH_ROLE_START(role)
91306+ if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
91307+ rtmp = task->role;
91308+ task->role = role;
91309+ role_applied = 1;
91310+ break;
91311+ }
91312+ FOR_EACH_ROLE_END(role)
91313+ }
91314+ if (!role_applied) {
91315+ cred = __task_cred(task);
91316+ rtmp = task->role;
91317+ task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
91318+ }
91319+ /* this handles non-nested inherited subjects, nested subjects will still
91320+ be dropped currently */
91321+ subj = __gr_get_subject_for_task(polstate, task, task->acl->filename, 1);
91322+ task->tmpacl = __gr_get_subject_for_task(polstate, task, NULL, 1);
91323+ /* change the role back so that we've made no modifications to the policy */
91324+ task->role = rtmp;
91325+
91326+ if (subj == NULL || task->tmpacl == NULL) {
91327+ ret = -EINVAL;
91328+ goto out;
91329+ }
91330+ } while_each_thread(task2, task);
91331+
91332+ /* now actually apply the policy */
91333+
91334+ do_each_thread(task2, task) {
91335+ if (task->exec_file) {
91336+ role_applied = 0;
91337+ if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
91338+ /* preserve special roles */
91339+ FOR_EACH_ROLE_START(role)
91340+ if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
91341+ task->role = role;
91342+ role_applied = 1;
91343+ break;
91344+ }
91345+ FOR_EACH_ROLE_END(role)
91346+ }
91347+ if (!role_applied) {
91348+ cred = __task_cred(task);
91349+ task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
91350+ }
91351+ /* this handles non-nested inherited subjects, nested subjects will still
91352+ be dropped currently */
91353+ if (!reload_state->oldmode && task->inherited)
91354+ subj = __gr_get_subject_for_task(polstate, task, task->acl->filename, 1);
91355+ else {
91356+ /* looked up and tagged to the task previously */
91357+ subj = task->tmpacl;
91358+ }
91359+ /* subj will be non-null */
91360+ __gr_apply_subject_to_task(polstate, task, subj);
91361+ if (reload_state->oldmode) {
91362+ task->acl_role_id = 0;
91363+ task->acl_sp_role = 0;
91364+ task->inherited = 0;
91365+ }
91366+ } else {
91367+ // it's a kernel process
91368+ task->role = polstate->kernel_role;
91369+ task->acl = polstate->kernel_role->root_label;
91370+#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
91371+ task->acl->mode &= ~GR_PROCFIND;
91372+#endif
91373+ }
91374+ } while_each_thread(task2, task);
91375+
91376+ memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
91377+ memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
91378+
91379+out:
91380+
91381+ return ret;
91382+}
91383+
91384+static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
91385+{
91386+ struct gr_reload_state new_reload_state = { };
91387+ int err;
91388+
91389+ new_reload_state.oldpolicy_ptr = polstate;
91390+ new_reload_state.oldalloc_ptr = current_alloc_state;
91391+ new_reload_state.oldmode = oldmode;
91392+
91393+ current_alloc_state = &new_reload_state.newalloc;
91394+ polstate = &new_reload_state.newpolicy;
91395+
91396+ /* everything relevant is now saved off, copy in the new policy */
91397+ if (init_variables(args, true)) {
91398+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
91399+ err = -ENOMEM;
91400+ goto error;
91401+ }
91402+
91403+ err = copy_user_acl(args);
91404+ free_init_variables();
91405+ if (err)
91406+ goto error;
91407+ /* the new policy is copied in, with the old policy available via saved_state
91408+ first go through applying roles, making sure to preserve special roles
91409+ then apply new subjects, making sure to preserve inherited and nested subjects,
91410+ though currently only inherited subjects will be preserved
91411+ */
91412+ err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
91413+ if (err)
91414+ goto error;
91415+
91416+ /* we've now applied the new policy, so restore the old policy state to free it */
91417+ polstate = &new_reload_state.oldpolicy;
91418+ current_alloc_state = &new_reload_state.oldalloc;
91419+ free_variables(true);
91420+
91421+ /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
91422+ to running_polstate/current_alloc_state inside stop_machine
91423+ */
91424+ err = 0;
91425+ goto out;
91426+error:
91427+ /* on error of loading the new policy, we'll just keep the previous
91428+ policy set around
91429+ */
91430+ free_variables(true);
91431+
91432+ /* doesn't affect runtime, but maintains consistent state */
91433+out:
91434+ polstate = new_reload_state.oldpolicy_ptr;
91435+ current_alloc_state = new_reload_state.oldalloc_ptr;
91436+
91437+ return err;
91438+}
91439+
91440+static int
91441+gracl_init(struct gr_arg *args)
91442+{
91443+ int error = 0;
91444+
91445+ memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
91446+ memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
91447+
91448+ if (init_variables(args, false)) {
91449+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
91450+ error = -ENOMEM;
91451+ goto out;
91452+ }
91453+
91454+ error = copy_user_acl(args);
91455+ free_init_variables();
91456+ if (error)
91457+ goto out;
91458+
91459+ error = gr_set_acls(0);
91460+ if (error)
91461+ goto out;
91462+
91463+ gr_enable_rbac_system();
91464+
91465+ return 0;
91466+
91467+out:
91468+ free_variables(false);
91469+ return error;
91470+}
91471+
91472+static int
91473+lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
91474+ unsigned char **sum)
91475+{
91476+ struct acl_role_label *r;
91477+ struct role_allowed_ip *ipp;
91478+ struct role_transition *trans;
91479+ unsigned int i;
91480+ int found = 0;
91481+ u32 curr_ip = current->signal->curr_ip;
91482+
91483+ current->signal->saved_ip = curr_ip;
91484+
91485+ /* check transition table */
91486+
91487+ for (trans = current->role->transitions; trans; trans = trans->next) {
91488+ if (!strcmp(rolename, trans->rolename)) {
91489+ found = 1;
91490+ break;
91491+ }
91492+ }
91493+
91494+ if (!found)
91495+ return 0;
91496+
91497+ /* handle special roles that do not require authentication
91498+ and check ip */
91499+
91500+ FOR_EACH_ROLE_START(r)
91501+ if (!strcmp(rolename, r->rolename) &&
91502+ (r->roletype & GR_ROLE_SPECIAL)) {
91503+ found = 0;
91504+ if (r->allowed_ips != NULL) {
91505+ for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
91506+ if ((ntohl(curr_ip) & ipp->netmask) ==
91507+ (ntohl(ipp->addr) & ipp->netmask))
91508+ found = 1;
91509+ }
91510+ } else
91511+ found = 2;
91512+ if (!found)
91513+ return 0;
91514+
91515+ if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
91516+ ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
91517+ *salt = NULL;
91518+ *sum = NULL;
91519+ return 1;
91520+ }
91521+ }
91522+ FOR_EACH_ROLE_END(r)
91523+
91524+ for (i = 0; i < polstate->num_sprole_pws; i++) {
91525+ if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
91526+ *salt = polstate->acl_special_roles[i]->salt;
91527+ *sum = polstate->acl_special_roles[i]->sum;
91528+ return 1;
91529+ }
91530+ }
91531+
91532+ return 0;
91533+}
91534+
91535+int gr_check_secure_terminal(struct task_struct *task)
91536+{
91537+ struct task_struct *p, *p2, *p3;
91538+ struct files_struct *files;
91539+ struct fdtable *fdt;
91540+ struct file *our_file = NULL, *file;
91541+ struct inode *our_inode = NULL;
91542+ int i;
91543+
91544+ if (task->signal->tty == NULL)
91545+ return 1;
91546+
91547+ files = get_files_struct(task);
91548+ if (files != NULL) {
91549+ rcu_read_lock();
91550+ fdt = files_fdtable(files);
91551+ for (i=0; i < fdt->max_fds; i++) {
91552+ file = fcheck_files(files, i);
91553+ if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
91554+ get_file(file);
91555+ our_file = file;
91556+ }
91557+ }
91558+ rcu_read_unlock();
91559+ put_files_struct(files);
91560+ }
91561+
91562+ if (our_file == NULL)
91563+ return 1;
91564+
91565+ our_inode = d_backing_inode(our_file->f_path.dentry);
91566+
91567+ read_lock(&tasklist_lock);
91568+ do_each_thread(p2, p) {
91569+ files = get_files_struct(p);
91570+ if (files == NULL ||
91571+ (p->signal && p->signal->tty == task->signal->tty)) {
91572+ if (files != NULL)
91573+ put_files_struct(files);
91574+ continue;
91575+ }
91576+ rcu_read_lock();
91577+ fdt = files_fdtable(files);
91578+ for (i=0; i < fdt->max_fds; i++) {
91579+ struct inode *inode = NULL;
91580+ file = fcheck_files(files, i);
91581+ if (file)
91582+ inode = d_backing_inode(file->f_path.dentry);
91583+ if (inode && S_ISCHR(inode->i_mode) && inode->i_rdev == our_inode->i_rdev) {
91584+ p3 = task;
91585+ while (task_pid_nr(p3) > 0) {
91586+ if (p3 == p)
91587+ break;
91588+ p3 = p3->real_parent;
91589+ }
91590+ if (p3 == p)
91591+ break;
91592+ gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
91593+ gr_handle_alertkill(p);
91594+ rcu_read_unlock();
91595+ put_files_struct(files);
91596+ read_unlock(&tasklist_lock);
91597+ fput(our_file);
91598+ return 0;
91599+ }
91600+ }
91601+ rcu_read_unlock();
91602+ put_files_struct(files);
91603+ } while_each_thread(p2, p);
91604+ read_unlock(&tasklist_lock);
91605+
91606+ fput(our_file);
91607+ return 1;
91608+}
91609+
91610+ssize_t
91611+write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
91612+{
91613+ struct gr_arg_wrapper uwrap;
91614+ unsigned char *sprole_salt = NULL;
91615+ unsigned char *sprole_sum = NULL;
91616+ int error = 0;
91617+ int error2 = 0;
91618+ size_t req_count = 0;
91619+ unsigned char oldmode = 0;
91620+
91621+ mutex_lock(&gr_dev_mutex);
91622+
91623+ if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
91624+ error = -EPERM;
91625+ goto out;
91626+ }
91627+
91628+#ifdef CONFIG_COMPAT
91629+ pax_open_kernel();
91630+ if (is_compat_task()) {
91631+ copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
91632+ copy_gr_arg = &copy_gr_arg_compat;
91633+ copy_acl_object_label = &copy_acl_object_label_compat;
91634+ copy_acl_subject_label = &copy_acl_subject_label_compat;
91635+ copy_acl_role_label = &copy_acl_role_label_compat;
91636+ copy_acl_ip_label = &copy_acl_ip_label_compat;
91637+ copy_role_allowed_ip = &copy_role_allowed_ip_compat;
91638+ copy_role_transition = &copy_role_transition_compat;
91639+ copy_sprole_pw = &copy_sprole_pw_compat;
91640+ copy_gr_hash_struct = &copy_gr_hash_struct_compat;
91641+ copy_pointer_from_array = &copy_pointer_from_array_compat;
91642+ get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
91643+ } else {
91644+ copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
91645+ copy_gr_arg = &copy_gr_arg_normal;
91646+ copy_acl_object_label = &copy_acl_object_label_normal;
91647+ copy_acl_subject_label = &copy_acl_subject_label_normal;
91648+ copy_acl_role_label = &copy_acl_role_label_normal;
91649+ copy_acl_ip_label = &copy_acl_ip_label_normal;
91650+ copy_role_allowed_ip = &copy_role_allowed_ip_normal;
91651+ copy_role_transition = &copy_role_transition_normal;
91652+ copy_sprole_pw = &copy_sprole_pw_normal;
91653+ copy_gr_hash_struct = &copy_gr_hash_struct_normal;
91654+ copy_pointer_from_array = &copy_pointer_from_array_normal;
91655+ get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
91656+ }
91657+ pax_close_kernel();
91658+#endif
91659+
91660+ req_count = get_gr_arg_wrapper_size();
91661+
91662+ if (count != req_count) {
91663+ gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
91664+ error = -EINVAL;
91665+ goto out;
91666+ }
91667+
91668+
91669+ if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
91670+ gr_auth_expires = 0;
91671+ gr_auth_attempts = 0;
91672+ }
91673+
91674+ error = copy_gr_arg_wrapper(buf, &uwrap);
91675+ if (error)
91676+ goto out;
91677+
91678+ error = copy_gr_arg(uwrap.arg, gr_usermode);
91679+ if (error)
91680+ goto out;
91681+
91682+ if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
91683+ gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
91684+ time_after(gr_auth_expires, get_seconds())) {
91685+ error = -EBUSY;
91686+ goto out;
91687+ }
91688+
91689+ /* if non-root trying to do anything other than use a special role,
91690+ do not attempt authentication, do not count towards authentication
91691+ locking
91692+ */
91693+
91694+ if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
91695+ gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
91696+ gr_is_global_nonroot(current_uid())) {
91697+ error = -EPERM;
91698+ goto out;
91699+ }
91700+
91701+ /* ensure pw and special role name are null terminated */
91702+
91703+ gr_usermode->pw[GR_PW_LEN - 1] = '\0';
91704+ gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
91705+
91706+ /* Okay.
91707+ * We have our enough of the argument structure..(we have yet
91708+ * to copy_from_user the tables themselves) . Copy the tables
91709+ * only if we need them, i.e. for loading operations. */
91710+
91711+ switch (gr_usermode->mode) {
91712+ case GR_STATUS:
91713+ if (gr_acl_is_enabled()) {
91714+ error = 1;
91715+ if (!gr_check_secure_terminal(current))
91716+ error = 3;
91717+ } else
91718+ error = 2;
91719+ goto out;
91720+ case GR_SHUTDOWN:
91721+ if (gr_acl_is_enabled() && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
91722+ stop_machine(gr_rbac_disable, NULL, NULL);
91723+ free_variables(false);
91724+ memset(gr_usermode, 0, sizeof(struct gr_arg));
91725+ memset(gr_system_salt, 0, GR_SALT_LEN);
91726+ memset(gr_system_sum, 0, GR_SHA_LEN);
91727+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
91728+ } else if (gr_acl_is_enabled()) {
91729+ gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
91730+ error = -EPERM;
91731+ } else {
91732+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
91733+ error = -EAGAIN;
91734+ }
91735+ break;
91736+ case GR_ENABLE:
91737+ if (!gr_acl_is_enabled() && !(error2 = gracl_init(gr_usermode)))
91738+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
91739+ else {
91740+ if (gr_acl_is_enabled())
91741+ error = -EAGAIN;
91742+ else
91743+ error = error2;
91744+ gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
91745+ }
91746+ break;
91747+ case GR_OLDRELOAD:
91748+ oldmode = 1;
91749+ case GR_RELOAD:
91750+ if (!gr_acl_is_enabled()) {
91751+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
91752+ error = -EAGAIN;
91753+ } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
91754+ error2 = gracl_reload(gr_usermode, oldmode);
91755+ if (!error2)
91756+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
91757+ else {
91758+ gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
91759+ error = error2;
91760+ }
91761+ } else {
91762+ gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
91763+ error = -EPERM;
91764+ }
91765+ break;
91766+ case GR_SEGVMOD:
91767+ if (unlikely(!gr_acl_is_enabled())) {
91768+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
91769+ error = -EAGAIN;
91770+ break;
91771+ }
91772+
91773+ if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
91774+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
91775+ if (gr_usermode->segv_device && gr_usermode->segv_inode) {
91776+ struct acl_subject_label *segvacl;
91777+ segvacl =
91778+ lookup_acl_subj_label(gr_usermode->segv_inode,
91779+ gr_usermode->segv_device,
91780+ current->role);
91781+ if (segvacl) {
91782+ segvacl->crashes = 0;
91783+ segvacl->expires = 0;
91784+ }
91785+ } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
91786+ gr_remove_uid(gr_usermode->segv_uid);
91787+ }
91788+ } else {
91789+ gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
91790+ error = -EPERM;
91791+ }
91792+ break;
91793+ case GR_SPROLE:
91794+ case GR_SPROLEPAM:
91795+ if (unlikely(!gr_acl_is_enabled())) {
91796+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
91797+ error = -EAGAIN;
91798+ break;
91799+ }
91800+
91801+ if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
91802+ current->role->expires = 0;
91803+ current->role->auth_attempts = 0;
91804+ }
91805+
91806+ if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
91807+ time_after(current->role->expires, get_seconds())) {
91808+ error = -EBUSY;
91809+ goto out;
91810+ }
91811+
91812+ if (lookup_special_role_auth
91813+ (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
91814+ && ((!sprole_salt && !sprole_sum)
91815+ || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
91816+ char *p = "";
91817+ assign_special_role(gr_usermode->sp_role);
91818+ read_lock(&tasklist_lock);
91819+ if (current->real_parent)
91820+ p = current->real_parent->role->rolename;
91821+ read_unlock(&tasklist_lock);
91822+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
91823+ p, acl_sp_role_value);
91824+ } else {
91825+ gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
91826+ error = -EPERM;
91827+ if(!(current->role->auth_attempts++))
91828+ current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
91829+
91830+ goto out;
91831+ }
91832+ break;
91833+ case GR_UNSPROLE:
91834+ if (unlikely(!gr_acl_is_enabled())) {
91835+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
91836+ error = -EAGAIN;
91837+ break;
91838+ }
91839+
91840+ if (current->role->roletype & GR_ROLE_SPECIAL) {
91841+ char *p = "";
91842+ int i = 0;
91843+
91844+ read_lock(&tasklist_lock);
91845+ if (current->real_parent) {
91846+ p = current->real_parent->role->rolename;
91847+ i = current->real_parent->acl_role_id;
91848+ }
91849+ read_unlock(&tasklist_lock);
91850+
91851+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
91852+ gr_set_acls(1);
91853+ } else {
91854+ error = -EPERM;
91855+ goto out;
91856+ }
91857+ break;
91858+ default:
91859+ gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
91860+ error = -EINVAL;
91861+ break;
91862+ }
91863+
91864+ if (error != -EPERM)
91865+ goto out;
91866+
91867+ if(!(gr_auth_attempts++))
91868+ gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
91869+
91870+ out:
91871+ mutex_unlock(&gr_dev_mutex);
91872+
91873+ if (!error)
91874+ error = req_count;
91875+
91876+ return error;
91877+}
91878+
91879+int
91880+gr_set_acls(const int type)
91881+{
91882+ struct task_struct *task, *task2;
91883+ struct acl_role_label *role = current->role;
91884+ struct acl_subject_label *subj;
91885+ __u16 acl_role_id = current->acl_role_id;
91886+ const struct cred *cred;
91887+ int ret;
91888+
91889+ rcu_read_lock();
91890+ read_lock(&tasklist_lock);
91891+ read_lock(&grsec_exec_file_lock);
91892+ do_each_thread(task2, task) {
91893+ /* check to see if we're called from the exit handler,
91894+ if so, only replace ACLs that have inherited the admin
91895+ ACL */
91896+
91897+ if (type && (task->role != role ||
91898+ task->acl_role_id != acl_role_id))
91899+ continue;
91900+
91901+ task->acl_role_id = 0;
91902+ task->acl_sp_role = 0;
91903+ task->inherited = 0;
91904+
91905+ if (task->exec_file) {
91906+ cred = __task_cred(task);
91907+ task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
91908+ subj = __gr_get_subject_for_task(polstate, task, NULL, 1);
91909+ if (subj == NULL) {
91910+ ret = -EINVAL;
91911+ read_unlock(&grsec_exec_file_lock);
91912+ read_unlock(&tasklist_lock);
91913+ rcu_read_unlock();
91914+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
91915+ return ret;
91916+ }
91917+ __gr_apply_subject_to_task(polstate, task, subj);
91918+ } else {
91919+ // it's a kernel process
91920+ task->role = polstate->kernel_role;
91921+ task->acl = polstate->kernel_role->root_label;
91922+#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
91923+ task->acl->mode &= ~GR_PROCFIND;
91924+#endif
91925+ }
91926+ } while_each_thread(task2, task);
91927+ read_unlock(&grsec_exec_file_lock);
91928+ read_unlock(&tasklist_lock);
91929+ rcu_read_unlock();
91930+
91931+ return 0;
91932+}
91933diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
91934new file mode 100644
91935index 0000000..39645c9
91936--- /dev/null
91937+++ b/grsecurity/gracl_res.c
91938@@ -0,0 +1,68 @@
91939+#include <linux/kernel.h>
91940+#include <linux/sched.h>
91941+#include <linux/gracl.h>
91942+#include <linux/grinternal.h>
91943+
91944+static const char *restab_log[] = {
91945+ [RLIMIT_CPU] = "RLIMIT_CPU",
91946+ [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
91947+ [RLIMIT_DATA] = "RLIMIT_DATA",
91948+ [RLIMIT_STACK] = "RLIMIT_STACK",
91949+ [RLIMIT_CORE] = "RLIMIT_CORE",
91950+ [RLIMIT_RSS] = "RLIMIT_RSS",
91951+ [RLIMIT_NPROC] = "RLIMIT_NPROC",
91952+ [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
91953+ [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
91954+ [RLIMIT_AS] = "RLIMIT_AS",
91955+ [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
91956+ [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
91957+ [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
91958+ [RLIMIT_NICE] = "RLIMIT_NICE",
91959+ [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
91960+ [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
91961+ [GR_CRASH_RES] = "RLIMIT_CRASH"
91962+};
91963+
91964+void
91965+gr_log_resource(const struct task_struct *task,
91966+ const int res, const unsigned long wanted, const int gt)
91967+{
91968+ const struct cred *cred;
91969+ unsigned long rlim;
91970+
91971+ if (!gr_acl_is_enabled() && !grsec_resource_logging)
91972+ return;
91973+
91974+ // not yet supported resource
91975+ if (unlikely(!restab_log[res]))
91976+ return;
91977+
91978+ if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
91979+ rlim = task_rlimit_max(task, res);
91980+ else
91981+ rlim = task_rlimit(task, res);
91982+
91983+ if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
91984+ return;
91985+
91986+ rcu_read_lock();
91987+ cred = __task_cred(task);
91988+
91989+ if (res == RLIMIT_NPROC &&
91990+ (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
91991+ cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
91992+ goto out_rcu_unlock;
91993+ else if (res == RLIMIT_MEMLOCK &&
91994+ cap_raised(cred->cap_effective, CAP_IPC_LOCK))
91995+ goto out_rcu_unlock;
91996+ else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
91997+ goto out_rcu_unlock;
91998+ rcu_read_unlock();
91999+
92000+ gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
92001+
92002+ return;
92003+out_rcu_unlock:
92004+ rcu_read_unlock();
92005+ return;
92006+}
92007diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
92008new file mode 100644
92009index 0000000..21646aa
92010--- /dev/null
92011+++ b/grsecurity/gracl_segv.c
92012@@ -0,0 +1,304 @@
92013+#include <linux/kernel.h>
92014+#include <linux/mm.h>
92015+#include <asm/uaccess.h>
92016+#include <asm/errno.h>
92017+#include <asm/mman.h>
92018+#include <net/sock.h>
92019+#include <linux/file.h>
92020+#include <linux/fs.h>
92021+#include <linux/net.h>
92022+#include <linux/in.h>
92023+#include <linux/slab.h>
92024+#include <linux/types.h>
92025+#include <linux/sched.h>
92026+#include <linux/timer.h>
92027+#include <linux/gracl.h>
92028+#include <linux/grsecurity.h>
92029+#include <linux/grinternal.h>
92030+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
92031+#include <linux/magic.h>
92032+#include <linux/pagemap.h>
92033+#include "../fs/btrfs/async-thread.h"
92034+#include "../fs/btrfs/ctree.h"
92035+#include "../fs/btrfs/btrfs_inode.h"
92036+#endif
92037+
92038+static struct crash_uid *uid_set;
92039+static unsigned short uid_used;
92040+static DEFINE_SPINLOCK(gr_uid_lock);
92041+extern rwlock_t gr_inode_lock;
92042+extern struct acl_subject_label *
92043+ lookup_acl_subj_label(const u64 inode, const dev_t dev,
92044+ struct acl_role_label *role);
92045+
92046+int
92047+gr_init_uidset(void)
92048+{
92049+ uid_set =
92050+ kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
92051+ uid_used = 0;
92052+
92053+ return uid_set ? 1 : 0;
92054+}
92055+
92056+void
92057+gr_free_uidset(void)
92058+{
92059+ if (uid_set) {
92060+ struct crash_uid *tmpset;
92061+ spin_lock(&gr_uid_lock);
92062+ tmpset = uid_set;
92063+ uid_set = NULL;
92064+ uid_used = 0;
92065+ spin_unlock(&gr_uid_lock);
92066+ if (tmpset)
92067+ kfree(tmpset);
92068+ }
92069+
92070+ return;
92071+}
92072+
92073+int
92074+gr_find_uid(const uid_t uid)
92075+{
92076+ struct crash_uid *tmp = uid_set;
92077+ uid_t buid;
92078+ int low = 0, high = uid_used - 1, mid;
92079+
92080+ while (high >= low) {
92081+ mid = (low + high) >> 1;
92082+ buid = tmp[mid].uid;
92083+ if (buid == uid)
92084+ return mid;
92085+ if (buid > uid)
92086+ high = mid - 1;
92087+ if (buid < uid)
92088+ low = mid + 1;
92089+ }
92090+
92091+ return -1;
92092+}
92093+
92094+static void
92095+gr_insertsort(void)
92096+{
92097+ unsigned short i, j;
92098+ struct crash_uid index;
92099+
92100+ for (i = 1; i < uid_used; i++) {
92101+ index = uid_set[i];
92102+ j = i;
92103+ while ((j > 0) && uid_set[j - 1].uid > index.uid) {
92104+ uid_set[j] = uid_set[j - 1];
92105+ j--;
92106+ }
92107+ uid_set[j] = index;
92108+ }
92109+
92110+ return;
92111+}
92112+
92113+static void
92114+gr_insert_uid(const kuid_t kuid, const unsigned long expires)
92115+{
92116+ int loc;
92117+ uid_t uid = GR_GLOBAL_UID(kuid);
92118+
92119+ if (uid_used == GR_UIDTABLE_MAX)
92120+ return;
92121+
92122+ loc = gr_find_uid(uid);
92123+
92124+ if (loc >= 0) {
92125+ uid_set[loc].expires = expires;
92126+ return;
92127+ }
92128+
92129+ uid_set[uid_used].uid = uid;
92130+ uid_set[uid_used].expires = expires;
92131+ uid_used++;
92132+
92133+ gr_insertsort();
92134+
92135+ return;
92136+}
92137+
92138+void
92139+gr_remove_uid(const unsigned short loc)
92140+{
92141+ unsigned short i;
92142+
92143+ for (i = loc + 1; i < uid_used; i++)
92144+ uid_set[i - 1] = uid_set[i];
92145+
92146+ uid_used--;
92147+
92148+ return;
92149+}
92150+
92151+int
92152+gr_check_crash_uid(const kuid_t kuid)
92153+{
92154+ int loc;
92155+ int ret = 0;
92156+ uid_t uid;
92157+
92158+ if (unlikely(!gr_acl_is_enabled()))
92159+ return 0;
92160+
92161+ uid = GR_GLOBAL_UID(kuid);
92162+
92163+ spin_lock(&gr_uid_lock);
92164+ loc = gr_find_uid(uid);
92165+
92166+ if (loc < 0)
92167+ goto out_unlock;
92168+
92169+ if (time_before_eq(uid_set[loc].expires, get_seconds()))
92170+ gr_remove_uid(loc);
92171+ else
92172+ ret = 1;
92173+
92174+out_unlock:
92175+ spin_unlock(&gr_uid_lock);
92176+ return ret;
92177+}
92178+
92179+static int
92180+proc_is_setxid(const struct cred *cred)
92181+{
92182+ if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
92183+ !uid_eq(cred->uid, cred->fsuid))
92184+ return 1;
92185+ if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
92186+ !gid_eq(cred->gid, cred->fsgid))
92187+ return 1;
92188+
92189+ return 0;
92190+}
92191+
92192+extern int gr_fake_force_sig(int sig, struct task_struct *t);
92193+
92194+void
92195+gr_handle_crash(struct task_struct *task, const int sig)
92196+{
92197+ struct acl_subject_label *curr;
92198+ struct task_struct *tsk, *tsk2;
92199+ const struct cred *cred;
92200+ const struct cred *cred2;
92201+
92202+ if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
92203+ return;
92204+
92205+ if (unlikely(!gr_acl_is_enabled()))
92206+ return;
92207+
92208+ curr = task->acl;
92209+
92210+ if (!(curr->resmask & (1U << GR_CRASH_RES)))
92211+ return;
92212+
92213+ if (time_before_eq(curr->expires, get_seconds())) {
92214+ curr->expires = 0;
92215+ curr->crashes = 0;
92216+ }
92217+
92218+ curr->crashes++;
92219+
92220+ if (!curr->expires)
92221+ curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
92222+
92223+ if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
92224+ time_after(curr->expires, get_seconds())) {
92225+ rcu_read_lock();
92226+ cred = __task_cred(task);
92227+ if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
92228+ gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
92229+ spin_lock(&gr_uid_lock);
92230+ gr_insert_uid(cred->uid, curr->expires);
92231+ spin_unlock(&gr_uid_lock);
92232+ curr->expires = 0;
92233+ curr->crashes = 0;
92234+ read_lock(&tasklist_lock);
92235+ do_each_thread(tsk2, tsk) {
92236+ cred2 = __task_cred(tsk);
92237+ if (tsk != task && uid_eq(cred2->uid, cred->uid))
92238+ gr_fake_force_sig(SIGKILL, tsk);
92239+ } while_each_thread(tsk2, tsk);
92240+ read_unlock(&tasklist_lock);
92241+ } else {
92242+ gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
92243+ read_lock(&tasklist_lock);
92244+ read_lock(&grsec_exec_file_lock);
92245+ do_each_thread(tsk2, tsk) {
92246+ if (likely(tsk != task)) {
92247+ // if this thread has the same subject as the one that triggered
92248+ // RES_CRASH and it's the same binary, kill it
92249+ if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
92250+ gr_fake_force_sig(SIGKILL, tsk);
92251+ }
92252+ } while_each_thread(tsk2, tsk);
92253+ read_unlock(&grsec_exec_file_lock);
92254+ read_unlock(&tasklist_lock);
92255+ }
92256+ rcu_read_unlock();
92257+ }
92258+
92259+ return;
92260+}
92261+
92262+int
92263+gr_check_crash_exec(const struct file *filp)
92264+{
92265+ struct acl_subject_label *curr;
92266+ struct dentry *dentry;
92267+
92268+ if (unlikely(!gr_acl_is_enabled()))
92269+ return 0;
92270+
92271+ read_lock(&gr_inode_lock);
92272+ dentry = filp->f_path.dentry;
92273+ curr = lookup_acl_subj_label(gr_get_ino_from_dentry(dentry), gr_get_dev_from_dentry(dentry),
92274+ current->role);
92275+ read_unlock(&gr_inode_lock);
92276+
92277+ if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
92278+ (!curr->crashes && !curr->expires))
92279+ return 0;
92280+
92281+ if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
92282+ time_after(curr->expires, get_seconds()))
92283+ return 1;
92284+ else if (time_before_eq(curr->expires, get_seconds())) {
92285+ curr->crashes = 0;
92286+ curr->expires = 0;
92287+ }
92288+
92289+ return 0;
92290+}
92291+
92292+void
92293+gr_handle_alertkill(struct task_struct *task)
92294+{
92295+ struct acl_subject_label *curracl;
92296+ __u32 curr_ip;
92297+ struct task_struct *p, *p2;
92298+
92299+ if (unlikely(!gr_acl_is_enabled()))
92300+ return;
92301+
92302+ curracl = task->acl;
92303+ curr_ip = task->signal->curr_ip;
92304+
92305+ if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
92306+ read_lock(&tasklist_lock);
92307+ do_each_thread(p2, p) {
92308+ if (p->signal->curr_ip == curr_ip)
92309+ gr_fake_force_sig(SIGKILL, p);
92310+ } while_each_thread(p2, p);
92311+ read_unlock(&tasklist_lock);
92312+ } else if (curracl->mode & GR_KILLPROC)
92313+ gr_fake_force_sig(SIGKILL, task);
92314+
92315+ return;
92316+}
92317diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
92318new file mode 100644
92319index 0000000..6b0c9cc
92320--- /dev/null
92321+++ b/grsecurity/gracl_shm.c
92322@@ -0,0 +1,40 @@
92323+#include <linux/kernel.h>
92324+#include <linux/mm.h>
92325+#include <linux/sched.h>
92326+#include <linux/file.h>
92327+#include <linux/ipc.h>
92328+#include <linux/gracl.h>
92329+#include <linux/grsecurity.h>
92330+#include <linux/grinternal.h>
92331+
92332+int
92333+gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
92334+ const u64 shm_createtime, const kuid_t cuid, const int shmid)
92335+{
92336+ struct task_struct *task;
92337+
92338+ if (!gr_acl_is_enabled())
92339+ return 1;
92340+
92341+ rcu_read_lock();
92342+ read_lock(&tasklist_lock);
92343+
92344+ task = find_task_by_vpid(shm_cprid);
92345+
92346+ if (unlikely(!task))
92347+ task = find_task_by_vpid(shm_lapid);
92348+
92349+ if (unlikely(task && (time_before_eq64(task->start_time, shm_createtime) ||
92350+ (task_pid_nr(task) == shm_lapid)) &&
92351+ (task->acl->mode & GR_PROTSHM) &&
92352+ (task->acl != current->acl))) {
92353+ read_unlock(&tasklist_lock);
92354+ rcu_read_unlock();
92355+ gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
92356+ return 0;
92357+ }
92358+ read_unlock(&tasklist_lock);
92359+ rcu_read_unlock();
92360+
92361+ return 1;
92362+}
92363diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
92364new file mode 100644
92365index 0000000..bc0be01
92366--- /dev/null
92367+++ b/grsecurity/grsec_chdir.c
92368@@ -0,0 +1,19 @@
92369+#include <linux/kernel.h>
92370+#include <linux/sched.h>
92371+#include <linux/fs.h>
92372+#include <linux/file.h>
92373+#include <linux/grsecurity.h>
92374+#include <linux/grinternal.h>
92375+
92376+void
92377+gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
92378+{
92379+#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
92380+ if ((grsec_enable_chdir && grsec_enable_group &&
92381+ in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
92382+ !grsec_enable_group)) {
92383+ gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
92384+ }
92385+#endif
92386+ return;
92387+}
92388diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
92389new file mode 100644
92390index 0000000..652ab45
92391--- /dev/null
92392+++ b/grsecurity/grsec_chroot.c
92393@@ -0,0 +1,467 @@
92394+#include <linux/kernel.h>
92395+#include <linux/module.h>
92396+#include <linux/sched.h>
92397+#include <linux/file.h>
92398+#include <linux/fs.h>
92399+#include <linux/mount.h>
92400+#include <linux/types.h>
92401+#include "../fs/mount.h"
92402+#include <linux/grsecurity.h>
92403+#include <linux/grinternal.h>
92404+
92405+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
92406+int gr_init_ran;
92407+#endif
92408+
92409+void gr_inc_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt)
92410+{
92411+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92412+ struct dentry *tmpd = dentry;
92413+
92414+ read_seqlock_excl(&mount_lock);
92415+ write_seqlock(&rename_lock);
92416+
92417+ while (tmpd != mnt->mnt_root) {
92418+ atomic_inc(&tmpd->chroot_refcnt);
92419+ tmpd = tmpd->d_parent;
92420+ }
92421+ atomic_inc(&tmpd->chroot_refcnt);
92422+
92423+ write_sequnlock(&rename_lock);
92424+ read_sequnlock_excl(&mount_lock);
92425+#endif
92426+}
92427+
92428+void gr_dec_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt)
92429+{
92430+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92431+ struct dentry *tmpd = dentry;
92432+
92433+ read_seqlock_excl(&mount_lock);
92434+ write_seqlock(&rename_lock);
92435+
92436+ while (tmpd != mnt->mnt_root) {
92437+ atomic_dec(&tmpd->chroot_refcnt);
92438+ tmpd = tmpd->d_parent;
92439+ }
92440+ atomic_dec(&tmpd->chroot_refcnt);
92441+
92442+ write_sequnlock(&rename_lock);
92443+ read_sequnlock_excl(&mount_lock);
92444+#endif
92445+}
92446+
92447+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92448+static struct dentry *get_closest_chroot(struct dentry *dentry)
92449+{
92450+ write_seqlock(&rename_lock);
92451+ do {
92452+ if (atomic_read(&dentry->chroot_refcnt)) {
92453+ write_sequnlock(&rename_lock);
92454+ return dentry;
92455+ }
92456+ dentry = dentry->d_parent;
92457+ } while (!IS_ROOT(dentry));
92458+ write_sequnlock(&rename_lock);
92459+ return NULL;
92460+}
92461+#endif
92462+
92463+int gr_bad_chroot_rename(struct dentry *olddentry, struct vfsmount *oldmnt,
92464+ struct dentry *newdentry, struct vfsmount *newmnt)
92465+{
92466+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92467+ struct dentry *chroot;
92468+
92469+ if (unlikely(!grsec_enable_chroot_rename))
92470+ return 0;
92471+
92472+ if (likely(!proc_is_chrooted(current) && gr_is_global_root(current_uid())))
92473+ return 0;
92474+
92475+ chroot = get_closest_chroot(olddentry);
92476+
92477+ if (chroot == NULL)
92478+ return 0;
92479+
92480+ if (is_subdir(newdentry, chroot))
92481+ return 0;
92482+
92483+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_RENAME_MSG, olddentry, oldmnt);
92484+
92485+ return 1;
92486+#else
92487+ return 0;
92488+#endif
92489+}
92490+
92491+void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
92492+{
92493+#ifdef CONFIG_GRKERNSEC
92494+ if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
92495+ path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
92496+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
92497+ && gr_init_ran
92498+#endif
92499+ )
92500+ task->gr_is_chrooted = 1;
92501+ else {
92502+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
92503+ if (task_pid_nr(task) == 1 && !gr_init_ran)
92504+ gr_init_ran = 1;
92505+#endif
92506+ task->gr_is_chrooted = 0;
92507+ }
92508+
92509+ task->gr_chroot_dentry = path->dentry;
92510+#endif
92511+ return;
92512+}
92513+
92514+void gr_clear_chroot_entries(struct task_struct *task)
92515+{
92516+#ifdef CONFIG_GRKERNSEC
92517+ task->gr_is_chrooted = 0;
92518+ task->gr_chroot_dentry = NULL;
92519+#endif
92520+ return;
92521+}
92522+
92523+int
92524+gr_handle_chroot_unix(const pid_t pid)
92525+{
92526+#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
92527+ struct task_struct *p;
92528+
92529+ if (unlikely(!grsec_enable_chroot_unix))
92530+ return 1;
92531+
92532+ if (likely(!proc_is_chrooted(current)))
92533+ return 1;
92534+
92535+ rcu_read_lock();
92536+ read_lock(&tasklist_lock);
92537+ p = find_task_by_vpid_unrestricted(pid);
92538+ if (unlikely(p && !have_same_root(current, p))) {
92539+ read_unlock(&tasklist_lock);
92540+ rcu_read_unlock();
92541+ gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
92542+ return 0;
92543+ }
92544+ read_unlock(&tasklist_lock);
92545+ rcu_read_unlock();
92546+#endif
92547+ return 1;
92548+}
92549+
92550+int
92551+gr_handle_chroot_nice(void)
92552+{
92553+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
92554+ if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
92555+ gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
92556+ return -EPERM;
92557+ }
92558+#endif
92559+ return 0;
92560+}
92561+
92562+int
92563+gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
92564+{
92565+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
92566+ if (grsec_enable_chroot_nice && (niceval < task_nice(p))
92567+ && proc_is_chrooted(current)) {
92568+ gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
92569+ return -EACCES;
92570+ }
92571+#endif
92572+ return 0;
92573+}
92574+
92575+int
92576+gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
92577+{
92578+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
92579+ struct task_struct *p;
92580+ int ret = 0;
92581+ if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
92582+ return ret;
92583+
92584+ read_lock(&tasklist_lock);
92585+ do_each_pid_task(pid, type, p) {
92586+ if (!have_same_root(current, p)) {
92587+ ret = 1;
92588+ goto out;
92589+ }
92590+ } while_each_pid_task(pid, type, p);
92591+out:
92592+ read_unlock(&tasklist_lock);
92593+ return ret;
92594+#endif
92595+ return 0;
92596+}
92597+
92598+int
92599+gr_pid_is_chrooted(struct task_struct *p)
92600+{
92601+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
92602+ if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
92603+ return 0;
92604+
92605+ if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
92606+ !have_same_root(current, p)) {
92607+ return 1;
92608+ }
92609+#endif
92610+ return 0;
92611+}
92612+
92613+EXPORT_SYMBOL_GPL(gr_pid_is_chrooted);
92614+
92615+#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
92616+int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
92617+{
92618+ struct path path, currentroot;
92619+ int ret = 0;
92620+
92621+ path.dentry = (struct dentry *)u_dentry;
92622+ path.mnt = (struct vfsmount *)u_mnt;
92623+ get_fs_root(current->fs, &currentroot);
92624+ if (path_is_under(&path, &currentroot))
92625+ ret = 1;
92626+ path_put(&currentroot);
92627+
92628+ return ret;
92629+}
92630+#endif
92631+
92632+int
92633+gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
92634+{
92635+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
92636+ if (!grsec_enable_chroot_fchdir)
92637+ return 1;
92638+
92639+ if (!proc_is_chrooted(current))
92640+ return 1;
92641+ else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
92642+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
92643+ return 0;
92644+ }
92645+#endif
92646+ return 1;
92647+}
92648+
92649+int
92650+gr_chroot_fhandle(void)
92651+{
92652+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
92653+ if (!grsec_enable_chroot_fchdir)
92654+ return 1;
92655+
92656+ if (!proc_is_chrooted(current))
92657+ return 1;
92658+ else {
92659+ gr_log_noargs(GR_DONT_AUDIT, GR_CHROOT_FHANDLE_MSG);
92660+ return 0;
92661+ }
92662+#endif
92663+ return 1;
92664+}
92665+
92666+int
92667+gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
92668+ const u64 shm_createtime)
92669+{
92670+#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
92671+ struct task_struct *p;
92672+
92673+ if (unlikely(!grsec_enable_chroot_shmat))
92674+ return 1;
92675+
92676+ if (likely(!proc_is_chrooted(current)))
92677+ return 1;
92678+
92679+ rcu_read_lock();
92680+ read_lock(&tasklist_lock);
92681+
92682+ if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
92683+ if (time_before_eq64(p->start_time, shm_createtime)) {
92684+ if (have_same_root(current, p)) {
92685+ goto allow;
92686+ } else {
92687+ read_unlock(&tasklist_lock);
92688+ rcu_read_unlock();
92689+ gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
92690+ return 0;
92691+ }
92692+ }
92693+ /* creator exited, pid reuse, fall through to next check */
92694+ }
92695+ if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
92696+ if (unlikely(!have_same_root(current, p))) {
92697+ read_unlock(&tasklist_lock);
92698+ rcu_read_unlock();
92699+ gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
92700+ return 0;
92701+ }
92702+ }
92703+
92704+allow:
92705+ read_unlock(&tasklist_lock);
92706+ rcu_read_unlock();
92707+#endif
92708+ return 1;
92709+}
92710+
92711+void
92712+gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
92713+{
92714+#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
92715+ if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
92716+ gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
92717+#endif
92718+ return;
92719+}
92720+
92721+int
92722+gr_handle_chroot_mknod(const struct dentry *dentry,
92723+ const struct vfsmount *mnt, const int mode)
92724+{
92725+#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
92726+ if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
92727+ proc_is_chrooted(current)) {
92728+ gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
92729+ return -EPERM;
92730+ }
92731+#endif
92732+ return 0;
92733+}
92734+
92735+int
92736+gr_handle_chroot_mount(const struct dentry *dentry,
92737+ const struct vfsmount *mnt, const char *dev_name)
92738+{
92739+#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
92740+ if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
92741+ gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
92742+ return -EPERM;
92743+ }
92744+#endif
92745+ return 0;
92746+}
92747+
92748+int
92749+gr_handle_chroot_pivot(void)
92750+{
92751+#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
92752+ if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
92753+ gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
92754+ return -EPERM;
92755+ }
92756+#endif
92757+ return 0;
92758+}
92759+
92760+int
92761+gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
92762+{
92763+#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
92764+ if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
92765+ !gr_is_outside_chroot(dentry, mnt)) {
92766+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
92767+ return -EPERM;
92768+ }
92769+#endif
92770+ return 0;
92771+}
92772+
92773+extern const char *captab_log[];
92774+extern int captab_log_entries;
92775+
92776+int
92777+gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
92778+{
92779+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92780+ if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
92781+ kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
92782+ if (cap_raised(chroot_caps, cap)) {
92783+ if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
92784+ gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
92785+ }
92786+ return 0;
92787+ }
92788+ }
92789+#endif
92790+ return 1;
92791+}
92792+
92793+int
92794+gr_chroot_is_capable(const int cap)
92795+{
92796+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92797+ return gr_task_chroot_is_capable(current, current_cred(), cap);
92798+#endif
92799+ return 1;
92800+}
92801+
92802+int
92803+gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
92804+{
92805+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92806+ if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
92807+ kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
92808+ if (cap_raised(chroot_caps, cap)) {
92809+ return 0;
92810+ }
92811+ }
92812+#endif
92813+ return 1;
92814+}
92815+
92816+int
92817+gr_chroot_is_capable_nolog(const int cap)
92818+{
92819+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92820+ return gr_task_chroot_is_capable_nolog(current, cap);
92821+#endif
92822+ return 1;
92823+}
92824+
92825+int
92826+gr_handle_chroot_sysctl(const int op)
92827+{
92828+#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
92829+ if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
92830+ proc_is_chrooted(current))
92831+ return -EACCES;
92832+#endif
92833+ return 0;
92834+}
92835+
92836+void
92837+gr_handle_chroot_chdir(const struct path *path)
92838+{
92839+#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
92840+ if (grsec_enable_chroot_chdir)
92841+ set_fs_pwd(current->fs, path);
92842+#endif
92843+ return;
92844+}
92845+
92846+int
92847+gr_handle_chroot_chmod(const struct dentry *dentry,
92848+ const struct vfsmount *mnt, const int mode)
92849+{
92850+#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
92851+ /* allow chmod +s on directories, but not files */
92852+ if (grsec_enable_chroot_chmod && !d_is_dir(dentry) &&
92853+ ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
92854+ proc_is_chrooted(current)) {
92855+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
92856+ return -EPERM;
92857+ }
92858+#endif
92859+ return 0;
92860+}
92861diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
92862new file mode 100644
92863index 0000000..e723c08
92864--- /dev/null
92865+++ b/grsecurity/grsec_disabled.c
92866@@ -0,0 +1,445 @@
92867+#include <linux/kernel.h>
92868+#include <linux/module.h>
92869+#include <linux/sched.h>
92870+#include <linux/file.h>
92871+#include <linux/fs.h>
92872+#include <linux/kdev_t.h>
92873+#include <linux/net.h>
92874+#include <linux/in.h>
92875+#include <linux/ip.h>
92876+#include <linux/skbuff.h>
92877+#include <linux/sysctl.h>
92878+
92879+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
92880+void
92881+pax_set_initial_flags(struct linux_binprm *bprm)
92882+{
92883+ return;
92884+}
92885+#endif
92886+
92887+#ifdef CONFIG_SYSCTL
92888+__u32
92889+gr_handle_sysctl(const struct ctl_table * table, const int op)
92890+{
92891+ return 0;
92892+}
92893+#endif
92894+
92895+#ifdef CONFIG_TASKSTATS
92896+int gr_is_taskstats_denied(int pid)
92897+{
92898+ return 0;
92899+}
92900+#endif
92901+
92902+int
92903+gr_acl_is_enabled(void)
92904+{
92905+ return 0;
92906+}
92907+
92908+int
92909+gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap)
92910+{
92911+ return 0;
92912+}
92913+
92914+void
92915+gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
92916+{
92917+ return;
92918+}
92919+
92920+int
92921+gr_handle_rawio(const struct inode *inode)
92922+{
92923+ return 0;
92924+}
92925+
92926+void
92927+gr_acl_handle_psacct(struct task_struct *task, const long code)
92928+{
92929+ return;
92930+}
92931+
92932+int
92933+gr_handle_ptrace(struct task_struct *task, const long request)
92934+{
92935+ return 0;
92936+}
92937+
92938+int
92939+gr_handle_proc_ptrace(struct task_struct *task)
92940+{
92941+ return 0;
92942+}
92943+
92944+int
92945+gr_set_acls(const int type)
92946+{
92947+ return 0;
92948+}
92949+
92950+int
92951+gr_check_hidden_task(const struct task_struct *tsk)
92952+{
92953+ return 0;
92954+}
92955+
92956+int
92957+gr_check_protected_task(const struct task_struct *task)
92958+{
92959+ return 0;
92960+}
92961+
92962+int
92963+gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
92964+{
92965+ return 0;
92966+}
92967+
92968+void
92969+gr_copy_label(struct task_struct *tsk)
92970+{
92971+ return;
92972+}
92973+
92974+void
92975+gr_set_pax_flags(struct task_struct *task)
92976+{
92977+ return;
92978+}
92979+
92980+int
92981+gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
92982+ const int unsafe_share)
92983+{
92984+ return 0;
92985+}
92986+
92987+void
92988+gr_handle_delete(const u64 ino, const dev_t dev)
92989+{
92990+ return;
92991+}
92992+
92993+void
92994+gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
92995+{
92996+ return;
92997+}
92998+
92999+void
93000+gr_handle_crash(struct task_struct *task, const int sig)
93001+{
93002+ return;
93003+}
93004+
93005+int
93006+gr_check_crash_exec(const struct file *filp)
93007+{
93008+ return 0;
93009+}
93010+
93011+int
93012+gr_check_crash_uid(const kuid_t uid)
93013+{
93014+ return 0;
93015+}
93016+
93017+void
93018+gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
93019+ struct dentry *old_dentry,
93020+ struct dentry *new_dentry,
93021+ struct vfsmount *mnt, const __u8 replace, unsigned int flags)
93022+{
93023+ return;
93024+}
93025+
93026+int
93027+gr_search_socket(const int family, const int type, const int protocol)
93028+{
93029+ return 1;
93030+}
93031+
93032+int
93033+gr_search_connectbind(const int mode, const struct socket *sock,
93034+ const struct sockaddr_in *addr)
93035+{
93036+ return 0;
93037+}
93038+
93039+void
93040+gr_handle_alertkill(struct task_struct *task)
93041+{
93042+ return;
93043+}
93044+
93045+__u32
93046+gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
93047+{
93048+ return 1;
93049+}
93050+
93051+__u32
93052+gr_acl_handle_hidden_file(const struct dentry * dentry,
93053+ const struct vfsmount * mnt)
93054+{
93055+ return 1;
93056+}
93057+
93058+__u32
93059+gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
93060+ int acc_mode)
93061+{
93062+ return 1;
93063+}
93064+
93065+__u32
93066+gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
93067+{
93068+ return 1;
93069+}
93070+
93071+__u32
93072+gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
93073+{
93074+ return 1;
93075+}
93076+
93077+int
93078+gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
93079+ unsigned int *vm_flags)
93080+{
93081+ return 1;
93082+}
93083+
93084+__u32
93085+gr_acl_handle_truncate(const struct dentry * dentry,
93086+ const struct vfsmount * mnt)
93087+{
93088+ return 1;
93089+}
93090+
93091+__u32
93092+gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
93093+{
93094+ return 1;
93095+}
93096+
93097+__u32
93098+gr_acl_handle_access(const struct dentry * dentry,
93099+ const struct vfsmount * mnt, const int fmode)
93100+{
93101+ return 1;
93102+}
93103+
93104+__u32
93105+gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
93106+ umode_t *mode)
93107+{
93108+ return 1;
93109+}
93110+
93111+__u32
93112+gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
93113+{
93114+ return 1;
93115+}
93116+
93117+__u32
93118+gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
93119+{
93120+ return 1;
93121+}
93122+
93123+__u32
93124+gr_acl_handle_removexattr(const struct dentry * dentry, const struct vfsmount * mnt)
93125+{
93126+ return 1;
93127+}
93128+
93129+void
93130+grsecurity_init(void)
93131+{
93132+ return;
93133+}
93134+
93135+umode_t gr_acl_umask(void)
93136+{
93137+ return 0;
93138+}
93139+
93140+__u32
93141+gr_acl_handle_mknod(const struct dentry * new_dentry,
93142+ const struct dentry * parent_dentry,
93143+ const struct vfsmount * parent_mnt,
93144+ const int mode)
93145+{
93146+ return 1;
93147+}
93148+
93149+__u32
93150+gr_acl_handle_mkdir(const struct dentry * new_dentry,
93151+ const struct dentry * parent_dentry,
93152+ const struct vfsmount * parent_mnt)
93153+{
93154+ return 1;
93155+}
93156+
93157+__u32
93158+gr_acl_handle_symlink(const struct dentry * new_dentry,
93159+ const struct dentry * parent_dentry,
93160+ const struct vfsmount * parent_mnt, const struct filename *from)
93161+{
93162+ return 1;
93163+}
93164+
93165+__u32
93166+gr_acl_handle_link(const struct dentry * new_dentry,
93167+ const struct dentry * parent_dentry,
93168+ const struct vfsmount * parent_mnt,
93169+ const struct dentry * old_dentry,
93170+ const struct vfsmount * old_mnt, const struct filename *to)
93171+{
93172+ return 1;
93173+}
93174+
93175+int
93176+gr_acl_handle_rename(const struct dentry *new_dentry,
93177+ const struct dentry *parent_dentry,
93178+ const struct vfsmount *parent_mnt,
93179+ const struct dentry *old_dentry,
93180+ const struct inode *old_parent_inode,
93181+ const struct vfsmount *old_mnt, const struct filename *newname,
93182+ unsigned int flags)
93183+{
93184+ return 0;
93185+}
93186+
93187+int
93188+gr_acl_handle_filldir(const struct file *file, const char *name,
93189+ const int namelen, const u64 ino)
93190+{
93191+ return 1;
93192+}
93193+
93194+int
93195+gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
93196+ const u64 shm_createtime, const kuid_t cuid, const int shmid)
93197+{
93198+ return 1;
93199+}
93200+
93201+int
93202+gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
93203+{
93204+ return 0;
93205+}
93206+
93207+int
93208+gr_search_accept(const struct socket *sock)
93209+{
93210+ return 0;
93211+}
93212+
93213+int
93214+gr_search_listen(const struct socket *sock)
93215+{
93216+ return 0;
93217+}
93218+
93219+int
93220+gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
93221+{
93222+ return 0;
93223+}
93224+
93225+__u32
93226+gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
93227+{
93228+ return 1;
93229+}
93230+
93231+__u32
93232+gr_acl_handle_creat(const struct dentry * dentry,
93233+ const struct dentry * p_dentry,
93234+ const struct vfsmount * p_mnt, int open_flags, int acc_mode,
93235+ const int imode)
93236+{
93237+ return 1;
93238+}
93239+
93240+void
93241+gr_acl_handle_exit(void)
93242+{
93243+ return;
93244+}
93245+
93246+int
93247+gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
93248+{
93249+ return 1;
93250+}
93251+
93252+void
93253+gr_set_role_label(const kuid_t uid, const kgid_t gid)
93254+{
93255+ return;
93256+}
93257+
93258+int
93259+gr_acl_handle_procpidmem(const struct task_struct *task)
93260+{
93261+ return 0;
93262+}
93263+
93264+int
93265+gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
93266+{
93267+ return 0;
93268+}
93269+
93270+int
93271+gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
93272+{
93273+ return 0;
93274+}
93275+
93276+int
93277+gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
93278+{
93279+ return 0;
93280+}
93281+
93282+int
93283+gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
93284+{
93285+ return 0;
93286+}
93287+
93288+int gr_acl_enable_at_secure(void)
93289+{
93290+ return 0;
93291+}
93292+
93293+dev_t gr_get_dev_from_dentry(struct dentry *dentry)
93294+{
93295+ return d_backing_inode(dentry)->i_sb->s_dev;
93296+}
93297+
93298+u64 gr_get_ino_from_dentry(struct dentry *dentry)
93299+{
93300+ return d_backing_inode(dentry)->i_ino;
93301+}
93302+
93303+void gr_put_exec_file(struct task_struct *task)
93304+{
93305+ return;
93306+}
93307+
93308+#ifdef CONFIG_SECURITY
93309+EXPORT_SYMBOL_GPL(gr_check_user_change);
93310+EXPORT_SYMBOL_GPL(gr_check_group_change);
93311+#endif
93312diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
93313new file mode 100644
93314index 0000000..fb7531e
93315--- /dev/null
93316+++ b/grsecurity/grsec_exec.c
93317@@ -0,0 +1,189 @@
93318+#include <linux/kernel.h>
93319+#include <linux/sched.h>
93320+#include <linux/file.h>
93321+#include <linux/binfmts.h>
93322+#include <linux/fs.h>
93323+#include <linux/types.h>
93324+#include <linux/grdefs.h>
93325+#include <linux/grsecurity.h>
93326+#include <linux/grinternal.h>
93327+#include <linux/capability.h>
93328+#include <linux/module.h>
93329+#include <linux/compat.h>
93330+
93331+#include <asm/uaccess.h>
93332+
93333+#ifdef CONFIG_GRKERNSEC_EXECLOG
93334+static char gr_exec_arg_buf[132];
93335+static DEFINE_MUTEX(gr_exec_arg_mutex);
93336+#endif
93337+
93338+struct user_arg_ptr {
93339+#ifdef CONFIG_COMPAT
93340+ bool is_compat;
93341+#endif
93342+ union {
93343+ const char __user *const __user *native;
93344+#ifdef CONFIG_COMPAT
93345+ const compat_uptr_t __user *compat;
93346+#endif
93347+ } ptr;
93348+};
93349+
93350+extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
93351+
93352+void
93353+gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
93354+{
93355+#ifdef CONFIG_GRKERNSEC_EXECLOG
93356+ char *grarg = gr_exec_arg_buf;
93357+ unsigned int i, x, execlen = 0;
93358+ char c;
93359+
93360+ if (!((grsec_enable_execlog && grsec_enable_group &&
93361+ in_group_p(grsec_audit_gid))
93362+ || (grsec_enable_execlog && !grsec_enable_group)))
93363+ return;
93364+
93365+ mutex_lock(&gr_exec_arg_mutex);
93366+ memset(grarg, 0, sizeof(gr_exec_arg_buf));
93367+
93368+ for (i = 0; i < bprm->argc && execlen < 128; i++) {
93369+ const char __user *p;
93370+ unsigned int len;
93371+
93372+ p = get_user_arg_ptr(argv, i);
93373+ if (IS_ERR(p))
93374+ goto log;
93375+
93376+ len = strnlen_user(p, 128 - execlen);
93377+ if (len > 128 - execlen)
93378+ len = 128 - execlen;
93379+ else if (len > 0)
93380+ len--;
93381+ if (copy_from_user(grarg + execlen, p, len))
93382+ goto log;
93383+
93384+ /* rewrite unprintable characters */
93385+ for (x = 0; x < len; x++) {
93386+ c = *(grarg + execlen + x);
93387+ if (c < 32 || c > 126)
93388+ *(grarg + execlen + x) = ' ';
93389+ }
93390+
93391+ execlen += len;
93392+ *(grarg + execlen) = ' ';
93393+ *(grarg + execlen + 1) = '\0';
93394+ execlen++;
93395+ }
93396+
93397+ log:
93398+ gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
93399+ bprm->file->f_path.mnt, grarg);
93400+ mutex_unlock(&gr_exec_arg_mutex);
93401+#endif
93402+ return;
93403+}
93404+
93405+#ifdef CONFIG_GRKERNSEC
93406+extern int gr_acl_is_capable(const int cap);
93407+extern int gr_acl_is_capable_nolog(const int cap);
93408+extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
93409+extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
93410+extern int gr_chroot_is_capable(const int cap);
93411+extern int gr_chroot_is_capable_nolog(const int cap);
93412+extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
93413+extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
93414+#endif
93415+
93416+const char *captab_log[] = {
93417+ "CAP_CHOWN",
93418+ "CAP_DAC_OVERRIDE",
93419+ "CAP_DAC_READ_SEARCH",
93420+ "CAP_FOWNER",
93421+ "CAP_FSETID",
93422+ "CAP_KILL",
93423+ "CAP_SETGID",
93424+ "CAP_SETUID",
93425+ "CAP_SETPCAP",
93426+ "CAP_LINUX_IMMUTABLE",
93427+ "CAP_NET_BIND_SERVICE",
93428+ "CAP_NET_BROADCAST",
93429+ "CAP_NET_ADMIN",
93430+ "CAP_NET_RAW",
93431+ "CAP_IPC_LOCK",
93432+ "CAP_IPC_OWNER",
93433+ "CAP_SYS_MODULE",
93434+ "CAP_SYS_RAWIO",
93435+ "CAP_SYS_CHROOT",
93436+ "CAP_SYS_PTRACE",
93437+ "CAP_SYS_PACCT",
93438+ "CAP_SYS_ADMIN",
93439+ "CAP_SYS_BOOT",
93440+ "CAP_SYS_NICE",
93441+ "CAP_SYS_RESOURCE",
93442+ "CAP_SYS_TIME",
93443+ "CAP_SYS_TTY_CONFIG",
93444+ "CAP_MKNOD",
93445+ "CAP_LEASE",
93446+ "CAP_AUDIT_WRITE",
93447+ "CAP_AUDIT_CONTROL",
93448+ "CAP_SETFCAP",
93449+ "CAP_MAC_OVERRIDE",
93450+ "CAP_MAC_ADMIN",
93451+ "CAP_SYSLOG",
93452+ "CAP_WAKE_ALARM",
93453+ "CAP_BLOCK_SUSPEND",
93454+ "CAP_AUDIT_READ"
93455+};
93456+
93457+int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
93458+
93459+int gr_is_capable(const int cap)
93460+{
93461+#ifdef CONFIG_GRKERNSEC
93462+ if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
93463+ return 1;
93464+ return 0;
93465+#else
93466+ return 1;
93467+#endif
93468+}
93469+
93470+int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
93471+{
93472+#ifdef CONFIG_GRKERNSEC
93473+ if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
93474+ return 1;
93475+ return 0;
93476+#else
93477+ return 1;
93478+#endif
93479+}
93480+
93481+int gr_is_capable_nolog(const int cap)
93482+{
93483+#ifdef CONFIG_GRKERNSEC
93484+ if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
93485+ return 1;
93486+ return 0;
93487+#else
93488+ return 1;
93489+#endif
93490+}
93491+
93492+int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
93493+{
93494+#ifdef CONFIG_GRKERNSEC
93495+ if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
93496+ return 1;
93497+ return 0;
93498+#else
93499+ return 1;
93500+#endif
93501+}
93502+
93503+EXPORT_SYMBOL_GPL(gr_is_capable);
93504+EXPORT_SYMBOL_GPL(gr_is_capable_nolog);
93505+EXPORT_SYMBOL_GPL(gr_task_is_capable);
93506+EXPORT_SYMBOL_GPL(gr_task_is_capable_nolog);
93507diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
93508new file mode 100644
93509index 0000000..cdec49b
93510--- /dev/null
93511+++ b/grsecurity/grsec_fifo.c
93512@@ -0,0 +1,26 @@
93513+#include <linux/kernel.h>
93514+#include <linux/sched.h>
93515+#include <linux/fs.h>
93516+#include <linux/file.h>
93517+#include <linux/grinternal.h>
93518+
93519+int
93520+gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
93521+ const struct dentry *dir, const int flag, const int acc_mode)
93522+{
93523+#ifdef CONFIG_GRKERNSEC_FIFO
93524+ const struct cred *cred = current_cred();
93525+ struct inode *inode = d_backing_inode(dentry);
93526+ struct inode *dir_inode = d_backing_inode(dir);
93527+
93528+ if (grsec_enable_fifo && S_ISFIFO(inode->i_mode) &&
93529+ !(flag & O_EXCL) && (dir_inode->i_mode & S_ISVTX) &&
93530+ !uid_eq(inode->i_uid, dir_inode->i_uid) &&
93531+ !uid_eq(cred->fsuid, inode->i_uid)) {
93532+ if (!inode_permission(inode, acc_mode))
93533+ gr_log_fs_int2(GR_DONT_AUDIT, GR_FIFO_MSG, dentry, mnt, GR_GLOBAL_UID(inode->i_uid), GR_GLOBAL_GID(inode->i_gid));
93534+ return -EACCES;
93535+ }
93536+#endif
93537+ return 0;
93538+}
93539diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
93540new file mode 100644
93541index 0000000..8ca18bf
93542--- /dev/null
93543+++ b/grsecurity/grsec_fork.c
93544@@ -0,0 +1,23 @@
93545+#include <linux/kernel.h>
93546+#include <linux/sched.h>
93547+#include <linux/grsecurity.h>
93548+#include <linux/grinternal.h>
93549+#include <linux/errno.h>
93550+
93551+void
93552+gr_log_forkfail(const int retval)
93553+{
93554+#ifdef CONFIG_GRKERNSEC_FORKFAIL
93555+ if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
93556+ switch (retval) {
93557+ case -EAGAIN:
93558+ gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
93559+ break;
93560+ case -ENOMEM:
93561+ gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
93562+ break;
93563+ }
93564+ }
93565+#endif
93566+ return;
93567+}
93568diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
93569new file mode 100644
93570index 0000000..a364c58
93571--- /dev/null
93572+++ b/grsecurity/grsec_init.c
93573@@ -0,0 +1,290 @@
93574+#include <linux/kernel.h>
93575+#include <linux/sched.h>
93576+#include <linux/mm.h>
93577+#include <linux/gracl.h>
93578+#include <linux/slab.h>
93579+#include <linux/vmalloc.h>
93580+#include <linux/percpu.h>
93581+#include <linux/module.h>
93582+
93583+int grsec_enable_ptrace_readexec __read_only;
93584+int grsec_enable_setxid __read_only;
93585+int grsec_enable_symlinkown __read_only;
93586+kgid_t grsec_symlinkown_gid __read_only;
93587+int grsec_enable_brute __read_only;
93588+int grsec_enable_link __read_only;
93589+int grsec_enable_dmesg __read_only;
93590+int grsec_enable_harden_ptrace __read_only;
93591+int grsec_enable_harden_ipc __read_only;
93592+int grsec_enable_fifo __read_only;
93593+int grsec_enable_execlog __read_only;
93594+int grsec_enable_signal __read_only;
93595+int grsec_enable_forkfail __read_only;
93596+int grsec_enable_audit_ptrace __read_only;
93597+int grsec_enable_time __read_only;
93598+int grsec_enable_group __read_only;
93599+kgid_t grsec_audit_gid __read_only;
93600+int grsec_enable_chdir __read_only;
93601+int grsec_enable_mount __read_only;
93602+int grsec_enable_rofs __read_only;
93603+int grsec_deny_new_usb __read_only;
93604+int grsec_enable_chroot_findtask __read_only;
93605+int grsec_enable_chroot_mount __read_only;
93606+int grsec_enable_chroot_shmat __read_only;
93607+int grsec_enable_chroot_fchdir __read_only;
93608+int grsec_enable_chroot_double __read_only;
93609+int grsec_enable_chroot_pivot __read_only;
93610+int grsec_enable_chroot_chdir __read_only;
93611+int grsec_enable_chroot_chmod __read_only;
93612+int grsec_enable_chroot_mknod __read_only;
93613+int grsec_enable_chroot_nice __read_only;
93614+int grsec_enable_chroot_execlog __read_only;
93615+int grsec_enable_chroot_caps __read_only;
93616+int grsec_enable_chroot_rename __read_only;
93617+int grsec_enable_chroot_sysctl __read_only;
93618+int grsec_enable_chroot_unix __read_only;
93619+int grsec_enable_tpe __read_only;
93620+kgid_t grsec_tpe_gid __read_only;
93621+int grsec_enable_blackhole __read_only;
93622+#ifdef CONFIG_IPV6_MODULE
93623+EXPORT_SYMBOL_GPL(grsec_enable_blackhole);
93624+#endif
93625+int grsec_lastack_retries __read_only;
93626+int grsec_enable_tpe_all __read_only;
93627+int grsec_enable_tpe_invert __read_only;
93628+int grsec_enable_socket_all __read_only;
93629+kgid_t grsec_socket_all_gid __read_only;
93630+int grsec_enable_socket_client __read_only;
93631+kgid_t grsec_socket_client_gid __read_only;
93632+int grsec_enable_socket_server __read_only;
93633+kgid_t grsec_socket_server_gid __read_only;
93634+int grsec_resource_logging __read_only;
93635+int grsec_disable_privio __read_only;
93636+int grsec_enable_log_rwxmaps __read_only;
93637+int grsec_lock __read_only;
93638+
93639+DEFINE_SPINLOCK(grsec_alert_lock);
93640+unsigned long grsec_alert_wtime = 0;
93641+unsigned long grsec_alert_fyet = 0;
93642+
93643+DEFINE_SPINLOCK(grsec_audit_lock);
93644+
93645+DEFINE_RWLOCK(grsec_exec_file_lock);
93646+
93647+char *gr_shared_page[4];
93648+
93649+char *gr_alert_log_fmt;
93650+char *gr_audit_log_fmt;
93651+char *gr_alert_log_buf;
93652+char *gr_audit_log_buf;
93653+
93654+extern struct gr_arg *gr_usermode;
93655+extern unsigned char *gr_system_salt;
93656+extern unsigned char *gr_system_sum;
93657+
93658+void __init
93659+grsecurity_init(void)
93660+{
93661+ int j;
93662+ /* create the per-cpu shared pages */
93663+
93664+#ifdef CONFIG_X86
93665+ memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
93666+#endif
93667+
93668+ for (j = 0; j < 4; j++) {
93669+ gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
93670+ if (gr_shared_page[j] == NULL) {
93671+ panic("Unable to allocate grsecurity shared page");
93672+ return;
93673+ }
93674+ }
93675+
93676+ /* allocate log buffers */
93677+ gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
93678+ if (!gr_alert_log_fmt) {
93679+ panic("Unable to allocate grsecurity alert log format buffer");
93680+ return;
93681+ }
93682+ gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
93683+ if (!gr_audit_log_fmt) {
93684+ panic("Unable to allocate grsecurity audit log format buffer");
93685+ return;
93686+ }
93687+ gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
93688+ if (!gr_alert_log_buf) {
93689+ panic("Unable to allocate grsecurity alert log buffer");
93690+ return;
93691+ }
93692+ gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
93693+ if (!gr_audit_log_buf) {
93694+ panic("Unable to allocate grsecurity audit log buffer");
93695+ return;
93696+ }
93697+
93698+ /* allocate memory for authentication structure */
93699+ gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
93700+ gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
93701+ gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
93702+
93703+ if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
93704+ panic("Unable to allocate grsecurity authentication structure");
93705+ return;
93706+ }
93707+
93708+#ifdef CONFIG_GRKERNSEC_IO
93709+#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
93710+ grsec_disable_privio = 1;
93711+#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
93712+ grsec_disable_privio = 1;
93713+#else
93714+ grsec_disable_privio = 0;
93715+#endif
93716+#endif
93717+
93718+#ifdef CONFIG_GRKERNSEC_TPE_INVERT
93719+ /* for backward compatibility, tpe_invert always defaults to on if
93720+ enabled in the kernel
93721+ */
93722+ grsec_enable_tpe_invert = 1;
93723+#endif
93724+
93725+#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
93726+#ifndef CONFIG_GRKERNSEC_SYSCTL
93727+ grsec_lock = 1;
93728+#endif
93729+
93730+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
93731+ grsec_enable_log_rwxmaps = 1;
93732+#endif
93733+#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
93734+ grsec_enable_group = 1;
93735+ grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
93736+#endif
93737+#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
93738+ grsec_enable_ptrace_readexec = 1;
93739+#endif
93740+#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
93741+ grsec_enable_chdir = 1;
93742+#endif
93743+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
93744+ grsec_enable_harden_ptrace = 1;
93745+#endif
93746+#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
93747+ grsec_enable_harden_ipc = 1;
93748+#endif
93749+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
93750+ grsec_enable_mount = 1;
93751+#endif
93752+#ifdef CONFIG_GRKERNSEC_LINK
93753+ grsec_enable_link = 1;
93754+#endif
93755+#ifdef CONFIG_GRKERNSEC_BRUTE
93756+ grsec_enable_brute = 1;
93757+#endif
93758+#ifdef CONFIG_GRKERNSEC_DMESG
93759+ grsec_enable_dmesg = 1;
93760+#endif
93761+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93762+ grsec_enable_blackhole = 1;
93763+ grsec_lastack_retries = 4;
93764+#endif
93765+#ifdef CONFIG_GRKERNSEC_FIFO
93766+ grsec_enable_fifo = 1;
93767+#endif
93768+#ifdef CONFIG_GRKERNSEC_EXECLOG
93769+ grsec_enable_execlog = 1;
93770+#endif
93771+#ifdef CONFIG_GRKERNSEC_SETXID
93772+ grsec_enable_setxid = 1;
93773+#endif
93774+#ifdef CONFIG_GRKERNSEC_SIGNAL
93775+ grsec_enable_signal = 1;
93776+#endif
93777+#ifdef CONFIG_GRKERNSEC_FORKFAIL
93778+ grsec_enable_forkfail = 1;
93779+#endif
93780+#ifdef CONFIG_GRKERNSEC_TIME
93781+ grsec_enable_time = 1;
93782+#endif
93783+#ifdef CONFIG_GRKERNSEC_RESLOG
93784+ grsec_resource_logging = 1;
93785+#endif
93786+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
93787+ grsec_enable_chroot_findtask = 1;
93788+#endif
93789+#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
93790+ grsec_enable_chroot_unix = 1;
93791+#endif
93792+#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
93793+ grsec_enable_chroot_mount = 1;
93794+#endif
93795+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
93796+ grsec_enable_chroot_fchdir = 1;
93797+#endif
93798+#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
93799+ grsec_enable_chroot_shmat = 1;
93800+#endif
93801+#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
93802+ grsec_enable_audit_ptrace = 1;
93803+#endif
93804+#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
93805+ grsec_enable_chroot_double = 1;
93806+#endif
93807+#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
93808+ grsec_enable_chroot_pivot = 1;
93809+#endif
93810+#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
93811+ grsec_enable_chroot_chdir = 1;
93812+#endif
93813+#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
93814+ grsec_enable_chroot_chmod = 1;
93815+#endif
93816+#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
93817+ grsec_enable_chroot_mknod = 1;
93818+#endif
93819+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
93820+ grsec_enable_chroot_nice = 1;
93821+#endif
93822+#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
93823+ grsec_enable_chroot_execlog = 1;
93824+#endif
93825+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
93826+ grsec_enable_chroot_caps = 1;
93827+#endif
93828+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
93829+ grsec_enable_chroot_rename = 1;
93830+#endif
93831+#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
93832+ grsec_enable_chroot_sysctl = 1;
93833+#endif
93834+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
93835+ grsec_enable_symlinkown = 1;
93836+ grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
93837+#endif
93838+#ifdef CONFIG_GRKERNSEC_TPE
93839+ grsec_enable_tpe = 1;
93840+ grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
93841+#ifdef CONFIG_GRKERNSEC_TPE_ALL
93842+ grsec_enable_tpe_all = 1;
93843+#endif
93844+#endif
93845+#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
93846+ grsec_enable_socket_all = 1;
93847+ grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
93848+#endif
93849+#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
93850+ grsec_enable_socket_client = 1;
93851+ grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
93852+#endif
93853+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
93854+ grsec_enable_socket_server = 1;
93855+ grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
93856+#endif
93857+#endif
93858+#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
93859+ grsec_deny_new_usb = 1;
93860+#endif
93861+
93862+ return;
93863+}
93864diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
93865new file mode 100644
93866index 0000000..1773300
93867--- /dev/null
93868+++ b/grsecurity/grsec_ipc.c
93869@@ -0,0 +1,48 @@
93870+#include <linux/kernel.h>
93871+#include <linux/mm.h>
93872+#include <linux/sched.h>
93873+#include <linux/file.h>
93874+#include <linux/ipc.h>
93875+#include <linux/ipc_namespace.h>
93876+#include <linux/grsecurity.h>
93877+#include <linux/grinternal.h>
93878+
93879+int
93880+gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
93881+{
93882+#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
93883+ int write;
93884+ int orig_granted_mode;
93885+ kuid_t euid;
93886+ kgid_t egid;
93887+
93888+ if (!grsec_enable_harden_ipc)
93889+ return 1;
93890+
93891+ euid = current_euid();
93892+ egid = current_egid();
93893+
93894+ write = requested_mode & 00002;
93895+ orig_granted_mode = ipcp->mode;
93896+
93897+ if (uid_eq(euid, ipcp->cuid) || uid_eq(euid, ipcp->uid))
93898+ orig_granted_mode >>= 6;
93899+ else {
93900+ /* if likely wrong permissions, lock to user */
93901+ if (orig_granted_mode & 0007)
93902+ orig_granted_mode = 0;
93903+ /* otherwise do a egid-only check */
93904+ else if (gid_eq(egid, ipcp->cgid) || gid_eq(egid, ipcp->gid))
93905+ orig_granted_mode >>= 3;
93906+ /* otherwise, no access */
93907+ else
93908+ orig_granted_mode = 0;
93909+ }
93910+ if (!(requested_mode & ~granted_mode & 0007) && (requested_mode & ~orig_granted_mode & 0007) &&
93911+ !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
93912+ gr_log_str_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", GR_GLOBAL_UID(ipcp->cuid));
93913+ return 0;
93914+ }
93915+#endif
93916+ return 1;
93917+}
93918diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
93919new file mode 100644
93920index 0000000..84c44a0
93921--- /dev/null
93922+++ b/grsecurity/grsec_link.c
93923@@ -0,0 +1,65 @@
93924+#include <linux/kernel.h>
93925+#include <linux/sched.h>
93926+#include <linux/fs.h>
93927+#include <linux/file.h>
93928+#include <linux/grinternal.h>
93929+
93930+int gr_get_symlinkown_enabled(void)
93931+{
93932+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
93933+ if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid))
93934+ return 1;
93935+#endif
93936+ return 0;
93937+}
93938+
93939+int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
93940+{
93941+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
93942+ const struct inode *link_inode = d_backing_inode(link->dentry);
93943+
93944+ if (target && !uid_eq(link_inode->i_uid, target->i_uid)) {
93945+ 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));
93946+ return 1;
93947+ }
93948+#endif
93949+ return 0;
93950+}
93951+
93952+int
93953+gr_handle_follow_link(const struct dentry *dentry, const struct vfsmount *mnt)
93954+{
93955+#ifdef CONFIG_GRKERNSEC_LINK
93956+ struct inode *inode = d_backing_inode(dentry);
93957+ struct inode *parent = d_backing_inode(dentry->d_parent);
93958+ const struct cred *cred = current_cred();
93959+
93960+ if (grsec_enable_link && d_is_symlink(dentry) &&
93961+ (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
93962+ (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
93963+ gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, GR_GLOBAL_UID(inode->i_uid), GR_GLOBAL_GID(inode->i_gid));
93964+ return -EACCES;
93965+ }
93966+#endif
93967+ return 0;
93968+}
93969+
93970+int
93971+gr_handle_hardlink(const struct dentry *dentry,
93972+ const struct vfsmount *mnt,
93973+ const struct filename *to)
93974+{
93975+#ifdef CONFIG_GRKERNSEC_LINK
93976+ struct inode *inode = d_backing_inode(dentry);
93977+ const struct cred *cred = current_cred();
93978+
93979+ if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
93980+ (!d_is_reg(dentry) || is_privileged_binary(dentry) ||
93981+ (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
93982+ !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
93983+ 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);
93984+ return -EPERM;
93985+ }
93986+#endif
93987+ return 0;
93988+}
93989diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
93990new file mode 100644
93991index 0000000..a24b338
93992--- /dev/null
93993+++ b/grsecurity/grsec_log.c
93994@@ -0,0 +1,340 @@
93995+#include <linux/kernel.h>
93996+#include <linux/sched.h>
93997+#include <linux/file.h>
93998+#include <linux/tty.h>
93999+#include <linux/fs.h>
94000+#include <linux/mm.h>
94001+#include <linux/grinternal.h>
94002+
94003+#ifdef CONFIG_TREE_PREEMPT_RCU
94004+#define DISABLE_PREEMPT() preempt_disable()
94005+#define ENABLE_PREEMPT() preempt_enable()
94006+#else
94007+#define DISABLE_PREEMPT()
94008+#define ENABLE_PREEMPT()
94009+#endif
94010+
94011+#define BEGIN_LOCKS(x) \
94012+ DISABLE_PREEMPT(); \
94013+ rcu_read_lock(); \
94014+ read_lock(&tasklist_lock); \
94015+ read_lock(&grsec_exec_file_lock); \
94016+ if (x != GR_DO_AUDIT) \
94017+ spin_lock(&grsec_alert_lock); \
94018+ else \
94019+ spin_lock(&grsec_audit_lock)
94020+
94021+#define END_LOCKS(x) \
94022+ if (x != GR_DO_AUDIT) \
94023+ spin_unlock(&grsec_alert_lock); \
94024+ else \
94025+ spin_unlock(&grsec_audit_lock); \
94026+ read_unlock(&grsec_exec_file_lock); \
94027+ read_unlock(&tasklist_lock); \
94028+ rcu_read_unlock(); \
94029+ ENABLE_PREEMPT(); \
94030+ if (x == GR_DONT_AUDIT) \
94031+ gr_handle_alertkill(current)
94032+
94033+enum {
94034+ FLOODING,
94035+ NO_FLOODING
94036+};
94037+
94038+extern char *gr_alert_log_fmt;
94039+extern char *gr_audit_log_fmt;
94040+extern char *gr_alert_log_buf;
94041+extern char *gr_audit_log_buf;
94042+
94043+static int gr_log_start(int audit)
94044+{
94045+ char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
94046+ char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
94047+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
94048+#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
94049+ unsigned long curr_secs = get_seconds();
94050+
94051+ if (audit == GR_DO_AUDIT)
94052+ goto set_fmt;
94053+
94054+ if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
94055+ grsec_alert_wtime = curr_secs;
94056+ grsec_alert_fyet = 0;
94057+ } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
94058+ && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
94059+ grsec_alert_fyet++;
94060+ } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
94061+ grsec_alert_wtime = curr_secs;
94062+ grsec_alert_fyet++;
94063+ printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
94064+ return FLOODING;
94065+ }
94066+ else return FLOODING;
94067+
94068+set_fmt:
94069+#endif
94070+ memset(buf, 0, PAGE_SIZE);
94071+ if (current->signal->curr_ip && gr_acl_is_enabled()) {
94072+ sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
94073+ snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
94074+ } else if (current->signal->curr_ip) {
94075+ sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
94076+ snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
94077+ } else if (gr_acl_is_enabled()) {
94078+ sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
94079+ snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
94080+ } else {
94081+ sprintf(fmt, "%s%s", loglevel, "grsec: ");
94082+ strcpy(buf, fmt);
94083+ }
94084+
94085+ return NO_FLOODING;
94086+}
94087+
94088+static void gr_log_middle(int audit, const char *msg, va_list ap)
94089+ __attribute__ ((format (printf, 2, 0)));
94090+
94091+static void gr_log_middle(int audit, const char *msg, va_list ap)
94092+{
94093+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
94094+ unsigned int len = strlen(buf);
94095+
94096+ vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
94097+
94098+ return;
94099+}
94100+
94101+static void gr_log_middle_varargs(int audit, const char *msg, ...)
94102+ __attribute__ ((format (printf, 2, 3)));
94103+
94104+static void gr_log_middle_varargs(int audit, const char *msg, ...)
94105+{
94106+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
94107+ unsigned int len = strlen(buf);
94108+ va_list ap;
94109+
94110+ va_start(ap, msg);
94111+ vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
94112+ va_end(ap);
94113+
94114+ return;
94115+}
94116+
94117+static void gr_log_end(int audit, int append_default)
94118+{
94119+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
94120+ if (append_default) {
94121+ struct task_struct *task = current;
94122+ struct task_struct *parent = task->real_parent;
94123+ const struct cred *cred = __task_cred(task);
94124+ const struct cred *pcred = __task_cred(parent);
94125+ unsigned int len = strlen(buf);
94126+
94127+ 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));
94128+ }
94129+
94130+ printk("%s\n", buf);
94131+
94132+ return;
94133+}
94134+
94135+void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
94136+{
94137+ int logtype;
94138+ char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
94139+ char *str1 = NULL, *str2 = NULL, *str3 = NULL;
94140+ void *voidptr = NULL;
94141+ int num1 = 0, num2 = 0;
94142+ unsigned long ulong1 = 0, ulong2 = 0;
94143+ struct dentry *dentry = NULL;
94144+ struct vfsmount *mnt = NULL;
94145+ struct file *file = NULL;
94146+ struct task_struct *task = NULL;
94147+ struct vm_area_struct *vma = NULL;
94148+ const struct cred *cred, *pcred;
94149+ va_list ap;
94150+
94151+ BEGIN_LOCKS(audit);
94152+ logtype = gr_log_start(audit);
94153+ if (logtype == FLOODING) {
94154+ END_LOCKS(audit);
94155+ return;
94156+ }
94157+ va_start(ap, argtypes);
94158+ switch (argtypes) {
94159+ case GR_TTYSNIFF:
94160+ task = va_arg(ap, struct task_struct *);
94161+ 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));
94162+ break;
94163+ case GR_SYSCTL_HIDDEN:
94164+ str1 = va_arg(ap, char *);
94165+ gr_log_middle_varargs(audit, msg, result, str1);
94166+ break;
94167+ case GR_RBAC:
94168+ dentry = va_arg(ap, struct dentry *);
94169+ mnt = va_arg(ap, struct vfsmount *);
94170+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
94171+ break;
94172+ case GR_RBAC_STR:
94173+ dentry = va_arg(ap, struct dentry *);
94174+ mnt = va_arg(ap, struct vfsmount *);
94175+ str1 = va_arg(ap, char *);
94176+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
94177+ break;
94178+ case GR_STR_RBAC:
94179+ str1 = va_arg(ap, char *);
94180+ dentry = va_arg(ap, struct dentry *);
94181+ mnt = va_arg(ap, struct vfsmount *);
94182+ gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
94183+ break;
94184+ case GR_RBAC_MODE2:
94185+ dentry = va_arg(ap, struct dentry *);
94186+ mnt = va_arg(ap, struct vfsmount *);
94187+ str1 = va_arg(ap, char *);
94188+ str2 = va_arg(ap, char *);
94189+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
94190+ break;
94191+ case GR_RBAC_MODE3:
94192+ dentry = va_arg(ap, struct dentry *);
94193+ mnt = va_arg(ap, struct vfsmount *);
94194+ str1 = va_arg(ap, char *);
94195+ str2 = va_arg(ap, char *);
94196+ str3 = va_arg(ap, char *);
94197+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
94198+ break;
94199+ case GR_FILENAME:
94200+ dentry = va_arg(ap, struct dentry *);
94201+ mnt = va_arg(ap, struct vfsmount *);
94202+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
94203+ break;
94204+ case GR_STR_FILENAME:
94205+ str1 = va_arg(ap, char *);
94206+ dentry = va_arg(ap, struct dentry *);
94207+ mnt = va_arg(ap, struct vfsmount *);
94208+ gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
94209+ break;
94210+ case GR_FILENAME_STR:
94211+ dentry = va_arg(ap, struct dentry *);
94212+ mnt = va_arg(ap, struct vfsmount *);
94213+ str1 = va_arg(ap, char *);
94214+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
94215+ break;
94216+ case GR_FILENAME_TWO_INT:
94217+ dentry = va_arg(ap, struct dentry *);
94218+ mnt = va_arg(ap, struct vfsmount *);
94219+ num1 = va_arg(ap, int);
94220+ num2 = va_arg(ap, int);
94221+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
94222+ break;
94223+ case GR_FILENAME_TWO_INT_STR:
94224+ dentry = va_arg(ap, struct dentry *);
94225+ mnt = va_arg(ap, struct vfsmount *);
94226+ num1 = va_arg(ap, int);
94227+ num2 = va_arg(ap, int);
94228+ str1 = va_arg(ap, char *);
94229+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
94230+ break;
94231+ case GR_TEXTREL:
94232+ str1 = va_arg(ap, char *);
94233+ file = va_arg(ap, struct file *);
94234+ ulong1 = va_arg(ap, unsigned long);
94235+ ulong2 = va_arg(ap, unsigned long);
94236+ gr_log_middle_varargs(audit, msg, str1, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
94237+ break;
94238+ case GR_PTRACE:
94239+ task = va_arg(ap, struct task_struct *);
94240+ 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));
94241+ break;
94242+ case GR_RESOURCE:
94243+ task = va_arg(ap, struct task_struct *);
94244+ cred = __task_cred(task);
94245+ pcred = __task_cred(task->real_parent);
94246+ ulong1 = va_arg(ap, unsigned long);
94247+ str1 = va_arg(ap, char *);
94248+ ulong2 = va_arg(ap, unsigned long);
94249+ 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));
94250+ break;
94251+ case GR_CAP:
94252+ task = va_arg(ap, struct task_struct *);
94253+ cred = __task_cred(task);
94254+ pcred = __task_cred(task->real_parent);
94255+ str1 = va_arg(ap, char *);
94256+ 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));
94257+ break;
94258+ case GR_SIG:
94259+ str1 = va_arg(ap, char *);
94260+ voidptr = va_arg(ap, void *);
94261+ gr_log_middle_varargs(audit, msg, str1, voidptr);
94262+ break;
94263+ case GR_SIG2:
94264+ task = va_arg(ap, struct task_struct *);
94265+ cred = __task_cred(task);
94266+ pcred = __task_cred(task->real_parent);
94267+ num1 = va_arg(ap, int);
94268+ 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));
94269+ break;
94270+ case GR_CRASH1:
94271+ task = va_arg(ap, struct task_struct *);
94272+ cred = __task_cred(task);
94273+ pcred = __task_cred(task->real_parent);
94274+ ulong1 = va_arg(ap, unsigned long);
94275+ 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);
94276+ break;
94277+ case GR_CRASH2:
94278+ task = va_arg(ap, struct task_struct *);
94279+ cred = __task_cred(task);
94280+ pcred = __task_cred(task->real_parent);
94281+ ulong1 = va_arg(ap, unsigned long);
94282+ 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);
94283+ break;
94284+ case GR_RWXMAP:
94285+ file = va_arg(ap, struct file *);
94286+ gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
94287+ break;
94288+ case GR_RWXMAPVMA:
94289+ vma = va_arg(ap, struct vm_area_struct *);
94290+ if (vma->vm_file)
94291+ str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
94292+ else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
94293+ str1 = "<stack>";
94294+ else if (vma->vm_start <= current->mm->brk &&
94295+ vma->vm_end >= current->mm->start_brk)
94296+ str1 = "<heap>";
94297+ else
94298+ str1 = "<anonymous mapping>";
94299+ gr_log_middle_varargs(audit, msg, str1);
94300+ break;
94301+ case GR_PSACCT:
94302+ {
94303+ unsigned int wday, cday;
94304+ __u8 whr, chr;
94305+ __u8 wmin, cmin;
94306+ __u8 wsec, csec;
94307+
94308+ task = va_arg(ap, struct task_struct *);
94309+ wday = va_arg(ap, unsigned int);
94310+ cday = va_arg(ap, unsigned int);
94311+ whr = va_arg(ap, int);
94312+ chr = va_arg(ap, int);
94313+ wmin = va_arg(ap, int);
94314+ cmin = va_arg(ap, int);
94315+ wsec = va_arg(ap, int);
94316+ csec = va_arg(ap, int);
94317+ ulong1 = va_arg(ap, unsigned long);
94318+ cred = __task_cred(task);
94319+ pcred = __task_cred(task->real_parent);
94320+
94321+ 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));
94322+ }
94323+ break;
94324+ default:
94325+ gr_log_middle(audit, msg, ap);
94326+ }
94327+ va_end(ap);
94328+ // these don't need DEFAULTSECARGS printed on the end
94329+ if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
94330+ gr_log_end(audit, 0);
94331+ else
94332+ gr_log_end(audit, 1);
94333+ END_LOCKS(audit);
94334+}
94335diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
94336new file mode 100644
94337index 0000000..0e39d8c
94338--- /dev/null
94339+++ b/grsecurity/grsec_mem.c
94340@@ -0,0 +1,48 @@
94341+#include <linux/kernel.h>
94342+#include <linux/sched.h>
94343+#include <linux/mm.h>
94344+#include <linux/mman.h>
94345+#include <linux/module.h>
94346+#include <linux/grinternal.h>
94347+
94348+void gr_handle_msr_write(void)
94349+{
94350+ gr_log_noargs(GR_DONT_AUDIT, GR_MSRWRITE_MSG);
94351+ return;
94352+}
94353+EXPORT_SYMBOL_GPL(gr_handle_msr_write);
94354+
94355+void
94356+gr_handle_ioperm(void)
94357+{
94358+ gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
94359+ return;
94360+}
94361+
94362+void
94363+gr_handle_iopl(void)
94364+{
94365+ gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
94366+ return;
94367+}
94368+
94369+void
94370+gr_handle_mem_readwrite(u64 from, u64 to)
94371+{
94372+ gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
94373+ return;
94374+}
94375+
94376+void
94377+gr_handle_vm86(void)
94378+{
94379+ gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
94380+ return;
94381+}
94382+
94383+void
94384+gr_log_badprocpid(const char *entry)
94385+{
94386+ gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
94387+ return;
94388+}
94389diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
94390new file mode 100644
94391index 0000000..fe02bf4
94392--- /dev/null
94393+++ b/grsecurity/grsec_mount.c
94394@@ -0,0 +1,65 @@
94395+#include <linux/kernel.h>
94396+#include <linux/sched.h>
94397+#include <linux/mount.h>
94398+#include <linux/major.h>
94399+#include <linux/grsecurity.h>
94400+#include <linux/grinternal.h>
94401+
94402+void
94403+gr_log_remount(const char *devname, const int retval)
94404+{
94405+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
94406+ if (grsec_enable_mount && (retval >= 0))
94407+ gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
94408+#endif
94409+ return;
94410+}
94411+
94412+void
94413+gr_log_unmount(const char *devname, const int retval)
94414+{
94415+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
94416+ if (grsec_enable_mount && (retval >= 0))
94417+ gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
94418+#endif
94419+ return;
94420+}
94421+
94422+void
94423+gr_log_mount(const char *from, struct path *to, const int retval)
94424+{
94425+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
94426+ if (grsec_enable_mount && (retval >= 0))
94427+ gr_log_str_fs(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to->dentry, to->mnt);
94428+#endif
94429+ return;
94430+}
94431+
94432+int
94433+gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
94434+{
94435+#ifdef CONFIG_GRKERNSEC_ROFS
94436+ if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
94437+ gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
94438+ return -EPERM;
94439+ } else
94440+ return 0;
94441+#endif
94442+ return 0;
94443+}
94444+
94445+int
94446+gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
94447+{
94448+#ifdef CONFIG_GRKERNSEC_ROFS
94449+ struct inode *inode = d_backing_inode(dentry);
94450+
94451+ if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
94452+ inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR))) {
94453+ gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
94454+ return -EPERM;
94455+ } else
94456+ return 0;
94457+#endif
94458+ return 0;
94459+}
94460diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
94461new file mode 100644
94462index 0000000..2ad7b96
94463--- /dev/null
94464+++ b/grsecurity/grsec_pax.c
94465@@ -0,0 +1,47 @@
94466+#include <linux/kernel.h>
94467+#include <linux/sched.h>
94468+#include <linux/mm.h>
94469+#include <linux/file.h>
94470+#include <linux/grinternal.h>
94471+#include <linux/grsecurity.h>
94472+
94473+void
94474+gr_log_textrel(struct vm_area_struct * vma, bool is_textrel_rw)
94475+{
94476+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94477+ if (grsec_enable_log_rwxmaps)
94478+ gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG,
94479+ is_textrel_rw ? "executable to writable" : "writable to executable",
94480+ vma->vm_file, vma->vm_start, vma->vm_pgoff);
94481+#endif
94482+ return;
94483+}
94484+
94485+void gr_log_ptgnustack(struct file *file)
94486+{
94487+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94488+ if (grsec_enable_log_rwxmaps)
94489+ gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
94490+#endif
94491+ return;
94492+}
94493+
94494+void
94495+gr_log_rwxmmap(struct file *file)
94496+{
94497+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94498+ if (grsec_enable_log_rwxmaps)
94499+ gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
94500+#endif
94501+ return;
94502+}
94503+
94504+void
94505+gr_log_rwxmprotect(struct vm_area_struct *vma)
94506+{
94507+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
94508+ if (grsec_enable_log_rwxmaps)
94509+ gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
94510+#endif
94511+ return;
94512+}
94513diff --git a/grsecurity/grsec_proc.c b/grsecurity/grsec_proc.c
94514new file mode 100644
94515index 0000000..2005a3a
94516--- /dev/null
94517+++ b/grsecurity/grsec_proc.c
94518@@ -0,0 +1,20 @@
94519+#include <linux/kernel.h>
94520+#include <linux/sched.h>
94521+#include <linux/grsecurity.h>
94522+#include <linux/grinternal.h>
94523+
94524+int gr_proc_is_restricted(void)
94525+{
94526+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
94527+ const struct cred *cred = current_cred();
94528+#endif
94529+
94530+#ifdef CONFIG_GRKERNSEC_PROC_USER
94531+ if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
94532+ return -EACCES;
94533+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
94534+ if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
94535+ return -EACCES;
94536+#endif
94537+ return 0;
94538+}
94539diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
94540new file mode 100644
94541index 0000000..304c518
94542--- /dev/null
94543+++ b/grsecurity/grsec_ptrace.c
94544@@ -0,0 +1,30 @@
94545+#include <linux/kernel.h>
94546+#include <linux/sched.h>
94547+#include <linux/grinternal.h>
94548+#include <linux/security.h>
94549+
94550+void
94551+gr_audit_ptrace(struct task_struct *task)
94552+{
94553+#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
94554+ if (grsec_enable_audit_ptrace)
94555+ gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
94556+#endif
94557+ return;
94558+}
94559+
94560+int
94561+gr_ptrace_readexec(struct file *file, int unsafe_flags)
94562+{
94563+#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
94564+ const struct dentry *dentry = file->f_path.dentry;
94565+ const struct vfsmount *mnt = file->f_path.mnt;
94566+
94567+ if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
94568+ (inode_permission(d_backing_inode(dentry), MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
94569+ gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
94570+ return -EACCES;
94571+ }
94572+#endif
94573+ return 0;
94574+}
94575diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
94576new file mode 100644
94577index 0000000..3860c7e
94578--- /dev/null
94579+++ b/grsecurity/grsec_sig.c
94580@@ -0,0 +1,236 @@
94581+#include <linux/kernel.h>
94582+#include <linux/sched.h>
94583+#include <linux/fs.h>
94584+#include <linux/delay.h>
94585+#include <linux/grsecurity.h>
94586+#include <linux/grinternal.h>
94587+#include <linux/hardirq.h>
94588+
94589+char *signames[] = {
94590+ [SIGSEGV] = "Segmentation fault",
94591+ [SIGILL] = "Illegal instruction",
94592+ [SIGABRT] = "Abort",
94593+ [SIGBUS] = "Invalid alignment/Bus error"
94594+};
94595+
94596+void
94597+gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
94598+{
94599+#ifdef CONFIG_GRKERNSEC_SIGNAL
94600+ if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
94601+ (sig == SIGABRT) || (sig == SIGBUS))) {
94602+ if (task_pid_nr(t) == task_pid_nr(current)) {
94603+ gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
94604+ } else {
94605+ gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
94606+ }
94607+ }
94608+#endif
94609+ return;
94610+}
94611+
94612+int
94613+gr_handle_signal(const struct task_struct *p, const int sig)
94614+{
94615+#ifdef CONFIG_GRKERNSEC
94616+ /* ignore the 0 signal for protected task checks */
94617+ if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
94618+ gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
94619+ return -EPERM;
94620+ } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
94621+ return -EPERM;
94622+ }
94623+#endif
94624+ return 0;
94625+}
94626+
94627+#ifdef CONFIG_GRKERNSEC
94628+extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
94629+
94630+int gr_fake_force_sig(int sig, struct task_struct *t)
94631+{
94632+ unsigned long int flags;
94633+ int ret, blocked, ignored;
94634+ struct k_sigaction *action;
94635+
94636+ spin_lock_irqsave(&t->sighand->siglock, flags);
94637+ action = &t->sighand->action[sig-1];
94638+ ignored = action->sa.sa_handler == SIG_IGN;
94639+ blocked = sigismember(&t->blocked, sig);
94640+ if (blocked || ignored) {
94641+ action->sa.sa_handler = SIG_DFL;
94642+ if (blocked) {
94643+ sigdelset(&t->blocked, sig);
94644+ recalc_sigpending_and_wake(t);
94645+ }
94646+ }
94647+ if (action->sa.sa_handler == SIG_DFL)
94648+ t->signal->flags &= ~SIGNAL_UNKILLABLE;
94649+ ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
94650+
94651+ spin_unlock_irqrestore(&t->sighand->siglock, flags);
94652+
94653+ return ret;
94654+}
94655+#endif
94656+
94657+#define GR_USER_BAN_TIME (15 * 60)
94658+#define GR_DAEMON_BRUTE_TIME (30 * 60)
94659+
94660+void gr_handle_brute_attach(int dumpable)
94661+{
94662+#ifdef CONFIG_GRKERNSEC_BRUTE
94663+ struct task_struct *p = current;
94664+ kuid_t uid = GLOBAL_ROOT_UID;
94665+ int daemon = 0;
94666+
94667+ if (!grsec_enable_brute)
94668+ return;
94669+
94670+ rcu_read_lock();
94671+ read_lock(&tasklist_lock);
94672+ read_lock(&grsec_exec_file_lock);
94673+ if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
94674+ p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
94675+ p->real_parent->brute = 1;
94676+ daemon = 1;
94677+ } else {
94678+ const struct cred *cred = __task_cred(p), *cred2;
94679+ struct task_struct *tsk, *tsk2;
94680+
94681+ if (dumpable != SUID_DUMP_USER && gr_is_global_nonroot(cred->uid)) {
94682+ struct user_struct *user;
94683+
94684+ uid = cred->uid;
94685+
94686+ /* this is put upon execution past expiration */
94687+ user = find_user(uid);
94688+ if (user == NULL)
94689+ goto unlock;
94690+ user->suid_banned = 1;
94691+ user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
94692+ if (user->suid_ban_expires == ~0UL)
94693+ user->suid_ban_expires--;
94694+
94695+ /* only kill other threads of the same binary, from the same user */
94696+ do_each_thread(tsk2, tsk) {
94697+ cred2 = __task_cred(tsk);
94698+ if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
94699+ gr_fake_force_sig(SIGKILL, tsk);
94700+ } while_each_thread(tsk2, tsk);
94701+ }
94702+ }
94703+unlock:
94704+ read_unlock(&grsec_exec_file_lock);
94705+ read_unlock(&tasklist_lock);
94706+ rcu_read_unlock();
94707+
94708+ if (gr_is_global_nonroot(uid))
94709+ 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);
94710+ else if (daemon)
94711+ gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
94712+
94713+#endif
94714+ return;
94715+}
94716+
94717+void gr_handle_brute_check(void)
94718+{
94719+#ifdef CONFIG_GRKERNSEC_BRUTE
94720+ struct task_struct *p = current;
94721+
94722+ if (unlikely(p->brute)) {
94723+ if (!grsec_enable_brute)
94724+ p->brute = 0;
94725+ else if (time_before(get_seconds(), p->brute_expires))
94726+ msleep(30 * 1000);
94727+ }
94728+#endif
94729+ return;
94730+}
94731+
94732+void gr_handle_kernel_exploit(void)
94733+{
94734+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
94735+ const struct cred *cred;
94736+ struct task_struct *tsk, *tsk2;
94737+ struct user_struct *user;
94738+ kuid_t uid;
94739+
94740+ if (in_irq() || in_serving_softirq() || in_nmi())
94741+ panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
94742+
94743+ uid = current_uid();
94744+
94745+ if (gr_is_global_root(uid))
94746+ panic("grsec: halting the system due to suspicious kernel crash caused by root");
94747+ else {
94748+ /* kill all the processes of this user, hold a reference
94749+ to their creds struct, and prevent them from creating
94750+ another process until system reset
94751+ */
94752+ printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
94753+ GR_GLOBAL_UID(uid));
94754+ /* we intentionally leak this ref */
94755+ user = get_uid(current->cred->user);
94756+ if (user)
94757+ user->kernel_banned = 1;
94758+
94759+ /* kill all processes of this user */
94760+ read_lock(&tasklist_lock);
94761+ do_each_thread(tsk2, tsk) {
94762+ cred = __task_cred(tsk);
94763+ if (uid_eq(cred->uid, uid))
94764+ gr_fake_force_sig(SIGKILL, tsk);
94765+ } while_each_thread(tsk2, tsk);
94766+ read_unlock(&tasklist_lock);
94767+ }
94768+#endif
94769+}
94770+
94771+#ifdef CONFIG_GRKERNSEC_BRUTE
94772+static bool suid_ban_expired(struct user_struct *user)
94773+{
94774+ if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
94775+ user->suid_banned = 0;
94776+ user->suid_ban_expires = 0;
94777+ free_uid(user);
94778+ return true;
94779+ }
94780+
94781+ return false;
94782+}
94783+#endif
94784+
94785+int gr_process_kernel_exec_ban(void)
94786+{
94787+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
94788+ if (unlikely(current->cred->user->kernel_banned))
94789+ return -EPERM;
94790+#endif
94791+ return 0;
94792+}
94793+
94794+int gr_process_kernel_setuid_ban(struct user_struct *user)
94795+{
94796+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
94797+ if (unlikely(user->kernel_banned))
94798+ gr_fake_force_sig(SIGKILL, current);
94799+#endif
94800+ return 0;
94801+}
94802+
94803+int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
94804+{
94805+#ifdef CONFIG_GRKERNSEC_BRUTE
94806+ struct user_struct *user = current->cred->user;
94807+ if (unlikely(user->suid_banned)) {
94808+ if (suid_ban_expired(user))
94809+ return 0;
94810+ /* disallow execution of suid binaries only */
94811+ else if (!uid_eq(bprm->cred->euid, current->cred->uid))
94812+ return -EPERM;
94813+ }
94814+#endif
94815+ return 0;
94816+}
94817diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
94818new file mode 100644
94819index 0000000..a523bd2
94820--- /dev/null
94821+++ b/grsecurity/grsec_sock.c
94822@@ -0,0 +1,244 @@
94823+#include <linux/kernel.h>
94824+#include <linux/module.h>
94825+#include <linux/sched.h>
94826+#include <linux/file.h>
94827+#include <linux/net.h>
94828+#include <linux/in.h>
94829+#include <linux/ip.h>
94830+#include <net/sock.h>
94831+#include <net/inet_sock.h>
94832+#include <linux/grsecurity.h>
94833+#include <linux/grinternal.h>
94834+#include <linux/gracl.h>
94835+
94836+extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
94837+extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
94838+
94839+EXPORT_SYMBOL_GPL(gr_search_udp_recvmsg);
94840+EXPORT_SYMBOL_GPL(gr_search_udp_sendmsg);
94841+
94842+#ifdef CONFIG_UNIX_MODULE
94843+EXPORT_SYMBOL_GPL(gr_acl_handle_unix);
94844+EXPORT_SYMBOL_GPL(gr_acl_handle_mknod);
94845+EXPORT_SYMBOL_GPL(gr_handle_chroot_unix);
94846+EXPORT_SYMBOL_GPL(gr_handle_create);
94847+#endif
94848+
94849+#ifdef CONFIG_GRKERNSEC
94850+#define gr_conn_table_size 32749
94851+struct conn_table_entry {
94852+ struct conn_table_entry *next;
94853+ struct signal_struct *sig;
94854+};
94855+
94856+struct conn_table_entry *gr_conn_table[gr_conn_table_size];
94857+DEFINE_SPINLOCK(gr_conn_table_lock);
94858+
94859+extern const char * gr_socktype_to_name(unsigned char type);
94860+extern const char * gr_proto_to_name(unsigned char proto);
94861+extern const char * gr_sockfamily_to_name(unsigned char family);
94862+
94863+static int
94864+conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
94865+{
94866+ return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
94867+}
94868+
94869+static int
94870+conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
94871+ __u16 sport, __u16 dport)
94872+{
94873+ if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
94874+ sig->gr_sport == sport && sig->gr_dport == dport))
94875+ return 1;
94876+ else
94877+ return 0;
94878+}
94879+
94880+static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
94881+{
94882+ struct conn_table_entry **match;
94883+ unsigned int index;
94884+
94885+ index = conn_hash(sig->gr_saddr, sig->gr_daddr,
94886+ sig->gr_sport, sig->gr_dport,
94887+ gr_conn_table_size);
94888+
94889+ newent->sig = sig;
94890+
94891+ match = &gr_conn_table[index];
94892+ newent->next = *match;
94893+ *match = newent;
94894+
94895+ return;
94896+}
94897+
94898+static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
94899+{
94900+ struct conn_table_entry *match, *last = NULL;
94901+ unsigned int index;
94902+
94903+ index = conn_hash(sig->gr_saddr, sig->gr_daddr,
94904+ sig->gr_sport, sig->gr_dport,
94905+ gr_conn_table_size);
94906+
94907+ match = gr_conn_table[index];
94908+ while (match && !conn_match(match->sig,
94909+ sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
94910+ sig->gr_dport)) {
94911+ last = match;
94912+ match = match->next;
94913+ }
94914+
94915+ if (match) {
94916+ if (last)
94917+ last->next = match->next;
94918+ else
94919+ gr_conn_table[index] = NULL;
94920+ kfree(match);
94921+ }
94922+
94923+ return;
94924+}
94925+
94926+static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
94927+ __u16 sport, __u16 dport)
94928+{
94929+ struct conn_table_entry *match;
94930+ unsigned int index;
94931+
94932+ index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
94933+
94934+ match = gr_conn_table[index];
94935+ while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
94936+ match = match->next;
94937+
94938+ if (match)
94939+ return match->sig;
94940+ else
94941+ return NULL;
94942+}
94943+
94944+#endif
94945+
94946+void gr_update_task_in_ip_table(const struct inet_sock *inet)
94947+{
94948+#ifdef CONFIG_GRKERNSEC
94949+ struct signal_struct *sig = current->signal;
94950+ struct conn_table_entry *newent;
94951+
94952+ newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
94953+ if (newent == NULL)
94954+ return;
94955+ /* no bh lock needed since we are called with bh disabled */
94956+ spin_lock(&gr_conn_table_lock);
94957+ gr_del_task_from_ip_table_nolock(sig);
94958+ sig->gr_saddr = inet->inet_rcv_saddr;
94959+ sig->gr_daddr = inet->inet_daddr;
94960+ sig->gr_sport = inet->inet_sport;
94961+ sig->gr_dport = inet->inet_dport;
94962+ gr_add_to_task_ip_table_nolock(sig, newent);
94963+ spin_unlock(&gr_conn_table_lock);
94964+#endif
94965+ return;
94966+}
94967+
94968+void gr_del_task_from_ip_table(struct task_struct *task)
94969+{
94970+#ifdef CONFIG_GRKERNSEC
94971+ spin_lock_bh(&gr_conn_table_lock);
94972+ gr_del_task_from_ip_table_nolock(task->signal);
94973+ spin_unlock_bh(&gr_conn_table_lock);
94974+#endif
94975+ return;
94976+}
94977+
94978+void
94979+gr_attach_curr_ip(const struct sock *sk)
94980+{
94981+#ifdef CONFIG_GRKERNSEC
94982+ struct signal_struct *p, *set;
94983+ const struct inet_sock *inet = inet_sk(sk);
94984+
94985+ if (unlikely(sk->sk_protocol != IPPROTO_TCP))
94986+ return;
94987+
94988+ set = current->signal;
94989+
94990+ spin_lock_bh(&gr_conn_table_lock);
94991+ p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
94992+ inet->inet_dport, inet->inet_sport);
94993+ if (unlikely(p != NULL)) {
94994+ set->curr_ip = p->curr_ip;
94995+ set->used_accept = 1;
94996+ gr_del_task_from_ip_table_nolock(p);
94997+ spin_unlock_bh(&gr_conn_table_lock);
94998+ return;
94999+ }
95000+ spin_unlock_bh(&gr_conn_table_lock);
95001+
95002+ set->curr_ip = inet->inet_daddr;
95003+ set->used_accept = 1;
95004+#endif
95005+ return;
95006+}
95007+
95008+int
95009+gr_handle_sock_all(const int family, const int type, const int protocol)
95010+{
95011+#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
95012+ if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
95013+ (family != AF_UNIX)) {
95014+ if (family == AF_INET)
95015+ gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
95016+ else
95017+ gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
95018+ return -EACCES;
95019+ }
95020+#endif
95021+ return 0;
95022+}
95023+
95024+int
95025+gr_handle_sock_server(const struct sockaddr *sck)
95026+{
95027+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
95028+ if (grsec_enable_socket_server &&
95029+ in_group_p(grsec_socket_server_gid) &&
95030+ sck && (sck->sa_family != AF_UNIX) &&
95031+ (sck->sa_family != AF_LOCAL)) {
95032+ gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
95033+ return -EACCES;
95034+ }
95035+#endif
95036+ return 0;
95037+}
95038+
95039+int
95040+gr_handle_sock_server_other(const struct sock *sck)
95041+{
95042+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
95043+ if (grsec_enable_socket_server &&
95044+ in_group_p(grsec_socket_server_gid) &&
95045+ sck && (sck->sk_family != AF_UNIX) &&
95046+ (sck->sk_family != AF_LOCAL)) {
95047+ gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
95048+ return -EACCES;
95049+ }
95050+#endif
95051+ return 0;
95052+}
95053+
95054+int
95055+gr_handle_sock_client(const struct sockaddr *sck)
95056+{
95057+#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
95058+ if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
95059+ sck && (sck->sa_family != AF_UNIX) &&
95060+ (sck->sa_family != AF_LOCAL)) {
95061+ gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
95062+ return -EACCES;
95063+ }
95064+#endif
95065+ return 0;
95066+}
95067diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
95068new file mode 100644
95069index 0000000..aaec43c
95070--- /dev/null
95071+++ b/grsecurity/grsec_sysctl.c
95072@@ -0,0 +1,488 @@
95073+#include <linux/kernel.h>
95074+#include <linux/sched.h>
95075+#include <linux/sysctl.h>
95076+#include <linux/grsecurity.h>
95077+#include <linux/grinternal.h>
95078+
95079+int
95080+gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
95081+{
95082+#ifdef CONFIG_GRKERNSEC_SYSCTL
95083+ if (dirname == NULL || name == NULL)
95084+ return 0;
95085+ if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
95086+ gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
95087+ return -EACCES;
95088+ }
95089+#endif
95090+ return 0;
95091+}
95092+
95093+#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
95094+static int __maybe_unused __read_only one = 1;
95095+#endif
95096+
95097+#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
95098+ defined(CONFIG_GRKERNSEC_DENYUSB)
95099+struct ctl_table grsecurity_table[] = {
95100+#ifdef CONFIG_GRKERNSEC_SYSCTL
95101+#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
95102+#ifdef CONFIG_GRKERNSEC_IO
95103+ {
95104+ .procname = "disable_priv_io",
95105+ .data = &grsec_disable_privio,
95106+ .maxlen = sizeof(int),
95107+ .mode = 0600,
95108+ .proc_handler = &proc_dointvec_secure,
95109+ },
95110+#endif
95111+#endif
95112+#ifdef CONFIG_GRKERNSEC_LINK
95113+ {
95114+ .procname = "linking_restrictions",
95115+ .data = &grsec_enable_link,
95116+ .maxlen = sizeof(int),
95117+ .mode = 0600,
95118+ .proc_handler = &proc_dointvec_secure,
95119+ },
95120+#endif
95121+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
95122+ {
95123+ .procname = "enforce_symlinksifowner",
95124+ .data = &grsec_enable_symlinkown,
95125+ .maxlen = sizeof(int),
95126+ .mode = 0600,
95127+ .proc_handler = &proc_dointvec_secure,
95128+ },
95129+ {
95130+ .procname = "symlinkown_gid",
95131+ .data = &grsec_symlinkown_gid,
95132+ .maxlen = sizeof(int),
95133+ .mode = 0600,
95134+ .proc_handler = &proc_dointvec_secure,
95135+ },
95136+#endif
95137+#ifdef CONFIG_GRKERNSEC_BRUTE
95138+ {
95139+ .procname = "deter_bruteforce",
95140+ .data = &grsec_enable_brute,
95141+ .maxlen = sizeof(int),
95142+ .mode = 0600,
95143+ .proc_handler = &proc_dointvec_secure,
95144+ },
95145+#endif
95146+#ifdef CONFIG_GRKERNSEC_FIFO
95147+ {
95148+ .procname = "fifo_restrictions",
95149+ .data = &grsec_enable_fifo,
95150+ .maxlen = sizeof(int),
95151+ .mode = 0600,
95152+ .proc_handler = &proc_dointvec_secure,
95153+ },
95154+#endif
95155+#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
95156+ {
95157+ .procname = "ptrace_readexec",
95158+ .data = &grsec_enable_ptrace_readexec,
95159+ .maxlen = sizeof(int),
95160+ .mode = 0600,
95161+ .proc_handler = &proc_dointvec_secure,
95162+ },
95163+#endif
95164+#ifdef CONFIG_GRKERNSEC_SETXID
95165+ {
95166+ .procname = "consistent_setxid",
95167+ .data = &grsec_enable_setxid,
95168+ .maxlen = sizeof(int),
95169+ .mode = 0600,
95170+ .proc_handler = &proc_dointvec_secure,
95171+ },
95172+#endif
95173+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95174+ {
95175+ .procname = "ip_blackhole",
95176+ .data = &grsec_enable_blackhole,
95177+ .maxlen = sizeof(int),
95178+ .mode = 0600,
95179+ .proc_handler = &proc_dointvec_secure,
95180+ },
95181+ {
95182+ .procname = "lastack_retries",
95183+ .data = &grsec_lastack_retries,
95184+ .maxlen = sizeof(int),
95185+ .mode = 0600,
95186+ .proc_handler = &proc_dointvec_secure,
95187+ },
95188+#endif
95189+#ifdef CONFIG_GRKERNSEC_EXECLOG
95190+ {
95191+ .procname = "exec_logging",
95192+ .data = &grsec_enable_execlog,
95193+ .maxlen = sizeof(int),
95194+ .mode = 0600,
95195+ .proc_handler = &proc_dointvec_secure,
95196+ },
95197+#endif
95198+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
95199+ {
95200+ .procname = "rwxmap_logging",
95201+ .data = &grsec_enable_log_rwxmaps,
95202+ .maxlen = sizeof(int),
95203+ .mode = 0600,
95204+ .proc_handler = &proc_dointvec_secure,
95205+ },
95206+#endif
95207+#ifdef CONFIG_GRKERNSEC_SIGNAL
95208+ {
95209+ .procname = "signal_logging",
95210+ .data = &grsec_enable_signal,
95211+ .maxlen = sizeof(int),
95212+ .mode = 0600,
95213+ .proc_handler = &proc_dointvec_secure,
95214+ },
95215+#endif
95216+#ifdef CONFIG_GRKERNSEC_FORKFAIL
95217+ {
95218+ .procname = "forkfail_logging",
95219+ .data = &grsec_enable_forkfail,
95220+ .maxlen = sizeof(int),
95221+ .mode = 0600,
95222+ .proc_handler = &proc_dointvec_secure,
95223+ },
95224+#endif
95225+#ifdef CONFIG_GRKERNSEC_TIME
95226+ {
95227+ .procname = "timechange_logging",
95228+ .data = &grsec_enable_time,
95229+ .maxlen = sizeof(int),
95230+ .mode = 0600,
95231+ .proc_handler = &proc_dointvec_secure,
95232+ },
95233+#endif
95234+#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
95235+ {
95236+ .procname = "chroot_deny_shmat",
95237+ .data = &grsec_enable_chroot_shmat,
95238+ .maxlen = sizeof(int),
95239+ .mode = 0600,
95240+ .proc_handler = &proc_dointvec_secure,
95241+ },
95242+#endif
95243+#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
95244+ {
95245+ .procname = "chroot_deny_unix",
95246+ .data = &grsec_enable_chroot_unix,
95247+ .maxlen = sizeof(int),
95248+ .mode = 0600,
95249+ .proc_handler = &proc_dointvec_secure,
95250+ },
95251+#endif
95252+#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
95253+ {
95254+ .procname = "chroot_deny_mount",
95255+ .data = &grsec_enable_chroot_mount,
95256+ .maxlen = sizeof(int),
95257+ .mode = 0600,
95258+ .proc_handler = &proc_dointvec_secure,
95259+ },
95260+#endif
95261+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
95262+ {
95263+ .procname = "chroot_deny_fchdir",
95264+ .data = &grsec_enable_chroot_fchdir,
95265+ .maxlen = sizeof(int),
95266+ .mode = 0600,
95267+ .proc_handler = &proc_dointvec_secure,
95268+ },
95269+#endif
95270+#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
95271+ {
95272+ .procname = "chroot_deny_chroot",
95273+ .data = &grsec_enable_chroot_double,
95274+ .maxlen = sizeof(int),
95275+ .mode = 0600,
95276+ .proc_handler = &proc_dointvec_secure,
95277+ },
95278+#endif
95279+#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
95280+ {
95281+ .procname = "chroot_deny_pivot",
95282+ .data = &grsec_enable_chroot_pivot,
95283+ .maxlen = sizeof(int),
95284+ .mode = 0600,
95285+ .proc_handler = &proc_dointvec_secure,
95286+ },
95287+#endif
95288+#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
95289+ {
95290+ .procname = "chroot_enforce_chdir",
95291+ .data = &grsec_enable_chroot_chdir,
95292+ .maxlen = sizeof(int),
95293+ .mode = 0600,
95294+ .proc_handler = &proc_dointvec_secure,
95295+ },
95296+#endif
95297+#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
95298+ {
95299+ .procname = "chroot_deny_chmod",
95300+ .data = &grsec_enable_chroot_chmod,
95301+ .maxlen = sizeof(int),
95302+ .mode = 0600,
95303+ .proc_handler = &proc_dointvec_secure,
95304+ },
95305+#endif
95306+#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
95307+ {
95308+ .procname = "chroot_deny_mknod",
95309+ .data = &grsec_enable_chroot_mknod,
95310+ .maxlen = sizeof(int),
95311+ .mode = 0600,
95312+ .proc_handler = &proc_dointvec_secure,
95313+ },
95314+#endif
95315+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
95316+ {
95317+ .procname = "chroot_restrict_nice",
95318+ .data = &grsec_enable_chroot_nice,
95319+ .maxlen = sizeof(int),
95320+ .mode = 0600,
95321+ .proc_handler = &proc_dointvec_secure,
95322+ },
95323+#endif
95324+#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
95325+ {
95326+ .procname = "chroot_execlog",
95327+ .data = &grsec_enable_chroot_execlog,
95328+ .maxlen = sizeof(int),
95329+ .mode = 0600,
95330+ .proc_handler = &proc_dointvec_secure,
95331+ },
95332+#endif
95333+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
95334+ {
95335+ .procname = "chroot_caps",
95336+ .data = &grsec_enable_chroot_caps,
95337+ .maxlen = sizeof(int),
95338+ .mode = 0600,
95339+ .proc_handler = &proc_dointvec_secure,
95340+ },
95341+#endif
95342+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
95343+ {
95344+ .procname = "chroot_deny_bad_rename",
95345+ .data = &grsec_enable_chroot_rename,
95346+ .maxlen = sizeof(int),
95347+ .mode = 0600,
95348+ .proc_handler = &proc_dointvec_secure,
95349+ },
95350+#endif
95351+#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
95352+ {
95353+ .procname = "chroot_deny_sysctl",
95354+ .data = &grsec_enable_chroot_sysctl,
95355+ .maxlen = sizeof(int),
95356+ .mode = 0600,
95357+ .proc_handler = &proc_dointvec_secure,
95358+ },
95359+#endif
95360+#ifdef CONFIG_GRKERNSEC_TPE
95361+ {
95362+ .procname = "tpe",
95363+ .data = &grsec_enable_tpe,
95364+ .maxlen = sizeof(int),
95365+ .mode = 0600,
95366+ .proc_handler = &proc_dointvec_secure,
95367+ },
95368+ {
95369+ .procname = "tpe_gid",
95370+ .data = &grsec_tpe_gid,
95371+ .maxlen = sizeof(int),
95372+ .mode = 0600,
95373+ .proc_handler = &proc_dointvec_secure,
95374+ },
95375+#endif
95376+#ifdef CONFIG_GRKERNSEC_TPE_INVERT
95377+ {
95378+ .procname = "tpe_invert",
95379+ .data = &grsec_enable_tpe_invert,
95380+ .maxlen = sizeof(int),
95381+ .mode = 0600,
95382+ .proc_handler = &proc_dointvec_secure,
95383+ },
95384+#endif
95385+#ifdef CONFIG_GRKERNSEC_TPE_ALL
95386+ {
95387+ .procname = "tpe_restrict_all",
95388+ .data = &grsec_enable_tpe_all,
95389+ .maxlen = sizeof(int),
95390+ .mode = 0600,
95391+ .proc_handler = &proc_dointvec_secure,
95392+ },
95393+#endif
95394+#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
95395+ {
95396+ .procname = "socket_all",
95397+ .data = &grsec_enable_socket_all,
95398+ .maxlen = sizeof(int),
95399+ .mode = 0600,
95400+ .proc_handler = &proc_dointvec_secure,
95401+ },
95402+ {
95403+ .procname = "socket_all_gid",
95404+ .data = &grsec_socket_all_gid,
95405+ .maxlen = sizeof(int),
95406+ .mode = 0600,
95407+ .proc_handler = &proc_dointvec_secure,
95408+ },
95409+#endif
95410+#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
95411+ {
95412+ .procname = "socket_client",
95413+ .data = &grsec_enable_socket_client,
95414+ .maxlen = sizeof(int),
95415+ .mode = 0600,
95416+ .proc_handler = &proc_dointvec_secure,
95417+ },
95418+ {
95419+ .procname = "socket_client_gid",
95420+ .data = &grsec_socket_client_gid,
95421+ .maxlen = sizeof(int),
95422+ .mode = 0600,
95423+ .proc_handler = &proc_dointvec_secure,
95424+ },
95425+#endif
95426+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
95427+ {
95428+ .procname = "socket_server",
95429+ .data = &grsec_enable_socket_server,
95430+ .maxlen = sizeof(int),
95431+ .mode = 0600,
95432+ .proc_handler = &proc_dointvec_secure,
95433+ },
95434+ {
95435+ .procname = "socket_server_gid",
95436+ .data = &grsec_socket_server_gid,
95437+ .maxlen = sizeof(int),
95438+ .mode = 0600,
95439+ .proc_handler = &proc_dointvec_secure,
95440+ },
95441+#endif
95442+#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
95443+ {
95444+ .procname = "audit_group",
95445+ .data = &grsec_enable_group,
95446+ .maxlen = sizeof(int),
95447+ .mode = 0600,
95448+ .proc_handler = &proc_dointvec_secure,
95449+ },
95450+ {
95451+ .procname = "audit_gid",
95452+ .data = &grsec_audit_gid,
95453+ .maxlen = sizeof(int),
95454+ .mode = 0600,
95455+ .proc_handler = &proc_dointvec_secure,
95456+ },
95457+#endif
95458+#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
95459+ {
95460+ .procname = "audit_chdir",
95461+ .data = &grsec_enable_chdir,
95462+ .maxlen = sizeof(int),
95463+ .mode = 0600,
95464+ .proc_handler = &proc_dointvec_secure,
95465+ },
95466+#endif
95467+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
95468+ {
95469+ .procname = "audit_mount",
95470+ .data = &grsec_enable_mount,
95471+ .maxlen = sizeof(int),
95472+ .mode = 0600,
95473+ .proc_handler = &proc_dointvec_secure,
95474+ },
95475+#endif
95476+#ifdef CONFIG_GRKERNSEC_DMESG
95477+ {
95478+ .procname = "dmesg",
95479+ .data = &grsec_enable_dmesg,
95480+ .maxlen = sizeof(int),
95481+ .mode = 0600,
95482+ .proc_handler = &proc_dointvec_secure,
95483+ },
95484+#endif
95485+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
95486+ {
95487+ .procname = "chroot_findtask",
95488+ .data = &grsec_enable_chroot_findtask,
95489+ .maxlen = sizeof(int),
95490+ .mode = 0600,
95491+ .proc_handler = &proc_dointvec_secure,
95492+ },
95493+#endif
95494+#ifdef CONFIG_GRKERNSEC_RESLOG
95495+ {
95496+ .procname = "resource_logging",
95497+ .data = &grsec_resource_logging,
95498+ .maxlen = sizeof(int),
95499+ .mode = 0600,
95500+ .proc_handler = &proc_dointvec_secure,
95501+ },
95502+#endif
95503+#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
95504+ {
95505+ .procname = "audit_ptrace",
95506+ .data = &grsec_enable_audit_ptrace,
95507+ .maxlen = sizeof(int),
95508+ .mode = 0600,
95509+ .proc_handler = &proc_dointvec_secure,
95510+ },
95511+#endif
95512+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
95513+ {
95514+ .procname = "harden_ptrace",
95515+ .data = &grsec_enable_harden_ptrace,
95516+ .maxlen = sizeof(int),
95517+ .mode = 0600,
95518+ .proc_handler = &proc_dointvec_secure,
95519+ },
95520+#endif
95521+#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
95522+ {
95523+ .procname = "harden_ipc",
95524+ .data = &grsec_enable_harden_ipc,
95525+ .maxlen = sizeof(int),
95526+ .mode = 0600,
95527+ .proc_handler = &proc_dointvec_secure,
95528+ },
95529+#endif
95530+ {
95531+ .procname = "grsec_lock",
95532+ .data = &grsec_lock,
95533+ .maxlen = sizeof(int),
95534+ .mode = 0600,
95535+ .proc_handler = &proc_dointvec_secure,
95536+ },
95537+#endif
95538+#ifdef CONFIG_GRKERNSEC_ROFS
95539+ {
95540+ .procname = "romount_protect",
95541+ .data = &grsec_enable_rofs,
95542+ .maxlen = sizeof(int),
95543+ .mode = 0600,
95544+ .proc_handler = &proc_dointvec_minmax_secure,
95545+ .extra1 = &one,
95546+ .extra2 = &one,
95547+ },
95548+#endif
95549+#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
95550+ {
95551+ .procname = "deny_new_usb",
95552+ .data = &grsec_deny_new_usb,
95553+ .maxlen = sizeof(int),
95554+ .mode = 0600,
95555+ .proc_handler = &proc_dointvec_secure,
95556+ },
95557+#endif
95558+ { }
95559+};
95560+#endif
95561diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
95562new file mode 100644
95563index 0000000..61b514e
95564--- /dev/null
95565+++ b/grsecurity/grsec_time.c
95566@@ -0,0 +1,16 @@
95567+#include <linux/kernel.h>
95568+#include <linux/sched.h>
95569+#include <linux/grinternal.h>
95570+#include <linux/module.h>
95571+
95572+void
95573+gr_log_timechange(void)
95574+{
95575+#ifdef CONFIG_GRKERNSEC_TIME
95576+ if (grsec_enable_time)
95577+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
95578+#endif
95579+ return;
95580+}
95581+
95582+EXPORT_SYMBOL_GPL(gr_log_timechange);
95583diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
95584new file mode 100644
95585index 0000000..9786671
95586--- /dev/null
95587+++ b/grsecurity/grsec_tpe.c
95588@@ -0,0 +1,78 @@
95589+#include <linux/kernel.h>
95590+#include <linux/sched.h>
95591+#include <linux/file.h>
95592+#include <linux/fs.h>
95593+#include <linux/grinternal.h>
95594+
95595+extern int gr_acl_tpe_check(void);
95596+
95597+int
95598+gr_tpe_allow(const struct file *file)
95599+{
95600+#ifdef CONFIG_GRKERNSEC
95601+ struct inode *inode = d_backing_inode(file->f_path.dentry->d_parent);
95602+ struct inode *file_inode = d_backing_inode(file->f_path.dentry);
95603+ const struct cred *cred = current_cred();
95604+ char *msg = NULL;
95605+ char *msg2 = NULL;
95606+
95607+ // never restrict root
95608+ if (gr_is_global_root(cred->uid))
95609+ return 1;
95610+
95611+ if (grsec_enable_tpe) {
95612+#ifdef CONFIG_GRKERNSEC_TPE_INVERT
95613+ if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
95614+ msg = "not being in trusted group";
95615+ else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
95616+ msg = "being in untrusted group";
95617+#else
95618+ if (in_group_p(grsec_tpe_gid))
95619+ msg = "being in untrusted group";
95620+#endif
95621+ }
95622+ if (!msg && gr_acl_tpe_check())
95623+ msg = "being in untrusted role";
95624+
95625+ // not in any affected group/role
95626+ if (!msg)
95627+ goto next_check;
95628+
95629+ if (gr_is_global_nonroot(inode->i_uid))
95630+ msg2 = "file in non-root-owned directory";
95631+ else if (inode->i_mode & S_IWOTH)
95632+ msg2 = "file in world-writable directory";
95633+ else if (inode->i_mode & S_IWGRP)
95634+ msg2 = "file in group-writable directory";
95635+ else if (file_inode->i_mode & S_IWOTH)
95636+ msg2 = "file is world-writable";
95637+
95638+ if (msg && msg2) {
95639+ char fullmsg[70] = {0};
95640+ snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
95641+ gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
95642+ return 0;
95643+ }
95644+ msg = NULL;
95645+next_check:
95646+#ifdef CONFIG_GRKERNSEC_TPE_ALL
95647+ if (!grsec_enable_tpe || !grsec_enable_tpe_all)
95648+ return 1;
95649+
95650+ if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
95651+ msg = "directory not owned by user";
95652+ else if (inode->i_mode & S_IWOTH)
95653+ msg = "file in world-writable directory";
95654+ else if (inode->i_mode & S_IWGRP)
95655+ msg = "file in group-writable directory";
95656+ else if (file_inode->i_mode & S_IWOTH)
95657+ msg = "file is world-writable";
95658+
95659+ if (msg) {
95660+ gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
95661+ return 0;
95662+ }
95663+#endif
95664+#endif
95665+ return 1;
95666+}
95667diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
95668new file mode 100644
95669index 0000000..ae02d8e
95670--- /dev/null
95671+++ b/grsecurity/grsec_usb.c
95672@@ -0,0 +1,15 @@
95673+#include <linux/kernel.h>
95674+#include <linux/grinternal.h>
95675+#include <linux/module.h>
95676+
95677+int gr_handle_new_usb(void)
95678+{
95679+#ifdef CONFIG_GRKERNSEC_DENYUSB
95680+ if (grsec_deny_new_usb) {
95681+ printk(KERN_ALERT "grsec: denied insert of new USB device\n");
95682+ return 1;
95683+ }
95684+#endif
95685+ return 0;
95686+}
95687+EXPORT_SYMBOL_GPL(gr_handle_new_usb);
95688diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
95689new file mode 100644
95690index 0000000..158b330
95691--- /dev/null
95692+++ b/grsecurity/grsum.c
95693@@ -0,0 +1,64 @@
95694+#include <linux/err.h>
95695+#include <linux/kernel.h>
95696+#include <linux/sched.h>
95697+#include <linux/mm.h>
95698+#include <linux/scatterlist.h>
95699+#include <linux/crypto.h>
95700+#include <linux/gracl.h>
95701+
95702+
95703+#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
95704+#error "crypto and sha256 must be built into the kernel"
95705+#endif
95706+
95707+int
95708+chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
95709+{
95710+ struct crypto_hash *tfm;
95711+ struct hash_desc desc;
95712+ struct scatterlist sg[2];
95713+ unsigned char temp_sum[GR_SHA_LEN] __attribute__((aligned(__alignof__(unsigned long))));
95714+ unsigned long *tmpsumptr = (unsigned long *)temp_sum;
95715+ unsigned long *sumptr = (unsigned long *)sum;
95716+ int cryptres;
95717+ int retval = 1;
95718+ volatile int mismatched = 0;
95719+ volatile int dummy = 0;
95720+ unsigned int i;
95721+
95722+ tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
95723+ if (IS_ERR(tfm)) {
95724+ /* should never happen, since sha256 should be built in */
95725+ memset(entry->pw, 0, GR_PW_LEN);
95726+ return 1;
95727+ }
95728+
95729+ sg_init_table(sg, 2);
95730+ sg_set_buf(&sg[0], salt, GR_SALT_LEN);
95731+ sg_set_buf(&sg[1], entry->pw, strlen(entry->pw));
95732+
95733+ desc.tfm = tfm;
95734+ desc.flags = 0;
95735+
95736+ cryptres = crypto_hash_digest(&desc, sg, GR_SALT_LEN + strlen(entry->pw),
95737+ temp_sum);
95738+
95739+ memset(entry->pw, 0, GR_PW_LEN);
95740+
95741+ if (cryptres)
95742+ goto out;
95743+
95744+ for (i = 0; i < GR_SHA_LEN/sizeof(tmpsumptr[0]); i++)
95745+ if (sumptr[i] != tmpsumptr[i])
95746+ mismatched = 1;
95747+ else
95748+ dummy = 1; // waste a cycle
95749+
95750+ if (!mismatched)
95751+ retval = dummy - 1;
95752+
95753+out:
95754+ crypto_free_hash(tfm);
95755+
95756+ return retval;
95757+}
95758diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
95759index 5bdab6b..9ae82fe 100644
95760--- a/include/asm-generic/4level-fixup.h
95761+++ b/include/asm-generic/4level-fixup.h
95762@@ -14,8 +14,10 @@
95763 #define pmd_alloc(mm, pud, address) \
95764 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
95765 NULL: pmd_offset(pud, address))
95766+#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
95767
95768 #define pud_alloc(mm, pgd, address) (pgd)
95769+#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
95770 #define pud_offset(pgd, start) (pgd)
95771 #define pud_none(pud) 0
95772 #define pud_bad(pud) 0
95773diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
95774index b7babf0..1e4b4f1 100644
95775--- a/include/asm-generic/atomic-long.h
95776+++ b/include/asm-generic/atomic-long.h
95777@@ -22,6 +22,12 @@
95778
95779 typedef atomic64_t atomic_long_t;
95780
95781+#ifdef CONFIG_PAX_REFCOUNT
95782+typedef atomic64_unchecked_t atomic_long_unchecked_t;
95783+#else
95784+typedef atomic64_t atomic_long_unchecked_t;
95785+#endif
95786+
95787 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
95788
95789 static inline long atomic_long_read(atomic_long_t *l)
95790@@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
95791 return (long)atomic64_read(v);
95792 }
95793
95794+#ifdef CONFIG_PAX_REFCOUNT
95795+static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
95796+{
95797+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95798+
95799+ return (long)atomic64_read_unchecked(v);
95800+}
95801+#endif
95802+
95803 static inline void atomic_long_set(atomic_long_t *l, long i)
95804 {
95805 atomic64_t *v = (atomic64_t *)l;
95806@@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
95807 atomic64_set(v, i);
95808 }
95809
95810+#ifdef CONFIG_PAX_REFCOUNT
95811+static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
95812+{
95813+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95814+
95815+ atomic64_set_unchecked(v, i);
95816+}
95817+#endif
95818+
95819 static inline void atomic_long_inc(atomic_long_t *l)
95820 {
95821 atomic64_t *v = (atomic64_t *)l;
95822@@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
95823 atomic64_inc(v);
95824 }
95825
95826+#ifdef CONFIG_PAX_REFCOUNT
95827+static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
95828+{
95829+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95830+
95831+ atomic64_inc_unchecked(v);
95832+}
95833+#endif
95834+
95835 static inline void atomic_long_dec(atomic_long_t *l)
95836 {
95837 atomic64_t *v = (atomic64_t *)l;
95838@@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
95839 atomic64_dec(v);
95840 }
95841
95842+#ifdef CONFIG_PAX_REFCOUNT
95843+static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
95844+{
95845+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95846+
95847+ atomic64_dec_unchecked(v);
95848+}
95849+#endif
95850+
95851 static inline void atomic_long_add(long i, atomic_long_t *l)
95852 {
95853 atomic64_t *v = (atomic64_t *)l;
95854@@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
95855 atomic64_add(i, v);
95856 }
95857
95858+#ifdef CONFIG_PAX_REFCOUNT
95859+static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
95860+{
95861+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95862+
95863+ atomic64_add_unchecked(i, v);
95864+}
95865+#endif
95866+
95867 static inline void atomic_long_sub(long i, atomic_long_t *l)
95868 {
95869 atomic64_t *v = (atomic64_t *)l;
95870@@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
95871 atomic64_sub(i, v);
95872 }
95873
95874+#ifdef CONFIG_PAX_REFCOUNT
95875+static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
95876+{
95877+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95878+
95879+ atomic64_sub_unchecked(i, v);
95880+}
95881+#endif
95882+
95883 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
95884 {
95885 atomic64_t *v = (atomic64_t *)l;
95886@@ -94,13 +154,22 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
95887 return atomic64_add_negative(i, v);
95888 }
95889
95890-static inline long atomic_long_add_return(long i, atomic_long_t *l)
95891+static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
95892 {
95893 atomic64_t *v = (atomic64_t *)l;
95894
95895 return (long)atomic64_add_return(i, v);
95896 }
95897
95898+#ifdef CONFIG_PAX_REFCOUNT
95899+static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
95900+{
95901+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95902+
95903+ return (long)atomic64_add_return_unchecked(i, v);
95904+}
95905+#endif
95906+
95907 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
95908 {
95909 atomic64_t *v = (atomic64_t *)l;
95910@@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
95911 return (long)atomic64_inc_return(v);
95912 }
95913
95914+#ifdef CONFIG_PAX_REFCOUNT
95915+static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
95916+{
95917+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
95918+
95919+ return (long)atomic64_inc_return_unchecked(v);
95920+}
95921+#endif
95922+
95923 static inline long atomic_long_dec_return(atomic_long_t *l)
95924 {
95925 atomic64_t *v = (atomic64_t *)l;
95926@@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
95927
95928 typedef atomic_t atomic_long_t;
95929
95930+#ifdef CONFIG_PAX_REFCOUNT
95931+typedef atomic_unchecked_t atomic_long_unchecked_t;
95932+#else
95933+typedef atomic_t atomic_long_unchecked_t;
95934+#endif
95935+
95936 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
95937 static inline long atomic_long_read(atomic_long_t *l)
95938 {
95939@@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
95940 return (long)atomic_read(v);
95941 }
95942
95943+#ifdef CONFIG_PAX_REFCOUNT
95944+static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
95945+{
95946+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95947+
95948+ return (long)atomic_read_unchecked(v);
95949+}
95950+#endif
95951+
95952 static inline void atomic_long_set(atomic_long_t *l, long i)
95953 {
95954 atomic_t *v = (atomic_t *)l;
95955@@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
95956 atomic_set(v, i);
95957 }
95958
95959+#ifdef CONFIG_PAX_REFCOUNT
95960+static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
95961+{
95962+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95963+
95964+ atomic_set_unchecked(v, i);
95965+}
95966+#endif
95967+
95968 static inline void atomic_long_inc(atomic_long_t *l)
95969 {
95970 atomic_t *v = (atomic_t *)l;
95971@@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
95972 atomic_inc(v);
95973 }
95974
95975+#ifdef CONFIG_PAX_REFCOUNT
95976+static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
95977+{
95978+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95979+
95980+ atomic_inc_unchecked(v);
95981+}
95982+#endif
95983+
95984 static inline void atomic_long_dec(atomic_long_t *l)
95985 {
95986 atomic_t *v = (atomic_t *)l;
95987@@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
95988 atomic_dec(v);
95989 }
95990
95991+#ifdef CONFIG_PAX_REFCOUNT
95992+static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
95993+{
95994+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
95995+
95996+ atomic_dec_unchecked(v);
95997+}
95998+#endif
95999+
96000 static inline void atomic_long_add(long i, atomic_long_t *l)
96001 {
96002 atomic_t *v = (atomic_t *)l;
96003@@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
96004 atomic_add(i, v);
96005 }
96006
96007+#ifdef CONFIG_PAX_REFCOUNT
96008+static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
96009+{
96010+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
96011+
96012+ atomic_add_unchecked(i, v);
96013+}
96014+#endif
96015+
96016 static inline void atomic_long_sub(long i, atomic_long_t *l)
96017 {
96018 atomic_t *v = (atomic_t *)l;
96019@@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
96020 atomic_sub(i, v);
96021 }
96022
96023+#ifdef CONFIG_PAX_REFCOUNT
96024+static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
96025+{
96026+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
96027+
96028+ atomic_sub_unchecked(i, v);
96029+}
96030+#endif
96031+
96032 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
96033 {
96034 atomic_t *v = (atomic_t *)l;
96035@@ -211,13 +349,23 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
96036 return atomic_add_negative(i, v);
96037 }
96038
96039-static inline long atomic_long_add_return(long i, atomic_long_t *l)
96040+static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
96041 {
96042 atomic_t *v = (atomic_t *)l;
96043
96044 return (long)atomic_add_return(i, v);
96045 }
96046
96047+#ifdef CONFIG_PAX_REFCOUNT
96048+static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
96049+{
96050+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
96051+
96052+ return (long)atomic_add_return_unchecked(i, v);
96053+}
96054+
96055+#endif
96056+
96057 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
96058 {
96059 atomic_t *v = (atomic_t *)l;
96060@@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
96061 return (long)atomic_inc_return(v);
96062 }
96063
96064+#ifdef CONFIG_PAX_REFCOUNT
96065+static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
96066+{
96067+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
96068+
96069+ return (long)atomic_inc_return_unchecked(v);
96070+}
96071+#endif
96072+
96073 static inline long atomic_long_dec_return(atomic_long_t *l)
96074 {
96075 atomic_t *v = (atomic_t *)l;
96076@@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
96077
96078 #endif /* BITS_PER_LONG == 64 */
96079
96080+#ifdef CONFIG_PAX_REFCOUNT
96081+static inline void pax_refcount_needs_these_functions(void)
96082+{
96083+ atomic_read_unchecked((atomic_unchecked_t *)NULL);
96084+ atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
96085+ atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
96086+ atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
96087+ atomic_inc_unchecked((atomic_unchecked_t *)NULL);
96088+ (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
96089+ atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
96090+ atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
96091+ atomic_dec_unchecked((atomic_unchecked_t *)NULL);
96092+ atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
96093+ (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
96094+#ifdef CONFIG_X86
96095+ atomic_clear_mask_unchecked(0, NULL);
96096+ atomic_set_mask_unchecked(0, NULL);
96097+#endif
96098+
96099+ atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
96100+ atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
96101+ atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
96102+ atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
96103+ atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
96104+ atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
96105+ atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
96106+ atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
96107+}
96108+#else
96109+#define atomic_read_unchecked(v) atomic_read(v)
96110+#define atomic_set_unchecked(v, i) atomic_set((v), (i))
96111+#define atomic_add_unchecked(i, v) atomic_add((i), (v))
96112+#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
96113+#define atomic_inc_unchecked(v) atomic_inc(v)
96114+#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
96115+#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
96116+#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
96117+#define atomic_dec_unchecked(v) atomic_dec(v)
96118+#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
96119+#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
96120+#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
96121+#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
96122+
96123+#define atomic_long_read_unchecked(v) atomic_long_read(v)
96124+#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
96125+#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
96126+#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
96127+#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
96128+#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
96129+#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
96130+#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
96131+#endif
96132+
96133 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
96134diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
96135index 30ad9c8..c70c170 100644
96136--- a/include/asm-generic/atomic64.h
96137+++ b/include/asm-generic/atomic64.h
96138@@ -16,6 +16,8 @@ typedef struct {
96139 long long counter;
96140 } atomic64_t;
96141
96142+typedef atomic64_t atomic64_unchecked_t;
96143+
96144 #define ATOMIC64_INIT(i) { (i) }
96145
96146 extern long long atomic64_read(const atomic64_t *v);
96147@@ -51,4 +53,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
96148 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
96149 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
96150
96151+#define atomic64_read_unchecked(v) atomic64_read(v)
96152+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
96153+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
96154+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
96155+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
96156+#define atomic64_inc_unchecked(v) atomic64_inc(v)
96157+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
96158+#define atomic64_dec_unchecked(v) atomic64_dec(v)
96159+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
96160+
96161 #endif /* _ASM_GENERIC_ATOMIC64_H */
96162diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h
96163index 55e3abc..104e2a1 100644
96164--- a/include/asm-generic/barrier.h
96165+++ b/include/asm-generic/barrier.h
96166@@ -108,7 +108,7 @@
96167 do { \
96168 compiletime_assert_atomic_type(*p); \
96169 smp_mb(); \
96170- ACCESS_ONCE(*p) = (v); \
96171+ ACCESS_ONCE_RW(*p) = (v); \
96172 } while (0)
96173
96174 #define smp_load_acquire(p) \
96175diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h
96176index a60a7cc..0fe12f2 100644
96177--- a/include/asm-generic/bitops/__fls.h
96178+++ b/include/asm-generic/bitops/__fls.h
96179@@ -9,7 +9,7 @@
96180 *
96181 * Undefined if no set bit exists, so code should check against 0 first.
96182 */
96183-static __always_inline unsigned long __fls(unsigned long word)
96184+static __always_inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
96185 {
96186 int num = BITS_PER_LONG - 1;
96187
96188diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
96189index 0576d1f..dad6c71 100644
96190--- a/include/asm-generic/bitops/fls.h
96191+++ b/include/asm-generic/bitops/fls.h
96192@@ -9,7 +9,7 @@
96193 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
96194 */
96195
96196-static __always_inline int fls(int x)
96197+static __always_inline int __intentional_overflow(-1) fls(int x)
96198 {
96199 int r = 32;
96200
96201diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h
96202index b097cf8..3d40e14 100644
96203--- a/include/asm-generic/bitops/fls64.h
96204+++ b/include/asm-generic/bitops/fls64.h
96205@@ -15,7 +15,7 @@
96206 * at position 64.
96207 */
96208 #if BITS_PER_LONG == 32
96209-static __always_inline int fls64(__u64 x)
96210+static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
96211 {
96212 __u32 h = x >> 32;
96213 if (h)
96214@@ -23,7 +23,7 @@ static __always_inline int fls64(__u64 x)
96215 return fls(x);
96216 }
96217 #elif BITS_PER_LONG == 64
96218-static __always_inline int fls64(__u64 x)
96219+static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
96220 {
96221 if (x == 0)
96222 return 0;
96223diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
96224index 630dd23..8c1dcb6b 100644
96225--- a/include/asm-generic/bug.h
96226+++ b/include/asm-generic/bug.h
96227@@ -62,13 +62,13 @@ struct bug_entry {
96228 * to provide better diagnostics.
96229 */
96230 #ifndef __WARN_TAINT
96231-extern __printf(3, 4)
96232+extern __printf(3, 4) __nocapture(1, 3, 4)
96233 void warn_slowpath_fmt(const char *file, const int line,
96234 const char *fmt, ...);
96235-extern __printf(4, 5)
96236+extern __printf(4, 5) __nocapture(1, 4, 5)
96237 void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint,
96238 const char *fmt, ...);
96239-extern void warn_slowpath_null(const char *file, const int line);
96240+extern __nocapture(1) void warn_slowpath_null(const char *file, const int line);
96241 #define WANT_WARN_ON_SLOWPATH
96242 #define __WARN() warn_slowpath_null(__FILE__, __LINE__)
96243 #define __WARN_printf(arg...) warn_slowpath_fmt(__FILE__, __LINE__, arg)
96244diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
96245index 1bfcfe5..e04c5c9 100644
96246--- a/include/asm-generic/cache.h
96247+++ b/include/asm-generic/cache.h
96248@@ -6,7 +6,7 @@
96249 * cache lines need to provide their own cache.h.
96250 */
96251
96252-#define L1_CACHE_SHIFT 5
96253-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
96254+#define L1_CACHE_SHIFT 5UL
96255+#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
96256
96257 #endif /* __ASM_GENERIC_CACHE_H */
96258diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
96259index 0d68a1e..b74a761 100644
96260--- a/include/asm-generic/emergency-restart.h
96261+++ b/include/asm-generic/emergency-restart.h
96262@@ -1,7 +1,7 @@
96263 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
96264 #define _ASM_GENERIC_EMERGENCY_RESTART_H
96265
96266-static inline void machine_emergency_restart(void)
96267+static inline __noreturn void machine_emergency_restart(void)
96268 {
96269 machine_restart(NULL);
96270 }
96271diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
96272index 90f99c7..00ce236 100644
96273--- a/include/asm-generic/kmap_types.h
96274+++ b/include/asm-generic/kmap_types.h
96275@@ -2,9 +2,9 @@
96276 #define _ASM_GENERIC_KMAP_TYPES_H
96277
96278 #ifdef __WITH_KM_FENCE
96279-# define KM_TYPE_NR 41
96280+# define KM_TYPE_NR 42
96281 #else
96282-# define KM_TYPE_NR 20
96283+# define KM_TYPE_NR 21
96284 #endif
96285
96286 #endif
96287diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
96288index 9ceb03b..62b0b8f 100644
96289--- a/include/asm-generic/local.h
96290+++ b/include/asm-generic/local.h
96291@@ -23,24 +23,37 @@ typedef struct
96292 atomic_long_t a;
96293 } local_t;
96294
96295+typedef struct {
96296+ atomic_long_unchecked_t a;
96297+} local_unchecked_t;
96298+
96299 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
96300
96301 #define local_read(l) atomic_long_read(&(l)->a)
96302+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
96303 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
96304+#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
96305 #define local_inc(l) atomic_long_inc(&(l)->a)
96306+#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
96307 #define local_dec(l) atomic_long_dec(&(l)->a)
96308+#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
96309 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
96310+#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
96311 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
96312+#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
96313
96314 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
96315 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
96316 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
96317 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
96318 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
96319+#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
96320 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
96321 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
96322+#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
96323
96324 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
96325+#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
96326 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
96327 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
96328 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
96329diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
96330index 725612b..9cc513a 100644
96331--- a/include/asm-generic/pgtable-nopmd.h
96332+++ b/include/asm-generic/pgtable-nopmd.h
96333@@ -1,14 +1,19 @@
96334 #ifndef _PGTABLE_NOPMD_H
96335 #define _PGTABLE_NOPMD_H
96336
96337-#ifndef __ASSEMBLY__
96338-
96339 #include <asm-generic/pgtable-nopud.h>
96340
96341-struct mm_struct;
96342-
96343 #define __PAGETABLE_PMD_FOLDED
96344
96345+#define PMD_SHIFT PUD_SHIFT
96346+#define PTRS_PER_PMD 1
96347+#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
96348+#define PMD_MASK (~(PMD_SIZE-1))
96349+
96350+#ifndef __ASSEMBLY__
96351+
96352+struct mm_struct;
96353+
96354 /*
96355 * Having the pmd type consist of a pud gets the size right, and allows
96356 * us to conceptually access the pud entry that this pmd is folded into
96357@@ -16,11 +21,6 @@ struct mm_struct;
96358 */
96359 typedef struct { pud_t pud; } pmd_t;
96360
96361-#define PMD_SHIFT PUD_SHIFT
96362-#define PTRS_PER_PMD 1
96363-#define PMD_SIZE (1UL << PMD_SHIFT)
96364-#define PMD_MASK (~(PMD_SIZE-1))
96365-
96366 /*
96367 * The "pud_xxx()" functions here are trivial for a folded two-level
96368 * setup: the pmd is never bad, and a pmd always exists (as it's folded
96369diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
96370index 810431d..0ec4804f 100644
96371--- a/include/asm-generic/pgtable-nopud.h
96372+++ b/include/asm-generic/pgtable-nopud.h
96373@@ -1,10 +1,15 @@
96374 #ifndef _PGTABLE_NOPUD_H
96375 #define _PGTABLE_NOPUD_H
96376
96377-#ifndef __ASSEMBLY__
96378-
96379 #define __PAGETABLE_PUD_FOLDED
96380
96381+#define PUD_SHIFT PGDIR_SHIFT
96382+#define PTRS_PER_PUD 1
96383+#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
96384+#define PUD_MASK (~(PUD_SIZE-1))
96385+
96386+#ifndef __ASSEMBLY__
96387+
96388 /*
96389 * Having the pud type consist of a pgd gets the size right, and allows
96390 * us to conceptually access the pgd entry that this pud is folded into
96391@@ -12,11 +17,6 @@
96392 */
96393 typedef struct { pgd_t pgd; } pud_t;
96394
96395-#define PUD_SHIFT PGDIR_SHIFT
96396-#define PTRS_PER_PUD 1
96397-#define PUD_SIZE (1UL << PUD_SHIFT)
96398-#define PUD_MASK (~(PUD_SIZE-1))
96399-
96400 /*
96401 * The "pgd_xxx()" functions here are trivial for a folded two-level
96402 * setup: the pud is never bad, and a pud always exists (as it's folded
96403@@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
96404 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
96405
96406 #define pgd_populate(mm, pgd, pud) do { } while (0)
96407+#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
96408 /*
96409 * (puds are folded into pgds so this doesn't get actually called,
96410 * but the define is needed for a generic inline function.)
96411diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
96412index 29c57b2..da571a2 100644
96413--- a/include/asm-generic/pgtable.h
96414+++ b/include/asm-generic/pgtable.h
96415@@ -715,6 +715,22 @@ static inline int pmd_protnone(pmd_t pmd)
96416 }
96417 #endif /* CONFIG_NUMA_BALANCING */
96418
96419+#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
96420+#ifdef CONFIG_PAX_KERNEXEC
96421+#error KERNEXEC requires pax_open_kernel
96422+#else
96423+static inline unsigned long pax_open_kernel(void) { return 0; }
96424+#endif
96425+#endif
96426+
96427+#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
96428+#ifdef CONFIG_PAX_KERNEXEC
96429+#error KERNEXEC requires pax_close_kernel
96430+#else
96431+static inline unsigned long pax_close_kernel(void) { return 0; }
96432+#endif
96433+#endif
96434+
96435 #endif /* CONFIG_MMU */
96436
96437 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
96438diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
96439index b58fd66..6cfae67 100644
96440--- a/include/asm-generic/sections.h
96441+++ b/include/asm-generic/sections.h
96442@@ -30,6 +30,7 @@ extern char _data[], _sdata[], _edata[];
96443 extern char __bss_start[], __bss_stop[];
96444 extern char __init_begin[], __init_end[];
96445 extern char _sinittext[], _einittext[];
96446+extern char _sinitdata[], _einitdata[];
96447 extern char _end[];
96448 extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[];
96449 extern char __kprobes_text_start[], __kprobes_text_end[];
96450diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
96451index 72d8803..cb9749c 100644
96452--- a/include/asm-generic/uaccess.h
96453+++ b/include/asm-generic/uaccess.h
96454@@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
96455 return __clear_user(to, n);
96456 }
96457
96458+#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
96459+#ifdef CONFIG_PAX_MEMORY_UDEREF
96460+#error UDEREF requires pax_open_userland
96461+#else
96462+static inline unsigned long pax_open_userland(void) { return 0; }
96463+#endif
96464+#endif
96465+
96466+#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
96467+#ifdef CONFIG_PAX_MEMORY_UDEREF
96468+#error UDEREF requires pax_close_userland
96469+#else
96470+static inline unsigned long pax_close_userland(void) { return 0; }
96471+#endif
96472+#endif
96473+
96474 #endif /* __ASM_GENERIC_UACCESS_H */
96475diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
96476index 8bd374d..2665ce3 100644
96477--- a/include/asm-generic/vmlinux.lds.h
96478+++ b/include/asm-generic/vmlinux.lds.h
96479@@ -246,6 +246,7 @@
96480 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
96481 VMLINUX_SYMBOL(__start_rodata) = .; \
96482 *(.rodata) *(.rodata.*) \
96483+ *(.data..read_only) \
96484 *(__vermagic) /* Kernel version magic */ \
96485 . = ALIGN(8); \
96486 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
96487@@ -504,6 +505,7 @@
96488 KERNEL_CTORS() \
96489 MCOUNT_REC() \
96490 *(.init.rodata) \
96491+ *(.init.rodata.*) \
96492 FTRACE_EVENTS() \
96493 TRACE_SYSCALLS() \
96494 KPROBE_BLACKLIST() \
96495@@ -525,6 +527,8 @@
96496
96497 #define EXIT_DATA \
96498 *(.exit.data) \
96499+ *(.exit.rodata) \
96500+ *(.exit.rodata.*) \
96501 MEM_DISCARD(exit.data) \
96502 MEM_DISCARD(exit.rodata)
96503
96504@@ -741,17 +745,18 @@
96505 * section in the linker script will go there too. @phdr should have
96506 * a leading colon.
96507 *
96508- * Note that this macros defines __per_cpu_load as an absolute symbol.
96509+ * Note that this macros defines per_cpu_load as an absolute symbol.
96510 * If there is no need to put the percpu section at a predetermined
96511 * address, use PERCPU_SECTION.
96512 */
96513 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
96514- VMLINUX_SYMBOL(__per_cpu_load) = .; \
96515- .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
96516+ per_cpu_load = .; \
96517+ .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
96518 - LOAD_OFFSET) { \
96519+ VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
96520 PERCPU_INPUT(cacheline) \
96521 } phdr \
96522- . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
96523+ . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
96524
96525 /**
96526 * PERCPU_SECTION - define output section for percpu area, simple version
96527@@ -813,12 +818,14 @@
96528
96529 #define INIT_DATA_SECTION(initsetup_align) \
96530 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \
96531+ VMLINUX_SYMBOL(_sinitdata) = .; \
96532 INIT_DATA \
96533 INIT_SETUP(initsetup_align) \
96534 INIT_CALLS \
96535 CON_INITCALL \
96536 SECURITY_INITCALL \
96537 INIT_RAM_FS \
96538+ VMLINUX_SYMBOL(_einitdata) = .; \
96539 }
96540
96541 #define BSS_SECTION(sbss_align, bss_align, stop_align) \
96542diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
96543index d4ebf6e..ca4bd35 100644
96544--- a/include/crypto/algapi.h
96545+++ b/include/crypto/algapi.h
96546@@ -35,7 +35,7 @@ struct crypto_type {
96547 unsigned int maskclear;
96548 unsigned int maskset;
96549 unsigned int tfmsize;
96550-};
96551+} __do_const;
96552
96553 struct crypto_instance {
96554 struct crypto_alg alg;
96555diff --git a/include/drm/drmP.h b/include/drm/drmP.h
96556index 5aa5197..e4ca348 100644
96557--- a/include/drm/drmP.h
96558+++ b/include/drm/drmP.h
96559@@ -59,6 +59,7 @@
96560
96561 #include <asm/mman.h>
96562 #include <asm/pgalloc.h>
96563+#include <asm/local.h>
96564 #include <asm/uaccess.h>
96565
96566 #include <uapi/drm/drm.h>
96567@@ -137,17 +138,18 @@ void drm_err(const char *format, ...);
96568 /*@{*/
96569
96570 /* driver capabilities and requirements mask */
96571-#define DRIVER_USE_AGP 0x1
96572-#define DRIVER_PCI_DMA 0x8
96573-#define DRIVER_SG 0x10
96574-#define DRIVER_HAVE_DMA 0x20
96575-#define DRIVER_HAVE_IRQ 0x40
96576-#define DRIVER_IRQ_SHARED 0x80
96577-#define DRIVER_GEM 0x1000
96578-#define DRIVER_MODESET 0x2000
96579-#define DRIVER_PRIME 0x4000
96580-#define DRIVER_RENDER 0x8000
96581-#define DRIVER_ATOMIC 0x10000
96582+#define DRIVER_USE_AGP 0x1
96583+#define DRIVER_PCI_DMA 0x8
96584+#define DRIVER_SG 0x10
96585+#define DRIVER_HAVE_DMA 0x20
96586+#define DRIVER_HAVE_IRQ 0x40
96587+#define DRIVER_IRQ_SHARED 0x80
96588+#define DRIVER_GEM 0x1000
96589+#define DRIVER_MODESET 0x2000
96590+#define DRIVER_PRIME 0x4000
96591+#define DRIVER_RENDER 0x8000
96592+#define DRIVER_ATOMIC 0x10000
96593+#define DRIVER_KMS_LEGACY_CONTEXT 0x20000
96594
96595 /***********************************************************************/
96596 /** \name Macros to make printk easier */
96597@@ -233,10 +235,12 @@ void drm_err(const char *format, ...);
96598 * \param cmd command.
96599 * \param arg argument.
96600 */
96601-typedef int drm_ioctl_t(struct drm_device *dev, void *data,
96602+typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
96603+ struct drm_file *file_priv);
96604+typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
96605 struct drm_file *file_priv);
96606
96607-typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
96608+typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
96609 unsigned long arg);
96610
96611 #define DRM_IOCTL_NR(n) _IOC_NR(n)
96612@@ -252,9 +256,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
96613 struct drm_ioctl_desc {
96614 unsigned int cmd;
96615 int flags;
96616- drm_ioctl_t *func;
96617+ drm_ioctl_t func;
96618 const char *name;
96619-};
96620+} __do_const;
96621
96622 /**
96623 * Creates a driver or general drm_ioctl_desc array entry for the given
96624@@ -647,7 +651,8 @@ struct drm_info_list {
96625 int (*show)(struct seq_file*, void*); /** show callback */
96626 u32 driver_features; /**< Required driver features for this entry */
96627 void *data;
96628-};
96629+} __do_const;
96630+typedef struct drm_info_list __no_const drm_info_list_no_const;
96631
96632 /**
96633 * debugfs node structure. This structure represents a debugfs file.
96634@@ -735,7 +740,7 @@ struct drm_device {
96635
96636 /** \name Usage Counters */
96637 /*@{ */
96638- int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
96639+ local_t open_count; /**< Outstanding files open, protected by drm_global_mutex. */
96640 spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
96641 int buf_use; /**< Buffers in use -- cannot alloc */
96642 atomic_t buf_alloc; /**< Buffer allocation in progress */
96643diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
96644index 918aa68..f162a8a 100644
96645--- a/include/drm/drm_crtc_helper.h
96646+++ b/include/drm/drm_crtc_helper.h
96647@@ -161,7 +161,7 @@ struct drm_encoder_helper_funcs {
96648 int (*atomic_check)(struct drm_encoder *encoder,
96649 struct drm_crtc_state *crtc_state,
96650 struct drm_connector_state *conn_state);
96651-};
96652+} __no_const;
96653
96654 /**
96655 * struct drm_connector_helper_funcs - helper operations for connectors
96656diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
96657index 0de6290..2a2c125 100644
96658--- a/include/drm/drm_mm.h
96659+++ b/include/drm/drm_mm.h
96660@@ -297,7 +297,7 @@ void drm_mm_remove_node(struct drm_mm_node *node);
96661 void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new);
96662 void drm_mm_init(struct drm_mm *mm,
96663 u64 start,
96664- u64 size);
96665+ u64 size) __intentional_overflow(3);
96666 void drm_mm_takedown(struct drm_mm *mm);
96667 bool drm_mm_clean(struct drm_mm *mm);
96668
96669diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
96670index 17c4456..da0c5eb 100644
96671--- a/include/drm/i915_pciids.h
96672+++ b/include/drm/i915_pciids.h
96673@@ -37,7 +37,7 @@
96674 */
96675 #define INTEL_VGA_DEVICE(id, info) { \
96676 0x8086, id, \
96677- ~0, ~0, \
96678+ PCI_ANY_ID, PCI_ANY_ID, \
96679 0x030000, 0xff0000, \
96680 (unsigned long) info }
96681
96682diff --git a/include/drm/intel-gtt.h b/include/drm/intel-gtt.h
96683index b08bdad..21e6054 100644
96684--- a/include/drm/intel-gtt.h
96685+++ b/include/drm/intel-gtt.h
96686@@ -3,8 +3,8 @@
96687 #ifndef _DRM_INTEL_GTT_H
96688 #define _DRM_INTEL_GTT_H
96689
96690-void intel_gtt_get(size_t *gtt_total, size_t *stolen_size,
96691- phys_addr_t *mappable_base, unsigned long *mappable_end);
96692+void intel_gtt_get(uint64_t *gtt_total, uint64_t *stolen_size,
96693+ uint64_t *mappable_base, uint64_t *mappable_end);
96694
96695 int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
96696 struct agp_bridge_data *bridge);
96697diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
96698index 72dcbe8..8db58d7 100644
96699--- a/include/drm/ttm/ttm_memory.h
96700+++ b/include/drm/ttm/ttm_memory.h
96701@@ -48,7 +48,7 @@
96702
96703 struct ttm_mem_shrink {
96704 int (*do_shrink) (struct ttm_mem_shrink *);
96705-};
96706+} __no_const;
96707
96708 /**
96709 * struct ttm_mem_global - Global memory accounting structure.
96710diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
96711index 49a8284..9643967 100644
96712--- a/include/drm/ttm/ttm_page_alloc.h
96713+++ b/include/drm/ttm/ttm_page_alloc.h
96714@@ -80,6 +80,7 @@ void ttm_dma_page_alloc_fini(void);
96715 */
96716 extern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);
96717
96718+struct device;
96719 extern int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev);
96720 extern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev);
96721
96722diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
96723index 4b840e8..155d235 100644
96724--- a/include/keys/asymmetric-subtype.h
96725+++ b/include/keys/asymmetric-subtype.h
96726@@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
96727 /* Verify the signature on a key of this subtype (optional) */
96728 int (*verify_signature)(const struct key *key,
96729 const struct public_key_signature *sig);
96730-};
96731+} __do_const;
96732
96733 /**
96734 * asymmetric_key_subtype - Get the subtype from an asymmetric key
96735diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
96736index c1da539..1dcec55 100644
96737--- a/include/linux/atmdev.h
96738+++ b/include/linux/atmdev.h
96739@@ -28,7 +28,7 @@ struct compat_atm_iobuf {
96740 #endif
96741
96742 struct k_atm_aal_stats {
96743-#define __HANDLE_ITEM(i) atomic_t i
96744+#define __HANDLE_ITEM(i) atomic_unchecked_t i
96745 __AAL_STAT_ITEMS
96746 #undef __HANDLE_ITEM
96747 };
96748@@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
96749 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
96750 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
96751 struct module *owner;
96752-};
96753+} __do_const ;
96754
96755 struct atmphy_ops {
96756 int (*start)(struct atm_dev *dev);
96757diff --git a/include/linux/atomic.h b/include/linux/atomic.h
96758index 5b08a85..60922fb 100644
96759--- a/include/linux/atomic.h
96760+++ b/include/linux/atomic.h
96761@@ -12,7 +12,7 @@
96762 * Atomically adds @a to @v, so long as @v was not already @u.
96763 * Returns non-zero if @v was not @u, and zero otherwise.
96764 */
96765-static inline int atomic_add_unless(atomic_t *v, int a, int u)
96766+static inline int __intentional_overflow(-1) atomic_add_unless(atomic_t *v, int a, int u)
96767 {
96768 return __atomic_add_unless(v, a, u) != u;
96769 }
96770diff --git a/include/linux/audit.h b/include/linux/audit.h
96771index c2e7e3a..8bfc0e1 100644
96772--- a/include/linux/audit.h
96773+++ b/include/linux/audit.h
96774@@ -223,7 +223,7 @@ static inline void audit_ptrace(struct task_struct *t)
96775 extern unsigned int audit_serial(void);
96776 extern int auditsc_get_stamp(struct audit_context *ctx,
96777 struct timespec *t, unsigned int *serial);
96778-extern int audit_set_loginuid(kuid_t loginuid);
96779+extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
96780
96781 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
96782 {
96783diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
96784index 576e463..28fd926 100644
96785--- a/include/linux/binfmts.h
96786+++ b/include/linux/binfmts.h
96787@@ -44,7 +44,7 @@ struct linux_binprm {
96788 unsigned interp_flags;
96789 unsigned interp_data;
96790 unsigned long loader, exec;
96791-};
96792+} __randomize_layout;
96793
96794 #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
96795 #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
96796@@ -77,8 +77,10 @@ struct linux_binfmt {
96797 int (*load_binary)(struct linux_binprm *);
96798 int (*load_shlib)(struct file *);
96799 int (*core_dump)(struct coredump_params *cprm);
96800+ void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
96801+ void (*handle_mmap)(struct file *);
96802 unsigned long min_coredump; /* minimal dump size */
96803-};
96804+} __do_const __randomize_layout;
96805
96806 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
96807
96808diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
96809index ea17cca..dd56e56 100644
96810--- a/include/linux/bitmap.h
96811+++ b/include/linux/bitmap.h
96812@@ -295,7 +295,7 @@ static inline int bitmap_full(const unsigned long *src, unsigned int nbits)
96813 return find_first_zero_bit(src, nbits) == nbits;
96814 }
96815
96816-static inline int bitmap_weight(const unsigned long *src, unsigned int nbits)
96817+static inline int __intentional_overflow(-1) bitmap_weight(const unsigned long *src, unsigned int nbits)
96818 {
96819 if (small_const_nbits(nbits))
96820 return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
96821diff --git a/include/linux/bitops.h b/include/linux/bitops.h
96822index 297f5bd..5892caa 100644
96823--- a/include/linux/bitops.h
96824+++ b/include/linux/bitops.h
96825@@ -75,7 +75,7 @@ static __inline__ int get_count_order(unsigned int count)
96826 return order;
96827 }
96828
96829-static inline unsigned long hweight_long(unsigned long w)
96830+static inline unsigned long __intentional_overflow(-1) hweight_long(unsigned long w)
96831 {
96832 return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
96833 }
96834@@ -105,7 +105,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
96835 * @word: value to rotate
96836 * @shift: bits to roll
96837 */
96838-static inline __u32 rol32(__u32 word, unsigned int shift)
96839+static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
96840 {
96841 return (word << shift) | (word >> (32 - shift));
96842 }
96843@@ -115,7 +115,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
96844 * @word: value to rotate
96845 * @shift: bits to roll
96846 */
96847-static inline __u32 ror32(__u32 word, unsigned int shift)
96848+static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
96849 {
96850 return (word >> shift) | (word << (32 - shift));
96851 }
96852@@ -171,7 +171,7 @@ static inline __s32 sign_extend32(__u32 value, int index)
96853 return (__s32)(value << shift) >> shift;
96854 }
96855
96856-static inline unsigned fls_long(unsigned long l)
96857+static inline unsigned __intentional_overflow(-1) fls_long(unsigned long l)
96858 {
96859 if (sizeof(l) == 4)
96860 return fls(l);
96861diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
96862index d4068c1..77159a1 100644
96863--- a/include/linux/blkdev.h
96864+++ b/include/linux/blkdev.h
96865@@ -1567,7 +1567,7 @@ struct block_device_operations {
96866 /* this callback is with swap_lock and sometimes page table lock held */
96867 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
96868 struct module *owner;
96869-};
96870+} __do_const;
96871
96872 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
96873 unsigned long);
96874diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
96875index afc1343..9735539 100644
96876--- a/include/linux/blktrace_api.h
96877+++ b/include/linux/blktrace_api.h
96878@@ -25,7 +25,7 @@ struct blk_trace {
96879 struct dentry *dropped_file;
96880 struct dentry *msg_file;
96881 struct list_head running_list;
96882- atomic_t dropped;
96883+ atomic_unchecked_t dropped;
96884 };
96885
96886 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
96887diff --git a/include/linux/cache.h b/include/linux/cache.h
96888index 17e7e82..1d7da26 100644
96889--- a/include/linux/cache.h
96890+++ b/include/linux/cache.h
96891@@ -16,6 +16,14 @@
96892 #define __read_mostly
96893 #endif
96894
96895+#ifndef __read_only
96896+#ifdef CONFIG_PAX_KERNEXEC
96897+#error KERNEXEC requires __read_only
96898+#else
96899+#define __read_only __read_mostly
96900+#endif
96901+#endif
96902+
96903 #ifndef ____cacheline_aligned
96904 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
96905 #endif
96906diff --git a/include/linux/capability.h b/include/linux/capability.h
96907index af9f0b9..71a5e5c 100644
96908--- a/include/linux/capability.h
96909+++ b/include/linux/capability.h
96910@@ -237,15 +237,28 @@ static inline bool capable(int cap)
96911 {
96912 return true;
96913 }
96914+static inline bool capable_nolog(int cap)
96915+{
96916+ return true;
96917+}
96918 static inline bool ns_capable(struct user_namespace *ns, int cap)
96919 {
96920 return true;
96921 }
96922+static inline bool ns_capable_nolog(struct user_namespace *ns, int cap)
96923+{
96924+ return true;
96925+}
96926 #endif /* CONFIG_MULTIUSER */
96927 extern bool capable_wrt_inode_uidgid(const struct inode *inode, int cap);
96928+extern bool capable_wrt_inode_uidgid_nolog(const struct inode *inode, int cap);
96929 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
96930+extern bool capable_nolog(int cap);
96931+extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
96932
96933 /* audit system wants to get cap info from files as well */
96934 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
96935
96936+extern int is_privileged_binary(const struct dentry *dentry);
96937+
96938 #endif /* !_LINUX_CAPABILITY_H */
96939diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
96940index 8609d57..86e4d79 100644
96941--- a/include/linux/cdrom.h
96942+++ b/include/linux/cdrom.h
96943@@ -87,7 +87,6 @@ struct cdrom_device_ops {
96944
96945 /* driver specifications */
96946 const int capability; /* capability flags */
96947- int n_minors; /* number of active minor devices */
96948 /* handle uniform packets for scsi type devices (scsi,atapi) */
96949 int (*generic_packet) (struct cdrom_device_info *,
96950 struct packet_command *);
96951diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
96952index bda5ec0b4..51d8ea1 100644
96953--- a/include/linux/cleancache.h
96954+++ b/include/linux/cleancache.h
96955@@ -35,7 +35,7 @@ struct cleancache_ops {
96956 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
96957 void (*invalidate_inode)(int, struct cleancache_filekey);
96958 void (*invalidate_fs)(int);
96959-};
96960+} __no_const;
96961
96962 extern int cleancache_register_ops(struct cleancache_ops *ops);
96963 extern void __cleancache_init_fs(struct super_block *);
96964diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
96965index 78842f4..7e7f81f 100644
96966--- a/include/linux/clk-provider.h
96967+++ b/include/linux/clk-provider.h
96968@@ -196,6 +196,7 @@ struct clk_ops {
96969 void (*init)(struct clk_hw *hw);
96970 int (*debug_init)(struct clk_hw *hw, struct dentry *dentry);
96971 };
96972+typedef struct clk_ops __no_const clk_ops_no_const;
96973
96974 /**
96975 * struct clk_init_data - holds init data that's common to all clocks and is
96976diff --git a/include/linux/compat.h b/include/linux/compat.h
96977index a76c917..63b52db 100644
96978--- a/include/linux/compat.h
96979+++ b/include/linux/compat.h
96980@@ -316,7 +316,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
96981 compat_size_t __user *len_ptr);
96982
96983 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
96984-asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
96985+asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
96986 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
96987 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
96988 compat_ssize_t msgsz, int msgflg);
96989@@ -325,7 +325,7 @@ asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp,
96990 long compat_sys_msgctl(int first, int second, void __user *uptr);
96991 long compat_sys_shmctl(int first, int second, void __user *uptr);
96992 long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
96993- unsigned nsems, const struct compat_timespec __user *timeout);
96994+ compat_long_t nsems, const struct compat_timespec __user *timeout);
96995 asmlinkage long compat_sys_keyctl(u32 option,
96996 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
96997 asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
96998@@ -439,7 +439,7 @@ extern int compat_ptrace_request(struct task_struct *child,
96999 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
97000 compat_ulong_t addr, compat_ulong_t data);
97001 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
97002- compat_long_t addr, compat_long_t data);
97003+ compat_ulong_t addr, compat_ulong_t data);
97004
97005 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t);
97006 /*
97007diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
97008index dfaa7b3..d8bb2a0 100644
97009--- a/include/linux/compiler-gcc.h
97010+++ b/include/linux/compiler-gcc.h
97011@@ -116,8 +116,8 @@
97012 */
97013 #define __pure __attribute__((pure))
97014 #define __aligned(x) __attribute__((aligned(x)))
97015-#define __printf(a, b) __attribute__((format(printf, a, b)))
97016-#define __scanf(a, b) __attribute__((format(scanf, a, b)))
97017+#define __printf(a, b) __attribute__((format(printf, a, b))) __nocapture(a, b)
97018+#define __scanf(a, b) __attribute__((format(scanf, a, b))) __nocapture(a, b)
97019 #define __attribute_const__ __attribute__((__const__))
97020 #define __maybe_unused __attribute__((unused))
97021 #define __always_unused __attribute__((unused))
97022@@ -184,9 +184,38 @@
97023 # define __compiletime_warning(message) __attribute__((warning(message)))
97024 # define __compiletime_error(message) __attribute__((error(message)))
97025 #endif /* __CHECKER__ */
97026+
97027+#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
97028+#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
97029+#define __bos0(ptr) __bos((ptr), 0)
97030+#define __bos1(ptr) __bos((ptr), 1)
97031 #endif /* GCC_VERSION >= 40300 */
97032
97033 #if GCC_VERSION >= 40500
97034+
97035+#ifdef RANDSTRUCT_PLUGIN
97036+#define __randomize_layout __attribute__((randomize_layout))
97037+#define __no_randomize_layout __attribute__((no_randomize_layout))
97038+#endif
97039+
97040+#ifdef CONSTIFY_PLUGIN
97041+#define __no_const __attribute__((no_const))
97042+#define __do_const __attribute__((do_const))
97043+#endif
97044+
97045+#ifdef SIZE_OVERFLOW_PLUGIN
97046+#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
97047+#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
97048+#endif
97049+
97050+#ifdef LATENT_ENTROPY_PLUGIN
97051+#define __latent_entropy __attribute__((latent_entropy))
97052+#endif
97053+
97054+#ifdef INITIFY_PLUGIN
97055+#define __nocapture(...) __attribute__((nocapture(__VA_ARGS__)))
97056+#endif
97057+
97058 /*
97059 * Mark a position in code as unreachable. This can be used to
97060 * suppress control flow warnings after asm blocks that transfer
97061@@ -237,6 +266,10 @@
97062 #define KASAN_ABI_VERSION 3
97063 #endif
97064
97065+#if GCC_VERSION >= 50000
97066+//#define CC_HAVE_BUILTIN_OVERFLOW
97067+#endif
97068+
97069 #endif /* gcc version >= 40000 specific checks */
97070
97071 #if !defined(__noclone)
97072diff --git a/include/linux/compiler.h b/include/linux/compiler.h
97073index e08a6ae..2e5e776 100644
97074--- a/include/linux/compiler.h
97075+++ b/include/linux/compiler.h
97076@@ -5,11 +5,14 @@
97077
97078 #ifdef __CHECKER__
97079 # define __user __attribute__((noderef, address_space(1)))
97080+# define __force_user __force __user
97081 # define __kernel __attribute__((address_space(0)))
97082+# define __force_kernel __force __kernel
97083 # define __safe __attribute__((safe))
97084 # define __force __attribute__((force))
97085 # define __nocast __attribute__((nocast))
97086 # define __iomem __attribute__((noderef, address_space(2)))
97087+# define __force_iomem __force __iomem
97088 # define __must_hold(x) __attribute__((context(x,1,1)))
97089 # define __acquires(x) __attribute__((context(x,0,1)))
97090 # define __releases(x) __attribute__((context(x,1,0)))
97091@@ -17,21 +20,39 @@
97092 # define __release(x) __context__(x,-1)
97093 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
97094 # define __percpu __attribute__((noderef, address_space(3)))
97095+# define __force_percpu __force __percpu
97096 # define __pmem __attribute__((noderef, address_space(5)))
97097+# define __force_pmem __force __pmem
97098 #ifdef CONFIG_SPARSE_RCU_POINTER
97099 # define __rcu __attribute__((noderef, address_space(4)))
97100+# define __force_rcu __force __rcu
97101 #else
97102 # define __rcu
97103+# define __force_rcu
97104 #endif
97105 extern void __chk_user_ptr(const volatile void __user *);
97106 extern void __chk_io_ptr(const volatile void __iomem *);
97107 #else
97108-# define __user
97109-# define __kernel
97110+# ifdef CHECKER_PLUGIN
97111+//# define __user
97112+//# define __force_user
97113+//# define __kernel
97114+//# define __force_kernel
97115+# else
97116+# ifdef STRUCTLEAK_PLUGIN
97117+# define __user __attribute__((user))
97118+# else
97119+# define __user
97120+# endif
97121+# define __force_user
97122+# define __kernel
97123+# define __force_kernel
97124+# endif
97125 # define __safe
97126 # define __force
97127 # define __nocast
97128 # define __iomem
97129+# define __force_iomem
97130 # define __chk_user_ptr(x) (void)0
97131 # define __chk_io_ptr(x) (void)0
97132 # define __builtin_warning(x, y...) (1)
97133@@ -42,8 +63,11 @@ extern void __chk_io_ptr(const volatile void __iomem *);
97134 # define __release(x) (void)0
97135 # define __cond_lock(x,c) (c)
97136 # define __percpu
97137+# define __force_percpu
97138 # define __rcu
97139+# define __force_rcu
97140 # define __pmem
97141+# define __force_pmem
97142 #endif
97143
97144 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
97145@@ -201,27 +225,27 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
97146 static __always_inline void __read_once_size(const volatile void *p, void *res, int size)
97147 {
97148 switch (size) {
97149- case 1: *(__u8 *)res = *(volatile __u8 *)p; break;
97150- case 2: *(__u16 *)res = *(volatile __u16 *)p; break;
97151- case 4: *(__u32 *)res = *(volatile __u32 *)p; break;
97152- case 8: *(__u64 *)res = *(volatile __u64 *)p; break;
97153+ case 1: *(__u8 *)res = *(const volatile __u8 *)p; break;
97154+ case 2: *(__u16 *)res = *(const volatile __u16 *)p; break;
97155+ case 4: *(__u32 *)res = *(const volatile __u32 *)p; break;
97156+ case 8: *(__u64 *)res = *(const volatile __u64 *)p; break;
97157 default:
97158 barrier();
97159- __builtin_memcpy((void *)res, (const void *)p, size);
97160+ __builtin_memcpy(res, (const void *)p, size);
97161 barrier();
97162 }
97163 }
97164
97165-static __always_inline void __write_once_size(volatile void *p, void *res, int size)
97166+static __always_inline void __write_once_size(volatile void *p, const void *res, int size)
97167 {
97168 switch (size) {
97169- case 1: *(volatile __u8 *)p = *(__u8 *)res; break;
97170- case 2: *(volatile __u16 *)p = *(__u16 *)res; break;
97171- case 4: *(volatile __u32 *)p = *(__u32 *)res; break;
97172- case 8: *(volatile __u64 *)p = *(__u64 *)res; break;
97173+ case 1: *(volatile __u8 *)p = *(const __u8 *)res; break;
97174+ case 2: *(volatile __u16 *)p = *(const __u16 *)res; break;
97175+ case 4: *(volatile __u32 *)p = *(const __u32 *)res; break;
97176+ case 8: *(volatile __u64 *)p = *(const __u64 *)res; break;
97177 default:
97178 barrier();
97179- __builtin_memcpy((void *)p, (const void *)res, size);
97180+ __builtin_memcpy((void *)p, res, size);
97181 barrier();
97182 }
97183 }
97184@@ -370,6 +394,38 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
97185 # define __attribute_const__ /* unimplemented */
97186 #endif
97187
97188+#ifndef __randomize_layout
97189+# define __randomize_layout
97190+#endif
97191+
97192+#ifndef __no_randomize_layout
97193+# define __no_randomize_layout
97194+#endif
97195+
97196+#ifndef __no_const
97197+# define __no_const
97198+#endif
97199+
97200+#ifndef __do_const
97201+# define __do_const
97202+#endif
97203+
97204+#ifndef __size_overflow
97205+# define __size_overflow(...)
97206+#endif
97207+
97208+#ifndef __intentional_overflow
97209+# define __intentional_overflow(...)
97210+#endif
97211+
97212+#ifndef __latent_entropy
97213+# define __latent_entropy
97214+#endif
97215+
97216+#ifndef __nocapture
97217+# define __nocapture(...)
97218+#endif
97219+
97220 /*
97221 * Tell gcc if a function is cold. The compiler will assume any path
97222 * directly leading to the call is unlikely.
97223@@ -379,6 +435,22 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
97224 #define __cold
97225 #endif
97226
97227+#ifndef __alloc_size
97228+#define __alloc_size(...)
97229+#endif
97230+
97231+#ifndef __bos
97232+#define __bos(ptr, arg)
97233+#endif
97234+
97235+#ifndef __bos0
97236+#define __bos0(ptr)
97237+#endif
97238+
97239+#ifndef __bos1
97240+#define __bos1(ptr)
97241+#endif
97242+
97243 /* Simple shorthand for a section definition */
97244 #ifndef __section
97245 # define __section(S) __attribute__ ((__section__(#S)))
97246@@ -393,6 +465,8 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
97247 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
97248 #endif
97249
97250+#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))
97251+
97252 /* Is this type a native word size -- useful for atomic operations */
97253 #ifndef __native_word
97254 # define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
97255@@ -472,8 +546,9 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
97256 */
97257 #define __ACCESS_ONCE(x) ({ \
97258 __maybe_unused typeof(x) __var = (__force typeof(x)) 0; \
97259- (volatile typeof(x) *)&(x); })
97260+ (volatile const typeof(x) *)&(x); })
97261 #define ACCESS_ONCE(x) (*__ACCESS_ONCE(x))
97262+#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
97263
97264 /**
97265 * lockless_dereference() - safely load a pointer for later dereference
97266diff --git a/include/linux/configfs.h b/include/linux/configfs.h
97267index 63a36e8..26b0825 100644
97268--- a/include/linux/configfs.h
97269+++ b/include/linux/configfs.h
97270@@ -125,7 +125,7 @@ struct configfs_attribute {
97271 const char *ca_name;
97272 struct module *ca_owner;
97273 umode_t ca_mode;
97274-};
97275+} __do_const;
97276
97277 /*
97278 * Users often need to create attribute structures for their configurable
97279diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
97280index bde1e56..168de74 100644
97281--- a/include/linux/cpufreq.h
97282+++ b/include/linux/cpufreq.h
97283@@ -211,6 +211,7 @@ struct global_attr {
97284 ssize_t (*store)(struct kobject *a, struct attribute *b,
97285 const char *c, size_t count);
97286 };
97287+typedef struct global_attr __no_const global_attr_no_const;
97288
97289 #define define_one_global_ro(_name) \
97290 static struct global_attr _name = \
97291@@ -282,7 +283,7 @@ struct cpufreq_driver {
97292 bool boost_supported;
97293 bool boost_enabled;
97294 int (*set_boost)(int state);
97295-};
97296+} __do_const;
97297
97298 /* flags */
97299 #define CPUFREQ_STICKY (1 << 0) /* driver isn't removed even if
97300diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
97301index d075d34..3b6734a 100644
97302--- a/include/linux/cpuidle.h
97303+++ b/include/linux/cpuidle.h
97304@@ -59,7 +59,8 @@ struct cpuidle_state {
97305 void (*enter_freeze) (struct cpuidle_device *dev,
97306 struct cpuidle_driver *drv,
97307 int index);
97308-};
97309+} __do_const;
97310+typedef struct cpuidle_state __no_const cpuidle_state_no_const;
97311
97312 /* Idle State Flags */
97313 #define CPUIDLE_FLAG_COUPLED (0x02) /* state applies to multiple cpus */
97314@@ -235,7 +236,7 @@ struct cpuidle_governor {
97315 void (*reflect) (struct cpuidle_device *dev, int index);
97316
97317 struct module *owner;
97318-};
97319+} __do_const;
97320
97321 #ifdef CONFIG_CPU_IDLE
97322 extern int cpuidle_register_governor(struct cpuidle_governor *gov);
97323diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
97324index 59915ea..81ebec0 100644
97325--- a/include/linux/cpumask.h
97326+++ b/include/linux/cpumask.h
97327@@ -127,17 +127,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
97328 }
97329
97330 /* Valid inputs for n are -1 and 0. */
97331-static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
97332+static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
97333 {
97334 return n+1;
97335 }
97336
97337-static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
97338+static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
97339 {
97340 return n+1;
97341 }
97342
97343-static inline unsigned int cpumask_next_and(int n,
97344+static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
97345 const struct cpumask *srcp,
97346 const struct cpumask *andp)
97347 {
97348@@ -181,7 +181,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
97349 *
97350 * Returns >= nr_cpu_ids if no further cpus set.
97351 */
97352-static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
97353+static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
97354 {
97355 /* -1 is a legal arg here. */
97356 if (n != -1)
97357@@ -196,7 +196,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
97358 *
97359 * Returns >= nr_cpu_ids if no further cpus unset.
97360 */
97361-static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
97362+static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
97363 {
97364 /* -1 is a legal arg here. */
97365 if (n != -1)
97366@@ -204,7 +204,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
97367 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
97368 }
97369
97370-int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
97371+int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
97372 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
97373 unsigned int cpumask_local_spread(unsigned int i, int node);
97374
97375@@ -471,7 +471,7 @@ static inline bool cpumask_full(const struct cpumask *srcp)
97376 * cpumask_weight - Count of bits in *srcp
97377 * @srcp: the cpumask to count bits (< nr_cpu_ids) in.
97378 */
97379-static inline unsigned int cpumask_weight(const struct cpumask *srcp)
97380+static inline unsigned int __intentional_overflow(-1) cpumask_weight(const struct cpumask *srcp)
97381 {
97382 return bitmap_weight(cpumask_bits(srcp), nr_cpumask_bits);
97383 }
97384diff --git a/include/linux/cred.h b/include/linux/cred.h
97385index 8b6c083..51cb9f5 100644
97386--- a/include/linux/cred.h
97387+++ b/include/linux/cred.h
97388@@ -35,7 +35,7 @@ struct group_info {
97389 int nblocks;
97390 kgid_t small_block[NGROUPS_SMALL];
97391 kgid_t *blocks[0];
97392-};
97393+} __randomize_layout;
97394
97395 /**
97396 * get_group_info - Get a reference to a group info structure
97397@@ -152,7 +152,7 @@ struct cred {
97398 struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */
97399 struct group_info *group_info; /* supplementary groups for euid/fsgid */
97400 struct rcu_head rcu; /* RCU deletion hook */
97401-};
97402+} __randomize_layout;
97403
97404 extern void __put_cred(struct cred *);
97405 extern void exit_creds(struct task_struct *);
97406@@ -210,6 +210,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
97407 static inline void validate_process_creds(void)
97408 {
97409 }
97410+static inline void validate_task_creds(struct task_struct *task)
97411+{
97412+}
97413 #endif
97414
97415 /**
97416@@ -347,6 +350,7 @@ static inline void put_cred(const struct cred *_cred)
97417
97418 #define task_uid(task) (task_cred_xxx((task), uid))
97419 #define task_euid(task) (task_cred_xxx((task), euid))
97420+#define task_securebits(task) (task_cred_xxx((task), securebits))
97421
97422 #define current_cred_xxx(xxx) \
97423 ({ \
97424diff --git a/include/linux/crypto.h b/include/linux/crypto.h
97425index 81ef938..9ec0fdb 100644
97426--- a/include/linux/crypto.h
97427+++ b/include/linux/crypto.h
97428@@ -569,7 +569,7 @@ struct cipher_tfm {
97429 const u8 *key, unsigned int keylen);
97430 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
97431 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
97432-};
97433+} __no_const;
97434
97435 struct hash_tfm {
97436 int (*init)(struct hash_desc *desc);
97437@@ -590,7 +590,7 @@ struct compress_tfm {
97438 int (*cot_decompress)(struct crypto_tfm *tfm,
97439 const u8 *src, unsigned int slen,
97440 u8 *dst, unsigned int *dlen);
97441-};
97442+} __no_const;
97443
97444 #define crt_ablkcipher crt_u.ablkcipher
97445 #define crt_blkcipher crt_u.blkcipher
97446diff --git a/include/linux/ctype.h b/include/linux/ctype.h
97447index 653589e..4ef254a 100644
97448--- a/include/linux/ctype.h
97449+++ b/include/linux/ctype.h
97450@@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
97451 * Fast implementation of tolower() for internal usage. Do not use in your
97452 * code.
97453 */
97454-static inline char _tolower(const char c)
97455+static inline unsigned char _tolower(const unsigned char c)
97456 {
97457 return c | 0x20;
97458 }
97459diff --git a/include/linux/dcache.h b/include/linux/dcache.h
97460index d67ae11..9ec20d2 100644
97461--- a/include/linux/dcache.h
97462+++ b/include/linux/dcache.h
97463@@ -123,6 +123,9 @@ struct dentry {
97464 unsigned long d_time; /* used by d_revalidate */
97465 void *d_fsdata; /* fs-specific data */
97466
97467+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
97468+ atomic_t chroot_refcnt; /* tracks use of directory in chroot */
97469+#endif
97470 struct list_head d_lru; /* LRU list */
97471 struct list_head d_child; /* child of parent list */
97472 struct list_head d_subdirs; /* our children */
97473@@ -133,7 +136,7 @@ struct dentry {
97474 struct hlist_node d_alias; /* inode alias list */
97475 struct rcu_head d_rcu;
97476 } d_u;
97477-};
97478+} __randomize_layout;
97479
97480 /*
97481 * dentry->d_lock spinlock nesting subclasses:
97482@@ -321,7 +324,7 @@ extern struct dentry *__d_lookup_rcu(const struct dentry *parent,
97483
97484 static inline unsigned d_count(const struct dentry *dentry)
97485 {
97486- return dentry->d_lockref.count;
97487+ return __lockref_read(&dentry->d_lockref);
97488 }
97489
97490 /*
97491@@ -350,7 +353,7 @@ extern char *dentry_path(struct dentry *, char *, int);
97492 static inline struct dentry *dget_dlock(struct dentry *dentry)
97493 {
97494 if (dentry)
97495- dentry->d_lockref.count++;
97496+ __lockref_inc(&dentry->d_lockref);
97497 return dentry;
97498 }
97499
97500diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
97501index 7925bf0..d5143d2 100644
97502--- a/include/linux/decompress/mm.h
97503+++ b/include/linux/decompress/mm.h
97504@@ -77,7 +77,7 @@ static void free(void *where)
97505 * warnings when not needed (indeed large_malloc / large_free are not
97506 * needed by inflate */
97507
97508-#define malloc(a) kmalloc(a, GFP_KERNEL)
97509+#define malloc(a) kmalloc((a), GFP_KERNEL)
97510 #define free(a) kfree(a)
97511
97512 #define large_malloc(a) vmalloc(a)
97513diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
97514index ce447f0..83c66bd 100644
97515--- a/include/linux/devfreq.h
97516+++ b/include/linux/devfreq.h
97517@@ -114,7 +114,7 @@ struct devfreq_governor {
97518 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
97519 int (*event_handler)(struct devfreq *devfreq,
97520 unsigned int event, void *data);
97521-};
97522+} __do_const;
97523
97524 /**
97525 * struct devfreq - Device devfreq structure
97526diff --git a/include/linux/device.h b/include/linux/device.h
97527index a2b4ea7..b07dddd 100644
97528--- a/include/linux/device.h
97529+++ b/include/linux/device.h
97530@@ -342,7 +342,7 @@ struct subsys_interface {
97531 struct list_head node;
97532 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
97533 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
97534-};
97535+} __do_const;
97536
97537 int subsys_interface_register(struct subsys_interface *sif);
97538 void subsys_interface_unregister(struct subsys_interface *sif);
97539@@ -538,7 +538,7 @@ struct device_type {
97540 void (*release)(struct device *dev);
97541
97542 const struct dev_pm_ops *pm;
97543-};
97544+} __do_const;
97545
97546 /* interface for exporting device attributes */
97547 struct device_attribute {
97548@@ -548,11 +548,12 @@ struct device_attribute {
97549 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
97550 const char *buf, size_t count);
97551 };
97552+typedef struct device_attribute __no_const device_attribute_no_const;
97553
97554 struct dev_ext_attribute {
97555 struct device_attribute attr;
97556 void *var;
97557-};
97558+} __do_const;
97559
97560 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
97561 char *buf);
97562diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
97563index ac07ff0..edff186 100644
97564--- a/include/linux/dma-mapping.h
97565+++ b/include/linux/dma-mapping.h
97566@@ -64,7 +64,7 @@ struct dma_map_ops {
97567 u64 (*get_required_mask)(struct device *dev);
97568 #endif
97569 int is_phys;
97570-};
97571+} __do_const;
97572
97573 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
97574
97575diff --git a/include/linux/efi.h b/include/linux/efi.h
97576index 85ef051..2714c3b 100644
97577--- a/include/linux/efi.h
97578+++ b/include/linux/efi.h
97579@@ -1073,6 +1073,7 @@ struct efivar_operations {
97580 efi_set_variable_nonblocking_t *set_variable_nonblocking;
97581 efi_query_variable_store_t *query_variable_store;
97582 };
97583+typedef struct efivar_operations __no_const efivar_operations_no_const;
97584
97585 struct efivars {
97586 /*
97587diff --git a/include/linux/elf.h b/include/linux/elf.h
97588index 20fa8d8..3d0dd18 100644
97589--- a/include/linux/elf.h
97590+++ b/include/linux/elf.h
97591@@ -29,6 +29,7 @@ extern Elf32_Dyn _DYNAMIC [];
97592 #define elf_note elf32_note
97593 #define elf_addr_t Elf32_Off
97594 #define Elf_Half Elf32_Half
97595+#define elf_dyn Elf32_Dyn
97596
97597 #else
97598
97599@@ -39,6 +40,7 @@ extern Elf64_Dyn _DYNAMIC [];
97600 #define elf_note elf64_note
97601 #define elf_addr_t Elf64_Off
97602 #define Elf_Half Elf64_Half
97603+#define elf_dyn Elf64_Dyn
97604
97605 #endif
97606
97607diff --git a/include/linux/err.h b/include/linux/err.h
97608index a729120..6ede2c9 100644
97609--- a/include/linux/err.h
97610+++ b/include/linux/err.h
97611@@ -20,12 +20,12 @@
97612
97613 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
97614
97615-static inline void * __must_check ERR_PTR(long error)
97616+static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
97617 {
97618 return (void *) error;
97619 }
97620
97621-static inline long __must_check PTR_ERR(__force const void *ptr)
97622+static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
97623 {
97624 return (long) ptr;
97625 }
97626diff --git a/include/linux/extcon.h b/include/linux/extcon.h
97627index b16d929..d389bf1 100644
97628--- a/include/linux/extcon.h
97629+++ b/include/linux/extcon.h
97630@@ -120,7 +120,7 @@ struct extcon_dev {
97631 /* /sys/class/extcon/.../mutually_exclusive/... */
97632 struct attribute_group attr_g_muex;
97633 struct attribute **attrs_muex;
97634- struct device_attribute *d_attrs_muex;
97635+ device_attribute_no_const *d_attrs_muex;
97636 };
97637
97638 /**
97639diff --git a/include/linux/fb.h b/include/linux/fb.h
97640index 043f328..180ccbf 100644
97641--- a/include/linux/fb.h
97642+++ b/include/linux/fb.h
97643@@ -305,7 +305,8 @@ struct fb_ops {
97644 /* called at KDB enter and leave time to prepare the console */
97645 int (*fb_debug_enter)(struct fb_info *info);
97646 int (*fb_debug_leave)(struct fb_info *info);
97647-};
97648+} __do_const;
97649+typedef struct fb_ops __no_const fb_ops_no_const;
97650
97651 #ifdef CONFIG_FB_TILEBLITTING
97652 #define FB_TILE_CURSOR_NONE 0
97653diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
97654index fbb8874..15c61e7 100644
97655--- a/include/linux/fdtable.h
97656+++ b/include/linux/fdtable.h
97657@@ -103,7 +103,7 @@ struct files_struct *get_files_struct(struct task_struct *);
97658 void put_files_struct(struct files_struct *fs);
97659 void reset_files_struct(struct files_struct *);
97660 int unshare_files(struct files_struct **);
97661-struct files_struct *dup_fd(struct files_struct *, int *);
97662+struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
97663 void do_close_on_exec(struct files_struct *);
97664 int iterate_fd(struct files_struct *, unsigned,
97665 int (*)(const void *, struct file *, unsigned),
97666diff --git a/include/linux/fs.h b/include/linux/fs.h
97667index 84b783f..b31767d 100644
97668--- a/include/linux/fs.h
97669+++ b/include/linux/fs.h
97670@@ -439,7 +439,7 @@ struct address_space {
97671 spinlock_t private_lock; /* for use by the address_space */
97672 struct list_head private_list; /* ditto */
97673 void *private_data; /* ditto */
97674-} __attribute__((aligned(sizeof(long))));
97675+} __attribute__((aligned(sizeof(long)))) __randomize_layout;
97676 /*
97677 * On most architectures that alignment is already the case; but
97678 * must be enforced here for CRIS, to let the least significant bit
97679@@ -482,7 +482,7 @@ struct block_device {
97680 int bd_fsfreeze_count;
97681 /* Mutex for freeze */
97682 struct mutex bd_fsfreeze_mutex;
97683-};
97684+} __randomize_layout;
97685
97686 /*
97687 * Radix-tree tags, for tagging dirty and writeback pages within the pagecache
97688@@ -677,7 +677,7 @@ struct inode {
97689 #endif
97690
97691 void *i_private; /* fs or device private pointer */
97692-};
97693+} __randomize_layout;
97694
97695 static inline int inode_unhashed(struct inode *inode)
97696 {
97697@@ -872,7 +872,7 @@ struct file {
97698 struct list_head f_tfile_llink;
97699 #endif /* #ifdef CONFIG_EPOLL */
97700 struct address_space *f_mapping;
97701-} __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */
97702+} __attribute__((aligned(4))) __randomize_layout; /* lest something weird decides that 2 is OK */
97703
97704 struct file_handle {
97705 __u32 handle_bytes;
97706@@ -1001,7 +1001,7 @@ struct file_lock {
97707 int state; /* state of grant or error if -ve */
97708 } afs;
97709 } fl_u;
97710-};
97711+} __randomize_layout;
97712
97713 struct file_lock_context {
97714 spinlock_t flc_lock;
97715@@ -1380,7 +1380,7 @@ struct super_block {
97716 * Indicates how deep in a filesystem stack this SB is
97717 */
97718 int s_stack_depth;
97719-};
97720+} __randomize_layout;
97721
97722 extern struct timespec current_fs_time(struct super_block *sb);
97723
97724@@ -1632,7 +1632,8 @@ struct file_operations {
97725 #ifndef CONFIG_MMU
97726 unsigned (*mmap_capabilities)(struct file *);
97727 #endif
97728-};
97729+} __do_const __randomize_layout;
97730+typedef struct file_operations __no_const file_operations_no_const;
97731
97732 struct inode_operations {
97733 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
97734@@ -2341,7 +2342,7 @@ extern int register_chrdev_region(dev_t, unsigned, const char *);
97735 extern int __register_chrdev(unsigned int major, unsigned int baseminor,
97736 unsigned int count, const char *name,
97737 const struct file_operations *fops);
97738-extern void __unregister_chrdev(unsigned int major, unsigned int baseminor,
97739+extern __nocapture(4) void __unregister_chrdev(unsigned int major, unsigned int baseminor,
97740 unsigned int count, const char *name);
97741 extern void unregister_chrdev_region(dev_t, unsigned);
97742 extern void chrdev_show(struct seq_file *,off_t);
97743@@ -3041,4 +3042,14 @@ static inline bool dir_relax(struct inode *inode)
97744 return !IS_DEADDIR(inode);
97745 }
97746
97747+static inline bool is_sidechannel_device(const struct inode *inode)
97748+{
97749+#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
97750+ umode_t mode = inode->i_mode;
97751+ return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
97752+#else
97753+ return false;
97754+#endif
97755+}
97756+
97757 #endif /* _LINUX_FS_H */
97758diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
97759index 0efc3e6..fd23610 100644
97760--- a/include/linux/fs_struct.h
97761+++ b/include/linux/fs_struct.h
97762@@ -6,13 +6,13 @@
97763 #include <linux/seqlock.h>
97764
97765 struct fs_struct {
97766- int users;
97767+ atomic_t users;
97768 spinlock_t lock;
97769 seqcount_t seq;
97770 int umask;
97771 int in_exec;
97772 struct path root, pwd;
97773-};
97774+} __randomize_layout;
97775
97776 extern struct kmem_cache *fs_cachep;
97777
97778diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
97779index 604e152..5954d0d 100644
97780--- a/include/linux/fscache-cache.h
97781+++ b/include/linux/fscache-cache.h
97782@@ -117,7 +117,7 @@ struct fscache_operation {
97783 fscache_operation_release_t release;
97784 };
97785
97786-extern atomic_t fscache_op_debug_id;
97787+extern atomic_unchecked_t fscache_op_debug_id;
97788 extern void fscache_op_work_func(struct work_struct *work);
97789
97790 extern void fscache_enqueue_operation(struct fscache_operation *);
97791diff --git a/include/linux/fscache.h b/include/linux/fscache.h
97792index 115bb81..e7b812b 100644
97793--- a/include/linux/fscache.h
97794+++ b/include/linux/fscache.h
97795@@ -152,7 +152,7 @@ struct fscache_cookie_def {
97796 * - this is mandatory for any object that may have data
97797 */
97798 void (*now_uncached)(void *cookie_netfs_data);
97799-};
97800+} __do_const;
97801
97802 /*
97803 * fscache cached network filesystem type
97804diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
97805index 7ee1774..72505b8 100644
97806--- a/include/linux/fsnotify.h
97807+++ b/include/linux/fsnotify.h
97808@@ -197,6 +197,9 @@ static inline void fsnotify_access(struct file *file)
97809 struct inode *inode = file_inode(file);
97810 __u32 mask = FS_ACCESS;
97811
97812+ if (is_sidechannel_device(inode))
97813+ return;
97814+
97815 if (S_ISDIR(inode->i_mode))
97816 mask |= FS_ISDIR;
97817
97818@@ -215,6 +218,9 @@ static inline void fsnotify_modify(struct file *file)
97819 struct inode *inode = file_inode(file);
97820 __u32 mask = FS_MODIFY;
97821
97822+ if (is_sidechannel_device(inode))
97823+ return;
97824+
97825 if (S_ISDIR(inode->i_mode))
97826 mask |= FS_ISDIR;
97827
97828@@ -317,7 +323,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
97829 */
97830 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
97831 {
97832- return kstrdup(name, GFP_KERNEL);
97833+ return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
97834 }
97835
97836 /*
97837diff --git a/include/linux/genhd.h b/include/linux/genhd.h
97838index ec274e0..e678159 100644
97839--- a/include/linux/genhd.h
97840+++ b/include/linux/genhd.h
97841@@ -194,7 +194,7 @@ struct gendisk {
97842 struct kobject *slave_dir;
97843
97844 struct timer_rand_state *random;
97845- atomic_t sync_io; /* RAID */
97846+ atomic_unchecked_t sync_io; /* RAID */
97847 struct disk_events *ev;
97848 #ifdef CONFIG_BLK_DEV_INTEGRITY
97849 struct blk_integrity *integrity;
97850@@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
97851 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
97852
97853 /* drivers/char/random.c */
97854-extern void add_disk_randomness(struct gendisk *disk);
97855+extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
97856 extern void rand_initialize_disk(struct gendisk *disk);
97857
97858 static inline sector_t get_start_sect(struct block_device *bdev)
97859diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
97860index 667c311..abac2a7 100644
97861--- a/include/linux/genl_magic_func.h
97862+++ b/include/linux/genl_magic_func.h
97863@@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
97864 },
97865
97866 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
97867-static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
97868+static struct genl_ops ZZZ_genl_ops[] = {
97869 #include GENL_MAGIC_INCLUDE_FILE
97870 };
97871
97872diff --git a/include/linux/gfp.h b/include/linux/gfp.h
97873index ad35f30..30b1916 100644
97874--- a/include/linux/gfp.h
97875+++ b/include/linux/gfp.h
97876@@ -35,6 +35,13 @@ struct vm_area_struct;
97877 #define ___GFP_NO_KSWAPD 0x400000u
97878 #define ___GFP_OTHER_NODE 0x800000u
97879 #define ___GFP_WRITE 0x1000000u
97880+
97881+#ifdef CONFIG_PAX_USERCOPY_SLABS
97882+#define ___GFP_USERCOPY 0x2000000u
97883+#else
97884+#define ___GFP_USERCOPY 0
97885+#endif
97886+
97887 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
97888
97889 /*
97890@@ -94,6 +101,7 @@ struct vm_area_struct;
97891 #define __GFP_NO_KSWAPD ((__force gfp_t)___GFP_NO_KSWAPD)
97892 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
97893 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
97894+#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
97895
97896 /*
97897 * This may seem redundant, but it's a way of annotating false positives vs.
97898@@ -101,7 +109,7 @@ struct vm_area_struct;
97899 */
97900 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
97901
97902-#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
97903+#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
97904 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
97905
97906 /* This equals 0, but use constants in case they ever change */
97907@@ -146,6 +154,8 @@ struct vm_area_struct;
97908 /* 4GB DMA on some platforms */
97909 #define GFP_DMA32 __GFP_DMA32
97910
97911+#define GFP_USERCOPY __GFP_USERCOPY
97912+
97913 /* Convert GFP flags to their corresponding migrate type */
97914 static inline int gfpflags_to_migratetype(const gfp_t gfp_flags)
97915 {
97916diff --git a/include/linux/gracl.h b/include/linux/gracl.h
97917new file mode 100644
97918index 0000000..91858e4
97919--- /dev/null
97920+++ b/include/linux/gracl.h
97921@@ -0,0 +1,342 @@
97922+#ifndef GR_ACL_H
97923+#define GR_ACL_H
97924+
97925+#include <linux/grdefs.h>
97926+#include <linux/resource.h>
97927+#include <linux/capability.h>
97928+#include <linux/dcache.h>
97929+#include <asm/resource.h>
97930+
97931+/* Major status information */
97932+
97933+#define GR_VERSION "grsecurity 3.1"
97934+#define GRSECURITY_VERSION 0x3100
97935+
97936+enum {
97937+ GR_SHUTDOWN = 0,
97938+ GR_ENABLE = 1,
97939+ GR_SPROLE = 2,
97940+ GR_OLDRELOAD = 3,
97941+ GR_SEGVMOD = 4,
97942+ GR_STATUS = 5,
97943+ GR_UNSPROLE = 6,
97944+ GR_PASSSET = 7,
97945+ GR_SPROLEPAM = 8,
97946+ GR_RELOAD = 9,
97947+};
97948+
97949+/* Password setup definitions
97950+ * kernel/grhash.c */
97951+enum {
97952+ GR_PW_LEN = 128,
97953+ GR_SALT_LEN = 16,
97954+ GR_SHA_LEN = 32,
97955+};
97956+
97957+enum {
97958+ GR_SPROLE_LEN = 64,
97959+};
97960+
97961+enum {
97962+ GR_NO_GLOB = 0,
97963+ GR_REG_GLOB,
97964+ GR_CREATE_GLOB
97965+};
97966+
97967+#define GR_NLIMITS 32
97968+
97969+/* Begin Data Structures */
97970+
97971+struct sprole_pw {
97972+ unsigned char *rolename;
97973+ unsigned char salt[GR_SALT_LEN];
97974+ unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
97975+};
97976+
97977+struct name_entry {
97978+ __u32 key;
97979+ u64 inode;
97980+ dev_t device;
97981+ char *name;
97982+ __u16 len;
97983+ __u8 deleted;
97984+ struct name_entry *prev;
97985+ struct name_entry *next;
97986+};
97987+
97988+struct inodev_entry {
97989+ struct name_entry *nentry;
97990+ struct inodev_entry *prev;
97991+ struct inodev_entry *next;
97992+};
97993+
97994+struct acl_role_db {
97995+ struct acl_role_label **r_hash;
97996+ __u32 r_size;
97997+};
97998+
97999+struct inodev_db {
98000+ struct inodev_entry **i_hash;
98001+ __u32 i_size;
98002+};
98003+
98004+struct name_db {
98005+ struct name_entry **n_hash;
98006+ __u32 n_size;
98007+};
98008+
98009+struct crash_uid {
98010+ uid_t uid;
98011+ unsigned long expires;
98012+};
98013+
98014+struct gr_hash_struct {
98015+ void **table;
98016+ void **nametable;
98017+ void *first;
98018+ __u32 table_size;
98019+ __u32 used_size;
98020+ int type;
98021+};
98022+
98023+/* Userspace Grsecurity ACL data structures */
98024+
98025+struct acl_subject_label {
98026+ char *filename;
98027+ u64 inode;
98028+ dev_t device;
98029+ __u32 mode;
98030+ kernel_cap_t cap_mask;
98031+ kernel_cap_t cap_lower;
98032+ kernel_cap_t cap_invert_audit;
98033+
98034+ struct rlimit res[GR_NLIMITS];
98035+ __u32 resmask;
98036+
98037+ __u8 user_trans_type;
98038+ __u8 group_trans_type;
98039+ uid_t *user_transitions;
98040+ gid_t *group_transitions;
98041+ __u16 user_trans_num;
98042+ __u16 group_trans_num;
98043+
98044+ __u32 sock_families[2];
98045+ __u32 ip_proto[8];
98046+ __u32 ip_type;
98047+ struct acl_ip_label **ips;
98048+ __u32 ip_num;
98049+ __u32 inaddr_any_override;
98050+
98051+ __u32 crashes;
98052+ unsigned long expires;
98053+
98054+ struct acl_subject_label *parent_subject;
98055+ struct gr_hash_struct *hash;
98056+ struct acl_subject_label *prev;
98057+ struct acl_subject_label *next;
98058+
98059+ struct acl_object_label **obj_hash;
98060+ __u32 obj_hash_size;
98061+ __u16 pax_flags;
98062+};
98063+
98064+struct role_allowed_ip {
98065+ __u32 addr;
98066+ __u32 netmask;
98067+
98068+ struct role_allowed_ip *prev;
98069+ struct role_allowed_ip *next;
98070+};
98071+
98072+struct role_transition {
98073+ char *rolename;
98074+
98075+ struct role_transition *prev;
98076+ struct role_transition *next;
98077+};
98078+
98079+struct acl_role_label {
98080+ char *rolename;
98081+ uid_t uidgid;
98082+ __u16 roletype;
98083+
98084+ __u16 auth_attempts;
98085+ unsigned long expires;
98086+
98087+ struct acl_subject_label *root_label;
98088+ struct gr_hash_struct *hash;
98089+
98090+ struct acl_role_label *prev;
98091+ struct acl_role_label *next;
98092+
98093+ struct role_transition *transitions;
98094+ struct role_allowed_ip *allowed_ips;
98095+ uid_t *domain_children;
98096+ __u16 domain_child_num;
98097+
98098+ umode_t umask;
98099+
98100+ struct acl_subject_label **subj_hash;
98101+ __u32 subj_hash_size;
98102+};
98103+
98104+struct user_acl_role_db {
98105+ struct acl_role_label **r_table;
98106+ __u32 num_pointers; /* Number of allocations to track */
98107+ __u32 num_roles; /* Number of roles */
98108+ __u32 num_domain_children; /* Number of domain children */
98109+ __u32 num_subjects; /* Number of subjects */
98110+ __u32 num_objects; /* Number of objects */
98111+};
98112+
98113+struct acl_object_label {
98114+ char *filename;
98115+ u64 inode;
98116+ dev_t device;
98117+ __u32 mode;
98118+
98119+ struct acl_subject_label *nested;
98120+ struct acl_object_label *globbed;
98121+
98122+ /* next two structures not used */
98123+
98124+ struct acl_object_label *prev;
98125+ struct acl_object_label *next;
98126+};
98127+
98128+struct acl_ip_label {
98129+ char *iface;
98130+ __u32 addr;
98131+ __u32 netmask;
98132+ __u16 low, high;
98133+ __u8 mode;
98134+ __u32 type;
98135+ __u32 proto[8];
98136+
98137+ /* next two structures not used */
98138+
98139+ struct acl_ip_label *prev;
98140+ struct acl_ip_label *next;
98141+};
98142+
98143+struct gr_arg {
98144+ struct user_acl_role_db role_db;
98145+ unsigned char pw[GR_PW_LEN];
98146+ unsigned char salt[GR_SALT_LEN];
98147+ unsigned char sum[GR_SHA_LEN];
98148+ unsigned char sp_role[GR_SPROLE_LEN];
98149+ struct sprole_pw *sprole_pws;
98150+ dev_t segv_device;
98151+ u64 segv_inode;
98152+ uid_t segv_uid;
98153+ __u16 num_sprole_pws;
98154+ __u16 mode;
98155+};
98156+
98157+struct gr_arg_wrapper {
98158+ struct gr_arg *arg;
98159+ __u32 version;
98160+ __u32 size;
98161+};
98162+
98163+struct subject_map {
98164+ struct acl_subject_label *user;
98165+ struct acl_subject_label *kernel;
98166+ struct subject_map *prev;
98167+ struct subject_map *next;
98168+};
98169+
98170+struct acl_subj_map_db {
98171+ struct subject_map **s_hash;
98172+ __u32 s_size;
98173+};
98174+
98175+struct gr_policy_state {
98176+ struct sprole_pw **acl_special_roles;
98177+ __u16 num_sprole_pws;
98178+ struct acl_role_label *kernel_role;
98179+ struct acl_role_label *role_list;
98180+ struct acl_role_label *default_role;
98181+ struct acl_role_db acl_role_set;
98182+ struct acl_subj_map_db subj_map_set;
98183+ struct name_db name_set;
98184+ struct inodev_db inodev_set;
98185+};
98186+
98187+struct gr_alloc_state {
98188+ unsigned long alloc_stack_next;
98189+ unsigned long alloc_stack_size;
98190+ void **alloc_stack;
98191+};
98192+
98193+struct gr_reload_state {
98194+ struct gr_policy_state oldpolicy;
98195+ struct gr_alloc_state oldalloc;
98196+ struct gr_policy_state newpolicy;
98197+ struct gr_alloc_state newalloc;
98198+ struct gr_policy_state *oldpolicy_ptr;
98199+ struct gr_alloc_state *oldalloc_ptr;
98200+ unsigned char oldmode;
98201+};
98202+
98203+/* End Data Structures Section */
98204+
98205+/* Hash functions generated by empirical testing by Brad Spengler
98206+ Makes good use of the low bits of the inode. Generally 0-1 times
98207+ in loop for successful match. 0-3 for unsuccessful match.
98208+ Shift/add algorithm with modulus of table size and an XOR*/
98209+
98210+static __inline__ unsigned int
98211+gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
98212+{
98213+ return ((((uid + type) << (16 + type)) ^ uid) % sz);
98214+}
98215+
98216+ static __inline__ unsigned int
98217+gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
98218+{
98219+ return ((const unsigned long)userp % sz);
98220+}
98221+
98222+static __inline__ unsigned int
98223+gr_fhash(const u64 ino, const dev_t dev, const unsigned int sz)
98224+{
98225+ unsigned int rem;
98226+ div_u64_rem((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9)), sz, &rem);
98227+ return rem;
98228+}
98229+
98230+static __inline__ unsigned int
98231+gr_nhash(const char *name, const __u16 len, const unsigned int sz)
98232+{
98233+ return full_name_hash((const unsigned char *)name, len) % sz;
98234+}
98235+
98236+#define FOR_EACH_SUBJECT_START(role,subj,iter) \
98237+ subj = NULL; \
98238+ iter = 0; \
98239+ while (iter < role->subj_hash_size) { \
98240+ if (subj == NULL) \
98241+ subj = role->subj_hash[iter]; \
98242+ if (subj == NULL) { \
98243+ iter++; \
98244+ continue; \
98245+ }
98246+
98247+#define FOR_EACH_SUBJECT_END(subj,iter) \
98248+ subj = subj->next; \
98249+ if (subj == NULL) \
98250+ iter++; \
98251+ }
98252+
98253+
98254+#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
98255+ subj = role->hash->first; \
98256+ while (subj != NULL) {
98257+
98258+#define FOR_EACH_NESTED_SUBJECT_END(subj) \
98259+ subj = subj->next; \
98260+ }
98261+
98262+#endif
98263+
98264diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
98265new file mode 100644
98266index 0000000..af64092
98267--- /dev/null
98268+++ b/include/linux/gracl_compat.h
98269@@ -0,0 +1,156 @@
98270+#ifndef GR_ACL_COMPAT_H
98271+#define GR_ACL_COMPAT_H
98272+
98273+#include <linux/resource.h>
98274+#include <asm/resource.h>
98275+
98276+struct sprole_pw_compat {
98277+ compat_uptr_t rolename;
98278+ unsigned char salt[GR_SALT_LEN];
98279+ unsigned char sum[GR_SHA_LEN];
98280+};
98281+
98282+struct gr_hash_struct_compat {
98283+ compat_uptr_t table;
98284+ compat_uptr_t nametable;
98285+ compat_uptr_t first;
98286+ __u32 table_size;
98287+ __u32 used_size;
98288+ int type;
98289+};
98290+
98291+struct acl_subject_label_compat {
98292+ compat_uptr_t filename;
98293+ compat_u64 inode;
98294+ __u32 device;
98295+ __u32 mode;
98296+ kernel_cap_t cap_mask;
98297+ kernel_cap_t cap_lower;
98298+ kernel_cap_t cap_invert_audit;
98299+
98300+ struct compat_rlimit res[GR_NLIMITS];
98301+ __u32 resmask;
98302+
98303+ __u8 user_trans_type;
98304+ __u8 group_trans_type;
98305+ compat_uptr_t user_transitions;
98306+ compat_uptr_t group_transitions;
98307+ __u16 user_trans_num;
98308+ __u16 group_trans_num;
98309+
98310+ __u32 sock_families[2];
98311+ __u32 ip_proto[8];
98312+ __u32 ip_type;
98313+ compat_uptr_t ips;
98314+ __u32 ip_num;
98315+ __u32 inaddr_any_override;
98316+
98317+ __u32 crashes;
98318+ compat_ulong_t expires;
98319+
98320+ compat_uptr_t parent_subject;
98321+ compat_uptr_t hash;
98322+ compat_uptr_t prev;
98323+ compat_uptr_t next;
98324+
98325+ compat_uptr_t obj_hash;
98326+ __u32 obj_hash_size;
98327+ __u16 pax_flags;
98328+};
98329+
98330+struct role_allowed_ip_compat {
98331+ __u32 addr;
98332+ __u32 netmask;
98333+
98334+ compat_uptr_t prev;
98335+ compat_uptr_t next;
98336+};
98337+
98338+struct role_transition_compat {
98339+ compat_uptr_t rolename;
98340+
98341+ compat_uptr_t prev;
98342+ compat_uptr_t next;
98343+};
98344+
98345+struct acl_role_label_compat {
98346+ compat_uptr_t rolename;
98347+ uid_t uidgid;
98348+ __u16 roletype;
98349+
98350+ __u16 auth_attempts;
98351+ compat_ulong_t expires;
98352+
98353+ compat_uptr_t root_label;
98354+ compat_uptr_t hash;
98355+
98356+ compat_uptr_t prev;
98357+ compat_uptr_t next;
98358+
98359+ compat_uptr_t transitions;
98360+ compat_uptr_t allowed_ips;
98361+ compat_uptr_t domain_children;
98362+ __u16 domain_child_num;
98363+
98364+ umode_t umask;
98365+
98366+ compat_uptr_t subj_hash;
98367+ __u32 subj_hash_size;
98368+};
98369+
98370+struct user_acl_role_db_compat {
98371+ compat_uptr_t r_table;
98372+ __u32 num_pointers;
98373+ __u32 num_roles;
98374+ __u32 num_domain_children;
98375+ __u32 num_subjects;
98376+ __u32 num_objects;
98377+};
98378+
98379+struct acl_object_label_compat {
98380+ compat_uptr_t filename;
98381+ compat_u64 inode;
98382+ __u32 device;
98383+ __u32 mode;
98384+
98385+ compat_uptr_t nested;
98386+ compat_uptr_t globbed;
98387+
98388+ compat_uptr_t prev;
98389+ compat_uptr_t next;
98390+};
98391+
98392+struct acl_ip_label_compat {
98393+ compat_uptr_t iface;
98394+ __u32 addr;
98395+ __u32 netmask;
98396+ __u16 low, high;
98397+ __u8 mode;
98398+ __u32 type;
98399+ __u32 proto[8];
98400+
98401+ compat_uptr_t prev;
98402+ compat_uptr_t next;
98403+};
98404+
98405+struct gr_arg_compat {
98406+ struct user_acl_role_db_compat role_db;
98407+ unsigned char pw[GR_PW_LEN];
98408+ unsigned char salt[GR_SALT_LEN];
98409+ unsigned char sum[GR_SHA_LEN];
98410+ unsigned char sp_role[GR_SPROLE_LEN];
98411+ compat_uptr_t sprole_pws;
98412+ __u32 segv_device;
98413+ compat_u64 segv_inode;
98414+ uid_t segv_uid;
98415+ __u16 num_sprole_pws;
98416+ __u16 mode;
98417+};
98418+
98419+struct gr_arg_wrapper_compat {
98420+ compat_uptr_t arg;
98421+ __u32 version;
98422+ __u32 size;
98423+};
98424+
98425+#endif
98426diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
98427new file mode 100644
98428index 0000000..323ecf2
98429--- /dev/null
98430+++ b/include/linux/gralloc.h
98431@@ -0,0 +1,9 @@
98432+#ifndef __GRALLOC_H
98433+#define __GRALLOC_H
98434+
98435+void acl_free_all(void);
98436+int acl_alloc_stack_init(unsigned long size);
98437+void *acl_alloc(unsigned long len);
98438+void *acl_alloc_num(unsigned long num, unsigned long len);
98439+
98440+#endif
98441diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
98442new file mode 100644
98443index 0000000..be66033
98444--- /dev/null
98445+++ b/include/linux/grdefs.h
98446@@ -0,0 +1,140 @@
98447+#ifndef GRDEFS_H
98448+#define GRDEFS_H
98449+
98450+/* Begin grsecurity status declarations */
98451+
98452+enum {
98453+ GR_READY = 0x01,
98454+ GR_STATUS_INIT = 0x00 // disabled state
98455+};
98456+
98457+/* Begin ACL declarations */
98458+
98459+/* Role flags */
98460+
98461+enum {
98462+ GR_ROLE_USER = 0x0001,
98463+ GR_ROLE_GROUP = 0x0002,
98464+ GR_ROLE_DEFAULT = 0x0004,
98465+ GR_ROLE_SPECIAL = 0x0008,
98466+ GR_ROLE_AUTH = 0x0010,
98467+ GR_ROLE_NOPW = 0x0020,
98468+ GR_ROLE_GOD = 0x0040,
98469+ GR_ROLE_LEARN = 0x0080,
98470+ GR_ROLE_TPE = 0x0100,
98471+ GR_ROLE_DOMAIN = 0x0200,
98472+ GR_ROLE_PAM = 0x0400,
98473+ GR_ROLE_PERSIST = 0x0800
98474+};
98475+
98476+/* ACL Subject and Object mode flags */
98477+enum {
98478+ GR_DELETED = 0x80000000
98479+};
98480+
98481+/* ACL Object-only mode flags */
98482+enum {
98483+ GR_READ = 0x00000001,
98484+ GR_APPEND = 0x00000002,
98485+ GR_WRITE = 0x00000004,
98486+ GR_EXEC = 0x00000008,
98487+ GR_FIND = 0x00000010,
98488+ GR_INHERIT = 0x00000020,
98489+ GR_SETID = 0x00000040,
98490+ GR_CREATE = 0x00000080,
98491+ GR_DELETE = 0x00000100,
98492+ GR_LINK = 0x00000200,
98493+ GR_AUDIT_READ = 0x00000400,
98494+ GR_AUDIT_APPEND = 0x00000800,
98495+ GR_AUDIT_WRITE = 0x00001000,
98496+ GR_AUDIT_EXEC = 0x00002000,
98497+ GR_AUDIT_FIND = 0x00004000,
98498+ GR_AUDIT_INHERIT= 0x00008000,
98499+ GR_AUDIT_SETID = 0x00010000,
98500+ GR_AUDIT_CREATE = 0x00020000,
98501+ GR_AUDIT_DELETE = 0x00040000,
98502+ GR_AUDIT_LINK = 0x00080000,
98503+ GR_PTRACERD = 0x00100000,
98504+ GR_NOPTRACE = 0x00200000,
98505+ GR_SUPPRESS = 0x00400000,
98506+ GR_NOLEARN = 0x00800000,
98507+ GR_INIT_TRANSFER= 0x01000000
98508+};
98509+
98510+#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
98511+ GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
98512+ GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
98513+
98514+/* ACL subject-only mode flags */
98515+enum {
98516+ GR_KILL = 0x00000001,
98517+ GR_VIEW = 0x00000002,
98518+ GR_PROTECTED = 0x00000004,
98519+ GR_LEARN = 0x00000008,
98520+ GR_OVERRIDE = 0x00000010,
98521+ /* just a placeholder, this mode is only used in userspace */
98522+ GR_DUMMY = 0x00000020,
98523+ GR_PROTSHM = 0x00000040,
98524+ GR_KILLPROC = 0x00000080,
98525+ GR_KILLIPPROC = 0x00000100,
98526+ /* just a placeholder, this mode is only used in userspace */
98527+ GR_NOTROJAN = 0x00000200,
98528+ GR_PROTPROCFD = 0x00000400,
98529+ GR_PROCACCT = 0x00000800,
98530+ GR_RELAXPTRACE = 0x00001000,
98531+ //GR_NESTED = 0x00002000,
98532+ GR_INHERITLEARN = 0x00004000,
98533+ GR_PROCFIND = 0x00008000,
98534+ GR_POVERRIDE = 0x00010000,
98535+ GR_KERNELAUTH = 0x00020000,
98536+ GR_ATSECURE = 0x00040000,
98537+ GR_SHMEXEC = 0x00080000
98538+};
98539+
98540+enum {
98541+ GR_PAX_ENABLE_SEGMEXEC = 0x0001,
98542+ GR_PAX_ENABLE_PAGEEXEC = 0x0002,
98543+ GR_PAX_ENABLE_MPROTECT = 0x0004,
98544+ GR_PAX_ENABLE_RANDMMAP = 0x0008,
98545+ GR_PAX_ENABLE_EMUTRAMP = 0x0010,
98546+ GR_PAX_DISABLE_SEGMEXEC = 0x0100,
98547+ GR_PAX_DISABLE_PAGEEXEC = 0x0200,
98548+ GR_PAX_DISABLE_MPROTECT = 0x0400,
98549+ GR_PAX_DISABLE_RANDMMAP = 0x0800,
98550+ GR_PAX_DISABLE_EMUTRAMP = 0x1000,
98551+};
98552+
98553+enum {
98554+ GR_ID_USER = 0x01,
98555+ GR_ID_GROUP = 0x02,
98556+};
98557+
98558+enum {
98559+ GR_ID_ALLOW = 0x01,
98560+ GR_ID_DENY = 0x02,
98561+};
98562+
98563+#define GR_CRASH_RES 31
98564+#define GR_UIDTABLE_MAX 500
98565+
98566+/* begin resource learning section */
98567+enum {
98568+ GR_RLIM_CPU_BUMP = 60,
98569+ GR_RLIM_FSIZE_BUMP = 50000,
98570+ GR_RLIM_DATA_BUMP = 10000,
98571+ GR_RLIM_STACK_BUMP = 1000,
98572+ GR_RLIM_CORE_BUMP = 10000,
98573+ GR_RLIM_RSS_BUMP = 500000,
98574+ GR_RLIM_NPROC_BUMP = 1,
98575+ GR_RLIM_NOFILE_BUMP = 5,
98576+ GR_RLIM_MEMLOCK_BUMP = 50000,
98577+ GR_RLIM_AS_BUMP = 500000,
98578+ GR_RLIM_LOCKS_BUMP = 2,
98579+ GR_RLIM_SIGPENDING_BUMP = 5,
98580+ GR_RLIM_MSGQUEUE_BUMP = 10000,
98581+ GR_RLIM_NICE_BUMP = 1,
98582+ GR_RLIM_RTPRIO_BUMP = 1,
98583+ GR_RLIM_RTTIME_BUMP = 1000000
98584+};
98585+
98586+#endif
98587diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
98588new file mode 100644
98589index 0000000..6245f9e
98590--- /dev/null
98591+++ b/include/linux/grinternal.h
98592@@ -0,0 +1,230 @@
98593+#ifndef __GRINTERNAL_H
98594+#define __GRINTERNAL_H
98595+
98596+#ifdef CONFIG_GRKERNSEC
98597+
98598+#include <linux/fs.h>
98599+#include <linux/mnt_namespace.h>
98600+#include <linux/nsproxy.h>
98601+#include <linux/gracl.h>
98602+#include <linux/grdefs.h>
98603+#include <linux/grmsg.h>
98604+
98605+void gr_add_learn_entry(const char *fmt, ...)
98606+ __attribute__ ((format (printf, 1, 2)));
98607+__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
98608+ const struct vfsmount *mnt);
98609+__u32 gr_check_create(const struct dentry *new_dentry,
98610+ const struct dentry *parent,
98611+ const struct vfsmount *mnt, const __u32 mode);
98612+int gr_check_protected_task(const struct task_struct *task);
98613+__u32 to_gr_audit(const __u32 reqmode);
98614+int gr_set_acls(const int type);
98615+int gr_acl_is_enabled(void);
98616+char gr_roletype_to_char(void);
98617+
98618+void gr_handle_alertkill(struct task_struct *task);
98619+char *gr_to_filename(const struct dentry *dentry,
98620+ const struct vfsmount *mnt);
98621+char *gr_to_filename1(const struct dentry *dentry,
98622+ const struct vfsmount *mnt);
98623+char *gr_to_filename2(const struct dentry *dentry,
98624+ const struct vfsmount *mnt);
98625+char *gr_to_filename3(const struct dentry *dentry,
98626+ const struct vfsmount *mnt);
98627+
98628+extern int grsec_enable_ptrace_readexec;
98629+extern int grsec_enable_harden_ptrace;
98630+extern int grsec_enable_link;
98631+extern int grsec_enable_fifo;
98632+extern int grsec_enable_execve;
98633+extern int grsec_enable_shm;
98634+extern int grsec_enable_execlog;
98635+extern int grsec_enable_signal;
98636+extern int grsec_enable_audit_ptrace;
98637+extern int grsec_enable_forkfail;
98638+extern int grsec_enable_time;
98639+extern int grsec_enable_rofs;
98640+extern int grsec_deny_new_usb;
98641+extern int grsec_enable_chroot_shmat;
98642+extern int grsec_enable_chroot_mount;
98643+extern int grsec_enable_chroot_double;
98644+extern int grsec_enable_chroot_pivot;
98645+extern int grsec_enable_chroot_chdir;
98646+extern int grsec_enable_chroot_chmod;
98647+extern int grsec_enable_chroot_mknod;
98648+extern int grsec_enable_chroot_fchdir;
98649+extern int grsec_enable_chroot_nice;
98650+extern int grsec_enable_chroot_execlog;
98651+extern int grsec_enable_chroot_caps;
98652+extern int grsec_enable_chroot_rename;
98653+extern int grsec_enable_chroot_sysctl;
98654+extern int grsec_enable_chroot_unix;
98655+extern int grsec_enable_symlinkown;
98656+extern kgid_t grsec_symlinkown_gid;
98657+extern int grsec_enable_tpe;
98658+extern kgid_t grsec_tpe_gid;
98659+extern int grsec_enable_tpe_all;
98660+extern int grsec_enable_tpe_invert;
98661+extern int grsec_enable_socket_all;
98662+extern kgid_t grsec_socket_all_gid;
98663+extern int grsec_enable_socket_client;
98664+extern kgid_t grsec_socket_client_gid;
98665+extern int grsec_enable_socket_server;
98666+extern kgid_t grsec_socket_server_gid;
98667+extern kgid_t grsec_audit_gid;
98668+extern int grsec_enable_group;
98669+extern int grsec_enable_log_rwxmaps;
98670+extern int grsec_enable_mount;
98671+extern int grsec_enable_chdir;
98672+extern int grsec_resource_logging;
98673+extern int grsec_enable_blackhole;
98674+extern int grsec_lastack_retries;
98675+extern int grsec_enable_brute;
98676+extern int grsec_enable_harden_ipc;
98677+extern int grsec_lock;
98678+
98679+extern spinlock_t grsec_alert_lock;
98680+extern unsigned long grsec_alert_wtime;
98681+extern unsigned long grsec_alert_fyet;
98682+
98683+extern spinlock_t grsec_audit_lock;
98684+
98685+extern rwlock_t grsec_exec_file_lock;
98686+
98687+#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
98688+ gr_to_filename2((tsk)->exec_file->f_path.dentry, \
98689+ (tsk)->exec_file->f_path.mnt) : "/")
98690+
98691+#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
98692+ gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
98693+ (tsk)->real_parent->exec_file->f_path.mnt) : "/")
98694+
98695+#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
98696+ gr_to_filename((tsk)->exec_file->f_path.dentry, \
98697+ (tsk)->exec_file->f_path.mnt) : "/")
98698+
98699+#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
98700+ gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
98701+ (tsk)->real_parent->exec_file->f_path.mnt) : "/")
98702+
98703+#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
98704+
98705+#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
98706+
98707+static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
98708+{
98709+ if (file1 && file2) {
98710+ const struct inode *inode1 = file1->f_path.dentry->d_inode;
98711+ const struct inode *inode2 = file2->f_path.dentry->d_inode;
98712+ if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
98713+ return true;
98714+ }
98715+
98716+ return false;
98717+}
98718+
98719+#define GR_CHROOT_CAPS {{ \
98720+ CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
98721+ CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
98722+ CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
98723+ CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
98724+ CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
98725+ CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
98726+ CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
98727+
98728+#define security_learn(normal_msg,args...) \
98729+({ \
98730+ read_lock(&grsec_exec_file_lock); \
98731+ gr_add_learn_entry(normal_msg "\n", ## args); \
98732+ read_unlock(&grsec_exec_file_lock); \
98733+})
98734+
98735+enum {
98736+ GR_DO_AUDIT,
98737+ GR_DONT_AUDIT,
98738+ /* used for non-audit messages that we shouldn't kill the task on */
98739+ GR_DONT_AUDIT_GOOD
98740+};
98741+
98742+enum {
98743+ GR_TTYSNIFF,
98744+ GR_RBAC,
98745+ GR_RBAC_STR,
98746+ GR_STR_RBAC,
98747+ GR_RBAC_MODE2,
98748+ GR_RBAC_MODE3,
98749+ GR_FILENAME,
98750+ GR_SYSCTL_HIDDEN,
98751+ GR_NOARGS,
98752+ GR_ONE_INT,
98753+ GR_ONE_INT_TWO_STR,
98754+ GR_ONE_STR,
98755+ GR_STR_INT,
98756+ GR_TWO_STR_INT,
98757+ GR_TWO_INT,
98758+ GR_TWO_U64,
98759+ GR_THREE_INT,
98760+ GR_FIVE_INT_TWO_STR,
98761+ GR_TWO_STR,
98762+ GR_THREE_STR,
98763+ GR_FOUR_STR,
98764+ GR_STR_FILENAME,
98765+ GR_FILENAME_STR,
98766+ GR_FILENAME_TWO_INT,
98767+ GR_FILENAME_TWO_INT_STR,
98768+ GR_TEXTREL,
98769+ GR_PTRACE,
98770+ GR_RESOURCE,
98771+ GR_CAP,
98772+ GR_SIG,
98773+ GR_SIG2,
98774+ GR_CRASH1,
98775+ GR_CRASH2,
98776+ GR_PSACCT,
98777+ GR_RWXMAP,
98778+ GR_RWXMAPVMA
98779+};
98780+
98781+#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
98782+#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
98783+#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
98784+#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
98785+#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
98786+#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
98787+#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)
98788+#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
98789+#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
98790+#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
98791+#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
98792+#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
98793+#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
98794+#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
98795+#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
98796+#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
98797+#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)
98798+#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
98799+#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
98800+#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
98801+#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
98802+#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
98803+#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
98804+#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
98805+#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)
98806+#define gr_log_textrel_ulong_ulong(audit, msg, str, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, str, file, ulong1, ulong2)
98807+#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
98808+#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
98809+#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
98810+#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
98811+#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
98812+#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
98813+#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
98814+#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)
98815+#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
98816+#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
98817+
98818+void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
98819+
98820+#endif
98821+
98822+#endif
98823diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
98824new file mode 100644
98825index 0000000..3092b3c
98826--- /dev/null
98827+++ b/include/linux/grmsg.h
98828@@ -0,0 +1,118 @@
98829+#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"
98830+#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"
98831+#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
98832+#define GR_STOPMOD_MSG "denied modification of module state by "
98833+#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
98834+#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
98835+#define GR_IOPERM_MSG "denied use of ioperm() by "
98836+#define GR_IOPL_MSG "denied use of iopl() by "
98837+#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
98838+#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
98839+#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
98840+#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
98841+#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
98842+#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"
98843+#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"
98844+#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
98845+#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
98846+#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
98847+#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
98848+#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
98849+#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
98850+#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
98851+#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
98852+#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
98853+#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
98854+#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
98855+#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
98856+#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
98857+#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
98858+#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
98859+#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
98860+#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
98861+#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
98862+#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
98863+#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
98864+#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
98865+#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
98866+#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
98867+#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
98868+#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
98869+#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
98870+#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
98871+#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
98872+#define GR_CHROOT_RENAME_MSG "denied bad rename of %.950s out of a chroot by "
98873+#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
98874+#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
98875+#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
98876+#define GR_CHROOT_FHANDLE_MSG "denied use of file handles inside chroot by "
98877+#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
98878+#define GR_SETXATTR_ACL_MSG "%s setting extended attribute of %.950s by "
98879+#define GR_REMOVEXATTR_ACL_MSG "%s removing extended attribute of %.950s by "
98880+#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
98881+#define GR_INITF_ACL_MSG "init_variables() failed %s by "
98882+#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"
98883+#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
98884+#define GR_SHUTS_ACL_MSG "shutdown auth success for "
98885+#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
98886+#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
98887+#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
98888+#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
98889+#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
98890+#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
98891+#define GR_ENABLEF_ACL_MSG "unable to load %s for "
98892+#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
98893+#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
98894+#define GR_RELOADF_ACL_MSG "failed reload of %s for "
98895+#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
98896+#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
98897+#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
98898+#define GR_SPROLEF_ACL_MSG "special role %s failure for "
98899+#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
98900+#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
98901+#define GR_INVMODE_ACL_MSG "invalid mode %d by "
98902+#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
98903+#define GR_FAILFORK_MSG "failed fork with errno %s by "
98904+#define GR_NICE_CHROOT_MSG "denied priority change by "
98905+#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
98906+#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
98907+#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
98908+#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
98909+#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
98910+#define GR_TIME_MSG "time set by "
98911+#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
98912+#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
98913+#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
98914+#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
98915+#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
98916+#define GR_BIND_MSG "denied bind() by "
98917+#define GR_CONNECT_MSG "denied connect() by "
98918+#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
98919+#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
98920+#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"
98921+#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
98922+#define GR_CAP_ACL_MSG "use of %s denied for "
98923+#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
98924+#define GR_CAP_ACL_MSG2 "use of %s permitted for "
98925+#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
98926+#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
98927+#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
98928+#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
98929+#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
98930+#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
98931+#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
98932+#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
98933+#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
98934+#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
98935+#define GR_TEXTREL_AUDIT_MSG "allowed %s text relocation transition in %.950s, VMA:0x%08lx 0x%08lx by "
98936+#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
98937+#define GR_VM86_MSG "denied use of vm86 by "
98938+#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
98939+#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
98940+#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
98941+#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
98942+#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
98943+#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 "
98944+#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 "
98945+#define GR_IPC_DENIED_MSG "denied %s of overly-permissive IPC object with creator uid %u by "
98946+#define GR_MSRWRITE_MSG "denied write to CPU MSR by "
98947diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
98948new file mode 100644
98949index 0000000..0ea4a82
98950--- /dev/null
98951+++ b/include/linux/grsecurity.h
98952@@ -0,0 +1,255 @@
98953+#ifndef GR_SECURITY_H
98954+#define GR_SECURITY_H
98955+#include <linux/fs.h>
98956+#include <linux/fs_struct.h>
98957+#include <linux/binfmts.h>
98958+#include <linux/gracl.h>
98959+
98960+/* notify of brain-dead configs */
98961+#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_GRKERNSEC_KMEM)
98962+#error "CONFIG_DEBUG_FS being enabled is a security risk when CONFIG_GRKERNSEC_KMEM is enabled"
98963+#endif
98964+#if defined(CONFIG_PROC_PAGE_MONITOR) && defined(CONFIG_GRKERNSEC)
98965+#error "CONFIG_PROC_PAGE_MONITOR is a security risk"
98966+#endif
98967+#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
98968+#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
98969+#endif
98970+#if defined(CONFIG_GRKERNSEC_PROC) && !defined(CONFIG_GRKERNSEC_PROC_USER) && !defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
98971+#error "CONFIG_GRKERNSEC_PROC enabled, but neither CONFIG_GRKERNSEC_PROC_USER nor CONFIG_GRKERNSEC_PROC_USERGROUP enabled"
98972+#endif
98973+#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
98974+#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
98975+#endif
98976+#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
98977+#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
98978+#endif
98979+#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
98980+#error "CONFIG_PAX enabled, but no PaX options are enabled."
98981+#endif
98982+
98983+int gr_handle_new_usb(void);
98984+
98985+void gr_handle_brute_attach(int dumpable);
98986+void gr_handle_brute_check(void);
98987+void gr_handle_kernel_exploit(void);
98988+
98989+char gr_roletype_to_char(void);
98990+
98991+int gr_proc_is_restricted(void);
98992+
98993+int gr_acl_enable_at_secure(void);
98994+
98995+int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
98996+int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
98997+
98998+int gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap);
98999+
99000+void gr_del_task_from_ip_table(struct task_struct *p);
99001+
99002+int gr_pid_is_chrooted(struct task_struct *p);
99003+int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
99004+int gr_handle_chroot_nice(void);
99005+int gr_handle_chroot_sysctl(const int op);
99006+int gr_handle_chroot_setpriority(struct task_struct *p,
99007+ const int niceval);
99008+int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
99009+int gr_chroot_fhandle(void);
99010+int gr_handle_chroot_chroot(const struct dentry *dentry,
99011+ const struct vfsmount *mnt);
99012+void gr_handle_chroot_chdir(const struct path *path);
99013+int gr_handle_chroot_chmod(const struct dentry *dentry,
99014+ const struct vfsmount *mnt, const int mode);
99015+int gr_handle_chroot_mknod(const struct dentry *dentry,
99016+ const struct vfsmount *mnt, const int mode);
99017+int gr_handle_chroot_mount(const struct dentry *dentry,
99018+ const struct vfsmount *mnt,
99019+ const char *dev_name);
99020+int gr_handle_chroot_pivot(void);
99021+int gr_handle_chroot_unix(const pid_t pid);
99022+
99023+int gr_handle_rawio(const struct inode *inode);
99024+
99025+void gr_handle_ioperm(void);
99026+void gr_handle_iopl(void);
99027+void gr_handle_msr_write(void);
99028+
99029+umode_t gr_acl_umask(void);
99030+
99031+int gr_tpe_allow(const struct file *file);
99032+
99033+void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
99034+void gr_clear_chroot_entries(struct task_struct *task);
99035+
99036+void gr_log_forkfail(const int retval);
99037+void gr_log_timechange(void);
99038+void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
99039+void gr_log_chdir(const struct dentry *dentry,
99040+ const struct vfsmount *mnt);
99041+void gr_log_chroot_exec(const struct dentry *dentry,
99042+ const struct vfsmount *mnt);
99043+void gr_log_remount(const char *devname, const int retval);
99044+void gr_log_unmount(const char *devname, const int retval);
99045+void gr_log_mount(const char *from, struct path *to, const int retval);
99046+void gr_log_textrel(struct vm_area_struct *vma, bool is_textrel_rw);
99047+void gr_log_ptgnustack(struct file *file);
99048+void gr_log_rwxmmap(struct file *file);
99049+void gr_log_rwxmprotect(struct vm_area_struct *vma);
99050+
99051+int gr_handle_follow_link(const struct dentry *dentry,
99052+ const struct vfsmount *mnt);
99053+int gr_handle_fifo(const struct dentry *dentry,
99054+ const struct vfsmount *mnt,
99055+ const struct dentry *dir, const int flag,
99056+ const int acc_mode);
99057+int gr_handle_hardlink(const struct dentry *dentry,
99058+ const struct vfsmount *mnt,
99059+ const struct filename *to);
99060+
99061+int gr_is_capable(const int cap);
99062+int gr_is_capable_nolog(const int cap);
99063+int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
99064+int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
99065+
99066+void gr_copy_label(struct task_struct *tsk);
99067+void gr_handle_crash(struct task_struct *task, const int sig);
99068+int gr_handle_signal(const struct task_struct *p, const int sig);
99069+int gr_check_crash_uid(const kuid_t uid);
99070+int gr_check_protected_task(const struct task_struct *task);
99071+int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
99072+int gr_acl_handle_mmap(const struct file *file,
99073+ const unsigned long prot);
99074+int gr_acl_handle_mprotect(const struct file *file,
99075+ const unsigned long prot);
99076+int gr_check_hidden_task(const struct task_struct *tsk);
99077+__u32 gr_acl_handle_truncate(const struct dentry *dentry,
99078+ const struct vfsmount *mnt);
99079+__u32 gr_acl_handle_utime(const struct dentry *dentry,
99080+ const struct vfsmount *mnt);
99081+__u32 gr_acl_handle_access(const struct dentry *dentry,
99082+ const struct vfsmount *mnt, const int fmode);
99083+__u32 gr_acl_handle_chmod(const struct dentry *dentry,
99084+ const struct vfsmount *mnt, umode_t *mode);
99085+__u32 gr_acl_handle_chown(const struct dentry *dentry,
99086+ const struct vfsmount *mnt);
99087+__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
99088+ const struct vfsmount *mnt);
99089+__u32 gr_acl_handle_removexattr(const struct dentry *dentry,
99090+ const struct vfsmount *mnt);
99091+int gr_handle_ptrace(struct task_struct *task, const long request);
99092+int gr_handle_proc_ptrace(struct task_struct *task);
99093+__u32 gr_acl_handle_execve(const struct dentry *dentry,
99094+ const struct vfsmount *mnt);
99095+int gr_check_crash_exec(const struct file *filp);
99096+int gr_acl_is_enabled(void);
99097+void gr_set_role_label(struct task_struct *task, const kuid_t uid,
99098+ const kgid_t gid);
99099+int gr_set_proc_label(const struct dentry *dentry,
99100+ const struct vfsmount *mnt,
99101+ const int unsafe_flags);
99102+__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
99103+ const struct vfsmount *mnt);
99104+__u32 gr_acl_handle_open(const struct dentry *dentry,
99105+ const struct vfsmount *mnt, int acc_mode);
99106+__u32 gr_acl_handle_creat(const struct dentry *dentry,
99107+ const struct dentry *p_dentry,
99108+ const struct vfsmount *p_mnt,
99109+ int open_flags, int acc_mode, const int imode);
99110+void gr_handle_create(const struct dentry *dentry,
99111+ const struct vfsmount *mnt);
99112+void gr_handle_proc_create(const struct dentry *dentry,
99113+ const struct inode *inode);
99114+__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
99115+ const struct dentry *parent_dentry,
99116+ const struct vfsmount *parent_mnt,
99117+ const int mode);
99118+__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
99119+ const struct dentry *parent_dentry,
99120+ const struct vfsmount *parent_mnt);
99121+__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
99122+ const struct vfsmount *mnt);
99123+void gr_handle_delete(const u64 ino, const dev_t dev);
99124+__u32 gr_acl_handle_unlink(const struct dentry *dentry,
99125+ const struct vfsmount *mnt);
99126+__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
99127+ const struct dentry *parent_dentry,
99128+ const struct vfsmount *parent_mnt,
99129+ const struct filename *from);
99130+__u32 gr_acl_handle_link(const struct dentry *new_dentry,
99131+ const struct dentry *parent_dentry,
99132+ const struct vfsmount *parent_mnt,
99133+ const struct dentry *old_dentry,
99134+ const struct vfsmount *old_mnt, const struct filename *to);
99135+int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
99136+int gr_acl_handle_rename(struct dentry *new_dentry,
99137+ struct dentry *parent_dentry,
99138+ const struct vfsmount *parent_mnt,
99139+ struct dentry *old_dentry,
99140+ struct inode *old_parent_inode,
99141+ struct vfsmount *old_mnt, const struct filename *newname, unsigned int flags);
99142+void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
99143+ struct dentry *old_dentry,
99144+ struct dentry *new_dentry,
99145+ struct vfsmount *mnt, const __u8 replace, unsigned int flags);
99146+__u32 gr_check_link(const struct dentry *new_dentry,
99147+ const struct dentry *parent_dentry,
99148+ const struct vfsmount *parent_mnt,
99149+ const struct dentry *old_dentry,
99150+ const struct vfsmount *old_mnt);
99151+int gr_acl_handle_filldir(const struct file *file, const char *name,
99152+ const unsigned int namelen, const u64 ino);
99153+
99154+__u32 gr_acl_handle_unix(const struct dentry *dentry,
99155+ const struct vfsmount *mnt);
99156+void gr_acl_handle_exit(void);
99157+void gr_acl_handle_psacct(struct task_struct *task, const long code);
99158+int gr_acl_handle_procpidmem(const struct task_struct *task);
99159+int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
99160+int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
99161+void gr_audit_ptrace(struct task_struct *task);
99162+dev_t gr_get_dev_from_dentry(struct dentry *dentry);
99163+u64 gr_get_ino_from_dentry(struct dentry *dentry);
99164+void gr_put_exec_file(struct task_struct *task);
99165+
99166+int gr_get_symlinkown_enabled(void);
99167+
99168+int gr_ptrace_readexec(struct file *file, int unsafe_flags);
99169+
99170+void gr_inc_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt);
99171+void gr_dec_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt);
99172+int gr_bad_chroot_rename(struct dentry *olddentry, struct vfsmount *oldmnt,
99173+ struct dentry *newdentry, struct vfsmount *newmnt);
99174+
99175+#ifdef CONFIG_GRKERNSEC_RESLOG
99176+extern void gr_log_resource(const struct task_struct *task, const int res,
99177+ const unsigned long wanted, const int gt);
99178+#else
99179+static inline void gr_log_resource(const struct task_struct *task, const int res,
99180+ const unsigned long wanted, const int gt)
99181+{
99182+}
99183+#endif
99184+
99185+#ifdef CONFIG_GRKERNSEC
99186+void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
99187+void gr_handle_vm86(void);
99188+void gr_handle_mem_readwrite(u64 from, u64 to);
99189+
99190+void gr_log_badprocpid(const char *entry);
99191+
99192+extern int grsec_enable_dmesg;
99193+extern int grsec_disable_privio;
99194+
99195+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
99196+extern kgid_t grsec_proc_gid;
99197+#endif
99198+
99199+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
99200+extern int grsec_enable_chroot_findtask;
99201+#endif
99202+#ifdef CONFIG_GRKERNSEC_SETXID
99203+extern int grsec_enable_setxid;
99204+#endif
99205+#endif
99206+
99207+#endif
99208diff --git a/include/linux/grsock.h b/include/linux/grsock.h
99209new file mode 100644
99210index 0000000..e7ffaaf
99211--- /dev/null
99212+++ b/include/linux/grsock.h
99213@@ -0,0 +1,19 @@
99214+#ifndef __GRSOCK_H
99215+#define __GRSOCK_H
99216+
99217+extern void gr_attach_curr_ip(const struct sock *sk);
99218+extern int gr_handle_sock_all(const int family, const int type,
99219+ const int protocol);
99220+extern int gr_handle_sock_server(const struct sockaddr *sck);
99221+extern int gr_handle_sock_server_other(const struct sock *sck);
99222+extern int gr_handle_sock_client(const struct sockaddr *sck);
99223+extern int gr_search_connect(struct socket * sock,
99224+ struct sockaddr_in * addr);
99225+extern int gr_search_bind(struct socket * sock,
99226+ struct sockaddr_in * addr);
99227+extern int gr_search_listen(struct socket * sock);
99228+extern int gr_search_accept(struct socket * sock);
99229+extern int gr_search_socket(const int domain, const int type,
99230+ const int protocol);
99231+
99232+#endif
99233diff --git a/include/linux/highmem.h b/include/linux/highmem.h
99234index 6aefcd0..98b81dc 100644
99235--- a/include/linux/highmem.h
99236+++ b/include/linux/highmem.h
99237@@ -191,6 +191,18 @@ static inline void clear_highpage(struct page *page)
99238 kunmap_atomic(kaddr);
99239 }
99240
99241+static inline void sanitize_highpage(struct page *page)
99242+{
99243+ void *kaddr;
99244+ unsigned long flags;
99245+
99246+ local_irq_save(flags);
99247+ kaddr = kmap_atomic(page);
99248+ clear_page(kaddr);
99249+ kunmap_atomic(kaddr);
99250+ local_irq_restore(flags);
99251+}
99252+
99253 static inline void zero_user_segments(struct page *page,
99254 unsigned start1, unsigned end1,
99255 unsigned start2, unsigned end2)
99256diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
99257index 1c7b89a..7dda400 100644
99258--- a/include/linux/hwmon-sysfs.h
99259+++ b/include/linux/hwmon-sysfs.h
99260@@ -25,7 +25,8 @@
99261 struct sensor_device_attribute{
99262 struct device_attribute dev_attr;
99263 int index;
99264-};
99265+} __do_const;
99266+typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
99267 #define to_sensor_dev_attr(_dev_attr) \
99268 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
99269
99270@@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
99271 struct device_attribute dev_attr;
99272 u8 index;
99273 u8 nr;
99274-};
99275+} __do_const;
99276+typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
99277 #define to_sensor_dev_attr_2(_dev_attr) \
99278 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
99279
99280diff --git a/include/linux/i2c.h b/include/linux/i2c.h
99281index e83a738..8b323fa 100644
99282--- a/include/linux/i2c.h
99283+++ b/include/linux/i2c.h
99284@@ -409,6 +409,7 @@ struct i2c_algorithm {
99285 int (*unreg_slave)(struct i2c_client *client);
99286 #endif
99287 };
99288+typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
99289
99290 /**
99291 * struct i2c_bus_recovery_info - I2C bus recovery information
99292diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
99293index b49cf92..0c29072 100644
99294--- a/include/linux/if_pppox.h
99295+++ b/include/linux/if_pppox.h
99296@@ -78,7 +78,7 @@ struct pppox_proto {
99297 int (*ioctl)(struct socket *sock, unsigned int cmd,
99298 unsigned long arg);
99299 struct module *owner;
99300-};
99301+} __do_const;
99302
99303 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
99304 extern void unregister_pppox_proto(int proto_num);
99305diff --git a/include/linux/init.h b/include/linux/init.h
99306index b449f37..61005b3 100644
99307--- a/include/linux/init.h
99308+++ b/include/linux/init.h
99309@@ -37,9 +37,17 @@
99310 * section.
99311 */
99312
99313+#define add_init_latent_entropy __latent_entropy
99314+
99315+#ifdef CONFIG_MEMORY_HOTPLUG
99316+#define add_meminit_latent_entropy
99317+#else
99318+#define add_meminit_latent_entropy __latent_entropy
99319+#endif
99320+
99321 /* These are for everybody (although not all archs will actually
99322 discard it in modules) */
99323-#define __init __section(.init.text) __cold notrace
99324+#define __init __section(.init.text) __cold notrace add_init_latent_entropy
99325 #define __initdata __section(.init.data)
99326 #define __initconst __constsection(.init.rodata)
99327 #define __exitdata __section(.exit.data)
99328@@ -92,7 +100,7 @@
99329 #define __exit __section(.exit.text) __exitused __cold notrace
99330
99331 /* Used for MEMORY_HOTPLUG */
99332-#define __meminit __section(.meminit.text) __cold notrace
99333+#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
99334 #define __meminitdata __section(.meminit.data)
99335 #define __meminitconst __constsection(.meminit.rodata)
99336 #define __memexit __section(.memexit.text) __exitused __cold notrace
99337diff --git a/include/linux/init_task.h b/include/linux/init_task.h
99338index bb9b075..ecac42c 100644
99339--- a/include/linux/init_task.h
99340+++ b/include/linux/init_task.h
99341@@ -157,6 +157,12 @@ extern struct task_group root_task_group;
99342
99343 #define INIT_TASK_COMM "swapper"
99344
99345+#ifdef CONFIG_X86
99346+#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
99347+#else
99348+#define INIT_TASK_THREAD_INFO
99349+#endif
99350+
99351 #ifdef CONFIG_RT_MUTEXES
99352 # define INIT_RT_MUTEXES(tsk) \
99353 .pi_waiters = RB_ROOT, \
99354@@ -223,6 +229,7 @@ extern struct task_group root_task_group;
99355 RCU_POINTER_INITIALIZER(cred, &init_cred), \
99356 .comm = INIT_TASK_COMM, \
99357 .thread = INIT_THREAD, \
99358+ INIT_TASK_THREAD_INFO \
99359 .fs = &init_fs, \
99360 .files = &init_files, \
99361 .signal = &init_signals, \
99362diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
99363index be7e75c..09bec77 100644
99364--- a/include/linux/interrupt.h
99365+++ b/include/linux/interrupt.h
99366@@ -433,8 +433,8 @@ extern const char * const softirq_to_name[NR_SOFTIRQS];
99367
99368 struct softirq_action
99369 {
99370- void (*action)(struct softirq_action *);
99371-};
99372+ void (*action)(void);
99373+} __no_const;
99374
99375 asmlinkage void do_softirq(void);
99376 asmlinkage void __do_softirq(void);
99377@@ -448,7 +448,7 @@ static inline void do_softirq_own_stack(void)
99378 }
99379 #endif
99380
99381-extern void open_softirq(int nr, void (*action)(struct softirq_action *));
99382+extern void open_softirq(int nr, void (*action)(void));
99383 extern void softirq_init(void);
99384 extern void __raise_softirq_irqoff(unsigned int nr);
99385
99386diff --git a/include/linux/iommu.h b/include/linux/iommu.h
99387index f9c1b6d..db7d6f5 100644
99388--- a/include/linux/iommu.h
99389+++ b/include/linux/iommu.h
99390@@ -192,7 +192,7 @@ struct iommu_ops {
99391
99392 unsigned long pgsize_bitmap;
99393 void *priv;
99394-};
99395+} __do_const;
99396
99397 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
99398 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
99399diff --git a/include/linux/ioport.h b/include/linux/ioport.h
99400index 388e3ae..d7e45a1 100644
99401--- a/include/linux/ioport.h
99402+++ b/include/linux/ioport.h
99403@@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
99404 int adjust_resource(struct resource *res, resource_size_t start,
99405 resource_size_t size);
99406 resource_size_t resource_alignment(struct resource *res);
99407-static inline resource_size_t resource_size(const struct resource *res)
99408+static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
99409 {
99410 return res->end - res->start + 1;
99411 }
99412diff --git a/include/linux/ipc.h b/include/linux/ipc.h
99413index 9d84942..12d5bdf 100644
99414--- a/include/linux/ipc.h
99415+++ b/include/linux/ipc.h
99416@@ -19,8 +19,8 @@ struct kern_ipc_perm
99417 kuid_t cuid;
99418 kgid_t cgid;
99419 umode_t mode;
99420- unsigned long seq;
99421+ unsigned long seq __intentional_overflow(-1);
99422 void *security;
99423-};
99424+} __randomize_layout;
99425
99426 #endif /* _LINUX_IPC_H */
99427diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
99428index 1eee6bc..9cf4912 100644
99429--- a/include/linux/ipc_namespace.h
99430+++ b/include/linux/ipc_namespace.h
99431@@ -60,7 +60,7 @@ struct ipc_namespace {
99432 struct user_namespace *user_ns;
99433
99434 struct ns_common ns;
99435-};
99436+} __randomize_layout;
99437
99438 extern struct ipc_namespace init_ipc_ns;
99439 extern atomic_t nr_ipc_ns;
99440diff --git a/include/linux/irq.h b/include/linux/irq.h
99441index 51744bc..e902653 100644
99442--- a/include/linux/irq.h
99443+++ b/include/linux/irq.h
99444@@ -383,7 +383,10 @@ struct irq_chip {
99445 int (*irq_set_vcpu_affinity)(struct irq_data *data, void *vcpu_info);
99446
99447 unsigned long flags;
99448-};
99449+} __do_const;
99450+#ifndef _LINUX_IRQDOMAIN_H
99451+typedef struct irq_chip __no_const irq_chip_no_const;
99452+#endif
99453
99454 /*
99455 * irq_chip specific flags
99456diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
99457index fcea4e4..cff381d 100644
99458--- a/include/linux/irqdesc.h
99459+++ b/include/linux/irqdesc.h
99460@@ -59,7 +59,7 @@ struct irq_desc {
99461 unsigned int irq_count; /* For detecting broken IRQs */
99462 unsigned long last_unhandled; /* Aging timer for unhandled count */
99463 unsigned int irqs_unhandled;
99464- atomic_t threads_handled;
99465+ atomic_unchecked_t threads_handled;
99466 int threads_handled_last;
99467 raw_spinlock_t lock;
99468 struct cpumask *percpu_enabled;
99469diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
99470index 744ac0e..382b1a6 100644
99471--- a/include/linux/irqdomain.h
99472+++ b/include/linux/irqdomain.h
99473@@ -40,6 +40,9 @@ struct device_node;
99474 struct irq_domain;
99475 struct of_device_id;
99476 struct irq_chip;
99477+#ifndef _LINUX_IRQ_H
99478+typedef struct irq_chip __no_const irq_chip_no_const;
99479+#endif
99480 struct irq_data;
99481
99482 /* Number of irqs reserved for a legacy isa controller */
99483diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
99484index 535fd3b..e5c356e 100644
99485--- a/include/linux/jiffies.h
99486+++ b/include/linux/jiffies.h
99487@@ -284,19 +284,19 @@ extern unsigned long preset_lpj;
99488 extern unsigned int jiffies_to_msecs(const unsigned long j);
99489 extern unsigned int jiffies_to_usecs(const unsigned long j);
99490
99491-static inline u64 jiffies_to_nsecs(const unsigned long j)
99492+static inline u64 __intentional_overflow(-1) jiffies_to_nsecs(const unsigned long j)
99493 {
99494 return (u64)jiffies_to_usecs(j) * NSEC_PER_USEC;
99495 }
99496
99497-extern unsigned long __msecs_to_jiffies(const unsigned int m);
99498+extern unsigned long __msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
99499 #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
99500 /*
99501 * HZ is equal to or smaller than 1000, and 1000 is a nice round
99502 * multiple of HZ, divide with the factor between them, but round
99503 * upwards:
99504 */
99505-static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99506+static inline unsigned long __intentional_overflow(-1) _msecs_to_jiffies(const unsigned int m)
99507 {
99508 return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
99509 }
99510@@ -307,7 +307,7 @@ static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99511 *
99512 * But first make sure the multiplication result cannot overflow:
99513 */
99514-static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99515+static inline unsigned long __intentional_overflow(-1) _msecs_to_jiffies(const unsigned int m)
99516 {
99517 if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
99518 return MAX_JIFFY_OFFSET;
99519@@ -318,7 +318,7 @@ static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99520 * Generic case - multiply, round and divide. But first check that if
99521 * we are doing a net multiplication, that we wouldn't overflow:
99522 */
99523-static inline unsigned long _msecs_to_jiffies(const unsigned int m)
99524+static inline unsigned long __intentional_overflow(-1) _msecs_to_jiffies(const unsigned int m)
99525 {
99526 if (HZ > MSEC_PER_SEC && m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
99527 return MAX_JIFFY_OFFSET;
99528@@ -362,21 +362,19 @@ static inline unsigned long msecs_to_jiffies(const unsigned int m)
99529 }
99530 }
99531
99532-extern unsigned long __usecs_to_jiffies(const unsigned int u);
99533+extern unsigned long __usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
99534 #if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ)
99535-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
99536+static inline unsigned long __intentional_overflow(-1) _usecs_to_jiffies(const unsigned int u)
99537 {
99538 return (u + (USEC_PER_SEC / HZ) - 1) / (USEC_PER_SEC / HZ);
99539 }
99540 #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC)
99541-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
99542+static inline unsigned long __intentional_overflow(-1) _usecs_to_jiffies(const unsigned int u)
99543 {
99544 return u * (HZ / USEC_PER_SEC);
99545 }
99546-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
99547-{
99548 #else
99549-static inline unsigned long _usecs_to_jiffies(const unsigned int u)
99550+static inline unsigned long __intentional_overflow(-1) _usecs_to_jiffies(const unsigned int u)
99551 {
99552 return (USEC_TO_HZ_MUL32 * u + USEC_TO_HZ_ADJ32)
99553 >> USEC_TO_HZ_SHR32;
99554diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
99555index 6883e19..e854fcb 100644
99556--- a/include/linux/kallsyms.h
99557+++ b/include/linux/kallsyms.h
99558@@ -15,7 +15,8 @@
99559
99560 struct module;
99561
99562-#ifdef CONFIG_KALLSYMS
99563+#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
99564+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
99565 /* Lookup the address for a symbol. Returns 0 if not found. */
99566 unsigned long kallsyms_lookup_name(const char *name);
99567
99568@@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
99569 /* Stupid that this does nothing, but I didn't create this mess. */
99570 #define __print_symbol(fmt, addr)
99571 #endif /*CONFIG_KALLSYMS*/
99572+#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
99573+ arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
99574+extern unsigned long kallsyms_lookup_name(const char *name);
99575+extern void __print_symbol(const char *fmt, unsigned long address);
99576+extern int sprint_backtrace(char *buffer, unsigned long address);
99577+extern int sprint_symbol(char *buffer, unsigned long address);
99578+extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
99579+const char *kallsyms_lookup(unsigned long addr,
99580+ unsigned long *symbolsize,
99581+ unsigned long *offset,
99582+ char **modname, char *namebuf);
99583+extern int kallsyms_lookup_size_offset(unsigned long addr,
99584+ unsigned long *symbolsize,
99585+ unsigned long *offset);
99586+#endif
99587
99588 /* This macro allows us to keep printk typechecking */
99589 static __printf(1, 2)
99590diff --git a/include/linux/key-type.h b/include/linux/key-type.h
99591index ff9f1d3..6712be5 100644
99592--- a/include/linux/key-type.h
99593+++ b/include/linux/key-type.h
99594@@ -152,7 +152,7 @@ struct key_type {
99595 /* internal fields */
99596 struct list_head link; /* link in types list */
99597 struct lock_class_key lock_class; /* key->sem lock class */
99598-};
99599+} __do_const;
99600
99601 extern struct key_type key_type_keyring;
99602
99603diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
99604index e465bb1..19f605fd 100644
99605--- a/include/linux/kgdb.h
99606+++ b/include/linux/kgdb.h
99607@@ -52,7 +52,7 @@ extern int kgdb_connected;
99608 extern int kgdb_io_module_registered;
99609
99610 extern atomic_t kgdb_setting_breakpoint;
99611-extern atomic_t kgdb_cpu_doing_single_step;
99612+extern atomic_unchecked_t kgdb_cpu_doing_single_step;
99613
99614 extern struct task_struct *kgdb_usethread;
99615 extern struct task_struct *kgdb_contthread;
99616@@ -254,7 +254,7 @@ struct kgdb_arch {
99617 void (*correct_hw_break)(void);
99618
99619 void (*enable_nmi)(bool on);
99620-};
99621+} __do_const;
99622
99623 /**
99624 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
99625@@ -279,7 +279,7 @@ struct kgdb_io {
99626 void (*pre_exception) (void);
99627 void (*post_exception) (void);
99628 int is_console;
99629-};
99630+} __do_const;
99631
99632 extern struct kgdb_arch arch_kgdb_ops;
99633
99634diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h
99635index d0a1f99..0bd8b7c 100644
99636--- a/include/linux/kmemleak.h
99637+++ b/include/linux/kmemleak.h
99638@@ -27,7 +27,7 @@
99639
99640 extern void kmemleak_init(void) __ref;
99641 extern void kmemleak_alloc(const void *ptr, size_t size, int min_count,
99642- gfp_t gfp) __ref;
99643+ gfp_t gfp) __ref __size_overflow(2);
99644 extern void kmemleak_alloc_percpu(const void __percpu *ptr, size_t size,
99645 gfp_t gfp) __ref;
99646 extern void kmemleak_free(const void *ptr) __ref;
99647@@ -63,7 +63,7 @@ static inline void kmemleak_erase(void **ptr)
99648 static inline void kmemleak_init(void)
99649 {
99650 }
99651-static inline void kmemleak_alloc(const void *ptr, size_t size, int min_count,
99652+static inline void __size_overflow(2) kmemleak_alloc(const void *ptr, size_t size, int min_count,
99653 gfp_t gfp)
99654 {
99655 }
99656diff --git a/include/linux/kmod.h b/include/linux/kmod.h
99657index 0555cc6..40116ce 100644
99658--- a/include/linux/kmod.h
99659+++ b/include/linux/kmod.h
99660@@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
99661 * usually useless though. */
99662 extern __printf(2, 3)
99663 int __request_module(bool wait, const char *name, ...);
99664+extern __printf(3, 4)
99665+int ___request_module(bool wait, char *param_name, const char *name, ...);
99666 #define request_module(mod...) __request_module(true, mod)
99667 #define request_module_nowait(mod...) __request_module(false, mod)
99668 #define try_then_request_module(x, mod...) \
99669@@ -57,6 +59,9 @@ struct subprocess_info {
99670 struct work_struct work;
99671 struct completion *complete;
99672 char *path;
99673+#ifdef CONFIG_GRKERNSEC
99674+ char *origpath;
99675+#endif
99676 char **argv;
99677 char **envp;
99678 int wait;
99679diff --git a/include/linux/kobject.h b/include/linux/kobject.h
99680index 637f670..3d69945 100644
99681--- a/include/linux/kobject.h
99682+++ b/include/linux/kobject.h
99683@@ -119,7 +119,7 @@ struct kobj_type {
99684 struct attribute **default_attrs;
99685 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
99686 const void *(*namespace)(struct kobject *kobj);
99687-};
99688+} __do_const;
99689
99690 struct kobj_uevent_env {
99691 char *argv[3];
99692@@ -143,6 +143,7 @@ struct kobj_attribute {
99693 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
99694 const char *buf, size_t count);
99695 };
99696+typedef struct kobj_attribute __no_const kobj_attribute_no_const;
99697
99698 extern const struct sysfs_ops kobj_sysfs_ops;
99699
99700@@ -170,7 +171,7 @@ struct kset {
99701 spinlock_t list_lock;
99702 struct kobject kobj;
99703 const struct kset_uevent_ops *uevent_ops;
99704-};
99705+} __randomize_layout;
99706
99707 extern void kset_init(struct kset *kset);
99708 extern int __must_check kset_register(struct kset *kset);
99709diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
99710index df32d25..fb52e27 100644
99711--- a/include/linux/kobject_ns.h
99712+++ b/include/linux/kobject_ns.h
99713@@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
99714 const void *(*netlink_ns)(struct sock *sk);
99715 const void *(*initial_ns)(void);
99716 void (*drop_ns)(void *);
99717-};
99718+} __do_const;
99719
99720 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
99721 int kobj_ns_type_registered(enum kobj_ns_type type);
99722diff --git a/include/linux/kref.h b/include/linux/kref.h
99723index 484604d..0f6c5b6 100644
99724--- a/include/linux/kref.h
99725+++ b/include/linux/kref.h
99726@@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
99727 static inline int kref_sub(struct kref *kref, unsigned int count,
99728 void (*release)(struct kref *kref))
99729 {
99730- WARN_ON(release == NULL);
99731+ BUG_ON(release == NULL);
99732
99733 if (atomic_sub_and_test((int) count, &kref->refcount)) {
99734 release(kref);
99735diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
99736index 05e99b8..484b1f97 100644
99737--- a/include/linux/kvm_host.h
99738+++ b/include/linux/kvm_host.h
99739@@ -468,7 +468,7 @@ static inline void kvm_irqfd_exit(void)
99740 {
99741 }
99742 #endif
99743-int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
99744+int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
99745 struct module *module);
99746 void kvm_exit(void);
99747
99748@@ -678,7 +678,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
99749 struct kvm_guest_debug *dbg);
99750 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
99751
99752-int kvm_arch_init(void *opaque);
99753+int kvm_arch_init(const void *opaque);
99754 void kvm_arch_exit(void);
99755
99756 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
99757diff --git a/include/linux/libata.h b/include/linux/libata.h
99758index c9cfbcd..46986db 100644
99759--- a/include/linux/libata.h
99760+++ b/include/linux/libata.h
99761@@ -990,7 +990,7 @@ struct ata_port_operations {
99762 * fields must be pointers.
99763 */
99764 const struct ata_port_operations *inherits;
99765-};
99766+} __do_const;
99767
99768 struct ata_port_info {
99769 unsigned long flags;
99770diff --git a/include/linux/linkage.h b/include/linux/linkage.h
99771index a6a42dd..6c5ebce 100644
99772--- a/include/linux/linkage.h
99773+++ b/include/linux/linkage.h
99774@@ -36,6 +36,7 @@
99775 #endif
99776
99777 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
99778+#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
99779 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
99780
99781 /*
99782diff --git a/include/linux/list.h b/include/linux/list.h
99783index feb773c..98f3075 100644
99784--- a/include/linux/list.h
99785+++ b/include/linux/list.h
99786@@ -113,6 +113,19 @@ extern void __list_del_entry(struct list_head *entry);
99787 extern void list_del(struct list_head *entry);
99788 #endif
99789
99790+extern void __pax_list_add(struct list_head *new,
99791+ struct list_head *prev,
99792+ struct list_head *next);
99793+static inline void pax_list_add(struct list_head *new, struct list_head *head)
99794+{
99795+ __pax_list_add(new, head, head->next);
99796+}
99797+static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
99798+{
99799+ __pax_list_add(new, head->prev, head);
99800+}
99801+extern void pax_list_del(struct list_head *entry);
99802+
99803 /**
99804 * list_replace - replace old entry by new one
99805 * @old : the element to be replaced
99806@@ -146,6 +159,8 @@ static inline void list_del_init(struct list_head *entry)
99807 INIT_LIST_HEAD(entry);
99808 }
99809
99810+extern void pax_list_del_init(struct list_head *entry);
99811+
99812 /**
99813 * list_move - delete from one list and add as another's head
99814 * @list: the entry to move
99815diff --git a/include/linux/lockref.h b/include/linux/lockref.h
99816index b10b122..d37b3de 100644
99817--- a/include/linux/lockref.h
99818+++ b/include/linux/lockref.h
99819@@ -28,7 +28,7 @@ struct lockref {
99820 #endif
99821 struct {
99822 spinlock_t lock;
99823- int count;
99824+ atomic_t count;
99825 };
99826 };
99827 };
99828@@ -43,9 +43,29 @@ extern void lockref_mark_dead(struct lockref *);
99829 extern int lockref_get_not_dead(struct lockref *);
99830
99831 /* Must be called under spinlock for reliable results */
99832-static inline int __lockref_is_dead(const struct lockref *l)
99833+static inline int __lockref_is_dead(const struct lockref *lockref)
99834 {
99835- return ((int)l->count < 0);
99836+ return atomic_read(&lockref->count) < 0;
99837+}
99838+
99839+static inline int __lockref_read(const struct lockref *lockref)
99840+{
99841+ return atomic_read(&lockref->count);
99842+}
99843+
99844+static inline void __lockref_set(struct lockref *lockref, int count)
99845+{
99846+ atomic_set(&lockref->count, count);
99847+}
99848+
99849+static inline void __lockref_inc(struct lockref *lockref)
99850+{
99851+ atomic_inc(&lockref->count);
99852+}
99853+
99854+static inline void __lockref_dec(struct lockref *lockref)
99855+{
99856+ atomic_dec(&lockref->count);
99857 }
99858
99859 #endif /* __LINUX_LOCKREF_H */
99860diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
99861index 9429f05..a5d5425 100644
99862--- a/include/linux/lsm_hooks.h
99863+++ b/include/linux/lsm_hooks.h
99864@@ -1824,7 +1824,7 @@ struct security_hook_heads {
99865 struct list_head audit_rule_match;
99866 struct list_head audit_rule_free;
99867 #endif /* CONFIG_AUDIT */
99868-};
99869+} __randomize_layout;
99870
99871 /*
99872 * Security module hook list structure.
99873@@ -1834,7 +1834,7 @@ struct security_hook_list {
99874 struct list_head list;
99875 struct list_head *head;
99876 union security_list_options hook;
99877-};
99878+} __randomize_layout;
99879
99880 /*
99881 * Initializing a security_hook_list structure takes
99882diff --git a/include/linux/math64.h b/include/linux/math64.h
99883index c45c089..298841c 100644
99884--- a/include/linux/math64.h
99885+++ b/include/linux/math64.h
99886@@ -15,7 +15,7 @@
99887 * This is commonly provided by 32bit archs to provide an optimized 64bit
99888 * divide.
99889 */
99890-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
99891+static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
99892 {
99893 *remainder = dividend % divisor;
99894 return dividend / divisor;
99895@@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
99896 /**
99897 * div64_u64 - unsigned 64bit divide with 64bit divisor
99898 */
99899-static inline u64 div64_u64(u64 dividend, u64 divisor)
99900+static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
99901 {
99902 return dividend / divisor;
99903 }
99904@@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
99905 #define div64_ul(x, y) div_u64((x), (y))
99906
99907 #ifndef div_u64_rem
99908-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
99909+static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
99910 {
99911 *remainder = do_div(dividend, divisor);
99912 return dividend;
99913@@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
99914 #endif
99915
99916 #ifndef div64_u64
99917-extern u64 div64_u64(u64 dividend, u64 divisor);
99918+extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
99919 #endif
99920
99921 #ifndef div64_s64
99922@@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
99923 * divide.
99924 */
99925 #ifndef div_u64
99926-static inline u64 div_u64(u64 dividend, u32 divisor)
99927+static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
99928 {
99929 u32 remainder;
99930 return div_u64_rem(dividend, divisor, &remainder);
99931diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
99932index 3d385c8..deacb6a 100644
99933--- a/include/linux/mempolicy.h
99934+++ b/include/linux/mempolicy.h
99935@@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
99936 }
99937
99938 #define vma_policy(vma) ((vma)->vm_policy)
99939+static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
99940+{
99941+ vma->vm_policy = pol;
99942+}
99943
99944 static inline void mpol_get(struct mempolicy *pol)
99945 {
99946@@ -229,6 +233,9 @@ static inline void mpol_free_shared_policy(struct shared_policy *p)
99947 }
99948
99949 #define vma_policy(vma) NULL
99950+static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
99951+{
99952+}
99953
99954 static inline int
99955 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
99956diff --git a/include/linux/mm.h b/include/linux/mm.h
99957index 2b05068..c58989c 100644
99958--- a/include/linux/mm.h
99959+++ b/include/linux/mm.h
99960@@ -136,6 +136,11 @@ extern unsigned int kobjsize(const void *objp);
99961
99962 #define VM_DONTCOPY 0x00020000 /* Do not copy this vma on fork */
99963 #define VM_DONTEXPAND 0x00040000 /* Cannot expand with mremap() */
99964+
99965+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
99966+#define VM_PAGEEXEC 0x00080000 /* vma->vm_page_prot needs special handling */
99967+#endif
99968+
99969 #define VM_ACCOUNT 0x00100000 /* Is a VM accounted object */
99970 #define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */
99971 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
99972@@ -258,8 +263,8 @@ struct vm_operations_struct {
99973 /* called by access_process_vm when get_user_pages() fails, typically
99974 * for use by special VMAs that can switch between memory and hardware
99975 */
99976- int (*access)(struct vm_area_struct *vma, unsigned long addr,
99977- void *buf, int len, int write);
99978+ ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
99979+ void *buf, size_t len, int write);
99980
99981 /* Called by the /proc/PID/maps code to ask the vma whether it
99982 * has a special name. Returning non-NULL will also cause this
99983@@ -297,6 +302,7 @@ struct vm_operations_struct {
99984 struct page *(*find_special_page)(struct vm_area_struct *vma,
99985 unsigned long addr);
99986 };
99987+typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
99988
99989 struct mmu_gather;
99990 struct inode;
99991@@ -1181,8 +1187,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
99992 unsigned long *pfn);
99993 int follow_phys(struct vm_area_struct *vma, unsigned long address,
99994 unsigned int flags, unsigned long *prot, resource_size_t *phys);
99995-int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
99996- void *buf, int len, int write);
99997+ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
99998+ void *buf, size_t len, int write);
99999
100000 static inline void unmap_shared_mapping_range(struct address_space *mapping,
100001 loff_t const holebegin, loff_t const holelen)
100002@@ -1222,9 +1228,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
100003 }
100004 #endif
100005
100006-extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
100007-extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
100008- void *buf, int len, int write);
100009+extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
100010+extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
100011+ void *buf, size_t len, int write);
100012
100013 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
100014 unsigned long start, unsigned long nr_pages,
100015@@ -1272,34 +1278,6 @@ int clear_page_dirty_for_io(struct page *page);
100016
100017 int get_cmdline(struct task_struct *task, char *buffer, int buflen);
100018
100019-/* Is the vma a continuation of the stack vma above it? */
100020-static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
100021-{
100022- return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
100023-}
100024-
100025-static inline int stack_guard_page_start(struct vm_area_struct *vma,
100026- unsigned long addr)
100027-{
100028- return (vma->vm_flags & VM_GROWSDOWN) &&
100029- (vma->vm_start == addr) &&
100030- !vma_growsdown(vma->vm_prev, addr);
100031-}
100032-
100033-/* Is the vma a continuation of the stack vma below it? */
100034-static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
100035-{
100036- return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
100037-}
100038-
100039-static inline int stack_guard_page_end(struct vm_area_struct *vma,
100040- unsigned long addr)
100041-{
100042- return (vma->vm_flags & VM_GROWSUP) &&
100043- (vma->vm_end == addr) &&
100044- !vma_growsup(vma->vm_next, addr);
100045-}
100046-
100047 extern struct task_struct *task_of_stack(struct task_struct *task,
100048 struct vm_area_struct *vma, bool in_group);
100049
100050@@ -1422,8 +1400,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
100051 {
100052 return 0;
100053 }
100054+
100055+static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
100056+ unsigned long address)
100057+{
100058+ return 0;
100059+}
100060 #else
100061 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
100062+int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
100063 #endif
100064
100065 #if defined(__PAGETABLE_PMD_FOLDED) || !defined(CONFIG_MMU)
100066@@ -1433,6 +1418,12 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
100067 return 0;
100068 }
100069
100070+static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
100071+ unsigned long address)
100072+{
100073+ return 0;
100074+}
100075+
100076 static inline void mm_nr_pmds_init(struct mm_struct *mm) {}
100077
100078 static inline unsigned long mm_nr_pmds(struct mm_struct *mm)
100079@@ -1445,6 +1436,7 @@ static inline void mm_dec_nr_pmds(struct mm_struct *mm) {}
100080
100081 #else
100082 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
100083+int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
100084
100085 static inline void mm_nr_pmds_init(struct mm_struct *mm)
100086 {
100087@@ -1482,11 +1474,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
100088 NULL: pud_offset(pgd, address);
100089 }
100090
100091+static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
100092+{
100093+ return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
100094+ NULL: pud_offset(pgd, address);
100095+}
100096+
100097 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
100098 {
100099 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
100100 NULL: pmd_offset(pud, address);
100101 }
100102+
100103+static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
100104+{
100105+ return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
100106+ NULL: pmd_offset(pud, address);
100107+}
100108 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
100109
100110 #if USE_SPLIT_PTE_PTLOCKS
100111@@ -1867,12 +1871,23 @@ extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
100112 bool *need_rmap_locks);
100113 extern void exit_mmap(struct mm_struct *);
100114
100115+#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
100116+extern void gr_learn_resource(const struct task_struct *task, const int res,
100117+ const unsigned long wanted, const int gt);
100118+#else
100119+static inline void gr_learn_resource(const struct task_struct *task, const int res,
100120+ const unsigned long wanted, const int gt)
100121+{
100122+}
100123+#endif
100124+
100125 static inline int check_data_rlimit(unsigned long rlim,
100126 unsigned long new,
100127 unsigned long start,
100128 unsigned long end_data,
100129 unsigned long start_data)
100130 {
100131+ gr_learn_resource(current, RLIMIT_DATA, (new - start) + (end_data - start_data), 1);
100132 if (rlim < RLIM_INFINITY) {
100133 if (((new - start) + (end_data - start_data)) > rlim)
100134 return -ENOSPC;
100135@@ -1905,6 +1920,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
100136 unsigned long len, unsigned long prot, unsigned long flags,
100137 unsigned long pgoff, unsigned long *populate);
100138 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
100139+extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
100140
100141 #ifdef CONFIG_MMU
100142 extern int __mm_populate(unsigned long addr, unsigned long len,
100143@@ -1933,10 +1949,11 @@ struct vm_unmapped_area_info {
100144 unsigned long high_limit;
100145 unsigned long align_mask;
100146 unsigned long align_offset;
100147+ unsigned long threadstack_offset;
100148 };
100149
100150-extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
100151-extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
100152+extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
100153+extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
100154
100155 /*
100156 * Search for an unmapped address range.
100157@@ -1948,7 +1965,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
100158 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
100159 */
100160 static inline unsigned long
100161-vm_unmapped_area(struct vm_unmapped_area_info *info)
100162+vm_unmapped_area(const struct vm_unmapped_area_info *info)
100163 {
100164 if (info->flags & VM_UNMAPPED_AREA_TOPDOWN)
100165 return unmapped_area_topdown(info);
100166@@ -2010,6 +2027,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
100167 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
100168 struct vm_area_struct **pprev);
100169
100170+extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
100171+extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
100172+extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
100173+
100174 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
100175 NULL if none. Assume start_addr < end_addr. */
100176 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
100177@@ -2039,10 +2060,10 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
100178 }
100179
100180 #ifdef CONFIG_MMU
100181-pgprot_t vm_get_page_prot(unsigned long vm_flags);
100182+pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
100183 void vma_set_page_prot(struct vm_area_struct *vma);
100184 #else
100185-static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
100186+static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
100187 {
100188 return __pgprot(0);
100189 }
100190@@ -2104,6 +2125,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
100191 static inline void vm_stat_account(struct mm_struct *mm,
100192 unsigned long flags, struct file *file, long pages)
100193 {
100194+
100195+#ifdef CONFIG_PAX_RANDMMAP
100196+ if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
100197+#endif
100198+
100199 mm->total_vm += pages;
100200 }
100201 #endif /* CONFIG_PROC_FS */
100202@@ -2207,7 +2233,7 @@ extern int get_hwpoison_page(struct page *page);
100203 extern int sysctl_memory_failure_early_kill;
100204 extern int sysctl_memory_failure_recovery;
100205 extern void shake_page(struct page *p, int access);
100206-extern atomic_long_t num_poisoned_pages;
100207+extern atomic_long_unchecked_t num_poisoned_pages;
100208 extern int soft_offline_page(struct page *page, int flags);
100209
100210
100211@@ -2292,5 +2318,11 @@ void __init setup_nr_node_ids(void);
100212 static inline void setup_nr_node_ids(void) {}
100213 #endif
100214
100215+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
100216+extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
100217+#else
100218+static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
100219+#endif
100220+
100221 #endif /* __KERNEL__ */
100222 #endif /* _LINUX_MM_H */
100223diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
100224index 1554957..0973bc5 100644
100225--- a/include/linux/mm_types.h
100226+++ b/include/linux/mm_types.h
100227@@ -322,7 +322,9 @@ struct vm_area_struct {
100228 #ifdef CONFIG_NUMA
100229 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
100230 #endif
100231-};
100232+
100233+ struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
100234+} __randomize_layout;
100235
100236 struct core_thread {
100237 struct task_struct *task;
100238@@ -475,7 +477,25 @@ struct mm_struct {
100239 /* address of the bounds directory */
100240 void __user *bd_addr;
100241 #endif
100242-};
100243+
100244+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
100245+ unsigned long pax_flags;
100246+#endif
100247+
100248+#ifdef CONFIG_PAX_DLRESOLVE
100249+ unsigned long call_dl_resolve;
100250+#endif
100251+
100252+#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
100253+ unsigned long call_syscall;
100254+#endif
100255+
100256+#ifdef CONFIG_PAX_ASLR
100257+ unsigned long delta_mmap; /* randomized offset */
100258+ unsigned long delta_stack; /* randomized offset */
100259+#endif
100260+
100261+} __randomize_layout;
100262
100263 static inline void mm_init_cpumask(struct mm_struct *mm)
100264 {
100265diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
100266index 3ba327a..85cd5ce 100644
100267--- a/include/linux/mmiotrace.h
100268+++ b/include/linux/mmiotrace.h
100269@@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
100270 /* Called from ioremap.c */
100271 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
100272 void __iomem *addr);
100273-extern void mmiotrace_iounmap(volatile void __iomem *addr);
100274+extern void mmiotrace_iounmap(const volatile void __iomem *addr);
100275
100276 /* For anyone to insert markers. Remember trailing newline. */
100277 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
100278@@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
100279 {
100280 }
100281
100282-static inline void mmiotrace_iounmap(volatile void __iomem *addr)
100283+static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
100284 {
100285 }
100286
100287diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
100288index 754c259..7b65ac6 100644
100289--- a/include/linux/mmzone.h
100290+++ b/include/linux/mmzone.h
100291@@ -526,7 +526,7 @@ struct zone {
100292
100293 ZONE_PADDING(_pad3_)
100294 /* Zone statistics */
100295- atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
100296+ atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
100297 } ____cacheline_internodealigned_in_smp;
100298
100299 enum zone_flags {
100300diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
100301index 34f25b7..0586069 100644
100302--- a/include/linux/mod_devicetable.h
100303+++ b/include/linux/mod_devicetable.h
100304@@ -139,7 +139,7 @@ struct usb_device_id {
100305 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
100306 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
100307
100308-#define HID_ANY_ID (~0)
100309+#define HID_ANY_ID (~0U)
100310 #define HID_BUS_ANY 0xffff
100311 #define HID_GROUP_ANY 0x0000
100312
100313@@ -472,7 +472,7 @@ struct dmi_system_id {
100314 const char *ident;
100315 struct dmi_strmatch matches[4];
100316 void *driver_data;
100317-};
100318+} __do_const;
100319 /*
100320 * struct dmi_device_id appears during expansion of
100321 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
100322diff --git a/include/linux/module.h b/include/linux/module.h
100323index 3a19c79..dea8c47 100644
100324--- a/include/linux/module.h
100325+++ b/include/linux/module.h
100326@@ -19,9 +19,11 @@
100327 #include <linux/jump_label.h>
100328 #include <linux/export.h>
100329 #include <linux/rbtree_latch.h>
100330+#include <linux/fs.h>
100331
100332 #include <linux/percpu.h>
100333 #include <asm/module.h>
100334+#include <asm/pgtable.h>
100335
100336 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
100337 #define MODULE_SIG_STRING "~Module signature appended~\n"
100338@@ -44,7 +46,7 @@ struct module_kobject {
100339 struct kobject *drivers_dir;
100340 struct module_param_attrs *mp;
100341 struct completion *kobj_completion;
100342-};
100343+} __randomize_layout;
100344
100345 struct module_attribute {
100346 struct attribute attr;
100347@@ -56,12 +58,13 @@ struct module_attribute {
100348 int (*test)(struct module *);
100349 void (*free)(struct module *);
100350 };
100351+typedef struct module_attribute __no_const module_attribute_no_const;
100352
100353 struct module_version_attribute {
100354 struct module_attribute mattr;
100355 const char *module_name;
100356 const char *version;
100357-} __attribute__ ((__aligned__(sizeof(void *))));
100358+} __do_const __attribute__ ((__aligned__(sizeof(void *))));
100359
100360 extern ssize_t __modver_version_show(struct module_attribute *,
100361 struct module_kobject *, char *);
100362@@ -313,7 +316,7 @@ struct module {
100363
100364 /* Sysfs stuff. */
100365 struct module_kobject mkobj;
100366- struct module_attribute *modinfo_attrs;
100367+ module_attribute_no_const *modinfo_attrs;
100368 const char *version;
100369 const char *srcversion;
100370 struct kobject *holders_dir;
100371@@ -370,20 +373,21 @@ struct module {
100372 * If this is non-NULL, vfree() after init() returns.
100373 *
100374 * Cacheline align here, such that:
100375- * module_init, module_core, init_size, core_size,
100376+ * module_init_*, module_core_*, init_size_*, core_size_*,
100377 * init_text_size, core_text_size and mtn_core::{mod,node[0]}
100378 * are on the same cacheline.
100379 */
100380- void *module_init ____cacheline_aligned;
100381+ void *module_init_rw ____cacheline_aligned;
100382+ void *module_init_rx;
100383
100384 /* Here is the actual code + data, vfree'd on unload. */
100385- void *module_core;
100386+ void *module_core_rx, *module_core_rw;
100387
100388 /* Here are the sizes of the init and core sections */
100389- unsigned int init_size, core_size;
100390+ unsigned int init_size_rw, core_size_rw;
100391
100392 /* The size of the executable code in each section. */
100393- unsigned int init_text_size, core_text_size;
100394+ unsigned int init_size_rx, core_size_rx;
100395
100396 #ifdef CONFIG_MODULES_TREE_LOOKUP
100397 /*
100398@@ -391,13 +395,12 @@ struct module {
100399 * above entries such that a regular lookup will only touch one
100400 * cacheline.
100401 */
100402- struct mod_tree_node mtn_core;
100403- struct mod_tree_node mtn_init;
100404+ struct mod_tree_node mtn_core_rw;
100405+ struct mod_tree_node mtn_core_rx;
100406+ struct mod_tree_node mtn_init_rw;
100407+ struct mod_tree_node mtn_init_rx;
100408 #endif
100409
100410- /* Size of RO sections of the module (text+rodata) */
100411- unsigned int init_ro_size, core_ro_size;
100412-
100413 /* Arch-specific module values */
100414 struct mod_arch_specific arch;
100415
100416@@ -454,6 +457,10 @@ struct module {
100417 unsigned int num_trace_events;
100418 struct trace_enum_map **trace_enums;
100419 unsigned int num_trace_enums;
100420+ struct file_operations trace_id;
100421+ struct file_operations trace_enable;
100422+ struct file_operations trace_format;
100423+ struct file_operations trace_filter;
100424 #endif
100425 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
100426 unsigned int num_ftrace_callsites;
100427@@ -481,7 +488,8 @@ struct module {
100428 ctor_fn_t *ctors;
100429 unsigned int num_ctors;
100430 #endif
100431-} ____cacheline_aligned;
100432+} ____cacheline_aligned __randomize_layout;
100433+
100434 #ifndef MODULE_ARCH_INIT
100435 #define MODULE_ARCH_INIT {}
100436 #endif
100437@@ -502,18 +510,48 @@ bool is_module_address(unsigned long addr);
100438 bool is_module_percpu_address(unsigned long addr);
100439 bool is_module_text_address(unsigned long addr);
100440
100441+static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
100442+{
100443+
100444+#ifdef CONFIG_PAX_KERNEXEC
100445+ if (ktla_ktva(addr) >= (unsigned long)start &&
100446+ ktla_ktva(addr) < (unsigned long)start + size)
100447+ return 1;
100448+#endif
100449+
100450+ return ((void *)addr >= start && (void *)addr < start + size);
100451+}
100452+
100453+static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
100454+{
100455+ return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
100456+}
100457+
100458+static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
100459+{
100460+ return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
100461+}
100462+
100463+static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
100464+{
100465+ return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
100466+}
100467+
100468+static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
100469+{
100470+ return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
100471+}
100472+
100473 static inline bool within_module_core(unsigned long addr,
100474 const struct module *mod)
100475 {
100476- return (unsigned long)mod->module_core <= addr &&
100477- addr < (unsigned long)mod->module_core + mod->core_size;
100478+ return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
100479 }
100480
100481 static inline bool within_module_init(unsigned long addr,
100482 const struct module *mod)
100483 {
100484- return (unsigned long)mod->module_init <= addr &&
100485- addr < (unsigned long)mod->module_init + mod->init_size;
100486+ return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
100487 }
100488
100489 static inline bool within_module(unsigned long addr, const struct module *mod)
100490diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
100491index 4d0cb9b..3169ac7 100644
100492--- a/include/linux/moduleloader.h
100493+++ b/include/linux/moduleloader.h
100494@@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
100495 sections. Returns NULL on failure. */
100496 void *module_alloc(unsigned long size);
100497
100498+#ifdef CONFIG_PAX_KERNEXEC
100499+void *module_alloc_exec(unsigned long size);
100500+#else
100501+#define module_alloc_exec(x) module_alloc(x)
100502+#endif
100503+
100504 /* Free memory returned from module_alloc. */
100505 void module_memfree(void *module_region);
100506
100507+#ifdef CONFIG_PAX_KERNEXEC
100508+void module_memfree_exec(void *module_region);
100509+#else
100510+#define module_memfree_exec(x) module_memfree((x))
100511+#endif
100512+
100513 /*
100514 * Apply the given relocation to the (simplified) ELF. Return -error
100515 * or 0.
100516@@ -45,8 +57,10 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
100517 unsigned int relsec,
100518 struct module *me)
100519 {
100520+#ifdef CONFIG_MODULES
100521 printk(KERN_ERR "module %s: REL relocation unsupported\n",
100522 module_name(me));
100523+#endif
100524 return -ENOEXEC;
100525 }
100526 #endif
100527@@ -68,8 +82,10 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
100528 unsigned int relsec,
100529 struct module *me)
100530 {
100531+#ifdef CONFIG_MODULES
100532 printk(KERN_ERR "module %s: REL relocation unsupported\n",
100533 module_name(me));
100534+#endif
100535 return -ENOEXEC;
100536 }
100537 #endif
100538diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
100539index c12f214..3ef907f 100644
100540--- a/include/linux/moduleparam.h
100541+++ b/include/linux/moduleparam.h
100542@@ -289,7 +289,7 @@ static inline void kernel_param_unlock(struct module *mod)
100543 * @len is usually just sizeof(string).
100544 */
100545 #define module_param_string(name, string, len, perm) \
100546- static const struct kparam_string __param_string_##name \
100547+ static const struct kparam_string __param_string_##name __used \
100548 = { len, string }; \
100549 __module_param_call(MODULE_PARAM_PREFIX, name, \
100550 &param_ops_string, \
100551@@ -440,7 +440,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
100552 */
100553 #define module_param_array_named(name, array, type, nump, perm) \
100554 param_check_##type(name, &(array)[0]); \
100555- static const struct kparam_array __param_arr_##name \
100556+ static const struct kparam_array __param_arr_##name __used \
100557 = { .max = ARRAY_SIZE(array), .num = nump, \
100558 .ops = &param_ops_##type, \
100559 .elemsize = sizeof(array[0]), .elem = array }; \
100560diff --git a/include/linux/mount.h b/include/linux/mount.h
100561index f822c3c..958ca0a 100644
100562--- a/include/linux/mount.h
100563+++ b/include/linux/mount.h
100564@@ -67,7 +67,7 @@ struct vfsmount {
100565 struct dentry *mnt_root; /* root of the mounted tree */
100566 struct super_block *mnt_sb; /* pointer to superblock */
100567 int mnt_flags;
100568-};
100569+} __randomize_layout;
100570
100571 struct file; /* forward dec */
100572 struct path;
100573diff --git a/include/linux/net.h b/include/linux/net.h
100574index 04aa068..8a24df5 100644
100575--- a/include/linux/net.h
100576+++ b/include/linux/net.h
100577@@ -189,7 +189,7 @@ struct net_proto_family {
100578 int (*create)(struct net *net, struct socket *sock,
100579 int protocol, int kern);
100580 struct module *owner;
100581-};
100582+} __do_const;
100583
100584 struct iovec;
100585 struct kvec;
100586diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
100587index e20979d..3c7827b 100644
100588--- a/include/linux/netdevice.h
100589+++ b/include/linux/netdevice.h
100590@@ -1212,6 +1212,7 @@ struct net_device_ops {
100591 u32 maxrate);
100592 int (*ndo_get_iflink)(const struct net_device *dev);
100593 };
100594+typedef struct net_device_ops __no_const net_device_ops_no_const;
100595
100596 /**
100597 * enum net_device_priv_flags - &struct net_device priv_flags
100598@@ -1519,7 +1520,7 @@ struct net_device {
100599 unsigned long base_addr;
100600 int irq;
100601
100602- atomic_t carrier_changes;
100603+ atomic_unchecked_t carrier_changes;
100604
100605 /*
100606 * Some hardware also needs these fields (state,dev_list,
100607@@ -1558,8 +1559,8 @@ struct net_device {
100608
100609 struct net_device_stats stats;
100610
100611- atomic_long_t rx_dropped;
100612- atomic_long_t tx_dropped;
100613+ atomic_long_unchecked_t rx_dropped;
100614+ atomic_long_unchecked_t tx_dropped;
100615
100616 #ifdef CONFIG_WIRELESS_EXT
100617 const struct iw_handler_def * wireless_handlers;
100618diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
100619index 00050df..0bc7081 100644
100620--- a/include/linux/netfilter.h
100621+++ b/include/linux/netfilter.h
100622@@ -115,7 +115,7 @@ struct nf_sockopt_ops {
100623 #endif
100624 /* Use the module struct to lock set/get code in place */
100625 struct module *owner;
100626-};
100627+} __do_const;
100628
100629 /* Function to register/unregister hook points. */
100630 int nf_register_hook(struct nf_hook_ops *reg);
100631diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
100632index e955d47..04a5338 100644
100633--- a/include/linux/netfilter/nfnetlink.h
100634+++ b/include/linux/netfilter/nfnetlink.h
100635@@ -19,7 +19,7 @@ struct nfnl_callback {
100636 const struct nlattr * const cda[]);
100637 const struct nla_policy *policy; /* netlink attribute policy */
100638 const u_int16_t attr_count; /* number of nlattr's */
100639-};
100640+} __do_const;
100641
100642 struct nfnetlink_subsystem {
100643 const char *name;
100644diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
100645new file mode 100644
100646index 0000000..33f4af8
100647--- /dev/null
100648+++ b/include/linux/netfilter/xt_gradm.h
100649@@ -0,0 +1,9 @@
100650+#ifndef _LINUX_NETFILTER_XT_GRADM_H
100651+#define _LINUX_NETFILTER_XT_GRADM_H 1
100652+
100653+struct xt_gradm_mtinfo {
100654+ __u16 flags;
100655+ __u16 invflags;
100656+};
100657+
100658+#endif
100659diff --git a/include/linux/nls.h b/include/linux/nls.h
100660index 520681b..2b7fabb 100644
100661--- a/include/linux/nls.h
100662+++ b/include/linux/nls.h
100663@@ -31,7 +31,7 @@ struct nls_table {
100664 const unsigned char *charset2upper;
100665 struct module *owner;
100666 struct nls_table *next;
100667-};
100668+} __do_const;
100669
100670 /* this value hold the maximum octet of charset */
100671 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
100672@@ -46,7 +46,7 @@ enum utf16_endian {
100673 /* nls_base.c */
100674 extern int __register_nls(struct nls_table *, struct module *);
100675 extern int unregister_nls(struct nls_table *);
100676-extern struct nls_table *load_nls(char *);
100677+extern struct nls_table *load_nls(const char *);
100678 extern void unload_nls(struct nls_table *);
100679 extern struct nls_table *load_nls_default(void);
100680 #define register_nls(nls) __register_nls((nls), THIS_MODULE)
100681diff --git a/include/linux/notifier.h b/include/linux/notifier.h
100682index d14a4c3..a078786 100644
100683--- a/include/linux/notifier.h
100684+++ b/include/linux/notifier.h
100685@@ -54,7 +54,8 @@ struct notifier_block {
100686 notifier_fn_t notifier_call;
100687 struct notifier_block __rcu *next;
100688 int priority;
100689-};
100690+} __do_const;
100691+typedef struct notifier_block __no_const notifier_block_no_const;
100692
100693 struct atomic_notifier_head {
100694 spinlock_t lock;
100695diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
100696index b2a0f15..4d7da32 100644
100697--- a/include/linux/oprofile.h
100698+++ b/include/linux/oprofile.h
100699@@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
100700 int oprofilefs_create_ro_ulong(struct dentry * root,
100701 char const * name, ulong * val);
100702
100703-/** Create a file for read-only access to an atomic_t. */
100704+/** Create a file for read-only access to an atomic_unchecked_t. */
100705 int oprofilefs_create_ro_atomic(struct dentry * root,
100706- char const * name, atomic_t * val);
100707+ char const * name, atomic_unchecked_t * val);
100708
100709 /** create a directory */
100710 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
100711diff --git a/include/linux/overflow-arith.h b/include/linux/overflow-arith.h
100712new file mode 100644
100713index 0000000..e12ccf8
100714--- /dev/null
100715+++ b/include/linux/overflow-arith.h
100716@@ -0,0 +1,18 @@
100717+#pragma once
100718+
100719+#include <linux/kernel.h>
100720+
100721+#ifdef CC_HAVE_BUILTIN_OVERFLOW
100722+
100723+#define overflow_usub __builtin_usub_overflow
100724+
100725+#else
100726+
100727+static inline bool overflow_usub(unsigned int a, unsigned int b,
100728+ unsigned int *res)
100729+{
100730+ *res = a - b;
100731+ return *res > a ? true : false;
100732+}
100733+
100734+#endif
100735diff --git a/include/linux/padata.h b/include/linux/padata.h
100736index 4386946..f50c615 100644
100737--- a/include/linux/padata.h
100738+++ b/include/linux/padata.h
100739@@ -129,7 +129,7 @@ struct parallel_data {
100740 struct padata_serial_queue __percpu *squeue;
100741 atomic_t reorder_objects;
100742 atomic_t refcnt;
100743- atomic_t seq_nr;
100744+ atomic_unchecked_t seq_nr;
100745 struct padata_cpumask cpumask;
100746 spinlock_t lock ____cacheline_aligned;
100747 unsigned int processed;
100748diff --git a/include/linux/path.h b/include/linux/path.h
100749index d137218..be0c176 100644
100750--- a/include/linux/path.h
100751+++ b/include/linux/path.h
100752@@ -1,13 +1,15 @@
100753 #ifndef _LINUX_PATH_H
100754 #define _LINUX_PATH_H
100755
100756+#include <linux/compiler.h>
100757+
100758 struct dentry;
100759 struct vfsmount;
100760
100761 struct path {
100762 struct vfsmount *mnt;
100763 struct dentry *dentry;
100764-};
100765+} __randomize_layout;
100766
100767 extern void path_get(const struct path *);
100768 extern void path_put(const struct path *);
100769diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
100770index 8c78950..0d74ed9 100644
100771--- a/include/linux/pci_hotplug.h
100772+++ b/include/linux/pci_hotplug.h
100773@@ -71,7 +71,8 @@ struct hotplug_slot_ops {
100774 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
100775 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
100776 int (*reset_slot) (struct hotplug_slot *slot, int probe);
100777-};
100778+} __do_const;
100779+typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
100780
100781 /**
100782 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
100783diff --git a/include/linux/percpu.h b/include/linux/percpu.h
100784index caebf2a..4c3ae9d 100644
100785--- a/include/linux/percpu.h
100786+++ b/include/linux/percpu.h
100787@@ -34,7 +34,7 @@
100788 * preallocate for this. Keep PERCPU_DYNAMIC_RESERVE equal to or
100789 * larger than PERCPU_DYNAMIC_EARLY_SIZE.
100790 */
100791-#define PERCPU_DYNAMIC_EARLY_SLOTS 128
100792+#define PERCPU_DYNAMIC_EARLY_SLOTS 256
100793 #define PERCPU_DYNAMIC_EARLY_SIZE (12 << 10)
100794
100795 /*
100796diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
100797index 2027809..c9cd38e 100644
100798--- a/include/linux/perf_event.h
100799+++ b/include/linux/perf_event.h
100800@@ -384,8 +384,8 @@ struct perf_event {
100801
100802 enum perf_event_active_state state;
100803 unsigned int attach_state;
100804- local64_t count;
100805- atomic64_t child_count;
100806+ local64_t count; /* PaX: fix it one day */
100807+ atomic64_unchecked_t child_count;
100808
100809 /*
100810 * These are the total time in nanoseconds that the event
100811@@ -436,8 +436,8 @@ struct perf_event {
100812 * These accumulate total time (in nanoseconds) that children
100813 * events have been enabled and running, respectively.
100814 */
100815- atomic64_t child_total_time_enabled;
100816- atomic64_t child_total_time_running;
100817+ atomic64_unchecked_t child_total_time_enabled;
100818+ atomic64_unchecked_t child_total_time_running;
100819
100820 /*
100821 * Protect attach/detach and child_list:
100822@@ -859,7 +859,7 @@ static inline void perf_event_task_sched_out(struct task_struct *prev,
100823
100824 static inline u64 __perf_event_count(struct perf_event *event)
100825 {
100826- return local64_read(&event->count) + atomic64_read(&event->child_count);
100827+ return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
100828 }
100829
100830 extern void perf_event_mmap(struct vm_area_struct *vma);
100831@@ -883,7 +883,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
100832 entry->ip[entry->nr++] = ip;
100833 }
100834
100835-extern int sysctl_perf_event_paranoid;
100836+extern int sysctl_perf_event_legitimately_concerned;
100837 extern int sysctl_perf_event_mlock;
100838 extern int sysctl_perf_event_sample_rate;
100839 extern int sysctl_perf_cpu_time_max_percent;
100840@@ -898,19 +898,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
100841 loff_t *ppos);
100842
100843
100844+static inline bool perf_paranoid_any(void)
100845+{
100846+ return sysctl_perf_event_legitimately_concerned > 2;
100847+}
100848+
100849 static inline bool perf_paranoid_tracepoint_raw(void)
100850 {
100851- return sysctl_perf_event_paranoid > -1;
100852+ return sysctl_perf_event_legitimately_concerned > -1;
100853 }
100854
100855 static inline bool perf_paranoid_cpu(void)
100856 {
100857- return sysctl_perf_event_paranoid > 0;
100858+ return sysctl_perf_event_legitimately_concerned > 0;
100859 }
100860
100861 static inline bool perf_paranoid_kernel(void)
100862 {
100863- return sysctl_perf_event_paranoid > 1;
100864+ return sysctl_perf_event_legitimately_concerned > 1;
100865 }
100866
100867 extern void perf_event_init(void);
100868@@ -1066,7 +1071,7 @@ struct perf_pmu_events_attr {
100869 struct device_attribute attr;
100870 u64 id;
100871 const char *event_str;
100872-};
100873+} __do_const;
100874
100875 ssize_t perf_event_sysfs_show(struct device *dev, struct device_attribute *attr,
100876 char *page);
100877diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
100878index 918b117..7af374b7 100644
100879--- a/include/linux/pid_namespace.h
100880+++ b/include/linux/pid_namespace.h
100881@@ -45,7 +45,7 @@ struct pid_namespace {
100882 int hide_pid;
100883 int reboot; /* group exit code if this pidns was rebooted */
100884 struct ns_common ns;
100885-};
100886+} __randomize_layout;
100887
100888 extern struct pid_namespace init_pid_ns;
100889
100890diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
100891index eb8b8ac..62649e1 100644
100892--- a/include/linux/pipe_fs_i.h
100893+++ b/include/linux/pipe_fs_i.h
100894@@ -47,10 +47,10 @@ struct pipe_inode_info {
100895 struct mutex mutex;
100896 wait_queue_head_t wait;
100897 unsigned int nrbufs, curbuf, buffers;
100898- unsigned int readers;
100899- unsigned int writers;
100900- unsigned int files;
100901- unsigned int waiting_writers;
100902+ atomic_t readers;
100903+ atomic_t writers;
100904+ atomic_t files;
100905+ atomic_t waiting_writers;
100906 unsigned int r_counter;
100907 unsigned int w_counter;
100908 struct page *tmp_page;
100909diff --git a/include/linux/pm.h b/include/linux/pm.h
100910index 35d599e..c604209 100644
100911--- a/include/linux/pm.h
100912+++ b/include/linux/pm.h
100913@@ -630,6 +630,7 @@ struct dev_pm_domain {
100914 void (*sync)(struct device *dev);
100915 void (*dismiss)(struct device *dev);
100916 };
100917+typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
100918
100919 /*
100920 * The PM_EVENT_ messages are also used by drivers implementing the legacy
100921diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
100922index 681ccb0..a90e0b7 100644
100923--- a/include/linux/pm_domain.h
100924+++ b/include/linux/pm_domain.h
100925@@ -39,11 +39,11 @@ struct gpd_dev_ops {
100926 int (*save_state)(struct device *dev);
100927 int (*restore_state)(struct device *dev);
100928 bool (*active_wakeup)(struct device *dev);
100929-};
100930+} __no_const;
100931
100932 struct gpd_cpuidle_data {
100933 unsigned int saved_exit_latency;
100934- struct cpuidle_state *idle_state;
100935+ cpuidle_state_no_const *idle_state;
100936 };
100937
100938 struct generic_pm_domain {
100939diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
100940index 30e84d4..22278b4 100644
100941--- a/include/linux/pm_runtime.h
100942+++ b/include/linux/pm_runtime.h
100943@@ -115,7 +115,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
100944
100945 static inline void pm_runtime_mark_last_busy(struct device *dev)
100946 {
100947- ACCESS_ONCE(dev->power.last_busy) = jiffies;
100948+ ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
100949 }
100950
100951 static inline bool pm_runtime_is_irq_safe(struct device *dev)
100952diff --git a/include/linux/pnp.h b/include/linux/pnp.h
100953index 5df733b..d55f252 100644
100954--- a/include/linux/pnp.h
100955+++ b/include/linux/pnp.h
100956@@ -298,7 +298,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
100957 struct pnp_fixup {
100958 char id[7];
100959 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
100960-};
100961+} __do_const;
100962
100963 /* config parameters */
100964 #define PNP_CONFIG_NORMAL 0x0001
100965diff --git a/include/linux/poison.h b/include/linux/poison.h
100966index 2110a81..13a11bb 100644
100967--- a/include/linux/poison.h
100968+++ b/include/linux/poison.h
100969@@ -19,8 +19,8 @@
100970 * under normal circumstances, used to verify that nobody uses
100971 * non-initialized list entries.
100972 */
100973-#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
100974-#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
100975+#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
100976+#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
100977
100978 /********** include/linux/timer.h **********/
100979 /*
100980diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
100981index d8b187c3..9a9257a 100644
100982--- a/include/linux/power/smartreflex.h
100983+++ b/include/linux/power/smartreflex.h
100984@@ -238,7 +238,7 @@ struct omap_sr_class_data {
100985 int (*notify)(struct omap_sr *sr, u32 status);
100986 u8 notify_flags;
100987 u8 class_type;
100988-};
100989+} __do_const;
100990
100991 /**
100992 * struct omap_sr_nvalue_table - Smartreflex n-target value info
100993diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
100994index 4ea1d37..80f4b33 100644
100995--- a/include/linux/ppp-comp.h
100996+++ b/include/linux/ppp-comp.h
100997@@ -84,7 +84,7 @@ struct compressor {
100998 struct module *owner;
100999 /* Extra skb space needed by the compressor algorithm */
101000 unsigned int comp_extra;
101001-};
101002+} __do_const;
101003
101004 /*
101005 * The return value from decompress routine is the length of the
101006diff --git a/include/linux/preempt.h b/include/linux/preempt.h
101007index bea8dd8..534a23d 100644
101008--- a/include/linux/preempt.h
101009+++ b/include/linux/preempt.h
101010@@ -140,11 +140,16 @@ extern void preempt_count_sub(int val);
101011 #define preempt_count_dec_and_test() __preempt_count_dec_and_test()
101012 #endif
101013
101014+#define raw_preempt_count_add(val) __preempt_count_add(val)
101015+#define raw_preempt_count_sub(val) __preempt_count_sub(val)
101016+
101017 #define __preempt_count_inc() __preempt_count_add(1)
101018 #define __preempt_count_dec() __preempt_count_sub(1)
101019
101020 #define preempt_count_inc() preempt_count_add(1)
101021+#define raw_preempt_count_inc() raw_preempt_count_add(1)
101022 #define preempt_count_dec() preempt_count_sub(1)
101023+#define raw_preempt_count_dec() raw_preempt_count_sub(1)
101024
101025 #define preempt_active_enter() \
101026 do { \
101027@@ -166,6 +171,12 @@ do { \
101028 barrier(); \
101029 } while (0)
101030
101031+#define raw_preempt_disable() \
101032+do { \
101033+ raw_preempt_count_inc(); \
101034+ barrier(); \
101035+} while (0)
101036+
101037 #define sched_preempt_enable_no_resched() \
101038 do { \
101039 barrier(); \
101040@@ -174,6 +185,12 @@ do { \
101041
101042 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
101043
101044+#define raw_preempt_enable_no_resched() \
101045+do { \
101046+ barrier(); \
101047+ raw_preempt_count_dec(); \
101048+} while (0)
101049+
101050 #define preemptible() (preempt_count() == 0 && !irqs_disabled())
101051
101052 #ifdef CONFIG_PREEMPT
101053@@ -234,8 +251,10 @@ do { \
101054 * region.
101055 */
101056 #define preempt_disable() barrier()
101057+#define raw_preempt_disable() barrier()
101058 #define sched_preempt_enable_no_resched() barrier()
101059 #define preempt_enable_no_resched() barrier()
101060+#define raw_preempt_enable_no_resched() barrier()
101061 #define preempt_enable() barrier()
101062 #define preempt_check_resched() do { } while (0)
101063
101064@@ -250,11 +269,13 @@ do { \
101065 /*
101066 * Modules have no business playing preemption tricks.
101067 */
101068+#ifndef CONFIG_PAX_KERNEXEC
101069 #undef sched_preempt_enable_no_resched
101070 #undef preempt_enable_no_resched
101071 #undef preempt_enable_no_resched_notrace
101072 #undef preempt_check_resched
101073 #endif
101074+#endif
101075
101076 #define preempt_set_need_resched() \
101077 do { \
101078diff --git a/include/linux/printk.h b/include/linux/printk.h
101079index a6298b2..57fe982 100644
101080--- a/include/linux/printk.h
101081+++ b/include/linux/printk.h
101082@@ -123,6 +123,7 @@ void early_printk(const char *s, ...) { }
101083 #endif
101084
101085 typedef __printf(1, 0) int (*printk_func_t)(const char *fmt, va_list args);
101086+extern int kptr_restrict;
101087
101088 #ifdef CONFIG_PRINTK
101089 asmlinkage __printf(5, 0)
101090@@ -158,7 +159,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
101091
101092 extern int printk_delay_msec;
101093 extern int dmesg_restrict;
101094-extern int kptr_restrict;
101095
101096 extern void wake_up_klogd(void);
101097
101098diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
101099index b97bf2e..f14c92d4 100644
101100--- a/include/linux/proc_fs.h
101101+++ b/include/linux/proc_fs.h
101102@@ -17,8 +17,11 @@ extern void proc_flush_task(struct task_struct *);
101103 extern struct proc_dir_entry *proc_symlink(const char *,
101104 struct proc_dir_entry *, const char *);
101105 extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
101106+extern struct proc_dir_entry *proc_mkdir_restrict(const char *, struct proc_dir_entry *);
101107 extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
101108 struct proc_dir_entry *, void *);
101109+extern struct proc_dir_entry *proc_mkdir_data_restrict(const char *, umode_t,
101110+ struct proc_dir_entry *, void *);
101111 extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
101112 struct proc_dir_entry *);
101113
101114@@ -34,6 +37,19 @@ static inline struct proc_dir_entry *proc_create(
101115 return proc_create_data(name, mode, parent, proc_fops, NULL);
101116 }
101117
101118+static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
101119+ struct proc_dir_entry *parent, const struct file_operations *proc_fops)
101120+{
101121+#ifdef CONFIG_GRKERNSEC_PROC_USER
101122+ return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
101123+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
101124+ return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
101125+#else
101126+ return proc_create_data(name, mode, parent, proc_fops, NULL);
101127+#endif
101128+}
101129+
101130+
101131 extern void proc_set_size(struct proc_dir_entry *, loff_t);
101132 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
101133 extern void *PDE_DATA(const struct inode *);
101134@@ -56,8 +72,12 @@ static inline struct proc_dir_entry *proc_symlink(const char *name,
101135 struct proc_dir_entry *parent,const char *dest) { return NULL;}
101136 static inline struct proc_dir_entry *proc_mkdir(const char *name,
101137 struct proc_dir_entry *parent) {return NULL;}
101138+static inline struct proc_dir_entry *proc_mkdir_restrict(const char *name,
101139+ struct proc_dir_entry *parent) { return NULL; }
101140 static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
101141 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
101142+static inline struct proc_dir_entry *proc_mkdir_data_restrict(const char *name,
101143+ umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
101144 static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
101145 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
101146 #define proc_create(name, mode, parent, proc_fops) ({NULL;})
101147@@ -79,7 +99,7 @@ struct net;
101148 static inline struct proc_dir_entry *proc_net_mkdir(
101149 struct net *net, const char *name, struct proc_dir_entry *parent)
101150 {
101151- return proc_mkdir_data(name, 0, parent, net);
101152+ return proc_mkdir_data_restrict(name, 0, parent, net);
101153 }
101154
101155 #endif /* _LINUX_PROC_FS_H */
101156diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
101157index 42dfc61..8113a99 100644
101158--- a/include/linux/proc_ns.h
101159+++ b/include/linux/proc_ns.h
101160@@ -16,7 +16,7 @@ struct proc_ns_operations {
101161 struct ns_common *(*get)(struct task_struct *task);
101162 void (*put)(struct ns_common *ns);
101163 int (*install)(struct nsproxy *nsproxy, struct ns_common *ns);
101164-};
101165+} __do_const __randomize_layout;
101166
101167 extern const struct proc_ns_operations netns_operations;
101168 extern const struct proc_ns_operations utsns_operations;
101169diff --git a/include/linux/quota.h b/include/linux/quota.h
101170index b2505ac..5f7ab55 100644
101171--- a/include/linux/quota.h
101172+++ b/include/linux/quota.h
101173@@ -76,7 +76,7 @@ struct kqid { /* Type in which we store the quota identifier */
101174
101175 extern bool qid_eq(struct kqid left, struct kqid right);
101176 extern bool qid_lt(struct kqid left, struct kqid right);
101177-extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
101178+extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
101179 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
101180 extern bool qid_valid(struct kqid qid);
101181
101182diff --git a/include/linux/random.h b/include/linux/random.h
101183index e651874..a872186 100644
101184--- a/include/linux/random.h
101185+++ b/include/linux/random.h
101186@@ -16,9 +16,19 @@ struct random_ready_callback {
101187 };
101188
101189 extern void add_device_randomness(const void *, unsigned int);
101190+
101191+static inline void add_latent_entropy(void)
101192+{
101193+
101194+#ifdef LATENT_ENTROPY_PLUGIN
101195+ add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
101196+#endif
101197+
101198+}
101199+
101200 extern void add_input_randomness(unsigned int type, unsigned int code,
101201- unsigned int value);
101202-extern void add_interrupt_randomness(int irq, int irq_flags);
101203+ unsigned int value) __latent_entropy;
101204+extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
101205
101206 extern void get_random_bytes(void *buf, int nbytes);
101207 extern int add_random_ready_callback(struct random_ready_callback *rdy);
101208@@ -46,6 +56,11 @@ struct rnd_state {
101209 u32 prandom_u32_state(struct rnd_state *state);
101210 void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes);
101211
101212+static inline unsigned long __intentional_overflow(-1) pax_get_random_long(void)
101213+{
101214+ return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
101215+}
101216+
101217 /**
101218 * prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro)
101219 * @ep_ro: right open interval endpoint
101220@@ -58,7 +73,7 @@ void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes);
101221 *
101222 * Returns: pseudo-random number in interval [0, ep_ro)
101223 */
101224-static inline u32 prandom_u32_max(u32 ep_ro)
101225+static inline u32 __intentional_overflow(-1) prandom_u32_max(u32 ep_ro)
101226 {
101227 return (u32)(((u64) prandom_u32() * ep_ro) >> 32);
101228 }
101229diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
101230index 14d7b83..a1edf56 100644
101231--- a/include/linux/rbtree_augmented.h
101232+++ b/include/linux/rbtree_augmented.h
101233@@ -90,7 +90,9 @@ rbname ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \
101234 old->rbaugmented = rbcompute(old); \
101235 } \
101236 rbstatic const struct rb_augment_callbacks rbname = { \
101237- rbname ## _propagate, rbname ## _copy, rbname ## _rotate \
101238+ .propagate = rbname ## _propagate, \
101239+ .copy = rbname ## _copy, \
101240+ .rotate = rbname ## _rotate \
101241 };
101242
101243
101244diff --git a/include/linux/rculist.h b/include/linux/rculist.h
101245index 17c6b1f..a65e3f8 100644
101246--- a/include/linux/rculist.h
101247+++ b/include/linux/rculist.h
101248@@ -59,6 +59,9 @@ void __list_add_rcu(struct list_head *new,
101249 struct list_head *prev, struct list_head *next);
101250 #endif
101251
101252+void __pax_list_add_rcu(struct list_head *new,
101253+ struct list_head *prev, struct list_head *next);
101254+
101255 /**
101256 * list_add_rcu - add a new entry to rcu-protected list
101257 * @new: new entry to be added
101258@@ -80,6 +83,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
101259 __list_add_rcu(new, head, head->next);
101260 }
101261
101262+static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
101263+{
101264+ __pax_list_add_rcu(new, head, head->next);
101265+}
101266+
101267 /**
101268 * list_add_tail_rcu - add a new entry to rcu-protected list
101269 * @new: new entry to be added
101270@@ -102,6 +110,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
101271 __list_add_rcu(new, head->prev, head);
101272 }
101273
101274+static inline void pax_list_add_tail_rcu(struct list_head *new,
101275+ struct list_head *head)
101276+{
101277+ __pax_list_add_rcu(new, head->prev, head);
101278+}
101279+
101280 /**
101281 * list_del_rcu - deletes entry from list without re-initialization
101282 * @entry: the element to delete from the list.
101283@@ -132,6 +146,8 @@ static inline void list_del_rcu(struct list_head *entry)
101284 entry->prev = LIST_POISON2;
101285 }
101286
101287+extern void pax_list_del_rcu(struct list_head *entry);
101288+
101289 /**
101290 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
101291 * @n: the element to delete from the hash list.
101292diff --git a/include/linux/reboot.h b/include/linux/reboot.h
101293index a7ff409..03e2fa8 100644
101294--- a/include/linux/reboot.h
101295+++ b/include/linux/reboot.h
101296@@ -47,9 +47,9 @@ extern void do_kernel_restart(char *cmd);
101297 */
101298
101299 extern void migrate_to_reboot_cpu(void);
101300-extern void machine_restart(char *cmd);
101301-extern void machine_halt(void);
101302-extern void machine_power_off(void);
101303+extern void machine_restart(char *cmd) __noreturn;
101304+extern void machine_halt(void) __noreturn;
101305+extern void machine_power_off(void) __noreturn;
101306
101307 extern void machine_shutdown(void);
101308 struct pt_regs;
101309@@ -60,9 +60,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
101310 */
101311
101312 extern void kernel_restart_prepare(char *cmd);
101313-extern void kernel_restart(char *cmd);
101314-extern void kernel_halt(void);
101315-extern void kernel_power_off(void);
101316+extern void kernel_restart(char *cmd) __noreturn;
101317+extern void kernel_halt(void) __noreturn;
101318+extern void kernel_power_off(void) __noreturn;
101319
101320 extern int C_A_D; /* for sysctl */
101321 void ctrl_alt_del(void);
101322@@ -77,7 +77,7 @@ extern void orderly_reboot(void);
101323 * Emergency restart, callable from an interrupt handler.
101324 */
101325
101326-extern void emergency_restart(void);
101327+extern void emergency_restart(void) __noreturn;
101328 #include <asm/emergency-restart.h>
101329
101330 #endif /* _LINUX_REBOOT_H */
101331diff --git a/include/linux/regset.h b/include/linux/regset.h
101332index 8e0c9fe..ac4d221 100644
101333--- a/include/linux/regset.h
101334+++ b/include/linux/regset.h
101335@@ -161,7 +161,8 @@ struct user_regset {
101336 unsigned int align;
101337 unsigned int bias;
101338 unsigned int core_note_type;
101339-};
101340+} __do_const;
101341+typedef struct user_regset __no_const user_regset_no_const;
101342
101343 /**
101344 * struct user_regset_view - available regsets
101345diff --git a/include/linux/relay.h b/include/linux/relay.h
101346index d7c8359..818daf5 100644
101347--- a/include/linux/relay.h
101348+++ b/include/linux/relay.h
101349@@ -157,7 +157,7 @@ struct rchan_callbacks
101350 * The callback should return 0 if successful, negative if not.
101351 */
101352 int (*remove_buf_file)(struct dentry *dentry);
101353-};
101354+} __no_const;
101355
101356 /*
101357 * CONFIG_RELAY kernel API, kernel/relay.c
101358diff --git a/include/linux/rio.h b/include/linux/rio.h
101359index cde976e..ebd6033 100644
101360--- a/include/linux/rio.h
101361+++ b/include/linux/rio.h
101362@@ -358,7 +358,7 @@ struct rio_ops {
101363 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
101364 u64 rstart, u32 size, u32 flags);
101365 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
101366-};
101367+} __no_const;
101368
101369 #define RIO_RESOURCE_MEM 0x00000100
101370 #define RIO_RESOURCE_DOORBELL 0x00000200
101371diff --git a/include/linux/rmap.h b/include/linux/rmap.h
101372index c89c53a..aa0a65a 100644
101373--- a/include/linux/rmap.h
101374+++ b/include/linux/rmap.h
101375@@ -146,8 +146,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
101376 void anon_vma_init(void); /* create anon_vma_cachep */
101377 int anon_vma_prepare(struct vm_area_struct *);
101378 void unlink_anon_vmas(struct vm_area_struct *);
101379-int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
101380-int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
101381+int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
101382+int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
101383
101384 static inline void anon_vma_merge(struct vm_area_struct *vma,
101385 struct vm_area_struct *next)
101386diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
101387index 9b1ef0c..9fa3feb 100644
101388--- a/include/linux/scatterlist.h
101389+++ b/include/linux/scatterlist.h
101390@@ -1,6 +1,7 @@
101391 #ifndef _LINUX_SCATTERLIST_H
101392 #define _LINUX_SCATTERLIST_H
101393
101394+#include <linux/sched.h>
101395 #include <linux/string.h>
101396 #include <linux/types.h>
101397 #include <linux/bug.h>
101398@@ -136,10 +137,17 @@ static inline struct page *sg_page(struct scatterlist *sg)
101399 static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
101400 unsigned int buflen)
101401 {
101402+ const void *realbuf = buf;
101403+
101404+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
101405+ if (object_starts_on_stack(buf))
101406+ realbuf = buf - current->stack + current->lowmem_stack;
101407+#endif
101408+
101409 #ifdef CONFIG_DEBUG_SG
101410- BUG_ON(!virt_addr_valid(buf));
101411+ BUG_ON(!virt_addr_valid(realbuf));
101412 #endif
101413- sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
101414+ sg_set_page(sg, virt_to_page(realbuf), buflen, offset_in_page(realbuf));
101415 }
101416
101417 /*
101418diff --git a/include/linux/sched.h b/include/linux/sched.h
101419index bfca8aa..ac50d1b 100644
101420--- a/include/linux/sched.h
101421+++ b/include/linux/sched.h
101422@@ -7,7 +7,7 @@
101423
101424
101425 struct sched_param {
101426- int sched_priority;
101427+ unsigned int sched_priority;
101428 };
101429
101430 #include <asm/param.h> /* for HZ */
101431@@ -134,6 +134,7 @@ struct perf_event_context;
101432 struct blk_plug;
101433 struct filename;
101434 struct nameidata;
101435+struct linux_binprm;
101436
101437 #define VMACACHE_BITS 2
101438 #define VMACACHE_SIZE (1U << VMACACHE_BITS)
101439@@ -436,6 +437,19 @@ struct nsproxy;
101440 struct user_namespace;
101441
101442 #ifdef CONFIG_MMU
101443+
101444+#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
101445+extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
101446+#else
101447+static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
101448+{
101449+ return 0;
101450+}
101451+#endif
101452+
101453+extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
101454+extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
101455+
101456 extern void arch_pick_mmap_layout(struct mm_struct *mm);
101457 extern unsigned long
101458 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
101459@@ -749,6 +763,17 @@ struct signal_struct {
101460 #ifdef CONFIG_TASKSTATS
101461 struct taskstats *stats;
101462 #endif
101463+
101464+#ifdef CONFIG_GRKERNSEC
101465+ u32 curr_ip;
101466+ u32 saved_ip;
101467+ u32 gr_saddr;
101468+ u32 gr_daddr;
101469+ u16 gr_sport;
101470+ u16 gr_dport;
101471+ u8 used_accept:1;
101472+#endif
101473+
101474 #ifdef CONFIG_AUDIT
101475 unsigned audit_tty;
101476 unsigned audit_tty_log_passwd;
101477@@ -775,7 +800,7 @@ struct signal_struct {
101478 struct mutex cred_guard_mutex; /* guard against foreign influences on
101479 * credential calculations
101480 * (notably. ptrace) */
101481-};
101482+} __randomize_layout;
101483
101484 /*
101485 * Bits in flags field of signal_struct.
101486@@ -828,6 +853,14 @@ struct user_struct {
101487 struct key *session_keyring; /* UID's default session keyring */
101488 #endif
101489
101490+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
101491+ unsigned char kernel_banned;
101492+#endif
101493+#ifdef CONFIG_GRKERNSEC_BRUTE
101494+ unsigned char suid_banned;
101495+ unsigned long suid_ban_expires;
101496+#endif
101497+
101498 /* Hash table maintenance information */
101499 struct hlist_node uidhash_node;
101500 kuid_t uid;
101501@@ -835,7 +868,7 @@ struct user_struct {
101502 #ifdef CONFIG_PERF_EVENTS
101503 atomic_long_t locked_vm;
101504 #endif
101505-};
101506+} __randomize_layout;
101507
101508 extern int uids_sysfs_init(void);
101509
101510@@ -1356,6 +1389,9 @@ enum perf_event_task_context {
101511 struct task_struct {
101512 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
101513 void *stack;
101514+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
101515+ void *lowmem_stack;
101516+#endif
101517 atomic_t usage;
101518 unsigned int flags; /* per process flags, defined below */
101519 unsigned int ptrace;
101520@@ -1488,8 +1524,8 @@ struct task_struct {
101521 struct list_head thread_node;
101522
101523 struct completion *vfork_done; /* for vfork() */
101524- int __user *set_child_tid; /* CLONE_CHILD_SETTID */
101525- int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
101526+ pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
101527+ pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
101528
101529 cputime_t utime, stime, utimescaled, stimescaled;
101530 cputime_t gtime;
101531@@ -1514,11 +1550,6 @@ struct task_struct {
101532 struct task_cputime cputime_expires;
101533 struct list_head cpu_timers[3];
101534
101535-/* process credentials */
101536- const struct cred __rcu *real_cred; /* objective and real subjective task
101537- * credentials (COW) */
101538- const struct cred __rcu *cred; /* effective (overridable) subjective task
101539- * credentials (COW) */
101540 char comm[TASK_COMM_LEN]; /* executable name excluding path
101541 - access with [gs]et_task_comm (which lock
101542 it with task_lock())
101543@@ -1534,6 +1565,8 @@ struct task_struct {
101544 /* hung task detection */
101545 unsigned long last_switch_count;
101546 #endif
101547+/* CPU-specific state of this task */
101548+ struct thread_struct thread;
101549 /* filesystem information */
101550 struct fs_struct *fs;
101551 /* open file information */
101552@@ -1610,6 +1643,10 @@ struct task_struct {
101553 gfp_t lockdep_reclaim_gfp;
101554 #endif
101555
101556+/* process credentials */
101557+ const struct cred __rcu *real_cred; /* objective and real subjective task
101558+ * credentials (COW) */
101559+
101560 /* journalling filesystem info */
101561 void *journal_info;
101562
101563@@ -1648,6 +1685,10 @@ struct task_struct {
101564 /* cg_list protected by css_set_lock and tsk->alloc_lock */
101565 struct list_head cg_list;
101566 #endif
101567+
101568+ const struct cred __rcu *cred; /* effective (overridable) subjective task
101569+ * credentials (COW) */
101570+
101571 #ifdef CONFIG_FUTEX
101572 struct robust_list_head __user *robust_list;
101573 #ifdef CONFIG_COMPAT
101574@@ -1759,7 +1800,7 @@ struct task_struct {
101575 * Number of functions that haven't been traced
101576 * because of depth overrun.
101577 */
101578- atomic_t trace_overrun;
101579+ atomic_unchecked_t trace_overrun;
101580 /* Pause for the tracing */
101581 atomic_t tracing_graph_pause;
101582 #endif
101583@@ -1788,22 +1829,89 @@ struct task_struct {
101584 unsigned long task_state_change;
101585 #endif
101586 int pagefault_disabled;
101587-/* CPU-specific state of this task */
101588- struct thread_struct thread;
101589-/*
101590- * WARNING: on x86, 'thread_struct' contains a variable-sized
101591- * structure. It *MUST* be at the end of 'task_struct'.
101592- *
101593- * Do not put anything below here!
101594- */
101595-};
101596+
101597+#ifdef CONFIG_GRKERNSEC
101598+ /* grsecurity */
101599+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
101600+ u64 exec_id;
101601+#endif
101602+#ifdef CONFIG_GRKERNSEC_SETXID
101603+ const struct cred *delayed_cred;
101604+#endif
101605+ struct dentry *gr_chroot_dentry;
101606+ struct acl_subject_label *acl;
101607+ struct acl_subject_label *tmpacl;
101608+ struct acl_role_label *role;
101609+ struct file *exec_file;
101610+ unsigned long brute_expires;
101611+ u16 acl_role_id;
101612+ u8 inherited;
101613+ /* is this the task that authenticated to the special role */
101614+ u8 acl_sp_role;
101615+ u8 is_writable;
101616+ u8 brute;
101617+ u8 gr_is_chrooted;
101618+#endif
101619+
101620+/* thread_info moved to task_struct */
101621+#ifdef CONFIG_X86
101622+ struct thread_info tinfo;
101623+#endif
101624+} __randomize_layout;
101625
101626 #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT
101627-extern int arch_task_struct_size __read_mostly;
101628+extern size_t arch_task_struct_size __read_mostly;
101629 #else
101630 # define arch_task_struct_size (sizeof(struct task_struct))
101631 #endif
101632
101633+#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
101634+#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
101635+#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
101636+#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
101637+/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
101638+#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
101639+
101640+#ifdef CONFIG_PAX_SOFTMODE
101641+extern int pax_softmode;
101642+#endif
101643+
101644+extern int pax_check_flags(unsigned long *);
101645+#define PAX_PARSE_FLAGS_FALLBACK (~0UL)
101646+
101647+/* if tsk != current then task_lock must be held on it */
101648+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
101649+static inline unsigned long pax_get_flags(struct task_struct *tsk)
101650+{
101651+ if (likely(tsk->mm))
101652+ return tsk->mm->pax_flags;
101653+ else
101654+ return 0UL;
101655+}
101656+
101657+/* if tsk != current then task_lock must be held on it */
101658+static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
101659+{
101660+ if (likely(tsk->mm)) {
101661+ tsk->mm->pax_flags = flags;
101662+ return 0;
101663+ }
101664+ return -EINVAL;
101665+}
101666+#endif
101667+
101668+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
101669+extern void pax_set_initial_flags(struct linux_binprm *bprm);
101670+#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
101671+extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
101672+#endif
101673+
101674+struct path;
101675+extern char *pax_get_path(const struct path *path, char *buf, int buflen);
101676+extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
101677+extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
101678+extern void pax_report_refcount_overflow(struct pt_regs *regs);
101679+
101680 /* Future-safe accessor for struct task_struct's cpus_allowed. */
101681 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
101682
101683@@ -1885,7 +1993,7 @@ struct pid_namespace;
101684 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
101685 struct pid_namespace *ns);
101686
101687-static inline pid_t task_pid_nr(struct task_struct *tsk)
101688+static inline pid_t task_pid_nr(const struct task_struct *tsk)
101689 {
101690 return tsk->pid;
101691 }
101692@@ -2253,6 +2361,25 @@ extern u64 sched_clock_cpu(int cpu);
101693
101694 extern void sched_clock_init(void);
101695
101696+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
101697+static inline void populate_stack(void)
101698+{
101699+ struct task_struct *curtask = current;
101700+ int c;
101701+ int *ptr = curtask->stack;
101702+ int *end = curtask->stack + THREAD_SIZE;
101703+
101704+ while (ptr < end) {
101705+ c = *(volatile int *)ptr;
101706+ ptr += PAGE_SIZE/sizeof(int);
101707+ }
101708+}
101709+#else
101710+static inline void populate_stack(void)
101711+{
101712+}
101713+#endif
101714+
101715 #ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
101716 static inline void sched_clock_tick(void)
101717 {
101718@@ -2381,7 +2508,9 @@ extern void set_curr_task(int cpu, struct task_struct *p);
101719 void yield(void);
101720
101721 union thread_union {
101722+#ifndef CONFIG_X86
101723 struct thread_info thread_info;
101724+#endif
101725 unsigned long stack[THREAD_SIZE/sizeof(long)];
101726 };
101727
101728@@ -2414,6 +2543,7 @@ extern struct pid_namespace init_pid_ns;
101729 */
101730
101731 extern struct task_struct *find_task_by_vpid(pid_t nr);
101732+extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
101733 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
101734 struct pid_namespace *ns);
101735
101736@@ -2591,7 +2721,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
101737 extern void exit_itimers(struct signal_struct *);
101738 extern void flush_itimer_signals(void);
101739
101740-extern void do_group_exit(int);
101741+extern __noreturn void do_group_exit(int);
101742
101743 extern int do_execve(struct filename *,
101744 const char __user * const __user *,
101745@@ -2796,9 +2926,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
101746 #define task_stack_end_corrupted(task) \
101747 (*(end_of_stack(task)) != STACK_END_MAGIC)
101748
101749-static inline int object_is_on_stack(void *obj)
101750+static inline int object_starts_on_stack(const void *obj)
101751 {
101752- void *stack = task_stack_page(current);
101753+ const void *stack = task_stack_page(current);
101754
101755 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
101756 }
101757diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
101758index c9e4731..c716293 100644
101759--- a/include/linux/sched/sysctl.h
101760+++ b/include/linux/sched/sysctl.h
101761@@ -34,6 +34,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
101762 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
101763
101764 extern int sysctl_max_map_count;
101765+extern unsigned long sysctl_heap_stack_gap;
101766
101767 extern unsigned int sysctl_sched_latency;
101768 extern unsigned int sysctl_sched_min_granularity;
101769diff --git a/include/linux/security.h b/include/linux/security.h
101770index 2f4c1f7..5bc05d7 100644
101771--- a/include/linux/security.h
101772+++ b/include/linux/security.h
101773@@ -28,6 +28,7 @@
101774 #include <linux/err.h>
101775 #include <linux/string.h>
101776 #include <linux/mm.h>
101777+#include <linux/grsecurity.h>
101778
101779 struct linux_binprm;
101780 struct cred;
101781diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
101782index dc368b8..e895209 100644
101783--- a/include/linux/semaphore.h
101784+++ b/include/linux/semaphore.h
101785@@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
101786 }
101787
101788 extern void down(struct semaphore *sem);
101789-extern int __must_check down_interruptible(struct semaphore *sem);
101790+extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
101791 extern int __must_check down_killable(struct semaphore *sem);
101792 extern int __must_check down_trylock(struct semaphore *sem);
101793 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
101794diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
101795index d4c7271..abf5706 100644
101796--- a/include/linux/seq_file.h
101797+++ b/include/linux/seq_file.h
101798@@ -27,6 +27,9 @@ struct seq_file {
101799 struct mutex lock;
101800 const struct seq_operations *op;
101801 int poll_event;
101802+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
101803+ u64 exec_id;
101804+#endif
101805 #ifdef CONFIG_USER_NS
101806 struct user_namespace *user_ns;
101807 #endif
101808@@ -39,6 +42,7 @@ struct seq_operations {
101809 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
101810 int (*show) (struct seq_file *m, void *v);
101811 };
101812+typedef struct seq_operations __no_const seq_operations_no_const;
101813
101814 #define SEQ_SKIP 1
101815
101816@@ -111,6 +115,7 @@ void seq_pad(struct seq_file *m, char c);
101817
101818 char *mangle_path(char *s, const char *p, const char *esc);
101819 int seq_open(struct file *, const struct seq_operations *);
101820+int seq_open_restrict(struct file *, const struct seq_operations *);
101821 ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
101822 loff_t seq_lseek(struct file *, loff_t, int);
101823 int seq_release(struct inode *, struct file *);
101824@@ -129,6 +134,7 @@ int seq_path_root(struct seq_file *m, const struct path *path,
101825 const struct path *root, const char *esc);
101826
101827 int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
101828+int single_open_restrict(struct file *, int (*)(struct seq_file *, void *), void *);
101829 int single_open_size(struct file *, int (*)(struct seq_file *, void *), void *, size_t);
101830 int single_release(struct inode *, struct file *);
101831 void *__seq_open_private(struct file *, const struct seq_operations *, int);
101832diff --git a/include/linux/shm.h b/include/linux/shm.h
101833index 6fb8016..2cf60e7 100644
101834--- a/include/linux/shm.h
101835+++ b/include/linux/shm.h
101836@@ -22,7 +22,11 @@ struct shmid_kernel /* private to the kernel */
101837 /* The task created the shm object. NULL if the task is dead. */
101838 struct task_struct *shm_creator;
101839 struct list_head shm_clist; /* list by creator */
101840-};
101841+#ifdef CONFIG_GRKERNSEC
101842+ u64 shm_createtime;
101843+ pid_t shm_lapid;
101844+#endif
101845+} __randomize_layout;
101846
101847 /* shm_mode upper byte flags */
101848 #define SHM_DEST 01000 /* segment will be destroyed on last detach */
101849diff --git a/include/linux/signal.h b/include/linux/signal.h
101850index ab1e039..ad4229e 100644
101851--- a/include/linux/signal.h
101852+++ b/include/linux/signal.h
101853@@ -289,7 +289,7 @@ static inline void allow_signal(int sig)
101854 * know it'll be handled, so that they don't get converted to
101855 * SIGKILL or just silently dropped.
101856 */
101857- kernel_sigaction(sig, (__force __sighandler_t)2);
101858+ kernel_sigaction(sig, (__force_user __sighandler_t)2);
101859 }
101860
101861 static inline void disallow_signal(int sig)
101862diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
101863index 2751588..dc96c12 100644
101864--- a/include/linux/skbuff.h
101865+++ b/include/linux/skbuff.h
101866@@ -784,7 +784,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t priority, int flags,
101867 int node);
101868 struct sk_buff *__build_skb(void *data, unsigned int frag_size);
101869 struct sk_buff *build_skb(void *data, unsigned int frag_size);
101870-static inline struct sk_buff *alloc_skb(unsigned int size,
101871+static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
101872 gfp_t priority)
101873 {
101874 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
101875@@ -1964,7 +1964,7 @@ static inline int skb_checksum_start_offset(const struct sk_buff *skb)
101876 return skb->csum_start - skb_headroom(skb);
101877 }
101878
101879-static inline int skb_transport_offset(const struct sk_buff *skb)
101880+static inline int __intentional_overflow(0) skb_transport_offset(const struct sk_buff *skb)
101881 {
101882 return skb_transport_header(skb) - skb->data;
101883 }
101884@@ -1979,7 +1979,7 @@ static inline u32 skb_inner_network_header_len(const struct sk_buff *skb)
101885 return skb->inner_transport_header - skb->inner_network_header;
101886 }
101887
101888-static inline int skb_network_offset(const struct sk_buff *skb)
101889+static inline int __intentional_overflow(0) skb_network_offset(const struct sk_buff *skb)
101890 {
101891 return skb_network_header(skb) - skb->data;
101892 }
101893@@ -2039,7 +2039,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
101894 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
101895 */
101896 #ifndef NET_SKB_PAD
101897-#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
101898+#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
101899 #endif
101900
101901 int ___pskb_trim(struct sk_buff *skb, unsigned int len);
101902@@ -2685,9 +2685,9 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
101903 int *err);
101904 unsigned int datagram_poll(struct file *file, struct socket *sock,
101905 struct poll_table_struct *wait);
101906-int skb_copy_datagram_iter(const struct sk_buff *from, int offset,
101907+int __intentional_overflow(0) skb_copy_datagram_iter(const struct sk_buff *from, int offset,
101908 struct iov_iter *to, int size);
101909-static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset,
101910+static inline int __intentional_overflow(2,4) skb_copy_datagram_msg(const struct sk_buff *from, int offset,
101911 struct msghdr *msg, int size)
101912 {
101913 return skb_copy_datagram_iter(from, offset, &msg->msg_iter, size);
101914@@ -3216,6 +3216,9 @@ static inline void nf_reset(struct sk_buff *skb)
101915 nf_bridge_put(skb->nf_bridge);
101916 skb->nf_bridge = NULL;
101917 #endif
101918+#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
101919+ skb->nf_trace = 0;
101920+#endif
101921 }
101922
101923 static inline void nf_reset_trace(struct sk_buff *skb)
101924diff --git a/include/linux/slab.h b/include/linux/slab.h
101925index a99f0e5..4efa730 100644
101926--- a/include/linux/slab.h
101927+++ b/include/linux/slab.h
101928@@ -15,14 +15,29 @@
101929 #include <linux/types.h>
101930 #include <linux/workqueue.h>
101931
101932+#include <linux/err.h>
101933
101934 /*
101935 * Flags to pass to kmem_cache_create().
101936 * The ones marked DEBUG are only valid if CONFIG_DEBUG_SLAB is set.
101937 */
101938 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
101939+
101940+#ifdef CONFIG_PAX_USERCOPY_SLABS
101941+#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
101942+#else
101943+#define SLAB_USERCOPY 0x00000000UL
101944+#endif
101945+
101946 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
101947 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
101948+
101949+#ifdef CONFIG_PAX_MEMORY_SANITIZE
101950+#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
101951+#else
101952+#define SLAB_NO_SANITIZE 0x00000000UL
101953+#endif
101954+
101955 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
101956 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
101957 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
101958@@ -98,10 +113,13 @@
101959 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
101960 * Both make kfree a no-op.
101961 */
101962-#define ZERO_SIZE_PTR ((void *)16)
101963+#define ZERO_SIZE_PTR \
101964+({ \
101965+ BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
101966+ (void *)(-MAX_ERRNO-1L); \
101967+})
101968
101969-#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
101970- (unsigned long)ZERO_SIZE_PTR)
101971+#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
101972
101973 #include <linux/kmemleak.h>
101974 #include <linux/kasan.h>
101975@@ -143,6 +161,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
101976 void kfree(const void *);
101977 void kzfree(const void *);
101978 size_t ksize(const void *);
101979+const char *check_heap_object(const void *ptr, unsigned long n);
101980+bool is_usercopy_object(const void *ptr);
101981
101982 /*
101983 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
101984@@ -235,6 +255,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
101985 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
101986 #endif
101987
101988+#ifdef CONFIG_PAX_USERCOPY_SLABS
101989+extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
101990+#endif
101991+
101992 /*
101993 * Figure out which kmalloc slab an allocation of a certain size
101994 * belongs to.
101995@@ -243,7 +267,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
101996 * 2 = 129 .. 192 bytes
101997 * n = 2^(n-1)+1 .. 2^n
101998 */
101999-static __always_inline int kmalloc_index(size_t size)
102000+static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
102001 {
102002 if (!size)
102003 return 0;
102004@@ -286,15 +310,15 @@ static __always_inline int kmalloc_index(size_t size)
102005 }
102006 #endif /* !CONFIG_SLOB */
102007
102008-void *__kmalloc(size_t size, gfp_t flags);
102009+void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
102010 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
102011 void kmem_cache_free(struct kmem_cache *, void *);
102012
102013 #ifdef CONFIG_NUMA
102014-void *__kmalloc_node(size_t size, gfp_t flags, int node);
102015+void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1) __size_overflow(1);
102016 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
102017 #else
102018-static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
102019+static __always_inline void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t flags, int node)
102020 {
102021 return __kmalloc(size, flags);
102022 }
102023diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
102024index 33d0490..70a6313 100644
102025--- a/include/linux/slab_def.h
102026+++ b/include/linux/slab_def.h
102027@@ -40,7 +40,7 @@ struct kmem_cache {
102028 /* 4) cache creation/removal */
102029 const char *name;
102030 struct list_head list;
102031- int refcount;
102032+ atomic_t refcount;
102033 int object_size;
102034 int align;
102035
102036@@ -56,10 +56,14 @@ struct kmem_cache {
102037 unsigned long node_allocs;
102038 unsigned long node_frees;
102039 unsigned long node_overflow;
102040- atomic_t allochit;
102041- atomic_t allocmiss;
102042- atomic_t freehit;
102043- atomic_t freemiss;
102044+ atomic_unchecked_t allochit;
102045+ atomic_unchecked_t allocmiss;
102046+ atomic_unchecked_t freehit;
102047+ atomic_unchecked_t freemiss;
102048+#ifdef CONFIG_PAX_MEMORY_SANITIZE
102049+ atomic_unchecked_t sanitized;
102050+ atomic_unchecked_t not_sanitized;
102051+#endif
102052
102053 /*
102054 * If debugging is enabled, then the allocator can add additional
102055diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
102056index 3388511..6252f90 100644
102057--- a/include/linux/slub_def.h
102058+++ b/include/linux/slub_def.h
102059@@ -74,7 +74,7 @@ struct kmem_cache {
102060 struct kmem_cache_order_objects max;
102061 struct kmem_cache_order_objects min;
102062 gfp_t allocflags; /* gfp flags to use on each alloc */
102063- int refcount; /* Refcount for slab cache destroy */
102064+ atomic_t refcount; /* Refcount for slab cache destroy */
102065 void (*ctor)(void *);
102066 int inuse; /* Offset to metadata */
102067 int align; /* Alignment */
102068diff --git a/include/linux/smp.h b/include/linux/smp.h
102069index c441407..f487b83 100644
102070--- a/include/linux/smp.h
102071+++ b/include/linux/smp.h
102072@@ -183,7 +183,9 @@ static inline void smp_init(void) { }
102073 #endif
102074
102075 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
102076+#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
102077 #define put_cpu() preempt_enable()
102078+#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
102079
102080 /*
102081 * Callback to arch code if there's nosmp or maxcpus=0 on the
102082diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
102083index fddebc6..6f0ae39 100644
102084--- a/include/linux/sock_diag.h
102085+++ b/include/linux/sock_diag.h
102086@@ -15,7 +15,7 @@ struct sock_diag_handler {
102087 __u8 family;
102088 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
102089 int (*get_info)(struct sk_buff *skb, struct sock *sk);
102090-};
102091+} __do_const;
102092
102093 int sock_diag_register(const struct sock_diag_handler *h);
102094 void sock_diag_unregister(const struct sock_diag_handler *h);
102095diff --git a/include/linux/sonet.h b/include/linux/sonet.h
102096index 680f9a3..f13aeb0 100644
102097--- a/include/linux/sonet.h
102098+++ b/include/linux/sonet.h
102099@@ -7,7 +7,7 @@
102100 #include <uapi/linux/sonet.h>
102101
102102 struct k_sonet_stats {
102103-#define __HANDLE_ITEM(i) atomic_t i
102104+#define __HANDLE_ITEM(i) atomic_unchecked_t i
102105 __SONET_ITEMS
102106 #undef __HANDLE_ITEM
102107 };
102108diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
102109index 07d8e53..dc934c9 100644
102110--- a/include/linux/sunrpc/addr.h
102111+++ b/include/linux/sunrpc/addr.h
102112@@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
102113 {
102114 switch (sap->sa_family) {
102115 case AF_INET:
102116- return ntohs(((struct sockaddr_in *)sap)->sin_port);
102117+ return ntohs(((const struct sockaddr_in *)sap)->sin_port);
102118 case AF_INET6:
102119- return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
102120+ return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
102121 }
102122 return 0;
102123 }
102124@@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
102125 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
102126 const struct sockaddr *src)
102127 {
102128- const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
102129+ const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
102130 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
102131
102132 dsin->sin_family = ssin->sin_family;
102133@@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
102134 if (sa->sa_family != AF_INET6)
102135 return 0;
102136
102137- return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
102138+ return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
102139 }
102140
102141 #endif /* _LINUX_SUNRPC_ADDR_H */
102142diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
102143index 131032f..5f9378a 100644
102144--- a/include/linux/sunrpc/clnt.h
102145+++ b/include/linux/sunrpc/clnt.h
102146@@ -101,7 +101,7 @@ struct rpc_procinfo {
102147 unsigned int p_timer; /* Which RTT timer to use */
102148 u32 p_statidx; /* Which procedure to account */
102149 const char * p_name; /* name of procedure */
102150-};
102151+} __do_const;
102152
102153 #ifdef __KERNEL__
102154
102155diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
102156index fae6fb9..023fbcd 100644
102157--- a/include/linux/sunrpc/svc.h
102158+++ b/include/linux/sunrpc/svc.h
102159@@ -420,7 +420,7 @@ struct svc_procedure {
102160 unsigned int pc_count; /* call count */
102161 unsigned int pc_cachetype; /* cache info (NFS) */
102162 unsigned int pc_xdrressize; /* maximum size of XDR reply */
102163-};
102164+} __do_const;
102165
102166 /*
102167 * Function prototypes.
102168diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
102169index 4929a8a..b8f29e9 100644
102170--- a/include/linux/sunrpc/svc_rdma.h
102171+++ b/include/linux/sunrpc/svc_rdma.h
102172@@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
102173 extern unsigned int svcrdma_max_requests;
102174 extern unsigned int svcrdma_max_req_size;
102175
102176-extern atomic_t rdma_stat_recv;
102177-extern atomic_t rdma_stat_read;
102178-extern atomic_t rdma_stat_write;
102179-extern atomic_t rdma_stat_sq_starve;
102180-extern atomic_t rdma_stat_rq_starve;
102181-extern atomic_t rdma_stat_rq_poll;
102182-extern atomic_t rdma_stat_rq_prod;
102183-extern atomic_t rdma_stat_sq_poll;
102184-extern atomic_t rdma_stat_sq_prod;
102185+extern atomic_unchecked_t rdma_stat_recv;
102186+extern atomic_unchecked_t rdma_stat_read;
102187+extern atomic_unchecked_t rdma_stat_write;
102188+extern atomic_unchecked_t rdma_stat_sq_starve;
102189+extern atomic_unchecked_t rdma_stat_rq_starve;
102190+extern atomic_unchecked_t rdma_stat_rq_poll;
102191+extern atomic_unchecked_t rdma_stat_rq_prod;
102192+extern atomic_unchecked_t rdma_stat_sq_poll;
102193+extern atomic_unchecked_t rdma_stat_sq_prod;
102194
102195 /*
102196 * Contexts are built when an RDMA request is created and are a
102197diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
102198index 8d71d65..f79586e 100644
102199--- a/include/linux/sunrpc/svcauth.h
102200+++ b/include/linux/sunrpc/svcauth.h
102201@@ -120,7 +120,7 @@ struct auth_ops {
102202 int (*release)(struct svc_rqst *rq);
102203 void (*domain_release)(struct auth_domain *);
102204 int (*set_client)(struct svc_rqst *rq);
102205-};
102206+} __do_const;
102207
102208 #define SVC_GARBAGE 1
102209 #define SVC_SYSERR 2
102210diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
102211index e7a018e..49f8b17 100644
102212--- a/include/linux/swiotlb.h
102213+++ b/include/linux/swiotlb.h
102214@@ -60,7 +60,8 @@ extern void
102215
102216 extern void
102217 swiotlb_free_coherent(struct device *hwdev, size_t size,
102218- void *vaddr, dma_addr_t dma_handle);
102219+ void *vaddr, dma_addr_t dma_handle,
102220+ struct dma_attrs *attrs);
102221
102222 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
102223 unsigned long offset, size_t size,
102224diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
102225index b45c45b..a6ae64c 100644
102226--- a/include/linux/syscalls.h
102227+++ b/include/linux/syscalls.h
102228@@ -102,7 +102,12 @@ union bpf_attr;
102229 #define __TYPE_IS_L(t) (__same_type((t)0, 0L))
102230 #define __TYPE_IS_UL(t) (__same_type((t)0, 0UL))
102231 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
102232-#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
102233+#define __SC_LONG(t, a) __typeof__( \
102234+ __builtin_choose_expr( \
102235+ sizeof(t) > sizeof(int), \
102236+ (t) 0, \
102237+ __builtin_choose_expr(__type_is_unsigned(t), 0UL, 0L) \
102238+ )) a
102239 #define __SC_CAST(t, a) (t) a
102240 #define __SC_ARGS(t, a) a
102241 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
102242@@ -384,11 +389,11 @@ asmlinkage long sys_sync(void);
102243 asmlinkage long sys_fsync(unsigned int fd);
102244 asmlinkage long sys_fdatasync(unsigned int fd);
102245 asmlinkage long sys_bdflush(int func, long data);
102246-asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
102247- char __user *type, unsigned long flags,
102248+asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
102249+ const char __user *type, unsigned long flags,
102250 void __user *data);
102251-asmlinkage long sys_umount(char __user *name, int flags);
102252-asmlinkage long sys_oldumount(char __user *name);
102253+asmlinkage long sys_umount(const char __user *name, int flags);
102254+asmlinkage long sys_oldumount(const char __user *name);
102255 asmlinkage long sys_truncate(const char __user *path, long length);
102256 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
102257 asmlinkage long sys_stat(const char __user *filename,
102258@@ -604,7 +609,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
102259 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
102260 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
102261 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
102262- struct sockaddr __user *, int);
102263+ struct sockaddr __user *, int) __intentional_overflow(0);
102264 asmlinkage long sys_sendmsg(int fd, struct user_msghdr __user *msg, unsigned flags);
102265 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
102266 unsigned int vlen, unsigned flags);
102267@@ -663,10 +668,10 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf);
102268
102269 asmlinkage long sys_semget(key_t key, int nsems, int semflg);
102270 asmlinkage long sys_semop(int semid, struct sembuf __user *sops,
102271- unsigned nsops);
102272+ long nsops);
102273 asmlinkage long sys_semctl(int semid, int semnum, int cmd, unsigned long arg);
102274 asmlinkage long sys_semtimedop(int semid, struct sembuf __user *sops,
102275- unsigned nsops,
102276+ long nsops,
102277 const struct timespec __user *timeout);
102278 asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg);
102279 asmlinkage long sys_shmget(key_t key, size_t size, int flag);
102280diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
102281index 27b3b0b..e093dd9 100644
102282--- a/include/linux/syscore_ops.h
102283+++ b/include/linux/syscore_ops.h
102284@@ -16,7 +16,7 @@ struct syscore_ops {
102285 int (*suspend)(void);
102286 void (*resume)(void);
102287 void (*shutdown)(void);
102288-};
102289+} __do_const;
102290
102291 extern void register_syscore_ops(struct syscore_ops *ops);
102292 extern void unregister_syscore_ops(struct syscore_ops *ops);
102293diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
102294index fa7bc29..0d96561 100644
102295--- a/include/linux/sysctl.h
102296+++ b/include/linux/sysctl.h
102297@@ -39,10 +39,16 @@ typedef int proc_handler (struct ctl_table *ctl, int write,
102298
102299 extern int proc_dostring(struct ctl_table *, int,
102300 void __user *, size_t *, loff_t *);
102301+extern int proc_dostring_modpriv(struct ctl_table *, int,
102302+ void __user *, size_t *, loff_t *);
102303 extern int proc_dointvec(struct ctl_table *, int,
102304 void __user *, size_t *, loff_t *);
102305+extern int proc_dointvec_secure(struct ctl_table *, int,
102306+ void __user *, size_t *, loff_t *);
102307 extern int proc_dointvec_minmax(struct ctl_table *, int,
102308 void __user *, size_t *, loff_t *);
102309+extern int proc_dointvec_minmax_secure(struct ctl_table *, int,
102310+ void __user *, size_t *, loff_t *);
102311 extern int proc_dointvec_jiffies(struct ctl_table *, int,
102312 void __user *, size_t *, loff_t *);
102313 extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int,
102314@@ -113,7 +119,8 @@ struct ctl_table
102315 struct ctl_table_poll *poll;
102316 void *extra1;
102317 void *extra2;
102318-};
102319+} __do_const __randomize_layout;
102320+typedef struct ctl_table __no_const ctl_table_no_const;
102321
102322 struct ctl_node {
102323 struct rb_node node;
102324diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
102325index 9f65758..487a6f1 100644
102326--- a/include/linux/sysfs.h
102327+++ b/include/linux/sysfs.h
102328@@ -34,7 +34,8 @@ struct attribute {
102329 struct lock_class_key *key;
102330 struct lock_class_key skey;
102331 #endif
102332-};
102333+} __do_const;
102334+typedef struct attribute __no_const attribute_no_const;
102335
102336 /**
102337 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
102338@@ -78,7 +79,8 @@ struct attribute_group {
102339 struct attribute *, int);
102340 struct attribute **attrs;
102341 struct bin_attribute **bin_attrs;
102342-};
102343+} __do_const;
102344+typedef struct attribute_group __no_const attribute_group_no_const;
102345
102346 /**
102347 * Use these macros to make defining attributes easier. See include/linux/device.h
102348@@ -152,7 +154,8 @@ struct bin_attribute {
102349 char *, loff_t, size_t);
102350 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
102351 struct vm_area_struct *vma);
102352-};
102353+} __do_const;
102354+typedef struct bin_attribute __no_const bin_attribute_no_const;
102355
102356 /**
102357 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
102358diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
102359index 387fa7d..3fcde6b 100644
102360--- a/include/linux/sysrq.h
102361+++ b/include/linux/sysrq.h
102362@@ -16,6 +16,7 @@
102363
102364 #include <linux/errno.h>
102365 #include <linux/types.h>
102366+#include <linux/compiler.h>
102367
102368 /* Possible values of bitmask for enabling sysrq functions */
102369 /* 0x0001 is reserved for enable everything */
102370@@ -33,7 +34,7 @@ struct sysrq_key_op {
102371 char *help_msg;
102372 char *action_msg;
102373 int enable_mask;
102374-};
102375+} __do_const;
102376
102377 #ifdef CONFIG_MAGIC_SYSRQ
102378
102379diff --git a/include/linux/tcp.h b/include/linux/tcp.h
102380index 48c3696..e7a7ba6 100644
102381--- a/include/linux/tcp.h
102382+++ b/include/linux/tcp.h
102383@@ -63,13 +63,13 @@ struct tcp_fastopen_cookie {
102384
102385 /* This defines a selective acknowledgement block. */
102386 struct tcp_sack_block_wire {
102387- __be32 start_seq;
102388- __be32 end_seq;
102389+ __be32 start_seq __intentional_overflow(-1);
102390+ __be32 end_seq __intentional_overflow(-1);
102391 };
102392
102393 struct tcp_sack_block {
102394- u32 start_seq;
102395- u32 end_seq;
102396+ u32 start_seq __intentional_overflow(-1);
102397+ u32 end_seq __intentional_overflow(-1);
102398 };
102399
102400 /*These are used to set the sack_ok field in struct tcp_options_received */
102401@@ -153,7 +153,7 @@ struct tcp_sock {
102402 * total number of segments in.
102403 */
102404 u32 rcv_nxt; /* What we want to receive next */
102405- u32 copied_seq; /* Head of yet unread data */
102406+ u32 copied_seq __intentional_overflow(-1); /* Head of yet unread data */
102407 u32 rcv_wup; /* rcv_nxt on last window update sent */
102408 u32 snd_nxt; /* Next sequence we send */
102409 u32 segs_out; /* RFC4898 tcpEStatsPerfSegsOut
102410@@ -248,7 +248,7 @@ struct tcp_sock {
102411 u32 prr_out; /* Total number of pkts sent during Recovery. */
102412
102413 u32 rcv_wnd; /* Current receiver window */
102414- u32 write_seq; /* Tail(+1) of data held in tcp send buffer */
102415+ u32 write_seq __intentional_overflow(-1); /* Tail(+1) of data held in tcp send buffer */
102416 u32 notsent_lowat; /* TCP_NOTSENT_LOWAT */
102417 u32 pushed_seq; /* Last pushed seq, required to talk to windows */
102418 u32 lost_out; /* Lost packets */
102419@@ -291,7 +291,7 @@ struct tcp_sock {
102420 int undo_retrans; /* number of undoable retransmissions. */
102421 u32 total_retrans; /* Total retransmits for entire connection */
102422
102423- u32 urg_seq; /* Seq of received urgent pointer */
102424+ u32 urg_seq __intentional_overflow(-1); /* Seq of received urgent pointer */
102425 unsigned int keepalive_time; /* time before keep alive takes place */
102426 unsigned int keepalive_intvl; /* time interval between keep alive probes */
102427
102428diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
102429index ff307b5..f1a4468 100644
102430--- a/include/linux/thread_info.h
102431+++ b/include/linux/thread_info.h
102432@@ -145,6 +145,13 @@ static inline bool test_and_clear_restore_sigmask(void)
102433 #error "no set_restore_sigmask() provided and default one won't work"
102434 #endif
102435
102436+extern void __check_object_size(const void *ptr, unsigned long n, bool to_user, bool const_size);
102437+
102438+static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
102439+{
102440+ __check_object_size(ptr, n, to_user, __builtin_constant_p(n));
102441+}
102442+
102443 #endif /* __KERNEL__ */
102444
102445 #endif /* _LINUX_THREAD_INFO_H */
102446diff --git a/include/linux/tty.h b/include/linux/tty.h
102447index ad6c891..93a8f45 100644
102448--- a/include/linux/tty.h
102449+++ b/include/linux/tty.h
102450@@ -225,7 +225,7 @@ struct tty_port {
102451 const struct tty_port_operations *ops; /* Port operations */
102452 spinlock_t lock; /* Lock protecting tty field */
102453 int blocked_open; /* Waiting to open */
102454- int count; /* Usage count */
102455+ atomic_t count; /* Usage count */
102456 wait_queue_head_t open_wait; /* Open waiters */
102457 wait_queue_head_t close_wait; /* Close waiters */
102458 wait_queue_head_t delta_msr_wait; /* Modem status change */
102459@@ -313,7 +313,7 @@ struct tty_struct {
102460 /* If the tty has a pending do_SAK, queue it here - akpm */
102461 struct work_struct SAK_work;
102462 struct tty_port *port;
102463-};
102464+} __randomize_layout;
102465
102466 /* Each of a tty's open files has private_data pointing to tty_file_private */
102467 struct tty_file_private {
102468@@ -573,7 +573,7 @@ extern int tty_port_open(struct tty_port *port,
102469 struct tty_struct *tty, struct file *filp);
102470 static inline int tty_port_users(struct tty_port *port)
102471 {
102472- return port->count + port->blocked_open;
102473+ return atomic_read(&port->count) + port->blocked_open;
102474 }
102475
102476 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
102477diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
102478index 92e337c..f46757b 100644
102479--- a/include/linux/tty_driver.h
102480+++ b/include/linux/tty_driver.h
102481@@ -291,7 +291,7 @@ struct tty_operations {
102482 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
102483 #endif
102484 const struct file_operations *proc_fops;
102485-};
102486+} __do_const __randomize_layout;
102487
102488 struct tty_driver {
102489 int magic; /* magic number for this structure */
102490@@ -325,7 +325,7 @@ struct tty_driver {
102491
102492 const struct tty_operations *ops;
102493 struct list_head tty_drivers;
102494-};
102495+} __randomize_layout;
102496
102497 extern struct list_head tty_drivers;
102498
102499diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
102500index 00c9d68..bc0188b 100644
102501--- a/include/linux/tty_ldisc.h
102502+++ b/include/linux/tty_ldisc.h
102503@@ -215,7 +215,7 @@ struct tty_ldisc_ops {
102504
102505 struct module *owner;
102506
102507- int refcount;
102508+ atomic_t refcount;
102509 };
102510
102511 struct tty_ldisc {
102512diff --git a/include/linux/types.h b/include/linux/types.h
102513index 8715287..1be77ee 100644
102514--- a/include/linux/types.h
102515+++ b/include/linux/types.h
102516@@ -176,10 +176,26 @@ typedef struct {
102517 int counter;
102518 } atomic_t;
102519
102520+#ifdef CONFIG_PAX_REFCOUNT
102521+typedef struct {
102522+ int counter;
102523+} atomic_unchecked_t;
102524+#else
102525+typedef atomic_t atomic_unchecked_t;
102526+#endif
102527+
102528 #ifdef CONFIG_64BIT
102529 typedef struct {
102530 long counter;
102531 } atomic64_t;
102532+
102533+#ifdef CONFIG_PAX_REFCOUNT
102534+typedef struct {
102535+ long counter;
102536+} atomic64_unchecked_t;
102537+#else
102538+typedef atomic64_t atomic64_unchecked_t;
102539+#endif
102540 #endif
102541
102542 struct list_head {
102543diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
102544index ae572c1..73bd4ec 100644
102545--- a/include/linux/uaccess.h
102546+++ b/include/linux/uaccess.h
102547@@ -97,11 +97,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
102548 long ret; \
102549 mm_segment_t old_fs = get_fs(); \
102550 \
102551- set_fs(KERNEL_DS); \
102552 pagefault_disable(); \
102553- ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
102554- pagefault_enable(); \
102555+ set_fs(KERNEL_DS); \
102556+ ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
102557 set_fs(old_fs); \
102558+ pagefault_enable(); \
102559 ret; \
102560 })
102561
102562diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
102563index 0383552..a0125dd 100644
102564--- a/include/linux/uidgid.h
102565+++ b/include/linux/uidgid.h
102566@@ -187,4 +187,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
102567
102568 #endif /* CONFIG_USER_NS */
102569
102570+#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
102571+#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
102572+#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
102573+#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
102574+
102575 #endif /* _LINUX_UIDGID_H */
102576diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
102577index 32c0e83..671eb35 100644
102578--- a/include/linux/uio_driver.h
102579+++ b/include/linux/uio_driver.h
102580@@ -67,7 +67,7 @@ struct uio_device {
102581 struct module *owner;
102582 struct device *dev;
102583 int minor;
102584- atomic_t event;
102585+ atomic_unchecked_t event;
102586 struct fasync_struct *async_queue;
102587 wait_queue_head_t wait;
102588 struct uio_info *info;
102589diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
102590index 99c1b4d..562e6f3 100644
102591--- a/include/linux/unaligned/access_ok.h
102592+++ b/include/linux/unaligned/access_ok.h
102593@@ -4,34 +4,34 @@
102594 #include <linux/kernel.h>
102595 #include <asm/byteorder.h>
102596
102597-static inline u16 get_unaligned_le16(const void *p)
102598+static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
102599 {
102600- return le16_to_cpup((__le16 *)p);
102601+ return le16_to_cpup((const __le16 *)p);
102602 }
102603
102604-static inline u32 get_unaligned_le32(const void *p)
102605+static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
102606 {
102607- return le32_to_cpup((__le32 *)p);
102608+ return le32_to_cpup((const __le32 *)p);
102609 }
102610
102611-static inline u64 get_unaligned_le64(const void *p)
102612+static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
102613 {
102614- return le64_to_cpup((__le64 *)p);
102615+ return le64_to_cpup((const __le64 *)p);
102616 }
102617
102618-static inline u16 get_unaligned_be16(const void *p)
102619+static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
102620 {
102621- return be16_to_cpup((__be16 *)p);
102622+ return be16_to_cpup((const __be16 *)p);
102623 }
102624
102625-static inline u32 get_unaligned_be32(const void *p)
102626+static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
102627 {
102628- return be32_to_cpup((__be32 *)p);
102629+ return be32_to_cpup((const __be32 *)p);
102630 }
102631
102632-static inline u64 get_unaligned_be64(const void *p)
102633+static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
102634 {
102635- return be64_to_cpup((__be64 *)p);
102636+ return be64_to_cpup((const __be64 *)p);
102637 }
102638
102639 static inline void put_unaligned_le16(u16 val, void *p)
102640diff --git a/include/linux/usb.h b/include/linux/usb.h
102641index 447fe29..07a9cf0 100644
102642--- a/include/linux/usb.h
102643+++ b/include/linux/usb.h
102644@@ -363,7 +363,7 @@ struct usb_bus {
102645 * with the URB_SHORT_NOT_OK flag set.
102646 */
102647 unsigned no_sg_constraint:1; /* no sg constraint */
102648- unsigned sg_tablesize; /* 0 or largest number of sg list entries */
102649+ unsigned short sg_tablesize; /* 0 or largest number of sg list entries */
102650
102651 int devnum_next; /* Next open device number in
102652 * round-robin allocation */
102653@@ -592,7 +592,7 @@ struct usb_device {
102654 int maxchild;
102655
102656 u32 quirks;
102657- atomic_t urbnum;
102658+ atomic_unchecked_t urbnum;
102659
102660 unsigned long active_duration;
102661
102662@@ -1785,10 +1785,10 @@ void usb_sg_wait(struct usb_sg_request *io);
102663
102664 /* NOTE: these are not the standard USB_ENDPOINT_XFER_* values!! */
102665 /* (yet ... they're the values used by usbfs) */
102666-#define PIPE_ISOCHRONOUS 0
102667-#define PIPE_INTERRUPT 1
102668-#define PIPE_CONTROL 2
102669-#define PIPE_BULK 3
102670+#define PIPE_ISOCHRONOUS 0U
102671+#define PIPE_INTERRUPT 1U
102672+#define PIPE_CONTROL 2U
102673+#define PIPE_BULK 3U
102674
102675 #define usb_pipein(pipe) ((pipe) & USB_DIR_IN)
102676 #define usb_pipeout(pipe) (!usb_pipein(pipe))
102677diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
102678index c9aa779..46d6f69 100644
102679--- a/include/linux/usb/hcd.h
102680+++ b/include/linux/usb/hcd.h
102681@@ -23,6 +23,7 @@
102682
102683 #include <linux/rwsem.h>
102684 #include <linux/interrupt.h>
102685+#include <scsi/scsi_host.h>
102686
102687 #define MAX_TOPO_LEVEL 6
102688
102689diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
102690index 3dd5a78..ed69d7b 100644
102691--- a/include/linux/usb/renesas_usbhs.h
102692+++ b/include/linux/usb/renesas_usbhs.h
102693@@ -39,7 +39,7 @@ enum {
102694 */
102695 struct renesas_usbhs_driver_callback {
102696 int (*notify_hotplug)(struct platform_device *pdev);
102697-};
102698+} __no_const;
102699
102700 /*
102701 * callback functions for platform
102702diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
102703index 8297e5b..0dfae27 100644
102704--- a/include/linux/user_namespace.h
102705+++ b/include/linux/user_namespace.h
102706@@ -39,7 +39,7 @@ struct user_namespace {
102707 struct key *persistent_keyring_register;
102708 struct rw_semaphore persistent_keyring_register_sem;
102709 #endif
102710-};
102711+} __randomize_layout;
102712
102713 extern struct user_namespace init_user_ns;
102714
102715diff --git a/include/linux/utsname.h b/include/linux/utsname.h
102716index 5093f58..c103e58 100644
102717--- a/include/linux/utsname.h
102718+++ b/include/linux/utsname.h
102719@@ -25,7 +25,7 @@ struct uts_namespace {
102720 struct new_utsname name;
102721 struct user_namespace *user_ns;
102722 struct ns_common ns;
102723-};
102724+} __randomize_layout;
102725 extern struct uts_namespace init_uts_ns;
102726
102727 #ifdef CONFIG_UTS_NS
102728diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
102729index 6f8fbcf..4efc177 100644
102730--- a/include/linux/vermagic.h
102731+++ b/include/linux/vermagic.h
102732@@ -25,9 +25,42 @@
102733 #define MODULE_ARCH_VERMAGIC ""
102734 #endif
102735
102736+#ifdef CONFIG_PAX_REFCOUNT
102737+#define MODULE_PAX_REFCOUNT "REFCOUNT "
102738+#else
102739+#define MODULE_PAX_REFCOUNT ""
102740+#endif
102741+
102742+#ifdef CONSTIFY_PLUGIN
102743+#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
102744+#else
102745+#define MODULE_CONSTIFY_PLUGIN ""
102746+#endif
102747+
102748+#ifdef STACKLEAK_PLUGIN
102749+#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
102750+#else
102751+#define MODULE_STACKLEAK_PLUGIN ""
102752+#endif
102753+
102754+#ifdef RANDSTRUCT_PLUGIN
102755+#include <generated/randomize_layout_hash.h>
102756+#define MODULE_RANDSTRUCT_PLUGIN "RANDSTRUCT_PLUGIN_" RANDSTRUCT_HASHED_SEED
102757+#else
102758+#define MODULE_RANDSTRUCT_PLUGIN
102759+#endif
102760+
102761+#ifdef CONFIG_GRKERNSEC
102762+#define MODULE_GRSEC "GRSEC "
102763+#else
102764+#define MODULE_GRSEC ""
102765+#endif
102766+
102767 #define VERMAGIC_STRING \
102768 UTS_RELEASE " " \
102769 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
102770 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
102771- MODULE_ARCH_VERMAGIC
102772+ MODULE_ARCH_VERMAGIC \
102773+ MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
102774+ MODULE_GRSEC MODULE_RANDSTRUCT_PLUGIN
102775
102776diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
102777index b483abd..af305ad 100644
102778--- a/include/linux/vga_switcheroo.h
102779+++ b/include/linux/vga_switcheroo.h
102780@@ -63,9 +63,9 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
102781
102782 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
102783
102784-int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
102785+int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
102786 void vga_switcheroo_fini_domain_pm_ops(struct device *dev);
102787-int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
102788+int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
102789 #else
102790
102791 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
102792@@ -82,9 +82,9 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
102793
102794 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
102795
102796-static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
102797+static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
102798 static inline void vga_switcheroo_fini_domain_pm_ops(struct device *dev) {}
102799-static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
102800+static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
102801
102802 #endif
102803 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
102804diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
102805index 0ec5983..d5888bb 100644
102806--- a/include/linux/vmalloc.h
102807+++ b/include/linux/vmalloc.h
102808@@ -18,6 +18,14 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
102809 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
102810 #define VM_NO_GUARD 0x00000040 /* don't add guard page */
102811 #define VM_KASAN 0x00000080 /* has allocated kasan shadow memory */
102812+
102813+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
102814+#define VM_KERNEXEC 0x00000100 /* allocate from executable kernel memory range */
102815+#endif
102816+
102817+#define VM_USERCOPY 0x00000200 /* allocation intended for copies to userland */
102818+
102819+
102820 /* bits [20..32] reserved for arch specific ioremap internals */
102821
102822 /*
102823@@ -67,6 +75,7 @@ static inline void vmalloc_init(void)
102824 #endif
102825
102826 extern void *vmalloc(unsigned long size);
102827+extern void *vmalloc_usercopy(unsigned long size);
102828 extern void *vzalloc(unsigned long size);
102829 extern void *vmalloc_user(unsigned long size);
102830 extern void *vmalloc_node(unsigned long size, int node);
102831@@ -86,6 +95,10 @@ extern void *vmap(struct page **pages, unsigned int count,
102832 unsigned long flags, pgprot_t prot);
102833 extern void vunmap(const void *addr);
102834
102835+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
102836+extern void unmap_process_stacks(struct task_struct *task);
102837+#endif
102838+
102839 extern int remap_vmalloc_range_partial(struct vm_area_struct *vma,
102840 unsigned long uaddr, void *kaddr,
102841 unsigned long size);
102842@@ -150,7 +163,7 @@ extern void free_vm_area(struct vm_struct *area);
102843
102844 /* for /dev/kmem */
102845 extern long vread(char *buf, char *addr, unsigned long count);
102846-extern long vwrite(char *buf, char *addr, unsigned long count);
102847+extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
102848
102849 /*
102850 * Internals. Dont't use..
102851diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
102852index 82e7db7..f8ce3d0 100644
102853--- a/include/linux/vmstat.h
102854+++ b/include/linux/vmstat.h
102855@@ -108,18 +108,18 @@ static inline void vm_events_fold_cpu(int cpu)
102856 /*
102857 * Zone based page accounting with per cpu differentials.
102858 */
102859-extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
102860+extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
102861
102862 static inline void zone_page_state_add(long x, struct zone *zone,
102863 enum zone_stat_item item)
102864 {
102865- atomic_long_add(x, &zone->vm_stat[item]);
102866- atomic_long_add(x, &vm_stat[item]);
102867+ atomic_long_add_unchecked(x, &zone->vm_stat[item]);
102868+ atomic_long_add_unchecked(x, &vm_stat[item]);
102869 }
102870
102871-static inline unsigned long global_page_state(enum zone_stat_item item)
102872+static inline unsigned long __intentional_overflow(-1) global_page_state(enum zone_stat_item item)
102873 {
102874- long x = atomic_long_read(&vm_stat[item]);
102875+ long x = atomic_long_read_unchecked(&vm_stat[item]);
102876 #ifdef CONFIG_SMP
102877 if (x < 0)
102878 x = 0;
102879@@ -127,10 +127,10 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
102880 return x;
102881 }
102882
102883-static inline unsigned long zone_page_state(struct zone *zone,
102884+static inline unsigned long __intentional_overflow(-1) zone_page_state(struct zone *zone,
102885 enum zone_stat_item item)
102886 {
102887- long x = atomic_long_read(&zone->vm_stat[item]);
102888+ long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
102889 #ifdef CONFIG_SMP
102890 if (x < 0)
102891 x = 0;
102892@@ -147,7 +147,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
102893 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
102894 enum zone_stat_item item)
102895 {
102896- long x = atomic_long_read(&zone->vm_stat[item]);
102897+ long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
102898
102899 #ifdef CONFIG_SMP
102900 int cpu;
102901@@ -234,14 +234,14 @@ static inline void __mod_zone_page_state(struct zone *zone,
102902
102903 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
102904 {
102905- atomic_long_inc(&zone->vm_stat[item]);
102906- atomic_long_inc(&vm_stat[item]);
102907+ atomic_long_inc_unchecked(&zone->vm_stat[item]);
102908+ atomic_long_inc_unchecked(&vm_stat[item]);
102909 }
102910
102911 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
102912 {
102913- atomic_long_dec(&zone->vm_stat[item]);
102914- atomic_long_dec(&vm_stat[item]);
102915+ atomic_long_dec_unchecked(&zone->vm_stat[item]);
102916+ atomic_long_dec_unchecked(&vm_stat[item]);
102917 }
102918
102919 static inline void __inc_zone_page_state(struct page *page,
102920diff --git a/include/linux/xattr.h b/include/linux/xattr.h
102921index 91b0a68..0e9adf6 100644
102922--- a/include/linux/xattr.h
102923+++ b/include/linux/xattr.h
102924@@ -28,7 +28,7 @@ struct xattr_handler {
102925 size_t size, int handler_flags);
102926 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
102927 size_t size, int flags, int handler_flags);
102928-};
102929+} __do_const;
102930
102931 struct xattr {
102932 const char *name;
102933@@ -37,6 +37,9 @@ struct xattr {
102934 };
102935
102936 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
102937+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
102938+ssize_t pax_getxattr(struct dentry *, void *, size_t);
102939+#endif
102940 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
102941 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
102942 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
102943diff --git a/include/linux/zlib.h b/include/linux/zlib.h
102944index 92dbbd3..13ab0b3 100644
102945--- a/include/linux/zlib.h
102946+++ b/include/linux/zlib.h
102947@@ -31,6 +31,7 @@
102948 #define _ZLIB_H
102949
102950 #include <linux/zconf.h>
102951+#include <linux/compiler.h>
102952
102953 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
102954 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
102955@@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
102956
102957 /* basic functions */
102958
102959-extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
102960+extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
102961 /*
102962 Returns the number of bytes that needs to be allocated for a per-
102963 stream workspace with the specified parameters. A pointer to this
102964diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
102965index acbcd2f..c3abe84 100644
102966--- a/include/media/v4l2-dev.h
102967+++ b/include/media/v4l2-dev.h
102968@@ -74,7 +74,7 @@ struct v4l2_file_operations {
102969 int (*mmap) (struct file *, struct vm_area_struct *);
102970 int (*open) (struct file *);
102971 int (*release) (struct file *);
102972-};
102973+} __do_const;
102974
102975 /*
102976 * Newer version of video_device, handled by videodev2.c
102977diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
102978index 9c58157..d86ebf5 100644
102979--- a/include/media/v4l2-device.h
102980+++ b/include/media/v4l2-device.h
102981@@ -93,7 +93,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
102982 this function returns 0. If the name ends with a digit (e.g. cx18),
102983 then the name will be set to cx18-0 since cx180 looks really odd. */
102984 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
102985- atomic_t *instance);
102986+ atomic_unchecked_t *instance);
102987
102988 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
102989 Since the parent disappears this ensures that v4l2_dev doesn't have an
102990diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
102991index 5122b5e..598b440 100644
102992--- a/include/net/9p/transport.h
102993+++ b/include/net/9p/transport.h
102994@@ -62,7 +62,7 @@ struct p9_trans_module {
102995 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
102996 int (*zc_request)(struct p9_client *, struct p9_req_t *,
102997 struct iov_iter *, struct iov_iter *, int , int, int);
102998-};
102999+} __do_const;
103000
103001 void v9fs_register_trans(struct p9_trans_module *m);
103002 void v9fs_unregister_trans(struct p9_trans_module *m);
103003diff --git a/include/net/af_unix.h b/include/net/af_unix.h
103004index cb1b9bb..56b3ee0 100644
103005--- a/include/net/af_unix.h
103006+++ b/include/net/af_unix.h
103007@@ -36,7 +36,7 @@ struct unix_skb_parms {
103008 u32 secid; /* Security ID */
103009 #endif
103010 u32 consumed;
103011-};
103012+} __randomize_layout;
103013
103014 #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))
103015
103016diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
103017index 2239a37..a83461f 100644
103018--- a/include/net/bluetooth/l2cap.h
103019+++ b/include/net/bluetooth/l2cap.h
103020@@ -609,7 +609,7 @@ struct l2cap_ops {
103021 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
103022 unsigned long hdr_len,
103023 unsigned long len, int nb);
103024-};
103025+} __do_const;
103026
103027 struct l2cap_conn {
103028 struct hci_conn *hcon;
103029diff --git a/include/net/bonding.h b/include/net/bonding.h
103030index 20defc0..3072903 100644
103031--- a/include/net/bonding.h
103032+++ b/include/net/bonding.h
103033@@ -661,7 +661,7 @@ extern struct rtnl_link_ops bond_link_ops;
103034
103035 static inline void bond_tx_drop(struct net_device *dev, struct sk_buff *skb)
103036 {
103037- atomic_long_inc(&dev->tx_dropped);
103038+ atomic_long_inc_unchecked(&dev->tx_dropped);
103039 dev_kfree_skb_any(skb);
103040 }
103041
103042diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
103043index f2ae33d..c457cf0 100644
103044--- a/include/net/caif/cfctrl.h
103045+++ b/include/net/caif/cfctrl.h
103046@@ -52,7 +52,7 @@ struct cfctrl_rsp {
103047 void (*radioset_rsp)(void);
103048 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
103049 struct cflayer *client_layer);
103050-};
103051+} __no_const;
103052
103053 /* Link Setup Parameters for CAIF-Links. */
103054 struct cfctrl_link_param {
103055@@ -101,8 +101,8 @@ struct cfctrl_request_info {
103056 struct cfctrl {
103057 struct cfsrvl serv;
103058 struct cfctrl_rsp res;
103059- atomic_t req_seq_no;
103060- atomic_t rsp_seq_no;
103061+ atomic_unchecked_t req_seq_no;
103062+ atomic_unchecked_t rsp_seq_no;
103063 struct list_head list;
103064 /* Protects from simultaneous access to first_req list */
103065 spinlock_t info_list_lock;
103066diff --git a/include/net/flow.h b/include/net/flow.h
103067index 8109a15..504466d 100644
103068--- a/include/net/flow.h
103069+++ b/include/net/flow.h
103070@@ -231,6 +231,6 @@ void flow_cache_fini(struct net *net);
103071
103072 void flow_cache_flush(struct net *net);
103073 void flow_cache_flush_deferred(struct net *net);
103074-extern atomic_t flow_cache_genid;
103075+extern atomic_unchecked_t flow_cache_genid;
103076
103077 #endif
103078diff --git a/include/net/genetlink.h b/include/net/genetlink.h
103079index a9af1cc..1f3fa7b 100644
103080--- a/include/net/genetlink.h
103081+++ b/include/net/genetlink.h
103082@@ -128,7 +128,7 @@ struct genl_ops {
103083 u8 cmd;
103084 u8 internal_flags;
103085 u8 flags;
103086-};
103087+} __do_const;
103088
103089 int __genl_register_family(struct genl_family *family);
103090
103091diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
103092index 0f712c0..cd762c4 100644
103093--- a/include/net/gro_cells.h
103094+++ b/include/net/gro_cells.h
103095@@ -27,7 +27,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
103096 cell = this_cpu_ptr(gcells->cells);
103097
103098 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
103099- atomic_long_inc(&dev->rx_dropped);
103100+ atomic_long_inc_unchecked(&dev->rx_dropped);
103101 kfree_skb(skb);
103102 return;
103103 }
103104diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
103105index 0320bbb..938789c 100644
103106--- a/include/net/inet_connection_sock.h
103107+++ b/include/net/inet_connection_sock.h
103108@@ -63,7 +63,7 @@ struct inet_connection_sock_af_ops {
103109 int (*bind_conflict)(const struct sock *sk,
103110 const struct inet_bind_bucket *tb, bool relax);
103111 void (*mtu_reduced)(struct sock *sk);
103112-};
103113+} __do_const;
103114
103115 /** inet_connection_sock - INET connection oriented sock
103116 *
103117diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
103118index 47eb67b..0e733b2 100644
103119--- a/include/net/inet_sock.h
103120+++ b/include/net/inet_sock.h
103121@@ -43,7 +43,7 @@
103122 struct ip_options {
103123 __be32 faddr;
103124 __be32 nexthop;
103125- unsigned char optlen;
103126+ unsigned char optlen __intentional_overflow(0);
103127 unsigned char srr;
103128 unsigned char rr;
103129 unsigned char ts;
103130diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
103131index d5332dd..10a5c3c 100644
103132--- a/include/net/inetpeer.h
103133+++ b/include/net/inetpeer.h
103134@@ -48,7 +48,7 @@ struct inet_peer {
103135 */
103136 union {
103137 struct {
103138- atomic_t rid; /* Frag reception counter */
103139+ atomic_unchecked_t rid; /* Frag reception counter */
103140 };
103141 struct rcu_head rcu;
103142 struct inet_peer *gc_next;
103143diff --git a/include/net/ip.h b/include/net/ip.h
103144index d5fe9f2..8da10ed 100644
103145--- a/include/net/ip.h
103146+++ b/include/net/ip.h
103147@@ -319,7 +319,7 @@ static inline unsigned int ip_skb_dst_mtu(const struct sk_buff *skb)
103148 }
103149 }
103150
103151-u32 ip_idents_reserve(u32 hash, int segs);
103152+u32 ip_idents_reserve(u32 hash, int segs) __intentional_overflow(-1);
103153 void __ip_select_ident(struct net *net, struct iphdr *iph, int segs);
103154
103155 static inline void ip_select_ident_segs(struct net *net, struct sk_buff *skb,
103156diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
103157index 5fa643b..d871e20 100644
103158--- a/include/net/ip_fib.h
103159+++ b/include/net/ip_fib.h
103160@@ -170,7 +170,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
103161
103162 #define FIB_RES_SADDR(net, res) \
103163 ((FIB_RES_NH(res).nh_saddr_genid == \
103164- atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
103165+ atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
103166 FIB_RES_NH(res).nh_saddr : \
103167 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
103168 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
103169diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
103170index 4e3731e..a242e28 100644
103171--- a/include/net/ip_vs.h
103172+++ b/include/net/ip_vs.h
103173@@ -551,7 +551,7 @@ struct ip_vs_conn {
103174 struct ip_vs_conn *control; /* Master control connection */
103175 atomic_t n_control; /* Number of controlled ones */
103176 struct ip_vs_dest *dest; /* real server */
103177- atomic_t in_pkts; /* incoming packet counter */
103178+ atomic_unchecked_t in_pkts; /* incoming packet counter */
103179
103180 /* Packet transmitter for different forwarding methods. If it
103181 * mangles the packet, it must return NF_DROP or better NF_STOLEN,
103182@@ -699,7 +699,7 @@ struct ip_vs_dest {
103183 __be16 port; /* port number of the server */
103184 union nf_inet_addr addr; /* IP address of the server */
103185 volatile unsigned int flags; /* dest status flags */
103186- atomic_t conn_flags; /* flags to copy to conn */
103187+ atomic_unchecked_t conn_flags; /* flags to copy to conn */
103188 atomic_t weight; /* server weight */
103189
103190 atomic_t refcnt; /* reference counter */
103191@@ -946,11 +946,11 @@ struct netns_ipvs {
103192 /* ip_vs_lblc */
103193 int sysctl_lblc_expiration;
103194 struct ctl_table_header *lblc_ctl_header;
103195- struct ctl_table *lblc_ctl_table;
103196+ ctl_table_no_const *lblc_ctl_table;
103197 /* ip_vs_lblcr */
103198 int sysctl_lblcr_expiration;
103199 struct ctl_table_header *lblcr_ctl_header;
103200- struct ctl_table *lblcr_ctl_table;
103201+ ctl_table_no_const *lblcr_ctl_table;
103202 /* ip_vs_est */
103203 struct list_head est_list; /* estimator list */
103204 spinlock_t est_lock;
103205diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
103206index 8d4f588..2e37ad2 100644
103207--- a/include/net/irda/ircomm_tty.h
103208+++ b/include/net/irda/ircomm_tty.h
103209@@ -33,6 +33,7 @@
103210 #include <linux/termios.h>
103211 #include <linux/timer.h>
103212 #include <linux/tty.h> /* struct tty_struct */
103213+#include <asm/local.h>
103214
103215 #include <net/irda/irias_object.h>
103216 #include <net/irda/ircomm_core.h>
103217diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
103218index 714cc9a..ea05f3e 100644
103219--- a/include/net/iucv/af_iucv.h
103220+++ b/include/net/iucv/af_iucv.h
103221@@ -149,7 +149,7 @@ struct iucv_skb_cb {
103222 struct iucv_sock_list {
103223 struct hlist_head head;
103224 rwlock_t lock;
103225- atomic_t autobind_name;
103226+ atomic_unchecked_t autobind_name;
103227 };
103228
103229 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
103230diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
103231index f3be818..bf46196 100644
103232--- a/include/net/llc_c_ac.h
103233+++ b/include/net/llc_c_ac.h
103234@@ -87,7 +87,7 @@
103235 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
103236 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
103237
103238-typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
103239+typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
103240
103241 int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
103242 int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
103243diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
103244index 3948cf1..83b28c4 100644
103245--- a/include/net/llc_c_ev.h
103246+++ b/include/net/llc_c_ev.h
103247@@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
103248 return (struct llc_conn_state_ev *)skb->cb;
103249 }
103250
103251-typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
103252-typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
103253+typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
103254+typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
103255
103256 int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
103257 int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
103258diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
103259index 48f3f89..0e92c50 100644
103260--- a/include/net/llc_c_st.h
103261+++ b/include/net/llc_c_st.h
103262@@ -37,7 +37,7 @@ struct llc_conn_state_trans {
103263 u8 next_state;
103264 const llc_conn_ev_qfyr_t *ev_qualifiers;
103265 const llc_conn_action_t *ev_actions;
103266-};
103267+} __do_const;
103268
103269 struct llc_conn_state {
103270 u8 current_state;
103271diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
103272index a61b98c..aade1eb 100644
103273--- a/include/net/llc_s_ac.h
103274+++ b/include/net/llc_s_ac.h
103275@@ -23,7 +23,7 @@
103276 #define SAP_ACT_TEST_IND 9
103277
103278 /* All action functions must look like this */
103279-typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
103280+typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
103281
103282 int llc_sap_action_unitdata_ind(struct llc_sap *sap, struct sk_buff *skb);
103283 int llc_sap_action_send_ui(struct llc_sap *sap, struct sk_buff *skb);
103284diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
103285index c4359e2..76dbc4a 100644
103286--- a/include/net/llc_s_st.h
103287+++ b/include/net/llc_s_st.h
103288@@ -20,7 +20,7 @@ struct llc_sap_state_trans {
103289 llc_sap_ev_t ev;
103290 u8 next_state;
103291 const llc_sap_action_t *ev_actions;
103292-};
103293+} __do_const;
103294
103295 struct llc_sap_state {
103296 u8 curr_state;
103297diff --git a/include/net/mac80211.h b/include/net/mac80211.h
103298index 6b1077c..7b72f67 100644
103299--- a/include/net/mac80211.h
103300+++ b/include/net/mac80211.h
103301@@ -5106,7 +5106,7 @@ struct ieee80211_tx_rate_control {
103302 struct sk_buff *skb;
103303 struct ieee80211_tx_rate reported_rate;
103304 bool rts, short_preamble;
103305- u8 max_rate_idx;
103306+ s8 max_rate_idx;
103307 u32 rate_idx_mask;
103308 u8 *rate_idx_mcs_mask;
103309 bool bss;
103310@@ -5143,7 +5143,7 @@ struct rate_control_ops {
103311 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
103312
103313 u32 (*get_expected_throughput)(void *priv_sta);
103314-};
103315+} __do_const;
103316
103317 static inline int rate_supported(struct ieee80211_sta *sta,
103318 enum ieee80211_band band,
103319diff --git a/include/net/neighbour.h b/include/net/neighbour.h
103320index bd33e66..6508d00 100644
103321--- a/include/net/neighbour.h
103322+++ b/include/net/neighbour.h
103323@@ -162,7 +162,7 @@ struct neigh_ops {
103324 void (*error_report)(struct neighbour *, struct sk_buff *);
103325 int (*output)(struct neighbour *, struct sk_buff *);
103326 int (*connected_output)(struct neighbour *, struct sk_buff *);
103327-};
103328+} __do_const;
103329
103330 struct pneigh_entry {
103331 struct pneigh_entry *next;
103332@@ -216,7 +216,7 @@ struct neigh_table {
103333 struct neigh_statistics __percpu *stats;
103334 struct neigh_hash_table __rcu *nht;
103335 struct pneigh_entry **phash_buckets;
103336-};
103337+} __randomize_layout;
103338
103339 enum {
103340 NEIGH_ARP_TABLE = 0,
103341diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
103342index e951453..0685f5b 100644
103343--- a/include/net/net_namespace.h
103344+++ b/include/net/net_namespace.h
103345@@ -53,7 +53,7 @@ struct net {
103346 */
103347 spinlock_t rules_mod_lock;
103348
103349- atomic64_t cookie_gen;
103350+ atomic64_unchecked_t cookie_gen;
103351
103352 struct list_head list; /* list of network namespaces */
103353 struct list_head cleanup_list; /* namespaces on death row */
103354@@ -135,8 +135,8 @@ struct net {
103355 struct netns_mpls mpls;
103356 #endif
103357 struct sock *diag_nlsk;
103358- atomic_t fnhe_genid;
103359-};
103360+ atomic_unchecked_t fnhe_genid;
103361+} __randomize_layout;
103362
103363 #include <linux/seq_file_net.h>
103364
103365@@ -271,7 +271,11 @@ static inline struct net *read_pnet(const possible_net_t *pnet)
103366 #define __net_init __init
103367 #define __net_exit __exit_refok
103368 #define __net_initdata __initdata
103369+#ifdef CONSTIFY_PLUGIN
103370 #define __net_initconst __initconst
103371+#else
103372+#define __net_initconst __initdata
103373+#endif
103374 #endif
103375
103376 int peernet2id_alloc(struct net *net, struct net *peer);
103377@@ -286,7 +290,7 @@ struct pernet_operations {
103378 void (*exit_batch)(struct list_head *net_exit_list);
103379 int *id;
103380 size_t size;
103381-};
103382+} __do_const;
103383
103384 /*
103385 * Use these carefully. If you implement a network device and it
103386@@ -334,12 +338,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
103387
103388 static inline int rt_genid_ipv4(struct net *net)
103389 {
103390- return atomic_read(&net->ipv4.rt_genid);
103391+ return atomic_read_unchecked(&net->ipv4.rt_genid);
103392 }
103393
103394 static inline void rt_genid_bump_ipv4(struct net *net)
103395 {
103396- atomic_inc(&net->ipv4.rt_genid);
103397+ atomic_inc_unchecked(&net->ipv4.rt_genid);
103398 }
103399
103400 extern void (*__fib6_flush_trees)(struct net *net);
103401@@ -366,12 +370,12 @@ static inline void rt_genid_bump_all(struct net *net)
103402
103403 static inline int fnhe_genid(struct net *net)
103404 {
103405- return atomic_read(&net->fnhe_genid);
103406+ return atomic_read_unchecked(&net->fnhe_genid);
103407 }
103408
103409 static inline void fnhe_genid_bump(struct net *net)
103410 {
103411- atomic_inc(&net->fnhe_genid);
103412+ atomic_inc_unchecked(&net->fnhe_genid);
103413 }
103414
103415 #endif /* __NET_NET_NAMESPACE_H */
103416diff --git a/include/net/netlink.h b/include/net/netlink.h
103417index 2a5dbcc..8243656 100644
103418--- a/include/net/netlink.h
103419+++ b/include/net/netlink.h
103420@@ -521,7 +521,7 @@ static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
103421 {
103422 if (mark) {
103423 WARN_ON((unsigned char *) mark < skb->data);
103424- skb_trim(skb, (unsigned char *) mark - skb->data);
103425+ skb_trim(skb, (const unsigned char *) mark - skb->data);
103426 }
103427 }
103428
103429diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
103430index 723b61c..4386367 100644
103431--- a/include/net/netns/conntrack.h
103432+++ b/include/net/netns/conntrack.h
103433@@ -14,10 +14,10 @@ struct nf_conntrack_ecache;
103434 struct nf_proto_net {
103435 #ifdef CONFIG_SYSCTL
103436 struct ctl_table_header *ctl_table_header;
103437- struct ctl_table *ctl_table;
103438+ ctl_table_no_const *ctl_table;
103439 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
103440 struct ctl_table_header *ctl_compat_header;
103441- struct ctl_table *ctl_compat_table;
103442+ ctl_table_no_const *ctl_compat_table;
103443 #endif
103444 #endif
103445 unsigned int users;
103446@@ -60,7 +60,7 @@ struct nf_ip_net {
103447 struct nf_icmp_net icmpv6;
103448 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
103449 struct ctl_table_header *ctl_table_header;
103450- struct ctl_table *ctl_table;
103451+ ctl_table_no_const *ctl_table;
103452 #endif
103453 };
103454
103455diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
103456index c68926b..106c147 100644
103457--- a/include/net/netns/ipv4.h
103458+++ b/include/net/netns/ipv4.h
103459@@ -93,7 +93,7 @@ struct netns_ipv4 {
103460
103461 struct ping_group_range ping_group_range;
103462
103463- atomic_t dev_addr_genid;
103464+ atomic_unchecked_t dev_addr_genid;
103465
103466 #ifdef CONFIG_SYSCTL
103467 unsigned long *sysctl_local_reserved_ports;
103468@@ -107,6 +107,6 @@ struct netns_ipv4 {
103469 struct fib_rules_ops *mr_rules_ops;
103470 #endif
103471 #endif
103472- atomic_t rt_genid;
103473+ atomic_unchecked_t rt_genid;
103474 };
103475 #endif
103476diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
103477index 8d93544..05c3e89 100644
103478--- a/include/net/netns/ipv6.h
103479+++ b/include/net/netns/ipv6.h
103480@@ -79,8 +79,8 @@ struct netns_ipv6 {
103481 struct fib_rules_ops *mr6_rules_ops;
103482 #endif
103483 #endif
103484- atomic_t dev_addr_genid;
103485- atomic_t fib6_sernum;
103486+ atomic_unchecked_t dev_addr_genid;
103487+ atomic_unchecked_t fib6_sernum;
103488 };
103489
103490 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
103491diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h
103492index 730d82a..045f2c4 100644
103493--- a/include/net/netns/xfrm.h
103494+++ b/include/net/netns/xfrm.h
103495@@ -78,7 +78,7 @@ struct netns_xfrm {
103496
103497 /* flow cache part */
103498 struct flow_cache flow_cache_global;
103499- atomic_t flow_cache_genid;
103500+ atomic_unchecked_t flow_cache_genid;
103501 struct list_head flow_cache_gc_list;
103502 spinlock_t flow_cache_gc_lock;
103503 struct work_struct flow_cache_gc_work;
103504diff --git a/include/net/ping.h b/include/net/ping.h
103505index ac80cb4..ec1ed09 100644
103506--- a/include/net/ping.h
103507+++ b/include/net/ping.h
103508@@ -54,7 +54,7 @@ struct ping_iter_state {
103509
103510 extern struct proto ping_prot;
103511 #if IS_ENABLED(CONFIG_IPV6)
103512-extern struct pingv6_ops pingv6_ops;
103513+extern struct pingv6_ops *pingv6_ops;
103514 #endif
103515
103516 struct pingfakehdr {
103517diff --git a/include/net/protocol.h b/include/net/protocol.h
103518index d6fcc1f..ca277058 100644
103519--- a/include/net/protocol.h
103520+++ b/include/net/protocol.h
103521@@ -49,7 +49,7 @@ struct net_protocol {
103522 * socket lookup?
103523 */
103524 icmp_strict_tag_validation:1;
103525-};
103526+} __do_const;
103527
103528 #if IS_ENABLED(CONFIG_IPV6)
103529 struct inet6_protocol {
103530@@ -62,7 +62,7 @@ struct inet6_protocol {
103531 u8 type, u8 code, int offset,
103532 __be32 info);
103533 unsigned int flags; /* INET6_PROTO_xxx */
103534-};
103535+} __do_const;
103536
103537 #define INET6_PROTO_NOPOLICY 0x1
103538 #define INET6_PROTO_FINAL 0x2
103539diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
103540index 343d922..7959cde 100644
103541--- a/include/net/rtnetlink.h
103542+++ b/include/net/rtnetlink.h
103543@@ -95,7 +95,7 @@ struct rtnl_link_ops {
103544 const struct net_device *dev,
103545 const struct net_device *slave_dev);
103546 struct net *(*get_link_net)(const struct net_device *dev);
103547-};
103548+} __do_const;
103549
103550 int __rtnl_link_register(struct rtnl_link_ops *ops);
103551 void __rtnl_link_unregister(struct rtnl_link_ops *ops);
103552diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h
103553index 4a5b9a3..ca27d73 100644
103554--- a/include/net/sctp/checksum.h
103555+++ b/include/net/sctp/checksum.h
103556@@ -61,8 +61,8 @@ static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
103557 unsigned int offset)
103558 {
103559 struct sctphdr *sh = sctp_hdr(skb);
103560- __le32 ret, old = sh->checksum;
103561- const struct skb_checksum_ops ops = {
103562+ __le32 ret, old = sh->checksum;
103563+ static const struct skb_checksum_ops ops = {
103564 .update = sctp_csum_update,
103565 .combine = sctp_csum_combine,
103566 };
103567diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
103568index 487ef34..d457f98 100644
103569--- a/include/net/sctp/sm.h
103570+++ b/include/net/sctp/sm.h
103571@@ -80,7 +80,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
103572 typedef struct {
103573 sctp_state_fn_t *fn;
103574 const char *name;
103575-} sctp_sm_table_entry_t;
103576+} __do_const sctp_sm_table_entry_t;
103577
103578 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
103579 * currently in use.
103580@@ -292,7 +292,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
103581 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
103582
103583 /* Extern declarations for major data structures. */
103584-extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
103585+extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
103586
103587
103588 /* Get the size of a DATA chunk payload. */
103589diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
103590index 495c87e..5b327ff 100644
103591--- a/include/net/sctp/structs.h
103592+++ b/include/net/sctp/structs.h
103593@@ -513,7 +513,7 @@ struct sctp_pf {
103594 void (*to_sk_saddr)(union sctp_addr *, struct sock *sk);
103595 void (*to_sk_daddr)(union sctp_addr *, struct sock *sk);
103596 struct sctp_af *af;
103597-};
103598+} __do_const;
103599
103600
103601 /* Structure to track chunk fragments that have been acked, but peer
103602diff --git a/include/net/sock.h b/include/net/sock.h
103603index 4ca4c3f..1573f47 100644
103604--- a/include/net/sock.h
103605+++ b/include/net/sock.h
103606@@ -198,7 +198,7 @@ struct sock_common {
103607 struct in6_addr skc_v6_rcv_saddr;
103608 #endif
103609
103610- atomic64_t skc_cookie;
103611+ atomic64_unchecked_t skc_cookie;
103612
103613 /*
103614 * fields between dontcopy_begin/dontcopy_end
103615@@ -364,7 +364,7 @@ struct sock {
103616 unsigned int sk_napi_id;
103617 unsigned int sk_ll_usec;
103618 #endif
103619- atomic_t sk_drops;
103620+ atomic_unchecked_t sk_drops;
103621 int sk_rcvbuf;
103622
103623 struct sk_filter __rcu *sk_filter;
103624@@ -1046,7 +1046,7 @@ struct proto {
103625 void (*destroy_cgroup)(struct mem_cgroup *memcg);
103626 struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg);
103627 #endif
103628-};
103629+} __randomize_layout;
103630
103631 /*
103632 * Bits in struct cg_proto.flags
103633@@ -1219,7 +1219,7 @@ static inline void memcg_memory_allocated_sub(struct cg_proto *prot,
103634 page_counter_uncharge(&prot->memory_allocated, amt);
103635 }
103636
103637-static inline long
103638+static inline long __intentional_overflow(-1)
103639 sk_memory_allocated(const struct sock *sk)
103640 {
103641 struct proto *prot = sk->sk_prot;
103642@@ -1784,7 +1784,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
103643 }
103644
103645 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
103646- struct iov_iter *from, char *to,
103647+ struct iov_iter *from, unsigned char *to,
103648 int copy, int offset)
103649 {
103650 if (skb->ip_summed == CHECKSUM_NONE) {
103651@@ -2031,7 +2031,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
103652 }
103653 }
103654
103655-struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
103656+struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
103657 bool force_schedule);
103658
103659 /**
103660@@ -2107,7 +2107,7 @@ struct sock_skb_cb {
103661 static inline void
103662 sock_skb_set_dropcount(const struct sock *sk, struct sk_buff *skb)
103663 {
103664- SOCK_SKB_CB(skb)->dropcount = atomic_read(&sk->sk_drops);
103665+ SOCK_SKB_CB(skb)->dropcount = atomic_read_unchecked(&sk->sk_drops);
103666 }
103667
103668 void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
103669diff --git a/include/net/tcp.h b/include/net/tcp.h
103670index 950cfec..0bf9d85 100644
103671--- a/include/net/tcp.h
103672+++ b/include/net/tcp.h
103673@@ -546,7 +546,7 @@ void tcp_retransmit_timer(struct sock *sk);
103674 void tcp_xmit_retransmit_queue(struct sock *);
103675 void tcp_simple_retransmit(struct sock *);
103676 int tcp_trim_head(struct sock *, struct sk_buff *, u32);
103677-int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int, gfp_t);
103678+int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int, gfp_t) __intentional_overflow(3);
103679
103680 void tcp_send_probe0(struct sock *);
103681 void tcp_send_partial(struct sock *);
103682@@ -724,8 +724,8 @@ static inline u32 tcp_skb_timestamp(const struct sk_buff *skb)
103683 * If this grows please adjust skbuff.h:skbuff->cb[xxx] size appropriately.
103684 */
103685 struct tcp_skb_cb {
103686- __u32 seq; /* Starting sequence number */
103687- __u32 end_seq; /* SEQ + FIN + SYN + datalen */
103688+ __u32 seq __intentional_overflow(-1); /* Starting sequence number */
103689+ __u32 end_seq __intentional_overflow(-1); /* SEQ + FIN + SYN + datalen */
103690 union {
103691 /* Note : tcp_tw_isn is used in input path only
103692 * (isn chosen by tcp_timewait_state_process())
103693@@ -753,7 +753,7 @@ struct tcp_skb_cb {
103694
103695 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
103696 /* 1 byte hole */
103697- __u32 ack_seq; /* Sequence number ACK'd */
103698+ __u32 ack_seq __intentional_overflow(-1); /* Sequence number ACK'd */
103699 union {
103700 struct inet_skb_parm h4;
103701 #if IS_ENABLED(CONFIG_IPV6)
103702diff --git a/include/net/xfrm.h b/include/net/xfrm.h
103703index f0ee97e..73e2b5a 100644
103704--- a/include/net/xfrm.h
103705+++ b/include/net/xfrm.h
103706@@ -284,7 +284,6 @@ struct xfrm_dst;
103707 struct xfrm_policy_afinfo {
103708 unsigned short family;
103709 struct dst_ops *dst_ops;
103710- void (*garbage_collect)(struct net *net);
103711 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
103712 const xfrm_address_t *saddr,
103713 const xfrm_address_t *daddr);
103714@@ -302,7 +301,7 @@ struct xfrm_policy_afinfo {
103715 struct net_device *dev,
103716 const struct flowi *fl);
103717 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
103718-};
103719+} __do_const;
103720
103721 int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
103722 int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
103723@@ -341,7 +340,7 @@ struct xfrm_state_afinfo {
103724 int (*transport_finish)(struct sk_buff *skb,
103725 int async);
103726 void (*local_error)(struct sk_buff *skb, u32 mtu);
103727-};
103728+} __do_const;
103729
103730 int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
103731 int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
103732@@ -436,7 +435,7 @@ struct xfrm_mode {
103733 struct module *owner;
103734 unsigned int encap;
103735 int flags;
103736-};
103737+} __do_const;
103738
103739 /* Flags for xfrm_mode. */
103740 enum {
103741@@ -531,7 +530,7 @@ struct xfrm_policy {
103742 struct timer_list timer;
103743
103744 struct flow_cache_object flo;
103745- atomic_t genid;
103746+ atomic_unchecked_t genid;
103747 u32 priority;
103748 u32 index;
103749 struct xfrm_mark mark;
103750@@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
103751 }
103752
103753 void xfrm_garbage_collect(struct net *net);
103754+void xfrm_garbage_collect_deferred(struct net *net);
103755
103756 #else
103757
103758@@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
103759 static inline void xfrm_garbage_collect(struct net *net)
103760 {
103761 }
103762+static inline void xfrm_garbage_collect_deferred(struct net *net)
103763+{
103764+}
103765 #endif
103766
103767 static __inline__
103768diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
103769index 036bd27..c0d7f17 100644
103770--- a/include/rdma/iw_cm.h
103771+++ b/include/rdma/iw_cm.h
103772@@ -123,7 +123,7 @@ struct iw_cm_verbs {
103773 int backlog);
103774
103775 int (*destroy_listen)(struct iw_cm_id *cm_id);
103776-};
103777+} __no_const;
103778
103779 /**
103780 * iw_create_cm_id - Create an IW CM identifier.
103781diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
103782index 93d14da..734b3d8 100644
103783--- a/include/scsi/libfc.h
103784+++ b/include/scsi/libfc.h
103785@@ -771,6 +771,7 @@ struct libfc_function_template {
103786 */
103787 void (*disc_stop_final) (struct fc_lport *);
103788 };
103789+typedef struct libfc_function_template __no_const libfc_function_template_no_const;
103790
103791 /**
103792 * struct fc_disc - Discovery context
103793@@ -875,7 +876,7 @@ struct fc_lport {
103794 struct fc_vport *vport;
103795
103796 /* Operational Information */
103797- struct libfc_function_template tt;
103798+ libfc_function_template_no_const tt;
103799 u8 link_up;
103800 u8 qfull;
103801 enum fc_lport_state state;
103802diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
103803index ae84b22..7954097 100644
103804--- a/include/scsi/scsi_device.h
103805+++ b/include/scsi/scsi_device.h
103806@@ -185,9 +185,9 @@ struct scsi_device {
103807 unsigned int max_device_blocked; /* what device_blocked counts down from */
103808 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
103809
103810- atomic_t iorequest_cnt;
103811- atomic_t iodone_cnt;
103812- atomic_t ioerr_cnt;
103813+ atomic_unchecked_t iorequest_cnt;
103814+ atomic_unchecked_t iodone_cnt;
103815+ atomic_unchecked_t ioerr_cnt;
103816
103817 struct device sdev_gendev,
103818 sdev_dev;
103819diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h
103820index 891a658..fcd68df 100644
103821--- a/include/scsi/scsi_driver.h
103822+++ b/include/scsi/scsi_driver.h
103823@@ -14,7 +14,7 @@ struct scsi_driver {
103824 void (*rescan)(struct device *);
103825 int (*init_command)(struct scsi_cmnd *);
103826 void (*uninit_command)(struct scsi_cmnd *);
103827- int (*done)(struct scsi_cmnd *);
103828+ unsigned int (*done)(struct scsi_cmnd *);
103829 int (*eh_action)(struct scsi_cmnd *, int);
103830 };
103831 #define to_scsi_driver(drv) \
103832diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
103833index 784bc2c..855a04c 100644
103834--- a/include/scsi/scsi_transport_fc.h
103835+++ b/include/scsi/scsi_transport_fc.h
103836@@ -757,7 +757,8 @@ struct fc_function_template {
103837 unsigned long show_host_system_hostname:1;
103838
103839 unsigned long disable_target_scan:1;
103840-};
103841+} __do_const;
103842+typedef struct fc_function_template __no_const fc_function_template_no_const;
103843
103844
103845 /**
103846diff --git a/include/scsi/sg.h b/include/scsi/sg.h
103847index 3afec70..b196b43 100644
103848--- a/include/scsi/sg.h
103849+++ b/include/scsi/sg.h
103850@@ -52,7 +52,7 @@ typedef struct sg_io_hdr
103851 or scatter gather list */
103852 unsigned char __user *cmdp; /* [i], [*i] points to command to perform */
103853 void __user *sbp; /* [i], [*o] points to sense_buffer memory */
103854- unsigned int timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
103855+ unsigned int timeout __intentional_overflow(-1); /* [i] MAX_UINT->no timeout (unit: millisec) */
103856 unsigned int flags; /* [i] 0 -> default, see SG_FLAG... */
103857 int pack_id; /* [i->o] unused internally (normally) */
103858 void __user * usr_ptr; /* [i->o] unused internally */
103859diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
103860index fa1d055..3647940 100644
103861--- a/include/sound/compress_driver.h
103862+++ b/include/sound/compress_driver.h
103863@@ -130,7 +130,7 @@ struct snd_compr_ops {
103864 struct snd_compr_caps *caps);
103865 int (*get_codec_caps) (struct snd_compr_stream *stream,
103866 struct snd_compr_codec_caps *codec);
103867-};
103868+} __no_const;
103869
103870 /**
103871 * struct snd_compr: Compressed device
103872diff --git a/include/sound/soc.h b/include/sound/soc.h
103873index 93df8bf..c84577b 100644
103874--- a/include/sound/soc.h
103875+++ b/include/sound/soc.h
103876@@ -883,7 +883,7 @@ struct snd_soc_codec_driver {
103877 enum snd_soc_dapm_type, int);
103878
103879 bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */
103880-};
103881+} __do_const;
103882
103883 /* SoC platform interface */
103884 struct snd_soc_platform_driver {
103885@@ -910,7 +910,7 @@ struct snd_soc_platform_driver {
103886 const struct snd_compr_ops *compr_ops;
103887
103888 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
103889-};
103890+} __do_const;
103891
103892 struct snd_soc_dai_link_component {
103893 const char *name;
103894diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
103895index 17ae2d6..2c06382 100644
103896--- a/include/target/target_core_base.h
103897+++ b/include/target/target_core_base.h
103898@@ -751,7 +751,7 @@ struct se_device {
103899 atomic_long_t write_bytes;
103900 /* Active commands on this virtual SE device */
103901 atomic_t simple_cmds;
103902- atomic_t dev_ordered_id;
103903+ atomic_unchecked_t dev_ordered_id;
103904 atomic_t dev_ordered_sync;
103905 atomic_t dev_qf_count;
103906 u32 export_count;
103907diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
103908new file mode 100644
103909index 0000000..fb634b7
103910--- /dev/null
103911+++ b/include/trace/events/fs.h
103912@@ -0,0 +1,53 @@
103913+#undef TRACE_SYSTEM
103914+#define TRACE_SYSTEM fs
103915+
103916+#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
103917+#define _TRACE_FS_H
103918+
103919+#include <linux/fs.h>
103920+#include <linux/tracepoint.h>
103921+
103922+TRACE_EVENT(do_sys_open,
103923+
103924+ TP_PROTO(const char *filename, int flags, int mode),
103925+
103926+ TP_ARGS(filename, flags, mode),
103927+
103928+ TP_STRUCT__entry(
103929+ __string( filename, filename )
103930+ __field( int, flags )
103931+ __field( int, mode )
103932+ ),
103933+
103934+ TP_fast_assign(
103935+ __assign_str(filename, filename);
103936+ __entry->flags = flags;
103937+ __entry->mode = mode;
103938+ ),
103939+
103940+ TP_printk("\"%s\" %x %o",
103941+ __get_str(filename), __entry->flags, __entry->mode)
103942+);
103943+
103944+TRACE_EVENT(open_exec,
103945+
103946+ TP_PROTO(const char *filename),
103947+
103948+ TP_ARGS(filename),
103949+
103950+ TP_STRUCT__entry(
103951+ __string( filename, filename )
103952+ ),
103953+
103954+ TP_fast_assign(
103955+ __assign_str(filename, filename);
103956+ ),
103957+
103958+ TP_printk("\"%s\"",
103959+ __get_str(filename))
103960+);
103961+
103962+#endif /* _TRACE_FS_H */
103963+
103964+/* This part must be outside protection */
103965+#include <trace/define_trace.h>
103966diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
103967index ff8f6c0..6b6bae3 100644
103968--- a/include/trace/events/irq.h
103969+++ b/include/trace/events/irq.h
103970@@ -51,7 +51,7 @@ SOFTIRQ_NAME_LIST
103971 */
103972 TRACE_EVENT(irq_handler_entry,
103973
103974- TP_PROTO(int irq, struct irqaction *action),
103975+ TP_PROTO(int irq, const struct irqaction *action),
103976
103977 TP_ARGS(irq, action),
103978
103979@@ -81,7 +81,7 @@ TRACE_EVENT(irq_handler_entry,
103980 */
103981 TRACE_EVENT(irq_handler_exit,
103982
103983- TP_PROTO(int irq, struct irqaction *action, int ret),
103984+ TP_PROTO(int irq, const struct irqaction *action, int ret),
103985
103986 TP_ARGS(irq, action, ret),
103987
103988diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
103989index db809b7..05a44aa 100644
103990--- a/include/uapi/drm/i915_drm.h
103991+++ b/include/uapi/drm/i915_drm.h
103992@@ -354,6 +354,7 @@ typedef struct drm_i915_irq_wait {
103993 #define I915_PARAM_REVISION 32
103994 #define I915_PARAM_SUBSLICE_TOTAL 33
103995 #define I915_PARAM_EU_TOTAL 34
103996+#define I915_PARAM_HAS_LEGACY_CONTEXT 35
103997
103998 typedef struct drm_i915_getparam {
103999 int param;
104000diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
104001index 7caf44c..23c6f27 100644
104002--- a/include/uapi/linux/a.out.h
104003+++ b/include/uapi/linux/a.out.h
104004@@ -39,6 +39,14 @@ enum machine_type {
104005 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
104006 };
104007
104008+/* Constants for the N_FLAGS field */
104009+#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
104010+#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
104011+#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
104012+#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
104013+/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
104014+#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
104015+
104016 #if !defined (N_MAGIC)
104017 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
104018 #endif
104019diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
104020index 22b6ad3..aeba37e 100644
104021--- a/include/uapi/linux/bcache.h
104022+++ b/include/uapi/linux/bcache.h
104023@@ -5,6 +5,7 @@
104024 * Bcache on disk data structures
104025 */
104026
104027+#include <linux/compiler.h>
104028 #include <asm/types.h>
104029
104030 #define BITMASK(name, type, field, offset, size) \
104031@@ -20,8 +21,8 @@ static inline void SET_##name(type *k, __u64 v) \
104032 /* Btree keys - all units are in sectors */
104033
104034 struct bkey {
104035- __u64 high;
104036- __u64 low;
104037+ __u64 high __intentional_overflow(-1);
104038+ __u64 low __intentional_overflow(-1);
104039 __u64 ptr[];
104040 };
104041
104042diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
104043index d876736..ccce5c0 100644
104044--- a/include/uapi/linux/byteorder/little_endian.h
104045+++ b/include/uapi/linux/byteorder/little_endian.h
104046@@ -42,51 +42,51 @@
104047
104048 static inline __le64 __cpu_to_le64p(const __u64 *p)
104049 {
104050- return (__force __le64)*p;
104051+ return (__force const __le64)*p;
104052 }
104053-static inline __u64 __le64_to_cpup(const __le64 *p)
104054+static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
104055 {
104056- return (__force __u64)*p;
104057+ return (__force const __u64)*p;
104058 }
104059 static inline __le32 __cpu_to_le32p(const __u32 *p)
104060 {
104061- return (__force __le32)*p;
104062+ return (__force const __le32)*p;
104063 }
104064 static inline __u32 __le32_to_cpup(const __le32 *p)
104065 {
104066- return (__force __u32)*p;
104067+ return (__force const __u32)*p;
104068 }
104069 static inline __le16 __cpu_to_le16p(const __u16 *p)
104070 {
104071- return (__force __le16)*p;
104072+ return (__force const __le16)*p;
104073 }
104074 static inline __u16 __le16_to_cpup(const __le16 *p)
104075 {
104076- return (__force __u16)*p;
104077+ return (__force const __u16)*p;
104078 }
104079 static inline __be64 __cpu_to_be64p(const __u64 *p)
104080 {
104081- return (__force __be64)__swab64p(p);
104082+ return (__force const __be64)__swab64p(p);
104083 }
104084 static inline __u64 __be64_to_cpup(const __be64 *p)
104085 {
104086- return __swab64p((__u64 *)p);
104087+ return __swab64p((const __u64 *)p);
104088 }
104089 static inline __be32 __cpu_to_be32p(const __u32 *p)
104090 {
104091- return (__force __be32)__swab32p(p);
104092+ return (__force const __be32)__swab32p(p);
104093 }
104094-static inline __u32 __be32_to_cpup(const __be32 *p)
104095+static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
104096 {
104097- return __swab32p((__u32 *)p);
104098+ return __swab32p((const __u32 *)p);
104099 }
104100 static inline __be16 __cpu_to_be16p(const __u16 *p)
104101 {
104102- return (__force __be16)__swab16p(p);
104103+ return (__force const __be16)__swab16p(p);
104104 }
104105 static inline __u16 __be16_to_cpup(const __be16 *p)
104106 {
104107- return __swab16p((__u16 *)p);
104108+ return __swab16p((const __u16 *)p);
104109 }
104110 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
104111 #define __le64_to_cpus(x) do { (void)(x); } while (0)
104112diff --git a/include/uapi/linux/connector.h b/include/uapi/linux/connector.h
104113index 4cb2835..cfbc4e2 100644
104114--- a/include/uapi/linux/connector.h
104115+++ b/include/uapi/linux/connector.h
104116@@ -69,7 +69,7 @@ struct cb_id {
104117 struct cn_msg {
104118 struct cb_id id;
104119
104120- __u32 seq;
104121+ __u32 seq __intentional_overflow(-1);
104122 __u32 ack;
104123
104124 __u16 len; /* Length of the following data */
104125diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
104126index 71e1d0e..6cc9caf 100644
104127--- a/include/uapi/linux/elf.h
104128+++ b/include/uapi/linux/elf.h
104129@@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
104130 #define PT_GNU_EH_FRAME 0x6474e550
104131
104132 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
104133+#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
104134+
104135+#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
104136+
104137+/* Constants for the e_flags field */
104138+#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
104139+#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
104140+#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
104141+#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
104142+/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
104143+#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
104144
104145 /*
104146 * Extended Numbering
104147@@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
104148 #define DT_DEBUG 21
104149 #define DT_TEXTREL 22
104150 #define DT_JMPREL 23
104151+#define DT_FLAGS 30
104152+ #define DF_TEXTREL 0x00000004
104153 #define DT_ENCODING 32
104154 #define OLD_DT_LOOS 0x60000000
104155 #define DT_LOOS 0x6000000d
104156@@ -240,6 +253,19 @@ typedef struct elf64_hdr {
104157 #define PF_W 0x2
104158 #define PF_X 0x1
104159
104160+#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
104161+#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
104162+#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
104163+#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
104164+#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
104165+#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
104166+/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
104167+/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
104168+#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
104169+#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
104170+#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
104171+#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
104172+
104173 typedef struct elf32_phdr{
104174 Elf32_Word p_type;
104175 Elf32_Off p_offset;
104176@@ -332,6 +358,8 @@ typedef struct elf64_shdr {
104177 #define EI_OSABI 7
104178 #define EI_PAD 8
104179
104180+#define EI_PAX 14
104181+
104182 #define ELFMAG0 0x7f /* EI_MAG */
104183 #define ELFMAG1 'E'
104184 #define ELFMAG2 'L'
104185diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
104186index aa169c4..6a2771d 100644
104187--- a/include/uapi/linux/personality.h
104188+++ b/include/uapi/linux/personality.h
104189@@ -30,6 +30,7 @@ enum {
104190 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
104191 ADDR_NO_RANDOMIZE | \
104192 ADDR_COMPAT_LAYOUT | \
104193+ ADDR_LIMIT_3GB | \
104194 MMAP_PAGE_ZERO)
104195
104196 /*
104197diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
104198index 7530e74..e714828 100644
104199--- a/include/uapi/linux/screen_info.h
104200+++ b/include/uapi/linux/screen_info.h
104201@@ -43,7 +43,8 @@ struct screen_info {
104202 __u16 pages; /* 0x32 */
104203 __u16 vesa_attributes; /* 0x34 */
104204 __u32 capabilities; /* 0x36 */
104205- __u8 _reserved[6]; /* 0x3a */
104206+ __u16 vesapm_size; /* 0x3a */
104207+ __u8 _reserved[4]; /* 0x3c */
104208 } __attribute__((packed));
104209
104210 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
104211diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
104212index 0e011eb..82681b1 100644
104213--- a/include/uapi/linux/swab.h
104214+++ b/include/uapi/linux/swab.h
104215@@ -43,7 +43,7 @@
104216 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
104217 */
104218
104219-static inline __attribute_const__ __u16 __fswab16(__u16 val)
104220+static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
104221 {
104222 #ifdef __HAVE_BUILTIN_BSWAP16__
104223 return __builtin_bswap16(val);
104224@@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
104225 #endif
104226 }
104227
104228-static inline __attribute_const__ __u32 __fswab32(__u32 val)
104229+static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
104230 {
104231 #ifdef __HAVE_BUILTIN_BSWAP32__
104232 return __builtin_bswap32(val);
104233@@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
104234 #endif
104235 }
104236
104237-static inline __attribute_const__ __u64 __fswab64(__u64 val)
104238+static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
104239 {
104240 #ifdef __HAVE_BUILTIN_BSWAP64__
104241 return __builtin_bswap64(val);
104242diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
104243index 1590c49..5eab462 100644
104244--- a/include/uapi/linux/xattr.h
104245+++ b/include/uapi/linux/xattr.h
104246@@ -73,5 +73,9 @@
104247 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
104248 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
104249
104250+/* User namespace */
104251+#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
104252+#define XATTR_PAX_FLAGS_SUFFIX "flags"
104253+#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
104254
104255 #endif /* _UAPI_LINUX_XATTR_H */
104256diff --git a/include/video/udlfb.h b/include/video/udlfb.h
104257index f9466fa..f4e2b81 100644
104258--- a/include/video/udlfb.h
104259+++ b/include/video/udlfb.h
104260@@ -53,10 +53,10 @@ struct dlfb_data {
104261 u32 pseudo_palette[256];
104262 int blank_mode; /*one of FB_BLANK_ */
104263 /* blit-only rendering path metrics, exposed through sysfs */
104264- atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
104265- atomic_t bytes_identical; /* saved effort with backbuffer comparison */
104266- atomic_t bytes_sent; /* to usb, after compression including overhead */
104267- atomic_t cpu_kcycles_used; /* transpired during pixel processing */
104268+ atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
104269+ atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
104270+ atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
104271+ atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
104272 };
104273
104274 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
104275diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
104276index 30f5362..8ed8ac9 100644
104277--- a/include/video/uvesafb.h
104278+++ b/include/video/uvesafb.h
104279@@ -122,6 +122,7 @@ struct uvesafb_par {
104280 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
104281 u8 pmi_setpal; /* PMI for palette changes */
104282 u16 *pmi_base; /* protected mode interface location */
104283+ u8 *pmi_code; /* protected mode code location */
104284 void *pmi_start;
104285 void *pmi_pal;
104286 u8 *vbe_state_orig; /*
104287diff --git a/init/Kconfig b/init/Kconfig
104288index af09b4f..5ee6e6a 100644
104289--- a/init/Kconfig
104290+++ b/init/Kconfig
104291@@ -642,6 +642,7 @@ config RCU_FAST_NO_HZ
104292 config TREE_RCU_TRACE
104293 def_bool RCU_TRACE && ( TREE_RCU || PREEMPT_RCU )
104294 select DEBUG_FS
104295+ depends on !GRKERNSEC_KMEM
104296 help
104297 This option provides tracing for the TREE_RCU and
104298 PREEMPT_RCU implementations, permitting Makefile to
104299@@ -1139,6 +1140,7 @@ endif # CGROUPS
104300 config CHECKPOINT_RESTORE
104301 bool "Checkpoint/restore support" if EXPERT
104302 select PROC_CHILDREN
104303+ depends on !GRKERNSEC
104304 default n
104305 help
104306 Enables additional kernel features in a sake of checkpoint/restore.
104307@@ -1664,7 +1666,7 @@ config SLUB_DEBUG
104308
104309 config COMPAT_BRK
104310 bool "Disable heap randomization"
104311- default y
104312+ default n
104313 help
104314 Randomizing heap placement makes heap exploits harder, but it
104315 also breaks ancient binaries (including anything libc5 based).
104316@@ -1994,7 +1996,7 @@ config INIT_ALL_POSSIBLE
104317 config STOP_MACHINE
104318 bool
104319 default y
104320- depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
104321+ depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
104322 help
104323 Need stop_machine() primitive.
104324
104325diff --git a/init/Makefile b/init/Makefile
104326index 7bc47ee..6da2dc7 100644
104327--- a/init/Makefile
104328+++ b/init/Makefile
104329@@ -2,6 +2,9 @@
104330 # Makefile for the linux kernel.
104331 #
104332
104333+ccflags-y := $(GCC_PLUGINS_CFLAGS)
104334+asflags-y := $(GCC_PLUGINS_AFLAGS)
104335+
104336 obj-y := main.o version.o mounts.o
104337 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
104338 obj-y += noinitramfs.o
104339diff --git a/init/do_mounts.c b/init/do_mounts.c
104340index dea5de9..bbdbb5f 100644
104341--- a/init/do_mounts.c
104342+++ b/init/do_mounts.c
104343@@ -363,11 +363,11 @@ static void __init get_fs_names(char *page)
104344 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
104345 {
104346 struct super_block *s;
104347- int err = sys_mount(name, "/root", fs, flags, data);
104348+ int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
104349 if (err)
104350 return err;
104351
104352- sys_chdir("/root");
104353+ sys_chdir((const char __force_user *)"/root");
104354 s = current->fs->pwd.dentry->d_sb;
104355 ROOT_DEV = s->s_dev;
104356 printk(KERN_INFO
104357@@ -490,18 +490,18 @@ void __init change_floppy(char *fmt, ...)
104358 va_start(args, fmt);
104359 vsprintf(buf, fmt, args);
104360 va_end(args);
104361- fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
104362+ fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
104363 if (fd >= 0) {
104364 sys_ioctl(fd, FDEJECT, 0);
104365 sys_close(fd);
104366 }
104367 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
104368- fd = sys_open("/dev/console", O_RDWR, 0);
104369+ fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
104370 if (fd >= 0) {
104371 sys_ioctl(fd, TCGETS, (long)&termios);
104372 termios.c_lflag &= ~ICANON;
104373 sys_ioctl(fd, TCSETSF, (long)&termios);
104374- sys_read(fd, &c, 1);
104375+ sys_read(fd, (char __user *)&c, 1);
104376 termios.c_lflag |= ICANON;
104377 sys_ioctl(fd, TCSETSF, (long)&termios);
104378 sys_close(fd);
104379@@ -600,8 +600,8 @@ void __init prepare_namespace(void)
104380 mount_root();
104381 out:
104382 devtmpfs_mount("dev");
104383- sys_mount(".", "/", NULL, MS_MOVE, NULL);
104384- sys_chroot(".");
104385+ sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
104386+ sys_chroot((const char __force_user *)".");
104387 }
104388
104389 static bool is_tmpfs;
104390diff --git a/init/do_mounts.h b/init/do_mounts.h
104391index f5b978a..69dbfe8 100644
104392--- a/init/do_mounts.h
104393+++ b/init/do_mounts.h
104394@@ -15,15 +15,15 @@ extern int root_mountflags;
104395
104396 static inline int create_dev(char *name, dev_t dev)
104397 {
104398- sys_unlink(name);
104399- return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
104400+ sys_unlink((char __force_user *)name);
104401+ return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
104402 }
104403
104404 #if BITS_PER_LONG == 32
104405 static inline u32 bstat(char *name)
104406 {
104407 struct stat64 stat;
104408- if (sys_stat64(name, &stat) != 0)
104409+ if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
104410 return 0;
104411 if (!S_ISBLK(stat.st_mode))
104412 return 0;
104413@@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
104414 static inline u32 bstat(char *name)
104415 {
104416 struct stat stat;
104417- if (sys_newstat(name, &stat) != 0)
104418+ if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
104419 return 0;
104420 if (!S_ISBLK(stat.st_mode))
104421 return 0;
104422diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
104423index 3e0878e..8a9d7a0 100644
104424--- a/init/do_mounts_initrd.c
104425+++ b/init/do_mounts_initrd.c
104426@@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
104427 {
104428 sys_unshare(CLONE_FS | CLONE_FILES);
104429 /* stdin/stdout/stderr for /linuxrc */
104430- sys_open("/dev/console", O_RDWR, 0);
104431+ sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
104432 sys_dup(0);
104433 sys_dup(0);
104434 /* move initrd over / and chdir/chroot in initrd root */
104435- sys_chdir("/root");
104436- sys_mount(".", "/", NULL, MS_MOVE, NULL);
104437- sys_chroot(".");
104438+ sys_chdir((const char __force_user *)"/root");
104439+ sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
104440+ sys_chroot((const char __force_user *)".");
104441 sys_setsid();
104442 return 0;
104443 }
104444@@ -59,8 +59,8 @@ static void __init handle_initrd(void)
104445 create_dev("/dev/root.old", Root_RAM0);
104446 /* mount initrd on rootfs' /root */
104447 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
104448- sys_mkdir("/old", 0700);
104449- sys_chdir("/old");
104450+ sys_mkdir((const char __force_user *)"/old", 0700);
104451+ sys_chdir((const char __force_user *)"/old");
104452
104453 /* try loading default modules from initrd */
104454 load_default_modules();
104455@@ -80,31 +80,31 @@ static void __init handle_initrd(void)
104456 current->flags &= ~PF_FREEZER_SKIP;
104457
104458 /* move initrd to rootfs' /old */
104459- sys_mount("..", ".", NULL, MS_MOVE, NULL);
104460+ sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
104461 /* switch root and cwd back to / of rootfs */
104462- sys_chroot("..");
104463+ sys_chroot((const char __force_user *)"..");
104464
104465 if (new_decode_dev(real_root_dev) == Root_RAM0) {
104466- sys_chdir("/old");
104467+ sys_chdir((const char __force_user *)"/old");
104468 return;
104469 }
104470
104471- sys_chdir("/");
104472+ sys_chdir((const char __force_user *)"/");
104473 ROOT_DEV = new_decode_dev(real_root_dev);
104474 mount_root();
104475
104476 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
104477- error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
104478+ error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
104479 if (!error)
104480 printk("okay\n");
104481 else {
104482- int fd = sys_open("/dev/root.old", O_RDWR, 0);
104483+ int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
104484 if (error == -ENOENT)
104485 printk("/initrd does not exist. Ignored.\n");
104486 else
104487 printk("failed\n");
104488 printk(KERN_NOTICE "Unmounting old root\n");
104489- sys_umount("/old", MNT_DETACH);
104490+ sys_umount((char __force_user *)"/old", MNT_DETACH);
104491 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
104492 if (fd < 0) {
104493 error = fd;
104494@@ -127,11 +127,11 @@ int __init initrd_load(void)
104495 * mounted in the normal path.
104496 */
104497 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
104498- sys_unlink("/initrd.image");
104499+ sys_unlink((const char __force_user *)"/initrd.image");
104500 handle_initrd();
104501 return 1;
104502 }
104503 }
104504- sys_unlink("/initrd.image");
104505+ sys_unlink((const char __force_user *)"/initrd.image");
104506 return 0;
104507 }
104508diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
104509index 8cb6db5..d729f50 100644
104510--- a/init/do_mounts_md.c
104511+++ b/init/do_mounts_md.c
104512@@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
104513 partitioned ? "_d" : "", minor,
104514 md_setup_args[ent].device_names);
104515
104516- fd = sys_open(name, 0, 0);
104517+ fd = sys_open((char __force_user *)name, 0, 0);
104518 if (fd < 0) {
104519 printk(KERN_ERR "md: open failed - cannot start "
104520 "array %s\n", name);
104521@@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
104522 * array without it
104523 */
104524 sys_close(fd);
104525- fd = sys_open(name, 0, 0);
104526+ fd = sys_open((char __force_user *)name, 0, 0);
104527 sys_ioctl(fd, BLKRRPART, 0);
104528 }
104529 sys_close(fd);
104530@@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
104531
104532 wait_for_device_probe();
104533
104534- fd = sys_open("/dev/md0", 0, 0);
104535+ fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
104536 if (fd >= 0) {
104537 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
104538 sys_close(fd);
104539diff --git a/init/init_task.c b/init/init_task.c
104540index ba0a7f36..2bcf1d5 100644
104541--- a/init/init_task.c
104542+++ b/init/init_task.c
104543@@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
104544 * Initial thread structure. Alignment of this is handled by a special
104545 * linker map entry.
104546 */
104547+#ifdef CONFIG_X86
104548+union thread_union init_thread_union __init_task_data;
104549+#else
104550 union thread_union init_thread_union __init_task_data =
104551 { INIT_THREAD_INFO(init_task) };
104552+#endif
104553diff --git a/init/initramfs.c b/init/initramfs.c
104554index ad1bd77..dca2c1b 100644
104555--- a/init/initramfs.c
104556+++ b/init/initramfs.c
104557@@ -25,7 +25,7 @@ static ssize_t __init xwrite(int fd, const char *p, size_t count)
104558
104559 /* sys_write only can write MAX_RW_COUNT aka 2G-4K bytes at most */
104560 while (count) {
104561- ssize_t rv = sys_write(fd, p, count);
104562+ ssize_t rv = sys_write(fd, (char __force_user *)p, count);
104563
104564 if (rv < 0) {
104565 if (rv == -EINTR || rv == -EAGAIN)
104566@@ -107,7 +107,7 @@ static void __init free_hash(void)
104567 }
104568 }
104569
104570-static long __init do_utime(char *filename, time_t mtime)
104571+static long __init do_utime(char __force_user *filename, time_t mtime)
104572 {
104573 struct timespec t[2];
104574
104575@@ -142,7 +142,7 @@ static void __init dir_utime(void)
104576 struct dir_entry *de, *tmp;
104577 list_for_each_entry_safe(de, tmp, &dir_list, list) {
104578 list_del(&de->list);
104579- do_utime(de->name, de->mtime);
104580+ do_utime((char __force_user *)de->name, de->mtime);
104581 kfree(de->name);
104582 kfree(de);
104583 }
104584@@ -304,7 +304,7 @@ static int __init maybe_link(void)
104585 if (nlink >= 2) {
104586 char *old = find_link(major, minor, ino, mode, collected);
104587 if (old)
104588- return (sys_link(old, collected) < 0) ? -1 : 1;
104589+ return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
104590 }
104591 return 0;
104592 }
104593@@ -313,11 +313,11 @@ static void __init clean_path(char *path, umode_t fmode)
104594 {
104595 struct stat st;
104596
104597- if (!sys_newlstat(path, &st) && (st.st_mode ^ fmode) & S_IFMT) {
104598+ if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode ^ fmode) & S_IFMT) {
104599 if (S_ISDIR(st.st_mode))
104600- sys_rmdir(path);
104601+ sys_rmdir((char __force_user *)path);
104602 else
104603- sys_unlink(path);
104604+ sys_unlink((char __force_user *)path);
104605 }
104606 }
104607
104608@@ -338,7 +338,7 @@ static int __init do_name(void)
104609 int openflags = O_WRONLY|O_CREAT;
104610 if (ml != 1)
104611 openflags |= O_TRUNC;
104612- wfd = sys_open(collected, openflags, mode);
104613+ wfd = sys_open((char __force_user *)collected, openflags, mode);
104614
104615 if (wfd >= 0) {
104616 sys_fchown(wfd, uid, gid);
104617@@ -350,17 +350,17 @@ static int __init do_name(void)
104618 }
104619 }
104620 } else if (S_ISDIR(mode)) {
104621- sys_mkdir(collected, mode);
104622- sys_chown(collected, uid, gid);
104623- sys_chmod(collected, mode);
104624+ sys_mkdir((char __force_user *)collected, mode);
104625+ sys_chown((char __force_user *)collected, uid, gid);
104626+ sys_chmod((char __force_user *)collected, mode);
104627 dir_add(collected, mtime);
104628 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
104629 S_ISFIFO(mode) || S_ISSOCK(mode)) {
104630 if (maybe_link() == 0) {
104631- sys_mknod(collected, mode, rdev);
104632- sys_chown(collected, uid, gid);
104633- sys_chmod(collected, mode);
104634- do_utime(collected, mtime);
104635+ sys_mknod((char __force_user *)collected, mode, rdev);
104636+ sys_chown((char __force_user *)collected, uid, gid);
104637+ sys_chmod((char __force_user *)collected, mode);
104638+ do_utime((char __force_user *)collected, mtime);
104639 }
104640 }
104641 return 0;
104642@@ -372,7 +372,7 @@ static int __init do_copy(void)
104643 if (xwrite(wfd, victim, body_len) != body_len)
104644 error("write error");
104645 sys_close(wfd);
104646- do_utime(vcollected, mtime);
104647+ do_utime((char __force_user *)vcollected, mtime);
104648 kfree(vcollected);
104649 eat(body_len);
104650 state = SkipIt;
104651@@ -390,9 +390,9 @@ static int __init do_symlink(void)
104652 {
104653 collected[N_ALIGN(name_len) + body_len] = '\0';
104654 clean_path(collected, 0);
104655- sys_symlink(collected + N_ALIGN(name_len), collected);
104656- sys_lchown(collected, uid, gid);
104657- do_utime(collected, mtime);
104658+ sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
104659+ sys_lchown((char __force_user *)collected, uid, gid);
104660+ do_utime((char __force_user *)collected, mtime);
104661 state = SkipIt;
104662 next_state = Reset;
104663 return 0;
104664diff --git a/init/main.c b/init/main.c
104665index 5650655..937d1b1 100644
104666--- a/init/main.c
104667+++ b/init/main.c
104668@@ -97,6 +97,8 @@ extern void radix_tree_init(void);
104669 static inline void mark_rodata_ro(void) { }
104670 #endif
104671
104672+extern void grsecurity_init(void);
104673+
104674 /*
104675 * Debug helper: via this flag we know that we are in 'early bootup code'
104676 * where only the boot processor is running with IRQ disabled. This means
104677@@ -158,6 +160,37 @@ static int __init set_reset_devices(char *str)
104678
104679 __setup("reset_devices", set_reset_devices);
104680
104681+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
104682+kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
104683+static int __init setup_grsec_proc_gid(char *str)
104684+{
104685+ grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
104686+ return 1;
104687+}
104688+__setup("grsec_proc_gid=", setup_grsec_proc_gid);
104689+#endif
104690+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
104691+int grsec_enable_sysfs_restrict = 1;
104692+static int __init setup_grsec_sysfs_restrict(char *str)
104693+{
104694+ if (!simple_strtol(str, NULL, 0))
104695+ grsec_enable_sysfs_restrict = 0;
104696+ return 1;
104697+}
104698+__setup("grsec_sysfs_restrict", setup_grsec_sysfs_restrict);
104699+#endif
104700+
104701+#ifdef CONFIG_PAX_SOFTMODE
104702+int pax_softmode;
104703+
104704+static int __init setup_pax_softmode(char *str)
104705+{
104706+ get_option(&str, &pax_softmode);
104707+ return 1;
104708+}
104709+__setup("pax_softmode=", setup_pax_softmode);
104710+#endif
104711+
104712 static const char *argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
104713 const char *envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
104714 static const char *panic_later, *panic_param;
104715@@ -731,7 +764,7 @@ static bool __init_or_module initcall_blacklisted(initcall_t fn)
104716 struct blacklist_entry *entry;
104717 char *fn_name;
104718
104719- fn_name = kasprintf(GFP_KERNEL, "%pf", fn);
104720+ fn_name = kasprintf(GFP_KERNEL, "%pX", fn);
104721 if (!fn_name)
104722 return false;
104723
104724@@ -783,7 +816,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
104725 {
104726 int count = preempt_count();
104727 int ret;
104728- char msgbuf[64];
104729+ const char *msg1 = "", *msg2 = "";
104730
104731 if (initcall_blacklisted(fn))
104732 return -EPERM;
104733@@ -793,18 +826,17 @@ int __init_or_module do_one_initcall(initcall_t fn)
104734 else
104735 ret = fn();
104736
104737- msgbuf[0] = 0;
104738-
104739 if (preempt_count() != count) {
104740- sprintf(msgbuf, "preemption imbalance ");
104741+ msg1 = " preemption imbalance";
104742 preempt_count_set(count);
104743 }
104744 if (irqs_disabled()) {
104745- strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
104746+ msg2 = " disabled interrupts";
104747 local_irq_enable();
104748 }
104749- WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
104750+ WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
104751
104752+ add_latent_entropy();
104753 return ret;
104754 }
104755
104756@@ -910,8 +942,8 @@ static int run_init_process(const char *init_filename)
104757 {
104758 argv_init[0] = init_filename;
104759 return do_execve(getname_kernel(init_filename),
104760- (const char __user *const __user *)argv_init,
104761- (const char __user *const __user *)envp_init);
104762+ (const char __user *const __force_user *)argv_init,
104763+ (const char __user *const __force_user *)envp_init);
104764 }
104765
104766 static int try_to_run_init_process(const char *init_filename)
104767@@ -928,6 +960,10 @@ static int try_to_run_init_process(const char *init_filename)
104768 return ret;
104769 }
104770
104771+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
104772+extern int gr_init_ran;
104773+#endif
104774+
104775 static noinline void __init kernel_init_freeable(void);
104776
104777 static int __ref kernel_init(void *unused)
104778@@ -952,6 +988,11 @@ static int __ref kernel_init(void *unused)
104779 ramdisk_execute_command, ret);
104780 }
104781
104782+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
104783+ /* if no initrd was used, be extra sure we enforce chroot restrictions */
104784+ gr_init_ran = 1;
104785+#endif
104786+
104787 /*
104788 * We try each of these until one succeeds.
104789 *
104790@@ -1009,7 +1050,7 @@ static noinline void __init kernel_init_freeable(void)
104791 do_basic_setup();
104792
104793 /* Open the /dev/console on the rootfs, this should never fail */
104794- if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
104795+ if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
104796 pr_err("Warning: unable to open an initial console.\n");
104797
104798 (void) sys_dup(0);
104799@@ -1022,11 +1063,13 @@ static noinline void __init kernel_init_freeable(void)
104800 if (!ramdisk_execute_command)
104801 ramdisk_execute_command = "/init";
104802
104803- if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
104804+ if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
104805 ramdisk_execute_command = NULL;
104806 prepare_namespace();
104807 }
104808
104809+ grsecurity_init();
104810+
104811 /*
104812 * Ok, we have completed the initial bootup, and
104813 * we're essentially up and running. Get rid of the
104814diff --git a/ipc/compat.c b/ipc/compat.c
104815index 9b3c85f..5266b0f 100644
104816--- a/ipc/compat.c
104817+++ b/ipc/compat.c
104818@@ -396,7 +396,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
104819 COMPAT_SHMLBA);
104820 if (err < 0)
104821 return err;
104822- return put_user(raddr, (compat_ulong_t *)compat_ptr(third));
104823+ return put_user(raddr, (compat_ulong_t __user *)compat_ptr(third));
104824 }
104825 case SHMDT:
104826 return sys_shmdt(compat_ptr(ptr));
104827@@ -747,7 +747,7 @@ COMPAT_SYSCALL_DEFINE3(shmctl, int, first, int, second, void __user *, uptr)
104828 }
104829
104830 COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems,
104831- unsigned, nsops,
104832+ compat_long_t, nsops,
104833 const struct compat_timespec __user *, timeout)
104834 {
104835 struct timespec __user *ts64;
104836diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
104837index 8ad93c2..efd80f8 100644
104838--- a/ipc/ipc_sysctl.c
104839+++ b/ipc/ipc_sysctl.c
104840@@ -30,7 +30,7 @@ static void *get_ipc(struct ctl_table *table)
104841 static int proc_ipc_dointvec(struct ctl_table *table, int write,
104842 void __user *buffer, size_t *lenp, loff_t *ppos)
104843 {
104844- struct ctl_table ipc_table;
104845+ ctl_table_no_const ipc_table;
104846
104847 memcpy(&ipc_table, table, sizeof(ipc_table));
104848 ipc_table.data = get_ipc(table);
104849@@ -41,7 +41,7 @@ static int proc_ipc_dointvec(struct ctl_table *table, int write,
104850 static int proc_ipc_dointvec_minmax(struct ctl_table *table, int write,
104851 void __user *buffer, size_t *lenp, loff_t *ppos)
104852 {
104853- struct ctl_table ipc_table;
104854+ ctl_table_no_const ipc_table;
104855
104856 memcpy(&ipc_table, table, sizeof(ipc_table));
104857 ipc_table.data = get_ipc(table);
104858@@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(struct ctl_table *table, int write,
104859 static int proc_ipc_doulongvec_minmax(struct ctl_table *table, int write,
104860 void __user *buffer, size_t *lenp, loff_t *ppos)
104861 {
104862- struct ctl_table ipc_table;
104863+ ctl_table_no_const ipc_table;
104864 memcpy(&ipc_table, table, sizeof(ipc_table));
104865 ipc_table.data = get_ipc(table);
104866
104867@@ -76,7 +76,7 @@ static int proc_ipc_doulongvec_minmax(struct ctl_table *table, int write,
104868 static int proc_ipc_auto_msgmni(struct ctl_table *table, int write,
104869 void __user *buffer, size_t *lenp, loff_t *ppos)
104870 {
104871- struct ctl_table ipc_table;
104872+ ctl_table_no_const ipc_table;
104873 int dummy = 0;
104874
104875 memcpy(&ipc_table, table, sizeof(ipc_table));
104876diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
104877index 68d4e95..1477ded 100644
104878--- a/ipc/mq_sysctl.c
104879+++ b/ipc/mq_sysctl.c
104880@@ -25,7 +25,7 @@ static void *get_mq(struct ctl_table *table)
104881 static int proc_mq_dointvec(struct ctl_table *table, int write,
104882 void __user *buffer, size_t *lenp, loff_t *ppos)
104883 {
104884- struct ctl_table mq_table;
104885+ ctl_table_no_const mq_table;
104886 memcpy(&mq_table, table, sizeof(mq_table));
104887 mq_table.data = get_mq(table);
104888
104889@@ -35,7 +35,7 @@ static int proc_mq_dointvec(struct ctl_table *table, int write,
104890 static int proc_mq_dointvec_minmax(struct ctl_table *table, int write,
104891 void __user *buffer, size_t *lenp, loff_t *ppos)
104892 {
104893- struct ctl_table mq_table;
104894+ ctl_table_no_const mq_table;
104895 memcpy(&mq_table, table, sizeof(mq_table));
104896 mq_table.data = get_mq(table);
104897
104898diff --git a/ipc/mqueue.c b/ipc/mqueue.c
104899index 161a180..be31d93 100644
104900--- a/ipc/mqueue.c
104901+++ b/ipc/mqueue.c
104902@@ -274,6 +274,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
104903 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
104904 info->attr.mq_msgsize);
104905
104906+ gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
104907 spin_lock(&mq_lock);
104908 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
104909 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
104910diff --git a/ipc/sem.c b/ipc/sem.c
104911index b471e5a..89aef1d 100644
104912--- a/ipc/sem.c
104913+++ b/ipc/sem.c
104914@@ -1790,7 +1790,7 @@ static int get_queue_result(struct sem_queue *q)
104915 }
104916
104917 SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
104918- unsigned, nsops, const struct timespec __user *, timeout)
104919+ long, nsops, const struct timespec __user *, timeout)
104920 {
104921 int error = -EINVAL;
104922 struct sem_array *sma;
104923@@ -2025,7 +2025,7 @@ out_free:
104924 }
104925
104926 SYSCALL_DEFINE3(semop, int, semid, struct sembuf __user *, tsops,
104927- unsigned, nsops)
104928+ long, nsops)
104929 {
104930 return sys_semtimedop(semid, tsops, nsops, NULL);
104931 }
104932diff --git a/ipc/shm.c b/ipc/shm.c
104933index 0e61fd4..c545631 100644
104934--- a/ipc/shm.c
104935+++ b/ipc/shm.c
104936@@ -72,6 +72,14 @@ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp);
104937 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
104938 #endif
104939
104940+#ifdef CONFIG_GRKERNSEC
104941+extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
104942+ const u64 shm_createtime, const kuid_t cuid,
104943+ const int shmid);
104944+extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
104945+ const u64 shm_createtime);
104946+#endif
104947+
104948 void shm_init_ns(struct ipc_namespace *ns)
104949 {
104950 ns->shm_ctlmax = SHMMAX;
104951@@ -555,6 +563,9 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
104952 shp->shm_lprid = 0;
104953 shp->shm_atim = shp->shm_dtim = 0;
104954 shp->shm_ctim = get_seconds();
104955+#ifdef CONFIG_GRKERNSEC
104956+ shp->shm_createtime = ktime_get_ns();
104957+#endif
104958 shp->shm_segsz = size;
104959 shp->shm_nattch = 0;
104960 shp->shm_file = file;
104961@@ -1098,6 +1109,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
104962 f_mode = FMODE_READ | FMODE_WRITE;
104963 }
104964 if (shmflg & SHM_EXEC) {
104965+
104966+#ifdef CONFIG_PAX_MPROTECT
104967+ if (current->mm->pax_flags & MF_PAX_MPROTECT)
104968+ goto out;
104969+#endif
104970+
104971 prot |= PROT_EXEC;
104972 acc_mode |= S_IXUGO;
104973 }
104974@@ -1122,6 +1139,15 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
104975 if (err)
104976 goto out_unlock;
104977
104978+#ifdef CONFIG_GRKERNSEC
104979+ if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
104980+ shp->shm_perm.cuid, shmid) ||
104981+ !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
104982+ err = -EACCES;
104983+ goto out_unlock;
104984+ }
104985+#endif
104986+
104987 ipc_lock_object(&shp->shm_perm);
104988
104989 /* check if shm_destroy() is tearing down shp */
104990@@ -1134,6 +1160,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
104991 path = shp->shm_file->f_path;
104992 path_get(&path);
104993 shp->shm_nattch++;
104994+#ifdef CONFIG_GRKERNSEC
104995+ shp->shm_lapid = current->pid;
104996+#endif
104997 size = i_size_read(d_inode(path.dentry));
104998 ipc_unlock_object(&shp->shm_perm);
104999 rcu_read_unlock();
105000diff --git a/ipc/util.c b/ipc/util.c
105001index 0f401d9..049b0ff 100644
105002--- a/ipc/util.c
105003+++ b/ipc/util.c
105004@@ -71,6 +71,8 @@ struct ipc_proc_iface {
105005 int (*show)(struct seq_file *, void *);
105006 };
105007
105008+extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
105009+
105010 /**
105011 * ipc_init - initialise ipc subsystem
105012 *
105013@@ -494,6 +496,10 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
105014 granted_mode >>= 6;
105015 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
105016 granted_mode >>= 3;
105017+
105018+ if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
105019+ return -1;
105020+
105021 /* is there some bit set in requested_mode but not in granted_mode? */
105022 if ((requested_mode & ~granted_mode & 0007) &&
105023 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
105024diff --git a/kernel/audit.c b/kernel/audit.c
105025index f9e6065..3fcb6ab 100644
105026--- a/kernel/audit.c
105027+++ b/kernel/audit.c
105028@@ -124,7 +124,7 @@ u32 audit_sig_sid = 0;
105029 3) suppressed due to audit_rate_limit
105030 4) suppressed due to audit_backlog_limit
105031 */
105032-static atomic_t audit_lost = ATOMIC_INIT(0);
105033+static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
105034
105035 /* The netlink socket. */
105036 static struct sock *audit_sock;
105037@@ -258,7 +258,7 @@ void audit_log_lost(const char *message)
105038 unsigned long now;
105039 int print;
105040
105041- atomic_inc(&audit_lost);
105042+ atomic_inc_unchecked(&audit_lost);
105043
105044 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
105045
105046@@ -275,7 +275,7 @@ void audit_log_lost(const char *message)
105047 if (print) {
105048 if (printk_ratelimit())
105049 pr_warn("audit_lost=%u audit_rate_limit=%u audit_backlog_limit=%u\n",
105050- atomic_read(&audit_lost),
105051+ atomic_read_unchecked(&audit_lost),
105052 audit_rate_limit,
105053 audit_backlog_limit);
105054 audit_panic(message);
105055@@ -833,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
105056 s.pid = audit_pid;
105057 s.rate_limit = audit_rate_limit;
105058 s.backlog_limit = audit_backlog_limit;
105059- s.lost = atomic_read(&audit_lost);
105060+ s.lost = atomic_read_unchecked(&audit_lost);
105061 s.backlog = skb_queue_len(&audit_skb_queue);
105062 s.feature_bitmap = AUDIT_FEATURE_BITMAP_ALL;
105063 s.backlog_wait_time = audit_backlog_wait_time_master;
105064diff --git a/kernel/auditsc.c b/kernel/auditsc.c
105065index e85bdfd..441a638 100644
105066--- a/kernel/auditsc.c
105067+++ b/kernel/auditsc.c
105068@@ -1021,7 +1021,7 @@ static int audit_log_single_execve_arg(struct audit_context *context,
105069 * for strings that are too long, we should not have created
105070 * any.
105071 */
105072- if (WARN_ON_ONCE(len < 0 || len > MAX_ARG_STRLEN - 1)) {
105073+ if (WARN_ON_ONCE(len > MAX_ARG_STRLEN - 1)) {
105074 send_sig(SIGKILL, current, 0);
105075 return -1;
105076 }
105077@@ -1952,7 +1952,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
105078 }
105079
105080 /* global counter which is incremented every time something logs in */
105081-static atomic_t session_id = ATOMIC_INIT(0);
105082+static atomic_unchecked_t session_id = ATOMIC_INIT(0);
105083
105084 static int audit_set_loginuid_perm(kuid_t loginuid)
105085 {
105086@@ -2019,7 +2019,7 @@ int audit_set_loginuid(kuid_t loginuid)
105087
105088 /* are we setting or clearing? */
105089 if (uid_valid(loginuid))
105090- sessionid = (unsigned int)atomic_inc_return(&session_id);
105091+ sessionid = (unsigned int)atomic_inc_return_unchecked(&session_id);
105092
105093 task->sessionid = sessionid;
105094 task->loginuid = loginuid;
105095diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
105096index c5bedc8..6ec8715 100644
105097--- a/kernel/bpf/core.c
105098+++ b/kernel/bpf/core.c
105099@@ -145,14 +145,17 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
105100 * random section of illegal instructions.
105101 */
105102 size = round_up(proglen + sizeof(*hdr) + 128, PAGE_SIZE);
105103- hdr = module_alloc(size);
105104+ hdr = module_alloc_exec(size);
105105 if (hdr == NULL)
105106 return NULL;
105107
105108 /* Fill space with illegal/arch-dep instructions. */
105109 bpf_fill_ill_insns(hdr, size);
105110
105111+ pax_open_kernel();
105112 hdr->pages = size / PAGE_SIZE;
105113+ pax_close_kernel();
105114+
105115 hole = min_t(unsigned int, size - (proglen + sizeof(*hdr)),
105116 PAGE_SIZE - sizeof(*hdr));
105117 start = (prandom_u32() % hole) & ~(alignment - 1);
105118@@ -165,7 +168,7 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
105119
105120 void bpf_jit_binary_free(struct bpf_binary_header *hdr)
105121 {
105122- module_memfree(hdr);
105123+ module_memfree_exec(hdr);
105124 }
105125 #endif /* CONFIG_BPF_JIT */
105126
105127diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
105128index a1b14d1..7dce5d9 100644
105129--- a/kernel/bpf/syscall.c
105130+++ b/kernel/bpf/syscall.c
105131@@ -592,11 +592,15 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, siz
105132 int err;
105133
105134 /* the syscall is limited to root temporarily. This restriction will be
105135- * lifted when security audit is clean. Note that eBPF+tracing must have
105136- * this restriction, since it may pass kernel data to user space
105137+ * lifted by upstream when a half-assed security audit is clean. Note
105138+ * that eBPF+tracing must have this restriction, since it may pass
105139+ * kernel data to user space
105140 */
105141 if (!capable(CAP_SYS_ADMIN))
105142 return -EPERM;
105143+#ifdef CONFIG_GRKERNSEC
105144+ return -EPERM;
105145+#endif
105146
105147 if (!access_ok(VERIFY_READ, uattr, 1))
105148 return -EFAULT;
105149diff --git a/kernel/capability.c b/kernel/capability.c
105150index 45432b5..988f1e4 100644
105151--- a/kernel/capability.c
105152+++ b/kernel/capability.c
105153@@ -193,6 +193,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
105154 * before modification is attempted and the application
105155 * fails.
105156 */
105157+ if (tocopy > ARRAY_SIZE(kdata))
105158+ return -EFAULT;
105159+
105160 if (copy_to_user(dataptr, kdata, tocopy
105161 * sizeof(struct __user_cap_data_struct))) {
105162 return -EFAULT;
105163@@ -298,10 +301,11 @@ bool has_ns_capability(struct task_struct *t,
105164 int ret;
105165
105166 rcu_read_lock();
105167- ret = security_capable(__task_cred(t), ns, cap);
105168+ ret = security_capable(__task_cred(t), ns, cap) == 0 &&
105169+ gr_task_is_capable(t, __task_cred(t), cap);
105170 rcu_read_unlock();
105171
105172- return (ret == 0);
105173+ return ret;
105174 }
105175
105176 /**
105177@@ -338,10 +342,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
105178 int ret;
105179
105180 rcu_read_lock();
105181- ret = security_capable_noaudit(__task_cred(t), ns, cap);
105182+ ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
105183 rcu_read_unlock();
105184
105185- return (ret == 0);
105186+ return ret;
105187 }
105188
105189 /**
105190@@ -379,7 +383,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
105191 BUG();
105192 }
105193
105194- if (security_capable(current_cred(), ns, cap) == 0) {
105195+ if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
105196 current->flags |= PF_SUPERPRIV;
105197 return true;
105198 }
105199@@ -387,6 +391,20 @@ bool ns_capable(struct user_namespace *ns, int cap)
105200 }
105201 EXPORT_SYMBOL(ns_capable);
105202
105203+bool ns_capable_nolog(struct user_namespace *ns, int cap)
105204+{
105205+ if (unlikely(!cap_valid(cap))) {
105206+ pr_crit("capable_nolog() called with invalid cap=%u\n", cap);
105207+ BUG();
105208+ }
105209+
105210+ if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
105211+ current->flags |= PF_SUPERPRIV;
105212+ return true;
105213+ }
105214+ return false;
105215+}
105216+EXPORT_SYMBOL(ns_capable_nolog);
105217
105218 /**
105219 * capable - Determine if the current task has a superior capability in effect
105220@@ -403,6 +421,13 @@ bool capable(int cap)
105221 return ns_capable(&init_user_ns, cap);
105222 }
105223 EXPORT_SYMBOL(capable);
105224+
105225+bool capable_nolog(int cap)
105226+{
105227+ return ns_capable_nolog(&init_user_ns, cap);
105228+}
105229+EXPORT_SYMBOL(capable_nolog);
105230+
105231 #endif /* CONFIG_MULTIUSER */
105232
105233 /**
105234@@ -447,3 +472,12 @@ bool capable_wrt_inode_uidgid(const struct inode *inode, int cap)
105235 kgid_has_mapping(ns, inode->i_gid);
105236 }
105237 EXPORT_SYMBOL(capable_wrt_inode_uidgid);
105238+
105239+bool capable_wrt_inode_uidgid_nolog(const struct inode *inode, int cap)
105240+{
105241+ struct user_namespace *ns = current_user_ns();
105242+
105243+ return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid) &&
105244+ kgid_has_mapping(ns, inode->i_gid);
105245+}
105246+EXPORT_SYMBOL(capable_wrt_inode_uidgid_nolog);
105247diff --git a/kernel/cgroup.c b/kernel/cgroup.c
105248index fe6f855..7dba913 100644
105249--- a/kernel/cgroup.c
105250+++ b/kernel/cgroup.c
105251@@ -5425,6 +5425,9 @@ static void cgroup_release_agent(struct work_struct *work)
105252 if (!pathbuf || !agentbuf)
105253 goto out;
105254
105255+ if (agentbuf[0] == '\0')
105256+ goto out;
105257+
105258 path = cgroup_path(cgrp, pathbuf, PATH_MAX);
105259 if (!path)
105260 goto out;
105261@@ -5610,7 +5613,7 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v)
105262 struct task_struct *task;
105263 int count = 0;
105264
105265- seq_printf(seq, "css_set %p\n", cset);
105266+ seq_printf(seq, "css_set %pK\n", cset);
105267
105268 list_for_each_entry(task, &cset->tasks, cg_list) {
105269 if (count++ > MAX_TASKS_SHOWN_PER_CSS)
105270diff --git a/kernel/compat.c b/kernel/compat.c
105271index 333d364..762ec00 100644
105272--- a/kernel/compat.c
105273+++ b/kernel/compat.c
105274@@ -13,6 +13,7 @@
105275
105276 #include <linux/linkage.h>
105277 #include <linux/compat.h>
105278+#include <linux/module.h>
105279 #include <linux/errno.h>
105280 #include <linux/time.h>
105281 #include <linux/signal.h>
105282@@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
105283 mm_segment_t oldfs;
105284 long ret;
105285
105286- restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
105287+ restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
105288 oldfs = get_fs();
105289 set_fs(KERNEL_DS);
105290 ret = hrtimer_nanosleep_restart(restart);
105291@@ -252,7 +253,7 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
105292 oldfs = get_fs();
105293 set_fs(KERNEL_DS);
105294 ret = hrtimer_nanosleep(&tu,
105295- rmtp ? (struct timespec __user *)&rmt : NULL,
105296+ rmtp ? (struct timespec __force_user *)&rmt : NULL,
105297 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
105298 set_fs(oldfs);
105299
105300@@ -378,7 +379,7 @@ COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set)
105301 mm_segment_t old_fs = get_fs();
105302
105303 set_fs(KERNEL_DS);
105304- ret = sys_sigpending((old_sigset_t __user *) &s);
105305+ ret = sys_sigpending((old_sigset_t __force_user *) &s);
105306 set_fs(old_fs);
105307 if (ret == 0)
105308 ret = put_user(s, set);
105309@@ -468,7 +469,7 @@ COMPAT_SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
105310 mm_segment_t old_fs = get_fs();
105311
105312 set_fs(KERNEL_DS);
105313- ret = sys_old_getrlimit(resource, (struct rlimit __user *)&r);
105314+ ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
105315 set_fs(old_fs);
105316
105317 if (!ret) {
105318@@ -550,8 +551,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
105319 set_fs (KERNEL_DS);
105320 ret = sys_wait4(pid,
105321 (stat_addr ?
105322- (unsigned int __user *) &status : NULL),
105323- options, (struct rusage __user *) &r);
105324+ (unsigned int __force_user *) &status : NULL),
105325+ options, (struct rusage __force_user *) &r);
105326 set_fs (old_fs);
105327
105328 if (ret > 0) {
105329@@ -577,8 +578,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
105330 memset(&info, 0, sizeof(info));
105331
105332 set_fs(KERNEL_DS);
105333- ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
105334- uru ? (struct rusage __user *)&ru : NULL);
105335+ ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
105336+ uru ? (struct rusage __force_user *)&ru : NULL);
105337 set_fs(old_fs);
105338
105339 if ((ret < 0) || (info.si_signo == 0))
105340@@ -712,8 +713,8 @@ COMPAT_SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
105341 oldfs = get_fs();
105342 set_fs(KERNEL_DS);
105343 err = sys_timer_settime(timer_id, flags,
105344- (struct itimerspec __user *) &newts,
105345- (struct itimerspec __user *) &oldts);
105346+ (struct itimerspec __force_user *) &newts,
105347+ (struct itimerspec __force_user *) &oldts);
105348 set_fs(oldfs);
105349 if (!err && old && put_compat_itimerspec(old, &oldts))
105350 return -EFAULT;
105351@@ -730,7 +731,7 @@ COMPAT_SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
105352 oldfs = get_fs();
105353 set_fs(KERNEL_DS);
105354 err = sys_timer_gettime(timer_id,
105355- (struct itimerspec __user *) &ts);
105356+ (struct itimerspec __force_user *) &ts);
105357 set_fs(oldfs);
105358 if (!err && put_compat_itimerspec(setting, &ts))
105359 return -EFAULT;
105360@@ -749,7 +750,7 @@ COMPAT_SYSCALL_DEFINE2(clock_settime, clockid_t, which_clock,
105361 oldfs = get_fs();
105362 set_fs(KERNEL_DS);
105363 err = sys_clock_settime(which_clock,
105364- (struct timespec __user *) &ts);
105365+ (struct timespec __force_user *) &ts);
105366 set_fs(oldfs);
105367 return err;
105368 }
105369@@ -764,7 +765,7 @@ COMPAT_SYSCALL_DEFINE2(clock_gettime, clockid_t, which_clock,
105370 oldfs = get_fs();
105371 set_fs(KERNEL_DS);
105372 err = sys_clock_gettime(which_clock,
105373- (struct timespec __user *) &ts);
105374+ (struct timespec __force_user *) &ts);
105375 set_fs(oldfs);
105376 if (!err && compat_put_timespec(&ts, tp))
105377 return -EFAULT;
105378@@ -784,7 +785,7 @@ COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
105379
105380 oldfs = get_fs();
105381 set_fs(KERNEL_DS);
105382- ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
105383+ ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
105384 set_fs(oldfs);
105385
105386 err = compat_put_timex(utp, &txc);
105387@@ -804,7 +805,7 @@ COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock,
105388 oldfs = get_fs();
105389 set_fs(KERNEL_DS);
105390 err = sys_clock_getres(which_clock,
105391- (struct timespec __user *) &ts);
105392+ (struct timespec __force_user *) &ts);
105393 set_fs(oldfs);
105394 if (!err && tp && compat_put_timespec(&ts, tp))
105395 return -EFAULT;
105396@@ -818,7 +819,7 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
105397 struct timespec tu;
105398 struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
105399
105400- restart->nanosleep.rmtp = (struct timespec __user *) &tu;
105401+ restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
105402 oldfs = get_fs();
105403 set_fs(KERNEL_DS);
105404 err = clock_nanosleep_restart(restart);
105405@@ -850,8 +851,8 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
105406 oldfs = get_fs();
105407 set_fs(KERNEL_DS);
105408 err = sys_clock_nanosleep(which_clock, flags,
105409- (struct timespec __user *) &in,
105410- (struct timespec __user *) &out);
105411+ (struct timespec __force_user *) &in,
105412+ (struct timespec __force_user *) &out);
105413 set_fs(oldfs);
105414
105415 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
105416@@ -1147,7 +1148,7 @@ COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval,
105417 mm_segment_t old_fs = get_fs();
105418
105419 set_fs(KERNEL_DS);
105420- ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
105421+ ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
105422 set_fs(old_fs);
105423 if (compat_put_timespec(&t, interval))
105424 return -EFAULT;
105425diff --git a/kernel/configs.c b/kernel/configs.c
105426index c18b1f1..b9a0132 100644
105427--- a/kernel/configs.c
105428+++ b/kernel/configs.c
105429@@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
105430 struct proc_dir_entry *entry;
105431
105432 /* create the current config file */
105433+#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
105434+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
105435+ entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
105436+ &ikconfig_file_ops);
105437+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
105438+ entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
105439+ &ikconfig_file_ops);
105440+#endif
105441+#else
105442 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
105443 &ikconfig_file_ops);
105444+#endif
105445+
105446 if (!entry)
105447 return -ENOMEM;
105448
105449diff --git a/kernel/cred.c b/kernel/cred.c
105450index ec1c076..7da8a0e 100644
105451--- a/kernel/cred.c
105452+++ b/kernel/cred.c
105453@@ -167,6 +167,15 @@ void exit_creds(struct task_struct *tsk)
105454 validate_creds(cred);
105455 alter_cred_subscribers(cred, -1);
105456 put_cred(cred);
105457+
105458+#ifdef CONFIG_GRKERNSEC_SETXID
105459+ cred = (struct cred *) tsk->delayed_cred;
105460+ if (cred != NULL) {
105461+ tsk->delayed_cred = NULL;
105462+ validate_creds(cred);
105463+ put_cred(cred);
105464+ }
105465+#endif
105466 }
105467
105468 /**
105469@@ -414,7 +423,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
105470 * Always returns 0 thus allowing this function to be tail-called at the end
105471 * of, say, sys_setgid().
105472 */
105473-int commit_creds(struct cred *new)
105474+static int __commit_creds(struct cred *new)
105475 {
105476 struct task_struct *task = current;
105477 const struct cred *old = task->real_cred;
105478@@ -433,6 +442,8 @@ int commit_creds(struct cred *new)
105479
105480 get_cred(new); /* we will require a ref for the subj creds too */
105481
105482+ gr_set_role_label(task, new->uid, new->gid);
105483+
105484 /* dumpability changes */
105485 if (!uid_eq(old->euid, new->euid) ||
105486 !gid_eq(old->egid, new->egid) ||
105487@@ -482,6 +493,105 @@ int commit_creds(struct cred *new)
105488 put_cred(old);
105489 return 0;
105490 }
105491+#ifdef CONFIG_GRKERNSEC_SETXID
105492+extern int set_user(struct cred *new);
105493+
105494+void gr_delayed_cred_worker(void)
105495+{
105496+ const struct cred *new = current->delayed_cred;
105497+ struct cred *ncred;
105498+
105499+ current->delayed_cred = NULL;
105500+
105501+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
105502+ // from doing get_cred on it when queueing this
105503+ put_cred(new);
105504+ return;
105505+ } else if (new == NULL)
105506+ return;
105507+
105508+ ncred = prepare_creds();
105509+ if (!ncred)
105510+ goto die;
105511+ // uids
105512+ ncred->uid = new->uid;
105513+ ncred->euid = new->euid;
105514+ ncred->suid = new->suid;
105515+ ncred->fsuid = new->fsuid;
105516+ // gids
105517+ ncred->gid = new->gid;
105518+ ncred->egid = new->egid;
105519+ ncred->sgid = new->sgid;
105520+ ncred->fsgid = new->fsgid;
105521+ // groups
105522+ set_groups(ncred, new->group_info);
105523+ // caps
105524+ ncred->securebits = new->securebits;
105525+ ncred->cap_inheritable = new->cap_inheritable;
105526+ ncred->cap_permitted = new->cap_permitted;
105527+ ncred->cap_effective = new->cap_effective;
105528+ ncred->cap_bset = new->cap_bset;
105529+
105530+ if (set_user(ncred)) {
105531+ abort_creds(ncred);
105532+ goto die;
105533+ }
105534+
105535+ // from doing get_cred on it when queueing this
105536+ put_cred(new);
105537+
105538+ __commit_creds(ncred);
105539+ return;
105540+die:
105541+ // from doing get_cred on it when queueing this
105542+ put_cred(new);
105543+ do_group_exit(SIGKILL);
105544+}
105545+#endif
105546+
105547+int commit_creds(struct cred *new)
105548+{
105549+#ifdef CONFIG_GRKERNSEC_SETXID
105550+ int ret;
105551+ int schedule_it = 0;
105552+ struct task_struct *t;
105553+ unsigned oldsecurebits = current_cred()->securebits;
105554+
105555+ /* we won't get called with tasklist_lock held for writing
105556+ and interrupts disabled as the cred struct in that case is
105557+ init_cred
105558+ */
105559+ if (grsec_enable_setxid && !current_is_single_threaded() &&
105560+ uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
105561+ !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
105562+ schedule_it = 1;
105563+ }
105564+ ret = __commit_creds(new);
105565+ if (schedule_it) {
105566+ rcu_read_lock();
105567+ read_lock(&tasklist_lock);
105568+ for (t = next_thread(current); t != current;
105569+ t = next_thread(t)) {
105570+ /* we'll check if the thread has uid 0 in
105571+ * the delayed worker routine
105572+ */
105573+ if (task_securebits(t) == oldsecurebits &&
105574+ t->delayed_cred == NULL) {
105575+ t->delayed_cred = get_cred(new);
105576+ set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
105577+ set_tsk_need_resched(t);
105578+ }
105579+ }
105580+ read_unlock(&tasklist_lock);
105581+ rcu_read_unlock();
105582+ }
105583+
105584+ return ret;
105585+#else
105586+ return __commit_creds(new);
105587+#endif
105588+}
105589+
105590 EXPORT_SYMBOL(commit_creds);
105591
105592 /**
105593diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
105594index 0874e2e..5b32cc9 100644
105595--- a/kernel/debug/debug_core.c
105596+++ b/kernel/debug/debug_core.c
105597@@ -127,7 +127,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
105598 */
105599 static atomic_t masters_in_kgdb;
105600 static atomic_t slaves_in_kgdb;
105601-static atomic_t kgdb_break_tasklet_var;
105602+static atomic_unchecked_t kgdb_break_tasklet_var;
105603 atomic_t kgdb_setting_breakpoint;
105604
105605 struct task_struct *kgdb_usethread;
105606@@ -137,7 +137,7 @@ int kgdb_single_step;
105607 static pid_t kgdb_sstep_pid;
105608
105609 /* to keep track of the CPU which is doing the single stepping*/
105610-atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
105611+atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
105612
105613 /*
105614 * If you are debugging a problem where roundup (the collection of
105615@@ -552,7 +552,7 @@ return_normal:
105616 * kernel will only try for the value of sstep_tries before
105617 * giving up and continuing on.
105618 */
105619- if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
105620+ if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
105621 (kgdb_info[cpu].task &&
105622 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
105623 atomic_set(&kgdb_active, -1);
105624@@ -654,8 +654,8 @@ cpu_master_loop:
105625 }
105626
105627 kgdb_restore:
105628- if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
105629- int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
105630+ if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
105631+ int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
105632 if (kgdb_info[sstep_cpu].task)
105633 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
105634 else
105635@@ -949,18 +949,18 @@ static void kgdb_unregister_callbacks(void)
105636 static void kgdb_tasklet_bpt(unsigned long ing)
105637 {
105638 kgdb_breakpoint();
105639- atomic_set(&kgdb_break_tasklet_var, 0);
105640+ atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
105641 }
105642
105643 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
105644
105645 void kgdb_schedule_breakpoint(void)
105646 {
105647- if (atomic_read(&kgdb_break_tasklet_var) ||
105648+ if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
105649 atomic_read(&kgdb_active) != -1 ||
105650 atomic_read(&kgdb_setting_breakpoint))
105651 return;
105652- atomic_inc(&kgdb_break_tasklet_var);
105653+ atomic_inc_unchecked(&kgdb_break_tasklet_var);
105654 tasklet_schedule(&kgdb_tasklet_breakpoint);
105655 }
105656 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
105657diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
105658index 41213454..861e178 100644
105659--- a/kernel/debug/kdb/kdb_main.c
105660+++ b/kernel/debug/kdb/kdb_main.c
105661@@ -2021,7 +2021,7 @@ static int kdb_lsmod(int argc, const char **argv)
105662 continue;
105663
105664 kdb_printf("%-20s%8u 0x%p ", mod->name,
105665- mod->core_size, (void *)mod);
105666+ mod->core_size_rx + mod->core_size_rw, (void *)mod);
105667 #ifdef CONFIG_MODULE_UNLOAD
105668 kdb_printf("%4d ", module_refcount(mod));
105669 #endif
105670@@ -2031,7 +2031,7 @@ static int kdb_lsmod(int argc, const char **argv)
105671 kdb_printf(" (Loading)");
105672 else
105673 kdb_printf(" (Live)");
105674- kdb_printf(" 0x%p", mod->module_core);
105675+ kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
105676
105677 #ifdef CONFIG_MODULE_UNLOAD
105678 {
105679diff --git a/kernel/events/core.c b/kernel/events/core.c
105680index e6feb51..470c853 100644
105681--- a/kernel/events/core.c
105682+++ b/kernel/events/core.c
105683@@ -174,8 +174,15 @@ static struct srcu_struct pmus_srcu;
105684 * 0 - disallow raw tracepoint access for unpriv
105685 * 1 - disallow cpu events for unpriv
105686 * 2 - disallow kernel profiling for unpriv
105687+ * 3 - disallow all unpriv perf event use
105688 */
105689-int sysctl_perf_event_paranoid __read_mostly = 1;
105690+#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
105691+int sysctl_perf_event_legitimately_concerned __read_only = 3;
105692+#elif defined(CONFIG_GRKERNSEC_HIDESYM)
105693+int sysctl_perf_event_legitimately_concerned __read_only = 2;
105694+#else
105695+int sysctl_perf_event_legitimately_concerned __read_only = 1;
105696+#endif
105697
105698 /* Minimum for 512 kiB + 1 user control page */
105699 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
105700@@ -201,7 +208,7 @@ void update_perf_cpu_limits(void)
105701
105702 tmp *= sysctl_perf_cpu_time_max_percent;
105703 do_div(tmp, 100);
105704- ACCESS_ONCE(perf_sample_allowed_ns) = tmp;
105705+ ACCESS_ONCE_RW(perf_sample_allowed_ns) = tmp;
105706 }
105707
105708 static int perf_rotate_context(struct perf_cpu_context *cpuctx);
105709@@ -307,7 +314,7 @@ void perf_sample_event_took(u64 sample_len_ns)
105710 }
105711 }
105712
105713-static atomic64_t perf_event_id;
105714+static atomic64_unchecked_t perf_event_id;
105715
105716 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
105717 enum event_type_t event_type);
105718@@ -3753,9 +3760,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
105719 mutex_lock(&event->child_mutex);
105720 total += perf_event_read(event);
105721 *enabled += event->total_time_enabled +
105722- atomic64_read(&event->child_total_time_enabled);
105723+ atomic64_read_unchecked(&event->child_total_time_enabled);
105724 *running += event->total_time_running +
105725- atomic64_read(&event->child_total_time_running);
105726+ atomic64_read_unchecked(&event->child_total_time_running);
105727
105728 list_for_each_entry(child, &event->child_list, child_list) {
105729 total += perf_event_read(child);
105730@@ -4285,10 +4292,10 @@ void perf_event_update_userpage(struct perf_event *event)
105731 userpg->offset -= local64_read(&event->hw.prev_count);
105732
105733 userpg->time_enabled = enabled +
105734- atomic64_read(&event->child_total_time_enabled);
105735+ atomic64_read_unchecked(&event->child_total_time_enabled);
105736
105737 userpg->time_running = running +
105738- atomic64_read(&event->child_total_time_running);
105739+ atomic64_read_unchecked(&event->child_total_time_running);
105740
105741 arch_perf_update_userpage(event, userpg, now);
105742
105743@@ -4963,7 +4970,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
105744
105745 /* Data. */
105746 sp = perf_user_stack_pointer(regs);
105747- rem = __output_copy_user(handle, (void *) sp, dump_size);
105748+ rem = __output_copy_user(handle, (void __user *) sp, dump_size);
105749 dyn_size = dump_size - rem;
105750
105751 perf_output_skip(handle, rem);
105752@@ -5054,11 +5061,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
105753 values[n++] = perf_event_count(event);
105754 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
105755 values[n++] = enabled +
105756- atomic64_read(&event->child_total_time_enabled);
105757+ atomic64_read_unchecked(&event->child_total_time_enabled);
105758 }
105759 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
105760 values[n++] = running +
105761- atomic64_read(&event->child_total_time_running);
105762+ atomic64_read_unchecked(&event->child_total_time_running);
105763 }
105764 if (read_format & PERF_FORMAT_ID)
105765 values[n++] = primary_event_id(event);
105766@@ -7588,7 +7595,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
105767 event->parent = parent_event;
105768
105769 event->ns = get_pid_ns(task_active_pid_ns(current));
105770- event->id = atomic64_inc_return(&perf_event_id);
105771+ event->id = atomic64_inc_return_unchecked(&perf_event_id);
105772
105773 event->state = PERF_EVENT_STATE_INACTIVE;
105774
105775@@ -7947,6 +7954,11 @@ SYSCALL_DEFINE5(perf_event_open,
105776 if (flags & ~PERF_FLAG_ALL)
105777 return -EINVAL;
105778
105779+#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
105780+ if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
105781+ return -EACCES;
105782+#endif
105783+
105784 err = perf_copy_attr(attr_uptr, &attr);
105785 if (err)
105786 return err;
105787@@ -8395,10 +8407,10 @@ static void sync_child_event(struct perf_event *child_event,
105788 /*
105789 * Add back the child's count to the parent's count:
105790 */
105791- atomic64_add(child_val, &parent_event->child_count);
105792- atomic64_add(child_event->total_time_enabled,
105793+ atomic64_add_unchecked(child_val, &parent_event->child_count);
105794+ atomic64_add_unchecked(child_event->total_time_enabled,
105795 &parent_event->child_total_time_enabled);
105796- atomic64_add(child_event->total_time_running,
105797+ atomic64_add_unchecked(child_event->total_time_running,
105798 &parent_event->child_total_time_running);
105799
105800 /*
105801diff --git a/kernel/events/internal.h b/kernel/events/internal.h
105802index 2bbad9c..056f20c 100644
105803--- a/kernel/events/internal.h
105804+++ b/kernel/events/internal.h
105805@@ -115,10 +115,10 @@ static inline unsigned long perf_aux_size(struct ring_buffer *rb)
105806 return rb->aux_nr_pages << PAGE_SHIFT;
105807 }
105808
105809-#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
105810+#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
105811 static inline unsigned long \
105812 func_name(struct perf_output_handle *handle, \
105813- const void *buf, unsigned long len) \
105814+ const void user *buf, unsigned long len) \
105815 { \
105816 unsigned long size, written; \
105817 \
105818@@ -151,7 +151,7 @@ memcpy_common(void *dst, const void *src, unsigned long n)
105819 return 0;
105820 }
105821
105822-DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
105823+DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
105824
105825 static inline unsigned long
105826 memcpy_skip(void *dst, const void *src, unsigned long n)
105827@@ -159,7 +159,7 @@ memcpy_skip(void *dst, const void *src, unsigned long n)
105828 return 0;
105829 }
105830
105831-DEFINE_OUTPUT_COPY(__output_skip, memcpy_skip)
105832+DEFINE_OUTPUT_COPY(__output_skip, memcpy_skip, )
105833
105834 #ifndef arch_perf_out_copy_user
105835 #define arch_perf_out_copy_user arch_perf_out_copy_user
105836@@ -177,7 +177,7 @@ arch_perf_out_copy_user(void *dst, const void *src, unsigned long n)
105837 }
105838 #endif
105839
105840-DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
105841+DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
105842
105843 /* Callchain handling */
105844 extern struct perf_callchain_entry *
105845diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
105846index cb346f2..e4dc317 100644
105847--- a/kernel/events/uprobes.c
105848+++ b/kernel/events/uprobes.c
105849@@ -1670,7 +1670,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
105850 {
105851 struct page *page;
105852 uprobe_opcode_t opcode;
105853- int result;
105854+ long result;
105855
105856 pagefault_disable();
105857 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
105858diff --git a/kernel/exit.c b/kernel/exit.c
105859index 031325e..c6342c4 100644
105860--- a/kernel/exit.c
105861+++ b/kernel/exit.c
105862@@ -171,6 +171,10 @@ void release_task(struct task_struct *p)
105863 struct task_struct *leader;
105864 int zap_leader;
105865 repeat:
105866+#ifdef CONFIG_NET
105867+ gr_del_task_from_ip_table(p);
105868+#endif
105869+
105870 /* don't need to get the RCU readlock here - the process is dead and
105871 * can't be modifying its own credentials. But shut RCU-lockdep up */
105872 rcu_read_lock();
105873@@ -656,6 +660,8 @@ void do_exit(long code)
105874 int group_dead;
105875 TASKS_RCU(int tasks_rcu_i);
105876
105877+ set_fs(USER_DS);
105878+
105879 profile_task_exit(tsk);
105880
105881 WARN_ON(blk_needs_flush_plug(tsk));
105882@@ -672,7 +678,6 @@ void do_exit(long code)
105883 * mm_release()->clear_child_tid() from writing to a user-controlled
105884 * kernel address.
105885 */
105886- set_fs(USER_DS);
105887
105888 ptrace_event(PTRACE_EVENT_EXIT, code);
105889
105890@@ -730,6 +735,9 @@ void do_exit(long code)
105891 tsk->exit_code = code;
105892 taskstats_exit(tsk, group_dead);
105893
105894+ gr_acl_handle_psacct(tsk, code);
105895+ gr_acl_handle_exit();
105896+
105897 exit_mm(tsk);
105898
105899 if (group_dead)
105900@@ -847,7 +855,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
105901 * Take down every thread in the group. This is called by fatal signals
105902 * as well as by sys_exit_group (below).
105903 */
105904-void
105905+__noreturn void
105906 do_group_exit(int exit_code)
105907 {
105908 struct signal_struct *sig = current->signal;
105909diff --git a/kernel/fork.c b/kernel/fork.c
105910index e769c8c..9fa1de5 100644
105911--- a/kernel/fork.c
105912+++ b/kernel/fork.c
105913@@ -188,12 +188,54 @@ static void free_thread_info(struct thread_info *ti)
105914 void thread_info_cache_init(void)
105915 {
105916 thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE,
105917- THREAD_SIZE, 0, NULL);
105918+ THREAD_SIZE, SLAB_USERCOPY, NULL);
105919 BUG_ON(thread_info_cache == NULL);
105920 }
105921 # endif
105922 #endif
105923
105924+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
105925+static inline struct thread_info *gr_alloc_thread_info_node(struct task_struct *tsk,
105926+ int node, void **lowmem_stack)
105927+{
105928+ struct page *pages[THREAD_SIZE / PAGE_SIZE];
105929+ void *ret = NULL;
105930+ unsigned int i;
105931+
105932+ *lowmem_stack = alloc_thread_info_node(tsk, node);
105933+ if (*lowmem_stack == NULL)
105934+ goto out;
105935+
105936+ for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++)
105937+ pages[i] = virt_to_page(*lowmem_stack + (i * PAGE_SIZE));
105938+
105939+ /* use VM_IOREMAP to gain THREAD_SIZE alignment */
105940+ ret = vmap(pages, THREAD_SIZE / PAGE_SIZE, VM_IOREMAP, PAGE_KERNEL);
105941+ if (ret == NULL) {
105942+ free_thread_info(*lowmem_stack);
105943+ *lowmem_stack = NULL;
105944+ }
105945+
105946+out:
105947+ return ret;
105948+}
105949+
105950+static inline void gr_free_thread_info(struct task_struct *tsk, struct thread_info *ti)
105951+{
105952+ unmap_process_stacks(tsk);
105953+}
105954+#else
105955+static inline struct thread_info *gr_alloc_thread_info_node(struct task_struct *tsk,
105956+ int node, void **lowmem_stack)
105957+{
105958+ return alloc_thread_info_node(tsk, node);
105959+}
105960+static inline void gr_free_thread_info(struct task_struct *tsk, struct thread_info *ti)
105961+{
105962+ free_thread_info(ti);
105963+}
105964+#endif
105965+
105966 /* SLAB cache for signal_struct structures (tsk->signal) */
105967 static struct kmem_cache *signal_cachep;
105968
105969@@ -212,18 +254,22 @@ struct kmem_cache *vm_area_cachep;
105970 /* SLAB cache for mm_struct structures (tsk->mm) */
105971 static struct kmem_cache *mm_cachep;
105972
105973-static void account_kernel_stack(struct thread_info *ti, int account)
105974+static void account_kernel_stack(struct task_struct *tsk, struct thread_info *ti, int account)
105975 {
105976+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
105977+ struct zone *zone = page_zone(virt_to_page(tsk->lowmem_stack));
105978+#else
105979 struct zone *zone = page_zone(virt_to_page(ti));
105980+#endif
105981
105982 mod_zone_page_state(zone, NR_KERNEL_STACK, account);
105983 }
105984
105985 void free_task(struct task_struct *tsk)
105986 {
105987- account_kernel_stack(tsk->stack, -1);
105988+ account_kernel_stack(tsk, tsk->stack, -1);
105989 arch_release_thread_info(tsk->stack);
105990- free_thread_info(tsk->stack);
105991+ gr_free_thread_info(tsk, tsk->stack);
105992 rt_mutex_debug_task_free(tsk);
105993 ftrace_graph_exit_task(tsk);
105994 put_seccomp_filter(tsk);
105995@@ -289,7 +335,7 @@ static void set_max_threads(unsigned int max_threads_suggested)
105996
105997 #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT
105998 /* Initialized by the architecture: */
105999-int arch_task_struct_size __read_mostly;
106000+size_t arch_task_struct_size __read_mostly;
106001 #endif
106002
106003 void __init fork_init(void)
106004@@ -334,6 +380,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
106005 {
106006 struct task_struct *tsk;
106007 struct thread_info *ti;
106008+ void *lowmem_stack;
106009 int node = tsk_fork_get_node(orig);
106010 int err;
106011
106012@@ -341,7 +388,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
106013 if (!tsk)
106014 return NULL;
106015
106016- ti = alloc_thread_info_node(tsk, node);
106017+ ti = gr_alloc_thread_info_node(tsk, node, &lowmem_stack);
106018 if (!ti)
106019 goto free_tsk;
106020
106021@@ -350,6 +397,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
106022 goto free_ti;
106023
106024 tsk->stack = ti;
106025+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
106026+ tsk->lowmem_stack = lowmem_stack;
106027+#endif
106028 #ifdef CONFIG_SECCOMP
106029 /*
106030 * We must handle setting up seccomp filters once we're under
106031@@ -366,7 +416,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
106032 set_task_stack_end_magic(tsk);
106033
106034 #ifdef CONFIG_CC_STACKPROTECTOR
106035- tsk->stack_canary = get_random_int();
106036+ tsk->stack_canary = pax_get_random_long();
106037 #endif
106038
106039 /*
106040@@ -380,24 +430,89 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
106041 tsk->splice_pipe = NULL;
106042 tsk->task_frag.page = NULL;
106043
106044- account_kernel_stack(ti, 1);
106045+ account_kernel_stack(tsk, ti, 1);
106046
106047 return tsk;
106048
106049 free_ti:
106050- free_thread_info(ti);
106051+ gr_free_thread_info(tsk, ti);
106052 free_tsk:
106053 free_task_struct(tsk);
106054 return NULL;
106055 }
106056
106057 #ifdef CONFIG_MMU
106058-static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
106059+static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
106060+{
106061+ struct vm_area_struct *tmp;
106062+ unsigned long charge;
106063+ struct file *file;
106064+ int retval;
106065+
106066+ charge = 0;
106067+ if (mpnt->vm_flags & VM_ACCOUNT) {
106068+ unsigned long len = vma_pages(mpnt);
106069+
106070+ if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
106071+ goto fail_nomem;
106072+ charge = len;
106073+ }
106074+ tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
106075+ if (!tmp)
106076+ goto fail_nomem;
106077+ *tmp = *mpnt;
106078+ tmp->vm_mm = mm;
106079+ INIT_LIST_HEAD(&tmp->anon_vma_chain);
106080+ retval = vma_dup_policy(mpnt, tmp);
106081+ if (retval)
106082+ goto fail_nomem_policy;
106083+ if (anon_vma_fork(tmp, mpnt))
106084+ goto fail_nomem_anon_vma_fork;
106085+ tmp->vm_flags &= ~VM_LOCKED;
106086+ tmp->vm_next = tmp->vm_prev = NULL;
106087+ tmp->vm_mirror = NULL;
106088+ file = tmp->vm_file;
106089+ if (file) {
106090+ struct inode *inode = file_inode(file);
106091+ struct address_space *mapping = file->f_mapping;
106092+
106093+ get_file(file);
106094+ if (tmp->vm_flags & VM_DENYWRITE)
106095+ atomic_dec(&inode->i_writecount);
106096+ i_mmap_lock_write(mapping);
106097+ if (tmp->vm_flags & VM_SHARED)
106098+ atomic_inc(&mapping->i_mmap_writable);
106099+ flush_dcache_mmap_lock(mapping);
106100+ /* insert tmp into the share list, just after mpnt */
106101+ vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
106102+ flush_dcache_mmap_unlock(mapping);
106103+ i_mmap_unlock_write(mapping);
106104+ }
106105+
106106+ /*
106107+ * Clear hugetlb-related page reserves for children. This only
106108+ * affects MAP_PRIVATE mappings. Faults generated by the child
106109+ * are not guaranteed to succeed, even if read-only
106110+ */
106111+ if (is_vm_hugetlb_page(tmp))
106112+ reset_vma_resv_huge_pages(tmp);
106113+
106114+ return tmp;
106115+
106116+fail_nomem_anon_vma_fork:
106117+ mpol_put(vma_policy(tmp));
106118+fail_nomem_policy:
106119+ kmem_cache_free(vm_area_cachep, tmp);
106120+fail_nomem:
106121+ vm_unacct_memory(charge);
106122+ return NULL;
106123+}
106124+
106125+static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
106126 {
106127 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
106128 struct rb_node **rb_link, *rb_parent;
106129 int retval;
106130- unsigned long charge;
106131
106132 uprobe_start_dup_mmap();
106133 down_write(&oldmm->mmap_sem);
106134@@ -428,51 +543,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
106135
106136 prev = NULL;
106137 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
106138- struct file *file;
106139-
106140 if (mpnt->vm_flags & VM_DONTCOPY) {
106141 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
106142 -vma_pages(mpnt));
106143 continue;
106144 }
106145- charge = 0;
106146- if (mpnt->vm_flags & VM_ACCOUNT) {
106147- unsigned long len = vma_pages(mpnt);
106148-
106149- if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
106150- goto fail_nomem;
106151- charge = len;
106152- }
106153- tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
106154- if (!tmp)
106155- goto fail_nomem;
106156- *tmp = *mpnt;
106157- INIT_LIST_HEAD(&tmp->anon_vma_chain);
106158- retval = vma_dup_policy(mpnt, tmp);
106159- if (retval)
106160- goto fail_nomem_policy;
106161- tmp->vm_mm = mm;
106162- if (anon_vma_fork(tmp, mpnt))
106163- goto fail_nomem_anon_vma_fork;
106164- tmp->vm_flags &= ~VM_LOCKED;
106165- tmp->vm_next = tmp->vm_prev = NULL;
106166- file = tmp->vm_file;
106167- if (file) {
106168- struct inode *inode = file_inode(file);
106169- struct address_space *mapping = file->f_mapping;
106170-
106171- get_file(file);
106172- if (tmp->vm_flags & VM_DENYWRITE)
106173- atomic_dec(&inode->i_writecount);
106174- i_mmap_lock_write(mapping);
106175- if (tmp->vm_flags & VM_SHARED)
106176- atomic_inc(&mapping->i_mmap_writable);
106177- flush_dcache_mmap_lock(mapping);
106178- /* insert tmp into the share list, just after mpnt */
106179- vma_interval_tree_insert_after(tmp, mpnt,
106180- &mapping->i_mmap);
106181- flush_dcache_mmap_unlock(mapping);
106182- i_mmap_unlock_write(mapping);
106183+ tmp = dup_vma(mm, oldmm, mpnt);
106184+ if (!tmp) {
106185+ retval = -ENOMEM;
106186+ goto out;
106187 }
106188
106189 /*
106190@@ -504,6 +583,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
106191 if (retval)
106192 goto out;
106193 }
106194+
106195+#ifdef CONFIG_PAX_SEGMEXEC
106196+ if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
106197+ struct vm_area_struct *mpnt_m;
106198+
106199+ for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
106200+ BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
106201+
106202+ if (!mpnt->vm_mirror)
106203+ continue;
106204+
106205+ if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
106206+ BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
106207+ mpnt->vm_mirror = mpnt_m;
106208+ } else {
106209+ BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
106210+ mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
106211+ mpnt_m->vm_mirror->vm_mirror = mpnt_m;
106212+ mpnt->vm_mirror->vm_mirror = mpnt;
106213+ }
106214+ }
106215+ BUG_ON(mpnt_m);
106216+ }
106217+#endif
106218+
106219 /* a new mm has just been created */
106220 arch_dup_mmap(oldmm, mm);
106221 retval = 0;
106222@@ -513,14 +617,6 @@ out:
106223 up_write(&oldmm->mmap_sem);
106224 uprobe_end_dup_mmap();
106225 return retval;
106226-fail_nomem_anon_vma_fork:
106227- mpol_put(vma_policy(tmp));
106228-fail_nomem_policy:
106229- kmem_cache_free(vm_area_cachep, tmp);
106230-fail_nomem:
106231- retval = -ENOMEM;
106232- vm_unacct_memory(charge);
106233- goto out;
106234 }
106235
106236 static inline int mm_alloc_pgd(struct mm_struct *mm)
106237@@ -795,8 +891,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
106238 return ERR_PTR(err);
106239
106240 mm = get_task_mm(task);
106241- if (mm && mm != current->mm &&
106242- !ptrace_may_access(task, mode)) {
106243+ if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
106244+ (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
106245 mmput(mm);
106246 mm = ERR_PTR(-EACCES);
106247 }
106248@@ -997,13 +1093,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
106249 spin_unlock(&fs->lock);
106250 return -EAGAIN;
106251 }
106252- fs->users++;
106253+ atomic_inc(&fs->users);
106254 spin_unlock(&fs->lock);
106255 return 0;
106256 }
106257 tsk->fs = copy_fs_struct(fs);
106258 if (!tsk->fs)
106259 return -ENOMEM;
106260+ /* Carry through gr_chroot_dentry and is_chrooted instead
106261+ of recomputing it here. Already copied when the task struct
106262+ is duplicated. This allows pivot_root to not be treated as
106263+ a chroot
106264+ */
106265+ //gr_set_chroot_entries(tsk, &tsk->fs->root);
106266+
106267 return 0;
106268 }
106269
106270@@ -1238,7 +1341,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
106271 * parts of the process environment (as per the clone
106272 * flags). The actual kick-off is left to the caller.
106273 */
106274-static struct task_struct *copy_process(unsigned long clone_flags,
106275+static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
106276 unsigned long stack_start,
106277 unsigned long stack_size,
106278 int __user *child_tidptr,
106279@@ -1310,6 +1413,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
106280 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
106281 #endif
106282 retval = -EAGAIN;
106283+
106284+ gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
106285+
106286 if (atomic_read(&p->real_cred->user->processes) >=
106287 task_rlimit(p, RLIMIT_NPROC)) {
106288 if (p->real_cred->user != INIT_USER &&
106289@@ -1560,6 +1666,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
106290 goto bad_fork_free_pid;
106291 }
106292
106293+ /* synchronizes with gr_set_acls()
106294+ we need to call this past the point of no return for fork()
106295+ */
106296+ gr_copy_label(p);
106297+
106298 if (likely(p->pid)) {
106299 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
106300
106301@@ -1649,6 +1760,8 @@ bad_fork_cleanup_count:
106302 bad_fork_free:
106303 free_task(p);
106304 fork_out:
106305+ gr_log_forkfail(retval);
106306+
106307 return ERR_PTR(retval);
106308 }
106309
106310@@ -1711,6 +1824,7 @@ long _do_fork(unsigned long clone_flags,
106311
106312 p = copy_process(clone_flags, stack_start, stack_size,
106313 child_tidptr, NULL, trace, tls);
106314+ add_latent_entropy();
106315 /*
106316 * Do this prior waking up the new thread - the thread pointer
106317 * might get invalid after that point, if the thread exits quickly.
106318@@ -1727,6 +1841,8 @@ long _do_fork(unsigned long clone_flags,
106319 if (clone_flags & CLONE_PARENT_SETTID)
106320 put_user(nr, parent_tidptr);
106321
106322+ gr_handle_brute_check();
106323+
106324 if (clone_flags & CLONE_VFORK) {
106325 p->vfork_done = &vfork;
106326 init_completion(&vfork);
106327@@ -1859,7 +1975,7 @@ void __init proc_caches_init(void)
106328 mm_cachep = kmem_cache_create("mm_struct",
106329 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
106330 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
106331- vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
106332+ vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
106333 mmap_init();
106334 nsproxy_cache_init();
106335 }
106336@@ -1907,7 +2023,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
106337 return 0;
106338
106339 /* don't need lock here; in the worst case we'll do useless copy */
106340- if (fs->users == 1)
106341+ if (atomic_read(&fs->users) == 1)
106342 return 0;
106343
106344 *new_fsp = copy_fs_struct(fs);
106345@@ -2019,7 +2135,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
106346 fs = current->fs;
106347 spin_lock(&fs->lock);
106348 current->fs = new_fs;
106349- if (--fs->users)
106350+ gr_set_chroot_entries(current, &current->fs->root);
106351+ if (atomic_dec_return(&fs->users))
106352 new_fs = NULL;
106353 else
106354 new_fs = fs;
106355@@ -2083,7 +2200,7 @@ int unshare_files(struct files_struct **displaced)
106356 int sysctl_max_threads(struct ctl_table *table, int write,
106357 void __user *buffer, size_t *lenp, loff_t *ppos)
106358 {
106359- struct ctl_table t;
106360+ ctl_table_no_const t;
106361 int ret;
106362 int threads = max_threads;
106363 int min = MIN_THREADS;
106364diff --git a/kernel/futex.c b/kernel/futex.c
106365index c4a182f..e789324 100644
106366--- a/kernel/futex.c
106367+++ b/kernel/futex.c
106368@@ -201,7 +201,7 @@ struct futex_pi_state {
106369 atomic_t refcount;
106370
106371 union futex_key key;
106372-};
106373+} __randomize_layout;
106374
106375 /**
106376 * struct futex_q - The hashed futex queue entry, one per waiting task
106377@@ -235,7 +235,7 @@ struct futex_q {
106378 struct rt_mutex_waiter *rt_waiter;
106379 union futex_key *requeue_pi_key;
106380 u32 bitset;
106381-};
106382+} __randomize_layout;
106383
106384 static const struct futex_q futex_q_init = {
106385 /* list gets initialized in queue_me()*/
106386@@ -402,6 +402,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
106387 struct page *page, *page_head;
106388 int err, ro = 0;
106389
106390+#ifdef CONFIG_PAX_SEGMEXEC
106391+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
106392+ return -EFAULT;
106393+#endif
106394+
106395 /*
106396 * The futex address must be "naturally" aligned.
106397 */
106398@@ -601,7 +606,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
106399
106400 static int get_futex_value_locked(u32 *dest, u32 __user *from)
106401 {
106402- int ret;
106403+ unsigned long ret;
106404
106405 pagefault_disable();
106406 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
106407@@ -3030,6 +3035,7 @@ static void __init futex_detect_cmpxchg(void)
106408 {
106409 #ifndef CONFIG_HAVE_FUTEX_CMPXCHG
106410 u32 curval;
106411+ mm_segment_t oldfs;
106412
106413 /*
106414 * This will fail and we want it. Some arch implementations do
106415@@ -3041,8 +3047,11 @@ static void __init futex_detect_cmpxchg(void)
106416 * implementation, the non-functional ones will return
106417 * -ENOSYS.
106418 */
106419+ oldfs = get_fs();
106420+ set_fs(USER_DS);
106421 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
106422 futex_cmpxchg_enabled = 1;
106423+ set_fs(oldfs);
106424 #endif
106425 }
106426
106427diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
106428index 55c8c93..9ba7ad6 100644
106429--- a/kernel/futex_compat.c
106430+++ b/kernel/futex_compat.c
106431@@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
106432 return 0;
106433 }
106434
106435-static void __user *futex_uaddr(struct robust_list __user *entry,
106436+static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
106437 compat_long_t futex_offset)
106438 {
106439 compat_uptr_t base = ptr_to_compat(entry);
106440diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
106441index 7080ae1..c9b3761 100644
106442--- a/kernel/gcov/base.c
106443+++ b/kernel/gcov/base.c
106444@@ -123,11 +123,6 @@ void gcov_enable_events(void)
106445 }
106446
106447 #ifdef CONFIG_MODULES
106448-static inline int within(void *addr, void *start, unsigned long size)
106449-{
106450- return ((addr >= start) && (addr < start + size));
106451-}
106452-
106453 /* Update list and generate events when modules are unloaded. */
106454 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
106455 void *data)
106456@@ -142,7 +137,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
106457
106458 /* Remove entries located in module from linked list. */
106459 while ((info = gcov_info_next(info))) {
106460- if (within(info, mod->module_core, mod->core_size)) {
106461+ if (within_module_core_rw((unsigned long)info, mod)) {
106462 gcov_info_unlink(prev, info);
106463 if (gcov_events_enabled)
106464 gcov_event(GCOV_REMOVE, info);
106465diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
106466index f974485..c5b8afd 100644
106467--- a/kernel/irq/manage.c
106468+++ b/kernel/irq/manage.c
106469@@ -937,7 +937,7 @@ static int irq_thread(void *data)
106470
106471 action_ret = handler_fn(desc, action);
106472 if (action_ret == IRQ_HANDLED)
106473- atomic_inc(&desc->threads_handled);
106474+ atomic_inc_unchecked(&desc->threads_handled);
106475
106476 wake_threads_waitq(desc);
106477 }
106478diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
106479index 7bf1f1b..d73e508 100644
106480--- a/kernel/irq/msi.c
106481+++ b/kernel/irq/msi.c
106482@@ -195,16 +195,18 @@ static void msi_domain_update_dom_ops(struct msi_domain_info *info)
106483 return;
106484 }
106485
106486+ pax_open_kernel();
106487 if (ops->get_hwirq == NULL)
106488- ops->get_hwirq = msi_domain_ops_default.get_hwirq;
106489+ *(void **)&ops->get_hwirq = msi_domain_ops_default.get_hwirq;
106490 if (ops->msi_init == NULL)
106491- ops->msi_init = msi_domain_ops_default.msi_init;
106492+ *(void **)&ops->msi_init = msi_domain_ops_default.msi_init;
106493 if (ops->msi_check == NULL)
106494- ops->msi_check = msi_domain_ops_default.msi_check;
106495+ *(void **)&ops->msi_check = msi_domain_ops_default.msi_check;
106496 if (ops->msi_prepare == NULL)
106497- ops->msi_prepare = msi_domain_ops_default.msi_prepare;
106498+ *(void **)&ops->msi_prepare = msi_domain_ops_default.msi_prepare;
106499 if (ops->set_desc == NULL)
106500- ops->set_desc = msi_domain_ops_default.set_desc;
106501+ *(void **)&ops->set_desc = msi_domain_ops_default.set_desc;
106502+ pax_close_kernel();
106503 }
106504
106505 static void msi_domain_update_chip_ops(struct msi_domain_info *info)
106506@@ -212,12 +214,14 @@ static void msi_domain_update_chip_ops(struct msi_domain_info *info)
106507 struct irq_chip *chip = info->chip;
106508
106509 BUG_ON(!chip);
106510+ pax_open_kernel();
106511 if (!chip->irq_mask)
106512- chip->irq_mask = pci_msi_mask_irq;
106513+ *(void **)&chip->irq_mask = pci_msi_mask_irq;
106514 if (!chip->irq_unmask)
106515- chip->irq_unmask = pci_msi_unmask_irq;
106516+ *(void **)&chip->irq_unmask = pci_msi_unmask_irq;
106517 if (!chip->irq_set_affinity)
106518- chip->irq_set_affinity = msi_domain_set_affinity;
106519+ *(void **)&chip->irq_set_affinity = msi_domain_set_affinity;
106520+ pax_close_kernel();
106521 }
106522
106523 /**
106524diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
106525index e2514b0..de3dfe0 100644
106526--- a/kernel/irq/spurious.c
106527+++ b/kernel/irq/spurious.c
106528@@ -337,7 +337,7 @@ void note_interrupt(unsigned int irq, struct irq_desc *desc,
106529 * count. We just care about the count being
106530 * different than the one we saw before.
106531 */
106532- handled = atomic_read(&desc->threads_handled);
106533+ handled = atomic_read_unchecked(&desc->threads_handled);
106534 handled |= SPURIOUS_DEFERRED;
106535 if (handled != desc->threads_handled_last) {
106536 action_ret = IRQ_HANDLED;
106537diff --git a/kernel/jump_label.c b/kernel/jump_label.c
106538index 52ebaca..ec6f5cb 100644
106539--- a/kernel/jump_label.c
106540+++ b/kernel/jump_label.c
106541@@ -14,6 +14,7 @@
106542 #include <linux/err.h>
106543 #include <linux/static_key.h>
106544 #include <linux/jump_label_ratelimit.h>
106545+#include <linux/mm.h>
106546
106547 #ifdef HAVE_JUMP_LABEL
106548
106549@@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
106550
106551 size = (((unsigned long)stop - (unsigned long)start)
106552 / sizeof(struct jump_entry));
106553+ pax_open_kernel();
106554 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
106555+ pax_close_kernel();
106556 }
106557
106558 static void jump_label_update(struct static_key *key, int enable);
106559@@ -363,10 +366,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
106560 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
106561 struct jump_entry *iter;
106562
106563+ pax_open_kernel();
106564 for (iter = iter_start; iter < iter_stop; iter++) {
106565 if (within_module_init(iter->code, mod))
106566 iter->code = 0;
106567 }
106568+ pax_close_kernel();
106569 }
106570
106571 static int
106572diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
106573index 5c5987f..bc502b0 100644
106574--- a/kernel/kallsyms.c
106575+++ b/kernel/kallsyms.c
106576@@ -11,6 +11,9 @@
106577 * Changed the compression method from stem compression to "table lookup"
106578 * compression (see scripts/kallsyms.c for a more complete description)
106579 */
106580+#ifdef CONFIG_GRKERNSEC_HIDESYM
106581+#define __INCLUDED_BY_HIDESYM 1
106582+#endif
106583 #include <linux/kallsyms.h>
106584 #include <linux/module.h>
106585 #include <linux/init.h>
106586@@ -54,12 +57,33 @@ extern const unsigned long kallsyms_markers[] __weak;
106587
106588 static inline int is_kernel_inittext(unsigned long addr)
106589 {
106590+ if (system_state != SYSTEM_BOOTING)
106591+ return 0;
106592+
106593 if (addr >= (unsigned long)_sinittext
106594 && addr <= (unsigned long)_einittext)
106595 return 1;
106596 return 0;
106597 }
106598
106599+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
106600+#ifdef CONFIG_MODULES
106601+static inline int is_module_text(unsigned long addr)
106602+{
106603+ if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
106604+ return 1;
106605+
106606+ addr = ktla_ktva(addr);
106607+ return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
106608+}
106609+#else
106610+static inline int is_module_text(unsigned long addr)
106611+{
106612+ return 0;
106613+}
106614+#endif
106615+#endif
106616+
106617 static inline int is_kernel_text(unsigned long addr)
106618 {
106619 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
106620@@ -70,13 +94,28 @@ static inline int is_kernel_text(unsigned long addr)
106621
106622 static inline int is_kernel(unsigned long addr)
106623 {
106624+
106625+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
106626+ if (is_kernel_text(addr) || is_kernel_inittext(addr))
106627+ return 1;
106628+
106629+ if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
106630+#else
106631 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
106632+#endif
106633+
106634 return 1;
106635 return in_gate_area_no_mm(addr);
106636 }
106637
106638 static int is_ksym_addr(unsigned long addr)
106639 {
106640+
106641+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
106642+ if (is_module_text(addr))
106643+ return 0;
106644+#endif
106645+
106646 if (all_var)
106647 return is_kernel(addr);
106648
106649@@ -481,7 +520,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
106650
106651 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
106652 {
106653- iter->name[0] = '\0';
106654 iter->nameoff = get_symbol_offset(new_pos);
106655 iter->pos = new_pos;
106656 }
106657@@ -529,6 +567,11 @@ static int s_show(struct seq_file *m, void *p)
106658 {
106659 struct kallsym_iter *iter = m->private;
106660
106661+#ifdef CONFIG_GRKERNSEC_HIDESYM
106662+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
106663+ return 0;
106664+#endif
106665+
106666 /* Some debugging symbols have no name. Ignore them. */
106667 if (!iter->name[0])
106668 return 0;
106669@@ -542,6 +585,7 @@ static int s_show(struct seq_file *m, void *p)
106670 */
106671 type = iter->exported ? toupper(iter->type) :
106672 tolower(iter->type);
106673+
106674 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
106675 type, iter->name, iter->module_name);
106676 } else
106677diff --git a/kernel/kcmp.c b/kernel/kcmp.c
106678index 0aa69ea..a7fcafb 100644
106679--- a/kernel/kcmp.c
106680+++ b/kernel/kcmp.c
106681@@ -100,6 +100,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
106682 struct task_struct *task1, *task2;
106683 int ret;
106684
106685+#ifdef CONFIG_GRKERNSEC
106686+ return -ENOSYS;
106687+#endif
106688+
106689 rcu_read_lock();
106690
106691 /*
106692diff --git a/kernel/kexec.c b/kernel/kexec.c
106693index a785c10..6dbb06f 100644
106694--- a/kernel/kexec.c
106695+++ b/kernel/kexec.c
106696@@ -1243,7 +1243,7 @@ static int kimage_load_segment(struct kimage *image,
106697 */
106698 struct kimage *kexec_image;
106699 struct kimage *kexec_crash_image;
106700-int kexec_load_disabled;
106701+int kexec_load_disabled __read_only;
106702
106703 static DEFINE_MUTEX(kexec_mutex);
106704
106705@@ -1359,7 +1359,8 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,
106706 compat_ulong_t, flags)
106707 {
106708 struct compat_kexec_segment in;
106709- struct kexec_segment out, __user *ksegments;
106710+ struct kexec_segment out;
106711+ struct kexec_segment __user *ksegments;
106712 unsigned long i, result;
106713
106714 /* Don't allow clients that don't understand the native
106715diff --git a/kernel/kmod.c b/kernel/kmod.c
106716index 2777f40..a689506 100644
106717--- a/kernel/kmod.c
106718+++ b/kernel/kmod.c
106719@@ -68,7 +68,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
106720 kfree(info->argv);
106721 }
106722
106723-static int call_modprobe(char *module_name, int wait)
106724+static int call_modprobe(char *module_name, char *module_param, int wait)
106725 {
106726 struct subprocess_info *info;
106727 static char *envp[] = {
106728@@ -78,7 +78,7 @@ static int call_modprobe(char *module_name, int wait)
106729 NULL
106730 };
106731
106732- char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
106733+ char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
106734 if (!argv)
106735 goto out;
106736
106737@@ -90,7 +90,8 @@ static int call_modprobe(char *module_name, int wait)
106738 argv[1] = "-q";
106739 argv[2] = "--";
106740 argv[3] = module_name; /* check free_modprobe_argv() */
106741- argv[4] = NULL;
106742+ argv[4] = module_param;
106743+ argv[5] = NULL;
106744
106745 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
106746 NULL, free_modprobe_argv, NULL);
106747@@ -122,9 +123,8 @@ out:
106748 * If module auto-loading support is disabled then this function
106749 * becomes a no-operation.
106750 */
106751-int __request_module(bool wait, const char *fmt, ...)
106752+static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
106753 {
106754- va_list args;
106755 char module_name[MODULE_NAME_LEN];
106756 unsigned int max_modprobes;
106757 int ret;
106758@@ -143,9 +143,7 @@ int __request_module(bool wait, const char *fmt, ...)
106759 if (!modprobe_path[0])
106760 return 0;
106761
106762- va_start(args, fmt);
106763- ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
106764- va_end(args);
106765+ ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
106766 if (ret >= MODULE_NAME_LEN)
106767 return -ENAMETOOLONG;
106768
106769@@ -153,6 +151,20 @@ int __request_module(bool wait, const char *fmt, ...)
106770 if (ret)
106771 return ret;
106772
106773+#ifdef CONFIG_GRKERNSEC_MODHARDEN
106774+ if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
106775+ /* hack to workaround consolekit/udisks stupidity */
106776+ read_lock(&tasklist_lock);
106777+ if (!strcmp(current->comm, "mount") &&
106778+ current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
106779+ read_unlock(&tasklist_lock);
106780+ printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
106781+ return -EPERM;
106782+ }
106783+ read_unlock(&tasklist_lock);
106784+ }
106785+#endif
106786+
106787 /* If modprobe needs a service that is in a module, we get a recursive
106788 * loop. Limit the number of running kmod threads to max_threads/2 or
106789 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
106790@@ -181,16 +193,61 @@ int __request_module(bool wait, const char *fmt, ...)
106791
106792 trace_module_request(module_name, wait, _RET_IP_);
106793
106794- ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
106795+ ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
106796
106797 atomic_dec(&kmod_concurrent);
106798 return ret;
106799 }
106800+
106801+int ___request_module(bool wait, char *module_param, const char *fmt, ...)
106802+{
106803+ va_list args;
106804+ int ret;
106805+
106806+ va_start(args, fmt);
106807+ ret = ____request_module(wait, module_param, fmt, args);
106808+ va_end(args);
106809+
106810+ return ret;
106811+}
106812+
106813+int __request_module(bool wait, const char *fmt, ...)
106814+{
106815+ va_list args;
106816+ int ret;
106817+
106818+#ifdef CONFIG_GRKERNSEC_MODHARDEN
106819+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
106820+ char module_param[MODULE_NAME_LEN];
106821+
106822+ memset(module_param, 0, sizeof(module_param));
106823+
106824+ snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
106825+
106826+ va_start(args, fmt);
106827+ ret = ____request_module(wait, module_param, fmt, args);
106828+ va_end(args);
106829+
106830+ return ret;
106831+ }
106832+#endif
106833+
106834+ va_start(args, fmt);
106835+ ret = ____request_module(wait, NULL, fmt, args);
106836+ va_end(args);
106837+
106838+ return ret;
106839+}
106840+
106841 EXPORT_SYMBOL(__request_module);
106842 #endif /* CONFIG_MODULES */
106843
106844 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
106845 {
106846+#ifdef CONFIG_GRKERNSEC
106847+ kfree(info->path);
106848+ info->path = info->origpath;
106849+#endif
106850 if (info->cleanup)
106851 (*info->cleanup)(info);
106852 kfree(info);
106853@@ -232,6 +289,21 @@ static int ____call_usermodehelper(void *data)
106854 */
106855 set_user_nice(current, 0);
106856
106857+#ifdef CONFIG_GRKERNSEC
106858+ /* this is race-free as far as userland is concerned as we copied
106859+ out the path to be used prior to this point and are now operating
106860+ on that copy
106861+ */
106862+ if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/", 9) &&
106863+ strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7) &&
106864+ strncmp(sub_info->path, "/usr/libexec/", 13) && strncmp(sub_info->path, "/usr/bin/", 9) &&
106865+ strcmp(sub_info->path, "/usr/share/apport/apport")) || strstr(sub_info->path, "..")) {
106866+ printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of permitted system paths\n", sub_info->path);
106867+ retval = -EPERM;
106868+ goto out;
106869+ }
106870+#endif
106871+
106872 retval = -ENOMEM;
106873 new = prepare_kernel_cred(current);
106874 if (!new)
106875@@ -254,8 +326,8 @@ static int ____call_usermodehelper(void *data)
106876 commit_creds(new);
106877
106878 retval = do_execve(getname_kernel(sub_info->path),
106879- (const char __user *const __user *)sub_info->argv,
106880- (const char __user *const __user *)sub_info->envp);
106881+ (const char __user *const __force_user *)sub_info->argv,
106882+ (const char __user *const __force_user *)sub_info->envp);
106883 out:
106884 sub_info->retval = retval;
106885 /* wait_for_helper() will call umh_complete if UHM_WAIT_PROC. */
106886@@ -288,7 +360,7 @@ static int wait_for_helper(void *data)
106887 *
106888 * Thus the __user pointer cast is valid here.
106889 */
106890- sys_wait4(pid, (int __user *)&ret, 0, NULL);
106891+ sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
106892
106893 /*
106894 * If ret is 0, either ____call_usermodehelper failed and the
106895@@ -510,7 +582,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
106896 goto out;
106897
106898 INIT_WORK(&sub_info->work, __call_usermodehelper);
106899+#ifdef CONFIG_GRKERNSEC
106900+ sub_info->origpath = path;
106901+ sub_info->path = kstrdup(path, gfp_mask);
106902+#else
106903 sub_info->path = path;
106904+#endif
106905 sub_info->argv = argv;
106906 sub_info->envp = envp;
106907
106908@@ -612,7 +689,7 @@ EXPORT_SYMBOL(call_usermodehelper);
106909 static int proc_cap_handler(struct ctl_table *table, int write,
106910 void __user *buffer, size_t *lenp, loff_t *ppos)
106911 {
106912- struct ctl_table t;
106913+ ctl_table_no_const t;
106914 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
106915 kernel_cap_t new_cap;
106916 int err, i;
106917diff --git a/kernel/kprobes.c b/kernel/kprobes.c
106918index c90e417..e6c515d 100644
106919--- a/kernel/kprobes.c
106920+++ b/kernel/kprobes.c
106921@@ -31,6 +31,9 @@
106922 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
106923 * <prasanna@in.ibm.com> added function-return probes.
106924 */
106925+#ifdef CONFIG_GRKERNSEC_HIDESYM
106926+#define __INCLUDED_BY_HIDESYM 1
106927+#endif
106928 #include <linux/kprobes.h>
106929 #include <linux/hash.h>
106930 #include <linux/init.h>
106931@@ -122,12 +125,12 @@ enum kprobe_slot_state {
106932
106933 static void *alloc_insn_page(void)
106934 {
106935- return module_alloc(PAGE_SIZE);
106936+ return module_alloc_exec(PAGE_SIZE);
106937 }
106938
106939 static void free_insn_page(void *page)
106940 {
106941- module_memfree(page);
106942+ module_memfree_exec(page);
106943 }
106944
106945 struct kprobe_insn_cache kprobe_insn_slots = {
106946@@ -2198,11 +2201,11 @@ static void report_probe(struct seq_file *pi, struct kprobe *p,
106947 kprobe_type = "k";
106948
106949 if (sym)
106950- seq_printf(pi, "%p %s %s+0x%x %s ",
106951+ seq_printf(pi, "%pK %s %s+0x%x %s ",
106952 p->addr, kprobe_type, sym, offset,
106953 (modname ? modname : " "));
106954 else
106955- seq_printf(pi, "%p %s %p ",
106956+ seq_printf(pi, "%pK %s %pK ",
106957 p->addr, kprobe_type, p->addr);
106958
106959 if (!pp)
106960diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
106961index 6683cce..daf8999 100644
106962--- a/kernel/ksysfs.c
106963+++ b/kernel/ksysfs.c
106964@@ -50,6 +50,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
106965 {
106966 if (count+1 > UEVENT_HELPER_PATH_LEN)
106967 return -ENOENT;
106968+ if (!capable(CAP_SYS_ADMIN))
106969+ return -EPERM;
106970 memcpy(uevent_helper, buf, count);
106971 uevent_helper[count] = '\0';
106972 if (count && uevent_helper[count-1] == '\n')
106973@@ -176,7 +178,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
106974 return count;
106975 }
106976
106977-static struct bin_attribute notes_attr = {
106978+static bin_attribute_no_const notes_attr __read_only = {
106979 .attr = {
106980 .name = "notes",
106981 .mode = S_IRUGO,
106982diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
106983index 8acfbf7..0c5a34a 100644
106984--- a/kernel/locking/lockdep.c
106985+++ b/kernel/locking/lockdep.c
106986@@ -613,6 +613,10 @@ static int static_obj(void *obj)
106987 end = (unsigned long) &_end,
106988 addr = (unsigned long) obj;
106989
106990+#ifdef CONFIG_PAX_KERNEXEC
106991+ start = ktla_ktva(start);
106992+#endif
106993+
106994 /*
106995 * static variable?
106996 */
106997@@ -757,6 +761,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
106998 if (!static_obj(lock->key)) {
106999 debug_locks_off();
107000 printk("INFO: trying to register non-static key.\n");
107001+ printk("lock:%pS key:%pS.\n", lock, lock->key);
107002 printk("the code is fine but needs lockdep annotation.\n");
107003 printk("turning off the locking correctness validator.\n");
107004 dump_stack();
107005@@ -3102,7 +3107,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
107006 if (!class)
107007 return 0;
107008 }
107009- atomic_inc((atomic_t *)&class->ops);
107010+ atomic_long_inc_unchecked((atomic_long_unchecked_t *)&class->ops);
107011 if (very_verbose(class)) {
107012 printk("\nacquire class [%p] %s", class->key, class->name);
107013 if (class->name_version > 1)
107014diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
107015index d83d798..ea3120d 100644
107016--- a/kernel/locking/lockdep_proc.c
107017+++ b/kernel/locking/lockdep_proc.c
107018@@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
107019 return 0;
107020 }
107021
107022- seq_printf(m, "%p", class->key);
107023+ seq_printf(m, "%pK", class->key);
107024 #ifdef CONFIG_DEBUG_LOCKDEP
107025 seq_printf(m, " OPS:%8ld", class->ops);
107026 #endif
107027@@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
107028
107029 list_for_each_entry(entry, &class->locks_after, entry) {
107030 if (entry->distance == 1) {
107031- seq_printf(m, " -> [%p] ", entry->class->key);
107032+ seq_printf(m, " -> [%pK] ", entry->class->key);
107033 print_name(m, entry->class);
107034 seq_puts(m, "\n");
107035 }
107036@@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
107037 if (!class->key)
107038 continue;
107039
107040- seq_printf(m, "[%p] ", class->key);
107041+ seq_printf(m, "[%pK] ", class->key);
107042 print_name(m, class);
107043 seq_puts(m, "\n");
107044 }
107045@@ -508,7 +508,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
107046 if (!i)
107047 seq_line(m, '-', 40-namelen, namelen);
107048
107049- snprintf(ip, sizeof(ip), "[<%p>]",
107050+ snprintf(ip, sizeof(ip), "[<%pK>]",
107051 (void *)class->contention_point[i]);
107052 seq_printf(m, "%40s %14lu %29s %pS\n",
107053 name, stats->contention_point[i],
107054@@ -523,7 +523,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
107055 if (!i)
107056 seq_line(m, '-', 40-namelen, namelen);
107057
107058- snprintf(ip, sizeof(ip), "[<%p>]",
107059+ snprintf(ip, sizeof(ip), "[<%pK>]",
107060 (void *)class->contending_point[i]);
107061 seq_printf(m, "%40s %14lu %29s %pS\n",
107062 name, stats->contending_point[i],
107063diff --git a/kernel/locking/mutex-debug.c b/kernel/locking/mutex-debug.c
107064index 3ef3736..9c951fa 100644
107065--- a/kernel/locking/mutex-debug.c
107066+++ b/kernel/locking/mutex-debug.c
107067@@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
107068 }
107069
107070 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
107071- struct thread_info *ti)
107072+ struct task_struct *task)
107073 {
107074 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
107075
107076 /* Mark the current thread as blocked on the lock: */
107077- ti->task->blocked_on = waiter;
107078+ task->blocked_on = waiter;
107079 }
107080
107081 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
107082- struct thread_info *ti)
107083+ struct task_struct *task)
107084 {
107085 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
107086- DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
107087- DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
107088- ti->task->blocked_on = NULL;
107089+ DEBUG_LOCKS_WARN_ON(waiter->task != task);
107090+ DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
107091+ task->blocked_on = NULL;
107092
107093 list_del_init(&waiter->list);
107094 waiter->task = NULL;
107095diff --git a/kernel/locking/mutex-debug.h b/kernel/locking/mutex-debug.h
107096index 0799fd3..d06ae3b 100644
107097--- a/kernel/locking/mutex-debug.h
107098+++ b/kernel/locking/mutex-debug.h
107099@@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
107100 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
107101 extern void debug_mutex_add_waiter(struct mutex *lock,
107102 struct mutex_waiter *waiter,
107103- struct thread_info *ti);
107104+ struct task_struct *task);
107105 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
107106- struct thread_info *ti);
107107+ struct task_struct *task);
107108 extern void debug_mutex_unlock(struct mutex *lock);
107109 extern void debug_mutex_init(struct mutex *lock, const char *name,
107110 struct lock_class_key *key);
107111diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
107112index 4cccea6..4382db9 100644
107113--- a/kernel/locking/mutex.c
107114+++ b/kernel/locking/mutex.c
107115@@ -533,7 +533,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
107116 goto skip_wait;
107117
107118 debug_mutex_lock_common(lock, &waiter);
107119- debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
107120+ debug_mutex_add_waiter(lock, &waiter, task);
107121
107122 /* add waiting tasks to the end of the waitqueue (FIFO): */
107123 list_add_tail(&waiter.list, &lock->wait_list);
107124@@ -580,7 +580,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
107125 }
107126 __set_task_state(task, TASK_RUNNING);
107127
107128- mutex_remove_waiter(lock, &waiter, current_thread_info());
107129+ mutex_remove_waiter(lock, &waiter, task);
107130 /* set it to 0 if there are no waiters left: */
107131 if (likely(list_empty(&lock->wait_list)))
107132 atomic_set(&lock->count, 0);
107133@@ -601,7 +601,7 @@ skip_wait:
107134 return 0;
107135
107136 err:
107137- mutex_remove_waiter(lock, &waiter, task_thread_info(task));
107138+ mutex_remove_waiter(lock, &waiter, task);
107139 spin_unlock_mutex(&lock->wait_lock, flags);
107140 debug_mutex_free_waiter(&waiter);
107141 mutex_release(&lock->dep_map, 1, ip);
107142diff --git a/kernel/locking/rtmutex-tester.c b/kernel/locking/rtmutex-tester.c
107143index 1d96dd0..994ff19 100644
107144--- a/kernel/locking/rtmutex-tester.c
107145+++ b/kernel/locking/rtmutex-tester.c
107146@@ -22,7 +22,7 @@
107147 #define MAX_RT_TEST_MUTEXES 8
107148
107149 static spinlock_t rttest_lock;
107150-static atomic_t rttest_event;
107151+static atomic_unchecked_t rttest_event;
107152
107153 struct test_thread_data {
107154 int opcode;
107155@@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
107156
107157 case RTTEST_LOCKCONT:
107158 td->mutexes[td->opdata] = 1;
107159- td->event = atomic_add_return(1, &rttest_event);
107160+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107161 return 0;
107162
107163 case RTTEST_RESET:
107164@@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
107165 return 0;
107166
107167 case RTTEST_RESETEVENT:
107168- atomic_set(&rttest_event, 0);
107169+ atomic_set_unchecked(&rttest_event, 0);
107170 return 0;
107171
107172 default:
107173@@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
107174 return ret;
107175
107176 td->mutexes[id] = 1;
107177- td->event = atomic_add_return(1, &rttest_event);
107178+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107179 rt_mutex_lock(&mutexes[id]);
107180- td->event = atomic_add_return(1, &rttest_event);
107181+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107182 td->mutexes[id] = 4;
107183 return 0;
107184
107185@@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
107186 return ret;
107187
107188 td->mutexes[id] = 1;
107189- td->event = atomic_add_return(1, &rttest_event);
107190+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107191 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
107192- td->event = atomic_add_return(1, &rttest_event);
107193+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107194 td->mutexes[id] = ret ? 0 : 4;
107195 return ret ? -EINTR : 0;
107196
107197@@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
107198 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
107199 return ret;
107200
107201- td->event = atomic_add_return(1, &rttest_event);
107202+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107203 rt_mutex_unlock(&mutexes[id]);
107204- td->event = atomic_add_return(1, &rttest_event);
107205+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107206 td->mutexes[id] = 0;
107207 return 0;
107208
107209@@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
107210 break;
107211
107212 td->mutexes[dat] = 2;
107213- td->event = atomic_add_return(1, &rttest_event);
107214+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107215 break;
107216
107217 default:
107218@@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
107219 return;
107220
107221 td->mutexes[dat] = 3;
107222- td->event = atomic_add_return(1, &rttest_event);
107223+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107224 break;
107225
107226 case RTTEST_LOCKNOWAIT:
107227@@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
107228 return;
107229
107230 td->mutexes[dat] = 1;
107231- td->event = atomic_add_return(1, &rttest_event);
107232+ td->event = atomic_add_return_unchecked(1, &rttest_event);
107233 return;
107234
107235 default:
107236diff --git a/kernel/module.c b/kernel/module.c
107237index b86b7bf..f5eaa56 100644
107238--- a/kernel/module.c
107239+++ b/kernel/module.c
107240@@ -59,6 +59,7 @@
107241 #include <linux/jump_label.h>
107242 #include <linux/pfn.h>
107243 #include <linux/bsearch.h>
107244+#include <linux/grsecurity.h>
107245 #include <uapi/linux/module.h>
107246 #include "module-internal.h"
107247
107248@@ -108,7 +109,7 @@ static LIST_HEAD(modules);
107249 * Use a latched RB-tree for __module_address(); this allows us to use
107250 * RCU-sched lookups of the address from any context.
107251 *
107252- * Because modules have two address ranges: init and core, we need two
107253+ * Because modules have four address ranges: init_{rw,rx} and core_{rw,rx}, we need four
107254 * latch_tree_nodes entries. Therefore we need the back-pointer from
107255 * mod_tree_node.
107256 *
107257@@ -125,10 +126,14 @@ static __always_inline unsigned long __mod_tree_val(struct latch_tree_node *n)
107258 struct mod_tree_node *mtn = container_of(n, struct mod_tree_node, node);
107259 struct module *mod = mtn->mod;
107260
107261- if (unlikely(mtn == &mod->mtn_init))
107262- return (unsigned long)mod->module_init;
107263+ if (unlikely(mtn == &mod->mtn_init_rw))
107264+ return (unsigned long)mod->module_init_rw;
107265+ if (unlikely(mtn == &mod->mtn_init_rx))
107266+ return (unsigned long)mod->module_init_rx;
107267
107268- return (unsigned long)mod->module_core;
107269+ if (unlikely(mtn == &mod->mtn_core_rw))
107270+ return (unsigned long)mod->module_core_rw;
107271+ return (unsigned long)mod->module_core_rx;
107272 }
107273
107274 static __always_inline unsigned long __mod_tree_size(struct latch_tree_node *n)
107275@@ -136,10 +141,14 @@ static __always_inline unsigned long __mod_tree_size(struct latch_tree_node *n)
107276 struct mod_tree_node *mtn = container_of(n, struct mod_tree_node, node);
107277 struct module *mod = mtn->mod;
107278
107279- if (unlikely(mtn == &mod->mtn_init))
107280- return (unsigned long)mod->init_size;
107281+ if (unlikely(mtn == &mod->mtn_init_rw))
107282+ return (unsigned long)mod->init_size_rw;
107283+ if (unlikely(mtn == &mod->mtn_init_rx))
107284+ return (unsigned long)mod->init_size_rx;
107285
107286- return (unsigned long)mod->core_size;
107287+ if (unlikely(mtn == &mod->mtn_core_rw))
107288+ return (unsigned long)mod->core_size_rw;
107289+ return (unsigned long)mod->core_size_rx;
107290 }
107291
107292 static __always_inline bool
107293@@ -172,14 +181,19 @@ static const struct latch_tree_ops mod_tree_ops = {
107294
107295 static struct mod_tree_root {
107296 struct latch_tree_root root;
107297- unsigned long addr_min;
107298- unsigned long addr_max;
107299+ unsigned long addr_min_rw;
107300+ unsigned long addr_min_rx;
107301+ unsigned long addr_max_rw;
107302+ unsigned long addr_max_rx;
107303 } mod_tree __cacheline_aligned = {
107304- .addr_min = -1UL,
107305+ .addr_min_rw = -1UL,
107306+ .addr_min_rx = -1UL,
107307 };
107308
107309-#define module_addr_min mod_tree.addr_min
107310-#define module_addr_max mod_tree.addr_max
107311+#define module_addr_min_rw mod_tree.addr_min_rw
107312+#define module_addr_min_rx mod_tree.addr_min_rx
107313+#define module_addr_max_rw mod_tree.addr_max_rw
107314+#define module_addr_max_rx mod_tree.addr_max_rx
107315
107316 static noinline void __mod_tree_insert(struct mod_tree_node *node)
107317 {
107318@@ -197,23 +211,31 @@ static void __mod_tree_remove(struct mod_tree_node *node)
107319 */
107320 static void mod_tree_insert(struct module *mod)
107321 {
107322- mod->mtn_core.mod = mod;
107323- mod->mtn_init.mod = mod;
107324+ mod->mtn_core_rw.mod = mod;
107325+ mod->mtn_core_rx.mod = mod;
107326+ mod->mtn_init_rw.mod = mod;
107327+ mod->mtn_init_rx.mod = mod;
107328
107329- __mod_tree_insert(&mod->mtn_core);
107330- if (mod->init_size)
107331- __mod_tree_insert(&mod->mtn_init);
107332+ __mod_tree_insert(&mod->mtn_core_rw);
107333+ __mod_tree_insert(&mod->mtn_core_rx);
107334+ if (mod->init_size_rw)
107335+ __mod_tree_insert(&mod->mtn_init_rw);
107336+ if (mod->init_size_rx)
107337+ __mod_tree_insert(&mod->mtn_init_rx);
107338 }
107339
107340 static void mod_tree_remove_init(struct module *mod)
107341 {
107342- if (mod->init_size)
107343- __mod_tree_remove(&mod->mtn_init);
107344+ if (mod->init_size_rw)
107345+ __mod_tree_remove(&mod->mtn_init_rw);
107346+ if (mod->init_size_rx)
107347+ __mod_tree_remove(&mod->mtn_init_rx);
107348 }
107349
107350 static void mod_tree_remove(struct module *mod)
107351 {
107352- __mod_tree_remove(&mod->mtn_core);
107353+ __mod_tree_remove(&mod->mtn_core_rw);
107354+ __mod_tree_remove(&mod->mtn_core_rx);
107355 mod_tree_remove_init(mod);
107356 }
107357
107358@@ -230,7 +252,8 @@ static struct module *mod_find(unsigned long addr)
107359
107360 #else /* MODULES_TREE_LOOKUP */
107361
107362-static unsigned long module_addr_min = -1UL, module_addr_max = 0;
107363+static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
107364+static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
107365
107366 static void mod_tree_insert(struct module *mod) { }
107367 static void mod_tree_remove_init(struct module *mod) { }
107368@@ -254,22 +277,36 @@ static struct module *mod_find(unsigned long addr)
107369 * Bounds of module text, for speeding up __module_address.
107370 * Protected by module_mutex.
107371 */
107372-static void __mod_update_bounds(void *base, unsigned int size)
107373+static void __mod_update_bounds_rw(void *base, unsigned int size)
107374 {
107375 unsigned long min = (unsigned long)base;
107376 unsigned long max = min + size;
107377
107378- if (min < module_addr_min)
107379- module_addr_min = min;
107380- if (max > module_addr_max)
107381- module_addr_max = max;
107382+ if (min < module_addr_min_rw)
107383+ module_addr_min_rw = min;
107384+ if (max > module_addr_max_rw)
107385+ module_addr_max_rw = max;
107386+}
107387+
107388+static void __mod_update_bounds_rx(void *base, unsigned int size)
107389+{
107390+ unsigned long min = (unsigned long)base;
107391+ unsigned long max = min + size;
107392+
107393+ if (min < module_addr_min_rx)
107394+ module_addr_min_rx = min;
107395+ if (max > module_addr_max_rx)
107396+ module_addr_max_rx = max;
107397 }
107398
107399 static void mod_update_bounds(struct module *mod)
107400 {
107401- __mod_update_bounds(mod->module_core, mod->core_size);
107402- if (mod->init_size)
107403- __mod_update_bounds(mod->module_init, mod->init_size);
107404+ __mod_update_bounds_rw(mod->module_core_rw, mod->core_size_rw);
107405+ __mod_update_bounds_rx(mod->module_core_rx, mod->core_size_rx);
107406+ if (mod->init_size_rw)
107407+ __mod_update_bounds_rw(mod->module_init_rw, mod->init_size_rw);
107408+ if (mod->init_size_rx)
107409+ __mod_update_bounds_rx(mod->module_init_rx, mod->init_size_rx);
107410 }
107411
107412 #ifdef CONFIG_KGDB_KDB
107413@@ -298,7 +335,7 @@ module_param(sig_enforce, bool_enable_only, 0644);
107414 #endif /* !CONFIG_MODULE_SIG_FORCE */
107415
107416 /* Block module loading/unloading? */
107417-int modules_disabled = 0;
107418+int modules_disabled __read_only = 0;
107419 core_param(nomodule, modules_disabled, bint, 0);
107420
107421 /* Waiting for a module to finish initializing? */
107422@@ -473,7 +510,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
107423 return true;
107424
107425 list_for_each_entry_rcu(mod, &modules, list) {
107426- struct symsearch arr[] = {
107427+ struct symsearch modarr[] = {
107428 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
107429 NOT_GPL_ONLY, false },
107430 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
107431@@ -498,7 +535,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
107432 if (mod->state == MODULE_STATE_UNFORMED)
107433 continue;
107434
107435- if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
107436+ if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
107437 return true;
107438 }
107439 return false;
107440@@ -644,7 +681,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
107441 if (!pcpusec->sh_size)
107442 return 0;
107443
107444- if (align > PAGE_SIZE) {
107445+ if (align-1 >= PAGE_SIZE) {
107446 pr_warn("%s: per-cpu alignment %li > %li\n",
107447 mod->name, align, PAGE_SIZE);
107448 align = PAGE_SIZE;
107449@@ -1210,7 +1247,7 @@ struct module_attribute module_uevent =
107450 static ssize_t show_coresize(struct module_attribute *mattr,
107451 struct module_kobject *mk, char *buffer)
107452 {
107453- return sprintf(buffer, "%u\n", mk->mod->core_size);
107454+ return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
107455 }
107456
107457 static struct module_attribute modinfo_coresize =
107458@@ -1219,7 +1256,7 @@ static struct module_attribute modinfo_coresize =
107459 static ssize_t show_initsize(struct module_attribute *mattr,
107460 struct module_kobject *mk, char *buffer)
107461 {
107462- return sprintf(buffer, "%u\n", mk->mod->init_size);
107463+ return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
107464 }
107465
107466 static struct module_attribute modinfo_initsize =
107467@@ -1311,12 +1348,29 @@ static int check_version(Elf_Shdr *sechdrs,
107468 goto bad_version;
107469 }
107470
107471+#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
107472+ /*
107473+ * avoid potentially printing jibberish on attempted load
107474+ * of a module randomized with a different seed
107475+ */
107476+ pr_warn("no symbol version for %s\n", symname);
107477+#else
107478 pr_warn("%s: no symbol version for %s\n", mod->name, symname);
107479+#endif
107480 return 0;
107481
107482 bad_version:
107483+#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
107484+ /*
107485+ * avoid potentially printing jibberish on attempted load
107486+ * of a module randomized with a different seed
107487+ */
107488+ pr_warn("attempted module disagrees about version of symbol %s\n",
107489+ symname);
107490+#else
107491 pr_warn("%s: disagrees about version of symbol %s\n",
107492 mod->name, symname);
107493+#endif
107494 return 0;
107495 }
107496
107497@@ -1444,7 +1498,7 @@ resolve_symbol_wait(struct module *mod,
107498 */
107499 #ifdef CONFIG_SYSFS
107500
107501-#ifdef CONFIG_KALLSYMS
107502+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
107503 static inline bool sect_empty(const Elf_Shdr *sect)
107504 {
107505 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
107506@@ -1582,7 +1636,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
107507 {
107508 unsigned int notes, loaded, i;
107509 struct module_notes_attrs *notes_attrs;
107510- struct bin_attribute *nattr;
107511+ bin_attribute_no_const *nattr;
107512
107513 /* failed to create section attributes, so can't create notes */
107514 if (!mod->sect_attrs)
107515@@ -1694,7 +1748,7 @@ static void del_usage_links(struct module *mod)
107516 static int module_add_modinfo_attrs(struct module *mod)
107517 {
107518 struct module_attribute *attr;
107519- struct module_attribute *temp_attr;
107520+ module_attribute_no_const *temp_attr;
107521 int error = 0;
107522 int i;
107523
107524@@ -1911,21 +1965,21 @@ static void set_section_ro_nx(void *base,
107525
107526 static void unset_module_core_ro_nx(struct module *mod)
107527 {
107528- set_page_attributes(mod->module_core + mod->core_text_size,
107529- mod->module_core + mod->core_size,
107530+ set_page_attributes(mod->module_core_rw,
107531+ mod->module_core_rw + mod->core_size_rw,
107532 set_memory_x);
107533- set_page_attributes(mod->module_core,
107534- mod->module_core + mod->core_ro_size,
107535+ set_page_attributes(mod->module_core_rx,
107536+ mod->module_core_rx + mod->core_size_rx,
107537 set_memory_rw);
107538 }
107539
107540 static void unset_module_init_ro_nx(struct module *mod)
107541 {
107542- set_page_attributes(mod->module_init + mod->init_text_size,
107543- mod->module_init + mod->init_size,
107544+ set_page_attributes(mod->module_init_rw,
107545+ mod->module_init_rw + mod->init_size_rw,
107546 set_memory_x);
107547- set_page_attributes(mod->module_init,
107548- mod->module_init + mod->init_ro_size,
107549+ set_page_attributes(mod->module_init_rx,
107550+ mod->module_init_rx + mod->init_size_rx,
107551 set_memory_rw);
107552 }
107553
107554@@ -1938,14 +1992,14 @@ void set_all_modules_text_rw(void)
107555 list_for_each_entry_rcu(mod, &modules, list) {
107556 if (mod->state == MODULE_STATE_UNFORMED)
107557 continue;
107558- if ((mod->module_core) && (mod->core_text_size)) {
107559- set_page_attributes(mod->module_core,
107560- mod->module_core + mod->core_text_size,
107561+ if ((mod->module_core_rx) && (mod->core_size_rx)) {
107562+ set_page_attributes(mod->module_core_rx,
107563+ mod->module_core_rx + mod->core_size_rx,
107564 set_memory_rw);
107565 }
107566- if ((mod->module_init) && (mod->init_text_size)) {
107567- set_page_attributes(mod->module_init,
107568- mod->module_init + mod->init_text_size,
107569+ if ((mod->module_init_rx) && (mod->init_size_rx)) {
107570+ set_page_attributes(mod->module_init_rx,
107571+ mod->module_init_rx + mod->init_size_rx,
107572 set_memory_rw);
107573 }
107574 }
107575@@ -1961,14 +2015,14 @@ void set_all_modules_text_ro(void)
107576 list_for_each_entry_rcu(mod, &modules, list) {
107577 if (mod->state == MODULE_STATE_UNFORMED)
107578 continue;
107579- if ((mod->module_core) && (mod->core_text_size)) {
107580- set_page_attributes(mod->module_core,
107581- mod->module_core + mod->core_text_size,
107582+ if ((mod->module_core_rx) && (mod->core_size_rx)) {
107583+ set_page_attributes(mod->module_core_rx,
107584+ mod->module_core_rx + mod->core_size_rx,
107585 set_memory_ro);
107586 }
107587- if ((mod->module_init) && (mod->init_text_size)) {
107588- set_page_attributes(mod->module_init,
107589- mod->module_init + mod->init_text_size,
107590+ if ((mod->module_init_rx) && (mod->init_size_rx)) {
107591+ set_page_attributes(mod->module_init_rx,
107592+ mod->module_init_rx + mod->init_size_rx,
107593 set_memory_ro);
107594 }
107595 }
107596@@ -1977,7 +2031,15 @@ void set_all_modules_text_ro(void)
107597 #else
107598 static inline void set_section_ro_nx(void *base, unsigned long text_size, unsigned long ro_size, unsigned long total_size) { }
107599 static void unset_module_core_ro_nx(struct module *mod) { }
107600-static void unset_module_init_ro_nx(struct module *mod) { }
107601+static void unset_module_init_ro_nx(struct module *mod)
107602+{
107603+
107604+#ifdef CONFIG_PAX_KERNEXEC
107605+ set_memory_nx((unsigned long)mod->module_init_rx, PFN_UP(mod->init_size_rx));
107606+ set_memory_rw((unsigned long)mod->module_init_rx, PFN_UP(mod->init_size_rx));
107607+#endif
107608+
107609+}
107610 #endif
107611
107612 void __weak module_memfree(void *module_region)
107613@@ -2032,16 +2094,19 @@ static void free_module(struct module *mod)
107614 /* This may be NULL, but that's OK */
107615 unset_module_init_ro_nx(mod);
107616 module_arch_freeing_init(mod);
107617- module_memfree(mod->module_init);
107618+ module_memfree(mod->module_init_rw);
107619+ module_memfree_exec(mod->module_init_rx);
107620 kfree(mod->args);
107621 percpu_modfree(mod);
107622
107623 /* Free lock-classes; relies on the preceding sync_rcu(). */
107624- lockdep_free_key_range(mod->module_core, mod->core_size);
107625+ lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
107626+ lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
107627
107628 /* Finally, free the core (containing the module structure) */
107629 unset_module_core_ro_nx(mod);
107630- module_memfree(mod->module_core);
107631+ module_memfree_exec(mod->module_core_rx);
107632+ module_memfree(mod->module_core_rw);
107633
107634 #ifdef CONFIG_MPU
107635 update_protections(current->mm);
107636@@ -2110,9 +2175,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
107637 int ret = 0;
107638 const struct kernel_symbol *ksym;
107639
107640+#ifdef CONFIG_GRKERNSEC_MODHARDEN
107641+ int is_fs_load = 0;
107642+ int register_filesystem_found = 0;
107643+ char *p;
107644+
107645+ p = strstr(mod->args, "grsec_modharden_fs");
107646+ if (p) {
107647+ char *endptr = p + sizeof("grsec_modharden_fs") - 1;
107648+ /* copy \0 as well */
107649+ memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
107650+ is_fs_load = 1;
107651+ }
107652+#endif
107653+
107654 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
107655 const char *name = info->strtab + sym[i].st_name;
107656
107657+#ifdef CONFIG_GRKERNSEC_MODHARDEN
107658+ /* it's a real shame this will never get ripped and copied
107659+ upstream! ;(
107660+ */
107661+ if (is_fs_load && !strcmp(name, "register_filesystem"))
107662+ register_filesystem_found = 1;
107663+#endif
107664+
107665 switch (sym[i].st_shndx) {
107666 case SHN_COMMON:
107667 /* Ignore common symbols */
107668@@ -2137,7 +2224,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
107669 ksym = resolve_symbol_wait(mod, info, name);
107670 /* Ok if resolved. */
107671 if (ksym && !IS_ERR(ksym)) {
107672+ pax_open_kernel();
107673 sym[i].st_value = ksym->value;
107674+ pax_close_kernel();
107675 break;
107676 }
107677
107678@@ -2156,11 +2245,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
107679 secbase = (unsigned long)mod_percpu(mod);
107680 else
107681 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
107682+ pax_open_kernel();
107683 sym[i].st_value += secbase;
107684+ pax_close_kernel();
107685 break;
107686 }
107687 }
107688
107689+#ifdef CONFIG_GRKERNSEC_MODHARDEN
107690+ if (is_fs_load && !register_filesystem_found) {
107691+ printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
107692+ ret = -EPERM;
107693+ }
107694+#endif
107695+
107696 return ret;
107697 }
107698
107699@@ -2244,22 +2342,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
107700 || s->sh_entsize != ~0UL
107701 || strstarts(sname, ".init"))
107702 continue;
107703- s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
107704+ if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
107705+ s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
107706+ else
107707+ s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
107708 pr_debug("\t%s\n", sname);
107709 }
107710- switch (m) {
107711- case 0: /* executable */
107712- mod->core_size = debug_align(mod->core_size);
107713- mod->core_text_size = mod->core_size;
107714- break;
107715- case 1: /* RO: text and ro-data */
107716- mod->core_size = debug_align(mod->core_size);
107717- mod->core_ro_size = mod->core_size;
107718- break;
107719- case 3: /* whole core */
107720- mod->core_size = debug_align(mod->core_size);
107721- break;
107722- }
107723 }
107724
107725 pr_debug("Init section allocation order:\n");
107726@@ -2273,23 +2361,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
107727 || s->sh_entsize != ~0UL
107728 || !strstarts(sname, ".init"))
107729 continue;
107730- s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
107731- | INIT_OFFSET_MASK);
107732+ if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
107733+ s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
107734+ else
107735+ s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
107736+ s->sh_entsize |= INIT_OFFSET_MASK;
107737 pr_debug("\t%s\n", sname);
107738 }
107739- switch (m) {
107740- case 0: /* executable */
107741- mod->init_size = debug_align(mod->init_size);
107742- mod->init_text_size = mod->init_size;
107743- break;
107744- case 1: /* RO: text and ro-data */
107745- mod->init_size = debug_align(mod->init_size);
107746- mod->init_ro_size = mod->init_size;
107747- break;
107748- case 3: /* whole init */
107749- mod->init_size = debug_align(mod->init_size);
107750- break;
107751- }
107752 }
107753 }
107754
107755@@ -2462,7 +2540,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
107756
107757 /* Put symbol section at end of init part of module. */
107758 symsect->sh_flags |= SHF_ALLOC;
107759- symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
107760+ symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
107761 info->index.sym) | INIT_OFFSET_MASK;
107762 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
107763
107764@@ -2479,16 +2557,16 @@ static void layout_symtab(struct module *mod, struct load_info *info)
107765 }
107766
107767 /* Append room for core symbols at end of core part. */
107768- info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
107769- info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
107770- mod->core_size += strtab_size;
107771- mod->core_size = debug_align(mod->core_size);
107772+ info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
107773+ info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
107774+ mod->core_size_rx += strtab_size;
107775+ mod->core_size_rx = debug_align(mod->core_size_rx);
107776
107777 /* Put string table section at end of init part of module. */
107778 strsect->sh_flags |= SHF_ALLOC;
107779- strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
107780+ strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
107781 info->index.str) | INIT_OFFSET_MASK;
107782- mod->init_size = debug_align(mod->init_size);
107783+ mod->init_size_rx = debug_align(mod->init_size_rx);
107784 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
107785 }
107786
107787@@ -2505,12 +2583,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
107788 /* Make sure we get permanent strtab: don't use info->strtab. */
107789 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
107790
107791+ pax_open_kernel();
107792+
107793 /* Set types up while we still have access to sections. */
107794 for (i = 0; i < mod->num_symtab; i++)
107795 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
107796
107797- mod->core_symtab = dst = mod->module_core + info->symoffs;
107798- mod->core_strtab = s = mod->module_core + info->stroffs;
107799+ mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
107800+ mod->core_strtab = s = mod->module_core_rx + info->stroffs;
107801 src = mod->symtab;
107802 for (ndst = i = 0; i < mod->num_symtab; i++) {
107803 if (i == 0 ||
107804@@ -2522,6 +2602,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
107805 }
107806 }
107807 mod->core_num_syms = ndst;
107808+
107809+ pax_close_kernel();
107810 }
107811 #else
107812 static inline void layout_symtab(struct module *mod, struct load_info *info)
107813@@ -2821,7 +2903,15 @@ static struct module *setup_load_info(struct load_info *info, int flags)
107814 mod = (void *)info->sechdrs[info->index.mod].sh_addr;
107815
107816 if (info->index.sym == 0) {
107817+#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
107818+ /*
107819+ * avoid potentially printing jibberish on attempted load
107820+ * of a module randomized with a different seed
107821+ */
107822+ pr_warn("module has no symbols (stripped?)\n");
107823+#else
107824 pr_warn("%s: module has no symbols (stripped?)\n", mod->name);
107825+#endif
107826 return ERR_PTR(-ENOEXEC);
107827 }
107828
107829@@ -2837,8 +2927,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
107830 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
107831 {
107832 const char *modmagic = get_modinfo(info, "vermagic");
107833+ const char *license = get_modinfo(info, "license");
107834 int err;
107835
107836+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
107837+ if (!license || !license_is_gpl_compatible(license))
107838+ return -ENOEXEC;
107839+#endif
107840+
107841 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
107842 modmagic = NULL;
107843
107844@@ -2863,7 +2959,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
107845 }
107846
107847 /* Set up license info based on the info section */
107848- set_license(mod, get_modinfo(info, "license"));
107849+ set_license(mod, license);
107850
107851 return 0;
107852 }
107853@@ -2960,7 +3056,7 @@ static int move_module(struct module *mod, struct load_info *info)
107854 void *ptr;
107855
107856 /* Do the allocs. */
107857- ptr = module_alloc(mod->core_size);
107858+ ptr = module_alloc(mod->core_size_rw);
107859 /*
107860 * The pointer to this block is stored in the module structure
107861 * which is inside the block. Just mark it as not being a
107862@@ -2970,11 +3066,11 @@ static int move_module(struct module *mod, struct load_info *info)
107863 if (!ptr)
107864 return -ENOMEM;
107865
107866- memset(ptr, 0, mod->core_size);
107867- mod->module_core = ptr;
107868+ memset(ptr, 0, mod->core_size_rw);
107869+ mod->module_core_rw = ptr;
107870
107871- if (mod->init_size) {
107872- ptr = module_alloc(mod->init_size);
107873+ if (mod->init_size_rw) {
107874+ ptr = module_alloc(mod->init_size_rw);
107875 /*
107876 * The pointer to this block is stored in the module structure
107877 * which is inside the block. This block doesn't need to be
107878@@ -2983,13 +3079,45 @@ static int move_module(struct module *mod, struct load_info *info)
107879 */
107880 kmemleak_ignore(ptr);
107881 if (!ptr) {
107882- module_memfree(mod->module_core);
107883+ module_memfree(mod->module_core_rw);
107884 return -ENOMEM;
107885 }
107886- memset(ptr, 0, mod->init_size);
107887- mod->module_init = ptr;
107888+ memset(ptr, 0, mod->init_size_rw);
107889+ mod->module_init_rw = ptr;
107890 } else
107891- mod->module_init = NULL;
107892+ mod->module_init_rw = NULL;
107893+
107894+ ptr = module_alloc_exec(mod->core_size_rx);
107895+ kmemleak_not_leak(ptr);
107896+ if (!ptr) {
107897+ if (mod->module_init_rw)
107898+ module_memfree(mod->module_init_rw);
107899+ module_memfree(mod->module_core_rw);
107900+ return -ENOMEM;
107901+ }
107902+
107903+ pax_open_kernel();
107904+ memset(ptr, 0, mod->core_size_rx);
107905+ pax_close_kernel();
107906+ mod->module_core_rx = ptr;
107907+
107908+ if (mod->init_size_rx) {
107909+ ptr = module_alloc_exec(mod->init_size_rx);
107910+ kmemleak_ignore(ptr);
107911+ if (!ptr && mod->init_size_rx) {
107912+ module_memfree_exec(mod->module_core_rx);
107913+ if (mod->module_init_rw)
107914+ module_memfree(mod->module_init_rw);
107915+ module_memfree(mod->module_core_rw);
107916+ return -ENOMEM;
107917+ }
107918+
107919+ pax_open_kernel();
107920+ memset(ptr, 0, mod->init_size_rx);
107921+ pax_close_kernel();
107922+ mod->module_init_rx = ptr;
107923+ } else
107924+ mod->module_init_rx = NULL;
107925
107926 /* Transfer each section which specifies SHF_ALLOC */
107927 pr_debug("final section addresses:\n");
107928@@ -3000,16 +3128,45 @@ static int move_module(struct module *mod, struct load_info *info)
107929 if (!(shdr->sh_flags & SHF_ALLOC))
107930 continue;
107931
107932- if (shdr->sh_entsize & INIT_OFFSET_MASK)
107933- dest = mod->module_init
107934- + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
107935- else
107936- dest = mod->module_core + shdr->sh_entsize;
107937+ if (shdr->sh_entsize & INIT_OFFSET_MASK) {
107938+ if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
107939+ dest = mod->module_init_rw
107940+ + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
107941+ else
107942+ dest = mod->module_init_rx
107943+ + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
107944+ } else {
107945+ if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
107946+ dest = mod->module_core_rw + shdr->sh_entsize;
107947+ else
107948+ dest = mod->module_core_rx + shdr->sh_entsize;
107949+ }
107950+
107951+ if (shdr->sh_type != SHT_NOBITS) {
107952+
107953+#ifdef CONFIG_PAX_KERNEXEC
107954+#ifdef CONFIG_X86_64
107955+ if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
107956+ set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
107957+#endif
107958+ if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
107959+ pax_open_kernel();
107960+ memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
107961+ pax_close_kernel();
107962+ } else
107963+#endif
107964
107965- if (shdr->sh_type != SHT_NOBITS)
107966 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
107967+ }
107968 /* Update sh_addr to point to copy in image. */
107969- shdr->sh_addr = (unsigned long)dest;
107970+
107971+#ifdef CONFIG_PAX_KERNEXEC
107972+ if (shdr->sh_flags & SHF_EXECINSTR)
107973+ shdr->sh_addr = ktva_ktla((unsigned long)dest);
107974+ else
107975+#endif
107976+
107977+ shdr->sh_addr = (unsigned long)dest;
107978 pr_debug("\t0x%lx %s\n",
107979 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
107980 }
107981@@ -3066,12 +3223,12 @@ static void flush_module_icache(const struct module *mod)
107982 * Do it before processing of module parameters, so the module
107983 * can provide parameter accessor functions of its own.
107984 */
107985- if (mod->module_init)
107986- flush_icache_range((unsigned long)mod->module_init,
107987- (unsigned long)mod->module_init
107988- + mod->init_size);
107989- flush_icache_range((unsigned long)mod->module_core,
107990- (unsigned long)mod->module_core + mod->core_size);
107991+ if (mod->module_init_rx)
107992+ flush_icache_range((unsigned long)mod->module_init_rx,
107993+ (unsigned long)mod->module_init_rx
107994+ + mod->init_size_rx);
107995+ flush_icache_range((unsigned long)mod->module_core_rx,
107996+ (unsigned long)mod->module_core_rx + mod->core_size_rx);
107997
107998 set_fs(old_fs);
107999 }
108000@@ -3129,8 +3286,10 @@ static void module_deallocate(struct module *mod, struct load_info *info)
108001 {
108002 percpu_modfree(mod);
108003 module_arch_freeing_init(mod);
108004- module_memfree(mod->module_init);
108005- module_memfree(mod->module_core);
108006+ module_memfree_exec(mod->module_init_rx);
108007+ module_memfree_exec(mod->module_core_rx);
108008+ module_memfree(mod->module_init_rw);
108009+ module_memfree(mod->module_core_rw);
108010 }
108011
108012 int __weak module_finalize(const Elf_Ehdr *hdr,
108013@@ -3143,7 +3302,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
108014 static int post_relocation(struct module *mod, const struct load_info *info)
108015 {
108016 /* Sort exception table now relocations are done. */
108017+ pax_open_kernel();
108018 sort_extable(mod->extable, mod->extable + mod->num_exentries);
108019+ pax_close_kernel();
108020
108021 /* Copy relocated percpu area over. */
108022 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
108023@@ -3191,13 +3352,15 @@ static void do_mod_ctors(struct module *mod)
108024 /* For freeing module_init on success, in case kallsyms traversing */
108025 struct mod_initfree {
108026 struct rcu_head rcu;
108027- void *module_init;
108028+ void *module_init_rw;
108029+ void *module_init_rx;
108030 };
108031
108032 static void do_free_init(struct rcu_head *head)
108033 {
108034 struct mod_initfree *m = container_of(head, struct mod_initfree, rcu);
108035- module_memfree(m->module_init);
108036+ module_memfree(m->module_init_rw);
108037+ module_memfree_exec(m->module_init_rx);
108038 kfree(m);
108039 }
108040
108041@@ -3217,7 +3380,8 @@ static noinline int do_init_module(struct module *mod)
108042 ret = -ENOMEM;
108043 goto fail;
108044 }
108045- freeinit->module_init = mod->module_init;
108046+ freeinit->module_init_rw = mod->module_init_rw;
108047+ freeinit->module_init_rx = mod->module_init_rx;
108048
108049 /*
108050 * We want to find out whether @mod uses async during init. Clear
108051@@ -3277,10 +3441,10 @@ static noinline int do_init_module(struct module *mod)
108052 mod_tree_remove_init(mod);
108053 unset_module_init_ro_nx(mod);
108054 module_arch_freeing_init(mod);
108055- mod->module_init = NULL;
108056- mod->init_size = 0;
108057- mod->init_ro_size = 0;
108058- mod->init_text_size = 0;
108059+ mod->module_init_rw = NULL;
108060+ mod->module_init_rx = NULL;
108061+ mod->init_size_rw = 0;
108062+ mod->init_size_rx = 0;
108063 /*
108064 * We want to free module_init, but be aware that kallsyms may be
108065 * walking this with preempt disabled. In all the failure paths, we
108066@@ -3370,16 +3534,16 @@ static int complete_formation(struct module *mod, struct load_info *info)
108067 module_bug_finalize(info->hdr, info->sechdrs, mod);
108068
108069 /* Set RO and NX regions for core */
108070- set_section_ro_nx(mod->module_core,
108071- mod->core_text_size,
108072- mod->core_ro_size,
108073- mod->core_size);
108074+ set_section_ro_nx(mod->module_core_rx,
108075+ mod->core_size_rx,
108076+ mod->core_size_rx,
108077+ mod->core_size_rx);
108078
108079 /* Set RO and NX regions for init */
108080- set_section_ro_nx(mod->module_init,
108081- mod->init_text_size,
108082- mod->init_ro_size,
108083- mod->init_size);
108084+ set_section_ro_nx(mod->module_init_rx,
108085+ mod->init_size_rx,
108086+ mod->init_size_rx,
108087+ mod->init_size_rx);
108088
108089 /* Mark state as coming so strong_try_module_get() ignores us,
108090 * but kallsyms etc. can see us. */
108091@@ -3474,9 +3638,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
108092 if (err)
108093 goto free_unload;
108094
108095+ /* Now copy in args */
108096+ mod->args = strndup_user(uargs, ~0UL >> 1);
108097+ if (IS_ERR(mod->args)) {
108098+ err = PTR_ERR(mod->args);
108099+ goto free_unload;
108100+ }
108101+
108102 /* Set up MODINFO_ATTR fields */
108103 setup_modinfo(mod, info);
108104
108105+#ifdef CONFIG_GRKERNSEC_MODHARDEN
108106+ {
108107+ char *p, *p2;
108108+
108109+ if (strstr(mod->args, "grsec_modharden_netdev")) {
108110+ 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);
108111+ err = -EPERM;
108112+ goto free_modinfo;
108113+ } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
108114+ p += sizeof("grsec_modharden_normal") - 1;
108115+ p2 = strstr(p, "_");
108116+ if (p2) {
108117+ *p2 = '\0';
108118+ printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
108119+ *p2 = '_';
108120+ }
108121+ err = -EPERM;
108122+ goto free_modinfo;
108123+ }
108124+ }
108125+#endif
108126+
108127 /* Fix up syms, so that st_value is a pointer to location. */
108128 err = simplify_symbols(mod, info);
108129 if (err < 0)
108130@@ -3492,13 +3685,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
108131
108132 flush_module_icache(mod);
108133
108134- /* Now copy in args */
108135- mod->args = strndup_user(uargs, ~0UL >> 1);
108136- if (IS_ERR(mod->args)) {
108137- err = PTR_ERR(mod->args);
108138- goto free_arch_cleanup;
108139- }
108140-
108141 dynamic_debug_setup(info->debug, info->num_debug);
108142
108143 /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
108144@@ -3550,11 +3736,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
108145 ddebug_cleanup:
108146 dynamic_debug_remove(info->debug);
108147 synchronize_sched();
108148- kfree(mod->args);
108149- free_arch_cleanup:
108150 module_arch_cleanup(mod);
108151 free_modinfo:
108152 free_modinfo(mod);
108153+ kfree(mod->args);
108154 free_unload:
108155 module_unload_free(mod);
108156 unlink_mod:
108157@@ -3568,7 +3753,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
108158 mutex_unlock(&module_mutex);
108159 free_module:
108160 /* Free lock-classes; relies on the preceding sync_rcu() */
108161- lockdep_free_key_range(mod->module_core, mod->core_size);
108162+ lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
108163+ lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
108164
108165 module_deallocate(mod, info);
108166 free_copy:
108167@@ -3645,10 +3831,16 @@ static const char *get_ksymbol(struct module *mod,
108168 unsigned long nextval;
108169
108170 /* At worse, next value is at end of module */
108171- if (within_module_init(addr, mod))
108172- nextval = (unsigned long)mod->module_init+mod->init_text_size;
108173+ if (within_module_init_rx(addr, mod))
108174+ nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
108175+ else if (within_module_init_rw(addr, mod))
108176+ nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
108177+ else if (within_module_core_rx(addr, mod))
108178+ nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
108179+ else if (within_module_core_rw(addr, mod))
108180+ nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
108181 else
108182- nextval = (unsigned long)mod->module_core+mod->core_text_size;
108183+ return NULL;
108184
108185 /* Scan for closest preceding symbol, and next symbol. (ELF
108186 starts real symbols at 1). */
108187@@ -3895,7 +4087,7 @@ static int m_show(struct seq_file *m, void *p)
108188 return 0;
108189
108190 seq_printf(m, "%s %u",
108191- mod->name, mod->init_size + mod->core_size);
108192+ mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
108193 print_unload_info(m, mod);
108194
108195 /* Informative for users. */
108196@@ -3904,7 +4096,7 @@ static int m_show(struct seq_file *m, void *p)
108197 mod->state == MODULE_STATE_COMING ? "Loading" :
108198 "Live");
108199 /* Used by oprofile and other similar tools. */
108200- seq_printf(m, " 0x%pK", mod->module_core);
108201+ seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
108202
108203 /* Taints info */
108204 if (mod->taints)
108205@@ -3940,7 +4132,17 @@ static const struct file_operations proc_modules_operations = {
108206
108207 static int __init proc_modules_init(void)
108208 {
108209+#ifndef CONFIG_GRKERNSEC_HIDESYM
108210+#ifdef CONFIG_GRKERNSEC_PROC_USER
108211+ proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
108212+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
108213+ proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
108214+#else
108215 proc_create("modules", 0, NULL, &proc_modules_operations);
108216+#endif
108217+#else
108218+ proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
108219+#endif
108220 return 0;
108221 }
108222 module_init(proc_modules_init);
108223@@ -4001,7 +4203,8 @@ struct module *__module_address(unsigned long addr)
108224 {
108225 struct module *mod;
108226
108227- if (addr < module_addr_min || addr > module_addr_max)
108228+ if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
108229+ (addr < module_addr_min_rw || addr > module_addr_max_rw))
108230 return NULL;
108231
108232 module_assert_mutex_or_preempt();
108233@@ -4044,11 +4247,20 @@ bool is_module_text_address(unsigned long addr)
108234 */
108235 struct module *__module_text_address(unsigned long addr)
108236 {
108237- struct module *mod = __module_address(addr);
108238+ struct module *mod;
108239+
108240+#ifdef CONFIG_X86_32
108241+ addr = ktla_ktva(addr);
108242+#endif
108243+
108244+ if (addr < module_addr_min_rx || addr > module_addr_max_rx)
108245+ return NULL;
108246+
108247+ mod = __module_address(addr);
108248+
108249 if (mod) {
108250 /* Make sure it's within the text section. */
108251- if (!within(addr, mod->module_init, mod->init_text_size)
108252- && !within(addr, mod->module_core, mod->core_text_size))
108253+ if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
108254 mod = NULL;
108255 }
108256 return mod;
108257diff --git a/kernel/notifier.c b/kernel/notifier.c
108258index ae9fc7c..5085fbf 100644
108259--- a/kernel/notifier.c
108260+++ b/kernel/notifier.c
108261@@ -5,6 +5,7 @@
108262 #include <linux/rcupdate.h>
108263 #include <linux/vmalloc.h>
108264 #include <linux/reboot.h>
108265+#include <linux/mm.h>
108266
108267 /*
108268 * Notifier list for kernel code which wants to be called
108269@@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
108270 while ((*nl) != NULL) {
108271 if (n->priority > (*nl)->priority)
108272 break;
108273- nl = &((*nl)->next);
108274+ nl = (struct notifier_block **)&((*nl)->next);
108275 }
108276- n->next = *nl;
108277+ pax_open_kernel();
108278+ *(const void **)&n->next = *nl;
108279 rcu_assign_pointer(*nl, n);
108280+ pax_close_kernel();
108281 return 0;
108282 }
108283
108284@@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
108285 return 0;
108286 if (n->priority > (*nl)->priority)
108287 break;
108288- nl = &((*nl)->next);
108289+ nl = (struct notifier_block **)&((*nl)->next);
108290 }
108291- n->next = *nl;
108292+ pax_open_kernel();
108293+ *(const void **)&n->next = *nl;
108294 rcu_assign_pointer(*nl, n);
108295+ pax_close_kernel();
108296 return 0;
108297 }
108298
108299@@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
108300 {
108301 while ((*nl) != NULL) {
108302 if ((*nl) == n) {
108303+ pax_open_kernel();
108304 rcu_assign_pointer(*nl, n->next);
108305+ pax_close_kernel();
108306 return 0;
108307 }
108308- nl = &((*nl)->next);
108309+ nl = (struct notifier_block **)&((*nl)->next);
108310 }
108311 return -ENOENT;
108312 }
108313diff --git a/kernel/padata.c b/kernel/padata.c
108314index b38bea9..91acfbe 100644
108315--- a/kernel/padata.c
108316+++ b/kernel/padata.c
108317@@ -54,7 +54,7 @@ static int padata_cpu_hash(struct parallel_data *pd)
108318 * seq_nr mod. number of cpus in use.
108319 */
108320
108321- seq_nr = atomic_inc_return(&pd->seq_nr);
108322+ seq_nr = atomic_inc_return_unchecked(&pd->seq_nr);
108323 cpu_index = seq_nr % cpumask_weight(pd->cpumask.pcpu);
108324
108325 return padata_index_to_cpu(pd, cpu_index);
108326@@ -428,7 +428,7 @@ static struct parallel_data *padata_alloc_pd(struct padata_instance *pinst,
108327 padata_init_pqueues(pd);
108328 padata_init_squeues(pd);
108329 setup_timer(&pd->timer, padata_reorder_timer, (unsigned long)pd);
108330- atomic_set(&pd->seq_nr, -1);
108331+ atomic_set_unchecked(&pd->seq_nr, -1);
108332 atomic_set(&pd->reorder_objects, 0);
108333 atomic_set(&pd->refcnt, 0);
108334 pd->pinst = pinst;
108335diff --git a/kernel/panic.c b/kernel/panic.c
108336index 04e91ff..2419384 100644
108337--- a/kernel/panic.c
108338+++ b/kernel/panic.c
108339@@ -54,7 +54,7 @@ EXPORT_SYMBOL(panic_blink);
108340 /*
108341 * Stop ourself in panic -- architecture code may override this
108342 */
108343-void __weak panic_smp_self_stop(void)
108344+void __weak __noreturn panic_smp_self_stop(void)
108345 {
108346 while (1)
108347 cpu_relax();
108348@@ -426,7 +426,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
108349 disable_trace_on_warning();
108350
108351 pr_warn("------------[ cut here ]------------\n");
108352- pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
108353+ pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
108354 raw_smp_processor_id(), current->pid, file, line, caller);
108355
108356 if (args)
108357@@ -491,7 +491,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
108358 */
108359 __visible void __stack_chk_fail(void)
108360 {
108361- panic("stack-protector: Kernel stack is corrupted in: %p\n",
108362+ dump_stack();
108363+ panic("stack-protector: Kernel stack is corrupted in: %pA\n",
108364 __builtin_return_address(0));
108365 }
108366 EXPORT_SYMBOL(__stack_chk_fail);
108367diff --git a/kernel/pid.c b/kernel/pid.c
108368index 4fd07d5..02bce4f 100644
108369--- a/kernel/pid.c
108370+++ b/kernel/pid.c
108371@@ -33,6 +33,7 @@
108372 #include <linux/rculist.h>
108373 #include <linux/bootmem.h>
108374 #include <linux/hash.h>
108375+#include <linux/security.h>
108376 #include <linux/pid_namespace.h>
108377 #include <linux/init_task.h>
108378 #include <linux/syscalls.h>
108379@@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
108380
108381 int pid_max = PID_MAX_DEFAULT;
108382
108383-#define RESERVED_PIDS 300
108384+#define RESERVED_PIDS 500
108385
108386 int pid_max_min = RESERVED_PIDS + 1;
108387 int pid_max_max = PID_MAX_LIMIT;
108388@@ -451,10 +452,18 @@ EXPORT_SYMBOL(pid_task);
108389 */
108390 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
108391 {
108392+ struct task_struct *task;
108393+
108394 rcu_lockdep_assert(rcu_read_lock_held(),
108395 "find_task_by_pid_ns() needs rcu_read_lock()"
108396 " protection");
108397- return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
108398+
108399+ task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
108400+
108401+ if (gr_pid_is_chrooted(task))
108402+ return NULL;
108403+
108404+ return task;
108405 }
108406
108407 struct task_struct *find_task_by_vpid(pid_t vnr)
108408@@ -462,6 +471,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
108409 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
108410 }
108411
108412+struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
108413+{
108414+ rcu_lockdep_assert(rcu_read_lock_held(),
108415+ "find_task_by_pid_ns() needs rcu_read_lock()"
108416+ " protection");
108417+ return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
108418+}
108419+
108420 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
108421 {
108422 struct pid *pid;
108423diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
108424index a65ba13..f600dbb 100644
108425--- a/kernel/pid_namespace.c
108426+++ b/kernel/pid_namespace.c
108427@@ -274,7 +274,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
108428 void __user *buffer, size_t *lenp, loff_t *ppos)
108429 {
108430 struct pid_namespace *pid_ns = task_active_pid_ns(current);
108431- struct ctl_table tmp = *table;
108432+ ctl_table_no_const tmp = *table;
108433
108434 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
108435 return -EPERM;
108436diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
108437index 9e30231..75a6d97 100644
108438--- a/kernel/power/Kconfig
108439+++ b/kernel/power/Kconfig
108440@@ -24,6 +24,8 @@ config HIBERNATE_CALLBACKS
108441 config HIBERNATION
108442 bool "Hibernation (aka 'suspend to disk')"
108443 depends on SWAP && ARCH_HIBERNATION_POSSIBLE
108444+ depends on !GRKERNSEC_KMEM
108445+ depends on !PAX_MEMORY_SANITIZE
108446 select HIBERNATE_CALLBACKS
108447 select LZO_COMPRESS
108448 select LZO_DECOMPRESS
108449diff --git a/kernel/power/process.c b/kernel/power/process.c
108450index 564f786..361a18e 100644
108451--- a/kernel/power/process.c
108452+++ b/kernel/power/process.c
108453@@ -35,6 +35,7 @@ static int try_to_freeze_tasks(bool user_only)
108454 unsigned int elapsed_msecs;
108455 bool wakeup = false;
108456 int sleep_usecs = USEC_PER_MSEC;
108457+ bool timedout = false;
108458
108459 do_gettimeofday(&start);
108460
108461@@ -45,13 +46,20 @@ static int try_to_freeze_tasks(bool user_only)
108462
108463 while (true) {
108464 todo = 0;
108465+ if (time_after(jiffies, end_time))
108466+ timedout = true;
108467 read_lock(&tasklist_lock);
108468 for_each_process_thread(g, p) {
108469 if (p == current || !freeze_task(p))
108470 continue;
108471
108472- if (!freezer_should_skip(p))
108473+ if (!freezer_should_skip(p)) {
108474 todo++;
108475+ if (timedout) {
108476+ printk(KERN_ERR "Task refusing to freeze:\n");
108477+ sched_show_task(p);
108478+ }
108479+ }
108480 }
108481 read_unlock(&tasklist_lock);
108482
108483@@ -60,7 +68,7 @@ static int try_to_freeze_tasks(bool user_only)
108484 todo += wq_busy;
108485 }
108486
108487- if (!todo || time_after(jiffies, end_time))
108488+ if (!todo || timedout)
108489 break;
108490
108491 if (pm_wakeup_pending()) {
108492diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
108493index cf8c242..84e7843 100644
108494--- a/kernel/printk/printk.c
108495+++ b/kernel/printk/printk.c
108496@@ -475,7 +475,7 @@ static int log_store(int facility, int level,
108497 return msg->text_len;
108498 }
108499
108500-int dmesg_restrict = IS_ENABLED(CONFIG_SECURITY_DMESG_RESTRICT);
108501+int dmesg_restrict __read_only = IS_ENABLED(CONFIG_SECURITY_DMESG_RESTRICT);
108502
108503 static int syslog_action_restricted(int type)
108504 {
108505@@ -498,6 +498,11 @@ int check_syslog_permissions(int type, int source)
108506 if (source == SYSLOG_FROM_PROC && type != SYSLOG_ACTION_OPEN)
108507 goto ok;
108508
108509+#ifdef CONFIG_GRKERNSEC_DMESG
108510+ if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
108511+ return -EPERM;
108512+#endif
108513+
108514 if (syslog_action_restricted(type)) {
108515 if (capable(CAP_SYSLOG))
108516 goto ok;
108517diff --git a/kernel/profile.c b/kernel/profile.c
108518index a7bcd28..5b368fa 100644
108519--- a/kernel/profile.c
108520+++ b/kernel/profile.c
108521@@ -37,7 +37,7 @@ struct profile_hit {
108522 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
108523 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
108524
108525-static atomic_t *prof_buffer;
108526+static atomic_unchecked_t *prof_buffer;
108527 static unsigned long prof_len, prof_shift;
108528
108529 int prof_on __read_mostly;
108530@@ -256,7 +256,7 @@ static void profile_flip_buffers(void)
108531 hits[i].pc = 0;
108532 continue;
108533 }
108534- atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
108535+ atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
108536 hits[i].hits = hits[i].pc = 0;
108537 }
108538 }
108539@@ -317,9 +317,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
108540 * Add the current hit(s) and flush the write-queue out
108541 * to the global buffer:
108542 */
108543- atomic_add(nr_hits, &prof_buffer[pc]);
108544+ atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
108545 for (i = 0; i < NR_PROFILE_HIT; ++i) {
108546- atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
108547+ atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
108548 hits[i].pc = hits[i].hits = 0;
108549 }
108550 out:
108551@@ -394,7 +394,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
108552 {
108553 unsigned long pc;
108554 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
108555- atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
108556+ atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
108557 }
108558 #endif /* !CONFIG_SMP */
108559
108560@@ -489,7 +489,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
108561 return -EFAULT;
108562 buf++; p++; count--; read++;
108563 }
108564- pnt = (char *)prof_buffer + p - sizeof(atomic_t);
108565+ pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
108566 if (copy_to_user(buf, (void *)pnt, count))
108567 return -EFAULT;
108568 read += count;
108569@@ -520,7 +520,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
108570 }
108571 #endif
108572 profile_discard_flip_buffers();
108573- memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
108574+ memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
108575 return count;
108576 }
108577
108578diff --git a/kernel/ptrace.c b/kernel/ptrace.c
108579index c8e0e05..2be5614 100644
108580--- a/kernel/ptrace.c
108581+++ b/kernel/ptrace.c
108582@@ -321,7 +321,7 @@ static int ptrace_attach(struct task_struct *task, long request,
108583 if (seize)
108584 flags |= PT_SEIZED;
108585 rcu_read_lock();
108586- if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
108587+ if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
108588 flags |= PT_PTRACE_CAP;
108589 rcu_read_unlock();
108590 task->ptrace = flags;
108591@@ -514,7 +514,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
108592 break;
108593 return -EIO;
108594 }
108595- if (copy_to_user(dst, buf, retval))
108596+ if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
108597 return -EFAULT;
108598 copied += retval;
108599 src += retval;
108600@@ -802,7 +802,7 @@ int ptrace_request(struct task_struct *child, long request,
108601 bool seized = child->ptrace & PT_SEIZED;
108602 int ret = -EIO;
108603 siginfo_t siginfo, *si;
108604- void __user *datavp = (void __user *) data;
108605+ void __user *datavp = (__force void __user *) data;
108606 unsigned long __user *datalp = datavp;
108607 unsigned long flags;
108608
108609@@ -1048,14 +1048,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
108610 goto out;
108611 }
108612
108613+ if (gr_handle_ptrace(child, request)) {
108614+ ret = -EPERM;
108615+ goto out_put_task_struct;
108616+ }
108617+
108618 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
108619 ret = ptrace_attach(child, request, addr, data);
108620 /*
108621 * Some architectures need to do book-keeping after
108622 * a ptrace attach.
108623 */
108624- if (!ret)
108625+ if (!ret) {
108626 arch_ptrace_attach(child);
108627+ gr_audit_ptrace(child);
108628+ }
108629 goto out_put_task_struct;
108630 }
108631
108632@@ -1083,7 +1090,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
108633 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
108634 if (copied != sizeof(tmp))
108635 return -EIO;
108636- return put_user(tmp, (unsigned long __user *)data);
108637+ return put_user(tmp, (__force unsigned long __user *)data);
108638 }
108639
108640 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
108641@@ -1176,7 +1183,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
108642 }
108643
108644 COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid,
108645- compat_long_t, addr, compat_long_t, data)
108646+ compat_ulong_t, addr, compat_ulong_t, data)
108647 {
108648 struct task_struct *child;
108649 long ret;
108650@@ -1192,14 +1199,21 @@ COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid,
108651 goto out;
108652 }
108653
108654+ if (gr_handle_ptrace(child, request)) {
108655+ ret = -EPERM;
108656+ goto out_put_task_struct;
108657+ }
108658+
108659 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
108660 ret = ptrace_attach(child, request, addr, data);
108661 /*
108662 * Some architectures need to do book-keeping after
108663 * a ptrace attach.
108664 */
108665- if (!ret)
108666+ if (!ret) {
108667 arch_ptrace_attach(child);
108668+ gr_audit_ptrace(child);
108669+ }
108670 goto out_put_task_struct;
108671 }
108672
108673diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
108674index 59e32684..d2eb3d9 100644
108675--- a/kernel/rcu/rcutorture.c
108676+++ b/kernel/rcu/rcutorture.c
108677@@ -134,12 +134,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1],
108678 rcu_torture_count) = { 0 };
108679 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1],
108680 rcu_torture_batch) = { 0 };
108681-static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
108682-static atomic_t n_rcu_torture_alloc;
108683-static atomic_t n_rcu_torture_alloc_fail;
108684-static atomic_t n_rcu_torture_free;
108685-static atomic_t n_rcu_torture_mberror;
108686-static atomic_t n_rcu_torture_error;
108687+static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
108688+static atomic_unchecked_t n_rcu_torture_alloc;
108689+static atomic_unchecked_t n_rcu_torture_alloc_fail;
108690+static atomic_unchecked_t n_rcu_torture_free;
108691+static atomic_unchecked_t n_rcu_torture_mberror;
108692+static atomic_unchecked_t n_rcu_torture_error;
108693 static long n_rcu_torture_barrier_error;
108694 static long n_rcu_torture_boost_ktrerror;
108695 static long n_rcu_torture_boost_rterror;
108696@@ -148,7 +148,7 @@ static long n_rcu_torture_boosts;
108697 static long n_rcu_torture_timers;
108698 static long n_barrier_attempts;
108699 static long n_barrier_successes;
108700-static atomic_long_t n_cbfloods;
108701+static atomic_long_unchecked_t n_cbfloods;
108702 static struct list_head rcu_torture_removed;
108703
108704 static int rcu_torture_writer_state;
108705@@ -211,11 +211,11 @@ rcu_torture_alloc(void)
108706
108707 spin_lock_bh(&rcu_torture_lock);
108708 if (list_empty(&rcu_torture_freelist)) {
108709- atomic_inc(&n_rcu_torture_alloc_fail);
108710+ atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
108711 spin_unlock_bh(&rcu_torture_lock);
108712 return NULL;
108713 }
108714- atomic_inc(&n_rcu_torture_alloc);
108715+ atomic_inc_unchecked(&n_rcu_torture_alloc);
108716 p = rcu_torture_freelist.next;
108717 list_del_init(p);
108718 spin_unlock_bh(&rcu_torture_lock);
108719@@ -228,7 +228,7 @@ rcu_torture_alloc(void)
108720 static void
108721 rcu_torture_free(struct rcu_torture *p)
108722 {
108723- atomic_inc(&n_rcu_torture_free);
108724+ atomic_inc_unchecked(&n_rcu_torture_free);
108725 spin_lock_bh(&rcu_torture_lock);
108726 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
108727 spin_unlock_bh(&rcu_torture_lock);
108728@@ -309,7 +309,7 @@ rcu_torture_pipe_update_one(struct rcu_torture *rp)
108729 i = rp->rtort_pipe_count;
108730 if (i > RCU_TORTURE_PIPE_LEN)
108731 i = RCU_TORTURE_PIPE_LEN;
108732- atomic_inc(&rcu_torture_wcount[i]);
108733+ atomic_inc_unchecked(&rcu_torture_wcount[i]);
108734 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
108735 rp->rtort_mbtest = 0;
108736 return true;
108737@@ -830,7 +830,7 @@ rcu_torture_cbflood(void *arg)
108738 VERBOSE_TOROUT_STRING("rcu_torture_cbflood task started");
108739 do {
108740 schedule_timeout_interruptible(cbflood_inter_holdoff);
108741- atomic_long_inc(&n_cbfloods);
108742+ atomic_long_inc_unchecked(&n_cbfloods);
108743 WARN_ON(signal_pending(current));
108744 for (i = 0; i < cbflood_n_burst; i++) {
108745 for (j = 0; j < cbflood_n_per_burst; j++) {
108746@@ -957,7 +957,7 @@ rcu_torture_writer(void *arg)
108747 i = old_rp->rtort_pipe_count;
108748 if (i > RCU_TORTURE_PIPE_LEN)
108749 i = RCU_TORTURE_PIPE_LEN;
108750- atomic_inc(&rcu_torture_wcount[i]);
108751+ atomic_inc_unchecked(&rcu_torture_wcount[i]);
108752 old_rp->rtort_pipe_count++;
108753 switch (synctype[torture_random(&rand) % nsynctypes]) {
108754 case RTWS_DEF_FREE:
108755@@ -1095,7 +1095,7 @@ static void rcu_torture_timer(unsigned long unused)
108756 return;
108757 }
108758 if (p->rtort_mbtest == 0)
108759- atomic_inc(&n_rcu_torture_mberror);
108760+ atomic_inc_unchecked(&n_rcu_torture_mberror);
108761 spin_lock(&rand_lock);
108762 cur_ops->read_delay(&rand);
108763 n_rcu_torture_timers++;
108764@@ -1170,7 +1170,7 @@ rcu_torture_reader(void *arg)
108765 continue;
108766 }
108767 if (p->rtort_mbtest == 0)
108768- atomic_inc(&n_rcu_torture_mberror);
108769+ atomic_inc_unchecked(&n_rcu_torture_mberror);
108770 cur_ops->read_delay(&rand);
108771 preempt_disable();
108772 pipe_count = p->rtort_pipe_count;
108773@@ -1239,11 +1239,11 @@ rcu_torture_stats_print(void)
108774 rcu_torture_current,
108775 rcu_torture_current_version,
108776 list_empty(&rcu_torture_freelist),
108777- atomic_read(&n_rcu_torture_alloc),
108778- atomic_read(&n_rcu_torture_alloc_fail),
108779- atomic_read(&n_rcu_torture_free));
108780+ atomic_read_unchecked(&n_rcu_torture_alloc),
108781+ atomic_read_unchecked(&n_rcu_torture_alloc_fail),
108782+ atomic_read_unchecked(&n_rcu_torture_free));
108783 pr_cont("rtmbe: %d rtbke: %ld rtbre: %ld ",
108784- atomic_read(&n_rcu_torture_mberror),
108785+ atomic_read_unchecked(&n_rcu_torture_mberror),
108786 n_rcu_torture_boost_ktrerror,
108787 n_rcu_torture_boost_rterror);
108788 pr_cont("rtbf: %ld rtb: %ld nt: %ld ",
108789@@ -1255,17 +1255,17 @@ rcu_torture_stats_print(void)
108790 n_barrier_successes,
108791 n_barrier_attempts,
108792 n_rcu_torture_barrier_error);
108793- pr_cont("cbflood: %ld\n", atomic_long_read(&n_cbfloods));
108794+ pr_cont("cbflood: %ld\n", atomic_long_read_unchecked(&n_cbfloods));
108795
108796 pr_alert("%s%s ", torture_type, TORTURE_FLAG);
108797- if (atomic_read(&n_rcu_torture_mberror) != 0 ||
108798+ if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
108799 n_rcu_torture_barrier_error != 0 ||
108800 n_rcu_torture_boost_ktrerror != 0 ||
108801 n_rcu_torture_boost_rterror != 0 ||
108802 n_rcu_torture_boost_failure != 0 ||
108803 i > 1) {
108804 pr_cont("%s", "!!! ");
108805- atomic_inc(&n_rcu_torture_error);
108806+ atomic_inc_unchecked(&n_rcu_torture_error);
108807 WARN_ON_ONCE(1);
108808 }
108809 pr_cont("Reader Pipe: ");
108810@@ -1282,7 +1282,7 @@ rcu_torture_stats_print(void)
108811 pr_alert("%s%s ", torture_type, TORTURE_FLAG);
108812 pr_cont("Free-Block Circulation: ");
108813 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
108814- pr_cont(" %d", atomic_read(&rcu_torture_wcount[i]));
108815+ pr_cont(" %d", atomic_read_unchecked(&rcu_torture_wcount[i]));
108816 }
108817 pr_cont("\n");
108818
108819@@ -1636,7 +1636,7 @@ rcu_torture_cleanup(void)
108820
108821 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
108822
108823- if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
108824+ if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
108825 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
108826 else if (torture_onoff_failures())
108827 rcu_torture_print_module_parms(cur_ops,
108828@@ -1761,18 +1761,18 @@ rcu_torture_init(void)
108829
108830 rcu_torture_current = NULL;
108831 rcu_torture_current_version = 0;
108832- atomic_set(&n_rcu_torture_alloc, 0);
108833- atomic_set(&n_rcu_torture_alloc_fail, 0);
108834- atomic_set(&n_rcu_torture_free, 0);
108835- atomic_set(&n_rcu_torture_mberror, 0);
108836- atomic_set(&n_rcu_torture_error, 0);
108837+ atomic_set_unchecked(&n_rcu_torture_alloc, 0);
108838+ atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
108839+ atomic_set_unchecked(&n_rcu_torture_free, 0);
108840+ atomic_set_unchecked(&n_rcu_torture_mberror, 0);
108841+ atomic_set_unchecked(&n_rcu_torture_error, 0);
108842 n_rcu_torture_barrier_error = 0;
108843 n_rcu_torture_boost_ktrerror = 0;
108844 n_rcu_torture_boost_rterror = 0;
108845 n_rcu_torture_boost_failure = 0;
108846 n_rcu_torture_boosts = 0;
108847 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
108848- atomic_set(&rcu_torture_wcount[i], 0);
108849+ atomic_set_unchecked(&rcu_torture_wcount[i], 0);
108850 for_each_possible_cpu(cpu) {
108851 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
108852 per_cpu(rcu_torture_count, cpu)[i] = 0;
108853diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
108854index c291bd6..8a01679 100644
108855--- a/kernel/rcu/tiny.c
108856+++ b/kernel/rcu/tiny.c
108857@@ -42,7 +42,7 @@
108858 /* Forward declarations for tiny_plugin.h. */
108859 struct rcu_ctrlblk;
108860 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
108861-static void rcu_process_callbacks(struct softirq_action *unused);
108862+static void rcu_process_callbacks(void);
108863 static void __call_rcu(struct rcu_head *head,
108864 void (*func)(struct rcu_head *rcu),
108865 struct rcu_ctrlblk *rcp);
108866@@ -170,7 +170,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
108867 false));
108868 }
108869
108870-static void rcu_process_callbacks(struct softirq_action *unused)
108871+static __latent_entropy void rcu_process_callbacks(void)
108872 {
108873 __rcu_process_callbacks(&rcu_sched_ctrlblk);
108874 __rcu_process_callbacks(&rcu_bh_ctrlblk);
108875diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
108876index 65137bc..775d7ad 100644
108877--- a/kernel/rcu/tree.c
108878+++ b/kernel/rcu/tree.c
108879@@ -326,7 +326,7 @@ static void rcu_momentary_dyntick_idle(void)
108880 */
108881 rdtp = this_cpu_ptr(&rcu_dynticks);
108882 smp_mb__before_atomic(); /* Earlier stuff before QS. */
108883- atomic_add(2, &rdtp->dynticks); /* QS. */
108884+ atomic_add_unchecked(2, &rdtp->dynticks); /* QS. */
108885 smp_mb__after_atomic(); /* Later stuff after QS. */
108886 break;
108887 }
108888@@ -639,10 +639,10 @@ static void rcu_eqs_enter_common(long long oldval, bool user)
108889 rcu_prepare_for_idle();
108890 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
108891 smp_mb__before_atomic(); /* See above. */
108892- atomic_inc(&rdtp->dynticks);
108893+ atomic_inc_unchecked(&rdtp->dynticks);
108894 smp_mb__after_atomic(); /* Force ordering with next sojourn. */
108895 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) &&
108896- atomic_read(&rdtp->dynticks) & 0x1);
108897+ atomic_read_unchecked(&rdtp->dynticks) & 0x1);
108898 rcu_dynticks_task_enter();
108899
108900 /*
108901@@ -765,11 +765,11 @@ static void rcu_eqs_exit_common(long long oldval, int user)
108902
108903 rcu_dynticks_task_exit();
108904 smp_mb__before_atomic(); /* Force ordering w/previous sojourn. */
108905- atomic_inc(&rdtp->dynticks);
108906+ atomic_inc_unchecked(&rdtp->dynticks);
108907 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
108908 smp_mb__after_atomic(); /* See above. */
108909 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) &&
108910- !(atomic_read(&rdtp->dynticks) & 0x1));
108911+ !(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
108912 rcu_cleanup_after_idle();
108913 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
108914 if (IS_ENABLED(CONFIG_RCU_EQS_DEBUG) &&
108915@@ -905,12 +905,12 @@ void rcu_nmi_enter(void)
108916 * to be in the outermost NMI handler that interrupted an RCU-idle
108917 * period (observation due to Andy Lutomirski).
108918 */
108919- if (!(atomic_read(&rdtp->dynticks) & 0x1)) {
108920+ if (!(atomic_read_unchecked(&rdtp->dynticks) & 0x1)) {
108921 smp_mb__before_atomic(); /* Force delay from prior write. */
108922- atomic_inc(&rdtp->dynticks);
108923+ atomic_inc_unchecked(&rdtp->dynticks);
108924 /* atomic_inc() before later RCU read-side crit sects */
108925 smp_mb__after_atomic(); /* See above. */
108926- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
108927+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
108928 incby = 1;
108929 }
108930 rdtp->dynticks_nmi_nesting += incby;
108931@@ -935,7 +935,7 @@ void rcu_nmi_exit(void)
108932 * to us!)
108933 */
108934 WARN_ON_ONCE(rdtp->dynticks_nmi_nesting <= 0);
108935- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
108936+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
108937
108938 /*
108939 * If the nesting level is not 1, the CPU wasn't RCU-idle, so
108940@@ -950,9 +950,9 @@ void rcu_nmi_exit(void)
108941 rdtp->dynticks_nmi_nesting = 0;
108942 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
108943 smp_mb__before_atomic(); /* See above. */
108944- atomic_inc(&rdtp->dynticks);
108945+ atomic_inc_unchecked(&rdtp->dynticks);
108946 smp_mb__after_atomic(); /* Force delay to next write. */
108947- WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
108948+ WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
108949 }
108950
108951 /**
108952@@ -965,7 +965,7 @@ void rcu_nmi_exit(void)
108953 */
108954 bool notrace __rcu_is_watching(void)
108955 {
108956- return atomic_read(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1;
108957+ return atomic_read_unchecked(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1;
108958 }
108959
108960 /**
108961@@ -1048,7 +1048,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
108962 static int dyntick_save_progress_counter(struct rcu_data *rdp,
108963 bool *isidle, unsigned long *maxj)
108964 {
108965- rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
108966+ rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
108967 rcu_sysidle_check_cpu(rdp, isidle, maxj);
108968 if ((rdp->dynticks_snap & 0x1) == 0) {
108969 trace_rcu_fqs(rdp->rsp->name, rdp->gpnum, rdp->cpu, TPS("dti"));
108970@@ -1074,7 +1074,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
108971 int *rcrmp;
108972 unsigned int snap;
108973
108974- curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
108975+ curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
108976 snap = (unsigned int)rdp->dynticks_snap;
108977
108978 /*
108979@@ -2895,7 +2895,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
108980 /*
108981 * Do RCU core processing for the current CPU.
108982 */
108983-static void rcu_process_callbacks(struct softirq_action *unused)
108984+static void rcu_process_callbacks(void)
108985 {
108986 struct rcu_state *rsp;
108987
108988@@ -3319,11 +3319,11 @@ void synchronize_sched_expedited(void)
108989 * counter wrap on a 32-bit system. Quite a few more CPUs would of
108990 * course be required on a 64-bit system.
108991 */
108992- if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
108993+ if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
108994 (ulong)atomic_long_read(&rsp->expedited_done) +
108995 ULONG_MAX / 8)) {
108996 wait_rcu_gp(call_rcu_sched);
108997- atomic_long_inc(&rsp->expedited_wrap);
108998+ atomic_long_inc_return_unchecked(&rsp->expedited_wrap);
108999 return;
109000 }
109001
109002@@ -3331,12 +3331,12 @@ void synchronize_sched_expedited(void)
109003 * Take a ticket. Note that atomic_inc_return() implies a
109004 * full memory barrier.
109005 */
109006- snap = atomic_long_inc_return(&rsp->expedited_start);
109007+ snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
109008 firstsnap = snap;
109009 if (!try_get_online_cpus()) {
109010 /* CPU hotplug operation in flight, fall back to normal GP. */
109011 wait_rcu_gp(call_rcu_sched);
109012- atomic_long_inc(&rsp->expedited_normal);
109013+ atomic_long_inc_unchecked(&rsp->expedited_normal);
109014 return;
109015 }
109016 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
109017@@ -3349,7 +3349,7 @@ void synchronize_sched_expedited(void)
109018 for_each_cpu(cpu, cm) {
109019 struct rcu_dynticks *rdtp = &per_cpu(rcu_dynticks, cpu);
109020
109021- if (!(atomic_add_return(0, &rdtp->dynticks) & 0x1))
109022+ if (!(atomic_add_return_unchecked(0, &rdtp->dynticks) & 0x1))
109023 cpumask_clear_cpu(cpu, cm);
109024 }
109025 if (cpumask_weight(cm) == 0)
109026@@ -3364,14 +3364,14 @@ void synchronize_sched_expedited(void)
109027 synchronize_sched_expedited_cpu_stop,
109028 NULL) == -EAGAIN) {
109029 put_online_cpus();
109030- atomic_long_inc(&rsp->expedited_tryfail);
109031+ atomic_long_inc_unchecked(&rsp->expedited_tryfail);
109032
109033 /* Check to see if someone else did our work for us. */
109034 s = atomic_long_read(&rsp->expedited_done);
109035 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
109036 /* ensure test happens before caller kfree */
109037 smp_mb__before_atomic(); /* ^^^ */
109038- atomic_long_inc(&rsp->expedited_workdone1);
109039+ atomic_long_inc_unchecked(&rsp->expedited_workdone1);
109040 free_cpumask_var(cm);
109041 return;
109042 }
109043@@ -3381,7 +3381,7 @@ void synchronize_sched_expedited(void)
109044 udelay(trycount * num_online_cpus());
109045 } else {
109046 wait_rcu_gp(call_rcu_sched);
109047- atomic_long_inc(&rsp->expedited_normal);
109048+ atomic_long_inc_unchecked(&rsp->expedited_normal);
109049 free_cpumask_var(cm);
109050 return;
109051 }
109052@@ -3391,7 +3391,7 @@ void synchronize_sched_expedited(void)
109053 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
109054 /* ensure test happens before caller kfree */
109055 smp_mb__before_atomic(); /* ^^^ */
109056- atomic_long_inc(&rsp->expedited_workdone2);
109057+ atomic_long_inc_unchecked(&rsp->expedited_workdone2);
109058 free_cpumask_var(cm);
109059 return;
109060 }
109061@@ -3406,14 +3406,14 @@ void synchronize_sched_expedited(void)
109062 if (!try_get_online_cpus()) {
109063 /* CPU hotplug operation in flight, use normal GP. */
109064 wait_rcu_gp(call_rcu_sched);
109065- atomic_long_inc(&rsp->expedited_normal);
109066+ atomic_long_inc_unchecked(&rsp->expedited_normal);
109067 free_cpumask_var(cm);
109068 return;
109069 }
109070- snap = atomic_long_read(&rsp->expedited_start);
109071+ snap = atomic_long_read_unchecked(&rsp->expedited_start);
109072 smp_mb(); /* ensure read is before try_stop_cpus(). */
109073 }
109074- atomic_long_inc(&rsp->expedited_stoppedcpus);
109075+ atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
109076
109077 all_cpus_idle:
109078 free_cpumask_var(cm);
109079@@ -3425,16 +3425,16 @@ all_cpus_idle:
109080 * than we did already did their update.
109081 */
109082 do {
109083- atomic_long_inc(&rsp->expedited_done_tries);
109084+ atomic_long_inc_unchecked(&rsp->expedited_done_tries);
109085 s = atomic_long_read(&rsp->expedited_done);
109086 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
109087 /* ensure test happens before caller kfree */
109088 smp_mb__before_atomic(); /* ^^^ */
109089- atomic_long_inc(&rsp->expedited_done_lost);
109090+ atomic_long_inc_unchecked(&rsp->expedited_done_lost);
109091 break;
109092 }
109093 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
109094- atomic_long_inc(&rsp->expedited_done_exit);
109095+ atomic_long_inc_unchecked(&rsp->expedited_done_exit);
109096
109097 put_online_cpus();
109098 }
109099@@ -3767,7 +3767,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
109100 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
109101 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
109102 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
109103- WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
109104+ WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
109105 rdp->cpu = cpu;
109106 rdp->rsp = rsp;
109107 rcu_boot_init_nocb_percpu_data(rdp);
109108@@ -3798,8 +3798,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp)
109109 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
109110 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
109111 rcu_sysidle_init_percpu_data(rdp->dynticks);
109112- atomic_set(&rdp->dynticks->dynticks,
109113- (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
109114+ atomic_set_unchecked(&rdp->dynticks->dynticks,
109115+ (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
109116 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
109117
109118 /*
109119diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
109120index 4adb7ca..20910e6 100644
109121--- a/kernel/rcu/tree.h
109122+++ b/kernel/rcu/tree.h
109123@@ -108,11 +108,11 @@ struct rcu_dynticks {
109124 long long dynticks_nesting; /* Track irq/process nesting level. */
109125 /* Process level is worth LLONG_MAX/2. */
109126 int dynticks_nmi_nesting; /* Track NMI nesting level. */
109127- atomic_t dynticks; /* Even value for idle, else odd. */
109128+ atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
109129 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
109130 long long dynticks_idle_nesting;
109131 /* irq/process nesting level from idle. */
109132- atomic_t dynticks_idle; /* Even value for idle, else odd. */
109133+ atomic_unchecked_t dynticks_idle;/* Even value for idle, else odd. */
109134 /* "Idle" excludes userspace execution. */
109135 unsigned long dynticks_idle_jiffies;
109136 /* End of last non-NMI non-idle period. */
109137@@ -483,17 +483,17 @@ struct rcu_state {
109138 /* _rcu_barrier(). */
109139 /* End of fields guarded by barrier_mutex. */
109140
109141- atomic_long_t expedited_start; /* Starting ticket. */
109142- atomic_long_t expedited_done; /* Done ticket. */
109143- atomic_long_t expedited_wrap; /* # near-wrap incidents. */
109144- atomic_long_t expedited_tryfail; /* # acquisition failures. */
109145- atomic_long_t expedited_workdone1; /* # done by others #1. */
109146- atomic_long_t expedited_workdone2; /* # done by others #2. */
109147- atomic_long_t expedited_normal; /* # fallbacks to normal. */
109148- atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
109149- atomic_long_t expedited_done_tries; /* # tries to update _done. */
109150- atomic_long_t expedited_done_lost; /* # times beaten to _done. */
109151- atomic_long_t expedited_done_exit; /* # times exited _done loop. */
109152+ atomic_long_unchecked_t expedited_start; /* Starting ticket. */
109153+ atomic_long_t expedited_done; /* Done ticket. */
109154+ atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
109155+ atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
109156+ atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
109157+ atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
109158+ atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
109159+ atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
109160+ atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
109161+ atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
109162+ atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
109163
109164 unsigned long jiffies_force_qs; /* Time at which to invoke */
109165 /* force_quiescent_state(). */
109166diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
109167index 013485f..2e678db 100644
109168--- a/kernel/rcu/tree_plugin.h
109169+++ b/kernel/rcu/tree_plugin.h
109170@@ -1294,7 +1294,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
109171 free_cpumask_var(cm);
109172 }
109173
109174-static struct smp_hotplug_thread rcu_cpu_thread_spec = {
109175+static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
109176 .store = &rcu_cpu_kthread_task,
109177 .thread_should_run = rcu_cpu_kthread_should_run,
109178 .thread_fn = rcu_cpu_kthread,
109179@@ -1767,7 +1767,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
109180 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
109181 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u fqs=%ld %s\n",
109182 cpu, ticks_value, ticks_title,
109183- atomic_read(&rdtp->dynticks) & 0xfff,
109184+ atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
109185 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
109186 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
109187 READ_ONCE(rsp->n_force_qs) - rsp->n_force_qs_gpstart,
109188@@ -2675,9 +2675,9 @@ static void rcu_sysidle_enter(int irq)
109189 j = jiffies;
109190 WRITE_ONCE(rdtp->dynticks_idle_jiffies, j);
109191 smp_mb__before_atomic();
109192- atomic_inc(&rdtp->dynticks_idle);
109193+ atomic_inc_unchecked(&rdtp->dynticks_idle);
109194 smp_mb__after_atomic();
109195- WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
109196+ WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
109197 }
109198
109199 /*
109200@@ -2748,9 +2748,9 @@ static void rcu_sysidle_exit(int irq)
109201
109202 /* Record end of idle period. */
109203 smp_mb__before_atomic();
109204- atomic_inc(&rdtp->dynticks_idle);
109205+ atomic_inc_unchecked(&rdtp->dynticks_idle);
109206 smp_mb__after_atomic();
109207- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
109208+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
109209
109210 /*
109211 * If we are the timekeeping CPU, we are permitted to be non-idle
109212@@ -2796,7 +2796,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
109213 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
109214
109215 /* Pick up current idle and NMI-nesting counter and check. */
109216- cur = atomic_read(&rdtp->dynticks_idle);
109217+ cur = atomic_read_unchecked(&rdtp->dynticks_idle);
109218 if (cur & 0x1) {
109219 *isidle = false; /* We are not idle! */
109220 return;
109221diff --git a/kernel/rcu/tree_trace.c b/kernel/rcu/tree_trace.c
109222index 3ea7ffc..cb06f2d 100644
109223--- a/kernel/rcu/tree_trace.c
109224+++ b/kernel/rcu/tree_trace.c
109225@@ -125,7 +125,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
109226 rdp->rcu_qs_ctr_snap == per_cpu(rcu_qs_ctr, rdp->cpu),
109227 rdp->qs_pending);
109228 seq_printf(m, " dt=%d/%llx/%d df=%lu",
109229- atomic_read(&rdp->dynticks->dynticks),
109230+ atomic_read_unchecked(&rdp->dynticks->dynticks),
109231 rdp->dynticks->dynticks_nesting,
109232 rdp->dynticks->dynticks_nmi_nesting,
109233 rdp->dynticks_fqs);
109234@@ -186,17 +186,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
109235 struct rcu_state *rsp = (struct rcu_state *)m->private;
109236
109237 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",
109238- atomic_long_read(&rsp->expedited_start),
109239+ atomic_long_read_unchecked(&rsp->expedited_start),
109240 atomic_long_read(&rsp->expedited_done),
109241- atomic_long_read(&rsp->expedited_wrap),
109242- atomic_long_read(&rsp->expedited_tryfail),
109243- atomic_long_read(&rsp->expedited_workdone1),
109244- atomic_long_read(&rsp->expedited_workdone2),
109245- atomic_long_read(&rsp->expedited_normal),
109246- atomic_long_read(&rsp->expedited_stoppedcpus),
109247- atomic_long_read(&rsp->expedited_done_tries),
109248- atomic_long_read(&rsp->expedited_done_lost),
109249- atomic_long_read(&rsp->expedited_done_exit));
109250+ atomic_long_read_unchecked(&rsp->expedited_wrap),
109251+ atomic_long_read_unchecked(&rsp->expedited_tryfail),
109252+ atomic_long_read_unchecked(&rsp->expedited_workdone1),
109253+ atomic_long_read_unchecked(&rsp->expedited_workdone2),
109254+ atomic_long_read_unchecked(&rsp->expedited_normal),
109255+ atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
109256+ atomic_long_read_unchecked(&rsp->expedited_done_tries),
109257+ atomic_long_read_unchecked(&rsp->expedited_done_lost),
109258+ atomic_long_read_unchecked(&rsp->expedited_done_exit));
109259 return 0;
109260 }
109261
109262diff --git a/kernel/resource.c b/kernel/resource.c
109263index fed052a..ad13346 100644
109264--- a/kernel/resource.c
109265+++ b/kernel/resource.c
109266@@ -162,8 +162,18 @@ static const struct file_operations proc_iomem_operations = {
109267
109268 static int __init ioresources_init(void)
109269 {
109270+#ifdef CONFIG_GRKERNSEC_PROC_ADD
109271+#ifdef CONFIG_GRKERNSEC_PROC_USER
109272+ proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
109273+ proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
109274+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
109275+ proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
109276+ proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
109277+#endif
109278+#else
109279 proc_create("ioports", 0, NULL, &proc_ioports_operations);
109280 proc_create("iomem", 0, NULL, &proc_iomem_operations);
109281+#endif
109282 return 0;
109283 }
109284 __initcall(ioresources_init);
109285diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
109286index 750ed60..eb01466 100644
109287--- a/kernel/sched/auto_group.c
109288+++ b/kernel/sched/auto_group.c
109289@@ -9,7 +9,7 @@
109290
109291 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
109292 static struct autogroup autogroup_default;
109293-static atomic_t autogroup_seq_nr;
109294+static atomic_unchecked_t autogroup_seq_nr;
109295
109296 void __init autogroup_init(struct task_struct *init_task)
109297 {
109298@@ -77,7 +77,7 @@ static inline struct autogroup *autogroup_create(void)
109299
109300 kref_init(&ag->kref);
109301 init_rwsem(&ag->lock);
109302- ag->id = atomic_inc_return(&autogroup_seq_nr);
109303+ ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
109304 ag->tg = tg;
109305 #ifdef CONFIG_RT_GROUP_SCHED
109306 /*
109307diff --git a/kernel/sched/core.c b/kernel/sched/core.c
109308index 6776631..45eb6ee 100644
109309--- a/kernel/sched/core.c
109310+++ b/kernel/sched/core.c
109311@@ -2080,7 +2080,7 @@ void set_numabalancing_state(bool enabled)
109312 int sysctl_numa_balancing(struct ctl_table *table, int write,
109313 void __user *buffer, size_t *lenp, loff_t *ppos)
109314 {
109315- struct ctl_table t;
109316+ ctl_table_no_const t;
109317 int err;
109318 int state = numabalancing_enabled;
109319
109320@@ -2573,8 +2573,10 @@ context_switch(struct rq *rq, struct task_struct *prev,
109321 next->active_mm = oldmm;
109322 atomic_inc(&oldmm->mm_count);
109323 enter_lazy_tlb(oldmm, next);
109324- } else
109325+ } else {
109326 switch_mm(oldmm, mm, next);
109327+ populate_stack();
109328+ }
109329
109330 if (!prev->mm) {
109331 prev->active_mm = NULL;
109332@@ -3393,6 +3395,8 @@ int can_nice(const struct task_struct *p, const int nice)
109333 /* convert nice value [19,-20] to rlimit style value [1,40] */
109334 int nice_rlim = nice_to_rlimit(nice);
109335
109336+ gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
109337+
109338 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
109339 capable(CAP_SYS_NICE));
109340 }
109341@@ -3419,7 +3423,8 @@ SYSCALL_DEFINE1(nice, int, increment)
109342 nice = task_nice(current) + increment;
109343
109344 nice = clamp_val(nice, MIN_NICE, MAX_NICE);
109345- if (increment < 0 && !can_nice(current, nice))
109346+ if (increment < 0 && (!can_nice(current, nice) ||
109347+ gr_handle_chroot_nice()))
109348 return -EPERM;
109349
109350 retval = security_task_setnice(current, nice);
109351@@ -3731,6 +3736,7 @@ recheck:
109352 if (policy != p->policy && !rlim_rtprio)
109353 return -EPERM;
109354
109355+ gr_learn_resource(p, RLIMIT_RTPRIO, attr->sched_priority, 1);
109356 /* can't increase priority */
109357 if (attr->sched_priority > p->rt_priority &&
109358 attr->sched_priority > rlim_rtprio)
109359@@ -5055,6 +5061,7 @@ void idle_task_exit(void)
109360
109361 if (mm != &init_mm) {
109362 switch_mm(mm, &init_mm, current);
109363+ populate_stack();
109364 finish_arch_post_lock_switch();
109365 }
109366 mmdrop(mm);
109367@@ -5157,7 +5164,7 @@ static void migrate_tasks(struct rq *dead_rq)
109368
109369 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
109370
109371-static struct ctl_table sd_ctl_dir[] = {
109372+static ctl_table_no_const sd_ctl_dir[] __read_only = {
109373 {
109374 .procname = "sched_domain",
109375 .mode = 0555,
109376@@ -5174,17 +5181,17 @@ static struct ctl_table sd_ctl_root[] = {
109377 {}
109378 };
109379
109380-static struct ctl_table *sd_alloc_ctl_entry(int n)
109381+static ctl_table_no_const *sd_alloc_ctl_entry(int n)
109382 {
109383- struct ctl_table *entry =
109384+ ctl_table_no_const *entry =
109385 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
109386
109387 return entry;
109388 }
109389
109390-static void sd_free_ctl_entry(struct ctl_table **tablep)
109391+static void sd_free_ctl_entry(ctl_table_no_const *tablep)
109392 {
109393- struct ctl_table *entry;
109394+ ctl_table_no_const *entry;
109395
109396 /*
109397 * In the intermediate directories, both the child directory and
109398@@ -5192,22 +5199,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
109399 * will always be set. In the lowest directory the names are
109400 * static strings and all have proc handlers.
109401 */
109402- for (entry = *tablep; entry->mode; entry++) {
109403- if (entry->child)
109404- sd_free_ctl_entry(&entry->child);
109405+ for (entry = tablep; entry->mode; entry++) {
109406+ if (entry->child) {
109407+ sd_free_ctl_entry(entry->child);
109408+ pax_open_kernel();
109409+ entry->child = NULL;
109410+ pax_close_kernel();
109411+ }
109412 if (entry->proc_handler == NULL)
109413 kfree(entry->procname);
109414 }
109415
109416- kfree(*tablep);
109417- *tablep = NULL;
109418+ kfree(tablep);
109419 }
109420
109421 static int min_load_idx = 0;
109422 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
109423
109424 static void
109425-set_table_entry(struct ctl_table *entry,
109426+set_table_entry(ctl_table_no_const *entry,
109427 const char *procname, void *data, int maxlen,
109428 umode_t mode, proc_handler *proc_handler,
109429 bool load_idx)
109430@@ -5227,7 +5237,7 @@ set_table_entry(struct ctl_table *entry,
109431 static struct ctl_table *
109432 sd_alloc_ctl_domain_table(struct sched_domain *sd)
109433 {
109434- struct ctl_table *table = sd_alloc_ctl_entry(14);
109435+ ctl_table_no_const *table = sd_alloc_ctl_entry(14);
109436
109437 if (table == NULL)
109438 return NULL;
109439@@ -5265,9 +5275,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
109440 return table;
109441 }
109442
109443-static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
109444+static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
109445 {
109446- struct ctl_table *entry, *table;
109447+ ctl_table_no_const *entry, *table;
109448 struct sched_domain *sd;
109449 int domain_num = 0, i;
109450 char buf[32];
109451@@ -5294,11 +5304,13 @@ static struct ctl_table_header *sd_sysctl_header;
109452 static void register_sched_domain_sysctl(void)
109453 {
109454 int i, cpu_num = num_possible_cpus();
109455- struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
109456+ ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
109457 char buf[32];
109458
109459 WARN_ON(sd_ctl_dir[0].child);
109460+ pax_open_kernel();
109461 sd_ctl_dir[0].child = entry;
109462+ pax_close_kernel();
109463
109464 if (entry == NULL)
109465 return;
109466@@ -5321,8 +5333,12 @@ static void unregister_sched_domain_sysctl(void)
109467 if (sd_sysctl_header)
109468 unregister_sysctl_table(sd_sysctl_header);
109469 sd_sysctl_header = NULL;
109470- if (sd_ctl_dir[0].child)
109471- sd_free_ctl_entry(&sd_ctl_dir[0].child);
109472+ if (sd_ctl_dir[0].child) {
109473+ sd_free_ctl_entry(sd_ctl_dir[0].child);
109474+ pax_open_kernel();
109475+ sd_ctl_dir[0].child = NULL;
109476+ pax_close_kernel();
109477+ }
109478 }
109479 #else
109480 static void register_sched_domain_sysctl(void)
109481diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
109482index d113c3b..91a6fcc 100644
109483--- a/kernel/sched/fair.c
109484+++ b/kernel/sched/fair.c
109485@@ -7958,7 +7958,7 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) { }
109486 * run_rebalance_domains is triggered when needed from the scheduler tick.
109487 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
109488 */
109489-static void run_rebalance_domains(struct softirq_action *h)
109490+static __latent_entropy void run_rebalance_domains(void)
109491 {
109492 struct rq *this_rq = this_rq();
109493 enum cpu_idle_type idle = this_rq->idle_balance ?
109494diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
109495index 08ab96b..82ab34c 100644
109496--- a/kernel/sched/sched.h
109497+++ b/kernel/sched/sched.h
109498@@ -1242,7 +1242,7 @@ struct sched_class {
109499 #ifdef CONFIG_FAIR_GROUP_SCHED
109500 void (*task_move_group) (struct task_struct *p, int on_rq);
109501 #endif
109502-};
109503+} __do_const;
109504
109505 static inline void put_prev_task(struct rq *rq, struct task_struct *prev)
109506 {
109507diff --git a/kernel/signal.c b/kernel/signal.c
109508index 0f6bbbe..d77d2c3 100644
109509--- a/kernel/signal.c
109510+++ b/kernel/signal.c
109511@@ -53,12 +53,12 @@ static struct kmem_cache *sigqueue_cachep;
109512
109513 int print_fatal_signals __read_mostly;
109514
109515-static void __user *sig_handler(struct task_struct *t, int sig)
109516+static __sighandler_t sig_handler(struct task_struct *t, int sig)
109517 {
109518 return t->sighand->action[sig - 1].sa.sa_handler;
109519 }
109520
109521-static int sig_handler_ignored(void __user *handler, int sig)
109522+static int sig_handler_ignored(__sighandler_t handler, int sig)
109523 {
109524 /* Is it explicitly or implicitly ignored? */
109525 return handler == SIG_IGN ||
109526@@ -67,7 +67,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
109527
109528 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
109529 {
109530- void __user *handler;
109531+ __sighandler_t handler;
109532
109533 handler = sig_handler(t, sig);
109534
109535@@ -372,6 +372,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
109536 atomic_inc(&user->sigpending);
109537 rcu_read_unlock();
109538
109539+ if (!override_rlimit)
109540+ gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
109541+
109542 if (override_rlimit ||
109543 atomic_read(&user->sigpending) <=
109544 task_rlimit(t, RLIMIT_SIGPENDING)) {
109545@@ -494,7 +497,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
109546
109547 int unhandled_signal(struct task_struct *tsk, int sig)
109548 {
109549- void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
109550+ __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
109551 if (is_global_init(tsk))
109552 return 1;
109553 if (handler != SIG_IGN && handler != SIG_DFL)
109554@@ -788,6 +791,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
109555 }
109556 }
109557
109558+ /* allow glibc communication via tgkill to other threads in our
109559+ thread group */
109560+ if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
109561+ sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
109562+ && gr_handle_signal(t, sig))
109563+ return -EPERM;
109564+
109565 return security_task_kill(t, info, sig, 0);
109566 }
109567
109568@@ -1171,7 +1181,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
109569 return send_signal(sig, info, p, 1);
109570 }
109571
109572-static int
109573+int
109574 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
109575 {
109576 return send_signal(sig, info, t, 0);
109577@@ -1208,6 +1218,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
109578 unsigned long int flags;
109579 int ret, blocked, ignored;
109580 struct k_sigaction *action;
109581+ int is_unhandled = 0;
109582
109583 spin_lock_irqsave(&t->sighand->siglock, flags);
109584 action = &t->sighand->action[sig-1];
109585@@ -1222,9 +1233,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
109586 }
109587 if (action->sa.sa_handler == SIG_DFL)
109588 t->signal->flags &= ~SIGNAL_UNKILLABLE;
109589+ if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
109590+ is_unhandled = 1;
109591 ret = specific_send_sig_info(sig, info, t);
109592 spin_unlock_irqrestore(&t->sighand->siglock, flags);
109593
109594+ /* only deal with unhandled signals, java etc trigger SIGSEGV during
109595+ normal operation */
109596+ if (is_unhandled) {
109597+ gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
109598+ gr_handle_crash(t, sig);
109599+ }
109600+
109601 return ret;
109602 }
109603
109604@@ -1305,8 +1325,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
109605 ret = check_kill_permission(sig, info, p);
109606 rcu_read_unlock();
109607
109608- if (!ret && sig)
109609+ if (!ret && sig) {
109610 ret = do_send_sig_info(sig, info, p, true);
109611+ if (!ret)
109612+ gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
109613+ }
109614
109615 return ret;
109616 }
109617@@ -2913,7 +2936,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
109618 int error = -ESRCH;
109619
109620 rcu_read_lock();
109621- p = find_task_by_vpid(pid);
109622+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
109623+ /* allow glibc communication via tgkill to other threads in our
109624+ thread group */
109625+ if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
109626+ sig == (SIGRTMIN+1) && tgid == info->si_pid)
109627+ p = find_task_by_vpid_unrestricted(pid);
109628+ else
109629+#endif
109630+ p = find_task_by_vpid(pid);
109631 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
109632 error = check_kill_permission(sig, info, p);
109633 /*
109634@@ -3242,8 +3273,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
109635 }
109636 seg = get_fs();
109637 set_fs(KERNEL_DS);
109638- ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
109639- (stack_t __force __user *) &uoss,
109640+ ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
109641+ (stack_t __force_user *) &uoss,
109642 compat_user_stack_pointer());
109643 set_fs(seg);
109644 if (ret >= 0 && uoss_ptr) {
109645diff --git a/kernel/smpboot.c b/kernel/smpboot.c
109646index 7c434c3..155d90a 100644
109647--- a/kernel/smpboot.c
109648+++ b/kernel/smpboot.c
109649@@ -305,7 +305,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
109650 }
109651 smpboot_unpark_thread(plug_thread, cpu);
109652 }
109653- list_add(&plug_thread->list, &hotplug_threads);
109654+ pax_list_add(&plug_thread->list, &hotplug_threads);
109655 out:
109656 mutex_unlock(&smpboot_threads_lock);
109657 put_online_cpus();
109658@@ -323,7 +323,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
109659 {
109660 get_online_cpus();
109661 mutex_lock(&smpboot_threads_lock);
109662- list_del(&plug_thread->list);
109663+ pax_list_del(&plug_thread->list);
109664 smpboot_destroy_threads(plug_thread);
109665 mutex_unlock(&smpboot_threads_lock);
109666 put_online_cpus();
109667diff --git a/kernel/softirq.c b/kernel/softirq.c
109668index 479e443..66d845e1 100644
109669--- a/kernel/softirq.c
109670+++ b/kernel/softirq.c
109671@@ -53,7 +53,7 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
109672 EXPORT_SYMBOL(irq_stat);
109673 #endif
109674
109675-static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
109676+static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
109677
109678 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
109679
109680@@ -270,7 +270,7 @@ restart:
109681 kstat_incr_softirqs_this_cpu(vec_nr);
109682
109683 trace_softirq_entry(vec_nr);
109684- h->action(h);
109685+ h->action();
109686 trace_softirq_exit(vec_nr);
109687 if (unlikely(prev_count != preempt_count())) {
109688 pr_err("huh, entered softirq %u %s %p with preempt_count %08x, exited with %08x?\n",
109689@@ -430,7 +430,7 @@ void __raise_softirq_irqoff(unsigned int nr)
109690 or_softirq_pending(1UL << nr);
109691 }
109692
109693-void open_softirq(int nr, void (*action)(struct softirq_action *))
109694+void __init open_softirq(int nr, void (*action)(void))
109695 {
109696 softirq_vec[nr].action = action;
109697 }
109698@@ -482,7 +482,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
109699 }
109700 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
109701
109702-static void tasklet_action(struct softirq_action *a)
109703+static void tasklet_action(void)
109704 {
109705 struct tasklet_struct *list;
109706
109707@@ -518,7 +518,7 @@ static void tasklet_action(struct softirq_action *a)
109708 }
109709 }
109710
109711-static void tasklet_hi_action(struct softirq_action *a)
109712+static __latent_entropy void tasklet_hi_action(void)
109713 {
109714 struct tasklet_struct *list;
109715
109716@@ -744,7 +744,7 @@ static struct notifier_block cpu_nfb = {
109717 .notifier_call = cpu_callback
109718 };
109719
109720-static struct smp_hotplug_thread softirq_threads = {
109721+static struct smp_hotplug_thread softirq_threads __read_only = {
109722 .store = &ksoftirqd,
109723 .thread_should_run = ksoftirqd_should_run,
109724 .thread_fn = run_ksoftirqd,
109725diff --git a/kernel/sys.c b/kernel/sys.c
109726index 259fda2..e824a93 100644
109727--- a/kernel/sys.c
109728+++ b/kernel/sys.c
109729@@ -160,6 +160,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
109730 error = -EACCES;
109731 goto out;
109732 }
109733+
109734+ if (gr_handle_chroot_setpriority(p, niceval)) {
109735+ error = -EACCES;
109736+ goto out;
109737+ }
109738+
109739 no_nice = security_task_setnice(p, niceval);
109740 if (no_nice) {
109741 error = no_nice;
109742@@ -366,6 +372,20 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
109743 goto error;
109744 }
109745
109746+ if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
109747+ goto error;
109748+
109749+ if (!gid_eq(new->gid, old->gid)) {
109750+ /* make sure we generate a learn log for what will
109751+ end up being a role transition after a full-learning
109752+ policy is generated
109753+ CAP_SETGID is required to perform a transition
109754+ we may not log a CAP_SETGID check above, e.g.
109755+ in the case where new rgid = old egid
109756+ */
109757+ gr_learn_cap(current, new, CAP_SETGID);
109758+ }
109759+
109760 if (rgid != (gid_t) -1 ||
109761 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
109762 new->sgid = new->egid;
109763@@ -401,6 +421,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
109764 old = current_cred();
109765
109766 retval = -EPERM;
109767+
109768+ if (gr_check_group_change(kgid, kgid, kgid))
109769+ goto error;
109770+
109771 if (ns_capable(old->user_ns, CAP_SETGID))
109772 new->gid = new->egid = new->sgid = new->fsgid = kgid;
109773 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
109774@@ -418,7 +442,7 @@ error:
109775 /*
109776 * change the user struct in a credentials set to match the new UID
109777 */
109778-static int set_user(struct cred *new)
109779+int set_user(struct cred *new)
109780 {
109781 struct user_struct *new_user;
109782
109783@@ -498,7 +522,18 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
109784 goto error;
109785 }
109786
109787+ if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
109788+ goto error;
109789+
109790 if (!uid_eq(new->uid, old->uid)) {
109791+ /* make sure we generate a learn log for what will
109792+ end up being a role transition after a full-learning
109793+ policy is generated
109794+ CAP_SETUID is required to perform a transition
109795+ we may not log a CAP_SETUID check above, e.g.
109796+ in the case where new ruid = old euid
109797+ */
109798+ gr_learn_cap(current, new, CAP_SETUID);
109799 retval = set_user(new);
109800 if (retval < 0)
109801 goto error;
109802@@ -548,6 +583,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
109803 old = current_cred();
109804
109805 retval = -EPERM;
109806+
109807+ if (gr_check_crash_uid(kuid))
109808+ goto error;
109809+ if (gr_check_user_change(kuid, kuid, kuid))
109810+ goto error;
109811+
109812 if (ns_capable(old->user_ns, CAP_SETUID)) {
109813 new->suid = new->uid = kuid;
109814 if (!uid_eq(kuid, old->uid)) {
109815@@ -617,6 +658,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
109816 goto error;
109817 }
109818
109819+ if (gr_check_user_change(kruid, keuid, INVALID_UID))
109820+ goto error;
109821+
109822 if (ruid != (uid_t) -1) {
109823 new->uid = kruid;
109824 if (!uid_eq(kruid, old->uid)) {
109825@@ -701,6 +745,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
109826 goto error;
109827 }
109828
109829+ if (gr_check_group_change(krgid, kegid, INVALID_GID))
109830+ goto error;
109831+
109832 if (rgid != (gid_t) -1)
109833 new->gid = krgid;
109834 if (egid != (gid_t) -1)
109835@@ -765,12 +812,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
109836 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
109837 ns_capable(old->user_ns, CAP_SETUID)) {
109838 if (!uid_eq(kuid, old->fsuid)) {
109839+ if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
109840+ goto error;
109841+
109842 new->fsuid = kuid;
109843 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
109844 goto change_okay;
109845 }
109846 }
109847
109848+error:
109849 abort_creds(new);
109850 return old_fsuid;
109851
109852@@ -803,12 +854,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
109853 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
109854 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
109855 ns_capable(old->user_ns, CAP_SETGID)) {
109856+ if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
109857+ goto error;
109858+
109859 if (!gid_eq(kgid, old->fsgid)) {
109860 new->fsgid = kgid;
109861 goto change_okay;
109862 }
109863 }
109864
109865+error:
109866 abort_creds(new);
109867 return old_fsgid;
109868
109869@@ -1187,19 +1242,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
109870 return -EFAULT;
109871
109872 down_read(&uts_sem);
109873- error = __copy_to_user(&name->sysname, &utsname()->sysname,
109874+ error = __copy_to_user(name->sysname, &utsname()->sysname,
109875 __OLD_UTS_LEN);
109876 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
109877- error |= __copy_to_user(&name->nodename, &utsname()->nodename,
109878+ error |= __copy_to_user(name->nodename, &utsname()->nodename,
109879 __OLD_UTS_LEN);
109880 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
109881- error |= __copy_to_user(&name->release, &utsname()->release,
109882+ error |= __copy_to_user(name->release, &utsname()->release,
109883 __OLD_UTS_LEN);
109884 error |= __put_user(0, name->release + __OLD_UTS_LEN);
109885- error |= __copy_to_user(&name->version, &utsname()->version,
109886+ error |= __copy_to_user(name->version, &utsname()->version,
109887 __OLD_UTS_LEN);
109888 error |= __put_user(0, name->version + __OLD_UTS_LEN);
109889- error |= __copy_to_user(&name->machine, &utsname()->machine,
109890+ error |= __copy_to_user(name->machine, &utsname()->machine,
109891 __OLD_UTS_LEN);
109892 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
109893 up_read(&uts_sem);
109894@@ -1400,6 +1455,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
109895 */
109896 new_rlim->rlim_cur = 1;
109897 }
109898+ /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
109899+ is changed to a lower value. Since tasks can be created by the same
109900+ user in between this limit change and an execve by this task, force
109901+ a recheck only for this task by setting PF_NPROC_EXCEEDED
109902+ */
109903+ if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
109904+ tsk->flags |= PF_NPROC_EXCEEDED;
109905 }
109906 if (!retval) {
109907 if (old_rlim)
109908diff --git a/kernel/sysctl.c b/kernel/sysctl.c
109909index 19b62b5..74cc287 100644
109910--- a/kernel/sysctl.c
109911+++ b/kernel/sysctl.c
109912@@ -94,7 +94,6 @@
109913 #endif
109914
109915 #if defined(CONFIG_SYSCTL)
109916-
109917 /* External variables not in a header file. */
109918 extern int suid_dumpable;
109919 #ifdef CONFIG_COREDUMP
109920@@ -111,22 +110,24 @@ extern int sysctl_nr_open_min, sysctl_nr_open_max;
109921 #ifndef CONFIG_MMU
109922 extern int sysctl_nr_trim_pages;
109923 #endif
109924+extern int sysctl_modify_ldt;
109925
109926 /* Constants used for minimum and maximum */
109927 #ifdef CONFIG_LOCKUP_DETECTOR
109928-static int sixty = 60;
109929+static int sixty __read_only = 60;
109930 #endif
109931
109932-static int __maybe_unused neg_one = -1;
109933+static int __maybe_unused neg_one __read_only = -1;
109934
109935-static int zero;
109936-static int __maybe_unused one = 1;
109937-static int __maybe_unused two = 2;
109938-static int __maybe_unused four = 4;
109939-static unsigned long one_ul = 1;
109940-static int one_hundred = 100;
109941+static int zero __read_only = 0;
109942+static int __maybe_unused one __read_only = 1;
109943+static int __maybe_unused two __read_only = 2;
109944+static int __maybe_unused three __read_only = 3;
109945+static int __maybe_unused four __read_only = 4;
109946+static unsigned long one_ul __read_only = 1;
109947+static int one_hundred __read_only = 100;
109948 #ifdef CONFIG_PRINTK
109949-static int ten_thousand = 10000;
109950+static int ten_thousand __read_only = 10000;
109951 #endif
109952
109953 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
109954@@ -180,10 +181,8 @@ static int proc_taint(struct ctl_table *table, int write,
109955 void __user *buffer, size_t *lenp, loff_t *ppos);
109956 #endif
109957
109958-#ifdef CONFIG_PRINTK
109959-static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
109960+static int proc_dointvec_minmax_secure_sysadmin(struct ctl_table *table, int write,
109961 void __user *buffer, size_t *lenp, loff_t *ppos);
109962-#endif
109963
109964 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
109965 void __user *buffer, size_t *lenp, loff_t *ppos);
109966@@ -214,6 +213,8 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write,
109967
109968 #endif
109969
109970+extern struct ctl_table grsecurity_table[];
109971+
109972 static struct ctl_table kern_table[];
109973 static struct ctl_table vm_table[];
109974 static struct ctl_table fs_table[];
109975@@ -228,6 +229,20 @@ extern struct ctl_table epoll_table[];
109976 int sysctl_legacy_va_layout;
109977 #endif
109978
109979+#ifdef CONFIG_PAX_SOFTMODE
109980+static struct ctl_table pax_table[] = {
109981+ {
109982+ .procname = "softmode",
109983+ .data = &pax_softmode,
109984+ .maxlen = sizeof(unsigned int),
109985+ .mode = 0600,
109986+ .proc_handler = &proc_dointvec,
109987+ },
109988+
109989+ { }
109990+};
109991+#endif
109992+
109993 /* The default sysctl tables: */
109994
109995 static struct ctl_table sysctl_base_table[] = {
109996@@ -276,6 +291,22 @@ static int max_extfrag_threshold = 1000;
109997 #endif
109998
109999 static struct ctl_table kern_table[] = {
110000+#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
110001+ {
110002+ .procname = "grsecurity",
110003+ .mode = 0500,
110004+ .child = grsecurity_table,
110005+ },
110006+#endif
110007+
110008+#ifdef CONFIG_PAX_SOFTMODE
110009+ {
110010+ .procname = "pax",
110011+ .mode = 0500,
110012+ .child = pax_table,
110013+ },
110014+#endif
110015+
110016 {
110017 .procname = "sched_child_runs_first",
110018 .data = &sysctl_sched_child_runs_first,
110019@@ -628,7 +659,7 @@ static struct ctl_table kern_table[] = {
110020 .maxlen = sizeof(int),
110021 .mode = 0644,
110022 /* only handle a transition from default "0" to "1" */
110023- .proc_handler = proc_dointvec_minmax,
110024+ .proc_handler = proc_dointvec_minmax_secure,
110025 .extra1 = &one,
110026 .extra2 = &one,
110027 },
110028@@ -639,7 +670,7 @@ static struct ctl_table kern_table[] = {
110029 .data = &modprobe_path,
110030 .maxlen = KMOD_PATH_LEN,
110031 .mode = 0644,
110032- .proc_handler = proc_dostring,
110033+ .proc_handler = proc_dostring_modpriv,
110034 },
110035 {
110036 .procname = "modules_disabled",
110037@@ -647,7 +678,7 @@ static struct ctl_table kern_table[] = {
110038 .maxlen = sizeof(int),
110039 .mode = 0644,
110040 /* only handle a transition from default "0" to "1" */
110041- .proc_handler = proc_dointvec_minmax,
110042+ .proc_handler = proc_dointvec_minmax_secure,
110043 .extra1 = &one,
110044 .extra2 = &one,
110045 },
110046@@ -802,20 +833,24 @@ static struct ctl_table kern_table[] = {
110047 .data = &dmesg_restrict,
110048 .maxlen = sizeof(int),
110049 .mode = 0644,
110050- .proc_handler = proc_dointvec_minmax_sysadmin,
110051+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
110052 .extra1 = &zero,
110053 .extra2 = &one,
110054 },
110055+#endif
110056 {
110057 .procname = "kptr_restrict",
110058 .data = &kptr_restrict,
110059 .maxlen = sizeof(int),
110060 .mode = 0644,
110061- .proc_handler = proc_dointvec_minmax_sysadmin,
110062+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
110063+#ifdef CONFIG_GRKERNSEC_HIDESYM
110064+ .extra1 = &two,
110065+#else
110066 .extra1 = &zero,
110067+#endif
110068 .extra2 = &two,
110069 },
110070-#endif
110071 {
110072 .procname = "ngroups_max",
110073 .data = &ngroups_max,
110074@@ -960,6 +995,15 @@ static struct ctl_table kern_table[] = {
110075 .mode = 0644,
110076 .proc_handler = proc_dointvec,
110077 },
110078+ {
110079+ .procname = "modify_ldt",
110080+ .data = &sysctl_modify_ldt,
110081+ .maxlen = sizeof(int),
110082+ .mode = 0644,
110083+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
110084+ .extra1 = &zero,
110085+ .extra2 = &one,
110086+ },
110087 #endif
110088 #if defined(CONFIG_MMU)
110089 {
110090@@ -1082,10 +1126,17 @@ static struct ctl_table kern_table[] = {
110091 */
110092 {
110093 .procname = "perf_event_paranoid",
110094- .data = &sysctl_perf_event_paranoid,
110095- .maxlen = sizeof(sysctl_perf_event_paranoid),
110096+ .data = &sysctl_perf_event_legitimately_concerned,
110097+ .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
110098 .mode = 0644,
110099- .proc_handler = proc_dointvec,
110100+ /* go ahead, be a hero */
110101+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
110102+ .extra1 = &neg_one,
110103+#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
110104+ .extra2 = &three,
110105+#else
110106+ .extra2 = &two,
110107+#endif
110108 },
110109 {
110110 .procname = "perf_event_mlock_kb",
110111@@ -1376,6 +1427,13 @@ static struct ctl_table vm_table[] = {
110112 .proc_handler = proc_dointvec_minmax,
110113 .extra1 = &zero,
110114 },
110115+ {
110116+ .procname = "heap_stack_gap",
110117+ .data = &sysctl_heap_stack_gap,
110118+ .maxlen = sizeof(sysctl_heap_stack_gap),
110119+ .mode = 0644,
110120+ .proc_handler = proc_doulongvec_minmax,
110121+ },
110122 #else
110123 {
110124 .procname = "nr_trim_pages",
110125@@ -1852,6 +1910,16 @@ int proc_dostring(struct ctl_table *table, int write,
110126 (char __user *)buffer, lenp, ppos);
110127 }
110128
110129+int proc_dostring_modpriv(struct ctl_table *table, int write,
110130+ void __user *buffer, size_t *lenp, loff_t *ppos)
110131+{
110132+ if (write && !capable(CAP_SYS_MODULE))
110133+ return -EPERM;
110134+
110135+ return _proc_do_string(table->data, table->maxlen, write,
110136+ buffer, lenp, ppos);
110137+}
110138+
110139 static size_t proc_skip_spaces(char **buf)
110140 {
110141 size_t ret;
110142@@ -1957,6 +2025,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
110143 len = strlen(tmp);
110144 if (len > *size)
110145 len = *size;
110146+ if (len > sizeof(tmp))
110147+ len = sizeof(tmp);
110148 if (copy_to_user(*buf, tmp, len))
110149 return -EFAULT;
110150 *size -= len;
110151@@ -1995,7 +2065,7 @@ static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
110152 int val = *valp;
110153 if (val < 0) {
110154 *negp = true;
110155- *lvalp = (unsigned long)-val;
110156+ *lvalp = -(unsigned long)val;
110157 } else {
110158 *negp = false;
110159 *lvalp = (unsigned long)val;
110160@@ -2135,6 +2205,44 @@ int proc_dointvec(struct ctl_table *table, int write,
110161 NULL,NULL);
110162 }
110163
110164+static int do_proc_dointvec_conv_secure(bool *negp, unsigned long *lvalp,
110165+ int *valp,
110166+ int write, void *data)
110167+{
110168+ if (write) {
110169+ if (*negp) {
110170+ if (*lvalp > (unsigned long) INT_MAX + 1)
110171+ return -EINVAL;
110172+ pax_open_kernel();
110173+ *valp = -*lvalp;
110174+ pax_close_kernel();
110175+ } else {
110176+ if (*lvalp > (unsigned long) INT_MAX)
110177+ return -EINVAL;
110178+ pax_open_kernel();
110179+ *valp = *lvalp;
110180+ pax_close_kernel();
110181+ }
110182+ } else {
110183+ int val = *valp;
110184+ if (val < 0) {
110185+ *negp = true;
110186+ *lvalp = -(unsigned long)val;
110187+ } else {
110188+ *negp = false;
110189+ *lvalp = (unsigned long)val;
110190+ }
110191+ }
110192+ return 0;
110193+}
110194+
110195+int proc_dointvec_secure(struct ctl_table *table, int write,
110196+ void __user *buffer, size_t *lenp, loff_t *ppos)
110197+{
110198+ return do_proc_dointvec(table,write,buffer,lenp,ppos,
110199+ do_proc_dointvec_conv_secure,NULL);
110200+}
110201+
110202 /*
110203 * Taint values can only be increased
110204 * This means we can safely use a temporary.
110205@@ -2142,7 +2250,7 @@ int proc_dointvec(struct ctl_table *table, int write,
110206 static int proc_taint(struct ctl_table *table, int write,
110207 void __user *buffer, size_t *lenp, loff_t *ppos)
110208 {
110209- struct ctl_table t;
110210+ ctl_table_no_const t;
110211 unsigned long tmptaint = get_taint();
110212 int err;
110213
110214@@ -2170,16 +2278,14 @@ static int proc_taint(struct ctl_table *table, int write,
110215 return err;
110216 }
110217
110218-#ifdef CONFIG_PRINTK
110219-static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
110220+static int proc_dointvec_minmax_secure_sysadmin(struct ctl_table *table, int write,
110221 void __user *buffer, size_t *lenp, loff_t *ppos)
110222 {
110223 if (write && !capable(CAP_SYS_ADMIN))
110224 return -EPERM;
110225
110226- return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
110227+ return proc_dointvec_minmax_secure(table, write, buffer, lenp, ppos);
110228 }
110229-#endif
110230
110231 struct do_proc_dointvec_minmax_conv_param {
110232 int *min;
110233@@ -2201,7 +2307,33 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
110234 int val = *valp;
110235 if (val < 0) {
110236 *negp = true;
110237- *lvalp = (unsigned long)-val;
110238+ *lvalp = -(unsigned long)val;
110239+ } else {
110240+ *negp = false;
110241+ *lvalp = (unsigned long)val;
110242+ }
110243+ }
110244+ return 0;
110245+}
110246+
110247+static int do_proc_dointvec_minmax_conv_secure(bool *negp, unsigned long *lvalp,
110248+ int *valp,
110249+ int write, void *data)
110250+{
110251+ struct do_proc_dointvec_minmax_conv_param *param = data;
110252+ if (write) {
110253+ int val = *negp ? -*lvalp : *lvalp;
110254+ if ((param->min && *param->min > val) ||
110255+ (param->max && *param->max < val))
110256+ return -EINVAL;
110257+ pax_open_kernel();
110258+ *valp = val;
110259+ pax_close_kernel();
110260+ } else {
110261+ int val = *valp;
110262+ if (val < 0) {
110263+ *negp = true;
110264+ *lvalp = -(unsigned long)val;
110265 } else {
110266 *negp = false;
110267 *lvalp = (unsigned long)val;
110268@@ -2237,6 +2369,17 @@ int proc_dointvec_minmax(struct ctl_table *table, int write,
110269 do_proc_dointvec_minmax_conv, &param);
110270 }
110271
110272+int proc_dointvec_minmax_secure(struct ctl_table *table, int write,
110273+ void __user *buffer, size_t *lenp, loff_t *ppos)
110274+{
110275+ struct do_proc_dointvec_minmax_conv_param param = {
110276+ .min = (int *) table->extra1,
110277+ .max = (int *) table->extra2,
110278+ };
110279+ return do_proc_dointvec(table, write, buffer, lenp, ppos,
110280+ do_proc_dointvec_minmax_conv_secure, &param);
110281+}
110282+
110283 static void validate_coredump_safety(void)
110284 {
110285 #ifdef CONFIG_COREDUMP
110286@@ -2436,7 +2579,7 @@ static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
110287 unsigned long lval;
110288 if (val < 0) {
110289 *negp = true;
110290- lval = (unsigned long)-val;
110291+ lval = -(unsigned long)val;
110292 } else {
110293 *negp = false;
110294 lval = (unsigned long)val;
110295@@ -2459,7 +2602,7 @@ static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp
110296 unsigned long lval;
110297 if (val < 0) {
110298 *negp = true;
110299- lval = (unsigned long)-val;
110300+ lval = -(unsigned long)val;
110301 } else {
110302 *negp = false;
110303 lval = (unsigned long)val;
110304@@ -2484,7 +2627,7 @@ static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
110305 unsigned long lval;
110306 if (val < 0) {
110307 *negp = true;
110308- lval = (unsigned long)-val;
110309+ lval = -(unsigned long)val;
110310 } else {
110311 *negp = false;
110312 lval = (unsigned long)val;
110313@@ -2739,6 +2882,12 @@ int proc_dostring(struct ctl_table *table, int write,
110314 return -ENOSYS;
110315 }
110316
110317+int proc_dostring_modpriv(struct ctl_table *table, int write,
110318+ void __user *buffer, size_t *lenp, loff_t *ppos)
110319+{
110320+ return -ENOSYS;
110321+}
110322+
110323 int proc_dointvec(struct ctl_table *table, int write,
110324 void __user *buffer, size_t *lenp, loff_t *ppos)
110325 {
110326@@ -2795,5 +2944,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
110327 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
110328 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
110329 EXPORT_SYMBOL(proc_dostring);
110330+EXPORT_SYMBOL(proc_dostring_modpriv);
110331 EXPORT_SYMBOL(proc_doulongvec_minmax);
110332 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
110333diff --git a/kernel/taskstats.c b/kernel/taskstats.c
110334index 21f82c2..c1984e5 100644
110335--- a/kernel/taskstats.c
110336+++ b/kernel/taskstats.c
110337@@ -28,9 +28,12 @@
110338 #include <linux/fs.h>
110339 #include <linux/file.h>
110340 #include <linux/pid_namespace.h>
110341+#include <linux/grsecurity.h>
110342 #include <net/genetlink.h>
110343 #include <linux/atomic.h>
110344
110345+extern int gr_is_taskstats_denied(int pid);
110346+
110347 /*
110348 * Maximum length of a cpumask that can be specified in
110349 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
110350@@ -567,6 +570,9 @@ err:
110351
110352 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
110353 {
110354+ if (gr_is_taskstats_denied(current->pid))
110355+ return -EACCES;
110356+
110357 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
110358 return cmd_attr_register_cpumask(info);
110359 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
110360diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
110361index 7fbba635..7cc64ae 100644
110362--- a/kernel/time/alarmtimer.c
110363+++ b/kernel/time/alarmtimer.c
110364@@ -820,7 +820,7 @@ static int __init alarmtimer_init(void)
110365 struct platform_device *pdev;
110366 int error = 0;
110367 int i;
110368- struct k_clock alarm_clock = {
110369+ static struct k_clock alarm_clock = {
110370 .clock_getres = alarm_clock_getres,
110371 .clock_get = alarm_clock_get,
110372 .timer_create = alarm_timer_create,
110373diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
110374index 892e3da..cb71aa5 100644
110375--- a/kernel/time/posix-cpu-timers.c
110376+++ b/kernel/time/posix-cpu-timers.c
110377@@ -1470,14 +1470,14 @@ struct k_clock clock_posix_cpu = {
110378
110379 static __init int init_posix_cpu_timers(void)
110380 {
110381- struct k_clock process = {
110382+ static struct k_clock process = {
110383 .clock_getres = process_cpu_clock_getres,
110384 .clock_get = process_cpu_clock_get,
110385 .timer_create = process_cpu_timer_create,
110386 .nsleep = process_cpu_nsleep,
110387 .nsleep_restart = process_cpu_nsleep_restart,
110388 };
110389- struct k_clock thread = {
110390+ static struct k_clock thread = {
110391 .clock_getres = thread_cpu_clock_getres,
110392 .clock_get = thread_cpu_clock_get,
110393 .timer_create = thread_cpu_timer_create,
110394diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
110395index 31d11ac..5a3bb13 100644
110396--- a/kernel/time/posix-timers.c
110397+++ b/kernel/time/posix-timers.c
110398@@ -43,6 +43,7 @@
110399 #include <linux/hash.h>
110400 #include <linux/posix-clock.h>
110401 #include <linux/posix-timers.h>
110402+#include <linux/grsecurity.h>
110403 #include <linux/syscalls.h>
110404 #include <linux/wait.h>
110405 #include <linux/workqueue.h>
110406@@ -124,7 +125,7 @@ static DEFINE_SPINLOCK(hash_lock);
110407 * which we beg off on and pass to do_sys_settimeofday().
110408 */
110409
110410-static struct k_clock posix_clocks[MAX_CLOCKS];
110411+static struct k_clock *posix_clocks[MAX_CLOCKS];
110412
110413 /*
110414 * These ones are defined below.
110415@@ -284,7 +285,7 @@ static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec *tp)
110416 */
110417 static __init int init_posix_timers(void)
110418 {
110419- struct k_clock clock_realtime = {
110420+ static struct k_clock clock_realtime = {
110421 .clock_getres = posix_get_hrtimer_res,
110422 .clock_get = posix_clock_realtime_get,
110423 .clock_set = posix_clock_realtime_set,
110424@@ -296,7 +297,7 @@ static __init int init_posix_timers(void)
110425 .timer_get = common_timer_get,
110426 .timer_del = common_timer_del,
110427 };
110428- struct k_clock clock_monotonic = {
110429+ static struct k_clock clock_monotonic = {
110430 .clock_getres = posix_get_hrtimer_res,
110431 .clock_get = posix_ktime_get_ts,
110432 .nsleep = common_nsleep,
110433@@ -306,19 +307,19 @@ static __init int init_posix_timers(void)
110434 .timer_get = common_timer_get,
110435 .timer_del = common_timer_del,
110436 };
110437- struct k_clock clock_monotonic_raw = {
110438+ static struct k_clock clock_monotonic_raw = {
110439 .clock_getres = posix_get_hrtimer_res,
110440 .clock_get = posix_get_monotonic_raw,
110441 };
110442- struct k_clock clock_realtime_coarse = {
110443+ static struct k_clock clock_realtime_coarse = {
110444 .clock_getres = posix_get_coarse_res,
110445 .clock_get = posix_get_realtime_coarse,
110446 };
110447- struct k_clock clock_monotonic_coarse = {
110448+ static struct k_clock clock_monotonic_coarse = {
110449 .clock_getres = posix_get_coarse_res,
110450 .clock_get = posix_get_monotonic_coarse,
110451 };
110452- struct k_clock clock_tai = {
110453+ static struct k_clock clock_tai = {
110454 .clock_getres = posix_get_hrtimer_res,
110455 .clock_get = posix_get_tai,
110456 .nsleep = common_nsleep,
110457@@ -328,7 +329,7 @@ static __init int init_posix_timers(void)
110458 .timer_get = common_timer_get,
110459 .timer_del = common_timer_del,
110460 };
110461- struct k_clock clock_boottime = {
110462+ static struct k_clock clock_boottime = {
110463 .clock_getres = posix_get_hrtimer_res,
110464 .clock_get = posix_get_boottime,
110465 .nsleep = common_nsleep,
110466@@ -540,7 +541,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
110467 return;
110468 }
110469
110470- posix_clocks[clock_id] = *new_clock;
110471+ posix_clocks[clock_id] = new_clock;
110472 }
110473 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
110474
110475@@ -586,9 +587,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
110476 return (id & CLOCKFD_MASK) == CLOCKFD ?
110477 &clock_posix_dynamic : &clock_posix_cpu;
110478
110479- if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
110480+ if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
110481 return NULL;
110482- return &posix_clocks[id];
110483+ return posix_clocks[id];
110484 }
110485
110486 static int common_timer_create(struct k_itimer *new_timer)
110487@@ -606,7 +607,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
110488 struct k_clock *kc = clockid_to_kclock(which_clock);
110489 struct k_itimer *new_timer;
110490 int error, new_timer_id;
110491- sigevent_t event;
110492+ sigevent_t event = { };
110493 int it_id_set = IT_ID_NOT_SET;
110494
110495 if (!kc)
110496@@ -1021,6 +1022,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
110497 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
110498 return -EFAULT;
110499
110500+ /* only the CLOCK_REALTIME clock can be set, all other clocks
110501+ have their clock_set fptr set to a nosettime dummy function
110502+ CLOCK_REALTIME has a NULL clock_set fptr which causes it to
110503+ call common_clock_set, which calls do_sys_settimeofday, which
110504+ we hook
110505+ */
110506+
110507 return kc->clock_set(which_clock, &new_tp);
110508 }
110509
110510diff --git a/kernel/time/time.c b/kernel/time/time.c
110511index 85d5bb1..aeca463 100644
110512--- a/kernel/time/time.c
110513+++ b/kernel/time/time.c
110514@@ -177,6 +177,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
110515 if (tz->tz_minuteswest > 15*60 || tz->tz_minuteswest < -15*60)
110516 return -EINVAL;
110517
110518+ /* we log in do_settimeofday called below, so don't log twice
110519+ */
110520+ if (!tv)
110521+ gr_log_timechange();
110522+
110523 sys_tz = *tz;
110524 update_vsyscall_tz();
110525 if (firsttime) {
110526diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
110527index 3688f1e..3dfea48 100644
110528--- a/kernel/time/timekeeping.c
110529+++ b/kernel/time/timekeeping.c
110530@@ -15,6 +15,7 @@
110531 #include <linux/init.h>
110532 #include <linux/mm.h>
110533 #include <linux/sched.h>
110534+#include <linux/grsecurity.h>
110535 #include <linux/syscore_ops.h>
110536 #include <linux/clocksource.h>
110537 #include <linux/jiffies.h>
110538@@ -915,6 +916,8 @@ int do_settimeofday64(const struct timespec64 *ts)
110539 if (!timespec64_valid_strict(ts))
110540 return -EINVAL;
110541
110542+ gr_log_timechange();
110543+
110544 raw_spin_lock_irqsave(&timekeeper_lock, flags);
110545 write_seqcount_begin(&tk_core.seq);
110546
110547diff --git a/kernel/time/timer.c b/kernel/time/timer.c
110548index 84190f0..6f4ccad 100644
110549--- a/kernel/time/timer.c
110550+++ b/kernel/time/timer.c
110551@@ -1406,7 +1406,7 @@ void update_process_times(int user_tick)
110552 /*
110553 * This function runs timers and the timer-tq in bottom half context.
110554 */
110555-static void run_timer_softirq(struct softirq_action *h)
110556+static __latent_entropy void run_timer_softirq(void)
110557 {
110558 struct tvec_base *base = this_cpu_ptr(&tvec_bases);
110559
110560diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
110561index a4536e1..5d8774c 100644
110562--- a/kernel/time/timer_list.c
110563+++ b/kernel/time/timer_list.c
110564@@ -50,12 +50,16 @@ static void SEQ_printf(struct seq_file *m, const char *fmt, ...)
110565
110566 static void print_name_offset(struct seq_file *m, void *sym)
110567 {
110568+#ifdef CONFIG_GRKERNSEC_HIDESYM
110569+ SEQ_printf(m, "<%p>", NULL);
110570+#else
110571 char symname[KSYM_NAME_LEN];
110572
110573 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
110574 SEQ_printf(m, "<%pK>", sym);
110575 else
110576 SEQ_printf(m, "%s", symname);
110577+#endif
110578 }
110579
110580 static void
110581@@ -124,11 +128,14 @@ next_one:
110582 static void
110583 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
110584 {
110585+#ifdef CONFIG_GRKERNSEC_HIDESYM
110586+ SEQ_printf(m, " .base: %p\n", NULL);
110587+#else
110588 SEQ_printf(m, " .base: %pK\n", base);
110589+#endif
110590 SEQ_printf(m, " .index: %d\n", base->index);
110591
110592 SEQ_printf(m, " .resolution: %u nsecs\n", (unsigned) hrtimer_resolution);
110593-
110594 SEQ_printf(m, " .get_time: ");
110595 print_name_offset(m, base->get_time);
110596 SEQ_printf(m, "\n");
110597@@ -399,7 +406,11 @@ static int __init init_timer_list_procfs(void)
110598 {
110599 struct proc_dir_entry *pe;
110600
110601+#ifdef CONFIG_GRKERNSEC_PROC_ADD
110602+ pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
110603+#else
110604 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
110605+#endif
110606 if (!pe)
110607 return -ENOMEM;
110608 return 0;
110609diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
110610index 1adecb4..b4fb631 100644
110611--- a/kernel/time/timer_stats.c
110612+++ b/kernel/time/timer_stats.c
110613@@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
110614 static unsigned long nr_entries;
110615 static struct entry entries[MAX_ENTRIES];
110616
110617-static atomic_t overflow_count;
110618+static atomic_unchecked_t overflow_count;
110619
110620 /*
110621 * The entries are in a hash-table, for fast lookup:
110622@@ -140,7 +140,7 @@ static void reset_entries(void)
110623 nr_entries = 0;
110624 memset(entries, 0, sizeof(entries));
110625 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
110626- atomic_set(&overflow_count, 0);
110627+ atomic_set_unchecked(&overflow_count, 0);
110628 }
110629
110630 static struct entry *alloc_entry(void)
110631@@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
110632 if (likely(entry))
110633 entry->count++;
110634 else
110635- atomic_inc(&overflow_count);
110636+ atomic_inc_unchecked(&overflow_count);
110637
110638 out_unlock:
110639 raw_spin_unlock_irqrestore(lock, flags);
110640@@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
110641
110642 static void print_name_offset(struct seq_file *m, unsigned long addr)
110643 {
110644+#ifdef CONFIG_GRKERNSEC_HIDESYM
110645+ seq_printf(m, "<%p>", NULL);
110646+#else
110647 char symname[KSYM_NAME_LEN];
110648
110649 if (lookup_symbol_name(addr, symname) < 0)
110650- seq_printf(m, "<%p>", (void *)addr);
110651+ seq_printf(m, "<%pK>", (void *)addr);
110652 else
110653 seq_printf(m, "%s", symname);
110654+#endif
110655 }
110656
110657 static int tstats_show(struct seq_file *m, void *v)
110658@@ -300,8 +304,8 @@ static int tstats_show(struct seq_file *m, void *v)
110659
110660 seq_puts(m, "Timer Stats Version: v0.3\n");
110661 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
110662- if (atomic_read(&overflow_count))
110663- seq_printf(m, "Overflow: %d entries\n", atomic_read(&overflow_count));
110664+ if (atomic_read_unchecked(&overflow_count))
110665+ seq_printf(m, "Overflow: %d entries\n", atomic_read_unchecked(&overflow_count));
110666 seq_printf(m, "Collection: %s\n", timer_stats_active ? "active" : "inactive");
110667
110668 for (i = 0; i < nr_entries; i++) {
110669@@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
110670 {
110671 struct proc_dir_entry *pe;
110672
110673+#ifdef CONFIG_GRKERNSEC_PROC_ADD
110674+ pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
110675+#else
110676 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
110677+#endif
110678 if (!pe)
110679 return -ENOMEM;
110680 return 0;
110681diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
110682index 3b9a48a..6125816 100644
110683--- a/kernel/trace/Kconfig
110684+++ b/kernel/trace/Kconfig
110685@@ -120,6 +120,7 @@ config TRACING_SUPPORT
110686 # irqflags tracing for your architecture.
110687 depends on TRACE_IRQFLAGS_SUPPORT || PPC32
110688 depends on STACKTRACE_SUPPORT
110689+ depends on !GRKERNSEC_KMEM
110690 default y
110691
110692 if TRACING_SUPPORT
110693@@ -378,6 +379,7 @@ config BLK_DEV_IO_TRACE
110694 depends on BLOCK
110695 select RELAY
110696 select DEBUG_FS
110697+ depends on !GRKERNSEC_KMEM
110698 select TRACEPOINTS
110699 select GENERIC_TRACER
110700 select STACKTRACE
110701diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
110702index b3e6b39..719099b 100644
110703--- a/kernel/trace/blktrace.c
110704+++ b/kernel/trace/blktrace.c
110705@@ -328,7 +328,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
110706 struct blk_trace *bt = filp->private_data;
110707 char buf[16];
110708
110709- snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
110710+ snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
110711
110712 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
110713 }
110714@@ -386,7 +386,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
110715 return 1;
110716
110717 bt = buf->chan->private_data;
110718- atomic_inc(&bt->dropped);
110719+ atomic_inc_unchecked(&bt->dropped);
110720 return 0;
110721 }
110722
110723@@ -485,7 +485,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
110724
110725 bt->dir = dir;
110726 bt->dev = dev;
110727- atomic_set(&bt->dropped, 0);
110728+ atomic_set_unchecked(&bt->dropped, 0);
110729 INIT_LIST_HEAD(&bt->running_list);
110730
110731 ret = -EIO;
110732diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
110733index eb11011..43adc29 100644
110734--- a/kernel/trace/ftrace.c
110735+++ b/kernel/trace/ftrace.c
110736@@ -2413,12 +2413,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
110737 if (unlikely(ftrace_disabled))
110738 return 0;
110739
110740+ ret = ftrace_arch_code_modify_prepare();
110741+ FTRACE_WARN_ON(ret);
110742+ if (ret)
110743+ return 0;
110744+
110745 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
110746+ FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
110747 if (ret) {
110748 ftrace_bug(ret, rec);
110749- return 0;
110750 }
110751- return 1;
110752+ return ret ? 0 : 1;
110753 }
110754
110755 /*
110756@@ -4807,8 +4812,10 @@ static int ftrace_process_locs(struct module *mod,
110757 if (!count)
110758 return 0;
110759
110760+ pax_open_kernel();
110761 sort(start, count, sizeof(*start),
110762 ftrace_cmp_ips, ftrace_swap_ips);
110763+ pax_close_kernel();
110764
110765 start_pg = ftrace_allocate_pages(count);
110766 if (!start_pg)
110767@@ -5675,7 +5682,7 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list)
110768
110769 if (t->ret_stack == NULL) {
110770 atomic_set(&t->tracing_graph_pause, 0);
110771- atomic_set(&t->trace_overrun, 0);
110772+ atomic_set_unchecked(&t->trace_overrun, 0);
110773 t->curr_ret_stack = -1;
110774 /* Make sure the tasks see the -1 first: */
110775 smp_wmb();
110776@@ -5898,7 +5905,7 @@ static void
110777 graph_init_task(struct task_struct *t, struct ftrace_ret_stack *ret_stack)
110778 {
110779 atomic_set(&t->tracing_graph_pause, 0);
110780- atomic_set(&t->trace_overrun, 0);
110781+ atomic_set_unchecked(&t->trace_overrun, 0);
110782 t->ftrace_timestamp = 0;
110783 /* make curr_ret_stack visible before we add the ret_stack */
110784 smp_wmb();
110785diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
110786index 6260717..b9bd83c 100644
110787--- a/kernel/trace/ring_buffer.c
110788+++ b/kernel/trace/ring_buffer.c
110789@@ -296,9 +296,9 @@ struct buffer_data_page {
110790 */
110791 struct buffer_page {
110792 struct list_head list; /* list of buffer pages */
110793- local_t write; /* index for next write */
110794+ local_unchecked_t write; /* index for next write */
110795 unsigned read; /* index for next read */
110796- local_t entries; /* entries on this page */
110797+ local_unchecked_t entries; /* entries on this page */
110798 unsigned long real_end; /* real end of data */
110799 struct buffer_data_page *page; /* Actual data page */
110800 };
110801@@ -437,11 +437,11 @@ struct ring_buffer_per_cpu {
110802 unsigned long last_overrun;
110803 local_t entries_bytes;
110804 local_t entries;
110805- local_t overrun;
110806- local_t commit_overrun;
110807- local_t dropped_events;
110808+ local_unchecked_t overrun;
110809+ local_unchecked_t commit_overrun;
110810+ local_unchecked_t dropped_events;
110811 local_t committing;
110812- local_t commits;
110813+ local_unchecked_t commits;
110814 unsigned long read;
110815 unsigned long read_bytes;
110816 u64 write_stamp;
110817@@ -1011,8 +1011,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
110818 *
110819 * We add a counter to the write field to denote this.
110820 */
110821- old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
110822- old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
110823+ old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
110824+ old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
110825
110826 /*
110827 * Just make sure we have seen our old_write and synchronize
110828@@ -1040,8 +1040,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
110829 * cmpxchg to only update if an interrupt did not already
110830 * do it for us. If the cmpxchg fails, we don't care.
110831 */
110832- (void)local_cmpxchg(&next_page->write, old_write, val);
110833- (void)local_cmpxchg(&next_page->entries, old_entries, eval);
110834+ (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
110835+ (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
110836
110837 /*
110838 * No need to worry about races with clearing out the commit.
110839@@ -1409,12 +1409,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
110840
110841 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
110842 {
110843- return local_read(&bpage->entries) & RB_WRITE_MASK;
110844+ return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
110845 }
110846
110847 static inline unsigned long rb_page_write(struct buffer_page *bpage)
110848 {
110849- return local_read(&bpage->write) & RB_WRITE_MASK;
110850+ return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
110851 }
110852
110853 static int
110854@@ -1509,7 +1509,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
110855 * bytes consumed in ring buffer from here.
110856 * Increment overrun to account for the lost events.
110857 */
110858- local_add(page_entries, &cpu_buffer->overrun);
110859+ local_add_unchecked(page_entries, &cpu_buffer->overrun);
110860 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
110861 }
110862
110863@@ -2071,7 +2071,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
110864 * it is our responsibility to update
110865 * the counters.
110866 */
110867- local_add(entries, &cpu_buffer->overrun);
110868+ local_add_unchecked(entries, &cpu_buffer->overrun);
110869 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
110870
110871 /*
110872@@ -2221,7 +2221,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
110873 if (tail == BUF_PAGE_SIZE)
110874 tail_page->real_end = 0;
110875
110876- local_sub(length, &tail_page->write);
110877+ local_sub_unchecked(length, &tail_page->write);
110878 return;
110879 }
110880
110881@@ -2256,7 +2256,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
110882 rb_event_set_padding(event);
110883
110884 /* Set the write back to the previous setting */
110885- local_sub(length, &tail_page->write);
110886+ local_sub_unchecked(length, &tail_page->write);
110887 return;
110888 }
110889
110890@@ -2268,7 +2268,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
110891
110892 /* Set write to end of buffer */
110893 length = (tail + length) - BUF_PAGE_SIZE;
110894- local_sub(length, &tail_page->write);
110895+ local_sub_unchecked(length, &tail_page->write);
110896 }
110897
110898 /*
110899@@ -2294,7 +2294,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
110900 * about it.
110901 */
110902 if (unlikely(next_page == commit_page)) {
110903- local_inc(&cpu_buffer->commit_overrun);
110904+ local_inc_unchecked(&cpu_buffer->commit_overrun);
110905 goto out_reset;
110906 }
110907
110908@@ -2324,7 +2324,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
110909 * this is easy, just stop here.
110910 */
110911 if (!(buffer->flags & RB_FL_OVERWRITE)) {
110912- local_inc(&cpu_buffer->dropped_events);
110913+ local_inc_unchecked(&cpu_buffer->dropped_events);
110914 goto out_reset;
110915 }
110916
110917@@ -2350,7 +2350,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
110918 cpu_buffer->tail_page) &&
110919 (cpu_buffer->commit_page ==
110920 cpu_buffer->reader_page))) {
110921- local_inc(&cpu_buffer->commit_overrun);
110922+ local_inc_unchecked(&cpu_buffer->commit_overrun);
110923 goto out_reset;
110924 }
110925 }
110926@@ -2398,7 +2398,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
110927 length += RB_LEN_TIME_EXTEND;
110928
110929 tail_page = cpu_buffer->tail_page;
110930- write = local_add_return(length, &tail_page->write);
110931+ write = local_add_return_unchecked(length, &tail_page->write);
110932
110933 /* set write to only the index of the write */
110934 write &= RB_WRITE_MASK;
110935@@ -2422,7 +2422,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
110936 kmemcheck_annotate_bitfield(event, bitfield);
110937 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
110938
110939- local_inc(&tail_page->entries);
110940+ local_inc_unchecked(&tail_page->entries);
110941
110942 /*
110943 * If this is the first commit on the page, then update
110944@@ -2455,7 +2455,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
110945
110946 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
110947 unsigned long write_mask =
110948- local_read(&bpage->write) & ~RB_WRITE_MASK;
110949+ local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
110950 unsigned long event_length = rb_event_length(event);
110951 /*
110952 * This is on the tail page. It is possible that
110953@@ -2465,7 +2465,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
110954 */
110955 old_index += write_mask;
110956 new_index += write_mask;
110957- index = local_cmpxchg(&bpage->write, old_index, new_index);
110958+ index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
110959 if (index == old_index) {
110960 /* update counters */
110961 local_sub(event_length, &cpu_buffer->entries_bytes);
110962@@ -2480,7 +2480,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
110963 static void rb_start_commit(struct ring_buffer_per_cpu *cpu_buffer)
110964 {
110965 local_inc(&cpu_buffer->committing);
110966- local_inc(&cpu_buffer->commits);
110967+ local_inc_unchecked(&cpu_buffer->commits);
110968 }
110969
110970 static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
110971@@ -2492,7 +2492,7 @@ static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
110972 return;
110973
110974 again:
110975- commits = local_read(&cpu_buffer->commits);
110976+ commits = local_read_unchecked(&cpu_buffer->commits);
110977 /* synchronize with interrupts */
110978 barrier();
110979 if (local_read(&cpu_buffer->committing) == 1)
110980@@ -2508,7 +2508,7 @@ static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
110981 * updating of the commit page and the clearing of the
110982 * committing counter.
110983 */
110984- if (unlikely(local_read(&cpu_buffer->commits) != commits) &&
110985+ if (unlikely(local_read_unchecked(&cpu_buffer->commits) != commits) &&
110986 !local_read(&cpu_buffer->committing)) {
110987 local_inc(&cpu_buffer->committing);
110988 goto again;
110989@@ -2538,7 +2538,7 @@ rb_reserve_next_event(struct ring_buffer *buffer,
110990 barrier();
110991 if (unlikely(ACCESS_ONCE(cpu_buffer->buffer) != buffer)) {
110992 local_dec(&cpu_buffer->committing);
110993- local_dec(&cpu_buffer->commits);
110994+ local_dec_unchecked(&cpu_buffer->commits);
110995 return NULL;
110996 }
110997 #endif
110998@@ -2852,7 +2852,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
110999
111000 /* Do the likely case first */
111001 if (likely(bpage->page == (void *)addr)) {
111002- local_dec(&bpage->entries);
111003+ local_dec_unchecked(&bpage->entries);
111004 return;
111005 }
111006
111007@@ -2864,7 +2864,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
111008 start = bpage;
111009 do {
111010 if (bpage->page == (void *)addr) {
111011- local_dec(&bpage->entries);
111012+ local_dec_unchecked(&bpage->entries);
111013 return;
111014 }
111015 rb_inc_page(cpu_buffer, &bpage);
111016@@ -3152,7 +3152,7 @@ static inline unsigned long
111017 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
111018 {
111019 return local_read(&cpu_buffer->entries) -
111020- (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
111021+ (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
111022 }
111023
111024 /**
111025@@ -3241,7 +3241,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
111026 return 0;
111027
111028 cpu_buffer = buffer->buffers[cpu];
111029- ret = local_read(&cpu_buffer->overrun);
111030+ ret = local_read_unchecked(&cpu_buffer->overrun);
111031
111032 return ret;
111033 }
111034@@ -3264,7 +3264,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
111035 return 0;
111036
111037 cpu_buffer = buffer->buffers[cpu];
111038- ret = local_read(&cpu_buffer->commit_overrun);
111039+ ret = local_read_unchecked(&cpu_buffer->commit_overrun);
111040
111041 return ret;
111042 }
111043@@ -3286,7 +3286,7 @@ ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu)
111044 return 0;
111045
111046 cpu_buffer = buffer->buffers[cpu];
111047- ret = local_read(&cpu_buffer->dropped_events);
111048+ ret = local_read_unchecked(&cpu_buffer->dropped_events);
111049
111050 return ret;
111051 }
111052@@ -3349,7 +3349,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
111053 /* if you care about this being correct, lock the buffer */
111054 for_each_buffer_cpu(buffer, cpu) {
111055 cpu_buffer = buffer->buffers[cpu];
111056- overruns += local_read(&cpu_buffer->overrun);
111057+ overruns += local_read_unchecked(&cpu_buffer->overrun);
111058 }
111059
111060 return overruns;
111061@@ -3520,8 +3520,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
111062 /*
111063 * Reset the reader page to size zero.
111064 */
111065- local_set(&cpu_buffer->reader_page->write, 0);
111066- local_set(&cpu_buffer->reader_page->entries, 0);
111067+ local_set_unchecked(&cpu_buffer->reader_page->write, 0);
111068+ local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
111069 local_set(&cpu_buffer->reader_page->page->commit, 0);
111070 cpu_buffer->reader_page->real_end = 0;
111071
111072@@ -3555,7 +3555,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
111073 * want to compare with the last_overrun.
111074 */
111075 smp_mb();
111076- overwrite = local_read(&(cpu_buffer->overrun));
111077+ overwrite = local_read_unchecked(&(cpu_buffer->overrun));
111078
111079 /*
111080 * Here's the tricky part.
111081@@ -4137,8 +4137,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
111082
111083 cpu_buffer->head_page
111084 = list_entry(cpu_buffer->pages, struct buffer_page, list);
111085- local_set(&cpu_buffer->head_page->write, 0);
111086- local_set(&cpu_buffer->head_page->entries, 0);
111087+ local_set_unchecked(&cpu_buffer->head_page->write, 0);
111088+ local_set_unchecked(&cpu_buffer->head_page->entries, 0);
111089 local_set(&cpu_buffer->head_page->page->commit, 0);
111090
111091 cpu_buffer->head_page->read = 0;
111092@@ -4148,18 +4148,18 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
111093
111094 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
111095 INIT_LIST_HEAD(&cpu_buffer->new_pages);
111096- local_set(&cpu_buffer->reader_page->write, 0);
111097- local_set(&cpu_buffer->reader_page->entries, 0);
111098+ local_set_unchecked(&cpu_buffer->reader_page->write, 0);
111099+ local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
111100 local_set(&cpu_buffer->reader_page->page->commit, 0);
111101 cpu_buffer->reader_page->read = 0;
111102
111103 local_set(&cpu_buffer->entries_bytes, 0);
111104- local_set(&cpu_buffer->overrun, 0);
111105- local_set(&cpu_buffer->commit_overrun, 0);
111106- local_set(&cpu_buffer->dropped_events, 0);
111107+ local_set_unchecked(&cpu_buffer->overrun, 0);
111108+ local_set_unchecked(&cpu_buffer->commit_overrun, 0);
111109+ local_set_unchecked(&cpu_buffer->dropped_events, 0);
111110 local_set(&cpu_buffer->entries, 0);
111111 local_set(&cpu_buffer->committing, 0);
111112- local_set(&cpu_buffer->commits, 0);
111113+ local_set_unchecked(&cpu_buffer->commits, 0);
111114 cpu_buffer->read = 0;
111115 cpu_buffer->read_bytes = 0;
111116
111117@@ -4549,8 +4549,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
111118 rb_init_page(bpage);
111119 bpage = reader->page;
111120 reader->page = *data_page;
111121- local_set(&reader->write, 0);
111122- local_set(&reader->entries, 0);
111123+ local_set_unchecked(&reader->write, 0);
111124+ local_set_unchecked(&reader->entries, 0);
111125 reader->read = 0;
111126 *data_page = bpage;
111127
111128diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
111129index abcbf7f..ef8b6fe 100644
111130--- a/kernel/trace/trace.c
111131+++ b/kernel/trace/trace.c
111132@@ -3539,7 +3539,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
111133 return 0;
111134 }
111135
111136-int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
111137+int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
111138 {
111139 /* do nothing if flag is already set */
111140 if (!!(trace_flags & mask) == !!enabled)
111141diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
111142index 74bde81..f9abfd4 100644
111143--- a/kernel/trace/trace.h
111144+++ b/kernel/trace/trace.h
111145@@ -1272,7 +1272,7 @@ extern const char *__stop___tracepoint_str[];
111146 void trace_printk_init_buffers(void);
111147 void trace_printk_start_comm(void);
111148 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
111149-int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
111150+int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
111151
111152 /*
111153 * Normal trace_printk() and friends allocates special buffers
111154diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
111155index 0f06532..247c8e7 100644
111156--- a/kernel/trace/trace_clock.c
111157+++ b/kernel/trace/trace_clock.c
111158@@ -127,7 +127,7 @@ u64 notrace trace_clock_global(void)
111159 }
111160 EXPORT_SYMBOL_GPL(trace_clock_global);
111161
111162-static atomic64_t trace_counter;
111163+static atomic64_unchecked_t trace_counter;
111164
111165 /*
111166 * trace_clock_counter(): simply an atomic counter.
111167@@ -136,5 +136,5 @@ static atomic64_t trace_counter;
111168 */
111169 u64 notrace trace_clock_counter(void)
111170 {
111171- return atomic64_add_return(1, &trace_counter);
111172+ return atomic64_inc_return_unchecked(&trace_counter);
111173 }
111174diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
111175index 404a372..d9e5547 100644
111176--- a/kernel/trace/trace_events.c
111177+++ b/kernel/trace/trace_events.c
111178@@ -1887,7 +1887,6 @@ __trace_early_add_new_event(struct trace_event_call *call,
111179 return 0;
111180 }
111181
111182-struct ftrace_module_file_ops;
111183 static void __add_event_to_tracers(struct trace_event_call *call);
111184
111185 /* Add an additional event_call dynamically */
111186diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
111187index 8968bf7..e6623fc 100644
111188--- a/kernel/trace/trace_functions_graph.c
111189+++ b/kernel/trace/trace_functions_graph.c
111190@@ -132,7 +132,7 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
111191
111192 /* The return trace stack is full */
111193 if (current->curr_ret_stack == FTRACE_RETFUNC_DEPTH - 1) {
111194- atomic_inc(&current->trace_overrun);
111195+ atomic_inc_unchecked(&current->trace_overrun);
111196 return -EBUSY;
111197 }
111198
111199@@ -229,7 +229,7 @@ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret,
111200 *ret = current->ret_stack[index].ret;
111201 trace->func = current->ret_stack[index].func;
111202 trace->calltime = current->ret_stack[index].calltime;
111203- trace->overrun = atomic_read(&current->trace_overrun);
111204+ trace->overrun = atomic_read_unchecked(&current->trace_overrun);
111205 trace->depth = index;
111206 }
111207
111208diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
111209index 638e110..99b73b2 100644
111210--- a/kernel/trace/trace_mmiotrace.c
111211+++ b/kernel/trace/trace_mmiotrace.c
111212@@ -24,7 +24,7 @@ struct header_iter {
111213 static struct trace_array *mmio_trace_array;
111214 static bool overrun_detected;
111215 static unsigned long prev_overruns;
111216-static atomic_t dropped_count;
111217+static atomic_unchecked_t dropped_count;
111218
111219 static void mmio_reset_data(struct trace_array *tr)
111220 {
111221@@ -124,7 +124,7 @@ static void mmio_close(struct trace_iterator *iter)
111222
111223 static unsigned long count_overruns(struct trace_iterator *iter)
111224 {
111225- unsigned long cnt = atomic_xchg(&dropped_count, 0);
111226+ unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
111227 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
111228
111229 if (over > prev_overruns)
111230@@ -307,7 +307,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
111231 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
111232 sizeof(*entry), 0, pc);
111233 if (!event) {
111234- atomic_inc(&dropped_count);
111235+ atomic_inc_unchecked(&dropped_count);
111236 return;
111237 }
111238 entry = ring_buffer_event_data(event);
111239@@ -337,7 +337,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
111240 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
111241 sizeof(*entry), 0, pc);
111242 if (!event) {
111243- atomic_inc(&dropped_count);
111244+ atomic_inc_unchecked(&dropped_count);
111245 return;
111246 }
111247 entry = ring_buffer_event_data(event);
111248diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
111249index dfab253..8e9b477 100644
111250--- a/kernel/trace/trace_output.c
111251+++ b/kernel/trace/trace_output.c
111252@@ -752,14 +752,16 @@ int register_trace_event(struct trace_event *event)
111253 goto out;
111254 }
111255
111256+ pax_open_kernel();
111257 if (event->funcs->trace == NULL)
111258- event->funcs->trace = trace_nop_print;
111259+ *(void **)&event->funcs->trace = trace_nop_print;
111260 if (event->funcs->raw == NULL)
111261- event->funcs->raw = trace_nop_print;
111262+ *(void **)&event->funcs->raw = trace_nop_print;
111263 if (event->funcs->hex == NULL)
111264- event->funcs->hex = trace_nop_print;
111265+ *(void **)&event->funcs->hex = trace_nop_print;
111266 if (event->funcs->binary == NULL)
111267- event->funcs->binary = trace_nop_print;
111268+ *(void **)&event->funcs->binary = trace_nop_print;
111269+ pax_close_kernel();
111270
111271 key = event->type & (EVENT_HASHSIZE - 1);
111272
111273diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c
111274index e694c9f..6775a38 100644
111275--- a/kernel/trace/trace_seq.c
111276+++ b/kernel/trace/trace_seq.c
111277@@ -337,7 +337,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
111278 return 0;
111279 }
111280
111281- seq_buf_path(&s->seq, path, "\n");
111282+ seq_buf_path(&s->seq, path, "\n\\");
111283
111284 if (unlikely(seq_buf_has_overflowed(&s->seq))) {
111285 s->seq.len = save_len;
111286diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
111287index 3f34496..0492d95 100644
111288--- a/kernel/trace/trace_stack.c
111289+++ b/kernel/trace/trace_stack.c
111290@@ -88,7 +88,7 @@ check_stack(unsigned long ip, unsigned long *stack)
111291 return;
111292
111293 /* we do not handle interrupt stacks yet */
111294- if (!object_is_on_stack(stack))
111295+ if (!object_starts_on_stack(stack))
111296 return;
111297
111298 local_irq_save(flags);
111299diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
111300index 7d567a4..407a28d 100644
111301--- a/kernel/trace/trace_syscalls.c
111302+++ b/kernel/trace/trace_syscalls.c
111303@@ -590,6 +590,8 @@ static int perf_sysenter_enable(struct trace_event_call *call)
111304 int num;
111305
111306 num = ((struct syscall_metadata *)call->data)->syscall_nr;
111307+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
111308+ return -EINVAL;
111309
111310 mutex_lock(&syscall_trace_lock);
111311 if (!sys_perf_refcount_enter)
111312@@ -610,6 +612,8 @@ static void perf_sysenter_disable(struct trace_event_call *call)
111313 int num;
111314
111315 num = ((struct syscall_metadata *)call->data)->syscall_nr;
111316+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
111317+ return;
111318
111319 mutex_lock(&syscall_trace_lock);
111320 sys_perf_refcount_enter--;
111321@@ -662,6 +666,8 @@ static int perf_sysexit_enable(struct trace_event_call *call)
111322 int num;
111323
111324 num = ((struct syscall_metadata *)call->data)->syscall_nr;
111325+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
111326+ return -EINVAL;
111327
111328 mutex_lock(&syscall_trace_lock);
111329 if (!sys_perf_refcount_exit)
111330@@ -682,6 +688,8 @@ static void perf_sysexit_disable(struct trace_event_call *call)
111331 int num;
111332
111333 num = ((struct syscall_metadata *)call->data)->syscall_nr;
111334+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
111335+ return;
111336
111337 mutex_lock(&syscall_trace_lock);
111338 sys_perf_refcount_exit--;
111339diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
111340index 4109f83..fe1f830 100644
111341--- a/kernel/user_namespace.c
111342+++ b/kernel/user_namespace.c
111343@@ -83,6 +83,21 @@ int create_user_ns(struct cred *new)
111344 !kgid_has_mapping(parent_ns, group))
111345 return -EPERM;
111346
111347+#ifdef CONFIG_GRKERNSEC
111348+ /*
111349+ * This doesn't really inspire confidence:
111350+ * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
111351+ * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
111352+ * Increases kernel attack surface in areas developers
111353+ * previously cared little about ("low importance due
111354+ * to requiring "root" capability")
111355+ * To be removed when this code receives *proper* review
111356+ */
111357+ if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
111358+ !capable(CAP_SETGID))
111359+ return -EPERM;
111360+#endif
111361+
111362 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
111363 if (!ns)
111364 return -ENOMEM;
111365@@ -980,7 +995,7 @@ static int userns_install(struct nsproxy *nsproxy, struct ns_common *ns)
111366 if (atomic_read(&current->mm->mm_users) > 1)
111367 return -EINVAL;
111368
111369- if (current->fs->users != 1)
111370+ if (atomic_read(&current->fs->users) != 1)
111371 return -EINVAL;
111372
111373 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
111374diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
111375index c8eac43..4b5f08f 100644
111376--- a/kernel/utsname_sysctl.c
111377+++ b/kernel/utsname_sysctl.c
111378@@ -47,7 +47,7 @@ static void put_uts(struct ctl_table *table, int write, void *which)
111379 static int proc_do_uts_string(struct ctl_table *table, int write,
111380 void __user *buffer, size_t *lenp, loff_t *ppos)
111381 {
111382- struct ctl_table uts_table;
111383+ ctl_table_no_const uts_table;
111384 int r;
111385 memcpy(&uts_table, table, sizeof(uts_table));
111386 uts_table.data = get_uts(table, write);
111387diff --git a/kernel/watchdog.c b/kernel/watchdog.c
111388index a6ffa43..e48103b 100644
111389--- a/kernel/watchdog.c
111390+++ b/kernel/watchdog.c
111391@@ -655,7 +655,7 @@ void watchdog_nmi_enable_all(void) {}
111392 void watchdog_nmi_disable_all(void) {}
111393 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
111394
111395-static struct smp_hotplug_thread watchdog_threads = {
111396+static struct smp_hotplug_thread watchdog_threads __read_only = {
111397 .store = &softlockup_watchdog,
111398 .thread_should_run = watchdog_should_run,
111399 .thread_fn = watchdog,
111400diff --git a/kernel/workqueue.c b/kernel/workqueue.c
111401index 1de0f5fab..dbf1ec6 100644
111402--- a/kernel/workqueue.c
111403+++ b/kernel/workqueue.c
111404@@ -4452,7 +4452,7 @@ static void rebind_workers(struct worker_pool *pool)
111405 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
111406 worker_flags |= WORKER_REBOUND;
111407 worker_flags &= ~WORKER_UNBOUND;
111408- ACCESS_ONCE(worker->flags) = worker_flags;
111409+ ACCESS_ONCE_RW(worker->flags) = worker_flags;
111410 }
111411
111412 spin_unlock_irq(&pool->lock);
111413diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
111414index e2894b2..23751b3 100644
111415--- a/lib/Kconfig.debug
111416+++ b/lib/Kconfig.debug
111417@@ -242,6 +242,7 @@ config PAGE_OWNER
111418 bool "Track page owner"
111419 depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
111420 select DEBUG_FS
111421+ depends on !GRKERNSEC_KMEM
111422 select STACKTRACE
111423 select PAGE_EXTENSION
111424 help
111425@@ -256,6 +257,7 @@ config PAGE_OWNER
111426
111427 config DEBUG_FS
111428 bool "Debug Filesystem"
111429+ depends on !GRKERNSEC_KMEM
111430 help
111431 debugfs is a virtual file system that kernel developers use to put
111432 debugging files into. Enable this option to be able to read and
111433@@ -488,6 +490,7 @@ config DEBUG_KMEMLEAK
111434 bool "Kernel memory leak detector"
111435 depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK
111436 select DEBUG_FS
111437+ depends on !GRKERNSEC_KMEM
111438 select STACKTRACE if STACKTRACE_SUPPORT
111439 select KALLSYMS
111440 select CRC32
111441@@ -941,7 +944,7 @@ config DEBUG_MUTEXES
111442
111443 config DEBUG_WW_MUTEX_SLOWPATH
111444 bool "Wait/wound mutex debugging: Slowpath testing"
111445- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
111446+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
111447 select DEBUG_LOCK_ALLOC
111448 select DEBUG_SPINLOCK
111449 select DEBUG_MUTEXES
111450@@ -958,7 +961,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
111451
111452 config DEBUG_LOCK_ALLOC
111453 bool "Lock debugging: detect incorrect freeing of live locks"
111454- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
111455+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
111456 select DEBUG_SPINLOCK
111457 select DEBUG_MUTEXES
111458 select LOCKDEP
111459@@ -972,7 +975,7 @@ config DEBUG_LOCK_ALLOC
111460
111461 config PROVE_LOCKING
111462 bool "Lock debugging: prove locking correctness"
111463- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
111464+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
111465 select LOCKDEP
111466 select DEBUG_SPINLOCK
111467 select DEBUG_MUTEXES
111468@@ -1023,7 +1026,7 @@ config LOCKDEP
111469
111470 config LOCK_STAT
111471 bool "Lock usage statistics"
111472- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
111473+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
111474 select LOCKDEP
111475 select DEBUG_SPINLOCK
111476 select DEBUG_MUTEXES
111477@@ -1422,6 +1425,7 @@ config NOTIFIER_ERROR_INJECTION
111478 tristate "Notifier error injection"
111479 depends on DEBUG_KERNEL
111480 select DEBUG_FS
111481+ depends on !GRKERNSEC_KMEM
111482 help
111483 This option provides the ability to inject artificial errors to
111484 specified notifier chain callbacks. It is useful to test the error
111485@@ -1534,6 +1538,7 @@ config FAIL_IO_TIMEOUT
111486 config FAIL_MMC_REQUEST
111487 bool "Fault-injection capability for MMC IO"
111488 select DEBUG_FS
111489+ depends on !GRKERNSEC_KMEM
111490 depends on FAULT_INJECTION && MMC
111491 help
111492 Provide fault-injection capability for MMC IO.
111493@@ -1563,6 +1568,7 @@ config LATENCYTOP
111494 depends on DEBUG_KERNEL
111495 depends on STACKTRACE_SUPPORT
111496 depends on PROC_FS
111497+ depends on !GRKERNSEC_HIDESYM
111498 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
111499 select KALLSYMS
111500 select KALLSYMS_ALL
111501@@ -1579,7 +1585,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
111502 config DEBUG_STRICT_USER_COPY_CHECKS
111503 bool "Strict user copy size checks"
111504 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
111505- depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
111506+ depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
111507 help
111508 Enabling this option turns a certain set of sanity checks for user
111509 copy operations into compile time failures.
111510@@ -1710,7 +1716,7 @@ endmenu # runtime tests
111511
111512 config PROVIDE_OHCI1394_DMA_INIT
111513 bool "Remote debugging over FireWire early on boot"
111514- depends on PCI && X86
111515+ depends on PCI && X86 && !GRKERNSEC
111516 help
111517 If you want to debug problems which hang or crash the kernel early
111518 on boot and the crashing machine has a FireWire port, you can use
111519diff --git a/lib/Makefile b/lib/Makefile
111520index 6897b52..466bda9 100644
111521--- a/lib/Makefile
111522+++ b/lib/Makefile
111523@@ -62,7 +62,7 @@ obj-$(CONFIG_BTREE) += btree.o
111524 obj-$(CONFIG_INTERVAL_TREE) += interval_tree.o
111525 obj-$(CONFIG_ASSOCIATIVE_ARRAY) += assoc_array.o
111526 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
111527-obj-$(CONFIG_DEBUG_LIST) += list_debug.o
111528+obj-y += list_debug.o
111529 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
111530
111531 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
111532diff --git a/lib/average.c b/lib/average.c
111533index 114d1be..ab0350c 100644
111534--- a/lib/average.c
111535+++ b/lib/average.c
111536@@ -55,7 +55,7 @@ struct ewma *ewma_add(struct ewma *avg, unsigned long val)
111537 {
111538 unsigned long internal = ACCESS_ONCE(avg->internal);
111539
111540- ACCESS_ONCE(avg->internal) = internal ?
111541+ ACCESS_ONCE_RW(avg->internal) = internal ?
111542 (((internal << avg->weight) - internal) +
111543 (val << avg->factor)) >> avg->weight :
111544 (val << avg->factor);
111545diff --git a/lib/bitmap.c b/lib/bitmap.c
111546index a578a01..2198e50 100644
111547--- a/lib/bitmap.c
111548+++ b/lib/bitmap.c
111549@@ -361,7 +361,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
111550 {
111551 int c, old_c, totaldigits, ndigits, nchunks, nbits;
111552 u32 chunk;
111553- const char __user __force *ubuf = (const char __user __force *)buf;
111554+ const char __user *ubuf = (const char __force_user *)buf;
111555
111556 bitmap_zero(maskp, nmaskbits);
111557
111558@@ -446,7 +446,7 @@ int bitmap_parse_user(const char __user *ubuf,
111559 {
111560 if (!access_ok(VERIFY_READ, ubuf, ulen))
111561 return -EFAULT;
111562- return __bitmap_parse((const char __force *)ubuf,
111563+ return __bitmap_parse((const char __force_kernel *)ubuf,
111564 ulen, 1, maskp, nmaskbits);
111565
111566 }
111567@@ -506,7 +506,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
111568 {
111569 unsigned a, b;
111570 int c, old_c, totaldigits;
111571- const char __user __force *ubuf = (const char __user __force *)buf;
111572+ const char __user *ubuf = (const char __force_user *)buf;
111573 int at_start, in_range;
111574
111575 totaldigits = c = 0;
111576@@ -602,7 +602,7 @@ int bitmap_parselist_user(const char __user *ubuf,
111577 {
111578 if (!access_ok(VERIFY_READ, ubuf, ulen))
111579 return -EFAULT;
111580- return __bitmap_parselist((const char __force *)ubuf,
111581+ return __bitmap_parselist((const char __force_kernel *)ubuf,
111582 ulen, 1, maskp, nmaskbits);
111583 }
111584 EXPORT_SYMBOL(bitmap_parselist_user);
111585diff --git a/lib/bug.c b/lib/bug.c
111586index cff145f..724a0b8 100644
111587--- a/lib/bug.c
111588+++ b/lib/bug.c
111589@@ -148,6 +148,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
111590 return BUG_TRAP_TYPE_NONE;
111591
111592 bug = find_bug(bugaddr);
111593+ if (!bug)
111594+ return BUG_TRAP_TYPE_NONE;
111595
111596 file = NULL;
111597 line = 0;
111598diff --git a/lib/debugobjects.c b/lib/debugobjects.c
111599index 547f7f9..a6d4ba0 100644
111600--- a/lib/debugobjects.c
111601+++ b/lib/debugobjects.c
111602@@ -289,7 +289,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
111603 if (limit > 4)
111604 return;
111605
111606- is_on_stack = object_is_on_stack(addr);
111607+ is_on_stack = object_starts_on_stack(addr);
111608 if (is_on_stack == onstack)
111609 return;
111610
111611diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c
111612index 0234361..41a411c 100644
111613--- a/lib/decompress_bunzip2.c
111614+++ b/lib/decompress_bunzip2.c
111615@@ -665,7 +665,8 @@ static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, long len,
111616
111617 /* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
111618 uncompressed data. Allocate intermediate buffer for block. */
111619- bd->dbufSize = 100000*(i-BZh0);
111620+ i -= BZh0;
111621+ bd->dbufSize = 100000 * i;
111622
111623 bd->dbuf = large_malloc(bd->dbufSize * sizeof(int));
111624 if (!bd->dbuf)
111625diff --git a/lib/decompress_unlzma.c b/lib/decompress_unlzma.c
111626index decb646..8d6441a 100644
111627--- a/lib/decompress_unlzma.c
111628+++ b/lib/decompress_unlzma.c
111629@@ -39,10 +39,10 @@
111630
111631 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
111632
111633-static long long INIT read_int(unsigned char *ptr, int size)
111634+static unsigned long long INIT read_int(unsigned char *ptr, int size)
111635 {
111636 int i;
111637- long long ret = 0;
111638+ unsigned long long ret = 0;
111639
111640 for (i = 0; i < size; i++)
111641 ret = (ret << 8) | ptr[size-i-1];
111642diff --git a/lib/div64.c b/lib/div64.c
111643index 19ea7ed..20cac21 100644
111644--- a/lib/div64.c
111645+++ b/lib/div64.c
111646@@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
111647 EXPORT_SYMBOL(__div64_32);
111648
111649 #ifndef div_s64_rem
111650-s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
111651+s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
111652 {
111653 u64 quotient;
111654
111655@@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
111656 * 'http://www.hackersdelight.org/hdcodetxt/divDouble.c.txt'
111657 */
111658 #ifndef div64_u64
111659-u64 div64_u64(u64 dividend, u64 divisor)
111660+u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
111661 {
111662 u32 high = divisor >> 32;
111663 u64 quot;
111664diff --git a/lib/dma-debug.c b/lib/dma-debug.c
111665index dace71f..13da37b 100644
111666--- a/lib/dma-debug.c
111667+++ b/lib/dma-debug.c
111668@@ -982,7 +982,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
111669
111670 void dma_debug_add_bus(struct bus_type *bus)
111671 {
111672- struct notifier_block *nb;
111673+ notifier_block_no_const *nb;
111674
111675 if (dma_debug_disabled())
111676 return;
111677@@ -1164,7 +1164,7 @@ static void check_unmap(struct dma_debug_entry *ref)
111678
111679 static void check_for_stack(struct device *dev, void *addr)
111680 {
111681- if (object_is_on_stack(addr))
111682+ if (object_starts_on_stack(addr))
111683 err_printk(dev, NULL, "DMA-API: device driver maps memory from "
111684 "stack [addr=%p]\n", addr);
111685 }
111686diff --git a/lib/inflate.c b/lib/inflate.c
111687index 013a761..c28f3fc 100644
111688--- a/lib/inflate.c
111689+++ b/lib/inflate.c
111690@@ -269,7 +269,7 @@ static void free(void *where)
111691 malloc_ptr = free_mem_ptr;
111692 }
111693 #else
111694-#define malloc(a) kmalloc(a, GFP_KERNEL)
111695+#define malloc(a) kmalloc((a), GFP_KERNEL)
111696 #define free(a) kfree(a)
111697 #endif
111698
111699diff --git a/lib/ioremap.c b/lib/ioremap.c
111700index 86c8911..f5bfc34 100644
111701--- a/lib/ioremap.c
111702+++ b/lib/ioremap.c
111703@@ -75,7 +75,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
111704 unsigned long next;
111705
111706 phys_addr -= addr;
111707- pmd = pmd_alloc(&init_mm, pud, addr);
111708+ pmd = pmd_alloc_kernel(&init_mm, pud, addr);
111709 if (!pmd)
111710 return -ENOMEM;
111711 do {
111712@@ -101,7 +101,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
111713 unsigned long next;
111714
111715 phys_addr -= addr;
111716- pud = pud_alloc(&init_mm, pgd, addr);
111717+ pud = pud_alloc_kernel(&init_mm, pgd, addr);
111718 if (!pud)
111719 return -ENOMEM;
111720 do {
111721diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
111722index bd2bea9..6b3c95e 100644
111723--- a/lib/is_single_threaded.c
111724+++ b/lib/is_single_threaded.c
111725@@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
111726 struct task_struct *p, *t;
111727 bool ret;
111728
111729+ if (!mm)
111730+ return true;
111731+
111732 if (atomic_read(&task->signal->live) != 1)
111733 return false;
111734
111735diff --git a/lib/kobject.c b/lib/kobject.c
111736index 3e3a5c3..4a12109 100644
111737--- a/lib/kobject.c
111738+++ b/lib/kobject.c
111739@@ -935,9 +935,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
111740
111741
111742 static DEFINE_SPINLOCK(kobj_ns_type_lock);
111743-static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
111744+static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
111745
111746-int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
111747+int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
111748 {
111749 enum kobj_ns_type type = ops->type;
111750 int error;
111751diff --git a/lib/list_debug.c b/lib/list_debug.c
111752index c24c2f7..f0296f4 100644
111753--- a/lib/list_debug.c
111754+++ b/lib/list_debug.c
111755@@ -11,7 +11,9 @@
111756 #include <linux/bug.h>
111757 #include <linux/kernel.h>
111758 #include <linux/rculist.h>
111759+#include <linux/mm.h>
111760
111761+#ifdef CONFIG_DEBUG_LIST
111762 /*
111763 * Insert a new entry between two known consecutive entries.
111764 *
111765@@ -19,21 +21,40 @@
111766 * the prev/next entries already!
111767 */
111768
111769+static bool __list_add_debug(struct list_head *new,
111770+ struct list_head *prev,
111771+ struct list_head *next)
111772+{
111773+ if (unlikely(next->prev != prev)) {
111774+ printk(KERN_ERR "list_add corruption. next->prev should be "
111775+ "prev (%p), but was %p. (next=%p).\n",
111776+ prev, next->prev, next);
111777+ BUG();
111778+ return false;
111779+ }
111780+ if (unlikely(prev->next != next)) {
111781+ printk(KERN_ERR "list_add corruption. prev->next should be "
111782+ "next (%p), but was %p. (prev=%p).\n",
111783+ next, prev->next, prev);
111784+ BUG();
111785+ return false;
111786+ }
111787+ if (unlikely(new == prev || new == next)) {
111788+ printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
111789+ new, prev, next);
111790+ BUG();
111791+ return false;
111792+ }
111793+ return true;
111794+}
111795+
111796 void __list_add(struct list_head *new,
111797- struct list_head *prev,
111798- struct list_head *next)
111799+ struct list_head *prev,
111800+ struct list_head *next)
111801 {
111802- WARN(next->prev != prev,
111803- "list_add corruption. next->prev should be "
111804- "prev (%p), but was %p. (next=%p).\n",
111805- prev, next->prev, next);
111806- WARN(prev->next != next,
111807- "list_add corruption. prev->next should be "
111808- "next (%p), but was %p. (prev=%p).\n",
111809- next, prev->next, prev);
111810- WARN(new == prev || new == next,
111811- "list_add double add: new=%p, prev=%p, next=%p.\n",
111812- new, prev, next);
111813+ if (!__list_add_debug(new, prev, next))
111814+ return;
111815+
111816 next->prev = new;
111817 new->next = next;
111818 new->prev = prev;
111819@@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
111820 }
111821 EXPORT_SYMBOL(__list_add);
111822
111823-void __list_del_entry(struct list_head *entry)
111824+static bool __list_del_entry_debug(struct list_head *entry)
111825 {
111826 struct list_head *prev, *next;
111827
111828 prev = entry->prev;
111829 next = entry->next;
111830
111831- if (WARN(next == LIST_POISON1,
111832- "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
111833- entry, LIST_POISON1) ||
111834- WARN(prev == LIST_POISON2,
111835- "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
111836- entry, LIST_POISON2) ||
111837- WARN(prev->next != entry,
111838- "list_del corruption. prev->next should be %p, "
111839- "but was %p\n", entry, prev->next) ||
111840- WARN(next->prev != entry,
111841- "list_del corruption. next->prev should be %p, "
111842- "but was %p\n", entry, next->prev))
111843+ if (unlikely(next == LIST_POISON1)) {
111844+ printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
111845+ entry, LIST_POISON1);
111846+ BUG();
111847+ return false;
111848+ }
111849+ if (unlikely(prev == LIST_POISON2)) {
111850+ printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
111851+ entry, LIST_POISON2);
111852+ BUG();
111853+ return false;
111854+ }
111855+ if (unlikely(entry->prev->next != entry)) {
111856+ printk(KERN_ERR "list_del corruption. prev->next should be %p, "
111857+ "but was %p\n", entry, prev->next);
111858+ BUG();
111859+ return false;
111860+ }
111861+ if (unlikely(entry->next->prev != entry)) {
111862+ printk(KERN_ERR "list_del corruption. next->prev should be %p, "
111863+ "but was %p\n", entry, next->prev);
111864+ BUG();
111865+ return false;
111866+ }
111867+ return true;
111868+}
111869+
111870+void __list_del_entry(struct list_head *entry)
111871+{
111872+ if (!__list_del_entry_debug(entry))
111873 return;
111874
111875- __list_del(prev, next);
111876+ __list_del(entry->prev, entry->next);
111877 }
111878 EXPORT_SYMBOL(__list_del_entry);
111879
111880@@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
111881 void __list_add_rcu(struct list_head *new,
111882 struct list_head *prev, struct list_head *next)
111883 {
111884- WARN(next->prev != prev,
111885- "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
111886- prev, next->prev, next);
111887- WARN(prev->next != next,
111888- "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
111889- next, prev->next, prev);
111890+ if (!__list_add_debug(new, prev, next))
111891+ return;
111892+
111893 new->next = next;
111894 new->prev = prev;
111895 rcu_assign_pointer(list_next_rcu(prev), new);
111896 next->prev = new;
111897 }
111898 EXPORT_SYMBOL(__list_add_rcu);
111899+#endif
111900+
111901+void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
111902+{
111903+#ifdef CONFIG_DEBUG_LIST
111904+ if (!__list_add_debug(new, prev, next))
111905+ return;
111906+#endif
111907+
111908+ pax_open_kernel();
111909+ next->prev = new;
111910+ new->next = next;
111911+ new->prev = prev;
111912+ prev->next = new;
111913+ pax_close_kernel();
111914+}
111915+EXPORT_SYMBOL(__pax_list_add);
111916+
111917+void pax_list_del(struct list_head *entry)
111918+{
111919+#ifdef CONFIG_DEBUG_LIST
111920+ if (!__list_del_entry_debug(entry))
111921+ return;
111922+#endif
111923+
111924+ pax_open_kernel();
111925+ __list_del(entry->prev, entry->next);
111926+ entry->next = LIST_POISON1;
111927+ entry->prev = LIST_POISON2;
111928+ pax_close_kernel();
111929+}
111930+EXPORT_SYMBOL(pax_list_del);
111931+
111932+void pax_list_del_init(struct list_head *entry)
111933+{
111934+ pax_open_kernel();
111935+ __list_del(entry->prev, entry->next);
111936+ INIT_LIST_HEAD(entry);
111937+ pax_close_kernel();
111938+}
111939+EXPORT_SYMBOL(pax_list_del_init);
111940+
111941+void __pax_list_add_rcu(struct list_head *new,
111942+ struct list_head *prev, struct list_head *next)
111943+{
111944+#ifdef CONFIG_DEBUG_LIST
111945+ if (!__list_add_debug(new, prev, next))
111946+ return;
111947+#endif
111948+
111949+ pax_open_kernel();
111950+ new->next = next;
111951+ new->prev = prev;
111952+ rcu_assign_pointer(list_next_rcu(prev), new);
111953+ next->prev = new;
111954+ pax_close_kernel();
111955+}
111956+EXPORT_SYMBOL(__pax_list_add_rcu);
111957+
111958+void pax_list_del_rcu(struct list_head *entry)
111959+{
111960+#ifdef CONFIG_DEBUG_LIST
111961+ if (!__list_del_entry_debug(entry))
111962+ return;
111963+#endif
111964+
111965+ pax_open_kernel();
111966+ __list_del(entry->prev, entry->next);
111967+ entry->next = LIST_POISON1;
111968+ entry->prev = LIST_POISON2;
111969+ pax_close_kernel();
111970+}
111971+EXPORT_SYMBOL(pax_list_del_rcu);
111972diff --git a/lib/lockref.c b/lib/lockref.c
111973index 494994b..65caf94 100644
111974--- a/lib/lockref.c
111975+++ b/lib/lockref.c
111976@@ -48,13 +48,13 @@
111977 void lockref_get(struct lockref *lockref)
111978 {
111979 CMPXCHG_LOOP(
111980- new.count++;
111981+ __lockref_inc(&new);
111982 ,
111983 return;
111984 );
111985
111986 spin_lock(&lockref->lock);
111987- lockref->count++;
111988+ __lockref_inc(lockref);
111989 spin_unlock(&lockref->lock);
111990 }
111991 EXPORT_SYMBOL(lockref_get);
111992@@ -69,8 +69,8 @@ int lockref_get_not_zero(struct lockref *lockref)
111993 int retval;
111994
111995 CMPXCHG_LOOP(
111996- new.count++;
111997- if (old.count <= 0)
111998+ __lockref_inc(&new);
111999+ if (__lockref_read(&old) <= 0)
112000 return 0;
112001 ,
112002 return 1;
112003@@ -78,8 +78,8 @@ int lockref_get_not_zero(struct lockref *lockref)
112004
112005 spin_lock(&lockref->lock);
112006 retval = 0;
112007- if (lockref->count > 0) {
112008- lockref->count++;
112009+ if (__lockref_read(lockref) > 0) {
112010+ __lockref_inc(lockref);
112011 retval = 1;
112012 }
112013 spin_unlock(&lockref->lock);
112014@@ -96,17 +96,17 @@ EXPORT_SYMBOL(lockref_get_not_zero);
112015 int lockref_get_or_lock(struct lockref *lockref)
112016 {
112017 CMPXCHG_LOOP(
112018- new.count++;
112019- if (old.count <= 0)
112020+ __lockref_inc(&new);
112021+ if (__lockref_read(&old) <= 0)
112022 break;
112023 ,
112024 return 1;
112025 );
112026
112027 spin_lock(&lockref->lock);
112028- if (lockref->count <= 0)
112029+ if (__lockref_read(lockref) <= 0)
112030 return 0;
112031- lockref->count++;
112032+ __lockref_inc(lockref);
112033 spin_unlock(&lockref->lock);
112034 return 1;
112035 }
112036@@ -122,11 +122,11 @@ EXPORT_SYMBOL(lockref_get_or_lock);
112037 int lockref_put_return(struct lockref *lockref)
112038 {
112039 CMPXCHG_LOOP(
112040- new.count--;
112041- if (old.count <= 0)
112042+ __lockref_dec(&new);
112043+ if (__lockref_read(&old) <= 0)
112044 return -1;
112045 ,
112046- return new.count;
112047+ return __lockref_read(&new);
112048 );
112049 return -1;
112050 }
112051@@ -140,17 +140,17 @@ EXPORT_SYMBOL(lockref_put_return);
112052 int lockref_put_or_lock(struct lockref *lockref)
112053 {
112054 CMPXCHG_LOOP(
112055- new.count--;
112056- if (old.count <= 1)
112057+ __lockref_dec(&new);
112058+ if (__lockref_read(&old) <= 1)
112059 break;
112060 ,
112061 return 1;
112062 );
112063
112064 spin_lock(&lockref->lock);
112065- if (lockref->count <= 1)
112066+ if (__lockref_read(lockref) <= 1)
112067 return 0;
112068- lockref->count--;
112069+ __lockref_dec(lockref);
112070 spin_unlock(&lockref->lock);
112071 return 1;
112072 }
112073@@ -163,7 +163,7 @@ EXPORT_SYMBOL(lockref_put_or_lock);
112074 void lockref_mark_dead(struct lockref *lockref)
112075 {
112076 assert_spin_locked(&lockref->lock);
112077- lockref->count = -128;
112078+ __lockref_set(lockref, -128);
112079 }
112080 EXPORT_SYMBOL(lockref_mark_dead);
112081
112082@@ -177,8 +177,8 @@ int lockref_get_not_dead(struct lockref *lockref)
112083 int retval;
112084
112085 CMPXCHG_LOOP(
112086- new.count++;
112087- if (old.count < 0)
112088+ __lockref_inc(&new);
112089+ if (__lockref_read(&old) < 0)
112090 return 0;
112091 ,
112092 return 1;
112093@@ -186,8 +186,8 @@ int lockref_get_not_dead(struct lockref *lockref)
112094
112095 spin_lock(&lockref->lock);
112096 retval = 0;
112097- if (lockref->count >= 0) {
112098- lockref->count++;
112099+ if (__lockref_read(lockref) >= 0) {
112100+ __lockref_inc(lockref);
112101 retval = 1;
112102 }
112103 spin_unlock(&lockref->lock);
112104diff --git a/lib/nlattr.c b/lib/nlattr.c
112105index f5907d2..36072be 100644
112106--- a/lib/nlattr.c
112107+++ b/lib/nlattr.c
112108@@ -278,6 +278,8 @@ int nla_memcpy(void *dest, const struct nlattr *src, int count)
112109 {
112110 int minlen = min_t(int, count, nla_len(src));
112111
112112+ BUG_ON(minlen < 0);
112113+
112114 memcpy(dest, nla_data(src), minlen);
112115 if (count > minlen)
112116 memset(dest + minlen, 0, count - minlen);
112117diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
112118index 6111bcb..02e816b 100644
112119--- a/lib/percpu-refcount.c
112120+++ b/lib/percpu-refcount.c
112121@@ -31,7 +31,7 @@
112122 * atomic_long_t can't hit 0 before we've added up all the percpu refs.
112123 */
112124
112125-#define PERCPU_COUNT_BIAS (1LU << (BITS_PER_LONG - 1))
112126+#define PERCPU_COUNT_BIAS (1LU << (BITS_PER_LONG - 2))
112127
112128 static DECLARE_WAIT_QUEUE_HEAD(percpu_ref_switch_waitq);
112129
112130diff --git a/lib/radix-tree.c b/lib/radix-tree.c
112131index f9ebe1c..e985666 100644
112132--- a/lib/radix-tree.c
112133+++ b/lib/radix-tree.c
112134@@ -68,7 +68,7 @@ struct radix_tree_preload {
112135 /* nodes->private_data points to next preallocated node */
112136 struct radix_tree_node *nodes;
112137 };
112138-static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
112139+static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
112140
112141 static inline void *ptr_to_indirect(void *ptr)
112142 {
112143diff --git a/lib/random32.c b/lib/random32.c
112144index 0bee183..526f12f 100644
112145--- a/lib/random32.c
112146+++ b/lib/random32.c
112147@@ -47,7 +47,7 @@ static inline void prandom_state_selftest(void)
112148 }
112149 #endif
112150
112151-static DEFINE_PER_CPU(struct rnd_state, net_rand_state);
112152+static DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy;
112153
112154 /**
112155 * prandom_u32_state - seeded pseudo-random number generator.
112156diff --git a/lib/rbtree.c b/lib/rbtree.c
112157index 1356454..70ce6c6 100644
112158--- a/lib/rbtree.c
112159+++ b/lib/rbtree.c
112160@@ -412,7 +412,9 @@ static inline void dummy_copy(struct rb_node *old, struct rb_node *new) {}
112161 static inline void dummy_rotate(struct rb_node *old, struct rb_node *new) {}
112162
112163 static const struct rb_augment_callbacks dummy_callbacks = {
112164- dummy_propagate, dummy_copy, dummy_rotate
112165+ .propagate = dummy_propagate,
112166+ .copy = dummy_copy,
112167+ .rotate = dummy_rotate
112168 };
112169
112170 void rb_insert_color(struct rb_node *node, struct rb_root *root)
112171diff --git a/lib/show_mem.c b/lib/show_mem.c
112172index adc98e18..0ce83c2 100644
112173--- a/lib/show_mem.c
112174+++ b/lib/show_mem.c
112175@@ -49,6 +49,6 @@ void show_mem(unsigned int filter)
112176 quicklist_total_size());
112177 #endif
112178 #ifdef CONFIG_MEMORY_FAILURE
112179- printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
112180+ printk("%lu pages hwpoisoned\n", atomic_long_read_unchecked(&num_poisoned_pages));
112181 #endif
112182 }
112183diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
112184index e0af6ff..fcc9f15 100644
112185--- a/lib/strncpy_from_user.c
112186+++ b/lib/strncpy_from_user.c
112187@@ -22,7 +22,7 @@
112188 */
112189 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
112190 {
112191- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
112192+ static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
112193 long res = 0;
112194
112195 /*
112196diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
112197index 3a5f2b3..102f1ff 100644
112198--- a/lib/strnlen_user.c
112199+++ b/lib/strnlen_user.c
112200@@ -26,7 +26,7 @@
112201 */
112202 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
112203 {
112204- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
112205+ static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
112206 long align, res = 0;
112207 unsigned long c;
112208
112209diff --git a/lib/swiotlb.c b/lib/swiotlb.c
112210index 76f29ec..1a5316f 100644
112211--- a/lib/swiotlb.c
112212+++ b/lib/swiotlb.c
112213@@ -690,7 +690,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
112214
112215 void
112216 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
112217- dma_addr_t dev_addr)
112218+ dma_addr_t dev_addr, struct dma_attrs *attrs)
112219 {
112220 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
112221
112222diff --git a/lib/usercopy.c b/lib/usercopy.c
112223index 4f5b1dd..7cab418 100644
112224--- a/lib/usercopy.c
112225+++ b/lib/usercopy.c
112226@@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
112227 WARN(1, "Buffer overflow detected!\n");
112228 }
112229 EXPORT_SYMBOL(copy_from_user_overflow);
112230+
112231+void copy_to_user_overflow(void)
112232+{
112233+ WARN(1, "Buffer overflow detected!\n");
112234+}
112235+EXPORT_SYMBOL(copy_to_user_overflow);
112236diff --git a/lib/vsprintf.c b/lib/vsprintf.c
112237index da39c60..ac91239 100644
112238--- a/lib/vsprintf.c
112239+++ b/lib/vsprintf.c
112240@@ -16,6 +16,9 @@
112241 * - scnprintf and vscnprintf
112242 */
112243
112244+#ifdef CONFIG_GRKERNSEC_HIDESYM
112245+#define __INCLUDED_BY_HIDESYM 1
112246+#endif
112247 #include <stdarg.h>
112248 #include <linux/clk-provider.h>
112249 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
112250@@ -628,7 +631,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
112251 #ifdef CONFIG_KALLSYMS
112252 if (*fmt == 'B')
112253 sprint_backtrace(sym, value);
112254- else if (*fmt != 'f' && *fmt != 's')
112255+ else if (*fmt != 'f' && *fmt != 's' && *fmt != 'X')
112256 sprint_symbol(sym, value);
112257 else
112258 sprint_symbol_no_offset(sym, value);
112259@@ -1360,7 +1363,11 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
112260 }
112261 }
112262
112263-int kptr_restrict __read_mostly;
112264+#ifdef CONFIG_GRKERNSEC_HIDESYM
112265+int kptr_restrict __read_only = 2;
112266+#else
112267+int kptr_restrict __read_only;
112268+#endif
112269
112270 /*
112271 * Show a '%p' thing. A kernel extension is that the '%p' is followed
112272@@ -1371,8 +1378,10 @@ int kptr_restrict __read_mostly;
112273 *
112274 * - 'F' For symbolic function descriptor pointers with offset
112275 * - 'f' For simple symbolic function names without offset
112276+ * - 'X' For simple symbolic function names without offset approved for use with GRKERNSEC_HIDESYM
112277 * - 'S' For symbolic direct pointers with offset
112278 * - 's' For symbolic direct pointers without offset
112279+ * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
112280 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
112281 * - 'B' For backtraced symbolic direct pointers with offset
112282 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
112283@@ -1460,12 +1469,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
112284
112285 if (!ptr && *fmt != 'K') {
112286 /*
112287- * Print (null) with the same width as a pointer so it makes
112288+ * Print (nil) with the same width as a pointer so it makes
112289 * tabular output look nice.
112290 */
112291 if (spec.field_width == -1)
112292 spec.field_width = default_width;
112293- return string(buf, end, "(null)", spec);
112294+ return string(buf, end, "(nil)", spec);
112295 }
112296
112297 switch (*fmt) {
112298@@ -1475,6 +1484,14 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
112299 /* Fallthrough */
112300 case 'S':
112301 case 's':
112302+#ifdef CONFIG_GRKERNSEC_HIDESYM
112303+ break;
112304+#else
112305+ return symbol_string(buf, end, ptr, spec, fmt);
112306+#endif
112307+ case 'X':
112308+ ptr = dereference_function_descriptor(ptr);
112309+ case 'A':
112310 case 'B':
112311 return symbol_string(buf, end, ptr, spec, fmt);
112312 case 'R':
112313@@ -1539,6 +1556,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
112314 va_end(va);
112315 return buf;
112316 }
112317+ case 'P':
112318+ break;
112319 case 'K':
112320 /*
112321 * %pK cannot be used in IRQ context because its test
112322@@ -1598,6 +1617,22 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
112323 ((const struct file *)ptr)->f_path.dentry,
112324 spec, fmt);
112325 }
112326+
112327+#ifdef CONFIG_GRKERNSEC_HIDESYM
112328+ /* 'P' = approved pointers to copy to userland,
112329+ as in the /proc/kallsyms case, as we make it display nothing
112330+ for non-root users, and the real contents for root users
112331+ 'X' = approved simple symbols
112332+ Also ignore 'K' pointers, since we force their NULLing for non-root users
112333+ above
112334+ */
112335+ if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'X' && *fmt != 'K' && is_usercopy_object(buf)) {
112336+ printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
112337+ dump_stack();
112338+ ptr = NULL;
112339+ }
112340+#endif
112341+
112342 spec.flags |= SMALL;
112343 if (spec.field_width == -1) {
112344 spec.field_width = default_width;
112345@@ -2296,11 +2331,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
112346 typeof(type) value; \
112347 if (sizeof(type) == 8) { \
112348 args = PTR_ALIGN(args, sizeof(u32)); \
112349- *(u32 *)&value = *(u32 *)args; \
112350- *((u32 *)&value + 1) = *(u32 *)(args + 4); \
112351+ *(u32 *)&value = *(const u32 *)args; \
112352+ *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
112353 } else { \
112354 args = PTR_ALIGN(args, sizeof(type)); \
112355- value = *(typeof(type) *)args; \
112356+ value = *(const typeof(type) *)args; \
112357 } \
112358 args += sizeof(type); \
112359 value; \
112360@@ -2363,7 +2398,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
112361 case FORMAT_TYPE_STR: {
112362 const char *str_arg = args;
112363 args += strlen(str_arg) + 1;
112364- str = string(str, end, (char *)str_arg, spec);
112365+ str = string(str, end, str_arg, spec);
112366 break;
112367 }
112368
112369diff --git a/localversion-grsec b/localversion-grsec
112370new file mode 100644
112371index 0000000..7cd6065
112372--- /dev/null
112373+++ b/localversion-grsec
112374@@ -0,0 +1 @@
112375+-grsec
112376diff --git a/mm/Kconfig b/mm/Kconfig
112377index e79de2b..fba3116 100644
112378--- a/mm/Kconfig
112379+++ b/mm/Kconfig
112380@@ -342,10 +342,11 @@ config KSM
112381 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
112382
112383 config DEFAULT_MMAP_MIN_ADDR
112384- int "Low address space to protect from user allocation"
112385+ int "Low address space to protect from user allocation"
112386 depends on MMU
112387- default 4096
112388- help
112389+ default 32768 if ALPHA || ARM || PARISC || SPARC32
112390+ default 65536
112391+ help
112392 This is the portion of low virtual memory which should be protected
112393 from userspace allocation. Keeping a user from writing to low pages
112394 can help reduce the impact of kernel NULL pointer bugs.
112395@@ -377,8 +378,9 @@ config MEMORY_FAILURE
112396
112397 config HWPOISON_INJECT
112398 tristate "HWPoison pages injector"
112399- depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
112400+ depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
112401 select PROC_PAGE_MONITOR
112402+ depends on !GRKERNSEC
112403
112404 config NOMMU_INITIAL_TRIM_EXCESS
112405 int "Turn on mmap() excess space trimming before booting"
112406@@ -539,6 +541,7 @@ config MEM_SOFT_DIRTY
112407 bool "Track memory changes"
112408 depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY && PROC_FS
112409 select PROC_PAGE_MONITOR
112410+ depends on !GRKERNSEC
112411 help
112412 This option enables memory changes tracking by introducing a
112413 soft-dirty bit on pte-s. This bit it set when someone writes
112414@@ -613,6 +616,7 @@ config ZSMALLOC_STAT
112415 bool "Export zsmalloc statistics"
112416 depends on ZSMALLOC
112417 select DEBUG_FS
112418+ depends on !GRKERNSEC_KMEM
112419 help
112420 This option enables code in the zsmalloc to collect various
112421 statistics about whats happening in zsmalloc and exports that
112422diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug
112423index 957d3da..1d34e20 100644
112424--- a/mm/Kconfig.debug
112425+++ b/mm/Kconfig.debug
112426@@ -10,6 +10,7 @@ config PAGE_EXTENSION
112427 config DEBUG_PAGEALLOC
112428 bool "Debug page memory allocations"
112429 depends on DEBUG_KERNEL
112430+ depends on !PAX_MEMORY_SANITIZE
112431 depends on !HIBERNATION || ARCH_SUPPORTS_DEBUG_PAGEALLOC && !PPC && !SPARC
112432 depends on !KMEMCHECK
112433 select PAGE_EXTENSION
112434diff --git a/mm/backing-dev.c b/mm/backing-dev.c
112435index dac5bf5..d8c02ce 100644
112436--- a/mm/backing-dev.c
112437+++ b/mm/backing-dev.c
112438@@ -12,7 +12,7 @@
112439 #include <linux/device.h>
112440 #include <trace/events/writeback.h>
112441
112442-static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
112443+static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
112444
112445 struct backing_dev_info noop_backing_dev_info = {
112446 .name = "noop",
112447@@ -855,7 +855,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name)
112448 return err;
112449
112450 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
112451- atomic_long_inc_return(&bdi_seq));
112452+ atomic_long_inc_return_unchecked(&bdi_seq));
112453 if (err) {
112454 bdi_destroy(bdi);
112455 return err;
112456diff --git a/mm/dmapool.c b/mm/dmapool.c
112457index fd5fe43..39ea317 100644
112458--- a/mm/dmapool.c
112459+++ b/mm/dmapool.c
112460@@ -386,7 +386,7 @@ static struct dma_page *pool_find_page(struct dma_pool *pool, dma_addr_t dma)
112461 list_for_each_entry(page, &pool->page_list, page_list) {
112462 if (dma < page->dma)
112463 continue;
112464- if (dma < (page->dma + pool->allocation))
112465+ if ((dma - page->dma) < pool->allocation)
112466 return page;
112467 }
112468 return NULL;
112469diff --git a/mm/filemap.c b/mm/filemap.c
112470index 1283fc8..a0347d5 100644
112471--- a/mm/filemap.c
112472+++ b/mm/filemap.c
112473@@ -2122,7 +2122,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
112474 struct address_space *mapping = file->f_mapping;
112475
112476 if (!mapping->a_ops->readpage)
112477- return -ENOEXEC;
112478+ return -ENODEV;
112479 file_accessed(file);
112480 vma->vm_ops = &generic_file_vm_ops;
112481 return 0;
112482@@ -2303,6 +2303,7 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)
112483 pos = iocb->ki_pos;
112484
112485 if (limit != RLIM_INFINITY) {
112486+ gr_learn_resource(current, RLIMIT_FSIZE, iocb->ki_pos, 0);
112487 if (iocb->ki_pos >= limit) {
112488 send_sig(SIGXFSZ, current, 0);
112489 return -EFBIG;
112490diff --git a/mm/gup.c b/mm/gup.c
112491index 6297f6b..7652403 100644
112492--- a/mm/gup.c
112493+++ b/mm/gup.c
112494@@ -265,11 +265,6 @@ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma,
112495 unsigned int fault_flags = 0;
112496 int ret;
112497
112498- /* For mm_populate(), just skip the stack guard page. */
112499- if ((*flags & FOLL_POPULATE) &&
112500- (stack_guard_page_start(vma, address) ||
112501- stack_guard_page_end(vma, address + PAGE_SIZE)))
112502- return -ENOENT;
112503 if (*flags & FOLL_WRITE)
112504 fault_flags |= FAULT_FLAG_WRITE;
112505 if (nonblocking)
112506@@ -435,14 +430,14 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
112507 if (!(gup_flags & FOLL_FORCE))
112508 gup_flags |= FOLL_NUMA;
112509
112510- do {
112511+ while (nr_pages) {
112512 struct page *page;
112513 unsigned int foll_flags = gup_flags;
112514 unsigned int page_increm;
112515
112516 /* first iteration or cross vma bound */
112517 if (!vma || start >= vma->vm_end) {
112518- vma = find_extend_vma(mm, start);
112519+ vma = find_vma(mm, start);
112520 if (!vma && in_gate_area(mm, start)) {
112521 int ret;
112522 ret = get_gate_page(mm, start & PAGE_MASK,
112523@@ -454,7 +449,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
112524 goto next_page;
112525 }
112526
112527- if (!vma || check_vma_flags(vma, gup_flags))
112528+ if (!vma || start < vma->vm_start || check_vma_flags(vma, gup_flags))
112529 return i ? : -EFAULT;
112530 if (is_vm_hugetlb_page(vma)) {
112531 i = follow_hugetlb_page(mm, vma, pages, vmas,
112532@@ -509,7 +504,7 @@ next_page:
112533 i += page_increm;
112534 start += page_increm * PAGE_SIZE;
112535 nr_pages -= page_increm;
112536- } while (nr_pages);
112537+ }
112538 return i;
112539 }
112540 EXPORT_SYMBOL(__get_user_pages);
112541diff --git a/mm/highmem.c b/mm/highmem.c
112542index 123bcd3..c2c85db 100644
112543--- a/mm/highmem.c
112544+++ b/mm/highmem.c
112545@@ -195,8 +195,9 @@ static void flush_all_zero_pkmaps(void)
112546 * So no dangers, even with speculative execution.
112547 */
112548 page = pte_page(pkmap_page_table[i]);
112549+ pax_open_kernel();
112550 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
112551-
112552+ pax_close_kernel();
112553 set_page_address(page, NULL);
112554 need_flush = 1;
112555 }
112556@@ -259,8 +260,11 @@ start:
112557 }
112558 }
112559 vaddr = PKMAP_ADDR(last_pkmap_nr);
112560+
112561+ pax_open_kernel();
112562 set_pte_at(&init_mm, vaddr,
112563 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
112564+ pax_close_kernel();
112565
112566 pkmap_count[last_pkmap_nr] = 1;
112567 set_page_address(page, (void *)vaddr);
112568diff --git a/mm/hugetlb.c b/mm/hugetlb.c
112569index 62c1ec5..ec431dc 100644
112570--- a/mm/hugetlb.c
112571+++ b/mm/hugetlb.c
112572@@ -2442,6 +2442,7 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
112573 struct ctl_table *table, int write,
112574 void __user *buffer, size_t *length, loff_t *ppos)
112575 {
112576+ ctl_table_no_const t;
112577 struct hstate *h = &default_hstate;
112578 unsigned long tmp = h->max_huge_pages;
112579 int ret;
112580@@ -2449,9 +2450,10 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
112581 if (!hugepages_supported())
112582 return -ENOTSUPP;
112583
112584- table->data = &tmp;
112585- table->maxlen = sizeof(unsigned long);
112586- ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
112587+ t = *table;
112588+ t.data = &tmp;
112589+ t.maxlen = sizeof(unsigned long);
112590+ ret = proc_doulongvec_minmax(&t, write, buffer, length, ppos);
112591 if (ret)
112592 goto out;
112593
112594@@ -2486,6 +2488,7 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
112595 struct hstate *h = &default_hstate;
112596 unsigned long tmp;
112597 int ret;
112598+ ctl_table_no_const hugetlb_table;
112599
112600 if (!hugepages_supported())
112601 return -ENOTSUPP;
112602@@ -2495,9 +2498,10 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
112603 if (write && hstate_is_gigantic(h))
112604 return -EINVAL;
112605
112606- table->data = &tmp;
112607- table->maxlen = sizeof(unsigned long);
112608- ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
112609+ hugetlb_table = *table;
112610+ hugetlb_table.data = &tmp;
112611+ hugetlb_table.maxlen = sizeof(unsigned long);
112612+ ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
112613 if (ret)
112614 goto out;
112615
112616@@ -2995,6 +2999,27 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
112617 i_mmap_unlock_write(mapping);
112618 }
112619
112620+#ifdef CONFIG_PAX_SEGMEXEC
112621+static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
112622+{
112623+ struct mm_struct *mm = vma->vm_mm;
112624+ struct vm_area_struct *vma_m;
112625+ unsigned long address_m;
112626+ pte_t *ptep_m;
112627+
112628+ vma_m = pax_find_mirror_vma(vma);
112629+ if (!vma_m)
112630+ return;
112631+
112632+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
112633+ address_m = address + SEGMEXEC_TASK_SIZE;
112634+ ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
112635+ get_page(page_m);
112636+ hugepage_add_anon_rmap(page_m, vma_m, address_m);
112637+ set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
112638+}
112639+#endif
112640+
112641 /*
112642 * Hugetlb_cow() should be called with page lock of the original hugepage held.
112643 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
112644@@ -3108,6 +3133,11 @@ retry_avoidcopy:
112645 make_huge_pte(vma, new_page, 1));
112646 page_remove_rmap(old_page);
112647 hugepage_add_new_anon_rmap(new_page, vma, address);
112648+
112649+#ifdef CONFIG_PAX_SEGMEXEC
112650+ pax_mirror_huge_pte(vma, address, new_page);
112651+#endif
112652+
112653 /* Make the old page be freed below */
112654 new_page = old_page;
112655 }
112656@@ -3269,6 +3299,10 @@ retry:
112657 && (vma->vm_flags & VM_SHARED)));
112658 set_huge_pte_at(mm, address, ptep, new_pte);
112659
112660+#ifdef CONFIG_PAX_SEGMEXEC
112661+ pax_mirror_huge_pte(vma, address, page);
112662+#endif
112663+
112664 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
112665 /* Optimization, do the COW without a second fault */
112666 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page, ptl);
112667@@ -3336,6 +3370,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
112668 struct address_space *mapping;
112669 int need_wait_lock = 0;
112670
112671+#ifdef CONFIG_PAX_SEGMEXEC
112672+ struct vm_area_struct *vma_m;
112673+#endif
112674+
112675 address &= huge_page_mask(h);
112676
112677 ptep = huge_pte_offset(mm, address);
112678@@ -3349,6 +3387,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
112679 VM_FAULT_SET_HINDEX(hstate_index(h));
112680 }
112681
112682+#ifdef CONFIG_PAX_SEGMEXEC
112683+ vma_m = pax_find_mirror_vma(vma);
112684+ if (vma_m) {
112685+ unsigned long address_m;
112686+
112687+ if (vma->vm_start > vma_m->vm_start) {
112688+ address_m = address;
112689+ address -= SEGMEXEC_TASK_SIZE;
112690+ vma = vma_m;
112691+ h = hstate_vma(vma);
112692+ } else
112693+ address_m = address + SEGMEXEC_TASK_SIZE;
112694+
112695+ if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
112696+ return VM_FAULT_OOM;
112697+ address_m &= HPAGE_MASK;
112698+ unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
112699+ }
112700+#endif
112701+
112702 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
112703 if (!ptep)
112704 return VM_FAULT_OOM;
112705diff --git a/mm/internal.h b/mm/internal.h
112706index 36b23f1..673a6c7 100644
112707--- a/mm/internal.h
112708+++ b/mm/internal.h
112709@@ -157,6 +157,7 @@ __find_buddy_index(unsigned long page_idx, unsigned int order)
112710 extern int __isolate_free_page(struct page *page, unsigned int order);
112711 extern void __free_pages_bootmem(struct page *page, unsigned long pfn,
112712 unsigned int order);
112713+extern void free_compound_page(struct page *page);
112714 extern void prep_compound_page(struct page *page, unsigned long order);
112715 #ifdef CONFIG_MEMORY_FAILURE
112716 extern bool is_free_buddy_page(struct page *page);
112717diff --git a/mm/kmemleak.c b/mm/kmemleak.c
112718index cf79f11..254224e 100644
112719--- a/mm/kmemleak.c
112720+++ b/mm/kmemleak.c
112721@@ -375,7 +375,7 @@ static void print_unreferenced(struct seq_file *seq,
112722
112723 for (i = 0; i < object->trace_len; i++) {
112724 void *ptr = (void *)object->trace[i];
112725- seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
112726+ seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
112727 }
112728 }
112729
112730@@ -1966,7 +1966,7 @@ static int __init kmemleak_late_init(void)
112731 return -ENOMEM;
112732 }
112733
112734- dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
112735+ dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
112736 &kmemleak_fops);
112737 if (!dentry)
112738 pr_warning("Failed to create the debugfs kmemleak file\n");
112739diff --git a/mm/maccess.c b/mm/maccess.c
112740index d53adf9..03a24bf 100644
112741--- a/mm/maccess.c
112742+++ b/mm/maccess.c
112743@@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
112744 set_fs(KERNEL_DS);
112745 pagefault_disable();
112746 ret = __copy_from_user_inatomic(dst,
112747- (__force const void __user *)src, size);
112748+ (const void __force_user *)src, size);
112749 pagefault_enable();
112750 set_fs(old_fs);
112751
112752@@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
112753
112754 set_fs(KERNEL_DS);
112755 pagefault_disable();
112756- ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
112757+ ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
112758 pagefault_enable();
112759 set_fs(old_fs);
112760
112761diff --git a/mm/madvise.c b/mm/madvise.c
112762index 64bb8a2..68e4be5 100644
112763--- a/mm/madvise.c
112764+++ b/mm/madvise.c
112765@@ -52,6 +52,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
112766 pgoff_t pgoff;
112767 unsigned long new_flags = vma->vm_flags;
112768
112769+#ifdef CONFIG_PAX_SEGMEXEC
112770+ struct vm_area_struct *vma_m;
112771+#endif
112772+
112773 switch (behavior) {
112774 case MADV_NORMAL:
112775 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
112776@@ -127,6 +131,13 @@ success:
112777 /*
112778 * vm_flags is protected by the mmap_sem held in write mode.
112779 */
112780+
112781+#ifdef CONFIG_PAX_SEGMEXEC
112782+ vma_m = pax_find_mirror_vma(vma);
112783+ if (vma_m)
112784+ vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
112785+#endif
112786+
112787 vma->vm_flags = new_flags;
112788
112789 out:
112790@@ -278,11 +289,27 @@ static long madvise_dontneed(struct vm_area_struct *vma,
112791 struct vm_area_struct **prev,
112792 unsigned long start, unsigned long end)
112793 {
112794+
112795+#ifdef CONFIG_PAX_SEGMEXEC
112796+ struct vm_area_struct *vma_m;
112797+#endif
112798+
112799 *prev = vma;
112800 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
112801 return -EINVAL;
112802
112803 zap_page_range(vma, start, end - start, NULL);
112804+
112805+#ifdef CONFIG_PAX_SEGMEXEC
112806+ vma_m = pax_find_mirror_vma(vma);
112807+ if (vma_m) {
112808+ if (vma_m->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
112809+ return -EINVAL;
112810+
112811+ zap_page_range(vma_m, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
112812+ }
112813+#endif
112814+
112815 return 0;
112816 }
112817
112818@@ -485,6 +512,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
112819 if (end < start)
112820 return error;
112821
112822+#ifdef CONFIG_PAX_SEGMEXEC
112823+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
112824+ if (end > SEGMEXEC_TASK_SIZE)
112825+ return error;
112826+ } else
112827+#endif
112828+
112829+ if (end > TASK_SIZE)
112830+ return error;
112831+
112832 error = 0;
112833 if (end == start)
112834 return error;
112835diff --git a/mm/memory-failure.c b/mm/memory-failure.c
112836index 1f4446a..47abb4e 100644
112837--- a/mm/memory-failure.c
112838+++ b/mm/memory-failure.c
112839@@ -63,7 +63,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
112840
112841 int sysctl_memory_failure_recovery __read_mostly = 1;
112842
112843-atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
112844+atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
112845
112846 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
112847
112848@@ -200,7 +200,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
112849 pfn, t->comm, t->pid);
112850 si.si_signo = SIGBUS;
112851 si.si_errno = 0;
112852- si.si_addr = (void *)addr;
112853+ si.si_addr = (void __user *)addr;
112854 #ifdef __ARCH_SI_TRAPNO
112855 si.si_trapno = trapno;
112856 #endif
112857@@ -797,7 +797,7 @@ static struct page_state {
112858 unsigned long res;
112859 enum mf_action_page_type type;
112860 int (*action)(struct page *p, unsigned long pfn);
112861-} error_states[] = {
112862+} __do_const error_states[] = {
112863 { reserved, reserved, MF_MSG_KERNEL, me_kernel },
112864 /*
112865 * free pages are specially detected outside this table:
112866@@ -1100,7 +1100,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
112867 nr_pages = 1 << compound_order(hpage);
112868 else /* normal page or thp */
112869 nr_pages = 1;
112870- atomic_long_add(nr_pages, &num_poisoned_pages);
112871+ atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
112872
112873 /*
112874 * We need/can do nothing about count=0 pages.
112875@@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
112876 if (PageHWPoison(hpage)) {
112877 if ((hwpoison_filter(p) && TestClearPageHWPoison(p))
112878 || (p != hpage && TestSetPageHWPoison(hpage))) {
112879- atomic_long_sub(nr_pages, &num_poisoned_pages);
112880+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112881 unlock_page(hpage);
112882 return 0;
112883 }
112884@@ -1152,7 +1152,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
112885 else
112886 pr_err("MCE: %#lx: thp split failed\n", pfn);
112887 if (TestClearPageHWPoison(p))
112888- atomic_long_sub(nr_pages, &num_poisoned_pages);
112889+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112890 put_page(p);
112891 if (p != hpage)
112892 put_page(hpage);
112893@@ -1214,14 +1214,14 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
112894 */
112895 if (!PageHWPoison(p)) {
112896 printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn);
112897- atomic_long_sub(nr_pages, &num_poisoned_pages);
112898+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112899 unlock_page(hpage);
112900 put_page(hpage);
112901 return 0;
112902 }
112903 if (hwpoison_filter(p)) {
112904 if (TestClearPageHWPoison(p))
112905- atomic_long_sub(nr_pages, &num_poisoned_pages);
112906+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112907 unlock_page(hpage);
112908 put_page(hpage);
112909 return 0;
112910@@ -1450,7 +1450,7 @@ int unpoison_memory(unsigned long pfn)
112911 return 0;
112912 }
112913 if (TestClearPageHWPoison(p))
112914- atomic_long_dec(&num_poisoned_pages);
112915+ atomic_long_dec_unchecked(&num_poisoned_pages);
112916 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
112917 return 0;
112918 }
112919@@ -1464,7 +1464,7 @@ int unpoison_memory(unsigned long pfn)
112920 */
112921 if (TestClearPageHWPoison(page)) {
112922 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
112923- atomic_long_sub(nr_pages, &num_poisoned_pages);
112924+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112925 freeit = 1;
112926 if (PageHuge(page))
112927 clear_page_hwpoison_huge_page(page);
112928@@ -1600,11 +1600,11 @@ static int soft_offline_huge_page(struct page *page, int flags)
112929 if (PageHuge(page)) {
112930 set_page_hwpoison_huge_page(hpage);
112931 dequeue_hwpoisoned_huge_page(hpage);
112932- atomic_long_add(1 << compound_order(hpage),
112933+ atomic_long_add_unchecked(1 << compound_order(hpage),
112934 &num_poisoned_pages);
112935 } else {
112936 SetPageHWPoison(page);
112937- atomic_long_inc(&num_poisoned_pages);
112938+ atomic_long_inc_unchecked(&num_poisoned_pages);
112939 }
112940 }
112941 return ret;
112942@@ -1643,7 +1643,7 @@ static int __soft_offline_page(struct page *page, int flags)
112943 put_page(page);
112944 pr_info("soft_offline: %#lx: invalidated\n", pfn);
112945 SetPageHWPoison(page);
112946- atomic_long_inc(&num_poisoned_pages);
112947+ atomic_long_inc_unchecked(&num_poisoned_pages);
112948 return 0;
112949 }
112950
112951@@ -1664,7 +1664,7 @@ static int __soft_offline_page(struct page *page, int flags)
112952 page_is_file_cache(page));
112953 list_add(&page->lru, &pagelist);
112954 if (!TestSetPageHWPoison(page))
112955- atomic_long_inc(&num_poisoned_pages);
112956+ atomic_long_inc_unchecked(&num_poisoned_pages);
112957 ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL,
112958 MIGRATE_SYNC, MR_MEMORY_FAILURE);
112959 if (ret) {
112960@@ -1680,7 +1680,7 @@ static int __soft_offline_page(struct page *page, int flags)
112961 if (ret > 0)
112962 ret = -EIO;
112963 if (TestClearPageHWPoison(page))
112964- atomic_long_dec(&num_poisoned_pages);
112965+ atomic_long_dec_unchecked(&num_poisoned_pages);
112966 }
112967 } else {
112968 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
112969@@ -1742,11 +1742,11 @@ int soft_offline_page(struct page *page, int flags)
112970 if (PageHuge(page)) {
112971 set_page_hwpoison_huge_page(hpage);
112972 if (!dequeue_hwpoisoned_huge_page(hpage))
112973- atomic_long_add(1 << compound_order(hpage),
112974+ atomic_long_add_unchecked(1 << compound_order(hpage),
112975 &num_poisoned_pages);
112976 } else {
112977 if (!TestSetPageHWPoison(page))
112978- atomic_long_inc(&num_poisoned_pages);
112979+ atomic_long_inc_unchecked(&num_poisoned_pages);
112980 }
112981 }
112982 return ret;
112983diff --git a/mm/memory.c b/mm/memory.c
112984index 388dcf9..82aa351 100644
112985--- a/mm/memory.c
112986+++ b/mm/memory.c
112987@@ -414,6 +414,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
112988 free_pte_range(tlb, pmd, addr);
112989 } while (pmd++, addr = next, addr != end);
112990
112991+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
112992 start &= PUD_MASK;
112993 if (start < floor)
112994 return;
112995@@ -429,6 +430,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
112996 pud_clear(pud);
112997 pmd_free_tlb(tlb, pmd, start);
112998 mm_dec_nr_pmds(tlb->mm);
112999+#endif
113000 }
113001
113002 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
113003@@ -448,6 +450,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
113004 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
113005 } while (pud++, addr = next, addr != end);
113006
113007+#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
113008 start &= PGDIR_MASK;
113009 if (start < floor)
113010 return;
113011@@ -462,6 +465,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
113012 pud = pud_offset(pgd, start);
113013 pgd_clear(pgd);
113014 pud_free_tlb(tlb, pud, start);
113015+#endif
113016+
113017 }
113018
113019 /*
113020@@ -690,7 +695,7 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
113021 /*
113022 * Choose text because data symbols depend on CONFIG_KALLSYMS_ALL=y
113023 */
113024- pr_alert("file:%pD fault:%pf mmap:%pf readpage:%pf\n",
113025+ pr_alert("file:%pD fault:%pX mmap:%pX readpage:%pX\n",
113026 vma->vm_file,
113027 vma->vm_ops ? vma->vm_ops->fault : NULL,
113028 vma->vm_file ? vma->vm_file->f_op->mmap : NULL,
113029@@ -1463,6 +1468,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
113030 page_add_file_rmap(page);
113031 set_pte_at(mm, addr, pte, mk_pte(page, prot));
113032
113033+#ifdef CONFIG_PAX_SEGMEXEC
113034+ pax_mirror_file_pte(vma, addr, page, ptl);
113035+#endif
113036+
113037 retval = 0;
113038 pte_unmap_unlock(pte, ptl);
113039 return retval;
113040@@ -1507,9 +1516,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
113041 if (!page_count(page))
113042 return -EINVAL;
113043 if (!(vma->vm_flags & VM_MIXEDMAP)) {
113044+
113045+#ifdef CONFIG_PAX_SEGMEXEC
113046+ struct vm_area_struct *vma_m;
113047+#endif
113048+
113049 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
113050 BUG_ON(vma->vm_flags & VM_PFNMAP);
113051 vma->vm_flags |= VM_MIXEDMAP;
113052+
113053+#ifdef CONFIG_PAX_SEGMEXEC
113054+ vma_m = pax_find_mirror_vma(vma);
113055+ if (vma_m)
113056+ vma_m->vm_flags |= VM_MIXEDMAP;
113057+#endif
113058+
113059 }
113060 return insert_page(vma, addr, page, vma->vm_page_prot);
113061 }
113062@@ -1592,6 +1613,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
113063 unsigned long pfn)
113064 {
113065 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
113066+ BUG_ON(vma->vm_mirror);
113067
113068 if (addr < vma->vm_start || addr >= vma->vm_end)
113069 return -EFAULT;
113070@@ -1839,7 +1861,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
113071
113072 BUG_ON(pud_huge(*pud));
113073
113074- pmd = pmd_alloc(mm, pud, addr);
113075+ pmd = (mm == &init_mm) ?
113076+ pmd_alloc_kernel(mm, pud, addr) :
113077+ pmd_alloc(mm, pud, addr);
113078 if (!pmd)
113079 return -ENOMEM;
113080 do {
113081@@ -1859,7 +1883,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
113082 unsigned long next;
113083 int err;
113084
113085- pud = pud_alloc(mm, pgd, addr);
113086+ pud = (mm == &init_mm) ?
113087+ pud_alloc_kernel(mm, pgd, addr) :
113088+ pud_alloc(mm, pgd, addr);
113089 if (!pud)
113090 return -ENOMEM;
113091 do {
113092@@ -2040,6 +2066,196 @@ static inline int wp_page_reuse(struct mm_struct *mm,
113093 return VM_FAULT_WRITE;
113094 }
113095
113096+#ifdef CONFIG_PAX_SEGMEXEC
113097+static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
113098+{
113099+ struct mm_struct *mm = vma->vm_mm;
113100+ spinlock_t *ptl;
113101+ pte_t *pte, entry;
113102+
113103+ pte = pte_offset_map_lock(mm, pmd, address, &ptl);
113104+ entry = *pte;
113105+ if (pte_none(entry))
113106+ ;
113107+ else if (!pte_present(entry)) {
113108+ swp_entry_t swapentry;
113109+
113110+ swapentry = pte_to_swp_entry(entry);
113111+ if (!non_swap_entry(swapentry))
113112+ dec_mm_counter_fast(mm, MM_SWAPENTS);
113113+ else if (is_migration_entry(swapentry)) {
113114+ if (PageAnon(migration_entry_to_page(swapentry)))
113115+ dec_mm_counter_fast(mm, MM_ANONPAGES);
113116+ else
113117+ dec_mm_counter_fast(mm, MM_FILEPAGES);
113118+ }
113119+ free_swap_and_cache(swapentry);
113120+ pte_clear_not_present_full(mm, address, pte, 0);
113121+ } else {
113122+ struct page *page;
113123+
113124+ flush_cache_page(vma, address, pte_pfn(entry));
113125+ entry = ptep_clear_flush(vma, address, pte);
113126+ BUG_ON(pte_dirty(entry));
113127+ page = vm_normal_page(vma, address, entry);
113128+ if (page) {
113129+ update_hiwater_rss(mm);
113130+ if (PageAnon(page))
113131+ dec_mm_counter_fast(mm, MM_ANONPAGES);
113132+ else
113133+ dec_mm_counter_fast(mm, MM_FILEPAGES);
113134+ page_remove_rmap(page);
113135+ page_cache_release(page);
113136+ }
113137+ }
113138+ pte_unmap_unlock(pte, ptl);
113139+}
113140+
113141+/* PaX: if vma is mirrored, synchronize the mirror's PTE
113142+ *
113143+ * the ptl of the lower mapped page is held on entry and is not released on exit
113144+ * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
113145+ */
113146+static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
113147+{
113148+ struct mm_struct *mm = vma->vm_mm;
113149+ unsigned long address_m;
113150+ spinlock_t *ptl_m;
113151+ struct vm_area_struct *vma_m;
113152+ pmd_t *pmd_m;
113153+ pte_t *pte_m, entry_m;
113154+
113155+ BUG_ON(!page_m || !PageAnon(page_m));
113156+
113157+ vma_m = pax_find_mirror_vma(vma);
113158+ if (!vma_m)
113159+ return;
113160+
113161+ BUG_ON(!PageLocked(page_m));
113162+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
113163+ address_m = address + SEGMEXEC_TASK_SIZE;
113164+ pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
113165+ pte_m = pte_offset_map(pmd_m, address_m);
113166+ ptl_m = pte_lockptr(mm, pmd_m);
113167+ if (ptl != ptl_m) {
113168+ spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
113169+ if (!pte_none(*pte_m))
113170+ goto out;
113171+ }
113172+
113173+ entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
113174+ page_cache_get(page_m);
113175+ page_add_anon_rmap(page_m, vma_m, address_m);
113176+ inc_mm_counter_fast(mm, MM_ANONPAGES);
113177+ set_pte_at(mm, address_m, pte_m, entry_m);
113178+ update_mmu_cache(vma_m, address_m, pte_m);
113179+out:
113180+ if (ptl != ptl_m)
113181+ spin_unlock(ptl_m);
113182+ pte_unmap(pte_m);
113183+ unlock_page(page_m);
113184+}
113185+
113186+void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
113187+{
113188+ struct mm_struct *mm = vma->vm_mm;
113189+ unsigned long address_m;
113190+ spinlock_t *ptl_m;
113191+ struct vm_area_struct *vma_m;
113192+ pmd_t *pmd_m;
113193+ pte_t *pte_m, entry_m;
113194+
113195+ BUG_ON(!page_m || PageAnon(page_m));
113196+
113197+ vma_m = pax_find_mirror_vma(vma);
113198+ if (!vma_m)
113199+ return;
113200+
113201+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
113202+ address_m = address + SEGMEXEC_TASK_SIZE;
113203+ pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
113204+ pte_m = pte_offset_map(pmd_m, address_m);
113205+ ptl_m = pte_lockptr(mm, pmd_m);
113206+ if (ptl != ptl_m) {
113207+ spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
113208+ if (!pte_none(*pte_m))
113209+ goto out;
113210+ }
113211+
113212+ entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
113213+ page_cache_get(page_m);
113214+ page_add_file_rmap(page_m);
113215+ inc_mm_counter_fast(mm, MM_FILEPAGES);
113216+ set_pte_at(mm, address_m, pte_m, entry_m);
113217+ update_mmu_cache(vma_m, address_m, pte_m);
113218+out:
113219+ if (ptl != ptl_m)
113220+ spin_unlock(ptl_m);
113221+ pte_unmap(pte_m);
113222+}
113223+
113224+static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
113225+{
113226+ struct mm_struct *mm = vma->vm_mm;
113227+ unsigned long address_m;
113228+ spinlock_t *ptl_m;
113229+ struct vm_area_struct *vma_m;
113230+ pmd_t *pmd_m;
113231+ pte_t *pte_m, entry_m;
113232+
113233+ vma_m = pax_find_mirror_vma(vma);
113234+ if (!vma_m)
113235+ return;
113236+
113237+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
113238+ address_m = address + SEGMEXEC_TASK_SIZE;
113239+ pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
113240+ pte_m = pte_offset_map(pmd_m, address_m);
113241+ ptl_m = pte_lockptr(mm, pmd_m);
113242+ if (ptl != ptl_m) {
113243+ spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
113244+ if (!pte_none(*pte_m))
113245+ goto out;
113246+ }
113247+
113248+ entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
113249+ set_pte_at(mm, address_m, pte_m, entry_m);
113250+out:
113251+ if (ptl != ptl_m)
113252+ spin_unlock(ptl_m);
113253+ pte_unmap(pte_m);
113254+}
113255+
113256+static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
113257+{
113258+ struct page *page_m;
113259+ pte_t entry;
113260+
113261+ if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
113262+ goto out;
113263+
113264+ entry = *pte;
113265+ page_m = vm_normal_page(vma, address, entry);
113266+ if (!page_m)
113267+ pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
113268+ else if (PageAnon(page_m)) {
113269+ if (pax_find_mirror_vma(vma)) {
113270+ pte_unmap_unlock(pte, ptl);
113271+ lock_page(page_m);
113272+ pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
113273+ if (pte_same(entry, *pte))
113274+ pax_mirror_anon_pte(vma, address, page_m, ptl);
113275+ else
113276+ unlock_page(page_m);
113277+ }
113278+ } else
113279+ pax_mirror_file_pte(vma, address, page_m, ptl);
113280+
113281+out:
113282+ pte_unmap_unlock(pte, ptl);
113283+}
113284+#endif
113285+
113286 /*
113287 * Handle the case of a page which we actually need to copy to a new page.
113288 *
113289@@ -2094,6 +2310,12 @@ static int wp_page_copy(struct mm_struct *mm, struct vm_area_struct *vma,
113290 */
113291 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
113292 if (likely(pte_same(*page_table, orig_pte))) {
113293+
113294+#ifdef CONFIG_PAX_SEGMEXEC
113295+ if (pax_find_mirror_vma(vma))
113296+ BUG_ON(!trylock_page(new_page));
113297+#endif
113298+
113299 if (old_page) {
113300 if (!PageAnon(old_page)) {
113301 dec_mm_counter_fast(mm, MM_FILEPAGES);
113302@@ -2148,6 +2370,10 @@ static int wp_page_copy(struct mm_struct *mm, struct vm_area_struct *vma,
113303 page_remove_rmap(old_page);
113304 }
113305
113306+#ifdef CONFIG_PAX_SEGMEXEC
113307+ pax_mirror_anon_pte(vma, address, new_page, ptl);
113308+#endif
113309+
113310 /* Free the old page.. */
113311 new_page = old_page;
113312 page_copied = 1;
113313@@ -2579,6 +2805,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
113314 swap_free(entry);
113315 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
113316 try_to_free_swap(page);
113317+
113318+#ifdef CONFIG_PAX_SEGMEXEC
113319+ if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
113320+#endif
113321+
113322 unlock_page(page);
113323 if (page != swapcache) {
113324 /*
113325@@ -2602,6 +2833,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
113326
113327 /* No need to invalidate - it was non-present before */
113328 update_mmu_cache(vma, address, page_table);
113329+
113330+#ifdef CONFIG_PAX_SEGMEXEC
113331+ pax_mirror_anon_pte(vma, address, page, ptl);
113332+#endif
113333+
113334 unlock:
113335 pte_unmap_unlock(page_table, ptl);
113336 out:
113337@@ -2621,40 +2857,6 @@ out_release:
113338 }
113339
113340 /*
113341- * This is like a special single-page "expand_{down|up}wards()",
113342- * except we must first make sure that 'address{-|+}PAGE_SIZE'
113343- * doesn't hit another vma.
113344- */
113345-static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
113346-{
113347- address &= PAGE_MASK;
113348- if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
113349- struct vm_area_struct *prev = vma->vm_prev;
113350-
113351- /*
113352- * Is there a mapping abutting this one below?
113353- *
113354- * That's only ok if it's the same stack mapping
113355- * that has gotten split..
113356- */
113357- if (prev && prev->vm_end == address)
113358- return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
113359-
113360- return expand_downwards(vma, address - PAGE_SIZE);
113361- }
113362- if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
113363- struct vm_area_struct *next = vma->vm_next;
113364-
113365- /* As VM_GROWSDOWN but s/below/above/ */
113366- if (next && next->vm_start == address + PAGE_SIZE)
113367- return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
113368-
113369- return expand_upwards(vma, address + PAGE_SIZE);
113370- }
113371- return 0;
113372-}
113373-
113374-/*
113375 * We enter with non-exclusive mmap_sem (to exclude vma changes,
113376 * but allow concurrent faults), and pte mapped but not yet locked.
113377 * We return with mmap_sem still held, but pte unmapped and unlocked.
113378@@ -2664,31 +2866,29 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
113379 unsigned int flags)
113380 {
113381 struct mem_cgroup *memcg;
113382- struct page *page;
113383+ struct page *page = NULL;
113384 spinlock_t *ptl;
113385 pte_t entry;
113386
113387- pte_unmap(page_table);
113388-
113389 /* File mapping without ->vm_ops ? */
113390- if (vma->vm_flags & VM_SHARED)
113391+ if (vma->vm_flags & VM_SHARED) {
113392+ pte_unmap(page_table);
113393 return VM_FAULT_SIGBUS;
113394+ }
113395
113396- /* Check if we need to add a guard page to the stack */
113397- if (check_stack_guard_page(vma, address) < 0)
113398- return VM_FAULT_SIGSEGV;
113399-
113400- /* Use the zero-page for reads */
113401 if (!(flags & FAULT_FLAG_WRITE) && !mm_forbids_zeropage(mm)) {
113402 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
113403 vma->vm_page_prot));
113404- page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
113405+ ptl = pte_lockptr(mm, pmd);
113406+ spin_lock(ptl);
113407 if (!pte_none(*page_table))
113408 goto unlock;
113409 goto setpte;
113410 }
113411
113412 /* Allocate our own private page. */
113413+ pte_unmap(page_table);
113414+
113415 if (unlikely(anon_vma_prepare(vma)))
113416 goto oom;
113417 page = alloc_zeroed_user_highpage_movable(vma, address);
113418@@ -2713,6 +2913,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
113419 if (!pte_none(*page_table))
113420 goto release;
113421
113422+#ifdef CONFIG_PAX_SEGMEXEC
113423+ if (pax_find_mirror_vma(vma))
113424+ BUG_ON(!trylock_page(page));
113425+#endif
113426+
113427 inc_mm_counter_fast(mm, MM_ANONPAGES);
113428 page_add_new_anon_rmap(page, vma, address);
113429 mem_cgroup_commit_charge(page, memcg, false);
113430@@ -2722,6 +2927,12 @@ setpte:
113431
113432 /* No need to invalidate - it was non-present before */
113433 update_mmu_cache(vma, address, page_table);
113434+
113435+#ifdef CONFIG_PAX_SEGMEXEC
113436+ if (page)
113437+ pax_mirror_anon_pte(vma, address, page, ptl);
113438+#endif
113439+
113440 unlock:
113441 pte_unmap_unlock(page_table, ptl);
113442 return 0;
113443@@ -2954,6 +3165,11 @@ static int do_read_fault(struct mm_struct *mm, struct vm_area_struct *vma,
113444 return ret;
113445 }
113446 do_set_pte(vma, address, fault_page, pte, false, false);
113447+
113448+#ifdef CONFIG_PAX_SEGMEXEC
113449+ pax_mirror_file_pte(vma, address, fault_page, ptl);
113450+#endif
113451+
113452 unlock_page(fault_page);
113453 unlock_out:
113454 pte_unmap_unlock(pte, ptl);
113455@@ -3005,7 +3221,18 @@ static int do_cow_fault(struct mm_struct *mm, struct vm_area_struct *vma,
113456 }
113457 goto uncharge_out;
113458 }
113459+
113460+#ifdef CONFIG_PAX_SEGMEXEC
113461+ if (pax_find_mirror_vma(vma))
113462+ BUG_ON(!trylock_page(new_page));
113463+#endif
113464+
113465 do_set_pte(vma, address, new_page, pte, true, true);
113466+
113467+#ifdef CONFIG_PAX_SEGMEXEC
113468+ pax_mirror_anon_pte(vma, address, new_page, ptl);
113469+#endif
113470+
113471 mem_cgroup_commit_charge(new_page, memcg, false);
113472 lru_cache_add_active_or_unevictable(new_page, vma);
113473 pte_unmap_unlock(pte, ptl);
113474@@ -3063,6 +3290,11 @@ static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma,
113475 return ret;
113476 }
113477 do_set_pte(vma, address, fault_page, pte, true, false);
113478+
113479+#ifdef CONFIG_PAX_SEGMEXEC
113480+ pax_mirror_file_pte(vma, address, fault_page, ptl);
113481+#endif
113482+
113483 pte_unmap_unlock(pte, ptl);
113484
113485 if (set_page_dirty(fault_page))
113486@@ -3288,6 +3520,12 @@ static int handle_pte_fault(struct mm_struct *mm,
113487 if (flags & FAULT_FLAG_WRITE)
113488 flush_tlb_fix_spurious_fault(vma, address);
113489 }
113490+
113491+#ifdef CONFIG_PAX_SEGMEXEC
113492+ pax_mirror_pte(vma, address, pte, pmd, ptl);
113493+ return 0;
113494+#endif
113495+
113496 unlock:
113497 pte_unmap_unlock(pte, ptl);
113498 return 0;
113499@@ -3307,9 +3545,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
113500 pmd_t *pmd;
113501 pte_t *pte;
113502
113503+#ifdef CONFIG_PAX_SEGMEXEC
113504+ struct vm_area_struct *vma_m;
113505+#endif
113506+
113507 if (unlikely(is_vm_hugetlb_page(vma)))
113508 return hugetlb_fault(mm, vma, address, flags);
113509
113510+#ifdef CONFIG_PAX_SEGMEXEC
113511+ vma_m = pax_find_mirror_vma(vma);
113512+ if (vma_m) {
113513+ unsigned long address_m;
113514+ pgd_t *pgd_m;
113515+ pud_t *pud_m;
113516+ pmd_t *pmd_m;
113517+
113518+ if (vma->vm_start > vma_m->vm_start) {
113519+ address_m = address;
113520+ address -= SEGMEXEC_TASK_SIZE;
113521+ vma = vma_m;
113522+ } else
113523+ address_m = address + SEGMEXEC_TASK_SIZE;
113524+
113525+ pgd_m = pgd_offset(mm, address_m);
113526+ pud_m = pud_alloc(mm, pgd_m, address_m);
113527+ if (!pud_m)
113528+ return VM_FAULT_OOM;
113529+ pmd_m = pmd_alloc(mm, pud_m, address_m);
113530+ if (!pmd_m)
113531+ return VM_FAULT_OOM;
113532+ if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
113533+ return VM_FAULT_OOM;
113534+ pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
113535+ }
113536+#endif
113537+
113538 pgd = pgd_offset(mm, address);
113539 pud = pud_alloc(mm, pgd, address);
113540 if (!pud)
113541@@ -3444,6 +3714,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
113542 spin_unlock(&mm->page_table_lock);
113543 return 0;
113544 }
113545+
113546+int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
113547+{
113548+ pud_t *new = pud_alloc_one(mm, address);
113549+ if (!new)
113550+ return -ENOMEM;
113551+
113552+ smp_wmb(); /* See comment in __pte_alloc */
113553+
113554+ spin_lock(&mm->page_table_lock);
113555+ if (pgd_present(*pgd)) /* Another has populated it */
113556+ pud_free(mm, new);
113557+ else
113558+ pgd_populate_kernel(mm, pgd, new);
113559+ spin_unlock(&mm->page_table_lock);
113560+ return 0;
113561+}
113562 #endif /* __PAGETABLE_PUD_FOLDED */
113563
113564 #ifndef __PAGETABLE_PMD_FOLDED
113565@@ -3476,6 +3763,32 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
113566 spin_unlock(&mm->page_table_lock);
113567 return 0;
113568 }
113569+
113570+int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
113571+{
113572+ pmd_t *new = pmd_alloc_one(mm, address);
113573+ if (!new)
113574+ return -ENOMEM;
113575+
113576+ smp_wmb(); /* See comment in __pte_alloc */
113577+
113578+ spin_lock(&mm->page_table_lock);
113579+#ifndef __ARCH_HAS_4LEVEL_HACK
113580+ if (!pud_present(*pud)) {
113581+ mm_inc_nr_pmds(mm);
113582+ pud_populate_kernel(mm, pud, new);
113583+ } else /* Another has populated it */
113584+ pmd_free(mm, new);
113585+#else
113586+ if (!pgd_present(*pud)) {
113587+ mm_inc_nr_pmds(mm);
113588+ pgd_populate_kernel(mm, pud, new);
113589+ } else /* Another has populated it */
113590+ pmd_free(mm, new);
113591+#endif /* __ARCH_HAS_4LEVEL_HACK */
113592+ spin_unlock(&mm->page_table_lock);
113593+ return 0;
113594+}
113595 #endif /* __PAGETABLE_PMD_FOLDED */
113596
113597 static int __follow_pte(struct mm_struct *mm, unsigned long address,
113598@@ -3585,8 +3898,8 @@ out:
113599 return ret;
113600 }
113601
113602-int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
113603- void *buf, int len, int write)
113604+ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
113605+ void *buf, size_t len, int write)
113606 {
113607 resource_size_t phys_addr;
113608 unsigned long prot = 0;
113609@@ -3612,8 +3925,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
113610 * Access another process' address space as given in mm. If non-NULL, use the
113611 * given task for page fault accounting.
113612 */
113613-static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
113614- unsigned long addr, void *buf, int len, int write)
113615+static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
113616+ unsigned long addr, void *buf, size_t len, int write)
113617 {
113618 struct vm_area_struct *vma;
113619 void *old_buf = buf;
113620@@ -3621,7 +3934,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
113621 down_read(&mm->mmap_sem);
113622 /* ignore errors, just check how much was successfully transferred */
113623 while (len) {
113624- int bytes, ret, offset;
113625+ ssize_t bytes, ret, offset;
113626 void *maddr;
113627 struct page *page = NULL;
113628
113629@@ -3682,8 +3995,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
113630 *
113631 * The caller must hold a reference on @mm.
113632 */
113633-int access_remote_vm(struct mm_struct *mm, unsigned long addr,
113634- void *buf, int len, int write)
113635+ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
113636+ void *buf, size_t len, int write)
113637 {
113638 return __access_remote_vm(NULL, mm, addr, buf, len, write);
113639 }
113640@@ -3693,11 +4006,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
113641 * Source/target buffer must be kernel space,
113642 * Do not walk the page table directly, use get_user_pages
113643 */
113644-int access_process_vm(struct task_struct *tsk, unsigned long addr,
113645- void *buf, int len, int write)
113646+ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
113647+ void *buf, size_t len, int write)
113648 {
113649 struct mm_struct *mm;
113650- int ret;
113651+ ssize_t ret;
113652
113653 mm = get_task_mm(tsk);
113654 if (!mm)
113655diff --git a/mm/mempolicy.c b/mm/mempolicy.c
113656index 99d4c1d..a577817 100644
113657--- a/mm/mempolicy.c
113658+++ b/mm/mempolicy.c
113659@@ -703,6 +703,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
113660 unsigned long vmstart;
113661 unsigned long vmend;
113662
113663+#ifdef CONFIG_PAX_SEGMEXEC
113664+ struct vm_area_struct *vma_m;
113665+#endif
113666+
113667 vma = find_vma(mm, start);
113668 if (!vma || vma->vm_start > start)
113669 return -EFAULT;
113670@@ -746,6 +750,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
113671 err = vma_replace_policy(vma, new_pol);
113672 if (err)
113673 goto out;
113674+
113675+#ifdef CONFIG_PAX_SEGMEXEC
113676+ vma_m = pax_find_mirror_vma(vma);
113677+ if (vma_m) {
113678+ err = vma_replace_policy(vma_m, new_pol);
113679+ if (err)
113680+ goto out;
113681+ }
113682+#endif
113683+
113684 }
113685
113686 out:
113687@@ -1161,6 +1175,17 @@ static long do_mbind(unsigned long start, unsigned long len,
113688
113689 if (end < start)
113690 return -EINVAL;
113691+
113692+#ifdef CONFIG_PAX_SEGMEXEC
113693+ if (mm->pax_flags & MF_PAX_SEGMEXEC) {
113694+ if (end > SEGMEXEC_TASK_SIZE)
113695+ return -EINVAL;
113696+ } else
113697+#endif
113698+
113699+ if (end > TASK_SIZE)
113700+ return -EINVAL;
113701+
113702 if (end == start)
113703 return 0;
113704
113705@@ -1386,8 +1411,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
113706 */
113707 tcred = __task_cred(task);
113708 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
113709- !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
113710- !capable(CAP_SYS_NICE)) {
113711+ !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
113712 rcu_read_unlock();
113713 err = -EPERM;
113714 goto out_put;
113715@@ -1418,6 +1442,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
113716 goto out;
113717 }
113718
113719+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
113720+ if (mm != current->mm &&
113721+ (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
113722+ mmput(mm);
113723+ err = -EPERM;
113724+ goto out;
113725+ }
113726+#endif
113727+
113728 err = do_migrate_pages(mm, old, new,
113729 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
113730
113731diff --git a/mm/migrate.c b/mm/migrate.c
113732index fcb6204..b3f1a44 100644
113733--- a/mm/migrate.c
113734+++ b/mm/migrate.c
113735@@ -1501,8 +1501,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
113736 */
113737 tcred = __task_cred(task);
113738 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
113739- !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
113740- !capable(CAP_SYS_NICE)) {
113741+ !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
113742 rcu_read_unlock();
113743 err = -EPERM;
113744 goto out;
113745diff --git a/mm/mlock.c b/mm/mlock.c
113746index 6fd2cf1..cbae765 100644
113747--- a/mm/mlock.c
113748+++ b/mm/mlock.c
113749@@ -14,6 +14,7 @@
113750 #include <linux/pagevec.h>
113751 #include <linux/mempolicy.h>
113752 #include <linux/syscalls.h>
113753+#include <linux/security.h>
113754 #include <linux/sched.h>
113755 #include <linux/export.h>
113756 #include <linux/rmap.h>
113757@@ -557,7 +558,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
113758 {
113759 unsigned long nstart, end, tmp;
113760 struct vm_area_struct * vma, * prev;
113761- int error;
113762+ int error = 0;
113763
113764 VM_BUG_ON(start & ~PAGE_MASK);
113765 VM_BUG_ON(len != PAGE_ALIGN(len));
113766@@ -566,6 +567,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
113767 return -EINVAL;
113768 if (end == start)
113769 return 0;
113770+ if (end > TASK_SIZE)
113771+ return -EINVAL;
113772+
113773 vma = find_vma(current->mm, start);
113774 if (!vma || vma->vm_start > start)
113775 return -ENOMEM;
113776@@ -577,6 +581,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
113777 for (nstart = start ; ; ) {
113778 vm_flags_t newflags;
113779
113780+#ifdef CONFIG_PAX_SEGMEXEC
113781+ if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
113782+ break;
113783+#endif
113784+
113785 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
113786
113787 newflags = vma->vm_flags & ~VM_LOCKED;
113788@@ -627,6 +636,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
113789 locked += current->mm->locked_vm;
113790
113791 /* check against resource limits */
113792+ gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
113793 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
113794 error = do_mlock(start, len, 1);
113795
113796@@ -668,6 +678,11 @@ static int do_mlockall(int flags)
113797 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
113798 vm_flags_t newflags;
113799
113800+#ifdef CONFIG_PAX_SEGMEXEC
113801+ if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
113802+ break;
113803+#endif
113804+
113805 newflags = vma->vm_flags & ~VM_LOCKED;
113806 if (flags & MCL_CURRENT)
113807 newflags |= VM_LOCKED;
113808@@ -699,8 +714,10 @@ SYSCALL_DEFINE1(mlockall, int, flags)
113809 lock_limit >>= PAGE_SHIFT;
113810
113811 ret = -ENOMEM;
113812+
113813+ gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
113814+
113815 down_write(&current->mm->mmap_sem);
113816-
113817 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
113818 capable(CAP_IPC_LOCK))
113819 ret = do_mlockall(flags);
113820diff --git a/mm/mm_init.c b/mm/mm_init.c
113821index fdadf91..5f527d1 100644
113822--- a/mm/mm_init.c
113823+++ b/mm/mm_init.c
113824@@ -170,7 +170,7 @@ static int __meminit mm_compute_batch_notifier(struct notifier_block *self,
113825 return NOTIFY_OK;
113826 }
113827
113828-static struct notifier_block compute_batch_nb __meminitdata = {
113829+static struct notifier_block compute_batch_nb __meminitconst = {
113830 .notifier_call = mm_compute_batch_notifier,
113831 .priority = IPC_CALLBACK_PRI, /* use lowest priority */
113832 };
113833diff --git a/mm/mmap.c b/mm/mmap.c
113834index aa632ad..13456342 100644
113835--- a/mm/mmap.c
113836+++ b/mm/mmap.c
113837@@ -41,6 +41,7 @@
113838 #include <linux/notifier.h>
113839 #include <linux/memory.h>
113840 #include <linux/printk.h>
113841+#include <linux/random.h>
113842
113843 #include <asm/uaccess.h>
113844 #include <asm/cacheflush.h>
113845@@ -57,6 +58,16 @@
113846 #define arch_rebalance_pgtables(addr, len) (addr)
113847 #endif
113848
113849+static inline void verify_mm_writelocked(struct mm_struct *mm)
113850+{
113851+#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
113852+ if (unlikely(down_read_trylock(&mm->mmap_sem))) {
113853+ up_read(&mm->mmap_sem);
113854+ BUG();
113855+ }
113856+#endif
113857+}
113858+
113859 static void unmap_region(struct mm_struct *mm,
113860 struct vm_area_struct *vma, struct vm_area_struct *prev,
113861 unsigned long start, unsigned long end);
113862@@ -76,16 +87,25 @@ static void unmap_region(struct mm_struct *mm,
113863 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
113864 *
113865 */
113866-pgprot_t protection_map[16] = {
113867+pgprot_t protection_map[16] __read_only = {
113868 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
113869 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
113870 };
113871
113872-pgprot_t vm_get_page_prot(unsigned long vm_flags)
113873+pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
113874 {
113875- return __pgprot(pgprot_val(protection_map[vm_flags &
113876+ pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
113877 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
113878 pgprot_val(arch_vm_get_page_prot(vm_flags)));
113879+
113880+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
113881+ if (!(__supported_pte_mask & _PAGE_NX) &&
113882+ (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
113883+ (vm_flags & (VM_READ | VM_WRITE)))
113884+ prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
113885+#endif
113886+
113887+ return prot;
113888 }
113889 EXPORT_SYMBOL(vm_get_page_prot);
113890
113891@@ -114,6 +134,7 @@ unsigned long sysctl_overcommit_kbytes __read_mostly;
113892 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
113893 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
113894 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
113895+unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
113896 /*
113897 * Make sure vm_committed_as in one cacheline and not cacheline shared with
113898 * other variables. It can be updated by several CPUs frequently.
113899@@ -271,6 +292,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
113900 struct vm_area_struct *next = vma->vm_next;
113901
113902 might_sleep();
113903+ BUG_ON(vma->vm_mirror);
113904 if (vma->vm_ops && vma->vm_ops->close)
113905 vma->vm_ops->close(vma);
113906 if (vma->vm_file)
113907@@ -284,6 +306,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len);
113908
113909 SYSCALL_DEFINE1(brk, unsigned long, brk)
113910 {
113911+ unsigned long rlim;
113912 unsigned long retval;
113913 unsigned long newbrk, oldbrk;
113914 struct mm_struct *mm = current->mm;
113915@@ -314,7 +337,13 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
113916 * segment grow beyond its set limit the in case where the limit is
113917 * not page aligned -Ram Gupta
113918 */
113919- if (check_data_rlimit(rlimit(RLIMIT_DATA), brk, mm->start_brk,
113920+ rlim = rlimit(RLIMIT_DATA);
113921+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
113922+ /* force a minimum 16MB brk heap on setuid/setgid binaries */
113923+ if (rlim < PAGE_SIZE && (get_dumpable(mm) != SUID_DUMP_USER) && gr_is_global_nonroot(current_uid()))
113924+ rlim = 4096 * PAGE_SIZE;
113925+#endif
113926+ if (check_data_rlimit(rlim, brk, mm->start_brk,
113927 mm->end_data, mm->start_data))
113928 goto out;
113929
113930@@ -967,6 +996,12 @@ static int
113931 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
113932 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
113933 {
113934+
113935+#ifdef CONFIG_PAX_SEGMEXEC
113936+ if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
113937+ return 0;
113938+#endif
113939+
113940 if (is_mergeable_vma(vma, file, vm_flags) &&
113941 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
113942 if (vma->vm_pgoff == vm_pgoff)
113943@@ -986,6 +1021,12 @@ static int
113944 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
113945 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
113946 {
113947+
113948+#ifdef CONFIG_PAX_SEGMEXEC
113949+ if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
113950+ return 0;
113951+#endif
113952+
113953 if (is_mergeable_vma(vma, file, vm_flags) &&
113954 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
113955 pgoff_t vm_pglen;
113956@@ -1035,6 +1076,13 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113957 struct vm_area_struct *area, *next;
113958 int err;
113959
113960+#ifdef CONFIG_PAX_SEGMEXEC
113961+ unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
113962+ struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
113963+
113964+ BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
113965+#endif
113966+
113967 /*
113968 * We later require that vma->vm_flags == vm_flags,
113969 * so this tests vma->vm_flags & VM_SPECIAL, too.
113970@@ -1050,6 +1098,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113971 if (next && next->vm_end == end) /* cases 6, 7, 8 */
113972 next = next->vm_next;
113973
113974+#ifdef CONFIG_PAX_SEGMEXEC
113975+ if (prev)
113976+ prev_m = pax_find_mirror_vma(prev);
113977+ if (area)
113978+ area_m = pax_find_mirror_vma(area);
113979+ if (next)
113980+ next_m = pax_find_mirror_vma(next);
113981+#endif
113982+
113983 /*
113984 * Can it merge with the predecessor?
113985 */
113986@@ -1069,9 +1126,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113987 /* cases 1, 6 */
113988 err = vma_adjust(prev, prev->vm_start,
113989 next->vm_end, prev->vm_pgoff, NULL);
113990- } else /* cases 2, 5, 7 */
113991+
113992+#ifdef CONFIG_PAX_SEGMEXEC
113993+ if (!err && prev_m)
113994+ err = vma_adjust(prev_m, prev_m->vm_start,
113995+ next_m->vm_end, prev_m->vm_pgoff, NULL);
113996+#endif
113997+
113998+ } else { /* cases 2, 5, 7 */
113999 err = vma_adjust(prev, prev->vm_start,
114000 end, prev->vm_pgoff, NULL);
114001+
114002+#ifdef CONFIG_PAX_SEGMEXEC
114003+ if (!err && prev_m)
114004+ err = vma_adjust(prev_m, prev_m->vm_start,
114005+ end_m, prev_m->vm_pgoff, NULL);
114006+#endif
114007+
114008+ }
114009 if (err)
114010 return NULL;
114011 khugepaged_enter_vma_merge(prev, vm_flags);
114012@@ -1085,12 +1157,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
114013 mpol_equal(policy, vma_policy(next)) &&
114014 can_vma_merge_before(next, vm_flags,
114015 anon_vma, file, pgoff+pglen)) {
114016- if (prev && addr < prev->vm_end) /* case 4 */
114017+ if (prev && addr < prev->vm_end) { /* case 4 */
114018 err = vma_adjust(prev, prev->vm_start,
114019 addr, prev->vm_pgoff, NULL);
114020- else /* cases 3, 8 */
114021+
114022+#ifdef CONFIG_PAX_SEGMEXEC
114023+ if (!err && prev_m)
114024+ err = vma_adjust(prev_m, prev_m->vm_start,
114025+ addr_m, prev_m->vm_pgoff, NULL);
114026+#endif
114027+
114028+ } else { /* cases 3, 8 */
114029 err = vma_adjust(area, addr, next->vm_end,
114030 next->vm_pgoff - pglen, NULL);
114031+
114032+#ifdef CONFIG_PAX_SEGMEXEC
114033+ if (!err && area_m)
114034+ err = vma_adjust(area_m, addr_m, next_m->vm_end,
114035+ next_m->vm_pgoff - pglen, NULL);
114036+#endif
114037+
114038+ }
114039 if (err)
114040 return NULL;
114041 khugepaged_enter_vma_merge(area, vm_flags);
114042@@ -1199,8 +1286,10 @@ none:
114043 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
114044 struct file *file, long pages)
114045 {
114046- const unsigned long stack_flags
114047- = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
114048+
114049+#ifdef CONFIG_PAX_RANDMMAP
114050+ if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
114051+#endif
114052
114053 mm->total_vm += pages;
114054
114055@@ -1208,7 +1297,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
114056 mm->shared_vm += pages;
114057 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
114058 mm->exec_vm += pages;
114059- } else if (flags & stack_flags)
114060+ } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
114061 mm->stack_vm += pages;
114062 }
114063 #endif /* CONFIG_PROC_FS */
114064@@ -1238,6 +1327,7 @@ static inline int mlock_future_check(struct mm_struct *mm,
114065 locked += mm->locked_vm;
114066 lock_limit = rlimit(RLIMIT_MEMLOCK);
114067 lock_limit >>= PAGE_SHIFT;
114068+ gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
114069 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
114070 return -EAGAIN;
114071 }
114072@@ -1267,7 +1357,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
114073 * (the exception is when the underlying filesystem is noexec
114074 * mounted, in which case we dont add PROT_EXEC.)
114075 */
114076- if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
114077+ if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
114078 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
114079 prot |= PROT_EXEC;
114080
114081@@ -1290,7 +1380,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
114082 /* Obtain the address to map to. we verify (or select) it and ensure
114083 * that it represents a valid section of the address space.
114084 */
114085- addr = get_unmapped_area(file, addr, len, pgoff, flags);
114086+ addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
114087 if (addr & ~PAGE_MASK)
114088 return addr;
114089
114090@@ -1301,6 +1391,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
114091 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
114092 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
114093
114094+#ifdef CONFIG_PAX_MPROTECT
114095+ if (mm->pax_flags & MF_PAX_MPROTECT) {
114096+
114097+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
114098+ if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
114099+ mm->binfmt->handle_mmap)
114100+ mm->binfmt->handle_mmap(file);
114101+#endif
114102+
114103+#ifndef CONFIG_PAX_MPROTECT_COMPAT
114104+ if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
114105+ gr_log_rwxmmap(file);
114106+
114107+#ifdef CONFIG_PAX_EMUPLT
114108+ vm_flags &= ~VM_EXEC;
114109+#else
114110+ return -EPERM;
114111+#endif
114112+
114113+ }
114114+
114115+ if (!(vm_flags & VM_EXEC))
114116+ vm_flags &= ~VM_MAYEXEC;
114117+#else
114118+ if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
114119+ vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
114120+#endif
114121+ else
114122+ vm_flags &= ~VM_MAYWRITE;
114123+ }
114124+#endif
114125+
114126+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
114127+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
114128+ vm_flags &= ~VM_PAGEEXEC;
114129+#endif
114130+
114131 if (flags & MAP_LOCKED)
114132 if (!can_do_mlock())
114133 return -EPERM;
114134@@ -1388,6 +1515,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
114135 vm_flags |= VM_NORESERVE;
114136 }
114137
114138+ if (!gr_acl_handle_mmap(file, prot))
114139+ return -EACCES;
114140+
114141 addr = mmap_region(file, addr, len, vm_flags, pgoff);
114142 if (!IS_ERR_VALUE(addr) &&
114143 ((vm_flags & VM_LOCKED) ||
114144@@ -1481,7 +1611,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
114145 vm_flags_t vm_flags = vma->vm_flags;
114146
114147 /* If it was private or non-writable, the write bit is already clear */
114148- if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
114149+ if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
114150 return 0;
114151
114152 /* The backer wishes to know when pages are first written to? */
114153@@ -1532,7 +1662,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
114154 struct rb_node **rb_link, *rb_parent;
114155 unsigned long charged = 0;
114156
114157+#ifdef CONFIG_PAX_SEGMEXEC
114158+ struct vm_area_struct *vma_m = NULL;
114159+#endif
114160+
114161+ /*
114162+ * mm->mmap_sem is required to protect against another thread
114163+ * changing the mappings in case we sleep.
114164+ */
114165+ verify_mm_writelocked(mm);
114166+
114167 /* Check against address space limit. */
114168+
114169+#ifdef CONFIG_PAX_RANDMMAP
114170+ if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
114171+#endif
114172+
114173 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
114174 unsigned long nr_pages;
114175
114176@@ -1555,6 +1700,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
114177 &rb_parent)) {
114178 if (do_munmap(mm, addr, len))
114179 return -ENOMEM;
114180+ BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
114181 }
114182
114183 /*
114184@@ -1586,6 +1732,16 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
114185 goto unacct_error;
114186 }
114187
114188+#ifdef CONFIG_PAX_SEGMEXEC
114189+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
114190+ vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
114191+ if (!vma_m) {
114192+ error = -ENOMEM;
114193+ goto free_vma;
114194+ }
114195+ }
114196+#endif
114197+
114198 vma->vm_mm = mm;
114199 vma->vm_start = addr;
114200 vma->vm_end = addr + len;
114201@@ -1616,6 +1772,13 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
114202 if (error)
114203 goto unmap_and_free_vma;
114204
114205+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
114206+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
114207+ vma->vm_flags |= VM_PAGEEXEC;
114208+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
114209+ }
114210+#endif
114211+
114212 /* Can addr have changed??
114213 *
114214 * Answer: Yes, several device drivers can do it in their
114215@@ -1634,6 +1797,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
114216 }
114217
114218 vma_link(mm, vma, prev, rb_link, rb_parent);
114219+
114220+#ifdef CONFIG_PAX_SEGMEXEC
114221+ if (vma_m)
114222+ BUG_ON(pax_mirror_vma(vma_m, vma));
114223+#endif
114224+
114225 /* Once vma denies write, undo our temporary denial count */
114226 if (file) {
114227 if (vm_flags & VM_SHARED)
114228@@ -1646,6 +1815,7 @@ out:
114229 perf_event_mmap(vma);
114230
114231 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
114232+ track_exec_limit(mm, addr, addr + len, vm_flags);
114233 if (vm_flags & VM_LOCKED) {
114234 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
114235 vma == get_gate_vma(current->mm)))
114236@@ -1683,6 +1853,12 @@ allow_write_and_free_vma:
114237 if (vm_flags & VM_DENYWRITE)
114238 allow_write_access(file);
114239 free_vma:
114240+
114241+#ifdef CONFIG_PAX_SEGMEXEC
114242+ if (vma_m)
114243+ kmem_cache_free(vm_area_cachep, vma_m);
114244+#endif
114245+
114246 kmem_cache_free(vm_area_cachep, vma);
114247 unacct_error:
114248 if (charged)
114249@@ -1690,7 +1866,63 @@ unacct_error:
114250 return error;
114251 }
114252
114253-unsigned long unmapped_area(struct vm_unmapped_area_info *info)
114254+#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
114255+unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
114256+{
114257+ if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
114258+ return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
114259+
114260+ return 0;
114261+}
114262+#endif
114263+
114264+bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
114265+{
114266+ if (!vma) {
114267+#ifdef CONFIG_STACK_GROWSUP
114268+ if (addr > sysctl_heap_stack_gap)
114269+ vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
114270+ else
114271+ vma = find_vma(current->mm, 0);
114272+ if (vma && (vma->vm_flags & VM_GROWSUP))
114273+ return false;
114274+#endif
114275+ return true;
114276+ }
114277+
114278+ if (addr + len > vma->vm_start)
114279+ return false;
114280+
114281+ if (vma->vm_flags & VM_GROWSDOWN)
114282+ return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
114283+#ifdef CONFIG_STACK_GROWSUP
114284+ else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
114285+ return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
114286+#endif
114287+ else if (offset)
114288+ return offset <= vma->vm_start - addr - len;
114289+
114290+ return true;
114291+}
114292+
114293+unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
114294+{
114295+ if (vma->vm_start < len)
114296+ return -ENOMEM;
114297+
114298+ if (!(vma->vm_flags & VM_GROWSDOWN)) {
114299+ if (offset <= vma->vm_start - len)
114300+ return vma->vm_start - len - offset;
114301+ else
114302+ return -ENOMEM;
114303+ }
114304+
114305+ if (sysctl_heap_stack_gap <= vma->vm_start - len)
114306+ return vma->vm_start - len - sysctl_heap_stack_gap;
114307+ return -ENOMEM;
114308+}
114309+
114310+unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
114311 {
114312 /*
114313 * We implement the search by looking for an rbtree node that
114314@@ -1738,11 +1970,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
114315 }
114316 }
114317
114318- gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
114319+ gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
114320 check_current:
114321 /* Check if current node has a suitable gap */
114322 if (gap_start > high_limit)
114323 return -ENOMEM;
114324+
114325+ if (gap_end - gap_start > info->threadstack_offset)
114326+ gap_start += info->threadstack_offset;
114327+ else
114328+ gap_start = gap_end;
114329+
114330+ if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
114331+ if (gap_end - gap_start > sysctl_heap_stack_gap)
114332+ gap_start += sysctl_heap_stack_gap;
114333+ else
114334+ gap_start = gap_end;
114335+ }
114336+ if (vma->vm_flags & VM_GROWSDOWN) {
114337+ if (gap_end - gap_start > sysctl_heap_stack_gap)
114338+ gap_end -= sysctl_heap_stack_gap;
114339+ else
114340+ gap_end = gap_start;
114341+ }
114342 if (gap_end >= low_limit && gap_end - gap_start >= length)
114343 goto found;
114344
114345@@ -1792,7 +2042,7 @@ found:
114346 return gap_start;
114347 }
114348
114349-unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
114350+unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
114351 {
114352 struct mm_struct *mm = current->mm;
114353 struct vm_area_struct *vma;
114354@@ -1846,6 +2096,24 @@ check_current:
114355 gap_end = vma->vm_start;
114356 if (gap_end < low_limit)
114357 return -ENOMEM;
114358+
114359+ if (gap_end - gap_start > info->threadstack_offset)
114360+ gap_end -= info->threadstack_offset;
114361+ else
114362+ gap_end = gap_start;
114363+
114364+ if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
114365+ if (gap_end - gap_start > sysctl_heap_stack_gap)
114366+ gap_start += sysctl_heap_stack_gap;
114367+ else
114368+ gap_start = gap_end;
114369+ }
114370+ if (vma->vm_flags & VM_GROWSDOWN) {
114371+ if (gap_end - gap_start > sysctl_heap_stack_gap)
114372+ gap_end -= sysctl_heap_stack_gap;
114373+ else
114374+ gap_end = gap_start;
114375+ }
114376 if (gap_start <= high_limit && gap_end - gap_start >= length)
114377 goto found;
114378
114379@@ -1909,6 +2177,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
114380 struct mm_struct *mm = current->mm;
114381 struct vm_area_struct *vma;
114382 struct vm_unmapped_area_info info;
114383+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
114384
114385 if (len > TASK_SIZE - mmap_min_addr)
114386 return -ENOMEM;
114387@@ -1916,11 +2185,15 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
114388 if (flags & MAP_FIXED)
114389 return addr;
114390
114391+#ifdef CONFIG_PAX_RANDMMAP
114392+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
114393+#endif
114394+
114395 if (addr) {
114396 addr = PAGE_ALIGN(addr);
114397 vma = find_vma(mm, addr);
114398 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
114399- (!vma || addr + len <= vma->vm_start))
114400+ check_heap_stack_gap(vma, addr, len, offset))
114401 return addr;
114402 }
114403
114404@@ -1929,6 +2202,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
114405 info.low_limit = mm->mmap_base;
114406 info.high_limit = TASK_SIZE;
114407 info.align_mask = 0;
114408+ info.threadstack_offset = offset;
114409 return vm_unmapped_area(&info);
114410 }
114411 #endif
114412@@ -1947,6 +2221,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
114413 struct mm_struct *mm = current->mm;
114414 unsigned long addr = addr0;
114415 struct vm_unmapped_area_info info;
114416+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
114417
114418 /* requested length too big for entire address space */
114419 if (len > TASK_SIZE - mmap_min_addr)
114420@@ -1955,12 +2230,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
114421 if (flags & MAP_FIXED)
114422 return addr;
114423
114424+#ifdef CONFIG_PAX_RANDMMAP
114425+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
114426+#endif
114427+
114428 /* requesting a specific address */
114429 if (addr) {
114430 addr = PAGE_ALIGN(addr);
114431 vma = find_vma(mm, addr);
114432 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
114433- (!vma || addr + len <= vma->vm_start))
114434+ check_heap_stack_gap(vma, addr, len, offset))
114435 return addr;
114436 }
114437
114438@@ -1969,6 +2248,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
114439 info.low_limit = max(PAGE_SIZE, mmap_min_addr);
114440 info.high_limit = mm->mmap_base;
114441 info.align_mask = 0;
114442+ info.threadstack_offset = offset;
114443 addr = vm_unmapped_area(&info);
114444
114445 /*
114446@@ -1981,6 +2261,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
114447 VM_BUG_ON(addr != -ENOMEM);
114448 info.flags = 0;
114449 info.low_limit = TASK_UNMAPPED_BASE;
114450+
114451+#ifdef CONFIG_PAX_RANDMMAP
114452+ if (mm->pax_flags & MF_PAX_RANDMMAP)
114453+ info.low_limit += mm->delta_mmap;
114454+#endif
114455+
114456 info.high_limit = TASK_SIZE;
114457 addr = vm_unmapped_area(&info);
114458 }
114459@@ -2081,6 +2367,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
114460 return vma;
114461 }
114462
114463+#ifdef CONFIG_PAX_SEGMEXEC
114464+struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
114465+{
114466+ struct vm_area_struct *vma_m;
114467+
114468+ BUG_ON(!vma || vma->vm_start >= vma->vm_end);
114469+ if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
114470+ BUG_ON(vma->vm_mirror);
114471+ return NULL;
114472+ }
114473+ BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
114474+ vma_m = vma->vm_mirror;
114475+ BUG_ON(!vma_m || vma_m->vm_mirror != vma);
114476+ BUG_ON(vma->vm_file != vma_m->vm_file);
114477+ BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
114478+ BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
114479+ BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
114480+ BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
114481+ return vma_m;
114482+}
114483+#endif
114484+
114485 /*
114486 * Verify that the stack growth is acceptable and
114487 * update accounting. This is shared with both the
114488@@ -2098,8 +2406,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
114489
114490 /* Stack limit test */
114491 actual_size = size;
114492- if (size && (vma->vm_flags & (VM_GROWSUP | VM_GROWSDOWN)))
114493- actual_size -= PAGE_SIZE;
114494+ gr_learn_resource(current, RLIMIT_STACK, actual_size, 1);
114495 if (actual_size > READ_ONCE(rlim[RLIMIT_STACK].rlim_cur))
114496 return -ENOMEM;
114497
114498@@ -2110,6 +2417,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
114499 locked = mm->locked_vm + grow;
114500 limit = READ_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
114501 limit >>= PAGE_SHIFT;
114502+ gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
114503 if (locked > limit && !capable(CAP_IPC_LOCK))
114504 return -ENOMEM;
114505 }
114506@@ -2139,37 +2447,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
114507 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
114508 * vma is the last one with address > vma->vm_end. Have to extend vma.
114509 */
114510+#ifndef CONFIG_IA64
114511+static
114512+#endif
114513 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
114514 {
114515 int error;
114516+ bool locknext;
114517
114518 if (!(vma->vm_flags & VM_GROWSUP))
114519 return -EFAULT;
114520
114521+ /* Also guard against wrapping around to address 0. */
114522+ if (address < PAGE_ALIGN(address+1))
114523+ address = PAGE_ALIGN(address+1);
114524+ else
114525+ return -ENOMEM;
114526+
114527 /*
114528 * We must make sure the anon_vma is allocated
114529 * so that the anon_vma locking is not a noop.
114530 */
114531 if (unlikely(anon_vma_prepare(vma)))
114532 return -ENOMEM;
114533+ locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
114534+ if (locknext && anon_vma_prepare(vma->vm_next))
114535+ return -ENOMEM;
114536 vma_lock_anon_vma(vma);
114537+ if (locknext)
114538+ vma_lock_anon_vma(vma->vm_next);
114539
114540 /*
114541 * vma->vm_start/vm_end cannot change under us because the caller
114542 * is required to hold the mmap_sem in read mode. We need the
114543- * anon_vma lock to serialize against concurrent expand_stacks.
114544- * Also guard against wrapping around to address 0.
114545+ * anon_vma locks to serialize against concurrent expand_stacks
114546+ * and expand_upwards.
114547 */
114548- if (address < PAGE_ALIGN(address+4))
114549- address = PAGE_ALIGN(address+4);
114550- else {
114551- vma_unlock_anon_vma(vma);
114552- return -ENOMEM;
114553- }
114554 error = 0;
114555
114556 /* Somebody else might have raced and expanded it already */
114557- if (address > vma->vm_end) {
114558+ 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)
114559+ error = -ENOMEM;
114560+ else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
114561 unsigned long size, grow;
114562
114563 size = address - vma->vm_start;
114564@@ -2204,6 +2523,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
114565 }
114566 }
114567 }
114568+ if (locknext)
114569+ vma_unlock_anon_vma(vma->vm_next);
114570 vma_unlock_anon_vma(vma);
114571 khugepaged_enter_vma_merge(vma, vma->vm_flags);
114572 validate_mm(vma->vm_mm);
114573@@ -2218,6 +2539,8 @@ int expand_downwards(struct vm_area_struct *vma,
114574 unsigned long address)
114575 {
114576 int error;
114577+ bool lockprev = false;
114578+ struct vm_area_struct *prev;
114579
114580 /*
114581 * We must make sure the anon_vma is allocated
114582@@ -2231,6 +2554,15 @@ int expand_downwards(struct vm_area_struct *vma,
114583 if (error)
114584 return error;
114585
114586+ prev = vma->vm_prev;
114587+#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
114588+ lockprev = prev && (prev->vm_flags & VM_GROWSUP);
114589+#endif
114590+ if (lockprev && anon_vma_prepare(prev))
114591+ return -ENOMEM;
114592+ if (lockprev)
114593+ vma_lock_anon_vma(prev);
114594+
114595 vma_lock_anon_vma(vma);
114596
114597 /*
114598@@ -2240,9 +2572,17 @@ int expand_downwards(struct vm_area_struct *vma,
114599 */
114600
114601 /* Somebody else might have raced and expanded it already */
114602- if (address < vma->vm_start) {
114603+ if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
114604+ error = -ENOMEM;
114605+ else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
114606 unsigned long size, grow;
114607
114608+#ifdef CONFIG_PAX_SEGMEXEC
114609+ struct vm_area_struct *vma_m;
114610+
114611+ vma_m = pax_find_mirror_vma(vma);
114612+#endif
114613+
114614 size = vma->vm_end - address;
114615 grow = (vma->vm_start - address) >> PAGE_SHIFT;
114616
114617@@ -2267,13 +2607,27 @@ int expand_downwards(struct vm_area_struct *vma,
114618 vma->vm_pgoff -= grow;
114619 anon_vma_interval_tree_post_update_vma(vma);
114620 vma_gap_update(vma);
114621+
114622+#ifdef CONFIG_PAX_SEGMEXEC
114623+ if (vma_m) {
114624+ anon_vma_interval_tree_pre_update_vma(vma_m);
114625+ vma_m->vm_start -= grow << PAGE_SHIFT;
114626+ vma_m->vm_pgoff -= grow;
114627+ anon_vma_interval_tree_post_update_vma(vma_m);
114628+ vma_gap_update(vma_m);
114629+ }
114630+#endif
114631+
114632 spin_unlock(&vma->vm_mm->page_table_lock);
114633
114634+ track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
114635 perf_event_mmap(vma);
114636 }
114637 }
114638 }
114639 vma_unlock_anon_vma(vma);
114640+ if (lockprev)
114641+ vma_unlock_anon_vma(prev);
114642 khugepaged_enter_vma_merge(vma, vma->vm_flags);
114643 validate_mm(vma->vm_mm);
114644 return error;
114645@@ -2373,6 +2727,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
114646 do {
114647 long nrpages = vma_pages(vma);
114648
114649+#ifdef CONFIG_PAX_SEGMEXEC
114650+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
114651+ vma = remove_vma(vma);
114652+ continue;
114653+ }
114654+#endif
114655+
114656 if (vma->vm_flags & VM_ACCOUNT)
114657 nr_accounted += nrpages;
114658 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
114659@@ -2417,6 +2778,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
114660 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
114661 vma->vm_prev = NULL;
114662 do {
114663+
114664+#ifdef CONFIG_PAX_SEGMEXEC
114665+ if (vma->vm_mirror) {
114666+ BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
114667+ vma->vm_mirror->vm_mirror = NULL;
114668+ vma->vm_mirror->vm_flags &= ~VM_EXEC;
114669+ vma->vm_mirror = NULL;
114670+ }
114671+#endif
114672+
114673 vma_rb_erase(vma, &mm->mm_rb);
114674 mm->map_count--;
114675 tail_vma = vma;
114676@@ -2444,14 +2815,33 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114677 struct vm_area_struct *new;
114678 int err = -ENOMEM;
114679
114680+#ifdef CONFIG_PAX_SEGMEXEC
114681+ struct vm_area_struct *vma_m, *new_m = NULL;
114682+ unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
114683+#endif
114684+
114685 if (is_vm_hugetlb_page(vma) && (addr &
114686 ~(huge_page_mask(hstate_vma(vma)))))
114687 return -EINVAL;
114688
114689+#ifdef CONFIG_PAX_SEGMEXEC
114690+ vma_m = pax_find_mirror_vma(vma);
114691+#endif
114692+
114693 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
114694 if (!new)
114695 goto out_err;
114696
114697+#ifdef CONFIG_PAX_SEGMEXEC
114698+ if (vma_m) {
114699+ new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
114700+ if (!new_m) {
114701+ kmem_cache_free(vm_area_cachep, new);
114702+ goto out_err;
114703+ }
114704+ }
114705+#endif
114706+
114707 /* most fields are the same, copy all, and then fixup */
114708 *new = *vma;
114709
114710@@ -2464,6 +2854,22 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114711 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
114712 }
114713
114714+#ifdef CONFIG_PAX_SEGMEXEC
114715+ if (vma_m) {
114716+ *new_m = *vma_m;
114717+ INIT_LIST_HEAD(&new_m->anon_vma_chain);
114718+ new_m->vm_mirror = new;
114719+ new->vm_mirror = new_m;
114720+
114721+ if (new_below)
114722+ new_m->vm_end = addr_m;
114723+ else {
114724+ new_m->vm_start = addr_m;
114725+ new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
114726+ }
114727+ }
114728+#endif
114729+
114730 err = vma_dup_policy(vma, new);
114731 if (err)
114732 goto out_free_vma;
114733@@ -2484,6 +2890,38 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114734 else
114735 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
114736
114737+#ifdef CONFIG_PAX_SEGMEXEC
114738+ if (!err && vma_m) {
114739+ struct mempolicy *pol = vma_policy(new);
114740+
114741+ if (anon_vma_clone(new_m, vma_m))
114742+ goto out_free_mpol;
114743+
114744+ mpol_get(pol);
114745+ set_vma_policy(new_m, pol);
114746+
114747+ if (new_m->vm_file)
114748+ get_file(new_m->vm_file);
114749+
114750+ if (new_m->vm_ops && new_m->vm_ops->open)
114751+ new_m->vm_ops->open(new_m);
114752+
114753+ if (new_below)
114754+ err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
114755+ ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
114756+ else
114757+ err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
114758+
114759+ if (err) {
114760+ if (new_m->vm_ops && new_m->vm_ops->close)
114761+ new_m->vm_ops->close(new_m);
114762+ if (new_m->vm_file)
114763+ fput(new_m->vm_file);
114764+ mpol_put(pol);
114765+ }
114766+ }
114767+#endif
114768+
114769 /* Success. */
114770 if (!err)
114771 return 0;
114772@@ -2493,10 +2931,18 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114773 new->vm_ops->close(new);
114774 if (new->vm_file)
114775 fput(new->vm_file);
114776- unlink_anon_vmas(new);
114777 out_free_mpol:
114778 mpol_put(vma_policy(new));
114779 out_free_vma:
114780+
114781+#ifdef CONFIG_PAX_SEGMEXEC
114782+ if (new_m) {
114783+ unlink_anon_vmas(new_m);
114784+ kmem_cache_free(vm_area_cachep, new_m);
114785+ }
114786+#endif
114787+
114788+ unlink_anon_vmas(new);
114789 kmem_cache_free(vm_area_cachep, new);
114790 out_err:
114791 return err;
114792@@ -2509,6 +2955,15 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114793 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114794 unsigned long addr, int new_below)
114795 {
114796+
114797+#ifdef CONFIG_PAX_SEGMEXEC
114798+ if (mm->pax_flags & MF_PAX_SEGMEXEC) {
114799+ BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
114800+ if (mm->map_count >= sysctl_max_map_count-1)
114801+ return -ENOMEM;
114802+ } else
114803+#endif
114804+
114805 if (mm->map_count >= sysctl_max_map_count)
114806 return -ENOMEM;
114807
114808@@ -2520,11 +2975,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114809 * work. This now handles partial unmappings.
114810 * Jeremy Fitzhardinge <jeremy@goop.org>
114811 */
114812+#ifdef CONFIG_PAX_SEGMEXEC
114813 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
114814 {
114815+ int ret = __do_munmap(mm, start, len);
114816+ if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
114817+ return ret;
114818+
114819+ return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
114820+}
114821+
114822+int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
114823+#else
114824+int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
114825+#endif
114826+{
114827 unsigned long end;
114828 struct vm_area_struct *vma, *prev, *last;
114829
114830+ /*
114831+ * mm->mmap_sem is required to protect against another thread
114832+ * changing the mappings in case we sleep.
114833+ */
114834+ verify_mm_writelocked(mm);
114835+
114836 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
114837 return -EINVAL;
114838
114839@@ -2602,6 +3076,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
114840 /* Fix up all other VM information */
114841 remove_vma_list(mm, vma);
114842
114843+ track_exec_limit(mm, start, end, 0UL);
114844+
114845 return 0;
114846 }
114847
114848@@ -2610,6 +3086,13 @@ int vm_munmap(unsigned long start, size_t len)
114849 int ret;
114850 struct mm_struct *mm = current->mm;
114851
114852+
114853+#ifdef CONFIG_PAX_SEGMEXEC
114854+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
114855+ (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
114856+ return -EINVAL;
114857+#endif
114858+
114859 down_write(&mm->mmap_sem);
114860 ret = do_munmap(mm, start, len);
114861 up_write(&mm->mmap_sem);
114862@@ -2656,6 +3139,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
114863 down_write(&mm->mmap_sem);
114864 vma = find_vma(mm, start);
114865
114866+#ifdef CONFIG_PAX_SEGMEXEC
114867+ if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
114868+ goto out;
114869+#endif
114870+
114871 if (!vma || !(vma->vm_flags & VM_SHARED))
114872 goto out;
114873
114874@@ -2692,16 +3180,6 @@ out:
114875 return ret;
114876 }
114877
114878-static inline void verify_mm_writelocked(struct mm_struct *mm)
114879-{
114880-#ifdef CONFIG_DEBUG_VM
114881- if (unlikely(down_read_trylock(&mm->mmap_sem))) {
114882- WARN_ON(1);
114883- up_read(&mm->mmap_sem);
114884- }
114885-#endif
114886-}
114887-
114888 /*
114889 * this is really a simplified "do_mmap". it only handles
114890 * anonymous maps. eventually we may be able to do some
114891@@ -2715,6 +3193,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114892 struct rb_node **rb_link, *rb_parent;
114893 pgoff_t pgoff = addr >> PAGE_SHIFT;
114894 int error;
114895+ unsigned long charged;
114896
114897 len = PAGE_ALIGN(len);
114898 if (!len)
114899@@ -2722,10 +3201,24 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114900
114901 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
114902
114903+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
114904+ if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
114905+ flags &= ~VM_EXEC;
114906+
114907+#ifdef CONFIG_PAX_MPROTECT
114908+ if (mm->pax_flags & MF_PAX_MPROTECT)
114909+ flags &= ~VM_MAYEXEC;
114910+#endif
114911+
114912+ }
114913+#endif
114914+
114915 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
114916 if (error & ~PAGE_MASK)
114917 return error;
114918
114919+ charged = len >> PAGE_SHIFT;
114920+
114921 error = mlock_future_check(mm, mm->def_flags, len);
114922 if (error)
114923 return error;
114924@@ -2743,16 +3236,17 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114925 &rb_parent)) {
114926 if (do_munmap(mm, addr, len))
114927 return -ENOMEM;
114928+ BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
114929 }
114930
114931 /* Check against address space limits *after* clearing old maps... */
114932- if (!may_expand_vm(mm, len >> PAGE_SHIFT))
114933+ if (!may_expand_vm(mm, charged))
114934 return -ENOMEM;
114935
114936 if (mm->map_count > sysctl_max_map_count)
114937 return -ENOMEM;
114938
114939- if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
114940+ if (security_vm_enough_memory_mm(mm, charged))
114941 return -ENOMEM;
114942
114943 /* Can we just expand an old private anonymous mapping? */
114944@@ -2766,7 +3260,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114945 */
114946 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
114947 if (!vma) {
114948- vm_unacct_memory(len >> PAGE_SHIFT);
114949+ vm_unacct_memory(charged);
114950 return -ENOMEM;
114951 }
114952
114953@@ -2780,10 +3274,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114954 vma_link(mm, vma, prev, rb_link, rb_parent);
114955 out:
114956 perf_event_mmap(vma);
114957- mm->total_vm += len >> PAGE_SHIFT;
114958+ mm->total_vm += charged;
114959 if (flags & VM_LOCKED)
114960- mm->locked_vm += (len >> PAGE_SHIFT);
114961+ mm->locked_vm += charged;
114962 vma->vm_flags |= VM_SOFTDIRTY;
114963+ track_exec_limit(mm, addr, addr + len, flags);
114964 return addr;
114965 }
114966
114967@@ -2845,6 +3340,7 @@ void exit_mmap(struct mm_struct *mm)
114968 while (vma) {
114969 if (vma->vm_flags & VM_ACCOUNT)
114970 nr_accounted += vma_pages(vma);
114971+ vma->vm_mirror = NULL;
114972 vma = remove_vma(vma);
114973 }
114974 vm_unacct_memory(nr_accounted);
114975@@ -2859,6 +3355,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
114976 struct vm_area_struct *prev;
114977 struct rb_node **rb_link, *rb_parent;
114978
114979+#ifdef CONFIG_PAX_SEGMEXEC
114980+ struct vm_area_struct *vma_m = NULL;
114981+#endif
114982+
114983+ if (security_mmap_addr(vma->vm_start))
114984+ return -EPERM;
114985+
114986 /*
114987 * The vm_pgoff of a purely anonymous vma should be irrelevant
114988 * until its first write fault, when page's anon_vma and index
114989@@ -2882,7 +3385,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
114990 security_vm_enough_memory_mm(mm, vma_pages(vma)))
114991 return -ENOMEM;
114992
114993+#ifdef CONFIG_PAX_SEGMEXEC
114994+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
114995+ vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
114996+ if (!vma_m)
114997+ return -ENOMEM;
114998+ }
114999+#endif
115000+
115001 vma_link(mm, vma, prev, rb_link, rb_parent);
115002+
115003+#ifdef CONFIG_PAX_SEGMEXEC
115004+ if (vma_m)
115005+ BUG_ON(pax_mirror_vma(vma_m, vma));
115006+#endif
115007+
115008 return 0;
115009 }
115010
115011@@ -2901,6 +3418,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
115012 struct rb_node **rb_link, *rb_parent;
115013 bool faulted_in_anon_vma = true;
115014
115015+ BUG_ON(vma->vm_mirror);
115016+
115017 /*
115018 * If anonymous vma has not yet been faulted, update new pgoff
115019 * to match new location, to increase its chance of merging.
115020@@ -2965,6 +3484,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
115021 return NULL;
115022 }
115023
115024+#ifdef CONFIG_PAX_SEGMEXEC
115025+long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
115026+{
115027+ struct vm_area_struct *prev_m;
115028+ struct rb_node **rb_link_m, *rb_parent_m;
115029+ struct mempolicy *pol_m;
115030+
115031+ BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
115032+ BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
115033+ BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
115034+ *vma_m = *vma;
115035+ INIT_LIST_HEAD(&vma_m->anon_vma_chain);
115036+ if (anon_vma_clone(vma_m, vma))
115037+ return -ENOMEM;
115038+ pol_m = vma_policy(vma_m);
115039+ mpol_get(pol_m);
115040+ set_vma_policy(vma_m, pol_m);
115041+ vma_m->vm_start += SEGMEXEC_TASK_SIZE;
115042+ vma_m->vm_end += SEGMEXEC_TASK_SIZE;
115043+ vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
115044+ vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
115045+ if (vma_m->vm_file)
115046+ get_file(vma_m->vm_file);
115047+ if (vma_m->vm_ops && vma_m->vm_ops->open)
115048+ vma_m->vm_ops->open(vma_m);
115049+ BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
115050+ vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
115051+ vma_m->vm_mirror = vma;
115052+ vma->vm_mirror = vma_m;
115053+ return 0;
115054+}
115055+#endif
115056+
115057 /*
115058 * Return true if the calling process may expand its vm space by the passed
115059 * number of pages
115060@@ -2976,6 +3528,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
115061
115062 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
115063
115064+ gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
115065 if (cur + npages > lim)
115066 return 0;
115067 return 1;
115068@@ -3058,6 +3611,22 @@ static struct vm_area_struct *__install_special_mapping(
115069 vma->vm_start = addr;
115070 vma->vm_end = addr + len;
115071
115072+#ifdef CONFIG_PAX_MPROTECT
115073+ if (mm->pax_flags & MF_PAX_MPROTECT) {
115074+#ifndef CONFIG_PAX_MPROTECT_COMPAT
115075+ if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
115076+ return ERR_PTR(-EPERM);
115077+ if (!(vm_flags & VM_EXEC))
115078+ vm_flags &= ~VM_MAYEXEC;
115079+#else
115080+ if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
115081+ vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
115082+#endif
115083+ else
115084+ vm_flags &= ~VM_MAYWRITE;
115085+ }
115086+#endif
115087+
115088 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
115089 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
115090
115091diff --git a/mm/mprotect.c b/mm/mprotect.c
115092index e7d6f11..6116007 100644
115093--- a/mm/mprotect.c
115094+++ b/mm/mprotect.c
115095@@ -24,10 +24,18 @@
115096 #include <linux/migrate.h>
115097 #include <linux/perf_event.h>
115098 #include <linux/ksm.h>
115099+#include <linux/sched/sysctl.h>
115100+
115101+#ifdef CONFIG_PAX_MPROTECT
115102+#include <linux/elf.h>
115103+#include <linux/binfmts.h>
115104+#endif
115105+
115106 #include <asm/uaccess.h>
115107 #include <asm/pgtable.h>
115108 #include <asm/cacheflush.h>
115109 #include <asm/tlbflush.h>
115110+#include <asm/mmu_context.h>
115111
115112 #include "internal.h"
115113
115114@@ -254,6 +262,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
115115 return pages;
115116 }
115117
115118+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
115119+/* called while holding the mmap semaphor for writing except stack expansion */
115120+void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
115121+{
115122+ unsigned long oldlimit, newlimit = 0UL;
115123+
115124+ if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
115125+ return;
115126+
115127+ spin_lock(&mm->page_table_lock);
115128+ oldlimit = mm->context.user_cs_limit;
115129+ if ((prot & VM_EXEC) && oldlimit < end)
115130+ /* USER_CS limit moved up */
115131+ newlimit = end;
115132+ else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
115133+ /* USER_CS limit moved down */
115134+ newlimit = start;
115135+
115136+ if (newlimit) {
115137+ mm->context.user_cs_limit = newlimit;
115138+
115139+#ifdef CONFIG_SMP
115140+ wmb();
115141+ cpumask_clear(&mm->context.cpu_user_cs_mask);
115142+ cpumask_set_cpu(smp_processor_id(), &mm->context.cpu_user_cs_mask);
115143+#endif
115144+
115145+ set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
115146+ }
115147+ spin_unlock(&mm->page_table_lock);
115148+ if (newlimit == end) {
115149+ struct vm_area_struct *vma = find_vma(mm, oldlimit);
115150+
115151+ for (; vma && vma->vm_start < end; vma = vma->vm_next)
115152+ if (is_vm_hugetlb_page(vma))
115153+ hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
115154+ else
115155+ change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
115156+ }
115157+}
115158+#endif
115159+
115160 int
115161 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
115162 unsigned long start, unsigned long end, unsigned long newflags)
115163@@ -266,11 +316,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
115164 int error;
115165 int dirty_accountable = 0;
115166
115167+#ifdef CONFIG_PAX_SEGMEXEC
115168+ struct vm_area_struct *vma_m = NULL;
115169+ unsigned long start_m, end_m;
115170+
115171+ start_m = start + SEGMEXEC_TASK_SIZE;
115172+ end_m = end + SEGMEXEC_TASK_SIZE;
115173+#endif
115174+
115175 if (newflags == oldflags) {
115176 *pprev = vma;
115177 return 0;
115178 }
115179
115180+ if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
115181+ struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
115182+
115183+ if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
115184+ return -ENOMEM;
115185+
115186+ if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
115187+ return -ENOMEM;
115188+ }
115189+
115190 /*
115191 * If we make a private mapping writable we increase our commit;
115192 * but (without finer accounting) cannot reduce our commit if we
115193@@ -287,6 +355,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
115194 }
115195 }
115196
115197+#ifdef CONFIG_PAX_SEGMEXEC
115198+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
115199+ if (start != vma->vm_start) {
115200+ error = split_vma(mm, vma, start, 1);
115201+ if (error)
115202+ goto fail;
115203+ BUG_ON(!*pprev || (*pprev)->vm_next == vma);
115204+ *pprev = (*pprev)->vm_next;
115205+ }
115206+
115207+ if (end != vma->vm_end) {
115208+ error = split_vma(mm, vma, end, 0);
115209+ if (error)
115210+ goto fail;
115211+ }
115212+
115213+ if (pax_find_mirror_vma(vma)) {
115214+ error = __do_munmap(mm, start_m, end_m - start_m);
115215+ if (error)
115216+ goto fail;
115217+ } else {
115218+ vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
115219+ if (!vma_m) {
115220+ error = -ENOMEM;
115221+ goto fail;
115222+ }
115223+ vma->vm_flags = newflags;
115224+ error = pax_mirror_vma(vma_m, vma);
115225+ if (error) {
115226+ vma->vm_flags = oldflags;
115227+ goto fail;
115228+ }
115229+ }
115230+ }
115231+#endif
115232+
115233 /*
115234 * First try to merge with previous and/or next vma.
115235 */
115236@@ -317,7 +421,19 @@ success:
115237 * vm_flags and vm_page_prot are protected by the mmap_sem
115238 * held in write mode.
115239 */
115240+
115241+#ifdef CONFIG_PAX_SEGMEXEC
115242+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
115243+ pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
115244+#endif
115245+
115246 vma->vm_flags = newflags;
115247+
115248+#ifdef CONFIG_PAX_MPROTECT
115249+ if (mm->binfmt && mm->binfmt->handle_mprotect)
115250+ mm->binfmt->handle_mprotect(vma, newflags);
115251+#endif
115252+
115253 dirty_accountable = vma_wants_writenotify(vma);
115254 vma_set_page_prot(vma);
115255
115256@@ -362,6 +478,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115257 end = start + len;
115258 if (end <= start)
115259 return -ENOMEM;
115260+
115261+#ifdef CONFIG_PAX_SEGMEXEC
115262+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
115263+ if (end > SEGMEXEC_TASK_SIZE)
115264+ return -EINVAL;
115265+ } else
115266+#endif
115267+
115268+ if (end > TASK_SIZE)
115269+ return -EINVAL;
115270+
115271 if (!arch_validate_prot(prot))
115272 return -EINVAL;
115273
115274@@ -369,7 +496,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115275 /*
115276 * Does the application expect PROT_READ to imply PROT_EXEC:
115277 */
115278- if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
115279+ if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
115280 prot |= PROT_EXEC;
115281
115282 vm_flags = calc_vm_prot_bits(prot);
115283@@ -401,6 +528,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115284 if (start > vma->vm_start)
115285 prev = vma;
115286
115287+#ifdef CONFIG_PAX_MPROTECT
115288+ if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
115289+ current->mm->binfmt->handle_mprotect(vma, vm_flags);
115290+#endif
115291+
115292 for (nstart = start ; ; ) {
115293 unsigned long newflags;
115294
115295@@ -411,6 +543,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115296
115297 /* newflags >> 4 shift VM_MAY% in place of VM_% */
115298 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
115299+ if (prot & (PROT_WRITE | PROT_EXEC))
115300+ gr_log_rwxmprotect(vma);
115301+
115302+ error = -EACCES;
115303+ goto out;
115304+ }
115305+
115306+ if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
115307 error = -EACCES;
115308 goto out;
115309 }
115310@@ -425,6 +565,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
115311 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
115312 if (error)
115313 goto out;
115314+
115315+ track_exec_limit(current->mm, nstart, tmp, vm_flags);
115316+
115317 nstart = tmp;
115318
115319 if (nstart < prev->vm_end)
115320diff --git a/mm/mremap.c b/mm/mremap.c
115321index a7c93ec..69c2949 100644
115322--- a/mm/mremap.c
115323+++ b/mm/mremap.c
115324@@ -143,6 +143,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
115325 continue;
115326 pte = ptep_get_and_clear(mm, old_addr, old_pte);
115327 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
115328+
115329+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
115330+ if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
115331+ pte = pte_exprotect(pte);
115332+#endif
115333+
115334 pte = move_soft_dirty_pte(pte);
115335 set_pte_at(mm, new_addr, new_pte, pte);
115336 }
115337@@ -355,6 +361,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
115338 if (is_vm_hugetlb_page(vma))
115339 return ERR_PTR(-EINVAL);
115340
115341+#ifdef CONFIG_PAX_SEGMEXEC
115342+ if (pax_find_mirror_vma(vma))
115343+ return ERR_PTR(-EINVAL);
115344+#endif
115345+
115346 /* We can't remap across vm area boundaries */
115347 if (old_len > vma->vm_end - addr)
115348 return ERR_PTR(-EFAULT);
115349@@ -401,20 +412,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
115350 unsigned long ret = -EINVAL;
115351 unsigned long charged = 0;
115352 unsigned long map_flags;
115353+ unsigned long pax_task_size = TASK_SIZE;
115354
115355 if (new_addr & ~PAGE_MASK)
115356 goto out;
115357
115358- if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
115359+#ifdef CONFIG_PAX_SEGMEXEC
115360+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
115361+ pax_task_size = SEGMEXEC_TASK_SIZE;
115362+#endif
115363+
115364+ pax_task_size -= PAGE_SIZE;
115365+
115366+ if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
115367 goto out;
115368
115369 /* Check if the location we're moving into overlaps the
115370 * old location at all, and fail if it does.
115371 */
115372- if ((new_addr <= addr) && (new_addr+new_len) > addr)
115373- goto out;
115374-
115375- if ((addr <= new_addr) && (addr+old_len) > new_addr)
115376+ if (addr + old_len > new_addr && new_addr + new_len > addr)
115377 goto out;
115378
115379 ret = do_munmap(mm, new_addr, new_len);
115380@@ -483,6 +499,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
115381 unsigned long ret = -EINVAL;
115382 unsigned long charged = 0;
115383 bool locked = false;
115384+ unsigned long pax_task_size = TASK_SIZE;
115385
115386 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
115387 return ret;
115388@@ -504,6 +521,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
115389 if (!new_len)
115390 return ret;
115391
115392+#ifdef CONFIG_PAX_SEGMEXEC
115393+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
115394+ pax_task_size = SEGMEXEC_TASK_SIZE;
115395+#endif
115396+
115397+ pax_task_size -= PAGE_SIZE;
115398+
115399+ if (new_len > pax_task_size || addr > pax_task_size-new_len ||
115400+ old_len > pax_task_size || addr > pax_task_size-old_len)
115401+ return ret;
115402+
115403 down_write(&current->mm->mmap_sem);
115404
115405 if (flags & MREMAP_FIXED) {
115406@@ -554,6 +582,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
115407 new_addr = addr;
115408 }
115409 ret = addr;
115410+ track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
115411 goto out;
115412 }
115413 }
115414@@ -577,7 +606,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
115415 goto out;
115416 }
115417
115418+ map_flags = vma->vm_flags;
115419 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
115420+ if (!(ret & ~PAGE_MASK)) {
115421+ track_exec_limit(current->mm, addr, addr + old_len, 0UL);
115422+ track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
115423+ }
115424 }
115425 out:
115426 if (ret & ~PAGE_MASK)
115427diff --git a/mm/nommu.c b/mm/nommu.c
115428index 58ea364..7b01d28 100644
115429--- a/mm/nommu.c
115430+++ b/mm/nommu.c
115431@@ -56,7 +56,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
115432 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
115433 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
115434 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
115435-int heap_stack_gap = 0;
115436
115437 atomic_long_t mmap_pages_allocated;
115438
115439@@ -863,15 +862,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
115440 EXPORT_SYMBOL(find_vma);
115441
115442 /*
115443- * find a VMA
115444- * - we don't extend stack VMAs under NOMMU conditions
115445- */
115446-struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
115447-{
115448- return find_vma(mm, addr);
115449-}
115450-
115451-/*
115452 * expand a stack to a given address
115453 * - not supported under NOMMU conditions
115454 */
115455@@ -1535,6 +1525,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
115456
115457 /* most fields are the same, copy all, and then fixup */
115458 *new = *vma;
115459+ INIT_LIST_HEAD(&new->anon_vma_chain);
115460 *region = *vma->vm_region;
115461 new->vm_region = region;
115462
115463@@ -1935,8 +1926,8 @@ void filemap_map_pages(struct vm_area_struct *vma, struct vm_fault *vmf)
115464 }
115465 EXPORT_SYMBOL(filemap_map_pages);
115466
115467-static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
115468- unsigned long addr, void *buf, int len, int write)
115469+static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
115470+ unsigned long addr, void *buf, size_t len, int write)
115471 {
115472 struct vm_area_struct *vma;
115473
115474@@ -1977,8 +1968,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
115475 *
115476 * The caller must hold a reference on @mm.
115477 */
115478-int access_remote_vm(struct mm_struct *mm, unsigned long addr,
115479- void *buf, int len, int write)
115480+ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
115481+ void *buf, size_t len, int write)
115482 {
115483 return __access_remote_vm(NULL, mm, addr, buf, len, write);
115484 }
115485@@ -1987,7 +1978,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
115486 * Access another process' address space.
115487 * - source/target buffer must be kernel space
115488 */
115489-int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
115490+ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
115491 {
115492 struct mm_struct *mm;
115493
115494diff --git a/mm/page-writeback.c b/mm/page-writeback.c
115495index 5cccc12..1872e56 100644
115496--- a/mm/page-writeback.c
115497+++ b/mm/page-writeback.c
115498@@ -852,7 +852,7 @@ static long long pos_ratio_polynom(unsigned long setpoint,
115499 * card's wb_dirty may rush to many times higher than wb_setpoint.
115500 * - the wb dirty thresh drops quickly due to change of JBOD workload
115501 */
115502-static void wb_position_ratio(struct dirty_throttle_control *dtc)
115503+static void __intentional_overflow(-1) wb_position_ratio(struct dirty_throttle_control *dtc)
115504 {
115505 struct bdi_writeback *wb = dtc->wb;
115506 unsigned long write_bw = wb->avg_write_bandwidth;
115507diff --git a/mm/page_alloc.c b/mm/page_alloc.c
115508index 5b5240b..2bc0996 100644
115509--- a/mm/page_alloc.c
115510+++ b/mm/page_alloc.c
115511@@ -62,6 +62,7 @@
115512 #include <linux/sched/rt.h>
115513 #include <linux/page_owner.h>
115514 #include <linux/kthread.h>
115515+#include <linux/random.h>
115516
115517 #include <asm/sections.h>
115518 #include <asm/tlbflush.h>
115519@@ -427,7 +428,7 @@ out:
115520 * This usage means that zero-order pages may not be compound.
115521 */
115522
115523-static void free_compound_page(struct page *page)
115524+void free_compound_page(struct page *page)
115525 {
115526 __free_pages_ok(page, compound_order(page));
115527 }
115528@@ -536,7 +537,7 @@ static inline void clear_page_guard(struct zone *zone, struct page *page,
115529 __mod_zone_freepage_state(zone, (1 << order), migratetype);
115530 }
115531 #else
115532-struct page_ext_operations debug_guardpage_ops = { NULL, };
115533+struct page_ext_operations debug_guardpage_ops = { .need = NULL, .init = NULL };
115534 static inline void set_page_guard(struct zone *zone, struct page *page,
115535 unsigned int order, int migratetype) {}
115536 static inline void clear_page_guard(struct zone *zone, struct page *page,
115537@@ -908,6 +909,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
115538 bool compound = PageCompound(page);
115539 int i, bad = 0;
115540
115541+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115542+ unsigned long index = 1UL << order;
115543+#endif
115544+
115545 VM_BUG_ON_PAGE(PageTail(page), page);
115546 VM_BUG_ON_PAGE(compound && compound_order(page) != order, page);
115547
115548@@ -934,6 +939,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
115549 debug_check_no_obj_freed(page_address(page),
115550 PAGE_SIZE << order);
115551 }
115552+
115553+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115554+ for (; index; --index)
115555+ sanitize_highpage(page + index - 1);
115556+#endif
115557+
115558 arch_free_page(page, order);
115559 kernel_map_pages(page, 1 << order, 0);
115560
115561@@ -957,6 +968,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
115562 local_irq_restore(flags);
115563 }
115564
115565+#ifdef CONFIG_PAX_LATENT_ENTROPY
115566+bool __meminitdata extra_latent_entropy;
115567+
115568+static int __init setup_pax_extra_latent_entropy(char *str)
115569+{
115570+ extra_latent_entropy = true;
115571+ return 0;
115572+}
115573+early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
115574+
115575+volatile u64 latent_entropy __latent_entropy;
115576+EXPORT_SYMBOL(latent_entropy);
115577+#endif
115578+
115579 static void __init __free_pages_boot_core(struct page *page,
115580 unsigned long pfn, unsigned int order)
115581 {
115582@@ -973,6 +998,19 @@ static void __init __free_pages_boot_core(struct page *page,
115583 __ClearPageReserved(p);
115584 set_page_count(p, 0);
115585
115586+#ifdef CONFIG_PAX_LATENT_ENTROPY
115587+ if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
115588+ u64 hash = 0;
115589+ size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
115590+ const u64 *data = lowmem_page_address(page);
115591+
115592+ for (index = 0; index < end; index++)
115593+ hash ^= hash + data[index];
115594+ latent_entropy ^= hash;
115595+ add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
115596+ }
115597+#endif
115598+
115599 page_zone(page)->managed_pages += nr_pages;
115600 set_page_refcounted(page);
115601 __free_pages(page, order);
115602@@ -1029,7 +1067,6 @@ static inline bool __meminit meminit_pfn_in_nid(unsigned long pfn, int node,
115603 }
115604 #endif
115605
115606-
115607 void __init __free_pages_bootmem(struct page *page, unsigned long pfn,
115608 unsigned int order)
115609 {
115610@@ -1333,9 +1370,11 @@ static int prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags,
115611 kernel_map_pages(page, 1 << order, 1);
115612 kasan_alloc_pages(page, order);
115613
115614+#ifndef CONFIG_PAX_MEMORY_SANITIZE
115615 if (gfp_flags & __GFP_ZERO)
115616 for (i = 0; i < (1 << order); i++)
115617 clear_highpage(page + i);
115618+#endif
115619
115620 if (order && (gfp_flags & __GFP_COMP))
115621 prep_compound_page(page, order);
115622@@ -2116,7 +2155,7 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
115623 }
115624
115625 __mod_zone_page_state(zone, NR_ALLOC_BATCH, -(1 << order));
115626- if (atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]) <= 0 &&
115627+ if (atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]) <= 0 &&
115628 !test_bit(ZONE_FAIR_DEPLETED, &zone->flags))
115629 set_bit(ZONE_FAIR_DEPLETED, &zone->flags);
115630
115631@@ -2435,7 +2474,7 @@ static void reset_alloc_batches(struct zone *preferred_zone)
115632 do {
115633 mod_zone_page_state(zone, NR_ALLOC_BATCH,
115634 high_wmark_pages(zone) - low_wmark_pages(zone) -
115635- atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]));
115636+ atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]));
115637 clear_bit(ZONE_FAIR_DEPLETED, &zone->flags);
115638 } while (zone++ != preferred_zone);
115639 }
115640@@ -6184,7 +6223,7 @@ static void __setup_per_zone_wmarks(void)
115641
115642 __mod_zone_page_state(zone, NR_ALLOC_BATCH,
115643 high_wmark_pages(zone) - low_wmark_pages(zone) -
115644- atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]));
115645+ atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]));
115646
115647 setup_zone_migrate_reserve(zone);
115648 spin_unlock_irqrestore(&zone->lock, flags);
115649diff --git a/mm/percpu.c b/mm/percpu.c
115650index 2dd7448..9bb6305 100644
115651--- a/mm/percpu.c
115652+++ b/mm/percpu.c
115653@@ -131,7 +131,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
115654 static unsigned int pcpu_high_unit_cpu __read_mostly;
115655
115656 /* the address of the first chunk which starts with the kernel static area */
115657-void *pcpu_base_addr __read_mostly;
115658+void *pcpu_base_addr __read_only;
115659 EXPORT_SYMBOL_GPL(pcpu_base_addr);
115660
115661 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
115662diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
115663index e88d071..d80e01a 100644
115664--- a/mm/process_vm_access.c
115665+++ b/mm/process_vm_access.c
115666@@ -13,6 +13,7 @@
115667 #include <linux/uio.h>
115668 #include <linux/sched.h>
115669 #include <linux/highmem.h>
115670+#include <linux/security.h>
115671 #include <linux/ptrace.h>
115672 #include <linux/slab.h>
115673 #include <linux/syscalls.h>
115674@@ -154,19 +155,19 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
115675 ssize_t iov_len;
115676 size_t total_len = iov_iter_count(iter);
115677
115678+ return -ENOSYS; // PaX: until properly audited
115679+
115680 /*
115681 * Work out how many pages of struct pages we're going to need
115682 * when eventually calling get_user_pages
115683 */
115684 for (i = 0; i < riovcnt; i++) {
115685 iov_len = rvec[i].iov_len;
115686- if (iov_len > 0) {
115687- nr_pages_iov = ((unsigned long)rvec[i].iov_base
115688- + iov_len)
115689- / PAGE_SIZE - (unsigned long)rvec[i].iov_base
115690- / PAGE_SIZE + 1;
115691- nr_pages = max(nr_pages, nr_pages_iov);
115692- }
115693+ if (iov_len <= 0)
115694+ continue;
115695+ nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
115696+ (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
115697+ nr_pages = max(nr_pages, nr_pages_iov);
115698 }
115699
115700 if (nr_pages == 0)
115701@@ -194,6 +195,11 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
115702 goto free_proc_pages;
115703 }
115704
115705+ if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
115706+ rc = -EPERM;
115707+ goto put_task_struct;
115708+ }
115709+
115710 mm = mm_access(task, PTRACE_MODE_ATTACH);
115711 if (!mm || IS_ERR(mm)) {
115712 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
115713diff --git a/mm/rmap.c b/mm/rmap.c
115714index 171b687..1a4b7e8 100644
115715--- a/mm/rmap.c
115716+++ b/mm/rmap.c
115717@@ -168,6 +168,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
115718 struct anon_vma *anon_vma = vma->anon_vma;
115719 struct anon_vma_chain *avc;
115720
115721+#ifdef CONFIG_PAX_SEGMEXEC
115722+ struct anon_vma_chain *avc_m = NULL;
115723+#endif
115724+
115725 might_sleep();
115726 if (unlikely(!anon_vma)) {
115727 struct mm_struct *mm = vma->vm_mm;
115728@@ -177,6 +181,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
115729 if (!avc)
115730 goto out_enomem;
115731
115732+#ifdef CONFIG_PAX_SEGMEXEC
115733+ avc_m = anon_vma_chain_alloc(GFP_KERNEL);
115734+ if (!avc_m)
115735+ goto out_enomem_free_avc;
115736+#endif
115737+
115738 anon_vma = find_mergeable_anon_vma(vma);
115739 allocated = NULL;
115740 if (!anon_vma) {
115741@@ -190,6 +200,19 @@ int anon_vma_prepare(struct vm_area_struct *vma)
115742 /* page_table_lock to protect against threads */
115743 spin_lock(&mm->page_table_lock);
115744 if (likely(!vma->anon_vma)) {
115745+
115746+#ifdef CONFIG_PAX_SEGMEXEC
115747+ struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
115748+
115749+ if (vma_m) {
115750+ BUG_ON(vma_m->anon_vma);
115751+ vma_m->anon_vma = anon_vma;
115752+ anon_vma_chain_link(vma_m, avc_m, anon_vma);
115753+ anon_vma->degree++;
115754+ avc_m = NULL;
115755+ }
115756+#endif
115757+
115758 vma->anon_vma = anon_vma;
115759 anon_vma_chain_link(vma, avc, anon_vma);
115760 /* vma reference or self-parent link for new root */
115761@@ -202,12 +225,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
115762
115763 if (unlikely(allocated))
115764 put_anon_vma(allocated);
115765+
115766+#ifdef CONFIG_PAX_SEGMEXEC
115767+ if (unlikely(avc_m))
115768+ anon_vma_chain_free(avc_m);
115769+#endif
115770+
115771 if (unlikely(avc))
115772 anon_vma_chain_free(avc);
115773 }
115774 return 0;
115775
115776 out_enomem_free_avc:
115777+
115778+#ifdef CONFIG_PAX_SEGMEXEC
115779+ if (avc_m)
115780+ anon_vma_chain_free(avc_m);
115781+#endif
115782+
115783 anon_vma_chain_free(avc);
115784 out_enomem:
115785 return -ENOMEM;
115786@@ -251,7 +286,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
115787 * good chance of avoiding scanning the whole hierarchy when it searches where
115788 * page is mapped.
115789 */
115790-int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
115791+int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
115792 {
115793 struct anon_vma_chain *avc, *pavc;
115794 struct anon_vma *root = NULL;
115795@@ -305,7 +340,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
115796 * the corresponding VMA in the parent process is attached to.
115797 * Returns 0 on success, non-zero on failure.
115798 */
115799-int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
115800+int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
115801 {
115802 struct anon_vma_chain *avc;
115803 struct anon_vma *anon_vma;
115804@@ -425,8 +460,10 @@ static void anon_vma_ctor(void *data)
115805 void __init anon_vma_init(void)
115806 {
115807 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
115808- 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
115809- anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
115810+ 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
115811+ anon_vma_ctor);
115812+ anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
115813+ SLAB_PANIC|SLAB_NO_SANITIZE);
115814 }
115815
115816 /*
115817diff --git a/mm/shmem.c b/mm/shmem.c
115818index dbe0c1e..22c16c7 100644
115819--- a/mm/shmem.c
115820+++ b/mm/shmem.c
115821@@ -33,7 +33,7 @@
115822 #include <linux/swap.h>
115823 #include <linux/uio.h>
115824
115825-static struct vfsmount *shm_mnt;
115826+struct vfsmount *shm_mnt;
115827
115828 #ifdef CONFIG_SHMEM
115829 /*
115830@@ -80,7 +80,7 @@ static struct vfsmount *shm_mnt;
115831 #define BOGO_DIRENT_SIZE 20
115832
115833 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
115834-#define SHORT_SYMLINK_LEN 128
115835+#define SHORT_SYMLINK_LEN 64
115836
115837 /*
115838 * shmem_fallocate communicates with shmem_fault or shmem_writepage via
115839@@ -2549,6 +2549,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
115840 static int shmem_xattr_validate(const char *name)
115841 {
115842 struct { const char *prefix; size_t len; } arr[] = {
115843+
115844+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
115845+ { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
115846+#endif
115847+
115848 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
115849 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
115850 };
115851@@ -2604,6 +2609,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
115852 if (err)
115853 return err;
115854
115855+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
115856+ if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
115857+ if (strcmp(name, XATTR_NAME_PAX_FLAGS))
115858+ return -EOPNOTSUPP;
115859+ if (size > 8)
115860+ return -EINVAL;
115861+ }
115862+#endif
115863+
115864 return simple_xattr_set(&info->xattrs, name, value, size, flags);
115865 }
115866
115867@@ -2987,8 +3001,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
115868 int err = -ENOMEM;
115869
115870 /* Round up to L1_CACHE_BYTES to resist false sharing */
115871- sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
115872- L1_CACHE_BYTES), GFP_KERNEL);
115873+ sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
115874 if (!sbinfo)
115875 return -ENOMEM;
115876
115877diff --git a/mm/slab.c b/mm/slab.c
115878index ae36028..eb6af9e 100644
115879--- a/mm/slab.c
115880+++ b/mm/slab.c
115881@@ -116,6 +116,7 @@
115882 #include <linux/kmemcheck.h>
115883 #include <linux/memory.h>
115884 #include <linux/prefetch.h>
115885+#include <linux/vmalloc.h>
115886
115887 #include <net/sock.h>
115888
115889@@ -314,10 +315,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
115890 if ((x)->max_freeable < i) \
115891 (x)->max_freeable = i; \
115892 } while (0)
115893-#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
115894-#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
115895-#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
115896-#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
115897+#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
115898+#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
115899+#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
115900+#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
115901+#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
115902+#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
115903 #else
115904 #define STATS_INC_ACTIVE(x) do { } while (0)
115905 #define STATS_DEC_ACTIVE(x) do { } while (0)
115906@@ -334,6 +337,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
115907 #define STATS_INC_ALLOCMISS(x) do { } while (0)
115908 #define STATS_INC_FREEHIT(x) do { } while (0)
115909 #define STATS_INC_FREEMISS(x) do { } while (0)
115910+#define STATS_INC_SANITIZED(x) do { } while (0)
115911+#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
115912 #endif
115913
115914 #if DEBUG
115915@@ -450,7 +455,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct page *page,
115916 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
115917 */
115918 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
115919- const struct page *page, void *obj)
115920+ const struct page *page, const void *obj)
115921 {
115922 u32 offset = (obj - page->s_mem);
115923 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
115924@@ -1452,7 +1457,7 @@ void __init kmem_cache_init(void)
115925 * structures first. Without this, further allocations will bug.
115926 */
115927 kmalloc_caches[INDEX_NODE] = create_kmalloc_cache("kmalloc-node",
115928- kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
115929+ kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
115930 slab_state = PARTIAL_NODE;
115931 setup_kmalloc_cache_index_table();
115932
115933@@ -2074,7 +2079,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
115934
115935 cachep = find_mergeable(size, align, flags, name, ctor);
115936 if (cachep) {
115937- cachep->refcount++;
115938+ atomic_inc(&cachep->refcount);
115939
115940 /*
115941 * Adjust the object sizes so that we clear
115942@@ -3379,6 +3384,20 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
115943 struct array_cache *ac = cpu_cache_get(cachep);
115944
115945 check_irq_off();
115946+
115947+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115948+ if (cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))
115949+ STATS_INC_NOT_SANITIZED(cachep);
115950+ else {
115951+ memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
115952+
115953+ if (cachep->ctor)
115954+ cachep->ctor(objp);
115955+
115956+ STATS_INC_SANITIZED(cachep);
115957+ }
115958+#endif
115959+
115960 kmemleak_free_recursive(objp, cachep->flags);
115961 objp = cache_free_debugcheck(cachep, objp, caller);
115962
115963@@ -3491,7 +3510,7 @@ __do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller)
115964 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
115965 }
115966
115967-void *__kmalloc_node(size_t size, gfp_t flags, int node)
115968+void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t flags, int node)
115969 {
115970 return __do_kmalloc_node(size, flags, node, _RET_IP_);
115971 }
115972@@ -3511,7 +3530,7 @@ EXPORT_SYMBOL(__kmalloc_node_track_caller);
115973 * @flags: the type of memory to allocate (see kmalloc).
115974 * @caller: function caller for debug tracking of the caller
115975 */
115976-static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,
115977+static __always_inline void * __size_overflow(1) __do_kmalloc(size_t size, gfp_t flags,
115978 unsigned long caller)
115979 {
115980 struct kmem_cache *cachep;
115981@@ -3584,6 +3603,7 @@ void kfree(const void *objp)
115982
115983 if (unlikely(ZERO_OR_NULL_PTR(objp)))
115984 return;
115985+ VM_BUG_ON(!virt_addr_valid(objp));
115986 local_irq_save(flags);
115987 kfree_debugcheck(objp);
115988 c = virt_to_cache(objp);
115989@@ -4003,14 +4023,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
115990 }
115991 /* cpu stats */
115992 {
115993- unsigned long allochit = atomic_read(&cachep->allochit);
115994- unsigned long allocmiss = atomic_read(&cachep->allocmiss);
115995- unsigned long freehit = atomic_read(&cachep->freehit);
115996- unsigned long freemiss = atomic_read(&cachep->freemiss);
115997+ unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
115998+ unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
115999+ unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
116000+ unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
116001
116002 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
116003 allochit, allocmiss, freehit, freemiss);
116004 }
116005+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116006+ {
116007+ unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
116008+ unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
116009+
116010+ seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
116011+ }
116012+#endif
116013 #endif
116014 }
116015
116016@@ -4218,13 +4246,80 @@ static const struct file_operations proc_slabstats_operations = {
116017 static int __init slab_proc_init(void)
116018 {
116019 #ifdef CONFIG_DEBUG_SLAB_LEAK
116020- proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
116021+ proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
116022 #endif
116023 return 0;
116024 }
116025 module_init(slab_proc_init);
116026 #endif
116027
116028+bool is_usercopy_object(const void *ptr)
116029+{
116030+ struct page *page;
116031+ struct kmem_cache *cachep;
116032+
116033+ if (ZERO_OR_NULL_PTR(ptr))
116034+ return false;
116035+
116036+ if (!slab_is_available())
116037+ return false;
116038+
116039+ if (is_vmalloc_addr(ptr)
116040+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116041+ && !object_starts_on_stack(ptr)
116042+#endif
116043+ ) {
116044+ struct vm_struct *vm = find_vm_area(ptr);
116045+ if (vm && (vm->flags & VM_USERCOPY))
116046+ return true;
116047+ return false;
116048+ }
116049+
116050+ if (!virt_addr_valid(ptr))
116051+ return false;
116052+
116053+ page = virt_to_head_page(ptr);
116054+
116055+ if (!PageSlab(page))
116056+ return false;
116057+
116058+ cachep = page->slab_cache;
116059+ return cachep->flags & SLAB_USERCOPY;
116060+}
116061+
116062+#ifdef CONFIG_PAX_USERCOPY
116063+const char *check_heap_object(const void *ptr, unsigned long n)
116064+{
116065+ struct page *page;
116066+ struct kmem_cache *cachep;
116067+ unsigned int objnr;
116068+ unsigned long offset;
116069+
116070+ if (ZERO_OR_NULL_PTR(ptr))
116071+ return "<null>";
116072+
116073+ if (!virt_addr_valid(ptr))
116074+ return NULL;
116075+
116076+ page = virt_to_head_page(ptr);
116077+
116078+ if (!PageSlab(page))
116079+ return NULL;
116080+
116081+ cachep = page->slab_cache;
116082+ if (!(cachep->flags & SLAB_USERCOPY))
116083+ return cachep->name;
116084+
116085+ objnr = obj_to_index(cachep, page, ptr);
116086+ BUG_ON(objnr >= cachep->num);
116087+ offset = ptr - index_to_obj(cachep, page, objnr) - obj_offset(cachep);
116088+ if (offset <= cachep->object_size && n <= cachep->object_size - offset)
116089+ return NULL;
116090+
116091+ return cachep->name;
116092+}
116093+#endif
116094+
116095 /**
116096 * ksize - get the actual amount of memory allocated for a given object
116097 * @objp: Pointer to the object
116098diff --git a/mm/slab.h b/mm/slab.h
116099index 8da63e4..50c423b 100644
116100--- a/mm/slab.h
116101+++ b/mm/slab.h
116102@@ -22,7 +22,7 @@ struct kmem_cache {
116103 unsigned int align; /* Alignment as calculated */
116104 unsigned long flags; /* Active flags on the slab */
116105 const char *name; /* Slab name for sysfs */
116106- int refcount; /* Use counter */
116107+ atomic_t refcount; /* Use counter */
116108 void (*ctor)(void *); /* Called on object slot creation */
116109 struct list_head list; /* List of all slab caches on the system */
116110 };
116111@@ -66,6 +66,20 @@ extern struct list_head slab_caches;
116112 /* The slab cache that manages slab cache information */
116113 extern struct kmem_cache *kmem_cache;
116114
116115+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116116+#ifdef CONFIG_X86_64
116117+#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
116118+#else
116119+#define PAX_MEMORY_SANITIZE_VALUE '\xff'
116120+#endif
116121+enum pax_sanitize_mode {
116122+ PAX_SANITIZE_SLAB_OFF = 0,
116123+ PAX_SANITIZE_SLAB_FAST,
116124+ PAX_SANITIZE_SLAB_FULL,
116125+};
116126+extern enum pax_sanitize_mode pax_sanitize_slab;
116127+#endif
116128+
116129 unsigned long calculate_alignment(unsigned long flags,
116130 unsigned long align, unsigned long size);
116131
116132@@ -115,7 +129,8 @@ static inline unsigned long kmem_cache_flags(unsigned long object_size,
116133
116134 /* Legal flag mask for kmem_cache_create(), for various configurations */
116135 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
116136- SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
116137+ SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
116138+ SLAB_USERCOPY | SLAB_NO_SANITIZE)
116139
116140 #if defined(CONFIG_DEBUG_SLAB)
116141 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
116142@@ -316,6 +331,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
116143 return s;
116144
116145 page = virt_to_head_page(x);
116146+
116147+ BUG_ON(!PageSlab(page));
116148+
116149 cachep = page->slab_cache;
116150 if (slab_equal_or_root(cachep, s))
116151 return cachep;
116152diff --git a/mm/slab_common.c b/mm/slab_common.c
116153index 8683110..916e2c5 100644
116154--- a/mm/slab_common.c
116155+++ b/mm/slab_common.c
116156@@ -25,11 +25,35 @@
116157
116158 #include "slab.h"
116159
116160-enum slab_state slab_state;
116161+enum slab_state slab_state __read_only;
116162 LIST_HEAD(slab_caches);
116163 DEFINE_MUTEX(slab_mutex);
116164 struct kmem_cache *kmem_cache;
116165
116166+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116167+enum pax_sanitize_mode pax_sanitize_slab __read_only = PAX_SANITIZE_SLAB_FAST;
116168+static int __init pax_sanitize_slab_setup(char *str)
116169+{
116170+ if (!str)
116171+ return 0;
116172+
116173+ if (!strcmp(str, "0") || !strcmp(str, "off")) {
116174+ pr_info("PaX slab sanitization: %s\n", "disabled");
116175+ pax_sanitize_slab = PAX_SANITIZE_SLAB_OFF;
116176+ } else if (!strcmp(str, "1") || !strcmp(str, "fast")) {
116177+ pr_info("PaX slab sanitization: %s\n", "fast");
116178+ pax_sanitize_slab = PAX_SANITIZE_SLAB_FAST;
116179+ } else if (!strcmp(str, "full")) {
116180+ pr_info("PaX slab sanitization: %s\n", "full");
116181+ pax_sanitize_slab = PAX_SANITIZE_SLAB_FULL;
116182+ } else
116183+ pr_err("PaX slab sanitization: unsupported option '%s'\n", str);
116184+
116185+ return 0;
116186+}
116187+early_param("pax_sanitize_slab", pax_sanitize_slab_setup);
116188+#endif
116189+
116190 /*
116191 * Set of flags that will prevent slab merging
116192 */
116193@@ -43,7 +67,7 @@ struct kmem_cache *kmem_cache;
116194 * Merge control. If this is set then no merging of slab caches will occur.
116195 * (Could be removed. This was introduced to pacify the merge skeptics.)
116196 */
116197-static int slab_nomerge;
116198+static int slab_nomerge = 1;
116199
116200 static int __init setup_slab_nomerge(char *str)
116201 {
116202@@ -216,7 +240,7 @@ int slab_unmergeable(struct kmem_cache *s)
116203 /*
116204 * We may have set a slab to be unmergeable during bootstrap.
116205 */
116206- if (s->refcount < 0)
116207+ if (atomic_read(&s->refcount) < 0)
116208 return 1;
116209
116210 return 0;
116211@@ -320,7 +344,7 @@ do_kmem_cache_create(const char *name, size_t object_size, size_t size,
116212 if (err)
116213 goto out_free_cache;
116214
116215- s->refcount = 1;
116216+ atomic_set(&s->refcount, 1);
116217 list_add(&s->list, &slab_caches);
116218 out:
116219 if (err)
116220@@ -385,6 +409,13 @@ kmem_cache_create(const char *name, size_t size, size_t align,
116221 */
116222 flags &= CACHE_CREATE_MASK;
116223
116224+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116225+ if (pax_sanitize_slab == PAX_SANITIZE_SLAB_OFF || (flags & SLAB_DESTROY_BY_RCU))
116226+ flags |= SLAB_NO_SANITIZE;
116227+ else if (pax_sanitize_slab == PAX_SANITIZE_SLAB_FULL)
116228+ flags &= ~SLAB_NO_SANITIZE;
116229+#endif
116230+
116231 s = __kmem_cache_alias(name, size, align, flags, ctor);
116232 if (s)
116233 goto out_unlock;
116234@@ -455,7 +486,7 @@ static void do_kmem_cache_release(struct list_head *release,
116235 rcu_barrier();
116236
116237 list_for_each_entry_safe(s, s2, release, list) {
116238-#ifdef SLAB_SUPPORTS_SYSFS
116239+#if defined(SLAB_SUPPORTS_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116240 sysfs_slab_remove(s);
116241 #else
116242 slab_kmem_cache_release(s);
116243@@ -624,8 +655,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
116244
116245 mutex_lock(&slab_mutex);
116246
116247- s->refcount--;
116248- if (s->refcount)
116249+ if (!atomic_dec_and_test(&s->refcount))
116250 goto out_unlock;
116251
116252 for_each_memcg_cache_safe(c, c2, s) {
116253@@ -690,7 +720,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
116254 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
116255 name, size, err);
116256
116257- s->refcount = -1; /* Exempt from merging for now */
116258+ atomic_set(&s->refcount, -1); /* Exempt from merging for now */
116259 }
116260
116261 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
116262@@ -703,7 +733,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
116263
116264 create_boot_cache(s, name, size, flags);
116265 list_add(&s->list, &slab_caches);
116266- s->refcount = 1;
116267+ atomic_set(&s->refcount, 1);
116268 return s;
116269 }
116270
116271@@ -715,6 +745,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
116272 EXPORT_SYMBOL(kmalloc_dma_caches);
116273 #endif
116274
116275+#ifdef CONFIG_PAX_USERCOPY_SLABS
116276+struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
116277+EXPORT_SYMBOL(kmalloc_usercopy_caches);
116278+#endif
116279+
116280 /*
116281 * Conversion table for small slabs sizes / 8 to the index in the
116282 * kmalloc array. This is necessary for slabs < 192 since we have non power
116283@@ -779,6 +814,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
116284 return kmalloc_dma_caches[index];
116285
116286 #endif
116287+
116288+#ifdef CONFIG_PAX_USERCOPY_SLABS
116289+ if (unlikely((flags & GFP_USERCOPY)))
116290+ return kmalloc_usercopy_caches[index];
116291+
116292+#endif
116293+
116294 return kmalloc_caches[index];
116295 }
116296
116297@@ -871,7 +913,7 @@ void __init create_kmalloc_caches(unsigned long flags)
116298
116299 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
116300 if (!kmalloc_caches[i])
116301- new_kmalloc_cache(i, flags);
116302+ new_kmalloc_cache(i, SLAB_USERCOPY | flags);
116303
116304 /*
116305 * Caches that are not of the two-to-the-power-of size.
116306@@ -879,9 +921,9 @@ void __init create_kmalloc_caches(unsigned long flags)
116307 * earlier power of two caches
116308 */
116309 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
116310- new_kmalloc_cache(1, flags);
116311+ new_kmalloc_cache(1, SLAB_USERCOPY | flags);
116312 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
116313- new_kmalloc_cache(2, flags);
116314+ new_kmalloc_cache(2, SLAB_USERCOPY | flags);
116315 }
116316
116317 /* Kmalloc array is now usable */
116318@@ -902,6 +944,23 @@ void __init create_kmalloc_caches(unsigned long flags)
116319 }
116320 }
116321 #endif
116322+
116323+#ifdef CONFIG_PAX_USERCOPY_SLABS
116324+ for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
116325+ struct kmem_cache *s = kmalloc_caches[i];
116326+
116327+ if (s) {
116328+ int size = kmalloc_size(i);
116329+ char *n = kasprintf(GFP_NOWAIT,
116330+ "usercopy-kmalloc-%d", size);
116331+
116332+ BUG_ON(!n);
116333+ kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
116334+ size, SLAB_USERCOPY | flags);
116335+ }
116336+ }
116337+#endif
116338+
116339 }
116340 #endif /* !CONFIG_SLOB */
116341
116342@@ -961,6 +1020,9 @@ static void print_slabinfo_header(struct seq_file *m)
116343 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
116344 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
116345 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
116346+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116347+ seq_puts(m, " : pax <sanitized> <not_sanitized>");
116348+#endif
116349 #endif
116350 seq_putc(m, '\n');
116351 }
116352@@ -1090,7 +1152,7 @@ static int __init slab_proc_init(void)
116353 module_init(slab_proc_init);
116354 #endif /* CONFIG_SLABINFO */
116355
116356-static __always_inline void *__do_krealloc(const void *p, size_t new_size,
116357+static __always_inline void * __size_overflow(2) __do_krealloc(const void *p, size_t new_size,
116358 gfp_t flags)
116359 {
116360 void *ret;
116361diff --git a/mm/slob.c b/mm/slob.c
116362index 4765f65..5dec45e 100644
116363--- a/mm/slob.c
116364+++ b/mm/slob.c
116365@@ -67,6 +67,7 @@
116366 #include <linux/rcupdate.h>
116367 #include <linux/list.h>
116368 #include <linux/kmemleak.h>
116369+#include <linux/vmalloc.h>
116370
116371 #include <trace/events/kmem.h>
116372
116373@@ -157,7 +158,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
116374 /*
116375 * Return the size of a slob block.
116376 */
116377-static slobidx_t slob_units(slob_t *s)
116378+static slobidx_t slob_units(const slob_t *s)
116379 {
116380 if (s->units > 0)
116381 return s->units;
116382@@ -167,7 +168,7 @@ static slobidx_t slob_units(slob_t *s)
116383 /*
116384 * Return the next free slob block pointer after this one.
116385 */
116386-static slob_t *slob_next(slob_t *s)
116387+static slob_t *slob_next(const slob_t *s)
116388 {
116389 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
116390 slobidx_t next;
116391@@ -182,14 +183,14 @@ static slob_t *slob_next(slob_t *s)
116392 /*
116393 * Returns true if s is the last free block in its page.
116394 */
116395-static int slob_last(slob_t *s)
116396+static int slob_last(const slob_t *s)
116397 {
116398 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
116399 }
116400
116401-static void *slob_new_pages(gfp_t gfp, int order, int node)
116402+static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
116403 {
116404- void *page;
116405+ struct page *page;
116406
116407 #ifdef CONFIG_NUMA
116408 if (node != NUMA_NO_NODE)
116409@@ -201,14 +202,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
116410 if (!page)
116411 return NULL;
116412
116413- return page_address(page);
116414+ __SetPageSlab(page);
116415+ return page;
116416 }
116417
116418-static void slob_free_pages(void *b, int order)
116419+static void slob_free_pages(struct page *sp, int order)
116420 {
116421 if (current->reclaim_state)
116422 current->reclaim_state->reclaimed_slab += 1 << order;
116423- free_pages((unsigned long)b, order);
116424+ __ClearPageSlab(sp);
116425+ page_mapcount_reset(sp);
116426+ sp->private = 0;
116427+ __free_pages(sp, order);
116428 }
116429
116430 /*
116431@@ -313,15 +318,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
116432
116433 /* Not enough space: must allocate a new page */
116434 if (!b) {
116435- b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
116436- if (!b)
116437+ sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
116438+ if (!sp)
116439 return NULL;
116440- sp = virt_to_page(b);
116441- __SetPageSlab(sp);
116442+ b = page_address(sp);
116443
116444 spin_lock_irqsave(&slob_lock, flags);
116445 sp->units = SLOB_UNITS(PAGE_SIZE);
116446 sp->freelist = b;
116447+ sp->private = 0;
116448 INIT_LIST_HEAD(&sp->lru);
116449 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
116450 set_slob_page_free(sp, slob_list);
116451@@ -337,7 +342,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
116452 /*
116453 * slob_free: entry point into the slob allocator.
116454 */
116455-static void slob_free(void *block, int size)
116456+static void slob_free(struct kmem_cache *c, void *block, int size)
116457 {
116458 struct page *sp;
116459 slob_t *prev, *next, *b = (slob_t *)block;
116460@@ -359,12 +364,15 @@ static void slob_free(void *block, int size)
116461 if (slob_page_free(sp))
116462 clear_slob_page_free(sp);
116463 spin_unlock_irqrestore(&slob_lock, flags);
116464- __ClearPageSlab(sp);
116465- page_mapcount_reset(sp);
116466- slob_free_pages(b, 0);
116467+ slob_free_pages(sp, 0);
116468 return;
116469 }
116470
116471+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116472+ if (pax_sanitize_slab && !(c && (c->flags & SLAB_NO_SANITIZE)))
116473+ memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
116474+#endif
116475+
116476 if (!slob_page_free(sp)) {
116477 /* This slob page is about to become partially free. Easy! */
116478 sp->units = units;
116479@@ -424,11 +432,10 @@ out:
116480 */
116481
116482 static __always_inline void *
116483-__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
116484+__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
116485 {
116486- unsigned int *m;
116487- int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
116488- void *ret;
116489+ slob_t *m;
116490+ void *ret = NULL;
116491
116492 gfp &= gfp_allowed_mask;
116493
116494@@ -442,27 +449,45 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
116495
116496 if (!m)
116497 return NULL;
116498- *m = size;
116499+ BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
116500+ BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
116501+ m[0].units = size;
116502+ m[1].units = align;
116503 ret = (void *)m + align;
116504
116505 trace_kmalloc_node(caller, ret,
116506 size, size + align, gfp, node);
116507 } else {
116508 unsigned int order = get_order(size);
116509+ struct page *page;
116510
116511 if (likely(order))
116512 gfp |= __GFP_COMP;
116513- ret = slob_new_pages(gfp, order, node);
116514+ page = slob_new_pages(gfp, order, node);
116515+ if (page) {
116516+ ret = page_address(page);
116517+ page->private = size;
116518+ }
116519
116520 trace_kmalloc_node(caller, ret,
116521 size, PAGE_SIZE << order, gfp, node);
116522 }
116523
116524- kmemleak_alloc(ret, size, 1, gfp);
116525 return ret;
116526 }
116527
116528-void *__kmalloc(size_t size, gfp_t gfp)
116529+static __always_inline void *
116530+__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
116531+{
116532+ int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
116533+ void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
116534+
116535+ if (!ZERO_OR_NULL_PTR(ret))
116536+ kmemleak_alloc(ret, size, 1, gfp);
116537+ return ret;
116538+}
116539+
116540+void * __size_overflow(1) __kmalloc(size_t size, gfp_t gfp)
116541 {
116542 return __do_kmalloc_node(size, gfp, NUMA_NO_NODE, _RET_IP_);
116543 }
116544@@ -491,34 +516,123 @@ void kfree(const void *block)
116545 return;
116546 kmemleak_free(block);
116547
116548+ VM_BUG_ON(!virt_addr_valid(block));
116549 sp = virt_to_page(block);
116550- if (PageSlab(sp)) {
116551+ VM_BUG_ON(!PageSlab(sp));
116552+ if (!sp->private) {
116553 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
116554- unsigned int *m = (unsigned int *)(block - align);
116555- slob_free(m, *m + align);
116556- } else
116557+ slob_t *m = (slob_t *)(block - align);
116558+ slob_free(NULL, m, m[0].units + align);
116559+ } else {
116560+ __ClearPageSlab(sp);
116561+ page_mapcount_reset(sp);
116562+ sp->private = 0;
116563 __free_pages(sp, compound_order(sp));
116564+ }
116565 }
116566 EXPORT_SYMBOL(kfree);
116567
116568+bool is_usercopy_object(const void *ptr)
116569+{
116570+ if (!slab_is_available())
116571+ return false;
116572+
116573+ if (is_vmalloc_addr(ptr)
116574+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116575+ && !object_starts_on_stack(ptr)
116576+#endif
116577+ ) {
116578+ struct vm_struct *vm = find_vm_area(ptr);
116579+ if (vm && (vm->flags & VM_USERCOPY))
116580+ return true;
116581+ return false;
116582+ }
116583+
116584+ // PAX: TODO
116585+
116586+ return false;
116587+}
116588+
116589+#ifdef CONFIG_PAX_USERCOPY
116590+const char *check_heap_object(const void *ptr, unsigned long n)
116591+{
116592+ struct page *page;
116593+ const slob_t *free;
116594+ const void *base;
116595+ unsigned long flags;
116596+
116597+ if (ZERO_OR_NULL_PTR(ptr))
116598+ return "<null>";
116599+
116600+ if (!virt_addr_valid(ptr))
116601+ return NULL;
116602+
116603+ page = virt_to_head_page(ptr);
116604+ if (!PageSlab(page))
116605+ return NULL;
116606+
116607+ if (page->private) {
116608+ base = page;
116609+ if (base <= ptr && n <= page->private - (ptr - base))
116610+ return NULL;
116611+ return "<slob>";
116612+ }
116613+
116614+ /* some tricky double walking to find the chunk */
116615+ spin_lock_irqsave(&slob_lock, flags);
116616+ base = (void *)((unsigned long)ptr & PAGE_MASK);
116617+ free = page->freelist;
116618+
116619+ while (!slob_last(free) && (void *)free <= ptr) {
116620+ base = free + slob_units(free);
116621+ free = slob_next(free);
116622+ }
116623+
116624+ while (base < (void *)free) {
116625+ slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
116626+ int size = SLOB_UNIT * SLOB_UNITS(m + align);
116627+ int offset;
116628+
116629+ if (ptr < base + align)
116630+ break;
116631+
116632+ offset = ptr - base - align;
116633+ if (offset >= m) {
116634+ base += size;
116635+ continue;
116636+ }
116637+
116638+ if (n > m - offset)
116639+ break;
116640+
116641+ spin_unlock_irqrestore(&slob_lock, flags);
116642+ return NULL;
116643+ }
116644+
116645+ spin_unlock_irqrestore(&slob_lock, flags);
116646+ return "<slob>";
116647+}
116648+#endif
116649+
116650 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
116651 size_t ksize(const void *block)
116652 {
116653 struct page *sp;
116654 int align;
116655- unsigned int *m;
116656+ slob_t *m;
116657
116658 BUG_ON(!block);
116659 if (unlikely(block == ZERO_SIZE_PTR))
116660 return 0;
116661
116662 sp = virt_to_page(block);
116663- if (unlikely(!PageSlab(sp)))
116664- return PAGE_SIZE << compound_order(sp);
116665+ VM_BUG_ON(!PageSlab(sp));
116666+ if (sp->private)
116667+ return sp->private;
116668
116669 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
116670- m = (unsigned int *)(block - align);
116671- return SLOB_UNITS(*m) * SLOB_UNIT;
116672+ m = (slob_t *)(block - align);
116673+ return SLOB_UNITS(m[0].units) * SLOB_UNIT;
116674 }
116675 EXPORT_SYMBOL(ksize);
116676
116677@@ -534,23 +648,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
116678
116679 static void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
116680 {
116681- void *b;
116682+ void *b = NULL;
116683
116684 flags &= gfp_allowed_mask;
116685
116686 lockdep_trace_alloc(flags);
116687
116688+#ifdef CONFIG_PAX_USERCOPY_SLABS
116689+ b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
116690+#else
116691 if (c->size < PAGE_SIZE) {
116692 b = slob_alloc(c->size, flags, c->align, node);
116693 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
116694 SLOB_UNITS(c->size) * SLOB_UNIT,
116695 flags, node);
116696 } else {
116697- b = slob_new_pages(flags, get_order(c->size), node);
116698+ struct page *sp;
116699+
116700+ sp = slob_new_pages(flags, get_order(c->size), node);
116701+ if (sp) {
116702+ b = page_address(sp);
116703+ sp->private = c->size;
116704+ }
116705 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
116706 PAGE_SIZE << get_order(c->size),
116707 flags, node);
116708 }
116709+#endif
116710
116711 if (b && c->ctor)
116712 c->ctor(b);
116713@@ -566,7 +690,7 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
116714 EXPORT_SYMBOL(kmem_cache_alloc);
116715
116716 #ifdef CONFIG_NUMA
116717-void *__kmalloc_node(size_t size, gfp_t gfp, int node)
116718+void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t gfp, int node)
116719 {
116720 return __do_kmalloc_node(size, gfp, node, _RET_IP_);
116721 }
116722@@ -579,12 +703,16 @@ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t gfp, int node)
116723 EXPORT_SYMBOL(kmem_cache_alloc_node);
116724 #endif
116725
116726-static void __kmem_cache_free(void *b, int size)
116727+static void __kmem_cache_free(struct kmem_cache *c, void *b, int size)
116728 {
116729- if (size < PAGE_SIZE)
116730- slob_free(b, size);
116731+ struct page *sp;
116732+
116733+ sp = virt_to_page(b);
116734+ BUG_ON(!PageSlab(sp));
116735+ if (!sp->private)
116736+ slob_free(c, b, size);
116737 else
116738- slob_free_pages(b, get_order(size));
116739+ slob_free_pages(sp, get_order(size));
116740 }
116741
116742 static void kmem_rcu_free(struct rcu_head *head)
116743@@ -592,22 +720,36 @@ static void kmem_rcu_free(struct rcu_head *head)
116744 struct slob_rcu *slob_rcu = (struct slob_rcu *)head;
116745 void *b = (void *)slob_rcu - (slob_rcu->size - sizeof(struct slob_rcu));
116746
116747- __kmem_cache_free(b, slob_rcu->size);
116748+ __kmem_cache_free(NULL, b, slob_rcu->size);
116749 }
116750
116751 void kmem_cache_free(struct kmem_cache *c, void *b)
116752 {
116753+ int size = c->size;
116754+
116755+#ifdef CONFIG_PAX_USERCOPY_SLABS
116756+ if (size + c->align < PAGE_SIZE) {
116757+ size += c->align;
116758+ b -= c->align;
116759+ }
116760+#endif
116761+
116762 kmemleak_free_recursive(b, c->flags);
116763 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
116764 struct slob_rcu *slob_rcu;
116765- slob_rcu = b + (c->size - sizeof(struct slob_rcu));
116766- slob_rcu->size = c->size;
116767+ slob_rcu = b + (size - sizeof(struct slob_rcu));
116768+ slob_rcu->size = size;
116769 call_rcu(&slob_rcu->head, kmem_rcu_free);
116770 } else {
116771- __kmem_cache_free(b, c->size);
116772+ __kmem_cache_free(c, b, size);
116773 }
116774
116775+#ifdef CONFIG_PAX_USERCOPY_SLABS
116776+ trace_kfree(_RET_IP_, b);
116777+#else
116778 trace_kmem_cache_free(_RET_IP_, b);
116779+#endif
116780+
116781 }
116782 EXPORT_SYMBOL(kmem_cache_free);
116783
116784diff --git a/mm/slub.c b/mm/slub.c
116785index f68c0e5..eb77178 100644
116786--- a/mm/slub.c
116787+++ b/mm/slub.c
116788@@ -34,6 +34,7 @@
116789 #include <linux/stacktrace.h>
116790 #include <linux/prefetch.h>
116791 #include <linux/memcontrol.h>
116792+#include <linux/vmalloc.h>
116793
116794 #include <trace/events/kmem.h>
116795
116796@@ -198,7 +199,7 @@ struct track {
116797
116798 enum track_item { TRACK_ALLOC, TRACK_FREE };
116799
116800-#ifdef CONFIG_SYSFS
116801+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116802 static int sysfs_slab_add(struct kmem_cache *);
116803 static int sysfs_slab_alias(struct kmem_cache *, const char *);
116804 static void memcg_propagate_slab_attrs(struct kmem_cache *s);
116805@@ -556,7 +557,7 @@ static void print_track(const char *s, struct track *t)
116806 if (!t->addr)
116807 return;
116808
116809- pr_err("INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
116810+ pr_err("INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
116811 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
116812 #ifdef CONFIG_STACKTRACE
116813 {
116814@@ -2707,6 +2708,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
116815
116816 slab_free_hook(s, x);
116817
116818+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116819+ if (!(s->flags & SLAB_NO_SANITIZE)) {
116820+ memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
116821+ if (s->ctor)
116822+ s->ctor(x);
116823+ }
116824+#endif
116825+
116826 redo:
116827 /*
116828 * Determine the currently cpus per cpu slab.
116829@@ -3048,6 +3057,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
116830 s->inuse = size;
116831
116832 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
116833+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116834+ (!(flags & SLAB_NO_SANITIZE)) ||
116835+#endif
116836 s->ctor)) {
116837 /*
116838 * Relocate free pointer after the object if it is not
116839@@ -3302,7 +3314,7 @@ static int __init setup_slub_min_objects(char *str)
116840
116841 __setup("slub_min_objects=", setup_slub_min_objects);
116842
116843-void *__kmalloc(size_t size, gfp_t flags)
116844+void * __size_overflow(1) __kmalloc(size_t size, gfp_t flags)
116845 {
116846 struct kmem_cache *s;
116847 void *ret;
116848@@ -3340,7 +3352,7 @@ static void *kmalloc_large_node(size_t size, gfp_t flags, int node)
116849 return ptr;
116850 }
116851
116852-void *__kmalloc_node(size_t size, gfp_t flags, int node)
116853+void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t flags, int node)
116854 {
116855 struct kmem_cache *s;
116856 void *ret;
116857@@ -3388,6 +3400,70 @@ static size_t __ksize(const void *object)
116858 return slab_ksize(page->slab_cache);
116859 }
116860
116861+bool is_usercopy_object(const void *ptr)
116862+{
116863+ struct page *page;
116864+ struct kmem_cache *s;
116865+
116866+ if (ZERO_OR_NULL_PTR(ptr))
116867+ return false;
116868+
116869+ if (!slab_is_available())
116870+ return false;
116871+
116872+ if (is_vmalloc_addr(ptr)
116873+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116874+ && !object_starts_on_stack(ptr)
116875+#endif
116876+ ) {
116877+ struct vm_struct *vm = find_vm_area(ptr);
116878+ if (vm && (vm->flags & VM_USERCOPY))
116879+ return true;
116880+ return false;
116881+ }
116882+
116883+ if (!virt_addr_valid(ptr))
116884+ return false;
116885+
116886+ page = virt_to_head_page(ptr);
116887+
116888+ if (!PageSlab(page))
116889+ return false;
116890+
116891+ s = page->slab_cache;
116892+ return s->flags & SLAB_USERCOPY;
116893+}
116894+
116895+#ifdef CONFIG_PAX_USERCOPY
116896+const char *check_heap_object(const void *ptr, unsigned long n)
116897+{
116898+ struct page *page;
116899+ struct kmem_cache *s;
116900+ unsigned long offset;
116901+
116902+ if (ZERO_OR_NULL_PTR(ptr))
116903+ return "<null>";
116904+
116905+ if (!virt_addr_valid(ptr))
116906+ return NULL;
116907+
116908+ page = virt_to_head_page(ptr);
116909+
116910+ if (!PageSlab(page))
116911+ return NULL;
116912+
116913+ s = page->slab_cache;
116914+ if (!(s->flags & SLAB_USERCOPY))
116915+ return s->name;
116916+
116917+ offset = (ptr - page_address(page)) % s->size;
116918+ if (offset <= s->object_size && n <= s->object_size - offset)
116919+ return NULL;
116920+
116921+ return s->name;
116922+}
116923+#endif
116924+
116925 size_t ksize(const void *object)
116926 {
116927 size_t size = __ksize(object);
116928@@ -3408,6 +3484,7 @@ void kfree(const void *x)
116929 if (unlikely(ZERO_OR_NULL_PTR(x)))
116930 return;
116931
116932+ VM_BUG_ON(!virt_addr_valid(x));
116933 page = virt_to_head_page(x);
116934 if (unlikely(!PageSlab(page))) {
116935 BUG_ON(!PageCompound(page));
116936@@ -3725,7 +3802,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
116937
116938 s = find_mergeable(size, align, flags, name, ctor);
116939 if (s) {
116940- s->refcount++;
116941+ atomic_inc(&s->refcount);
116942
116943 /*
116944 * Adjust the object sizes so that we clear
116945@@ -3741,7 +3818,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
116946 }
116947
116948 if (sysfs_slab_alias(s, name)) {
116949- s->refcount--;
116950+ atomic_dec(&s->refcount);
116951 s = NULL;
116952 }
116953 }
116954@@ -3858,7 +3935,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
116955 }
116956 #endif
116957
116958-#ifdef CONFIG_SYSFS
116959+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116960 static int count_inuse(struct page *page)
116961 {
116962 return page->inuse;
116963@@ -4139,7 +4216,11 @@ static int list_locations(struct kmem_cache *s, char *buf,
116964 len += sprintf(buf + len, "%7ld ", l->count);
116965
116966 if (l->addr)
116967+#ifdef CONFIG_GRKERNSEC_HIDESYM
116968+ len += sprintf(buf + len, "%pS", NULL);
116969+#else
116970 len += sprintf(buf + len, "%pS", (void *)l->addr);
116971+#endif
116972 else
116973 len += sprintf(buf + len, "<not-available>");
116974
116975@@ -4237,12 +4318,12 @@ static void __init resiliency_test(void)
116976 validate_slab_cache(kmalloc_caches[9]);
116977 }
116978 #else
116979-#ifdef CONFIG_SYSFS
116980+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116981 static void resiliency_test(void) {};
116982 #endif
116983 #endif
116984
116985-#ifdef CONFIG_SYSFS
116986+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116987 enum slab_stat_type {
116988 SL_ALL, /* All slabs */
116989 SL_PARTIAL, /* Only partially allocated slabs */
116990@@ -4479,13 +4560,17 @@ static ssize_t ctor_show(struct kmem_cache *s, char *buf)
116991 {
116992 if (!s->ctor)
116993 return 0;
116994+#ifdef CONFIG_GRKERNSEC_HIDESYM
116995+ return sprintf(buf, "%pS\n", NULL);
116996+#else
116997 return sprintf(buf, "%pS\n", s->ctor);
116998+#endif
116999 }
117000 SLAB_ATTR_RO(ctor);
117001
117002 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
117003 {
117004- return sprintf(buf, "%d\n", s->refcount < 0 ? 0 : s->refcount - 1);
117005+ return sprintf(buf, "%d\n", atomic_read(&s->refcount) < 0 ? 0 : atomic_read(&s->refcount) - 1);
117006 }
117007 SLAB_ATTR_RO(aliases);
117008
117009@@ -4573,6 +4658,22 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
117010 SLAB_ATTR_RO(cache_dma);
117011 #endif
117012
117013+#ifdef CONFIG_PAX_USERCOPY_SLABS
117014+static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
117015+{
117016+ return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
117017+}
117018+SLAB_ATTR_RO(usercopy);
117019+#endif
117020+
117021+#ifdef CONFIG_PAX_MEMORY_SANITIZE
117022+static ssize_t sanitize_show(struct kmem_cache *s, char *buf)
117023+{
117024+ return sprintf(buf, "%d\n", !(s->flags & SLAB_NO_SANITIZE));
117025+}
117026+SLAB_ATTR_RO(sanitize);
117027+#endif
117028+
117029 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
117030 {
117031 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
117032@@ -4628,7 +4729,7 @@ static ssize_t trace_store(struct kmem_cache *s, const char *buf,
117033 * as well as cause other issues like converting a mergeable
117034 * cache into an umergeable one.
117035 */
117036- if (s->refcount > 1)
117037+ if (atomic_read(&s->refcount) > 1)
117038 return -EINVAL;
117039
117040 s->flags &= ~SLAB_TRACE;
117041@@ -4748,7 +4849,7 @@ static ssize_t failslab_show(struct kmem_cache *s, char *buf)
117042 static ssize_t failslab_store(struct kmem_cache *s, const char *buf,
117043 size_t length)
117044 {
117045- if (s->refcount > 1)
117046+ if (atomic_read(&s->refcount) > 1)
117047 return -EINVAL;
117048
117049 s->flags &= ~SLAB_FAILSLAB;
117050@@ -4915,6 +5016,12 @@ static struct attribute *slab_attrs[] = {
117051 #ifdef CONFIG_ZONE_DMA
117052 &cache_dma_attr.attr,
117053 #endif
117054+#ifdef CONFIG_PAX_USERCOPY_SLABS
117055+ &usercopy_attr.attr,
117056+#endif
117057+#ifdef CONFIG_PAX_MEMORY_SANITIZE
117058+ &sanitize_attr.attr,
117059+#endif
117060 #ifdef CONFIG_NUMA
117061 &remote_node_defrag_ratio_attr.attr,
117062 #endif
117063@@ -5156,6 +5263,7 @@ static char *create_unique_id(struct kmem_cache *s)
117064 return name;
117065 }
117066
117067+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
117068 static int sysfs_slab_add(struct kmem_cache *s)
117069 {
117070 int err;
117071@@ -5229,6 +5337,7 @@ void sysfs_slab_remove(struct kmem_cache *s)
117072 kobject_del(&s->kobj);
117073 kobject_put(&s->kobj);
117074 }
117075+#endif
117076
117077 /*
117078 * Need to buffer aliases during bootup until sysfs becomes
117079@@ -5242,6 +5351,7 @@ struct saved_alias {
117080
117081 static struct saved_alias *alias_list;
117082
117083+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
117084 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
117085 {
117086 struct saved_alias *al;
117087@@ -5264,6 +5374,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
117088 alias_list = al;
117089 return 0;
117090 }
117091+#endif
117092
117093 static int __init slab_sysfs_init(void)
117094 {
117095diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
117096index 4cba9c2..b4f9fcc 100644
117097--- a/mm/sparse-vmemmap.c
117098+++ b/mm/sparse-vmemmap.c
117099@@ -131,7 +131,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
117100 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
117101 if (!p)
117102 return NULL;
117103- pud_populate(&init_mm, pud, p);
117104+ pud_populate_kernel(&init_mm, pud, p);
117105 }
117106 return pud;
117107 }
117108@@ -143,7 +143,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
117109 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
117110 if (!p)
117111 return NULL;
117112- pgd_populate(&init_mm, pgd, p);
117113+ pgd_populate_kernel(&init_mm, pgd, p);
117114 }
117115 return pgd;
117116 }
117117diff --git a/mm/sparse.c b/mm/sparse.c
117118index d1b48b6..6e8590e 100644
117119--- a/mm/sparse.c
117120+++ b/mm/sparse.c
117121@@ -750,7 +750,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
117122
117123 for (i = 0; i < PAGES_PER_SECTION; i++) {
117124 if (PageHWPoison(&memmap[i])) {
117125- atomic_long_sub(1, &num_poisoned_pages);
117126+ atomic_long_sub_unchecked(1, &num_poisoned_pages);
117127 ClearPageHWPoison(&memmap[i]);
117128 }
117129 }
117130diff --git a/mm/swap.c b/mm/swap.c
117131index a3a0a2f..915d436 100644
117132--- a/mm/swap.c
117133+++ b/mm/swap.c
117134@@ -85,6 +85,8 @@ static void __put_compound_page(struct page *page)
117135 if (!PageHuge(page))
117136 __page_cache_release(page);
117137 dtor = get_compound_page_dtor(page);
117138+ if (!PageHuge(page))
117139+ BUG_ON(dtor != free_compound_page);
117140 (*dtor)(page);
117141 }
117142
117143diff --git a/mm/swapfile.c b/mm/swapfile.c
117144index 41e4581..6c452c9 100644
117145--- a/mm/swapfile.c
117146+++ b/mm/swapfile.c
117147@@ -84,7 +84,7 @@ static DEFINE_MUTEX(swapon_mutex);
117148
117149 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
117150 /* Activity counter to indicate that a swapon or swapoff has occurred */
117151-static atomic_t proc_poll_event = ATOMIC_INIT(0);
117152+static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
117153
117154 static inline unsigned char swap_count(unsigned char ent)
117155 {
117156@@ -1944,7 +1944,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
117157 spin_unlock(&swap_lock);
117158
117159 err = 0;
117160- atomic_inc(&proc_poll_event);
117161+ atomic_inc_unchecked(&proc_poll_event);
117162 wake_up_interruptible(&proc_poll_wait);
117163
117164 out_dput:
117165@@ -1961,8 +1961,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
117166
117167 poll_wait(file, &proc_poll_wait, wait);
117168
117169- if (seq->poll_event != atomic_read(&proc_poll_event)) {
117170- seq->poll_event = atomic_read(&proc_poll_event);
117171+ if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
117172+ seq->poll_event = atomic_read_unchecked(&proc_poll_event);
117173 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
117174 }
117175
117176@@ -2060,7 +2060,7 @@ static int swaps_open(struct inode *inode, struct file *file)
117177 return ret;
117178
117179 seq = file->private_data;
117180- seq->poll_event = atomic_read(&proc_poll_event);
117181+ seq->poll_event = atomic_read_unchecked(&proc_poll_event);
117182 return 0;
117183 }
117184
117185@@ -2520,7 +2520,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
117186 (frontswap_map) ? "FS" : "");
117187
117188 mutex_unlock(&swapon_mutex);
117189- atomic_inc(&proc_poll_event);
117190+ atomic_inc_unchecked(&proc_poll_event);
117191 wake_up_interruptible(&proc_poll_wait);
117192
117193 if (S_ISREG(inode->i_mode))
117194diff --git a/mm/util.c b/mm/util.c
117195index 68ff8a5..40c7a70 100644
117196--- a/mm/util.c
117197+++ b/mm/util.c
117198@@ -233,6 +233,12 @@ struct task_struct *task_of_stack(struct task_struct *task,
117199 void arch_pick_mmap_layout(struct mm_struct *mm)
117200 {
117201 mm->mmap_base = TASK_UNMAPPED_BASE;
117202+
117203+#ifdef CONFIG_PAX_RANDMMAP
117204+ if (mm->pax_flags & MF_PAX_RANDMMAP)
117205+ mm->mmap_base += mm->delta_mmap;
117206+#endif
117207+
117208 mm->get_unmapped_area = arch_get_unmapped_area;
117209 }
117210 #endif
117211@@ -434,6 +440,9 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen)
117212 if (!mm->arg_end)
117213 goto out_mm; /* Shh! No looking before we're done */
117214
117215+ if (gr_acl_handle_procpidmem(task))
117216+ goto out_mm;
117217+
117218 len = mm->arg_end - mm->arg_start;
117219
117220 if (len > buflen)
117221diff --git a/mm/vmalloc.c b/mm/vmalloc.c
117222index 2faaa29..c816cf4 100644
117223--- a/mm/vmalloc.c
117224+++ b/mm/vmalloc.c
117225@@ -40,20 +40,65 @@ struct vfree_deferred {
117226 struct work_struct wq;
117227 };
117228 static DEFINE_PER_CPU(struct vfree_deferred, vfree_deferred);
117229+static DEFINE_PER_CPU(struct vfree_deferred, vunmap_deferred);
117230+
117231+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117232+struct stack_deferred_llist {
117233+ struct llist_head list;
117234+ void *stack;
117235+ void *lowmem_stack;
117236+};
117237+
117238+struct stack_deferred {
117239+ struct stack_deferred_llist list;
117240+ struct work_struct wq;
117241+};
117242+
117243+static DEFINE_PER_CPU(struct stack_deferred, stack_deferred);
117244+#endif
117245
117246 static void __vunmap(const void *, int);
117247
117248-static void free_work(struct work_struct *w)
117249+static void vfree_work(struct work_struct *w)
117250 {
117251 struct vfree_deferred *p = container_of(w, struct vfree_deferred, wq);
117252 struct llist_node *llnode = llist_del_all(&p->list);
117253 while (llnode) {
117254- void *p = llnode;
117255+ void *x = llnode;
117256 llnode = llist_next(llnode);
117257- __vunmap(p, 1);
117258+ __vunmap(x, 1);
117259 }
117260 }
117261
117262+static void vunmap_work(struct work_struct *w)
117263+{
117264+ struct vfree_deferred *p = container_of(w, struct vfree_deferred, wq);
117265+ struct llist_node *llnode = llist_del_all(&p->list);
117266+ while (llnode) {
117267+ void *x = llnode;
117268+ llnode = llist_next(llnode);
117269+ __vunmap(x, 0);
117270+ }
117271+}
117272+
117273+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117274+static void unmap_work(struct work_struct *w)
117275+{
117276+ struct stack_deferred *p = container_of(w, struct stack_deferred, wq);
117277+ struct llist_node *llnode = llist_del_all(&p->list.list);
117278+ while (llnode) {
117279+ struct stack_deferred_llist *x =
117280+ llist_entry((struct llist_head *)llnode,
117281+ struct stack_deferred_llist, list);
117282+ void *stack = ACCESS_ONCE(x->stack);
117283+ void *lowmem_stack = ACCESS_ONCE(x->lowmem_stack);
117284+ llnode = llist_next(llnode);
117285+ __vunmap(stack, 0);
117286+ free_kmem_pages((unsigned long)lowmem_stack, THREAD_SIZE_ORDER);
117287+ }
117288+}
117289+#endif
117290+
117291 /*** Page table manipulation functions ***/
117292
117293 static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
117294@@ -61,10 +106,23 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
117295 pte_t *pte;
117296
117297 pte = pte_offset_kernel(pmd, addr);
117298+ pax_open_kernel();
117299 do {
117300- pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
117301- WARN_ON(!pte_none(ptent) && !pte_present(ptent));
117302+
117303+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
117304+ if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
117305+ BUG_ON(!pte_exec(*pte));
117306+ set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
117307+ continue;
117308+ }
117309+#endif
117310+
117311+ {
117312+ pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
117313+ WARN_ON(!pte_none(ptent) && !pte_present(ptent));
117314+ }
117315 } while (pte++, addr += PAGE_SIZE, addr != end);
117316+ pax_close_kernel();
117317 }
117318
117319 static void vunmap_pmd_range(pud_t *pud, unsigned long addr, unsigned long end)
117320@@ -127,16 +185,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
117321 pte = pte_alloc_kernel(pmd, addr);
117322 if (!pte)
117323 return -ENOMEM;
117324+
117325+ pax_open_kernel();
117326 do {
117327 struct page *page = pages[*nr];
117328
117329- if (WARN_ON(!pte_none(*pte)))
117330+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
117331+ if (pgprot_val(prot) & _PAGE_NX)
117332+#endif
117333+
117334+ if (!pte_none(*pte)) {
117335+ pax_close_kernel();
117336+ WARN_ON(1);
117337 return -EBUSY;
117338- if (WARN_ON(!page))
117339+ }
117340+ if (!page) {
117341+ pax_close_kernel();
117342+ WARN_ON(1);
117343 return -ENOMEM;
117344+ }
117345 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
117346 (*nr)++;
117347 } while (pte++, addr += PAGE_SIZE, addr != end);
117348+ pax_close_kernel();
117349 return 0;
117350 }
117351
117352@@ -146,7 +217,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
117353 pmd_t *pmd;
117354 unsigned long next;
117355
117356- pmd = pmd_alloc(&init_mm, pud, addr);
117357+ pmd = pmd_alloc_kernel(&init_mm, pud, addr);
117358 if (!pmd)
117359 return -ENOMEM;
117360 do {
117361@@ -163,7 +234,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
117362 pud_t *pud;
117363 unsigned long next;
117364
117365- pud = pud_alloc(&init_mm, pgd, addr);
117366+ pud = pud_alloc_kernel(&init_mm, pgd, addr);
117367 if (!pud)
117368 return -ENOMEM;
117369 do {
117370@@ -223,6 +294,12 @@ int is_vmalloc_or_module_addr(const void *x)
117371 if (addr >= MODULES_VADDR && addr < MODULES_END)
117372 return 1;
117373 #endif
117374+
117375+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
117376+ if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
117377+ return 1;
117378+#endif
117379+
117380 return is_vmalloc_addr(x);
117381 }
117382
117383@@ -243,8 +320,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
117384
117385 if (!pgd_none(*pgd)) {
117386 pud_t *pud = pud_offset(pgd, addr);
117387+#ifdef CONFIG_X86
117388+ if (!pud_large(*pud))
117389+#endif
117390 if (!pud_none(*pud)) {
117391 pmd_t *pmd = pmd_offset(pud, addr);
117392+#ifdef CONFIG_X86
117393+ if (!pmd_large(*pmd))
117394+#endif
117395 if (!pmd_none(*pmd)) {
117396 pte_t *ptep, pte;
117397
117398@@ -346,7 +429,7 @@ static void purge_vmap_area_lazy(void);
117399 * Allocate a region of KVA of the specified size and alignment, within the
117400 * vstart and vend.
117401 */
117402-static struct vmap_area *alloc_vmap_area(unsigned long size,
117403+static struct vmap_area * __size_overflow(1) alloc_vmap_area(unsigned long size,
117404 unsigned long align,
117405 unsigned long vstart, unsigned long vend,
117406 int node, gfp_t gfp_mask)
117407@@ -1202,13 +1285,27 @@ void __init vmalloc_init(void)
117408 for_each_possible_cpu(i) {
117409 struct vmap_block_queue *vbq;
117410 struct vfree_deferred *p;
117411+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117412+ struct stack_deferred *p2;
117413+#endif
117414
117415 vbq = &per_cpu(vmap_block_queue, i);
117416 spin_lock_init(&vbq->lock);
117417 INIT_LIST_HEAD(&vbq->free);
117418+
117419 p = &per_cpu(vfree_deferred, i);
117420 init_llist_head(&p->list);
117421- INIT_WORK(&p->wq, free_work);
117422+ INIT_WORK(&p->wq, vfree_work);
117423+
117424+ p = &per_cpu(vunmap_deferred, i);
117425+ init_llist_head(&p->list);
117426+ INIT_WORK(&p->wq, vunmap_work);
117427+
117428+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117429+ p2 = &per_cpu(stack_deferred, i);
117430+ init_llist_head(&p2->list.list);
117431+ INIT_WORK(&p2->wq, unmap_work);
117432+#endif
117433 }
117434
117435 /* Import existing vmlist entries. */
117436@@ -1333,6 +1430,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
117437 struct vm_struct *area;
117438
117439 BUG_ON(in_interrupt());
117440+
117441+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
117442+ if (flags & VM_KERNEXEC) {
117443+ if (start != VMALLOC_START || end != VMALLOC_END)
117444+ return NULL;
117445+ start = (unsigned long)MODULES_EXEC_VADDR;
117446+ end = (unsigned long)MODULES_EXEC_END;
117447+ }
117448+#endif
117449+
117450 if (flags & VM_IOREMAP)
117451 align = 1ul << clamp_t(int, fls_long(size),
117452 PAGE_SHIFT, IOREMAP_MAX_ORDER);
117453@@ -1531,13 +1638,36 @@ EXPORT_SYMBOL(vfree);
117454 */
117455 void vunmap(const void *addr)
117456 {
117457- BUG_ON(in_interrupt());
117458- might_sleep();
117459- if (addr)
117460+ if (!addr)
117461+ return;
117462+ if (unlikely(in_interrupt())) {
117463+ struct vfree_deferred *p = this_cpu_ptr(&vunmap_deferred);
117464+ if (llist_add((struct llist_node *)addr, &p->list))
117465+ schedule_work(&p->wq);
117466+ } else {
117467+ might_sleep();
117468 __vunmap(addr, 0);
117469+ }
117470 }
117471 EXPORT_SYMBOL(vunmap);
117472
117473+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
117474+void unmap_process_stacks(struct task_struct *task)
117475+{
117476+ if (unlikely(in_interrupt())) {
117477+ struct stack_deferred *p = this_cpu_ptr(&stack_deferred);
117478+ struct stack_deferred_llist *list = task->stack;
117479+ list->stack = task->stack;
117480+ list->lowmem_stack = task->lowmem_stack;
117481+ if (llist_add((struct llist_node *)&list->list, &p->list.list))
117482+ schedule_work(&p->wq);
117483+ } else {
117484+ __vunmap(task->stack, 0);
117485+ free_kmem_pages((unsigned long)task->lowmem_stack, THREAD_SIZE_ORDER);
117486+ }
117487+}
117488+#endif
117489+
117490 /**
117491 * vmap - map an array of pages into virtually contiguous space
117492 * @pages: array of page pointers
117493@@ -1558,6 +1688,11 @@ void *vmap(struct page **pages, unsigned int count,
117494 if (count > totalram_pages)
117495 return NULL;
117496
117497+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
117498+ if (!(pgprot_val(prot) & _PAGE_NX))
117499+ flags |= VM_KERNEXEC;
117500+#endif
117501+
117502 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
117503 __builtin_return_address(0));
117504 if (!area)
117505@@ -1662,6 +1797,14 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
117506 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
117507 goto fail;
117508
117509+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
117510+ if (!(pgprot_val(prot) & _PAGE_NX)) {
117511+ vm_flags |= VM_KERNEXEC;
117512+ start = VMALLOC_START;
117513+ end = VMALLOC_END;
117514+ }
117515+#endif
117516+
117517 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED |
117518 vm_flags, start, end, node, gfp_mask, caller);
117519 if (!area)
117520@@ -1715,6 +1858,14 @@ static void *__vmalloc_node(unsigned long size, unsigned long align,
117521 gfp_mask, prot, 0, node, caller);
117522 }
117523
117524+void *vmalloc_usercopy(unsigned long size)
117525+{
117526+ return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
117527+ GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL,
117528+ VM_USERCOPY, NUMA_NO_NODE,
117529+ __builtin_return_address(0));
117530+}
117531+
117532 void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
117533 {
117534 return __vmalloc_node(size, 1, gfp_mask, prot, NUMA_NO_NODE,
117535@@ -1838,10 +1989,9 @@ EXPORT_SYMBOL(vzalloc_node);
117536 * For tight control over page level allocator and protection flags
117537 * use __vmalloc() instead.
117538 */
117539-
117540 void *vmalloc_exec(unsigned long size)
117541 {
117542- return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
117543+ return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
117544 NUMA_NO_NODE, __builtin_return_address(0));
117545 }
117546
117547@@ -2148,6 +2298,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
117548 {
117549 struct vm_struct *area;
117550
117551+ BUG_ON(vma->vm_mirror);
117552+
117553 size = PAGE_ALIGN(size);
117554
117555 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
117556@@ -2630,7 +2782,11 @@ static int s_show(struct seq_file *m, void *p)
117557 v->addr, v->addr + v->size, v->size);
117558
117559 if (v->caller)
117560+#ifdef CONFIG_GRKERNSEC_HIDESYM
117561+ seq_printf(m, " %pK", v->caller);
117562+#else
117563 seq_printf(m, " %pS", v->caller);
117564+#endif
117565
117566 if (v->nr_pages)
117567 seq_printf(m, " pages=%d", v->nr_pages);
117568diff --git a/mm/vmstat.c b/mm/vmstat.c
117569index 4f5cd97..9fb715a 100644
117570--- a/mm/vmstat.c
117571+++ b/mm/vmstat.c
117572@@ -27,6 +27,7 @@
117573 #include <linux/mm_inline.h>
117574 #include <linux/page_ext.h>
117575 #include <linux/page_owner.h>
117576+#include <linux/grsecurity.h>
117577
117578 #include "internal.h"
117579
117580@@ -86,7 +87,7 @@ void vm_events_fold_cpu(int cpu)
117581 *
117582 * vm_stat contains the global counters
117583 */
117584-atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
117585+atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
117586 EXPORT_SYMBOL(vm_stat);
117587
117588 #ifdef CONFIG_SMP
117589@@ -438,7 +439,7 @@ static int fold_diff(int *diff)
117590
117591 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
117592 if (diff[i]) {
117593- atomic_long_add(diff[i], &vm_stat[i]);
117594+ atomic_long_add_unchecked(diff[i], &vm_stat[i]);
117595 changes++;
117596 }
117597 return changes;
117598@@ -476,7 +477,7 @@ static int refresh_cpu_vm_stats(void)
117599 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
117600 if (v) {
117601
117602- atomic_long_add(v, &zone->vm_stat[i]);
117603+ atomic_long_add_unchecked(v, &zone->vm_stat[i]);
117604 global_diff[i] += v;
117605 #ifdef CONFIG_NUMA
117606 /* 3 seconds idle till flush */
117607@@ -540,7 +541,7 @@ void cpu_vm_stats_fold(int cpu)
117608
117609 v = p->vm_stat_diff[i];
117610 p->vm_stat_diff[i] = 0;
117611- atomic_long_add(v, &zone->vm_stat[i]);
117612+ atomic_long_add_unchecked(v, &zone->vm_stat[i]);
117613 global_diff[i] += v;
117614 }
117615 }
117616@@ -560,8 +561,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
117617 if (pset->vm_stat_diff[i]) {
117618 int v = pset->vm_stat_diff[i];
117619 pset->vm_stat_diff[i] = 0;
117620- atomic_long_add(v, &zone->vm_stat[i]);
117621- atomic_long_add(v, &vm_stat[i]);
117622+ atomic_long_add_unchecked(v, &zone->vm_stat[i]);
117623+ atomic_long_add_unchecked(v, &vm_stat[i]);
117624 }
117625 }
117626 #endif
117627@@ -1293,10 +1294,22 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
117628 stat_items_size += sizeof(struct vm_event_state);
117629 #endif
117630
117631- v = kmalloc(stat_items_size, GFP_KERNEL);
117632+ v = kzalloc(stat_items_size, GFP_KERNEL);
117633 m->private = v;
117634 if (!v)
117635 return ERR_PTR(-ENOMEM);
117636+
117637+#ifdef CONFIG_GRKERNSEC_PROC_ADD
117638+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
117639+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
117640+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
117641+ && !in_group_p(grsec_proc_gid)
117642+#endif
117643+ )
117644+ return (unsigned long *)m->private + *pos;
117645+#endif
117646+#endif
117647+
117648 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
117649 v[i] = global_page_state(i);
117650 v += NR_VM_ZONE_STAT_ITEMS;
117651@@ -1528,10 +1541,16 @@ static int __init setup_vmstat(void)
117652 cpu_notifier_register_done();
117653 #endif
117654 #ifdef CONFIG_PROC_FS
117655- proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
117656- proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
117657- proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
117658- proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
117659+ {
117660+ mode_t gr_mode = S_IRUGO;
117661+#ifdef CONFIG_GRKERNSEC_PROC_ADD
117662+ gr_mode = S_IRUSR;
117663+#endif
117664+ proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
117665+ proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
117666+ proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
117667+ proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
117668+ }
117669 #endif
117670 return 0;
117671 }
117672diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
117673index d2cd9de..501c186 100644
117674--- a/net/8021q/vlan.c
117675+++ b/net/8021q/vlan.c
117676@@ -491,7 +491,7 @@ out:
117677 return NOTIFY_DONE;
117678 }
117679
117680-static struct notifier_block vlan_notifier_block __read_mostly = {
117681+static struct notifier_block vlan_notifier_block = {
117682 .notifier_call = vlan_device_event,
117683 };
117684
117685@@ -566,8 +566,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
117686 err = -EPERM;
117687 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
117688 break;
117689- if ((args.u.name_type >= 0) &&
117690- (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
117691+ if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
117692 struct vlan_net *vn;
117693
117694 vn = net_generic(net, vlan_net_id);
117695diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
117696index c92b52f..006c052 100644
117697--- a/net/8021q/vlan_netlink.c
117698+++ b/net/8021q/vlan_netlink.c
117699@@ -245,7 +245,7 @@ static struct net *vlan_get_link_net(const struct net_device *dev)
117700 return dev_net(real_dev);
117701 }
117702
117703-struct rtnl_link_ops vlan_link_ops __read_mostly = {
117704+struct rtnl_link_ops vlan_link_ops = {
117705 .kind = "vlan",
117706 .maxtype = IFLA_VLAN_MAX,
117707 .policy = vlan_policy,
117708diff --git a/net/9p/mod.c b/net/9p/mod.c
117709index 6ab36ae..6f1841b 100644
117710--- a/net/9p/mod.c
117711+++ b/net/9p/mod.c
117712@@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
117713 void v9fs_register_trans(struct p9_trans_module *m)
117714 {
117715 spin_lock(&v9fs_trans_lock);
117716- list_add_tail(&m->list, &v9fs_trans_list);
117717+ pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
117718 spin_unlock(&v9fs_trans_lock);
117719 }
117720 EXPORT_SYMBOL(v9fs_register_trans);
117721@@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
117722 void v9fs_unregister_trans(struct p9_trans_module *m)
117723 {
117724 spin_lock(&v9fs_trans_lock);
117725- list_del_init(&m->list);
117726+ pax_list_del_init((struct list_head *)&m->list);
117727 spin_unlock(&v9fs_trans_lock);
117728 }
117729 EXPORT_SYMBOL(v9fs_unregister_trans);
117730diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
117731index bced8c0..ef253b7 100644
117732--- a/net/9p/trans_fd.c
117733+++ b/net/9p/trans_fd.c
117734@@ -428,7 +428,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
117735 oldfs = get_fs();
117736 set_fs(get_ds());
117737 /* The cast to a user pointer is valid due to the set_fs() */
117738- ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
117739+ ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
117740 set_fs(oldfs);
117741
117742 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
117743diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
117744index af46bc4..f9adfcd 100644
117745--- a/net/appletalk/atalk_proc.c
117746+++ b/net/appletalk/atalk_proc.c
117747@@ -256,7 +256,7 @@ int __init atalk_proc_init(void)
117748 struct proc_dir_entry *p;
117749 int rc = -ENOMEM;
117750
117751- atalk_proc_dir = proc_mkdir("atalk", init_net.proc_net);
117752+ atalk_proc_dir = proc_mkdir_restrict("atalk", init_net.proc_net);
117753 if (!atalk_proc_dir)
117754 goto out;
117755
117756diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
117757index 876fbe8..8bbea9f 100644
117758--- a/net/atm/atm_misc.c
117759+++ b/net/atm/atm_misc.c
117760@@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
117761 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
117762 return 1;
117763 atm_return(vcc, truesize);
117764- atomic_inc(&vcc->stats->rx_drop);
117765+ atomic_inc_unchecked(&vcc->stats->rx_drop);
117766 return 0;
117767 }
117768 EXPORT_SYMBOL(atm_charge);
117769@@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
117770 }
117771 }
117772 atm_return(vcc, guess);
117773- atomic_inc(&vcc->stats->rx_drop);
117774+ atomic_inc_unchecked(&vcc->stats->rx_drop);
117775 return NULL;
117776 }
117777 EXPORT_SYMBOL(atm_alloc_charge);
117778@@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
117779
117780 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
117781 {
117782-#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
117783+#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
117784 __SONET_ITEMS
117785 #undef __HANDLE_ITEM
117786 }
117787@@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
117788
117789 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
117790 {
117791-#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
117792+#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
117793 __SONET_ITEMS
117794 #undef __HANDLE_ITEM
117795 }
117796diff --git a/net/atm/lec.c b/net/atm/lec.c
117797index cd3b379..977a3c9 100644
117798--- a/net/atm/lec.c
117799+++ b/net/atm/lec.c
117800@@ -111,9 +111,9 @@ static inline void lec_arp_put(struct lec_arp_table *entry)
117801 }
117802
117803 static struct lane2_ops lane2_ops = {
117804- lane2_resolve, /* resolve, spec 3.1.3 */
117805- lane2_associate_req, /* associate_req, spec 3.1.4 */
117806- NULL /* associate indicator, spec 3.1.5 */
117807+ .resolve = lane2_resolve,
117808+ .associate_req = lane2_associate_req,
117809+ .associate_indicator = NULL
117810 };
117811
117812 static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
117813diff --git a/net/atm/lec.h b/net/atm/lec.h
117814index 4149db1..f2ab682 100644
117815--- a/net/atm/lec.h
117816+++ b/net/atm/lec.h
117817@@ -48,7 +48,7 @@ struct lane2_ops {
117818 const u8 *tlvs, u32 sizeoftlvs);
117819 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
117820 const u8 *tlvs, u32 sizeoftlvs);
117821-};
117822+} __no_const;
117823
117824 /*
117825 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
117826diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c
117827index d1b2d9a..d549f7f 100644
117828--- a/net/atm/mpoa_caches.c
117829+++ b/net/atm/mpoa_caches.c
117830@@ -535,30 +535,30 @@ static void eg_destroy_cache(struct mpoa_client *mpc)
117831
117832
117833 static struct in_cache_ops ingress_ops = {
117834- in_cache_add_entry, /* add_entry */
117835- in_cache_get, /* get */
117836- in_cache_get_with_mask, /* get_with_mask */
117837- in_cache_get_by_vcc, /* get_by_vcc */
117838- in_cache_put, /* put */
117839- in_cache_remove_entry, /* remove_entry */
117840- cache_hit, /* cache_hit */
117841- clear_count_and_expired, /* clear_count */
117842- check_resolving_entries, /* check_resolving */
117843- refresh_entries, /* refresh */
117844- in_destroy_cache /* destroy_cache */
117845+ .add_entry = in_cache_add_entry,
117846+ .get = in_cache_get,
117847+ .get_with_mask = in_cache_get_with_mask,
117848+ .get_by_vcc = in_cache_get_by_vcc,
117849+ .put = in_cache_put,
117850+ .remove_entry = in_cache_remove_entry,
117851+ .cache_hit = cache_hit,
117852+ .clear_count = clear_count_and_expired,
117853+ .check_resolving = check_resolving_entries,
117854+ .refresh = refresh_entries,
117855+ .destroy_cache = in_destroy_cache
117856 };
117857
117858 static struct eg_cache_ops egress_ops = {
117859- eg_cache_add_entry, /* add_entry */
117860- eg_cache_get_by_cache_id, /* get_by_cache_id */
117861- eg_cache_get_by_tag, /* get_by_tag */
117862- eg_cache_get_by_vcc, /* get_by_vcc */
117863- eg_cache_get_by_src_ip, /* get_by_src_ip */
117864- eg_cache_put, /* put */
117865- eg_cache_remove_entry, /* remove_entry */
117866- update_eg_cache_entry, /* update */
117867- clear_expired, /* clear_expired */
117868- eg_destroy_cache /* destroy_cache */
117869+ .add_entry = eg_cache_add_entry,
117870+ .get_by_cache_id = eg_cache_get_by_cache_id,
117871+ .get_by_tag = eg_cache_get_by_tag,
117872+ .get_by_vcc = eg_cache_get_by_vcc,
117873+ .get_by_src_ip = eg_cache_get_by_src_ip,
117874+ .put = eg_cache_put,
117875+ .remove_entry = eg_cache_remove_entry,
117876+ .update = update_eg_cache_entry,
117877+ .clear_expired = clear_expired,
117878+ .destroy_cache = eg_destroy_cache
117879 };
117880
117881
117882diff --git a/net/atm/proc.c b/net/atm/proc.c
117883index bbb6461..cf04016 100644
117884--- a/net/atm/proc.c
117885+++ b/net/atm/proc.c
117886@@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
117887 const struct k_atm_aal_stats *stats)
117888 {
117889 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
117890- atomic_read(&stats->tx), atomic_read(&stats->tx_err),
117891- atomic_read(&stats->rx), atomic_read(&stats->rx_err),
117892- atomic_read(&stats->rx_drop));
117893+ atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
117894+ atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
117895+ atomic_read_unchecked(&stats->rx_drop));
117896 }
117897
117898 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
117899diff --git a/net/atm/resources.c b/net/atm/resources.c
117900index 0447d5d..3cf4728 100644
117901--- a/net/atm/resources.c
117902+++ b/net/atm/resources.c
117903@@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
117904 static void copy_aal_stats(struct k_atm_aal_stats *from,
117905 struct atm_aal_stats *to)
117906 {
117907-#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
117908+#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
117909 __AAL_STAT_ITEMS
117910 #undef __HANDLE_ITEM
117911 }
117912@@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
117913 static void subtract_aal_stats(struct k_atm_aal_stats *from,
117914 struct atm_aal_stats *to)
117915 {
117916-#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
117917+#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
117918 __AAL_STAT_ITEMS
117919 #undef __HANDLE_ITEM
117920 }
117921diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
117922index 919a5ce..cc6b444 100644
117923--- a/net/ax25/sysctl_net_ax25.c
117924+++ b/net/ax25/sysctl_net_ax25.c
117925@@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
117926 {
117927 char path[sizeof("net/ax25/") + IFNAMSIZ];
117928 int k;
117929- struct ctl_table *table;
117930+ ctl_table_no_const *table;
117931
117932 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
117933 if (!table)
117934diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
117935index 753383c..32d12d9 100644
117936--- a/net/batman-adv/bat_iv_ogm.c
117937+++ b/net/batman-adv/bat_iv_ogm.c
117938@@ -343,7 +343,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
117939
117940 /* randomize initial seqno to avoid collision */
117941 get_random_bytes(&random_seqno, sizeof(random_seqno));
117942- atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
117943+ atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
117944
117945 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
117946 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
117947@@ -947,9 +947,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
117948 batadv_ogm_packet->tvlv_len = htons(tvlv_len);
117949
117950 /* change sequence number to network order */
117951- seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
117952+ seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
117953 batadv_ogm_packet->seqno = htonl(seqno);
117954- atomic_inc(&hard_iface->bat_iv.ogm_seqno);
117955+ atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
117956
117957 batadv_iv_ogm_slide_own_bcast_window(hard_iface);
117958
117959@@ -1626,7 +1626,7 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
117960 return;
117961
117962 /* could be changed by schedule_own_packet() */
117963- if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
117964+ if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
117965
117966 if (ogm_packet->flags & BATADV_DIRECTLINK)
117967 has_directlink_flag = true;
117968diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
117969index c0f0d01..725928a 100644
117970--- a/net/batman-adv/fragmentation.c
117971+++ b/net/batman-adv/fragmentation.c
117972@@ -465,7 +465,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
117973 frag_header.packet_type = BATADV_UNICAST_FRAG;
117974 frag_header.version = BATADV_COMPAT_VERSION;
117975 frag_header.ttl = BATADV_TTL;
117976- frag_header.seqno = htons(atomic_inc_return(&bat_priv->frag_seqno));
117977+ frag_header.seqno = htons(atomic_inc_return_unchecked(&bat_priv->frag_seqno));
117978 frag_header.reserved = 0;
117979 frag_header.no = 0;
117980 frag_header.total_size = htons(skb->len);
117981diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
117982index 51cda3a..a5db59e 100644
117983--- a/net/batman-adv/soft-interface.c
117984+++ b/net/batman-adv/soft-interface.c
117985@@ -330,7 +330,7 @@ send:
117986 primary_if->net_dev->dev_addr);
117987
117988 /* set broadcast sequence number */
117989- seqno = atomic_inc_return(&bat_priv->bcast_seqno);
117990+ seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
117991 bcast_packet->seqno = htonl(seqno);
117992
117993 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
117994@@ -798,7 +798,7 @@ static int batadv_softif_init_late(struct net_device *dev)
117995 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
117996
117997 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
117998- atomic_set(&bat_priv->bcast_seqno, 1);
117999+ atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
118000 atomic_set(&bat_priv->tt.vn, 0);
118001 atomic_set(&bat_priv->tt.local_changes, 0);
118002 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
118003@@ -812,7 +812,7 @@ static int batadv_softif_init_late(struct net_device *dev)
118004
118005 /* randomize initial seqno to avoid collision */
118006 get_random_bytes(&random_seqno, sizeof(random_seqno));
118007- atomic_set(&bat_priv->frag_seqno, random_seqno);
118008+ atomic_set_unchecked(&bat_priv->frag_seqno, random_seqno);
118009
118010 bat_priv->primary_if = NULL;
118011 bat_priv->num_ifaces = 0;
118012@@ -1020,7 +1020,7 @@ int batadv_softif_is_valid(const struct net_device *net_dev)
118013 return 0;
118014 }
118015
118016-struct rtnl_link_ops batadv_link_ops __read_mostly = {
118017+struct rtnl_link_ops batadv_link_ops = {
118018 .kind = "batadv",
118019 .priv_size = sizeof(struct batadv_priv),
118020 .setup = batadv_softif_init_early,
118021diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
118022index 55610a8..aba2ae8 100644
118023--- a/net/batman-adv/types.h
118024+++ b/net/batman-adv/types.h
118025@@ -81,7 +81,7 @@ enum batadv_dhcp_recipient {
118026 struct batadv_hard_iface_bat_iv {
118027 unsigned char *ogm_buff;
118028 int ogm_buff_len;
118029- atomic_t ogm_seqno;
118030+ atomic_unchecked_t ogm_seqno;
118031 };
118032
118033 /**
118034@@ -786,7 +786,7 @@ struct batadv_priv {
118035 atomic_t bonding;
118036 atomic_t fragmentation;
118037 atomic_t packet_size_max;
118038- atomic_t frag_seqno;
118039+ atomic_unchecked_t frag_seqno;
118040 #ifdef CONFIG_BATMAN_ADV_BLA
118041 atomic_t bridge_loop_avoidance;
118042 #endif
118043@@ -805,7 +805,7 @@ struct batadv_priv {
118044 #endif
118045 uint32_t isolation_mark;
118046 uint32_t isolation_mark_mask;
118047- atomic_t bcast_seqno;
118048+ atomic_unchecked_t bcast_seqno;
118049 atomic_t bcast_queue_left;
118050 atomic_t batman_queue_left;
118051 char num_ifaces;
118052diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
118053index f2d30d1..0573933 100644
118054--- a/net/bluetooth/hci_sock.c
118055+++ b/net/bluetooth/hci_sock.c
118056@@ -1253,7 +1253,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
118057 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
118058 }
118059
118060- len = min_t(unsigned int, len, sizeof(uf));
118061+ len = min((size_t)len, sizeof(uf));
118062 if (copy_from_user(&uf, optval, len)) {
118063 err = -EFAULT;
118064 break;
118065diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
118066index 45fffa4..c5ad848 100644
118067--- a/net/bluetooth/l2cap_core.c
118068+++ b/net/bluetooth/l2cap_core.c
118069@@ -3537,8 +3537,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
118070 break;
118071
118072 case L2CAP_CONF_RFC:
118073- if (olen == sizeof(rfc))
118074- memcpy(&rfc, (void *)val, olen);
118075+ if (olen != sizeof(rfc))
118076+ break;
118077+
118078+ memcpy(&rfc, (void *)val, olen);
118079
118080 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
118081 rfc.mode != chan->mode)
118082diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
118083index 2442877..24ddcd1 100644
118084--- a/net/bluetooth/l2cap_sock.c
118085+++ b/net/bluetooth/l2cap_sock.c
118086@@ -633,7 +633,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
118087 struct sock *sk = sock->sk;
118088 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
118089 struct l2cap_options opts;
118090- int len, err = 0;
118091+ int err = 0;
118092+ size_t len = optlen;
118093 u32 opt;
118094
118095 BT_DBG("sk %p", sk);
118096@@ -660,7 +661,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
118097 opts.max_tx = chan->max_tx;
118098 opts.txwin_size = chan->tx_win;
118099
118100- len = min_t(unsigned int, sizeof(opts), optlen);
118101+ len = min(sizeof(opts), len);
118102 if (copy_from_user((char *) &opts, optval, len)) {
118103 err = -EFAULT;
118104 break;
118105@@ -747,7 +748,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
118106 struct bt_security sec;
118107 struct bt_power pwr;
118108 struct l2cap_conn *conn;
118109- int len, err = 0;
118110+ int err = 0;
118111+ size_t len = optlen;
118112 u32 opt;
118113
118114 BT_DBG("sk %p", sk);
118115@@ -771,7 +773,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
118116
118117 sec.level = BT_SECURITY_LOW;
118118
118119- len = min_t(unsigned int, sizeof(sec), optlen);
118120+ len = min(sizeof(sec), len);
118121 if (copy_from_user((char *) &sec, optval, len)) {
118122 err = -EFAULT;
118123 break;
118124@@ -867,7 +869,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
118125
118126 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
118127
118128- len = min_t(unsigned int, sizeof(pwr), optlen);
118129+ len = min(sizeof(pwr), len);
118130 if (copy_from_user((char *) &pwr, optval, len)) {
118131 err = -EFAULT;
118132 break;
118133diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
118134index 7511df7..a670df3 100644
118135--- a/net/bluetooth/rfcomm/sock.c
118136+++ b/net/bluetooth/rfcomm/sock.c
118137@@ -690,7 +690,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
118138 struct sock *sk = sock->sk;
118139 struct bt_security sec;
118140 int err = 0;
118141- size_t len;
118142+ size_t len = optlen;
118143 u32 opt;
118144
118145 BT_DBG("sk %p", sk);
118146@@ -712,7 +712,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
118147
118148 sec.level = BT_SECURITY_LOW;
118149
118150- len = min_t(unsigned int, sizeof(sec), optlen);
118151+ len = min(sizeof(sec), len);
118152 if (copy_from_user((char *) &sec, optval, len)) {
118153 err = -EFAULT;
118154 break;
118155diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
118156index 8e385a0..a5bdd8e 100644
118157--- a/net/bluetooth/rfcomm/tty.c
118158+++ b/net/bluetooth/rfcomm/tty.c
118159@@ -752,7 +752,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
118160 BT_DBG("tty %p id %d", tty, tty->index);
118161
118162 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
118163- dev->channel, dev->port.count);
118164+ dev->channel, atomic_read(&dev->port.count));
118165
118166 err = tty_port_open(&dev->port, tty, filp);
118167 if (err)
118168@@ -775,7 +775,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
118169 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
118170
118171 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
118172- dev->port.count);
118173+ atomic_read(&dev->port.count));
118174
118175 tty_port_close(&dev->port, tty, filp);
118176 }
118177diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
118178index 4d74a06..f37f9c2 100644
118179--- a/net/bridge/br_netlink.c
118180+++ b/net/bridge/br_netlink.c
118181@@ -835,7 +835,7 @@ static struct rtnl_af_ops br_af_ops __read_mostly = {
118182 .get_link_af_size = br_get_link_af_size,
118183 };
118184
118185-struct rtnl_link_ops br_link_ops __read_mostly = {
118186+struct rtnl_link_ops br_link_ops = {
118187 .kind = "bridge",
118188 .priv_size = sizeof(struct net_bridge),
118189 .setup = br_dev_setup,
118190diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
118191index 18ca4b2..7e8d731 100644
118192--- a/net/bridge/netfilter/ebtables.c
118193+++ b/net/bridge/netfilter/ebtables.c
118194@@ -1533,7 +1533,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
118195 tmp.valid_hooks = t->table->valid_hooks;
118196 }
118197 mutex_unlock(&ebt_mutex);
118198- if (copy_to_user(user, &tmp, *len) != 0) {
118199+ if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
118200 BUGPRINT("c2u Didn't work\n");
118201 ret = -EFAULT;
118202 break;
118203@@ -2339,7 +2339,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
118204 goto out;
118205 tmp.valid_hooks = t->valid_hooks;
118206
118207- if (copy_to_user(user, &tmp, *len) != 0) {
118208+ if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
118209 ret = -EFAULT;
118210 break;
118211 }
118212@@ -2350,7 +2350,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
118213 tmp.entries_size = t->table->entries_size;
118214 tmp.valid_hooks = t->table->valid_hooks;
118215
118216- if (copy_to_user(user, &tmp, *len) != 0) {
118217+ if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
118218 ret = -EFAULT;
118219 break;
118220 }
118221diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
118222index f5afda1..dcf770a 100644
118223--- a/net/caif/cfctrl.c
118224+++ b/net/caif/cfctrl.c
118225@@ -10,6 +10,7 @@
118226 #include <linux/spinlock.h>
118227 #include <linux/slab.h>
118228 #include <linux/pkt_sched.h>
118229+#include <linux/sched.h>
118230 #include <net/caif/caif_layer.h>
118231 #include <net/caif/cfpkt.h>
118232 #include <net/caif/cfctrl.h>
118233@@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
118234 memset(&dev_info, 0, sizeof(dev_info));
118235 dev_info.id = 0xff;
118236 cfsrvl_init(&this->serv, 0, &dev_info, false);
118237- atomic_set(&this->req_seq_no, 1);
118238- atomic_set(&this->rsp_seq_no, 1);
118239+ atomic_set_unchecked(&this->req_seq_no, 1);
118240+ atomic_set_unchecked(&this->rsp_seq_no, 1);
118241 this->serv.layer.receive = cfctrl_recv;
118242 sprintf(this->serv.layer.name, "ctrl");
118243 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
118244@@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
118245 struct cfctrl_request_info *req)
118246 {
118247 spin_lock_bh(&ctrl->info_list_lock);
118248- atomic_inc(&ctrl->req_seq_no);
118249- req->sequence_no = atomic_read(&ctrl->req_seq_no);
118250+ atomic_inc_unchecked(&ctrl->req_seq_no);
118251+ req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
118252 list_add_tail(&req->list, &ctrl->list);
118253 spin_unlock_bh(&ctrl->info_list_lock);
118254 }
118255@@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
118256 if (p != first)
118257 pr_warn("Requests are not received in order\n");
118258
118259- atomic_set(&ctrl->rsp_seq_no,
118260+ atomic_set_unchecked(&ctrl->rsp_seq_no,
118261 p->sequence_no);
118262 list_del(&p->list);
118263 goto out;
118264diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
118265index 67a4a36..8d28068 100644
118266--- a/net/caif/chnl_net.c
118267+++ b/net/caif/chnl_net.c
118268@@ -515,7 +515,7 @@ static const struct nla_policy ipcaif_policy[IFLA_CAIF_MAX + 1] = {
118269 };
118270
118271
118272-static struct rtnl_link_ops ipcaif_link_ops __read_mostly = {
118273+static struct rtnl_link_ops ipcaif_link_ops = {
118274 .kind = "caif",
118275 .priv_size = sizeof(struct chnl_net),
118276 .setup = ipcaif_net_setup,
118277diff --git a/net/can/af_can.c b/net/can/af_can.c
118278index 166d436..2920816 100644
118279--- a/net/can/af_can.c
118280+++ b/net/can/af_can.c
118281@@ -890,7 +890,7 @@ static const struct net_proto_family can_family_ops = {
118282 };
118283
118284 /* notifier block for netdevice event */
118285-static struct notifier_block can_netdev_notifier __read_mostly = {
118286+static struct notifier_block can_netdev_notifier = {
118287 .notifier_call = can_notifier,
118288 };
118289
118290diff --git a/net/can/bcm.c b/net/can/bcm.c
118291index a1ba687..aafaec5 100644
118292--- a/net/can/bcm.c
118293+++ b/net/can/bcm.c
118294@@ -1620,7 +1620,7 @@ static int __init bcm_module_init(void)
118295 }
118296
118297 /* create /proc/net/can-bcm directory */
118298- proc_dir = proc_mkdir("can-bcm", init_net.proc_net);
118299+ proc_dir = proc_mkdir_restrict("can-bcm", init_net.proc_net);
118300 return 0;
118301 }
118302
118303diff --git a/net/can/gw.c b/net/can/gw.c
118304index 4551687..4e82e9b 100644
118305--- a/net/can/gw.c
118306+++ b/net/can/gw.c
118307@@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
118308 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
118309
118310 static HLIST_HEAD(cgw_list);
118311-static struct notifier_block notifier;
118312
118313 static struct kmem_cache *cgw_cache __read_mostly;
118314
118315@@ -992,6 +991,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
118316 return err;
118317 }
118318
118319+static struct notifier_block notifier = {
118320+ .notifier_call = cgw_notifier
118321+};
118322+
118323 static __init int cgw_module_init(void)
118324 {
118325 /* sanitize given module parameter */
118326@@ -1007,7 +1010,6 @@ static __init int cgw_module_init(void)
118327 return -ENOMEM;
118328
118329 /* set notifier */
118330- notifier.notifier_call = cgw_notifier;
118331 register_netdevice_notifier(&notifier);
118332
118333 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
118334diff --git a/net/can/proc.c b/net/can/proc.c
118335index 1a19b98..df2b4ec 100644
118336--- a/net/can/proc.c
118337+++ b/net/can/proc.c
118338@@ -514,7 +514,7 @@ static void can_remove_proc_readentry(const char *name)
118339 void can_init_proc(void)
118340 {
118341 /* create /proc/net/can directory */
118342- can_dir = proc_mkdir("can", init_net.proc_net);
118343+ can_dir = proc_mkdir_restrict("can", init_net.proc_net);
118344
118345 if (!can_dir) {
118346 printk(KERN_INFO "can: failed to create /proc/net/can . "
118347diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
118348index e3be1d2..254c555 100644
118349--- a/net/ceph/messenger.c
118350+++ b/net/ceph/messenger.c
118351@@ -189,7 +189,7 @@ static void con_fault(struct ceph_connection *con);
118352 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
118353
118354 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
118355-static atomic_t addr_str_seq = ATOMIC_INIT(0);
118356+static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
118357
118358 static struct page *zero_page; /* used in certain error cases */
118359
118360@@ -200,7 +200,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
118361 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
118362 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
118363
118364- i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
118365+ i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
118366 s = addr_str[i];
118367
118368 switch (ss->ss_family) {
118369diff --git a/net/compat.c b/net/compat.c
118370index 5cfd26a..7e43828 100644
118371--- a/net/compat.c
118372+++ b/net/compat.c
118373@@ -98,20 +98,20 @@ int get_compat_msghdr(struct msghdr *kmsg,
118374
118375 #define CMSG_COMPAT_FIRSTHDR(msg) \
118376 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
118377- (struct compat_cmsghdr __user *)((msg)->msg_control) : \
118378+ (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
118379 (struct compat_cmsghdr __user *)NULL)
118380
118381 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
118382 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
118383 (ucmlen) <= (unsigned long) \
118384 ((mhdr)->msg_controllen - \
118385- ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
118386+ ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
118387
118388 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
118389 struct compat_cmsghdr __user *cmsg, int cmsg_len)
118390 {
118391 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
118392- if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
118393+ if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
118394 msg->msg_controllen)
118395 return NULL;
118396 return (struct compat_cmsghdr __user *)ptr;
118397@@ -201,7 +201,7 @@ Efault:
118398
118399 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
118400 {
118401- struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
118402+ struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
118403 struct compat_cmsghdr cmhdr;
118404 struct compat_timeval ctv;
118405 struct compat_timespec cts[3];
118406@@ -257,7 +257,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
118407
118408 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
118409 {
118410- struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
118411+ struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
118412 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
118413 int fdnum = scm->fp->count;
118414 struct file **fp = scm->fp->fp;
118415@@ -345,7 +345,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
118416 return -EFAULT;
118417 old_fs = get_fs();
118418 set_fs(KERNEL_DS);
118419- err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
118420+ err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
118421 set_fs(old_fs);
118422
118423 return err;
118424@@ -406,7 +406,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
118425 len = sizeof(ktime);
118426 old_fs = get_fs();
118427 set_fs(KERNEL_DS);
118428- err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
118429+ err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
118430 set_fs(old_fs);
118431
118432 if (!err) {
118433@@ -549,7 +549,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
118434 case MCAST_JOIN_GROUP:
118435 case MCAST_LEAVE_GROUP:
118436 {
118437- struct compat_group_req __user *gr32 = (void *)optval;
118438+ struct compat_group_req __user *gr32 = (void __user *)optval;
118439 struct group_req __user *kgr =
118440 compat_alloc_user_space(sizeof(struct group_req));
118441 u32 interface;
118442@@ -570,7 +570,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
118443 case MCAST_BLOCK_SOURCE:
118444 case MCAST_UNBLOCK_SOURCE:
118445 {
118446- struct compat_group_source_req __user *gsr32 = (void *)optval;
118447+ struct compat_group_source_req __user *gsr32 = (void __user *)optval;
118448 struct group_source_req __user *kgsr = compat_alloc_user_space(
118449 sizeof(struct group_source_req));
118450 u32 interface;
118451@@ -591,7 +591,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
118452 }
118453 case MCAST_MSFILTER:
118454 {
118455- struct compat_group_filter __user *gf32 = (void *)optval;
118456+ struct compat_group_filter __user *gf32 = (void __user *)optval;
118457 struct group_filter __user *kgf;
118458 u32 interface, fmode, numsrc;
118459
118460@@ -629,7 +629,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
118461 char __user *optval, int __user *optlen,
118462 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
118463 {
118464- struct compat_group_filter __user *gf32 = (void *)optval;
118465+ struct compat_group_filter __user *gf32 = (void __user *)optval;
118466 struct group_filter __user *kgf;
118467 int __user *koptlen;
118468 u32 interface, fmode, numsrc;
118469@@ -773,7 +773,7 @@ COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args)
118470
118471 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
118472 return -EINVAL;
118473- if (copy_from_user(a, args, nas[call]))
118474+ if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
118475 return -EFAULT;
118476 a0 = a[0];
118477 a1 = a[1];
118478diff --git a/net/core/datagram.c b/net/core/datagram.c
118479index 617088a..0364f4f 100644
118480--- a/net/core/datagram.c
118481+++ b/net/core/datagram.c
118482@@ -338,7 +338,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
118483 }
118484
118485 kfree_skb(skb);
118486- atomic_inc(&sk->sk_drops);
118487+ atomic_inc_unchecked(&sk->sk_drops);
118488 sk_mem_reclaim_partial(sk);
118489
118490 return err;
118491diff --git a/net/core/dev.c b/net/core/dev.c
118492index a8e4dd4..aab06f7 100644
118493--- a/net/core/dev.c
118494+++ b/net/core/dev.c
118495@@ -1721,7 +1721,7 @@ int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
118496 {
118497 if (skb_orphan_frags(skb, GFP_ATOMIC) ||
118498 unlikely(!is_skb_forwardable(dev, skb))) {
118499- atomic_long_inc(&dev->rx_dropped);
118500+ atomic_long_inc_unchecked(&dev->rx_dropped);
118501 kfree_skb(skb);
118502 return NET_RX_DROP;
118503 }
118504@@ -3125,7 +3125,7 @@ recursion_alert:
118505 drop:
118506 rcu_read_unlock_bh();
118507
118508- atomic_long_inc(&dev->tx_dropped);
118509+ atomic_long_inc_unchecked(&dev->tx_dropped);
118510 kfree_skb_list(skb);
118511 return rc;
118512 out:
118513@@ -3477,7 +3477,7 @@ drop:
118514
118515 local_irq_restore(flags);
118516
118517- atomic_long_inc(&skb->dev->rx_dropped);
118518+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
118519 kfree_skb(skb);
118520 return NET_RX_DROP;
118521 }
118522@@ -3554,7 +3554,7 @@ int netif_rx_ni(struct sk_buff *skb)
118523 }
118524 EXPORT_SYMBOL(netif_rx_ni);
118525
118526-static void net_tx_action(struct softirq_action *h)
118527+static __latent_entropy void net_tx_action(void)
118528 {
118529 struct softnet_data *sd = this_cpu_ptr(&softnet_data);
118530
118531@@ -3892,7 +3892,7 @@ ncls:
118532 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
118533 } else {
118534 drop:
118535- atomic_long_inc(&skb->dev->rx_dropped);
118536+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
118537 kfree_skb(skb);
118538 /* Jamal, now you will not able to escape explaining
118539 * me how you were going to use this. :-)
118540@@ -4783,7 +4783,7 @@ out_unlock:
118541 return work;
118542 }
118543
118544-static void net_rx_action(struct softirq_action *h)
118545+static __latent_entropy void net_rx_action(void)
118546 {
118547 struct softnet_data *sd = this_cpu_ptr(&softnet_data);
118548 unsigned long time_limit = jiffies + 2;
118549@@ -6843,8 +6843,8 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
118550 } else {
118551 netdev_stats_to_stats64(storage, &dev->stats);
118552 }
118553- storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
118554- storage->tx_dropped += atomic_long_read(&dev->tx_dropped);
118555+ storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
118556+ storage->tx_dropped += atomic_long_read_unchecked(&dev->tx_dropped);
118557 return storage;
118558 }
118559 EXPORT_SYMBOL(dev_get_stats);
118560diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
118561index b94b1d2..da3ed7c 100644
118562--- a/net/core/dev_ioctl.c
118563+++ b/net/core/dev_ioctl.c
118564@@ -368,8 +368,13 @@ void dev_load(struct net *net, const char *name)
118565 no_module = !dev;
118566 if (no_module && capable(CAP_NET_ADMIN))
118567 no_module = request_module("netdev-%s", name);
118568- if (no_module && capable(CAP_SYS_MODULE))
118569+ if (no_module && capable(CAP_SYS_MODULE)) {
118570+#ifdef CONFIG_GRKERNSEC_MODHARDEN
118571+ ___request_module(true, "grsec_modharden_netdev", "%s", name);
118572+#else
118573 request_module("%s", name);
118574+#endif
118575+ }
118576 }
118577 EXPORT_SYMBOL(dev_load);
118578
118579diff --git a/net/core/filter.c b/net/core/filter.c
118580index 8dcdd86..a809731 100644
118581--- a/net/core/filter.c
118582+++ b/net/core/filter.c
118583@@ -582,7 +582,11 @@ do_pass:
118584
118585 /* Unknown instruction. */
118586 default:
118587- goto err;
118588+ WARN(1, KERN_ALERT "Unknown sock filter code:%u jt:%u tf:%u k:%u\n",
118589+ fp->code, fp->jt, fp->jf, fp->k);
118590+ kfree(addrs);
118591+ BUG();
118592+ return -EINVAL;
118593 }
118594
118595 insn++;
118596@@ -626,7 +630,7 @@ static int check_load_and_stores(const struct sock_filter *filter, int flen)
118597 u16 *masks, memvalid = 0; /* One bit per cell, 16 cells */
118598 int pc, ret = 0;
118599
118600- BUILD_BUG_ON(BPF_MEMWORDS > 16);
118601+ BUILD_BUG_ON(BPF_MEMWORDS != 16);
118602
118603 masks = kmalloc_array(flen, sizeof(*masks), GFP_KERNEL);
118604 if (!masks)
118605@@ -1055,7 +1059,7 @@ int bpf_prog_create(struct bpf_prog **pfp, struct sock_fprog_kern *fprog)
118606 if (!fp)
118607 return -ENOMEM;
118608
118609- memcpy(fp->insns, fprog->filter, fsize);
118610+ memcpy(fp->insns, (void __force_kernel *)fprog->filter, fsize);
118611
118612 fp->len = fprog->len;
118613 /* Since unattached filters are not copied back to user
118614diff --git a/net/core/flow.c b/net/core/flow.c
118615index 1033725..340f65d 100644
118616--- a/net/core/flow.c
118617+++ b/net/core/flow.c
118618@@ -65,7 +65,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
118619 static int flow_entry_valid(struct flow_cache_entry *fle,
118620 struct netns_xfrm *xfrm)
118621 {
118622- if (atomic_read(&xfrm->flow_cache_genid) != fle->genid)
118623+ if (atomic_read_unchecked(&xfrm->flow_cache_genid) != fle->genid)
118624 return 0;
118625 if (fle->object && !fle->object->ops->check(fle->object))
118626 return 0;
118627@@ -242,7 +242,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
118628 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
118629 fcp->hash_count++;
118630 }
118631- } else if (likely(fle->genid == atomic_read(&net->xfrm.flow_cache_genid))) {
118632+ } else if (likely(fle->genid == atomic_read_unchecked(&net->xfrm.flow_cache_genid))) {
118633 flo = fle->object;
118634 if (!flo)
118635 goto ret_object;
118636@@ -263,7 +263,7 @@ nocache:
118637 }
118638 flo = resolver(net, key, family, dir, flo, ctx);
118639 if (fle) {
118640- fle->genid = atomic_read(&net->xfrm.flow_cache_genid);
118641+ fle->genid = atomic_read_unchecked(&net->xfrm.flow_cache_genid);
118642 if (!IS_ERR(flo))
118643 fle->object = flo;
118644 else
118645diff --git a/net/core/neighbour.c b/net/core/neighbour.c
118646index 84195da..035c7a7 100644
118647--- a/net/core/neighbour.c
118648+++ b/net/core/neighbour.c
118649@@ -2821,7 +2821,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
118650 void __user *buffer, size_t *lenp, loff_t *ppos)
118651 {
118652 int size, ret;
118653- struct ctl_table tmp = *ctl;
118654+ ctl_table_no_const tmp = *ctl;
118655
118656 tmp.extra1 = &zero;
118657 tmp.extra2 = &unres_qlen_max;
118658@@ -2883,7 +2883,7 @@ static int neigh_proc_dointvec_zero_intmax(struct ctl_table *ctl, int write,
118659 void __user *buffer,
118660 size_t *lenp, loff_t *ppos)
118661 {
118662- struct ctl_table tmp = *ctl;
118663+ ctl_table_no_const tmp = *ctl;
118664 int ret;
118665
118666 tmp.extra1 = &zero;
118667diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
118668index 2bf8329..2eb1423 100644
118669--- a/net/core/net-procfs.c
118670+++ b/net/core/net-procfs.c
118671@@ -79,7 +79,13 @@ static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
118672 struct rtnl_link_stats64 temp;
118673 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
118674
118675- seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
118676+ if (gr_proc_is_restricted())
118677+ seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
118678+ "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
118679+ dev->name, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL,
118680+ 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL);
118681+ else
118682+ seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
118683 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
118684 dev->name, stats->rx_bytes, stats->rx_packets,
118685 stats->rx_errors,
118686@@ -166,7 +172,7 @@ static int softnet_seq_show(struct seq_file *seq, void *v)
118687 return 0;
118688 }
118689
118690-static const struct seq_operations dev_seq_ops = {
118691+const struct seq_operations dev_seq_ops = {
118692 .start = dev_seq_start,
118693 .next = dev_seq_next,
118694 .stop = dev_seq_stop,
118695@@ -196,7 +202,7 @@ static const struct seq_operations softnet_seq_ops = {
118696
118697 static int softnet_seq_open(struct inode *inode, struct file *file)
118698 {
118699- return seq_open(file, &softnet_seq_ops);
118700+ return seq_open_restrict(file, &softnet_seq_ops);
118701 }
118702
118703 static const struct file_operations softnet_seq_fops = {
118704@@ -283,8 +289,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
118705 else
118706 seq_printf(seq, "%04x", ntohs(pt->type));
118707
118708+#ifdef CONFIG_GRKERNSEC_HIDESYM
118709+ seq_printf(seq, " %-8s %pf\n",
118710+ pt->dev ? pt->dev->name : "", NULL);
118711+#else
118712 seq_printf(seq, " %-8s %pf\n",
118713 pt->dev ? pt->dev->name : "", pt->func);
118714+#endif
118715 }
118716
118717 return 0;
118718diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
118719index 18b34d7..faecc1d 100644
118720--- a/net/core/net-sysfs.c
118721+++ b/net/core/net-sysfs.c
118722@@ -288,7 +288,7 @@ static ssize_t carrier_changes_show(struct device *dev,
118723 {
118724 struct net_device *netdev = to_net_dev(dev);
118725 return sprintf(buf, fmt_dec,
118726- atomic_read(&netdev->carrier_changes));
118727+ atomic_read_unchecked(&netdev->carrier_changes));
118728 }
118729 static DEVICE_ATTR_RO(carrier_changes);
118730
118731diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
118732index 2c2eb1b..a53be3e 100644
118733--- a/net/core/net_namespace.c
118734+++ b/net/core/net_namespace.c
118735@@ -775,7 +775,7 @@ static int __register_pernet_operations(struct list_head *list,
118736 int error;
118737 LIST_HEAD(net_exit_list);
118738
118739- list_add_tail(&ops->list, list);
118740+ pax_list_add_tail((struct list_head *)&ops->list, list);
118741 if (ops->init || (ops->id && ops->size)) {
118742 for_each_net(net) {
118743 error = ops_init(ops, net);
118744@@ -788,7 +788,7 @@ static int __register_pernet_operations(struct list_head *list,
118745
118746 out_undo:
118747 /* If I have an error cleanup all namespaces I initialized */
118748- list_del(&ops->list);
118749+ pax_list_del((struct list_head *)&ops->list);
118750 ops_exit_list(ops, &net_exit_list);
118751 ops_free_list(ops, &net_exit_list);
118752 return error;
118753@@ -799,7 +799,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
118754 struct net *net;
118755 LIST_HEAD(net_exit_list);
118756
118757- list_del(&ops->list);
118758+ pax_list_del((struct list_head *)&ops->list);
118759 for_each_net(net)
118760 list_add_tail(&net->exit_list, &net_exit_list);
118761 ops_exit_list(ops, &net_exit_list);
118762@@ -933,7 +933,7 @@ int register_pernet_device(struct pernet_operations *ops)
118763 mutex_lock(&net_mutex);
118764 error = register_pernet_operations(&pernet_list, ops);
118765 if (!error && (first_device == &pernet_list))
118766- first_device = &ops->list;
118767+ first_device = (struct list_head *)&ops->list;
118768 mutex_unlock(&net_mutex);
118769 return error;
118770 }
118771diff --git a/net/core/netpoll.c b/net/core/netpoll.c
118772index c126a87..10ad89d 100644
118773--- a/net/core/netpoll.c
118774+++ b/net/core/netpoll.c
118775@@ -377,7 +377,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
118776 struct udphdr *udph;
118777 struct iphdr *iph;
118778 struct ethhdr *eth;
118779- static atomic_t ip_ident;
118780+ static atomic_unchecked_t ip_ident;
118781 struct ipv6hdr *ip6h;
118782
118783 udp_len = len + sizeof(*udph);
118784@@ -448,7 +448,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
118785 put_unaligned(0x45, (unsigned char *)iph);
118786 iph->tos = 0;
118787 put_unaligned(htons(ip_len), &(iph->tot_len));
118788- iph->id = htons(atomic_inc_return(&ip_ident));
118789+ iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
118790 iph->frag_off = 0;
118791 iph->ttl = 64;
118792 iph->protocol = IPPROTO_UDP;
118793diff --git a/net/core/pktgen.c b/net/core/pktgen.c
118794index 1cbd209..9553598 100644
118795--- a/net/core/pktgen.c
118796+++ b/net/core/pktgen.c
118797@@ -3828,7 +3828,7 @@ static int __net_init pg_net_init(struct net *net)
118798 pn->net = net;
118799 INIT_LIST_HEAD(&pn->pktgen_threads);
118800 pn->pktgen_exiting = false;
118801- pn->proc_dir = proc_mkdir(PG_PROC_DIR, pn->net->proc_net);
118802+ pn->proc_dir = proc_mkdir_restrict(PG_PROC_DIR, pn->net->proc_net);
118803 if (!pn->proc_dir) {
118804 pr_warn("cannot create /proc/net/%s\n", PG_PROC_DIR);
118805 return -ENODEV;
118806diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
118807index 0861018..1fd388b 100644
118808--- a/net/core/rtnetlink.c
118809+++ b/net/core/rtnetlink.c
118810@@ -61,7 +61,7 @@ struct rtnl_link {
118811 rtnl_doit_func doit;
118812 rtnl_dumpit_func dumpit;
118813 rtnl_calcit_func calcit;
118814-};
118815+} __no_const;
118816
118817 static DEFINE_MUTEX(rtnl_mutex);
118818
118819@@ -307,10 +307,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
118820 * to use the ops for creating device. So do not
118821 * fill up dellink as well. That disables rtnl_dellink.
118822 */
118823- if (ops->setup && !ops->dellink)
118824- ops->dellink = unregister_netdevice_queue;
118825+ if (ops->setup && !ops->dellink) {
118826+ pax_open_kernel();
118827+ *(void **)&ops->dellink = unregister_netdevice_queue;
118828+ pax_close_kernel();
118829+ }
118830
118831- list_add_tail(&ops->list, &link_ops);
118832+ pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
118833 return 0;
118834 }
118835 EXPORT_SYMBOL_GPL(__rtnl_link_register);
118836@@ -357,7 +360,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
118837 for_each_net(net) {
118838 __rtnl_kill_links(net, ops);
118839 }
118840- list_del(&ops->list);
118841+ pax_list_del((struct list_head *)&ops->list);
118842 }
118843 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
118844
118845@@ -1082,7 +1085,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
118846 (dev->ifalias &&
118847 nla_put_string(skb, IFLA_IFALIAS, dev->ifalias)) ||
118848 nla_put_u32(skb, IFLA_CARRIER_CHANGES,
118849- atomic_read(&dev->carrier_changes)))
118850+ atomic_read_unchecked(&dev->carrier_changes)))
118851 goto nla_put_failure;
118852
118853 if (1) {
118854diff --git a/net/core/scm.c b/net/core/scm.c
118855index 3b6899b..20d20e7 100644
118856--- a/net/core/scm.c
118857+++ b/net/core/scm.c
118858@@ -209,9 +209,9 @@ EXPORT_SYMBOL(__scm_send);
118859 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
118860 {
118861 struct cmsghdr __user *cm
118862- = (__force struct cmsghdr __user *)msg->msg_control;
118863+ = (struct cmsghdr __force_user *)msg->msg_control;
118864 struct cmsghdr cmhdr;
118865- int cmlen = CMSG_LEN(len);
118866+ size_t cmlen = CMSG_LEN(len);
118867 int err;
118868
118869 if (MSG_CMSG_COMPAT & msg->msg_flags)
118870@@ -232,7 +232,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
118871 err = -EFAULT;
118872 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
118873 goto out;
118874- if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
118875+ if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
118876 goto out;
118877 cmlen = CMSG_SPACE(len);
118878 if (msg->msg_controllen < cmlen)
118879@@ -248,7 +248,7 @@ EXPORT_SYMBOL(put_cmsg);
118880 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118881 {
118882 struct cmsghdr __user *cm
118883- = (__force struct cmsghdr __user*)msg->msg_control;
118884+ = (struct cmsghdr __force_user *)msg->msg_control;
118885
118886 int fdmax = 0;
118887 int fdnum = scm->fp->count;
118888@@ -268,7 +268,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118889 if (fdnum < fdmax)
118890 fdmax = fdnum;
118891
118892- for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
118893+ for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
118894 i++, cmfptr++)
118895 {
118896 struct socket *sock;
118897@@ -297,7 +297,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118898
118899 if (i > 0)
118900 {
118901- int cmlen = CMSG_LEN(i*sizeof(int));
118902+ size_t cmlen = CMSG_LEN(i*sizeof(int));
118903 err = put_user(SOL_SOCKET, &cm->cmsg_level);
118904 if (!err)
118905 err = put_user(SCM_RIGHTS, &cm->cmsg_type);
118906@@ -305,6 +305,8 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118907 err = put_user(cmlen, &cm->cmsg_len);
118908 if (!err) {
118909 cmlen = CMSG_SPACE(i*sizeof(int));
118910+ if (msg->msg_controllen < cmlen)
118911+ cmlen = msg->msg_controllen;
118912 msg->msg_control += cmlen;
118913 msg->msg_controllen -= cmlen;
118914 }
118915diff --git a/net/core/skbuff.c b/net/core/skbuff.c
118916index 7bfa187..032715a 100644
118917--- a/net/core/skbuff.c
118918+++ b/net/core/skbuff.c
118919@@ -2103,7 +2103,7 @@ EXPORT_SYMBOL(__skb_checksum);
118920 __wsum skb_checksum(const struct sk_buff *skb, int offset,
118921 int len, __wsum csum)
118922 {
118923- const struct skb_checksum_ops ops = {
118924+ static const struct skb_checksum_ops ops = {
118925 .update = csum_partial_ext,
118926 .combine = csum_block_add_ext,
118927 };
118928@@ -3318,12 +3318,14 @@ void __init skb_init(void)
118929 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
118930 sizeof(struct sk_buff),
118931 0,
118932- SLAB_HWCACHE_ALIGN|SLAB_PANIC,
118933+ SLAB_HWCACHE_ALIGN|SLAB_PANIC|
118934+ SLAB_NO_SANITIZE,
118935 NULL);
118936 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
118937 sizeof(struct sk_buff_fclones),
118938 0,
118939- SLAB_HWCACHE_ALIGN|SLAB_PANIC,
118940+ SLAB_HWCACHE_ALIGN|SLAB_PANIC|
118941+ SLAB_NO_SANITIZE,
118942 NULL);
118943 }
118944
118945diff --git a/net/core/sock.c b/net/core/sock.c
118946index 193901d..33094ab 100644
118947--- a/net/core/sock.c
118948+++ b/net/core/sock.c
118949@@ -441,7 +441,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
118950 struct sk_buff_head *list = &sk->sk_receive_queue;
118951
118952 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
118953- atomic_inc(&sk->sk_drops);
118954+ atomic_inc_unchecked(&sk->sk_drops);
118955 trace_sock_rcvqueue_full(sk, skb);
118956 return -ENOMEM;
118957 }
118958@@ -451,7 +451,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
118959 return err;
118960
118961 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
118962- atomic_inc(&sk->sk_drops);
118963+ atomic_inc_unchecked(&sk->sk_drops);
118964 return -ENOBUFS;
118965 }
118966
118967@@ -484,7 +484,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
118968 skb->dev = NULL;
118969
118970 if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) {
118971- atomic_inc(&sk->sk_drops);
118972+ atomic_inc_unchecked(&sk->sk_drops);
118973 goto discard_and_relse;
118974 }
118975 if (nested)
118976@@ -502,7 +502,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
118977 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
118978 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
118979 bh_unlock_sock(sk);
118980- atomic_inc(&sk->sk_drops);
118981+ atomic_inc_unchecked(&sk->sk_drops);
118982 goto discard_and_relse;
118983 }
118984
118985@@ -908,6 +908,7 @@ set_rcvbuf:
118986 }
118987 break;
118988
118989+#ifndef GRKERNSEC_BPF_HARDEN
118990 case SO_ATTACH_BPF:
118991 ret = -EINVAL;
118992 if (optlen == sizeof(u32)) {
118993@@ -920,7 +921,7 @@ set_rcvbuf:
118994 ret = sk_attach_bpf(ufd, sk);
118995 }
118996 break;
118997-
118998+#endif
118999 case SO_DETACH_FILTER:
119000 ret = sk_detach_filter(sk);
119001 break;
119002@@ -1022,12 +1023,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
119003 struct timeval tm;
119004 } v;
119005
119006- int lv = sizeof(int);
119007- int len;
119008+ unsigned int lv = sizeof(int);
119009+ unsigned int len;
119010
119011 if (get_user(len, optlen))
119012 return -EFAULT;
119013- if (len < 0)
119014+ if (len > INT_MAX)
119015 return -EINVAL;
119016
119017 memset(&v, 0, sizeof(v));
119018@@ -1165,11 +1166,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
119019
119020 case SO_PEERNAME:
119021 {
119022- char address[128];
119023+ char address[_K_SS_MAXSIZE];
119024
119025 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
119026 return -ENOTCONN;
119027- if (lv < len)
119028+ if (lv < len || sizeof address < len)
119029 return -EINVAL;
119030 if (copy_to_user(optval, address, len))
119031 return -EFAULT;
119032@@ -1257,7 +1258,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
119033
119034 if (len > lv)
119035 len = lv;
119036- if (copy_to_user(optval, &v, len))
119037+ if (len > sizeof(v) || copy_to_user(optval, &v, len))
119038 return -EFAULT;
119039 lenout:
119040 if (put_user(len, optlen))
119041@@ -1550,7 +1551,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
119042 newsk->sk_err = 0;
119043 newsk->sk_priority = 0;
119044 newsk->sk_incoming_cpu = raw_smp_processor_id();
119045- atomic64_set(&newsk->sk_cookie, 0);
119046+ atomic64_set_unchecked(&newsk->sk_cookie, 0);
119047 /*
119048 * Before updating sk_refcnt, we must commit prior changes to memory
119049 * (Documentation/RCU/rculist_nulls.txt for details)
119050@@ -2359,7 +2360,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
119051 */
119052 smp_wmb();
119053 atomic_set(&sk->sk_refcnt, 1);
119054- atomic_set(&sk->sk_drops, 0);
119055+ atomic_set_unchecked(&sk->sk_drops, 0);
119056 }
119057 EXPORT_SYMBOL(sock_init_data);
119058
119059@@ -2487,6 +2488,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
119060 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
119061 int level, int type)
119062 {
119063+ struct sock_extended_err ee;
119064 struct sock_exterr_skb *serr;
119065 struct sk_buff *skb;
119066 int copied, err;
119067@@ -2508,7 +2510,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
119068 sock_recv_timestamp(msg, sk, skb);
119069
119070 serr = SKB_EXT_ERR(skb);
119071- put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
119072+ ee = serr->ee;
119073+ put_cmsg(msg, level, type, sizeof ee, &ee);
119074
119075 msg->msg_flags |= MSG_ERRQUEUE;
119076 err = copied;
119077diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
119078index 817622f..2577b26 100644
119079--- a/net/core/sock_diag.c
119080+++ b/net/core/sock_diag.c
119081@@ -12,7 +12,7 @@
119082 #include <linux/inet_diag.h>
119083 #include <linux/sock_diag.h>
119084
119085-static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
119086+static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
119087 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
119088 static DEFINE_MUTEX(sock_diag_table_mutex);
119089 static struct workqueue_struct *broadcast_wq;
119090@@ -20,12 +20,12 @@ static struct workqueue_struct *broadcast_wq;
119091 static u64 sock_gen_cookie(struct sock *sk)
119092 {
119093 while (1) {
119094- u64 res = atomic64_read(&sk->sk_cookie);
119095+ u64 res = atomic64_read_unchecked(&sk->sk_cookie);
119096
119097 if (res)
119098 return res;
119099- res = atomic64_inc_return(&sock_net(sk)->cookie_gen);
119100- atomic64_cmpxchg(&sk->sk_cookie, 0, res);
119101+ res = atomic64_inc_return_unchecked(&sock_net(sk)->cookie_gen);
119102+ atomic64_cmpxchg_unchecked(&sk->sk_cookie, 0, res);
119103 }
119104 }
119105
119106@@ -190,8 +190,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
119107 mutex_lock(&sock_diag_table_mutex);
119108 if (sock_diag_handlers[hndl->family])
119109 err = -EBUSY;
119110- else
119111+ else {
119112+ pax_open_kernel();
119113 sock_diag_handlers[hndl->family] = hndl;
119114+ pax_close_kernel();
119115+ }
119116 mutex_unlock(&sock_diag_table_mutex);
119117
119118 return err;
119119@@ -207,7 +210,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
119120
119121 mutex_lock(&sock_diag_table_mutex);
119122 BUG_ON(sock_diag_handlers[family] != hnld);
119123+ pax_open_kernel();
119124 sock_diag_handlers[family] = NULL;
119125+ pax_close_kernel();
119126 mutex_unlock(&sock_diag_table_mutex);
119127 }
119128 EXPORT_SYMBOL_GPL(sock_diag_unregister);
119129diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
119130index 95b6139..3048623 100644
119131--- a/net/core/sysctl_net_core.c
119132+++ b/net/core/sysctl_net_core.c
119133@@ -35,7 +35,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
119134 {
119135 unsigned int orig_size, size;
119136 int ret, i;
119137- struct ctl_table tmp = {
119138+ ctl_table_no_const tmp = {
119139 .data = &size,
119140 .maxlen = sizeof(size),
119141 .mode = table->mode
119142@@ -203,7 +203,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
119143 void __user *buffer, size_t *lenp, loff_t *ppos)
119144 {
119145 char id[IFNAMSIZ];
119146- struct ctl_table tbl = {
119147+ ctl_table_no_const tbl = {
119148 .data = id,
119149 .maxlen = IFNAMSIZ,
119150 };
119151@@ -221,7 +221,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
119152 static int proc_do_rss_key(struct ctl_table *table, int write,
119153 void __user *buffer, size_t *lenp, loff_t *ppos)
119154 {
119155- struct ctl_table fake_table;
119156+ ctl_table_no_const fake_table;
119157 char buf[NETDEV_RSS_KEY_LEN * 3];
119158
119159 snprintf(buf, sizeof(buf), "%*phC", NETDEV_RSS_KEY_LEN, netdev_rss_key);
119160@@ -285,7 +285,7 @@ static struct ctl_table net_core_table[] = {
119161 .mode = 0444,
119162 .proc_handler = proc_do_rss_key,
119163 },
119164-#ifdef CONFIG_BPF_JIT
119165+#if defined(CONFIG_BPF_JIT) && !defined(CONFIG_GRKERNSEC_BPF_HARDEN)
119166 {
119167 .procname = "bpf_jit_enable",
119168 .data = &bpf_jit_enable,
119169@@ -409,13 +409,12 @@ static struct ctl_table netns_core_table[] = {
119170
119171 static __net_init int sysctl_core_net_init(struct net *net)
119172 {
119173- struct ctl_table *tbl;
119174+ ctl_table_no_const *tbl = NULL;
119175
119176 net->core.sysctl_somaxconn = SOMAXCONN;
119177
119178- tbl = netns_core_table;
119179 if (!net_eq(net, &init_net)) {
119180- tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
119181+ tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
119182 if (tbl == NULL)
119183 goto err_dup;
119184
119185@@ -425,17 +424,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
119186 if (net->user_ns != &init_user_ns) {
119187 tbl[0].procname = NULL;
119188 }
119189- }
119190-
119191- net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
119192+ net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
119193+ } else
119194+ net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
119195 if (net->core.sysctl_hdr == NULL)
119196 goto err_reg;
119197
119198 return 0;
119199
119200 err_reg:
119201- if (tbl != netns_core_table)
119202- kfree(tbl);
119203+ kfree(tbl);
119204 err_dup:
119205 return -ENOMEM;
119206 }
119207@@ -450,7 +448,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
119208 kfree(tbl);
119209 }
119210
119211-static __net_initdata struct pernet_operations sysctl_core_ops = {
119212+static __net_initconst struct pernet_operations sysctl_core_ops = {
119213 .init = sysctl_core_net_init,
119214 .exit = sysctl_core_net_exit,
119215 };
119216diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
119217index 675cf94..9279a75 100644
119218--- a/net/decnet/af_decnet.c
119219+++ b/net/decnet/af_decnet.c
119220@@ -466,6 +466,7 @@ static struct proto dn_proto = {
119221 .sysctl_rmem = sysctl_decnet_rmem,
119222 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
119223 .obj_size = sizeof(struct dn_sock),
119224+ .slab_flags = SLAB_USERCOPY,
119225 };
119226
119227 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp, int kern)
119228diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
119229index b2c26b0..41f803e 100644
119230--- a/net/decnet/dn_dev.c
119231+++ b/net/decnet/dn_dev.c
119232@@ -201,7 +201,7 @@ static struct dn_dev_sysctl_table {
119233 .extra1 = &min_t3,
119234 .extra2 = &max_t3
119235 },
119236- {0}
119237+ { }
119238 },
119239 };
119240
119241diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
119242index 5325b54..a0d4d69 100644
119243--- a/net/decnet/sysctl_net_decnet.c
119244+++ b/net/decnet/sysctl_net_decnet.c
119245@@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
119246
119247 if (len > *lenp) len = *lenp;
119248
119249- if (copy_to_user(buffer, addr, len))
119250+ if (len > sizeof addr || copy_to_user(buffer, addr, len))
119251 return -EFAULT;
119252
119253 *lenp = len;
119254@@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
119255
119256 if (len > *lenp) len = *lenp;
119257
119258- if (copy_to_user(buffer, devname, len))
119259+ if (len > sizeof devname || copy_to_user(buffer, devname, len))
119260 return -EFAULT;
119261
119262 *lenp = len;
119263diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
119264index b445d49..13e8538 100644
119265--- a/net/dsa/dsa.c
119266+++ b/net/dsa/dsa.c
119267@@ -851,7 +851,7 @@ static struct packet_type dsa_pack_type __read_mostly = {
119268 .func = dsa_switch_rcv,
119269 };
119270
119271-static struct notifier_block dsa_netdevice_nb __read_mostly = {
119272+static struct notifier_block dsa_netdevice_nb = {
119273 .notifier_call = dsa_slave_netdevice_event,
119274 };
119275
119276diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c
119277index a2c7e4c..3dc9f67 100644
119278--- a/net/hsr/hsr_netlink.c
119279+++ b/net/hsr/hsr_netlink.c
119280@@ -102,7 +102,7 @@ nla_put_failure:
119281 return -EMSGSIZE;
119282 }
119283
119284-static struct rtnl_link_ops hsr_link_ops __read_mostly = {
119285+static struct rtnl_link_ops hsr_link_ops = {
119286 .kind = "hsr",
119287 .maxtype = IFLA_HSR_MAX,
119288 .policy = hsr_policy,
119289diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
119290index f20a387..2058892 100644
119291--- a/net/ieee802154/6lowpan/core.c
119292+++ b/net/ieee802154/6lowpan/core.c
119293@@ -191,7 +191,7 @@ static void lowpan_dellink(struct net_device *dev, struct list_head *head)
119294 dev_put(real_dev);
119295 }
119296
119297-static struct rtnl_link_ops lowpan_link_ops __read_mostly = {
119298+static struct rtnl_link_ops lowpan_link_ops = {
119299 .kind = "lowpan",
119300 .priv_size = sizeof(struct lowpan_dev_info),
119301 .setup = lowpan_setup,
119302diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
119303index 214d44a..dcb7f86 100644
119304--- a/net/ieee802154/6lowpan/reassembly.c
119305+++ b/net/ieee802154/6lowpan/reassembly.c
119306@@ -435,14 +435,13 @@ static struct ctl_table lowpan_frags_ctl_table[] = {
119307
119308 static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
119309 {
119310- struct ctl_table *table;
119311+ ctl_table_no_const *table = NULL;
119312 struct ctl_table_header *hdr;
119313 struct netns_ieee802154_lowpan *ieee802154_lowpan =
119314 net_ieee802154_lowpan(net);
119315
119316- table = lowpan_frags_ns_ctl_table;
119317 if (!net_eq(net, &init_net)) {
119318- table = kmemdup(table, sizeof(lowpan_frags_ns_ctl_table),
119319+ table = kmemdup(lowpan_frags_ns_ctl_table, sizeof(lowpan_frags_ns_ctl_table),
119320 GFP_KERNEL);
119321 if (table == NULL)
119322 goto err_alloc;
119323@@ -457,9 +456,9 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
119324 /* Don't export sysctls to unprivileged users */
119325 if (net->user_ns != &init_user_ns)
119326 table[0].procname = NULL;
119327- }
119328-
119329- hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
119330+ hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
119331+ } else
119332+ hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", lowpan_frags_ns_ctl_table);
119333 if (hdr == NULL)
119334 goto err_reg;
119335
119336@@ -467,8 +466,7 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
119337 return 0;
119338
119339 err_reg:
119340- if (!net_eq(net, &init_net))
119341- kfree(table);
119342+ kfree(table);
119343 err_alloc:
119344 return -ENOMEM;
119345 }
119346diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
119347index 9532ee8..020410a 100644
119348--- a/net/ipv4/af_inet.c
119349+++ b/net/ipv4/af_inet.c
119350@@ -1392,7 +1392,7 @@ int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)
119351 return ip_recv_error(sk, msg, len, addr_len);
119352 #if IS_ENABLED(CONFIG_IPV6)
119353 if (sk->sk_family == AF_INET6)
119354- return pingv6_ops.ipv6_recv_error(sk, msg, len, addr_len);
119355+ return pingv6_ops->ipv6_recv_error(sk, msg, len, addr_len);
119356 #endif
119357 return -EINVAL;
119358 }
119359diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
119360index 2d9cb17..20ae904 100644
119361--- a/net/ipv4/devinet.c
119362+++ b/net/ipv4/devinet.c
119363@@ -69,7 +69,8 @@
119364
119365 static struct ipv4_devconf ipv4_devconf = {
119366 .data = {
119367- [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 1,
119368+ [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 0,
119369+ [IPV4_DEVCONF_RP_FILTER - 1] = 1,
119370 [IPV4_DEVCONF_SEND_REDIRECTS - 1] = 1,
119371 [IPV4_DEVCONF_SECURE_REDIRECTS - 1] = 1,
119372 [IPV4_DEVCONF_SHARED_MEDIA - 1] = 1,
119373@@ -80,7 +81,8 @@ static struct ipv4_devconf ipv4_devconf = {
119374
119375 static struct ipv4_devconf ipv4_devconf_dflt = {
119376 .data = {
119377- [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 1,
119378+ [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 0,
119379+ [IPV4_DEVCONF_RP_FILTER - 1] = 1,
119380 [IPV4_DEVCONF_SEND_REDIRECTS - 1] = 1,
119381 [IPV4_DEVCONF_SECURE_REDIRECTS - 1] = 1,
119382 [IPV4_DEVCONF_SHARED_MEDIA - 1] = 1,
119383@@ -1579,7 +1581,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
119384 idx = 0;
119385 head = &net->dev_index_head[h];
119386 rcu_read_lock();
119387- cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
119388+ cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
119389 net->dev_base_seq;
119390 hlist_for_each_entry_rcu(dev, head, index_hlist) {
119391 if (idx < s_idx)
119392@@ -1905,7 +1907,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
119393 idx = 0;
119394 head = &net->dev_index_head[h];
119395 rcu_read_lock();
119396- cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
119397+ cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
119398 net->dev_base_seq;
119399 hlist_for_each_entry_rcu(dev, head, index_hlist) {
119400 if (idx < s_idx)
119401@@ -2146,7 +2148,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
119402 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
119403 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
119404
119405-static struct devinet_sysctl_table {
119406+static const struct devinet_sysctl_table {
119407 struct ctl_table_header *sysctl_header;
119408 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
119409 } devinet_sysctl = {
119410@@ -2280,7 +2282,7 @@ static __net_init int devinet_init_net(struct net *net)
119411 int err;
119412 struct ipv4_devconf *all, *dflt;
119413 #ifdef CONFIG_SYSCTL
119414- struct ctl_table *tbl = ctl_forward_entry;
119415+ ctl_table_no_const *tbl = NULL;
119416 struct ctl_table_header *forw_hdr;
119417 #endif
119418
119419@@ -2298,7 +2300,7 @@ static __net_init int devinet_init_net(struct net *net)
119420 goto err_alloc_dflt;
119421
119422 #ifdef CONFIG_SYSCTL
119423- tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
119424+ tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
119425 if (!tbl)
119426 goto err_alloc_ctl;
119427
119428@@ -2318,7 +2320,10 @@ static __net_init int devinet_init_net(struct net *net)
119429 goto err_reg_dflt;
119430
119431 err = -ENOMEM;
119432- forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
119433+ if (!net_eq(net, &init_net))
119434+ forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
119435+ else
119436+ forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
119437 if (!forw_hdr)
119438 goto err_reg_ctl;
119439 net->ipv4.forw_hdr = forw_hdr;
119440@@ -2334,8 +2339,7 @@ err_reg_ctl:
119441 err_reg_dflt:
119442 __devinet_sysctl_unregister(all);
119443 err_reg_all:
119444- if (tbl != ctl_forward_entry)
119445- kfree(tbl);
119446+ kfree(tbl);
119447 err_alloc_ctl:
119448 #endif
119449 if (dflt != &ipv4_devconf_dflt)
119450diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
119451index 6bbc549..28d74951 100644
119452--- a/net/ipv4/fib_frontend.c
119453+++ b/net/ipv4/fib_frontend.c
119454@@ -1083,12 +1083,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
119455 #ifdef CONFIG_IP_ROUTE_MULTIPATH
119456 fib_sync_up(dev, RTNH_F_DEAD);
119457 #endif
119458- atomic_inc(&net->ipv4.dev_addr_genid);
119459+ atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
119460 rt_cache_flush(dev_net(dev));
119461 break;
119462 case NETDEV_DOWN:
119463 fib_del_ifaddr(ifa, NULL);
119464- atomic_inc(&net->ipv4.dev_addr_genid);
119465+ atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
119466 if (!ifa->ifa_dev->ifa_list) {
119467 /* Last address was deleted from this interface.
119468 * Disable IP.
119469@@ -1127,7 +1127,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
119470 #ifdef CONFIG_IP_ROUTE_MULTIPATH
119471 fib_sync_up(dev, RTNH_F_DEAD);
119472 #endif
119473- atomic_inc(&net->ipv4.dev_addr_genid);
119474+ atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
119475 rt_cache_flush(net);
119476 break;
119477 case NETDEV_DOWN:
119478diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
119479index 3a06586..1020c5b 100644
119480--- a/net/ipv4/fib_semantics.c
119481+++ b/net/ipv4/fib_semantics.c
119482@@ -755,7 +755,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
119483 nh->nh_saddr = inet_select_addr(nh->nh_dev,
119484 nh->nh_gw,
119485 nh->nh_parent->fib_scope);
119486- nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
119487+ nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
119488
119489 return nh->nh_saddr;
119490 }
119491diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
119492index 61b45a1..2970363 100644
119493--- a/net/ipv4/inet_connection_sock.c
119494+++ b/net/ipv4/inet_connection_sock.c
119495@@ -729,8 +729,8 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
119496 newsk->sk_write_space = sk_stream_write_space;
119497
119498 newsk->sk_mark = inet_rsk(req)->ir_mark;
119499- atomic64_set(&newsk->sk_cookie,
119500- atomic64_read(&inet_rsk(req)->ir_cookie));
119501+ atomic64_set_unchecked(&newsk->sk_cookie,
119502+ atomic64_read_unchecked(&inet_rsk(req)->ir_cookie));
119503
119504 newicsk->icsk_retransmits = 0;
119505 newicsk->icsk_backoff = 0;
119506diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
119507index 0cb9165..8589720 100644
119508--- a/net/ipv4/inet_hashtables.c
119509+++ b/net/ipv4/inet_hashtables.c
119510@@ -19,6 +19,7 @@
119511 #include <linux/slab.h>
119512 #include <linux/wait.h>
119513 #include <linux/vmalloc.h>
119514+#include <linux/security.h>
119515
119516 #include <net/inet_connection_sock.h>
119517 #include <net/inet_hashtables.h>
119518@@ -54,6 +55,8 @@ u32 sk_ehashfn(const struct sock *sk)
119519 sk->sk_daddr, sk->sk_dport);
119520 }
119521
119522+extern void gr_update_task_in_ip_table(const struct inet_sock *inet);
119523+
119524 /*
119525 * Allocate and initialize a new local port bind bucket.
119526 * The bindhash mutex for snum's hash chain must be held here.
119527@@ -566,6 +569,8 @@ ok:
119528 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
119529 spin_unlock(&head->lock);
119530
119531+ gr_update_task_in_ip_table(inet_sk(sk));
119532+
119533 if (tw) {
119534 inet_twsk_deschedule(tw);
119535 while (twrefcnt) {
119536diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
119537index 2ffbd16..6e94995 100644
119538--- a/net/ipv4/inet_timewait_sock.c
119539+++ b/net/ipv4/inet_timewait_sock.c
119540@@ -214,7 +214,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,
119541 tw->tw_ipv6only = 0;
119542 tw->tw_transparent = inet->transparent;
119543 tw->tw_prot = sk->sk_prot_creator;
119544- atomic64_set(&tw->tw_cookie, atomic64_read(&sk->sk_cookie));
119545+ atomic64_set_unchecked(&tw->tw_cookie, atomic64_read_unchecked(&sk->sk_cookie));
119546 twsk_net_set(tw, sock_net(sk));
119547 setup_timer(&tw->tw_timer, tw_timer_handler, (unsigned long)tw);
119548 /*
119549diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
119550index 241afd7..31b95d5 100644
119551--- a/net/ipv4/inetpeer.c
119552+++ b/net/ipv4/inetpeer.c
119553@@ -461,7 +461,7 @@ relookup:
119554 if (p) {
119555 p->daddr = *daddr;
119556 atomic_set(&p->refcnt, 1);
119557- atomic_set(&p->rid, 0);
119558+ atomic_set_unchecked(&p->rid, 0);
119559 p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW;
119560 p->rate_tokens = 0;
119561 /* 60*HZ is arbitrary, but chosen enough high so that the first
119562diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
119563index 921138f..1e011ff 100644
119564--- a/net/ipv4/ip_fragment.c
119565+++ b/net/ipv4/ip_fragment.c
119566@@ -276,7 +276,7 @@ static int ip_frag_too_far(struct ipq *qp)
119567 return 0;
119568
119569 start = qp->rid;
119570- end = atomic_inc_return(&peer->rid);
119571+ end = atomic_inc_return_unchecked(&peer->rid);
119572 qp->rid = end;
119573
119574 rc = qp->q.fragments && (end - start) > max;
119575@@ -780,12 +780,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
119576
119577 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
119578 {
119579- struct ctl_table *table;
119580+ ctl_table_no_const *table = NULL;
119581 struct ctl_table_header *hdr;
119582
119583- table = ip4_frags_ns_ctl_table;
119584 if (!net_eq(net, &init_net)) {
119585- table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
119586+ table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
119587 if (!table)
119588 goto err_alloc;
119589
119590@@ -799,9 +798,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
119591 /* Don't export sysctls to unprivileged users */
119592 if (net->user_ns != &init_user_ns)
119593 table[0].procname = NULL;
119594- }
119595+ hdr = register_net_sysctl(net, "net/ipv4", table);
119596+ } else
119597+ hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
119598
119599- hdr = register_net_sysctl(net, "net/ipv4", table);
119600 if (!hdr)
119601 goto err_reg;
119602
119603@@ -809,8 +809,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
119604 return 0;
119605
119606 err_reg:
119607- if (!net_eq(net, &init_net))
119608- kfree(table);
119609+ kfree(table);
119610 err_alloc:
119611 return -ENOMEM;
119612 }
119613diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
119614index 5fd7064..d13d75f 100644
119615--- a/net/ipv4/ip_gre.c
119616+++ b/net/ipv4/ip_gre.c
119617@@ -115,7 +115,7 @@ static bool log_ecn_error = true;
119618 module_param(log_ecn_error, bool, 0644);
119619 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
119620
119621-static struct rtnl_link_ops ipgre_link_ops __read_mostly;
119622+static struct rtnl_link_ops ipgre_link_ops;
119623 static int ipgre_tunnel_init(struct net_device *dev);
119624
119625 static int ipgre_net_id __read_mostly;
119626@@ -819,7 +819,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
119627 [IFLA_GRE_ENCAP_DPORT] = { .type = NLA_U16 },
119628 };
119629
119630-static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
119631+static struct rtnl_link_ops ipgre_link_ops = {
119632 .kind = "gre",
119633 .maxtype = IFLA_GRE_MAX,
119634 .policy = ipgre_policy,
119635@@ -834,7 +834,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
119636 .get_link_net = ip_tunnel_get_link_net,
119637 };
119638
119639-static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
119640+static struct rtnl_link_ops ipgre_tap_ops = {
119641 .kind = "gretap",
119642 .maxtype = IFLA_GRE_MAX,
119643 .policy = ipgre_policy,
119644diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
119645index 2db4c87..4db9282 100644
119646--- a/net/ipv4/ip_input.c
119647+++ b/net/ipv4/ip_input.c
119648@@ -147,6 +147,10 @@
119649 #include <linux/mroute.h>
119650 #include <linux/netlink.h>
119651
119652+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119653+extern int grsec_enable_blackhole;
119654+#endif
119655+
119656 /*
119657 * Process Router Attention IP option (RFC 2113)
119658 */
119659@@ -223,6 +227,9 @@ static int ip_local_deliver_finish(struct sock *sk, struct sk_buff *skb)
119660 if (!raw) {
119661 if (xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
119662 IP_INC_STATS_BH(net, IPSTATS_MIB_INUNKNOWNPROTOS);
119663+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119664+ if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
119665+#endif
119666 icmp_send(skb, ICMP_DEST_UNREACH,
119667 ICMP_PROT_UNREACH, 0);
119668 }
119669diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
119670index c3c359a..504edc6 100644
119671--- a/net/ipv4/ip_sockglue.c
119672+++ b/net/ipv4/ip_sockglue.c
119673@@ -1295,7 +1295,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
119674 len = min_t(unsigned int, len, opt->optlen);
119675 if (put_user(len, optlen))
119676 return -EFAULT;
119677- if (copy_to_user(optval, opt->__data, len))
119678+ if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
119679+ copy_to_user(optval, opt->__data, len))
119680 return -EFAULT;
119681 return 0;
119682 }
119683@@ -1432,7 +1433,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
119684 if (sk->sk_type != SOCK_STREAM)
119685 return -ENOPROTOOPT;
119686
119687- msg.msg_control = (__force void *) optval;
119688+ msg.msg_control = (__force_kernel void *) optval;
119689 msg.msg_controllen = len;
119690 msg.msg_flags = flags;
119691
119692diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
119693index 0c15208..a3a76c5 100644
119694--- a/net/ipv4/ip_vti.c
119695+++ b/net/ipv4/ip_vti.c
119696@@ -45,7 +45,7 @@
119697 #include <net/net_namespace.h>
119698 #include <net/netns/generic.h>
119699
119700-static struct rtnl_link_ops vti_link_ops __read_mostly;
119701+static struct rtnl_link_ops vti_link_ops;
119702
119703 static int vti_net_id __read_mostly;
119704 static int vti_tunnel_init(struct net_device *dev);
119705@@ -525,7 +525,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
119706 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
119707 };
119708
119709-static struct rtnl_link_ops vti_link_ops __read_mostly = {
119710+static struct rtnl_link_ops vti_link_ops = {
119711 .kind = "vti",
119712 .maxtype = IFLA_VTI_MAX,
119713 .policy = vti_policy,
119714diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
119715index 8e7328c..9bd7ed3 100644
119716--- a/net/ipv4/ipconfig.c
119717+++ b/net/ipv4/ipconfig.c
119718@@ -333,7 +333,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
119719
119720 mm_segment_t oldfs = get_fs();
119721 set_fs(get_ds());
119722- res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
119723+ res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
119724 set_fs(oldfs);
119725 return res;
119726 }
119727@@ -344,7 +344,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
119728
119729 mm_segment_t oldfs = get_fs();
119730 set_fs(get_ds());
119731- res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
119732+ res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
119733 set_fs(oldfs);
119734 return res;
119735 }
119736@@ -355,7 +355,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
119737
119738 mm_segment_t oldfs = get_fs();
119739 set_fs(get_ds());
119740- res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
119741+ res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
119742 set_fs(oldfs);
119743 return res;
119744 }
119745diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
119746index 254238d..82c19a2 100644
119747--- a/net/ipv4/ipip.c
119748+++ b/net/ipv4/ipip.c
119749@@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
119750 static int ipip_net_id __read_mostly;
119751
119752 static int ipip_tunnel_init(struct net_device *dev);
119753-static struct rtnl_link_ops ipip_link_ops __read_mostly;
119754+static struct rtnl_link_ops ipip_link_ops;
119755
119756 static int ipip_err(struct sk_buff *skb, u32 info)
119757 {
119758@@ -488,7 +488,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
119759 [IFLA_IPTUN_ENCAP_DPORT] = { .type = NLA_U16 },
119760 };
119761
119762-static struct rtnl_link_ops ipip_link_ops __read_mostly = {
119763+static struct rtnl_link_ops ipip_link_ops = {
119764 .kind = "ipip",
119765 .maxtype = IFLA_IPTUN_MAX,
119766 .policy = ipip_policy,
119767diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
119768index 92305a1..0a5b349 100644
119769--- a/net/ipv4/netfilter/arp_tables.c
119770+++ b/net/ipv4/netfilter/arp_tables.c
119771@@ -896,14 +896,14 @@ static int compat_table_info(const struct xt_table_info *info,
119772 #endif
119773
119774 static int get_info(struct net *net, void __user *user,
119775- const int *len, int compat)
119776+ int len, int compat)
119777 {
119778 char name[XT_TABLE_MAXNAMELEN];
119779 struct xt_table *t;
119780 int ret;
119781
119782- if (*len != sizeof(struct arpt_getinfo)) {
119783- duprintf("length %u != %Zu\n", *len,
119784+ if (len != sizeof(struct arpt_getinfo)) {
119785+ duprintf("length %u != %Zu\n", len,
119786 sizeof(struct arpt_getinfo));
119787 return -EINVAL;
119788 }
119789@@ -940,7 +940,7 @@ static int get_info(struct net *net, void __user *user,
119790 info.size = private->size;
119791 strcpy(info.name, name);
119792
119793- if (copy_to_user(user, &info, *len) != 0)
119794+ if (copy_to_user(user, &info, len) != 0)
119795 ret = -EFAULT;
119796 else
119797 ret = 0;
119798@@ -1705,7 +1705,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
119799
119800 switch (cmd) {
119801 case ARPT_SO_GET_INFO:
119802- ret = get_info(sock_net(sk), user, len, 1);
119803+ ret = get_info(sock_net(sk), user, *len, 1);
119804 break;
119805 case ARPT_SO_GET_ENTRIES:
119806 ret = compat_get_entries(sock_net(sk), user, len);
119807@@ -1750,7 +1750,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
119808
119809 switch (cmd) {
119810 case ARPT_SO_GET_INFO:
119811- ret = get_info(sock_net(sk), user, len, 0);
119812+ ret = get_info(sock_net(sk), user, *len, 0);
119813 break;
119814
119815 case ARPT_SO_GET_ENTRIES:
119816diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
119817index 6c72fbb..ce47b05 100644
119818--- a/net/ipv4/netfilter/ip_tables.c
119819+++ b/net/ipv4/netfilter/ip_tables.c
119820@@ -1073,14 +1073,14 @@ static int compat_table_info(const struct xt_table_info *info,
119821 #endif
119822
119823 static int get_info(struct net *net, void __user *user,
119824- const int *len, int compat)
119825+ int len, int compat)
119826 {
119827 char name[XT_TABLE_MAXNAMELEN];
119828 struct xt_table *t;
119829 int ret;
119830
119831- if (*len != sizeof(struct ipt_getinfo)) {
119832- duprintf("length %u != %zu\n", *len,
119833+ if (len != sizeof(struct ipt_getinfo)) {
119834+ duprintf("length %u != %zu\n", len,
119835 sizeof(struct ipt_getinfo));
119836 return -EINVAL;
119837 }
119838@@ -1117,7 +1117,7 @@ static int get_info(struct net *net, void __user *user,
119839 info.size = private->size;
119840 strcpy(info.name, name);
119841
119842- if (copy_to_user(user, &info, *len) != 0)
119843+ if (copy_to_user(user, &info, len) != 0)
119844 ret = -EFAULT;
119845 else
119846 ret = 0;
119847@@ -1968,7 +1968,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
119848
119849 switch (cmd) {
119850 case IPT_SO_GET_INFO:
119851- ret = get_info(sock_net(sk), user, len, 1);
119852+ ret = get_info(sock_net(sk), user, *len, 1);
119853 break;
119854 case IPT_SO_GET_ENTRIES:
119855 ret = compat_get_entries(sock_net(sk), user, len);
119856@@ -2015,7 +2015,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
119857
119858 switch (cmd) {
119859 case IPT_SO_GET_INFO:
119860- ret = get_info(sock_net(sk), user, len, 0);
119861+ ret = get_info(sock_net(sk), user, *len, 0);
119862 break;
119863
119864 case IPT_SO_GET_ENTRIES:
119865diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
119866index 45cb16a..cef4ecd 100644
119867--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
119868+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
119869@@ -730,7 +730,7 @@ static int clusterip_net_init(struct net *net)
119870 spin_lock_init(&cn->lock);
119871
119872 #ifdef CONFIG_PROC_FS
119873- cn->procdir = proc_mkdir("ipt_CLUSTERIP", net->proc_net);
119874+ cn->procdir = proc_mkdir_restrict("ipt_CLUSTERIP", net->proc_net);
119875 if (!cn->procdir) {
119876 pr_err("Unable to proc dir entry\n");
119877 return -ENOMEM;
119878diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
119879index 05ff44b..da00000 100644
119880--- a/net/ipv4/ping.c
119881+++ b/net/ipv4/ping.c
119882@@ -59,7 +59,7 @@ struct ping_table {
119883 };
119884
119885 static struct ping_table ping_table;
119886-struct pingv6_ops pingv6_ops;
119887+struct pingv6_ops *pingv6_ops;
119888 EXPORT_SYMBOL_GPL(pingv6_ops);
119889
119890 static u16 ping_port_rover;
119891@@ -359,7 +359,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
119892 return -ENODEV;
119893 }
119894 }
119895- has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
119896+ has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
119897 scoped);
119898 rcu_read_unlock();
119899
119900@@ -567,7 +567,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
119901 }
119902 #if IS_ENABLED(CONFIG_IPV6)
119903 } else if (skb->protocol == htons(ETH_P_IPV6)) {
119904- harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
119905+ harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
119906 #endif
119907 }
119908
119909@@ -585,7 +585,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
119910 info, (u8 *)icmph);
119911 #if IS_ENABLED(CONFIG_IPV6)
119912 } else if (family == AF_INET6) {
119913- pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
119914+ pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
119915 info, (u8 *)icmph);
119916 #endif
119917 }
119918@@ -918,10 +918,10 @@ int ping_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
119919 }
119920
119921 if (inet6_sk(sk)->rxopt.all)
119922- pingv6_ops.ip6_datagram_recv_common_ctl(sk, msg, skb);
119923+ pingv6_ops->ip6_datagram_recv_common_ctl(sk, msg, skb);
119924 if (skb->protocol == htons(ETH_P_IPV6) &&
119925 inet6_sk(sk)->rxopt.all)
119926- pingv6_ops.ip6_datagram_recv_specific_ctl(sk, msg, skb);
119927+ pingv6_ops->ip6_datagram_recv_specific_ctl(sk, msg, skb);
119928 else if (skb->protocol == htons(ETH_P_IP) && isk->cmsg_flags)
119929 ip_cmsg_recv(msg, skb);
119930 #endif
119931@@ -1116,7 +1116,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
119932 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
119933 0, sock_i_ino(sp),
119934 atomic_read(&sp->sk_refcnt), sp,
119935- atomic_read(&sp->sk_drops));
119936+ atomic_read_unchecked(&sp->sk_drops));
119937 }
119938
119939 static int ping_v4_seq_show(struct seq_file *seq, void *v)
119940diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
119941index 561cd4b..a32a155 100644
119942--- a/net/ipv4/raw.c
119943+++ b/net/ipv4/raw.c
119944@@ -323,7 +323,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
119945 int raw_rcv(struct sock *sk, struct sk_buff *skb)
119946 {
119947 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
119948- atomic_inc(&sk->sk_drops);
119949+ atomic_inc_unchecked(&sk->sk_drops);
119950 kfree_skb(skb);
119951 return NET_RX_DROP;
119952 }
119953@@ -771,16 +771,20 @@ static int raw_init(struct sock *sk)
119954
119955 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
119956 {
119957+ struct icmp_filter filter;
119958+
119959 if (optlen > sizeof(struct icmp_filter))
119960 optlen = sizeof(struct icmp_filter);
119961- if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
119962+ if (copy_from_user(&filter, optval, optlen))
119963 return -EFAULT;
119964+ raw_sk(sk)->filter = filter;
119965 return 0;
119966 }
119967
119968 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
119969 {
119970 int len, ret = -EFAULT;
119971+ struct icmp_filter filter;
119972
119973 if (get_user(len, optlen))
119974 goto out;
119975@@ -790,8 +794,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
119976 if (len > sizeof(struct icmp_filter))
119977 len = sizeof(struct icmp_filter);
119978 ret = -EFAULT;
119979- if (put_user(len, optlen) ||
119980- copy_to_user(optval, &raw_sk(sk)->filter, len))
119981+ filter = raw_sk(sk)->filter;
119982+ if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
119983 goto out;
119984 ret = 0;
119985 out: return ret;
119986@@ -1020,7 +1024,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
119987 0, 0L, 0,
119988 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
119989 0, sock_i_ino(sp),
119990- atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
119991+ atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
119992 }
119993
119994 static int raw_seq_show(struct seq_file *seq, void *v)
119995diff --git a/net/ipv4/route.c b/net/ipv4/route.c
119996index e681b85..8a43a65 100644
119997--- a/net/ipv4/route.c
119998+++ b/net/ipv4/route.c
119999@@ -227,7 +227,7 @@ static const struct seq_operations rt_cache_seq_ops = {
120000
120001 static int rt_cache_seq_open(struct inode *inode, struct file *file)
120002 {
120003- return seq_open(file, &rt_cache_seq_ops);
120004+ return seq_open_restrict(file, &rt_cache_seq_ops);
120005 }
120006
120007 static const struct file_operations rt_cache_seq_fops = {
120008@@ -318,7 +318,7 @@ static const struct seq_operations rt_cpu_seq_ops = {
120009
120010 static int rt_cpu_seq_open(struct inode *inode, struct file *file)
120011 {
120012- return seq_open(file, &rt_cpu_seq_ops);
120013+ return seq_open_restrict(file, &rt_cpu_seq_ops);
120014 }
120015
120016 static const struct file_operations rt_cpu_seq_fops = {
120017@@ -356,7 +356,7 @@ static int rt_acct_proc_show(struct seq_file *m, void *v)
120018
120019 static int rt_acct_proc_open(struct inode *inode, struct file *file)
120020 {
120021- return single_open(file, rt_acct_proc_show, NULL);
120022+ return single_open_restrict(file, rt_acct_proc_show, NULL);
120023 }
120024
120025 static const struct file_operations rt_acct_proc_fops = {
120026@@ -458,7 +458,7 @@ static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst,
120027
120028 #define IP_IDENTS_SZ 2048u
120029
120030-static atomic_t *ip_idents __read_mostly;
120031+static atomic_unchecked_t ip_idents[IP_IDENTS_SZ] __read_mostly;
120032 static u32 *ip_tstamps __read_mostly;
120033
120034 /* In order to protect privacy, we add a perturbation to identifiers
120035@@ -468,7 +468,7 @@ static u32 *ip_tstamps __read_mostly;
120036 u32 ip_idents_reserve(u32 hash, int segs)
120037 {
120038 u32 *p_tstamp = ip_tstamps + hash % IP_IDENTS_SZ;
120039- atomic_t *p_id = ip_idents + hash % IP_IDENTS_SZ;
120040+ atomic_unchecked_t *p_id = ip_idents + hash % IP_IDENTS_SZ;
120041 u32 old = ACCESS_ONCE(*p_tstamp);
120042 u32 now = (u32)jiffies;
120043 u32 delta = 0;
120044@@ -476,7 +476,7 @@ u32 ip_idents_reserve(u32 hash, int segs)
120045 if (old != now && cmpxchg(p_tstamp, old, now) == old)
120046 delta = prandom_u32_max(now - old);
120047
120048- return atomic_add_return(segs + delta, p_id) - segs;
120049+ return atomic_add_return_unchecked(segs + delta, p_id) - segs;
120050 }
120051 EXPORT_SYMBOL(ip_idents_reserve);
120052
120053@@ -2640,34 +2640,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
120054 .maxlen = sizeof(int),
120055 .mode = 0200,
120056 .proc_handler = ipv4_sysctl_rtcache_flush,
120057+ .extra1 = &init_net,
120058 },
120059 { },
120060 };
120061
120062 static __net_init int sysctl_route_net_init(struct net *net)
120063 {
120064- struct ctl_table *tbl;
120065+ ctl_table_no_const *tbl = NULL;
120066
120067- tbl = ipv4_route_flush_table;
120068 if (!net_eq(net, &init_net)) {
120069- tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
120070+ tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
120071 if (!tbl)
120072 goto err_dup;
120073
120074 /* Don't export sysctls to unprivileged users */
120075 if (net->user_ns != &init_user_ns)
120076 tbl[0].procname = NULL;
120077- }
120078- tbl[0].extra1 = net;
120079+ tbl[0].extra1 = net;
120080+ net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
120081+ } else
120082+ net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
120083
120084- net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
120085 if (!net->ipv4.route_hdr)
120086 goto err_reg;
120087 return 0;
120088
120089 err_reg:
120090- if (tbl != ipv4_route_flush_table)
120091- kfree(tbl);
120092+ kfree(tbl);
120093 err_dup:
120094 return -ENOMEM;
120095 }
120096@@ -2690,8 +2690,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
120097
120098 static __net_init int rt_genid_init(struct net *net)
120099 {
120100- atomic_set(&net->ipv4.rt_genid, 0);
120101- atomic_set(&net->fnhe_genid, 0);
120102+ atomic_set_unchecked(&net->ipv4.rt_genid, 0);
120103+ atomic_set_unchecked(&net->fnhe_genid, 0);
120104 get_random_bytes(&net->ipv4.dev_addr_genid,
120105 sizeof(net->ipv4.dev_addr_genid));
120106 return 0;
120107@@ -2735,11 +2735,7 @@ int __init ip_rt_init(void)
120108 int rc = 0;
120109 int cpu;
120110
120111- ip_idents = kmalloc(IP_IDENTS_SZ * sizeof(*ip_idents), GFP_KERNEL);
120112- if (!ip_idents)
120113- panic("IP: failed to allocate ip_idents\n");
120114-
120115- prandom_bytes(ip_idents, IP_IDENTS_SZ * sizeof(*ip_idents));
120116+ prandom_bytes(ip_idents, sizeof(ip_idents));
120117
120118 ip_tstamps = kcalloc(IP_IDENTS_SZ, sizeof(*ip_tstamps), GFP_KERNEL);
120119 if (!ip_tstamps)
120120diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
120121index 0330ab2..4745d2c 100644
120122--- a/net/ipv4/sysctl_net_ipv4.c
120123+++ b/net/ipv4/sysctl_net_ipv4.c
120124@@ -66,7 +66,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
120125 container_of(table->data, struct net, ipv4.ip_local_ports.range);
120126 int ret;
120127 int range[2];
120128- struct ctl_table tmp = {
120129+ ctl_table_no_const tmp = {
120130 .data = &range,
120131 .maxlen = sizeof(range),
120132 .mode = table->mode,
120133@@ -124,7 +124,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
120134 int ret;
120135 gid_t urange[2];
120136 kgid_t low, high;
120137- struct ctl_table tmp = {
120138+ ctl_table_no_const tmp = {
120139 .data = &urange,
120140 .maxlen = sizeof(urange),
120141 .mode = table->mode,
120142@@ -155,7 +155,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
120143 void __user *buffer, size_t *lenp, loff_t *ppos)
120144 {
120145 char val[TCP_CA_NAME_MAX];
120146- struct ctl_table tbl = {
120147+ ctl_table_no_const tbl = {
120148 .data = val,
120149 .maxlen = TCP_CA_NAME_MAX,
120150 };
120151@@ -174,7 +174,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
120152 void __user *buffer, size_t *lenp,
120153 loff_t *ppos)
120154 {
120155- struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
120156+ ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
120157 int ret;
120158
120159 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
120160@@ -191,7 +191,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
120161 void __user *buffer, size_t *lenp,
120162 loff_t *ppos)
120163 {
120164- struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
120165+ ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
120166 int ret;
120167
120168 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
120169@@ -210,7 +210,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
120170 void __user *buffer, size_t *lenp,
120171 loff_t *ppos)
120172 {
120173- struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
120174+ ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
120175 struct tcp_fastopen_context *ctxt;
120176 int ret;
120177 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
120178@@ -915,13 +915,12 @@ static struct ctl_table ipv4_net_table[] = {
120179
120180 static __net_init int ipv4_sysctl_init_net(struct net *net)
120181 {
120182- struct ctl_table *table;
120183+ ctl_table_no_const *table = NULL;
120184
120185- table = ipv4_net_table;
120186 if (!net_eq(net, &init_net)) {
120187 int i;
120188
120189- table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
120190+ table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
120191 if (!table)
120192 goto err_alloc;
120193
120194@@ -930,7 +929,10 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
120195 table[i].data += (void *)net - (void *)&init_net;
120196 }
120197
120198- net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
120199+ if (!net_eq(net, &init_net))
120200+ net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
120201+ else
120202+ net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
120203 if (!net->ipv4.ipv4_hdr)
120204 goto err_reg;
120205
120206diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
120207index 728f5b3..dc51cbe 100644
120208--- a/net/ipv4/tcp_input.c
120209+++ b/net/ipv4/tcp_input.c
120210@@ -767,7 +767,7 @@ static void tcp_update_pacing_rate(struct sock *sk)
120211 * without any lock. We want to make sure compiler wont store
120212 * intermediate values in this location.
120213 */
120214- ACCESS_ONCE(sk->sk_pacing_rate) = min_t(u64, rate,
120215+ ACCESS_ONCE_RW(sk->sk_pacing_rate) = min_t(u64, rate,
120216 sk->sk_max_pacing_rate);
120217 }
120218
120219@@ -4608,7 +4608,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
120220 * simplifies code)
120221 */
120222 static void
120223-tcp_collapse(struct sock *sk, struct sk_buff_head *list,
120224+__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
120225 struct sk_buff *head, struct sk_buff *tail,
120226 u32 start, u32 end)
120227 {
120228@@ -5603,6 +5603,7 @@ discard:
120229 tcp_paws_reject(&tp->rx_opt, 0))
120230 goto discard_and_undo;
120231
120232+#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
120233 if (th->syn) {
120234 /* We see SYN without ACK. It is attempt of
120235 * simultaneous connect with crossed SYNs.
120236@@ -5653,6 +5654,7 @@ discard:
120237 goto discard;
120238 #endif
120239 }
120240+#endif
120241 /* "fifth, if neither of the SYN or RST bits is set then
120242 * drop the segment and return."
120243 */
120244@@ -5699,7 +5701,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
120245 goto discard;
120246
120247 if (th->syn) {
120248- if (th->fin)
120249+ if (th->fin || th->urg || th->psh)
120250 goto discard;
120251 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
120252 return 1;
120253@@ -6026,7 +6028,7 @@ struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops,
120254
120255 kmemcheck_annotate_bitfield(ireq, flags);
120256 ireq->opt = NULL;
120257- atomic64_set(&ireq->ir_cookie, 0);
120258+ atomic64_set_unchecked(&ireq->ir_cookie, 0);
120259 ireq->ireq_state = TCP_NEW_SYN_RECV;
120260 write_pnet(&ireq->ireq_net, sock_net(sk_listener));
120261 ireq->ireq_family = sk_listener->sk_family;
120262diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
120263index 0ea2e1c..a4d1c48 100644
120264--- a/net/ipv4/tcp_ipv4.c
120265+++ b/net/ipv4/tcp_ipv4.c
120266@@ -89,6 +89,10 @@ int sysctl_tcp_tw_reuse __read_mostly;
120267 int sysctl_tcp_low_latency __read_mostly;
120268 EXPORT_SYMBOL(sysctl_tcp_low_latency);
120269
120270+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120271+extern int grsec_enable_blackhole;
120272+#endif
120273+
120274 #ifdef CONFIG_TCP_MD5SIG
120275 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
120276 __be32 daddr, __be32 saddr, const struct tcphdr *th);
120277@@ -1427,6 +1431,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
120278 return 0;
120279
120280 reset:
120281+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120282+ if (!grsec_enable_blackhole)
120283+#endif
120284 tcp_v4_send_reset(rsk, skb);
120285 discard:
120286 kfree_skb(skb);
120287@@ -1591,12 +1598,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
120288 TCP_SKB_CB(skb)->sacked = 0;
120289
120290 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
120291- if (!sk)
120292+ if (!sk) {
120293+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120294+ ret = 1;
120295+#endif
120296 goto no_tcp_socket;
120297-
120298+ }
120299 process:
120300- if (sk->sk_state == TCP_TIME_WAIT)
120301+ if (sk->sk_state == TCP_TIME_WAIT) {
120302+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120303+ ret = 2;
120304+#endif
120305 goto do_time_wait;
120306+ }
120307
120308 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
120309 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
120310@@ -1653,6 +1667,10 @@ csum_error:
120311 bad_packet:
120312 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
120313 } else {
120314+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120315+ if (!grsec_enable_blackhole || (ret == 1 &&
120316+ (skb->dev->flags & IFF_LOOPBACK)))
120317+#endif
120318 tcp_v4_send_reset(NULL, skb);
120319 }
120320
120321diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
120322index 4bc00cb..d024adf 100644
120323--- a/net/ipv4/tcp_minisocks.c
120324+++ b/net/ipv4/tcp_minisocks.c
120325@@ -27,6 +27,10 @@
120326 #include <net/inet_common.h>
120327 #include <net/xfrm.h>
120328
120329+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120330+extern int grsec_enable_blackhole;
120331+#endif
120332+
120333 int sysctl_tcp_syncookies __read_mostly = 1;
120334 EXPORT_SYMBOL(sysctl_tcp_syncookies);
120335
120336@@ -782,7 +786,10 @@ embryonic_reset:
120337 * avoid becoming vulnerable to outside attack aiming at
120338 * resetting legit local connections.
120339 */
120340- req->rsk_ops->send_reset(sk, skb);
120341+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120342+ if (!grsec_enable_blackhole)
120343+#endif
120344+ req->rsk_ops->send_reset(sk, skb);
120345 } else if (fastopen) { /* received a valid RST pkt */
120346 reqsk_fastopen_remove(sk, req, true);
120347 tcp_reset(sk);
120348diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
120349index ebf5ff5..4d1ff32 100644
120350--- a/net/ipv4/tcp_probe.c
120351+++ b/net/ipv4/tcp_probe.c
120352@@ -236,7 +236,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
120353 if (cnt + width >= len)
120354 break;
120355
120356- if (copy_to_user(buf + cnt, tbuf, width))
120357+ if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
120358 return -EFAULT;
120359 cnt += width;
120360 }
120361diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
120362index 5b752f5..9594bb2 100644
120363--- a/net/ipv4/tcp_timer.c
120364+++ b/net/ipv4/tcp_timer.c
120365@@ -22,6 +22,10 @@
120366 #include <linux/gfp.h>
120367 #include <net/tcp.h>
120368
120369+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120370+extern int grsec_lastack_retries;
120371+#endif
120372+
120373 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
120374 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
120375 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
120376@@ -195,6 +199,13 @@ static int tcp_write_timeout(struct sock *sk)
120377 }
120378 }
120379
120380+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120381+ if ((sk->sk_state == TCP_LAST_ACK) &&
120382+ (grsec_lastack_retries > 0) &&
120383+ (grsec_lastack_retries < retry_until))
120384+ retry_until = grsec_lastack_retries;
120385+#endif
120386+
120387 if (retransmits_timed_out(sk, retry_until,
120388 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
120389 /* Has it gone just too far? */
120390diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
120391index 1b8c5ba..e1f0542 100644
120392--- a/net/ipv4/udp.c
120393+++ b/net/ipv4/udp.c
120394@@ -87,6 +87,7 @@
120395 #include <linux/types.h>
120396 #include <linux/fcntl.h>
120397 #include <linux/module.h>
120398+#include <linux/security.h>
120399 #include <linux/socket.h>
120400 #include <linux/sockios.h>
120401 #include <linux/igmp.h>
120402@@ -115,6 +116,10 @@
120403 #include <net/busy_poll.h>
120404 #include "udp_impl.h"
120405
120406+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120407+extern int grsec_enable_blackhole;
120408+#endif
120409+
120410 struct udp_table udp_table __read_mostly;
120411 EXPORT_SYMBOL(udp_table);
120412
120413@@ -608,6 +613,9 @@ static inline bool __udp_is_mcast_sock(struct net *net, struct sock *sk,
120414 return true;
120415 }
120416
120417+extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
120418+extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
120419+
120420 /*
120421 * This routine is called by the ICMP module when it gets some
120422 * sort of error condition. If err < 0 then the socket should
120423@@ -944,9 +952,18 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
120424 dport = usin->sin_port;
120425 if (dport == 0)
120426 return -EINVAL;
120427+
120428+ err = gr_search_udp_sendmsg(sk, usin);
120429+ if (err)
120430+ return err;
120431 } else {
120432 if (sk->sk_state != TCP_ESTABLISHED)
120433 return -EDESTADDRREQ;
120434+
120435+ err = gr_search_udp_sendmsg(sk, NULL);
120436+ if (err)
120437+ return err;
120438+
120439 daddr = inet->inet_daddr;
120440 dport = inet->inet_dport;
120441 /* Open fast path for connected socket.
120442@@ -1193,7 +1210,7 @@ static unsigned int first_packet_length(struct sock *sk)
120443 IS_UDPLITE(sk));
120444 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
120445 IS_UDPLITE(sk));
120446- atomic_inc(&sk->sk_drops);
120447+ atomic_inc_unchecked(&sk->sk_drops);
120448 __skb_unlink(skb, rcvq);
120449 __skb_queue_tail(&list_kill, skb);
120450 }
120451@@ -1273,6 +1290,10 @@ try_again:
120452 if (!skb)
120453 goto out;
120454
120455+ err = gr_search_udp_recvmsg(sk, skb);
120456+ if (err)
120457+ goto out_free;
120458+
120459 ulen = skb->len - sizeof(struct udphdr);
120460 copied = len;
120461 if (copied > ulen)
120462@@ -1305,7 +1326,7 @@ try_again:
120463 if (unlikely(err)) {
120464 trace_kfree_skb(skb, udp_recvmsg);
120465 if (!peeked) {
120466- atomic_inc(&sk->sk_drops);
120467+ atomic_inc_unchecked(&sk->sk_drops);
120468 UDP_INC_STATS_USER(sock_net(sk),
120469 UDP_MIB_INERRORS, is_udplite);
120470 }
120471@@ -1599,7 +1620,7 @@ csum_error:
120472 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
120473 drop:
120474 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
120475- atomic_inc(&sk->sk_drops);
120476+ atomic_inc_unchecked(&sk->sk_drops);
120477 kfree_skb(skb);
120478 return -1;
120479 }
120480@@ -1617,7 +1638,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
120481 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
120482
120483 if (!skb1) {
120484- atomic_inc(&sk->sk_drops);
120485+ atomic_inc_unchecked(&sk->sk_drops);
120486 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
120487 IS_UDPLITE(sk));
120488 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
120489@@ -1823,6 +1844,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
120490 goto csum_error;
120491
120492 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
120493+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120494+ if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
120495+#endif
120496 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
120497
120498 /*
120499@@ -2427,7 +2451,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
120500 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
120501 0, sock_i_ino(sp),
120502 atomic_read(&sp->sk_refcnt), sp,
120503- atomic_read(&sp->sk_drops));
120504+ atomic_read_unchecked(&sp->sk_drops));
120505 }
120506
120507 int udp4_seq_show(struct seq_file *seq, void *v)
120508diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
120509index bff6974..c63736c 100644
120510--- a/net/ipv4/xfrm4_policy.c
120511+++ b/net/ipv4/xfrm4_policy.c
120512@@ -186,11 +186,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
120513 fl4->flowi4_tos = iph->tos;
120514 }
120515
120516-static inline int xfrm4_garbage_collect(struct dst_ops *ops)
120517+static int xfrm4_garbage_collect(struct dst_ops *ops)
120518 {
120519 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
120520
120521- xfrm4_policy_afinfo.garbage_collect(net);
120522+ xfrm_garbage_collect_deferred(net);
120523 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
120524 }
120525
120526@@ -268,19 +268,18 @@ static struct ctl_table xfrm4_policy_table[] = {
120527
120528 static int __net_init xfrm4_net_init(struct net *net)
120529 {
120530- struct ctl_table *table;
120531+ ctl_table_no_const *table = NULL;
120532 struct ctl_table_header *hdr;
120533
120534- table = xfrm4_policy_table;
120535 if (!net_eq(net, &init_net)) {
120536- table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
120537+ table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
120538 if (!table)
120539 goto err_alloc;
120540
120541 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
120542- }
120543-
120544- hdr = register_net_sysctl(net, "net/ipv4", table);
120545+ hdr = register_net_sysctl(net, "net/ipv4", table);
120546+ } else
120547+ hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
120548 if (!hdr)
120549 goto err_reg;
120550
120551@@ -288,8 +287,7 @@ static int __net_init xfrm4_net_init(struct net *net)
120552 return 0;
120553
120554 err_reg:
120555- if (!net_eq(net, &init_net))
120556- kfree(table);
120557+ kfree(table);
120558 err_alloc:
120559 return -ENOMEM;
120560 }
120561diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
120562index 21c2c81..373c1ba 100644
120563--- a/net/ipv6/addrconf.c
120564+++ b/net/ipv6/addrconf.c
120565@@ -178,7 +178,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
120566 .hop_limit = IPV6_DEFAULT_HOPLIMIT,
120567 .mtu6 = IPV6_MIN_MTU,
120568 .accept_ra = 1,
120569- .accept_redirects = 1,
120570+ .accept_redirects = 0,
120571 .autoconf = 1,
120572 .force_mld_version = 0,
120573 .mldv1_unsolicited_report_interval = 10 * HZ,
120574@@ -219,7 +219,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
120575 .hop_limit = IPV6_DEFAULT_HOPLIMIT,
120576 .mtu6 = IPV6_MIN_MTU,
120577 .accept_ra = 1,
120578- .accept_redirects = 1,
120579+ .accept_redirects = 0,
120580 .autoconf = 1,
120581 .force_mld_version = 0,
120582 .mldv1_unsolicited_report_interval = 10 * HZ,
120583@@ -620,7 +620,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
120584 idx = 0;
120585 head = &net->dev_index_head[h];
120586 rcu_read_lock();
120587- cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
120588+ cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
120589 net->dev_base_seq;
120590 hlist_for_each_entry_rcu(dev, head, index_hlist) {
120591 if (idx < s_idx)
120592@@ -2508,7 +2508,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
120593 p.iph.ihl = 5;
120594 p.iph.protocol = IPPROTO_IPV6;
120595 p.iph.ttl = 64;
120596- ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
120597+ ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
120598
120599 if (ops->ndo_do_ioctl) {
120600 mm_segment_t oldfs = get_fs();
120601@@ -3774,16 +3774,23 @@ static const struct file_operations if6_fops = {
120602 .release = seq_release_net,
120603 };
120604
120605+extern void register_ipv6_seq_ops_addr(struct seq_operations *addr);
120606+extern void unregister_ipv6_seq_ops_addr(void);
120607+
120608 static int __net_init if6_proc_net_init(struct net *net)
120609 {
120610- if (!proc_create("if_inet6", S_IRUGO, net->proc_net, &if6_fops))
120611+ register_ipv6_seq_ops_addr(&if6_seq_ops);
120612+ if (!proc_create("if_inet6", S_IRUGO, net->proc_net, &if6_fops)) {
120613+ unregister_ipv6_seq_ops_addr();
120614 return -ENOMEM;
120615+ }
120616 return 0;
120617 }
120618
120619 static void __net_exit if6_proc_net_exit(struct net *net)
120620 {
120621 remove_proc_entry("if_inet6", net->proc_net);
120622+ unregister_ipv6_seq_ops_addr();
120623 }
120624
120625 static struct pernet_operations if6_proc_net_ops = {
120626@@ -4402,7 +4409,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
120627 s_ip_idx = ip_idx = cb->args[2];
120628
120629 rcu_read_lock();
120630- cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
120631+ cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
120632 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
120633 idx = 0;
120634 head = &net->dev_index_head[h];
120635@@ -5059,7 +5066,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
120636 rt_genid_bump_ipv6(net);
120637 break;
120638 }
120639- atomic_inc(&net->ipv6.dev_addr_genid);
120640+ atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
120641 }
120642
120643 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
120644@@ -5079,7 +5086,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
120645 int *valp = ctl->data;
120646 int val = *valp;
120647 loff_t pos = *ppos;
120648- struct ctl_table lctl;
120649+ ctl_table_no_const lctl;
120650 int ret;
120651
120652 /*
120653@@ -5104,7 +5111,7 @@ int addrconf_sysctl_mtu(struct ctl_table *ctl, int write,
120654 {
120655 struct inet6_dev *idev = ctl->extra1;
120656 int min_mtu = IPV6_MIN_MTU;
120657- struct ctl_table lctl;
120658+ ctl_table_no_const lctl;
120659
120660 lctl = *ctl;
120661 lctl.extra1 = &min_mtu;
120662@@ -5179,7 +5186,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
120663 int *valp = ctl->data;
120664 int val = *valp;
120665 loff_t pos = *ppos;
120666- struct ctl_table lctl;
120667+ ctl_table_no_const lctl;
120668 int ret;
120669
120670 /*
120671@@ -5244,7 +5251,7 @@ static int addrconf_sysctl_stable_secret(struct ctl_table *ctl, int write,
120672 int err;
120673 struct in6_addr addr;
120674 char str[IPV6_MAX_STRLEN];
120675- struct ctl_table lctl = *ctl;
120676+ ctl_table_no_const lctl = *ctl;
120677 struct net *net = ctl->extra2;
120678 struct ipv6_stable_secret *secret = ctl->data;
120679
120680diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
120681index 7de52b6..ce7fb94 100644
120682--- a/net/ipv6/af_inet6.c
120683+++ b/net/ipv6/af_inet6.c
120684@@ -770,7 +770,7 @@ static int __net_init inet6_net_init(struct net *net)
120685 net->ipv6.sysctl.idgen_retries = 3;
120686 net->ipv6.sysctl.idgen_delay = 1 * HZ;
120687 net->ipv6.sysctl.flowlabel_state_ranges = 1;
120688- atomic_set(&net->ipv6.fib6_sernum, 1);
120689+ atomic_set_unchecked(&net->ipv6.fib6_sernum, 1);
120690
120691 err = ipv6_init_mibs(net);
120692 if (err)
120693diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
120694index b10a889..e881e1f 100644
120695--- a/net/ipv6/datagram.c
120696+++ b/net/ipv6/datagram.c
120697@@ -977,5 +977,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
120698 0,
120699 sock_i_ino(sp),
120700 atomic_read(&sp->sk_refcnt), sp,
120701- atomic_read(&sp->sk_drops));
120702+ atomic_read_unchecked(&sp->sk_drops));
120703 }
120704diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
120705index 713d743..8eec687 100644
120706--- a/net/ipv6/icmp.c
120707+++ b/net/ipv6/icmp.c
120708@@ -1004,7 +1004,7 @@ static struct ctl_table ipv6_icmp_table_template[] = {
120709
120710 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
120711 {
120712- struct ctl_table *table;
120713+ ctl_table_no_const *table;
120714
120715 table = kmemdup(ipv6_icmp_table_template,
120716 sizeof(ipv6_icmp_table_template),
120717diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
120718index 548c623..bc8ec4f 100644
120719--- a/net/ipv6/ip6_fib.c
120720+++ b/net/ipv6/ip6_fib.c
120721@@ -99,9 +99,9 @@ static int fib6_new_sernum(struct net *net)
120722 int new, old;
120723
120724 do {
120725- old = atomic_read(&net->ipv6.fib6_sernum);
120726+ old = atomic_read_unchecked(&net->ipv6.fib6_sernum);
120727 new = old < INT_MAX ? old + 1 : 1;
120728- } while (atomic_cmpxchg(&net->ipv6.fib6_sernum,
120729+ } while (atomic_cmpxchg_unchecked(&net->ipv6.fib6_sernum,
120730 old, new) != old);
120731 return new;
120732 }
120733diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
120734index 69f4f68..1f97524 100644
120735--- a/net/ipv6/ip6_gre.c
120736+++ b/net/ipv6/ip6_gre.c
120737@@ -71,8 +71,8 @@ struct ip6gre_net {
120738 struct net_device *fb_tunnel_dev;
120739 };
120740
120741-static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
120742-static struct rtnl_link_ops ip6gre_tap_ops __read_mostly;
120743+static struct rtnl_link_ops ip6gre_link_ops;
120744+static struct rtnl_link_ops ip6gre_tap_ops;
120745 static int ip6gre_tunnel_init(struct net_device *dev);
120746 static void ip6gre_tunnel_setup(struct net_device *dev);
120747 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
120748@@ -1281,7 +1281,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
120749 }
120750
120751
120752-static struct inet6_protocol ip6gre_protocol __read_mostly = {
120753+static struct inet6_protocol ip6gre_protocol = {
120754 .handler = ip6gre_rcv,
120755 .err_handler = ip6gre_err,
120756 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
120757@@ -1640,7 +1640,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
120758 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
120759 };
120760
120761-static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
120762+static struct rtnl_link_ops ip6gre_link_ops = {
120763 .kind = "ip6gre",
120764 .maxtype = IFLA_GRE_MAX,
120765 .policy = ip6gre_policy,
120766@@ -1655,7 +1655,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
120767 .get_link_net = ip6_tnl_get_link_net,
120768 };
120769
120770-static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
120771+static struct rtnl_link_ops ip6gre_tap_ops = {
120772 .kind = "ip6gretap",
120773 .maxtype = IFLA_GRE_MAX,
120774 .policy = ip6gre_policy,
120775diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
120776index d5f7716..b4b3821 100644
120777--- a/net/ipv6/ip6_output.c
120778+++ b/net/ipv6/ip6_output.c
120779@@ -28,6 +28,7 @@
120780
120781 #include <linux/errno.h>
120782 #include <linux/kernel.h>
120783+#include <linux/overflow-arith.h>
120784 #include <linux/string.h>
120785 #include <linux/socket.h>
120786 #include <linux/net.h>
120787@@ -581,7 +582,10 @@ int ip6_fragment(struct sock *sk, struct sk_buff *skb,
120788 if (np->frag_size)
120789 mtu = np->frag_size;
120790 }
120791- mtu -= hlen + sizeof(struct frag_hdr);
120792+
120793+ if (overflow_usub(mtu, hlen + sizeof(struct frag_hdr), &mtu) ||
120794+ mtu <= 7)
120795+ goto fail_toobig;
120796
120797 frag_id = ipv6_select_ident(net, &ipv6_hdr(skb)->daddr,
120798 &ipv6_hdr(skb)->saddr);
120799diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
120800index 2e67b66..b816b34 100644
120801--- a/net/ipv6/ip6_tunnel.c
120802+++ b/net/ipv6/ip6_tunnel.c
120803@@ -80,7 +80,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
120804
120805 static int ip6_tnl_dev_init(struct net_device *dev);
120806 static void ip6_tnl_dev_setup(struct net_device *dev);
120807-static struct rtnl_link_ops ip6_link_ops __read_mostly;
120808+static struct rtnl_link_ops ip6_link_ops;
120809
120810 static int ip6_tnl_net_id __read_mostly;
120811 struct ip6_tnl_net {
120812@@ -1776,7 +1776,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
120813 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
120814 };
120815
120816-static struct rtnl_link_ops ip6_link_ops __read_mostly = {
120817+static struct rtnl_link_ops ip6_link_ops = {
120818 .kind = "ip6tnl",
120819 .maxtype = IFLA_IPTUN_MAX,
120820 .policy = ip6_tnl_policy,
120821diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
120822index 0224c03..c5ec3d9 100644
120823--- a/net/ipv6/ip6_vti.c
120824+++ b/net/ipv6/ip6_vti.c
120825@@ -62,7 +62,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
120826
120827 static int vti6_dev_init(struct net_device *dev);
120828 static void vti6_dev_setup(struct net_device *dev);
120829-static struct rtnl_link_ops vti6_link_ops __read_mostly;
120830+static struct rtnl_link_ops vti6_link_ops;
120831
120832 static int vti6_net_id __read_mostly;
120833 struct vti6_net {
120834@@ -1019,7 +1019,7 @@ static const struct nla_policy vti6_policy[IFLA_VTI_MAX + 1] = {
120835 [IFLA_VTI_OKEY] = { .type = NLA_U32 },
120836 };
120837
120838-static struct rtnl_link_ops vti6_link_ops __read_mostly = {
120839+static struct rtnl_link_ops vti6_link_ops = {
120840 .kind = "vti6",
120841 .maxtype = IFLA_VTI_MAX,
120842 .policy = vti6_policy,
120843diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
120844index 63e6956..ebbbcf6 100644
120845--- a/net/ipv6/ipv6_sockglue.c
120846+++ b/net/ipv6/ipv6_sockglue.c
120847@@ -1015,7 +1015,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
120848 if (sk->sk_type != SOCK_STREAM)
120849 return -ENOPROTOOPT;
120850
120851- msg.msg_control = optval;
120852+ msg.msg_control = (void __force_kernel *)optval;
120853 msg.msg_controllen = len;
120854 msg.msg_flags = flags;
120855
120856diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
120857index 3c35ced..2e6882f 100644
120858--- a/net/ipv6/netfilter/ip6_tables.c
120859+++ b/net/ipv6/netfilter/ip6_tables.c
120860@@ -1086,14 +1086,14 @@ static int compat_table_info(const struct xt_table_info *info,
120861 #endif
120862
120863 static int get_info(struct net *net, void __user *user,
120864- const int *len, int compat)
120865+ int len, int compat)
120866 {
120867 char name[XT_TABLE_MAXNAMELEN];
120868 struct xt_table *t;
120869 int ret;
120870
120871- if (*len != sizeof(struct ip6t_getinfo)) {
120872- duprintf("length %u != %zu\n", *len,
120873+ if (len != sizeof(struct ip6t_getinfo)) {
120874+ duprintf("length %u != %zu\n", len,
120875 sizeof(struct ip6t_getinfo));
120876 return -EINVAL;
120877 }
120878@@ -1130,7 +1130,7 @@ static int get_info(struct net *net, void __user *user,
120879 info.size = private->size;
120880 strcpy(info.name, name);
120881
120882- if (copy_to_user(user, &info, *len) != 0)
120883+ if (copy_to_user(user, &info, len) != 0)
120884 ret = -EFAULT;
120885 else
120886 ret = 0;
120887@@ -1978,7 +1978,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
120888
120889 switch (cmd) {
120890 case IP6T_SO_GET_INFO:
120891- ret = get_info(sock_net(sk), user, len, 1);
120892+ ret = get_info(sock_net(sk), user, *len, 1);
120893 break;
120894 case IP6T_SO_GET_ENTRIES:
120895 ret = compat_get_entries(sock_net(sk), user, len);
120896@@ -2025,7 +2025,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
120897
120898 switch (cmd) {
120899 case IP6T_SO_GET_INFO:
120900- ret = get_info(sock_net(sk), user, len, 0);
120901+ ret = get_info(sock_net(sk), user, *len, 0);
120902 break;
120903
120904 case IP6T_SO_GET_ENTRIES:
120905diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
120906index 6d02498..55e564f 100644
120907--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
120908+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
120909@@ -96,12 +96,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
120910
120911 static int nf_ct_frag6_sysctl_register(struct net *net)
120912 {
120913- struct ctl_table *table;
120914+ ctl_table_no_const *table = NULL;
120915 struct ctl_table_header *hdr;
120916
120917- table = nf_ct_frag6_sysctl_table;
120918 if (!net_eq(net, &init_net)) {
120919- table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
120920+ table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
120921 GFP_KERNEL);
120922 if (table == NULL)
120923 goto err_alloc;
120924@@ -112,9 +111,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
120925 table[2].data = &net->nf_frag.frags.high_thresh;
120926 table[2].extra1 = &net->nf_frag.frags.low_thresh;
120927 table[2].extra2 = &init_net.nf_frag.frags.high_thresh;
120928- }
120929-
120930- hdr = register_net_sysctl(net, "net/netfilter", table);
120931+ hdr = register_net_sysctl(net, "net/netfilter", table);
120932+ } else
120933+ hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
120934 if (hdr == NULL)
120935 goto err_reg;
120936
120937@@ -122,8 +121,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
120938 return 0;
120939
120940 err_reg:
120941- if (!net_eq(net, &init_net))
120942- kfree(table);
120943+ kfree(table);
120944 err_alloc:
120945 return -ENOMEM;
120946 }
120947diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
120948index 263a516..692f738 100644
120949--- a/net/ipv6/ping.c
120950+++ b/net/ipv6/ping.c
120951@@ -240,6 +240,24 @@ static struct pernet_operations ping_v6_net_ops = {
120952 };
120953 #endif
120954
120955+static struct pingv6_ops real_pingv6_ops = {
120956+ .ipv6_recv_error = ipv6_recv_error,
120957+ .ip6_datagram_recv_common_ctl = ip6_datagram_recv_common_ctl,
120958+ .ip6_datagram_recv_specific_ctl = ip6_datagram_recv_specific_ctl,
120959+ .icmpv6_err_convert = icmpv6_err_convert,
120960+ .ipv6_icmp_error = ipv6_icmp_error,
120961+ .ipv6_chk_addr = ipv6_chk_addr,
120962+};
120963+
120964+static struct pingv6_ops dummy_pingv6_ops = {
120965+ .ipv6_recv_error = dummy_ipv6_recv_error,
120966+ .ip6_datagram_recv_common_ctl = dummy_ip6_datagram_recv_ctl,
120967+ .ip6_datagram_recv_specific_ctl = dummy_ip6_datagram_recv_ctl,
120968+ .icmpv6_err_convert = dummy_icmpv6_err_convert,
120969+ .ipv6_icmp_error = dummy_ipv6_icmp_error,
120970+ .ipv6_chk_addr = dummy_ipv6_chk_addr,
120971+};
120972+
120973 int __init pingv6_init(void)
120974 {
120975 #ifdef CONFIG_PROC_FS
120976@@ -247,13 +265,7 @@ int __init pingv6_init(void)
120977 if (ret)
120978 return ret;
120979 #endif
120980- pingv6_ops.ipv6_recv_error = ipv6_recv_error;
120981- pingv6_ops.ip6_datagram_recv_common_ctl = ip6_datagram_recv_common_ctl;
120982- pingv6_ops.ip6_datagram_recv_specific_ctl =
120983- ip6_datagram_recv_specific_ctl;
120984- pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
120985- pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
120986- pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
120987+ pingv6_ops = &real_pingv6_ops;
120988 return inet6_register_protosw(&pingv6_protosw);
120989 }
120990
120991@@ -262,14 +274,9 @@ int __init pingv6_init(void)
120992 */
120993 void pingv6_exit(void)
120994 {
120995- pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
120996- pingv6_ops.ip6_datagram_recv_common_ctl = dummy_ip6_datagram_recv_ctl;
120997- pingv6_ops.ip6_datagram_recv_specific_ctl = dummy_ip6_datagram_recv_ctl;
120998- pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
120999- pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
121000- pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
121001 #ifdef CONFIG_PROC_FS
121002 unregister_pernet_subsys(&ping_v6_net_ops);
121003 #endif
121004+ pingv6_ops = &dummy_pingv6_ops;
121005 inet6_unregister_protosw(&pingv6_protosw);
121006 }
121007diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
121008index 679253d0..70b653c 100644
121009--- a/net/ipv6/proc.c
121010+++ b/net/ipv6/proc.c
121011@@ -310,7 +310,7 @@ static int __net_init ipv6_proc_init_net(struct net *net)
121012 if (!proc_create("snmp6", S_IRUGO, net->proc_net, &snmp6_seq_fops))
121013 goto proc_snmp6_fail;
121014
121015- net->mib.proc_net_devsnmp6 = proc_mkdir("dev_snmp6", net->proc_net);
121016+ net->mib.proc_net_devsnmp6 = proc_mkdir_restrict("dev_snmp6", net->proc_net);
121017 if (!net->mib.proc_net_devsnmp6)
121018 goto proc_dev_snmp6_fail;
121019 return 0;
121020diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
121021index ca4700c..e44c0f9 100644
121022--- a/net/ipv6/raw.c
121023+++ b/net/ipv6/raw.c
121024@@ -388,7 +388,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
121025 {
121026 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
121027 skb_checksum_complete(skb)) {
121028- atomic_inc(&sk->sk_drops);
121029+ atomic_inc_unchecked(&sk->sk_drops);
121030 kfree_skb(skb);
121031 return NET_RX_DROP;
121032 }
121033@@ -416,7 +416,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
121034 struct raw6_sock *rp = raw6_sk(sk);
121035
121036 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
121037- atomic_inc(&sk->sk_drops);
121038+ atomic_inc_unchecked(&sk->sk_drops);
121039 kfree_skb(skb);
121040 return NET_RX_DROP;
121041 }
121042@@ -440,7 +440,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
121043
121044 if (inet->hdrincl) {
121045 if (skb_checksum_complete(skb)) {
121046- atomic_inc(&sk->sk_drops);
121047+ atomic_inc_unchecked(&sk->sk_drops);
121048 kfree_skb(skb);
121049 return NET_RX_DROP;
121050 }
121051@@ -608,7 +608,7 @@ out:
121052 return err;
121053 }
121054
121055-static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
121056+static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, unsigned int length,
121057 struct flowi6 *fl6, struct dst_entry **dstp,
121058 unsigned int flags)
121059 {
121060@@ -916,12 +916,15 @@ do_confirm:
121061 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
121062 char __user *optval, int optlen)
121063 {
121064+ struct icmp6_filter filter;
121065+
121066 switch (optname) {
121067 case ICMPV6_FILTER:
121068 if (optlen > sizeof(struct icmp6_filter))
121069 optlen = sizeof(struct icmp6_filter);
121070- if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
121071+ if (copy_from_user(&filter, optval, optlen))
121072 return -EFAULT;
121073+ raw6_sk(sk)->filter = filter;
121074 return 0;
121075 default:
121076 return -ENOPROTOOPT;
121077@@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
121078 char __user *optval, int __user *optlen)
121079 {
121080 int len;
121081+ struct icmp6_filter filter;
121082
121083 switch (optname) {
121084 case ICMPV6_FILTER:
121085@@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
121086 len = sizeof(struct icmp6_filter);
121087 if (put_user(len, optlen))
121088 return -EFAULT;
121089- if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
121090+ filter = raw6_sk(sk)->filter;
121091+ if (len > sizeof filter || copy_to_user(optval, &filter, len))
121092 return -EFAULT;
121093 return 0;
121094 default:
121095diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
121096index f1159bb..0db5dad 100644
121097--- a/net/ipv6/reassembly.c
121098+++ b/net/ipv6/reassembly.c
121099@@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
121100
121101 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
121102 {
121103- struct ctl_table *table;
121104+ ctl_table_no_const *table = NULL;
121105 struct ctl_table_header *hdr;
121106
121107- table = ip6_frags_ns_ctl_table;
121108 if (!net_eq(net, &init_net)) {
121109- table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
121110+ table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
121111 if (!table)
121112 goto err_alloc;
121113
121114@@ -645,9 +644,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
121115 /* Don't export sysctls to unprivileged users */
121116 if (net->user_ns != &init_user_ns)
121117 table[0].procname = NULL;
121118- }
121119+ hdr = register_net_sysctl(net, "net/ipv6", table);
121120+ } else
121121+ hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
121122
121123- hdr = register_net_sysctl(net, "net/ipv6", table);
121124 if (!hdr)
121125 goto err_reg;
121126
121127@@ -655,8 +655,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
121128 return 0;
121129
121130 err_reg:
121131- if (!net_eq(net, &init_net))
121132- kfree(table);
121133+ kfree(table);
121134 err_alloc:
121135 return -ENOMEM;
121136 }
121137diff --git a/net/ipv6/route.c b/net/ipv6/route.c
121138index dd6ebba..69d56e8 100644
121139--- a/net/ipv6/route.c
121140+++ b/net/ipv6/route.c
121141@@ -3432,7 +3432,7 @@ struct ctl_table ipv6_route_table_template[] = {
121142
121143 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
121144 {
121145- struct ctl_table *table;
121146+ ctl_table_no_const *table;
121147
121148 table = kmemdup(ipv6_route_table_template,
121149 sizeof(ipv6_route_table_template),
121150diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
121151index ac35a28..070cc8c 100644
121152--- a/net/ipv6/sit.c
121153+++ b/net/ipv6/sit.c
121154@@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
121155 static void ipip6_dev_free(struct net_device *dev);
121156 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
121157 __be32 *v4dst);
121158-static struct rtnl_link_ops sit_link_ops __read_mostly;
121159+static struct rtnl_link_ops sit_link_ops;
121160
121161 static int sit_net_id __read_mostly;
121162 struct sit_net {
121163@@ -1749,7 +1749,7 @@ static void ipip6_dellink(struct net_device *dev, struct list_head *head)
121164 unregister_netdevice_queue(dev, head);
121165 }
121166
121167-static struct rtnl_link_ops sit_link_ops __read_mostly = {
121168+static struct rtnl_link_ops sit_link_ops = {
121169 .kind = "sit",
121170 .maxtype = IFLA_IPTUN_MAX,
121171 .policy = ipip6_policy,
121172diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
121173index 4e705ad..9ba8db8 100644
121174--- a/net/ipv6/sysctl_net_ipv6.c
121175+++ b/net/ipv6/sysctl_net_ipv6.c
121176@@ -99,7 +99,7 @@ static struct ctl_table ipv6_rotable[] = {
121177
121178 static int __net_init ipv6_sysctl_net_init(struct net *net)
121179 {
121180- struct ctl_table *ipv6_table;
121181+ ctl_table_no_const *ipv6_table;
121182 struct ctl_table *ipv6_route_table;
121183 struct ctl_table *ipv6_icmp_table;
121184 int err;
121185diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
121186index 7a6cea5..1a99e26 100644
121187--- a/net/ipv6/tcp_ipv6.c
121188+++ b/net/ipv6/tcp_ipv6.c
121189@@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
121190 }
121191 }
121192
121193+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121194+extern int grsec_enable_blackhole;
121195+#endif
121196+
121197 static __u32 tcp_v6_init_sequence(const struct sk_buff *skb)
121198 {
121199 return secure_tcpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,
121200@@ -1280,6 +1284,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
121201 return 0;
121202
121203 reset:
121204+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121205+ if (!grsec_enable_blackhole)
121206+#endif
121207 tcp_v6_send_reset(sk, skb);
121208 discard:
121209 if (opt_skb)
121210@@ -1389,12 +1396,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
121211
121212 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest,
121213 inet6_iif(skb));
121214- if (!sk)
121215+ if (!sk) {
121216+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121217+ ret = 1;
121218+#endif
121219 goto no_tcp_socket;
121220+ }
121221
121222 process:
121223- if (sk->sk_state == TCP_TIME_WAIT)
121224+ if (sk->sk_state == TCP_TIME_WAIT) {
121225+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121226+ ret = 2;
121227+#endif
121228 goto do_time_wait;
121229+ }
121230
121231 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
121232 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
121233@@ -1446,6 +1461,10 @@ csum_error:
121234 bad_packet:
121235 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
121236 } else {
121237+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121238+ if (!grsec_enable_blackhole || (ret == 1 &&
121239+ (skb->dev->flags & IFF_LOOPBACK)))
121240+#endif
121241 tcp_v6_send_reset(NULL, skb);
121242 }
121243
121244diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
121245index e51fc3e..8f04229 100644
121246--- a/net/ipv6/udp.c
121247+++ b/net/ipv6/udp.c
121248@@ -76,6 +76,10 @@ static u32 udp6_ehashfn(const struct net *net,
121249 udp_ipv6_hash_secret + net_hash_mix(net));
121250 }
121251
121252+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121253+extern int grsec_enable_blackhole;
121254+#endif
121255+
121256 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
121257 {
121258 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
121259@@ -445,7 +449,7 @@ try_again:
121260 if (unlikely(err)) {
121261 trace_kfree_skb(skb, udpv6_recvmsg);
121262 if (!peeked) {
121263- atomic_inc(&sk->sk_drops);
121264+ atomic_inc_unchecked(&sk->sk_drops);
121265 if (is_udp4)
121266 UDP_INC_STATS_USER(sock_net(sk),
121267 UDP_MIB_INERRORS,
121268@@ -709,7 +713,7 @@ csum_error:
121269 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
121270 drop:
121271 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
121272- atomic_inc(&sk->sk_drops);
121273+ atomic_inc_unchecked(&sk->sk_drops);
121274 kfree_skb(skb);
121275 return -1;
121276 }
121277@@ -750,7 +754,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
121278 if (likely(!skb1))
121279 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
121280 if (!skb1) {
121281- atomic_inc(&sk->sk_drops);
121282+ atomic_inc_unchecked(&sk->sk_drops);
121283 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
121284 IS_UDPLITE(sk));
121285 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
121286@@ -934,6 +938,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
121287 goto csum_error;
121288
121289 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
121290+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
121291+ if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
121292+#endif
121293 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
121294
121295 kfree_skb(skb);
121296diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
121297index ed0583c..606962a 100644
121298--- a/net/ipv6/xfrm6_policy.c
121299+++ b/net/ipv6/xfrm6_policy.c
121300@@ -174,7 +174,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
121301 return;
121302
121303 case IPPROTO_ICMPV6:
121304- if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) {
121305+ if (!onlyproto && (nh + offset + 2 < skb->data ||
121306+ pskb_may_pull(skb, nh + offset + 2 - skb->data))) {
121307 u8 *icmp;
121308
121309 nh = skb_network_header(skb);
121310@@ -188,7 +189,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
121311 #if IS_ENABLED(CONFIG_IPV6_MIP6)
121312 case IPPROTO_MH:
121313 offset += ipv6_optlen(exthdr);
121314- if (!onlyproto && pskb_may_pull(skb, nh + offset + 3 - skb->data)) {
121315+ if (!onlyproto && (nh + offset + 3 < skb->data ||
121316+ pskb_may_pull(skb, nh + offset + 3 - skb->data))) {
121317 struct ip6_mh *mh;
121318
121319 nh = skb_network_header(skb);
121320@@ -211,11 +213,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
121321 }
121322 }
121323
121324-static inline int xfrm6_garbage_collect(struct dst_ops *ops)
121325+static int xfrm6_garbage_collect(struct dst_ops *ops)
121326 {
121327 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
121328
121329- xfrm6_policy_afinfo.garbage_collect(net);
121330+ xfrm_garbage_collect_deferred(net);
121331 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
121332 }
121333
121334@@ -322,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
121335
121336 static int __net_init xfrm6_net_init(struct net *net)
121337 {
121338- struct ctl_table *table;
121339+ ctl_table_no_const *table = NULL;
121340 struct ctl_table_header *hdr;
121341
121342- table = xfrm6_policy_table;
121343 if (!net_eq(net, &init_net)) {
121344- table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
121345+ table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
121346 if (!table)
121347 goto err_alloc;
121348
121349 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
121350- }
121351+ hdr = register_net_sysctl(net, "net/ipv6", table);
121352+ } else
121353+ hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
121354
121355- hdr = register_net_sysctl(net, "net/ipv6", table);
121356 if (!hdr)
121357 goto err_reg;
121358
121359@@ -342,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
121360 return 0;
121361
121362 err_reg:
121363- if (!net_eq(net, &init_net))
121364- kfree(table);
121365+ kfree(table);
121366 err_alloc:
121367 return -ENOMEM;
121368 }
121369diff --git a/net/ipx/ipx_proc.c b/net/ipx/ipx_proc.c
121370index c1d247e..9e5949d 100644
121371--- a/net/ipx/ipx_proc.c
121372+++ b/net/ipx/ipx_proc.c
121373@@ -289,7 +289,7 @@ int __init ipx_proc_init(void)
121374 struct proc_dir_entry *p;
121375 int rc = -ENOMEM;
121376
121377- ipx_proc_dir = proc_mkdir("ipx", init_net.proc_net);
121378+ ipx_proc_dir = proc_mkdir_restrict("ipx", init_net.proc_net);
121379
121380 if (!ipx_proc_dir)
121381 goto out;
121382diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
121383index 683346d..cb0e12d 100644
121384--- a/net/irda/ircomm/ircomm_tty.c
121385+++ b/net/irda/ircomm/ircomm_tty.c
121386@@ -310,10 +310,10 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
121387 add_wait_queue(&port->open_wait, &wait);
121388
121389 pr_debug("%s(%d):block_til_ready before block on %s open_count=%d\n",
121390- __FILE__, __LINE__, tty->driver->name, port->count);
121391+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
121392
121393 spin_lock_irqsave(&port->lock, flags);
121394- port->count--;
121395+ atomic_dec(&port->count);
121396 port->blocked_open++;
121397 spin_unlock_irqrestore(&port->lock, flags);
121398
121399@@ -348,7 +348,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
121400 }
121401
121402 pr_debug("%s(%d):block_til_ready blocking on %s open_count=%d\n",
121403- __FILE__, __LINE__, tty->driver->name, port->count);
121404+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
121405
121406 schedule();
121407 }
121408@@ -358,12 +358,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
121409
121410 spin_lock_irqsave(&port->lock, flags);
121411 if (!tty_hung_up_p(filp))
121412- port->count++;
121413+ atomic_inc(&port->count);
121414 port->blocked_open--;
121415 spin_unlock_irqrestore(&port->lock, flags);
121416
121417 pr_debug("%s(%d):block_til_ready after blocking on %s open_count=%d\n",
121418- __FILE__, __LINE__, tty->driver->name, port->count);
121419+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
121420
121421 if (!retval)
121422 port->flags |= ASYNC_NORMAL_ACTIVE;
121423@@ -433,12 +433,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
121424
121425 /* ++ is not atomic, so this should be protected - Jean II */
121426 spin_lock_irqsave(&self->port.lock, flags);
121427- self->port.count++;
121428+ atomic_inc(&self->port.count);
121429 spin_unlock_irqrestore(&self->port.lock, flags);
121430 tty_port_tty_set(&self->port, tty);
121431
121432 pr_debug("%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
121433- self->line, self->port.count);
121434+ self->line, atomic_read(&self->port.count));
121435
121436 /* Not really used by us, but lets do it anyway */
121437 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
121438@@ -961,7 +961,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
121439 tty_kref_put(port->tty);
121440 }
121441 port->tty = NULL;
121442- port->count = 0;
121443+ atomic_set(&port->count, 0);
121444 spin_unlock_irqrestore(&port->lock, flags);
121445
121446 wake_up_interruptible(&port->open_wait);
121447@@ -1308,7 +1308,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
121448 seq_putc(m, '\n');
121449
121450 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
121451- seq_printf(m, "Open count: %d\n", self->port.count);
121452+ seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
121453 seq_printf(m, "Max data size: %d\n", self->max_data_size);
121454 seq_printf(m, "Max header size: %d\n", self->max_header_size);
121455
121456diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
121457index a26c401..4396459 100644
121458--- a/net/irda/irlmp.c
121459+++ b/net/irda/irlmp.c
121460@@ -1839,7 +1839,7 @@ static void *irlmp_seq_hb_idx(struct irlmp_iter_state *iter, loff_t *off)
121461 for (element = hashbin_get_first(iter->hashbin);
121462 element != NULL;
121463 element = hashbin_get_next(iter->hashbin)) {
121464- if (!off || *off-- == 0) {
121465+ if (!off || (*off)-- == 0) {
121466 /* NB: hashbin left locked */
121467 return element;
121468 }
121469diff --git a/net/irda/irproc.c b/net/irda/irproc.c
121470index b9ac598..f88cc56 100644
121471--- a/net/irda/irproc.c
121472+++ b/net/irda/irproc.c
121473@@ -66,7 +66,7 @@ void __init irda_proc_register(void)
121474 {
121475 int i;
121476
121477- proc_irda = proc_mkdir("irda", init_net.proc_net);
121478+ proc_irda = proc_mkdir_restrict("irda", init_net.proc_net);
121479 if (proc_irda == NULL)
121480 return;
121481
121482diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
121483index 918151c..5bbe95a 100644
121484--- a/net/iucv/af_iucv.c
121485+++ b/net/iucv/af_iucv.c
121486@@ -686,10 +686,10 @@ static void __iucv_auto_name(struct iucv_sock *iucv)
121487 {
121488 char name[12];
121489
121490- sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
121491+ sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
121492 while (__iucv_get_sock_by_name(name)) {
121493 sprintf(name, "%08x",
121494- atomic_inc_return(&iucv_sk_list.autobind_name));
121495+ atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
121496 }
121497 memcpy(iucv->src_name, name, 8);
121498 }
121499diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
121500index 2a6a1fd..6c112b0 100644
121501--- a/net/iucv/iucv.c
121502+++ b/net/iucv/iucv.c
121503@@ -702,7 +702,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
121504 return NOTIFY_OK;
121505 }
121506
121507-static struct notifier_block __refdata iucv_cpu_notifier = {
121508+static struct notifier_block iucv_cpu_notifier = {
121509 .notifier_call = iucv_cpu_notify,
121510 };
121511
121512diff --git a/net/key/af_key.c b/net/key/af_key.c
121513index 83a7068..facf2f0 100644
121514--- a/net/key/af_key.c
121515+++ b/net/key/af_key.c
121516@@ -3050,10 +3050,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
121517 static u32 get_acqseq(void)
121518 {
121519 u32 res;
121520- static atomic_t acqseq;
121521+ static atomic_unchecked_t acqseq;
121522
121523 do {
121524- res = atomic_inc_return(&acqseq);
121525+ res = atomic_inc_return_unchecked(&acqseq);
121526 } while (!res);
121527 return res;
121528 }
121529diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
121530index 4b55287..bd247f7 100644
121531--- a/net/l2tp/l2tp_eth.c
121532+++ b/net/l2tp/l2tp_eth.c
121533@@ -42,12 +42,12 @@ struct l2tp_eth {
121534 struct sock *tunnel_sock;
121535 struct l2tp_session *session;
121536 struct list_head list;
121537- atomic_long_t tx_bytes;
121538- atomic_long_t tx_packets;
121539- atomic_long_t tx_dropped;
121540- atomic_long_t rx_bytes;
121541- atomic_long_t rx_packets;
121542- atomic_long_t rx_errors;
121543+ atomic_long_unchecked_t tx_bytes;
121544+ atomic_long_unchecked_t tx_packets;
121545+ atomic_long_unchecked_t tx_dropped;
121546+ atomic_long_unchecked_t rx_bytes;
121547+ atomic_long_unchecked_t rx_packets;
121548+ atomic_long_unchecked_t rx_errors;
121549 };
121550
121551 /* via l2tp_session_priv() */
121552@@ -98,10 +98,10 @@ static int l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev)
121553 int ret = l2tp_xmit_skb(session, skb, session->hdr_len);
121554
121555 if (likely(ret == NET_XMIT_SUCCESS)) {
121556- atomic_long_add(len, &priv->tx_bytes);
121557- atomic_long_inc(&priv->tx_packets);
121558+ atomic_long_add_unchecked(len, &priv->tx_bytes);
121559+ atomic_long_inc_unchecked(&priv->tx_packets);
121560 } else {
121561- atomic_long_inc(&priv->tx_dropped);
121562+ atomic_long_inc_unchecked(&priv->tx_dropped);
121563 }
121564 return NETDEV_TX_OK;
121565 }
121566@@ -111,12 +111,12 @@ static struct rtnl_link_stats64 *l2tp_eth_get_stats64(struct net_device *dev,
121567 {
121568 struct l2tp_eth *priv = netdev_priv(dev);
121569
121570- stats->tx_bytes = atomic_long_read(&priv->tx_bytes);
121571- stats->tx_packets = atomic_long_read(&priv->tx_packets);
121572- stats->tx_dropped = atomic_long_read(&priv->tx_dropped);
121573- stats->rx_bytes = atomic_long_read(&priv->rx_bytes);
121574- stats->rx_packets = atomic_long_read(&priv->rx_packets);
121575- stats->rx_errors = atomic_long_read(&priv->rx_errors);
121576+ stats->tx_bytes = atomic_long_read_unchecked(&priv->tx_bytes);
121577+ stats->tx_packets = atomic_long_read_unchecked(&priv->tx_packets);
121578+ stats->tx_dropped = atomic_long_read_unchecked(&priv->tx_dropped);
121579+ stats->rx_bytes = atomic_long_read_unchecked(&priv->rx_bytes);
121580+ stats->rx_packets = atomic_long_read_unchecked(&priv->rx_packets);
121581+ stats->rx_errors = atomic_long_read_unchecked(&priv->rx_errors);
121582 return stats;
121583 }
121584
121585@@ -167,15 +167,15 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb,
121586 nf_reset(skb);
121587
121588 if (dev_forward_skb(dev, skb) == NET_RX_SUCCESS) {
121589- atomic_long_inc(&priv->rx_packets);
121590- atomic_long_add(data_len, &priv->rx_bytes);
121591+ atomic_long_inc_unchecked(&priv->rx_packets);
121592+ atomic_long_add_unchecked(data_len, &priv->rx_bytes);
121593 } else {
121594- atomic_long_inc(&priv->rx_errors);
121595+ atomic_long_inc_unchecked(&priv->rx_errors);
121596 }
121597 return;
121598
121599 error:
121600- atomic_long_inc(&priv->rx_errors);
121601+ atomic_long_inc_unchecked(&priv->rx_errors);
121602 kfree_skb(skb);
121603 }
121604
121605diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
121606index 7964993..2c48a3a 100644
121607--- a/net/l2tp/l2tp_ip.c
121608+++ b/net/l2tp/l2tp_ip.c
121609@@ -608,7 +608,7 @@ static struct inet_protosw l2tp_ip_protosw = {
121610 .ops = &l2tp_ip_ops,
121611 };
121612
121613-static struct net_protocol l2tp_ip_protocol __read_mostly = {
121614+static const struct net_protocol l2tp_ip_protocol = {
121615 .handler = l2tp_ip_recv,
121616 .netns_ok = 1,
121617 };
121618diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
121619index d1ded37..c0d1e49 100644
121620--- a/net/l2tp/l2tp_ip6.c
121621+++ b/net/l2tp/l2tp_ip6.c
121622@@ -755,7 +755,7 @@ static struct inet_protosw l2tp_ip6_protosw = {
121623 .ops = &l2tp_ip6_ops,
121624 };
121625
121626-static struct inet6_protocol l2tp_ip6_protocol __read_mostly = {
121627+static const struct inet6_protocol l2tp_ip6_protocol = {
121628 .handler = l2tp_ip6_recv,
121629 };
121630
121631diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
121632index 1a3c7e0..80f8b0c 100644
121633--- a/net/llc/llc_proc.c
121634+++ b/net/llc/llc_proc.c
121635@@ -247,7 +247,7 @@ int __init llc_proc_init(void)
121636 int rc = -ENOMEM;
121637 struct proc_dir_entry *p;
121638
121639- llc_proc_dir = proc_mkdir("llc", init_net.proc_net);
121640+ llc_proc_dir = proc_mkdir_restrict("llc", init_net.proc_net);
121641 if (!llc_proc_dir)
121642 goto out;
121643
121644diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
121645index bf7023f..86a5bc6 100644
121646--- a/net/mac80211/cfg.c
121647+++ b/net/mac80211/cfg.c
121648@@ -580,7 +580,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
121649 ret = ieee80211_vif_use_channel(sdata, chandef,
121650 IEEE80211_CHANCTX_EXCLUSIVE);
121651 }
121652- } else if (local->open_count == local->monitors) {
121653+ } else if (local_read(&local->open_count) == local->monitors) {
121654 local->_oper_chandef = *chandef;
121655 ieee80211_hw_config(local, 0);
121656 }
121657@@ -3488,7 +3488,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
121658 else
121659 local->probe_req_reg--;
121660
121661- if (!local->open_count)
121662+ if (!local_read(&local->open_count))
121663 break;
121664
121665 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
121666@@ -3637,8 +3637,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
121667 if (chanctx_conf) {
121668 *chandef = sdata->vif.bss_conf.chandef;
121669 ret = 0;
121670- } else if (local->open_count > 0 &&
121671- local->open_count == local->monitors &&
121672+ } else if (local_read(&local->open_count) > 0 &&
121673+ local_read(&local->open_count) == local->monitors &&
121674 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
121675 if (local->use_chanctx)
121676 *chandef = local->monitor_chandef;
121677diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
121678index b12f615..a264a60 100644
121679--- a/net/mac80211/ieee80211_i.h
121680+++ b/net/mac80211/ieee80211_i.h
121681@@ -30,6 +30,7 @@
121682 #include <net/ieee80211_radiotap.h>
121683 #include <net/cfg80211.h>
121684 #include <net/mac80211.h>
121685+#include <asm/local.h>
121686 #include "key.h"
121687 #include "sta_info.h"
121688 #include "debug.h"
121689@@ -1112,7 +1113,7 @@ struct ieee80211_local {
121690 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
121691 spinlock_t queue_stop_reason_lock;
121692
121693- int open_count;
121694+ local_t open_count;
121695 int monitors, cooked_mntrs;
121696 /* number of interfaces with corresponding FIF_ flags */
121697 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
121698diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
121699index 553ac6d..d2480da 100644
121700--- a/net/mac80211/iface.c
121701+++ b/net/mac80211/iface.c
121702@@ -550,7 +550,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121703 break;
121704 }
121705
121706- if (local->open_count == 0) {
121707+ if (local_read(&local->open_count) == 0) {
121708 res = drv_start(local);
121709 if (res)
121710 goto err_del_bss;
121711@@ -597,7 +597,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121712 res = drv_add_interface(local, sdata);
121713 if (res)
121714 goto err_stop;
121715- } else if (local->monitors == 0 && local->open_count == 0) {
121716+ } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
121717 res = ieee80211_add_virtual_monitor(local);
121718 if (res)
121719 goto err_stop;
121720@@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121721 atomic_inc(&local->iff_allmultis);
121722
121723 if (coming_up)
121724- local->open_count++;
121725+ local_inc(&local->open_count);
121726
121727 if (hw_reconf_flags)
121728 ieee80211_hw_config(local, hw_reconf_flags);
121729@@ -742,7 +742,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121730 err_del_interface:
121731 drv_remove_interface(local, sdata);
121732 err_stop:
121733- if (!local->open_count)
121734+ if (!local_read(&local->open_count))
121735 drv_stop(local);
121736 err_del_bss:
121737 sdata->bss = NULL;
121738@@ -909,7 +909,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121739 }
121740
121741 if (going_down)
121742- local->open_count--;
121743+ local_dec(&local->open_count);
121744
121745 switch (sdata->vif.type) {
121746 case NL80211_IFTYPE_AP_VLAN:
121747@@ -978,7 +978,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121748 atomic_set(&sdata->txqs_len[txqi->txq.ac], 0);
121749 }
121750
121751- if (local->open_count == 0)
121752+ if (local_read(&local->open_count) == 0)
121753 ieee80211_clear_tx_pending(local);
121754
121755 /*
121756@@ -1021,7 +1021,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121757 if (cancel_scan)
121758 flush_delayed_work(&local->scan_work);
121759
121760- if (local->open_count == 0) {
121761+ if (local_read(&local->open_count) == 0) {
121762 ieee80211_stop_device(local);
121763
121764 /* no reconfiguring after stop! */
121765@@ -1032,7 +1032,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121766 ieee80211_configure_filter(local);
121767 ieee80211_hw_config(local, hw_reconf_flags);
121768
121769- if (local->monitors == local->open_count)
121770+ if (local->monitors == local_read(&local->open_count))
121771 ieee80211_add_virtual_monitor(local);
121772 }
121773
121774@@ -1884,8 +1884,8 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local)
121775 */
121776 cfg80211_shutdown_all_interfaces(local->hw.wiphy);
121777
121778- WARN(local->open_count, "%s: open count remains %d\n",
121779- wiphy_name(local->hw.wiphy), local->open_count);
121780+ WARN(local_read(&local->open_count), "%s: open count remains %ld\n",
121781+ wiphy_name(local->hw.wiphy), local_read(&local->open_count));
121782
121783 mutex_lock(&local->iflist_mtx);
121784 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
121785diff --git a/net/mac80211/main.c b/net/mac80211/main.c
121786index 3c63468..b5c285f 100644
121787--- a/net/mac80211/main.c
121788+++ b/net/mac80211/main.c
121789@@ -172,7 +172,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
121790 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
121791 IEEE80211_CONF_CHANGE_POWER);
121792
121793- if (changed && local->open_count) {
121794+ if (changed && local_read(&local->open_count)) {
121795 ret = drv_config(local, changed);
121796 /*
121797 * Goal:
121798diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
121799index b676b9f..395dd95 100644
121800--- a/net/mac80211/pm.c
121801+++ b/net/mac80211/pm.c
121802@@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
121803 struct ieee80211_sub_if_data *sdata;
121804 struct sta_info *sta;
121805
121806- if (!local->open_count)
121807+ if (!local_read(&local->open_count))
121808 goto suspend;
121809
121810 ieee80211_scan_cancel(local);
121811@@ -166,7 +166,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
121812 WARN_ON(!list_empty(&local->chanctx_list));
121813
121814 /* stop hardware - this must stop RX */
121815- if (local->open_count)
121816+ if (local_read(&local->open_count))
121817 ieee80211_stop_device(local);
121818
121819 suspend:
121820diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
121821index fda33f9..0e7d4c0 100644
121822--- a/net/mac80211/rate.c
121823+++ b/net/mac80211/rate.c
121824@@ -730,7 +730,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
121825
121826 ASSERT_RTNL();
121827
121828- if (local->open_count)
121829+ if (local_read(&local->open_count))
121830 return -EBUSY;
121831
121832 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
121833diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
121834index 666ddac..0cad93b 100644
121835--- a/net/mac80211/sta_info.c
121836+++ b/net/mac80211/sta_info.c
121837@@ -341,7 +341,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
121838 int size = sizeof(struct txq_info) +
121839 ALIGN(hw->txq_data_size, sizeof(void *));
121840
121841- txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp);
121842+ txq_data = kcalloc(size, ARRAY_SIZE(sta->sta.txq), gfp);
121843 if (!txq_data)
121844 goto free;
121845
121846diff --git a/net/mac80211/util.c b/net/mac80211/util.c
121847index 43e5aad..d117c3a 100644
121848--- a/net/mac80211/util.c
121849+++ b/net/mac80211/util.c
121850@@ -1761,7 +1761,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121851 bool sched_scan_stopped = false;
121852
121853 /* nothing to do if HW shouldn't run */
121854- if (!local->open_count)
121855+ if (!local_read(&local->open_count))
121856 goto wake_up;
121857
121858 #ifdef CONFIG_PM
121859@@ -2033,7 +2033,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121860 local->in_reconfig = false;
121861 barrier();
121862
121863- if (local->monitors == local->open_count && local->monitors > 0)
121864+ if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
121865 ieee80211_add_virtual_monitor(local);
121866
121867 /*
121868@@ -2088,7 +2088,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121869 * If this is for hw restart things are still running.
121870 * We may want to change that later, however.
121871 */
121872- if (local->open_count && (!local->suspended || reconfig_due_to_wowlan))
121873+ if (local_read(&local->open_count) && (!local->suspended || reconfig_due_to_wowlan))
121874 drv_reconfig_complete(local, IEEE80211_RECONFIG_TYPE_RESTART);
121875
121876 if (!local->suspended)
121877@@ -2112,7 +2112,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121878 flush_delayed_work(&local->scan_work);
121879 }
121880
121881- if (local->open_count && !reconfig_due_to_wowlan)
121882+ if (local_read(&local->open_count) && !reconfig_due_to_wowlan)
121883 drv_reconfig_complete(local, IEEE80211_RECONFIG_TYPE_SUSPEND);
121884
121885 list_for_each_entry(sdata, &local->interfaces, list) {
121886diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
121887index 1f93a59..96faa29 100644
121888--- a/net/mpls/af_mpls.c
121889+++ b/net/mpls/af_mpls.c
121890@@ -456,7 +456,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
121891 struct mpls_dev *mdev)
121892 {
121893 char path[sizeof("net/mpls/conf/") + IFNAMSIZ];
121894- struct ctl_table *table;
121895+ ctl_table_no_const *table;
121896 int i;
121897
121898 table = kmemdup(&mpls_dev_table, sizeof(mpls_dev_table), GFP_KERNEL);
121899@@ -1025,7 +1025,7 @@ static int mpls_platform_labels(struct ctl_table *table, int write,
121900 struct net *net = table->data;
121901 int platform_labels = net->mpls.platform_labels;
121902 int ret;
121903- struct ctl_table tmp = {
121904+ ctl_table_no_const tmp = {
121905 .procname = table->procname,
121906 .data = &platform_labels,
121907 .maxlen = sizeof(int),
121908@@ -1055,7 +1055,7 @@ static const struct ctl_table mpls_table[] = {
121909
121910 static int mpls_net_init(struct net *net)
121911 {
121912- struct ctl_table *table;
121913+ ctl_table_no_const *table;
121914
121915 net->mpls.platform_labels = 0;
121916 net->mpls.platform_label = NULL;
121917diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
121918index 6eae69a..ccccba8 100644
121919--- a/net/netfilter/Kconfig
121920+++ b/net/netfilter/Kconfig
121921@@ -1125,6 +1125,16 @@ config NETFILTER_XT_MATCH_ESP
121922
121923 To compile it as a module, choose M here. If unsure, say N.
121924
121925+config NETFILTER_XT_MATCH_GRADM
121926+ tristate '"gradm" match support'
121927+ depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
121928+ depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
121929+ ---help---
121930+ The gradm match allows to match on grsecurity RBAC being enabled.
121931+ It is useful when iptables rules are applied early on bootup to
121932+ prevent connections to the machine (except from a trusted host)
121933+ while the RBAC system is disabled.
121934+
121935 config NETFILTER_XT_MATCH_HASHLIMIT
121936 tristate '"hashlimit" match support'
121937 depends on IP6_NF_IPTABLES || IP6_NF_IPTABLES=n
121938diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
121939index 70d026d..c400590 100644
121940--- a/net/netfilter/Makefile
121941+++ b/net/netfilter/Makefile
121942@@ -140,6 +140,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
121943 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
121944 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
121945 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
121946+obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
121947 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
121948 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
121949 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
121950diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
121951index 338b404..839dcb0 100644
121952--- a/net/netfilter/ipset/ip_set_core.c
121953+++ b/net/netfilter/ipset/ip_set_core.c
121954@@ -1998,7 +1998,7 @@ done:
121955 return ret;
121956 }
121957
121958-static struct nf_sockopt_ops so_set __read_mostly = {
121959+static struct nf_sockopt_ops so_set = {
121960 .pf = PF_INET,
121961 .get_optmin = SO_IP_SET,
121962 .get_optmax = SO_IP_SET + 1,
121963diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
121964index b0f7b62..0541842 100644
121965--- a/net/netfilter/ipvs/ip_vs_conn.c
121966+++ b/net/netfilter/ipvs/ip_vs_conn.c
121967@@ -572,7 +572,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
121968 /* Increase the refcnt counter of the dest */
121969 ip_vs_dest_hold(dest);
121970
121971- conn_flags = atomic_read(&dest->conn_flags);
121972+ conn_flags = atomic_read_unchecked(&dest->conn_flags);
121973 if (cp->protocol != IPPROTO_UDP)
121974 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
121975 flags = cp->flags;
121976@@ -922,7 +922,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p, int dest_af,
121977
121978 cp->control = NULL;
121979 atomic_set(&cp->n_control, 0);
121980- atomic_set(&cp->in_pkts, 0);
121981+ atomic_set_unchecked(&cp->in_pkts, 0);
121982
121983 cp->packet_xmit = NULL;
121984 cp->app = NULL;
121985@@ -1229,7 +1229,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
121986
121987 /* Don't drop the entry if its number of incoming packets is not
121988 located in [0, 8] */
121989- i = atomic_read(&cp->in_pkts);
121990+ i = atomic_read_unchecked(&cp->in_pkts);
121991 if (i > 8 || i < 0) return 0;
121992
121993 if (!todrop_rate[i]) return 0;
121994diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
121995index 38fbc19..4272cb4 100644
121996--- a/net/netfilter/ipvs/ip_vs_core.c
121997+++ b/net/netfilter/ipvs/ip_vs_core.c
121998@@ -586,7 +586,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
121999 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
122000 /* do not touch skb anymore */
122001
122002- atomic_inc(&cp->in_pkts);
122003+ atomic_inc_unchecked(&cp->in_pkts);
122004 ip_vs_conn_put(cp);
122005 return ret;
122006 }
122007@@ -1762,7 +1762,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
122008 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
122009 pkts = sysctl_sync_threshold(ipvs);
122010 else
122011- pkts = atomic_add_return(1, &cp->in_pkts);
122012+ pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
122013
122014 if (ipvs->sync_state & IP_VS_STATE_MASTER)
122015 ip_vs_sync_conn(net, cp, pkts);
122016diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
122017index 24c5542..e9fd3e5 100644
122018--- a/net/netfilter/ipvs/ip_vs_ctl.c
122019+++ b/net/netfilter/ipvs/ip_vs_ctl.c
122020@@ -814,7 +814,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
122021 */
122022 ip_vs_rs_hash(ipvs, dest);
122023 }
122024- atomic_set(&dest->conn_flags, conn_flags);
122025+ atomic_set_unchecked(&dest->conn_flags, conn_flags);
122026
122027 /* bind the service */
122028 old_svc = rcu_dereference_protected(dest->svc, 1);
122029@@ -1694,7 +1694,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
122030 * align with netns init in ip_vs_control_net_init()
122031 */
122032
122033-static struct ctl_table vs_vars[] = {
122034+static ctl_table_no_const vs_vars[] __read_only = {
122035 {
122036 .procname = "amemthresh",
122037 .maxlen = sizeof(int),
122038@@ -2036,7 +2036,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
122039 " %-7s %-6d %-10d %-10d\n",
122040 &dest->addr.in6,
122041 ntohs(dest->port),
122042- ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
122043+ ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
122044 atomic_read(&dest->weight),
122045 atomic_read(&dest->activeconns),
122046 atomic_read(&dest->inactconns));
122047@@ -2047,7 +2047,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
122048 "%-7s %-6d %-10d %-10d\n",
122049 ntohl(dest->addr.ip),
122050 ntohs(dest->port),
122051- ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
122052+ ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
122053 atomic_read(&dest->weight),
122054 atomic_read(&dest->activeconns),
122055 atomic_read(&dest->inactconns));
122056@@ -2546,7 +2546,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
122057
122058 entry.addr = dest->addr.ip;
122059 entry.port = dest->port;
122060- entry.conn_flags = atomic_read(&dest->conn_flags);
122061+ entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
122062 entry.weight = atomic_read(&dest->weight);
122063 entry.u_threshold = dest->u_threshold;
122064 entry.l_threshold = dest->l_threshold;
122065@@ -3121,7 +3121,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
122066 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
122067 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
122068 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
122069- (atomic_read(&dest->conn_flags) &
122070+ (atomic_read_unchecked(&dest->conn_flags) &
122071 IP_VS_CONN_F_FWD_MASK)) ||
122072 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
122073 atomic_read(&dest->weight)) ||
122074@@ -3759,7 +3759,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
122075 {
122076 int idx;
122077 struct netns_ipvs *ipvs = net_ipvs(net);
122078- struct ctl_table *tbl;
122079+ ctl_table_no_const *tbl;
122080
122081 atomic_set(&ipvs->dropentry, 0);
122082 spin_lock_init(&ipvs->dropentry_lock);
122083diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
122084index 127f140..553d652 100644
122085--- a/net/netfilter/ipvs/ip_vs_lblc.c
122086+++ b/net/netfilter/ipvs/ip_vs_lblc.c
122087@@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
122088 * IPVS LBLC sysctl table
122089 */
122090 #ifdef CONFIG_SYSCTL
122091-static struct ctl_table vs_vars_table[] = {
122092+static ctl_table_no_const vs_vars_table[] __read_only = {
122093 {
122094 .procname = "lblc_expiration",
122095 .data = NULL,
122096diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
122097index 2229d2d..b32b785 100644
122098--- a/net/netfilter/ipvs/ip_vs_lblcr.c
122099+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
122100@@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
122101 * IPVS LBLCR sysctl table
122102 */
122103
122104-static struct ctl_table vs_vars_table[] = {
122105+static ctl_table_no_const vs_vars_table[] __read_only = {
122106 {
122107 .procname = "lblcr_expiration",
122108 .data = NULL,
122109diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
122110index d99ad93..09bd6dc 100644
122111--- a/net/netfilter/ipvs/ip_vs_sync.c
122112+++ b/net/netfilter/ipvs/ip_vs_sync.c
122113@@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
122114 cp = cp->control;
122115 if (cp) {
122116 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
122117- pkts = atomic_add_return(1, &cp->in_pkts);
122118+ pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
122119 else
122120 pkts = sysctl_sync_threshold(ipvs);
122121 ip_vs_sync_conn(net, cp, pkts);
122122@@ -771,7 +771,7 @@ control:
122123 if (!cp)
122124 return;
122125 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
122126- pkts = atomic_add_return(1, &cp->in_pkts);
122127+ pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
122128 else
122129 pkts = sysctl_sync_threshold(ipvs);
122130 goto sloop;
122131@@ -919,7 +919,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
122132
122133 if (opt)
122134 memcpy(&cp->in_seq, opt, sizeof(*opt));
122135- atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
122136+ atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
122137 cp->state = state;
122138 cp->old_state = cp->state;
122139 /*
122140diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
122141index 258a0b0..2082f50 100644
122142--- a/net/netfilter/ipvs/ip_vs_xmit.c
122143+++ b/net/netfilter/ipvs/ip_vs_xmit.c
122144@@ -1259,7 +1259,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
122145 else
122146 rc = NF_ACCEPT;
122147 /* do not touch skb anymore */
122148- atomic_inc(&cp->in_pkts);
122149+ atomic_inc_unchecked(&cp->in_pkts);
122150 goto out;
122151 }
122152
122153@@ -1352,7 +1352,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
122154 else
122155 rc = NF_ACCEPT;
122156 /* do not touch skb anymore */
122157- atomic_inc(&cp->in_pkts);
122158+ atomic_inc_unchecked(&cp->in_pkts);
122159 goto out;
122160 }
122161
122162diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
122163index 45da11a..ef3e5dc 100644
122164--- a/net/netfilter/nf_conntrack_acct.c
122165+++ b/net/netfilter/nf_conntrack_acct.c
122166@@ -64,7 +64,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
122167 #ifdef CONFIG_SYSCTL
122168 static int nf_conntrack_acct_init_sysctl(struct net *net)
122169 {
122170- struct ctl_table *table;
122171+ ctl_table_no_const *table;
122172
122173 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
122174 GFP_KERNEL);
122175diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
122176index 0625a42..b2c15f4 100644
122177--- a/net/netfilter/nf_conntrack_core.c
122178+++ b/net/netfilter/nf_conntrack_core.c
122179@@ -1754,6 +1754,10 @@ void nf_conntrack_init_end(void)
122180 #define DYING_NULLS_VAL ((1<<30)+1)
122181 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
122182
122183+#ifdef CONFIG_GRKERNSEC_HIDESYM
122184+static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
122185+#endif
122186+
122187 int nf_conntrack_init_net(struct net *net)
122188 {
122189 int ret = -ENOMEM;
122190@@ -1778,7 +1782,11 @@ int nf_conntrack_init_net(struct net *net)
122191 if (!net->ct.stat)
122192 goto err_pcpu_lists;
122193
122194+#ifdef CONFIG_GRKERNSEC_HIDESYM
122195+ net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08x", atomic_inc_return_unchecked(&conntrack_cache_id));
122196+#else
122197 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
122198+#endif
122199 if (!net->ct.slabname)
122200 goto err_slabname;
122201
122202diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
122203index 4e78c57..ec8fb74 100644
122204--- a/net/netfilter/nf_conntrack_ecache.c
122205+++ b/net/netfilter/nf_conntrack_ecache.c
122206@@ -264,7 +264,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
122207 #ifdef CONFIG_SYSCTL
122208 static int nf_conntrack_event_init_sysctl(struct net *net)
122209 {
122210- struct ctl_table *table;
122211+ ctl_table_no_const *table;
122212
122213 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
122214 GFP_KERNEL);
122215diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
122216index bd9d315..989947e 100644
122217--- a/net/netfilter/nf_conntrack_helper.c
122218+++ b/net/netfilter/nf_conntrack_helper.c
122219@@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
122220
122221 static int nf_conntrack_helper_init_sysctl(struct net *net)
122222 {
122223- struct ctl_table *table;
122224+ ctl_table_no_const *table;
122225
122226 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
122227 GFP_KERNEL);
122228diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
122229index b65d586..beec902 100644
122230--- a/net/netfilter/nf_conntrack_proto.c
122231+++ b/net/netfilter/nf_conntrack_proto.c
122232@@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
122233
122234 static void
122235 nf_ct_unregister_sysctl(struct ctl_table_header **header,
122236- struct ctl_table **table,
122237+ ctl_table_no_const **table,
122238 unsigned int users)
122239 {
122240 if (users > 0)
122241diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
122242index fc823fa..8311af3 100644
122243--- a/net/netfilter/nf_conntrack_standalone.c
122244+++ b/net/netfilter/nf_conntrack_standalone.c
122245@@ -468,7 +468,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
122246
122247 static int nf_conntrack_standalone_init_sysctl(struct net *net)
122248 {
122249- struct ctl_table *table;
122250+ ctl_table_no_const *table;
122251
122252 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
122253 GFP_KERNEL);
122254diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
122255index 7a394df..bd91a8a 100644
122256--- a/net/netfilter/nf_conntrack_timestamp.c
122257+++ b/net/netfilter/nf_conntrack_timestamp.c
122258@@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
122259 #ifdef CONFIG_SYSCTL
122260 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
122261 {
122262- struct ctl_table *table;
122263+ ctl_table_no_const *table;
122264
122265 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
122266 GFP_KERNEL);
122267diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
122268index a5d41df..1ff49be 100644
122269--- a/net/netfilter/nf_log.c
122270+++ b/net/netfilter/nf_log.c
122271@@ -391,7 +391,7 @@ static const struct file_operations nflog_file_ops = {
122272
122273 #ifdef CONFIG_SYSCTL
122274 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
122275-static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
122276+static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
122277
122278 static int nf_log_proc_dostring(struct ctl_table *table, int write,
122279 void __user *buffer, size_t *lenp, loff_t *ppos)
122280@@ -422,13 +422,15 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
122281 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
122282 mutex_unlock(&nf_log_mutex);
122283 } else {
122284+ ctl_table_no_const nf_log_table = *table;
122285+
122286 mutex_lock(&nf_log_mutex);
122287 logger = nft_log_dereference(net->nf.nf_loggers[tindex]);
122288 if (!logger)
122289- table->data = "NONE";
122290+ nf_log_table.data = "NONE";
122291 else
122292- table->data = logger->name;
122293- r = proc_dostring(table, write, buffer, lenp, ppos);
122294+ nf_log_table.data = logger->name;
122295+ r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
122296 mutex_unlock(&nf_log_mutex);
122297 }
122298
122299diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
122300index c68c1e5..8b5d670 100644
122301--- a/net/netfilter/nf_sockopt.c
122302+++ b/net/netfilter/nf_sockopt.c
122303@@ -43,7 +43,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
122304 }
122305 }
122306
122307- list_add(&reg->list, &nf_sockopts);
122308+ pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
122309 out:
122310 mutex_unlock(&nf_sockopt_mutex);
122311 return ret;
122312@@ -53,7 +53,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
122313 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
122314 {
122315 mutex_lock(&nf_sockopt_mutex);
122316- list_del(&reg->list);
122317+ pax_list_del((struct list_head *)&reg->list);
122318 mutex_unlock(&nf_sockopt_mutex);
122319 }
122320 EXPORT_SYMBOL(nf_unregister_sockopt);
122321diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
122322index 4670821..a6c3c47d 100644
122323--- a/net/netfilter/nfnetlink_log.c
122324+++ b/net/netfilter/nfnetlink_log.c
122325@@ -84,7 +84,7 @@ static int nfnl_log_net_id __read_mostly;
122326 struct nfnl_log_net {
122327 spinlock_t instances_lock;
122328 struct hlist_head instance_table[INSTANCE_BUCKETS];
122329- atomic_t global_seq;
122330+ atomic_unchecked_t global_seq;
122331 };
122332
122333 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
122334@@ -572,7 +572,7 @@ __build_packet_message(struct nfnl_log_net *log,
122335 /* global sequence number */
122336 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
122337 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
122338- htonl(atomic_inc_return(&log->global_seq))))
122339+ htonl(atomic_inc_return_unchecked(&log->global_seq))))
122340 goto nla_put_failure;
122341
122342 if (data_len) {
122343diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
122344index 9c8fab0..5080c7c 100644
122345--- a/net/netfilter/nft_compat.c
122346+++ b/net/netfilter/nft_compat.c
122347@@ -322,14 +322,7 @@ static void nft_match_eval(const struct nft_expr *expr,
122348 return;
122349 }
122350
122351- switch (ret ? 1 : 0) {
122352- case 1:
122353- regs->verdict.code = NFT_CONTINUE;
122354- break;
122355- case 0:
122356- regs->verdict.code = NFT_BREAK;
122357- break;
122358- }
122359+ regs->verdict.code = ret ? NFT_CONTINUE : NFT_BREAK;
122360 }
122361
122362 static const struct nla_policy nft_match_policy[NFTA_MATCH_MAX + 1] = {
122363diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
122364new file mode 100644
122365index 0000000..c566332
122366--- /dev/null
122367+++ b/net/netfilter/xt_gradm.c
122368@@ -0,0 +1,51 @@
122369+/*
122370+ * gradm match for netfilter
122371